vexflow 4.0.1-alpha.2 → 4.0.1-beta.2

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.
Files changed (76) hide show
  1. package/build/cjs/vexflow-bravura.js +2 -2
  2. package/build/cjs/vexflow-bravura.js.map +1 -1
  3. package/build/cjs/vexflow-core.js +2 -2
  4. package/build/cjs/vexflow-core.js.map +1 -1
  5. package/build/cjs/vexflow-debug-with-tests.js +345 -115
  6. package/build/cjs/vexflow-debug-with-tests.js.map +1 -1
  7. package/build/cjs/vexflow-debug.js +247 -78
  8. package/build/cjs/vexflow-debug.js.map +1 -1
  9. package/build/cjs/vexflow-font-bravura.js +1 -1
  10. package/build/cjs/vexflow-font-bravura.js.map +1 -1
  11. package/build/cjs/vexflow-font-gonville.js +1 -1
  12. package/build/cjs/vexflow-font-gonville.js.map +1 -1
  13. package/build/cjs/vexflow-font-petaluma.js +1 -1
  14. package/build/cjs/vexflow-font-petaluma.js.map +1 -1
  15. package/build/cjs/vexflow-gonville.js +2 -2
  16. package/build/cjs/vexflow-gonville.js.map +1 -1
  17. package/build/cjs/vexflow-petaluma.js +2 -2
  18. package/build/cjs/vexflow-petaluma.js.map +1 -1
  19. package/build/cjs/vexflow.js +2 -2
  20. package/build/cjs/vexflow.js.map +1 -1
  21. package/build/esm/src/accidental.js +1 -1
  22. package/build/esm/src/annotation.js +24 -5
  23. package/build/esm/src/articulation.js +5 -2
  24. package/build/esm/src/beam.js +4 -0
  25. package/build/esm/src/fonts/bravura_metrics.js +8 -5
  26. package/build/esm/src/fonts/gonville_glyphs.js +4 -4
  27. package/build/esm/src/fonts/gonville_metrics.js +8 -2
  28. package/build/esm/src/fonts/petaluma_metrics.js +8 -5
  29. package/build/esm/src/gracenote.js +2 -0
  30. package/build/esm/src/note.js +1 -1
  31. package/build/esm/src/stavenote.js +88 -22
  32. package/build/esm/src/staverepetition.js +8 -8
  33. package/build/esm/src/stavetie.js +2 -0
  34. package/build/esm/src/stemmablenote.js +4 -2
  35. package/build/esm/src/tables.js +36 -0
  36. package/build/esm/src/tabnote.js +12 -9
  37. package/build/esm/src/version.js +3 -3
  38. package/build/esm/tests/articulation_tests.js +11 -24
  39. package/build/esm/tests/formatter_tests.js +2 -2
  40. package/build/esm/tests/gracenote_tests.js +43 -0
  41. package/build/esm/tests/ornament_tests.js +0 -1
  42. package/build/esm/tests/stavenote_tests.js +32 -0
  43. package/build/types/entry/vexflow-font-bravura.d.ts +8 -5
  44. package/build/types/entry/vexflow-font-gonville.d.ts +8 -2
  45. package/build/types/entry/vexflow-font-petaluma.d.ts +8 -5
  46. package/build/types/src/fonts/bravura_metrics.d.ts +8 -5
  47. package/build/types/src/fonts/gonville_metrics.d.ts +8 -2
  48. package/build/types/src/fonts/petaluma_metrics.d.ts +8 -5
  49. package/build/types/src/glyph.d.ts +4 -0
  50. package/build/types/src/note.d.ts +1 -0
  51. package/build/types/src/stavenote.d.ts +2 -0
  52. package/build/types/src/stem.d.ts +4 -1
  53. package/build/types/src/stemmablenote.d.ts +4 -1
  54. package/build/types/src/tabnote.d.ts +4 -1
  55. package/package.json +1 -1
  56. package/src/accidental.ts +1 -1
  57. package/src/annotation.ts +27 -6
  58. package/src/articulation.ts +8 -2
  59. package/src/beam.ts +4 -0
  60. package/src/fonts/bravura_metrics.ts +8 -5
  61. package/src/fonts/gonville_glyphs.ts +4 -4
  62. package/src/fonts/gonville_metrics.ts +8 -2
  63. package/src/fonts/petaluma_metrics.ts +8 -5
  64. package/src/glyph.ts +4 -0
  65. package/src/gracenote.ts +4 -1
  66. package/src/note.ts +2 -2
  67. package/src/stavenote.ts +97 -21
  68. package/src/staverepetition.ts +8 -8
  69. package/src/stavetie.ts +8 -0
  70. package/src/stem.ts +1 -1
  71. package/src/stemmablenote.ts +6 -4
  72. package/src/tables.ts +36 -0
  73. package/src/tabnote.ts +16 -13
  74. package/build/esm/src/publicpath.js +0 -1
  75. package/build/types/src/publicpath.d.ts +0 -0
  76. package/src/publicpath.ts +0 -0
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * VexFlow 4.0.1-alpha.2 2022-02-02T09:30:30.784Z 0df10df6d1fab3a99f5aa306341a31c6e686d659
2
+ * VexFlow 4.0.1-beta.2 2022-02-27T01:14:47.524Z 567ba80618390639c170a60de47ab4d1f2eabbff
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);var e={};function i(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.d(e,{default:()=>Ci});const s=t=>i(t,c.Barline),n=t=>i(t,c.GraceNote),a=t=>i(t,c.Note),o=t=>i(t,c.StaveNote),r=t=>i(t,c.StemmableNote),h=t=>i(t,c.TabNote);var c;!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"}(c||(c={}));class d extends Error{constructor(t,e=""){super("[RuntimeError] "+t+": "+e),this.code=t}}function l(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==t.g?t.g:Function("return this")()}function g(t,e="undefined",i=""){if(void 0===t)throw new d(e,i);return t}function u(t,...e){if(!e)return;const i=Array.prototype.slice.call(e).join(" ");l().console.log(t+": "+i)}function p(...t){const e=t.join(" "),i=new Error;l().console.log("Warning: ",e,i.stack)}function m(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 f(t){return`vf-${t}`}function _(t){return(t%=2*Math.PI)<0&&(t+=2*Math.PI),t}class x{constructor(t,e){this.numerator=1,this.denominator=1,this.set(t,e)}static get CATEGORY(){return c.Fraction}static GCD(t,e){if("number"!=typeof t||Number.isNaN(t)||"number"!=typeof e||Number.isNaN(e))throw new d("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/x.GCD(t,e)}static LCMM(t){return 0===t.length?0:1===t.length?t[0]:2===t.length?x.LCM(t[0],t[1]):x.LCM(t.shift(),x.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=x.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]=S(t,e),n=x.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]=S(t,e),n=x.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]=S(t,e);return this.set(this.numerator*i,this.denominator*s)}divide(t=1,e=1){const[i,s]=S(t,e);return this.set(this.numerator*s,this.denominator*i)}equals(t){const e=x.__staticFractionA.copy(t).simplify(),i=x.__staticFractionB.copy(this).simplify();return e.numerator===i.numerator&&e.denominator===i.denominator}greaterThan(t){const e=x.__staticFractionB.copy(this);return e.subtract(t),e.numerator>0}greaterThanEquals(t){const e=x.__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 x(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 x.__staticFractionTmp.copy(this).simplify().toString()}toMixedString(){let t="";const e=this.quotient(),i=x.__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 S(t,e=1){return"number"==typeof t?[t,e]:[t.numerator,t.denominator]}x.__staticFractionA=new x,x.__staticFractionB=new x,x.__staticFractionTmp=new x;class y{constructor(t,e,i,s){this.x=t,this.y=e,this.w=i,this.h=s}static copy(t){return new y(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 y.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 T{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 b,w,v=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 E;!function(t){t.NORMAL="normal",t.BOLD="bold"}(b||(b={})),function(t){t.NORMAL="normal",t.ITALIC="italic"}(w||(w={}));const C={};class k{constructor(t){this.name=t}static convertSizeToPixelValue(t=k.SIZE){var e;if("number"==typeof t)return t*k.scaleToPxFrom.pt;{const i=parseFloat(t);if(isNaN(i))return 0;const s=t.replace(/[\d.\s]/g,"").toLowerCase();return i*(null!==(e=k.scaleToPxFrom[s])&&void 0!==e?e:1)}}static convertSizeToPointValue(t=k.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=k.scaleToPxFrom[s])&&void 0!==e?e:1)/k.scaleToPxFrom.pt)}}static validate(t,e,i,s){if("string"==typeof t&&void 0===e&&void 0===i&&void 0===s)return k.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:k.SANS_SERIF,e=null!=e?e:k.SIZE+"pt",i=null!=i?i:b.NORMAL,s=null!=s?s:w.NORMAL,""===i&&(i=b.NORMAL),""===s&&(s=w.NORMAL),"number"==typeof e&&(e=`${e}pt`),"number"==typeof i&&(i=i.toString()),{family:n,size:e,weight:i,style:s}}static fromCSSString(t){E||(E=document.createElement("span")),E.style.font=t;const{fontFamily:e,fontSize:i,fontWeight:s,fontStyle:n}=E.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===w.NORMAL||""===s||void 0===s?"":s.trim()+" ";const a=t.weight;let o;n=a===b.NORMAL||""===a||void 0===a?"":"number"==typeof a?a+" ":a.trim()+" ";const r=t.size;o=void 0===r?k.SIZE+"pt ":"number"==typeof r?r+"pt ":r.trim()+" ";return`${i}${n}${o}${null!==(e=t.family)&&void 0!==e?e:k.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()===w.ITALIC}static loadWebFont(t,e,i=!0){return v(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 v(this,void 0,void 0,(function*(){const t=k.WEB_FONT_HOST,e=k.WEB_FONT_FILES;for(const i in e){const s=e[i];k.loadWebFont(i,t+s)}}))}static loadTextFonts(){}static load(t,e,i){let s=C[t];return s||(s=new k(t),C[t]=s),e&&s.setData(e),i&&s.setMetrics(i),s}getName(){return this.name}getData(){return g(this.data,"FontError","Missing font data")}getMetrics(){return g(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]"}}k.SANS_SERIF="Arial, sans-serif",k.SERIF="Times New Roman, serif",k.SIZE=10,k.scaleToPxFrom={pt:4/3,px:1,em:16,"%":.16,in:96,mm:96/25.4,cm:96/2.54},k.WEB_FONT_HOST="https://unpkg.com/vexflow-fonts@1.0.3/",k.WEB_FONT_FILES={"Roboto Slab":"robotoslab/RobotoSlab-Medium_2.001.woff",PetalumaScript:"petaluma/PetalumaScript_1.10_FS.woff"};class D{constructor(){this.id={},this.type={},this.class={}}}class N{constructor(){this.index=new D}static getDefaultRegistry(){return N.defaultRegistry}static enableDefaultRegistry(t){N.defaultRegistry=t}static disableDefaultRegistry(){N.defaultRegistry=void 0}clear(){return this.index=new D,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 d("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 A{constructor(){var t;this.attrs={id:A.newID(),el:void 0,type:this.getCategory(),classes:{}},this.rendered=!1,null===(t=N.getDefaultRegistry())||void 0===t||t.register(this)}static get CATEGORY(){return c.Element}static newID(){return"auto"+A.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 g(this.context,"NoContext","No rendering context attached to instance.")}set font(t){this.setFont(t)}get font(){return k.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?k.fromCSSString(t):r&&h?Object.assign({},n):k.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(),k.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 k.convertSizeToPointValue(this.fontSize)}get fontSizeInPixels(){return k.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 F,P;A.ID=1e3,A.TEXT_FONT={family:k.SANS_SERIF,size:k.SIZE,weight:b.NORMAL,style:w.NORMAL},function(t){t[t.MOVE=0]="MOVE",t[t.LINE=1]="LINE",t[t.QUADRATIC=2]="QUADRATIC",t[t.BEZIER=3]="BEZIER"}(F||(F={}));class B{constructor(t,e,i){this.point=-1,this.metrics=R.loadMetrics(t,e,i),this.bbox=R.getOutlineBoundingBox(this.metrics.outline,this.metrics.scale,this.metrics.x_shift,this.metrics.y_shift),i&&(this.point=R.lookupFontMetric(this.metrics.font,i,e,"point",-1))}}class M{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(F.MOVE,parseInt(i[s++]),parseInt(i[s++]));break;case"l":e.push(F.LINE,parseInt(i[s++]),parseInt(i[s++]));break;case"q":e.push(F.QUADRATIC,parseInt(i[s++]),parseInt(i[s++]),parseInt(i[s++]),parseInt(i[s++]));break;case"b":e.push(F.BEZIER,parseInt(i[s++]),parseInt(i[s++]),parseInt(i[s++]),parseInt(i[s++]),parseInt(i[s++]),parseInt(i[s++]))}return e}}class R extends A{constructor(t,e,i){super(),this.bbox=new y(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 c.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;g(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 d("BadGlyph",`Glyph ${e} does not exist in font.`)}static loadMetrics(t,e,i){const{glyph:s,font:n}=R.lookupGlyph(t,e);if(!s.o)throw new d("BadGlyph",`Glyph ${e} has no outline defined.`);let a=0,o=0,r=1;i&&n&&(a=R.lookupFontMetric(n,i,e,"shiftX",0),o=R.lookupFontMetric(n,i,e,"shiftY",0),r=R.lookupFontMetric(n,i,e,"scale",1));const h=s.x_min,c=s.x_max,l=s.ha;return s.cached_outline||(s.cached_outline=M.parse(s.o)),{x_min:h,x_max:c,x_shift:a,y_shift:o,scale:r,ha:l,outline:s.cached_outline,font:n,width:c-h,height:l}}static renderGlyph(t,e,i,s,n,a){var o;const r=R.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 R.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 M(e,s,n,i);let o,r;for(t.beginPath();!a.done();)switch(a.next()){case F.MOVE:t.moveTo(a.nextX(),a.nextY());break;case F.LINE:t.lineTo(a.nextX(),a.nextY());break;case F.QUADRATIC:o=a.nextX(),r=a.nextY(),t.quadraticCurveTo(a.nextX(),a.nextY(),o,r);break;case F.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 M(t,i,s,e),a=new T;let o,r,h=i,c=s;for(;!n.done();)switch(n.next()){case F.MOVE:h=n.nextX(),c=n.nextY();break;case F.LINE:a.addPoint(h,c),h=n.nextX(),c=n.nextY(),a.addPoint(h,c);break;case F.QUADRATIC:o=n.nextX(),r=n.nextY(),a.addQuadraticCurve(h,c,n.nextX(),n.nextY(),o,r),h=o,c=r;break;case F.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 y(a.getX1(),a.getY1(),a.width(),a.height())}static getWidth(t,e,i){const s=R.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}setXShift(t){return this.x_shift=t,this}setYShift(t){return this.y_shift=t,this}reset(){const t=R.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 y(t.bbox.getX()*this.scale,t.bbox.getY()*this.scale,t.bbox.getW()*this.scale,t.bbox.getH()*this.scale)}checkMetrics(){return g(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;R.renderOutline(t,n,a,o,r),this.restoreStyle(t)}checkStave(){return g(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;R.renderOutline(e,n,a,o,r),this.restoreStyle()}}R.cache=new class{constructor(){this.cache=new Map}lookup(t,e){let i=this.cache.get(R.CURRENT_CACHE_KEY);void 0===i&&(i={},this.cache.set(R.CURRENT_CACHE_KEY,i));const s=e?`${t}%${e}`:t;let n=i[s];return void 0===n&&(n=new B(R.MUSIC_FONT_STACK,t,e),i[s]=n),n}},R.CURRENT_CACHE_KEY="",R.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"}(P||(P={}));class O extends A{constructor(){super(),this.width=0,this.text_line=0,this.position=O.Position.LEFT,this.x_shift=0,this.y_shift=0,this.spacingFromNextModifier=0}static get CATEGORY(){return c.Modifier}static get Position(){return P}static get PositionString(){return{center:P.CENTER,above:P.ABOVE,below:P.BELOW,left:P.LEFT,right:P.RIGHT}}reset(){}getWidth(){return this.width}setWidth(t){return this.width=t,this}getNote(){return g(this.note,"NoNote","Modifier has no note.")}checkAttachedNote(){const t=this.getCategory();return g(this.index,"NoIndex",`Can't draw ${t} without an index.`),g(this.note,"NoNote",`Can't draw ${t} without a note.`)}setNote(t){return this.note=t,this}getIndex(){return this.index}checkIndex(){return g(this.index,"NoIndex","Modifier has an invalid index.")}setIndex(t){return this.index=t,this}getModifierContext(){return this.modifierContext}checkModifierContext(){return g(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?O.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===O.Position.LEFT?this.x_shift-=t:this.x_shift+=t,this}getXShift(){return this.x_shift}draw(){throw this.checkContext(),new d("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 L{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:L.scales.major,m:L.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<L.canonical_notes.length}isValidIntervalValue(t){return t>=0&&t<L.diatonic_intervals.length}getNoteParts(t){if(!t||t.length<1)throw new d("BadArguments","Invalid note name: "+t);if(t.length>3)throw new d("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 d("BadArguments","Invalid note name: "+t)}getKeyParts(t){if(!t||t.length<1)throw new d("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 d("BadArguments",`Invalid key: ${t}`)}getNoteValue(t){const e=L.noteValues[t];if(void 0===e)throw new d("BadArguments",`Invalid note name: ${t}`);return e.int_val}getIntervalValue(t){const e=L.intervals[t];if(void 0===e)throw new d("BadArguments",`Invalid interval name: ${t}`);return e}getCanonicalNoteName(t){if(!this.isValidNoteValue(t))throw new d("BadArguments",`Invalid note value: ${t}`);return L.canonical_notes[t]}getCanonicalIntervalName(t){if(!this.isValidIntervalValue(t))throw new d("BadArguments",`Invalid interval value: ${t}`);return L.diatonic_intervals[t]}getRelativeNoteValue(t,e,i=1){if(1!==i&&-1!==i)throw new d("BadArguments",`Invalid direction: ${i}`);let s=(t+i*e)%L.NUM_TONES;return s<0&&(s+=L.NUM_TONES),s}getRelativeNoteName(t,e){const i=this.getNoteParts(t),s=this.getNoteValue(i.root);let n=e-s;if(Math.abs(n)>L.NUM_TONES-3){let i=1;n>0&&(i=-1);const a=(e+1+(s+1))%L.NUM_TONES*i;if(Math.abs(a)>2)throw new d("BadArguments",`Notes not related: ${t}, ${e})`);n=a}if(Math.abs(n)>2)throw new d("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 d("BadArguments",`Invalid direction: ${i}`);if(!this.isValidNoteValue(t)||!this.isValidNoteValue(e))throw new d("BadArguments",`Invalid notes: ${t}, ${e}`);let s=1===i?e-t:t-e;return s<0&&(s+=L.NUM_TONES),s}createScaleMap(t){const e=this.getKeyParts(t);if(!e.type)throw new d("BadArguments","Unsupported key type: undefined");const i=L.scaleTypes[e.type];let s=e.root;if(e.accidental&&(s+=e.accidental),!i)throw new d("BadArguments","Unsupported key type: "+t);const n=this.getScaleTones(this.getNoteValue(s),i),a=L.root_indices[e.root],o={};for(let t=0;t<L.roots.length;++t){const e=(a+t)%L.roots.length,i=L.roots[e];let s=this.getRelativeNoteName(i,n[t]);1===s.length&&(s+="n"),o[i]=s}return o}}const I=16384,W={"1/2":32768,1:16384,2:8192,4:4096,8:2048,16:1024,32:512,64:256,128:128,256:64},G={w:"1",h:"2",q:"4",b:"256"},U={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}},Y={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}},j={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}},H={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"}},X={"#":{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}},V={"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 K{static currentMusicFont(){if(0===K.MUSIC_FONT_STACK.length)throw new d("NoFonts","The font stack is empty. See: await Flow.fetchMusicFont(...); Flow.setMusicFont(...).");return K.MUSIC_FONT_STACK[0]}static clefProperties(t){if(!t||!(t in Y))throw new d("BadArgument","Invalid clef: "+t);return Y[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 d("BadArguments",`First argument must be note/octave or note/octave/glyph-code: ${t}`);const a=n[0].toUpperCase(),o=j[a];if(!o)throw new d("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+=K.clefProperties(e).line_shift;let c=0;h<=0&&2*h%2==0&&(c=1),h>=6&&2*h%2==0&&(c=-1);const l=void 0!==o.int_val?12*r+o.int_val:void 0,g=o.code,u=o.shift_right;let p={};if(n.length>2&&n[2]){const t=n[2].toUpperCase();p=H[t]||{}}return Object.assign({key:a,octave:r,line:h,int_value:l,accidental:o.accidental,code:g,stroke:c,shift_right:u,displaced:!1},p)}static integerToNote(t){if(void 0===t||t<0||t>11)throw new d("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 d("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 R("accidentalDoubleSharp",K.TABLATURE_FONT_SCALE).getMetrics();if(i="accidentalDoubleSharp",null==t.width||null==t.height)throw new d("InvalidMetrics","Width and height required");s=t.width,n=-t.height/2}else s=K.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 V[t]}static accidentalCodes(t){return X[t]}static ornamentCodes(t){return z[t]}static keySignature(t){const e=U[t];if(!e)throw new d("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 U}static hasKeySignature(t){return t in U}static sanitizeDuration(t){const e=G[t];if(void 0!==e&&(t=e),void 0===W[t])throw new d("BadArguments",`The provided duration is not valid: ${t}`);return t}static durationToFraction(t){return(new x).parse(K.sanitizeDuration(t))}static durationToNumber(t){return K.durationToFraction(t).value()}static durationToTicks(t){t=K.sanitizeDuration(t);const e=W[t];if(void 0===e)throw new d("InvalidDuration");return e}static getGlyphProps(t,e="n"){t=K.sanitizeDuration(t);const i=$[t];if(void 0===i)return;let s=i.type[e];if(void 0===s){const t=H[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=K.NOTATION_FONT_SCALE)=>R.getWidth(n,t)}),s)}}K.STEM_WIDTH=1.5,K.STEM_HEIGHT=35,K.STAVE_LINE_THICKNESS=1,K.RESOLUTION=I,K.MUSIC_FONT_STACK=[],K.NOTATION_FONT_SCALE=39,K.TABLATURE_FONT_SCALE=39,K.SLASH_NOTEHEAD_WIDTH=15,K.STAVE_LINE_DISTANCE=10,K.TEXT_HEIGHT_OFFSET_HACK=1,K.accidentalMap=X,K.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]}},K.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)},K.validTypes={n:{name:"note"},r:{name:"rest"},h:{name:"harmonic"},m:{name:"muted"},s:{name:"slash"},g:{name:"ghost"}},K.TIME4_4={num_beats:4,beat_value:4,resolution:I};const $={"1/2":{common:{stem:!1,stem_offset:0,flag:!1,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:()=>K.SLASH_NOTEHEAD_WIDTH,position:"B/4"},g:{code_head:"noteheadDoubleWhole"}}},1:{common:{stem:!1,stem_offset:0,flag:!1,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:()=>K.SLASH_NOTEHEAD_WIDTH,position:"B/4"},g:{code_head:"noteheadWhole"}}},2:{common:{stem:!0,stem_offset:0,flag:!1,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:()=>K.SLASH_NOTEHEAD_WIDTH,position:"B/4"},g:{code_head:"noteheadHalf"}}},4:{common:{stem:!0,stem_offset:0,flag:!1,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:()=>K.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",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:()=>K.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",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:()=>K.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",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:()=>K.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",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:()=>K.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",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:()=>K.SLASH_NOTEHEAD_WIDTH,position:"B/4"},g:{code_head:"noteheadBlack"}}}};function q(...t){J.DEBUG&&u("Vex.Flow.Accidental",t)}class J extends O{constructor(t){super(),q("New accidental: ",t),this.type=t,this.position=O.Position.LEFT,this.render_options={font_scale:38,parenLeftPadding:2,parenRightPadding:2},this.accidental=K.accidentalCodes(this.type),g(this.accidental,"ArgumentError",`Unknown accidental type: ${t}`),this.cautionary=!1,this.reset()}static get CATEGORY(){return c.Accidental}static format(t,e){if(!t||0===t.length)return;const i=K.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(),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=K.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,q("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 q("Line_1, Line_2, Collision: ",t.line,e.line,n),n}static applyAccidentals(t,e){const s=[],n={};t.forEach((t=>{const e=new x(0,1);t.getTickables().forEach((t=>{if(t.shouldIgnoreTicks())return;const i=n[e.value()];i?i.push(t):(s.push(e.value()),n[e.value()]=[t]),e.add(t.getTicks())}))}));const a=new L;e||(e="C");const r=a.createScaleMap(e),h={};s.forEach((t=>{const e=n[t],s=[],d=t=>{if(!o(t)||t.isRest()||t.shouldIgnoreTicks())return;const e=t;e.keys.forEach(((t,n)=>{const o=a.getNoteParts(t.split("/")[0]),d=t.split("/")[1],l=o.accidental||"n",g=o.root+l;h[o.root+d]||(h[o.root+d]=r[o.root]);const u=h[o.root+d]===g,p=s.indexOf(t)>-1;if(e.getModifiers().forEach(((t,s)=>{i(t,c.Accidental)&&t.type==l&&t.getIndex()==n&&e.getModifiers().splice(s,1)})),!u||u&&p){h[o.root+d]=g;const i=new J(l);e.addModifier(i,n),s.push(t)}})),e.getModifiers().forEach((t=>{i(t,c.GraceNoteGroup)&&t.getGraceNotes().forEach(d)}))};e.forEach(d)}))}reset(){const t=this.render_options.font_scale;this.glyph=new R(this.accidental.code,t),this.glyph.setOriginX(1),this.cautionary&&(this.parenLeft=new R(K.accidentalCodes("{").code,t),this.parenRight=new R(K.accidentalCodes("}").code,t),this.parenLeft.setOriginX(1),this.parenRight.setOriginX(1))}getWidth(){if(this.cautionary){const t=g(this.parenLeft),e=g(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 g(t,"ArgumentError",`Bad note value: ${t}`),this.note=t,n(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 u=l.x+n;const p=l.y+a;if(q("Rendering: ",t,u,p),s){const t=g(this.parenLeft),e=g(this.parenRight);e.render(c,u,p),u-=e.getMetrics().width,u-=h,u-=this.accidental.parenRightPaddingAdjustment,o.render(c,u,p),u-=o.getMetrics().width,u-=r,t.render(c,u,p)}else o.render(c,u,p)}}J.DEBUG=!1;class Q extends A{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 c.Stem}static get UP(){return 1}static get DOWN(){return-1}static get WIDTH(){return K.STEM_WIDTH}static get HEIGHT(){return K.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===Q.UP?this.stem_up_y_offset:this.stem_down_y_offset;return(this.y_bottom-this.y_top+(Q.HEIGHT-t+this.stem_extension))*this.stem_direction}getBoundingBox(){throw new d("NotImplemented","getBoundingBox() not implemented.")}getExtents(){const t=this.stem_direction===Q.UP,e=[this.y_top,this.y_bottom],i=Q.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=K.currentMusicFont().lookupMetric("stem.heightAdjustmentForFlag",-3)}adjustHeightForBeam(){this.renderHeightAdjustment=-Q.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===Q.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){Q.DEBUG&&u("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(Q.WIDTH),t.moveTo(e,i-o+n),t.lineTo(e,i-a-this.renderHeightAdjustment*s),t.stroke(),this.restoreStyle(t),t.restore()}}function Z(...t){it.DEBUG&&u("Vex.Flow.TextFormatter",t)}Q.DEBUG=!1;const tt={},et={};class it{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 et){const i=et[e];t.push(Object.assign({},i))}return t}static create(t={}){Z("create: ",t),t.family||(t.family=k.SANS_SERIF);const e=[],i=t.family.split(/\s*,\s*/);for(const t of i){for(const i in et)i.startsWith(t)&&e.push(et[i]);if(e.length>0)break}let s;if(0===e.length)s=new it(Object.values(et)[0]);else if(1===e.length)s=new it(e[0]);else{const i=k.isBold(t.weight),n=k.isItalic(t.style),a=e.find((t=>t.bold===i&&t.italic===n));if(a)s=new it(a);else{const t=e.find((t=>t.italic===n||t.bold===i));s=new it(t||e[0])}}const n=t.size;if(void 0!==n){const t=k.convertSizeToPointValue(n);s.setFontSize(t)}return s}static getInfo(t){return et[t]}static registerInfo(t,e=!1){Z("registerInfo: ",t,e);const i=t.family;(void 0===et[i]||e)&&(et[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?b.BOLD:b.NORMAL,s=this.italic?w.ITALIC:w.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=tt[e];void 0===i&&(i={},tt[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*k.scaleToPxFrom.pt}getResolution(){return this.resolution}}var st,nt;it.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"}(st||(st={})),function(t){t[t.TOP=1]="TOP",t[t.CENTER=2]="CENTER",t[t.BOTTOM=3]="BOTTOM",t[t.CENTER_STEM=4]="CENTER_STEM"}(nt||(nt={}));class at extends O{constructor(t){super(),this.text=t,this.horizontalJustification=st.CENTER,this.verticalJustification=nt.TOP,this.resetFont(),this.setWidth(K.textWidth(t))}static get CATEGORY(){return c.Annotation}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=it.create(n.textFont);let o=(5+a.maxHeight)/K.STAVE_LINE_DISTANCE;const c=n.checkAttachedNote(),d=c.getStave(),l=c.hasStem()?c.getStemDirection():Q.UP;let g=0,u=5;if(h(c))if(c.render_options.draw_stem){const t=c.getStem();t&&(g=Math.abs(t.getHeight())/K.STAVE_LINE_DISTANCE)}else g=0;else if(r(c)){const t=c.getStem();t&&"n"===c.getNoteType()&&(g=Math.abs(t.getHeight())/K.STAVE_LINE_DISTANCE)}d&&(u=d.getNumLines());const p=a.getWidthForTextInPx(n.text);if(i=Math.max(i,p),n.verticalJustification===this.VerticalJustify.TOP){let t=c.getLineNumber(!0);h(c)&&(t=u-(c.leastString()-.5)),l===Q.UP&&(t+=g);t+e.top_text_line+.5<u?(n.setTextLine(u-t),o+=u-t,e.top_text_line=o):(n.setTextLine(e.top_text_line),e.top_text_line+=o)}else if(n.verticalJustification===this.VerticalJustify.BOTTOM){let t=u-c.getLineNumber();h(c)&&(t=c.greatestString()-1),l===Q.DOWN&&(t+=g);const i=t+e.text_line+1;i<u?(n.setTextLine(u-i),o+=u-i,e.text_line=o):(n.setTextLine(e.text_line),e.text_line+=o)}else n.setTextLine(e.text_line)}return e.left_shift+=i/2,e.right_shift+=i/2,!0}setVerticalJustification(t){return this.verticalJustification="string"==typeof t?at.VerticalJustifyString[t]:t,this}getJustification(){return this.horizontalJustification}setJustification(t){return this.horizontalJustification="string"==typeof t?at.HorizontalJustifyString[t]:t,this}draw(){const t=this.checkContext(),e=this.checkAttachedNote(),i=e.hasStem()?e.getStemDirection():Q.UP,s=it.create(this.textFont),n=e.getModifierStartXY(P.ABOVE,this.index);this.setRendered(),t.save();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===st.LEFT?n.x:this.horizontalJustification===st.RIGHT?n.x-o:this.horizontalJustification===st.CENTER?n.x-o/2:e.getStemX()-o/2;let d={},l=0;const g=e.hasStem(),p=e.checkStave();if(g&&(d=e.checkStem().getExtents(),l=p.getSpacingBetweenLines()),this.verticalJustification===nt.BOTTOM){c=e.getYs().reduce(((t,e)=>t>e?t:e)),c+=(this.text_line+1)*K.STAVE_LINE_DISTANCE+r,g&&i===Q.DOWN&&(c=Math.max(c,d.topY+r+l*this.text_line))}else if(this.verticalJustification===nt.CENTER){const t=e.getYForTopText(this.text_line)-1;c=t+(p.getYForBottomText(this.text_line)-t)/2+r/2}else if(this.verticalJustification===nt.TOP)c=e.getYs()[0]-(this.text_line+1)*K.STAVE_LINE_DISTANCE,g&&i===Q.UP&&(l=d.topY<p.getTopLineTopY()?K.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){at.DEBUG&&u("Vex.Flow.Annotation",t)}("Rendering annotation: ",this.text,h,c),t.fillText(this.text,h,c),t.closeGroup(),t.restore()}}at.DEBUG=!1,at.TEXT_FONT=Object.assign({},A.TEXT_FONT),at.HorizontalJustify=st,at.HorizontalJustifyString={left:st.LEFT,right:st.RIGHT,center:st.CENTER,centerStem:st.CENTER_STEM},at.VerticalJustify=nt,at.VerticalJustifyString={above:nt.TOP,top:nt.TOP,below:nt.BOTTOM,bottom:nt.BOTTOM,center:nt.CENTER,centerStem:nt.CENTER_STEM};const{ABOVE:ot,BELOW:rt}=O.Position;function ht(t,e){return.5*t(e/.5)}function ct(t,e){return e===ot?t<=5:t>=1}function dt(t,e){return ct(t,e)?e===ot?Math.ceil:Math.floor:Math.round}const lt=t=>o(t)||n(t);class gt extends O{constructor(t){super(),this.type=t,this.position=rt,this.render_options={font_scale:38},this.reset()}static get CATEGORY(){return c.Articulation}static format(t,e){if(!t||0===t.length)return!1;const i=(t,e,i)=>ht(dt(e,i),g(t.glyph.getMetrics().height)/10+.5);t.forEach((t=>{const s=t.checkAttachedNote();let n=5;const a=s.hasStem()?s.getStemDirection():Q.UP;let o=0;if(r(s)){const t=s.getStem();t&&(o=Math.abs(t.getHeight())/K.STAVE_LINE_DISTANCE)}const h=s.getStave();if(h&&(n=h.getNumLines()),t.getPosition()===ot){let r=s.getLineNumber(!0);a===Q.UP&&(r+=o);let h=i(t,e.top_text_line,ot);const c=r+e.top_text_line+.5;!t.articulation.between_lines&&c<n&&(h+=n-c),t.setTextLine(e.top_text_line),e.top_text_line+=h}else if(t.getPosition()===rt){let r=Math.max(n-s.getLineNumber(),0);a===Q.DOWN&&(r+=o);let h=i(t,e.text_line,rt);const c=r+e.text_line+.5;!t.articulation.between_lines&&c<n&&(h+=n-c),t.setTextLine(e.text_line),e.text_line+=h}}));const s=t.map((t=>t.getWidth())).reduce(((t,e)=>Math.max(e,t)));return e.left_shift+=s/2,e.right_shift+=s/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=O.PositionString[e]),i.getFactory().Articulation(n)})).map((t=>e.addModifier(t,0)))}reset(){this.articulation=K.articulationCodes(this.type);const t=g(this.articulation,"ArgumentError",`Articulation not found: ${this.type}`),e=(this.position===ot?t.aboveCode:t.belowCode)||t.code;this.glyph=new R(null!=e?e:"",this.render_options.font_scale),this.setWidth(g(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(),c=r.getSpacingBetweenLines(),l=h(e),{x:g}=e.getModifierStartXY(s,i),p=!o||l,m=function(t,e){const i=e===ot&&t.getStemDirection()===Q.UP||e===rt&&t.getStemDirection()===Q.DOWN;return lt(t)?t.hasStem()&&i?.5:1:t.hasStem()&&i?1:0}(e,s),f=K.currentMusicFont().lookupMetric(`articulation.${n.getCode()}.padding`,0);let _={[ot]:()=>{n.setOrigin(.5,1);const t=function(t,e){const i=t.getStemDirection(),{topY:s,baseY:n}=t.getStemExtents();if(lt(t))return t.hasStem()?i===Q.UP?s:n:Math.min(...t.getYs());if(h(t))return t.hasStem()&&i===Q.UP?s:t.checkStave().getYForTopText(e);throw new d("UnknownCategory","Only can get the top and bottom ys of stavenotes and tabnotes")}(e,a)-(a+m)*c;return p?Math.min(r.getYForTopText(gt.INITIAL_OFFSET),t):t},[rt]:()=>{n.setOrigin(.5,0);const t=function(t,e){const i=t.getStemDirection(),{topY:s,baseY:n}=t.getStemExtents();if(lt(t))return t.hasStem()?i===Q.UP?n:s:Math.max(...t.getYs());if(h(t))return t.hasStem()?i===Q.UP?t.checkStave().getYForBottomText(e):s:t.checkStave().getYForBottomText(e);throw new d("UnknownCategory","Only can get the top and bottom ys of stavenotes and tabnotes")}(e,a)+(a+m)*c;return p?Math.max(r.getYForBottomText(gt.INITIAL_OFFSET),t):t}}[s]();if(!l){const t=s===ot?-1:1,a=e.getKeyProps()[i].line,r=(e.getYs()[i]-_)/c+Number(a),h=function(t,e,i,s){const n=ht(dt(e,i),e);if(t&&ct(n,i)&&n%1==0)return n+.5*-s;return n}(o,r,s,t);ct(h,s)&&n.setOrigin(.5,.5),_+=Math.abs(h-r)*c*t+f*t}!function(...t){gt.DEBUG&&u("Vex.Flow.Articulation",t)}(`Rendering articulation at (x: ${g}, y: ${_})`),n.render(t,g,_)}}gt.DEBUG=!1,gt.INITIAL_OFFSET=-.5;class ut{static get CATEGORY(){return c.RenderContext}set font(t){this.setFont(t)}get font(){return this.getFont()}setRawFont(t){return this.setFont(t),this}}class pt extends A{constructor(){super(),this._preFormatted=!1,this._postFormatted=!1,this.ticks=new x(0,1),this.intrinsicTicks=0,this.tickMultiplier=new x(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 c.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 d("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 g(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 g(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*(K.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 g(this.modifierContext,"NoModifierContext","No modifier context attached to this tickable.")}}class mt extends pt{constructor(t){if(super(),!t)throw new d("BadArguments","Note must have valid initialization data to identify duration and type.");const e=mt.parseNoteStruct(t);if(!e)throw new d("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=K.getGlyphProps(this.duration,this.noteType),this.customGlyphs=this.customTypes.map((t=>K.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 c.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(k.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"),function(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()}(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=mt.parseDuration(t.duration);if(!e)return;let i=t.type;if(i&&!K.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=K.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 g(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 d("NoYValues","No Y-values calculated for this note.");return this.ys}getYForTopText(t){return this.checkStave().getYForTopText(t)}getVoice(){if(!this.voice)throw new d("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 g(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 d("WrongParams","Incorrect call signature. Use "+i+" instead.");return t.setNote(this),t.setIndex(e),super.addModifier(t),this}getModifiersByType(t){return this.checkModifierContext().getMembers(t)}getModifierStartXY(t,e,i){if(!this.preFormatted)throw new d("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():0}getFirstDotPx(){let t=this.getRightDisplacedHeadPx();return 0!==this.checkModifierContext().getMembers("Parenthesis").length&&(t+=K.currentMusicFont().lookupMetric("parenthesis.default.width")),t}getMetrics(){if(!this.preFormatted)throw new d("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()+K.currentMusicFont().lookupMetric("stave.padding")),this.isCenterAligned()&&(t+=this.getCenterXShift()),t}getStemDirection(){throw new d("NoStem","No stem attached to this note.")}getStemExtents(){throw new d("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 ft,_t,xt,St,yt,Tt,bt;!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"}(ft||(ft={}));class wt extends A{constructor(){super(),this.width=0,this.x=0,this.padding=10,this.position=ft.ABOVE}static get CATEGORY(){return c.StaveModifier}static get Position(){return ft}getPosition(){return this.position}setPosition(t){return this.position=t,this}getStave(){return this.stave}checkStave(){return g(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"}(_t||(_t={}));class vt extends wt{constructor(t){super(),this.thickness=K.STAVE_LINE_THICKNESS;const e=_t;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(ft.BEGIN),this.setType(t)}static get CATEGORY(){return c.Barline}static get type(){return _t}static get typeString(){return{single:_t.SINGLE,double:_t.DOUBLE,end:_t.END,repeatBegin:_t.REPEAT_BEGIN,repeatEnd:_t.REPEAT_END,repeatBoth:_t.REPEAT_BOTH,none:_t.NONE}}getType(){return this.type}setType(t){return this.type="string"==typeof t?vt.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 _t.SINGLE:this.drawVerticalBar(t,this.x,!1);break;case _t.DOUBLE:this.drawVerticalBar(t,this.x,!0);break;case _t.END:this.drawVerticalEndBar(t,this.x);break;case _t.REPEAT_BEGIN:this.drawRepeatBar(t,this.x,!0),t.getX()!==this.x&&this.drawVerticalBar(t,t.getX());break;case _t.REPEAT_END:this.drawRepeatBar(t,this.x,!1);break;case _t.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 Et extends mt{constructor(t=_t.SINGLE){super({duration:"b"}),this.metrics={widths:{}};const e=_t;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 c.BarNote}getType(){return this.type}setType(t){return this.type="string"==typeof t?vt.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){Et.DEBUG&&u("Vex.Flow.BarNote",t)}("Rendering bar line at: ",this.getAbsoluteX()),this.style&&this.applyStyle(t);const e=new vt(this.type);e.setX(this.getAbsoluteX()),e.draw(this.checkStave()),this.style&&this.restoreStyle(t),this.setRendered()}}Et.DEBUG=!1;class Ct extends O{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:Ct.UP,text:this.text}],this.release&&this.phrase.push({type:Ct.DOWN,text:""})),this.updateWidth()}static get CATEGORY(){return c.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(h(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 it.create(this.textFont).maxHeight}updateWidth(){const t=it.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===Ct.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(O.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()},l=(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()},g=(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()},u=(t,i)=>{e.save(),e.setFont(this.textFont);const s=t-e.measureText(i).width/2;e.fillText(i,s,h),e.restore()};let p,m=0,f=0;if(null===(t=this.tap)||void 0===t?void 0:t.length){u(i.getModifierStartXY(O.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),f=e.draw_width+m-(1===t?n:0),e.type===Ct.UP&&(p&&p.type===Ct.UP&&g(s.x,r,1),c(s.x,s.y,f,r)),e.type===Ct.DOWN&&(p&&p.type===Ct.UP&&l(s.x,s.y,f,r),p&&p.type===Ct.DOWN&&(g(s.x,s.y,-1),l(s.x,s.y,f,r)),p||(f=e.draw_width,l(s.x,s.y,f,r))),u(s.x+f,e.text),p=e,m=e.draw_width,p.x=s.x,s.x+=f}if(!p||null==p.x)throw new d("NoLastBendForBend","Internal error.");p.type===Ct.UP?g(p.x+f,r,1):p.type===Ct.DOWN&&g(p.x+f,s.y,-1)}}function kt(...t){Dt.DEBUG&&u("Vex.Flow.ChordSymbol",t)}Ct.TEXT_FONT=Object.assign({},A.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"}(xt||(xt={})),function(t){t[t.TOP=1]="TOP",t[t.BOTTOM=2]="BOTTOM"}(St||(St={})),function(t){t[t.GLYPH=1]="GLYPH",t[t.TEXT=2]="TEXT",t[t.LINE=3]="LINE"}(yt||(yt={})),function(t){t[t.NONE=1]="NONE",t[t.SUBSCRIPT=2]="SUBSCRIPT",t[t.SUPERSCRIPT=3]="SUPERSCRIPT"}(Tt||(Tt={}));class Dt extends O{constructor(){super(),this.symbolBlocks=[],this.horizontal=xt.LEFT,this.vertical=St.TOP,this.useKerning=!0,this.reportWidth=!0,this.resetFont()}static get CATEGORY(){return c.ChordSymbol}static get superSubRatio(){return Dt.metrics.global.superSubRatio}static set NO_TEXT_FORMAT(t){Dt.noFormat=t}static get NO_TEXT_FORMAT(){return Dt.noFormat}static getMetricForGlyph(t){if(Dt.metrics[t])return Dt.metrics[t]}static get engravingFontResolution(){return K.currentMusicFont().getResolution()}static get spacingBetweenBlocks(){return Dt.metrics.global.spacing/Dt.engravingFontResolution}static getWidthForGlyph(t){const e=Dt.getMetricForGlyph(t.code);return e?e.advanceWidth/Dt.engravingFontResolution:.65}static getYShiftForGlyph(t){const e=Dt.getMetricForGlyph(t.code);return e?e.yOffset/Dt.engravingFontResolution:0}static getXShiftForGlyph(t){const e=Dt.getMetricForGlyph(t.code);return e?-1*e.leftSideBearing/Dt.engravingFontResolution:0}static get superscriptOffset(){return Dt.metrics.global.superscriptOffset/Dt.engravingFontResolution}static get subscriptOffset(){return Dt.metrics.global.subscriptOffset/Dt.engravingFontResolution}static get kerningOffset(){return Dt.metrics.global.kerningOffset/Dt.engravingFontResolution}static get metrics(){return K.currentMusicFont().getMetrics().glyphs.chordSymbol}static get lowerKerningText(){return Dt.metrics.global.lowerKerningText}static get upperKerningText(){return Dt.metrics.global.upperKerningText}static isSuperscript(t){return void 0!==t.symbolModifier&&t.symbolModifier===Tt.SUPERSCRIPT}static isSubscript(t){return void 0!==t.symbolModifier&&t.symbolModifier===Tt.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=k.convertSizeToPointValue(null===(i=o.textFont)||void 0===i?void 0:i.size),r=k.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=Dt.isSuperscript(e),a=Dt.isSubscript(e),l=i||a?Dt.superSubRatio:1,g=e.symbolType===yt.GLYPH?h*l:r*l;(i||a)&&(c=2);const u=o.textFormatter.fontSizeInPixels,p=u*l;if(e.symbolType===yt.GLYPH&&void 0!==e.glyph?(e.width=Dt.getWidthForGlyph(e.glyph)*p,e.yShift+=Dt.getYShiftForGlyph(e.glyph)*p,e.xShift+=Dt.getXShiftForGlyph(e.glyph)*p,e.glyph.scale=e.glyph.scale*g):e.symbolType===yt.TEXT&&(e.width=e.width*p,e.yShift+=o.getYOffsetForText(e.text)*g),e.symbolType===yt.GLYPH&&void 0!==e.glyph&&e.glyph.code===Dt.glyphs.over.code&&(c=2),e.width+=Dt.spacingBetweenBlocks*u*l,i&&t>0){const e=o.symbolBlocks[t-1];Dt.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()===St.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"===K.currentMusicFont().getName()&&(t="PetalumaScript, Arial, sans-serif"),{family:t,size:12,weight:b.NORMAL,style:w.NORMAL}}get superscriptOffset(){return Dt.superscriptOffset*this.textFormatter.fontSizeInPixels}get subscriptOffset(){return Dt.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===yt.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===yt.GLYPH&&void 0!==e.glyph&&e.glyph.code===Dt.glyphs.over.code&&(s+=e.glyph.metrics.x_shift),void 0!==i&&i.symbolType===yt.GLYPH&&void 0!==i.glyph&&i.glyph.code===Dt.glyphs.over.code&&(s+=i.glyph.metrics.x_shift);let n=!1,a=!1;void 0!==i&&i.symbolType===yt.TEXT&&(n=Dt.upperKerningText.some((t=>t===i.text[i.text.length-1])),a=Dt.lowerKerningText.some((t=>t===i.text[i.text.length-1])));const o=Dt.kerningOffset*this.textFormatter.fontSizeInPixels;return n&&e.symbolModifier===Tt.SUPERSCRIPT&&(s+=o),a&&e.symbolType===yt.TEXT&&(e.text[0]>="a"&&e.text[0]<="z"&&(s+=o/2),Dt.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:yt.TEXT,a={text:null!==(i=t.text)&&void 0!==i?i:"",symbolType:n,symbolModifier:null!==(s=t.symbolModifier)&&void 0!==s?s:Tt.NONE,xShift:0,yShift:0,vAlign:!1,width:0};if(n===yt.GLYPH&&"string"==typeof t.glyph){const e=Dt.glyphs[t.glyph],i=20;a.glyph=new R(e.code,i,{category:"chordSymbol"})}else n===yt.TEXT?a.width=this.textFormatter.getWidthForTextInEm(a.text):n===yt.LINE&&(a.width=t.width);return a}addSymbolBlock(t){return this.symbolBlocks.push(this.getSymbolBlock(t)),this}addText(t,e={}){const i=yt.TEXT;return this.addSymbolBlock(Object.assign(Object.assign({},e),{text:t,symbolType:i}))}addTextSuperscript(t){const e=yt.TEXT,i=Tt.SUPERSCRIPT;return this.addSymbolBlock({text:t,symbolType:e,symbolModifier:i})}addTextSubscript(t){const e=yt.TEXT,i=Tt.SUBSCRIPT;return this.addSymbolBlock({text:t,symbolType:e,symbolModifier:i})}addGlyphSuperscript(t){const e=yt.GLYPH,i=Tt.SUPERSCRIPT;return this.addSymbolBlock({glyph:t,symbolType:e,symbolModifier:i})}addGlyph(t,e={}){const i=yt.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];Dt.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=yt.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=it.create(this.textFont),this}setEnableKerning(t){return this.useKerning=t,this}setVertical(t){return this.vertical="string"==typeof t?Dt.VerticalJustifyString[t]:t,this}getVertical(){return this.vertical}setHorizontal(t){return this.horizontal="string"==typeof t?Dt.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(O.Position.ABOVE,this.index);let n;t.setFont(this.textFont);const a=e.hasStem(),o=e.checkStave();if(this.vertical===St.BOTTOM){if(n=o.getYForBottomText(this.text_line+K.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===xt.LEFT?s.x:this.horizontal===xt.RIGHT?s.x+this.getWidth():this.horizontal===xt.CENTER?s.x-this.getWidth()/2:e.getStemX()-this.getWidth()/2,kt("Rendering ChordSymbol: ",this.textFormatter,r,n),this.symbolBlocks.forEach((e=>{const i=Dt.isSuperscript(e),s=Dt.isSubscript(e);let a=n;if(kt("shift was ",e.xShift,e.yShift),kt("curY pre sub ",a),i&&(a+=this.superscriptOffset),s&&(a+=this.subscriptOffset),kt("curY sup/sub ",a),e.symbolType===yt.TEXT){if((i||s)&&(t.save(),this.textFont)){const{family:e,size:i,weight:s,style:n}=this.textFont,a=k.scaleSize(i,Dt.superSubRatio);t.setFont(e,a,s,n)}kt("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===yt.GLYPH&&e.glyph?(a+=e.yShift,kt("Rendering Glyph: ",e.glyph.code,r+e.xShift,a),e.glyph.render(t,r+e.xShift,a)):e.symbolType===yt.LINE&&(kt("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()}}Dt.DEBUG=!1,Dt.HorizontalJustify=xt,Dt.HorizontalJustifyString={left:xt.LEFT,right:xt.RIGHT,center:xt.CENTER,centerStem:xt.CENTER_STEM},Dt.VerticalJustify=St,Dt.VerticalJustifyString={top:St.TOP,above:St.TOP,below:St.BOTTOM,bottom:St.BOTTOM},Dt.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"}},Dt.symbolTypes=yt,Dt.symbolModifiers=Tt,Dt.noFormat=!1;class Nt extends O{constructor(){super(),this.position=O.Position.RIGHT,this.radius=2,this.setWidth(5),this.dot_shiftY=0}static get CATEGORY(){return c.Dot}static getDots(t){return t.getModifiersByType(Nt.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 Nt;e.setDotShiftY(i.glyph.dot_shiftY),i.addModifier(e,t)}else if(null!=(null==e?void 0:e.index)){const t=new Nt;t.setDotShiftY(i.glyph.dot_shiftY),i.addModifier(t,null==e?void 0:e.index)}else{const t=new Nt;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],r=a.getNote();let c,l;if(o(r)){const t=a.checkIndex();c=r.getKeyProps()[t],l=r.getFirstDotPx()}else{if(!h(r))throw new d("Internal","Unexpected instance.");c={line:.5},l=i}const g=r.getAttribute("id");s.push({line:c.line,note:r,note_id:g,dot:a}),n[g]=Math.max(n[g]||l,l)}s.sort(((t,e)=>e.line-t.line));let a=i,r=0,c=null,l=null,g=null,u=0;for(let t=0;t<s.length;++t){const{dot:e,note:i,note_id:o,line:h}=s[t];h===c&&i===l||(a=n[o]),i.isRest()||h===c||(.5===Math.abs(h%1)?u=0:(u=.5,null==l||l.isRest()||null==c||c-h!=.5?h+u===g&&(u=-.5):u=-.5)),i.isRest()?e.dot_shiftY+=-u:e.dot_shiftY=-u,g=h+u,e.setXShift(a),a+=e.getWidth()+1,r=a>r?a:r,c=h,l=i}return e.right_shift+=r,!0}setNote(t){return this.note=t,n(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});h(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 At extends O{constructor(t){super(),this.finger=t,this.width=7,this.position=O.Position.LEFT,this.x_shift=0,this.y_shift=0,this.x_offset=0,this.y_offset=0,this.resetFont()}static get CATEGORY(){return c.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=it.create(c.textFont).maxHeight;if(c.position===P.ABOVE&&(e.top_text_line+=p/K.STAVE_LINE_DISTANCE+.5),c.position===P.BELOW&&(e.text_line+=p/K.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===O.Position.LEFT?(p.setXShift(i+h),e=i+x,d=e>d?e:d):o===O.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 O.Position.ABOVE:s-=4,n-=12;break;case O.Position.BELOW:s-=2,n+=10;break;case O.Position.LEFT:s-=this.width;break;case O.Position.RIGHT:s+=1;break;default:throw new d("InvalidPosition",`The position ${this.position} does not exist`)}t.save(),t.setFont(this.textFont),t.fillText(""+this.finger,s,n),t.restore()}}At.TEXT_FONT={family:k.SANS_SERIF,size:9,weight:b.BOLD,style:w.NORMAL};class Ft extends A{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 c.StaveTie}setDirection(t){return this.direction=t,this}setNotes(t){if(!t.first_note&&!t.last_note)throw new d("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 d("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 d("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 l=(t.last_x_px+a+(t.first_x_px+n))/2,g=t.first_ys[r[c]]+o,u=t.last_ys[h[c]]+o;if(isNaN(g)||isNaN(u))throw new d("BadArguments","Bad indices for tie rendering.");const p=(g+u)/2+i*t.direction,m=(g+u)/2+s*t.direction;e.beginPath(),e.moveTo(t.first_x_px+n,g),e.quadraticCurveTo(l,p,t.last_x_px+a,u),e.quadraticCurveTo(l,m,t.first_x_px+n,g),e.closePath(),e.fill()}}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}}Ft.TEXT_FONT=Object.assign({},A.TEXT_FONT);class Pt extends Ft{static get CATEGORY(){return c.TabTie}static createHammeron(t){return new Pt(t,"H")}static createPulloff(t){return new Pt(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"}(bt||(bt={}));class Bt extends A{constructor(t,e){let i;if(super(),this.resolutionMultiplier=1,this.mode=bt.STRICT,this.preFormatted=!1,this.ticksUsed=new x(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:K.RESOLUTION},i),this.totalTicks=new x(this.time.num_beats*(this.time.resolution/this.time.beat_value),1),this.smallestTickCount=this.totalTicks.clone()}static get CATEGORY(){return c.Voice}static get Mode(){return bt}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?bt.STRICT:bt.SOFT,this}isComplete(){return this.mode!==bt.STRICT&&this.mode!==bt.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===bt.STRICT||this.mode===bt.FULL)&&this.ticksUsed.greaterThan(this.totalTicks))throw this.ticksUsed.subtract(e),new d("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 g(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),g(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 Mt extends O{constructor(t,e){return super(),this.preFormatted=!1,this.position=O.Position.LEFT,this.grace_notes=t,this.width=0,this.show_slur=e,this.slur=void 0,this.voice=new Bt({num_beats:4,beat_value:4,resolution:K.RESOLUTION}).setStrict(!1),this.render_options={slur_y_shift:0},this.beams=[],this.voice.addTickables(this.grace_notes),this}static get CATEGORY(){return c.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],r=a.getNote(),h=o(r),c=h?4:0;if(h&&r!==s){for(let t=0;t<r.keys.length;++t)n=Math.max(r.getLeftDisplacedHeadPx(),n);s=r}i.push({shift:n,gracenote_group:a,spacing:c})}let a,r=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,r=Math.max(a,r)}for(let t=0;t<i.length;++t){const e=i[t].gracenote_group;a=e.getWidth()+i[t].spacing,e.setSpacingFromNextModifier(r-Math.min(a,r))}return e.left_shift+=r,!0}preFormat(){this.preFormatted||(this.formatter||(this.formatter=new we),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 Ne(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){Mt.DEBUG&&u("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=o(e),s=i?Ft:Pt;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()}}}Mt.DEBUG=!1;class Rt extends O{constructor(t){super(),this.preFormatted=!1,this.position=O.Position.LEFT,this.subNotes=t,this.subNotes.forEach((t=>{t.setIgnoreTicks(!1)})),this.width=0,this.formatter=new we,this.voice=new Bt({num_beats:4,beat_value:4,resolution:K.RESOLUTION}).setStrict(!1),this.voice.addTickables(this.subNotes)}static get CATEGORY(){return c.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 Ot{constructor(t){this.preFormatted=!1,this.postFormatted=!1,this.tickID=t&&t.tickID?t.tickID:0,this.currentTick=new x(0,1),this.maxTicks=new x(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 d("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 Lt extends O{constructor(t){super(),this.type=t,this.delayed=!1,this.render_options={font_scale:38,accidentalLowerPadding:3,accidentalUpperPadding:3},this.ornament=K.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=Lt.ornamentAlignWithNoteHead.indexOf(this.type)>=0,!this.ornament)throw new d("ArgumentError",`Ornament not found: '${this.type}'`);this.x_shift=e?e.xOffset:0,this.y_shift=e?e.yOffset:0,this.glyph=new R(this.ornament.code,this.render_options.font_scale,{category:`ornament.${this.ornament.code}`}),Lt.ornamentNoteTransition.indexOf(this.type)>=0&&(this.delayed=!0),e||this.glyph.setOrigin(.5,1)}static get CATEGORY(){return c.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(Lt.ornamentRelease.indexOf(r.type)>=0&&(r.x_shift+=s+2),Lt.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),Lt.ornamentArticulation.indexOf(r.type)>=0){g(r.note,"NoAttachedNote").getLineNumber()>=3||r.getPosition()===O.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()===O.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 K.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 R(K.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 R(K.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===Q.DOWN?a.baseY:a.topY;h(e)&&(e.hasStem()?i===Q.DOWN&&(o=s.getYForTopText(this.text_line)):o=s.getYForTopText(this.text_line));const r=i===Q.DOWN,c=s.getSpacingBetweenLines();let d=1;!r&&e.hasBeam()&&(d+=.5);const l=o-c*(this.text_line+d),g=e.getModifierStartXY(this.position,this.index);let p=g.x,m=this.ornamentAlignWithNoteHead?g.y:Math.min(s.getYForTopText(this.text_line),l);if(m+=this.y_shift,this.delayed){let t=0;const i=p-(s.getX()-10);if(void 0!==this.delayXShift)t=this.delayXShift;else{t+=this.glyph.getMetrics().width/2;const n=Ot.getNextContext(e.getTickContext());t+=n?.5*(n.getX()-i):.5*(s.getX()+s.getWidth()-i),this.delayXShift=t}p+=t}!function(...t){Lt.DEBUG&&u("Vex.Flow.Ornament",t)}("Rendering ornament: ",this.ornament,p,m),this.accidentalLower&&(this.accidentalLower.render(t,p,m),m-=this.accidentalLower.getMetrics().height,m-=this.render_options.accidentalLowerPadding),this.stemUpYOffset&&e.hasStem()&&1===e.getStemDirection()&&(m+=this.stemUpYOffset),e.getLineNumber()<5&&Lt.ornamentNoteTransition.indexOf(this.type)>=0&&(m=e.checkStave().getBoundingBox().getY()+40),this.glyph.render(t,p+this.x_shift,m),this.accidentalUpper&&(m-=this.glyph.getMetrics().height+this.render_options.accidentalUpperPadding,this.accidentalUpper.render(t,p,m)),t.closeGroup()}}Lt.DEBUG=!1;class It extends O{constructor(t){super(),this.position=null!=t?t:O.Position.LEFT,this.point=K.currentMusicFont().lookupMetric("parenthesis.default.point"),this.setWidth(K.currentMusicFont().lookupMetric("parenthesis.default.width"))}static get CATEGORY(){return c.Parenthesis}static buildAndAttach(t){for(const e of t)for(let t=0;t<e.keys.length;t++)e.addModifier(new It(P.LEFT),t),e.addModifier(new It(P.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===P.RIGHT&&(h=a.getRightParenthesisPx(r),s=s>h+n.width?s:h+n.width),o===P.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=K.currentMusicFont().lookupMetric("parenthesis.default.point"),this.setWidth(K.currentMusicFont().lookupMetric("parenthesis.default.width")),n(t)&&(this.point=K.currentMusicFont().lookupMetric("parenthesis.gracenote.point"),this.setWidth(K.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==O.Position.RIGHT?R.renderGlyph(t,s+1,n,this.point,"noteheadParenthesisRight",{category:"noteHead.standard.noteheadParenthesisRight"}):this.position==O.Position.LEFT&&R.renderGlyph(t,s-2,n,this.point,"noteheadParenthesisLeft",{category:"noteHead.standard.noteheadParenthesisLeft"})}}class Wt extends mt{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||Q.UP,this.line=t.line||0,this.glyph=K.getGlyphProps(this.duration,this.noteType),g(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||K.NOTATION_FONT_SCALE}),this.setWidth(this.glyph.getWidth(this.render_options.glyph_font_scale))}static get CATEGORY(){return c.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=Q.WIDTH/2,i=K.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 d("UnformattedNote","Can't call getBoundingBox on an unformatted note.");const t=this.checkStave().getSpacingBetweenLines(),e=t/2,i=this.y-e;return new y(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===Q.UP?this.stem_up_x_offset:this.stem_down_x_offset);const i=this.y;!function(...t){Wt.DEBUG&&u("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===Q.UP?"Up":"Down"}`;if("s"===this.noteType){const n=this.checkStave().getSpacingBetweenLines();!function(t,e,i,s,n,a){const o=K.SLASH_NOTEHEAD_WIDTH;t.save(),t.setLineWidth(K.STEM_WIDTH);let r=!1;if(K.durationToNumber(e)>2&&(r=!0),r||(i-=K.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(),K.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 R.renderGlyph(t,e,i,n,this.glyph_code,{category:this.custom_glyph?`noteHead.custom.${a}`:`noteHead.standard.${a}`});this.style&&this.restoreStyle(t)}}Wt.DEBUG=!1;class Gt extends mt{constructor(t){super(t)}static get CATEGORY(){return c.StemmableNote}getStem(){return this.stem}checkStem(){if(!this.stem)throw new d("NoStem","No stem attached to instance");return this.stem}setStem(t){return this.stem=t,this}buildStem(){const t=new Q;return this.setStem(t),this}buildFlag(t="flag"){const{glyph:e}=this;if(this.hasFlag()){const i=this.getStemDirection()===Q.DOWN?e.code_flag_downstem:e.code_flag_upstem;this.flag=new R(i,this.render_options.glyph_font_scale,{category:t})}}getBaseCustomNoteHeadGlyph(){return this.getStemDirection()===Q.DOWN?this.customGlyphs[this.customGlyphs.length-1]:this.customGlyphs[0]}getStemLength(){return Q.HEIGHT+this.getStemExtension()}getBeamCount(){const t=this.getGlyph();return t?t.beam_count:0}getStemMinimumLength(){let t=K.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 d("NoStem","No stem attached to this note.");return this.stem_direction}setStemDirection(t){if(t||(t=Q.UP),t!==Q.UP&&t!==Q.DOWN)throw new d("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=K.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===Q.DOWN?t:e}getCenterGlyphX(){return this.getAbsoluteX()+this.x_shift+this.getGlyphWidth()/2}getStemExtension(){const t=this.getGlyph();if(null!=this.stem_extension_override)return this.stem_extension_override;if(this.beam)return t.stem_beam_extension;const e=this.getStemDirection()===Q.DOWN?this.glyph.code_flag_downstem:this.glyph.code_flag_upstem;return Math.abs(K.currentMusicFont().lookupMetric(`glyphs.flag.${e}.shiftY`,0))}setStemLength(t){return this.stem_extension_override=t-Q.HEIGHT,this}getStemExtents(){if(!this.stem)throw new d("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 d("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 d("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 K.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 Q(t)),null===(e=this.stem)||void 0===e||e.setContext(this.getContext()).draw()}}function Ut(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 Yt extends Gt{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=K.getGlyphProps(this.duration,this.noteType),g(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||K.NOTATION_FONT_SCALE,stroke_px:t.stroke_px||Yt.LEDGER_LINE_OFFSET}),this.calculateKeyProps(),this.buildStem(),t.auto_stem?this.autoStem():this.setStemDirection(null!==(s=t.stem_direction)&&void 0!==s?s:Q.UP),this.reset(),this.buildFlag()}static get CATEGORY(){return c.StaveNote}static get STEM_UP(){return Q.UP}static get STEM_DOWN(){return Q.DOWN}static get LEDGER_LINE_OFFSET(){return 3}static get minNoteheadPadding(){return K.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.stemDirection===o.stemDirection?0:.5;return n.minLine<=o.maxLine+t&&(n.isrest?Ut(n,0,1):o.isrest?Ut(o,0,-1):n.stemDirection===o.stemDirection?(h=r+2,n.note.setXShift(h)):(h=r+2,o.note.setXShift(h))),e.right_shift+=h,!0}if(!a)throw new d("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-m(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?(Ut(n,0,1),Ut(o,0,-1),e.right_shift+=h,!0):(a.isrest&&n.isrest&&a.minLine<=o.maxLine&&Ut(a,0,1),a.isrest&&o.isrest&&n.minLine<=a.maxLine&&Ut(a,0,-1),n.isrest&&n.minLine<=a.maxLine&&Ut(n,0,1),o.isrest&&a.minLine<=o.maxLine&&Ut(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 Q({hide:!!this.isRest()})),this}buildNoteHeads(){this._noteHeads=[];const t=this.getStemDirection(),e=this.getKeys();let i,s,n,a,o,r=!1;t===Q.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 Wt({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?Q.UP:Q.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=K.keyProperties(i,this.clef,s);if(!n)throw new d("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&&p("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 d("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=K.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 y(a,o,i,r-o)}getLineNumber(t){if(!this.keyProps.length)throw new d("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?Q.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=m(Math.max(t,e),Math.min(t,e))}return t}getModifierStartXY(t,e,i={}){var s,n;if(!this.preFormatted)throw new d("UnformattedNote","Can't call GetModifierStartXY on an unformatted note");if(0===this.ys.length)throw new d("NoYValues","No Y-Values calculated for this note.");const{ABOVE:a,BELOW:o,LEFT:r,RIGHT:h}=O.Position;let c=0;return t===r?c=-2:t===h?(c=this.getGlyphWidth()+this.x_shift+2,this.stem_direction===Q.UP&&this.hasFlag()&&(i.forceFlagRight||((t,e)=>e===(t.getStemDirection()===Q.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){var e;return super.setStyle(t),this._noteHeads.forEach((e=>e.setStyle(t))),null===(e=this.stem)||void 0===e||e.setStyle(t),this}setStemStyle(t){const e=this.getStem();return null==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===Q.DOWN?this.getGlyphWidth():0),this.setRightDisplacedHeadPx(!this.hasFlag()&&this.displaced&&this.stem_direction===Q.UP?this.getGlyphWidth():0)}preFormat(){if(this.preFormatted)return;let t=0;this.modifierContext&&(this.modifierContext.preFormat(),0===this.modifierContext.getWidth()&&(t=Yt.minNoteheadPadding));let e=this.getGlyphWidth()+this.leftDisplacedHeadPx+this.rightDisplacedHeadPx+t;this.shouldDrawFlag()&&this.stem_direction===Q.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)-Q.WIDTH/2;if(this.isRest())return;if(!s)throw new d("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:l,lowest_non_displaced_line:g,displaced_x:u,non_displaced_x:p}=this.getNoteHeadBounds();if(o<6&&r>0)return;const m=Math.min(null!=u?u:0,null!=p?p:0),f=(t,e,o)=>{let r;r=o&&e?m-i:e?(null!=p?p:0)-i:(null!=u?u: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!==p&&e<=c,s=void 0!==h&&e<=h;f(t.getYForNote(e),i,s)}for(let e=0;e>=r;--e){const i=void 0!==p&&e>=g,s=void 0!==l&&e>=l;f(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;const e=this.checkContext();if(!e)throw new d("NoCanvasContext","Can't draw without a canvas context.");if(this.shouldDrawFlag()){const{y_top:i,y_bottom:s}=this.getNoteHeadBounds(),n=this.stem.getHeight(),a=this.getStemX(),o=void 0!==this.flag?this.flag.checkMetrics().y_shift:0,r=this.getStemDirection()===Q.DOWN?i-n+2-o:s-n-2-o;e.openGroup("flag",void 0,{pointerBBox:!0}),this.applyStyle(e,this.getFlagStyle()),null===(t=this.flag)||void 0===t||t.render(e,a,r),this.restoreStyle(e,this.getFlagStyle()),e.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){var e;const i=this.checkContext();t&&this.setStem(new Q(t)),this.shouldDrawFlag()&&this.stem&&this.stem.adjustHeightForFlag(),i.openGroup("stem",void 0,{pointerBBox:!0}),null===(e=this.stem)||void 0===e||e.setContext(i).draw(),i.closeGroup()}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===Q.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(){var t;if(0===this.ys.length)throw new d("NoYValues","Can't draw note without Y values.");const e=this.checkContext(),i=this.getNoteHeadBeginX(),s=this.hasStem()&&!this.beam;this._noteHeads.forEach((t=>t.setX(i)));const n=this.getStemX();null===(t=this.stem)||void 0===t||t.setNoteHeadXBounds(n,n),function(...t){Yt.DEBUG&&u("Vex.Flow.StaveNote",t)}("Rendering ",this.isChord()?"chord :":"note :",this.keys),this.applyStyle(),this.setAttribute("el",e.openGroup("stavenote",this.getAttribute("id"))),this.drawLedgerLines(),e.openGroup("note",void 0,{pointerBBox:!0}),s&&this.drawStem(),this.drawNoteHeads(),this.drawFlag(),e.closeGroup(),this.drawModifiers(),e.closeGroup(),this.restoreStyle(),this.setRendered()}}function jt(t){if(!t)return!1;const e=l();return"function"==typeof e.HTMLCanvasElement&&t instanceof e.HTMLCanvasElement||"function"==typeof t.getContext&&"function"==typeof t.toDataURL}Yt.DEBUG=!1;class Ht extends ut{constructor(t){super(),this.textHeight=0,this.context2D=t,t.canvas?this.canvas=t.canvas:this.canvas={width:Ht.WIDTH,height:Ht.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&&(p("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=l().devicePixelRatio||1;return[t,e]=Ht.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=k.validate(t,e,i,s);return this.context2D.font=k.toCSSString(n),this.textHeight=k.convertSizeToPixelValue(n.size),this}getFont(){return this.context2D.font}}const Xt={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}},Vt="http://www.w3.org/2000/svg",zt=2*Math.PI;class Kt extends ut{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":k.SANS_SERIF,"font-size":k.SIZE+"pt","font-weight":b.NORMAL,"font-style":w.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(Vt,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",f(t)),e&&s.setAttribute("id",f(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 d("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=Xt[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>=zt||a&&s-n>=zt){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=_(s),n=_(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 Kt.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=k.validate(t,e,i,s);this.fontCSSString=k.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 $t,qt,Jt,Qt;Kt.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(Vt,"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"}($t||($t={})),function(t){t[t.NONE=1]="NONE",t[t.UP=2]="UP",t[t.DOWN=3]="DOWN"}(qt||(qt={}));class Zt{constructor(t,e){if(i(t,c.RenderContext))this.ctx=t;else{if(void 0===e)throw new d("InvalidArgument","Missing backend argument");const i=e;let s;if("string"==typeof t){const e=document.getElementById(t);if(!e)throw new d("BadElementId",`Can't find element with ID "${e}"`);s=e}else s=t;if(i===Zt.Backends.CANVAS){if(!jt(s))throw new d("BadElement","CANVAS context requires an HTMLCanvasElement.");const t=s.getContext("2d");if(!t)throw new d("BadElement","Can't get canvas context");this.ctx=new Ht(t)}else{if(i!==Zt.Backends.SVG)throw new d("InvalidBackend",`No support for backend: ${i}`);if(!function(t){if(!t)return!1;const e=l();return"function"==typeof e.HTMLDivElement&&t instanceof e.HTMLDivElement||"function"==typeof t.appendChild&&"object"==typeof t.style}(s))throw new d("BadElement","SVG context requires an HTMLDivElement.");this.ctx=new Kt(s)}}}static buildContext(t,e,i,s,n="#FFF"){const a=new Zt(t,e);i&&s&&a.resize(i,s);const o=a.getContext();return o.setBackgroundFillStyle(n),Zt.lastContext=o,o}static getCanvasContext(t,e,i,s){return Zt.buildContext(t,Zt.Backends.CANVAS,e,i,s)}static getSVGContext(t,e,i,s){return Zt.buildContext(t,Zt.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}}Zt.Backends=$t,Zt.LineEndType=qt,Zt.lastContext=void 0;class te extends O{constructor(t){super(),this.string_number=t,this.setWidth(20),this.position=O.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=Zt.LineEndType.NONE,this.radius=8,this.resetFont()}static get CATEGORY(){return c.StringNumber}static get metrics(){return K.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,r=0,h=0;for(let c=0;c<t.length;++c){const l=t[c],g=l.getNote(),u=l.getPosition();if(!o(g))throw new d("NoStaveNote");const p=l.checkIndex(),m=g.getKeyProps()[p],f=g.getModifierContext(),_=2*l.radius/K.STAVE_LINE_DISTANCE+.5;if(f&&(u===P.ABOVE?(l.text_line=f.getState().top_text_line,e.top_text_line+=_):u===P.BELOW&&(l.text_line=f.getState().text_line,e.text_line+=_)),g!==a){for(let t=0;t<g.keys.length;++t)0===i&&(r=Math.max(g.getLeftDisplacedHeadPx(),r)),0===s&&(h=Math.max(g.getRightDisplacedHeadPx(),h));a=g}const x=m.line;n.push({pos:u,note:g,num:l,line:x,shiftL:r,shiftR:h})}n.sort(((t,e)=>e.line-t.line));let c=0,l=0,g=0,u=null,p=null;for(let t=0;t<n.length;++t){let e=0;const a=n[t].note,o=n[t].pos,h=n[t].num,d=n[t].line,m=n[t].shiftR;d===u&&a===p||(c=s+m);const f=h.getWidth()+1;o===O.Position.LEFT?(h.setXShift(i),e=r+f,l=e>l?e:l):o===O.Position.RIGHT&&(h.setXShift(c),e+=f,g=e>g?e:g),u=d,p=a}return e.left_shift+=l,e.right_shift+=g,!0}setLineEndType(t){return t>=Zt.LineEndType.NONE&&t<=Zt.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():Q.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 O.Position.ABOVE:o=e.getYs().reduce(((t,e)=>t<e?t:e)),e.hasStem()&&s==Q.UP&&(o=a.topY+te.metrics.stemPadding),o-=this.radius+te.metrics.verticalPadding+this.text_line*K.STAVE_LINE_DISTANCE;break;case O.Position.BELOW:o=e.getYs().reduce(((t,e)=>t>e?t:e)),e.hasStem()&&s==Q.DOWN&&(o=a.topY-te.metrics.stemPadding),o+=this.radius+te.metrics.verticalPadding+this.text_line*K.STAVE_LINE_DISTANCE;break;case O.Position.LEFT:n-=this.radius/2+te.metrics.leftPadding;break;case O.Position.RIGHT:n+=this.radius/2+te.metrics.rightPadding;break;default:throw new d("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 h=n-t.measureText(this.string_number).width/2;t.fillText(""+this.string_number,h,o+4.5);const c=this.last_note;if(r(c)){const i=c.getStemX()-e.getX()+5;let s,a;switch(t.setStrokeStyle("#000000"),t.setLineCap("round"),t.setLineWidth(.6),this.dashed?Zt.drawDashedLine(t,n+10,o,n+i,o,[3,3]):Zt.drawDashedLine(t,n+10,o,n+i,o,[3,0]),this.leg){case Zt.LineEndType.UP:s=-10,a=this.dashed?[3,3]:[3,0],Zt.drawDashedLine(t,n+i,o,n+i,o+s,a);break;case Zt.LineEndType.DOWN:s=10,a=this.dashed?[3,3]:[3,0],Zt.drawDashedLine(t,n+i,o,n+i,o+s,a)}}t.restore()}}te.TEXT_FONT={family:k.SANS_SERIF,size:k.SIZE,weight:b.BOLD,style:w.NORMAL};class ee extends O{constructor(t,e){super(),this.options=Object.assign({all_voices:!0},e),this.all_voices=this.options.all_voices,this.type=t,this.position=O.Position.LEFT,this.render_options={font_scale:38},this.resetFont(),this.setXShift(0),this.setWidth(10)}static get CATEGORY(){return c.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(o(e)){const{line:s}=e.getKeyProps()[i];return{line:s,shift:e.getLeftDisplacedHeadPx(),stroke:t}}if(h(e)){const{str:s}=e.getPositions()[i];return{line:s,shift:0,stroke:t}}throw new d("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,r=i.y;const h=i.x-5,c=e.checkStave().getSpacingBetweenLines(),l=this.checkModifierContext().getMembers(e.getCategory());for(let t=0;t<l.length;t++){const e=l[t];if(a(e)){s=e.getYs();for(let e=0;e<s.length;e++)(this.note===l[t]||this.all_voices)&&(n=Math.min(n,s[e]),r=Math.max(r,s[e]))}}let g="",u=0,p=0,m=0,f=0;switch(this.type){case ee.Type.BRUSH_DOWN:g="arrowheadBlackUp",u=-3,p=n-c/2+10,r+=c/2;break;case ee.Type.BRUSH_UP:g="arrowheadBlackDown",u=.5,p=r+c/2,n-=c/2;break;case ee.Type.ROLL_DOWN:case ee.Type.RASQUEDO_DOWN:g="arrowheadBlackUp",u=-3,m=this.x_shift+u-2,o(e)?(n+=1.5*c,r+=(r-n)%2!=0?.5*c:c,p=n-c,f=r+c+2):(n+=1.5*c,r+=c,p=n-.75*c,f=r+.25*c);break;case ee.Type.ROLL_UP:case ee.Type.RASQUEDO_UP:g="arrowheadBlackDown",u=-4,m=this.x_shift+u-1,o(e)?(p=c/2,n+=.5*c,(r-n)%2==0&&(r+=c/2),p=r+.5*c,f=n-1.25*c):(n+=.25*c,r+=.5*c,p=r+.25*c,f=n-c);break;case ee.Type.ARPEGGIO_DIRECTIONLESS:n+=.5*c,r+=c;break;default:throw new d("InvalidType",`The stroke type ${this.type} does not exist`)}let _="straight";if(this.type===ee.Type.BRUSH_DOWN||this.type===ee.Type.BRUSH_UP)t.fillRect(h+this.x_shift,n,1,r-n);else if(_="wiggly",o(e))for(let e=n;e<=r;e+=c)R.renderGlyph(t,h+this.x_shift-4,e,this.render_options.font_scale,"vexWiggleArpeggioUp");else{let e;for(e=n;e<=r;e+=10)R.renderGlyph(t,h+this.x_shift-4,e,this.render_options.font_scale,"vexWiggleArpeggioUp");this.type===ee.Type.RASQUEDO_DOWN&&(f=e+.25*c)}this.type!==ee.Type.ARPEGGIO_DIRECTIONLESS&&(R.renderGlyph(t,h+this.x_shift+u,p,this.render_options.font_scale,g,{category:`stroke.${g}.${_}`}),this.type!==ee.Type.RASQUEDO_DOWN&&this.type!==ee.Type.RASQUEDO_UP||(t.save(),t.setFont(this.textFont),t.fillText("R",h+m,f),t.restore()))}}ee.Type={BRUSH_DOWN:1,BRUSH_UP:2,ROLL_DOWN:3,ROLL_UP:4,RASQUEDO_DOWN:5,RASQUEDO_UP:6,ARPEGGIO_DIRECTIONLESS:7},ee.TEXT_FONT={family:k.SERIF,size:k.SIZE,weight:b.BOLD,style:w.ITALIC};class ie extends O{constructor(){super(),this.position=O.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 c.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(Ct.CATEGORY);if(o&&o.length>0){s-=o.map((t=>t.getTextHeight())).reduce(((t,e)=>t>e?t:e))/K.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(O.Position.RIGHT,this.index).x+this.x_shift,s=e.getYForTopText(this.text_line)+2;ie.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 se(...t){ne.DEBUG&&u("Vex.Flow.ModifierContext",t)}class ne{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 se("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 se("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 d("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;se("Preformatting ModifierContext");const t=this.state,e=this.members;Yt.format(e[c.StaveNote],t),It.format(e[c.Parenthesis],t),Nt.format(e[c.Dot],t),At.format(e[c.FretHandFinger],t),J.format(e[c.Accidental],t),ee.format(e[c.Stroke],t),Mt.format(e[c.GraceNoteGroup],t),Rt.format(e[c.NoteSubGroup],t),te.format(e[c.StringNumber],t),gt.format(e[c.Articulation],t),Lt.format(e[c.Ornament],t),at.format(e[c.Annotation],t),Dt.format(e[c.ChordSymbol],t),Ct.format(e[c.Bend],t),ie.format(e[c.Vibrato],t,this),this.width=t.left_shift+t.right_shift,this.preFormatted=!0}postFormat(){this.postFormatted||(se("Postformatting ModifierContext"),Yt.postFormat(this.getMembers(c.StaveNote)))}}ne.DEBUG=!1;class ae extends wt{constructor(t,e,i){super(),this.clef=ae.types.treble,this.setPosition(ft.BEGIN),this.setType(t,e,i),this.setWidth(K.currentMusicFont().lookupMetric(`clef.${this.size}.width`)),function(...t){ae.DEBUG&&u("Vex.Flow.Clef",t)}("Creating clef:",t)}static get CATEGORY(){return c.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=ae.types[t],this.size=void 0===e?"default":e;const s=K.currentMusicFont();if(this.clef.point=s.lookupMetric(`clef.${this.size}.point`,0),this.glyph=new R(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 R(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&&g(this.stave,"ClefError","Can't get width without stave."),this.width}setStave(t){if(this.stave=t,"tab"===this.type){const t=g(this.glyph,"ClefError","Can't set stave without glyph."),e=this.stave.getNumLines(),i=K.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=g(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()}}ae.DEBUG=!1;class oe extends wt{constructor(t,e,i){super(),this.accList=[],this.setKeySig(t,e,i),this.setPosition(ft.BEGIN),this.glyphFontScale=38,this.glyphs=[],this.xPositions=[],this.paddingForced=!1}static get CATEGORY(){return c.KeySignature}convertToGlyph(t,e){const i=K.accidentalCodes(t.type),s=new R(i.code,this.glyphFontScale);let n=1;if("n"===t.type&&e){const i=oe.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=K.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=K.keySignature(g(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===ft.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()}}oe.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 re extends wt{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 c.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 re.type.CODA_RIGHT:this.drawCodaFixed(t,e+t.getWidth());break;case re.type.CODA_LEFT:this.drawSymbolText(t,e,"Coda",!0);break;case re.type.SEGNO_LEFT:this.drawSignoFixed(t,e);break;case re.type.SEGNO_RIGHT:this.drawSignoFixed(t,e+t.getWidth());break;case re.type.DC:this.drawSymbolText(t,e,"D.C.",!1);break;case re.type.DC_AL_CODA:this.drawSymbolText(t,e,"D.C. al",!0);break;case re.type.DC_AL_FINE:this.drawSymbolText(t,e,"D.C. al Fine",!1);break;case re.type.DS:this.drawSymbolText(t,e,"D.S.",!1);break;case re.type.DS_AL_CODA:this.drawSymbolText(t,e,"D.S. al",!0);break;case re.type.DS_AL_FINE:this.drawSymbolText(t,e,"D.S. al Fine",!1);break;case re.type.FINE:this.drawSymbolText(t,e,"Fine",!1);break;case re.type.TO_CODA:this.drawSymbolText(t,e,"To",!0)}return this}drawCodaFixed(t,e){const i=t.getYForTopText(t.getNumLines())+this.y_shift;return R.renderGlyph(t.checkContext(),this.x+e+this.x_shift,i+K.currentMusicFont().lookupMetric("staveRepetition.default.offsetY"),40,"coda",{category:"coda"}),this}drawSignoFixed(t,e){const i=t.getYForTopText(t.getNumLines())+this.y_shift;return R.renderGlyph(t.checkContext(),this.x+e+this.x_shift,i+K.currentMusicFont().lookupMetric("staveRepetition.default.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 re.type.CODA_LEFT:a=this.x+t.getVerticalBarWidth(),o=a+n.measureText(i).width+K.currentMusicFont().lookupMetric("staveRepetition.default.offsetSymbol");break;case re.type.DC:case re.type.DC_AL_FINE:case re.type.DS:case re.type.DS_AL_FINE:case re.type.FINE:a=this.x+e+this.x_shift+t.getWidth()-K.currentMusicFont().lookupMetric("staveRepetition.default.spacing")-r-n.measureText(i).width;break;default:a=this.x+e+this.x_shift+t.getWidth()-K.currentMusicFont().lookupMetric("staveRepetition.default.spacing")-r-n.measureText(i).width-K.currentMusicFont().lookupMetric("staveRepetition.default.offsetSymbol"),o=a+n.measureText(i).width+K.currentMusicFont().lookupMetric("staveRepetition.default.offsetSymbol")}const h=t.getYForTopText(t.getNumLines())+this.y_shift+K.currentMusicFont().lookupMetric("staveRepetition.default.offsetY");return s&&R.renderGlyph(n,o,h,40,"coda",{category:"coda"}),n.fillText(i,a,h+5),n.restore(),this}}re.TEXT_FONT={family:k.SERIF,size:12,weight:b.BOLD,style:w.NORMAL},re.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 he extends wt{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 c.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}}he.TEXT_FONT={family:k.SANS_SERIF,size:10,weight:b.BOLD,style:w.NORMAL};class ce extends wt{constructor(t,e,i){super(),this.render_options={glyph_font_scale:30},this.tempo=t,this.position=ft.ABOVE,this.x=e,this.shift_x=10,this.shift_y=i,this.resetFont()}static get CATEGORY(){return c.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=K.getGlyphProps(o);if(c+=3*n,R.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&&(R.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}}ce.TEXT_FONT={family:k.SERIF,size:14,weight:b.BOLD,style:w.NORMAL},function(t){t[t.LEFT=1]="LEFT",t[t.CENTER=2]="CENTER",t[t.RIGHT=3]="RIGHT"}(Jt||(Jt={}));class de extends mt{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=Jt.LEFT,t.glyph){const e=de.GLYPHS[t.glyph];if(!e)throw new d("Invalid glyph type: "+t.glyph);this.glyph=new R(e.code,40,{category:"textNote"}),this.setWidth(this.glyph.getMetrics().width)}else this.glyph=void 0}static get CATEGORY(){return c.TextNote}static get Justification(){return Jt}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===Jt.CENTER?this.leftDisplacedHeadPx=this.width/2:this.justification===Jt.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===Jt.CENTER?s-=n/2:this.justification===Jt.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=k.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)}}}de.TEXT_FONT={family:k.SANS_SERIF,size:12,weight:b.NORMAL,style:w.NORMAL};class le extends wt{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:de.Justification.CENTER},i),this.resetFont()}static get CATEGORY(){return c.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 ft.LEFT:case ft.RIGHT:n=(t.getYForLine(0)+t.getBottomLineY())/2+this.options.shift_y,s=this.position===ft.LEFT?t.getX()-i-24+this.options.shift_x:t.getX()+t.getWidth()+24+this.options.shift_x;break;case ft.ABOVE:case ft.BELOW:s=t.getX()+this.options.shift_x,this.options.justification===Jt.CENTER?s+=t.getWidth()/2-i/2:this.options.justification===Jt.RIGHT&&(s+=t.getWidth()-i),n=this.position===ft.ABOVE?t.getYForTopText(2)+this.options.shift_y:t.getYForBottomText(2)+this.options.shift_y;break;default:throw new d("InvalidPosition","Value Must be in Modifier.Position.")}return e.fillText(""+this.text,s,n+4),e.restore(),this}}le.TEXT_FONT={family:k.SERIF,size:16,weight:b.NORMAL,style:w.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"}(Qt||(Qt={}));class ge extends wt{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 c.Volta}static get type(){return Qt}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 Qt.BEGIN:i.fillRect(this.x+e,n,1,a);break;case Qt.END:s-=5,i.fillRect(this.x+e+s,n,1,a);break;case Qt.BEGIN_END:s-=3,i.fillRect(this.x+e,n,1,a),i.fillRect(this.x+e+s,n,1,a)}return this.volta!==Qt.BEGIN&&this.volta!==Qt.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}}ge.TEXT_FONT={family:k.SANS_SERIF,size:9,weight:b.BOLD,style:w.NORMAL};class ue extends R{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 R("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 R("timeSig"+e,this.timeSignature.point);this.botGlyphs.push(s),h+=g(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];R.renderOutline(i,e.getMetrics().outline,this.scale,s+this.x_shift,n),s+=g(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),R.renderOutline(i,a.getMetrics().outline,this.scale,s+a.getMetrics().x_shift,n),s+=g(a.getMetrics().width)}}}class pe extends wt{constructor(t="4/4",e=15,i=!0){super(),this.validate_args=i;const s=e,n=K.currentMusicFont();this.point=n.lookupMetric("digits.point");const a=n.lookupMetric("digits.shiftLine",0);this.topLine=2+a,this.bottomLine=4+a,this.setPosition(ft.BEGIN),this.info=this.parseTimeSpec(t),this.setWidth(g(this.info.glyph.getMetrics().width)),this.setPadding(s)}static get CATEGORY(){return c.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}=pe.glyphs[t];return{line:e,num:!1,glyph:new R(i,s)}}this.validate_args&&(t=>{const e=t.split("/");if(2!==e.length&&"+"!==e[0]&&"-"!==e[0])throw new d("BadTimeSignature",`Invalid time spec: ${t}. Must be in the form "<numerator>/<denominator>"`);e.forEach((e=>{if(0==/^[0-9+\-()]+$/.test(e))throw new d("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 ue(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 me={[vt.CATEGORY]:0,[ae.CATEGORY]:1,[oe.CATEGORY]:2,[pe.CATEGORY]:3},fe={[pe.CATEGORY]:0,[oe.CATEGORY]:1,[vt.CATEGORY]:2,[ae.CATEGORY]:3};class _e extends A{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:K.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 vt(this.options.left_bar?_t.SINGLE:_t.NONE)),this.addEndModifier(new vt(this.options.right_bar?_t.SINGLE:_t.NONE))}static get CATEGORY(){return c.Stave}static get defaultPadding(){const t=K.currentMusicFont();return t.lookupMetric("stave.padding")+t.lookupMetric("stave.endPaddingMax")}static get rightPadding(){return K.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)-K.STAVE_LINE_THICKNESS/2}getBottomLineBottomY(){return this.getYForLine(this.getNumLines()-1)+K.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:K.STAVE_LINE_THICKNESS},this.style)}setMeasure(t){return this.measure=t,this}getModifierXShift(t=0){if("number"!=typeof t)throw new d("InvalidIndex","Must be of number type");if(this.formatted||this.format(),1===this.getModifiers(ft.BEGIN).length)return 0;if(this.modifiers[t].getPosition()===ft.RIGHT)return 0;let e=this.start_x-this.x;const i=this.modifiers[0];return i.getType()===_t.REPEAT_BEGIN&&e>i.getWidth()&&(e-=i.getWidth()),e}setRepetitionType(t,e=0){return this.modifiers.push(new re(t,this.x,e)),this}setVoltaType(t,e,i){return this.modifiers.push(new ge(t,e,this.x,i)),this}setSection(t,e,i=0,s){const n=new he(t,this.x+i,e);return s&&n.setFontSize(s),this.modifiers.push(n),this}setTempo(t,e){return this.modifiers.push(new ce(t,this.x,e)),this}setText(t,e,i={}){return this.modifiers.push(new le(t,e,i)),this}getHeight(){return this.height}getSpacingBetweenLines(){return this.options.spacing_between_lines_px}getBoundingBox(){return new y(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,ft.END),this}setBegBarType(t){const{SINGLE:e,REPEAT_BEGIN:i,NONE:s}=_t;return t!==e&&t!==i&&t!==s||(this.modifiers[0].setType(t),this.formatted=!1),this}setEndBarType(t){return t!==_t.REPEAT_BEGIN&&(this.modifiers[1].setType(t),this.formatted=!1),this}setClef(t,e,i,s){void 0===s&&(s=ft.BEGIN),s===ft.END?this.endClef=t:this.clef=t;const n=this.getModifiers(s,ae.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,ft.END),this}getEndClef(){return this.endClef}setKeySignature(t,e,i){void 0===i&&(i=ft.BEGIN);const s=this.getModifiers(i,oe.CATEGORY);return 0===s.length?this.addKeySignature(t,e,i):s[0].setKeySig(t,e),this}setEndKeySignature(t,e){return this.setKeySignature(t,e,ft.END),this}setTimeSignature(t,e,i){void 0===i&&(i=ft.BEGIN);const s=this.getModifiers(i,pe.CATEGORY);return 0===s.length?this.addTimeSignature(t,e,i):s[0].setTimeSig(t),this}setEndTimeSignature(t,e){return this.setTimeSignature(t,e,ft.END),this}addKeySignature(t,e,i){return void 0===i&&(i=ft.BEGIN),this.addModifier(new oe(t,e).setPosition(i),i),this}addClef(t,e,i,s){return void 0===s||s===ft.BEGIN?this.clef=t:s===ft.END&&(this.endClef=t),this.addModifier(new ae(t,e,i),s),this}addEndClef(t,e,i){return this.addClef(t,e,i,ft.END),this}addTimeSignature(t,e,i){return this.addModifier(new pe(t,e),i),this}addEndTimeSignature(t,e){return this.addTimeSignature(t,e,ft.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(ft.BEGIN),n=this.getModifiers(ft.END);let a,o,r;this.sortByCategory(i,me),this.sortByCategory(n,fe),i.length>1&&t.getType()===_t.REPEAT_BEGIN&&(i.push(i.splice(0,1)[0]),i.splice(0,0,new vt(_t.SINGLE))),n.indexOf(e)>0&&n.splice(0,0,new vt(_t.NONE));let h=0,c=this.x;for(let t=0;t<i.length;t++)r=i[t],o=r.getPadding(t+h),a=r.getWidth(),c+=o,r.setX(c),c+=a,o+a===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<n.length;t++){r=n[t],l=s(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===n.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===n.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 d("StaveConfigError","The line number must be within the range of the number of lines in the Stave.");if(void 0===e.visible)throw new d("StaveConfigError","The line configuration object is missing the 'visible' property.");if("boolean"!=typeof e.visible)throw new d("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 d("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 xe(t,e,i,s,n){if(e!==Se.type.BOLD_DOUBLE_LEFT&&e!==Se.type.BOLD_DOUBLE_RIGHT)throw new d("InvalidConnector","A REPEAT_BEGIN or REPEAT_END type must be provided.");let a=3,o=3.5;e===Se.type.BOLD_DOUBLE_RIGHT&&(a=-5,o=3),t.fillRect(i+a,s,1,n-s),t.fillRect(i-2,s,o,n-s)}_e.TEXT_FONT={family:k.SANS_SERIF,size:8,weight:b.NORMAL,style:w.NORMAL};class Se extends A{constructor(t,e){super(),this.thickness=K.STAVE_LINE_THICKNESS,this.width=3,this.top_stave=t,this.bottom_stave=e,this.type=Se.type.DOUBLE,this.resetFont(),this.x_shift=0,this.texts=[]}static get CATEGORY(){return c.StaveConnector}setType(t){return(t="string"==typeof t?Se.typeString[t]:t)>=Se.type.SINGLE_RIGHT&&t<=Se.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 d("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===Se.type.SINGLE_RIGHT||this.type===Se.type.BOLD_DOUBLE_RIGHT||this.type===Se.type.THIN_DOUBLE)&&(n=this.top_stave.getX()+this.top_stave.getWidth());let a=i-e;switch(this.type){case Se.type.SINGLE:case Se.type.SINGLE_LEFT:case Se.type.SINGLE_RIGHT:s=1;break;case Se.type.DOUBLE:n-=this.width+2,e-=this.thickness,a+=.5;break;case Se.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 Se.type.BRACKET:e-=6,i+=6,a=i-e,R.renderGlyph(t,n-5,e,40,"bracketTop"),R.renderGlyph(t,n-5,i,40,"bracketBottom"),n-=this.width+2;break;case Se.type.BOLD_DOUBLE_LEFT:xe(t,this.type,n+this.x_shift,e,i-this.thickness);break;case Se.type.BOLD_DOUBLE_RIGHT:xe(t,this.type,n,e,i-this.thickness);break;case Se.type.THIN_DOUBLE:s=1,a-=this.thickness;break;case Se.type.NONE:break;default:throw new d("InvalidType",`The provided StaveConnector.type (${this.type}) is invalid.`)}this.type!==Se.type.BRACE&&this.type!==Se.type.BOLD_DOUBLE_LEFT&&this.type!==Se.type.BOLD_DOUBLE_RIGHT&&this.type!==Se.type.NONE&&t.fillRect(n,e,s,a),this.type===Se.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()}}Se.TEXT_FONT={family:k.SERIF,size:16,weight:b.NORMAL,style:w.NORMAL},Se.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},Se.typeString={singleRight:Se.type.SINGLE_RIGHT,singleLeft:Se.type.SINGLE_LEFT,single:Se.type.SINGLE,double:Se.type.DOUBLE,brace:Se.type.BRACE,bracket:Se.type.BRACKET,boldDoubleLeft:Se.type.BOLD_DOUBLE_LEFT,boldDoubleRight:Se.type.BOLD_DOUBLE_RIGHT,thinDouble:Se.type.THIN_DOUBLE,none:Se.type.NONE};const ye=t=>t.reduce(((t,e)=>t+e),0);function Te(t,e,i){const s=we.getResolutionMultiplier(t),n={},a=[],o=[];return t.forEach(((t,r)=>{const h=new x(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 be(t,e,i,s){let n=e;for(let e=i+1;e<t.length;e++){const i=t[e];if(a(i)&&!i.isRest()&&!i.shouldIgnoreTicks()){n=i.getLineForRest();break}}if(s&&e!==n){n=m(Math.max(e,n),Math.min(e,n))}return n}class we{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 ne);const s=(new Ot).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:K.currentMusicFont().lookupMetric("stave.padding")},a)).stavePadding,r=e.contextGaps;t.save(),t.setFont(k.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 Bt(K.TIME4_4).setMode(Bt.Mode.SOFT).addTickables(i),o=n.auto_beam?Ne.applyAndGetBeams(a):[];return(new we).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 Bt(K.TIME4_4).setMode(Bt.Mode.SOFT).addTickables(n),c=new Bt(K.TIME4_4).setMode(Bt.Mode.SOFT).addTickables(s),d=r.auto_beam?Ne.applyAndGetBeams(h):[];(new we).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 Se(i,e).setContext(t).draw()}static AlignRestsToNotes(t,e,i){t.forEach(((s,n)=>{if(o(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=be(t,e.line,n,!1);else if(n>0&&n<t.length){const i=t[n-1];if(o(i))if(i.isRest())e.line=i.getKeyProps()[0].line;else{const s=i.getLineForRest();e.line=be(t,s,n,!0)}}s.setKeyLine(0,e.line)}}}))}alignRests(t,e){if(!t||!t.length)throw new d("BadArgument","No voices to format rests");t.forEach((t=>we.AlignRestsToNotes(t.getTickables(),e)))}preCalculateMinTotalWidth(t){const e=K.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 d("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,l=ye(a.map((t=>Math.pow(t-c,2)))),g=Math.pow(l/a.length,.5)/c,u=n/o.length,p=ye(o.map((t=>Math.pow(t-u,2)))),m=Math.pow(p/o.length,.5)/u,f=Math.max(m,g)*r.length*e,_=e*i;return this.minTotalWidth+Math.max(_,f)}getMinTotalWidth(){if(!this.hasMinTotalWidth)throw new d("NoMinTotalWidth","Call 'preCalculateMinTotalWidth' or 'preFormat' before calling 'getMinTotalWidth'");return this.minTotalWidth}static getResolutionMultiplier(t){if(!t||!t.length)throw new d("BadArgument","No voices to format");const e=t[0].getTotalTicks();return t.reduce(((t,i)=>{if(!i.getTotalTicks().equals(e))throw new d("TickMismatch","Voices should have same total note duration in ticks.");if(i.getMode()===Bt.Mode.STRICT&&!i.isComplete())throw new d("IncompleteVoice","Voice does not have enough notes.");return Math.max(t,x.LCM(t,i.getResolutionMultiplier()))}),1)}createModifierContexts(t){const e=Te(t,(()=>new ne),((t,e)=>t.addToModifierContext(e)));return this.modifierContexts=e,e}createTickContexts(t){const e=Te(t,(t=>new Ot(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 d("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:l,softmaxFactor:u,maxIterations:p}=this.formatterOptions,m=ye(a.map((t=>Math.pow(u,o[t].getMaxTicks().value()/c))));if(this.minTotalWidth=r+h,this.hasMinTotalWidth=!0,t<=0)return this.evaluate();const f=o[a[0]],_=o[a[a.length-1]];function x(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(),d=[];if(Object.keys(n).forEach((t=>{i[t]&&d.push(t)})),d.length>0){let a=0,o=1/0,h=0;if(d.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)),l){const e=c;h=Math.pow(u,a/e)/m*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=g(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())}))})),_.getX()-f.getX()}const y=t-_.getMetrics().notePx-_.getMetrics().totalRightPx-f.getMetrics().totalLeftPx,T=K.currentMusicFont(),b=T.lookupMetric("stave.endPaddingMin"),w=T.lookupMetric("stave.endPaddingMax");let v=y;const E=x(v);let C=S(E);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})(v,E);if(1===a.length)return 0;const D=2*w<k?k:w,N=y-(D-(w-b));let A=p;for(;C>N&&A>0||C+D<N&&A>1;)v-=C-N,C=S(x(v)),A--;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=-ye(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()-_e.defaultPadding;return function(...t){we.DEBUG&&u("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 ve;we.DEBUG=!1,function(t){t[t.BOTTOM=-1]="BOTTOM",t[t.TOP=1]="TOP"}(ve||(ve={}));class Ee extends A{constructor(t,e={}){if(super(),this.numerator_glyphs=[],this.denom_glyphs=[],!t||!t.length)throw new d("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=K.currentMusicFont().lookupMetric("digits.tupletPoint"),this.y_pos=16,this.x_pos=100,this.width=200,this.setTupletLocation(this.options.location||Ee.LOCATION_TOP),we.AlignRestsToNotes(t,!0,!0),this.resolveGlyphs(),this.attach()}static get CATEGORY(){return c.Tuplet}static get LOCATION_TOP(){return ve.TOP}static get LOCATION_BOTTOM(){return ve.BOTTOM}static get NESTING_OFFSET(){return 15}static get metrics(){return K.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!==Ee.LOCATION_TOP&&t!==Ee.LOCATION_BOTTOM&&(console.warn(`Invalid tuplet location [${t}]. Using Tuplet.LOCATION_TOP.`),t=Ee.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 R("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 R("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()*Ee.NESTING_OFFSET*-this.location,e=this.options.y_offset||0,i=this.notes[0];let s;if(this.location===Ee.LOCATION_TOP){s=i.checkStave().getYForLine(0)-Ee.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)-Ee.metrics.noteHeadOffset;if(e.hasStem()||e.isRest()){const t=e.getStemDirection()===Q.UP?e.getStemExtents().topY-Ee.metrics.stemOffset:e.getStemExtents().baseY-Ee.metrics.noteHeadOffset;s=Math.min(t,s),i>0&&(s=Math.min(a,s))}}}else{let t=Ee.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)+Ee.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()===Q.UP?this.notes[t].getStemExtents().baseY+Ee.metrics.noteHeadOffset:this.notes[t].getStemExtents().topY+Ee.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+g(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===Ee.LOCATION_BOTTOM?1:0),1,10*this.location),t.fillRect(this.x_pos+this.width,this.y_pos+(this.location===Ee.LOCATION_BOTTOM?1:0),1,10*this.location))}const o=K.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+=g(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+=g(e.getMetrics().width)}))}}}function Ce(t){let e=0;return t.forEach((t=>{t.keyProps&&t.keyProps.forEach((t=>{e+=t.line-3}))})),e>=0?Q.DOWN:Q.UP}const ke="L",De="B";class Ne extends A{constructor(t,e=!1){if(super(),this.slope=0,this.y_shift=0,!t||0===t.length)throw new d("BadArguments","No notes provided for beam.");if(1===t.length)throw new d("BadArguments","Too few notes for beam.");if(this.ticks=t[0].getIntrinsicTicks(),this.ticks>=K.durationToTicks("4"))throw new d("BadArguments","Beams can only be applied to notes shorter than a quarter note.");let i,s;for(this.stem_direction=Q.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&&o(t[0]))n=Ce(t);else if(e&&h(t[0])){const e=t.reduce(((t,e)=>t+e.getStemDirection()),0);n=e>-1?Q.UP:Q.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 c.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 x).parse(t)));{const e=parseInt(t.split("/")[0],10),i=parseInt(t.split("/")[1],10);if(e%3==0)return[new x(3,i)];if(i>4)return[new x(2,i)];if(i<=4)return[new x(1,i)]}return[new x(1,4)]}static applyAndGetBeams(t,e,i){return Ne.generateBeams(t.getTickables(),{groups:i,stem_direction:e})}static generateBeams(t,e={}){e.groups&&e.groups.length||(e.groups=[new x(2,8)]);const i=e.groups.map((t=>{if(!t.multiply)throw new d("InvalidBeamGroups","The beam groups must be an array of Vex.Flow.Fractions");return t.clone().multiply(K.RESOLUTION,1)})),s=t;let n=0,a=[],o=[];function r(){i.length-1>n?n+=1:n=0}!function(){let t=[],e=new x(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 x(0,1))).add(e);var d;const l=K.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 x(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():Q.UP}else i=e.stem_direction?e.stem_direction:Ce(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()>=K.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}(),l=[];return h.forEach((t=>{const i=new Ne(t);e.show_stemlets&&(i.render_options.show_stemlets=!0),e.secondary_breaks&&(i.render_options.secondary_break_ticks=K.durationToTicks(e.secondary_breaks)),!0===e.flat_beams&&(i.render_options.flat_beams=!0,i.render_options.flat_beam_offset=e.flat_beam_offset),l.push(i)})),c.forEach((t=>{const e=t.notes[0].stem_direction===Q.DOWN?ve.BOTTOM:ve.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)})),l}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}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===Q.DOWN&&h<n?(h=n,o=Math.max(...s.getYs()),r=s.getBeamCount()):e===Q.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===Q.DOWN&&c<l?c=o+d:e===Q.UP&&c>l&&(c=o-d),n?(e===Q.DOWN&&c>n||e===Q.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===Q.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){if("4"===t)return ke;const n=""+K.durationToNumber(t)/2,a=e<K.durationToTicks(n),o=s<K.durationToTicks(n),r=i<K.durationToTicks(n);return a&&o&&r?De:a&&!o&&r?ke:!a&&o&&r?"R":this.lookupBeamDirection(n,e,i,s)}getBeamLines(t){const e=K.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()-Q.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);[ke,De].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&&i.setContext(t).draw()}),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 d("NoLastBeamX","lastBeamX undefined.");{const e=this.getSlopeY(c,n,s,this.slope);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()}}s+=1.5*a}}preFormat(){return this}postFormat(){this.postFormatted||(h(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 Ae extends mt{constructor(t,e,i){super({duration:"b"}),this.type=t,this.clef_obj=new ae(t,e,i),this.clef=this.clef_obj.clef,this.glyph=new R(this.clef.code,this.clef.point),this.setWidth(this.glyph.getMetrics().width),this.ignore_ticks=!0}static get CATEGORY(){return c.ClefNote}setType(t,e,i){return this.type=t,this.clef_obj=new ae(t,e,i),this.clef=this.clef_obj.clef,this.glyph=new R(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 R(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 Fe extends mt{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 c.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=Ot.getNextContext(i),n=this.getAbsoluteX(),a=s?s.getX():e.getX()+e.getWidth(),o=e.getYForLine(this.line+-3)+1;!function(...t){Fe.DEBUG&&u("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 Pe;Fe.DEBUG=!1,function(t){t[t.NEAR_HEAD=1]="NEAR_HEAD",t[t.NEAR_TOP=2]="NEAR_TOP"}(Pe||(Pe={}));class Be extends A{constructor(t,e,i){super(),this.render_options=Object.assign({thickness:2,x_shift:0,y_shift:10,position:Pe.NEAR_HEAD,position_end:Pe.NEAR_HEAD,invert:!1,cps:[{x:0,y:10},{x:0,y:10}]},i),this.from=t,this.to=e}static get CATEGORY(){return c.Curve}static get Position(){return Pe}static get PositionString(){return{nearHead:Pe.NEAR_HEAD,nearTop:Pe.NEAR_TOP}}setNotes(t,e){if(!t&&!e)throw new d("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?Be.PositionString[t]:t}const d=c(this.render_options.position),l=c(this.render_options.position_end);if(d===Pe.NEAR_TOP&&(r="topY",h="topY"),l===Pe.NEAR_HEAD?h="baseY":l===Pe.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 Me(...t){Oe.DEBUG&&u("Vex.Flow.Parser",t)}function Re(t){if("matchedString"in t)return t.matchedString;if("results"in t)return Re(t.results);const e=t;return 1===e.length?Re(e[0]):0===e.length?null:e.map(Re)}class Oe{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(Me("Evaluating rule function:",t),!t)throw new d("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 Me(i),new d("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(Re(t)))),i.run&&e.success&&i.run({matches:s}),e}}function Le(...t){He.DEBUG&&u("Vex.Flow.EasyScore",t)}Oe.DEBUG=!1;class Ie{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 We{constructor(t){this.chord=[],this.dots=0,this.options={},this.duration=t}}class Ge{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(){Le("resetPiece"),this.piece=new We(this.rollingDuration)}setNoteDots(t){Le("setNoteDots:",t),t&&(this.piece.dots=t.length)}setNoteDuration(t){Le("setNoteDuration:",t),this.rollingDuration=this.piece.duration=t||this.rollingDuration}setNoteType(t){Le("setNoteType:",t),t&&(this.piece.type=t)}addNoteOption(t,e){Le("addNoteOption: key:",t,"value:",e),this.piece.options[t]=e}addNote(t,e,i){Le("addNote:",t,e,i),this.piece.chord.push({key:t,accid:e,octave:i})}addSingleNote(t,e,i){Le("addSingleNote:",t,e,i),this.addNote(t,e,i)}addChord(t){Le("startChord"),"object"!=typeof t[0]?this.addSingleNote(t[0]):t.forEach((t=>{t&&this.addNote(...t)})),Le("endChord")}commitPiece(){Le("commitPiece");const{factory:t}=this;if(!t)return;const e=Object.assign(Object.assign({},this.options),this.piece.options),i=g(e.stem,"BadArguments","options.stem is not defined").toLowerCase(),s=g(e.clef,"BadArguments","options.clef is not defined").toLowerCase(),{chord:n,duration:a,dots:o,type:r}=this.piece,h=L.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?Q.UP:Q.DOWN);const u=[];n.forEach(((e,i)=>{const s=e.accid;if("string"==typeof s){const e=t.Accidental({type:s});l.addModifier(e,i),u.push(e)}else u.push(void 0)}));for(let t=0;t<o;t++)Nt.buildAndAttach([l],{all:!0});this.commitHooks.forEach((t=>t(e,l,this))),this.elements.notes.push(l),this.elements.accidentals.push(u),this.resetPiece()}}function Ue(t,e){void 0!==t.id&&e.setAttribute("id",t.id)}const Ye=/\s*,\s*/;function je(t,e){void 0!==t.class&&t.class.split(Ye).forEach((t=>e.addClass(t)))}class He{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 Ge(s);return this.options=Object.assign(Object.assign({commitHooks:[Ue,je,gt.easyScoreHook,At.easyScoreHook],throwOnError:!1},t),{factory:s,builder:n}),this.factory=s,this.builder=n,this.grammar=new Ie(this.builder),this.parser=new Oe(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 Le(i),new d("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)}}He.DEBUG=!1;const Xe="Ghost note must have valid initialization data to identify duration.";class Ve extends Gt{static get CATEGORY(){return c.GhostNote}constructor(t){if(!t)throw new d("BadArguments",Xe);let e;if("string"==typeof t)e={duration:t};else{if("object"!=typeof t)throw new d("BadArguments",Xe);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];i(e,c.Annotation)&&(e.setContext(this.getContext()),e.drawWithStyle())}}}class ze extends mt{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 c.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 Ke extends Yt{constructor(t){super(Object.assign({glyph_font_scale:K.NOTATION_FONT_SCALE*Ke.SCALE,stroke_px:Ke.LEDGER_LINE_OFFSET},t)),this.slash=t.slash||!1,this.slur=!0,this.buildNoteHeads(),this.width=3}static get CATEGORY(){return c.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=(Q.HEIGHT+e)*t-Q.HEIGHT}return e}return 0}getStaveNoteScale(){return this.render_options.glyph_font_scale/K.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===Q.DOWN?a.y_top-o:a.y_bottom-o,c=K.STEM_HEIGHT;c-=c/2.8,h+=c*e*n;const d=n===Q.UP?{x1:1,y1:0,x2:13,y2:-9}:{x1:-4,y1:1,x2:13,y2:9};r+=d.x1*i,h+=d.y1*i,s={x1:r,y1:h,x2:r+d.x2*i,y2:h+d.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 d("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),l=Math.cos(c)*i.stem*a,g=Math.sin(c)*i.stem,u=Math.cos(c)*i.beam*a,p=Math.sin(c)*i.beam,m=this.getStemX(),f=s.notes[0].getStemX(),_=s.getBeamYToDraw()+(m-f)*n;return{x1:m-l,y1:_+t-g,x2:m+r*a+u,y2:_+h+p}}}class $e extends mt{constructor(t,e,i){super({duration:"b"}),this.keySignature=new oe(t,e,i),this.ignore_ticks=!0}static get CATEGORY(){return c.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 qe;class Je extends A{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=K.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:K.STAVE_LINE_DISTANCE,serif_thickness:2,semibreve_rest_glyph_scale:K.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 c.MultiMeasureRest}getXs(){return this.xs}setStave(t){return this.stave=t,this}getStave(){return this.stave}checkStave(){return g(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;qe=void 0;const d=function(){if(!qe){const t=new Wt({duration:"w",note_type:"r"});qe={glyph_font_scale:t.render_options.glyph_font_scale,glyph_code:t.glyph_code,width:t.getWidth()}}return qe}(),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)R.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(),n=e.getNoteEndX();const a=e.getModifiers(ft.BEGIN);1===a.length&&s(a[0])&&(i-=a[0].getWidth());const o=this.render_options;this.hasPaddingLeft&&(i=e.getX()+o.padding_left),this.hasPaddingRight&&(n=e.getX()+e.getWidth()-o.padding_right),this.xs.left=i,this.xs.right=n;const r=o.spacing_between_lines_px;if(o.use_symbols?this.drawSymbols(e,t,i,n,r):this.drawLine(e,t,i,n,r),o.show_number){const s="/"+this.number_of_measures,a=new pe(s,0,!1);a.point=o.number_glyph_point,a.setTimeSig(s),a.setStave(e),a.setX(i+.5*(n-i)-.5*a.getInfo().glyph.getMetrics().width),a.bottomLine=o.number_line,a.setContext(t).draw()}}}function Qe(t,e,i,s,n){const a=Ze.GLYPHS[t];new R(a.code,n,{category:"pedalMarking"}).render(e,i+a.x_shift,s+a.y_shift)}class Ze extends A{constructor(t){super(),this.notes=t,this.type=Ze.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 c.PedalMarking}static createSustain(t){return new Ze(t)}static createSostenuto(t){const e=new Ze(t);return e.setType(Ze.type.MIXED),e.setCustomText("Sost. Ped."),e}static createUnaCorda(t){const e=new Ze(t);return e.setType(Ze.type.TEXT),e.setCustomText("una corda","tre corda"),e}setType(t){return(t="string"==typeof t?Ze.typeString[t]:t)>=Ze.type.TEXT&&t<=Ze.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 d("InvalidConfiguration","The notes provided must be in order of ascending x positions");const c=o[a+1]===n,l=o[a-1]===n;let g=0;const u=K.currentMusicFont().lookupMetric(`pedalMarking.${s?"down":"up"}.point`);if(s)if(g=l?5:0,this.type!==Ze.type.MIXED||l)t.beginPath(),t.moveTo(r,h-this.render_options.bracket_height),t.lineTo(r+g,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),g=e/2+this.render_options.text_margin_right}else Qe("pedal_depress",t,r,h,u),g=20+this.render_options.text_margin_right;else g=c?-5:0,t.beginPath(),t.moveTo(e,i),t.lineTo(r+g,h),t.lineTo(r,h-this.render_options.bracket_height),t.stroke(),t.closePath();e=r+g,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=K.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)):Qe("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)):Qe("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){Ze.DEBUG&&u("Vex.Flow.PedalMarking",t)}("Rendering Pedal Marking"),this.type===Ze.type.BRACKET||this.type===Ze.type.MIXED?(t.setLineWidth(this.render_options.bracket_line_width),this.drawBracketed()):this.type===Ze.type.TEXT&&this.drawText(),t.restore()}}Ze.DEBUG=!1,Ze.TEXT_FONT={family:k.SERIF,size:12,weight:b.BOLD,style:w.ITALIC},Ze.GLYPHS={pedal_depress:{code:"keyboardPedalPed",x_shift:-10,y_shift:0},pedal_release:{code:"keyboardPedalUp",x_shift:-2,y_shift:3}},Ze.type={TEXT:1,BRACKET:2,MIXED:3},Ze.typeString={text:Ze.type.TEXT,bracket:Ze.type.BRACKET,mixed:Ze.type.MIXED};const ti={1:"repeat1Bar",2:"repeat2Bars",4:"repeat4Bars",slash:"repeatBarSlash"};class ei extends ze{static get CATEGORY(){return c.RepeatNote}constructor(t,e,i){super(void 0,Object.assign({duration:"q",align_center:"slash"!==t},e),i);const s=new R(ti[t]||"repeat1Bar",K.currentMusicFont().lookupMetric("repeatNote.point",40),{category:"repeatNote"});this.setGlyph(s)}}function ii(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 si extends A{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:si.TextVerticalPosition.TOP,text_justification:si.TextJustification.CENTER}}static get CATEGORY(){return c.StaveLine}setText(t){return this.text=t,this}setNotes(t){if(!t.first_note&&!t.last_note)throw new d("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 d("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,ii(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,ii(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===si.TextJustification.LEFT)h=n.x;else if(r===si.TextJustification.CENTER){h=(a.x-n.x)/2+n.x-o/2}else r===si.TextJustification.RIGHT&&(h=a.x-o);let c=0;const d=s.text_position_vertical;return d===si.TextVerticalPosition.TOP?c=e.checkStave().getYForTopText():d===si.TextVerticalPosition.BOTTOM&&(c=e.checkStave().getYForBottomText(K.TEXT_HEIGHT_OFFSET_HACK)),t.save(),this.applyFontStyle(),t.fillText(this.text,h,c),t.restore(),this}}si.TEXT_FONT=Object.assign({},A.TEXT_FONT),si.TextVerticalPosition={TOP:1,BOTTOM:2},si.TextJustification={LEFT:1,CENTER:2,RIGHT:3};class ni extends A{constructor(t={}){super(),this.setOptions(t),this.parts=[]}static get CATEGORY(){return c.System}setOptions(t={}){if(!t.factory)throw new d("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 we(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),this.options.autoWidth?t.voices.forEach((t=>{i.joinVoices([t])})):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+_e.rightPadding+(n-this.options.x))}))):e=this.options.noPadding?this.options.width-this.options.x:this.options.width-(n-this.options.x)-_e.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 y(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 d("NoFormatter","format() must be called before draw()");this.setRendered(),this.options.debugFormatter&&we.plotDebugging(t,this.formatter,this.startX,this.options.y,this.lastY),this.debugNoteMetricsYs.forEach((e=>{e.voice.getTickables().forEach((i=>mt.plotMetrics(t,i,e.y)))}))}}class ai extends Gt{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:K.TABLATURE_FONT_SCALE,draw_stem:e,draw_dots:e,draw_stem_through_stave:!1,y_shift:0,scale:1,font:`${k.SIZE}pt ${k.SANS_SERIF}`}),this.glyph=K.getGlyphProps(this.duration,this.noteType),g(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(Q.UP),this.ghost=!1,this.updateWidth()}static get CATEGORY(){return c.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(){return null!=this.stem_extension_override?this.stem_extension_override:this.flag?1===this.getStemDirection()?-this.flag.checkMetrics().y_shift:this.flag.checkMetrics().y_shift: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=K.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 d("UnformattedNote","Can't call GetModifierStartXY on an unformatted note");if(0===this.ys.length)throw new d("NoYValues","No Y-Values calculated for this note.");let i=0;if(t===O.Position.LEFT)i=-2;else if(t===O.Position.RIGHT)i=this.width+2;else if(t===O.Position.BELOW||t===O.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=Q.UP===this.stem_direction?-.5:t;return this.checkStave().getYForLine(e)}getStemExtents(){return this.checkStem().getExtents()}drawFlag(){const{beam:t,glyph:e,stem_direction:i,render_options:{draw_stem:s,glyph_font_scale:n}}=this,a=this.checkContext(),o=null==t&&s;if(e.flag&&o){const t=this.getStemX()+1,s=this.getStemY()-this.checkStem().getHeight(),o=i===Q.DOWN?e.code_flag_downstem:e.code_flag_upstem;R.renderGlyph(a,t,s,n,o,{category:"flag.tabStem"})}}drawModifiers(){this.modifiers.forEach((t=>{i(t,c.Dot)&&!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(Q.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)R.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 d("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 oi extends _e{static get CATEGORY(){return c.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 ri(...t){ci.DEBUG&&u("Vex.Flow.TextBracket",t)}var hi;!function(t){t[t.TOP=1]="TOP",t[t.BOTTOM=-1]="BOTTOM"}(hi||(hi={}));class ci extends A{constructor({start:t,stop:e,text:i="",superscript:s="",position:n=hi.TOP}){super(),this.start=t,this.stop=e,this.text=i,this.superscript=s,this.position="string"==typeof n?ci.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 c.TextBracket}static get Position(){return hi}static get PositionString(){return{top:hi.TOP,bottom:hi.BOTTOM}}static get Positions(){return ri("Positions is deprecated, use TextBracketPosition instead."),hi}static get PositionsString(){return ri("PositionsString is deprecated, use PositionString instead."),ci.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 hi.TOP:e=this.start.checkStave().getYForTopText(this.line);break;case hi.BOTTOM:e=this.start.checkStave().getYForBottomText(this.line+K.TEXT_HEIGHT_OFFSET_HACK);break;default:throw new d("InvalidPosition",`The position ${this.position} is invalid.`)}const i={x:this.start.getAbsoluteX(),y:e},s={x:this.stop.getAbsoluteX(),y:e};ri("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:l,weight:g,style:u}=this.textFont,p=k.scaleSize(l,.714286);t.setFont(c,p,g,u),t.fillText(this.superscript,i.x+o+1,h);const m=t.measureText(this.superscript),f=m.width,_=m.height;let x=i.x,S=h;const y=s.x+this.stop.getGlyph().getWidth();this.position===hi.TOP?(x+=o+f+5,S-=_/2.7):this.position===hi.BOTTOM&&(S+=_/2.7,x+=o+2,this.render_options.underline_superscript||(x+=f)),this.render_options.dashed?(Zt.drawDashedLine(t,x,S,y,S,this.render_options.dash),this.render_options.show_bracket&&Zt.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 di(...t){li.DEBUG&&u("Vex.Flow.TextDynamics",t)}ci.DEBUG=!1,ci.TEXT_FONT={family:k.SERIF,size:15,weight:b.NORMAL,style:w.ITALIC};class li extends mt{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}),di("New Dynamics Text: ",this.sequence)}static get CATEGORY(){return c.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=li.GLYPHS[e];if(!i)throw new d("Invalid dynamics character: "+e);const s=g(this.render_options.glyph_font_size),n=new R(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);di("Rendering Dynamics: ",this.sequence);let i=t;this.glyphs.forEach(((t,s)=>{const n=this.sequence[s];t.render(this.checkContext(),i,e),i+=li.GLYPHS[n].width}))}}li.DEBUG=!1;class gi extends mt{constructor(t,e){super({duration:"b"});const i=new pe(t,e);this.timeSigInfo=i.getInfo(),this.setWidth(this.timeSigInfo.glyph.getMetrics().width),this.ignore_ticks=!0}static get CATEGORY(){return c.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 ui extends A{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 c.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){ui.DEBUG&&u("Vex.Flow.VibratoBracket",t)}("Rendering VibratoBracket: start_x:",i,"stop_x:",s,"y:",e),ie.renderVibrato(t,i,e,this.render_options)}}function pi(...t){mi.DEBUG&&u("Vex.Flow.Factory",t)}ui.DEBUG=!1;class mi{constructor(t={}){pi("New factory: ",t),this.options={stave:{space:10},renderer:{elementId:"",width:500,height:200,background:"#FFF"},font:mi.TEXT_FONT},this.setOptions(t)}static newFromElementId(t,e=500,i=200){return new mi({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 pi(this),new d("renderer.elementId not set in FactoryOptions");let n=this.options.renderer.backend;if(void 0===n){n=jt(document.getElementById(t))?Zt.Backends.CANVAS:Zt.Backends.SVG}this.context=Zt.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 _e(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 oi(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 Yt(t);return this.stave&&e.setStave(this.stave),e.setContext(this.context),this.renderQ.push(e),e}GlyphNote(t,e,i){const s=new ze(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 ei(t,e,i);return this.stave&&s.setStave(this.stave),s.setContext(this.context),this.renderQ.push(s),s}GhostNote(t){const e=new Ve(t);return this.stave&&e.setStave(this.stave),e.setContext(this.context),this.renderQ.push(e),e}TextNote(t){const e=new de(t);return this.stave&&e.setStave(this.stave),e.setContext(this.context),this.renderQ.push(e),e}BarNote(t={}){const e=new Et(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 Ae(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 gi(e.time);return this.stave&&i.setStave(this.stave),i.setContext(this.context),this.renderQ.push(i),i}KeySigNote(t){const e=new $e(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 ai(t);return this.stave&&e.setStave(this.stave),e.setContext(this.context),this.renderQ.push(e),e}GraceNote(t){const e=new Ke(t);return this.stave&&e.setStave(this.stave),e.setContext(this.context),e}GraceNoteGroup(t){const e=new Mt(t.notes,t.slur);return e.setContext(this.context),e}Accidental(t){const e=new J(t.type);return e.setContext(this.context),e}Annotation(t){const e=Object.assign({text:"p",hJustify:st.CENTER,vJustify:nt.BOTTOM},t),i=new at(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 Dt;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 gt(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 li({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 At(e.number);return i.setPosition(e.position),i.setContext(this.context),i}StringNumber(t){const e=new te(t.number);return e.setPosition(t.position),e.setContext(this.context),e}TickContext(){return new Ot}ModifierContext(){return new ne}MultiMeasureRest(t){const e=g(t.number_of_measures,"NoNumberOfMeasures"),i=new Je(e,t);return i.setContext(this.context),this.renderQ.push(i),i}Voice(t){const e=Object.assign({time:"4/4"},t),i=new Bt(e.time,e.options);return this.voices.push(i),i}StaveConnector(t){const e=new Se(t.top_stave,t.bottom_stave);return e.setType(t.type).setContext(this.context),this.renderQ.push(e),e}Formatter(t){return new we(t)}Tuplet(t){const e=Object.assign({notes:[],options:{}},t),i=new Ee(e.notes,e.options).setContext(this.context);return this.renderQ.push(i),i}Beam(t){var e,i,s;const n=new Ne(t.notes,null===(e=t.options)||void 0===e?void 0:e.autoStem).setContext(this.context);return n.breakSecondaryAt(null!==(s=null===(i=t.options)||void 0===i?void 0:i.secondaryBeamBreaks)&&void 0!==s?s:[]),this.renderQ.push(n),n}Curve(t){const e=new Be(t.from,t.to,t.options).setContext(this.context);return this.renderQ.push(e),e}StaveTie(t){var e;const i=new Ft({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 si({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 ui({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 ci({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 ni(t).setContext(this.context);return this.systems.push(e),e}EasyScore(t={}){return t.factory=this,new He(t)}PedalMarking(t){const e=Object.assign({notes:[],options:{style:"mixed"}},t),i=new Ze(e.notes);return i.setType(Ze.typeString[e.options.style]),i.setContext(this.context),this.renderQ.push(i),i}NoteSubGroup(t){const e=Object.assign({notes:[]},t),i=new Rt(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()}}mi.DEBUG=!1,mi.TEXT_FONT=Object.assign({},A.TEXT_FONT);class fi extends A{constructor(t,e){super(),this.setNotes(t),this.hairpin=e,this.position=O.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 c.StaveHairpin}static FormatByTicksAndDraw(t,e,i,s,n,a){var o,r;const h=e.pixelsPerTick;if(null==h)throw new d("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),l=h*(null!==(r=a.right_shift_ticks)&&void 0!==r?r:0),g={height:a.height,y_shift:a.y_shift,left_shift_px:c,right_shift_px:l,right_shift_ticks:0,left_shift_ticks:0};new fi({first_note:i.first_note,last_note:i.last_note},s).setContext(t).setRenderOptions(g).setPosition(n).draw()}setPosition(t){return t!==O.Position.ABOVE&&t!==O.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 d("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===O.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 fi.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 fi.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 d("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()})}}fi.type={CRESC:1,DECRESC:2};class _i extends Pt{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)?_i.SLIDE_UP:i>s?_i.SLIDE_DOWN:_i.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 c.TabSlide}static get SLIDE_UP(){return 1}static get SLIDE_DOWN(){return-1}static createSlideUp(t){return new _i(t,_i.SLIDE_UP)}static createSlideDown(t){return new _i(t,_i.SLIDE_DOWN)}renderTie(t){if(0===t.first_ys.length||0===t.last_ys.length)throw new d("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!==_i.SLIDE_UP&&a!==_i.SLIDE_DOWN)throw new d("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 d("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()}}_i.TEXT_FONT={family:k.SERIF,size:10,weight:b.BOLD,style:w.ITALIC};class xi{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 K.keyProperties(t).int_value}setTuning(t){xi.names[t]&&(t=xi.names[t]),this.tuningValues=[];const e=t.split(/\s*,\s*/);if(0===e.length)throw new d("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 d("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 d("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`${K.integerToNote(n)}/${s}`}}var Si=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 yi{static get BUILD(){return{VERSION:"4.0.1-alpha.2",ID:"0df10df6d1fab3a99f5aa306341a31c6e686d659",DATE:"2022-02-02T09:30:30.784Z"}}static get Flow(){return yi}static setMusicFont(...t){const e=t.map((t=>k.load(t)));return K.MUSIC_FONT_STACK=e,R.MUSIC_FONT_STACK=e.slice(),R.CURRENT_CACHE_KEY=t.join(","),e}static fetchMusicFont(t,e){return Si(this,void 0,void 0,(function*(){}))}static getMusicFont(){return K.MUSIC_FONT_STACK.map((t=>t.getName()))}static get NOTATION_FONT_SCALE(){return K.NOTATION_FONT_SCALE}static set NOTATION_FONT_SCALE(t){K.NOTATION_FONT_SCALE=t}static get TABLATURE_FONT_SCALE(){return K.TABLATURE_FONT_SCALE}static set TABLATURE_FONT_SCALE(t){K.TABLATURE_FONT_SCALE=t}static get RESOLUTION(){return K.RESOLUTION}static set RESOLUTION(t){K.RESOLUTION=t}static get SLASH_NOTEHEAD_WIDTH(){return K.SLASH_NOTEHEAD_WIDTH}static set SLASH_NOTEHEAD_WIDTH(t){K.SLASH_NOTEHEAD_WIDTH=t}static get STAVE_LINE_DISTANCE(){return K.STAVE_LINE_DISTANCE}static set STAVE_LINE_DISTANCE(t){K.STAVE_LINE_DISTANCE=t}static get STAVE_LINE_THICKNESS(){return K.STAVE_LINE_THICKNESS}static set STAVE_LINE_THICKNESS(t){K.STAVE_LINE_THICKNESS=t}static get STEM_HEIGHT(){return K.STEM_HEIGHT}static set STEM_HEIGHT(t){K.STEM_HEIGHT=t}static get STEM_WIDTH(){return K.STEM_WIDTH}static set STEM_WIDTH(t){K.STEM_WIDTH=t}static get TIME4_4(){return K.TIME4_4}static get accidentalMap(){return K.accidentalMap}static get unicode(){return K.unicode}static keySignature(t){return K.keySignature(t)}static hasKeySignature(t){return K.hasKeySignature(t)}static getKeySignatures(){return K.getKeySignatures()}static clefProperties(t){return K.clefProperties(t)}static keyProperties(t,e,i){return K.keyProperties(t,e,i)}static durationToTicks(t){return K.durationToTicks(t)}}yi.Accidental=J,yi.Annotation=at,yi.Articulation=gt,yi.Barline=vt,yi.BarNote=Et,yi.Beam=Ne,yi.Bend=Ct,yi.BoundingBox=y,yi.BoundingBoxComputation=T,yi.CanvasContext=Ht,yi.ChordSymbol=Dt,yi.Clef=ae,yi.ClefNote=Ae,yi.Crescendo=Fe,yi.Curve=Be,yi.Dot=Nt,yi.EasyScore=He,yi.Element=A,yi.Factory=mi,yi.Font=k,yi.Formatter=we,yi.Fraction=x,yi.FretHandFinger=At,yi.GhostNote=Ve,yi.Glyph=R,yi.GlyphNote=ze,yi.GraceNote=Ke,yi.GraceNoteGroup=Mt,yi.GraceTabNote=class extends ai{static get CATEGORY(){return c.GraceTabNote}constructor(t){super(t,!1),this.render_options=Object.assign(Object.assign({},this.render_options),{y_shift:.3,scale:.6,font:`7.5pt ${k.SANS_SERIF}`}),this.updateWidth()}},yi.KeyManager=class{constructor(t){this.music=new L,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(!L.scaleTypes[this.keyParts.type])throw new d("BadArguments",`Unsupported key type: ${this.key}`);this.scale=this.music.getScaleTones(this.music.getNoteValue(this.keyString),L.scaleTypes[this.keyParts.type]),this.scaleMap={},this.scaleMapByValue={},this.originalScaleMapByValue={};const t=L.root_indices[this.keyParts.root];for(let e=0;e<L.roots.length;++e){const i=(t+e)%L.roots.length,s=L.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})}},yi.KeySignature=oe,yi.KeySigNote=$e,yi.Modifier=O,yi.ModifierContext=ne,yi.MultiMeasureRest=Je,yi.Music=L,yi.Note=mt,yi.NoteHead=Wt,yi.NoteSubGroup=Rt,yi.Ornament=Lt,yi.Parenthesis=It,yi.Parser=Oe,yi.PedalMarking=Ze,yi.Registry=N,yi.RenderContext=ut,yi.Renderer=Zt,yi.RepeatNote=ei,yi.Repetition=re,yi.Stave=_e,yi.StaveConnector=Se,yi.StaveHairpin=fi,yi.StaveLine=si,yi.StaveModifier=wt,yi.StaveNote=Yt,yi.StaveTempo=ce,yi.StaveText=le,yi.StaveTie=Ft,yi.Stem=Q,yi.StringNumber=te,yi.Stroke=ee,yi.SVGContext=Kt,yi.System=ni,yi.TabNote=ai,yi.TabSlide=_i,yi.TabStave=oi,yi.TabTie=Pt,yi.TextBracket=ci,yi.TextDynamics=li,yi.TextFormatter=it,yi.TextNote=de,yi.TickContext=Ot,yi.TimeSignature=pe,yi.TimeSigNote=gi,yi.Tremolo=class extends O{constructor(t){super(),this.num=t,this.position=O.Position.CENTER,this.code="tremolo1",this.y_spacing_scale=1,this.extra_stroke_scale=1}static get CATEGORY(){return c.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 a=n(e),o=a?Ke.SCALE:1,r="tremolo."+(a?"grace":"default"),h=K.currentMusicFont();let c=h.lookupMetric(`${r}.spacing`)*i;c*=this.y_spacing_scale;const d=this.num*c;let l=e.getStemExtents().baseY-d;l+=i<0?h.lookupMetric(`${r}.offsetYStemDown`)*o:h.lookupMetric(`${r}.offsetYStemUp`)*o;const g=h.lookupMetric(`${r}.point`);s+=h.lookupMetric(`${r}.offsetXStem${i===Q.UP?"Up":"Down"}`);for(let e=0;e<this.num;++e)R.renderGlyph(t,s,l,g,this.code,{category:r,scale:this.extra_stroke_scale}),l+=c}},yi.Tuning=xi,yi.Tuplet=Ee,yi.Vibrato=ie,yi.VibratoBracket=ui,yi.Voice=Bt,yi.Volta=ge,yi.BarlineType=_t,yi.ModifierPosition=P;class Ti{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 d("BadArgument","Invalid canvas selector: "+t);const e=document.getElementById(t);if(!e||!e.getContext)throw new d("UnsupportedBrowserError","This browser does not support HTML5 Canvas");return e.getContext("2d")}static benchmark(t,e){const i=(new Date).getTime();e();u(t,(new Date).getTime()-i+"ms")}static stackTrace(){return(new Error).stack}}Ti.Flow=yi;const bi={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"},wi={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"};var vi=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 Ei={Bravura:"./vexflow-font-bravura.js",Gonville:"./vexflow-font-gonville.js",Petaluma:"./vexflow-font-petaluma.js",Custom:"./vexflow-font-custom.js"};yi.fetchMusicFont=(t,e)=>vi(void 0,void 0,void 0,(function*(){const i=k.load(t);if(i.hasData())return;if(!e){if(!(t in Ei))throw new d("UnknownFont",`Music font ${t} does not exist.`);e=Ei[t]}let s;if("string"==typeof e){const i=yield import(e),n=l().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=wi,{fontFamily:e,resolution:i,glyphs:s}=t;k.load(e,t);const n="b";it.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=bi,{fontFamily:e,resolution:i,glyphs:s}=t;k.load(e,t);const n="b";it.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."})}}();const Ci=Ti;return 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);var e={};function i(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.d(e,{default:()=>Ci});const s=t=>i(t,c.Barline),n=t=>i(t,c.GraceNote),a=t=>i(t,c.Note),o=t=>i(t,c.StaveNote),r=t=>i(t,c.StemmableNote),h=t=>i(t,c.TabNote);var c;!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"}(c||(c={}));class d extends Error{constructor(t,e=""){super("[RuntimeError] "+t+": "+e),this.code=t}}function l(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==t.g?t.g:Function("return this")()}function g(t,e="undefined",i=""){if(void 0===t)throw new d(e,i);return t}function u(t,...e){if(!e)return;const i=Array.prototype.slice.call(e).join(" ");l().console.log(t+": "+i)}function p(...t){const e=t.join(" "),i=new Error;l().console.log("Warning: ",e,i.stack)}function m(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 _(t){return`vf-${t}`}function f(t){return(t%=2*Math.PI)<0&&(t+=2*Math.PI),t}class x{constructor(t,e){this.numerator=1,this.denominator=1,this.set(t,e)}static get CATEGORY(){return c.Fraction}static GCD(t,e){if("number"!=typeof t||Number.isNaN(t)||"number"!=typeof e||Number.isNaN(e))throw new d("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/x.GCD(t,e)}static LCMM(t){return 0===t.length?0:1===t.length?t[0]:2===t.length?x.LCM(t[0],t[1]):x.LCM(t.shift(),x.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=x.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]=S(t,e),n=x.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]=S(t,e),n=x.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]=S(t,e);return this.set(this.numerator*i,this.denominator*s)}divide(t=1,e=1){const[i,s]=S(t,e);return this.set(this.numerator*s,this.denominator*i)}equals(t){const e=x.__staticFractionA.copy(t).simplify(),i=x.__staticFractionB.copy(this).simplify();return e.numerator===i.numerator&&e.denominator===i.denominator}greaterThan(t){const e=x.__staticFractionB.copy(this);return e.subtract(t),e.numerator>0}greaterThanEquals(t){const e=x.__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 x(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 x.__staticFractionTmp.copy(this).simplify().toString()}toMixedString(){let t="";const e=this.quotient(),i=x.__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 S(t,e=1){return"number"==typeof t?[t,e]:[t.numerator,t.denominator]}x.__staticFractionA=new x,x.__staticFractionB=new x,x.__staticFractionTmp=new x;class y{constructor(t,e,i,s){this.x=t,this.y=e,this.w=i,this.h=s}static copy(t){return new y(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 y.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 T{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 b,w,v=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 E;!function(t){t.NORMAL="normal",t.BOLD="bold"}(b||(b={})),function(t){t.NORMAL="normal",t.ITALIC="italic"}(w||(w={}));const C={};class k{constructor(t){this.name=t}static convertSizeToPixelValue(t=k.SIZE){var e;if("number"==typeof t)return t*k.scaleToPxFrom.pt;{const i=parseFloat(t);if(isNaN(i))return 0;const s=t.replace(/[\d.\s]/g,"").toLowerCase();return i*(null!==(e=k.scaleToPxFrom[s])&&void 0!==e?e:1)}}static convertSizeToPointValue(t=k.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=k.scaleToPxFrom[s])&&void 0!==e?e:1)/k.scaleToPxFrom.pt)}}static validate(t,e,i,s){if("string"==typeof t&&void 0===e&&void 0===i&&void 0===s)return k.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:k.SANS_SERIF,e=null!=e?e:k.SIZE+"pt",i=null!=i?i:b.NORMAL,s=null!=s?s:w.NORMAL,""===i&&(i=b.NORMAL),""===s&&(s=w.NORMAL),"number"==typeof e&&(e=`${e}pt`),"number"==typeof i&&(i=i.toString()),{family:n,size:e,weight:i,style:s}}static fromCSSString(t){E||(E=document.createElement("span")),E.style.font=t;const{fontFamily:e,fontSize:i,fontWeight:s,fontStyle:n}=E.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===w.NORMAL||""===s||void 0===s?"":s.trim()+" ";const a=t.weight;let o;n=a===b.NORMAL||""===a||void 0===a?"":"number"==typeof a?a+" ":a.trim()+" ";const r=t.size;o=void 0===r?k.SIZE+"pt ":"number"==typeof r?r+"pt ":r.trim()+" ";return`${i}${n}${o}${null!==(e=t.family)&&void 0!==e?e:k.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()===w.ITALIC}static loadWebFont(t,e,i=!0){return v(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 v(this,void 0,void 0,(function*(){const t=k.WEB_FONT_HOST,e=k.WEB_FONT_FILES;for(const i in e){const s=e[i];k.loadWebFont(i,t+s)}}))}static loadTextFonts(){}static load(t,e,i){let s=C[t];return s||(s=new k(t),C[t]=s),e&&s.setData(e),i&&s.setMetrics(i),s}getName(){return this.name}getData(){return g(this.data,"FontError","Missing font data")}getMetrics(){return g(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]"}}k.SANS_SERIF="Arial, sans-serif",k.SERIF="Times New Roman, serif",k.SIZE=10,k.scaleToPxFrom={pt:4/3,px:1,em:16,"%":.16,in:96,mm:96/25.4,cm:96/2.54},k.WEB_FONT_HOST="https://unpkg.com/vexflow-fonts@1.0.3/",k.WEB_FONT_FILES={"Roboto Slab":"robotoslab/RobotoSlab-Medium_2.001.woff",PetalumaScript:"petaluma/PetalumaScript_1.10_FS.woff"};class D{constructor(){this.id={},this.type={},this.class={}}}class N{constructor(){this.index=new D}static getDefaultRegistry(){return N.defaultRegistry}static enableDefaultRegistry(t){N.defaultRegistry=t}static disableDefaultRegistry(){N.defaultRegistry=void 0}clear(){return this.index=new D,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 d("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 A{constructor(){var t;this.attrs={id:A.newID(),el:void 0,type:this.getCategory(),classes:{}},this.rendered=!1,null===(t=N.getDefaultRegistry())||void 0===t||t.register(this)}static get CATEGORY(){return c.Element}static newID(){return"auto"+A.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 g(this.context,"NoContext","No rendering context attached to instance.")}set font(t){this.setFont(t)}get font(){return k.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?k.fromCSSString(t):r&&h?Object.assign({},n):k.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(),k.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 k.convertSizeToPointValue(this.fontSize)}get fontSizeInPixels(){return k.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 F,P;A.ID=1e3,A.TEXT_FONT={family:k.SANS_SERIF,size:k.SIZE,weight:b.NORMAL,style:w.NORMAL},function(t){t[t.MOVE=0]="MOVE",t[t.LINE=1]="LINE",t[t.QUADRATIC=2]="QUADRATIC",t[t.BEZIER=3]="BEZIER"}(F||(F={}));class M{constructor(t,e,i){this.point=-1,this.metrics=R.loadMetrics(t,e,i),this.bbox=R.getOutlineBoundingBox(this.metrics.outline,this.metrics.scale,this.metrics.x_shift,this.metrics.y_shift),i&&(this.point=R.lookupFontMetric(this.metrics.font,i,e,"point",-1))}}class B{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(F.MOVE,parseInt(i[s++]),parseInt(i[s++]));break;case"l":e.push(F.LINE,parseInt(i[s++]),parseInt(i[s++]));break;case"q":e.push(F.QUADRATIC,parseInt(i[s++]),parseInt(i[s++]),parseInt(i[s++]),parseInt(i[s++]));break;case"b":e.push(F.BEZIER,parseInt(i[s++]),parseInt(i[s++]),parseInt(i[s++]),parseInt(i[s++]),parseInt(i[s++]),parseInt(i[s++]))}return e}}class R extends A{constructor(t,e,i){super(),this.bbox=new y(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 c.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;g(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 d("BadGlyph",`Glyph ${e} does not exist in font.`)}static loadMetrics(t,e,i){const{glyph:s,font:n}=R.lookupGlyph(t,e);if(!s.o)throw new d("BadGlyph",`Glyph ${e} has no outline defined.`);let a=0,o=0,r=1;i&&n&&(a=R.lookupFontMetric(n,i,e,"shiftX",0),o=R.lookupFontMetric(n,i,e,"shiftY",0),r=R.lookupFontMetric(n,i,e,"scale",1));const h=s.x_min,c=s.x_max,l=s.ha;return s.cached_outline||(s.cached_outline=B.parse(s.o)),{x_min:h,x_max:c,x_shift:a,y_shift:o,scale:r,ha:l,outline:s.cached_outline,font:n,width:c-h,height:l}}static renderGlyph(t,e,i,s,n,a){var o;const r=R.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 R.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 B(e,s,n,i);let o,r;for(t.beginPath();!a.done();)switch(a.next()){case F.MOVE:t.moveTo(a.nextX(),a.nextY());break;case F.LINE:t.lineTo(a.nextX(),a.nextY());break;case F.QUADRATIC:o=a.nextX(),r=a.nextY(),t.quadraticCurveTo(a.nextX(),a.nextY(),o,r);break;case F.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 B(t,i,s,e),a=new T;let o,r,h=i,c=s;for(;!n.done();)switch(n.next()){case F.MOVE:h=n.nextX(),c=n.nextY();break;case F.LINE:a.addPoint(h,c),h=n.nextX(),c=n.nextY(),a.addPoint(h,c);break;case F.QUADRATIC:o=n.nextX(),r=n.nextY(),a.addQuadraticCurve(h,c,n.nextX(),n.nextY(),o,r),h=o,c=r;break;case F.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 y(a.getX1(),a.getY1(),a.width(),a.height())}static getWidth(t,e,i){const s=R.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}setXShift(t){return this.x_shift=t,this}setYShift(t){return this.y_shift=t,this}reset(){const t=R.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 y(t.bbox.getX()*this.scale,t.bbox.getY()*this.scale,t.bbox.getW()*this.scale,t.bbox.getH()*this.scale)}checkMetrics(){return g(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;R.renderOutline(t,n,a,o,r),this.restoreStyle(t)}checkStave(){return g(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;R.renderOutline(e,n,a,o,r),this.restoreStyle()}}R.cache=new class{constructor(){this.cache=new Map}lookup(t,e){let i=this.cache.get(R.CURRENT_CACHE_KEY);void 0===i&&(i={},this.cache.set(R.CURRENT_CACHE_KEY,i));const s=e?`${t}%${e}`:t;let n=i[s];return void 0===n&&(n=new M(R.MUSIC_FONT_STACK,t,e),i[s]=n),n}},R.CURRENT_CACHE_KEY="",R.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"}(P||(P={}));class O extends A{constructor(){super(),this.width=0,this.text_line=0,this.position=O.Position.LEFT,this.x_shift=0,this.y_shift=0,this.spacingFromNextModifier=0}static get CATEGORY(){return c.Modifier}static get Position(){return P}static get PositionString(){return{center:P.CENTER,above:P.ABOVE,below:P.BELOW,left:P.LEFT,right:P.RIGHT}}reset(){}getWidth(){return this.width}setWidth(t){return this.width=t,this}getNote(){return g(this.note,"NoNote","Modifier has no note.")}checkAttachedNote(){const t=this.getCategory();return g(this.index,"NoIndex",`Can't draw ${t} without an index.`),g(this.note,"NoNote",`Can't draw ${t} without a note.`)}setNote(t){return this.note=t,this}getIndex(){return this.index}checkIndex(){return g(this.index,"NoIndex","Modifier has an invalid index.")}setIndex(t){return this.index=t,this}getModifierContext(){return this.modifierContext}checkModifierContext(){return g(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?O.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===O.Position.LEFT?this.x_shift-=t:this.x_shift+=t,this}getXShift(){return this.x_shift}draw(){throw this.checkContext(),new d("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 L{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:L.scales.major,m:L.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<L.canonical_notes.length}isValidIntervalValue(t){return t>=0&&t<L.diatonic_intervals.length}getNoteParts(t){if(!t||t.length<1)throw new d("BadArguments","Invalid note name: "+t);if(t.length>3)throw new d("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 d("BadArguments","Invalid note name: "+t)}getKeyParts(t){if(!t||t.length<1)throw new d("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 d("BadArguments",`Invalid key: ${t}`)}getNoteValue(t){const e=L.noteValues[t];if(void 0===e)throw new d("BadArguments",`Invalid note name: ${t}`);return e.int_val}getIntervalValue(t){const e=L.intervals[t];if(void 0===e)throw new d("BadArguments",`Invalid interval name: ${t}`);return e}getCanonicalNoteName(t){if(!this.isValidNoteValue(t))throw new d("BadArguments",`Invalid note value: ${t}`);return L.canonical_notes[t]}getCanonicalIntervalName(t){if(!this.isValidIntervalValue(t))throw new d("BadArguments",`Invalid interval value: ${t}`);return L.diatonic_intervals[t]}getRelativeNoteValue(t,e,i=1){if(1!==i&&-1!==i)throw new d("BadArguments",`Invalid direction: ${i}`);let s=(t+i*e)%L.NUM_TONES;return s<0&&(s+=L.NUM_TONES),s}getRelativeNoteName(t,e){const i=this.getNoteParts(t),s=this.getNoteValue(i.root);let n=e-s;if(Math.abs(n)>L.NUM_TONES-3){let i=1;n>0&&(i=-1);const a=(e+1+(s+1))%L.NUM_TONES*i;if(Math.abs(a)>2)throw new d("BadArguments",`Notes not related: ${t}, ${e})`);n=a}if(Math.abs(n)>2)throw new d("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 d("BadArguments",`Invalid direction: ${i}`);if(!this.isValidNoteValue(t)||!this.isValidNoteValue(e))throw new d("BadArguments",`Invalid notes: ${t}, ${e}`);let s=1===i?e-t:t-e;return s<0&&(s+=L.NUM_TONES),s}createScaleMap(t){const e=this.getKeyParts(t);if(!e.type)throw new d("BadArguments","Unsupported key type: undefined");const i=L.scaleTypes[e.type];let s=e.root;if(e.accidental&&(s+=e.accidental),!i)throw new d("BadArguments","Unsupported key type: "+t);const n=this.getScaleTones(this.getNoteValue(s),i),a=L.root_indices[e.root],o={};for(let t=0;t<L.roots.length;++t){const e=(a+t)%L.roots.length,i=L.roots[e];let s=this.getRelativeNoteName(i,n[t]);1===s.length&&(s+="n"),o[i]=s}return o}}const I=16384,W={"1/2":32768,1:16384,2:8192,4:4096,8:2048,16:1024,32:512,64:256,128:128,256:64},G={w:"1",h:"2",q:"4",b:"256"},U={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}},Y={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}},H={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"}},X={"#":{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}},V={"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 K{static currentMusicFont(){if(0===K.MUSIC_FONT_STACK.length)throw new d("NoFonts","The font stack is empty. See: await Flow.fetchMusicFont(...); Flow.setMusicFont(...).");return K.MUSIC_FONT_STACK[0]}static clefProperties(t){if(!t||!(t in Y))throw new d("BadArgument","Invalid clef: "+t);return Y[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 d("BadArguments",`First argument must be note/octave or note/octave/glyph-code: ${t}`);const a=n[0].toUpperCase(),o=H[a];if(!o)throw new d("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+=K.clefProperties(e).line_shift;let c=0;h<=0&&2*h%2==0&&(c=1),h>=6&&2*h%2==0&&(c=-1);const l=void 0!==o.int_val?12*r+o.int_val:void 0,g=o.code,u=o.shift_right;let p={};if(n.length>2&&n[2]){const t=n[2].toUpperCase();p=j[t]||{}}return Object.assign({key:a,octave:r,line:h,int_value:l,accidental:o.accidental,code:g,stroke:c,shift_right:u,displaced:!1},p)}static integerToNote(t){if(void 0===t||t<0||t>11)throw new d("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 d("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 R("accidentalDoubleSharp",K.TABLATURE_FONT_SCALE).getMetrics();if(i="accidentalDoubleSharp",null==t.width||null==t.height)throw new d("InvalidMetrics","Width and height required");s=t.width,n=-t.height/2}else s=K.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 V[t]}static accidentalCodes(t){return X[t]}static ornamentCodes(t){return z[t]}static keySignature(t){const e=U[t];if(!e)throw new d("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 U}static hasKeySignature(t){return t in U}static sanitizeDuration(t){const e=G[t];if(void 0!==e&&(t=e),void 0===W[t])throw new d("BadArguments",`The provided duration is not valid: ${t}`);return t}static durationToFraction(t){return(new x).parse(K.sanitizeDuration(t))}static durationToNumber(t){return K.durationToFraction(t).value()}static durationToTicks(t){t=K.sanitizeDuration(t);const e=W[t];if(void 0===e)throw new d("InvalidDuration");return e}static getGlyphProps(t,e="n"){t=K.sanitizeDuration(t);const i=$[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=K.NOTATION_FONT_SCALE)=>R.getWidth(n,t)}),s)}}K.STEM_WIDTH=1.5,K.STEM_HEIGHT=35,K.STAVE_LINE_THICKNESS=1,K.RESOLUTION=I,K.MUSIC_FONT_STACK=[],K.NOTATION_FONT_SCALE=39,K.TABLATURE_FONT_SCALE=39,K.SLASH_NOTEHEAD_WIDTH=15,K.STAVE_LINE_DISTANCE=10,K.TEXT_HEIGHT_OFFSET_HACK=1,K.accidentalMap=X,K.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]}},K.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)},K.validTypes={n:{name:"note"},r:{name:"rest"},h:{name:"harmonic"},m:{name:"muted"},s:{name:"slash"},g:{name:"ghost"}},K.TIME4_4={num_beats:4,beat_value:4,resolution:I};const $={"1/2":{common:{stem:!1,stem_offset:0,flag:!1,stem_up_extension:-K.STEM_HEIGHT,stem_down_extension:-K.STEM_HEIGHT,tabnote_stem_up_extension:-K.STEM_HEIGHT,tabnote_stem_down_extension:-K.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:()=>K.SLASH_NOTEHEAD_WIDTH,position:"B/4"},g:{code_head:"noteheadDoubleWhole"}}},1:{common:{stem:!1,stem_offset:0,flag:!1,stem_up_extension:-K.STEM_HEIGHT,stem_down_extension:-K.STEM_HEIGHT,tabnote_stem_up_extension:-K.STEM_HEIGHT,tabnote_stem_down_extension:-K.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:()=>K.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:()=>K.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:()=>K.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:()=>K.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:()=>K.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:()=>K.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:()=>K.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:()=>K.SLASH_NOTEHEAD_WIDTH,position:"B/4"},g:{code_head:"noteheadBlack"}}}};function J(...t){q.DEBUG&&u("Vex.Flow.Accidental",t)}class q extends O{constructor(t){super(),J("New accidental: ",t),this.type=t,this.position=O.Position.LEFT,this.render_options={font_scale:38,parenLeftPadding:2,parenRightPadding:2},this.accidental=K.accidentalCodes(this.type),g(this.accidental,"ArgumentError",`Unknown accidental type: ${t}`),this.cautionary=!1,this.reset()}static get CATEGORY(){return c.Accidental}static format(t,e){if(!t||0===t.length)return;const i=K.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=K.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 _=m[m.length-1];let f=0;d.forEach((t=>{let e=0;const i=f+t.numAcc;for(;f<i;f++){const i=m[t.column-1]+e;r[f].acc.setXShift(i),e+=r[f].acc.getWidth()+a,J("Line, accCount, shift: ",t.line,f,i)}})),e.left_shift+=_+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 J("Line_1, Line_2, Collision: ",t.line,e.line,n),n}static applyAccidentals(t,e){const s=[],n={};t.forEach((t=>{const e=new x(0,1);t.getTickables().forEach((t=>{if(t.shouldIgnoreTicks())return;const i=n[e.value()];i?i.push(t):(s.push(e.value()),n[e.value()]=[t]),e.add(t.getTicks())}))}));const a=new L;e||(e="C");const r=a.createScaleMap(e),h={};s.forEach((t=>{const e=n[t],s=[],d=t=>{if(!o(t)||t.isRest()||t.shouldIgnoreTicks())return;const e=t;e.keys.forEach(((t,n)=>{const o=a.getNoteParts(t.split("/")[0]),d=t.split("/")[1],l=o.accidental||"n",g=o.root+l;h[o.root+d]||(h[o.root+d]=r[o.root]);const u=h[o.root+d]===g,p=s.indexOf(t)>-1;if(e.getModifiers().forEach(((t,s)=>{i(t,c.Accidental)&&t.type==l&&t.getIndex()==n&&e.getModifiers().splice(s,1)})),!u||u&&p){h[o.root+d]=g;const i=new q(l);e.addModifier(i,n),s.push(t)}})),e.getModifiers().forEach((t=>{i(t,c.GraceNoteGroup)&&t.getGraceNotes().forEach(d)}))};e.forEach(d)}))}reset(){const t=this.render_options.font_scale;this.glyph=new R(this.accidental.code,t),this.glyph.setOriginX(1),this.cautionary&&(this.parenLeft=new R(K.accidentalCodes("{").code,t),this.parenRight=new R(K.accidentalCodes("}").code,t),this.parenLeft.setOriginX(1),this.parenRight.setOriginX(1))}getWidth(){if(this.cautionary){const t=g(this.parenLeft),e=g(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 g(t,"ArgumentError",`Bad note value: ${t}`),this.note=t,n(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 u=l.x+n;const p=l.y+a;if(J("Rendering: ",t,u,p),s){const t=g(this.parenLeft),e=g(this.parenRight);e.render(c,u,p),u-=e.getMetrics().width,u-=h,u-=this.accidental.parenRightPaddingAdjustment,o.render(c,u,p),u-=o.getMetrics().width,u-=r,t.render(c,u,p)}else o.render(c,u,p)}}q.DEBUG=!1;class Q extends A{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 c.Stem}static get UP(){return 1}static get DOWN(){return-1}static get WIDTH(){return K.STEM_WIDTH}static get HEIGHT(){return K.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===Q.UP?this.stem_up_y_offset:this.stem_down_y_offset;return(this.y_bottom-this.y_top+(Q.HEIGHT-t+this.stem_extension))*this.stem_direction}getBoundingBox(){throw new d("NotImplemented","getBoundingBox() not implemented.")}getExtents(){const t=this.stem_direction===Q.UP,e=[this.y_top,this.y_bottom],i=Q.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=K.currentMusicFont().lookupMetric("stem.heightAdjustmentForFlag",-3)}adjustHeightForBeam(){this.renderHeightAdjustment=-Q.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===Q.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){Q.DEBUG&&u("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(Q.WIDTH),t.moveTo(e,i-o+n),t.lineTo(e,i-a-this.renderHeightAdjustment*s),t.stroke(),this.restoreStyle(t),t.restore()}}function Z(...t){it.DEBUG&&u("Vex.Flow.TextFormatter",t)}Q.DEBUG=!1;const tt={},et={};class it{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 et){const i=et[e];t.push(Object.assign({},i))}return t}static create(t={}){Z("create: ",t),t.family||(t.family=k.SANS_SERIF);const e=[],i=t.family.split(/\s*,\s*/);for(const t of i){for(const i in et)i.startsWith(t)&&e.push(et[i]);if(e.length>0)break}let s;if(0===e.length)s=new it(Object.values(et)[0]);else if(1===e.length)s=new it(e[0]);else{const i=k.isBold(t.weight),n=k.isItalic(t.style),a=e.find((t=>t.bold===i&&t.italic===n));if(a)s=new it(a);else{const t=e.find((t=>t.italic===n||t.bold===i));s=new it(t||e[0])}}const n=t.size;if(void 0!==n){const t=k.convertSizeToPointValue(n);s.setFontSize(t)}return s}static getInfo(t){return et[t]}static registerInfo(t,e=!1){Z("registerInfo: ",t,e);const i=t.family;(void 0===et[i]||e)&&(et[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?b.BOLD:b.NORMAL,s=this.italic?w.ITALIC:w.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=tt[e];void 0===i&&(i={},tt[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*k.scaleToPxFrom.pt}getResolution(){return this.resolution}}var st,nt;it.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"}(st||(st={})),function(t){t[t.TOP=1]="TOP",t[t.CENTER=2]="CENTER",t[t.BOTTOM=3]="BOTTOM",t[t.CENTER_STEM=4]="CENTER_STEM"}(nt||(nt={}));class at extends O{constructor(t){super(),this.text=t,this.horizontalJustification=st.CENTER,this.verticalJustification=nt.TOP,this.resetFont(),this.setWidth(K.textWidth(t))}static get CATEGORY(){return c.Annotation}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 c=t[o],d=it.create(c.textFont);let l=(5+d.maxHeight)/K.STAVE_LINE_DISTANCE;const g=c.checkAttachedNote(),u=g.getGlyph().getWidth(),p=d.getWidthForTextInPx(c.text);c.horizontalJustification===st.LEFT?(n=Math.max(u,n),i=Math.max(i,p)):c.horizontalJustification===st.RIGHT?(a=Math.max(u,n),s=Math.max(s,p)):(i=Math.max(i,p/2),s=Math.max(s,p/2),n=Math.max(u/2,n),a=Math.max(u/2,a));const m=g.getStave(),_=g.hasStem()?g.getStemDirection():Q.UP;let f=0,x=5;if(h(g))if(g.render_options.draw_stem){const t=g.getStem();t&&(f=Math.abs(t.getHeight())/K.STAVE_LINE_DISTANCE)}else f=0;else if(r(g)){const t=g.getStem();t&&"n"===g.getNoteType()&&(f=Math.abs(t.getHeight())/K.STAVE_LINE_DISTANCE)}if(m&&(x=m.getNumLines()),c.verticalJustification===this.VerticalJustify.TOP){let t=g.getLineNumber(!0);h(g)&&(t=x-(g.leastString()-.5)),_===Q.UP&&(t+=f);t+e.top_text_line+.5<x?(c.setTextLine(x-t),l+=x-t,e.top_text_line=l):(c.setTextLine(e.top_text_line),e.top_text_line+=l)}else if(c.verticalJustification===this.VerticalJustify.BOTTOM){let t=x-g.getLineNumber();h(g)&&(t=g.greatestString()-1),_===Q.DOWN&&(t+=f);const i=t+e.text_line+1;i<x?(c.setTextLine(x-i),l+=x-i,e.text_line=l):(c.setTextLine(e.text_line),e.text_line+=l)}else c.setTextLine(e.text_line)}const o=Math.min(Math.max(s-a,0),Math.max(s-e.right_shift,0)),c=Math.min(Math.max(i-n,0),Math.max(i-e.left_shift,0));return e.left_shift+=c/2,e.right_shift+=o/2,!0}setVerticalJustification(t){return this.verticalJustification="string"==typeof t?at.VerticalJustifyString[t]:t,this}getJustification(){return this.horizontalJustification}setJustification(t){return this.horizontalJustification="string"==typeof t?at.HorizontalJustifyString[t]:t,this}draw(){const t=this.checkContext(),e=this.checkAttachedNote(),i=e.hasStem()?e.getStemDirection():Q.UP,s=it.create(this.textFont),n=e.getModifierStartXY(P.ABOVE,this.index);this.setRendered(),t.save();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===st.LEFT?n.x:this.horizontalJustification===st.RIGHT?n.x-o:this.horizontalJustification===st.CENTER?n.x-o/2:e.getStemX()-o/2;let d={},l=0;const g=e.hasStem(),p=e.checkStave();if(g&&(d=e.checkStem().getExtents(),l=p.getSpacingBetweenLines()),this.verticalJustification===nt.BOTTOM){c=e.getYs().reduce(((t,e)=>t>e?t:e)),c+=(this.text_line+1)*K.STAVE_LINE_DISTANCE+r,g&&i===Q.DOWN&&(c=Math.max(c,d.topY+r+l*this.text_line))}else if(this.verticalJustification===nt.CENTER){const t=e.getYForTopText(this.text_line)-1;c=t+(p.getYForBottomText(this.text_line)-t)/2+r/2}else if(this.verticalJustification===nt.TOP)c=e.getYs()[0]-(this.text_line+1)*K.STAVE_LINE_DISTANCE,g&&i===Q.UP&&(l=d.topY<p.getTopLineTopY()?K.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){at.DEBUG&&u("Vex.Flow.Annotation",t)}("Rendering annotation: ",this.text,h,c),t.fillText(this.text,h,c),t.closeGroup(),t.restore()}}at.DEBUG=!1,at.TEXT_FONT=Object.assign({},A.TEXT_FONT),at.HorizontalJustify=st,at.HorizontalJustifyString={left:st.LEFT,right:st.RIGHT,center:st.CENTER,centerStem:st.CENTER_STEM},at.VerticalJustify=nt,at.VerticalJustifyString={above:nt.TOP,top:nt.TOP,below:nt.BOTTOM,bottom:nt.BOTTOM,center:nt.CENTER,centerStem:nt.CENTER_STEM};const{ABOVE:ot,BELOW:rt}=O.Position;function ht(t,e){return.5*t(e/.5)}function ct(t,e){return e===ot?t<=5:t>=1}function dt(t,e){return ct(t,e)?e===ot?Math.ceil:Math.floor:Math.round}const lt=t=>o(t)||n(t);class gt extends O{constructor(t){super(),this.type=t,this.position=rt,this.render_options={font_scale:38},this.reset()}static get CATEGORY(){return c.Articulation}static format(t,e){if(!t||0===t.length)return!1;let i=0;const s=(t,e,i)=>ht(dt(e,i),g(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():Q.UP;let h=0;if(r(n)){const t=n.getStem();t&&(h=Math.abs(t.getHeight())/K.STAVE_LINE_DISTANCE)}const c=n.getStave();if(c&&(a=c.getNumLines()),t.getPosition()===ot){let i=n.getLineNumber(!0);o===Q.UP&&(i+=h);let r=s(t,e.top_text_line,ot);const c=i+e.top_text_line+.5;!t.articulation.between_lines&&c<a&&(r+=a-c),t.setTextLine(e.top_text_line),e.top_text_line+=r}else if(t.getPosition()===rt){let i=Math.max(a-n.getLineNumber(),0);o===Q.DOWN&&(i+=h);let r=s(t,e.text_line,rt);const c=i+e.text_line+.5;!t.articulation.between_lines&&c<a&&(r+=a-c),t.setTextLine(e.text_line),e.text_line+=r}}));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=O.PositionString[e]),i.getFactory().Articulation(n)})).map((t=>e.addModifier(t,0)))}reset(){this.articulation=K.articulationCodes(this.type);const t=g(this.articulation,"ArgumentError",`Articulation not found: ${this.type}`),e=(this.position===ot?t.aboveCode:t.belowCode)||t.code;this.glyph=new R(null!=e?e:"",this.render_options.font_scale),this.setWidth(g(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(),c=r.getSpacingBetweenLines(),l=h(e),{x:g}=e.getModifierStartXY(s,i),p=!o||l,m=function(t,e){const i=e===ot&&t.getStemDirection()===Q.UP||e===rt&&t.getStemDirection()===Q.DOWN;return lt(t)?t.hasStem()&&i?.5:1:t.hasStem()&&i?1:0}(e,s),_=K.currentMusicFont().lookupMetric(`articulation.${n.getCode()}.padding`,0);let f={[ot]:()=>{n.setOrigin(.5,1);const t=function(t,e){const i=t.getStemDirection(),{topY:s,baseY:n}=t.getStemExtents();if(lt(t))return t.hasStem()?i===Q.UP?s:n:Math.min(...t.getYs());if(h(t))return t.hasStem()&&i===Q.UP?s:t.checkStave().getYForTopText(e);throw new d("UnknownCategory","Only can get the top and bottom ys of stavenotes and tabnotes")}(e,a)-(a+m)*c;return p?Math.min(r.getYForTopText(gt.INITIAL_OFFSET),t):t},[rt]:()=>{n.setOrigin(.5,0);const t=function(t,e){const i=t.getStemDirection(),{topY:s,baseY:n}=t.getStemExtents();if(lt(t))return t.hasStem()?i===Q.UP?n:s:Math.max(...t.getYs());if(h(t))return t.hasStem()?i===Q.UP?t.checkStave().getYForBottomText(e):s:t.checkStave().getYForBottomText(e);throw new d("UnknownCategory","Only can get the top and bottom ys of stavenotes and tabnotes")}(e,a)+(a+m)*c;return p?Math.max(r.getYForBottomText(gt.INITIAL_OFFSET),t):t}}[s]();if(!l){const t=s===ot?-1:1,a=e.getKeyProps()[i].line,r=(e.getYs()[i]-f)/c+Number(a),h=function(t,e,i,s){const n=ht(dt(e,i),e);if(t&&ct(n,i)&&n%1==0)return n+.5*-s;return n}(o,r,s,t);ct(h,s)&&n.setOrigin(.5,.5),f+=Math.abs(h-r)*c*t+_*t}!function(...t){gt.DEBUG&&u("Vex.Flow.Articulation",t)}(`Rendering articulation at (x: ${g}, y: ${f})`),n.render(t,g,f)}}gt.DEBUG=!1,gt.INITIAL_OFFSET=-.5;class ut{static get CATEGORY(){return c.RenderContext}set font(t){this.setFont(t)}get font(){return this.getFont()}setRawFont(t){return this.setFont(t),this}}class pt extends A{constructor(){super(),this._preFormatted=!1,this._postFormatted=!1,this.ticks=new x(0,1),this.intrinsicTicks=0,this.tickMultiplier=new x(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 c.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 d("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 g(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 g(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*(K.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 g(this.modifierContext,"NoModifierContext","No modifier context attached to this tickable.")}}class mt extends pt{constructor(t){if(super(),!t)throw new d("BadArguments","Note must have valid initialization data to identify duration and type.");const e=mt.parseNoteStruct(t);if(!e)throw new d("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=K.getGlyphProps(this.duration,this.noteType),this.customGlyphs=this.customTypes.map((t=>K.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 c.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(k.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"),function(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()}(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=mt.parseDuration(t.duration);if(!e)return;let i=t.type;if(i&&!K.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=K.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 g(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 d("NoYValues","No Y-values calculated for this note.");return this.ys}getYForTopText(t){return this.checkStave().getYForTopText(t)}getVoice(){if(!this.voice)throw new d("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 g(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 d("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 d("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():0}getFirstDotPx(){let t=this.getRightDisplacedHeadPx();return 0!==this.checkModifierContext().getMembers("Parenthesis").length&&(t+=K.currentMusicFont().lookupMetric("parenthesis.default.width")),t}getMetrics(){if(!this.preFormatted)throw new d("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()+K.currentMusicFont().lookupMetric("stave.padding")),this.isCenterAligned()&&(t+=this.getCenterXShift()),t}getStemDirection(){throw new d("NoStem","No stem attached to this note.")}getStemExtents(){throw new d("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 _t,ft,xt,St,yt,Tt,bt;!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"}(_t||(_t={}));class wt extends A{constructor(){super(),this.width=0,this.x=0,this.padding=10,this.position=_t.ABOVE}static get CATEGORY(){return c.StaveModifier}static get Position(){return _t}getPosition(){return this.position}setPosition(t){return this.position=t,this}getStave(){return this.stave}checkStave(){return g(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"}(ft||(ft={}));class vt extends wt{constructor(t){super(),this.thickness=K.STAVE_LINE_THICKNESS;const e=ft;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(_t.BEGIN),this.setType(t)}static get CATEGORY(){return c.Barline}static get type(){return ft}static get typeString(){return{single:ft.SINGLE,double:ft.DOUBLE,end:ft.END,repeatBegin:ft.REPEAT_BEGIN,repeatEnd:ft.REPEAT_END,repeatBoth:ft.REPEAT_BOTH,none:ft.NONE}}getType(){return this.type}setType(t){return this.type="string"==typeof t?vt.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 ft.SINGLE:this.drawVerticalBar(t,this.x,!1);break;case ft.DOUBLE:this.drawVerticalBar(t,this.x,!0);break;case ft.END:this.drawVerticalEndBar(t,this.x);break;case ft.REPEAT_BEGIN:this.drawRepeatBar(t,this.x,!0),t.getX()!==this.x&&this.drawVerticalBar(t,t.getX());break;case ft.REPEAT_END:this.drawRepeatBar(t,this.x,!1);break;case ft.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 Et extends mt{constructor(t=ft.SINGLE){super({duration:"b"}),this.metrics={widths:{}};const e=ft;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 c.BarNote}getType(){return this.type}setType(t){return this.type="string"==typeof t?vt.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){Et.DEBUG&&u("Vex.Flow.BarNote",t)}("Rendering bar line at: ",this.getAbsoluteX()),this.style&&this.applyStyle(t);const e=new vt(this.type);e.setX(this.getAbsoluteX()),e.draw(this.checkStave()),this.style&&this.restoreStyle(t),this.setRendered()}}Et.DEBUG=!1;class Ct extends O{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:Ct.UP,text:this.text}],this.release&&this.phrase.push({type:Ct.DOWN,text:""})),this.updateWidth()}static get CATEGORY(){return c.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(h(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 it.create(this.textFont).maxHeight}updateWidth(){const t=it.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===Ct.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(O.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()},l=(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()},g=(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()},u=(t,i)=>{e.save(),e.setFont(this.textFont);const s=t-e.measureText(i).width/2;e.fillText(i,s,h),e.restore()};let p,m=0,_=0;if(null===(t=this.tap)||void 0===t?void 0:t.length){u(i.getModifierStartXY(O.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),_=e.draw_width+m-(1===t?n:0),e.type===Ct.UP&&(p&&p.type===Ct.UP&&g(s.x,r,1),c(s.x,s.y,_,r)),e.type===Ct.DOWN&&(p&&p.type===Ct.UP&&l(s.x,s.y,_,r),p&&p.type===Ct.DOWN&&(g(s.x,s.y,-1),l(s.x,s.y,_,r)),p||(_=e.draw_width,l(s.x,s.y,_,r))),u(s.x+_,e.text),p=e,m=e.draw_width,p.x=s.x,s.x+=_}if(!p||null==p.x)throw new d("NoLastBendForBend","Internal error.");p.type===Ct.UP?g(p.x+_,r,1):p.type===Ct.DOWN&&g(p.x+_,s.y,-1)}}function kt(...t){Dt.DEBUG&&u("Vex.Flow.ChordSymbol",t)}Ct.TEXT_FONT=Object.assign({},A.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"}(xt||(xt={})),function(t){t[t.TOP=1]="TOP",t[t.BOTTOM=2]="BOTTOM"}(St||(St={})),function(t){t[t.GLYPH=1]="GLYPH",t[t.TEXT=2]="TEXT",t[t.LINE=3]="LINE"}(yt||(yt={})),function(t){t[t.NONE=1]="NONE",t[t.SUBSCRIPT=2]="SUBSCRIPT",t[t.SUPERSCRIPT=3]="SUPERSCRIPT"}(Tt||(Tt={}));class Dt extends O{constructor(){super(),this.symbolBlocks=[],this.horizontal=xt.LEFT,this.vertical=St.TOP,this.useKerning=!0,this.reportWidth=!0,this.resetFont()}static get CATEGORY(){return c.ChordSymbol}static get superSubRatio(){return Dt.metrics.global.superSubRatio}static set NO_TEXT_FORMAT(t){Dt.noFormat=t}static get NO_TEXT_FORMAT(){return Dt.noFormat}static getMetricForGlyph(t){if(Dt.metrics[t])return Dt.metrics[t]}static get engravingFontResolution(){return K.currentMusicFont().getResolution()}static get spacingBetweenBlocks(){return Dt.metrics.global.spacing/Dt.engravingFontResolution}static getWidthForGlyph(t){const e=Dt.getMetricForGlyph(t.code);return e?e.advanceWidth/Dt.engravingFontResolution:.65}static getYShiftForGlyph(t){const e=Dt.getMetricForGlyph(t.code);return e?e.yOffset/Dt.engravingFontResolution:0}static getXShiftForGlyph(t){const e=Dt.getMetricForGlyph(t.code);return e?-1*e.leftSideBearing/Dt.engravingFontResolution:0}static get superscriptOffset(){return Dt.metrics.global.superscriptOffset/Dt.engravingFontResolution}static get subscriptOffset(){return Dt.metrics.global.subscriptOffset/Dt.engravingFontResolution}static get kerningOffset(){return Dt.metrics.global.kerningOffset/Dt.engravingFontResolution}static get metrics(){return K.currentMusicFont().getMetrics().glyphs.chordSymbol}static get lowerKerningText(){return Dt.metrics.global.lowerKerningText}static get upperKerningText(){return Dt.metrics.global.upperKerningText}static isSuperscript(t){return void 0!==t.symbolModifier&&t.symbolModifier===Tt.SUPERSCRIPT}static isSubscript(t){return void 0!==t.symbolModifier&&t.symbolModifier===Tt.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=k.convertSizeToPointValue(null===(i=o.textFont)||void 0===i?void 0:i.size),r=k.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=Dt.isSuperscript(e),a=Dt.isSubscript(e),l=i||a?Dt.superSubRatio:1,g=e.symbolType===yt.GLYPH?h*l:r*l;(i||a)&&(c=2);const u=o.textFormatter.fontSizeInPixels,p=u*l;if(e.symbolType===yt.GLYPH&&void 0!==e.glyph?(e.width=Dt.getWidthForGlyph(e.glyph)*p,e.yShift+=Dt.getYShiftForGlyph(e.glyph)*p,e.xShift+=Dt.getXShiftForGlyph(e.glyph)*p,e.glyph.scale=e.glyph.scale*g):e.symbolType===yt.TEXT&&(e.width=e.width*p,e.yShift+=o.getYOffsetForText(e.text)*g),e.symbolType===yt.GLYPH&&void 0!==e.glyph&&e.glyph.code===Dt.glyphs.over.code&&(c=2),e.width+=Dt.spacingBetweenBlocks*u*l,i&&t>0){const e=o.symbolBlocks[t-1];Dt.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()===St.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"===K.currentMusicFont().getName()&&(t="PetalumaScript, Arial, sans-serif"),{family:t,size:12,weight:b.NORMAL,style:w.NORMAL}}get superscriptOffset(){return Dt.superscriptOffset*this.textFormatter.fontSizeInPixels}get subscriptOffset(){return Dt.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===yt.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===yt.GLYPH&&void 0!==e.glyph&&e.glyph.code===Dt.glyphs.over.code&&(s+=e.glyph.metrics.x_shift),void 0!==i&&i.symbolType===yt.GLYPH&&void 0!==i.glyph&&i.glyph.code===Dt.glyphs.over.code&&(s+=i.glyph.metrics.x_shift);let n=!1,a=!1;void 0!==i&&i.symbolType===yt.TEXT&&(n=Dt.upperKerningText.some((t=>t===i.text[i.text.length-1])),a=Dt.lowerKerningText.some((t=>t===i.text[i.text.length-1])));const o=Dt.kerningOffset*this.textFormatter.fontSizeInPixels;return n&&e.symbolModifier===Tt.SUPERSCRIPT&&(s+=o),a&&e.symbolType===yt.TEXT&&(e.text[0]>="a"&&e.text[0]<="z"&&(s+=o/2),Dt.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:yt.TEXT,a={text:null!==(i=t.text)&&void 0!==i?i:"",symbolType:n,symbolModifier:null!==(s=t.symbolModifier)&&void 0!==s?s:Tt.NONE,xShift:0,yShift:0,vAlign:!1,width:0};if(n===yt.GLYPH&&"string"==typeof t.glyph){const e=Dt.glyphs[t.glyph],i=20;a.glyph=new R(e.code,i,{category:"chordSymbol"})}else n===yt.TEXT?a.width=this.textFormatter.getWidthForTextInEm(a.text):n===yt.LINE&&(a.width=t.width);return a}addSymbolBlock(t){return this.symbolBlocks.push(this.getSymbolBlock(t)),this}addText(t,e={}){const i=yt.TEXT;return this.addSymbolBlock(Object.assign(Object.assign({},e),{text:t,symbolType:i}))}addTextSuperscript(t){const e=yt.TEXT,i=Tt.SUPERSCRIPT;return this.addSymbolBlock({text:t,symbolType:e,symbolModifier:i})}addTextSubscript(t){const e=yt.TEXT,i=Tt.SUBSCRIPT;return this.addSymbolBlock({text:t,symbolType:e,symbolModifier:i})}addGlyphSuperscript(t){const e=yt.GLYPH,i=Tt.SUPERSCRIPT;return this.addSymbolBlock({glyph:t,symbolType:e,symbolModifier:i})}addGlyph(t,e={}){const i=yt.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];Dt.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=yt.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=it.create(this.textFont),this}setEnableKerning(t){return this.useKerning=t,this}setVertical(t){return this.vertical="string"==typeof t?Dt.VerticalJustifyString[t]:t,this}getVertical(){return this.vertical}setHorizontal(t){return this.horizontal="string"==typeof t?Dt.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(O.Position.ABOVE,this.index);let n;t.setFont(this.textFont);const a=e.hasStem(),o=e.checkStave();if(this.vertical===St.BOTTOM){if(n=o.getYForBottomText(this.text_line+K.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===xt.LEFT?s.x:this.horizontal===xt.RIGHT?s.x+this.getWidth():this.horizontal===xt.CENTER?s.x-this.getWidth()/2:e.getStemX()-this.getWidth()/2,kt("Rendering ChordSymbol: ",this.textFormatter,r,n),this.symbolBlocks.forEach((e=>{const i=Dt.isSuperscript(e),s=Dt.isSubscript(e);let a=n;if(kt("shift was ",e.xShift,e.yShift),kt("curY pre sub ",a),i&&(a+=this.superscriptOffset),s&&(a+=this.subscriptOffset),kt("curY sup/sub ",a),e.symbolType===yt.TEXT){if((i||s)&&(t.save(),this.textFont)){const{family:e,size:i,weight:s,style:n}=this.textFont,a=k.scaleSize(i,Dt.superSubRatio);t.setFont(e,a,s,n)}kt("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===yt.GLYPH&&e.glyph?(a+=e.yShift,kt("Rendering Glyph: ",e.glyph.code,r+e.xShift,a),e.glyph.render(t,r+e.xShift,a)):e.symbolType===yt.LINE&&(kt("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()}}Dt.DEBUG=!1,Dt.HorizontalJustify=xt,Dt.HorizontalJustifyString={left:xt.LEFT,right:xt.RIGHT,center:xt.CENTER,centerStem:xt.CENTER_STEM},Dt.VerticalJustify=St,Dt.VerticalJustifyString={top:St.TOP,above:St.TOP,below:St.BOTTOM,bottom:St.BOTTOM},Dt.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"}},Dt.symbolTypes=yt,Dt.symbolModifiers=Tt,Dt.noFormat=!1;class Nt extends O{constructor(){super(),this.position=O.Position.RIGHT,this.radius=2,this.setWidth(5),this.dot_shiftY=0}static get CATEGORY(){return c.Dot}static getDots(t){return t.getModifiersByType(Nt.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 Nt;e.setDotShiftY(i.glyph.dot_shiftY),i.addModifier(e,t)}else if(null!=(null==e?void 0:e.index)){const t=new Nt;t.setDotShiftY(i.glyph.dot_shiftY),i.addModifier(t,null==e?void 0:e.index)}else{const t=new Nt;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],r=a.getNote();let c,l;if(o(r)){const t=a.checkIndex();c=r.getKeyProps()[t],l=r.getFirstDotPx()}else{if(!h(r))throw new d("Internal","Unexpected instance.");c={line:.5},l=i}const g=r.getAttribute("id");s.push({line:c.line,note:r,note_id:g,dot:a}),n[g]=Math.max(n[g]||l,l)}s.sort(((t,e)=>e.line-t.line));let a=i,r=0,c=null,l=null,g=null,u=0;for(let t=0;t<s.length;++t){const{dot:e,note:i,note_id:o,line:h}=s[t];h===c&&i===l||(a=n[o]),i.isRest()||h===c||(.5===Math.abs(h%1)?u=0:(u=.5,null==l||l.isRest()||null==c||c-h!=.5?h+u===g&&(u=-.5):u=-.5)),i.isRest()?e.dot_shiftY+=-u:e.dot_shiftY=-u,g=h+u,e.setXShift(a),a+=e.getWidth()+1,r=a>r?a:r,c=h,l=i}return e.right_shift+=r,!0}setNote(t){return this.note=t,n(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});h(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 At extends O{constructor(t){super(),this.finger=t,this.width=7,this.position=O.Position.LEFT,this.x_shift=0,this.y_shift=0,this.x_offset=0,this.y_offset=0,this.resetFont()}static get CATEGORY(){return c.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=it.create(c.textFont).maxHeight;if(c.position===P.ABOVE&&(e.top_text_line+=p/K.STAVE_LINE_DISTANCE+.5),c.position===P.BELOW&&(e.text_line+=p/K.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:_,shiftR:f}=n[t];m===g&&a===u||(h=i+_,c=s+f);const x=p.getWidth()+1;o===O.Position.LEFT?(p.setXShift(i+h),e=i+x,d=e>d?e:d):o===O.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 O.Position.ABOVE:s-=4,n-=12;break;case O.Position.BELOW:s-=2,n+=10;break;case O.Position.LEFT:s-=this.width;break;case O.Position.RIGHT:s+=1;break;default:throw new d("InvalidPosition",`The position ${this.position} does not exist`)}t.save(),t.setFont(this.textFont),t.fillText(""+this.finger,s,n),t.restore()}}At.TEXT_FONT={family:k.SANS_SERIF,size:9,weight:b.BOLD,style:w.NORMAL};class Ft extends A{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 c.StaveTie}setDirection(t){return this.direction=t,this}setNotes(t){if(!t.first_note&&!t.last_note)throw new d("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 d("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 d("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 l=(t.last_x_px+a+(t.first_x_px+n))/2,g=t.first_ys[r[c]]+o,u=t.last_ys[h[c]]+o;if(isNaN(g)||isNaN(u))throw new d("BadArguments","Bad indices for tie rendering.");const p=(g+u)/2+i*t.direction,m=(g+u)/2+s*t.direction;this.setAttribute("el",e.openGroup("stavetie")),e.beginPath(),e.moveTo(t.first_x_px+n,g),e.quadraticCurveTo(l,p,t.last_x_px+a,u),e.quadraticCurveTo(l,m,t.first_x_px+n,g),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}}Ft.TEXT_FONT=Object.assign({},A.TEXT_FONT);class Pt extends Ft{static get CATEGORY(){return c.TabTie}static createHammeron(t){return new Pt(t,"H")}static createPulloff(t){return new Pt(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"}(bt||(bt={}));class Mt extends A{constructor(t,e){let i;if(super(),this.resolutionMultiplier=1,this.mode=bt.STRICT,this.preFormatted=!1,this.ticksUsed=new x(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:K.RESOLUTION},i),this.totalTicks=new x(this.time.num_beats*(this.time.resolution/this.time.beat_value),1),this.smallestTickCount=this.totalTicks.clone()}static get CATEGORY(){return c.Voice}static get Mode(){return bt}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?bt.STRICT:bt.SOFT,this}isComplete(){return this.mode!==bt.STRICT&&this.mode!==bt.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===bt.STRICT||this.mode===bt.FULL)&&this.ticksUsed.greaterThan(this.totalTicks))throw this.ticksUsed.subtract(e),new d("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 g(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),g(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 Bt extends O{constructor(t,e){return super(),this.preFormatted=!1,this.position=O.Position.LEFT,this.grace_notes=t,this.width=0,this.show_slur=e,this.slur=void 0,this.voice=new Mt({num_beats:4,beat_value:4,resolution:K.RESOLUTION}).setStrict(!1),this.render_options={slur_y_shift:0},this.beams=[],this.voice.addTickables(this.grace_notes),this}static get CATEGORY(){return c.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],r=a.getNote(),h=o(r),c=h?4:0;if(h&&r!==s){for(let t=0;t<r.keys.length;++t)n=Math.max(r.getLeftDisplacedHeadPx(),n);s=r}i.push({shift:n,gracenote_group:a,spacing:c})}let a,r=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,r=Math.max(a,r)}for(let t=0;t<i.length;++t){const e=i[t].gracenote_group;a=e.getWidth()+i[t].spacing,e.setSpacingFromNextModifier(r-Math.min(a,r))}return e.left_shift+=r,!0}preFormat(){this.preFormatted||(this.formatter||(this.formatter=new we),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 Ne(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){Bt.DEBUG&&u("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=o(e),s=i?Ft:Pt;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()}}}Bt.DEBUG=!1;class Rt extends O{constructor(t){super(),this.preFormatted=!1,this.position=O.Position.LEFT,this.subNotes=t,this.subNotes.forEach((t=>{t.setIgnoreTicks(!1)})),this.width=0,this.formatter=new we,this.voice=new Mt({num_beats:4,beat_value:4,resolution:K.RESOLUTION}).setStrict(!1),this.voice.addTickables(this.subNotes)}static get CATEGORY(){return c.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 Ot{constructor(t){this.preFormatted=!1,this.postFormatted=!1,this.tickID=t&&t.tickID?t.tickID:0,this.currentTick=new x(0,1),this.maxTicks=new x(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 d("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 Lt extends O{constructor(t){super(),this.type=t,this.delayed=!1,this.render_options={font_scale:38,accidentalLowerPadding:3,accidentalUpperPadding:3},this.ornament=K.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=Lt.ornamentAlignWithNoteHead.indexOf(this.type)>=0,!this.ornament)throw new d("ArgumentError",`Ornament not found: '${this.type}'`);this.x_shift=e?e.xOffset:0,this.y_shift=e?e.yOffset:0,this.glyph=new R(this.ornament.code,this.render_options.font_scale,{category:`ornament.${this.ornament.code}`}),Lt.ornamentNoteTransition.indexOf(this.type)>=0&&(this.delayed=!0),e||this.glyph.setOrigin(.5,1)}static get CATEGORY(){return c.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(Lt.ornamentRelease.indexOf(r.type)>=0&&(r.x_shift+=s+2),Lt.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),Lt.ornamentArticulation.indexOf(r.type)>=0){g(r.note,"NoAttachedNote").getLineNumber()>=3||r.getPosition()===O.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()===O.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 K.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 R(K.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 R(K.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===Q.DOWN?a.baseY:a.topY;h(e)&&(e.hasStem()?i===Q.DOWN&&(o=s.getYForTopText(this.text_line)):o=s.getYForTopText(this.text_line));const r=i===Q.DOWN,c=s.getSpacingBetweenLines();let d=1;!r&&e.hasBeam()&&(d+=.5);const l=o-c*(this.text_line+d),g=e.getModifierStartXY(this.position,this.index);let p=g.x,m=this.ornamentAlignWithNoteHead?g.y:Math.min(s.getYForTopText(this.text_line),l);if(m+=this.y_shift,this.delayed){let t=0;const i=p-(s.getX()-10);if(void 0!==this.delayXShift)t=this.delayXShift;else{t+=this.glyph.getMetrics().width/2;const n=Ot.getNextContext(e.getTickContext());t+=n?.5*(n.getX()-i):.5*(s.getX()+s.getWidth()-i),this.delayXShift=t}p+=t}!function(...t){Lt.DEBUG&&u("Vex.Flow.Ornament",t)}("Rendering ornament: ",this.ornament,p,m),this.accidentalLower&&(this.accidentalLower.render(t,p,m),m-=this.accidentalLower.getMetrics().height,m-=this.render_options.accidentalLowerPadding),this.stemUpYOffset&&e.hasStem()&&1===e.getStemDirection()&&(m+=this.stemUpYOffset),e.getLineNumber()<5&&Lt.ornamentNoteTransition.indexOf(this.type)>=0&&(m=e.checkStave().getBoundingBox().getY()+40),this.glyph.render(t,p+this.x_shift,m),this.accidentalUpper&&(m-=this.glyph.getMetrics().height+this.render_options.accidentalUpperPadding,this.accidentalUpper.render(t,p,m)),t.closeGroup()}}Lt.DEBUG=!1;class It extends O{constructor(t){super(),this.position=null!=t?t:O.Position.LEFT,this.point=K.currentMusicFont().lookupMetric("parenthesis.default.point"),this.setWidth(K.currentMusicFont().lookupMetric("parenthesis.default.width"))}static get CATEGORY(){return c.Parenthesis}static buildAndAttach(t){for(const e of t)for(let t=0;t<e.keys.length;t++)e.addModifier(new It(P.LEFT),t),e.addModifier(new It(P.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===P.RIGHT&&(h=a.getRightParenthesisPx(r),s=s>h+n.width?s:h+n.width),o===P.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=K.currentMusicFont().lookupMetric("parenthesis.default.point"),this.setWidth(K.currentMusicFont().lookupMetric("parenthesis.default.width")),n(t)&&(this.point=K.currentMusicFont().lookupMetric("parenthesis.gracenote.point"),this.setWidth(K.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==O.Position.RIGHT?R.renderGlyph(t,s+1,n,this.point,"noteheadParenthesisRight",{category:"noteHead.standard.noteheadParenthesisRight"}):this.position==O.Position.LEFT&&R.renderGlyph(t,s-2,n,this.point,"noteheadParenthesisLeft",{category:"noteHead.standard.noteheadParenthesisLeft"})}}class Wt extends mt{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||Q.UP,this.line=t.line||0,this.glyph=K.getGlyphProps(this.duration,this.noteType),g(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||K.NOTATION_FONT_SCALE}),this.setWidth(this.glyph.getWidth(this.render_options.glyph_font_scale))}static get CATEGORY(){return c.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=Q.WIDTH/2,i=K.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 d("UnformattedNote","Can't call getBoundingBox on an unformatted note.");const t=this.checkStave().getSpacingBetweenLines(),e=t/2,i=this.y-e;return new y(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===Q.UP?this.stem_up_x_offset:this.stem_down_x_offset);const i=this.y;!function(...t){Wt.DEBUG&&u("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===Q.UP?"Up":"Down"}`;if("s"===this.noteType){const n=this.checkStave().getSpacingBetweenLines();!function(t,e,i,s,n,a){const o=K.SLASH_NOTEHEAD_WIDTH;t.save(),t.setLineWidth(K.STEM_WIDTH);let r=!1;if(K.durationToNumber(e)>2&&(r=!0),r||(i-=K.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(),K.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 R.renderGlyph(t,e,i,n,this.glyph_code,{category:this.custom_glyph?`noteHead.custom.${a}`:`noteHead.standard.${a}`});this.style&&this.restoreStyle(t)}}Wt.DEBUG=!1;class Gt extends mt{constructor(t){super(t)}static get CATEGORY(){return c.StemmableNote}getStem(){return this.stem}checkStem(){if(!this.stem)throw new d("NoStem","No stem attached to instance");return this.stem}setStem(t){return this.stem=t,this}buildStem(){const t=new Q;return this.setStem(t),this}buildFlag(t="flag"){const{glyph:e}=this;if(this.hasFlag()){const i=this.getStemDirection()===Q.DOWN?e.code_flag_downstem:e.code_flag_upstem;this.flag=new R(i,this.render_options.glyph_font_scale,{category:t})}}getBaseCustomNoteHeadGlyph(){return this.getStemDirection()===Q.DOWN?this.customGlyphs[this.customGlyphs.length-1]:this.customGlyphs[0]}getStemLength(){return Q.HEIGHT+this.getStemExtension()}getBeamCount(){const t=this.getGlyph();return t?t.beam_count:0}getStemMinimumLength(){let t=K.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 d("NoStem","No stem attached to this note.");return this.stem_direction}setStemDirection(t){if(t||(t=Q.UP),t!==Q.UP&&t!==Q.DOWN)throw new d("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=K.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===Q.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()===Q.UP?t.stem_up_extension:t.stem_down_extension:0}setStemLength(t){return this.stem_extension_override=t-Q.HEIGHT,this}getStemExtents(){if(!this.stem)throw new d("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 d("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 d("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 K.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 Q(t)),null===(e=this.stem)||void 0===e||e.setContext(this.getContext()).draw()}}function Ut(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 Yt extends Gt{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=K.getGlyphProps(this.duration,this.noteType),g(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||K.NOTATION_FONT_SCALE,stroke_px:t.stroke_px||Yt.LEDGER_LINE_OFFSET}),this.calculateKeyProps(),this.buildStem(),t.auto_stem?this.autoStem():this.setStemDirection(null!==(s=t.stem_direction)&&void 0!==s?s:Q.UP),this.reset(),this.buildFlag()}static get CATEGORY(){return c.StaveNote}static get STEM_UP(){return Q.UP}static get STEM_DOWN(){return Q.DOWN}static get LEDGER_LINE_OFFSET(){return 3}static get minNoteheadPadding(){return K.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(n.minLine<=o.maxLine+t)if(n.isrest)Ut(n,0,1);else if(o.isrest)Ut(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===K.durationToNumber(n.note.duration)?e++:K.durationToNumber(n.note.duration)>2&&i++,2===K.durationToNumber(o.note.duration)?e++:K.durationToNumber(o.note.duration)>2&&i++,2!==e&&2!==i||n.note.getModifiersByType(c.Dot).length!==o.note.getModifiersByType(c.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 d("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-m(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?(Ut(n,0,1),Ut(o,0,-1),e.right_shift+=h,!0):(a.isrest&&n.isrest&&a.minLine<=o.maxLine&&Ut(a,0,1),a.isrest&&o.isrest&&n.minLine<=a.maxLine&&Ut(a,0,-1),n.isrest&&n.minLine<=a.maxLine&&Ut(n,0,1),o.isrest&&a.minLine<=o.maxLine&&Ut(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 Q({hide:!!this.isRest()})),this}buildNoteHeads(){this._noteHeads=[];const t=this.getStemDirection(),e=this.getKeys();let i,s,n,a,o,r=!1;t===Q.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 Wt({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?Q.UP:Q.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=K.keyProperties(i,this.clef,s);if(!n)throw new d("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&&p("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 d("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=K.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 y(a,o,i,r-o)}getLineNumber(t){if(!this.keyProps.length)throw new d("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?Q.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=m(Math.max(t,e),Math.min(t,e))}return t}getModifierStartXY(t,e,i={}){var s,n;if(!this.preFormatted)throw new d("UnformattedNote","Can't call GetModifierStartXY on an unformatted note");if(0===this.ys.length)throw new d("NoYValues","No Y-Values calculated for this note.");const{ABOVE:a,BELOW:o,LEFT:r,RIGHT:h}=O.Position;let c=0;return t===r?c=-2:t===h?(c=this.getGlyphWidth()+this.x_shift+2,this.stem_direction===Q.UP&&this.hasFlag()&&(i.forceFlagRight||((t,e)=>e===(t.getStemDirection()===Q.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===Q.DOWN?this.getGlyphWidth():0),this.setRightDisplacedHeadPx(!this.hasFlag()&&this.displaced&&this.stem_direction===Q.UP?this.getGlyphWidth():0)}preFormat(){if(this.preFormatted)return;let t=0;this.modifierContext&&(this.modifierContext.preFormat(),0===this.modifierContext.getWidth()&&(t=Yt.minNoteheadPadding));let e=this.getGlyphWidth()+this.leftDisplacedHeadPx+this.rightDisplacedHeadPx+t;this.shouldDrawFlag()&&this.stem_direction===Q.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)-Q.WIDTH/2;if(this.isRest())return;if(!s)throw new d("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:l,lowest_non_displaced_line:g,displaced_x:u,non_displaced_x:p}=this.getNoteHeadBounds();if(o<6&&r>0)return;const m=Math.min(null!=u?u:0,null!=p?p:0),_=(t,e,o)=>{let r;r=o&&e?m-i:e?(null!=p?p:0)-i:(null!=u?u:0)-i;const h=e&&o?a:n;s.beginPath(),s.moveTo(r,t),s.lineTo(r+h,t),s.stroke()},f=Object.assign(Object.assign({},t.getDefaultLedgerLineStyle()),this.getLedgerLineStyle());this.applyStyle(s,f);for(let e=6;e<=o;++e){const i=void 0!==p&&e<=c,s=void 0!==h&&e<=h;_(t.getYForNote(e),i,s)}for(let e=0;e>=r;--e){const i=void 0!==p&&e>=g,s=void 0!==l&&e>=l;_(t.getYForNote(e),i,s)}this.restoreStyle(s,f)}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 d("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()===Q.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 Q(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===Q.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(0===this.ys.length)throw new d("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){Yt.DEBUG&&u("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 Ht(t){if(!t)return!1;const e=l();return"function"==typeof e.HTMLCanvasElement&&t instanceof e.HTMLCanvasElement||"function"==typeof t.getContext&&"function"==typeof t.toDataURL}Yt.DEBUG=!1;class jt extends ut{constructor(t){super(),this.textHeight=0,this.context2D=t,t.canvas?this.canvas=t.canvas:this.canvas={width:jt.WIDTH,height:jt.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&&(p("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=l().devicePixelRatio||1;return[t,e]=jt.sanitizeCanvasDims(t*s,e*s),t=t/s|0,e=e/s|0,i.width=t*s,i.height=e*s,Ht(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=k.validate(t,e,i,s);return this.context2D.font=k.toCSSString(n),this.textHeight=k.convertSizeToPixelValue(n.size),this}getFont(){return this.context2D.font}}const Xt={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}},Vt="http://www.w3.org/2000/svg",zt=2*Math.PI;class Kt extends ut{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":k.SANS_SERIF,"font-size":k.SIZE+"pt","font-weight":b.NORMAL,"font-style":w.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(Vt,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",_(t)),e&&s.setAttribute("id",_(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 d("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=Xt[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>=zt||a&&s-n>=zt){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=f(s),n=f(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 Kt.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=k.validate(t,e,i,s);this.fontCSSString=k.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 $t,Jt,qt,Qt;Kt.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(Vt,"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"}($t||($t={})),function(t){t[t.NONE=1]="NONE",t[t.UP=2]="UP",t[t.DOWN=3]="DOWN"}(Jt||(Jt={}));class Zt{constructor(t,e){if(i(t,c.RenderContext))this.ctx=t;else{if(void 0===e)throw new d("InvalidArgument","Missing backend argument");const i=e;let s;if("string"==typeof t){const e=document.getElementById(t);if(!e)throw new d("BadElementId",`Can't find element with ID "${e}"`);s=e}else s=t;if(i===Zt.Backends.CANVAS){if(!Ht(s))throw new d("BadElement","CANVAS context requires an HTMLCanvasElement.");const t=s.getContext("2d");if(!t)throw new d("BadElement","Can't get canvas context");this.ctx=new jt(t)}else{if(i!==Zt.Backends.SVG)throw new d("InvalidBackend",`No support for backend: ${i}`);if(!function(t){if(!t)return!1;const e=l();return"function"==typeof e.HTMLDivElement&&t instanceof e.HTMLDivElement||"function"==typeof t.appendChild&&"object"==typeof t.style}(s))throw new d("BadElement","SVG context requires an HTMLDivElement.");this.ctx=new Kt(s)}}}static buildContext(t,e,i,s,n="#FFF"){const a=new Zt(t,e);i&&s&&a.resize(i,s);const o=a.getContext();return o.setBackgroundFillStyle(n),Zt.lastContext=o,o}static getCanvasContext(t,e,i,s){return Zt.buildContext(t,Zt.Backends.CANVAS,e,i,s)}static getSVGContext(t,e,i,s){return Zt.buildContext(t,Zt.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}}Zt.Backends=$t,Zt.LineEndType=Jt,Zt.lastContext=void 0;class te extends O{constructor(t){super(),this.string_number=t,this.setWidth(20),this.position=O.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=Zt.LineEndType.NONE,this.radius=8,this.resetFont()}static get CATEGORY(){return c.StringNumber}static get metrics(){return K.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,r=0,h=0;for(let c=0;c<t.length;++c){const l=t[c],g=l.getNote(),u=l.getPosition();if(!o(g))throw new d("NoStaveNote");const p=l.checkIndex(),m=g.getKeyProps()[p],_=g.getModifierContext(),f=2*l.radius/K.STAVE_LINE_DISTANCE+.5;if(_&&(u===P.ABOVE?(l.text_line=_.getState().top_text_line,e.top_text_line+=f):u===P.BELOW&&(l.text_line=_.getState().text_line,e.text_line+=f)),g!==a){for(let t=0;t<g.keys.length;++t)0===i&&(r=Math.max(g.getLeftDisplacedHeadPx(),r)),0===s&&(h=Math.max(g.getRightDisplacedHeadPx(),h));a=g}const x=m.line;n.push({pos:u,note:g,num:l,line:x,shiftL:r,shiftR:h})}n.sort(((t,e)=>e.line-t.line));let c=0,l=0,g=0,u=null,p=null;for(let t=0;t<n.length;++t){let e=0;const a=n[t].note,o=n[t].pos,h=n[t].num,d=n[t].line,m=n[t].shiftR;d===u&&a===p||(c=s+m);const _=h.getWidth()+1;o===O.Position.LEFT?(h.setXShift(i),e=r+_,l=e>l?e:l):o===O.Position.RIGHT&&(h.setXShift(c),e+=_,g=e>g?e:g),u=d,p=a}return e.left_shift+=l,e.right_shift+=g,!0}setLineEndType(t){return t>=Zt.LineEndType.NONE&&t<=Zt.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():Q.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 O.Position.ABOVE:o=e.getYs().reduce(((t,e)=>t<e?t:e)),e.hasStem()&&s==Q.UP&&(o=a.topY+te.metrics.stemPadding),o-=this.radius+te.metrics.verticalPadding+this.text_line*K.STAVE_LINE_DISTANCE;break;case O.Position.BELOW:o=e.getYs().reduce(((t,e)=>t>e?t:e)),e.hasStem()&&s==Q.DOWN&&(o=a.topY-te.metrics.stemPadding),o+=this.radius+te.metrics.verticalPadding+this.text_line*K.STAVE_LINE_DISTANCE;break;case O.Position.LEFT:n-=this.radius/2+te.metrics.leftPadding;break;case O.Position.RIGHT:n+=this.radius/2+te.metrics.rightPadding;break;default:throw new d("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 h=n-t.measureText(this.string_number).width/2;t.fillText(""+this.string_number,h,o+4.5);const c=this.last_note;if(r(c)){const i=c.getStemX()-e.getX()+5;let s,a;switch(t.setStrokeStyle("#000000"),t.setLineCap("round"),t.setLineWidth(.6),this.dashed?Zt.drawDashedLine(t,n+10,o,n+i,o,[3,3]):Zt.drawDashedLine(t,n+10,o,n+i,o,[3,0]),this.leg){case Zt.LineEndType.UP:s=-10,a=this.dashed?[3,3]:[3,0],Zt.drawDashedLine(t,n+i,o,n+i,o+s,a);break;case Zt.LineEndType.DOWN:s=10,a=this.dashed?[3,3]:[3,0],Zt.drawDashedLine(t,n+i,o,n+i,o+s,a)}}t.restore()}}te.TEXT_FONT={family:k.SANS_SERIF,size:k.SIZE,weight:b.BOLD,style:w.NORMAL};class ee extends O{constructor(t,e){super(),this.options=Object.assign({all_voices:!0},e),this.all_voices=this.options.all_voices,this.type=t,this.position=O.Position.LEFT,this.render_options={font_scale:38},this.resetFont(),this.setXShift(0),this.setWidth(10)}static get CATEGORY(){return c.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(o(e)){const{line:s}=e.getKeyProps()[i];return{line:s,shift:e.getLeftDisplacedHeadPx(),stroke:t}}if(h(e)){const{str:s}=e.getPositions()[i];return{line:s,shift:0,stroke:t}}throw new d("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,r=i.y;const h=i.x-5,c=e.checkStave().getSpacingBetweenLines(),l=this.checkModifierContext().getMembers(e.getCategory());for(let t=0;t<l.length;t++){const e=l[t];if(a(e)){s=e.getYs();for(let e=0;e<s.length;e++)(this.note===l[t]||this.all_voices)&&(n=Math.min(n,s[e]),r=Math.max(r,s[e]))}}let g="",u=0,p=0,m=0,_=0;switch(this.type){case ee.Type.BRUSH_DOWN:g="arrowheadBlackUp",u=-3,p=n-c/2+10,r+=c/2;break;case ee.Type.BRUSH_UP:g="arrowheadBlackDown",u=.5,p=r+c/2,n-=c/2;break;case ee.Type.ROLL_DOWN:case ee.Type.RASQUEDO_DOWN:g="arrowheadBlackUp",u=-3,m=this.x_shift+u-2,o(e)?(n+=1.5*c,r+=(r-n)%2!=0?.5*c:c,p=n-c,_=r+c+2):(n+=1.5*c,r+=c,p=n-.75*c,_=r+.25*c);break;case ee.Type.ROLL_UP:case ee.Type.RASQUEDO_UP:g="arrowheadBlackDown",u=-4,m=this.x_shift+u-1,o(e)?(p=c/2,n+=.5*c,(r-n)%2==0&&(r+=c/2),p=r+.5*c,_=n-1.25*c):(n+=.25*c,r+=.5*c,p=r+.25*c,_=n-c);break;case ee.Type.ARPEGGIO_DIRECTIONLESS:n+=.5*c,r+=c;break;default:throw new d("InvalidType",`The stroke type ${this.type} does not exist`)}let f="straight";if(this.type===ee.Type.BRUSH_DOWN||this.type===ee.Type.BRUSH_UP)t.fillRect(h+this.x_shift,n,1,r-n);else if(f="wiggly",o(e))for(let e=n;e<=r;e+=c)R.renderGlyph(t,h+this.x_shift-4,e,this.render_options.font_scale,"vexWiggleArpeggioUp");else{let e;for(e=n;e<=r;e+=10)R.renderGlyph(t,h+this.x_shift-4,e,this.render_options.font_scale,"vexWiggleArpeggioUp");this.type===ee.Type.RASQUEDO_DOWN&&(_=e+.25*c)}this.type!==ee.Type.ARPEGGIO_DIRECTIONLESS&&(R.renderGlyph(t,h+this.x_shift+u,p,this.render_options.font_scale,g,{category:`stroke.${g}.${f}`}),this.type!==ee.Type.RASQUEDO_DOWN&&this.type!==ee.Type.RASQUEDO_UP||(t.save(),t.setFont(this.textFont),t.fillText("R",h+m,_),t.restore()))}}ee.Type={BRUSH_DOWN:1,BRUSH_UP:2,ROLL_DOWN:3,ROLL_UP:4,RASQUEDO_DOWN:5,RASQUEDO_UP:6,ARPEGGIO_DIRECTIONLESS:7},ee.TEXT_FONT={family:k.SERIF,size:k.SIZE,weight:b.BOLD,style:w.ITALIC};class ie extends O{constructor(){super(),this.position=O.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 c.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(Ct.CATEGORY);if(o&&o.length>0){s-=o.map((t=>t.getTextHeight())).reduce(((t,e)=>t>e?t:e))/K.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(O.Position.RIGHT,this.index).x+this.x_shift,s=e.getYForTopText(this.text_line)+2;ie.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 se(...t){ne.DEBUG&&u("Vex.Flow.ModifierContext",t)}class ne{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 se("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 se("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 d("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;se("Preformatting ModifierContext");const t=this.state,e=this.members;Yt.format(e[c.StaveNote],t),It.format(e[c.Parenthesis],t),Nt.format(e[c.Dot],t),At.format(e[c.FretHandFinger],t),q.format(e[c.Accidental],t),ee.format(e[c.Stroke],t),Bt.format(e[c.GraceNoteGroup],t),Rt.format(e[c.NoteSubGroup],t),te.format(e[c.StringNumber],t),gt.format(e[c.Articulation],t),Lt.format(e[c.Ornament],t),at.format(e[c.Annotation],t),Dt.format(e[c.ChordSymbol],t),Ct.format(e[c.Bend],t),ie.format(e[c.Vibrato],t,this),this.width=t.left_shift+t.right_shift,this.preFormatted=!0}postFormat(){this.postFormatted||(se("Postformatting ModifierContext"),Yt.postFormat(this.getMembers(c.StaveNote)))}}ne.DEBUG=!1;class ae extends wt{constructor(t,e,i){super(),this.clef=ae.types.treble,this.setPosition(_t.BEGIN),this.setType(t,e,i),this.setWidth(K.currentMusicFont().lookupMetric(`clef.${this.size}.width`)),function(...t){ae.DEBUG&&u("Vex.Flow.Clef",t)}("Creating clef:",t)}static get CATEGORY(){return c.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=ae.types[t],this.size=void 0===e?"default":e;const s=K.currentMusicFont();if(this.clef.point=s.lookupMetric(`clef.${this.size}.point`,0),this.glyph=new R(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 R(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&&g(this.stave,"ClefError","Can't get width without stave."),this.width}setStave(t){if(this.stave=t,"tab"===this.type){const t=g(this.glyph,"ClefError","Can't set stave without glyph."),e=this.stave.getNumLines(),i=K.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=g(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()}}ae.DEBUG=!1;class oe extends wt{constructor(t,e,i){super(),this.accList=[],this.setKeySig(t,e,i),this.setPosition(_t.BEGIN),this.glyphFontScale=38,this.glyphs=[],this.xPositions=[],this.paddingForced=!1}static get CATEGORY(){return c.KeySignature}convertToGlyph(t,e){const i=K.accidentalCodes(t.type),s=new R(i.code,this.glyphFontScale);let n=1;if("n"===t.type&&e){const i=oe.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=K.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=K.keySignature(g(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===_t.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()}}oe.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 re extends wt{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 c.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 re.type.CODA_RIGHT:this.drawCodaFixed(t,e+t.getWidth());break;case re.type.CODA_LEFT:this.drawSymbolText(t,e,"Coda",!0);break;case re.type.SEGNO_LEFT:this.drawSignoFixed(t,e);break;case re.type.SEGNO_RIGHT:this.drawSignoFixed(t,e+t.getWidth());break;case re.type.DC:this.drawSymbolText(t,e,"D.C.",!1);break;case re.type.DC_AL_CODA:this.drawSymbolText(t,e,"D.C. al",!0);break;case re.type.DC_AL_FINE:this.drawSymbolText(t,e,"D.C. al Fine",!1);break;case re.type.DS:this.drawSymbolText(t,e,"D.S.",!1);break;case re.type.DS_AL_CODA:this.drawSymbolText(t,e,"D.S. al",!0);break;case re.type.DS_AL_FINE:this.drawSymbolText(t,e,"D.S. al Fine",!1);break;case re.type.FINE:this.drawSymbolText(t,e,"Fine",!1);break;case re.type.TO_CODA:this.drawSymbolText(t,e,"To",!0)}return this}drawCodaFixed(t,e){const i=t.getYForTopText(t.getNumLines())+this.y_shift;return R.renderGlyph(t.checkContext(),this.x+e+this.x_shift,i+K.currentMusicFont().lookupMetric("staveRepetition.coda.offsetY"),40,"coda",{category:"coda"}),this}drawSignoFixed(t,e){const i=t.getYForTopText(t.getNumLines())+this.y_shift;return R.renderGlyph(t.checkContext(),this.x+e+this.x_shift,i+K.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 re.type.CODA_LEFT:a=this.x+t.getVerticalBarWidth(),o=a+n.measureText(i).width+K.currentMusicFont().lookupMetric("staveRepetition.symbolText.offsetX");break;case re.type.DC:case re.type.DC_AL_FINE:case re.type.DS:case re.type.DS_AL_FINE:case re.type.FINE:a=this.x+e+this.x_shift+t.getWidth()-K.currentMusicFont().lookupMetric("staveRepetition.symbolText.spacing")-r-n.measureText(i).width;break;default:a=this.x+e+this.x_shift+t.getWidth()-K.currentMusicFont().lookupMetric("staveRepetition.symbolText.spacing")-r-n.measureText(i).width-K.currentMusicFont().lookupMetric("staveRepetition.symbolText.offsetX"),o=a+n.measureText(i).width+K.currentMusicFont().lookupMetric("staveRepetition.symbolText.offsetX")}const h=t.getYForTopText(t.getNumLines())+this.y_shift+K.currentMusicFont().lookupMetric("staveRepetition.symbolText.offsetY");return s&&R.renderGlyph(n,o,h,40,"coda",{category:"coda"}),n.fillText(i,a,h+5),n.restore(),this}}re.TEXT_FONT={family:k.SERIF,size:12,weight:b.BOLD,style:w.NORMAL},re.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 he extends wt{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 c.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}}he.TEXT_FONT={family:k.SANS_SERIF,size:10,weight:b.BOLD,style:w.NORMAL};class ce extends wt{constructor(t,e,i){super(),this.render_options={glyph_font_scale:30},this.tempo=t,this.position=_t.ABOVE,this.x=e,this.shift_x=10,this.shift_y=i,this.resetFont()}static get CATEGORY(){return c.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=K.getGlyphProps(o);if(c+=3*n,R.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&&(R.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}}ce.TEXT_FONT={family:k.SERIF,size:14,weight:b.BOLD,style:w.NORMAL},function(t){t[t.LEFT=1]="LEFT",t[t.CENTER=2]="CENTER",t[t.RIGHT=3]="RIGHT"}(qt||(qt={}));class de extends mt{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=qt.LEFT,t.glyph){const e=de.GLYPHS[t.glyph];if(!e)throw new d("Invalid glyph type: "+t.glyph);this.glyph=new R(e.code,40,{category:"textNote"}),this.setWidth(this.glyph.getMetrics().width)}else this.glyph=void 0}static get CATEGORY(){return c.TextNote}static get Justification(){return qt}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===qt.CENTER?this.leftDisplacedHeadPx=this.width/2:this.justification===qt.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===qt.CENTER?s-=n/2:this.justification===qt.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=k.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)}}}de.TEXT_FONT={family:k.SANS_SERIF,size:12,weight:b.NORMAL,style:w.NORMAL};class le extends wt{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:de.Justification.CENTER},i),this.resetFont()}static get CATEGORY(){return c.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 _t.LEFT:case _t.RIGHT:n=(t.getYForLine(0)+t.getBottomLineY())/2+this.options.shift_y,s=this.position===_t.LEFT?t.getX()-i-24+this.options.shift_x:t.getX()+t.getWidth()+24+this.options.shift_x;break;case _t.ABOVE:case _t.BELOW:s=t.getX()+this.options.shift_x,this.options.justification===qt.CENTER?s+=t.getWidth()/2-i/2:this.options.justification===qt.RIGHT&&(s+=t.getWidth()-i),n=this.position===_t.ABOVE?t.getYForTopText(2)+this.options.shift_y:t.getYForBottomText(2)+this.options.shift_y;break;default:throw new d("InvalidPosition","Value Must be in Modifier.Position.")}return e.fillText(""+this.text,s,n+4),e.restore(),this}}le.TEXT_FONT={family:k.SERIF,size:16,weight:b.NORMAL,style:w.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"}(Qt||(Qt={}));class ge extends wt{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 c.Volta}static get type(){return Qt}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 Qt.BEGIN:i.fillRect(this.x+e,n,1,a);break;case Qt.END:s-=5,i.fillRect(this.x+e+s,n,1,a);break;case Qt.BEGIN_END:s-=3,i.fillRect(this.x+e,n,1,a),i.fillRect(this.x+e+s,n,1,a)}return this.volta!==Qt.BEGIN&&this.volta!==Qt.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}}ge.TEXT_FONT={family:k.SANS_SERIF,size:9,weight:b.BOLD,style:w.NORMAL};class ue extends R{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 R("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 R("timeSig"+e,this.timeSignature.point);this.botGlyphs.push(s),h+=g(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];R.renderOutline(i,e.getMetrics().outline,this.scale,s+this.x_shift,n),s+=g(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),R.renderOutline(i,a.getMetrics().outline,this.scale,s+a.getMetrics().x_shift,n),s+=g(a.getMetrics().width)}}}class pe extends wt{constructor(t="4/4",e=15,i=!0){super(),this.validate_args=i;const s=e,n=K.currentMusicFont();this.point=n.lookupMetric("digits.point");const a=n.lookupMetric("digits.shiftLine",0);this.topLine=2+a,this.bottomLine=4+a,this.setPosition(_t.BEGIN),this.info=this.parseTimeSpec(t),this.setWidth(g(this.info.glyph.getMetrics().width)),this.setPadding(s)}static get CATEGORY(){return c.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}=pe.glyphs[t];return{line:e,num:!1,glyph:new R(i,s)}}this.validate_args&&(t=>{const e=t.split("/");if(2!==e.length&&"+"!==e[0]&&"-"!==e[0])throw new d("BadTimeSignature",`Invalid time spec: ${t}. Must be in the form "<numerator>/<denominator>"`);e.forEach((e=>{if(0==/^[0-9+\-()]+$/.test(e))throw new d("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 ue(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 me={[vt.CATEGORY]:0,[ae.CATEGORY]:1,[oe.CATEGORY]:2,[pe.CATEGORY]:3},_e={[pe.CATEGORY]:0,[oe.CATEGORY]:1,[vt.CATEGORY]:2,[ae.CATEGORY]:3};class fe extends A{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:K.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 vt(this.options.left_bar?ft.SINGLE:ft.NONE)),this.addEndModifier(new vt(this.options.right_bar?ft.SINGLE:ft.NONE))}static get CATEGORY(){return c.Stave}static get defaultPadding(){const t=K.currentMusicFont();return t.lookupMetric("stave.padding")+t.lookupMetric("stave.endPaddingMax")}static get rightPadding(){return K.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)-K.STAVE_LINE_THICKNESS/2}getBottomLineBottomY(){return this.getYForLine(this.getNumLines()-1)+K.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:K.STAVE_LINE_THICKNESS},this.style)}setMeasure(t){return this.measure=t,this}getModifierXShift(t=0){if("number"!=typeof t)throw new d("InvalidIndex","Must be of number type");if(this.formatted||this.format(),1===this.getModifiers(_t.BEGIN).length)return 0;if(this.modifiers[t].getPosition()===_t.RIGHT)return 0;let e=this.start_x-this.x;const i=this.modifiers[0];return i.getType()===ft.REPEAT_BEGIN&&e>i.getWidth()&&(e-=i.getWidth()),e}setRepetitionType(t,e=0){return this.modifiers.push(new re(t,this.x,e)),this}setVoltaType(t,e,i){return this.modifiers.push(new ge(t,e,this.x,i)),this}setSection(t,e,i=0,s){const n=new he(t,this.x+i,e);return s&&n.setFontSize(s),this.modifiers.push(n),this}setTempo(t,e){return this.modifiers.push(new ce(t,this.x,e)),this}setText(t,e,i={}){return this.modifiers.push(new le(t,e,i)),this}getHeight(){return this.height}getSpacingBetweenLines(){return this.options.spacing_between_lines_px}getBoundingBox(){return new y(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,_t.END),this}setBegBarType(t){const{SINGLE:e,REPEAT_BEGIN:i,NONE:s}=ft;return t!==e&&t!==i&&t!==s||(this.modifiers[0].setType(t),this.formatted=!1),this}setEndBarType(t){return t!==ft.REPEAT_BEGIN&&(this.modifiers[1].setType(t),this.formatted=!1),this}setClef(t,e,i,s){void 0===s&&(s=_t.BEGIN),s===_t.END?this.endClef=t:this.clef=t;const n=this.getModifiers(s,ae.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,_t.END),this}getEndClef(){return this.endClef}setKeySignature(t,e,i){void 0===i&&(i=_t.BEGIN);const s=this.getModifiers(i,oe.CATEGORY);return 0===s.length?this.addKeySignature(t,e,i):s[0].setKeySig(t,e),this}setEndKeySignature(t,e){return this.setKeySignature(t,e,_t.END),this}setTimeSignature(t,e,i){void 0===i&&(i=_t.BEGIN);const s=this.getModifiers(i,pe.CATEGORY);return 0===s.length?this.addTimeSignature(t,e,i):s[0].setTimeSig(t),this}setEndTimeSignature(t,e){return this.setTimeSignature(t,e,_t.END),this}addKeySignature(t,e,i){return void 0===i&&(i=_t.BEGIN),this.addModifier(new oe(t,e).setPosition(i),i),this}addClef(t,e,i,s){return void 0===s||s===_t.BEGIN?this.clef=t:s===_t.END&&(this.endClef=t),this.addModifier(new ae(t,e,i),s),this}addEndClef(t,e,i){return this.addClef(t,e,i,_t.END),this}addTimeSignature(t,e,i){return this.addModifier(new pe(t,e),i),this}addEndTimeSignature(t,e){return this.addTimeSignature(t,e,_t.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(_t.BEGIN),n=this.getModifiers(_t.END);let a,o,r;this.sortByCategory(i,me),this.sortByCategory(n,_e),i.length>1&&t.getType()===ft.REPEAT_BEGIN&&(i.push(i.splice(0,1)[0]),i.splice(0,0,new vt(ft.SINGLE))),n.indexOf(e)>0&&n.splice(0,0,new vt(ft.NONE));let h=0,c=this.x;for(let t=0;t<i.length;t++)r=i[t],o=r.getPadding(t+h),a=r.getWidth(),c+=o,r.setX(c),c+=a,o+a===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<n.length;t++){r=n[t],l=s(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===n.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===n.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 d("StaveConfigError","The line number must be within the range of the number of lines in the Stave.");if(void 0===e.visible)throw new d("StaveConfigError","The line configuration object is missing the 'visible' property.");if("boolean"!=typeof e.visible)throw new d("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 d("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 xe(t,e,i,s,n){if(e!==Se.type.BOLD_DOUBLE_LEFT&&e!==Se.type.BOLD_DOUBLE_RIGHT)throw new d("InvalidConnector","A REPEAT_BEGIN or REPEAT_END type must be provided.");let a=3,o=3.5;e===Se.type.BOLD_DOUBLE_RIGHT&&(a=-5,o=3),t.fillRect(i+a,s,1,n-s),t.fillRect(i-2,s,o,n-s)}fe.TEXT_FONT={family:k.SANS_SERIF,size:8,weight:b.NORMAL,style:w.NORMAL};class Se extends A{constructor(t,e){super(),this.thickness=K.STAVE_LINE_THICKNESS,this.width=3,this.top_stave=t,this.bottom_stave=e,this.type=Se.type.DOUBLE,this.resetFont(),this.x_shift=0,this.texts=[]}static get CATEGORY(){return c.StaveConnector}setType(t){return(t="string"==typeof t?Se.typeString[t]:t)>=Se.type.SINGLE_RIGHT&&t<=Se.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 d("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===Se.type.SINGLE_RIGHT||this.type===Se.type.BOLD_DOUBLE_RIGHT||this.type===Se.type.THIN_DOUBLE)&&(n=this.top_stave.getX()+this.top_stave.getWidth());let a=i-e;switch(this.type){case Se.type.SINGLE:case Se.type.SINGLE_LEFT:case Se.type.SINGLE_RIGHT:s=1;break;case Se.type.DOUBLE:n-=this.width+2,e-=this.thickness,a+=.5;break;case Se.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,_=d+.135*a,f=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 Se.type.BRACKET:e-=6,i+=6,a=i-e,R.renderGlyph(t,n-5,e,40,"bracketTop"),R.renderGlyph(t,n-5,i,40,"bracketBottom"),n-=this.width+2;break;case Se.type.BOLD_DOUBLE_LEFT:xe(t,this.type,n+this.x_shift,e,i-this.thickness);break;case Se.type.BOLD_DOUBLE_RIGHT:xe(t,this.type,n,e,i-this.thickness);break;case Se.type.THIN_DOUBLE:s=1,a-=this.thickness;break;case Se.type.NONE:break;default:throw new d("InvalidType",`The provided StaveConnector.type (${this.type}) is invalid.`)}this.type!==Se.type.BRACE&&this.type!==Se.type.BOLD_DOUBLE_LEFT&&this.type!==Se.type.BOLD_DOUBLE_RIGHT&&this.type!==Se.type.NONE&&t.fillRect(n,e,s,a),this.type===Se.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()}}Se.TEXT_FONT={family:k.SERIF,size:16,weight:b.NORMAL,style:w.NORMAL},Se.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},Se.typeString={singleRight:Se.type.SINGLE_RIGHT,singleLeft:Se.type.SINGLE_LEFT,single:Se.type.SINGLE,double:Se.type.DOUBLE,brace:Se.type.BRACE,bracket:Se.type.BRACKET,boldDoubleLeft:Se.type.BOLD_DOUBLE_LEFT,boldDoubleRight:Se.type.BOLD_DOUBLE_RIGHT,thinDouble:Se.type.THIN_DOUBLE,none:Se.type.NONE};const ye=t=>t.reduce(((t,e)=>t+e),0);function Te(t,e,i){const s=we.getResolutionMultiplier(t),n={},a=[],o=[];return t.forEach(((t,r)=>{const h=new x(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 be(t,e,i,s){let n=e;for(let e=i+1;e<t.length;e++){const i=t[e];if(a(i)&&!i.isRest()&&!i.shouldIgnoreTicks()){n=i.getLineForRest();break}}if(s&&e!==n){n=m(Math.max(e,n),Math.min(e,n))}return n}class we{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 ne);const s=(new Ot).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:K.currentMusicFont().lookupMetric("stave.padding")},a)).stavePadding,r=e.contextGaps;t.save(),t.setFont(k.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 Mt(K.TIME4_4).setMode(Mt.Mode.SOFT).addTickables(i),o=n.auto_beam?Ne.applyAndGetBeams(a):[];return(new we).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 Mt(K.TIME4_4).setMode(Mt.Mode.SOFT).addTickables(n),c=new Mt(K.TIME4_4).setMode(Mt.Mode.SOFT).addTickables(s),d=r.auto_beam?Ne.applyAndGetBeams(h):[];(new we).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 Se(i,e).setContext(t).draw()}static AlignRestsToNotes(t,e,i){t.forEach(((s,n)=>{if(o(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=be(t,e.line,n,!1);else if(n>0&&n<t.length){const i=t[n-1];if(o(i))if(i.isRest())e.line=i.getKeyProps()[0].line;else{const s=i.getLineForRest();e.line=be(t,s,n,!0)}}s.setKeyLine(0,e.line)}}}))}alignRests(t,e){if(!t||!t.length)throw new d("BadArgument","No voices to format rests");t.forEach((t=>we.AlignRestsToNotes(t.getTickables(),e)))}preCalculateMinTotalWidth(t){const e=K.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 d("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,l=ye(a.map((t=>Math.pow(t-c,2)))),g=Math.pow(l/a.length,.5)/c,u=n/o.length,p=ye(o.map((t=>Math.pow(t-u,2)))),m=Math.pow(p/o.length,.5)/u,_=Math.max(m,g)*r.length*e,f=e*i;return this.minTotalWidth+Math.max(f,_)}getMinTotalWidth(){if(!this.hasMinTotalWidth)throw new d("NoMinTotalWidth","Call 'preCalculateMinTotalWidth' or 'preFormat' before calling 'getMinTotalWidth'");return this.minTotalWidth}static getResolutionMultiplier(t){if(!t||!t.length)throw new d("BadArgument","No voices to format");const e=t[0].getTotalTicks();return t.reduce(((t,i)=>{if(!i.getTotalTicks().equals(e))throw new d("TickMismatch","Voices should have same total note duration in ticks.");if(i.getMode()===Mt.Mode.STRICT&&!i.isComplete())throw new d("IncompleteVoice","Voice does not have enough notes.");return Math.max(t,x.LCM(t,i.getResolutionMultiplier()))}),1)}createModifierContexts(t){const e=Te(t,(()=>new ne),((t,e)=>t.addToModifierContext(e)));return this.modifierContexts=e,e}createTickContexts(t){const e=Te(t,(t=>new Ot(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 d("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:l,softmaxFactor:u,maxIterations:p}=this.formatterOptions,m=ye(a.map((t=>Math.pow(u,o[t].getMaxTicks().value()/c))));if(this.minTotalWidth=r+h,this.hasMinTotalWidth=!0,t<=0)return this.evaluate();const _=o[a[0]],f=o[a[a.length-1]];function x(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(),d=[];if(Object.keys(n).forEach((t=>{i[t]&&d.push(t)})),d.length>0){let a=0,o=1/0,h=0;if(d.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)),l){const e=c;h=Math.pow(u,a/e)/m*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=g(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())}))})),f.getX()-_.getX()}const y=t-f.getMetrics().notePx-f.getMetrics().totalRightPx-_.getMetrics().totalLeftPx,T=K.currentMusicFont(),b=T.lookupMetric("stave.endPaddingMin"),w=T.lookupMetric("stave.endPaddingMax");let v=y;const E=x(v);let C=S(E);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})(v,E);if(1===a.length)return 0;const D=2*w<k?k:w,N=y-(D-(w-b));let A=p;for(;C>N&&A>0||C+D<N&&A>1;)v-=C-N,C=S(x(v)),A--;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=-ye(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()-fe.defaultPadding;return function(...t){we.DEBUG&&u("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 ve;we.DEBUG=!1,function(t){t[t.BOTTOM=-1]="BOTTOM",t[t.TOP=1]="TOP"}(ve||(ve={}));class Ee extends A{constructor(t,e={}){if(super(),this.numerator_glyphs=[],this.denom_glyphs=[],!t||!t.length)throw new d("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=K.currentMusicFont().lookupMetric("digits.tupletPoint"),this.y_pos=16,this.x_pos=100,this.width=200,this.setTupletLocation(this.options.location||Ee.LOCATION_TOP),we.AlignRestsToNotes(t,!0,!0),this.resolveGlyphs(),this.attach()}static get CATEGORY(){return c.Tuplet}static get LOCATION_TOP(){return ve.TOP}static get LOCATION_BOTTOM(){return ve.BOTTOM}static get NESTING_OFFSET(){return 15}static get metrics(){return K.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!==Ee.LOCATION_TOP&&t!==Ee.LOCATION_BOTTOM&&(console.warn(`Invalid tuplet location [${t}]. Using Tuplet.LOCATION_TOP.`),t=Ee.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 R("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 R("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()*Ee.NESTING_OFFSET*-this.location,e=this.options.y_offset||0,i=this.notes[0];let s;if(this.location===Ee.LOCATION_TOP){s=i.checkStave().getYForLine(0)-Ee.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)-Ee.metrics.noteHeadOffset;if(e.hasStem()||e.isRest()){const t=e.getStemDirection()===Q.UP?e.getStemExtents().topY-Ee.metrics.stemOffset:e.getStemExtents().baseY-Ee.metrics.noteHeadOffset;s=Math.min(t,s),i>0&&(s=Math.min(a,s))}}}else{let t=Ee.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)+Ee.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()===Q.UP?this.notes[t].getStemExtents().baseY+Ee.metrics.noteHeadOffset:this.notes[t].getStemExtents().topY+Ee.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+g(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===Ee.LOCATION_BOTTOM?1:0),1,10*this.location),t.fillRect(this.x_pos+this.width,this.y_pos+(this.location===Ee.LOCATION_BOTTOM?1:0),1,10*this.location))}const o=K.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+=g(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+=g(e.getMetrics().width)}))}}}function Ce(t){let e=0;return t.forEach((t=>{t.keyProps&&t.keyProps.forEach((t=>{e+=t.line-3}))})),e>=0?Q.DOWN:Q.UP}const ke="L",De="B";class Ne extends A{constructor(t,e=!1){if(super(),this.slope=0,this.y_shift=0,!t||0===t.length)throw new d("BadArguments","No notes provided for beam.");if(1===t.length)throw new d("BadArguments","Too few notes for beam.");if(this.ticks=t[0].getIntrinsicTicks(),this.ticks>=K.durationToTicks("4"))throw new d("BadArguments","Beams can only be applied to notes shorter than a quarter note.");let i,s;for(this.stem_direction=Q.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&&o(t[0]))n=Ce(t);else if(e&&h(t[0])){const e=t.reduce(((t,e)=>t+e.getStemDirection()),0);n=e>-1?Q.UP:Q.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 c.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 x).parse(t)));{const e=parseInt(t.split("/")[0],10),i=parseInt(t.split("/")[1],10);if(e%3==0)return[new x(3,i)];if(i>4)return[new x(2,i)];if(i<=4)return[new x(1,i)]}return[new x(1,4)]}static applyAndGetBeams(t,e,i){return Ne.generateBeams(t.getTickables(),{groups:i,stem_direction:e})}static generateBeams(t,e={}){e.groups&&e.groups.length||(e.groups=[new x(2,8)]);const i=e.groups.map((t=>{if(!t.multiply)throw new d("InvalidBeamGroups","The beam groups must be an array of Vex.Flow.Fractions");return t.clone().multiply(K.RESOLUTION,1)})),s=t;let n=0,a=[],o=[];function r(){i.length-1>n?n+=1:n=0}!function(){let t=[],e=new x(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 x(0,1))).add(e);var d;const l=K.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 x(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():Q.UP}else i=e.stem_direction?e.stem_direction:Ce(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()>=K.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}(),l=[];return h.forEach((t=>{const i=new Ne(t);e.show_stemlets&&(i.render_options.show_stemlets=!0),e.secondary_breaks&&(i.render_options.secondary_break_ticks=K.durationToTicks(e.secondary_breaks)),!0===e.flat_beams&&(i.render_options.flat_beams=!0,i.render_options.flat_beam_offset=e.flat_beam_offset),l.push(i)})),c.forEach((t=>{const e=t.notes[0].stem_direction===Q.DOWN?ve.BOTTOM:ve.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)})),l}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}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===Q.DOWN&&h<n?(h=n,o=Math.max(...s.getYs()),r=s.getBeamCount()):e===Q.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===Q.DOWN&&c<l?c=o+d:e===Q.UP&&c>l&&(c=o-d),n?(e===Q.DOWN&&c>n||e===Q.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===Q.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){if("4"===t)return ke;const n=""+K.durationToNumber(t)/2,a=e<K.durationToTicks(n),o=s<K.durationToTicks(n),r=i<K.durationToTicks(n);return a&&o&&r?De:a&&!o&&r?ke:!a&&o&&r?"R":this.lookupBeamDirection(n,e,i,s)}getBeamLines(t){const e=K.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()-Q.WIDTH/2,u=this.notes[h-1],p=this.notes[h+1],m=p&&p.getIntrinsicTicks()<e,_=u&&u.getIntrinsicTicks()<e,f=u&&p&&l&&!_&&!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,f){const e=u.getIntrinsicTicks(),i=p.getIntrinsicTicks(),s=c.getIntrinsicTicks(),o=this.lookupBeamDirection(t,e,s,i);[ke,De].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 d("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||(h(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 Ae extends mt{constructor(t,e,i){super({duration:"b"}),this.type=t,this.clef_obj=new ae(t,e,i),this.clef=this.clef_obj.clef,this.glyph=new R(this.clef.code,this.clef.point),this.setWidth(this.glyph.getMetrics().width),this.ignore_ticks=!0}static get CATEGORY(){return c.ClefNote}setType(t,e,i){return this.type=t,this.clef_obj=new ae(t,e,i),this.clef=this.clef_obj.clef,this.glyph=new R(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 R(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 Fe extends mt{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 c.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=Ot.getNextContext(i),n=this.getAbsoluteX(),a=s?s.getX():e.getX()+e.getWidth(),o=e.getYForLine(this.line+-3)+1;!function(...t){Fe.DEBUG&&u("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 Pe;Fe.DEBUG=!1,function(t){t[t.NEAR_HEAD=1]="NEAR_HEAD",t[t.NEAR_TOP=2]="NEAR_TOP"}(Pe||(Pe={}));class Me extends A{constructor(t,e,i){super(),this.render_options=Object.assign({thickness:2,x_shift:0,y_shift:10,position:Pe.NEAR_HEAD,position_end:Pe.NEAR_HEAD,invert:!1,cps:[{x:0,y:10},{x:0,y:10}]},i),this.from=t,this.to=e}static get CATEGORY(){return c.Curve}static get Position(){return Pe}static get PositionString(){return{nearHead:Pe.NEAR_HEAD,nearTop:Pe.NEAR_TOP}}setNotes(t,e){if(!t&&!e)throw new d("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?Me.PositionString[t]:t}const d=c(this.render_options.position),l=c(this.render_options.position_end);if(d===Pe.NEAR_TOP&&(r="topY",h="topY"),l===Pe.NEAR_HEAD?h="baseY":l===Pe.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 Be(...t){Oe.DEBUG&&u("Vex.Flow.Parser",t)}function Re(t){if("matchedString"in t)return t.matchedString;if("results"in t)return Re(t.results);const e=t;return 1===e.length?Re(e[0]):0===e.length?null:e.map(Re)}class Oe{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(Be("Evaluating rule function:",t),!t)throw new d("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 Be(i),new d("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(Re(t)))),i.run&&e.success&&i.run({matches:s}),e}}function Le(...t){je.DEBUG&&u("Vex.Flow.EasyScore",t)}Oe.DEBUG=!1;class Ie{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 We{constructor(t){this.chord=[],this.dots=0,this.options={},this.duration=t}}class Ge{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(){Le("resetPiece"),this.piece=new We(this.rollingDuration)}setNoteDots(t){Le("setNoteDots:",t),t&&(this.piece.dots=t.length)}setNoteDuration(t){Le("setNoteDuration:",t),this.rollingDuration=this.piece.duration=t||this.rollingDuration}setNoteType(t){Le("setNoteType:",t),t&&(this.piece.type=t)}addNoteOption(t,e){Le("addNoteOption: key:",t,"value:",e),this.piece.options[t]=e}addNote(t,e,i){Le("addNote:",t,e,i),this.piece.chord.push({key:t,accid:e,octave:i})}addSingleNote(t,e,i){Le("addSingleNote:",t,e,i),this.addNote(t,e,i)}addChord(t){Le("startChord"),"object"!=typeof t[0]?this.addSingleNote(t[0]):t.forEach((t=>{t&&this.addNote(...t)})),Le("endChord")}commitPiece(){Le("commitPiece");const{factory:t}=this;if(!t)return;const e=Object.assign(Object.assign({},this.options),this.piece.options),i=g(e.stem,"BadArguments","options.stem is not defined").toLowerCase(),s=g(e.clef,"BadArguments","options.clef is not defined").toLowerCase(),{chord:n,duration:a,dots:o,type:r}=this.piece,h=L.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?Q.UP:Q.DOWN);const u=[];n.forEach(((e,i)=>{const s=e.accid;if("string"==typeof s){const e=t.Accidental({type:s});l.addModifier(e,i),u.push(e)}else u.push(void 0)}));for(let t=0;t<o;t++)Nt.buildAndAttach([l],{all:!0});this.commitHooks.forEach((t=>t(e,l,this))),this.elements.notes.push(l),this.elements.accidentals.push(u),this.resetPiece()}}function Ue(t,e){void 0!==t.id&&e.setAttribute("id",t.id)}const Ye=/\s*,\s*/;function He(t,e){void 0!==t.class&&t.class.split(Ye).forEach((t=>e.addClass(t)))}class je{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 Ge(s);return this.options=Object.assign(Object.assign({commitHooks:[Ue,He,gt.easyScoreHook,At.easyScoreHook],throwOnError:!1},t),{factory:s,builder:n}),this.factory=s,this.builder=n,this.grammar=new Ie(this.builder),this.parser=new Oe(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 Le(i),new d("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)}}je.DEBUG=!1;const Xe="Ghost note must have valid initialization data to identify duration.";class Ve extends Gt{static get CATEGORY(){return c.GhostNote}constructor(t){if(!t)throw new d("BadArguments",Xe);let e;if("string"==typeof t)e={duration:t};else{if("object"!=typeof t)throw new d("BadArguments",Xe);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];i(e,c.Annotation)&&(e.setContext(this.getContext()),e.drawWithStyle())}}}class ze extends mt{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 c.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 Ke extends Yt{constructor(t){super(Object.assign({glyph_font_scale:K.NOTATION_FONT_SCALE*Ke.SCALE,stroke_px:Ke.LEDGER_LINE_OFFSET},t)),this.slash=t.slash||!1,this.slur=!0,this.buildNoteHeads(),this.width=3}static get CATEGORY(){return c.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=(Q.HEIGHT+e)*t-Q.HEIGHT}return e}return 0}getStaveNoteScale(){return this.render_options.glyph_font_scale/K.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===Q.DOWN?a.y_top-o:a.y_bottom-o;const c=n===Q.DOWN?this.glyph.stem_down_extension:this.glyph.stem_up_extension;let d=K.STEM_HEIGHT;d-=d/2.8,d+=c,h+=d*e*n;const l=n===Q.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 d("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),l=Math.cos(c)*i.stem*a,g=Math.sin(c)*i.stem,u=Math.cos(c)*i.beam*a,p=Math.sin(c)*i.beam,m=this.getStemX(),_=s.notes[0].getStemX(),f=s.getBeamYToDraw()+(m-_)*n;return{x1:m-l,y1:f+t-g,x2:m+r*a+u,y2:f+h+p}}}class $e extends mt{constructor(t,e,i){super({duration:"b"}),this.keySignature=new oe(t,e,i),this.ignore_ticks=!0}static get CATEGORY(){return c.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 Je;class qe extends A{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=K.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:K.STAVE_LINE_DISTANCE,serif_thickness:2,semibreve_rest_glyph_scale:K.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 c.MultiMeasureRest}getXs(){return this.xs}setStave(t){return this.stave=t,this}getStave(){return this.stave}checkStave(){return g(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;Je=void 0;const d=function(){if(!Je){const t=new Wt({duration:"w",note_type:"r"});Je={glyph_font_scale:t.render_options.glyph_font_scale,glyph_code:t.glyph_code,width:t.getWidth()}}return Je}(),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 _=c.line,f=t.getYForLine(_-1),x=t.getYForLine(_),S=t.getYForLine(_+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)R.renderGlyph(e,m,f,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(),n=e.getNoteEndX();const a=e.getModifiers(_t.BEGIN);1===a.length&&s(a[0])&&(i-=a[0].getWidth());const o=this.render_options;this.hasPaddingLeft&&(i=e.getX()+o.padding_left),this.hasPaddingRight&&(n=e.getX()+e.getWidth()-o.padding_right),this.xs.left=i,this.xs.right=n;const r=o.spacing_between_lines_px;if(o.use_symbols?this.drawSymbols(e,t,i,n,r):this.drawLine(e,t,i,n,r),o.show_number){const s="/"+this.number_of_measures,a=new pe(s,0,!1);a.point=o.number_glyph_point,a.setTimeSig(s),a.setStave(e),a.setX(i+.5*(n-i)-.5*a.getInfo().glyph.getMetrics().width),a.bottomLine=o.number_line,a.setContext(t).draw()}}}function Qe(t,e,i,s,n){const a=Ze.GLYPHS[t];new R(a.code,n,{category:"pedalMarking"}).render(e,i+a.x_shift,s+a.y_shift)}class Ze extends A{constructor(t){super(),this.notes=t,this.type=Ze.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 c.PedalMarking}static createSustain(t){return new Ze(t)}static createSostenuto(t){const e=new Ze(t);return e.setType(Ze.type.MIXED),e.setCustomText("Sost. Ped."),e}static createUnaCorda(t){const e=new Ze(t);return e.setType(Ze.type.TEXT),e.setCustomText("una corda","tre corda"),e}setType(t){return(t="string"==typeof t?Ze.typeString[t]:t)>=Ze.type.TEXT&&t<=Ze.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 d("InvalidConfiguration","The notes provided must be in order of ascending x positions");const c=o[a+1]===n,l=o[a-1]===n;let g=0;const u=K.currentMusicFont().lookupMetric(`pedalMarking.${s?"down":"up"}.point`);if(s)if(g=l?5:0,this.type!==Ze.type.MIXED||l)t.beginPath(),t.moveTo(r,h-this.render_options.bracket_height),t.lineTo(r+g,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),g=e/2+this.render_options.text_margin_right}else Qe("pedal_depress",t,r,h,u),g=20+this.render_options.text_margin_right;else g=c?-5:0,t.beginPath(),t.moveTo(e,i),t.lineTo(r+g,h),t.lineTo(r,h-this.render_options.bracket_height),t.stroke(),t.closePath();e=r+g,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=K.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)):Qe("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)):Qe("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){Ze.DEBUG&&u("Vex.Flow.PedalMarking",t)}("Rendering Pedal Marking"),this.type===Ze.type.BRACKET||this.type===Ze.type.MIXED?(t.setLineWidth(this.render_options.bracket_line_width),this.drawBracketed()):this.type===Ze.type.TEXT&&this.drawText(),t.restore()}}Ze.DEBUG=!1,Ze.TEXT_FONT={family:k.SERIF,size:12,weight:b.BOLD,style:w.ITALIC},Ze.GLYPHS={pedal_depress:{code:"keyboardPedalPed",x_shift:-10,y_shift:0},pedal_release:{code:"keyboardPedalUp",x_shift:-2,y_shift:3}},Ze.type={TEXT:1,BRACKET:2,MIXED:3},Ze.typeString={text:Ze.type.TEXT,bracket:Ze.type.BRACKET,mixed:Ze.type.MIXED};const ti={1:"repeat1Bar",2:"repeat2Bars",4:"repeat4Bars",slash:"repeatBarSlash"};class ei extends ze{static get CATEGORY(){return c.RepeatNote}constructor(t,e,i){super(void 0,Object.assign({duration:"q",align_center:"slash"!==t},e),i);const s=new R(ti[t]||"repeat1Bar",K.currentMusicFont().lookupMetric("repeatNote.point",40),{category:"repeatNote"});this.setGlyph(s)}}function ii(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 si extends A{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:si.TextVerticalPosition.TOP,text_justification:si.TextJustification.CENTER}}static get CATEGORY(){return c.StaveLine}setText(t){return this.text=t,this}setNotes(t){if(!t.first_note&&!t.last_note)throw new d("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 d("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)&&(_=p+Math.PI+this.render_options.arrowhead_angle,x=o+Math.cos(_)*m,S=r+Math.sin(_)*m,f=p+Math.PI-this.render_options.arrowhead_angle,y=o+Math.cos(f)*m,T=r+Math.sin(f)*m,ii(t,x,S,o,r,y,T)),(this.render_options.draw_start_arrow||s)&&(_=p+this.render_options.arrowhead_angle,x=n+Math.cos(_)*m,S=a+Math.sin(_)*m,f=p-this.render_options.arrowhead_angle,y=n+Math.cos(f)*m,T=a+Math.sin(f)*m,ii(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===si.TextJustification.LEFT)h=n.x;else if(r===si.TextJustification.CENTER){h=(a.x-n.x)/2+n.x-o/2}else r===si.TextJustification.RIGHT&&(h=a.x-o);let c=0;const d=s.text_position_vertical;return d===si.TextVerticalPosition.TOP?c=e.checkStave().getYForTopText():d===si.TextVerticalPosition.BOTTOM&&(c=e.checkStave().getYForBottomText(K.TEXT_HEIGHT_OFFSET_HACK)),t.save(),this.applyFontStyle(),t.fillText(this.text,h,c),t.restore(),this}}si.TEXT_FONT=Object.assign({},A.TEXT_FONT),si.TextVerticalPosition={TOP:1,BOTTOM:2},si.TextJustification={LEFT:1,CENTER:2,RIGHT:3};class ni extends A{constructor(t={}){super(),this.setOptions(t),this.parts=[]}static get CATEGORY(){return c.System}setOptions(t={}){if(!t.factory)throw new d("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 we(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),this.options.autoWidth?t.voices.forEach((t=>{i.joinVoices([t])})):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+fe.rightPadding+(n-this.options.x))}))):e=this.options.noPadding?this.options.width-this.options.x:this.options.width-(n-this.options.x)-fe.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 y(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 d("NoFormatter","format() must be called before draw()");this.setRendered(),this.options.debugFormatter&&we.plotDebugging(t,this.formatter,this.startX,this.options.y,this.lastY),this.debugNoteMetricsYs.forEach((e=>{e.voice.getTickables().forEach((i=>mt.plotMetrics(t,i,e.y)))}))}}class ai extends Gt{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:K.TABLATURE_FONT_SCALE,draw_stem:e,draw_dots:e,draw_stem_through_stave:!1,y_shift:0,scale:1,font:`${k.SIZE}pt ${k.SANS_SERIF}`}),this.glyph=K.getGlyphProps(this.duration,this.noteType),g(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(Q.UP),this.ghost=!1,this.updateWidth()}static get CATEGORY(){return c.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()===Q.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=K.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 d("UnformattedNote","Can't call GetModifierStartXY on an unformatted note");if(0===this.ys.length)throw new d("NoYValues","No Y-Values calculated for this note.");let i=0;if(t===O.Position.LEFT)i=-2;else if(t===O.Position.RIGHT)i=this.width+2;else if(t===O.Position.BELOW||t===O.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=Q.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()===Q.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=>{i(t,c.Dot)&&!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(Q.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)R.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 d("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 oi extends fe{static get CATEGORY(){return c.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 ri(...t){ci.DEBUG&&u("Vex.Flow.TextBracket",t)}var hi;!function(t){t[t.TOP=1]="TOP",t[t.BOTTOM=-1]="BOTTOM"}(hi||(hi={}));class ci extends A{constructor({start:t,stop:e,text:i="",superscript:s="",position:n=hi.TOP}){super(),this.start=t,this.stop=e,this.text=i,this.superscript=s,this.position="string"==typeof n?ci.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 c.TextBracket}static get Position(){return hi}static get PositionString(){return{top:hi.TOP,bottom:hi.BOTTOM}}static get Positions(){return ri("Positions is deprecated, use TextBracketPosition instead."),hi}static get PositionsString(){return ri("PositionsString is deprecated, use PositionString instead."),ci.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 hi.TOP:e=this.start.checkStave().getYForTopText(this.line);break;case hi.BOTTOM:e=this.start.checkStave().getYForBottomText(this.line+K.TEXT_HEIGHT_OFFSET_HACK);break;default:throw new d("InvalidPosition",`The position ${this.position} is invalid.`)}const i={x:this.start.getAbsoluteX(),y:e},s={x:this.stop.getAbsoluteX(),y:e};ri("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:l,weight:g,style:u}=this.textFont,p=k.scaleSize(l,.714286);t.setFont(c,p,g,u),t.fillText(this.superscript,i.x+o+1,h);const m=t.measureText(this.superscript),_=m.width,f=m.height;let x=i.x,S=h;const y=s.x+this.stop.getGlyph().getWidth();this.position===hi.TOP?(x+=o+_+5,S-=f/2.7):this.position===hi.BOTTOM&&(S+=f/2.7,x+=o+2,this.render_options.underline_superscript||(x+=_)),this.render_options.dashed?(Zt.drawDashedLine(t,x,S,y,S,this.render_options.dash),this.render_options.show_bracket&&Zt.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 di(...t){li.DEBUG&&u("Vex.Flow.TextDynamics",t)}ci.DEBUG=!1,ci.TEXT_FONT={family:k.SERIF,size:15,weight:b.NORMAL,style:w.ITALIC};class li extends mt{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}),di("New Dynamics Text: ",this.sequence)}static get CATEGORY(){return c.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=li.GLYPHS[e];if(!i)throw new d("Invalid dynamics character: "+e);const s=g(this.render_options.glyph_font_size),n=new R(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);di("Rendering Dynamics: ",this.sequence);let i=t;this.glyphs.forEach(((t,s)=>{const n=this.sequence[s];t.render(this.checkContext(),i,e),i+=li.GLYPHS[n].width}))}}li.DEBUG=!1;class gi extends mt{constructor(t,e){super({duration:"b"});const i=new pe(t,e);this.timeSigInfo=i.getInfo(),this.setWidth(this.timeSigInfo.glyph.getMetrics().width),this.ignore_ticks=!0}static get CATEGORY(){return c.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 ui extends A{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 c.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){ui.DEBUG&&u("Vex.Flow.VibratoBracket",t)}("Rendering VibratoBracket: start_x:",i,"stop_x:",s,"y:",e),ie.renderVibrato(t,i,e,this.render_options)}}function pi(...t){mi.DEBUG&&u("Vex.Flow.Factory",t)}ui.DEBUG=!1;class mi{constructor(t={}){pi("New factory: ",t),this.options={stave:{space:10},renderer:{elementId:"",width:500,height:200,background:"#FFF"},font:mi.TEXT_FONT},this.setOptions(t)}static newFromElementId(t,e=500,i=200){return new mi({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 pi(this),new d("renderer.elementId not set in FactoryOptions");let n=this.options.renderer.backend;if(void 0===n){n=Ht(document.getElementById(t))?Zt.Backends.CANVAS:Zt.Backends.SVG}this.context=Zt.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 fe(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 oi(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 Yt(t);return this.stave&&e.setStave(this.stave),e.setContext(this.context),this.renderQ.push(e),e}GlyphNote(t,e,i){const s=new ze(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 ei(t,e,i);return this.stave&&s.setStave(this.stave),s.setContext(this.context),this.renderQ.push(s),s}GhostNote(t){const e=new Ve(t);return this.stave&&e.setStave(this.stave),e.setContext(this.context),this.renderQ.push(e),e}TextNote(t){const e=new de(t);return this.stave&&e.setStave(this.stave),e.setContext(this.context),this.renderQ.push(e),e}BarNote(t={}){const e=new Et(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 Ae(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 gi(e.time);return this.stave&&i.setStave(this.stave),i.setContext(this.context),this.renderQ.push(i),i}KeySigNote(t){const e=new $e(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 ai(t);return this.stave&&e.setStave(this.stave),e.setContext(this.context),this.renderQ.push(e),e}GraceNote(t){const e=new Ke(t);return this.stave&&e.setStave(this.stave),e.setContext(this.context),e}GraceNoteGroup(t){const e=new Bt(t.notes,t.slur);return e.setContext(this.context),e}Accidental(t){const e=new q(t.type);return e.setContext(this.context),e}Annotation(t){const e=Object.assign({text:"p",hJustify:st.CENTER,vJustify:nt.BOTTOM},t),i=new at(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 Dt;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 gt(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 li({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 At(e.number);return i.setPosition(e.position),i.setContext(this.context),i}StringNumber(t){const e=new te(t.number);return e.setPosition(t.position),e.setContext(this.context),e}TickContext(){return new Ot}ModifierContext(){return new ne}MultiMeasureRest(t){const e=g(t.number_of_measures,"NoNumberOfMeasures"),i=new qe(e,t);return i.setContext(this.context),this.renderQ.push(i),i}Voice(t){const e=Object.assign({time:"4/4"},t),i=new Mt(e.time,e.options);return this.voices.push(i),i}StaveConnector(t){const e=new Se(t.top_stave,t.bottom_stave);return e.setType(t.type).setContext(this.context),this.renderQ.push(e),e}Formatter(t){return new we(t)}Tuplet(t){const e=Object.assign({notes:[],options:{}},t),i=new Ee(e.notes,e.options).setContext(this.context);return this.renderQ.push(i),i}Beam(t){var e,i,s;const n=new Ne(t.notes,null===(e=t.options)||void 0===e?void 0:e.autoStem).setContext(this.context);return n.breakSecondaryAt(null!==(s=null===(i=t.options)||void 0===i?void 0:i.secondaryBeamBreaks)&&void 0!==s?s:[]),this.renderQ.push(n),n}Curve(t){const e=new Me(t.from,t.to,t.options).setContext(this.context);return this.renderQ.push(e),e}StaveTie(t){var e;const i=new Ft({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 si({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 ui({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 ci({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 ni(t).setContext(this.context);return this.systems.push(e),e}EasyScore(t={}){return t.factory=this,new je(t)}PedalMarking(t){const e=Object.assign({notes:[],options:{style:"mixed"}},t),i=new Ze(e.notes);return i.setType(Ze.typeString[e.options.style]),i.setContext(this.context),this.renderQ.push(i),i}NoteSubGroup(t){const e=Object.assign({notes:[]},t),i=new Rt(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()}}mi.DEBUG=!1,mi.TEXT_FONT=Object.assign({},A.TEXT_FONT);class _i extends A{constructor(t,e){super(),this.setNotes(t),this.hairpin=e,this.position=O.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 c.StaveHairpin}static FormatByTicksAndDraw(t,e,i,s,n,a){var o,r;const h=e.pixelsPerTick;if(null==h)throw new d("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),l=h*(null!==(r=a.right_shift_ticks)&&void 0!==r?r:0),g={height:a.height,y_shift:a.y_shift,left_shift_px:c,right_shift_px:l,right_shift_ticks:0,left_shift_ticks:0};new _i({first_note:i.first_note,last_note:i.last_note},s).setContext(t).setRenderOptions(g).setPosition(n).draw()}setPosition(t){return t!==O.Position.ABOVE&&t!==O.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 d("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===O.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 _i.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 _i.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 d("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()})}}_i.type={CRESC:1,DECRESC:2};class fi extends Pt{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)?fi.SLIDE_UP:i>s?fi.SLIDE_DOWN:fi.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 c.TabSlide}static get SLIDE_UP(){return 1}static get SLIDE_DOWN(){return-1}static createSlideUp(t){return new fi(t,fi.SLIDE_UP)}static createSlideDown(t){return new fi(t,fi.SLIDE_DOWN)}renderTie(t){if(0===t.first_ys.length||0===t.last_ys.length)throw new d("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!==fi.SLIDE_UP&&a!==fi.SLIDE_DOWN)throw new d("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 d("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()}}fi.TEXT_FONT={family:k.SERIF,size:10,weight:b.BOLD,style:w.ITALIC};class xi{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 K.keyProperties(t).int_value}setTuning(t){xi.names[t]&&(t=xi.names[t]),this.tuningValues=[];const e=t.split(/\s*,\s*/);if(0===e.length)throw new d("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 d("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 d("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`${K.integerToNote(n)}/${s}`}}var Si=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 yi{static get BUILD(){return{VERSION:"4.0.1-beta.2",ID:"567ba80618390639c170a60de47ab4d1f2eabbff",DATE:"2022-02-27T01:14:47.524Z"}}static get Flow(){return yi}static setMusicFont(...t){const e=t.map((t=>k.load(t)));return K.MUSIC_FONT_STACK=e,R.MUSIC_FONT_STACK=e.slice(),R.CURRENT_CACHE_KEY=t.join(","),e}static fetchMusicFont(t,e){return Si(this,void 0,void 0,(function*(){}))}static getMusicFont(){return K.MUSIC_FONT_STACK.map((t=>t.getName()))}static get NOTATION_FONT_SCALE(){return K.NOTATION_FONT_SCALE}static set NOTATION_FONT_SCALE(t){K.NOTATION_FONT_SCALE=t}static get TABLATURE_FONT_SCALE(){return K.TABLATURE_FONT_SCALE}static set TABLATURE_FONT_SCALE(t){K.TABLATURE_FONT_SCALE=t}static get RESOLUTION(){return K.RESOLUTION}static set RESOLUTION(t){K.RESOLUTION=t}static get SLASH_NOTEHEAD_WIDTH(){return K.SLASH_NOTEHEAD_WIDTH}static set SLASH_NOTEHEAD_WIDTH(t){K.SLASH_NOTEHEAD_WIDTH=t}static get STAVE_LINE_DISTANCE(){return K.STAVE_LINE_DISTANCE}static set STAVE_LINE_DISTANCE(t){K.STAVE_LINE_DISTANCE=t}static get STAVE_LINE_THICKNESS(){return K.STAVE_LINE_THICKNESS}static set STAVE_LINE_THICKNESS(t){K.STAVE_LINE_THICKNESS=t}static get STEM_HEIGHT(){return K.STEM_HEIGHT}static set STEM_HEIGHT(t){K.STEM_HEIGHT=t}static get STEM_WIDTH(){return K.STEM_WIDTH}static set STEM_WIDTH(t){K.STEM_WIDTH=t}static get TIME4_4(){return K.TIME4_4}static get accidentalMap(){return K.accidentalMap}static get unicode(){return K.unicode}static keySignature(t){return K.keySignature(t)}static hasKeySignature(t){return K.hasKeySignature(t)}static getKeySignatures(){return K.getKeySignatures()}static clefProperties(t){return K.clefProperties(t)}static keyProperties(t,e,i){return K.keyProperties(t,e,i)}static durationToTicks(t){return K.durationToTicks(t)}}yi.Accidental=q,yi.Annotation=at,yi.Articulation=gt,yi.Barline=vt,yi.BarNote=Et,yi.Beam=Ne,yi.Bend=Ct,yi.BoundingBox=y,yi.BoundingBoxComputation=T,yi.CanvasContext=jt,yi.ChordSymbol=Dt,yi.Clef=ae,yi.ClefNote=Ae,yi.Crescendo=Fe,yi.Curve=Me,yi.Dot=Nt,yi.EasyScore=je,yi.Element=A,yi.Factory=mi,yi.Font=k,yi.Formatter=we,yi.Fraction=x,yi.FretHandFinger=At,yi.GhostNote=Ve,yi.Glyph=R,yi.GlyphNote=ze,yi.GraceNote=Ke,yi.GraceNoteGroup=Bt,yi.GraceTabNote=class extends ai{static get CATEGORY(){return c.GraceTabNote}constructor(t){super(t,!1),this.render_options=Object.assign(Object.assign({},this.render_options),{y_shift:.3,scale:.6,font:`7.5pt ${k.SANS_SERIF}`}),this.updateWidth()}},yi.KeyManager=class{constructor(t){this.music=new L,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(!L.scaleTypes[this.keyParts.type])throw new d("BadArguments",`Unsupported key type: ${this.key}`);this.scale=this.music.getScaleTones(this.music.getNoteValue(this.keyString),L.scaleTypes[this.keyParts.type]),this.scaleMap={},this.scaleMapByValue={},this.originalScaleMapByValue={};const t=L.root_indices[this.keyParts.root];for(let e=0;e<L.roots.length;++e){const i=(t+e)%L.roots.length,s=L.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})}},yi.KeySignature=oe,yi.KeySigNote=$e,yi.Modifier=O,yi.ModifierContext=ne,yi.MultiMeasureRest=qe,yi.Music=L,yi.Note=mt,yi.NoteHead=Wt,yi.NoteSubGroup=Rt,yi.Ornament=Lt,yi.Parenthesis=It,yi.Parser=Oe,yi.PedalMarking=Ze,yi.Registry=N,yi.RenderContext=ut,yi.Renderer=Zt,yi.RepeatNote=ei,yi.Repetition=re,yi.Stave=fe,yi.StaveConnector=Se,yi.StaveHairpin=_i,yi.StaveLine=si,yi.StaveModifier=wt,yi.StaveNote=Yt,yi.StaveTempo=ce,yi.StaveText=le,yi.StaveTie=Ft,yi.Stem=Q,yi.StringNumber=te,yi.Stroke=ee,yi.SVGContext=Kt,yi.System=ni,yi.TabNote=ai,yi.TabSlide=fi,yi.TabStave=oi,yi.TabTie=Pt,yi.TextBracket=ci,yi.TextDynamics=li,yi.TextFormatter=it,yi.TextNote=de,yi.TickContext=Ot,yi.TimeSignature=pe,yi.TimeSigNote=gi,yi.Tremolo=class extends O{constructor(t){super(),this.num=t,this.position=O.Position.CENTER,this.code="tremolo1",this.y_spacing_scale=1,this.extra_stroke_scale=1}static get CATEGORY(){return c.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 a=n(e),o=a?Ke.SCALE:1,r="tremolo."+(a?"grace":"default"),h=K.currentMusicFont();let c=h.lookupMetric(`${r}.spacing`)*i;c*=this.y_spacing_scale;const d=this.num*c;let l=e.getStemExtents().baseY-d;l+=i<0?h.lookupMetric(`${r}.offsetYStemDown`)*o:h.lookupMetric(`${r}.offsetYStemUp`)*o;const g=h.lookupMetric(`${r}.point`);s+=h.lookupMetric(`${r}.offsetXStem${i===Q.UP?"Up":"Down"}`);for(let e=0;e<this.num;++e)R.renderGlyph(t,s,l,g,this.code,{category:r,scale:this.extra_stroke_scale}),l+=c}},yi.Tuning=xi,yi.Tuplet=Ee,yi.Vibrato=ie,yi.VibratoBracket=ui,yi.Voice=Mt,yi.Volta=ge,yi.BarlineType=ft,yi.ModifierPosition=P;class Ti{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 d("BadArgument","Invalid canvas selector: "+t);const e=document.getElementById(t);if(!e||!e.getContext)throw new d("UnsupportedBrowserError","This browser does not support HTML5 Canvas");return e.getContext("2d")}static benchmark(t,e){const i=(new Date).getTime();e();u(t,(new Date).getTime()-i+"ms")}static stackTrace(){return(new Error).stack}}Ti.Flow=yi;const bi={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"},wi={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"};var vi=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 Ei={Bravura:"./vexflow-font-bravura.js",Gonville:"./vexflow-font-gonville.js",Petaluma:"./vexflow-font-petaluma.js",Custom:"./vexflow-font-custom.js"};yi.fetchMusicFont=(t,e)=>vi(void 0,void 0,void 0,(function*(){const i=k.load(t);if(i.hasData())return;if(!e){if(!(t in Ei))throw new d("UnknownFont",`Music font ${t} does not exist.`);e=Ei[t]}let s;if("string"==typeof e){const i=yield import(e),n=l().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=wi,{fontFamily:e,resolution:i,glyphs:s}=t;k.load(e,t);const n="b";it.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=bi,{fontFamily:e,resolution:i,glyphs:s}=t;k.load(e,t);const n="b";it.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."})}}();const Ci=Ti;return e=e.default})()}));
7
7
  //# sourceMappingURL=vexflow-core.js.map