vexflow 4.0.1-rc.0 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * VexFlow 4.0.1-rc.0 2022-03-21T22:34:31.158Z 1d341b5910cee7245c9b99a193f529ec38b80168
2
+ * VexFlow 4.0.1 2022-03-24T20:35:28.447Z 409af72ce03dd6da1919ee6c7de72c62aac0644e
3
3
  * Copyright (c) 2010 Mohit Muthanna Cheppudira <mohit@muthanna.com>
4
4
  * https://www.vexflow.com https://github.com/0xfe/vexflow
5
5
  */
6
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Vex=e():t.Vex=e()}("undefined"!=typeof window?window:"undefined"!=typeof globalThis?globalThis:this,(function(){return(()=>{"use strict";var t={d:(e,i)=>{for(var s in i)t.o(i,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:i[s]})}};t.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),t.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),t.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var e={};t.d(e,{default:()=>i});var i={};function s(t,e,i=!0){if("object"!=typeof t||null===t)return!1;let s=t.constructor;if(i){for(;null!==t;){if(s=t.constructor,"CATEGORY"in s&&s.CATEGORY===e)return!0;t=Object.getPrototypeOf(t)}return!1}return"CATEGORY"in s&&s.CATEGORY===e}t.r(i),t.d(i,{Accidental:()=>st,Annotation:()=>lt,AnnotationHorizontalJustify:()=>ct,AnnotationVerticalJustify:()=>dt,Articulation:()=>xt,BEAM_BOTH:()=>Le,BEAM_LEFT:()=>Re,BEAM_RIGHT:()=>Oe,BarNote:()=>Ft,Barline:()=>Pt,BarlineType:()=>vt,Beam:()=>Ie,Bend:()=>Mt,BoundingBox:()=>C,BoundingBoxComputation:()=>N,Builder:()=>$e,CanvasContext:()=>Qt,Category:()=>m,ChordSymbol:()=>Rt,ChordSymbolHorizontalJustify:()=>Et,ChordSymbolVerticalJustify:()=>Ct,Clef:()=>ue,ClefNote:()=>We,Crescendo:()=>Ge,Curve:()=>He,CurvePosition:()=>Ue,Dot:()=>Ot,EasyScore:()=>Ze,EasyScoreGrammar:()=>ze,Element:()=>O,Factory:()=>vi,Flow:()=>Fi,Font:()=>M,FontStyle:()=>D,FontWeight:()=>k,Formatter:()=>Pe,Fraction:()=>v,FretHandFinger:()=>Lt,GhostNote:()=>ei,Glyph:()=>U,GlyphNote:()=>ii,GraceNote:()=>si,GraceNoteGroup:()=>Ut,GraceTabNote:()=>Ei,KeyManager:()=>Ci,KeySigNote:()=>ni,KeySignature:()=>pe,Modifier:()=>H,ModifierContext:()=>ge,ModifierPosition:()=>I,MultiMeasureRest:()=>oi,Music:()=>Y,Note:()=>bt,NoteHead:()=>Vt,NoteSubGroup:()=>Ht,Ornament:()=>jt,OutlineCode:()=>L,Parenthesis:()=>Xt,Parser:()=>Xe,PedalMarking:()=>hi,Piece:()=>Ke,Registry:()=>R,RenderContext:()=>St,Renderer:()=>re,RendererBackends:()=>se,RendererLineEndType:()=>ne,RepeatNote:()=>di,Repetition:()=>me,RuntimeError:()=>f,SVGContext:()=>ie,Stave:()=>Ee,StaveConnector:()=>Ne,StaveHairpin:()=>Ni,StaveLine:()=>gi,StaveModifier:()=>At,StaveModifierPosition:()=>wt,StaveNote:()=>$t,StaveSection:()=>fe,StaveTempo:()=>_e,StaveText:()=>Se,StaveTie:()=>It,Stem:()=>nt,StemmableNote:()=>zt,StringNumber:()=>he,Stroke:()=>ce,SymbolModifiers:()=>kt,SymbolTypes:()=>Nt,System:()=>ui,TabNote:()=>pi,TabSlide:()=>ki,TabStave:()=>mi,TabTie:()=>Wt,TextBracket:()=>xi,TextBracketPosition:()=>_i,TextDynamics:()=>yi,TextFormatter:()=>ht,TextJustification:()=>ae,TextNote:()=>xe,TickContext:()=>Yt,Tickable:()=>Tt,TimeSigNote:()=>Ti,TimeSignature:()=>be,TimeSignatureGlyph:()=>Te,Tremolo:()=>Di,Tuning:()=>Ai,Tuplet:()=>Me,TupletLocation:()=>Fe,Vex:()=>Ri,Vibrato:()=>de,VibratoBracket:()=>bi,Voice:()=>Gt,VoiceMode:()=>Dt,Volta:()=>ye,VoltaType:()=>oe,defined:()=>x,drawDot:()=>yt,globalObject:()=>_,isAccidental:()=>n,isAnnotation:()=>a,isBarline:()=>o,isCategory:()=>s,isDot:()=>r,isGraceNote:()=>h,isGraceNoteGroup:()=>c,isHTMLCanvas:()=>Jt,isHTMLDiv:()=>qt,isNote:()=>d,isRenderContext:()=>l,isStaveNote:()=>g,isStemmableNote:()=>u,isTabNote:()=>p,log:()=>S,midLine:()=>T,normalizeAngle:()=>w,prefix:()=>b,warn:()=>y});const n=t=>s(t,m.Accidental),a=t=>s(t,m.Annotation),o=t=>s(t,m.Barline),r=t=>s(t,m.Dot),h=t=>s(t,m.GraceNote),c=t=>s(t,m.GraceNoteGroup),d=t=>s(t,m.Note),l=t=>s(t,m.RenderContext),g=t=>s(t,m.StaveNote),u=t=>s(t,m.StemmableNote),p=t=>s(t,m.TabNote);var m;!function(t){t.Accidental="Accidental",t.Annotation="Annotation",t.Articulation="Articulation",t.Barline="Barline",t.BarNote="BarNote",t.Beam="Beam",t.Bend="Bend",t.ChordSymbol="ChordSymbol",t.Clef="Clef",t.ClefNote="ClefNote",t.Crescendo="Crescendo",t.Curve="Curve",t.Dot="Dot",t.Element="Element",t.Fraction="Fraction",t.FretHandFinger="FretHandFinger",t.GhostNote="GhostNote",t.Glyph="Glyph",t.GlyphNote="GlyphNote",t.GraceNote="GraceNote",t.GraceNoteGroup="GraceNoteGroup",t.GraceTabNote="GraceTabNote",t.KeySignature="KeySignature",t.KeySigNote="KeySigNote",t.Modifier="Modifier",t.MultiMeasureRest="MultiMeasureRest",t.Note="Note",t.NoteHead="NoteHead",t.NoteSubGroup="NoteSubGroup",t.Ornament="Ornament",t.Parenthesis="Parenthesis",t.PedalMarking="PedalMarking",t.RenderContext="RenderContext",t.RepeatNote="RepeatNote",t.Repetition="Repetition",t.Stave="Stave",t.StaveConnector="StaveConnector",t.StaveHairpin="StaveHairpin",t.StaveLine="StaveLine",t.StaveModifier="StaveModifier",t.StaveNote="StaveNote",t.StaveSection="StaveSection",t.StaveTempo="StaveTempo",t.StaveText="StaveText",t.StaveTie="StaveTie",t.Stem="Stem",t.StemmableNote="StemmableNote",t.StringNumber="StringNumber",t.Stroke="Stroke",t.System="System",t.TabNote="TabNote",t.TabSlide="TabSlide",t.TabStave="TabStave",t.TabTie="TabTie",t.TextBracket="TextBracket",t.TextDynamics="TextDynamics",t.TextNote="TextNote",t.Tickable="Tickable",t.TimeSignature="TimeSignature",t.TimeSigNote="TimeSigNote",t.Tremolo="Tremolo",t.Tuplet="Tuplet",t.Vibrato="Vibrato",t.VibratoBracket="VibratoBracket",t.Voice="Voice",t.Volta="Volta"}(m||(m={}));class f extends Error{constructor(t,e=""){super("[RuntimeError] "+t+": "+e),this.code=t}}function _(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==t.g?t.g:Function("return this")()}function x(t,e="undefined",i=""){if(void 0===t)throw new f(e,i);return t}function S(t,...e){if(!e)return;const i=Array.prototype.slice.call(e).join(" ");_().console.log(t+": "+i)}function y(...t){const e=t.join(" "),i=new Error;_().console.log("Warning: ",e,i.stack)}function T(t,e){let i=e+(t-e)/2;var s,n;return i%2>0&&(i=((s=10*i)%(n=5)>=n/2?parseInt(""+s/n,10)*n+n:parseInt(""+s/n,10)*n)/10),i}function b(t){return`vf-${t}`}function w(t){return(t%=2*Math.PI)<0&&(t+=2*Math.PI),t}class v{constructor(t,e){this.numerator=1,this.denominator=1,this.set(t,e)}static get CATEGORY(){return m.Fraction}static GCD(t,e){if("number"!=typeof t||Number.isNaN(t)||"number"!=typeof e||Number.isNaN(e))throw new f("BadArgument",`Invalid numbers: ${t}, ${e}`);let i;for(;0!==e;)i=e,e=t%e,t=i;return t}static LCM(t,e){return t*e/v.GCD(t,e)}static LCMM(t){return 0===t.length?0:1===t.length?t[0]:2===t.length?v.LCM(t[0],t[1]):v.LCM(t.shift(),v.LCMM(t))}set(t=1,e=1){return this.numerator=t,this.denominator=e,this}value(){return this.numerator/this.denominator}simplify(){let t=this.numerator,e=this.denominator;const i=v.GCD(t,e);return t/=i,e/=i,e<0&&(e=-e,t=-t),this.set(t,e)}add(t=0,e=1){const[i,s]=E(t,e),n=v.LCM(this.denominator,s),a=n/this.denominator,o=n/s,r=this.numerator*a+i*o;return this.set(r,n)}subtract(t=0,e=1){const[i,s]=E(t,e),n=v.LCM(this.denominator,s),a=n/this.denominator,o=n/s,r=this.numerator*a-i*o;return this.set(r,n)}multiply(t=1,e=1){const[i,s]=E(t,e);return this.set(this.numerator*i,this.denominator*s)}divide(t=1,e=1){const[i,s]=E(t,e);return this.set(this.numerator*s,this.denominator*i)}equals(t){const e=v.__staticFractionA.copy(t).simplify(),i=v.__staticFractionB.copy(this).simplify();return e.numerator===i.numerator&&e.denominator===i.denominator}greaterThan(t){const e=v.__staticFractionB.copy(this);return e.subtract(t),e.numerator>0}greaterThanEquals(t){const e=v.__staticFractionB.copy(this);return e.subtract(t),e.numerator>=0}lessThan(t){return!this.greaterThanEquals(t)}lessThanEquals(t){return!this.greaterThan(t)}clone(){return new v(this.numerator,this.denominator)}copy(t){return"number"==typeof t?this.set(t,1):this.set(t.numerator,t.denominator)}quotient(){return Math.floor(this.numerator/this.denominator)}remainder(){return this.numerator%this.denominator}makeAbs(){return this.denominator=Math.abs(this.denominator),this.numerator=Math.abs(this.numerator),this}toString(){return`${this.numerator}/${this.denominator}`}toSimplifiedString(){return v.__staticFractionTmp.copy(this).simplify().toString()}toMixedString(){let t="";const e=this.quotient(),i=v.__staticFractionTmp.copy(this);return e<0&&i.makeAbs(),0!==e?(t+=e,0!==i.numerator&&(t+=` ${i.toSimplifiedString()}`)):t=0===i.numerator?"0":i.toSimplifiedString(),t}parse(t){const e=t.split("/"),i=parseInt(e[0],10),s=e[1]?parseInt(e[1],10):1;return this.set(i,s)}}function E(t,e=1){return"number"==typeof t?[t,e]:[t.numerator,t.denominator]}v.__staticFractionA=new v,v.__staticFractionB=new v,v.__staticFractionTmp=new v;class C{constructor(t,e,i,s){this.x=t,this.y=e,this.w=i,this.h=s}static copy(t){return new C(t.x,t.y,t.w,t.h)}getX(){return this.x}getY(){return this.y}getW(){return this.w}getH(){return this.h}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setW(t){return this.w=t,this}setH(t){return this.h=t,this}move(t,e){return this.x+=t,this.y+=e,this}clone(){return C.copy(this)}mergeWith(t){const e=t,i=this.x<e.x?this.x:e.x,s=this.y<e.y?this.y:e.y,n=Math.max(this.x+this.w,e.x+e.w)-i,a=Math.max(this.y+this.h,e.y+e.h)-s;return this.x=i,this.y=s,this.w=n,this.h=a,this}}class N{constructor(){this.x1=Number.NaN,this.y1=Number.NaN,this.x2=Number.NaN,this.y2=Number.NaN}getX1(){return this.x1}getY1(){return this.y1}width(){return this.x2-this.x1}height(){return this.y2-this.y1}addPoint(t,e){(isNaN(this.x1)||t<this.x1)&&(this.x1=t),(isNaN(this.x2)||t>this.x2)&&(this.x2=t),(isNaN(this.y1)||e<this.y1)&&(this.y1=e),(isNaN(this.y2)||e>this.y2)&&(this.y2=e)}addX(t){this.addPoint(t,this.y1)}addY(t){this.addPoint(this.x1,t)}addQuadraticCurve(t,e,i,s,n,a){this.addPoint(t,e),this.addPoint(n,a);const o=i-t;let r=o-(n-i);if(0!=r){const e=o/r;if(e>0&&e<1){const s=1-e;this.addX(s*s*t+2*s*e*i+e*e*n)}}const h=s-e;if(r=h-(a-s),0!=r){const t=h/r;if(t>0&&t<1){const i=1-t;this.addY(i*i*e+2*i*t*s+t*t*a)}}}addBezierCurve(t,e,i,s,n,a,o,r){const h=[t,e],c=[i,s],d=[n,a],l=[o,r];let g;this.addPoint(h[0],h[1]),this.addPoint(l[0],l[1]);const u=(t,e)=>Math.pow(1-t,3)*h[e]+3*Math.pow(1-t,2)*t*c[e]+3*(1-t)*Math.pow(t,2)*d[e]+Math.pow(t,3)*l[e];for(g=0;g<=1;g++){const t=6*h[g]-12*c[g]+6*d[g],e=-3*h[g]+9*c[g]-9*d[g]+3*l[g],i=3*c[g]-3*h[g];if(0===e){if(0===t)continue;const e=-i/t;0<e&&e<1&&(0===g&&this.addX(u(e,g)),1===g&&this.addY(u(e,g)));continue}const s=Math.pow(t,2)-4*i*e;if(s<0)continue;const n=(-t+Math.sqrt(s))/(2*e);0<n&&n<1&&(0===g&&this.addX(u(n,g)),1===g&&this.addY(u(n,g)));const a=(-t-Math.sqrt(s))/(2*e);0<a&&a<1&&(0===g&&this.addX(u(a,g)),1===g&&this.addY(u(a,g)))}}}var k,D,A=function(t,e,i,s){return new(i||(i=Promise))((function(n,a){function o(t){try{h(s.next(t))}catch(t){a(t)}}function r(t){try{h(s.throw(t))}catch(t){a(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,r)}h((s=s.apply(t,e||[])).next())}))};let P;!function(t){t.NORMAL="normal",t.BOLD="bold"}(k||(k={})),function(t){t.NORMAL="normal",t.ITALIC="italic"}(D||(D={}));const F={};class M{constructor(t){this.name=t}static convertSizeToPixelValue(t=M.SIZE){var e;if("number"==typeof t)return t*M.scaleToPxFrom.pt;{const i=parseFloat(t);if(isNaN(i))return 0;const s=t.replace(/[\d.\s]/g,"").toLowerCase();return i*(null!==(e=M.scaleToPxFrom[s])&&void 0!==e?e:1)}}static convertSizeToPointValue(t=M.SIZE){var e;if("number"==typeof t)return t;{const i=parseFloat(t);if(isNaN(i))return 0;const s=t.replace(/[\d.\s]/g,"").toLowerCase();return i*((null!==(e=M.scaleToPxFrom[s])&&void 0!==e?e:1)/M.scaleToPxFrom.pt)}}static validate(t,e,i,s){if("string"==typeof t&&void 0===e&&void 0===i&&void 0===s)return M.fromCSSString(t);let n;return"object"==typeof t?(n=t.family,e=t.size,i=t.weight,s=t.style):n=t,n=null!=n?n:M.SANS_SERIF,e=null!=e?e:M.SIZE+"pt",i=null!=i?i:k.NORMAL,s=null!=s?s:D.NORMAL,""===i&&(i=k.NORMAL),""===s&&(s=D.NORMAL),"number"==typeof e&&(e=`${e}pt`),"number"==typeof i&&(i=i.toString()),{family:n,size:e,weight:i,style:s}}static fromCSSString(t){P||(P=document.createElement("span")),P.style.font=t;const{fontFamily:e,fontSize:i,fontWeight:s,fontStyle:n}=P.style;return{family:e,size:i,weight:s,style:n}}static toCSSString(t){var e;if(!t)return"";let i;const s=t.style;let n;i=s===D.NORMAL||""===s||void 0===s?"":s.trim()+" ";const a=t.weight;let o;n=a===k.NORMAL||""===a||void 0===a?"":"number"==typeof a?a+" ":a.trim()+" ";const r=t.size;o=void 0===r?M.SIZE+"pt ":"number"==typeof r?r+"pt ":r.trim()+" ";return`${i}${n}${o}${null!==(e=t.family)&&void 0!==e?e:M.SANS_SERIF}`}static scaleSize(t,e){if("number"==typeof t)return t*e;return`${parseFloat(t)*e}${t.replace(/[\d.\s]/g,"")}`}static isBold(t){if(t){if("number"==typeof t)return t>=600;{const e=parseInt(t,10);return isNaN(e)?"bold"===t.toLowerCase():e>=600}}return!1}static isItalic(t){return!!t&&t.toLowerCase()===D.ITALIC}static loadWebFont(t,e,i=!0){return A(this,void 0,void 0,(function*(){const s=new FontFace(t,(i?`url(${e}2) format('woff2'), `:"")+`url(${e}) format('woff')`);return yield s.load(),document.fonts.add(s),s}))}static loadWebFonts(){return A(this,void 0,void 0,(function*(){const t=M.WEB_FONT_HOST,e=M.WEB_FONT_FILES;for(const i in e){const s=e[i];M.loadWebFont(i,t+s)}}))}static load(t,e,i){let s=F[t];return s||(s=new M(t),F[t]=s),e&&s.setData(e),i&&s.setMetrics(i),s}getName(){return this.name}getData(){return x(this.data,"FontError","Missing font data")}getMetrics(){return x(this.metrics,"FontError","Missing metrics")}setData(t){this.data=t}setMetrics(t){this.metrics=t}hasData(){return void 0!==this.data}getResolution(){return this.getData().resolution}getGlyphs(){return this.getData().glyphs}lookupMetric(t,e){const i=t.split(".");let s=this.getMetrics();for(let t=0;t<i.length;t++){const n=s[i[t]];if(void 0===n)return e;s=n}return s}toString(){return"["+this.name+" Font]"}}M.SANS_SERIF="Arial, sans-serif",M.SERIF="Times New Roman, serif",M.SIZE=10,M.scaleToPxFrom={pt:4/3,px:1,em:16,"%":.16,in:96,mm:96/25.4,cm:96/2.54},M.WEB_FONT_HOST="https://unpkg.com/vexflow-fonts@1.0.3/",M.WEB_FONT_FILES={"Roboto Slab":"robotoslab/RobotoSlab-Medium_2.001.woff",PetalumaScript:"petaluma/PetalumaScript_1.10_FS.woff"};class B{constructor(){this.id={},this.type={},this.class={}}}class R{constructor(){this.index=new B}static getDefaultRegistry(){return R.defaultRegistry}static enableDefaultRegistry(t){R.defaultRegistry=t}static disableDefaultRegistry(){R.defaultRegistry=void 0}clear(){return this.index=new B,this}setIndexValue(t,e,i,s){const n=this.index;n[t][e]||(n[t][e]={}),n[t][e][i]=s}updateIndex({id:t,name:e,value:i,oldValue:s}){const n=this.getElementById(t);void 0!==s&&this.index[e][s]&&delete this.index[e][s][t],i&&n&&this.setIndexValue(e,i,n.getAttribute("id"),n)}register(t,e){if(!(e=e||t.getAttribute("id")))throw new f("Can't add element without `id` attribute to registry");return t.setAttribute("id",e),this.setIndexValue("id",e,e,t),this.updateIndex({id:e,name:"type",value:t.getAttribute("type"),oldValue:void 0}),t.onRegister(this),this}getElementById(t){var e,i;return null===(i=null===(e=this.index.id)||void 0===e?void 0:e[t])||void 0===i?void 0:i[t]}getElementsByAttribute(t,e){const i=this.index[t];if(i){const t=i[e];if(t){return Object.keys(t).map((e=>t[e]))}}return[]}getElementsByType(t){return this.getElementsByAttribute("type",t)}getElementsByClass(t){return this.getElementsByAttribute("class",t)}onUpdate(t){return["id","type","class"].includes(t.name)&&this.updateIndex(t),this}}class O{constructor(){var t;this.attrs={id:O.newID(),el:void 0,type:this.getCategory(),classes:{}},this.rendered=!1,null===(t=R.getDefaultRegistry())||void 0===t||t.register(this)}static get CATEGORY(){return m.Element}static newID(){return"auto"+O.ID++}getCategory(){return this.constructor.CATEGORY}setStyle(t){return this.style=t,this}getStyle(){return this.style}applyStyle(t=this.context,e=this.getStyle()){return e&&t?(t.save(),e.shadowColor&&t.setShadowColor(e.shadowColor),e.shadowBlur&&t.setShadowBlur(e.shadowBlur),e.fillStyle&&t.setFillStyle(e.fillStyle),e.strokeStyle&&t.setStrokeStyle(e.strokeStyle),e.lineWidth&&t.setLineWidth(e.lineWidth),this):this}restoreStyle(t=this.context,e=this.getStyle()){return e&&t?(t.restore(),this):this}drawWithStyle(){this.checkContext(),this.applyStyle(),this.draw(),this.restoreStyle()}hasClass(t){return!0===this.attrs.classes[t]}addClass(t){var e;return this.attrs.classes[t]=!0,null===(e=this.registry)||void 0===e||e.onUpdate({id:this.attrs.id,name:"class",value:t,oldValue:void 0}),this}removeClass(t){var e;return delete this.attrs.classes[t],null===(e=this.registry)||void 0===e||e.onUpdate({id:this.attrs.id,name:"class",value:void 0,oldValue:t}),this}onRegister(t){return this.registry=t,this}isRendered(){return this.rendered}setRendered(t=!0){return this.rendered=t,this}getAttributes(){return this.attrs}getAttribute(t){return this.attrs[t]}setAttribute(t,e){var i;const s=this.attrs.id,n=this.attrs[t];return this.attrs[t]=e,null===(i=this.registry)||void 0===i||i.onUpdate({id:s,name:t,value:e,oldValue:n}),this}getBoundingBox(){return this.boundingBox}getContext(){return this.context}setContext(t){return this.context=t,this}checkContext(){return x(this.context,"NoContext","No rendering context attached to instance.")}set font(t){this.setFont(t)}get font(){return M.toCSSString(this.textFont)}setFont(t,e,i,s){const n=this.constructor.TEXT_FONT,a="object"==typeof t,o="string"==typeof t,r=void 0===t,h=void 0===e&&void 0===i&&void 0===s;return this.textFont=a?Object.assign(Object.assign({},n),t):o&&h?M.fromCSSString(t):r&&h?Object.assign({},n):M.validate(null!=t?t:n.family,null!=e?e:n.size,null!=i?i:n.weight,null!=s?s:n.style),this}getFont(){return this.textFont||this.resetFont(),M.toCSSString(this.textFont)}resetFont(){this.setFont()}get fontInfo(){return this.textFont||this.resetFont(),Object.assign({},this.textFont)}set fontInfo(t){this.setFont(t)}setFontSize(t){const e=this.fontInfo;return this.setFont(e.family,t,e.weight,e.style),this}getFontSize(){return this.fontSize}set fontSize(t){this.setFontSize(t)}get fontSize(){let t=this.fontInfo.size;return"number"==typeof t&&(t=`${t}pt`),t}get fontSizeInPoints(){return M.convertSizeToPointValue(this.fontSize)}get fontSizeInPixels(){return M.convertSizeToPixelValue(this.fontSize)}get fontStyle(){return this.fontInfo.style}set fontStyle(t){const e=this.fontInfo;this.setFont(e.family,e.size,e.weight,t)}get fontWeight(){return this.fontInfo.weight+""}set fontWeight(t){const e=this.fontInfo;this.setFont(e.family,e.size,t,e.style)}}var L,I;O.ID=1e3,O.TEXT_FONT={family:M.SANS_SERIF,size:M.SIZE,weight:k.NORMAL,style:D.NORMAL},function(t){t[t.MOVE=0]="MOVE",t[t.LINE=1]="LINE",t[t.QUADRATIC=2]="QUADRATIC",t[t.BEZIER=3]="BEZIER"}(L||(L={}));class W{constructor(t,e,i){this.point=-1,this.metrics=U.loadMetrics(t,e,i),this.bbox=U.getOutlineBoundingBox(this.metrics.outline,this.metrics.scale,this.metrics.x_shift,this.metrics.y_shift),i&&(this.point=U.lookupFontMetric(this.metrics.font,i,e,"point",-1))}}class G{constructor(t,e,i,s){this.outline=t,this.originX=e,this.originY=i,this.scale=s,this.i=0}done(){return this.i>=this.outline.length}next(){return this.outline[this.i++]}nextX(){return this.originX+this.outline[this.i++]*this.scale}nextY(){return this.originY-this.outline[this.i++]*this.scale}static parse(t){const e=[],i=t.split(" ");let s=0;for(;s<i.length;)switch(i[s++]){case"m":e.push(L.MOVE,parseInt(i[s++]),parseInt(i[s++]));break;case"l":e.push(L.LINE,parseInt(i[s++]),parseInt(i[s++]));break;case"q":e.push(L.QUADRATIC,parseInt(i[s++]),parseInt(i[s++]),parseInt(i[s++]),parseInt(i[s++]));break;case"b":e.push(L.BEZIER,parseInt(i[s++]),parseInt(i[s++]),parseInt(i[s++]),parseInt(i[s++]),parseInt(i[s++]),parseInt(i[s++]))}return e}}class U extends O{constructor(t,e,i){super(),this.bbox=new C(0,0,0,0),this.topGlyphs=[],this.botGlyphs=[],this.options={},this.scale=1,this.code=t,this.point=e,this.originShift={x:0,y:0},this.x_shift=0,this.y_shift=0,i?this.setOptions(i):this.reset()}static get CATEGORY(){return m.Glyph}static lookupFontMetric(t,e,i,s,n){let a=t.lookupMetric(`glyphs.${e}.${i}.${s}`,void 0);return void 0===a&&(a=t.lookupMetric(`glyphs.${e}.${s}`,n)),a}static lookupGlyph(t,e){let i,s;x(t,"BadFontStack","Font stack is misconfigured");for(let n=0;n<t.length;n++)if(s=t[n],i=s.getGlyphs()[e],i)return{glyph:i,font:s};throw new f("BadGlyph",`Glyph ${e} does not exist in font.`)}static loadMetrics(t,e,i){const{glyph:s,font:n}=U.lookupGlyph(t,e);if(!s.o)throw new f("BadGlyph",`Glyph ${e} has no outline defined.`);let a=0,o=0,r=1;i&&n&&(a=U.lookupFontMetric(n,i,e,"shiftX",0),o=U.lookupFontMetric(n,i,e,"shiftY",0),r=U.lookupFontMetric(n,i,e,"scale",1));const h=s.x_min,c=s.x_max,d=s.ha;return s.cached_outline||(s.cached_outline=G.parse(s.o)),{x_min:h,x_max:c,x_shift:a,y_shift:o,scale:r,ha:d,outline:s.cached_outline,font:n,width:c-h,height:d}}static renderGlyph(t,e,i,s,n,a){var o;const r=U.cache.lookup(n,null==a?void 0:a.category),h=r.metrics;-1!=r.point&&(s=r.point);const c=null!==(o=null==a?void 0:a.scale)&&void 0!==o?o:1,d=72*s/(100*h.font.getResolution())*h.scale*c;return U.renderOutline(t,h.outline,d,e+h.x_shift*c,i+h.y_shift*c),h}static renderOutline(t,e,i,s,n){const a=new G(e,s,n,i);let o,r;for(t.beginPath();!a.done();)switch(a.next()){case L.MOVE:t.moveTo(a.nextX(),a.nextY());break;case L.LINE:t.lineTo(a.nextX(),a.nextY());break;case L.QUADRATIC:o=a.nextX(),r=a.nextY(),t.quadraticCurveTo(a.nextX(),a.nextY(),o,r);break;case L.BEZIER:o=a.nextX(),r=a.nextY(),t.bezierCurveTo(a.nextX(),a.nextY(),a.nextX(),a.nextY(),o,r)}t.fill()}static getOutlineBoundingBox(t,e,i,s){const n=new G(t,i,s,e),a=new N;let o,r,h=i,c=s;for(;!n.done();)switch(n.next()){case L.MOVE:h=n.nextX(),c=n.nextY();break;case L.LINE:a.addPoint(h,c),h=n.nextX(),c=n.nextY(),a.addPoint(h,c);break;case L.QUADRATIC:o=n.nextX(),r=n.nextY(),a.addQuadraticCurve(h,c,n.nextX(),n.nextY(),o,r),h=o,c=r;break;case L.BEZIER:o=n.nextX(),r=n.nextY(),a.addBezierCurve(h,c,n.nextX(),n.nextY(),n.nextX(),n.nextY(),o,r),h=o,c=r}return new C(a.getX1(),a.getY1(),a.width(),a.height())}static getWidth(t,e,i){const s=U.cache.lookup(t,i);-1!=s.point&&(e=s.point);const n=72*e/(100*s.metrics.font.getResolution());return s.bbox.getW()*n}draw(...t){}getCode(){return this.code}setOptions(t){this.options=Object.assign(Object.assign({},this.options),t),this.reset()}setPoint(t){return this.point=t,this}setStave(t){return this.stave=t,this}getXShift(){return this.x_shift}setXShift(t){return this.x_shift=t,this}getYshift(){return this.y_shift}setYShift(t){return this.y_shift=t,this}reset(){const t=U.cache.lookup(this.code,this.options.category);this.metrics=t.metrics,-1!=t.point&&(this.point=t.point),this.scale=72*this.point/(100*this.metrics.font.getResolution()),this.bbox=new C(t.bbox.getX()*this.scale,t.bbox.getY()*this.scale,t.bbox.getW()*this.scale,t.bbox.getH()*this.scale)}checkMetrics(){return x(this.metrics,"BadGlyph",`Glyph ${this.code} is not initialized.`)}getMetrics(){const t=this.checkMetrics(),e=t.scale;return{x_min:t.x_min*this.scale*e,x_max:t.x_max*this.scale*e,width:this.bbox.getW(),height:this.bbox.getH(),scale:this.scale*e,x_shift:t.x_shift,y_shift:t.y_shift,outline:t.outline,font:t.font,ha:t.ha}}setOriginX(t){const{bbox:e}=this,i=(t-Math.abs(e.getX()/e.getW()))*e.getW();this.originShift.x=-i}setOriginY(t){const{bbox:e}=this,i=(t-Math.abs(e.getY()/e.getH()))*e.getH();this.originShift.y=-i}setOrigin(t,e){this.setOriginX(t),this.setOriginY(e)}render(t,e,i){const s=this.checkMetrics(),n=s.outline,a=this.scale*s.scale;this.setRendered(),this.applyStyle(t);const o=e+this.originShift.x+s.x_shift,r=i+this.originShift.y+s.y_shift;U.renderOutline(t,n,a,o,r),this.restoreStyle(t)}checkStave(){return x(this.stave,"NoStave","No stave attached to instance.")}renderToStave(t){const e=this.checkContext(),i=this.checkMetrics(),s=this.checkStave(),n=i.outline,a=this.scale*i.scale;this.setRendered(),this.applyStyle();const o=t+this.x_shift+i.x_shift,r=s.getYForGlyphs()+this.y_shift+i.y_shift;U.renderOutline(e,n,a,o,r),this.restoreStyle()}}U.cache=new class{constructor(){this.cache=new Map}lookup(t,e){let i=this.cache.get(U.CURRENT_CACHE_KEY);void 0===i&&(i={},this.cache.set(U.CURRENT_CACHE_KEY,i));const s=e?`${t}%${e}`:t;let n=i[s];return void 0===n&&(n=new W(U.MUSIC_FONT_STACK,t,e),i[s]=n),n}},U.CURRENT_CACHE_KEY="",U.MUSIC_FONT_STACK=[],function(t){t[t.CENTER=0]="CENTER",t[t.LEFT=1]="LEFT",t[t.RIGHT=2]="RIGHT",t[t.ABOVE=3]="ABOVE",t[t.BELOW=4]="BELOW"}(I||(I={}));class H extends O{constructor(){super(),this.width=0,this.text_line=0,this.position=H.Position.LEFT,this.x_shift=0,this.y_shift=0,this.spacingFromNextModifier=0}static get CATEGORY(){return m.Modifier}static get Position(){return I}static get PositionString(){return{center:I.CENTER,above:I.ABOVE,below:I.BELOW,left:I.LEFT,right:I.RIGHT}}reset(){}getWidth(){return this.width}setWidth(t){return this.width=t,this}getNote(){return x(this.note,"NoNote","Modifier has no note.")}checkAttachedNote(){const t=this.getCategory();return x(this.index,"NoIndex",`Can't draw ${t} without an index.`),x(this.note,"NoNote",`Can't draw ${t} without a note.`)}setNote(t){return this.note=t,this}getIndex(){return this.index}checkIndex(){return x(this.index,"NoIndex","Modifier has an invalid index.")}setIndex(t){return this.index=t,this}getModifierContext(){return this.modifierContext}checkModifierContext(){return x(this.modifierContext,"NoModifierContext","Modifier Context Required")}setModifierContext(t){return this.modifierContext=t,this}getPosition(){return this.position}setPosition(t){return this.position="string"==typeof t?H.PositionString[t]:t,this.reset(),this}setTextLine(t){return this.text_line=t,this}setYShift(t){return this.y_shift=t,this}setSpacingFromNextModifier(t){this.spacingFromNextModifier=t}getSpacingFromNextModifier(){return this.spacingFromNextModifier}setXShift(t){return this.x_shift=0,this.position===H.Position.LEFT?this.x_shift-=t:this.x_shift+=t,this}getXShift(){return this.x_shift}draw(){throw this.checkContext(),new f("NotImplemented","draw() not implemented for this modifier.")}alignSubNotesWithNote(t,e){const i=e.getTickContext(),s=i.getMetrics(),n=e.getStave(),a=i.getX()-s.modLeftPx-s.modRightPx+this.getSpacingFromNextModifier();t.forEach((t=>{const e=t.getTickContext();n&&t.setStave(n),e.setXOffset(a)}))}}class Y{static get NUM_TONES(){return this.canonical_notes.length}static get roots(){return["c","d","e","f","g","a","b"]}static get root_values(){return[0,2,4,5,7,9,11]}static get root_indices(){return{c:0,d:1,e:2,f:3,g:4,a:5,b:6}}static get canonical_notes(){return["c","c#","d","d#","e","f","f#","g","g#","a","a#","b"]}static get diatonic_intervals(){return["unison","m2","M2","m3","M3","p4","dim5","p5","m6","M6","b7","M7","octave"]}static get diatonic_accidentals(){return{unison:{note:0,accidental:0},m2:{note:1,accidental:-1},M2:{note:1,accidental:0},m3:{note:2,accidental:-1},M3:{note:2,accidental:0},p4:{note:3,accidental:0},dim5:{note:4,accidental:-1},p5:{note:4,accidental:0},m6:{note:5,accidental:-1},M6:{note:5,accidental:0},b7:{note:6,accidental:-1},M7:{note:6,accidental:0},octave:{note:7,accidental:0}}}static get intervals(){return{u:0,unison:0,m2:1,b2:1,min2:1,S:1,H:1,2:2,M2:2,maj2:2,T:2,W:2,m3:3,b3:3,min3:3,M3:4,3:4,maj3:4,4:5,p4:5,"#4":6,b5:6,aug4:6,dim5:6,5:7,p5:7,"#5":8,b6:8,aug5:8,6:9,M6:9,maj6:9,b7:10,m7:10,min7:10,dom7:10,M7:11,maj7:11,8:12,octave:12}}static get scales(){return{major:[2,2,1,2,2,2,1],minor:[2,1,2,2,1,2,2],ionian:[2,2,1,2,2,2,1],dorian:[2,1,2,2,2,1,2],phyrgian:[1,2,2,2,1,2,2],lydian:[2,2,2,1,2,2,1],mixolydian:[2,2,1,2,2,1,2],aeolian:[2,1,2,2,1,2,2],locrian:[1,2,2,1,2,2,2]}}static get scaleTypes(){return{M:Y.scales.major,m:Y.scales.minor}}static get accidentals(){return["bb","b","n","#","##"]}static get noteValues(){return{c:{root_index:0,int_val:0},cn:{root_index:0,int_val:0},"c#":{root_index:0,int_val:1},"c##":{root_index:0,int_val:2},cb:{root_index:0,int_val:11},cbb:{root_index:0,int_val:10},d:{root_index:1,int_val:2},dn:{root_index:1,int_val:2},"d#":{root_index:1,int_val:3},"d##":{root_index:1,int_val:4},db:{root_index:1,int_val:1},dbb:{root_index:1,int_val:0},e:{root_index:2,int_val:4},en:{root_index:2,int_val:4},"e#":{root_index:2,int_val:5},"e##":{root_index:2,int_val:6},eb:{root_index:2,int_val:3},ebb:{root_index:2,int_val:2},f:{root_index:3,int_val:5},fn:{root_index:3,int_val:5},"f#":{root_index:3,int_val:6},"f##":{root_index:3,int_val:7},fb:{root_index:3,int_val:4},fbb:{root_index:3,int_val:3},g:{root_index:4,int_val:7},gn:{root_index:4,int_val:7},"g#":{root_index:4,int_val:8},"g##":{root_index:4,int_val:9},gb:{root_index:4,int_val:6},gbb:{root_index:4,int_val:5},a:{root_index:5,int_val:9},an:{root_index:5,int_val:9},"a#":{root_index:5,int_val:10},"a##":{root_index:5,int_val:11},ab:{root_index:5,int_val:8},abb:{root_index:5,int_val:7},b:{root_index:6,int_val:11},bn:{root_index:6,int_val:11},"b#":{root_index:6,int_val:0},"b##":{root_index:6,int_val:1},bb:{root_index:6,int_val:10},bbb:{root_index:6,int_val:9}}}isValidNoteValue(t){return t>=0&&t<Y.canonical_notes.length}isValidIntervalValue(t){return t>=0&&t<Y.diatonic_intervals.length}getNoteParts(t){if(!t||t.length<1)throw new f("BadArguments","Invalid note name: "+t);if(t.length>3)throw new f("BadArguments","Invalid note name: "+t);const e=t.toLowerCase(),i=/^([cdefgab])(b|bb|n|#|##)?$/.exec(e);if(null!==i){return{root:i[1],accidental:i[2]}}throw new f("BadArguments","Invalid note name: "+t)}getKeyParts(t){if(!t||t.length<1)throw new f("BadArguments","Invalid key: "+t);const e=t.toLowerCase(),i=/^([cdefgab])(b|#)?(mel|harm|m|M)?$/.exec(e);if(null!==i){const t=i[1],e=i[2];let s=i[3];return s||(s="M"),{root:t,accidental:e,type:s}}throw new f("BadArguments",`Invalid key: ${t}`)}getNoteValue(t){const e=Y.noteValues[t];if(void 0===e)throw new f("BadArguments",`Invalid note name: ${t}`);return e.int_val}getIntervalValue(t){const e=Y.intervals[t];if(void 0===e)throw new f("BadArguments",`Invalid interval name: ${t}`);return e}getCanonicalNoteName(t){if(!this.isValidNoteValue(t))throw new f("BadArguments",`Invalid note value: ${t}`);return Y.canonical_notes[t]}getCanonicalIntervalName(t){if(!this.isValidIntervalValue(t))throw new f("BadArguments",`Invalid interval value: ${t}`);return Y.diatonic_intervals[t]}getRelativeNoteValue(t,e,i=1){if(1!==i&&-1!==i)throw new f("BadArguments",`Invalid direction: ${i}`);let s=(t+i*e)%Y.NUM_TONES;return s<0&&(s+=Y.NUM_TONES),s}getRelativeNoteName(t,e){const i=this.getNoteParts(t),s=this.getNoteValue(i.root);let n=e-s;if(Math.abs(n)>Y.NUM_TONES-3){let i=1;n>0&&(i=-1);const a=(e+1+(s+1))%Y.NUM_TONES*i;if(Math.abs(a)>2)throw new f("BadArguments",`Notes not related: ${t}, ${e})`);n=a}if(Math.abs(n)>2)throw new f("BadArguments",`Notes not related: ${t}, ${e})`);let a=i.root;if(n>0)for(let t=1;t<=n;++t)a+="#";else if(n<0)for(let t=-1;t>=n;--t)a+="b";return a}getScaleTones(t,e){const i=[t];let s=t;for(let n=0;n<e.length;n++)s=this.getRelativeNoteValue(s,e[n]),s!==t&&i.push(s);return i}getIntervalBetween(t,e,i=1){if(1!==i&&-1!==i)throw new f("BadArguments",`Invalid direction: ${i}`);if(!this.isValidNoteValue(t)||!this.isValidNoteValue(e))throw new f("BadArguments",`Invalid notes: ${t}, ${e}`);let s=1===i?e-t:t-e;return s<0&&(s+=Y.NUM_TONES),s}createScaleMap(t){const e=this.getKeyParts(t);if(!e.type)throw new f("BadArguments","Unsupported key type: undefined");const i=Y.scaleTypes[e.type];let s=e.root;if(e.accidental&&(s+=e.accidental),!i)throw new f("BadArguments","Unsupported key type: "+t);const n=this.getScaleTones(this.getNoteValue(s),i),a=Y.root_indices[e.root],o={};for(let t=0;t<Y.roots.length;++t){const e=(a+t)%Y.roots.length,i=Y.roots[e];let s=this.getRelativeNoteName(i,n[t]);1===s.length&&(s+="n"),o[i]=s}return o}}const j=16384,X={"1/2":32768,1:16384,2:8192,4:4096,8:2048,16:1024,32:512,64:256,128:128,256:64},V={w:"1",h:"2",q:"4",b:"256"},z={C:{num:0},Am:{num:0},F:{acc:"b",num:1},Dm:{acc:"b",num:1},Bb:{acc:"b",num:2},Gm:{acc:"b",num:2},Eb:{acc:"b",num:3},Cm:{acc:"b",num:3},Ab:{acc:"b",num:4},Fm:{acc:"b",num:4},Db:{acc:"b",num:5},Bbm:{acc:"b",num:5},Gb:{acc:"b",num:6},Ebm:{acc:"b",num:6},Cb:{acc:"b",num:7},Abm:{acc:"b",num:7},G:{acc:"#",num:1},Em:{acc:"#",num:1},D:{acc:"#",num:2},Bm:{acc:"#",num:2},A:{acc:"#",num:3},"F#m":{acc:"#",num:3},E:{acc:"#",num:4},"C#m":{acc:"#",num:4},B:{acc:"#",num:5},"G#m":{acc:"#",num:5},"F#":{acc:"#",num:6},"D#m":{acc:"#",num:6},"C#":{acc:"#",num:7},"A#m":{acc:"#",num:7}},K={treble:{line_shift:0},bass:{line_shift:6},tenor:{line_shift:4},alto:{line_shift:3},soprano:{line_shift:1},percussion:{line_shift:0},"mezzo-soprano":{line_shift:2},"baritone-c":{line_shift:5},"baritone-f":{line_shift:5},subbass:{line_shift:7},french:{line_shift:-1}},$={C:{index:0,int_val:0},CN:{index:0,int_val:0,accidental:"n"},"C#":{index:0,int_val:1,accidental:"#"},"C##":{index:0,int_val:2,accidental:"##"},CB:{index:0,int_val:11,accidental:"b"},CBB:{index:0,int_val:10,accidental:"bb"},D:{index:1,int_val:2},DN:{index:1,int_val:2,accidental:"n"},"D#":{index:1,int_val:3,accidental:"#"},"D##":{index:1,int_val:4,accidental:"##"},DB:{index:1,int_val:1,accidental:"b"},DBB:{index:1,int_val:0,accidental:"bb"},E:{index:2,int_val:4},EN:{index:2,int_val:4,accidental:"n"},"E#":{index:2,int_val:5,accidental:"#"},"E##":{index:2,int_val:6,accidental:"##"},EB:{index:2,int_val:3,accidental:"b"},EBB:{index:2,int_val:2,accidental:"bb"},F:{index:3,int_val:5},FN:{index:3,int_val:5,accidental:"n"},"F#":{index:3,int_val:6,accidental:"#"},"F##":{index:3,int_val:7,accidental:"##"},FB:{index:3,int_val:4,accidental:"b"},FBB:{index:3,int_val:3,accidental:"bb"},G:{index:4,int_val:7},GN:{index:4,int_val:7,accidental:"n"},"G#":{index:4,int_val:8,accidental:"#"},"G##":{index:4,int_val:9,accidental:"##"},GB:{index:4,int_val:6,accidental:"b"},GBB:{index:4,int_val:5,accidental:"bb"},A:{index:5,int_val:9},AN:{index:5,int_val:9,accidental:"n"},"A#":{index:5,int_val:10,accidental:"#"},"A##":{index:5,int_val:11,accidental:"##"},AB:{index:5,int_val:8,accidental:"b"},ABB:{index:5,int_val:7,accidental:"bb"},B:{index:6,int_val:11},BN:{index:6,int_val:11,accidental:"n"},"B#":{index:6,int_val:12,accidental:"#"},"B##":{index:6,int_val:13,accidental:"##"},BB:{index:6,int_val:10,accidental:"b"},BBB:{index:6,int_val:9,accidental:"bb"},R:{index:6,rest:!0},X:{index:6,accidental:"",octave:4,code:"noteheadXBlack",shift_right:5.5}},J={D0:{code:"noteheadDiamondWhole"},D1:{code:"noteheadDiamondHalf"},D2:{code:"noteheadDiamondBlack"},D3:{code:"noteheadDiamondBlack"},T0:{code:"noteheadTriangleUpWhole"},T1:{code:"noteheadTriangleUpHalf"},T2:{code:"noteheadTriangleUpBlack"},T3:{code:"noteheadTriangleUpBlack"},X0:{code:"noteheadXWhole"},X1:{code:"noteheadXHalf"},X2:{code:"noteheadXBlack"},X3:{code:"noteheadCircleX"},S1:{code:"noteheadSquareWhite"},S2:{code:"noteheadSquareBlack"},R1:{code:"vexNoteHeadRectWhite"},R2:{code:"vexNoteHeadRectBlack"}},q={"#":{code:"accidentalSharp",parenRightPaddingAdjustment:-1},"##":{code:"accidentalDoubleSharp",parenRightPaddingAdjustment:-1},b:{code:"accidentalFlat",parenRightPaddingAdjustment:-2},bb:{code:"accidentalDoubleFlat",parenRightPaddingAdjustment:-2},n:{code:"accidentalNatural",parenRightPaddingAdjustment:-1},"{":{code:"accidentalParensLeft",parenRightPaddingAdjustment:-1},"}":{code:"accidentalParensRight",parenRightPaddingAdjustment:-1},db:{code:"accidentalThreeQuarterTonesFlatZimmermann",parenRightPaddingAdjustment:-1},d:{code:"accidentalQuarterToneFlatStein",parenRightPaddingAdjustment:0},"++":{code:"accidentalThreeQuarterTonesSharpStein",parenRightPaddingAdjustment:-1},"+":{code:"accidentalQuarterToneSharpStein",parenRightPaddingAdjustment:-1},"+-":{code:"accidentalKucukMucennebSharp",parenRightPaddingAdjustment:-1},bs:{code:"accidentalBakiyeFlat",parenRightPaddingAdjustment:-1},bss:{code:"accidentalBuyukMucennebFlat",parenRightPaddingAdjustment:-1},o:{code:"accidentalSori",parenRightPaddingAdjustment:-1},k:{code:"accidentalKoron",parenRightPaddingAdjustment:-1},bbs:{code:"vexAccidentalMicrotonal1",parenRightPaddingAdjustment:-1},"++-":{code:"vexAccidentalMicrotonal2",parenRightPaddingAdjustment:-1},ashs:{code:"vexAccidentalMicrotonal3",parenRightPaddingAdjustment:-1},afhf:{code:"vexAccidentalMicrotonal4",parenRightPaddingAdjustment:-1},accSagittal5v7KleismaUp:{code:"accSagittal5v7KleismaUp",parenRightPaddingAdjustment:-1},accSagittal5v7KleismaDown:{code:"accSagittal5v7KleismaDown",parenRightPaddingAdjustment:-1},accSagittal5CommaUp:{code:"accSagittal5CommaUp",parenRightPaddingAdjustment:-1},accSagittal5CommaDown:{code:"accSagittal5CommaDown",parenRightPaddingAdjustment:-1},accSagittal7CommaUp:{code:"accSagittal7CommaUp",parenRightPaddingAdjustment:-1},accSagittal7CommaDown:{code:"accSagittal7CommaDown",parenRightPaddingAdjustment:-1},accSagittal25SmallDiesisUp:{code:"accSagittal25SmallDiesisUp",parenRightPaddingAdjustment:-1},accSagittal25SmallDiesisDown:{code:"accSagittal25SmallDiesisDown",parenRightPaddingAdjustment:-1},accSagittal35MediumDiesisUp:{code:"accSagittal35MediumDiesisUp",parenRightPaddingAdjustment:-1},accSagittal35MediumDiesisDown:{code:"accSagittal35MediumDiesisDown",parenRightPaddingAdjustment:-1},accSagittal11MediumDiesisUp:{code:"accSagittal11MediumDiesisUp",parenRightPaddingAdjustment:-1},accSagittal11MediumDiesisDown:{code:"accSagittal11MediumDiesisDown",parenRightPaddingAdjustment:-1},accSagittal11LargeDiesisUp:{code:"accSagittal11LargeDiesisUp",parenRightPaddingAdjustment:-1},accSagittal11LargeDiesisDown:{code:"accSagittal11LargeDiesisDown",parenRightPaddingAdjustment:-1},accSagittal35LargeDiesisUp:{code:"accSagittal35LargeDiesisUp",parenRightPaddingAdjustment:-1},accSagittal35LargeDiesisDown:{code:"accSagittal35LargeDiesisDown",parenRightPaddingAdjustment:-1},accSagittalSharp25SDown:{code:"accSagittalSharp25SDown",parenRightPaddingAdjustment:-1},accSagittalFlat25SUp:{code:"accSagittalFlat25SUp",parenRightPaddingAdjustment:-1},accSagittalSharp7CDown:{code:"accSagittalSharp7CDown",parenRightPaddingAdjustment:-1},accSagittalFlat7CUp:{code:"accSagittalFlat7CUp",parenRightPaddingAdjustment:-1},accSagittalSharp5CDown:{code:"accSagittalSharp5CDown",parenRightPaddingAdjustment:-1},accSagittalFlat5CUp:{code:"accSagittalFlat5CUp",parenRightPaddingAdjustment:-1},accSagittalSharp5v7kDown:{code:"accSagittalSharp5v7kDown",parenRightPaddingAdjustment:-1},accSagittalFlat5v7kUp:{code:"accSagittalFlat5v7kUp",parenRightPaddingAdjustment:-1},accSagittalSharp:{code:"accSagittalSharp",parenRightPaddingAdjustment:-1},accSagittalFlat:{code:"accSagittalFlat",parenRightPaddingAdjustment:-1},accSagittalSharp5v7kUp:{code:"accSagittalSharp5v7kUp",parenRightPaddingAdjustment:-1},accSagittalFlat5v7kDown:{code:"accSagittalFlat5v7kDown",parenRightPaddingAdjustment:-1},accSagittalSharp5CUp:{code:"accSagittalSharp5CUp",parenRightPaddingAdjustment:-1},accSagittalFlat5CDown:{code:"accSagittalFlat5CDown",parenRightPaddingAdjustment:-1},accSagittalSharp7CUp:{code:"accSagittalSharp7CUp",parenRightPaddingAdjustment:-1},accSagittalFlat7CDown:{code:"accSagittalFlat7CDown",parenRightPaddingAdjustment:-1},accSagittalSharp25SUp:{code:"accSagittalSharp25SUp",parenRightPaddingAdjustment:-1},accSagittalFlat25SDown:{code:"accSagittalFlat25SDown",parenRightPaddingAdjustment:-1},accSagittalSharp35MUp:{code:"accSagittalSharp35MUp",parenRightPaddingAdjustment:-1},accSagittalFlat35MDown:{code:"accSagittalFlat35MDown",parenRightPaddingAdjustment:-1},accSagittalSharp11MUp:{code:"accSagittalSharp11MUp",parenRightPaddingAdjustment:-1},accSagittalFlat11MDown:{code:"accSagittalFlat11MDown",parenRightPaddingAdjustment:-1},accSagittalSharp11LUp:{code:"accSagittalSharp11LUp",parenRightPaddingAdjustment:-1},accSagittalFlat11LDown:{code:"accSagittalFlat11LDown",parenRightPaddingAdjustment:-1},accSagittalSharp35LUp:{code:"accSagittalSharp35LUp",parenRightPaddingAdjustment:-1},accSagittalFlat35LDown:{code:"accSagittalFlat35LDown",parenRightPaddingAdjustment:-1},accSagittalDoubleSharp25SDown:{code:"accSagittalDoubleSharp25SDown",parenRightPaddingAdjustment:-1},accSagittalDoubleFlat25SUp:{code:"accSagittalDoubleFlat25SUp",parenRightPaddingAdjustment:-1},accSagittalDoubleSharp7CDown:{code:"accSagittalDoubleSharp7CDown",parenRightPaddingAdjustment:-1},accSagittalDoubleFlat7CUp:{code:"accSagittalDoubleFlat7CUp",parenRightPaddingAdjustment:-1},accSagittalDoubleSharp5CDown:{code:"accSagittalDoubleSharp5CDown",parenRightPaddingAdjustment:-1},accSagittalDoubleFlat5CUp:{code:"accSagittalDoubleFlat5CUp",parenRightPaddingAdjustment:-1},accSagittalDoubleSharp5v7kDown:{code:"accSagittalDoubleSharp5v7kDown",parenRightPaddingAdjustment:-1},accSagittalDoubleFlat5v7kUp:{code:"accSagittalDoubleFlat5v7kUp",parenRightPaddingAdjustment:-1},accSagittalDoubleSharp:{code:"accSagittalDoubleSharp",parenRightPaddingAdjustment:-1},accSagittalDoubleFlat:{code:"accSagittalDoubleFlat",parenRightPaddingAdjustment:-1},accSagittal7v11KleismaUp:{code:"accSagittal7v11KleismaUp",parenRightPaddingAdjustment:-1},accSagittal7v11KleismaDown:{code:"accSagittal7v11KleismaDown",parenRightPaddingAdjustment:-1},accSagittal17CommaUp:{code:"accSagittal17CommaUp",parenRightPaddingAdjustment:-1},accSagittal17CommaDown:{code:"accSagittal17CommaDown",parenRightPaddingAdjustment:-1},accSagittal55CommaUp:{code:"accSagittal55CommaUp",parenRightPaddingAdjustment:-1},accSagittal55CommaDown:{code:"accSagittal55CommaDown",parenRightPaddingAdjustment:-1},accSagittal7v11CommaUp:{code:"accSagittal7v11CommaUp",parenRightPaddingAdjustment:-1},accSagittal7v11CommaDown:{code:"accSagittal7v11CommaDown",parenRightPaddingAdjustment:-1},accSagittal5v11SmallDiesisUp:{code:"accSagittal5v11SmallDiesisUp",parenRightPaddingAdjustment:-1},accSagittal5v11SmallDiesisDown:{code:"accSagittal5v11SmallDiesisDown",parenRightPaddingAdjustment:-1},accSagittalSharp5v11SDown:{code:"accSagittalSharp5v11SDown",parenRightPaddingAdjustment:-1},accSagittalFlat5v11SUp:{code:"accSagittalFlat5v11SUp",parenRightPaddingAdjustment:-1},accSagittalSharp7v11CDown:{code:"accSagittalSharp7v11CDown",parenRightPaddingAdjustment:-1},accSagittalFlat7v11CUp:{code:"accSagittalFlat7v11CUp",parenRightPaddingAdjustment:-1},accSagittalSharp55CDown:{code:"accSagittalSharp55CDown",parenRightPaddingAdjustment:-1},accSagittalFlat55CUp:{code:"accSagittalFlat55CUp",parenRightPaddingAdjustment:-1},accSagittalSharp17CDown:{code:"accSagittalSharp17CDown",parenRightPaddingAdjustment:-1},accSagittalFlat17CUp:{code:"accSagittalFlat17CUp",parenRightPaddingAdjustment:-1},accSagittalSharp7v11kDown:{code:"accSagittalSharp7v11kDown",parenRightPaddingAdjustment:-1},accSagittalFlat7v11kUp:{code:"accSagittalFlat7v11kUp",parenRightPaddingAdjustment:-1},accSagittalSharp7v11kUp:{code:"accSagittalSharp7v11kUp",parenRightPaddingAdjustment:-1},accSagittalFlat7v11kDown:{code:"accSagittalFlat7v11kDown",parenRightPaddingAdjustment:-1},accSagittalSharp17CUp:{code:"accSagittalSharp17CUp",parenRightPaddingAdjustment:-1},accSagittalFlat17CDown:{code:"accSagittalFlat17CDown",parenRightPaddingAdjustment:-1},accSagittalSharp55CUp:{code:"accSagittalSharp55CUp",parenRightPaddingAdjustment:-1},accSagittalFlat55CDown:{code:"accSagittalFlat55CDown",parenRightPaddingAdjustment:-1},accSagittalSharp7v11CUp:{code:"accSagittalSharp7v11CUp",parenRightPaddingAdjustment:-1},accSagittalFlat7v11CDown:{code:"accSagittalFlat7v11CDown",parenRightPaddingAdjustment:-1},accSagittalSharp5v11SUp:{code:"accSagittalSharp5v11SUp",parenRightPaddingAdjustment:-1},accSagittalFlat5v11SDown:{code:"accSagittalFlat5v11SDown",parenRightPaddingAdjustment:-1},accSagittalDoubleSharp5v11SDown:{code:"accSagittalDoubleSharp5v11SDown",parenRightPaddingAdjustment:-1},accSagittalDoubleFlat5v11SUp:{code:"accSagittalDoubleFlat5v11SUp",parenRightPaddingAdjustment:-1},accSagittalDoubleSharp7v11CDown:{code:"accSagittalDoubleSharp7v11CDown",parenRightPaddingAdjustment:-1},accSagittalDoubleFlat7v11CUp:{code:"accSagittalDoubleFlat7v11CUp",parenRightPaddingAdjustment:-1},accSagittalDoubleSharp55CDown:{code:"accSagittalDoubleSharp55CDown",parenRightPaddingAdjustment:-1},accSagittalDoubleFlat55CUp:{code:"accSagittalDoubleFlat55CUp",parenRightPaddingAdjustment:-1},accSagittalDoubleSharp17CDown:{code:"accSagittalDoubleSharp17CDown",parenRightPaddingAdjustment:-1},accSagittalDoubleFlat17CUp:{code:"accSagittalDoubleFlat17CUp",parenRightPaddingAdjustment:-1},accSagittalDoubleSharp7v11kDown:{code:"accSagittalDoubleSharp7v11kDown",parenRightPaddingAdjustment:-1},accSagittalDoubleFlat7v11kUp:{code:"accSagittalDoubleFlat7v11kUp",parenRightPaddingAdjustment:-1},accSagittal23CommaUp:{code:"accSagittal23CommaUp",parenRightPaddingAdjustment:-1},accSagittal23CommaDown:{code:"accSagittal23CommaDown",parenRightPaddingAdjustment:-1},accSagittal5v19CommaUp:{code:"accSagittal5v19CommaUp",parenRightPaddingAdjustment:-1},accSagittal5v19CommaDown:{code:"accSagittal5v19CommaDown",parenRightPaddingAdjustment:-1},accSagittal5v23SmallDiesisUp:{code:"accSagittal5v23SmallDiesisUp",parenRightPaddingAdjustment:-1},accSagittal5v23SmallDiesisDown:{code:"accSagittal5v23SmallDiesisDown",parenRightPaddingAdjustment:-1},accSagittalSharp5v23SDown:{code:"accSagittalSharp5v23SDown",parenRightPaddingAdjustment:-1},accSagittalFlat5v23SUp:{code:"accSagittalFlat5v23SUp",parenRightPaddingAdjustment:-1},accSagittalSharp5v19CDown:{code:"accSagittalSharp5v19CDown",parenRightPaddingAdjustment:-1},accSagittalFlat5v19CUp:{code:"accSagittalFlat5v19CUp",parenRightPaddingAdjustment:-1},accSagittalSharp23CDown:{code:"accSagittalSharp23CDown",parenRightPaddingAdjustment:-1},accSagittalFlat23CUp:{code:"accSagittalFlat23CUp",parenRightPaddingAdjustment:-1},accSagittalSharp23CUp:{code:"accSagittalSharp23CUp",parenRightPaddingAdjustment:-1},accSagittalFlat23CDown:{code:"accSagittalFlat23CDown",parenRightPaddingAdjustment:-1},accSagittalSharp5v19CUp:{code:"accSagittalSharp5v19CUp",parenRightPaddingAdjustment:-1},accSagittalFlat5v19CDown:{code:"accSagittalFlat5v19CDown",parenRightPaddingAdjustment:-1},accSagittalSharp5v23SUp:{code:"accSagittalSharp5v23SUp",parenRightPaddingAdjustment:-1},accSagittalFlat5v23SDown:{code:"accSagittalFlat5v23SDown",parenRightPaddingAdjustment:-1},accSagittalDoubleSharp5v23SDown:{code:"accSagittalDoubleSharp5v23SDown",parenRightPaddingAdjustment:-1},accSagittalDoubleFlat5v23SUp:{code:"accSagittalDoubleFlat5v23SUp",parenRightPaddingAdjustment:-1},accSagittalDoubleSharp5v19CDown:{code:"accSagittalDoubleSharp5v19CDown",parenRightPaddingAdjustment:-1},accSagittalDoubleFlat5v19CUp:{code:"accSagittalDoubleFlat5v19CUp",parenRightPaddingAdjustment:-1},accSagittalDoubleSharp23CDown:{code:"accSagittalDoubleSharp23CDown",parenRightPaddingAdjustment:-1},accSagittalDoubleFlat23CUp:{code:"accSagittalDoubleFlat23CUp",parenRightPaddingAdjustment:-1},accSagittal19SchismaUp:{code:"accSagittal19SchismaUp",parenRightPaddingAdjustment:-1},accSagittal19SchismaDown:{code:"accSagittal19SchismaDown",parenRightPaddingAdjustment:-1},accSagittal17KleismaUp:{code:"accSagittal17KleismaUp",parenRightPaddingAdjustment:-1},accSagittal17KleismaDown:{code:"accSagittal17KleismaDown",parenRightPaddingAdjustment:-1},accSagittal143CommaUp:{code:"accSagittal143CommaUp",parenRightPaddingAdjustment:-1},accSagittal143CommaDown:{code:"accSagittal143CommaDown",parenRightPaddingAdjustment:-1},accSagittal11v49CommaUp:{code:"accSagittal11v49CommaUp",parenRightPaddingAdjustment:-1},accSagittal11v49CommaDown:{code:"accSagittal11v49CommaDown",parenRightPaddingAdjustment:-1},accSagittal19CommaUp:{code:"accSagittal19CommaUp",parenRightPaddingAdjustment:-1},accSagittal19CommaDown:{code:"accSagittal19CommaDown",parenRightPaddingAdjustment:-1},accSagittal7v19CommaUp:{code:"accSagittal7v19CommaUp",parenRightPaddingAdjustment:-1},accSagittal7v19CommaDown:{code:"accSagittal7v19CommaDown",parenRightPaddingAdjustment:-1},accSagittal49SmallDiesisUp:{code:"accSagittal49SmallDiesisUp",parenRightPaddingAdjustment:-1},accSagittal49SmallDiesisDown:{code:"accSagittal49SmallDiesisDown",parenRightPaddingAdjustment:-1},accSagittal23SmallDiesisUp:{code:"accSagittal23SmallDiesisUp",parenRightPaddingAdjustment:-1},accSagittal23SmallDiesisDown:{code:"accSagittal23SmallDiesisDown",parenRightPaddingAdjustment:-1},accSagittal5v13MediumDiesisUp:{code:"accSagittal5v13MediumDiesisUp",parenRightPaddingAdjustment:-1},accSagittal5v13MediumDiesisDown:{code:"accSagittal5v13MediumDiesisDown",parenRightPaddingAdjustment:-1},accSagittal11v19MediumDiesisUp:{code:"accSagittal11v19MediumDiesisUp",parenRightPaddingAdjustment:-1},accSagittal11v19MediumDiesisDown:{code:"accSagittal11v19MediumDiesisDown",parenRightPaddingAdjustment:-1},accSagittal49MediumDiesisUp:{code:"accSagittal49MediumDiesisUp",parenRightPaddingAdjustment:-1},accSagittal49MediumDiesisDown:{code:"accSagittal49MediumDiesisDown",parenRightPaddingAdjustment:-1},accSagittal5v49MediumDiesisUp:{code:"accSagittal5v49MediumDiesisUp",parenRightPaddingAdjustment:-1},accSagittal5v49MediumDiesisDown:{code:"accSagittal5v49MediumDiesisDown",parenRightPaddingAdjustment:-1},accSagittal49LargeDiesisUp:{code:"accSagittal49LargeDiesisUp",parenRightPaddingAdjustment:-1},accSagittal49LargeDiesisDown:{code:"accSagittal49LargeDiesisDown",parenRightPaddingAdjustment:-1},accSagittal11v19LargeDiesisUp:{code:"accSagittal11v19LargeDiesisUp",parenRightPaddingAdjustment:-1},accSagittal11v19LargeDiesisDown:{code:"accSagittal11v19LargeDiesisDown",parenRightPaddingAdjustment:-1},accSagittal5v13LargeDiesisUp:{code:"accSagittal5v13LargeDiesisUp",parenRightPaddingAdjustment:-1},accSagittal5v13LargeDiesisDown:{code:"accSagittal5v13LargeDiesisDown",parenRightPaddingAdjustment:-1},accSagittalSharp23SDown:{code:"accSagittalSharp23SDown",parenRightPaddingAdjustment:-1},accSagittalFlat23SUp:{code:"accSagittalFlat23SUp",parenRightPaddingAdjustment:-1},accSagittalSharp49SDown:{code:"accSagittalSharp49SDown",parenRightPaddingAdjustment:-1},accSagittalFlat49SUp:{code:"accSagittalFlat49SUp",parenRightPaddingAdjustment:-1},accSagittalSharp7v19CDown:{code:"accSagittalSharp7v19CDown",parenRightPaddingAdjustment:-1},accSagittalFlat7v19CUp:{code:"accSagittalFlat7v19CUp",parenRightPaddingAdjustment:-1},accSagittalSharp19CDown:{code:"accSagittalSharp19CDown",parenRightPaddingAdjustment:-1},accSagittalFlat19CUp:{code:"accSagittalFlat19CUp",parenRightPaddingAdjustment:-1},accSagittalSharp11v49CDown:{code:"accSagittalSharp11v49CDown",parenRightPaddingAdjustment:-1},accSagittalFlat11v49CUp:{code:"accSagittalFlat11v49CUp",parenRightPaddingAdjustment:-1},accSagittalSharp143CDown:{code:"accSagittalSharp143CDown",parenRightPaddingAdjustment:-1},accSagittalFlat143CUp:{code:"accSagittalFlat143CUp",parenRightPaddingAdjustment:-1},accSagittalSharp17kDown:{code:"accSagittalSharp17kDown",parenRightPaddingAdjustment:-1},accSagittalFlat17kUp:{code:"accSagittalFlat17kUp",parenRightPaddingAdjustment:-1},accSagittalSharp19sDown:{code:"accSagittalSharp19sDown",parenRightPaddingAdjustment:-1},accSagittalFlat19sUp:{code:"accSagittalFlat19sUp",parenRightPaddingAdjustment:-1},accSagittalSharp19sUp:{code:"accSagittalSharp19sUp",parenRightPaddingAdjustment:-1},accSagittalFlat19sDown:{code:"accSagittalFlat19sDown",parenRightPaddingAdjustment:-1},accSagittalSharp17kUp:{code:"accSagittalSharp17kUp",parenRightPaddingAdjustment:-1},accSagittalFlat17kDown:{code:"accSagittalFlat17kDown",parenRightPaddingAdjustment:-1},accSagittalSharp143CUp:{code:"accSagittalSharp143CUp",parenRightPaddingAdjustment:-1},accSagittalFlat143CDown:{code:"accSagittalFlat143CDown",parenRightPaddingAdjustment:-1},accSagittalSharp11v49CUp:{code:"accSagittalSharp11v49CUp",parenRightPaddingAdjustment:-1},accSagittalFlat11v49CDown:{code:"accSagittalFlat11v49CDown",parenRightPaddingAdjustment:-1},accSagittalSharp19CUp:{code:"accSagittalSharp19CUp",parenRightPaddingAdjustment:-1},accSagittalFlat19CDown:{code:"accSagittalFlat19CDown",parenRightPaddingAdjustment:-1},accSagittalSharp7v19CUp:{code:"accSagittalSharp7v19CUp",parenRightPaddingAdjustment:-1},accSagittalFlat7v19CDown:{code:"accSagittalFlat7v19CDown",parenRightPaddingAdjustment:-1},accSagittalSharp49SUp:{code:"accSagittalSharp49SUp",parenRightPaddingAdjustment:-1},accSagittalFlat49SDown:{code:"accSagittalFlat49SDown",parenRightPaddingAdjustment:-1},accSagittalSharp23SUp:{code:"accSagittalSharp23SUp",parenRightPaddingAdjustment:-1},accSagittalFlat23SDown:{code:"accSagittalFlat23SDown",parenRightPaddingAdjustment:-1},accSagittalSharp5v13MUp:{code:"accSagittalSharp5v13MUp",parenRightPaddingAdjustment:-1},accSagittalFlat5v13MDown:{code:"accSagittalFlat5v13MDown",parenRightPaddingAdjustment:-1},accSagittalSharp11v19MUp:{code:"accSagittalSharp11v19MUp",parenRightPaddingAdjustment:-1},accSagittalFlat11v19MDown:{code:"accSagittalFlat11v19MDown",parenRightPaddingAdjustment:-1},accSagittalSharp49MUp:{code:"accSagittalSharp49MUp",parenRightPaddingAdjustment:-1},accSagittalFlat49MDown:{code:"accSagittalFlat49MDown",parenRightPaddingAdjustment:-1},accSagittalSharp5v49MUp:{code:"accSagittalSharp5v49MUp",parenRightPaddingAdjustment:-1},accSagittalFlat5v49MDown:{code:"accSagittalFlat5v49MDown",parenRightPaddingAdjustment:-1},accSagittalSharp49LUp:{code:"accSagittalSharp49LUp",parenRightPaddingAdjustment:-1},accSagittalFlat49LDown:{code:"accSagittalFlat49LDown",parenRightPaddingAdjustment:-1},accSagittalSharp11v19LUp:{code:"accSagittalSharp11v19LUp",parenRightPaddingAdjustment:-1},accSagittalFlat11v19LDown:{code:"accSagittalFlat11v19LDown",parenRightPaddingAdjustment:-1},accSagittalSharp5v13LUp:{code:"accSagittalSharp5v13LUp",parenRightPaddingAdjustment:-1},accSagittalFlat5v13LDown:{code:"accSagittalFlat5v13LDown",parenRightPaddingAdjustment:-1},accSagittalDoubleSharp23SDown:{code:"accSagittalDoubleSharp23SDown",parenRightPaddingAdjustment:-1},accSagittalDoubleFlat23SUp:{code:"accSagittalDoubleFlat23SUp",parenRightPaddingAdjustment:-1},accSagittalDoubleSharp49SDown:{code:"accSagittalDoubleSharp49SDown",parenRightPaddingAdjustment:-1},accSagittalDoubleFlat49SUp:{code:"accSagittalDoubleFlat49SUp",parenRightPaddingAdjustment:-1},accSagittalDoubleSharp7v19CDown:{code:"accSagittalDoubleSharp7v19CDown",parenRightPaddingAdjustment:-1},accSagittalDoubleFlat7v19CUp:{code:"accSagittalDoubleFlat7v19CUp",parenRightPaddingAdjustment:-1},accSagittalDoubleSharp19CDown:{code:"accSagittalDoubleSharp19CDown",parenRightPaddingAdjustment:-1},accSagittalDoubleFlat19CUp:{code:"accSagittalDoubleFlat19CUp",parenRightPaddingAdjustment:-1},accSagittalDoubleSharp11v49CDown:{code:"accSagittalDoubleSharp11v49CDown",parenRightPaddingAdjustment:-1},accSagittalDoubleFlat11v49CUp:{code:"accSagittalDoubleFlat11v49CUp",parenRightPaddingAdjustment:-1},accSagittalDoubleSharp143CDown:{code:"accSagittalDoubleSharp143CDown",parenRightPaddingAdjustment:-1},accSagittalDoubleFlat143CUp:{code:"accSagittalDoubleFlat143CUp",parenRightPaddingAdjustment:-1},accSagittalDoubleSharp17kDown:{code:"accSagittalDoubleSharp17kDown",parenRightPaddingAdjustment:-1},accSagittalDoubleFlat17kUp:{code:"accSagittalDoubleFlat17kUp",parenRightPaddingAdjustment:-1},accSagittalDoubleSharp19sDown:{code:"accSagittalDoubleSharp19sDown",parenRightPaddingAdjustment:-1},accSagittalDoubleFlat19sUp:{code:"accSagittalDoubleFlat19sUp",parenRightPaddingAdjustment:-1},accSagittalShaftUp:{code:"accSagittalShaftUp",parenRightPaddingAdjustment:-1},accSagittalShaftDown:{code:"accSagittalShaftDown",parenRightPaddingAdjustment:-1},accSagittalAcute:{code:"accSagittalAcute",parenRightPaddingAdjustment:-1},accSagittalGrave:{code:"accSagittalGrave",parenRightPaddingAdjustment:-1},accSagittal1MinaUp:{code:"accSagittal1MinaUp",parenRightPaddingAdjustment:-1},accSagittal1MinaDown:{code:"accSagittal1MinaDown",parenRightPaddingAdjustment:-1},accSagittal2MinasUp:{code:"accSagittal2MinasUp",parenRightPaddingAdjustment:-1},accSagittal2MinasDown:{code:"accSagittal2MinasDown",parenRightPaddingAdjustment:-1},accSagittal1TinaUp:{code:"accSagittal1TinaUp",parenRightPaddingAdjustment:-1},accSagittal1TinaDown:{code:"accSagittal1TinaDown",parenRightPaddingAdjustment:-1},accSagittal2TinasUp:{code:"accSagittal2TinasUp",parenRightPaddingAdjustment:-1},accSagittal2TinasDown:{code:"accSagittal2TinasDown",parenRightPaddingAdjustment:-1},accSagittal3TinasUp:{code:"accSagittal3TinasUp",parenRightPaddingAdjustment:-1},accSagittal3TinasDown:{code:"accSagittal3TinasDown",parenRightPaddingAdjustment:-1},accSagittal4TinasUp:{code:"accSagittal4TinasUp",parenRightPaddingAdjustment:-1},accSagittal4TinasDown:{code:"accSagittal4TinasDown",parenRightPaddingAdjustment:-1},accSagittal5TinasUp:{code:"accSagittal5TinasUp",parenRightPaddingAdjustment:-1},accSagittal5TinasDown:{code:"accSagittal5TinasDown",parenRightPaddingAdjustment:-1},accSagittal6TinasUp:{code:"accSagittal6TinasUp",parenRightPaddingAdjustment:-1},accSagittal6TinasDown:{code:"accSagittal6TinasDown",parenRightPaddingAdjustment:-1},accSagittal7TinasUp:{code:"accSagittal7TinasUp",parenRightPaddingAdjustment:-1},accSagittal7TinasDown:{code:"accSagittal7TinasDown",parenRightPaddingAdjustment:-1},accSagittal8TinasUp:{code:"accSagittal8TinasUp",parenRightPaddingAdjustment:-1},accSagittal8TinasDown:{code:"accSagittal8TinasDown",parenRightPaddingAdjustment:-1},accSagittal9TinasUp:{code:"accSagittal9TinasUp",parenRightPaddingAdjustment:-1},accSagittal9TinasDown:{code:"accSagittal9TinasDown",parenRightPaddingAdjustment:-1},accSagittalFractionalTinaUp:{code:"accSagittalFractionalTinaUp",parenRightPaddingAdjustment:-1},accSagittalFractionalTinaDown:{code:"accSagittalFractionalTinaDown",parenRightPaddingAdjustment:-1},accidentalNarrowReversedFlat:{code:"accidentalNarrowReversedFlat",parenRightPaddingAdjustment:-1},accidentalNarrowReversedFlatAndFlat:{code:"accidentalNarrowReversedFlatAndFlat",parenRightPaddingAdjustment:-1},accidentalWilsonPlus:{code:"accidentalWilsonPlus",parenRightPaddingAdjustment:-1},accidentalWilsonMinus:{code:"accidentalWilsonMinus",parenRightPaddingAdjustment:-1}},Q={"a.":{code:"augmentationDot",between_lines:!0},av:{aboveCode:"articStaccatissimoAbove",belowCode:"articStaccatissimoBelow",between_lines:!0},"a>":{aboveCode:"articAccentAbove",belowCode:"articAccentBelow",between_lines:!0},"a-":{aboveCode:"articTenutoAbove",belowCode:"articTenutoBelow",between_lines:!0},"a^":{aboveCode:"articMarcatoAbove",belowCode:"articMarcatoBelow",between_lines:!1},"a+":{code:"pluckedLeftHandPizzicato",between_lines:!1},ao:{aboveCode:"pluckedSnapPizzicatoAbove",belowCode:"pluckedSnapPizzicatoBelow",between_lines:!1},ah:{code:"stringsHarmonic",between_lines:!1},"a@":{aboveCode:"fermataAbove",belowCode:"fermataBelow",between_lines:!1},"a@a":{code:"fermataAbove",between_lines:!1},"a@u":{code:"fermataBelow",between_lines:!1},"a|":{code:"stringsUpBow",between_lines:!1},am:{code:"stringsDownBow",between_lines:!1},"a,":{code:"pictChokeCymbal",between_lines:!1}},Z={mordent:{code:"ornamentShortTrill"},mordent_inverted:{code:"ornamentMordent"},turn:{code:"ornamentTurn"},turn_inverted:{code:"ornamentTurnSlash"},tr:{code:"ornamentTrill"},upprall:{code:"ornamentPrecompSlideTrillDAnglebert"},downprall:{code:"ornamentPrecompDoubleCadenceUpperPrefix"},prallup:{code:"ornamentPrecompTrillSuffixDandrieu"},pralldown:{code:"ornamentPrecompTrillLowerSuffix"},upmordent:{code:"ornamentPrecompSlideTrillBach"},downmordent:{code:"ornamentPrecompDoubleCadenceUpperPrefixTurn"},lineprall:{code:"ornamentPrecompAppoggTrill"},prallprall:{code:"ornamentTremblement"},scoop:{code:"brassScoop"},doit:{code:"brassDoitMedium"},fall:{code:"brassFallLipShort"},doitLong:{code:"brassLiftMedium"},fallLong:{code:"brassFallRoughMedium"},bend:{code:"brassBend"},plungerClosed:{code:"brassMuteClosed"},plungerOpen:{code:"brassMuteOpen"},flip:{code:"brassFlip"},jazzTurn:{code:"brassJazzTurn"},smear:{code:"brassSmear"}};class tt{static currentMusicFont(){if(0===tt.MUSIC_FONT_STACK.length)throw new f("NoFonts","The font stack is empty. See: await Flow.fetchMusicFont(...); Flow.setMusicFont(...).");return tt.MUSIC_FONT_STACK[0]}static clefProperties(t){if(!t||!(t in K))throw new f("BadArgument","Invalid clef: "+t);return K[t]}static keyProperties(t,e="treble",i){let s={octave_shift:0};"object"==typeof i&&(s=Object.assign(Object.assign({},s),i));const n=t.split("/");if(n.length<2)throw new f("BadArguments",`First argument must be note/octave or note/octave/glyph-code: ${t}`);const a=n[0].toUpperCase(),o=$[a];if(!o)throw new f("BadArguments","Invalid key name: "+a);o.octave&&(n[1]=o.octave.toString());let r=parseInt(n[1],10);r+=-1*s.octave_shift;let h=(7*r-28+o.index)/2;h+=tt.clefProperties(e).line_shift;let c=0;h<=0&&2*h%2==0&&(c=1),h>=6&&2*h%2==0&&(c=-1);const d=void 0!==o.int_val?12*r+o.int_val:void 0,l=o.code,g=o.shift_right;let u={};if(n.length>2&&n[2]){const t=n[2].toUpperCase();u=J[t]||{}}return Object.assign({key:a,octave:r,line:h,int_value:d,accidental:o.accidental,code:l,stroke:c,shift_right:g,displaced:!1},u)}static integerToNote(t){if(void 0===t||t<0||t>11)throw new f("BadArguments",`integerToNote() requires an integer in the range [0, 11]: ${t}`);const e={0:"C",1:"C#",2:"D",3:"D#",4:"E",5:"F",6:"F#",7:"G",8:"G#",9:"A",10:"A#",11:"B"}[t];if(!e)throw new f("BadArguments",`Unknown note value for integer: ${t}`);return e}static tabToGlyph(t,e=1){let i,s=0,n=0;if("X"===t.toUpperCase()){const t=new U("accidentalDoubleSharp",tt.TABLATURE_FONT_SCALE).getMetrics();if(i="accidentalDoubleSharp",null==t.width||null==t.height)throw new f("InvalidMetrics","Width and height required");s=t.width,n=-t.height/2}else s=tt.textWidth(t);return{text:t,code:i,getWidth:()=>s*e,shift_y:n}}static textWidth(t){return 7*t.toString().length}static articulationCodes(t){return Q[t]}static accidentalCodes(t){return q[t]}static ornamentCodes(t){return Z[t]}static keySignature(t){const e=z[t];if(!e)throw new f("BadKeySignature",`Bad key signature spec: '${t}'`);if(!e.acc)return[];const i={b:[2,.5,2.5,1,3,1.5,3.5],"#":[0,1.5,-.5,1,2.5,.5,2]}[e.acc],s=[];for(let t=0;t<e.num;++t){const n=i[t];s.push({type:e.acc,line:n})}return s}static getKeySignatures(){return z}static hasKeySignature(t){return t in z}static sanitizeDuration(t){const e=V[t];if(void 0!==e&&(t=e),void 0===X[t])throw new f("BadArguments",`The provided duration is not valid: ${t}`);return t}static durationToFraction(t){return(new v).parse(tt.sanitizeDuration(t))}static durationToNumber(t){return tt.durationToFraction(t).value()}static durationToTicks(t){t=tt.sanitizeDuration(t);const e=X[t];if(void 0===e)throw new f("InvalidDuration");return e}static getGlyphProps(t,e="n"){t=tt.sanitizeDuration(t);const i=et[t];if(void 0===i)return;let s=i.type[e];if(void 0===s){const t=J[e.toUpperCase()];if(void 0===t)return;s=Object.assign({code_head:t.code},t)}const n=s.code_head;return Object.assign(Object.assign(Object.assign({},i.common),{getWidth:(t=tt.NOTATION_FONT_SCALE)=>U.getWidth(n,t)}),s)}}tt.STEM_WIDTH=1.5,tt.STEM_HEIGHT=35,tt.STAVE_LINE_THICKNESS=1,tt.RESOLUTION=j,tt.MUSIC_FONT_STACK=[],tt.NOTATION_FONT_SCALE=39,tt.TABLATURE_FONT_SCALE=39,tt.SLASH_NOTEHEAD_WIDTH=15,tt.STAVE_LINE_DISTANCE=10,tt.TEXT_HEIGHT_OFFSET_HACK=1,tt.accidentalMap=q,tt.accidentalColumnsTable={1:{a:[1],b:[1]},2:{a:[1,2]},3:{a:[1,3,2],b:[1,2,1],second_on_bottom:[1,2,3]},4:{a:[1,3,4,2],b:[1,2,3,1],spaced_out_tetrachord:[1,2,1,2]},5:{a:[1,3,5,4,2],b:[1,2,4,3,1],spaced_out_pentachord:[1,2,3,2,1],very_spaced_out_pentachord:[1,2,1,2,1]},6:{a:[1,3,5,6,4,2],b:[1,2,4,5,3,1],spaced_out_hexachord:[1,3,2,1,3,2],very_spaced_out_hexachord:[1,2,1,2,1,2]}},tt.unicode={sharp:String.fromCharCode(9839),flat:String.fromCharCode(9837),natural:String.fromCharCode(9838),triangle:String.fromCharCode(9651),"o-with-slash":String.fromCharCode(248),degrees:String.fromCharCode(176),circle:String.fromCharCode(9675)},tt.validTypes={n:{name:"note"},r:{name:"rest"},h:{name:"harmonic"},m:{name:"muted"},s:{name:"slash"},g:{name:"ghost"}},tt.TIME4_4={num_beats:4,beat_value:4,resolution:j};const et={"1/2":{common:{stem:!1,stem_offset:0,flag:!1,stem_up_extension:-tt.STEM_HEIGHT,stem_down_extension:-tt.STEM_HEIGHT,tabnote_stem_up_extension:-tt.STEM_HEIGHT,tabnote_stem_down_extension:-tt.STEM_HEIGHT,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"noteheadDoubleWhole"},h:{code_head:"unpitchedPercussionClef1"},m:{code_head:"vexNoteHeadMutedBreve",stem_offset:0},r:{code_head:"restDoubleWhole",rest:!0,position:"B/5",dot_shiftY:.5},s:{getWidth:()=>tt.SLASH_NOTEHEAD_WIDTH,position:"B/4"},g:{code_head:"noteheadDoubleWhole"}}},1:{common:{stem:!1,stem_offset:0,flag:!1,stem_up_extension:-tt.STEM_HEIGHT,stem_down_extension:-tt.STEM_HEIGHT,tabnote_stem_up_extension:-tt.STEM_HEIGHT,tabnote_stem_down_extension:-tt.STEM_HEIGHT,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"noteheadWhole"},h:{code_head:"noteheadDiamondWhole"},m:{code_head:"noteheadXWhole",stem_offset:-3},r:{code_head:"restWhole",rest:!0,position:"D/5",dot_shiftY:.5},s:{getWidth:()=>tt.SLASH_NOTEHEAD_WIDTH,position:"B/4"},g:{code_head:"noteheadWhole"}}},2:{common:{stem:!0,stem_offset:0,flag:!1,stem_up_extension:0,stem_down_extension:0,tabnote_stem_up_extension:0,tabnote_stem_down_extension:0,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"noteheadHalf"},h:{code_head:"noteheadDiamondHalf"},m:{code_head:"noteheadXHalf",stem_offset:-3},r:{code_head:"restHalf",stem:!1,rest:!0,position:"B/4",dot_shiftY:-.5},s:{getWidth:()=>tt.SLASH_NOTEHEAD_WIDTH,position:"B/4"},g:{code_head:"noteheadHalf"}}},4:{common:{stem:!0,stem_offset:0,flag:!1,stem_up_extension:0,stem_down_extension:0,tabnote_stem_up_extension:0,tabnote_stem_down_extension:0,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"noteheadBlack"},h:{code_head:"noteheadDiamondBlack"},m:{code_head:"noteheadXBlack"},r:{code_head:"restQuarter",stem:!1,rest:!0,position:"B/4",dot_shiftY:-.5,line_above:1.5,line_below:1.5},s:{getWidth:()=>tt.SLASH_NOTEHEAD_WIDTH,position:"B/4"},g:{code_head:"noteheadBlack"}}},8:{common:{stem:!0,stem_offset:0,flag:!0,beam_count:1,stem_beam_extension:0,code_flag_upstem:"flag8thUp",code_flag_downstem:"flag8thDown",stem_up_extension:0,stem_down_extension:0,tabnote_stem_up_extension:0,tabnote_stem_down_extension:0,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"noteheadBlack"},h:{code_head:"noteheadDiamondBlack"},m:{code_head:"noteheadXBlack"},r:{code_head:"rest8th",stem:!1,flag:!1,rest:!0,position:"B/4",dot_shiftY:-.5,line_above:1,line_below:1},s:{getWidth:()=>tt.SLASH_NOTEHEAD_WIDTH,position:"B/4"},g:{code_head:"noteheadBlack"}}},16:{common:{beam_count:2,stem_beam_extension:0,stem:!0,stem_offset:0,flag:!0,code_flag_upstem:"flag16thUp",code_flag_downstem:"flag16thDown",stem_up_extension:0,stem_down_extension:0,tabnote_stem_up_extension:0,tabnote_stem_down_extension:0,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"noteheadBlack"},h:{code_head:"noteheadDiamondBlack"},m:{code_head:"noteheadXBlack"},r:{code_head:"rest16th",stem:!1,flag:!1,rest:!0,position:"B/4",dot_shiftY:-.5,line_above:1,line_below:2},s:{getWidth:()=>tt.SLASH_NOTEHEAD_WIDTH,position:"B/4"},g:{code_head:"noteheadBlack"}}},32:{common:{beam_count:3,stem_beam_extension:7.5,stem:!0,stem_offset:0,flag:!0,code_flag_upstem:"flag32ndUp",code_flag_downstem:"flag32ndDown",stem_up_extension:9,stem_down_extension:9,tabnote_stem_up_extension:9,tabnote_stem_down_extension:9,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"noteheadBlack"},h:{code_head:"noteheadDiamondBlack"},m:{code_head:"noteheadXBlack"},r:{code_head:"rest32nd",stem:!1,flag:!1,rest:!0,position:"B/4",dot_shiftY:-1.5,line_above:2,line_below:2},s:{getWidth:()=>tt.SLASH_NOTEHEAD_WIDTH,position:"B/4"},g:{code_head:"noteheadBlack"}}},64:{common:{beam_count:4,stem_beam_extension:15,stem:!0,stem_offset:0,flag:!0,code_flag_upstem:"flag64thUp",code_flag_downstem:"flag64thDown",stem_up_extension:13,stem_down_extension:13,tabnote_stem_up_extension:13,tabnote_stem_down_extension:13,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"noteheadBlack"},h:{code_head:"noteheadDiamondBlack"},m:{code_head:"noteheadXBlack"},r:{code_head:"rest64th",stem:!1,flag:!1,rest:!0,position:"B/4",dot_shiftY:-1.5,line_above:2,line_below:3},s:{getWidth:()=>tt.SLASH_NOTEHEAD_WIDTH,position:"B/4"},g:{code_head:"noteheadBlack"}}},128:{common:{beam_count:5,stem_beam_extension:22.5,stem:!0,stem_offset:0,flag:!0,code_flag_upstem:"flag128thUp",code_flag_downstem:"flag128thDown",stem_up_extension:22,stem_down_extension:22,tabnote_stem_up_extension:22,tabnote_stem_down_extension:22,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"noteheadBlack"},h:{code_head:"noteheadDiamondBlack"},m:{code_head:"noteheadXBlack"},r:{code_head:"rest128th",stem:!1,flag:!1,rest:!0,position:"B/4",dot_shiftY:-2.5,line_above:3,line_below:3},s:{getWidth:()=>tt.SLASH_NOTEHEAD_WIDTH,position:"B/4"},g:{code_head:"noteheadBlack"}}}};function it(...t){st.DEBUG&&S("Vex.Flow.Accidental",t)}class st extends H{constructor(t){super(),it("New accidental: ",t),this.type=t,this.position=H.Position.LEFT,this.render_options={font_scale:38,parenLeftPadding:2,parenRightPadding:2},this.accidental=tt.accidentalCodes(this.type),x(this.accidental,"ArgumentError",`Unknown accidental type: ${t}`),this.cautionary=!1,this.reset()}static get CATEGORY(){return m.Accidental}static format(t,e){if(!t||0===t.length)return;const i=tt.currentMusicFont(),s=i.lookupMetric("accidental.noteheadAccidentalPadding"),n=e.left_shift+s,a=i.lookupMetric("accidental.accidentalSpacing"),o=i.lookupMetric("accidental.leftPadding"),r=[];let h,c=0;for(let e=0;e<t.length;++e){const i=t[e],s=i.getNote(),n=s.getStave(),a=i.checkIndex(),o=s.getKeyProps()[a];if(s!==h){for(let t=0;t<s.keys.length;++t)c=Math.max(s.getLeftDisplacedHeadPx()-s.getXShift(),c);h=s}if(n){const t=n.getSpacingBetweenLines(),e=n.getYForLine(o.line),s=Math.round(e/t*2)/2;r.push({y:e,line:s,shift:c,acc:i,lineSpace:t})}else r.push({line:o.line,shift:c,acc:i})}r.sort(((t,e)=>e.line-t.line));const d=[];let l,g=0;for(let t=0;t<r.length;t++){const e=r[t];void 0!==l&&l===e.line||d.push({line:e.line,flatLine:!0,dblSharpLine:!0,numAcc:0,width:0,column:0}),"b"!==e.acc.type&&"bb"!==e.acc.type&&(d[d.length-1].flatLine=!1),"##"!==e.acc.type&&(d[d.length-1].dblSharpLine=!1),d[d.length-1].numAcc++,d[d.length-1].width+=e.acc.getWidth()+a,g=e.shift>g?e.shift:g,l=e.line}let u=0;for(let t=0;t<d.length;t++){let e=!1;const i=t;let s=t;for(;s+1<d.length&&!e;)this.checkCollision(d[s],d[s+1])?s++:e=!0;const n=t=>d[i+t],a=t=>t.map(n),o=(t,e)=>{const[i,s]=a([t,e]).map((t=>t.line));return i-s},r=(...t)=>t.map(a).every((([t,e])=>!this.checkCollision(t,e))),h=s-i+1;let c,l,g=this.checkCollision(d[i],d[s])?"a":"b";switch(h){case 3:"a"===g&&.5===o(1,2)&&.5!==o(0,1)&&(g="second_on_bottom");break;case 4:r([0,2],[1,3])&&(g="spaced_out_tetrachord");break;case 5:"b"===g&&r([1,3])&&(g="spaced_out_pentachord",r([0,2],[2,4])&&(g="very_spaced_out_pentachord"));break;case 6:r([0,3],[1,4],[2,5])&&(g="spaced_out_hexachord"),r([0,2],[2,4],[1,3],[3,5])&&(g="very_spaced_out_hexachord")}if(h>=7){let e=2,i=!0;for(;!0===i;){i=!1;for(let t=0;t+e<d.length;t++)if(this.checkCollision(d[t],d[t+e])){i=!0,e++;break}}for(c=t;c<=s;c++)l=(c-t)%e+1,d[c].column=l,u=u>l?u:l}else for(c=t;c<=s;c++)l=tt.accidentalColumnsTable[h][g][c-t],d[c].column=l,u=u>l?u:l;t=s}const p=[],m=[];for(let t=0;t<=u;t++)p[t]=0,m[t]=0;p[0]=g+n,m[0]=g+n,d.forEach((t=>{t.width>p[t.column]&&(p[t.column]=t.width)}));for(let t=1;t<p.length;t++)m[t]=p[t]+m[t-1];const f=m[m.length-1];let _=0;d.forEach((t=>{let e=0;const i=_+t.numAcc;for(;_<i;_++){const i=m[t.column-1]+e;r[_].acc.setXShift(i),e+=r[_].acc.getWidth()+a,it("Line, accCount, shift: ",t.line,_,i)}})),e.left_shift+=f+o}static checkCollision(t,e){let i=e.line-t.line,s=3;i>0?(s=e.flatLine||e.dblSharpLine?2.5:3,t.dblSharpLine&&(i-=.5)):(s=t.flatLine||t.dblSharpLine?2.5:3,e.dblSharpLine&&(i-=.5));const n=Math.abs(i)<s;return it("Line_1, Line_2, Collision: ",t.line,e.line,n),n}static applyAccidentals(t,e){const i=[],s={};t.forEach((t=>{const e=new v(0,1);t.getTickables().forEach((t=>{if(t.shouldIgnoreTicks())return;const n=s[e.value()];n?n.push(t):(i.push(e.value()),s[e.value()]=[t]),e.add(t.getTicks())}))}));const a=new Y;e||(e="C");const o=a.createScaleMap(e),r={};i.forEach((t=>{const e=s[t],i=[],h=t=>{if(!g(t)||t.isRest()||t.shouldIgnoreTicks())return;const e=t;e.keys.forEach(((t,s)=>{const h=a.getNoteParts(t.split("/")[0]),c=t.split("/")[1],d=h.accidental||"n",l=h.root+d;r[h.root+c]||(r[h.root+c]=o[h.root]);const g=r[h.root+c]===l,u=i.indexOf(t)>-1;if(e.getModifiers().forEach(((t,i)=>{n(t)&&t.type==d&&t.getIndex()==s&&e.getModifiers().splice(i,1)})),!g||g&&u){r[h.root+c]=l;const n=new st(d);e.addModifier(n,s),i.push(t)}})),e.getModifiers().forEach((t=>{c(t)&&t.getGraceNotes().forEach(h)}))};e.forEach(h)}))}reset(){const t=this.render_options.font_scale;this.glyph=new U(this.accidental.code,t),this.glyph.setOriginX(1),this.cautionary&&(this.parenLeft=new U(tt.accidentalCodes("{").code,t),this.parenRight=new U(tt.accidentalCodes("}").code,t),this.parenLeft.setOriginX(1),this.parenRight.setOriginX(1))}getWidth(){if(this.cautionary){const t=x(this.parenLeft),e=x(this.parenRight),i=t.getMetrics().width+e.getMetrics().width+this.render_options.parenLeftPadding+this.render_options.parenRightPadding;return this.glyph.getMetrics().width+i}return this.glyph.getMetrics().width}setNote(t){return x(t,"ArgumentError",`Bad note value: ${t}`),this.note=t,h(t)&&(this.render_options.font_scale=25,this.reset()),this}setAsCautionary(){return this.cautionary=!0,this.render_options.font_scale=28,this.reset(),this}draw(){const{type:t,position:e,index:i,cautionary:s,x_shift:n,y_shift:a,glyph:o,render_options:{parenLeftPadding:r,parenRightPadding:h}}=this,c=this.checkContext(),d=this.checkAttachedNote();this.setRendered();const l=d.getModifierStartXY(e,i);let g=l.x+n;const u=l.y+a;if(it("Rendering: ",t,g,u),s){const t=x(this.parenLeft),e=x(this.parenRight);e.render(c,g,u),g-=e.getMetrics().width,g-=h,g-=this.accidental.parenRightPaddingAdjustment,o.render(c,g,u),g-=o.getMetrics().width,g-=r,t.render(c,g,u)}else o.render(c,g,u)}}st.DEBUG=!1;class nt extends O{constructor(t){super(),this.stem_up_y_offset=0,this.stem_down_y_offset=0,this.stem_up_y_base_offset=0,this.stem_down_y_base_offset=0,this.x_begin=(null==t?void 0:t.x_begin)||0,this.x_end=(null==t?void 0:t.x_end)||0,this.y_top=(null==t?void 0:t.y_top)||0,this.y_bottom=(null==t?void 0:t.y_bottom)||0,this.stem_extension=(null==t?void 0:t.stem_extension)||0,this.stem_direction=(null==t?void 0:t.stem_direction)||0,this.hide=(null==t?void 0:t.hide)||!1,this.isStemlet=(null==t?void 0:t.isStemlet)||!1,this.stemletHeight=(null==t?void 0:t.stemletHeight)||0,this.renderHeightAdjustment=0,this.setOptions(t)}static get CATEGORY(){return m.Stem}static get UP(){return 1}static get DOWN(){return-1}static get WIDTH(){return tt.STEM_WIDTH}static get HEIGHT(){return tt.STEM_HEIGHT}setOptions(t){this.stem_up_y_offset=(null==t?void 0:t.stem_up_y_offset)||0,this.stem_down_y_offset=(null==t?void 0:t.stem_down_y_offset)||0,this.stem_up_y_base_offset=(null==t?void 0:t.stem_up_y_base_offset)||0,this.stem_down_y_base_offset=(null==t?void 0:t.stem_down_y_base_offset)||0}setNoteHeadXBounds(t,e){return this.x_begin=t,this.x_end=e,this}setDirection(t){this.stem_direction=t}setExtension(t){this.stem_extension=t}getExtension(){return this.stem_extension}setYBounds(t,e){this.y_top=t,this.y_bottom=e}getHeight(){const t=this.stem_direction===nt.UP?this.stem_up_y_offset:this.stem_down_y_offset;return(this.y_bottom-this.y_top+(nt.HEIGHT-t+this.stem_extension))*this.stem_direction}getBoundingBox(){throw new f("NotImplemented","getBoundingBox() not implemented.")}getExtents(){const t=this.stem_direction===nt.UP,e=[this.y_top,this.y_bottom],i=nt.HEIGHT+this.stem_extension,s=(t?Math.min:Math.max)(...e),n=(t?Math.max:Math.min)(...e);return{topY:s+i*-this.stem_direction,baseY:n}}setVisibility(t){return this.hide=!t,this}setStemlet(t,e){return this.isStemlet=t,this.stemletHeight=e,this}adjustHeightForFlag(){this.renderHeightAdjustment=tt.currentMusicFont().lookupMetric("stem.heightAdjustmentForFlag",-3)}adjustHeightForBeam(){this.renderHeightAdjustment=-nt.WIDTH/2}draw(){if(this.setRendered(),this.hide)return;const t=this.checkContext();let e,i;const s=this.stem_direction;let n=0;s===nt.DOWN?(e=this.x_begin,i=this.y_top+this.stem_down_y_offset,n=this.stem_down_y_base_offset):(e=this.x_end,i=this.y_bottom-this.stem_up_y_offset,n=this.stem_up_y_base_offset);const a=this.getHeight();!function(...t){nt.DEBUG&&S("Vex.Flow.Stem",t)}("Rendering stem - ","Top Y: ",this.y_top,"Bottom Y: ",this.y_bottom);const o=this.isStemlet?a-this.stemletHeight*this.stem_direction:0;t.save(),this.applyStyle(t),t.beginPath(),t.setLineWidth(nt.WIDTH),t.moveTo(e,i-o+n),t.lineTo(e,i-a-this.renderHeightAdjustment*s),t.stroke(),this.restoreStyle(t),t.restore()}}function at(...t){ht.DEBUG&&S("Vex.Flow.TextFormatter",t)}nt.DEBUG=!1;const ot={},rt={};class ht{constructor(t){this.family="",this.size=14,this.resolution=1e3,this.glyphs={},this.serifs=!1,this.monospaced=!1,this.italic=!1,this.bold=!1,this.superscriptOffset=0,this.subscriptOffset=0,this.maxSizeGlyph="H",this.cacheKey="",this.updateParams(t)}static getFontFamilies(){const t=[];for(const e in rt){const i=rt[e];t.push(Object.assign({},i))}return t}static create(t={}){at("create: ",t),t.family||(t.family=M.SANS_SERIF);const e=[],i=t.family.split(/\s*,\s*/);for(const t of i){for(const i in rt)i.startsWith(t)&&e.push(rt[i]);if(e.length>0)break}let s;if(0===e.length)s=new ht(Object.values(rt)[0]);else if(1===e.length)s=new ht(e[0]);else{const i=M.isBold(t.weight),n=M.isItalic(t.style),a=e.find((t=>t.bold===i&&t.italic===n));if(a)s=new ht(a);else{const t=e.find((t=>t.italic===n||t.bold===i));s=new ht(t||e[0])}}const n=t.size;if(void 0!==n){const t=M.convertSizeToPointValue(n);s.setFontSize(t)}return s}static getInfo(t){return rt[t]}static registerInfo(t,e=!1){at("registerInfo: ",t,e);const i=t.family;(void 0===rt[i]||e)&&(rt[i]=t)}updateParams(t){t.family&&(this.family=t.family),t.resolution&&(this.resolution=t.resolution),t.glyphs&&(this.glyphs=t.glyphs),t.serifs&&(this.serifs=t.serifs),t.monospaced&&(this.monospaced=t.monospaced),t.italic&&(this.italic=t.italic),t.bold&&(this.bold=t.bold),t.maxSizeGlyph&&(this.maxSizeGlyph=t.maxSizeGlyph),t.superscriptOffset&&(this.superscriptOffset=t.superscriptOffset),t.subscriptOffset&&(this.subscriptOffset=t.subscriptOffset),this.updateCacheKey()}updateCacheKey(){const t=this.family.replace(/\s+/g,"_"),e=this.size,i=this.bold?k.BOLD:k.NORMAL,s=this.italic?D.ITALIC:D.NORMAL;this.cacheKey=`${t}%${e}%${i}%${s}`}getGlyphMetrics(t){return this.glyphs[t]?this.glyphs[t]:this.glyphs[this.maxSizeGlyph]}get maxHeight(){return this.getGlyphMetrics(this.maxSizeGlyph).ha/this.resolution*this.fontSizeInPixels}getWidthForCharacterInEm(t){var e;const i=this.getGlyphMetrics(t);if(i){return(null!==(e=i.advanceWidth)&&void 0!==e?e:0)/this.resolution}return.65}getWidthForTextInEm(t){const e=this.cacheKey;let i=ot[e];void 0===i&&(i={},ot[e]=i);let s=i[t];if(void 0===s){s=0;for(let e=0;e<t.length;++e)s+=this.getWidthForCharacterInEm(t[e]);i[t]=s}return s}getWidthForTextInPx(t){return this.getWidthForTextInEm(t)*this.fontSizeInPixels}setFontSize(t){return this.size=t,this.updateCacheKey(),this}get fontSizeInPixels(){return this.size*M.scaleToPxFrom.pt}getResolution(){return this.resolution}}var ct,dt;ht.DEBUG=!1,function(t){t[t.LEFT=1]="LEFT",t[t.CENTER=2]="CENTER",t[t.RIGHT=3]="RIGHT",t[t.CENTER_STEM=4]="CENTER_STEM"}(ct||(ct={})),function(t){t[t.TOP=1]="TOP",t[t.CENTER=2]="CENTER",t[t.BOTTOM=3]="BOTTOM",t[t.CENTER_STEM=4]="CENTER_STEM"}(dt||(dt={}));class lt extends H{constructor(t){super(),this.text=t,this.horizontalJustification=ct.CENTER,this.verticalJustification=dt.TOP,this.resetFont(),this.setWidth(tt.textWidth(t))}static get CATEGORY(){return m.Annotation}static get minAnnotationPadding(){return tt.currentMusicFont().lookupMetric("glyphs.noteHead.minPadding")}static format(t,e){if(!t||0===t.length)return!1;let i=0,s=0,n=0,a=0;for(let o=0;o<t.length;++o){const r=t[o],h=ht.create(r.textFont);let c=(5+h.maxHeight)/tt.STAVE_LINE_DISTANCE;const d=r.checkAttachedNote(),l=d.getGlyph().getWidth(),g=h.getWidthForTextInPx(r.text);r.horizontalJustification===ct.LEFT?(n=Math.max(l,n),i=Math.max(i,g)+lt.minAnnotationPadding):r.horizontalJustification===ct.RIGHT?(a=Math.max(l,n),s=Math.max(s,g)):(i=Math.max(i,g/2)+lt.minAnnotationPadding,s=Math.max(s,g/2),n=Math.max(l/2,n),a=Math.max(l/2,a));const m=d.getStave(),f=d.hasStem()?d.getStemDirection():nt.UP;let _=0,x=5;if(p(d))if(d.render_options.draw_stem){const t=d.getStem();t&&(_=Math.abs(t.getHeight())/tt.STAVE_LINE_DISTANCE)}else _=0;else if(u(d)){const t=d.getStem();t&&"n"===d.getNoteType()&&(_=Math.abs(t.getHeight())/tt.STAVE_LINE_DISTANCE)}if(m&&(x=m.getNumLines()),r.verticalJustification===this.VerticalJustify.TOP){let t=d.getLineNumber(!0);p(d)&&(t=x-(d.leastString()-.5)),f===nt.UP&&(t+=_);t+e.top_text_line+.5<x?(r.setTextLine(x-t),c+=x-t,e.top_text_line=c):(r.setTextLine(e.top_text_line),e.top_text_line+=c)}else if(r.verticalJustification===this.VerticalJustify.BOTTOM){let t=x-d.getLineNumber();p(d)&&(t=d.greatestString()-1),f===nt.DOWN&&(t+=_);const i=t+e.text_line+1;i<x?(r.setTextLine(x-i),c+=x-i,e.text_line=c):(r.setTextLine(e.text_line),e.text_line+=c)}else r.setTextLine(e.text_line)}const o=Math.min(Math.max(s-a,0),Math.max(s-e.right_shift,0)),r=Math.min(Math.max(i-n,0),Math.max(i-e.left_shift,0));return e.left_shift+=r,e.right_shift+=o,!0}setVerticalJustification(t){return this.verticalJustification="string"==typeof t?lt.VerticalJustifyString[t]:t,this}getJustification(){return this.horizontalJustification}setJustification(t){return this.horizontalJustification="string"==typeof t?lt.HorizontalJustifyString[t]:t,this}draw(){const t=this.checkContext(),e=this.checkAttachedNote(),i=e.hasStem()?e.getStemDirection():nt.UP,s=ht.create(this.textFont),n=e.getModifierStartXY(I.ABOVE,this.index);this.setRendered(),t.save(),this.applyStyle();const a=Object.keys(this.getAttribute("classes")).join(" ");t.openGroup(a,this.getAttribute("id")),t.setFont(this.textFont);const o=t.measureText(this.text).width,r=s.maxHeight+2;let h,c;h=this.horizontalJustification===ct.LEFT?n.x:this.horizontalJustification===ct.RIGHT?n.x-o:this.horizontalJustification===ct.CENTER?n.x-o/2:e.getStemX()-o/2;let d={},l=0;const g=e.hasStem(),u=e.checkStave();if(g&&(d=e.checkStem().getExtents(),l=u.getSpacingBetweenLines()),this.verticalJustification===dt.BOTTOM){c=e.getYs().reduce(((t,e)=>t>e?t:e)),c+=(this.text_line+1)*tt.STAVE_LINE_DISTANCE+r,g&&i===nt.DOWN&&(c=Math.max(c,d.topY+r+l*this.text_line))}else if(this.verticalJustification===dt.CENTER){const t=e.getYForTopText(this.text_line)-1;c=t+(u.getYForBottomText(this.text_line)-t)/2+r/2}else if(this.verticalJustification===dt.TOP)c=e.getYs()[0]-(this.text_line+1)*tt.STAVE_LINE_DISTANCE,g&&i===nt.UP&&(l=d.topY<u.getTopLineTopY()?tt.STAVE_LINE_DISTANCE:l,c=Math.min(c,d.topY-l*(this.text_line+1)));else{const t=e.getStemExtents();c=t.topY+(t.baseY-t.topY)/2+r/2}!function(...t){lt.DEBUG&&S("Vex.Flow.Annotation",t)}("Rendering annotation: ",this.text,h,c),t.fillText(this.text,h,c),t.closeGroup(),this.restoreStyle(),t.restore()}}lt.DEBUG=!1,lt.TEXT_FONT=Object.assign({},O.TEXT_FONT),lt.HorizontalJustify=ct,lt.HorizontalJustifyString={left:ct.LEFT,right:ct.RIGHT,center:ct.CENTER,centerStem:ct.CENTER_STEM},lt.VerticalJustify=dt,lt.VerticalJustifyString={above:dt.TOP,top:dt.TOP,below:dt.BOTTOM,bottom:dt.BOTTOM,center:dt.CENTER,centerStem:dt.CENTER_STEM};const{ABOVE:gt,BELOW:ut}=H.Position;function pt(t,e){return.5*t(e/.5)}function mt(t,e){return e===gt?t<=5:t>=1}function ft(t,e){return mt(t,e)?e===gt?Math.ceil:Math.floor:Math.round}const _t=t=>g(t)||h(t);class xt extends H{constructor(t){super(),this.type=t,this.position=ut,this.render_options={font_scale:38},this.reset()}static get CATEGORY(){return m.Articulation}static format(t,e){if(!t||0===t.length)return!1;let i=0;const s=(t,e,i)=>pt(ft(e,i),x(t.glyph.getMetrics().height)/10+.5);t.forEach((t=>{const n=t.checkAttachedNote();i=Math.max(n.getGlyph().getWidth(),i);let a=5;const o=n.hasStem()?n.getStemDirection():nt.UP;let r=0;if(u(n)){const t=n.getStem();t&&(r=Math.abs(t.getHeight())/tt.STAVE_LINE_DISTANCE)}const h=n.getStave();if(h&&(a=h.getNumLines()),t.getPosition()===gt){let i=n.getLineNumber(!0);o===nt.UP&&(i+=r);let h=s(t,e.top_text_line,gt);const c=i+e.top_text_line+.5;!t.articulation.between_lines&&c<a&&(h+=a-c),t.setTextLine(e.top_text_line),e.top_text_line+=h}else if(t.getPosition()===ut){let i=Math.max(a-n.getLineNumber(),0);o===nt.DOWN&&(i+=r);let h=s(t,e.text_line,ut);const c=i+e.text_line+.5;!t.articulation.between_lines&&c<a&&(h+=a-c),t.setTextLine(e.text_line),e.text_line+=h}}));const n=t.map((t=>t.getWidth())).reduce(((t,e)=>Math.max(e,t))),a=Math.min(Math.max(n-i,0),Math.max(n-(e.left_shift+e.right_shift),0));return e.left_shift+=a/2,e.right_shift+=a/2,!0}static easyScoreHook({articulations:t},e,i){if(!t)return;const s={staccato:"a.",tenuto:"a-",accent:"a>"};t.split(",").map((t=>t.trim().split("."))).map((([t,e])=>{const n={type:s[t]};return e&&(n.position=H.PositionString[e]),i.getFactory().Articulation(n)})).map((t=>e.addModifier(t,0)))}reset(){this.articulation=tt.articulationCodes(this.type);const t=x(this.articulation,"ArgumentError",`Articulation not found: ${this.type}`),e=(this.position===gt?t.aboveCode:t.belowCode)||t.code;this.glyph=new U(null!=e?e:"",this.render_options.font_scale),this.setWidth(x(this.glyph.getMetrics().width))}draw(){const t=this.checkContext(),e=this.checkAttachedNote();this.setRendered();const i=this.checkIndex(),{position:s,glyph:n,text_line:a}=this,o=this.articulation.between_lines,r=e.checkStave(),h=r.getSpacingBetweenLines(),c=p(e),{x:d}=e.getModifierStartXY(s,i),l=!o||c,g=function(t,e){const i=e===gt&&t.getStemDirection()===nt.UP||e===ut&&t.getStemDirection()===nt.DOWN;return _t(t)?t.hasStem()&&i?.5:1:t.hasStem()&&i?1:0}(e,s),u=tt.currentMusicFont().lookupMetric(`articulation.${n.getCode()}.padding`,0);let m={[gt]:()=>{n.setOrigin(.5,1);const t=function(t,e){const i=t.getStemDirection(),{topY:s,baseY:n}=t.getStemExtents();if(_t(t))return t.hasStem()?i===nt.UP?s:n:Math.min(...t.getYs());if(p(t))return t.hasStem()&&i===nt.UP?s:t.checkStave().getYForTopText(e);throw new f("UnknownCategory","Only can get the top and bottom ys of stavenotes and tabnotes")}(e,a)-(a+g)*h;return l?Math.min(r.getYForTopText(xt.INITIAL_OFFSET),t):t},[ut]:()=>{n.setOrigin(.5,0);const t=function(t,e){const i=t.getStemDirection(),{topY:s,baseY:n}=t.getStemExtents();if(_t(t))return t.hasStem()?i===nt.UP?n:s:Math.max(...t.getYs());if(p(t))return t.hasStem()?i===nt.UP?t.checkStave().getYForBottomText(e):s:t.checkStave().getYForBottomText(e);throw new f("UnknownCategory","Only can get the top and bottom ys of stavenotes and tabnotes")}(e,a)+(a+g)*h;return l?Math.max(r.getYForBottomText(xt.INITIAL_OFFSET),t):t}}[s]();if(!c){const t=s===gt?-1:1,a=e.getKeyProps()[i].line,r=(e.getYs()[i]-m)/h+Number(a),c=function(t,e,i,s){const n=pt(ft(e,i),e);if(t&&mt(n,i)&&n%1==0)return n+.5*-s;return n}(o,r,s,t);mt(c,s)&&n.setOrigin(.5,.5),m+=Math.abs(c-r)*h*t+u*t}!function(...t){xt.DEBUG&&S("Vex.Flow.Articulation",t)}(`Rendering articulation at (x: ${d}, y: ${m})`),n.render(t,d,m)}}xt.DEBUG=!1,xt.INITIAL_OFFSET=-.5;class St{static get CATEGORY(){return m.RenderContext}set font(t){this.setFont(t)}get font(){return this.getFont()}setRawFont(t){return this.setFont(t),this}}function yt(t,e,i,s="#F55"){t.save(),t.setFillStyle(s),t.beginPath(),t.arc(e,i,3,0,2*Math.PI,!0),t.closePath(),t.fill(),t.restore()}class Tt extends O{constructor(){super(),this._preFormatted=!1,this._postFormatted=!1,this.ticks=new v(0,1),this.intrinsicTicks=0,this.tickMultiplier=new v(1,1),this.width=0,this.x_shift=0,this.modifiers=[],this.tupletStack=[],this.align_center=!1,this.center_x_shift=0,this.ignore_ticks=!1,this.formatterMetrics={freedom:{left:0,right:0},duration:"",iterations:0,space:{used:0,mean:0,deviation:0}}}static get CATEGORY(){return m.Tickable}reset(){return this}getTicks(){return this.ticks}shouldIgnoreTicks(){return this.ignore_ticks}setIgnoreTicks(t){return this.ignore_ticks=t,this}setWidth(t){this.width=t}getWidth(){if(!this._preFormatted)throw new f("UnformattedNote","Can't call GetWidth on an unformatted note.");return this.width+(this.modifierContext?this.modifierContext.getWidth():0)}setXShift(t){return this.x_shift=t,this}getXShift(){return this.x_shift}getX(){return this.checkTickContext("Can't getX() without a TickContext.").getX()+this.x_shift}getFormatterMetrics(){return this.formatterMetrics}getCenterXShift(){return this.isCenterAligned()?this.center_x_shift:0}setCenterXShift(t){return this.center_x_shift=t,this}isCenterAligned(){return this.align_center}setCenterAlignment(t){return this.align_center=t,this}getVoice(){return x(this.voice,"NoVoice","Tickable has no voice.")}setVoice(t){this.voice=t}getTuplet(){return this.tuplet}getTupletStack(){return this.tupletStack}resetTuplet(t){let e,i;if(t){const s=this.tupletStack.indexOf(t);return-1!==s&&(this.tupletStack.splice(s,1),e=t.getNoteCount(),i=t.getNotesOccupied(),this.applyTickMultiplier(e,i)),this}for(;this.tupletStack.length;)e=(t=this.tupletStack.pop()).getNoteCount(),i=t.getNotesOccupied(),this.applyTickMultiplier(e,i);return this}setTuplet(t){if(t){this.tupletStack.push(t);const e=t.getNoteCount(),i=t.getNotesOccupied();this.applyTickMultiplier(i,e)}return this.tuplet=t,this}addToModifierContext(t){this.modifierContext=t;for(let t=0;t<this.modifiers.length;++t)this.modifierContext.addMember(this.modifiers[t]);return this.modifierContext.addMember(this),this._preFormatted=!1,this}addModifier(t,e=0){return this.modifiers.push(t),this._preFormatted=!1,this}getModifiers(){return this.modifiers}setTickContext(t){this.tickContext=t,this._preFormatted=!1}checkTickContext(t="Tickable has no tick context."){return x(this.tickContext,"NoTickContext",t)}preFormat(){this._preFormatted||(this.width=0,this.modifierContext&&(this.modifierContext.preFormat(),this.width+=this.modifierContext.getWidth()))}set preFormatted(t){this._preFormatted=t}get preFormatted(){return this._preFormatted}postFormat(){return this._postFormatted||(this._postFormatted=!0),this}set postFormatted(t){this._postFormatted=t}get postFormatted(){return this._postFormatted}getIntrinsicTicks(){return this.intrinsicTicks}setIntrinsicTicks(t){this.intrinsicTicks=t,this.ticks=this.tickMultiplier.clone().multiply(this.intrinsicTicks)}getTickMultiplier(){return this.tickMultiplier}applyTickMultiplier(t,e){this.tickMultiplier.multiply(t,e),this.ticks=this.tickMultiplier.clone().multiply(this.intrinsicTicks)}setDuration(t){const e=t.numerator*(tt.RESOLUTION/t.denominator);this.ticks=this.tickMultiplier.clone().multiply(e),this.intrinsicTicks=this.ticks.value()}getAbsoluteX(){return this.checkTickContext("Can't getAbsoluteX() without a TickContext.").getX()}setModifierContext(t){return this.modifierContext=t,this}getModifierContext(){return this.modifierContext}checkModifierContext(){return x(this.modifierContext,"NoModifierContext","No modifier context attached to this tickable.")}}class bt extends Tt{constructor(t){if(super(),!t)throw new f("BadArguments","Note must have valid initialization data to identify duration and type.");const e=bt.parseNoteStruct(t);if(!e)throw new f("BadArguments",`Invalid note initialization object: ${JSON.stringify(t)}`);this.keys=t.keys||[],this.keyProps=[],this.duration=e.duration,this.noteType=e.type,this.customTypes=e.customTypes,t.duration_override?this.setDuration(t.duration_override):this.setIntrinsicTicks(e.ticks),this.modifiers=[],this.glyph=tt.getGlyphProps(this.duration,this.noteType),this.customGlyphs=this.customTypes.map((t=>tt.getGlyphProps(this.duration,t))),this.playNote=void 0,this.ignore_ticks=!1,this.width=0,this.leftDisplacedHeadPx=0,this.rightDisplacedHeadPx=0,this.x_shift=0,this.ys=[],t.align_center&&this.setCenterAlignment(t.align_center),this.render_options={annotation_spacing:5,glyph_font_scale:1,stroke_px:1,scale:1,font:"",y_shift:0}}static get CATEGORY(){return m.Note}static plotMetrics(t,e,i){const s=e.getMetrics(),n=e.getAbsoluteX()-s.modLeftPx-s.leftDisplacedHeadPx,a=e.getAbsoluteX()-s.leftDisplacedHeadPx,o=e.getAbsoluteX(),r=e.getAbsoluteX()+s.notePx,h=e.getAbsoluteX()+s.notePx+s.rightDisplacedHeadPx,c=e.getAbsoluteX()+s.notePx+s.rightDisplacedHeadPx+s.modRightPx,d=c+(e.getFormatterMetrics().freedom.right||0),l=c-n;t.save(),t.setFont(M.SANS_SERIF,8),t.fillText(Math.round(l)+"px",n+e.getXShift(),i);const g=i+7;function u(i,s,n,a=g){t.beginPath(),t.setStrokeStyle(n),t.setFillStyle(n),t.setLineWidth(3),t.moveTo(i+e.getXShift(),a),t.lineTo(s+e.getXShift(),a),t.stroke()}u(n,a,"red"),u(a,o,"#999"),u(o,r,"green"),u(r,h,"#999"),u(h,c,"red"),u(c,d,"#DD0"),u(n-e.getXShift(),n,"#BBB"),yt(t,o+e.getXShift(),g,"blue");const p=e.getFormatterMetrics();if(p.iterations>0){const s=p.space.deviation,n=s>=0?"+":"";t.setFillStyle("red"),t.fillText(n+Math.round(s),o+e.getXShift(),i-10)}t.restore()}static parseDuration(t){if(!t)return;const e=/(\d*\/?\d+|[a-z])(d*)([nrhms]|$)/.exec(t);if(!e)return;return{duration:e[1],dots:e[2].length,type:e[3]||"n"}}static parseNoteStruct(t){const e=bt.parseDuration(t.duration);if(!e)return;let i=t.type;if(i&&!tt.validTypes[i])return;const s=[];i||(i=e.type||"n",void 0!==t.keys&&t.keys.forEach(((t,e)=>{const n=t.split("/");s[e]=n&&3===n.length?n[2]:i})));let n=tt.durationToTicks(e.duration);if(!n)return;const a=t.dots?t.dots:e.dots;if("number"!=typeof a)return;let o=n;for(let t=0;t<a;t++){if(o<=1)return;o/=2,n+=o}return{duration:e.duration,type:i,customTypes:s,dots:a,ticks:n}}getPlayNote(){return this.playNote}setPlayNote(t){return this.playNote=t,this}isRest(){return!1}addStroke(t,e){return e.setNote(this),e.setIndex(t),this.modifiers.push(e),this.preFormatted=!1,this}getStave(){return this.stave}checkStave(){return x(this.stave,"NoStave","No stave attached to instance.")}setStave(t){return this.stave=t,this.setYs([t.getYForLine(0)]),this.setContext(this.stave.getContext()),this}getLeftDisplacedHeadPx(){return this.leftDisplacedHeadPx}getRightDisplacedHeadPx(){return this.rightDisplacedHeadPx}setLeftDisplacedHeadPx(t){return this.leftDisplacedHeadPx=t,this}setRightDisplacedHeadPx(t){return this.rightDisplacedHeadPx=t,this}shouldIgnoreTicks(){return this.ignore_ticks}getLineNumber(t){return 0}getLineForRest(){return 0}getGlyph(){return this.glyph}getGlyphWidth(){if(this.glyph){if(this.glyph.getMetrics)return this.glyph.getMetrics().width;if(this.glyph.getWidth)return this.glyph.getWidth(this.render_options.glyph_font_scale)}return 0}setYs(t){return this.ys=t,this}getYs(){if(0===this.ys.length)throw new f("NoYValues","No Y-values calculated for this note.");return this.ys}getYForTopText(t){return this.checkStave().getYForTopText(t)}getVoice(){if(!this.voice)throw new f("NoVoice","Note has no voice.");return this.voice}setVoice(t){return this.voice=t,this.preFormatted=!1,this}getTickContext(){return this.checkTickContext()}setTickContext(t){return this.tickContext=t,this.preFormatted=!1,this}getDuration(){return this.duration}isDotted(){return this.getModifiersByType("Dot").length>0}hasStem(){return!1}getNoteType(){return this.noteType}getBeam(){return this.beam}checkBeam(){return x(this.beam,"NoBeam","No beam attached to instance")}hasBeam(){return null!=this.beam}setBeam(t){return this.beam=t,this}addModifier(t,e=0){const i="Note.addModifier(modifier: Modifier, index: number=0)";if("string"==typeof e&&(e=parseInt(e),console.warn(i+" expected a number for `index`, but received a string.")),"object"!=typeof t||"number"!=typeof e)throw new f("WrongParams","Incorrect call signature. Use "+i+" instead.");return t.setNote(this),t.setIndex(e),super.addModifier(t),this}getModifiersByType(t){return this.modifiers.filter((e=>e.getCategory()===t))}getModifierStartXY(t,e,i){if(!this.preFormatted)throw new f("UnformattedNote","Can't call GetModifierStartXY on an unformatted note");return{x:this.getAbsoluteX(),y:this.ys[0]}}getRightParenthesisPx(t){return this.getKeyProps()[t].displaced?this.getRightDisplacedHeadPx():0}getLeftParenthesisPx(t){return this.getKeyProps()[t].displaced?this.getLeftDisplacedHeadPx()-this.x_shift:-this.x_shift}getFirstDotPx(){let t=this.getRightDisplacedHeadPx();return 0!==this.checkModifierContext().getMembers("Parenthesis").length&&(t+=tt.currentMusicFont().lookupMetric("parenthesis.default.width")),t}getMetrics(){if(!this.preFormatted)throw new f("UnformattedNote","Can't call getMetrics on an unformatted note.");const t=this.modifierContext?this.modifierContext.getState().left_shift:0,e=this.modifierContext?this.modifierContext.getState().right_shift:0,i=this.getWidth();return{width:i,glyphWidth:this.getGlyphWidth(),notePx:i-t-e-this.leftDisplacedHeadPx-this.rightDisplacedHeadPx,modLeftPx:t,modRightPx:e,leftDisplacedHeadPx:this.leftDisplacedHeadPx,rightDisplacedHeadPx:this.rightDisplacedHeadPx,glyphPx:0}}getAbsoluteX(){let t=this.checkTickContext("Can't getAbsoluteX() without a TickContext.").getX();return this.stave&&(t+=this.stave.getNoteStartX()+tt.currentMusicFont().lookupMetric("stave.padding")),this.isCenterAligned()&&(t+=this.getCenterXShift()),t}getStemDirection(){throw new f("NoStem","No stem attached to this note.")}getStemExtents(){throw new f("NoStem","No stem attached to this note.")}getTieRightX(){let t=this.getAbsoluteX();return t+=this.glyph.getWidth()/2,t+=-this.width/2+this.width+2,t}getTieLeftX(){let t=this.getAbsoluteX();return t+=this.glyph.getWidth()/2,t-=this.width/2+2,t}getKeys(){return this.keys}getKeyProps(){return this.keyProps}}var wt,vt,Et,Ct,Nt,kt,Dt;!function(t){t[t.CENTER=0]="CENTER",t[t.LEFT=1]="LEFT",t[t.RIGHT=2]="RIGHT",t[t.ABOVE=3]="ABOVE",t[t.BELOW=4]="BELOW",t[t.BEGIN=5]="BEGIN",t[t.END=6]="END"}(wt||(wt={}));class At extends O{constructor(){super(),this.width=0,this.x=0,this.padding=10,this.position=wt.ABOVE}static get CATEGORY(){return m.StaveModifier}static get Position(){return wt}getPosition(){return this.position}setPosition(t){return this.position=t,this}getStave(){return this.stave}checkStave(){return x(this.stave,"NoStave","No stave attached to instance.")}setStave(t){return this.stave=t,this}getWidth(){return this.width}setWidth(t){return this.width=t,this}getX(){return this.x}setX(t){return this.x=t,this}placeGlyphOnLine(t,e,i,s=0){t.setYShift(e.getYForLine(null!=i?i:0)-e.getYForGlyphs()+s)}getPadding(t){return void 0!==t&&t<2?0:this.padding}setPadding(t){return this.padding=t,this}setLayoutMetrics(t){return this.layoutMetrics=t,this}getLayoutMetrics(){return this.layoutMetrics}draw(...t){}}!function(t){t[t.SINGLE=1]="SINGLE",t[t.DOUBLE=2]="DOUBLE",t[t.END=3]="END",t[t.REPEAT_BEGIN=4]="REPEAT_BEGIN",t[t.REPEAT_END=5]="REPEAT_END",t[t.REPEAT_BOTH=6]="REPEAT_BOTH",t[t.NONE=7]="NONE"}(vt||(vt={}));class Pt extends At{constructor(t){super(),this.thickness=tt.STAVE_LINE_THICKNESS;const e=vt;this.widths={},this.widths[e.SINGLE]=5,this.widths[e.DOUBLE]=5,this.widths[e.END]=5,this.widths[e.REPEAT_BEGIN]=5,this.widths[e.REPEAT_END]=5,this.widths[e.REPEAT_BOTH]=5,this.widths[e.NONE]=5,this.paddings={},this.paddings[e.SINGLE]=0,this.paddings[e.DOUBLE]=0,this.paddings[e.END]=0,this.paddings[e.REPEAT_BEGIN]=15,this.paddings[e.REPEAT_END]=15,this.paddings[e.REPEAT_BOTH]=15,this.paddings[e.NONE]=0,this.layoutMetricsMap={},this.layoutMetricsMap[e.SINGLE]={xMin:0,xMax:1,paddingLeft:5,paddingRight:5},this.layoutMetricsMap[e.DOUBLE]={xMin:-3,xMax:1,paddingLeft:5,paddingRight:5},this.layoutMetricsMap[e.END]={xMin:-5,xMax:1,paddingLeft:5,paddingRight:5},this.layoutMetricsMap[e.REPEAT_END]={xMin:-10,xMax:1,paddingLeft:5,paddingRight:5},this.layoutMetricsMap[e.REPEAT_BEGIN]={xMin:-2,xMax:10,paddingLeft:5,paddingRight:5},this.layoutMetricsMap[e.REPEAT_BOTH]={xMin:-10,xMax:10,paddingLeft:5,paddingRight:5},this.layoutMetricsMap[e.NONE]={xMin:0,xMax:0,paddingLeft:5,paddingRight:5},this.setPosition(wt.BEGIN),this.setType(t)}static get CATEGORY(){return m.Barline}static get type(){return vt}static get typeString(){return{single:vt.SINGLE,double:vt.DOUBLE,end:vt.END,repeatBegin:vt.REPEAT_BEGIN,repeatEnd:vt.REPEAT_END,repeatBoth:vt.REPEAT_BOTH,none:vt.NONE}}getType(){return this.type}setType(t){return this.type="string"==typeof t?Pt.typeString[t]:t,this.setWidth(this.widths[this.type]),this.setPadding(this.paddings[this.type]),this.setLayoutMetrics(this.layoutMetricsMap[this.type]),this}draw(t){switch(t.checkContext(),this.setRendered(),this.type){case vt.SINGLE:this.drawVerticalBar(t,this.x,!1);break;case vt.DOUBLE:this.drawVerticalBar(t,this.x,!0);break;case vt.END:this.drawVerticalEndBar(t,this.x);break;case vt.REPEAT_BEGIN:this.drawRepeatBar(t,this.x,!0),t.getX()!==this.x&&this.drawVerticalBar(t,t.getX());break;case vt.REPEAT_END:this.drawRepeatBar(t,this.x,!1);break;case vt.REPEAT_BOTH:this.drawRepeatBar(t,this.x,!1),this.drawRepeatBar(t,this.x,!0)}}drawVerticalBar(t,e,i){const s=t.checkContext(),n=t.getTopLineTopY(),a=t.getBottomLineBottomY();i&&s.fillRect(e-3,n,1,a-n),s.fillRect(e,n,1,a-n)}drawVerticalEndBar(t,e){const i=t.checkContext(),s=t.getTopLineTopY(),n=t.getBottomLineBottomY();i.fillRect(e-5,s,1,n-s),i.fillRect(e-2,s,3,n-s)}drawRepeatBar(t,e,i){const s=t.checkContext(),n=t.getTopLineTopY(),a=t.getBottomLineBottomY();let o=3;i||(o=-5),s.fillRect(e+o,n,1,a-n),s.fillRect(e-2,n,3,a-n);i?o+=4:o-=4;const r=e+o+1;let h=(t.getNumLines()-1)*t.getSpacingBetweenLines();h=h/2-t.getSpacingBetweenLines()/2;let c=n+h+1;s.beginPath(),s.arc(r,c,2,0,2*Math.PI,!1),s.fill(),c+=t.getSpacingBetweenLines(),s.beginPath(),s.arc(r,c,2,0,2*Math.PI,!1),s.fill()}}class Ft extends bt{constructor(t=vt.SINGLE){super({duration:"b"}),this.metrics={widths:{}};const e=vt;this.metrics.widths={[e.SINGLE]:8,[e.DOUBLE]:12,[e.END]:15,[e.REPEAT_BEGIN]:14,[e.REPEAT_END]:14,[e.REPEAT_BOTH]:18,[e.NONE]:0},this.ignore_ticks=!0,this.setType(t)}static get CATEGORY(){return m.BarNote}getType(){return this.type}setType(t){return this.type="string"==typeof t?Pt.typeString[t]:t,this.setWidth(this.metrics.widths[this.type]),this}addToModifierContext(t){return this}preFormat(){return this.preFormatted=!0,this}draw(){const t=this.checkContext();!function(...t){Ft.DEBUG&&S("Vex.Flow.BarNote",t)}("Rendering bar line at: ",this.getAbsoluteX()),this.style&&this.applyStyle(t);const e=new Pt(this.type);e.setX(this.getAbsoluteX()),e.draw(this.checkStave()),this.style&&this.restoreStyle(t),this.setRendered()}}Ft.DEBUG=!1;class Mt extends H{constructor(t,e=!1,i){super(),this.text=t,this.x_shift=0,this.release=e,this.tap="",this.resetFont(),this.render_options={line_width:1.5,line_style:"#777777",bend_width:8,release_width:8},i?this.phrase=i:(this.phrase=[{type:Mt.UP,text:this.text}],this.release&&this.phrase.push({type:Mt.DOWN,text:""})),this.updateWidth()}static get CATEGORY(){return m.Bend}static get UP(){return 0}static get DOWN(){return 1}static format(t,e){if(!t||0===t.length)return!1;let i=0;for(let s=0;s<t.length;++s){const n=t[s],a=n.checkAttachedNote();if(p(a)){const t=a.leastString()-1;e.top_text_line<t&&(e.top_text_line=t)}n.setXShift(i),i=n.getWidth(),n.setTextLine(e.top_text_line)}return e.right_shift+=i,e.top_text_line+=1,!0}setXShift(t){return this.x_shift=t,this.updateWidth(),this}setTap(t){return this.tap=t,this}getText(){return this.text}getTextHeight(){return ht.create(this.textFont).maxHeight}updateWidth(){const t=ht.create(this.textFont);let e=0;for(let s=0;s<this.phrase.length;++s){const n=this.phrase[s];if(void 0!==n.width)e+=n.width;else{const s=n.type===Mt.UP?this.render_options.bend_width:this.render_options.release_width;n.width=Math.max(s,(i=n.text,t.getWidthForTextInPx(i)))+3,n.draw_width=n.width/2,e+=n.width}}var i;return this.setWidth(e+this.x_shift),this}draw(){var t;const e=this.checkContext(),i=this.checkAttachedNote();this.setRendered();const s=i.getModifierStartXY(H.Position.RIGHT,this.index);s.x+=3,s.y+=.5;const n=this.x_shift,a=i.checkStave().getSpacingBetweenLines(),o=i.getYs().reduce(((t,e)=>t<e?t:e)),r=s.y-((this.text_line+1)*a+s.y-o)+3,h=s.y-((this.text_line+1)*a+s.y-o)-1,c=(t,i,s,n)=>{const a=t+s,o=i;e.save(),e.beginPath(),e.setLineWidth(this.render_options.line_width),e.setStrokeStyle(this.render_options.line_style),e.setFillStyle(this.render_options.line_style),e.moveTo(t,i),e.quadraticCurveTo(a,o,t+s,n),e.stroke(),e.restore()},d=(t,i,s,n)=>{e.save(),e.beginPath(),e.setLineWidth(this.render_options.line_width),e.setStrokeStyle(this.render_options.line_style),e.setFillStyle(this.render_options.line_style),e.moveTo(t,n),e.quadraticCurveTo(t+s,n,t+s,i),e.stroke(),e.restore()},l=(t,i,s)=>{const n=i+4*s;e.beginPath(),e.moveTo(t,i),e.lineTo(t-4,n),e.lineTo(t+4,n),e.closePath(),e.fill()},g=(t,i)=>{e.save(),e.setFont(this.textFont);const s=t-e.measureText(i).width/2;e.fillText(i,s,h),e.restore()};let u,p=0,m=0;if(null===(t=this.tap)||void 0===t?void 0:t.length){g(i.getModifierStartXY(H.Position.CENTER,this.index).x,this.tap)}for(let t=0;t<this.phrase.length;++t){const e=this.phrase[t];e.draw_width||(e.draw_width=0),0===t&&(e.draw_width+=n),m=e.draw_width+p-(1===t?n:0),e.type===Mt.UP&&(u&&u.type===Mt.UP&&l(s.x,r,1),c(s.x,s.y,m,r)),e.type===Mt.DOWN&&(u&&u.type===Mt.UP&&d(s.x,s.y,m,r),u&&u.type===Mt.DOWN&&(l(s.x,s.y,-1),d(s.x,s.y,m,r)),u||(m=e.draw_width,d(s.x,s.y,m,r))),g(s.x+m,e.text),u=e,p=e.draw_width,u.x=s.x,s.x+=m}if(!u||null==u.x)throw new f("NoLastBendForBend","Internal error.");u.type===Mt.UP?l(u.x+m,r,1):u.type===Mt.DOWN&&l(u.x+m,s.y,-1)}}function Bt(...t){Rt.DEBUG&&S("Vex.Flow.ChordSymbol",t)}Mt.TEXT_FONT=Object.assign({},O.TEXT_FONT),function(t){t[t.LEFT=1]="LEFT",t[t.CENTER=2]="CENTER",t[t.RIGHT=3]="RIGHT",t[t.CENTER_STEM=4]="CENTER_STEM"}(Et||(Et={})),function(t){t[t.TOP=1]="TOP",t[t.BOTTOM=2]="BOTTOM"}(Ct||(Ct={})),function(t){t[t.GLYPH=1]="GLYPH",t[t.TEXT=2]="TEXT",t[t.LINE=3]="LINE"}(Nt||(Nt={})),function(t){t[t.NONE=1]="NONE",t[t.SUBSCRIPT=2]="SUBSCRIPT",t[t.SUPERSCRIPT=3]="SUPERSCRIPT"}(kt||(kt={}));class Rt extends H{constructor(){super(),this.symbolBlocks=[],this.horizontal=Et.LEFT,this.vertical=Ct.TOP,this.useKerning=!0,this.reportWidth=!0,this.resetFont()}static get CATEGORY(){return m.ChordSymbol}static get superSubRatio(){return Rt.metrics.global.superSubRatio}static set NO_TEXT_FORMAT(t){Rt.noFormat=t}static get NO_TEXT_FORMAT(){return Rt.noFormat}static getMetricForGlyph(t){if(Rt.metrics[t])return Rt.metrics[t]}static get engravingFontResolution(){return tt.currentMusicFont().getResolution()}static get spacingBetweenBlocks(){return Rt.metrics.global.spacing/Rt.engravingFontResolution}static getWidthForGlyph(t){const e=Rt.getMetricForGlyph(t.code);return e?e.advanceWidth/Rt.engravingFontResolution:.65}static getYShiftForGlyph(t){const e=Rt.getMetricForGlyph(t.code);return e?e.yOffset/Rt.engravingFontResolution:0}static getXShiftForGlyph(t){const e=Rt.getMetricForGlyph(t.code);return e?-1*e.leftSideBearing/Rt.engravingFontResolution:0}static get superscriptOffset(){return Rt.metrics.global.superscriptOffset/Rt.engravingFontResolution}static get subscriptOffset(){return Rt.metrics.global.subscriptOffset/Rt.engravingFontResolution}static get kerningOffset(){return Rt.metrics.global.kerningOffset/Rt.engravingFontResolution}static get metrics(){return tt.currentMusicFont().getMetrics().glyphs.chordSymbol}static get lowerKerningText(){return Rt.metrics.global.lowerKerningText}static get upperKerningText(){return Rt.metrics.global.upperKerningText}static isSuperscript(t){return void 0!==t.symbolModifier&&t.symbolModifier===kt.SUPERSCRIPT}static isSubscript(t){return void 0!==t.symbolModifier&&t.symbolModifier===kt.SUBSCRIPT}static format(t,e){var i;if(!t||0===t.length)return!1;let s=0,n=0;const a=[];for(const o of t){const t=M.convertSizeToPointValue(null===(i=o.textFont)||void 0===i?void 0:i.size),r=M.scaleSize(t,.05),h=2*r;let c=1,d=!1;for(let t=0;t<o.symbolBlocks.length;++t){const e=o.symbolBlocks[t],i=Rt.isSuperscript(e),a=Rt.isSubscript(e),l=i||a?Rt.superSubRatio:1,g=e.symbolType===Nt.GLYPH?h*l:r*l;(i||a)&&(c=2);const u=o.textFormatter.fontSizeInPixels,p=u*l;if(e.symbolType===Nt.GLYPH&&void 0!==e.glyph?(e.width=Rt.getWidthForGlyph(e.glyph)*p,e.yShift+=Rt.getYShiftForGlyph(e.glyph)*p,e.xShift+=Rt.getXShiftForGlyph(e.glyph)*p,e.glyph.scale=e.glyph.scale*g):e.symbolType===Nt.TEXT&&(e.width=e.width*p,e.yShift+=o.getYOffsetForText(e.text)*g),e.symbolType===Nt.GLYPH&&void 0!==e.glyph&&e.glyph.code===Rt.glyphs.over.code&&(c=2),e.width+=Rt.spacingBetweenBlocks*u*l,i&&t>0){const e=o.symbolBlocks[t-1];Rt.isSuperscript(e)||(n=s)}a&&n>0&&(d=!0,e.xShift=e.xShift+(n-s),s=n,n=0,o.setEnableKerning(!1)),i||a||(n=0),e.vAlign=d,s+=e.width}o.updateKerningAdjustments(),o.updateOverBarAdjustments(),o.getVertical()===Ct.TOP?(o.setTextLine(e.top_text_line),e.top_text_line+=c):(o.setTextLine(e.text_line+1),e.text_line+=c+1),o.getReportWidth()?a.push(s):a.push(0)}return s=a.reduce(((t,e)=>t+e),0),e.left_shift+=s/2,e.right_shift+=s/2,!0}static get TEXT_FONT(){let t="Roboto Slab, Times, serif";return"Petaluma"===tt.currentMusicFont().getName()&&(t="PetalumaScript, Arial, sans-serif"),{family:t,size:12,weight:k.NORMAL,style:D.NORMAL}}get superscriptOffset(){return Rt.superscriptOffset*this.textFormatter.fontSizeInPixels}get subscriptOffset(){return Rt.subscriptOffset*this.textFormatter.fontSizeInPixels}setReportWidth(t){return this.reportWidth=t,this}getReportWidth(){return this.reportWidth}updateOverBarAdjustments(){const t=this.symbolBlocks.findIndex((({symbolType:t,glyph:e})=>t===Nt.GLYPH&&void 0!==e&&"csymDiagonalArrangementSlash"===e.code));if(t<0)return;const e=this.symbolBlocks[t].width/4,i=.25*this.textFormatter.fontSizeInPixels;let s=0;for(;s<t;++s){const t=this.symbolBlocks[s];t.xShift=t.xShift+e,t.yShift=t.yShift-i}for(s=t+1;s<this.symbolBlocks.length;++s){const t=this.symbolBlocks[s];t.xShift=t.xShift-e,t.yShift=t.yShift+i}}updateKerningAdjustments(){let t=0;for(let e=0;e<this.symbolBlocks.length;++e){const i=this.symbolBlocks[e];t+=this.getKerningAdjustment(e),i.xShift+=t}}getKerningAdjustment(t){if(!this.useKerning)return 0;const e=this.symbolBlocks[t],i=t>0?this.symbolBlocks[t-1]:void 0;let s=0;e.symbolType===Nt.GLYPH&&void 0!==e.glyph&&e.glyph.code===Rt.glyphs.over.code&&(s+=e.glyph.metrics.x_shift),void 0!==i&&i.symbolType===Nt.GLYPH&&void 0!==i.glyph&&i.glyph.code===Rt.glyphs.over.code&&(s+=i.glyph.metrics.x_shift);let n=!1,a=!1;void 0!==i&&i.symbolType===Nt.TEXT&&(n=Rt.upperKerningText.some((t=>t===i.text[i.text.length-1])),a=Rt.lowerKerningText.some((t=>t===i.text[i.text.length-1])));const o=Rt.kerningOffset*this.textFormatter.fontSizeInPixels;return n&&e.symbolModifier===kt.SUPERSCRIPT&&(s+=o),a&&e.symbolType===Nt.TEXT&&(e.text[0]>="a"&&e.text[0]<="z"&&(s+=o/2),Rt.upperKerningText.some((t=>t===(null==i?void 0:i.text[i.text.length-1])))&&(s+=o/2)),s}getSymbolBlock(t={}){var e,i,s;const n=null!==(e=t.symbolType)&&void 0!==e?e:Nt.TEXT,a={text:null!==(i=t.text)&&void 0!==i?i:"",symbolType:n,symbolModifier:null!==(s=t.symbolModifier)&&void 0!==s?s:kt.NONE,xShift:0,yShift:0,vAlign:!1,width:0};if(n===Nt.GLYPH&&"string"==typeof t.glyph){const e=Rt.glyphs[t.glyph],i=20;a.glyph=new U(e.code,i,{category:"chordSymbol"})}else n===Nt.TEXT?a.width=this.textFormatter.getWidthForTextInEm(a.text):n===Nt.LINE&&(a.width=t.width);return a}addSymbolBlock(t){return this.symbolBlocks.push(this.getSymbolBlock(t)),this}addText(t,e={}){const i=Nt.TEXT;return this.addSymbolBlock(Object.assign(Object.assign({},e),{text:t,symbolType:i}))}addTextSuperscript(t){const e=Nt.TEXT,i=kt.SUPERSCRIPT;return this.addSymbolBlock({text:t,symbolType:e,symbolModifier:i})}addTextSubscript(t){const e=Nt.TEXT,i=kt.SUBSCRIPT;return this.addSymbolBlock({text:t,symbolType:e,symbolModifier:i})}addGlyphSuperscript(t){const e=Nt.GLYPH,i=kt.SUPERSCRIPT;return this.addSymbolBlock({glyph:t,symbolType:e,symbolModifier:i})}addGlyph(t,e={}){const i=Nt.GLYPH;return this.addSymbolBlock(Object.assign(Object.assign({},e),{glyph:t,symbolType:i}))}addGlyphOrText(t,e={}){let i="";for(let s=0;s<t.length;++s){const n=t[s];Rt.glyphs[n]?(i.length>0&&(this.addText(i,e),i=""),this.addGlyph(n,e)):i+=n}return i.length>0&&this.addText(i,e),this}addLine(t,e={}){const i=Nt.LINE;return this.addSymbolBlock(Object.assign(Object.assign({},e),{symbolType:i,width:t}))}setFont(t,e,i,s){return super.setFont(t,e,i,s),this.textFormatter=ht.create(this.textFont),this}setEnableKerning(t){return this.useKerning=t,this}setVertical(t){return this.vertical="string"==typeof t?Rt.VerticalJustifyString[t]:t,this}getVertical(){return this.vertical}setHorizontal(t){return this.horizontal="string"==typeof t?Rt.HorizontalJustifyString[t]:t,this}getHorizontal(){return this.horizontal}getWidth(){let t=0;return this.symbolBlocks.forEach((e=>{t+=e.vAlign?0:e.width})),t}getYOffsetForText(t){var e;let i=0,s=0;for(s=0;s<t.length;++s){const n=this.textFormatter.getGlyphMetrics(t[s]);if(n){const t=null!==(e=n.y_max)&&void 0!==e?e:0;i=t<i?t:i}}const n=this.textFormatter.getResolution();return s>0?i/n*-1:0}draw(){const t=this.checkContext(),e=this.checkAttachedNote();this.setRendered(),t.save();const i=Object.keys(this.getAttribute("classes")).join(" ");t.openGroup(i,this.getAttribute("id"));const s=e.getModifierStartXY(H.Position.ABOVE,this.index);let n;t.setFont(this.textFont);const a=e.hasStem(),o=e.checkStave();if(this.vertical===Ct.BOTTOM){if(n=o.getYForBottomText(this.text_line+tt.TEXT_HEIGHT_OFFSET_HACK),a){const t=e.checkStem().getExtents(),i=o.getSpacingBetweenLines(),s=1===e.getStemDirection()?t.baseY:t.topY;n=Math.max(n,s+i*(this.text_line+2))}}else if(n=Math.min(o.getYForTopText(this.text_line),e.getYs()[0]-10),a){const t=e.checkStem().getExtents(),i=o.getSpacingBetweenLines();n=Math.min(n,t.topY-5-i*this.text_line)}let r=s.x;r=this.horizontal===Et.LEFT?s.x:this.horizontal===Et.RIGHT?s.x+this.getWidth():this.horizontal===Et.CENTER?s.x-this.getWidth()/2:e.getStemX()-this.getWidth()/2,Bt("Rendering ChordSymbol: ",this.textFormatter,r,n),this.symbolBlocks.forEach((e=>{const i=Rt.isSuperscript(e),s=Rt.isSubscript(e);let a=n;if(Bt("shift was ",e.xShift,e.yShift),Bt("curY pre sub ",a),i&&(a+=this.superscriptOffset),s&&(a+=this.subscriptOffset),Bt("curY sup/sub ",a),e.symbolType===Nt.TEXT){if((i||s)&&(t.save(),this.textFont)){const{family:e,size:i,weight:s,style:n}=this.textFont,a=M.scaleSize(i,Rt.superSubRatio);t.setFont(e,a,s,n)}Bt("Rendering Text: ",e.text,r+e.xShift,a+e.yShift),t.fillText(e.text,r+e.xShift,a+e.yShift),(i||s)&&t.restore()}else e.symbolType===Nt.GLYPH&&e.glyph?(a+=e.yShift,Bt("Rendering Glyph: ",e.glyph.code,r+e.xShift,a),e.glyph.render(t,r+e.xShift,a)):e.symbolType===Nt.LINE&&(Bt("Rendering Line : ",e.width,r,a),t.beginPath(),t.setLineWidth(1),t.moveTo(r,n),t.lineTo(r+e.width,a),t.stroke());r+=e.width,e.vAlign&&(r+=e.xShift)})),t.closeGroup(),t.restore()}}Rt.DEBUG=!1,Rt.HorizontalJustify=Et,Rt.HorizontalJustifyString={left:Et.LEFT,right:Et.RIGHT,center:Et.CENTER,centerStem:Et.CENTER_STEM},Rt.VerticalJustify=Ct,Rt.VerticalJustifyString={top:Ct.TOP,above:Ct.TOP,below:Ct.BOTTOM,bottom:Ct.BOTTOM},Rt.glyphs={diminished:{code:"csymDiminished"},dim:{code:"csymDiminished"},halfDiminished:{code:"csymHalfDiminished"},"+":{code:"csymAugmented"},augmented:{code:"csymAugmented"},majorSeventh:{code:"csymMajorSeventh"},minor:{code:"csymMinor"},"-":{code:"csymMinor"},"(":{code:"csymParensLeftTall"},leftParen:{code:"csymParensLeftTall"},")":{code:"csymParensRightTall"},rightParen:{code:"csymParensRightTall"},leftBracket:{code:"csymBracketLeftTall"},rightBracket:{code:"csymBracketRightTall"},leftParenTall:{code:"csymParensLeftVeryTall"},rightParenTall:{code:"csymParensRightVeryTall"},"/":{code:"csymDiagonalArrangementSlash"},over:{code:"csymDiagonalArrangementSlash"},"#":{code:"accidentalSharp"},b:{code:"accidentalFlat"}},Rt.symbolTypes=Nt,Rt.symbolModifiers=kt,Rt.noFormat=!1;class Ot extends H{constructor(){super(),this.position=H.Position.RIGHT,this.radius=2,this.setWidth(5),this.dot_shiftY=0}static get CATEGORY(){return m.Dot}static getDots(t){return t.getModifiersByType(Ot.CATEGORY)}static buildAndAttach(t,e){for(const i of t)if(null==e?void 0:e.all)for(let t=0;t<i.keys.length;t++){const e=new Ot;e.setDotShiftY(i.glyph.dot_shiftY),i.addModifier(e,t)}else if(null!=(null==e?void 0:e.index)){const t=new Ot;t.setDotShiftY(i.glyph.dot_shiftY),i.addModifier(t,null==e?void 0:e.index)}else{const t=new Ot;t.setDotShiftY(i.glyph.dot_shiftY),i.addModifier(t,0)}}static format(t,e){const i=e.right_shift;if(!t||0===t.length)return!1;const s=[],n={};for(let e=0;e<t.length;++e){const a=t[e],o=a.getNote();let r,h;if(g(o)){const t=a.checkIndex();r=o.getKeyProps()[t],h=o.getFirstDotPx()}else{if(!p(o))throw new f("Internal","Unexpected instance.");r={line:.5},h=i}const c=o.getAttribute("id");s.push({line:r.line,note:o,note_id:c,dot:a}),n[c]=Math.max(n[c]||h,h)}s.sort(((t,e)=>e.line-t.line));let a=i,o=0,r=null,h=null,c=null,d=0;for(let t=0;t<s.length;++t){const{dot:e,note:i,note_id:l,line:g}=s[t];g===r&&i===h||(a=n[l]),i.isRest()||g===r||(.5===Math.abs(g%1)?d=0:(d=.5,null==h||h.isRest()||null==r||r-g!=.5?g+d===c&&(d=-.5):d=-.5)),i.isRest()?e.dot_shiftY+=-d:e.dot_shiftY=-d,c=g+d,e.setXShift(a),a+=e.getWidth()+1,o=a>o?a:o,r=g,h=i}return e.right_shift+=o,!0}setNote(t){return this.note=t,h(t)&&(this.radius*=.5,this.setWidth(3)),this}setDotShiftY(t){return this.dot_shiftY=t,this}draw(){const t=this.checkContext(),e=this.checkAttachedNote();this.setRendered();const i=e.checkStave().getSpacingBetweenLines(),s=e.getModifierStartXY(this.position,this.index,{forceFlagRight:!0});p(e)&&(s.y=e.getStemExtents().baseY);const n=s.x+this.x_shift+this.width-this.radius,a=s.y+this.y_shift+this.dot_shiftY*i;t.beginPath(),t.arc(n,a,this.radius,0,2*Math.PI,!1),t.fill()}}class Lt extends H{constructor(t){super(),this.finger=t,this.width=7,this.position=H.Position.LEFT,this.x_shift=0,this.y_shift=0,this.x_offset=0,this.y_offset=0,this.resetFont()}static get CATEGORY(){return m.FretHandFinger}static format(t,e){const{left_shift:i,right_shift:s}=e;if(!t||0===t.length)return!1;const n=[];let a=null,o=0,r=0;for(let h=0;h<t.length;++h){const c=t[h],d=c.getNote(),l=c.getPosition(),g=c.checkIndex(),u=d.getKeyProps()[g],p=ht.create(c.textFont).maxHeight;if(c.position===I.ABOVE&&(e.top_text_line+=p/tt.STAVE_LINE_DISTANCE+.5),c.position===I.BELOW&&(e.text_line+=p/tt.STAVE_LINE_DISTANCE+.5),d!==a){for(let t=0;t<d.keys.length;++t)0===i&&(o=Math.max(d.getLeftDisplacedHeadPx(),o)),0===s&&(r=Math.max(d.getRightDisplacedHeadPx(),r));a=d}n.push({note:d,num:c,pos:l,line:u.line,shiftL:o,shiftR:r})}n.sort(((t,e)=>e.line-t.line));let h=0,c=0,d=0,l=0,g=null,u=null;for(let t=0;t<n.length;++t){let e=0;const{note:a,pos:o,num:p,line:m,shiftL:f,shiftR:_}=n[t];m===g&&a===u||(h=i+f,c=s+_);const x=p.getWidth()+1;o===H.Position.LEFT?(p.setXShift(i+h),e=i+x,d=e>d?e:d):o===H.Position.RIGHT&&(p.setXShift(c),e=r+x,l=e>l?e:l),g=m,u=a}return e.left_shift+=d,e.right_shift+=l,!0}static easyScoreHook({fingerings:t}={},e,i){null==t||t.split(",").map((t=>{const e=t.trim().split("."),s={number:e[0]};return e[1]&&(s.position=e[1]),i.getFactory().Fingering(s)})).map(((t,i)=>e.addModifier(t,i)))}setFretHandFinger(t){return this.finger=t,this}getFretHandFinger(){return this.finger}setOffsetX(t){return this.x_offset=t,this}setOffsetY(t){return this.y_offset=t,this}draw(){const t=this.checkContext(),e=this.checkAttachedNote();this.setRendered();const i=e.getModifierStartXY(this.position,this.index);let s=i.x+this.x_shift+this.x_offset,n=i.y+this.y_shift+this.y_offset+5;switch(this.position){case H.Position.ABOVE:s-=4,n-=12;break;case H.Position.BELOW:s-=2,n+=10;break;case H.Position.LEFT:s-=this.width;break;case H.Position.RIGHT:s+=1;break;default:throw new f("InvalidPosition",`The position ${this.position} does not exist`)}t.save(),t.setFont(this.textFont),t.fillText(""+this.finger,s,n),t.restore()}}Lt.TEXT_FONT={family:M.SANS_SERIF,size:9,weight:k.BOLD,style:D.NORMAL};class It extends O{constructor(t,e){super(),this.setNotes(t),this.text=e,this.render_options={cp1:8,cp2:12,text_shift_x:0,first_x_shift:0,last_x_shift:0,y_shift:7,tie_spacing:0},this.resetFont()}static get CATEGORY(){return m.StaveTie}setDirection(t){return this.direction=t,this}setNotes(t){if(!t.first_note&&!t.last_note)throw new f("BadArguments","Tie needs to have either first_note or last_note set.");if(t.first_indices||(t.first_indices=[0]),t.last_indices||(t.last_indices=[0]),t.first_indices.length!==t.last_indices.length)throw new f("BadArguments","Tied notes must have same number of indices.");return this.notes=t,this}isPartial(){return!this.notes.first_note||!this.notes.last_note}renderTie(t){if(0===t.first_ys.length||0===t.last_ys.length)throw new f("BadArguments","No Y-values to render");const e=this.checkContext();let i=this.render_options.cp1,s=this.render_options.cp2;Math.abs(t.last_x_px-t.first_x_px)<10&&(i=2,s=8);const n=this.render_options.first_x_shift,a=this.render_options.last_x_shift,o=this.render_options.y_shift*t.direction,r=this.notes.first_indices,h=this.notes.last_indices;for(let c=0;c<r.length;++c){const d=(t.last_x_px+a+(t.first_x_px+n))/2,l=t.first_ys[r[c]]+o,g=t.last_ys[h[c]]+o;if(isNaN(l)||isNaN(g))throw new f("BadArguments","Bad indices for tie rendering.");const u=(l+g)/2+i*t.direction,p=(l+g)/2+s*t.direction;this.setAttribute("el",e.openGroup("stavetie")),e.beginPath(),e.moveTo(t.first_x_px+n,l),e.quadraticCurveTo(d,u,t.last_x_px+a,g),e.quadraticCurveTo(d,p,t.first_x_px+n,l),e.closePath(),e.fill(),e.closeGroup()}}renderText(t,e){var i,s,n;if(!this.text)return;const a=this.checkContext();let o=(t+e)/2;o-=a.measureText(this.text).width/2;const r=null!==(s=null===(i=this.notes.first_note)||void 0===i?void 0:i.checkStave())&&void 0!==s?s:null===(n=this.notes.last_note)||void 0===n?void 0:n.checkStave();r&&(a.save(),a.setFont(this.textFont),a.fillText(this.text,o+this.render_options.text_shift_x,r.getYForTopText()-1),a.restore())}draw(){this.checkContext(),this.setRendered();const t=this.notes.first_note,e=this.notes.last_note;let i=0,s=0,n=[0],a=[0],o=0;if(t)i=t.getTieRightX()+this.render_options.tie_spacing,o=t.getStemDirection(),n=t.getYs();else if(e){i=e.checkStave().getTieStartX(),n=e.getYs(),this.notes.first_indices=this.notes.last_indices}if(e)s=e.getTieLeftX()+this.render_options.tie_spacing,o=e.getStemDirection(),a=e.getYs();else if(t){s=t.checkStave().getTieEndX(),a=t.getYs(),this.notes.last_indices=this.notes.first_indices}return this.direction&&(o=this.direction),this.renderTie({first_x_px:i,last_x_px:s,first_ys:n,last_ys:a,direction:o}),this.renderText(i,s),!0}}It.TEXT_FONT=Object.assign({},O.TEXT_FONT);class Wt extends It{static get CATEGORY(){return m.TabTie}static createHammeron(t){return new Wt(t,"H")}static createPulloff(t){return new Wt(t,"P")}constructor(t,e){super(t,e),this.render_options.cp1=9,this.render_options.cp2=11,this.render_options.y_shift=3,this.direction=-1}}!function(t){t[t.STRICT=1]="STRICT",t[t.SOFT=2]="SOFT",t[t.FULL=3]="FULL"}(Dt||(Dt={}));class Gt extends O{constructor(t,e){let i;if(super(),this.resolutionMultiplier=1,this.mode=Dt.STRICT,this.preFormatted=!1,this.ticksUsed=new v(0,1),this.largestTickWidth=0,this.tickables=[],this.options=Object.assign({softmaxFactor:100},e),"string"==typeof t){const e=t.match(/(\d+)\/(\d+)/);e&&(i={num_beats:parseInt(e[1]),beat_value:parseInt(e[2])})}else i=t;this.time=Object.assign({num_beats:4,beat_value:4,resolution:tt.RESOLUTION},i),this.totalTicks=new v(this.time.num_beats*(this.time.resolution/this.time.beat_value),1),this.smallestTickCount=this.totalTicks.clone()}static get CATEGORY(){return m.Voice}static get Mode(){return Dt}getTotalTicks(){return this.totalTicks}getTicksUsed(){return this.ticksUsed}getLargestTickWidth(){return this.largestTickWidth}getSmallestTickCount(){return this.smallestTickCount}getTickables(){return this.tickables}getMode(){return this.mode}setMode(t){return this.mode=t,this}getResolutionMultiplier(){return this.resolutionMultiplier}getActualResolution(){return this.resolutionMultiplier*this.time.resolution}setStave(t){return this.stave=t,this.boundingBox=void 0,this}getStave(){return this.stave}getBoundingBox(){if(!this.boundingBox){const t=this.checkStave();let e;for(let i=0;i<this.tickables.length;++i){const s=this.tickables[i];s.setStave(t);const n=s.getBoundingBox();n&&(e=e?e.mergeWith(n):n)}this.boundingBox=e}return this.boundingBox}setStrict(t){return this.mode=t?Dt.STRICT:Dt.SOFT,this}isComplete(){return this.mode!==Dt.STRICT&&this.mode!==Dt.FULL||this.ticksUsed.equals(this.totalTicks)}setSoftmaxFactor(t){return this.options.softmaxFactor=t,this}reCalculateExpTicksUsed(){const t=this.ticksUsed.value();return this.expTicksUsed=this.tickables.map((e=>Math.pow(this.options.softmaxFactor,e.getTicks().value()/t))).reduce(((t,e)=>t+e),0),this.expTicksUsed}softmax(t){this.expTicksUsed||(this.expTicksUsed=this.reCalculateExpTicksUsed());const e=this.ticksUsed.value();return(t=>Math.pow(this.options.softmaxFactor,t/e))(t)/this.expTicksUsed}addTickable(t){if(!t.shouldIgnoreTicks()){const e=t.getTicks();if(this.ticksUsed.add(e),this.expTicksUsed=0,(this.mode===Dt.STRICT||this.mode===Dt.FULL)&&this.ticksUsed.greaterThan(this.totalTicks))throw this.ticksUsed.subtract(e),new f("BadArgument","Too many ticks.");e.lessThan(this.smallestTickCount)&&(this.smallestTickCount=e.clone()),this.resolutionMultiplier=this.ticksUsed.denominator,this.totalTicks.add(0,this.ticksUsed.denominator)}return this.tickables.push(t),t.setVoice(this),this}addTickables(t){for(let e=0;e<t.length;++e)this.addTickable(t[e]);return this}preFormat(){if(this.preFormatted)return this;const t=this.checkStave();return this.tickables.forEach((e=>{e.getStave()||e.setStave(t)})),this.preFormatted=!0,this}checkStave(){return x(this.stave,"NoStave","No stave attached to instance.")}draw(t=this.checkContext(),e){let i;e=null!=e?e:this.stave,this.setRendered();for(let s=0;s<this.tickables.length;++s){const n=this.tickables[s];e&&n.setStave(e),x(n.getStave(),"MissingStave","The voice cannot draw tickables without staves.");const a=n.getBoundingBox();a&&(i=i?i.mergeWith(a):a),n.setContext(t),n.drawWithStyle()}this.boundingBox=i}}class Ut extends H{constructor(t,e){return super(),this.preFormatted=!1,this.position=H.Position.LEFT,this.grace_notes=t,this.width=0,this.show_slur=e,this.slur=void 0,this.voice=new Gt({num_beats:4,beat_value:4,resolution:tt.RESOLUTION}).setStrict(!1),this.render_options={slur_y_shift:0},this.beams=[],this.voice.addTickables(this.grace_notes),this}static get CATEGORY(){return m.GraceNoteGroup}static format(t,e){if(!t||0===t.length)return!1;const i=[];let s=null,n=0;for(let e=0;e<t.length;++e){const a=t[e],o=a.getNote(),r=g(o),h=r?4:0;if(r&&o!==s){for(let t=0;t<o.keys.length;++t)n=Math.max(o.getLeftDisplacedHeadPx(),n);s=o}i.push({shift:n,gracenote_group:a,spacing:h})}let a,o=i[0].shift;for(let t=0;t<i.length;++t){const e=i[t].gracenote_group;e.preFormat(),a=e.getWidth()+i[t].spacing,o=Math.max(a,o)}for(let t=0;t<i.length;++t){const e=i[t].gracenote_group;a=e.getWidth()+i[t].spacing,e.setSpacingFromNextModifier(o-Math.min(a,o))}return e.left_shift+=o,!0}preFormat(){this.preFormatted||(this.formatter||(this.formatter=new Pe),this.formatter.joinVoices([this.voice]).format([this.voice],0,{}),this.setWidth(this.formatter.getMinTotalWidth()),this.preFormatted=!0)}beamNotes(t){if((t=t||this.grace_notes).length>1){const e=new Ie(t);e.render_options.beam_width=3,e.render_options.partial_beam_length=4,this.beams.push(e)}return this}setWidth(t){return this.width=t,this}getWidth(){return this.width}getGraceNotes(){return this.grace_notes}draw(){const t=this.checkContext(),e=this.checkAttachedNote();if(this.setRendered(),function(...t){Ut.DEBUG&&S("Vex.Flow.GraceNoteGroup",t)}("Drawing grace note group for:",e),this.alignSubNotesWithNote(this.getGraceNotes(),e),this.grace_notes.forEach((e=>e.setContext(t).draw())),this.beams.forEach((e=>e.setContext(t).draw())),this.show_slur){const i=g(e),s=i?It:Wt;this.slur=new s({last_note:this.grace_notes[0],first_note:e,first_indices:[0],last_indices:[0]}),this.slur.render_options.cp2=12,this.slur.render_options.y_shift=(i?7:5)+this.render_options.slur_y_shift,this.slur.setContext(t).draw()}}}Ut.DEBUG=!1;class Ht extends H{constructor(t){super(),this.preFormatted=!1,this.position=H.Position.LEFT,this.subNotes=t,this.subNotes.forEach((t=>{t.setIgnoreTicks(!1)})),this.width=0,this.formatter=new Pe,this.voice=new Gt({num_beats:4,beat_value:4,resolution:tt.RESOLUTION}).setStrict(!1),this.voice.addTickables(this.subNotes)}static get CATEGORY(){return m.NoteSubGroup}static format(t,e){if(!t||0===t.length)return!1;let i=0;for(let e=0;e<t.length;++e){const s=t[e];s.preFormat(),i+=s.getWidth()}return e.left_shift+=i,!0}preFormat(){this.preFormatted||(this.formatter.joinVoices([this.voice]).format([this.voice],0),this.setWidth(this.formatter.getMinTotalWidth()),this.preFormatted=!0)}setWidth(t){return this.width=t,this}getWidth(){return this.width}draw(){const t=this.checkContext(),e=this.checkAttachedNote();this.setRendered(),this.alignSubNotesWithNote(this.subNotes,e),this.subNotes.forEach((e=>e.setContext(t).drawWithStyle()))}}class Yt{constructor(t){this.preFormatted=!1,this.postFormatted=!1,this.tickID=t&&t.tickID?t.tickID:0,this.currentTick=new v(0,1),this.maxTicks=new v(0,1),this.maxTickable=void 0,this.minTicks=void 0,this.minTickable=void 0,this.padding=1,this.x=0,this.xBase=0,this.xOffset=0,this.tickables=[],this.tickablesByVoice={},this.notePx=0,this.glyphPx=0,this.leftDisplacedHeadPx=0,this.rightDisplacedHeadPx=0,this.modLeftPx=0,this.modRightPx=0,this.totalLeftPx=0,this.totalRightPx=0,this.tContexts=[],this.width=0,this.formatterMetrics={freedom:{left:0,right:0}}}static getNextContext(t){const e=t.tContexts,i=e.indexOf(t);if(i+1<e.length)return e[i+1]}getTickID(){return this.tickID}getX(){return this.x}setX(t){return this.x=t,this.xBase=t,this.xOffset=0,this}getXBase(){return this.xBase}setXBase(t){this.xBase=t,this.x=t+this.xOffset}getXOffset(){return this.xOffset}setXOffset(t){this.xOffset=t,this.x=this.xBase+t}getWidth(){return this.width+2*this.padding}setPadding(t){return this.padding=t,this}getMaxTicks(){return this.maxTicks}getMinTicks(){return this.minTicks}getMaxTickable(){return this.maxTickable}getMinTickable(){return this.minTickable}getTickables(){return this.tickables}getTickableForVoice(t){return this.tickablesByVoice[t]}getTickablesByVoice(){return this.tickablesByVoice}getCenterAlignedTickables(){return this.tickables.filter((t=>t.isCenterAligned()))}getMetrics(){const{width:t,glyphPx:e,notePx:i,leftDisplacedHeadPx:s,rightDisplacedHeadPx:n,modLeftPx:a,modRightPx:o,totalLeftPx:r,totalRightPx:h}=this;return{width:t,glyphPx:e,notePx:i,leftDisplacedHeadPx:s,rightDisplacedHeadPx:n,modLeftPx:a,modRightPx:o,totalLeftPx:r,totalRightPx:h}}getCurrentTick(){return this.currentTick}setCurrentTick(t){this.currentTick=t,this.preFormatted=!1}addTickable(t,e){if(!t)throw new f("BadArgument","Invalid tickable added.");if(!t.shouldIgnoreTicks()){const e=t.getTicks();e.greaterThan(this.maxTicks)&&(this.maxTicks=e.clone(),this.maxTickable=t),(null==this.minTicks||e.lessThan(this.minTicks))&&(this.minTicks=e.clone(),this.minTickable=t)}return t.setTickContext(this),this.tickables.push(t),this.tickablesByVoice[e||0]=t,this.preFormatted=!1,this}preFormat(){if(this.preFormatted)return this;for(let t=0;t<this.tickables.length;++t){const e=this.tickables[t];e.preFormat();const i=e.getMetrics();this.leftDisplacedHeadPx=Math.max(this.leftDisplacedHeadPx,i.leftDisplacedHeadPx),this.rightDisplacedHeadPx=Math.max(this.rightDisplacedHeadPx,i.rightDisplacedHeadPx),this.notePx=Math.max(this.notePx,i.notePx),this.glyphPx=Math.max(this.glyphPx,i.glyphWidth||0),this.modLeftPx=Math.max(this.modLeftPx,i.modLeftPx),this.modRightPx=Math.max(this.modRightPx,i.modRightPx),this.totalLeftPx=Math.max(this.totalLeftPx,i.modLeftPx+i.leftDisplacedHeadPx),this.totalRightPx=Math.max(this.totalRightPx,i.modRightPx+i.rightDisplacedHeadPx),this.width=this.notePx+this.totalLeftPx+this.totalRightPx}return this}postFormat(){return this.postFormatted||(this.postFormatted=!0),this}getFormatterMetrics(){return this.formatterMetrics}}class jt extends H{constructor(t){super(),this.type=t,this.delayed=!1,this.render_options={font_scale:38,accidentalLowerPadding:3,accidentalUpperPadding:3},this.ornament=tt.ornamentCodes(this.type);const e=this.getMetrics();if(this.adjustForStemDirection=!1,this.reportedWidth=e&&e.reportedWidth?e.reportedWidth:0,this.stemUpYOffset=e&&e.stemUpYOffset?e.stemUpYOffset:0,this.ornamentAlignWithNoteHead=jt.ornamentAlignWithNoteHead.indexOf(this.type)>=0,!this.ornament)throw new f("ArgumentError",`Ornament not found: '${this.type}'`);this.x_shift=e?e.xOffset:0,this.y_shift=e?e.yOffset:0,this.glyph=new U(this.ornament.code,this.render_options.font_scale,{category:`ornament.${this.ornament.code}`}),jt.ornamentNoteTransition.indexOf(this.type)>=0&&(this.delayed=!0),e||this.glyph.setOrigin(.5,1)}static get CATEGORY(){return m.Ornament}static format(t,e){if(!t||0===t.length)return!1;let i=0,s=e.right_shift,n=e.left_shift,a=0;for(let o=0;o<t.length;++o){const r=t[o],h=2;if(jt.ornamentRelease.indexOf(r.type)>=0&&(r.x_shift+=s+2),jt.ornamentAttack.indexOf(r.type)>=0&&(r.x_shift-=n+2),r.reportedWidth&&r.x_shift<0?n+=r.reportedWidth:r.reportedWidth&&r.x_shift>0?s+=r.reportedWidth:i=Math.max(r.getWidth(),i),jt.ornamentArticulation.indexOf(r.type)>=0){x(r.note,"NoAttachedNote").getLineNumber()>=3||r.getPosition()===H.Position.ABOVE?(e.top_text_line+=h,r.y_shift+=a,a-=r.glyph.bbox.getH()):(e.text_line+=h,r.y_shift+=a,a+=r.glyph.bbox.getH())}else r.getPosition()===H.Position.ABOVE?(r.setTextLine(e.top_text_line),e.top_text_line+=h):(r.setTextLine(e.text_line),e.text_line+=h)}return e.left_shift=n+i/2,e.right_shift=s+i/2,!0}static get ornamentNoteTransition(){return["flip","jazzTurn","smear"]}static get ornamentAttack(){return["scoop"]}static get ornamentAlignWithNoteHead(){return["doit","fall","fallLong","doitLong","bend","plungerClosed","plungerOpen","scoop"]}static get ornamentRelease(){return["doit","fall","fallLong","doitLong","jazzTurn","smear","flip"]}static get ornamentArticulation(){return["bend","plungerClosed","plungerOpen"]}getMetrics(){return tt.currentMusicFont().getMetrics().glyphs.jazzOrnaments[this.ornament.code]}setDelayed(t){return this.delayed=t,this}setUpperAccidental(t){const e=this.render_options.font_scale/1.3;return this.accidentalUpper=new U(tt.accidentalCodes(t).code,e),this.accidentalUpper.setOrigin(.5,1),this}setLowerAccidental(t){const e=this.render_options.font_scale/1.3;return this.accidentalLower=new U(tt.accidentalCodes(t).code,e),this.accidentalLower.setOrigin(.5,1),this}draw(){const t=this.checkContext(),e=this.checkAttachedNote();this.setRendered();const i=e.getStemDirection(),s=e.checkStave(),n=Object.keys(this.getAttribute("classes")).join(" ");t.openGroup(n,this.getAttribute("id"));const a=e.checkStem().getExtents();let o=i===nt.DOWN?a.baseY:a.topY;p(e)&&(e.hasStem()?i===nt.DOWN&&(o=s.getYForTopText(this.text_line)):o=s.getYForTopText(this.text_line));const r=i===nt.DOWN,h=s.getSpacingBetweenLines();let c=1;!r&&e.hasBeam()&&(c+=.5);const d=o-h*(this.text_line+c),l=e.getModifierStartXY(this.position,this.index);let g=l.x,u=this.ornamentAlignWithNoteHead?l.y:Math.min(s.getYForTopText(this.text_line),d);if(u+=this.y_shift,this.delayed){let t=0;const i=g-(s.getX()-10);if(void 0!==this.delayXShift)t=this.delayXShift;else{t+=this.glyph.getMetrics().width/2;const n=Yt.getNextContext(e.getTickContext());t+=n?.5*(n.getX()-i):.5*(s.getX()+s.getWidth()-i),this.delayXShift=t}g+=t}!function(...t){jt.DEBUG&&S("Vex.Flow.Ornament",t)}("Rendering ornament: ",this.ornament,g,u),this.accidentalLower&&(this.accidentalLower.render(t,g,u),u-=this.accidentalLower.getMetrics().height,u-=this.render_options.accidentalLowerPadding),this.stemUpYOffset&&e.hasStem()&&1===e.getStemDirection()&&(u+=this.stemUpYOffset),e.getLineNumber()<5&&jt.ornamentNoteTransition.indexOf(this.type)>=0&&(u=e.checkStave().getBoundingBox().getY()+40),this.glyph.render(t,g+this.x_shift,u),this.accidentalUpper&&(u-=this.glyph.getMetrics().height+this.render_options.accidentalUpperPadding,this.accidentalUpper.render(t,g,u)),t.closeGroup()}}jt.DEBUG=!1;class Xt extends H{constructor(t){super(),this.position=null!=t?t:H.Position.LEFT,this.point=tt.currentMusicFont().lookupMetric("parenthesis.default.point"),this.setWidth(tt.currentMusicFont().lookupMetric("parenthesis.default.width"))}static get CATEGORY(){return m.Parenthesis}static buildAndAttach(t){for(const e of t)for(let t=0;t<e.keys.length;t++)e.addModifier(new Xt(I.LEFT),t),e.addModifier(new Xt(I.RIGHT),t)}static format(t,e){if(!t||0===t.length)return!1;let i=0,s=0;for(let e=0;e<t.length;++e){const n=t[e],a=n.getNote(),o=n.getPosition(),r=n.checkIndex();let h=0;o===I.RIGHT&&(h=a.getRightParenthesisPx(r),s=s>h+n.width?s:h+n.width),o===I.LEFT&&(h=a.getLeftParenthesisPx(r),i=i>h+n.width?i:h+n.width),n.setXShift(h)}return e.left_shift+=i,e.right_shift+=s,!0}setNote(t){return this.note=t,this.point=tt.currentMusicFont().lookupMetric("parenthesis.default.point"),this.setWidth(tt.currentMusicFont().lookupMetric("parenthesis.default.width")),h(t)&&(this.point=tt.currentMusicFont().lookupMetric("parenthesis.gracenote.point"),this.setWidth(tt.currentMusicFont().lookupMetric("parenthesis.gracenote.width"))),this}draw(){const t=this.checkContext(),e=this.checkAttachedNote();this.setRendered();const i=e.getModifierStartXY(this.position,this.index,{forceFlagRight:!0}),s=i.x+this.x_shift,n=i.y+this.y_shift;this.position==H.Position.RIGHT?U.renderGlyph(t,s+1,n,this.point,"noteheadParenthesisRight",{category:"noteHead.standard.noteheadParenthesisRight"}):this.position==H.Position.LEFT&&U.renderGlyph(t,s-2,n,this.point,"noteheadParenthesisLeft",{category:"noteHead.standard.noteheadParenthesisLeft"})}}class Vt extends bt{constructor(t){super(t),this.custom_glyph=!1,this.stem_up_x_offset=0,this.stem_down_x_offset=0,this.index=t.index,this.x=t.x||0,this.y=t.y||0,t.note_type&&(this.noteType=t.note_type),this.displaced=t.displaced||!1,this.stem_direction=t.stem_direction||nt.UP,this.line=t.line||0,this.glyph=tt.getGlyphProps(this.duration,this.noteType),x(this.glyph,"BadArguments",`No glyph found for duration '${this.duration}' and type '${this.noteType}'`),this.glyph_code=this.glyph.code_head,this.x_shift=t.x_shift||0,t.custom_glyph_code&&(this.custom_glyph=!0,this.glyph_code=t.custom_glyph_code,this.stem_up_x_offset=t.stem_up_x_offset||0,this.stem_down_x_offset=t.stem_down_x_offset||0),this.style=t.style,this.slashed=t.slashed||!1,this.render_options=Object.assign(Object.assign({},this.render_options),{glyph_font_scale:t.glyph_font_scale||tt.NOTATION_FONT_SCALE}),this.setWidth(this.glyph.getWidth(this.render_options.glyph_font_scale))}static get CATEGORY(){return m.NoteHead}getWidth(){return this.width}isDisplaced(){return!0===this.displaced}getGlyph(){return this.glyph}setX(t){return this.x=t,this}getY(){return this.y}setY(t){return this.y=t,this}getLine(){return this.line}setLine(t){return this.line=t,this}getAbsoluteX(){const t=this.preFormatted?super.getAbsoluteX():this.x,e=nt.WIDTH/2,i=tt.currentMusicFont(),s=i.lookupMetric("notehead.shiftX",0)*this.stem_direction,n=i.lookupMetric("noteHead.displaced.shiftX",0)*this.stem_direction;return t+s+(this.displaced?(this.width-e)*this.stem_direction+n:0)}getBoundingBox(){if(!this.preFormatted)throw new f("UnformattedNote","Can't call getBoundingBox on an unformatted note.");const t=this.checkStave().getSpacingBetweenLines(),e=t/2,i=this.y-e;return new C(this.getAbsoluteX(),i,this.width,t)}setStave(t){const e=this.getLine();return this.stave=t,this.stave&&(this.setY(this.stave.getYForNote(e)),this.setContext(this.stave.getContext())),this}preFormat(){if(this.preFormatted)return this;const t=this.getWidth()+this.leftDisplacedHeadPx+this.rightDisplacedHeadPx;return this.setWidth(t),this.preFormatted=!0,this}draw(){const t=this.checkContext();this.setRendered();let e=this.getAbsoluteX();this.custom_glyph&&(e+=this.stem_direction===nt.UP?this.stem_up_x_offset:this.stem_down_x_offset);const i=this.y;!function(...t){Vt.DEBUG&&S("Vex.Flow.NoteHead",t)}("Drawing note head '",this.noteType,this.duration,"' at",e,i);const s=this.stem_direction,n=this.render_options.glyph_font_scale;this.style&&this.applyStyle(t);const a=`${this.glyph_code}Stem${s===nt.UP?"Up":"Down"}`;if("s"===this.noteType){const n=this.checkStave().getSpacingBetweenLines();!function(t,e,i,s,n,a){const o=tt.SLASH_NOTEHEAD_WIDTH;t.save(),t.setLineWidth(tt.STEM_WIDTH);let r=!1;if(tt.durationToNumber(e)>2&&(r=!0),r||(i-=tt.STEM_WIDTH/2*n),t.beginPath(),t.moveTo(i,s+a),t.lineTo(i,s+1),t.lineTo(i+o,s-a),t.lineTo(i+o,s),t.lineTo(i,s+a),t.closePath(),r?t.fill():t.stroke(),tt.durationToFraction(e).equals(.5)){const e=[-3,-1,o+1,o+3];for(let n=0;n<e.length;n++)t.beginPath(),t.moveTo(i+e[n],s-10),t.lineTo(i+e[n],s+11),t.stroke()}t.restore()}(t,this.duration,e,i,s,n)}else U.renderGlyph(t,e,i,n,this.glyph_code,{category:this.custom_glyph?`noteHead.custom.${a}`:`noteHead.standard.${a}`});this.style&&this.restoreStyle(t)}}Vt.DEBUG=!1;class zt extends bt{constructor(t){super(t)}static get CATEGORY(){return m.StemmableNote}getStem(){return this.stem}checkStem(){if(!this.stem)throw new f("NoStem","No stem attached to instance");return this.stem}setStem(t){return this.stem=t,this}buildStem(){const t=new nt;return this.setStem(t),this}buildFlag(t="flag"){const{glyph:e}=this;if(this.hasFlag()){const i=this.getStemDirection()===nt.DOWN?e.code_flag_downstem:e.code_flag_upstem;this.flag=new U(i,this.render_options.glyph_font_scale,{category:t})}}getBaseCustomNoteHeadGlyph(){return this.getStemDirection()===nt.DOWN?this.customGlyphs[this.customGlyphs.length-1]:this.customGlyphs[0]}getStemLength(){return nt.HEIGHT+this.getStemExtension()}getBeamCount(){const t=this.getGlyph();return t?t.beam_count:0}getStemMinimumLength(){let t=tt.durationToFraction(this.duration).value()<=1?0:20;switch(this.duration){case"8":null==this.beam&&(t=35);break;case"16":t=null==this.beam?35:25;break;case"32":t=null==this.beam?45:35;break;case"64":t=null==this.beam?50:40;break;case"128":t=null==this.beam?55:45}return t}getStemDirection(){if(!this.stem_direction)throw new f("NoStem","No stem attached to this note.");return this.stem_direction}setStemDirection(t){if(t||(t=nt.UP),t!==nt.UP&&t!==nt.DOWN)throw new f("BadArgument",`Invalid stem direction: ${t}`);if(this.stem_direction=t,this.reset(),this.hasFlag()&&this.buildFlag(),this.beam=void 0,this.stem){this.stem.setDirection(t),this.stem.setExtension(this.getStemExtension());const e=this.getBaseCustomNoteHeadGlyph()||this.getGlyph(),i=tt.currentMusicFont().lookupMetric(`stem.noteHead.${e.code_head}`,{offsetYBaseStemUp:0,offsetYTopStemUp:0,offsetYBaseStemDown:0,offsetYTopStemDown:0});this.stem.setOptions({stem_up_y_offset:i.offsetYTopStemUp,stem_down_y_offset:i.offsetYTopStemDown,stem_up_y_base_offset:i.offsetYBaseStemUp,stem_down_y_base_offset:i.offsetYBaseStemDown})}return this.preFormatted&&this.preFormat(),this}getStemX(){const t=this.getAbsoluteX()+this.x_shift,e=this.getAbsoluteX()+this.x_shift+this.getGlyphWidth();return this.stem_direction===nt.DOWN?t:e}getCenterGlyphX(){return this.getAbsoluteX()+this.x_shift+this.getGlyphWidth()/2}getStemExtension(){const t=this.getGlyph();return null!=this.stem_extension_override?this.stem_extension_override:this.beam?t.stem_beam_extension:t?this.getStemDirection()===nt.UP?t.stem_up_extension:t.stem_down_extension:0}setStemLength(t){return this.stem_extension_override=t-nt.HEIGHT,this}getStemExtents(){if(!this.stem)throw new f("NoStem","No stem attached to this note.");return this.stem.getExtents()}getYForTopText(t){const e=this.checkStave();if(this.hasStem()){const i=this.getStemExtents();if(!i)throw new f("InvalidState","Stem does not have extents.");return Math.min(e.getYForTopText(t),i.topY-this.render_options.annotation_spacing*(t+1))}return e.getYForTopText(t)}getYForBottomText(t){const e=this.checkStave();if(this.hasStem()){const i=this.getStemExtents();if(!i)throw new f("InvalidState","Stem does not have extents.");return Math.max(e.getYForTopText(t),i.baseY+this.render_options.annotation_spacing*t)}return e.getYForBottomText(t)}hasFlag(){return tt.getGlyphProps(this.duration).flag&&!this.beam}postFormat(){var t;return null===(t=this.beam)||void 0===t||t.postFormat(),this.postFormatted=!0,this}drawStem(t){var e;this.checkContext(),this.setRendered(),this.setStem(new nt(t)),null===(e=this.stem)||void 0===e||e.setContext(this.getContext()).draw()}}function Kt(t,e,i){const s=i;t.line+=s,t.maxLine+=s,t.minLine+=s,t.note.setKeyLine(0,t.note.getKeyLine(0)+s)}class $t extends zt{constructor(t){var e,i,s;super(t),this.minLine=0,this.maxLine=0,this.ledgerLineStyle={},this.clef=null!==(e=t.clef)&&void 0!==e?e:"treble",this.octave_shift=null!==(i=t.octave_shift)&&void 0!==i?i:0,this.glyph=tt.getGlyphProps(this.duration,this.noteType),x(this.glyph,"BadArguments",`No glyph found for duration '${this.duration}' and type '${this.noteType}'`),this.displaced=!1,this.dot_shiftY=0,this.use_default_head_x=!1,this._noteHeads=[],this.modifiers=[],this.render_options=Object.assign(Object.assign({},this.render_options),{glyph_font_scale:t.glyph_font_scale||tt.NOTATION_FONT_SCALE,stroke_px:t.stroke_px||$t.LEDGER_LINE_OFFSET}),this.calculateKeyProps(),this.buildStem(),t.auto_stem?this.autoStem():this.setStemDirection(null!==(s=t.stem_direction)&&void 0!==s?s:nt.UP),this.reset(),this.buildFlag()}static get CATEGORY(){return m.StaveNote}static get STEM_UP(){return nt.UP}static get STEM_DOWN(){return nt.DOWN}static get LEDGER_LINE_OFFSET(){return 3}static get minNoteheadPadding(){return tt.currentMusicFont().lookupMetric("glyphs.noteHead.minPadding")}static format(t,e){if(!t||t.length<2)return!1;const i=[];for(let e=0;e<t.length;e++){const s=t[e].getKeyProps(),n=s[0].line;let a=s[s.length-1].line;const o=t[e].getStemDirection(),r=t[e].getStemLength()/10,h=t[e].getStemMinimumLength()/10;let c;t[e].isRest()?(c=n+t[e].glyph.line_above,a=n-t[e].glyph.line_below):(c=1===o?s[s.length-1].line+r:s[s.length-1].line,a=1===o?s[0].line:s[0].line-r),i.push({line:s[0].line,maxLine:c,minLine:a,isrest:t[e].isRest(),stemDirection:o,stemMax:r,stemMin:h,voice_shift:t[e].getVoiceShiftWidth(),is_displaced:t[e].isDisplaced(),note:t[e]})}const s=i.length;let n=i[0];const a=s>2?i[1]:void 0;let o=s>2?i[2]:i[1];2===s&&-1===n.stemDirection&&1===o.stemDirection&&(n=i[1],o=i[0]);const r=Math.max(n.voice_shift,o.voice_shift);let h=0;if(2===s){const t=n.note.hasStem()&&o.note.hasStem()&&n.stemDirection===o.stemDirection?0:.5;if(o.isrest&&n.isrest&&n.note.duration===o.note.duration)o.note.render_options.draw=!1;else if(n.minLine<=o.maxLine+t)if(n.isrest)Kt(n,0,1);else if(o.isrest)Kt(o,0,-1);else{const t=Math.abs(n.line-o.line);if(n.note.hasStem()&&o.note.hasStem()){let e=0,i=0;2===tt.durationToNumber(n.note.duration)?e++:tt.durationToNumber(n.note.duration)>2&&i++,2===tt.durationToNumber(o.note.duration)?e++:tt.durationToNumber(o.note.duration)>2&&i++,2!==e&&2!==i||n.note.getModifiersByType(m.Dot).length!==o.note.getModifiersByType(m.Dot).length||t<1&&t>0?(h=r+2,n.stemDirection===o.stemDirection?n.note.setXShift(h):o.note.setXShift(h)):n.note.voice!==o.note.voice&&n.stemDirection===o.stemDirection&&(n.line!=o.line?(h=r+2,n.note.setXShift(h)):1===o.stemDirection&&(o.stemDirection=-1,o.note.setStemDirection(-1)))}else h=r+2,n.stemDirection===o.stemDirection?n.note.setXShift(h):o.note.setXShift(h)}return e.right_shift+=h,!0}if(!a)throw new f("InvalidState","noteM not defined.");if(a.isrest&&!n.isrest&&!o.isrest&&(n.minLine<=a.maxLine||a.minLine<=o.maxLine)){return a.maxLine-a.minLine<n.minLine-o.maxLine?function(t,e,i){const s=t.line-T(e.minLine,i.maxLine);t.note.setKeyLine(0,t.note.getKeyLine(0)-s),t.line-=s,t.maxLine-=s,t.minLine-=s}(a,n,o):(h=r+2,a.note.setXShift(h),!1===o.note.hasBeam()&&(o.stemDirection=-1,o.note.setStemDirection(-1)),n.minLine<=o.maxLine&&!1===n.note.hasBeam()&&(n.stemDirection=1,n.note.setStemDirection(1))),e.right_shift+=h,!0}return n.isrest&&a.isrest&&o.isrest?(n.note.render_options.draw=!1,o.note.render_options.draw=!1,e.right_shift+=h,!0):(a.isrest&&n.isrest&&a.minLine<=o.maxLine&&(a.note.render_options.draw=!1),a.isrest&&o.isrest&&n.minLine<=a.maxLine&&(a.note.render_options.draw=!1),n.isrest&&n.minLine<=a.maxLine&&Kt(n,0,1),o.isrest&&a.minLine<=o.maxLine&&Kt(o,0,-1),(n.minLine<=a.maxLine+.5||a.minLine<=o.maxLine)&&(h=r+2,a.note.setXShift(h),!1===o.note.hasBeam()&&(o.stemDirection=-1,o.note.setStemDirection(-1)),n.minLine<=o.maxLine&&!1===n.note.hasBeam()&&(n.stemDirection=1,n.note.setStemDirection(1))),e.right_shift+=h,!0)}static postFormat(t){return!!t&&(t.forEach((t=>t.postFormat())),!0)}reset(){super.reset();const t=this._noteHeads.map((t=>t.getStyle()));this.buildNoteHeads(),this._noteHeads.forEach(((e,i)=>{const s=t[i];s&&e.setStyle(s)}));const e=this.stave;return e&&this._noteHeads.forEach((t=>t.setStave(e))),this.calcNoteDisplacements(),this}setBeam(t){return this.beam=t,this.calcNoteDisplacements(),this.stem&&this.stem.setExtension(this.getStemExtension()),this}buildStem(){return this.setStem(new nt({hide:!!this.isRest()})),this}buildNoteHeads(){this._noteHeads=[];const t=this.getStemDirection(),e=this.getKeys();let i,s,n,a,o,r=!1;t===nt.UP?(n=0,a=e.length,o=1):(n=e.length-1,a=-1,o=-1);for(let e=n;e!==a;e+=o){const n=this.keyProps[e],a=n.line;void 0===i?i=a:(s=Math.abs(i-a),0===s||.5===s?r=!r:(r=!1,this.use_default_head_x=!0)),i=a;const o=new Vt({duration:this.duration,note_type:this.noteType,displaced:r,stem_direction:t,custom_glyph_code:n.code,glyph_font_scale:this.render_options.glyph_font_scale,x_shift:n.shift_right,stem_up_x_offset:n.stem_up_x_offset,stem_down_x_offset:n.stem_down_x_offset,line:n.line});this._noteHeads[e]=o}}autoStem(){this.setStemDirection(this.calculateOptimalStemDirection())}calculateOptimalStemDirection(){this.minLine=this.keyProps[0].line,this.maxLine=this.keyProps[this.keyProps.length-1].line;return(this.minLine+this.maxLine)/2<3?nt.UP:nt.DOWN}calculateKeyProps(){let t;for(let e=0;e<this.keys.length;++e){const i=this.keys[e];this.glyph.rest&&(this.glyph.position=i);const s={octave_shift:this.octave_shift||0},n=tt.keyProperties(i,this.clef,s);if(!n)throw new f("BadArguments",`Invalid key for note properties: ${i}`);"R"===n.key&&("1"===this.duration||"w"===this.duration?n.line=4:n.line=3);const a=n.line;null==t?t=a:.5===Math.abs(t-a)&&(this.displaced=!0,n.displaced=!0,this.keyProps.length>0&&(this.keyProps[e-1].displaced=!0)),t=a,this.keyProps.push(n)}t=void 0,this.keyProps.forEach((e=>{t&&e.line<t&&y("Unsorted keys in note will be sorted. See https://github.com/0xfe/vexflow/issues/104 for details."),t=e.line})),this.keyProps.sort(((t,e)=>t.line-e.line))}getBoundingBox(){var t,e;if(!this.preFormatted)throw new f("UnformattedNote","Can't call getBoundingBox on an unformatted note.");const{width:i,modLeftPx:s,leftDisplacedHeadPx:n}=this.getMetrics(),a=this.getAbsoluteX()-s-n;let o=0,r=0;const h=(null!==(e=null===(t=this.getStave())||void 0===t?void 0:t.getSpacingBetweenLines())&&void 0!==e?e:0)/2,c=2*h;if(this.isRest()){const t=this.ys[0],e=tt.durationToFraction(this.duration);e.equals(1)||e.equals(2)?(o=t-h,r=t+h):(o=t-this.glyph.line_above*c,r=t+this.glyph.line_below*c)}else if(this.glyph.stem){const t=this.getStemExtents();t.baseY+=h*this.getStemDirection(),o=Math.min(t.topY,t.baseY),r=Math.max(t.topY,t.baseY)}else{o=0,r=0;for(let t=0;t<this.ys.length;++t){const e=this.ys[t];0===t?(o=e,r=e):(o=Math.min(e,o),r=Math.max(e,r))}o-=h,r+=h}return new C(a,o,i,r-o)}getLineNumber(t){if(!this.keyProps.length)throw new f("NoKeyProps","Can't get bottom note line, because note is not initialized properly.");let e=this.keyProps[0].line;for(let i=0;i<this.keyProps.length;i++){const s=this.keyProps[i].line;t?s>e&&(e=s):s<e&&(e=s)}return e}isRest(){return this.glyph.rest}isChord(){return!this.isRest()&&this.keys.length>1}hasStem(){return this.glyph.stem}hasFlag(){return super.hasFlag()&&!this.isRest()}getStemX(){return"r"===this.noteType?this.getCenterGlyphX():super.getStemX()+(this.stem_direction?nt.WIDTH/(2*-this.stem_direction):0)}getYForTopText(t){const e=this.getStemExtents();return Math.min(this.checkStave().getYForTopText(t),e.topY-this.render_options.annotation_spacing*(t+1))}getYForBottomText(t){const e=this.getStemExtents();return Math.max(this.checkStave().getYForTopText(t),e.baseY+this.render_options.annotation_spacing*t)}setStave(t){super.setStave(t);const e=this._noteHeads.map((e=>(e.setStave(t),e.getY())));if(this.setYs(e),this.stem){const{y_top:t,y_bottom:e}=this.getNoteHeadBounds();this.stem.setYBounds(t,e)}return this}isDisplaced(){return this.displaced}setNoteDisplaced(t){return this.displaced=t,this}getTieRightX(){let t=this.getAbsoluteX();return t+=this.getGlyphWidth()+this.x_shift+this.rightDisplacedHeadPx,this.modifierContext&&(t+=this.modifierContext.getRightShift()),t}getTieLeftX(){let t=this.getAbsoluteX();return t+=this.x_shift-this.leftDisplacedHeadPx,t}getLineForRest(){let t=this.keyProps[0].line;if(this.keyProps.length>1){const e=this.keyProps[this.keyProps.length-1].line;t=T(Math.max(t,e),Math.min(t,e))}return t}getModifierStartXY(t,e,i={}){var s,n;if(!this.preFormatted)throw new f("UnformattedNote","Can't call GetModifierStartXY on an unformatted note");if(0===this.ys.length)throw new f("NoYValues","No Y-Values calculated for this note.");const{ABOVE:a,BELOW:o,LEFT:r,RIGHT:h}=H.Position;let c=0;return t===r?c=-2:t===h?(c=this.getGlyphWidth()+this.x_shift+2,this.stem_direction===nt.UP&&this.hasFlag()&&(i.forceFlagRight||((t,e)=>e===(t.getStemDirection()===nt.UP?t.keyProps.length-1:0))(this,e))&&(c+=null!==(n=null===(s=null==this?void 0:this.flag)||void 0===s?void 0:s.getMetrics().width)&&void 0!==n?n:0)):t!==o&&t!==a||(c=this.getGlyphWidth()/2),{x:this.getAbsoluteX()+c,y:this.ys[e]}}setStyle(t){return super.setStyle(t),this._noteHeads.forEach((e=>e.setStyle(t))),this.stem&&this.stem.setStyle(t),this}setStemStyle(t){const e=this.getStem();return e&&e.setStyle(t),this}getStemStyle(){var t;return null===(t=this.stem)||void 0===t?void 0:t.getStyle()}setLedgerLineStyle(t){this.ledgerLineStyle=t}getLedgerLineStyle(){return this.ledgerLineStyle}setFlagStyle(t){this.flagStyle=t}getFlagStyle(){return this.flagStyle}setKeyStyle(t,e){return this._noteHeads[t].setStyle(e),this}setKeyLine(t,e){return this.keyProps[t].line=e,this.reset(),this}getKeyLine(t){return this.keyProps[t].line}getVoiceShiftWidth(){return this.getGlyphWidth()*(this.displaced?2:1)}calcNoteDisplacements(){this.setLeftDisplacedHeadPx(this.displaced&&this.stem_direction===nt.DOWN?this.getGlyphWidth():0),this.setRightDisplacedHeadPx(!this.hasFlag()&&this.displaced&&this.stem_direction===nt.UP?this.getGlyphWidth():0)}preFormat(){if(this.preFormatted)return;let t=0;this.modifierContext&&(this.modifierContext.preFormat(),0===this.modifierContext.getWidth()&&(t=$t.minNoteheadPadding));let e=this.getGlyphWidth()+this.leftDisplacedHeadPx+this.rightDisplacedHeadPx+t;this.shouldDrawFlag()&&this.stem_direction===nt.UP&&(e+=this.getGlyphWidth()),this.setWidth(e),this.preFormatted=!0}getNoteHeadBounds(){let t,e,i,s,n=1/0,a=-1/0,o=this.checkStave().getNumLines(),r=1,h=o,c=r;return this._noteHeads.forEach((d=>{const l=d.getLine(),g=d.getY();n=Math.min(g,n),a=Math.max(g,a),void 0===e&&d.isDisplaced()&&(e=d.getAbsoluteX()),void 0!==t||d.isDisplaced()||(t=d.getAbsoluteX()),o=Math.max(l,o),r=Math.min(l,r),d.isDisplaced()?(i=void 0===i?l:Math.max(l,i),s=void 0===s?l:Math.min(l,s)):(h=Math.max(l,h),c=Math.min(l,c))}),this),{y_top:n,y_bottom:a,displaced_x:e,non_displaced_x:t,highest_line:o,lowest_line:r,highest_displaced_line:i,lowest_displaced_line:s,highest_non_displaced_line:h,lowest_non_displaced_line:c}}getNoteHeadBeginX(){return this.getAbsoluteX()+this.x_shift}getNoteHeadEndX(){return this.getNoteHeadBeginX()+this.getGlyphWidth()}get noteHeads(){return this._noteHeads.slice()}get note_heads(){return console.warn("StaveNote.note_heads is deprecated. Use StaveNote.noteHeads instead.","This accessor will be removed in VexFlow 5.0."),this.noteHeads}drawLedgerLines(){const t=this.checkStave(),{glyph:e,render_options:{stroke_px:i}}=this,s=this.checkContext(),n=e.getWidth()+2*i,a=2*(e.getWidth()+i)-nt.WIDTH/2;if(this.isRest())return;if(!s)throw new f("NoCanvasContext","Can't draw without a canvas context.");const{highest_line:o,lowest_line:r,highest_displaced_line:h,highest_non_displaced_line:c,lowest_displaced_line:d,lowest_non_displaced_line:l,displaced_x:g,non_displaced_x:u}=this.getNoteHeadBounds();if(o<6&&r>0)return;const p=Math.min(null!=g?g:0,null!=u?u:0),m=(t,e,o)=>{let r;r=o&&e?p-i:e?(null!=u?u:0)-i:(null!=g?g:0)-i;const h=e&&o?a:n;s.beginPath(),s.moveTo(r,t),s.lineTo(r+h,t),s.stroke()},_=Object.assign(Object.assign({},t.getDefaultLedgerLineStyle()),this.getLedgerLineStyle());this.applyStyle(s,_);for(let e=6;e<=o;++e){const i=void 0!==u&&e<=c,s=void 0!==h&&e<=h;m(t.getYForNote(e),i,s)}for(let e=0;e>=r;--e){const i=void 0!==u&&e>=l,s=void 0!==d&&e>=d;m(t.getYForNote(e),i,s)}this.restoreStyle(s,_)}drawModifiers(){const t=this.checkContext();t.openGroup("modifiers");for(let e=0;e<this.modifiers.length;e++){const i=this.modifiers[e],s=i.checkIndex(),n=this._noteHeads[s],a=n.getStyle();n.applyStyle(t,a),i.setContext(t),i.drawWithStyle(),n.restoreStyle(t,a)}t.closeGroup()}shouldDrawFlag(){const t=void 0!==this.stem,e=this.glyph.flag,i=void 0===this.beam;return t&&e&&i}drawFlag(){var t,e,i,s,n;const a=this.checkContext();if(!a)throw new f("NoCanvasContext","Can't draw without a canvas context.");if(this.shouldDrawFlag()){const{y_top:o,y_bottom:r}=this.getNoteHeadBounds(),h=this.stem.getHeight(),c=this.getStemX(),d=this.getStemDirection()===nt.DOWN?o-h+2-(this.glyph?this.glyph.stem_down_extension:0)*this.getStaveNoteScale()-(null!==(e=null===(t=this.flag)||void 0===t?void 0:t.getMetrics().y_shift)&&void 0!==e?e:0)*(1-this.getStaveNoteScale()):r-h-2+(this.glyph?this.glyph.stem_up_extension:0)*this.getStaveNoteScale()-(null!==(s=null===(i=this.flag)||void 0===i?void 0:i.getMetrics().y_shift)&&void 0!==s?s:0)*(1-this.getStaveNoteScale());a.openGroup("flag",void 0,{pointerBBox:!0}),this.applyStyle(a,this.getFlagStyle()),null===(n=this.flag)||void 0===n||n.render(a,c,d),this.restoreStyle(a,this.getFlagStyle()),a.closeGroup()}}drawNoteHeads(){const t=this.checkContext();this._noteHeads.forEach((e=>{t.openGroup("notehead",void 0,{pointerBBox:!0}),e.setContext(t).draw(),t.closeGroup()}))}drawStem(t){const e=this.checkContext();t&&this.setStem(new nt(t)),this.shouldDrawFlag()&&this.stem&&this.stem.adjustHeightForFlag(),this.stem&&(e.openGroup("stem",void 0,{pointerBBox:!0}),this.stem.setContext(e).draw(),e.closeGroup())}getStaveNoteScale(){return 1}getStemExtension(){const t=super.getStemExtension();if(!this.glyph.stem)return t;const e=this.getStemDirection();if(e!==this.calculateOptimalStemDirection())return t;let i;i=e===nt.UP?3-this.maxLine:this.minLine-3;const s=i-3.5;if(s<=0)return t;const n=this.getStave();let a=10;return null!=n&&(a=n.getSpacingBetweenLines()),t+s*a}draw(){if(!1===this.render_options.draw)return;if(0===this.ys.length)throw new f("NoYValues","Can't draw note without Y values.");const t=this.checkContext(),e=this.getNoteHeadBeginX(),i=this.hasStem()&&!this.beam;if(this._noteHeads.forEach((t=>t.setX(e))),this.stem){const t=this.getStemX();this.stem.setNoteHeadXBounds(t,t)}!function(...t){$t.DEBUG&&S("Vex.Flow.StaveNote",t)}("Rendering ",this.isChord()?"chord :":"note :",this.keys),this.applyStyle(),this.setAttribute("el",t.openGroup("stavenote",this.getAttribute("id"))),this.drawLedgerLines(),t.openGroup("note",void 0,{pointerBBox:!0}),i&&this.drawStem(),this.drawNoteHeads(),this.drawFlag(),t.closeGroup(),this.drawModifiers(),t.closeGroup(),this.restoreStyle(),this.setRendered()}}function Jt(t){if(!t)return!1;const e=_();return"function"==typeof e.HTMLCanvasElement&&t instanceof e.HTMLCanvasElement||"function"==typeof t.getContext&&"function"==typeof t.toDataURL}function qt(t){if(!t)return!1;const e=_();return"function"==typeof e.HTMLDivElement&&t instanceof e.HTMLDivElement||"function"==typeof t.appendChild&&"object"==typeof t.style}$t.DEBUG=!1;class Qt extends St{constructor(t){super(),this.textHeight=0,this.context2D=t,t.canvas?this.canvas=t.canvas:this.canvas={width:Qt.WIDTH,height:Qt.HEIGHT}}static get WIDTH(){return 600}static get HEIGHT(){return 400}static get CANVAS_BROWSER_SIZE_LIMIT(){return 32767}static sanitizeCanvasDims(t,e){const i=this.CANVAS_BROWSER_SIZE_LIMIT;return Math.max(t,e)>i&&(y("Canvas dimensions exceed browser limit. Cropping to "+i),t>i&&(t=i),e>i&&(e=i)),[t,e]}clear(){this.context2D.clearRect(0,0,this.canvas.width,this.canvas.height)}openGroup(t,e,i){}closeGroup(){}add(t){}setFillStyle(t){return this.context2D.fillStyle=t,this}setBackgroundFillStyle(t){return this}setStrokeStyle(t){return this.context2D.strokeStyle=t,this}setShadowColor(t){return this.context2D.shadowColor=t,this}setShadowBlur(t){const e=this.context2D.getTransform(),i=Math.sqrt(e.a*e.a+e.b*e.b+e.c*e.c+e.d*e.d);return this.context2D.shadowBlur=i*t,this}setLineWidth(t){return this.context2D.lineWidth=t,this}setLineCap(t){return this.context2D.lineCap=t,this}setLineDash(t){return this.context2D.setLineDash(t),this}scale(t,e){return this.context2D.scale(t,e),this}resize(t,e){const i=this.context2D.canvas,s=_().devicePixelRatio||1;return[t,e]=Qt.sanitizeCanvasDims(t*s,e*s),t=t/s|0,e=e/s|0,i.width=t*s,i.height=e*s,Jt(i)&&(i.style.width=t+"px",i.style.height=e+"px"),this.scale(s,s)}rect(t,e,i,s){return this.context2D.rect(t,e,i,s),this}fillRect(t,e,i,s){return this.context2D.fillRect(t,e,i,s),this}clearRect(t,e,i,s){return this.context2D.clearRect(t,e,i,s),this}beginPath(){return this.context2D.beginPath(),this}moveTo(t,e){return this.context2D.moveTo(t,e),this}lineTo(t,e){return this.context2D.lineTo(t,e),this}bezierCurveTo(t,e,i,s,n,a){return this.context2D.bezierCurveTo(t,e,i,s,n,a),this}quadraticCurveTo(t,e,i,s){return this.context2D.quadraticCurveTo(t,e,i,s),this}arc(t,e,i,s,n,a){return this.context2D.arc(t,e,i,s,n,a),this}fill(){return this.context2D.fill(),this}stroke(){return this.context2D.stroke(),this}closePath(){return this.context2D.closePath(),this}measureText(t){const e=this.context2D.measureText(t);let i=0,s=0;return e.fontBoundingBoxAscent?(i=-e.fontBoundingBoxAscent,s=e.fontBoundingBoxDescent+e.fontBoundingBoxAscent):(i=-e.actualBoundingBoxAscent,s=e.actualBoundingBoxDescent+e.actualBoundingBoxAscent),{x:0,y:i,width:e.width,height:s}}fillText(t,e,i){return this.context2D.fillText(t,e,i),this}save(){return this.context2D.save(),this}restore(){return this.context2D.restore(),this}set fillStyle(t){this.context2D.fillStyle=t}get fillStyle(){return this.context2D.fillStyle}set strokeStyle(t){this.context2D.strokeStyle=t}get strokeStyle(){return this.context2D.strokeStyle}setFont(t,e,i,s){const n=M.validate(t,e,i,s);return this.context2D.font=M.toCSSString(n),this.textHeight=M.convertSizeToPixelValue(n.size),this}getFont(){return this.context2D.font}}const Zt={path:{x:!0,y:!0,width:!0,height:!0,"font-family":!0,"font-weight":!0,"font-style":!0,"font-size":!0},rect:{"font-family":!0,"font-weight":!0,"font-style":!0,"font-size":!0},text:{width:!0,height:!0}},te="http://www.w3.org/2000/svg",ee=2*Math.PI;class ie extends St{constructor(t){super(),this.width=0,this.height=0,this.backgroundFillStyle="white",this.fontCSSString="",this.element=t;const e=this.create("svg");this.element.appendChild(e),this.svg=e,this.parent=this.svg,this.groups=[this.svg],this.path="",this.pen={x:NaN,y:NaN},this.lineWidth=1;const i={"font-family":M.SANS_SERIF,"font-size":M.SIZE+"pt","font-weight":k.NORMAL,"font-style":D.NORMAL};this.state=Object.assign({scale:{x:1,y:1}},i),this.attributes=Object.assign({"stroke-width":.3,"stroke-dasharray":"none",fill:"black",stroke:"black"},i),this.shadow_attributes={width:0,color:"black"},this.state_stack=[]}create(t){return document.createElementNS(te,t)}openGroup(t,e,i){const s=this.create("g");return this.groups.push(s),this.parent.appendChild(s),this.parent=s,t&&s.setAttribute("class",b(t)),e&&s.setAttribute("id",b(e)),i&&i.pointerBBox&&s.setAttribute("pointer-events","bounding-box"),s}closeGroup(){this.groups.pop(),this.parent=this.groups[this.groups.length-1]}add(t){this.parent.appendChild(t)}setFillStyle(t){return this.attributes.fill=t,this}setBackgroundFillStyle(t){return this.backgroundFillStyle=t,this}setStrokeStyle(t){return this.attributes.stroke=t,this}setShadowColor(t){return this.shadow_attributes.color=t,this}setShadowBlur(t){return this.shadow_attributes.width=t,this}setLineWidth(t){return this.attributes["stroke-width"]=t,this.lineWidth=t,this}setLineDash(t){if("[object Array]"===Object.prototype.toString.call(t))return this.attributes["stroke-dasharray"]=t.join(","),this;throw new f("ArgumentError","lineDash must be an array of integers.")}setLineCap(t){return this.attributes["stroke-linecap"]=t,this}resize(t,e){this.width=t,this.height=e,this.element.style.width=t.toString(),this.svg.style.width=t.toString(),this.svg.style.height=e.toString();const i={width:t,height:e};return this.applyAttributes(this.svg,i),this.scale(this.state.scale.x,this.state.scale.y),this}scale(t,e){this.state.scale={x:t,y:e};const i=this.width/t,s=this.height/e;return this.setViewBox(0,0,i,s),this}setViewBox(t,e,i,s){if("string"==typeof t)this.svg.setAttribute("viewBox",t);else{const n=t+" "+e+" "+i+" "+s;this.svg.setAttribute("viewBox",n)}}applyAttributes(t,e){const i=Zt[t.nodeName];for(const s in e)i&&i[s]||t.setAttributeNS(null,s,e[s]);return t}clear(){for(;this.svg.lastChild;)this.svg.removeChild(this.svg.lastChild);this.scale(this.state.scale.x,this.state.scale.y)}rect(t,e,i,s,n){s<0&&(e+=s,s*=-1);const a=this.create("rect");return n=null!=n?n:{fill:"none","stroke-width":this.lineWidth,stroke:"black"},this.applyAttributes(a,Object.assign({x:t,y:e,width:i,height:s},n)),this.add(a),this}fillRect(t,e,i,s){const n={fill:this.attributes.fill};return this.rect(t,e,i,s,n),this}clearRect(t,e,i,s){return this.rect(t,e,i,s,{"stroke-width":0,fill:this.backgroundFillStyle}),this}beginPath(){return this.path="",this.pen.x=NaN,this.pen.y=NaN,this}moveTo(t,e){return this.path+="M"+t+" "+e,this.pen.x=t,this.pen.y=e,this}lineTo(t,e){return this.path+="L"+t+" "+e,this.pen.x=t,this.pen.y=e,this}bezierCurveTo(t,e,i,s,n,a){return this.path+="C"+t+" "+e+","+i+" "+s+","+n+" "+a,this.pen.x=n,this.pen.y=a,this}quadraticCurveTo(t,e,i,s){return this.path+="Q"+t+" "+e+","+i+" "+s,this.pen.x=i,this.pen.y=s,this}arc(t,e,i,s,n,a){const o=t+i*Math.cos(s),r=e+i*Math.sin(s);if(!a&&n-s>=ee||a&&s-n>=ee){const n=t+i*Math.cos(s+Math.PI),a=e+i*Math.sin(s+Math.PI);this.path+=`M${o} ${r} A${i} ${i} 0 0 0 ${n} ${a} `,this.path+=`A${i} ${i} 0 0 0 ${o} ${r}`,this.pen.x=o,this.pen.y=r}else{const h=t+i*Math.cos(n),c=e+i*Math.sin(n);let d;s=w(s),n=w(n),d=Math.abs(n-s)<Math.PI?a:!a,s>n&&(d=!d);const l=!a;this.path+=`M${o} ${r} A${i} ${i} 0 ${+d} ${+l} ${h} ${c}`,this.pen.x=h,this.pen.y=c}return this}closePath(){return this.path+="Z",this}getShadowStyle(){const t=this.shadow_attributes;return`filter: drop-shadow(0 0 ${t.width/1.5}px ${t.color})`}fill(t){const e=this.create("path");return void 0===t&&(t=Object.assign(Object.assign({},this.attributes),{stroke:"none"})),t.d=this.path,this.shadow_attributes.width>0&&(t.style=this.getShadowStyle()),this.applyAttributes(e,t),this.add(e),this}stroke(){const t=this.create("path"),e=Object.assign(Object.assign({},this.attributes),{fill:"none","stroke-width":this.lineWidth,d:this.path});return this.shadow_attributes.width>0&&(e.style=this.getShadowStyle()),this.applyAttributes(t,e),this.add(t),this}measureText(t){return ie.measureTextCache.lookup(t,this.svg,this.attributes)}fillText(t,e,i){if(!t||t.length<=0)return this;const s=Object.assign(Object.assign({},this.attributes),{stroke:"none",x:e,y:i}),n=this.create("text");return n.textContent=t,this.applyAttributes(n,s),this.add(n),this}save(){return this.state_stack.push({state:{"font-family":this.state["font-family"],"font-weight":this.state["font-weight"],"font-style":this.state["font-style"],"font-size":this.state["font-size"],scale:this.state.scale},attributes:{"font-family":this.attributes["font-family"],"font-weight":this.attributes["font-weight"],"font-style":this.attributes["font-style"],"font-size":this.attributes["font-size"],fill:this.attributes.fill,stroke:this.attributes.stroke,"stroke-width":this.attributes["stroke-width"],"stroke-dasharray":this.attributes["stroke-dasharray"]},shadow_attributes:{width:this.shadow_attributes.width,color:this.shadow_attributes.color},lineWidth:this.lineWidth}),this}restore(){const t=this.state_stack.pop();if(t){const e=t;this.state["font-family"]=e.state["font-family"],this.state["font-weight"]=e.state["font-weight"],this.state["font-style"]=e.state["font-style"],this.state["font-size"]=e.state["font-size"],this.state.scale=e.state.scale,this.attributes["font-family"]=e.attributes["font-family"],this.attributes["font-weight"]=e.attributes["font-weight"],this.attributes["font-style"]=e.attributes["font-style"],this.attributes["font-size"]=e.attributes["font-size"],this.attributes.fill=e.attributes.fill,this.attributes.stroke=e.attributes.stroke,this.attributes["stroke-width"]=e.attributes["stroke-width"],this.attributes["stroke-dasharray"]=e.attributes["stroke-dasharray"],this.shadow_attributes.width=e.shadow_attributes.width,this.shadow_attributes.color=e.shadow_attributes.color,this.lineWidth=e.lineWidth}return this}set fillStyle(t){this.setFillStyle(t)}get fillStyle(){return this.attributes.fill}set strokeStyle(t){this.setStrokeStyle(t)}get strokeStyle(){return this.attributes.stroke}setFont(t,e,i,s){const n=M.validate(t,e,i,s);this.fontCSSString=M.toCSSString(n);const a={"font-family":n.family,"font-size":n.size,"font-weight":n.weight,"font-style":n.style};return this.attributes=Object.assign(Object.assign({},this.attributes),a),this.state=Object.assign(Object.assign({},this.state),a),this}getFont(){return this.fontCSSString}}var se,ne,ae,oe;ie.measureTextCache=new class{constructor(){this.cache={}}lookup(t,e,i){let s=this.cache[t];void 0===s&&(s={},this.cache[t]=s);const n=`${i["font-family"]}%${i["font-size"]}%${i["font-weight"]}%${i["font-style"]}`;let a=s[n];return void 0===a&&(a=this.measureImpl(t,e,i),s[n]=a),a}measureImpl(t,e,i){let s=this.txt;s||(s=document.createElementNS(te,"text"),this.txt=s),s.textContent=t,s.setAttributeNS(null,"font-family",i["font-family"]),s.setAttributeNS(null,"font-size",i["font-size"]),s.setAttributeNS(null,"font-style",i["font-style"]),s.setAttributeNS(null,"font-weight",i["font-weight"]),e.appendChild(s);const n=s.getBBox();return e.removeChild(s),{x:n.x,y:n.y,width:n.width,height:n.height}}},function(t){t[t.CANVAS=1]="CANVAS",t[t.SVG=2]="SVG"}(se||(se={})),function(t){t[t.NONE=1]="NONE",t[t.UP=2]="UP",t[t.DOWN=3]="DOWN"}(ne||(ne={}));class re{constructor(t,e){if(l(t))this.ctx=t;else{if(void 0===e)throw new f("InvalidArgument","Missing backend argument");const i=e;let s;if("string"==typeof t){const e=document.getElementById(t);if(!e)throw new f("BadElementId",`Can't find element with ID "${e}"`);s=e}else s=t;if(i===re.Backends.CANVAS){if(!Jt(s))throw new f("BadElement","CANVAS context requires an HTMLCanvasElement.");const t=s.getContext("2d");if(!t)throw new f("BadElement","Can't get canvas context");this.ctx=new Qt(t)}else{if(i!==re.Backends.SVG)throw new f("InvalidBackend",`No support for backend: ${i}`);if(!qt(s))throw new f("BadElement","SVG context requires an HTMLDivElement.");this.ctx=new ie(s)}}}static buildContext(t,e,i,s,n="#FFF"){const a=new re(t,e);i&&s&&a.resize(i,s);const o=a.getContext();return o.setBackgroundFillStyle(n),re.lastContext=o,o}static getCanvasContext(t,e,i,s){return re.buildContext(t,re.Backends.CANVAS,e,i,s)}static getSVGContext(t,e,i,s){return re.buildContext(t,re.Backends.SVG,e,i,s)}static drawDashedLine(t,e,i,s,n,a){t.beginPath();const o=s-e,r=n-i,h=Math.atan2(r,o);let c=e,d=i;t.moveTo(e,i);let l=0,g=!0;for(;!(o<0?c<=s:c>=s)||!(r<0?d<=n:d>=n);){const e=a[l++%a.length],i=c+Math.cos(h)*e;c=o<0?Math.max(s,i):Math.min(s,i);const u=d+Math.sin(h)*e;d=r<0?Math.max(n,u):Math.min(n,u),g?t.lineTo(c,d):t.moveTo(c,d),g=!g}t.closePath(),t.stroke()}resize(t,e){return this.ctx.resize(t,e),this}getContext(){return this.ctx}}re.Backends=se,re.LineEndType=ne,re.lastContext=void 0;class he extends H{constructor(t){super(),this.string_number=t,this.setWidth(20),this.position=H.Position.ABOVE,this.x_shift=0,this.y_shift=0,this.text_line=0,this.stem_offset=0,this.x_offset=0,this.y_offset=0,this.dashed=!0,this.leg=re.LineEndType.NONE,this.radius=8,this.resetFont()}static get CATEGORY(){return m.StringNumber}static get metrics(){return tt.currentMusicFont().getMetrics().glyphs.stringNumber}static format(t,e){const i=e.left_shift,s=e.right_shift;if(!t||0===t.length)return!1;const n=[];let a=null,o=0,r=0;for(let h=0;h<t.length;++h){const c=t[h],d=c.getNote(),l=c.getPosition();if(!g(d))throw new f("NoStaveNote");const u=c.checkIndex(),p=d.getKeyProps()[u],m=d.getModifierContext(),_=2*c.radius/tt.STAVE_LINE_DISTANCE+.5;if(m&&(l===I.ABOVE?(c.text_line=m.getState().top_text_line,e.top_text_line+=_):l===I.BELOW&&(c.text_line=m.getState().text_line,e.text_line+=_)),d!==a){for(let t=0;t<d.keys.length;++t)0===i&&(o=Math.max(d.getLeftDisplacedHeadPx(),o)),0===s&&(r=Math.max(d.getRightDisplacedHeadPx(),r));a=d}const x=p.line;n.push({pos:l,note:d,num:c,line:x,shiftL:o,shiftR:r})}n.sort(((t,e)=>e.line-t.line));let h=0,c=0,d=0,l=null,u=null;for(let t=0;t<n.length;++t){let e=0;const a=n[t].note,r=n[t].pos,g=n[t].num,p=n[t].line,m=n[t].shiftR;p===l&&a===u||(h=s+m);const f=g.getWidth()+1;r===H.Position.LEFT?(g.setXShift(i),e=o+f,c=e>c?e:c):r===H.Position.RIGHT&&(g.setXShift(h),e+=f,d=e>d?e:d),l=p,u=a}return e.left_shift+=c,e.right_shift+=d,!0}setLineEndType(t){return t>=re.LineEndType.NONE&&t<=re.LineEndType.DOWN&&(this.leg=t),this}setStringNumber(t){return this.string_number=t,this}setOffsetX(t){return this.x_offset=t,this}setOffsetY(t){return this.y_offset=t,this}setLastNote(t){return this.last_note=t,this}setDashed(t){return this.dashed=t,this}draw(){const t=this.checkContext(),e=this.checkAttachedNote();this.setRendered();const i=e.getModifierStartXY(this.position,this.index),s=e.hasStem()?e.getStemDirection():nt.UP;let n=i.x+this.x_shift+this.x_offset,a={};e.hasStem()&&(a=e.checkStem().getExtents());let o=i.y+this.y_shift+this.y_offset;switch(this.position){case H.Position.ABOVE:o=e.getYs().reduce(((t,e)=>t<e?t:e)),e.hasStem()&&s==nt.UP&&(o=a.topY+he.metrics.stemPadding),o-=this.radius+he.metrics.verticalPadding+this.text_line*tt.STAVE_LINE_DISTANCE;break;case H.Position.BELOW:o=e.getYs().reduce(((t,e)=>t>e?t:e)),e.hasStem()&&s==nt.DOWN&&(o=a.topY-he.metrics.stemPadding),o+=this.radius+he.metrics.verticalPadding+this.text_line*tt.STAVE_LINE_DISTANCE;break;case H.Position.LEFT:n-=this.radius/2+he.metrics.leftPadding;break;case H.Position.RIGHT:n+=this.radius/2+he.metrics.rightPadding;break;default:throw new f("InvalidPosition",`The position ${this.position} is invalid`)}t.save(),t.beginPath(),t.arc(n,o,this.radius,0,2*Math.PI,!1),t.setLineWidth(1.5),t.stroke(),t.setFont(this.textFont);const r=n-t.measureText(this.string_number).width/2;t.fillText(""+this.string_number,r,o+4.5);const h=this.last_note;if(u(h)){const i=h.getStemX()-e.getX()+5;let s,a;switch(t.setStrokeStyle("#000000"),t.setLineCap("round"),t.setLineWidth(.6),this.dashed?re.drawDashedLine(t,n+10,o,n+i,o,[3,3]):re.drawDashedLine(t,n+10,o,n+i,o,[3,0]),this.leg){case re.LineEndType.UP:s=-10,a=this.dashed?[3,3]:[3,0],re.drawDashedLine(t,n+i,o,n+i,o+s,a);break;case re.LineEndType.DOWN:s=10,a=this.dashed?[3,3]:[3,0],re.drawDashedLine(t,n+i,o,n+i,o+s,a)}}t.restore()}}he.TEXT_FONT={family:M.SANS_SERIF,size:M.SIZE,weight:k.BOLD,style:D.NORMAL};class ce extends H{constructor(t,e){super(),this.options=Object.assign({all_voices:!0},e),this.all_voices=this.options.all_voices,this.type=t,this.position=H.Position.LEFT,this.render_options={font_scale:38},this.resetFont(),this.setXShift(0),this.setWidth(10)}static get CATEGORY(){return m.Stroke}static format(t,e){const i=e.left_shift;if(!t||0===t.length)return!1;const s=t.map((t=>{const e=t.getNote(),i=t.checkIndex();if(g(e)){const{line:s}=e.getKeyProps()[i];return{line:s,shift:e.getLeftDisplacedHeadPx(),stroke:t}}if(p(e)){const{str:s}=e.getPositions()[i];return{line:s,shift:0,stroke:t}}throw new f("Internal","Unexpected instance.")})),n=i,a=s.reduce(((t,{stroke:e,shift:i})=>(e.setXShift(n+i),Math.max(e.getWidth()+0,t))),0);return e.left_shift+=a,!0}getPosition(){return this.position}addEndNote(t){return this.note_end=t,this}draw(){const t=this.checkContext(),e=this.checkAttachedNote();this.setRendered();const i=e.getModifierStartXY(this.position,this.index);let s=e.getYs(),n=i.y,a=i.y;const o=i.x-5,r=e.checkStave().getSpacingBetweenLines(),h=this.checkModifierContext().getMembers(e.getCategory());for(let t=0;t<h.length;t++){const e=h[t];if(d(e)){s=e.getYs();for(let e=0;e<s.length;e++)(this.note===h[t]||this.all_voices)&&(n=Math.min(n,s[e]),a=Math.max(a,s[e]))}}let c="",l=0,u=0,p=0,m=0;switch(this.type){case ce.Type.BRUSH_DOWN:c="arrowheadBlackUp",l=-3,u=n-r/2+10,a+=r/2;break;case ce.Type.BRUSH_UP:c="arrowheadBlackDown",l=.5,u=a+r/2,n-=r/2;break;case ce.Type.ROLL_DOWN:case ce.Type.RASQUEDO_DOWN:c="arrowheadBlackUp",l=-3,p=this.x_shift+l-2,g(e)?(n+=1.5*r,a+=(a-n)%2!=0?.5*r:r,u=n-r,m=a+r+2):(n+=1.5*r,a+=r,u=n-.75*r,m=a+.25*r);break;case ce.Type.ROLL_UP:case ce.Type.RASQUEDO_UP:c="arrowheadBlackDown",l=-4,p=this.x_shift+l-1,g(e)?(u=r/2,n+=.5*r,(a-n)%2==0&&(a+=r/2),u=a+.5*r,m=n-1.25*r):(n+=.25*r,a+=.5*r,u=a+.25*r,m=n-r);break;case ce.Type.ARPEGGIO_DIRECTIONLESS:n+=.5*r,a+=r;break;default:throw new f("InvalidType",`The stroke type ${this.type} does not exist`)}let _="straight";if(this.type===ce.Type.BRUSH_DOWN||this.type===ce.Type.BRUSH_UP)t.fillRect(o+this.x_shift,n,1,a-n);else if(_="wiggly",g(e))for(let e=n;e<=a;e+=r)U.renderGlyph(t,o+this.x_shift-4,e,this.render_options.font_scale,"vexWiggleArpeggioUp");else{let e;for(e=n;e<=a;e+=10)U.renderGlyph(t,o+this.x_shift-4,e,this.render_options.font_scale,"vexWiggleArpeggioUp");this.type===ce.Type.RASQUEDO_DOWN&&(m=e+.25*r)}this.type!==ce.Type.ARPEGGIO_DIRECTIONLESS&&(U.renderGlyph(t,o+this.x_shift+l,u,this.render_options.font_scale,c,{category:`stroke.${c}.${_}`}),this.type!==ce.Type.RASQUEDO_DOWN&&this.type!==ce.Type.RASQUEDO_UP||(t.save(),t.setFont(this.textFont),t.fillText("R",o+p,m),t.restore()))}}ce.Type={BRUSH_DOWN:1,BRUSH_UP:2,ROLL_DOWN:3,ROLL_UP:4,RASQUEDO_DOWN:5,RASQUEDO_UP:6,ARPEGGIO_DIRECTIONLESS:7},ce.TEXT_FONT={family:M.SERIF,size:M.SIZE,weight:k.BOLD,style:D.ITALIC};class de extends H{constructor(){super(),this.position=H.Position.RIGHT,this.render_options={harsh:!1,vibrato_width:20,wave_height:6,wave_width:4,wave_girth:2},this.setVibratoWidth(this.render_options.vibrato_width)}static get CATEGORY(){return m.Vibrato}static format(t,e,i){if(!t||0===t.length)return!1;let s=e.top_text_line,n=0,a=e.right_shift-7;const o=i.getMembers(Mt.CATEGORY);if(o&&o.length>0){s-=o.map((t=>t.getTextHeight())).reduce(((t,e)=>t>e?t:e))/tt.STAVE_LINE_DISTANCE+1}else e.top_text_line+=1;for(let e=0;e<t.length;++e){const i=t[e];i.setXShift(a),i.setTextLine(s),n+=i.getWidth(),a+=n}return e.right_shift+=n,!0}setHarsh(t){return this.render_options.harsh=t,this}setVibratoWidth(t){return this.render_options.vibrato_width=t,this.setWidth(t),this}draw(){const t=this.checkContext(),e=this.checkAttachedNote();this.setRendered();const i=e.getModifierStartXY(H.Position.RIGHT,this.index).x+this.x_shift,s=e.getYForTopText(this.text_line)+2;de.renderVibrato(t,i,s,this.render_options)}static renderVibrato(t,e,i,s){const{harsh:n,vibrato_width:a,wave_width:o,wave_girth:r,wave_height:h}=s,c=a/o;let d;if(t.beginPath(),n){for(t.moveTo(e,i+r+1),d=0;d<c/2;++d)t.lineTo(e+o,i-h/2),e+=o,t.lineTo(e+o,i+h/2),e+=o;for(d=0;d<c/2;++d)t.lineTo(e-o,i-h/2+r+1),e-=o,t.lineTo(e-o,i+h/2+r+1),e-=o;t.fill()}else{for(t.moveTo(e,i+r),d=0;d<c/2;++d)t.quadraticCurveTo(e+o/2,i-h/2,e+o,i),e+=o,t.quadraticCurveTo(e+o/2,i+h/2,e+o,i),e+=o;for(d=0;d<c/2;++d)t.quadraticCurveTo(e-o/2,i+h/2+r,e-o,i+r),e-=o,t.quadraticCurveTo(e-o/2,i-h/2+r,e-o,i+r),e-=o;t.fill()}}}function le(...t){ge.DEBUG&&S("Vex.Flow.ModifierContext",t)}class ge{constructor(){this.state={left_shift:0,right_shift:0,text_line:0,top_text_line:0},this.members={},this.preFormatted=!1,this.postFormatted=!1,this.formatted=!1,this.width=0,this.spacing=0}addModifier(t){return le("addModifier is deprecated, use addMember instead."),this.addMember(t)}addMember(t){const e=t.getCategory();return this.members[e]||(this.members[e]=[]),this.members[e].push(t),t.setModifierContext(this),this.preFormatted=!1,this}getModifiers(t){return le("getModifiers is deprecated, use getMembers instead."),this.getMembers(t)}getMembers(t){var e;return null!==(e=this.members[t])&&void 0!==e?e:[]}getWidth(){return this.width}getLeftShift(){return this.state.left_shift}getRightShift(){return this.state.right_shift}getState(){return this.state}getMetrics(){if(!this.formatted)throw new f("UnformattedMember","Unformatted member has no metrics.");return{width:this.state.left_shift+this.state.right_shift+this.spacing,spacing:this.spacing}}preFormat(){if(this.preFormatted)return;le("Preformatting ModifierContext");const t=this.state,e=this.members;$t.format(e[m.StaveNote],t),Xt.format(e[m.Parenthesis],t),Ot.format(e[m.Dot],t),Lt.format(e[m.FretHandFinger],t),st.format(e[m.Accidental],t),ce.format(e[m.Stroke],t),Ut.format(e[m.GraceNoteGroup],t),Ht.format(e[m.NoteSubGroup],t),he.format(e[m.StringNumber],t),xt.format(e[m.Articulation],t),jt.format(e[m.Ornament],t),lt.format(e[m.Annotation],t),Rt.format(e[m.ChordSymbol],t),Mt.format(e[m.Bend],t),de.format(e[m.Vibrato],t,this),this.width=t.left_shift+t.right_shift,this.preFormatted=!0}postFormat(){this.postFormatted||(le("Postformatting ModifierContext"),$t.postFormat(this.getMembers(m.StaveNote)))}}ge.DEBUG=!1;class ue extends At{constructor(t,e,i){super(),this.clef=ue.types.treble,this.setPosition(wt.BEGIN),this.setType(t,e,i),this.setWidth(tt.currentMusicFont().lookupMetric(`clef.${this.size}.width`)),function(...t){ue.DEBUG&&S("Vex.Flow.Clef",t)}("Creating clef:",t)}static get CATEGORY(){return m.Clef}static get types(){return{treble:{code:"gClef",line:3,point:0},bass:{code:"fClef",line:1,point:0},alto:{code:"cClef",line:2,point:0},tenor:{code:"cClef",line:1,point:0},percussion:{code:"restMaxima",line:2,point:0},soprano:{code:"cClef",line:4,point:0},"mezzo-soprano":{code:"cClef",line:3,point:0},"baritone-c":{code:"cClef",line:0,point:0},"baritone-f":{code:"fClef",line:2,point:0},subbass:{code:"fClef",line:0,point:0},french:{code:"gClef",line:4,point:0},tab:{code:"6stringTabClef",point:0}}}setType(t,e,i){this.type=t,this.clef=ue.types[t],this.size=void 0===e?"default":e;const s=tt.currentMusicFont();if(this.clef.point=s.lookupMetric(`clef.${this.size}.point`,0),this.glyph=new U(this.clef.code,this.clef.point,{category:`clef.${this.clef.code}.${this.size}`}),void 0!==i){const t=s.lookupMetric(`clef.annotations.${i}.smuflCode`),e=s.lookupMetric(`clef.annotations.${i}.${this.size}.point`),n=s.lookupMetric(`clef.annotations.${i}.${this.size}.${this.type}.line`),a=s.lookupMetric(`clef.annotations.${i}.${this.size}.${this.type}.shiftX`);this.annotation={code:t,point:e,line:n,x_shift:a},this.attachment=new U(this.annotation.code,this.annotation.point),this.attachment.metrics.x_max=0,this.attachment.setXShift(this.annotation.x_shift)}else this.annotation=void 0;return this}getWidth(){return"tab"===this.type&&x(this.stave,"ClefError","Can't get width without stave."),this.width}setStave(t){if(this.stave=t,"tab"===this.type){const t=x(this.glyph,"ClefError","Can't set stave without glyph."),e=this.stave.getNumLines(),i=tt.currentMusicFont(),s=i.lookupMetric(`clef.lineCount.${e}.point`),n=i.lookupMetric(`clef.lineCount.${e}.shiftY`);t.setPoint(s),t.setYShift(n)}return this}draw(){const t=x(this.glyph,"ClefError","Can't draw clef without glyph."),e=this.checkStave(),i=e.checkContext();this.setRendered(),i.openGroup("clef",this.getAttribute("id")),t.setStave(e),t.setContext(i),void 0!==this.clef.line&&this.placeGlyphOnLine(t,e,this.clef.line),t.renderToStave(this.x),void 0!==this.annotation&&void 0!==this.attachment&&(this.placeGlyphOnLine(this.attachment,e,this.annotation.line),this.attachment.setStave(e),this.attachment.setContext(i),this.attachment.renderToStave(this.x)),i.closeGroup()}}ue.DEBUG=!1;class pe extends At{constructor(t,e,i){super(),this.accList=[],this.setKeySig(t,e,i),this.setPosition(wt.BEGIN),this.glyphFontScale=38,this.glyphs=[],this.xPositions=[],this.paddingForced=!1}static get CATEGORY(){return m.KeySignature}convertToGlyph(t,e){const i=tt.accidentalCodes(t.type),s=new U(i.code,this.glyphFontScale);let n=1;if("n"===t.type&&e){const i=pe.accidentalSpacing[e.type];if(i){n=e.line>=t.line?i.above:i.below}}this.placeGlyphOnLine(s,this.checkStave(),t.line),this.glyphs.push(s);const a=this.xPositions[this.xPositions.length-1],o=s.getMetrics().width+n;this.xPositions.push(a+o),this.width+=o}cancelKey(t){return this.formatted=!1,this.cancelKeySpec=t,this}convertToCancelAccList(t){const e=tt.keySignature(t),i=this.accList.length>0&&e.length>0&&e[0].type!==this.accList[0].type,s=i?e.length:e.length-this.accList.length;if(s<1)return;const n=[];for(let t=0;t<s;t++){let a=t;i||(a=e.length-s+t);const o=e[a];n.push({type:"n",line:o.line})}return this.accList=n.concat(this.accList),{accList:n,type:e[0].type}}addToStave(t){return this.paddingForced=!0,t.addModifier(this),this}convertAccLines(t,e,i=this.accList){let s,n,a=0;switch(t){case"soprano":"#"===e?s=[2.5,.5,2,0,1.5,-.5,1]:a=-1;break;case"mezzo-soprano":"b"===e?s=[0,2,.5,2.5,1,3,1.5]:a=1.5;break;case"alto":a=.5;break;case"tenor":"#"===e?s=[3,1,2.5,.5,2,0,1.5]:a=-.5;break;case"baritone-f":case"baritone-c":"b"===e?s=[.5,2.5,1,3,1.5,3.5,2]:a=2;break;case"bass":case"french":a=1}if(void 0!==s)for(n=0;n<i.length;++n)i[n].line=s[n];else if(0!==a)for(n=0;n<i.length;++n)i[n].line+=a}getPadding(t){return this.formatted||this.format(),0===this.glyphs.length||!this.paddingForced&&t<2?0:this.padding}getWidth(){return this.formatted||this.format(),this.width}setKeySig(t,e,i){return this.formatted=!1,this.keySpec=t,this.cancelKeySpec=e,this.alterKeySpec=i,this}alterKey(t){return this.formatted=!1,this.alterKeySpec=t,this}convertToAlterAccList(t){const e=Math.min(t.length,this.accList.length);for(let i=0;i<e;++i)t[i]&&(this.accList[i].type=t[i])}format(){const t=this.checkStave();this.width=0,this.glyphs=[],this.xPositions=[0],this.accList=tt.keySignature(x(this.keySpec));const e=this.accList,i=e.length>0?e[0].type:void 0;let s;if(this.cancelKeySpec&&(s=this.convertToCancelAccList(this.cancelKeySpec)),this.alterKeySpec&&this.convertToAlterAccList(this.alterKeySpec),this.accList.length>0){const n=(this.position===wt.END?t.getEndClef():t.getClef())||t.getClef();s&&this.convertAccLines(n,s.type,s.accList),this.convertAccLines(n,i,e);for(let t=0;t<this.accList.length;++t)this.convertToGlyph(this.accList[t],this.accList[t+1])}this.formatted=!0}draw(){const t=this.checkStave(),e=t.checkContext();this.formatted||this.format(),this.setRendered(),e.openGroup("keysignature",this.getAttribute("id"));for(let i=0;i<this.glyphs.length;i++){const s=this.glyphs[i],n=this.x+this.xPositions[i];s.setStave(t),s.setContext(e),s.renderToStave(n)}e.closeGroup()}}pe.accidentalSpacing={"#":{above:6,below:4},b:{above:4,below:7},n:{above:4,below:1},"##":{above:6,below:4},bb:{above:4,below:7},db:{above:4,below:7},d:{above:4,below:7},bbs:{above:4,below:7},"++":{above:6,below:4},"+":{above:6,below:4},"+-":{above:6,below:4},"++-":{above:6,below:4},bs:{above:4,below:10},bss:{above:4,below:10}};class me extends At{constructor(t,e,i){super(),this.symbol_type=t,this.x=e,this.x_shift=0,this.y_shift=i,this.resetFont()}static get CATEGORY(){return m.Repetition}setShiftX(t){return this.x_shift=t,this}setShiftY(t){return this.y_shift=t,this}draw(t,e){switch(this.setRendered(),this.symbol_type){case me.type.CODA_RIGHT:this.drawCodaFixed(t,e+t.getWidth());break;case me.type.CODA_LEFT:this.drawSymbolText(t,e,"Coda",!0);break;case me.type.SEGNO_LEFT:this.drawSignoFixed(t,e);break;case me.type.SEGNO_RIGHT:this.drawSignoFixed(t,e+t.getWidth());break;case me.type.DC:this.drawSymbolText(t,e,"D.C.",!1);break;case me.type.DC_AL_CODA:this.drawSymbolText(t,e,"D.C. al",!0);break;case me.type.DC_AL_FINE:this.drawSymbolText(t,e,"D.C. al Fine",!1);break;case me.type.DS:this.drawSymbolText(t,e,"D.S.",!1);break;case me.type.DS_AL_CODA:this.drawSymbolText(t,e,"D.S. al",!0);break;case me.type.DS_AL_FINE:this.drawSymbolText(t,e,"D.S. al Fine",!1);break;case me.type.FINE:this.drawSymbolText(t,e,"Fine",!1);break;case me.type.TO_CODA:this.drawSymbolText(t,e,"To",!0)}return this}drawCodaFixed(t,e){const i=t.getYForTopText(t.getNumLines())+this.y_shift;return U.renderGlyph(t.checkContext(),this.x+e+this.x_shift,i+tt.currentMusicFont().lookupMetric("staveRepetition.coda.offsetY"),40,"coda",{category:"coda"}),this}drawSignoFixed(t,e){const i=t.getYForTopText(t.getNumLines())+this.y_shift;return U.renderGlyph(t.checkContext(),this.x+e+this.x_shift,i+tt.currentMusicFont().lookupMetric("staveRepetition.segno.offsetY"),30,"segno",{category:"segno"}),this}drawSymbolText(t,e,i,s){const n=t.checkContext();n.save(),n.setFont(this.textFont);let a=0,o=0;const r=t.getNoteStartX()-this.x;switch(this.symbol_type){case me.type.CODA_LEFT:a=this.x+t.getVerticalBarWidth(),o=a+n.measureText(i).width+tt.currentMusicFont().lookupMetric("staveRepetition.symbolText.offsetX");break;case me.type.DC:case me.type.DC_AL_FINE:case me.type.DS:case me.type.DS_AL_FINE:case me.type.FINE:a=this.x+e+this.x_shift+t.getWidth()-tt.currentMusicFont().lookupMetric("staveRepetition.symbolText.spacing")-r-n.measureText(i).width;break;default:a=this.x+e+this.x_shift+t.getWidth()-tt.currentMusicFont().lookupMetric("staveRepetition.symbolText.spacing")-r-n.measureText(i).width-tt.currentMusicFont().lookupMetric("staveRepetition.symbolText.offsetX"),o=a+n.measureText(i).width+tt.currentMusicFont().lookupMetric("staveRepetition.symbolText.offsetX")}const h=t.getYForTopText(t.getNumLines())+this.y_shift+tt.currentMusicFont().lookupMetric("staveRepetition.symbolText.offsetY");return s&&U.renderGlyph(n,o,h,40,"coda",{category:"coda"}),n.fillText(i,a,h+5),n.restore(),this}}me.TEXT_FONT={family:M.SERIF,size:12,weight:k.BOLD,style:D.NORMAL},me.type={NONE:1,CODA_LEFT:2,CODA_RIGHT:3,SEGNO_LEFT:4,SEGNO_RIGHT:5,DC:6,DC_AL_CODA:7,DC_AL_FINE:8,DS:9,DS_AL_CODA:10,DS_AL_FINE:11,FINE:12,TO_CODA:13};class fe extends At{constructor(t,e,i){super(),this.setWidth(16),this.section=t,this.x=e,this.shift_x=0,this.shift_y=i,this.resetFont()}static get CATEGORY(){return m.StaveSection}setStaveSection(t){return this.section=t,this}setShiftX(t){return this.shift_x=t,this}setShiftY(t){return this.shift_y=t,this}draw(t,e){const i=t.checkContext();this.setRendered(),i.save(),i.setLineWidth(2),i.setFont(this.textFont);const s=i.measureText(this.section),n=s.width+4,a=s.height+4,o=t.getYForTopText(2)+this.shift_y,r=this.x+e;return i.beginPath(),i.setLineWidth(2),i.rect(r,o+s.y-2,n,a),i.stroke(),i.fillText(this.section,r+2,o),i.restore(),this}}fe.TEXT_FONT={family:M.SANS_SERIF,size:10,weight:k.BOLD,style:D.NORMAL};class _e extends At{constructor(t,e,i){super(),this.render_options={glyph_font_scale:30},this.tempo=t,this.position=wt.ABOVE,this.x=e,this.shift_x=10,this.shift_y=i,this.resetFont()}static get CATEGORY(){return m.StaveTempo}setTempo(t){return this.tempo=t,this}setShiftX(t){return this.shift_x=t,this}setShiftY(t){return this.shift_y=t,this}draw(t,e){const i=t.checkContext();this.setRendered();const s=this.render_options,n=s.glyph_font_scale/38,a=this.tempo.name,o=this.tempo.duration,r=this.tempo.dots||0,h=this.tempo.bpm;let c=this.x+this.shift_x+e;const d=t.getYForTopText(1)+this.shift_y;if(i.save(),a&&(i.setFont(this.textFont),i.fillText(a,c,d),c+=i.measureText(a).width),o&&h){i.setFont(Object.assign(Object.assign({},this.textFont),{weight:"normal",style:"normal"})),a&&(c+=i.measureText(" ").width,i.fillText("(",c,d),c+=i.measureText("(").width);const t=tt.getGlyphProps(o);if(c+=3*n,U.renderGlyph(i,c,d,s.glyph_font_scale,t.code_head),c+=t.getWidth()*n,t.stem){let e=30;t.beam_count&&(e+=3*(t.beam_count-1)),e*=n;const a=d-e;i.fillRect(c-n,a,n,e),t.flag&&(U.renderGlyph(i,c,a,s.glyph_font_scale,t.code_flag_upstem,{category:"flag.staveTempo"}),r||(c+=6*n))}for(let t=0;t<r;t++)c+=6*n,i.beginPath(),i.arc(c,d+2*n,2*n,0,2*Math.PI,!1),i.fill();i.fillText(" = "+h+(a?")":""),c+3*n,d)}return i.restore(),this}}_e.TEXT_FONT={family:M.SERIF,size:14,weight:k.BOLD,style:D.NORMAL},function(t){t[t.LEFT=1]="LEFT",t[t.CENTER=2]="CENTER",t[t.RIGHT=3]="RIGHT"}(ae||(ae={}));class xe extends bt{constructor(t){if(super(t),this.text=t.text||"",this.superscript=t.superscript,this.subscript=t.subscript,this.setFont(t.font),this.line=t.line||0,this.smooth=t.smooth||!1,this.ignore_ticks=t.ignore_ticks||!1,this.justification=ae.LEFT,t.glyph){const e=xe.GLYPHS[t.glyph];if(!e)throw new f("Invalid glyph type: "+t.glyph);this.glyph=new U(e.code,40,{category:"textNote"}),this.setWidth(this.glyph.getMetrics().width)}else this.glyph=void 0}static get CATEGORY(){return m.TextNote}static get GLYPHS(){return{segno:{code:"segno"},tr:{code:"ornamentTrill"},mordent:{code:"ornamentMordent"},mordent_upper:{code:"ornamentShortTrill"},mordent_lower:{code:"ornamentMordent"},f:{code:"dynamicForte"},p:{code:"dynamicPiano"},m:{code:"dynamicMezzo"},s:{code:"dynamicSforzando"},z:{code:"dynamicZ"},coda:{code:"coda"},pedal_open:{code:"keyboardPedalPed"},pedal_close:{code:"keyboardPedalUp"},caesura_straight:{code:"caesura"},caesura_curved:{code:"caesuraCurved"},breath:{code:"breathMarkComma"},tick:{code:"breathMarkTick"},turn:{code:"ornamentTurn"},turn_inverted:{code:"ornamentTurnSlash"}}}setJustification(t){return this.justification=t,this}setLine(t){return this.line=t,this}preFormat(){if(this.preFormatted)return;const t=this.checkTickContext("Can't preformat without a TickContext.");if(this.smooth)this.setWidth(0);else if(this.glyph);else{const t=this.checkContext();t.setFont(this.textFont),this.setWidth(t.measureText(this.text).width)}this.justification===ae.CENTER?this.leftDisplacedHeadPx=this.width/2:this.justification===ae.RIGHT&&(this.leftDisplacedHeadPx=this.width),this.rightDisplacedHeadPx=t.getMetrics().glyphPx/2,this.preFormatted=!0}draw(){const t=this.checkContext(),e=this.checkStave(),i=this.checkTickContext("Can't draw without a TickContext.");this.setRendered();let s=this.getAbsoluteX()+i.getMetrics().glyphPx/2;const n=this.getWidth();let a;if(this.justification===ae.CENTER?s-=n/2:this.justification===ae.RIGHT&&(s-=n),this.glyph)a=e.getYForLine(this.line+-3),this.glyph.render(t,s,a);else{a=e.getYForLine(this.line+-3),this.applyStyle(t),t.setFont(this.textFont),t.fillText(this.text,s,a);const i=t.measureText(this.text).height,{family:n,size:o,weight:r,style:h}=this.textFont,c=M.scaleSize(o,.769231);this.superscript&&(t.setFont(n,c,r,h),t.fillText(this.superscript,s+this.width+2,a-i/2.2)),this.subscript&&(t.setFont(n,c,r,h),t.fillText(this.subscript,s+this.width+2,a+i/2.2-1)),this.restoreStyle(t)}}}xe.TEXT_FONT={family:M.SANS_SERIF,size:12,weight:k.NORMAL,style:D.NORMAL},xe.Justification=ae;class Se extends At{constructor(t,e,i={}){super(),this.setWidth(16),this.text=t,this.position=e,this.options=Object.assign({shift_x:0,shift_y:0,justification:xe.Justification.CENTER},i),this.resetFont()}static get CATEGORY(){return m.StaveText}setStaveText(t){return this.text=t,this}setShiftX(t){return this.shift_x=t,this}setShiftY(t){return this.shift_y=t,this}setText(t){return this.text=t,this}draw(t){const e=t.checkContext();this.setRendered(),e.save(),e.setLineWidth(2),e.setFont(this.textFont);const i=e.measureText(""+this.text).width;let s,n;switch(this.position){case wt.LEFT:case wt.RIGHT:n=(t.getYForLine(0)+t.getBottomLineY())/2+this.options.shift_y,s=this.position===wt.LEFT?t.getX()-i-24+this.options.shift_x:t.getX()+t.getWidth()+24+this.options.shift_x;break;case wt.ABOVE:case wt.BELOW:s=t.getX()+this.options.shift_x,this.options.justification===ae.CENTER?s+=t.getWidth()/2-i/2:this.options.justification===ae.RIGHT&&(s+=t.getWidth()-i),n=this.position===wt.ABOVE?t.getYForTopText(2)+this.options.shift_y:t.getYForBottomText(2)+this.options.shift_y;break;default:throw new f("InvalidPosition","Value Must be in Modifier.Position.")}return e.fillText(""+this.text,s,n+4),e.restore(),this}}Se.TEXT_FONT={family:M.SERIF,size:16,weight:k.NORMAL,style:D.NORMAL},function(t){t[t.NONE=1]="NONE",t[t.BEGIN=2]="BEGIN",t[t.MID=3]="MID",t[t.END=4]="END",t[t.BEGIN_END=5]="BEGIN_END"}(oe||(oe={}));class ye extends At{constructor(t,e,i,s){super(),this.volta=t,this.x=i,this.y_shift=s,this.number=e,this.resetFont()}static get CATEGORY(){return m.Volta}static get type(){return oe}setShiftY(t){return this.y_shift=t,this}draw(t,e){const i=t.checkContext();this.setRendered();let s=t.getWidth()-e;const n=t.getYForTopText(t.getNumLines())+this.y_shift,a=1.5*t.getSpacingBetweenLines();switch(this.volta){case oe.BEGIN:i.fillRect(this.x+e,n,1,a);break;case oe.END:s-=5,i.fillRect(this.x+e+s,n,1,a);break;case oe.BEGIN_END:s-=3,i.fillRect(this.x+e,n,1,a),i.fillRect(this.x+e+s,n,1,a)}return this.volta!==oe.BEGIN&&this.volta!==oe.BEGIN_END||(i.save(),i.setFont(this.textFont),i.fillText(this.number,this.x+e+5,n+15),i.restore()),i.fillRect(this.x+e,n,s,1),this}}ye.TEXT_FONT={family:M.SANS_SERIF,size:9,weight:k.BOLD,style:D.NORMAL};class Te extends U{constructor(t,e,i,s,n,a){var o;super(s,n,a),this.timeSignature=t,this.topGlyphs=[],this.botGlyphs=[];let r=0;for(let t=0;t<e.length;++t){let s=e[t];switch(e[t]){case"-":s="Minus";break;case"+":s=i.length>0?"PlusSmall":"Plus";break;case"(":s=i.length>0?"ParensLeftSmall":"ParensLeft";break;case")":s=i.length>0?"ParensRightSmall":"ParensRight"}const n=new U("timeSig"+s,this.timeSignature.point);this.topGlyphs.push(n),r+=null!==(o=n.getMetrics().width)&&void 0!==o?o:0}let h=0;for(let t=0;t<i.length;++t){let e=i[t];switch(i[t]){case"+":e="PlusSmall";break;case"(":e="ParensLeftSmall";break;case")":e="ParensRightSmall"}const s=new U("timeSig"+e,this.timeSignature.point);this.botGlyphs.push(s),h+=x(s.getMetrics().width)}this.width=Math.max(r,h),this.xMin=this.getMetrics().x_min,this.topStartX=(this.width-r)/2,this.botStartX=(this.width-h)/2,this.reset()}getMetrics(){return{x_min:this.xMin,x_max:this.xMin+this.width,width:this.width}}renderToStave(t){const e=this.checkStave(),i=this.checkContext();let s=t+this.topStartX,n=0;n=this.botGlyphs.length>0?e.getYForLine(this.timeSignature.topLine):(e.getYForLine(this.timeSignature.topLine)+e.getYForLine(this.timeSignature.bottomLine))/2;for(let t=0;t<this.topGlyphs.length;++t){const e=this.topGlyphs[t];U.renderOutline(i,e.getMetrics().outline,this.scale,s+this.x_shift,n),s+=x(e.getMetrics().width)}s=t+this.botStartX,n=e.getYForLine(this.timeSignature.bottomLine);for(let t=0;t<this.botGlyphs.length;++t){const a=this.botGlyphs[t];this.timeSignature.placeGlyphOnLine(a,e,0),U.renderOutline(i,a.getMetrics().outline,this.scale,s+a.getMetrics().x_shift,n),s+=x(a.getMetrics().width)}}}class be extends At{constructor(t="4/4",e=15,i=!0){super(),this.validate_args=i;const s=e,n=tt.currentMusicFont();this.point=n.lookupMetric("digits.point");const a=n.lookupMetric("digits.shiftLine",0);this.topLine=2+a,this.bottomLine=4+a,this.setPosition(wt.BEGIN),this.info=this.parseTimeSpec(t),this.setWidth(x(this.info.glyph.getMetrics().width)),this.setPadding(s)}static get CATEGORY(){return m.TimeSignature}static get glyphs(){return{C:{code:"timeSigCommon",point:40,line:2},"C|":{code:"timeSigCutCommon",point:40,line:2}}}parseTimeSpec(t){var e,i;if("C"===t||"C|"===t){const{line:e,code:i,point:s}=be.glyphs[t];return{line:e,num:!1,glyph:new U(i,s)}}this.validate_args&&(t=>{const e=t.split("/");if(2!==e.length&&"+"!==e[0]&&"-"!==e[0])throw new f("BadTimeSignature",`Invalid time spec: ${t}. Must be in the form "<numerator>/<denominator>"`);e.forEach((e=>{if(0==/^[0-9+\-()]+$/.test(e))throw new f("BadTimeSignature",`Invalid time spec: ${t}. Must contain valid signatures.`)}))})(t);const s=t.split("/");return{num:!0,glyph:this.makeTimeSignatureGlyph(null!==(e=s[0])&&void 0!==e?e:"",null!==(i=s[1])&&void 0!==i?i:"")}}makeTimeSignatureGlyph(t,e){return new Te(this,t,e,"timeSig0",this.point)}getInfo(){return this.info}setTimeSig(t){return this.info=this.parseTimeSpec(t),this}draw(){const t=this.checkStave(),e=t.checkContext();this.setRendered(),e.openGroup("timesignature",this.getAttribute("id")),this.info.glyph.setStave(t),this.info.glyph.setContext(e),this.placeGlyphOnLine(this.info.glyph,t,this.info.line),this.info.glyph.renderToStave(this.x),e.closeGroup()}}const we={[Pt.CATEGORY]:0,[ue.CATEGORY]:1,[pe.CATEGORY]:2,[be.CATEGORY]:3},ve={[be.CATEGORY]:0,[pe.CATEGORY]:1,[Pt.CATEGORY]:2,[ue.CATEGORY]:3};class Ee extends O{constructor(t,e,i,s){super(),this.height=0,this.x=t,this.y=e,this.width=i,this.formatted=!1,this.start_x=t+5,this.end_x=t+i,this.modifiers=[],this.measure=0,this.clef="treble",this.endClef=void 0,this.resetFont(),this.options=Object.assign({vertical_bar_width:10,num_lines:5,fill_style:"#999999",left_bar:!0,right_bar:!0,spacing_between_lines_px:tt.STAVE_LINE_DISTANCE,space_above_staff_ln:4,space_below_staff_ln:4,top_text_position:1,bottom_text_position:4,line_config:[]},s),this.bounds={x:this.x,y:this.y,w:this.width,h:0},this.defaultLedgerLineStyle={strokeStyle:"#444",lineWidth:1.4},this.resetLines(),this.addModifier(new Pt(this.options.left_bar?vt.SINGLE:vt.NONE)),this.addEndModifier(new Pt(this.options.right_bar?vt.SINGLE:vt.NONE))}static get CATEGORY(){return m.Stave}static get defaultPadding(){const t=tt.currentMusicFont();return t.lookupMetric("stave.padding")+t.lookupMetric("stave.endPaddingMax")}static get rightPadding(){return tt.currentMusicFont().lookupMetric("stave.endPaddingMax")}setDefaultLedgerLineStyle(t){this.defaultLedgerLineStyle=t}getDefaultLedgerLineStyle(){return Object.assign(Object.assign({},this.getStyle()),this.defaultLedgerLineStyle)}space(t){return this.options.spacing_between_lines_px*t}resetLines(){this.options.line_config=[];for(let t=0;t<this.options.num_lines;t++)this.options.line_config.push({visible:!0});this.height=(this.options.num_lines+this.options.space_above_staff_ln)*this.options.spacing_between_lines_px,this.options.bottom_text_position=this.options.num_lines}setNoteStartX(t){this.formatted||this.format(),this.start_x=t;const e=this.modifiers[0];return e.setX(this.start_x-e.getWidth()),this}getNoteStartX(){return this.formatted||this.format(),this.start_x}getNoteEndX(){return this.formatted||this.format(),this.end_x}getTieStartX(){return this.start_x}getTieEndX(){return this.end_x}getX(){return this.x}getNumLines(){return this.options.num_lines}setNumLines(t){return this.options.num_lines=t,this.resetLines(),this}setY(t){return this.y=t,this}getY(){return this.y}getTopLineTopY(){return this.getYForLine(0)-tt.STAVE_LINE_THICKNESS/2}getBottomLineBottomY(){return this.getYForLine(this.getNumLines()-1)+tt.STAVE_LINE_THICKNESS/2}setX(t){const e=t-this.x;this.formatted=!1,this.x=t,this.start_x+=e,this.end_x+=e;for(let t=0;t<this.modifiers.length;t++){const i=this.modifiers[t];i.setX(i.getX()+e)}return this}setWidth(t){return this.formatted=!1,this.width=t,this.end_x=this.x+t,this}getWidth(){return this.width}getStyle(){return Object.assign({fillStyle:this.options.fill_style,strokeStyle:this.options.fill_style,lineWidth:tt.STAVE_LINE_THICKNESS},this.style)}setMeasure(t){return this.measure=t,this}getModifierXShift(t=0){if("number"!=typeof t)throw new f("InvalidIndex","Must be of number type");if(this.formatted||this.format(),1===this.getModifiers(wt.BEGIN).length)return 0;if(this.modifiers[t].getPosition()===wt.RIGHT)return 0;let e=this.start_x-this.x;const i=this.modifiers[0];return i.getType()===vt.REPEAT_BEGIN&&e>i.getWidth()&&(e-=i.getWidth()),e}setRepetitionType(t,e=0){return this.modifiers.push(new me(t,this.x,e)),this}setVoltaType(t,e,i){return this.modifiers.push(new ye(t,e,this.x,i)),this}setSection(t,e,i=0,s){const n=new fe(t,this.x+i,e);return s&&n.setFontSize(s),this.modifiers.push(n),this}setTempo(t,e){return this.modifiers.push(new _e(t,this.x,e)),this}setText(t,e,i={}){return this.modifiers.push(new Se(t,e,i)),this}getHeight(){return this.height}getSpacingBetweenLines(){return this.options.spacing_between_lines_px}getBoundingBox(){return new C(this.x,this.y,this.width,this.getBottomY()-this.y)}getBottomY(){const t=this.options,e=t.spacing_between_lines_px;return this.getYForLine(t.num_lines)+t.space_below_staff_ln*e}getBottomLineY(){return this.getYForLine(this.options.num_lines)}getYForLine(t){const e=this.options,i=e.spacing_between_lines_px,s=e.space_above_staff_ln;return this.y+t*i+s*i}getLineForY(t){const e=this.options,i=e.spacing_between_lines_px,s=e.space_above_staff_ln;return(t-this.y)/i-s}getYForTopText(t=0){return this.getYForLine(-t-this.options.top_text_position)}getYForBottomText(t=0){return this.getYForLine(this.options.bottom_text_position+t)}getYForNote(t){const e=this.options,i=e.spacing_between_lines_px,s=e.space_above_staff_ln;return this.y+s*i+5*i-t*i}getYForGlyphs(){return this.getYForLine(3)}addModifier(t,e){return void 0!==e&&t.setPosition(e),t.setStave(this),this.formatted=!1,this.modifiers.push(t),this}addEndModifier(t){return this.addModifier(t,wt.END),this}setBegBarType(t){const{SINGLE:e,REPEAT_BEGIN:i,NONE:s}=vt;return t!==e&&t!==i&&t!==s||(this.modifiers[0].setType(t),this.formatted=!1),this}setEndBarType(t){return t!==vt.REPEAT_BEGIN&&(this.modifiers[1].setType(t),this.formatted=!1),this}setClef(t,e,i,s){void 0===s&&(s=wt.BEGIN),s===wt.END?this.endClef=t:this.clef=t;const n=this.getModifiers(s,ue.CATEGORY);return 0===n.length?this.addClef(t,e,i,s):n[0].setType(t,e,i),this}getClef(){return this.clef}setEndClef(t,e,i){return this.setClef(t,e,i,wt.END),this}getEndClef(){return this.endClef}setKeySignature(t,e,i){void 0===i&&(i=wt.BEGIN);const s=this.getModifiers(i,pe.CATEGORY);return 0===s.length?this.addKeySignature(t,e,i):s[0].setKeySig(t,e),this}setEndKeySignature(t,e){return this.setKeySignature(t,e,wt.END),this}setTimeSignature(t,e,i){void 0===i&&(i=wt.BEGIN);const s=this.getModifiers(i,be.CATEGORY);return 0===s.length?this.addTimeSignature(t,e,i):s[0].setTimeSig(t),this}setEndTimeSignature(t,e){return this.setTimeSignature(t,e,wt.END),this}addKeySignature(t,e,i){return void 0===i&&(i=wt.BEGIN),this.addModifier(new pe(t,e).setPosition(i),i),this}addClef(t,e,i,s){return void 0===s||s===wt.BEGIN?this.clef=t:s===wt.END&&(this.endClef=t),this.addModifier(new ue(t,e,i),s),this}addEndClef(t,e,i){return this.addClef(t,e,i,wt.END),this}addTimeSignature(t,e,i){return this.addModifier(new be(t,e),i),this}addEndTimeSignature(t,e){return this.addTimeSignature(t,e,wt.END),this}addTrebleGlyph(){return this.addClef("treble"),this}getModifiers(t,e){const i=void 0===t,s=void 0===e;return i&&s?this.modifiers:i?this.modifiers.filter((t=>e===t.getCategory())):s?this.modifiers.filter((e=>t===e.getPosition())):this.modifiers.filter((i=>t===i.getPosition()&&e===i.getCategory()))}sortByCategory(t,e){for(let i=t.length-1;i>=0;i--)for(let s=0;s<i;s++)if(e[t[s].getCategory()]>e[t[s+1].getCategory()]){const e=t[s];t[s]=t[s+1],t[s+1]=e}}format(){const t=this.modifiers[0],e=this.modifiers[1],i=this.getModifiers(wt.BEGIN),s=this.getModifiers(wt.END);let n,a,r;this.sortByCategory(i,we),this.sortByCategory(s,ve),i.length>1&&t.getType()===vt.REPEAT_BEGIN&&(i.push(i.splice(0,1)[0]),i.splice(0,0,new Pt(vt.SINGLE))),s.indexOf(e)>0&&s.splice(0,0,new Pt(vt.NONE));let h=0,c=this.x;for(let t=0;t<i.length;t++)r=i[t],a=r.getPadding(t+h),n=r.getWidth(),c+=a,r.setX(c),c+=n,a+n===0&&h--;this.start_x=c,c=this.x+this.width;const d={left:0,right:0,paddingRight:0,paddingLeft:0};let l=0;for(let t=0;t<s.length;t++){r=s[t],l=o(r)?t:l,d.right=0,d.left=0,d.paddingRight=0,d.paddingLeft=0;const e=r.getLayoutMetrics();e?(0!==t&&(d.right=e.xMax||0,d.paddingRight=e.paddingRight||0),d.left=-e.xMin||0,d.paddingLeft=e.paddingLeft||0,t===s.length-1&&(d.paddingLeft=0)):(d.paddingRight=r.getPadding(t-l),0!==t&&(d.right=r.getWidth()),0===t&&(d.left=r.getWidth())),c-=d.paddingRight,c-=d.right,r.setX(c),c-=d.left,c-=d.paddingLeft}this.end_x=1===s.length?this.x+this.width:c,this.formatted=!0}draw(){const t=this.checkContext();this.setRendered(),t.openGroup("stave",this.getAttribute("id")),this.formatted||this.format();const e=this.options.num_lines,i=this.width,s=this.x;let n;for(let a=0;a<e;a++)n=this.getYForLine(a),this.applyStyle(),this.options.line_config[a].visible&&(t.beginPath(),t.moveTo(s,n),t.lineTo(s+i,n),t.stroke()),this.restoreStyle();for(let e=0;e<this.modifiers.length;e++){const i=this.modifiers[e];"function"==typeof i.draw&&(i.applyStyle(t),i.draw(this,this.getModifierXShift(e)),i.restoreStyle(t))}if(this.measure>0){t.save(),t.setFont(this.textFont);const e=t.measureText(""+this.measure).width;n=this.getYForTopText(0)+3,t.fillText(""+this.measure,this.x-e/2,n),t.restore()}return t.closeGroup(),this}getVerticalBarWidth(){return this.options.vertical_bar_width}getConfigForLines(){return this.options.line_config}setConfigForLine(t,e){if(t>=this.options.num_lines||t<0)throw new f("StaveConfigError","The line number must be within the range of the number of lines in the Stave.");if(void 0===e.visible)throw new f("StaveConfigError","The line configuration object is missing the 'visible' property.");if("boolean"!=typeof e.visible)throw new f("StaveConfigError","The line configuration objects 'visible' property must be true or false.");return this.options.line_config[t]=e,this}setConfigForLines(t){if(t.length!==this.options.num_lines)throw new f("StaveConfigError","The length of the lines configuration array must match the number of lines in the Stave");for(const e in t)null==t[e].visible&&(t[e]=this.options.line_config[e]),this.options.line_config[e]=Object.assign(Object.assign({},this.options.line_config[e]),t[e]);return this.options.line_config=t,this}}function Ce(t,e,i,s,n){if(e!==Ne.type.BOLD_DOUBLE_LEFT&&e!==Ne.type.BOLD_DOUBLE_RIGHT)throw new f("InvalidConnector","A REPEAT_BEGIN or REPEAT_END type must be provided.");let a=3,o=3.5;e===Ne.type.BOLD_DOUBLE_RIGHT&&(a=-5,o=3),t.fillRect(i+a,s,1,n-s),t.fillRect(i-2,s,o,n-s)}Ee.TEXT_FONT={family:M.SANS_SERIF,size:8,weight:k.NORMAL,style:D.NORMAL};class Ne extends O{constructor(t,e){super(),this.thickness=tt.STAVE_LINE_THICKNESS,this.width=3,this.top_stave=t,this.bottom_stave=e,this.type=Ne.type.DOUBLE,this.resetFont(),this.x_shift=0,this.texts=[]}static get CATEGORY(){return m.StaveConnector}setType(t){return(t="string"==typeof t?Ne.typeString[t]:t)>=Ne.type.SINGLE_RIGHT&&t<=Ne.type.NONE&&(this.type=t),this}setText(t,e={}){return this.texts.push({content:t,options:Object.assign({shift_x:0,shift_y:0},e)}),this}setXShift(t){if("number"!=typeof t)throw new f("InvalidType","x_shift must be a Number");return this.x_shift=t,this}getXShift(){return this.x_shift}draw(){const t=this.checkContext();this.setRendered();let e=this.top_stave.getYForLine(0),i=this.bottom_stave.getYForLine(this.bottom_stave.getNumLines()-1)+this.thickness,s=this.width,n=this.top_stave.getX();(this.type===Ne.type.SINGLE_RIGHT||this.type===Ne.type.BOLD_DOUBLE_RIGHT||this.type===Ne.type.THIN_DOUBLE)&&(n=this.top_stave.getX()+this.top_stave.getWidth());let a=i-e;switch(this.type){case Ne.type.SINGLE:case Ne.type.SINGLE_LEFT:case Ne.type.SINGLE_RIGHT:s=1;break;case Ne.type.DOUBLE:n-=this.width+2,e-=this.thickness,a+=.5;break;case Ne.type.BRACE:{s=12;const n=this.top_stave.getX()-2+this.x_shift,o=e,r=n,h=i,c=n-s,d=o+a/2,l=c-.9*s,g=o+.2*a,u=n+1.1*s,p=d-.135*a,m=u,f=d+.135*a,_=l,x=h-.2*a,S=c-s,y=x,T=n+.4*s,b=d+.135*a,w=T,v=d-.135*a,E=S,C=g;t.beginPath(),t.moveTo(n,o),t.bezierCurveTo(l,g,u,p,c,d),t.bezierCurveTo(m,f,_,x,r,h),t.bezierCurveTo(S,y,T,b,c,d),t.bezierCurveTo(w,v,E,C,n,o),t.fill(),t.stroke();break}case Ne.type.BRACKET:e-=6,i+=6,a=i-e,U.renderGlyph(t,n-5,e,40,"bracketTop"),U.renderGlyph(t,n-5,i,40,"bracketBottom"),n-=this.width+2;break;case Ne.type.BOLD_DOUBLE_LEFT:Ce(t,this.type,n+this.x_shift,e,i-this.thickness);break;case Ne.type.BOLD_DOUBLE_RIGHT:Ce(t,this.type,n,e,i-this.thickness);break;case Ne.type.THIN_DOUBLE:s=1,a-=this.thickness;break;case Ne.type.NONE:break;default:throw new f("InvalidType",`The provided StaveConnector.type (${this.type}) is invalid.`)}this.type!==Ne.type.BRACE&&this.type!==Ne.type.BOLD_DOUBLE_LEFT&&this.type!==Ne.type.BOLD_DOUBLE_RIGHT&&this.type!==Ne.type.NONE&&t.fillRect(n,e,s,a),this.type===Ne.type.THIN_DOUBLE&&t.fillRect(n-3,e,s,a),t.save(),t.setLineWidth(2),t.setFont(this.textFont);for(let e=0;e<this.texts.length;e++){const i=this.texts[e],s=t.measureText(""+i.content).width,n=this.top_stave.getX()-s-24+i.options.shift_x,a=(this.top_stave.getYForLine(0)+this.bottom_stave.getBottomLineY())/2+i.options.shift_y;t.fillText(""+i.content,n,a+4)}t.restore()}}Ne.TEXT_FONT={family:M.SERIF,size:16,weight:k.NORMAL,style:D.NORMAL},Ne.type={SINGLE_RIGHT:0,SINGLE_LEFT:1,SINGLE:1,DOUBLE:2,BRACE:3,BRACKET:4,BOLD_DOUBLE_LEFT:5,BOLD_DOUBLE_RIGHT:6,THIN_DOUBLE:7,NONE:8},Ne.typeString={singleRight:Ne.type.SINGLE_RIGHT,singleLeft:Ne.type.SINGLE_LEFT,single:Ne.type.SINGLE,double:Ne.type.DOUBLE,brace:Ne.type.BRACE,bracket:Ne.type.BRACKET,boldDoubleLeft:Ne.type.BOLD_DOUBLE_LEFT,boldDoubleRight:Ne.type.BOLD_DOUBLE_RIGHT,thinDouble:Ne.type.THIN_DOUBLE,none:Ne.type.NONE};const ke=t=>t.reduce(((t,e)=>t+e),0);function De(t,e,i){const s=Pe.getResolutionMultiplier(t),n={},a=[],o=[];return t.forEach(((t,r)=>{const h=new v(0,s);t.getTickables().forEach((t=>{const s=h.numerator;if(!n[s]){const t=e({tickID:s});o.push(t),n[s]=t,a.push(s)}i(t,n[s],r),h.add(t.getTicks())}))})),{map:n,array:o,list:a.sort(((t,e)=>t-e)),resolutionMultiplier:s}}function Ae(t,e,i,s){let n=e;for(let e=i+1;e<t.length;e++){const i=t[e];if(d(i)&&!i.isRest()&&!i.shouldIgnoreTicks()){n=i.getLineForRest();break}}if(s&&e!==n){n=T(Math.max(e,n),Math.min(e,n))}return n}class Pe{constructor(t){this.formatterOptions=Object.assign({globalSoftmax:!1,softmaxFactor:100,maxIterations:5},t),this.justifyWidth=0,this.totalCost=0,this.totalShift=0,this.durationStats={},this.minTotalWidth=0,this.hasMinTotalWidth=!1,this.tickContexts=void 0,this.modifierContexts=void 0,this.contextGaps={total:0,gaps:[]},this.voices=[],this.lossHistory=[]}static SimpleFormat(t,e=0,{paddingBetween:i=10}={}){t.reduce(((t,e)=>{e.addToModifierContext(new ge);const s=(new Yt).addTickable(e).preFormat(),n=s.getMetrics();return s.setX(t+n.totalLeftPx),t+s.getWidth()+n.totalRightPx+i}),e)}static plotDebugging(t,e,i,s,n,a){const o=i+(a=Object.assign({stavePadding:tt.currentMusicFont().lookupMetric("stave.padding")},a)).stavePadding,r=e.contextGaps;t.save(),t.setFont(M.SANS_SERIF,8),r.gaps.forEach((e=>{var i,a,r;i=o+e.x1,a=o+e.x2,r="rgba(100,200,100,0.4)",t.beginPath(),t.setStrokeStyle(r),t.setFillStyle(r),t.setLineWidth(1),t.fillRect(i,s,Math.max(a-i,0),n-s),t.setFillStyle("green"),t.fillText(Math.round(e.x2-e.x1).toString(),o+e.x1,n+12)})),t.setFillStyle("red"),t.fillText(`Loss: ${(e.totalCost||0).toFixed(2)} Shift: ${(e.totalShift||0).toFixed(2)} Gap: ${r.total.toFixed(2)}`,o-20,n+27),t.restore()}static FormatAndDraw(t,e,i,s){let n={auto_beam:!1,align_rests:!1};"object"==typeof s?n=Object.assign(Object.assign({},n),s):"boolean"==typeof s&&(n.auto_beam=s);const a=new Gt(tt.TIME4_4).setMode(Gt.Mode.SOFT).addTickables(i),o=n.auto_beam?Ie.applyAndGetBeams(a):[];return(new Pe).joinVoices([a]).formatToStave([a],e,{align_rests:n.align_rests,stave:e}),a.setStave(e).draw(t,e),o.forEach((e=>e.setContext(t).draw())),a.getBoundingBox()}static FormatAndDrawTab(t,e,i,s,n,a,o){let r={auto_beam:a,align_rests:!1};"object"==typeof o?r=Object.assign(Object.assign({},r),o):"boolean"==typeof o&&(r.auto_beam=o);const h=new Gt(tt.TIME4_4).setMode(Gt.Mode.SOFT).addTickables(n),c=new Gt(tt.TIME4_4).setMode(Gt.Mode.SOFT).addTickables(s),d=r.auto_beam?Ie.applyAndGetBeams(h):[];(new Pe).joinVoices([h]).joinVoices([c]).formatToStave([h,c],i,{align_rests:r.align_rests}),h.draw(t,i),c.draw(t,e),d.forEach((e=>e.setContext(t).draw())),new Ne(i,e).setContext(t).draw()}static AlignRestsToNotes(t,e,i){t.forEach(((s,n)=>{if(g(s)&&s.isRest()){if(s.getTuplet()&&!i)return;const a=s.getGlyph().position.toUpperCase();if("R/4"!==a&&"B/4"!==a)return;if(e||s.getBeam()){const e=s.getKeyProps()[0];if(0===n)e.line=Ae(t,e.line,n,!1);else if(n>0&&n<t.length){const i=t[n-1];if(g(i))if(i.isRest())e.line=i.getKeyProps()[0].line;else{const s=i.getLineForRest();e.line=Ae(t,s,n,!0)}}s.setKeyLine(0,e.line)}}}))}alignRests(t,e){if(!t||!t.length)throw new f("BadArgument","No voices to format rests");t.forEach((t=>Pe.AlignRestsToNotes(t.getTickables(),e)))}preCalculateMinTotalWidth(t){const e=tt.currentMusicFont().lookupMetric("stave.unalignedNotePadding");let i=0,s=0,n=0;const a=[],o=[];if(this.hasMinTotalWidth)return this.minTotalWidth;if(!this.tickContexts){if(!t)throw new f("BadArgument","'voices' required to run preCalculateMinTotalWidth");this.createTickContexts(t)}const{list:r,map:h}=this.tickContexts;this.minTotalWidth=0,r.forEach((e=>{const r=h[e];r.preFormat(),r.getTickables().length<t.length&&(i+=1),r.getTickables().forEach((t=>{s+=t.getMetrics().width,n+=t.getTicks().value(),a.push(t.getMetrics().width),o.push(t.getTicks().value())}));const c=r.getWidth();this.minTotalWidth+=c})),this.hasMinTotalWidth=!0;const c=s>0?s/a.length:1/a.length,d=ke(a.map((t=>Math.pow(t-c,2)))),l=Math.pow(d/a.length,.5)/c,g=n/o.length,u=ke(o.map((t=>Math.pow(t-g,2)))),p=Math.pow(u/o.length,.5)/g,m=Math.max(p,l)*r.length*e,_=e*i;return this.minTotalWidth+Math.max(_,m)}getMinTotalWidth(){if(!this.hasMinTotalWidth)throw new f("NoMinTotalWidth","Call 'preCalculateMinTotalWidth' or 'preFormat' before calling 'getMinTotalWidth'");return this.minTotalWidth}static getResolutionMultiplier(t){if(!t||!t.length)throw new f("BadArgument","No voices to format");const e=t[0].getTotalTicks();return t.reduce(((t,i)=>{if(!i.getTotalTicks().equals(e))throw new f("TickMismatch","Voices should have same total note duration in ticks.");if(i.getMode()===Gt.Mode.STRICT&&!i.isComplete())throw new f("IncompleteVoice","Voice does not have enough notes.");return Math.max(t,v.LCM(t,i.getResolutionMultiplier()))}),1)}createModifierContexts(t){const e=De(t,(()=>new ge),((t,e)=>t.addToModifierContext(e)));return this.modifierContexts=e,e}createTickContexts(t){const e=De(t,(t=>new Yt(t)),((t,e,i)=>e.addTickable(t,i)));this.tickContexts=e;const i=this.tickContexts.array;return i.forEach((t=>{t.tContexts=i})),e}preFormat(t=0,e,i,s){const n=this.tickContexts;if(!n)throw new f("NoTickContexts","preFormat requires TickContexts");const{list:a,map:o}=n;this.lossHistory=[],i&&s&&i.forEach((t=>t.setStave(s).preFormat()));let r=0,h=0;this.minTotalWidth=0;let c=0;a.forEach((t=>{const e=o[t];e.preFormat();const i=e.getWidth();this.minTotalWidth+=i;const s=e.getMaxTicks().value();c+=s;const n=e.getMetrics();r=r+h+n.totalLeftPx,e.setX(r),h=i-n.totalLeftPx}));const{globalSoftmax:d,softmaxFactor:l,maxIterations:g}=this.formatterOptions,u=ke(a.map((t=>Math.pow(l,o[t].getMaxTicks().value()/c))));if(this.minTotalWidth=r+h,this.hasMinTotalWidth=!0,t<=0)return this.evaluate();const p=o[a[0]],m=o[a[a.length-1]];function _(t){return a.map(((e,i)=>{const s=o[e],n=s.getTickablesByVoice();let r;if(i>0){const e=o[a[i-1]];for(let h=i-1;h>=0;h--){const i=o[a[h]].getTickablesByVoice(),g=[];if(Object.keys(n).forEach((t=>{i[t]&&g.push(t)})),g.length>0){let a=0,o=1/0,h=0;if(g.forEach((t=>{const e=i[t].getTicks().value();e>a&&(r=i[t],a=e);const s=n[t],h=s.getX()-(s.getMetrics().modLeftPx+s.getMetrics().leftDisplacedHeadPx),c=i[t].getMetrics(),d=i[t].getX()+c.notePx+c.modRightPx+c.rightDisplacedHeadPx;o=Math.min(o,h-d)})),o=Math.min(o,s.getX()-(e.getX()+.05*t)),d){const e=c;h=Math.pow(l,a/e)/u*t}else void 0!==r&&(h=r.getVoice().softmax(a)*t);return{expectedDistance:h,maxNegativeShiftPx:o,fromTickable:r}}}}return{expectedDistance:0,fromTickablePx:0,maxNegativeShiftPx:0}}))}function S(t){const e=y/2;let i=0;return a.forEach(((s,n)=>{const a=o[s];if(n>0){const e=a.getX(),s=t[n],o=x(s.fromTickable).getX()+s.expectedDistance-(e+i);let r=0;o>0?i+=o:o<0&&(r=Math.min(s.maxNegativeShiftPx,Math.abs(o)),i+=-r),a.setX(e+i)}a.getCenterAlignedTickables().forEach((t=>{t.setCenterXShift(e-a.getX())}))})),m.getX()-p.getX()}const y=t-m.getMetrics().notePx-m.getMetrics().totalRightPx-p.getMetrics().totalLeftPx,T=tt.currentMusicFont(),b=T.lookupMetric("stave.endPaddingMin"),w=T.lookupMetric("stave.endPaddingMax"),v=T.lookupMetric("stave.padding");let E=y;const C=_(E);let N=S(C);if(1===a.length)return 0;const k=((t,e)=>{let i=t/2;if(e.length>1)for(let t=1;t<e.length;++t)i=Math.min(e[t].expectedDistance/2,i);return i})(E,C),D=t=>{let e=0;const i=m&&m.getMaxTickable();if(i){const s=i.getVoice();if(s.getTicksUsed().value()>s.getTotalTicks().value())return 2*w<k?k:w;const n=i.getWidth();e=s.softmax(m.getMaxTicks().value())*t-(n+v)}return 2*w<e?e:w};let A=D(E),P=A-(w-b);const F=y-P;let M=g;for(;N>F&&M>0||N+A<F&&M>1;)E-=N-F,A=D(E),P=A-(w-b),N=S(_(E)),M--;return this.justifyWidth=t,this.evaluate()}evaluate(){if(!this.tickContexts)return 0;const t=this.tickContexts,e=this.justifyWidth;this.contextGaps={total:0,gaps:[]},t.list.forEach(((e,i)=>{if(0===i)return;const s=t.list[i-1],n=t.map[s],a=t.map[e],o=n.getMetrics(),r=a.getMetrics(),h=n.getX()+o.notePx+o.totalRightPx,c=a.getX()-r.totalLeftPx,d=c-h;this.contextGaps.total+=d,this.contextGaps.gaps.push({x1:h,x2:c}),a.getFormatterMetrics().freedom.left=d,n.getFormatterMetrics().freedom.right=d})),this.durationStats={};const i=this.durationStats;this.voices.forEach((t=>{t.getTickables().forEach(((t,s,n)=>{const a=t.getTicks().clone().simplify().toString(),o=t.getMetrics(),r=t.getFormatterMetrics(),h=t.getX()+o.notePx+o.modRightPx+o.rightDisplacedHeadPx;let c=0;if(s<n.length-1){const e=n[s+1],i=e.getMetrics();c=e.getX()-i.modLeftPx-i.leftDisplacedHeadPx-h,r.space.used=e.getX()-t.getX(),e.getFormatterMetrics().freedom.left=c}else c=e-h,r.space.used=e-t.getX();r.freedom.right=c,function(t,e){const s=i[t];void 0===s?i[t]={mean:e,count:1}:(s.count+=1,s.mean=(s.mean+e)/2)}(a,r.space.used)}))}));let s=0;return this.voices.forEach((t=>{t.getTickables().forEach((t=>{const e=t.getTicks().clone().simplify().toString(),n=t.getFormatterMetrics();n.space.mean=i[e].mean,n.duration=e,n.iterations+=1,n.space.deviation=n.space.used-n.space.mean,s+=Math.pow(n.space.deviation,2)}))})),this.totalCost=Math.sqrt(s),this.lossHistory.push(this.totalCost),this.totalCost}tune(t){var e;const i=this.tickContexts;if(!i)return 0;const s=null!==(e=null==t?void 0:t.alpha)&&void 0!==e?e:.5;let n=0;return this.totalShift=0,i.list.forEach(((t,e,a)=>{const o=i.map[t],r=e>0?i.map[a[e-1]]:void 0,h=e<a.length-1?i.map[a[e+1]]:void 0;!function(t,e,i,s){t.setX(t.getX()+e),t.getFormatterMetrics().freedom.left+=e,t.getFormatterMetrics().freedom.right-=e,i&&(i.getFormatterMetrics().freedom.right+=e),s&&(s.getFormatterMetrics().freedom.left-=e)}(o,n,r,h);const c=-ke(o.getTickables().map((t=>t.getFormatterMetrics().space.deviation)));c>0?n=-Math.min(o.getFormatterMetrics().freedom.right,Math.abs(c)):c<0&&(n=h?Math.min(h.getFormatterMetrics().freedom.right,Math.abs(c)):0),n*=s,this.totalShift+=n})),this.evaluate()}postFormat(){const t=t=>t.list.forEach((e=>t.map[e].postFormat()));return this.modifierContexts&&t(this.modifierContexts),this.tickContexts&&t(this.tickContexts),this}joinVoices(t){return this.createModifierContexts(t),this.hasMinTotalWidth=!1,this}format(t,e,i){const s=Object.assign({align_rests:!1},i);this.voices=t;const n=this.formatterOptions.softmaxFactor;return n&&this.voices.forEach((t=>t.setSoftmaxFactor(n))),this.alignRests(t,s.align_rests),this.createTickContexts(t),this.preFormat(e,s.context,t,s.stave),s.stave&&this.postFormat(),this}formatToStave(t,e,i){const s=Object.assign({context:e.getContext()},i),n=e.getNoteEndX()-e.getNoteStartX()-Ee.defaultPadding;return function(...t){Pe.DEBUG&&S("Vex.Flow.Formatter",t)}("Formatting voices to width: ",n),this.format(t,n,s)}getTickContext(t){var e;return null===(e=this.tickContexts)||void 0===e?void 0:e.map[t]}}var Fe;Pe.DEBUG=!1,function(t){t[t.BOTTOM=-1]="BOTTOM",t[t.TOP=1]="TOP"}(Fe||(Fe={}));class Me extends O{constructor(t,e={}){if(super(),this.numerator_glyphs=[],this.denom_glyphs=[],!t||!t.length)throw new f("BadArguments","No notes provided for tuplet.");this.options=e,this.notes=t,this.num_notes=null!=this.options.num_notes?this.options.num_notes:t.length,this.options.beats_occupied&&this.beatsOccupiedDeprecationWarning(),this.notes_occupied=this.options.notes_occupied||this.options.beats_occupied||2,null!=this.options.bracketed?this.bracketed=this.options.bracketed:this.bracketed=t.some((t=>!t.hasBeam())),this.ratioed=null!=this.options.ratioed?this.options.ratioed:Math.abs(this.notes_occupied-this.num_notes)>1,this.point=tt.currentMusicFont().lookupMetric("digits.tupletPoint"),this.y_pos=16,this.x_pos=100,this.width=200,this.setTupletLocation(this.options.location||Me.LOCATION_TOP),Pe.AlignRestsToNotes(t,!0,!0),this.resolveGlyphs(),this.attach()}static get CATEGORY(){return m.Tuplet}static get LOCATION_TOP(){return Fe.TOP}static get LOCATION_BOTTOM(){return Fe.BOTTOM}static get NESTING_OFFSET(){return 15}static get metrics(){return tt.currentMusicFont().getMetrics().glyphs.tuplet}attach(){for(let t=0;t<this.notes.length;t++){this.notes[t].setTuplet(this)}}detach(){for(let t=0;t<this.notes.length;t++){this.notes[t].resetTuplet(this)}}setBracketed(t){return this.bracketed=!!t,this}setRatioed(t){return this.ratioed=!!t,this}setTupletLocation(t){return t!==Me.LOCATION_TOP&&t!==Me.LOCATION_BOTTOM&&(console.warn(`Invalid tuplet location [${t}]. Using Tuplet.LOCATION_TOP.`),t=Me.LOCATION_TOP),this.location=t,this}getNotes(){return this.notes}getNoteCount(){return this.num_notes}beatsOccupiedDeprecationWarning(){console.warn("beats_occupied has been deprecated as an option for tuplets. Please use notes_occupied instead.","Calls to getBeatsOccupied / setBeatsOccupied should now be routed to getNotesOccupied / setNotesOccupied.","The old methods will be removed in VexFlow 5.0.")}getBeatsOccupied(){return this.beatsOccupiedDeprecationWarning(),this.getNotesOccupied()}setBeatsOccupied(t){return this.beatsOccupiedDeprecationWarning(),this.setNotesOccupied(t)}getNotesOccupied(){return this.notes_occupied}setNotesOccupied(t){this.detach(),this.notes_occupied=t,this.resolveGlyphs(),this.attach()}resolveGlyphs(){this.numerator_glyphs=[];let t=this.num_notes;for(;t>=1;)this.numerator_glyphs.unshift(new U("timeSig"+t%10,this.point)),t=parseInt((t/10).toString(),10);for(this.denom_glyphs=[],t=this.notes_occupied;t>=1;)this.denom_glyphs.unshift(new U("timeSig"+t%10,this.point)),t=parseInt((t/10).toString(),10)}getNestedTupletCount(){const t=this.location,e=this.notes[0];let i=n(e,t),s=n(e,t);function n(t,e){return t.getTupletStack().filter((t=>t.location===e)).length}return this.notes.forEach((e=>{const a=n(e,t);i=a>i?a:i,s=a<s?a:s})),i-s}getYPosition(){const t=this.getNestedTupletCount()*Me.NESTING_OFFSET*-this.location,e=this.options.y_offset||0,i=this.notes[0];let s;if(this.location===Me.LOCATION_TOP){s=i.checkStave().getYForLine(0)-Me.metrics.topModifierOffset;for(let t=0;t<this.notes.length;++t){const e=this.notes[t];let i=0;const n=e.getModifierContext();n&&(i=Math.max(i,n.getState().top_text_line));const a=e.getYForTopText(i)-Me.metrics.noteHeadOffset;if(e.hasStem()||e.isRest()){const t=e.getStemDirection()===nt.UP?e.getStemExtents().topY-Me.metrics.stemOffset:e.getStemExtents().baseY-Me.metrics.noteHeadOffset;s=Math.min(t,s),i>0&&(s=Math.min(a,s))}}}else{let t=Me.metrics.bottomLine;this.notes.forEach((e=>{const i=e.getModifierContext();i&&(t=Math.max(t,i.getState().text_line+1))})),s=i.checkStave().getYForLine(t)+Me.metrics.noteHeadOffset;for(let t=0;t<this.notes.length;++t)if(this.notes[t].hasStem()||this.notes[t].isRest()){const e=this.notes[t].getStemDirection()===nt.UP?this.notes[t].getStemExtents().baseY+Me.metrics.noteHeadOffset:this.notes[t].getStemExtents().topY+Me.metrics.stemOffset;e>s&&(s=e)}}return s+t+e}draw(){const t=this.checkContext();this.setRendered();const e=this.notes[0],i=this.notes[this.notes.length-1];this.bracketed?(this.x_pos=e.getTieLeftX()-5,this.width=i.getTieRightX()-this.x_pos+5):(this.x_pos=e.getStemX(),this.width=i.getStemX()-this.x_pos),this.y_pos=this.getYPosition();const s=(t,e)=>t+x(e.getMetrics().width);let n=this.numerator_glyphs.reduce(s,0);this.ratioed&&(n=this.denom_glyphs.reduce(s,n),n+=.32*this.point);const a=this.x_pos+this.width/2-n/2;if(this.bracketed){const e=this.width/2-n/2-5;e>0&&(t.fillRect(this.x_pos,this.y_pos,e,1),t.fillRect(this.x_pos+this.width/2+n/2+5,this.y_pos,e,1),t.fillRect(this.x_pos,this.y_pos+(this.location===Me.LOCATION_BOTTOM?1:0),1,10*this.location),t.fillRect(this.x_pos+this.width,this.y_pos+(this.location===Me.LOCATION_BOTTOM?1:0),1,10*this.location))}const o=tt.currentMusicFont().lookupMetric("digits.shiftY",0);let r=0;if(this.numerator_glyphs.forEach((e=>{e.render(t,a+r,this.y_pos+this.point/3-2+o),r+=x(e.getMetrics().width)})),this.ratioed){const e=a+r+.16*this.point,i=.06*this.point;t.beginPath(),t.arc(e,this.y_pos-.08*this.point,i,0,2*Math.PI,!0),t.closePath(),t.fill(),t.beginPath(),t.arc(e,this.y_pos+.12*this.point,i,0,2*Math.PI,!0),t.closePath(),t.fill(),r+=.32*this.point,this.denom_glyphs.forEach((e=>{e.render(t,a+r,this.y_pos+this.point/3-2+o),r+=x(e.getMetrics().width)}))}}}function Be(t){let e=0;return t.forEach((t=>{t.keyProps&&t.keyProps.forEach((t=>{e+=t.line-3}))})),e>=0?nt.DOWN:nt.UP}const Re="L",Oe="R",Le="B";class Ie extends O{constructor(t,e=!1){if(super(),this.slope=0,this.y_shift=0,this.forcedPartialDirections={},!t||0===t.length)throw new f("BadArguments","No notes provided for beam.");if(1===t.length)throw new f("BadArguments","Too few notes for beam.");if(this.ticks=t[0].getIntrinsicTicks(),this.ticks>=tt.durationToTicks("4"))throw new f("BadArguments","Beams can only be applied to notes shorter than a quarter note.");let i,s;for(this.stem_direction=nt.UP,i=0;i<t.length;++i)if(s=t[i],s.hasStem()){this.stem_direction=s.getStemDirection();break}let n=this.stem_direction;if(e&&g(t[0]))n=Be(t);else if(e&&p(t[0])){const e=t.reduce(((t,e)=>t+e.getStemDirection()),0);n=e>-1?nt.UP:nt.DOWN}for(i=0;i<t.length;++i)s=t[i],e&&(s.setStemDirection(n),this.stem_direction=n),s.setBeam(this);this.postFormatted=!1,this.notes=t,this.beam_count=this.getBeamCount(),this.break_on_indices=[],this.render_options={beam_width:5,max_slope:.25,min_slope:-.25,slope_iterations:20,slope_cost:100,show_stemlets:!1,stemlet_extension:7,partial_beam_length:10,flat_beams:!1,min_flat_beam_offset:15}}static get CATEGORY(){return m.Beam}getStemDirection(){return this.stem_direction}static getDefaultBeamGroups(t){t&&"c"!==t||(t="4/4");const e={"1/2":["1/2"],"2/2":["1/2"],"3/2":["1/2"],"4/2":["1/2"],"1/4":["1/4"],"2/4":["1/4"],"3/4":["1/4"],"4/4":["1/4"],"1/8":["1/8"],"2/8":["2/8"],"3/8":["3/8"],"4/8":["2/8"],"1/16":["1/16"],"2/16":["2/16"],"3/16":["3/16"],"4/16":["2/16"]}[t];if(void 0!==e)return e.map((t=>(new v).parse(t)));{const e=parseInt(t.split("/")[0],10),i=parseInt(t.split("/")[1],10);if(e%3==0)return[new v(3,i)];if(i>4)return[new v(2,i)];if(i<=4)return[new v(1,i)]}return[new v(1,4)]}static applyAndGetBeams(t,e,i){return Ie.generateBeams(t.getTickables(),{groups:i,stem_direction:e})}static generateBeams(t,e={}){e.groups&&e.groups.length||(e.groups=[new v(2,8)]);const i=e.groups.map((t=>{if(!t.multiply)throw new f("InvalidBeamGroups","The beam groups must be an array of Vex.Flow.Fractions");return t.clone().multiply(tt.RESOLUTION,1)})),s=t;let n=0,a=[],o=[];function r(){i.length-1>n?n+=1:n=0}!function(){let t=[],e=new v(0,1);s.forEach((s=>{if(t=[],s.shouldIgnoreTicks())return a.push(o),void(o=t);o.push(s);const h=i[n].clone(),c=(d=o,d.reduce(((t,e)=>e.getTicks().clone().add(t)),new v(0,1))).add(e);var d;const l=tt.durationToNumber(s.getDuration())<8;if(l&&s.getTuplet()&&(h.numerator*=2),c.greaterThan(h)){if(!l){const e=o.pop();e&&t.push(e)}a.push(o);do{e=c.subtract(i[n]),r()}while(e.greaterThanEquals(i[n]));o=t}else c.equals(h)&&(a.push(o),e=new v(0,1),o=t,r())})),o.length>0&&a.push(o)}(),function(){const t=[];a.forEach((i=>{let s=[];i.forEach(((i,n,a)=>{const o=0===n||n===a.length-1,r=a[n-1],h=!e.beam_rests&&i.isRest(),c=e.beam_rests&&e.beam_middle_only&&i.isRest()&&o;let d=!1;if(e.maintain_stem_directions&&r&&!i.isRest()&&!r.isRest()){const t=r.getStemDirection();d=i.getStemDirection()!==t}const l=parseInt(i.getDuration(),10)<8;h||c||d||l?(s.length>0&&t.push(s),s=d?[i]:[]):s.push(i)})),s.length>0&&t.push(s)})),a=t}(),a.forEach((t=>{let i;if(e.maintain_stem_directions){const e=function(t){for(let e=0;e<t.length;e++){const i=t[e];if(!i.isRest())return i}return!1}(t);i=e?e.getStemDirection():nt.UP}else i=e.stem_direction?e.stem_direction:Be(t);!function(t,e){t.forEach((t=>{t.setStemDirection(e)}))}(t,i)}));const h=a.filter((t=>{if(t.length>1){let e=!0;return t.forEach((t=>{t.getIntrinsicTicks()>=tt.durationToTicks("4")&&(e=!1)})),e}return!1})),c=function(){const t=[];return a.forEach((e=>{let i;e.forEach((e=>{const s=e.getTuplet();s&&i!==s&&(i=s,t.push(i))}))})),t}(),d=[];return h.forEach((t=>{const i=new Ie(t);e.show_stemlets&&(i.render_options.show_stemlets=!0),e.secondary_breaks&&(i.render_options.secondary_break_ticks=tt.durationToTicks(e.secondary_breaks)),!0===e.flat_beams&&(i.render_options.flat_beams=!0,i.render_options.flat_beam_offset=e.flat_beam_offset),d.push(i)})),c.forEach((t=>{const e=t.notes[0].stem_direction===nt.DOWN?Fe.BOTTOM:Fe.TOP;t.setTupletLocation(e);let i=!1;for(let e=0;e<t.notes.length;e++){if(!t.notes[e].hasBeam()){i=!0;break}}t.setBracketed(i)})),d}getNotes(){return this.notes}getBeamCount(){return this.notes.map((t=>t.getGlyph().beam_count)).reduce(((t,e)=>e>t?e:t))}breakSecondaryAt(t){return this.break_on_indices=t,this}setPartialBeamSideAt(t,e){return this.forcedPartialDirections[t]=e,this}unsetPartialBeamSideAt(t){return delete this.forcedPartialDirections[t],this}getSlopeY(t,e,i,s){return i+(t-e)*s}calculateSlope(){const{notes:t,stem_direction:e,render_options:{max_slope:i,min_slope:s,slope_iterations:n,slope_cost:a}}=this,o=t[0],r=function(t,e){const i=t.getStemExtents().topY,s=t.getStemX();return(e.getStemExtents().topY-i)/(e.getStemX()-s)}(o,t[t.length-1]),h=(i-s)/n;let c=Number.MAX_VALUE,d=0,l=0;for(let n=s;n<=i;n+=h){let i=0,s=0;for(let a=1;a<t.length;++a){const r=t[a];if(r.hasStem()||r.isRest()){const t=this.getSlopeY(r.getStemX(),o.getStemX(),o.getStemExtents().topY,n)+s,h=r.getStemExtents().topY;if(h*e<t*e){const n=Math.abs(h-t);s+=n*-e,i+=n*a}else i+=(h-t)*e}}const h=r/2,g=a*Math.abs(h-n)+Math.abs(i);g<c&&(c=g,d=n,l=s)}this.slope=d,this.y_shift=l}calculateFlatSlope(){const{notes:t,stem_direction:e,render_options:{beam_width:i,min_flat_beam_offset:s,flat_beam_offset:n}}=this;let a=0,o=0,r=0,h=0;for(let i=0;i<t.length;i++){const s=t[i],n=s.getStemExtents().topY;a+=n,e===nt.DOWN&&h<n?(h=n,o=Math.max(...s.getYs()),r=s.getBeamCount()):e===nt.UP&&(0===h||h>n)&&(h=n,o=Math.min(...s.getYs()),r=s.getBeamCount())}let c=a/t.length;const d=s+r*(1.5*i),l=o+d*-e;e===nt.DOWN&&c<l?c=o+d:e===nt.UP&&c>l&&(c=o-d),n?(e===nt.DOWN&&c>n||e===nt.UP&&c<n)&&(this.render_options.flat_beam_offset=c):this.render_options.flat_beam_offset=c,this.slope=0,this.y_shift=0}getBeamYToDraw(){let t=this.notes[0].getStemExtents().topY;return this.render_options.flat_beams&&this.render_options.flat_beam_offset&&(t=this.render_options.flat_beam_offset),t}applyStemExtensions(){const{notes:t,slope:e,y_shift:i,stem_direction:s,beam_count:n,render_options:{show_stemlets:a,stemlet_extension:o,beam_width:r}}=this,h=t[0],c=this.getBeamYToDraw(),d=h.getStemX();for(let h=0;h<t.length;++h){const l=t[h],g=l.getStem();if(g){const t=l.getStemX(),{topY:h}=l.getStemExtents(),u=this.getSlopeY(t,d,c,e)+i,p=g.getExtension(),m=s===nt.UP?h-u:u-h;if(g.setExtension(p+m),g.adjustHeightForBeam(),l.isRest()&&a){const t=(n-1)*r*1.5+r;g.setVisibility(!0).setStemlet(!0,t+o)}}}}lookupBeamDirection(t,e,i,s,n){if("4"===t)return Re;const a=this.forcedPartialDirections[n];if(a)return a;const o=""+tt.durationToNumber(t)/2,r=e<tt.durationToTicks(o),h=s<tt.durationToTicks(o),c=i<tt.durationToTicks(o);return r&&h&&c?Le:r&&!h&&c?Re:!r&&h&&c?Oe:this.lookupBeamDirection(o,e,i,s,n)}getBeamLines(t){const e=tt.durationToTicks(t);let i=!1;const s=[];let n;const a=this.render_options.partial_beam_length;let o=!1,r=0;for(let h=0;h<this.notes.length;++h){const c=this.notes[h];r+=c.getTicks().value();let d=!1;parseInt(t,10)>=8&&(d=-1!==this.break_on_indices.indexOf(h),this.render_options.secondary_break_ticks&&r>=this.render_options.secondary_break_ticks&&(r=0,d=!0));const l=c.getIntrinsicTicks()<e,g=c.getStemX()-nt.WIDTH/2,u=this.notes[h-1],p=this.notes[h+1],m=p&&p.getIntrinsicTicks()<e,f=u&&u.getIntrinsicTicks()<e,_=u&&p&&l&&!f&&!m;if(l)if(i)n=s[s.length-1],n.end=g,d&&(i=!1,p&&!m&&void 0===n.end&&(n.end=n.start-a));else{if(n={start:g,end:void 0},i=!0,_){const e=u.getIntrinsicTicks(),i=p.getIntrinsicTicks(),s=c.getIntrinsicTicks(),o=this.lookupBeamDirection(t,e,s,i,h);[Re,Le].includes(o)?n.end=n.start-a:n.end=n.start+a}else m?d&&(n.end=n.start-a,i=!1):n.end=(o||0===h)&&p?n.start+a:n.start-a;s.push(n)}else i=!1;o=d}const h=s[s.length-1];return h&&void 0===h.end&&(h.end=h.start-a),s}drawStems(t){this.notes.forEach((e=>{const i=e.getStem();i&&(t.openGroup("stem",e.getAttribute("id")+"-stem"),i.setContext(t).draw(),t.closeGroup())}),this)}drawBeamLines(t){const e=["4","8","16","32","64"],i=this.notes[0];let s=this.getBeamYToDraw();const n=i.getStemX(),a=this.render_options.beam_width*this.stem_direction;for(let i=0;i<e.length;++i){const o=e[i],r=this.getBeamLines(o);for(let e=0;e<r.length;++e){const i=r[e],o=i.start,h=this.getSlopeY(o,n,s,this.slope),c=i.end;if(!c)throw new f("NoLastBeamX","lastBeamX undefined.");{const e=this.getSlopeY(c,n,s,this.slope);this.setAttribute("el",t.openGroup("beam")),t.beginPath(),t.moveTo(o,h),t.lineTo(o,h+a),t.lineTo(c+1,e+a),t.lineTo(c+1,e),t.closePath(),t.fill(),t.closeGroup()}}s+=1.5*a}}preFormat(){return this}postFormat(){this.postFormatted||(p(this.notes[0])||this.render_options.flat_beams?this.calculateFlatSlope():this.calculateSlope(),this.applyStemExtensions(),this.postFormatted=!0)}draw(){const t=this.checkContext();this.setRendered(),this.unbeamable||(this.postFormatted||this.postFormat(),this.drawStems(t),this.applyStyle(),this.drawBeamLines(t),this.restoreStyle())}}class We extends bt{constructor(t,e,i){super({duration:"b"}),this.type=t,this.clef_obj=new ue(t,e,i),this.clef=this.clef_obj.clef,this.glyph=new U(this.clef.code,this.clef.point),this.setWidth(this.glyph.getMetrics().width),this.ignore_ticks=!0}static get CATEGORY(){return m.ClefNote}setType(t,e,i){return this.type=t,this.clef_obj=new ue(t,e,i),this.clef=this.clef_obj.clef,this.glyph=new U(this.clef.code,this.clef.point),this.setWidth(this.glyph.getMetrics().width),this}getClef(){return this.clef}setContext(t){return super.setContext(t),this.glyph.setContext(this.getContext()),this}getBoundingBox(){return super.getBoundingBox()}addToModifierContext(t){return this}preFormat(){return this.preFormatted=!0,this}draw(){var t;const e=this.checkStave();this.glyph.getContext()||this.glyph.setContext(this.getContext()),this.setRendered();const i=this.getAbsoluteX();if(this.glyph.setStave(e),this.glyph.setYShift(e.getYForLine(null!==(t=this.clef.line)&&void 0!==t?t:0)-e.getYForGlyphs()),this.glyph.renderToStave(i),void 0!==this.clef_obj.annotation){const t=new U(this.clef_obj.annotation.code,this.clef_obj.annotation.point);t.getContext()||t.setContext(this.getContext()),t.setStave(e),t.setYShift(e.getYForLine(this.clef_obj.annotation.line)-e.getYForGlyphs()),t.setXShift(this.clef_obj.annotation.x_shift),t.renderToStave(i)}}}class Ge extends bt{constructor(t){super(t),this.options={extend_left:0,extend_right:0,y_shift:0},this.decrescendo=!1,this.line=t.line||0,this.height=15}static get CATEGORY(){return m.Crescendo}setLine(t){return this.line=t,this}setHeight(t){return this.height=t,this}setDecrescendo(t){return this.decrescendo=t,this}preFormat(){return this.preFormatted=!0,this}draw(){const t=this.checkContext(),e=this.checkStave();this.setRendered();const i=this.getTickContext(),s=Yt.getNextContext(i),n=this.getAbsoluteX(),a=s?s.getX():e.getX()+e.getWidth(),o=e.getYForLine(this.line+-3)+1;!function(...t){Ge.DEBUG&&S("Vex.Flow.Crescendo",t)}("Drawing ",this.decrescendo?"decrescendo ":"crescendo ",this.height,"x",n-a),function(t,e){const i=e.begin_x,s=e.end_x,n=e.y,a=e.height/2;t.beginPath(),e.reverse?(t.moveTo(i,n-a),t.lineTo(s,n),t.lineTo(i,n+a)):(t.moveTo(s,n-a),t.lineTo(i,n),t.lineTo(s,n+a)),t.stroke(),t.closePath()}(t,{begin_x:n-this.options.extend_left,end_x:a+this.options.extend_right,y:o+this.options.y_shift,height:this.height,reverse:this.decrescendo})}}var Ue;Ge.DEBUG=!1,function(t){t[t.NEAR_HEAD=1]="NEAR_HEAD",t[t.NEAR_TOP=2]="NEAR_TOP"}(Ue||(Ue={}));class He extends O{constructor(t,e,i){super(),this.render_options=Object.assign({thickness:2,x_shift:0,y_shift:10,position:Ue.NEAR_HEAD,position_end:Ue.NEAR_HEAD,invert:!1,cps:[{x:0,y:10},{x:0,y:10}]},i),this.from=t,this.to=e}static get CATEGORY(){return m.Curve}static get Position(){return Ue}static get PositionString(){return{nearHead:Ue.NEAR_HEAD,nearTop:Ue.NEAR_TOP}}setNotes(t,e){if(!t&&!e)throw new f("BadArguments","Curve needs to have either `from` or `to` set.");return this.from=t,this.to=e,this}isPartial(){return!this.from||!this.to}renderCurve(t){const e=this.checkContext(),i=this.render_options.x_shift,s=this.render_options.y_shift*t.direction,n=t.first_x+i,a=t.first_y+s,o=t.last_x-i,r=t.last_y+s,h=this.render_options.thickness,c=this.render_options.cps,{x:d,y:l}=c[0],{x:g,y:u}=c[1],p=(o-n)/(c.length+2);e.beginPath(),e.moveTo(n,a),e.bezierCurveTo(n+p+d,a+l*t.direction,o-p+g,r+u*t.direction,o,r),e.bezierCurveTo(o-p+g,r+(u+h)*t.direction,n+p+d,a+(l+h)*t.direction,n,a),e.stroke(),e.closePath(),e.fill()}draw(){this.checkContext(),this.setRendered();const t=this.from,e=this.to;let i,s,n,a,o=0,r="baseY",h="baseY";function c(t){return"string"==typeof t?He.PositionString[t]:t}const d=c(this.render_options.position),l=c(this.render_options.position_end);if(d===Ue.NEAR_TOP&&(r="topY",h="topY"),l===Ue.NEAR_HEAD?h="baseY":l===Ue.NEAR_TOP&&(h="topY"),t)i=t.getTieRightX(),o=t.getStemDirection(),n=t.getStemExtents()[r];else{i=e.checkStave().getTieStartX(),n=e.getStemExtents()[r]}if(e)s=e.getTieLeftX(),o=e.getStemDirection(),a=e.getStemExtents()[h];else{s=t.checkStave().getTieEndX(),a=t.getStemExtents()[h]}return this.renderCurve({first_x:i,last_x:s,first_y:n,last_y:a,direction:o*(!0===this.render_options.invert?-1:1)}),!0}}function Ye(...t){Xe.DEBUG&&S("Vex.Flow.Parser",t)}function je(t){if("matchedString"in t)return t.matchedString;if("results"in t)return je(t.results);const e=t;return 1===e.length?je(e[0]):0===e.length?null:e.map(je)}class Xe{constructor(t){this.grammar=t,this.line="",this.pos=0,this.errorPos=-1}parse(t){this.line=t,this.pos=0,this.errorPos=-1;const e=this.expect(this.grammar.begin());return e.errorPos=this.errorPos,e}matchFail(t){-1===this.errorPos&&(this.errorPos=this.pos),this.pos=t}matchSuccess(){this.errorPos=-1}matchToken(t,e=!1){const i=e?new RegExp("^(("+t+"))"):new RegExp("^(("+t+")\\s*)"),s=this.line.slice(this.pos).match(i);return null!==s?{success:!0,matchedString:s[2],incrementPos:s[1].length,pos:this.pos}:{success:!1,pos:this.pos}}expectOne(t,e=!1){const i=[],s=this.pos;let n=!0,a=!1;if(e=!0===e||!0===t.maybe,t.expect)for(const e of t.expect){const s=this.pos,o=this.expect(e);if(o.success){if(i.push(o),a=!0,t.or)break}else if(n=!1,!t.or){this.pos=s;break}}const o=t.or&&a||n,r=o||!0===e,h=o?1:0;return e&&!o&&(this.pos=s),r?this.matchSuccess():this.matchFail(s),{success:r,results:i,numMatches:h}}expectOneOrMore(t,e=!1){const i=[],s=this.pos;let n=0,a=!0;do{const e=this.expectOne(t);e.success&&e.results?(n++,i.push(e.results)):a=!1}while(a);const o=n>0||!0===e;return!e||n>0||(this.pos=s),o?this.matchSuccess():this.matchFail(s),{success:o,results:i,numMatches:n}}expectZeroOrMore(t){return this.expectOneOrMore(t,!0)}expect(t){if(Ye("Evaluating rule function:",t),!t)throw new f("Invalid rule function");let e;const i=t.bind(this.grammar)();if(i.token)e=this.matchToken(i.token,!0===i.noSpace),e.success&&(this.pos+=e.incrementPos);else{if(!i.expect)throw Ye(i),new f("Bad grammar! No `token` or `expect` property "+i);e=i.oneOrMore?this.expectOneOrMore(i):i.zeroOrMore?this.expectZeroOrMore(i):this.expectOne(i)}const s=[];return e.matches=s,e.results&&e.results.forEach((t=>s.push(je(t)))),i.run&&e.success&&i.run({matches:s}),e}}function Ve(...t){Ze.DEBUG&&S("Vex.Flow.EasyScore",t)}Xe.DEBUG=!1;class ze{constructor(t){this.builder=t}begin(){return this.LINE}LINE(){return{expect:[this.PIECE,this.PIECES,this.EOL]}}PIECE(){return{expect:[this.CHORDORNOTE,this.PARAMS],run:()=>this.builder.commitPiece()}}PIECES(){return{expect:[this.COMMA,this.PIECE],zeroOrMore:!0}}PARAMS(){return{expect:[this.DURATION,this.TYPE,this.DOTS,this.OPTS]}}CHORDORNOTE(){return{expect:[this.CHORD,this.SINGLENOTE],or:!0}}CHORD(){return{expect:[this.LPAREN,this.NOTES,this.RPAREN],run:t=>this.builder.addChord(t.matches[1])}}NOTES(){return{expect:[this.NOTE],oneOrMore:!0}}NOTE(){return{expect:[this.NOTENAME,this.ACCIDENTAL,this.OCTAVE]}}SINGLENOTE(){return{expect:[this.NOTENAME,this.ACCIDENTAL,this.OCTAVE],run:t=>{const e=t;this.builder.addSingleNote(e.matches[0],e.matches[1],e.matches[2])}}}ACCIDENTAL(){return{expect:[this.MICROTONES,this.ACCIDENTALS],maybe:!0,or:!0}}DOTS(){return{expect:[this.DOT],zeroOrMore:!0,run:t=>this.builder.setNoteDots(t.matches)}}TYPE(){return{expect:[this.SLASH,this.MAYBESLASH,this.TYPES],maybe:!0,run:t=>this.builder.setNoteType(t.matches[2])}}DURATION(){return{expect:[this.SLASH,this.DURATIONS],maybe:!0,run:t=>this.builder.setNoteDuration(t.matches[1])}}OPTS(){return{expect:[this.LBRACKET,this.KEYVAL,this.KEYVALS,this.RBRACKET],maybe:!0}}KEYVALS(){return{expect:[this.COMMA,this.KEYVAL],zeroOrMore:!0}}KEYVAL(){return{expect:[this.KEY,this.EQUALS,this.VAL],run:t=>this.builder.addNoteOption(t.matches[0],t.matches[2].slice(1,-1))}}VAL(){return{expect:[this.SVAL,this.DVAL],or:!0}}KEY(){return{token:"[a-zA-Z][a-zA-Z0-9]*"}}DVAL(){return{token:'["][^"]*["]'}}SVAL(){return{token:"['][^']*[']"}}NOTENAME(){return{token:"[a-gA-G]"}}OCTAVE(){return{token:"[0-9]+"}}ACCIDENTALS(){return{token:"bb|b|##|#|n"}}MICROTONES(){return{token:"bbs|bss|bs|db|d|\\+\\+-|\\+-|\\+\\+|\\+|k|o"}}DURATIONS(){return{token:"[0-9whq]+"}}TYPES(){return{token:"[rRsSmMhHgG]"}}LPAREN(){return{token:"[(]"}}RPAREN(){return{token:"[)]"}}COMMA(){return{token:"[,]"}}DOT(){return{token:"[.]"}}SLASH(){return{token:"[/]"}}MAYBESLASH(){return{token:"[/]?"}}EQUALS(){return{token:"[=]"}}LBRACKET(){return{token:"\\["}}RBRACKET(){return{token:"\\]"}}EOL(){return{token:"$"}}}class Ke{constructor(t){this.chord=[],this.dots=0,this.options={},this.duration=t}}class $e{constructor(t){this.commitHooks=[],this.factory=t,this.reset()}reset(t){this.options=Object.assign({stem:"auto",clef:"treble"},t),this.elements={notes:[],accidentals:[]},this.rollingDuration="8",this.resetPiece()}getFactory(){return this.factory}getElements(){return this.elements}addCommitHook(t){this.commitHooks.push(t)}resetPiece(){Ve("resetPiece"),this.piece=new Ke(this.rollingDuration)}setNoteDots(t){Ve("setNoteDots:",t),t&&(this.piece.dots=t.length)}setNoteDuration(t){Ve("setNoteDuration:",t),this.rollingDuration=this.piece.duration=t||this.rollingDuration}setNoteType(t){Ve("setNoteType:",t),t&&(this.piece.type=t)}addNoteOption(t,e){Ve("addNoteOption: key:",t,"value:",e),this.piece.options[t]=e}addNote(t,e,i){Ve("addNote:",t,e,i),this.piece.chord.push({key:t,accid:e,octave:i})}addSingleNote(t,e,i){Ve("addSingleNote:",t,e,i),this.addNote(t,e,i)}addChord(t){Ve("startChord"),"object"!=typeof t[0]?this.addSingleNote(t[0]):t.forEach((t=>{t&&this.addNote(...t)})),Ve("endChord")}commitPiece(){Ve("commitPiece");const{factory:t}=this;if(!t)return;const e=Object.assign(Object.assign({},this.options),this.piece.options),i=x(e.stem,"BadArguments","options.stem is not defined").toLowerCase(),s=x(e.clef,"BadArguments","options.clef is not defined").toLowerCase(),{chord:n,duration:a,dots:o,type:r}=this.piece,h=Y.accidentals,c=n.map((t=>{var e;return t.key+(h.includes(null!==(e=t.accid)&&void 0!==e?e:"")?t.accid:"")+"/"+t.octave})),d="auto"===i,l="g"==(null==r?void 0:r.toLowerCase())?t.GhostNote({duration:a,dots:o}):t.StaveNote({keys:c,duration:a,dots:o,type:r,clef:s,auto_stem:d});d||l.setStemDirection("up"===i?nt.UP:nt.DOWN);const g=[];n.forEach(((e,i)=>{const s=e.accid;if("string"==typeof s){const e=t.Accidental({type:s});l.addModifier(e,i),g.push(e)}else g.push(void 0)}));for(let t=0;t<o;t++)Ot.buildAndAttach([l],{all:!0});this.commitHooks.forEach((t=>t(e,l,this))),this.elements.notes.push(l),this.elements.accidentals.push(g),this.resetPiece()}}function Je(t,e){void 0!==t.id&&e.setAttribute("id",t.id)}const qe=/\s*,\s*/;function Qe(t,e){void 0!==t.class&&t.class.split(qe).forEach((t=>e.addClass(t)))}class Ze{constructor(t={}){this.defaults={clef:"treble",time:"4/4",stem:"auto"},this.setOptions(t)}set(t){return this.defaults=Object.assign(Object.assign({},this.defaults),t),this}setOptions(t){var e,i;const s=t.factory,n=null!==(e=t.builder)&&void 0!==e?e:new $e(s);return this.options=Object.assign(Object.assign({commitHooks:[Je,Qe,xt.easyScoreHook,Lt.easyScoreHook],throwOnError:!1},t),{factory:s,builder:n}),this.factory=s,this.builder=n,this.grammar=new ze(this.builder),this.parser=new Xe(this.grammar),null===(i=this.options.commitHooks)||void 0===i||i.forEach((t=>this.addCommitHook(t))),this}setContext(t){return this.factory.setContext(t),this}parse(t,e={}){this.builder.reset(e);const i=this.parser.parse(t);if(!i.success&&this.options.throwOnError)throw Ve(i),new f("Error parsing line: "+t);return i}beam(t,e){return this.factory.Beam({notes:t,options:e}),t}tuplet(t,e){return this.factory.Tuplet({notes:t,options:e}),t}notes(t,e={}){return e=Object.assign({clef:this.defaults.clef,stem:this.defaults.stem},e),this.parse(t,e),this.builder.getElements().notes}voice(t,e={}){return e=Object.assign({time:this.defaults.time},e),this.factory.Voice(e).addTickables(t)}addCommitHook(t){this.builder.addCommitHook(t)}}Ze.DEBUG=!1;const ti="Ghost note must have valid initialization data to identify duration.";class ei extends zt{static get CATEGORY(){return m.GhostNote}constructor(t){if(!t)throw new f("BadArguments",ti);let e;if("string"==typeof t)e={duration:t};else{if("object"!=typeof t)throw new f("BadArguments",ti);e=t}super(e),this.setWidth(0)}isRest(){return!0}setStave(t){return super.setStave(t),this}addToModifierContext(t){return this}preFormat(){return this.preFormatted=!0,this}draw(){this.setRendered();for(let t=0;t<this.modifiers.length;++t){const e=this.modifiers[t];a(e)&&(e.setContext(this.getContext()),e.drawWithStyle())}}}class ii extends bt{constructor(t,e,i){super(e),this.options=Object.assign({ignoreTicks:!1,line:2},i),this.ignore_ticks=this.options.ignoreTicks,t&&this.setGlyph(t)}static get CATEGORY(){return m.GlyphNote}setGlyph(t){return this.glyph=t,this.setWidth(this.glyph.getMetrics().width),this}getBoundingBox(){return this.glyph.getBoundingBox()}preFormat(){return!this.preFormatted&&this.modifierContext&&this.modifierContext.preFormat(),this.preFormatted=!0,this}drawModifiers(){const t=this.checkContext();t.openGroup("modifiers");for(let e=0;e<this.modifiers.length;e++){const i=this.modifiers[e];i.setContext(t),i.drawWithStyle()}t.closeGroup()}draw(){const t=this.checkStave(),e=t.checkContext();this.setRendered(),e.openGroup("glyphNote",this.getAttribute("id"));const i=this.glyph;i.getContext()||i.setContext(e),i.setStave(t),i.setYShift(t.getYForLine(this.options.line)-t.getYForGlyphs());const s=this.isCenterAligned()?this.getAbsoluteX()-this.getWidth()/2:this.getAbsoluteX();i.renderToStave(s),this.drawModifiers(),e.closeGroup()}}class si extends $t{constructor(t){super(Object.assign({glyph_font_scale:tt.NOTATION_FONT_SCALE*si.SCALE,stroke_px:si.LEDGER_LINE_OFFSET},t)),this.slash=t.slash||!1,this.slur=!0,this.buildNoteHeads(),this.width=3}static get CATEGORY(){return m.GraceNote}static get LEDGER_LINE_OFFSET(){return 2}static get SCALE(){return.66}getStemExtension(){if(this.stem_extension_override)return this.stem_extension_override;const t=this.getGlyph();if(t){let e=super.getStemExtension();if(t.stem){const t=this.getStaveNoteScale();e=(nt.HEIGHT+e)*t-nt.HEIGHT}return e}return 0}getStaveNoteScale(){return this.render_options.glyph_font_scale/tt.NOTATION_FONT_SCALE}draw(){super.draw(),this.setRendered();const t=this.stem;if(this.slash&&t){const e=this.getStaveNoteScale(),i=e/.66;let s;const n=this.beam;if(n)n.postFormatted||n.postFormat(),s=this.calcBeamedNotesSlashBBox(8*i,8*i,{stem:6*i,beam:5*i});else{const n=this.getStemDirection(),a=this.getNoteHeadBounds(),o=t.getHeight();let r=this.getAbsoluteX(),h=n===nt.DOWN?a.y_top-o:a.y_bottom-o;const c=n===nt.DOWN?this.glyph.stem_down_extension:this.glyph.stem_up_extension;let d=tt.STEM_HEIGHT;d-=d/2.8,d+=c,h+=d*e*n;const l=n===nt.UP?{x1:1,y1:0,x2:13,y2:-9}:{x1:-4,y1:1,x2:13,y2:9};r+=l.x1*i,h+=l.y1*i,s={x1:r,y1:h,x2:r+l.x2*i,y2:h+l.y2*i}}const a=this.checkContext();a.save(),a.setLineWidth(1*i),a.beginPath(),a.moveTo(s.x1,s.y1),a.lineTo(s.x2,s.y2),a.closePath(),a.stroke(),a.restore()}}calcBeamedNotesSlashBBox(t,e,i){const s=this.beam;if(!s)throw new f("NoBeam","Can't calculate without a beam.");const n=s.slope,a=s.notes[s.notes.length-1]===this?-1:1,o=Math.atan(n*a),r=Math.cos(o)*e,h=Math.sin(o)*e;t*=this.getStemDirection();const c=Math.atan((h-t)/r),d=Math.cos(c)*i.stem*a,l=Math.sin(c)*i.stem,g=Math.cos(c)*i.beam*a,u=Math.sin(c)*i.beam,p=this.getStemX(),m=s.notes[0].getStemX(),_=s.getBeamYToDraw()+(p-m)*n;return{x1:p-d,y1:_+t-l,x2:p+r*a+g,y2:_+h+u}}}class ni extends bt{constructor(t,e,i){super({duration:"b"}),this.keySignature=new pe(t,e,i),this.ignore_ticks=!0}static get CATEGORY(){return m.KeySigNote}addToModifierContext(t){return this}preFormat(){return this.preFormatted=!0,this.keySignature.setStave(this.checkStave()),this.setWidth(this.keySignature.getWidth()),this}draw(){const t=this.checkStave().checkContext();this.setRendered(),this.keySignature.setX(this.getAbsoluteX()),this.keySignature.setContext(t),this.keySignature.draw()}}let ai;class oi extends O{constructor(t,e){super(),this.xs={left:NaN,right:NaN},this.hasPaddingLeft=!1,this.hasPaddingRight=!1,this.hasLineThickness=!1,this.hasSymbolSpacing=!1,this.number_of_measures=t,this.hasPaddingLeft="number"==typeof e.padding_left,this.hasPaddingRight="number"==typeof e.padding_right,this.hasLineThickness="number"==typeof e.line_thickness,this.hasSymbolSpacing="number"==typeof e.symbol_spacing;const i=tt.currentMusicFont();this.render_options=Object.assign({use_symbols:!1,show_number:!0,number_line:-.5,number_glyph_point:i.lookupMetric("digits.point"),line:2,spacing_between_lines_px:tt.STAVE_LINE_DISTANCE,serif_thickness:2,semibreve_rest_glyph_scale:tt.NOTATION_FONT_SCALE,padding_left:0,padding_right:0,line_thickness:5,symbol_spacing:0},e);const s=i.lookupMetric("digits.shiftLine",0);this.render_options.number_line+=s}static get CATEGORY(){return m.MultiMeasureRest}getXs(){return this.xs}setStave(t){return this.stave=t,this}getStave(){return this.stave}checkStave(){return x(this.stave,"NoStave","No stave attached to instance.")}drawLine(t,e,i,s,n){const a=this.render_options,o=t.getYForLine(a.line),r=.1*(s-i);let h;i+=r,s-=r,h=this.hasLineThickness?.5*a.line_thickness:.25*n;const c=a.serif_thickness,d=o-n,l=o+n,g=i+c,u=s-c,p=o-h,m=o+h;e.save(),e.beginPath(),e.moveTo(i,d),e.lineTo(g,d),e.lineTo(g,p),e.lineTo(u,p),e.lineTo(u,d),e.lineTo(s,d),e.lineTo(s,l),e.lineTo(u,l),e.lineTo(u,m),e.lineTo(g,m),e.lineTo(g,l),e.lineTo(i,l),e.closePath(),e.fill()}drawSymbols(t,e,i,s,n){const a=Math.floor(this.number_of_measures/4),o=this.number_of_measures%4,r=Math.floor(o/2),h=o%2,c=this.render_options;ai=void 0;const d=function(){if(!ai){const t=new Vt({duration:"w",note_type:"r"});ai={glyph_font_scale:t.render_options.glyph_font_scale,glyph_code:t.glyph_code,width:t.getWidth()}}return ai}(),l=c.semibreve_rest_glyph_scale,g=d.width*(l/d.glyph_font_scale),u={2:{width:.5*g,height:n},1:{width:g}},p=this.hasSymbolSpacing?c.symbol_spacing:10;let m=i+.5*(s-i)-.5*(a*u[2].width+r*u[2].width+h*u[1].width+(a+r+h-1)*p);const f=c.line,_=t.getYForLine(f-1),x=t.getYForLine(f),S=t.getYForLine(f+1);e.save(),e.setStrokeStyle("none"),e.setLineWidth(0);for(let t=0;t<a;++t)e.fillRect(m,x-u[2].height,u[2].width,u[2].height),e.fillRect(m,S-u[2].height,u[2].width,u[2].height),m+=u[2].width+p;for(let t=0;t<r;++t)e.fillRect(m,x-u[2].height,u[2].width,u[2].height),m+=u[2].width+p;for(let t=0;t<h;++t)U.renderGlyph(e,m,_,l,d.glyph_code),m+=u[1].width+p;e.restore()}draw(){const t=this.checkContext();this.setRendered();const e=this.checkStave();let i=e.getNoteStartX(),s=e.getNoteEndX();const n=e.getModifiers(wt.BEGIN);1===n.length&&o(n[0])&&(i-=n[0].getWidth());const a=this.render_options;this.hasPaddingLeft&&(i=e.getX()+a.padding_left),this.hasPaddingRight&&(s=e.getX()+e.getWidth()-a.padding_right),this.xs.left=i,this.xs.right=s;const r=a.spacing_between_lines_px;if(a.use_symbols?this.drawSymbols(e,t,i,s,r):this.drawLine(e,t,i,s,r),a.show_number){const n="/"+this.number_of_measures,o=new be(n,0,!1);o.point=a.number_glyph_point,o.setTimeSig(n),o.setStave(e),o.setX(i+.5*(s-i)-.5*o.getInfo().glyph.getMetrics().width),o.bottomLine=a.number_line,o.setContext(t).draw()}}}function ri(t,e,i,s,n){const a=hi.GLYPHS[t];new U(a.code,n,{category:"pedalMarking"}).render(e,i+a.x_shift,s+a.y_shift)}class hi extends O{constructor(t){super(),this.notes=t,this.type=hi.type.TEXT,this.line=0,this.custom_depress_text="",this.custom_release_text="",this.resetFont(),this.render_options={bracket_height:10,text_margin_right:6,bracket_line_width:1,color:"black"}}static get CATEGORY(){return m.PedalMarking}static createSustain(t){return new hi(t)}static createSostenuto(t){const e=new hi(t);return e.setType(hi.type.MIXED),e.setCustomText("Sost. Ped."),e}static createUnaCorda(t){const e=new hi(t);return e.setType(hi.type.TEXT),e.setCustomText("una corda","tre corda"),e}setType(t){return(t="string"==typeof t?hi.typeString[t]:t)>=hi.type.TEXT&&t<=hi.type.MIXED&&(this.type=t),this}setCustomText(t,e){return this.custom_depress_text=t||"",this.custom_release_text=e||"",this}setLine(t){return this.line=t,this}drawBracketed(){const t=this.checkContext();let e,i,s=!1;this.notes.forEach(((n,a,o)=>{s=!s;const r=n.getAbsoluteX(),h=n.checkStave().getYForBottomText(this.line+3);if(r<e)throw new f("InvalidConfiguration","The notes provided must be in order of ascending x positions");const c=o[a+1]===n,d=o[a-1]===n;let l=0;const g=tt.currentMusicFont().lookupMetric(`pedalMarking.${s?"down":"up"}.point`);if(s)if(l=d?5:0,this.type!==hi.type.MIXED||d)t.beginPath(),t.moveTo(r,h-this.render_options.bracket_height),t.lineTo(r+l,h),t.stroke(),t.closePath();else if(this.custom_depress_text){const e=t.measureText(this.custom_depress_text).width;t.fillText(this.custom_depress_text,r-e/2,h),l=e/2+this.render_options.text_margin_right}else ri("pedal_depress",t,r,h,g),l=20+this.render_options.text_margin_right;else l=c?-5:0,t.beginPath(),t.moveTo(e,i),t.lineTo(r+l,h),t.lineTo(r,h-this.render_options.bracket_height),t.stroke(),t.closePath();e=r+l,i=h}))}drawText(){const t=this.checkContext();let e=!1;this.notes.forEach((i=>{e=!e;const s=i.checkStave(),n=i.getAbsoluteX(),a=s.getYForBottomText(this.line+3),o=tt.currentMusicFont().lookupMetric(`pedalMarking.${e?"down":"up"}.point`);let r=0;e?this.custom_depress_text?(r=t.measureText(this.custom_depress_text).width,t.fillText(this.custom_depress_text,n-r/2,a)):ri("pedal_depress",t,n,a,o):this.custom_release_text?(r=t.measureText(this.custom_release_text).width,t.fillText(this.custom_release_text,n-r/2,a)):ri("pedal_release",t,n,a,o)}))}draw(){const t=this.checkContext();this.setRendered(),t.save(),t.setStrokeStyle(this.render_options.color),t.setFillStyle(this.render_options.color),t.setFont(this.textFont),function(...t){hi.DEBUG&&S("Vex.Flow.PedalMarking",t)}("Rendering Pedal Marking"),this.type===hi.type.BRACKET||this.type===hi.type.MIXED?(t.setLineWidth(this.render_options.bracket_line_width),this.drawBracketed()):this.type===hi.type.TEXT&&this.drawText(),t.restore()}}hi.DEBUG=!1,hi.TEXT_FONT={family:M.SERIF,size:12,weight:k.BOLD,style:D.ITALIC},hi.GLYPHS={pedal_depress:{code:"keyboardPedalPed",x_shift:-10,y_shift:0},pedal_release:{code:"keyboardPedalUp",x_shift:-2,y_shift:3}},hi.type={TEXT:1,BRACKET:2,MIXED:3},hi.typeString={text:hi.type.TEXT,bracket:hi.type.BRACKET,mixed:hi.type.MIXED};const ci={1:"repeat1Bar",2:"repeat2Bars",4:"repeat4Bars",slash:"repeatBarSlash"};class di extends ii{static get CATEGORY(){return m.RepeatNote}constructor(t,e,i){super(void 0,Object.assign({duration:"q",align_center:"slash"!==t},e),i);const s=new U(ci[t]||"repeat1Bar",tt.currentMusicFont().lookupMetric("repeatNote.point",40),{category:"repeatNote"});this.setGlyph(s)}}function li(t,e,i,s,n,a,o){t.beginPath(),t.moveTo(e,i),t.lineTo(s,n),t.lineTo(a,o),t.lineTo(e,i),t.closePath(),t.fill()}class gi extends O{constructor(t){super(),this.setNotes(t),this.text="",this.resetFont(),this.render_options={padding_left:4,padding_right:3,line_width:1,line_dash:void 0,rounded_end:!0,color:void 0,draw_start_arrow:!1,draw_end_arrow:!1,arrowhead_length:10,arrowhead_angle:Math.PI/8,text_position_vertical:gi.TextVerticalPosition.TOP,text_justification:gi.TextJustification.CENTER}}static get CATEGORY(){return m.StaveLine}setText(t){return this.text=t,this}setNotes(t){if(!t.first_note&&!t.last_note)throw new f("BadArguments","Notes needs to have either first_note or last_note set.");if(t.first_indices||(t.first_indices=[0]),t.last_indices||(t.last_indices=[0]),t.first_indices.length!==t.last_indices.length)throw new f("BadArguments","Connected notes must have same number of indices.");return this.notes=t,this.first_note=t.first_note,this.first_indices=t.first_indices,this.last_note=t.last_note,this.last_indices=t.last_indices,this}applyLineStyle(){const t=this.checkContext(),e=this.render_options;e.line_dash&&t.setLineDash(e.line_dash),e.line_width&&t.setLineWidth(e.line_width),e.rounded_end?t.setLineCap("round"):t.setLineCap("square")}applyFontStyle(){const t=this.checkContext();t.setFont(this.textFont);const e=this.render_options.color;e&&(t.setStrokeStyle(e),t.setFillStyle(e))}drawArrowLine(t,e,i){const s=this.render_options.draw_start_arrow&&this.render_options.draw_end_arrow,n=e.x,a=e.y,o=i.x,r=i.y,h=Math.sqrt((o-n)*(o-n)+(r-a)*(r-a)),c=(h-this.render_options.arrowhead_length/3)/h;let d,l,g,u;this.render_options.draw_end_arrow||s?(d=Math.round(n+(o-n)*c),l=Math.round(a+(r-a)*c)):(d=o,l=r),this.render_options.draw_start_arrow||s?(g=n+(o-n)*(1-c),u=a+(r-a)*(1-c)):(g=n,u=a),this.render_options.color&&(t.setStrokeStyle(this.render_options.color),t.setFillStyle(this.render_options.color)),t.beginPath(),t.moveTo(g,u),t.lineTo(d,l),t.stroke(),t.closePath();const p=Math.atan2(r-a,o-n),m=Math.abs(this.render_options.arrowhead_length/Math.cos(this.render_options.arrowhead_angle));let f,_,x,S,y,T;(this.render_options.draw_end_arrow||s)&&(f=p+Math.PI+this.render_options.arrowhead_angle,x=o+Math.cos(f)*m,S=r+Math.sin(f)*m,_=p+Math.PI-this.render_options.arrowhead_angle,y=o+Math.cos(_)*m,T=r+Math.sin(_)*m,li(t,x,S,o,r,y,T)),(this.render_options.draw_start_arrow||s)&&(f=p+this.render_options.arrowhead_angle,x=n+Math.cos(f)*m,S=a+Math.sin(f)*m,_=p-this.render_options.arrowhead_angle,y=n+Math.cos(_)*m,T=a+Math.sin(_)*m,li(t,x,S,n,a,y,T))}draw(){const t=this.checkContext();this.setRendered();const e=this.first_note,i=this.last_note,s=this.render_options;t.save(),this.applyLineStyle();let n={x:0,y:0},a={x:0,y:0};this.first_indices.forEach(((o,r)=>{const h=this.last_indices[r];n=e.getModifierStartXY(2,o),a=i.getModifierStartXY(1,h);const c=n.y>a.y;n.x+=e.getMetrics().modRightPx+s.padding_left,a.x-=i.getMetrics().modLeftPx+s.padding_right;const d=e.getGlyph().getWidth();e.getKeyProps()[o].displaced&&1===e.getStemDirection()&&(n.x+=d+s.padding_left);i.getKeyProps()[h].displaced&&-1===i.getStemDirection()&&(a.x-=d+s.padding_right),n.y+=c?-3:1,a.y+=c?2:0,this.drawArrowLine(t,n,a)})),t.restore();const o=t.measureText(this.text).width,r=s.text_justification;let h=0;if(r===gi.TextJustification.LEFT)h=n.x;else if(r===gi.TextJustification.CENTER){h=(a.x-n.x)/2+n.x-o/2}else r===gi.TextJustification.RIGHT&&(h=a.x-o);let c=0;const d=s.text_position_vertical;return d===gi.TextVerticalPosition.TOP?c=e.checkStave().getYForTopText():d===gi.TextVerticalPosition.BOTTOM&&(c=e.checkStave().getYForBottomText(tt.TEXT_HEIGHT_OFFSET_HACK)),t.save(),this.applyFontStyle(),t.fillText(this.text,h,c),t.restore(),this}}gi.TEXT_FONT=Object.assign({},O.TEXT_FONT),gi.TextVerticalPosition={TOP:1,BOTTOM:2},gi.TextJustification=ae;class ui extends O{constructor(t={}){super(),this.setOptions(t),this.parts=[]}static get CATEGORY(){return m.System}setOptions(t={}){if(!t.factory)throw new f("NoFactory","System.setOptions(options) requires a factory.");this.factory=t.factory,this.options=Object.assign(Object.assign({factory:this.factory,x:10,y:10,width:500,spaceBetweenStaves:12,autoWidth:!1,noJustification:!1,debugFormatter:!1,formatIterations:0,noPadding:!1},t),{details:Object.assign({alpha:.5},t.details),formatOptions:Object.assign({},t.formatOptions)}),!1===this.options.noJustification&&void 0===t.width&&(this.options.autoWidth=!0)}setContext(t){return super.setContext(t),this.factory.setContext(t),this}addConnector(t="double"){return this.connector=this.factory.StaveConnector({top_stave:this.parts[0].stave,bottom_stave:this.parts[this.parts.length-1].stave,type:t}),this.connector}addStave(t){var e;const i=Object.assign({left_bar:!1},t.options),s=null!==(e=t.stave)&&void 0!==e?e:this.factory.Stave({x:this.options.x,y:this.options.y,width:this.options.width,options:i}),n=Object.assign(Object.assign({stave:s,spaceAbove:0,spaceBelow:0,debugNoteMetrics:!1,noJustification:!1},t),{options:i}),a=this.getContext();return n.voices.forEach((t=>t.setContext(a).setStave(s).getTickables().forEach((t=>t.setStave(s))))),this.parts.push(n),s}format(){const t=this.options.details;let e=0;const i=new Pe(t);this.formatter=i;let s=this.options.y,n=0,a=[];const o=[];this.parts.forEach((t=>{s+=t.stave.space(t.spaceAbove),t.stave.setY(s),i.joinVoices(t.voices),s+=t.stave.space(t.spaceBelow),s+=t.stave.space(this.options.spaceBetweenStaves),t.debugNoteMetrics&&(o.push({y:s,voice:t.voices[0]}),s+=15),a=a.concat(t.voices),n=Math.max(n,t.stave.getNoteStartX())})),this.parts.forEach((t=>t.stave.setNoteStartX(n))),this.options.autoWidth?(e=i.preCalculateMinTotalWidth(a),this.parts.forEach((t=>{t.stave.setWidth(e+Ee.rightPadding+(n-this.options.x))}))):e=this.options.noPadding?this.options.width-this.options.x:this.options.width-(n-this.options.x)-Ee.defaultPadding,i.format(a,this.options.noJustification?0:e,this.options.formatOptions);for(let e=0;e<this.options.formatIterations;e++)i.tune(t);this.startX=n,this.debugNoteMetricsYs=o,this.lastY=s,this.boundingBox=new C(this.options.x,this.options.y,this.options.width,this.lastY-this.options.y)}draw(){const t=this.checkContext();if(!(this.formatter&&this.startX&&this.lastY&&this.debugNoteMetricsYs))throw new f("NoFormatter","format() must be called before draw()");this.setRendered(),this.options.debugFormatter&&Pe.plotDebugging(t,this.formatter,this.startX,this.options.y,this.lastY),this.debugNoteMetricsYs.forEach((e=>{e.voice.getTickables().forEach((i=>bt.plotMetrics(t,i,e.y)))}))}}class pi extends zt{constructor(t,e=!1){super(t),this.glyphs=[],this.greatestString=()=>this.positions.map((t=>t.str)).reduce(((t,e)=>t>e?t:e)),this.leastString=()=>this.positions.map((t=>t.str)).reduce(((t,e)=>t<e?t:e)),this.ghost=!1,this.positions=t.positions||[],this.render_options=Object.assign(Object.assign({},this.render_options),{glyph_font_scale:tt.TABLATURE_FONT_SCALE,draw_stem:e,draw_dots:e,draw_stem_through_stave:!1,y_shift:0,scale:1,font:`${M.SIZE}pt ${M.SANS_SERIF}`}),this.glyph=tt.getGlyphProps(this.duration,this.noteType),x(this.glyph,"BadArguments",`No glyph found for duration '${this.duration}' and type '${this.noteType}'`),this.buildStem(),t.stem_direction?this.setStemDirection(t.stem_direction):this.setStemDirection(nt.UP),this.ghost=!1,this.updateWidth()}static get CATEGORY(){return m.TabNote}reset(){return super.reset(),this.stave&&this.setStave(this.stave),this}setGhost(t){return this.ghost=t,this.updateWidth(),this}hasStem(){return!!this.render_options.draw_stem}getStemExtension(){const t=this.getGlyph();return null!=this.stem_extension_override?this.stem_extension_override:t?this.getStemDirection()===nt.UP?t.tabnote_stem_up_extension:t.tabnote_stem_down_extension:0}updateWidth(){this.glyphs=[],this.width=0;for(let t=0;t<this.positions.length;++t){let e=this.positions[t].fret;this.ghost&&(e="("+e+")");const i=tt.tabToGlyph(e.toString(),this.render_options.scale);this.glyphs.push(i),this.width=Math.max(i.getWidth(),this.width)}this.glyph.getWidth=()=>this.width}setStave(t){super.setStave(t);const e=t.getContext();if(this.setContext(e),e){this.width=0;for(let t=0;t<this.glyphs.length;++t){const i=this.glyphs[t],s=""+i.text;"X"!==s.toUpperCase()&&(e.save(),e.setFont(this.render_options.font),i.width=e.measureText(s).width,e.restore(),i.getWidth=()=>i.width),this.width=Math.max(i.getWidth(),this.width)}this.glyph.getWidth=()=>this.width}const i=this.positions.map((({str:e})=>t.getYForLine(Number(e)-1)));return this.setYs(i),this.stem&&this.stem.setYBounds(this.getStemY(),this.getStemY()),this}getPositions(){return this.positions}getModifierStartXY(t,e){if(!this.preFormatted)throw new f("UnformattedNote","Can't call GetModifierStartXY on an unformatted note");if(0===this.ys.length)throw new f("NoYValues","No Y-Values calculated for this note.");let i=0;if(t===H.Position.LEFT)i=-2;else if(t===H.Position.RIGHT)i=this.width+2;else if(t===H.Position.BELOW||t===H.Position.ABOVE){i=this.glyph.getWidth()/2}return{x:this.getAbsoluteX()+i,y:this.ys[e]}}getLineForRest(){return Number(this.positions[0].str)}preFormat(){this.preFormatted||(this.modifierContext&&this.modifierContext.preFormat(),this.preFormatted=!0)}getStemX(){return this.getCenterGlyphX()}getStemY(){const t=this.checkStave().getNumLines()-.5,e=nt.UP===this.stem_direction?-.5:t;return this.checkStave().getYForLine(e)}getStemExtents(){return this.checkStem().getExtents()}drawFlag(){var t;const{beam:e,glyph:i,render_options:{draw_stem:s}}=this,n=this.checkContext(),a=null==e&&s;if(i.flag&&a){const e=this.getStemX(),i=this.getStemDirection()===nt.DOWN?this.getStemY()-this.checkStem().getHeight()-(this.glyph?this.glyph.stem_down_extension:0):this.getStemY()-this.checkStem().getHeight()+(this.glyph?this.glyph.stem_up_extension:0);null===(t=this.flag)||void 0===t||t.render(n,e,i)}}drawModifiers(){this.modifiers.forEach((t=>{r(t)&&!this.render_options.draw_dots||(t.setContext(this.getContext()),t.drawWithStyle())}))}drawStemThrough(){const t=this.getStemX(),e=this.getStemY(),i=this.checkContext(),s=this.render_options.draw_stem,n=this.render_options.draw_stem_through_stave;if(s&&n){const s=function(t,e,i,s){const n=1!==s,a=-1!==s,o=i.getSpacingBetweenLines(),r=i.getNumLines(),h=[];return e.forEach((e=>{const c=e.indexOf(r)>-1,d=e.indexOf(1)>-1;if(n&&d||a&&c)return;1===e.length&&e.push(e[0]);const l=[];e.forEach(((e,n,a)=>{const h=1===e,c=e===r;let d=i.getYForLine(e-1);0!==n||h?n!==a.length-1||c||(d+=o/2-1):d-=o/2-1,l.push(d),1===s&&h?l.push(t-2):-1===s&&c&&l.push(t+2)})),h.push(l.sort(((t,e)=>t-e)))})),h}(e,function(t,e){const i=[];let s=[];for(let n=1;n<=t;n++)e.indexOf(n)>-1?(i.push(s),s=[]):s.push(n);return s.length>0&&i.push(s),i}(this.checkStave().getNumLines(),this.positions.map((t=>Number(t.str)))),this.checkStave(),this.getStemDirection());i.save(),i.setLineWidth(nt.WIDTH),s.forEach((e=>{0!==e.length&&(i.beginPath(),i.moveTo(t,e[0]),i.lineTo(t,e[e.length-1]),i.stroke(),i.closePath())})),i.restore()}}drawPositions(){const t=this.checkContext(),e=this.getAbsoluteX(),i=this.ys;for(let s=0;s<this.positions.length;++s){const n=i[s]+this.render_options.y_shift,a=this.glyphs[s],o=e+this.glyph.getWidth()/2-a.getWidth()/2;if(t.clearRect(o-2,n-3,a.getWidth()+4,6),a.code)U.renderGlyph(t,o,n,this.render_options.glyph_font_scale*this.render_options.scale,a.code);else{t.save(),t.setFont(this.render_options.font);const e=a.text.toString();t.fillText(e,o,n+5*this.render_options.scale),t.restore()}}}draw(){const t=this.checkContext();if(0===this.ys.length)throw new f("NoYValues","Can't draw note without Y values.");this.setRendered();const e=null==this.beam&&this.render_options.draw_stem;if(t.openGroup("tabnote",void 0,{pointerBBox:!0}),this.drawPositions(),this.drawStemThrough(),this.stem&&e){const e=this.getStemX();this.stem.setNoteHeadXBounds(e,e),t.openGroup("stem",void 0,{pointerBBox:!0}),this.stem.setContext(t).draw(),t.closeGroup()}this.drawFlag(),this.drawModifiers(),t.closeGroup()}}class mi extends Ee{static get CATEGORY(){return m.TabStave}constructor(t,e,i,s){super(t,e,i,Object.assign({spacing_between_lines_px:13,num_lines:6,top_text_position:1},s))}getYForGlyphs(){return this.getYForLine(2.5)}addTabGlyph(){return this.addClef("tab"),this}}function fi(...t){xi.DEBUG&&S("Vex.Flow.TextBracket",t)}var _i;!function(t){t[t.TOP=1]="TOP",t[t.BOTTOM=-1]="BOTTOM"}(_i||(_i={}));class xi extends O{constructor({start:t,stop:e,text:i="",superscript:s="",position:n=_i.TOP}){super(),this.start=t,this.stop=e,this.text=i,this.superscript=s,this.position="string"==typeof n?xi.PositionString[n]:n,this.line=1,this.resetFont(),this.render_options={dashed:!0,dash:[5],color:"black",line_width:1,show_bracket:!0,bracket_height:8,underline_superscript:!0}}static get CATEGORY(){return m.TextBracket}static get Position(){return _i}static get PositionString(){return{top:_i.TOP,bottom:_i.BOTTOM}}static get Positions(){return fi("Positions is deprecated, use TextBracketPosition instead."),_i}static get PositionsString(){return fi("PositionsString is deprecated, use PositionString instead."),xi.PositionString}applyStyle(t){t.setFont(this.font);const e=this.render_options;return t.setStrokeStyle(e.color),t.setFillStyle(e.color),t.setLineWidth(e.line_width),this}setDashed(t,e){return this.render_options.dashed=t,e&&(this.render_options.dash=e),this}setLine(t){return this.line=t,this}draw(){const t=this.checkContext();this.setRendered();let e=0;switch(this.position){case _i.TOP:e=this.start.checkStave().getYForTopText(this.line);break;case _i.BOTTOM:e=this.start.checkStave().getYForBottomText(this.line+tt.TEXT_HEIGHT_OFFSET_HACK);break;default:throw new f("InvalidPosition",`The position ${this.position} is invalid.`)}const i={x:this.start.getAbsoluteX(),y:e},s={x:this.stop.getAbsoluteX(),y:e};fi("Rendering TextBracket: start:",i,"stop:",s,"y:",e);const n=this.render_options.bracket_height*this.position;t.save(),this.applyStyle(t),t.fillText(this.text,i.x,i.y);const a=t.measureText(this.text),o=a.width,r=a.height,h=i.y-r/2.5,{family:c,size:d,weight:l,style:g}=this.textFont,u=M.scaleSize(d,.714286);t.setFont(c,u,l,g),t.fillText(this.superscript,i.x+o+1,h);const p=t.measureText(this.superscript),m=p.width,_=p.height;let x=i.x,S=h;const y=s.x+this.stop.getGlyph().getWidth();this.position===_i.TOP?(x+=o+m+5,S-=_/2.7):this.position===_i.BOTTOM&&(S+=_/2.7,x+=o+2,this.render_options.underline_superscript||(x+=m)),this.render_options.dashed?(re.drawDashedLine(t,x,S,y,S,this.render_options.dash),this.render_options.show_bracket&&re.drawDashedLine(t,y,S+1*this.position,y,S+n,this.render_options.dash)):(t.beginPath(),t.moveTo(x,S),t.lineTo(y,S),this.render_options.show_bracket&&t.lineTo(y,S+n),t.stroke(),t.closePath()),t.restore()}}function Si(...t){yi.DEBUG&&S("Vex.Flow.TextDynamics",t)}xi.DEBUG=!1,xi.TEXT_FONT={family:M.SERIF,size:15,weight:k.NORMAL,style:D.ITALIC};class yi extends bt{constructor(t){super(t),this.sequence=(t.text||"").toLowerCase(),this.line=t.line||0,this.glyphs=[],this.render_options=Object.assign(Object.assign({},this.render_options),{glyph_font_size:40}),Si("New Dynamics Text: ",this.sequence)}static get CATEGORY(){return m.TextDynamics}static get GLYPHS(){return{f:{code:"dynamicForte",width:12},p:{code:"dynamicPiano",width:14},m:{code:"dynamicMezzo",width:17},s:{code:"dynamicSforzando",width:10},z:{code:"dynamicZ",width:12},r:{code:"dynamicRinforzando",width:12}}}setLine(t){return this.line=t,this}preFormat(){let t=0;return this.glyphs=[],this.sequence.split("").forEach((e=>{const i=yi.GLYPHS[e];if(!i)throw new f("Invalid dynamics character: "+e);const s=x(this.render_options.glyph_font_size),n=new U(i.code,s,{category:"textNote"});this.glyphs.push(n),t+=i.width})),this.setWidth(t),this.preFormatted=!0,this}draw(){this.setRendered();const t=this.getAbsoluteX(),e=this.checkStave().getYForLine(this.line+-3);Si("Rendering Dynamics: ",this.sequence);let i=t;this.glyphs.forEach(((t,s)=>{const n=this.sequence[s];t.render(this.checkContext(),i,e),i+=yi.GLYPHS[n].width}))}}yi.DEBUG=!1;class Ti extends bt{constructor(t,e){super({duration:"b"});const i=new be(t,e);this.timeSigInfo=i.getInfo(),this.setWidth(this.timeSigInfo.glyph.getMetrics().width),this.ignore_ticks=!0}static get CATEGORY(){return m.TimeSigNote}addToModifierContext(t){return this}preFormat(){return this.preFormatted=!0,this}draw(){const t=this.checkStave(),e=this.checkContext();this.setRendered(),this.timeSigInfo.glyph.getContext()||this.timeSigInfo.glyph.setContext(e),this.timeSigInfo.glyph.setStave(t),this.timeSigInfo.glyph.setYShift(t.getYForLine(2)-t.getYForGlyphs()),this.timeSigInfo.glyph.renderToStave(this.getAbsoluteX())}}class bi extends O{constructor(t){super(),t.start&&(this.start=t.start),t.stop&&(this.stop=t.stop),this.line=1,this.render_options={harsh:!1,wave_height:6,wave_width:4,wave_girth:2,vibrato_width:0}}static get CATEGORY(){return m.VibratoBracket}setLine(t){return this.line=t,this}setHarsh(t){return this.render_options.harsh=t,this}draw(){const t=this.checkContext();this.setRendered();const e=this.start&&this.start.checkStave().getYForTopText(this.line)||this.stop&&this.stop.checkStave().getYForTopText(this.line)||0,i=this.start&&this.start.getAbsoluteX()||this.stop&&this.stop.checkStave().getTieStartX()||0,s=this.stop&&this.stop.getAbsoluteX()-this.stop.getWidth()-5||this.start&&this.start.checkStave().getTieEndX()-10||0;this.render_options.vibrato_width=s-i,function(...t){bi.DEBUG&&S("Vex.Flow.VibratoBracket",t)}("Rendering VibratoBracket: start_x:",i,"stop_x:",s,"y:",e),de.renderVibrato(t,i,e,this.render_options)}}function wi(...t){vi.DEBUG&&S("Vex.Flow.Factory",t)}bi.DEBUG=!1;class vi{constructor(t={}){wi("New factory: ",t),this.options={stave:{space:10},renderer:{elementId:"",width:500,height:200,background:"#FFF"},font:vi.TEXT_FONT},this.setOptions(t)}static newFromElementId(t,e=500,i=200){return new vi({renderer:{elementId:t,width:e,height:i}})}reset(){this.renderQ=[],this.systems=[],this.staves=[],this.voices=[],this.stave=void 0}setOptions(t){this.options=Object.assign(Object.assign({},this.options),t),this.initRenderer(),this.reset()}initRenderer(){const{elementId:t,width:e,height:i,background:s}=this.options.renderer;if(null==t)return;if(""==t)throw wi(this),new f("renderer.elementId not set in FactoryOptions");let n=this.options.renderer.backend;if(void 0===n){n=Jt(document.getElementById(t))?re.Backends.CANVAS:re.Backends.SVG}this.context=re.buildContext(t,n,e,i,s)}getContext(){return this.context}setContext(t){return this.context=t,this}getStave(){return this.stave}getVoices(){return this.voices}Stave(t){const e=this.options.stave.space,i=Object.assign({x:0,y:0,width:this.options.renderer.width-1*e,options:{spacing_between_lines_px:1*e}},t),s=new Ee(i.x,i.y,i.width,i.options);return this.staves.push(s),s.setContext(this.context),this.stave=s,s}TabStave(t){const e=this.options.stave.space,i=Object.assign({x:0,y:0,width:this.options.renderer.width-1*e,options:{spacing_between_lines_px:1.3*e}},t),s=new mi(i.x,i.y,i.width,i.options);return this.staves.push(s),s.setContext(this.context),this.stave=s,s}StaveNote(t){const e=new $t(t);return this.stave&&e.setStave(this.stave),e.setContext(this.context),this.renderQ.push(e),e}GlyphNote(t,e,i){const s=new ii(t,e,i);return this.stave&&s.setStave(this.stave),s.setContext(this.context),this.renderQ.push(s),s}RepeatNote(t,e,i){const s=new di(t,e,i);return this.stave&&s.setStave(this.stave),s.setContext(this.context),this.renderQ.push(s),s}GhostNote(t){const e=new ei(t);return this.stave&&e.setStave(this.stave),e.setContext(this.context),this.renderQ.push(e),e}TextNote(t){const e=new xe(t);return this.stave&&e.setStave(this.stave),e.setContext(this.context),this.renderQ.push(e),e}BarNote(t={}){const e=new Ft(t.type);return this.stave&&e.setStave(this.stave),e.setContext(this.context),this.renderQ.push(e),e}ClefNote(t){const e=Object.assign({type:"treble",options:{size:"default",annotation:void 0}},t),i=new We(e.type,e.options.size,e.options.annotation);return this.stave&&i.setStave(this.stave),i.setContext(this.context),this.renderQ.push(i),i}TimeSigNote(t){const e=Object.assign({time:"4/4"},t),i=new Ti(e.time);return this.stave&&i.setStave(this.stave),i.setContext(this.context),this.renderQ.push(i),i}KeySigNote(t){const e=new ni(t.key,t.cancelKey,t.alterKey);return this.stave&&e.setStave(this.stave),e.setContext(this.context),this.renderQ.push(e),e}TabNote(t){const e=new pi(t);return this.stave&&e.setStave(this.stave),e.setContext(this.context),this.renderQ.push(e),e}GraceNote(t){const e=new si(t);return this.stave&&e.setStave(this.stave),e.setContext(this.context),e}GraceNoteGroup(t){const e=new Ut(t.notes,t.slur);return e.setContext(this.context),e}Accidental(t){const e=new st(t.type);return e.setContext(this.context),e}Annotation(t){const e=Object.assign({text:"p",hJustify:ct.CENTER,vJustify:dt.BOTTOM},t),i=new lt(e.text);return i.setJustification(e.hJustify),i.setVerticalJustification(e.vJustify),i.setFont(e.font),i.setContext(this.context),i}ChordSymbol(t){const e=Object.assign({vJustify:"top",hJustify:"center",kerning:!0,reportWidth:!0},t),i=new Rt;return i.setHorizontal(e.hJustify),i.setVertical(e.vJustify),i.setEnableKerning(e.kerning),i.setReportWidth(e.reportWidth),"string"==typeof e.fontFamily&&"number"==typeof e.fontSize?"string"==typeof e.fontWeight?i.setFont(e.fontFamily,e.fontSize,e.fontWeight):i.setFont(e.fontFamily,e.fontSize,""):"number"==typeof e.fontSize&&i.setFontSize(e.fontSize),i.setContext(this.context),i}Articulation(t){const e=Object.assign({type:"a.",position:"above"},t),i=new xt(e.type);return i.setPosition(e.position),i.setContext(this.context),i}TextDynamics(t){const e=Object.assign({text:"p",duration:"q",dots:0,line:0},t),i=new yi({text:e.text,line:e.line,duration:e.duration,dots:e.dots});return this.stave&&i.setStave(this.stave),i.setContext(this.context),this.renderQ.push(i),i}Fingering(t){const e=Object.assign({number:"0",position:"left"},t),i=new Lt(e.number);return i.setPosition(e.position),i.setContext(this.context),i}StringNumber(t){const e=new he(t.number);return e.setPosition(t.position),e.setContext(this.context),e}TickContext(){return new Yt}ModifierContext(){return new ge}MultiMeasureRest(t){const e=x(t.number_of_measures,"NoNumberOfMeasures"),i=new oi(e,t);return i.setContext(this.context),this.renderQ.push(i),i}Voice(t){const e=Object.assign({time:"4/4"},t),i=new Gt(e.time,e.options);return this.voices.push(i),i}StaveConnector(t){const e=new Ne(t.top_stave,t.bottom_stave);return e.setType(t.type).setContext(this.context),this.renderQ.push(e),e}Formatter(t){return new Pe(t)}Tuplet(t){const e=Object.assign({notes:[],options:{}},t),i=new Me(e.notes,e.options).setContext(this.context);return this.renderQ.push(i),i}Beam(t){var e,i,s,n,a;const o=new Ie(t.notes,null===(e=t.options)||void 0===e?void 0:e.autoStem).setContext(this.context);return o.breakSecondaryAt(null!==(s=null===(i=t.options)||void 0===i?void 0:i.secondaryBeamBreaks)&&void 0!==s?s:[]),(null===(n=t.options)||void 0===n?void 0:n.partialBeamDirections)&&Object.entries(null===(a=t.options)||void 0===a?void 0:a.partialBeamDirections).forEach((([t,e])=>{o.setPartialBeamSideAt(Number(t),e)})),this.renderQ.push(o),o}Curve(t){const e=new He(t.from,t.to,t.options).setContext(this.context);return this.renderQ.push(e),e}StaveTie(t){var e;const i=new It({first_note:t.from,last_note:t.to,first_indices:t.first_indices,last_indices:t.last_indices},t.text);return(null===(e=t.options)||void 0===e?void 0:e.direction)&&i.setDirection(t.options.direction),i.setContext(this.context),this.renderQ.push(i),i}StaveLine(t){var e,i;const s=new gi({first_note:t.from,last_note:t.to,first_indices:t.first_indices,last_indices:t.last_indices});return(null===(e=t.options)||void 0===e?void 0:e.text)&&s.setText(t.options.text),(null===(i=t.options)||void 0===i?void 0:i.font)&&s.setFont(t.options.font),s.setContext(this.context),this.renderQ.push(s),s}VibratoBracket(t){const e=new bi({start:t.from,stop:t.to});return t.options.line&&e.setLine(t.options.line),t.options.harsh&&e.setHarsh(t.options.harsh),e.setContext(this.context),this.renderQ.push(e),e}TextBracket(t){const e=new xi({start:t.from,stop:t.to,text:t.text,superscript:t.options.superscript,position:t.options.position});return t.options.line&&e.setLine(t.options.line),t.options.font&&e.setFont(t.options.font),e.setContext(this.context),this.renderQ.push(e),e}System(t={}){t.factory=this;const e=new ui(t).setContext(this.context);return this.systems.push(e),e}EasyScore(t={}){return t.factory=this,new Ze(t)}PedalMarking(t){const e=Object.assign({notes:[],options:{style:"mixed"}},t),i=new hi(e.notes);return i.setType(hi.typeString[e.options.style]),i.setContext(this.context),this.renderQ.push(i),i}NoteSubGroup(t){const e=Object.assign({notes:[]},t),i=new Ht(e.notes);return i.setContext(this.context),i}draw(){const t=this.context;this.systems.forEach((e=>e.setContext(t).format())),this.staves.forEach((e=>e.setContext(t).draw())),this.voices.forEach((e=>e.setContext(t).draw())),this.renderQ.forEach((e=>{e.isRendered()||e.setContext(t).draw()})),this.systems.forEach((e=>e.setContext(t).draw())),this.reset()}}vi.DEBUG=!1,vi.TEXT_FONT=Object.assign({},O.TEXT_FONT);class Ei extends pi{static get CATEGORY(){return m.GraceTabNote}constructor(t){super(t,!1),this.render_options=Object.assign(Object.assign({},this.render_options),{y_shift:.3,scale:.6,font:`7.5pt ${M.SANS_SERIF}`}),this.updateWidth()}}class Ci{constructor(t){this.music=new Y,this.setKey(t)}setKey(t){return this.key=t,this.reset(),this}getKey(){return this.key}reset(){this.keyParts=this.music.getKeyParts(this.key),this.keyString=this.keyParts.root,this.keyParts.accidental&&(this.keyString+=this.keyParts.accidental);if(!Y.scaleTypes[this.keyParts.type])throw new f("BadArguments",`Unsupported key type: ${this.key}`);this.scale=this.music.getScaleTones(this.music.getNoteValue(this.keyString),Y.scaleTypes[this.keyParts.type]),this.scaleMap={},this.scaleMapByValue={},this.originalScaleMapByValue={};const t=Y.root_indices[this.keyParts.root];for(let e=0;e<Y.roots.length;++e){const i=(t+e)%Y.roots.length,s=Y.roots[i],n=this.music.getRelativeNoteName(s,this.scale[e]);this.scaleMap[s]=n,this.scaleMapByValue[this.scale[e]]=n,this.originalScaleMapByValue[this.scale[e]]=n}return this}getAccidental(t){const e=this.music.getKeyParts(t).root,i=this.music.getNoteParts(this.scaleMap[e]);return{note:this.scaleMap[e],accidental:i.accidental}}selectNote(t){t=t.toLowerCase();const e=this.music.getNoteParts(t),i=this.scaleMap[e.root],s=this.music.getNoteParts(i);if(i===t)return{note:i,accidental:e.accidental,change:!1};const n=this.scaleMapByValue[this.music.getNoteValue(t)];if(null!=n)return{note:n,accidental:this.music.getNoteParts(n).accidental,change:!1};const a=this.originalScaleMapByValue[this.music.getNoteValue(t)];return null!=a?(this.scaleMap[s.root]=a,delete this.scaleMapByValue[this.music.getNoteValue(i)],this.scaleMapByValue[this.music.getNoteValue(t)]=a,{note:a,accidental:this.music.getNoteParts(a).accidental,change:!0}):s.root===t?(delete this.scaleMapByValue[this.music.getNoteValue(this.scaleMap[e.root])],this.scaleMapByValue[this.music.getNoteValue(s.root)]=s.root,this.scaleMap[s.root]=s.root,{note:s.root,accidental:void 0,change:!0}):(delete this.scaleMapByValue[this.music.getNoteValue(this.scaleMap[e.root])],this.scaleMapByValue[this.music.getNoteValue(t)]=t,delete this.scaleMap[s.root],this.scaleMap[s.root]=t,{note:t,accidental:e.accidental,change:!0})}}class Ni extends O{constructor(t,e){super(),this.setNotes(t),this.hairpin=e,this.position=H.Position.BELOW,this.render_options={height:10,y_shift:0,left_shift_px:0,right_shift_px:0,right_shift_ticks:0,left_shift_ticks:0}}static get CATEGORY(){return m.StaveHairpin}static FormatByTicksAndDraw(t,e,i,s,n,a){var o,r;const h=e.pixelsPerTick;if(null==h)throw new f("BadArguments","A valid Formatter must be provide to draw offsets by ticks.");const c=h*(null!==(o=a.left_shift_ticks)&&void 0!==o?o:0),d=h*(null!==(r=a.right_shift_ticks)&&void 0!==r?r:0),l={height:a.height,y_shift:a.y_shift,left_shift_px:c,right_shift_px:d,right_shift_ticks:0,left_shift_ticks:0};new Ni({first_note:i.first_note,last_note:i.last_note},s).setContext(t).setRenderOptions(l).setPosition(n).draw()}setPosition(t){return t!==H.Position.ABOVE&&t!==H.Position.BELOW||(this.position=t),this}setRenderOptions(t){return null!=t.height&&null!=t.y_shift&&null!=t.left_shift_px&&null!=t.right_shift_px&&(this.render_options=t),this}setNotes(t){if(!t.first_note&&!t.last_note)throw new f("BadArguments","Hairpin needs to have either first_note or last_note set.");return this.notes=t,this.first_note=t.first_note,this.last_note=t.last_note,this}renderHairpin(t){const e=this.checkContext();let i=this.render_options.y_shift+20,s=t.first_y;this.position===H.Position.ABOVE&&(i=30-i,s=t.first_y-t.staff_height);const n=this.render_options.left_shift_px,a=this.render_options.right_shift_px;switch(e.beginPath(),this.hairpin){case Ni.type.CRESC:e.moveTo(t.last_x+a,s+i),e.lineTo(t.first_x+n,s+this.render_options.height/2+i),e.lineTo(t.last_x+a,s+this.render_options.height+i);break;case Ni.type.DECRESC:e.moveTo(t.first_x+n,s+i),e.lineTo(t.last_x+a,s+this.render_options.height/2+i),e.lineTo(t.first_x+n,s+this.render_options.height+i)}e.stroke(),e.closePath()}draw(){this.checkContext(),this.setRendered();const t=this.first_note,e=this.last_note;if(!t||!e)throw new f("NoNote","Notes required to draw");const i=t.getModifierStartXY(this.position,0),s=e.getModifierStartXY(this.position,0);this.renderHairpin({first_x:i.x,last_x:s.x,first_y:t.checkStave().getY()+t.checkStave().getHeight(),last_y:e.checkStave().getY()+e.checkStave().getHeight(),staff_height:t.checkStave().getHeight()})}}Ni.type={CRESC:1,DECRESC:2};class ki extends Wt{constructor(t,e){if(super(t,"sl."),!e){let i=t.first_note.getPositions()[0].fret;"string"==typeof i&&(i=parseInt(i,10));let s=t.last_note.getPositions()[0].fret;"string"==typeof s&&(s=parseInt(s,10)),e=isNaN(i)||isNaN(s)?ki.SLIDE_UP:i>s?ki.SLIDE_DOWN:ki.SLIDE_UP}this.direction=e,this.render_options.cp1=11,this.render_options.cp2=14,this.render_options.y_shift=.5,this.resetFont()}static get CATEGORY(){return m.TabSlide}static get SLIDE_UP(){return 1}static get SLIDE_DOWN(){return-1}static createSlideUp(t){return new ki(t,ki.SLIDE_UP)}static createSlideDown(t){return new ki(t,ki.SLIDE_DOWN)}renderTie(t){if(0===t.first_ys.length||0===t.last_ys.length)throw new f("BadArguments","No Y-values to render");const e=this.checkContext(),i=t.first_x_px,s=t.first_ys,n=t.last_x_px,a=t.direction;if(a!==ki.SLIDE_UP&&a!==ki.SLIDE_DOWN)throw new f("BadSlide","Invalid slide direction");const o=this.notes.first_indices;for(let t=0;t<o.length;++t){const r=s[o[t]]+this.render_options.y_shift;if(isNaN(r))throw new f("BadArguments","Bad indices for slide rendering.");e.beginPath(),e.moveTo(i,r+3*a),e.lineTo(n,r-3*a),e.closePath(),e.stroke()}this.setRendered()}}ki.TEXT_FONT={family:M.SERIF,size:10,weight:k.BOLD,style:D.ITALIC};class Di extends H{constructor(t){super(),this.num=t,this.position=H.Position.CENTER,this.code="tremolo1",this.y_spacing_scale=1,this.extra_stroke_scale=1}static get CATEGORY(){return m.Tremolo}draw(){const t=this.checkContext(),e=this.checkAttachedNote();this.setRendered();const i=e.getStemDirection();let s=e.getModifierStartXY(this.position,this.index).x;const n=h(e),a=n?si.SCALE:1,o="tremolo."+(n?"grace":"default"),r=tt.currentMusicFont();let c=r.lookupMetric(`${o}.spacing`)*i;c*=this.y_spacing_scale;const d=this.num*c;let l=e.getStemExtents().baseY-d;l+=i<0?r.lookupMetric(`${o}.offsetYStemDown`)*a:r.lookupMetric(`${o}.offsetYStemUp`)*a;const g=r.lookupMetric(`${o}.point`);s+=r.lookupMetric(`${o}.offsetXStem${i===nt.UP?"Up":"Down"}`);for(let e=0;e<this.num;++e)U.renderGlyph(t,s,l,g,this.code,{category:o,scale:this.extra_stroke_scale}),l+=c}}class Ai{constructor(t="E/5,B/4,G/4,D/4,A/3,E/3,B/2,E/2"){this.tuningValues=[],this.setTuning(t)}static get names(){return{standard:"E/5,B/4,G/4,D/4,A/3,E/3",dagdad:"D/5,A/4,G/4,D/4,A/3,D/3",dropd:"E/5,B/4,G/4,D/4,A/3,D/3",eb:"Eb/5,Bb/4,Gb/4,Db/4,Ab/3,Db/3",standardBanjo:"D/5,B/4,G/4,D/4,G/5"}}noteToInteger(t){return tt.keyProperties(t).int_value}setTuning(t){Ai.names[t]&&(t=Ai.names[t]),this.tuningValues=[];const e=t.split(/\s*,\s*/);if(0===e.length)throw new f("BadArguments",`Invalid tuning string: ${t}`);for(let t=0;t<e.length;++t)this.tuningValues[t]=this.noteToInteger(e[t])}getValueForString(t){const e=Number(t);if(e<1||e>this.tuningValues.length)throw new f("BadArguments",`String number must be between 1 and ${this.tuningValues.length}:${t}`);return this.tuningValues[e-1]}getValueForFret(t,e){const i=this.getValueForString(e),s=Number(t);if(s<0)throw new f("BadArguments",`Fret number must be 0 or higher: ${t}`);return i+s}getNoteForFret(t,e){const i=this.getValueForFret(t,e),s=Math.floor(i/12),n=i%12;return`${tt.integerToNote(n)}/${s}`}}var Pi=function(t,e,i,s){return new(i||(i=Promise))((function(n,a){function o(t){try{h(s.next(t))}catch(t){a(t)}}function r(t){try{h(s.throw(t))}catch(t){a(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,r)}h((s=s.apply(t,e||[])).next())}))};class Fi{static get BUILD(){return{VERSION:"4.0.1-rc.0",ID:"1d341b5910cee7245c9b99a193f529ec38b80168",DATE:"2022-03-21T22:34:31.158Z"}}static setMusicFont(...t){const e=t.map((t=>M.load(t)));return tt.MUSIC_FONT_STACK=e,U.MUSIC_FONT_STACK=e.slice(),U.CURRENT_CACHE_KEY=t.join(","),e}static fetchMusicFont(t,e){return Pi(this,void 0,void 0,(function*(){}))}static getMusicFont(){return tt.MUSIC_FONT_STACK.map((t=>t.getName()))}static get NOTATION_FONT_SCALE(){return tt.NOTATION_FONT_SCALE}static set NOTATION_FONT_SCALE(t){tt.NOTATION_FONT_SCALE=t}static get TABLATURE_FONT_SCALE(){return tt.TABLATURE_FONT_SCALE}static set TABLATURE_FONT_SCALE(t){tt.TABLATURE_FONT_SCALE=t}static get RESOLUTION(){return tt.RESOLUTION}static set RESOLUTION(t){tt.RESOLUTION=t}static get SLASH_NOTEHEAD_WIDTH(){return tt.SLASH_NOTEHEAD_WIDTH}static set SLASH_NOTEHEAD_WIDTH(t){tt.SLASH_NOTEHEAD_WIDTH=t}static get STAVE_LINE_DISTANCE(){return tt.STAVE_LINE_DISTANCE}static set STAVE_LINE_DISTANCE(t){tt.STAVE_LINE_DISTANCE=t}static get STAVE_LINE_THICKNESS(){return tt.STAVE_LINE_THICKNESS}static set STAVE_LINE_THICKNESS(t){tt.STAVE_LINE_THICKNESS=t}static get STEM_HEIGHT(){return tt.STEM_HEIGHT}static set STEM_HEIGHT(t){tt.STEM_HEIGHT=t}static get STEM_WIDTH(){return tt.STEM_WIDTH}static set STEM_WIDTH(t){tt.STEM_WIDTH=t}static get TIME4_4(){return tt.TIME4_4}static get accidentalMap(){return tt.accidentalMap}static get unicode(){return tt.unicode}static keySignature(t){return tt.keySignature(t)}static hasKeySignature(t){return tt.hasKeySignature(t)}static getKeySignatures(){return tt.getKeySignatures()}static clefProperties(t){return tt.clefProperties(t)}static keyProperties(t,e,i){return tt.keyProperties(t,e,i)}static durationToTicks(t){return tt.durationToTicks(t)}}Fi.Accidental=st,Fi.Annotation=lt,Fi.Articulation=xt,Fi.Barline=Pt,Fi.BarNote=Ft,Fi.Beam=Ie,Fi.Bend=Mt,Fi.BoundingBox=C,Fi.BoundingBoxComputation=N,Fi.CanvasContext=Qt,Fi.ChordSymbol=Rt,Fi.Clef=ue,Fi.ClefNote=We,Fi.Crescendo=Ge,Fi.Curve=He,Fi.Dot=Ot,Fi.EasyScore=Ze,Fi.Element=O,Fi.Factory=vi,Fi.Font=M,Fi.Formatter=Pe,Fi.Fraction=v,Fi.FretHandFinger=Lt,Fi.GhostNote=ei,Fi.Glyph=U,Fi.GlyphNote=ii,Fi.GraceNote=si,Fi.GraceNoteGroup=Ut,Fi.GraceTabNote=Ei,Fi.KeyManager=Ci,Fi.KeySignature=pe,Fi.KeySigNote=ni,Fi.Modifier=H,Fi.ModifierContext=ge,Fi.MultiMeasureRest=oi,Fi.Music=Y,Fi.Note=bt,Fi.NoteHead=Vt,Fi.NoteSubGroup=Ht,Fi.Ornament=jt,Fi.Parenthesis=Xt,Fi.Parser=Xe,Fi.PedalMarking=hi,Fi.Registry=R,Fi.RenderContext=St,Fi.Renderer=re,Fi.RepeatNote=di,Fi.Repetition=me,Fi.Stave=Ee,Fi.StaveConnector=Ne,Fi.StaveHairpin=Ni,Fi.StaveLine=gi,Fi.StaveModifier=At,Fi.StaveNote=$t,Fi.StaveTempo=_e,Fi.StaveText=Se,Fi.StaveTie=It,Fi.Stem=nt,Fi.StringNumber=he,Fi.Stroke=ce,Fi.SVGContext=ie,Fi.System=ui,Fi.TabNote=pi,Fi.TabSlide=ki,Fi.TabStave=mi,Fi.TabTie=Wt,Fi.TextBracket=xi,Fi.TextDynamics=yi,Fi.TextFormatter=ht,Fi.TextNote=xe,Fi.TickContext=Yt,Fi.TimeSignature=be,Fi.TimeSigNote=Ti,Fi.Tremolo=Di,Fi.Tuning=Ai,Fi.Tuplet=Me,Fi.Vibrato=de,Fi.VibratoBracket=bi,Fi.Voice=Gt,Fi.Volta=ye,Fi.AnnotationHorizontalJustify=ct,Fi.AnnotationVerticalJustify=dt,Fi.ChordSymbolHorizontalJustify=Et,Fi.ChordSymbolVerticalJustify=Ct,Fi.SymbolTypes=Nt,Fi.SymbolModifiers=kt,Fi.CurvePosition=Ue,Fi.FontWeight=k,Fi.FontStyle=D,Fi.ModifierPosition=I,Fi.RendererBackends=se,Fi.RendererLineEndType=ne,Fi.BarlineType=vt,Fi.StaveModifierPosition=wt,Fi.VoltaType=oe,Fi.TextBracketPosition=_i,Fi.TextJustification=ae,Fi.VoiceMode=Dt;const Mi={spacing:50,glyphs:{" ":{x_min:0,x_max:250,y_min:0,y_max:500,ha:500,leftSideBearing:0,advanceWidth:250},0:{x_min:33,x_max:534,y_min:-13,y_max:751,ha:764,leftSideBearing:33,advanceWidth:570},1:{x_min:48,x_max:235,y_min:-17,y_max:734,ha:751,leftSideBearing:48,advanceWidth:286},2:{x_min:56,x_max:571,y_min:-19,y_max:741,ha:760,leftSideBearing:56,advanceWidth:626},3:{x_min:50,x_max:528,y_min:-7,y_max:731,ha:738,leftSideBearing:50,advanceWidth:589},4:{x_min:38,x_max:564,y_min:-13,y_max:743,ha:756,leftSideBearing:38,advanceWidth:614},5:{x_min:42,x_max:601,y_min:-34,y_max:743,ha:777,leftSideBearing:42,advanceWidth:648},6:{x_min:47,x_max:606,y_min:-16,y_max:743,ha:759,leftSideBearing:47,advanceWidth:667},7:{x_min:47,x_max:567,y_min:5,y_max:739,ha:734,leftSideBearing:0,advanceWidth:615},8:{x_min:40,x_max:541,y_min:-15,y_max:752,ha:767,leftSideBearing:40,advanceWidth:585},9:{x_min:40,x_max:537,y_min:-52,y_max:736,ha:788,leftSideBearing:40,advanceWidth:592},"!":{x_min:49,x_max:180,y_min:-7,y_max:761,ha:768,leftSideBearing:49,advanceWidth:230},'"':{x_min:39,x_max:304,y_min:596,y_max:804,ha:208,leftSideBearing:39,advanceWidth:353},"#":{x_min:33,x_max:599,y_min:-8,y_max:765,ha:773,leftSideBearing:33,advanceWidth:648},$:{x_min:53,x_max:495,y_min:-111,y_max:823,ha:934,leftSideBearing:53,advanceWidth:560},"%":{x_min:35,x_max:656,y_min:-128,y_max:808,ha:936,leftSideBearing:35,advanceWidth:711},"&":{x_min:53,x_max:441,y_min:-3,y_max:753,ha:756,leftSideBearing:53,advanceWidth:500},"'":{x_min:43,x_max:161,y_min:590,y_max:811,ha:221,leftSideBearing:43,advanceWidth:217},"(":{x_min:41,x_max:311,y_min:-36,y_max:845,ha:881,leftSideBearing:41,advanceWidth:308},")":{x_min:-8,x_max:257,y_min:-21,y_max:852,ha:873,leftSideBearing:-8,advanceWidth:280},"*":{x_min:59,x_max:539,y_min:175,y_max:589,ha:414,leftSideBearing:59,advanceWidth:601},"+":{x_min:33,x_max:361,y_min:180,y_max:587,ha:407,leftSideBearing:33,advanceWidth:400},",":{x_min:15,x_max:176,y_min:-129,y_max:92,ha:221,leftSideBearing:15,advanceWidth:205},"-":{x_min:40,x_max:380,y_min:317,y_max:452,ha:135,leftSideBearing:40,advanceWidth:422},".":{x_min:48,x_max:185,y_min:-56,y_max:84,ha:140,leftSideBearing:48,advanceWidth:227},"/":{x_min:-58,x_max:654,y_min:-122,y_max:844,ha:966,leftSideBearing:-58,advanceWidth:626},":":{x_min:65,x_max:225,y_min:97,y_max:536,ha:439,leftSideBearing:65,advanceWidth:302},";":{x_min:13,x_max:295,y_min:-139,y_max:536,ha:675,leftSideBearing:13,advanceWidth:334},"<":{x_min:28,x_max:438,y_min:-1,y_max:607,ha:608,leftSideBearing:28,advanceWidth:475},"=":{x_min:40,x_max:383,y_min:199.9598640852289,y_max:541,ha:341.0401359147711,leftSideBearing:40,advanceWidth:422},">":{x_min:35,x_max:421,y_min:28,y_max:632,ha:604,leftSideBearing:35,advanceWidth:466},"?":{x_min:45,x_max:548,y_min:-17,y_max:767,ha:784,leftSideBearing:45,advanceWidth:592},"@":{x_min:51,x_max:730,y_min:-78,y_max:753,ha:831,leftSideBearing:51,advanceWidth:781},A:{x_min:37,x_max:554,y_min:-4,y_max:746,ha:750,leftSideBearing:37,advanceWidth:617},B:{x_min:37,x_max:532,y_min:3,y_max:783,ha:780,leftSideBearing:37,advanceWidth:579},C:{x_min:37,x_max:583,y_min:-3,y_max:775,ha:778,leftSideBearing:37,advanceWidth:623},D:{x_min:50,x_max:530,y_min:-15,y_max:749,ha:764,leftSideBearing:50,advanceWidth:579},E:{x_min:45,x_max:531,y_min:-1,y_max:743,ha:744,leftSideBearing:45,advanceWidth:585},F:{x_min:45,x_max:459,y_min:23,y_max:727,ha:704,leftSideBearing:45,advanceWidth:510},G:{x_min:31,x_max:577,y_min:-8,y_max:733,ha:741,leftSideBearing:31,advanceWidth:611},H:{x_min:37,x_max:493,y_min:-22,y_max:758,ha:780,leftSideBearing:37,advanceWidth:535},I:{x_min:47,x_max:501,y_min:-3,y_max:731,ha:734,leftSideBearing:47,advanceWidth:541},J:{x_min:33,x_max:531,y_min:-23,y_max:725,ha:748,leftSideBearing:33,advanceWidth:573},K:{x_min:43,x_max:505,y_min:-10,y_max:740,ha:750,leftSideBearing:43,advanceWidth:560},L:{x_min:49,x_max:457,y_min:-2,y_max:746,ha:748,leftSideBearing:49,advanceWidth:510},M:{x_min:35,x_max:699,y_min:1,y_max:744,ha:743,leftSideBearing:35,advanceWidth:743},N:{x_min:34,x_max:533,y_min:-17,y_max:761,ha:778,leftSideBearing:34,advanceWidth:579},O:{x_min:41,x_max:608,y_min:-5,y_max:735,ha:740,leftSideBearing:41,advanceWidth:667},P:{x_min:53,x_max:451,y_min:-18,y_max:735,ha:753,leftSideBearing:53,advanceWidth:497},Q:{x_min:40,x_max:599,y_min:-67,y_max:744,ha:811,leftSideBearing:40,advanceWidth:648},R:{x_min:39,x_max:487,y_min:16,y_max:735,ha:719,leftSideBearing:39,advanceWidth:535},S:{x_min:35,x_max:552,y_min:-47,y_max:708,ha:755,leftSideBearing:35,advanceWidth:604},T:{x_min:26,x_max:656,y_min:-13,y_max:718,ha:731,leftSideBearing:26,advanceWidth:705},U:{x_min:41,x_max:518,y_min:-20,y_max:748,ha:768,leftSideBearing:41,advanceWidth:567},V:{x_min:47,x_max:509,y_min:-26,y_max:744,ha:770,leftSideBearing:47,advanceWidth:567},W:{x_min:44,x_max:789,y_min:-35,y_max:720,ha:755,leftSideBearing:44,advanceWidth:833},X:{x_min:63,x_max:635,y_min:-10,y_max:745,ha:755,leftSideBearing:63,advanceWidth:680},Y:{x_min:43,x_max:503,y_min:-21,y_max:734,ha:755,leftSideBearing:43,advanceWidth:541},Z:{x_min:42,x_max:584,y_min:-10,y_max:739,ha:749,leftSideBearing:42,advanceWidth:629},"[":{x_min:46,x_max:346,y_min:-150,y_max:884,ha:1034,leftSideBearing:46,advanceWidth:291},"\\":{x_min:20,x_max:616,y_min:-100,y_max:797,ha:897,leftSideBearing:20,advanceWidth:645},"]":{x_min:-76,x_max:226,y_min:-150,y_max:881,ha:1031,leftSideBearing:-76,advanceWidth:297},"^":{x_min:43,x_max:437,y_min:517,y_max:812,ha:295,leftSideBearing:43,advanceWidth:478},_:{x_min:29,x_max:563,y_min:-110,y_max:-1,ha:109,leftSideBearing:29,advanceWidth:598},"`":{x_min:54,x_max:321,y_min:540,y_max:747,ha:207,leftSideBearing:54,advanceWidth:368},a:{x_min:20,x_max:447,y_min:-17,y_max:495,ha:512,leftSideBearing:20,advanceWidth:494},b:{x_min:37,x_max:466,y_min:-27,y_max:770,ha:797,leftSideBearing:37,advanceWidth:510},c:{x_min:35,x_max:456,y_min:-9,y_max:507,ha:516,leftSideBearing:35,advanceWidth:460},d:{x_min:45,x_max:520,y_min:-15,y_max:764,ha:779,leftSideBearing:45,advanceWidth:560},e:{x_min:33,x_max:370,y_min:-5,y_max:501,ha:506,leftSideBearing:33,advanceWidth:397},f:{x_min:35,x_max:411,y_min:-13,y_max:695,ha:708,leftSideBearing:35,advanceWidth:453},g:{x_min:33,x_max:551,y_min:-257,y_max:505,ha:762,leftSideBearing:33,advanceWidth:611},h:{x_min:32,x_max:458,y_min:-29,y_max:743,ha:772,leftSideBearing:32,advanceWidth:491},i:{x_min:45,x_max:167,y_min:-13,y_max:631,ha:644,leftSideBearing:45,advanceWidth:220},j:{x_min:-127,x_max:261,y_min:-231,y_max:601,ha:832,leftSideBearing:-127,advanceWidth:308},k:{x_min:39,x_max:443,y_min:-3,y_max:700,ha:703,leftSideBearing:39,advanceWidth:497},l:{x_min:58,x_max:168,y_min:-8,y_max:686,ha:694,leftSideBearing:58,advanceWidth:227},m:{x_min:39,x_max:688,y_min:-14,y_max:501,ha:515,leftSideBearing:39,advanceWidth:718},n:{x_min:45,x_max:491,y_min:-32,y_max:512,ha:544,leftSideBearing:45,advanceWidth:541},o:{x_min:41,x_max:424,y_min:-12,y_max:493,ha:505,leftSideBearing:41,advanceWidth:447},p:{x_min:25,x_max:529,y_min:-260,y_max:500,ha:760,leftSideBearing:25,advanceWidth:573},q:{x_min:53,x_max:603,y_min:-235,y_max:514,ha:749,leftSideBearing:53,advanceWidth:623},r:{x_min:32,x_max:407,y_min:-7,y_max:492,ha:499,leftSideBearing:32,advanceWidth:460},s:{x_min:49,x_max:416,y_min:-12,y_max:519,ha:531,leftSideBearing:49,advanceWidth:460},t:{x_min:32,x_max:442,y_min:-5,y_max:684,ha:689,leftSideBearing:32,advanceWidth:469},u:{x_min:41,x_max:487,y_min:-5,y_max:507,ha:512,leftSideBearing:41,advanceWidth:510},v:{x_min:16,x_max:441,y_min:-20,y_max:542,ha:562,leftSideBearing:16,advanceWidth:456},w:{x_min:39,x_max:639,y_min:-22,y_max:505,ha:527,leftSideBearing:39,advanceWidth:661},x:{x_min:15,x_max:505,y_min:-39,y_max:539,ha:578,leftSideBearing:15,advanceWidth:541},y:{x_min:-98,x_max:501,y_min:-242,y_max:511,ha:753,leftSideBearing:-98,advanceWidth:548},z:{x_min:27,x_max:479,y_min:-3,y_max:494,ha:497,leftSideBearing:27,advanceWidth:494},"{":{x_min:0,x_max:0,y_min:0,y_max:0,ha:0,leftSideBearing:0,advanceWidth:308},"|":{x_min:0,x_max:0,y_min:0,y_max:0,ha:0,leftSideBearing:0,advanceWidth:308},"}":{x_min:0,x_max:0,y_min:0,y_max:0,ha:0,leftSideBearing:0,advanceWidth:308},"~":{x_min:0,x_max:0,y_min:0,y_max:0,ha:0,leftSideBearing:0,advanceWidth:308}},fontFamily:"PetalumaScript",resolution:1e3,generatedOn:"2020-06-14T18:33:25.407Z"},Bi={spacing:50,glyphs:{" ":{x_min:0,x_max:509,y_min:0,y_max:2e3,ha:2e3,leftSideBearing:0,advanceWidth:509},0:{x_min:121,x_max:1048,y_min:-21,y_max:1477,ha:1498,leftSideBearing:121,advanceWidth:1168},1:{x_min:117,x_max:767,y_min:0,y_max:1456,ha:1456,leftSideBearing:117,advanceWidth:844},2:{x_min:75.8474576645637,x_max:1040,y_min:0,y_max:1477,ha:1477,leftSideBearing:75,advanceWidth:1131},3:{x_min:74.85365853658536,x_max:994,y_min:-21,y_max:1477,ha:1498,leftSideBearing:74,advanceWidth:1106},4:{x_min:63,x_max:1114,y_min:0,y_max:1456,ha:1456,leftSideBearing:63,advanceWidth:1187},5:{x_min:96.8448275474953,x_max:982,y_min:-21,y_max:1456,ha:1477,leftSideBearing:96,advanceWidth:1081},6:{x_min:121,x_max:1067,y_min:-21,y_max:1477,ha:1498,leftSideBearing:121,advanceWidth:1144},7:{x_min:76,x_max:1060,y_min:0,y_max:1456,ha:1456,leftSideBearing:-30,advanceWidth:1128},8:{x_min:92,x_max:1039,y_min:-21,y_max:1477,ha:1498,leftSideBearing:92,advanceWidth:1131},9:{x_min:84,x_max:1026,y_min:-21,y_max:1477,ha:1498,leftSideBearing:84,advanceWidth:1154},"!":{x_min:143,x_max:340,y_min:0,y_max:1456,ha:1456,leftSideBearing:143,advanceWidth:483},'"':{x_min:166,x_max:634,y_min:1055,y_max:1560,ha:505,leftSideBearing:166,advanceWidth:770},"#":{x_min:63,x_max:1179,y_min:0,y_max:1456,ha:1456,leftSideBearing:63,advanceWidth:1246},$:{x_min:81.92156915727656,x_max:1012,y_min:-208,y_max:1693,ha:1901,leftSideBearing:81,advanceWidth:1110},"%":{x_min:77,x_max:1384,y_min:-21,y_max:1477,ha:1498,leftSideBearing:77,advanceWidth:1460},"&":{x_min:74,x_max:1242,y_min:-21,y_max:1477,ha:1498,leftSideBearing:74,advanceWidth:1289},"'":{x_min:166,x_max:324,y_min:1055,y_max:1560,ha:505,leftSideBearing:166,advanceWidth:460},"(":{x_min:114,x_max:650,y_min:-463,y_max:1636,ha:2099,leftSideBearing:114,advanceWidth:662},")":{x_min:11,x_max:547,y_min:-463,y_max:1636,ha:2099,leftSideBearing:11,advanceWidth:654},"*":{x_min:66,x_max:893,y_min:607,y_max:1456,ha:849,leftSideBearing:66,advanceWidth:958},"+":{x_min:73,x_max:1071,y_min:146,y_max:1206,ha:1060,leftSideBearing:73,advanceWidth:1145},",":{x_min:23,x_max:315,y_min:-311,y_max:221,ha:532,leftSideBearing:23,advanceWidth:404},"-":{x_min:154,x_max:643,y_min:538,y_max:692,ha:154,leftSideBearing:154,advanceWidth:797},".":{x_min:145,x_max:342,y_min:0,y_max:202,ha:202,leftSideBearing:145,advanceWidth:493},"/":{x_min:0,x_max:774,y_min:-125,y_max:1456,ha:1581,leftSideBearing:0,advanceWidth:824},":":{x_min:145,x_max:342,y_min:0,y_max:1082,ha:1082,leftSideBearing:145,advanceWidth:419},";":{x_min:53,x_max:345,y_min:-311,y_max:1082,ha:1393,leftSideBearing:53,advanceWidth:424},"<":{x_min:76,x_max:892,y_min:107,y_max:1013,ha:906,leftSideBearing:76,advanceWidth:1017},"=":{x_min:147,x_max:981,y_min:407,y_max:987,ha:580,leftSideBearing:147,advanceWidth:1127},">":{x_min:125,x_max:980,y_min:87,y_max:993,ha:906,leftSideBearing:125,advanceWidth:1060},"?":{x_min:65.92660602419838,x_max:890,y_min:0,y_max:1477,ha:1477,leftSideBearing:65,advanceWidth:953},"@":{x_min:84.3592218305664,x_max:1705.2346925277395,y_min:-453,y_max:1431,ha:1884,leftSideBearing:84,advanceWidth:1821},A:{x_min:70,x_max:1463,y_min:0,y_max:1456,ha:1456,leftSideBearing:70,advanceWidth:1533},B:{x_min:81,x_max:1253,y_min:0,y_max:1456,ha:1456,leftSideBearing:81,advanceWidth:1322},C:{x_min:80,x_max:1174,y_min:-21,y_max:1477,ha:1498,leftSideBearing:80,advanceWidth:1290},D:{x_min:81,x_max:1291,y_min:0,y_max:1456,ha:1456,leftSideBearing:81,advanceWidth:1356},E:{x_min:81,x_max:1190,y_min:0,y_max:1456,ha:1456,leftSideBearing:81,advanceWidth:1306},F:{x_min:81,x_max:1176,y_min:0,y_max:1456,ha:1456,leftSideBearing:81,advanceWidth:1256},G:{x_min:80,x_max:1226,y_min:-21,y_max:1477,ha:1498,leftSideBearing:80,advanceWidth:1346},H:{x_min:81,x_max:1497,y_min:0,y_max:1456,ha:1456,leftSideBearing:81,advanceWidth:1578},I:{x_min:81,x_max:604,y_min:0,y_max:1456,ha:1456,leftSideBearing:81,advanceWidth:685},J:{x_min:60,x_max:1100,y_min:-21,y_max:1456,ha:1477,leftSideBearing:60,advanceWidth:1169},K:{x_min:81,x_max:1427,y_min:0,y_max:1456,ha:1456,leftSideBearing:81,advanceWidth:1501},L:{x_min:81,x_max:1130,y_min:0,y_max:1456,ha:1456,leftSideBearing:81,advanceWidth:1210},M:{x_min:94,x_max:1888,y_min:0,y_max:1456,ha:1456,leftSideBearing:94,advanceWidth:1982},N:{x_min:83,x_max:1509,y_min:0,y_max:1456,ha:1456,leftSideBearing:83,advanceWidth:1592},O:{x_min:70,x_max:1281,y_min:-21,y_max:1477,ha:1498,leftSideBearing:70,advanceWidth:1351},P:{x_min:81,x_max:1242,y_min:0,y_max:1456,ha:1456,leftSideBearing:81,advanceWidth:1297},Q:{x_min:70,x_max:1348,y_min:-245,y_max:1477,ha:1722,leftSideBearing:70,advanceWidth:1376},R:{x_min:81,x_max:1285,y_min:0,y_max:1455,ha:1455,leftSideBearing:81,advanceWidth:1385},S:{x_min:115,x_max:1116,y_min:-21,y_max:1477,ha:1498,leftSideBearing:115,advanceWidth:1206},T:{x_min:96,x_max:1306,y_min:0,y_max:1456,ha:1456,leftSideBearing:96,advanceWidth:1406},U:{x_min:70,x_max:1452,y_min:-21,y_max:1456,ha:1477,leftSideBearing:70,advanceWidth:1522},V:{x_min:65,x_max:1443,y_min:0,y_max:1456,ha:1456,leftSideBearing:65,advanceWidth:1508},W:{x_min:72,x_max:2057,y_min:0,y_max:1456,ha:1456,leftSideBearing:72,advanceWidth:2129},X:{x_min:80,x_max:1449,y_min:0,y_max:1456,ha:1456,leftSideBearing:80,advanceWidth:1529},Y:{x_min:65,x_max:1396,y_min:0,y_max:1456,ha:1456,leftSideBearing:65,advanceWidth:1461},Z:{x_min:90,x_max:1107,y_min:0,y_max:1456,ha:1456,leftSideBearing:90,advanceWidth:1197},"[":{x_min:157,x_max:541,y_min:-312,y_max:1664,ha:1976,leftSideBearing:157,advanceWidth:573},"\\":{x_min:36,x_max:830,y_min:-125,y_max:1456,ha:1581,leftSideBearing:36,advanceWidth:841},"]":{x_min:23,x_max:408,y_min:-312,y_max:1664,ha:1976,leftSideBearing:23,advanceWidth:552},"^":{x_min:71,x_max:802,y_min:729,y_max:1456,ha:727,leftSideBearing:71,advanceWidth:864},_:{x_min:119,x_max:1041,y_min:-154,y_max:0,ha:154,leftSideBearing:119,advanceWidth:1168},"`":{x_min:40,x_max:456,y_min:1288,y_max:1560,ha:272,leftSideBearing:40,advanceWidth:496},a:{x_min:79,x_max:1053,y_min:-21,y_max:1102,ha:1123,leftSideBearing:79,advanceWidth:1132},b:{x_min:-16,x_max:1071,y_min:-21,y_max:1560,ha:1581,leftSideBearing:-16,advanceWidth:1145},c:{x_min:78,x_max:988,y_min:-21,y_max:1102,ha:1123,leftSideBearing:78,advanceWidth:1067},d:{x_min:78,x_max:1156,y_min:-21,y_max:1560,ha:1581,leftSideBearing:78,advanceWidth:1218},e:{x_min:74,x_max:980,y_min:-21,y_max:1102,ha:1123,leftSideBearing:74,advanceWidth:1059},f:{x_min:64,x_max:731,y_min:0,y_max:1581,ha:1581,leftSideBearing:64,advanceWidth:725},g:{x_min:78,x_max:1133,y_min:-437,y_max:1102,ha:1539,leftSideBearing:78,advanceWidth:1157},h:{x_min:49,x_max:1255,y_min:0,y_max:1560,ha:1560,leftSideBearing:49,advanceWidth:1315},i:{x_min:67,x_max:590,y_min:0,y_max:1560,ha:1560,leftSideBearing:67,advanceWidth:652},j:{x_min:-56,x_max:381,y_min:-437,y_max:1560,ha:1997,leftSideBearing:-56,advanceWidth:525},k:{x_min:64,x_max:1248,y_min:0,y_max:1560,ha:1560,leftSideBearing:64,advanceWidth:1287},l:{x_min:64,x_max:587,y_min:0,y_max:1560,ha:1560,leftSideBearing:64,advanceWidth:653},m:{x_min:74,x_max:1905,y_min:0,y_max:1102,ha:1102,leftSideBearing:74,advanceWidth:1977},n:{x_min:74,x_max:1278,y_min:0,y_max:1102,ha:1102,leftSideBearing:74,advanceWidth:1343},o:{x_min:78,x_max:1046,y_min:-21,y_max:1102,ha:1123,leftSideBearing:78,advanceWidth:1124},p:{x_min:34,x_max:1119,y_min:-416,y_max:1102,ha:1518,leftSideBearing:34,advanceWidth:1197},q:{x_min:78,x_max:1135,y_min:-416,y_max:1102,ha:1518,leftSideBearing:78,advanceWidth:1139},r:{x_min:72,x_max:808,y_min:0,y_max:1102,ha:1102,leftSideBearing:72,advanceWidth:854},s:{x_min:104,x_max:933,y_min:-21,y_max:1102,ha:1123,leftSideBearing:104,advanceWidth:1022},t:{x_min:24,x_max:678,y_min:-17,y_max:1343,ha:1360,leftSideBearing:24,advanceWidth:730},u:{x_min:52,x_max:1181,y_min:-21,y_max:1082,ha:1103,leftSideBearing:52,advanceWidth:1245},v:{x_min:26,x_max:1176,y_min:0,y_max:1082,ha:1082,leftSideBearing:26,advanceWidth:1206},w:{x_min:52,x_max:1777,y_min:0,y_max:1082,ha:1082,leftSideBearing:52,advanceWidth:1823},x:{x_min:42,x_max:1163,y_min:0,y_max:1082,ha:1082,leftSideBearing:42,advanceWidth:1203},y:{x_min:24,x_max:1172,y_min:-437,y_max:1082,ha:1519,leftSideBearing:24,advanceWidth:1192},z:{x_min:88,x_max:960,y_min:0,y_max:1082,ha:1082,leftSideBearing:88,advanceWidth:1032},"{":{x_min:63,x_max:671,y_min:-364,y_max:1597,ha:1961,leftSideBearing:63,advanceWidth:701},"|":{x_min:150,x_max:307,y_min:-270,y_max:1456,ha:1726,leftSideBearing:150,advanceWidth:451},"}":{x_min:27,x_max:635,y_min:-364,y_max:1597,ha:1961,leftSideBearing:27,advanceWidth:701},"~":{x_min:121,x_max:1257,y_min:401,y_max:803,ha:402,leftSideBearing:121,advanceWidth:1386}},fontFamily:"Roboto Slab",resolution:2048,generatedOn:"2020-06-15T19:12:58.120Z"};class Ri{static sortAndUnique(t,e,i){if(t.length>1){const s=[];let n;t.sort(e);for(let e=0;e<t.length;++e)0!==e&&i(t[e],n)||s.push(t[e]),n=t[e];return s}return t}static contains(t,e){let i=t.length;for(;i--;)if(t[i]===e)return!0;return!1}static getCanvasContext(t){if(!t)throw new f("BadArgument","Invalid canvas selector: "+t);const e=document.getElementById(t);if(!e||!e.getContext)throw new f("UnsupportedBrowserError","This browser does not support HTML5 Canvas");return e.getContext("2d")}static benchmark(t,e){const i=(new Date).getTime();e();S(t,(new Date).getTime()-i+"ms")}static stackTrace(){return(new Error).stack}}Ri.Flow=Fi;var Oi=function(t,e,i,s){return new(i||(i=Promise))((function(n,a){function o(t){try{h(s.next(t))}catch(t){a(t)}}function r(t){try{h(s.throw(t))}catch(t){a(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,r)}h((s=s.apply(t,e||[])).next())}))};const Li={Bravura:"./vexflow-font-bravura.js",Gonville:"./vexflow-font-gonville.js",Petaluma:"./vexflow-font-petaluma.js",Custom:"./vexflow-font-custom.js"};return Fi.fetchMusicFont=(t,e)=>Oi(void 0,void 0,void 0,(function*(){const i=M.load(t);if(i.hasData())return;if(!e){if(!(t in Li))throw new f("UnknownFont",`Music font ${t} does not exist.`);e=Li[t]}let s;if("string"==typeof e){const i=yield import(e),n=_().VexFlowFont;s=void 0!==n&&void 0!==n[t]?n[t]:i.Font}else s=e;i.setData(s.data),i.setMetrics(s.metrics)})),function(){{const t=Bi,{fontFamily:e,resolution:i,glyphs:s}=t;M.load(e,t);const n="b";ht.registerInfo({family:e,resolution:i,glyphs:s,maxSizeGlyph:n,monospaced:!1,bold:!1,italic:!1,superscriptOffset:.66,subscriptOffset:.66,serifs:!0,description:"Text font to pair with the Bravura / Gonville music fonts."})}{const t=Mi,{fontFamily:e,resolution:i,glyphs:s}=t;M.load(e,t);const n="b";ht.registerInfo({family:e,resolution:i,glyphs:s,maxSizeGlyph:n,monospaced:!1,bold:!1,italic:!1,superscriptOffset:.66,subscriptOffset:.66,serifs:!1,description:"Text font to pair with the Petaluma music font."})}}(),e=e.default})()}));
6
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Vex=e():t.Vex=e()}("undefined"!=typeof window?window:"undefined"!=typeof globalThis?globalThis:this,(function(){return(()=>{"use strict";var t={d:(e,i)=>{for(var s in i)t.o(i,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:i[s]})}};t.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),t.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),t.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var e={};t.d(e,{default:()=>i});var i={};function s(t,e,i=!0){if("object"!=typeof t||null===t)return!1;let s=t.constructor;if(i){for(;null!==t;){if(s=t.constructor,"CATEGORY"in s&&s.CATEGORY===e)return!0;t=Object.getPrototypeOf(t)}return!1}return"CATEGORY"in s&&s.CATEGORY===e}t.r(i),t.d(i,{Accidental:()=>st,Annotation:()=>lt,AnnotationHorizontalJustify:()=>ct,AnnotationVerticalJustify:()=>dt,Articulation:()=>xt,BEAM_BOTH:()=>Le,BEAM_LEFT:()=>Re,BEAM_RIGHT:()=>Oe,BarNote:()=>Ft,Barline:()=>Pt,BarlineType:()=>vt,Beam:()=>Ie,Bend:()=>Mt,BoundingBox:()=>C,BoundingBoxComputation:()=>N,Builder:()=>$e,CanvasContext:()=>Qt,Category:()=>m,ChordSymbol:()=>Rt,ChordSymbolHorizontalJustify:()=>Et,ChordSymbolVerticalJustify:()=>Ct,Clef:()=>ue,ClefNote:()=>We,Crescendo:()=>Ge,Curve:()=>He,CurvePosition:()=>Ue,Dot:()=>Ot,EasyScore:()=>Ze,EasyScoreGrammar:()=>ze,Element:()=>O,Factory:()=>vi,Flow:()=>Fi,Font:()=>M,FontStyle:()=>D,FontWeight:()=>k,Formatter:()=>Pe,Fraction:()=>v,FretHandFinger:()=>Lt,GhostNote:()=>ei,Glyph:()=>U,GlyphNote:()=>ii,GraceNote:()=>si,GraceNoteGroup:()=>Ut,GraceTabNote:()=>Ei,KeyManager:()=>Ci,KeySigNote:()=>ni,KeySignature:()=>pe,Modifier:()=>H,ModifierContext:()=>ge,ModifierPosition:()=>I,MultiMeasureRest:()=>oi,Music:()=>Y,Note:()=>bt,NoteHead:()=>Vt,NoteSubGroup:()=>Ht,Ornament:()=>jt,OutlineCode:()=>L,Parenthesis:()=>Xt,Parser:()=>Xe,PedalMarking:()=>hi,Piece:()=>Ke,Registry:()=>R,RenderContext:()=>St,Renderer:()=>re,RendererBackends:()=>se,RendererLineEndType:()=>ne,RepeatNote:()=>di,Repetition:()=>me,RuntimeError:()=>f,SVGContext:()=>ie,Stave:()=>Ee,StaveConnector:()=>Ne,StaveHairpin:()=>Ni,StaveLine:()=>gi,StaveModifier:()=>At,StaveModifierPosition:()=>wt,StaveNote:()=>$t,StaveSection:()=>fe,StaveTempo:()=>_e,StaveText:()=>Se,StaveTie:()=>It,Stem:()=>nt,StemmableNote:()=>zt,StringNumber:()=>he,Stroke:()=>ce,SymbolModifiers:()=>kt,SymbolTypes:()=>Nt,System:()=>ui,TabNote:()=>pi,TabSlide:()=>ki,TabStave:()=>mi,TabTie:()=>Wt,TextBracket:()=>xi,TextBracketPosition:()=>_i,TextDynamics:()=>yi,TextFormatter:()=>ht,TextJustification:()=>ae,TextNote:()=>xe,TickContext:()=>Yt,Tickable:()=>Tt,TimeSigNote:()=>Ti,TimeSignature:()=>be,TimeSignatureGlyph:()=>Te,Tremolo:()=>Di,Tuning:()=>Ai,Tuplet:()=>Me,TupletLocation:()=>Fe,Vex:()=>Ri,Vibrato:()=>de,VibratoBracket:()=>bi,Voice:()=>Gt,VoiceMode:()=>Dt,Volta:()=>ye,VoltaType:()=>oe,defined:()=>x,drawDot:()=>yt,globalObject:()=>_,isAccidental:()=>n,isAnnotation:()=>a,isBarline:()=>o,isCategory:()=>s,isDot:()=>r,isGraceNote:()=>h,isGraceNoteGroup:()=>c,isHTMLCanvas:()=>Jt,isHTMLDiv:()=>qt,isNote:()=>d,isRenderContext:()=>l,isStaveNote:()=>g,isStemmableNote:()=>u,isTabNote:()=>p,log:()=>S,midLine:()=>T,normalizeAngle:()=>w,prefix:()=>b,warn:()=>y});const n=t=>s(t,m.Accidental),a=t=>s(t,m.Annotation),o=t=>s(t,m.Barline),r=t=>s(t,m.Dot),h=t=>s(t,m.GraceNote),c=t=>s(t,m.GraceNoteGroup),d=t=>s(t,m.Note),l=t=>s(t,m.RenderContext),g=t=>s(t,m.StaveNote),u=t=>s(t,m.StemmableNote),p=t=>s(t,m.TabNote);var m;!function(t){t.Accidental="Accidental",t.Annotation="Annotation",t.Articulation="Articulation",t.Barline="Barline",t.BarNote="BarNote",t.Beam="Beam",t.Bend="Bend",t.ChordSymbol="ChordSymbol",t.Clef="Clef",t.ClefNote="ClefNote",t.Crescendo="Crescendo",t.Curve="Curve",t.Dot="Dot",t.Element="Element",t.Fraction="Fraction",t.FretHandFinger="FretHandFinger",t.GhostNote="GhostNote",t.Glyph="Glyph",t.GlyphNote="GlyphNote",t.GraceNote="GraceNote",t.GraceNoteGroup="GraceNoteGroup",t.GraceTabNote="GraceTabNote",t.KeySignature="KeySignature",t.KeySigNote="KeySigNote",t.Modifier="Modifier",t.MultiMeasureRest="MultiMeasureRest",t.Note="Note",t.NoteHead="NoteHead",t.NoteSubGroup="NoteSubGroup",t.Ornament="Ornament",t.Parenthesis="Parenthesis",t.PedalMarking="PedalMarking",t.RenderContext="RenderContext",t.RepeatNote="RepeatNote",t.Repetition="Repetition",t.Stave="Stave",t.StaveConnector="StaveConnector",t.StaveHairpin="StaveHairpin",t.StaveLine="StaveLine",t.StaveModifier="StaveModifier",t.StaveNote="StaveNote",t.StaveSection="StaveSection",t.StaveTempo="StaveTempo",t.StaveText="StaveText",t.StaveTie="StaveTie",t.Stem="Stem",t.StemmableNote="StemmableNote",t.StringNumber="StringNumber",t.Stroke="Stroke",t.System="System",t.TabNote="TabNote",t.TabSlide="TabSlide",t.TabStave="TabStave",t.TabTie="TabTie",t.TextBracket="TextBracket",t.TextDynamics="TextDynamics",t.TextNote="TextNote",t.Tickable="Tickable",t.TimeSignature="TimeSignature",t.TimeSigNote="TimeSigNote",t.Tremolo="Tremolo",t.Tuplet="Tuplet",t.Vibrato="Vibrato",t.VibratoBracket="VibratoBracket",t.Voice="Voice",t.Volta="Volta"}(m||(m={}));class f extends Error{constructor(t,e=""){super("[RuntimeError] "+t+": "+e),this.code=t}}function _(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==t.g?t.g:Function("return this")()}function x(t,e="undefined",i=""){if(void 0===t)throw new f(e,i);return t}function S(t,...e){if(!e)return;const i=Array.prototype.slice.call(e).join(" ");_().console.log(t+": "+i)}function y(...t){const e=t.join(" "),i=new Error;_().console.log("Warning: ",e,i.stack)}function T(t,e){let i=e+(t-e)/2;var s,n;return i%2>0&&(i=((s=10*i)%(n=5)>=n/2?parseInt(""+s/n,10)*n+n:parseInt(""+s/n,10)*n)/10),i}function b(t){return`vf-${t}`}function w(t){return(t%=2*Math.PI)<0&&(t+=2*Math.PI),t}class v{constructor(t,e){this.numerator=1,this.denominator=1,this.set(t,e)}static get CATEGORY(){return m.Fraction}static GCD(t,e){if("number"!=typeof t||Number.isNaN(t)||"number"!=typeof e||Number.isNaN(e))throw new f("BadArgument",`Invalid numbers: ${t}, ${e}`);let i;for(;0!==e;)i=e,e=t%e,t=i;return t}static LCM(t,e){return t*e/v.GCD(t,e)}static LCMM(t){return 0===t.length?0:1===t.length?t[0]:2===t.length?v.LCM(t[0],t[1]):v.LCM(t.shift(),v.LCMM(t))}set(t=1,e=1){return this.numerator=t,this.denominator=e,this}value(){return this.numerator/this.denominator}simplify(){let t=this.numerator,e=this.denominator;const i=v.GCD(t,e);return t/=i,e/=i,e<0&&(e=-e,t=-t),this.set(t,e)}add(t=0,e=1){const[i,s]=E(t,e),n=v.LCM(this.denominator,s),a=n/this.denominator,o=n/s,r=this.numerator*a+i*o;return this.set(r,n)}subtract(t=0,e=1){const[i,s]=E(t,e),n=v.LCM(this.denominator,s),a=n/this.denominator,o=n/s,r=this.numerator*a-i*o;return this.set(r,n)}multiply(t=1,e=1){const[i,s]=E(t,e);return this.set(this.numerator*i,this.denominator*s)}divide(t=1,e=1){const[i,s]=E(t,e);return this.set(this.numerator*s,this.denominator*i)}equals(t){const e=v.__staticFractionA.copy(t).simplify(),i=v.__staticFractionB.copy(this).simplify();return e.numerator===i.numerator&&e.denominator===i.denominator}greaterThan(t){const e=v.__staticFractionB.copy(this);return e.subtract(t),e.numerator>0}greaterThanEquals(t){const e=v.__staticFractionB.copy(this);return e.subtract(t),e.numerator>=0}lessThan(t){return!this.greaterThanEquals(t)}lessThanEquals(t){return!this.greaterThan(t)}clone(){return new v(this.numerator,this.denominator)}copy(t){return"number"==typeof t?this.set(t,1):this.set(t.numerator,t.denominator)}quotient(){return Math.floor(this.numerator/this.denominator)}remainder(){return this.numerator%this.denominator}makeAbs(){return this.denominator=Math.abs(this.denominator),this.numerator=Math.abs(this.numerator),this}toString(){return`${this.numerator}/${this.denominator}`}toSimplifiedString(){return v.__staticFractionTmp.copy(this).simplify().toString()}toMixedString(){let t="";const e=this.quotient(),i=v.__staticFractionTmp.copy(this);return e<0&&i.makeAbs(),0!==e?(t+=e,0!==i.numerator&&(t+=` ${i.toSimplifiedString()}`)):t=0===i.numerator?"0":i.toSimplifiedString(),t}parse(t){const e=t.split("/"),i=parseInt(e[0],10),s=e[1]?parseInt(e[1],10):1;return this.set(i,s)}}function E(t,e=1){return"number"==typeof t?[t,e]:[t.numerator,t.denominator]}v.__staticFractionA=new v,v.__staticFractionB=new v,v.__staticFractionTmp=new v;class C{constructor(t,e,i,s){this.x=t,this.y=e,this.w=i,this.h=s}static copy(t){return new C(t.x,t.y,t.w,t.h)}getX(){return this.x}getY(){return this.y}getW(){return this.w}getH(){return this.h}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setW(t){return this.w=t,this}setH(t){return this.h=t,this}move(t,e){return this.x+=t,this.y+=e,this}clone(){return C.copy(this)}mergeWith(t){const e=t,i=this.x<e.x?this.x:e.x,s=this.y<e.y?this.y:e.y,n=Math.max(this.x+this.w,e.x+e.w)-i,a=Math.max(this.y+this.h,e.y+e.h)-s;return this.x=i,this.y=s,this.w=n,this.h=a,this}}class N{constructor(){this.x1=Number.NaN,this.y1=Number.NaN,this.x2=Number.NaN,this.y2=Number.NaN}getX1(){return this.x1}getY1(){return this.y1}width(){return this.x2-this.x1}height(){return this.y2-this.y1}addPoint(t,e){(isNaN(this.x1)||t<this.x1)&&(this.x1=t),(isNaN(this.x2)||t>this.x2)&&(this.x2=t),(isNaN(this.y1)||e<this.y1)&&(this.y1=e),(isNaN(this.y2)||e>this.y2)&&(this.y2=e)}addX(t){this.addPoint(t,this.y1)}addY(t){this.addPoint(this.x1,t)}addQuadraticCurve(t,e,i,s,n,a){this.addPoint(t,e),this.addPoint(n,a);const o=i-t;let r=o-(n-i);if(0!=r){const e=o/r;if(e>0&&e<1){const s=1-e;this.addX(s*s*t+2*s*e*i+e*e*n)}}const h=s-e;if(r=h-(a-s),0!=r){const t=h/r;if(t>0&&t<1){const i=1-t;this.addY(i*i*e+2*i*t*s+t*t*a)}}}addBezierCurve(t,e,i,s,n,a,o,r){const h=[t,e],c=[i,s],d=[n,a],l=[o,r];let g;this.addPoint(h[0],h[1]),this.addPoint(l[0],l[1]);const u=(t,e)=>Math.pow(1-t,3)*h[e]+3*Math.pow(1-t,2)*t*c[e]+3*(1-t)*Math.pow(t,2)*d[e]+Math.pow(t,3)*l[e];for(g=0;g<=1;g++){const t=6*h[g]-12*c[g]+6*d[g],e=-3*h[g]+9*c[g]-9*d[g]+3*l[g],i=3*c[g]-3*h[g];if(0===e){if(0===t)continue;const e=-i/t;0<e&&e<1&&(0===g&&this.addX(u(e,g)),1===g&&this.addY(u(e,g)));continue}const s=Math.pow(t,2)-4*i*e;if(s<0)continue;const n=(-t+Math.sqrt(s))/(2*e);0<n&&n<1&&(0===g&&this.addX(u(n,g)),1===g&&this.addY(u(n,g)));const a=(-t-Math.sqrt(s))/(2*e);0<a&&a<1&&(0===g&&this.addX(u(a,g)),1===g&&this.addY(u(a,g)))}}}var k,D,A=function(t,e,i,s){return new(i||(i=Promise))((function(n,a){function o(t){try{h(s.next(t))}catch(t){a(t)}}function r(t){try{h(s.throw(t))}catch(t){a(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,r)}h((s=s.apply(t,e||[])).next())}))};let P;!function(t){t.NORMAL="normal",t.BOLD="bold"}(k||(k={})),function(t){t.NORMAL="normal",t.ITALIC="italic"}(D||(D={}));const F={};class M{constructor(t){this.name=t}static convertSizeToPixelValue(t=M.SIZE){var e;if("number"==typeof t)return t*M.scaleToPxFrom.pt;{const i=parseFloat(t);if(isNaN(i))return 0;const s=t.replace(/[\d.\s]/g,"").toLowerCase();return i*(null!==(e=M.scaleToPxFrom[s])&&void 0!==e?e:1)}}static convertSizeToPointValue(t=M.SIZE){var e;if("number"==typeof t)return t;{const i=parseFloat(t);if(isNaN(i))return 0;const s=t.replace(/[\d.\s]/g,"").toLowerCase();return i*((null!==(e=M.scaleToPxFrom[s])&&void 0!==e?e:1)/M.scaleToPxFrom.pt)}}static validate(t,e,i,s){if("string"==typeof t&&void 0===e&&void 0===i&&void 0===s)return M.fromCSSString(t);let n;return"object"==typeof t?(n=t.family,e=t.size,i=t.weight,s=t.style):n=t,n=null!=n?n:M.SANS_SERIF,e=null!=e?e:M.SIZE+"pt",i=null!=i?i:k.NORMAL,s=null!=s?s:D.NORMAL,""===i&&(i=k.NORMAL),""===s&&(s=D.NORMAL),"number"==typeof e&&(e=`${e}pt`),"number"==typeof i&&(i=i.toString()),{family:n,size:e,weight:i,style:s}}static fromCSSString(t){P||(P=document.createElement("span")),P.style.font=t;const{fontFamily:e,fontSize:i,fontWeight:s,fontStyle:n}=P.style;return{family:e,size:i,weight:s,style:n}}static toCSSString(t){var e;if(!t)return"";let i;const s=t.style;let n;i=s===D.NORMAL||""===s||void 0===s?"":s.trim()+" ";const a=t.weight;let o;n=a===k.NORMAL||""===a||void 0===a?"":"number"==typeof a?a+" ":a.trim()+" ";const r=t.size;o=void 0===r?M.SIZE+"pt ":"number"==typeof r?r+"pt ":r.trim()+" ";return`${i}${n}${o}${null!==(e=t.family)&&void 0!==e?e:M.SANS_SERIF}`}static scaleSize(t,e){if("number"==typeof t)return t*e;return`${parseFloat(t)*e}${t.replace(/[\d.\s]/g,"")}`}static isBold(t){if(t){if("number"==typeof t)return t>=600;{const e=parseInt(t,10);return isNaN(e)?"bold"===t.toLowerCase():e>=600}}return!1}static isItalic(t){return!!t&&t.toLowerCase()===D.ITALIC}static loadWebFont(t,e,i=!0){return A(this,void 0,void 0,(function*(){const s=new FontFace(t,(i?`url(${e}2) format('woff2'), `:"")+`url(${e}) format('woff')`);return yield s.load(),document.fonts.add(s),s}))}static loadWebFonts(){return A(this,void 0,void 0,(function*(){const t=M.WEB_FONT_HOST,e=M.WEB_FONT_FILES;for(const i in e){const s=e[i];M.loadWebFont(i,t+s)}}))}static load(t,e,i){let s=F[t];return s||(s=new M(t),F[t]=s),e&&s.setData(e),i&&s.setMetrics(i),s}getName(){return this.name}getData(){return x(this.data,"FontError","Missing font data")}getMetrics(){return x(this.metrics,"FontError","Missing metrics")}setData(t){this.data=t}setMetrics(t){this.metrics=t}hasData(){return void 0!==this.data}getResolution(){return this.getData().resolution}getGlyphs(){return this.getData().glyphs}lookupMetric(t,e){const i=t.split(".");let s=this.getMetrics();for(let t=0;t<i.length;t++){const n=s[i[t]];if(void 0===n)return e;s=n}return s}toString(){return"["+this.name+" Font]"}}M.SANS_SERIF="Arial, sans-serif",M.SERIF="Times New Roman, serif",M.SIZE=10,M.scaleToPxFrom={pt:4/3,px:1,em:16,"%":.16,in:96,mm:96/25.4,cm:96/2.54},M.WEB_FONT_HOST="https://unpkg.com/vexflow-fonts@1.0.3/",M.WEB_FONT_FILES={"Roboto Slab":"robotoslab/RobotoSlab-Medium_2.001.woff",PetalumaScript:"petaluma/PetalumaScript_1.10_FS.woff"};class B{constructor(){this.id={},this.type={},this.class={}}}class R{constructor(){this.index=new B}static getDefaultRegistry(){return R.defaultRegistry}static enableDefaultRegistry(t){R.defaultRegistry=t}static disableDefaultRegistry(){R.defaultRegistry=void 0}clear(){return this.index=new B,this}setIndexValue(t,e,i,s){const n=this.index;n[t][e]||(n[t][e]={}),n[t][e][i]=s}updateIndex({id:t,name:e,value:i,oldValue:s}){const n=this.getElementById(t);void 0!==s&&this.index[e][s]&&delete this.index[e][s][t],i&&n&&this.setIndexValue(e,i,n.getAttribute("id"),n)}register(t,e){if(!(e=e||t.getAttribute("id")))throw new f("Can't add element without `id` attribute to registry");return t.setAttribute("id",e),this.setIndexValue("id",e,e,t),this.updateIndex({id:e,name:"type",value:t.getAttribute("type"),oldValue:void 0}),t.onRegister(this),this}getElementById(t){var e,i;return null===(i=null===(e=this.index.id)||void 0===e?void 0:e[t])||void 0===i?void 0:i[t]}getElementsByAttribute(t,e){const i=this.index[t];if(i){const t=i[e];if(t){return Object.keys(t).map((e=>t[e]))}}return[]}getElementsByType(t){return this.getElementsByAttribute("type",t)}getElementsByClass(t){return this.getElementsByAttribute("class",t)}onUpdate(t){return["id","type","class"].includes(t.name)&&this.updateIndex(t),this}}class O{constructor(){var t;this.attrs={id:O.newID(),el:void 0,type:this.getCategory(),classes:{}},this.rendered=!1,null===(t=R.getDefaultRegistry())||void 0===t||t.register(this)}static get CATEGORY(){return m.Element}static newID(){return"auto"+O.ID++}getCategory(){return this.constructor.CATEGORY}setStyle(t){return this.style=t,this}getStyle(){return this.style}applyStyle(t=this.context,e=this.getStyle()){return e&&t?(t.save(),e.shadowColor&&t.setShadowColor(e.shadowColor),e.shadowBlur&&t.setShadowBlur(e.shadowBlur),e.fillStyle&&t.setFillStyle(e.fillStyle),e.strokeStyle&&t.setStrokeStyle(e.strokeStyle),e.lineWidth&&t.setLineWidth(e.lineWidth),this):this}restoreStyle(t=this.context,e=this.getStyle()){return e&&t?(t.restore(),this):this}drawWithStyle(){this.checkContext(),this.applyStyle(),this.draw(),this.restoreStyle()}hasClass(t){return!0===this.attrs.classes[t]}addClass(t){var e;return this.attrs.classes[t]=!0,null===(e=this.registry)||void 0===e||e.onUpdate({id:this.attrs.id,name:"class",value:t,oldValue:void 0}),this}removeClass(t){var e;return delete this.attrs.classes[t],null===(e=this.registry)||void 0===e||e.onUpdate({id:this.attrs.id,name:"class",value:void 0,oldValue:t}),this}onRegister(t){return this.registry=t,this}isRendered(){return this.rendered}setRendered(t=!0){return this.rendered=t,this}getAttributes(){return this.attrs}getAttribute(t){return this.attrs[t]}setAttribute(t,e){var i;const s=this.attrs.id,n=this.attrs[t];return this.attrs[t]=e,null===(i=this.registry)||void 0===i||i.onUpdate({id:s,name:t,value:e,oldValue:n}),this}getBoundingBox(){return this.boundingBox}getContext(){return this.context}setContext(t){return this.context=t,this}checkContext(){return x(this.context,"NoContext","No rendering context attached to instance.")}set font(t){this.setFont(t)}get font(){return M.toCSSString(this.textFont)}setFont(t,e,i,s){const n=this.constructor.TEXT_FONT,a="object"==typeof t,o="string"==typeof t,r=void 0===t,h=void 0===e&&void 0===i&&void 0===s;return this.textFont=a?Object.assign(Object.assign({},n),t):o&&h?M.fromCSSString(t):r&&h?Object.assign({},n):M.validate(null!=t?t:n.family,null!=e?e:n.size,null!=i?i:n.weight,null!=s?s:n.style),this}getFont(){return this.textFont||this.resetFont(),M.toCSSString(this.textFont)}resetFont(){this.setFont()}get fontInfo(){return this.textFont||this.resetFont(),Object.assign({},this.textFont)}set fontInfo(t){this.setFont(t)}setFontSize(t){const e=this.fontInfo;return this.setFont(e.family,t,e.weight,e.style),this}getFontSize(){return this.fontSize}set fontSize(t){this.setFontSize(t)}get fontSize(){let t=this.fontInfo.size;return"number"==typeof t&&(t=`${t}pt`),t}get fontSizeInPoints(){return M.convertSizeToPointValue(this.fontSize)}get fontSizeInPixels(){return M.convertSizeToPixelValue(this.fontSize)}get fontStyle(){return this.fontInfo.style}set fontStyle(t){const e=this.fontInfo;this.setFont(e.family,e.size,e.weight,t)}get fontWeight(){return this.fontInfo.weight+""}set fontWeight(t){const e=this.fontInfo;this.setFont(e.family,e.size,t,e.style)}}var L,I;O.ID=1e3,O.TEXT_FONT={family:M.SANS_SERIF,size:M.SIZE,weight:k.NORMAL,style:D.NORMAL},function(t){t[t.MOVE=0]="MOVE",t[t.LINE=1]="LINE",t[t.QUADRATIC=2]="QUADRATIC",t[t.BEZIER=3]="BEZIER"}(L||(L={}));class W{constructor(t,e,i){this.point=-1,this.metrics=U.loadMetrics(t,e,i),this.bbox=U.getOutlineBoundingBox(this.metrics.outline,this.metrics.scale,this.metrics.x_shift,this.metrics.y_shift),i&&(this.point=U.lookupFontMetric(this.metrics.font,i,e,"point",-1))}}class G{constructor(t,e,i,s){this.outline=t,this.originX=e,this.originY=i,this.scale=s,this.i=0}done(){return this.i>=this.outline.length}next(){return this.outline[this.i++]}nextX(){return this.originX+this.outline[this.i++]*this.scale}nextY(){return this.originY-this.outline[this.i++]*this.scale}static parse(t){const e=[],i=t.split(" ");let s=0;for(;s<i.length;)switch(i[s++]){case"m":e.push(L.MOVE,parseInt(i[s++]),parseInt(i[s++]));break;case"l":e.push(L.LINE,parseInt(i[s++]),parseInt(i[s++]));break;case"q":e.push(L.QUADRATIC,parseInt(i[s++]),parseInt(i[s++]),parseInt(i[s++]),parseInt(i[s++]));break;case"b":e.push(L.BEZIER,parseInt(i[s++]),parseInt(i[s++]),parseInt(i[s++]),parseInt(i[s++]),parseInt(i[s++]),parseInt(i[s++]))}return e}}class U extends O{constructor(t,e,i){super(),this.bbox=new C(0,0,0,0),this.topGlyphs=[],this.botGlyphs=[],this.options={},this.scale=1,this.code=t,this.point=e,this.originShift={x:0,y:0},this.x_shift=0,this.y_shift=0,i?this.setOptions(i):this.reset()}static get CATEGORY(){return m.Glyph}static lookupFontMetric(t,e,i,s,n){let a=t.lookupMetric(`glyphs.${e}.${i}.${s}`,void 0);return void 0===a&&(a=t.lookupMetric(`glyphs.${e}.${s}`,n)),a}static lookupGlyph(t,e){let i,s;x(t,"BadFontStack","Font stack is misconfigured");for(let n=0;n<t.length;n++)if(s=t[n],i=s.getGlyphs()[e],i)return{glyph:i,font:s};throw new f("BadGlyph",`Glyph ${e} does not exist in font.`)}static loadMetrics(t,e,i){const{glyph:s,font:n}=U.lookupGlyph(t,e);if(!s.o)throw new f("BadGlyph",`Glyph ${e} has no outline defined.`);let a=0,o=0,r=1;i&&n&&(a=U.lookupFontMetric(n,i,e,"shiftX",0),o=U.lookupFontMetric(n,i,e,"shiftY",0),r=U.lookupFontMetric(n,i,e,"scale",1));const h=s.x_min,c=s.x_max,d=s.ha;return s.cached_outline||(s.cached_outline=G.parse(s.o)),{x_min:h,x_max:c,x_shift:a,y_shift:o,scale:r,ha:d,outline:s.cached_outline,font:n,width:c-h,height:d}}static renderGlyph(t,e,i,s,n,a){var o;const r=U.cache.lookup(n,null==a?void 0:a.category),h=r.metrics;-1!=r.point&&(s=r.point);const c=null!==(o=null==a?void 0:a.scale)&&void 0!==o?o:1,d=72*s/(100*h.font.getResolution())*h.scale*c;return U.renderOutline(t,h.outline,d,e+h.x_shift*c,i+h.y_shift*c),h}static renderOutline(t,e,i,s,n){const a=new G(e,s,n,i);let o,r;for(t.beginPath();!a.done();)switch(a.next()){case L.MOVE:t.moveTo(a.nextX(),a.nextY());break;case L.LINE:t.lineTo(a.nextX(),a.nextY());break;case L.QUADRATIC:o=a.nextX(),r=a.nextY(),t.quadraticCurveTo(a.nextX(),a.nextY(),o,r);break;case L.BEZIER:o=a.nextX(),r=a.nextY(),t.bezierCurveTo(a.nextX(),a.nextY(),a.nextX(),a.nextY(),o,r)}t.fill()}static getOutlineBoundingBox(t,e,i,s){const n=new G(t,i,s,e),a=new N;let o,r,h=i,c=s;for(;!n.done();)switch(n.next()){case L.MOVE:h=n.nextX(),c=n.nextY();break;case L.LINE:a.addPoint(h,c),h=n.nextX(),c=n.nextY(),a.addPoint(h,c);break;case L.QUADRATIC:o=n.nextX(),r=n.nextY(),a.addQuadraticCurve(h,c,n.nextX(),n.nextY(),o,r),h=o,c=r;break;case L.BEZIER:o=n.nextX(),r=n.nextY(),a.addBezierCurve(h,c,n.nextX(),n.nextY(),n.nextX(),n.nextY(),o,r),h=o,c=r}return new C(a.getX1(),a.getY1(),a.width(),a.height())}static getWidth(t,e,i){const s=U.cache.lookup(t,i);-1!=s.point&&(e=s.point);const n=72*e/(100*s.metrics.font.getResolution());return s.bbox.getW()*n}draw(...t){}getCode(){return this.code}setOptions(t){this.options=Object.assign(Object.assign({},this.options),t),this.reset()}setPoint(t){return this.point=t,this}setStave(t){return this.stave=t,this}getXShift(){return this.x_shift}setXShift(t){return this.x_shift=t,this}getYshift(){return this.y_shift}setYShift(t){return this.y_shift=t,this}reset(){const t=U.cache.lookup(this.code,this.options.category);this.metrics=t.metrics,-1!=t.point&&(this.point=t.point),this.scale=72*this.point/(100*this.metrics.font.getResolution()),this.bbox=new C(t.bbox.getX()*this.scale,t.bbox.getY()*this.scale,t.bbox.getW()*this.scale,t.bbox.getH()*this.scale)}checkMetrics(){return x(this.metrics,"BadGlyph",`Glyph ${this.code} is not initialized.`)}getMetrics(){const t=this.checkMetrics(),e=t.scale;return{x_min:t.x_min*this.scale*e,x_max:t.x_max*this.scale*e,width:this.bbox.getW(),height:this.bbox.getH(),scale:this.scale*e,x_shift:t.x_shift,y_shift:t.y_shift,outline:t.outline,font:t.font,ha:t.ha}}setOriginX(t){const{bbox:e}=this,i=(t-Math.abs(e.getX()/e.getW()))*e.getW();this.originShift.x=-i}setOriginY(t){const{bbox:e}=this,i=(t-Math.abs(e.getY()/e.getH()))*e.getH();this.originShift.y=-i}setOrigin(t,e){this.setOriginX(t),this.setOriginY(e)}render(t,e,i){const s=this.checkMetrics(),n=s.outline,a=this.scale*s.scale;this.setRendered(),this.applyStyle(t);const o=e+this.originShift.x+s.x_shift,r=i+this.originShift.y+s.y_shift;U.renderOutline(t,n,a,o,r),this.restoreStyle(t)}checkStave(){return x(this.stave,"NoStave","No stave attached to instance.")}renderToStave(t){const e=this.checkContext(),i=this.checkMetrics(),s=this.checkStave(),n=i.outline,a=this.scale*i.scale;this.setRendered(),this.applyStyle();const o=t+this.x_shift+i.x_shift,r=s.getYForGlyphs()+this.y_shift+i.y_shift;U.renderOutline(e,n,a,o,r),this.restoreStyle()}}U.cache=new class{constructor(){this.cache=new Map}lookup(t,e){let i=this.cache.get(U.CURRENT_CACHE_KEY);void 0===i&&(i={},this.cache.set(U.CURRENT_CACHE_KEY,i));const s=e?`${t}%${e}`:t;let n=i[s];return void 0===n&&(n=new W(U.MUSIC_FONT_STACK,t,e),i[s]=n),n}},U.CURRENT_CACHE_KEY="",U.MUSIC_FONT_STACK=[],function(t){t[t.CENTER=0]="CENTER",t[t.LEFT=1]="LEFT",t[t.RIGHT=2]="RIGHT",t[t.ABOVE=3]="ABOVE",t[t.BELOW=4]="BELOW"}(I||(I={}));class H extends O{constructor(){super(),this.width=0,this.text_line=0,this.position=H.Position.LEFT,this.x_shift=0,this.y_shift=0,this.spacingFromNextModifier=0}static get CATEGORY(){return m.Modifier}static get Position(){return I}static get PositionString(){return{center:I.CENTER,above:I.ABOVE,below:I.BELOW,left:I.LEFT,right:I.RIGHT}}reset(){}getWidth(){return this.width}setWidth(t){return this.width=t,this}getNote(){return x(this.note,"NoNote","Modifier has no note.")}checkAttachedNote(){const t=this.getCategory();return x(this.index,"NoIndex",`Can't draw ${t} without an index.`),x(this.note,"NoNote",`Can't draw ${t} without a note.`)}setNote(t){return this.note=t,this}getIndex(){return this.index}checkIndex(){return x(this.index,"NoIndex","Modifier has an invalid index.")}setIndex(t){return this.index=t,this}getModifierContext(){return this.modifierContext}checkModifierContext(){return x(this.modifierContext,"NoModifierContext","Modifier Context Required")}setModifierContext(t){return this.modifierContext=t,this}getPosition(){return this.position}setPosition(t){return this.position="string"==typeof t?H.PositionString[t]:t,this.reset(),this}setTextLine(t){return this.text_line=t,this}setYShift(t){return this.y_shift=t,this}setSpacingFromNextModifier(t){this.spacingFromNextModifier=t}getSpacingFromNextModifier(){return this.spacingFromNextModifier}setXShift(t){return this.x_shift=0,this.position===H.Position.LEFT?this.x_shift-=t:this.x_shift+=t,this}getXShift(){return this.x_shift}draw(){throw this.checkContext(),new f("NotImplemented","draw() not implemented for this modifier.")}alignSubNotesWithNote(t,e){const i=e.getTickContext(),s=i.getMetrics(),n=e.getStave(),a=i.getX()-s.modLeftPx-s.modRightPx+this.getSpacingFromNextModifier();t.forEach((t=>{const e=t.getTickContext();n&&t.setStave(n),e.setXOffset(a)}))}}class Y{static get NUM_TONES(){return this.canonical_notes.length}static get roots(){return["c","d","e","f","g","a","b"]}static get root_values(){return[0,2,4,5,7,9,11]}static get root_indices(){return{c:0,d:1,e:2,f:3,g:4,a:5,b:6}}static get canonical_notes(){return["c","c#","d","d#","e","f","f#","g","g#","a","a#","b"]}static get diatonic_intervals(){return["unison","m2","M2","m3","M3","p4","dim5","p5","m6","M6","b7","M7","octave"]}static get diatonic_accidentals(){return{unison:{note:0,accidental:0},m2:{note:1,accidental:-1},M2:{note:1,accidental:0},m3:{note:2,accidental:-1},M3:{note:2,accidental:0},p4:{note:3,accidental:0},dim5:{note:4,accidental:-1},p5:{note:4,accidental:0},m6:{note:5,accidental:-1},M6:{note:5,accidental:0},b7:{note:6,accidental:-1},M7:{note:6,accidental:0},octave:{note:7,accidental:0}}}static get intervals(){return{u:0,unison:0,m2:1,b2:1,min2:1,S:1,H:1,2:2,M2:2,maj2:2,T:2,W:2,m3:3,b3:3,min3:3,M3:4,3:4,maj3:4,4:5,p4:5,"#4":6,b5:6,aug4:6,dim5:6,5:7,p5:7,"#5":8,b6:8,aug5:8,6:9,M6:9,maj6:9,b7:10,m7:10,min7:10,dom7:10,M7:11,maj7:11,8:12,octave:12}}static get scales(){return{major:[2,2,1,2,2,2,1],minor:[2,1,2,2,1,2,2],ionian:[2,2,1,2,2,2,1],dorian:[2,1,2,2,2,1,2],phyrgian:[1,2,2,2,1,2,2],lydian:[2,2,2,1,2,2,1],mixolydian:[2,2,1,2,2,1,2],aeolian:[2,1,2,2,1,2,2],locrian:[1,2,2,1,2,2,2]}}static get scaleTypes(){return{M:Y.scales.major,m:Y.scales.minor}}static get accidentals(){return["bb","b","n","#","##"]}static get noteValues(){return{c:{root_index:0,int_val:0},cn:{root_index:0,int_val:0},"c#":{root_index:0,int_val:1},"c##":{root_index:0,int_val:2},cb:{root_index:0,int_val:11},cbb:{root_index:0,int_val:10},d:{root_index:1,int_val:2},dn:{root_index:1,int_val:2},"d#":{root_index:1,int_val:3},"d##":{root_index:1,int_val:4},db:{root_index:1,int_val:1},dbb:{root_index:1,int_val:0},e:{root_index:2,int_val:4},en:{root_index:2,int_val:4},"e#":{root_index:2,int_val:5},"e##":{root_index:2,int_val:6},eb:{root_index:2,int_val:3},ebb:{root_index:2,int_val:2},f:{root_index:3,int_val:5},fn:{root_index:3,int_val:5},"f#":{root_index:3,int_val:6},"f##":{root_index:3,int_val:7},fb:{root_index:3,int_val:4},fbb:{root_index:3,int_val:3},g:{root_index:4,int_val:7},gn:{root_index:4,int_val:7},"g#":{root_index:4,int_val:8},"g##":{root_index:4,int_val:9},gb:{root_index:4,int_val:6},gbb:{root_index:4,int_val:5},a:{root_index:5,int_val:9},an:{root_index:5,int_val:9},"a#":{root_index:5,int_val:10},"a##":{root_index:5,int_val:11},ab:{root_index:5,int_val:8},abb:{root_index:5,int_val:7},b:{root_index:6,int_val:11},bn:{root_index:6,int_val:11},"b#":{root_index:6,int_val:0},"b##":{root_index:6,int_val:1},bb:{root_index:6,int_val:10},bbb:{root_index:6,int_val:9}}}isValidNoteValue(t){return t>=0&&t<Y.canonical_notes.length}isValidIntervalValue(t){return t>=0&&t<Y.diatonic_intervals.length}getNoteParts(t){if(!t||t.length<1)throw new f("BadArguments","Invalid note name: "+t);if(t.length>3)throw new f("BadArguments","Invalid note name: "+t);const e=t.toLowerCase(),i=/^([cdefgab])(b|bb|n|#|##)?$/.exec(e);if(null!==i){return{root:i[1],accidental:i[2]}}throw new f("BadArguments","Invalid note name: "+t)}getKeyParts(t){if(!t||t.length<1)throw new f("BadArguments","Invalid key: "+t);const e=t.toLowerCase(),i=/^([cdefgab])(b|#)?(mel|harm|m|M)?$/.exec(e);if(null!==i){const t=i[1],e=i[2];let s=i[3];return s||(s="M"),{root:t,accidental:e,type:s}}throw new f("BadArguments",`Invalid key: ${t}`)}getNoteValue(t){const e=Y.noteValues[t];if(void 0===e)throw new f("BadArguments",`Invalid note name: ${t}`);return e.int_val}getIntervalValue(t){const e=Y.intervals[t];if(void 0===e)throw new f("BadArguments",`Invalid interval name: ${t}`);return e}getCanonicalNoteName(t){if(!this.isValidNoteValue(t))throw new f("BadArguments",`Invalid note value: ${t}`);return Y.canonical_notes[t]}getCanonicalIntervalName(t){if(!this.isValidIntervalValue(t))throw new f("BadArguments",`Invalid interval value: ${t}`);return Y.diatonic_intervals[t]}getRelativeNoteValue(t,e,i=1){if(1!==i&&-1!==i)throw new f("BadArguments",`Invalid direction: ${i}`);let s=(t+i*e)%Y.NUM_TONES;return s<0&&(s+=Y.NUM_TONES),s}getRelativeNoteName(t,e){const i=this.getNoteParts(t),s=this.getNoteValue(i.root);let n=e-s;if(Math.abs(n)>Y.NUM_TONES-3){let i=1;n>0&&(i=-1);const a=(e+1+(s+1))%Y.NUM_TONES*i;if(Math.abs(a)>2)throw new f("BadArguments",`Notes not related: ${t}, ${e})`);n=a}if(Math.abs(n)>2)throw new f("BadArguments",`Notes not related: ${t}, ${e})`);let a=i.root;if(n>0)for(let t=1;t<=n;++t)a+="#";else if(n<0)for(let t=-1;t>=n;--t)a+="b";return a}getScaleTones(t,e){const i=[t];let s=t;for(let n=0;n<e.length;n++)s=this.getRelativeNoteValue(s,e[n]),s!==t&&i.push(s);return i}getIntervalBetween(t,e,i=1){if(1!==i&&-1!==i)throw new f("BadArguments",`Invalid direction: ${i}`);if(!this.isValidNoteValue(t)||!this.isValidNoteValue(e))throw new f("BadArguments",`Invalid notes: ${t}, ${e}`);let s=1===i?e-t:t-e;return s<0&&(s+=Y.NUM_TONES),s}createScaleMap(t){const e=this.getKeyParts(t);if(!e.type)throw new f("BadArguments","Unsupported key type: undefined");const i=Y.scaleTypes[e.type];let s=e.root;if(e.accidental&&(s+=e.accidental),!i)throw new f("BadArguments","Unsupported key type: "+t);const n=this.getScaleTones(this.getNoteValue(s),i),a=Y.root_indices[e.root],o={};for(let t=0;t<Y.roots.length;++t){const e=(a+t)%Y.roots.length,i=Y.roots[e];let s=this.getRelativeNoteName(i,n[t]);1===s.length&&(s+="n"),o[i]=s}return o}}const j=16384,X={"1/2":32768,1:16384,2:8192,4:4096,8:2048,16:1024,32:512,64:256,128:128,256:64},V={w:"1",h:"2",q:"4",b:"256"},z={C:{num:0},Am:{num:0},F:{acc:"b",num:1},Dm:{acc:"b",num:1},Bb:{acc:"b",num:2},Gm:{acc:"b",num:2},Eb:{acc:"b",num:3},Cm:{acc:"b",num:3},Ab:{acc:"b",num:4},Fm:{acc:"b",num:4},Db:{acc:"b",num:5},Bbm:{acc:"b",num:5},Gb:{acc:"b",num:6},Ebm:{acc:"b",num:6},Cb:{acc:"b",num:7},Abm:{acc:"b",num:7},G:{acc:"#",num:1},Em:{acc:"#",num:1},D:{acc:"#",num:2},Bm:{acc:"#",num:2},A:{acc:"#",num:3},"F#m":{acc:"#",num:3},E:{acc:"#",num:4},"C#m":{acc:"#",num:4},B:{acc:"#",num:5},"G#m":{acc:"#",num:5},"F#":{acc:"#",num:6},"D#m":{acc:"#",num:6},"C#":{acc:"#",num:7},"A#m":{acc:"#",num:7}},K={treble:{line_shift:0},bass:{line_shift:6},tenor:{line_shift:4},alto:{line_shift:3},soprano:{line_shift:1},percussion:{line_shift:0},"mezzo-soprano":{line_shift:2},"baritone-c":{line_shift:5},"baritone-f":{line_shift:5},subbass:{line_shift:7},french:{line_shift:-1}},$={C:{index:0,int_val:0},CN:{index:0,int_val:0,accidental:"n"},"C#":{index:0,int_val:1,accidental:"#"},"C##":{index:0,int_val:2,accidental:"##"},CB:{index:0,int_val:11,accidental:"b"},CBB:{index:0,int_val:10,accidental:"bb"},D:{index:1,int_val:2},DN:{index:1,int_val:2,accidental:"n"},"D#":{index:1,int_val:3,accidental:"#"},"D##":{index:1,int_val:4,accidental:"##"},DB:{index:1,int_val:1,accidental:"b"},DBB:{index:1,int_val:0,accidental:"bb"},E:{index:2,int_val:4},EN:{index:2,int_val:4,accidental:"n"},"E#":{index:2,int_val:5,accidental:"#"},"E##":{index:2,int_val:6,accidental:"##"},EB:{index:2,int_val:3,accidental:"b"},EBB:{index:2,int_val:2,accidental:"bb"},F:{index:3,int_val:5},FN:{index:3,int_val:5,accidental:"n"},"F#":{index:3,int_val:6,accidental:"#"},"F##":{index:3,int_val:7,accidental:"##"},FB:{index:3,int_val:4,accidental:"b"},FBB:{index:3,int_val:3,accidental:"bb"},G:{index:4,int_val:7},GN:{index:4,int_val:7,accidental:"n"},"G#":{index:4,int_val:8,accidental:"#"},"G##":{index:4,int_val:9,accidental:"##"},GB:{index:4,int_val:6,accidental:"b"},GBB:{index:4,int_val:5,accidental:"bb"},A:{index:5,int_val:9},AN:{index:5,int_val:9,accidental:"n"},"A#":{index:5,int_val:10,accidental:"#"},"A##":{index:5,int_val:11,accidental:"##"},AB:{index:5,int_val:8,accidental:"b"},ABB:{index:5,int_val:7,accidental:"bb"},B:{index:6,int_val:11},BN:{index:6,int_val:11,accidental:"n"},"B#":{index:6,int_val:12,accidental:"#"},"B##":{index:6,int_val:13,accidental:"##"},BB:{index:6,int_val:10,accidental:"b"},BBB:{index:6,int_val:9,accidental:"bb"},R:{index:6,rest:!0},X:{index:6,accidental:"",octave:4,code:"noteheadXBlack",shift_right:5.5}},J={D0:{code:"noteheadDiamondWhole"},D1:{code:"noteheadDiamondHalf"},D2:{code:"noteheadDiamondBlack"},D3:{code:"noteheadDiamondBlack"},T0:{code:"noteheadTriangleUpWhole"},T1:{code:"noteheadTriangleUpHalf"},T2:{code:"noteheadTriangleUpBlack"},T3:{code:"noteheadTriangleUpBlack"},X0:{code:"noteheadXWhole"},X1:{code:"noteheadXHalf"},X2:{code:"noteheadXBlack"},X3:{code:"noteheadCircleX"},S1:{code:"noteheadSquareWhite"},S2:{code:"noteheadSquareBlack"},R1:{code:"vexNoteHeadRectWhite"},R2:{code:"vexNoteHeadRectBlack"}},q={"#":{code:"accidentalSharp",parenRightPaddingAdjustment:-1},"##":{code:"accidentalDoubleSharp",parenRightPaddingAdjustment:-1},b:{code:"accidentalFlat",parenRightPaddingAdjustment:-2},bb:{code:"accidentalDoubleFlat",parenRightPaddingAdjustment:-2},n:{code:"accidentalNatural",parenRightPaddingAdjustment:-1},"{":{code:"accidentalParensLeft",parenRightPaddingAdjustment:-1},"}":{code:"accidentalParensRight",parenRightPaddingAdjustment:-1},db:{code:"accidentalThreeQuarterTonesFlatZimmermann",parenRightPaddingAdjustment:-1},d:{code:"accidentalQuarterToneFlatStein",parenRightPaddingAdjustment:0},"++":{code:"accidentalThreeQuarterTonesSharpStein",parenRightPaddingAdjustment:-1},"+":{code:"accidentalQuarterToneSharpStein",parenRightPaddingAdjustment:-1},"+-":{code:"accidentalKucukMucennebSharp",parenRightPaddingAdjustment:-1},bs:{code:"accidentalBakiyeFlat",parenRightPaddingAdjustment:-1},bss:{code:"accidentalBuyukMucennebFlat",parenRightPaddingAdjustment:-1},o:{code:"accidentalSori",parenRightPaddingAdjustment:-1},k:{code:"accidentalKoron",parenRightPaddingAdjustment:-1},bbs:{code:"vexAccidentalMicrotonal1",parenRightPaddingAdjustment:-1},"++-":{code:"vexAccidentalMicrotonal2",parenRightPaddingAdjustment:-1},ashs:{code:"vexAccidentalMicrotonal3",parenRightPaddingAdjustment:-1},afhf:{code:"vexAccidentalMicrotonal4",parenRightPaddingAdjustment:-1},accSagittal5v7KleismaUp:{code:"accSagittal5v7KleismaUp",parenRightPaddingAdjustment:-1},accSagittal5v7KleismaDown:{code:"accSagittal5v7KleismaDown",parenRightPaddingAdjustment:-1},accSagittal5CommaUp:{code:"accSagittal5CommaUp",parenRightPaddingAdjustment:-1},accSagittal5CommaDown:{code:"accSagittal5CommaDown",parenRightPaddingAdjustment:-1},accSagittal7CommaUp:{code:"accSagittal7CommaUp",parenRightPaddingAdjustment:-1},accSagittal7CommaDown:{code:"accSagittal7CommaDown",parenRightPaddingAdjustment:-1},accSagittal25SmallDiesisUp:{code:"accSagittal25SmallDiesisUp",parenRightPaddingAdjustment:-1},accSagittal25SmallDiesisDown:{code:"accSagittal25SmallDiesisDown",parenRightPaddingAdjustment:-1},accSagittal35MediumDiesisUp:{code:"accSagittal35MediumDiesisUp",parenRightPaddingAdjustment:-1},accSagittal35MediumDiesisDown:{code:"accSagittal35MediumDiesisDown",parenRightPaddingAdjustment:-1},accSagittal11MediumDiesisUp:{code:"accSagittal11MediumDiesisUp",parenRightPaddingAdjustment:-1},accSagittal11MediumDiesisDown:{code:"accSagittal11MediumDiesisDown",parenRightPaddingAdjustment:-1},accSagittal11LargeDiesisUp:{code:"accSagittal11LargeDiesisUp",parenRightPaddingAdjustment:-1},accSagittal11LargeDiesisDown:{code:"accSagittal11LargeDiesisDown",parenRightPaddingAdjustment:-1},accSagittal35LargeDiesisUp:{code:"accSagittal35LargeDiesisUp",parenRightPaddingAdjustment:-1},accSagittal35LargeDiesisDown:{code:"accSagittal35LargeDiesisDown",parenRightPaddingAdjustment:-1},accSagittalSharp25SDown:{code:"accSagittalSharp25SDown",parenRightPaddingAdjustment:-1},accSagittalFlat25SUp:{code:"accSagittalFlat25SUp",parenRightPaddingAdjustment:-1},accSagittalSharp7CDown:{code:"accSagittalSharp7CDown",parenRightPaddingAdjustment:-1},accSagittalFlat7CUp:{code:"accSagittalFlat7CUp",parenRightPaddingAdjustment:-1},accSagittalSharp5CDown:{code:"accSagittalSharp5CDown",parenRightPaddingAdjustment:-1},accSagittalFlat5CUp:{code:"accSagittalFlat5CUp",parenRightPaddingAdjustment:-1},accSagittalSharp5v7kDown:{code:"accSagittalSharp5v7kDown",parenRightPaddingAdjustment:-1},accSagittalFlat5v7kUp:{code:"accSagittalFlat5v7kUp",parenRightPaddingAdjustment:-1},accSagittalSharp:{code:"accSagittalSharp",parenRightPaddingAdjustment:-1},accSagittalFlat:{code:"accSagittalFlat",parenRightPaddingAdjustment:-1},accSagittalSharp5v7kUp:{code:"accSagittalSharp5v7kUp",parenRightPaddingAdjustment:-1},accSagittalFlat5v7kDown:{code:"accSagittalFlat5v7kDown",parenRightPaddingAdjustment:-1},accSagittalSharp5CUp:{code:"accSagittalSharp5CUp",parenRightPaddingAdjustment:-1},accSagittalFlat5CDown:{code:"accSagittalFlat5CDown",parenRightPaddingAdjustment:-1},accSagittalSharp7CUp:{code:"accSagittalSharp7CUp",parenRightPaddingAdjustment:-1},accSagittalFlat7CDown:{code:"accSagittalFlat7CDown",parenRightPaddingAdjustment:-1},accSagittalSharp25SUp:{code:"accSagittalSharp25SUp",parenRightPaddingAdjustment:-1},accSagittalFlat25SDown:{code:"accSagittalFlat25SDown",parenRightPaddingAdjustment:-1},accSagittalSharp35MUp:{code:"accSagittalSharp35MUp",parenRightPaddingAdjustment:-1},accSagittalFlat35MDown:{code:"accSagittalFlat35MDown",parenRightPaddingAdjustment:-1},accSagittalSharp11MUp:{code:"accSagittalSharp11MUp",parenRightPaddingAdjustment:-1},accSagittalFlat11MDown:{code:"accSagittalFlat11MDown",parenRightPaddingAdjustment:-1},accSagittalSharp11LUp:{code:"accSagittalSharp11LUp",parenRightPaddingAdjustment:-1},accSagittalFlat11LDown:{code:"accSagittalFlat11LDown",parenRightPaddingAdjustment:-1},accSagittalSharp35LUp:{code:"accSagittalSharp35LUp",parenRightPaddingAdjustment:-1},accSagittalFlat35LDown:{code:"accSagittalFlat35LDown",parenRightPaddingAdjustment:-1},accSagittalDoubleSharp25SDown:{code:"accSagittalDoubleSharp25SDown",parenRightPaddingAdjustment:-1},accSagittalDoubleFlat25SUp:{code:"accSagittalDoubleFlat25SUp",parenRightPaddingAdjustment:-1},accSagittalDoubleSharp7CDown:{code:"accSagittalDoubleSharp7CDown",parenRightPaddingAdjustment:-1},accSagittalDoubleFlat7CUp:{code:"accSagittalDoubleFlat7CUp",parenRightPaddingAdjustment:-1},accSagittalDoubleSharp5CDown:{code:"accSagittalDoubleSharp5CDown",parenRightPaddingAdjustment:-1},accSagittalDoubleFlat5CUp:{code:"accSagittalDoubleFlat5CUp",parenRightPaddingAdjustment:-1},accSagittalDoubleSharp5v7kDown:{code:"accSagittalDoubleSharp5v7kDown",parenRightPaddingAdjustment:-1},accSagittalDoubleFlat5v7kUp:{code:"accSagittalDoubleFlat5v7kUp",parenRightPaddingAdjustment:-1},accSagittalDoubleSharp:{code:"accSagittalDoubleSharp",parenRightPaddingAdjustment:-1},accSagittalDoubleFlat:{code:"accSagittalDoubleFlat",parenRightPaddingAdjustment:-1},accSagittal7v11KleismaUp:{code:"accSagittal7v11KleismaUp",parenRightPaddingAdjustment:-1},accSagittal7v11KleismaDown:{code:"accSagittal7v11KleismaDown",parenRightPaddingAdjustment:-1},accSagittal17CommaUp:{code:"accSagittal17CommaUp",parenRightPaddingAdjustment:-1},accSagittal17CommaDown:{code:"accSagittal17CommaDown",parenRightPaddingAdjustment:-1},accSagittal55CommaUp:{code:"accSagittal55CommaUp",parenRightPaddingAdjustment:-1},accSagittal55CommaDown:{code:"accSagittal55CommaDown",parenRightPaddingAdjustment:-1},accSagittal7v11CommaUp:{code:"accSagittal7v11CommaUp",parenRightPaddingAdjustment:-1},accSagittal7v11CommaDown:{code:"accSagittal7v11CommaDown",parenRightPaddingAdjustment:-1},accSagittal5v11SmallDiesisUp:{code:"accSagittal5v11SmallDiesisUp",parenRightPaddingAdjustment:-1},accSagittal5v11SmallDiesisDown:{code:"accSagittal5v11SmallDiesisDown",parenRightPaddingAdjustment:-1},accSagittalSharp5v11SDown:{code:"accSagittalSharp5v11SDown",parenRightPaddingAdjustment:-1},accSagittalFlat5v11SUp:{code:"accSagittalFlat5v11SUp",parenRightPaddingAdjustment:-1},accSagittalSharp7v11CDown:{code:"accSagittalSharp7v11CDown",parenRightPaddingAdjustment:-1},accSagittalFlat7v11CUp:{code:"accSagittalFlat7v11CUp",parenRightPaddingAdjustment:-1},accSagittalSharp55CDown:{code:"accSagittalSharp55CDown",parenRightPaddingAdjustment:-1},accSagittalFlat55CUp:{code:"accSagittalFlat55CUp",parenRightPaddingAdjustment:-1},accSagittalSharp17CDown:{code:"accSagittalSharp17CDown",parenRightPaddingAdjustment:-1},accSagittalFlat17CUp:{code:"accSagittalFlat17CUp",parenRightPaddingAdjustment:-1},accSagittalSharp7v11kDown:{code:"accSagittalSharp7v11kDown",parenRightPaddingAdjustment:-1},accSagittalFlat7v11kUp:{code:"accSagittalFlat7v11kUp",parenRightPaddingAdjustment:-1},accSagittalSharp7v11kUp:{code:"accSagittalSharp7v11kUp",parenRightPaddingAdjustment:-1},accSagittalFlat7v11kDown:{code:"accSagittalFlat7v11kDown",parenRightPaddingAdjustment:-1},accSagittalSharp17CUp:{code:"accSagittalSharp17CUp",parenRightPaddingAdjustment:-1},accSagittalFlat17CDown:{code:"accSagittalFlat17CDown",parenRightPaddingAdjustment:-1},accSagittalSharp55CUp:{code:"accSagittalSharp55CUp",parenRightPaddingAdjustment:-1},accSagittalFlat55CDown:{code:"accSagittalFlat55CDown",parenRightPaddingAdjustment:-1},accSagittalSharp7v11CUp:{code:"accSagittalSharp7v11CUp",parenRightPaddingAdjustment:-1},accSagittalFlat7v11CDown:{code:"accSagittalFlat7v11CDown",parenRightPaddingAdjustment:-1},accSagittalSharp5v11SUp:{code:"accSagittalSharp5v11SUp",parenRightPaddingAdjustment:-1},accSagittalFlat5v11SDown:{code:"accSagittalFlat5v11SDown",parenRightPaddingAdjustment:-1},accSagittalDoubleSharp5v11SDown:{code:"accSagittalDoubleSharp5v11SDown",parenRightPaddingAdjustment:-1},accSagittalDoubleFlat5v11SUp:{code:"accSagittalDoubleFlat5v11SUp",parenRightPaddingAdjustment:-1},accSagittalDoubleSharp7v11CDown:{code:"accSagittalDoubleSharp7v11CDown",parenRightPaddingAdjustment:-1},accSagittalDoubleFlat7v11CUp:{code:"accSagittalDoubleFlat7v11CUp",parenRightPaddingAdjustment:-1},accSagittalDoubleSharp55CDown:{code:"accSagittalDoubleSharp55CDown",parenRightPaddingAdjustment:-1},accSagittalDoubleFlat55CUp:{code:"accSagittalDoubleFlat55CUp",parenRightPaddingAdjustment:-1},accSagittalDoubleSharp17CDown:{code:"accSagittalDoubleSharp17CDown",parenRightPaddingAdjustment:-1},accSagittalDoubleFlat17CUp:{code:"accSagittalDoubleFlat17CUp",parenRightPaddingAdjustment:-1},accSagittalDoubleSharp7v11kDown:{code:"accSagittalDoubleSharp7v11kDown",parenRightPaddingAdjustment:-1},accSagittalDoubleFlat7v11kUp:{code:"accSagittalDoubleFlat7v11kUp",parenRightPaddingAdjustment:-1},accSagittal23CommaUp:{code:"accSagittal23CommaUp",parenRightPaddingAdjustment:-1},accSagittal23CommaDown:{code:"accSagittal23CommaDown",parenRightPaddingAdjustment:-1},accSagittal5v19CommaUp:{code:"accSagittal5v19CommaUp",parenRightPaddingAdjustment:-1},accSagittal5v19CommaDown:{code:"accSagittal5v19CommaDown",parenRightPaddingAdjustment:-1},accSagittal5v23SmallDiesisUp:{code:"accSagittal5v23SmallDiesisUp",parenRightPaddingAdjustment:-1},accSagittal5v23SmallDiesisDown:{code:"accSagittal5v23SmallDiesisDown",parenRightPaddingAdjustment:-1},accSagittalSharp5v23SDown:{code:"accSagittalSharp5v23SDown",parenRightPaddingAdjustment:-1},accSagittalFlat5v23SUp:{code:"accSagittalFlat5v23SUp",parenRightPaddingAdjustment:-1},accSagittalSharp5v19CDown:{code:"accSagittalSharp5v19CDown",parenRightPaddingAdjustment:-1},accSagittalFlat5v19CUp:{code:"accSagittalFlat5v19CUp",parenRightPaddingAdjustment:-1},accSagittalSharp23CDown:{code:"accSagittalSharp23CDown",parenRightPaddingAdjustment:-1},accSagittalFlat23CUp:{code:"accSagittalFlat23CUp",parenRightPaddingAdjustment:-1},accSagittalSharp23CUp:{code:"accSagittalSharp23CUp",parenRightPaddingAdjustment:-1},accSagittalFlat23CDown:{code:"accSagittalFlat23CDown",parenRightPaddingAdjustment:-1},accSagittalSharp5v19CUp:{code:"accSagittalSharp5v19CUp",parenRightPaddingAdjustment:-1},accSagittalFlat5v19CDown:{code:"accSagittalFlat5v19CDown",parenRightPaddingAdjustment:-1},accSagittalSharp5v23SUp:{code:"accSagittalSharp5v23SUp",parenRightPaddingAdjustment:-1},accSagittalFlat5v23SDown:{code:"accSagittalFlat5v23SDown",parenRightPaddingAdjustment:-1},accSagittalDoubleSharp5v23SDown:{code:"accSagittalDoubleSharp5v23SDown",parenRightPaddingAdjustment:-1},accSagittalDoubleFlat5v23SUp:{code:"accSagittalDoubleFlat5v23SUp",parenRightPaddingAdjustment:-1},accSagittalDoubleSharp5v19CDown:{code:"accSagittalDoubleSharp5v19CDown",parenRightPaddingAdjustment:-1},accSagittalDoubleFlat5v19CUp:{code:"accSagittalDoubleFlat5v19CUp",parenRightPaddingAdjustment:-1},accSagittalDoubleSharp23CDown:{code:"accSagittalDoubleSharp23CDown",parenRightPaddingAdjustment:-1},accSagittalDoubleFlat23CUp:{code:"accSagittalDoubleFlat23CUp",parenRightPaddingAdjustment:-1},accSagittal19SchismaUp:{code:"accSagittal19SchismaUp",parenRightPaddingAdjustment:-1},accSagittal19SchismaDown:{code:"accSagittal19SchismaDown",parenRightPaddingAdjustment:-1},accSagittal17KleismaUp:{code:"accSagittal17KleismaUp",parenRightPaddingAdjustment:-1},accSagittal17KleismaDown:{code:"accSagittal17KleismaDown",parenRightPaddingAdjustment:-1},accSagittal143CommaUp:{code:"accSagittal143CommaUp",parenRightPaddingAdjustment:-1},accSagittal143CommaDown:{code:"accSagittal143CommaDown",parenRightPaddingAdjustment:-1},accSagittal11v49CommaUp:{code:"accSagittal11v49CommaUp",parenRightPaddingAdjustment:-1},accSagittal11v49CommaDown:{code:"accSagittal11v49CommaDown",parenRightPaddingAdjustment:-1},accSagittal19CommaUp:{code:"accSagittal19CommaUp",parenRightPaddingAdjustment:-1},accSagittal19CommaDown:{code:"accSagittal19CommaDown",parenRightPaddingAdjustment:-1},accSagittal7v19CommaUp:{code:"accSagittal7v19CommaUp",parenRightPaddingAdjustment:-1},accSagittal7v19CommaDown:{code:"accSagittal7v19CommaDown",parenRightPaddingAdjustment:-1},accSagittal49SmallDiesisUp:{code:"accSagittal49SmallDiesisUp",parenRightPaddingAdjustment:-1},accSagittal49SmallDiesisDown:{code:"accSagittal49SmallDiesisDown",parenRightPaddingAdjustment:-1},accSagittal23SmallDiesisUp:{code:"accSagittal23SmallDiesisUp",parenRightPaddingAdjustment:-1},accSagittal23SmallDiesisDown:{code:"accSagittal23SmallDiesisDown",parenRightPaddingAdjustment:-1},accSagittal5v13MediumDiesisUp:{code:"accSagittal5v13MediumDiesisUp",parenRightPaddingAdjustment:-1},accSagittal5v13MediumDiesisDown:{code:"accSagittal5v13MediumDiesisDown",parenRightPaddingAdjustment:-1},accSagittal11v19MediumDiesisUp:{code:"accSagittal11v19MediumDiesisUp",parenRightPaddingAdjustment:-1},accSagittal11v19MediumDiesisDown:{code:"accSagittal11v19MediumDiesisDown",parenRightPaddingAdjustment:-1},accSagittal49MediumDiesisUp:{code:"accSagittal49MediumDiesisUp",parenRightPaddingAdjustment:-1},accSagittal49MediumDiesisDown:{code:"accSagittal49MediumDiesisDown",parenRightPaddingAdjustment:-1},accSagittal5v49MediumDiesisUp:{code:"accSagittal5v49MediumDiesisUp",parenRightPaddingAdjustment:-1},accSagittal5v49MediumDiesisDown:{code:"accSagittal5v49MediumDiesisDown",parenRightPaddingAdjustment:-1},accSagittal49LargeDiesisUp:{code:"accSagittal49LargeDiesisUp",parenRightPaddingAdjustment:-1},accSagittal49LargeDiesisDown:{code:"accSagittal49LargeDiesisDown",parenRightPaddingAdjustment:-1},accSagittal11v19LargeDiesisUp:{code:"accSagittal11v19LargeDiesisUp",parenRightPaddingAdjustment:-1},accSagittal11v19LargeDiesisDown:{code:"accSagittal11v19LargeDiesisDown",parenRightPaddingAdjustment:-1},accSagittal5v13LargeDiesisUp:{code:"accSagittal5v13LargeDiesisUp",parenRightPaddingAdjustment:-1},accSagittal5v13LargeDiesisDown:{code:"accSagittal5v13LargeDiesisDown",parenRightPaddingAdjustment:-1},accSagittalSharp23SDown:{code:"accSagittalSharp23SDown",parenRightPaddingAdjustment:-1},accSagittalFlat23SUp:{code:"accSagittalFlat23SUp",parenRightPaddingAdjustment:-1},accSagittalSharp49SDown:{code:"accSagittalSharp49SDown",parenRightPaddingAdjustment:-1},accSagittalFlat49SUp:{code:"accSagittalFlat49SUp",parenRightPaddingAdjustment:-1},accSagittalSharp7v19CDown:{code:"accSagittalSharp7v19CDown",parenRightPaddingAdjustment:-1},accSagittalFlat7v19CUp:{code:"accSagittalFlat7v19CUp",parenRightPaddingAdjustment:-1},accSagittalSharp19CDown:{code:"accSagittalSharp19CDown",parenRightPaddingAdjustment:-1},accSagittalFlat19CUp:{code:"accSagittalFlat19CUp",parenRightPaddingAdjustment:-1},accSagittalSharp11v49CDown:{code:"accSagittalSharp11v49CDown",parenRightPaddingAdjustment:-1},accSagittalFlat11v49CUp:{code:"accSagittalFlat11v49CUp",parenRightPaddingAdjustment:-1},accSagittalSharp143CDown:{code:"accSagittalSharp143CDown",parenRightPaddingAdjustment:-1},accSagittalFlat143CUp:{code:"accSagittalFlat143CUp",parenRightPaddingAdjustment:-1},accSagittalSharp17kDown:{code:"accSagittalSharp17kDown",parenRightPaddingAdjustment:-1},accSagittalFlat17kUp:{code:"accSagittalFlat17kUp",parenRightPaddingAdjustment:-1},accSagittalSharp19sDown:{code:"accSagittalSharp19sDown",parenRightPaddingAdjustment:-1},accSagittalFlat19sUp:{code:"accSagittalFlat19sUp",parenRightPaddingAdjustment:-1},accSagittalSharp19sUp:{code:"accSagittalSharp19sUp",parenRightPaddingAdjustment:-1},accSagittalFlat19sDown:{code:"accSagittalFlat19sDown",parenRightPaddingAdjustment:-1},accSagittalSharp17kUp:{code:"accSagittalSharp17kUp",parenRightPaddingAdjustment:-1},accSagittalFlat17kDown:{code:"accSagittalFlat17kDown",parenRightPaddingAdjustment:-1},accSagittalSharp143CUp:{code:"accSagittalSharp143CUp",parenRightPaddingAdjustment:-1},accSagittalFlat143CDown:{code:"accSagittalFlat143CDown",parenRightPaddingAdjustment:-1},accSagittalSharp11v49CUp:{code:"accSagittalSharp11v49CUp",parenRightPaddingAdjustment:-1},accSagittalFlat11v49CDown:{code:"accSagittalFlat11v49CDown",parenRightPaddingAdjustment:-1},accSagittalSharp19CUp:{code:"accSagittalSharp19CUp",parenRightPaddingAdjustment:-1},accSagittalFlat19CDown:{code:"accSagittalFlat19CDown",parenRightPaddingAdjustment:-1},accSagittalSharp7v19CUp:{code:"accSagittalSharp7v19CUp",parenRightPaddingAdjustment:-1},accSagittalFlat7v19CDown:{code:"accSagittalFlat7v19CDown",parenRightPaddingAdjustment:-1},accSagittalSharp49SUp:{code:"accSagittalSharp49SUp",parenRightPaddingAdjustment:-1},accSagittalFlat49SDown:{code:"accSagittalFlat49SDown",parenRightPaddingAdjustment:-1},accSagittalSharp23SUp:{code:"accSagittalSharp23SUp",parenRightPaddingAdjustment:-1},accSagittalFlat23SDown:{code:"accSagittalFlat23SDown",parenRightPaddingAdjustment:-1},accSagittalSharp5v13MUp:{code:"accSagittalSharp5v13MUp",parenRightPaddingAdjustment:-1},accSagittalFlat5v13MDown:{code:"accSagittalFlat5v13MDown",parenRightPaddingAdjustment:-1},accSagittalSharp11v19MUp:{code:"accSagittalSharp11v19MUp",parenRightPaddingAdjustment:-1},accSagittalFlat11v19MDown:{code:"accSagittalFlat11v19MDown",parenRightPaddingAdjustment:-1},accSagittalSharp49MUp:{code:"accSagittalSharp49MUp",parenRightPaddingAdjustment:-1},accSagittalFlat49MDown:{code:"accSagittalFlat49MDown",parenRightPaddingAdjustment:-1},accSagittalSharp5v49MUp:{code:"accSagittalSharp5v49MUp",parenRightPaddingAdjustment:-1},accSagittalFlat5v49MDown:{code:"accSagittalFlat5v49MDown",parenRightPaddingAdjustment:-1},accSagittalSharp49LUp:{code:"accSagittalSharp49LUp",parenRightPaddingAdjustment:-1},accSagittalFlat49LDown:{code:"accSagittalFlat49LDown",parenRightPaddingAdjustment:-1},accSagittalSharp11v19LUp:{code:"accSagittalSharp11v19LUp",parenRightPaddingAdjustment:-1},accSagittalFlat11v19LDown:{code:"accSagittalFlat11v19LDown",parenRightPaddingAdjustment:-1},accSagittalSharp5v13LUp:{code:"accSagittalSharp5v13LUp",parenRightPaddingAdjustment:-1},accSagittalFlat5v13LDown:{code:"accSagittalFlat5v13LDown",parenRightPaddingAdjustment:-1},accSagittalDoubleSharp23SDown:{code:"accSagittalDoubleSharp23SDown",parenRightPaddingAdjustment:-1},accSagittalDoubleFlat23SUp:{code:"accSagittalDoubleFlat23SUp",parenRightPaddingAdjustment:-1},accSagittalDoubleSharp49SDown:{code:"accSagittalDoubleSharp49SDown",parenRightPaddingAdjustment:-1},accSagittalDoubleFlat49SUp:{code:"accSagittalDoubleFlat49SUp",parenRightPaddingAdjustment:-1},accSagittalDoubleSharp7v19CDown:{code:"accSagittalDoubleSharp7v19CDown",parenRightPaddingAdjustment:-1},accSagittalDoubleFlat7v19CUp:{code:"accSagittalDoubleFlat7v19CUp",parenRightPaddingAdjustment:-1},accSagittalDoubleSharp19CDown:{code:"accSagittalDoubleSharp19CDown",parenRightPaddingAdjustment:-1},accSagittalDoubleFlat19CUp:{code:"accSagittalDoubleFlat19CUp",parenRightPaddingAdjustment:-1},accSagittalDoubleSharp11v49CDown:{code:"accSagittalDoubleSharp11v49CDown",parenRightPaddingAdjustment:-1},accSagittalDoubleFlat11v49CUp:{code:"accSagittalDoubleFlat11v49CUp",parenRightPaddingAdjustment:-1},accSagittalDoubleSharp143CDown:{code:"accSagittalDoubleSharp143CDown",parenRightPaddingAdjustment:-1},accSagittalDoubleFlat143CUp:{code:"accSagittalDoubleFlat143CUp",parenRightPaddingAdjustment:-1},accSagittalDoubleSharp17kDown:{code:"accSagittalDoubleSharp17kDown",parenRightPaddingAdjustment:-1},accSagittalDoubleFlat17kUp:{code:"accSagittalDoubleFlat17kUp",parenRightPaddingAdjustment:-1},accSagittalDoubleSharp19sDown:{code:"accSagittalDoubleSharp19sDown",parenRightPaddingAdjustment:-1},accSagittalDoubleFlat19sUp:{code:"accSagittalDoubleFlat19sUp",parenRightPaddingAdjustment:-1},accSagittalShaftUp:{code:"accSagittalShaftUp",parenRightPaddingAdjustment:-1},accSagittalShaftDown:{code:"accSagittalShaftDown",parenRightPaddingAdjustment:-1},accSagittalAcute:{code:"accSagittalAcute",parenRightPaddingAdjustment:-1},accSagittalGrave:{code:"accSagittalGrave",parenRightPaddingAdjustment:-1},accSagittal1MinaUp:{code:"accSagittal1MinaUp",parenRightPaddingAdjustment:-1},accSagittal1MinaDown:{code:"accSagittal1MinaDown",parenRightPaddingAdjustment:-1},accSagittal2MinasUp:{code:"accSagittal2MinasUp",parenRightPaddingAdjustment:-1},accSagittal2MinasDown:{code:"accSagittal2MinasDown",parenRightPaddingAdjustment:-1},accSagittal1TinaUp:{code:"accSagittal1TinaUp",parenRightPaddingAdjustment:-1},accSagittal1TinaDown:{code:"accSagittal1TinaDown",parenRightPaddingAdjustment:-1},accSagittal2TinasUp:{code:"accSagittal2TinasUp",parenRightPaddingAdjustment:-1},accSagittal2TinasDown:{code:"accSagittal2TinasDown",parenRightPaddingAdjustment:-1},accSagittal3TinasUp:{code:"accSagittal3TinasUp",parenRightPaddingAdjustment:-1},accSagittal3TinasDown:{code:"accSagittal3TinasDown",parenRightPaddingAdjustment:-1},accSagittal4TinasUp:{code:"accSagittal4TinasUp",parenRightPaddingAdjustment:-1},accSagittal4TinasDown:{code:"accSagittal4TinasDown",parenRightPaddingAdjustment:-1},accSagittal5TinasUp:{code:"accSagittal5TinasUp",parenRightPaddingAdjustment:-1},accSagittal5TinasDown:{code:"accSagittal5TinasDown",parenRightPaddingAdjustment:-1},accSagittal6TinasUp:{code:"accSagittal6TinasUp",parenRightPaddingAdjustment:-1},accSagittal6TinasDown:{code:"accSagittal6TinasDown",parenRightPaddingAdjustment:-1},accSagittal7TinasUp:{code:"accSagittal7TinasUp",parenRightPaddingAdjustment:-1},accSagittal7TinasDown:{code:"accSagittal7TinasDown",parenRightPaddingAdjustment:-1},accSagittal8TinasUp:{code:"accSagittal8TinasUp",parenRightPaddingAdjustment:-1},accSagittal8TinasDown:{code:"accSagittal8TinasDown",parenRightPaddingAdjustment:-1},accSagittal9TinasUp:{code:"accSagittal9TinasUp",parenRightPaddingAdjustment:-1},accSagittal9TinasDown:{code:"accSagittal9TinasDown",parenRightPaddingAdjustment:-1},accSagittalFractionalTinaUp:{code:"accSagittalFractionalTinaUp",parenRightPaddingAdjustment:-1},accSagittalFractionalTinaDown:{code:"accSagittalFractionalTinaDown",parenRightPaddingAdjustment:-1},accidentalNarrowReversedFlat:{code:"accidentalNarrowReversedFlat",parenRightPaddingAdjustment:-1},accidentalNarrowReversedFlatAndFlat:{code:"accidentalNarrowReversedFlatAndFlat",parenRightPaddingAdjustment:-1},accidentalWilsonPlus:{code:"accidentalWilsonPlus",parenRightPaddingAdjustment:-1},accidentalWilsonMinus:{code:"accidentalWilsonMinus",parenRightPaddingAdjustment:-1}},Q={"a.":{code:"augmentationDot",between_lines:!0},av:{aboveCode:"articStaccatissimoAbove",belowCode:"articStaccatissimoBelow",between_lines:!0},"a>":{aboveCode:"articAccentAbove",belowCode:"articAccentBelow",between_lines:!0},"a-":{aboveCode:"articTenutoAbove",belowCode:"articTenutoBelow",between_lines:!0},"a^":{aboveCode:"articMarcatoAbove",belowCode:"articMarcatoBelow",between_lines:!1},"a+":{code:"pluckedLeftHandPizzicato",between_lines:!1},ao:{aboveCode:"pluckedSnapPizzicatoAbove",belowCode:"pluckedSnapPizzicatoBelow",between_lines:!1},ah:{code:"stringsHarmonic",between_lines:!1},"a@":{aboveCode:"fermataAbove",belowCode:"fermataBelow",between_lines:!1},"a@a":{code:"fermataAbove",between_lines:!1},"a@u":{code:"fermataBelow",between_lines:!1},"a|":{code:"stringsUpBow",between_lines:!1},am:{code:"stringsDownBow",between_lines:!1},"a,":{code:"pictChokeCymbal",between_lines:!1}},Z={mordent:{code:"ornamentShortTrill"},mordent_inverted:{code:"ornamentMordent"},turn:{code:"ornamentTurn"},turn_inverted:{code:"ornamentTurnSlash"},tr:{code:"ornamentTrill"},upprall:{code:"ornamentPrecompSlideTrillDAnglebert"},downprall:{code:"ornamentPrecompDoubleCadenceUpperPrefix"},prallup:{code:"ornamentPrecompTrillSuffixDandrieu"},pralldown:{code:"ornamentPrecompTrillLowerSuffix"},upmordent:{code:"ornamentPrecompSlideTrillBach"},downmordent:{code:"ornamentPrecompDoubleCadenceUpperPrefixTurn"},lineprall:{code:"ornamentPrecompAppoggTrill"},prallprall:{code:"ornamentTremblement"},scoop:{code:"brassScoop"},doit:{code:"brassDoitMedium"},fall:{code:"brassFallLipShort"},doitLong:{code:"brassLiftMedium"},fallLong:{code:"brassFallRoughMedium"},bend:{code:"brassBend"},plungerClosed:{code:"brassMuteClosed"},plungerOpen:{code:"brassMuteOpen"},flip:{code:"brassFlip"},jazzTurn:{code:"brassJazzTurn"},smear:{code:"brassSmear"}};class tt{static currentMusicFont(){if(0===tt.MUSIC_FONT_STACK.length)throw new f("NoFonts","The font stack is empty. See: await Flow.fetchMusicFont(...); Flow.setMusicFont(...).");return tt.MUSIC_FONT_STACK[0]}static clefProperties(t){if(!t||!(t in K))throw new f("BadArgument","Invalid clef: "+t);return K[t]}static keyProperties(t,e="treble",i){let s={octave_shift:0};"object"==typeof i&&(s=Object.assign(Object.assign({},s),i));const n=t.split("/");if(n.length<2)throw new f("BadArguments",`First argument must be note/octave or note/octave/glyph-code: ${t}`);const a=n[0].toUpperCase(),o=$[a];if(!o)throw new f("BadArguments","Invalid key name: "+a);o.octave&&(n[1]=o.octave.toString());let r=parseInt(n[1],10);r+=-1*s.octave_shift;let h=(7*r-28+o.index)/2;h+=tt.clefProperties(e).line_shift;let c=0;h<=0&&2*h%2==0&&(c=1),h>=6&&2*h%2==0&&(c=-1);const d=void 0!==o.int_val?12*r+o.int_val:void 0,l=o.code,g=o.shift_right;let u={};if(n.length>2&&n[2]){const t=n[2].toUpperCase();u=J[t]||{}}return Object.assign({key:a,octave:r,line:h,int_value:d,accidental:o.accidental,code:l,stroke:c,shift_right:g,displaced:!1},u)}static integerToNote(t){if(void 0===t||t<0||t>11)throw new f("BadArguments",`integerToNote() requires an integer in the range [0, 11]: ${t}`);const e={0:"C",1:"C#",2:"D",3:"D#",4:"E",5:"F",6:"F#",7:"G",8:"G#",9:"A",10:"A#",11:"B"}[t];if(!e)throw new f("BadArguments",`Unknown note value for integer: ${t}`);return e}static tabToGlyph(t,e=1){let i,s=0,n=0;if("X"===t.toUpperCase()){const t=new U("accidentalDoubleSharp",tt.TABLATURE_FONT_SCALE).getMetrics();if(i="accidentalDoubleSharp",null==t.width||null==t.height)throw new f("InvalidMetrics","Width and height required");s=t.width,n=-t.height/2}else s=tt.textWidth(t);return{text:t,code:i,getWidth:()=>s*e,shift_y:n}}static textWidth(t){return 7*t.toString().length}static articulationCodes(t){return Q[t]}static accidentalCodes(t){return q[t]}static ornamentCodes(t){return Z[t]}static keySignature(t){const e=z[t];if(!e)throw new f("BadKeySignature",`Bad key signature spec: '${t}'`);if(!e.acc)return[];const i={b:[2,.5,2.5,1,3,1.5,3.5],"#":[0,1.5,-.5,1,2.5,.5,2]}[e.acc],s=[];for(let t=0;t<e.num;++t){const n=i[t];s.push({type:e.acc,line:n})}return s}static getKeySignatures(){return z}static hasKeySignature(t){return t in z}static sanitizeDuration(t){const e=V[t];if(void 0!==e&&(t=e),void 0===X[t])throw new f("BadArguments",`The provided duration is not valid: ${t}`);return t}static durationToFraction(t){return(new v).parse(tt.sanitizeDuration(t))}static durationToNumber(t){return tt.durationToFraction(t).value()}static durationToTicks(t){t=tt.sanitizeDuration(t);const e=X[t];if(void 0===e)throw new f("InvalidDuration");return e}static getGlyphProps(t,e="n"){t=tt.sanitizeDuration(t);const i=et[t];if(void 0===i)return;let s=i.type[e];if(void 0===s){const t=J[e.toUpperCase()];if(void 0===t)return;s=Object.assign({code_head:t.code},t)}const n=s.code_head;return Object.assign(Object.assign(Object.assign({},i.common),{getWidth:(t=tt.NOTATION_FONT_SCALE)=>U.getWidth(n,t)}),s)}}tt.STEM_WIDTH=1.5,tt.STEM_HEIGHT=35,tt.STAVE_LINE_THICKNESS=1,tt.RESOLUTION=j,tt.MUSIC_FONT_STACK=[],tt.NOTATION_FONT_SCALE=39,tt.TABLATURE_FONT_SCALE=39,tt.SLASH_NOTEHEAD_WIDTH=15,tt.STAVE_LINE_DISTANCE=10,tt.TEXT_HEIGHT_OFFSET_HACK=1,tt.accidentalMap=q,tt.accidentalColumnsTable={1:{a:[1],b:[1]},2:{a:[1,2]},3:{a:[1,3,2],b:[1,2,1],second_on_bottom:[1,2,3]},4:{a:[1,3,4,2],b:[1,2,3,1],spaced_out_tetrachord:[1,2,1,2]},5:{a:[1,3,5,4,2],b:[1,2,4,3,1],spaced_out_pentachord:[1,2,3,2,1],very_spaced_out_pentachord:[1,2,1,2,1]},6:{a:[1,3,5,6,4,2],b:[1,2,4,5,3,1],spaced_out_hexachord:[1,3,2,1,3,2],very_spaced_out_hexachord:[1,2,1,2,1,2]}},tt.unicode={sharp:String.fromCharCode(9839),flat:String.fromCharCode(9837),natural:String.fromCharCode(9838),triangle:String.fromCharCode(9651),"o-with-slash":String.fromCharCode(248),degrees:String.fromCharCode(176),circle:String.fromCharCode(9675)},tt.validTypes={n:{name:"note"},r:{name:"rest"},h:{name:"harmonic"},m:{name:"muted"},s:{name:"slash"},g:{name:"ghost"}},tt.TIME4_4={num_beats:4,beat_value:4,resolution:j};const et={"1/2":{common:{stem:!1,stem_offset:0,flag:!1,stem_up_extension:-tt.STEM_HEIGHT,stem_down_extension:-tt.STEM_HEIGHT,tabnote_stem_up_extension:-tt.STEM_HEIGHT,tabnote_stem_down_extension:-tt.STEM_HEIGHT,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"noteheadDoubleWhole"},h:{code_head:"unpitchedPercussionClef1"},m:{code_head:"vexNoteHeadMutedBreve",stem_offset:0},r:{code_head:"restDoubleWhole",rest:!0,position:"B/5",dot_shiftY:.5},s:{getWidth:()=>tt.SLASH_NOTEHEAD_WIDTH,position:"B/4"},g:{code_head:"noteheadDoubleWhole"}}},1:{common:{stem:!1,stem_offset:0,flag:!1,stem_up_extension:-tt.STEM_HEIGHT,stem_down_extension:-tt.STEM_HEIGHT,tabnote_stem_up_extension:-tt.STEM_HEIGHT,tabnote_stem_down_extension:-tt.STEM_HEIGHT,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"noteheadWhole"},h:{code_head:"noteheadDiamondWhole"},m:{code_head:"noteheadXWhole",stem_offset:-3},r:{code_head:"restWhole",rest:!0,position:"D/5",dot_shiftY:.5},s:{getWidth:()=>tt.SLASH_NOTEHEAD_WIDTH,position:"B/4"},g:{code_head:"noteheadWhole"}}},2:{common:{stem:!0,stem_offset:0,flag:!1,stem_up_extension:0,stem_down_extension:0,tabnote_stem_up_extension:0,tabnote_stem_down_extension:0,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"noteheadHalf"},h:{code_head:"noteheadDiamondHalf"},m:{code_head:"noteheadXHalf",stem_offset:-3},r:{code_head:"restHalf",stem:!1,rest:!0,position:"B/4",dot_shiftY:-.5},s:{getWidth:()=>tt.SLASH_NOTEHEAD_WIDTH,position:"B/4"},g:{code_head:"noteheadHalf"}}},4:{common:{stem:!0,stem_offset:0,flag:!1,stem_up_extension:0,stem_down_extension:0,tabnote_stem_up_extension:0,tabnote_stem_down_extension:0,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"noteheadBlack"},h:{code_head:"noteheadDiamondBlack"},m:{code_head:"noteheadXBlack"},r:{code_head:"restQuarter",stem:!1,rest:!0,position:"B/4",dot_shiftY:-.5,line_above:1.5,line_below:1.5},s:{getWidth:()=>tt.SLASH_NOTEHEAD_WIDTH,position:"B/4"},g:{code_head:"noteheadBlack"}}},8:{common:{stem:!0,stem_offset:0,flag:!0,beam_count:1,stem_beam_extension:0,code_flag_upstem:"flag8thUp",code_flag_downstem:"flag8thDown",stem_up_extension:0,stem_down_extension:0,tabnote_stem_up_extension:0,tabnote_stem_down_extension:0,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"noteheadBlack"},h:{code_head:"noteheadDiamondBlack"},m:{code_head:"noteheadXBlack"},r:{code_head:"rest8th",stem:!1,flag:!1,rest:!0,position:"B/4",dot_shiftY:-.5,line_above:1,line_below:1},s:{getWidth:()=>tt.SLASH_NOTEHEAD_WIDTH,position:"B/4"},g:{code_head:"noteheadBlack"}}},16:{common:{beam_count:2,stem_beam_extension:0,stem:!0,stem_offset:0,flag:!0,code_flag_upstem:"flag16thUp",code_flag_downstem:"flag16thDown",stem_up_extension:0,stem_down_extension:0,tabnote_stem_up_extension:0,tabnote_stem_down_extension:0,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"noteheadBlack"},h:{code_head:"noteheadDiamondBlack"},m:{code_head:"noteheadXBlack"},r:{code_head:"rest16th",stem:!1,flag:!1,rest:!0,position:"B/4",dot_shiftY:-.5,line_above:1,line_below:2},s:{getWidth:()=>tt.SLASH_NOTEHEAD_WIDTH,position:"B/4"},g:{code_head:"noteheadBlack"}}},32:{common:{beam_count:3,stem_beam_extension:7.5,stem:!0,stem_offset:0,flag:!0,code_flag_upstem:"flag32ndUp",code_flag_downstem:"flag32ndDown",stem_up_extension:9,stem_down_extension:9,tabnote_stem_up_extension:9,tabnote_stem_down_extension:9,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"noteheadBlack"},h:{code_head:"noteheadDiamondBlack"},m:{code_head:"noteheadXBlack"},r:{code_head:"rest32nd",stem:!1,flag:!1,rest:!0,position:"B/4",dot_shiftY:-1.5,line_above:2,line_below:2},s:{getWidth:()=>tt.SLASH_NOTEHEAD_WIDTH,position:"B/4"},g:{code_head:"noteheadBlack"}}},64:{common:{beam_count:4,stem_beam_extension:15,stem:!0,stem_offset:0,flag:!0,code_flag_upstem:"flag64thUp",code_flag_downstem:"flag64thDown",stem_up_extension:13,stem_down_extension:13,tabnote_stem_up_extension:13,tabnote_stem_down_extension:13,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"noteheadBlack"},h:{code_head:"noteheadDiamondBlack"},m:{code_head:"noteheadXBlack"},r:{code_head:"rest64th",stem:!1,flag:!1,rest:!0,position:"B/4",dot_shiftY:-1.5,line_above:2,line_below:3},s:{getWidth:()=>tt.SLASH_NOTEHEAD_WIDTH,position:"B/4"},g:{code_head:"noteheadBlack"}}},128:{common:{beam_count:5,stem_beam_extension:22.5,stem:!0,stem_offset:0,flag:!0,code_flag_upstem:"flag128thUp",code_flag_downstem:"flag128thDown",stem_up_extension:22,stem_down_extension:22,tabnote_stem_up_extension:22,tabnote_stem_down_extension:22,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"noteheadBlack"},h:{code_head:"noteheadDiamondBlack"},m:{code_head:"noteheadXBlack"},r:{code_head:"rest128th",stem:!1,flag:!1,rest:!0,position:"B/4",dot_shiftY:-2.5,line_above:3,line_below:3},s:{getWidth:()=>tt.SLASH_NOTEHEAD_WIDTH,position:"B/4"},g:{code_head:"noteheadBlack"}}}};function it(...t){st.DEBUG&&S("Vex.Flow.Accidental",t)}class st extends H{constructor(t){super(),it("New accidental: ",t),this.type=t,this.position=H.Position.LEFT,this.render_options={font_scale:38,parenLeftPadding:2,parenRightPadding:2},this.accidental=tt.accidentalCodes(this.type),x(this.accidental,"ArgumentError",`Unknown accidental type: ${t}`),this.cautionary=!1,this.reset()}static get CATEGORY(){return m.Accidental}static format(t,e){if(!t||0===t.length)return;const i=tt.currentMusicFont(),s=i.lookupMetric("accidental.noteheadAccidentalPadding"),n=e.left_shift+s,a=i.lookupMetric("accidental.accidentalSpacing"),o=i.lookupMetric("accidental.leftPadding"),r=[];let h,c=0;for(let e=0;e<t.length;++e){const i=t[e],s=i.getNote(),n=s.getStave(),a=i.checkIndex(),o=s.getKeyProps()[a];if(s!==h){for(let t=0;t<s.keys.length;++t)c=Math.max(s.getLeftDisplacedHeadPx()-s.getXShift(),c);h=s}if(n){const t=n.getSpacingBetweenLines(),e=n.getYForLine(o.line),s=Math.round(e/t*2)/2;r.push({y:e,line:s,shift:c,acc:i,lineSpace:t})}else r.push({line:o.line,shift:c,acc:i})}r.sort(((t,e)=>e.line-t.line));const d=[];let l,g=0;for(let t=0;t<r.length;t++){const e=r[t];void 0!==l&&l===e.line||d.push({line:e.line,flatLine:!0,dblSharpLine:!0,numAcc:0,width:0,column:0}),"b"!==e.acc.type&&"bb"!==e.acc.type&&(d[d.length-1].flatLine=!1),"##"!==e.acc.type&&(d[d.length-1].dblSharpLine=!1),d[d.length-1].numAcc++,d[d.length-1].width+=e.acc.getWidth()+a,g=e.shift>g?e.shift:g,l=e.line}let u=0;for(let t=0;t<d.length;t++){let e=!1;const i=t;let s=t;for(;s+1<d.length&&!e;)this.checkCollision(d[s],d[s+1])?s++:e=!0;const n=t=>d[i+t],a=t=>t.map(n),o=(t,e)=>{const[i,s]=a([t,e]).map((t=>t.line));return i-s},r=(...t)=>t.map(a).every((([t,e])=>!this.checkCollision(t,e))),h=s-i+1;let c,l,g=this.checkCollision(d[i],d[s])?"a":"b";switch(h){case 3:"a"===g&&.5===o(1,2)&&.5!==o(0,1)&&(g="second_on_bottom");break;case 4:r([0,2],[1,3])&&(g="spaced_out_tetrachord");break;case 5:"b"===g&&r([1,3])&&(g="spaced_out_pentachord",r([0,2],[2,4])&&(g="very_spaced_out_pentachord"));break;case 6:r([0,3],[1,4],[2,5])&&(g="spaced_out_hexachord"),r([0,2],[2,4],[1,3],[3,5])&&(g="very_spaced_out_hexachord")}if(h>=7){let e=2,i=!0;for(;!0===i;){i=!1;for(let t=0;t+e<d.length;t++)if(this.checkCollision(d[t],d[t+e])){i=!0,e++;break}}for(c=t;c<=s;c++)l=(c-t)%e+1,d[c].column=l,u=u>l?u:l}else for(c=t;c<=s;c++)l=tt.accidentalColumnsTable[h][g][c-t],d[c].column=l,u=u>l?u:l;t=s}const p=[],m=[];for(let t=0;t<=u;t++)p[t]=0,m[t]=0;p[0]=g+n,m[0]=g+n,d.forEach((t=>{t.width>p[t.column]&&(p[t.column]=t.width)}));for(let t=1;t<p.length;t++)m[t]=p[t]+m[t-1];const f=m[m.length-1];let _=0;d.forEach((t=>{let e=0;const i=_+t.numAcc;for(;_<i;_++){const i=m[t.column-1]+e;r[_].acc.setXShift(i),e+=r[_].acc.getWidth()+a,it("Line, accCount, shift: ",t.line,_,i)}})),e.left_shift+=f+o}static checkCollision(t,e){let i=e.line-t.line,s=3;i>0?(s=e.flatLine||e.dblSharpLine?2.5:3,t.dblSharpLine&&(i-=.5)):(s=t.flatLine||t.dblSharpLine?2.5:3,e.dblSharpLine&&(i-=.5));const n=Math.abs(i)<s;return it("Line_1, Line_2, Collision: ",t.line,e.line,n),n}static applyAccidentals(t,e){const i=[],s={};t.forEach((t=>{const e=new v(0,1);t.getTickables().forEach((t=>{if(t.shouldIgnoreTicks())return;const n=s[e.value()];n?n.push(t):(i.push(e.value()),s[e.value()]=[t]),e.add(t.getTicks())}))}));const a=new Y;e||(e="C");const o=a.createScaleMap(e),r={};i.forEach((t=>{const e=s[t],i=[],h=t=>{if(!g(t)||t.isRest()||t.shouldIgnoreTicks())return;const e=t;e.keys.forEach(((t,s)=>{const h=a.getNoteParts(t.split("/")[0]),c=t.split("/")[1],d=h.accidental||"n",l=h.root+d;r[h.root+c]||(r[h.root+c]=o[h.root]);const g=r[h.root+c]===l,u=i.indexOf(t)>-1;if(e.getModifiers().forEach(((t,i)=>{n(t)&&t.type==d&&t.getIndex()==s&&e.getModifiers().splice(i,1)})),!g||g&&u){r[h.root+c]=l;const n=new st(d);e.addModifier(n,s),i.push(t)}})),e.getModifiers().forEach((t=>{c(t)&&t.getGraceNotes().forEach(h)}))};e.forEach(h)}))}reset(){const t=this.render_options.font_scale;this.glyph=new U(this.accidental.code,t),this.glyph.setOriginX(1),this.cautionary&&(this.parenLeft=new U(tt.accidentalCodes("{").code,t),this.parenRight=new U(tt.accidentalCodes("}").code,t),this.parenLeft.setOriginX(1),this.parenRight.setOriginX(1))}getWidth(){if(this.cautionary){const t=x(this.parenLeft),e=x(this.parenRight),i=t.getMetrics().width+e.getMetrics().width+this.render_options.parenLeftPadding+this.render_options.parenRightPadding;return this.glyph.getMetrics().width+i}return this.glyph.getMetrics().width}setNote(t){return x(t,"ArgumentError",`Bad note value: ${t}`),this.note=t,h(t)&&(this.render_options.font_scale=25,this.reset()),this}setAsCautionary(){return this.cautionary=!0,this.render_options.font_scale=28,this.reset(),this}draw(){const{type:t,position:e,index:i,cautionary:s,x_shift:n,y_shift:a,glyph:o,render_options:{parenLeftPadding:r,parenRightPadding:h}}=this,c=this.checkContext(),d=this.checkAttachedNote();this.setRendered();const l=d.getModifierStartXY(e,i);let g=l.x+n;const u=l.y+a;if(it("Rendering: ",t,g,u),s){const t=x(this.parenLeft),e=x(this.parenRight);e.render(c,g,u),g-=e.getMetrics().width,g-=h,g-=this.accidental.parenRightPaddingAdjustment,o.render(c,g,u),g-=o.getMetrics().width,g-=r,t.render(c,g,u)}else o.render(c,g,u)}}st.DEBUG=!1;class nt extends O{constructor(t){super(),this.stem_up_y_offset=0,this.stem_down_y_offset=0,this.stem_up_y_base_offset=0,this.stem_down_y_base_offset=0,this.x_begin=(null==t?void 0:t.x_begin)||0,this.x_end=(null==t?void 0:t.x_end)||0,this.y_top=(null==t?void 0:t.y_top)||0,this.y_bottom=(null==t?void 0:t.y_bottom)||0,this.stem_extension=(null==t?void 0:t.stem_extension)||0,this.stem_direction=(null==t?void 0:t.stem_direction)||0,this.hide=(null==t?void 0:t.hide)||!1,this.isStemlet=(null==t?void 0:t.isStemlet)||!1,this.stemletHeight=(null==t?void 0:t.stemletHeight)||0,this.renderHeightAdjustment=0,this.setOptions(t)}static get CATEGORY(){return m.Stem}static get UP(){return 1}static get DOWN(){return-1}static get WIDTH(){return tt.STEM_WIDTH}static get HEIGHT(){return tt.STEM_HEIGHT}setOptions(t){this.stem_up_y_offset=(null==t?void 0:t.stem_up_y_offset)||0,this.stem_down_y_offset=(null==t?void 0:t.stem_down_y_offset)||0,this.stem_up_y_base_offset=(null==t?void 0:t.stem_up_y_base_offset)||0,this.stem_down_y_base_offset=(null==t?void 0:t.stem_down_y_base_offset)||0}setNoteHeadXBounds(t,e){return this.x_begin=t,this.x_end=e,this}setDirection(t){this.stem_direction=t}setExtension(t){this.stem_extension=t}getExtension(){return this.stem_extension}setYBounds(t,e){this.y_top=t,this.y_bottom=e}getHeight(){const t=this.stem_direction===nt.UP?this.stem_up_y_offset:this.stem_down_y_offset;return(this.y_bottom-this.y_top+(nt.HEIGHT-t+this.stem_extension))*this.stem_direction}getBoundingBox(){throw new f("NotImplemented","getBoundingBox() not implemented.")}getExtents(){const t=this.stem_direction===nt.UP,e=[this.y_top,this.y_bottom],i=nt.HEIGHT+this.stem_extension,s=(t?Math.min:Math.max)(...e),n=(t?Math.max:Math.min)(...e);return{topY:s+i*-this.stem_direction,baseY:n}}setVisibility(t){return this.hide=!t,this}setStemlet(t,e){return this.isStemlet=t,this.stemletHeight=e,this}adjustHeightForFlag(){this.renderHeightAdjustment=tt.currentMusicFont().lookupMetric("stem.heightAdjustmentForFlag",-3)}adjustHeightForBeam(){this.renderHeightAdjustment=-nt.WIDTH/2}draw(){if(this.setRendered(),this.hide)return;const t=this.checkContext();let e,i;const s=this.stem_direction;let n=0;s===nt.DOWN?(e=this.x_begin,i=this.y_top+this.stem_down_y_offset,n=this.stem_down_y_base_offset):(e=this.x_end,i=this.y_bottom-this.stem_up_y_offset,n=this.stem_up_y_base_offset);const a=this.getHeight();!function(...t){nt.DEBUG&&S("Vex.Flow.Stem",t)}("Rendering stem - ","Top Y: ",this.y_top,"Bottom Y: ",this.y_bottom);const o=this.isStemlet?a-this.stemletHeight*this.stem_direction:0;t.save(),this.applyStyle(t),t.beginPath(),t.setLineWidth(nt.WIDTH),t.moveTo(e,i-o+n),t.lineTo(e,i-a-this.renderHeightAdjustment*s),t.stroke(),this.restoreStyle(t),t.restore()}}function at(...t){ht.DEBUG&&S("Vex.Flow.TextFormatter",t)}nt.DEBUG=!1;const ot={},rt={};class ht{constructor(t){this.family="",this.size=14,this.resolution=1e3,this.glyphs={},this.serifs=!1,this.monospaced=!1,this.italic=!1,this.bold=!1,this.superscriptOffset=0,this.subscriptOffset=0,this.maxSizeGlyph="H",this.cacheKey="",this.updateParams(t)}static getFontFamilies(){const t=[];for(const e in rt){const i=rt[e];t.push(Object.assign({},i))}return t}static create(t={}){at("create: ",t),t.family||(t.family=M.SANS_SERIF);const e=[],i=t.family.split(/\s*,\s*/);for(const t of i){for(const i in rt)i.startsWith(t)&&e.push(rt[i]);if(e.length>0)break}let s;if(0===e.length)s=new ht(Object.values(rt)[0]);else if(1===e.length)s=new ht(e[0]);else{const i=M.isBold(t.weight),n=M.isItalic(t.style),a=e.find((t=>t.bold===i&&t.italic===n));if(a)s=new ht(a);else{const t=e.find((t=>t.italic===n||t.bold===i));s=new ht(t||e[0])}}const n=t.size;if(void 0!==n){const t=M.convertSizeToPointValue(n);s.setFontSize(t)}return s}static getInfo(t){return rt[t]}static registerInfo(t,e=!1){at("registerInfo: ",t,e);const i=t.family;(void 0===rt[i]||e)&&(rt[i]=t)}updateParams(t){t.family&&(this.family=t.family),t.resolution&&(this.resolution=t.resolution),t.glyphs&&(this.glyphs=t.glyphs),t.serifs&&(this.serifs=t.serifs),t.monospaced&&(this.monospaced=t.monospaced),t.italic&&(this.italic=t.italic),t.bold&&(this.bold=t.bold),t.maxSizeGlyph&&(this.maxSizeGlyph=t.maxSizeGlyph),t.superscriptOffset&&(this.superscriptOffset=t.superscriptOffset),t.subscriptOffset&&(this.subscriptOffset=t.subscriptOffset),this.updateCacheKey()}updateCacheKey(){const t=this.family.replace(/\s+/g,"_"),e=this.size,i=this.bold?k.BOLD:k.NORMAL,s=this.italic?D.ITALIC:D.NORMAL;this.cacheKey=`${t}%${e}%${i}%${s}`}getGlyphMetrics(t){return this.glyphs[t]?this.glyphs[t]:this.glyphs[this.maxSizeGlyph]}get maxHeight(){return this.getGlyphMetrics(this.maxSizeGlyph).ha/this.resolution*this.fontSizeInPixels}getWidthForCharacterInEm(t){var e;const i=this.getGlyphMetrics(t);if(i){return(null!==(e=i.advanceWidth)&&void 0!==e?e:0)/this.resolution}return.65}getWidthForTextInEm(t){const e=this.cacheKey;let i=ot[e];void 0===i&&(i={},ot[e]=i);let s=i[t];if(void 0===s){s=0;for(let e=0;e<t.length;++e)s+=this.getWidthForCharacterInEm(t[e]);i[t]=s}return s}getWidthForTextInPx(t){return this.getWidthForTextInEm(t)*this.fontSizeInPixels}setFontSize(t){return this.size=t,this.updateCacheKey(),this}get fontSizeInPixels(){return this.size*M.scaleToPxFrom.pt}getResolution(){return this.resolution}}var ct,dt;ht.DEBUG=!1,function(t){t[t.LEFT=1]="LEFT",t[t.CENTER=2]="CENTER",t[t.RIGHT=3]="RIGHT",t[t.CENTER_STEM=4]="CENTER_STEM"}(ct||(ct={})),function(t){t[t.TOP=1]="TOP",t[t.CENTER=2]="CENTER",t[t.BOTTOM=3]="BOTTOM",t[t.CENTER_STEM=4]="CENTER_STEM"}(dt||(dt={}));class lt extends H{constructor(t){super(),this.text=t,this.horizontalJustification=ct.CENTER,this.verticalJustification=dt.TOP,this.resetFont(),this.setWidth(tt.textWidth(t))}static get CATEGORY(){return m.Annotation}static get minAnnotationPadding(){return tt.currentMusicFont().lookupMetric("glyphs.noteHead.minPadding")}static format(t,e){if(!t||0===t.length)return!1;let i=0,s=0,n=0,a=0;for(let o=0;o<t.length;++o){const r=t[o],h=ht.create(r.textFont);let c=(5+h.maxHeight)/tt.STAVE_LINE_DISTANCE;const d=r.checkAttachedNote(),l=d.getGlyph().getWidth(),g=h.getWidthForTextInPx(r.text);r.horizontalJustification===ct.LEFT?(n=Math.max(l,n),i=Math.max(i,g)+lt.minAnnotationPadding):r.horizontalJustification===ct.RIGHT?(a=Math.max(l,n),s=Math.max(s,g)):(i=Math.max(i,g/2)+lt.minAnnotationPadding,s=Math.max(s,g/2),n=Math.max(l/2,n),a=Math.max(l/2,a));const m=d.getStave(),f=d.hasStem()?d.getStemDirection():nt.UP;let _=0,x=5;if(p(d))if(d.render_options.draw_stem){const t=d.getStem();t&&(_=Math.abs(t.getHeight())/tt.STAVE_LINE_DISTANCE)}else _=0;else if(u(d)){const t=d.getStem();t&&"n"===d.getNoteType()&&(_=Math.abs(t.getHeight())/tt.STAVE_LINE_DISTANCE)}if(m&&(x=m.getNumLines()),r.verticalJustification===this.VerticalJustify.TOP){let t=d.getLineNumber(!0);p(d)&&(t=x-(d.leastString()-.5)),f===nt.UP&&(t+=_);t+e.top_text_line+.5<x?(r.setTextLine(x-t),c+=x-t,e.top_text_line=c):(r.setTextLine(e.top_text_line),e.top_text_line+=c)}else if(r.verticalJustification===this.VerticalJustify.BOTTOM){let t=x-d.getLineNumber();p(d)&&(t=d.greatestString()-1),f===nt.DOWN&&(t+=_);const i=t+e.text_line+1;i<x?(r.setTextLine(x-i),c+=x-i,e.text_line=c):(r.setTextLine(e.text_line),e.text_line+=c)}else r.setTextLine(e.text_line)}const o=Math.min(Math.max(s-a,0),Math.max(s-e.right_shift,0)),r=Math.min(Math.max(i-n,0),Math.max(i-e.left_shift,0));return e.left_shift+=r,e.right_shift+=o,!0}setVerticalJustification(t){return this.verticalJustification="string"==typeof t?lt.VerticalJustifyString[t]:t,this}getJustification(){return this.horizontalJustification}setJustification(t){return this.horizontalJustification="string"==typeof t?lt.HorizontalJustifyString[t]:t,this}draw(){const t=this.checkContext(),e=this.checkAttachedNote(),i=e.hasStem()?e.getStemDirection():nt.UP,s=ht.create(this.textFont),n=e.getModifierStartXY(I.ABOVE,this.index);this.setRendered(),t.save(),this.applyStyle();const a=Object.keys(this.getAttribute("classes")).join(" ");t.openGroup(a,this.getAttribute("id")),t.setFont(this.textFont);const o=t.measureText(this.text).width,r=s.maxHeight+2;let h,c;h=this.horizontalJustification===ct.LEFT?n.x:this.horizontalJustification===ct.RIGHT?n.x-o:this.horizontalJustification===ct.CENTER?n.x-o/2:e.getStemX()-o/2;let d={},l=0;const g=e.hasStem(),u=e.checkStave();if(g&&(d=e.checkStem().getExtents(),l=u.getSpacingBetweenLines()),this.verticalJustification===dt.BOTTOM){c=e.getYs().reduce(((t,e)=>t>e?t:e)),c+=(this.text_line+1)*tt.STAVE_LINE_DISTANCE+r,g&&i===nt.DOWN&&(c=Math.max(c,d.topY+r+l*this.text_line))}else if(this.verticalJustification===dt.CENTER){const t=e.getYForTopText(this.text_line)-1;c=t+(u.getYForBottomText(this.text_line)-t)/2+r/2}else if(this.verticalJustification===dt.TOP)c=e.getYs()[0]-(this.text_line+1)*tt.STAVE_LINE_DISTANCE,g&&i===nt.UP&&(l=d.topY<u.getTopLineTopY()?tt.STAVE_LINE_DISTANCE:l,c=Math.min(c,d.topY-l*(this.text_line+1)));else{const t=e.getStemExtents();c=t.topY+(t.baseY-t.topY)/2+r/2}!function(...t){lt.DEBUG&&S("Vex.Flow.Annotation",t)}("Rendering annotation: ",this.text,h,c),t.fillText(this.text,h,c),t.closeGroup(),this.restoreStyle(),t.restore()}}lt.DEBUG=!1,lt.TEXT_FONT=Object.assign({},O.TEXT_FONT),lt.HorizontalJustify=ct,lt.HorizontalJustifyString={left:ct.LEFT,right:ct.RIGHT,center:ct.CENTER,centerStem:ct.CENTER_STEM},lt.VerticalJustify=dt,lt.VerticalJustifyString={above:dt.TOP,top:dt.TOP,below:dt.BOTTOM,bottom:dt.BOTTOM,center:dt.CENTER,centerStem:dt.CENTER_STEM};const{ABOVE:gt,BELOW:ut}=H.Position;function pt(t,e){return.5*t(e/.5)}function mt(t,e){return e===gt?t<=5:t>=1}function ft(t,e){return mt(t,e)?e===gt?Math.ceil:Math.floor:Math.round}const _t=t=>g(t)||h(t);class xt extends H{constructor(t){super(),this.type=t,this.position=ut,this.render_options={font_scale:38},this.reset()}static get CATEGORY(){return m.Articulation}static format(t,e){if(!t||0===t.length)return!1;let i=0;const s=(t,e,i)=>pt(ft(e,i),x(t.glyph.getMetrics().height)/10+.5);t.forEach((t=>{const n=t.checkAttachedNote();i=Math.max(n.getGlyph().getWidth(),i);let a=5;const o=n.hasStem()?n.getStemDirection():nt.UP;let r=0;if(u(n)){const t=n.getStem();t&&(r=Math.abs(t.getHeight())/tt.STAVE_LINE_DISTANCE)}const h=n.getStave();if(h&&(a=h.getNumLines()),t.getPosition()===gt){let i=n.getLineNumber(!0);o===nt.UP&&(i+=r);let h=s(t,e.top_text_line,gt);const c=i+e.top_text_line+.5;!t.articulation.between_lines&&c<a&&(h+=a-c),t.setTextLine(e.top_text_line),e.top_text_line+=h}else if(t.getPosition()===ut){let i=Math.max(a-n.getLineNumber(),0);o===nt.DOWN&&(i+=r);let h=s(t,e.text_line,ut);const c=i+e.text_line+.5;!t.articulation.between_lines&&c<a&&(h+=a-c),t.setTextLine(e.text_line),e.text_line+=h}}));const n=t.map((t=>t.getWidth())).reduce(((t,e)=>Math.max(e,t))),a=Math.min(Math.max(n-i,0),Math.max(n-(e.left_shift+e.right_shift),0));return e.left_shift+=a/2,e.right_shift+=a/2,!0}static easyScoreHook({articulations:t},e,i){if(!t)return;const s={staccato:"a.",tenuto:"a-",accent:"a>"};t.split(",").map((t=>t.trim().split("."))).map((([t,e])=>{const n={type:s[t]};return e&&(n.position=H.PositionString[e]),i.getFactory().Articulation(n)})).map((t=>e.addModifier(t,0)))}reset(){this.articulation=tt.articulationCodes(this.type);const t=x(this.articulation,"ArgumentError",`Articulation not found: ${this.type}`),e=(this.position===gt?t.aboveCode:t.belowCode)||t.code;this.glyph=new U(null!=e?e:"",this.render_options.font_scale),this.setWidth(x(this.glyph.getMetrics().width))}draw(){const t=this.checkContext(),e=this.checkAttachedNote();this.setRendered();const i=this.checkIndex(),{position:s,glyph:n,text_line:a}=this,o=this.articulation.between_lines,r=e.checkStave(),h=r.getSpacingBetweenLines(),c=p(e),{x:d}=e.getModifierStartXY(s,i),l=!o||c,g=function(t,e){const i=e===gt&&t.getStemDirection()===nt.UP||e===ut&&t.getStemDirection()===nt.DOWN;return _t(t)?t.hasStem()&&i?.5:1:t.hasStem()&&i?1:0}(e,s),u=tt.currentMusicFont().lookupMetric(`articulation.${n.getCode()}.padding`,0);let m={[gt]:()=>{n.setOrigin(.5,1);const t=function(t,e){const i=t.getStemDirection(),{topY:s,baseY:n}=t.getStemExtents();if(_t(t))return t.hasStem()?i===nt.UP?s:n:Math.min(...t.getYs());if(p(t))return t.hasStem()&&i===nt.UP?s:t.checkStave().getYForTopText(e);throw new f("UnknownCategory","Only can get the top and bottom ys of stavenotes and tabnotes")}(e,a)-(a+g)*h;return l?Math.min(r.getYForTopText(xt.INITIAL_OFFSET),t):t},[ut]:()=>{n.setOrigin(.5,0);const t=function(t,e){const i=t.getStemDirection(),{topY:s,baseY:n}=t.getStemExtents();if(_t(t))return t.hasStem()?i===nt.UP?n:s:Math.max(...t.getYs());if(p(t))return t.hasStem()?i===nt.UP?t.checkStave().getYForBottomText(e):s:t.checkStave().getYForBottomText(e);throw new f("UnknownCategory","Only can get the top and bottom ys of stavenotes and tabnotes")}(e,a)+(a+g)*h;return l?Math.max(r.getYForBottomText(xt.INITIAL_OFFSET),t):t}}[s]();if(!c){const t=s===gt?-1:1,a=e.getKeyProps()[i].line,r=(e.getYs()[i]-m)/h+Number(a),c=function(t,e,i,s){const n=pt(ft(e,i),e);if(t&&mt(n,i)&&n%1==0)return n+.5*-s;return n}(o,r,s,t);mt(c,s)&&n.setOrigin(.5,.5),m+=Math.abs(c-r)*h*t+u*t}!function(...t){xt.DEBUG&&S("Vex.Flow.Articulation",t)}(`Rendering articulation at (x: ${d}, y: ${m})`),n.render(t,d,m)}}xt.DEBUG=!1,xt.INITIAL_OFFSET=-.5;class St{static get CATEGORY(){return m.RenderContext}set font(t){this.setFont(t)}get font(){return this.getFont()}setRawFont(t){return this.setFont(t),this}}function yt(t,e,i,s="#F55"){t.save(),t.setFillStyle(s),t.beginPath(),t.arc(e,i,3,0,2*Math.PI,!0),t.closePath(),t.fill(),t.restore()}class Tt extends O{constructor(){super(),this._preFormatted=!1,this._postFormatted=!1,this.ticks=new v(0,1),this.intrinsicTicks=0,this.tickMultiplier=new v(1,1),this.width=0,this.x_shift=0,this.modifiers=[],this.tupletStack=[],this.align_center=!1,this.center_x_shift=0,this.ignore_ticks=!1,this.formatterMetrics={freedom:{left:0,right:0},duration:"",iterations:0,space:{used:0,mean:0,deviation:0}}}static get CATEGORY(){return m.Tickable}reset(){return this}getTicks(){return this.ticks}shouldIgnoreTicks(){return this.ignore_ticks}setIgnoreTicks(t){return this.ignore_ticks=t,this}setWidth(t){this.width=t}getWidth(){if(!this._preFormatted)throw new f("UnformattedNote","Can't call GetWidth on an unformatted note.");return this.width+(this.modifierContext?this.modifierContext.getWidth():0)}setXShift(t){return this.x_shift=t,this}getXShift(){return this.x_shift}getX(){return this.checkTickContext("Can't getX() without a TickContext.").getX()+this.x_shift}getFormatterMetrics(){return this.formatterMetrics}getCenterXShift(){return this.isCenterAligned()?this.center_x_shift:0}setCenterXShift(t){return this.center_x_shift=t,this}isCenterAligned(){return this.align_center}setCenterAlignment(t){return this.align_center=t,this}getVoice(){return x(this.voice,"NoVoice","Tickable has no voice.")}setVoice(t){this.voice=t}getTuplet(){return this.tuplet}getTupletStack(){return this.tupletStack}resetTuplet(t){let e,i;if(t){const s=this.tupletStack.indexOf(t);return-1!==s&&(this.tupletStack.splice(s,1),e=t.getNoteCount(),i=t.getNotesOccupied(),this.applyTickMultiplier(e,i)),this}for(;this.tupletStack.length;)e=(t=this.tupletStack.pop()).getNoteCount(),i=t.getNotesOccupied(),this.applyTickMultiplier(e,i);return this}setTuplet(t){if(t){this.tupletStack.push(t);const e=t.getNoteCount(),i=t.getNotesOccupied();this.applyTickMultiplier(i,e)}return this.tuplet=t,this}addToModifierContext(t){this.modifierContext=t;for(let t=0;t<this.modifiers.length;++t)this.modifierContext.addMember(this.modifiers[t]);return this.modifierContext.addMember(this),this._preFormatted=!1,this}addModifier(t,e=0){return this.modifiers.push(t),this._preFormatted=!1,this}getModifiers(){return this.modifiers}setTickContext(t){this.tickContext=t,this._preFormatted=!1}checkTickContext(t="Tickable has no tick context."){return x(this.tickContext,"NoTickContext",t)}preFormat(){this._preFormatted||(this.width=0,this.modifierContext&&(this.modifierContext.preFormat(),this.width+=this.modifierContext.getWidth()))}set preFormatted(t){this._preFormatted=t}get preFormatted(){return this._preFormatted}postFormat(){return this._postFormatted||(this._postFormatted=!0),this}set postFormatted(t){this._postFormatted=t}get postFormatted(){return this._postFormatted}getIntrinsicTicks(){return this.intrinsicTicks}setIntrinsicTicks(t){this.intrinsicTicks=t,this.ticks=this.tickMultiplier.clone().multiply(this.intrinsicTicks)}getTickMultiplier(){return this.tickMultiplier}applyTickMultiplier(t,e){this.tickMultiplier.multiply(t,e),this.ticks=this.tickMultiplier.clone().multiply(this.intrinsicTicks)}setDuration(t){const e=t.numerator*(tt.RESOLUTION/t.denominator);this.ticks=this.tickMultiplier.clone().multiply(e),this.intrinsicTicks=this.ticks.value()}getAbsoluteX(){return this.checkTickContext("Can't getAbsoluteX() without a TickContext.").getX()}setModifierContext(t){return this.modifierContext=t,this}getModifierContext(){return this.modifierContext}checkModifierContext(){return x(this.modifierContext,"NoModifierContext","No modifier context attached to this tickable.")}}class bt extends Tt{constructor(t){if(super(),!t)throw new f("BadArguments","Note must have valid initialization data to identify duration and type.");const e=bt.parseNoteStruct(t);if(!e)throw new f("BadArguments",`Invalid note initialization object: ${JSON.stringify(t)}`);this.keys=t.keys||[],this.keyProps=[],this.duration=e.duration,this.noteType=e.type,this.customTypes=e.customTypes,t.duration_override?this.setDuration(t.duration_override):this.setIntrinsicTicks(e.ticks),this.modifiers=[],this.glyph=tt.getGlyphProps(this.duration,this.noteType),this.customGlyphs=this.customTypes.map((t=>tt.getGlyphProps(this.duration,t))),this.playNote=void 0,this.ignore_ticks=!1,this.width=0,this.leftDisplacedHeadPx=0,this.rightDisplacedHeadPx=0,this.x_shift=0,this.ys=[],t.align_center&&this.setCenterAlignment(t.align_center),this.render_options={annotation_spacing:5,glyph_font_scale:1,stroke_px:1,scale:1,font:"",y_shift:0}}static get CATEGORY(){return m.Note}static plotMetrics(t,e,i){const s=e.getMetrics(),n=e.getAbsoluteX()-s.modLeftPx-s.leftDisplacedHeadPx,a=e.getAbsoluteX()-s.leftDisplacedHeadPx,o=e.getAbsoluteX(),r=e.getAbsoluteX()+s.notePx,h=e.getAbsoluteX()+s.notePx+s.rightDisplacedHeadPx,c=e.getAbsoluteX()+s.notePx+s.rightDisplacedHeadPx+s.modRightPx,d=c+(e.getFormatterMetrics().freedom.right||0),l=c-n;t.save(),t.setFont(M.SANS_SERIF,8),t.fillText(Math.round(l)+"px",n+e.getXShift(),i);const g=i+7;function u(i,s,n,a=g){t.beginPath(),t.setStrokeStyle(n),t.setFillStyle(n),t.setLineWidth(3),t.moveTo(i+e.getXShift(),a),t.lineTo(s+e.getXShift(),a),t.stroke()}u(n,a,"red"),u(a,o,"#999"),u(o,r,"green"),u(r,h,"#999"),u(h,c,"red"),u(c,d,"#DD0"),u(n-e.getXShift(),n,"#BBB"),yt(t,o+e.getXShift(),g,"blue");const p=e.getFormatterMetrics();if(p.iterations>0){const s=p.space.deviation,n=s>=0?"+":"";t.setFillStyle("red"),t.fillText(n+Math.round(s),o+e.getXShift(),i-10)}t.restore()}static parseDuration(t){if(!t)return;const e=/(\d*\/?\d+|[a-z])(d*)([nrhms]|$)/.exec(t);if(!e)return;return{duration:e[1],dots:e[2].length,type:e[3]||"n"}}static parseNoteStruct(t){const e=bt.parseDuration(t.duration);if(!e)return;let i=t.type;if(i&&!tt.validTypes[i])return;const s=[];i||(i=e.type||"n",void 0!==t.keys&&t.keys.forEach(((t,e)=>{const n=t.split("/");s[e]=n&&3===n.length?n[2]:i})));let n=tt.durationToTicks(e.duration);if(!n)return;const a=t.dots?t.dots:e.dots;if("number"!=typeof a)return;let o=n;for(let t=0;t<a;t++){if(o<=1)return;o/=2,n+=o}return{duration:e.duration,type:i,customTypes:s,dots:a,ticks:n}}getPlayNote(){return this.playNote}setPlayNote(t){return this.playNote=t,this}isRest(){return!1}addStroke(t,e){return e.setNote(this),e.setIndex(t),this.modifiers.push(e),this.preFormatted=!1,this}getStave(){return this.stave}checkStave(){return x(this.stave,"NoStave","No stave attached to instance.")}setStave(t){return this.stave=t,this.setYs([t.getYForLine(0)]),this.setContext(this.stave.getContext()),this}getLeftDisplacedHeadPx(){return this.leftDisplacedHeadPx}getRightDisplacedHeadPx(){return this.rightDisplacedHeadPx}setLeftDisplacedHeadPx(t){return this.leftDisplacedHeadPx=t,this}setRightDisplacedHeadPx(t){return this.rightDisplacedHeadPx=t,this}shouldIgnoreTicks(){return this.ignore_ticks}getLineNumber(t){return 0}getLineForRest(){return 0}getGlyph(){return this.glyph}getGlyphWidth(){if(this.glyph){if(this.glyph.getMetrics)return this.glyph.getMetrics().width;if(this.glyph.getWidth)return this.glyph.getWidth(this.render_options.glyph_font_scale)}return 0}setYs(t){return this.ys=t,this}getYs(){if(0===this.ys.length)throw new f("NoYValues","No Y-values calculated for this note.");return this.ys}getYForTopText(t){return this.checkStave().getYForTopText(t)}getVoice(){if(!this.voice)throw new f("NoVoice","Note has no voice.");return this.voice}setVoice(t){return this.voice=t,this.preFormatted=!1,this}getTickContext(){return this.checkTickContext()}setTickContext(t){return this.tickContext=t,this.preFormatted=!1,this}getDuration(){return this.duration}isDotted(){return this.getModifiersByType("Dot").length>0}hasStem(){return!1}getNoteType(){return this.noteType}getBeam(){return this.beam}checkBeam(){return x(this.beam,"NoBeam","No beam attached to instance")}hasBeam(){return null!=this.beam}setBeam(t){return this.beam=t,this}addModifier(t,e=0){const i="Note.addModifier(modifier: Modifier, index: number=0)";if("string"==typeof e&&(e=parseInt(e),console.warn(i+" expected a number for `index`, but received a string.")),"object"!=typeof t||"number"!=typeof e)throw new f("WrongParams","Incorrect call signature. Use "+i+" instead.");return t.setNote(this),t.setIndex(e),super.addModifier(t),this}getModifiersByType(t){return this.modifiers.filter((e=>e.getCategory()===t))}getModifierStartXY(t,e,i){if(!this.preFormatted)throw new f("UnformattedNote","Can't call GetModifierStartXY on an unformatted note");return{x:this.getAbsoluteX(),y:this.ys[0]}}getRightParenthesisPx(t){return this.getKeyProps()[t].displaced?this.getRightDisplacedHeadPx():0}getLeftParenthesisPx(t){return this.getKeyProps()[t].displaced?this.getLeftDisplacedHeadPx()-this.x_shift:-this.x_shift}getFirstDotPx(){let t=this.getRightDisplacedHeadPx();return 0!==this.checkModifierContext().getMembers("Parenthesis").length&&(t+=tt.currentMusicFont().lookupMetric("parenthesis.default.width")),t}getMetrics(){if(!this.preFormatted)throw new f("UnformattedNote","Can't call getMetrics on an unformatted note.");const t=this.modifierContext?this.modifierContext.getState().left_shift:0,e=this.modifierContext?this.modifierContext.getState().right_shift:0,i=this.getWidth();return{width:i,glyphWidth:this.getGlyphWidth(),notePx:i-t-e-this.leftDisplacedHeadPx-this.rightDisplacedHeadPx,modLeftPx:t,modRightPx:e,leftDisplacedHeadPx:this.leftDisplacedHeadPx,rightDisplacedHeadPx:this.rightDisplacedHeadPx,glyphPx:0}}getAbsoluteX(){let t=this.checkTickContext("Can't getAbsoluteX() without a TickContext.").getX();return this.stave&&(t+=this.stave.getNoteStartX()+tt.currentMusicFont().lookupMetric("stave.padding")),this.isCenterAligned()&&(t+=this.getCenterXShift()),t}getStemDirection(){throw new f("NoStem","No stem attached to this note.")}getStemExtents(){throw new f("NoStem","No stem attached to this note.")}getTieRightX(){let t=this.getAbsoluteX();return t+=this.glyph.getWidth()/2,t+=-this.width/2+this.width+2,t}getTieLeftX(){let t=this.getAbsoluteX();return t+=this.glyph.getWidth()/2,t-=this.width/2+2,t}getKeys(){return this.keys}getKeyProps(){return this.keyProps}}var wt,vt,Et,Ct,Nt,kt,Dt;!function(t){t[t.CENTER=0]="CENTER",t[t.LEFT=1]="LEFT",t[t.RIGHT=2]="RIGHT",t[t.ABOVE=3]="ABOVE",t[t.BELOW=4]="BELOW",t[t.BEGIN=5]="BEGIN",t[t.END=6]="END"}(wt||(wt={}));class At extends O{constructor(){super(),this.width=0,this.x=0,this.padding=10,this.position=wt.ABOVE}static get CATEGORY(){return m.StaveModifier}static get Position(){return wt}getPosition(){return this.position}setPosition(t){return this.position=t,this}getStave(){return this.stave}checkStave(){return x(this.stave,"NoStave","No stave attached to instance.")}setStave(t){return this.stave=t,this}getWidth(){return this.width}setWidth(t){return this.width=t,this}getX(){return this.x}setX(t){return this.x=t,this}placeGlyphOnLine(t,e,i,s=0){t.setYShift(e.getYForLine(null!=i?i:0)-e.getYForGlyphs()+s)}getPadding(t){return void 0!==t&&t<2?0:this.padding}setPadding(t){return this.padding=t,this}setLayoutMetrics(t){return this.layoutMetrics=t,this}getLayoutMetrics(){return this.layoutMetrics}draw(...t){}}!function(t){t[t.SINGLE=1]="SINGLE",t[t.DOUBLE=2]="DOUBLE",t[t.END=3]="END",t[t.REPEAT_BEGIN=4]="REPEAT_BEGIN",t[t.REPEAT_END=5]="REPEAT_END",t[t.REPEAT_BOTH=6]="REPEAT_BOTH",t[t.NONE=7]="NONE"}(vt||(vt={}));class Pt extends At{constructor(t){super(),this.thickness=tt.STAVE_LINE_THICKNESS;const e=vt;this.widths={},this.widths[e.SINGLE]=5,this.widths[e.DOUBLE]=5,this.widths[e.END]=5,this.widths[e.REPEAT_BEGIN]=5,this.widths[e.REPEAT_END]=5,this.widths[e.REPEAT_BOTH]=5,this.widths[e.NONE]=5,this.paddings={},this.paddings[e.SINGLE]=0,this.paddings[e.DOUBLE]=0,this.paddings[e.END]=0,this.paddings[e.REPEAT_BEGIN]=15,this.paddings[e.REPEAT_END]=15,this.paddings[e.REPEAT_BOTH]=15,this.paddings[e.NONE]=0,this.layoutMetricsMap={},this.layoutMetricsMap[e.SINGLE]={xMin:0,xMax:1,paddingLeft:5,paddingRight:5},this.layoutMetricsMap[e.DOUBLE]={xMin:-3,xMax:1,paddingLeft:5,paddingRight:5},this.layoutMetricsMap[e.END]={xMin:-5,xMax:1,paddingLeft:5,paddingRight:5},this.layoutMetricsMap[e.REPEAT_END]={xMin:-10,xMax:1,paddingLeft:5,paddingRight:5},this.layoutMetricsMap[e.REPEAT_BEGIN]={xMin:-2,xMax:10,paddingLeft:5,paddingRight:5},this.layoutMetricsMap[e.REPEAT_BOTH]={xMin:-10,xMax:10,paddingLeft:5,paddingRight:5},this.layoutMetricsMap[e.NONE]={xMin:0,xMax:0,paddingLeft:5,paddingRight:5},this.setPosition(wt.BEGIN),this.setType(t)}static get CATEGORY(){return m.Barline}static get type(){return vt}static get typeString(){return{single:vt.SINGLE,double:vt.DOUBLE,end:vt.END,repeatBegin:vt.REPEAT_BEGIN,repeatEnd:vt.REPEAT_END,repeatBoth:vt.REPEAT_BOTH,none:vt.NONE}}getType(){return this.type}setType(t){return this.type="string"==typeof t?Pt.typeString[t]:t,this.setWidth(this.widths[this.type]),this.setPadding(this.paddings[this.type]),this.setLayoutMetrics(this.layoutMetricsMap[this.type]),this}draw(t){switch(t.checkContext(),this.setRendered(),this.type){case vt.SINGLE:this.drawVerticalBar(t,this.x,!1);break;case vt.DOUBLE:this.drawVerticalBar(t,this.x,!0);break;case vt.END:this.drawVerticalEndBar(t,this.x);break;case vt.REPEAT_BEGIN:this.drawRepeatBar(t,this.x,!0),t.getX()!==this.x&&this.drawVerticalBar(t,t.getX());break;case vt.REPEAT_END:this.drawRepeatBar(t,this.x,!1);break;case vt.REPEAT_BOTH:this.drawRepeatBar(t,this.x,!1),this.drawRepeatBar(t,this.x,!0)}}drawVerticalBar(t,e,i){const s=t.checkContext(),n=t.getTopLineTopY(),a=t.getBottomLineBottomY();i&&s.fillRect(e-3,n,1,a-n),s.fillRect(e,n,1,a-n)}drawVerticalEndBar(t,e){const i=t.checkContext(),s=t.getTopLineTopY(),n=t.getBottomLineBottomY();i.fillRect(e-5,s,1,n-s),i.fillRect(e-2,s,3,n-s)}drawRepeatBar(t,e,i){const s=t.checkContext(),n=t.getTopLineTopY(),a=t.getBottomLineBottomY();let o=3;i||(o=-5),s.fillRect(e+o,n,1,a-n),s.fillRect(e-2,n,3,a-n);i?o+=4:o-=4;const r=e+o+1;let h=(t.getNumLines()-1)*t.getSpacingBetweenLines();h=h/2-t.getSpacingBetweenLines()/2;let c=n+h+1;s.beginPath(),s.arc(r,c,2,0,2*Math.PI,!1),s.fill(),c+=t.getSpacingBetweenLines(),s.beginPath(),s.arc(r,c,2,0,2*Math.PI,!1),s.fill()}}class Ft extends bt{constructor(t=vt.SINGLE){super({duration:"b"}),this.metrics={widths:{}};const e=vt;this.metrics.widths={[e.SINGLE]:8,[e.DOUBLE]:12,[e.END]:15,[e.REPEAT_BEGIN]:14,[e.REPEAT_END]:14,[e.REPEAT_BOTH]:18,[e.NONE]:0},this.ignore_ticks=!0,this.setType(t)}static get CATEGORY(){return m.BarNote}getType(){return this.type}setType(t){return this.type="string"==typeof t?Pt.typeString[t]:t,this.setWidth(this.metrics.widths[this.type]),this}addToModifierContext(t){return this}preFormat(){return this.preFormatted=!0,this}draw(){const t=this.checkContext();!function(...t){Ft.DEBUG&&S("Vex.Flow.BarNote",t)}("Rendering bar line at: ",this.getAbsoluteX()),this.style&&this.applyStyle(t);const e=new Pt(this.type);e.setX(this.getAbsoluteX()),e.draw(this.checkStave()),this.style&&this.restoreStyle(t),this.setRendered()}}Ft.DEBUG=!1;class Mt extends H{constructor(t,e=!1,i){super(),this.text=t,this.x_shift=0,this.release=e,this.tap="",this.resetFont(),this.render_options={line_width:1.5,line_style:"#777777",bend_width:8,release_width:8},i?this.phrase=i:(this.phrase=[{type:Mt.UP,text:this.text}],this.release&&this.phrase.push({type:Mt.DOWN,text:""})),this.updateWidth()}static get CATEGORY(){return m.Bend}static get UP(){return 0}static get DOWN(){return 1}static format(t,e){if(!t||0===t.length)return!1;let i=0;for(let s=0;s<t.length;++s){const n=t[s],a=n.checkAttachedNote();if(p(a)){const t=a.leastString()-1;e.top_text_line<t&&(e.top_text_line=t)}n.setXShift(i),i=n.getWidth(),n.setTextLine(e.top_text_line)}return e.right_shift+=i,e.top_text_line+=1,!0}setXShift(t){return this.x_shift=t,this.updateWidth(),this}setTap(t){return this.tap=t,this}getText(){return this.text}getTextHeight(){return ht.create(this.textFont).maxHeight}updateWidth(){const t=ht.create(this.textFont);let e=0;for(let s=0;s<this.phrase.length;++s){const n=this.phrase[s];if(void 0!==n.width)e+=n.width;else{const s=n.type===Mt.UP?this.render_options.bend_width:this.render_options.release_width;n.width=Math.max(s,(i=n.text,t.getWidthForTextInPx(i)))+3,n.draw_width=n.width/2,e+=n.width}}var i;return this.setWidth(e+this.x_shift),this}draw(){var t;const e=this.checkContext(),i=this.checkAttachedNote();this.setRendered();const s=i.getModifierStartXY(H.Position.RIGHT,this.index);s.x+=3,s.y+=.5;const n=this.x_shift,a=i.checkStave().getSpacingBetweenLines(),o=i.getYs().reduce(((t,e)=>t<e?t:e)),r=s.y-((this.text_line+1)*a+s.y-o)+3,h=s.y-((this.text_line+1)*a+s.y-o)-1,c=(t,i,s,n)=>{const a=t+s,o=i;e.save(),e.beginPath(),e.setLineWidth(this.render_options.line_width),e.setStrokeStyle(this.render_options.line_style),e.setFillStyle(this.render_options.line_style),e.moveTo(t,i),e.quadraticCurveTo(a,o,t+s,n),e.stroke(),e.restore()},d=(t,i,s,n)=>{e.save(),e.beginPath(),e.setLineWidth(this.render_options.line_width),e.setStrokeStyle(this.render_options.line_style),e.setFillStyle(this.render_options.line_style),e.moveTo(t,n),e.quadraticCurveTo(t+s,n,t+s,i),e.stroke(),e.restore()},l=(t,i,s)=>{const n=i+4*s;e.beginPath(),e.moveTo(t,i),e.lineTo(t-4,n),e.lineTo(t+4,n),e.closePath(),e.fill()},g=(t,i)=>{e.save(),e.setFont(this.textFont);const s=t-e.measureText(i).width/2;e.fillText(i,s,h),e.restore()};let u,p=0,m=0;if(null===(t=this.tap)||void 0===t?void 0:t.length){g(i.getModifierStartXY(H.Position.CENTER,this.index).x,this.tap)}for(let t=0;t<this.phrase.length;++t){const e=this.phrase[t];e.draw_width||(e.draw_width=0),0===t&&(e.draw_width+=n),m=e.draw_width+p-(1===t?n:0),e.type===Mt.UP&&(u&&u.type===Mt.UP&&l(s.x,r,1),c(s.x,s.y,m,r)),e.type===Mt.DOWN&&(u&&u.type===Mt.UP&&d(s.x,s.y,m,r),u&&u.type===Mt.DOWN&&(l(s.x,s.y,-1),d(s.x,s.y,m,r)),u||(m=e.draw_width,d(s.x,s.y,m,r))),g(s.x+m,e.text),u=e,p=e.draw_width,u.x=s.x,s.x+=m}if(!u||null==u.x)throw new f("NoLastBendForBend","Internal error.");u.type===Mt.UP?l(u.x+m,r,1):u.type===Mt.DOWN&&l(u.x+m,s.y,-1)}}function Bt(...t){Rt.DEBUG&&S("Vex.Flow.ChordSymbol",t)}Mt.TEXT_FONT=Object.assign({},O.TEXT_FONT),function(t){t[t.LEFT=1]="LEFT",t[t.CENTER=2]="CENTER",t[t.RIGHT=3]="RIGHT",t[t.CENTER_STEM=4]="CENTER_STEM"}(Et||(Et={})),function(t){t[t.TOP=1]="TOP",t[t.BOTTOM=2]="BOTTOM"}(Ct||(Ct={})),function(t){t[t.GLYPH=1]="GLYPH",t[t.TEXT=2]="TEXT",t[t.LINE=3]="LINE"}(Nt||(Nt={})),function(t){t[t.NONE=1]="NONE",t[t.SUBSCRIPT=2]="SUBSCRIPT",t[t.SUPERSCRIPT=3]="SUPERSCRIPT"}(kt||(kt={}));class Rt extends H{constructor(){super(),this.symbolBlocks=[],this.horizontal=Et.LEFT,this.vertical=Ct.TOP,this.useKerning=!0,this.reportWidth=!0,this.resetFont()}static get CATEGORY(){return m.ChordSymbol}static get superSubRatio(){return Rt.metrics.global.superSubRatio}static set NO_TEXT_FORMAT(t){Rt.noFormat=t}static get NO_TEXT_FORMAT(){return Rt.noFormat}static getMetricForGlyph(t){if(Rt.metrics[t])return Rt.metrics[t]}static get engravingFontResolution(){return tt.currentMusicFont().getResolution()}static get spacingBetweenBlocks(){return Rt.metrics.global.spacing/Rt.engravingFontResolution}static getWidthForGlyph(t){const e=Rt.getMetricForGlyph(t.code);return e?e.advanceWidth/Rt.engravingFontResolution:.65}static getYShiftForGlyph(t){const e=Rt.getMetricForGlyph(t.code);return e?e.yOffset/Rt.engravingFontResolution:0}static getXShiftForGlyph(t){const e=Rt.getMetricForGlyph(t.code);return e?-1*e.leftSideBearing/Rt.engravingFontResolution:0}static get superscriptOffset(){return Rt.metrics.global.superscriptOffset/Rt.engravingFontResolution}static get subscriptOffset(){return Rt.metrics.global.subscriptOffset/Rt.engravingFontResolution}static get kerningOffset(){return Rt.metrics.global.kerningOffset/Rt.engravingFontResolution}static get metrics(){return tt.currentMusicFont().getMetrics().glyphs.chordSymbol}static get lowerKerningText(){return Rt.metrics.global.lowerKerningText}static get upperKerningText(){return Rt.metrics.global.upperKerningText}static isSuperscript(t){return void 0!==t.symbolModifier&&t.symbolModifier===kt.SUPERSCRIPT}static isSubscript(t){return void 0!==t.symbolModifier&&t.symbolModifier===kt.SUBSCRIPT}static format(t,e){var i;if(!t||0===t.length)return!1;let s=0,n=0;const a=[];for(const o of t){const t=M.convertSizeToPointValue(null===(i=o.textFont)||void 0===i?void 0:i.size),r=M.scaleSize(t,.05),h=2*r;let c=1,d=!1;for(let t=0;t<o.symbolBlocks.length;++t){const e=o.symbolBlocks[t],i=Rt.isSuperscript(e),a=Rt.isSubscript(e),l=i||a?Rt.superSubRatio:1,g=e.symbolType===Nt.GLYPH?h*l:r*l;(i||a)&&(c=2);const u=o.textFormatter.fontSizeInPixels,p=u*l;if(e.symbolType===Nt.GLYPH&&void 0!==e.glyph?(e.width=Rt.getWidthForGlyph(e.glyph)*p,e.yShift+=Rt.getYShiftForGlyph(e.glyph)*p,e.xShift+=Rt.getXShiftForGlyph(e.glyph)*p,e.glyph.scale=e.glyph.scale*g):e.symbolType===Nt.TEXT&&(e.width=e.width*p,e.yShift+=o.getYOffsetForText(e.text)*g),e.symbolType===Nt.GLYPH&&void 0!==e.glyph&&e.glyph.code===Rt.glyphs.over.code&&(c=2),e.width+=Rt.spacingBetweenBlocks*u*l,i&&t>0){const e=o.symbolBlocks[t-1];Rt.isSuperscript(e)||(n=s)}a&&n>0&&(d=!0,e.xShift=e.xShift+(n-s),s=n,n=0,o.setEnableKerning(!1)),i||a||(n=0),e.vAlign=d,s+=e.width}o.updateKerningAdjustments(),o.updateOverBarAdjustments(),o.getVertical()===Ct.TOP?(o.setTextLine(e.top_text_line),e.top_text_line+=c):(o.setTextLine(e.text_line+1),e.text_line+=c+1),o.getReportWidth()?a.push(s):a.push(0)}return s=a.reduce(((t,e)=>t+e),0),e.left_shift+=s/2,e.right_shift+=s/2,!0}static get TEXT_FONT(){let t="Roboto Slab, Times, serif";return"Petaluma"===tt.currentMusicFont().getName()&&(t="PetalumaScript, Arial, sans-serif"),{family:t,size:12,weight:k.NORMAL,style:D.NORMAL}}get superscriptOffset(){return Rt.superscriptOffset*this.textFormatter.fontSizeInPixels}get subscriptOffset(){return Rt.subscriptOffset*this.textFormatter.fontSizeInPixels}setReportWidth(t){return this.reportWidth=t,this}getReportWidth(){return this.reportWidth}updateOverBarAdjustments(){const t=this.symbolBlocks.findIndex((({symbolType:t,glyph:e})=>t===Nt.GLYPH&&void 0!==e&&"csymDiagonalArrangementSlash"===e.code));if(t<0)return;const e=this.symbolBlocks[t].width/4,i=.25*this.textFormatter.fontSizeInPixels;let s=0;for(;s<t;++s){const t=this.symbolBlocks[s];t.xShift=t.xShift+e,t.yShift=t.yShift-i}for(s=t+1;s<this.symbolBlocks.length;++s){const t=this.symbolBlocks[s];t.xShift=t.xShift-e,t.yShift=t.yShift+i}}updateKerningAdjustments(){let t=0;for(let e=0;e<this.symbolBlocks.length;++e){const i=this.symbolBlocks[e];t+=this.getKerningAdjustment(e),i.xShift+=t}}getKerningAdjustment(t){if(!this.useKerning)return 0;const e=this.symbolBlocks[t],i=t>0?this.symbolBlocks[t-1]:void 0;let s=0;e.symbolType===Nt.GLYPH&&void 0!==e.glyph&&e.glyph.code===Rt.glyphs.over.code&&(s+=e.glyph.metrics.x_shift),void 0!==i&&i.symbolType===Nt.GLYPH&&void 0!==i.glyph&&i.glyph.code===Rt.glyphs.over.code&&(s+=i.glyph.metrics.x_shift);let n=!1,a=!1;void 0!==i&&i.symbolType===Nt.TEXT&&(n=Rt.upperKerningText.some((t=>t===i.text[i.text.length-1])),a=Rt.lowerKerningText.some((t=>t===i.text[i.text.length-1])));const o=Rt.kerningOffset*this.textFormatter.fontSizeInPixels;return n&&e.symbolModifier===kt.SUPERSCRIPT&&(s+=o),a&&e.symbolType===Nt.TEXT&&(e.text[0]>="a"&&e.text[0]<="z"&&(s+=o/2),Rt.upperKerningText.some((t=>t===(null==i?void 0:i.text[i.text.length-1])))&&(s+=o/2)),s}getSymbolBlock(t={}){var e,i,s;const n=null!==(e=t.symbolType)&&void 0!==e?e:Nt.TEXT,a={text:null!==(i=t.text)&&void 0!==i?i:"",symbolType:n,symbolModifier:null!==(s=t.symbolModifier)&&void 0!==s?s:kt.NONE,xShift:0,yShift:0,vAlign:!1,width:0};if(n===Nt.GLYPH&&"string"==typeof t.glyph){const e=Rt.glyphs[t.glyph],i=20;a.glyph=new U(e.code,i,{category:"chordSymbol"})}else n===Nt.TEXT?a.width=this.textFormatter.getWidthForTextInEm(a.text):n===Nt.LINE&&(a.width=t.width);return a}addSymbolBlock(t){return this.symbolBlocks.push(this.getSymbolBlock(t)),this}addText(t,e={}){const i=Nt.TEXT;return this.addSymbolBlock(Object.assign(Object.assign({},e),{text:t,symbolType:i}))}addTextSuperscript(t){const e=Nt.TEXT,i=kt.SUPERSCRIPT;return this.addSymbolBlock({text:t,symbolType:e,symbolModifier:i})}addTextSubscript(t){const e=Nt.TEXT,i=kt.SUBSCRIPT;return this.addSymbolBlock({text:t,symbolType:e,symbolModifier:i})}addGlyphSuperscript(t){const e=Nt.GLYPH,i=kt.SUPERSCRIPT;return this.addSymbolBlock({glyph:t,symbolType:e,symbolModifier:i})}addGlyph(t,e={}){const i=Nt.GLYPH;return this.addSymbolBlock(Object.assign(Object.assign({},e),{glyph:t,symbolType:i}))}addGlyphOrText(t,e={}){let i="";for(let s=0;s<t.length;++s){const n=t[s];Rt.glyphs[n]?(i.length>0&&(this.addText(i,e),i=""),this.addGlyph(n,e)):i+=n}return i.length>0&&this.addText(i,e),this}addLine(t,e={}){const i=Nt.LINE;return this.addSymbolBlock(Object.assign(Object.assign({},e),{symbolType:i,width:t}))}setFont(t,e,i,s){return super.setFont(t,e,i,s),this.textFormatter=ht.create(this.textFont),this}setEnableKerning(t){return this.useKerning=t,this}setVertical(t){return this.vertical="string"==typeof t?Rt.VerticalJustifyString[t]:t,this}getVertical(){return this.vertical}setHorizontal(t){return this.horizontal="string"==typeof t?Rt.HorizontalJustifyString[t]:t,this}getHorizontal(){return this.horizontal}getWidth(){let t=0;return this.symbolBlocks.forEach((e=>{t+=e.vAlign?0:e.width})),t}getYOffsetForText(t){var e;let i=0,s=0;for(s=0;s<t.length;++s){const n=this.textFormatter.getGlyphMetrics(t[s]);if(n){const t=null!==(e=n.y_max)&&void 0!==e?e:0;i=t<i?t:i}}const n=this.textFormatter.getResolution();return s>0?i/n*-1:0}draw(){const t=this.checkContext(),e=this.checkAttachedNote();this.setRendered(),t.save();const i=Object.keys(this.getAttribute("classes")).join(" ");t.openGroup(i,this.getAttribute("id"));const s=e.getModifierStartXY(H.Position.ABOVE,this.index);let n;t.setFont(this.textFont);const a=e.hasStem(),o=e.checkStave();if(this.vertical===Ct.BOTTOM){if(n=o.getYForBottomText(this.text_line+tt.TEXT_HEIGHT_OFFSET_HACK),a){const t=e.checkStem().getExtents(),i=o.getSpacingBetweenLines(),s=1===e.getStemDirection()?t.baseY:t.topY;n=Math.max(n,s+i*(this.text_line+2))}}else if(n=Math.min(o.getYForTopText(this.text_line),e.getYs()[0]-10),a){const t=e.checkStem().getExtents(),i=o.getSpacingBetweenLines();n=Math.min(n,t.topY-5-i*this.text_line)}let r=s.x;r=this.horizontal===Et.LEFT?s.x:this.horizontal===Et.RIGHT?s.x+this.getWidth():this.horizontal===Et.CENTER?s.x-this.getWidth()/2:e.getStemX()-this.getWidth()/2,Bt("Rendering ChordSymbol: ",this.textFormatter,r,n),this.symbolBlocks.forEach((e=>{const i=Rt.isSuperscript(e),s=Rt.isSubscript(e);let a=n;if(Bt("shift was ",e.xShift,e.yShift),Bt("curY pre sub ",a),i&&(a+=this.superscriptOffset),s&&(a+=this.subscriptOffset),Bt("curY sup/sub ",a),e.symbolType===Nt.TEXT){if((i||s)&&(t.save(),this.textFont)){const{family:e,size:i,weight:s,style:n}=this.textFont,a=M.scaleSize(i,Rt.superSubRatio);t.setFont(e,a,s,n)}Bt("Rendering Text: ",e.text,r+e.xShift,a+e.yShift),t.fillText(e.text,r+e.xShift,a+e.yShift),(i||s)&&t.restore()}else e.symbolType===Nt.GLYPH&&e.glyph?(a+=e.yShift,Bt("Rendering Glyph: ",e.glyph.code,r+e.xShift,a),e.glyph.render(t,r+e.xShift,a)):e.symbolType===Nt.LINE&&(Bt("Rendering Line : ",e.width,r,a),t.beginPath(),t.setLineWidth(1),t.moveTo(r,n),t.lineTo(r+e.width,a),t.stroke());r+=e.width,e.vAlign&&(r+=e.xShift)})),t.closeGroup(),t.restore()}}Rt.DEBUG=!1,Rt.HorizontalJustify=Et,Rt.HorizontalJustifyString={left:Et.LEFT,right:Et.RIGHT,center:Et.CENTER,centerStem:Et.CENTER_STEM},Rt.VerticalJustify=Ct,Rt.VerticalJustifyString={top:Ct.TOP,above:Ct.TOP,below:Ct.BOTTOM,bottom:Ct.BOTTOM},Rt.glyphs={diminished:{code:"csymDiminished"},dim:{code:"csymDiminished"},halfDiminished:{code:"csymHalfDiminished"},"+":{code:"csymAugmented"},augmented:{code:"csymAugmented"},majorSeventh:{code:"csymMajorSeventh"},minor:{code:"csymMinor"},"-":{code:"csymMinor"},"(":{code:"csymParensLeftTall"},leftParen:{code:"csymParensLeftTall"},")":{code:"csymParensRightTall"},rightParen:{code:"csymParensRightTall"},leftBracket:{code:"csymBracketLeftTall"},rightBracket:{code:"csymBracketRightTall"},leftParenTall:{code:"csymParensLeftVeryTall"},rightParenTall:{code:"csymParensRightVeryTall"},"/":{code:"csymDiagonalArrangementSlash"},over:{code:"csymDiagonalArrangementSlash"},"#":{code:"accidentalSharp"},b:{code:"accidentalFlat"}},Rt.symbolTypes=Nt,Rt.symbolModifiers=kt,Rt.noFormat=!1;class Ot extends H{constructor(){super(),this.position=H.Position.RIGHT,this.radius=2,this.setWidth(5),this.dot_shiftY=0}static get CATEGORY(){return m.Dot}static getDots(t){return t.getModifiersByType(Ot.CATEGORY)}static buildAndAttach(t,e){for(const i of t)if(null==e?void 0:e.all)for(let t=0;t<i.keys.length;t++){const e=new Ot;e.setDotShiftY(i.glyph.dot_shiftY),i.addModifier(e,t)}else if(null!=(null==e?void 0:e.index)){const t=new Ot;t.setDotShiftY(i.glyph.dot_shiftY),i.addModifier(t,null==e?void 0:e.index)}else{const t=new Ot;t.setDotShiftY(i.glyph.dot_shiftY),i.addModifier(t,0)}}static format(t,e){const i=e.right_shift;if(!t||0===t.length)return!1;const s=[],n={};for(let e=0;e<t.length;++e){const a=t[e],o=a.getNote();let r,h;if(g(o)){const t=a.checkIndex();r=o.getKeyProps()[t],h=o.getFirstDotPx()}else{if(!p(o))throw new f("Internal","Unexpected instance.");r={line:.5},h=i}const c=o.getAttribute("id");s.push({line:r.line,note:o,note_id:c,dot:a}),n[c]=Math.max(n[c]||h,h)}s.sort(((t,e)=>e.line-t.line));let a=i,o=0,r=null,h=null,c=null,d=0;for(let t=0;t<s.length;++t){const{dot:e,note:i,note_id:l,line:g}=s[t];g===r&&i===h||(a=n[l]),i.isRest()||g===r||(.5===Math.abs(g%1)?d=0:(d=.5,null==h||h.isRest()||null==r||r-g!=.5?g+d===c&&(d=-.5):d=-.5)),i.isRest()?e.dot_shiftY+=-d:e.dot_shiftY=-d,c=g+d,e.setXShift(a),a+=e.getWidth()+1,o=a>o?a:o,r=g,h=i}return e.right_shift+=o,!0}setNote(t){return this.note=t,h(t)&&(this.radius*=.5,this.setWidth(3)),this}setDotShiftY(t){return this.dot_shiftY=t,this}draw(){const t=this.checkContext(),e=this.checkAttachedNote();this.setRendered();const i=e.checkStave().getSpacingBetweenLines(),s=e.getModifierStartXY(this.position,this.index,{forceFlagRight:!0});p(e)&&(s.y=e.getStemExtents().baseY);const n=s.x+this.x_shift+this.width-this.radius,a=s.y+this.y_shift+this.dot_shiftY*i;t.beginPath(),t.arc(n,a,this.radius,0,2*Math.PI,!1),t.fill()}}class Lt extends H{constructor(t){super(),this.finger=t,this.width=7,this.position=H.Position.LEFT,this.x_shift=0,this.y_shift=0,this.x_offset=0,this.y_offset=0,this.resetFont()}static get CATEGORY(){return m.FretHandFinger}static format(t,e){const{left_shift:i,right_shift:s}=e;if(!t||0===t.length)return!1;const n=[];let a=null,o=0,r=0;for(let h=0;h<t.length;++h){const c=t[h],d=c.getNote(),l=c.getPosition(),g=c.checkIndex(),u=d.getKeyProps()[g],p=ht.create(c.textFont).maxHeight;if(c.position===I.ABOVE&&(e.top_text_line+=p/tt.STAVE_LINE_DISTANCE+.5),c.position===I.BELOW&&(e.text_line+=p/tt.STAVE_LINE_DISTANCE+.5),d!==a){for(let t=0;t<d.keys.length;++t)0===i&&(o=Math.max(d.getLeftDisplacedHeadPx(),o)),0===s&&(r=Math.max(d.getRightDisplacedHeadPx(),r));a=d}n.push({note:d,num:c,pos:l,line:u.line,shiftL:o,shiftR:r})}n.sort(((t,e)=>e.line-t.line));let h=0,c=0,d=0,l=0,g=null,u=null;for(let t=0;t<n.length;++t){let e=0;const{note:a,pos:o,num:p,line:m,shiftL:f,shiftR:_}=n[t];m===g&&a===u||(h=i+f,c=s+_);const x=p.getWidth()+1;o===H.Position.LEFT?(p.setXShift(i+h),e=i+x,d=e>d?e:d):o===H.Position.RIGHT&&(p.setXShift(c),e=r+x,l=e>l?e:l),g=m,u=a}return e.left_shift+=d,e.right_shift+=l,!0}static easyScoreHook({fingerings:t}={},e,i){null==t||t.split(",").map((t=>{const e=t.trim().split("."),s={number:e[0]};return e[1]&&(s.position=e[1]),i.getFactory().Fingering(s)})).map(((t,i)=>e.addModifier(t,i)))}setFretHandFinger(t){return this.finger=t,this}getFretHandFinger(){return this.finger}setOffsetX(t){return this.x_offset=t,this}setOffsetY(t){return this.y_offset=t,this}draw(){const t=this.checkContext(),e=this.checkAttachedNote();this.setRendered();const i=e.getModifierStartXY(this.position,this.index);let s=i.x+this.x_shift+this.x_offset,n=i.y+this.y_shift+this.y_offset+5;switch(this.position){case H.Position.ABOVE:s-=4,n-=12;break;case H.Position.BELOW:s-=2,n+=10;break;case H.Position.LEFT:s-=this.width;break;case H.Position.RIGHT:s+=1;break;default:throw new f("InvalidPosition",`The position ${this.position} does not exist`)}t.save(),t.setFont(this.textFont),t.fillText(""+this.finger,s,n),t.restore()}}Lt.TEXT_FONT={family:M.SANS_SERIF,size:9,weight:k.BOLD,style:D.NORMAL};class It extends O{constructor(t,e){super(),this.setNotes(t),this.text=e,this.render_options={cp1:8,cp2:12,text_shift_x:0,first_x_shift:0,last_x_shift:0,y_shift:7,tie_spacing:0},this.resetFont()}static get CATEGORY(){return m.StaveTie}setDirection(t){return this.direction=t,this}setNotes(t){if(!t.first_note&&!t.last_note)throw new f("BadArguments","Tie needs to have either first_note or last_note set.");if(t.first_indices||(t.first_indices=[0]),t.last_indices||(t.last_indices=[0]),t.first_indices.length!==t.last_indices.length)throw new f("BadArguments","Tied notes must have same number of indices.");return this.notes=t,this}isPartial(){return!this.notes.first_note||!this.notes.last_note}renderTie(t){if(0===t.first_ys.length||0===t.last_ys.length)throw new f("BadArguments","No Y-values to render");const e=this.checkContext();let i=this.render_options.cp1,s=this.render_options.cp2;Math.abs(t.last_x_px-t.first_x_px)<10&&(i=2,s=8);const n=this.render_options.first_x_shift,a=this.render_options.last_x_shift,o=this.render_options.y_shift*t.direction,r=this.notes.first_indices,h=this.notes.last_indices;for(let c=0;c<r.length;++c){const d=(t.last_x_px+a+(t.first_x_px+n))/2,l=t.first_ys[r[c]]+o,g=t.last_ys[h[c]]+o;if(isNaN(l)||isNaN(g))throw new f("BadArguments","Bad indices for tie rendering.");const u=(l+g)/2+i*t.direction,p=(l+g)/2+s*t.direction;this.setAttribute("el",e.openGroup("stavetie")),e.beginPath(),e.moveTo(t.first_x_px+n,l),e.quadraticCurveTo(d,u,t.last_x_px+a,g),e.quadraticCurveTo(d,p,t.first_x_px+n,l),e.closePath(),e.fill(),e.closeGroup()}}renderText(t,e){var i,s,n;if(!this.text)return;const a=this.checkContext();let o=(t+e)/2;o-=a.measureText(this.text).width/2;const r=null!==(s=null===(i=this.notes.first_note)||void 0===i?void 0:i.checkStave())&&void 0!==s?s:null===(n=this.notes.last_note)||void 0===n?void 0:n.checkStave();r&&(a.save(),a.setFont(this.textFont),a.fillText(this.text,o+this.render_options.text_shift_x,r.getYForTopText()-1),a.restore())}draw(){this.checkContext(),this.setRendered();const t=this.notes.first_note,e=this.notes.last_note;let i=0,s=0,n=[0],a=[0],o=0;if(t)i=t.getTieRightX()+this.render_options.tie_spacing,o=t.getStemDirection(),n=t.getYs();else if(e){i=e.checkStave().getTieStartX(),n=e.getYs(),this.notes.first_indices=this.notes.last_indices}if(e)s=e.getTieLeftX()+this.render_options.tie_spacing,o=e.getStemDirection(),a=e.getYs();else if(t){s=t.checkStave().getTieEndX(),a=t.getYs(),this.notes.last_indices=this.notes.first_indices}return this.direction&&(o=this.direction),this.renderTie({first_x_px:i,last_x_px:s,first_ys:n,last_ys:a,direction:o}),this.renderText(i,s),!0}}It.TEXT_FONT=Object.assign({},O.TEXT_FONT);class Wt extends It{static get CATEGORY(){return m.TabTie}static createHammeron(t){return new Wt(t,"H")}static createPulloff(t){return new Wt(t,"P")}constructor(t,e){super(t,e),this.render_options.cp1=9,this.render_options.cp2=11,this.render_options.y_shift=3,this.direction=-1}}!function(t){t[t.STRICT=1]="STRICT",t[t.SOFT=2]="SOFT",t[t.FULL=3]="FULL"}(Dt||(Dt={}));class Gt extends O{constructor(t,e){let i;if(super(),this.resolutionMultiplier=1,this.mode=Dt.STRICT,this.preFormatted=!1,this.ticksUsed=new v(0,1),this.largestTickWidth=0,this.tickables=[],this.options=Object.assign({softmaxFactor:100},e),"string"==typeof t){const e=t.match(/(\d+)\/(\d+)/);e&&(i={num_beats:parseInt(e[1]),beat_value:parseInt(e[2])})}else i=t;this.time=Object.assign({num_beats:4,beat_value:4,resolution:tt.RESOLUTION},i),this.totalTicks=new v(this.time.num_beats*(this.time.resolution/this.time.beat_value),1),this.smallestTickCount=this.totalTicks.clone()}static get CATEGORY(){return m.Voice}static get Mode(){return Dt}getTotalTicks(){return this.totalTicks}getTicksUsed(){return this.ticksUsed}getLargestTickWidth(){return this.largestTickWidth}getSmallestTickCount(){return this.smallestTickCount}getTickables(){return this.tickables}getMode(){return this.mode}setMode(t){return this.mode=t,this}getResolutionMultiplier(){return this.resolutionMultiplier}getActualResolution(){return this.resolutionMultiplier*this.time.resolution}setStave(t){return this.stave=t,this.boundingBox=void 0,this}getStave(){return this.stave}getBoundingBox(){if(!this.boundingBox){const t=this.checkStave();let e;for(let i=0;i<this.tickables.length;++i){const s=this.tickables[i];s.setStave(t);const n=s.getBoundingBox();n&&(e=e?e.mergeWith(n):n)}this.boundingBox=e}return this.boundingBox}setStrict(t){return this.mode=t?Dt.STRICT:Dt.SOFT,this}isComplete(){return this.mode!==Dt.STRICT&&this.mode!==Dt.FULL||this.ticksUsed.equals(this.totalTicks)}setSoftmaxFactor(t){return this.options.softmaxFactor=t,this}reCalculateExpTicksUsed(){const t=this.ticksUsed.value();return this.expTicksUsed=this.tickables.map((e=>Math.pow(this.options.softmaxFactor,e.getTicks().value()/t))).reduce(((t,e)=>t+e),0),this.expTicksUsed}softmax(t){this.expTicksUsed||(this.expTicksUsed=this.reCalculateExpTicksUsed());const e=this.ticksUsed.value();return(t=>Math.pow(this.options.softmaxFactor,t/e))(t)/this.expTicksUsed}addTickable(t){if(!t.shouldIgnoreTicks()){const e=t.getTicks();if(this.ticksUsed.add(e),this.expTicksUsed=0,(this.mode===Dt.STRICT||this.mode===Dt.FULL)&&this.ticksUsed.greaterThan(this.totalTicks))throw this.ticksUsed.subtract(e),new f("BadArgument","Too many ticks.");e.lessThan(this.smallestTickCount)&&(this.smallestTickCount=e.clone()),this.resolutionMultiplier=this.ticksUsed.denominator,this.totalTicks.add(0,this.ticksUsed.denominator)}return this.tickables.push(t),t.setVoice(this),this}addTickables(t){for(let e=0;e<t.length;++e)this.addTickable(t[e]);return this}preFormat(){if(this.preFormatted)return this;const t=this.checkStave();return this.tickables.forEach((e=>{e.getStave()||e.setStave(t)})),this.preFormatted=!0,this}checkStave(){return x(this.stave,"NoStave","No stave attached to instance.")}draw(t=this.checkContext(),e){let i;e=null!=e?e:this.stave,this.setRendered();for(let s=0;s<this.tickables.length;++s){const n=this.tickables[s];e&&n.setStave(e),x(n.getStave(),"MissingStave","The voice cannot draw tickables without staves.");const a=n.getBoundingBox();a&&(i=i?i.mergeWith(a):a),n.setContext(t),n.drawWithStyle()}this.boundingBox=i}}class Ut extends H{constructor(t,e){return super(),this.preFormatted=!1,this.position=H.Position.LEFT,this.grace_notes=t,this.width=0,this.show_slur=e,this.slur=void 0,this.voice=new Gt({num_beats:4,beat_value:4,resolution:tt.RESOLUTION}).setStrict(!1),this.render_options={slur_y_shift:0},this.beams=[],this.voice.addTickables(this.grace_notes),this}static get CATEGORY(){return m.GraceNoteGroup}static format(t,e){if(!t||0===t.length)return!1;const i=[];let s=null,n=0;for(let e=0;e<t.length;++e){const a=t[e],o=a.getNote(),r=g(o),h=r?4:0;if(r&&o!==s){for(let t=0;t<o.keys.length;++t)n=Math.max(o.getLeftDisplacedHeadPx(),n);s=o}i.push({shift:n,gracenote_group:a,spacing:h})}let a,o=i[0].shift;for(let t=0;t<i.length;++t){const e=i[t].gracenote_group;e.preFormat(),a=e.getWidth()+i[t].spacing,o=Math.max(a,o)}for(let t=0;t<i.length;++t){const e=i[t].gracenote_group;a=e.getWidth()+i[t].spacing,e.setSpacingFromNextModifier(o-Math.min(a,o))}return e.left_shift+=o,!0}preFormat(){this.preFormatted||(this.formatter||(this.formatter=new Pe),this.formatter.joinVoices([this.voice]).format([this.voice],0,{}),this.setWidth(this.formatter.getMinTotalWidth()),this.preFormatted=!0)}beamNotes(t){if((t=t||this.grace_notes).length>1){const e=new Ie(t);e.render_options.beam_width=3,e.render_options.partial_beam_length=4,this.beams.push(e)}return this}setWidth(t){return this.width=t,this}getWidth(){return this.width}getGraceNotes(){return this.grace_notes}draw(){const t=this.checkContext(),e=this.checkAttachedNote();if(this.setRendered(),function(...t){Ut.DEBUG&&S("Vex.Flow.GraceNoteGroup",t)}("Drawing grace note group for:",e),this.alignSubNotesWithNote(this.getGraceNotes(),e),this.grace_notes.forEach((e=>e.setContext(t).draw())),this.beams.forEach((e=>e.setContext(t).draw())),this.show_slur){const i=g(e),s=i?It:Wt;this.slur=new s({last_note:this.grace_notes[0],first_note:e,first_indices:[0],last_indices:[0]}),this.slur.render_options.cp2=12,this.slur.render_options.y_shift=(i?7:5)+this.render_options.slur_y_shift,this.slur.setContext(t).draw()}}}Ut.DEBUG=!1;class Ht extends H{constructor(t){super(),this.preFormatted=!1,this.position=H.Position.LEFT,this.subNotes=t,this.subNotes.forEach((t=>{t.setIgnoreTicks(!1)})),this.width=0,this.formatter=new Pe,this.voice=new Gt({num_beats:4,beat_value:4,resolution:tt.RESOLUTION}).setStrict(!1),this.voice.addTickables(this.subNotes)}static get CATEGORY(){return m.NoteSubGroup}static format(t,e){if(!t||0===t.length)return!1;let i=0;for(let e=0;e<t.length;++e){const s=t[e];s.preFormat(),i+=s.getWidth()}return e.left_shift+=i,!0}preFormat(){this.preFormatted||(this.formatter.joinVoices([this.voice]).format([this.voice],0),this.setWidth(this.formatter.getMinTotalWidth()),this.preFormatted=!0)}setWidth(t){return this.width=t,this}getWidth(){return this.width}draw(){const t=this.checkContext(),e=this.checkAttachedNote();this.setRendered(),this.alignSubNotesWithNote(this.subNotes,e),this.subNotes.forEach((e=>e.setContext(t).drawWithStyle()))}}class Yt{constructor(t){this.preFormatted=!1,this.postFormatted=!1,this.tickID=t&&t.tickID?t.tickID:0,this.currentTick=new v(0,1),this.maxTicks=new v(0,1),this.maxTickable=void 0,this.minTicks=void 0,this.minTickable=void 0,this.padding=1,this.x=0,this.xBase=0,this.xOffset=0,this.tickables=[],this.tickablesByVoice={},this.notePx=0,this.glyphPx=0,this.leftDisplacedHeadPx=0,this.rightDisplacedHeadPx=0,this.modLeftPx=0,this.modRightPx=0,this.totalLeftPx=0,this.totalRightPx=0,this.tContexts=[],this.width=0,this.formatterMetrics={freedom:{left:0,right:0}}}static getNextContext(t){const e=t.tContexts,i=e.indexOf(t);if(i+1<e.length)return e[i+1]}getTickID(){return this.tickID}getX(){return this.x}setX(t){return this.x=t,this.xBase=t,this.xOffset=0,this}getXBase(){return this.xBase}setXBase(t){this.xBase=t,this.x=t+this.xOffset}getXOffset(){return this.xOffset}setXOffset(t){this.xOffset=t,this.x=this.xBase+t}getWidth(){return this.width+2*this.padding}setPadding(t){return this.padding=t,this}getMaxTicks(){return this.maxTicks}getMinTicks(){return this.minTicks}getMaxTickable(){return this.maxTickable}getMinTickable(){return this.minTickable}getTickables(){return this.tickables}getTickableForVoice(t){return this.tickablesByVoice[t]}getTickablesByVoice(){return this.tickablesByVoice}getCenterAlignedTickables(){return this.tickables.filter((t=>t.isCenterAligned()))}getMetrics(){const{width:t,glyphPx:e,notePx:i,leftDisplacedHeadPx:s,rightDisplacedHeadPx:n,modLeftPx:a,modRightPx:o,totalLeftPx:r,totalRightPx:h}=this;return{width:t,glyphPx:e,notePx:i,leftDisplacedHeadPx:s,rightDisplacedHeadPx:n,modLeftPx:a,modRightPx:o,totalLeftPx:r,totalRightPx:h}}getCurrentTick(){return this.currentTick}setCurrentTick(t){this.currentTick=t,this.preFormatted=!1}addTickable(t,e){if(!t)throw new f("BadArgument","Invalid tickable added.");if(!t.shouldIgnoreTicks()){const e=t.getTicks();e.greaterThan(this.maxTicks)&&(this.maxTicks=e.clone(),this.maxTickable=t),(null==this.minTicks||e.lessThan(this.minTicks))&&(this.minTicks=e.clone(),this.minTickable=t)}return t.setTickContext(this),this.tickables.push(t),this.tickablesByVoice[e||0]=t,this.preFormatted=!1,this}preFormat(){if(this.preFormatted)return this;for(let t=0;t<this.tickables.length;++t){const e=this.tickables[t];e.preFormat();const i=e.getMetrics();this.leftDisplacedHeadPx=Math.max(this.leftDisplacedHeadPx,i.leftDisplacedHeadPx),this.rightDisplacedHeadPx=Math.max(this.rightDisplacedHeadPx,i.rightDisplacedHeadPx),this.notePx=Math.max(this.notePx,i.notePx),this.glyphPx=Math.max(this.glyphPx,i.glyphWidth||0),this.modLeftPx=Math.max(this.modLeftPx,i.modLeftPx),this.modRightPx=Math.max(this.modRightPx,i.modRightPx),this.totalLeftPx=Math.max(this.totalLeftPx,i.modLeftPx+i.leftDisplacedHeadPx),this.totalRightPx=Math.max(this.totalRightPx,i.modRightPx+i.rightDisplacedHeadPx),this.width=this.notePx+this.totalLeftPx+this.totalRightPx}return this}postFormat(){return this.postFormatted||(this.postFormatted=!0),this}getFormatterMetrics(){return this.formatterMetrics}}class jt extends H{constructor(t){super(),this.type=t,this.delayed=!1,this.render_options={font_scale:38,accidentalLowerPadding:3,accidentalUpperPadding:3},this.ornament=tt.ornamentCodes(this.type);const e=this.getMetrics();if(this.adjustForStemDirection=!1,this.reportedWidth=e&&e.reportedWidth?e.reportedWidth:0,this.stemUpYOffset=e&&e.stemUpYOffset?e.stemUpYOffset:0,this.ornamentAlignWithNoteHead=jt.ornamentAlignWithNoteHead.indexOf(this.type)>=0,!this.ornament)throw new f("ArgumentError",`Ornament not found: '${this.type}'`);this.x_shift=e?e.xOffset:0,this.y_shift=e?e.yOffset:0,this.glyph=new U(this.ornament.code,this.render_options.font_scale,{category:`ornament.${this.ornament.code}`}),jt.ornamentNoteTransition.indexOf(this.type)>=0&&(this.delayed=!0),e||this.glyph.setOrigin(.5,1)}static get CATEGORY(){return m.Ornament}static format(t,e){if(!t||0===t.length)return!1;let i=0,s=e.right_shift,n=e.left_shift,a=0;for(let o=0;o<t.length;++o){const r=t[o],h=2;if(jt.ornamentRelease.indexOf(r.type)>=0&&(r.x_shift+=s+2),jt.ornamentAttack.indexOf(r.type)>=0&&(r.x_shift-=n+2),r.reportedWidth&&r.x_shift<0?n+=r.reportedWidth:r.reportedWidth&&r.x_shift>0?s+=r.reportedWidth:i=Math.max(r.getWidth(),i),jt.ornamentArticulation.indexOf(r.type)>=0){x(r.note,"NoAttachedNote").getLineNumber()>=3||r.getPosition()===H.Position.ABOVE?(e.top_text_line+=h,r.y_shift+=a,a-=r.glyph.bbox.getH()):(e.text_line+=h,r.y_shift+=a,a+=r.glyph.bbox.getH())}else r.getPosition()===H.Position.ABOVE?(r.setTextLine(e.top_text_line),e.top_text_line+=h):(r.setTextLine(e.text_line),e.text_line+=h)}return e.left_shift=n+i/2,e.right_shift=s+i/2,!0}static get ornamentNoteTransition(){return["flip","jazzTurn","smear"]}static get ornamentAttack(){return["scoop"]}static get ornamentAlignWithNoteHead(){return["doit","fall","fallLong","doitLong","bend","plungerClosed","plungerOpen","scoop"]}static get ornamentRelease(){return["doit","fall","fallLong","doitLong","jazzTurn","smear","flip"]}static get ornamentArticulation(){return["bend","plungerClosed","plungerOpen"]}getMetrics(){return tt.currentMusicFont().getMetrics().glyphs.jazzOrnaments[this.ornament.code]}setDelayed(t){return this.delayed=t,this}setUpperAccidental(t){const e=this.render_options.font_scale/1.3;return this.accidentalUpper=new U(tt.accidentalCodes(t).code,e),this.accidentalUpper.setOrigin(.5,1),this}setLowerAccidental(t){const e=this.render_options.font_scale/1.3;return this.accidentalLower=new U(tt.accidentalCodes(t).code,e),this.accidentalLower.setOrigin(.5,1),this}draw(){const t=this.checkContext(),e=this.checkAttachedNote();this.setRendered();const i=e.getStemDirection(),s=e.checkStave(),n=Object.keys(this.getAttribute("classes")).join(" ");t.openGroup(n,this.getAttribute("id"));const a=e.checkStem().getExtents();let o=i===nt.DOWN?a.baseY:a.topY;p(e)&&(e.hasStem()?i===nt.DOWN&&(o=s.getYForTopText(this.text_line)):o=s.getYForTopText(this.text_line));const r=i===nt.DOWN,h=s.getSpacingBetweenLines();let c=1;!r&&e.hasBeam()&&(c+=.5);const d=o-h*(this.text_line+c),l=e.getModifierStartXY(this.position,this.index);let g=l.x,u=this.ornamentAlignWithNoteHead?l.y:Math.min(s.getYForTopText(this.text_line),d);if(u+=this.y_shift,this.delayed){let t=0;const i=g-(s.getX()-10);if(void 0!==this.delayXShift)t=this.delayXShift;else{t+=this.glyph.getMetrics().width/2;const n=Yt.getNextContext(e.getTickContext());t+=n?.5*(n.getX()-i):.5*(s.getX()+s.getWidth()-i),this.delayXShift=t}g+=t}!function(...t){jt.DEBUG&&S("Vex.Flow.Ornament",t)}("Rendering ornament: ",this.ornament,g,u),this.accidentalLower&&(this.accidentalLower.render(t,g,u),u-=this.accidentalLower.getMetrics().height,u-=this.render_options.accidentalLowerPadding),this.stemUpYOffset&&e.hasStem()&&1===e.getStemDirection()&&(u+=this.stemUpYOffset),e.getLineNumber()<5&&jt.ornamentNoteTransition.indexOf(this.type)>=0&&(u=e.checkStave().getBoundingBox().getY()+40),this.glyph.render(t,g+this.x_shift,u),this.accidentalUpper&&(u-=this.glyph.getMetrics().height+this.render_options.accidentalUpperPadding,this.accidentalUpper.render(t,g,u)),t.closeGroup()}}jt.DEBUG=!1;class Xt extends H{constructor(t){super(),this.position=null!=t?t:H.Position.LEFT,this.point=tt.currentMusicFont().lookupMetric("parenthesis.default.point"),this.setWidth(tt.currentMusicFont().lookupMetric("parenthesis.default.width"))}static get CATEGORY(){return m.Parenthesis}static buildAndAttach(t){for(const e of t)for(let t=0;t<e.keys.length;t++)e.addModifier(new Xt(I.LEFT),t),e.addModifier(new Xt(I.RIGHT),t)}static format(t,e){if(!t||0===t.length)return!1;let i=0,s=0;for(let e=0;e<t.length;++e){const n=t[e],a=n.getNote(),o=n.getPosition(),r=n.checkIndex();let h=0;o===I.RIGHT&&(h=a.getRightParenthesisPx(r),s=s>h+n.width?s:h+n.width),o===I.LEFT&&(h=a.getLeftParenthesisPx(r),i=i>h+n.width?i:h+n.width),n.setXShift(h)}return e.left_shift+=i,e.right_shift+=s,!0}setNote(t){return this.note=t,this.point=tt.currentMusicFont().lookupMetric("parenthesis.default.point"),this.setWidth(tt.currentMusicFont().lookupMetric("parenthesis.default.width")),h(t)&&(this.point=tt.currentMusicFont().lookupMetric("parenthesis.gracenote.point"),this.setWidth(tt.currentMusicFont().lookupMetric("parenthesis.gracenote.width"))),this}draw(){const t=this.checkContext(),e=this.checkAttachedNote();this.setRendered();const i=e.getModifierStartXY(this.position,this.index,{forceFlagRight:!0}),s=i.x+this.x_shift,n=i.y+this.y_shift;this.position==H.Position.RIGHT?U.renderGlyph(t,s+1,n,this.point,"noteheadParenthesisRight",{category:"noteHead.standard.noteheadParenthesisRight"}):this.position==H.Position.LEFT&&U.renderGlyph(t,s-2,n,this.point,"noteheadParenthesisLeft",{category:"noteHead.standard.noteheadParenthesisLeft"})}}class Vt extends bt{constructor(t){super(t),this.custom_glyph=!1,this.stem_up_x_offset=0,this.stem_down_x_offset=0,this.index=t.index,this.x=t.x||0,this.y=t.y||0,t.note_type&&(this.noteType=t.note_type),this.displaced=t.displaced||!1,this.stem_direction=t.stem_direction||nt.UP,this.line=t.line||0,this.glyph=tt.getGlyphProps(this.duration,this.noteType),x(this.glyph,"BadArguments",`No glyph found for duration '${this.duration}' and type '${this.noteType}'`),this.glyph_code=this.glyph.code_head,this.x_shift=t.x_shift||0,t.custom_glyph_code&&(this.custom_glyph=!0,this.glyph_code=t.custom_glyph_code,this.stem_up_x_offset=t.stem_up_x_offset||0,this.stem_down_x_offset=t.stem_down_x_offset||0),this.style=t.style,this.slashed=t.slashed||!1,this.render_options=Object.assign(Object.assign({},this.render_options),{glyph_font_scale:t.glyph_font_scale||tt.NOTATION_FONT_SCALE}),this.setWidth(this.glyph.getWidth(this.render_options.glyph_font_scale))}static get CATEGORY(){return m.NoteHead}getWidth(){return this.width}isDisplaced(){return!0===this.displaced}getGlyph(){return this.glyph}setX(t){return this.x=t,this}getY(){return this.y}setY(t){return this.y=t,this}getLine(){return this.line}setLine(t){return this.line=t,this}getAbsoluteX(){const t=this.preFormatted?super.getAbsoluteX():this.x,e=nt.WIDTH/2,i=tt.currentMusicFont(),s=i.lookupMetric("notehead.shiftX",0)*this.stem_direction,n=i.lookupMetric("noteHead.displaced.shiftX",0)*this.stem_direction;return t+s+(this.displaced?(this.width-e)*this.stem_direction+n:0)}getBoundingBox(){if(!this.preFormatted)throw new f("UnformattedNote","Can't call getBoundingBox on an unformatted note.");const t=this.checkStave().getSpacingBetweenLines(),e=t/2,i=this.y-e;return new C(this.getAbsoluteX(),i,this.width,t)}setStave(t){const e=this.getLine();return this.stave=t,this.stave&&(this.setY(this.stave.getYForNote(e)),this.setContext(this.stave.getContext())),this}preFormat(){if(this.preFormatted)return this;const t=this.getWidth()+this.leftDisplacedHeadPx+this.rightDisplacedHeadPx;return this.setWidth(t),this.preFormatted=!0,this}draw(){const t=this.checkContext();this.setRendered();let e=this.getAbsoluteX();this.custom_glyph&&(e+=this.stem_direction===nt.UP?this.stem_up_x_offset:this.stem_down_x_offset);const i=this.y;!function(...t){Vt.DEBUG&&S("Vex.Flow.NoteHead",t)}("Drawing note head '",this.noteType,this.duration,"' at",e,i);const s=this.stem_direction,n=this.render_options.glyph_font_scale;this.style&&this.applyStyle(t);const a=`${this.glyph_code}Stem${s===nt.UP?"Up":"Down"}`;if("s"===this.noteType){const n=this.checkStave().getSpacingBetweenLines();!function(t,e,i,s,n,a){const o=tt.SLASH_NOTEHEAD_WIDTH;t.save(),t.setLineWidth(tt.STEM_WIDTH);let r=!1;if(tt.durationToNumber(e)>2&&(r=!0),r||(i-=tt.STEM_WIDTH/2*n),t.beginPath(),t.moveTo(i,s+a),t.lineTo(i,s+1),t.lineTo(i+o,s-a),t.lineTo(i+o,s),t.lineTo(i,s+a),t.closePath(),r?t.fill():t.stroke(),tt.durationToFraction(e).equals(.5)){const e=[-3,-1,o+1,o+3];for(let n=0;n<e.length;n++)t.beginPath(),t.moveTo(i+e[n],s-10),t.lineTo(i+e[n],s+11),t.stroke()}t.restore()}(t,this.duration,e,i,s,n)}else U.renderGlyph(t,e,i,n,this.glyph_code,{category:this.custom_glyph?`noteHead.custom.${a}`:`noteHead.standard.${a}`});this.style&&this.restoreStyle(t)}}Vt.DEBUG=!1;class zt extends bt{constructor(t){super(t)}static get CATEGORY(){return m.StemmableNote}getStem(){return this.stem}checkStem(){if(!this.stem)throw new f("NoStem","No stem attached to instance");return this.stem}setStem(t){return this.stem=t,this}buildStem(){const t=new nt;return this.setStem(t),this}buildFlag(t="flag"){const{glyph:e}=this;if(this.hasFlag()){const i=this.getStemDirection()===nt.DOWN?e.code_flag_downstem:e.code_flag_upstem;this.flag=new U(i,this.render_options.glyph_font_scale,{category:t})}}getBaseCustomNoteHeadGlyph(){return this.getStemDirection()===nt.DOWN?this.customGlyphs[this.customGlyphs.length-1]:this.customGlyphs[0]}getStemLength(){return nt.HEIGHT+this.getStemExtension()}getBeamCount(){const t=this.getGlyph();return t?t.beam_count:0}getStemMinimumLength(){let t=tt.durationToFraction(this.duration).value()<=1?0:20;switch(this.duration){case"8":null==this.beam&&(t=35);break;case"16":t=null==this.beam?35:25;break;case"32":t=null==this.beam?45:35;break;case"64":t=null==this.beam?50:40;break;case"128":t=null==this.beam?55:45}return t}getStemDirection(){if(!this.stem_direction)throw new f("NoStem","No stem attached to this note.");return this.stem_direction}setStemDirection(t){if(t||(t=nt.UP),t!==nt.UP&&t!==nt.DOWN)throw new f("BadArgument",`Invalid stem direction: ${t}`);if(this.stem_direction=t,this.reset(),this.hasFlag()&&this.buildFlag(),this.beam=void 0,this.stem){this.stem.setDirection(t),this.stem.setExtension(this.getStemExtension());const e=this.getBaseCustomNoteHeadGlyph()||this.getGlyph(),i=tt.currentMusicFont().lookupMetric(`stem.noteHead.${e.code_head}`,{offsetYBaseStemUp:0,offsetYTopStemUp:0,offsetYBaseStemDown:0,offsetYTopStemDown:0});this.stem.setOptions({stem_up_y_offset:i.offsetYTopStemUp,stem_down_y_offset:i.offsetYTopStemDown,stem_up_y_base_offset:i.offsetYBaseStemUp,stem_down_y_base_offset:i.offsetYBaseStemDown})}return this.preFormatted&&this.preFormat(),this}getStemX(){const t=this.getAbsoluteX()+this.x_shift,e=this.getAbsoluteX()+this.x_shift+this.getGlyphWidth();return this.stem_direction===nt.DOWN?t:e}getCenterGlyphX(){return this.getAbsoluteX()+this.x_shift+this.getGlyphWidth()/2}getStemExtension(){const t=this.getGlyph();return null!=this.stem_extension_override?this.stem_extension_override:this.beam?t.stem_beam_extension:t?this.getStemDirection()===nt.UP?t.stem_up_extension:t.stem_down_extension:0}setStemLength(t){return this.stem_extension_override=t-nt.HEIGHT,this}getStemExtents(){if(!this.stem)throw new f("NoStem","No stem attached to this note.");return this.stem.getExtents()}getYForTopText(t){const e=this.checkStave();if(this.hasStem()){const i=this.getStemExtents();if(!i)throw new f("InvalidState","Stem does not have extents.");return Math.min(e.getYForTopText(t),i.topY-this.render_options.annotation_spacing*(t+1))}return e.getYForTopText(t)}getYForBottomText(t){const e=this.checkStave();if(this.hasStem()){const i=this.getStemExtents();if(!i)throw new f("InvalidState","Stem does not have extents.");return Math.max(e.getYForTopText(t),i.baseY+this.render_options.annotation_spacing*t)}return e.getYForBottomText(t)}hasFlag(){return tt.getGlyphProps(this.duration).flag&&!this.beam}postFormat(){var t;return null===(t=this.beam)||void 0===t||t.postFormat(),this.postFormatted=!0,this}drawStem(t){var e;this.checkContext(),this.setRendered(),this.setStem(new nt(t)),null===(e=this.stem)||void 0===e||e.setContext(this.getContext()).draw()}}function Kt(t,e,i){const s=i;t.line+=s,t.maxLine+=s,t.minLine+=s,t.note.setKeyLine(0,t.note.getKeyLine(0)+s)}class $t extends zt{constructor(t){var e,i,s;super(t),this.minLine=0,this.maxLine=0,this.ledgerLineStyle={},this.clef=null!==(e=t.clef)&&void 0!==e?e:"treble",this.octave_shift=null!==(i=t.octave_shift)&&void 0!==i?i:0,this.glyph=tt.getGlyphProps(this.duration,this.noteType),x(this.glyph,"BadArguments",`No glyph found for duration '${this.duration}' and type '${this.noteType}'`),this.displaced=!1,this.dot_shiftY=0,this.use_default_head_x=!1,this._noteHeads=[],this.modifiers=[],this.render_options=Object.assign(Object.assign({},this.render_options),{glyph_font_scale:t.glyph_font_scale||tt.NOTATION_FONT_SCALE,stroke_px:t.stroke_px||$t.LEDGER_LINE_OFFSET}),this.calculateKeyProps(),this.buildStem(),t.auto_stem?this.autoStem():this.setStemDirection(null!==(s=t.stem_direction)&&void 0!==s?s:nt.UP),this.reset(),this.buildFlag()}static get CATEGORY(){return m.StaveNote}static get STEM_UP(){return nt.UP}static get STEM_DOWN(){return nt.DOWN}static get LEDGER_LINE_OFFSET(){return 3}static get minNoteheadPadding(){return tt.currentMusicFont().lookupMetric("glyphs.noteHead.minPadding")}static format(t,e){if(!t||t.length<2)return!1;const i=[];for(let e=0;e<t.length;e++){const s=t[e].getKeyProps(),n=s[0].line;let a=s[s.length-1].line;const o=t[e].getStemDirection(),r=t[e].getStemLength()/10,h=t[e].getStemMinimumLength()/10;let c;t[e].isRest()?(c=n+t[e].glyph.line_above,a=n-t[e].glyph.line_below):(c=1===o?s[s.length-1].line+r:s[s.length-1].line,a=1===o?s[0].line:s[0].line-r),i.push({line:s[0].line,maxLine:c,minLine:a,isrest:t[e].isRest(),stemDirection:o,stemMax:r,stemMin:h,voice_shift:t[e].getVoiceShiftWidth(),is_displaced:t[e].isDisplaced(),note:t[e]})}const s=i.length;let n=i[0];const a=s>2?i[1]:void 0;let o=s>2?i[2]:i[1];2===s&&-1===n.stemDirection&&1===o.stemDirection&&(n=i[1],o=i[0]);const r=Math.max(n.voice_shift,o.voice_shift);let h=0;if(2===s){const t=n.note.hasStem()&&o.note.hasStem()&&n.stemDirection===o.stemDirection?0:.5;if(o.isrest&&n.isrest&&n.note.duration===o.note.duration)o.note.render_options.draw=!1;else if(n.minLine<=o.maxLine+t)if(n.isrest)Kt(n,0,1);else if(o.isrest)Kt(o,0,-1);else{const t=Math.abs(n.line-o.line);if(n.note.hasStem()&&o.note.hasStem()){let e=0,i=0;2===tt.durationToNumber(n.note.duration)?e++:tt.durationToNumber(n.note.duration)>2&&i++,2===tt.durationToNumber(o.note.duration)?e++:tt.durationToNumber(o.note.duration)>2&&i++,2!==e&&2!==i||n.note.getModifiersByType(m.Dot).length!==o.note.getModifiersByType(m.Dot).length||t<1&&t>0?(h=r+2,n.stemDirection===o.stemDirection?n.note.setXShift(h):o.note.setXShift(h)):n.note.voice!==o.note.voice&&n.stemDirection===o.stemDirection&&(n.line!=o.line?(h=r+2,n.note.setXShift(h)):1===o.stemDirection&&(o.stemDirection=-1,o.note.setStemDirection(-1)))}else h=r+2,n.stemDirection===o.stemDirection?n.note.setXShift(h):o.note.setXShift(h)}return e.right_shift+=h,!0}if(!a)throw new f("InvalidState","noteM not defined.");if(a.isrest&&!n.isrest&&!o.isrest&&(n.minLine<=a.maxLine||a.minLine<=o.maxLine)){return a.maxLine-a.minLine<n.minLine-o.maxLine?function(t,e,i){const s=t.line-T(e.minLine,i.maxLine);t.note.setKeyLine(0,t.note.getKeyLine(0)-s),t.line-=s,t.maxLine-=s,t.minLine-=s}(a,n,o):(h=r+2,a.note.setXShift(h),!1===o.note.hasBeam()&&(o.stemDirection=-1,o.note.setStemDirection(-1)),n.minLine<=o.maxLine&&!1===n.note.hasBeam()&&(n.stemDirection=1,n.note.setStemDirection(1))),e.right_shift+=h,!0}return n.isrest&&a.isrest&&o.isrest?(n.note.render_options.draw=!1,o.note.render_options.draw=!1,e.right_shift+=h,!0):(a.isrest&&n.isrest&&a.minLine<=o.maxLine&&(a.note.render_options.draw=!1),a.isrest&&o.isrest&&n.minLine<=a.maxLine&&(a.note.render_options.draw=!1),n.isrest&&n.minLine<=a.maxLine&&Kt(n,0,1),o.isrest&&a.minLine<=o.maxLine&&Kt(o,0,-1),(n.minLine<=a.maxLine+.5||a.minLine<=o.maxLine)&&(h=r+2,a.note.setXShift(h),!1===o.note.hasBeam()&&(o.stemDirection=-1,o.note.setStemDirection(-1)),n.minLine<=o.maxLine&&!1===n.note.hasBeam()&&(n.stemDirection=1,n.note.setStemDirection(1))),e.right_shift+=h,!0)}static postFormat(t){return!!t&&(t.forEach((t=>t.postFormat())),!0)}reset(){super.reset();const t=this._noteHeads.map((t=>t.getStyle()));this.buildNoteHeads(),this._noteHeads.forEach(((e,i)=>{const s=t[i];s&&e.setStyle(s)}));const e=this.stave;return e&&this._noteHeads.forEach((t=>t.setStave(e))),this.calcNoteDisplacements(),this}setBeam(t){return this.beam=t,this.calcNoteDisplacements(),this.stem&&this.stem.setExtension(this.getStemExtension()),this}buildStem(){return this.setStem(new nt({hide:!!this.isRest()})),this}buildNoteHeads(){this._noteHeads=[];const t=this.getStemDirection(),e=this.getKeys();let i,s,n,a,o,r=!1;t===nt.UP?(n=0,a=e.length,o=1):(n=e.length-1,a=-1,o=-1);for(let e=n;e!==a;e+=o){const n=this.keyProps[e],a=n.line;void 0===i?i=a:(s=Math.abs(i-a),0===s||.5===s?r=!r:(r=!1,this.use_default_head_x=!0)),i=a;const o=new Vt({duration:this.duration,note_type:this.noteType,displaced:r,stem_direction:t,custom_glyph_code:n.code,glyph_font_scale:this.render_options.glyph_font_scale,x_shift:n.shift_right,stem_up_x_offset:n.stem_up_x_offset,stem_down_x_offset:n.stem_down_x_offset,line:n.line});this._noteHeads[e]=o}}autoStem(){this.setStemDirection(this.calculateOptimalStemDirection())}calculateOptimalStemDirection(){this.minLine=this.keyProps[0].line,this.maxLine=this.keyProps[this.keyProps.length-1].line;return(this.minLine+this.maxLine)/2<3?nt.UP:nt.DOWN}calculateKeyProps(){let t;for(let e=0;e<this.keys.length;++e){const i=this.keys[e];this.glyph.rest&&(this.glyph.position=i);const s={octave_shift:this.octave_shift||0},n=tt.keyProperties(i,this.clef,s);if(!n)throw new f("BadArguments",`Invalid key for note properties: ${i}`);"R"===n.key&&("1"===this.duration||"w"===this.duration?n.line=4:n.line=3);const a=n.line;null==t?t=a:.5===Math.abs(t-a)&&(this.displaced=!0,n.displaced=!0,this.keyProps.length>0&&(this.keyProps[e-1].displaced=!0)),t=a,this.keyProps.push(n)}t=void 0,this.keyProps.forEach((e=>{t&&e.line<t&&y("Unsorted keys in note will be sorted. See https://github.com/0xfe/vexflow/issues/104 for details."),t=e.line})),this.keyProps.sort(((t,e)=>t.line-e.line))}getBoundingBox(){var t,e;if(!this.preFormatted)throw new f("UnformattedNote","Can't call getBoundingBox on an unformatted note.");const{width:i,modLeftPx:s,leftDisplacedHeadPx:n}=this.getMetrics(),a=this.getAbsoluteX()-s-n;let o=0,r=0;const h=(null!==(e=null===(t=this.getStave())||void 0===t?void 0:t.getSpacingBetweenLines())&&void 0!==e?e:0)/2,c=2*h;if(this.isRest()){const t=this.ys[0],e=tt.durationToFraction(this.duration);e.equals(1)||e.equals(2)?(o=t-h,r=t+h):(o=t-this.glyph.line_above*c,r=t+this.glyph.line_below*c)}else if(this.glyph.stem){const t=this.getStemExtents();t.baseY+=h*this.getStemDirection(),o=Math.min(t.topY,t.baseY),r=Math.max(t.topY,t.baseY)}else{o=0,r=0;for(let t=0;t<this.ys.length;++t){const e=this.ys[t];0===t?(o=e,r=e):(o=Math.min(e,o),r=Math.max(e,r))}o-=h,r+=h}return new C(a,o,i,r-o)}getLineNumber(t){if(!this.keyProps.length)throw new f("NoKeyProps","Can't get bottom note line, because note is not initialized properly.");let e=this.keyProps[0].line;for(let i=0;i<this.keyProps.length;i++){const s=this.keyProps[i].line;t?s>e&&(e=s):s<e&&(e=s)}return e}isRest(){return this.glyph.rest}isChord(){return!this.isRest()&&this.keys.length>1}hasStem(){return this.glyph.stem}hasFlag(){return super.hasFlag()&&!this.isRest()}getStemX(){return"r"===this.noteType?this.getCenterGlyphX():super.getStemX()+(this.stem_direction?nt.WIDTH/(2*-this.stem_direction):0)}getYForTopText(t){const e=this.getStemExtents();return Math.min(this.checkStave().getYForTopText(t),e.topY-this.render_options.annotation_spacing*(t+1))}getYForBottomText(t){const e=this.getStemExtents();return Math.max(this.checkStave().getYForTopText(t),e.baseY+this.render_options.annotation_spacing*t)}setStave(t){super.setStave(t);const e=this._noteHeads.map((e=>(e.setStave(t),e.getY())));if(this.setYs(e),this.stem){const{y_top:t,y_bottom:e}=this.getNoteHeadBounds();this.stem.setYBounds(t,e)}return this}isDisplaced(){return this.displaced}setNoteDisplaced(t){return this.displaced=t,this}getTieRightX(){let t=this.getAbsoluteX();return t+=this.getGlyphWidth()+this.x_shift+this.rightDisplacedHeadPx,this.modifierContext&&(t+=this.modifierContext.getRightShift()),t}getTieLeftX(){let t=this.getAbsoluteX();return t+=this.x_shift-this.leftDisplacedHeadPx,t}getLineForRest(){let t=this.keyProps[0].line;if(this.keyProps.length>1){const e=this.keyProps[this.keyProps.length-1].line;t=T(Math.max(t,e),Math.min(t,e))}return t}getModifierStartXY(t,e,i={}){var s,n;if(!this.preFormatted)throw new f("UnformattedNote","Can't call GetModifierStartXY on an unformatted note");if(0===this.ys.length)throw new f("NoYValues","No Y-Values calculated for this note.");const{ABOVE:a,BELOW:o,LEFT:r,RIGHT:h}=H.Position;let c=0;return t===r?c=-2:t===h?(c=this.getGlyphWidth()+this.x_shift+2,this.stem_direction===nt.UP&&this.hasFlag()&&(i.forceFlagRight||((t,e)=>e===(t.getStemDirection()===nt.UP?t.keyProps.length-1:0))(this,e))&&(c+=null!==(n=null===(s=null==this?void 0:this.flag)||void 0===s?void 0:s.getMetrics().width)&&void 0!==n?n:0)):t!==o&&t!==a||(c=this.getGlyphWidth()/2),{x:this.getAbsoluteX()+c,y:this.ys[e]}}setStyle(t){return super.setStyle(t),this._noteHeads.forEach((e=>e.setStyle(t))),this.stem&&this.stem.setStyle(t),this}setStemStyle(t){const e=this.getStem();return e&&e.setStyle(t),this}getStemStyle(){var t;return null===(t=this.stem)||void 0===t?void 0:t.getStyle()}setLedgerLineStyle(t){this.ledgerLineStyle=t}getLedgerLineStyle(){return this.ledgerLineStyle}setFlagStyle(t){this.flagStyle=t}getFlagStyle(){return this.flagStyle}setKeyStyle(t,e){return this._noteHeads[t].setStyle(e),this}setKeyLine(t,e){return this.keyProps[t].line=e,this.reset(),this}getKeyLine(t){return this.keyProps[t].line}getVoiceShiftWidth(){return this.getGlyphWidth()*(this.displaced?2:1)}calcNoteDisplacements(){this.setLeftDisplacedHeadPx(this.displaced&&this.stem_direction===nt.DOWN?this.getGlyphWidth():0),this.setRightDisplacedHeadPx(!this.hasFlag()&&this.displaced&&this.stem_direction===nt.UP?this.getGlyphWidth():0)}preFormat(){if(this.preFormatted)return;let t=0;this.modifierContext&&(this.modifierContext.preFormat(),0===this.modifierContext.getWidth()&&(t=$t.minNoteheadPadding));let e=this.getGlyphWidth()+this.leftDisplacedHeadPx+this.rightDisplacedHeadPx+t;this.shouldDrawFlag()&&this.stem_direction===nt.UP&&(e+=this.getGlyphWidth()),this.setWidth(e),this.preFormatted=!0}getNoteHeadBounds(){let t,e,i,s,n=1/0,a=-1/0,o=this.checkStave().getNumLines(),r=1,h=o,c=r;return this._noteHeads.forEach((d=>{const l=d.getLine(),g=d.getY();n=Math.min(g,n),a=Math.max(g,a),void 0===e&&d.isDisplaced()&&(e=d.getAbsoluteX()),void 0!==t||d.isDisplaced()||(t=d.getAbsoluteX()),o=Math.max(l,o),r=Math.min(l,r),d.isDisplaced()?(i=void 0===i?l:Math.max(l,i),s=void 0===s?l:Math.min(l,s)):(h=Math.max(l,h),c=Math.min(l,c))}),this),{y_top:n,y_bottom:a,displaced_x:e,non_displaced_x:t,highest_line:o,lowest_line:r,highest_displaced_line:i,lowest_displaced_line:s,highest_non_displaced_line:h,lowest_non_displaced_line:c}}getNoteHeadBeginX(){return this.getAbsoluteX()+this.x_shift}getNoteHeadEndX(){return this.getNoteHeadBeginX()+this.getGlyphWidth()}get noteHeads(){return this._noteHeads.slice()}get note_heads(){return console.warn("StaveNote.note_heads is deprecated. Use StaveNote.noteHeads instead.","This accessor will be removed in VexFlow 5.0."),this.noteHeads}drawLedgerLines(){const t=this.checkStave(),{glyph:e,render_options:{stroke_px:i}}=this,s=this.checkContext(),n=e.getWidth()+2*i,a=2*(e.getWidth()+i)-nt.WIDTH/2;if(this.isRest())return;if(!s)throw new f("NoCanvasContext","Can't draw without a canvas context.");const{highest_line:o,lowest_line:r,highest_displaced_line:h,highest_non_displaced_line:c,lowest_displaced_line:d,lowest_non_displaced_line:l,displaced_x:g,non_displaced_x:u}=this.getNoteHeadBounds();if(o<6&&r>0)return;const p=Math.min(null!=g?g:0,null!=u?u:0),m=(t,e,o)=>{let r;r=o&&e?p-i:e?(null!=u?u:0)-i:(null!=g?g:0)-i;const h=e&&o?a:n;s.beginPath(),s.moveTo(r,t),s.lineTo(r+h,t),s.stroke()},_=Object.assign(Object.assign({},t.getDefaultLedgerLineStyle()),this.getLedgerLineStyle());this.applyStyle(s,_);for(let e=6;e<=o;++e){const i=void 0!==u&&e<=c,s=void 0!==h&&e<=h;m(t.getYForNote(e),i,s)}for(let e=0;e>=r;--e){const i=void 0!==u&&e>=l,s=void 0!==d&&e>=d;m(t.getYForNote(e),i,s)}this.restoreStyle(s,_)}drawModifiers(){const t=this.checkContext();t.openGroup("modifiers");for(let e=0;e<this.modifiers.length;e++){const i=this.modifiers[e],s=i.checkIndex(),n=this._noteHeads[s],a=n.getStyle();n.applyStyle(t,a),i.setContext(t),i.drawWithStyle(),n.restoreStyle(t,a)}t.closeGroup()}shouldDrawFlag(){const t=void 0!==this.stem,e=this.glyph.flag,i=void 0===this.beam;return t&&e&&i}drawFlag(){var t,e,i,s,n;const a=this.checkContext();if(!a)throw new f("NoCanvasContext","Can't draw without a canvas context.");if(this.shouldDrawFlag()){const{y_top:o,y_bottom:r}=this.getNoteHeadBounds(),h=this.stem.getHeight(),c=this.getStemX(),d=this.getStemDirection()===nt.DOWN?o-h+2-(this.glyph?this.glyph.stem_down_extension:0)*this.getStaveNoteScale()-(null!==(e=null===(t=this.flag)||void 0===t?void 0:t.getMetrics().y_shift)&&void 0!==e?e:0)*(1-this.getStaveNoteScale()):r-h-2+(this.glyph?this.glyph.stem_up_extension:0)*this.getStaveNoteScale()-(null!==(s=null===(i=this.flag)||void 0===i?void 0:i.getMetrics().y_shift)&&void 0!==s?s:0)*(1-this.getStaveNoteScale());a.openGroup("flag",void 0,{pointerBBox:!0}),this.applyStyle(a,this.getFlagStyle()),null===(n=this.flag)||void 0===n||n.render(a,c,d),this.restoreStyle(a,this.getFlagStyle()),a.closeGroup()}}drawNoteHeads(){const t=this.checkContext();this._noteHeads.forEach((e=>{t.openGroup("notehead",void 0,{pointerBBox:!0}),e.setContext(t).draw(),t.closeGroup()}))}drawStem(t){const e=this.checkContext();t&&this.setStem(new nt(t)),this.shouldDrawFlag()&&this.stem&&this.stem.adjustHeightForFlag(),this.stem&&(e.openGroup("stem",void 0,{pointerBBox:!0}),this.stem.setContext(e).draw(),e.closeGroup())}getStaveNoteScale(){return 1}getStemExtension(){const t=super.getStemExtension();if(!this.glyph.stem)return t;const e=this.getStemDirection();if(e!==this.calculateOptimalStemDirection())return t;let i;i=e===nt.UP?3-this.maxLine:this.minLine-3;const s=i-3.5;if(s<=0)return t;const n=this.getStave();let a=10;return null!=n&&(a=n.getSpacingBetweenLines()),t+s*a}draw(){if(!1===this.render_options.draw)return;if(0===this.ys.length)throw new f("NoYValues","Can't draw note without Y values.");const t=this.checkContext(),e=this.getNoteHeadBeginX(),i=this.hasStem()&&!this.beam;if(this._noteHeads.forEach((t=>t.setX(e))),this.stem){const t=this.getStemX();this.stem.setNoteHeadXBounds(t,t)}!function(...t){$t.DEBUG&&S("Vex.Flow.StaveNote",t)}("Rendering ",this.isChord()?"chord :":"note :",this.keys),this.applyStyle(),this.setAttribute("el",t.openGroup("stavenote",this.getAttribute("id"))),this.drawLedgerLines(),t.openGroup("note",void 0,{pointerBBox:!0}),i&&this.drawStem(),this.drawNoteHeads(),this.drawFlag(),t.closeGroup(),this.drawModifiers(),t.closeGroup(),this.restoreStyle(),this.setRendered()}}function Jt(t){if(!t)return!1;const e=_();return"function"==typeof e.HTMLCanvasElement&&t instanceof e.HTMLCanvasElement||"function"==typeof t.getContext&&"function"==typeof t.toDataURL}function qt(t){if(!t)return!1;const e=_();return"function"==typeof e.HTMLDivElement&&t instanceof e.HTMLDivElement||"function"==typeof t.appendChild&&"object"==typeof t.style}$t.DEBUG=!1;class Qt extends St{constructor(t){super(),this.textHeight=0,this.context2D=t,t.canvas?this.canvas=t.canvas:this.canvas={width:Qt.WIDTH,height:Qt.HEIGHT}}static get WIDTH(){return 600}static get HEIGHT(){return 400}static get CANVAS_BROWSER_SIZE_LIMIT(){return 32767}static sanitizeCanvasDims(t,e){const i=this.CANVAS_BROWSER_SIZE_LIMIT;return Math.max(t,e)>i&&(y("Canvas dimensions exceed browser limit. Cropping to "+i),t>i&&(t=i),e>i&&(e=i)),[t,e]}clear(){this.context2D.clearRect(0,0,this.canvas.width,this.canvas.height)}openGroup(t,e,i){}closeGroup(){}add(t){}setFillStyle(t){return this.context2D.fillStyle=t,this}setBackgroundFillStyle(t){return this}setStrokeStyle(t){return this.context2D.strokeStyle=t,this}setShadowColor(t){return this.context2D.shadowColor=t,this}setShadowBlur(t){const e=this.context2D.getTransform(),i=Math.sqrt(e.a*e.a+e.b*e.b+e.c*e.c+e.d*e.d);return this.context2D.shadowBlur=i*t,this}setLineWidth(t){return this.context2D.lineWidth=t,this}setLineCap(t){return this.context2D.lineCap=t,this}setLineDash(t){return this.context2D.setLineDash(t),this}scale(t,e){return this.context2D.scale(t,e),this}resize(t,e){const i=this.context2D.canvas,s=_().devicePixelRatio||1;return[t,e]=Qt.sanitizeCanvasDims(t*s,e*s),t=t/s|0,e=e/s|0,i.width=t*s,i.height=e*s,Jt(i)&&(i.style.width=t+"px",i.style.height=e+"px"),this.scale(s,s)}rect(t,e,i,s){return this.context2D.rect(t,e,i,s),this}fillRect(t,e,i,s){return this.context2D.fillRect(t,e,i,s),this}clearRect(t,e,i,s){return this.context2D.clearRect(t,e,i,s),this}beginPath(){return this.context2D.beginPath(),this}moveTo(t,e){return this.context2D.moveTo(t,e),this}lineTo(t,e){return this.context2D.lineTo(t,e),this}bezierCurveTo(t,e,i,s,n,a){return this.context2D.bezierCurveTo(t,e,i,s,n,a),this}quadraticCurveTo(t,e,i,s){return this.context2D.quadraticCurveTo(t,e,i,s),this}arc(t,e,i,s,n,a){return this.context2D.arc(t,e,i,s,n,a),this}fill(){return this.context2D.fill(),this}stroke(){return this.context2D.stroke(),this}closePath(){return this.context2D.closePath(),this}measureText(t){const e=this.context2D.measureText(t);let i=0,s=0;return e.fontBoundingBoxAscent?(i=-e.fontBoundingBoxAscent,s=e.fontBoundingBoxDescent+e.fontBoundingBoxAscent):(i=-e.actualBoundingBoxAscent,s=e.actualBoundingBoxDescent+e.actualBoundingBoxAscent),{x:0,y:i,width:e.width,height:s}}fillText(t,e,i){return this.context2D.fillText(t,e,i),this}save(){return this.context2D.save(),this}restore(){return this.context2D.restore(),this}set fillStyle(t){this.context2D.fillStyle=t}get fillStyle(){return this.context2D.fillStyle}set strokeStyle(t){this.context2D.strokeStyle=t}get strokeStyle(){return this.context2D.strokeStyle}setFont(t,e,i,s){const n=M.validate(t,e,i,s);return this.context2D.font=M.toCSSString(n),this.textHeight=M.convertSizeToPixelValue(n.size),this}getFont(){return this.context2D.font}}const Zt={path:{x:!0,y:!0,width:!0,height:!0,"font-family":!0,"font-weight":!0,"font-style":!0,"font-size":!0},rect:{"font-family":!0,"font-weight":!0,"font-style":!0,"font-size":!0},text:{width:!0,height:!0}},te="http://www.w3.org/2000/svg",ee=2*Math.PI;class ie extends St{constructor(t){super(),this.width=0,this.height=0,this.backgroundFillStyle="white",this.fontCSSString="",this.element=t;const e=this.create("svg");this.element.appendChild(e),this.svg=e,this.parent=this.svg,this.groups=[this.svg],this.path="",this.pen={x:NaN,y:NaN},this.lineWidth=1;const i={"font-family":M.SANS_SERIF,"font-size":M.SIZE+"pt","font-weight":k.NORMAL,"font-style":D.NORMAL};this.state=Object.assign({scale:{x:1,y:1}},i),this.attributes=Object.assign({"stroke-width":.3,"stroke-dasharray":"none",fill:"black",stroke:"black"},i),this.shadow_attributes={width:0,color:"black"},this.state_stack=[]}create(t){return document.createElementNS(te,t)}openGroup(t,e,i){const s=this.create("g");return this.groups.push(s),this.parent.appendChild(s),this.parent=s,t&&s.setAttribute("class",b(t)),e&&s.setAttribute("id",b(e)),i&&i.pointerBBox&&s.setAttribute("pointer-events","bounding-box"),s}closeGroup(){this.groups.pop(),this.parent=this.groups[this.groups.length-1]}add(t){this.parent.appendChild(t)}setFillStyle(t){return this.attributes.fill=t,this}setBackgroundFillStyle(t){return this.backgroundFillStyle=t,this}setStrokeStyle(t){return this.attributes.stroke=t,this}setShadowColor(t){return this.shadow_attributes.color=t,this}setShadowBlur(t){return this.shadow_attributes.width=t,this}setLineWidth(t){return this.attributes["stroke-width"]=t,this.lineWidth=t,this}setLineDash(t){if("[object Array]"===Object.prototype.toString.call(t))return this.attributes["stroke-dasharray"]=t.join(","),this;throw new f("ArgumentError","lineDash must be an array of integers.")}setLineCap(t){return this.attributes["stroke-linecap"]=t,this}resize(t,e){this.width=t,this.height=e,this.element.style.width=t.toString(),this.svg.style.width=t.toString(),this.svg.style.height=e.toString();const i={width:t,height:e};return this.applyAttributes(this.svg,i),this.scale(this.state.scale.x,this.state.scale.y),this}scale(t,e){this.state.scale={x:t,y:e};const i=this.width/t,s=this.height/e;return this.setViewBox(0,0,i,s),this}setViewBox(t,e,i,s){if("string"==typeof t)this.svg.setAttribute("viewBox",t);else{const n=t+" "+e+" "+i+" "+s;this.svg.setAttribute("viewBox",n)}}applyAttributes(t,e){const i=Zt[t.nodeName];for(const s in e)i&&i[s]||t.setAttributeNS(null,s,e[s]);return t}clear(){for(;this.svg.lastChild;)this.svg.removeChild(this.svg.lastChild);this.scale(this.state.scale.x,this.state.scale.y)}rect(t,e,i,s,n){s<0&&(e+=s,s*=-1);const a=this.create("rect");return n=null!=n?n:{fill:"none","stroke-width":this.lineWidth,stroke:"black"},this.applyAttributes(a,Object.assign({x:t,y:e,width:i,height:s},n)),this.add(a),this}fillRect(t,e,i,s){const n={fill:this.attributes.fill};return this.rect(t,e,i,s,n),this}clearRect(t,e,i,s){return this.rect(t,e,i,s,{"stroke-width":0,fill:this.backgroundFillStyle}),this}beginPath(){return this.path="",this.pen.x=NaN,this.pen.y=NaN,this}moveTo(t,e){return this.path+="M"+t+" "+e,this.pen.x=t,this.pen.y=e,this}lineTo(t,e){return this.path+="L"+t+" "+e,this.pen.x=t,this.pen.y=e,this}bezierCurveTo(t,e,i,s,n,a){return this.path+="C"+t+" "+e+","+i+" "+s+","+n+" "+a,this.pen.x=n,this.pen.y=a,this}quadraticCurveTo(t,e,i,s){return this.path+="Q"+t+" "+e+","+i+" "+s,this.pen.x=i,this.pen.y=s,this}arc(t,e,i,s,n,a){const o=t+i*Math.cos(s),r=e+i*Math.sin(s);if(!a&&n-s>=ee||a&&s-n>=ee){const n=t+i*Math.cos(s+Math.PI),a=e+i*Math.sin(s+Math.PI);this.path+=`M${o} ${r} A${i} ${i} 0 0 0 ${n} ${a} `,this.path+=`A${i} ${i} 0 0 0 ${o} ${r}`,this.pen.x=o,this.pen.y=r}else{const h=t+i*Math.cos(n),c=e+i*Math.sin(n);let d;s=w(s),n=w(n),d=Math.abs(n-s)<Math.PI?a:!a,s>n&&(d=!d);const l=!a;this.path+=`M${o} ${r} A${i} ${i} 0 ${+d} ${+l} ${h} ${c}`,this.pen.x=h,this.pen.y=c}return this}closePath(){return this.path+="Z",this}getShadowStyle(){const t=this.shadow_attributes;return`filter: drop-shadow(0 0 ${t.width/1.5}px ${t.color})`}fill(t){const e=this.create("path");return void 0===t&&(t=Object.assign(Object.assign({},this.attributes),{stroke:"none"})),t.d=this.path,this.shadow_attributes.width>0&&(t.style=this.getShadowStyle()),this.applyAttributes(e,t),this.add(e),this}stroke(){const t=this.create("path"),e=Object.assign(Object.assign({},this.attributes),{fill:"none","stroke-width":this.lineWidth,d:this.path});return this.shadow_attributes.width>0&&(e.style=this.getShadowStyle()),this.applyAttributes(t,e),this.add(t),this}measureText(t){return ie.measureTextCache.lookup(t,this.svg,this.attributes)}fillText(t,e,i){if(!t||t.length<=0)return this;const s=Object.assign(Object.assign({},this.attributes),{stroke:"none",x:e,y:i}),n=this.create("text");return n.textContent=t,this.applyAttributes(n,s),this.add(n),this}save(){return this.state_stack.push({state:{"font-family":this.state["font-family"],"font-weight":this.state["font-weight"],"font-style":this.state["font-style"],"font-size":this.state["font-size"],scale:this.state.scale},attributes:{"font-family":this.attributes["font-family"],"font-weight":this.attributes["font-weight"],"font-style":this.attributes["font-style"],"font-size":this.attributes["font-size"],fill:this.attributes.fill,stroke:this.attributes.stroke,"stroke-width":this.attributes["stroke-width"],"stroke-dasharray":this.attributes["stroke-dasharray"]},shadow_attributes:{width:this.shadow_attributes.width,color:this.shadow_attributes.color},lineWidth:this.lineWidth}),this}restore(){const t=this.state_stack.pop();if(t){const e=t;this.state["font-family"]=e.state["font-family"],this.state["font-weight"]=e.state["font-weight"],this.state["font-style"]=e.state["font-style"],this.state["font-size"]=e.state["font-size"],this.state.scale=e.state.scale,this.attributes["font-family"]=e.attributes["font-family"],this.attributes["font-weight"]=e.attributes["font-weight"],this.attributes["font-style"]=e.attributes["font-style"],this.attributes["font-size"]=e.attributes["font-size"],this.attributes.fill=e.attributes.fill,this.attributes.stroke=e.attributes.stroke,this.attributes["stroke-width"]=e.attributes["stroke-width"],this.attributes["stroke-dasharray"]=e.attributes["stroke-dasharray"],this.shadow_attributes.width=e.shadow_attributes.width,this.shadow_attributes.color=e.shadow_attributes.color,this.lineWidth=e.lineWidth}return this}set fillStyle(t){this.setFillStyle(t)}get fillStyle(){return this.attributes.fill}set strokeStyle(t){this.setStrokeStyle(t)}get strokeStyle(){return this.attributes.stroke}setFont(t,e,i,s){const n=M.validate(t,e,i,s);this.fontCSSString=M.toCSSString(n);const a={"font-family":n.family,"font-size":n.size,"font-weight":n.weight,"font-style":n.style};return this.attributes=Object.assign(Object.assign({},this.attributes),a),this.state=Object.assign(Object.assign({},this.state),a),this}getFont(){return this.fontCSSString}}var se,ne,ae,oe;ie.measureTextCache=new class{constructor(){this.cache={}}lookup(t,e,i){let s=this.cache[t];void 0===s&&(s={},this.cache[t]=s);const n=`${i["font-family"]}%${i["font-size"]}%${i["font-weight"]}%${i["font-style"]}`;let a=s[n];return void 0===a&&(a=this.measureImpl(t,e,i),s[n]=a),a}measureImpl(t,e,i){let s=this.txt;s||(s=document.createElementNS(te,"text"),this.txt=s),s.textContent=t,s.setAttributeNS(null,"font-family",i["font-family"]),s.setAttributeNS(null,"font-size",i["font-size"]),s.setAttributeNS(null,"font-style",i["font-style"]),s.setAttributeNS(null,"font-weight",i["font-weight"]),e.appendChild(s);const n=s.getBBox();return e.removeChild(s),{x:n.x,y:n.y,width:n.width,height:n.height}}},function(t){t[t.CANVAS=1]="CANVAS",t[t.SVG=2]="SVG"}(se||(se={})),function(t){t[t.NONE=1]="NONE",t[t.UP=2]="UP",t[t.DOWN=3]="DOWN"}(ne||(ne={}));class re{constructor(t,e){if(l(t))this.ctx=t;else{if(void 0===e)throw new f("InvalidArgument","Missing backend argument");const i=e;let s;if("string"==typeof t){const e=document.getElementById(t);if(!e)throw new f("BadElementId",`Can't find element with ID "${e}"`);s=e}else s=t;if(i===re.Backends.CANVAS){if(!Jt(s))throw new f("BadElement","CANVAS context requires an HTMLCanvasElement.");const t=s.getContext("2d");if(!t)throw new f("BadElement","Can't get canvas context");this.ctx=new Qt(t)}else{if(i!==re.Backends.SVG)throw new f("InvalidBackend",`No support for backend: ${i}`);if(!qt(s))throw new f("BadElement","SVG context requires an HTMLDivElement.");this.ctx=new ie(s)}}}static buildContext(t,e,i,s,n="#FFF"){const a=new re(t,e);i&&s&&a.resize(i,s);const o=a.getContext();return o.setBackgroundFillStyle(n),re.lastContext=o,o}static getCanvasContext(t,e,i,s){return re.buildContext(t,re.Backends.CANVAS,e,i,s)}static getSVGContext(t,e,i,s){return re.buildContext(t,re.Backends.SVG,e,i,s)}static drawDashedLine(t,e,i,s,n,a){t.beginPath();const o=s-e,r=n-i,h=Math.atan2(r,o);let c=e,d=i;t.moveTo(e,i);let l=0,g=!0;for(;!(o<0?c<=s:c>=s)||!(r<0?d<=n:d>=n);){const e=a[l++%a.length],i=c+Math.cos(h)*e;c=o<0?Math.max(s,i):Math.min(s,i);const u=d+Math.sin(h)*e;d=r<0?Math.max(n,u):Math.min(n,u),g?t.lineTo(c,d):t.moveTo(c,d),g=!g}t.closePath(),t.stroke()}resize(t,e){return this.ctx.resize(t,e),this}getContext(){return this.ctx}}re.Backends=se,re.LineEndType=ne,re.lastContext=void 0;class he extends H{constructor(t){super(),this.string_number=t,this.setWidth(20),this.position=H.Position.ABOVE,this.x_shift=0,this.y_shift=0,this.text_line=0,this.stem_offset=0,this.x_offset=0,this.y_offset=0,this.dashed=!0,this.leg=re.LineEndType.NONE,this.radius=8,this.resetFont()}static get CATEGORY(){return m.StringNumber}static get metrics(){return tt.currentMusicFont().getMetrics().glyphs.stringNumber}static format(t,e){const i=e.left_shift,s=e.right_shift;if(!t||0===t.length)return!1;const n=[];let a=null,o=0,r=0;for(let h=0;h<t.length;++h){const c=t[h],d=c.getNote(),l=c.getPosition();if(!g(d))throw new f("NoStaveNote");const u=c.checkIndex(),p=d.getKeyProps()[u],m=d.getModifierContext(),_=2*c.radius/tt.STAVE_LINE_DISTANCE+.5;if(m&&(l===I.ABOVE?(c.text_line=m.getState().top_text_line,e.top_text_line+=_):l===I.BELOW&&(c.text_line=m.getState().text_line,e.text_line+=_)),d!==a){for(let t=0;t<d.keys.length;++t)0===i&&(o=Math.max(d.getLeftDisplacedHeadPx(),o)),0===s&&(r=Math.max(d.getRightDisplacedHeadPx(),r));a=d}const x=p.line;n.push({pos:l,note:d,num:c,line:x,shiftL:o,shiftR:r})}n.sort(((t,e)=>e.line-t.line));let h=0,c=0,d=0,l=null,u=null;for(let t=0;t<n.length;++t){let e=0;const a=n[t].note,r=n[t].pos,g=n[t].num,p=n[t].line,m=n[t].shiftR;p===l&&a===u||(h=s+m);const f=g.getWidth()+1;r===H.Position.LEFT?(g.setXShift(i),e=o+f,c=e>c?e:c):r===H.Position.RIGHT&&(g.setXShift(h),e+=f,d=e>d?e:d),l=p,u=a}return e.left_shift+=c,e.right_shift+=d,!0}setLineEndType(t){return t>=re.LineEndType.NONE&&t<=re.LineEndType.DOWN&&(this.leg=t),this}setStringNumber(t){return this.string_number=t,this}setOffsetX(t){return this.x_offset=t,this}setOffsetY(t){return this.y_offset=t,this}setLastNote(t){return this.last_note=t,this}setDashed(t){return this.dashed=t,this}draw(){const t=this.checkContext(),e=this.checkAttachedNote();this.setRendered();const i=e.getModifierStartXY(this.position,this.index),s=e.hasStem()?e.getStemDirection():nt.UP;let n=i.x+this.x_shift+this.x_offset,a={};e.hasStem()&&(a=e.checkStem().getExtents());let o=i.y+this.y_shift+this.y_offset;switch(this.position){case H.Position.ABOVE:o=e.getYs().reduce(((t,e)=>t<e?t:e)),e.hasStem()&&s==nt.UP&&(o=a.topY+he.metrics.stemPadding),o-=this.radius+he.metrics.verticalPadding+this.text_line*tt.STAVE_LINE_DISTANCE;break;case H.Position.BELOW:o=e.getYs().reduce(((t,e)=>t>e?t:e)),e.hasStem()&&s==nt.DOWN&&(o=a.topY-he.metrics.stemPadding),o+=this.radius+he.metrics.verticalPadding+this.text_line*tt.STAVE_LINE_DISTANCE;break;case H.Position.LEFT:n-=this.radius/2+he.metrics.leftPadding;break;case H.Position.RIGHT:n+=this.radius/2+he.metrics.rightPadding;break;default:throw new f("InvalidPosition",`The position ${this.position} is invalid`)}t.save(),t.beginPath(),t.arc(n,o,this.radius,0,2*Math.PI,!1),t.setLineWidth(1.5),t.stroke(),t.setFont(this.textFont);const r=n-t.measureText(this.string_number).width/2;t.fillText(""+this.string_number,r,o+4.5);const h=this.last_note;if(u(h)){const i=h.getStemX()-e.getX()+5;let s,a;switch(t.setStrokeStyle("#000000"),t.setLineCap("round"),t.setLineWidth(.6),this.dashed?re.drawDashedLine(t,n+10,o,n+i,o,[3,3]):re.drawDashedLine(t,n+10,o,n+i,o,[3,0]),this.leg){case re.LineEndType.UP:s=-10,a=this.dashed?[3,3]:[3,0],re.drawDashedLine(t,n+i,o,n+i,o+s,a);break;case re.LineEndType.DOWN:s=10,a=this.dashed?[3,3]:[3,0],re.drawDashedLine(t,n+i,o,n+i,o+s,a)}}t.restore()}}he.TEXT_FONT={family:M.SANS_SERIF,size:M.SIZE,weight:k.BOLD,style:D.NORMAL};class ce extends H{constructor(t,e){super(),this.options=Object.assign({all_voices:!0},e),this.all_voices=this.options.all_voices,this.type=t,this.position=H.Position.LEFT,this.render_options={font_scale:38},this.resetFont(),this.setXShift(0),this.setWidth(10)}static get CATEGORY(){return m.Stroke}static format(t,e){const i=e.left_shift;if(!t||0===t.length)return!1;const s=t.map((t=>{const e=t.getNote(),i=t.checkIndex();if(g(e)){const{line:s}=e.getKeyProps()[i];return{line:s,shift:e.getLeftDisplacedHeadPx(),stroke:t}}if(p(e)){const{str:s}=e.getPositions()[i];return{line:s,shift:0,stroke:t}}throw new f("Internal","Unexpected instance.")})),n=i,a=s.reduce(((t,{stroke:e,shift:i})=>(e.setXShift(n+i),Math.max(e.getWidth()+0,t))),0);return e.left_shift+=a,!0}getPosition(){return this.position}addEndNote(t){return this.note_end=t,this}draw(){const t=this.checkContext(),e=this.checkAttachedNote();this.setRendered();const i=e.getModifierStartXY(this.position,this.index);let s=e.getYs(),n=i.y,a=i.y;const o=i.x-5,r=e.checkStave().getSpacingBetweenLines(),h=this.checkModifierContext().getMembers(e.getCategory());for(let t=0;t<h.length;t++){const e=h[t];if(d(e)){s=e.getYs();for(let e=0;e<s.length;e++)(this.note===h[t]||this.all_voices)&&(n=Math.min(n,s[e]),a=Math.max(a,s[e]))}}let c="",l=0,u=0,p=0,m=0;switch(this.type){case ce.Type.BRUSH_DOWN:c="arrowheadBlackUp",l=-3,u=n-r/2+10,a+=r/2;break;case ce.Type.BRUSH_UP:c="arrowheadBlackDown",l=.5,u=a+r/2,n-=r/2;break;case ce.Type.ROLL_DOWN:case ce.Type.RASQUEDO_DOWN:c="arrowheadBlackUp",l=-3,p=this.x_shift+l-2,g(e)?(n+=1.5*r,a+=(a-n)%2!=0?.5*r:r,u=n-r,m=a+r+2):(n+=1.5*r,a+=r,u=n-.75*r,m=a+.25*r);break;case ce.Type.ROLL_UP:case ce.Type.RASQUEDO_UP:c="arrowheadBlackDown",l=-4,p=this.x_shift+l-1,g(e)?(u=r/2,n+=.5*r,(a-n)%2==0&&(a+=r/2),u=a+.5*r,m=n-1.25*r):(n+=.25*r,a+=.5*r,u=a+.25*r,m=n-r);break;case ce.Type.ARPEGGIO_DIRECTIONLESS:n+=.5*r,a+=r;break;default:throw new f("InvalidType",`The stroke type ${this.type} does not exist`)}let _="straight";if(this.type===ce.Type.BRUSH_DOWN||this.type===ce.Type.BRUSH_UP)t.fillRect(o+this.x_shift,n,1,a-n);else if(_="wiggly",g(e))for(let e=n;e<=a;e+=r)U.renderGlyph(t,o+this.x_shift-4,e,this.render_options.font_scale,"vexWiggleArpeggioUp");else{let e;for(e=n;e<=a;e+=10)U.renderGlyph(t,o+this.x_shift-4,e,this.render_options.font_scale,"vexWiggleArpeggioUp");this.type===ce.Type.RASQUEDO_DOWN&&(m=e+.25*r)}this.type!==ce.Type.ARPEGGIO_DIRECTIONLESS&&(U.renderGlyph(t,o+this.x_shift+l,u,this.render_options.font_scale,c,{category:`stroke.${c}.${_}`}),this.type!==ce.Type.RASQUEDO_DOWN&&this.type!==ce.Type.RASQUEDO_UP||(t.save(),t.setFont(this.textFont),t.fillText("R",o+p,m),t.restore()))}}ce.Type={BRUSH_DOWN:1,BRUSH_UP:2,ROLL_DOWN:3,ROLL_UP:4,RASQUEDO_DOWN:5,RASQUEDO_UP:6,ARPEGGIO_DIRECTIONLESS:7},ce.TEXT_FONT={family:M.SERIF,size:M.SIZE,weight:k.BOLD,style:D.ITALIC};class de extends H{constructor(){super(),this.position=H.Position.RIGHT,this.render_options={harsh:!1,vibrato_width:20,wave_height:6,wave_width:4,wave_girth:2},this.setVibratoWidth(this.render_options.vibrato_width)}static get CATEGORY(){return m.Vibrato}static format(t,e,i){if(!t||0===t.length)return!1;let s=e.top_text_line,n=0,a=e.right_shift-7;const o=i.getMembers(Mt.CATEGORY);if(o&&o.length>0){s-=o.map((t=>t.getTextHeight())).reduce(((t,e)=>t>e?t:e))/tt.STAVE_LINE_DISTANCE+1}else e.top_text_line+=1;for(let e=0;e<t.length;++e){const i=t[e];i.setXShift(a),i.setTextLine(s),n+=i.getWidth(),a+=n}return e.right_shift+=n,!0}setHarsh(t){return this.render_options.harsh=t,this}setVibratoWidth(t){return this.render_options.vibrato_width=t,this.setWidth(t),this}draw(){const t=this.checkContext(),e=this.checkAttachedNote();this.setRendered();const i=e.getModifierStartXY(H.Position.RIGHT,this.index).x+this.x_shift,s=e.getYForTopText(this.text_line)+2;de.renderVibrato(t,i,s,this.render_options)}static renderVibrato(t,e,i,s){const{harsh:n,vibrato_width:a,wave_width:o,wave_girth:r,wave_height:h}=s,c=a/o;let d;if(t.beginPath(),n){for(t.moveTo(e,i+r+1),d=0;d<c/2;++d)t.lineTo(e+o,i-h/2),e+=o,t.lineTo(e+o,i+h/2),e+=o;for(d=0;d<c/2;++d)t.lineTo(e-o,i-h/2+r+1),e-=o,t.lineTo(e-o,i+h/2+r+1),e-=o;t.fill()}else{for(t.moveTo(e,i+r),d=0;d<c/2;++d)t.quadraticCurveTo(e+o/2,i-h/2,e+o,i),e+=o,t.quadraticCurveTo(e+o/2,i+h/2,e+o,i),e+=o;for(d=0;d<c/2;++d)t.quadraticCurveTo(e-o/2,i+h/2+r,e-o,i+r),e-=o,t.quadraticCurveTo(e-o/2,i-h/2+r,e-o,i+r),e-=o;t.fill()}}}function le(...t){ge.DEBUG&&S("Vex.Flow.ModifierContext",t)}class ge{constructor(){this.state={left_shift:0,right_shift:0,text_line:0,top_text_line:0},this.members={},this.preFormatted=!1,this.postFormatted=!1,this.formatted=!1,this.width=0,this.spacing=0}addModifier(t){return le("addModifier is deprecated, use addMember instead."),this.addMember(t)}addMember(t){const e=t.getCategory();return this.members[e]||(this.members[e]=[]),this.members[e].push(t),t.setModifierContext(this),this.preFormatted=!1,this}getModifiers(t){return le("getModifiers is deprecated, use getMembers instead."),this.getMembers(t)}getMembers(t){var e;return null!==(e=this.members[t])&&void 0!==e?e:[]}getWidth(){return this.width}getLeftShift(){return this.state.left_shift}getRightShift(){return this.state.right_shift}getState(){return this.state}getMetrics(){if(!this.formatted)throw new f("UnformattedMember","Unformatted member has no metrics.");return{width:this.state.left_shift+this.state.right_shift+this.spacing,spacing:this.spacing}}preFormat(){if(this.preFormatted)return;le("Preformatting ModifierContext");const t=this.state,e=this.members;$t.format(e[m.StaveNote],t),Xt.format(e[m.Parenthesis],t),Ot.format(e[m.Dot],t),Lt.format(e[m.FretHandFinger],t),st.format(e[m.Accidental],t),ce.format(e[m.Stroke],t),Ut.format(e[m.GraceNoteGroup],t),Ht.format(e[m.NoteSubGroup],t),he.format(e[m.StringNumber],t),xt.format(e[m.Articulation],t),jt.format(e[m.Ornament],t),lt.format(e[m.Annotation],t),Rt.format(e[m.ChordSymbol],t),Mt.format(e[m.Bend],t),de.format(e[m.Vibrato],t,this),this.width=t.left_shift+t.right_shift,this.preFormatted=!0}postFormat(){this.postFormatted||(le("Postformatting ModifierContext"),$t.postFormat(this.getMembers(m.StaveNote)))}}ge.DEBUG=!1;class ue extends At{constructor(t,e,i){super(),this.clef=ue.types.treble,this.setPosition(wt.BEGIN),this.setType(t,e,i),this.setWidth(tt.currentMusicFont().lookupMetric(`clef.${this.size}.width`)),function(...t){ue.DEBUG&&S("Vex.Flow.Clef",t)}("Creating clef:",t)}static get CATEGORY(){return m.Clef}static get types(){return{treble:{code:"gClef",line:3,point:0},bass:{code:"fClef",line:1,point:0},alto:{code:"cClef",line:2,point:0},tenor:{code:"cClef",line:1,point:0},percussion:{code:"restMaxima",line:2,point:0},soprano:{code:"cClef",line:4,point:0},"mezzo-soprano":{code:"cClef",line:3,point:0},"baritone-c":{code:"cClef",line:0,point:0},"baritone-f":{code:"fClef",line:2,point:0},subbass:{code:"fClef",line:0,point:0},french:{code:"gClef",line:4,point:0},tab:{code:"6stringTabClef",point:0}}}setType(t,e,i){this.type=t,this.clef=ue.types[t],this.size=void 0===e?"default":e;const s=tt.currentMusicFont();if(this.clef.point=s.lookupMetric(`clef.${this.size}.point`,0),this.glyph=new U(this.clef.code,this.clef.point,{category:`clef.${this.clef.code}.${this.size}`}),void 0!==i){const t=s.lookupMetric(`clef.annotations.${i}.smuflCode`),e=s.lookupMetric(`clef.annotations.${i}.${this.size}.point`),n=s.lookupMetric(`clef.annotations.${i}.${this.size}.${this.type}.line`),a=s.lookupMetric(`clef.annotations.${i}.${this.size}.${this.type}.shiftX`);this.annotation={code:t,point:e,line:n,x_shift:a},this.attachment=new U(this.annotation.code,this.annotation.point),this.attachment.metrics.x_max=0,this.attachment.setXShift(this.annotation.x_shift)}else this.annotation=void 0;return this}getWidth(){return"tab"===this.type&&x(this.stave,"ClefError","Can't get width without stave."),this.width}setStave(t){if(this.stave=t,"tab"===this.type){const t=x(this.glyph,"ClefError","Can't set stave without glyph."),e=this.stave.getNumLines(),i=tt.currentMusicFont(),s=i.lookupMetric(`clef.lineCount.${e}.point`),n=i.lookupMetric(`clef.lineCount.${e}.shiftY`);t.setPoint(s),t.setYShift(n)}return this}draw(){const t=x(this.glyph,"ClefError","Can't draw clef without glyph."),e=this.checkStave(),i=e.checkContext();this.setRendered(),i.openGroup("clef",this.getAttribute("id")),t.setStave(e),t.setContext(i),void 0!==this.clef.line&&this.placeGlyphOnLine(t,e,this.clef.line),t.renderToStave(this.x),void 0!==this.annotation&&void 0!==this.attachment&&(this.placeGlyphOnLine(this.attachment,e,this.annotation.line),this.attachment.setStave(e),this.attachment.setContext(i),this.attachment.renderToStave(this.x)),i.closeGroup()}}ue.DEBUG=!1;class pe extends At{constructor(t,e,i){super(),this.accList=[],this.setKeySig(t,e,i),this.setPosition(wt.BEGIN),this.glyphFontScale=38,this.glyphs=[],this.xPositions=[],this.paddingForced=!1}static get CATEGORY(){return m.KeySignature}convertToGlyph(t,e){const i=tt.accidentalCodes(t.type),s=new U(i.code,this.glyphFontScale);let n=1;if("n"===t.type&&e){const i=pe.accidentalSpacing[e.type];if(i){n=e.line>=t.line?i.above:i.below}}this.placeGlyphOnLine(s,this.checkStave(),t.line),this.glyphs.push(s);const a=this.xPositions[this.xPositions.length-1],o=s.getMetrics().width+n;this.xPositions.push(a+o),this.width+=o}cancelKey(t){return this.formatted=!1,this.cancelKeySpec=t,this}convertToCancelAccList(t){const e=tt.keySignature(t),i=this.accList.length>0&&e.length>0&&e[0].type!==this.accList[0].type,s=i?e.length:e.length-this.accList.length;if(s<1)return;const n=[];for(let t=0;t<s;t++){let a=t;i||(a=e.length-s+t);const o=e[a];n.push({type:"n",line:o.line})}return this.accList=n.concat(this.accList),{accList:n,type:e[0].type}}addToStave(t){return this.paddingForced=!0,t.addModifier(this),this}convertAccLines(t,e,i=this.accList){let s,n,a=0;switch(t){case"soprano":"#"===e?s=[2.5,.5,2,0,1.5,-.5,1]:a=-1;break;case"mezzo-soprano":"b"===e?s=[0,2,.5,2.5,1,3,1.5]:a=1.5;break;case"alto":a=.5;break;case"tenor":"#"===e?s=[3,1,2.5,.5,2,0,1.5]:a=-.5;break;case"baritone-f":case"baritone-c":"b"===e?s=[.5,2.5,1,3,1.5,3.5,2]:a=2;break;case"bass":case"french":a=1}if(void 0!==s)for(n=0;n<i.length;++n)i[n].line=s[n];else if(0!==a)for(n=0;n<i.length;++n)i[n].line+=a}getPadding(t){return this.formatted||this.format(),0===this.glyphs.length||!this.paddingForced&&t<2?0:this.padding}getWidth(){return this.formatted||this.format(),this.width}setKeySig(t,e,i){return this.formatted=!1,this.keySpec=t,this.cancelKeySpec=e,this.alterKeySpec=i,this}alterKey(t){return this.formatted=!1,this.alterKeySpec=t,this}convertToAlterAccList(t){const e=Math.min(t.length,this.accList.length);for(let i=0;i<e;++i)t[i]&&(this.accList[i].type=t[i])}format(){const t=this.checkStave();this.width=0,this.glyphs=[],this.xPositions=[0],this.accList=tt.keySignature(x(this.keySpec));const e=this.accList,i=e.length>0?e[0].type:void 0;let s;if(this.cancelKeySpec&&(s=this.convertToCancelAccList(this.cancelKeySpec)),this.alterKeySpec&&this.convertToAlterAccList(this.alterKeySpec),this.accList.length>0){const n=(this.position===wt.END?t.getEndClef():t.getClef())||t.getClef();s&&this.convertAccLines(n,s.type,s.accList),this.convertAccLines(n,i,e);for(let t=0;t<this.accList.length;++t)this.convertToGlyph(this.accList[t],this.accList[t+1])}this.formatted=!0}draw(){const t=this.checkStave(),e=t.checkContext();this.formatted||this.format(),this.setRendered(),e.openGroup("keysignature",this.getAttribute("id"));for(let i=0;i<this.glyphs.length;i++){const s=this.glyphs[i],n=this.x+this.xPositions[i];s.setStave(t),s.setContext(e),s.renderToStave(n)}e.closeGroup()}}pe.accidentalSpacing={"#":{above:6,below:4},b:{above:4,below:7},n:{above:4,below:1},"##":{above:6,below:4},bb:{above:4,below:7},db:{above:4,below:7},d:{above:4,below:7},bbs:{above:4,below:7},"++":{above:6,below:4},"+":{above:6,below:4},"+-":{above:6,below:4},"++-":{above:6,below:4},bs:{above:4,below:10},bss:{above:4,below:10}};class me extends At{constructor(t,e,i){super(),this.symbol_type=t,this.x=e,this.x_shift=0,this.y_shift=i,this.resetFont()}static get CATEGORY(){return m.Repetition}setShiftX(t){return this.x_shift=t,this}setShiftY(t){return this.y_shift=t,this}draw(t,e){switch(this.setRendered(),this.symbol_type){case me.type.CODA_RIGHT:this.drawCodaFixed(t,e+t.getWidth());break;case me.type.CODA_LEFT:this.drawSymbolText(t,e,"Coda",!0);break;case me.type.SEGNO_LEFT:this.drawSignoFixed(t,e);break;case me.type.SEGNO_RIGHT:this.drawSignoFixed(t,e+t.getWidth());break;case me.type.DC:this.drawSymbolText(t,e,"D.C.",!1);break;case me.type.DC_AL_CODA:this.drawSymbolText(t,e,"D.C. al",!0);break;case me.type.DC_AL_FINE:this.drawSymbolText(t,e,"D.C. al Fine",!1);break;case me.type.DS:this.drawSymbolText(t,e,"D.S.",!1);break;case me.type.DS_AL_CODA:this.drawSymbolText(t,e,"D.S. al",!0);break;case me.type.DS_AL_FINE:this.drawSymbolText(t,e,"D.S. al Fine",!1);break;case me.type.FINE:this.drawSymbolText(t,e,"Fine",!1);break;case me.type.TO_CODA:this.drawSymbolText(t,e,"To",!0)}return this}drawCodaFixed(t,e){const i=t.getYForTopText(t.getNumLines())+this.y_shift;return U.renderGlyph(t.checkContext(),this.x+e+this.x_shift,i+tt.currentMusicFont().lookupMetric("staveRepetition.coda.offsetY"),40,"coda",{category:"coda"}),this}drawSignoFixed(t,e){const i=t.getYForTopText(t.getNumLines())+this.y_shift;return U.renderGlyph(t.checkContext(),this.x+e+this.x_shift,i+tt.currentMusicFont().lookupMetric("staveRepetition.segno.offsetY"),30,"segno",{category:"segno"}),this}drawSymbolText(t,e,i,s){const n=t.checkContext();n.save(),n.setFont(this.textFont);let a=0,o=0;const r=t.getNoteStartX()-this.x;switch(this.symbol_type){case me.type.CODA_LEFT:a=this.x+t.getVerticalBarWidth(),o=a+n.measureText(i).width+tt.currentMusicFont().lookupMetric("staveRepetition.symbolText.offsetX");break;case me.type.DC:case me.type.DC_AL_FINE:case me.type.DS:case me.type.DS_AL_FINE:case me.type.FINE:a=this.x+e+this.x_shift+t.getWidth()-tt.currentMusicFont().lookupMetric("staveRepetition.symbolText.spacing")-r-n.measureText(i).width;break;default:a=this.x+e+this.x_shift+t.getWidth()-tt.currentMusicFont().lookupMetric("staveRepetition.symbolText.spacing")-r-n.measureText(i).width-tt.currentMusicFont().lookupMetric("staveRepetition.symbolText.offsetX"),o=a+n.measureText(i).width+tt.currentMusicFont().lookupMetric("staveRepetition.symbolText.offsetX")}const h=t.getYForTopText(t.getNumLines())+this.y_shift+tt.currentMusicFont().lookupMetric("staveRepetition.symbolText.offsetY");return s&&U.renderGlyph(n,o,h,40,"coda",{category:"coda"}),n.fillText(i,a,h+5),n.restore(),this}}me.TEXT_FONT={family:M.SERIF,size:12,weight:k.BOLD,style:D.NORMAL},me.type={NONE:1,CODA_LEFT:2,CODA_RIGHT:3,SEGNO_LEFT:4,SEGNO_RIGHT:5,DC:6,DC_AL_CODA:7,DC_AL_FINE:8,DS:9,DS_AL_CODA:10,DS_AL_FINE:11,FINE:12,TO_CODA:13};class fe extends At{constructor(t,e,i){super(),this.setWidth(16),this.section=t,this.x=e,this.shift_x=0,this.shift_y=i,this.resetFont()}static get CATEGORY(){return m.StaveSection}setStaveSection(t){return this.section=t,this}setShiftX(t){return this.shift_x=t,this}setShiftY(t){return this.shift_y=t,this}draw(t,e){const i=t.checkContext();this.setRendered(),i.save(),i.setLineWidth(2),i.setFont(this.textFont);const s=i.measureText(this.section),n=s.width+4,a=s.height+4,o=t.getYForTopText(2)+this.shift_y,r=this.x+e;return i.beginPath(),i.setLineWidth(2),i.rect(r,o+s.y-2,n,a),i.stroke(),i.fillText(this.section,r+2,o),i.restore(),this}}fe.TEXT_FONT={family:M.SANS_SERIF,size:10,weight:k.BOLD,style:D.NORMAL};class _e extends At{constructor(t,e,i){super(),this.render_options={glyph_font_scale:30},this.tempo=t,this.position=wt.ABOVE,this.x=e,this.shift_x=10,this.shift_y=i,this.resetFont()}static get CATEGORY(){return m.StaveTempo}setTempo(t){return this.tempo=t,this}setShiftX(t){return this.shift_x=t,this}setShiftY(t){return this.shift_y=t,this}draw(t,e){const i=t.checkContext();this.setRendered();const s=this.render_options,n=s.glyph_font_scale/38,a=this.tempo.name,o=this.tempo.duration,r=this.tempo.dots||0,h=this.tempo.bpm;let c=this.x+this.shift_x+e;const d=t.getYForTopText(1)+this.shift_y;if(i.save(),a&&(i.setFont(this.textFont),i.fillText(a,c,d),c+=i.measureText(a).width),o&&h){i.setFont(Object.assign(Object.assign({},this.textFont),{weight:"normal",style:"normal"})),a&&(c+=i.measureText(" ").width,i.fillText("(",c,d),c+=i.measureText("(").width);const t=tt.getGlyphProps(o);if(c+=3*n,U.renderGlyph(i,c,d,s.glyph_font_scale,t.code_head),c+=t.getWidth()*n,t.stem){let e=30;t.beam_count&&(e+=3*(t.beam_count-1)),e*=n;const a=d-e;i.fillRect(c-n,a,n,e),t.flag&&(U.renderGlyph(i,c,a,s.glyph_font_scale,t.code_flag_upstem,{category:"flag.staveTempo"}),r||(c+=6*n))}for(let t=0;t<r;t++)c+=6*n,i.beginPath(),i.arc(c,d+2*n,2*n,0,2*Math.PI,!1),i.fill();i.fillText(" = "+h+(a?")":""),c+3*n,d)}return i.restore(),this}}_e.TEXT_FONT={family:M.SERIF,size:14,weight:k.BOLD,style:D.NORMAL},function(t){t[t.LEFT=1]="LEFT",t[t.CENTER=2]="CENTER",t[t.RIGHT=3]="RIGHT"}(ae||(ae={}));class xe extends bt{constructor(t){if(super(t),this.text=t.text||"",this.superscript=t.superscript,this.subscript=t.subscript,this.setFont(t.font),this.line=t.line||0,this.smooth=t.smooth||!1,this.ignore_ticks=t.ignore_ticks||!1,this.justification=ae.LEFT,t.glyph){const e=xe.GLYPHS[t.glyph];if(!e)throw new f("Invalid glyph type: "+t.glyph);this.glyph=new U(e.code,40,{category:"textNote"}),this.setWidth(this.glyph.getMetrics().width)}else this.glyph=void 0}static get CATEGORY(){return m.TextNote}static get GLYPHS(){return{segno:{code:"segno"},tr:{code:"ornamentTrill"},mordent:{code:"ornamentMordent"},mordent_upper:{code:"ornamentShortTrill"},mordent_lower:{code:"ornamentMordent"},f:{code:"dynamicForte"},p:{code:"dynamicPiano"},m:{code:"dynamicMezzo"},s:{code:"dynamicSforzando"},z:{code:"dynamicZ"},coda:{code:"coda"},pedal_open:{code:"keyboardPedalPed"},pedal_close:{code:"keyboardPedalUp"},caesura_straight:{code:"caesura"},caesura_curved:{code:"caesuraCurved"},breath:{code:"breathMarkComma"},tick:{code:"breathMarkTick"},turn:{code:"ornamentTurn"},turn_inverted:{code:"ornamentTurnSlash"}}}setJustification(t){return this.justification=t,this}setLine(t){return this.line=t,this}preFormat(){if(this.preFormatted)return;const t=this.checkTickContext("Can't preformat without a TickContext.");if(this.smooth)this.setWidth(0);else if(this.glyph);else{const t=this.checkContext();t.setFont(this.textFont),this.setWidth(t.measureText(this.text).width)}this.justification===ae.CENTER?this.leftDisplacedHeadPx=this.width/2:this.justification===ae.RIGHT&&(this.leftDisplacedHeadPx=this.width),this.rightDisplacedHeadPx=t.getMetrics().glyphPx/2,this.preFormatted=!0}draw(){const t=this.checkContext(),e=this.checkStave(),i=this.checkTickContext("Can't draw without a TickContext.");this.setRendered();let s=this.getAbsoluteX()+i.getMetrics().glyphPx/2;const n=this.getWidth();let a;if(this.justification===ae.CENTER?s-=n/2:this.justification===ae.RIGHT&&(s-=n),this.glyph)a=e.getYForLine(this.line+-3),this.glyph.render(t,s,a);else{a=e.getYForLine(this.line+-3),this.applyStyle(t),t.setFont(this.textFont),t.fillText(this.text,s,a);const i=t.measureText(this.text).height,{family:n,size:o,weight:r,style:h}=this.textFont,c=M.scaleSize(o,.769231);this.superscript&&(t.setFont(n,c,r,h),t.fillText(this.superscript,s+this.width+2,a-i/2.2)),this.subscript&&(t.setFont(n,c,r,h),t.fillText(this.subscript,s+this.width+2,a+i/2.2-1)),this.restoreStyle(t)}}}xe.TEXT_FONT={family:M.SANS_SERIF,size:12,weight:k.NORMAL,style:D.NORMAL},xe.Justification=ae;class Se extends At{constructor(t,e,i={}){super(),this.setWidth(16),this.text=t,this.position=e,this.options=Object.assign({shift_x:0,shift_y:0,justification:xe.Justification.CENTER},i),this.resetFont()}static get CATEGORY(){return m.StaveText}setStaveText(t){return this.text=t,this}setShiftX(t){return this.shift_x=t,this}setShiftY(t){return this.shift_y=t,this}setText(t){return this.text=t,this}draw(t){const e=t.checkContext();this.setRendered(),e.save(),e.setLineWidth(2),e.setFont(this.textFont);const i=e.measureText(""+this.text).width;let s,n;switch(this.position){case wt.LEFT:case wt.RIGHT:n=(t.getYForLine(0)+t.getBottomLineY())/2+this.options.shift_y,s=this.position===wt.LEFT?t.getX()-i-24+this.options.shift_x:t.getX()+t.getWidth()+24+this.options.shift_x;break;case wt.ABOVE:case wt.BELOW:s=t.getX()+this.options.shift_x,this.options.justification===ae.CENTER?s+=t.getWidth()/2-i/2:this.options.justification===ae.RIGHT&&(s+=t.getWidth()-i),n=this.position===wt.ABOVE?t.getYForTopText(2)+this.options.shift_y:t.getYForBottomText(2)+this.options.shift_y;break;default:throw new f("InvalidPosition","Value Must be in Modifier.Position.")}return e.fillText(""+this.text,s,n+4),e.restore(),this}}Se.TEXT_FONT={family:M.SERIF,size:16,weight:k.NORMAL,style:D.NORMAL},function(t){t[t.NONE=1]="NONE",t[t.BEGIN=2]="BEGIN",t[t.MID=3]="MID",t[t.END=4]="END",t[t.BEGIN_END=5]="BEGIN_END"}(oe||(oe={}));class ye extends At{constructor(t,e,i,s){super(),this.volta=t,this.x=i,this.y_shift=s,this.number=e,this.resetFont()}static get CATEGORY(){return m.Volta}static get type(){return oe}setShiftY(t){return this.y_shift=t,this}draw(t,e){const i=t.checkContext();this.setRendered();let s=t.getWidth()-e;const n=t.getYForTopText(t.getNumLines())+this.y_shift,a=1.5*t.getSpacingBetweenLines();switch(this.volta){case oe.BEGIN:i.fillRect(this.x+e,n,1,a);break;case oe.END:s-=5,i.fillRect(this.x+e+s,n,1,a);break;case oe.BEGIN_END:s-=3,i.fillRect(this.x+e,n,1,a),i.fillRect(this.x+e+s,n,1,a)}return this.volta!==oe.BEGIN&&this.volta!==oe.BEGIN_END||(i.save(),i.setFont(this.textFont),i.fillText(this.number,this.x+e+5,n+15),i.restore()),i.fillRect(this.x+e,n,s,1),this}}ye.TEXT_FONT={family:M.SANS_SERIF,size:9,weight:k.BOLD,style:D.NORMAL};class Te extends U{constructor(t,e,i,s,n,a){var o;super(s,n,a),this.timeSignature=t,this.topGlyphs=[],this.botGlyphs=[];let r=0;for(let t=0;t<e.length;++t){let s=e[t];switch(e[t]){case"-":s="Minus";break;case"+":s=i.length>0?"PlusSmall":"Plus";break;case"(":s=i.length>0?"ParensLeftSmall":"ParensLeft";break;case")":s=i.length>0?"ParensRightSmall":"ParensRight"}const n=new U("timeSig"+s,this.timeSignature.point);this.topGlyphs.push(n),r+=null!==(o=n.getMetrics().width)&&void 0!==o?o:0}let h=0;for(let t=0;t<i.length;++t){let e=i[t];switch(i[t]){case"+":e="PlusSmall";break;case"(":e="ParensLeftSmall";break;case")":e="ParensRightSmall"}const s=new U("timeSig"+e,this.timeSignature.point);this.botGlyphs.push(s),h+=x(s.getMetrics().width)}this.width=Math.max(r,h),this.xMin=this.getMetrics().x_min,this.topStartX=(this.width-r)/2,this.botStartX=(this.width-h)/2,this.reset()}getMetrics(){return{x_min:this.xMin,x_max:this.xMin+this.width,width:this.width}}renderToStave(t){const e=this.checkStave(),i=this.checkContext();let s=t+this.topStartX,n=0;n=this.botGlyphs.length>0?e.getYForLine(this.timeSignature.topLine):(e.getYForLine(this.timeSignature.topLine)+e.getYForLine(this.timeSignature.bottomLine))/2;for(let t=0;t<this.topGlyphs.length;++t){const e=this.topGlyphs[t];U.renderOutline(i,e.getMetrics().outline,this.scale,s+this.x_shift,n),s+=x(e.getMetrics().width)}s=t+this.botStartX,n=e.getYForLine(this.timeSignature.bottomLine);for(let t=0;t<this.botGlyphs.length;++t){const a=this.botGlyphs[t];this.timeSignature.placeGlyphOnLine(a,e,0),U.renderOutline(i,a.getMetrics().outline,this.scale,s+a.getMetrics().x_shift,n),s+=x(a.getMetrics().width)}}}class be extends At{constructor(t="4/4",e=15,i=!0){super(),this.validate_args=i;const s=e,n=tt.currentMusicFont();this.point=n.lookupMetric("digits.point");const a=n.lookupMetric("digits.shiftLine",0);this.topLine=2+a,this.bottomLine=4+a,this.setPosition(wt.BEGIN),this.info=this.parseTimeSpec(t),this.setWidth(x(this.info.glyph.getMetrics().width)),this.setPadding(s)}static get CATEGORY(){return m.TimeSignature}static get glyphs(){return{C:{code:"timeSigCommon",point:40,line:2},"C|":{code:"timeSigCutCommon",point:40,line:2}}}parseTimeSpec(t){var e,i;if("C"===t||"C|"===t){const{line:e,code:i,point:s}=be.glyphs[t];return{line:e,num:!1,glyph:new U(i,s)}}this.validate_args&&(t=>{const e=t.split("/");if(2!==e.length&&"+"!==e[0]&&"-"!==e[0])throw new f("BadTimeSignature",`Invalid time spec: ${t}. Must be in the form "<numerator>/<denominator>"`);e.forEach((e=>{if(0==/^[0-9+\-()]+$/.test(e))throw new f("BadTimeSignature",`Invalid time spec: ${t}. Must contain valid signatures.`)}))})(t);const s=t.split("/");return{num:!0,glyph:this.makeTimeSignatureGlyph(null!==(e=s[0])&&void 0!==e?e:"",null!==(i=s[1])&&void 0!==i?i:"")}}makeTimeSignatureGlyph(t,e){return new Te(this,t,e,"timeSig0",this.point)}getInfo(){return this.info}setTimeSig(t){return this.info=this.parseTimeSpec(t),this}draw(){const t=this.checkStave(),e=t.checkContext();this.setRendered(),e.openGroup("timesignature",this.getAttribute("id")),this.info.glyph.setStave(t),this.info.glyph.setContext(e),this.placeGlyphOnLine(this.info.glyph,t,this.info.line),this.info.glyph.renderToStave(this.x),e.closeGroup()}}const we={[Pt.CATEGORY]:0,[ue.CATEGORY]:1,[pe.CATEGORY]:2,[be.CATEGORY]:3},ve={[be.CATEGORY]:0,[pe.CATEGORY]:1,[Pt.CATEGORY]:2,[ue.CATEGORY]:3};class Ee extends O{constructor(t,e,i,s){super(),this.height=0,this.x=t,this.y=e,this.width=i,this.formatted=!1,this.start_x=t+5,this.end_x=t+i,this.modifiers=[],this.measure=0,this.clef="treble",this.endClef=void 0,this.resetFont(),this.options=Object.assign({vertical_bar_width:10,num_lines:5,fill_style:"#999999",left_bar:!0,right_bar:!0,spacing_between_lines_px:tt.STAVE_LINE_DISTANCE,space_above_staff_ln:4,space_below_staff_ln:4,top_text_position:1,bottom_text_position:4,line_config:[]},s),this.bounds={x:this.x,y:this.y,w:this.width,h:0},this.defaultLedgerLineStyle={strokeStyle:"#444",lineWidth:1.4},this.resetLines(),this.addModifier(new Pt(this.options.left_bar?vt.SINGLE:vt.NONE)),this.addEndModifier(new Pt(this.options.right_bar?vt.SINGLE:vt.NONE))}static get CATEGORY(){return m.Stave}static get defaultPadding(){const t=tt.currentMusicFont();return t.lookupMetric("stave.padding")+t.lookupMetric("stave.endPaddingMax")}static get rightPadding(){return tt.currentMusicFont().lookupMetric("stave.endPaddingMax")}setDefaultLedgerLineStyle(t){this.defaultLedgerLineStyle=t}getDefaultLedgerLineStyle(){return Object.assign(Object.assign({},this.getStyle()),this.defaultLedgerLineStyle)}space(t){return this.options.spacing_between_lines_px*t}resetLines(){this.options.line_config=[];for(let t=0;t<this.options.num_lines;t++)this.options.line_config.push({visible:!0});this.height=(this.options.num_lines+this.options.space_above_staff_ln)*this.options.spacing_between_lines_px,this.options.bottom_text_position=this.options.num_lines}setNoteStartX(t){this.formatted||this.format(),this.start_x=t;const e=this.modifiers[0];return e.setX(this.start_x-e.getWidth()),this}getNoteStartX(){return this.formatted||this.format(),this.start_x}getNoteEndX(){return this.formatted||this.format(),this.end_x}getTieStartX(){return this.start_x}getTieEndX(){return this.end_x}getX(){return this.x}getNumLines(){return this.options.num_lines}setNumLines(t){return this.options.num_lines=t,this.resetLines(),this}setY(t){return this.y=t,this}getY(){return this.y}getTopLineTopY(){return this.getYForLine(0)-tt.STAVE_LINE_THICKNESS/2}getBottomLineBottomY(){return this.getYForLine(this.getNumLines()-1)+tt.STAVE_LINE_THICKNESS/2}setX(t){const e=t-this.x;this.formatted=!1,this.x=t,this.start_x+=e,this.end_x+=e;for(let t=0;t<this.modifiers.length;t++){const i=this.modifiers[t];i.setX(i.getX()+e)}return this}setWidth(t){return this.formatted=!1,this.width=t,this.end_x=this.x+t,this}getWidth(){return this.width}getStyle(){return Object.assign({fillStyle:this.options.fill_style,strokeStyle:this.options.fill_style,lineWidth:tt.STAVE_LINE_THICKNESS},this.style)}setMeasure(t){return this.measure=t,this}getModifierXShift(t=0){if("number"!=typeof t)throw new f("InvalidIndex","Must be of number type");if(this.formatted||this.format(),1===this.getModifiers(wt.BEGIN).length)return 0;if(this.modifiers[t].getPosition()===wt.RIGHT)return 0;let e=this.start_x-this.x;const i=this.modifiers[0];return i.getType()===vt.REPEAT_BEGIN&&e>i.getWidth()&&(e-=i.getWidth()),e}setRepetitionType(t,e=0){return this.modifiers.push(new me(t,this.x,e)),this}setVoltaType(t,e,i){return this.modifiers.push(new ye(t,e,this.x,i)),this}setSection(t,e,i=0,s){const n=new fe(t,this.x+i,e);return s&&n.setFontSize(s),this.modifiers.push(n),this}setTempo(t,e){return this.modifiers.push(new _e(t,this.x,e)),this}setText(t,e,i={}){return this.modifiers.push(new Se(t,e,i)),this}getHeight(){return this.height}getSpacingBetweenLines(){return this.options.spacing_between_lines_px}getBoundingBox(){return new C(this.x,this.y,this.width,this.getBottomY()-this.y)}getBottomY(){const t=this.options,e=t.spacing_between_lines_px;return this.getYForLine(t.num_lines)+t.space_below_staff_ln*e}getBottomLineY(){return this.getYForLine(this.options.num_lines)}getYForLine(t){const e=this.options,i=e.spacing_between_lines_px,s=e.space_above_staff_ln;return this.y+t*i+s*i}getLineForY(t){const e=this.options,i=e.spacing_between_lines_px,s=e.space_above_staff_ln;return(t-this.y)/i-s}getYForTopText(t=0){return this.getYForLine(-t-this.options.top_text_position)}getYForBottomText(t=0){return this.getYForLine(this.options.bottom_text_position+t)}getYForNote(t){const e=this.options,i=e.spacing_between_lines_px,s=e.space_above_staff_ln;return this.y+s*i+5*i-t*i}getYForGlyphs(){return this.getYForLine(3)}addModifier(t,e){return void 0!==e&&t.setPosition(e),t.setStave(this),this.formatted=!1,this.modifiers.push(t),this}addEndModifier(t){return this.addModifier(t,wt.END),this}setBegBarType(t){const{SINGLE:e,REPEAT_BEGIN:i,NONE:s}=vt;return t!==e&&t!==i&&t!==s||(this.modifiers[0].setType(t),this.formatted=!1),this}setEndBarType(t){return t!==vt.REPEAT_BEGIN&&(this.modifiers[1].setType(t),this.formatted=!1),this}setClef(t,e,i,s){void 0===s&&(s=wt.BEGIN),s===wt.END?this.endClef=t:this.clef=t;const n=this.getModifiers(s,ue.CATEGORY);return 0===n.length?this.addClef(t,e,i,s):n[0].setType(t,e,i),this}getClef(){return this.clef}setEndClef(t,e,i){return this.setClef(t,e,i,wt.END),this}getEndClef(){return this.endClef}setKeySignature(t,e,i){void 0===i&&(i=wt.BEGIN);const s=this.getModifiers(i,pe.CATEGORY);return 0===s.length?this.addKeySignature(t,e,i):s[0].setKeySig(t,e),this}setEndKeySignature(t,e){return this.setKeySignature(t,e,wt.END),this}setTimeSignature(t,e,i){void 0===i&&(i=wt.BEGIN);const s=this.getModifiers(i,be.CATEGORY);return 0===s.length?this.addTimeSignature(t,e,i):s[0].setTimeSig(t),this}setEndTimeSignature(t,e){return this.setTimeSignature(t,e,wt.END),this}addKeySignature(t,e,i){return void 0===i&&(i=wt.BEGIN),this.addModifier(new pe(t,e).setPosition(i),i),this}addClef(t,e,i,s){return void 0===s||s===wt.BEGIN?this.clef=t:s===wt.END&&(this.endClef=t),this.addModifier(new ue(t,e,i),s),this}addEndClef(t,e,i){return this.addClef(t,e,i,wt.END),this}addTimeSignature(t,e,i){return this.addModifier(new be(t,e),i),this}addEndTimeSignature(t,e){return this.addTimeSignature(t,e,wt.END),this}addTrebleGlyph(){return this.addClef("treble"),this}getModifiers(t,e){const i=void 0===t,s=void 0===e;return i&&s?this.modifiers:i?this.modifiers.filter((t=>e===t.getCategory())):s?this.modifiers.filter((e=>t===e.getPosition())):this.modifiers.filter((i=>t===i.getPosition()&&e===i.getCategory()))}sortByCategory(t,e){for(let i=t.length-1;i>=0;i--)for(let s=0;s<i;s++)if(e[t[s].getCategory()]>e[t[s+1].getCategory()]){const e=t[s];t[s]=t[s+1],t[s+1]=e}}format(){const t=this.modifiers[0],e=this.modifiers[1],i=this.getModifiers(wt.BEGIN),s=this.getModifiers(wt.END);let n,a,r;this.sortByCategory(i,we),this.sortByCategory(s,ve),i.length>1&&t.getType()===vt.REPEAT_BEGIN&&(i.push(i.splice(0,1)[0]),i.splice(0,0,new Pt(vt.SINGLE))),s.indexOf(e)>0&&s.splice(0,0,new Pt(vt.NONE));let h=0,c=this.x;for(let t=0;t<i.length;t++)r=i[t],a=r.getPadding(t+h),n=r.getWidth(),c+=a,r.setX(c),c+=n,a+n===0&&h--;this.start_x=c,c=this.x+this.width;const d={left:0,right:0,paddingRight:0,paddingLeft:0};let l=0;for(let t=0;t<s.length;t++){r=s[t],l=o(r)?t:l,d.right=0,d.left=0,d.paddingRight=0,d.paddingLeft=0;const e=r.getLayoutMetrics();e?(0!==t&&(d.right=e.xMax||0,d.paddingRight=e.paddingRight||0),d.left=-e.xMin||0,d.paddingLeft=e.paddingLeft||0,t===s.length-1&&(d.paddingLeft=0)):(d.paddingRight=r.getPadding(t-l),0!==t&&(d.right=r.getWidth()),0===t&&(d.left=r.getWidth())),c-=d.paddingRight,c-=d.right,r.setX(c),c-=d.left,c-=d.paddingLeft}this.end_x=1===s.length?this.x+this.width:c,this.formatted=!0}draw(){const t=this.checkContext();this.setRendered(),t.openGroup("stave",this.getAttribute("id")),this.formatted||this.format();const e=this.options.num_lines,i=this.width,s=this.x;let n;for(let a=0;a<e;a++)n=this.getYForLine(a),this.applyStyle(),this.options.line_config[a].visible&&(t.beginPath(),t.moveTo(s,n),t.lineTo(s+i,n),t.stroke()),this.restoreStyle();for(let e=0;e<this.modifiers.length;e++){const i=this.modifiers[e];"function"==typeof i.draw&&(i.applyStyle(t),i.draw(this,this.getModifierXShift(e)),i.restoreStyle(t))}if(this.measure>0){t.save(),t.setFont(this.textFont);const e=t.measureText(""+this.measure).width;n=this.getYForTopText(0)+3,t.fillText(""+this.measure,this.x-e/2,n),t.restore()}return t.closeGroup(),this}getVerticalBarWidth(){return this.options.vertical_bar_width}getConfigForLines(){return this.options.line_config}setConfigForLine(t,e){if(t>=this.options.num_lines||t<0)throw new f("StaveConfigError","The line number must be within the range of the number of lines in the Stave.");if(void 0===e.visible)throw new f("StaveConfigError","The line configuration object is missing the 'visible' property.");if("boolean"!=typeof e.visible)throw new f("StaveConfigError","The line configuration objects 'visible' property must be true or false.");return this.options.line_config[t]=e,this}setConfigForLines(t){if(t.length!==this.options.num_lines)throw new f("StaveConfigError","The length of the lines configuration array must match the number of lines in the Stave");for(const e in t)null==t[e].visible&&(t[e]=this.options.line_config[e]),this.options.line_config[e]=Object.assign(Object.assign({},this.options.line_config[e]),t[e]);return this.options.line_config=t,this}}function Ce(t,e,i,s,n){if(e!==Ne.type.BOLD_DOUBLE_LEFT&&e!==Ne.type.BOLD_DOUBLE_RIGHT)throw new f("InvalidConnector","A REPEAT_BEGIN or REPEAT_END type must be provided.");let a=3,o=3.5;e===Ne.type.BOLD_DOUBLE_RIGHT&&(a=-5,o=3),t.fillRect(i+a,s,1,n-s),t.fillRect(i-2,s,o,n-s)}Ee.TEXT_FONT={family:M.SANS_SERIF,size:8,weight:k.NORMAL,style:D.NORMAL};class Ne extends O{constructor(t,e){super(),this.thickness=tt.STAVE_LINE_THICKNESS,this.width=3,this.top_stave=t,this.bottom_stave=e,this.type=Ne.type.DOUBLE,this.resetFont(),this.x_shift=0,this.texts=[]}static get CATEGORY(){return m.StaveConnector}setType(t){return(t="string"==typeof t?Ne.typeString[t]:t)>=Ne.type.SINGLE_RIGHT&&t<=Ne.type.NONE&&(this.type=t),this}setText(t,e={}){return this.texts.push({content:t,options:Object.assign({shift_x:0,shift_y:0},e)}),this}setXShift(t){if("number"!=typeof t)throw new f("InvalidType","x_shift must be a Number");return this.x_shift=t,this}getXShift(){return this.x_shift}draw(){const t=this.checkContext();this.setRendered();let e=this.top_stave.getYForLine(0),i=this.bottom_stave.getYForLine(this.bottom_stave.getNumLines()-1)+this.thickness,s=this.width,n=this.top_stave.getX();(this.type===Ne.type.SINGLE_RIGHT||this.type===Ne.type.BOLD_DOUBLE_RIGHT||this.type===Ne.type.THIN_DOUBLE)&&(n=this.top_stave.getX()+this.top_stave.getWidth());let a=i-e;switch(this.type){case Ne.type.SINGLE:case Ne.type.SINGLE_LEFT:case Ne.type.SINGLE_RIGHT:s=1;break;case Ne.type.DOUBLE:n-=this.width+2,e-=this.thickness,a+=.5;break;case Ne.type.BRACE:{s=12;const n=this.top_stave.getX()-2+this.x_shift,o=e,r=n,h=i,c=n-s,d=o+a/2,l=c-.9*s,g=o+.2*a,u=n+1.1*s,p=d-.135*a,m=u,f=d+.135*a,_=l,x=h-.2*a,S=c-s,y=x,T=n+.4*s,b=d+.135*a,w=T,v=d-.135*a,E=S,C=g;t.beginPath(),t.moveTo(n,o),t.bezierCurveTo(l,g,u,p,c,d),t.bezierCurveTo(m,f,_,x,r,h),t.bezierCurveTo(S,y,T,b,c,d),t.bezierCurveTo(w,v,E,C,n,o),t.fill(),t.stroke();break}case Ne.type.BRACKET:e-=6,i+=6,a=i-e,U.renderGlyph(t,n-5,e,40,"bracketTop"),U.renderGlyph(t,n-5,i,40,"bracketBottom"),n-=this.width+2;break;case Ne.type.BOLD_DOUBLE_LEFT:Ce(t,this.type,n+this.x_shift,e,i-this.thickness);break;case Ne.type.BOLD_DOUBLE_RIGHT:Ce(t,this.type,n,e,i-this.thickness);break;case Ne.type.THIN_DOUBLE:s=1,a-=this.thickness;break;case Ne.type.NONE:break;default:throw new f("InvalidType",`The provided StaveConnector.type (${this.type}) is invalid.`)}this.type!==Ne.type.BRACE&&this.type!==Ne.type.BOLD_DOUBLE_LEFT&&this.type!==Ne.type.BOLD_DOUBLE_RIGHT&&this.type!==Ne.type.NONE&&t.fillRect(n,e,s,a),this.type===Ne.type.THIN_DOUBLE&&t.fillRect(n-3,e,s,a),t.save(),t.setLineWidth(2),t.setFont(this.textFont);for(let e=0;e<this.texts.length;e++){const i=this.texts[e],s=t.measureText(""+i.content).width,n=this.top_stave.getX()-s-24+i.options.shift_x,a=(this.top_stave.getYForLine(0)+this.bottom_stave.getBottomLineY())/2+i.options.shift_y;t.fillText(""+i.content,n,a+4)}t.restore()}}Ne.TEXT_FONT={family:M.SERIF,size:16,weight:k.NORMAL,style:D.NORMAL},Ne.type={SINGLE_RIGHT:0,SINGLE_LEFT:1,SINGLE:1,DOUBLE:2,BRACE:3,BRACKET:4,BOLD_DOUBLE_LEFT:5,BOLD_DOUBLE_RIGHT:6,THIN_DOUBLE:7,NONE:8},Ne.typeString={singleRight:Ne.type.SINGLE_RIGHT,singleLeft:Ne.type.SINGLE_LEFT,single:Ne.type.SINGLE,double:Ne.type.DOUBLE,brace:Ne.type.BRACE,bracket:Ne.type.BRACKET,boldDoubleLeft:Ne.type.BOLD_DOUBLE_LEFT,boldDoubleRight:Ne.type.BOLD_DOUBLE_RIGHT,thinDouble:Ne.type.THIN_DOUBLE,none:Ne.type.NONE};const ke=t=>t.reduce(((t,e)=>t+e),0);function De(t,e,i){const s=Pe.getResolutionMultiplier(t),n={},a=[],o=[];return t.forEach(((t,r)=>{const h=new v(0,s);t.getTickables().forEach((t=>{const s=h.numerator;if(!n[s]){const t=e({tickID:s});o.push(t),n[s]=t,a.push(s)}i(t,n[s],r),h.add(t.getTicks())}))})),{map:n,array:o,list:a.sort(((t,e)=>t-e)),resolutionMultiplier:s}}function Ae(t,e,i,s){let n=e;for(let e=i+1;e<t.length;e++){const i=t[e];if(d(i)&&!i.isRest()&&!i.shouldIgnoreTicks()){n=i.getLineForRest();break}}if(s&&e!==n){n=T(Math.max(e,n),Math.min(e,n))}return n}class Pe{constructor(t){this.formatterOptions=Object.assign({globalSoftmax:!1,softmaxFactor:100,maxIterations:5},t),this.justifyWidth=0,this.totalCost=0,this.totalShift=0,this.durationStats={},this.minTotalWidth=0,this.hasMinTotalWidth=!1,this.tickContexts=void 0,this.modifierContexts=void 0,this.contextGaps={total:0,gaps:[]},this.voices=[],this.lossHistory=[]}static SimpleFormat(t,e=0,{paddingBetween:i=10}={}){t.reduce(((t,e)=>{e.addToModifierContext(new ge);const s=(new Yt).addTickable(e).preFormat(),n=s.getMetrics();return s.setX(t+n.totalLeftPx),t+s.getWidth()+n.totalRightPx+i}),e)}static plotDebugging(t,e,i,s,n,a){const o=i+(a=Object.assign({stavePadding:tt.currentMusicFont().lookupMetric("stave.padding")},a)).stavePadding,r=e.contextGaps;t.save(),t.setFont(M.SANS_SERIF,8),r.gaps.forEach((e=>{var i,a,r;i=o+e.x1,a=o+e.x2,r="rgba(100,200,100,0.4)",t.beginPath(),t.setStrokeStyle(r),t.setFillStyle(r),t.setLineWidth(1),t.fillRect(i,s,Math.max(a-i,0),n-s),t.setFillStyle("green"),t.fillText(Math.round(e.x2-e.x1).toString(),o+e.x1,n+12)})),t.setFillStyle("red"),t.fillText(`Loss: ${(e.totalCost||0).toFixed(2)} Shift: ${(e.totalShift||0).toFixed(2)} Gap: ${r.total.toFixed(2)}`,o-20,n+27),t.restore()}static FormatAndDraw(t,e,i,s){let n={auto_beam:!1,align_rests:!1};"object"==typeof s?n=Object.assign(Object.assign({},n),s):"boolean"==typeof s&&(n.auto_beam=s);const a=new Gt(tt.TIME4_4).setMode(Gt.Mode.SOFT).addTickables(i),o=n.auto_beam?Ie.applyAndGetBeams(a):[];return(new Pe).joinVoices([a]).formatToStave([a],e,{align_rests:n.align_rests,stave:e}),a.setStave(e).draw(t,e),o.forEach((e=>e.setContext(t).draw())),a.getBoundingBox()}static FormatAndDrawTab(t,e,i,s,n,a,o){let r={auto_beam:a,align_rests:!1};"object"==typeof o?r=Object.assign(Object.assign({},r),o):"boolean"==typeof o&&(r.auto_beam=o);const h=new Gt(tt.TIME4_4).setMode(Gt.Mode.SOFT).addTickables(n),c=new Gt(tt.TIME4_4).setMode(Gt.Mode.SOFT).addTickables(s),d=r.auto_beam?Ie.applyAndGetBeams(h):[];(new Pe).joinVoices([h]).joinVoices([c]).formatToStave([h,c],i,{align_rests:r.align_rests}),h.draw(t,i),c.draw(t,e),d.forEach((e=>e.setContext(t).draw())),new Ne(i,e).setContext(t).draw()}static AlignRestsToNotes(t,e,i){t.forEach(((s,n)=>{if(g(s)&&s.isRest()){if(s.getTuplet()&&!i)return;const a=s.getGlyph().position.toUpperCase();if("R/4"!==a&&"B/4"!==a)return;if(e||s.getBeam()){const e=s.getKeyProps()[0];if(0===n)e.line=Ae(t,e.line,n,!1);else if(n>0&&n<t.length){const i=t[n-1];if(g(i))if(i.isRest())e.line=i.getKeyProps()[0].line;else{const s=i.getLineForRest();e.line=Ae(t,s,n,!0)}}s.setKeyLine(0,e.line)}}}))}alignRests(t,e){if(!t||!t.length)throw new f("BadArgument","No voices to format rests");t.forEach((t=>Pe.AlignRestsToNotes(t.getTickables(),e)))}preCalculateMinTotalWidth(t){const e=tt.currentMusicFont().lookupMetric("stave.unalignedNotePadding");let i=0,s=0,n=0;const a=[],o=[];if(this.hasMinTotalWidth)return this.minTotalWidth;if(!this.tickContexts){if(!t)throw new f("BadArgument","'voices' required to run preCalculateMinTotalWidth");this.createTickContexts(t)}const{list:r,map:h}=this.tickContexts;this.minTotalWidth=0,r.forEach((e=>{const r=h[e];r.preFormat(),r.getTickables().length<t.length&&(i+=1),r.getTickables().forEach((t=>{s+=t.getMetrics().width,n+=t.getTicks().value(),a.push(t.getMetrics().width),o.push(t.getTicks().value())}));const c=r.getWidth();this.minTotalWidth+=c})),this.hasMinTotalWidth=!0;const c=s>0?s/a.length:1/a.length,d=ke(a.map((t=>Math.pow(t-c,2)))),l=Math.pow(d/a.length,.5)/c,g=n/o.length,u=ke(o.map((t=>Math.pow(t-g,2)))),p=Math.pow(u/o.length,.5)/g,m=Math.max(p,l)*r.length*e,_=e*i;return this.minTotalWidth+Math.max(_,m)}getMinTotalWidth(){if(!this.hasMinTotalWidth)throw new f("NoMinTotalWidth","Call 'preCalculateMinTotalWidth' or 'preFormat' before calling 'getMinTotalWidth'");return this.minTotalWidth}static getResolutionMultiplier(t){if(!t||!t.length)throw new f("BadArgument","No voices to format");const e=t[0].getTotalTicks();return t.reduce(((t,i)=>{if(!i.getTotalTicks().equals(e))throw new f("TickMismatch","Voices should have same total note duration in ticks.");if(i.getMode()===Gt.Mode.STRICT&&!i.isComplete())throw new f("IncompleteVoice","Voice does not have enough notes.");return Math.max(t,v.LCM(t,i.getResolutionMultiplier()))}),1)}createModifierContexts(t){const e=De(t,(()=>new ge),((t,e)=>t.addToModifierContext(e)));return this.modifierContexts=e,e}createTickContexts(t){const e=De(t,(t=>new Yt(t)),((t,e,i)=>e.addTickable(t,i)));this.tickContexts=e;const i=this.tickContexts.array;return i.forEach((t=>{t.tContexts=i})),e}preFormat(t=0,e,i,s){const n=this.tickContexts;if(!n)throw new f("NoTickContexts","preFormat requires TickContexts");const{list:a,map:o}=n;this.lossHistory=[],i&&s&&i.forEach((t=>t.setStave(s).preFormat()));let r=0,h=0;this.minTotalWidth=0;let c=0;a.forEach((t=>{const e=o[t];e.preFormat();const i=e.getWidth();this.minTotalWidth+=i;const s=e.getMaxTicks().value();c+=s;const n=e.getMetrics();r=r+h+n.totalLeftPx,e.setX(r),h=i-n.totalLeftPx}));const{globalSoftmax:d,softmaxFactor:l,maxIterations:g}=this.formatterOptions,u=ke(a.map((t=>Math.pow(l,o[t].getMaxTicks().value()/c))));if(this.minTotalWidth=r+h,this.hasMinTotalWidth=!0,t<=0)return this.evaluate();const p=o[a[0]],m=o[a[a.length-1]];function _(t){return a.map(((e,i)=>{const s=o[e],n=s.getTickablesByVoice();let r;if(i>0){const e=o[a[i-1]];for(let h=i-1;h>=0;h--){const i=o[a[h]].getTickablesByVoice(),g=[];if(Object.keys(n).forEach((t=>{i[t]&&g.push(t)})),g.length>0){let a=0,o=1/0,h=0;if(g.forEach((t=>{const e=i[t].getTicks().value();e>a&&(r=i[t],a=e);const s=n[t],h=s.getX()-(s.getMetrics().modLeftPx+s.getMetrics().leftDisplacedHeadPx),c=i[t].getMetrics(),d=i[t].getX()+c.notePx+c.modRightPx+c.rightDisplacedHeadPx;o=Math.min(o,h-d)})),o=Math.min(o,s.getX()-(e.getX()+.05*t)),d){const e=c;h=Math.pow(l,a/e)/u*t}else void 0!==r&&(h=r.getVoice().softmax(a)*t);return{expectedDistance:h,maxNegativeShiftPx:o,fromTickable:r}}}}return{expectedDistance:0,fromTickablePx:0,maxNegativeShiftPx:0}}))}function S(t){const e=y/2;let i=0;return a.forEach(((s,n)=>{const a=o[s];if(n>0){const e=a.getX(),s=t[n],o=x(s.fromTickable).getX()+s.expectedDistance-(e+i);let r=0;o>0?i+=o:o<0&&(r=Math.min(s.maxNegativeShiftPx,Math.abs(o)),i+=-r),a.setX(e+i)}a.getCenterAlignedTickables().forEach((t=>{t.setCenterXShift(e-a.getX())}))})),m.getX()-p.getX()}const y=t-m.getMetrics().notePx-m.getMetrics().totalRightPx-p.getMetrics().totalLeftPx,T=tt.currentMusicFont(),b=T.lookupMetric("stave.endPaddingMin"),w=T.lookupMetric("stave.endPaddingMax"),v=T.lookupMetric("stave.padding");let E=y;const C=_(E);let N=S(C);if(1===a.length)return 0;const k=((t,e)=>{let i=t/2;if(e.length>1)for(let t=1;t<e.length;++t)i=Math.min(e[t].expectedDistance/2,i);return i})(E,C),D=t=>{let e=0;const i=m&&m.getMaxTickable();if(i){const s=i.getVoice();if(s.getTicksUsed().value()>s.getTotalTicks().value())return 2*w<k?k:w;const n=i.getWidth();e=s.softmax(m.getMaxTicks().value())*t-(n+v)}return 2*w<e?e:w};let A=D(E),P=A-(w-b);const F=y-P;let M=g;for(;N>F&&M>0||N+A<F&&M>1;)E-=N-F,A=D(E),P=A-(w-b),N=S(_(E)),M--;return this.justifyWidth=t,this.evaluate()}evaluate(){if(!this.tickContexts)return 0;const t=this.tickContexts,e=this.justifyWidth;this.contextGaps={total:0,gaps:[]},t.list.forEach(((e,i)=>{if(0===i)return;const s=t.list[i-1],n=t.map[s],a=t.map[e],o=n.getMetrics(),r=a.getMetrics(),h=n.getX()+o.notePx+o.totalRightPx,c=a.getX()-r.totalLeftPx,d=c-h;this.contextGaps.total+=d,this.contextGaps.gaps.push({x1:h,x2:c}),a.getFormatterMetrics().freedom.left=d,n.getFormatterMetrics().freedom.right=d})),this.durationStats={};const i=this.durationStats;this.voices.forEach((t=>{t.getTickables().forEach(((t,s,n)=>{const a=t.getTicks().clone().simplify().toString(),o=t.getMetrics(),r=t.getFormatterMetrics(),h=t.getX()+o.notePx+o.modRightPx+o.rightDisplacedHeadPx;let c=0;if(s<n.length-1){const e=n[s+1],i=e.getMetrics();c=e.getX()-i.modLeftPx-i.leftDisplacedHeadPx-h,r.space.used=e.getX()-t.getX(),e.getFormatterMetrics().freedom.left=c}else c=e-h,r.space.used=e-t.getX();r.freedom.right=c,function(t,e){const s=i[t];void 0===s?i[t]={mean:e,count:1}:(s.count+=1,s.mean=(s.mean+e)/2)}(a,r.space.used)}))}));let s=0;return this.voices.forEach((t=>{t.getTickables().forEach((t=>{const e=t.getTicks().clone().simplify().toString(),n=t.getFormatterMetrics();n.space.mean=i[e].mean,n.duration=e,n.iterations+=1,n.space.deviation=n.space.used-n.space.mean,s+=Math.pow(n.space.deviation,2)}))})),this.totalCost=Math.sqrt(s),this.lossHistory.push(this.totalCost),this.totalCost}tune(t){var e;const i=this.tickContexts;if(!i)return 0;const s=null!==(e=null==t?void 0:t.alpha)&&void 0!==e?e:.5;let n=0;return this.totalShift=0,i.list.forEach(((t,e,a)=>{const o=i.map[t],r=e>0?i.map[a[e-1]]:void 0,h=e<a.length-1?i.map[a[e+1]]:void 0;!function(t,e,i,s){t.setX(t.getX()+e),t.getFormatterMetrics().freedom.left+=e,t.getFormatterMetrics().freedom.right-=e,i&&(i.getFormatterMetrics().freedom.right+=e),s&&(s.getFormatterMetrics().freedom.left-=e)}(o,n,r,h);const c=-ke(o.getTickables().map((t=>t.getFormatterMetrics().space.deviation)));c>0?n=-Math.min(o.getFormatterMetrics().freedom.right,Math.abs(c)):c<0&&(n=h?Math.min(h.getFormatterMetrics().freedom.right,Math.abs(c)):0),n*=s,this.totalShift+=n})),this.evaluate()}postFormat(){const t=t=>t.list.forEach((e=>t.map[e].postFormat()));return this.modifierContexts&&t(this.modifierContexts),this.tickContexts&&t(this.tickContexts),this}joinVoices(t){return this.createModifierContexts(t),this.hasMinTotalWidth=!1,this}format(t,e,i){const s=Object.assign({align_rests:!1},i);this.voices=t;const n=this.formatterOptions.softmaxFactor;return n&&this.voices.forEach((t=>t.setSoftmaxFactor(n))),this.alignRests(t,s.align_rests),this.createTickContexts(t),this.preFormat(e,s.context,t,s.stave),s.stave&&this.postFormat(),this}formatToStave(t,e,i){const s=Object.assign({context:e.getContext()},i),n=e.getNoteEndX()-e.getNoteStartX()-Ee.defaultPadding;return function(...t){Pe.DEBUG&&S("Vex.Flow.Formatter",t)}("Formatting voices to width: ",n),this.format(t,n,s)}getTickContext(t){var e;return null===(e=this.tickContexts)||void 0===e?void 0:e.map[t]}}var Fe;Pe.DEBUG=!1,function(t){t[t.BOTTOM=-1]="BOTTOM",t[t.TOP=1]="TOP"}(Fe||(Fe={}));class Me extends O{constructor(t,e={}){if(super(),this.numerator_glyphs=[],this.denom_glyphs=[],!t||!t.length)throw new f("BadArguments","No notes provided for tuplet.");this.options=e,this.notes=t,this.num_notes=null!=this.options.num_notes?this.options.num_notes:t.length,this.options.beats_occupied&&this.beatsOccupiedDeprecationWarning(),this.notes_occupied=this.options.notes_occupied||this.options.beats_occupied||2,null!=this.options.bracketed?this.bracketed=this.options.bracketed:this.bracketed=t.some((t=>!t.hasBeam())),this.ratioed=null!=this.options.ratioed?this.options.ratioed:Math.abs(this.notes_occupied-this.num_notes)>1,this.point=tt.currentMusicFont().lookupMetric("digits.tupletPoint"),this.y_pos=16,this.x_pos=100,this.width=200,this.setTupletLocation(this.options.location||Me.LOCATION_TOP),Pe.AlignRestsToNotes(t,!0,!0),this.resolveGlyphs(),this.attach()}static get CATEGORY(){return m.Tuplet}static get LOCATION_TOP(){return Fe.TOP}static get LOCATION_BOTTOM(){return Fe.BOTTOM}static get NESTING_OFFSET(){return 15}static get metrics(){return tt.currentMusicFont().getMetrics().glyphs.tuplet}attach(){for(let t=0;t<this.notes.length;t++){this.notes[t].setTuplet(this)}}detach(){for(let t=0;t<this.notes.length;t++){this.notes[t].resetTuplet(this)}}setBracketed(t){return this.bracketed=!!t,this}setRatioed(t){return this.ratioed=!!t,this}setTupletLocation(t){return t!==Me.LOCATION_TOP&&t!==Me.LOCATION_BOTTOM&&(console.warn(`Invalid tuplet location [${t}]. Using Tuplet.LOCATION_TOP.`),t=Me.LOCATION_TOP),this.location=t,this}getNotes(){return this.notes}getNoteCount(){return this.num_notes}beatsOccupiedDeprecationWarning(){console.warn("beats_occupied has been deprecated as an option for tuplets. Please use notes_occupied instead.","Calls to getBeatsOccupied / setBeatsOccupied should now be routed to getNotesOccupied / setNotesOccupied.","The old methods will be removed in VexFlow 5.0.")}getBeatsOccupied(){return this.beatsOccupiedDeprecationWarning(),this.getNotesOccupied()}setBeatsOccupied(t){return this.beatsOccupiedDeprecationWarning(),this.setNotesOccupied(t)}getNotesOccupied(){return this.notes_occupied}setNotesOccupied(t){this.detach(),this.notes_occupied=t,this.resolveGlyphs(),this.attach()}resolveGlyphs(){this.numerator_glyphs=[];let t=this.num_notes;for(;t>=1;)this.numerator_glyphs.unshift(new U("timeSig"+t%10,this.point)),t=parseInt((t/10).toString(),10);for(this.denom_glyphs=[],t=this.notes_occupied;t>=1;)this.denom_glyphs.unshift(new U("timeSig"+t%10,this.point)),t=parseInt((t/10).toString(),10)}getNestedTupletCount(){const t=this.location,e=this.notes[0];let i=n(e,t),s=n(e,t);function n(t,e){return t.getTupletStack().filter((t=>t.location===e)).length}return this.notes.forEach((e=>{const a=n(e,t);i=a>i?a:i,s=a<s?a:s})),i-s}getYPosition(){const t=this.getNestedTupletCount()*Me.NESTING_OFFSET*-this.location,e=this.options.y_offset||0,i=this.notes[0];let s;if(this.location===Me.LOCATION_TOP){s=i.checkStave().getYForLine(0)-Me.metrics.topModifierOffset;for(let t=0;t<this.notes.length;++t){const e=this.notes[t];let i=0;const n=e.getModifierContext();n&&(i=Math.max(i,n.getState().top_text_line));const a=e.getYForTopText(i)-Me.metrics.noteHeadOffset;if(e.hasStem()||e.isRest()){const t=e.getStemDirection()===nt.UP?e.getStemExtents().topY-Me.metrics.stemOffset:e.getStemExtents().baseY-Me.metrics.noteHeadOffset;s=Math.min(t,s),i>0&&(s=Math.min(a,s))}}}else{let t=Me.metrics.bottomLine;this.notes.forEach((e=>{const i=e.getModifierContext();i&&(t=Math.max(t,i.getState().text_line+1))})),s=i.checkStave().getYForLine(t)+Me.metrics.noteHeadOffset;for(let t=0;t<this.notes.length;++t)if(this.notes[t].hasStem()||this.notes[t].isRest()){const e=this.notes[t].getStemDirection()===nt.UP?this.notes[t].getStemExtents().baseY+Me.metrics.noteHeadOffset:this.notes[t].getStemExtents().topY+Me.metrics.stemOffset;e>s&&(s=e)}}return s+t+e}draw(){const t=this.checkContext();this.setRendered();const e=this.notes[0],i=this.notes[this.notes.length-1];this.bracketed?(this.x_pos=e.getTieLeftX()-5,this.width=i.getTieRightX()-this.x_pos+5):(this.x_pos=e.getStemX(),this.width=i.getStemX()-this.x_pos),this.y_pos=this.getYPosition();const s=(t,e)=>t+x(e.getMetrics().width);let n=this.numerator_glyphs.reduce(s,0);this.ratioed&&(n=this.denom_glyphs.reduce(s,n),n+=.32*this.point);const a=this.x_pos+this.width/2-n/2;if(this.bracketed){const e=this.width/2-n/2-5;e>0&&(t.fillRect(this.x_pos,this.y_pos,e,1),t.fillRect(this.x_pos+this.width/2+n/2+5,this.y_pos,e,1),t.fillRect(this.x_pos,this.y_pos+(this.location===Me.LOCATION_BOTTOM?1:0),1,10*this.location),t.fillRect(this.x_pos+this.width,this.y_pos+(this.location===Me.LOCATION_BOTTOM?1:0),1,10*this.location))}const o=tt.currentMusicFont().lookupMetric("digits.shiftY",0);let r=0;if(this.numerator_glyphs.forEach((e=>{e.render(t,a+r,this.y_pos+this.point/3-2+o),r+=x(e.getMetrics().width)})),this.ratioed){const e=a+r+.16*this.point,i=.06*this.point;t.beginPath(),t.arc(e,this.y_pos-.08*this.point,i,0,2*Math.PI,!0),t.closePath(),t.fill(),t.beginPath(),t.arc(e,this.y_pos+.12*this.point,i,0,2*Math.PI,!0),t.closePath(),t.fill(),r+=.32*this.point,this.denom_glyphs.forEach((e=>{e.render(t,a+r,this.y_pos+this.point/3-2+o),r+=x(e.getMetrics().width)}))}}}function Be(t){let e=0;return t.forEach((t=>{t.keyProps&&t.keyProps.forEach((t=>{e+=t.line-3}))})),e>=0?nt.DOWN:nt.UP}const Re="L",Oe="R",Le="B";class Ie extends O{constructor(t,e=!1){if(super(),this.slope=0,this.y_shift=0,this.forcedPartialDirections={},!t||0===t.length)throw new f("BadArguments","No notes provided for beam.");if(1===t.length)throw new f("BadArguments","Too few notes for beam.");if(this.ticks=t[0].getIntrinsicTicks(),this.ticks>=tt.durationToTicks("4"))throw new f("BadArguments","Beams can only be applied to notes shorter than a quarter note.");let i,s;for(this.stem_direction=nt.UP,i=0;i<t.length;++i)if(s=t[i],s.hasStem()){this.stem_direction=s.getStemDirection();break}let n=this.stem_direction;if(e&&g(t[0]))n=Be(t);else if(e&&p(t[0])){const e=t.reduce(((t,e)=>t+e.getStemDirection()),0);n=e>-1?nt.UP:nt.DOWN}for(i=0;i<t.length;++i)s=t[i],e&&(s.setStemDirection(n),this.stem_direction=n),s.setBeam(this);this.postFormatted=!1,this.notes=t,this.beam_count=this.getBeamCount(),this.break_on_indices=[],this.render_options={beam_width:5,max_slope:.25,min_slope:-.25,slope_iterations:20,slope_cost:100,show_stemlets:!1,stemlet_extension:7,partial_beam_length:10,flat_beams:!1,min_flat_beam_offset:15}}static get CATEGORY(){return m.Beam}getStemDirection(){return this.stem_direction}static getDefaultBeamGroups(t){t&&"c"!==t||(t="4/4");const e={"1/2":["1/2"],"2/2":["1/2"],"3/2":["1/2"],"4/2":["1/2"],"1/4":["1/4"],"2/4":["1/4"],"3/4":["1/4"],"4/4":["1/4"],"1/8":["1/8"],"2/8":["2/8"],"3/8":["3/8"],"4/8":["2/8"],"1/16":["1/16"],"2/16":["2/16"],"3/16":["3/16"],"4/16":["2/16"]}[t];if(void 0!==e)return e.map((t=>(new v).parse(t)));{const e=parseInt(t.split("/")[0],10),i=parseInt(t.split("/")[1],10);if(e%3==0)return[new v(3,i)];if(i>4)return[new v(2,i)];if(i<=4)return[new v(1,i)]}return[new v(1,4)]}static applyAndGetBeams(t,e,i){return Ie.generateBeams(t.getTickables(),{groups:i,stem_direction:e})}static generateBeams(t,e={}){e.groups&&e.groups.length||(e.groups=[new v(2,8)]);const i=e.groups.map((t=>{if(!t.multiply)throw new f("InvalidBeamGroups","The beam groups must be an array of Vex.Flow.Fractions");return t.clone().multiply(tt.RESOLUTION,1)})),s=t;let n=0,a=[],o=[];function r(){i.length-1>n?n+=1:n=0}!function(){let t=[],e=new v(0,1);s.forEach((s=>{if(t=[],s.shouldIgnoreTicks())return a.push(o),void(o=t);o.push(s);const h=i[n].clone(),c=(d=o,d.reduce(((t,e)=>e.getTicks().clone().add(t)),new v(0,1))).add(e);var d;const l=tt.durationToNumber(s.getDuration())<8;if(l&&s.getTuplet()&&(h.numerator*=2),c.greaterThan(h)){if(!l){const e=o.pop();e&&t.push(e)}a.push(o);do{e=c.subtract(i[n]),r()}while(e.greaterThanEquals(i[n]));o=t}else c.equals(h)&&(a.push(o),e=new v(0,1),o=t,r())})),o.length>0&&a.push(o)}(),function(){const t=[];a.forEach((i=>{let s=[];i.forEach(((i,n,a)=>{const o=0===n||n===a.length-1,r=a[n-1],h=!e.beam_rests&&i.isRest(),c=e.beam_rests&&e.beam_middle_only&&i.isRest()&&o;let d=!1;if(e.maintain_stem_directions&&r&&!i.isRest()&&!r.isRest()){const t=r.getStemDirection();d=i.getStemDirection()!==t}const l=parseInt(i.getDuration(),10)<8;h||c||d||l?(s.length>0&&t.push(s),s=d?[i]:[]):s.push(i)})),s.length>0&&t.push(s)})),a=t}(),a.forEach((t=>{let i;if(e.maintain_stem_directions){const e=function(t){for(let e=0;e<t.length;e++){const i=t[e];if(!i.isRest())return i}return!1}(t);i=e?e.getStemDirection():nt.UP}else i=e.stem_direction?e.stem_direction:Be(t);!function(t,e){t.forEach((t=>{t.setStemDirection(e)}))}(t,i)}));const h=a.filter((t=>{if(t.length>1){let e=!0;return t.forEach((t=>{t.getIntrinsicTicks()>=tt.durationToTicks("4")&&(e=!1)})),e}return!1})),c=function(){const t=[];return a.forEach((e=>{let i;e.forEach((e=>{const s=e.getTuplet();s&&i!==s&&(i=s,t.push(i))}))})),t}(),d=[];return h.forEach((t=>{const i=new Ie(t);e.show_stemlets&&(i.render_options.show_stemlets=!0),e.secondary_breaks&&(i.render_options.secondary_break_ticks=tt.durationToTicks(e.secondary_breaks)),!0===e.flat_beams&&(i.render_options.flat_beams=!0,i.render_options.flat_beam_offset=e.flat_beam_offset),d.push(i)})),c.forEach((t=>{const e=t.notes[0].stem_direction===nt.DOWN?Fe.BOTTOM:Fe.TOP;t.setTupletLocation(e);let i=!1;for(let e=0;e<t.notes.length;e++){if(!t.notes[e].hasBeam()){i=!0;break}}t.setBracketed(i)})),d}getNotes(){return this.notes}getBeamCount(){return this.notes.map((t=>t.getGlyph().beam_count)).reduce(((t,e)=>e>t?e:t))}breakSecondaryAt(t){return this.break_on_indices=t,this}setPartialBeamSideAt(t,e){return this.forcedPartialDirections[t]=e,this}unsetPartialBeamSideAt(t){return delete this.forcedPartialDirections[t],this}getSlopeY(t,e,i,s){return i+(t-e)*s}calculateSlope(){const{notes:t,stem_direction:e,render_options:{max_slope:i,min_slope:s,slope_iterations:n,slope_cost:a}}=this,o=t[0],r=function(t,e){const i=t.getStemExtents().topY,s=t.getStemX();return(e.getStemExtents().topY-i)/(e.getStemX()-s)}(o,t[t.length-1]),h=(i-s)/n;let c=Number.MAX_VALUE,d=0,l=0;for(let n=s;n<=i;n+=h){let i=0,s=0;for(let a=1;a<t.length;++a){const r=t[a];if(r.hasStem()||r.isRest()){const t=this.getSlopeY(r.getStemX(),o.getStemX(),o.getStemExtents().topY,n)+s,h=r.getStemExtents().topY;if(h*e<t*e){const n=Math.abs(h-t);s+=n*-e,i+=n*a}else i+=(h-t)*e}}const h=r/2,g=a*Math.abs(h-n)+Math.abs(i);g<c&&(c=g,d=n,l=s)}this.slope=d,this.y_shift=l}calculateFlatSlope(){const{notes:t,stem_direction:e,render_options:{beam_width:i,min_flat_beam_offset:s,flat_beam_offset:n}}=this;let a=0,o=0,r=0,h=0;for(let i=0;i<t.length;i++){const s=t[i],n=s.getStemExtents().topY;a+=n,e===nt.DOWN&&h<n?(h=n,o=Math.max(...s.getYs()),r=s.getBeamCount()):e===nt.UP&&(0===h||h>n)&&(h=n,o=Math.min(...s.getYs()),r=s.getBeamCount())}let c=a/t.length;const d=s+r*(1.5*i),l=o+d*-e;e===nt.DOWN&&c<l?c=o+d:e===nt.UP&&c>l&&(c=o-d),n?(e===nt.DOWN&&c>n||e===nt.UP&&c<n)&&(this.render_options.flat_beam_offset=c):this.render_options.flat_beam_offset=c,this.slope=0,this.y_shift=0}getBeamYToDraw(){let t=this.notes[0].getStemExtents().topY;return this.render_options.flat_beams&&this.render_options.flat_beam_offset&&(t=this.render_options.flat_beam_offset),t}applyStemExtensions(){const{notes:t,slope:e,y_shift:i,stem_direction:s,beam_count:n,render_options:{show_stemlets:a,stemlet_extension:o,beam_width:r}}=this,h=t[0],c=this.getBeamYToDraw(),d=h.getStemX();for(let h=0;h<t.length;++h){const l=t[h],g=l.getStem();if(g){const t=l.getStemX(),{topY:h}=l.getStemExtents(),u=this.getSlopeY(t,d,c,e)+i,p=g.getExtension(),m=s===nt.UP?h-u:u-h;if(g.setExtension(p+m),g.adjustHeightForBeam(),l.isRest()&&a){const t=(n-1)*r*1.5+r;g.setVisibility(!0).setStemlet(!0,t+o)}}}}lookupBeamDirection(t,e,i,s,n){if("4"===t)return Re;const a=this.forcedPartialDirections[n];if(a)return a;const o=""+tt.durationToNumber(t)/2,r=e<tt.durationToTicks(o),h=s<tt.durationToTicks(o),c=i<tt.durationToTicks(o);return r&&h&&c?Le:r&&!h&&c?Re:!r&&h&&c?Oe:this.lookupBeamDirection(o,e,i,s,n)}getBeamLines(t){const e=tt.durationToTicks(t);let i=!1;const s=[];let n;const a=this.render_options.partial_beam_length;let o=!1,r=0;for(let h=0;h<this.notes.length;++h){const c=this.notes[h];r+=c.getTicks().value();let d=!1;parseInt(t,10)>=8&&(d=-1!==this.break_on_indices.indexOf(h),this.render_options.secondary_break_ticks&&r>=this.render_options.secondary_break_ticks&&(r=0,d=!0));const l=c.getIntrinsicTicks()<e,g=c.getStemX()-nt.WIDTH/2,u=this.notes[h-1],p=this.notes[h+1],m=p&&p.getIntrinsicTicks()<e,f=u&&u.getIntrinsicTicks()<e,_=u&&p&&l&&!f&&!m;if(l)if(i)n=s[s.length-1],n.end=g,d&&(i=!1,p&&!m&&void 0===n.end&&(n.end=n.start-a));else{if(n={start:g,end:void 0},i=!0,_){const e=u.getIntrinsicTicks(),i=p.getIntrinsicTicks(),s=c.getIntrinsicTicks(),o=this.lookupBeamDirection(t,e,s,i,h);[Re,Le].includes(o)?n.end=n.start-a:n.end=n.start+a}else m?d&&(n.end=n.start-a,i=!1):n.end=(o||0===h)&&p?n.start+a:n.start-a;s.push(n)}else i=!1;o=d}const h=s[s.length-1];return h&&void 0===h.end&&(h.end=h.start-a),s}drawStems(t){this.notes.forEach((e=>{const i=e.getStem();i&&(t.openGroup("stem",e.getAttribute("id")+"-stem"),i.setContext(t).draw(),t.closeGroup())}),this)}drawBeamLines(t){const e=["4","8","16","32","64"],i=this.notes[0];let s=this.getBeamYToDraw();const n=i.getStemX(),a=this.render_options.beam_width*this.stem_direction;for(let i=0;i<e.length;++i){const o=e[i],r=this.getBeamLines(o);for(let e=0;e<r.length;++e){const i=r[e],o=i.start,h=this.getSlopeY(o,n,s,this.slope),c=i.end;if(!c)throw new f("NoLastBeamX","lastBeamX undefined.");{const e=this.getSlopeY(c,n,s,this.slope);this.setAttribute("el",t.openGroup("beam")),t.beginPath(),t.moveTo(o,h),t.lineTo(o,h+a),t.lineTo(c+1,e+a),t.lineTo(c+1,e),t.closePath(),t.fill(),t.closeGroup()}}s+=1.5*a}}preFormat(){return this}postFormat(){this.postFormatted||(p(this.notes[0])||this.render_options.flat_beams?this.calculateFlatSlope():this.calculateSlope(),this.applyStemExtensions(),this.postFormatted=!0)}draw(){const t=this.checkContext();this.setRendered(),this.unbeamable||(this.postFormatted||this.postFormat(),this.drawStems(t),this.applyStyle(),this.drawBeamLines(t),this.restoreStyle())}}class We extends bt{constructor(t,e,i){super({duration:"b"}),this.type=t,this.clef_obj=new ue(t,e,i),this.clef=this.clef_obj.clef,this.glyph=new U(this.clef.code,this.clef.point),this.setWidth(this.glyph.getMetrics().width),this.ignore_ticks=!0}static get CATEGORY(){return m.ClefNote}setType(t,e,i){return this.type=t,this.clef_obj=new ue(t,e,i),this.clef=this.clef_obj.clef,this.glyph=new U(this.clef.code,this.clef.point),this.setWidth(this.glyph.getMetrics().width),this}getClef(){return this.clef}setContext(t){return super.setContext(t),this.glyph.setContext(this.getContext()),this}getBoundingBox(){return super.getBoundingBox()}addToModifierContext(t){return this}preFormat(){return this.preFormatted=!0,this}draw(){var t;const e=this.checkStave();this.glyph.getContext()||this.glyph.setContext(this.getContext()),this.setRendered();const i=this.getAbsoluteX();if(this.glyph.setStave(e),this.glyph.setYShift(e.getYForLine(null!==(t=this.clef.line)&&void 0!==t?t:0)-e.getYForGlyphs()),this.glyph.renderToStave(i),void 0!==this.clef_obj.annotation){const t=new U(this.clef_obj.annotation.code,this.clef_obj.annotation.point);t.getContext()||t.setContext(this.getContext()),t.setStave(e),t.setYShift(e.getYForLine(this.clef_obj.annotation.line)-e.getYForGlyphs()),t.setXShift(this.clef_obj.annotation.x_shift),t.renderToStave(i)}}}class Ge extends bt{constructor(t){super(t),this.options={extend_left:0,extend_right:0,y_shift:0},this.decrescendo=!1,this.line=t.line||0,this.height=15}static get CATEGORY(){return m.Crescendo}setLine(t){return this.line=t,this}setHeight(t){return this.height=t,this}setDecrescendo(t){return this.decrescendo=t,this}preFormat(){return this.preFormatted=!0,this}draw(){const t=this.checkContext(),e=this.checkStave();this.setRendered();const i=this.getTickContext(),s=Yt.getNextContext(i),n=this.getAbsoluteX(),a=s?s.getX():e.getX()+e.getWidth(),o=e.getYForLine(this.line+-3)+1;!function(...t){Ge.DEBUG&&S("Vex.Flow.Crescendo",t)}("Drawing ",this.decrescendo?"decrescendo ":"crescendo ",this.height,"x",n-a),function(t,e){const i=e.begin_x,s=e.end_x,n=e.y,a=e.height/2;t.beginPath(),e.reverse?(t.moveTo(i,n-a),t.lineTo(s,n),t.lineTo(i,n+a)):(t.moveTo(s,n-a),t.lineTo(i,n),t.lineTo(s,n+a)),t.stroke(),t.closePath()}(t,{begin_x:n-this.options.extend_left,end_x:a+this.options.extend_right,y:o+this.options.y_shift,height:this.height,reverse:this.decrescendo})}}var Ue;Ge.DEBUG=!1,function(t){t[t.NEAR_HEAD=1]="NEAR_HEAD",t[t.NEAR_TOP=2]="NEAR_TOP"}(Ue||(Ue={}));class He extends O{constructor(t,e,i){super(),this.render_options=Object.assign({thickness:2,x_shift:0,y_shift:10,position:Ue.NEAR_HEAD,position_end:Ue.NEAR_HEAD,invert:!1,cps:[{x:0,y:10},{x:0,y:10}]},i),this.from=t,this.to=e}static get CATEGORY(){return m.Curve}static get Position(){return Ue}static get PositionString(){return{nearHead:Ue.NEAR_HEAD,nearTop:Ue.NEAR_TOP}}setNotes(t,e){if(!t&&!e)throw new f("BadArguments","Curve needs to have either `from` or `to` set.");return this.from=t,this.to=e,this}isPartial(){return!this.from||!this.to}renderCurve(t){const e=this.checkContext(),i=this.render_options.x_shift,s=this.render_options.y_shift*t.direction,n=t.first_x+i,a=t.first_y+s,o=t.last_x-i,r=t.last_y+s,h=this.render_options.thickness,c=this.render_options.cps,{x:d,y:l}=c[0],{x:g,y:u}=c[1],p=(o-n)/(c.length+2);e.beginPath(),e.moveTo(n,a),e.bezierCurveTo(n+p+d,a+l*t.direction,o-p+g,r+u*t.direction,o,r),e.bezierCurveTo(o-p+g,r+(u+h)*t.direction,n+p+d,a+(l+h)*t.direction,n,a),e.stroke(),e.closePath(),e.fill()}draw(){this.checkContext(),this.setRendered();const t=this.from,e=this.to;let i,s,n,a,o=0,r="baseY",h="baseY";function c(t){return"string"==typeof t?He.PositionString[t]:t}const d=c(this.render_options.position),l=c(this.render_options.position_end);if(d===Ue.NEAR_TOP&&(r="topY",h="topY"),l===Ue.NEAR_HEAD?h="baseY":l===Ue.NEAR_TOP&&(h="topY"),t)i=t.getTieRightX(),o=t.getStemDirection(),n=t.getStemExtents()[r];else{i=e.checkStave().getTieStartX(),n=e.getStemExtents()[r]}if(e)s=e.getTieLeftX(),o=e.getStemDirection(),a=e.getStemExtents()[h];else{s=t.checkStave().getTieEndX(),a=t.getStemExtents()[h]}return this.renderCurve({first_x:i,last_x:s,first_y:n,last_y:a,direction:o*(!0===this.render_options.invert?-1:1)}),!0}}function Ye(...t){Xe.DEBUG&&S("Vex.Flow.Parser",t)}function je(t){if("matchedString"in t)return t.matchedString;if("results"in t)return je(t.results);const e=t;return 1===e.length?je(e[0]):0===e.length?null:e.map(je)}class Xe{constructor(t){this.grammar=t,this.line="",this.pos=0,this.errorPos=-1}parse(t){this.line=t,this.pos=0,this.errorPos=-1;const e=this.expect(this.grammar.begin());return e.errorPos=this.errorPos,e}matchFail(t){-1===this.errorPos&&(this.errorPos=this.pos),this.pos=t}matchSuccess(){this.errorPos=-1}matchToken(t,e=!1){const i=e?new RegExp("^(("+t+"))"):new RegExp("^(("+t+")\\s*)"),s=this.line.slice(this.pos).match(i);return null!==s?{success:!0,matchedString:s[2],incrementPos:s[1].length,pos:this.pos}:{success:!1,pos:this.pos}}expectOne(t,e=!1){const i=[],s=this.pos;let n=!0,a=!1;if(e=!0===e||!0===t.maybe,t.expect)for(const e of t.expect){const s=this.pos,o=this.expect(e);if(o.success){if(i.push(o),a=!0,t.or)break}else if(n=!1,!t.or){this.pos=s;break}}const o=t.or&&a||n,r=o||!0===e,h=o?1:0;return e&&!o&&(this.pos=s),r?this.matchSuccess():this.matchFail(s),{success:r,results:i,numMatches:h}}expectOneOrMore(t,e=!1){const i=[],s=this.pos;let n=0,a=!0;do{const e=this.expectOne(t);e.success&&e.results?(n++,i.push(e.results)):a=!1}while(a);const o=n>0||!0===e;return!e||n>0||(this.pos=s),o?this.matchSuccess():this.matchFail(s),{success:o,results:i,numMatches:n}}expectZeroOrMore(t){return this.expectOneOrMore(t,!0)}expect(t){if(Ye("Evaluating rule function:",t),!t)throw new f("Invalid rule function");let e;const i=t.bind(this.grammar)();if(i.token)e=this.matchToken(i.token,!0===i.noSpace),e.success&&(this.pos+=e.incrementPos);else{if(!i.expect)throw Ye(i),new f("Bad grammar! No `token` or `expect` property "+i);e=i.oneOrMore?this.expectOneOrMore(i):i.zeroOrMore?this.expectZeroOrMore(i):this.expectOne(i)}const s=[];return e.matches=s,e.results&&e.results.forEach((t=>s.push(je(t)))),i.run&&e.success&&i.run({matches:s}),e}}function Ve(...t){Ze.DEBUG&&S("Vex.Flow.EasyScore",t)}Xe.DEBUG=!1;class ze{constructor(t){this.builder=t}begin(){return this.LINE}LINE(){return{expect:[this.PIECE,this.PIECES,this.EOL]}}PIECE(){return{expect:[this.CHORDORNOTE,this.PARAMS],run:()=>this.builder.commitPiece()}}PIECES(){return{expect:[this.COMMA,this.PIECE],zeroOrMore:!0}}PARAMS(){return{expect:[this.DURATION,this.TYPE,this.DOTS,this.OPTS]}}CHORDORNOTE(){return{expect:[this.CHORD,this.SINGLENOTE],or:!0}}CHORD(){return{expect:[this.LPAREN,this.NOTES,this.RPAREN],run:t=>this.builder.addChord(t.matches[1])}}NOTES(){return{expect:[this.NOTE],oneOrMore:!0}}NOTE(){return{expect:[this.NOTENAME,this.ACCIDENTAL,this.OCTAVE]}}SINGLENOTE(){return{expect:[this.NOTENAME,this.ACCIDENTAL,this.OCTAVE],run:t=>{const e=t;this.builder.addSingleNote(e.matches[0],e.matches[1],e.matches[2])}}}ACCIDENTAL(){return{expect:[this.MICROTONES,this.ACCIDENTALS],maybe:!0,or:!0}}DOTS(){return{expect:[this.DOT],zeroOrMore:!0,run:t=>this.builder.setNoteDots(t.matches)}}TYPE(){return{expect:[this.SLASH,this.MAYBESLASH,this.TYPES],maybe:!0,run:t=>this.builder.setNoteType(t.matches[2])}}DURATION(){return{expect:[this.SLASH,this.DURATIONS],maybe:!0,run:t=>this.builder.setNoteDuration(t.matches[1])}}OPTS(){return{expect:[this.LBRACKET,this.KEYVAL,this.KEYVALS,this.RBRACKET],maybe:!0}}KEYVALS(){return{expect:[this.COMMA,this.KEYVAL],zeroOrMore:!0}}KEYVAL(){return{expect:[this.KEY,this.EQUALS,this.VAL],run:t=>this.builder.addNoteOption(t.matches[0],t.matches[2].slice(1,-1))}}VAL(){return{expect:[this.SVAL,this.DVAL],or:!0}}KEY(){return{token:"[a-zA-Z][a-zA-Z0-9]*"}}DVAL(){return{token:'["][^"]*["]'}}SVAL(){return{token:"['][^']*[']"}}NOTENAME(){return{token:"[a-gA-G]"}}OCTAVE(){return{token:"[0-9]+"}}ACCIDENTALS(){return{token:"bb|b|##|#|n"}}MICROTONES(){return{token:"bbs|bss|bs|db|d|\\+\\+-|\\+-|\\+\\+|\\+|k|o"}}DURATIONS(){return{token:"[0-9whq]+"}}TYPES(){return{token:"[rRsSmMhHgG]"}}LPAREN(){return{token:"[(]"}}RPAREN(){return{token:"[)]"}}COMMA(){return{token:"[,]"}}DOT(){return{token:"[.]"}}SLASH(){return{token:"[/]"}}MAYBESLASH(){return{token:"[/]?"}}EQUALS(){return{token:"[=]"}}LBRACKET(){return{token:"\\["}}RBRACKET(){return{token:"\\]"}}EOL(){return{token:"$"}}}class Ke{constructor(t){this.chord=[],this.dots=0,this.options={},this.duration=t}}class $e{constructor(t){this.commitHooks=[],this.factory=t,this.reset()}reset(t){this.options=Object.assign({stem:"auto",clef:"treble"},t),this.elements={notes:[],accidentals:[]},this.rollingDuration="8",this.resetPiece()}getFactory(){return this.factory}getElements(){return this.elements}addCommitHook(t){this.commitHooks.push(t)}resetPiece(){Ve("resetPiece"),this.piece=new Ke(this.rollingDuration)}setNoteDots(t){Ve("setNoteDots:",t),t&&(this.piece.dots=t.length)}setNoteDuration(t){Ve("setNoteDuration:",t),this.rollingDuration=this.piece.duration=t||this.rollingDuration}setNoteType(t){Ve("setNoteType:",t),t&&(this.piece.type=t)}addNoteOption(t,e){Ve("addNoteOption: key:",t,"value:",e),this.piece.options[t]=e}addNote(t,e,i){Ve("addNote:",t,e,i),this.piece.chord.push({key:t,accid:e,octave:i})}addSingleNote(t,e,i){Ve("addSingleNote:",t,e,i),this.addNote(t,e,i)}addChord(t){Ve("startChord"),"object"!=typeof t[0]?this.addSingleNote(t[0]):t.forEach((t=>{t&&this.addNote(...t)})),Ve("endChord")}commitPiece(){Ve("commitPiece");const{factory:t}=this;if(!t)return;const e=Object.assign(Object.assign({},this.options),this.piece.options),i=x(e.stem,"BadArguments","options.stem is not defined").toLowerCase(),s=x(e.clef,"BadArguments","options.clef is not defined").toLowerCase(),{chord:n,duration:a,dots:o,type:r}=this.piece,h=Y.accidentals,c=n.map((t=>{var e;return t.key+(h.includes(null!==(e=t.accid)&&void 0!==e?e:"")?t.accid:"")+"/"+t.octave})),d="auto"===i,l="g"==(null==r?void 0:r.toLowerCase())?t.GhostNote({duration:a,dots:o}):t.StaveNote({keys:c,duration:a,dots:o,type:r,clef:s,auto_stem:d});d||l.setStemDirection("up"===i?nt.UP:nt.DOWN);const g=[];n.forEach(((e,i)=>{const s=e.accid;if("string"==typeof s){const e=t.Accidental({type:s});l.addModifier(e,i),g.push(e)}else g.push(void 0)}));for(let t=0;t<o;t++)Ot.buildAndAttach([l],{all:!0});this.commitHooks.forEach((t=>t(e,l,this))),this.elements.notes.push(l),this.elements.accidentals.push(g),this.resetPiece()}}function Je(t,e){void 0!==t.id&&e.setAttribute("id",t.id)}const qe=/\s*,\s*/;function Qe(t,e){void 0!==t.class&&t.class.split(qe).forEach((t=>e.addClass(t)))}class Ze{constructor(t={}){this.defaults={clef:"treble",time:"4/4",stem:"auto"},this.setOptions(t)}set(t){return this.defaults=Object.assign(Object.assign({},this.defaults),t),this}setOptions(t){var e,i;const s=t.factory,n=null!==(e=t.builder)&&void 0!==e?e:new $e(s);return this.options=Object.assign(Object.assign({commitHooks:[Je,Qe,xt.easyScoreHook,Lt.easyScoreHook],throwOnError:!1},t),{factory:s,builder:n}),this.factory=s,this.builder=n,this.grammar=new ze(this.builder),this.parser=new Xe(this.grammar),null===(i=this.options.commitHooks)||void 0===i||i.forEach((t=>this.addCommitHook(t))),this}setContext(t){return this.factory.setContext(t),this}parse(t,e={}){this.builder.reset(e);const i=this.parser.parse(t);if(!i.success&&this.options.throwOnError)throw Ve(i),new f("Error parsing line: "+t);return i}beam(t,e){return this.factory.Beam({notes:t,options:e}),t}tuplet(t,e){return this.factory.Tuplet({notes:t,options:e}),t}notes(t,e={}){return e=Object.assign({clef:this.defaults.clef,stem:this.defaults.stem},e),this.parse(t,e),this.builder.getElements().notes}voice(t,e={}){return e=Object.assign({time:this.defaults.time},e),this.factory.Voice(e).addTickables(t)}addCommitHook(t){this.builder.addCommitHook(t)}}Ze.DEBUG=!1;const ti="Ghost note must have valid initialization data to identify duration.";class ei extends zt{static get CATEGORY(){return m.GhostNote}constructor(t){if(!t)throw new f("BadArguments",ti);let e;if("string"==typeof t)e={duration:t};else{if("object"!=typeof t)throw new f("BadArguments",ti);e=t}super(e),this.setWidth(0)}isRest(){return!0}setStave(t){return super.setStave(t),this}addToModifierContext(t){return this}preFormat(){return this.preFormatted=!0,this}draw(){this.setRendered();for(let t=0;t<this.modifiers.length;++t){const e=this.modifiers[t];a(e)&&(e.setContext(this.getContext()),e.drawWithStyle())}}}class ii extends bt{constructor(t,e,i){super(e),this.options=Object.assign({ignoreTicks:!1,line:2},i),this.ignore_ticks=this.options.ignoreTicks,t&&this.setGlyph(t)}static get CATEGORY(){return m.GlyphNote}setGlyph(t){return this.glyph=t,this.setWidth(this.glyph.getMetrics().width),this}getBoundingBox(){return this.glyph.getBoundingBox()}preFormat(){return!this.preFormatted&&this.modifierContext&&this.modifierContext.preFormat(),this.preFormatted=!0,this}drawModifiers(){const t=this.checkContext();t.openGroup("modifiers");for(let e=0;e<this.modifiers.length;e++){const i=this.modifiers[e];i.setContext(t),i.drawWithStyle()}t.closeGroup()}draw(){const t=this.checkStave(),e=t.checkContext();this.setRendered(),e.openGroup("glyphNote",this.getAttribute("id"));const i=this.glyph;i.getContext()||i.setContext(e),i.setStave(t),i.setYShift(t.getYForLine(this.options.line)-t.getYForGlyphs());const s=this.isCenterAligned()?this.getAbsoluteX()-this.getWidth()/2:this.getAbsoluteX();i.renderToStave(s),this.drawModifiers(),e.closeGroup()}}class si extends $t{constructor(t){super(Object.assign({glyph_font_scale:tt.NOTATION_FONT_SCALE*si.SCALE,stroke_px:si.LEDGER_LINE_OFFSET},t)),this.slash=t.slash||!1,this.slur=!0,this.buildNoteHeads(),this.width=3}static get CATEGORY(){return m.GraceNote}static get LEDGER_LINE_OFFSET(){return 2}static get SCALE(){return.66}getStemExtension(){if(this.stem_extension_override)return this.stem_extension_override;const t=this.getGlyph();if(t){let e=super.getStemExtension();if(t.stem){const t=this.getStaveNoteScale();e=(nt.HEIGHT+e)*t-nt.HEIGHT}return e}return 0}getStaveNoteScale(){return this.render_options.glyph_font_scale/tt.NOTATION_FONT_SCALE}draw(){super.draw(),this.setRendered();const t=this.stem;if(this.slash&&t){const e=this.getStaveNoteScale(),i=e/.66;let s;const n=this.beam;if(n)n.postFormatted||n.postFormat(),s=this.calcBeamedNotesSlashBBox(8*i,8*i,{stem:6*i,beam:5*i});else{const n=this.getStemDirection(),a=this.getNoteHeadBounds(),o=t.getHeight();let r=this.getAbsoluteX(),h=n===nt.DOWN?a.y_top-o:a.y_bottom-o;const c=n===nt.DOWN?this.glyph.stem_down_extension:this.glyph.stem_up_extension;let d=tt.STEM_HEIGHT;d-=d/2.8,d+=c,h+=d*e*n;const l=n===nt.UP?{x1:1,y1:0,x2:13,y2:-9}:{x1:-4,y1:1,x2:13,y2:9};r+=l.x1*i,h+=l.y1*i,s={x1:r,y1:h,x2:r+l.x2*i,y2:h+l.y2*i}}const a=this.checkContext();a.save(),a.setLineWidth(1*i),a.beginPath(),a.moveTo(s.x1,s.y1),a.lineTo(s.x2,s.y2),a.closePath(),a.stroke(),a.restore()}}calcBeamedNotesSlashBBox(t,e,i){const s=this.beam;if(!s)throw new f("NoBeam","Can't calculate without a beam.");const n=s.slope,a=s.notes[s.notes.length-1]===this?-1:1,o=Math.atan(n*a),r=Math.cos(o)*e,h=Math.sin(o)*e;t*=this.getStemDirection();const c=Math.atan((h-t)/r),d=Math.cos(c)*i.stem*a,l=Math.sin(c)*i.stem,g=Math.cos(c)*i.beam*a,u=Math.sin(c)*i.beam,p=this.getStemX(),m=s.notes[0].getStemX(),_=s.getBeamYToDraw()+(p-m)*n;return{x1:p-d,y1:_+t-l,x2:p+r*a+g,y2:_+h+u}}}class ni extends bt{constructor(t,e,i){super({duration:"b"}),this.keySignature=new pe(t,e,i),this.ignore_ticks=!0}static get CATEGORY(){return m.KeySigNote}addToModifierContext(t){return this}preFormat(){return this.preFormatted=!0,this.keySignature.setStave(this.checkStave()),this.setWidth(this.keySignature.getWidth()),this}draw(){const t=this.checkStave().checkContext();this.setRendered(),this.keySignature.setX(this.getAbsoluteX()),this.keySignature.setContext(t),this.keySignature.draw()}}let ai;class oi extends O{constructor(t,e){super(),this.xs={left:NaN,right:NaN},this.hasPaddingLeft=!1,this.hasPaddingRight=!1,this.hasLineThickness=!1,this.hasSymbolSpacing=!1,this.number_of_measures=t,this.hasPaddingLeft="number"==typeof e.padding_left,this.hasPaddingRight="number"==typeof e.padding_right,this.hasLineThickness="number"==typeof e.line_thickness,this.hasSymbolSpacing="number"==typeof e.symbol_spacing;const i=tt.currentMusicFont();this.render_options=Object.assign({use_symbols:!1,show_number:!0,number_line:-.5,number_glyph_point:i.lookupMetric("digits.point"),line:2,spacing_between_lines_px:tt.STAVE_LINE_DISTANCE,serif_thickness:2,semibreve_rest_glyph_scale:tt.NOTATION_FONT_SCALE,padding_left:0,padding_right:0,line_thickness:5,symbol_spacing:0},e);const s=i.lookupMetric("digits.shiftLine",0);this.render_options.number_line+=s}static get CATEGORY(){return m.MultiMeasureRest}getXs(){return this.xs}setStave(t){return this.stave=t,this}getStave(){return this.stave}checkStave(){return x(this.stave,"NoStave","No stave attached to instance.")}drawLine(t,e,i,s,n){const a=this.render_options,o=t.getYForLine(a.line),r=.1*(s-i);let h;i+=r,s-=r,h=this.hasLineThickness?.5*a.line_thickness:.25*n;const c=a.serif_thickness,d=o-n,l=o+n,g=i+c,u=s-c,p=o-h,m=o+h;e.save(),e.beginPath(),e.moveTo(i,d),e.lineTo(g,d),e.lineTo(g,p),e.lineTo(u,p),e.lineTo(u,d),e.lineTo(s,d),e.lineTo(s,l),e.lineTo(u,l),e.lineTo(u,m),e.lineTo(g,m),e.lineTo(g,l),e.lineTo(i,l),e.closePath(),e.fill()}drawSymbols(t,e,i,s,n){const a=Math.floor(this.number_of_measures/4),o=this.number_of_measures%4,r=Math.floor(o/2),h=o%2,c=this.render_options;ai=void 0;const d=function(){if(!ai){const t=new Vt({duration:"w",note_type:"r"});ai={glyph_font_scale:t.render_options.glyph_font_scale,glyph_code:t.glyph_code,width:t.getWidth()}}return ai}(),l=c.semibreve_rest_glyph_scale,g=d.width*(l/d.glyph_font_scale),u={2:{width:.5*g,height:n},1:{width:g}},p=this.hasSymbolSpacing?c.symbol_spacing:10;let m=i+.5*(s-i)-.5*(a*u[2].width+r*u[2].width+h*u[1].width+(a+r+h-1)*p);const f=c.line,_=t.getYForLine(f-1),x=t.getYForLine(f),S=t.getYForLine(f+1);e.save(),e.setStrokeStyle("none"),e.setLineWidth(0);for(let t=0;t<a;++t)e.fillRect(m,x-u[2].height,u[2].width,u[2].height),e.fillRect(m,S-u[2].height,u[2].width,u[2].height),m+=u[2].width+p;for(let t=0;t<r;++t)e.fillRect(m,x-u[2].height,u[2].width,u[2].height),m+=u[2].width+p;for(let t=0;t<h;++t)U.renderGlyph(e,m,_,l,d.glyph_code),m+=u[1].width+p;e.restore()}draw(){const t=this.checkContext();this.setRendered();const e=this.checkStave();let i=e.getNoteStartX(),s=e.getNoteEndX();const n=e.getModifiers(wt.BEGIN);1===n.length&&o(n[0])&&(i-=n[0].getWidth());const a=this.render_options;this.hasPaddingLeft&&(i=e.getX()+a.padding_left),this.hasPaddingRight&&(s=e.getX()+e.getWidth()-a.padding_right),this.xs.left=i,this.xs.right=s;const r=a.spacing_between_lines_px;if(a.use_symbols?this.drawSymbols(e,t,i,s,r):this.drawLine(e,t,i,s,r),a.show_number){const n="/"+this.number_of_measures,o=new be(n,0,!1);o.point=a.number_glyph_point,o.setTimeSig(n),o.setStave(e),o.setX(i+.5*(s-i)-.5*o.getInfo().glyph.getMetrics().width),o.bottomLine=a.number_line,o.setContext(t).draw()}}}function ri(t,e,i,s,n){const a=hi.GLYPHS[t];new U(a.code,n,{category:"pedalMarking"}).render(e,i+a.x_shift,s+a.y_shift)}class hi extends O{constructor(t){super(),this.notes=t,this.type=hi.type.TEXT,this.line=0,this.custom_depress_text="",this.custom_release_text="",this.resetFont(),this.render_options={bracket_height:10,text_margin_right:6,bracket_line_width:1,color:"black"}}static get CATEGORY(){return m.PedalMarking}static createSustain(t){return new hi(t)}static createSostenuto(t){const e=new hi(t);return e.setType(hi.type.MIXED),e.setCustomText("Sost. Ped."),e}static createUnaCorda(t){const e=new hi(t);return e.setType(hi.type.TEXT),e.setCustomText("una corda","tre corda"),e}setType(t){return(t="string"==typeof t?hi.typeString[t]:t)>=hi.type.TEXT&&t<=hi.type.MIXED&&(this.type=t),this}setCustomText(t,e){return this.custom_depress_text=t||"",this.custom_release_text=e||"",this}setLine(t){return this.line=t,this}drawBracketed(){const t=this.checkContext();let e,i,s=!1;this.notes.forEach(((n,a,o)=>{s=!s;const r=n.getAbsoluteX(),h=n.checkStave().getYForBottomText(this.line+3);if(r<e)throw new f("InvalidConfiguration","The notes provided must be in order of ascending x positions");const c=o[a+1]===n,d=o[a-1]===n;let l=0;const g=tt.currentMusicFont().lookupMetric(`pedalMarking.${s?"down":"up"}.point`);if(s)if(l=d?5:0,this.type!==hi.type.MIXED||d)t.beginPath(),t.moveTo(r,h-this.render_options.bracket_height),t.lineTo(r+l,h),t.stroke(),t.closePath();else if(this.custom_depress_text){const e=t.measureText(this.custom_depress_text).width;t.fillText(this.custom_depress_text,r-e/2,h),l=e/2+this.render_options.text_margin_right}else ri("pedal_depress",t,r,h,g),l=20+this.render_options.text_margin_right;else l=c?-5:0,t.beginPath(),t.moveTo(e,i),t.lineTo(r+l,h),t.lineTo(r,h-this.render_options.bracket_height),t.stroke(),t.closePath();e=r+l,i=h}))}drawText(){const t=this.checkContext();let e=!1;this.notes.forEach((i=>{e=!e;const s=i.checkStave(),n=i.getAbsoluteX(),a=s.getYForBottomText(this.line+3),o=tt.currentMusicFont().lookupMetric(`pedalMarking.${e?"down":"up"}.point`);let r=0;e?this.custom_depress_text?(r=t.measureText(this.custom_depress_text).width,t.fillText(this.custom_depress_text,n-r/2,a)):ri("pedal_depress",t,n,a,o):this.custom_release_text?(r=t.measureText(this.custom_release_text).width,t.fillText(this.custom_release_text,n-r/2,a)):ri("pedal_release",t,n,a,o)}))}draw(){const t=this.checkContext();this.setRendered(),t.save(),t.setStrokeStyle(this.render_options.color),t.setFillStyle(this.render_options.color),t.setFont(this.textFont),function(...t){hi.DEBUG&&S("Vex.Flow.PedalMarking",t)}("Rendering Pedal Marking"),this.type===hi.type.BRACKET||this.type===hi.type.MIXED?(t.setLineWidth(this.render_options.bracket_line_width),this.drawBracketed()):this.type===hi.type.TEXT&&this.drawText(),t.restore()}}hi.DEBUG=!1,hi.TEXT_FONT={family:M.SERIF,size:12,weight:k.BOLD,style:D.ITALIC},hi.GLYPHS={pedal_depress:{code:"keyboardPedalPed",x_shift:-10,y_shift:0},pedal_release:{code:"keyboardPedalUp",x_shift:-2,y_shift:3}},hi.type={TEXT:1,BRACKET:2,MIXED:3},hi.typeString={text:hi.type.TEXT,bracket:hi.type.BRACKET,mixed:hi.type.MIXED};const ci={1:"repeat1Bar",2:"repeat2Bars",4:"repeat4Bars",slash:"repeatBarSlash"};class di extends ii{static get CATEGORY(){return m.RepeatNote}constructor(t,e,i){super(void 0,Object.assign({duration:"q",align_center:"slash"!==t},e),i);const s=new U(ci[t]||"repeat1Bar",tt.currentMusicFont().lookupMetric("repeatNote.point",40),{category:"repeatNote"});this.setGlyph(s)}}function li(t,e,i,s,n,a,o){t.beginPath(),t.moveTo(e,i),t.lineTo(s,n),t.lineTo(a,o),t.lineTo(e,i),t.closePath(),t.fill()}class gi extends O{constructor(t){super(),this.setNotes(t),this.text="",this.resetFont(),this.render_options={padding_left:4,padding_right:3,line_width:1,line_dash:void 0,rounded_end:!0,color:void 0,draw_start_arrow:!1,draw_end_arrow:!1,arrowhead_length:10,arrowhead_angle:Math.PI/8,text_position_vertical:gi.TextVerticalPosition.TOP,text_justification:gi.TextJustification.CENTER}}static get CATEGORY(){return m.StaveLine}setText(t){return this.text=t,this}setNotes(t){if(!t.first_note&&!t.last_note)throw new f("BadArguments","Notes needs to have either first_note or last_note set.");if(t.first_indices||(t.first_indices=[0]),t.last_indices||(t.last_indices=[0]),t.first_indices.length!==t.last_indices.length)throw new f("BadArguments","Connected notes must have same number of indices.");return this.notes=t,this.first_note=t.first_note,this.first_indices=t.first_indices,this.last_note=t.last_note,this.last_indices=t.last_indices,this}applyLineStyle(){const t=this.checkContext(),e=this.render_options;e.line_dash&&t.setLineDash(e.line_dash),e.line_width&&t.setLineWidth(e.line_width),e.rounded_end?t.setLineCap("round"):t.setLineCap("square")}applyFontStyle(){const t=this.checkContext();t.setFont(this.textFont);const e=this.render_options.color;e&&(t.setStrokeStyle(e),t.setFillStyle(e))}drawArrowLine(t,e,i){const s=this.render_options.draw_start_arrow&&this.render_options.draw_end_arrow,n=e.x,a=e.y,o=i.x,r=i.y,h=Math.sqrt((o-n)*(o-n)+(r-a)*(r-a)),c=(h-this.render_options.arrowhead_length/3)/h;let d,l,g,u;this.render_options.draw_end_arrow||s?(d=Math.round(n+(o-n)*c),l=Math.round(a+(r-a)*c)):(d=o,l=r),this.render_options.draw_start_arrow||s?(g=n+(o-n)*(1-c),u=a+(r-a)*(1-c)):(g=n,u=a),this.render_options.color&&(t.setStrokeStyle(this.render_options.color),t.setFillStyle(this.render_options.color)),t.beginPath(),t.moveTo(g,u),t.lineTo(d,l),t.stroke(),t.closePath();const p=Math.atan2(r-a,o-n),m=Math.abs(this.render_options.arrowhead_length/Math.cos(this.render_options.arrowhead_angle));let f,_,x,S,y,T;(this.render_options.draw_end_arrow||s)&&(f=p+Math.PI+this.render_options.arrowhead_angle,x=o+Math.cos(f)*m,S=r+Math.sin(f)*m,_=p+Math.PI-this.render_options.arrowhead_angle,y=o+Math.cos(_)*m,T=r+Math.sin(_)*m,li(t,x,S,o,r,y,T)),(this.render_options.draw_start_arrow||s)&&(f=p+this.render_options.arrowhead_angle,x=n+Math.cos(f)*m,S=a+Math.sin(f)*m,_=p-this.render_options.arrowhead_angle,y=n+Math.cos(_)*m,T=a+Math.sin(_)*m,li(t,x,S,n,a,y,T))}draw(){const t=this.checkContext();this.setRendered();const e=this.first_note,i=this.last_note,s=this.render_options;t.save(),this.applyLineStyle();let n={x:0,y:0},a={x:0,y:0};this.first_indices.forEach(((o,r)=>{const h=this.last_indices[r];n=e.getModifierStartXY(2,o),a=i.getModifierStartXY(1,h);const c=n.y>a.y;n.x+=e.getMetrics().modRightPx+s.padding_left,a.x-=i.getMetrics().modLeftPx+s.padding_right;const d=e.getGlyph().getWidth();e.getKeyProps()[o].displaced&&1===e.getStemDirection()&&(n.x+=d+s.padding_left);i.getKeyProps()[h].displaced&&-1===i.getStemDirection()&&(a.x-=d+s.padding_right),n.y+=c?-3:1,a.y+=c?2:0,this.drawArrowLine(t,n,a)})),t.restore();const o=t.measureText(this.text).width,r=s.text_justification;let h=0;if(r===gi.TextJustification.LEFT)h=n.x;else if(r===gi.TextJustification.CENTER){h=(a.x-n.x)/2+n.x-o/2}else r===gi.TextJustification.RIGHT&&(h=a.x-o);let c=0;const d=s.text_position_vertical;return d===gi.TextVerticalPosition.TOP?c=e.checkStave().getYForTopText():d===gi.TextVerticalPosition.BOTTOM&&(c=e.checkStave().getYForBottomText(tt.TEXT_HEIGHT_OFFSET_HACK)),t.save(),this.applyFontStyle(),t.fillText(this.text,h,c),t.restore(),this}}gi.TEXT_FONT=Object.assign({},O.TEXT_FONT),gi.TextVerticalPosition={TOP:1,BOTTOM:2},gi.TextJustification=ae;class ui extends O{constructor(t={}){super(),this.setOptions(t),this.parts=[]}static get CATEGORY(){return m.System}setOptions(t={}){if(!t.factory)throw new f("NoFactory","System.setOptions(options) requires a factory.");this.factory=t.factory,this.options=Object.assign(Object.assign({factory:this.factory,x:10,y:10,width:500,spaceBetweenStaves:12,autoWidth:!1,noJustification:!1,debugFormatter:!1,formatIterations:0,noPadding:!1},t),{details:Object.assign({alpha:.5},t.details),formatOptions:Object.assign({},t.formatOptions)}),!1===this.options.noJustification&&void 0===t.width&&(this.options.autoWidth=!0)}setContext(t){return super.setContext(t),this.factory.setContext(t),this}addConnector(t="double"){return this.connector=this.factory.StaveConnector({top_stave:this.parts[0].stave,bottom_stave:this.parts[this.parts.length-1].stave,type:t}),this.connector}addStave(t){var e;const i=Object.assign({left_bar:!1},t.options),s=null!==(e=t.stave)&&void 0!==e?e:this.factory.Stave({x:this.options.x,y:this.options.y,width:this.options.width,options:i}),n=Object.assign(Object.assign({stave:s,spaceAbove:0,spaceBelow:0,debugNoteMetrics:!1,noJustification:!1},t),{options:i}),a=this.getContext();return n.voices.forEach((t=>t.setContext(a).setStave(s).getTickables().forEach((t=>t.setStave(s))))),this.parts.push(n),s}format(){const t=this.options.details;let e=0;const i=new Pe(t);this.formatter=i;let s=this.options.y,n=0,a=[];const o=[];this.parts.forEach((t=>{s+=t.stave.space(t.spaceAbove),t.stave.setY(s),i.joinVoices(t.voices),s+=t.stave.space(t.spaceBelow),s+=t.stave.space(this.options.spaceBetweenStaves),t.debugNoteMetrics&&(o.push({y:s,voice:t.voices[0]}),s+=15),a=a.concat(t.voices),n=Math.max(n,t.stave.getNoteStartX())})),this.parts.forEach((t=>t.stave.setNoteStartX(n))),this.options.autoWidth?(e=i.preCalculateMinTotalWidth(a),this.parts.forEach((t=>{t.stave.setWidth(e+Ee.rightPadding+(n-this.options.x))}))):e=this.options.noPadding?this.options.width-this.options.x:this.options.width-(n-this.options.x)-Ee.defaultPadding,i.format(a,this.options.noJustification?0:e,this.options.formatOptions);for(let e=0;e<this.options.formatIterations;e++)i.tune(t);this.startX=n,this.debugNoteMetricsYs=o,this.lastY=s,this.boundingBox=new C(this.options.x,this.options.y,this.options.width,this.lastY-this.options.y)}draw(){const t=this.checkContext();if(!(this.formatter&&this.startX&&this.lastY&&this.debugNoteMetricsYs))throw new f("NoFormatter","format() must be called before draw()");this.setRendered(),this.options.debugFormatter&&Pe.plotDebugging(t,this.formatter,this.startX,this.options.y,this.lastY),this.debugNoteMetricsYs.forEach((e=>{e.voice.getTickables().forEach((i=>bt.plotMetrics(t,i,e.y)))}))}}class pi extends zt{constructor(t,e=!1){super(t),this.glyphs=[],this.greatestString=()=>this.positions.map((t=>t.str)).reduce(((t,e)=>t>e?t:e)),this.leastString=()=>this.positions.map((t=>t.str)).reduce(((t,e)=>t<e?t:e)),this.ghost=!1,this.positions=t.positions||[],this.render_options=Object.assign(Object.assign({},this.render_options),{glyph_font_scale:tt.TABLATURE_FONT_SCALE,draw_stem:e,draw_dots:e,draw_stem_through_stave:!1,y_shift:0,scale:1,font:`${M.SIZE}pt ${M.SANS_SERIF}`}),this.glyph=tt.getGlyphProps(this.duration,this.noteType),x(this.glyph,"BadArguments",`No glyph found for duration '${this.duration}' and type '${this.noteType}'`),this.buildStem(),t.stem_direction?this.setStemDirection(t.stem_direction):this.setStemDirection(nt.UP),this.ghost=!1,this.updateWidth()}static get CATEGORY(){return m.TabNote}reset(){return super.reset(),this.stave&&this.setStave(this.stave),this}setGhost(t){return this.ghost=t,this.updateWidth(),this}hasStem(){return!!this.render_options.draw_stem}getStemExtension(){const t=this.getGlyph();return null!=this.stem_extension_override?this.stem_extension_override:t?this.getStemDirection()===nt.UP?t.tabnote_stem_up_extension:t.tabnote_stem_down_extension:0}updateWidth(){this.glyphs=[],this.width=0;for(let t=0;t<this.positions.length;++t){let e=this.positions[t].fret;this.ghost&&(e="("+e+")");const i=tt.tabToGlyph(e.toString(),this.render_options.scale);this.glyphs.push(i),this.width=Math.max(i.getWidth(),this.width)}this.glyph.getWidth=()=>this.width}setStave(t){super.setStave(t);const e=t.getContext();if(this.setContext(e),e){this.width=0;for(let t=0;t<this.glyphs.length;++t){const i=this.glyphs[t],s=""+i.text;"X"!==s.toUpperCase()&&(e.save(),e.setFont(this.render_options.font),i.width=e.measureText(s).width,e.restore(),i.getWidth=()=>i.width),this.width=Math.max(i.getWidth(),this.width)}this.glyph.getWidth=()=>this.width}const i=this.positions.map((({str:e})=>t.getYForLine(Number(e)-1)));return this.setYs(i),this.stem&&this.stem.setYBounds(this.getStemY(),this.getStemY()),this}getPositions(){return this.positions}getModifierStartXY(t,e){if(!this.preFormatted)throw new f("UnformattedNote","Can't call GetModifierStartXY on an unformatted note");if(0===this.ys.length)throw new f("NoYValues","No Y-Values calculated for this note.");let i=0;if(t===H.Position.LEFT)i=-2;else if(t===H.Position.RIGHT)i=this.width+2;else if(t===H.Position.BELOW||t===H.Position.ABOVE){i=this.glyph.getWidth()/2}return{x:this.getAbsoluteX()+i,y:this.ys[e]}}getLineForRest(){return Number(this.positions[0].str)}preFormat(){this.preFormatted||(this.modifierContext&&this.modifierContext.preFormat(),this.preFormatted=!0)}getStemX(){return this.getCenterGlyphX()}getStemY(){const t=this.checkStave().getNumLines()-.5,e=nt.UP===this.stem_direction?-.5:t;return this.checkStave().getYForLine(e)}getStemExtents(){return this.checkStem().getExtents()}drawFlag(){var t;const{beam:e,glyph:i,render_options:{draw_stem:s}}=this,n=this.checkContext(),a=null==e&&s;if(i.flag&&a){const e=this.getStemX(),i=this.getStemDirection()===nt.DOWN?this.getStemY()-this.checkStem().getHeight()-(this.glyph?this.glyph.stem_down_extension:0):this.getStemY()-this.checkStem().getHeight()+(this.glyph?this.glyph.stem_up_extension:0);null===(t=this.flag)||void 0===t||t.render(n,e,i)}}drawModifiers(){this.modifiers.forEach((t=>{r(t)&&!this.render_options.draw_dots||(t.setContext(this.getContext()),t.drawWithStyle())}))}drawStemThrough(){const t=this.getStemX(),e=this.getStemY(),i=this.checkContext(),s=this.render_options.draw_stem,n=this.render_options.draw_stem_through_stave;if(s&&n){const s=function(t,e,i,s){const n=1!==s,a=-1!==s,o=i.getSpacingBetweenLines(),r=i.getNumLines(),h=[];return e.forEach((e=>{const c=e.indexOf(r)>-1,d=e.indexOf(1)>-1;if(n&&d||a&&c)return;1===e.length&&e.push(e[0]);const l=[];e.forEach(((e,n,a)=>{const h=1===e,c=e===r;let d=i.getYForLine(e-1);0!==n||h?n!==a.length-1||c||(d+=o/2-1):d-=o/2-1,l.push(d),1===s&&h?l.push(t-2):-1===s&&c&&l.push(t+2)})),h.push(l.sort(((t,e)=>t-e)))})),h}(e,function(t,e){const i=[];let s=[];for(let n=1;n<=t;n++)e.indexOf(n)>-1?(i.push(s),s=[]):s.push(n);return s.length>0&&i.push(s),i}(this.checkStave().getNumLines(),this.positions.map((t=>Number(t.str)))),this.checkStave(),this.getStemDirection());i.save(),i.setLineWidth(nt.WIDTH),s.forEach((e=>{0!==e.length&&(i.beginPath(),i.moveTo(t,e[0]),i.lineTo(t,e[e.length-1]),i.stroke(),i.closePath())})),i.restore()}}drawPositions(){const t=this.checkContext(),e=this.getAbsoluteX(),i=this.ys;for(let s=0;s<this.positions.length;++s){const n=i[s]+this.render_options.y_shift,a=this.glyphs[s],o=e+this.glyph.getWidth()/2-a.getWidth()/2;if(t.clearRect(o-2,n-3,a.getWidth()+4,6),a.code)U.renderGlyph(t,o,n,this.render_options.glyph_font_scale*this.render_options.scale,a.code);else{t.save(),t.setFont(this.render_options.font);const e=a.text.toString();t.fillText(e,o,n+5*this.render_options.scale),t.restore()}}}draw(){const t=this.checkContext();if(0===this.ys.length)throw new f("NoYValues","Can't draw note without Y values.");this.setRendered();const e=null==this.beam&&this.render_options.draw_stem;if(t.openGroup("tabnote",void 0,{pointerBBox:!0}),this.drawPositions(),this.drawStemThrough(),this.stem&&e){const e=this.getStemX();this.stem.setNoteHeadXBounds(e,e),t.openGroup("stem",void 0,{pointerBBox:!0}),this.stem.setContext(t).draw(),t.closeGroup()}this.drawFlag(),this.drawModifiers(),t.closeGroup()}}class mi extends Ee{static get CATEGORY(){return m.TabStave}constructor(t,e,i,s){super(t,e,i,Object.assign({spacing_between_lines_px:13,num_lines:6,top_text_position:1},s))}getYForGlyphs(){return this.getYForLine(2.5)}addTabGlyph(){return this.addClef("tab"),this}}function fi(...t){xi.DEBUG&&S("Vex.Flow.TextBracket",t)}var _i;!function(t){t[t.TOP=1]="TOP",t[t.BOTTOM=-1]="BOTTOM"}(_i||(_i={}));class xi extends O{constructor({start:t,stop:e,text:i="",superscript:s="",position:n=_i.TOP}){super(),this.start=t,this.stop=e,this.text=i,this.superscript=s,this.position="string"==typeof n?xi.PositionString[n]:n,this.line=1,this.resetFont(),this.render_options={dashed:!0,dash:[5],color:"black",line_width:1,show_bracket:!0,bracket_height:8,underline_superscript:!0}}static get CATEGORY(){return m.TextBracket}static get Position(){return _i}static get PositionString(){return{top:_i.TOP,bottom:_i.BOTTOM}}static get Positions(){return fi("Positions is deprecated, use TextBracketPosition instead."),_i}static get PositionsString(){return fi("PositionsString is deprecated, use PositionString instead."),xi.PositionString}applyStyle(t){t.setFont(this.font);const e=this.render_options;return t.setStrokeStyle(e.color),t.setFillStyle(e.color),t.setLineWidth(e.line_width),this}setDashed(t,e){return this.render_options.dashed=t,e&&(this.render_options.dash=e),this}setLine(t){return this.line=t,this}draw(){const t=this.checkContext();this.setRendered();let e=0;switch(this.position){case _i.TOP:e=this.start.checkStave().getYForTopText(this.line);break;case _i.BOTTOM:e=this.start.checkStave().getYForBottomText(this.line+tt.TEXT_HEIGHT_OFFSET_HACK);break;default:throw new f("InvalidPosition",`The position ${this.position} is invalid.`)}const i={x:this.start.getAbsoluteX(),y:e},s={x:this.stop.getAbsoluteX(),y:e};fi("Rendering TextBracket: start:",i,"stop:",s,"y:",e);const n=this.render_options.bracket_height*this.position;t.save(),this.applyStyle(t),t.fillText(this.text,i.x,i.y);const a=t.measureText(this.text),o=a.width,r=a.height,h=i.y-r/2.5,{family:c,size:d,weight:l,style:g}=this.textFont,u=M.scaleSize(d,.714286);t.setFont(c,u,l,g),t.fillText(this.superscript,i.x+o+1,h);const p=t.measureText(this.superscript),m=p.width,_=p.height;let x=i.x,S=h;const y=s.x+this.stop.getGlyph().getWidth();this.position===_i.TOP?(x+=o+m+5,S-=_/2.7):this.position===_i.BOTTOM&&(S+=_/2.7,x+=o+2,this.render_options.underline_superscript||(x+=m)),this.render_options.dashed?(re.drawDashedLine(t,x,S,y,S,this.render_options.dash),this.render_options.show_bracket&&re.drawDashedLine(t,y,S+1*this.position,y,S+n,this.render_options.dash)):(t.beginPath(),t.moveTo(x,S),t.lineTo(y,S),this.render_options.show_bracket&&t.lineTo(y,S+n),t.stroke(),t.closePath()),t.restore()}}function Si(...t){yi.DEBUG&&S("Vex.Flow.TextDynamics",t)}xi.DEBUG=!1,xi.TEXT_FONT={family:M.SERIF,size:15,weight:k.NORMAL,style:D.ITALIC};class yi extends bt{constructor(t){super(t),this.sequence=(t.text||"").toLowerCase(),this.line=t.line||0,this.glyphs=[],this.render_options=Object.assign(Object.assign({},this.render_options),{glyph_font_size:40}),Si("New Dynamics Text: ",this.sequence)}static get CATEGORY(){return m.TextDynamics}static get GLYPHS(){return{f:{code:"dynamicForte",width:12},p:{code:"dynamicPiano",width:14},m:{code:"dynamicMezzo",width:17},s:{code:"dynamicSforzando",width:10},z:{code:"dynamicZ",width:12},r:{code:"dynamicRinforzando",width:12}}}setLine(t){return this.line=t,this}preFormat(){let t=0;return this.glyphs=[],this.sequence.split("").forEach((e=>{const i=yi.GLYPHS[e];if(!i)throw new f("Invalid dynamics character: "+e);const s=x(this.render_options.glyph_font_size),n=new U(i.code,s,{category:"textNote"});this.glyphs.push(n),t+=i.width})),this.setWidth(t),this.preFormatted=!0,this}draw(){this.setRendered();const t=this.getAbsoluteX(),e=this.checkStave().getYForLine(this.line+-3);Si("Rendering Dynamics: ",this.sequence);let i=t;this.glyphs.forEach(((t,s)=>{const n=this.sequence[s];t.render(this.checkContext(),i,e),i+=yi.GLYPHS[n].width}))}}yi.DEBUG=!1;class Ti extends bt{constructor(t,e){super({duration:"b"});const i=new be(t,e);this.timeSigInfo=i.getInfo(),this.setWidth(this.timeSigInfo.glyph.getMetrics().width),this.ignore_ticks=!0}static get CATEGORY(){return m.TimeSigNote}addToModifierContext(t){return this}preFormat(){return this.preFormatted=!0,this}draw(){const t=this.checkStave(),e=this.checkContext();this.setRendered(),this.timeSigInfo.glyph.getContext()||this.timeSigInfo.glyph.setContext(e),this.timeSigInfo.glyph.setStave(t),this.timeSigInfo.glyph.setYShift(t.getYForLine(2)-t.getYForGlyphs()),this.timeSigInfo.glyph.renderToStave(this.getAbsoluteX())}}class bi extends O{constructor(t){super(),t.start&&(this.start=t.start),t.stop&&(this.stop=t.stop),this.line=1,this.render_options={harsh:!1,wave_height:6,wave_width:4,wave_girth:2,vibrato_width:0}}static get CATEGORY(){return m.VibratoBracket}setLine(t){return this.line=t,this}setHarsh(t){return this.render_options.harsh=t,this}draw(){const t=this.checkContext();this.setRendered();const e=this.start&&this.start.checkStave().getYForTopText(this.line)||this.stop&&this.stop.checkStave().getYForTopText(this.line)||0,i=this.start&&this.start.getAbsoluteX()||this.stop&&this.stop.checkStave().getTieStartX()||0,s=this.stop&&this.stop.getAbsoluteX()-this.stop.getWidth()-5||this.start&&this.start.checkStave().getTieEndX()-10||0;this.render_options.vibrato_width=s-i,function(...t){bi.DEBUG&&S("Vex.Flow.VibratoBracket",t)}("Rendering VibratoBracket: start_x:",i,"stop_x:",s,"y:",e),de.renderVibrato(t,i,e,this.render_options)}}function wi(...t){vi.DEBUG&&S("Vex.Flow.Factory",t)}bi.DEBUG=!1;class vi{constructor(t={}){wi("New factory: ",t),this.options={stave:{space:10},renderer:{elementId:"",width:500,height:200,background:"#FFF"},font:vi.TEXT_FONT},this.setOptions(t)}static newFromElementId(t,e=500,i=200){return new vi({renderer:{elementId:t,width:e,height:i}})}reset(){this.renderQ=[],this.systems=[],this.staves=[],this.voices=[],this.stave=void 0}setOptions(t){this.options=Object.assign(Object.assign({},this.options),t),this.initRenderer(),this.reset()}initRenderer(){const{elementId:t,width:e,height:i,background:s}=this.options.renderer;if(null==t)return;if(""==t)throw wi(this),new f("renderer.elementId not set in FactoryOptions");let n=this.options.renderer.backend;if(void 0===n){n=Jt(document.getElementById(t))?re.Backends.CANVAS:re.Backends.SVG}this.context=re.buildContext(t,n,e,i,s)}getContext(){return this.context}setContext(t){return this.context=t,this}getStave(){return this.stave}getVoices(){return this.voices}Stave(t){const e=this.options.stave.space,i=Object.assign({x:0,y:0,width:this.options.renderer.width-1*e,options:{spacing_between_lines_px:1*e}},t),s=new Ee(i.x,i.y,i.width,i.options);return this.staves.push(s),s.setContext(this.context),this.stave=s,s}TabStave(t){const e=this.options.stave.space,i=Object.assign({x:0,y:0,width:this.options.renderer.width-1*e,options:{spacing_between_lines_px:1.3*e}},t),s=new mi(i.x,i.y,i.width,i.options);return this.staves.push(s),s.setContext(this.context),this.stave=s,s}StaveNote(t){const e=new $t(t);return this.stave&&e.setStave(this.stave),e.setContext(this.context),this.renderQ.push(e),e}GlyphNote(t,e,i){const s=new ii(t,e,i);return this.stave&&s.setStave(this.stave),s.setContext(this.context),this.renderQ.push(s),s}RepeatNote(t,e,i){const s=new di(t,e,i);return this.stave&&s.setStave(this.stave),s.setContext(this.context),this.renderQ.push(s),s}GhostNote(t){const e=new ei(t);return this.stave&&e.setStave(this.stave),e.setContext(this.context),this.renderQ.push(e),e}TextNote(t){const e=new xe(t);return this.stave&&e.setStave(this.stave),e.setContext(this.context),this.renderQ.push(e),e}BarNote(t={}){const e=new Ft(t.type);return this.stave&&e.setStave(this.stave),e.setContext(this.context),this.renderQ.push(e),e}ClefNote(t){const e=Object.assign({type:"treble",options:{size:"default",annotation:void 0}},t),i=new We(e.type,e.options.size,e.options.annotation);return this.stave&&i.setStave(this.stave),i.setContext(this.context),this.renderQ.push(i),i}TimeSigNote(t){const e=Object.assign({time:"4/4"},t),i=new Ti(e.time);return this.stave&&i.setStave(this.stave),i.setContext(this.context),this.renderQ.push(i),i}KeySigNote(t){const e=new ni(t.key,t.cancelKey,t.alterKey);return this.stave&&e.setStave(this.stave),e.setContext(this.context),this.renderQ.push(e),e}TabNote(t){const e=new pi(t);return this.stave&&e.setStave(this.stave),e.setContext(this.context),this.renderQ.push(e),e}GraceNote(t){const e=new si(t);return this.stave&&e.setStave(this.stave),e.setContext(this.context),e}GraceNoteGroup(t){const e=new Ut(t.notes,t.slur);return e.setContext(this.context),e}Accidental(t){const e=new st(t.type);return e.setContext(this.context),e}Annotation(t){const e=Object.assign({text:"p",hJustify:ct.CENTER,vJustify:dt.BOTTOM},t),i=new lt(e.text);return i.setJustification(e.hJustify),i.setVerticalJustification(e.vJustify),i.setFont(e.font),i.setContext(this.context),i}ChordSymbol(t){const e=Object.assign({vJustify:"top",hJustify:"center",kerning:!0,reportWidth:!0},t),i=new Rt;return i.setHorizontal(e.hJustify),i.setVertical(e.vJustify),i.setEnableKerning(e.kerning),i.setReportWidth(e.reportWidth),"string"==typeof e.fontFamily&&"number"==typeof e.fontSize?"string"==typeof e.fontWeight?i.setFont(e.fontFamily,e.fontSize,e.fontWeight):i.setFont(e.fontFamily,e.fontSize,""):"number"==typeof e.fontSize&&i.setFontSize(e.fontSize),i.setContext(this.context),i}Articulation(t){const e=Object.assign({type:"a.",position:"above"},t),i=new xt(e.type);return i.setPosition(e.position),i.setContext(this.context),i}TextDynamics(t){const e=Object.assign({text:"p",duration:"q",dots:0,line:0},t),i=new yi({text:e.text,line:e.line,duration:e.duration,dots:e.dots});return this.stave&&i.setStave(this.stave),i.setContext(this.context),this.renderQ.push(i),i}Fingering(t){const e=Object.assign({number:"0",position:"left"},t),i=new Lt(e.number);return i.setPosition(e.position),i.setContext(this.context),i}StringNumber(t){const e=new he(t.number);return e.setPosition(t.position),e.setContext(this.context),e}TickContext(){return new Yt}ModifierContext(){return new ge}MultiMeasureRest(t){const e=x(t.number_of_measures,"NoNumberOfMeasures"),i=new oi(e,t);return i.setContext(this.context),this.renderQ.push(i),i}Voice(t){const e=Object.assign({time:"4/4"},t),i=new Gt(e.time,e.options);return this.voices.push(i),i}StaveConnector(t){const e=new Ne(t.top_stave,t.bottom_stave);return e.setType(t.type).setContext(this.context),this.renderQ.push(e),e}Formatter(t){return new Pe(t)}Tuplet(t){const e=Object.assign({notes:[],options:{}},t),i=new Me(e.notes,e.options).setContext(this.context);return this.renderQ.push(i),i}Beam(t){var e,i,s,n,a;const o=new Ie(t.notes,null===(e=t.options)||void 0===e?void 0:e.autoStem).setContext(this.context);return o.breakSecondaryAt(null!==(s=null===(i=t.options)||void 0===i?void 0:i.secondaryBeamBreaks)&&void 0!==s?s:[]),(null===(n=t.options)||void 0===n?void 0:n.partialBeamDirections)&&Object.entries(null===(a=t.options)||void 0===a?void 0:a.partialBeamDirections).forEach((([t,e])=>{o.setPartialBeamSideAt(Number(t),e)})),this.renderQ.push(o),o}Curve(t){const e=new He(t.from,t.to,t.options).setContext(this.context);return this.renderQ.push(e),e}StaveTie(t){var e;const i=new It({first_note:t.from,last_note:t.to,first_indices:t.first_indices,last_indices:t.last_indices},t.text);return(null===(e=t.options)||void 0===e?void 0:e.direction)&&i.setDirection(t.options.direction),i.setContext(this.context),this.renderQ.push(i),i}StaveLine(t){var e,i;const s=new gi({first_note:t.from,last_note:t.to,first_indices:t.first_indices,last_indices:t.last_indices});return(null===(e=t.options)||void 0===e?void 0:e.text)&&s.setText(t.options.text),(null===(i=t.options)||void 0===i?void 0:i.font)&&s.setFont(t.options.font),s.setContext(this.context),this.renderQ.push(s),s}VibratoBracket(t){const e=new bi({start:t.from,stop:t.to});return t.options.line&&e.setLine(t.options.line),t.options.harsh&&e.setHarsh(t.options.harsh),e.setContext(this.context),this.renderQ.push(e),e}TextBracket(t){const e=new xi({start:t.from,stop:t.to,text:t.text,superscript:t.options.superscript,position:t.options.position});return t.options.line&&e.setLine(t.options.line),t.options.font&&e.setFont(t.options.font),e.setContext(this.context),this.renderQ.push(e),e}System(t={}){t.factory=this;const e=new ui(t).setContext(this.context);return this.systems.push(e),e}EasyScore(t={}){return t.factory=this,new Ze(t)}PedalMarking(t){const e=Object.assign({notes:[],options:{style:"mixed"}},t),i=new hi(e.notes);return i.setType(hi.typeString[e.options.style]),i.setContext(this.context),this.renderQ.push(i),i}NoteSubGroup(t){const e=Object.assign({notes:[]},t),i=new Ht(e.notes);return i.setContext(this.context),i}draw(){const t=this.context;this.systems.forEach((e=>e.setContext(t).format())),this.staves.forEach((e=>e.setContext(t).draw())),this.voices.forEach((e=>e.setContext(t).draw())),this.renderQ.forEach((e=>{e.isRendered()||e.setContext(t).draw()})),this.systems.forEach((e=>e.setContext(t).draw())),this.reset()}}vi.DEBUG=!1,vi.TEXT_FONT=Object.assign({},O.TEXT_FONT);class Ei extends pi{static get CATEGORY(){return m.GraceTabNote}constructor(t){super(t,!1),this.render_options=Object.assign(Object.assign({},this.render_options),{y_shift:.3,scale:.6,font:`7.5pt ${M.SANS_SERIF}`}),this.updateWidth()}}class Ci{constructor(t){this.music=new Y,this.setKey(t)}setKey(t){return this.key=t,this.reset(),this}getKey(){return this.key}reset(){this.keyParts=this.music.getKeyParts(this.key),this.keyString=this.keyParts.root,this.keyParts.accidental&&(this.keyString+=this.keyParts.accidental);if(!Y.scaleTypes[this.keyParts.type])throw new f("BadArguments",`Unsupported key type: ${this.key}`);this.scale=this.music.getScaleTones(this.music.getNoteValue(this.keyString),Y.scaleTypes[this.keyParts.type]),this.scaleMap={},this.scaleMapByValue={},this.originalScaleMapByValue={};const t=Y.root_indices[this.keyParts.root];for(let e=0;e<Y.roots.length;++e){const i=(t+e)%Y.roots.length,s=Y.roots[i],n=this.music.getRelativeNoteName(s,this.scale[e]);this.scaleMap[s]=n,this.scaleMapByValue[this.scale[e]]=n,this.originalScaleMapByValue[this.scale[e]]=n}return this}getAccidental(t){const e=this.music.getKeyParts(t).root,i=this.music.getNoteParts(this.scaleMap[e]);return{note:this.scaleMap[e],accidental:i.accidental}}selectNote(t){t=t.toLowerCase();const e=this.music.getNoteParts(t),i=this.scaleMap[e.root],s=this.music.getNoteParts(i);if(i===t)return{note:i,accidental:e.accidental,change:!1};const n=this.scaleMapByValue[this.music.getNoteValue(t)];if(null!=n)return{note:n,accidental:this.music.getNoteParts(n).accidental,change:!1};const a=this.originalScaleMapByValue[this.music.getNoteValue(t)];return null!=a?(this.scaleMap[s.root]=a,delete this.scaleMapByValue[this.music.getNoteValue(i)],this.scaleMapByValue[this.music.getNoteValue(t)]=a,{note:a,accidental:this.music.getNoteParts(a).accidental,change:!0}):s.root===t?(delete this.scaleMapByValue[this.music.getNoteValue(this.scaleMap[e.root])],this.scaleMapByValue[this.music.getNoteValue(s.root)]=s.root,this.scaleMap[s.root]=s.root,{note:s.root,accidental:void 0,change:!0}):(delete this.scaleMapByValue[this.music.getNoteValue(this.scaleMap[e.root])],this.scaleMapByValue[this.music.getNoteValue(t)]=t,delete this.scaleMap[s.root],this.scaleMap[s.root]=t,{note:t,accidental:e.accidental,change:!0})}}class Ni extends O{constructor(t,e){super(),this.setNotes(t),this.hairpin=e,this.position=H.Position.BELOW,this.render_options={height:10,y_shift:0,left_shift_px:0,right_shift_px:0,right_shift_ticks:0,left_shift_ticks:0}}static get CATEGORY(){return m.StaveHairpin}static FormatByTicksAndDraw(t,e,i,s,n,a){var o,r;const h=e.pixelsPerTick;if(null==h)throw new f("BadArguments","A valid Formatter must be provide to draw offsets by ticks.");const c=h*(null!==(o=a.left_shift_ticks)&&void 0!==o?o:0),d=h*(null!==(r=a.right_shift_ticks)&&void 0!==r?r:0),l={height:a.height,y_shift:a.y_shift,left_shift_px:c,right_shift_px:d,right_shift_ticks:0,left_shift_ticks:0};new Ni({first_note:i.first_note,last_note:i.last_note},s).setContext(t).setRenderOptions(l).setPosition(n).draw()}setPosition(t){return t!==H.Position.ABOVE&&t!==H.Position.BELOW||(this.position=t),this}setRenderOptions(t){return null!=t.height&&null!=t.y_shift&&null!=t.left_shift_px&&null!=t.right_shift_px&&(this.render_options=t),this}setNotes(t){if(!t.first_note&&!t.last_note)throw new f("BadArguments","Hairpin needs to have either first_note or last_note set.");return this.notes=t,this.first_note=t.first_note,this.last_note=t.last_note,this}renderHairpin(t){const e=this.checkContext();let i=this.render_options.y_shift+20,s=t.first_y;this.position===H.Position.ABOVE&&(i=30-i,s=t.first_y-t.staff_height);const n=this.render_options.left_shift_px,a=this.render_options.right_shift_px;switch(e.beginPath(),this.hairpin){case Ni.type.CRESC:e.moveTo(t.last_x+a,s+i),e.lineTo(t.first_x+n,s+this.render_options.height/2+i),e.lineTo(t.last_x+a,s+this.render_options.height+i);break;case Ni.type.DECRESC:e.moveTo(t.first_x+n,s+i),e.lineTo(t.last_x+a,s+this.render_options.height/2+i),e.lineTo(t.first_x+n,s+this.render_options.height+i)}e.stroke(),e.closePath()}draw(){this.checkContext(),this.setRendered();const t=this.first_note,e=this.last_note;if(!t||!e)throw new f("NoNote","Notes required to draw");const i=t.getModifierStartXY(this.position,0),s=e.getModifierStartXY(this.position,0);this.renderHairpin({first_x:i.x,last_x:s.x,first_y:t.checkStave().getY()+t.checkStave().getHeight(),last_y:e.checkStave().getY()+e.checkStave().getHeight(),staff_height:t.checkStave().getHeight()})}}Ni.type={CRESC:1,DECRESC:2};class ki extends Wt{constructor(t,e){if(super(t,"sl."),!e){let i=t.first_note.getPositions()[0].fret;"string"==typeof i&&(i=parseInt(i,10));let s=t.last_note.getPositions()[0].fret;"string"==typeof s&&(s=parseInt(s,10)),e=isNaN(i)||isNaN(s)?ki.SLIDE_UP:i>s?ki.SLIDE_DOWN:ki.SLIDE_UP}this.direction=e,this.render_options.cp1=11,this.render_options.cp2=14,this.render_options.y_shift=.5,this.resetFont()}static get CATEGORY(){return m.TabSlide}static get SLIDE_UP(){return 1}static get SLIDE_DOWN(){return-1}static createSlideUp(t){return new ki(t,ki.SLIDE_UP)}static createSlideDown(t){return new ki(t,ki.SLIDE_DOWN)}renderTie(t){if(0===t.first_ys.length||0===t.last_ys.length)throw new f("BadArguments","No Y-values to render");const e=this.checkContext(),i=t.first_x_px,s=t.first_ys,n=t.last_x_px,a=t.direction;if(a!==ki.SLIDE_UP&&a!==ki.SLIDE_DOWN)throw new f("BadSlide","Invalid slide direction");const o=this.notes.first_indices;for(let t=0;t<o.length;++t){const r=s[o[t]]+this.render_options.y_shift;if(isNaN(r))throw new f("BadArguments","Bad indices for slide rendering.");e.beginPath(),e.moveTo(i,r+3*a),e.lineTo(n,r-3*a),e.closePath(),e.stroke()}this.setRendered()}}ki.TEXT_FONT={family:M.SERIF,size:10,weight:k.BOLD,style:D.ITALIC};class Di extends H{constructor(t){super(),this.num=t,this.position=H.Position.CENTER,this.code="tremolo1",this.y_spacing_scale=1,this.extra_stroke_scale=1}static get CATEGORY(){return m.Tremolo}draw(){const t=this.checkContext(),e=this.checkAttachedNote();this.setRendered();const i=e.getStemDirection();let s=e.getModifierStartXY(this.position,this.index).x;const n=h(e),a=n?si.SCALE:1,o="tremolo."+(n?"grace":"default"),r=tt.currentMusicFont();let c=r.lookupMetric(`${o}.spacing`)*i;c*=this.y_spacing_scale;const d=this.num*c;let l=e.getStemExtents().baseY-d;l+=i<0?r.lookupMetric(`${o}.offsetYStemDown`)*a:r.lookupMetric(`${o}.offsetYStemUp`)*a;const g=r.lookupMetric(`${o}.point`);s+=r.lookupMetric(`${o}.offsetXStem${i===nt.UP?"Up":"Down"}`);for(let e=0;e<this.num;++e)U.renderGlyph(t,s,l,g,this.code,{category:o,scale:this.extra_stroke_scale}),l+=c}}class Ai{constructor(t="E/5,B/4,G/4,D/4,A/3,E/3,B/2,E/2"){this.tuningValues=[],this.setTuning(t)}static get names(){return{standard:"E/5,B/4,G/4,D/4,A/3,E/3",dagdad:"D/5,A/4,G/4,D/4,A/3,D/3",dropd:"E/5,B/4,G/4,D/4,A/3,D/3",eb:"Eb/5,Bb/4,Gb/4,Db/4,Ab/3,Db/3",standardBanjo:"D/5,B/4,G/4,D/4,G/5"}}noteToInteger(t){return tt.keyProperties(t).int_value}setTuning(t){Ai.names[t]&&(t=Ai.names[t]),this.tuningValues=[];const e=t.split(/\s*,\s*/);if(0===e.length)throw new f("BadArguments",`Invalid tuning string: ${t}`);for(let t=0;t<e.length;++t)this.tuningValues[t]=this.noteToInteger(e[t])}getValueForString(t){const e=Number(t);if(e<1||e>this.tuningValues.length)throw new f("BadArguments",`String number must be between 1 and ${this.tuningValues.length}:${t}`);return this.tuningValues[e-1]}getValueForFret(t,e){const i=this.getValueForString(e),s=Number(t);if(s<0)throw new f("BadArguments",`Fret number must be 0 or higher: ${t}`);return i+s}getNoteForFret(t,e){const i=this.getValueForFret(t,e),s=Math.floor(i/12),n=i%12;return`${tt.integerToNote(n)}/${s}`}}var Pi=function(t,e,i,s){return new(i||(i=Promise))((function(n,a){function o(t){try{h(s.next(t))}catch(t){a(t)}}function r(t){try{h(s.throw(t))}catch(t){a(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,r)}h((s=s.apply(t,e||[])).next())}))};class Fi{static get BUILD(){return{VERSION:"4.0.1",ID:"409af72ce03dd6da1919ee6c7de72c62aac0644e",DATE:"2022-03-24T20:35:28.447Z"}}static setMusicFont(...t){const e=t.map((t=>M.load(t)));return tt.MUSIC_FONT_STACK=e,U.MUSIC_FONT_STACK=e.slice(),U.CURRENT_CACHE_KEY=t.join(","),e}static fetchMusicFont(t,e){return Pi(this,void 0,void 0,(function*(){}))}static getMusicFont(){return tt.MUSIC_FONT_STACK.map((t=>t.getName()))}static get NOTATION_FONT_SCALE(){return tt.NOTATION_FONT_SCALE}static set NOTATION_FONT_SCALE(t){tt.NOTATION_FONT_SCALE=t}static get TABLATURE_FONT_SCALE(){return tt.TABLATURE_FONT_SCALE}static set TABLATURE_FONT_SCALE(t){tt.TABLATURE_FONT_SCALE=t}static get RESOLUTION(){return tt.RESOLUTION}static set RESOLUTION(t){tt.RESOLUTION=t}static get SLASH_NOTEHEAD_WIDTH(){return tt.SLASH_NOTEHEAD_WIDTH}static set SLASH_NOTEHEAD_WIDTH(t){tt.SLASH_NOTEHEAD_WIDTH=t}static get STAVE_LINE_DISTANCE(){return tt.STAVE_LINE_DISTANCE}static set STAVE_LINE_DISTANCE(t){tt.STAVE_LINE_DISTANCE=t}static get STAVE_LINE_THICKNESS(){return tt.STAVE_LINE_THICKNESS}static set STAVE_LINE_THICKNESS(t){tt.STAVE_LINE_THICKNESS=t}static get STEM_HEIGHT(){return tt.STEM_HEIGHT}static set STEM_HEIGHT(t){tt.STEM_HEIGHT=t}static get STEM_WIDTH(){return tt.STEM_WIDTH}static set STEM_WIDTH(t){tt.STEM_WIDTH=t}static get TIME4_4(){return tt.TIME4_4}static get accidentalMap(){return tt.accidentalMap}static get unicode(){return tt.unicode}static keySignature(t){return tt.keySignature(t)}static hasKeySignature(t){return tt.hasKeySignature(t)}static getKeySignatures(){return tt.getKeySignatures()}static clefProperties(t){return tt.clefProperties(t)}static keyProperties(t,e,i){return tt.keyProperties(t,e,i)}static durationToTicks(t){return tt.durationToTicks(t)}}Fi.Accidental=st,Fi.Annotation=lt,Fi.Articulation=xt,Fi.Barline=Pt,Fi.BarNote=Ft,Fi.Beam=Ie,Fi.Bend=Mt,Fi.BoundingBox=C,Fi.BoundingBoxComputation=N,Fi.CanvasContext=Qt,Fi.ChordSymbol=Rt,Fi.Clef=ue,Fi.ClefNote=We,Fi.Crescendo=Ge,Fi.Curve=He,Fi.Dot=Ot,Fi.EasyScore=Ze,Fi.Element=O,Fi.Factory=vi,Fi.Font=M,Fi.Formatter=Pe,Fi.Fraction=v,Fi.FretHandFinger=Lt,Fi.GhostNote=ei,Fi.Glyph=U,Fi.GlyphNote=ii,Fi.GraceNote=si,Fi.GraceNoteGroup=Ut,Fi.GraceTabNote=Ei,Fi.KeyManager=Ci,Fi.KeySignature=pe,Fi.KeySigNote=ni,Fi.Modifier=H,Fi.ModifierContext=ge,Fi.MultiMeasureRest=oi,Fi.Music=Y,Fi.Note=bt,Fi.NoteHead=Vt,Fi.NoteSubGroup=Ht,Fi.Ornament=jt,Fi.Parenthesis=Xt,Fi.Parser=Xe,Fi.PedalMarking=hi,Fi.Registry=R,Fi.RenderContext=St,Fi.Renderer=re,Fi.RepeatNote=di,Fi.Repetition=me,Fi.Stave=Ee,Fi.StaveConnector=Ne,Fi.StaveHairpin=Ni,Fi.StaveLine=gi,Fi.StaveModifier=At,Fi.StaveNote=$t,Fi.StaveTempo=_e,Fi.StaveText=Se,Fi.StaveTie=It,Fi.Stem=nt,Fi.StringNumber=he,Fi.Stroke=ce,Fi.SVGContext=ie,Fi.System=ui,Fi.TabNote=pi,Fi.TabSlide=ki,Fi.TabStave=mi,Fi.TabTie=Wt,Fi.TextBracket=xi,Fi.TextDynamics=yi,Fi.TextFormatter=ht,Fi.TextNote=xe,Fi.TickContext=Yt,Fi.TimeSignature=be,Fi.TimeSigNote=Ti,Fi.Tremolo=Di,Fi.Tuning=Ai,Fi.Tuplet=Me,Fi.Vibrato=de,Fi.VibratoBracket=bi,Fi.Voice=Gt,Fi.Volta=ye,Fi.AnnotationHorizontalJustify=ct,Fi.AnnotationVerticalJustify=dt,Fi.ChordSymbolHorizontalJustify=Et,Fi.ChordSymbolVerticalJustify=Ct,Fi.SymbolTypes=Nt,Fi.SymbolModifiers=kt,Fi.CurvePosition=Ue,Fi.FontWeight=k,Fi.FontStyle=D,Fi.ModifierPosition=I,Fi.RendererBackends=se,Fi.RendererLineEndType=ne,Fi.BarlineType=vt,Fi.StaveModifierPosition=wt,Fi.VoltaType=oe,Fi.TextBracketPosition=_i,Fi.TextJustification=ae,Fi.VoiceMode=Dt;const Mi={spacing:50,glyphs:{" ":{x_min:0,x_max:250,y_min:0,y_max:500,ha:500,leftSideBearing:0,advanceWidth:250},0:{x_min:33,x_max:534,y_min:-13,y_max:751,ha:764,leftSideBearing:33,advanceWidth:570},1:{x_min:48,x_max:235,y_min:-17,y_max:734,ha:751,leftSideBearing:48,advanceWidth:286},2:{x_min:56,x_max:571,y_min:-19,y_max:741,ha:760,leftSideBearing:56,advanceWidth:626},3:{x_min:50,x_max:528,y_min:-7,y_max:731,ha:738,leftSideBearing:50,advanceWidth:589},4:{x_min:38,x_max:564,y_min:-13,y_max:743,ha:756,leftSideBearing:38,advanceWidth:614},5:{x_min:42,x_max:601,y_min:-34,y_max:743,ha:777,leftSideBearing:42,advanceWidth:648},6:{x_min:47,x_max:606,y_min:-16,y_max:743,ha:759,leftSideBearing:47,advanceWidth:667},7:{x_min:47,x_max:567,y_min:5,y_max:739,ha:734,leftSideBearing:0,advanceWidth:615},8:{x_min:40,x_max:541,y_min:-15,y_max:752,ha:767,leftSideBearing:40,advanceWidth:585},9:{x_min:40,x_max:537,y_min:-52,y_max:736,ha:788,leftSideBearing:40,advanceWidth:592},"!":{x_min:49,x_max:180,y_min:-7,y_max:761,ha:768,leftSideBearing:49,advanceWidth:230},'"':{x_min:39,x_max:304,y_min:596,y_max:804,ha:208,leftSideBearing:39,advanceWidth:353},"#":{x_min:33,x_max:599,y_min:-8,y_max:765,ha:773,leftSideBearing:33,advanceWidth:648},$:{x_min:53,x_max:495,y_min:-111,y_max:823,ha:934,leftSideBearing:53,advanceWidth:560},"%":{x_min:35,x_max:656,y_min:-128,y_max:808,ha:936,leftSideBearing:35,advanceWidth:711},"&":{x_min:53,x_max:441,y_min:-3,y_max:753,ha:756,leftSideBearing:53,advanceWidth:500},"'":{x_min:43,x_max:161,y_min:590,y_max:811,ha:221,leftSideBearing:43,advanceWidth:217},"(":{x_min:41,x_max:311,y_min:-36,y_max:845,ha:881,leftSideBearing:41,advanceWidth:308},")":{x_min:-8,x_max:257,y_min:-21,y_max:852,ha:873,leftSideBearing:-8,advanceWidth:280},"*":{x_min:59,x_max:539,y_min:175,y_max:589,ha:414,leftSideBearing:59,advanceWidth:601},"+":{x_min:33,x_max:361,y_min:180,y_max:587,ha:407,leftSideBearing:33,advanceWidth:400},",":{x_min:15,x_max:176,y_min:-129,y_max:92,ha:221,leftSideBearing:15,advanceWidth:205},"-":{x_min:40,x_max:380,y_min:317,y_max:452,ha:135,leftSideBearing:40,advanceWidth:422},".":{x_min:48,x_max:185,y_min:-56,y_max:84,ha:140,leftSideBearing:48,advanceWidth:227},"/":{x_min:-58,x_max:654,y_min:-122,y_max:844,ha:966,leftSideBearing:-58,advanceWidth:626},":":{x_min:65,x_max:225,y_min:97,y_max:536,ha:439,leftSideBearing:65,advanceWidth:302},";":{x_min:13,x_max:295,y_min:-139,y_max:536,ha:675,leftSideBearing:13,advanceWidth:334},"<":{x_min:28,x_max:438,y_min:-1,y_max:607,ha:608,leftSideBearing:28,advanceWidth:475},"=":{x_min:40,x_max:383,y_min:199.9598640852289,y_max:541,ha:341.0401359147711,leftSideBearing:40,advanceWidth:422},">":{x_min:35,x_max:421,y_min:28,y_max:632,ha:604,leftSideBearing:35,advanceWidth:466},"?":{x_min:45,x_max:548,y_min:-17,y_max:767,ha:784,leftSideBearing:45,advanceWidth:592},"@":{x_min:51,x_max:730,y_min:-78,y_max:753,ha:831,leftSideBearing:51,advanceWidth:781},A:{x_min:37,x_max:554,y_min:-4,y_max:746,ha:750,leftSideBearing:37,advanceWidth:617},B:{x_min:37,x_max:532,y_min:3,y_max:783,ha:780,leftSideBearing:37,advanceWidth:579},C:{x_min:37,x_max:583,y_min:-3,y_max:775,ha:778,leftSideBearing:37,advanceWidth:623},D:{x_min:50,x_max:530,y_min:-15,y_max:749,ha:764,leftSideBearing:50,advanceWidth:579},E:{x_min:45,x_max:531,y_min:-1,y_max:743,ha:744,leftSideBearing:45,advanceWidth:585},F:{x_min:45,x_max:459,y_min:23,y_max:727,ha:704,leftSideBearing:45,advanceWidth:510},G:{x_min:31,x_max:577,y_min:-8,y_max:733,ha:741,leftSideBearing:31,advanceWidth:611},H:{x_min:37,x_max:493,y_min:-22,y_max:758,ha:780,leftSideBearing:37,advanceWidth:535},I:{x_min:47,x_max:501,y_min:-3,y_max:731,ha:734,leftSideBearing:47,advanceWidth:541},J:{x_min:33,x_max:531,y_min:-23,y_max:725,ha:748,leftSideBearing:33,advanceWidth:573},K:{x_min:43,x_max:505,y_min:-10,y_max:740,ha:750,leftSideBearing:43,advanceWidth:560},L:{x_min:49,x_max:457,y_min:-2,y_max:746,ha:748,leftSideBearing:49,advanceWidth:510},M:{x_min:35,x_max:699,y_min:1,y_max:744,ha:743,leftSideBearing:35,advanceWidth:743},N:{x_min:34,x_max:533,y_min:-17,y_max:761,ha:778,leftSideBearing:34,advanceWidth:579},O:{x_min:41,x_max:608,y_min:-5,y_max:735,ha:740,leftSideBearing:41,advanceWidth:667},P:{x_min:53,x_max:451,y_min:-18,y_max:735,ha:753,leftSideBearing:53,advanceWidth:497},Q:{x_min:40,x_max:599,y_min:-67,y_max:744,ha:811,leftSideBearing:40,advanceWidth:648},R:{x_min:39,x_max:487,y_min:16,y_max:735,ha:719,leftSideBearing:39,advanceWidth:535},S:{x_min:35,x_max:552,y_min:-47,y_max:708,ha:755,leftSideBearing:35,advanceWidth:604},T:{x_min:26,x_max:656,y_min:-13,y_max:718,ha:731,leftSideBearing:26,advanceWidth:705},U:{x_min:41,x_max:518,y_min:-20,y_max:748,ha:768,leftSideBearing:41,advanceWidth:567},V:{x_min:47,x_max:509,y_min:-26,y_max:744,ha:770,leftSideBearing:47,advanceWidth:567},W:{x_min:44,x_max:789,y_min:-35,y_max:720,ha:755,leftSideBearing:44,advanceWidth:833},X:{x_min:63,x_max:635,y_min:-10,y_max:745,ha:755,leftSideBearing:63,advanceWidth:680},Y:{x_min:43,x_max:503,y_min:-21,y_max:734,ha:755,leftSideBearing:43,advanceWidth:541},Z:{x_min:42,x_max:584,y_min:-10,y_max:739,ha:749,leftSideBearing:42,advanceWidth:629},"[":{x_min:46,x_max:346,y_min:-150,y_max:884,ha:1034,leftSideBearing:46,advanceWidth:291},"\\":{x_min:20,x_max:616,y_min:-100,y_max:797,ha:897,leftSideBearing:20,advanceWidth:645},"]":{x_min:-76,x_max:226,y_min:-150,y_max:881,ha:1031,leftSideBearing:-76,advanceWidth:297},"^":{x_min:43,x_max:437,y_min:517,y_max:812,ha:295,leftSideBearing:43,advanceWidth:478},_:{x_min:29,x_max:563,y_min:-110,y_max:-1,ha:109,leftSideBearing:29,advanceWidth:598},"`":{x_min:54,x_max:321,y_min:540,y_max:747,ha:207,leftSideBearing:54,advanceWidth:368},a:{x_min:20,x_max:447,y_min:-17,y_max:495,ha:512,leftSideBearing:20,advanceWidth:494},b:{x_min:37,x_max:466,y_min:-27,y_max:770,ha:797,leftSideBearing:37,advanceWidth:510},c:{x_min:35,x_max:456,y_min:-9,y_max:507,ha:516,leftSideBearing:35,advanceWidth:460},d:{x_min:45,x_max:520,y_min:-15,y_max:764,ha:779,leftSideBearing:45,advanceWidth:560},e:{x_min:33,x_max:370,y_min:-5,y_max:501,ha:506,leftSideBearing:33,advanceWidth:397},f:{x_min:35,x_max:411,y_min:-13,y_max:695,ha:708,leftSideBearing:35,advanceWidth:453},g:{x_min:33,x_max:551,y_min:-257,y_max:505,ha:762,leftSideBearing:33,advanceWidth:611},h:{x_min:32,x_max:458,y_min:-29,y_max:743,ha:772,leftSideBearing:32,advanceWidth:491},i:{x_min:45,x_max:167,y_min:-13,y_max:631,ha:644,leftSideBearing:45,advanceWidth:220},j:{x_min:-127,x_max:261,y_min:-231,y_max:601,ha:832,leftSideBearing:-127,advanceWidth:308},k:{x_min:39,x_max:443,y_min:-3,y_max:700,ha:703,leftSideBearing:39,advanceWidth:497},l:{x_min:58,x_max:168,y_min:-8,y_max:686,ha:694,leftSideBearing:58,advanceWidth:227},m:{x_min:39,x_max:688,y_min:-14,y_max:501,ha:515,leftSideBearing:39,advanceWidth:718},n:{x_min:45,x_max:491,y_min:-32,y_max:512,ha:544,leftSideBearing:45,advanceWidth:541},o:{x_min:41,x_max:424,y_min:-12,y_max:493,ha:505,leftSideBearing:41,advanceWidth:447},p:{x_min:25,x_max:529,y_min:-260,y_max:500,ha:760,leftSideBearing:25,advanceWidth:573},q:{x_min:53,x_max:603,y_min:-235,y_max:514,ha:749,leftSideBearing:53,advanceWidth:623},r:{x_min:32,x_max:407,y_min:-7,y_max:492,ha:499,leftSideBearing:32,advanceWidth:460},s:{x_min:49,x_max:416,y_min:-12,y_max:519,ha:531,leftSideBearing:49,advanceWidth:460},t:{x_min:32,x_max:442,y_min:-5,y_max:684,ha:689,leftSideBearing:32,advanceWidth:469},u:{x_min:41,x_max:487,y_min:-5,y_max:507,ha:512,leftSideBearing:41,advanceWidth:510},v:{x_min:16,x_max:441,y_min:-20,y_max:542,ha:562,leftSideBearing:16,advanceWidth:456},w:{x_min:39,x_max:639,y_min:-22,y_max:505,ha:527,leftSideBearing:39,advanceWidth:661},x:{x_min:15,x_max:505,y_min:-39,y_max:539,ha:578,leftSideBearing:15,advanceWidth:541},y:{x_min:-98,x_max:501,y_min:-242,y_max:511,ha:753,leftSideBearing:-98,advanceWidth:548},z:{x_min:27,x_max:479,y_min:-3,y_max:494,ha:497,leftSideBearing:27,advanceWidth:494},"{":{x_min:0,x_max:0,y_min:0,y_max:0,ha:0,leftSideBearing:0,advanceWidth:308},"|":{x_min:0,x_max:0,y_min:0,y_max:0,ha:0,leftSideBearing:0,advanceWidth:308},"}":{x_min:0,x_max:0,y_min:0,y_max:0,ha:0,leftSideBearing:0,advanceWidth:308},"~":{x_min:0,x_max:0,y_min:0,y_max:0,ha:0,leftSideBearing:0,advanceWidth:308}},fontFamily:"PetalumaScript",resolution:1e3,generatedOn:"2020-06-14T18:33:25.407Z"},Bi={spacing:50,glyphs:{" ":{x_min:0,x_max:509,y_min:0,y_max:2e3,ha:2e3,leftSideBearing:0,advanceWidth:509},0:{x_min:121,x_max:1048,y_min:-21,y_max:1477,ha:1498,leftSideBearing:121,advanceWidth:1168},1:{x_min:117,x_max:767,y_min:0,y_max:1456,ha:1456,leftSideBearing:117,advanceWidth:844},2:{x_min:75.8474576645637,x_max:1040,y_min:0,y_max:1477,ha:1477,leftSideBearing:75,advanceWidth:1131},3:{x_min:74.85365853658536,x_max:994,y_min:-21,y_max:1477,ha:1498,leftSideBearing:74,advanceWidth:1106},4:{x_min:63,x_max:1114,y_min:0,y_max:1456,ha:1456,leftSideBearing:63,advanceWidth:1187},5:{x_min:96.8448275474953,x_max:982,y_min:-21,y_max:1456,ha:1477,leftSideBearing:96,advanceWidth:1081},6:{x_min:121,x_max:1067,y_min:-21,y_max:1477,ha:1498,leftSideBearing:121,advanceWidth:1144},7:{x_min:76,x_max:1060,y_min:0,y_max:1456,ha:1456,leftSideBearing:-30,advanceWidth:1128},8:{x_min:92,x_max:1039,y_min:-21,y_max:1477,ha:1498,leftSideBearing:92,advanceWidth:1131},9:{x_min:84,x_max:1026,y_min:-21,y_max:1477,ha:1498,leftSideBearing:84,advanceWidth:1154},"!":{x_min:143,x_max:340,y_min:0,y_max:1456,ha:1456,leftSideBearing:143,advanceWidth:483},'"':{x_min:166,x_max:634,y_min:1055,y_max:1560,ha:505,leftSideBearing:166,advanceWidth:770},"#":{x_min:63,x_max:1179,y_min:0,y_max:1456,ha:1456,leftSideBearing:63,advanceWidth:1246},$:{x_min:81.92156915727656,x_max:1012,y_min:-208,y_max:1693,ha:1901,leftSideBearing:81,advanceWidth:1110},"%":{x_min:77,x_max:1384,y_min:-21,y_max:1477,ha:1498,leftSideBearing:77,advanceWidth:1460},"&":{x_min:74,x_max:1242,y_min:-21,y_max:1477,ha:1498,leftSideBearing:74,advanceWidth:1289},"'":{x_min:166,x_max:324,y_min:1055,y_max:1560,ha:505,leftSideBearing:166,advanceWidth:460},"(":{x_min:114,x_max:650,y_min:-463,y_max:1636,ha:2099,leftSideBearing:114,advanceWidth:662},")":{x_min:11,x_max:547,y_min:-463,y_max:1636,ha:2099,leftSideBearing:11,advanceWidth:654},"*":{x_min:66,x_max:893,y_min:607,y_max:1456,ha:849,leftSideBearing:66,advanceWidth:958},"+":{x_min:73,x_max:1071,y_min:146,y_max:1206,ha:1060,leftSideBearing:73,advanceWidth:1145},",":{x_min:23,x_max:315,y_min:-311,y_max:221,ha:532,leftSideBearing:23,advanceWidth:404},"-":{x_min:154,x_max:643,y_min:538,y_max:692,ha:154,leftSideBearing:154,advanceWidth:797},".":{x_min:145,x_max:342,y_min:0,y_max:202,ha:202,leftSideBearing:145,advanceWidth:493},"/":{x_min:0,x_max:774,y_min:-125,y_max:1456,ha:1581,leftSideBearing:0,advanceWidth:824},":":{x_min:145,x_max:342,y_min:0,y_max:1082,ha:1082,leftSideBearing:145,advanceWidth:419},";":{x_min:53,x_max:345,y_min:-311,y_max:1082,ha:1393,leftSideBearing:53,advanceWidth:424},"<":{x_min:76,x_max:892,y_min:107,y_max:1013,ha:906,leftSideBearing:76,advanceWidth:1017},"=":{x_min:147,x_max:981,y_min:407,y_max:987,ha:580,leftSideBearing:147,advanceWidth:1127},">":{x_min:125,x_max:980,y_min:87,y_max:993,ha:906,leftSideBearing:125,advanceWidth:1060},"?":{x_min:65.92660602419838,x_max:890,y_min:0,y_max:1477,ha:1477,leftSideBearing:65,advanceWidth:953},"@":{x_min:84.3592218305664,x_max:1705.2346925277395,y_min:-453,y_max:1431,ha:1884,leftSideBearing:84,advanceWidth:1821},A:{x_min:70,x_max:1463,y_min:0,y_max:1456,ha:1456,leftSideBearing:70,advanceWidth:1533},B:{x_min:81,x_max:1253,y_min:0,y_max:1456,ha:1456,leftSideBearing:81,advanceWidth:1322},C:{x_min:80,x_max:1174,y_min:-21,y_max:1477,ha:1498,leftSideBearing:80,advanceWidth:1290},D:{x_min:81,x_max:1291,y_min:0,y_max:1456,ha:1456,leftSideBearing:81,advanceWidth:1356},E:{x_min:81,x_max:1190,y_min:0,y_max:1456,ha:1456,leftSideBearing:81,advanceWidth:1306},F:{x_min:81,x_max:1176,y_min:0,y_max:1456,ha:1456,leftSideBearing:81,advanceWidth:1256},G:{x_min:80,x_max:1226,y_min:-21,y_max:1477,ha:1498,leftSideBearing:80,advanceWidth:1346},H:{x_min:81,x_max:1497,y_min:0,y_max:1456,ha:1456,leftSideBearing:81,advanceWidth:1578},I:{x_min:81,x_max:604,y_min:0,y_max:1456,ha:1456,leftSideBearing:81,advanceWidth:685},J:{x_min:60,x_max:1100,y_min:-21,y_max:1456,ha:1477,leftSideBearing:60,advanceWidth:1169},K:{x_min:81,x_max:1427,y_min:0,y_max:1456,ha:1456,leftSideBearing:81,advanceWidth:1501},L:{x_min:81,x_max:1130,y_min:0,y_max:1456,ha:1456,leftSideBearing:81,advanceWidth:1210},M:{x_min:94,x_max:1888,y_min:0,y_max:1456,ha:1456,leftSideBearing:94,advanceWidth:1982},N:{x_min:83,x_max:1509,y_min:0,y_max:1456,ha:1456,leftSideBearing:83,advanceWidth:1592},O:{x_min:70,x_max:1281,y_min:-21,y_max:1477,ha:1498,leftSideBearing:70,advanceWidth:1351},P:{x_min:81,x_max:1242,y_min:0,y_max:1456,ha:1456,leftSideBearing:81,advanceWidth:1297},Q:{x_min:70,x_max:1348,y_min:-245,y_max:1477,ha:1722,leftSideBearing:70,advanceWidth:1376},R:{x_min:81,x_max:1285,y_min:0,y_max:1455,ha:1455,leftSideBearing:81,advanceWidth:1385},S:{x_min:115,x_max:1116,y_min:-21,y_max:1477,ha:1498,leftSideBearing:115,advanceWidth:1206},T:{x_min:96,x_max:1306,y_min:0,y_max:1456,ha:1456,leftSideBearing:96,advanceWidth:1406},U:{x_min:70,x_max:1452,y_min:-21,y_max:1456,ha:1477,leftSideBearing:70,advanceWidth:1522},V:{x_min:65,x_max:1443,y_min:0,y_max:1456,ha:1456,leftSideBearing:65,advanceWidth:1508},W:{x_min:72,x_max:2057,y_min:0,y_max:1456,ha:1456,leftSideBearing:72,advanceWidth:2129},X:{x_min:80,x_max:1449,y_min:0,y_max:1456,ha:1456,leftSideBearing:80,advanceWidth:1529},Y:{x_min:65,x_max:1396,y_min:0,y_max:1456,ha:1456,leftSideBearing:65,advanceWidth:1461},Z:{x_min:90,x_max:1107,y_min:0,y_max:1456,ha:1456,leftSideBearing:90,advanceWidth:1197},"[":{x_min:157,x_max:541,y_min:-312,y_max:1664,ha:1976,leftSideBearing:157,advanceWidth:573},"\\":{x_min:36,x_max:830,y_min:-125,y_max:1456,ha:1581,leftSideBearing:36,advanceWidth:841},"]":{x_min:23,x_max:408,y_min:-312,y_max:1664,ha:1976,leftSideBearing:23,advanceWidth:552},"^":{x_min:71,x_max:802,y_min:729,y_max:1456,ha:727,leftSideBearing:71,advanceWidth:864},_:{x_min:119,x_max:1041,y_min:-154,y_max:0,ha:154,leftSideBearing:119,advanceWidth:1168},"`":{x_min:40,x_max:456,y_min:1288,y_max:1560,ha:272,leftSideBearing:40,advanceWidth:496},a:{x_min:79,x_max:1053,y_min:-21,y_max:1102,ha:1123,leftSideBearing:79,advanceWidth:1132},b:{x_min:-16,x_max:1071,y_min:-21,y_max:1560,ha:1581,leftSideBearing:-16,advanceWidth:1145},c:{x_min:78,x_max:988,y_min:-21,y_max:1102,ha:1123,leftSideBearing:78,advanceWidth:1067},d:{x_min:78,x_max:1156,y_min:-21,y_max:1560,ha:1581,leftSideBearing:78,advanceWidth:1218},e:{x_min:74,x_max:980,y_min:-21,y_max:1102,ha:1123,leftSideBearing:74,advanceWidth:1059},f:{x_min:64,x_max:731,y_min:0,y_max:1581,ha:1581,leftSideBearing:64,advanceWidth:725},g:{x_min:78,x_max:1133,y_min:-437,y_max:1102,ha:1539,leftSideBearing:78,advanceWidth:1157},h:{x_min:49,x_max:1255,y_min:0,y_max:1560,ha:1560,leftSideBearing:49,advanceWidth:1315},i:{x_min:67,x_max:590,y_min:0,y_max:1560,ha:1560,leftSideBearing:67,advanceWidth:652},j:{x_min:-56,x_max:381,y_min:-437,y_max:1560,ha:1997,leftSideBearing:-56,advanceWidth:525},k:{x_min:64,x_max:1248,y_min:0,y_max:1560,ha:1560,leftSideBearing:64,advanceWidth:1287},l:{x_min:64,x_max:587,y_min:0,y_max:1560,ha:1560,leftSideBearing:64,advanceWidth:653},m:{x_min:74,x_max:1905,y_min:0,y_max:1102,ha:1102,leftSideBearing:74,advanceWidth:1977},n:{x_min:74,x_max:1278,y_min:0,y_max:1102,ha:1102,leftSideBearing:74,advanceWidth:1343},o:{x_min:78,x_max:1046,y_min:-21,y_max:1102,ha:1123,leftSideBearing:78,advanceWidth:1124},p:{x_min:34,x_max:1119,y_min:-416,y_max:1102,ha:1518,leftSideBearing:34,advanceWidth:1197},q:{x_min:78,x_max:1135,y_min:-416,y_max:1102,ha:1518,leftSideBearing:78,advanceWidth:1139},r:{x_min:72,x_max:808,y_min:0,y_max:1102,ha:1102,leftSideBearing:72,advanceWidth:854},s:{x_min:104,x_max:933,y_min:-21,y_max:1102,ha:1123,leftSideBearing:104,advanceWidth:1022},t:{x_min:24,x_max:678,y_min:-17,y_max:1343,ha:1360,leftSideBearing:24,advanceWidth:730},u:{x_min:52,x_max:1181,y_min:-21,y_max:1082,ha:1103,leftSideBearing:52,advanceWidth:1245},v:{x_min:26,x_max:1176,y_min:0,y_max:1082,ha:1082,leftSideBearing:26,advanceWidth:1206},w:{x_min:52,x_max:1777,y_min:0,y_max:1082,ha:1082,leftSideBearing:52,advanceWidth:1823},x:{x_min:42,x_max:1163,y_min:0,y_max:1082,ha:1082,leftSideBearing:42,advanceWidth:1203},y:{x_min:24,x_max:1172,y_min:-437,y_max:1082,ha:1519,leftSideBearing:24,advanceWidth:1192},z:{x_min:88,x_max:960,y_min:0,y_max:1082,ha:1082,leftSideBearing:88,advanceWidth:1032},"{":{x_min:63,x_max:671,y_min:-364,y_max:1597,ha:1961,leftSideBearing:63,advanceWidth:701},"|":{x_min:150,x_max:307,y_min:-270,y_max:1456,ha:1726,leftSideBearing:150,advanceWidth:451},"}":{x_min:27,x_max:635,y_min:-364,y_max:1597,ha:1961,leftSideBearing:27,advanceWidth:701},"~":{x_min:121,x_max:1257,y_min:401,y_max:803,ha:402,leftSideBearing:121,advanceWidth:1386}},fontFamily:"Roboto Slab",resolution:2048,generatedOn:"2020-06-15T19:12:58.120Z"};class Ri{static sortAndUnique(t,e,i){if(t.length>1){const s=[];let n;t.sort(e);for(let e=0;e<t.length;++e)0!==e&&i(t[e],n)||s.push(t[e]),n=t[e];return s}return t}static contains(t,e){let i=t.length;for(;i--;)if(t[i]===e)return!0;return!1}static getCanvasContext(t){if(!t)throw new f("BadArgument","Invalid canvas selector: "+t);const e=document.getElementById(t);if(!e||!e.getContext)throw new f("UnsupportedBrowserError","This browser does not support HTML5 Canvas");return e.getContext("2d")}static benchmark(t,e){const i=(new Date).getTime();e();S(t,(new Date).getTime()-i+"ms")}static stackTrace(){return(new Error).stack}}Ri.Flow=Fi;var Oi=function(t,e,i,s){return new(i||(i=Promise))((function(n,a){function o(t){try{h(s.next(t))}catch(t){a(t)}}function r(t){try{h(s.throw(t))}catch(t){a(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,r)}h((s=s.apply(t,e||[])).next())}))};const Li={Bravura:"./vexflow-font-bravura.js",Gonville:"./vexflow-font-gonville.js",Petaluma:"./vexflow-font-petaluma.js",Custom:"./vexflow-font-custom.js"};return Fi.fetchMusicFont=(t,e)=>Oi(void 0,void 0,void 0,(function*(){const i=M.load(t);if(i.hasData())return;if(!e){if(!(t in Li))throw new f("UnknownFont",`Music font ${t} does not exist.`);e=Li[t]}let s;if("string"==typeof e){const i=yield import(e),n=_().VexFlowFont;s=void 0!==n&&void 0!==n[t]?n[t]:i.Font}else s=e;i.setData(s.data),i.setMetrics(s.metrics)})),function(){{const t=Bi,{fontFamily:e,resolution:i,glyphs:s}=t;M.load(e,t);const n="b";ht.registerInfo({family:e,resolution:i,glyphs:s,maxSizeGlyph:n,monospaced:!1,bold:!1,italic:!1,superscriptOffset:.66,subscriptOffset:.66,serifs:!0,description:"Text font to pair with the Bravura / Gonville music fonts."})}{const t=Mi,{fontFamily:e,resolution:i,glyphs:s}=t;M.load(e,t);const n="b";ht.registerInfo({family:e,resolution:i,glyphs:s,maxSizeGlyph:n,monospaced:!1,bold:!1,italic:!1,superscriptOffset:.66,subscriptOffset:.66,serifs:!1,description:"Text font to pair with the Petaluma music font."})}}(),e=e.default})()}));
7
7
  //# sourceMappingURL=vexflow-core.js.map