diff --git a/internal/jazz/lilypond.go b/internal/jazz/lilypond.go index 6fe733e..0f14eaf 100644 --- a/internal/jazz/lilypond.go +++ b/internal/jazz/lilypond.go @@ -3,6 +3,7 @@ package jazz import ( "bytes" "fmt" + "math" "os" "os/exec" "path/filepath" @@ -43,6 +44,11 @@ func lilypondPitch(p Pitch) string { // lilypondDuration converts beat duration into LilyPond duration string (e.g. "1", "2.", "2", "4.", "4", "8"). func lilypondDuration(beats float64) string { switch { + case beats > 4.25: + if math.Abs(beats-float64(int(beats))) < 0.01 { + return fmt.Sprintf("1*%d/4", int(beats)) + } + return fmt.Sprintf("1*%.2g/4", beats) case beats >= 3.75: return "1" case beats >= 2.75: @@ -57,13 +63,31 @@ func lilypondDuration(beats float64) string { return "8." case beats >= 0.4: return "8" + case beats >= 0.2: + return "16" + case beats >= 0.1: + return "32" default: return "16" } } -// lilypondChordName formats a chord into LilyPond chordmode syntax (e.g. ees4:maj7). -func lilypondChordName(c Chord, beats float64) string { +// fullMeasureRest returns a whole-measure rest notation for the given meter (e.g. R1, R1*5/4, R1*3/4). +func fullMeasureRest(timeBeats, timeBeatType int) string { + if timeBeats == 0 { + timeBeats = 4 + } + if timeBeatType == 0 { + timeBeatType = 4 + } + if timeBeats == 4 && timeBeatType == 4 { + return "R1" + } + return fmt.Sprintf("R1*%d/%d", timeBeats, timeBeatType) +} + +// lilypondChordNameWithDuration formats a chord into LilyPond chordmode syntax with an explicit duration string. +func lilypondChordNameWithDuration(c Chord, dur string) string { stepChar := strings.ToLower(string(c.Root.Step)) var acc string switch c.Root.Alter { @@ -76,7 +100,6 @@ func lilypondChordName(c Chord, beats float64) string { case 2: acc = "isis" } - dur := lilypondDuration(beats) qual := "" switch c.Quality { case QualityMajor7: @@ -107,6 +130,101 @@ func lilypondChordName(c Chord, beats float64) string { return stepChar + acc + dur + qual } +// lilypondChordName formats a chord into LilyPond chordmode syntax (e.g. ees4:maj7). +func lilypondChordName(c Chord, beats float64) string { + return lilypondChordNameWithDuration(c, lilypondDuration(beats)) +} + +// lilypondSkip converts beat duration into LilyPond skip syntax (e.g. s1, s2, s4, or s16*N for odd lengths). +func lilypondSkip(beats float64) string { + sixteenths := int(math.Round(beats * 4.0)) + if sixteenths <= 0 { + return "s16" + } + switch sixteenths { + case 16: + return "s1" + case 12: + return "s2." + case 8: + return "s2" + case 6: + return "s4." + case 4: + return "s4" + case 3: + return "s8." + case 2: + return "s8" + case 1: + return "s16" + default: + return fmt.Sprintf("s16*%d", sixteenths) + } +} + +// decomposeDuration breaks a duration in quarter note beats into standard LilyPond duration tokens. +func decomposeDuration(beats float64) []string { + sixteenths := int(math.Round(beats * 4.0)) + var durs []string + for sixteenths > 0 { + switch { + case sixteenths >= 16: + durs = append(durs, "1") + sixteenths -= 16 + case sixteenths >= 12: + durs = append(durs, "2.") + sixteenths -= 12 + case sixteenths >= 8: + durs = append(durs, "2") + sixteenths -= 8 + case sixteenths >= 6: + durs = append(durs, "4.") + sixteenths -= 6 + case sixteenths >= 4: + durs = append(durs, "4") + sixteenths -= 4 + case sixteenths >= 3: + durs = append(durs, "8.") + sixteenths -= 3 + case sixteenths >= 2: + durs = append(durs, "8") + sixteenths -= 2 + default: + durs = append(durs, "16") + sixteenths -= 1 + } + } + if len(durs) == 0 { + return []string{"4"} + } + return durs +} + +// durationToSixteenths converts a LilyPond duration token ("1", "2.", "2", "4.", "4", "8.", "8", "16") to sixteenth units. +func durationToSixteenths(dur string) int { + switch dur { + case "1": + return 16 + case "2.": + return 12 + case "2": + return 8 + case "4.": + return 6 + case "4": + return 4 + case "8.": + return 3 + case "8": + return 2 + case "16": + return 1 + default: + return 1 + } +} + // DetermineBarsPerLine calculates the optimal measures per line to fit the tune on 1 page. func DetermineBarsPerLine(tune *Tune, userBars int) int { if userBars > 0 { @@ -193,6 +311,14 @@ func GenerateLilyPondScoreWithAnnotationConfig(tune *Tune, userBars int, cfg Ann } } + hasMelody := tune.HasMelody() + barsPerLine := DetermineBarsPerLine(tune, userBars) + numSystems := 1 + if barsPerLine > 0 && len(tune.Measures) > 0 { + numSystems = (len(tune.Measures) + barsPerLine - 1) / barsPerLine + } + canFitOnePage := !hasMelody && numSystems <= 7 + var buf bytes.Buffer buf.WriteString("\\version \"2.24.0\"\n\n") @@ -202,11 +328,13 @@ func GenerateLilyPondScoreWithAnnotationConfig(tune *Tune, userBars int, cfg Ann buf.WriteString(" ragged-right = ##f\n") buf.WriteString(" ragged-bottom = ##t\n") buf.WriteString(" ragged-last-bottom = ##t\n") - buf.WriteString(" page-count = #1\n") + if canFitOnePage { + buf.WriteString(" page-count = #1\n") + } buf.WriteString(" system-system-spacing =\n") buf.WriteString(" #'((basic-distance . 16)\n") buf.WriteString(" (minimum-distance . 12)\n") - buf.WriteString(" (padding . 4)\n") + buf.WriteString(" (padding . 5)\n") buf.WriteString(" (stretchability . 10))\n") buf.WriteString("}\n\n") @@ -229,8 +357,6 @@ func GenerateLilyPondScoreWithAnnotationConfig(tune *Tune, userBars int, cfg Ann devices = DetectHarmonicDevices(tune) } - barsPerLine := DetermineBarsPerLine(tune, userBars) - if len(devices) > 0 { buf.WriteString("deviceAnnotations = {\n") buf.WriteString(generateDevicesTrack(tune, devices, barsPerLine)) @@ -256,8 +382,8 @@ func GenerateLilyPondScoreWithAnnotationConfig(tune *Tune, userBars int, cfg Ann if len(m.Chords) == 0 { chordBuf.WriteString(fmt.Sprintf(" r%s |\n", lilypondDuration(beats))) - upperBuf.WriteString(fmt.Sprintf(" R%s |%s\n", lilypondDuration(beats), breakSuffix)) - lowerBuf.WriteString(fmt.Sprintf(" R%s |\n", lilypondDuration(beats))) + upperBuf.WriteString(fmt.Sprintf(" %s |%s\n", fullMeasureRest(m.TimeBeats, m.TimeBeatType), breakSuffix)) + lowerBuf.WriteString(fmt.Sprintf(" %s |\n", fullMeasureRest(m.TimeBeats, m.TimeBeatType))) } else { // Chords cPos := 0.0 @@ -266,16 +392,22 @@ func GenerateLilyPondScoreWithAnnotationConfig(tune *Tune, userBars int, cfg Ann if tc.IsTonalCenterChange && tc.TonalCenterColor != "" { chordBuf.WriteString(fmt.Sprintf("\\override ChordNames.ChordName.color = #%s ", tc.TonalCenterColor)) } - if tc.BeatOffset > cPos { - restBeats := tc.BeatOffset - cPos - chordBuf.WriteString(fmt.Sprintf("r%s ", lilypondDuration(restBeats))) - cPos += restBeats + if tc.BeatOffset > cPos+0.05 { + writeLilyPondRests(&chordBuf, tc.BeatOffset-cPos) + cPos = tc.BeatOffset + } + parts := decomposeDuration(tc.DurationBeats) + for pIdx, d := range parts { + tie := "" + if pIdx < len(parts)-1 { + tie = " ~" + } + chordBuf.WriteString(fmt.Sprintf("%s%s ", lilypondChordNameWithDuration(tc.Chord, d), tie)) } - chordBuf.WriteString(fmt.Sprintf("%s ", lilypondChordName(tc.Chord, tc.DurationBeats))) cPos += tc.DurationBeats } - if cPos < beats { - chordBuf.WriteString(fmt.Sprintf("r%s ", lilypondDuration(beats-cPos))) + if beats-cPos > 0.05 { + writeLilyPondRests(&chordBuf, beats-cPos) } chordBuf.WriteString("|\n") @@ -283,13 +415,11 @@ func GenerateLilyPondScoreWithAnnotationConfig(tune *Tune, userBars int, cfg Ann v1Pos := 0.0 upperBuf.WriteString(" ") for _, tc := range m.Chords { - if tc.BeatOffset > v1Pos { - restBeats := tc.BeatOffset - v1Pos - upperBuf.WriteString(fmt.Sprintf("r%s ", lilypondDuration(restBeats))) - v1Pos += restBeats + if tc.BeatOffset > v1Pos+0.05 { + writeLilyPondRests(&upperBuf, tc.BeatOffset-v1Pos) + v1Pos = tc.BeatOffset } p := tc.GuideTones.Voice1 - dur := tc.DurationBeats colorPrefix := "" if tc.TonalCenterColor != "" { colorPrefix = fmt.Sprintf("\\tweak color #%s ", tc.TonalCenterColor) @@ -298,11 +428,24 @@ func GenerateLilyPondScoreWithAnnotationConfig(tune *Tune, userBars int, cfg Ann if cfg.ShowKeys && tc.IsTonalCenterChange && tc.TonalCenter != "" { markupSuffix = fmt.Sprintf("^\\markup { \\with-color #%s \\rounded-box \\bold \\fontsize #-2 \"%s\" }", tc.TonalCenterColor, tc.TonalCenter) } - upperBuf.WriteString(fmt.Sprintf("%s%s%s%s ", colorPrefix, lilypondPitch(p), lilypondDuration(dur), markupSuffix)) - v1Pos += dur + parts := decomposeDuration(tc.DurationBeats) + for pIdx, d := range parts { + tie := "" + if pIdx < len(parts)-1 { + tie = " ~" + } + cp := "" + ms := "" + if pIdx == 0 { + cp = colorPrefix + ms = markupSuffix + } + upperBuf.WriteString(fmt.Sprintf("%s%s%s%s%s ", cp, lilypondPitch(p), d, tie, ms)) + } + v1Pos += tc.DurationBeats } - if v1Pos < beats { - upperBuf.WriteString(fmt.Sprintf("r%s ", lilypondDuration(beats-v1Pos))) + if beats-v1Pos > 0.05 { + writeLilyPondRests(&upperBuf, beats-v1Pos) } upperBuf.WriteString(fmt.Sprintf("|%s\n", breakSuffix)) @@ -310,22 +453,31 @@ func GenerateLilyPondScoreWithAnnotationConfig(tune *Tune, userBars int, cfg Ann v2Pos := 0.0 lowerBuf.WriteString(" ") for _, tc := range m.Chords { - if tc.BeatOffset > v2Pos { - restBeats := tc.BeatOffset - v2Pos - lowerBuf.WriteString(fmt.Sprintf("r%s ", lilypondDuration(restBeats))) - v2Pos += restBeats + if tc.BeatOffset > v2Pos+0.05 { + writeLilyPondRests(&lowerBuf, tc.BeatOffset-v2Pos) + v2Pos = tc.BeatOffset } p := tc.GuideTones.Voice2 - dur := tc.DurationBeats colorPrefix := "" if tc.TonalCenterColor != "" { colorPrefix = fmt.Sprintf("\\tweak color #%s ", tc.TonalCenterColor) } - lowerBuf.WriteString(fmt.Sprintf("%s%s%s ", colorPrefix, lilypondPitch(p), lilypondDuration(dur))) - v2Pos += dur + parts := decomposeDuration(tc.DurationBeats) + for pIdx, d := range parts { + tie := "" + if pIdx < len(parts)-1 { + tie = " ~" + } + cp := "" + if pIdx == 0 { + cp = colorPrefix + } + lowerBuf.WriteString(fmt.Sprintf("%s%s%s%s ", cp, lilypondPitch(p), d, tie)) + } + v2Pos += tc.DurationBeats } - if v2Pos < beats { - lowerBuf.WriteString(fmt.Sprintf("r%s ", lilypondDuration(beats-v2Pos))) + if beats-v2Pos > 0.05 { + writeLilyPondRests(&lowerBuf, beats-v2Pos) } lowerBuf.WriteString("|\n") } @@ -343,7 +495,6 @@ func GenerateLilyPondScoreWithAnnotationConfig(tune *Tune, userBars int, cfg Ann buf.WriteString(lowerBuf.String()) buf.WriteString("}\n\n") - hasMelody := tune.HasMelody() if hasMelody { buf.WriteString("melodyVoice = {\n") buf.WriteString(generateMelodyTrack(tune, barsPerLine)) @@ -369,28 +520,59 @@ func GenerateLilyPondScoreWithAnnotationConfig(tune *Tune, userBars int, cfg Ann buf.WriteString("\\score {\n") buf.WriteString(" <<\n") if len(devices) > 0 { - buf.WriteString(" \\new Dynamics { \\deviceAnnotations }\n") - } - buf.WriteString(" \\new ChordNames { \\theChords }\n") + buf.WriteString(" \\new Dynamics \\with {\n") + buf.WriteString(" \\override VerticalAxisGroup.nonstaff-relatedstaff-spacing =\n") + buf.WriteString(" #'((basic-distance . 4)\n") + buf.WriteString(" (minimum-distance . 3)\n") + buf.WriteString(" (padding . 1.5))\n") + buf.WriteString(" } { \\deviceAnnotations }\n") + } + buf.WriteString(" \\new ChordNames \\with {\n") + buf.WriteString(" \\override VerticalAxisGroup.nonstaff-relatedstaff-spacing =\n") + buf.WriteString(" #'((basic-distance . 5)\n") + buf.WriteString(" (minimum-distance . 4)\n") + buf.WriteString(" (padding . 2))\n") + buf.WriteString(" } { \\theChords }\n") if hasMelody { - buf.WriteString(" \\new Staff \\with { instrumentName = #\"Melody\" shortInstrumentName = #\"Mel.\" } {\n") + buf.WriteString(" \\new GrandStaff \\with {\n") + buf.WriteString(" \\override StaffGrouper.staff-staff-spacing =\n") + buf.WriteString(" #'((basic-distance . 11)\n") + buf.WriteString(" (minimum-distance . 8)\n") + buf.WriteString(" (padding . 3.5)\n") + buf.WriteString(" (stretchability . 4))\n") + buf.WriteString(" \\override StaffGrouper.staffgroup-staff-spacing =\n") + buf.WriteString(" #'((basic-distance . 15)\n") + buf.WriteString(" (minimum-distance . 11)\n") + buf.WriteString(" (padding . 5)\n") + buf.WriteString(" (stretchability . 8))\n") + buf.WriteString(" } <<\n") + buf.WriteString(" \\new Staff \\with { instrumentName = #\"Melody\" shortInstrumentName = #\"Mel.\" } {\n") + buf.WriteString(" \\clef treble\n") + buf.WriteString(fmt.Sprintf(" \\key %s\n", keyLily)) + buf.WriteString(fmt.Sprintf(" \\time %d/%d\n", timeBeats, timeBeatType)) + buf.WriteString(" \\new Voice { \\melodyVoice }\n") + buf.WriteString(" }\n") + buf.WriteString(" \\new Staff \\with { instrumentName = #\"Guide Tones\" shortInstrumentName = #\"G.T.\" } {\n") + buf.WriteString(" \\clef treble\n") + buf.WriteString(fmt.Sprintf(" \\key %s\n", keyLily)) + buf.WriteString(fmt.Sprintf(" \\time %d/%d\n", timeBeats, timeBeatType)) + buf.WriteString(" <<\n") + buf.WriteString(" \\new Voice { \\voiceOne \\voiceUpper }\n") + buf.WriteString(" \\new Voice { \\voiceTwo \\voiceLower }\n") + buf.WriteString(" >>\n") + buf.WriteString(" }\n") + buf.WriteString(" >>\n") + } else { + buf.WriteString(" \\new Staff {\n") buf.WriteString(" \\clef treble\n") buf.WriteString(fmt.Sprintf(" \\key %s\n", keyLily)) buf.WriteString(fmt.Sprintf(" \\time %d/%d\n", timeBeats, timeBeatType)) - buf.WriteString(" \\new Voice { \\melodyVoice }\n") + buf.WriteString(" <<\n") + buf.WriteString(" \\new Voice { \\voiceOne \\voiceUpper }\n") + buf.WriteString(" \\new Voice { \\voiceTwo \\voiceLower }\n") + buf.WriteString(" >>\n") buf.WriteString(" }\n") - buf.WriteString(" \\new Staff \\with { instrumentName = #\"Guide Tones\" shortInstrumentName = #\"G.T.\" } {\n") - } else { - buf.WriteString(" \\new Staff {\n") } - buf.WriteString(" \\clef treble\n") - buf.WriteString(fmt.Sprintf(" \\key %s\n", keyLily)) - buf.WriteString(fmt.Sprintf(" \\time %d/%d\n", timeBeats, timeBeatType)) - buf.WriteString(" <<\n") - buf.WriteString(" \\new Voice { \\voiceOne \\voiceUpper }\n") - buf.WriteString(" \\new Voice { \\voiceTwo \\voiceLower }\n") - buf.WriteString(" >>\n") - buf.WriteString(" }\n") buf.WriteString(" >>\n") buf.WriteString(" \\layout { }\n") buf.WriteString("}\n") @@ -398,6 +580,39 @@ func GenerateLilyPondScoreWithAnnotationConfig(tune *Tune, userBars int, cfg Ann return buf.String(), nil } +// writeLilyPondRests decomposes a remainder duration (in quarter beats) into standard LilyPond rests. +func writeLilyPondRests(buf *bytes.Buffer, rem float64) { + sixteenths := int(math.Round(rem * 4.0)) + for sixteenths > 0 { + switch { + case sixteenths >= 16: + buf.WriteString("r1 ") + sixteenths -= 16 + case sixteenths >= 12: + buf.WriteString("r2. ") + sixteenths -= 12 + case sixteenths >= 8: + buf.WriteString("r2 ") + sixteenths -= 8 + case sixteenths >= 6: + buf.WriteString("r4. ") + sixteenths -= 6 + case sixteenths >= 4: + buf.WriteString("r4 ") + sixteenths -= 4 + case sixteenths >= 3: + buf.WriteString("r8. ") + sixteenths -= 3 + case sixteenths >= 2: + buf.WriteString("r8 ") + sixteenths -= 2 + default: + buf.WriteString("r16 ") + sixteenths -= 1 + } + } +} + // generateMelodyTrack generates LilyPond notes for the primary lead sheet melody. func generateMelodyTrack(tune *Tune, barsPerLine int) string { var buf bytes.Buffer @@ -413,34 +628,114 @@ func generateMelodyTrack(tune *Tune, barsPerLine int) string { } if len(m.Melody) == 0 { - buf.WriteString(fmt.Sprintf(" R%s |%s\n", lilypondDuration(beats), breakSuffix)) + buf.WriteString(fmt.Sprintf(" %s |%s\n", fullMeasureRest(m.TimeBeats, m.TimeBeatType), breakSuffix)) continue } - buf.WriteString(" ") - consumed := 0.0 + type noteGroup struct { + beatOffset float64 + duration float64 + isRest bool + pitches []Pitch + tie string + } + + var groups []noteGroup for _, mn := range m.Melody { dur := mn.DurationBeats if dur <= 0 { dur = 0.5 } - durStr := lilypondDuration(dur) if mn.IsRest || mn.Pitch == nil { - buf.WriteString(fmt.Sprintf("r%s ", durStr)) + groups = append(groups, noteGroup{ + beatOffset: mn.BeatOffset, + duration: dur, + isRest: true, + }) } else { p := *mn.Pitch p.Octave = mn.Octave - pStr := lilypondPitch(p) - tieSuffix := "" - if mn.Tie == "start" { - tieSuffix = " ~" + // If this note is flagged as a chord or shares the beat offset of the previous note, group together + if len(groups) > 0 && !groups[len(groups)-1].isRest && + (mn.IsChord || math.Abs(mn.BeatOffset-groups[len(groups)-1].beatOffset) < 0.02) { + last := &groups[len(groups)-1] + last.pitches = append(last.pitches, p) + if mn.Tie != "" { + last.tie = mn.Tie + } + if dur > last.duration { + last.duration = dur + } + } else { + groups = append(groups, noteGroup{ + beatOffset: mn.BeatOffset, + duration: dur, + isRest: false, + pitches: []Pitch{p}, + tie: mn.Tie, + }) + } + } + } + + totalMeasureSixteenths := int(math.Round(beats * 4.0)) + consumedSixteenths := 0 + + buf.WriteString(" ") + for _, grp := range groups { + targetOffsetSixteenths := int(math.Round(grp.beatOffset * 4.0)) + if targetOffsetSixteenths > consumedSixteenths { + gapSixteenths := targetOffsetSixteenths - consumedSixteenths + writeLilyPondRests(&buf, float64(gapSixteenths)/4.0) + consumedSixteenths += gapSixteenths + } + + parts := decomposeDuration(grp.duration) + grpSixteenths := 0 + for _, d := range parts { + grpSixteenths += durationToSixteenths(d) + } + if consumedSixteenths+grpSixteenths > totalMeasureSixteenths { + availSixteenths := totalMeasureSixteenths - consumedSixteenths + if availSixteenths <= 0 { + break + } + parts = decomposeDuration(float64(availSixteenths) / 4.0) + } + + if grp.isRest { + for _, d := range parts { + buf.WriteString(fmt.Sprintf("r%s ", d)) + consumedSixteenths += durationToSixteenths(d) + } + } else if len(grp.pitches) == 1 { + for pIdx, d := range parts { + tie := "" + if pIdx < len(parts)-1 || grp.tie == "start" { + tie = " ~" + } + buf.WriteString(fmt.Sprintf("%s%s%s ", lilypondPitch(grp.pitches[0]), d, tie)) + consumedSixteenths += durationToSixteenths(d) + } + } else { + var chordPitches []string + for _, p := range grp.pitches { + chordPitches = append(chordPitches, lilypondPitch(p)) + } + chordStr := fmt.Sprintf("<%s>", strings.Join(chordPitches, " ")) + for pIdx, d := range parts { + tie := "" + if pIdx < len(parts)-1 || grp.tie == "start" { + tie = " ~" + } + buf.WriteString(fmt.Sprintf("%s%s%s ", chordStr, d, tie)) + consumedSixteenths += durationToSixteenths(d) } - buf.WriteString(fmt.Sprintf("%s%s%s ", pStr, durStr, tieSuffix)) } - consumed += dur } - if consumed < beats { - buf.WriteString(fmt.Sprintf("r%s ", lilypondDuration(beats-consumed))) + + if consumedSixteenths < totalMeasureSixteenths { + writeLilyPondRests(&buf, float64(totalMeasureSixteenths-consumedSixteenths)/4.0) } buf.WriteString(fmt.Sprintf("|%s\n", breakSuffix)) } @@ -491,32 +786,32 @@ func generateDevicesTrack(tune *Tune, devices []HarmonicDevice, barsPerLine int) if shouldStop && shouldStart { d := startDevs[0] writeSpannerOverrides(&buf, d) - mult := int(beats*4.0 - 1) + mult := int(math.Round(beats*4.0)) - 1 if mult < 1 { mult = 1 } buf.WriteString(fmt.Sprintf("s16\\stopTextSpan s16*%d\\startTextSpan |%s\n", mult, breakSuffix)) activeSpanner = true } else if shouldStop { - buf.WriteString(fmt.Sprintf("s%s\\stopTextSpan |%s\n", lilypondDuration(beats), breakSuffix)) + buf.WriteString(fmt.Sprintf("%s\\stopTextSpan |%s\n", lilypondSkip(beats), breakSuffix)) activeSpanner = false } else if shouldStart { d := startDevs[0] writeSpannerOverrides(&buf, d) - buf.WriteString(fmt.Sprintf("s%s\\startTextSpan |%s\n", lilypondDuration(beats), breakSuffix)) + buf.WriteString(fmt.Sprintf("%s\\startTextSpan |%s\n", lilypondSkip(beats), breakSuffix)) activeSpanner = true } else { - buf.WriteString(fmt.Sprintf("s%s |%s\n", lilypondDuration(beats), breakSuffix)) + buf.WriteString(fmt.Sprintf("%s |%s\n", lilypondSkip(beats), breakSuffix)) } continue } cPos := 0.0 for _, tc := range m.Chords { - if tc.BeatOffset > cPos { + if tc.BeatOffset > cPos+0.05 { gap := tc.BeatOffset - cPos - buf.WriteString(fmt.Sprintf("s%s ", lilypondDuration(gap))) - cPos += gap + buf.WriteString(fmt.Sprintf("%s ", lilypondSkip(gap))) + cPos = tc.BeatOffset } stopDevs := stopsAt[keyForPos(mIdx, tc.BeatOffset)] @@ -526,50 +821,49 @@ func generateDevicesTrack(tune *Tune, devices []HarmonicDevice, barsPerLine int) shouldStop := activeSpanner && len(stopDevs) > 0 shouldStart := len(startDevs) > 0 + mult := int(math.Round(dur*4.0)) - 1 + if mult < 1 { + mult = 1 + } + if shouldStop && shouldStart { d := startDevs[0] writeSpannerOverrides(&buf, d) - mult := int(dur*4.0 - 1) - if mult < 1 { - mult = 1 - } buf.WriteString(fmt.Sprintf("s16\\stopTextSpan s16*%d\\startTextSpan ", mult)) activeSpanner = true } else if shouldStop { - buf.WriteString(fmt.Sprintf("s%s\\stopTextSpan ", lilypondDuration(dur))) + buf.WriteString(fmt.Sprintf("%s\\stopTextSpan ", lilypondSkip(dur))) activeSpanner = false } else if shouldStart { d := startDevs[0] writeSpannerOverrides(&buf, d) // Check if this same chord also stops the device at its end if len(stopsAt[keyForPos(mIdx, tc.BeatOffset+dur)]) > 0 { - mult := int(dur*4.0 - 1) if mult < 1 { - buf.WriteString(fmt.Sprintf("s%s\\startTextSpan\\stopTextSpan ", lilypondDuration(dur))) + buf.WriteString(fmt.Sprintf("%s\\startTextSpan\\stopTextSpan ", lilypondSkip(dur))) } else { buf.WriteString(fmt.Sprintf("s16*%d\\startTextSpan s16\\stopTextSpan ", mult)) } activeSpanner = false } else { - buf.WriteString(fmt.Sprintf("s%s\\startTextSpan ", lilypondDuration(dur))) + buf.WriteString(fmt.Sprintf("%s\\startTextSpan ", lilypondSkip(dur))) activeSpanner = true } } else if activeSpanner && len(stopsAt[keyForPos(mIdx, tc.BeatOffset+dur)]) > 0 { - mult := int(dur*4.0 - 1) if mult < 1 { - buf.WriteString(fmt.Sprintf("s%s\\stopTextSpan ", lilypondDuration(dur))) + buf.WriteString(fmt.Sprintf("%s\\stopTextSpan ", lilypondSkip(dur))) } else { buf.WriteString(fmt.Sprintf("s16*%d s16\\stopTextSpan ", mult)) } activeSpanner = false } else { - buf.WriteString(fmt.Sprintf("s%s ", lilypondDuration(dur))) + buf.WriteString(fmt.Sprintf("%s ", lilypondSkip(dur))) } cPos += dur } - if cPos < beats { - buf.WriteString(fmt.Sprintf("s%s ", lilypondDuration(beats-cPos))) + if beats-cPos > 0.05 { + buf.WriteString(fmt.Sprintf("%s ", lilypondSkip(beats-cPos))) } buf.WriteString(fmt.Sprintf("|%s\n", breakSuffix)) } diff --git a/internal/jazz/musicxml_read.go b/internal/jazz/musicxml_read.go index 9bfff1c..3410835 100644 --- a/internal/jazz/musicxml_read.go +++ b/internal/jazz/musicxml_read.go @@ -5,6 +5,7 @@ import ( "fmt" "io" "os" + "sort" "strconv" "strings" "unicode/utf8" @@ -421,6 +422,21 @@ func ParseMusicXML(r io.Reader) (*Tune, error) { numHarmonies := len(harmonyEvents) if numHarmonies > 0 { + sort.SliceStable(harmonyEvents, func(i, j int) bool { + return harmonyEvents[i].division < harmonyEvents[j].division + }) + + // Deduplicate harmonies that fall on the exact same division + var deduped []harmonyAt + for _, h := range harmonyEvents { + if len(deduped) > 0 && deduped[len(deduped)-1].division == h.division { + continue + } + deduped = append(deduped, h) + } + harmonyEvents = deduped + numHarmonies = len(harmonyEvents) + hasNoteTiming := maxCursor > 0 && divisions > 0 for i, h := range harmonyEvents { diff --git a/internal/server/api.go b/internal/server/api.go index 77bc0f4..09bb734 100644 --- a/internal/server/api.go +++ b/internal/server/api.go @@ -193,15 +193,22 @@ func (s *Server) handleAnalyze(w http.ResponseWriter, r *http.Request) { // Run tonal center analysis and device detection jazz.AnalyzeTonalCenters(tune) devices := jazz.DetectHarmonicDevices(tune) + if devices == nil { + devices = []jazz.HarmonicDevice{} + } journeySpans := jazz.GetHarmonicJourneySpans(tune) + if journeySpans == nil { + journeySpans = []jazz.JourneySpan{} + } journeyStr := jazz.HarmonicJourney(tune) - var measuresDTO []MeasureDTO + measuresDTO := make([]MeasureDTO, 0, len(tune.Measures)) pairIdx := 0 for _, m := range tune.Measures { mDTO := MeasureDTO{ Number: m.Number, + Chords: make([]ChordDTO, 0, len(m.Chords)), } for _, tc := range m.Chords { var p jazz.GuideTonePair diff --git a/internal/server/server_test.go b/internal/server/server_test.go index 1313b81..47d16dc 100644 --- a/internal/server/server_test.go +++ b/internal/server/server_test.go @@ -157,4 +157,18 @@ func TestAnalyzeEndpoint_StandardAutumnLeaves(t *testing.T) { if len(resp.Measures) == 0 { t.Errorf("expected measures in Autumn Leaves, got 0") } + + rawJSON := rec.Body.String() + if strings.Contains(rawJSON, `"chords":null`) { + t.Errorf("expected non-null chords in JSON, but found '\"chords\":null'") + } + if resp.Measures[0].Chords == nil { + t.Errorf("expected Measure[0].Chords to be non-nil empty slice, got nil") + } + if resp.Devices == nil { + t.Errorf("expected Devices to be non-nil slice, got nil") + } + if resp.JourneySpans == nil { + t.Errorf("expected JourneySpans to be non-nil slice, got nil") + } } diff --git a/web/dist/assets/index-BU2UpVYr.js b/web/dist/assets/index-BEh0cyCH.js similarity index 83% rename from web/dist/assets/index-BU2UpVYr.js rename to web/dist/assets/index-BEh0cyCH.js index 3d2013a..a6adea5 100644 --- a/web/dist/assets/index-BU2UpVYr.js +++ b/web/dist/assets/index-BEh0cyCH.js @@ -1,4 +1,4 @@ -(function(){const Jt=document.createElement("link").relList;if(Jt&&Jt.supports&&Jt.supports("modulepreload"))return;for(const le of document.querySelectorAll('link[rel="modulepreload"]'))Lt(le);new MutationObserver(le=>{for(const St of le)if(St.type==="childList")for(const y of St.addedNodes)y.tagName==="LINK"&&y.rel==="modulepreload"&&Lt(y)}).observe(document,{childList:!0,subtree:!0});function se(le){const St={};return le.integrity&&(St.integrity=le.integrity),le.referrerPolicy&&(St.referrerPolicy=le.referrerPolicy),le.crossOrigin==="use-credentials"?St.credentials="include":le.crossOrigin==="anonymous"?St.credentials="omit":St.credentials="same-origin",St}function Lt(le){if(le.ep)return;le.ep=!0;const St=se(le);fetch(le.href,St)}})();function k1(Wt){return Wt&&Wt.__esModule&&Object.prototype.hasOwnProperty.call(Wt,"default")?Wt.default:Wt}var ph={exports:{}},_a={};/** +(function(){const te=document.createElement("link").relList;if(te&&te.supports&&te.supports("modulepreload"))return;for(const ae of document.querySelectorAll('link[rel="modulepreload"]'))Lt(ae);new MutationObserver(ae=>{for(const St of ae)if(St.type==="childList")for(const y of St.addedNodes)y.tagName==="LINK"&&y.rel==="modulepreload"&&Lt(y)}).observe(document,{childList:!0,subtree:!0});function re(ae){const St={};return ae.integrity&&(St.integrity=ae.integrity),ae.referrerPolicy&&(St.referrerPolicy=ae.referrerPolicy),ae.crossOrigin==="use-credentials"?St.credentials="include":ae.crossOrigin==="anonymous"?St.credentials="omit":St.credentials="same-origin",St}function Lt(ae){if(ae.ep)return;ae.ep=!0;const St=re(ae);fetch(ae.href,St)}})();function k1(Ht){return Ht&&Ht.__esModule&&Object.prototype.hasOwnProperty.call(Ht,"default")?Ht.default:Ht}var ph={exports:{}},wo={};/** * @license React * react-jsx-runtime.production.js * @@ -6,7 +6,7 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var M1;function M2(){if(M1)return _a;M1=1;var Wt=Symbol.for("react.transitional.element"),Jt=Symbol.for("react.fragment");function se(Lt,le,St){var y=null;if(St!==void 0&&(y=""+St),le.key!==void 0&&(y=""+le.key),"key"in le){St={};for(var p in le)p!=="key"&&(St[p]=le[p])}else St=le;return le=St.ref,{$$typeof:Wt,type:Lt,key:y,ref:le!==void 0?le:null,props:St}}return _a.Fragment=Jt,_a.jsx=se,_a.jsxs=se,_a}var T1;function T2(){return T1||(T1=1,ph.exports=M2()),ph.exports}var Gt=T2(),gh={exports:{}},fe={};/** + */var M1;function M2(){if(M1)return wo;M1=1;var Ht=Symbol.for("react.transitional.element"),te=Symbol.for("react.fragment");function re(Lt,ae,St){var y=null;if(St!==void 0&&(y=""+St),ae.key!==void 0&&(y=""+ae.key),"key"in ae){St={};for(var p in ae)p!=="key"&&(St[p]=ae[p])}else St=ae;return ae=St.ref,{$$typeof:Ht,type:Lt,key:y,ref:ae!==void 0?ae:null,props:St}}return wo.Fragment=te,wo.jsx=re,wo.jsxs=re,wo}var T1;function T2(){return T1||(T1=1,ph.exports=M2()),ph.exports}var Gt=T2(),gh={exports:{}},fe={};/** * @license React * react.production.js * @@ -14,7 +14,7 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var _1;function _2(){if(_1)return fe;_1=1;var Wt=Symbol.for("react.transitional.element"),Jt=Symbol.for("react.portal"),se=Symbol.for("react.fragment"),Lt=Symbol.for("react.strict_mode"),le=Symbol.for("react.profiler"),St=Symbol.for("react.consumer"),y=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),l=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),a=Symbol.for("react.activity"),s=Symbol.for("react.view_transition"),h=Symbol.iterator;function u(H){return H===null||typeof H!="object"?null:(H=h&&H[h]||H["@@iterator"],typeof H=="function"?H:null)}var f={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},r=Object.assign,b={};function S(H,rt,ct){this.props=H,this.context=rt,this.refs=b,this.updater=ct||f}S.prototype.isReactComponent={},S.prototype.setState=function(H,rt){if(typeof H!="object"&&typeof H!="function"&&H!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,H,rt,"setState")},S.prototype.forceUpdate=function(H){this.updater.enqueueForceUpdate(this,H,"forceUpdate")};function v(){}v.prototype=S.prototype;function w(H,rt,ct){this.props=H,this.context=rt,this.refs=b,this.updater=ct||f}var T=w.prototype=new v;T.constructor=w,r(T,S.prototype),T.isPureReactComponent=!0;var g=Array.isArray;function x(){}var P={H:null,A:null,T:null,S:null},_=Object.prototype.hasOwnProperty;function B(H,rt,ct){var st=ct.ref;return{$$typeof:Wt,type:H,key:rt,ref:st!==void 0?st:null,props:ct}}function k(H,rt){return B(H.type,rt,H.props)}function R(H){return typeof H=="object"&&H!==null&&H.$$typeof===Wt}function F(H){var rt={"=":"=0",":":"=2"};return"$"+H.replace(/[=:]/g,function(ct){return rt[ct]})}var A=/\/+/g;function G(H,rt){return typeof H=="object"&&H!==null&&H.key!=null?F(""+H.key):rt.toString(36)}function U(H){switch(H.status){case"fulfilled":return H.value;case"rejected":throw H.reason;default:switch(typeof H.status=="string"?H.then(x,x):(H.status="pending",H.then(function(rt){H.status==="pending"&&(H.status="fulfilled",H.value=rt)},function(rt){H.status==="pending"&&(H.status="rejected",H.reason=rt)})),H.status){case"fulfilled":return H.value;case"rejected":throw H.reason}}throw H}function C(H,rt,ct,st,at){var ht=typeof H;(ht==="undefined"||ht==="boolean")&&(H=null);var lt=!1;if(H===null)lt=!0;else switch(ht){case"bigint":case"string":case"number":lt=!0;break;case"object":switch(H.$$typeof){case Wt:case Jt:lt=!0;break;case m:return lt=H._init,C(lt(H._payload),rt,ct,st,at)}}if(lt)return at=at(H),lt=st===""?"."+G(H,0):st,g(at)?(ct="",lt!=null&&(ct=lt.replace(A,"$&/")+"/"),C(at,rt,ct,"",function(j){return j})):at!=null&&(R(at)&&(at=k(at,ct+(at.key==null||H&&H.key===at.key?"":(""+at.key).replace(A,"$&/")+"/")+lt)),rt.push(at)),1;lt=0;var O=st===""?".":st+":";if(g(H))for(var D=0;D>>1,$=U[W];if(0>>1;Wle(tt,z))H<$&&0>le(rt,tt)?(U[W]=rt,U[H]=z,W=H):(U[W]=tt,U[Y]=z,W=Y);else if(H<$&&0>le(rt,z))U[W]=rt,U[H]=z,W=H;else break t}}return C}function le(U,C){var z=U.sortIndex-C.sortIndex;return z!==0?z:U.id-C.id}if(Wt.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var St=performance;Wt.unstable_now=function(){return St.now()}}else{var y=Date,p=y.now();Wt.unstable_now=function(){return y.now()-p}}var d=[],l=[],m=1,a=null,s=3,h=!1,u=!1,f=!1,r=!1,b=typeof setTimeout=="function"?setTimeout:null,S=typeof clearTimeout=="function"?clearTimeout:null,v=typeof setImmediate<"u"?setImmediate:null;function w(U){for(var C=se(l);C!==null;){if(C.callback===null)Lt(l);else if(C.startTime<=U)Lt(l),C.sortIndex=C.expirationTime,Jt(d,C);else break;C=se(l)}}function T(U){if(f=!1,w(U),!u)if(se(d)!==null)u=!0,g||(g=!0,R());else{var C=se(l);C!==null&&G(T,C.startTime-U)}}var g=!1,x=-1,P=5,_=-1;function B(){return r?!0:!(Wt.unstable_now()-_U&&B());){var W=a.callback;if(typeof W=="function"){a.callback=null,s=a.priorityLevel;var $=W(a.expirationTime<=U);if(U=Wt.unstable_now(),typeof $=="function"){a.callback=$,w(U),C=!0;break e}a===se(d)&&Lt(d),w(U)}else Lt(d);a=se(d)}if(a!==null)C=!0;else{var N=se(l);N!==null&&G(T,N.startTime-U),C=!1}}break t}finally{a=null,s=z,h=!1}C=void 0}}finally{C?R():g=!1}}}var R;if(typeof v=="function")R=function(){v(k)};else if(typeof MessageChannel<"u"){var F=new MessageChannel,A=F.port2;F.port1.onmessage=k,R=function(){A.postMessage(null)}}else R=function(){b(k,0)};function G(U,C){x=b(function(){U(Wt.unstable_now())},C)}Wt.unstable_IdlePriority=5,Wt.unstable_ImmediatePriority=1,Wt.unstable_LowPriority=4,Wt.unstable_NormalPriority=3,Wt.unstable_Profiling=null,Wt.unstable_UserBlockingPriority=2,Wt.unstable_cancelCallback=function(U){U.callback=null},Wt.unstable_forceFrameRate=function(U){0>U||125W?(U.sortIndex=z,Jt(l,U),se(d)===null&&U===se(l)&&(f?(S(x),x=-1):f=!0,G(T,z-W))):(U.sortIndex=$,Jt(d,U),u||h||(u=!0,g||(g=!0,R()))),U},Wt.unstable_shouldYield=B,Wt.unstable_wrapCallback=function(U){var C=s;return function(){var z=s;s=C;try{return U.apply(this,arguments)}finally{s=z}}}})(yh)),yh}var A1;function L2(){return A1||(A1=1,Sh.exports=w2()),Sh.exports}var vh={exports:{}},Si={};/** + */var L1;function w2(){return L1||(L1=1,(function(Ht){function te(U,C){var z=U.length;U.push(C);t:for(;0>>1,$=U[W];if(0>>1;Wae(tt,z))H<$&&0>ae(rt,tt)?(U[W]=rt,U[H]=z,W=H):(U[W]=tt,U[Y]=z,W=Y);else if(H<$&&0>ae(rt,z))U[W]=rt,U[H]=z,W=H;else break t}}return C}function ae(U,C){var z=U.sortIndex-C.sortIndex;return z!==0?z:U.id-C.id}if(Ht.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var St=performance;Ht.unstable_now=function(){return St.now()}}else{var y=Date,p=y.now();Ht.unstable_now=function(){return y.now()-p}}var d=[],l=[],m=1,o=null,s=3,h=!1,u=!1,f=!1,r=!1,b=typeof setTimeout=="function"?setTimeout:null,S=typeof clearTimeout=="function"?clearTimeout:null,v=typeof setImmediate<"u"?setImmediate:null;function w(U){for(var C=re(l);C!==null;){if(C.callback===null)Lt(l);else if(C.startTime<=U)Lt(l),C.sortIndex=C.expirationTime,te(d,C);else break;C=re(l)}}function T(U){if(f=!1,w(U),!u)if(re(d)!==null)u=!0,g||(g=!0,R());else{var C=re(l);C!==null&&G(T,C.startTime-U)}}var g=!1,x=-1,P=5,_=-1;function B(){return r?!0:!(Ht.unstable_now()-_U&&B());){var W=o.callback;if(typeof W=="function"){o.callback=null,s=o.priorityLevel;var $=W(o.expirationTime<=U);if(U=Ht.unstable_now(),typeof $=="function"){o.callback=$,w(U),C=!0;break e}o===re(d)&&Lt(d),w(U)}else Lt(d);o=re(d)}if(o!==null)C=!0;else{var N=re(l);N!==null&&G(T,N.startTime-U),C=!1}}break t}finally{o=null,s=z,h=!1}C=void 0}}finally{C?R():g=!1}}}var R;if(typeof v=="function")R=function(){v(k)};else if(typeof MessageChannel<"u"){var F=new MessageChannel,A=F.port2;F.port1.onmessage=k,R=function(){A.postMessage(null)}}else R=function(){b(k,0)};function G(U,C){x=b(function(){U(Ht.unstable_now())},C)}Ht.unstable_IdlePriority=5,Ht.unstable_ImmediatePriority=1,Ht.unstable_LowPriority=4,Ht.unstable_NormalPriority=3,Ht.unstable_Profiling=null,Ht.unstable_UserBlockingPriority=2,Ht.unstable_cancelCallback=function(U){U.callback=null},Ht.unstable_forceFrameRate=function(U){0>U||125W?(U.sortIndex=z,te(l,U),re(d)===null&&U===re(l)&&(f?(S(x),x=-1):f=!0,G(T,z-W))):(U.sortIndex=$,te(d,U),u||h||(u=!0,g||(g=!0,R()))),U},Ht.unstable_shouldYield=B,Ht.unstable_wrapCallback=function(U){var C=s;return function(){var z=s;s=C;try{return U.apply(this,arguments)}finally{s=z}}}})(yh)),yh}var A1;function L2(){return A1||(A1=1,Sh.exports=w2()),Sh.exports}var vh={exports:{}},Si={};/** * @license React * react-dom.production.js * @@ -30,7 +30,7 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var P1;function A2(){if(P1)return Si;P1=1;var Wt=Th();function Jt(m){var a="https://react.dev/errors/"+m;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Wt)}catch(Jt){console.error(Jt)}}return Wt(),vh.exports=A2(),vh.exports}/** + */var P1;function A2(){if(P1)return Si;P1=1;var Ht=Th();function te(m){var o="https://react.dev/errors/"+m;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Ht)}catch(te){console.error(te)}}return Ht(),vh.exports=A2(),vh.exports}/** * @license React * react-dom-client.production.js * @@ -38,32 +38,32 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var R1;function C2(){if(R1)return wa;R1=1;var Wt=L2(),Jt=Th(),se=P2();function Lt(t){var e="https://react.dev/errors/"+t;if(1J||(t.current=Q[J],Q[J]=null,J--)}function it(t,e){J++,Q[J]=t.current,t.current=e}var dt=q(null),mt=q(null),yt=q(null),Et=q(null);function Dt(t,e){switch(it(yt,e),it(mt,t),it(dt,null),e.nodeType){case 9:case 11:t=(t=e.documentElement)&&(t=t.namespaceURI)?Nf(t):0;break;default:if(t=e.tagName,e=e.namespaceURI)e=Nf(e),t=If(e,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}et(dt),it(dt,t)}function Vt(){et(dt),et(mt),et(yt)}function Nt(t){var e=t.memoizedState;e!==null&&(Nr._currentValue=e.memoizedState,it(Et,t)),e=dt.current;var n=If(e,t.type);e!==n&&(it(mt,t),it(dt,n))}function It(t){mt.current===t&&(et(dt),et(mt)),Et.current===t&&(et(Et),Nr._currentValue=j)}var Ct,zt;function Xt(t){if(Ct===void 0)try{throw Error()}catch(n){var e=n.stack.trim().match(/\n( *(at )?)/);Ct=e&&e[1]||"",zt=-1J||(t.current=Q[J],Q[J]=null,J--)}function it(t,e){J++,Q[J]=t.current,t.current=e}var dt=q(null),mt=q(null),yt=q(null),Et=q(null);function Dt(t,e){switch(it(yt,e),it(mt,t),it(dt,null),e.nodeType){case 9:case 11:t=(t=e.documentElement)&&(t=t.namespaceURI)?Nf(t):0;break;default:if(t=e.tagName,e=e.namespaceURI)e=Nf(e),t=If(e,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}et(dt),it(dt,t)}function Vt(){et(dt),et(mt),et(yt)}function Nt(t){var e=t.memoizedState;e!==null&&(Nr._currentValue=e.memoizedState,it(Et,t)),e=dt.current;var n=If(e,t.type);e!==n&&(it(mt,t),it(dt,n))}function It(t){mt.current===t&&(et(dt),et(mt)),Et.current===t&&(et(Et),Nr._currentValue=j)}var Ct,zt;function Xt(t){if(Ct===void 0)try{throw Error()}catch(n){var e=n.stack.trim().match(/\n( *(at )?)/);Ct=e&&e[1]||"",zt=-1)":-1E||xt[o]!==Rt[E]){var kt=` -`+xt[o].replace(" at new "," at ");return t.displayName&&kt.includes("")&&(kt=kt.replace("",t.displayName)),kt}while(1<=o&&0<=E);break}}}finally{Ut=!1,Error.prepareStackTrace=n}return(n=t?t.displayName||t.name:"")?Xt(n):""}function qt(t,e){switch(t.tag){case 26:case 27:case 5:return Xt(t.type);case 16:return Xt("Lazy");case 13:return t.child!==e&&e!==null?Xt("Suspense Fallback"):Xt("Suspense");case 19:return Xt("SuspenseList");case 0:case 15:return Kt(t.type,!1);case 11:return Kt(t.type.render,!1);case 1:return Kt(t.type,!0);case 31:return Xt("Activity");case 30:return Xt("ViewTransition");default:return""}}function Qt(t){try{var e="",n=null;do e+=qt(t,n),n=t,t=t.return;while(t);return e}catch(o){return` -Error generating stack: `+o.message+` -`+o.stack}}var te=Object.prototype.hasOwnProperty,ie=Wt.unstable_scheduleCallback,$t=Wt.unstable_cancelCallback,ae=Wt.unstable_shouldYield,Ke=Wt.unstable_requestPaint,De=Wt.unstable_now,Xe=Wt.unstable_getCurrentPriorityLevel,Pi=Wt.unstable_ImmediatePriority,oi=Wt.unstable_UserBlockingPriority,we=Wt.unstable_NormalPriority,Ge=Wt.unstable_LowPriority,xi=Wt.unstable_IdlePriority,Ce=Wt.log,Re=Wt.unstable_setDisableYieldValue,He=null,Te=null;function Ye(t){if(typeof Ce=="function"&&Re(t),Te&&typeof Te.setStrictMode=="function")try{Te.setStrictMode(He,t)}catch{}}var ci=Math.clz32?Math.clz32:_s,Ts=Math.log,nn=Math.LN2;function _s(t){return t>>>=0,t===0?32:31-(Ts(t)/nn|0)|0}var ws=256,Mi=262144,Yi=4194304;function sn(t){var e=t&42;if(e!==0)return e;switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return t&-t;case 262144:case 524288:case 1048576:case 2097152:return t&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return t&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return t}}function Ln(t,e,n){var o=t.pendingLanes;if(o===0)return 0;var E=0,L=t.suspendedLanes,K=t.pingedLanes;t=t.warmLanes;var ut=o&134217727;return ut!==0?(o=ut&~L,o!==0?E=sn(o):(K&=ut,K!==0?E=sn(K):n||(n=ut&~t,n!==0&&(E=sn(n))))):(ut=o&~L,ut!==0?E=sn(ut):K!==0?E=sn(K):n||(n=o&~t,n!==0&&(E=sn(n)))),E===0?0:e!==0&&e!==E&&(e&L)===0&&(L=E&-E,n=e&-e,L>=n||L===32&&(n&4194048)!==0)?e:E}function rn(t,e){return(t.pendingLanes&~(t.suspendedLanes&~t.pingedLanes)&e)===0}function Ci(t,e){(e&8)!==0&&(e|=e&32);var n=t.entangledLanes;if(n!==0)for(t=t.entanglements,n&=e;0n;n++)e.push(t);return e}function yi(t,e){t.pendingLanes|=e,e!==268435456&&(t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0)}function Or(t,e,n,o,E,L){var K=t.pendingLanes;t.pendingLanes=n,t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0,t.expiredLanes&=n,t.entangledLanes&=n,t.errorRecoveryDisabledLanes&=n,t.shellSuspendCounter=0;var ut=t.entanglements,xt=t.expirationTimes,Rt=t.hiddenUpdates;for(n=K&~n;0"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Jo=!1;if(Rn)try{var kr={};Object.defineProperty(kr,"passive",{get:function(){Jo=!0}}),window.addEventListener("test",kr,kr),window.removeEventListener("test",kr,kr)}catch{Jo=!1}var Zn=null,$o=null,Ca=null;function Lh(){if(Ca)return Ca;var t,e=$o,n=e.length,o,E="value"in Zn?Zn.value:Zn.textContent,L=E.length;for(t=0;t=zr),Ih=" ",Bh=!1;function Oh(t,e){switch(t){case"keyup":return vm.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Dh(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var tr=!1;function xm(t,e){switch(t){case"compositionend":return Dh(e);case"keypress":return e.which!==32?null:(Bh=!0,Ih);case"textInput":return t=e.data,t===Ih&&Bh?null:t;default:return null}}function Mm(t,e){if(tr)return t==="compositionend"||!sl&&Oh(t,e)?(t=Lh(),Ca=$o=Zn=null,tr=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function Wh(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function jh(t,e){var n=Wh(t);t=0;for(var o;n;){if(n.nodeType===3){if(o=t+n.textContent.length,t<=e&&o>=e)return{node:n,offset:e-t};t=o}t:{for(;n;){if(n.nextSibling){n=n.nextSibling;break t}n=n.parentNode}n=void 0}n=Wh(n)}}function Xh(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?Xh(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function Yh(t){t=t!=null&&t.ownerDocument!=null&&t.ownerDocument.defaultView!=null?t.ownerDocument.defaultView:window;for(var e=ol(t.document);e instanceof t.HTMLIFrameElement;){try{var n=typeof e.contentWindow.location.href=="string"}catch{n=!1}if(n)t=e.contentWindow;else break;e=ol(t.document)}return e}function ll(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}var Rm=Rn&&"documentMode"in document&&11>=document.documentMode,er=null,ul=null,jr=null,hl=!1;function qh(t,e,n){var o=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;hl||er==null||er!==ol(o)||(o=er,"selectionStart"in o&&ll(o)?o={start:o.selectionStart,end:o.selectionEnd}:(o=(o.ownerDocument&&o.ownerDocument.defaultView||window).getSelection(),o={anchorNode:o.anchorNode,anchorOffset:o.anchorOffset,focusNode:o.focusNode,focusOffset:o.focusOffset}),jr&&Wr(jr,o)||(jr=o,o=Do(ul,"onSelect"),0>=K,E-=K,bn=1<<32-ci(e)+E|n<de?(si=ce,ce=null):si=ce.sibling;var _e=At(Pt,ce,Bt[de],Ht);if(_e===null){ce===null&&(ce=si);break}t&&ce&&_e.alternate===null&&e(Pt,ce),wt=L(_e,wt,de),Me===null?oe=_e:Me.sibling=_e,Me=_e,ce=si}if(de===Bt.length)return n(Pt,ce),Se&&On(Pt,de),oe;if(ce===null){for(;dede?(si=ce,ce=null):si=ce.sibling;var xs=At(Pt,ce,_e.value,Ht);if(xs===null){ce===null&&(ce=si);break}t&&ce&&xs.alternate===null&&e(Pt,ce),wt=L(xs,wt,de),Me===null?oe=xs:Me.sibling=xs,Me=xs,ce=si}if(_e.done)return n(Pt,ce),Se&&On(Pt,de),oe;if(ce===null){for(;!_e.done;de++,_e=Bt.next())_e=jt(Pt,_e.value,Ht),_e!==null&&(wt=L(_e,wt,de),Me===null?oe=_e:Me.sibling=_e,Me=_e);return Se&&On(Pt,de),oe}for(ce=o(ce);!_e.done;de++,_e=Bt.next())_e=Ot(ce,Pt,de,_e.value,Ht),_e!==null&&(t&&(si=_e.alternate,si!==null&&ce.delete(si.key===null?de:si.key)),wt=L(_e,wt,de),Me===null?oe=_e:Me.sibling=_e,Me=_e);return t&&ce.forEach(function(x2){return e(Pt,x2)}),Se&&On(Pt,de),oe}function ge(Pt,wt,Bt,Ht){if(typeof Bt=="object"&&Bt!==null&&Bt.type===k&&Bt.key===null&&Bt.props.ref===void 0&&(Bt=Bt.props.children),typeof Bt=="object"&&Bt!==null){switch(Bt.$$typeof){case _:t:{for(var oe=Bt.key;wt!==null;){if(wt.key===oe){if(oe=Bt.type,oe===k){if(wt.tag===7){n(Pt,wt.sibling),Ht=E(wt,Bt.props.children),ns(Ht,Bt),Ht.return=Pt,Pt=Ht;break t}}else if(wt.elementType===oe||typeof oe=="object"&&oe!==null&&oe.$$typeof===$&&ks(oe)===wt.type){n(Pt,wt.sibling),Ht=E(wt,Bt.props),ns(Ht,Bt),Ht.return=Pt,Pt=Ht;break t}n(Pt,wt);break}else e(Pt,wt);wt=wt.sibling}Bt.type===k?(Ht=Rs(Bt.props.children,Pt.mode,Ht,Bt.key),ns(Ht,Bt),Ht.return=Pt,Pt=Ht):(Ht=Ga(Bt.type,Bt.key,Bt.props,null,Pt.mode,Ht),ns(Ht,Bt),Ht.return=Pt,Pt=Ht)}return K(Pt);case B:t:{for(oe=Bt.key;wt!==null;){if(wt.key===oe)if(wt.tag===4&&wt.stateNode.containerInfo===Bt.containerInfo&&wt.stateNode.implementation===Bt.implementation){n(Pt,wt.sibling),Ht=E(wt,Bt.children||[]),Ht.return=Pt,Pt=Ht;break t}else{n(Pt,wt);break}else e(Pt,wt);wt=wt.sibling}Ht=bl(Bt,Pt.mode,Ht),Ht.return=Pt,Pt=Ht}return K(Pt);case $:return Bt=ks(Bt),ge(Pt,wt,Bt,Ht)}if(lt(Bt))return re(Pt,wt,Bt,Ht);if(st(Bt)){if(oe=st(Bt),typeof oe!="function")throw Error(Lt(150));return Bt=oe.call(Bt),ue(Pt,wt,Bt,Ht)}if(typeof Bt.then=="function")return ge(Pt,wt,Qa(Bt),Ht);if(Bt.$$typeof===G)return ge(Pt,wt,Xa(Pt,Bt),Ht);Za(Pt,Bt)}return typeof Bt=="string"&&Bt!==""||typeof Bt=="number"||typeof Bt=="bigint"?(Bt=""+Bt,wt!==null&&wt.tag===6?(n(Pt,wt.sibling),Ht=E(wt,Bt),Ht.return=Pt,Pt=Ht):(n(Pt,wt),Ht=gl(Bt,Pt.mode,Ht),Ht.return=Pt,Pt=Ht),K(Pt)):n(Pt,wt)}return function(Pt,wt,Bt,Ht){try{Zr=0;var oe=ge(Pt,wt,Bt,Ht);return hr=null,oe}catch(ce){if(ce===ur||ce===qa)throw ce;var Me=Ni(29,ce,null,Pt.mode);return Me.lanes=Ht,Me.return=Pt,Me}finally{}}}var Gs=Sc(!0),yc=Sc(!1),ss=!1;function Ll(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Al(t,e){t=t.updateQueue,e.updateQueue===t&&(e.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,callbacks:null})}function rs(t){return{lane:t,tag:0,payload:null,callback:null,next:null}}function as(t,e,n){var o=t.updateQueue;if(o===null)return null;if(o=o.shared,(Ae&2)!==0){var E=o.pending;return E===null?e.next=e:(e.next=E.next,E.next=e),o.pending=e,e=Va(t),ic(t,null,n),e}return ka(t,o,e,n),Va(t)}function Jr(t,e,n){if(e=e.updateQueue,e!==null&&(e=e.shared,(n&4194048)!==0)){var o=e.lanes;o&=t.pendingLanes,n|=o,e.lanes=n,di(t,n)}}function Pl(t,e){var n=t.updateQueue,o=t.alternate;if(o!==null&&(o=o.updateQueue,n===o)){var E=null,L=null;if(n=n.firstBaseUpdate,n!==null){do{var K={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};L===null?E=L=K:L=L.next=K,n=n.next}while(n!==null);L===null?E=L=e:L=L.next=e}else E=L=e;n={baseState:o.baseState,firstBaseUpdate:E,lastBaseUpdate:L,shared:o.shared,callbacks:o.callbacks},t.updateQueue=n;return}t=n.lastBaseUpdate,t===null?n.firstBaseUpdate=e:t.next=e,n.lastBaseUpdate=e}var Cl=!1;function $r(){if(Cl){var t=lr;if(t!==null)throw t}}function ta(t,e,n,o){Cl=!1;var E=t.updateQueue;ss=!1;var L=E.firstBaseUpdate,K=E.lastBaseUpdate,ut=E.shared.pending;if(ut!==null){E.shared.pending=null;var xt=ut,Rt=xt.next;xt.next=null,K===null?L=Rt:K.next=Rt,K=xt;var kt=t.alternate;kt!==null&&(kt=kt.updateQueue,ut=kt.lastBaseUpdate,ut!==K&&(ut===null?kt.firstBaseUpdate=Rt:ut.next=Rt,kt.lastBaseUpdate=xt))}if(L!==null){var jt=E.baseState;K=0,kt=Rt=xt=null,ut=L;do{var At=ut.lane&-536870913,Ot=At!==ut.lane;if(Ot?(xe&At)===At:(o&At)===At){At!==0&&At===Ds&&(Cl=!0),kt!==null&&(kt=kt.next={lane:0,tag:ut.tag,payload:ut.payload,callback:null,next:null});t:{var re=t,ue=ut;At=e;var ge=n;switch(ue.tag){case 1:if(re=ue.payload,typeof re=="function"){jt=re.call(ge,jt,At);break t}jt=re;break t;case 3:re.flags=re.flags&-65537|128;case 0:if(re=ue.payload,At=typeof re=="function"?re.call(ge,jt,At):re,At==null)break t;jt=x({},jt,At);break t;case 2:ss=!0}}At=ut.callback,At!==null&&(t.flags|=64,Ot&&(t.flags|=8192),Ot=E.callbacks,Ot===null?E.callbacks=[At]:Ot.push(At))}else Ot={lane:At,tag:ut.tag,payload:ut.payload,callback:ut.callback,next:null},kt===null?(Rt=kt=Ot,xt=jt):kt=kt.next=Ot,K|=At;if(ut=ut.next,ut===null){if(ut=E.shared.pending,ut===null)break;Ot=ut,ut=Ot.next,Ot.next=null,E.lastBaseUpdate=Ot,E.shared.pending=null}}while(!0);kt===null&&(xt=jt),E.baseState=xt,E.firstBaseUpdate=Rt,E.lastBaseUpdate=kt,L===null&&(E.shared.lanes=0),fs|=K,t.lanes=K,t.memoizedState=jt}}function vc(t,e){if(typeof t!="function")throw Error(Lt(191,t));t.call(e)}function Ec(t,e){var n=t.callbacks;if(n!==null)for(t.callbacks=null,t=0;tL?L:8;var K=O.T,ut={};ut.types=K!==null?K.types:null,O.T=ut,Ql(t,!1,e,n);try{var xt=E(),Rt=O.S;if(Rt!==null&&Rt(ut,xt),xt!==null&&typeof xt=="object"&&typeof xt.then=="function"){var kt=Um(xt,o);sa(t,e,kt,ji(t))}else sa(t,e,o,ji(t))}catch(jt){sa(t,e,{then:function(){},status:"rejected",reason:jt},ji())}finally{D.p=L,K!==null&&ut.types!==null&&(K.types=ut.types),O.T=K}}function qm(){}function ql(t,e,n,o){if(t.tag!==5)throw Error(Lt(476));var E=$c(t).queue;Jc(t,E,e,j,n===null?qm:function(){return td(t),n(o)})}function $c(t){var e=t.memoizedState;if(e!==null)return e;e={memoizedState:j,baseState:j,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Vn,lastRenderedState:j},next:null};var n={};return e.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Vn,lastRenderedState:n},next:null},t.memoizedState=e,t=t.alternate,t!==null&&(t.memoizedState=e),e}function td(t){var e=$c(t);e.next===null&&(e=t.alternate.memoizedState),sa(t,e.next.queue,{},ji())}function Kl(){return fi(Nr)}function ed(){return ti().memoizedState}function id(){return ti().memoizedState}function Km(t){for(var e=t.return;e!==null;){switch(e.tag){case 24:case 3:var n=ji();t=rs(n);var o=as(e,t,n);o!==null&&(Di(o,e,n),Jr(o,e,n)),e={cache:Ml()},t.payload=e;return}e=e.return}}function Qm(t,e,n){var o=ji();n={lane:o,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},oo(t)?sd(e,n):(n=ml(t,e,n,o),n!==null&&(Di(n,t,o),rd(n,e,o)))}function nd(t,e,n){var o=ji();sa(t,e,n,o)}function sa(t,e,n,o){var E={lane:o,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(oo(t))sd(e,E);else{var L=t.alternate;if(t.lanes===0&&(L===null||L.lanes===0)&&(L=e.lastRenderedReducer,L!==null))try{var K=e.lastRenderedState,ut=L(K,n);if(E.hasEagerState=!0,E.eagerState=ut,Gi(ut,K))return ka(t,e,E,0),ke===null&&Fa(),!1}catch{}finally{}if(n=ml(t,e,E,o),n!==null)return Di(n,t,o),rd(n,e,o),!0}return!1}function Ql(t,e,n,o){if(o={lane:2,revertLane:Gu(),gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},oo(t)){if(e)throw Error(Lt(479))}else e=ml(t,n,o,2),e!==null&&Di(e,t,2)}function oo(t){var e=t.alternate;return t===pe||e!==null&&e===pe}function sd(t,e){cr=to=!0;var n=t.pending;n===null?e.next=e:(e.next=n.next,n.next=e),t.pending=e}function rd(t,e,n){if((n&4194048)!==0){var o=e.lanes;o&=t.pendingLanes,n|=o,e.lanes=n,di(t,n)}}var lo={readContext:fi,use:no,useCallback:Je,useContext:Je,useEffect:Je,useImperativeHandle:Je,useLayoutEffect:Je,useInsertionEffect:Je,useMemo:Je,useReducer:Je,useRef:Je,useState:Je,useDebugValue:Je,useDeferredValue:Je,useTransition:Je,useSyncExternalStore:Je,useId:Je,useHostTransitionStatus:Je,useFormState:Je,useActionState:Je,useOptimistic:Je,useMemoCache:Je,useCacheRefresh:Je,useEffectEvent:Je},ad={readContext:fi,use:no,useCallback:function(t,e){return wi().memoizedState=[t,e===void 0?null:e],t},useContext:fi,useEffect:Hc,useImperativeHandle:function(t,e,n){n=n!=null?n.concat([t]):null,ro(4194308,4,Yc.bind(null,e,t),n)},useLayoutEffect:function(t,e){return ro(4194308,4,t,e)},useInsertionEffect:function(t,e){ro(4,2,t,e)},useMemo:function(t,e){var n=wi();e=e===void 0?null:e;var o=t();if(zs){Ye(!0);try{t()}finally{Ye(!1)}}return n.memoizedState=[o,e],o},useReducer:function(t,e,n){var o=wi();if(n!==void 0){var E=n(e);if(zs){Ye(!0);try{n(e)}finally{Ye(!1)}}}else E=e;return o.memoizedState=o.baseState=E,t={pending:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:E},o.queue=t,t=t.dispatch=Qm.bind(null,pe,t),[o.memoizedState,t]},useRef:function(t){var e=wi();return t={current:t},e.memoizedState=t},useState:function(t){t=Hl(t);var e=t.queue,n=nd.bind(null,pe,e);return e.dispatch=n,[t.memoizedState,n]},useDebugValue:Xl,useDeferredValue:function(t,e){var n=wi();return Yl(n,t,e)},useTransition:function(){var t=Hl(!1);return t=Jc.bind(null,pe,t.queue,!0,!1),wi().memoizedState=t,[!1,t]},useSyncExternalStore:function(t,e,n){var o=pe,E=wi();if(Se){if(n===void 0)throw Error(Lt(407));n=n()}else{if(n=e(),ke===null)throw Error(Lt(349));(xe&127)!==0||Lc(o,e,n)}E.memoizedState=n;var L={value:n,getSnapshot:e};return E.queue=L,Hc(Pc.bind(null,o,L,t),[t]),o.flags|=2048,fr(9,{destroy:void 0},Ac.bind(null,o,L,n,e),null),n},useId:function(){var t=wi(),e=ke.identifierPrefix;if(Se){var n=Sn,o=bn;n=(o&~(1<<32-ci(o)-1)).toString(32)+n,e="_"+e+"R_"+n,n=eo++,0<\/script>",L=L.removeChild(L.firstChild);break;case"select":L=typeof o.is=="string"?K.createElement("select",{is:o.is}):K.createElement("select"),o.multiple?L.multiple=!0:o.size&&(L.size=o.size);break;default:L=typeof o.is=="string"?K.createElement(E,{is:o.is}):K.createElement(E)}}L[Ze]=e,L[We]=o;t:for(K=e.child;K!==null;){if(K.tag===5||K.tag===6)L.appendChild(K.stateNode);else if(K.tag!==4&&K.tag!==27&&K.child!==null){K.child.return=K,K=K.child;continue}if(K===e)break t;for(;K.sibling===null;){if(K.return===null||K.return===e)break t;K=K.return}K.sibling.return=K.return,K=K.sibling}e.stateNode=L;t:switch(bi(L,E,o),E){case"button":case"input":case"select":case"textarea":o=!!o.autoFocus;break t;case"img":o=!0;break t;default:o=!1}o&&zn(e)}}return Ue(e),e.subtreeFlags&=-33554433,uu(e,e.type,t===null?null:t.memoizedProps,e.pendingProps,n),null;case 6:if(t&&e.stateNode!=null)t.memoizedProps!==o&&zn(e);else{if(typeof o!="string"&&e.stateNode===null)throw Error(Lt(166));if(t=yt.current,or(e)){if(t=e.stateNode,n=e.memoizedProps,o=null,E=li,E!==null)switch(E.tag){case 27:case 5:o=E.memoizedProps}t[Ze]=e,t=!!(t.nodeValue===n||o!==null&&o.suppressHydrationWarning===!0||Cf(t.nodeValue,n)),t||es(e,!0)}else t=ba(t).createTextNode(o),t[Ze]=e,e.stateNode=t}return Ue(e),null;case 31:if(n=e.memoizedState,t===null||t.memoizedState!==null){if(o=or(e),n!==null){if(t===null){if(!o)throw Error(Lt(318));if(t=e.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(Lt(557));t[Ze]=e}else Ns(),(e.flags&128)===0&&(e.memoizedState=null),e.flags|=4;Ue(e),t=!1}else n=vl(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=n),t=!0;if(!t)return e.flags&256?(zi(e),e):(zi(e),null);if((e.flags&128)!==0)throw Error(Lt(558))}return Ue(e),null;case 13:if(o=e.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(E=or(e),o!==null&&o.dehydrated!==null){if(t===null){if(!E)throw Error(Lt(318));if(E=e.memoizedState,E=E!==null?E.dehydrated:null,!E)throw Error(Lt(317));E[Ze]=e}else Ns(),(e.flags&128)===0&&(e.memoizedState=null),e.flags|=4;Ue(e),E=!1}else E=vl(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=E),E=!0;if(!E)return e.flags&256?(zi(e),e):(zi(e),null)}return zi(e),(e.flags&128)!==0?(e.lanes=n,e):(n=o!==null,t=t!==null&&t.memoizedState!==null,n&&(o=e.child,E=null,o.alternate!==null&&o.alternate.memoizedState!==null&&o.alternate.memoizedState.cachePool!==null&&(E=o.alternate.memoizedState.cachePool.pool),L=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(L=o.memoizedState.cachePool.pool),L!==E&&(o.flags|=2048)),n!==t&&n&&(e.child.flags|=8192),po(e,e.updateQueue),Ue(e),null);case 4:return Vt(),t===null&&Wu(e.stateNode.containerInfo),e.flags|=67108864,Ue(e),null;case 10:return Fn(e.type),Ue(e),null;case 19:if(Bl(e),o=e.memoizedState,o===null)return Ue(e),null;if(E=(e.flags&128)!==0,L=o.rendering,L===null)if(E)aa(o,!1);else{if($e!==0||t!==null&&(t.flags&128)!==0)for(t=e.child;t!==null;){if(L=$a(t),L!==null){for(e.flags|=128,aa(o,!1),t=L.updateQueue,e.updateQueue=t,po(e,t),e.subtreeFlags=0,t=n,n=e.child;n!==null;)nc(n,t),n=n.sibling;return ea(e,pi.current&1|2),Se&&On(e,o.treeForkCount),e.child}t=t.sibling}o.tail!==null&&De()>Lo&&(e.flags|=128,E=!0,aa(o,!1),e.lanes=4194304)}else{if(!E)if(t=$a(L),t!==null){if(e.flags|=128,E=!0,t=t.updateQueue,e.updateQueue=t,po(e,t),aa(o,!0),o.tail===null&&o.tailMode!=="collapsed"&&o.tailMode!=="visible"&&!L.alternate&&!Se)return Ue(e),null}else 2*De()-o.renderingStartTime>Lo&&n!==536870912&&(e.flags|=128,E=!0,aa(o,!1),e.lanes=4194304);o.isBackwards?(L.sibling=e.child,e.child=L):(t=o.last,t!==null?t.sibling=L:e.child=L,o.last=L)}if(o.tail!==null){t=o.tail;t:{for(n=t;n!==null;){if(n.alternate!==null){n=!1;break t}n=n.sibling}n=!0}return o.rendering=t,o.tail=t.sibling,o.renderingStartTime=De(),t.sibling=null,L=pi.current,L=E?L&1|2:L&1,o.tailMode==="visible"||o.tailMode==="collapsed"||!n||Se?ea(e,L):(n=L,it(mi,e),it(pi,n),Ei===null&&(Ei=e)),Se&&On(e,o.treeForkCount),t}return Ue(e),null;case 22:case 23:return zi(e),Nl(),o=e.memoizedState!==null,t!==null?t.memoizedState!==null!==o&&(e.flags|=8192):o&&(e.flags|=8192),o?(n&536870912)!==0&&(e.flags&128)===0&&(Ue(e),e.subtreeFlags&6&&(e.flags|=8192)):Ue(e),n=e.updateQueue,n!==null&&po(e,n.retryQueue),n=null,t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(n=t.memoizedState.cachePool.pool),o=null,e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(o=e.memoizedState.cachePool.pool),o!==n&&(e.flags|=2048),t!==null&&et(Fs),null;case 24:return n=null,t!==null&&(n=t.memoizedState.cache),e.memoizedState.cache!==n&&(e.flags|=2048),Fn(ei),Ue(e),null;case 25:return null;case 30:return e.flags|=33554432,Ue(e),null}throw Error(Lt(156,e.tag))}function np(t,e){switch(Sl(e),e.tag){case 1:return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return Fn(ei),Vt(),t=e.flags,(t&65536)!==0&&(t&128)===0?(e.flags=t&-65537|128,e):null;case 26:case 27:case 5:return It(e),null;case 31:if(e.memoizedState!==null){if(zi(e),e.alternate===null)throw Error(Lt(340));Ns()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 13:if(zi(e),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(Lt(340));Ns()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return Bl(e),t=e.flags,t&65536?(e.flags=t&-65537|128,t=e.memoizedState,t!==null&&(t.rendering=null,t.tail=null),e.flags|=4,e):null;case 4:return Vt(),null;case 10:return Fn(e.type),null;case 22:case 23:return zi(e),Nl(),t!==null&&et(Fs),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 24:return Fn(ei),null;case 25:return null;default:return null}}function Rd(t,e){switch(Sl(e),e.tag){case 3:Fn(ei),Vt();break;case 26:case 27:case 5:It(e);break;case 4:Vt();break;case 31:e.memoizedState!==null&&zi(e);break;case 13:zi(e);break;case 19:Bl(e);break;case 10:Fn(e.type);break;case 22:case 23:zi(e),Nl(),t!==null&&et(Fs);break;case 24:Fn(ei)}}function oa(t,e){try{var n=e.updateQueue,o=n!==null?n.lastEffect:null;if(o!==null){var E=o.next;n=E;do{if((n.tag&t)===t){o=void 0;var L=n.create,K=n.inst;o=L(),K.destroy=o}n=n.next}while(n!==E)}}catch(ut){Ie(e,e.return,ut)}}function hs(t,e,n){try{var o=e.updateQueue,E=o!==null?o.lastEffect:null;if(E!==null){var L=E.next;o=L;do{if((o.tag&t)===t){var K=o.inst,ut=K.destroy;if(ut!==void 0){K.destroy=void 0,E=e;var xt=n,Rt=ut;try{Rt()}catch(kt){Ie(E,xt,kt)}}}o=o.next}while(o!==L)}}catch(kt){Ie(e,e.return,kt)}}function Nd(t){var e=t.updateQueue;if(e!==null){var n=t.stateNode;try{Ec(e,n)}catch(o){Ie(t,t.return,o)}}}function Id(t,e,n){n.props=Us(t.type,t.memoizedProps),n.state=t.memoizedState;try{n.componentWillUnmount()}catch(o){Ie(t,e,o)}}function yn(t,e){try{var n=t.ref;if(n!==null){switch(t.tag){case 26:case 27:case 5:var o=t.stateNode;break;case 30:var E=t.stateNode,L=Nn(t.memoizedProps,E);(E.ref===null||E.ref.name!==L)&&(E.ref=zf(L)),o=E.ref;break;case 7:if(t.stateNode===null){var K=new Xi(t);a(t.child,!1,Yp,K,void 0,void 0),t.stateNode=K}o=t.stateNode;break;default:o=t.stateNode}typeof n=="function"?t.refCleanup=n(o):n.current=o}}catch(ut){Ie(t,e,ut)}}function gi(t,e){var n=t.ref,o=t.refCleanup;if(n!==null)if(typeof o=="function")try{o()}catch(E){Ie(t,e,E)}finally{t.refCleanup=null,t=t.alternate,t!=null&&(t.refCleanup=null)}else if(typeof n=="function")try{n(null)}catch(E){Ie(t,e,E)}else n.current=null}function go(t,e){if((t.tag===5||t.tag===27||t.tag===6)&&t.alternate===null&&e!==null)for(var n=0;n title"))),bi(o,e,n),o[Ze]=t,vt(o),e=o;break t;case"link":if(L=s1("link","href",E).get(e+(n.href||""))){for(K=0;Kge&&(K=ge,ge=ue,ue=K);var Pt=jh(ut,ue),wt=jh(ut,ge);if(Pt&&wt&&(Ot.rangeCount!==1||Ot.anchorNode!==Pt.node||Ot.anchorOffset!==Pt.offset||Ot.focusNode!==wt.node||Ot.focusOffset!==wt.offset)){var Bt=jt.createRange();Bt.setStart(Pt.node,Pt.offset),Ot.removeAllRanges(),ue>ge?(Ot.addRange(Bt),Ot.extend(wt.node,wt.offset)):(Bt.setEnd(wt.node,wt.offset),Ot.addRange(Bt))}}}}for(jt=[],Ot=ut;Ot=Ot.parentNode;)Ot.nodeType===1&&jt.push({element:Ot,left:Ot.scrollLeft,top:Ot.scrollTop});for(typeof ut.focus=="function"&&ut.focus(),ut=0;utn?32:n,O.T=null,n=Cu,Cu=null;var L=fn,K=_n;if(Qe=0,Xs=fn=null,_n=0,(Ae&6)!==0)throw Error(Lt(331));var ut=Ae;if(Ae|=4,nf(L.current),$d(L,L.current,K,n),Ae=ut,ma(0,!1),Te&&typeof Te.onPostCommitFiberRoot=="function")try{Te.onPostCommitFiberRoot(He,L)}catch{}return!0}finally{D.p=E,O.T=o,Sf(t,e)}}function yf(t,e,n){e=Ki(n,e),e=$l(t.stateNode,e,2),t=as(t,e,2),t!==null&&(yi(t,2),wn(t))}function Ie(t,e,n){if(t.tag===3)yf(t,t,n);else for(;e!==null;){if(e.tag===3){yf(e,t,n);break}else if(e.tag===1){var o=e.stateNode;if(typeof e.type.getDerivedStateFromError=="function"||typeof o.componentDidCatch=="function"&&(ms===null||!ms.has(o))){t=Ki(n,t),n=md(2),o=as(e,n,2),o!==null&&(pd(n,o,e,t),yi(o,2),wn(o));break}}e=e.return}}function Fu(t,e,n){var o=t.pingCache;if(o===null){o=t.pingCache=new op;var E=new Set;o.set(e,E)}else E=o.get(e),E===void 0&&(E=new Set,o.set(e,E));E.has(n)||(Lu=!0,E.add(n),t=pp.bind(null,t,e,n),e.then(t,t))}function pp(t,e,n){var o=t.pingCache;o!==null&&o.delete(e),t.pingedLanes|=t.suspendedLanes&n,t.warmLanes&=~n,ke===t&&(xe&n)===n&&(($e===4||$e===3&&(xe&62914560)===xe&&300>De()-wo)&&(Ae&2)===0?Tr(t,0):_o|=n,yr===xe&&(yr=0)),wn(t)}function vf(t,e){e===0&&(e=An()),t=Cs(t,e),t!==null&&(yi(t,e),wn(t))}function gp(t){var e=t.memoizedState,n=0;e!==null&&(n=e.retryLane),vf(t,n)}function bp(t,e){var n=0;switch(t.tag){case 31:case 13:var o=t.stateNode,E=t.memoizedState;E!==null&&(n=E.retryLane);break;case 19:o=t.stateNode;break;case 22:o=t.stateNode._retryCache;break;default:throw Error(Lt(314))}o!==null&&o.delete(e),vf(t,n)}function Sp(t,e){return ie(t,e)}var wr=null,Lr=null,ku=!1,Bo=!1,Vu=!1,gs=0;function wn(t){t!==Lr&&t.next===null&&(Lr===null?wr=Lr=t:Lr=Lr.next=t),Bo=!0,ku||(ku=!0,vp())}function ma(t,e){if(!Vu&&Bo){Vu=!0;do for(var n=!1,o=wr;o!==null;){if(t!==0){var E=o.pendingLanes;if(E===0)var L=0;else{var K=o.suspendedLanes,ut=o.pingedLanes;L=(1<<31-ci(42|t)+1)-1,L&=E&~(K&~ut),L=L&201326741?L&201326741|1:L?L|2:0}L!==0&&(n=!0,Tf(o,L))}else L=xe,L=Ln(o,o===ke?L:0,o.cancelPendingCommit!==null||o.timeoutHandle!==-1),(L&3)===0||rn(o,L)||(n=!0,Tf(o,L));o=o.next}while(n);Vu=!1}}function yp(){Ef()}function Ef(){Bo=ku=!1;var t=0;gs!==0&&Rp()&&(t=gs);for(var e=De(),n=null,o=wr;o!==null;){var E=o.next,L=xf(o,e);L===0?(o.next=null,n===null?wr=E:n.next=E,E===null&&(Lr=n)):(n=o,(t!==0||(L&3)!==0)&&(Bo=!0)),o=E}Qe!==0&&Qe!==5||ma(t),gs!==0&&(gs=0)}function xf(t,e){for(var n=t.suspendedLanes,o=t.pingedLanes,E=t.expirationTimes,L=t.pendingLanes&-62914561;0ut)break;var kt=xt.transferSize,jt=xt.initiatorType;kt&&Rf(jt)&&(xt=xt.responseEnd,K+=kt*(xtVo){ue.length=re;break}Bt=new Promise(Fp.bind(Bt)),ue.push(Bt)}}}if(0"u"?null:document;function t1(t,e,n){var o=Pr;if(o&&typeof e=="string"&&e){var E=ne(e);E='link[rel="'+t+'"][href="'+E+'"]',typeof n=="string"&&(E+='[crossorigin="'+n+'"]'),$f.has(E)||($f.add(E),t={rel:t,crossOrigin:n,href:e},o.querySelector(E)===null&&(e=o.createElement("link"),bi(e,"link",t),vt(e),o.head.appendChild(e)))}}function i2(t){Hn.D(t),t1("dns-prefetch",t,null)}function n2(t,e){Hn.C(t,e),t1("preconnect",t,e)}function s2(t,e,n){Hn.L(t,e,n);var o=Pr;if(o&&t&&e){var E='link[rel="preload"][as="'+ne(e)+'"]';e==="image"&&n&&n.imageSrcSet?(E+='[imagesrcset="'+ne(n.imageSrcSet)+'"]',typeof n.imageSizes=="string"&&(E+='[imagesizes="'+ne(n.imageSizes)+'"]')):E+='[href="'+ne(t)+'"]';var L=E;switch(e){case"style":L=Cr(t);break;case"script":L=Rr(t)}if(!(en.has(L)||(t=x({rel:"preload",href:e==="image"&&n&&n.imageSrcSet?void 0:t,as:e},n),en.set(L,t),o.querySelector(E)!==null||e==="style"&&o.querySelector(ya(L))||e==="script"&&o.querySelector(va(L))))){var K=o.createElement("link");bi(K,"link",t),e==="style"&&(K[Js]=!0,K.onload=K.onerror=function(){i(K)}),vt(K),o.head.appendChild(K)}}}function r2(t,e){Hn.m(t,e);var n=Pr;if(n&&t){var o=e&&typeof e.as=="string"?e.as:"script",E='link[rel="modulepreload"][as="'+ne(o)+'"][href="'+ne(t)+'"]',L=E;switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":L=Rr(t)}if(!en.has(L)&&(t=x({rel:"modulepreload",href:t},e),en.set(L,t),n.querySelector(E)===null)){switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(n.querySelector(va(L)))return}o=n.createElement("link"),bi(o,"link",t),vt(o),n.head.appendChild(o)}}}function a2(t,e,n){Hn.S(t,e,n);var o=Pr;if(o&&t){var E=Xn(o).hoistableStyles,L=Cr(t);e=e||"default";var K=E.get(L);if(!K){var ut={loading:0,preload:null};if(K=o.querySelector(ya(L)))ut.loading=5;else{t=x({rel:"stylesheet",href:t,"data-precedence":e},n),(n=en.get(L))&&ah(t,n);var xt=K=o.createElement("link");vt(xt),bi(xt,"link",t),xt._p=new Promise(function(Rt,kt){xt.onload=Rt,xt.onerror=kt}),xt.addEventListener("load",function(){ut.loading|=1}),xt.addEventListener("error",function(){ut.loading|=2}),ut.loading|=4,Fo(K,e,o)}K={type:"stylesheet",instance:K,count:1,state:ut},E.set(L,K)}}}function o2(t,e){Hn.X(t,e);var n=Pr;if(n&&t){var o=Xn(n).hoistableScripts,E=Rr(t),L=o.get(E);L||(L=n.querySelector(va(E)),L||(t=x({src:t,async:!0},e),(e=en.get(E))&&oh(t,e),L=n.createElement("script"),vt(L),bi(L,"link",t),n.head.appendChild(L)),L={type:"script",instance:L,count:1,state:null},o.set(E,L))}}function l2(t,e){Hn.M(t,e);var n=Pr;if(n&&t){var o=Xn(n).hoistableScripts,E=Rr(t),L=o.get(E);L||(L=n.querySelector(va(E)),L||(t=x({src:t,async:!0,type:"module"},e),(e=en.get(E))&&oh(t,e),L=n.createElement("script"),vt(L),bi(L,"link",t),n.head.appendChild(L)),L={type:"script",instance:L,count:1,state:null},o.set(E,L))}}function e1(t,e,n,o){var E=(E=yt.current)?Sa(E):null;if(!E)throw Error(Lt(446));switch(t){case"meta":case"title":return null;case"style":return typeof n.precedence=="string"&&typeof n.href=="string"?(n=Cr(n.href),e=Xn(E).hoistableStyles,o=e.get(n),o||(o={type:"style",instance:null,count:0,state:null},e.set(n,o)),o):{type:"void",instance:null,count:0,state:null};case"link":if(n.rel==="stylesheet"&&typeof n.href=="string"&&typeof n.precedence=="string"){t=Cr(n.href);var L=Xn(E).hoistableStyles,K=L.get(t);if(K||(E=E.ownerDocument||E,K={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},L.set(t,K),(L=E.querySelector(ya(t)))?L._p||(K.instance=L,K.state.loading=5):(L=en.get(t),L||(L={rel:"preload",as:"style",href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},en.set(t,L)),u2(E,t,L,K.state))),e&&o===null)throw Error(Lt(528,""));return K}if(e&&o!==null)throw Error(Lt(529,""));return null;case"script":return e=n.async,n=n.src,typeof n=="string"&&e&&typeof e!="function"&&typeof e!="symbol"?(n=Rr(n),e=Xn(E).hoistableScripts,o=e.get(n),o||(o={type:"script",instance:null,count:0,state:null},e.set(n,o)),o):{type:"void",instance:null,count:0,state:null};default:throw Error(Lt(444,t))}}function Cr(t){return'href="'+ne(t)+'"'}function ya(t){return'link[rel="stylesheet"]['+t+"]"}function i1(t){return x({},t,{"data-precedence":t.precedence,precedence:null})}function u2(t,e,n,o){if(e=t.querySelector('link[rel="preload"][as="style"]['+e+"]")){if(e[Js]!==!0){o.loading=1;return}}else e=t.createElement("link"),e[Js]=!0,e.onload=e.onerror=i.bind(null,e),bi(e,"link",n),vt(e),t.head.appendChild(e);o.preload=e,e.addEventListener("load",function(){return o.loading|=1}),e.addEventListener("error",function(){return o.loading|=2})}function Rr(t){return'[src="'+ne(t)+'"]'}function va(t){return"script[async]"+t}function n1(t,e,n){if(e.count++,e.instance===null)switch(e.type){case"style":var o=t.querySelector('style[data-href~="'+ne(n.href)+'"]');if(o)return e.instance=o,vt(o),o;var E=x({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return o=(t.ownerDocument||t).createElement("style"),vt(o),bi(o,"style",E),Fo(o,n.precedence,t),e.instance=o;case"stylesheet":E=Cr(n.href);var L=t.querySelector(ya(E));if(L)return e.state.loading|=4,e.instance=L,vt(L),L;o=i1(n),(E=en.get(E))&&ah(o,E),L=(t.ownerDocument||t).createElement("link"),vt(L);var K=L;return K._p=new Promise(function(ut,xt){K.onload=ut,K.onerror=xt}),bi(L,"link",o),e.state.loading|=4,Fo(L,n.precedence,t),e.instance=L;case"script":return L=Rr(n.src),(E=t.querySelector(va(L)))?(e.instance=E,vt(E),E):(o=n,(E=en.get(L))&&(o=x({},n),oh(o,E)),t=t.ownerDocument||t,E=t.createElement("script"),vt(E),bi(E,"link",o),t.head.appendChild(E),e.instance=E);case"void":return null;default:throw Error(Lt(443,e.type))}else e.type==="stylesheet"&&(e.state.loading&4)===0&&(o=e.instance,e.state.loading|=4,Fo(o,n.precedence,t));return e.instance}function Fo(t,e,n){for(var o=n.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),E=o.length?o[o.length-1]:null,L=E,K=0;K title"):null)}function h2(t,e,n){if(n===1||e.itemProp!=null)return!1;switch(t){case"meta":case"title":return!0;case"style":if(typeof e.precedence!="string"||typeof e.href!="string"||e.href==="")break;return!0;case"link":if(typeof e.rel!="string"||typeof e.href!="string"||e.href===""||e.onLoad||e.onError)break;switch(e.rel){case"stylesheet":return t=e.disabled,typeof e.precedence=="string"&&t==null;default:return!0}case"script":if(e.async&&typeof e.async!="function"&&typeof e.async!="symbol"&&!e.onLoad&&!e.onError&&e.src&&typeof e.src=="string")return!0}return!1}function r1(t,e){return t==="img"&&e.src!=null&&e.src!==""&&e.onLoad==null&&e.loading!=="lazy"}function a1(t){return!(t.type==="stylesheet"&&(t.state.loading&3)===0)}function o1(t){return(t.width||100)*(t.height||100)*(typeof devicePixelRatio=="number"?devicePixelRatio:1)*.25}function l1(t,e){typeof e.decode=="function"&&(t.imgCount++,e.complete||(t.imgBytes+=o1(e),t.suspenseyImages.push(e)),t=f2.bind(t),e.decode().then(t,t))}function c2(t,e,n,o){if(n.type==="stylesheet"&&(typeof o.media!="string"||matchMedia(o.media).matches!==!1)&&(n.state.loading&4)===0){if(n.instance===null){var E=Cr(o.href),L=e.querySelector(ya(E));if(L){e=L._p,e!==null&&typeof e=="object"&&typeof e.then=="function"&&(t.count++,t=Ea.bind(t),e.then(t,t)),n.state.loading|=4,n.instance=L,vt(L);return}L=e.ownerDocument||e,o=i1(o),(E=en.get(E))&&ah(o,E),L=L.createElement("link"),vt(L);var K=L;K._p=new Promise(function(ut,xt){K.onload=ut,K.onerror=xt}),bi(L,"link",o),n.instance=L}t.stylesheets===null&&(t.stylesheets=new Map),t.stylesheets.set(n,e),(e=n.state.preload)&&(n.state.loading&3)===0&&(t.count++,n=Ea.bind(t),e.addEventListener("load",n),e.addEventListener("error",n))}}var Vo=0;function d2(t,e){return t.stylesheets&&t.count===0&&zo(t,t.stylesheets),0Vo?50:800)+e);return t.unsuspend=n,function(){t.unsuspend=null,clearTimeout(o),clearTimeout(E)}}:null}function u1(t){if(t.count===0&&(t.imgCount===0||!t.waitingForImages)){if(t.stylesheets)zo(t,t.stylesheets);else if(t.unsuspend){var e=t.unsuspend;t.unsuspend=null,e()}}}function Ea(){this.count--,u1(this)}function f2(){this.imgCount--,u1(this)}var Go=null;function zo(t,e){t.stylesheets=null,t.unsuspend!==null&&(t.count++,Go=new Map,e.forEach(m2,t),Go=null,Ea.call(t))}function m2(t,e){if(!(e.state.loading&4)){var n=Go.get(t);if(n)var o=n.get(null);else{n=new Map,Go.set(t,n);for(var E=t.querySelectorAll("link[data-precedence],style[data-precedence]"),L=0;L"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Wt)}catch(Jt){console.error(Jt)}}return Wt(),bh.exports=C2(),bh.exports}var N2=R2();const I2=k1(N2),B2=({spans:Wt})=>!Wt||Wt.length===0?null:Gt.jsxs("div",{className:"bg-white rounded-xl shadow-sm border border-slate-200 p-4",children:[Gt.jsx("div",{className:"text-xs font-semibold uppercase tracking-wider text-slate-500 mb-2",children:"Harmonic Modulation Trajectory"}),Gt.jsx("div",{className:"flex flex-wrap items-center gap-2",children:Wt.map((Jt,se)=>Gt.jsxs(V1.Fragment,{children:[Gt.jsxs("div",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-semibold text-white shadow-sm transition-transform hover:scale-105",style:{backgroundColor:Jt.colorHex||"#1e293b"},children:[Gt.jsx("span",{className:"text-sm font-bold tracking-tight",children:Jt.center}),Gt.jsxs("span",{className:"opacity-80 text-[10px] font-normal",children:["(",Jt.startBar===Jt.endBar?`bar ${Jt.startBar}`:`bars ${Jt.startBar}–${Jt.endBar}`,")"]})]}),se!Wt||Wt.length===0?null:Gt.jsxs("div",{className:"bg-white rounded-xl shadow-sm border border-slate-200 p-4",children:[Gt.jsxs("div",{className:"text-xs font-semibold uppercase tracking-wider text-slate-500 mb-2",children:["Identified Berklee Harmonic Devices (",Wt.length,")"]}),Gt.jsx("div",{className:"flex flex-wrap gap-2",children:Wt.map((Jt,se)=>Gt.jsxs("div",{className:`flex items-center gap-2 px-3 py-1.5 rounded-lg border text-xs ${Jt.IsDashed?"border-dashed border-amber-300 bg-amber-50/50 text-amber-900":"border-slate-200 bg-slate-50 text-slate-800"}`,children:[Gt.jsx("span",{className:"font-bold text-sm",children:Jt.Label}),Gt.jsxs("span",{className:"text-[11px] text-slate-500",children:["bars ",Jt.StartMeasure+1,"–",Jt.EndMeasure+1]}),Jt.Resolves&&Gt.jsxs("span",{className:"px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800 text-[10px] font-bold",children:["Resolves ➔ ",Jt.TargetKey]}),!Jt.Resolves&&Gt.jsx("span",{className:"px-1.5 py-0.5 rounded bg-slate-200 text-slate-600 text-[10px] font-medium",children:"Turnaround ┐"})]},se))})]}),D2=({measures:Wt})=>!Wt||Wt.length===0?null:Gt.jsxs("div",{className:"bg-white rounded-xl shadow-sm border border-slate-200 overflow-hidden",children:[Gt.jsxs("div",{className:"px-5 py-3 border-b border-slate-100 bg-slate-50/50 flex justify-between items-center",children:[Gt.jsx("h3",{className:"text-sm font-semibold text-slate-800",children:"Measure & Voice Leading Detail"}),Gt.jsxs("span",{className:"text-xs text-slate-500",children:[Wt.length," measures"]})]}),Gt.jsx("div",{className:"overflow-x-auto max-h-96",children:Gt.jsxs("table",{className:"w-full text-left text-xs border-collapse",children:[Gt.jsx("thead",{className:"bg-slate-100/75 text-slate-600 font-semibold sticky top-0 shadow-sm z-10",children:Gt.jsxs("tr",{children:[Gt.jsx("th",{className:"py-2.5 px-4",children:"Bar"}),Gt.jsx("th",{className:"py-2.5 px-4",children:"Beat"}),Gt.jsx("th",{className:"py-2.5 px-4",children:"Chord"}),Gt.jsx("th",{className:"py-2.5 px-4",children:"Hold"}),Gt.jsx("th",{className:"py-2.5 px-4",children:"Voice 1 (3/7)"}),Gt.jsx("th",{className:"py-2.5 px-4",children:"Voice 2 (3/7)"}),Gt.jsx("th",{className:"py-2.5 px-4",children:"Tonal Center"})]})}),Gt.jsx("tbody",{className:"divide-y divide-slate-100 font-mono",children:Wt.flatMap(Jt=>Jt.chords.map((se,Lt)=>Gt.jsxs("tr",{className:"hover:bg-slate-50/80 transition-colors",children:[Gt.jsx("td",{className:"py-2 px-4 font-semibold text-slate-700",children:Lt===0?Jt.number:""}),Gt.jsx("td",{className:"py-2 px-4 text-slate-500",children:(se.beatOffset+1).toFixed(1)}),Gt.jsx("td",{className:"py-2 px-4 font-bold text-slate-900",children:se.symbol}),Gt.jsxs("td",{className:"py-2 px-4 text-slate-600",children:[se.durationBeats.toFixed(1)," b"]}),Gt.jsx("td",{className:"py-2 px-4 text-blue-600 font-semibold",children:se.voice1}),Gt.jsx("td",{className:"py-2 px-4 text-indigo-600 font-semibold",children:se.voice2}),Gt.jsx("td",{className:"py-2 px-4",children:Gt.jsx("span",{className:"inline-block px-2 py-0.5 rounded text-[11px] font-bold text-white shadow-xs",style:{backgroundColor:se.colorHex||"#334155"},children:se.tonalCenter})})]},`${Jt.number}-${Lt}`)))})]})})]});var qo={exports:{}};/*! For license information please see opensheetmusicdisplay.min.js.LICENSE.txt */var F2=qo.exports,I1;function k2(){return I1||(I1=1,(function(Wt,Jt){(function(se,Lt){Wt.exports=Lt()})(F2,()=>(()=>{var se={1710(St,y,p){St.exports=(function d(l,m,a){function s(f,r){if(!m[f]){if(!l[f]){if(h)return h(f,!0);var b=new Error("Cannot find module '"+f+"'");throw b.code="MODULE_NOT_FOUND",b}var S=m[f]={exports:{}};l[f][0].call(S.exports,function(v){return s(l[f][1][v]||v)},S,S.exports,d,l,m,a)}return m[f].exports}for(var h=void 0,u=0;u>2,v=(3&f)<<4|r>>4,w=1<_?(15&r)<<2|b>>6:64,T=2<_?63&b:64,g.push(h.charAt(S)+h.charAt(v)+h.charAt(w)+h.charAt(T));return g.join("")},m.decode=function(u){var f,r,b,S,v,w,T=0,g=0,x="data:";if(u.substr(0,5)===x)throw new Error("Invalid base64 input, it looks like a data url.");var P,_=3*(u=u.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(u.charAt(u.length-1)===h.charAt(64)&&_--,u.charAt(u.length-2)===h.charAt(64)&&_--,_%1!=0)throw new Error("Invalid base64 input, bad content length.");for(P=s.uint8array?new Uint8Array(0|_):new Array(0|_);T>4,r=(15&S)<<4|(v=h.indexOf(u.charAt(T++)))>>2,b=(3&v)<<6|(w=h.indexOf(u.charAt(T++))),P[g++]=f,v!==64&&(P[g++]=r),w!==64&&(P[g++]=b);return P}},{"./support":30,"./utils":32}],2:[function(d,l,m){var a=d("./external"),s=d("./stream/DataWorker"),h=d("./stream/Crc32Probe"),u=d("./stream/DataLengthProbe");function f(r,b,S,v,w){this.compressedSize=r,this.uncompressedSize=b,this.crc32=S,this.compression=v,this.compressedContent=w}f.prototype={getContentWorker:function(){var r=new s(a.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new u("data_length")),b=this;return r.on("end",function(){if(this.streamInfo.data_length!==b.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),r},getCompressedWorker:function(){return new s(a.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},f.createWorkerFrom=function(r,b,S){return r.pipe(new h).pipe(new u("uncompressedSize")).pipe(b.compressWorker(S)).pipe(new u("compressedSize")).withStreamInfo("compression",b)},l.exports=f},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(d,l,m){var a=d("./stream/GenericWorker");m.STORE={magic:"\0\0",compressWorker:function(){return new a("STORE compression")},uncompressWorker:function(){return new a("STORE decompression")}},m.DEFLATE=d("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(d,l,m){var a=d("./utils"),s=(function(){for(var h,u=[],f=0;f<256;f++){h=f;for(var r=0;r<8;r++)h=1&h?3988292384^h>>>1:h>>>1;u[f]=h}return u})();l.exports=function(h,u){return h!==void 0&&h.length?a.getTypeOf(h)!=="string"?(function(f,r,b){var S=s,v=0+b;f^=-1;for(var w=0;w>>8^S[255&(f^r[w])];return-1^f})(0|u,h,h.length):(function(f,r,b){var S=s,v=0+b;f^=-1;for(var w=0;w>>8^S[255&(f^r.charCodeAt(w))];return-1^f})(0|u,h,h.length):0}},{"./utils":32}],5:[function(d,l,m){m.base64=!1,m.binary=!1,m.dir=!1,m.createFolders=!0,m.date=null,m.compression=null,m.compressionOptions=null,m.comment=null,m.unixPermissions=null,m.dosPermissions=null},{}],6:[function(d,l,m){var a;a=typeof Promise<"u"?Promise:d("lie"),l.exports={Promise:a}},{lie:37}],7:[function(d,l,m){var a=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",s=d("pako"),h=d("./utils"),u=d("./stream/GenericWorker"),f=a?"uint8array":"array";function r(b,S){u.call(this,"FlateWorker/"+b),this._pako=null,this._pakoAction=b,this._pakoOptions=S,this.meta={}}m.magic="\b\0",h.inherits(r,u),r.prototype.processChunk=function(b){this.meta=b.meta,this._pako===null&&this._createPako(),this._pako.push(h.transformTo(f,b.data),!1)},r.prototype.flush=function(){u.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},r.prototype.cleanUp=function(){u.prototype.cleanUp.call(this),this._pako=null},r.prototype._createPako=function(){this._pako=new s[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var b=this;this._pako.onData=function(S){b.push({data:S,meta:b.meta})}},m.compressWorker=function(b){return new r("Deflate",b)},m.uncompressWorker=function(){return new r("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(d,l,m){function a(v,w){var T,g="";for(T=0;T>>=8;return g}function s(v,w,T,g,x,P){var _,B,k=v.file,R=v.compression,F=P!==f.utf8encode,A=h.transformTo("string",P(k.name)),G=h.transformTo("string",f.utf8encode(k.name)),U=k.comment,C=h.transformTo("string",P(U)),z=h.transformTo("string",f.utf8encode(U)),W=G.length!==k.name.length,$=z.length!==U.length,N="",Y="",tt="",H=k.dir,rt=k.date,ct={crc32:0,compressedSize:0,uncompressedSize:0};w&&!T||(ct.crc32=v.crc32,ct.compressedSize=v.compressedSize,ct.uncompressedSize=v.uncompressedSize);var st=0;w&&(st|=8),F||!W&&!$||(st|=2048);var at=0,ht=0;H&&(at|=16),x==="UNIX"?(ht=798,at|=(function(O,D){var j=O;return O||(j=D?16893:33204),(65535&j)<<16})(k.unixPermissions,H)):(ht=20,at|=(function(O){return 63&(O||0)})(k.dosPermissions)),_=rt.getUTCHours(),_<<=6,_|=rt.getUTCMinutes(),_<<=5,_|=rt.getUTCSeconds()/2,B=rt.getUTCFullYear()-1980,B<<=4,B|=rt.getUTCMonth()+1,B<<=5,B|=rt.getUTCDate(),W&&(Y=a(1,1)+a(r(A),4)+G,N+="up"+a(Y.length,2)+Y),$&&(tt=a(1,1)+a(r(C),4)+z,N+="uc"+a(tt.length,2)+tt);var lt="";return lt+=` -\0`,lt+=a(st,2),lt+=R.magic,lt+=a(_,2),lt+=a(B,2),lt+=a(ct.crc32,4),lt+=a(ct.compressedSize,4),lt+=a(ct.uncompressedSize,4),lt+=a(A.length,2),lt+=a(N.length,2),{fileRecord:b.LOCAL_FILE_HEADER+lt+A+N,dirRecord:b.CENTRAL_FILE_HEADER+a(ht,2)+lt+a(C.length,2)+"\0\0\0\0"+a(at,4)+a(g,4)+A+N+C}}var h=d("../utils"),u=d("../stream/GenericWorker"),f=d("../utf8"),r=d("../crc32"),b=d("../signature");function S(v,w,T,g){u.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=w,this.zipPlatform=T,this.encodeFileName=g,this.streamFiles=v,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}h.inherits(S,u),S.prototype.push=function(v){var w=v.meta.percent||0,T=this.entriesCount,g=this._sources.length;this.accumulate?this.contentBuffer.push(v):(this.bytesWritten+=v.data.length,u.prototype.push.call(this,{data:v.data,meta:{currentFile:this.currentFile,percent:T?(w+100*(T-g-1))/T:100}}))},S.prototype.openedSource=function(v){this.currentSourceOffset=this.bytesWritten,this.currentFile=v.file.name;var w=this.streamFiles&&!v.file.dir;if(w){var T=s(v,w,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:T.fileRecord,meta:{percent:0}})}else this.accumulate=!0},S.prototype.closedSource=function(v){this.accumulate=!1;var w=this.streamFiles&&!v.file.dir,T=s(v,w,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(T.dirRecord),w)this.push({data:(function(g){return b.DATA_DESCRIPTOR+a(g.crc32,4)+a(g.compressedSize,4)+a(g.uncompressedSize,4)})(v),meta:{percent:100}});else for(this.push({data:T.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},S.prototype.flush=function(){for(var v=this.bytesWritten,w=0;w=this.index;u--)f=(f<<8)+this.byteAt(u);return this.index+=h,f},readString:function(h){return a.transformTo("string",this.readData(h))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var h=this.readInt(4);return new Date(Date.UTC(1980+(h>>25&127),(h>>21&15)-1,h>>16&31,h>>11&31,h>>5&63,(31&h)<<1))}},l.exports=s},{"../utils":32}],19:[function(d,l,m){var a=d("./Uint8ArrayReader");function s(h){a.call(this,h)}d("../utils").inherits(s,a),s.prototype.readData=function(h){this.checkOffset(h);var u=this.data.slice(this.zero+this.index,this.zero+this.index+h);return this.index+=h,u},l.exports=s},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(d,l,m){var a=d("./DataReader");function s(h){a.call(this,h)}d("../utils").inherits(s,a),s.prototype.byteAt=function(h){return this.data.charCodeAt(this.zero+h)},s.prototype.lastIndexOfSignature=function(h){return this.data.lastIndexOf(h)-this.zero},s.prototype.readAndCheckSignature=function(h){return h===this.readData(4)},s.prototype.readData=function(h){this.checkOffset(h);var u=this.data.slice(this.zero+this.index,this.zero+this.index+h);return this.index+=h,u},l.exports=s},{"../utils":32,"./DataReader":18}],21:[function(d,l,m){var a=d("./ArrayReader");function s(h){a.call(this,h)}d("../utils").inherits(s,a),s.prototype.readData=function(h){if(this.checkOffset(h),h===0)return new Uint8Array(0);var u=this.data.subarray(this.zero+this.index,this.zero+this.index+h);return this.index+=h,u},l.exports=s},{"../utils":32,"./ArrayReader":17}],22:[function(d,l,m){var a=d("../utils"),s=d("../support"),h=d("./ArrayReader"),u=d("./StringReader"),f=d("./NodeBufferReader"),r=d("./Uint8ArrayReader");l.exports=function(b){var S=a.getTypeOf(b);return a.checkSupport(S),S!=="string"||s.uint8array?S==="nodebuffer"?new f(b):s.uint8array?new r(a.transformTo("uint8array",b)):new h(a.transformTo("array",b)):new u(b)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(d,l,m){m.LOCAL_FILE_HEADER="PK",m.CENTRAL_FILE_HEADER="PK",m.CENTRAL_DIRECTORY_END="PK",m.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",m.ZIP64_CENTRAL_DIRECTORY_END="PK",m.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(d,l,m){var a=d("./GenericWorker"),s=d("../utils");function h(u){a.call(this,"ConvertWorker to "+u),this.destType=u}s.inherits(h,a),h.prototype.processChunk=function(u){this.push({data:s.transformTo(this.destType,u.data),meta:u.meta})},l.exports=h},{"../utils":32,"./GenericWorker":28}],25:[function(d,l,m){var a=d("./GenericWorker"),s=d("../crc32");function h(){a.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}d("../utils").inherits(h,a),h.prototype.processChunk=function(u){this.streamInfo.crc32=s(u.data,this.streamInfo.crc32||0),this.push(u)},l.exports=h},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(d,l,m){var a=d("../utils"),s=d("./GenericWorker");function h(u){s.call(this,"DataLengthProbe for "+u),this.propName=u,this.withStreamInfo(u,0)}a.inherits(h,s),h.prototype.processChunk=function(u){if(u){var f=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=f+u.data.length}s.prototype.processChunk.call(this,u)},l.exports=h},{"../utils":32,"./GenericWorker":28}],27:[function(d,l,m){var a=d("../utils"),s=d("./GenericWorker");function h(u){s.call(this,"DataWorker");var f=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,u.then(function(r){f.dataIsReady=!0,f.data=r,f.max=r&&r.length||0,f.type=a.getTypeOf(r),f.isPaused||f._tickAndRepeat()},function(r){f.error(r)})}a.inherits(h,s),h.prototype.cleanUp=function(){s.prototype.cleanUp.call(this),this.data=null},h.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,a.delay(this._tickAndRepeat,[],this)),!0)},h.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(a.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},h.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var u=null,f=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":u=this.data.substring(this.index,f);break;case"uint8array":u=this.data.subarray(this.index,f);break;case"array":case"nodebuffer":u=this.data.slice(this.index,f)}return this.index=f,this.push({data:u,meta:{percent:this.max?this.index/this.max*100:0}})},l.exports=h},{"../utils":32,"./GenericWorker":28}],28:[function(d,l,m){function a(s){this.name=s||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}a.prototype={push:function(s){this.emit("data",s)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(s){this.emit("error",s)}return!0},error:function(s){return!this.isFinished&&(this.isPaused?this.generatedError=s:(this.isFinished=!0,this.emit("error",s),this.previous&&this.previous.error(s),this.cleanUp()),!0)},on:function(s,h){return this._listeners[s].push(h),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(s,h){if(this._listeners[s])for(var u=0;u "+s:s}},l.exports=a},{}],29:[function(d,l,m){var a=d("../utils"),s=d("./ConvertWorker"),h=d("./GenericWorker"),u=d("../base64"),f=d("../support"),r=d("../external"),b=null;if(f.nodestream)try{b=d("../nodejs/NodejsStreamOutputAdapter")}catch{}function S(v,w,T){var g=w;switch(w){case"blob":case"arraybuffer":g="uint8array";break;case"base64":g="string"}try{this._internalType=g,this._outputType=w,this._mimeType=T,a.checkSupport(g),this._worker=v.pipe(new s(g)),v.lock()}catch(x){this._worker=new h("error"),this._worker.error(x)}}S.prototype={accumulate:function(v){return(function(w,T){return new r.Promise(function(g,x){var P=[],_=w._internalType,B=w._outputType,k=w._mimeType;w.on("data",function(R,F){P.push(R),T&&T(F)}).on("error",function(R){P=[],x(R)}).on("end",function(){try{var R=(function(F,A,G){switch(F){case"blob":return a.newBlob(a.transformTo("arraybuffer",A),G);case"base64":return u.encode(A);default:return a.transformTo(F,A)}})(B,(function(F,A){var G,U=0,C=null,z=0;for(G=0;G"u")m.blob=!1;else{var a=new ArrayBuffer(0);try{m.blob=new Blob([a],{type:"application/zip"}).size===0}catch{try{var s=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);s.append(a),m.blob=s.getBlob("application/zip").size===0}catch{m.blob=!1}}}try{m.nodestream=!!d("readable-stream").Readable}catch{m.nodestream=!1}},{"readable-stream":16}],31:[function(d,l,m){for(var a=d("./utils"),s=d("./support"),h=d("./nodejsUtils"),u=d("./stream/GenericWorker"),f=new Array(256),r=0;r<256;r++)f[r]=252<=r?6:248<=r?5:240<=r?4:224<=r?3:192<=r?2:1;function b(){u.call(this,"utf-8 decode"),this.leftOver=null}function S(){u.call(this,"utf-8 encode")}f[254]=f[254]=1,m.utf8encode=function(v){return s.nodebuffer?h.newBufferFrom(v,"utf-8"):(function(w){var T,g,x,P,_,B=w.length,k=0;for(P=0;P>>6:(g<65536?T[_++]=224|g>>>12:(T[_++]=240|g>>>18,T[_++]=128|g>>>12&63),T[_++]=128|g>>>6&63),T[_++]=128|63&g);return T})(v)},m.utf8decode=function(v){return s.nodebuffer?a.transformTo("nodebuffer",v).toString("utf-8"):(function(w){var T,g,x,P,_=w.length,B=new Array(2*_);for(T=g=0;T<_;)if((x=w[T++])<128)B[g++]=x;else if(4<(P=f[x]))B[g++]=65533,T+=P-1;else{for(x&=P===2?31:P===3?15:7;1>10&1023,B[g++]=56320|1023&x)}return B.length!==g&&(B.subarray?B=B.subarray(0,g):B.length=g),a.applyFromCharCode(B)})(v=a.transformTo(s.uint8array?"uint8array":"array",v))},a.inherits(b,u),b.prototype.processChunk=function(v){var w=a.transformTo(s.uint8array?"uint8array":"array",v.data);if(this.leftOver&&this.leftOver.length){if(s.uint8array){var T=w;(w=new Uint8Array(T.length+this.leftOver.length)).set(this.leftOver,0),w.set(T,this.leftOver.length)}else w=this.leftOver.concat(w);this.leftOver=null}var g=(function(P,_){var B;for((_=_||P.length)>P.length&&(_=P.length),B=_-1;0<=B&&(192&P[B])==128;)B--;return B<0||B===0?_:B+f[P[B]]>_?B:_})(w),x=w;g!==w.length&&(s.uint8array?(x=w.subarray(0,g),this.leftOver=w.subarray(g,w.length)):(x=w.slice(0,g),this.leftOver=w.slice(g,w.length))),this.push({data:m.utf8decode(x),meta:v.meta})},b.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:m.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},m.Utf8DecodeWorker=b,a.inherits(S,u),S.prototype.processChunk=function(v){this.push({data:m.utf8encode(v.data),meta:v.meta})},m.Utf8EncodeWorker=S},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(d,l,m){var a=d("./support"),s=d("./base64"),h=d("./nodejsUtils"),u=d("./external");function f(T){return T}function r(T,g){for(var x=0;x>8;this.dir=!!(16&this.externalFileAttributes),v==0&&(this.dosPermissions=63&this.externalFileAttributes),v==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var v=a(this.extraFields[1].value);this.uncompressedSize===s.MAX_VALUE_32BITS&&(this.uncompressedSize=v.readInt(8)),this.compressedSize===s.MAX_VALUE_32BITS&&(this.compressedSize=v.readInt(8)),this.localHeaderOffset===s.MAX_VALUE_32BITS&&(this.localHeaderOffset=v.readInt(8)),this.diskNumberStart===s.MAX_VALUE_32BITS&&(this.diskNumberStart=v.readInt(4))}},readExtraFields:function(v){var w,T,g,x=v.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});v.index+4>>6:(v<65536?S[g++]=224|v>>>12:(S[g++]=240|v>>>18,S[g++]=128|v>>>12&63),S[g++]=128|v>>>6&63),S[g++]=128|63&v);return S},m.buf2binstring=function(b){return r(b,b.length)},m.binstring2buf=function(b){for(var S=new a.Buf8(b.length),v=0,w=S.length;v>10&1023,P[w++]=56320|1023&T)}return r(P,w)},m.utf8border=function(b,S){var v;for((S=S||b.length)>b.length&&(S=b.length),v=S-1;0<=v&&(192&b[v])==128;)v--;return v<0||v===0?S:v+u[b[v]]>S?v:S}},{"./common":41}],43:[function(d,l,m){l.exports=function(a,s,h,u){for(var f=65535&a,r=a>>>16&65535,b=0;h!==0;){for(h-=b=2e3>>1:s>>>1;h[u]=s}return h})();l.exports=function(s,h,u,f){var r=a,b=f+u;s^=-1;for(var S=f;S>>8^r[255&(s^h[S])];return-1^s}},{}],46:[function(d,l,m){var a,s=d("../utils/common"),h=d("./trees"),u=d("./adler32"),f=d("./crc32"),r=d("./messages"),b=-2,S=258,v=262,w=113;function T(N,Y){return N.msg=r[Y],Y}function g(N){return(N<<1)-(4N.avail_out&&(tt=N.avail_out),tt!==0&&(s.arraySet(N.output,Y.pending_buf,Y.pending_out,tt,N.next_out),N.next_out+=tt,Y.pending_out+=tt,N.total_out+=tt,N.avail_out-=tt,Y.pending-=tt,Y.pending===0&&(Y.pending_out=0))}function _(N,Y){h._tr_flush_block(N,0<=N.block_start?N.block_start:-1,N.strstart-N.block_start,Y),N.block_start=N.strstart,P(N.strm)}function B(N,Y){N.pending_buf[N.pending++]=Y}function k(N,Y){N.pending_buf[N.pending++]=Y>>>8&255,N.pending_buf[N.pending++]=255&Y}function R(N,Y){var tt,H,rt=N.max_chain_length,ct=N.strstart,st=N.prev_length,at=N.nice_match,ht=N.strstart>N.w_size-v?N.strstart-(N.w_size-v):0,lt=N.window,O=N.w_mask,D=N.prev,j=N.strstart+S,Q=lt[ct+st-1],J=lt[ct+st];N.prev_length>=N.good_match&&(rt>>=2),at>N.lookahead&&(at=N.lookahead);do if(lt[(tt=Y)+st]===J&<[tt+st-1]===Q&<[tt]===lt[ct]&<[++tt]===lt[ct+1]){ct+=2,tt++;do;while(lt[++ct]===lt[++tt]&<[++ct]===lt[++tt]&<[++ct]===lt[++tt]&<[++ct]===lt[++tt]&<[++ct]===lt[++tt]&<[++ct]===lt[++tt]&<[++ct]===lt[++tt]&<[++ct]===lt[++tt]&&ctht&&--rt!=0);return st<=N.lookahead?st:N.lookahead}function F(N){var Y,tt,H,rt,ct,st,at,ht,lt,O,D=N.w_size;do{if(rt=N.window_size-N.lookahead-N.strstart,N.strstart>=D+(D-v)){for(s.arraySet(N.window,N.window,D,D,0),N.match_start-=D,N.strstart-=D,N.block_start-=D,Y=tt=N.hash_size;H=N.head[--Y],N.head[Y]=D<=H?H-D:0,--tt;);for(Y=tt=D;H=N.prev[--Y],N.prev[Y]=D<=H?H-D:0,--tt;);rt+=D}if(N.strm.avail_in===0)break;if(st=N.strm,at=N.window,ht=N.strstart+N.lookahead,O=void 0,(lt=rt)<(O=st.avail_in)&&(O=lt),tt=O===0?0:(st.avail_in-=O,s.arraySet(at,st.input,st.next_in,O,ht),st.state.wrap===1?st.adler=u(st.adler,at,O,ht):st.state.wrap===2&&(st.adler=f(st.adler,at,O,ht)),st.next_in+=O,st.total_in+=O,O),N.lookahead+=tt,N.lookahead+N.insert>=3)for(ct=N.strstart-N.insert,N.ins_h=N.window[ct],N.ins_h=(N.ins_h<=3&&(N.ins_h=(N.ins_h<=3)if(H=h._tr_tally(N,N.strstart-N.match_start,N.match_length-3),N.lookahead-=N.match_length,N.match_length<=N.max_lazy_match&&N.lookahead>=3){for(N.match_length--;N.strstart++,N.ins_h=(N.ins_h<=3&&(N.ins_h=(N.ins_h<=3&&N.match_length<=N.prev_length){for(rt=N.strstart+N.lookahead-3,H=h._tr_tally(N,N.strstart-1-N.prev_match,N.prev_length-3),N.lookahead-=N.prev_length-1,N.prev_length-=2;++N.strstart<=rt&&(N.ins_h=(N.ins_h<N.pending_buf_size-5&&(tt=N.pending_buf_size-5);;){if(N.lookahead<=1){if(F(N),N.lookahead===0&&Y===0)return 1;if(N.lookahead===0)break}N.strstart+=N.lookahead,N.lookahead=0;var H=N.block_start+tt;if((N.strstart===0||N.strstart>=H)&&(N.lookahead=N.strstart-H,N.strstart=H,_(N,!1),N.strm.avail_out===0)||N.strstart-N.block_start>=N.w_size-v&&(_(N,!1),N.strm.avail_out===0))return 1}return N.insert=0,Y===4?(_(N,!0),N.strm.avail_out===0?3:4):(N.strstart>N.block_start&&(_(N,!1),N.strm.avail_out),1)}),new U(4,4,8,4,A),new U(4,5,16,8,A),new U(4,6,32,32,A),new U(4,4,16,16,G),new U(8,16,32,32,G),new U(8,16,128,128,G),new U(8,32,128,256,G),new U(32,128,258,1024,G),new U(32,258,258,4096,G)],m.deflateInit=function(N,Y){return $(N,Y,8,15,8,0)},m.deflateInit2=$,m.deflateReset=W,m.deflateResetKeep=z,m.deflateSetHeader=function(N,Y){return N&&N.state?N.state.wrap!==2?b:(N.state.gzhead=Y,0):b},m.deflate=function(N,Y){var tt,H,rt,ct;if(!N||!N.state||5>8&255),B(H,H.gzhead.time>>16&255),B(H,H.gzhead.time>>24&255),B(H,H.level===9?2:2<=H.strategy||H.level<2?4:0),B(H,255&H.gzhead.os),H.gzhead.extra&&H.gzhead.extra.length&&(B(H,255&H.gzhead.extra.length),B(H,H.gzhead.extra.length>>8&255)),H.gzhead.hcrc&&(N.adler=f(N.adler,H.pending_buf,H.pending,0)),H.gzindex=0,H.status=69):(B(H,0),B(H,0),B(H,0),B(H,0),B(H,0),B(H,H.level===9?2:2<=H.strategy||H.level<2?4:0),B(H,3),H.status=w);else{var st=8+(H.w_bits-8<<4)<<8;st|=(2<=H.strategy||H.level<2?0:H.level<6?1:H.level===6?2:3)<<6,H.strstart!==0&&(st|=32),st+=31-st%31,H.status=w,k(H,st),H.strstart!==0&&(k(H,N.adler>>>16),k(H,65535&N.adler)),N.adler=1}if(H.status===69)if(H.gzhead.extra){for(rt=H.pending;H.gzindex<(65535&H.gzhead.extra.length)&&(H.pending!==H.pending_buf_size||(H.gzhead.hcrc&&H.pending>rt&&(N.adler=f(N.adler,H.pending_buf,H.pending-rt,rt)),P(N),rt=H.pending,H.pending!==H.pending_buf_size));)B(H,255&H.gzhead.extra[H.gzindex]),H.gzindex++;H.gzhead.hcrc&&H.pending>rt&&(N.adler=f(N.adler,H.pending_buf,H.pending-rt,rt)),H.gzindex===H.gzhead.extra.length&&(H.gzindex=0,H.status=73)}else H.status=73;if(H.status===73)if(H.gzhead.name){rt=H.pending;do{if(H.pending===H.pending_buf_size&&(H.gzhead.hcrc&&H.pending>rt&&(N.adler=f(N.adler,H.pending_buf,H.pending-rt,rt)),P(N),rt=H.pending,H.pending===H.pending_buf_size)){ct=1;break}ct=H.gzindexrt&&(N.adler=f(N.adler,H.pending_buf,H.pending-rt,rt)),ct===0&&(H.gzindex=0,H.status=91)}else H.status=91;if(H.status===91)if(H.gzhead.comment){rt=H.pending;do{if(H.pending===H.pending_buf_size&&(H.gzhead.hcrc&&H.pending>rt&&(N.adler=f(N.adler,H.pending_buf,H.pending-rt,rt)),P(N),rt=H.pending,H.pending===H.pending_buf_size)){ct=1;break}ct=H.gzindexrt&&(N.adler=f(N.adler,H.pending_buf,H.pending-rt,rt)),ct===0&&(H.status=103)}else H.status=103;if(H.status===103&&(H.gzhead.hcrc?(H.pending+2>H.pending_buf_size&&P(N),H.pending+2<=H.pending_buf_size&&(B(H,255&N.adler),B(H,N.adler>>8&255),N.adler=0,H.status=w)):H.status=w),H.pending!==0){if(P(N),N.avail_out===0)return H.last_flush=-1,0}else if(N.avail_in===0&&g(Y)<=g(tt)&&Y!==4)return T(N,-5);if(H.status===666&&N.avail_in!==0)return T(N,-5);if(N.avail_in!==0||H.lookahead!==0||Y!==0&&H.status!==666){var at=H.strategy===2?(function(ht,lt){for(var O;;){if(ht.lookahead===0&&(F(ht),ht.lookahead===0)){if(lt===0)return 1;break}if(ht.match_length=0,O=h._tr_tally(ht,0,ht.window[ht.strstart]),ht.lookahead--,ht.strstart++,O&&(_(ht,!1),ht.strm.avail_out===0))return 1}return ht.insert=0,lt===4?(_(ht,!0),ht.strm.avail_out===0?3:4):ht.last_lit&&(_(ht,!1),ht.strm.avail_out===0)?1:2})(H,Y):H.strategy===3?(function(ht,lt){for(var O,D,j,Q,J=ht.window;;){if(ht.lookahead<=S){if(F(ht),ht.lookahead<=S&<===0)return 1;if(ht.lookahead===0)break}if(ht.match_length=0,ht.lookahead>=3&&0ht.lookahead&&(ht.match_length=ht.lookahead)}if(ht.match_length>=3?(O=h._tr_tally(ht,1,ht.match_length-3),ht.lookahead-=ht.match_length,ht.strstart+=ht.match_length,ht.match_length=0):(O=h._tr_tally(ht,0,ht.window[ht.strstart]),ht.lookahead--,ht.strstart++),O&&(_(ht,!1),ht.strm.avail_out===0))return 1}return ht.insert=0,lt===4?(_(ht,!0),ht.strm.avail_out===0?3:4):ht.last_lit&&(_(ht,!1),ht.strm.avail_out===0)?1:2})(H,Y):a[H.level].func(H,Y);if(at!==3&&at!==4||(H.status=666),at===1||at===3)return N.avail_out===0&&(H.last_flush=-1),0;if(at===2&&(Y===1?h._tr_align(H):Y!==5&&(h._tr_stored_block(H,0,0,!1),Y===3&&(x(H.head),H.lookahead===0&&(H.strstart=0,H.block_start=0,H.insert=0))),P(N),N.avail_out===0))return H.last_flush=-1,0}return Y!==4?0:H.wrap<=0?1:(H.wrap===2?(B(H,255&N.adler),B(H,N.adler>>8&255),B(H,N.adler>>16&255),B(H,N.adler>>24&255),B(H,255&N.total_in),B(H,N.total_in>>8&255),B(H,N.total_in>>16&255),B(H,N.total_in>>24&255)):(k(H,N.adler>>>16),k(H,65535&N.adler)),P(N),0=tt.w_size&&(ct===0&&(x(tt.head),tt.strstart=0,tt.block_start=0,tt.insert=0),lt=new s.Buf8(tt.w_size),s.arraySet(lt,Y,O-tt.w_size,tt.w_size,0),Y=lt,O=tt.w_size),st=N.avail_in,at=N.next_in,ht=N.input,N.avail_in=O,N.next_in=0,N.input=Y,F(tt);tt.lookahead>=3;){for(H=tt.strstart,rt=tt.lookahead-2;tt.ins_h=(tt.ins_h<>>=G=A>>>24,_-=G,(G=A>>>16&255)==0)N[r++]=65535&A;else{if(!(16&G)){if(!(64&G)){A=B[(65535&A)+(P&(1<>>=G,_-=G),_<15&&(P+=$[u++]<<_,_+=8,P+=$[u++]<<_,_+=8),A=k[P&F];i:for(;;){if(P>>>=G=A>>>24,_-=G,!(16&(G=A>>>16&255))){if(!(64&G)){A=k[(65535&A)+(P&(1<>>=G,_-=G,(G=r-b)>3,P&=(1<<(_-=U<<3))-1,a.next_in=u,a.next_out=r,a.avail_in=u>>24&255)+(R>>>8&65280)+((65280&R)<<8)+((255&R)<<24)}function S(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new a.Buf16(320),this.work=new a.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function v(R){var F;return R&&R.state?(F=R.state,R.total_in=R.total_out=F.total=0,R.msg="",F.wrap&&(R.adler=1&F.wrap),F.mode=1,F.last=0,F.havedict=0,F.dmax=32768,F.head=null,F.hold=0,F.bits=0,F.lencode=F.lendyn=new a.Buf32(852),F.distcode=F.distdyn=new a.Buf32(592),F.sane=1,F.back=-1,0):r}function w(R){var F;return R&&R.state?((F=R.state).wsize=0,F.whave=0,F.wnext=0,v(R)):r}function T(R,F){var A,G;return R&&R.state?(G=R.state,F<0?(A=0,F=-F):(A=1+(F>>4),F<48&&(F&=15)),F&&(F<8||15=C.wsize?(a.arraySet(C.window,F,A-C.wsize,C.wsize,0),C.wnext=0,C.whave=C.wsize):(G<(U=C.wsize-C.wnext)&&(U=G),a.arraySet(C.window,F,A-G,U,C.wnext),(G-=U)?(a.arraySet(C.window,F,A-G,G,0),C.wnext=G,C.whave=C.wsize):(C.wnext+=U,C.wnext===C.wsize&&(C.wnext=0),C.whave>>8&255,A.check=h(A.check,dt,2,0),Y=N=0,A.mode=2;break}if(A.flags=0,A.head&&(A.head.done=!1),!(1&A.wrap)||(((255&N)<<8)+(N>>8))%31){R.msg="incorrect header check",A.mode=30;break}if((15&N)!=8){R.msg="unknown compression method",A.mode=30;break}if(Y-=4,Q=8+(15&(N>>>=4)),A.wbits===0)A.wbits=Q;else if(Q>A.wbits){R.msg="invalid window size",A.mode=30;break}A.dmax=1<>8&1),512&A.flags&&(dt[0]=255&N,dt[1]=N>>>8&255,A.check=h(A.check,dt,2,0)),Y=N=0,A.mode=3;case 3:for(;Y<32;){if(W===0)break t;W--,N+=G[C++]<>>8&255,dt[2]=N>>>16&255,dt[3]=N>>>24&255,A.check=h(A.check,dt,4,0)),Y=N=0,A.mode=4;case 4:for(;Y<16;){if(W===0)break t;W--,N+=G[C++]<>8),512&A.flags&&(dt[0]=255&N,dt[1]=N>>>8&255,A.check=h(A.check,dt,2,0)),Y=N=0,A.mode=5;case 5:if(1024&A.flags){for(;Y<16;){if(W===0)break t;W--,N+=G[C++]<>>8&255,A.check=h(A.check,dt,2,0)),Y=N=0}else A.head&&(A.head.extra=null);A.mode=6;case 6:if(1024&A.flags&&(W<(rt=A.length)&&(rt=W),rt&&(A.head&&(Q=A.head.extra_len-A.length,A.head.extra||(A.head.extra=new Array(A.head.extra_len)),a.arraySet(A.head.extra,G,C,rt,Q)),512&A.flags&&(A.check=h(A.check,G,rt,C)),W-=rt,C+=rt,A.length-=rt),A.length))break t;A.length=0,A.mode=7;case 7:if(2048&A.flags){if(W===0)break t;for(rt=0;Q=G[C+rt++],A.head&&Q&&A.length<65536&&(A.head.name+=String.fromCharCode(Q)),Q&&rt>9&1,A.head.done=!0),R.adler=A.check=0,A.mode=12;break;case 10:for(;Y<32;){if(W===0)break t;W--,N+=G[C++]<>>=7&Y,Y-=7&Y,A.mode=27;break}for(;Y<3;){if(W===0)break t;W--,N+=G[C++]<>>=1)){case 0:A.mode=14;break;case 1:if(B(A),A.mode=20,F!==6)break;N>>>=2,Y-=2;break t;case 2:A.mode=17;break;case 3:R.msg="invalid block type",A.mode=30}N>>>=2,Y-=2;break;case 14:for(N>>>=7&Y,Y-=7&Y;Y<32;){if(W===0)break t;W--,N+=G[C++]<>>16^65535)){R.msg="invalid stored block lengths",A.mode=30;break}if(A.length=65535&N,Y=N=0,A.mode=15,F===6)break t;case 15:A.mode=16;case 16:if(rt=A.length){if(W>>=5,Y-=5,A.ndist=1+(31&N),N>>>=5,Y-=5,A.ncode=4+(15&N),N>>>=4,Y-=4,286>>=3,Y-=3}for(;A.have<19;)A.lens[mt[A.have++]]=0;if(A.lencode=A.lendyn,A.lenbits=7,q={bits:A.lenbits},J=f(0,A.lens,0,19,A.lencode,0,A.work,q),A.lenbits=q.bits,J){R.msg="invalid code lengths set",A.mode=30;break}A.have=0,A.mode=19;case 19:for(;A.have>>16&255,lt=65535&it,!((at=it>>>24)<=Y);){if(W===0)break t;W--,N+=G[C++]<>>=at,Y-=at,A.lens[A.have++]=lt;else{if(lt===16){for(et=at+2;Y>>=at,Y-=at,A.have===0){R.msg="invalid bit length repeat",A.mode=30;break}Q=A.lens[A.have-1],rt=3+(3&N),N>>>=2,Y-=2}else if(lt===17){for(et=at+3;Y>>=at)),N>>>=3,Y-=3}else{for(et=at+7;Y>>=at)),N>>>=7,Y-=7}if(A.have+rt>A.nlen+A.ndist){R.msg="invalid bit length repeat",A.mode=30;break}for(;rt--;)A.lens[A.have++]=Q}}if(A.mode===30)break;if(A.lens[256]===0){R.msg="invalid code -- missing end-of-block",A.mode=30;break}if(A.lenbits=9,q={bits:A.lenbits},J=f(1,A.lens,0,A.nlen,A.lencode,0,A.work,q),A.lenbits=q.bits,J){R.msg="invalid literal/lengths set",A.mode=30;break}if(A.distbits=6,A.distcode=A.distdyn,q={bits:A.distbits},J=f(2,A.lens,A.nlen,A.ndist,A.distcode,0,A.work,q),A.distbits=q.bits,J){R.msg="invalid distances set",A.mode=30;break}if(A.mode=20,F===6)break t;case 20:A.mode=21;case 21:if(6<=W&&258<=$){R.next_out=z,R.avail_out=$,R.next_in=C,R.avail_in=W,A.hold=N,A.bits=Y,u(R,H),z=R.next_out,U=R.output,$=R.avail_out,C=R.next_in,G=R.input,W=R.avail_in,N=A.hold,Y=A.bits,A.mode===12&&(A.back=-1);break}for(A.back=0;ht=(it=A.lencode[N&(1<>>16&255,lt=65535&it,!((at=it>>>24)<=Y);){if(W===0)break t;W--,N+=G[C++]<>O)])>>>16&255,lt=65535&it,!(O+(at=it>>>24)<=Y);){if(W===0)break t;W--,N+=G[C++]<>>=O,Y-=O,A.back+=O}if(N>>>=at,Y-=at,A.back+=at,A.length=lt,ht===0){A.mode=26;break}if(32&ht){A.back=-1,A.mode=12;break}if(64&ht){R.msg="invalid literal/length code",A.mode=30;break}A.extra=15&ht,A.mode=22;case 22:if(A.extra){for(et=A.extra;Y>>=A.extra,Y-=A.extra,A.back+=A.extra}A.was=A.length,A.mode=23;case 23:for(;ht=(it=A.distcode[N&(1<>>16&255,lt=65535&it,!((at=it>>>24)<=Y);){if(W===0)break t;W--,N+=G[C++]<>O)])>>>16&255,lt=65535&it,!(O+(at=it>>>24)<=Y);){if(W===0)break t;W--,N+=G[C++]<>>=O,Y-=O,A.back+=O}if(N>>>=at,Y-=at,A.back+=at,64&ht){R.msg="invalid distance code",A.mode=30;break}A.offset=lt,A.extra=15&ht,A.mode=24;case 24:if(A.extra){for(et=A.extra;Y>>=A.extra,Y-=A.extra,A.back+=A.extra}if(A.offset>A.dmax){R.msg="invalid distance too far back",A.mode=30;break}A.mode=25;case 25:if($===0)break t;if(rt=H-$,A.offset>rt){if((rt=A.offset-rt)>A.whave&&A.sane){R.msg="invalid distance too far back",A.mode=30;break}ct=rt>A.wnext?(rt-=A.wnext,A.wsize-rt):A.wnext-rt,rt>A.length&&(rt=A.length),st=A.window}else st=U,ct=z-A.offset,rt=A.length;for($F?(G=D[j+g[W]],at[ht+g[W]]):(G=96,0),P=1<>H)+(_-=P)]=A<<24|G<<16|U,_!==0;);for(P=1<>=1;if(P!==0?(st&=P-1,st+=P):st=0,W++,--lt[z]==0){if(z===N)break;z=b[S+g[W]]}if(Y>>7)]}function C(D,j){D.pending_buf[D.pending++]=255&j,D.pending_buf[D.pending++]=j>>>8&255}function z(D,j,Q){D.bi_valid>16-Q?(D.bi_buf|=j<>16-D.bi_valid,D.bi_valid+=Q-16):(D.bi_buf|=j<>>=1,Q<<=1,0<--j;);return Q>>>1}function N(D,j,Q){var J,q,et=new Array(16),it=0;for(J=1;J<=r;J++)et[J]=it=it+Q[J-1]<<1;for(q=0;q<=j;q++){var dt=D[2*q+1];dt!==0&&(D[2*q]=$(et[dt]++,dt))}}function Y(D){var j;for(j=0;j>1;1<=Q;Q--)rt(D,et,Q);for(q=mt;Q=D.heap[1],D.heap[1]=D.heap[D.heap_len--],rt(D,et,1),J=D.heap[1],D.heap[--D.heap_max]=Q,D.heap[--D.heap_max]=J,et[2*q]=et[2*Q]+et[2*J],D.depth[q]=(D.depth[Q]>=D.depth[J]?D.depth[Q]:D.depth[J])+1,et[2*Q+1]=et[2*J+1]=q,D.heap[1]=q++,rt(D,et,1),2<=D.heap_len;);D.heap[--D.heap_max]=D.heap[1],(function(Et,Dt){var Vt,Nt,It,Ct,zt,Xt,Ut=Dt.dyn_tree,Kt=Dt.max_code,qt=Dt.stat_desc.static_tree,Qt=Dt.stat_desc.has_stree,te=Dt.stat_desc.extra_bits,ie=Dt.stat_desc.extra_base,$t=Dt.stat_desc.max_length,ae=0;for(Ct=0;Ct<=r;Ct++)Et.bl_count[Ct]=0;for(Ut[2*Et.heap[Et.heap_max]+1]=0,Vt=Et.heap_max+1;Vt<573;Vt++)$t<(Ct=Ut[2*Ut[2*(Nt=Et.heap[Vt])+1]+1]+1)&&(Ct=$t,ae++),Ut[2*Nt+1]=Ct,Kt>=7;q>>=1)if(1&yt&&dt.dyn_ltree[2*mt]!==0)return 0;if(dt.dyn_ltree[18]!==0||dt.dyn_ltree[20]!==0||dt.dyn_ltree[26]!==0)return 1;for(mt=32;mt>>3,(et=D.static_len+3+7>>>3)<=q&&(q=et)):q=et=Q+5,Q+4<=q&&j!==-1?O(D,j,Q,J):D.strategy===4||et===q?(z(D,2+(J?1:0),3),ct(D,T,g)):(z(D,4+(J?1:0),3),(function(dt,mt,yt,Et){var Dt;for(z(dt,mt-257,5),z(dt,yt-1,5),z(dt,Et-4,4),Dt=0;Dt>>8&255,D.pending_buf[D.d_buf+2*D.last_lit+1]=255&j,D.pending_buf[D.l_buf+D.last_lit]=255&Q,D.last_lit++,j===0?D.dyn_ltree[2*Q]++:(D.matches++,j--,D.dyn_ltree[2*(P[Q]+h+1)]++,D.dyn_dtree[2*U(j)]++),D.last_lit===D.lit_bufsize-1},m._tr_align=function(D){z(D,2,3),W(D,256,T),(function(j){j.bi_valid===16?(C(j,j.bi_buf),j.bi_buf=0,j.bi_valid=0):8<=j.bi_valid&&(j.pending_buf[j.pending++]=255&j.bi_buf,j.bi_buf>>=8,j.bi_valid-=8)})(D)}},{"../utils/common":41}],53:[function(d,l,m){l.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(d,l,m){(function(a){(function(s){if(!s.setImmediate){var h,u,f,r,b=1,S={},v=!1,w=s.document,T=Object.getPrototypeOf&&Object.getPrototypeOf(s);T=T&&T.setTimeout?T:s,h={}.toString.call(s.process)==="[object process]"?function(_){process.nextTick(function(){x(_)})}:(function(){if(s.postMessage&&!s.importScripts){var _=!0,B=s.onmessage;return s.onmessage=function(){_=!1},s.postMessage("","*"),s.onmessage=B,_}})()?(r="setImmediate$"+Math.random()+"$",s.addEventListener?s.addEventListener("message",P,!1):s.attachEvent("onmessage",P),function(_){s.postMessage(r+_,"*")}):s.MessageChannel?((f=new MessageChannel).port1.onmessage=function(_){x(_.data)},function(_){f.port2.postMessage(_)}):w&&"onreadystatechange"in w.createElement("script")?(u=w.documentElement,function(_){var B=w.createElement("script");B.onreadystatechange=function(){x(_),B.onreadystatechange=null,u.removeChild(B),B=null},u.appendChild(B)}):function(_){setTimeout(x,0,_)},T.setImmediate=function(_){typeof _!="function"&&(_=new Function(""+_));for(var B=new Array(arguments.length-1),k=0;k"u"?a===void 0?this:a:self)}).call(this,p.g!==void 0?p.g:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)},3065(St,y,p){var d,l;(function(){d=function(){var m=function(){},a="undefined",s=typeof window!==a&&typeof window.navigator!==a&&/Trident\/|MSIE /.test(window.navigator.userAgent),h=["trace","debug","info","warn","error"],u={},f=null;function r(x,P){var _=x[P];if(typeof _.bind=="function")return _.bind(x);try{return Function.prototype.bind.call(_,x)}catch{return function(){return Function.prototype.apply.apply(_,[x,arguments])}}}function b(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function S(){for(var x=this.getLevel(),P=0;P=0&&z<=R.levels.SILENT)return z;throw new TypeError("log.setLevel() called with invalid level: "+C)}typeof x=="string"?F+=":"+x:typeof x=="symbol"&&(F=void 0),R.name=x,R.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},R.methodFactory=P||w,R.getLevel=function(){return k??B??_},R.setLevel=function(C,z){return k=G(C),z!==!1&&(function(W){var $=(h[W]||"silent").toUpperCase();if(typeof window!==a&&F){try{return void(window.localStorage[F]=$)}catch{}try{window.document.cookie=encodeURIComponent(F)+"="+$+";"}catch{}}})(k),S.call(R)},R.setDefaultLevel=function(C){B=G(C),A()||R.setLevel(C,!1)},R.resetLevel=function(){k=null,(function(){if(typeof window!==a&&F){try{window.localStorage.removeItem(F)}catch{}try{window.document.cookie=encodeURIComponent(F)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}})(),S.call(R)},R.enableAll=function(C){R.setLevel(R.levels.TRACE,C)},R.disableAll=function(C){R.setLevel(R.levels.SILENT,C)},R.rebuild=function(){if(f!==R&&(_=G(f.getLevel())),S.call(R),f===R)for(var C in u)u[C].rebuild()},_=G(f?f.getLevel():"WARN");var U=A();U!=null&&(k=G(U)),S.call(R)}(f=new T).getLogger=function(x){if(typeof x!="symbol"&&typeof x!="string"||x==="")throw new TypeError("You must supply a name when creating a logger.");var P=u[x];return P||(P=u[x]=new T(x,f.methodFactory)),P};var g=typeof window!==a?window.log:void 0;return f.noConflict=function(){return typeof window!==a&&window.log===f&&(window.log=g),f},f.getLoggers=function(){return u},f.default=f,f},(l=d.call(y,p,y,St))===void 0||(St.exports=l)})()},2561(St,y){Object.defineProperty(y,"__esModule",{value:!0}),y.Fraction=void 0;class p{static max(l,m){return l.RealValue>m.RealValue?l:m}static Equal(l,m){return l.wholeValue===m.wholeValue&&l.Denominator===m.Denominator&&l.Numerator===m.Numerator}static createFromFraction(l){return new p(l.numerator,l.denominator,l.wholeValue,!1)}static plus(l,m){const a=l.clone();return a.Add(m),a}static minus(l,m){const a=l.clone();return a.Sub(m),a}static multiply(l,m){return new p((l.wholeValue*l.denominator+l.numerator)*(m.wholeValue*m.denominator+m.numerator),l.denominator*m.denominator)}static greatestCommonDenominator(l,m){if(l===0)return m;if(m===1)return 1;for(;Math.abs(m)>=1&&Math.abs(l)>=1;)l>m?l-=m:m-=l;const a=Math.round(l);return Math.max(a,1)}constructor(l=0,m=1,a=0,s=!0){this.numerator=0,this.denominator=1,this.wholeValue=0,this.numerator=l,this.denominator=m,this.wholeValue=a,s&&this.simplify(),this.setRealValue()}toString(){let l=this.numerator+"/"+this.denominator;return this.wholeValue!==0&&(l=this.wholeValue+" "+l),l}clone(){return new p(this.numerator,this.denominator,this.wholeValue,!1)}get Numerator(){return this.numerator}set Numerator(l){this.numerator!==l&&(this.numerator=l,this.simplify(),this.setRealValue())}get Denominator(){return this.denominator}set Denominator(l){this.denominator!==l&&(this.denominator=l,this.numerator!==0&&this.simplify(),this.setRealValue())}get WholeValue(){return this.wholeValue}set WholeValue(l){this.wholeValue!==l&&(this.wholeValue=l,this.setRealValue())}GetExpandedNumerator(){return this.wholeValue*this.denominator+this.numerator}calculateNumberOfNeededDots(){let l=1,m=2;const a=this.GetExpandedNumerator();for(;ml;)m.Numerator++;if(this.numerator>this.denominator){const a=new p(this.numerator-1,this.denominator,this.wholeValue);for(;a.Denominator>l;)a.Numerator--;if(a.Denominatorp.maximumAllowedNumber){const a=this.denominator/p.maximumAllowedNumber;this.numerator=Math.round(this.numerator/a),this.denominator=Math.round(this.denominator/a)}if(this.numerator>p.maximumAllowedNumber){const a=this.numerator/p.maximumAllowedNumber;this.numerator=Math.round(this.numerator/a),this.denominator=Math.round(this.denominator/a)}}isOnBeat(l){const m=this.distanceFromBeat(l);return Math.abs(m)h.length-1&&(f=1),r<0&&(r=h.length+r,f=-1),[h[r],f]}static CalculateTransposedHalfTone(a,s){const h=a.fundamentalNote+a.AccidentalHalfTones+s;return l.WrapAroundCheck(h,12)}static WrapAroundCheck(a,s){let h=0;for(;a<0;)a+=s,h--;for(;a>=s;)a-=s,h++;return{overflow:h,halftone:a}}static calcFrequency(a){let s,h=0;if(a instanceof l){const u=a;h=u.octave-1,s=u.fundamentalNote-p.A+u.AccidentalHalfTones}else typeof a=="number"&&(s=a-57);return 440*Math.pow(2,h)*Math.pow(2,s/12)}static calcFractionalKey(a){return Math.log(a/440)/Math.LN10*l.halftoneFactor+57}static fromFrequency(a){const s=l.calcFractionalKey(a)+.5,h=Math.floor(s/12)-l.octXmlDiff,u=Math.floor(s)%12;let f=u,r=d.NONE;return this.pitchEnumValues.indexOf(f)===-1&&(f=u-1,r=d.SHARP),new l(f,h,r)}static fromHalftone(a){const s=Math.floor(a/12)-l.octXmlDiff,h=a%12;let u=h,f=d.NONE;return this.pitchEnumValues.indexOf(u)===-1&&(u=h-1,f=d.SHARP),new l(u,s,f)}static ceiling(a){let s=a%=12;return this.pitchEnumValues.indexOf(s)===-1&&(s=a+1),s}static floor(a){let s=a%=12;return this.pitchEnumValues.indexOf(s)===-1&&(s=a-1),s}constructor(a,s,h,u=void 0,f=!1,r=void 0){this.accidental=d.NONE,this.fundamentalNote=a,this.octave=s,this.accidental=h,this.accidentalXml=u,this.halfTone=a+12*(s+l.octXmlDiff)+l.HalfTonesFromAccidental(h),f||(this.frequency=l.calcFrequency(this)),this.OctaveShiftApplied=r}static HalfTonesFromAccidental(a){switch(a){case d.NONE:return 0;case d.SHARP:return 1;case d.FLAT:return-1;case d.NATURAL:return 0;case d.DOUBLESHARP:return 2;case d.DOUBLEFLAT:return-2;case d.TRIPLESHARP:return 3;case d.TRIPLEFLAT:return-3;case d.QUARTERTONESHARP:return .5;case d.QUARTERTONEFLAT:return-.5;case d.SLASHFLAT:return-.51;case d.THREEQUARTERSSHARP:return 1.5;case d.THREEQUARTERSFLAT:return-1.5;case d.SLASHQUARTERSHARP:return .0013;case d.SLASHSHARP:return .0014;case d.DOUBLESLASHFLAT:return-.0015;case d.SORI:return .0016;case d.KORON:return .0017;default:throw new Error("Unhandled AccidentalEnum value")}}static AccidentalFromHalfTones(a){switch(a){case 0:return d.NONE;case 1:return d.SHARP;case-1:return d.FLAT;case 2:return d.DOUBLESHARP;case-2:return d.DOUBLEFLAT;case 3:return d.TRIPLESHARP;case-3:return d.TRIPLEFLAT;case .5:return d.QUARTERTONESHARP;case-.5:return d.QUARTERTONEFLAT;case 1.5:return d.THREEQUARTERSSHARP;case-1.5:return d.THREEQUARTERSFLAT;default:return a>0&&a<1?d.QUARTERTONESHARP:a<0&&a>-1?d.QUARTERTONEFLAT:d.QUARTERTONESHARP}}static accidentalVexflow(a){let s;switch(a){case d.NATURAL:s="n";break;case d.FLAT:s="b";break;case d.SHARP:s="#";break;case d.DOUBLESHARP:s="##";break;case d.TRIPLESHARP:s="###";break;case d.DOUBLEFLAT:s="bb";break;case d.TRIPLEFLAT:s="bbs";break;case d.QUARTERTONESHARP:s="+";break;case d.QUARTERTONEFLAT:s="d";break;case d.SLASHFLAT:s="bs";break;case d.THREEQUARTERSSHARP:s="++";break;case d.THREEQUARTERSFLAT:s="db";break;case d.SLASHQUARTERSHARP:s="+-";break;case d.SLASHSHARP:s="++-";break;case d.DOUBLESLASHFLAT:s="bss";break;case d.SORI:s="o";break;case d.KORON:s="k"}return s}get AccidentalHalfTones(){return l.HalfTonesFromAccidental(this.accidental)}get Octave(){return this.octave}get FundamentalNote(){return this.fundamentalNote}get Accidental(){return this.accidental}get AccidentalXml(){return this.accidentalXml}get Frequency(){return this.frequency}static get OctaveXmlDifference(){return l.octXmlDiff}getHalfTone(){return this.halfTone}getTransposedPitch(a){if(a>12)throw new Error("rewrite this method to handle bigger octave changes or don't use is with bigger octave changes!");return a>0?this.getHigherPitchByTransposeFactor(a):a<0?this.getLowerPitchByTransposeFactor(-a):this}DoEnharmonicChange(){switch(this.accidental){case d.FLAT:case d.DOUBLEFLAT:this.fundamentalNote=this.getPreviousFundamentalNote(this.fundamentalNote),this.accidental=l.AccidentalFromHalfTones(this.halfTone-(this.fundamentalNote+12*(this.octave+l.octXmlDiff)));break;case d.SHARP:case d.DOUBLESHARP:this.fundamentalNote=this.getNextFundamentalNote(this.fundamentalNote),this.accidental=l.AccidentalFromHalfTones(this.halfTone-(this.fundamentalNote+12*(this.octave+l.octXmlDiff)));break;default:return}}ToString(){let a=l.accidentalVexflow(this.accidental);return a||(a=""),"Key: "+l.getNoteEnumString(this.fundamentalNote)+a+", Note: "+this.fundamentalNote+", octave: "+this.octave.toString()}ToStringShort(a=0){let s=l.accidentalVexflow(this.accidental);s||(s="");const h=this.octave+a;return l.getNoteEnumString(this.fundamentalNote)+s+h}get ToStringShortGet(){return this.ToStringShort(0)}OperatorEquals(a){const s=this;return!(!s||!a)&&s.FundamentalNote===a.FundamentalNote&&s.Octave===a.Octave&&s.Accidental===a.Accidental}OperatorNotEqual(a){return this!==a}OperatorFundamentalGreaterThan(a){const s=this;return s.Octave===a.Octave?s.FundamentalNote>a.FundamentalNote:s.Octave>a.Octave}OperatorFundamentalLessThan(a){const s=this;return s.Octave===a.Octave?s.FundamentalNotel.pitchEnumValues.length-1?(h=l.pitchEnumValues[s+a-l.pitchEnumValues.length],u++):h=l.pitchEnumValues[s+a],new l(h,u,d.NONE)}getLowerPitchByTransposeFactor(a){const s=l.pitchEnumValues.indexOf(this.fundamentalNote);let h,u=this.octave;return s-a<0?(h=l.pitchEnumValues[l.pitchEnumValues.length+s-a],u--):h=l.pitchEnumValues[s-a],new l(h,u,d.NONE)}getNextFundamentalNote(a){let s=l.pitchEnumValues.indexOf(a);return s=(s+1)%l.pitchEnumValues.length,l.pitchEnumValues[s]}getPreviousFundamentalNote(a){const s=l.pitchEnumValues.indexOf(a);return s>0?l.pitchEnumValues[s-1]:l.pitchEnumValues[l.pitchEnumValues.length-1]}}y.Pitch=l,l.pitchEnumValues=[p.C,p.D,p.E,p.F,p.G,p.A,p.B],l.halftoneFactor=12/(Math.LN2/Math.LN10),l.octXmlDiff=3},283(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.PlaybackSettings=void 0;const d=p(2561);class l{constructor(a=new d.Fraction,s=100){this.rhythm=a,this.beatsPerMinute=s,this.beatLengthInMilliseconds=6e4/s,this.beatRealValue=.25}static createFrom(a){return new l(a.Rhythm,a.BeatsPerMinute)}get BeatsPerMinute(){return this.beatsPerMinute}set BeatsPerMinute(a){this.beatsPerMinute=a,this.beatLengthInMilliseconds=6e4/this.beatsPerMinute}get Rhythm(){return this.rhythm}set Rhythm(a){this.rhythm=a}get BeatRealValue(){return this.beatRealValue}get BeatLengthInMilliseconds(){return this.beatLengthInMilliseconds}getDurationInMilliseconds(a){return(typeof a=="number"?a:a.RealValue)*this.BeatLengthInMilliseconds/this.beatRealValue}getDurationAsNoteDuration(a,s=1024){const h=a/this.BeatLengthInMilliseconds;let u=Math.floor(h);const f=new d.Fraction(u,4),r=h-u;return u=Math.round(r/(1/s)/4),r!==0&&u===0&&a>0&&(u=1),f.Add(new d.Fraction(u,s)),f}}y.PlaybackSettings=l},9409(St,y){Object.defineProperty(y,"__esModule",{value:!0}),y.PointF2D=void 0;class p{constructor(l=0,m=0){this.x=0,this.y=0,this.x=l,this.y=m}static get Empty(){return new p}static pointsAreEqual(l,m){return l.x===m.x&&l.y===m.y}ToString(){return"["+this.x+", "+this.y+"]"}}y.PointF2D=p},200(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.RectangleF2D=void 0;const d=p(6864),l=p(9409);class m{constructor(s,h,u,f){this.x=0,this.y=0,this.width=0,this.height=0,this.x=s,this.y=h,this.width=u,this.height=f}static createFromLocationAndSize(s,h){return new m(s.x,s.y,h.width,h.height)}get Location(){return new l.PointF2D(this.x,this.y)}get Size(){return new d.SizeF2D(this.width,this.height)}}y.RectangleF2D=m},6864(St,y){Object.defineProperty(y,"__esModule",{value:!0}),y.SizeF2D=void 0,y.SizeF2D=class{constructor(p=0,d=0){this.width=p,this.height=d}}},9735(St,y,p){var d=this&&this.__createBinding||(Object.create?function(m,a,s,h){h===void 0&&(h=s);var u=Object.getOwnPropertyDescriptor(a,s);u&&!("get"in u?!a.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return a[s]}}),Object.defineProperty(m,h,u)}:function(m,a,s,h){h===void 0&&(h=s),m[h]=a[s]}),l=this&&this.__exportStar||function(m,a){for(var s in m)s==="default"||Object.prototype.hasOwnProperty.call(a,s)||d(a,m,s)};Object.defineProperty(y,"__esModule",{value:!0}),l(p(2561),y),l(p(6904),y),l(p(8786),y),l(p(8705),y),l(p(8233),y),l(p(9409),y),l(p(200),y),l(p(6864),y)},4434(St,y){var p;Object.defineProperty(y,"__esModule",{value:!0}),y.ColoringModes=void 0,(function(d){d[d.XML=0]="XML",d[d.AutoColoring=1]="AutoColoring",d[d.CustomColorSet=2]="CustomColorSet"})(p||(y.ColoringModes=p={}))},4146(St,y){var p;Object.defineProperty(y,"__esModule",{value:!0}),y.DrawingParametersEnum=void 0,(function(d){d.allon="allon",d.compact="compact",d.compacttight="compacttight",d.default="default",d.leadsheet="leadsheet",d.preview="preview",d.thumbnail="thumbnail"})(p||(y.DrawingParametersEnum=p={}))},2570(St,y){var p;Object.defineProperty(y,"__esModule",{value:!0}),y.FontStyles=void 0,(function(d){d[d.Regular=0]="Regular",d[d.Bold=1]="Bold",d[d.Italic=2]="Italic",d[d.BoldItalic=3]="BoldItalic",d[d.Underlined=4]="Underlined"})(p||(y.FontStyles=p={}))},5951(St,y){var p;Object.defineProperty(y,"__esModule",{value:!0}),y.Fonts=void 0,(function(d){d[d.TimesNewRoman=0]="TimesNewRoman",d[d.Kokila=1]="Kokila"})(p||(y.Fonts=p={}))},7533(St,y){var p;Object.defineProperty(y,"__esModule",{value:!0}),y.TextAlignment=y.TextAlignmentEnum=void 0,(function(d){d[d.LeftTop=0]="LeftTop",d[d.LeftCenter=1]="LeftCenter",d[d.LeftBottom=2]="LeftBottom",d[d.CenterTop=3]="CenterTop",d[d.CenterCenter=4]="CenterCenter",d[d.CenterBottom=5]="CenterBottom",d[d.RightTop=6]="RightTop",d[d.RightCenter=7]="RightCenter",d[d.RightBottom=8]="RightBottom"})(p||(y.TextAlignmentEnum=p={})),y.TextAlignment=class{static IsLeft(d){return d===p.LeftTop||d===p.LeftCenter||d===p.LeftBottom}static IsCenterAligned(d){return d===p.CenterTop||d===p.CenterCenter||d===p.CenterBottom}static IsRight(d){return d===p.RightTop||d===p.RightCenter||d===p.RightBottom}}},2514(St,y){var p;Object.defineProperty(y,"__esModule",{value:!0}),y.TieTypes=void 0,(function(d){d.SIMPLE="",d.HAMMERON="H",d.PULLOFF="P",d.SLIDE="S",d.TAPPING="T"})(p||(y.TieTypes=p={}))},2257(St,y,p){var d=this&&this.__createBinding||(Object.create?function(m,a,s,h){h===void 0&&(h=s);var u=Object.getOwnPropertyDescriptor(a,s);u&&!("get"in u?!a.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return a[s]}}),Object.defineProperty(m,h,u)}:function(m,a,s,h){h===void 0&&(h=s),m[h]=a[s]}),l=this&&this.__exportStar||function(m,a){for(var s in m)s==="default"||Object.prototype.hasOwnProperty.call(a,s)||d(a,m,s)};Object.defineProperty(y,"__esModule",{value:!0}),l(p(4434),y),l(p(4146),y),l(p(2570),y),l(p(5951),y),l(p(7533),y),l(p(2514),y)},6888(St,y,p){var d=this&&this.__importDefault||function(h){return h&&h.__esModule?h:{default:h}};Object.defineProperty(y,"__esModule",{value:!0}),y.MXLHelper=y.MXLFile=void 0;const l=p(3902),m=d(p(1710)),a=d(p(3065));y.MXLFile=class{constructor(h){this.unzipSuccessful=!1,this.blob=h}async tryUnzip(){this.zipFile=new m.default;try{return this.unzipSuccessful=!0,await this.zipFile.loadAsync(this.blob),!0}catch{return this.unzipSuccessful=!1,!1}}getXmlString(){return s.jszipToXMLstring(this.zipFile)}};class s{static MXLtoIXmlElement(u){return this.MXLtoXMLstring(u).then(f=>{const r=new DOMParser().parseFromString(f,"text/xml"),b=new l.IXmlElement(r.documentElement);return Promise.resolve(b)},f=>{throw new Error("extractSheetFromMxl: "+f.message)})}static async jszipToXMLstring(u){let f=await u.file("META-INF/container.xml").async("text");if(!f.startsWith("<")){const S=await u.file("META-INF/container.xml").async("uint8array");f=new TextDecoder("utf-8").decode(S)}if(!f.startsWith("<")){const S=await u.file("META-INF/container.xml").async("uint8array");f=new TextDecoder("utf-16").decode(S)}const r=new DOMParser().parseFromString(f,"text/xml").getElementsByTagName("rootfile")[0].getAttribute("full-path"),b=await u.file(r).async("text");if(!b.substring(0,1).startsWith("<")){const S=await u.file(r).async("uint8array");return new TextDecoder("utf-16").decode(S)}return b}static MXLtoXMLstring(u){const f=new m.default;return f.loadAsync(u).then(async r=>this.jszipToXMLstring(f),r=>{throw a.default.error(r),r})}}y.MXLHelper=s},3902(St,y){Object.defineProperty(y,"__esModule",{value:!0}),y.IXmlElement=void 0;class p{constructor(l){if(this.hasAttributes=!1,!l)throw new Error("IXmlElement: expected Element, got undefined");this.elem=l,this.name=l.nodeName.toLowerCase(),l.hasAttributes()&&(this.hasAttributes=!0,this.firstAttribute=l.attributes[0]),this.hasElements=l.hasChildNodes(),l.childNodes.length===1&&l.childNodes[0].nodeType===Node.TEXT_NODE?this.value=l.childNodes[0].nodeValue:this.value=""}attribute(l){return this.elem.attributes.getNamedItem(l)}attributes(){if(!this.attrs){const l=this.elem.attributes,m=[];for(let a=0;a0){let a;for(let s=0,h=m.length;s=0;if(this.currentInMeasureNoteAlterationsDict.containsKey(u))if(r&&this.currentAlterationsComparedToKeyInstructionList.splice(this.currentAlterationsComparedToKeyInstructionList.indexOf(u),1),this.currentInMeasureNoteAlterationsDict.getValue(u)!==h.AccidentalHalfTones){this.keySignatureNoteAlterationsDict.containsKey(u)&&this.keySignatureNoteAlterationsDict.getValue(u)!==h.AccidentalHalfTones?(this.currentAlterationsComparedToKeyInstructionList.push(u),this.currentInMeasureNoteAlterationsDict.setValue(u,h.AccidentalHalfTones)):h.Accidental!==d.AccidentalEnum.NONE?this.keySignatureNoteAlterationsDict.containsKey(u)?this.currentInMeasureNoteAlterationsDict.setValue(u,this.keySignatureNoteAlterationsDict.getValue(u)):this.currentInMeasureNoteAlterationsDict.remove(u):this.currentInMeasureNoteAlterationsDict.setValue(u,h.AccidentalHalfTones);const b=this.currentInMeasureNoteAlterationsDict.getValue(u);if(h.Accidental===d.AccidentalEnum.NONE&&(h=Math.abs(b)===.5?new l.Pitch(h.FundamentalNote,h.Octave,d.AccidentalEnum.NONE,void 0,!1,h.OctaveShiftApplied):new l.Pitch(h.FundamentalNote,h.Octave,d.AccidentalEnum.NATURAL,void 0,!1,h.OctaveShiftApplied)),this.isAlterAmbiguousAccidental(h.Accidental)&&!h.AccidentalXml)return;a.MusicSheetCalculator.symbolFactory.addGraphicalAccidental(s,h)}else h.AccidentalXml&&this.Transpose===0&&!r&&a.MusicSheetCalculator.symbolFactory.addGraphicalAccidental(s,h);else if(h.Accidental!==d.AccidentalEnum.NONE){if(r||this.currentAlterationsComparedToKeyInstructionList.push(u),this.currentInMeasureNoteAlterationsDict.setValue(u,h.AccidentalHalfTones),this.isAlterAmbiguousAccidental(h.Accidental)&&!h.AccidentalXml)return;a.MusicSheetCalculator.symbolFactory.addGraphicalAccidental(s,h)}else r&&(h=new l.Pitch(h.FundamentalNote,h.Octave,d.AccidentalEnum.NATURAL,void 0,!1,h.OctaveShiftApplied),this.currentAlterationsComparedToKeyInstructionList.splice(this.currentAlterationsComparedToKeyInstructionList.indexOf(u),1),a.MusicSheetCalculator.symbolFactory.addGraphicalAccidental(s,h))}isAlterAmbiguousAccidental(s){return s===d.AccidentalEnum.SLASHFLAT||s===d.AccidentalEnum.QUARTERTONEFLAT}reactOnKeyInstructionChange(){const s=this.activeKeyInstruction.AlteratedNotes;let h;h=this.activeKeyInstruction.Key>0?d.AccidentalEnum.SHARP:d.AccidentalEnum.FLAT,this.keySignatureNoteAlterationsDict.clear(),this.currentAlterationsComparedToKeyInstructionList.length=0;for(let u=-9;u<9;u++)for(let f=0;fthis.borderLeft?this.borderLeft:this.borderMarginLeft}set BorderMarginLeft(r){this.borderMarginLeft=r,this.calculateMarginRectangle()}get BorderMarginRight(){return this.borderMarginRightthis.borderTop?this.borderTop:this.borderMarginTop}set BorderMarginTop(r){this.borderMarginTop=r,this.calculateMarginRectangle()}get BorderMarginBottom(){return this.borderMarginBottom-1&&this.parent.ChildElements.splice(b,1)}this.parent=r,this.parent.ChildElements.indexOf(this)>-1?l.default.error("BoundingBox of "+this.dataObject.constructor.name+" already in children list of "+this.parent.dataObject.constructor.name+"'s BoundingBox"):this.parent.ChildElements.push(this)}get DataObject(){return this.dataObject}get Center(){return new a.PointF2D(this.RelativePosition.x+(this.BorderMarginRight+this.BorderMarginLeft),this.RelativePosition.y+(this.BorderMarginBottom+this.BorderMarginTop))}setAbsolutePositionFromParent(){this.parent?(this.absolutePosition.x=this.parent.AbsolutePosition.x+this.relativePosition.x,this.absolutePosition.y=this.parent.AbsolutePosition.y+this.relativePosition.y):this.absolutePosition=this.relativePosition}calculateAbsolutePosition(){this.absolutePosition.x=this.relativePosition.x,this.absolutePosition.y=this.relativePosition.y;let r=this.parent;for(;r;)this.absolutePosition.x+=r.relativePosition.x,this.absolutePosition.y+=r.relativePosition.y,r=r.parent}calculateAbsolutePositionsRecursiveWithoutTopelement(){this.absolutePosition.x=0,this.absolutePosition.y=0;for(let r=0,b=this.ChildElements.length;r.001;break;case f.Up:case f.Down:v=this.relativePosition.y,r.calculateMarginPositionAlongDirection(this,b),w=Math.abs(v-this.relativePosition.y)>.001;break;default:throw new m.ArgumentOutOfRangeException("direction")}while(w)}collisionDetection(r){const b=Math.min(this.AbsolutePosition.x+this.borderRight,r.absolutePosition.x+r.borderRight)-Math.max(this.AbsolutePosition.x+this.borderLeft,r.absolutePosition.x+r.borderLeft),S=Math.min(this.AbsolutePosition.y+this.borderBottom,r.absolutePosition.y+r.borderBottom)-Math.max(this.AbsolutePosition.y+this.borderTop,r.absolutePosition.y+r.borderTop);return b>=0&&S>=0}liesInsideBorders(r){const b=this.AbsolutePosition.x+this.borderLeft<=r.absolutePosition.x+r.borderLeft&&r.absolutePosition.x+r.borderLeft<=this.AbsolutePosition.x+this.borderRight,S=this.AbsolutePosition.x+this.borderLeft<=r.absolutePosition.x+r.borderRight&&r.absolutePosition.x+r.borderRight<=this.AbsolutePosition.x+this.borderRight;if(b&&S){const v=this.AbsolutePosition.y+this.borderTop<=r.absolutePosition.y+r.borderTop&&r.absolutePosition.y+r.borderTop<=this.AbsolutePosition.y+this.borderBottom,w=this.AbsolutePosition.y+this.borderTop<=r.absolutePosition.y+r.borderBottom&&r.absolutePosition.y+r.borderBottom<=this.AbsolutePosition.y+this.borderBottom;if(v&&w)return!0}return!1}pointLiesInsideBorders(r){return this.AbsolutePosition.x+this.borderLeft<=r.x&&r.x<=this.AbsolutePosition.x+this.borderRight&&this.AbsolutePosition.y+this.borderTop<=r.y&&r.y<=this.AbsolutePosition.y+this.borderBottom}marginCollisionDetection(r){const b=Math.min(this.AbsolutePosition.x+this.borderMarginRight,r.absolutePosition.x+r.borderMarginRight)-Math.max(this.AbsolutePosition.x+this.borderMarginLeft,r.absolutePosition.x+r.borderMarginLeft),S=Math.min(this.AbsolutePosition.y+this.borderMarginBottom,r.absolutePosition.y+r.borderMarginBottom)-Math.max(this.AbsolutePosition.y+this.borderMarginTop,r.absolutePosition.y+r.borderMarginTop);return b>0&&S>0}liesInsideMargins(r){const b=this.AbsolutePosition.x+this.borderMarginLeft<=r.absolutePosition.x+r.borderMarginLeft&&r.absolutePosition.x+r.borderMarginLeft<=this.AbsolutePosition.x+this.borderMarginRight,S=this.AbsolutePosition.x+this.borderMarginLeft<=r.absolutePosition.x+r.borderMarginRight&&r.absolutePosition.x+r.borderMarginRight<=this.AbsolutePosition.x+this.borderMarginRight;if(b&&S){const v=this.AbsolutePosition.y+this.borderMarginTop<=r.absolutePosition.y+r.borderMarginTop&&r.absolutePosition.y+r.borderMarginTop<=this.AbsolutePosition.y+this.borderMarginBottom,w=this.AbsolutePosition.y+this.borderMarginTop<=r.absolutePosition.y+r.borderMarginBottom&&r.absolutePosition.y+r.borderMarginBottom<=this.AbsolutePosition.y+this.borderMarginBottom;if(v&&w)return!0}return!1}pointLiesInsideMargins(r){return this.AbsolutePosition.x+this.borderMarginLeft<=r.x&&r.x<=this.AbsolutePosition.x+this.borderMarginRight&&this.AbsolutePosition.y+this.borderMarginTop<=r.y&&r.y<=this.AbsolutePosition.y+this.borderMarginBottom}computeNonOverlappingPosition(r,b,S){this.RelativePosition=new a.PointF2D(S.x,S.y),this.setAbsolutePositionFromParent();let v=0,w=!1;do switch(b){case f.Left:case f.Right:v=this.relativePosition.x,r.calculatePositionAlongDirection(this,b),w=Math.abs(v-this.relativePosition.x)>1e-4;break;case f.Up:case f.Down:v=this.relativePosition.y,r.calculatePositionAlongDirection(this,b),w=Math.abs(v-this.relativePosition.y)>1e-4;break;default:throw new m.ArgumentOutOfRangeException("direction")}while(w)}getClickedObjectOfType(r){const b=this.dataObject;if(this.pointLiesInsideBorders(r)&&b)return b;for(let S=0,v=this.childElements.length;S=this.SkyBottomLineWebGLMinMeasures&&(this.PreferredSkyBottomLineBatchCalculatorBackend=h.SkyBottomLineBatchCalculatorBackendType.WebGL)}applyDefaultColorMusic(x){this.DefaultColorMusic=x,this.DefaultColorNotehead=x,this.DefaultColorRest=x,this.DefaultColorStem=x,this.DefaultColorLabel=x,this.DefaultColorLyrics=x,this.DefaultColorTitle=x,this.LedgerLineColorDefault=x}addGraphicalNoteToNoteMap(x,P){x.NoteToGraphicalNoteObjectId=this.NoteToGraphicalNoteMapObjectCount,this.NoteToGraphicalNoteMap.setValue(x.NoteToGraphicalNoteObjectId,P),this.NoteToGraphicalNoteMapObjectCount++}GNote(x){return v.GraphicalNote.FromNote(x,this)}clearMusicSheetObjects(){this.NoteToGraphicalNoteMap=new f.Dictionary,this.NoteToGraphicalNoteMapObjectCount=0}resetChordAccidentalTexts(x,P){x.setValue(b.AccidentalEnum.SHARP,P?"♯":"#"),x.setValue(b.AccidentalEnum.FLAT,P?"♭":"b"),x.setValue(b.AccidentalEnum.DOUBLEFLAT,P?"𝄫":"bb"),x.setValue(b.AccidentalEnum.DOUBLESHARP,P?"𝄪":"x")}setChordSymbolLabelText(x,P){this.ChordSymbolLabelTexts.setValue(x,P)}resetChordSymbolLabelTexts(x){return x.setValue(S.ChordSymbolEnum.minor,"m"),x.setValue(S.ChordSymbolEnum.augmented,"aug"),x.setValue(S.ChordSymbolEnum.diminished,"dim"),x.setValue(S.ChordSymbolEnum.dominant,"7"),x.setValue(S.ChordSymbolEnum.majorseventh,"maj7"),x.setValue(S.ChordSymbolEnum.minorseventh,"m7"),x.setValue(S.ChordSymbolEnum.diminishedseventh,"dim7"),x.setValue(S.ChordSymbolEnum.augmentedseventh,"aug7"),x.setValue(S.ChordSymbolEnum.halfdiminished,`m7${this.ChordAccidentalTexts.getValue(b.AccidentalEnum.FLAT)}5`),x.setValue(S.ChordSymbolEnum.majorminor,"m(maj7)"),x.setValue(S.ChordSymbolEnum.majorsixth,"maj6"),x.setValue(S.ChordSymbolEnum.minorsixth,"m6"),x.setValue(S.ChordSymbolEnum.dominantninth,"9"),x.setValue(S.ChordSymbolEnum.majorninth,"maj9"),x.setValue(S.ChordSymbolEnum.minorninth,"m9"),x.setValue(S.ChordSymbolEnum.dominant11th,"11"),x.setValue(S.ChordSymbolEnum.major11th,"maj11"),x.setValue(S.ChordSymbolEnum.minor11th,"m11"),x.setValue(S.ChordSymbolEnum.dominant13th,"13"),x.setValue(S.ChordSymbolEnum.major13th,"maj13"),x.setValue(S.ChordSymbolEnum.minor13th,"m13"),x.setValue(S.ChordSymbolEnum.suspendedsecond,"sus2"),x.setValue(S.ChordSymbolEnum.suspendedfourth,"sus4"),x.setValue(S.ChordSymbolEnum.power,"5"),x.setValue(S.ChordSymbolEnum.none,"N.C."),x}addChordName(x,P,_,B,k){if(S.ChordSymbolEnum[P]!==void 0){const R={adds:_,alts:B,subs:k};this.CustomChords.push(S.CustomChord.createCustomChord(x,S.ChordSymbolEnum[P],R))}}renameChord(x,P){S.CustomChord.renameCustomChord(x,P,this.CustomChords)}resetChordNames(){const x=this.ChordAccidentalTexts.getValue(b.AccidentalEnum.SHARP),P=this.ChordAccidentalTexts.getValue(b.AccidentalEnum.FLAT);this.addChordName("alt","major",[`${x}5`,`${P}9`,`${x}9`],[`${P}5`],[]),this.addChordName("7alt","dominant",[`${x}5`,`${P}9`,`${x}9`],[`${P}5`],[]),this.addChordName("7sus4","dominant",["4"],[],["3"]),this.addChordName("7sus4","suspendedfourth",["7"],[],[]),this.addChordName("9sus4","dominantninth",["4"],[],["3"]),this.addChordName("9sus4","suspendedfourth",["9"],[],[]),this.addChordName("11sus4","dominant11th",["4"],[],["3"]),this.addChordName("11sus4","suspendedfourth",["11"],[],[]),this.addChordName("13sus4","dominant13th",["4"],[],["3"]),this.addChordName("13sus4","suspendedfourth",["13"],[],[]),this.addChordName("7sus2","dominant",["2"],[],["3"]),this.addChordName("7sus2","suspendedsecond",["7"],[],[]),this.addChordName(`m7${P}5`,"minorseventh",[],[`${P}5`],[]),this.addChordName("9sus2","dominantninth",["2"],[],["3"]),this.addChordName("9sus2","suspendedsecond",["9"],[],[]),this.addChordName("11sus2","dominant11th",["2"],[],["3"]),this.addChordName("11sus2","suspendedsecond",["11"],[],[]),this.addChordName("13sus2","dominant13th",["2"],[],["3"]),this.addChordName("13sus2","suspendedsecond",["13"],[],[]),this.addChordName("m(maj9)","majorminor",["9"],[],[]),this.addChordName("m(maj11)","majorminor",["11"],[],[]),this.addChordName("m(maj13)","majorminor",["13"],[],[]),this.addChordName("69","majorsixth",["9"],[],[]),this.addChordName("mi69","minorsixth",["9"],[],[])}calculateCurveParametersArrays(){this.TPower3=new Array(this.BezierCurveStepSize),this.OneMinusTPower3=new Array(this.BezierCurveStepSize),this.FactorOne=new Array(this.BezierCurveStepSize),this.FactorTwo=new Array(this.BezierCurveStepSize);for(let x=0;x0}get NotToBeRemoved(){return this.notToBeRemoved}set NotToBeRemoved(b){this.notToBeRemoved=b}get Lines(){return this.lines}get ContinuousDynamic(){return this.SourceExpression}updateSkyBottomLine(){var w;const b=this.parentStaffLine.SkyBottomLineCalculator,S=this.IsVerbal?this.label.PositionAndShape.RelativePosition.x+this.label.PositionAndShape.BorderMarginLeft:0,v=this.IsVerbal?this.label.PositionAndShape.RelativePosition.x+this.label.PositionAndShape.BorderMarginRight:0;switch(!this.IsSoftAccent&&!this.IsVerbal&&this.lines.length<2&&u.default.warn("Not enough lines for SkyBottomLine calculation"),this.IsVerbal||this.ContinuousDynamic.DynamicType!==m.ContDynamicEnum.crescendo&&this.ContinuousDynamic.DynamicType!==m.ContDynamicEnum.diminuendo&&u.default.warn("GraphicalContinuousDynamicExpression.updateSkyBottomLine(): unhandled continuous dynamic type. start measure: "+((w=this.startMeasure)==null?void 0:w.MeasureNumber)),this.Placement){case h.PlacementEnum.Above:if(this.IsSoftAccent)b.updateSkyLineWithWedge(this.lines[0].Start,this.lines[0].End),b.updateSkyLineWithWedge(this.lines[2].End,this.lines[2].Start),b.updateSkyLineWithLine(this.lines[0].End,this.lines[2].End,this.lines[0].End.y);else if(this.IsVerbal){const T=this.label.PositionAndShape.BorderMarginTop+this.label.PositionAndShape.RelativePosition.y;b.updateSkyLineInRange(S,v,T)}else this.ContinuousDynamic.DynamicType===m.ContDynamicEnum.crescendo?b.updateSkyLineWithWedge(this.lines[0].Start,this.lines[0].End):this.ContinuousDynamic.DynamicType===m.ContDynamicEnum.diminuendo&&b.updateSkyLineWithWedge(this.lines[0].End,this.lines[0].Start);break;case h.PlacementEnum.Below:if(this.IsVerbal){const T=this.label.PositionAndShape.BorderMarginBottom+this.label.PositionAndShape.RelativePosition.y;b.updateBottomLineInRange(S,v,T)}else this.ContinuousDynamic.DynamicType===m.ContDynamicEnum.crescendo?b.updateBottomLineWithWedge(this.lines[1].Start,this.lines[1].End):this.ContinuousDynamic.DynamicType===m.ContDynamicEnum.diminuendo&&b.updateBottomLineWithWedge(this.lines[1].End,this.lines[1].Start);break;default:u.default.error("Placement for GraphicalContinuousDynamicExpression is unknown")}}createCrescendoLines(b,S,v,w=this.rules.WedgeOpeningLength,T=this.rules.WedgeLineWidth){const g=new a.PointF2D(b,v),x=new a.PointF2D(S,v-w/2),P=new a.PointF2D(S,v+w/2);this.addWedgeLines(g,x,P,T)}createFirstHalfCrescendoLines(b,S,v,w=this.rules.WedgeMeasureEndOpeningLength,T=this.rules.WedgeLineWidth){const g=new a.PointF2D(b,v),x=new a.PointF2D(S,v-w/2),P=new a.PointF2D(S,v+w/2);this.addWedgeLines(g,x,P,T)}createSecondHalfCrescendoLines(b,S,v,w=this.rules.WedgeMeasureBeginOpeningLength,T=this.rules.WedgeOpeningLength,g=this.rules.WedgeLineWidth){const x=new a.PointF2D(b,v-w/2),P=new a.PointF2D(b,v+w/2),_=new a.PointF2D(S,v-T/2),B=new a.PointF2D(S,v+T/2);this.addDoubleLines(x,_,P,B,g)}recalculateCrescendoLines(b,S,v){const w=Math.abs(this.lines[0].Start.y-this.lines[1].Start.y)>1e-4;this.lines.clear(),w?this.createSecondHalfCrescendoLines(b,S,v):this.isSplittedPart?this.createFirstHalfCrescendoLines(b,S,v):this.createCrescendoLines(b,S,v)}createDiminuendoLines(b,S,v,w=this.rules.WedgeOpeningLength,T=this.rules.WedgeLineWidth){const g=new a.PointF2D(b,v-w/2),x=new a.PointF2D(b,v+w/2),P=new a.PointF2D(S,v);this.addWedgeLines(P,g,x,T)}createFirstHalfDiminuendoLines(b,S,v,w=this.rules.WedgeOpeningLength,T=this.rules.WedgeMeasureEndOpeningLength,g=this.rules.WedgeLineWidth){const x=new a.PointF2D(b,v-w/2),P=new a.PointF2D(b,v+w/2),_=new a.PointF2D(S,v-T/2),B=new a.PointF2D(S,v+T/2);this.addDoubleLines(x,_,P,B,g)}createSecondHalfDiminuendoLines(b,S,v,w=this.rules.WedgeMeasureBeginOpeningLength,T=this.rules.WedgeLineWidth){const g=new a.PointF2D(b,v-w/2),x=new a.PointF2D(b,v+w/2),P=new a.PointF2D(S,v);this.addWedgeLines(P,g,x,T)}recalculateDiminuendoLines(b,S,v){const w=Math.abs(this.lines[0].End.y-this.lines[1].End.y)>1e-4;this.lines.clear(),w?this.createFirstHalfDiminuendoLines(b,S,v):this.isSplittedPart?this.createSecondHalfDiminuendoLines(b,S,v):this.createDiminuendoLines(b,S,v)}createFirstHalfLines(b,S,v,w=this.rules.WedgeOpeningLength,T=this.rules.WedgeMeasureEndOpeningLength,g=this.rules.WedgeLineWidth){this.ContinuousDynamic.DynamicType===m.ContDynamicEnum.crescendo?this.createFirstHalfCrescendoLines(b,S,v,T,g):this.ContinuousDynamic.DynamicType===m.ContDynamicEnum.diminuendo&&this.createFirstHalfDiminuendoLines(b,S,v,w,T,g)}createSecondHalfLines(b,S,v,w=this.rules.WedgeMeasureBeginOpeningLength,T=this.rules.WedgeOpeningLength,g=this.rules.WedgeLineWidth){this.ContinuousDynamic.DynamicType===m.ContDynamicEnum.crescendo?this.createSecondHalfCrescendoLines(b,S,v,w,T,g):this.ContinuousDynamic.DynamicType===m.ContDynamicEnum.diminuendo&&this.createSecondHalfDiminuendoLines(b,S,v,w,g)}createLines(b,S,v,w=this.rules.WedgeOpeningLength,T=this.rules.WedgeLineWidth){this.ContinuousDynamic.DynamicType===m.ContDynamicEnum.crescendo?this.createCrescendoLines(b,S,v,w,T):this.ContinuousDynamic.DynamicType===m.ContDynamicEnum.diminuendo&&this.createDiminuendoLines(b,S,v,w,T)}calcPsi(){this.IsVerbal?this.PositionAndShape.calculateBoundingBox():(this.PositionAndShape.RelativePosition=this.lines[0].Start,this.PositionAndShape.BorderMarginTop=this.lines[0].End.y-this.lines[0].Start.y,this.PositionAndShape.BorderMarginBottom=this.lines[1].End.y-this.lines[1].Start.y,this.PositionAndShape.Center.y=(this.PositionAndShape.BorderMarginTop+this.PositionAndShape.BorderMarginBottom)/2,this.IsSoftAccent?(this.PositionAndShape.BorderMarginLeft=0,this.PositionAndShape.BorderMarginRight=this.lines[3].Start.x-this.lines[0].Start.x):this.ContinuousDynamic.DynamicType===m.ContDynamicEnum.crescendo?(this.PositionAndShape.BorderMarginLeft=0,this.PositionAndShape.BorderMarginRight=this.lines[0].End.x-this.lines[0].Start.x):(this.PositionAndShape.BorderMarginLeft=this.lines[0].End.x-this.lines[0].Start.x,this.PositionAndShape.BorderMarginRight=0))}cleanUp(){this.lines.clear()}shiftYPosition(b){this.IsVerbal?(this.PositionAndShape.RelativePosition.y+=b,this.PositionAndShape.calculateBoundingBox()):(this.lines[0].Start.y+=b,this.lines[0].End.y+=b,this.lines[1].End.y+=b)}squeeze(b){this.IsVerbal||Math.abs(this.lines[0].End.x-this.lines[0].Start.x)0?this.lines[0].Start.x+=b:(this.lines[0].End.x+=b,this.lines[1].End.x+=b):b<0?this.lines[0].Start.x+=b:(this.lines[0].End.x+=b,this.lines[1].End.x+=b),this.calcPsi())}addWedgeLines(b,S,v,w){const T=new l.GraphicalLine(b,S,w),g=new l.GraphicalLine(b,v,w);this.rules.DefaultColorMusic&&(T.colorHex=this.rules.DefaultColorMusic,g.colorHex=this.rules.DefaultColorMusic),this.lines.push(T),this.lines.push(g)}addDoubleLines(b,S,v,w,T){const g=new l.GraphicalLine(b,S,T),x=new l.GraphicalLine(v,w,T);this.rules.DefaultColorMusic&&(g.colorHex=this.rules.DefaultColorMusic,x.colorHex=this.rules.DefaultColorMusic),this.lines.push(g),this.lines.push(x)}}y.GraphicalContinuousDynamicExpression=f},6711(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.GraphicalCurve=void 0;const d=p(9409);class l{constructor(){l.tPow3=new Array(l.bezierCurveStepSize),l.oneMinusTPow3=new Array(l.bezierCurveStepSize),l.bezierFactorOne=new Array(l.bezierCurveStepSize),l.bezierFactorTwo=new Array(l.bezierCurveStepSize);for(let a=0;a=l.bezierCurveStepSize?new d.PointF2D:new d.PointF2D(l.oneMinusTPow3[s]*this.bezierStartPt.x+l.bezierFactorOne[s]*this.bezierStartControlPt.x+l.bezierFactorTwo[s]*this.bezierEndControlPt.x+l.tPow3[s]*this.bezierEndPt.x,l.oneMinusTPow3[s]*this.bezierStartPt.y+l.bezierFactorOne[s]*this.bezierStartControlPt.y+l.bezierFactorTwo[s]*this.bezierEndControlPt.y+l.tPow3[s]*this.bezierEndPt.y)}}y.GraphicalCurve=l,l.bezierCurveStepSize=1e3},98(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.GraphicalGlissando=void 0;const d=p(9409),l=p(6438),m=p(6452);y.GraphicalGlissando=class{constructor(a){this.Glissando=a,this.staffEntries=[]}calculateLine(a){const s=this.staffEntries[0],h=this.staffEntries[this.staffEntries.length-1],u=s.findGraphicalNoteFromNote(this.Glissando.StartNote),f=h.findGraphicalNoteFromNote(this.Glissando.EndNote);if(!u&&!f)return;const r=s.parentMeasure.ParentStaffLine;let b,S,v,w;if(u&&s.parentMeasure.ParentStaffLine===this.StaffLine)b=u.PositionAndShape.RelativePosition.x+u.parentVoiceEntry.parentStaffEntry.PositionAndShape.RelativePosition.x+u.parentVoiceEntry.parentStaffEntry.parentMeasure.PositionAndShape.RelativePosition.x+a.GlissandoNoteOffset,v=u.PositionAndShape.AbsolutePosition.y;else{b=h.parentMeasure.beginInstructionsWidth-.4;const x=this.Glissando.Direction===l.ColDirEnum.Down?-1:1;v=f.PositionAndShape.AbsolutePosition.y+x*a.GlissandoStafflineStartYDistanceToNote}if(f&&h.parentMeasure.ParentStaffLine===this.StaffLine)S=f.PositionAndShape.RelativePosition.x+f.parentVoiceEntry.parentStaffEntry.PositionAndShape.RelativePosition.x+f.parentVoiceEntry.parentStaffEntry.parentMeasure.PositionAndShape.RelativePosition.x-.5-a.GlissandoNoteOffset,b>S&&(b=S-a.GlissandoStafflineStartMinimumWidth),w=f.PositionAndShape.AbsolutePosition.y;else{if(r.Measures.last().parentSourceMeasure.HasEndLine)return;S=r.PositionAndShape.Size.width,S-b>a.GlissandoStafflineEndOffset&&(b=S-a.GlissandoStafflineEndOffset);const x=this.Glissando.Direction===l.ColDirEnum.Down?1:-1;w=u.PositionAndShape.AbsolutePosition.y+x*a.GlissandoStafflineStartYDistanceToNote}const T=new d.PointF2D(b,v),g=new d.PointF2D(S,w);this.Width===void 0&&(this.Width=a.GlissandoDefaultWidth),this.Line=new m.GraphicalLine(T,g,this.Width)}}},5023(St,y,p){var d=this&&this.__importDefault||function(h){return h&&h.__esModule?h:{default:h}};Object.defineProperty(y,"__esModule",{value:!0}),y.GraphicalInstantaneousDynamicExpression=void 0;const l=p(9490),m=p(6362),a=d(p(3065));class s extends l.AbstractGraphicalExpression{constructor(u,f,r){super(f,u,r.parentSourceMeasure),this.mInstantaneousDynamicExpression=u,this.mMeasure=r}updateSkyBottomLine(){const u=this.parentStaffLine.SkyBottomLineCalculator,f=this.PositionAndShape.RelativePosition.x+this.PositionAndShape.BorderMarginLeft,r=this.PositionAndShape.RelativePosition.x+this.PositionAndShape.BorderMarginRight;let b=0;switch(this.Placement){case m.PlacementEnum.Above:b=this.PositionAndShape.RelativePosition.y+this.PositionAndShape.BorderMarginTop,u.updateSkyLineInRange(f,r,b);break;case m.PlacementEnum.Below:b=this.PositionAndShape.RelativePosition.y+this.PositionAndShape.BorderMarginBottom,u.updateBottomLineInRange(f,r,b);break;default:a.default.error("Placement for GraphicalInstantaneousDynamicExpression is unknown")}}}y.GraphicalInstantaneousDynamicExpression=s},3361(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.GraphicalInstantaneousTempoExpression=void 0;const d=p(9490);class l extends d.AbstractGraphicalExpression{constructor(a,s){super(s.PositionAndShape.Parent.DataObject,a,a.parentMeasure),this.label=s}get GraphicalLabel(){return this.label}updateSkyBottomLine(){}}y.GraphicalInstantaneousTempoExpression=l},8254(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.GraphicalLabel=void 0;const d=p(7533),l=p(6438),m=p(995),a=p(7921);class s extends m.Clickable{constructor(u,f,r,b,S=void 0){super(),this.CenteringXShift=0,this.label=u,this.boundingBox=new l.BoundingBox(this,S),this.label.fontHeight=f,this.label.textAlignment=r,this.rules=b}get Label(){return this.label}toString(){return`${this.label.text} (${this.boundingBox.RelativePosition.x},${this.boundingBox.RelativePosition.y})`}setLabelPositionAndShapeBorders(){var w;if(this.Label.text.trim()==="")return;this.TextLines=[];const u=((w=this.rules)==null?void 0:w.LabelMarginBorderFactor)??.1,f=this.Label.text.split(/[\n\r]+/g),r=f.length;let b=0;for(let T=0;T0&&this.TextLines.length>1&&(S+=this.rules.SpacingBetweenTextLines*r/10);const v=this.PositionAndShape;switch(this.Label.textAlignment){case d.TextAlignmentEnum.CenterBottom:v.BorderTop=-S,v.BorderLeft=-b/2,v.BorderBottom=0,v.BorderRight=b/2;break;case d.TextAlignmentEnum.CenterCenter:v.BorderTop=-S/2,v.BorderLeft=-b/2,v.BorderBottom=S/2,v.BorderRight=b/2;break;case d.TextAlignmentEnum.CenterTop:v.BorderTop=0,v.BorderLeft=-b/2,v.BorderBottom=S,v.BorderRight=b/2;break;case d.TextAlignmentEnum.LeftBottom:v.BorderTop=-S,v.BorderLeft=0,v.BorderBottom=0,v.BorderRight=b;break;case d.TextAlignmentEnum.LeftCenter:v.BorderTop=-S/2,v.BorderLeft=0,v.BorderBottom=S/2,v.BorderRight=b;break;case d.TextAlignmentEnum.LeftTop:v.BorderTop=0,v.BorderLeft=0,v.BorderBottom=S,v.BorderRight=b;break;case d.TextAlignmentEnum.RightBottom:v.BorderTop=-S,v.BorderLeft=-b,v.BorderBottom=0,v.BorderRight=0;break;case d.TextAlignmentEnum.RightCenter:v.BorderTop=-S/2,v.BorderLeft=-b,v.BorderBottom=S/2,v.BorderRight=0;break;case d.TextAlignmentEnum.RightTop:v.BorderTop=0,v.BorderLeft=-b,v.BorderBottom=S,v.BorderRight=0}v.BorderMarginTop=v.BorderTop-S*u,v.BorderMarginLeft=v.BorderLeft-S*u,v.BorderMarginBottom=v.BorderBottom+S*u,v.BorderMarginRight=v.BorderRight+S*u}}y.GraphicalLabel=s},6452(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.GraphicalLine=void 0;const d=p(2683);y.GraphicalLine=class{constructor(l,m,a=0,s=d.OutlineAndFillStyleEnum.BaseWritingColor,h=void 0){this.start=l,this.end=m,this.width=a,this.styleId=s,this.colorHex=h}get Start(){return this.start}set Start(l){this.start=l}get End(){return this.end}set End(l){this.end=l}get Width(){return this.width}set Width(l){this.width=l}}},2395(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.GraphicalLyricEntry=void 0;const d=p(8254),l=p(7435),m=p(9409),a=p(7533);y.GraphicalLyricEntry=class{constructor(s,h,u,f){this.lyricsEntry=s,this.graphicalStaffEntry=h;const r=h.parentMeasure.parentSourceMeasure.Rules.LyricsAlignmentStandard;s.Text.length>=4&&s.Parent.Notes[0].Length.Denominator>4&&a.TextAlignmentEnum.LeftBottom;const b=new l.Label(s.Text),S=this.graphicalStaffEntry.parentMeasure.parentSourceMeasure.Rules;this.graphicalLabel=new d.GraphicalLabel(b,u,r,S,h.PositionAndShape),this.graphicalLabel.Label.colorDefault=S.DefaultColorLyrics,this.graphicalLabel.PositionAndShape.RelativePosition=new m.PointF2D(0,f),this.graphicalLabel.setLabelPositionAndShapeBorders(),this.graphicalLabel.PositionAndShape.Size.width1&&s1}isVisible(){return this.ParentStaff.isVisible()}isMultiRestMeasure(){return this.multiRestElement!==void 0}getGraphicalMeasureDurationFromStaffEntries(){let u=new l.Fraction(0,1);const f=[];for(let r=0,b=this.staffEntries.length;r0&&v.Add(T.notes[0].graphicalNoteLength);u.lt(v)&&(u=l.Fraction.createFromFraction(v))}return u}addGraphicalStaffEntry(u){this.staffEntries.push(u)}addGraphicalStaffEntryAtTimestamp(u){if(u)if(this.staffEntries.length===0||this.staffEntries[this.staffEntries.length-1].relInMeasureTimestamp.lt(u.relInMeasureTimestamp))this.staffEntries.push(u);else for(let f=this.staffEntries.length-1;f>=0;f--){if(this.staffEntries[f].relInMeasureTimestamp.lt(u.relInMeasureTimestamp)){this.staffEntries.splice(f+1,0,u);break}f===0&&this.staffEntries.splice(f,0,u)}}isPianoRightHand(){return this.isUpperStaffOfInstrument()}isPianoLeftHand(){return this.isLowerStaffOfInstrument()}isUpperStaffOfInstrument(){return this.parentStaff.ParentInstrument.Staves.length===1||this.ParentStaff===this.parentStaff.ParentInstrument.Staves[0]}isLowerStaffOfInstrument(){return this.parentStaff.ParentInstrument.Staves.length!==1&&this.ParentStaff===this.ParentStaff.ParentInstrument.Staves.last()}beginsWithLineRepetition(){const u=this.parentSourceMeasure;return!!u&&u.beginsWithLineRepetition()}endsWithLineRepetition(){const u=this.parentSourceMeasure;return!!u&&u.endsWithLineRepetition()}beginsWithWordRepetition(){const u=this.parentSourceMeasure;return!!u&&u.beginsWithWordRepetition()}endsWithWordRepetition(){const u=this.parentSourceMeasure;return!!u&&u.endsWithWordRepetition()}getTransposedHalftones(){return this.parentStaff.ParentInstrument.GetMusicSheet.Transpose+this.parentStaff.ParentInstrument.Transpose}}y.GraphicalMeasure=s},1888(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.PagePlacementEnum=y.GraphicalMusicPage=void 0;const d=p(6438),l=p(7741),m=p(9409);class a extends l.GraphicalObject{constructor(u){super(),this.musicSystems=[],this.labels=[],this.parent=u,this.boundingBox=new d.BoundingBox(this,void 0)}get MusicSystems(){return this.musicSystems}set MusicSystems(u){this.musicSystems=u}get Labels(){return this.labels}set Labels(u){this.labels=u}get Parent(){return this.parent}set Parent(u){this.parent=u}get PageNumber(){return this.pageNumber}set PageNumber(u){this.pageNumber=u}setMusicPageAbsolutePosition(u,f){return new m.PointF2D(0,0)}}var s;y.GraphicalMusicPage=a,(function(h){h[h.Down=0]="Down",h[h.Right=1]="Right",h[h.RightDown=2]="RightDown"})(s||(y.PagePlacementEnum=s={}))},8724(St,y,p){var d=this&&this.__importDefault||function(T){return T&&T.__esModule?T:{default:T}};Object.defineProperty(y,"__esModule",{value:!0}),y.SystemImageProperties=y.GraphicalMusicSheet=void 0;const l=p(6723),m=p(6452),a=p(348),s=p(9409),h=p(164),u=p(4543),f=p(2561),r=p(6438),b=d(p(3065)),S=p(813),v=p(4548),w=p(7741);y.GraphicalMusicSheet=class{constructor(T,g){this.musicPages=[],this.measureList=[],this.verticalGraphicalStaffEntryContainers=[],this.cursors=[],this.leadSheet=!1,this.musicSheet=T,this.numberOfStaves=this.musicSheet.Staves.length,this.calculator=g,this.calculator.initialize(this)}get ParentMusicSheet(){return this.musicSheet}get GetCalculator(){return this.calculator}get MusicPages(){return this.musicPages}set MusicPages(T){this.musicPages=T}get MeasureList(){return this.measureList}set MeasureList(T){this.measureList=T}get VerticalGraphicalStaffEntryContainers(){return this.verticalGraphicalStaffEntryContainers}set VerticalGraphicalStaffEntryContainers(T){this.verticalGraphicalStaffEntryContainers=T}get Title(){return this.title}set Title(T){this.title=T}get Subtitle(){return this.subtitle}set Subtitle(T){this.subtitle=T}get Composer(){return this.composer}set Composer(T){this.composer=T}get Lyricist(){return this.lyricist}set Lyricist(T){this.lyricist=T}get Copyright(){return this.copyright}set Copyright(T){this.copyright=T}get Cursors(){return this.cursors}get SelectionStartSymbol(){return this.selectionStartSymbol}get SelectionEndSymbol(){return this.selectionEndSymbol}get MinAllowedSystemWidth(){return this.minAllowedSystemWidth}set MinAllowedSystemWidth(T){this.minAllowedSystemWidth=T}get NumberOfStaves(){return this.numberOfStaves}get LeadSheet(){return this.leadSheet}set LeadSheet(T){this.leadSheet=T}static transformRelativeToAbsolutePosition(T){for(let g=0;g=0;P--){const _=(x=this.measureList[P])==null?void 0:x[g];if(_)return _}}findGraphicalMeasureByMeasureNumber(T,g){for(let x=T;x>=0;x--)if(this.MeasureList[x]){const P=this.MeasureList[x][g];if((P==null?void 0:P.MeasureNumber)===T)return P}}findGraphicalStaffEntryFromMeasureList(T,g,x){for(let P=g;P0)return B.staffEntries[0]}}getFirstVisibleMeasuresListFromIndices(T,g){const x=[],P=this.measureList[0].length;for(let _=T;_<=g;_++)for(let B=0;B=0;g--){if(this.verticalGraphicalStaffEntryContainers[g].AbsoluteTimestamp.lt(T)){const x=new l.VerticalGraphicalStaffEntryContainer(this.numberOfStaves,T);return this.verticalGraphicalStaffEntryContainers.splice(g+1,0,x),x}if(this.verticalGraphicalStaffEntryContainers[g].AbsoluteTimestamp.Equals(T))return this.verticalGraphicalStaffEntryContainers[g]}}GetVerticalContainerFromTimestamp(T,g=0){const x=S.CollectionUtil.binarySearch(this.verticalGraphicalStaffEntryContainers,new l.VerticalGraphicalStaffEntryContainer(0,T),l.VerticalGraphicalStaffEntryContainer.compareByTimestamp,g);if(x>=0)return this.verticalGraphicalStaffEntryContainers[x]}GetInterpolatedIndexInVerticalContainers(T){const g=this.verticalGraphicalStaffEntryContainers;if(g.length===1)return 0;let x,P,_=0,B=g.length-1;if(T.lte(g[g.length-1].AbsoluteTimestamp)){for(;B-_>1;){const F=Math.floor((B+_)/2);if(g[_].AbsoluteTimestamp.Equals(T)){B=_;break}if(g[B].AbsoluteTimestamp.Equals(T)){_=B;break}if(g[F].AbsoluteTimestamp.Equals(T))return this.verticalGraphicalStaffEntryContainers.indexOf(g[F]);T.lt(g[F].AbsoluteTimestamp)?B=F:_=F}if(_===B)return this.verticalGraphicalStaffEntryContainers.indexOf(g[_]);x=g[_].AbsoluteTimestamp,P=g[B].AbsoluteTimestamp}else x=g[g.length-1].AbsoluteTimestamp,P=f.Fraction.plus(this.getLongestStaffEntryDuration(g.length-1),x),B=g.length;const k=P.RealValue-x.RealValue,R=B-(P.RealValue-T.RealValue)/k;return Math.min(R,this.verticalGraphicalStaffEntryContainers.length-1)}getVisibleStavesIndicesFromSourceMeasure(T){const g=[],x=[];for(let P=0,_=T.length;P<_;++P){const B=T[P].ParentStaff.ParentInstrument;g.indexOf(B)===-1&&g.push(B)}for(let P=0,_=g.length;P<_;++P){const B=g[P],k=this.musicSheet.getGlobalStaffIndexOfFirstStaff(B);for(let R=0;R=0;)P=this.measureList[--x][T];return this.measureList[x][T]}getMeasureIndex(T,g,x){for(g=0;g{var x;return((x=g.parentStaffEntry)==null?void 0:x.relInMeasureTimestamp)!==void 0})}GetNearestNote(T,g){const x=this.GetNearestVoiceEntry(T);if(!x)return;let P,_=Number.MAX_SAFE_INTEGER;for(const B of x.notes){const k=B.PositionAndShape.AbsolutePosition.y,R=Math.abs(B.PositionAndShape.AbsolutePosition.x-T.x),F=Math.abs(k-T.y);R+F<_&&(P=B,_=R+F)}return P}domToSvg(T){return this.domToSvgTransform(T,!0)}svgToDom(T){return this.domToSvgTransform(T,!1)}svgToOsmd(T){const g=new s.PointF2D(T.x,T.y);return g.x/=10,g.y/=10,g}domToSvgTransform(T,g){const x=this.drawer.Backends[0].getSvgElement(),P=x.createSVGPoint();P.x=T.x,P.y=T.y;let _=x.getScreenCTM();g&&(_=_.inverse());const B=P.matrixTransform(_);return new s.PointF2D(B.x,B.y)}GetClickableLabel(T){const g=new r.BoundingBox;g.BorderLeft=T.x-4,g.BorderTop=T.y-4,g.BorderRight=T.x+4,g.BorderBottom=T.y+4,g.AbsolutePosition=new s.PointF2D(0,0);for(let x=0,P=this.MusicPages.length;xB.PositionAndShape.RelativePosition.x&&(x=B):x=B)}}catch(P){b.default.info("GraphicalMusicSheet.getStaffEntry",P)}return x}GetPreviousVisibleContainerIndex(T){for(let g=T-1;g>=0;g--){const x=this.verticalGraphicalStaffEntryContainers[g].StaffEntries;for(let P=0,_=x.length;P<_;++P){const B=x[P];if(B&&B.sourceStaffEntry.ParentStaff.isVisible())return g}}return-1}GetNextVisibleContainerIndex(T){for(let g=T+1;g=0;_--)if(x=this.getStaffEntry(_),x&&(!g||x.sourceStaffEntry.ParentStaff.isVisible()))return x}findClosestRightStaffEntry(T,g){let x;for(let P=Math.max(0,Math.ceil(T));Pg.RealValue?1:g.RealValue>T.RealValue?-1:0}calculateCurve(v){const w=this.staffEntries[0],T=this.staffEntries[this.staffEntries.length-1];let g=w.findGraphicalNoteFromNote(this.slur.StartNote);!g&&this.graceStart&&(g=w.findGraphicalNoteFromGraceNote(this.slur.StartNote)),g||(g=w.findEndTieGraphicalNoteFromNoteWithStartingSlur(this.slur.StartNote,this.slur));let x=T.findGraphicalNoteFromNote(this.slur.EndNote);!x&&this.graceEnd&&(x=T.findGraphicalNoteFromGraceNote(this.slur.EndNote));const P=w.parentMeasure.ParentStaffLine,_=P.SkyBottomLineCalculator;this.calculatePlacement(_,P);const B=this.calculateStartAndEnd(g,x,P,v,_),k=B.startX,R=B.endX;let F=B.startY,A=B.endY;const G=v.SlurTangentMinAngle,U=v.SlurTangentMaxAngle;let C;if(this.placement===a.PlacementEnum.Above){F-=v.SlurNoteHeadYOffset,A-=v.SlurNoteHeadYOffset;const z=new l.PointF2D(this.staffEntries[0].parentMeasure.PositionAndShape.RelativePosition.x+this.staffEntries[0].PositionAndShape.RelativePosition.x,F);g?z.x+=this.staffEntries[0].PositionAndShape.BorderRight:z.x=this.staffEntries[0].parentMeasure.beginInstructionsWidth,this.graceStart&&(z.x+=T.PositionAndShape.RelativePosition.x);const W=new l.PointF2D(this.staffEntries[this.staffEntries.length-1].parentMeasure.PositionAndShape.RelativePosition.x+this.staffEntries[this.staffEntries.length-1].PositionAndShape.RelativePosition.x,A);if(x?W.x+=this.staffEntries[this.staffEntries.length-1].PositionAndShape.BorderLeft:W.x=this.staffEntries[this.staffEntries.length-1].parentMeasure.PositionAndShape.RelativePosition.x+this.staffEntries[this.staffEntries.length-1].parentMeasure.PositionAndShape.Size.width,this.graceEnd&&(W.x+=T.staffEntryParent.PositionAndShape.RelativePosition.x),C=this.calculateTopPoints(z,W,P,_),C.length===0){const Nt=new l.PointF2D((W.x-z.x)/2+z.x,(W.y-z.y)/2+z.y);C.push(Nt)}const $=Math.atan((A-F)/(R-k)),N=new l.PointF2D(0,0);let Y=new l.PointF2D(R-k,-(A-F));const tt=s.Matrix2D.getRotationMatrix($),H=tt.getTransposeMatrix();Y=tt.vectorMultiplication(Y);const rt=this.calculateTranslatedAndRotatedPointListAbove(C,k,F,tt),ct=this.calculateMaxLeftSlope(rt,N,Y),st=this.calculateMaxRightSlope(rt,N,Y),at=N.y-N.x*ct,ht=Y.y-Y.x*st,lt=new l.PointF2D;let O=!1;Math.abs(Math.abs(ct)-Math.abs(st))<1e-4?(lt.x=Y.x/2,lt.y=0,O=!0):(lt.x=(ht-at)/(ct-st),lt.y=ct*lt.x+at);const D=this.calculateHeightWidthRatio(Y.x,rt),j=0,Q=0;let J=G,q=-G;if(!O){const Nt=this.calculateAngles(G,ct,st,U);J=Nt.startAngle,q=Nt.endAngle}const et=this.calculateControlPoints(Y.x,J,q,rt,D,F,A);let it=et.startControlPoint,dt=et.endControlPoint;it=H.vectorMultiplication(it),it.x+=k,it.y=-it.y+F,dt=H.vectorMultiplication(dt),dt.x+=k,dt.y=-dt.y+F,this.bezierStartPt=new l.PointF2D(k,F-j),this.bezierStartControlPt=new l.PointF2D(it.x,it.y-j),this.bezierEndControlPt=new l.PointF2D(dt.x,dt.y-Q),this.bezierEndPt=new l.PointF2D(R,A-Q);const mt=P.SkyLine.length,yt=_.getLeftIndexForPointX(this.bezierStartPt.x,mt),Et=_.getLeftIndexForPointX(this.bezierEndPt.x,mt),Dt=this.bezierEndPt.x-this.bezierStartPt.x,Vt=_.SamplingUnit;for(let Nt=yt;Nt=yt&&(P.SkyLine[zt]=Math.min(P.SkyLine[zt],Ct.y)),zt++,zt=yt&&(P.BottomLine[zt]=Math.max(P.BottomLine[zt],Ct.y)),zt++,zt0)return void(this.placement=a.PlacementEnum.Above);const T=this.staffEntries[0],g=this.staffEntries[this.staffEntries.length-1],x=T.graphicalVoiceEntries[0].parentVoiceEntry.StemDirection;if(x===g.graphicalVoiceEntries[0].parentVoiceEntry.StemDirection)this.placement=x===f.StemDirectionType.Up?a.PlacementEnum.Below:a.PlacementEnum.Above,this.rules.SlurPlacementAtStems&&(this.placement=x===f.StemDirectionType.Up?a.PlacementEnum.Above:a.PlacementEnum.Below);else{let P=T.PositionAndShape.BorderLeft+T.PositionAndShape.RelativePosition.x+T.parentMeasure.PositionAndShape.RelativePosition.x,_=g.PositionAndShape.BorderRight+g.PositionAndShape.RelativePosition.x+g.parentMeasure.PositionAndShape.RelativePosition.x;this.graceStart&&(P+=g.PositionAndShape.RelativePosition.x),this.graceEnd&&(_+=g.staffEntryParent.PositionAndShape.RelativePosition.x);const B=-1*v.getSkyLineMinInRange(P,_),k=v.getBottomLineMaxInRange(P,_)-w.StaffHeight;this.placement=k>B?a.PlacementEnum.Above:a.PlacementEnum.Below}}calculateTopPoints(v,w,T,g){const x=[];let P=g.getRightIndexForPointX(v.x,T.SkyLine.length),_=g.getLeftIndexForPointX(w.x,T.SkyLine.length);P<0&&(P=0),_>=T.SkyLine.length&&(_=T.SkyLine.length-1);for(let B=P;B<_;B++){const k=T.SkyLine[B];if(k!==0){const R=new l.PointF2D((.5+B)/g.SamplingUnit,k);x.push(R)}}return x}calculateBottomPoints(v,w,T,g){const x=[];let P=g.getRightIndexForPointX(v.x,T.BottomLine.length),_=g.getLeftIndexForPointX(w.x,T.BottomLine.length);P<0&&(P=0),_>=T.BottomLine.length&&(_=T.BottomLine.length-1);for(let B=P;B<_;B++){const k=T.BottomLine[B];if(k!==0){const R=new l.PointF2D((.5+B)/g.SamplingUnit,k);x.push(R)}}return x}calculateMaxLeftSlope(v,w,T){let g=-Number.MAX_VALUE;const x=w.x,P=w.y;for(let _=0;_R&&v>F&&(k+=v/70*this.rules.SlurHeightFlattenLongSlursFactorByWidth,k*=1+w/30*this.rules.SlurHeightFlattenLongSlursFactorByAngle,B/=k);const A=Math.min(.5,Math.max(.1,1.7*w/80*B*Math.pow(Math.max(x,.05),.4))),G=Math.min(.5,Math.max(.1,1.7*-T/80*B*Math.pow(Math.max(x,.05),.4))),U=new l.PointF2D;U.x=v*A*Math.cos(w*b.degreesToRadiansFactor),U.y=v*A*Math.sin(w*b.degreesToRadiansFactor);const C=new l.PointF2D;C.x=v-v*G*Math.cos(T*b.degreesToRadiansFactor),C.y=-v*G*Math.sin(T*b.degreesToRadiansFactor);let z=U.y-C.y;for(;this.rules.SlurMaximumYControlPointDistance&&Math.abs(z)>this.rules.SlurMaximumYControlPointDistance;)z<0?(U.y+=1,C.y-=1):(U.y-=1,C.y+=1),z=U.y-C.y;return{startControlPoint:U,endControlPoint:C}}calculateAngles(v,w,T,g){let x=Math.atan(w)/b.degreesToRadiansFactor;w>0?x+=20:x-=20;let P=Math.atan(T)/b.degreesToRadiansFactor;return T<0?P-=20:P+=20,{startAngle:Math.min(Math.max(v,x),g),endAngle:Math.max(Math.min(-v,P),-g)}}}y.GraphicalSlur=b,b.degreesToRadiansFactor=Math.PI/180},348(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.GraphicalStaffEntry=void 0;const d=p(6438),l=p(2561),m=p(7741),a=p(813),s=p(7921);class h extends m.GraphicalObject{constructor(f,r=void 0,b=void 0){super(),this.graphicalChordContainers=[],this.tabStaffEntry=void 0,this.MaxAccidentals=0,this.graphicalInstructions=[],this.ties=[],this.graphicalTies=[],this.lyricsEntries=[],this.parentMeasure=f,this.graphicalVoiceEntries=[],this.sourceStaffEntry=r,b?(this.staffEntryParent=b,this.parentVerticalContainer=b.parentVerticalContainer,this.PositionAndShape=new d.BoundingBox(this,b.PositionAndShape)):this.PositionAndShape=new d.BoundingBox(this,f.PositionAndShape),r&&(this.relInMeasureTimestamp=r.Timestamp),this.FingeringEntries=[]}get GraphicalInstructions(){return this.graphicalInstructions}get GraphicalTies(){return this.graphicalTies}get LyricsEntries(){return this.lyricsEntries}set LyricsEntries(f){this.lyricsEntries=f}getAbsoluteTimestamp(){const f=this.parentMeasure.parentSourceMeasure.AbsoluteTimestamp.clone();return this.relInMeasureTimestamp&&f.Add(this.relInMeasureTimestamp),f}findTieGraphicalNoteFromNote(f){for(const r of this.graphicalVoiceEntries)for(const b of r.notes){const S=b.sourceNote;if(!S.isRest()&&S.Pitch.FundamentalNote===f.Pitch.FundamentalNote&&S.Pitch.Octave===f.Pitch.Octave&&S.getAbsoluteTimestamp().Equals(f.getAbsoluteTimestamp()))return b}}findEndTieGraphicalNoteFromNoteWithStartingSlur(f,r){if(f){for(const b of this.graphicalVoiceEntries)if(b.parentVoiceEntry===f.ParentVoiceEntry)for(const S of b.notes){const v=S.sourceNote;if(v.NoteTie&&v.NoteSlurs.indexOf(r)!==-1)return S}}}findGraphicalNoteFromGraceNote(f){if(f){for(const r of this.graphicalVoiceEntries)if(r.parentVoiceEntry===f.ParentVoiceEntry){for(const b of r.notes)if(b.sourceNote===f)return b}}}findGraphicalNoteFromNote(f){if(f){for(const r of this.graphicalVoiceEntries)if(r.parentVoiceEntry===f.ParentVoiceEntry){for(const b of r.notes)if(b.sourceNote===f&&this.getAbsoluteTimestamp().Equals(f.getAbsoluteTimestamp()))return b}}}getGraphicalNoteDurationFromVoice(f){for(const r of this.graphicalVoiceEntries)if(r.parentVoiceEntry.ParentVoice===f)return r.notes[0].graphicalNoteLength;return new l.Fraction(0,1)}findVoiceEntryGraphicalNotes(f){for(const r of this.graphicalVoiceEntries)if(r.parentVoiceEntry===f)return r.notes}isVoiceEntryPartOfLinkedVoiceEntry(f){if(this.sourceStaffEntry.Link)for(let r=0,b=this.sourceStaffEntry.Link.LinkStaffEntries.length;r0&&(f=S)}return f}findStaffEntryMaxNoteLength(){let f=new l.Fraction(0,1);for(const r of this.graphicalVoiceEntries)for(const b of r.notes){const S=b.graphicalNoteLength;f.lt(S)&&S.GetExpandedNumerator()>0&&(f=S)}return f}findOrCreateGraphicalVoiceEntry(f){for(const b of this.graphicalVoiceEntries)if(b.parentVoiceEntry===f)return b;const r=s.MusicSheetCalculator.symbolFactory.createVoiceEntry(f,this);return this.graphicalVoiceEntries.push(r),r}findOrCreateGraphicalVoiceEntryFromGraphicalNote(f){for(const b of this.graphicalVoiceEntries)if(b===f.parentVoiceEntry)return b;const r=s.MusicSheetCalculator.symbolFactory.createVoiceEntry(f.sourceNote.ParentVoiceEntry,this);return this.graphicalVoiceEntries.push(r),r}addGraphicalNoteToListAtCorrectYPosition(f,r){const b=f.notes;if(b.length===0||r.PositionAndShape.RelativePosition.y=0;S--){if(b[S].PositionAndShape.RelativePosition.y>r.PositionAndShape.RelativePosition.y){b.splice(S+1,0,r);break}if(S===0){b.splice(0,0,r);break}}}hasOnlyRests(){return this.sourceStaffEntry.hasOnlyRests}getSkylineMin(){var S;const f=(S=this.parentMeasure)==null?void 0:S.ParentStaffLine.SkyBottomLineCalculator;if(!f)return;const[r,b]=this.getAbsoluteStartAndEnd();return f.getSkyLineMinInRange(r,b)}getHighestYAtEntry(){return this.parentMeasure.ParentStaffLine.PositionAndShape.AbsolutePosition.y+this.getSkylineMin()}getLowestYAtEntry(){return this.parentMeasure.ParentStaffLine.PositionAndShape.AbsolutePosition.y+this.getBottomlineMax()}getBottomlineMax(){var S;const f=(S=this.parentMeasure)==null?void 0:S.ParentStaffLine.SkyBottomLineCalculator;if(!f)return;const[r,b]=this.getAbsoluteStartAndEnd();return f.getBottomLineMaxInRange(r,b)}getAbsoluteStartAndEnd(){let f=this.PositionAndShape.AbsolutePosition.x;return f-=this.parentMeasure.ParentStaffLine.PositionAndShape.AbsolutePosition.x,[f,f+this.PositionAndShape.Size.width]}}y.GraphicalStaffEntry=h},9760(St,y){Object.defineProperty(y,"__esModule",{value:!0}),y.GraphicalStaffEntryLink=void 0,y.GraphicalStaffEntryLink=class{constructor(p){this.graphicalLinkedStaffEntries=[],this.staffEntryLink=p,this.initialize()}get GetStaffEntryLink(){return this.staffEntryLink}get GraphicalLinkedStaffEntries(){return this.graphicalLinkedStaffEntries}set GraphicalLinkedStaffEntries(p){this.graphicalLinkedStaffEntries=p}isFilled(){for(let p=0;p{var f,r;return(((f=u.sourceNote.Pitch)==null?void 0:f.getHalfTone())??0)-(((r=h.sourceNote.Pitch)==null?void 0:r.getHalfTone())??0)}),this.notes}sortForVexflow(){return this.notes.sort((h,u)=>{var f;return(((f=h.sourceNote.Pitch)==null?void 0:f.getHalfTone())??0)-(u.sourceNote.Pitch.getHalfTone()??0)}),this.notes}applyCustomNoteheads(){}color(){}}y.GraphicalVoiceEntry=a},7753(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.GraphicalWavyLine=void 0;const d=p(6438),l=p(7741);class m extends l.GraphicalObject{constructor(s,h){super(),this.getWavyLine=s,this.PositionAndShape=new d.BoundingBox(this,h)}}y.GraphicalWavyLine=m},7225(St,y){Object.defineProperty(y,"__esModule",{value:!0})},7921(St,y,p){var d=this&&this.__importDefault||function(lt){return lt&<.__esModule?lt:{default:lt}};Object.defineProperty(y,"__esModule",{value:!0}),y.MusicSheetCalculator=void 0;const l=p(8724),m=p(2561),a=p(1850),s=p(5748),h=p(164),u=p(437),f=p(1336),r=p(1645),b=p(7066),S=p(9409),v=p(2369),w=p(8254),T=p(7533),g=p(4543),x=p(3123),P=p(4249),_=p(6438),B=p(8033),k=p(8927),R=p(164),F=p(4064),A=d(p(3065)),G=p(3263),U=p(6452),C=p(7435),z=p(3236),W=p(6362),$=p(3361),N=p(9161),Y=p(2221),tt=p(5875),H=p(1066),rt=p(624),ct=p(5824),st=p(5534),at=p(9647);class ht{constructor(){this.staffEntriesWithGraphicalTies=[],this.staffEntriesWithOrnaments=[],this.staffEntriesWithChordSymbols=[],this.staffLinesWithLyricWords=[],this.graphicalLyricWords=[],this.abstractNotImplementedErrorMessage="abstract, not implemented",this.dynamicExpressionMap=new Map}static get TextMeasurer(){return ht.textMeasurer}static set TextMeasurer(O){ht.textMeasurer=O}get leadSheet(){return this.graphicalMusicSheet.LeadSheet}static setMeasuresMinStaffEntriesWidth(O,D){for(let j=0,Q=O.length;j0&&this.rules.RenderMultipleRestMeasures){yt.isReducedToMultiRest=!0,yt.multipleRestMeasureNumber=1;const Dt=yt.multipleRestMeasures-1;dt+=Dt;for(let Vt=1;Vt<=Dt;Vt++){const Nt=O.SourceMeasures.indexOf(yt)+Vt;if(Nt>=O.SourceMeasures.length)break;const It=O.SourceMeasures[Nt];It.multipleRestMeasureNumber=Vt+1,It.isReducedToMultiRest=!0,D.push([void 0])}}}if(this.rules.AutoGenerateMultipleRestMeasuresFromRestMeasures&&this.rules.RenderMultipleRestMeasures){let dt,mt=0;for(let yt=0,Et=O.SourceMeasures.length;yt0){dt.isReducedToMultiRest=!0,dt.multipleRestMeasureNumber=1,mt++,Dt.multipleRestMeasureNumber=mt,Dt.isReducedToMultiRest=!0;for(let Vt=0;Vt1){dt.multipleRestMeasures=mt;const Vt=this.createGraphicalMeasuresForSourceMeasure(dt,j,J,et,Q);D[dt.measureListIndex]=Vt,mt=0,dt=void 0}else mt=0,dt=void 0}if(mt>1){dt.multipleRestMeasures=mt,dt.isReducedToMultiRest=!0;const yt=this.createGraphicalMeasuresForSourceMeasure(dt,j,J,et,Q);D[dt.measureListIndex]=yt,mt=0,dt=void 0}}const it=Q.map(dt=>dt.ClefType===h.ClefEnum.percussion);this.handleStaffEntries(it),this.calculateVerticalContainersList(),this.setIndicesToVerticalGraphicalContainers()}calculate(){this.musicSystems=[],this.clearSystemsAndMeasures(),this.clearRecreatedObjects(),this.createGraphicalTies(),this.calculateSheetLabelBoundingBoxes(),this.calculateXLayout(this.graphicalMusicSheet,this.maxInstrNameLabelLength()),this.graphicalMusicSheet.MusicPages.length=0,this.calculateMusicSystems(),l.GraphicalMusicSheet.transformRelativeToAbsolutePosition(this.graphicalMusicSheet)}calculateXLayout(O,D){var j;if(this.graphicalMusicSheet.MeasureList.length>0){let Q,J=0,q=1;for(let et=0;etJ&&(J=it);const dt=this.graphicalMusicSheet.ParentMusicSheet.MeasureWidthFactor;for(const mt of Q)if(mt!=null&&mt.parentSourceMeasure.WidthFactor){q=mt.parentSourceMeasure.WidthFactor;break}it*=dt*q,ht.setMeasuresMinStaffEntriesWidth(Q,it)}if(this.rules.FixedMeasureWidth){let et=J;this.rules.FixedMeasureWidthFixedValue&&(et=this.rules.FixedMeasureWidthFixedValue);for(let it=0;it1;if(J===1&&D.Measures[0].parentSourceMeasure.ImplicitMeasure&&(et=!1),et)return;q.MeasureNumber!==0&&q.MeasureNumber!==1||(j=q.MeasureNumber),Q=q!==D.Measures[0]&&this.rules.MeasureNumberLabelXOffset?this.rules.MeasureNumberLabelXOffset:0;const it=this.rules.UseXMLMeasureNumbers&&q.MeasureNumber===1&&q.parentSourceMeasure.getPrintedMeasureNumber()!==1;((q.MeasureNumber===j||q.MeasureNumber>=j+this.rules.MeasureNumberLabelOffset)&&!q.parentSourceMeasure.ImplicitMeasure||it)&&((q.MeasureNumber!==1||q.MeasureNumber===1&&q!==D.Measures[0]||it)&&this.calculateSingleMeasureNumberPlacement(q,D,O,Q),j=q.MeasureNumber)}}calculateSingleMeasureNumberPlacement(O,D,j,Q=0){const J=O.parentSourceMeasure.getPrintedMeasureNumber().toString(),q=new C.Label(J),et=new w.GraphicalLabel(q,this.rules.MeasureNumberLabelHeight,T.TextAlignmentEnum.LeftBottom,this.rules),it=D.SkyBottomLineCalculator;et.setLabelPositionAndShapeBorders(),et.PositionAndShape.Parent=j.PositionAndShape;const dt=D.PositionAndShape.RelativePosition.x+O.PositionAndShape.RelativePosition.x-et.PositionAndShape.BorderMarginLeft+Q;let mt,yt=dt,Et=dt-et.PositionAndShape.BorderLeft+et.PositionAndShape.BorderRight;yt-=D.PositionAndShape.RelativePosition.x,Et-=D.PositionAndShape.RelativePosition.x;const Dt=yt+.5,Vt=Et-.5,Nt=it.getSkyLineMinInRange(Dt,Vt);if(O===D.Measures[0]){let It=0;if(j.GroupBrackets.length>0)for(const Ct of j.GroupBrackets)It=Math.min(It,Ct.PositionAndShape.BorderTop);else O.ParentStaff.ParentInstrument.Parent&&(It=-1);mt=Math.min(Nt,It)}else mt=Nt;mt=Math.min(0,mt),et.PositionAndShape.RelativePosition=new S.PointF2D(dt,mt),j.MeasureNumberLabels.push(et)}calculateMeasureNumberSkyline(O){const D=O.StaffLines[0];for(const j of O.MeasureNumberLabels){let Q=j.PositionAndShape.RelativePosition.x,J=Q-j.PositionAndShape.BorderLeft+j.PositionAndShape.BorderRight;Q-=D.PositionAndShape.RelativePosition.x,J-=D.PositionAndShape.RelativePosition.x,D.SkyBottomLineCalculator.updateSkyLineInRange(Q,J,j.PositionAndShape.RelativePosition.y+j.PositionAndShape.BorderMarginTop)}}layoutGraphicalTie(O,D,j){throw new Error(this.abstractNotImplementedErrorMessage)}calculateSingleStaffLineLyricsPosition(O,D){let j=0,Q=this.rules.StaffHeight;const J=new Map,q=[],et=O.SkyBottomLineCalculator;let it=O.Measures.length;for(let mt=0;mt0){q.push(Nt),j=Math.max(j,Nt.LyricsEntries.length);const Ct=Nt.PositionAndShape.RelativePosition.x+Et.x;let zt=Number.MAX_VALUE,Xt=Number.MIN_VALUE;for(let Kt=0;Kt0){const mt=O.PositionAndShape.Size.width;let yt=q[0].PositionAndShape.RelativePosition.x+q[0].PositionAndShape.BorderMarginLeft+q[0].parentMeasure.PositionAndShape.RelativePosition.x;yt=yt>mt?mt:yt,et.updateBottomLineInRange(yt,mt,dt)}return q}calculateLyricsExtendsAndDashes(O){for(let D=0,j=O.length;D0||O.UnknownList.length>0){let mt="";for(let Ct=0,zt=O.EntriesList.length;Ct-50){let Ct=et/10;Ct+=this.rules.PlaceWordsInsideStafflineYOffset,Vt.PositionAndShape.RelativePosition.y=Ct}const It=new ct.GraphicalUnknownExpression(yt,Vt,Dt,(dt=J[j])==null?void 0:dt.parentSourceMeasure,O);yt.AbstractExpressions.push(It)}}clearRecreatedObjects(){for(let O=0,D=this.staffEntriesWithGraphicalTies.length;OO.length-1&&(A.default.debug("minimum measure to draw index out of range. resetting min measure index to limit."),this.rules.MinMeasureToDrawIndex=O.length-1);const D=[];for(let J=this.rules.MinMeasureToDrawIndex,q=O.length;J0){let Xt=0;et.staffEntries[0].relInMeasureTimestamp.RealValue===0&&(Xt=et.staffEntries[0].PositionAndShape.RelativePosition.x,et.MeasureNumber===1&&(Xt+=this.rules.ChordSymbolWholeMeasureRestXOffsetMeasure1));let Ut=Xt+(et.PositionAndShape.Size.width-et.endInstructionsWidth-Xt)*(dt.relInMeasureTimestamp.RealValue/et.parentSourceMeasure.Duration.RealValue)+yt.PositionAndShape.BorderMarginLeft;it&&(Ut=Math.max(Ut,it.PositionAndShape.RelativePosition.x+it.GraphicalLabel.PositionAndShape.Size.width+this.rules.ChordSymbolXSpacing)),yt.PositionAndShape.RelativePosition.x=Ut,yt.PositionAndShape.Parent=et.staffEntries[0].PositionAndShape.Parent}const Et=yt.PositionAndShape,Dt=Et.Parent;if(Dt.DataObject instanceof s.GraphicalMeasure&&dt.relInMeasureTimestamp.RealValue===0&&(Et.RelativePosition.x=Math.max(et.beginInstructionsWidth,Et.RelativePosition.x),et.MeasureNumber===1&&Et.RelativePosition.x>3&&(Et.RelativePosition.x+=this.rules.ChordSymbolWholeMeasureRestXOffsetMeasure1)),dt.PositionAndShape.RelativePosition.x===0){const Xt=O.GraphicalMeasures[q];for(const Ut of Xt){let Kt=!1;for(const qt of Ut.staffEntries)if(qt.relInMeasureTimestamp===dt.relInMeasureTimestamp&&qt.PositionAndShape.RelativePosition.x!==0){Et.RelativePosition.x=qt.PositionAndShape.RelativePosition.x,Kt=!0;break}if(Kt)break}}const Vt=Et.BorderMarginLeft+Dt.AbsolutePosition.x+Et.RelativePosition.x,Nt=Et.BorderMarginRight+Dt.AbsolutePosition.x+Et.RelativePosition.x,It=yt.GetChordSymbolContainer.Placement;It===W.PlacementEnum.Below?(!this.rules.ChordSymbolYAlignment||J<0)&&(J=j.getBottomLineMaxInRange(Vt,Nt)):It===W.PlacementEnum.Above&&(!this.rules.ChordSymbolYAlignment||Q>0)&&(Q=j.getSkyLineMinInRange(Vt,Nt));let Ct=0;mt===0?(Ct+=this.rules.ChordSymbolYOffset,Ct+=.1):Ct+=this.rules.ChordSymbolYPadding,It!==W.PlacementEnum.Below&&(Ct*=-1);const zt=yt.GraphicalLabel;It===W.PlacementEnum.Below?(zt.PositionAndShape.RelativePosition.y=J+Ct,zt.setLabelPositionAndShapeBorders(),zt.PositionAndShape.calculateBoundingBox(),j.updateBottomLineInRange(Vt,Nt,J+zt.PositionAndShape.BorderMarginBottom+this.rules.ChordSymbolBottomMargin)):(zt.PositionAndShape.RelativePosition.y=Q+Ct,zt.setLabelPositionAndShapeBorders(),zt.PositionAndShape.calculateBoundingBox(),j.updateSkyLineInRange(Vt,Nt,Q+zt.PositionAndShape.BorderMarginTop)),it=yt}}}}calculateAlignedChordSymbolsOffset(O,D){let j=Number.MAX_SAFE_INTEGER,Q=Number.MIN_SAFE_INTEGER;for(const J of O)for(const q of J.graphicalChordContainers){const et=q.PositionAndShape,it=et.Parent;let dt=et.BorderMarginLeft+it.AbsolutePosition.x,mt=et.BorderMarginRight+it.AbsolutePosition.x;it.DataObject instanceof s.GraphicalMeasure&&(dt+=it.DataObject.beginInstructionsWidth,mt+=it.DataObject.beginInstructionsWidth);const yt=q.GetChordSymbolContainer.Placement;yt===W.PlacementEnum.Above?j=Math.min(j,D.getSkyLineMinInRange(dt,mt)):yt===W.PlacementEnum.Below&&(Q=Math.max(Q,D.getBottomLineMaxInRange(dt,mt)))}return{minOffset:j,maxOffset:Q}}layoutMeasureWithWholeRest(O,D,j){}layoutBeams(O){}layoutArticulationMarks(O,D,j){}layoutOrnament(O,D,j){}calculateRestNotePlacementWithinGraphicalBeam(O,D,j,Q,J){}calculateTupletNumbers(){if(!this.rules.TupletNumberLimitConsecutiveRepetitions)return;let O,D,j,Q=-1,J=0;const q={};for(const et of this.graphicalMusicSheet.ParentMusicSheet.Instruments)for(const it of et.Voices){J=0,q[it.VoiceId]={};for(const dt of it.VoiceEntries)if(dt.Notes.length>0){const mt=dt.Notes[0];if(!mt.NoteTuplet||mt.NoteTuplet.shouldBeBracketed(this.rules.TupletsBracketedUseXMLValue,this.rules.TupletsBracketed,this.rules.TripletsBracketed)){Q=-1,J=0,D=void 0,O=void 0;continue}if(mt.NoteTuplet===j)continue;let yt=mt.TypeLength;if(yt||(A.default.warn("note missing TypeLength"),yt=mt.NoteTuplet.Fractions[0]),mt.NoteTuplet!==D&&q[it.VoiceId][mt.NoteTuplet.TupletLabelNumber]&&q[it.VoiceId][mt.NoteTuplet.TupletLabelNumber][yt.RealValue]){mt.NoteTuplet.RenderTupletNumber=!1,j=mt.NoteTuplet;continue}mt.NoteTuplet.TupletLabelNumber===Q&&yt.Equals(O)&&!mt.NoteTuplet.Bracket||(Q=mt.NoteTuplet.TupletLabelNumber,O=yt,J=0),D=mt.NoteTuplet,J++,J<=this.rules.TupletNumberMaxConsecutiveRepetitions&&(mt.NoteTuplet.RenderTupletNumber=!0),J>this.rules.TupletNumberMaxConsecutiveRepetitions&&(mt.NoteTuplet.RenderTupletNumber=!1,this.rules.TupletNumberAlwaysDisableAfterFirstMax&&(q[it.VoiceId][Q]||(q[it.VoiceId][Q]={}),q[it.VoiceId][Q][yt.RealValue]=!0)),j=D}}}calculateSlurs(){}calculateGlissandi(){}calculateDynamicExpressionsForMultiExpression(O,D,j){}calculateGraphicalVerbalContinuousDynamic(O,D){const j=O.Label,Q=D.x+j.PositionAndShape.BorderMarginLeft,J=D.x+j.PositionAndShape.BorderMarginRight,q=O.ContinuousDynamic.Placement,et=O.ParentStaffLine.SkyBottomLineCalculator;let it;q===W.PlacementEnum.Below?(it=et.getBottomLineMaxInRange(Q,J),j.PositionAndShape.RelativePosition=new S.PointF2D(D.x,it-j.PositionAndShape.BorderMarginTop)):(it=et.getSkyLineMinInRange(Q,J),j.PositionAndShape.RelativePosition=new S.PointF2D(D.x,it-j.PositionAndShape.BorderMarginBottom))}calculateGraphicalContinuousDynamic(O,D){var xi;const j=O.IsSoftAccent,Q=O.ParentStaffLine.ParentStaff.idInMusicSheet,J=this.graphicalMusicSheet.getGraphicalMeasureFromSourceMeasureAndIndex(O.ContinuousDynamic.EndMultiExpression.SourceMeasureParent,Q);if(!J)return void A.default.warn("MusicSheetCalculator.calculateGraphicalContinuousDynamic: No endMeasure found");O.EndMeasure=J;const q=O.ParentStaffLine,et=J.ParentStaffLine,it=et&&q===et;let dt=!1;et?dt=et==null?void 0:et.isPartOfMultiStaffInstrument():q&&(dt=q==null?void 0:q.isPartOfMultiStaffInstrument());const mt=m.Fraction.createFromFraction(O.ContinuousDynamic.EndMultiExpression.AbsoluteTimestamp),yt=this.graphicalMusicSheet.GetVerticalContainerFromTimestamp(mt),Et=yt.getFirstNonNullStaffEntry().parentMeasure,Dt=Et.PositionAndShape.AbsolutePosition.x+Et.PositionAndShape.BorderRight;let Vt=new m.Fraction(0,0,0);for(const Ce of yt.StaffEntries){if((Ce==null?void 0:Ce.sourceStaffEntry.ParentStaff)!==q.ParentStaff)continue;const Re=(xi=Ce==null?void 0:Ce.sourceStaffEntry)==null?void 0:xi.calculateMaxNoteLength(!1);Re!=null&&Re.gt(Vt)&&(Vt=Re)}const Nt=!j&&O.ContinuousDynamic.DynamicType===tt.ContDynamicEnum.diminuendo,It=this.getRelativePositionInStaffLineFromTimestamp(mt,Q,et,dt,0,Nt),Ct=m.Fraction.plus(mt,Vt).clone();O.ContinuousDynamic.EndMultiExpression.EndOffsetFraction&&this.rules.UseEndOffsetForExpressions&&Ct.Add(O.ContinuousDynamic.EndMultiExpression.EndOffsetFraction);const zt=this.getRelativePositionInStaffLineFromTimestamp(Ct,Q,et,dt,0,O.ContinuousDynamic.DynamicType===tt.ContDynamicEnum.diminuendo),Xt=this.rules.SoftAccentWedgePadding,Ut=yt.getFirstNonNullStaffEntry().PositionAndShape.Size.width,Kt=this.rules.SoftAccentSizeFactor;j?(D.x-=Ut/2*Kt+Xt,It.x=D.x+Ut/2*Kt):zt.x>It.x&&zt.xte){const Te=Qt.StaffLines[Ce].PositionAndShape.RelativePosition.y-q.PositionAndShape.RelativePosition.y-this.rules.StaffHeight;we=this.rules.StaffHeight+Te/2}else we=this.rules.WedgePlacementBelowY;we-=this.rules.WedgeOpeningLength/2,it||(Ge=we);let Re=ie.getBottomLineMaxInRange(Ke,Xe);Re>we&&(we=Re);const He=!1;if(teGe&&(Ge=Re),Ge+=this.rules.WedgeOpeningLength/2,Ge+=this.rules.WedgeVerticalMargin),we+=this.rules.WedgeOpeningLength/2,we+=this.rules.WedgeVerticalMargin}else if($t===W.PlacementEnum.Above){if(q.ParentStaff.ParentInstrument.Staves.length===1)we=this.rules.WedgePlacementAboveY;else{let Re=0;te>0&&(Re=te-1);const He=Qt.StaffLines[Re];we=-(q.PositionAndShape.RelativePosition.y-He.PositionAndShape.RelativePosition.y-this.rules.StaffHeight)/2}we+=this.rules.WedgeOpeningLength/2,it||(Ge=we);let Ce=ie.getSkyLineMinInRange(Ke,Xe);if(Ce1&&te>0){const Re=q.findClosestStaffEntry(Ke),He=q.findClosestStaffEntry(Xe);Re&&He&&Re.parentVerticalContainer}it||(Ce=et.SkyBottomLineCalculator.getSkyLineMinInRange(De,Pi),CeTe&&(Te=Ye),Te+=this.rules.WedgeOpeningLength/2,Te+=this.rules.WedgeVerticalMargin}else if($t===W.PlacementEnum.Above){const Ye=He.SkyBottomLineCalculator.getSkyLineMinInRange(De,Pi);Ye-yt/2?-yt/2:dt-O.PositionAndShape.BorderMarginBottom}}else it=dt-O.PositionAndShape.BorderMarginBottom;O.PositionAndShape.RelativePosition=new S.PointF2D(D.x,it)}else if(O.Placement===W.PlacementEnum.Below){const dt=et.getBottomLineMaxInRange(J,q),mt=Q.ParentStaff.ParentInstrument.Staves[Q.ParentStaff.ParentInstrument.Staves.length-1];if(Q.isPartOfMultiStaffInstrument()&&Q.ParentStaff!==mt){const yt=Q.ParentMusicSystem.StaffLines[Q.ParentMusicSystem.StaffLines.indexOf(Q)+1];if(yt){const Et=yt.PositionAndShape.RelativePosition.y-Q.PositionAndShape.RelativePosition.y-this.rules.StaffHeight;it=dt+O.PositionAndShape.BorderMarginBottomO.PositionAndShape.Size.width&&(Vt=O.PositionAndShape.Size.width-this.rules.MeasureRightMargin,Dt=Vt-mt.PositionAndShape.MarginSize.width,D.x=Dt-mt.PositionAndShape.BorderMarginLeft),Dt0||!J[0])return;let et=J[0].ParentStaffLine,it=J[0].PositionAndShape.RelativePosition.x,dt=0;for(let mt=0;mt0){et=J[mt].ParentStaffLine,it=J[mt].PositionAndShape.RelativePosition.x,dt=mt;break}if(q=this.getRelativePositionInStaffLineFromTimestamp(Q,dt,et,et.isPartOfMultiStaffInstrument(),it),D.EntriesList.length>0&&D.EntriesList[0].Expression instanceof N.InstantaneousTempoExpression&&(D.EntriesList[0].Expression.Placement=W.PlacementEnum.Above,et.Measures[0].staffEntries.length>0&&Math.abs(q.x-et.Measures[0].staffEntries[0].PositionAndShape.RelativePosition.x)===0&&et.ParentMusicSystem===this.musicSystems[0])){const mt=et.Measures[0].FirstInstructionStaffEntry;if(mt){const yt=mt.GraphicalInstructions.last();q.x=yt.PositionAndShape.RelativePosition.x}this.rules.CompactMode&&(q.x=et.PositionAndShape.RelativePosition.x+et.Measures[0].PositionAndShape.RelativePosition.x)}for(const mt of D.EntriesList){let yt=this.rules.TempoExpressionTextAlignment;this.rules.CompactMode&&(yt=T.TextAlignmentEnum.LeftBottom);const Et=this.calculateLabel(et,q,mt.label,D.getFontstyleOfFirstEntry(),mt.Expression.Placement,this.rules.UnknownTextHeight,yt,this.rules.TempoYSpacing);if(mt.Expression.ColorXML&&this.rules.ExpressionsUseXMLColor&&(Et.ColorXML=mt.Expression.ColorXML),mt.Expression instanceof N.InstantaneousTempoExpression){for(const Dt of et.AbstractExpressions)Dt instanceof $.GraphicalInstantaneousTempoExpression&&(Dt.SourceExpression.Label,mt.Expression.Label);if(new $.GraphicalInstantaneousTempoExpression(mt.Expression,Et).ParentStaffLine||A.default.warn("Adding staffline didn't work"),this.rules.MetronomeMarksDrawn&&mt.Expression.TempoType===N.TempoType.metronomeMark){this.createMetronomeMark(mt.Expression);continue}}else if(mt.Expression instanceof Y.ContinuousTempoExpression){for(const Dt of et.AbstractExpressions)Dt instanceof $.GraphicalInstantaneousTempoExpression&&(Dt.SourceExpression.Label,mt.Expression.Label);et.AbstractExpressions.push(new $.GraphicalInstantaneousTempoExpression(mt.Expression,Et))}}}}createMetronomeMark(O){throw new Error(this.abstractNotImplementedErrorMessage)}graphicalMeasureCreatedCalculations(O){}clearSystemsAndMeasures(){for(let O=0,D=this.graphicalMusicSheet.MusicPages.length;O-1&&Et.PositionAndShape.ChildElements.splice(Dt,1),Et.FirstInstructionStaffEntry=void 0,Et.beginInstructionsWidth=0}if(Et.LastInstructionStaffEntry){const Dt=Et.PositionAndShape.ChildElements.indexOf(Et.LastInstructionStaffEntry.PositionAndShape);Dt>-1&&Et.PositionAndShape.ChildElements.splice(Dt,1),Et.LastInstructionStaffEntry=void 0,Et.endInstructionsWidth=0}}dt.Measures=[],dt.PositionAndShape.ChildElements=[]}q.StaffLines.length=0,q.PositionAndShape.ChildElements=[]}j.MusicSystems=[],j.PositionAndShape.ChildElements=[]}this.graphicalMusicSheet.MusicPages=[]}handleVoiceEntry(O,D,j,Q,J,q,et,it,dt,mt=void 0,yt=void 0){O.StemDirectionXml!==f.StemDirectionType.Undefined&&this.rules.SetWantedStemDirectionByXml&&O.StemDirectionXml!==void 0?O.WantedStemDirection=O.StemDirectionXml:this.calculateStemDirectionFromVoices(O);const Et=D.findOrCreateGraphicalVoiceEntry(O);Et.octaveShiftValue=it;const Dt=D.tabStaffEntry;let Vt;Dt&&(Vt=Dt.findOrCreateGraphicalVoiceEntry(O));for(let Nt=0,It=O.Notes.length;Nt-1)continue;let zt;if(O.IsGrace?zt=ht.symbolFactory.createGraceNote(Ct,Et,J,this.rules,it):(zt=ht.symbolFactory.createNote(Ct,Et,J,it,this.rules,void 0),ht.stafflineNoteCalculator.trackNote(zt)),Ct.Pitch&&this.checkNoteForAccidental(zt,j,J,it),this.resetYPositionForLeadSheet(zt.PositionAndShape),D.addGraphicalNoteToListAtCorrectYPosition(Et,zt),zt.PositionAndShape.calculateBoundingBox(),this.leadSheet||(Ct.NoteBeam!==void 0&&Ct.PrintObject&&(Ct instanceof at.TabNote&&!this.rules.TabBeamsRendered||this.handleBeam(zt,Ct.NoteBeam,et)),Ct.NoteTuplet!==void 0&&Ct.PrintObject&&this.handleTuplet(zt,Ct.NoteTuplet,q)),Vt){const Xt=ht.symbolFactory.createNote(Ct,Vt,J,it,this.rules,void 0);Dt.addGraphicalNoteToListAtCorrectYPosition(Vt,Xt),Xt.PositionAndShape.calculateBoundingBox(),this.leadSheet||Ct.NoteTuplet&&this.handleTuplet(Xt,Ct.NoteTuplet,q)}}return O.Articulations.length>0&&this.handleVoiceEntryArticulations(O.Articulations,O,D),O.TechnicalInstructions.length>0&&this.handleVoiceEntryTechnicalInstructions(O.TechnicalInstructions,O,D),O.LyricsEntries.size()>0&&this.handleVoiceEntryLyrics(O,D,Q),O.OrnamentContainer&&this.handleVoiceEntryOrnaments(O.OrnamentContainer,O,D),it}resetYPositionForLeadSheet(O){this.leadSheet&&(O.RelativePosition=new S.PointF2D(O.RelativePosition.x,0))}layoutVoiceEntries(O,D){if(O.PositionAndShape.RelativePosition=new S.PointF2D(0,0),!this.leadSheet)for(const j of O.graphicalVoiceEntries){const Q=j.notes;if(Q.length===0)continue;const J=Q[0].sourceNote.ParentVoiceEntry,q=Q[0].sourceNote.Pitch!==void 0;this.layoutVoiceEntry(J,Q,O,q)}}maxInstrNameLabelLength(){var D;let O=0;for(const j of this.graphicalMusicSheet.ParentMusicSheet.Instruments)if((D=j.NameLabel)!=null&&D.print&&j.Voices.length>0&&j.Voices[0].Visible){let Q=j.NameLabel;this.rules.RenderPartNames||(Q=new C.Label("",Q.textAlignment,Q.font));const J=new w.GraphicalLabel(Q,this.rules.InstrumentLabelTextHeight,T.TextAlignmentEnum.LeftCenter,this.rules);J.setLabelPositionAndShapeBorders(),O=Math.max(O,J.PositionAndShape.MarginSize.width)}return this.rules.RenderPartNames?O:0}calculateSheetLabelBoundingBoxes(){const O=this.graphicalMusicSheet.ParentMusicSheet,D=this.rules.DefaultColorTitle;if(O.Title!==void 0&&this.rules.RenderTitle){const j=new w.GraphicalLabel(O.Title,this.rules.SheetTitleHeight,T.TextAlignmentEnum.CenterBottom,this.rules);j.Label.IsCreditLabel=!0,j.Label.colorDefault=D,this.graphicalMusicSheet.Title=j,j.setLabelPositionAndShapeBorders()}else this.rules.RenderTitle||(this.graphicalMusicSheet.Title=void 0);if(O.Subtitle!==void 0&&this.rules.RenderSubtitle){const j=new w.GraphicalLabel(O.Subtitle,this.rules.SheetSubtitleHeight,T.TextAlignmentEnum.CenterCenter,this.rules);j.Label.IsCreditLabel=!0,j.Label.colorDefault=D,this.graphicalMusicSheet.Subtitle=j,j.setLabelPositionAndShapeBorders()}else this.rules.RenderSubtitle||(this.graphicalMusicSheet.Subtitle=void 0);if(O.Composer!==void 0&&this.rules.RenderComposer){const j=new w.GraphicalLabel(O.Composer,this.rules.SheetComposerHeight,T.TextAlignmentEnum.RightCenter,this.rules);j.Label.IsCreditLabel=!0,j.Label.colorDefault=D,this.graphicalMusicSheet.Composer=j,j.setLabelPositionAndShapeBorders()}else this.rules.RenderComposer||(this.graphicalMusicSheet.Composer=void 0);if(O.Lyricist!==void 0&&this.rules.RenderLyricist){const j=new w.GraphicalLabel(O.Lyricist,this.rules.SheetAuthorHeight,T.TextAlignmentEnum.LeftCenter,this.rules);j.Label.IsCreditLabel=!0,j.Label.colorDefault=D,this.graphicalMusicSheet.Lyricist=j,j.setLabelPositionAndShapeBorders()}else this.rules.RenderLyricist||(this.graphicalMusicSheet.Lyricist=void 0);if(O.Copyright!==void 0&&this.rules.RenderCopyright){const j=new w.GraphicalLabel(O.Copyright,this.rules.SheetCopyrightHeight,T.TextAlignmentEnum.CenterBottom,this.rules);j.Label.IsCreditLabel=!0,j.Label.colorDefault=D,this.graphicalMusicSheet.Copyright=j,j.setLabelPositionAndShapeBorders()}else this.rules.RenderCopyright||(this.graphicalMusicSheet.Copyright=void 0)}checkMeasuresForWholeRestNotes(){for(let O=0,D=this.musicSystems.length;O0&&mt.graphicalVoiceEntries[0].notes.length===1){const yt=mt.graphicalVoiceEntries[0].notes[0];!yt.sourceNote.Pitch&&new m.Fraction(1,2).lt(yt.sourceNote.Length)&&this.layoutMeasureWithWholeRest(yt,mt,dt)}}}}}}optimizeRestNotePlacement(O,D){if(O.graphicalVoiceEntries.length===0)return;const j=O.graphicalVoiceEntries[0].notes;if(j.length===0)return;const Q=j[0],J=Q.sourceNote.isRest();if(O.graphicalVoiceEntries.length===2){let q=!1;const et=O.graphicalVoiceEntries[1].notes;et.length>0&&(q=et[0].sourceNote.isRest()),J&&q?this.calculateTwoRestNotesPlacementWithCollisionDetection(O):(J||q)&&this.calculateRestNotePlacementWithCollisionDetectionFromGraphicalNote(O)}else if(J&&O!==D.staffEntries[0]&&O!==D.staffEntries[D.staffEntries.length-1]){const q=D.staffEntries.indexOf(O),et=D.staffEntries[q-1],it=D.staffEntries[q+1];if(et.graphicalVoiceEntries.length===1){const dt=et.graphicalVoiceEntries[0].notes[0];if(dt.sourceNote.NoteBeam!==void 0&&it.graphicalVoiceEntries.length===1){const mt=it.graphicalVoiceEntries[0].notes[0];mt.sourceNote.NoteBeam!==void 0&&dt.sourceNote.NoteBeam===mt.sourceNote.NoteBeam&&(this.calculateRestNotePlacementWithinGraphicalBeam(O,Q,dt,it,mt),O.PositionAndShape.calculateBoundingBox())}}}}getRelativePositionInStaffLineFromTimestamp(O,D,j,Q,J=0,q=!1){let et,it,dt=new S.PointF2D;const mt=this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers.length,yt=this.graphicalMusicSheet.GetInterpolatedIndexInVerticalContainers(O),Et=Math.min(Math.floor(yt),mt-1),Dt=Math.min(Math.ceil(yt),mt-1);if(Et<0||D<0)return dt;if(et=this.getFirstLeftNotNullStaffEntryFromContainer(Et,D,Q),it=this.getFirstRightNotNullStaffEntryFromContainer(Dt,D,Q),et&&it){let Vt=et.parentMeasure.PositionAndShape.RelativePosition.x;J>0&&(Vt=J);let Nt=et.PositionAndShape.RelativePosition.x+Vt,It=it.PositionAndShape.RelativePosition.x+it.parentMeasure.PositionAndShape.RelativePosition.x;const Ct=O.RealValue>it.getAbsoluteTimestamp().RealValue;J>0?It=it.PositionAndShape.RelativePosition.x+Vt:q&&(et.getAbsoluteTimestamp().RealValue===O.RealValue||Ct)&&(Nt=et.PositionAndShape.RelativePosition.x+et.PositionAndShape.BorderLeft+Vt,It=Nt);let zt=0;if(et!==it){const Xt=et.getAbsoluteTimestamp(),Ut=it.getAbsoluteTimestamp();zt=m.Fraction.minus(O,Xt).RealValue/m.Fraction.minus(Ut,Xt).RealValue}et.parentMeasure.ParentStaffLine!==it.parentMeasure.ParentStaffLine&&(et.parentMeasure.ParentStaffLine===j?It=j.PositionAndShape.Size.width:Nt=j.PositionAndShape.RelativePosition.x),dt=new S.PointF2D(Nt+(It-Nt)*zt,0)}return dt}getRelativeXPositionFromTimestamp(O){const D=this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers.length,j=this.graphicalMusicSheet.GetInterpolatedIndexInVerticalContainers(O),Q=Math.max(0,Math.min(Math.round(j),D-1)),J=this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers[Q].getFirstNonNullStaffEntry();return J.PositionAndShape.RelativePosition.x+J.parentMeasure.PositionAndShape.RelativePosition.x}calculatePageLabels(O){var dt,mt;this.rules.RenderSingleHorizontalStaffline&&(O.PositionAndShape.calculateBoundingBox([s.GraphicalMeasure.name]),this.graphicalMusicSheet.ParentMusicSheet.pageWidth=O.PositionAndShape.Size.width);let D=10,j=-1;if(O.MusicSystems.length>0){const yt=O.MusicSystems[0];D=yt.PositionAndShape.RelativePosition.y+yt.PositionAndShape.BorderTop;const Et=O.MusicSystems[O.MusicSystems.length-1];j=Et.PositionAndShape.RelativePosition.y+Et.PositionAndShape.BorderBottom}const Q=this.graphicalMusicSheet.Title;if(Q&&this.rules.RenderTitle){Q.PositionAndShape.Parent=O.PositionAndShape;const yt=new S.PointF2D;yt.x=this.graphicalMusicSheet.ParentMusicSheet.pageWidth/2,this.rules.RenderSingleHorizontalStaffline&&(yt.x=Math.max(yt.x,Q.PositionAndShape.Size.width)),yt.y=this.rules.TitleTopDistance+this.rules.SheetTitleHeight,Q.PositionAndShape.RelativePosition=yt,O.Labels.push(Q)}if(this.graphicalMusicSheet.Subtitle&&this.rules.RenderTitle&&this.rules.RenderSubtitle){const yt=this.graphicalMusicSheet.Subtitle;yt.PositionAndShape.Parent=O.PositionAndShape;const Et=new S.PointF2D;Et.x=this.graphicalMusicSheet.ParentMusicSheet.pageWidth/2,this.rules.RenderSingleHorizontalStaffline&&(Et.x=Q.PositionAndShape.RelativePosition.x),Et.y=this.rules.TitleTopDistance+this.rules.SheetTitleHeight+this.rules.SheetMinimumDistanceBetweenTitleAndSubtitle;const Dt=(dt=yt.TextLines)==null?void 0:dt.length;Dt>1&&(Et.y+=yt.PositionAndShape.BorderBottom*(Dt-1)/Dt),yt.PositionAndShape.RelativePosition=Et,O.Labels.push(yt)}const J=this.graphicalMusicSheet.Composer;let q;if(J&&this.rules.RenderComposer){J.PositionAndShape.Parent=O.PositionAndShape,J.setLabelPositionAndShapeBorders();const yt=new S.PointF2D;yt.x=this.graphicalMusicSheet.ParentMusicSheet.pageWidth-this.rules.PageRightMargin,yt.y=D,yt.y-=this.rules.SystemComposerDistance;const Et=(mt=J.TextLines)==null?void 0:mt.length;Et>1&&(yt.y-=J.PositionAndShape.BorderBottom*(Et-1)/Et),q=yt.y,J.PositionAndShape.RelativePosition=yt,O.Labels.push(J)}const et=this.graphicalMusicSheet.Lyricist;if(et&&this.rules.RenderLyricist){et.PositionAndShape.Parent=O.PositionAndShape,et.setLabelPositionAndShapeBorders();const yt=new S.PointF2D;yt.x=this.rules.PageLeftMargin,yt.y=D,yt.y-=this.rules.SystemLyricistDistance,yt.y+=et.PositionAndShape.BorderBottom,yt.y=Math.min(yt.y,q??Number.MAX_SAFE_INTEGER),et.PositionAndShape.RelativePosition=yt,O.Labels.push(et)}const it=this.graphicalMusicSheet.Copyright;if(it&&this.rules.RenderCopyright){it.PositionAndShape.Parent=O.PositionAndShape,it.setLabelPositionAndShapeBorders();const yt=new S.PointF2D;yt.x=O.PositionAndShape.Size.width/2,yt.y=j+this.rules.SheetCopyrightMargin,yt.y-=it.PositionAndShape.BorderTop,it.PositionAndShape.RelativePosition=yt,O.Labels.push(it)}this.rules.RenderSingleHorizontalStaffline&&(O.PositionAndShape.calculateBoundingBox([s.GraphicalMeasure.name]),this.graphicalMusicSheet.ParentMusicSheet.pageWidth=O.PositionAndShape.Size.width)}createGraphicalTies(){for(let O=0;O=0&&this.staffEntriesWithGraphicalTies.push(it)}it=q}}setTieDirections(O){if(!O)return;const D=O.ties;if(D.length===1){const j=D[0];if(j.TieDirection===W.PlacementEnum.NotYetDefined){const Q=j.Notes[0].ParentVoiceEntry.ParentVoice.VoiceId;Q!==2&&Q!==6||(j.TieDirection=W.PlacementEnum.Below)}}if(D.length>1){let j;for(const Q of D){const J=Q.Notes[0];(!j||J.Pitch.getHalfTone()>j.Pitch.getHalfTone())&&(j=J)}for(const Q of D)Q.TieDirection===W.PlacementEnum.NotYetDefined&&(Q.Notes[0]===j?Q.TieDirection=W.PlacementEnum.Above:Q.TieDirection=W.PlacementEnum.Below)}}createAccidentalCalculators(){var j;const O=[],D=this.graphicalMusicSheet.ParentMusicSheet.getFirstSourceMeasure();if(D){const Q=this.graphicalMusicSheet.ParentMusicSheet.Transpose;for(let J=0;J1)return;yt=ht.symbolFactory.createGraphicalMeasure(O,mt)}if(yt.hasError=O.getErrorInMeasure(it),O.FirstInstructionsStaffEntries[it])for(let Ut=0,Kt=O.FirstInstructionsStaffEntries[it].Instructions.length;Ut0&&((Ct=te.ParentEndMultiExpression)!=null&&Ct.AbsoluteTimestamp.Equals(Kt.AbsoluteTimestamp))&&$t>=te.endVoiceEntryIndex&&(ie=u.OctaveEnum.NONE,te=void 0),ie=this.handleVoiceEntry(Ke,qt,Q,et,J[it],D,j,ie,it,Qt,Kt)}for(const $t of Kt.Instructions)if($t instanceof h.ClefInstruction){ht.symbolFactory.createInStaffClef(qt,$t);break}this.rules.RenderChordSymbols&&((zt=Kt.ChordContainers)==null?void 0:zt.length)>0&&(Kt.ParentStaff.ParentInstrument.HasChordSymbols=!0,ht.symbolFactory.createChordSymbols(Kt,qt,Q.ActiveKeyInstruction,this.graphicalMusicSheet.ParentMusicSheet.Transpose))}}if(Q.doCalculationsAtEndOfMeasure(),O.LastInstructionsStaffEntries[it]){const Ut=O.LastInstructionsStaffEntries[it];for(let Kt=0,qt=Ut.Instructions.length;Kt=1&&yt.staffEntries.length===0){const Ut=new v.SourceStaffEntry(new z.VerticalSourceStaffEntryContainer(yt.parentSourceMeasure,yt.parentSourceMeasure.AbsoluteTimestamp,yt.parentSourceMeasure.CompleteNumberOfStaves),mt);if(mt.Voices.length===0){const ae=new st.Voice(yt.ParentStaff.ParentInstrument,-1);mt.Voices.push(ae)}const Kt=new f.VoiceEntry(new m.Fraction(0,1),mt.Voices[0],Ut);let qt=O.Duration;qt.RealValue===0&&(qt=O.ActiveTimeSignature.clone());const Qt=new a.Note(Kt,Ut,qt,void 0,O,!0);Qt.IsWholeMeasureRest=!0,Qt.PrintObject=this.rules.FillEmptyMeasuresWithWholeRest===rt.FillEmptyMeasuresWithWholeRests.YesVisible,Kt.Notes.push(Qt);const te=ht.symbolFactory.createStaffEntry(Ut,yt);yt.addGraphicalStaffEntry(te),te.relInMeasureTimestamp=Kt.Timestamp;const ie=ht.symbolFactory.createVoiceEntry(Kt,te);te.graphicalVoiceEntries.push(ie);const $t=ht.symbolFactory.createNote(Qt,ie,new h.ClefInstruction,u.OctaveEnum.NONE,this.rules);ht.stafflineNoteCalculator.trackNote($t),ie.notes.push($t)}yt.hasOnlyRests=!0;for(const Ut of yt.staffEntries)if(yt.hasOnlyRests=Ut.hasOnlyRests(),!yt.hasOnlyRests)break;return yt}checkNoteForAccidental(O,D,j,Q){let J=O.sourceNote.Pitch;const q=O.parentVoiceEntry.parentStaffEntry.parentMeasure.getTransposedHalftones();q!==0&&O.sourceNote.ParentStaffEntry.ParentStaff.ParentInstrument.MidiInstrumentId!==R.MidiInstrument.Percussion?(J=O.Transpose(D.ActiveKeyInstruction,j,q,Q),O.sourceNote.TransposedPitch=J):O.sourceNote.TransposedPitch=void 0,O.sourceNote.halfTone=J.getHalfTone(),D.checkAccidental(O,J)}handleStaffEntries(O){for(let D=0,j=this.graphicalMusicSheet.MeasureList.length;D0&&!this.rules.PercussionUseCajon2NoteSystem&&O[J]&&(this.rules.PercussionOneLineCutoff===-1||ht.stafflineNoteCalculator.getStafflineUniquePositionCount(J)0&&it.graphicalVoiceEntries[0].notes.length>0&&(this.layoutVoiceEntries(it,J),this.layoutStaffEntry(it));this.graphicalMeasureCreatedCalculations(et)}}}}calculateSkyBottomLines(){}calculateExpressionAlignements(){}calculateStaffEntryArticulationMarks(){for(let O=0,D=this.musicSystems.length;O0&&this.layoutArticulationMarks(Nt.Articulations,Nt,Et)}}}}}}calculateOrnaments(){for(let O=0,D=this.musicSystems.length;O0){let yt;q===W.PlacementEnum.Below&&mt.reverse();for(const Et of et.graphicalVoiceEntries)for(const Dt of Et.notes)(!yt||((O=Dt.sourceNote.Pitch)==null?void 0:O.getHalfTone())>((D=yt.Pitch)==null?void 0:D.getHalfTone()))&&(yt=Dt.sourceNote);mt[0].sourceNote===yt&&q===W.PlacementEnum.Above&&mt.reverse()}for(let yt=0;yt0&&Q.LyricVersesNumbers.sort()}for(let D=0,j=this.musicSystems.length;D=0&&(Q=D.GraphicalLyricsEntries[j+1]),!Q)return;const J=O.StaffEntryParent.parentMeasure.ParentStaffLine,q=Q.StaffEntryParent.parentMeasure.ParentStaffLine,et=O.StaffEntryParent,it=Q.StaffEntryParent;if(O.StaffEntryParent.parentMeasure.ParentStaffLine===Q.StaffEntryParent.parentMeasure.ParentStaffLine){const dt=et.parentMeasure.PositionAndShape.RelativePosition.x+et.PositionAndShape.RelativePosition.x+O.GraphicalLabel.PositionAndShape.RelativePosition.x+O.GraphicalLabel.PositionAndShape.BorderMarginRight-O.GraphicalLabel.CenteringXShift,mt=it.parentMeasure.PositionAndShape.RelativePosition.x+it.PositionAndShape.RelativePosition.x+O.GraphicalLabel.PositionAndShape.RelativePosition.x+Q.GraphicalLabel.PositionAndShape.BorderMarginLeft,yt=O.GraphicalLabel.PositionAndShape.RelativePosition.y;let Et=1;mt-dt>3*this.rules.MinimumDistanceBetweenDashes&&(Et=Math.floor((mt-dt)/this.rules.MinimumDistanceBetweenDashes)-1),Et===1?this.calculateSingleDashForLyricWord(J,dt,mt,yt):this.calculateDashes(J,dt,mt,yt)}else{const dt=et.parentMeasure.PositionAndShape.RelativePosition.x+et.PositionAndShape.RelativePosition.x+O.GraphicalLabel.PositionAndShape.BorderMarginRight,mt=J.Measures[J.Measures.length-1],yt=mt.PositionAndShape.RelativePosition.x+mt.PositionAndShape.Size.width;let Et=O.GraphicalLabel.PositionAndShape.RelativePosition.y;if(this.calculateDashes(J,dt,yt,Et),q&&q.Measures[0]&&it.parentMeasure.ParentStaffLine&&(it!==it.parentMeasure.staffEntries[0]||it.parentMeasure!==it.parentMeasure.ParentStaffLine.Measures[0])){const Dt=q.Measures[0].staffEntries[0].PositionAndShape.RelativePosition.x,Vt=it.parentMeasure.PositionAndShape.RelativePosition.x+it.PositionAndShape.RelativePosition.x+Q.GraphicalLabel.PositionAndShape.BorderMarginLeft;Et=Q.GraphicalLabel.PositionAndShape.RelativePosition.y,this.calculateDashes(q,Dt,Vt,Et)}}}calculateDashes(O,D,j,Q){let J=j-D;if(J<3*this.rules.MinimumDistanceBetweenDashes)this.calculateSingleDashForLyricWord(O,D,j,Q);else{const q=Math.floor(J/this.rules.MinimumDistanceBetweenDashes)-1,et=J/(q+1);let it=0;for(D+=et,j-=et;it<=Math.floor(q/2)&&j>D;)J=this.calculateRightAndLeftDashesForLyricWord(O,D,j,Q),D+=et,j-=et,it++;J>2*et&&this.calculateSingleDashForLyricWord(O,D,j,Q)}}calculateSingleDashForLyricWord(O,D,j,Q){const J=new C.Label("-");J.colorDefault=this.rules.DefaultColorLyrics;let q=this.rules.LyricsHeight;j-D<.8&&(q*=.8,Q-=.1*q);const et=new w.GraphicalLabel(J,q,T.TextAlignmentEnum.CenterBottom,this.rules);et.setLabelPositionAndShapeBorders(),O.LyricsDashes.push(et),this.staffLinesWithLyricWords.indexOf(O)===-1&&this.staffLinesWithLyricWords.push(O),et.PositionAndShape.Parent=O.PositionAndShape;const it=new S.PointF2D(D+(j-D)/2,Q);et.PositionAndShape.RelativePosition=it}calculateLyricExtend(O){let D=O.GraphicalLabel.PositionAndShape.RelativePosition.y;const j=O.StaffEntryParent,Q=j.parentMeasure.ParentStaffLine;let J,q;const et=j.parentMeasure.ParentStaff.idInMusicSheet;if(j.parentVerticalContainer){for(let it=j.parentVerticalContainer.Index+1;it0)break;J=dt,q=J.parentMeasure.ParentStaffLine,q||(q=j.parentMeasure.ParentStaffLine)}}if(J&&q)if(Q===q&&J.parentMeasure.ParentStaffLine){const it=j.parentMeasure.PositionAndShape.RelativePosition.x+j.PositionAndShape.RelativePosition.x+O.GraphicalLabel.PositionAndShape.BorderMarginRight,dt=J.parentMeasure.PositionAndShape.RelativePosition.x+J.PositionAndShape.RelativePosition.x+J.PositionAndShape.BorderMarginRight;D-=O.GraphicalLabel.PositionAndShape.Size.height/4,this.calculateSingleLyricWordWithUnderscore(Q,it,dt,D)}else{const it=Q.Measures[Q.Measures.length-1].PositionAndShape,dt=j.parentMeasure.PositionAndShape.RelativePosition.x+j.PositionAndShape.RelativePosition.x+O.GraphicalLabel.PositionAndShape.BorderMarginRight,mt=it.RelativePosition.x+it.Size.width;if(D-=O.GraphicalLabel.PositionAndShape.Size.height/4,this.calculateSingleLyricWordWithUnderscore(Q,dt,mt,D),!J)return;if(J.parentMeasure.ParentStaffLine&&J.parentMeasure.staffEntries&&(J!==J.parentMeasure.staffEntries[0]||J.parentMeasure!==J.parentMeasure.ParentStaffLine.Measures[0])){const yt=q.Measures[0].staffEntries[0].PositionAndShape.RelativePosition.x,Et=J.parentMeasure.PositionAndShape.RelativePosition.x+J.PositionAndShape.RelativePosition.x+J.PositionAndShape.BorderMarginRight;this.calculateSingleLyricWordWithUnderscore(q,yt,Et,D)}}}}calculateSingleLyricWordWithUnderscore(O,D,j,Q){const J=new S.PointF2D(D,Q),q=new S.PointF2D(j,Q),et=new U.GraphicalLine(J,q,this.rules.LyricUnderscoreLineWidth);et.colorHex=this.rules.DefaultColorLyrics,O.LyricLines.push(et),this.staffLinesWithLyricWords.indexOf(O)===-1&&this.staffLinesWithLyricWords.push(O)}calculateRightAndLeftDashesForLyricWord(O,D,j,Q){const J=new C.Label("-");J.colorDefault=this.rules.DefaultColorLyrics;const q=new w.GraphicalLabel(J,this.rules.LyricsHeight,T.TextAlignmentEnum.CenterBottom,this.rules);q.setLabelPositionAndShapeBorders(),O.LyricsDashes.push(q),this.staffLinesWithLyricWords.indexOf(O)===-1&&this.staffLinesWithLyricWords.push(O),q.PositionAndShape.Parent=O.PositionAndShape;const et=new S.PointF2D(D,Q);q.PositionAndShape.RelativePosition=et;const it=new C.Label("-"),dt=new w.GraphicalLabel(it,this.rules.LyricsHeight,T.TextAlignmentEnum.CenterBottom,this.rules);dt.setLabelPositionAndShapeBorders(),O.LyricsDashes.push(dt),dt.PositionAndShape.Parent=O.PositionAndShape;const mt=new S.PointF2D(j,Q);return dt.PositionAndShape.RelativePosition=mt,dt.PositionAndShape.RelativePosition.x-q.PositionAndShape.RelativePosition.x}calculateDynamicExpressions(){const O=Math.min(this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.length-1,this.rules.MaxMeasureToDrawIndex);for(let D=Math.min(this.rules.MinMeasureToDrawIndex,this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.length);D<=O;D++){const j=this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures[D];this.dynamicExpressionMap.clear();for(let Q=0;Q=0;Q--)if(this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers[Q].StaffEntries[D])return this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers[Q].StaffEntries[D]}getFirstRightNotNullStaffEntryFromContainer(O,D,j){if(this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers[O].StaffEntries[D])return this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers[O].StaffEntries[D];for(let Q=O+1;Q0){const et=O[O.length-1];if(D>et.startMeasure){const it=new r.RepetitionInstruction(D,r.RepetitionInstructionEnum.Ending,r.AlignmentType.Mid,void 0,et.endingIndices);this.calculateWordRepetitionInstruction(it,D)}}q&&O.length>0&&O.pop()}}calculateRepetitionEndings(){const O=this.graphicalMusicSheet.ParentMusicSheet;for(let D=0,j=O.Repetitions.length;D0||j.StaffLinkedExpressions[Q][q].UnknownList.length>0)&&this.calculateMoodAndUnknownExpression(j.StaffLinkedExpressions[Q][q],D,J)}}}calculateStemDirectionFromVoices(O){if(O.ParentSourceStaffEntry.Link!==void 0)return O===O.ParentSourceStaffEntry.VoiceEntries[0]?void(O.WantedStemDirection=f.StemDirectionType.Up):void(O.WantedStemDirection=f.StemDirectionType.Down);O.ParentVoice instanceof P.LinkedVoice?O.WantedStemDirection=f.StemDirectionType.Down:O.ParentSourceStaffEntry.VoiceEntries.length>1&&(O.WantedStemDirection=f.StemDirectionType.Up)}setBeamNotesWantedStemDirections(O){var j;if(!(O.Notes.length>0))return;const D=O.Notes[0].NoteBeam;if(D){for(const Q of D.Notes)if(((j=Q.Notehead)==null?void 0:j.Shape)!==F.NoteHeadShape.NONE&&Q.ParentVoiceEntry.WantedStemDirection!==f.StemDirectionType.Undefined&&Q.ParentVoiceEntry.ParentSourceStaffEntry.ParentStaff.Id===O.ParentSourceStaffEntry.ParentStaff.Id){O.WantedStemDirection=Q.ParentVoiceEntry.WantedStemDirection;break}}}}y.MusicSheetCalculator=ht},1932(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.MusicSheetDrawer=void 0;const d=p(6438),l=p(2683),m=p(6452),a=p(200),s=p(9409),h=p(8254),u=p(7435),f=p(7533),r=p(7307),b=p(4284),S=p(512),v=p(242),w=p(7499),T=p(298);y.MusicSheetDrawer=class{constructor(g,x){this.drawableBoundingBoxElement="None",this.skyLineVisible=!1,this.bottomLineVisible=!1,this.phonicScoreMode=v.PhonicScoreModes.Manual,this.textMeasurer=g,this.splitScreenLineColor=-1,this.drawingParameters=x,this.rules=x.Rules}set Mode(g){this.phonicScoreMode=g}drawSheet(g){if(this.graphicalMusicSheet=g,this.rules=g.ParentMusicSheet.Rules,this.drawSplitScreenLine(),this.drawingParameters.drawCursors)for(const P of g.Cursors){if(!P)continue;const _=new d.BoundingBox(P);_.AbsolutePosition=P.Start,_.BorderBottom=P.End.y-P.Start.y,_.BorderRight=P.Width/2,_.BorderLeft=-P.Width/2,this.isVisible(_)&&this.drawLineAsVerticalRectangle(P,l.GraphicalLayers.Cursor)}this.drawingParameters.drawScrollIndicator&&this.drawScrollIndicator();const x=Math.min(this.graphicalMusicSheet.MusicPages.length,this.rules.MaxPageToDrawNumber);for(let P=0;P0&&this.drawDashes(G.LyricsDashes),G.LyricLines.length>0&&this.drawLyricLines(G.LyricLines,G));for(const G of g.SystemLines)this.drawSystemLineObject(G);if(this.rules.RenderSystemLabelsAfterFirstPage||g.Parent===g.Parent.Parent.MusicPages[0])for(const G of g.Labels)G.SVGNode=this.drawLabel(G,l.GraphicalLayers.Notes);const k=this.graphicalMusicSheet.ParentMusicSheet.Instruments,R=k.filter(G=>G.isVisible()).length;for(const G of g.InstrumentBrackets)this.drawInstrumentBrace(G,g);if(k.length>0)if(R>1)for(const G of g.GroupBrackets)this.drawGroupBracket(G,g);else for(const G of g.GroupBrackets)G.Visible=!1;if(!this.leadSheet)for(const G of g.MeasureNumberLabels)G.SVGNode=this.drawLabel(G,l.GraphicalLayers.Notes),(A=(F=G.SVGNode)==null?void 0:F.classList)==null||A.add("measure-number");for(const G of g.StaffLines)this.drawStaffLineSymbols(G);this.drawingParameters.drawMarkedAreas&&this.drawMarkedAreas(g),this.drawingParameters.drawComments&&this.drawComment(g)}activateSystemRendering(g,x,P,_){return!0}drawSystemLineObject(g){}drawStaffLine(g){for(const x of g.Measures)this.drawMeasure(x);this.rules.RenderLyrics&&g.LyricsDashes.length>0&&this.drawDashes(g.LyricsDashes),this.drawOctaveShifts(g),this.drawPedals(g),this.drawWavyLines(g),this.drawExpressions(g),this.skyLineVisible&&this.drawSkyLine(g),this.bottomLineVisible&&this.drawBottomLine(g)}drawLyricLines(g,x){x.LyricLines.forEach(P=>{P.Start.y+=x.PositionAndShape.AbsolutePosition.y,P.End.y+=x.PositionAndShape.AbsolutePosition.y,P.Start.x+=x.PositionAndShape.AbsolutePosition.x,P.End.x+=x.PositionAndShape.AbsolutePosition.x,this.drawGraphicalLine(P,this.rules.LyricUnderscoreLineWidth,P.colorHex)})}drawExpressions(g){}drawGraphicalLine(g,x,P="black"){return this.drawLine(g.Start,g.End,P,x)}drawLine(g,x,P="#FF0000FF",_){}drawDashes(g){g.forEach(x=>{var P;x.SVGNode=this.drawLabel(x,l.GraphicalLayers.Notes),(P=x.SVGNode)==null||P.classList.add("dash")})}drawOctaveShifts(g){}drawStaffLines(g){if(g.StaffLines){const x=g.PositionAndShape.AbsolutePosition;for(let P=0;P<5;P++)this.drawLineAsHorizontalRectangleWithOffset(g.StaffLines[P],x,l.GraphicalLayers.Notes)}}drawInstantaneousDynamic(g){throw new Error("not implemented")}drawContinuousDynamic(g){throw new Error("not implemented")}drawSymbol(g,x,P,_=1,B=l.GraphicalLayers.Notes){}get leadSheet(){return this.graphicalMusicSheet.LeadSheet}set leadSheet(g){this.graphicalMusicSheet.LeadSheet=g}drawPage(g){if(this.isVisible(g.PositionAndShape)){for(const x of g.MusicSystems)this.isVisible(x.PositionAndShape)&&this.drawMusicSystem(x);if(g===g.Parent.MusicPages[0])for(const x of g.Labels)x.SVGNode=this.drawLabel(x,l.GraphicalLayers.Notes);this.drawableBoundingBoxElement&&this.drawBoundingBoxes(g.PositionAndShape,0,this.drawableBoundingBoxElement)}}drawBoundingBoxes(g,x=0,P="all",_=!1){const B=g.DataObject.constructor.name;let k=!1;if(P==="all"?k=!0:P==="VexFlowStaffEntry"?k=g.DataObject instanceof w.VexFlowStaffEntry:P==="VexFlowMeasure"?k=g.DataObject instanceof w.VexFlowMeasure:P==="VexFlowGraphicalNote"?k=g.DataObject instanceof w.VexFlowGraphicalNote:P==="VexFlowVoiceEntry"?k=g.DataObject instanceof w.VexFlowVoiceEntry:P==="GraphicalLabel"?k=g.DataObject instanceof h.GraphicalLabel:P==="VexFlowStaffLine"?k=g.DataObject instanceof w.VexFlowStaffLine:P==="SystemLine"?k=g.DataObject instanceof b.SystemLine:P==="StaffLineActivitySymbol"?k=g.DataObject instanceof T.StaffLineActivitySymbol:P==="VexFlowContinuousDynamicExpression"&&(k=g.DataObject instanceof w.VexFlowContinuousDynamicExpression),k||B===P){let R;_&&(R=B),this.drawBoundingBox(g,void 0,!0,R,x)}x++,g.ChildElements.forEach(R=>this.drawBoundingBoxes(R,x,P))}drawBoundingBox(g,x=void 0,P=!1,_=void 0,B=0){let k=new a.RectangleF2D(g.AbsolutePosition.x+g.BorderMarginLeft,g.AbsolutePosition.y+g.BorderMarginTop,g.BorderMarginRight-g.BorderMarginLeft,g.BorderMarginBottom-g.BorderMarginTop);P&&(this.drawLineAsHorizontalRectangle(new m.GraphicalLine(new s.PointF2D(g.AbsolutePosition.x-1,g.AbsolutePosition.y),new s.PointF2D(g.AbsolutePosition.x+1,g.AbsolutePosition.y),.1,l.OutlineAndFillStyleEnum.BaseWritingColor,x),B-1),this.drawLineAsVerticalRectangle(new m.GraphicalLine(new s.PointF2D(g.AbsolutePosition.x,g.AbsolutePosition.y-1),new s.PointF2D(g.AbsolutePosition.x,g.AbsolutePosition.y+1),.1,l.OutlineAndFillStyleEnum.BaseWritingColor,x),B-1)),k=this.applyScreenTransformationForRect(k);const R=this.renderRectangle(k,l.GraphicalLayers.Background,B,x,.5);if(_){const F=new u.Label(_),A=new h.GraphicalLabel(F,.8,f.TextAlignmentEnum.CenterCenter,this.rules);A.setLabelPositionAndShapeBorders(),this.renderLabel(A,B,k.width,k.height,k.height,new s.PointF2D(k.x,k.y+12))}return R}drawMarkedAreas(g){for(const x of g.GraphicalMarkedAreas)x&&(x.systemRectangle&&this.drawRectangle(x.systemRectangle,l.GraphicalLayers.Background),x.settings&&(x.settings.SVGNode=this.drawLabel(x.settings,l.GraphicalLayers.Comment)),x.labelRectangle&&this.drawRectangle(x.labelRectangle,l.GraphicalLayers.Background),x.label&&(x.label.SVGNode=this.drawLabel(x.label,l.GraphicalLayers.Comment)))}drawComment(g){for(const x of g.GraphicalComments)x&&(x.settings&&(x.settings.SVGNode=this.drawLabel(x.settings,l.GraphicalLayers.Comment)),x.label&&(x.label.SVGNode=this.drawLabel(x.label,l.GraphicalLayers.Comment)))}drawStaffLineSymbols(g){const x=g.ParentStaff.ParentInstrument,P=g.PositionAndShape.AbsolutePosition.x,_=g.PositionAndShape.AbsolutePosition.y+2,B=g.PositionAndShape.BorderRight;x.highlight&&this.drawingParameters.drawHighlights&&this.drawLineAsHorizontalRectangle(new m.GraphicalLine(new s.PointF2D(P,_),new s.PointF2D(P+B,_),4,l.OutlineAndFillStyleEnum.Highlighted),l.GraphicalLayers.Highlight);let k=v.MusicSymbolDrawingStyle.Disabled,R=S.MusicSymbol.PLAY,F=this.drawingParameters.drawActivitySymbols;switch(this.phonicScoreMode){case v.PhonicScoreModes.Midi:R=S.MusicSymbol.PLAY,this.midiPlaybackAvailable&&g.ParentStaff.audible&&(k=v.MusicSymbolDrawingStyle.PlaybackSymbols);break;case v.PhonicScoreModes.Following:R=S.MusicSymbol.MIC,g.ParentStaff.following&&(k=v.MusicSymbolDrawingStyle.FollowSymbols);break;default:F=!1}if(F){const A=new s.PointF2D(P+B+2,_);this.drawSymbol(R,k,A)}if(this.drawingParameters.drawErrors)for(const A of g.Measures){const G=A.PositionAndShape,U=G.AbsolutePosition.x,C=G.AbsolutePosition.y+2;A.hasError&&this.graphicalMusicSheet.ParentMusicSheet.DrawErroneousMeasures&&this.drawLineAsHorizontalRectangle(new m.GraphicalLine(new s.PointF2D(U,C),new s.PointF2D(U+G.BorderRight,C),4,l.OutlineAndFillStyleEnum.ErrorUnderlay),l.GraphicalLayers.MeasureError)}}}},512(St,y){var p;Object.defineProperty(y,"__esModule",{value:!0}),y.MusicSymbol=void 0,(function(d){d[d.Unused_first_Symbol=0]="Unused_first_Symbol",d[d.BLACK_HEAD=1]="BLACK_HEAD",d[d.UPWARDS_TAIL=2]="UPWARDS_TAIL",d[d.DOWNWARDS_TAIL=3]="DOWNWARDS_TAIL",d[d.UPWARDS_DOUBLE_TAIL=4]="UPWARDS_DOUBLE_TAIL",d[d.DOWNWARDS_DOUBLE_TAIL=5]="DOWNWARDS_DOUBLE_TAIL",d[d.UPWARDS_TRIPLE_TAIL=6]="UPWARDS_TRIPLE_TAIL",d[d.DOWNWARDS_TRIPLE_TAIL=7]="DOWNWARDS_TRIPLE_TAIL",d[d.UPWARDS_QUAD_TAIL=8]="UPWARDS_QUAD_TAIL",d[d.DOWNWARDS_QUAD_TAIL=9]="DOWNWARDS_QUAD_TAIL",d[d.ROUND_HEAD=10]="ROUND_HEAD",d[d.WHITE_HEAD=11]="WHITE_HEAD",d[d.G_CLEF=12]="G_CLEF",d[d.F_CLEF=13]="F_CLEF",d[d.C_CLEF=14]="C_CLEF",d[d.BREVE=15]="BREVE",d[d.BREVE_REST=16]="BREVE_REST",d[d.COMMON_TIME=17]="COMMON_TIME",d[d.CUT_TIME=18]="CUT_TIME",d[d.WHOLE_REST=19]="WHOLE_REST",d[d.HALF_REST=20]="HALF_REST",d[d.QUARTER_REST=21]="QUARTER_REST",d[d.EIGHTH_REST=22]="EIGHTH_REST",d[d.SIXTEENTH_REST=23]="SIXTEENTH_REST",d[d.THIRTYSECOND_REST=24]="THIRTYSECOND_REST",d[d.SIXTYFOURTH_REST=25]="SIXTYFOURTH_REST",d[d.FLAT=26]="FLAT",d[d.SHARP=27]="SHARP",d[d.NATURAL=28]="NATURAL",d[d.DOUBLE_FLAT=29]="DOUBLE_FLAT",d[d.DOUBLE_SHARP=30]="DOUBLE_SHARP",d[d.ZERO=31]="ZERO",d[d.ONE=32]="ONE",d[d.TWO=33]="TWO",d[d.THREE=34]="THREE",d[d.FOUR=35]="FOUR",d[d.FIVE=36]="FIVE",d[d.SIX=37]="SIX",d[d.SEVEN=38]="SEVEN",d[d.EIGHT=39]="EIGHT",d[d.NINE=40]="NINE",d[d.DOT=41]="DOT",d[d.FERMATA=42]="FERMATA",d[d.INVERTED_FERMATA=43]="INVERTED_FERMATA",d[d.SPICCATO=44]="SPICCATO",d[d.TENUTO=45]="TENUTO",d[d.MARCATO=46]="MARCATO",d[d.MARCATISSIMO=47]="MARCATISSIMO",d[d.INVERTED_MARCATISSIMO=48]="INVERTED_MARCATISSIMO",d[d.P=49]="P",d[d.F=50]="F",d[d.S=51]="S",d[d.Z=52]="Z",d[d.M=53]="M",d[d.R=54]="R",d[d.SEGNO=55]="SEGNO",d[d.CODA=56]="CODA",d[d.DRUM_CLEF=57]="DRUM_CLEF",d[d.G_CLEF_SUB8=58]="G_CLEF_SUB8",d[d.G_CLEF_SUPER8=59]="G_CLEF_SUPER8",d[d.G_CLEF_SUB15=60]="G_CLEF_SUB15",d[d.G_CLEF_SUPER15=61]="G_CLEF_SUPER15",d[d.F_CLEF_SUB8=62]="F_CLEF_SUB8",d[d.F_CLEF_SUPER8=63]="F_CLEF_SUPER8",d[d.F_CLEF_SUB15=64]="F_CLEF_SUB15",d[d.F_CLEF_SUPER15=65]="F_CLEF_SUPER15",d[d.DOWN_BOW=66]="DOWN_BOW",d[d.MORDENT=67]="MORDENT",d[d.INVERTED_MORDENT=68]="INVERTED_MORDENT",d[d.TURN=69]="TURN",d[d.INVERTED_TURN=70]="INVERTED_TURN",d[d.LEFTHAND_PIZZICATO=71]="LEFTHAND_PIZZICATO",d[d.RELEASE_PED=72]="RELEASE_PED",d[d.ENGAGE_PED=73]="ENGAGE_PED",d[d.VA8=74]="VA8",d[d.VB8=75]="VB8",d[d.TRILL=76]="TRILL",d[d.MA15=77]="MA15",d[d.MB15=78]="MB15",d[d.HIGH=79]="HIGH",d[d.PLAY=80]="PLAY",d[d.MIC=81]="MIC",d[d.SNAP_PIZZICATO=82]="SNAP_PIZZICATO",d[d.NATURAL_HARMONIC=83]="NATURAL_HARMONIC",d[d.EditPen=84]="EditPen",d[d.PEDAL_BRACKET=85]="PEDAL_BRACKET",d[d.PEDAL_MIXED=86]="PEDAL_MIXED",d[d.PEDAL_SYMBOL=87]="PEDAL_SYMBOL"})(p||(y.MusicSymbol=p={}))},5221(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.MusicSystem=void 0;const d=p(9252),l=p(6438),m=p(2561),a=p(7533),s=p(8254),h=p(7741),u=p(9409),f=p(6954),r=p(3263),b=p(67),S=p(7435);class v extends h.GraphicalObject{constructor(T){super(),this.needsToBeRedrawn=!0,this.staffLines=[],this.graphicalMeasures=[],this.labels=new r.Dictionary,this.measureNumberLabels=[],this.objectsToRedraw=[],this.instrumentBrackets=[],this.groupBrackets=[],this.graphicalMarkedAreas=[],this.graphicalComments=[],this.systemLines=[],this.breaksPage=!1,this.id=T,this.boundingBox=new l.BoundingBox(this),this.maxLabelLength=0}get Parent(){return this.parent}set Parent(T){if(this.parent){const g=this.parent.MusicSystems.indexOf(this,0);g>-1&&this.parent.MusicSystems.splice(g,1)}this.parent=T,this.boundingBox.Parent=T.PositionAndShape}get NextSystem(){const T=this.Parent.MusicSystems.indexOf(this);return T!==this.Parent.MusicSystems.length?this.Parent.MusicSystems[T+1]:void 0}get StaffLines(){return this.staffLines}set StaffLines(T){this.staffLines=T}get GraphicalMeasures(){return this.graphicalMeasures}get MeasureNumberLabels(){return this.measureNumberLabels}get Labels(){return this.labels.values()}get ObjectsToRedraw(){return this.objectsToRedraw}get InstrumentBrackets(){return this.instrumentBrackets}get GroupBrackets(){return this.groupBrackets}get GraphicalMarkedAreas(){return this.graphicalMarkedAreas}get GraphicalComments(){return this.graphicalComments}get SystemLines(){return this.systemLines}get Id(){return this.id}get MaxLabelLength(){return this.maxLabelLength}createSystemLeftLine(T,g,x){let P=-T/2;x&&(P=this.maxLabelLength+g-T/2);const _=this.staffLines[0].Measures[0];let B;this.staffLines.length>1&&(B=this.staffLines[this.staffLines.length-1].Measures[0]);const k=this.createSystemLine(P,T,f.SystemLinesEnum.SingleThin,b.SystemLinePosition.MeasureBegin,this,_,B);this.SystemLines.push(k),k.PositionAndShape.RelativePosition=new u.PointF2D(P,0),k.PositionAndShape.BorderLeft=0,k.PositionAndShape.BorderRight=T,k.PositionAndShape.BorderTop=k.PositionAndShape.Parent.BorderTop,k.PositionAndShape.BorderBottom=k.PositionAndShape.Parent.BorderBottom,this.createLinesForSystemLine(k)}createVerticalLineForMeasure(T,g,x,P,_,B){const k=B.ParentStaffLine,R=new u.PointF2D(k.PositionAndShape.RelativePosition.x,k.PositionAndShape.RelativePosition.y),F=k.ParentStaff.ParentInstrument.Staves;if(k.ParentStaff===F[0]){let A;F.length>1&&(A=this.getBottomStaffLine(k).Measures[_]);const G=this.createSystemLine(T,g,x,P,this,B,A),U=R.x+T;G.PositionAndShape.RelativePosition=new u.PointF2D(U,0),G.PositionAndShape.BorderLeft=0,G.PositionAndShape.BorderRight=g,this.SystemLines.push(G)}}setYPositionsToVerticalLineObjectsAndCreateLines(T){}calculateBorders(T){}alignBeginInstructions(){}GetLeftBorderAbsoluteXPosition(){return this.StaffLines[0].PositionAndShape.AbsolutePosition.x+this.StaffLines[0].Measures[0].beginInstructionsWidth}GetRightBorderAbsoluteXPosition(){return this.StaffLines[0].PositionAndShape.AbsolutePosition.x+this.StaffLines[0].StaffLines[0].End.x}AddGraphicalMeasures(T){for(let g=0,x=T.length;g1){let B,k;for(let R=0,F=this.staffLines.length;Rthis.maxLabelLength&&(this.maxLabelLength=A.PositionAndShape.Size.width,g=_)}this.updateMusicSystemStaffLineXPosition(g)}setMusicSystemLabelsYPosition(){this.labels.forEach((T,g)=>{let x=0,P=0;for(let _=0;_0&&(g.PositionAndShape.RelativePosition=new u.PointF2D(0,x/P+2))})}checkStaffEntriesForStaffEntryLink(){let T=!1,g=!1;for(let x=0;x=0;_--)if((P=g[_])!=null&&P.Visible){x=g[_];break}for(const _ of T.ParentMusicSystem.staffLines)if(_.ParentStaff===x)return _}createSystemLine(T,g,x,P,_,B,k=void 0){throw new Error("not implemented")}createLinesForSystemLine(T){}calcBracketsWidth(){let T=0;for(let g=0,x=this.GroupBrackets.length;g=0;x--){if(g=T.InstrumentalGroups[x],!(g instanceof d.Instrument))return this.findLastVisibleInstrumentInInstrumentalGroup(g);if(g.isVisible())return g}}updateMusicSystemStaffLineXPosition(T){for(let g=0,x=this.StaffLines.length;g0?this.currentSystemParams.maxLabelLength+this.rules.SystemLabelsRightMargin:0,rt=this.currentSystemParams.currentWidth+Y+N+H0;if(F||rt&&!st){if(this.addMeasureToSystem(_,C,W,Y,G,z,U),this.updateActiveClefs(B,_),this.measureListIndex++,R){if(this.rules.MaxSystemToDrawNumber===this.musicSystems.length)return this.finalizeCurrentSystem(_,!this.rules.StretchLastSystemLine,!1),this.musicSystems;this.finalizeCurrentAndCreateNewSystem(_,!this.rules.StretchLastSystemLine,!1)}T=k}else{if(this.rules.MaxSystemToDrawNumber===this.musicSystems.length)return this.finalizeCurrentSystem(_,!1,!0,ct),this.musicSystems;this.finalizeCurrentAndCreateNewSystem(_,!1,!0,ct)}}if(this.currentSystemParams.systemMeasures.length>0){if(this.rules.MaxSystemToDrawNumber===this.musicSystems.length)return this.finalizeCurrentSystem(this.measureList[this.measureList.length-1],!this.rules.StretchLastSystemLine,!1),this.musicSystems;this.finalizeCurrentAndCreateNewSystem(this.measureList[this.measureList.length-1],!this.rules.StretchLastSystemLine,!1)}return this.musicSystems}calculateSystemYLayout(){for(const w of this.musicSystems)this.optimizeDistanceBetweenStaffLines(w);this.calculateMusicSystemsRelativePositions()}setMeasureWidth(w,T,g,x){for(let P=0,_=w.length;P<_;++P){const B=w[P];B.setWidth(T),g>0&&(B.beginInstructionsWidth=g),x>0&&(B.endInstructionsWidth=x)}}finalizeCurrentAndCreateNewSystem(w,T=!1,g=!0,x=!1){this.finalizeCurrentSystem(w,T,g,x),this.currentSystemParams=new v,w!==void 0&&this.measureListIndex=1){const T=this.currentSystemParams.currentSystem.GraphicalMeasures[this.currentSystemParams.currentSystem.GraphicalMeasures.length-1];let g=0;const x=w[w.length-1];x.endLine===u.SystemLinesEnum.DotsBoldBoldDots&&(x.endLine=u.SystemLinesEnum.DotsThinBold,g=T[0].getLineWidth(u.SystemLinesEnum.DotsBoldBoldDots)/2-T[0].getLineWidth(u.SystemLinesEnum.DotsThinBold)),this.currentSystemParams.currentSystemFixWidth-=g;for(let P=0,_=T.length;P<_;++P)T[P].endInstructionsWidth-=g}}addMeasureToSystem(w,T,g,x,P,_,B){this.currentSystemParams.systemMeasures.push({beginLine:T,endLine:g}),this.setMeasureWidth(w,x,P,B),this.addStaveMeasuresToSystem(w),this.currentSystemParams.currentWidth+=x,this.currentSystemParams.currentSystemFixWidth+=P+B,this.currentSystemParams.currentSystemVarWidth+=_,this.currentSystemParams.systemMeasureIndex++}initMusicSystem(){const w=f.MusicSheetCalculator.symbolFactory.createMusicSystem(this.globalSystemIndex++,this.rules);return this.musicSystems.push(w),this.layoutSystemStaves(w),w.createMusicSystemLabel(this.rules.InstrumentLabelTextHeight,this.rules.SystemLabelsRightMargin,this.rules.LabelMarginBorderFactor,this.musicSystems.length===1),w}getFullPageSystemWidth(){return this.graphicalMusicSheet.ParentMusicSheet.pageWidth-this.rules.PageLeftMargin-this.rules.PageRightMargin-this.rules.SystemLeftMargin-this.rules.SystemRightMargin}layoutSystemStaves(w){const T=this.getFullPageSystemWidth(),g=w.PositionAndShape;g.BorderLeft=0,g.BorderRight=T,g.BorderTop=0;const x=[],P=this.graphicalMusicSheet.ParentMusicSheet.Instruments;for(let k=0,R=P.length;k1){_=!0;break}}let B=0;for(let k=0;k=0&&this.measureList[z]){const W=this.measureList[z],$=(U=W[0])==null?void 0:U.parentSourceMeasure;$!=null&&$.ImplicitMeasure&&($!=null&&$.RhythmPrinted)&&(C=!1)}C&&(T.addRhythmAtBegin(k),T.parentSourceMeasure.RhythmPrinted=k,G=!0)}return(F||A||G)&&(R+=T.beginInstructionsWidth,G&&(R+=this.rules.RhythmRightMargin)),R}addInstructionsAtMeasureEnd(w,T,g){if(!w||!w.Instructions||w.Instructions.length===0)return 0;for(let x=0,P=w.Instructions.length;x0&&(this.currentSystemParams.systemMeasures.push({beginLine:u.SystemLinesEnum.None,endLine:u.SystemLinesEnum.None}),this.currentSystemParams.currentWidth+=x,this.currentSystemParams.currentSystemFixWidth+=x)}addExtraInstructionMeasure(w,T,g){const x=this.currentSystemParams.currentSystem,P=f.MusicSheetCalculator.symbolFactory.createExtraGraphicalMeasure(x.StaffLines[w]);T&&P.addKeyAtBegin(T,this.activeKeys[w],this.activeClefs[w]),g!==void 0&&g.PrintObject&&P.addRhythmAtBegin(g),P.PositionAndShape.BorderLeft=0,P.PositionAndShape.BorderTop=0,P.PositionAndShape.BorderBottom=this.rules.StaffHeight;const _=this.rules.MeasureLeftMargin+P.beginInstructionsWidth+this.rules.MeasureRightMargin;return P.PositionAndShape.BorderRight=_,x.StaffLines[w].Measures.push(P),_}addStaveMeasuresToSystem(w){if(w[0]){const T=[];for(let x=0;x1){const T=Math.min(this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.length-1,w.measureListIndex+w.multipleRestMeasures-1);w=this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures[T]}}finally{}return this.nextMeasureBeginsLineRepetition()&&this.thisMeasureEndsLineRepetition()?u.SystemLinesEnum.DotsBoldBoldDots:this.thisMeasureEndsLineRepetition()?u.SystemLinesEnum.DotsThinBold:this.nextMeasureHasKeyInstructionChange()?u.SystemLinesEnum.DoubleThin:w&&w.endingBarStyleEnum!==void 0?w.endingBarStyleEnum:u.SystemLinesEnum.SingleThin}getLineWidth(w,T,g){let x=w.getLineWidth(T);return T===u.SystemLinesEnum.DotsBoldBoldDots&&(x/=2),g&&T===u.SystemLinesEnum.BoldThinDots&&(x+=this.rules.DistanceBetweenLastInstructionAndRepetitionBarline),x}previousMeasureEndsLineRepetition(){if(this.measureListIndex===0)return!1;for(let w=0,T=this.measureList[this.measureListIndex-1].length;w=this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.length||!this.measureList[w])return!1;for(let T=0,g=this.measureList[w].length;T=k))break;_=F,k=F.multipleRestMeasureNumber}return _.endsWithLineRepetition()}}return!1}nextMeasureBeginsWordRepetition(){const w=this.measureListIndex+1;if(w>=this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.length||w>this.measureList.length-1)return!1;for(let T=0,g=this.measureList[w].length;Tthis.rules.PageHeight-this.rules.PageBottomMargin&&(x++,x<=4&&console.log(`warning: could not fit a single system on page ${w.PageNumber} and measure number ${g.GraphicalMeasures[0][0].MeasureNumber}. +`);for(E=a=0;aE||xt[a]!==Rt[E]){var kt=` +`+xt[a].replace(" at new "," at ");return t.displayName&&kt.includes("")&&(kt=kt.replace("",t.displayName)),kt}while(1<=a&&0<=E);break}}}finally{Ut=!1,Error.prepareStackTrace=n}return(n=t?t.displayName||t.name:"")?Xt(n):""}function qt(t,e){switch(t.tag){case 26:case 27:case 5:return Xt(t.type);case 16:return Xt("Lazy");case 13:return t.child!==e&&e!==null?Xt("Suspense Fallback"):Xt("Suspense");case 19:return Xt("SuspenseList");case 0:case 15:return Kt(t.type,!1);case 11:return Kt(t.type.render,!1);case 1:return Kt(t.type,!0);case 31:return Xt("Activity");case 30:return Xt("ViewTransition");default:return""}}function Qt(t){try{var e="",n=null;do e+=qt(t,n),n=t,t=t.return;while(t);return e}catch(a){return` +Error generating stack: `+a.message+` +`+a.stack}}var $t=Object.prototype.hasOwnProperty,ie=Ht.unstable_scheduleCallback,Jt=Ht.unstable_cancelCallback,oe=Ht.unstable_shouldYield,Ke=Ht.unstable_requestPaint,De=Ht.unstable_now,Xe=Ht.unstable_getCurrentPriorityLevel,Pi=Ht.unstable_ImmediatePriority,ai=Ht.unstable_UserBlockingPriority,we=Ht.unstable_NormalPriority,Ge=Ht.unstable_LowPriority,xi=Ht.unstable_IdlePriority,Ce=Ht.log,Re=Ht.unstable_setDisableYieldValue,He=null,Te=null;function Ye(t){if(typeof Ce=="function"&&Re(t),Te&&typeof Te.setStrictMode=="function")try{Te.setStrictMode(He,t)}catch{}}var ci=Math.clz32?Math.clz32:_s,Ts=Math.log,nn=Math.LN2;function _s(t){return t>>>=0,t===0?32:31-(Ts(t)/nn|0)|0}var ws=256,Mi=262144,Yi=4194304;function sn(t){var e=t&42;if(e!==0)return e;switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return t&-t;case 262144:case 524288:case 1048576:case 2097152:return t&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return t&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return t}}function Ln(t,e,n){var a=t.pendingLanes;if(a===0)return 0;var E=0,L=t.suspendedLanes,K=t.pingedLanes;t=t.warmLanes;var ut=a&134217727;return ut!==0?(a=ut&~L,a!==0?E=sn(a):(K&=ut,K!==0?E=sn(K):n||(n=ut&~t,n!==0&&(E=sn(n))))):(ut=a&~L,ut!==0?E=sn(ut):K!==0?E=sn(K):n||(n=a&~t,n!==0&&(E=sn(n)))),E===0?0:e!==0&&e!==E&&(e&L)===0&&(L=E&-E,n=e&-e,L>=n||L===32&&(n&4194048)!==0)?e:E}function rn(t,e){return(t.pendingLanes&~(t.suspendedLanes&~t.pingedLanes)&e)===0}function Ci(t,e){(e&8)!==0&&(e|=e&32);var n=t.entangledLanes;if(n!==0)for(t=t.entanglements,n&=e;0n;n++)e.push(t);return e}function yi(t,e){t.pendingLanes|=e,e!==268435456&&(t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0)}function Or(t,e,n,a,E,L){var K=t.pendingLanes;t.pendingLanes=n,t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0,t.expiredLanes&=n,t.entangledLanes&=n,t.errorRecoveryDisabledLanes&=n,t.shellSuspendCounter=0;var ut=t.entanglements,xt=t.expirationTimes,Rt=t.hiddenUpdates;for(n=K&~n;0"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ja=!1;if(Rn)try{var kr={};Object.defineProperty(kr,"passive",{get:function(){Ja=!0}}),window.addEventListener("test",kr,kr),window.removeEventListener("test",kr,kr)}catch{Ja=!1}var Zn=null,$a=null,Ro=null;function Lh(){if(Ro)return Ro;var t,e=$a,n=e.length,a,E="value"in Zn?Zn.value:Zn.textContent,L=E.length;for(t=0;t=zr),Ih=" ",Bh=!1;function Oh(t,e){switch(t){case"keyup":return vm.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Dh(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var tr=!1;function xm(t,e){switch(t){case"compositionend":return Dh(e);case"keypress":return e.which!==32?null:(Bh=!0,Ih);case"textInput":return t=e.data,t===Ih&&Bh?null:t;default:return null}}function Mm(t,e){if(tr)return t==="compositionend"||!sl&&Oh(t,e)?(t=Lh(),Ro=$a=Zn=null,tr=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function Wh(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function jh(t,e){var n=Wh(t);t=0;for(var a;n;){if(n.nodeType===3){if(a=t+n.textContent.length,t<=e&&a>=e)return{node:n,offset:e-t};t=a}t:{for(;n;){if(n.nextSibling){n=n.nextSibling;break t}n=n.parentNode}n=void 0}n=Wh(n)}}function Xh(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?Xh(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function Yh(t){t=t!=null&&t.ownerDocument!=null&&t.ownerDocument.defaultView!=null?t.ownerDocument.defaultView:window;for(var e=al(t.document);e instanceof t.HTMLIFrameElement;){try{var n=typeof e.contentWindow.location.href=="string"}catch{n=!1}if(n)t=e.contentWindow;else break;e=al(t.document)}return e}function ll(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}var Rm=Rn&&"documentMode"in document&&11>=document.documentMode,er=null,ul=null,jr=null,hl=!1;function qh(t,e,n){var a=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;hl||er==null||er!==al(a)||(a=er,"selectionStart"in a&&ll(a)?a={start:a.selectionStart,end:a.selectionEnd}:(a=(a.ownerDocument&&a.ownerDocument.defaultView||window).getSelection(),a={anchorNode:a.anchorNode,anchorOffset:a.anchorOffset,focusNode:a.focusNode,focusOffset:a.focusOffset}),jr&&Wr(jr,a)||(jr=a,a=Da(ul,"onSelect"),0>=K,E-=K,bn=1<<32-ci(e)+E|n<de?(si=ce,ce=null):si=ce.sibling;var _e=At(Pt,ce,Bt[de],Wt);if(_e===null){ce===null&&(ce=si);break}t&&ce&&_e.alternate===null&&e(Pt,ce),wt=L(_e,wt,de),Me===null?le=_e:Me.sibling=_e,Me=_e,ce=si}if(de===Bt.length)return n(Pt,ce),Se&&On(Pt,de),le;if(ce===null){for(;dede?(si=ce,ce=null):si=ce.sibling;var xs=At(Pt,ce,_e.value,Wt);if(xs===null){ce===null&&(ce=si);break}t&&ce&&xs.alternate===null&&e(Pt,ce),wt=L(xs,wt,de),Me===null?le=xs:Me.sibling=xs,Me=xs,ce=si}if(_e.done)return n(Pt,ce),Se&&On(Pt,de),le;if(ce===null){for(;!_e.done;de++,_e=Bt.next())_e=jt(Pt,_e.value,Wt),_e!==null&&(wt=L(_e,wt,de),Me===null?le=_e:Me.sibling=_e,Me=_e);return Se&&On(Pt,de),le}for(ce=a(ce);!_e.done;de++,_e=Bt.next())_e=Ot(ce,Pt,de,_e.value,Wt),_e!==null&&(t&&(si=_e.alternate,si!==null&&ce.delete(si.key===null?de:si.key)),wt=L(_e,wt,de),Me===null?le=_e:Me.sibling=_e,Me=_e);return t&&ce.forEach(function(x2){return e(Pt,x2)}),Se&&On(Pt,de),le}function ge(Pt,wt,Bt,Wt){if(typeof Bt=="object"&&Bt!==null&&Bt.type===k&&Bt.key===null&&Bt.props.ref===void 0&&(Bt=Bt.props.children),typeof Bt=="object"&&Bt!==null){switch(Bt.$$typeof){case _:t:{for(var le=Bt.key;wt!==null;){if(wt.key===le){if(le=Bt.type,le===k){if(wt.tag===7){n(Pt,wt.sibling),Wt=E(wt,Bt.props.children),ns(Wt,Bt),Wt.return=Pt,Pt=Wt;break t}}else if(wt.elementType===le||typeof le=="object"&&le!==null&&le.$$typeof===$&&ks(le)===wt.type){n(Pt,wt.sibling),Wt=E(wt,Bt.props),ns(Wt,Bt),Wt.return=Pt,Pt=Wt;break t}n(Pt,wt);break}else e(Pt,wt);wt=wt.sibling}Bt.type===k?(Wt=Rs(Bt.props.children,Pt.mode,Wt,Bt.key),ns(Wt,Bt),Wt.return=Pt,Pt=Wt):(Wt=zo(Bt.type,Bt.key,Bt.props,null,Pt.mode,Wt),ns(Wt,Bt),Wt.return=Pt,Pt=Wt)}return K(Pt);case B:t:{for(le=Bt.key;wt!==null;){if(wt.key===le)if(wt.tag===4&&wt.stateNode.containerInfo===Bt.containerInfo&&wt.stateNode.implementation===Bt.implementation){n(Pt,wt.sibling),Wt=E(wt,Bt.children||[]),Wt.return=Pt,Pt=Wt;break t}else{n(Pt,wt);break}else e(Pt,wt);wt=wt.sibling}Wt=bl(Bt,Pt.mode,Wt),Wt.return=Pt,Pt=Wt}return K(Pt);case $:return Bt=ks(Bt),ge(Pt,wt,Bt,Wt)}if(lt(Bt))return se(Pt,wt,Bt,Wt);if(st(Bt)){if(le=st(Bt),typeof le!="function")throw Error(Lt(150));return Bt=le.call(Bt),ue(Pt,wt,Bt,Wt)}if(typeof Bt.then=="function")return ge(Pt,wt,Zo(Bt),Wt);if(Bt.$$typeof===G)return ge(Pt,wt,Yo(Pt,Bt),Wt);Jo(Pt,Bt)}return typeof Bt=="string"&&Bt!==""||typeof Bt=="number"||typeof Bt=="bigint"?(Bt=""+Bt,wt!==null&&wt.tag===6?(n(Pt,wt.sibling),Wt=E(wt,Bt),Wt.return=Pt,Pt=Wt):(n(Pt,wt),Wt=gl(Bt,Pt.mode,Wt),Wt.return=Pt,Pt=Wt),K(Pt)):n(Pt,wt)}return function(Pt,wt,Bt,Wt){try{Zr=0;var le=ge(Pt,wt,Bt,Wt);return hr=null,le}catch(ce){if(ce===ur||ce===Ko)throw ce;var Me=Ni(29,ce,null,Pt.mode);return Me.lanes=Wt,Me.return=Pt,Me}finally{}}}var Gs=Sc(!0),yc=Sc(!1),ss=!1;function Ll(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Al(t,e){t=t.updateQueue,e.updateQueue===t&&(e.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,callbacks:null})}function rs(t){return{lane:t,tag:0,payload:null,callback:null,next:null}}function os(t,e,n){var a=t.updateQueue;if(a===null)return null;if(a=a.shared,(Ae&2)!==0){var E=a.pending;return E===null?e.next=e:(e.next=E.next,E.next=e),a.pending=e,e=Go(t),ic(t,null,n),e}return Vo(t,a,e,n),Go(t)}function Jr(t,e,n){if(e=e.updateQueue,e!==null&&(e=e.shared,(n&4194048)!==0)){var a=e.lanes;a&=t.pendingLanes,n|=a,e.lanes=n,di(t,n)}}function Pl(t,e){var n=t.updateQueue,a=t.alternate;if(a!==null&&(a=a.updateQueue,n===a)){var E=null,L=null;if(n=n.firstBaseUpdate,n!==null){do{var K={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};L===null?E=L=K:L=L.next=K,n=n.next}while(n!==null);L===null?E=L=e:L=L.next=e}else E=L=e;n={baseState:a.baseState,firstBaseUpdate:E,lastBaseUpdate:L,shared:a.shared,callbacks:a.callbacks},t.updateQueue=n;return}t=n.lastBaseUpdate,t===null?n.firstBaseUpdate=e:t.next=e,n.lastBaseUpdate=e}var Cl=!1;function $r(){if(Cl){var t=lr;if(t!==null)throw t}}function to(t,e,n,a){Cl=!1;var E=t.updateQueue;ss=!1;var L=E.firstBaseUpdate,K=E.lastBaseUpdate,ut=E.shared.pending;if(ut!==null){E.shared.pending=null;var xt=ut,Rt=xt.next;xt.next=null,K===null?L=Rt:K.next=Rt,K=xt;var kt=t.alternate;kt!==null&&(kt=kt.updateQueue,ut=kt.lastBaseUpdate,ut!==K&&(ut===null?kt.firstBaseUpdate=Rt:ut.next=Rt,kt.lastBaseUpdate=xt))}if(L!==null){var jt=E.baseState;K=0,kt=Rt=xt=null,ut=L;do{var At=ut.lane&-536870913,Ot=At!==ut.lane;if(Ot?(xe&At)===At:(a&At)===At){At!==0&&At===Ds&&(Cl=!0),kt!==null&&(kt=kt.next={lane:0,tag:ut.tag,payload:ut.payload,callback:null,next:null});t:{var se=t,ue=ut;At=e;var ge=n;switch(ue.tag){case 1:if(se=ue.payload,typeof se=="function"){jt=se.call(ge,jt,At);break t}jt=se;break t;case 3:se.flags=se.flags&-65537|128;case 0:if(se=ue.payload,At=typeof se=="function"?se.call(ge,jt,At):se,At==null)break t;jt=x({},jt,At);break t;case 2:ss=!0}}At=ut.callback,At!==null&&(t.flags|=64,Ot&&(t.flags|=8192),Ot=E.callbacks,Ot===null?E.callbacks=[At]:Ot.push(At))}else Ot={lane:At,tag:ut.tag,payload:ut.payload,callback:ut.callback,next:null},kt===null?(Rt=kt=Ot,xt=jt):kt=kt.next=Ot,K|=At;if(ut=ut.next,ut===null){if(ut=E.shared.pending,ut===null)break;Ot=ut,ut=Ot.next,Ot.next=null,E.lastBaseUpdate=Ot,E.shared.pending=null}}while(!0);kt===null&&(xt=jt),E.baseState=xt,E.firstBaseUpdate=Rt,E.lastBaseUpdate=kt,L===null&&(E.shared.lanes=0),fs|=K,t.lanes=K,t.memoizedState=jt}}function vc(t,e){if(typeof t!="function")throw Error(Lt(191,t));t.call(e)}function Ec(t,e){var n=t.callbacks;if(n!==null)for(t.callbacks=null,t=0;tL?L:8;var K=O.T,ut={};ut.types=K!==null?K.types:null,O.T=ut,Ql(t,!1,e,n);try{var xt=E(),Rt=O.S;if(Rt!==null&&Rt(ut,xt),xt!==null&&typeof xt=="object"&&typeof xt.then=="function"){var kt=Um(xt,a);so(t,e,kt,ji(t))}else so(t,e,a,ji(t))}catch(jt){so(t,e,{then:function(){},status:"rejected",reason:jt},ji())}finally{D.p=L,K!==null&&ut.types!==null&&(K.types=ut.types),O.T=K}}function qm(){}function ql(t,e,n,a){if(t.tag!==5)throw Error(Lt(476));var E=$c(t).queue;Jc(t,E,e,j,n===null?qm:function(){return td(t),n(a)})}function $c(t){var e=t.memoizedState;if(e!==null)return e;e={memoizedState:j,baseState:j,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Vn,lastRenderedState:j},next:null};var n={};return e.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Vn,lastRenderedState:n},next:null},t.memoizedState=e,t=t.alternate,t!==null&&(t.memoizedState=e),e}function td(t){var e=$c(t);e.next===null&&(e=t.alternate.memoizedState),so(t,e.next.queue,{},ji())}function Kl(){return fi(Nr)}function ed(){return ti().memoizedState}function id(){return ti().memoizedState}function Km(t){for(var e=t.return;e!==null;){switch(e.tag){case 24:case 3:var n=ji();t=rs(n);var a=os(e,t,n);a!==null&&(Di(a,e,n),Jr(a,e,n)),e={cache:Ml()},t.payload=e;return}e=e.return}}function Qm(t,e,n){var a=ji();n={lane:a,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},la(t)?sd(e,n):(n=ml(t,e,n,a),n!==null&&(Di(n,t,a),rd(n,e,a)))}function nd(t,e,n){var a=ji();so(t,e,n,a)}function so(t,e,n,a){var E={lane:a,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(la(t))sd(e,E);else{var L=t.alternate;if(t.lanes===0&&(L===null||L.lanes===0)&&(L=e.lastRenderedReducer,L!==null))try{var K=e.lastRenderedState,ut=L(K,n);if(E.hasEagerState=!0,E.eagerState=ut,Gi(ut,K))return Vo(t,e,E,0),ke===null&&ko(),!1}catch{}finally{}if(n=ml(t,e,E,a),n!==null)return Di(n,t,a),rd(n,e,a),!0}return!1}function Ql(t,e,n,a){if(a={lane:2,revertLane:Gu(),gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},la(t)){if(e)throw Error(Lt(479))}else e=ml(t,n,a,2),e!==null&&Di(e,t,2)}function la(t){var e=t.alternate;return t===pe||e!==null&&e===pe}function sd(t,e){cr=ea=!0;var n=t.pending;n===null?e.next=e:(e.next=n.next,n.next=e),t.pending=e}function rd(t,e,n){if((n&4194048)!==0){var a=e.lanes;a&=t.pendingLanes,n|=a,e.lanes=n,di(t,n)}}var ua={readContext:fi,use:sa,useCallback:Je,useContext:Je,useEffect:Je,useImperativeHandle:Je,useLayoutEffect:Je,useInsertionEffect:Je,useMemo:Je,useReducer:Je,useRef:Je,useState:Je,useDebugValue:Je,useDeferredValue:Je,useTransition:Je,useSyncExternalStore:Je,useId:Je,useHostTransitionStatus:Je,useFormState:Je,useActionState:Je,useOptimistic:Je,useMemoCache:Je,useCacheRefresh:Je,useEffectEvent:Je},od={readContext:fi,use:sa,useCallback:function(t,e){return wi().memoizedState=[t,e===void 0?null:e],t},useContext:fi,useEffect:Hc,useImperativeHandle:function(t,e,n){n=n!=null?n.concat([t]):null,oa(4194308,4,Yc.bind(null,e,t),n)},useLayoutEffect:function(t,e){return oa(4194308,4,t,e)},useInsertionEffect:function(t,e){oa(4,2,t,e)},useMemo:function(t,e){var n=wi();e=e===void 0?null:e;var a=t();if(zs){Ye(!0);try{t()}finally{Ye(!1)}}return n.memoizedState=[a,e],a},useReducer:function(t,e,n){var a=wi();if(n!==void 0){var E=n(e);if(zs){Ye(!0);try{n(e)}finally{Ye(!1)}}}else E=e;return a.memoizedState=a.baseState=E,t={pending:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:E},a.queue=t,t=t.dispatch=Qm.bind(null,pe,t),[a.memoizedState,t]},useRef:function(t){var e=wi();return t={current:t},e.memoizedState=t},useState:function(t){t=Hl(t);var e=t.queue,n=nd.bind(null,pe,e);return e.dispatch=n,[t.memoizedState,n]},useDebugValue:Xl,useDeferredValue:function(t,e){var n=wi();return Yl(n,t,e)},useTransition:function(){var t=Hl(!1);return t=Jc.bind(null,pe,t.queue,!0,!1),wi().memoizedState=t,[!1,t]},useSyncExternalStore:function(t,e,n){var a=pe,E=wi();if(Se){if(n===void 0)throw Error(Lt(407));n=n()}else{if(n=e(),ke===null)throw Error(Lt(349));(xe&127)!==0||Lc(a,e,n)}E.memoizedState=n;var L={value:n,getSnapshot:e};return E.queue=L,Hc(Pc.bind(null,a,L,t),[t]),a.flags|=2048,fr(9,{destroy:void 0},Ac.bind(null,a,L,n,e),null),n},useId:function(){var t=wi(),e=ke.identifierPrefix;if(Se){var n=Sn,a=bn;n=(a&~(1<<32-ci(a)-1)).toString(32)+n,e="_"+e+"R_"+n,n=ia++,0<\/script>",L=L.removeChild(L.firstChild);break;case"select":L=typeof a.is=="string"?K.createElement("select",{is:a.is}):K.createElement("select"),a.multiple?L.multiple=!0:a.size&&(L.size=a.size);break;default:L=typeof a.is=="string"?K.createElement(E,{is:a.is}):K.createElement(E)}}L[Ze]=e,L[We]=a;t:for(K=e.child;K!==null;){if(K.tag===5||K.tag===6)L.appendChild(K.stateNode);else if(K.tag!==4&&K.tag!==27&&K.child!==null){K.child.return=K,K=K.child;continue}if(K===e)break t;for(;K.sibling===null;){if(K.return===null||K.return===e)break t;K=K.return}K.sibling.return=K.return,K=K.sibling}e.stateNode=L;t:switch(bi(L,E,a),E){case"button":case"input":case"select":case"textarea":a=!!a.autoFocus;break t;case"img":a=!0;break t;default:a=!1}a&&zn(e)}}return Ue(e),e.subtreeFlags&=-33554433,uu(e,e.type,t===null?null:t.memoizedProps,e.pendingProps,n),null;case 6:if(t&&e.stateNode!=null)t.memoizedProps!==a&&zn(e);else{if(typeof a!="string"&&e.stateNode===null)throw Error(Lt(166));if(t=yt.current,ar(e)){if(t=e.stateNode,n=e.memoizedProps,a=null,E=li,E!==null)switch(E.tag){case 27:case 5:a=E.memoizedProps}t[Ze]=e,t=!!(t.nodeValue===n||a!==null&&a.suppressHydrationWarning===!0||Cf(t.nodeValue,n)),t||es(e,!0)}else t=So(t).createTextNode(a),t[Ze]=e,e.stateNode=t}return Ue(e),null;case 31:if(n=e.memoizedState,t===null||t.memoizedState!==null){if(a=ar(e),n!==null){if(t===null){if(!a)throw Error(Lt(318));if(t=e.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(Lt(557));t[Ze]=e}else Ns(),(e.flags&128)===0&&(e.memoizedState=null),e.flags|=4;Ue(e),t=!1}else n=vl(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=n),t=!0;if(!t)return e.flags&256?(zi(e),e):(zi(e),null);if((e.flags&128)!==0)throw Error(Lt(558))}return Ue(e),null;case 13:if(a=e.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(E=ar(e),a!==null&&a.dehydrated!==null){if(t===null){if(!E)throw Error(Lt(318));if(E=e.memoizedState,E=E!==null?E.dehydrated:null,!E)throw Error(Lt(317));E[Ze]=e}else Ns(),(e.flags&128)===0&&(e.memoizedState=null),e.flags|=4;Ue(e),E=!1}else E=vl(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=E),E=!0;if(!E)return e.flags&256?(zi(e),e):(zi(e),null)}return zi(e),(e.flags&128)!==0?(e.lanes=n,e):(n=a!==null,t=t!==null&&t.memoizedState!==null,n&&(a=e.child,E=null,a.alternate!==null&&a.alternate.memoizedState!==null&&a.alternate.memoizedState.cachePool!==null&&(E=a.alternate.memoizedState.cachePool.pool),L=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(L=a.memoizedState.cachePool.pool),L!==E&&(a.flags|=2048)),n!==t&&n&&(e.child.flags|=8192),pa(e,e.updateQueue),Ue(e),null);case 4:return Vt(),t===null&&Wu(e.stateNode.containerInfo),e.flags|=67108864,Ue(e),null;case 10:return Fn(e.type),Ue(e),null;case 19:if(Bl(e),a=e.memoizedState,a===null)return Ue(e),null;if(E=(e.flags&128)!==0,L=a.rendering,L===null)if(E)oo(a,!1);else{if($e!==0||t!==null&&(t.flags&128)!==0)for(t=e.child;t!==null;){if(L=ta(t),L!==null){for(e.flags|=128,oo(a,!1),t=L.updateQueue,e.updateQueue=t,pa(e,t),e.subtreeFlags=0,t=n,n=e.child;n!==null;)nc(n,t),n=n.sibling;return eo(e,pi.current&1|2),Se&&On(e,a.treeForkCount),e.child}t=t.sibling}a.tail!==null&&De()>La&&(e.flags|=128,E=!0,oo(a,!1),e.lanes=4194304)}else{if(!E)if(t=ta(L),t!==null){if(e.flags|=128,E=!0,t=t.updateQueue,e.updateQueue=t,pa(e,t),oo(a,!0),a.tail===null&&a.tailMode!=="collapsed"&&a.tailMode!=="visible"&&!L.alternate&&!Se)return Ue(e),null}else 2*De()-a.renderingStartTime>La&&n!==536870912&&(e.flags|=128,E=!0,oo(a,!1),e.lanes=4194304);a.isBackwards?(L.sibling=e.child,e.child=L):(t=a.last,t!==null?t.sibling=L:e.child=L,a.last=L)}if(a.tail!==null){t=a.tail;t:{for(n=t;n!==null;){if(n.alternate!==null){n=!1;break t}n=n.sibling}n=!0}return a.rendering=t,a.tail=t.sibling,a.renderingStartTime=De(),t.sibling=null,L=pi.current,L=E?L&1|2:L&1,a.tailMode==="visible"||a.tailMode==="collapsed"||!n||Se?eo(e,L):(n=L,it(mi,e),it(pi,n),Ei===null&&(Ei=e)),Se&&On(e,a.treeForkCount),t}return Ue(e),null;case 22:case 23:return zi(e),Nl(),a=e.memoizedState!==null,t!==null?t.memoizedState!==null!==a&&(e.flags|=8192):a&&(e.flags|=8192),a?(n&536870912)!==0&&(e.flags&128)===0&&(Ue(e),e.subtreeFlags&6&&(e.flags|=8192)):Ue(e),n=e.updateQueue,n!==null&&pa(e,n.retryQueue),n=null,t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(n=t.memoizedState.cachePool.pool),a=null,e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(a=e.memoizedState.cachePool.pool),a!==n&&(e.flags|=2048),t!==null&&et(Fs),null;case 24:return n=null,t!==null&&(n=t.memoizedState.cache),e.memoizedState.cache!==n&&(e.flags|=2048),Fn(ei),Ue(e),null;case 25:return null;case 30:return e.flags|=33554432,Ue(e),null}throw Error(Lt(156,e.tag))}function np(t,e){switch(Sl(e),e.tag){case 1:return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return Fn(ei),Vt(),t=e.flags,(t&65536)!==0&&(t&128)===0?(e.flags=t&-65537|128,e):null;case 26:case 27:case 5:return It(e),null;case 31:if(e.memoizedState!==null){if(zi(e),e.alternate===null)throw Error(Lt(340));Ns()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 13:if(zi(e),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(Lt(340));Ns()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return Bl(e),t=e.flags,t&65536?(e.flags=t&-65537|128,t=e.memoizedState,t!==null&&(t.rendering=null,t.tail=null),e.flags|=4,e):null;case 4:return Vt(),null;case 10:return Fn(e.type),null;case 22:case 23:return zi(e),Nl(),t!==null&&et(Fs),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 24:return Fn(ei),null;case 25:return null;default:return null}}function Rd(t,e){switch(Sl(e),e.tag){case 3:Fn(ei),Vt();break;case 26:case 27:case 5:It(e);break;case 4:Vt();break;case 31:e.memoizedState!==null&&zi(e);break;case 13:zi(e);break;case 19:Bl(e);break;case 10:Fn(e.type);break;case 22:case 23:zi(e),Nl(),t!==null&&et(Fs);break;case 24:Fn(ei)}}function ao(t,e){try{var n=e.updateQueue,a=n!==null?n.lastEffect:null;if(a!==null){var E=a.next;n=E;do{if((n.tag&t)===t){a=void 0;var L=n.create,K=n.inst;a=L(),K.destroy=a}n=n.next}while(n!==E)}}catch(ut){Ie(e,e.return,ut)}}function hs(t,e,n){try{var a=e.updateQueue,E=a!==null?a.lastEffect:null;if(E!==null){var L=E.next;a=L;do{if((a.tag&t)===t){var K=a.inst,ut=K.destroy;if(ut!==void 0){K.destroy=void 0,E=e;var xt=n,Rt=ut;try{Rt()}catch(kt){Ie(E,xt,kt)}}}a=a.next}while(a!==L)}}catch(kt){Ie(e,e.return,kt)}}function Nd(t){var e=t.updateQueue;if(e!==null){var n=t.stateNode;try{Ec(e,n)}catch(a){Ie(t,t.return,a)}}}function Id(t,e,n){n.props=Us(t.type,t.memoizedProps),n.state=t.memoizedState;try{n.componentWillUnmount()}catch(a){Ie(t,e,a)}}function yn(t,e){try{var n=t.ref;if(n!==null){switch(t.tag){case 26:case 27:case 5:var a=t.stateNode;break;case 30:var E=t.stateNode,L=Nn(t.memoizedProps,E);(E.ref===null||E.ref.name!==L)&&(E.ref=zf(L)),a=E.ref;break;case 7:if(t.stateNode===null){var K=new Xi(t);o(t.child,!1,Yp,K,void 0,void 0),t.stateNode=K}a=t.stateNode;break;default:a=t.stateNode}typeof n=="function"?t.refCleanup=n(a):n.current=a}}catch(ut){Ie(t,e,ut)}}function gi(t,e){var n=t.ref,a=t.refCleanup;if(n!==null)if(typeof a=="function")try{a()}catch(E){Ie(t,e,E)}finally{t.refCleanup=null,t=t.alternate,t!=null&&(t.refCleanup=null)}else if(typeof n=="function")try{n(null)}catch(E){Ie(t,e,E)}else n.current=null}function ga(t,e){if((t.tag===5||t.tag===27||t.tag===6)&&t.alternate===null&&e!==null)for(var n=0;n title"))),bi(a,e,n),a[Ze]=t,vt(a),e=a;break t;case"link":if(L=s1("link","href",E).get(e+(n.href||""))){for(K=0;Kge&&(K=ge,ge=ue,ue=K);var Pt=jh(ut,ue),wt=jh(ut,ge);if(Pt&&wt&&(Ot.rangeCount!==1||Ot.anchorNode!==Pt.node||Ot.anchorOffset!==Pt.offset||Ot.focusNode!==wt.node||Ot.focusOffset!==wt.offset)){var Bt=jt.createRange();Bt.setStart(Pt.node,Pt.offset),Ot.removeAllRanges(),ue>ge?(Ot.addRange(Bt),Ot.extend(wt.node,wt.offset)):(Bt.setEnd(wt.node,wt.offset),Ot.addRange(Bt))}}}}for(jt=[],Ot=ut;Ot=Ot.parentNode;)Ot.nodeType===1&&jt.push({element:Ot,left:Ot.scrollLeft,top:Ot.scrollTop});for(typeof ut.focus=="function"&&ut.focus(),ut=0;utn?32:n,O.T=null,n=Cu,Cu=null;var L=fn,K=_n;if(Qe=0,Xs=fn=null,_n=0,(Ae&6)!==0)throw Error(Lt(331));var ut=Ae;if(Ae|=4,nf(L.current),$d(L,L.current,K,n),Ae=ut,po(0,!1),Te&&typeof Te.onPostCommitFiberRoot=="function")try{Te.onPostCommitFiberRoot(He,L)}catch{}return!0}finally{D.p=E,O.T=a,Sf(t,e)}}function yf(t,e,n){e=Ki(n,e),e=$l(t.stateNode,e,2),t=os(t,e,2),t!==null&&(yi(t,2),wn(t))}function Ie(t,e,n){if(t.tag===3)yf(t,t,n);else for(;e!==null;){if(e.tag===3){yf(e,t,n);break}else if(e.tag===1){var a=e.stateNode;if(typeof e.type.getDerivedStateFromError=="function"||typeof a.componentDidCatch=="function"&&(ms===null||!ms.has(a))){t=Ki(n,t),n=md(2),a=os(e,n,2),a!==null&&(pd(n,a,e,t),yi(a,2),wn(a));break}}e=e.return}}function Fu(t,e,n){var a=t.pingCache;if(a===null){a=t.pingCache=new ap;var E=new Set;a.set(e,E)}else E=a.get(e),E===void 0&&(E=new Set,a.set(e,E));E.has(n)||(Lu=!0,E.add(n),t=pp.bind(null,t,e,n),e.then(t,t))}function pp(t,e,n){var a=t.pingCache;a!==null&&a.delete(e),t.pingedLanes|=t.suspendedLanes&n,t.warmLanes&=~n,ke===t&&(xe&n)===n&&(($e===4||$e===3&&(xe&62914560)===xe&&300>De()-wa)&&(Ae&2)===0?Tr(t,0):_a|=n,yr===xe&&(yr=0)),wn(t)}function vf(t,e){e===0&&(e=An()),t=Cs(t,e),t!==null&&(yi(t,e),wn(t))}function gp(t){var e=t.memoizedState,n=0;e!==null&&(n=e.retryLane),vf(t,n)}function bp(t,e){var n=0;switch(t.tag){case 31:case 13:var a=t.stateNode,E=t.memoizedState;E!==null&&(n=E.retryLane);break;case 19:a=t.stateNode;break;case 22:a=t.stateNode._retryCache;break;default:throw Error(Lt(314))}a!==null&&a.delete(e),vf(t,n)}function Sp(t,e){return ie(t,e)}var wr=null,Lr=null,ku=!1,Ba=!1,Vu=!1,gs=0;function wn(t){t!==Lr&&t.next===null&&(Lr===null?wr=Lr=t:Lr=Lr.next=t),Ba=!0,ku||(ku=!0,vp())}function po(t,e){if(!Vu&&Ba){Vu=!0;do for(var n=!1,a=wr;a!==null;){if(t!==0){var E=a.pendingLanes;if(E===0)var L=0;else{var K=a.suspendedLanes,ut=a.pingedLanes;L=(1<<31-ci(42|t)+1)-1,L&=E&~(K&~ut),L=L&201326741?L&201326741|1:L?L|2:0}L!==0&&(n=!0,Tf(a,L))}else L=xe,L=Ln(a,a===ke?L:0,a.cancelPendingCommit!==null||a.timeoutHandle!==-1),(L&3)===0||rn(a,L)||(n=!0,Tf(a,L));a=a.next}while(n);Vu=!1}}function yp(){Ef()}function Ef(){Ba=ku=!1;var t=0;gs!==0&&Rp()&&(t=gs);for(var e=De(),n=null,a=wr;a!==null;){var E=a.next,L=xf(a,e);L===0?(a.next=null,n===null?wr=E:n.next=E,E===null&&(Lr=n)):(n=a,(t!==0||(L&3)!==0)&&(Ba=!0)),a=E}Qe!==0&&Qe!==5||po(t),gs!==0&&(gs=0)}function xf(t,e){for(var n=t.suspendedLanes,a=t.pingedLanes,E=t.expirationTimes,L=t.pendingLanes&-62914561;0ut)break;var kt=xt.transferSize,jt=xt.initiatorType;kt&&Rf(jt)&&(xt=xt.responseEnd,K+=kt*(xtVa){ue.length=se;break}Bt=new Promise(Fp.bind(Bt)),ue.push(Bt)}}}if(0"u"?null:document;function t1(t,e,n){var a=Pr;if(a&&typeof e=="string"&&e){var E=ne(e);E='link[rel="'+t+'"][href="'+E+'"]',typeof n=="string"&&(E+='[crossorigin="'+n+'"]'),$f.has(E)||($f.add(E),t={rel:t,crossOrigin:n,href:e},a.querySelector(E)===null&&(e=a.createElement("link"),bi(e,"link",t),vt(e),a.head.appendChild(e)))}}function i2(t){Hn.D(t),t1("dns-prefetch",t,null)}function n2(t,e){Hn.C(t,e),t1("preconnect",t,e)}function s2(t,e,n){Hn.L(t,e,n);var a=Pr;if(a&&t&&e){var E='link[rel="preload"][as="'+ne(e)+'"]';e==="image"&&n&&n.imageSrcSet?(E+='[imagesrcset="'+ne(n.imageSrcSet)+'"]',typeof n.imageSizes=="string"&&(E+='[imagesizes="'+ne(n.imageSizes)+'"]')):E+='[href="'+ne(t)+'"]';var L=E;switch(e){case"style":L=Cr(t);break;case"script":L=Rr(t)}if(!(en.has(L)||(t=x({rel:"preload",href:e==="image"&&n&&n.imageSrcSet?void 0:t,as:e},n),en.set(L,t),a.querySelector(E)!==null||e==="style"&&a.querySelector(vo(L))||e==="script"&&a.querySelector(Eo(L))))){var K=a.createElement("link");bi(K,"link",t),e==="style"&&(K[Js]=!0,K.onload=K.onerror=function(){i(K)}),vt(K),a.head.appendChild(K)}}}function r2(t,e){Hn.m(t,e);var n=Pr;if(n&&t){var a=e&&typeof e.as=="string"?e.as:"script",E='link[rel="modulepreload"][as="'+ne(a)+'"][href="'+ne(t)+'"]',L=E;switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":L=Rr(t)}if(!en.has(L)&&(t=x({rel:"modulepreload",href:t},e),en.set(L,t),n.querySelector(E)===null)){switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(n.querySelector(Eo(L)))return}a=n.createElement("link"),bi(a,"link",t),vt(a),n.head.appendChild(a)}}}function o2(t,e,n){Hn.S(t,e,n);var a=Pr;if(a&&t){var E=Xn(a).hoistableStyles,L=Cr(t);e=e||"default";var K=E.get(L);if(!K){var ut={loading:0,preload:null};if(K=a.querySelector(vo(L)))ut.loading=5;else{t=x({rel:"stylesheet",href:t,"data-precedence":e},n),(n=en.get(L))&&oh(t,n);var xt=K=a.createElement("link");vt(xt),bi(xt,"link",t),xt._p=new Promise(function(Rt,kt){xt.onload=Rt,xt.onerror=kt}),xt.addEventListener("load",function(){ut.loading|=1}),xt.addEventListener("error",function(){ut.loading|=2}),ut.loading|=4,Fa(K,e,a)}K={type:"stylesheet",instance:K,count:1,state:ut},E.set(L,K)}}}function a2(t,e){Hn.X(t,e);var n=Pr;if(n&&t){var a=Xn(n).hoistableScripts,E=Rr(t),L=a.get(E);L||(L=n.querySelector(Eo(E)),L||(t=x({src:t,async:!0},e),(e=en.get(E))&&ah(t,e),L=n.createElement("script"),vt(L),bi(L,"link",t),n.head.appendChild(L)),L={type:"script",instance:L,count:1,state:null},a.set(E,L))}}function l2(t,e){Hn.M(t,e);var n=Pr;if(n&&t){var a=Xn(n).hoistableScripts,E=Rr(t),L=a.get(E);L||(L=n.querySelector(Eo(E)),L||(t=x({src:t,async:!0,type:"module"},e),(e=en.get(E))&&ah(t,e),L=n.createElement("script"),vt(L),bi(L,"link",t),n.head.appendChild(L)),L={type:"script",instance:L,count:1,state:null},a.set(E,L))}}function e1(t,e,n,a){var E=(E=yt.current)?yo(E):null;if(!E)throw Error(Lt(446));switch(t){case"meta":case"title":return null;case"style":return typeof n.precedence=="string"&&typeof n.href=="string"?(n=Cr(n.href),e=Xn(E).hoistableStyles,a=e.get(n),a||(a={type:"style",instance:null,count:0,state:null},e.set(n,a)),a):{type:"void",instance:null,count:0,state:null};case"link":if(n.rel==="stylesheet"&&typeof n.href=="string"&&typeof n.precedence=="string"){t=Cr(n.href);var L=Xn(E).hoistableStyles,K=L.get(t);if(K||(E=E.ownerDocument||E,K={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},L.set(t,K),(L=E.querySelector(vo(t)))?L._p||(K.instance=L,K.state.loading=5):(L=en.get(t),L||(L={rel:"preload",as:"style",href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},en.set(t,L)),u2(E,t,L,K.state))),e&&a===null)throw Error(Lt(528,""));return K}if(e&&a!==null)throw Error(Lt(529,""));return null;case"script":return e=n.async,n=n.src,typeof n=="string"&&e&&typeof e!="function"&&typeof e!="symbol"?(n=Rr(n),e=Xn(E).hoistableScripts,a=e.get(n),a||(a={type:"script",instance:null,count:0,state:null},e.set(n,a)),a):{type:"void",instance:null,count:0,state:null};default:throw Error(Lt(444,t))}}function Cr(t){return'href="'+ne(t)+'"'}function vo(t){return'link[rel="stylesheet"]['+t+"]"}function i1(t){return x({},t,{"data-precedence":t.precedence,precedence:null})}function u2(t,e,n,a){if(e=t.querySelector('link[rel="preload"][as="style"]['+e+"]")){if(e[Js]!==!0){a.loading=1;return}}else e=t.createElement("link"),e[Js]=!0,e.onload=e.onerror=i.bind(null,e),bi(e,"link",n),vt(e),t.head.appendChild(e);a.preload=e,e.addEventListener("load",function(){return a.loading|=1}),e.addEventListener("error",function(){return a.loading|=2})}function Rr(t){return'[src="'+ne(t)+'"]'}function Eo(t){return"script[async]"+t}function n1(t,e,n){if(e.count++,e.instance===null)switch(e.type){case"style":var a=t.querySelector('style[data-href~="'+ne(n.href)+'"]');if(a)return e.instance=a,vt(a),a;var E=x({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return a=(t.ownerDocument||t).createElement("style"),vt(a),bi(a,"style",E),Fa(a,n.precedence,t),e.instance=a;case"stylesheet":E=Cr(n.href);var L=t.querySelector(vo(E));if(L)return e.state.loading|=4,e.instance=L,vt(L),L;a=i1(n),(E=en.get(E))&&oh(a,E),L=(t.ownerDocument||t).createElement("link"),vt(L);var K=L;return K._p=new Promise(function(ut,xt){K.onload=ut,K.onerror=xt}),bi(L,"link",a),e.state.loading|=4,Fa(L,n.precedence,t),e.instance=L;case"script":return L=Rr(n.src),(E=t.querySelector(Eo(L)))?(e.instance=E,vt(E),E):(a=n,(E=en.get(L))&&(a=x({},n),ah(a,E)),t=t.ownerDocument||t,E=t.createElement("script"),vt(E),bi(E,"link",a),t.head.appendChild(E),e.instance=E);case"void":return null;default:throw Error(Lt(443,e.type))}else e.type==="stylesheet"&&(e.state.loading&4)===0&&(a=e.instance,e.state.loading|=4,Fa(a,n.precedence,t));return e.instance}function Fa(t,e,n){for(var a=n.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),E=a.length?a[a.length-1]:null,L=E,K=0;K title"):null)}function h2(t,e,n){if(n===1||e.itemProp!=null)return!1;switch(t){case"meta":case"title":return!0;case"style":if(typeof e.precedence!="string"||typeof e.href!="string"||e.href==="")break;return!0;case"link":if(typeof e.rel!="string"||typeof e.href!="string"||e.href===""||e.onLoad||e.onError)break;switch(e.rel){case"stylesheet":return t=e.disabled,typeof e.precedence=="string"&&t==null;default:return!0}case"script":if(e.async&&typeof e.async!="function"&&typeof e.async!="symbol"&&!e.onLoad&&!e.onError&&e.src&&typeof e.src=="string")return!0}return!1}function r1(t,e){return t==="img"&&e.src!=null&&e.src!==""&&e.onLoad==null&&e.loading!=="lazy"}function o1(t){return!(t.type==="stylesheet"&&(t.state.loading&3)===0)}function a1(t){return(t.width||100)*(t.height||100)*(typeof devicePixelRatio=="number"?devicePixelRatio:1)*.25}function l1(t,e){typeof e.decode=="function"&&(t.imgCount++,e.complete||(t.imgBytes+=a1(e),t.suspenseyImages.push(e)),t=f2.bind(t),e.decode().then(t,t))}function c2(t,e,n,a){if(n.type==="stylesheet"&&(typeof a.media!="string"||matchMedia(a.media).matches!==!1)&&(n.state.loading&4)===0){if(n.instance===null){var E=Cr(a.href),L=e.querySelector(vo(E));if(L){e=L._p,e!==null&&typeof e=="object"&&typeof e.then=="function"&&(t.count++,t=xo.bind(t),e.then(t,t)),n.state.loading|=4,n.instance=L,vt(L);return}L=e.ownerDocument||e,a=i1(a),(E=en.get(E))&&oh(a,E),L=L.createElement("link"),vt(L);var K=L;K._p=new Promise(function(ut,xt){K.onload=ut,K.onerror=xt}),bi(L,"link",a),n.instance=L}t.stylesheets===null&&(t.stylesheets=new Map),t.stylesheets.set(n,e),(e=n.state.preload)&&(n.state.loading&3)===0&&(t.count++,n=xo.bind(t),e.addEventListener("load",n),e.addEventListener("error",n))}}var Va=0;function d2(t,e){return t.stylesheets&&t.count===0&&za(t,t.stylesheets),0Va?50:800)+e);return t.unsuspend=n,function(){t.unsuspend=null,clearTimeout(a),clearTimeout(E)}}:null}function u1(t){if(t.count===0&&(t.imgCount===0||!t.waitingForImages)){if(t.stylesheets)za(t,t.stylesheets);else if(t.unsuspend){var e=t.unsuspend;t.unsuspend=null,e()}}}function xo(){this.count--,u1(this)}function f2(){this.imgCount--,u1(this)}var Ga=null;function za(t,e){t.stylesheets=null,t.unsuspend!==null&&(t.count++,Ga=new Map,e.forEach(m2,t),Ga=null,xo.call(t))}function m2(t,e){if(!(e.state.loading&4)){var n=Ga.get(t);if(n)var a=n.get(null);else{n=new Map,Ga.set(t,n);for(var E=t.querySelectorAll("link[data-precedence],style[data-precedence]"),L=0;L"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Ht)}catch(te){console.error(te)}}return Ht(),bh.exports=C2(),bh.exports}var N2=R2();const I2=k1(N2),B2=({spans:Ht})=>!Ht||Ht.length===0?null:Gt.jsxs("div",{className:"bg-white rounded-xl shadow-sm border border-slate-200 p-4",children:[Gt.jsx("div",{className:"text-xs font-semibold uppercase tracking-wider text-slate-500 mb-2",children:"Harmonic Modulation Trajectory"}),Gt.jsx("div",{className:"flex flex-wrap items-center gap-2",children:Ht.map((te,re)=>Gt.jsxs(V1.Fragment,{children:[Gt.jsxs("div",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-semibold text-white shadow-sm transition-transform hover:scale-105",style:{backgroundColor:te.colorHex||"#1e293b"},children:[Gt.jsx("span",{className:"text-sm font-bold tracking-tight",children:te.center}),Gt.jsxs("span",{className:"opacity-80 text-[10px] font-normal",children:["(",te.startBar===te.endBar?`bar ${te.startBar}`:`bars ${te.startBar}–${te.endBar}`,")"]})]}),re!Ht||Ht.length===0?null:Gt.jsxs("div",{className:"bg-white rounded-xl shadow-sm border border-slate-200 p-4",children:[Gt.jsxs("div",{className:"text-xs font-semibold uppercase tracking-wider text-slate-500 mb-2",children:["Identified Berklee Harmonic Devices (",Ht.length,")"]}),Gt.jsx("div",{className:"flex flex-wrap gap-2",children:Ht.map((te,re)=>Gt.jsxs("div",{className:`flex items-center gap-2 px-3 py-1.5 rounded-lg border text-xs ${te.IsDashed?"border-dashed border-amber-300 bg-amber-50/50 text-amber-900":"border-slate-200 bg-slate-50 text-slate-800"}`,children:[Gt.jsx("span",{className:"font-bold text-sm",children:te.Label}),Gt.jsxs("span",{className:"text-[11px] text-slate-500",children:["bars ",te.StartMeasure+1,"–",te.EndMeasure+1]}),te.Resolves&&Gt.jsxs("span",{className:"px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800 text-[10px] font-bold",children:["Resolves ➔ ",te.TargetKey]}),!te.Resolves&&Gt.jsx("span",{className:"px-1.5 py-0.5 rounded bg-slate-200 text-slate-600 text-[10px] font-medium",children:"Turnaround ┐"})]},re))})]}),D2=({measures:Ht})=>!Ht||Ht.length===0||!Ht.some(re=>re.chords&&re.chords.length>0)?null:Gt.jsxs("div",{className:"bg-white rounded-xl shadow-sm border border-slate-200 overflow-hidden",children:[Gt.jsxs("div",{className:"px-5 py-3 border-b border-slate-100 bg-slate-50/50 flex justify-between items-center",children:[Gt.jsx("h3",{className:"text-sm font-semibold text-slate-800",children:"Measure & Voice Leading Detail"}),Gt.jsxs("span",{className:"text-xs text-slate-500",children:[Ht.length," measures"]})]}),Gt.jsx("div",{className:"overflow-x-auto max-h-96",children:Gt.jsxs("table",{className:"w-full text-left text-xs border-collapse",children:[Gt.jsx("thead",{className:"bg-slate-100/75 text-slate-600 font-semibold sticky top-0 shadow-sm z-10",children:Gt.jsxs("tr",{children:[Gt.jsx("th",{className:"py-2.5 px-4",children:"Bar"}),Gt.jsx("th",{className:"py-2.5 px-4",children:"Beat"}),Gt.jsx("th",{className:"py-2.5 px-4",children:"Chord"}),Gt.jsx("th",{className:"py-2.5 px-4",children:"Hold"}),Gt.jsx("th",{className:"py-2.5 px-4",children:"Voice 1 (3/7)"}),Gt.jsx("th",{className:"py-2.5 px-4",children:"Voice 2 (3/7)"}),Gt.jsx("th",{className:"py-2.5 px-4",children:"Tonal Center"})]})}),Gt.jsx("tbody",{className:"divide-y divide-slate-100 font-mono",children:Ht.flatMap(re=>(re.chords||[]).map((Lt,ae)=>Gt.jsxs("tr",{className:"hover:bg-slate-50/80 transition-colors",children:[Gt.jsx("td",{className:"py-2 px-4 font-semibold text-slate-700",children:ae===0?re.number:""}),Gt.jsx("td",{className:"py-2 px-4 text-slate-500",children:(Lt.beatOffset+1).toFixed(1)}),Gt.jsx("td",{className:"py-2 px-4 font-bold text-slate-900",children:Lt.symbol}),Gt.jsxs("td",{className:"py-2 px-4 text-slate-600",children:[Lt.durationBeats.toFixed(1)," b"]}),Gt.jsx("td",{className:"py-2 px-4 text-blue-600 font-semibold",children:Lt.voice1}),Gt.jsx("td",{className:"py-2 px-4 text-indigo-600 font-semibold",children:Lt.voice2}),Gt.jsx("td",{className:"py-2 px-4",children:Gt.jsx("span",{className:"inline-block px-2 py-0.5 rounded text-[11px] font-bold text-white shadow-xs",style:{backgroundColor:Lt.colorHex||"#334155"},children:Lt.tonalCenter})})]},`${re.number}-${ae}`)))})]})})]});var qa={exports:{}};/*! For license information please see opensheetmusicdisplay.min.js.LICENSE.txt */var F2=qa.exports,I1;function k2(){return I1||(I1=1,(function(Ht,te){(function(re,Lt){Ht.exports=Lt()})(F2,()=>(()=>{var re={1710(St,y,p){St.exports=(function d(l,m,o){function s(f,r){if(!m[f]){if(!l[f]){if(h)return h(f,!0);var b=new Error("Cannot find module '"+f+"'");throw b.code="MODULE_NOT_FOUND",b}var S=m[f]={exports:{}};l[f][0].call(S.exports,function(v){return s(l[f][1][v]||v)},S,S.exports,d,l,m,o)}return m[f].exports}for(var h=void 0,u=0;u>2,v=(3&f)<<4|r>>4,w=1<_?(15&r)<<2|b>>6:64,T=2<_?63&b:64,g.push(h.charAt(S)+h.charAt(v)+h.charAt(w)+h.charAt(T));return g.join("")},m.decode=function(u){var f,r,b,S,v,w,T=0,g=0,x="data:";if(u.substr(0,5)===x)throw new Error("Invalid base64 input, it looks like a data url.");var P,_=3*(u=u.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(u.charAt(u.length-1)===h.charAt(64)&&_--,u.charAt(u.length-2)===h.charAt(64)&&_--,_%1!=0)throw new Error("Invalid base64 input, bad content length.");for(P=s.uint8array?new Uint8Array(0|_):new Array(0|_);T>4,r=(15&S)<<4|(v=h.indexOf(u.charAt(T++)))>>2,b=(3&v)<<6|(w=h.indexOf(u.charAt(T++))),P[g++]=f,v!==64&&(P[g++]=r),w!==64&&(P[g++]=b);return P}},{"./support":30,"./utils":32}],2:[function(d,l,m){var o=d("./external"),s=d("./stream/DataWorker"),h=d("./stream/Crc32Probe"),u=d("./stream/DataLengthProbe");function f(r,b,S,v,w){this.compressedSize=r,this.uncompressedSize=b,this.crc32=S,this.compression=v,this.compressedContent=w}f.prototype={getContentWorker:function(){var r=new s(o.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new u("data_length")),b=this;return r.on("end",function(){if(this.streamInfo.data_length!==b.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),r},getCompressedWorker:function(){return new s(o.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},f.createWorkerFrom=function(r,b,S){return r.pipe(new h).pipe(new u("uncompressedSize")).pipe(b.compressWorker(S)).pipe(new u("compressedSize")).withStreamInfo("compression",b)},l.exports=f},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(d,l,m){var o=d("./stream/GenericWorker");m.STORE={magic:"\0\0",compressWorker:function(){return new o("STORE compression")},uncompressWorker:function(){return new o("STORE decompression")}},m.DEFLATE=d("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(d,l,m){var o=d("./utils"),s=(function(){for(var h,u=[],f=0;f<256;f++){h=f;for(var r=0;r<8;r++)h=1&h?3988292384^h>>>1:h>>>1;u[f]=h}return u})();l.exports=function(h,u){return h!==void 0&&h.length?o.getTypeOf(h)!=="string"?(function(f,r,b){var S=s,v=0+b;f^=-1;for(var w=0;w>>8^S[255&(f^r[w])];return-1^f})(0|u,h,h.length):(function(f,r,b){var S=s,v=0+b;f^=-1;for(var w=0;w>>8^S[255&(f^r.charCodeAt(w))];return-1^f})(0|u,h,h.length):0}},{"./utils":32}],5:[function(d,l,m){m.base64=!1,m.binary=!1,m.dir=!1,m.createFolders=!0,m.date=null,m.compression=null,m.compressionOptions=null,m.comment=null,m.unixPermissions=null,m.dosPermissions=null},{}],6:[function(d,l,m){var o;o=typeof Promise<"u"?Promise:d("lie"),l.exports={Promise:o}},{lie:37}],7:[function(d,l,m){var o=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",s=d("pako"),h=d("./utils"),u=d("./stream/GenericWorker"),f=o?"uint8array":"array";function r(b,S){u.call(this,"FlateWorker/"+b),this._pako=null,this._pakoAction=b,this._pakoOptions=S,this.meta={}}m.magic="\b\0",h.inherits(r,u),r.prototype.processChunk=function(b){this.meta=b.meta,this._pako===null&&this._createPako(),this._pako.push(h.transformTo(f,b.data),!1)},r.prototype.flush=function(){u.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},r.prototype.cleanUp=function(){u.prototype.cleanUp.call(this),this._pako=null},r.prototype._createPako=function(){this._pako=new s[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var b=this;this._pako.onData=function(S){b.push({data:S,meta:b.meta})}},m.compressWorker=function(b){return new r("Deflate",b)},m.uncompressWorker=function(){return new r("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(d,l,m){function o(v,w){var T,g="";for(T=0;T>>=8;return g}function s(v,w,T,g,x,P){var _,B,k=v.file,R=v.compression,F=P!==f.utf8encode,A=h.transformTo("string",P(k.name)),G=h.transformTo("string",f.utf8encode(k.name)),U=k.comment,C=h.transformTo("string",P(U)),z=h.transformTo("string",f.utf8encode(U)),W=G.length!==k.name.length,$=z.length!==U.length,N="",Y="",tt="",H=k.dir,rt=k.date,ct={crc32:0,compressedSize:0,uncompressedSize:0};w&&!T||(ct.crc32=v.crc32,ct.compressedSize=v.compressedSize,ct.uncompressedSize=v.uncompressedSize);var st=0;w&&(st|=8),F||!W&&!$||(st|=2048);var ot=0,ht=0;H&&(ot|=16),x==="UNIX"?(ht=798,ot|=(function(O,D){var j=O;return O||(j=D?16893:33204),(65535&j)<<16})(k.unixPermissions,H)):(ht=20,ot|=(function(O){return 63&(O||0)})(k.dosPermissions)),_=rt.getUTCHours(),_<<=6,_|=rt.getUTCMinutes(),_<<=5,_|=rt.getUTCSeconds()/2,B=rt.getUTCFullYear()-1980,B<<=4,B|=rt.getUTCMonth()+1,B<<=5,B|=rt.getUTCDate(),W&&(Y=o(1,1)+o(r(A),4)+G,N+="up"+o(Y.length,2)+Y),$&&(tt=o(1,1)+o(r(C),4)+z,N+="uc"+o(tt.length,2)+tt);var lt="";return lt+=` +\0`,lt+=o(st,2),lt+=R.magic,lt+=o(_,2),lt+=o(B,2),lt+=o(ct.crc32,4),lt+=o(ct.compressedSize,4),lt+=o(ct.uncompressedSize,4),lt+=o(A.length,2),lt+=o(N.length,2),{fileRecord:b.LOCAL_FILE_HEADER+lt+A+N,dirRecord:b.CENTRAL_FILE_HEADER+o(ht,2)+lt+o(C.length,2)+"\0\0\0\0"+o(ot,4)+o(g,4)+A+N+C}}var h=d("../utils"),u=d("../stream/GenericWorker"),f=d("../utf8"),r=d("../crc32"),b=d("../signature");function S(v,w,T,g){u.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=w,this.zipPlatform=T,this.encodeFileName=g,this.streamFiles=v,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}h.inherits(S,u),S.prototype.push=function(v){var w=v.meta.percent||0,T=this.entriesCount,g=this._sources.length;this.accumulate?this.contentBuffer.push(v):(this.bytesWritten+=v.data.length,u.prototype.push.call(this,{data:v.data,meta:{currentFile:this.currentFile,percent:T?(w+100*(T-g-1))/T:100}}))},S.prototype.openedSource=function(v){this.currentSourceOffset=this.bytesWritten,this.currentFile=v.file.name;var w=this.streamFiles&&!v.file.dir;if(w){var T=s(v,w,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:T.fileRecord,meta:{percent:0}})}else this.accumulate=!0},S.prototype.closedSource=function(v){this.accumulate=!1;var w=this.streamFiles&&!v.file.dir,T=s(v,w,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(T.dirRecord),w)this.push({data:(function(g){return b.DATA_DESCRIPTOR+o(g.crc32,4)+o(g.compressedSize,4)+o(g.uncompressedSize,4)})(v),meta:{percent:100}});else for(this.push({data:T.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},S.prototype.flush=function(){for(var v=this.bytesWritten,w=0;w=this.index;u--)f=(f<<8)+this.byteAt(u);return this.index+=h,f},readString:function(h){return o.transformTo("string",this.readData(h))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var h=this.readInt(4);return new Date(Date.UTC(1980+(h>>25&127),(h>>21&15)-1,h>>16&31,h>>11&31,h>>5&63,(31&h)<<1))}},l.exports=s},{"../utils":32}],19:[function(d,l,m){var o=d("./Uint8ArrayReader");function s(h){o.call(this,h)}d("../utils").inherits(s,o),s.prototype.readData=function(h){this.checkOffset(h);var u=this.data.slice(this.zero+this.index,this.zero+this.index+h);return this.index+=h,u},l.exports=s},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(d,l,m){var o=d("./DataReader");function s(h){o.call(this,h)}d("../utils").inherits(s,o),s.prototype.byteAt=function(h){return this.data.charCodeAt(this.zero+h)},s.prototype.lastIndexOfSignature=function(h){return this.data.lastIndexOf(h)-this.zero},s.prototype.readAndCheckSignature=function(h){return h===this.readData(4)},s.prototype.readData=function(h){this.checkOffset(h);var u=this.data.slice(this.zero+this.index,this.zero+this.index+h);return this.index+=h,u},l.exports=s},{"../utils":32,"./DataReader":18}],21:[function(d,l,m){var o=d("./ArrayReader");function s(h){o.call(this,h)}d("../utils").inherits(s,o),s.prototype.readData=function(h){if(this.checkOffset(h),h===0)return new Uint8Array(0);var u=this.data.subarray(this.zero+this.index,this.zero+this.index+h);return this.index+=h,u},l.exports=s},{"../utils":32,"./ArrayReader":17}],22:[function(d,l,m){var o=d("../utils"),s=d("../support"),h=d("./ArrayReader"),u=d("./StringReader"),f=d("./NodeBufferReader"),r=d("./Uint8ArrayReader");l.exports=function(b){var S=o.getTypeOf(b);return o.checkSupport(S),S!=="string"||s.uint8array?S==="nodebuffer"?new f(b):s.uint8array?new r(o.transformTo("uint8array",b)):new h(o.transformTo("array",b)):new u(b)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(d,l,m){m.LOCAL_FILE_HEADER="PK",m.CENTRAL_FILE_HEADER="PK",m.CENTRAL_DIRECTORY_END="PK",m.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",m.ZIP64_CENTRAL_DIRECTORY_END="PK",m.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(d,l,m){var o=d("./GenericWorker"),s=d("../utils");function h(u){o.call(this,"ConvertWorker to "+u),this.destType=u}s.inherits(h,o),h.prototype.processChunk=function(u){this.push({data:s.transformTo(this.destType,u.data),meta:u.meta})},l.exports=h},{"../utils":32,"./GenericWorker":28}],25:[function(d,l,m){var o=d("./GenericWorker"),s=d("../crc32");function h(){o.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}d("../utils").inherits(h,o),h.prototype.processChunk=function(u){this.streamInfo.crc32=s(u.data,this.streamInfo.crc32||0),this.push(u)},l.exports=h},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(d,l,m){var o=d("../utils"),s=d("./GenericWorker");function h(u){s.call(this,"DataLengthProbe for "+u),this.propName=u,this.withStreamInfo(u,0)}o.inherits(h,s),h.prototype.processChunk=function(u){if(u){var f=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=f+u.data.length}s.prototype.processChunk.call(this,u)},l.exports=h},{"../utils":32,"./GenericWorker":28}],27:[function(d,l,m){var o=d("../utils"),s=d("./GenericWorker");function h(u){s.call(this,"DataWorker");var f=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,u.then(function(r){f.dataIsReady=!0,f.data=r,f.max=r&&r.length||0,f.type=o.getTypeOf(r),f.isPaused||f._tickAndRepeat()},function(r){f.error(r)})}o.inherits(h,s),h.prototype.cleanUp=function(){s.prototype.cleanUp.call(this),this.data=null},h.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,o.delay(this._tickAndRepeat,[],this)),!0)},h.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(o.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},h.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var u=null,f=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":u=this.data.substring(this.index,f);break;case"uint8array":u=this.data.subarray(this.index,f);break;case"array":case"nodebuffer":u=this.data.slice(this.index,f)}return this.index=f,this.push({data:u,meta:{percent:this.max?this.index/this.max*100:0}})},l.exports=h},{"../utils":32,"./GenericWorker":28}],28:[function(d,l,m){function o(s){this.name=s||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}o.prototype={push:function(s){this.emit("data",s)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(s){this.emit("error",s)}return!0},error:function(s){return!this.isFinished&&(this.isPaused?this.generatedError=s:(this.isFinished=!0,this.emit("error",s),this.previous&&this.previous.error(s),this.cleanUp()),!0)},on:function(s,h){return this._listeners[s].push(h),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(s,h){if(this._listeners[s])for(var u=0;u "+s:s}},l.exports=o},{}],29:[function(d,l,m){var o=d("../utils"),s=d("./ConvertWorker"),h=d("./GenericWorker"),u=d("../base64"),f=d("../support"),r=d("../external"),b=null;if(f.nodestream)try{b=d("../nodejs/NodejsStreamOutputAdapter")}catch{}function S(v,w,T){var g=w;switch(w){case"blob":case"arraybuffer":g="uint8array";break;case"base64":g="string"}try{this._internalType=g,this._outputType=w,this._mimeType=T,o.checkSupport(g),this._worker=v.pipe(new s(g)),v.lock()}catch(x){this._worker=new h("error"),this._worker.error(x)}}S.prototype={accumulate:function(v){return(function(w,T){return new r.Promise(function(g,x){var P=[],_=w._internalType,B=w._outputType,k=w._mimeType;w.on("data",function(R,F){P.push(R),T&&T(F)}).on("error",function(R){P=[],x(R)}).on("end",function(){try{var R=(function(F,A,G){switch(F){case"blob":return o.newBlob(o.transformTo("arraybuffer",A),G);case"base64":return u.encode(A);default:return o.transformTo(F,A)}})(B,(function(F,A){var G,U=0,C=null,z=0;for(G=0;G"u")m.blob=!1;else{var o=new ArrayBuffer(0);try{m.blob=new Blob([o],{type:"application/zip"}).size===0}catch{try{var s=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);s.append(o),m.blob=s.getBlob("application/zip").size===0}catch{m.blob=!1}}}try{m.nodestream=!!d("readable-stream").Readable}catch{m.nodestream=!1}},{"readable-stream":16}],31:[function(d,l,m){for(var o=d("./utils"),s=d("./support"),h=d("./nodejsUtils"),u=d("./stream/GenericWorker"),f=new Array(256),r=0;r<256;r++)f[r]=252<=r?6:248<=r?5:240<=r?4:224<=r?3:192<=r?2:1;function b(){u.call(this,"utf-8 decode"),this.leftOver=null}function S(){u.call(this,"utf-8 encode")}f[254]=f[254]=1,m.utf8encode=function(v){return s.nodebuffer?h.newBufferFrom(v,"utf-8"):(function(w){var T,g,x,P,_,B=w.length,k=0;for(P=0;P>>6:(g<65536?T[_++]=224|g>>>12:(T[_++]=240|g>>>18,T[_++]=128|g>>>12&63),T[_++]=128|g>>>6&63),T[_++]=128|63&g);return T})(v)},m.utf8decode=function(v){return s.nodebuffer?o.transformTo("nodebuffer",v).toString("utf-8"):(function(w){var T,g,x,P,_=w.length,B=new Array(2*_);for(T=g=0;T<_;)if((x=w[T++])<128)B[g++]=x;else if(4<(P=f[x]))B[g++]=65533,T+=P-1;else{for(x&=P===2?31:P===3?15:7;1>10&1023,B[g++]=56320|1023&x)}return B.length!==g&&(B.subarray?B=B.subarray(0,g):B.length=g),o.applyFromCharCode(B)})(v=o.transformTo(s.uint8array?"uint8array":"array",v))},o.inherits(b,u),b.prototype.processChunk=function(v){var w=o.transformTo(s.uint8array?"uint8array":"array",v.data);if(this.leftOver&&this.leftOver.length){if(s.uint8array){var T=w;(w=new Uint8Array(T.length+this.leftOver.length)).set(this.leftOver,0),w.set(T,this.leftOver.length)}else w=this.leftOver.concat(w);this.leftOver=null}var g=(function(P,_){var B;for((_=_||P.length)>P.length&&(_=P.length),B=_-1;0<=B&&(192&P[B])==128;)B--;return B<0||B===0?_:B+f[P[B]]>_?B:_})(w),x=w;g!==w.length&&(s.uint8array?(x=w.subarray(0,g),this.leftOver=w.subarray(g,w.length)):(x=w.slice(0,g),this.leftOver=w.slice(g,w.length))),this.push({data:m.utf8decode(x),meta:v.meta})},b.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:m.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},m.Utf8DecodeWorker=b,o.inherits(S,u),S.prototype.processChunk=function(v){this.push({data:m.utf8encode(v.data),meta:v.meta})},m.Utf8EncodeWorker=S},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(d,l,m){var o=d("./support"),s=d("./base64"),h=d("./nodejsUtils"),u=d("./external");function f(T){return T}function r(T,g){for(var x=0;x>8;this.dir=!!(16&this.externalFileAttributes),v==0&&(this.dosPermissions=63&this.externalFileAttributes),v==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var v=o(this.extraFields[1].value);this.uncompressedSize===s.MAX_VALUE_32BITS&&(this.uncompressedSize=v.readInt(8)),this.compressedSize===s.MAX_VALUE_32BITS&&(this.compressedSize=v.readInt(8)),this.localHeaderOffset===s.MAX_VALUE_32BITS&&(this.localHeaderOffset=v.readInt(8)),this.diskNumberStart===s.MAX_VALUE_32BITS&&(this.diskNumberStart=v.readInt(4))}},readExtraFields:function(v){var w,T,g,x=v.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});v.index+4>>6:(v<65536?S[g++]=224|v>>>12:(S[g++]=240|v>>>18,S[g++]=128|v>>>12&63),S[g++]=128|v>>>6&63),S[g++]=128|63&v);return S},m.buf2binstring=function(b){return r(b,b.length)},m.binstring2buf=function(b){for(var S=new o.Buf8(b.length),v=0,w=S.length;v>10&1023,P[w++]=56320|1023&T)}return r(P,w)},m.utf8border=function(b,S){var v;for((S=S||b.length)>b.length&&(S=b.length),v=S-1;0<=v&&(192&b[v])==128;)v--;return v<0||v===0?S:v+u[b[v]]>S?v:S}},{"./common":41}],43:[function(d,l,m){l.exports=function(o,s,h,u){for(var f=65535&o,r=o>>>16&65535,b=0;h!==0;){for(h-=b=2e3>>1:s>>>1;h[u]=s}return h})();l.exports=function(s,h,u,f){var r=o,b=f+u;s^=-1;for(var S=f;S>>8^r[255&(s^h[S])];return-1^s}},{}],46:[function(d,l,m){var o,s=d("../utils/common"),h=d("./trees"),u=d("./adler32"),f=d("./crc32"),r=d("./messages"),b=-2,S=258,v=262,w=113;function T(N,Y){return N.msg=r[Y],Y}function g(N){return(N<<1)-(4N.avail_out&&(tt=N.avail_out),tt!==0&&(s.arraySet(N.output,Y.pending_buf,Y.pending_out,tt,N.next_out),N.next_out+=tt,Y.pending_out+=tt,N.total_out+=tt,N.avail_out-=tt,Y.pending-=tt,Y.pending===0&&(Y.pending_out=0))}function _(N,Y){h._tr_flush_block(N,0<=N.block_start?N.block_start:-1,N.strstart-N.block_start,Y),N.block_start=N.strstart,P(N.strm)}function B(N,Y){N.pending_buf[N.pending++]=Y}function k(N,Y){N.pending_buf[N.pending++]=Y>>>8&255,N.pending_buf[N.pending++]=255&Y}function R(N,Y){var tt,H,rt=N.max_chain_length,ct=N.strstart,st=N.prev_length,ot=N.nice_match,ht=N.strstart>N.w_size-v?N.strstart-(N.w_size-v):0,lt=N.window,O=N.w_mask,D=N.prev,j=N.strstart+S,Q=lt[ct+st-1],J=lt[ct+st];N.prev_length>=N.good_match&&(rt>>=2),ot>N.lookahead&&(ot=N.lookahead);do if(lt[(tt=Y)+st]===J&<[tt+st-1]===Q&<[tt]===lt[ct]&<[++tt]===lt[ct+1]){ct+=2,tt++;do;while(lt[++ct]===lt[++tt]&<[++ct]===lt[++tt]&<[++ct]===lt[++tt]&<[++ct]===lt[++tt]&<[++ct]===lt[++tt]&<[++ct]===lt[++tt]&<[++ct]===lt[++tt]&<[++ct]===lt[++tt]&&ctht&&--rt!=0);return st<=N.lookahead?st:N.lookahead}function F(N){var Y,tt,H,rt,ct,st,ot,ht,lt,O,D=N.w_size;do{if(rt=N.window_size-N.lookahead-N.strstart,N.strstart>=D+(D-v)){for(s.arraySet(N.window,N.window,D,D,0),N.match_start-=D,N.strstart-=D,N.block_start-=D,Y=tt=N.hash_size;H=N.head[--Y],N.head[Y]=D<=H?H-D:0,--tt;);for(Y=tt=D;H=N.prev[--Y],N.prev[Y]=D<=H?H-D:0,--tt;);rt+=D}if(N.strm.avail_in===0)break;if(st=N.strm,ot=N.window,ht=N.strstart+N.lookahead,O=void 0,(lt=rt)<(O=st.avail_in)&&(O=lt),tt=O===0?0:(st.avail_in-=O,s.arraySet(ot,st.input,st.next_in,O,ht),st.state.wrap===1?st.adler=u(st.adler,ot,O,ht):st.state.wrap===2&&(st.adler=f(st.adler,ot,O,ht)),st.next_in+=O,st.total_in+=O,O),N.lookahead+=tt,N.lookahead+N.insert>=3)for(ct=N.strstart-N.insert,N.ins_h=N.window[ct],N.ins_h=(N.ins_h<=3&&(N.ins_h=(N.ins_h<=3)if(H=h._tr_tally(N,N.strstart-N.match_start,N.match_length-3),N.lookahead-=N.match_length,N.match_length<=N.max_lazy_match&&N.lookahead>=3){for(N.match_length--;N.strstart++,N.ins_h=(N.ins_h<=3&&(N.ins_h=(N.ins_h<=3&&N.match_length<=N.prev_length){for(rt=N.strstart+N.lookahead-3,H=h._tr_tally(N,N.strstart-1-N.prev_match,N.prev_length-3),N.lookahead-=N.prev_length-1,N.prev_length-=2;++N.strstart<=rt&&(N.ins_h=(N.ins_h<N.pending_buf_size-5&&(tt=N.pending_buf_size-5);;){if(N.lookahead<=1){if(F(N),N.lookahead===0&&Y===0)return 1;if(N.lookahead===0)break}N.strstart+=N.lookahead,N.lookahead=0;var H=N.block_start+tt;if((N.strstart===0||N.strstart>=H)&&(N.lookahead=N.strstart-H,N.strstart=H,_(N,!1),N.strm.avail_out===0)||N.strstart-N.block_start>=N.w_size-v&&(_(N,!1),N.strm.avail_out===0))return 1}return N.insert=0,Y===4?(_(N,!0),N.strm.avail_out===0?3:4):(N.strstart>N.block_start&&(_(N,!1),N.strm.avail_out),1)}),new U(4,4,8,4,A),new U(4,5,16,8,A),new U(4,6,32,32,A),new U(4,4,16,16,G),new U(8,16,32,32,G),new U(8,16,128,128,G),new U(8,32,128,256,G),new U(32,128,258,1024,G),new U(32,258,258,4096,G)],m.deflateInit=function(N,Y){return $(N,Y,8,15,8,0)},m.deflateInit2=$,m.deflateReset=W,m.deflateResetKeep=z,m.deflateSetHeader=function(N,Y){return N&&N.state?N.state.wrap!==2?b:(N.state.gzhead=Y,0):b},m.deflate=function(N,Y){var tt,H,rt,ct;if(!N||!N.state||5>8&255),B(H,H.gzhead.time>>16&255),B(H,H.gzhead.time>>24&255),B(H,H.level===9?2:2<=H.strategy||H.level<2?4:0),B(H,255&H.gzhead.os),H.gzhead.extra&&H.gzhead.extra.length&&(B(H,255&H.gzhead.extra.length),B(H,H.gzhead.extra.length>>8&255)),H.gzhead.hcrc&&(N.adler=f(N.adler,H.pending_buf,H.pending,0)),H.gzindex=0,H.status=69):(B(H,0),B(H,0),B(H,0),B(H,0),B(H,0),B(H,H.level===9?2:2<=H.strategy||H.level<2?4:0),B(H,3),H.status=w);else{var st=8+(H.w_bits-8<<4)<<8;st|=(2<=H.strategy||H.level<2?0:H.level<6?1:H.level===6?2:3)<<6,H.strstart!==0&&(st|=32),st+=31-st%31,H.status=w,k(H,st),H.strstart!==0&&(k(H,N.adler>>>16),k(H,65535&N.adler)),N.adler=1}if(H.status===69)if(H.gzhead.extra){for(rt=H.pending;H.gzindex<(65535&H.gzhead.extra.length)&&(H.pending!==H.pending_buf_size||(H.gzhead.hcrc&&H.pending>rt&&(N.adler=f(N.adler,H.pending_buf,H.pending-rt,rt)),P(N),rt=H.pending,H.pending!==H.pending_buf_size));)B(H,255&H.gzhead.extra[H.gzindex]),H.gzindex++;H.gzhead.hcrc&&H.pending>rt&&(N.adler=f(N.adler,H.pending_buf,H.pending-rt,rt)),H.gzindex===H.gzhead.extra.length&&(H.gzindex=0,H.status=73)}else H.status=73;if(H.status===73)if(H.gzhead.name){rt=H.pending;do{if(H.pending===H.pending_buf_size&&(H.gzhead.hcrc&&H.pending>rt&&(N.adler=f(N.adler,H.pending_buf,H.pending-rt,rt)),P(N),rt=H.pending,H.pending===H.pending_buf_size)){ct=1;break}ct=H.gzindexrt&&(N.adler=f(N.adler,H.pending_buf,H.pending-rt,rt)),ct===0&&(H.gzindex=0,H.status=91)}else H.status=91;if(H.status===91)if(H.gzhead.comment){rt=H.pending;do{if(H.pending===H.pending_buf_size&&(H.gzhead.hcrc&&H.pending>rt&&(N.adler=f(N.adler,H.pending_buf,H.pending-rt,rt)),P(N),rt=H.pending,H.pending===H.pending_buf_size)){ct=1;break}ct=H.gzindexrt&&(N.adler=f(N.adler,H.pending_buf,H.pending-rt,rt)),ct===0&&(H.status=103)}else H.status=103;if(H.status===103&&(H.gzhead.hcrc?(H.pending+2>H.pending_buf_size&&P(N),H.pending+2<=H.pending_buf_size&&(B(H,255&N.adler),B(H,N.adler>>8&255),N.adler=0,H.status=w)):H.status=w),H.pending!==0){if(P(N),N.avail_out===0)return H.last_flush=-1,0}else if(N.avail_in===0&&g(Y)<=g(tt)&&Y!==4)return T(N,-5);if(H.status===666&&N.avail_in!==0)return T(N,-5);if(N.avail_in!==0||H.lookahead!==0||Y!==0&&H.status!==666){var ot=H.strategy===2?(function(ht,lt){for(var O;;){if(ht.lookahead===0&&(F(ht),ht.lookahead===0)){if(lt===0)return 1;break}if(ht.match_length=0,O=h._tr_tally(ht,0,ht.window[ht.strstart]),ht.lookahead--,ht.strstart++,O&&(_(ht,!1),ht.strm.avail_out===0))return 1}return ht.insert=0,lt===4?(_(ht,!0),ht.strm.avail_out===0?3:4):ht.last_lit&&(_(ht,!1),ht.strm.avail_out===0)?1:2})(H,Y):H.strategy===3?(function(ht,lt){for(var O,D,j,Q,J=ht.window;;){if(ht.lookahead<=S){if(F(ht),ht.lookahead<=S&<===0)return 1;if(ht.lookahead===0)break}if(ht.match_length=0,ht.lookahead>=3&&0ht.lookahead&&(ht.match_length=ht.lookahead)}if(ht.match_length>=3?(O=h._tr_tally(ht,1,ht.match_length-3),ht.lookahead-=ht.match_length,ht.strstart+=ht.match_length,ht.match_length=0):(O=h._tr_tally(ht,0,ht.window[ht.strstart]),ht.lookahead--,ht.strstart++),O&&(_(ht,!1),ht.strm.avail_out===0))return 1}return ht.insert=0,lt===4?(_(ht,!0),ht.strm.avail_out===0?3:4):ht.last_lit&&(_(ht,!1),ht.strm.avail_out===0)?1:2})(H,Y):o[H.level].func(H,Y);if(ot!==3&&ot!==4||(H.status=666),ot===1||ot===3)return N.avail_out===0&&(H.last_flush=-1),0;if(ot===2&&(Y===1?h._tr_align(H):Y!==5&&(h._tr_stored_block(H,0,0,!1),Y===3&&(x(H.head),H.lookahead===0&&(H.strstart=0,H.block_start=0,H.insert=0))),P(N),N.avail_out===0))return H.last_flush=-1,0}return Y!==4?0:H.wrap<=0?1:(H.wrap===2?(B(H,255&N.adler),B(H,N.adler>>8&255),B(H,N.adler>>16&255),B(H,N.adler>>24&255),B(H,255&N.total_in),B(H,N.total_in>>8&255),B(H,N.total_in>>16&255),B(H,N.total_in>>24&255)):(k(H,N.adler>>>16),k(H,65535&N.adler)),P(N),0=tt.w_size&&(ct===0&&(x(tt.head),tt.strstart=0,tt.block_start=0,tt.insert=0),lt=new s.Buf8(tt.w_size),s.arraySet(lt,Y,O-tt.w_size,tt.w_size,0),Y=lt,O=tt.w_size),st=N.avail_in,ot=N.next_in,ht=N.input,N.avail_in=O,N.next_in=0,N.input=Y,F(tt);tt.lookahead>=3;){for(H=tt.strstart,rt=tt.lookahead-2;tt.ins_h=(tt.ins_h<>>=G=A>>>24,_-=G,(G=A>>>16&255)==0)N[r++]=65535&A;else{if(!(16&G)){if(!(64&G)){A=B[(65535&A)+(P&(1<>>=G,_-=G),_<15&&(P+=$[u++]<<_,_+=8,P+=$[u++]<<_,_+=8),A=k[P&F];i:for(;;){if(P>>>=G=A>>>24,_-=G,!(16&(G=A>>>16&255))){if(!(64&G)){A=k[(65535&A)+(P&(1<>>=G,_-=G,(G=r-b)>3,P&=(1<<(_-=U<<3))-1,o.next_in=u,o.next_out=r,o.avail_in=u>>24&255)+(R>>>8&65280)+((65280&R)<<8)+((255&R)<<24)}function S(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new o.Buf16(320),this.work=new o.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function v(R){var F;return R&&R.state?(F=R.state,R.total_in=R.total_out=F.total=0,R.msg="",F.wrap&&(R.adler=1&F.wrap),F.mode=1,F.last=0,F.havedict=0,F.dmax=32768,F.head=null,F.hold=0,F.bits=0,F.lencode=F.lendyn=new o.Buf32(852),F.distcode=F.distdyn=new o.Buf32(592),F.sane=1,F.back=-1,0):r}function w(R){var F;return R&&R.state?((F=R.state).wsize=0,F.whave=0,F.wnext=0,v(R)):r}function T(R,F){var A,G;return R&&R.state?(G=R.state,F<0?(A=0,F=-F):(A=1+(F>>4),F<48&&(F&=15)),F&&(F<8||15=C.wsize?(o.arraySet(C.window,F,A-C.wsize,C.wsize,0),C.wnext=0,C.whave=C.wsize):(G<(U=C.wsize-C.wnext)&&(U=G),o.arraySet(C.window,F,A-G,U,C.wnext),(G-=U)?(o.arraySet(C.window,F,A-G,G,0),C.wnext=G,C.whave=C.wsize):(C.wnext+=U,C.wnext===C.wsize&&(C.wnext=0),C.whave>>8&255,A.check=h(A.check,dt,2,0),Y=N=0,A.mode=2;break}if(A.flags=0,A.head&&(A.head.done=!1),!(1&A.wrap)||(((255&N)<<8)+(N>>8))%31){R.msg="incorrect header check",A.mode=30;break}if((15&N)!=8){R.msg="unknown compression method",A.mode=30;break}if(Y-=4,Q=8+(15&(N>>>=4)),A.wbits===0)A.wbits=Q;else if(Q>A.wbits){R.msg="invalid window size",A.mode=30;break}A.dmax=1<>8&1),512&A.flags&&(dt[0]=255&N,dt[1]=N>>>8&255,A.check=h(A.check,dt,2,0)),Y=N=0,A.mode=3;case 3:for(;Y<32;){if(W===0)break t;W--,N+=G[C++]<>>8&255,dt[2]=N>>>16&255,dt[3]=N>>>24&255,A.check=h(A.check,dt,4,0)),Y=N=0,A.mode=4;case 4:for(;Y<16;){if(W===0)break t;W--,N+=G[C++]<>8),512&A.flags&&(dt[0]=255&N,dt[1]=N>>>8&255,A.check=h(A.check,dt,2,0)),Y=N=0,A.mode=5;case 5:if(1024&A.flags){for(;Y<16;){if(W===0)break t;W--,N+=G[C++]<>>8&255,A.check=h(A.check,dt,2,0)),Y=N=0}else A.head&&(A.head.extra=null);A.mode=6;case 6:if(1024&A.flags&&(W<(rt=A.length)&&(rt=W),rt&&(A.head&&(Q=A.head.extra_len-A.length,A.head.extra||(A.head.extra=new Array(A.head.extra_len)),o.arraySet(A.head.extra,G,C,rt,Q)),512&A.flags&&(A.check=h(A.check,G,rt,C)),W-=rt,C+=rt,A.length-=rt),A.length))break t;A.length=0,A.mode=7;case 7:if(2048&A.flags){if(W===0)break t;for(rt=0;Q=G[C+rt++],A.head&&Q&&A.length<65536&&(A.head.name+=String.fromCharCode(Q)),Q&&rt>9&1,A.head.done=!0),R.adler=A.check=0,A.mode=12;break;case 10:for(;Y<32;){if(W===0)break t;W--,N+=G[C++]<>>=7&Y,Y-=7&Y,A.mode=27;break}for(;Y<3;){if(W===0)break t;W--,N+=G[C++]<>>=1)){case 0:A.mode=14;break;case 1:if(B(A),A.mode=20,F!==6)break;N>>>=2,Y-=2;break t;case 2:A.mode=17;break;case 3:R.msg="invalid block type",A.mode=30}N>>>=2,Y-=2;break;case 14:for(N>>>=7&Y,Y-=7&Y;Y<32;){if(W===0)break t;W--,N+=G[C++]<>>16^65535)){R.msg="invalid stored block lengths",A.mode=30;break}if(A.length=65535&N,Y=N=0,A.mode=15,F===6)break t;case 15:A.mode=16;case 16:if(rt=A.length){if(W>>=5,Y-=5,A.ndist=1+(31&N),N>>>=5,Y-=5,A.ncode=4+(15&N),N>>>=4,Y-=4,286>>=3,Y-=3}for(;A.have<19;)A.lens[mt[A.have++]]=0;if(A.lencode=A.lendyn,A.lenbits=7,q={bits:A.lenbits},J=f(0,A.lens,0,19,A.lencode,0,A.work,q),A.lenbits=q.bits,J){R.msg="invalid code lengths set",A.mode=30;break}A.have=0,A.mode=19;case 19:for(;A.have>>16&255,lt=65535&it,!((ot=it>>>24)<=Y);){if(W===0)break t;W--,N+=G[C++]<>>=ot,Y-=ot,A.lens[A.have++]=lt;else{if(lt===16){for(et=ot+2;Y>>=ot,Y-=ot,A.have===0){R.msg="invalid bit length repeat",A.mode=30;break}Q=A.lens[A.have-1],rt=3+(3&N),N>>>=2,Y-=2}else if(lt===17){for(et=ot+3;Y>>=ot)),N>>>=3,Y-=3}else{for(et=ot+7;Y>>=ot)),N>>>=7,Y-=7}if(A.have+rt>A.nlen+A.ndist){R.msg="invalid bit length repeat",A.mode=30;break}for(;rt--;)A.lens[A.have++]=Q}}if(A.mode===30)break;if(A.lens[256]===0){R.msg="invalid code -- missing end-of-block",A.mode=30;break}if(A.lenbits=9,q={bits:A.lenbits},J=f(1,A.lens,0,A.nlen,A.lencode,0,A.work,q),A.lenbits=q.bits,J){R.msg="invalid literal/lengths set",A.mode=30;break}if(A.distbits=6,A.distcode=A.distdyn,q={bits:A.distbits},J=f(2,A.lens,A.nlen,A.ndist,A.distcode,0,A.work,q),A.distbits=q.bits,J){R.msg="invalid distances set",A.mode=30;break}if(A.mode=20,F===6)break t;case 20:A.mode=21;case 21:if(6<=W&&258<=$){R.next_out=z,R.avail_out=$,R.next_in=C,R.avail_in=W,A.hold=N,A.bits=Y,u(R,H),z=R.next_out,U=R.output,$=R.avail_out,C=R.next_in,G=R.input,W=R.avail_in,N=A.hold,Y=A.bits,A.mode===12&&(A.back=-1);break}for(A.back=0;ht=(it=A.lencode[N&(1<>>16&255,lt=65535&it,!((ot=it>>>24)<=Y);){if(W===0)break t;W--,N+=G[C++]<>O)])>>>16&255,lt=65535&it,!(O+(ot=it>>>24)<=Y);){if(W===0)break t;W--,N+=G[C++]<>>=O,Y-=O,A.back+=O}if(N>>>=ot,Y-=ot,A.back+=ot,A.length=lt,ht===0){A.mode=26;break}if(32&ht){A.back=-1,A.mode=12;break}if(64&ht){R.msg="invalid literal/length code",A.mode=30;break}A.extra=15&ht,A.mode=22;case 22:if(A.extra){for(et=A.extra;Y>>=A.extra,Y-=A.extra,A.back+=A.extra}A.was=A.length,A.mode=23;case 23:for(;ht=(it=A.distcode[N&(1<>>16&255,lt=65535&it,!((ot=it>>>24)<=Y);){if(W===0)break t;W--,N+=G[C++]<>O)])>>>16&255,lt=65535&it,!(O+(ot=it>>>24)<=Y);){if(W===0)break t;W--,N+=G[C++]<>>=O,Y-=O,A.back+=O}if(N>>>=ot,Y-=ot,A.back+=ot,64&ht){R.msg="invalid distance code",A.mode=30;break}A.offset=lt,A.extra=15&ht,A.mode=24;case 24:if(A.extra){for(et=A.extra;Y>>=A.extra,Y-=A.extra,A.back+=A.extra}if(A.offset>A.dmax){R.msg="invalid distance too far back",A.mode=30;break}A.mode=25;case 25:if($===0)break t;if(rt=H-$,A.offset>rt){if((rt=A.offset-rt)>A.whave&&A.sane){R.msg="invalid distance too far back",A.mode=30;break}ct=rt>A.wnext?(rt-=A.wnext,A.wsize-rt):A.wnext-rt,rt>A.length&&(rt=A.length),st=A.window}else st=U,ct=z-A.offset,rt=A.length;for($F?(G=D[j+g[W]],ot[ht+g[W]]):(G=96,0),P=1<>H)+(_-=P)]=A<<24|G<<16|U,_!==0;);for(P=1<>=1;if(P!==0?(st&=P-1,st+=P):st=0,W++,--lt[z]==0){if(z===N)break;z=b[S+g[W]]}if(Y>>7)]}function C(D,j){D.pending_buf[D.pending++]=255&j,D.pending_buf[D.pending++]=j>>>8&255}function z(D,j,Q){D.bi_valid>16-Q?(D.bi_buf|=j<>16-D.bi_valid,D.bi_valid+=Q-16):(D.bi_buf|=j<>>=1,Q<<=1,0<--j;);return Q>>>1}function N(D,j,Q){var J,q,et=new Array(16),it=0;for(J=1;J<=r;J++)et[J]=it=it+Q[J-1]<<1;for(q=0;q<=j;q++){var dt=D[2*q+1];dt!==0&&(D[2*q]=$(et[dt]++,dt))}}function Y(D){var j;for(j=0;j>1;1<=Q;Q--)rt(D,et,Q);for(q=mt;Q=D.heap[1],D.heap[1]=D.heap[D.heap_len--],rt(D,et,1),J=D.heap[1],D.heap[--D.heap_max]=Q,D.heap[--D.heap_max]=J,et[2*q]=et[2*Q]+et[2*J],D.depth[q]=(D.depth[Q]>=D.depth[J]?D.depth[Q]:D.depth[J])+1,et[2*Q+1]=et[2*J+1]=q,D.heap[1]=q++,rt(D,et,1),2<=D.heap_len;);D.heap[--D.heap_max]=D.heap[1],(function(Et,Dt){var Vt,Nt,It,Ct,zt,Xt,Ut=Dt.dyn_tree,Kt=Dt.max_code,qt=Dt.stat_desc.static_tree,Qt=Dt.stat_desc.has_stree,$t=Dt.stat_desc.extra_bits,ie=Dt.stat_desc.extra_base,Jt=Dt.stat_desc.max_length,oe=0;for(Ct=0;Ct<=r;Ct++)Et.bl_count[Ct]=0;for(Ut[2*Et.heap[Et.heap_max]+1]=0,Vt=Et.heap_max+1;Vt<573;Vt++)Jt<(Ct=Ut[2*Ut[2*(Nt=Et.heap[Vt])+1]+1]+1)&&(Ct=Jt,oe++),Ut[2*Nt+1]=Ct,Kt>=7;q>>=1)if(1&yt&&dt.dyn_ltree[2*mt]!==0)return 0;if(dt.dyn_ltree[18]!==0||dt.dyn_ltree[20]!==0||dt.dyn_ltree[26]!==0)return 1;for(mt=32;mt>>3,(et=D.static_len+3+7>>>3)<=q&&(q=et)):q=et=Q+5,Q+4<=q&&j!==-1?O(D,j,Q,J):D.strategy===4||et===q?(z(D,2+(J?1:0),3),ct(D,T,g)):(z(D,4+(J?1:0),3),(function(dt,mt,yt,Et){var Dt;for(z(dt,mt-257,5),z(dt,yt-1,5),z(dt,Et-4,4),Dt=0;Dt>>8&255,D.pending_buf[D.d_buf+2*D.last_lit+1]=255&j,D.pending_buf[D.l_buf+D.last_lit]=255&Q,D.last_lit++,j===0?D.dyn_ltree[2*Q]++:(D.matches++,j--,D.dyn_ltree[2*(P[Q]+h+1)]++,D.dyn_dtree[2*U(j)]++),D.last_lit===D.lit_bufsize-1},m._tr_align=function(D){z(D,2,3),W(D,256,T),(function(j){j.bi_valid===16?(C(j,j.bi_buf),j.bi_buf=0,j.bi_valid=0):8<=j.bi_valid&&(j.pending_buf[j.pending++]=255&j.bi_buf,j.bi_buf>>=8,j.bi_valid-=8)})(D)}},{"../utils/common":41}],53:[function(d,l,m){l.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(d,l,m){(function(o){(function(s){if(!s.setImmediate){var h,u,f,r,b=1,S={},v=!1,w=s.document,T=Object.getPrototypeOf&&Object.getPrototypeOf(s);T=T&&T.setTimeout?T:s,h={}.toString.call(s.process)==="[object process]"?function(_){process.nextTick(function(){x(_)})}:(function(){if(s.postMessage&&!s.importScripts){var _=!0,B=s.onmessage;return s.onmessage=function(){_=!1},s.postMessage("","*"),s.onmessage=B,_}})()?(r="setImmediate$"+Math.random()+"$",s.addEventListener?s.addEventListener("message",P,!1):s.attachEvent("onmessage",P),function(_){s.postMessage(r+_,"*")}):s.MessageChannel?((f=new MessageChannel).port1.onmessage=function(_){x(_.data)},function(_){f.port2.postMessage(_)}):w&&"onreadystatechange"in w.createElement("script")?(u=w.documentElement,function(_){var B=w.createElement("script");B.onreadystatechange=function(){x(_),B.onreadystatechange=null,u.removeChild(B),B=null},u.appendChild(B)}):function(_){setTimeout(x,0,_)},T.setImmediate=function(_){typeof _!="function"&&(_=new Function(""+_));for(var B=new Array(arguments.length-1),k=0;k"u"?o===void 0?this:o:self)}).call(this,p.g!==void 0?p.g:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)},3065(St,y,p){var d,l;(function(){d=function(){var m=function(){},o="undefined",s=typeof window!==o&&typeof window.navigator!==o&&/Trident\/|MSIE /.test(window.navigator.userAgent),h=["trace","debug","info","warn","error"],u={},f=null;function r(x,P){var _=x[P];if(typeof _.bind=="function")return _.bind(x);try{return Function.prototype.bind.call(_,x)}catch{return function(){return Function.prototype.apply.apply(_,[x,arguments])}}}function b(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function S(){for(var x=this.getLevel(),P=0;P=0&&z<=R.levels.SILENT)return z;throw new TypeError("log.setLevel() called with invalid level: "+C)}typeof x=="string"?F+=":"+x:typeof x=="symbol"&&(F=void 0),R.name=x,R.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},R.methodFactory=P||w,R.getLevel=function(){return k??B??_},R.setLevel=function(C,z){return k=G(C),z!==!1&&(function(W){var $=(h[W]||"silent").toUpperCase();if(typeof window!==o&&F){try{return void(window.localStorage[F]=$)}catch{}try{window.document.cookie=encodeURIComponent(F)+"="+$+";"}catch{}}})(k),S.call(R)},R.setDefaultLevel=function(C){B=G(C),A()||R.setLevel(C,!1)},R.resetLevel=function(){k=null,(function(){if(typeof window!==o&&F){try{window.localStorage.removeItem(F)}catch{}try{window.document.cookie=encodeURIComponent(F)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}})(),S.call(R)},R.enableAll=function(C){R.setLevel(R.levels.TRACE,C)},R.disableAll=function(C){R.setLevel(R.levels.SILENT,C)},R.rebuild=function(){if(f!==R&&(_=G(f.getLevel())),S.call(R),f===R)for(var C in u)u[C].rebuild()},_=G(f?f.getLevel():"WARN");var U=A();U!=null&&(k=G(U)),S.call(R)}(f=new T).getLogger=function(x){if(typeof x!="symbol"&&typeof x!="string"||x==="")throw new TypeError("You must supply a name when creating a logger.");var P=u[x];return P||(P=u[x]=new T(x,f.methodFactory)),P};var g=typeof window!==o?window.log:void 0;return f.noConflict=function(){return typeof window!==o&&window.log===f&&(window.log=g),f},f.getLoggers=function(){return u},f.default=f,f},(l=d.call(y,p,y,St))===void 0||(St.exports=l)})()},2561(St,y){Object.defineProperty(y,"__esModule",{value:!0}),y.Fraction=void 0;class p{static max(l,m){return l.RealValue>m.RealValue?l:m}static Equal(l,m){return l.wholeValue===m.wholeValue&&l.Denominator===m.Denominator&&l.Numerator===m.Numerator}static createFromFraction(l){return new p(l.numerator,l.denominator,l.wholeValue,!1)}static plus(l,m){const o=l.clone();return o.Add(m),o}static minus(l,m){const o=l.clone();return o.Sub(m),o}static multiply(l,m){return new p((l.wholeValue*l.denominator+l.numerator)*(m.wholeValue*m.denominator+m.numerator),l.denominator*m.denominator)}static greatestCommonDenominator(l,m){if(l===0)return m;if(m===1)return 1;for(;Math.abs(m)>=1&&Math.abs(l)>=1;)l>m?l-=m:m-=l;const o=Math.round(l);return Math.max(o,1)}constructor(l=0,m=1,o=0,s=!0){this.numerator=0,this.denominator=1,this.wholeValue=0,this.numerator=l,this.denominator=m,this.wholeValue=o,s&&this.simplify(),this.setRealValue()}toString(){let l=this.numerator+"/"+this.denominator;return this.wholeValue!==0&&(l=this.wholeValue+" "+l),l}clone(){return new p(this.numerator,this.denominator,this.wholeValue,!1)}get Numerator(){return this.numerator}set Numerator(l){this.numerator!==l&&(this.numerator=l,this.simplify(),this.setRealValue())}get Denominator(){return this.denominator}set Denominator(l){this.denominator!==l&&(this.denominator=l,this.numerator!==0&&this.simplify(),this.setRealValue())}get WholeValue(){return this.wholeValue}set WholeValue(l){this.wholeValue!==l&&(this.wholeValue=l,this.setRealValue())}GetExpandedNumerator(){return this.wholeValue*this.denominator+this.numerator}calculateNumberOfNeededDots(){let l=1,m=2;const o=this.GetExpandedNumerator();for(;ml;)m.Numerator++;if(this.numerator>this.denominator){const o=new p(this.numerator-1,this.denominator,this.wholeValue);for(;o.Denominator>l;)o.Numerator--;if(o.Denominatorp.maximumAllowedNumber){const o=this.denominator/p.maximumAllowedNumber;this.numerator=Math.round(this.numerator/o),this.denominator=Math.round(this.denominator/o)}if(this.numerator>p.maximumAllowedNumber){const o=this.numerator/p.maximumAllowedNumber;this.numerator=Math.round(this.numerator/o),this.denominator=Math.round(this.denominator/o)}}isOnBeat(l){const m=this.distanceFromBeat(l);return Math.abs(m)h.length-1&&(f=1),r<0&&(r=h.length+r,f=-1),[h[r],f]}static CalculateTransposedHalfTone(o,s){const h=o.fundamentalNote+o.AccidentalHalfTones+s;return l.WrapAroundCheck(h,12)}static WrapAroundCheck(o,s){let h=0;for(;o<0;)o+=s,h--;for(;o>=s;)o-=s,h++;return{overflow:h,halftone:o}}static calcFrequency(o){let s,h=0;if(o instanceof l){const u=o;h=u.octave-1,s=u.fundamentalNote-p.A+u.AccidentalHalfTones}else typeof o=="number"&&(s=o-57);return 440*Math.pow(2,h)*Math.pow(2,s/12)}static calcFractionalKey(o){return Math.log(o/440)/Math.LN10*l.halftoneFactor+57}static fromFrequency(o){const s=l.calcFractionalKey(o)+.5,h=Math.floor(s/12)-l.octXmlDiff,u=Math.floor(s)%12;let f=u,r=d.NONE;return this.pitchEnumValues.indexOf(f)===-1&&(f=u-1,r=d.SHARP),new l(f,h,r)}static fromHalftone(o){const s=Math.floor(o/12)-l.octXmlDiff,h=o%12;let u=h,f=d.NONE;return this.pitchEnumValues.indexOf(u)===-1&&(u=h-1,f=d.SHARP),new l(u,s,f)}static ceiling(o){let s=o%=12;return this.pitchEnumValues.indexOf(s)===-1&&(s=o+1),s}static floor(o){let s=o%=12;return this.pitchEnumValues.indexOf(s)===-1&&(s=o-1),s}constructor(o,s,h,u=void 0,f=!1,r=void 0){this.accidental=d.NONE,this.fundamentalNote=o,this.octave=s,this.accidental=h,this.accidentalXml=u,this.halfTone=o+12*(s+l.octXmlDiff)+l.HalfTonesFromAccidental(h),f||(this.frequency=l.calcFrequency(this)),this.OctaveShiftApplied=r}static HalfTonesFromAccidental(o){switch(o){case d.NONE:return 0;case d.SHARP:return 1;case d.FLAT:return-1;case d.NATURAL:return 0;case d.DOUBLESHARP:return 2;case d.DOUBLEFLAT:return-2;case d.TRIPLESHARP:return 3;case d.TRIPLEFLAT:return-3;case d.QUARTERTONESHARP:return .5;case d.QUARTERTONEFLAT:return-.5;case d.SLASHFLAT:return-.51;case d.THREEQUARTERSSHARP:return 1.5;case d.THREEQUARTERSFLAT:return-1.5;case d.SLASHQUARTERSHARP:return .0013;case d.SLASHSHARP:return .0014;case d.DOUBLESLASHFLAT:return-.0015;case d.SORI:return .0016;case d.KORON:return .0017;default:throw new Error("Unhandled AccidentalEnum value")}}static AccidentalFromHalfTones(o){switch(o){case 0:return d.NONE;case 1:return d.SHARP;case-1:return d.FLAT;case 2:return d.DOUBLESHARP;case-2:return d.DOUBLEFLAT;case 3:return d.TRIPLESHARP;case-3:return d.TRIPLEFLAT;case .5:return d.QUARTERTONESHARP;case-.5:return d.QUARTERTONEFLAT;case 1.5:return d.THREEQUARTERSSHARP;case-1.5:return d.THREEQUARTERSFLAT;default:return o>0&&o<1?d.QUARTERTONESHARP:o<0&&o>-1?d.QUARTERTONEFLAT:d.QUARTERTONESHARP}}static accidentalVexflow(o){let s;switch(o){case d.NATURAL:s="n";break;case d.FLAT:s="b";break;case d.SHARP:s="#";break;case d.DOUBLESHARP:s="##";break;case d.TRIPLESHARP:s="###";break;case d.DOUBLEFLAT:s="bb";break;case d.TRIPLEFLAT:s="bbs";break;case d.QUARTERTONESHARP:s="+";break;case d.QUARTERTONEFLAT:s="d";break;case d.SLASHFLAT:s="bs";break;case d.THREEQUARTERSSHARP:s="++";break;case d.THREEQUARTERSFLAT:s="db";break;case d.SLASHQUARTERSHARP:s="+-";break;case d.SLASHSHARP:s="++-";break;case d.DOUBLESLASHFLAT:s="bss";break;case d.SORI:s="o";break;case d.KORON:s="k"}return s}get AccidentalHalfTones(){return l.HalfTonesFromAccidental(this.accidental)}get Octave(){return this.octave}get FundamentalNote(){return this.fundamentalNote}get Accidental(){return this.accidental}get AccidentalXml(){return this.accidentalXml}get Frequency(){return this.frequency}static get OctaveXmlDifference(){return l.octXmlDiff}getHalfTone(){return this.halfTone}getTransposedPitch(o){if(o>12)throw new Error("rewrite this method to handle bigger octave changes or don't use is with bigger octave changes!");return o>0?this.getHigherPitchByTransposeFactor(o):o<0?this.getLowerPitchByTransposeFactor(-o):this}DoEnharmonicChange(){switch(this.accidental){case d.FLAT:case d.DOUBLEFLAT:this.fundamentalNote=this.getPreviousFundamentalNote(this.fundamentalNote),this.accidental=l.AccidentalFromHalfTones(this.halfTone-(this.fundamentalNote+12*(this.octave+l.octXmlDiff)));break;case d.SHARP:case d.DOUBLESHARP:this.fundamentalNote=this.getNextFundamentalNote(this.fundamentalNote),this.accidental=l.AccidentalFromHalfTones(this.halfTone-(this.fundamentalNote+12*(this.octave+l.octXmlDiff)));break;default:return}}ToString(){let o=l.accidentalVexflow(this.accidental);return o||(o=""),"Key: "+l.getNoteEnumString(this.fundamentalNote)+o+", Note: "+this.fundamentalNote+", octave: "+this.octave.toString()}ToStringShort(o=0){let s=l.accidentalVexflow(this.accidental);s||(s="");const h=this.octave+o;return l.getNoteEnumString(this.fundamentalNote)+s+h}get ToStringShortGet(){return this.ToStringShort(0)}OperatorEquals(o){const s=this;return!(!s||!o)&&s.FundamentalNote===o.FundamentalNote&&s.Octave===o.Octave&&s.Accidental===o.Accidental}OperatorNotEqual(o){return this!==o}OperatorFundamentalGreaterThan(o){const s=this;return s.Octave===o.Octave?s.FundamentalNote>o.FundamentalNote:s.Octave>o.Octave}OperatorFundamentalLessThan(o){const s=this;return s.Octave===o.Octave?s.FundamentalNotel.pitchEnumValues.length-1?(h=l.pitchEnumValues[s+o-l.pitchEnumValues.length],u++):h=l.pitchEnumValues[s+o],new l(h,u,d.NONE)}getLowerPitchByTransposeFactor(o){const s=l.pitchEnumValues.indexOf(this.fundamentalNote);let h,u=this.octave;return s-o<0?(h=l.pitchEnumValues[l.pitchEnumValues.length+s-o],u--):h=l.pitchEnumValues[s-o],new l(h,u,d.NONE)}getNextFundamentalNote(o){let s=l.pitchEnumValues.indexOf(o);return s=(s+1)%l.pitchEnumValues.length,l.pitchEnumValues[s]}getPreviousFundamentalNote(o){const s=l.pitchEnumValues.indexOf(o);return s>0?l.pitchEnumValues[s-1]:l.pitchEnumValues[l.pitchEnumValues.length-1]}}y.Pitch=l,l.pitchEnumValues=[p.C,p.D,p.E,p.F,p.G,p.A,p.B],l.halftoneFactor=12/(Math.LN2/Math.LN10),l.octXmlDiff=3},283(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.PlaybackSettings=void 0;const d=p(2561);class l{constructor(o=new d.Fraction,s=100){this.rhythm=o,this.beatsPerMinute=s,this.beatLengthInMilliseconds=6e4/s,this.beatRealValue=.25}static createFrom(o){return new l(o.Rhythm,o.BeatsPerMinute)}get BeatsPerMinute(){return this.beatsPerMinute}set BeatsPerMinute(o){this.beatsPerMinute=o,this.beatLengthInMilliseconds=6e4/this.beatsPerMinute}get Rhythm(){return this.rhythm}set Rhythm(o){this.rhythm=o}get BeatRealValue(){return this.beatRealValue}get BeatLengthInMilliseconds(){return this.beatLengthInMilliseconds}getDurationInMilliseconds(o){return(typeof o=="number"?o:o.RealValue)*this.BeatLengthInMilliseconds/this.beatRealValue}getDurationAsNoteDuration(o,s=1024){const h=o/this.BeatLengthInMilliseconds;let u=Math.floor(h);const f=new d.Fraction(u,4),r=h-u;return u=Math.round(r/(1/s)/4),r!==0&&u===0&&o>0&&(u=1),f.Add(new d.Fraction(u,s)),f}}y.PlaybackSettings=l},9409(St,y){Object.defineProperty(y,"__esModule",{value:!0}),y.PointF2D=void 0;class p{constructor(l=0,m=0){this.x=0,this.y=0,this.x=l,this.y=m}static get Empty(){return new p}static pointsAreEqual(l,m){return l.x===m.x&&l.y===m.y}ToString(){return"["+this.x+", "+this.y+"]"}}y.PointF2D=p},200(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.RectangleF2D=void 0;const d=p(6864),l=p(9409);class m{constructor(s,h,u,f){this.x=0,this.y=0,this.width=0,this.height=0,this.x=s,this.y=h,this.width=u,this.height=f}static createFromLocationAndSize(s,h){return new m(s.x,s.y,h.width,h.height)}get Location(){return new l.PointF2D(this.x,this.y)}get Size(){return new d.SizeF2D(this.width,this.height)}}y.RectangleF2D=m},6864(St,y){Object.defineProperty(y,"__esModule",{value:!0}),y.SizeF2D=void 0,y.SizeF2D=class{constructor(p=0,d=0){this.width=p,this.height=d}}},9735(St,y,p){var d=this&&this.__createBinding||(Object.create?function(m,o,s,h){h===void 0&&(h=s);var u=Object.getOwnPropertyDescriptor(o,s);u&&!("get"in u?!o.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return o[s]}}),Object.defineProperty(m,h,u)}:function(m,o,s,h){h===void 0&&(h=s),m[h]=o[s]}),l=this&&this.__exportStar||function(m,o){for(var s in m)s==="default"||Object.prototype.hasOwnProperty.call(o,s)||d(o,m,s)};Object.defineProperty(y,"__esModule",{value:!0}),l(p(2561),y),l(p(6904),y),l(p(8786),y),l(p(8705),y),l(p(8233),y),l(p(9409),y),l(p(200),y),l(p(6864),y)},4434(St,y){var p;Object.defineProperty(y,"__esModule",{value:!0}),y.ColoringModes=void 0,(function(d){d[d.XML=0]="XML",d[d.AutoColoring=1]="AutoColoring",d[d.CustomColorSet=2]="CustomColorSet"})(p||(y.ColoringModes=p={}))},4146(St,y){var p;Object.defineProperty(y,"__esModule",{value:!0}),y.DrawingParametersEnum=void 0,(function(d){d.allon="allon",d.compact="compact",d.compacttight="compacttight",d.default="default",d.leadsheet="leadsheet",d.preview="preview",d.thumbnail="thumbnail"})(p||(y.DrawingParametersEnum=p={}))},2570(St,y){var p;Object.defineProperty(y,"__esModule",{value:!0}),y.FontStyles=void 0,(function(d){d[d.Regular=0]="Regular",d[d.Bold=1]="Bold",d[d.Italic=2]="Italic",d[d.BoldItalic=3]="BoldItalic",d[d.Underlined=4]="Underlined"})(p||(y.FontStyles=p={}))},5951(St,y){var p;Object.defineProperty(y,"__esModule",{value:!0}),y.Fonts=void 0,(function(d){d[d.TimesNewRoman=0]="TimesNewRoman",d[d.Kokila=1]="Kokila"})(p||(y.Fonts=p={}))},7533(St,y){var p;Object.defineProperty(y,"__esModule",{value:!0}),y.TextAlignment=y.TextAlignmentEnum=void 0,(function(d){d[d.LeftTop=0]="LeftTop",d[d.LeftCenter=1]="LeftCenter",d[d.LeftBottom=2]="LeftBottom",d[d.CenterTop=3]="CenterTop",d[d.CenterCenter=4]="CenterCenter",d[d.CenterBottom=5]="CenterBottom",d[d.RightTop=6]="RightTop",d[d.RightCenter=7]="RightCenter",d[d.RightBottom=8]="RightBottom"})(p||(y.TextAlignmentEnum=p={})),y.TextAlignment=class{static IsLeft(d){return d===p.LeftTop||d===p.LeftCenter||d===p.LeftBottom}static IsCenterAligned(d){return d===p.CenterTop||d===p.CenterCenter||d===p.CenterBottom}static IsRight(d){return d===p.RightTop||d===p.RightCenter||d===p.RightBottom}}},2514(St,y){var p;Object.defineProperty(y,"__esModule",{value:!0}),y.TieTypes=void 0,(function(d){d.SIMPLE="",d.HAMMERON="H",d.PULLOFF="P",d.SLIDE="S",d.TAPPING="T"})(p||(y.TieTypes=p={}))},2257(St,y,p){var d=this&&this.__createBinding||(Object.create?function(m,o,s,h){h===void 0&&(h=s);var u=Object.getOwnPropertyDescriptor(o,s);u&&!("get"in u?!o.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return o[s]}}),Object.defineProperty(m,h,u)}:function(m,o,s,h){h===void 0&&(h=s),m[h]=o[s]}),l=this&&this.__exportStar||function(m,o){for(var s in m)s==="default"||Object.prototype.hasOwnProperty.call(o,s)||d(o,m,s)};Object.defineProperty(y,"__esModule",{value:!0}),l(p(4434),y),l(p(4146),y),l(p(2570),y),l(p(5951),y),l(p(7533),y),l(p(2514),y)},6888(St,y,p){var d=this&&this.__importDefault||function(h){return h&&h.__esModule?h:{default:h}};Object.defineProperty(y,"__esModule",{value:!0}),y.MXLHelper=y.MXLFile=void 0;const l=p(3902),m=d(p(1710)),o=d(p(3065));y.MXLFile=class{constructor(h){this.unzipSuccessful=!1,this.blob=h}async tryUnzip(){this.zipFile=new m.default;try{return this.unzipSuccessful=!0,await this.zipFile.loadAsync(this.blob),!0}catch{return this.unzipSuccessful=!1,!1}}getXmlString(){return s.jszipToXMLstring(this.zipFile)}};class s{static MXLtoIXmlElement(u){return this.MXLtoXMLstring(u).then(f=>{const r=new DOMParser().parseFromString(f,"text/xml"),b=new l.IXmlElement(r.documentElement);return Promise.resolve(b)},f=>{throw new Error("extractSheetFromMxl: "+f.message)})}static async jszipToXMLstring(u){let f=await u.file("META-INF/container.xml").async("text");if(!f.startsWith("<")){const S=await u.file("META-INF/container.xml").async("uint8array");f=new TextDecoder("utf-8").decode(S)}if(!f.startsWith("<")){const S=await u.file("META-INF/container.xml").async("uint8array");f=new TextDecoder("utf-16").decode(S)}const r=new DOMParser().parseFromString(f,"text/xml").getElementsByTagName("rootfile")[0].getAttribute("full-path"),b=await u.file(r).async("text");if(!b.substring(0,1).startsWith("<")){const S=await u.file(r).async("uint8array");return new TextDecoder("utf-16").decode(S)}return b}static MXLtoXMLstring(u){const f=new m.default;return f.loadAsync(u).then(async r=>this.jszipToXMLstring(f),r=>{throw o.default.error(r),r})}}y.MXLHelper=s},3902(St,y){Object.defineProperty(y,"__esModule",{value:!0}),y.IXmlElement=void 0;class p{constructor(l){if(this.hasAttributes=!1,!l)throw new Error("IXmlElement: expected Element, got undefined");this.elem=l,this.name=l.nodeName.toLowerCase(),l.hasAttributes()&&(this.hasAttributes=!0,this.firstAttribute=l.attributes[0]),this.hasElements=l.hasChildNodes(),l.childNodes.length===1&&l.childNodes[0].nodeType===Node.TEXT_NODE?this.value=l.childNodes[0].nodeValue:this.value=""}attribute(l){return this.elem.attributes.getNamedItem(l)}attributes(){if(!this.attrs){const l=this.elem.attributes,m=[];for(let o=0;o0){let o;for(let s=0,h=m.length;s=0;if(this.currentInMeasureNoteAlterationsDict.containsKey(u))if(r&&this.currentAlterationsComparedToKeyInstructionList.splice(this.currentAlterationsComparedToKeyInstructionList.indexOf(u),1),this.currentInMeasureNoteAlterationsDict.getValue(u)!==h.AccidentalHalfTones){this.keySignatureNoteAlterationsDict.containsKey(u)&&this.keySignatureNoteAlterationsDict.getValue(u)!==h.AccidentalHalfTones?(this.currentAlterationsComparedToKeyInstructionList.push(u),this.currentInMeasureNoteAlterationsDict.setValue(u,h.AccidentalHalfTones)):h.Accidental!==d.AccidentalEnum.NONE?this.keySignatureNoteAlterationsDict.containsKey(u)?this.currentInMeasureNoteAlterationsDict.setValue(u,this.keySignatureNoteAlterationsDict.getValue(u)):this.currentInMeasureNoteAlterationsDict.remove(u):this.currentInMeasureNoteAlterationsDict.setValue(u,h.AccidentalHalfTones);const b=this.currentInMeasureNoteAlterationsDict.getValue(u);if(h.Accidental===d.AccidentalEnum.NONE&&(h=Math.abs(b)===.5?new l.Pitch(h.FundamentalNote,h.Octave,d.AccidentalEnum.NONE,void 0,!1,h.OctaveShiftApplied):new l.Pitch(h.FundamentalNote,h.Octave,d.AccidentalEnum.NATURAL,void 0,!1,h.OctaveShiftApplied)),this.isAlterAmbiguousAccidental(h.Accidental)&&!h.AccidentalXml)return;o.MusicSheetCalculator.symbolFactory.addGraphicalAccidental(s,h)}else h.AccidentalXml&&this.Transpose===0&&!r&&o.MusicSheetCalculator.symbolFactory.addGraphicalAccidental(s,h);else if(h.Accidental!==d.AccidentalEnum.NONE){if(r||this.currentAlterationsComparedToKeyInstructionList.push(u),this.currentInMeasureNoteAlterationsDict.setValue(u,h.AccidentalHalfTones),this.isAlterAmbiguousAccidental(h.Accidental)&&!h.AccidentalXml)return;o.MusicSheetCalculator.symbolFactory.addGraphicalAccidental(s,h)}else r&&(h=new l.Pitch(h.FundamentalNote,h.Octave,d.AccidentalEnum.NATURAL,void 0,!1,h.OctaveShiftApplied),this.currentAlterationsComparedToKeyInstructionList.splice(this.currentAlterationsComparedToKeyInstructionList.indexOf(u),1),o.MusicSheetCalculator.symbolFactory.addGraphicalAccidental(s,h))}isAlterAmbiguousAccidental(s){return s===d.AccidentalEnum.SLASHFLAT||s===d.AccidentalEnum.QUARTERTONEFLAT}reactOnKeyInstructionChange(){const s=this.activeKeyInstruction.AlteratedNotes;let h;h=this.activeKeyInstruction.Key>0?d.AccidentalEnum.SHARP:d.AccidentalEnum.FLAT,this.keySignatureNoteAlterationsDict.clear(),this.currentAlterationsComparedToKeyInstructionList.length=0;for(let u=-9;u<9;u++)for(let f=0;fthis.borderLeft?this.borderLeft:this.borderMarginLeft}set BorderMarginLeft(r){this.borderMarginLeft=r,this.calculateMarginRectangle()}get BorderMarginRight(){return this.borderMarginRightthis.borderTop?this.borderTop:this.borderMarginTop}set BorderMarginTop(r){this.borderMarginTop=r,this.calculateMarginRectangle()}get BorderMarginBottom(){return this.borderMarginBottom-1&&this.parent.ChildElements.splice(b,1)}this.parent=r,this.parent.ChildElements.indexOf(this)>-1?l.default.error("BoundingBox of "+this.dataObject.constructor.name+" already in children list of "+this.parent.dataObject.constructor.name+"'s BoundingBox"):this.parent.ChildElements.push(this)}get DataObject(){return this.dataObject}get Center(){return new o.PointF2D(this.RelativePosition.x+(this.BorderMarginRight+this.BorderMarginLeft),this.RelativePosition.y+(this.BorderMarginBottom+this.BorderMarginTop))}setAbsolutePositionFromParent(){this.parent?(this.absolutePosition.x=this.parent.AbsolutePosition.x+this.relativePosition.x,this.absolutePosition.y=this.parent.AbsolutePosition.y+this.relativePosition.y):this.absolutePosition=this.relativePosition}calculateAbsolutePosition(){this.absolutePosition.x=this.relativePosition.x,this.absolutePosition.y=this.relativePosition.y;let r=this.parent;for(;r;)this.absolutePosition.x+=r.relativePosition.x,this.absolutePosition.y+=r.relativePosition.y,r=r.parent}calculateAbsolutePositionsRecursiveWithoutTopelement(){this.absolutePosition.x=0,this.absolutePosition.y=0;for(let r=0,b=this.ChildElements.length;r.001;break;case f.Up:case f.Down:v=this.relativePosition.y,r.calculateMarginPositionAlongDirection(this,b),w=Math.abs(v-this.relativePosition.y)>.001;break;default:throw new m.ArgumentOutOfRangeException("direction")}while(w)}collisionDetection(r){const b=Math.min(this.AbsolutePosition.x+this.borderRight,r.absolutePosition.x+r.borderRight)-Math.max(this.AbsolutePosition.x+this.borderLeft,r.absolutePosition.x+r.borderLeft),S=Math.min(this.AbsolutePosition.y+this.borderBottom,r.absolutePosition.y+r.borderBottom)-Math.max(this.AbsolutePosition.y+this.borderTop,r.absolutePosition.y+r.borderTop);return b>=0&&S>=0}liesInsideBorders(r){const b=this.AbsolutePosition.x+this.borderLeft<=r.absolutePosition.x+r.borderLeft&&r.absolutePosition.x+r.borderLeft<=this.AbsolutePosition.x+this.borderRight,S=this.AbsolutePosition.x+this.borderLeft<=r.absolutePosition.x+r.borderRight&&r.absolutePosition.x+r.borderRight<=this.AbsolutePosition.x+this.borderRight;if(b&&S){const v=this.AbsolutePosition.y+this.borderTop<=r.absolutePosition.y+r.borderTop&&r.absolutePosition.y+r.borderTop<=this.AbsolutePosition.y+this.borderBottom,w=this.AbsolutePosition.y+this.borderTop<=r.absolutePosition.y+r.borderBottom&&r.absolutePosition.y+r.borderBottom<=this.AbsolutePosition.y+this.borderBottom;if(v&&w)return!0}return!1}pointLiesInsideBorders(r){return this.AbsolutePosition.x+this.borderLeft<=r.x&&r.x<=this.AbsolutePosition.x+this.borderRight&&this.AbsolutePosition.y+this.borderTop<=r.y&&r.y<=this.AbsolutePosition.y+this.borderBottom}marginCollisionDetection(r){const b=Math.min(this.AbsolutePosition.x+this.borderMarginRight,r.absolutePosition.x+r.borderMarginRight)-Math.max(this.AbsolutePosition.x+this.borderMarginLeft,r.absolutePosition.x+r.borderMarginLeft),S=Math.min(this.AbsolutePosition.y+this.borderMarginBottom,r.absolutePosition.y+r.borderMarginBottom)-Math.max(this.AbsolutePosition.y+this.borderMarginTop,r.absolutePosition.y+r.borderMarginTop);return b>0&&S>0}liesInsideMargins(r){const b=this.AbsolutePosition.x+this.borderMarginLeft<=r.absolutePosition.x+r.borderMarginLeft&&r.absolutePosition.x+r.borderMarginLeft<=this.AbsolutePosition.x+this.borderMarginRight,S=this.AbsolutePosition.x+this.borderMarginLeft<=r.absolutePosition.x+r.borderMarginRight&&r.absolutePosition.x+r.borderMarginRight<=this.AbsolutePosition.x+this.borderMarginRight;if(b&&S){const v=this.AbsolutePosition.y+this.borderMarginTop<=r.absolutePosition.y+r.borderMarginTop&&r.absolutePosition.y+r.borderMarginTop<=this.AbsolutePosition.y+this.borderMarginBottom,w=this.AbsolutePosition.y+this.borderMarginTop<=r.absolutePosition.y+r.borderMarginBottom&&r.absolutePosition.y+r.borderMarginBottom<=this.AbsolutePosition.y+this.borderMarginBottom;if(v&&w)return!0}return!1}pointLiesInsideMargins(r){return this.AbsolutePosition.x+this.borderMarginLeft<=r.x&&r.x<=this.AbsolutePosition.x+this.borderMarginRight&&this.AbsolutePosition.y+this.borderMarginTop<=r.y&&r.y<=this.AbsolutePosition.y+this.borderMarginBottom}computeNonOverlappingPosition(r,b,S){this.RelativePosition=new o.PointF2D(S.x,S.y),this.setAbsolutePositionFromParent();let v=0,w=!1;do switch(b){case f.Left:case f.Right:v=this.relativePosition.x,r.calculatePositionAlongDirection(this,b),w=Math.abs(v-this.relativePosition.x)>1e-4;break;case f.Up:case f.Down:v=this.relativePosition.y,r.calculatePositionAlongDirection(this,b),w=Math.abs(v-this.relativePosition.y)>1e-4;break;default:throw new m.ArgumentOutOfRangeException("direction")}while(w)}getClickedObjectOfType(r){const b=this.dataObject;if(this.pointLiesInsideBorders(r)&&b)return b;for(let S=0,v=this.childElements.length;S=this.SkyBottomLineWebGLMinMeasures&&(this.PreferredSkyBottomLineBatchCalculatorBackend=h.SkyBottomLineBatchCalculatorBackendType.WebGL)}applyDefaultColorMusic(x){this.DefaultColorMusic=x,this.DefaultColorNotehead=x,this.DefaultColorRest=x,this.DefaultColorStem=x,this.DefaultColorLabel=x,this.DefaultColorLyrics=x,this.DefaultColorTitle=x,this.LedgerLineColorDefault=x}addGraphicalNoteToNoteMap(x,P){x.NoteToGraphicalNoteObjectId=this.NoteToGraphicalNoteMapObjectCount,this.NoteToGraphicalNoteMap.setValue(x.NoteToGraphicalNoteObjectId,P),this.NoteToGraphicalNoteMapObjectCount++}GNote(x){return v.GraphicalNote.FromNote(x,this)}clearMusicSheetObjects(){this.NoteToGraphicalNoteMap=new f.Dictionary,this.NoteToGraphicalNoteMapObjectCount=0}resetChordAccidentalTexts(x,P){x.setValue(b.AccidentalEnum.SHARP,P?"♯":"#"),x.setValue(b.AccidentalEnum.FLAT,P?"♭":"b"),x.setValue(b.AccidentalEnum.DOUBLEFLAT,P?"𝄫":"bb"),x.setValue(b.AccidentalEnum.DOUBLESHARP,P?"𝄪":"x")}setChordSymbolLabelText(x,P){this.ChordSymbolLabelTexts.setValue(x,P)}resetChordSymbolLabelTexts(x){return x.setValue(S.ChordSymbolEnum.minor,"m"),x.setValue(S.ChordSymbolEnum.augmented,"aug"),x.setValue(S.ChordSymbolEnum.diminished,"dim"),x.setValue(S.ChordSymbolEnum.dominant,"7"),x.setValue(S.ChordSymbolEnum.majorseventh,"maj7"),x.setValue(S.ChordSymbolEnum.minorseventh,"m7"),x.setValue(S.ChordSymbolEnum.diminishedseventh,"dim7"),x.setValue(S.ChordSymbolEnum.augmentedseventh,"aug7"),x.setValue(S.ChordSymbolEnum.halfdiminished,`m7${this.ChordAccidentalTexts.getValue(b.AccidentalEnum.FLAT)}5`),x.setValue(S.ChordSymbolEnum.majorminor,"m(maj7)"),x.setValue(S.ChordSymbolEnum.majorsixth,"maj6"),x.setValue(S.ChordSymbolEnum.minorsixth,"m6"),x.setValue(S.ChordSymbolEnum.dominantninth,"9"),x.setValue(S.ChordSymbolEnum.majorninth,"maj9"),x.setValue(S.ChordSymbolEnum.minorninth,"m9"),x.setValue(S.ChordSymbolEnum.dominant11th,"11"),x.setValue(S.ChordSymbolEnum.major11th,"maj11"),x.setValue(S.ChordSymbolEnum.minor11th,"m11"),x.setValue(S.ChordSymbolEnum.dominant13th,"13"),x.setValue(S.ChordSymbolEnum.major13th,"maj13"),x.setValue(S.ChordSymbolEnum.minor13th,"m13"),x.setValue(S.ChordSymbolEnum.suspendedsecond,"sus2"),x.setValue(S.ChordSymbolEnum.suspendedfourth,"sus4"),x.setValue(S.ChordSymbolEnum.power,"5"),x.setValue(S.ChordSymbolEnum.none,"N.C."),x}addChordName(x,P,_,B,k){if(S.ChordSymbolEnum[P]!==void 0){const R={adds:_,alts:B,subs:k};this.CustomChords.push(S.CustomChord.createCustomChord(x,S.ChordSymbolEnum[P],R))}}renameChord(x,P){S.CustomChord.renameCustomChord(x,P,this.CustomChords)}resetChordNames(){const x=this.ChordAccidentalTexts.getValue(b.AccidentalEnum.SHARP),P=this.ChordAccidentalTexts.getValue(b.AccidentalEnum.FLAT);this.addChordName("alt","major",[`${x}5`,`${P}9`,`${x}9`],[`${P}5`],[]),this.addChordName("7alt","dominant",[`${x}5`,`${P}9`,`${x}9`],[`${P}5`],[]),this.addChordName("7sus4","dominant",["4"],[],["3"]),this.addChordName("7sus4","suspendedfourth",["7"],[],[]),this.addChordName("9sus4","dominantninth",["4"],[],["3"]),this.addChordName("9sus4","suspendedfourth",["9"],[],[]),this.addChordName("11sus4","dominant11th",["4"],[],["3"]),this.addChordName("11sus4","suspendedfourth",["11"],[],[]),this.addChordName("13sus4","dominant13th",["4"],[],["3"]),this.addChordName("13sus4","suspendedfourth",["13"],[],[]),this.addChordName("7sus2","dominant",["2"],[],["3"]),this.addChordName("7sus2","suspendedsecond",["7"],[],[]),this.addChordName(`m7${P}5`,"minorseventh",[],[`${P}5`],[]),this.addChordName("9sus2","dominantninth",["2"],[],["3"]),this.addChordName("9sus2","suspendedsecond",["9"],[],[]),this.addChordName("11sus2","dominant11th",["2"],[],["3"]),this.addChordName("11sus2","suspendedsecond",["11"],[],[]),this.addChordName("13sus2","dominant13th",["2"],[],["3"]),this.addChordName("13sus2","suspendedsecond",["13"],[],[]),this.addChordName("m(maj9)","majorminor",["9"],[],[]),this.addChordName("m(maj11)","majorminor",["11"],[],[]),this.addChordName("m(maj13)","majorminor",["13"],[],[]),this.addChordName("69","majorsixth",["9"],[],[]),this.addChordName("mi69","minorsixth",["9"],[],[])}calculateCurveParametersArrays(){this.TPower3=new Array(this.BezierCurveStepSize),this.OneMinusTPower3=new Array(this.BezierCurveStepSize),this.FactorOne=new Array(this.BezierCurveStepSize),this.FactorTwo=new Array(this.BezierCurveStepSize);for(let x=0;x0}get NotToBeRemoved(){return this.notToBeRemoved}set NotToBeRemoved(b){this.notToBeRemoved=b}get Lines(){return this.lines}get ContinuousDynamic(){return this.SourceExpression}updateSkyBottomLine(){var w;const b=this.parentStaffLine.SkyBottomLineCalculator,S=this.IsVerbal?this.label.PositionAndShape.RelativePosition.x+this.label.PositionAndShape.BorderMarginLeft:0,v=this.IsVerbal?this.label.PositionAndShape.RelativePosition.x+this.label.PositionAndShape.BorderMarginRight:0;switch(!this.IsSoftAccent&&!this.IsVerbal&&this.lines.length<2&&u.default.warn("Not enough lines for SkyBottomLine calculation"),this.IsVerbal||this.ContinuousDynamic.DynamicType!==m.ContDynamicEnum.crescendo&&this.ContinuousDynamic.DynamicType!==m.ContDynamicEnum.diminuendo&&u.default.warn("GraphicalContinuousDynamicExpression.updateSkyBottomLine(): unhandled continuous dynamic type. start measure: "+((w=this.startMeasure)==null?void 0:w.MeasureNumber)),this.Placement){case h.PlacementEnum.Above:if(this.IsSoftAccent)b.updateSkyLineWithWedge(this.lines[0].Start,this.lines[0].End),b.updateSkyLineWithWedge(this.lines[2].End,this.lines[2].Start),b.updateSkyLineWithLine(this.lines[0].End,this.lines[2].End,this.lines[0].End.y);else if(this.IsVerbal){const T=this.label.PositionAndShape.BorderMarginTop+this.label.PositionAndShape.RelativePosition.y;b.updateSkyLineInRange(S,v,T)}else this.ContinuousDynamic.DynamicType===m.ContDynamicEnum.crescendo?b.updateSkyLineWithWedge(this.lines[0].Start,this.lines[0].End):this.ContinuousDynamic.DynamicType===m.ContDynamicEnum.diminuendo&&b.updateSkyLineWithWedge(this.lines[0].End,this.lines[0].Start);break;case h.PlacementEnum.Below:if(this.IsVerbal){const T=this.label.PositionAndShape.BorderMarginBottom+this.label.PositionAndShape.RelativePosition.y;b.updateBottomLineInRange(S,v,T)}else this.ContinuousDynamic.DynamicType===m.ContDynamicEnum.crescendo?b.updateBottomLineWithWedge(this.lines[1].Start,this.lines[1].End):this.ContinuousDynamic.DynamicType===m.ContDynamicEnum.diminuendo&&b.updateBottomLineWithWedge(this.lines[1].End,this.lines[1].Start);break;default:u.default.error("Placement for GraphicalContinuousDynamicExpression is unknown")}}createCrescendoLines(b,S,v,w=this.rules.WedgeOpeningLength,T=this.rules.WedgeLineWidth){const g=new o.PointF2D(b,v),x=new o.PointF2D(S,v-w/2),P=new o.PointF2D(S,v+w/2);this.addWedgeLines(g,x,P,T)}createFirstHalfCrescendoLines(b,S,v,w=this.rules.WedgeMeasureEndOpeningLength,T=this.rules.WedgeLineWidth){const g=new o.PointF2D(b,v),x=new o.PointF2D(S,v-w/2),P=new o.PointF2D(S,v+w/2);this.addWedgeLines(g,x,P,T)}createSecondHalfCrescendoLines(b,S,v,w=this.rules.WedgeMeasureBeginOpeningLength,T=this.rules.WedgeOpeningLength,g=this.rules.WedgeLineWidth){const x=new o.PointF2D(b,v-w/2),P=new o.PointF2D(b,v+w/2),_=new o.PointF2D(S,v-T/2),B=new o.PointF2D(S,v+T/2);this.addDoubleLines(x,_,P,B,g)}recalculateCrescendoLines(b,S,v){const w=Math.abs(this.lines[0].Start.y-this.lines[1].Start.y)>1e-4;this.lines.clear(),w?this.createSecondHalfCrescendoLines(b,S,v):this.isSplittedPart?this.createFirstHalfCrescendoLines(b,S,v):this.createCrescendoLines(b,S,v)}createDiminuendoLines(b,S,v,w=this.rules.WedgeOpeningLength,T=this.rules.WedgeLineWidth){const g=new o.PointF2D(b,v-w/2),x=new o.PointF2D(b,v+w/2),P=new o.PointF2D(S,v);this.addWedgeLines(P,g,x,T)}createFirstHalfDiminuendoLines(b,S,v,w=this.rules.WedgeOpeningLength,T=this.rules.WedgeMeasureEndOpeningLength,g=this.rules.WedgeLineWidth){const x=new o.PointF2D(b,v-w/2),P=new o.PointF2D(b,v+w/2),_=new o.PointF2D(S,v-T/2),B=new o.PointF2D(S,v+T/2);this.addDoubleLines(x,_,P,B,g)}createSecondHalfDiminuendoLines(b,S,v,w=this.rules.WedgeMeasureBeginOpeningLength,T=this.rules.WedgeLineWidth){const g=new o.PointF2D(b,v-w/2),x=new o.PointF2D(b,v+w/2),P=new o.PointF2D(S,v);this.addWedgeLines(P,g,x,T)}recalculateDiminuendoLines(b,S,v){const w=Math.abs(this.lines[0].End.y-this.lines[1].End.y)>1e-4;this.lines.clear(),w?this.createFirstHalfDiminuendoLines(b,S,v):this.isSplittedPart?this.createSecondHalfDiminuendoLines(b,S,v):this.createDiminuendoLines(b,S,v)}createFirstHalfLines(b,S,v,w=this.rules.WedgeOpeningLength,T=this.rules.WedgeMeasureEndOpeningLength,g=this.rules.WedgeLineWidth){this.ContinuousDynamic.DynamicType===m.ContDynamicEnum.crescendo?this.createFirstHalfCrescendoLines(b,S,v,T,g):this.ContinuousDynamic.DynamicType===m.ContDynamicEnum.diminuendo&&this.createFirstHalfDiminuendoLines(b,S,v,w,T,g)}createSecondHalfLines(b,S,v,w=this.rules.WedgeMeasureBeginOpeningLength,T=this.rules.WedgeOpeningLength,g=this.rules.WedgeLineWidth){this.ContinuousDynamic.DynamicType===m.ContDynamicEnum.crescendo?this.createSecondHalfCrescendoLines(b,S,v,w,T,g):this.ContinuousDynamic.DynamicType===m.ContDynamicEnum.diminuendo&&this.createSecondHalfDiminuendoLines(b,S,v,w,g)}createLines(b,S,v,w=this.rules.WedgeOpeningLength,T=this.rules.WedgeLineWidth){this.ContinuousDynamic.DynamicType===m.ContDynamicEnum.crescendo?this.createCrescendoLines(b,S,v,w,T):this.ContinuousDynamic.DynamicType===m.ContDynamicEnum.diminuendo&&this.createDiminuendoLines(b,S,v,w,T)}calcPsi(){this.IsVerbal?this.PositionAndShape.calculateBoundingBox():(this.PositionAndShape.RelativePosition=this.lines[0].Start,this.PositionAndShape.BorderMarginTop=this.lines[0].End.y-this.lines[0].Start.y,this.PositionAndShape.BorderMarginBottom=this.lines[1].End.y-this.lines[1].Start.y,this.PositionAndShape.Center.y=(this.PositionAndShape.BorderMarginTop+this.PositionAndShape.BorderMarginBottom)/2,this.IsSoftAccent?(this.PositionAndShape.BorderMarginLeft=0,this.PositionAndShape.BorderMarginRight=this.lines[3].Start.x-this.lines[0].Start.x):this.ContinuousDynamic.DynamicType===m.ContDynamicEnum.crescendo?(this.PositionAndShape.BorderMarginLeft=0,this.PositionAndShape.BorderMarginRight=this.lines[0].End.x-this.lines[0].Start.x):(this.PositionAndShape.BorderMarginLeft=this.lines[0].End.x-this.lines[0].Start.x,this.PositionAndShape.BorderMarginRight=0))}cleanUp(){this.lines.clear()}shiftYPosition(b){this.IsVerbal?(this.PositionAndShape.RelativePosition.y+=b,this.PositionAndShape.calculateBoundingBox()):(this.lines[0].Start.y+=b,this.lines[0].End.y+=b,this.lines[1].End.y+=b)}squeeze(b){this.IsVerbal||Math.abs(this.lines[0].End.x-this.lines[0].Start.x)0?this.lines[0].Start.x+=b:(this.lines[0].End.x+=b,this.lines[1].End.x+=b):b<0?this.lines[0].Start.x+=b:(this.lines[0].End.x+=b,this.lines[1].End.x+=b),this.calcPsi())}addWedgeLines(b,S,v,w){const T=new l.GraphicalLine(b,S,w),g=new l.GraphicalLine(b,v,w);this.rules.DefaultColorMusic&&(T.colorHex=this.rules.DefaultColorMusic,g.colorHex=this.rules.DefaultColorMusic),this.lines.push(T),this.lines.push(g)}addDoubleLines(b,S,v,w,T){const g=new l.GraphicalLine(b,S,T),x=new l.GraphicalLine(v,w,T);this.rules.DefaultColorMusic&&(g.colorHex=this.rules.DefaultColorMusic,x.colorHex=this.rules.DefaultColorMusic),this.lines.push(g),this.lines.push(x)}}y.GraphicalContinuousDynamicExpression=f},6711(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.GraphicalCurve=void 0;const d=p(9409);class l{constructor(){l.tPow3=new Array(l.bezierCurveStepSize),l.oneMinusTPow3=new Array(l.bezierCurveStepSize),l.bezierFactorOne=new Array(l.bezierCurveStepSize),l.bezierFactorTwo=new Array(l.bezierCurveStepSize);for(let o=0;o=l.bezierCurveStepSize?new d.PointF2D:new d.PointF2D(l.oneMinusTPow3[s]*this.bezierStartPt.x+l.bezierFactorOne[s]*this.bezierStartControlPt.x+l.bezierFactorTwo[s]*this.bezierEndControlPt.x+l.tPow3[s]*this.bezierEndPt.x,l.oneMinusTPow3[s]*this.bezierStartPt.y+l.bezierFactorOne[s]*this.bezierStartControlPt.y+l.bezierFactorTwo[s]*this.bezierEndControlPt.y+l.tPow3[s]*this.bezierEndPt.y)}}y.GraphicalCurve=l,l.bezierCurveStepSize=1e3},98(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.GraphicalGlissando=void 0;const d=p(9409),l=p(6438),m=p(6452);y.GraphicalGlissando=class{constructor(o){this.Glissando=o,this.staffEntries=[]}calculateLine(o){const s=this.staffEntries[0],h=this.staffEntries[this.staffEntries.length-1],u=s.findGraphicalNoteFromNote(this.Glissando.StartNote),f=h.findGraphicalNoteFromNote(this.Glissando.EndNote);if(!u&&!f)return;const r=s.parentMeasure.ParentStaffLine;let b,S,v,w;if(u&&s.parentMeasure.ParentStaffLine===this.StaffLine)b=u.PositionAndShape.RelativePosition.x+u.parentVoiceEntry.parentStaffEntry.PositionAndShape.RelativePosition.x+u.parentVoiceEntry.parentStaffEntry.parentMeasure.PositionAndShape.RelativePosition.x+o.GlissandoNoteOffset,v=u.PositionAndShape.AbsolutePosition.y;else{b=h.parentMeasure.beginInstructionsWidth-.4;const x=this.Glissando.Direction===l.ColDirEnum.Down?-1:1;v=f.PositionAndShape.AbsolutePosition.y+x*o.GlissandoStafflineStartYDistanceToNote}if(f&&h.parentMeasure.ParentStaffLine===this.StaffLine)S=f.PositionAndShape.RelativePosition.x+f.parentVoiceEntry.parentStaffEntry.PositionAndShape.RelativePosition.x+f.parentVoiceEntry.parentStaffEntry.parentMeasure.PositionAndShape.RelativePosition.x-.5-o.GlissandoNoteOffset,b>S&&(b=S-o.GlissandoStafflineStartMinimumWidth),w=f.PositionAndShape.AbsolutePosition.y;else{if(r.Measures.last().parentSourceMeasure.HasEndLine)return;S=r.PositionAndShape.Size.width,S-b>o.GlissandoStafflineEndOffset&&(b=S-o.GlissandoStafflineEndOffset);const x=this.Glissando.Direction===l.ColDirEnum.Down?1:-1;w=u.PositionAndShape.AbsolutePosition.y+x*o.GlissandoStafflineStartYDistanceToNote}const T=new d.PointF2D(b,v),g=new d.PointF2D(S,w);this.Width===void 0&&(this.Width=o.GlissandoDefaultWidth),this.Line=new m.GraphicalLine(T,g,this.Width)}}},5023(St,y,p){var d=this&&this.__importDefault||function(h){return h&&h.__esModule?h:{default:h}};Object.defineProperty(y,"__esModule",{value:!0}),y.GraphicalInstantaneousDynamicExpression=void 0;const l=p(9490),m=p(6362),o=d(p(3065));class s extends l.AbstractGraphicalExpression{constructor(u,f,r){super(f,u,r.parentSourceMeasure),this.mInstantaneousDynamicExpression=u,this.mMeasure=r}updateSkyBottomLine(){const u=this.parentStaffLine.SkyBottomLineCalculator,f=this.PositionAndShape.RelativePosition.x+this.PositionAndShape.BorderMarginLeft,r=this.PositionAndShape.RelativePosition.x+this.PositionAndShape.BorderMarginRight;let b=0;switch(this.Placement){case m.PlacementEnum.Above:b=this.PositionAndShape.RelativePosition.y+this.PositionAndShape.BorderMarginTop,u.updateSkyLineInRange(f,r,b);break;case m.PlacementEnum.Below:b=this.PositionAndShape.RelativePosition.y+this.PositionAndShape.BorderMarginBottom,u.updateBottomLineInRange(f,r,b);break;default:o.default.error("Placement for GraphicalInstantaneousDynamicExpression is unknown")}}}y.GraphicalInstantaneousDynamicExpression=s},3361(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.GraphicalInstantaneousTempoExpression=void 0;const d=p(9490);class l extends d.AbstractGraphicalExpression{constructor(o,s){super(s.PositionAndShape.Parent.DataObject,o,o.parentMeasure),this.label=s}get GraphicalLabel(){return this.label}updateSkyBottomLine(){}}y.GraphicalInstantaneousTempoExpression=l},8254(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.GraphicalLabel=void 0;const d=p(7533),l=p(6438),m=p(995),o=p(7921);class s extends m.Clickable{constructor(u,f,r,b,S=void 0){super(),this.CenteringXShift=0,this.label=u,this.boundingBox=new l.BoundingBox(this,S),this.label.fontHeight=f,this.label.textAlignment=r,this.rules=b}get Label(){return this.label}toString(){return`${this.label.text} (${this.boundingBox.RelativePosition.x},${this.boundingBox.RelativePosition.y})`}setLabelPositionAndShapeBorders(){var w;if(this.Label.text.trim()==="")return;this.TextLines=[];const u=((w=this.rules)==null?void 0:w.LabelMarginBorderFactor)??.1,f=this.Label.text.split(/[\n\r]+/g),r=f.length;let b=0;for(let T=0;T0&&this.TextLines.length>1&&(S+=this.rules.SpacingBetweenTextLines*r/10);const v=this.PositionAndShape;switch(this.Label.textAlignment){case d.TextAlignmentEnum.CenterBottom:v.BorderTop=-S,v.BorderLeft=-b/2,v.BorderBottom=0,v.BorderRight=b/2;break;case d.TextAlignmentEnum.CenterCenter:v.BorderTop=-S/2,v.BorderLeft=-b/2,v.BorderBottom=S/2,v.BorderRight=b/2;break;case d.TextAlignmentEnum.CenterTop:v.BorderTop=0,v.BorderLeft=-b/2,v.BorderBottom=S,v.BorderRight=b/2;break;case d.TextAlignmentEnum.LeftBottom:v.BorderTop=-S,v.BorderLeft=0,v.BorderBottom=0,v.BorderRight=b;break;case d.TextAlignmentEnum.LeftCenter:v.BorderTop=-S/2,v.BorderLeft=0,v.BorderBottom=S/2,v.BorderRight=b;break;case d.TextAlignmentEnum.LeftTop:v.BorderTop=0,v.BorderLeft=0,v.BorderBottom=S,v.BorderRight=b;break;case d.TextAlignmentEnum.RightBottom:v.BorderTop=-S,v.BorderLeft=-b,v.BorderBottom=0,v.BorderRight=0;break;case d.TextAlignmentEnum.RightCenter:v.BorderTop=-S/2,v.BorderLeft=-b,v.BorderBottom=S/2,v.BorderRight=0;break;case d.TextAlignmentEnum.RightTop:v.BorderTop=0,v.BorderLeft=-b,v.BorderBottom=S,v.BorderRight=0}v.BorderMarginTop=v.BorderTop-S*u,v.BorderMarginLeft=v.BorderLeft-S*u,v.BorderMarginBottom=v.BorderBottom+S*u,v.BorderMarginRight=v.BorderRight+S*u}}y.GraphicalLabel=s},6452(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.GraphicalLine=void 0;const d=p(2683);y.GraphicalLine=class{constructor(l,m,o=0,s=d.OutlineAndFillStyleEnum.BaseWritingColor,h=void 0){this.start=l,this.end=m,this.width=o,this.styleId=s,this.colorHex=h}get Start(){return this.start}set Start(l){this.start=l}get End(){return this.end}set End(l){this.end=l}get Width(){return this.width}set Width(l){this.width=l}}},2395(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.GraphicalLyricEntry=void 0;const d=p(8254),l=p(7435),m=p(9409),o=p(7533);y.GraphicalLyricEntry=class{constructor(s,h,u,f){this.lyricsEntry=s,this.graphicalStaffEntry=h;const r=h.parentMeasure.parentSourceMeasure.Rules.LyricsAlignmentStandard;s.Text.length>=4&&s.Parent.Notes[0].Length.Denominator>4&&o.TextAlignmentEnum.LeftBottom;const b=new l.Label(s.Text),S=this.graphicalStaffEntry.parentMeasure.parentSourceMeasure.Rules;this.graphicalLabel=new d.GraphicalLabel(b,u,r,S,h.PositionAndShape),this.graphicalLabel.Label.colorDefault=S.DefaultColorLyrics,this.graphicalLabel.PositionAndShape.RelativePosition=new m.PointF2D(0,f),this.graphicalLabel.setLabelPositionAndShapeBorders(),this.graphicalLabel.PositionAndShape.Size.width1&&s1}isVisible(){return this.ParentStaff.isVisible()}isMultiRestMeasure(){return this.multiRestElement!==void 0}getGraphicalMeasureDurationFromStaffEntries(){let u=new l.Fraction(0,1);const f=[];for(let r=0,b=this.staffEntries.length;r0&&v.Add(T.notes[0].graphicalNoteLength);u.lt(v)&&(u=l.Fraction.createFromFraction(v))}return u}addGraphicalStaffEntry(u){this.staffEntries.push(u)}addGraphicalStaffEntryAtTimestamp(u){if(u)if(this.staffEntries.length===0||this.staffEntries[this.staffEntries.length-1].relInMeasureTimestamp.lt(u.relInMeasureTimestamp))this.staffEntries.push(u);else for(let f=this.staffEntries.length-1;f>=0;f--){if(this.staffEntries[f].relInMeasureTimestamp.lt(u.relInMeasureTimestamp)){this.staffEntries.splice(f+1,0,u);break}f===0&&this.staffEntries.splice(f,0,u)}}isPianoRightHand(){return this.isUpperStaffOfInstrument()}isPianoLeftHand(){return this.isLowerStaffOfInstrument()}isUpperStaffOfInstrument(){return this.parentStaff.ParentInstrument.Staves.length===1||this.ParentStaff===this.parentStaff.ParentInstrument.Staves[0]}isLowerStaffOfInstrument(){return this.parentStaff.ParentInstrument.Staves.length!==1&&this.ParentStaff===this.ParentStaff.ParentInstrument.Staves.last()}beginsWithLineRepetition(){const u=this.parentSourceMeasure;return!!u&&u.beginsWithLineRepetition()}endsWithLineRepetition(){const u=this.parentSourceMeasure;return!!u&&u.endsWithLineRepetition()}beginsWithWordRepetition(){const u=this.parentSourceMeasure;return!!u&&u.beginsWithWordRepetition()}endsWithWordRepetition(){const u=this.parentSourceMeasure;return!!u&&u.endsWithWordRepetition()}getTransposedHalftones(){return this.parentStaff.ParentInstrument.GetMusicSheet.Transpose+this.parentStaff.ParentInstrument.Transpose}}y.GraphicalMeasure=s},1888(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.PagePlacementEnum=y.GraphicalMusicPage=void 0;const d=p(6438),l=p(7741),m=p(9409);class o extends l.GraphicalObject{constructor(u){super(),this.musicSystems=[],this.labels=[],this.parent=u,this.boundingBox=new d.BoundingBox(this,void 0)}get MusicSystems(){return this.musicSystems}set MusicSystems(u){this.musicSystems=u}get Labels(){return this.labels}set Labels(u){this.labels=u}get Parent(){return this.parent}set Parent(u){this.parent=u}get PageNumber(){return this.pageNumber}set PageNumber(u){this.pageNumber=u}setMusicPageAbsolutePosition(u,f){return new m.PointF2D(0,0)}}var s;y.GraphicalMusicPage=o,(function(h){h[h.Down=0]="Down",h[h.Right=1]="Right",h[h.RightDown=2]="RightDown"})(s||(y.PagePlacementEnum=s={}))},8724(St,y,p){var d=this&&this.__importDefault||function(T){return T&&T.__esModule?T:{default:T}};Object.defineProperty(y,"__esModule",{value:!0}),y.SystemImageProperties=y.GraphicalMusicSheet=void 0;const l=p(6723),m=p(6452),o=p(348),s=p(9409),h=p(164),u=p(4543),f=p(2561),r=p(6438),b=d(p(3065)),S=p(813),v=p(4548),w=p(7741);y.GraphicalMusicSheet=class{constructor(T,g){this.musicPages=[],this.measureList=[],this.verticalGraphicalStaffEntryContainers=[],this.cursors=[],this.leadSheet=!1,this.musicSheet=T,this.numberOfStaves=this.musicSheet.Staves.length,this.calculator=g,this.calculator.initialize(this)}get ParentMusicSheet(){return this.musicSheet}get GetCalculator(){return this.calculator}get MusicPages(){return this.musicPages}set MusicPages(T){this.musicPages=T}get MeasureList(){return this.measureList}set MeasureList(T){this.measureList=T}get VerticalGraphicalStaffEntryContainers(){return this.verticalGraphicalStaffEntryContainers}set VerticalGraphicalStaffEntryContainers(T){this.verticalGraphicalStaffEntryContainers=T}get Title(){return this.title}set Title(T){this.title=T}get Subtitle(){return this.subtitle}set Subtitle(T){this.subtitle=T}get Composer(){return this.composer}set Composer(T){this.composer=T}get Lyricist(){return this.lyricist}set Lyricist(T){this.lyricist=T}get Copyright(){return this.copyright}set Copyright(T){this.copyright=T}get Cursors(){return this.cursors}get SelectionStartSymbol(){return this.selectionStartSymbol}get SelectionEndSymbol(){return this.selectionEndSymbol}get MinAllowedSystemWidth(){return this.minAllowedSystemWidth}set MinAllowedSystemWidth(T){this.minAllowedSystemWidth=T}get NumberOfStaves(){return this.numberOfStaves}get LeadSheet(){return this.leadSheet}set LeadSheet(T){this.leadSheet=T}static transformRelativeToAbsolutePosition(T){for(let g=0;g=0;P--){const _=(x=this.measureList[P])==null?void 0:x[g];if(_)return _}}findGraphicalMeasureByMeasureNumber(T,g){for(let x=T;x>=0;x--)if(this.MeasureList[x]){const P=this.MeasureList[x][g];if((P==null?void 0:P.MeasureNumber)===T)return P}}findGraphicalStaffEntryFromMeasureList(T,g,x){for(let P=g;P0)return B.staffEntries[0]}}getFirstVisibleMeasuresListFromIndices(T,g){const x=[],P=this.measureList[0].length;for(let _=T;_<=g;_++)for(let B=0;B=0;g--){if(this.verticalGraphicalStaffEntryContainers[g].AbsoluteTimestamp.lt(T)){const x=new l.VerticalGraphicalStaffEntryContainer(this.numberOfStaves,T);return this.verticalGraphicalStaffEntryContainers.splice(g+1,0,x),x}if(this.verticalGraphicalStaffEntryContainers[g].AbsoluteTimestamp.Equals(T))return this.verticalGraphicalStaffEntryContainers[g]}}GetVerticalContainerFromTimestamp(T,g=0){const x=S.CollectionUtil.binarySearch(this.verticalGraphicalStaffEntryContainers,new l.VerticalGraphicalStaffEntryContainer(0,T),l.VerticalGraphicalStaffEntryContainer.compareByTimestamp,g);if(x>=0)return this.verticalGraphicalStaffEntryContainers[x]}GetInterpolatedIndexInVerticalContainers(T){const g=this.verticalGraphicalStaffEntryContainers;if(g.length===1)return 0;let x,P,_=0,B=g.length-1;if(T.lte(g[g.length-1].AbsoluteTimestamp)){for(;B-_>1;){const F=Math.floor((B+_)/2);if(g[_].AbsoluteTimestamp.Equals(T)){B=_;break}if(g[B].AbsoluteTimestamp.Equals(T)){_=B;break}if(g[F].AbsoluteTimestamp.Equals(T))return this.verticalGraphicalStaffEntryContainers.indexOf(g[F]);T.lt(g[F].AbsoluteTimestamp)?B=F:_=F}if(_===B)return this.verticalGraphicalStaffEntryContainers.indexOf(g[_]);x=g[_].AbsoluteTimestamp,P=g[B].AbsoluteTimestamp}else x=g[g.length-1].AbsoluteTimestamp,P=f.Fraction.plus(this.getLongestStaffEntryDuration(g.length-1),x),B=g.length;const k=P.RealValue-x.RealValue,R=B-(P.RealValue-T.RealValue)/k;return Math.min(R,this.verticalGraphicalStaffEntryContainers.length-1)}getVisibleStavesIndicesFromSourceMeasure(T){const g=[],x=[];for(let P=0,_=T.length;P<_;++P){const B=T[P].ParentStaff.ParentInstrument;g.indexOf(B)===-1&&g.push(B)}for(let P=0,_=g.length;P<_;++P){const B=g[P],k=this.musicSheet.getGlobalStaffIndexOfFirstStaff(B);for(let R=0;R=0;)P=this.measureList[--x][T];return this.measureList[x][T]}getMeasureIndex(T,g,x){for(g=0;g{var x;return((x=g.parentStaffEntry)==null?void 0:x.relInMeasureTimestamp)!==void 0})}GetNearestNote(T,g){const x=this.GetNearestVoiceEntry(T);if(!x)return;let P,_=Number.MAX_SAFE_INTEGER;for(const B of x.notes){const k=B.PositionAndShape.AbsolutePosition.y,R=Math.abs(B.PositionAndShape.AbsolutePosition.x-T.x),F=Math.abs(k-T.y);R+F<_&&(P=B,_=R+F)}return P}domToSvg(T){return this.domToSvgTransform(T,!0)}svgToDom(T){return this.domToSvgTransform(T,!1)}svgToOsmd(T){const g=new s.PointF2D(T.x,T.y);return g.x/=10,g.y/=10,g}domToSvgTransform(T,g){const x=this.drawer.Backends[0].getSvgElement(),P=x.createSVGPoint();P.x=T.x,P.y=T.y;let _=x.getScreenCTM();g&&(_=_.inverse());const B=P.matrixTransform(_);return new s.PointF2D(B.x,B.y)}GetClickableLabel(T){const g=new r.BoundingBox;g.BorderLeft=T.x-4,g.BorderTop=T.y-4,g.BorderRight=T.x+4,g.BorderBottom=T.y+4,g.AbsolutePosition=new s.PointF2D(0,0);for(let x=0,P=this.MusicPages.length;xB.PositionAndShape.RelativePosition.x&&(x=B):x=B)}}catch(P){b.default.info("GraphicalMusicSheet.getStaffEntry",P)}return x}GetPreviousVisibleContainerIndex(T){for(let g=T-1;g>=0;g--){const x=this.verticalGraphicalStaffEntryContainers[g].StaffEntries;for(let P=0,_=x.length;P<_;++P){const B=x[P];if(B&&B.sourceStaffEntry.ParentStaff.isVisible())return g}}return-1}GetNextVisibleContainerIndex(T){for(let g=T+1;g=0;_--)if(x=this.getStaffEntry(_),x&&(!g||x.sourceStaffEntry.ParentStaff.isVisible()))return x}findClosestRightStaffEntry(T,g){let x;for(let P=Math.max(0,Math.ceil(T));Pg.RealValue?1:g.RealValue>T.RealValue?-1:0}calculateCurve(v){const w=this.staffEntries[0],T=this.staffEntries[this.staffEntries.length-1];let g=w.findGraphicalNoteFromNote(this.slur.StartNote);!g&&this.graceStart&&(g=w.findGraphicalNoteFromGraceNote(this.slur.StartNote)),g||(g=w.findEndTieGraphicalNoteFromNoteWithStartingSlur(this.slur.StartNote,this.slur));let x=T.findGraphicalNoteFromNote(this.slur.EndNote);!x&&this.graceEnd&&(x=T.findGraphicalNoteFromGraceNote(this.slur.EndNote));const P=w.parentMeasure.ParentStaffLine,_=P.SkyBottomLineCalculator;this.calculatePlacement(_,P);const B=this.calculateStartAndEnd(g,x,P,v,_),k=B.startX,R=B.endX;let F=B.startY,A=B.endY;const G=v.SlurTangentMinAngle,U=v.SlurTangentMaxAngle;let C;if(this.placement===o.PlacementEnum.Above){F-=v.SlurNoteHeadYOffset,A-=v.SlurNoteHeadYOffset;const z=new l.PointF2D(this.staffEntries[0].parentMeasure.PositionAndShape.RelativePosition.x+this.staffEntries[0].PositionAndShape.RelativePosition.x,F);g?z.x+=this.staffEntries[0].PositionAndShape.BorderRight:z.x=this.staffEntries[0].parentMeasure.beginInstructionsWidth,this.graceStart&&(z.x+=T.PositionAndShape.RelativePosition.x);const W=new l.PointF2D(this.staffEntries[this.staffEntries.length-1].parentMeasure.PositionAndShape.RelativePosition.x+this.staffEntries[this.staffEntries.length-1].PositionAndShape.RelativePosition.x,A);if(x?W.x+=this.staffEntries[this.staffEntries.length-1].PositionAndShape.BorderLeft:W.x=this.staffEntries[this.staffEntries.length-1].parentMeasure.PositionAndShape.RelativePosition.x+this.staffEntries[this.staffEntries.length-1].parentMeasure.PositionAndShape.Size.width,this.graceEnd&&(W.x+=T.staffEntryParent.PositionAndShape.RelativePosition.x),C=this.calculateTopPoints(z,W,P,_),C.length===0){const Nt=new l.PointF2D((W.x-z.x)/2+z.x,(W.y-z.y)/2+z.y);C.push(Nt)}const $=Math.atan((A-F)/(R-k)),N=new l.PointF2D(0,0);let Y=new l.PointF2D(R-k,-(A-F));const tt=s.Matrix2D.getRotationMatrix($),H=tt.getTransposeMatrix();Y=tt.vectorMultiplication(Y);const rt=this.calculateTranslatedAndRotatedPointListAbove(C,k,F,tt),ct=this.calculateMaxLeftSlope(rt,N,Y),st=this.calculateMaxRightSlope(rt,N,Y),ot=N.y-N.x*ct,ht=Y.y-Y.x*st,lt=new l.PointF2D;let O=!1;Math.abs(Math.abs(ct)-Math.abs(st))<1e-4?(lt.x=Y.x/2,lt.y=0,O=!0):(lt.x=(ht-ot)/(ct-st),lt.y=ct*lt.x+ot);const D=this.calculateHeightWidthRatio(Y.x,rt),j=0,Q=0;let J=G,q=-G;if(!O){const Nt=this.calculateAngles(G,ct,st,U);J=Nt.startAngle,q=Nt.endAngle}const et=this.calculateControlPoints(Y.x,J,q,rt,D,F,A);let it=et.startControlPoint,dt=et.endControlPoint;it=H.vectorMultiplication(it),it.x+=k,it.y=-it.y+F,dt=H.vectorMultiplication(dt),dt.x+=k,dt.y=-dt.y+F,this.bezierStartPt=new l.PointF2D(k,F-j),this.bezierStartControlPt=new l.PointF2D(it.x,it.y-j),this.bezierEndControlPt=new l.PointF2D(dt.x,dt.y-Q),this.bezierEndPt=new l.PointF2D(R,A-Q);const mt=P.SkyLine.length,yt=_.getLeftIndexForPointX(this.bezierStartPt.x,mt),Et=_.getLeftIndexForPointX(this.bezierEndPt.x,mt),Dt=this.bezierEndPt.x-this.bezierStartPt.x,Vt=_.SamplingUnit;for(let Nt=yt;Nt=yt&&(P.SkyLine[zt]=Math.min(P.SkyLine[zt],Ct.y)),zt++,zt=yt&&(P.BottomLine[zt]=Math.max(P.BottomLine[zt],Ct.y)),zt++,zt0)return void(this.placement=o.PlacementEnum.Above);const T=this.staffEntries[0],g=this.staffEntries[this.staffEntries.length-1],x=T.graphicalVoiceEntries[0].parentVoiceEntry.StemDirection;if(x===g.graphicalVoiceEntries[0].parentVoiceEntry.StemDirection)this.placement=x===f.StemDirectionType.Up?o.PlacementEnum.Below:o.PlacementEnum.Above,this.rules.SlurPlacementAtStems&&(this.placement=x===f.StemDirectionType.Up?o.PlacementEnum.Above:o.PlacementEnum.Below);else{let P=T.PositionAndShape.BorderLeft+T.PositionAndShape.RelativePosition.x+T.parentMeasure.PositionAndShape.RelativePosition.x,_=g.PositionAndShape.BorderRight+g.PositionAndShape.RelativePosition.x+g.parentMeasure.PositionAndShape.RelativePosition.x;this.graceStart&&(P+=g.PositionAndShape.RelativePosition.x),this.graceEnd&&(_+=g.staffEntryParent.PositionAndShape.RelativePosition.x);const B=-1*v.getSkyLineMinInRange(P,_),k=v.getBottomLineMaxInRange(P,_)-w.StaffHeight;this.placement=k>B?o.PlacementEnum.Above:o.PlacementEnum.Below}}calculateTopPoints(v,w,T,g){const x=[];let P=g.getRightIndexForPointX(v.x,T.SkyLine.length),_=g.getLeftIndexForPointX(w.x,T.SkyLine.length);P<0&&(P=0),_>=T.SkyLine.length&&(_=T.SkyLine.length-1);for(let B=P;B<_;B++){const k=T.SkyLine[B];if(k!==0){const R=new l.PointF2D((.5+B)/g.SamplingUnit,k);x.push(R)}}return x}calculateBottomPoints(v,w,T,g){const x=[];let P=g.getRightIndexForPointX(v.x,T.BottomLine.length),_=g.getLeftIndexForPointX(w.x,T.BottomLine.length);P<0&&(P=0),_>=T.BottomLine.length&&(_=T.BottomLine.length-1);for(let B=P;B<_;B++){const k=T.BottomLine[B];if(k!==0){const R=new l.PointF2D((.5+B)/g.SamplingUnit,k);x.push(R)}}return x}calculateMaxLeftSlope(v,w,T){let g=-Number.MAX_VALUE;const x=w.x,P=w.y;for(let _=0;_R&&v>F&&(k+=v/70*this.rules.SlurHeightFlattenLongSlursFactorByWidth,k*=1+w/30*this.rules.SlurHeightFlattenLongSlursFactorByAngle,B/=k);const A=Math.min(.5,Math.max(.1,1.7*w/80*B*Math.pow(Math.max(x,.05),.4))),G=Math.min(.5,Math.max(.1,1.7*-T/80*B*Math.pow(Math.max(x,.05),.4))),U=new l.PointF2D;U.x=v*A*Math.cos(w*b.degreesToRadiansFactor),U.y=v*A*Math.sin(w*b.degreesToRadiansFactor);const C=new l.PointF2D;C.x=v-v*G*Math.cos(T*b.degreesToRadiansFactor),C.y=-v*G*Math.sin(T*b.degreesToRadiansFactor);let z=U.y-C.y;for(;this.rules.SlurMaximumYControlPointDistance&&Math.abs(z)>this.rules.SlurMaximumYControlPointDistance;)z<0?(U.y+=1,C.y-=1):(U.y-=1,C.y+=1),z=U.y-C.y;return{startControlPoint:U,endControlPoint:C}}calculateAngles(v,w,T,g){let x=Math.atan(w)/b.degreesToRadiansFactor;w>0?x+=20:x-=20;let P=Math.atan(T)/b.degreesToRadiansFactor;return T<0?P-=20:P+=20,{startAngle:Math.min(Math.max(v,x),g),endAngle:Math.max(Math.min(-v,P),-g)}}}y.GraphicalSlur=b,b.degreesToRadiansFactor=Math.PI/180},348(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.GraphicalStaffEntry=void 0;const d=p(6438),l=p(2561),m=p(7741),o=p(813),s=p(7921);class h extends m.GraphicalObject{constructor(f,r=void 0,b=void 0){super(),this.graphicalChordContainers=[],this.tabStaffEntry=void 0,this.MaxAccidentals=0,this.graphicalInstructions=[],this.ties=[],this.graphicalTies=[],this.lyricsEntries=[],this.parentMeasure=f,this.graphicalVoiceEntries=[],this.sourceStaffEntry=r,b?(this.staffEntryParent=b,this.parentVerticalContainer=b.parentVerticalContainer,this.PositionAndShape=new d.BoundingBox(this,b.PositionAndShape)):this.PositionAndShape=new d.BoundingBox(this,f.PositionAndShape),r&&(this.relInMeasureTimestamp=r.Timestamp),this.FingeringEntries=[]}get GraphicalInstructions(){return this.graphicalInstructions}get GraphicalTies(){return this.graphicalTies}get LyricsEntries(){return this.lyricsEntries}set LyricsEntries(f){this.lyricsEntries=f}getAbsoluteTimestamp(){const f=this.parentMeasure.parentSourceMeasure.AbsoluteTimestamp.clone();return this.relInMeasureTimestamp&&f.Add(this.relInMeasureTimestamp),f}findTieGraphicalNoteFromNote(f){for(const r of this.graphicalVoiceEntries)for(const b of r.notes){const S=b.sourceNote;if(!S.isRest()&&S.Pitch.FundamentalNote===f.Pitch.FundamentalNote&&S.Pitch.Octave===f.Pitch.Octave&&S.getAbsoluteTimestamp().Equals(f.getAbsoluteTimestamp()))return b}}findEndTieGraphicalNoteFromNoteWithStartingSlur(f,r){if(f){for(const b of this.graphicalVoiceEntries)if(b.parentVoiceEntry===f.ParentVoiceEntry)for(const S of b.notes){const v=S.sourceNote;if(v.NoteTie&&v.NoteSlurs.indexOf(r)!==-1)return S}}}findGraphicalNoteFromGraceNote(f){if(f){for(const r of this.graphicalVoiceEntries)if(r.parentVoiceEntry===f.ParentVoiceEntry){for(const b of r.notes)if(b.sourceNote===f)return b}}}findGraphicalNoteFromNote(f){if(f){for(const r of this.graphicalVoiceEntries)if(r.parentVoiceEntry===f.ParentVoiceEntry){for(const b of r.notes)if(b.sourceNote===f&&this.getAbsoluteTimestamp().Equals(f.getAbsoluteTimestamp()))return b}}}getGraphicalNoteDurationFromVoice(f){for(const r of this.graphicalVoiceEntries)if(r.parentVoiceEntry.ParentVoice===f)return r.notes[0].graphicalNoteLength;return new l.Fraction(0,1)}findVoiceEntryGraphicalNotes(f){for(const r of this.graphicalVoiceEntries)if(r.parentVoiceEntry===f)return r.notes}isVoiceEntryPartOfLinkedVoiceEntry(f){if(this.sourceStaffEntry.Link)for(let r=0,b=this.sourceStaffEntry.Link.LinkStaffEntries.length;r0&&(f=S)}return f}findStaffEntryMaxNoteLength(){let f=new l.Fraction(0,1);for(const r of this.graphicalVoiceEntries)for(const b of r.notes){const S=b.graphicalNoteLength;f.lt(S)&&S.GetExpandedNumerator()>0&&(f=S)}return f}findOrCreateGraphicalVoiceEntry(f){for(const b of this.graphicalVoiceEntries)if(b.parentVoiceEntry===f)return b;const r=s.MusicSheetCalculator.symbolFactory.createVoiceEntry(f,this);return this.graphicalVoiceEntries.push(r),r}findOrCreateGraphicalVoiceEntryFromGraphicalNote(f){for(const b of this.graphicalVoiceEntries)if(b===f.parentVoiceEntry)return b;const r=s.MusicSheetCalculator.symbolFactory.createVoiceEntry(f.sourceNote.ParentVoiceEntry,this);return this.graphicalVoiceEntries.push(r),r}addGraphicalNoteToListAtCorrectYPosition(f,r){const b=f.notes;if(b.length===0||r.PositionAndShape.RelativePosition.y=0;S--){if(b[S].PositionAndShape.RelativePosition.y>r.PositionAndShape.RelativePosition.y){b.splice(S+1,0,r);break}if(S===0){b.splice(0,0,r);break}}}hasOnlyRests(){return this.sourceStaffEntry.hasOnlyRests}getSkylineMin(){var S;const f=(S=this.parentMeasure)==null?void 0:S.ParentStaffLine.SkyBottomLineCalculator;if(!f)return;const[r,b]=this.getAbsoluteStartAndEnd();return f.getSkyLineMinInRange(r,b)}getHighestYAtEntry(){return this.parentMeasure.ParentStaffLine.PositionAndShape.AbsolutePosition.y+this.getSkylineMin()}getLowestYAtEntry(){return this.parentMeasure.ParentStaffLine.PositionAndShape.AbsolutePosition.y+this.getBottomlineMax()}getBottomlineMax(){var S;const f=(S=this.parentMeasure)==null?void 0:S.ParentStaffLine.SkyBottomLineCalculator;if(!f)return;const[r,b]=this.getAbsoluteStartAndEnd();return f.getBottomLineMaxInRange(r,b)}getAbsoluteStartAndEnd(){let f=this.PositionAndShape.AbsolutePosition.x;return f-=this.parentMeasure.ParentStaffLine.PositionAndShape.AbsolutePosition.x,[f,f+this.PositionAndShape.Size.width]}}y.GraphicalStaffEntry=h},9760(St,y){Object.defineProperty(y,"__esModule",{value:!0}),y.GraphicalStaffEntryLink=void 0,y.GraphicalStaffEntryLink=class{constructor(p){this.graphicalLinkedStaffEntries=[],this.staffEntryLink=p,this.initialize()}get GetStaffEntryLink(){return this.staffEntryLink}get GraphicalLinkedStaffEntries(){return this.graphicalLinkedStaffEntries}set GraphicalLinkedStaffEntries(p){this.graphicalLinkedStaffEntries=p}isFilled(){for(let p=0;p{var f,r;return(((f=u.sourceNote.Pitch)==null?void 0:f.getHalfTone())??0)-(((r=h.sourceNote.Pitch)==null?void 0:r.getHalfTone())??0)}),this.notes}sortForVexflow(){return this.notes.sort((h,u)=>{var f;return(((f=h.sourceNote.Pitch)==null?void 0:f.getHalfTone())??0)-(u.sourceNote.Pitch.getHalfTone()??0)}),this.notes}applyCustomNoteheads(){}color(){}}y.GraphicalVoiceEntry=o},7753(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.GraphicalWavyLine=void 0;const d=p(6438),l=p(7741);class m extends l.GraphicalObject{constructor(s,h){super(),this.getWavyLine=s,this.PositionAndShape=new d.BoundingBox(this,h)}}y.GraphicalWavyLine=m},7225(St,y){Object.defineProperty(y,"__esModule",{value:!0})},7921(St,y,p){var d=this&&this.__importDefault||function(lt){return lt&<.__esModule?lt:{default:lt}};Object.defineProperty(y,"__esModule",{value:!0}),y.MusicSheetCalculator=void 0;const l=p(8724),m=p(2561),o=p(1850),s=p(5748),h=p(164),u=p(437),f=p(1336),r=p(1645),b=p(7066),S=p(9409),v=p(2369),w=p(8254),T=p(7533),g=p(4543),x=p(3123),P=p(4249),_=p(6438),B=p(8033),k=p(8927),R=p(164),F=p(4064),A=d(p(3065)),G=p(3263),U=p(6452),C=p(7435),z=p(3236),W=p(6362),$=p(3361),N=p(9161),Y=p(2221),tt=p(5875),H=p(1066),rt=p(624),ct=p(5824),st=p(5534),ot=p(9647);class ht{constructor(){this.staffEntriesWithGraphicalTies=[],this.staffEntriesWithOrnaments=[],this.staffEntriesWithChordSymbols=[],this.staffLinesWithLyricWords=[],this.graphicalLyricWords=[],this.abstractNotImplementedErrorMessage="abstract, not implemented",this.dynamicExpressionMap=new Map}static get TextMeasurer(){return ht.textMeasurer}static set TextMeasurer(O){ht.textMeasurer=O}get leadSheet(){return this.graphicalMusicSheet.LeadSheet}static setMeasuresMinStaffEntriesWidth(O,D){for(let j=0,Q=O.length;j0&&this.rules.RenderMultipleRestMeasures){yt.isReducedToMultiRest=!0,yt.multipleRestMeasureNumber=1;const Dt=yt.multipleRestMeasures-1;dt+=Dt;for(let Vt=1;Vt<=Dt;Vt++){const Nt=O.SourceMeasures.indexOf(yt)+Vt;if(Nt>=O.SourceMeasures.length)break;const It=O.SourceMeasures[Nt];It.multipleRestMeasureNumber=Vt+1,It.isReducedToMultiRest=!0,D.push([void 0])}}}if(this.rules.AutoGenerateMultipleRestMeasuresFromRestMeasures&&this.rules.RenderMultipleRestMeasures){let dt,mt=0;for(let yt=0,Et=O.SourceMeasures.length;yt0){dt.isReducedToMultiRest=!0,dt.multipleRestMeasureNumber=1,mt++,Dt.multipleRestMeasureNumber=mt,Dt.isReducedToMultiRest=!0;for(let Vt=0;Vt1){dt.multipleRestMeasures=mt;const Vt=this.createGraphicalMeasuresForSourceMeasure(dt,j,J,et,Q);D[dt.measureListIndex]=Vt,mt=0,dt=void 0}else mt=0,dt=void 0}if(mt>1){dt.multipleRestMeasures=mt,dt.isReducedToMultiRest=!0;const yt=this.createGraphicalMeasuresForSourceMeasure(dt,j,J,et,Q);D[dt.measureListIndex]=yt,mt=0,dt=void 0}}const it=Q.map(dt=>dt.ClefType===h.ClefEnum.percussion);this.handleStaffEntries(it),this.calculateVerticalContainersList(),this.setIndicesToVerticalGraphicalContainers()}calculate(){this.musicSystems=[],this.clearSystemsAndMeasures(),this.clearRecreatedObjects(),this.createGraphicalTies(),this.calculateSheetLabelBoundingBoxes(),this.calculateXLayout(this.graphicalMusicSheet,this.maxInstrNameLabelLength()),this.graphicalMusicSheet.MusicPages.length=0,this.calculateMusicSystems(),l.GraphicalMusicSheet.transformRelativeToAbsolutePosition(this.graphicalMusicSheet)}calculateXLayout(O,D){var j;if(this.graphicalMusicSheet.MeasureList.length>0){let Q,J=0,q=1;for(let et=0;etJ&&(J=it);const dt=this.graphicalMusicSheet.ParentMusicSheet.MeasureWidthFactor;for(const mt of Q)if(mt!=null&&mt.parentSourceMeasure.WidthFactor){q=mt.parentSourceMeasure.WidthFactor;break}it*=dt*q,ht.setMeasuresMinStaffEntriesWidth(Q,it)}if(this.rules.FixedMeasureWidth){let et=J;this.rules.FixedMeasureWidthFixedValue&&(et=this.rules.FixedMeasureWidthFixedValue);for(let it=0;it1;if(J===1&&D.Measures[0].parentSourceMeasure.ImplicitMeasure&&(et=!1),et)return;q.MeasureNumber!==0&&q.MeasureNumber!==1||(j=q.MeasureNumber),Q=q!==D.Measures[0]&&this.rules.MeasureNumberLabelXOffset?this.rules.MeasureNumberLabelXOffset:0;const it=this.rules.UseXMLMeasureNumbers&&q.MeasureNumber===1&&q.parentSourceMeasure.getPrintedMeasureNumber()!==1;((q.MeasureNumber===j||q.MeasureNumber>=j+this.rules.MeasureNumberLabelOffset)&&!q.parentSourceMeasure.ImplicitMeasure||it)&&((q.MeasureNumber!==1||q.MeasureNumber===1&&q!==D.Measures[0]||it)&&this.calculateSingleMeasureNumberPlacement(q,D,O,Q),j=q.MeasureNumber)}}calculateSingleMeasureNumberPlacement(O,D,j,Q=0){const J=O.parentSourceMeasure.getPrintedMeasureNumber().toString(),q=new C.Label(J),et=new w.GraphicalLabel(q,this.rules.MeasureNumberLabelHeight,T.TextAlignmentEnum.LeftBottom,this.rules),it=D.SkyBottomLineCalculator;et.setLabelPositionAndShapeBorders(),et.PositionAndShape.Parent=j.PositionAndShape;const dt=D.PositionAndShape.RelativePosition.x+O.PositionAndShape.RelativePosition.x-et.PositionAndShape.BorderMarginLeft+Q;let mt,yt=dt,Et=dt-et.PositionAndShape.BorderLeft+et.PositionAndShape.BorderRight;yt-=D.PositionAndShape.RelativePosition.x,Et-=D.PositionAndShape.RelativePosition.x;const Dt=yt+.5,Vt=Et-.5,Nt=it.getSkyLineMinInRange(Dt,Vt);if(O===D.Measures[0]){let It=0;if(j.GroupBrackets.length>0)for(const Ct of j.GroupBrackets)It=Math.min(It,Ct.PositionAndShape.BorderTop);else O.ParentStaff.ParentInstrument.Parent&&(It=-1);mt=Math.min(Nt,It)}else mt=Nt;mt=Math.min(0,mt),et.PositionAndShape.RelativePosition=new S.PointF2D(dt,mt),j.MeasureNumberLabels.push(et)}calculateMeasureNumberSkyline(O){const D=O.StaffLines[0];for(const j of O.MeasureNumberLabels){let Q=j.PositionAndShape.RelativePosition.x,J=Q-j.PositionAndShape.BorderLeft+j.PositionAndShape.BorderRight;Q-=D.PositionAndShape.RelativePosition.x,J-=D.PositionAndShape.RelativePosition.x,D.SkyBottomLineCalculator.updateSkyLineInRange(Q,J,j.PositionAndShape.RelativePosition.y+j.PositionAndShape.BorderMarginTop)}}layoutGraphicalTie(O,D,j){throw new Error(this.abstractNotImplementedErrorMessage)}calculateSingleStaffLineLyricsPosition(O,D){let j=0,Q=this.rules.StaffHeight;const J=new Map,q=[],et=O.SkyBottomLineCalculator;let it=O.Measures.length;for(let mt=0;mt0){q.push(Nt),j=Math.max(j,Nt.LyricsEntries.length);const Ct=Nt.PositionAndShape.RelativePosition.x+Et.x;let zt=Number.MAX_VALUE,Xt=Number.MIN_VALUE;for(let Kt=0;Kt0){const mt=O.PositionAndShape.Size.width;let yt=q[0].PositionAndShape.RelativePosition.x+q[0].PositionAndShape.BorderMarginLeft+q[0].parentMeasure.PositionAndShape.RelativePosition.x;yt=yt>mt?mt:yt,et.updateBottomLineInRange(yt,mt,dt)}return q}calculateLyricsExtendsAndDashes(O){for(let D=0,j=O.length;D0||O.UnknownList.length>0){let mt="";for(let Ct=0,zt=O.EntriesList.length;Ct-50){let Ct=et/10;Ct+=this.rules.PlaceWordsInsideStafflineYOffset,Vt.PositionAndShape.RelativePosition.y=Ct}const It=new ct.GraphicalUnknownExpression(yt,Vt,Dt,(dt=J[j])==null?void 0:dt.parentSourceMeasure,O);yt.AbstractExpressions.push(It)}}clearRecreatedObjects(){for(let O=0,D=this.staffEntriesWithGraphicalTies.length;OO.length-1&&(A.default.debug("minimum measure to draw index out of range. resetting min measure index to limit."),this.rules.MinMeasureToDrawIndex=O.length-1);const D=[];for(let J=this.rules.MinMeasureToDrawIndex,q=O.length;J0){let Xt=0;et.staffEntries[0].relInMeasureTimestamp.RealValue===0&&(Xt=et.staffEntries[0].PositionAndShape.RelativePosition.x,et.MeasureNumber===1&&(Xt+=this.rules.ChordSymbolWholeMeasureRestXOffsetMeasure1));let Ut=Xt+(et.PositionAndShape.Size.width-et.endInstructionsWidth-Xt)*(dt.relInMeasureTimestamp.RealValue/et.parentSourceMeasure.Duration.RealValue)+yt.PositionAndShape.BorderMarginLeft;it&&(Ut=Math.max(Ut,it.PositionAndShape.RelativePosition.x+it.GraphicalLabel.PositionAndShape.Size.width+this.rules.ChordSymbolXSpacing)),yt.PositionAndShape.RelativePosition.x=Ut,yt.PositionAndShape.Parent=et.staffEntries[0].PositionAndShape.Parent}const Et=yt.PositionAndShape,Dt=Et.Parent;if(Dt.DataObject instanceof s.GraphicalMeasure&&dt.relInMeasureTimestamp.RealValue===0&&(Et.RelativePosition.x=Math.max(et.beginInstructionsWidth,Et.RelativePosition.x),et.MeasureNumber===1&&Et.RelativePosition.x>3&&(Et.RelativePosition.x+=this.rules.ChordSymbolWholeMeasureRestXOffsetMeasure1)),dt.PositionAndShape.RelativePosition.x===0){const Xt=O.GraphicalMeasures[q];for(const Ut of Xt){let Kt=!1;for(const qt of Ut.staffEntries)if(qt.relInMeasureTimestamp===dt.relInMeasureTimestamp&&qt.PositionAndShape.RelativePosition.x!==0){Et.RelativePosition.x=qt.PositionAndShape.RelativePosition.x,Kt=!0;break}if(Kt)break}}const Vt=Et.BorderMarginLeft+Dt.AbsolutePosition.x+Et.RelativePosition.x,Nt=Et.BorderMarginRight+Dt.AbsolutePosition.x+Et.RelativePosition.x,It=yt.GetChordSymbolContainer.Placement;It===W.PlacementEnum.Below?(!this.rules.ChordSymbolYAlignment||J<0)&&(J=j.getBottomLineMaxInRange(Vt,Nt)):It===W.PlacementEnum.Above&&(!this.rules.ChordSymbolYAlignment||Q>0)&&(Q=j.getSkyLineMinInRange(Vt,Nt));let Ct=0;mt===0?(Ct+=this.rules.ChordSymbolYOffset,Ct+=.1):Ct+=this.rules.ChordSymbolYPadding,It!==W.PlacementEnum.Below&&(Ct*=-1);const zt=yt.GraphicalLabel;It===W.PlacementEnum.Below?(zt.PositionAndShape.RelativePosition.y=J+Ct,zt.setLabelPositionAndShapeBorders(),zt.PositionAndShape.calculateBoundingBox(),j.updateBottomLineInRange(Vt,Nt,J+zt.PositionAndShape.BorderMarginBottom+this.rules.ChordSymbolBottomMargin)):(zt.PositionAndShape.RelativePosition.y=Q+Ct,zt.setLabelPositionAndShapeBorders(),zt.PositionAndShape.calculateBoundingBox(),j.updateSkyLineInRange(Vt,Nt,Q+zt.PositionAndShape.BorderMarginTop)),it=yt}}}}calculateAlignedChordSymbolsOffset(O,D){let j=Number.MAX_SAFE_INTEGER,Q=Number.MIN_SAFE_INTEGER;for(const J of O)for(const q of J.graphicalChordContainers){const et=q.PositionAndShape,it=et.Parent;let dt=et.BorderMarginLeft+it.AbsolutePosition.x,mt=et.BorderMarginRight+it.AbsolutePosition.x;it.DataObject instanceof s.GraphicalMeasure&&(dt+=it.DataObject.beginInstructionsWidth,mt+=it.DataObject.beginInstructionsWidth);const yt=q.GetChordSymbolContainer.Placement;yt===W.PlacementEnum.Above?j=Math.min(j,D.getSkyLineMinInRange(dt,mt)):yt===W.PlacementEnum.Below&&(Q=Math.max(Q,D.getBottomLineMaxInRange(dt,mt)))}return{minOffset:j,maxOffset:Q}}layoutMeasureWithWholeRest(O,D,j){}layoutBeams(O){}layoutArticulationMarks(O,D,j){}layoutOrnament(O,D,j){}calculateRestNotePlacementWithinGraphicalBeam(O,D,j,Q,J){}calculateTupletNumbers(){if(!this.rules.TupletNumberLimitConsecutiveRepetitions)return;let O,D,j,Q=-1,J=0;const q={};for(const et of this.graphicalMusicSheet.ParentMusicSheet.Instruments)for(const it of et.Voices){J=0,q[it.VoiceId]={};for(const dt of it.VoiceEntries)if(dt.Notes.length>0){const mt=dt.Notes[0];if(!mt.NoteTuplet||mt.NoteTuplet.shouldBeBracketed(this.rules.TupletsBracketedUseXMLValue,this.rules.TupletsBracketed,this.rules.TripletsBracketed)){Q=-1,J=0,D=void 0,O=void 0;continue}if(mt.NoteTuplet===j)continue;let yt=mt.TypeLength;if(yt||(A.default.warn("note missing TypeLength"),yt=mt.NoteTuplet.Fractions[0]),mt.NoteTuplet!==D&&q[it.VoiceId][mt.NoteTuplet.TupletLabelNumber]&&q[it.VoiceId][mt.NoteTuplet.TupletLabelNumber][yt.RealValue]){mt.NoteTuplet.RenderTupletNumber=!1,j=mt.NoteTuplet;continue}mt.NoteTuplet.TupletLabelNumber===Q&&yt.Equals(O)&&!mt.NoteTuplet.Bracket||(Q=mt.NoteTuplet.TupletLabelNumber,O=yt,J=0),D=mt.NoteTuplet,J++,J<=this.rules.TupletNumberMaxConsecutiveRepetitions&&(mt.NoteTuplet.RenderTupletNumber=!0),J>this.rules.TupletNumberMaxConsecutiveRepetitions&&(mt.NoteTuplet.RenderTupletNumber=!1,this.rules.TupletNumberAlwaysDisableAfterFirstMax&&(q[it.VoiceId][Q]||(q[it.VoiceId][Q]={}),q[it.VoiceId][Q][yt.RealValue]=!0)),j=D}}}calculateSlurs(){}calculateGlissandi(){}calculateDynamicExpressionsForMultiExpression(O,D,j){}calculateGraphicalVerbalContinuousDynamic(O,D){const j=O.Label,Q=D.x+j.PositionAndShape.BorderMarginLeft,J=D.x+j.PositionAndShape.BorderMarginRight,q=O.ContinuousDynamic.Placement,et=O.ParentStaffLine.SkyBottomLineCalculator;let it;q===W.PlacementEnum.Below?(it=et.getBottomLineMaxInRange(Q,J),j.PositionAndShape.RelativePosition=new S.PointF2D(D.x,it-j.PositionAndShape.BorderMarginTop)):(it=et.getSkyLineMinInRange(Q,J),j.PositionAndShape.RelativePosition=new S.PointF2D(D.x,it-j.PositionAndShape.BorderMarginBottom))}calculateGraphicalContinuousDynamic(O,D){var xi;const j=O.IsSoftAccent,Q=O.ParentStaffLine.ParentStaff.idInMusicSheet,J=this.graphicalMusicSheet.getGraphicalMeasureFromSourceMeasureAndIndex(O.ContinuousDynamic.EndMultiExpression.SourceMeasureParent,Q);if(!J)return void A.default.warn("MusicSheetCalculator.calculateGraphicalContinuousDynamic: No endMeasure found");O.EndMeasure=J;const q=O.ParentStaffLine,et=J.ParentStaffLine,it=et&&q===et;let dt=!1;et?dt=et==null?void 0:et.isPartOfMultiStaffInstrument():q&&(dt=q==null?void 0:q.isPartOfMultiStaffInstrument());const mt=m.Fraction.createFromFraction(O.ContinuousDynamic.EndMultiExpression.AbsoluteTimestamp),yt=this.graphicalMusicSheet.GetVerticalContainerFromTimestamp(mt),Et=yt.getFirstNonNullStaffEntry().parentMeasure,Dt=Et.PositionAndShape.AbsolutePosition.x+Et.PositionAndShape.BorderRight;let Vt=new m.Fraction(0,0,0);for(const Ce of yt.StaffEntries){if((Ce==null?void 0:Ce.sourceStaffEntry.ParentStaff)!==q.ParentStaff)continue;const Re=(xi=Ce==null?void 0:Ce.sourceStaffEntry)==null?void 0:xi.calculateMaxNoteLength(!1);Re!=null&&Re.gt(Vt)&&(Vt=Re)}const Nt=!j&&O.ContinuousDynamic.DynamicType===tt.ContDynamicEnum.diminuendo,It=this.getRelativePositionInStaffLineFromTimestamp(mt,Q,et,dt,0,Nt),Ct=m.Fraction.plus(mt,Vt).clone();O.ContinuousDynamic.EndMultiExpression.EndOffsetFraction&&this.rules.UseEndOffsetForExpressions&&Ct.Add(O.ContinuousDynamic.EndMultiExpression.EndOffsetFraction);const zt=this.getRelativePositionInStaffLineFromTimestamp(Ct,Q,et,dt,0,O.ContinuousDynamic.DynamicType===tt.ContDynamicEnum.diminuendo),Xt=this.rules.SoftAccentWedgePadding,Ut=yt.getFirstNonNullStaffEntry().PositionAndShape.Size.width,Kt=this.rules.SoftAccentSizeFactor;j?(D.x-=Ut/2*Kt+Xt,It.x=D.x+Ut/2*Kt):zt.x>It.x&&zt.x$t){const Te=Qt.StaffLines[Ce].PositionAndShape.RelativePosition.y-q.PositionAndShape.RelativePosition.y-this.rules.StaffHeight;we=this.rules.StaffHeight+Te/2}else we=this.rules.WedgePlacementBelowY;we-=this.rules.WedgeOpeningLength/2,it||(Ge=we);let Re=ie.getBottomLineMaxInRange(Ke,Xe);Re>we&&(we=Re);const He=!1;if($tGe&&(Ge=Re),Ge+=this.rules.WedgeOpeningLength/2,Ge+=this.rules.WedgeVerticalMargin),we+=this.rules.WedgeOpeningLength/2,we+=this.rules.WedgeVerticalMargin}else if(Jt===W.PlacementEnum.Above){if(q.ParentStaff.ParentInstrument.Staves.length===1)we=this.rules.WedgePlacementAboveY;else{let Re=0;$t>0&&(Re=$t-1);const He=Qt.StaffLines[Re];we=-(q.PositionAndShape.RelativePosition.y-He.PositionAndShape.RelativePosition.y-this.rules.StaffHeight)/2}we+=this.rules.WedgeOpeningLength/2,it||(Ge=we);let Ce=ie.getSkyLineMinInRange(Ke,Xe);if(Ce1&&$t>0){const Re=q.findClosestStaffEntry(Ke),He=q.findClosestStaffEntry(Xe);Re&&He&&Re.parentVerticalContainer}it||(Ce=et.SkyBottomLineCalculator.getSkyLineMinInRange(De,Pi),CeTe&&(Te=Ye),Te+=this.rules.WedgeOpeningLength/2,Te+=this.rules.WedgeVerticalMargin}else if(Jt===W.PlacementEnum.Above){const Ye=He.SkyBottomLineCalculator.getSkyLineMinInRange(De,Pi);Ye-yt/2?-yt/2:dt-O.PositionAndShape.BorderMarginBottom}}else it=dt-O.PositionAndShape.BorderMarginBottom;O.PositionAndShape.RelativePosition=new S.PointF2D(D.x,it)}else if(O.Placement===W.PlacementEnum.Below){const dt=et.getBottomLineMaxInRange(J,q),mt=Q.ParentStaff.ParentInstrument.Staves[Q.ParentStaff.ParentInstrument.Staves.length-1];if(Q.isPartOfMultiStaffInstrument()&&Q.ParentStaff!==mt){const yt=Q.ParentMusicSystem.StaffLines[Q.ParentMusicSystem.StaffLines.indexOf(Q)+1];if(yt){const Et=yt.PositionAndShape.RelativePosition.y-Q.PositionAndShape.RelativePosition.y-this.rules.StaffHeight;it=dt+O.PositionAndShape.BorderMarginBottomO.PositionAndShape.Size.width&&(Vt=O.PositionAndShape.Size.width-this.rules.MeasureRightMargin,Dt=Vt-mt.PositionAndShape.MarginSize.width,D.x=Dt-mt.PositionAndShape.BorderMarginLeft),Dt0||!J[0])return;let et=J[0].ParentStaffLine,it=J[0].PositionAndShape.RelativePosition.x,dt=0;for(let mt=0;mt0){et=J[mt].ParentStaffLine,it=J[mt].PositionAndShape.RelativePosition.x,dt=mt;break}if(q=this.getRelativePositionInStaffLineFromTimestamp(Q,dt,et,et.isPartOfMultiStaffInstrument(),it),D.EntriesList.length>0&&D.EntriesList[0].Expression instanceof N.InstantaneousTempoExpression&&(D.EntriesList[0].Expression.Placement=W.PlacementEnum.Above,et.Measures[0].staffEntries.length>0&&Math.abs(q.x-et.Measures[0].staffEntries[0].PositionAndShape.RelativePosition.x)===0&&et.ParentMusicSystem===this.musicSystems[0])){const mt=et.Measures[0].FirstInstructionStaffEntry;if(mt){const yt=mt.GraphicalInstructions.last();q.x=yt.PositionAndShape.RelativePosition.x}this.rules.CompactMode&&(q.x=et.PositionAndShape.RelativePosition.x+et.Measures[0].PositionAndShape.RelativePosition.x)}for(const mt of D.EntriesList){let yt=this.rules.TempoExpressionTextAlignment;this.rules.CompactMode&&(yt=T.TextAlignmentEnum.LeftBottom);const Et=this.calculateLabel(et,q,mt.label,D.getFontstyleOfFirstEntry(),mt.Expression.Placement,this.rules.UnknownTextHeight,yt,this.rules.TempoYSpacing);if(mt.Expression.ColorXML&&this.rules.ExpressionsUseXMLColor&&(Et.ColorXML=mt.Expression.ColorXML),mt.Expression instanceof N.InstantaneousTempoExpression){for(const Dt of et.AbstractExpressions)Dt instanceof $.GraphicalInstantaneousTempoExpression&&(Dt.SourceExpression.Label,mt.Expression.Label);if(new $.GraphicalInstantaneousTempoExpression(mt.Expression,Et).ParentStaffLine||A.default.warn("Adding staffline didn't work"),this.rules.MetronomeMarksDrawn&&mt.Expression.TempoType===N.TempoType.metronomeMark){this.createMetronomeMark(mt.Expression);continue}}else if(mt.Expression instanceof Y.ContinuousTempoExpression){for(const Dt of et.AbstractExpressions)Dt instanceof $.GraphicalInstantaneousTempoExpression&&(Dt.SourceExpression.Label,mt.Expression.Label);et.AbstractExpressions.push(new $.GraphicalInstantaneousTempoExpression(mt.Expression,Et))}}}}createMetronomeMark(O){throw new Error(this.abstractNotImplementedErrorMessage)}graphicalMeasureCreatedCalculations(O){}clearSystemsAndMeasures(){for(let O=0,D=this.graphicalMusicSheet.MusicPages.length;O-1&&Et.PositionAndShape.ChildElements.splice(Dt,1),Et.FirstInstructionStaffEntry=void 0,Et.beginInstructionsWidth=0}if(Et.LastInstructionStaffEntry){const Dt=Et.PositionAndShape.ChildElements.indexOf(Et.LastInstructionStaffEntry.PositionAndShape);Dt>-1&&Et.PositionAndShape.ChildElements.splice(Dt,1),Et.LastInstructionStaffEntry=void 0,Et.endInstructionsWidth=0}}dt.Measures=[],dt.PositionAndShape.ChildElements=[]}q.StaffLines.length=0,q.PositionAndShape.ChildElements=[]}j.MusicSystems=[],j.PositionAndShape.ChildElements=[]}this.graphicalMusicSheet.MusicPages=[]}handleVoiceEntry(O,D,j,Q,J,q,et,it,dt,mt=void 0,yt=void 0){O.StemDirectionXml!==f.StemDirectionType.Undefined&&this.rules.SetWantedStemDirectionByXml&&O.StemDirectionXml!==void 0?O.WantedStemDirection=O.StemDirectionXml:this.calculateStemDirectionFromVoices(O);const Et=D.findOrCreateGraphicalVoiceEntry(O);Et.octaveShiftValue=it;const Dt=D.tabStaffEntry;let Vt;Dt&&(Vt=Dt.findOrCreateGraphicalVoiceEntry(O));for(let Nt=0,It=O.Notes.length;Nt-1)continue;let zt;if(O.IsGrace?zt=ht.symbolFactory.createGraceNote(Ct,Et,J,this.rules,it):(zt=ht.symbolFactory.createNote(Ct,Et,J,it,this.rules,void 0),ht.stafflineNoteCalculator.trackNote(zt)),Ct.Pitch&&this.checkNoteForAccidental(zt,j,J,it),this.resetYPositionForLeadSheet(zt.PositionAndShape),D.addGraphicalNoteToListAtCorrectYPosition(Et,zt),zt.PositionAndShape.calculateBoundingBox(),this.leadSheet||(Ct.NoteBeam!==void 0&&Ct.PrintObject&&(Ct instanceof ot.TabNote&&!this.rules.TabBeamsRendered||this.handleBeam(zt,Ct.NoteBeam,et)),Ct.NoteTuplet!==void 0&&Ct.PrintObject&&this.handleTuplet(zt,Ct.NoteTuplet,q)),Vt){const Xt=ht.symbolFactory.createNote(Ct,Vt,J,it,this.rules,void 0);Dt.addGraphicalNoteToListAtCorrectYPosition(Vt,Xt),Xt.PositionAndShape.calculateBoundingBox(),this.leadSheet||Ct.NoteTuplet&&this.handleTuplet(Xt,Ct.NoteTuplet,q)}}return O.Articulations.length>0&&this.handleVoiceEntryArticulations(O.Articulations,O,D),O.TechnicalInstructions.length>0&&this.handleVoiceEntryTechnicalInstructions(O.TechnicalInstructions,O,D),O.LyricsEntries.size()>0&&this.handleVoiceEntryLyrics(O,D,Q),O.OrnamentContainer&&this.handleVoiceEntryOrnaments(O.OrnamentContainer,O,D),it}resetYPositionForLeadSheet(O){this.leadSheet&&(O.RelativePosition=new S.PointF2D(O.RelativePosition.x,0))}layoutVoiceEntries(O,D){if(O.PositionAndShape.RelativePosition=new S.PointF2D(0,0),!this.leadSheet)for(const j of O.graphicalVoiceEntries){const Q=j.notes;if(Q.length===0)continue;const J=Q[0].sourceNote.ParentVoiceEntry,q=Q[0].sourceNote.Pitch!==void 0;this.layoutVoiceEntry(J,Q,O,q)}}maxInstrNameLabelLength(){var D;let O=0;for(const j of this.graphicalMusicSheet.ParentMusicSheet.Instruments)if((D=j.NameLabel)!=null&&D.print&&j.Voices.length>0&&j.Voices[0].Visible){let Q=j.NameLabel;this.rules.RenderPartNames||(Q=new C.Label("",Q.textAlignment,Q.font));const J=new w.GraphicalLabel(Q,this.rules.InstrumentLabelTextHeight,T.TextAlignmentEnum.LeftCenter,this.rules);J.setLabelPositionAndShapeBorders(),O=Math.max(O,J.PositionAndShape.MarginSize.width)}return this.rules.RenderPartNames?O:0}calculateSheetLabelBoundingBoxes(){const O=this.graphicalMusicSheet.ParentMusicSheet,D=this.rules.DefaultColorTitle;if(O.Title!==void 0&&this.rules.RenderTitle){const j=new w.GraphicalLabel(O.Title,this.rules.SheetTitleHeight,T.TextAlignmentEnum.CenterBottom,this.rules);j.Label.IsCreditLabel=!0,j.Label.colorDefault=D,this.graphicalMusicSheet.Title=j,j.setLabelPositionAndShapeBorders()}else this.rules.RenderTitle||(this.graphicalMusicSheet.Title=void 0);if(O.Subtitle!==void 0&&this.rules.RenderSubtitle){const j=new w.GraphicalLabel(O.Subtitle,this.rules.SheetSubtitleHeight,T.TextAlignmentEnum.CenterCenter,this.rules);j.Label.IsCreditLabel=!0,j.Label.colorDefault=D,this.graphicalMusicSheet.Subtitle=j,j.setLabelPositionAndShapeBorders()}else this.rules.RenderSubtitle||(this.graphicalMusicSheet.Subtitle=void 0);if(O.Composer!==void 0&&this.rules.RenderComposer){const j=new w.GraphicalLabel(O.Composer,this.rules.SheetComposerHeight,T.TextAlignmentEnum.RightCenter,this.rules);j.Label.IsCreditLabel=!0,j.Label.colorDefault=D,this.graphicalMusicSheet.Composer=j,j.setLabelPositionAndShapeBorders()}else this.rules.RenderComposer||(this.graphicalMusicSheet.Composer=void 0);if(O.Lyricist!==void 0&&this.rules.RenderLyricist){const j=new w.GraphicalLabel(O.Lyricist,this.rules.SheetAuthorHeight,T.TextAlignmentEnum.LeftCenter,this.rules);j.Label.IsCreditLabel=!0,j.Label.colorDefault=D,this.graphicalMusicSheet.Lyricist=j,j.setLabelPositionAndShapeBorders()}else this.rules.RenderLyricist||(this.graphicalMusicSheet.Lyricist=void 0);if(O.Copyright!==void 0&&this.rules.RenderCopyright){const j=new w.GraphicalLabel(O.Copyright,this.rules.SheetCopyrightHeight,T.TextAlignmentEnum.CenterBottom,this.rules);j.Label.IsCreditLabel=!0,j.Label.colorDefault=D,this.graphicalMusicSheet.Copyright=j,j.setLabelPositionAndShapeBorders()}else this.rules.RenderCopyright||(this.graphicalMusicSheet.Copyright=void 0)}checkMeasuresForWholeRestNotes(){for(let O=0,D=this.musicSystems.length;O0&&mt.graphicalVoiceEntries[0].notes.length===1){const yt=mt.graphicalVoiceEntries[0].notes[0];!yt.sourceNote.Pitch&&new m.Fraction(1,2).lt(yt.sourceNote.Length)&&this.layoutMeasureWithWholeRest(yt,mt,dt)}}}}}}optimizeRestNotePlacement(O,D){if(O.graphicalVoiceEntries.length===0)return;const j=O.graphicalVoiceEntries[0].notes;if(j.length===0)return;const Q=j[0],J=Q.sourceNote.isRest();if(O.graphicalVoiceEntries.length===2){let q=!1;const et=O.graphicalVoiceEntries[1].notes;et.length>0&&(q=et[0].sourceNote.isRest()),J&&q?this.calculateTwoRestNotesPlacementWithCollisionDetection(O):(J||q)&&this.calculateRestNotePlacementWithCollisionDetectionFromGraphicalNote(O)}else if(J&&O!==D.staffEntries[0]&&O!==D.staffEntries[D.staffEntries.length-1]){const q=D.staffEntries.indexOf(O),et=D.staffEntries[q-1],it=D.staffEntries[q+1];if(et.graphicalVoiceEntries.length===1){const dt=et.graphicalVoiceEntries[0].notes[0];if(dt.sourceNote.NoteBeam!==void 0&&it.graphicalVoiceEntries.length===1){const mt=it.graphicalVoiceEntries[0].notes[0];mt.sourceNote.NoteBeam!==void 0&&dt.sourceNote.NoteBeam===mt.sourceNote.NoteBeam&&(this.calculateRestNotePlacementWithinGraphicalBeam(O,Q,dt,it,mt),O.PositionAndShape.calculateBoundingBox())}}}}getRelativePositionInStaffLineFromTimestamp(O,D,j,Q,J=0,q=!1){let et,it,dt=new S.PointF2D;const mt=this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers.length,yt=this.graphicalMusicSheet.GetInterpolatedIndexInVerticalContainers(O),Et=Math.min(Math.floor(yt),mt-1),Dt=Math.min(Math.ceil(yt),mt-1);if(Et<0||D<0)return dt;if(et=this.getFirstLeftNotNullStaffEntryFromContainer(Et,D,Q),it=this.getFirstRightNotNullStaffEntryFromContainer(Dt,D,Q),et&&it){let Vt=et.parentMeasure.PositionAndShape.RelativePosition.x;J>0&&(Vt=J);let Nt=et.PositionAndShape.RelativePosition.x+Vt,It=it.PositionAndShape.RelativePosition.x+it.parentMeasure.PositionAndShape.RelativePosition.x;const Ct=O.RealValue>it.getAbsoluteTimestamp().RealValue;J>0?It=it.PositionAndShape.RelativePosition.x+Vt:q&&(et.getAbsoluteTimestamp().RealValue===O.RealValue||Ct)&&(Nt=et.PositionAndShape.RelativePosition.x+et.PositionAndShape.BorderLeft+Vt,It=Nt);let zt=0;if(et!==it){const Xt=et.getAbsoluteTimestamp(),Ut=it.getAbsoluteTimestamp();zt=m.Fraction.minus(O,Xt).RealValue/m.Fraction.minus(Ut,Xt).RealValue}et.parentMeasure.ParentStaffLine!==it.parentMeasure.ParentStaffLine&&(et.parentMeasure.ParentStaffLine===j?It=j.PositionAndShape.Size.width:Nt=j.PositionAndShape.RelativePosition.x),dt=new S.PointF2D(Nt+(It-Nt)*zt,0)}return dt}getRelativeXPositionFromTimestamp(O){const D=this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers.length,j=this.graphicalMusicSheet.GetInterpolatedIndexInVerticalContainers(O),Q=Math.max(0,Math.min(Math.round(j),D-1)),J=this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers[Q].getFirstNonNullStaffEntry();return J.PositionAndShape.RelativePosition.x+J.parentMeasure.PositionAndShape.RelativePosition.x}calculatePageLabels(O){var dt,mt;this.rules.RenderSingleHorizontalStaffline&&(O.PositionAndShape.calculateBoundingBox([s.GraphicalMeasure.name]),this.graphicalMusicSheet.ParentMusicSheet.pageWidth=O.PositionAndShape.Size.width);let D=10,j=-1;if(O.MusicSystems.length>0){const yt=O.MusicSystems[0];D=yt.PositionAndShape.RelativePosition.y+yt.PositionAndShape.BorderTop;const Et=O.MusicSystems[O.MusicSystems.length-1];j=Et.PositionAndShape.RelativePosition.y+Et.PositionAndShape.BorderBottom}const Q=this.graphicalMusicSheet.Title;if(Q&&this.rules.RenderTitle){Q.PositionAndShape.Parent=O.PositionAndShape;const yt=new S.PointF2D;yt.x=this.graphicalMusicSheet.ParentMusicSheet.pageWidth/2,this.rules.RenderSingleHorizontalStaffline&&(yt.x=Math.max(yt.x,Q.PositionAndShape.Size.width)),yt.y=this.rules.TitleTopDistance+this.rules.SheetTitleHeight,Q.PositionAndShape.RelativePosition=yt,O.Labels.push(Q)}if(this.graphicalMusicSheet.Subtitle&&this.rules.RenderTitle&&this.rules.RenderSubtitle){const yt=this.graphicalMusicSheet.Subtitle;yt.PositionAndShape.Parent=O.PositionAndShape;const Et=new S.PointF2D;Et.x=this.graphicalMusicSheet.ParentMusicSheet.pageWidth/2,this.rules.RenderSingleHorizontalStaffline&&(Et.x=Q.PositionAndShape.RelativePosition.x),Et.y=this.rules.TitleTopDistance+this.rules.SheetTitleHeight+this.rules.SheetMinimumDistanceBetweenTitleAndSubtitle;const Dt=(dt=yt.TextLines)==null?void 0:dt.length;Dt>1&&(Et.y+=yt.PositionAndShape.BorderBottom*(Dt-1)/Dt),yt.PositionAndShape.RelativePosition=Et,O.Labels.push(yt)}const J=this.graphicalMusicSheet.Composer;let q;if(J&&this.rules.RenderComposer){J.PositionAndShape.Parent=O.PositionAndShape,J.setLabelPositionAndShapeBorders();const yt=new S.PointF2D;yt.x=this.graphicalMusicSheet.ParentMusicSheet.pageWidth-this.rules.PageRightMargin,yt.y=D,yt.y-=this.rules.SystemComposerDistance;const Et=(mt=J.TextLines)==null?void 0:mt.length;Et>1&&(yt.y-=J.PositionAndShape.BorderBottom*(Et-1)/Et),q=yt.y,J.PositionAndShape.RelativePosition=yt,O.Labels.push(J)}const et=this.graphicalMusicSheet.Lyricist;if(et&&this.rules.RenderLyricist){et.PositionAndShape.Parent=O.PositionAndShape,et.setLabelPositionAndShapeBorders();const yt=new S.PointF2D;yt.x=this.rules.PageLeftMargin,yt.y=D,yt.y-=this.rules.SystemLyricistDistance,yt.y+=et.PositionAndShape.BorderBottom,yt.y=Math.min(yt.y,q??Number.MAX_SAFE_INTEGER),et.PositionAndShape.RelativePosition=yt,O.Labels.push(et)}const it=this.graphicalMusicSheet.Copyright;if(it&&this.rules.RenderCopyright){it.PositionAndShape.Parent=O.PositionAndShape,it.setLabelPositionAndShapeBorders();const yt=new S.PointF2D;yt.x=O.PositionAndShape.Size.width/2,yt.y=j+this.rules.SheetCopyrightMargin,yt.y-=it.PositionAndShape.BorderTop,it.PositionAndShape.RelativePosition=yt,O.Labels.push(it)}this.rules.RenderSingleHorizontalStaffline&&(O.PositionAndShape.calculateBoundingBox([s.GraphicalMeasure.name]),this.graphicalMusicSheet.ParentMusicSheet.pageWidth=O.PositionAndShape.Size.width)}createGraphicalTies(){for(let O=0;O=0&&this.staffEntriesWithGraphicalTies.push(it)}it=q}}setTieDirections(O){if(!O)return;const D=O.ties;if(D.length===1){const j=D[0];if(j.TieDirection===W.PlacementEnum.NotYetDefined){const Q=j.Notes[0].ParentVoiceEntry.ParentVoice.VoiceId;Q!==2&&Q!==6||(j.TieDirection=W.PlacementEnum.Below)}}if(D.length>1){let j;for(const Q of D){const J=Q.Notes[0];(!j||J.Pitch.getHalfTone()>j.Pitch.getHalfTone())&&(j=J)}for(const Q of D)Q.TieDirection===W.PlacementEnum.NotYetDefined&&(Q.Notes[0]===j?Q.TieDirection=W.PlacementEnum.Above:Q.TieDirection=W.PlacementEnum.Below)}}createAccidentalCalculators(){var j;const O=[],D=this.graphicalMusicSheet.ParentMusicSheet.getFirstSourceMeasure();if(D){const Q=this.graphicalMusicSheet.ParentMusicSheet.Transpose;for(let J=0;J1)return;yt=ht.symbolFactory.createGraphicalMeasure(O,mt)}if(yt.hasError=O.getErrorInMeasure(it),O.FirstInstructionsStaffEntries[it])for(let Ut=0,Kt=O.FirstInstructionsStaffEntries[it].Instructions.length;Ut0&&((Ct=$t.ParentEndMultiExpression)!=null&&Ct.AbsoluteTimestamp.Equals(Kt.AbsoluteTimestamp))&&Jt>=$t.endVoiceEntryIndex&&(ie=u.OctaveEnum.NONE,$t=void 0),ie=this.handleVoiceEntry(Ke,qt,Q,et,J[it],D,j,ie,it,Qt,Kt)}for(const Jt of Kt.Instructions)if(Jt instanceof h.ClefInstruction){ht.symbolFactory.createInStaffClef(qt,Jt);break}this.rules.RenderChordSymbols&&((zt=Kt.ChordContainers)==null?void 0:zt.length)>0&&(Kt.ParentStaff.ParentInstrument.HasChordSymbols=!0,ht.symbolFactory.createChordSymbols(Kt,qt,Q.ActiveKeyInstruction,this.graphicalMusicSheet.ParentMusicSheet.Transpose))}}if(Q.doCalculationsAtEndOfMeasure(),O.LastInstructionsStaffEntries[it]){const Ut=O.LastInstructionsStaffEntries[it];for(let Kt=0,qt=Ut.Instructions.length;Kt=1&&yt.staffEntries.length===0){const Ut=new v.SourceStaffEntry(new z.VerticalSourceStaffEntryContainer(yt.parentSourceMeasure,yt.parentSourceMeasure.AbsoluteTimestamp,yt.parentSourceMeasure.CompleteNumberOfStaves),mt);if(mt.Voices.length===0){const oe=new st.Voice(yt.ParentStaff.ParentInstrument,-1);mt.Voices.push(oe)}const Kt=new f.VoiceEntry(new m.Fraction(0,1),mt.Voices[0],Ut);let qt=O.Duration;qt.RealValue===0&&(qt=O.ActiveTimeSignature.clone());const Qt=new o.Note(Kt,Ut,qt,void 0,O,!0);Qt.IsWholeMeasureRest=!0,Qt.PrintObject=this.rules.FillEmptyMeasuresWithWholeRest===rt.FillEmptyMeasuresWithWholeRests.YesVisible,Kt.Notes.push(Qt);const $t=ht.symbolFactory.createStaffEntry(Ut,yt);yt.addGraphicalStaffEntry($t),$t.relInMeasureTimestamp=Kt.Timestamp;const ie=ht.symbolFactory.createVoiceEntry(Kt,$t);$t.graphicalVoiceEntries.push(ie);const Jt=ht.symbolFactory.createNote(Qt,ie,new h.ClefInstruction,u.OctaveEnum.NONE,this.rules);ht.stafflineNoteCalculator.trackNote(Jt),ie.notes.push(Jt)}yt.hasOnlyRests=!0;for(const Ut of yt.staffEntries)if(yt.hasOnlyRests=Ut.hasOnlyRests(),!yt.hasOnlyRests)break;return yt}checkNoteForAccidental(O,D,j,Q){let J=O.sourceNote.Pitch;const q=O.parentVoiceEntry.parentStaffEntry.parentMeasure.getTransposedHalftones();q!==0&&O.sourceNote.ParentStaffEntry.ParentStaff.ParentInstrument.MidiInstrumentId!==R.MidiInstrument.Percussion?(J=O.Transpose(D.ActiveKeyInstruction,j,q,Q),O.sourceNote.TransposedPitch=J):O.sourceNote.TransposedPitch=void 0,O.sourceNote.halfTone=J.getHalfTone(),D.checkAccidental(O,J)}handleStaffEntries(O){for(let D=0,j=this.graphicalMusicSheet.MeasureList.length;D0&&!this.rules.PercussionUseCajon2NoteSystem&&O[J]&&(this.rules.PercussionOneLineCutoff===-1||ht.stafflineNoteCalculator.getStafflineUniquePositionCount(J)0&&it.graphicalVoiceEntries[0].notes.length>0&&(this.layoutVoiceEntries(it,J),this.layoutStaffEntry(it));this.graphicalMeasureCreatedCalculations(et)}}}}calculateSkyBottomLines(){}calculateExpressionAlignements(){}calculateStaffEntryArticulationMarks(){for(let O=0,D=this.musicSystems.length;O0&&this.layoutArticulationMarks(Nt.Articulations,Nt,Et)}}}}}}calculateOrnaments(){for(let O=0,D=this.musicSystems.length;O0){let yt;q===W.PlacementEnum.Below&&mt.reverse();for(const Et of et.graphicalVoiceEntries)for(const Dt of Et.notes)(!yt||((O=Dt.sourceNote.Pitch)==null?void 0:O.getHalfTone())>((D=yt.Pitch)==null?void 0:D.getHalfTone()))&&(yt=Dt.sourceNote);mt[0].sourceNote===yt&&q===W.PlacementEnum.Above&&mt.reverse()}for(let yt=0;yt0&&Q.LyricVersesNumbers.sort()}for(let D=0,j=this.musicSystems.length;D=0&&(Q=D.GraphicalLyricsEntries[j+1]),!Q)return;const J=O.StaffEntryParent.parentMeasure.ParentStaffLine,q=Q.StaffEntryParent.parentMeasure.ParentStaffLine,et=O.StaffEntryParent,it=Q.StaffEntryParent;if(O.StaffEntryParent.parentMeasure.ParentStaffLine===Q.StaffEntryParent.parentMeasure.ParentStaffLine){const dt=et.parentMeasure.PositionAndShape.RelativePosition.x+et.PositionAndShape.RelativePosition.x+O.GraphicalLabel.PositionAndShape.RelativePosition.x+O.GraphicalLabel.PositionAndShape.BorderMarginRight-O.GraphicalLabel.CenteringXShift,mt=it.parentMeasure.PositionAndShape.RelativePosition.x+it.PositionAndShape.RelativePosition.x+O.GraphicalLabel.PositionAndShape.RelativePosition.x+Q.GraphicalLabel.PositionAndShape.BorderMarginLeft,yt=O.GraphicalLabel.PositionAndShape.RelativePosition.y;let Et=1;mt-dt>3*this.rules.MinimumDistanceBetweenDashes&&(Et=Math.floor((mt-dt)/this.rules.MinimumDistanceBetweenDashes)-1),Et===1?this.calculateSingleDashForLyricWord(J,dt,mt,yt):this.calculateDashes(J,dt,mt,yt)}else{const dt=et.parentMeasure.PositionAndShape.RelativePosition.x+et.PositionAndShape.RelativePosition.x+O.GraphicalLabel.PositionAndShape.BorderMarginRight,mt=J.Measures[J.Measures.length-1],yt=mt.PositionAndShape.RelativePosition.x+mt.PositionAndShape.Size.width;let Et=O.GraphicalLabel.PositionAndShape.RelativePosition.y;if(this.calculateDashes(J,dt,yt,Et),q&&q.Measures[0]&&it.parentMeasure.ParentStaffLine&&(it!==it.parentMeasure.staffEntries[0]||it.parentMeasure!==it.parentMeasure.ParentStaffLine.Measures[0])){const Dt=q.Measures[0].staffEntries[0].PositionAndShape.RelativePosition.x,Vt=it.parentMeasure.PositionAndShape.RelativePosition.x+it.PositionAndShape.RelativePosition.x+Q.GraphicalLabel.PositionAndShape.BorderMarginLeft;Et=Q.GraphicalLabel.PositionAndShape.RelativePosition.y,this.calculateDashes(q,Dt,Vt,Et)}}}calculateDashes(O,D,j,Q){let J=j-D;if(J<3*this.rules.MinimumDistanceBetweenDashes)this.calculateSingleDashForLyricWord(O,D,j,Q);else{const q=Math.floor(J/this.rules.MinimumDistanceBetweenDashes)-1,et=J/(q+1);let it=0;for(D+=et,j-=et;it<=Math.floor(q/2)&&j>D;)J=this.calculateRightAndLeftDashesForLyricWord(O,D,j,Q),D+=et,j-=et,it++;J>2*et&&this.calculateSingleDashForLyricWord(O,D,j,Q)}}calculateSingleDashForLyricWord(O,D,j,Q){const J=new C.Label("-");J.colorDefault=this.rules.DefaultColorLyrics;let q=this.rules.LyricsHeight;j-D<.8&&(q*=.8,Q-=.1*q);const et=new w.GraphicalLabel(J,q,T.TextAlignmentEnum.CenterBottom,this.rules);et.setLabelPositionAndShapeBorders(),O.LyricsDashes.push(et),this.staffLinesWithLyricWords.indexOf(O)===-1&&this.staffLinesWithLyricWords.push(O),et.PositionAndShape.Parent=O.PositionAndShape;const it=new S.PointF2D(D+(j-D)/2,Q);et.PositionAndShape.RelativePosition=it}calculateLyricExtend(O){let D=O.GraphicalLabel.PositionAndShape.RelativePosition.y;const j=O.StaffEntryParent,Q=j.parentMeasure.ParentStaffLine;let J,q;const et=j.parentMeasure.ParentStaff.idInMusicSheet;if(j.parentVerticalContainer){for(let it=j.parentVerticalContainer.Index+1;it0)break;J=dt,q=J.parentMeasure.ParentStaffLine,q||(q=j.parentMeasure.ParentStaffLine)}}if(J&&q)if(Q===q&&J.parentMeasure.ParentStaffLine){const it=j.parentMeasure.PositionAndShape.RelativePosition.x+j.PositionAndShape.RelativePosition.x+O.GraphicalLabel.PositionAndShape.BorderMarginRight,dt=J.parentMeasure.PositionAndShape.RelativePosition.x+J.PositionAndShape.RelativePosition.x+J.PositionAndShape.BorderMarginRight;D-=O.GraphicalLabel.PositionAndShape.Size.height/4,this.calculateSingleLyricWordWithUnderscore(Q,it,dt,D)}else{const it=Q.Measures[Q.Measures.length-1].PositionAndShape,dt=j.parentMeasure.PositionAndShape.RelativePosition.x+j.PositionAndShape.RelativePosition.x+O.GraphicalLabel.PositionAndShape.BorderMarginRight,mt=it.RelativePosition.x+it.Size.width;if(D-=O.GraphicalLabel.PositionAndShape.Size.height/4,this.calculateSingleLyricWordWithUnderscore(Q,dt,mt,D),!J)return;if(J.parentMeasure.ParentStaffLine&&J.parentMeasure.staffEntries&&(J!==J.parentMeasure.staffEntries[0]||J.parentMeasure!==J.parentMeasure.ParentStaffLine.Measures[0])){const yt=q.Measures[0].staffEntries[0].PositionAndShape.RelativePosition.x,Et=J.parentMeasure.PositionAndShape.RelativePosition.x+J.PositionAndShape.RelativePosition.x+J.PositionAndShape.BorderMarginRight;this.calculateSingleLyricWordWithUnderscore(q,yt,Et,D)}}}}calculateSingleLyricWordWithUnderscore(O,D,j,Q){const J=new S.PointF2D(D,Q),q=new S.PointF2D(j,Q),et=new U.GraphicalLine(J,q,this.rules.LyricUnderscoreLineWidth);et.colorHex=this.rules.DefaultColorLyrics,O.LyricLines.push(et),this.staffLinesWithLyricWords.indexOf(O)===-1&&this.staffLinesWithLyricWords.push(O)}calculateRightAndLeftDashesForLyricWord(O,D,j,Q){const J=new C.Label("-");J.colorDefault=this.rules.DefaultColorLyrics;const q=new w.GraphicalLabel(J,this.rules.LyricsHeight,T.TextAlignmentEnum.CenterBottom,this.rules);q.setLabelPositionAndShapeBorders(),O.LyricsDashes.push(q),this.staffLinesWithLyricWords.indexOf(O)===-1&&this.staffLinesWithLyricWords.push(O),q.PositionAndShape.Parent=O.PositionAndShape;const et=new S.PointF2D(D,Q);q.PositionAndShape.RelativePosition=et;const it=new C.Label("-"),dt=new w.GraphicalLabel(it,this.rules.LyricsHeight,T.TextAlignmentEnum.CenterBottom,this.rules);dt.setLabelPositionAndShapeBorders(),O.LyricsDashes.push(dt),dt.PositionAndShape.Parent=O.PositionAndShape;const mt=new S.PointF2D(j,Q);return dt.PositionAndShape.RelativePosition=mt,dt.PositionAndShape.RelativePosition.x-q.PositionAndShape.RelativePosition.x}calculateDynamicExpressions(){const O=Math.min(this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.length-1,this.rules.MaxMeasureToDrawIndex);for(let D=Math.min(this.rules.MinMeasureToDrawIndex,this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.length);D<=O;D++){const j=this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures[D];this.dynamicExpressionMap.clear();for(let Q=0;Q=0;Q--)if(this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers[Q].StaffEntries[D])return this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers[Q].StaffEntries[D]}getFirstRightNotNullStaffEntryFromContainer(O,D,j){if(this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers[O].StaffEntries[D])return this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers[O].StaffEntries[D];for(let Q=O+1;Q0){const et=O[O.length-1];if(D>et.startMeasure){const it=new r.RepetitionInstruction(D,r.RepetitionInstructionEnum.Ending,r.AlignmentType.Mid,void 0,et.endingIndices);this.calculateWordRepetitionInstruction(it,D)}}q&&O.length>0&&O.pop()}}calculateRepetitionEndings(){const O=this.graphicalMusicSheet.ParentMusicSheet;for(let D=0,j=O.Repetitions.length;D0||j.StaffLinkedExpressions[Q][q].UnknownList.length>0)&&this.calculateMoodAndUnknownExpression(j.StaffLinkedExpressions[Q][q],D,J)}}}calculateStemDirectionFromVoices(O){if(O.ParentSourceStaffEntry.Link!==void 0)return O===O.ParentSourceStaffEntry.VoiceEntries[0]?void(O.WantedStemDirection=f.StemDirectionType.Up):void(O.WantedStemDirection=f.StemDirectionType.Down);O.ParentVoice instanceof P.LinkedVoice?O.WantedStemDirection=f.StemDirectionType.Down:O.ParentSourceStaffEntry.VoiceEntries.length>1&&(O.WantedStemDirection=f.StemDirectionType.Up)}setBeamNotesWantedStemDirections(O){var j;if(!(O.Notes.length>0))return;const D=O.Notes[0].NoteBeam;if(D){for(const Q of D.Notes)if(((j=Q.Notehead)==null?void 0:j.Shape)!==F.NoteHeadShape.NONE&&Q.ParentVoiceEntry.WantedStemDirection!==f.StemDirectionType.Undefined&&Q.ParentVoiceEntry.ParentSourceStaffEntry.ParentStaff.Id===O.ParentSourceStaffEntry.ParentStaff.Id){O.WantedStemDirection=Q.ParentVoiceEntry.WantedStemDirection;break}}}}y.MusicSheetCalculator=ht},1932(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.MusicSheetDrawer=void 0;const d=p(6438),l=p(2683),m=p(6452),o=p(200),s=p(9409),h=p(8254),u=p(7435),f=p(7533),r=p(7307),b=p(4284),S=p(512),v=p(242),w=p(7499),T=p(298);y.MusicSheetDrawer=class{constructor(g,x){this.drawableBoundingBoxElement="None",this.skyLineVisible=!1,this.bottomLineVisible=!1,this.phonicScoreMode=v.PhonicScoreModes.Manual,this.textMeasurer=g,this.splitScreenLineColor=-1,this.drawingParameters=x,this.rules=x.Rules}set Mode(g){this.phonicScoreMode=g}drawSheet(g){if(this.graphicalMusicSheet=g,this.rules=g.ParentMusicSheet.Rules,this.drawSplitScreenLine(),this.drawingParameters.drawCursors)for(const P of g.Cursors){if(!P)continue;const _=new d.BoundingBox(P);_.AbsolutePosition=P.Start,_.BorderBottom=P.End.y-P.Start.y,_.BorderRight=P.Width/2,_.BorderLeft=-P.Width/2,this.isVisible(_)&&this.drawLineAsVerticalRectangle(P,l.GraphicalLayers.Cursor)}this.drawingParameters.drawScrollIndicator&&this.drawScrollIndicator();const x=Math.min(this.graphicalMusicSheet.MusicPages.length,this.rules.MaxPageToDrawNumber);for(let P=0;P0&&this.drawDashes(G.LyricsDashes),G.LyricLines.length>0&&this.drawLyricLines(G.LyricLines,G));for(const G of g.SystemLines)this.drawSystemLineObject(G);if(this.rules.RenderSystemLabelsAfterFirstPage||g.Parent===g.Parent.Parent.MusicPages[0])for(const G of g.Labels)G.SVGNode=this.drawLabel(G,l.GraphicalLayers.Notes);const k=this.graphicalMusicSheet.ParentMusicSheet.Instruments,R=k.filter(G=>G.isVisible()).length;for(const G of g.InstrumentBrackets)this.drawInstrumentBrace(G,g);if(k.length>0)if(R>1)for(const G of g.GroupBrackets)this.drawGroupBracket(G,g);else for(const G of g.GroupBrackets)G.Visible=!1;if(!this.leadSheet)for(const G of g.MeasureNumberLabels)G.SVGNode=this.drawLabel(G,l.GraphicalLayers.Notes),(A=(F=G.SVGNode)==null?void 0:F.classList)==null||A.add("measure-number");for(const G of g.StaffLines)this.drawStaffLineSymbols(G);this.drawingParameters.drawMarkedAreas&&this.drawMarkedAreas(g),this.drawingParameters.drawComments&&this.drawComment(g)}activateSystemRendering(g,x,P,_){return!0}drawSystemLineObject(g){}drawStaffLine(g){for(const x of g.Measures)this.drawMeasure(x);this.rules.RenderLyrics&&g.LyricsDashes.length>0&&this.drawDashes(g.LyricsDashes),this.drawOctaveShifts(g),this.drawPedals(g),this.drawWavyLines(g),this.drawExpressions(g),this.skyLineVisible&&this.drawSkyLine(g),this.bottomLineVisible&&this.drawBottomLine(g)}drawLyricLines(g,x){x.LyricLines.forEach(P=>{P.Start.y+=x.PositionAndShape.AbsolutePosition.y,P.End.y+=x.PositionAndShape.AbsolutePosition.y,P.Start.x+=x.PositionAndShape.AbsolutePosition.x,P.End.x+=x.PositionAndShape.AbsolutePosition.x,this.drawGraphicalLine(P,this.rules.LyricUnderscoreLineWidth,P.colorHex)})}drawExpressions(g){}drawGraphicalLine(g,x,P="black"){return this.drawLine(g.Start,g.End,P,x)}drawLine(g,x,P="#FF0000FF",_){}drawDashes(g){g.forEach(x=>{var P;x.SVGNode=this.drawLabel(x,l.GraphicalLayers.Notes),(P=x.SVGNode)==null||P.classList.add("dash")})}drawOctaveShifts(g){}drawStaffLines(g){if(g.StaffLines){const x=g.PositionAndShape.AbsolutePosition;for(let P=0;P<5;P++)this.drawLineAsHorizontalRectangleWithOffset(g.StaffLines[P],x,l.GraphicalLayers.Notes)}}drawInstantaneousDynamic(g){throw new Error("not implemented")}drawContinuousDynamic(g){throw new Error("not implemented")}drawSymbol(g,x,P,_=1,B=l.GraphicalLayers.Notes){}get leadSheet(){return this.graphicalMusicSheet.LeadSheet}set leadSheet(g){this.graphicalMusicSheet.LeadSheet=g}drawPage(g){if(this.isVisible(g.PositionAndShape)){for(const x of g.MusicSystems)this.isVisible(x.PositionAndShape)&&this.drawMusicSystem(x);if(g===g.Parent.MusicPages[0])for(const x of g.Labels)x.SVGNode=this.drawLabel(x,l.GraphicalLayers.Notes);this.drawableBoundingBoxElement&&this.drawBoundingBoxes(g.PositionAndShape,0,this.drawableBoundingBoxElement)}}drawBoundingBoxes(g,x=0,P="all",_=!1){const B=g.DataObject.constructor.name;let k=!1;if(P==="all"?k=!0:P==="VexFlowStaffEntry"?k=g.DataObject instanceof w.VexFlowStaffEntry:P==="VexFlowMeasure"?k=g.DataObject instanceof w.VexFlowMeasure:P==="VexFlowGraphicalNote"?k=g.DataObject instanceof w.VexFlowGraphicalNote:P==="VexFlowVoiceEntry"?k=g.DataObject instanceof w.VexFlowVoiceEntry:P==="GraphicalLabel"?k=g.DataObject instanceof h.GraphicalLabel:P==="VexFlowStaffLine"?k=g.DataObject instanceof w.VexFlowStaffLine:P==="SystemLine"?k=g.DataObject instanceof b.SystemLine:P==="StaffLineActivitySymbol"?k=g.DataObject instanceof T.StaffLineActivitySymbol:P==="VexFlowContinuousDynamicExpression"&&(k=g.DataObject instanceof w.VexFlowContinuousDynamicExpression),k||B===P){let R;_&&(R=B),this.drawBoundingBox(g,void 0,!0,R,x)}x++,g.ChildElements.forEach(R=>this.drawBoundingBoxes(R,x,P))}drawBoundingBox(g,x=void 0,P=!1,_=void 0,B=0){let k=new o.RectangleF2D(g.AbsolutePosition.x+g.BorderMarginLeft,g.AbsolutePosition.y+g.BorderMarginTop,g.BorderMarginRight-g.BorderMarginLeft,g.BorderMarginBottom-g.BorderMarginTop);P&&(this.drawLineAsHorizontalRectangle(new m.GraphicalLine(new s.PointF2D(g.AbsolutePosition.x-1,g.AbsolutePosition.y),new s.PointF2D(g.AbsolutePosition.x+1,g.AbsolutePosition.y),.1,l.OutlineAndFillStyleEnum.BaseWritingColor,x),B-1),this.drawLineAsVerticalRectangle(new m.GraphicalLine(new s.PointF2D(g.AbsolutePosition.x,g.AbsolutePosition.y-1),new s.PointF2D(g.AbsolutePosition.x,g.AbsolutePosition.y+1),.1,l.OutlineAndFillStyleEnum.BaseWritingColor,x),B-1)),k=this.applyScreenTransformationForRect(k);const R=this.renderRectangle(k,l.GraphicalLayers.Background,B,x,.5);if(_){const F=new u.Label(_),A=new h.GraphicalLabel(F,.8,f.TextAlignmentEnum.CenterCenter,this.rules);A.setLabelPositionAndShapeBorders(),this.renderLabel(A,B,k.width,k.height,k.height,new s.PointF2D(k.x,k.y+12))}return R}drawMarkedAreas(g){for(const x of g.GraphicalMarkedAreas)x&&(x.systemRectangle&&this.drawRectangle(x.systemRectangle,l.GraphicalLayers.Background),x.settings&&(x.settings.SVGNode=this.drawLabel(x.settings,l.GraphicalLayers.Comment)),x.labelRectangle&&this.drawRectangle(x.labelRectangle,l.GraphicalLayers.Background),x.label&&(x.label.SVGNode=this.drawLabel(x.label,l.GraphicalLayers.Comment)))}drawComment(g){for(const x of g.GraphicalComments)x&&(x.settings&&(x.settings.SVGNode=this.drawLabel(x.settings,l.GraphicalLayers.Comment)),x.label&&(x.label.SVGNode=this.drawLabel(x.label,l.GraphicalLayers.Comment)))}drawStaffLineSymbols(g){const x=g.ParentStaff.ParentInstrument,P=g.PositionAndShape.AbsolutePosition.x,_=g.PositionAndShape.AbsolutePosition.y+2,B=g.PositionAndShape.BorderRight;x.highlight&&this.drawingParameters.drawHighlights&&this.drawLineAsHorizontalRectangle(new m.GraphicalLine(new s.PointF2D(P,_),new s.PointF2D(P+B,_),4,l.OutlineAndFillStyleEnum.Highlighted),l.GraphicalLayers.Highlight);let k=v.MusicSymbolDrawingStyle.Disabled,R=S.MusicSymbol.PLAY,F=this.drawingParameters.drawActivitySymbols;switch(this.phonicScoreMode){case v.PhonicScoreModes.Midi:R=S.MusicSymbol.PLAY,this.midiPlaybackAvailable&&g.ParentStaff.audible&&(k=v.MusicSymbolDrawingStyle.PlaybackSymbols);break;case v.PhonicScoreModes.Following:R=S.MusicSymbol.MIC,g.ParentStaff.following&&(k=v.MusicSymbolDrawingStyle.FollowSymbols);break;default:F=!1}if(F){const A=new s.PointF2D(P+B+2,_);this.drawSymbol(R,k,A)}if(this.drawingParameters.drawErrors)for(const A of g.Measures){const G=A.PositionAndShape,U=G.AbsolutePosition.x,C=G.AbsolutePosition.y+2;A.hasError&&this.graphicalMusicSheet.ParentMusicSheet.DrawErroneousMeasures&&this.drawLineAsHorizontalRectangle(new m.GraphicalLine(new s.PointF2D(U,C),new s.PointF2D(U+G.BorderRight,C),4,l.OutlineAndFillStyleEnum.ErrorUnderlay),l.GraphicalLayers.MeasureError)}}}},512(St,y){var p;Object.defineProperty(y,"__esModule",{value:!0}),y.MusicSymbol=void 0,(function(d){d[d.Unused_first_Symbol=0]="Unused_first_Symbol",d[d.BLACK_HEAD=1]="BLACK_HEAD",d[d.UPWARDS_TAIL=2]="UPWARDS_TAIL",d[d.DOWNWARDS_TAIL=3]="DOWNWARDS_TAIL",d[d.UPWARDS_DOUBLE_TAIL=4]="UPWARDS_DOUBLE_TAIL",d[d.DOWNWARDS_DOUBLE_TAIL=5]="DOWNWARDS_DOUBLE_TAIL",d[d.UPWARDS_TRIPLE_TAIL=6]="UPWARDS_TRIPLE_TAIL",d[d.DOWNWARDS_TRIPLE_TAIL=7]="DOWNWARDS_TRIPLE_TAIL",d[d.UPWARDS_QUAD_TAIL=8]="UPWARDS_QUAD_TAIL",d[d.DOWNWARDS_QUAD_TAIL=9]="DOWNWARDS_QUAD_TAIL",d[d.ROUND_HEAD=10]="ROUND_HEAD",d[d.WHITE_HEAD=11]="WHITE_HEAD",d[d.G_CLEF=12]="G_CLEF",d[d.F_CLEF=13]="F_CLEF",d[d.C_CLEF=14]="C_CLEF",d[d.BREVE=15]="BREVE",d[d.BREVE_REST=16]="BREVE_REST",d[d.COMMON_TIME=17]="COMMON_TIME",d[d.CUT_TIME=18]="CUT_TIME",d[d.WHOLE_REST=19]="WHOLE_REST",d[d.HALF_REST=20]="HALF_REST",d[d.QUARTER_REST=21]="QUARTER_REST",d[d.EIGHTH_REST=22]="EIGHTH_REST",d[d.SIXTEENTH_REST=23]="SIXTEENTH_REST",d[d.THIRTYSECOND_REST=24]="THIRTYSECOND_REST",d[d.SIXTYFOURTH_REST=25]="SIXTYFOURTH_REST",d[d.FLAT=26]="FLAT",d[d.SHARP=27]="SHARP",d[d.NATURAL=28]="NATURAL",d[d.DOUBLE_FLAT=29]="DOUBLE_FLAT",d[d.DOUBLE_SHARP=30]="DOUBLE_SHARP",d[d.ZERO=31]="ZERO",d[d.ONE=32]="ONE",d[d.TWO=33]="TWO",d[d.THREE=34]="THREE",d[d.FOUR=35]="FOUR",d[d.FIVE=36]="FIVE",d[d.SIX=37]="SIX",d[d.SEVEN=38]="SEVEN",d[d.EIGHT=39]="EIGHT",d[d.NINE=40]="NINE",d[d.DOT=41]="DOT",d[d.FERMATA=42]="FERMATA",d[d.INVERTED_FERMATA=43]="INVERTED_FERMATA",d[d.SPICCATO=44]="SPICCATO",d[d.TENUTO=45]="TENUTO",d[d.MARCATO=46]="MARCATO",d[d.MARCATISSIMO=47]="MARCATISSIMO",d[d.INVERTED_MARCATISSIMO=48]="INVERTED_MARCATISSIMO",d[d.P=49]="P",d[d.F=50]="F",d[d.S=51]="S",d[d.Z=52]="Z",d[d.M=53]="M",d[d.R=54]="R",d[d.SEGNO=55]="SEGNO",d[d.CODA=56]="CODA",d[d.DRUM_CLEF=57]="DRUM_CLEF",d[d.G_CLEF_SUB8=58]="G_CLEF_SUB8",d[d.G_CLEF_SUPER8=59]="G_CLEF_SUPER8",d[d.G_CLEF_SUB15=60]="G_CLEF_SUB15",d[d.G_CLEF_SUPER15=61]="G_CLEF_SUPER15",d[d.F_CLEF_SUB8=62]="F_CLEF_SUB8",d[d.F_CLEF_SUPER8=63]="F_CLEF_SUPER8",d[d.F_CLEF_SUB15=64]="F_CLEF_SUB15",d[d.F_CLEF_SUPER15=65]="F_CLEF_SUPER15",d[d.DOWN_BOW=66]="DOWN_BOW",d[d.MORDENT=67]="MORDENT",d[d.INVERTED_MORDENT=68]="INVERTED_MORDENT",d[d.TURN=69]="TURN",d[d.INVERTED_TURN=70]="INVERTED_TURN",d[d.LEFTHAND_PIZZICATO=71]="LEFTHAND_PIZZICATO",d[d.RELEASE_PED=72]="RELEASE_PED",d[d.ENGAGE_PED=73]="ENGAGE_PED",d[d.VA8=74]="VA8",d[d.VB8=75]="VB8",d[d.TRILL=76]="TRILL",d[d.MA15=77]="MA15",d[d.MB15=78]="MB15",d[d.HIGH=79]="HIGH",d[d.PLAY=80]="PLAY",d[d.MIC=81]="MIC",d[d.SNAP_PIZZICATO=82]="SNAP_PIZZICATO",d[d.NATURAL_HARMONIC=83]="NATURAL_HARMONIC",d[d.EditPen=84]="EditPen",d[d.PEDAL_BRACKET=85]="PEDAL_BRACKET",d[d.PEDAL_MIXED=86]="PEDAL_MIXED",d[d.PEDAL_SYMBOL=87]="PEDAL_SYMBOL"})(p||(y.MusicSymbol=p={}))},5221(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.MusicSystem=void 0;const d=p(9252),l=p(6438),m=p(2561),o=p(7533),s=p(8254),h=p(7741),u=p(9409),f=p(6954),r=p(3263),b=p(67),S=p(7435);class v extends h.GraphicalObject{constructor(T){super(),this.needsToBeRedrawn=!0,this.staffLines=[],this.graphicalMeasures=[],this.labels=new r.Dictionary,this.measureNumberLabels=[],this.objectsToRedraw=[],this.instrumentBrackets=[],this.groupBrackets=[],this.graphicalMarkedAreas=[],this.graphicalComments=[],this.systemLines=[],this.breaksPage=!1,this.id=T,this.boundingBox=new l.BoundingBox(this),this.maxLabelLength=0}get Parent(){return this.parent}set Parent(T){if(this.parent){const g=this.parent.MusicSystems.indexOf(this,0);g>-1&&this.parent.MusicSystems.splice(g,1)}this.parent=T,this.boundingBox.Parent=T.PositionAndShape}get NextSystem(){const T=this.Parent.MusicSystems.indexOf(this);return T!==this.Parent.MusicSystems.length?this.Parent.MusicSystems[T+1]:void 0}get StaffLines(){return this.staffLines}set StaffLines(T){this.staffLines=T}get GraphicalMeasures(){return this.graphicalMeasures}get MeasureNumberLabels(){return this.measureNumberLabels}get Labels(){return this.labels.values()}get ObjectsToRedraw(){return this.objectsToRedraw}get InstrumentBrackets(){return this.instrumentBrackets}get GroupBrackets(){return this.groupBrackets}get GraphicalMarkedAreas(){return this.graphicalMarkedAreas}get GraphicalComments(){return this.graphicalComments}get SystemLines(){return this.systemLines}get Id(){return this.id}get MaxLabelLength(){return this.maxLabelLength}createSystemLeftLine(T,g,x){let P=-T/2;x&&(P=this.maxLabelLength+g-T/2);const _=this.staffLines[0].Measures[0];let B;this.staffLines.length>1&&(B=this.staffLines[this.staffLines.length-1].Measures[0]);const k=this.createSystemLine(P,T,f.SystemLinesEnum.SingleThin,b.SystemLinePosition.MeasureBegin,this,_,B);this.SystemLines.push(k),k.PositionAndShape.RelativePosition=new u.PointF2D(P,0),k.PositionAndShape.BorderLeft=0,k.PositionAndShape.BorderRight=T,k.PositionAndShape.BorderTop=k.PositionAndShape.Parent.BorderTop,k.PositionAndShape.BorderBottom=k.PositionAndShape.Parent.BorderBottom,this.createLinesForSystemLine(k)}createVerticalLineForMeasure(T,g,x,P,_,B){const k=B.ParentStaffLine,R=new u.PointF2D(k.PositionAndShape.RelativePosition.x,k.PositionAndShape.RelativePosition.y),F=k.ParentStaff.ParentInstrument.Staves;if(k.ParentStaff===F[0]){let A;F.length>1&&(A=this.getBottomStaffLine(k).Measures[_]);const G=this.createSystemLine(T,g,x,P,this,B,A),U=R.x+T;G.PositionAndShape.RelativePosition=new u.PointF2D(U,0),G.PositionAndShape.BorderLeft=0,G.PositionAndShape.BorderRight=g,this.SystemLines.push(G)}}setYPositionsToVerticalLineObjectsAndCreateLines(T){}calculateBorders(T){}alignBeginInstructions(){}GetLeftBorderAbsoluteXPosition(){return this.StaffLines[0].PositionAndShape.AbsolutePosition.x+this.StaffLines[0].Measures[0].beginInstructionsWidth}GetRightBorderAbsoluteXPosition(){return this.StaffLines[0].PositionAndShape.AbsolutePosition.x+this.StaffLines[0].StaffLines[0].End.x}AddGraphicalMeasures(T){for(let g=0,x=T.length;g1){let B,k;for(let R=0,F=this.staffLines.length;Rthis.maxLabelLength&&(this.maxLabelLength=A.PositionAndShape.Size.width,g=_)}this.updateMusicSystemStaffLineXPosition(g)}setMusicSystemLabelsYPosition(){this.labels.forEach((T,g)=>{let x=0,P=0;for(let _=0;_0&&(g.PositionAndShape.RelativePosition=new u.PointF2D(0,x/P+2))})}checkStaffEntriesForStaffEntryLink(){let T=!1,g=!1;for(let x=0;x=0;_--)if((P=g[_])!=null&&P.Visible){x=g[_];break}for(const _ of T.ParentMusicSystem.staffLines)if(_.ParentStaff===x)return _}createSystemLine(T,g,x,P,_,B,k=void 0){throw new Error("not implemented")}createLinesForSystemLine(T){}calcBracketsWidth(){let T=0;for(let g=0,x=this.GroupBrackets.length;g=0;x--){if(g=T.InstrumentalGroups[x],!(g instanceof d.Instrument))return this.findLastVisibleInstrumentInInstrumentalGroup(g);if(g.isVisible())return g}}updateMusicSystemStaffLineXPosition(T){for(let g=0,x=this.StaffLines.length;g0?this.currentSystemParams.maxLabelLength+this.rules.SystemLabelsRightMargin:0,rt=this.currentSystemParams.currentWidth+Y+N+H0;if(F||rt&&!st){if(this.addMeasureToSystem(_,C,W,Y,G,z,U),this.updateActiveClefs(B,_),this.measureListIndex++,R){if(this.rules.MaxSystemToDrawNumber===this.musicSystems.length)return this.finalizeCurrentSystem(_,!this.rules.StretchLastSystemLine,!1),this.musicSystems;this.finalizeCurrentAndCreateNewSystem(_,!this.rules.StretchLastSystemLine,!1)}T=k}else{if(this.rules.MaxSystemToDrawNumber===this.musicSystems.length)return this.finalizeCurrentSystem(_,!1,!0,ct),this.musicSystems;this.finalizeCurrentAndCreateNewSystem(_,!1,!0,ct)}}if(this.currentSystemParams.systemMeasures.length>0){if(this.rules.MaxSystemToDrawNumber===this.musicSystems.length)return this.finalizeCurrentSystem(this.measureList[this.measureList.length-1],!this.rules.StretchLastSystemLine,!1),this.musicSystems;this.finalizeCurrentAndCreateNewSystem(this.measureList[this.measureList.length-1],!this.rules.StretchLastSystemLine,!1)}return this.musicSystems}calculateSystemYLayout(){for(const w of this.musicSystems)this.optimizeDistanceBetweenStaffLines(w);this.calculateMusicSystemsRelativePositions()}setMeasureWidth(w,T,g,x){for(let P=0,_=w.length;P<_;++P){const B=w[P];B.setWidth(T),g>0&&(B.beginInstructionsWidth=g),x>0&&(B.endInstructionsWidth=x)}}finalizeCurrentAndCreateNewSystem(w,T=!1,g=!0,x=!1){this.finalizeCurrentSystem(w,T,g,x),this.currentSystemParams=new v,w!==void 0&&this.measureListIndex=1){const T=this.currentSystemParams.currentSystem.GraphicalMeasures[this.currentSystemParams.currentSystem.GraphicalMeasures.length-1];let g=0;const x=w[w.length-1];x.endLine===u.SystemLinesEnum.DotsBoldBoldDots&&(x.endLine=u.SystemLinesEnum.DotsThinBold,g=T[0].getLineWidth(u.SystemLinesEnum.DotsBoldBoldDots)/2-T[0].getLineWidth(u.SystemLinesEnum.DotsThinBold)),this.currentSystemParams.currentSystemFixWidth-=g;for(let P=0,_=T.length;P<_;++P)T[P].endInstructionsWidth-=g}}addMeasureToSystem(w,T,g,x,P,_,B){this.currentSystemParams.systemMeasures.push({beginLine:T,endLine:g}),this.setMeasureWidth(w,x,P,B),this.addStaveMeasuresToSystem(w),this.currentSystemParams.currentWidth+=x,this.currentSystemParams.currentSystemFixWidth+=P+B,this.currentSystemParams.currentSystemVarWidth+=_,this.currentSystemParams.systemMeasureIndex++}initMusicSystem(){const w=f.MusicSheetCalculator.symbolFactory.createMusicSystem(this.globalSystemIndex++,this.rules);return this.musicSystems.push(w),this.layoutSystemStaves(w),w.createMusicSystemLabel(this.rules.InstrumentLabelTextHeight,this.rules.SystemLabelsRightMargin,this.rules.LabelMarginBorderFactor,this.musicSystems.length===1),w}getFullPageSystemWidth(){return this.graphicalMusicSheet.ParentMusicSheet.pageWidth-this.rules.PageLeftMargin-this.rules.PageRightMargin-this.rules.SystemLeftMargin-this.rules.SystemRightMargin}layoutSystemStaves(w){const T=this.getFullPageSystemWidth(),g=w.PositionAndShape;g.BorderLeft=0,g.BorderRight=T,g.BorderTop=0;const x=[],P=this.graphicalMusicSheet.ParentMusicSheet.Instruments;for(let k=0,R=P.length;k1){_=!0;break}}let B=0;for(let k=0;k=0&&this.measureList[z]){const W=this.measureList[z],$=(U=W[0])==null?void 0:U.parentSourceMeasure;$!=null&&$.ImplicitMeasure&&($!=null&&$.RhythmPrinted)&&(C=!1)}C&&(T.addRhythmAtBegin(k),T.parentSourceMeasure.RhythmPrinted=k,G=!0)}return(F||A||G)&&(R+=T.beginInstructionsWidth,G&&(R+=this.rules.RhythmRightMargin)),R}addInstructionsAtMeasureEnd(w,T,g){if(!w||!w.Instructions||w.Instructions.length===0)return 0;for(let x=0,P=w.Instructions.length;x0&&(this.currentSystemParams.systemMeasures.push({beginLine:u.SystemLinesEnum.None,endLine:u.SystemLinesEnum.None}),this.currentSystemParams.currentWidth+=x,this.currentSystemParams.currentSystemFixWidth+=x)}addExtraInstructionMeasure(w,T,g){const x=this.currentSystemParams.currentSystem,P=f.MusicSheetCalculator.symbolFactory.createExtraGraphicalMeasure(x.StaffLines[w]);T&&P.addKeyAtBegin(T,this.activeKeys[w],this.activeClefs[w]),g!==void 0&&g.PrintObject&&P.addRhythmAtBegin(g),P.PositionAndShape.BorderLeft=0,P.PositionAndShape.BorderTop=0,P.PositionAndShape.BorderBottom=this.rules.StaffHeight;const _=this.rules.MeasureLeftMargin+P.beginInstructionsWidth+this.rules.MeasureRightMargin;return P.PositionAndShape.BorderRight=_,x.StaffLines[w].Measures.push(P),_}addStaveMeasuresToSystem(w){if(w[0]){const T=[];for(let x=0;x1){const T=Math.min(this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.length-1,w.measureListIndex+w.multipleRestMeasures-1);w=this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures[T]}}finally{}return this.nextMeasureBeginsLineRepetition()&&this.thisMeasureEndsLineRepetition()?u.SystemLinesEnum.DotsBoldBoldDots:this.thisMeasureEndsLineRepetition()?u.SystemLinesEnum.DotsThinBold:this.nextMeasureHasKeyInstructionChange()?u.SystemLinesEnum.DoubleThin:w&&w.endingBarStyleEnum!==void 0?w.endingBarStyleEnum:u.SystemLinesEnum.SingleThin}getLineWidth(w,T,g){let x=w.getLineWidth(T);return T===u.SystemLinesEnum.DotsBoldBoldDots&&(x/=2),g&&T===u.SystemLinesEnum.BoldThinDots&&(x+=this.rules.DistanceBetweenLastInstructionAndRepetitionBarline),x}previousMeasureEndsLineRepetition(){if(this.measureListIndex===0)return!1;for(let w=0,T=this.measureList[this.measureListIndex-1].length;w=this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.length||!this.measureList[w])return!1;for(let T=0,g=this.measureList[w].length;T=k))break;_=F,k=F.multipleRestMeasureNumber}return _.endsWithLineRepetition()}}return!1}nextMeasureBeginsWordRepetition(){const w=this.measureListIndex+1;if(w>=this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.length||w>this.measureList.length-1)return!1;for(let T=0,g=this.measureList[w].length;Tthis.rules.PageHeight-this.rules.PageBottomMargin&&(x++,x<=4&&console.log(`warning: could not fit a single system on page ${w.PageNumber} and measure number ${g.GraphicalMeasures[0][0].MeasureNumber}. The PageFormat may be too small for this sheet." - Will not give further warnings for all pages, only total.`))}else{const _=this.musicSystems[P-1],B=_.StaffLines[_.StaffLines.length-1],k=B.PositionAndShape;let R=this.findRequiredDistanceWithSkyBottomLine(_,g);R+=this.rules.MinSkyBottomDistBetweenSystems,R=Math.max(R,this.rules.MinimumDistanceBetweenSystems+B.StaffHeight);const F=T+k.RelativePosition.y+R,A=F+g.PositionAndShape.BorderMarginBottom;if(this.rules.NewPageAtXMLNewPageAttribute&&_.breaksPage||!(A0&&console.log(`total amount of pages that couldn't fit a single music system: ${x} of ${w.PageNumber}`)}findRequiredDistanceWithSkyBottomLine(w,T){const g=w.StaffLines[w.StaffLines.length-1],x=T.StaffLines[0],P=g.BottomLine,_=x.SkyLine,B=g.PositionAndShape,k=x.PositionAndShape,R=1/this.rules.SamplingUnit;let F=0;for(let A=0;A=_.length)break;const C=Math.max(0,U-6),z=Math.min(_.length-1,U+6);let W=0;for(let N=C;N<=z;N++)W=Math.min(W,_[N]);const $=G-W;F=Math.max($,F)}return F===0&&(F=B.BorderBottom-k.BorderTop),F}};class v{constructor(){this.systemMeasures=[],this.systemMeasureIndex=0,this.currentWidth=0,this.currentSystemFixWidth=0,this.currentSystemVarWidth=0,this.maxLabelLength=0}IsSystemStartMeasure(){return this.systemMeasureIndex===0}}y.SystemBuildParameters=v,y.MeasureBuildParameters=class{}},8033(St,y){Object.defineProperty(y,"__esModule",{value:!0}),y.OctaveShiftParams=void 0,y.OctaveShiftParams=class{constructor(p,d,l){this.getOpenOctaveShift=p,this.getAbsoluteStartTimestamp=d,this.getAbsoluteEndTimestamp=l}}},735(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.PlainSkyBottomLineBatchCalculatorBackend=void 0;const d=p(5479),l=p(3667);class m extends l.SkyBottomLineBatchCalculatorBackend{constructor(s,h){super(s,h)}getPreferredRenderingConfiguration(s,h){return{elementWidth:Math.ceil(s),numColumns:6,numRows:6}}onInitialize(s){}calculateFromCanvas(s,h,u,f,r){const b=s.width,S=h.getImageData(0,0,s.width,s.height),{elementWidth:v,elementHeight:w,numColumns:T}=r,g=[];for(let x=0;x0){G[W-k]=$-F;break}}U[W-k]=w;for(let $=A-1;$>=F;$--){const N=$*b*4+4*W;if(S.data[N+3]>0){U[W-k]=$-F;break}}}const C=Math.max(...G),z=Math.min(...U);for(let W=0;W<_;++W)G[W]=G[W]===0?C:G[W],U[W]=U[W]===w?z:U[W];g.push(new d.SkyBottomLineCalculationResult(G,U))}return g}}y.PlainSkyBottomLineBatchCalculatorBackend=m},7624(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.SelectionEndSymbol=void 0;const d=p(7741),l=p(2683),m=p(9409),a=p(6438),s=p(6452),h=p(813);class u extends d.GraphicalObject{constructor(r,b){super();const S=b,v=r.PositionAndShape.AbsolutePosition.y,w=h.CollectionUtil.last(r.StaffLines).PositionAndShape.RelativePosition.y+4;this.verticalLine=new s.GraphicalLine(new m.PointF2D(S,v),new m.PointF2D(S,v+w),.4,l.OutlineAndFillStyleEnum.SelectionSymbol);for(let T=0,g=r.StaffLines.length;T{if(r.has(S))return r.get(S);{const v=[];return r.set(S,v),v}})().push({skyBottomLineCalculator:b.SkyBottomLineCalculator,measures:b.Measures})}this.batches=new Map;for(const[b,S]of r.entries()){const v=h.CollectionUtil.flat(S.map(T=>T.measures)),w=(()=>{if(f===l.SkyBottomLineBatchCalculatorBackendType.Plain)return new m.PlainSkyBottomLineBatchCalculatorBackend(b,v).initialize();try{return new a.WebGLSkyBottomLineBatchCalculatorBackend(b,v).initialize()}catch{return s.default.info("Couldn't create WebGLBackend for Skyline. Using fallback."),new m.PlainSkyBottomLineBatchCalculatorBackend(b,v).initialize()}})();w.initialize(),this.batches.set(b,{backend:w,entries:S})}}calculateLines(){for(const[,{backend:u,entries:f}]of this.batches){const r=u.calculateLines();let b=0;for(const{skyBottomLineCalculator:S,measures:v}of f){const w=b+v.length;S.updateLines(r.slice(b,w)),b=w}}}}},3667(St,y,p){var d=this&&this.__importDefault||function(a){return a&&a.__esModule?a:{default:a}};Object.defineProperty(y,"__esModule",{value:!0}),y.SkyBottomLineBatchCalculatorBackend=void 0;const l=p(9834),m=d(p(3065));y.SkyBottomLineBatchCalculatorBackend=class{constructor(a,s){this.elementHeight=300,this.canvas=new l.CanvasVexFlowBackend(a),this.measures=s,this.maxWidth=Math.max(...this.measures.map(h=>{let u=h.getVFStave().getWidth();return u>0||h.IsExtraGraphicalMeasure||(m.default.warn("SkyBottomLineBatchCalculatorBackend: width not > 0 in measure "+h.MeasureNumber),u=50),u})),this.samplingUnit=a.SamplingUnit}initialize(){if(this.tableConfiguration={...this.getPreferredRenderingConfiguration(this.maxWidth,this.elementHeight),elementHeight:this.elementHeight},this.tableConfiguration.numRows<1||this.tableConfiguration.numColumns<1)throw m.default.warn("SkyBottomLineBatchCalculatorBackend: numRows or numColumns in tableConfiguration is 0"),new Error("numRows or numColumns in tableConfiguration is 0");this.tableConfiguration.elementWidth0||P.IsExtraGraphicalMeasure||(R=50),R=Math.floor(R),P.PositionAndShape.calculateAbsolutePositionsRecursive(0,0),_.setX(0);const A=_.y+100;_.setY(A);const G=_.getWidth();_.setWidth(R),P.format(),_.setWidth(G);try{b.translate(B*h,k*u),P.draw(r),b.translate(-B*h,-k*u)}catch(U){m.default.warn("SkyBottomLineBatchCalculatorBackend.calculateLines.draw",U)}}const g=this.calculateFromCanvas(S,r,T,this.samplingUnit,this.tableConfiguration);v.push(...g)}return v}}},5479(St,y){Object.defineProperty(y,"__esModule",{value:!0}),y.SkyBottomLineCalculationResult=void 0,y.SkyBottomLineCalculationResult=class{constructor(p,d){this.skyLine=p,this.bottomLine=d}}},2779(St,y,p){var d=this&&this.__importDefault||function(h){return h&&h.__esModule?h:{default:h}};Object.defineProperty(y,"__esModule",{value:!0}),y.SkyBottomLineCalculator=void 0,p(9409);const l=p(9479),m=d(p(3065)),a=p(5479),s=p(9834);y.SkyBottomLineCalculator=class{constructor(h){this.mStaffLineParent=h,this.mRules=h.ParentMusicSystem.rules}updateLines(h){const u=this.StaffLineParent.Measures;if(h.length!==u.length)if(m.default.warn("SkyBottomLineCalculator: lengths of calculation result array and measure array do not match"),h.length(T-v)/l.unitInPixels+this.StaffLineParent.TopLineOffset);const w=Math.min(...this.mBottomLine);this.mBottomLine=this.mBottomLine.map(T=>(T-w)/l.unitInPixels+this.StaffLineParent.BottomLineOffset)}calculateLines(){const h=this.mRules.SamplingUnit,u=[],f=new s.CanvasVexFlowBackend(this.mRules);for(const r of this.StaffLineParent.Measures){r.PositionAndShape.calculateAbsolutePositionsRecursive(0,0);const b=r.getVFStave();let S=b.getWidth();S>0||r.IsExtraGraphicalMeasure||(m.default.warn("SkyBottomLineCalculator: width not > 0 in measure "+r.MeasureNumber),S=50),f.initializeHeadless(S);const v=f.getContext(),w=f.getCanvas();S=w.width;const T=w.height;b.setY(b.y+100);const g=b.getWidth();b.setWidth(S),r.format(),b.setWidth(g);try{r.draw(v)}catch(R){m.default.warn("SkyBottomLineCalculator.calculateLines.draw",R)}const x=v.getImageData(0,0,S,T),P=4,_=Math.max(Math.ceil(r.PositionAndShape.Size.width*h),1),B=new Array(_),k=new Array(_);for(let R=0;R0){B[R]=F;break}}for(let F=T;F>0;F--){const A=F*S*P+R*P;if(x.data[A+3]>0){k[R]=F;break}}}for(let R=0;R=this.BottomLine.length&&(f=this.BottomLine.length-1),r<0&&(r=0),r>=this.BottomLine.length&&(r=this.BottomLine.length),this.SkyLine[f]=h.y;for(let S=f+1;S=this.BottomLine.length&&(f=this.BottomLine.length-1),r<0&&(r=0),r>=this.BottomLine.length&&(r=this.BottomLine.length),this.BottomLine[f]=h.y;for(let S=f+1;Sh)}setBottomLineWithValue(h){this.BottomLine.forEach(u=>h)}getLeftIndexForPointX(h,u){const f=Math.floor(h*this.SamplingUnit);return f<0?0:f>=u?u-1:f}getRightIndexForPointX(h,u){const f=Math.ceil(h*this.SamplingUnit);return f<0?0:f>=u?u-1:f}updateStaffLineBorders(){this.mStaffLineParent.PositionAndShape.BorderTop=this.getSkyLineMin(),this.mStaffLineParent.PositionAndShape.BorderMarginTop=this.getSkyLineMin(),this.mStaffLineParent.PositionAndShape.BorderBottom=this.getBottomLineMax(),this.mStaffLineParent.PositionAndShape.BorderMarginBottom=this.getBottomLineMax()}getSkyLineMin(){return Math.min(...this.SkyLine.filter(h=>!isNaN(h)))}getSkyLineMinAtPoint(h){const u=Math.round(h*this.SamplingUnit);return this.mSkyLine[u]}getSkyLineMinInRange(h,u){return this.getMinInRange(this.SkyLine,h,u)}getBottomLineMax(){return Math.max(...this.BottomLine.filter(h=>!isNaN(h)))}getBottomLineMaxAtPoint(h){const u=Math.round(h*this.SamplingUnit);return this.mBottomLine[u]}getBottomLineMaxInRange(h,u){return this.getMaxInRange(this.BottomLine,h,u)}getBottomLineMaxInBoundingBox(h){const u=Math.floor(h.AbsolutePosition.x+h.BorderLeft),f=Math.ceil(h.AbsolutePosition.x+h.BorderRight);return this.getMaxInRange(this.mBottomLine,u,f)}updateWithBoundingBoxRecursively(h){if(h.ChildElements&&h.ChildElements.length>0)this.updateWithBoundingBoxRecursively(h);else{const u=h.BorderTop+h.AbsolutePosition.y,f=h.BorderBottom+h.AbsolutePosition.y;if(u<0){const r=Math.floor(h.AbsolutePosition.x+h.BorderLeft),b=Math.ceil(h.AbsolutePosition.x+h.BorderRight);this.updateInRange(this.mSkyLine,r,b,u)}else if(f>this.StaffLineParent.StaffHeight){const r=Math.floor(h.AbsolutePosition.x+h.BorderLeft),b=Math.ceil(h.AbsolutePosition.x+h.BorderRight);this.updateInRange(this.mBottomLine,r,b,f)}}}findPreviousValidNumber(h,u){for(let f=h;f>=0;f--)if(!isNaN(u[f]))return u[f];return 0}findNextValidNumber(h,u){if(h>=u.length)return u[h-1];for(let f=h;fh.length&&(f=h.length);for(let b=u;bMath.abs(h[b])?r:h[b]}setInRange(h,u=0,f=h.length,r=0){if(u=Math.floor(u*this.SamplingUnit),(f=Math.ceil(f*this.SamplingUnit))h.length&&(f=h.length);for(let b=u;b=h.length&&(u=h.length-1),f<0&&(f=0),f>=h.length&&(f=h.length),u>=0&&f<=h.length?Math.min(...h.slice(u,f+1)):void 0):Number.MAX_VALUE}getMaxInRange(h,u,f){return u=Math.floor(u*this.SamplingUnit),f=Math.ceil(f*this.SamplingUnit),h?(u<0&&(u=0),u>=h.length&&(u=h.length-1),f<0&&(f=0),f>=h.length&&(f=h.length),u>=0&&f<=h.length?Math.max(...h.slice(u,f+1)):void 0):Number.MIN_VALUE}get SamplingUnit(){return this.mRules.SamplingUnit}get StaffLineParent(){return this.mStaffLineParent}get SkyLine(){return this.mSkyLine}get BottomLine(){return this.mBottomLine}}},2919(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.StaffLine=void 0;const d=p(6438),l=p(7741),m=p(298),a=p(9409),s=p(2779);class h extends l.GraphicalObject{constructor(f,r){super(),this.measures=[],this.staffLines=new Array(5),this.octaveShifts=[],this.lyricLines=[],this.lyricsDashes=[],this.abstractExpressions=[],this.graphicalSlurs=[],this.graphicalGlissandi=[],this.Pedals=[],this.WavyLines=[],this.parentMusicSystem=f,this.parentStaff=r,this.boundingBox=new d.BoundingBox(this,f.PositionAndShape),this.skyBottomLine=new s.SkyBottomLineCalculator(this),this.staffHeight=this.parentMusicSystem.rules.StaffHeight,this.topLineOffset=0,this.bottomLineOffset=4,this.calculateStaffLineOffsets()}calculateStaffLineOffsets(){if(this.ParentStaff.isTab)this.ParentStaff.StafflineCount===5?this.staffHeight=this.bottomLineOffset=6*this.ParentStaff.ParentInstrument.GetMusicSheet.Rules.TabStaffInterlineHeight:this.staffHeight=this.bottomLineOffset=this.ParentStaff.ParentInstrument.GetMusicSheet.Rules.TabStaffInterlineHeight*this.ParentStaff.StafflineCount;else switch(this.ParentStaff.StafflineCount){case 4:this.bottomLineOffset=1;break;case 3:this.topLineOffset=1,this.bottomLineOffset=1;break;case 2:this.topLineOffset=2,this.bottomLineOffset=1;break;case 1:this.topLineOffset=2,this.bottomLineOffset=2}}get Measures(){return this.measures}set Measures(f){this.measures=f}get StaffLines(){return this.staffLines}set StaffLines(f){this.staffLines=f}get NextStaffLine(){const f=this.parentMusicSystem.StaffLines.indexOf(this);return f!==this.parentMusicSystem.StaffLines.length?this.parentMusicSystem.StaffLines[f+1]:void 0}get LyricLines(){return this.lyricLines}get AbstractExpressions(){return this.abstractExpressions}set AbstractExpressions(f){this.abstractExpressions=f}set LyricLines(f){this.lyricLines=f}get LyricsDashes(){return this.lyricsDashes}set LyricsDashes(f){this.lyricsDashes=f}get ParentMusicSystem(){return this.parentMusicSystem}set ParentMusicSystem(f){this.parentMusicSystem=f}get ParentStaff(){return this.parentStaff}set ParentStaff(f){this.parentStaff=f}get SkyBottomLineCalculator(){return this.skyBottomLine}get SkyLine(){return this.skyBottomLine.SkyLine}get BottomLine(){return this.skyBottomLine.BottomLine}get OctaveShifts(){return this.octaveShifts}set OctaveShifts(f){this.octaveShifts=f}get StaffHeight(){return this.staffHeight}get TopLineOffset(){return this.topLineOffset}get BottomLineOffset(){return this.bottomLineOffset}get GraphicalSlurs(){return this.graphicalSlurs}get GraphicalGlissandi(){return this.graphicalGlissandi}addSlurToStaffline(f){this.graphicalSlurs.push(f)}addGlissandoToStaffline(f){this.graphicalGlissandi.push(f),f.StaffLine=this}addActivitySymbolClickArea(){const f=new m.StaffLineActivitySymbol(this),r=this.PositionAndShape;f.PositionAndShape.RelativePosition=new a.PointF2D(r.RelativePosition.x+r.BorderRight+.5,r.RelativePosition.y+.5),f.PositionAndShape.Parent=this.parentMusicSystem.PositionAndShape}isPartOfMultiStaffInstrument(){return this.parentStaff.ParentInstrument.Staves.length>1}findClosestStaffEntry(f){let r;for(let b=0,S=this.Measures.length;bm?1:0}getFirstNonNullStaffEntry(){for(let p=0,d=this.staffEntries.length;p0){const f=u.map(b=>b.PositionAndShape.Center.y),r=Math.max(...f);for(let b=0;b0?u[b-1]:void 0;if(w){const g=this.getOverlap(S.PositionAndShape,w.PositionAndShape);S.squeeze(-(g.x+this.rules.DynamicExpressionSpacer))}if(T){const g=this.getOverlap(T.PositionAndShape,S.PositionAndShape);S.squeeze(g.x+this.rules.DynamicExpressionSpacer)}}}}}getDistance(m,a){const s=m.RelativePosition.x+m.BorderMarginRight,h=a.RelativePosition.x+a.BorderMarginLeft,u=m.RelativePosition.y+m.BorderMarginBottom,f=a.RelativePosition.y+a.BorderMarginTop;return new l.PointF2D(h-s,f-u)}getOverlap(m,a){return new l.PointF2D(m.RelativePosition.x+m.BorderMarginRight-(a.RelativePosition.x+a.BorderMarginLeft),m.RelativePosition.y+m.BorderMarginBottom-(a.RelativePosition.y+a.BorderMarginTop))}}},9834(St,y,p){var d=this&&this.__importDefault||function(f){return f&&f.__esModule?f:{default:f}};Object.defineProperty(y,"__esModule",{value:!0}),y.CanvasVexFlowBackend=void 0;var l=d(p(3206)).default.Flow;const m=p(1902),a=p(6014),s=p(624),h=p(1888);class u extends m.VexFlowBackend{constructor(r){super(),this.rules=r}getVexflowBackendType(){return l.Renderer.Backends.CANVAS}getOSMDBackendType(){return s.BackendType.Canvas}getCanvasSize(){var r;return(r=document.getElementById("osmdCanvasPage"+this.graphicalMusicPage.PageNumber))==null?void 0:r.offsetHeight}initialize(r,b){this.zoom=b,this.canvas=document.createElement("canvas"),this.graphicalMusicPage||(this.graphicalMusicPage=new h.GraphicalMusicPage(void 0),this.graphicalMusicPage.PageNumber=1),this.canvas.id="osmdCanvasVexFlowBackendCanvas"+this.graphicalMusicPage.PageNumber,this.inner=document.createElement("div"),this.inner.id="osmdCanvasPage"+this.graphicalMusicPage.PageNumber,this.inner.style.position="relative",this.canvas.style.zIndex="0",this.inner.appendChild(this.canvas),r.appendChild(this.inner),this.renderer=new l.Renderer(this.canvas,this.getVexflowBackendType()),this.ctx=this.renderer.getContext()}initializeHeadless(r=300,b=300){this.graphicalMusicPage||(this.graphicalMusicPage=new h.GraphicalMusicPage(void 0),this.graphicalMusicPage.PageNumber=1),this.canvas=document.createElement("canvas"),this.canvas.width=r,this.canvas.height=b,this.renderer=new l.Renderer(this.canvas,this.getVexflowBackendType()),this.ctx=this.renderer.getContext()}getContext(){return this.ctx}free(){this.canvas&&(this.canvas.width=0,this.canvas.height=0,this.canvas.remove(),delete this.canvas,this.canvas=null)}clear(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.rules.PageBackgroundColor&&(this.ctx.save(),this.ctx.setFillStyle(this.rules.PageBackgroundColor),this.zoom=1,this.ctx.fillRect(0,0,this.canvas.width/this.zoom,this.canvas.height/this.zoom),this.ctx.restore())}scale(r){this.ctx.scale(r,r)}translate(r,b){this.CanvasRenderingCtx.translate(r,b)}renderText(r,b,S,v,w,T,g=void 0,x=void 0){const P=this.CanvasRenderingCtx.font;this.CanvasRenderingCtx.save(),this.CanvasRenderingCtx.font=a.VexFlowConverter.font(r,b,S,this.rules,x),this.CanvasRenderingCtx.fillStyle=g,this.CanvasRenderingCtx.strokeStyle=g,this.CanvasRenderingCtx.fillText(v,T.x,T.y+w),this.CanvasRenderingCtx.restore(),this.CanvasRenderingCtx.font=P}renderRectangle(r,b,S,v=1){const w=this.CanvasRenderingCtx.fillStyle;this.CanvasRenderingCtx.fillStyle=S||a.VexFlowConverter.style(b),this.CanvasRenderingCtx.globalAlpha=v,this.ctx.fillRect(r.x,r.y,r.width,r.height),this.CanvasRenderingCtx.fillStyle=w,this.CanvasRenderingCtx.globalAlpha=1}renderLine(r,b,S="#FF0000FF",v=2,w){const T=this.CanvasRenderingCtx.strokeStyle;this.CanvasRenderingCtx.strokeStyle=S,this.CanvasRenderingCtx.beginPath(),this.CanvasRenderingCtx.moveTo(r.x,r.y),this.CanvasRenderingCtx.lineTo(b.x,b.y),this.CanvasRenderingCtx.stroke(),this.CanvasRenderingCtx.strokeStyle=T}renderCurve(r){this.ctx.beginPath(),this.ctx.moveTo(r[0].x,r[0].y),this.ctx.bezierCurveTo(r[1].x,r[1].y,r[2].x,r[2].y,r[3].x,r[3].y),this.ctx.lineTo(r[7].x,r[7].y),this.ctx.bezierCurveTo(r[6].x,r[6].y,r[5].x,r[5].y,r[4].x,r[4].y),this.ctx.lineTo(r[0].x,r[0].y),this.ctx.closePath(),this.ctx.fill()}renderPath(r,b=!0,S){let v;this.ctx.beginPath();for(const w of r)v?this.ctx.lineTo(w.x,w.y):(this.ctx.moveTo(w.x,w.y),v=w);this.ctx.closePath(),b?this.ctx.fill():this.ctx.stroke()}get CanvasRenderingCtx(){return this.ctx.vexFlowCanvasContext}}y.CanvasVexFlowBackend=u},9436(St,y,p){var d=this&&this.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(y,"__esModule",{value:!0}),y.SvgVexFlowBackend=void 0;var l=d(p(3206)).default.Flow;const m=p(1902),a=p(6014),s=p(2570),h=p(624),u=d(p(3065));class f extends m.VexFlowBackend{constructor(b){super(),this.rules=b}getVexflowBackendType(){return l.Renderer.Backends.SVG}getOSMDBackendType(){return h.BackendType.SVG}getCanvasSize(){var b;return(b=document.getElementById("osmdCanvasPage"+this.graphicalMusicPage.PageNumber))==null?void 0:b.offsetHeight}initialize(b,S){this.zoom=S,this.canvas=document.createElement("div"),this.canvas.id="osmdCanvasPage"+this.graphicalMusicPage.PageNumber,this.inner=this.canvas,this.inner.style.position="relative",this.canvas.style.zIndex="0",b.appendChild(this.inner),this.renderer=new l.Renderer(this.canvas,this.getVexflowBackendType()),this.ctx=this.renderer.getContext(),this.ctx.svg.id="osmdSvgPage"+this.graphicalMusicPage.PageNumber}getContext(){return this.ctx}getSvgElement(){return this.ctx.svg}removeNode(b){var v;const S=(v=this.ctx)==null?void 0:v.svg;if(!S)return!1;try{S.removeChild(b)}catch(w){return u.default.error(w),!1}return!0}free(){const b=this.ctx.svg;for(;b.lastChild;)b.removeChild(b.lastChild)}clear(){this.ctx&&(this.free(),this.rules.PageBackgroundColor&&(this.ctx.svg.style["background-color"]=this.rules.PageBackgroundColor))}scale(b){this.ctx.scale(b,b)}translate(b,S){}renderText(b,S,v,w,T,g,x=void 0,P=void 0){this.ctx.save();const _=this.ctx.openGroup("text");x&&(this.ctx.attributes.fill=x,this.ctx.attributes.stroke=x);let B=P;P&&P!=="default"||(B=this.rules.DefaultFontFamily),this.ctx.setFont(B,b,a.VexFlowConverter.fontStyle(S)),this.ctx.attributes["font-size"]=`${b}px`,this.ctx.state["font-size"]=`${b}px`;let k="normal",R="normal";switch(S){case s.FontStyles.Bold:k="bold";break;case s.FontStyles.Italic:R="italic";break;case s.FontStyles.BoldItalic:k="bold",R="italic";break;default:k="normal"}return this.ctx.attributes["font-weight"]=k,this.ctx.state["font-weight"]=k,this.ctx.attributes["font-style"]=R,this.ctx.state["font-style"]=R,this.ctx.fillText(w,g.x,g.y+T),this.ctx.closeGroup(),this.ctx.restore(),_}renderRectangle(b,S,v,w=1){this.ctx.save();const T=this.ctx.openGroup("rect");return this.ctx.attributes.fill=v||a.VexFlowConverter.style(S),this.ctx.attributes["fill-opacity"]=w,this.ctx.fillRect(b.x,b.y,b.width,b.height),this.ctx.restore(),this.ctx.attributes["fill-opacity"]=1,this.ctx.closeGroup(),T}renderLine(b,S,v="#FF0000FF",w=2,T){this.ctx.save();const g=this.ctx.openGroup("line",T);return this.ctx.beginPath(),this.ctx.moveTo(b.x,b.y),this.ctx.lineTo(S.x,S.y),this.ctx.attributes.stroke=v,this.ctx.lineWidth=w,this.ctx.stroke(),this.ctx.closeGroup(),this.ctx.restore(),g}renderCurve(b,S,v){let w;S&&v&&(w=`${v.getSVGId()}-slur`);const T=this.ctx.openGroup("curve",w);return this.ctx.beginPath(),this.ctx.moveTo(b[0].x,b[0].y),this.ctx.bezierCurveTo(b[1].x,b[1].y,b[2].x,b[2].y,b[3].x,b[3].y),this.ctx.lineTo(b[7].x,b[7].y),this.ctx.bezierCurveTo(b[6].x,b[6].y,b[5].x,b[5].y,b[4].x,b[4].y),this.ctx.lineTo(b[0].x,b[0].y),this.ctx.closePath(),this.ctx.fill(),this.ctx.closeGroup(),T}renderPath(b,S=!0,v){const w=this.ctx.openGroup("path",v);let T;this.ctx.beginPath();for(const g of b)T?this.ctx.lineTo(g.x,g.y):(this.ctx.moveTo(g.x,g.y),T=g);return this.ctx.closePath(),S?this.ctx.fill():this.ctx.stroke(),this.ctx.stroke(),this.ctx.closeGroup(),w}export(){const b=this.ctx.svg.cloneNode(!0),S=document.implementation.createDocumentType("svg","-//W3C//DTD SVG 1.1//EN","http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"),v=document.implementation.createDocument("http://www.w3.org/2000/svg","svg",S);v.replaceChild(b,v.documentElement);const w=new XMLSerializer().serializeToString(v),T=document.createElement("a");T.href="data:image/svg+xml; charset=utf8, "+encodeURIComponent(w.replace(/> -\r<`)),T.download="opensheetmusicdisplay_download.svg",T.innerHTML=window.location.href+"/download",document.body.appendChild(T)}}y.SvgVexFlowBackend=f},1902(St,y,p){var d=this&&this.__importDefault||function(m){return m&&m.__esModule?m:{default:m}};Object.defineProperty(y,"__esModule",{value:!0}),y.VexFlowBackend=y.VexFlowBackends=void 0;var l=d(p(3206)).default.Flow;y.VexFlowBackends=class{},y.VexFlowBackend=class{getInnerElement(){return this.inner}getCanvas(){return this.canvas}getRenderElement(){let m=this.canvas;return this.getVexflowBackendType()===l.Renderer.Backends.CANVAS&&(m=this.inner),m}getRenderer(){return this.renderer}removeAllChildrenFromContainer(m){for(;m.children.length!==0;)m.removeChild(m.children.item(0))}removeFromContainer(m){const a=this.getRenderElement();for(let s=0;s1e-4;){const $=W.RealValue;if($>=2)z.push("1/2"),W.Sub(new s.Fraction(2,1));else if($>=1)z.push("w"),W.Sub(new s.Fraction(1,1));else if($<1&&$>=.5){if(C&&$>.5)return["w"];z.push("h"),W.Sub(new s.Fraction(1,2))}else if($<.5&&$>=.25){if(C&&$>.25)return["h"];z.push("q"),W.Sub(new s.Fraction(1,4))}else if($<.25&&$>=.125){if(C&&$>.125)return["q"];z.push("8"),W.Sub(new s.Fraction(1,8))}else if($<.125&&$>=.0625){if(C&&$>.0625)return["8"];z.push("16"),W.Sub(new s.Fraction(1,16))}else if($<.0625&&$>=.03125){if(C&&$>.03125)return["16"];z.push("32"),W.Sub(new s.Fraction(1,32))}else if($<.03125&&$>=.015625){if(C&&$>.015625)return["32"];z.push("64"),W.Sub(new s.Fraction(1,64))}else{if(C)return["64"];z.push("128"),W.Sub(new s.Fraction(1,128))}}return z}static pitch(U,C,z,W=void 0,$=void 0){let N=$;$===void 0&&(N=3),C&&$===void 0&&(N=0,z.ClefType===m.ClefEnum.F&&(N=2),z.ClefType===m.ClefEnum.C&&(N=2));const Y=r.NoteEnum[U.FundamentalNote].toLowerCase(),tt=a.Pitch.accidentalVexflow(U.Accidental),H=U.Octave-z.OctaveOffset+N;let rt="";return W&&(rt=this.NoteHeadCode(W)),[Y+"n/"+H+rt,tt,z]}static restToNotePitch(U,C){let z=U.Octave;switch(C){case m.ClefEnum.C:case m.ClefEnum.F:z+=2;case m.ClefEnum.G:}return new a.Pitch(U.FundamentalNote,z,f.AccidentalEnum.NONE)}static NoteHeadCode(U){const C=U.Filled?"2":"1";switch(U.Shape){case _.NoteHeadShape.NORMAL:case _.NoteHeadShape.NONE:return"";case _.NoteHeadShape.DIAMOND:return"/D"+C;case _.NoteHeadShape.TRIANGLE:return"/T"+C;case _.NoteHeadShape.TRIANGLE_INVERTED:return"/TI";case _.NoteHeadShape.X:return"/X"+C;case _.NoteHeadShape.CIRCLEX:return"/X3";case _.NoteHeadShape.RECTANGLE:return"/R"+C;case _.NoteHeadShape.SQUARE:return"/S"+C;case _.NoteHeadShape.SLASH:default:return""}}static GhostNotes(U){const C=[],z=A.durations(U,!1);for(const W of z)C.push(new l.GhostNote({duration:W}));return C}static StaveNote(U){var J,q,et,it,dt,mt,yt,Et,Dt,Vt,Nt;U.sortForVexflow();const C=U.notes,z=U.parentStaffEntry.parentMeasure.parentSourceMeasure.Rules,W=C[0];let $=[];const N=[],Y=W.graphicalNoteLength,tt=W.sourceNote.NoteTuplet!==void 0;let H,rt=A.durations(Y,tt)[0];W.sourceNote.TypeLength!==void 0&&W.sourceNote.TypeLength!==Y&&W.sourceNote.TypeLength.RealValue!==0&&(rt=A.durations(W.sourceNote.TypeLength,tt)[0],W.numberOfDots=W.sourceNote.DotsXml);let ct,st,at=W.numberOfDots,ht=!1,lt=0,O=!1;for(const It of C){if(at=1&&Xt.length-1>=qt+1&&(Ut=(mt=(dt=Xt[qt-1])==null?void 0:dt.graphicalVoiceEntries[0])==null?void 0:mt.parentVoiceEntry,Kt=(Et=(yt=Xt[qt+1])==null?void 0:yt.graphicalVoiceEntries[0])==null?void 0:Et.parentVoiceEntry,Ut&&Kt)){const Qt=Ut.Notes[0],te=Kt.Notes[0];if((Dt=Qt.NoteBeam)!=null&&Dt.Notes.includes(te)){const ie=Ut.Notes.last().Pitch,$t=It.Clef();$=[A.pitch(A.restToNotePitch(ie.getTransposedPitch(-2),$t.ClefType),!1,$t)[0]]}}}}if((It.sourceNote.IsWholeMeasureRest||Y.RealValue===It.sourceNote.SourceMeasure.ActiveTimeSignature.RealValue)&&($=["d/5"],U.parentStaffEntry.parentMeasure.ParentStaff.StafflineCount===1&&($=["b/4"]),rt="w",at=0,ht=!0,lt=z.WholeRestXShiftVexflow*B.unitInPixels),It.sourceNote.ParentStaff.Voices.length>1){const zt=It.parentVoiceEntry.parentStaffEntry.graphicalVoiceEntries,Xt=It.parentVoiceEntry.parentVoiceEntry.ParentVoice.VoiceId;let Ut,Kt;for(const qt of zt)for(const Qt of qt.notes){if(Qt===It||Qt.sourceNote.isRest()||!Qt.sourceNote.PrintObject)continue;const te=Qt.parentVoiceEntry.parentVoiceEntry.WantedStemDirection,ie=Xt===1||Xt===5,$t=ie?1:-1,ae=Qt.sourceNote.Pitch.getHalfTone();(!Ut||$t===1&&ae>Ut||$t===-1&&ae0){let qt=3;const Qt=It.Clef();switch(Qt.ClefType){case m.ClefEnum.F:qt=5;break;case m.ClefEnum.C:qt=4}ct=a.Pitch.fromHalftone(Ut),$=[A.pitch(ct,!0,Qt,void 0,qt)[0]]}}break}const Ct=It.vfpitch;$.push(Ct[0]),N.push(Ct[1]),H||(H=A.Clef(Ct[2]).type)}for(let It=0,Ct=at;It0&&z.RenderLyrics&&z.LyricsUseXPaddingForLongLyrics){const Xt=U.parentStaffEntry.parentMeasure,Ut=[];for(let Qt=Xt.staffEntries.indexOf(U.parentStaffEntry)+1;Qt.25){Ct=!1;break}if(Qt.LyricsEntries.length>0)break;zt+=32*s.Fraction.minus(te,qt).RealValue,qt=te}}if(z.RenderLyrics&&z.LyricsUseXPaddingForLongLyrics&&It.length>0&&Ct){let Xt=!1,Ut=0;for(const qt of C)if(qt.sourceNote.Length.RealValue<=.125){Xt=!0;break}let Kt=!1;for(const qt of It){const Qt=z.LyricsXPaddingWidthThreshold;let te=qt.GraphicalLabel.PositionAndShape.Size.width;if(qt.hasDashFromLyricWord()&&(te+=.5),te>Qt){Ut+=te-Qt;const ie=U.parentStaffEntry,$t=ie.parentMeasure.staffEntries,ae=$t.indexOf(ie)===$t.length-1,Ke=ae&&qt.hasDashFromLyricWord();ae&&(zt+=Ke?z.LyricsXPaddingReductionForLastNoteInMeasureCrossMeasureMidWord:z.LyricsXPaddingReductionForLastNoteInMeasure),Xt||(zt+=z.LyricsXPaddingReductionForLongNotes),!z.LyricsXPaddingForLastNoteInMeasure&&ae||te>Qt+zt&&(Kt=!0,Ut-=zt);break}}Kt&&(st.paddingRight=10*z.LyricsXPaddingFactorForLongLyrics*Ut)}}const Q=U.notes[0].lineShift;if(Q!==0&&(st.getKeyProps()[0].line+=Q),C.length>1)for(let It=0;ItU.notes[Ct].staffLine=It),(z.LedgerLineWidth||z.LedgerLineStrokeStyle)&&(st.ledgerLineStyle||(st.ledgerLineStyle={}),z.LedgerLineWidth&&(st.ledgerLineStyle.lineWidth=z.LedgerLineWidth),z.LedgerLineStrokeStyle&&(st.ledgerLineStyle.strokeStyle=z.LedgerLineStrokeStyle)),z.ColoringEnabled){const It=z.DefaultColorStem;let Ct=U.parentVoiceEntry.StemColor;!Ct&&It&&(Ct=It);const zt={fillStyle:Ct,strokeStyle:Ct};Ct&&(st.setStemStyle(zt),st.flag&&z.ColorFlags&&st.setFlagStyle(zt))}if(st.x_shift=lt,U.parentVoiceEntry.IsGrace&&U.notes[0].sourceNote.NoteBeam&&(U.parentVoiceEntry.WantedStemDirection=U.notes[0].sourceNote.NoteBeam.Notes[0].ParentVoiceEntry.WantedStemDirection),U.parentVoiceEntry)switch(U.parentVoiceEntry.WantedStemDirection){case g.StemDirectionType.Up:st.setStemDirection(l.Stem.UP),U.parentVoiceEntry.StemDirection=g.StemDirectionType.Up;break;case g.StemDirectionType.Down:st.setStemDirection(l.Stem.DOWN),U.parentVoiceEntry.StemDirection=g.StemDirectionType.Down}for(let It=0,Ct=C.length;It0){const Xt=new l.Tremolo(zt);Xt.extra_stroke_scale=z.TremoloStrokeScale,Xt.y_spacing_scale=z.TremoloYSpacingScale,st.addModifier(It,Xt)}}if(j.Length.RealValue===.25&&j.Notehead&&j.Notehead.Filled===!1){const It=st.getKeyProps();for(let Ct=0;Ct");const tt=C.sourceNote.NoteSlurs;for(const H of tt)H.StartNote===C.sourceNote&&(H.PlacementXml===F.PlacementEnum.Above?$.setYShift(10*-z.SlurStartArticulationYOffsetOfArticulation):H.PlacementXml===F.PlacementEnum.Below&&$.setYShift(10*z.SlurStartArticulationYOffsetOfArticulation));$.render_options={...$.render_options,extra_left_px:0,extra_right_px:0},$.getWidth&&($.getWidth=function(){return 0});break}case g.ArticulationEnum.breathmark:$=new l.Articulation("abr"),W.placement===F.PlacementEnum.Above&&(N=l.Modifier.Position.ABOVE),$.breathMarkDistance=z.BreathMarkDistance;break;case g.ArticulationEnum.downbow:$=new l.Articulation("am"),W.placement===void 0&&(N=l.Modifier.Position.ABOVE,W.placement=F.PlacementEnum.Above);break;case g.ArticulationEnum.fermata:$=new l.Articulation("a@a"),N=l.Modifier.Position.ABOVE,W.placement=F.PlacementEnum.Above;break;case g.ArticulationEnum.marcatodown:$=new l.Articulation("a|");break;case g.ArticulationEnum.marcatoup:$=new l.Articulation("a^"),N=l.Modifier.Position.ABOVE;break;case g.ArticulationEnum.invertedfermata:{const tt=C.sourceNote.ParentVoiceEntry;if(tt!==C.sourceNote.ParentVoiceEntry.ParentSourceStaffEntry.VoiceEntries.last()){tt.Articulations=tt.Articulations.slice(tt.Articulations.indexOf(W)),tt.ParentSourceStaffEntry.VoiceEntries.last().Articulations.push(W);continue}$=new l.Articulation("a@u"),N=l.Modifier.Position.BELOW,W.placement=F.PlacementEnum.Below;break}case g.ArticulationEnum.lefthandpizzicato:$=new l.Articulation("a+");break;case g.ArticulationEnum.naturalharmonic:$=new l.Articulation("ah");break;case g.ArticulationEnum.snappizzicato:$=new l.Articulation("ao");break;case g.ArticulationEnum.staccatissimo:$=new l.Articulation("av");break;case g.ArticulationEnum.staccato:$=new l.Articulation("a.");break;case g.ArticulationEnum.tenuto:$=new l.Articulation("a-");break;case g.ArticulationEnum.upbow:$=new l.Articulation("a|"),W.placement===void 0&&(N=l.Modifier.Position.ABOVE,W.placement=F.PlacementEnum.Above);break;case g.ArticulationEnum.strongaccent:$=new l.Articulation("a^")}$&&($.setPosition(N),U.addModifier(0,$))}}static generateOrnaments(U,C){let z,W=l.Modifier.Position.ABOVE;switch(C.placement===F.PlacementEnum.Below&&(W=l.Modifier.Position.BELOW),C.GetOrnament){case P.OrnamentEnum.DelayedInvertedTurn:z=new l.Ornament("turn_inverted"),z.setDelayed(!0);break;case P.OrnamentEnum.DelayedTurn:z=new l.Ornament("turn"),z.setDelayed(!0);break;case P.OrnamentEnum.InvertedMordent:z=new l.Ornament("mordent"),z.setDelayed(!1);break;case P.OrnamentEnum.InvertedTurn:z=new l.Ornament("turn_inverted"),z.setDelayed(!1);break;case P.OrnamentEnum.Mordent:z=new l.Ornament("mordent_inverted"),z.setDelayed(!1);break;case P.OrnamentEnum.Trill:z=new l.Ornament("tr"),z.setDelayed(!1);break;case P.OrnamentEnum.Turn:z=new l.Ornament("turn"),z.setDelayed(!1);break;default:return void T.default.warn("unhandled OrnamentEnum type: "+C.GetOrnament)}z&&(C.AccidentalBelow!==f.AccidentalEnum.NONE&&z.setLowerAccidental(a.Pitch.accidentalVexflow(C.AccidentalBelow)),C.AccidentalAbove!==f.AccidentalEnum.NONE&&z.setUpperAccidental(a.Pitch.accidentalVexflow(C.AccidentalAbove)),z.setPosition(W),U.addModifier(0,z))}static StrokeTypeFromArpeggioType(U){switch(U){case k.ArpeggioType.ARPEGGIO_DIRECTIONLESS:return l.Stroke.Type.ARPEGGIO_DIRECTIONLESS;case k.ArpeggioType.BRUSH_DOWN:return l.Stroke.Type.BRUSH_UP;case k.ArpeggioType.BRUSH_UP:return l.Stroke.Type.BRUSH_DOWN;case k.ArpeggioType.RASQUEDO_DOWN:return l.Stroke.Type.RASQUEDO_UP;case k.ArpeggioType.RASQUEDO_UP:return l.Stroke.Type.RASQUEDO_DOWN;case k.ArpeggioType.ROLL_DOWN:return l.Stroke.Type.ROLL_UP;case k.ArpeggioType.ROLL_UP:return l.Stroke.Type.ROLL_DOWN;default:return l.Stroke.Type.ARPEGGIO_DIRECTIONLESS}}static CreateTabNote(U){var st;const C=[],z=U.notes.reverse(),W=[],$=U.notes[0].graphicalNoteLength,N=U.notes[0].sourceNote.NoteTuplet!==void 0;let Y=A.durations($,N)[0],tt=0;const H=U.parentStaffEntry.parentMeasure.parentSourceMeasure.Rules;let rt=!1;for(const at of U.notes){const ht=at.sourceNote;let lt={str:ht.StringNumberTab,fret:ht.FretNumber};at.sourceNote instanceof R.TabNote||(T.default.info(`invalid tab note: ${at.sourceNote.Pitch.ToString()} in measure ${U.parentStaffEntry.parentMeasure.MeasureNumber}, likely missing XML string+fret number.`),lt={str:1,fret:0}),H.TabUseXNoteheadShapeForTabNote&&((st=at.sourceNote.Notehead)==null?void 0:st.Shape)===_.NoteHeadShape.X&&(lt.fret="x",rt=!0),C.push(lt),ht.BendArray&&ht.BendArray.forEach(function(O){let D;const j=O.bendalter-lt.fret;D=j>1?"Full":j===1?"1/2":"1/4",O.direction==="up"?W.push({type:l.Bend.UP,text:D,width:10}):W.push({type:l.Bend.DOWN,text:D,width:10})}),ttthis.vfnoteIndex&&r[this.vfnoteIndex]?f.note_heads[this.vfnoteIndex]:{line:0}}Clef(){return this.clef}getSVGId(){if(this.vfnote)return this.vfnote[0].getAttribute("id")}setVisible(u,f={}){var P,_;const r=f.applyToBeams??!0,b=f.applyToLedgerLines??!0,S=f.applyToNotehead??!0,v=f.applyToSlurs??!0,w=f.applyToStem??!0,T=f.applyToTies??!0,g="visibility",x=u?"visible":"hidden";if(S&&((P=this.getSVGGElement())==null||P.setAttribute(g,x)),w&&((_=this.getStemSVG())==null||_.setAttribute(g,x)),r)for(const B of this.getBeamSVGs())B==null||B.setAttribute(g,x);if(b)for(const B of this.getLedgerLineSVGs())B==null||B.setAttribute(g,x);if(T)for(const B of this.getTieSVGs())B==null||B.setAttribute(g,x);if(v)for(const B of this.getSlurSVGs())B==null||B.setAttribute(g,x)}getSVGGElement(){if(this.vfnote)return this.vfnote[0].getAttribute("el")}getStemSVG(){const u=document.getElementById("vf-"+this.getSVGId()+"-stem");return(u==null?void 0:u.children.length)>0?u.children[0]:u}getBeamSVGs(){const u=[];for(let f=0;;f++){const r=document.getElementById(`vf-${this.getSVGId()}-beam${f}`);if(!r)break;u.push(r)}return u}getLedgerLineSVGs(){const u=[],f=`vf-${this.getSVGId()}ledgers`,r=document.getElementById(f);if(!r)return[];for(const b of r.childNodes)u.push(b);return u}getTieSVGs(){const u=[],f=document.querySelectorAll(`[id='vf-${this.getSVGId()}-tie']`);for(const r of f)u.push(r);return u}getSlurSVGs(){const u=[],f=document.querySelectorAll(`[id='vf-${this.getSVGId()}-slur']`);for(const r of f)u.push(r);return u}getNoteheadSVGs(){var r;const u=this.getVFNoteSVG(),f=[];if((r=u==null?void 0:u.children)!=null&&r.length)for(const b of u.children)b.classList.contains("vf-notehead")&&f.push(b);return f}getFlagSVG(){var f;const u=this.getVFNoteSVG();if((f=u==null?void 0:u.children)!=null&&f.length){for(const r of u.children)if(r.classList.contains("vf-flag"))return r}}getVFNoteSVG(){if(this.parentVoiceEntry.parentStaffEntry.parentMeasure.isMultiRestMeasure())return this.parentVoiceEntry.parentStaffEntry.parentMeasure.multiRestElement;const u=this.getSVGGElement();if(u){for(const f of u.children)if(f.classList.contains("vf-note"))return f}}getModifierSVGs(){const u=this.getSVGGElement(),f=[];if(!(u!=null&&u.children))return f;if(u.children.length)for(const r of u.children)r.classList.contains("vf-modifiers")&&f.push(r);return f}setColor(u,f={}){var R,F;const r=f.applyToBeams??!1,b=f.applyToFlag??!0,S=f.applyToLedgerLines??!1,v=f.applyToLyrics??!1,w=f.applyToModifiers??!0,T=f.applyToNoteheads??!0,g=f.applyToSlurs??!1,x=f.applyToStem??!0,P=f.applyToTies??!1,_=f.applyToMultiRestMeasure??!0,B=f.applyToMultiRestMeasureNumber??!0,k=f.applyToMultiRestMeasureRestBar??!0;if(r){const A=this.getBeamSVGs();for(const G of A)for(const U of G.children)U.setAttribute("fill",u)}if(b){const A=this.getFlagSVG();if(A)for(const G of A.children)G.setAttribute("fill",u)}if(S){const A=this.getLedgerLineSVGs();for(const G of A)G.setAttribute("stroke",u)}if(v){const A=this.getLyricsSVGs();for(const G of A)for(const U of G.children)U.setAttribute("stroke",u),U.setAttribute("fill",u)}if(_&&this.parentVoiceEntry.parentStaffEntry.parentMeasure instanceof a.VexFlowMultiRestMeasure){const A=this.parentVoiceEntry.parentStaffEntry.parentMeasure.multiRestElementSVG;if((R=A==null?void 0:A.children)!=null&&R.length)for(const G of A.children)if((F=G.children)!=null&&F.length){if(B)for(const U of G.children)U.setAttribute("fill",u)}else k&&G.setAttribute("fill",u)}if(w){const A=this.getModifierSVGs();for(const G of A)for(const U of G.children)U.setAttribute("fill",u)}if(T){const A=this.getNoteheadSVGs();for(const G of A)for(const U of G.children)U.setAttribute("fill",u)}if(g){const A=this.getSlurSVGs();for(const G of A)for(const U of G.children)U.setAttribute("fill",u)}if(x){const A=this.getStemSVG();A&&A.setAttribute("stroke",u)}if(P){const A=this.getTieSVGs();for(const G of A)for(const U of G.children)U.setAttribute("fill",u)}}}y.VexFlowGraphicalNote=s},3753(St,y,p){var d=this&&this.__importDefault||function(g){return g&&g.__esModule?g:{default:g}};Object.defineProperty(y,"__esModule",{value:!0}),y.VexFlowGraphicalSymbolFactory=void 0;var l=d(p(3206)).default.Flow;const m=p(4332),a=p(5246),s=p(6670),h=p(437),u=p(9635),f=p(6659),r=p(4134),b=p(6014),S=p(6173),v=p(5866),w=p(3849),T=p(6362);y.VexFlowGraphicalSymbolFactory=class{createMusicSystem(g,x){return new m.VexFlowMusicSystem(g,x)}createStaffLine(g,x){return new v.VexFlowStaffLine(g,x)}createGraphicalMeasure(g,x,P=!1){return new a.VexFlowMeasure(x,g,void 0)}createMultiRestMeasure(g,x,P){return new w.VexFlowMultiRestMeasure(x,g,P)}createTabStaffMeasure(g,x){return new S.VexFlowTabMeasure(x,g)}createExtraGraphicalMeasure(g){const x=new a.VexFlowMeasure(g.ParentStaff,void 0,g);return x.IsExtraGraphicalMeasure=!0,x.ExtraGraphicalMeasurePreviousMeasure=g.Measures.last(),x}createStaffEntry(g,x){return new s.VexFlowStaffEntry(x,g,void 0)}createVoiceEntry(g,x){return new r.VexFlowVoiceEntry(g,x)}createNote(g,x,P,_=h.OctaveEnum.NONE,B,k=void 0){return new u.VexFlowGraphicalNote(g,x,P,_,B,k)}createGraceNote(g,x,P,_,B=h.OctaveEnum.NONE){return new u.VexFlowGraphicalNote(g,x,P,B,_)}addGraphicalAccidental(g,x){g.setAccidental(x)}addFermataAtTiedEndNote(g,x){}createInStaffClef(g,x){const P=g,_=b.VexFlowConverter.Clef(x,"small");P.vfClefBefore=new l.ClefNote(_.type,_.size,_.annotation)}createChordSymbols(g,x,P,_){const B=x.parentMeasure.parentSourceMeasure.Rules;let k=0;const R=B.ChordSymbolXSpacing;for(const F of g.ChordContainers){if(!F)continue;let A=x.PositionAndShape;x.graphicalVoiceEntries.length===1&&x.graphicalVoiceEntries[0].notes.length===1&&x.graphicalVoiceEntries[0].notes[0].sourceNote.isWholeRest()&&(A=x.parentMeasure.PositionAndShape,k+=x.parentMeasure.beginInstructionsWidth,k+=B.ChordSymbolWholeMeasureRestXOffset);const G=new f.GraphicalChordSymbolContainer(F,A,B.ChordSymbolTextHeight,P,_,B),U=G.GetChordSymbolContainer.Placement,C=G.GraphicalLabel;U===T.PlacementEnum.Below?C.PositionAndShape.RelativePosition.y=B.StaffHeight+B.ChordSymbolYOffset:C.PositionAndShape.RelativePosition.y-=B.ChordSymbolYOffset,C.setLabelPositionAndShapeBorders();let z=0;C.PositionAndShape.Size.width=0&&(z.parentVoiceEntry.PositionAndShape.RelativePosition.y=(C.StringNumberTab-1)*this.rules.TabStaffInterlineHeightForBboxes)}else for(const A of this.getVoicesWithinMeasure())for(const G of A.VoiceEntries)for(const U of G.Notes){if(U.isRest())continue;const C=this.rules.GNote(U);if(!(C!=null&&C.vfnote))return;const z=C.vfnote[0];let W=0;C.parentVoiceEntry.parentVoiceEntry.StemDirection===w.StemDirectionType.Up&&C.vfnote[0].getDuration()!=="w"?W+=3.5:W+=.5,W+=-C.notehead(z).line+C.parentVoiceEntry.notes.last().notehead().line,C.PositionAndShape.RelativePosition.y=W}}getVoicesWithinMeasure(){const A=[];for(const G of this.staffEntries)for(const U of G.graphicalVoiceEntries)A.indexOf(U.parentVoiceEntry.ParentVoice)===-1&&A.push(U.parentVoiceEntry.ParentVoice);return A}getGraphicalVoiceEntriesPerVoice(A){const G=[];for(const U of this.staffEntries)for(const C of U.graphicalVoiceEntries)C.parentVoiceEntry.ParentVoice===A&&G.push(C);return G}getRestFilledVexFlowStaveNotesPerVoice(A){let G,U=this.getGraphicalVoiceEntriesPerVoice(A);for(let W=0;W0){r.default.trace(`Ghost Found in between (measure ${this.MeasureNumber})`);const H=this.createGhostGves(tt);U.splice(W,0,...H),W+=H.length}}else{const tt=g.Fraction.minus(N,this.parentSourceMeasure.AbsoluteTimestamp);if(tt.RealValue>0){r.default.trace(`Ghost Found at start (measure ${this.MeasureNumber})`);const H=this.createGhostGves(tt);U.splice(0,0,...H),W+=H.length}}G=Y}const C=g.Fraction.plus(this.parentSourceMeasure.AbsoluteTimestamp,this.parentSourceMeasure.Duration),z=g.Fraction.minus(C,G);if(z.RealValue>0){r.default.trace(`Ghost Found at end (measure ${this.MeasureNumber})`);const W=this.createGhostGves(z);U=U.concat(W)}return U}createGhostGves(A){const G=h.VexFlowConverter.GhostNotes(A),U=[];for(const C of G){const z=new T.VexFlowVoiceEntry(void 0,void 0,this.rules);z.vfStaveNote=C,U.push(z)}return U}handleBeam(A,G){const U=A.sourceNote.ParentVoiceEntry.ParentVoice.VoiceId;let C,z=this.beams[U];z||(z=this.beams[U]=[]);for(const $ of z)$[0]===G&&(C=$);C||(C=[G,[]],z.push(C));const W=A.parentVoiceEntry;C[1].indexOf(W)<0&&C[1].push(W)}handleTuplet(A,G){const U=A.sourceNote.ParentVoiceEntry.ParentVoice.VoiceId;G=A.sourceNote.NoteTuplet;let C,z=this.tuplets[U];z||(z=this.tuplets[U]=[]);for(const $ of z)$[0]===G&&(C=$);C||(C=[G,[]],z.push(C));const W=A.parentVoiceEntry;C[1].indexOf(W)<0&&C[1].push(W)}finalizeBeams(){var G;if(this.vfbeams={},this.isTabMeasure&&!this.rules.TabBeamsRendered)return;const A=[];for(const U in this.beams)if(this.beams.hasOwnProperty(U)){let C=this.vfbeams[U];C||(C=this.vfbeams[U]=[]);for(const z of this.beams[U]){let W=!1;for(const st of z[0].Notes)if(st.Length.RealValue>=new g.Fraction(1,4).RealValue&&(!st.TypeLength||st.TypeLength.RealValue>.125)){W=!0;break}if(W){r.default.debug("Beam between note >= quarter, likely tremolo, currently unsupported. continuing.");continue}const $=[],N=z[0],Y=z[1];let tt=!0;for(const st of Y)st.parentVoiceEntry.ParentVoice===N.Notes[0].ParentVoiceEntry.ParentVoice&&(tt=st.parentVoiceEntry.WantedStemDirection===w.StemDirectionType.Undefined);let H,rt=!1;const ct=[];for(const st of Y){const at=st.vfStaveNote;at&&($.push(at),A.push(at)),st.parentVoiceEntry.IsGrace&&(rt=!0),st.parentVoiceEntry.StemColor&&this.rules.ColoringEnabled&&ct.push(st.parentVoiceEntry.StemColor)}if($.length>1){const st=new l.Beam($,tt);if(((G=N.SecondaryBreakIndices)==null?void 0:G.length)>0&&st.breakSecondaryAt(N.SecondaryBreakIndices),rt&&(st.render_options.beam_width=3,st.render_options.partial_beam_length=4),ct.length>=2&&this.rules.ColorBeams){H=ct[0];for(const at of ct)if(at!==H){H=void 0;break}st.setStyle({fillStyle:H,strokeStyle:H})}this.rules.FlatBeams&&(st.render_options.flat_beams=!0,st.render_options.flat_beam_offset=this.rules.FlatBeamOffset,st.render_options.flat_beam_offset_per_beam=this.rules.FlatBeamOffsetPerBeam),C.push(st)}else r.default.debug("Warning! Beam with no notes!")}}this.rules.AutoBeamNotes&&this.autoBeamNotes(A)}autoBeamNotes(A){if(!this.rules.AutoBeamTabs&&this.isTabMeasure)return;let G,U=60,C=[],z=[],W=[];this.autoTupletVfBeams=[];const $=[];this.autoVfBeams=[];let N=this.parentSourceMeasure.ActiveTimeSignature;N||(N=this.parentSourceMeasure.Duration);for(const H of this.staffEntries)for(const rt of H.graphicalVoiceEntries){const ct=rt.vfStaveNote,st=rt.notes[0],at={vfStaveNote:ct,sourceNote:st.sourceNote},ht=H.relInMeasureTimestamp.isOnBeat(N),lt=z.length>=2,O=st.sourceNote.Length.RealValue-new g.Fraction(1,4).RealValue>-g.Fraction.FloatInaccuracyTolerance,D=rt.parentVoiceEntry.IsGrace||O||A.contains(ct);if(D||ht){if(lt){for(const Q of z)C.push(Q);$.push(C.slice()),C=[]}if(z=[],D)continue}const j=rt.notes[0].sourceNote.NoteTuplet;if(j){let Q=!1;for(const J of j.Notes){for(const q of J)if(q.NoteTypeXml>=B.NoteType.QUARTER||q.ParentVoiceEntry.IsGrace||q.isRest()&&!this.rules.AutoBeamOptions.beam_rests){Q=!0;break}if(Q)break}if(G){if(G!==j){if(W.length>1){const J=[];for(const it of W)J.push(it.vfStaveNote);const q=new l.Beam(J,!0);this.rules.FlatBeams&&(q.render_options.flat_beams=!0,q.render_options.flat_beam_offset=this.rules.FlatBeamOffset,q.render_options.flat_beam_offset_per_beam=this.rules.FlatBeamOffsetPerBeam),this.autoTupletVfBeams.push(q);const et=new u.Beam(U++);et.AutoGenerated=!0;for(const it of W)et.addNoteToBeam(it.sourceNote)}W=[],G=j}}else G=j;Q||W.push(at);continue}G=void 0,z.push(at)}if(W.length>=2){const H=[];for(const st of W)H.push(st.vfStaveNote);const rt=new l.Beam(H,!0);this.rules.FlatBeams&&(rt.render_options.flat_beams=!0,rt.render_options.flat_beam_offset=this.rules.FlatBeamOffset,rt.render_options.flat_beam_offset_per_beam=this.rules.FlatBeamOffsetPerBeam),this.autoTupletVfBeams.push(rt);const ct=new u.Beam(U++);ct.AutoGenerated=!0;for(const st of W)ct.addNoteToBeam(st.sourceNote)}if(z.length>=2){for(const H of z)C.push(H);$.push(C)}const Y=this.rules.AutoBeamOptions,tt={beam_middle_only:Y.beam_middle_rests_only,beam_rests:Y.beam_rests,maintain_stem_directions:Y.maintain_stem_directions};if(Y.groups&&Y.groups.length){const H=[];for(const rt of Y.groups)H.push(new l.Fraction(rt[0],rt[1]));tt.groups=H}for(const H of $){const rt=[];for(const st of H)rt.push(st.vfStaveNote);const ct=l.Beam.generateBeams(rt,tt);for(const st of ct)this.rules.FlatBeams&&(st.render_options.flat_beams=!0,st.render_options.flat_beam_offset=this.rules.FlatBeamOffset,st.render_options.flat_beam_offset_per_beam=this.rules.FlatBeamOffsetPerBeam),this.autoVfBeams.push(st)}}finalizeTuplets(){this.vftuplets={};for(const A in this.tuplets)if(this.tuplets.hasOwnProperty(A)){let G=this.vftuplets[A];G||(G=this.vftuplets[A]=[]);for(const U of this.tuplets[A]){const C=[],z=U[1];for(const W of z)C.push(W.vfStaveNote);if(C.length>1){const W=U[0],$=W.Notes[0][0].NormalNotes,N=W.shouldBeBracketed(this.rules.TupletsBracketedUseXMLValue,this.rules.TupletsBracketed,this.rules.TripletsBracketed,this.isTabMeasure,this.rules.TabTupletsBracketed);let Y=l.Tuplet.LOCATION_TOP;W.tupletLabelNumberPlacement===_.PlacementEnum.Below&&(Y=l.Tuplet.LOCATION_BOTTOM);let tt=0;if(this.isTabMeasure&&(tt=10*this.rules.TabTupletYOffsetBottom,Y===l.Tuplet.LOCATION_TOP)){tt=-10*this.rules.TabTupletYOffsetTop;const rt=W.Notes[0][0];rt!=null&&rt.hasTabEffects()&&(tt-=10*this.rules.TabTupletYOffsetEffects)}const H=new l.Tuplet(C,{bracketed:N,location:Y,notes_occupied:$,num_notes:W.TupletLabelNumber,ratioed:W.Ratioed,y_offset:tt});G.push(H)}else r.default.debug("Warning! Tuplet with no notes! Trying to ignore, but this is a serious problem.")}}}layoutStaffEntry(A){}graphicalMeasureCreatedCalculations(){let A,G=[];const U=[];for(const z of this.staffEntries){A=!1,G=[];for(const W of z.graphicalVoiceEntries)if(W.parentVoiceEntry.IsGrace)G.push(W),U.push(W),A||(A=W.parentVoiceEntry.GraceSlur);else if(W.vfStaveNote=h.VexFlowConverter.StaveNote(W),G.length>0){const $=[];for(let tt=0;tt0&&(H.GraceSlash=!1);const rt=h.VexFlowConverter.StaveNote(H);H.vfStaveNote=rt,$.push(rt)}const N=new l.GraceNoteGroup($,A);let Y=this.rules.GraceNoteGroupXMargin;$.length>1&&(Y/=3),N.spacing=10*Y,W.vfStaveNote.addModifier(0,N),G=[]}}if(G.length>0)for(const z of G)z.vfStaveNote=h.VexFlowConverter.StaveNote(z),z.parentVoiceEntry.GraceAfterMainNote=!0;this.finalizeBeams(),this.finalizeTuplets();const C=this.getVoicesWithinMeasure();if(this.rules.RenderFingerings)for(const z of this.staffEntries)z.setModifierXOffsets();for(const z of C){if(!z)continue;this.vfVoices[z.VoiceId]=new l.Voice({beat_value:this.parentSourceMeasure.ActiveTimeSignature.Denominator,num_beats:this.parentSourceMeasure.ActiveTimeSignature.Numerator,resolution:l.RESOLUTION}).setMode(l.Voice.Mode.SOFT);const W=this.getRestFilledVexFlowStaveNotesPerVoice(z);for(const $ of W){if($.parentVoiceEntry&&$.parentVoiceEntry.IsGrace&&!$.parentVoiceEntry.GraceAfterMainNote)continue;const N=$;if(N.vfStaveNote.getTicks().denominator===0&&(N.vfStaveNote.getTicks().denominator=1),$.notes.length>0&&$.notes[0].sourceNote&&$.notes[0].sourceNote.NoteTuplet){const tt=$.notes[0].graphicalNoteLength,H=N.vfStaveNote.getTicks();H.numerator=tt.Numerator*l.RESOLUTION,H.denominator=tt.Denominator,H.simplify()}const Y=N.parentStaffEntry;if(Y&&Y.vfClefBefore){if($.notes[0]&&!$.notes[0].sourceNote.PrintObject){const rt=this.rules.DefaultColorMusic||"#000000";Y.vfClefBefore.setStyle({fillStyle:rt,strokeStyle:rt})}const tt=new f([Y.vfClefBefore]),H=N.vfStaveNote;H&&typeof H.addModifier=="function"&&H.addModifier(0,tt)}$.notes.length!==0&&$.notes[0]&&$.notes[0].sourceNote.PrintObject?($.parentVoiceEntry&&this.rules.RenderFingerings&&(this.rules.FingeringPosition!==_.PlacementEnum.Left&&this.rules.FingeringPosition!==_.PlacementEnum.Right||this.createFingerings($),this.createStringNumber($)),this.createArpeggio($),this.vfVoices[z.VoiceId].addTickable(N.vfStaveNote)):this.vfVoices[z.VoiceId].addTickable(N.vfStaveNote)}}this.setStemDirectionFromVexFlow();for(const z of U)this.createFingerings(z),this.createStringNumber(z),this.createArpeggio(z);this.createArticulations(),this.createOrnaments()}createArpeggio(A){if(A.parentVoiceEntry&&A.parentVoiceEntry.Arpeggio){const G=A.parentVoiceEntry.Arpeggio;if(A.notes&&A.notes.length>1){const U=h.VexFlowConverter.StrokeTypeFromArpeggioType(G.type),C=new l.Stroke(U,{all_voices:this.rules.ArpeggiosGoAcrossVoices});this.rules.RenderArpeggios&&A.vfStaveNote.addStroke(0,C)}else r.default.debug(`[OSMD] arpeggio in measure ${this.MeasureNumber} could not be drawn. - voice entry had less than two notes, arpeggio is likely between voice entries, not currently supported in Vexflow.`)}}setStemDirectionFromVexFlow(){for(const A of this.staffEntries)for(const G of A.graphicalVoiceEntries)for(const U of G.notes){const C=U.vfnote;if(C&&C[0])switch(C[0].getStemDirection()){case l.Stem.UP:G.parentVoiceEntry.StemDirection=w.StemDirectionType.Up;break;case l.Stem.DOWN:G.parentVoiceEntry.StemDirection=w.StemDirectionType.Down}}}createArticulations(){for(let A=0,G=this.staffEntries.length;AU){let W=0;for(const $ of A.notes)if($.sourceNote.Fingering)W++;else{if(W>C.length-1)break;$.sourceNote.Fingering=C[W],W++}}let z=-1;for(const W of A.notes){const $=W.sourceNote.Fingering;if(!$){z++;continue}z++;let N=this.rules.FingeringPosition;this.rules.FingeringPositionGrace===_.PlacementEnum.AboveOrBelow&&(this.isUpperStaffOfInstrument()?N=_.PlacementEnum.Above:this.isLowerStaffOfInstrument()&&(N=_.PlacementEnum.Below)),$.placement!==_.PlacementEnum.NotYetDefined&&(N=$.placement);let Y,tt=this.rules.FingeringOffsetX;switch(N){default:case _.PlacementEnum.Left:Y=l.StaveModifier.Position.LEFT,tt-=W.baseFingeringXOffset*b.unitInPixels;break;case _.PlacementEnum.Right:Y=l.StaveModifier.Position.RIGHT,tt+=W.baseFingeringXOffset*b.unitInPixels;break;case _.PlacementEnum.Above:Y=l.StaveModifier.Position.ABOVE;break;case _.PlacementEnum.Below:Y=l.StaveModifier.Position.BELOW;break;case _.PlacementEnum.NotYetDefined:const rt=A.parentStaffEntry.sourceStaffEntry.ParentStaff;A.notes.length>1||A.parentStaffEntry.graphicalVoiceEntries.length>1?Y=l.StaveModifier.Position.LEFT:rt.idInMusicSheet===0?(Y=l.StaveModifier.Position.ABOVE,N=_.PlacementEnum.Above):(Y=l.StaveModifier.Position.BELOW,N=_.PlacementEnum.Below)}const H=new l.FretHandFinger($.value);if(H.setPosition(Y),H.setOffsetX(tt),N===_.PlacementEnum.Above||N===_.PlacementEnum.Below){const rt=N===_.PlacementEnum.Above?-1:1,ct=N===_.PlacementEnum.Above?z:U-1-z;if(this.rules.FingeringInsideStafflines&&U>1){const st=H.getWidth()/2,at=2.5*U;H.setOffsetY(rt*(ct+at)*st)}else if(!this.rules.FingeringInsideStafflines){const st=new l.StringNumber($.value);st.radius=0,st.setPosition(Y),st.setOffsetY(rt*ct*st.getWidth()*2/3),G.vfStaveNote.addModifier(z,st);continue}}G.vfStaveNote.addModifier(z,H)}}createStringNumber(A){if(!this.rules.RenderStringNumbersClassical)return;const G=A;A.notes.forEach((U,C)=>{const z=U.sourceNote.StringInstruction;if(z){let W=z.value;switch(W){case"1":W="I";break;case"2":W="II";break;case"3":W="III";break;case"4":W="IV";break;case"5":W="V";break;case"6":W="VI"}const $=new l.StringNumber(W);$.radius=0;const N=-this.rules.StringNumberOffsetY;A.notes.length>1||A.parentStaffEntry.graphicalVoiceEntries.length>1?($.setOffsetX(13*U.baseStringNumberXOffset),$.setPosition(l.Modifier.Position.RIGHT)):$.setPosition(l.Modifier.Position.ABOVE),$.setOffsetY(N),G.vfStaveNote.addModifier(C,$)}})}lineTo(A,G,U=0){const C=new l.StaveConnector(A.getVFStave(),this.stave);C.setType(G),U!==0&&C.setXShift(U),this.connectors.push(C)}getVFStave(){return this.stave}updateInstructionWidth(){let A=0,G=0;const U=this.stave.getModifiers();for(const C of U)C.getPosition()===R.BEGIN?A+=C.getWidth()+C.getPadding(void 0):C.getPosition()===R.END&&(G+=C.getWidth()+C.getPadding(void 0));this.beginInstructionsWidth=(A??0)/b.unitInPixels,this.endInstructionsWidth=(G??0)/b.unitInPixels}addStaveTie(A,G){this.vfTies.push(A),G.vfTie=A,G.Tie.TieDirection===_.PlacementEnum.Below&&A.setDirection(1)}}var R;y.VexFlowMeasure=k,(function(F){F[F.LEFT=1]="LEFT",F[F.RIGHT=2]="RIGHT",F[F.ABOVE=3]="ABOVE",F[F.BELOW=4]="BELOW",F[F.BEGIN=5]="BEGIN",F[F.END=6]="END"})(R||(y.StavePositionEnum=R={}))},3849(St,y,p){var d=this&&this.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(y,"__esModule",{value:!0}),y.VexFlowMultiRestMeasure=void 0;var l=d(p(3206)).default.Flow;const m=p(5246);class a extends m.VexFlowMeasure{constructor(h,u=void 0,f=void 0){super(h,u,f),this.minimumStaffEntriesWidth=-1,f?this.rules=f.ParentMusicSystem.rules:u&&(this.rules=u.Rules),this.resetLayout(),this.multiRestElement=new l.MultiMeasureRest(u.multipleRestMeasures,{})}draw(h){var f,r;const u=h.openGroup();u&&((f=u.classList)==null||f.add("vf-measure"),(r=u.classList)==null||r.add("multi"),u.id=`${this.MeasureNumber}`),this.stave.setContext(h).draw(),this.multiRestElementSVG=h.openGroup("multirest"),this.multiRestElement.setStave(this.stave),this.multiRestElement.setContext(h),this.multiRestElement.draw(),this.multiRestElement.id=`vf-multi${this.MeasureNumber}`,h.closeGroup(),h.closeGroup();for(const b of this.connectors)b.setContext(h).draw()}format(){var h,u;for(const f of this.staffEntries){const r=this.PositionAndShape.Size.width-this.beginInstructionsWidth;f.PositionAndShape.RelativePosition.x=this.PositionAndShape.Size.width/2+this.beginInstructionsWidth/3,f.PositionAndShape.RelativePosition.y=0;const b=(u=(h=f.graphicalVoiceEntries[0])==null?void 0:h.notes[0])==null?void 0:u.PositionAndShape;b.BorderLeft=-r/3,b.BorderRight=r/3,b.BorderTop=1,b.BorderBottom=3,f.PositionAndShape.calculateBoundingBox()}}getVoicesWithinMeasure(){return[]}getGraphicalVoiceEntriesPerVoice(h){return[]}getRestFilledVexFlowStaveNotesPerVoice(h){return[]}handleBeam(h,u){}handleTuplet(h,u){}finalizeBeams(){}finalizeTuplets(){}layoutStaffEntry(h){}graphicalMeasureCreatedCalculations(){}createArticulations(){}createOrnaments(){}createFingerings(h){}getVFStave(){return this.stave}}y.VexFlowMultiRestMeasure=a},806(St,y,p){var d=this&&this.__importDefault||function(ct){return ct&&ct.__esModule?ct:{default:ct}};Object.defineProperty(y,"__esModule",{value:!0}),y.VexFlowMusicSheetCalculator=void 0;const l=p(7921),m=p(3753),a=p(5748),s=p(1327),h=p(5054),u=p(2561),f=p(8215),r=p(7785),b=d(p(3206));var S=b.default.Flow;const v=d(p(3065)),w=p(9479),T=p(2395),g=p(7751),x=p(9310),P=p(7809),_=p(7533),B=p(4022),k=p(2400),R=p(9161),F=p(624),A=p(7506),G=p(5282),U=p(6014),C=p(4980),z=p(6659),W=p(6954),$=p(7109),N=p(512),Y=p(813),tt=p(1216),H=p(2907);class rt extends l.MusicSheetCalculator{constructor(st){var at,ht,lt,O,D,j,Q,J;super(),this.beamsNeedUpdate=!1,this.previousLyricOverflowsByStaff=new Map,this.previousChordOverflowsByStaff=new Map,this.rules=st,l.MusicSheetCalculator.symbolFactory=new m.VexFlowGraphicalSymbolFactory,l.MusicSheetCalculator.TextMeasurer=new r.VexFlowTextMeasurer(this.rules),l.MusicSheetCalculator.stafflineNoteCalculator=new A.VexflowStafflineNoteCalculator(this.rules),((at=this.rules.DefaultVexFlowNoteFont)==null?void 0:at.toLowerCase())==="gonville"?b.default.Flow.DEFAULT_FONT_STACK=[(ht=b.default.Flow.Fonts)==null?void 0:ht.Gonville,(lt=b.default.Flow.Fonts)==null?void 0:lt.Bravura,(O=b.default.Flow.Fonts)==null?void 0:O.Custom]:((D=this.rules.DefaultVexFlowNoteFont)==null?void 0:D.toLowerCase())==="petaluma"&&(b.default.Flow.DEFAULT_FONT_STACK=[(j=b.default.Flow.Fonts)==null?void 0:j.Petaluma,(Q=b.default.Flow.Fonts)==null?void 0:Q.Gonville,(J=b.default.Flow.Fonts)==null?void 0:J.Bravura])}clearRecreatedObjects(){super.clearRecreatedObjects(),l.MusicSheetCalculator.stafflineNoteCalculator=new A.VexflowStafflineNoteCalculator(this.rules);for(const st of this.graphicalMusicSheet.MeasureList)for(const at of st)at==null||at.clean()}formatMeasures(){for(const st of this.graphicalMusicSheet.MeasureList)if(st&&st[0]){st.find(at=>at==null?void 0:at.isVisible()).format();for(const at of st){for(const ht of at.staffEntries)ht.calculateXPosition();at.finalizeBeams()}}this.beamsNeedUpdate=!1}calculateMeasureXLayout(st){const at=[];for(const J of st)J!=null&&J.isVisible()&&at.push(J);if(at.length===0)return 0;st=at;const ht=[],lt=new S.Formatter({softmaxFactor:this.rules.SoftmaxFactorVexFlow});let O=st[0].staffEntries.length,D=1;for(const J of st){if(!J)continue;let q=0;for(const dt of J.staffEntries)q+=dt.setMaxAccidentals();J.parentSourceMeasure.ImplicitMeasure&&(O=Math.max(J.staffEntries.length,O),D=Math.max(J.staffEntries.length+q,D));const et=J.vfVoices,it=[];for(const dt in et)if(et.hasOwnProperty(dt)){const mt=et[dt];J.hasOnlyRests&&!mt.ticksUsed.equals(mt.totalTicks)&&(mt.ticksUsed=mt.totalTicks),it.push(mt),ht.push(mt)}it.length!==0?lt.joinVoices(it):v.default.debug("Found a measure with no voices. Continuing anyway.",et)}let j=12;const Q=st[0].parentSourceMeasure;if(ht.length>0){if(j=lt.preCalculateMinTotalWidth(ht)/w.unitInPixels*this.rules.VoiceSpacingMultiplierVexflow+this.rules.VoiceSpacingAddendVexflow+.3*O,Q==null?void 0:Q.ImplicitMeasure){j=Q.Duration.RealValue/Q.ActiveTimeSignature.RealValue*j;let et=0;const it=Q.measureListIndex;if(it>1)for(const dt of this.graphicalMusicSheet.MeasureList[it-1]){const mt=dt==null?void 0:dt.parentSourceMeasure.endingBarStyleEnum;if(mt===W.SystemLinesEnum.ThinBold||mt===W.SystemLinesEnum.DotsThinBold){et=this.rules.PickupMeasureRepetitionSpacing;break}}j+=et,O>1?j+=.3*D*1.5:it>1&&O===1&&(j+=this.rules.PickupMeasureSpacingSingleNoteAddend),j*=this.rules.PickupMeasureWidthMultiplier}l.MusicSheetCalculator.setMeasuresMinStaffEntriesWidth(st,j);const J=(et,it)=>{lt.formatToStave(ht,it.getVFStave())},q=(et,it)=>{lt.formatToStave(ht,it.getVFStave(),{align_rests:!0,context:void 0})};for(const et of st){if(this.rules.AlignRests===F.AlignRestOption.Never)et.formatVoices=J;else if(this.rules.AlignRests===F.AlignRestOption.Always)et.formatVoices=q;else if(this.rules.AlignRests===F.AlignRestOption.Auto){let it=!1;for(const dt of et.staffEntries){let mt=0,yt=0;for(const Et of dt.graphicalVoiceEntries)if(Et.parentVoiceEntry.IsGrace||Et&&Et.notes&&Et.notes[0]&&Et.notes[0].sourceNote&&Et.notes[0].sourceNote.PrintObject&&mt++,Et&&Et.notes&&Et.notes[0]&&Et.notes[0].sourceNote&&Et.notes[0].sourceNote.isRest()&&Et.notes[0].sourceNote.PrintObject&&yt++,mt>1&&yt>=1){it=!0;break}if(it)break}et.formatVoices=it?q:J}if(et===st[0]){const it=et;it.formatVoices(j*w.unitInPixels,it)}}}for(const J of st)if(J)for(const q of J.staffEntries)q.calculateXPosition();for(const J of st){if(!J)continue;const q=J.vfVoices,et=[];for(const it in q)q.hasOwnProperty(it)&&et.push(q[it]);et.length!==0?lt.joinVoices(et):v.default.debug("Found a measure with no voices. Continuing anyway.",q)}return j}calculateElongationFactor(st,at,ht,lt,O,D,j,Q){let J=O,q=0,et=!1;for(const it of st){const dt=it.GraphicalLabel.Label.textAlignment;let mt=j,yt=Q;if(et=!1,it instanceof T.GraphicalLyricEntry&&it.ParentLyricWord){it.LyricsEntry.SyllableIndex>0&&(mt=this.rules.BetweenSyllableMinimumDistance,_.TextAlignment.IsCenterAligned(dt)&&(mt+=1));const te=it.ParentLyricWord.GetLyricWord.Syllables;te.length>1&&it.LyricsEntry.SyllableIndex0?Ct/It:(zt+Ct)/lt;let qt=1;it instanceof T.GraphicalLyricEntry&&it.LyricsEntry?ht[q]&&(qt=Vt/Nt,ht[q].sourceNoteDuration.Denominator>4&&(qt*=1.1)):ht[q]&&(qt=Vt/Nt),Kt=Math.max(Ut,qt),J=Math.max(J,Kt);let Qt=Math.max(Vt-Nt||0,0);ht[q]&&(Qt+=ht[q].cumulativeOverlap),ht[q]={cumulativeOverlap:Qt,extend:it instanceof T.GraphicalLyricEntry&&it.LyricsEntry.extend,labelWidth:Dt,measureNumber:D,needsDashSpaceAtEnd:et,sourceNoteDuration:it instanceof T.GraphicalLyricEntry&&it.LyricsEntry&&it.LyricsEntry.Parent.Notes[0].Length,text:it instanceof T.GraphicalLyricEntry?it.LyricsEntry.Text:it.GraphicalLabel.Label.text,xPosition:zt},q++}return J}calculateElongationFactorFromStaffEntries(st,at,ht,lt,O,D){let j=ht;const Q={},J={};if(O)for(let q=0;q0&&(Q[q]={cumulativeOverlap:0,extend:!1,labelWidth:et,measureNumber:lt-1,sourceNoteDuration:new u.Fraction(1,4),text:"",xPosition:0})}if(D)for(let q=0;q0&&(J[q]={cumulativeOverlap:0,extend:!1,labelWidth:et,measureNumber:lt-1,sourceNoteDuration:new u.Fraction(1,4),text:"",xPosition:0})}for(const q of st)q.LyricsEntries.length>0&&this.rules.RenderLyrics&&(j=this.calculateElongationFactor(q.LyricsEntries,q,Q,at,j,lt,this.rules.HorizontalBetweenLyricsDistance,this.rules.LyricOverlapAllowedIntoNextMeasure)),q.graphicalChordContainers.length>0&&this.rules.RenderChordSymbols&&(j=this.calculateElongationFactor(q.graphicalChordContainers,q,J,at,j,lt,this.rules.ChordSymbolXSpacing,this.rules.ChordOverlapAllowedIntoNextMeasure));return{factor:j,lastLyricEntryDict:Q,lastChordEntryDict:J}}calculateMeasureWidthFromStaffEntries(st,at){let ht=1;const lt=[],O=new Set;for(const j of st){if(!j||j.staffEntries.length===0||!j.isVisible())continue;const Q=j.ParentStaff;O.add(Q);const J=this.previousLyricOverflowsByStaff.get(Q),q=this.previousChordOverflowsByStaff.get(Q),et=this.calculateElongationFactorFromStaffEntries(j.staffEntries,at,ht,j.MeasureNumber,J,q);ht=et.factor,lt.push({staff:Q,lastLyricEntryDict:et.lastLyricEntryDict,lastChordEntryDict:et.lastChordEntryDict})}ht=Math.min(ht,this.rules.MaximumLyricsElongationFactor);const D=at*ht;for(const j of lt){const Q=this.computeContainerOverflows(j.lastLyricEntryDict,D),J=this.computeContainerOverflows(j.lastChordEntryDict,D);this.previousLyricOverflowsByStaff.set(j.staff,Q),this.previousChordOverflowsByStaff.set(j.staff,J)}for(const j of Array.from(this.previousLyricOverflowsByStaff.keys()))O.has(j)||this.previousLyricOverflowsByStaff.delete(j);for(const j of Array.from(this.previousChordOverflowsByStaff.keys()))O.has(j)||this.previousChordOverflowsByStaff.delete(j);return D}computeContainerOverflows(st,at){const ht=[];for(const lt of Object.keys(st)){const O=Number(lt),D=st[O];if(!D)continue;const j=D.xPosition+D.labelWidth;let Q=Math.max(0,j-at);D.needsDashSpaceAtEnd&&this.dashSpace!==void 0&&(Q+=this.dashSpace),ht[O]=Q}return ht}createGraphicalTie(st,at,ht,lt,O){return new h.GraphicalTie(st,lt,O)}updateStaffLineBorders(st){st.SkyBottomLineCalculator.updateStaffLineBorders()}graphicalMeasureCreatedCalculations(st){st.rules=this.rules,st.graphicalMeasureCreatedCalculations()}layoutVoiceEntry(st,at,ht,lt){for(let O=0;O=2&&(D=lt.vfnote[0],Q=lt.vfnote[1]);let J=0;if(O&&O.vfnote&&O.vfnote.length>=2&&(j=O.vfnote[0],J=O.vfnote[1]),at){if(D){const q=new S.StaveTie({first_indices:[Q],first_note:D});lt.parentVoiceEntry.parentStaffEntry.parentMeasure.addStaveTie(q,st)}if(j){const q=new S.StaveTie({last_indices:[J],last_note:j});O.parentVoiceEntry.parentStaffEntry.parentMeasure.addStaveTie(q,st)}}else if(D||j){let q;if(ht)if(st.Tie.Type==="S"){const et=st.StartNote.sourceNote,it=st.EndNote.sourceNote;let dt=1;et.FretNumber>it.FretNumber&&(dt=-1),q=new S.TabSlide({first_indices:[Q],first_note:D,last_indices:[J],last_note:j},dt)}else q=new S.TabTie({first_indices:[Q],first_note:D,last_indices:[J],last_note:j},st.Tie.Type);else{q=new S.StaveTie({first_indices:[Q],first_note:D,last_indices:[J],last_note:j});const et=st.Tie.getTieDirection(lt.sourceNote);et===C.PlacementEnum.Below?q.setDirection(1):et===C.PlacementEnum.Above&&q.setDirection(-1)}O.parentVoiceEntry.parentStaffEntry.parentMeasure.addStaveTie(q,st)}}calculateDynamicExpressionsForMultiExpression(st,at,ht){if(atthis.rules.MaxMeasureToDrawIndex)return;const lt=st.AbsoluteTimestamp,O=this.graphicalMusicSheet.MeasureList[at],D=O[ht].ParentStaffLine,j=O[ht],Q=st.StartingContinuousDynamic,J=Q!==void 0&&!Q.IsStartOfSoftAccent,q=this.getRelativePositionInStaffLineFromTimestamp(lt,ht,D,D==null?void 0:D.isPartOfMultiStaffInstrument(),void 0,J);if(q.x<=0&&(q.x=j.beginInstructionsWidth+this.rules.RhythmRightMargin),st.InstantaneousDynamic){const et=new P.VexFlowInstantaneousDynamicExpression(st.InstantaneousDynamic,D,j);this.calculateGraphicalInstantaneousDynamicExpression(et,q,lt),this.dynamicExpressionMap.set(lt.RealValue,et.PositionAndShape)}if(Q){const et=new k.VexFlowContinuousDynamicExpression(Q,D,j.parentSourceMeasure);if(et.StartMeasure=j,et.IsSoftAccent=st.StartingContinuousDynamic.IsStartOfSoftAccent,!et.IsVerbal&&Q.EndMultiExpression)try{this.calculateGraphicalContinuousDynamic(et,q),et.updateSkyBottomLine()}catch{}else et.IsVerbal?this.calculateGraphicalVerbalContinuousDynamic(et,q):v.default.warn("This continuous dynamic is not covered. measure"+st.SourceMeasureParent.MeasureNumber)}}createMetronomeMark(st){var et,it;const at=st.ParentMultiTempoExpression.SourceMeasureParent.MeasureNumber,ht=Math.max(st.StaffNumber-1,0),lt=this.graphicalMusicSheet.findGraphicalMeasureByMeasureNumber(at,ht),O=lt===this.graphicalMusicSheet.MeasureList[0][0];if(lt.hasMetronomeMark)return;const D=lt.getVFStave();let j=this.rules.MetronomeMarkYShift,Q=!1;for(const dt of st.parentMeasure.TempoExpressions){const mt=((et=dt.InstantaneousTempo)==null?void 0:et.TempoType)===R.TempoType.metronomeMark;if(dt.getPlacementOfFirstEntry()===C.PlacementEnum.Above&&!mt){Q=!0;break}}Q&&(j-=1.4);const J=(it=this.graphicalMusicSheet.MeasureList[0][0].ParentStaffLine)==null?void 0:it.SkyLine;if(st.metronomeNoteGroupLeft&&st.metronomeNoteGroupRight){const dt=this.buildNoteEquationForVexFlow(st.metronomeNoteGroupLeft,st.metronomeNoteGroupRight);D.setTempo({noteEquation:dt},j*w.unitInPixels)}else{let dt="q";if(st.beatUnit){const mt=G.NoteTypeHandler.getNoteDurationFromType(st.beatUnit);dt=U.VexFlowConverter.durations(mt,!1)[0]}D.setTempo({bpm:st.TempoInBpm,dots:st.dotted,duration:dt},j*w.unitInPixels)}const q=O?this.rules.MetronomeMarkXShift*w.unitInPixels:0;D.getModifiers()[D.getModifiers().length-1].setShiftX(q),lt.hasMetronomeMark=!0,J&&(J[0]=Math.min(J[0],-4.5+j))}buildNoteEquationForVexFlow(st,at){const ht=lt=>{const O={notes:lt.notes.map(D=>{const j=G.NoteTypeHandler.getNoteDurationFromType(D.type);return{duration:U.VexFlowConverter.durations(j,!1)[0],dots:D.dots,beam:D.beam}})};return lt.tuplet&&(O.tuplet={actualNotes:lt.tuplet.actualNotes,normalNotes:lt.tuplet.normalNotes,bracket:lt.tuplet.bracket,showNumber:lt.tuplet.showNumber}),O};return{left:ht(st),right:ht(at)}}calculateRehearsalMark(st){const at=st.rehearsalExpression;if(!at)return;const ht=this.graphicalMusicSheet.MeasureList[0][0].MeasureNumber,lt=Math.max(st.MeasureNumber-ht,0);for(const O of this.graphicalMusicSheet.MeasureList[lt]){const D=O==null?void 0:O.getVFStave();if(!D||!O.isVisible())continue;let j=-this.rules.RehearsalMarkYOffsetDefault-this.rules.RehearsalMarkYOffset;O.parentSourceMeasure.isReducedToMultiRest&&(j+=this.rules.RehearsalMarkYOffsetAddedForRehearsalMarks);let Q=this.rules.RehearsalMarkXOffsetDefault+this.rules.RehearsalMarkXOffset;st.IsSystemStartMeasure&&(Q+=this.rules.RehearsalMarkXOffsetSystemStartMeasure);const J=this.rules.RehearsalMarkFontSize;return void D.setSection(at.label,j,Q,J)}}calculateSingleOctaveShift(st,at,ht,lt){var mt,yt;const O=at.OctaveShiftStart,D=O.ParentStartMultiExpression.Timestamp,j=(mt=O.ParentEndMultiExpression)==null?void 0:mt.Timestamp,Q=this.rules.MinMeasureToDrawIndex,J=this.rules.MaxMeasureToDrawIndex;let q,et,it=this.graphicalMusicSheet.MeasureList[ht][lt].ParentStaffLine;if(it||(it=this.graphicalMusicSheet.MeasureList[Q][lt].ParentStaffLine),q=O.ParentEndMultiExpression?this.graphicalMusicSheet.getGraphicalMeasureFromSourceMeasureAndIndex(O.ParentEndMultiExpression.SourceMeasureParent,lt):this.graphicalMusicSheet.getLastGraphicalMeasureFromIndex(lt,!0),q.MeasureNumber>J+1&&(q=this.graphicalMusicSheet.getLastGraphicalMeasureFromIndex(lt,!0)),et=O.ParentStartMultiExpression?this.graphicalMusicSheet.getGraphicalMeasureFromSourceMeasureAndIndex(O.ParentStartMultiExpression.SourceMeasureParent,lt):this.graphicalMusicSheet.MeasureList[Q][lt],et.MeasureNumberJ||q.parentSourceMeasure.measureListIndexJ)return;let dt=q.ParentStaffLine;if(dt||(dt=it),q&&it&&dt){const Et=new x.VexFlowOctaveShift(O,it.PositionAndShape);if(!Et.startNote){let Nt;for(const It of et.staffEntries)if(It){Nt=It;break}if(!Nt||(Et.setStartNote(Nt),!Et.startNote))return}if(!Et.endNote){let Nt;for(let It=q.staffEntries.length-1;It>=0;It++)if(q.staffEntries[It]){Nt=q.staffEntries[It];break}if(!Nt)return void(Et.graphicalEndAtMeasureEnd=!0);if(Et.setEndNote(Nt),!Et.endNote)return}let Dt=et.findGraphicalStaffEntryFromTimestamp(D);Dt||(Dt=et.staffEntries[0]);let Vt=q.findGraphicalStaffEntryFromTimestamp(j);if(!Vt)for(let Nt=q.staffEntries.length-1;Nt>=0;Nt--){const It=q.staffEntries[Nt];if((yt=It.relInMeasureTimestamp)!=null&&yt.lte(j)){Vt=It;break}}if(Vt||(Vt=q.staffEntries[q.staffEntries.length-1]),Et.setStartNote(Dt),dt!==it){Et.endsOnDifferentStaffLine=!0;let Nt=this.findLastStafflineMeasure(it);Nt===void 0&&(Nt=q);const It=Nt.staffEntries[Nt.staffEntries.length-1];if(Et.setEndNote(It),Et.graphicalEndAtMeasureEnd=!0,Et.endMeasure=Nt,dt.ParentMusicSystem.Id-it.ParentMusicSystem.Id>0)for(let Ct=it.ParentMusicSystem.Id;Ct0?O.endVoiceEntryIndex:-1;qt.setEndNote(ie,ae),Ut.OctaveShifts.push(qt),this.calculateOctaveShiftSkyBottomLine(te,ie,qt,Ut)}this.calculateOctaveShiftSkyBottomLine(Dt,It,Et,it)}else Et.setEndNote(Vt,O.endVoiceEntryIndex>0?O.endVoiceEntryIndex:-1),this.calculateOctaveShiftSkyBottomLine(Dt,Vt,Et,it);it.OctaveShifts.push(Et)}else v.default.warn("End measure or staffLines for octave shift are undefined! This should not happen!")}findLastStafflineMeasure(st){for(let at=st.Measures.length-1;at>=0;at--){const ht=st.Measures[at];if(ht.staffEntries.length>0)return ht}}calculateSinglePedal(st,at,ht,lt){var mt;const O=at.PedalStart,D=O.ParentStartMultiExpression.Timestamp,j=(mt=O.ParentEndMultiExpression)==null?void 0:mt.Timestamp,Q=this.rules.MinMeasureToDrawIndex,J=this.rules.MaxMeasureToDrawIndex;let q,et,it=this.graphicalMusicSheet.MeasureList[ht][lt].ParentStaffLine;if(it||(it=this.graphicalMusicSheet.MeasureList[Q][lt].ParentStaffLine),q=O.ParentEndMultiExpression?this.graphicalMusicSheet.getGraphicalMeasureFromSourceMeasureAndIndex(O.ParentEndMultiExpression.SourceMeasureParent,lt):this.graphicalMusicSheet.getLastGraphicalMeasureFromIndex(lt,!0),q.MeasureNumber>J+1&&(q=this.graphicalMusicSheet.getLastGraphicalMeasureFromIndex(lt,!0)),O.ParentEndMultiExpression?et=this.graphicalMusicSheet.getGraphicalMeasureFromSourceMeasureAndIndex(O.ParentStartMultiExpression.SourceMeasureParent,lt):(et=this.graphicalMusicSheet.getGraphicalMeasureFromSourceMeasureAndIndex(O.ParentStartMultiExpression.SourceMeasureParent,lt),et||(et=this.graphicalMusicSheet.MeasureList[Q][lt])),et.MeasureNumberJ||q.parentSourceMeasure.measureListIndexJ)return;let dt=q.ParentStaffLine;if(dt||(dt=it),q&&it&&dt){let yt=!1;it!==dt&&(yt=!0);const Et=new $.VexFlowPedal(O,it.PositionAndShape,!1,yt);Et.setEndsStave(q,j);let Dt=et.findGraphicalStaffEntryFromTimestamp(D);Dt||(Dt=et.staffEntries[0]);let Vt=q.findGraphicalStaffEntryFromTimestamp(j);if(Vt||(Vt=q.staffEntries[q.staffEntries.length-1]),!Et.setStartNote(Dt))return;if(Et.setBeginsStave(Et.startNote.isRest(),D),dt!==it)if(Et.pedalSymbol===N.MusicSymbol.PEDAL_SYMBOL){Et.setEndNote(Vt),Et.setEndMeasure(q),Et.ReleaseText=" ",Et.CalculateBoundingBox(),this.calculatePedalSkyBottomLine(Et.startVfVoiceEntry,Et.endVfVoiceEntry,Et,it);const Nt=dt.Measures[0],It=new $.VexFlowPedal(O,Nt.PositionAndShape);Et.setEndsStave(q,j);const Ct=Nt.staffEntries[0];if(!It.setStartNote(Ct))return;It.setEndNote(Vt),It.setEndMeasure(q),Et.setEndMeasure(q),dt.Pedals.push(It),It.CalculateBoundingBox(),It.DepressText=" ",this.calculatePedalSkyBottomLine(It.startVfVoiceEntry,It.endVfVoiceEntry,It,dt)}else{let Nt=this.findLastStafflineMeasure(it);Nt===void 0&&(Nt=q);const It=Nt.staffEntries[Nt.staffEntries.length-1];Et.setEndNote(It),Et.setEndMeasure(q),Et.ChangeEnd=!1;const Ct=dt.ParentMusicSystem.Id-it.ParentMusicSystem.Id;if(Ct>0){let zt=1;for(let Xt=it.ParentMusicSystem.Id;XtJ+1&&(q=this.graphicalMusicSheet.getLastGraphicalMeasureFromIndex(lt,!0)),et=O.ParentEndMultiExpression?this.graphicalMusicSheet.getGraphicalMeasureFromSourceMeasureAndIndex(O.ParentStartMultiExpression.SourceMeasureParent,lt):this.graphicalMusicSheet.MeasureList[Q][lt],et.MeasureNumberJ||q.parentSourceMeasure.measureListIndexJ)return;let dt=q.ParentStaffLine;if(dt||(dt=it),q&&it&&dt){const yt=new H.VexFlowVibratoBracket(O,it.PositionAndShape,et.ParentStaff.isTab);let Et=et.findGraphicalStaffEntryFromTimestamp(D);Et||(Et=et.staffEntries[0]);let Dt=q.findGraphicalStaffEntryFromTimestamp(j);if(Dt||(Dt=q.staffEntries[q.staffEntries.length-1]),yt.setStartNote(Et),dt!==it){let Vt=it.Measures[it.Measures.length-1];Vt===void 0&&(Vt=q);const Nt=Vt.staffEntries[Vt.staffEntries.length-1];if(Nt&&yt.setEndNote(Nt),dt.ParentMusicSystem.Id-it.ParentMusicSystem.Id>0)for(let It=it.ParentMusicSystem.Id;Itq){const Nt=q;q=et,et=Nt}lt.SkyBottomLineCalculator.updateBottomLineInRange(et,q,it+Dt)}for(const Dt of lt.Pedals){const Vt=Dt,Nt=Vt.getPedalMarking();if(it>Nt.line+3+(lt.StaffLines.length-1)){const It=Nt.render_options.text_margin_right/10;let Ct,zt=Vt.startVfVoiceEntry.PositionAndShape.AbsolutePosition.x-It;Vt.setLine(it-3-(lt.StaffLines.length-1));let Xt=(mt=Vt.endVfVoiceEntry)==null?void 0:mt.PositionAndShape;if(Xt||(Xt=Vt.endMeasure.PositionAndShape),Vt.EndSymbolPositionAndShape){const Ut=j.render_options.glyph_point_size/20;Ct=zt+3.4;const Kt=Xt.AbsolutePosition.x-It,qt=Kt+1.5;lt.SkyBottomLineCalculator.updateBottomLineInRange(zt,Ct,it+Ut),lt.SkyBottomLineCalculator.updateBottomLineInRange(Kt,qt,it+Ut)}else{const Ut=Nt.render_options.bracket_height/10;if(Nt.EndsStave)Ct=Xt.AbsolutePosition.x+Xt.Size.width-It;else switch(j.style){case D.BRACKET_OPEN_END:case D.BRACKET_OPEN_BOTH:case D.MIXED_OPEN_END:Ct=Xt.AbsolutePosition.x+Xt.BorderRight-It;break;default:Ct=Xt.AbsolutePosition.x+Xt.BorderLeft-It}const Kt=(Et=(yt=Vt.endVfVoiceEntry)==null?void 0:yt.parentStaffEntry)==null?void 0:Et.vfClefBefore;if(Kt&&(Ct+=Kt.getWidth()/10),zt>Ct){const qt=zt;zt=Ct,Ct=qt}lt.SkyBottomLineCalculator.updateBottomLineInRange(zt,Ct,it+Ut)}}}}calculateOctaveShiftSkyBottomLine(st,at,ht,lt){if(!at)return void v.default.warn("octaveshift: no endStaffEntry");let O=at.PositionAndShape;ht.graphicalEndAtMeasureEnd&&(O=at.parentMeasure.PositionAndShape);let D=st.PositionAndShape.Size.width,j=O.Size.width;st.hasOnlyRests()?D=-D:D/=2,ht.graphicalEndAtMeasureEnd||(at.hasOnlyRests()?j*=2:j/=2,st===at&&(j*=2));let Q=st.PositionAndShape.AbsolutePosition.x-D,J=O.AbsolutePosition.x+j;if(Q>J){const it=Q;Q=J,J=it}ht.PositionAndShape.Size.width=J-Q;const q=ht.getTextBracket(),et=q.font.size/10;if(q.position===S.TextBracket.Positions.TOP){const it=Math.ceil(lt.SkyBottomLineCalculator.getSkyLineMinInRange(Q,J));if(it===1/0)return;q.start.getStave().options.top_text_position=Math.abs(it),lt.SkyBottomLineCalculator.updateSkyLineInRange(Q,J,it-2*et)}else{const it=lt.SkyBottomLineCalculator.getBottomLineMaxInRange(Q,J);if(it===1/0)return;q.start.getStave().options.bottom_text_position=it,lt.SkyBottomLineCalculator.updateBottomLineInRange(Q,J,it+1.5*et)}}calculateWordRepetitionInstruction(st,at){let ht;const lt=this.graphicalMusicSheet.MeasureList[at];for(let O=0,D=lt.length;Oht.StaffLines));let at=0;for(const ht of st)for(const lt of ht.Measures)lt&&at++;if(this.rules.AlwaysSetPreferredSkyBottomLineBackendAutomatically&&this.rules.setPreferredSkyBottomLineBackendAutomatically(at),at>=this.rules.SkyBottomLineBatchMinMeasures)new s.SkyBottomLineBatchCalculator(st,this.rules.PreferredSkyBottomLineBatchCalculatorBackend).calculateLines();else for(const ht of st)ht.SkyBottomLineCalculator.calculateLines()}calculateExpressionAlignements(){for(const st of this.musicSystems)for(const at of st.StaffLines)try{at.AlignmentManager.alignDynamicExpressions(),at.AbstractExpressions.forEach(ht=>{ht.updateSkyBottomLine()})}catch{}}handleTiedGraphicalNote(st,at,ht,lt,O,D,j,Q){}handleBeam(st,at,ht){st.parentVoiceEntry.parentStaffEntry.parentMeasure.handleBeam(st,at)}handleVoiceEntryLyrics(st,at,ht){st.LyricsEntries.forEach((lt,O)=>{const D=new T.GraphicalLyricEntry(O,at,this.rules.LyricsHeight,this.rules.StaffHeight);if(at.LyricsEntries.push(D),D.GraphicalLabel.setLabelPositionAndShapeBorders(),O.Word){const j=O.Word.Syllables.indexOf(O);let Q=ht.indexOf(O.Word);if(Q===-1&&(ht.push(O.Word),Q=ht.indexOf(O.Word)),this.graphicalLyricWords.length===0||Q>this.graphicalLyricWords.length-1){const J=new g.GraphicalLyricWord(O.Word);D.ParentLyricWord=J,J.GraphicalLyricsEntries[j]=D,this.graphicalLyricWords.push(J)}else{const J=this.graphicalLyricWords[Q];D.ParentLyricWord=J,J.GraphicalLyricsEntries[j]=D,J.isFilled()&&(ht.splice(Q,1),this.graphicalLyricWords.splice(this.graphicalLyricWords.indexOf(J),1))}}})}handleVoiceEntryOrnaments(st,at,ht){}handleVoiceEntryArticulations(st,at,ht){}handleVoiceEntryTechnicalInstructions(st,at,ht){}handleTuplet(st,at,ht){st.parentVoiceEntry.parentStaffEntry.parentMeasure.handleTuplet(st,at)}findIndexGraphicalSlurFromSlur(st,at){for(let ht=0;ht=0){const et=lt[q];et.staffEntries.indexOf(D)===-1&&et.staffEntries.push(D),lt.splice(q,1)}}}for(const j of lt)j.staffEntries.indexOf(D)===-1&&j.staffEntries.push(D)}}for(const at of this.musicSystems)for(const ht of at.StaffLines){const lt=ht.GraphicalSlurs.sort(B.GraphicalSlur.Compare);for(const O of lt)O.slur.isCrossed()||O.calculateCurve(this.rules)}}calculateGlissandi(){const st={};for(const at of this.graphicalMusicSheet.MeasureList[0])st[at.ParentStaff.idInMusicSheet]=[];for(const at of this.musicSystems)for(const ht of at.StaffLines){const lt=st[ht.ParentStaff.idInMusicSheet];for(let O=0;O=0){const et=lt[q];et.staffEntries.indexOf(D)===-1&&et.staffEntries.push(D),lt.splice(q,1)}}}}for(const j of lt)j.staffEntries.indexOf(D)===-1&&j.staffEntries.push(D)}}for(const at of this.musicSystems)for(const ht of at.StaffLines)for(const lt of ht.GraphicalGlissandi)if(ht.ParentStaff.isTab){const O=lt.Glissando.StartNote,D=lt.Glissando.EndNote,j=lt.staffEntries[0].findGraphicalNoteFromNote(O),Q=lt.staffEntries.last().findGraphicalNoteFromNote(D);if(!j&&!Q)return;let J,q,et,it,dt=1;O.FretNumber>D.FretNumber&&(dt=-1),j&&j.vfnote&&j.vfnote.length>=2&&(et=j.vfnote[0],J=[0]),Q&&Q.vfnote&&Q.vfnote.length>=2&&(it=Q.vfnote[0],q=[0]);const mt=new S.TabSlide({first_indices:J,first_note:et,last_indices:q,last_note:it},dt),yt=j==null?void 0:j.parentVoiceEntry.parentStaffEntry.parentMeasure;yt&&(yt.vfTies.push(mt),lt.vfTie=mt);const Et=Q==null?void 0:Q.parentVoiceEntry.parentStaffEntry.parentMeasure;Et&&(Et.vfTies.push(mt),lt.vfTie=mt)}}}y.VexFlowMusicSheetCalculator=rt},9479(St,y,p){var d=this&&this.__importDefault||function(P){return P&&P.__esModule?P:{default:P}};Object.defineProperty(y,"__esModule",{value:!0}),y.VexFlowMusicSheetDrawer=y.unitInPixels=void 0;const l=d(p(3206)),m=p(1932),a=p(200),s=p(9409),h=p(7785),u=p(2683),f=p(6362),r=p(3361),b=p(5023),S=d(p(3065)),v=p(1066),w=p(3661),T=p(5824),g=p(9436);y.unitInPixels=10;class x extends m.MusicSheetDrawer{constructor(_=new w.DrawingParameters){super(new h.VexFlowTextMeasurer(_.Rules),_),this.backends=[],this.zoom=1,this.pageIdx=0}get Backends(){return this.backends}drawSheet(_){var B,k,R;this.rules.DefaultVexFlowNoteFont==="gonville"&&(l.default.Flow.DEFAULT_FONT_STACK=[(B=l.default.Flow.Fonts)==null?void 0:B.Gonville,(k=l.default.Flow.Fonts)==null?void 0:k.Bravura,(R=l.default.Flow.Fonts)==null?void 0:R.Custom]),l.default.Flow.STAVE_LINE_THICKNESS=this.rules.StaffLineWidth*y.unitInPixels,l.default.Flow.STEM_WIDTH=this.rules.StemWidth*y.unitInPixels,l.default.Flow.DEFAULT_NOTATION_FONT_SCALE=this.rules.VexFlowDefaultNotationFontScale,l.default.Flow.DEFAULT_TAB_FONT_SCALE=this.rules.VexFlowDefaultTabFontScale,this.pageIdx=0;for(const F of _.MusicPages){if(F.PageNumber>this.rules.MaxPageToDrawNumber)break;const A=this.backends[this.pageIdx];A.graphicalMusicPage=F,A.scale(this.zoom),this.pageIdx+=1}this.pageIdx=0,this.backend=this.backends[0],super.drawSheet(_)}drawPage(_){_&&(this.backend=this.backends[_.PageNumber-1],super.drawPage(_),this.pageIdx+=1)}clear(){for(const _ of this.backends)_.clear()}setZoom(_){this.zoom=_}calculatePixelDistance(_){return _*y.unitInPixels}drawStaffLine(_){var F,A,G;const B=this.backend.getContext(),k=B.openGroup();k&&(k.classList.add("staffline"),_.ParentStaff&&(k.id=`${(F=_.ParentStaff.ParentInstrument)==null?void 0:F.Name}${(A=_.ParentStaff.ParentInstrument)==null?void 0:A.Id}-${(G=_.ParentStaff)==null?void 0:G.Id}`)),super.drawStaffLine(_);const R=_.PositionAndShape.AbsolutePosition;this.rules.RenderSlurs&&this.drawSlurs(_,R),this.rules.RenderGlissandi&&this.drawGlissandi(_,R),B.closeGroup()}drawSlurs(_,B){for(const k of _.GraphicalSlurs)k.slur.isCrossed()||this.drawSlur(k,B)}drawGlissandi(_,B){for(const k of _.GraphicalGlissandi)this.drawGlissando(k,B)}drawGlissando(_,B){if(_.StaffLine.ParentStaff.isTab||_.calculateLine(this.rules),_.Line){const k=new s.PointF2D(_.Line.Start.x+B.x,_.Line.Start.y),R=new s.PointF2D(_.Line.End.x+B.x,_.Line.End.y);_.Line.SVGElement=this.drawLine(k,R,_.Color,_.Width)}else{const k=_.vfTie;if(k){const R=this.backend.getContext();k.setContext(R),k.draw()}}}drawSlur(_,B){const k=[],R=new s.PointF2D(_.bezierStartPt.x+B.x,_.bezierStartPt.y+B.y),F=new s.PointF2D(_.bezierStartControlPt.x+B.x,_.bezierStartControlPt.y+B.y),A=new s.PointF2D(_.bezierEndControlPt.x+B.x,_.bezierEndControlPt.y+B.y),G=new s.PointF2D(_.bezierEndPt.x+B.x,_.bezierEndPt.y+B.y);k.push(this.applyScreenTransformation(R)),k.push(this.applyScreenTransformation(F)),k.push(this.applyScreenTransformation(A)),k.push(this.applyScreenTransformation(G)),_.placement===f.PlacementEnum.Above?(R.y-=.05,F.y-=.3,A.y-=.3,G.y-=.05):(R.y+=.05,F.y+=.3,A.y+=.3,G.y+=.05),k.push(this.applyScreenTransformation(R)),k.push(this.applyScreenTransformation(F)),k.push(this.applyScreenTransformation(A)),k.push(this.applyScreenTransformation(G));const U=this.rules.GNote(_.slur.StartNote);_.SVGElement=this.backend.renderCurve(k,!0,U)}drawMeasure(_){_.setAbsoluteCoordinates(_.PositionAndShape.AbsolutePosition.x*y.unitInPixels,_.PositionAndShape.AbsolutePosition.y*y.unitInPixels);try{_.draw(this.backend.getContext())}catch(k){S.default.warn("VexFlowMusicSheetDrawer.drawMeasure",k)}let B=0;for(const k of _.staffEntries)this.drawStaffEntry(k),B=this.drawBuzzRolls(k,B)}drawBuzzRolls(_,B){var k;for(const R of _.graphicalVoiceEntries)for(const F of R.notes)if((k=F.sourceNote.TremoloInfo)!=null&&k.tremoloUnmeasured){const A=this.rules.TremoloBuzzRollThickness,G=.9,U=.5,C=F;let z,W;const $=C.vfnote[0].getStemDirection();let N;if(this.backend instanceof g.SvgVexFlowBackend&&(N=C.getStemSVG()),(N==null?void 0:N.getBbox)!==void 0){const at=N.getBBox();z=new s.PointF2D(at.x/10,at.y/10),W=at.height/10}else W=C.vfnote[0].getStemLength()/10,z=new s.PointF2D(C.vfnote[0].getStem().x_begin/10,C.vfnote[0].getStem().y_top/10),$===1&&(z.y-=W);let Y=z.y+W/3;C.vfnote[0].getBeamCount()>1&&(Y=z.y+W/2,$===-1&&(Y-=U+.2));const tt=z.x-.5,H=Y,rt=[],ct=[new s.PointF2D(0,-A),new s.PointF2D(G-A,0),new s.PointF2D(-G+A,-U),new s.PointF2D(0,-A),new s.PointF2D(G,0),new s.PointF2D(0,A),new s.PointF2D(-G+A,0),new s.PointF2D(G-A,U),new s.PointF2D(0,A),new s.PointF2D(-G,0)];let st=new s.PointF2D(tt,H);rt.push(st);for(const at of ct)st=rt.last(),rt.push(new s.PointF2D(st.x+at.x,st.y-at.y));this.DrawPath(rt,C.ParentMusicPage,!0,`buzzRoll${B}`),B++}return B}drawLine(_,B,k="#000000FF",R=.2){return _=this.applyScreenTransformation(_),B=this.applyScreenTransformation(B),this.backend.renderLine(_,B,k,R*y.unitInPixels)}DrawOverlayLine(_,B,k,R="#FF0000FF",F=.2,A){if(!k.PageNumber||k.PageNumber>this.backends.length||k.PageNumber<1)return void console.log("VexFlowMusicSheetDrawer.drawOverlayLine: invalid page number / music page number doesn't correspond to an existing backend.");const G=k.PageNumber-1,U=this.backends[G];return _=this.applyScreenTransformation(_),B=this.applyScreenTransformation(B),A||(A=`overlayLine ${_.x}/${_.y}`),U.renderLine(_,B,R,F*y.unitInPixels,A)}DrawPath(_,B,k=!0,R){const F=B.PageNumber-1,A=this.backends[F],G=[];for(const U of _)G.push(this.applyScreenTransformation(U));return A.renderPath(G,k,R)}drawSkyLine(_){const B=_.PositionAndShape.AbsolutePosition,k=_.PositionAndShape.Size.width;this.drawSampledLine(_.SkyLine,B,k)}drawBottomLine(_){const B=new s.PointF2D(_.PositionAndShape.AbsolutePosition.x,_.PositionAndShape.AbsolutePosition.y),k=_.PositionAndShape.Size.width;this.drawSampledLine(_.BottomLine,B,k,"#0000FFFF")}drawSampledLine(_,B,k,R="#FF0000FF"){const F=[];let A=0;for(let U=0;U<_.length;U++)_[U]!==A&&(F.push(U),A=_[U]);const G=B;if(F.length>0){const U=this.rules.SamplingUnit;let C,z,W=new s.PointF2D(G.x,G.y),$=new s.PointF2D(F[0]/U+G.x,G.y);this.drawLine(W,$,R),_[0]>=0&&(C=new s.PointF2D(F[0]/U+G.x,G.y),z=new s.PointF2D(F[0]/U+G.x,G.y+_[F[0]]),this.drawLine(C,z,R));for(let N=1;N0)for(const B of _.FingeringEntries)B.SVGNode=this.drawLabel(B,u.GraphicalLayers.Notes);if(_.graphicalChordContainers!==void 0&&_.graphicalChordContainers.length>0)for(const B of _.graphicalChordContainers){const k=B.GraphicalLabel;k.SVGNode=this.drawLabel(k,u.GraphicalLayers.Notes)}this.rules.RenderLyrics&&_.LyricsEntries.length>0&&this.drawLyrics(_.LyricsEntries,u.GraphicalLayers.Notes)}drawLyrics(_,B){_.forEach(k=>{var F;const R=k.GraphicalLabel;R.Label.colorDefault=this.rules.DefaultColorLyrics,R.SVGNode=this.drawLabel(R,B),(F=R.SVGNode)==null||F.classList.add("lyrics")})}drawInstrumentBrace(_,B){const k=this.backend.getContext();k.openGroup("brace"),_.draw(k),k.closeGroup()}drawGroupBracket(_,B){const k=this.backend.getContext();k.openGroup("bracket"),_.draw(k),k.closeGroup()}drawOctaveShifts(_){for(const B of _.OctaveShifts)if(B){const k=B,R=this.backend.getContext(),F=k.getTextBracket();this.rules.DefaultColorMusic&&(F.render_options.color=this.rules.DefaultColorMusic),F.setContext(R);try{F.draw()}catch(A){S.default.warn(A)}}}drawPedals(_){for(const B of _.Pedals)if(B){const k=B,R=this.backend.getContext(),F=k.getPedalMarking();F.render_options.color=this.rules.DefaultColorMusic,F.setContext(R),F.draw()}}drawWavyLines(_){for(const B of _.WavyLines)if(B){const k=B,R=this.backend.getContext(),F=k.getVibratoBracket();F.setContext(R),F.draw()}}drawExpressions(_){var B;for(const k of _.AbstractExpressions)if(k instanceof b.GraphicalInstantaneousDynamicExpression)this.drawInstantaneousDynamic(k);else if(k instanceof r.GraphicalInstantaneousTempoExpression){if(((B=k.SourceExpression.parentMeasure)==null?void 0:B.MeasureNumber)<=1&&!this.rules.RenderFirstTempoExpression)continue;const R=k.GraphicalLabel;R.SVGNode=this.drawLabel(R,u.GraphicalLayers.Notes)}else if(k instanceof v.GraphicalContinuousDynamicExpression)this.drawContinuousDynamic(k);else if(k instanceof T.GraphicalUnknownExpression){const R=k.Label;R.SVGNode=this.drawLabel(R,u.GraphicalLayers.Notes)}else S.default.warn("Unkown type of expression!")}drawInstantaneousDynamic(_){const B=_.Label;B.SVGNode=this.drawLabel(B,u.GraphicalLayers.Notes)}drawContinuousDynamic(_){if(_.IsVerbal){const B=_.Label;B.SVGNode=this.drawLabel(B,u.GraphicalLayers.Notes)}else for(const B of _.Lines){const k=new s.PointF2D(_.ParentStaffLine.PositionAndShape.AbsolutePosition.x+B.Start.x,_.ParentStaffLine.PositionAndShape.AbsolutePosition.y+B.Start.y),R=new s.PointF2D(_.ParentStaffLine.PositionAndShape.AbsolutePosition.x+B.End.x,_.ParentStaffLine.PositionAndShape.AbsolutePosition.y+B.End.y);B.SVGElement=this.drawLine(k,R,B.colorHex??"#000000",B.Width)}}renderLabel(_,B,k,R,F,A){var N;if(!_.Label.print)return;const G=_.Label.fontHeight*y.unitInPixels,{font:U}=_.Label;let C;this.rules.ColoringEnabled&&(C=_.Label.colorDefault,_.ColorXML&&(C=_.ColorXML),C||(C=this.rules.DefaultColorLabel));let z,{fontStyle:W,fontFamily:$}=_.Label;W||(W=this.rules.DefaultFontStyle),$||($=this.rules.DefaultFontFamily);for(let Y=0;Y<((N=_.TextLines)==null?void 0:N.length);Y++){const tt=_.TextLines[Y],H=this.calculatePixelDistance(tt.xOffset),rt=new s.PointF2D(A.x+H,A.y),ct=this.backend.renderText(G,W,U,tt.text,F,rt,C,_.Label.fontFamily);z?z.appendChild(ct):z=ct,A.y=A.y+F,_.TextLines.length>1&&(A.y+=this.rules.SpacingBetweenTextLines)}return z}renderRectangle(_,B,k,R,F){return this.backend.renderRectangle(_,k,R,F)}applyScreenTransformation(_){return new s.PointF2D(_.x*y.unitInPixels,_.y*y.unitInPixels)}applyScreenTransformationForRect(_){return new a.RectangleF2D(_.x*y.unitInPixels,_.y*y.unitInPixels,_.width*y.unitInPixels,_.height*y.unitInPixels)}}y.VexFlowMusicSheetDrawer=x},4332(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.VexFlowMusicSystem=void 0;const d=p(5221),l=p(6954),m=p(67),a=p(4284),s=p(6014),h=p(3109),u=p(7098);class f extends d.MusicSystem{constructor(b,S){super(b),this.rules=S}calculateBorders(b){if(this.staffLines.length===0)return;const S=this.calcBracketsWidth();this.boundingBox.BorderLeft=-S,this.boundingBox.BorderMarginLeft=-S,this.boundingBox.XBordersHaveBeenSet=!0;const v=this.staffLines[0].SkyBottomLineCalculator.getSkyLineMin();this.boundingBox.BorderTop=v,this.boundingBox.BorderMarginTop=v;const w=this.staffLines[this.staffLines.length-1],T=w.SkyBottomLineCalculator.getBottomLineMax()+w.PositionAndShape.RelativePosition.y;this.boundingBox.BorderBottom=T,this.boundingBox.BorderMarginBottom=T,this.boundingBox.XBordersHaveBeenSet=!0,this.boundingBox.YBordersHaveBeenSet=!0}createSystemLine(b,S,v,w,T,g,x=void 0){const P=g;let _=!1;if(x){_=!0,x.addMeasureLine(v,w),P&&P.addMeasureLine(v,w,_);let B=0;if(v===l.SystemLinesEnum.BoldThinDots&&w===m.SystemLinePosition.MeasureBegin&&g.beginInstructionsWidth>0&&(B=P.getVFStave().getModifierXShift(0)),x.lineTo(g,s.VexFlowConverter.line(v,w),B),v===l.SystemLinesEnum.DotsBoldBoldDots){const k=x.ParentStaffLine.Measures.indexOf(x)+1,R=x.ParentStaffLine.Measures[k],F=g.ParentStaffLine.Measures[k];R&&F&&(R.lineTo(F,s.VexFlowConverter.line(l.SystemLinesEnum.BoldThinDots,w)),R.addMeasureLine(l.SystemLinesEnum.BoldThinDots,w))}}else P&&P.addMeasureLine(v,w,_);return new a.SystemLine(v,w,this,g,x)}createInstrumentBracket(b,S){const v=b,w=S,T=new u.VexFlowInstrumentBrace(v,w);this.InstrumentBrackets.push(T)}createGroupBracket(b,S,v){const w=b,T=S;if(v===0){const g=new h.VexFlowInstrumentBracket(w,T,v);this.GroupBrackets.push(g)}else{const g=new u.VexFlowInstrumentBrace(w,T,v);this.GroupBrackets.push(g)}}}y.VexFlowMusicSystem=f},9310(St,y,p){var d=this&&this.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(y,"__esModule",{value:!0}),y.VexFlowOctaveShift=void 0;var l=d(p(3206)).default.Flow;const m=p(2768),a=p(437),s=d(p(3065));class h extends m.GraphicalOctaveShift{constructor(f,r){switch(super(f,r),f.Type){case a.OctaveEnum.VA8:this.position=l.TextBracket.Positions.TOP,this.supscript="va",this.text="8";break;case a.OctaveEnum.MA15:this.position=l.TextBracket.Positions.TOP,this.supscript="ma",this.text="15";break;case a.OctaveEnum.VB8:this.position=l.TextBracket.Positions.BOTTOM,this.supscript="vb",this.text="8";break;case a.OctaveEnum.MB15:this.position=l.TextBracket.Positions.BOTTOM,this.supscript="mb",this.text="15";break;default:s.default.error("Unknown or NONE octaveshift. This should not be called!")}}setStartNote(f){for(const r of f.graphicalVoiceEntries){const b=r;if(b!=null&&b.vfStaveNote)return this.startNote=b.vfStaveNote,!0}return!1}setEndNote(f,r=-1){var S;const b=f.graphicalVoiceEntries;for(let v=(r>=0?Math.min(r,b.length):b.length)-1;v>=0;v--){const w=b[v];if(w!=null&&w.vfStaveNote)return this.endNote=w.vfStaveNote,this.endMeasure=f.parentMeasure,(S=this.endMeasure)!=null&&S.parentSourceMeasure.Rules.OctaveShiftOnWholeMeasureNoteUntilEndOfMeasure&&w.notes[0].sourceNote.isWholeMeasureNote()&&(this.graphicalEndAtMeasureEnd=!0),!0}return!1}getTextBracket(){let f,r=this.endNote;const b=this;this.graphicalEndAtMeasureEnd&&(f={getAbsoluteX:()=>10*(b.endMeasure.PositionAndShape.AbsolutePosition.x+b.endMeasure.PositionAndShape.Size.width),getGlyph:()=>({getWidth:()=>0})}),f&&(r=f);const S=new l.TextBracket({position:this.position,start:this.startNote,stop:r,superscript:this.supscript,text:this.text});return this.endsOnDifferentStaffLine&&(S.render_options.show_bracket=!1),S}}y.VexFlowOctaveShift=h},7109(St,y,p){var d=this&&this.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(y,"__esModule",{value:!0}),y.VexFlowPedal=void 0;const l=d(p(3206)),m=p(6438),a=p(7824),s=p(512);class h extends a.GraphicalPedal{constructor(f,r,b=!1,S=!1){switch(super(f,r),this.vfStyle=l.default.Flow.PedalMarking.Styles.BRACKET,this.ChangeBegin=!1,this.ChangeEnd=!1,this.line=-3,this.EndSymbolPositionAndShape=void 0,this.ChangeBegin=f.ChangeBegin,this.ChangeEnd=f.ChangeEnd,this.pedalSymbol){case s.MusicSymbol.PEDAL_SYMBOL:this.vfStyle=l.default.Flow.PedalMarking.Styles.TEXT,this.EndSymbolPositionAndShape=new m.BoundingBox(this,r);break;case s.MusicSymbol.PEDAL_MIXED:this.vfStyle=b&&S?l.default.Flow.PedalMarking.Styles.BRACKET_OPEN_BOTH:b?l.default.Flow.PedalMarking.Styles.BRACKET_OPEN_BEGIN:S?l.default.Flow.PedalMarking.Styles.MIXED_OPEN_END:l.default.Flow.PedalMarking.Styles.MIXED;break;case s.MusicSymbol.PEDAL_BRACKET:default:this.vfStyle=b&&S?l.default.Flow.PedalMarking.Styles.BRACKET_OPEN_BOTH:b?l.default.Flow.PedalMarking.Styles.BRACKET_OPEN_BEGIN:S?l.default.Flow.PedalMarking.Styles.BRACKET_OPEN_END:l.default.Flow.PedalMarking.Styles.BRACKET}}setStartNote(f){if(!f)return!1;for(const r of f.graphicalVoiceEntries){const b=r;if(b!=null&&b.vfStaveNote)return this.startNote=b.vfStaveNote,this.startVfVoiceEntry=b,!0}return!1}setEndNote(f){if(!f)return!1;for(const r of f.graphicalVoiceEntries){const b=r;if(b!=null&&b.vfStaveNote)return this.endNote=b.vfStaveNote,this.endVfVoiceEntry=b,!0}return!1}setEndMeasure(f){this.endMeasure=f}CalculateBoundingBox(){}setLine(f){this.line=f}getPedalMarking(){const f=new l.default.Flow.PedalMarking([this.startNote,this.endNote]);return this.endMeasure&&f.setEndStave(this.endMeasure.getVFStave()),f.setStyle(this.vfStyle),f.setLine(this.line),f.setCustomText(this.DepressText,this.ReleaseText),this.endVfVoiceEntry&&!this.getPedal.EndsStave||(f.EndsStave=!0),this.getPedal.BeginsStave&&(f.BeginsStave=!0),f.ChangeBegin=this.ChangeBegin,f.ChangeEnd=this.ChangeEnd,f}setEndsStave(f,r){r!=null&&r.gte(f.parentSourceMeasure.Duration)&&(this.getPedal.EndsStave=!0)}setBeginsStave(f,r){f&&r.RealValue===0&&(this.getPedal.BeginsStave=!0)}}y.VexFlowPedal=h},5468(St,y,p){var d=this&&this.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(y,"__esModule",{value:!0}),y.VexFlowSlur=y.CurvePositionEnum=void 0;var l,m=d(p(3206)).default.Flow;(function(s){s[s.NEAR_HEAD=1]="NEAR_HEAD",s[s.NEAR_TOP=2]="NEAR_TOP"})(l||(y.CurvePositionEnum=l={}));class a{constructor(h){this.vfStartNote=void 0,this.vfEndNote=void 0,this.parentSlur=h}static createFromVexflowSlur(h){return new a(h.parentSlur)}get vfSlur(){return this.parentSlur}curve_Options(){return{cps:[{x:0,y:10},{x:0,y:10}],invert:!1,position:l.NEAR_TOP,position_end:l.NEAR_TOP,spacing:2,thickness:2,x_shift:0,y_shift:10}}createVexFlowCurve(){this.vfCurve=new m.Curve(this.vfStartNote,this.vfEndNote,void 0)}}y.VexFlowSlur=a},6670(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.VexFlowStaffEntry=void 0;const d=p(348),l=p(9479),m=p(8233);class a extends d.GraphicalStaffEntry{constructor(h,u,f){super(h,u,f)}calculateXPosition(){const h=this.parentMeasure.getVFStave();let u=0;for(const f of this.graphicalVoiceEntries)if(f.vfStaveNote){if(f.vfStaveNote.setStave(h),!f.vfStaveNote.preFormatted)continue;f.applyBordersFromVexflow();let r=!1,b=this.PositionAndShape;f.notes[0].sourceNote.isWholeRest()&&!this.hasOnlyRests()&&(r=!0,b=f.PositionAndShape),this.parentMeasure.ParentStaff.isTab?b.RelativePosition.x=(f.vfStaveNote.getAbsoluteX()+f.vfStaveNote.glyph.getWidth())/l.unitInPixels:(b.RelativePosition.x=f.vfStaveNote.getBoundingBox().getX()/l.unitInPixels,r&&(b.RelativePosition.x-=h.getNoteStartX()/l.unitInPixels,b.RelativePosition.x-=1.3));const S=f.notes[0].sourceNote;S.isRest()&&S.Length.RealValue===this.parentMeasure.parentSourceMeasure.ActiveTimeSignature.RealValue&&(b.RelativePosition.x+=this.parentMeasure.parentSourceMeasure.Rules.WholeRestXShiftVexflow-.1,f.PositionAndShape.BorderLeft=-.7,f.PositionAndShape.BorderRight=.7),f.PositionAndShape.BorderLeftb.staffLine),f=this.calculateModifierXOffsets(u,.5),r=this.calculateModifierXOffsets(u,1);h.forEach((b,S)=>{b.baseFingeringXOffset=f[S],b.baseStringNumberXOffset=r[S]})}calculateModifierXOffsets(h,u){const f=[];for(let r=0;r=0;v--){if(Math.abs(h[r]-h[v])<=u&&b===f[v]){b++,S=!0;break}S=!1}f.push(b)}return f}}y.VexFlowStaffEntry=a},5866(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.VexFlowStaffLine=void 0;const d=p(2919),l=p(1083);class m extends d.StaffLine{constructor(s,h){super(s,h),this.slursInVFStaffLine=[],this.alignmentManager=new l.AlignmentManager(this)}get SlursInVFStaffLine(){return this.slursInVFStaffLine}addVFSlurToVFStaffline(s){this.slursInVFStaffLine.push(s)}get AlignmentManager(){return this.alignmentManager}}y.VexFlowStaffLine=m},6173(St,y,p){var d=this&&this.__importDefault||function(f){return f&&f.__esModule?f:{default:f}};Object.defineProperty(y,"__esModule",{value:!0}),y.VexFlowTabMeasure=void 0;var l=d(p(3206)).default.Flow;const m=p(5246),a=p(6014),s=d(p(3065)),h=p(164);class u extends m.VexFlowMeasure{constructor(r,b=void 0,S=void 0){super(r,b,S),this.isTabMeasure=!0}resetLayout(){const r=this.ParentStaff.StafflineCount??6;this.stave=new l.TabStave(0,0,0,{space_above_staff_ln:0,space_below_staff_ln:0,num_lines:r}),this.updateInstructionWidth()}graphicalMeasureCreatedCalculations(){for(let b=0,S=this.staffEntries.length;b1){const g=a.VexFlowConverter.StrokeTypeFromArpeggioType(T.type),x=new l.Stroke(g,{all_voices:this.rules.ArpeggiosGoAcrossVoices});this.rules.RenderArpeggios&&w.vfStaveNote.addStroke(0,x)}else s.default.debug(`[OSMD] arpeggio in measure ${this.MeasureNumber} could not be drawn. - voice entry had less than two notes, arpeggio is likely between voice entries, not currently supported in Vexflow.`)}if(w.vfGhostNotes)for(const T of w.vfGhostNotes)this.vfVoices[b.VoiceId].addTickable(T);else this.vfVoices[b.VoiceId].addTickable(w.vfStaveNote)}else if(w.vfGhostNotes)for(const T of w.vfGhostNotes)this.vfVoices[b.VoiceId].addTickable(T);else this.vfVoices[b.VoiceId].addTickable(w.vfStaveNote)}}}addClefAtBegin(r){r.ClefType===h.ClefEnum.TAB&&super.addClefAtBegin(r)}draw(r){super.draw(r);const b=this.parentSourceMeasure;b.multipleRestMeasures&&this.rules.RenderMultipleRestMeasures&&(this.multiRestElement=new l.MultiMeasureRest(b.multipleRestMeasures,{}),this.multiRestElement.setStave(this.stave),this.multiRestElement.setContext(r),this.multiRestElement.draw())}}y.VexFlowTabMeasure=u},7785(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.VexFlowTextMeasurer=void 0;const d=p(6014);y.VexFlowTextMeasurer=class{constructor(l){this.fontSize=20,this.fontSizeStandard=this.fontSize;const m=document.createElement("canvas");this.context=m.getContext("2d"),this.rules=l}computeTextWidthToHeightRatio(l,m,a,s=void 0,h=this.fontSize){return this.context.font=d.VexFlowConverter.font(h,a,m,this.rules,s),this.context.measureText(l).width/h}setFontSize(l=this.fontSizeStandard){return this.fontSize=l,l}}},2907(St,y,p){var d=this&&this.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(y,"__esModule",{value:!0}),y.VexFlowVibratoBracket=void 0;const l=p(7753),m=d(p(3206));class a extends l.GraphicalWavyLine{get ToEndOfStopStave(){return this.toEndOfStopStave}constructor(h,u,f=!1){super(h,u),this.line=1,this.isVibrato=!1,this.toEndOfStopStave=!1,this.isVibrato=f}setStartNote(h){for(const u of h.graphicalVoiceEntries){const f=u;if(f!=null&&f.vfStaveNote)return this.startNote=f.vfStaveNote,this.startVfVoiceEntry=f,!0}return!1}setEndNote(h){for(const u of h.graphicalVoiceEntries){const f=u;if(f!=null&&f.vfStaveNote){this.endNote=f.vfStaveNote,this.endVfVoiceEntry=f;const r=this.endVfVoiceEntry.parentStaffEntry.parentMeasure.staffEntries,b=r[r.length-1];return this.toEndOfStopStave=b===this.endVfVoiceEntry.parentStaffEntry,!0}}return!1}CalculateBoundingBox(){const h=this.getVibratoBracket();this.boundingBox.Size.height=.2*h.render_options.wave_height}getVibratoBracket(){const h=new m.default.Flow.VibratoBracket({start:this.startNote,stop:this.endNote,toEndOfStopStave:this.toEndOfStopStave});return h.setLine(this.line),this.isVibrato?h.render_options.vibrato_width=20:h.render_options.wave_girth=4,h}}y.VexFlowVibratoBracket=a},4134(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.VexFlowVoiceEntry=void 0;const d=p(4548),l=p(9479),m=p(4434),a=p(4064);class s extends d.GraphicalVoiceEntry{constructor(u,f,r){super(u,f,r)}applyBordersFromVexflow(){const u=this.vfStaveNote;if(!u.getNoteHeadBeginX)return;const f=u.getBoundingBox(),r=u.getNoteHeadBeginX()-f.x;this.PositionAndShape.RelativePosition.y=f.y/l.unitInPixels,this.PositionAndShape.BorderTop=0,this.PositionAndShape.BorderBottom=f.h/l.unitInPixels;const b=(u.width-(u.paddingRight??0))/2;this.PositionAndShape.BorderLeft=-(r+b)/l.unitInPixels,this.PositionAndShape.BorderRight=(f.w-r)/l.unitInPixels}set vfStaveNote(u){this.mVexFlowStaveNote=u}get vfStaveNote(){return this.mVexFlowStaveNote}applyCustomNoteheads(){const u=this.vfStaveNote;if(u)for(let f=0;ff.length-1)return-1;for(let S=b;Sthis.rules.PercussionOneLineCutoff&&!S&&!this.rules.PercussionUseCajon2NoteSystem)return f;const v=f,w=f.sourceNote.Pitch;let T=this.baseLineNote,g=this.baseLineOctave;if(this.rules.PercussionUseCajon2NoteSystem?w.FundamentalNote===d.NoteEnum.C&&(T=d.NoteEnum.G,g=1):this.rules.PercussionUseXMLDisplayStep&&f.sourceNote.displayStepUnpitched!==void 0&&(T=f.sourceNote.displayStepUnpitched,g=f.sourceNote.displayOctaveUnpitched+this.rules.PercussionOneLineXMLDisplayStepOctaveOffset),b.length<=this.rules.PercussionForceVoicesOneLineCutoff)v.setAccidental(new d.Pitch(T,g,w.Accidental));else{const x=h.PitchIndexOf(b,w);if(x>-1){const P=Math.ceil(b.length/2);if(!this.rules.PercussionUseXMLDisplayStep)if(x>=P)switch(g=2,(x-P)%5){case 1:T=d.NoteEnum.E;break;case 2:T=d.NoteEnum.G;break;case 3:T=d.NoteEnum.B;break;case 4:T=d.NoteEnum.D,g=3;break;default:T=d.NoteEnum.C}else switch(x%5){case 1:T=d.NoteEnum.F;break;case 2:T=d.NoteEnum.D;break;case 3:T=d.NoteEnum.B,g=0;break;case 4:T=d.NoteEnum.G,g=0;break;default:T=d.NoteEnum.A}const _=new d.Pitch(T,g,w.Accidental);v.setAccidental(_);const B=v.parentVoiceEntry.parentVoiceEntry;!this.rules.SetWantedStemDirectionByXml&&B.Notes.length<2&&(_.Octave>this.baseLineOctave||_.FundamentalNote===this.baseLineNote&&_.Octave===this.baseLineOctave?v.parentVoiceEntry.parentVoiceEntry.WantedStemDirection=s.StemDirectionType.Up:v.parentVoiceEntry.parentVoiceEntry.WantedStemDirection=s.StemDirectionType.Down)}}return v}getStafflineUniquePositionCount(f){return this.staffPitchListMapping.containsKey(f)?this.staffPitchListMapping.getValue(f).length:0}}y.VexflowStafflineNoteCalculator=h},7499(St,y,p){var d=this&&this.__createBinding||(Object.create?function(m,a,s,h){h===void 0&&(h=s);var u=Object.getOwnPropertyDescriptor(a,s);u&&!("get"in u?!a.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return a[s]}}),Object.defineProperty(m,h,u)}:function(m,a,s,h){h===void 0&&(h=s),m[h]=a[s]}),l=this&&this.__exportStar||function(m,a){for(var s in m)s==="default"||Object.prototype.hasOwnProperty.call(a,s)||d(a,m,s)};Object.defineProperty(y,"__esModule",{value:!0}),l(p(1083),y),l(p(9834),y),l(p(9436),y),l(p(1902),y),l(p(2400),y),l(p(6014),y),l(p(1216),y),l(p(9635),y),l(p(3753),y),l(p(7809),y),l(p(7098),y),l(p(3109),y),l(p(5246),y),l(p(3849),y),l(p(806),y),l(p(9479),y),l(p(4332),y),l(p(9310),y),l(p(5468),y),l(p(6670),y),l(p(5866),y),l(p(7506),y),l(p(6173),y),l(p(7785),y),l(p(4134),y)},3508(St,y,p){var d=this&&this.__importDefault||function(b){return b&&b.__esModule?b:{default:b}};Object.defineProperty(y,"__esModule",{value:!0}),y.WebGLSkyBottomLineBatchCalculatorBackend=void 0;const l=p(5479),m=p(3667),a=d(p(5340)),s=d(p(5166)),h=d(p(3065)),u=p(813);function f(b,S,v){const w=b.createShader(S);if(!w)throw h.default.warn("WebGLSkyBottomLineCalculatorBackend: Could not create a WebGL shader"),new Error("Could not create a WebGL shader");if(b.shaderSource(w,v),b.compileShader(w),!b.getShaderParameter(w,b.COMPILE_STATUS))throw h.default.warn(`Shader compilation failed + Will not give further warnings for all pages, only total.`))}else{const _=this.musicSystems[P-1],B=_.StaffLines[_.StaffLines.length-1],k=B.PositionAndShape;let R=this.findRequiredDistanceWithSkyBottomLine(_,g);R+=this.rules.MinSkyBottomDistBetweenSystems,R=Math.max(R,this.rules.MinimumDistanceBetweenSystems+B.StaffHeight);const F=T+k.RelativePosition.y+R,A=F+g.PositionAndShape.BorderMarginBottom;if(this.rules.NewPageAtXMLNewPageAttribute&&_.breaksPage||!(A0&&console.log(`total amount of pages that couldn't fit a single music system: ${x} of ${w.PageNumber}`)}findRequiredDistanceWithSkyBottomLine(w,T){const g=w.StaffLines[w.StaffLines.length-1],x=T.StaffLines[0],P=g.BottomLine,_=x.SkyLine,B=g.PositionAndShape,k=x.PositionAndShape,R=1/this.rules.SamplingUnit;let F=0;for(let A=0;A=_.length)break;const C=Math.max(0,U-6),z=Math.min(_.length-1,U+6);let W=0;for(let N=C;N<=z;N++)W=Math.min(W,_[N]);const $=G-W;F=Math.max($,F)}return F===0&&(F=B.BorderBottom-k.BorderTop),F}};class v{constructor(){this.systemMeasures=[],this.systemMeasureIndex=0,this.currentWidth=0,this.currentSystemFixWidth=0,this.currentSystemVarWidth=0,this.maxLabelLength=0}IsSystemStartMeasure(){return this.systemMeasureIndex===0}}y.SystemBuildParameters=v,y.MeasureBuildParameters=class{}},8033(St,y){Object.defineProperty(y,"__esModule",{value:!0}),y.OctaveShiftParams=void 0,y.OctaveShiftParams=class{constructor(p,d,l){this.getOpenOctaveShift=p,this.getAbsoluteStartTimestamp=d,this.getAbsoluteEndTimestamp=l}}},735(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.PlainSkyBottomLineBatchCalculatorBackend=void 0;const d=p(5479),l=p(3667);class m extends l.SkyBottomLineBatchCalculatorBackend{constructor(s,h){super(s,h)}getPreferredRenderingConfiguration(s,h){return{elementWidth:Math.ceil(s),numColumns:6,numRows:6}}onInitialize(s){}calculateFromCanvas(s,h,u,f,r){const b=s.width,S=h.getImageData(0,0,s.width,s.height),{elementWidth:v,elementHeight:w,numColumns:T}=r,g=[];for(let x=0;x0){G[W-k]=$-F;break}}U[W-k]=w;for(let $=A-1;$>=F;$--){const N=$*b*4+4*W;if(S.data[N+3]>0){U[W-k]=$-F;break}}}const C=Math.max(...G),z=Math.min(...U);for(let W=0;W<_;++W)G[W]=G[W]===0?C:G[W],U[W]=U[W]===w?z:U[W];g.push(new d.SkyBottomLineCalculationResult(G,U))}return g}}y.PlainSkyBottomLineBatchCalculatorBackend=m},7624(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.SelectionEndSymbol=void 0;const d=p(7741),l=p(2683),m=p(9409),o=p(6438),s=p(6452),h=p(813);class u extends d.GraphicalObject{constructor(r,b){super();const S=b,v=r.PositionAndShape.AbsolutePosition.y,w=h.CollectionUtil.last(r.StaffLines).PositionAndShape.RelativePosition.y+4;this.verticalLine=new s.GraphicalLine(new m.PointF2D(S,v),new m.PointF2D(S,v+w),.4,l.OutlineAndFillStyleEnum.SelectionSymbol);for(let T=0,g=r.StaffLines.length;T{if(r.has(S))return r.get(S);{const v=[];return r.set(S,v),v}})().push({skyBottomLineCalculator:b.SkyBottomLineCalculator,measures:b.Measures})}this.batches=new Map;for(const[b,S]of r.entries()){const v=h.CollectionUtil.flat(S.map(T=>T.measures)),w=(()=>{if(f===l.SkyBottomLineBatchCalculatorBackendType.Plain)return new m.PlainSkyBottomLineBatchCalculatorBackend(b,v).initialize();try{return new o.WebGLSkyBottomLineBatchCalculatorBackend(b,v).initialize()}catch{return s.default.info("Couldn't create WebGLBackend for Skyline. Using fallback."),new m.PlainSkyBottomLineBatchCalculatorBackend(b,v).initialize()}})();w.initialize(),this.batches.set(b,{backend:w,entries:S})}}calculateLines(){for(const[,{backend:u,entries:f}]of this.batches){const r=u.calculateLines();let b=0;for(const{skyBottomLineCalculator:S,measures:v}of f){const w=b+v.length;S.updateLines(r.slice(b,w)),b=w}}}}},3667(St,y,p){var d=this&&this.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};Object.defineProperty(y,"__esModule",{value:!0}),y.SkyBottomLineBatchCalculatorBackend=void 0;const l=p(9834),m=d(p(3065));y.SkyBottomLineBatchCalculatorBackend=class{constructor(o,s){this.elementHeight=300,this.canvas=new l.CanvasVexFlowBackend(o),this.measures=s,this.maxWidth=Math.max(...this.measures.map(h=>{let u=h.getVFStave().getWidth();return u>0||h.IsExtraGraphicalMeasure||(m.default.warn("SkyBottomLineBatchCalculatorBackend: width not > 0 in measure "+h.MeasureNumber),u=50),u})),this.samplingUnit=o.SamplingUnit}initialize(){if(this.tableConfiguration={...this.getPreferredRenderingConfiguration(this.maxWidth,this.elementHeight),elementHeight:this.elementHeight},this.tableConfiguration.numRows<1||this.tableConfiguration.numColumns<1)throw m.default.warn("SkyBottomLineBatchCalculatorBackend: numRows or numColumns in tableConfiguration is 0"),new Error("numRows or numColumns in tableConfiguration is 0");this.tableConfiguration.elementWidth0||P.IsExtraGraphicalMeasure||(R=50),R=Math.floor(R),P.PositionAndShape.calculateAbsolutePositionsRecursive(0,0),_.setX(0);const A=_.y+100;_.setY(A);const G=_.getWidth();_.setWidth(R),P.format(),_.setWidth(G);try{b.translate(B*h,k*u),P.draw(r),b.translate(-B*h,-k*u)}catch(U){m.default.warn("SkyBottomLineBatchCalculatorBackend.calculateLines.draw",U)}}const g=this.calculateFromCanvas(S,r,T,this.samplingUnit,this.tableConfiguration);v.push(...g)}return v}}},5479(St,y){Object.defineProperty(y,"__esModule",{value:!0}),y.SkyBottomLineCalculationResult=void 0,y.SkyBottomLineCalculationResult=class{constructor(p,d){this.skyLine=p,this.bottomLine=d}}},2779(St,y,p){var d=this&&this.__importDefault||function(h){return h&&h.__esModule?h:{default:h}};Object.defineProperty(y,"__esModule",{value:!0}),y.SkyBottomLineCalculator=void 0,p(9409);const l=p(9479),m=d(p(3065)),o=p(5479),s=p(9834);y.SkyBottomLineCalculator=class{constructor(h){this.mStaffLineParent=h,this.mRules=h.ParentMusicSystem.rules}updateLines(h){const u=this.StaffLineParent.Measures;if(h.length!==u.length)if(m.default.warn("SkyBottomLineCalculator: lengths of calculation result array and measure array do not match"),h.length(T-v)/l.unitInPixels+this.StaffLineParent.TopLineOffset);const w=Math.min(...this.mBottomLine);this.mBottomLine=this.mBottomLine.map(T=>(T-w)/l.unitInPixels+this.StaffLineParent.BottomLineOffset)}calculateLines(){const h=this.mRules.SamplingUnit,u=[],f=new s.CanvasVexFlowBackend(this.mRules);for(const r of this.StaffLineParent.Measures){r.PositionAndShape.calculateAbsolutePositionsRecursive(0,0);const b=r.getVFStave();let S=b.getWidth();S>0||r.IsExtraGraphicalMeasure||(m.default.warn("SkyBottomLineCalculator: width not > 0 in measure "+r.MeasureNumber),S=50),f.initializeHeadless(S);const v=f.getContext(),w=f.getCanvas();S=w.width;const T=w.height;b.setY(b.y+100);const g=b.getWidth();b.setWidth(S),r.format(),b.setWidth(g);try{r.draw(v)}catch(R){m.default.warn("SkyBottomLineCalculator.calculateLines.draw",R)}const x=v.getImageData(0,0,S,T),P=4,_=Math.max(Math.ceil(r.PositionAndShape.Size.width*h),1),B=new Array(_),k=new Array(_);for(let R=0;R0){B[R]=F;break}}for(let F=T;F>0;F--){const A=F*S*P+R*P;if(x.data[A+3]>0){k[R]=F;break}}}for(let R=0;R=this.BottomLine.length&&(f=this.BottomLine.length-1),r<0&&(r=0),r>=this.BottomLine.length&&(r=this.BottomLine.length),this.SkyLine[f]=h.y;for(let S=f+1;S=this.BottomLine.length&&(f=this.BottomLine.length-1),r<0&&(r=0),r>=this.BottomLine.length&&(r=this.BottomLine.length),this.BottomLine[f]=h.y;for(let S=f+1;Sh)}setBottomLineWithValue(h){this.BottomLine.forEach(u=>h)}getLeftIndexForPointX(h,u){const f=Math.floor(h*this.SamplingUnit);return f<0?0:f>=u?u-1:f}getRightIndexForPointX(h,u){const f=Math.ceil(h*this.SamplingUnit);return f<0?0:f>=u?u-1:f}updateStaffLineBorders(){this.mStaffLineParent.PositionAndShape.BorderTop=this.getSkyLineMin(),this.mStaffLineParent.PositionAndShape.BorderMarginTop=this.getSkyLineMin(),this.mStaffLineParent.PositionAndShape.BorderBottom=this.getBottomLineMax(),this.mStaffLineParent.PositionAndShape.BorderMarginBottom=this.getBottomLineMax()}getSkyLineMin(){return Math.min(...this.SkyLine.filter(h=>!isNaN(h)))}getSkyLineMinAtPoint(h){const u=Math.round(h*this.SamplingUnit);return this.mSkyLine[u]}getSkyLineMinInRange(h,u){return this.getMinInRange(this.SkyLine,h,u)}getBottomLineMax(){return Math.max(...this.BottomLine.filter(h=>!isNaN(h)))}getBottomLineMaxAtPoint(h){const u=Math.round(h*this.SamplingUnit);return this.mBottomLine[u]}getBottomLineMaxInRange(h,u){return this.getMaxInRange(this.BottomLine,h,u)}getBottomLineMaxInBoundingBox(h){const u=Math.floor(h.AbsolutePosition.x+h.BorderLeft),f=Math.ceil(h.AbsolutePosition.x+h.BorderRight);return this.getMaxInRange(this.mBottomLine,u,f)}updateWithBoundingBoxRecursively(h){if(h.ChildElements&&h.ChildElements.length>0)this.updateWithBoundingBoxRecursively(h);else{const u=h.BorderTop+h.AbsolutePosition.y,f=h.BorderBottom+h.AbsolutePosition.y;if(u<0){const r=Math.floor(h.AbsolutePosition.x+h.BorderLeft),b=Math.ceil(h.AbsolutePosition.x+h.BorderRight);this.updateInRange(this.mSkyLine,r,b,u)}else if(f>this.StaffLineParent.StaffHeight){const r=Math.floor(h.AbsolutePosition.x+h.BorderLeft),b=Math.ceil(h.AbsolutePosition.x+h.BorderRight);this.updateInRange(this.mBottomLine,r,b,f)}}}findPreviousValidNumber(h,u){for(let f=h;f>=0;f--)if(!isNaN(u[f]))return u[f];return 0}findNextValidNumber(h,u){if(h>=u.length)return u[h-1];for(let f=h;fh.length&&(f=h.length);for(let b=u;bMath.abs(h[b])?r:h[b]}setInRange(h,u=0,f=h.length,r=0){if(u=Math.floor(u*this.SamplingUnit),(f=Math.ceil(f*this.SamplingUnit))h.length&&(f=h.length);for(let b=u;b=h.length&&(u=h.length-1),f<0&&(f=0),f>=h.length&&(f=h.length),u>=0&&f<=h.length?Math.min(...h.slice(u,f+1)):void 0):Number.MAX_VALUE}getMaxInRange(h,u,f){return u=Math.floor(u*this.SamplingUnit),f=Math.ceil(f*this.SamplingUnit),h?(u<0&&(u=0),u>=h.length&&(u=h.length-1),f<0&&(f=0),f>=h.length&&(f=h.length),u>=0&&f<=h.length?Math.max(...h.slice(u,f+1)):void 0):Number.MIN_VALUE}get SamplingUnit(){return this.mRules.SamplingUnit}get StaffLineParent(){return this.mStaffLineParent}get SkyLine(){return this.mSkyLine}get BottomLine(){return this.mBottomLine}}},2919(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.StaffLine=void 0;const d=p(6438),l=p(7741),m=p(298),o=p(9409),s=p(2779);class h extends l.GraphicalObject{constructor(f,r){super(),this.measures=[],this.staffLines=new Array(5),this.octaveShifts=[],this.lyricLines=[],this.lyricsDashes=[],this.abstractExpressions=[],this.graphicalSlurs=[],this.graphicalGlissandi=[],this.Pedals=[],this.WavyLines=[],this.parentMusicSystem=f,this.parentStaff=r,this.boundingBox=new d.BoundingBox(this,f.PositionAndShape),this.skyBottomLine=new s.SkyBottomLineCalculator(this),this.staffHeight=this.parentMusicSystem.rules.StaffHeight,this.topLineOffset=0,this.bottomLineOffset=4,this.calculateStaffLineOffsets()}calculateStaffLineOffsets(){if(this.ParentStaff.isTab)this.ParentStaff.StafflineCount===5?this.staffHeight=this.bottomLineOffset=6*this.ParentStaff.ParentInstrument.GetMusicSheet.Rules.TabStaffInterlineHeight:this.staffHeight=this.bottomLineOffset=this.ParentStaff.ParentInstrument.GetMusicSheet.Rules.TabStaffInterlineHeight*this.ParentStaff.StafflineCount;else switch(this.ParentStaff.StafflineCount){case 4:this.bottomLineOffset=1;break;case 3:this.topLineOffset=1,this.bottomLineOffset=1;break;case 2:this.topLineOffset=2,this.bottomLineOffset=1;break;case 1:this.topLineOffset=2,this.bottomLineOffset=2}}get Measures(){return this.measures}set Measures(f){this.measures=f}get StaffLines(){return this.staffLines}set StaffLines(f){this.staffLines=f}get NextStaffLine(){const f=this.parentMusicSystem.StaffLines.indexOf(this);return f!==this.parentMusicSystem.StaffLines.length?this.parentMusicSystem.StaffLines[f+1]:void 0}get LyricLines(){return this.lyricLines}get AbstractExpressions(){return this.abstractExpressions}set AbstractExpressions(f){this.abstractExpressions=f}set LyricLines(f){this.lyricLines=f}get LyricsDashes(){return this.lyricsDashes}set LyricsDashes(f){this.lyricsDashes=f}get ParentMusicSystem(){return this.parentMusicSystem}set ParentMusicSystem(f){this.parentMusicSystem=f}get ParentStaff(){return this.parentStaff}set ParentStaff(f){this.parentStaff=f}get SkyBottomLineCalculator(){return this.skyBottomLine}get SkyLine(){return this.skyBottomLine.SkyLine}get BottomLine(){return this.skyBottomLine.BottomLine}get OctaveShifts(){return this.octaveShifts}set OctaveShifts(f){this.octaveShifts=f}get StaffHeight(){return this.staffHeight}get TopLineOffset(){return this.topLineOffset}get BottomLineOffset(){return this.bottomLineOffset}get GraphicalSlurs(){return this.graphicalSlurs}get GraphicalGlissandi(){return this.graphicalGlissandi}addSlurToStaffline(f){this.graphicalSlurs.push(f)}addGlissandoToStaffline(f){this.graphicalGlissandi.push(f),f.StaffLine=this}addActivitySymbolClickArea(){const f=new m.StaffLineActivitySymbol(this),r=this.PositionAndShape;f.PositionAndShape.RelativePosition=new o.PointF2D(r.RelativePosition.x+r.BorderRight+.5,r.RelativePosition.y+.5),f.PositionAndShape.Parent=this.parentMusicSystem.PositionAndShape}isPartOfMultiStaffInstrument(){return this.parentStaff.ParentInstrument.Staves.length>1}findClosestStaffEntry(f){let r;for(let b=0,S=this.Measures.length;bm?1:0}getFirstNonNullStaffEntry(){for(let p=0,d=this.staffEntries.length;p0){const f=u.map(b=>b.PositionAndShape.Center.y),r=Math.max(...f);for(let b=0;b0?u[b-1]:void 0;if(w){const g=this.getOverlap(S.PositionAndShape,w.PositionAndShape);S.squeeze(-(g.x+this.rules.DynamicExpressionSpacer))}if(T){const g=this.getOverlap(T.PositionAndShape,S.PositionAndShape);S.squeeze(g.x+this.rules.DynamicExpressionSpacer)}}}}}getDistance(m,o){const s=m.RelativePosition.x+m.BorderMarginRight,h=o.RelativePosition.x+o.BorderMarginLeft,u=m.RelativePosition.y+m.BorderMarginBottom,f=o.RelativePosition.y+o.BorderMarginTop;return new l.PointF2D(h-s,f-u)}getOverlap(m,o){return new l.PointF2D(m.RelativePosition.x+m.BorderMarginRight-(o.RelativePosition.x+o.BorderMarginLeft),m.RelativePosition.y+m.BorderMarginBottom-(o.RelativePosition.y+o.BorderMarginTop))}}},9834(St,y,p){var d=this&&this.__importDefault||function(f){return f&&f.__esModule?f:{default:f}};Object.defineProperty(y,"__esModule",{value:!0}),y.CanvasVexFlowBackend=void 0;var l=d(p(3206)).default.Flow;const m=p(1902),o=p(6014),s=p(624),h=p(1888);class u extends m.VexFlowBackend{constructor(r){super(),this.rules=r}getVexflowBackendType(){return l.Renderer.Backends.CANVAS}getOSMDBackendType(){return s.BackendType.Canvas}getCanvasSize(){var r;return(r=document.getElementById("osmdCanvasPage"+this.graphicalMusicPage.PageNumber))==null?void 0:r.offsetHeight}initialize(r,b){this.zoom=b,this.canvas=document.createElement("canvas"),this.graphicalMusicPage||(this.graphicalMusicPage=new h.GraphicalMusicPage(void 0),this.graphicalMusicPage.PageNumber=1),this.canvas.id="osmdCanvasVexFlowBackendCanvas"+this.graphicalMusicPage.PageNumber,this.inner=document.createElement("div"),this.inner.id="osmdCanvasPage"+this.graphicalMusicPage.PageNumber,this.inner.style.position="relative",this.canvas.style.zIndex="0",this.inner.appendChild(this.canvas),r.appendChild(this.inner),this.renderer=new l.Renderer(this.canvas,this.getVexflowBackendType()),this.ctx=this.renderer.getContext()}initializeHeadless(r=300,b=300){this.graphicalMusicPage||(this.graphicalMusicPage=new h.GraphicalMusicPage(void 0),this.graphicalMusicPage.PageNumber=1),this.canvas=document.createElement("canvas"),this.canvas.width=r,this.canvas.height=b,this.renderer=new l.Renderer(this.canvas,this.getVexflowBackendType()),this.ctx=this.renderer.getContext()}getContext(){return this.ctx}free(){this.canvas&&(this.canvas.width=0,this.canvas.height=0,this.canvas.remove(),delete this.canvas,this.canvas=null)}clear(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.rules.PageBackgroundColor&&(this.ctx.save(),this.ctx.setFillStyle(this.rules.PageBackgroundColor),this.zoom=1,this.ctx.fillRect(0,0,this.canvas.width/this.zoom,this.canvas.height/this.zoom),this.ctx.restore())}scale(r){this.ctx.scale(r,r)}translate(r,b){this.CanvasRenderingCtx.translate(r,b)}renderText(r,b,S,v,w,T,g=void 0,x=void 0){const P=this.CanvasRenderingCtx.font;this.CanvasRenderingCtx.save(),this.CanvasRenderingCtx.font=o.VexFlowConverter.font(r,b,S,this.rules,x),this.CanvasRenderingCtx.fillStyle=g,this.CanvasRenderingCtx.strokeStyle=g,this.CanvasRenderingCtx.fillText(v,T.x,T.y+w),this.CanvasRenderingCtx.restore(),this.CanvasRenderingCtx.font=P}renderRectangle(r,b,S,v=1){const w=this.CanvasRenderingCtx.fillStyle;this.CanvasRenderingCtx.fillStyle=S||o.VexFlowConverter.style(b),this.CanvasRenderingCtx.globalAlpha=v,this.ctx.fillRect(r.x,r.y,r.width,r.height),this.CanvasRenderingCtx.fillStyle=w,this.CanvasRenderingCtx.globalAlpha=1}renderLine(r,b,S="#FF0000FF",v=2,w){const T=this.CanvasRenderingCtx.strokeStyle;this.CanvasRenderingCtx.strokeStyle=S,this.CanvasRenderingCtx.beginPath(),this.CanvasRenderingCtx.moveTo(r.x,r.y),this.CanvasRenderingCtx.lineTo(b.x,b.y),this.CanvasRenderingCtx.stroke(),this.CanvasRenderingCtx.strokeStyle=T}renderCurve(r){this.ctx.beginPath(),this.ctx.moveTo(r[0].x,r[0].y),this.ctx.bezierCurveTo(r[1].x,r[1].y,r[2].x,r[2].y,r[3].x,r[3].y),this.ctx.lineTo(r[7].x,r[7].y),this.ctx.bezierCurveTo(r[6].x,r[6].y,r[5].x,r[5].y,r[4].x,r[4].y),this.ctx.lineTo(r[0].x,r[0].y),this.ctx.closePath(),this.ctx.fill()}renderPath(r,b=!0,S){let v;this.ctx.beginPath();for(const w of r)v?this.ctx.lineTo(w.x,w.y):(this.ctx.moveTo(w.x,w.y),v=w);this.ctx.closePath(),b?this.ctx.fill():this.ctx.stroke()}get CanvasRenderingCtx(){return this.ctx.vexFlowCanvasContext}}y.CanvasVexFlowBackend=u},9436(St,y,p){var d=this&&this.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(y,"__esModule",{value:!0}),y.SvgVexFlowBackend=void 0;var l=d(p(3206)).default.Flow;const m=p(1902),o=p(6014),s=p(2570),h=p(624),u=d(p(3065));class f extends m.VexFlowBackend{constructor(b){super(),this.rules=b}getVexflowBackendType(){return l.Renderer.Backends.SVG}getOSMDBackendType(){return h.BackendType.SVG}getCanvasSize(){var b;return(b=document.getElementById("osmdCanvasPage"+this.graphicalMusicPage.PageNumber))==null?void 0:b.offsetHeight}initialize(b,S){this.zoom=S,this.canvas=document.createElement("div"),this.canvas.id="osmdCanvasPage"+this.graphicalMusicPage.PageNumber,this.inner=this.canvas,this.inner.style.position="relative",this.canvas.style.zIndex="0",b.appendChild(this.inner),this.renderer=new l.Renderer(this.canvas,this.getVexflowBackendType()),this.ctx=this.renderer.getContext(),this.ctx.svg.id="osmdSvgPage"+this.graphicalMusicPage.PageNumber}getContext(){return this.ctx}getSvgElement(){return this.ctx.svg}removeNode(b){var v;const S=(v=this.ctx)==null?void 0:v.svg;if(!S)return!1;try{S.removeChild(b)}catch(w){return u.default.error(w),!1}return!0}free(){const b=this.ctx.svg;for(;b.lastChild;)b.removeChild(b.lastChild)}clear(){this.ctx&&(this.free(),this.rules.PageBackgroundColor&&(this.ctx.svg.style["background-color"]=this.rules.PageBackgroundColor))}scale(b){this.ctx.scale(b,b)}translate(b,S){}renderText(b,S,v,w,T,g,x=void 0,P=void 0){this.ctx.save();const _=this.ctx.openGroup("text");x&&(this.ctx.attributes.fill=x,this.ctx.attributes.stroke=x);let B=P;P&&P!=="default"||(B=this.rules.DefaultFontFamily),this.ctx.setFont(B,b,o.VexFlowConverter.fontStyle(S)),this.ctx.attributes["font-size"]=`${b}px`,this.ctx.state["font-size"]=`${b}px`;let k="normal",R="normal";switch(S){case s.FontStyles.Bold:k="bold";break;case s.FontStyles.Italic:R="italic";break;case s.FontStyles.BoldItalic:k="bold",R="italic";break;default:k="normal"}return this.ctx.attributes["font-weight"]=k,this.ctx.state["font-weight"]=k,this.ctx.attributes["font-style"]=R,this.ctx.state["font-style"]=R,this.ctx.fillText(w,g.x,g.y+T),this.ctx.closeGroup(),this.ctx.restore(),_}renderRectangle(b,S,v,w=1){this.ctx.save();const T=this.ctx.openGroup("rect");return this.ctx.attributes.fill=v||o.VexFlowConverter.style(S),this.ctx.attributes["fill-opacity"]=w,this.ctx.fillRect(b.x,b.y,b.width,b.height),this.ctx.restore(),this.ctx.attributes["fill-opacity"]=1,this.ctx.closeGroup(),T}renderLine(b,S,v="#FF0000FF",w=2,T){this.ctx.save();const g=this.ctx.openGroup("line",T);return this.ctx.beginPath(),this.ctx.moveTo(b.x,b.y),this.ctx.lineTo(S.x,S.y),this.ctx.attributes.stroke=v,this.ctx.lineWidth=w,this.ctx.stroke(),this.ctx.closeGroup(),this.ctx.restore(),g}renderCurve(b,S,v){let w;S&&v&&(w=`${v.getSVGId()}-slur`);const T=this.ctx.openGroup("curve",w);return this.ctx.beginPath(),this.ctx.moveTo(b[0].x,b[0].y),this.ctx.bezierCurveTo(b[1].x,b[1].y,b[2].x,b[2].y,b[3].x,b[3].y),this.ctx.lineTo(b[7].x,b[7].y),this.ctx.bezierCurveTo(b[6].x,b[6].y,b[5].x,b[5].y,b[4].x,b[4].y),this.ctx.lineTo(b[0].x,b[0].y),this.ctx.closePath(),this.ctx.fill(),this.ctx.closeGroup(),T}renderPath(b,S=!0,v){const w=this.ctx.openGroup("path",v);let T;this.ctx.beginPath();for(const g of b)T?this.ctx.lineTo(g.x,g.y):(this.ctx.moveTo(g.x,g.y),T=g);return this.ctx.closePath(),S?this.ctx.fill():this.ctx.stroke(),this.ctx.stroke(),this.ctx.closeGroup(),w}export(){const b=this.ctx.svg.cloneNode(!0),S=document.implementation.createDocumentType("svg","-//W3C//DTD SVG 1.1//EN","http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"),v=document.implementation.createDocument("http://www.w3.org/2000/svg","svg",S);v.replaceChild(b,v.documentElement);const w=new XMLSerializer().serializeToString(v),T=document.createElement("a");T.href="data:image/svg+xml; charset=utf8, "+encodeURIComponent(w.replace(/> +\r<`)),T.download="opensheetmusicdisplay_download.svg",T.innerHTML=window.location.href+"/download",document.body.appendChild(T)}}y.SvgVexFlowBackend=f},1902(St,y,p){var d=this&&this.__importDefault||function(m){return m&&m.__esModule?m:{default:m}};Object.defineProperty(y,"__esModule",{value:!0}),y.VexFlowBackend=y.VexFlowBackends=void 0;var l=d(p(3206)).default.Flow;y.VexFlowBackends=class{},y.VexFlowBackend=class{getInnerElement(){return this.inner}getCanvas(){return this.canvas}getRenderElement(){let m=this.canvas;return this.getVexflowBackendType()===l.Renderer.Backends.CANVAS&&(m=this.inner),m}getRenderer(){return this.renderer}removeAllChildrenFromContainer(m){for(;m.children.length!==0;)m.removeChild(m.children.item(0))}removeFromContainer(m){const o=this.getRenderElement();for(let s=0;s1e-4;){const $=W.RealValue;if($>=2)z.push("1/2"),W.Sub(new s.Fraction(2,1));else if($>=1)z.push("w"),W.Sub(new s.Fraction(1,1));else if($<1&&$>=.5){if(C&&$>.5)return["w"];z.push("h"),W.Sub(new s.Fraction(1,2))}else if($<.5&&$>=.25){if(C&&$>.25)return["h"];z.push("q"),W.Sub(new s.Fraction(1,4))}else if($<.25&&$>=.125){if(C&&$>.125)return["q"];z.push("8"),W.Sub(new s.Fraction(1,8))}else if($<.125&&$>=.0625){if(C&&$>.0625)return["8"];z.push("16"),W.Sub(new s.Fraction(1,16))}else if($<.0625&&$>=.03125){if(C&&$>.03125)return["16"];z.push("32"),W.Sub(new s.Fraction(1,32))}else if($<.03125&&$>=.015625){if(C&&$>.015625)return["32"];z.push("64"),W.Sub(new s.Fraction(1,64))}else{if(C)return["64"];z.push("128"),W.Sub(new s.Fraction(1,128))}}return z}static pitch(U,C,z,W=void 0,$=void 0){let N=$;$===void 0&&(N=3),C&&$===void 0&&(N=0,z.ClefType===m.ClefEnum.F&&(N=2),z.ClefType===m.ClefEnum.C&&(N=2));const Y=r.NoteEnum[U.FundamentalNote].toLowerCase(),tt=o.Pitch.accidentalVexflow(U.Accidental),H=U.Octave-z.OctaveOffset+N;let rt="";return W&&(rt=this.NoteHeadCode(W)),[Y+"n/"+H+rt,tt,z]}static restToNotePitch(U,C){let z=U.Octave;switch(C){case m.ClefEnum.C:case m.ClefEnum.F:z+=2;case m.ClefEnum.G:}return new o.Pitch(U.FundamentalNote,z,f.AccidentalEnum.NONE)}static NoteHeadCode(U){const C=U.Filled?"2":"1";switch(U.Shape){case _.NoteHeadShape.NORMAL:case _.NoteHeadShape.NONE:return"";case _.NoteHeadShape.DIAMOND:return"/D"+C;case _.NoteHeadShape.TRIANGLE:return"/T"+C;case _.NoteHeadShape.TRIANGLE_INVERTED:return"/TI";case _.NoteHeadShape.X:return"/X"+C;case _.NoteHeadShape.CIRCLEX:return"/X3";case _.NoteHeadShape.RECTANGLE:return"/R"+C;case _.NoteHeadShape.SQUARE:return"/S"+C;case _.NoteHeadShape.SLASH:default:return""}}static GhostNotes(U){const C=[],z=A.durations(U,!1);for(const W of z)C.push(new l.GhostNote({duration:W}));return C}static StaveNote(U){var J,q,et,it,dt,mt,yt,Et,Dt,Vt,Nt;U.sortForVexflow();const C=U.notes,z=U.parentStaffEntry.parentMeasure.parentSourceMeasure.Rules,W=C[0];let $=[];const N=[],Y=W.graphicalNoteLength,tt=W.sourceNote.NoteTuplet!==void 0;let H,rt=A.durations(Y,tt)[0];W.sourceNote.TypeLength!==void 0&&W.sourceNote.TypeLength!==Y&&W.sourceNote.TypeLength.RealValue!==0&&(rt=A.durations(W.sourceNote.TypeLength,tt)[0],W.numberOfDots=W.sourceNote.DotsXml);let ct,st,ot=W.numberOfDots,ht=!1,lt=0,O=!1;for(const It of C){if(ot=1&&Xt.length-1>=qt+1&&(Ut=(mt=(dt=Xt[qt-1])==null?void 0:dt.graphicalVoiceEntries[0])==null?void 0:mt.parentVoiceEntry,Kt=(Et=(yt=Xt[qt+1])==null?void 0:yt.graphicalVoiceEntries[0])==null?void 0:Et.parentVoiceEntry,Ut&&Kt)){const Qt=Ut.Notes[0],$t=Kt.Notes[0];if((Dt=Qt.NoteBeam)!=null&&Dt.Notes.includes($t)){const ie=Ut.Notes.last().Pitch,Jt=It.Clef();$=[A.pitch(A.restToNotePitch(ie.getTransposedPitch(-2),Jt.ClefType),!1,Jt)[0]]}}}}if((It.sourceNote.IsWholeMeasureRest||Y.RealValue===It.sourceNote.SourceMeasure.ActiveTimeSignature.RealValue)&&($=["d/5"],U.parentStaffEntry.parentMeasure.ParentStaff.StafflineCount===1&&($=["b/4"]),rt="w",ot=0,ht=!0,lt=z.WholeRestXShiftVexflow*B.unitInPixels),It.sourceNote.ParentStaff.Voices.length>1){const zt=It.parentVoiceEntry.parentStaffEntry.graphicalVoiceEntries,Xt=It.parentVoiceEntry.parentVoiceEntry.ParentVoice.VoiceId;let Ut,Kt;for(const qt of zt)for(const Qt of qt.notes){if(Qt===It||Qt.sourceNote.isRest()||!Qt.sourceNote.PrintObject)continue;const $t=Qt.parentVoiceEntry.parentVoiceEntry.WantedStemDirection,ie=Xt===1||Xt===5,Jt=ie?1:-1,oe=Qt.sourceNote.Pitch.getHalfTone();(!Ut||Jt===1&&oe>Ut||Jt===-1&&oe0){let qt=3;const Qt=It.Clef();switch(Qt.ClefType){case m.ClefEnum.F:qt=5;break;case m.ClefEnum.C:qt=4}ct=o.Pitch.fromHalftone(Ut),$=[A.pitch(ct,!0,Qt,void 0,qt)[0]]}}break}const Ct=It.vfpitch;$.push(Ct[0]),N.push(Ct[1]),H||(H=A.Clef(Ct[2]).type)}for(let It=0,Ct=ot;It0&&z.RenderLyrics&&z.LyricsUseXPaddingForLongLyrics){const Xt=U.parentStaffEntry.parentMeasure,Ut=[];for(let Qt=Xt.staffEntries.indexOf(U.parentStaffEntry)+1;Qt.25){Ct=!1;break}if(Qt.LyricsEntries.length>0)break;zt+=32*s.Fraction.minus($t,qt).RealValue,qt=$t}}if(z.RenderLyrics&&z.LyricsUseXPaddingForLongLyrics&&It.length>0&&Ct){let Xt=!1,Ut=0;for(const qt of C)if(qt.sourceNote.Length.RealValue<=.125){Xt=!0;break}let Kt=!1;for(const qt of It){const Qt=z.LyricsXPaddingWidthThreshold;let $t=qt.GraphicalLabel.PositionAndShape.Size.width;if(qt.hasDashFromLyricWord()&&($t+=.5),$t>Qt){Ut+=$t-Qt;const ie=U.parentStaffEntry,Jt=ie.parentMeasure.staffEntries,oe=Jt.indexOf(ie)===Jt.length-1,Ke=oe&&qt.hasDashFromLyricWord();oe&&(zt+=Ke?z.LyricsXPaddingReductionForLastNoteInMeasureCrossMeasureMidWord:z.LyricsXPaddingReductionForLastNoteInMeasure),Xt||(zt+=z.LyricsXPaddingReductionForLongNotes),!z.LyricsXPaddingForLastNoteInMeasure&&oe||$t>Qt+zt&&(Kt=!0,Ut-=zt);break}}Kt&&(st.paddingRight=10*z.LyricsXPaddingFactorForLongLyrics*Ut)}}const Q=U.notes[0].lineShift;if(Q!==0&&(st.getKeyProps()[0].line+=Q),C.length>1)for(let It=0;ItU.notes[Ct].staffLine=It),(z.LedgerLineWidth||z.LedgerLineStrokeStyle)&&(st.ledgerLineStyle||(st.ledgerLineStyle={}),z.LedgerLineWidth&&(st.ledgerLineStyle.lineWidth=z.LedgerLineWidth),z.LedgerLineStrokeStyle&&(st.ledgerLineStyle.strokeStyle=z.LedgerLineStrokeStyle)),z.ColoringEnabled){const It=z.DefaultColorStem;let Ct=U.parentVoiceEntry.StemColor;!Ct&&It&&(Ct=It);const zt={fillStyle:Ct,strokeStyle:Ct};Ct&&(st.setStemStyle(zt),st.flag&&z.ColorFlags&&st.setFlagStyle(zt))}if(st.x_shift=lt,U.parentVoiceEntry.IsGrace&&U.notes[0].sourceNote.NoteBeam&&(U.parentVoiceEntry.WantedStemDirection=U.notes[0].sourceNote.NoteBeam.Notes[0].ParentVoiceEntry.WantedStemDirection),U.parentVoiceEntry)switch(U.parentVoiceEntry.WantedStemDirection){case g.StemDirectionType.Up:st.setStemDirection(l.Stem.UP),U.parentVoiceEntry.StemDirection=g.StemDirectionType.Up;break;case g.StemDirectionType.Down:st.setStemDirection(l.Stem.DOWN),U.parentVoiceEntry.StemDirection=g.StemDirectionType.Down}for(let It=0,Ct=C.length;It0){const Xt=new l.Tremolo(zt);Xt.extra_stroke_scale=z.TremoloStrokeScale,Xt.y_spacing_scale=z.TremoloYSpacingScale,st.addModifier(It,Xt)}}if(j.Length.RealValue===.25&&j.Notehead&&j.Notehead.Filled===!1){const It=st.getKeyProps();for(let Ct=0;Ct");const tt=C.sourceNote.NoteSlurs;for(const H of tt)H.StartNote===C.sourceNote&&(H.PlacementXml===F.PlacementEnum.Above?$.setYShift(10*-z.SlurStartArticulationYOffsetOfArticulation):H.PlacementXml===F.PlacementEnum.Below&&$.setYShift(10*z.SlurStartArticulationYOffsetOfArticulation));$.render_options={...$.render_options,extra_left_px:0,extra_right_px:0},$.getWidth&&($.getWidth=function(){return 0});break}case g.ArticulationEnum.breathmark:$=new l.Articulation("abr"),W.placement===F.PlacementEnum.Above&&(N=l.Modifier.Position.ABOVE),$.breathMarkDistance=z.BreathMarkDistance;break;case g.ArticulationEnum.downbow:$=new l.Articulation("am"),W.placement===void 0&&(N=l.Modifier.Position.ABOVE,W.placement=F.PlacementEnum.Above);break;case g.ArticulationEnum.fermata:$=new l.Articulation("a@a"),N=l.Modifier.Position.ABOVE,W.placement=F.PlacementEnum.Above;break;case g.ArticulationEnum.marcatodown:$=new l.Articulation("a|");break;case g.ArticulationEnum.marcatoup:$=new l.Articulation("a^"),N=l.Modifier.Position.ABOVE;break;case g.ArticulationEnum.invertedfermata:{const tt=C.sourceNote.ParentVoiceEntry;if(tt!==C.sourceNote.ParentVoiceEntry.ParentSourceStaffEntry.VoiceEntries.last()){tt.Articulations=tt.Articulations.slice(tt.Articulations.indexOf(W)),tt.ParentSourceStaffEntry.VoiceEntries.last().Articulations.push(W);continue}$=new l.Articulation("a@u"),N=l.Modifier.Position.BELOW,W.placement=F.PlacementEnum.Below;break}case g.ArticulationEnum.lefthandpizzicato:$=new l.Articulation("a+");break;case g.ArticulationEnum.naturalharmonic:$=new l.Articulation("ah");break;case g.ArticulationEnum.snappizzicato:$=new l.Articulation("ao");break;case g.ArticulationEnum.staccatissimo:$=new l.Articulation("av");break;case g.ArticulationEnum.staccato:$=new l.Articulation("a.");break;case g.ArticulationEnum.tenuto:$=new l.Articulation("a-");break;case g.ArticulationEnum.upbow:$=new l.Articulation("a|"),W.placement===void 0&&(N=l.Modifier.Position.ABOVE,W.placement=F.PlacementEnum.Above);break;case g.ArticulationEnum.strongaccent:$=new l.Articulation("a^")}$&&($.setPosition(N),U.addModifier(0,$))}}static generateOrnaments(U,C){let z,W=l.Modifier.Position.ABOVE;switch(C.placement===F.PlacementEnum.Below&&(W=l.Modifier.Position.BELOW),C.GetOrnament){case P.OrnamentEnum.DelayedInvertedTurn:z=new l.Ornament("turn_inverted"),z.setDelayed(!0);break;case P.OrnamentEnum.DelayedTurn:z=new l.Ornament("turn"),z.setDelayed(!0);break;case P.OrnamentEnum.InvertedMordent:z=new l.Ornament("mordent"),z.setDelayed(!1);break;case P.OrnamentEnum.InvertedTurn:z=new l.Ornament("turn_inverted"),z.setDelayed(!1);break;case P.OrnamentEnum.Mordent:z=new l.Ornament("mordent_inverted"),z.setDelayed(!1);break;case P.OrnamentEnum.Trill:z=new l.Ornament("tr"),z.setDelayed(!1);break;case P.OrnamentEnum.Turn:z=new l.Ornament("turn"),z.setDelayed(!1);break;default:return void T.default.warn("unhandled OrnamentEnum type: "+C.GetOrnament)}z&&(C.AccidentalBelow!==f.AccidentalEnum.NONE&&z.setLowerAccidental(o.Pitch.accidentalVexflow(C.AccidentalBelow)),C.AccidentalAbove!==f.AccidentalEnum.NONE&&z.setUpperAccidental(o.Pitch.accidentalVexflow(C.AccidentalAbove)),z.setPosition(W),U.addModifier(0,z))}static StrokeTypeFromArpeggioType(U){switch(U){case k.ArpeggioType.ARPEGGIO_DIRECTIONLESS:return l.Stroke.Type.ARPEGGIO_DIRECTIONLESS;case k.ArpeggioType.BRUSH_DOWN:return l.Stroke.Type.BRUSH_UP;case k.ArpeggioType.BRUSH_UP:return l.Stroke.Type.BRUSH_DOWN;case k.ArpeggioType.RASQUEDO_DOWN:return l.Stroke.Type.RASQUEDO_UP;case k.ArpeggioType.RASQUEDO_UP:return l.Stroke.Type.RASQUEDO_DOWN;case k.ArpeggioType.ROLL_DOWN:return l.Stroke.Type.ROLL_UP;case k.ArpeggioType.ROLL_UP:return l.Stroke.Type.ROLL_DOWN;default:return l.Stroke.Type.ARPEGGIO_DIRECTIONLESS}}static CreateTabNote(U){var st;const C=[],z=U.notes.reverse(),W=[],$=U.notes[0].graphicalNoteLength,N=U.notes[0].sourceNote.NoteTuplet!==void 0;let Y=A.durations($,N)[0],tt=0;const H=U.parentStaffEntry.parentMeasure.parentSourceMeasure.Rules;let rt=!1;for(const ot of U.notes){const ht=ot.sourceNote;let lt={str:ht.StringNumberTab,fret:ht.FretNumber};ot.sourceNote instanceof R.TabNote||(T.default.info(`invalid tab note: ${ot.sourceNote.Pitch.ToString()} in measure ${U.parentStaffEntry.parentMeasure.MeasureNumber}, likely missing XML string+fret number.`),lt={str:1,fret:0}),H.TabUseXNoteheadShapeForTabNote&&((st=ot.sourceNote.Notehead)==null?void 0:st.Shape)===_.NoteHeadShape.X&&(lt.fret="x",rt=!0),C.push(lt),ht.BendArray&&ht.BendArray.forEach(function(O){let D;const j=O.bendalter-lt.fret;D=j>1?"Full":j===1?"1/2":"1/4",O.direction==="up"?W.push({type:l.Bend.UP,text:D,width:10}):W.push({type:l.Bend.DOWN,text:D,width:10})}),ttthis.vfnoteIndex&&r[this.vfnoteIndex]?f.note_heads[this.vfnoteIndex]:{line:0}}Clef(){return this.clef}getSVGId(){if(this.vfnote)return this.vfnote[0].getAttribute("id")}setVisible(u,f={}){var P,_;const r=f.applyToBeams??!0,b=f.applyToLedgerLines??!0,S=f.applyToNotehead??!0,v=f.applyToSlurs??!0,w=f.applyToStem??!0,T=f.applyToTies??!0,g="visibility",x=u?"visible":"hidden";if(S&&((P=this.getSVGGElement())==null||P.setAttribute(g,x)),w&&((_=this.getStemSVG())==null||_.setAttribute(g,x)),r)for(const B of this.getBeamSVGs())B==null||B.setAttribute(g,x);if(b)for(const B of this.getLedgerLineSVGs())B==null||B.setAttribute(g,x);if(T)for(const B of this.getTieSVGs())B==null||B.setAttribute(g,x);if(v)for(const B of this.getSlurSVGs())B==null||B.setAttribute(g,x)}getSVGGElement(){if(this.vfnote)return this.vfnote[0].getAttribute("el")}getStemSVG(){const u=document.getElementById("vf-"+this.getSVGId()+"-stem");return(u==null?void 0:u.children.length)>0?u.children[0]:u}getBeamSVGs(){const u=[];for(let f=0;;f++){const r=document.getElementById(`vf-${this.getSVGId()}-beam${f}`);if(!r)break;u.push(r)}return u}getLedgerLineSVGs(){const u=[],f=`vf-${this.getSVGId()}ledgers`,r=document.getElementById(f);if(!r)return[];for(const b of r.childNodes)u.push(b);return u}getTieSVGs(){const u=[],f=document.querySelectorAll(`[id='vf-${this.getSVGId()}-tie']`);for(const r of f)u.push(r);return u}getSlurSVGs(){const u=[],f=document.querySelectorAll(`[id='vf-${this.getSVGId()}-slur']`);for(const r of f)u.push(r);return u}getNoteheadSVGs(){var r;const u=this.getVFNoteSVG(),f=[];if((r=u==null?void 0:u.children)!=null&&r.length)for(const b of u.children)b.classList.contains("vf-notehead")&&f.push(b);return f}getFlagSVG(){var f;const u=this.getVFNoteSVG();if((f=u==null?void 0:u.children)!=null&&f.length){for(const r of u.children)if(r.classList.contains("vf-flag"))return r}}getVFNoteSVG(){if(this.parentVoiceEntry.parentStaffEntry.parentMeasure.isMultiRestMeasure())return this.parentVoiceEntry.parentStaffEntry.parentMeasure.multiRestElement;const u=this.getSVGGElement();if(u){for(const f of u.children)if(f.classList.contains("vf-note"))return f}}getModifierSVGs(){const u=this.getSVGGElement(),f=[];if(!(u!=null&&u.children))return f;if(u.children.length)for(const r of u.children)r.classList.contains("vf-modifiers")&&f.push(r);return f}setColor(u,f={}){var R,F;const r=f.applyToBeams??!1,b=f.applyToFlag??!0,S=f.applyToLedgerLines??!1,v=f.applyToLyrics??!1,w=f.applyToModifiers??!0,T=f.applyToNoteheads??!0,g=f.applyToSlurs??!1,x=f.applyToStem??!0,P=f.applyToTies??!1,_=f.applyToMultiRestMeasure??!0,B=f.applyToMultiRestMeasureNumber??!0,k=f.applyToMultiRestMeasureRestBar??!0;if(r){const A=this.getBeamSVGs();for(const G of A)for(const U of G.children)U.setAttribute("fill",u)}if(b){const A=this.getFlagSVG();if(A)for(const G of A.children)G.setAttribute("fill",u)}if(S){const A=this.getLedgerLineSVGs();for(const G of A)G.setAttribute("stroke",u)}if(v){const A=this.getLyricsSVGs();for(const G of A)for(const U of G.children)U.setAttribute("stroke",u),U.setAttribute("fill",u)}if(_&&this.parentVoiceEntry.parentStaffEntry.parentMeasure instanceof o.VexFlowMultiRestMeasure){const A=this.parentVoiceEntry.parentStaffEntry.parentMeasure.multiRestElementSVG;if((R=A==null?void 0:A.children)!=null&&R.length)for(const G of A.children)if((F=G.children)!=null&&F.length){if(B)for(const U of G.children)U.setAttribute("fill",u)}else k&&G.setAttribute("fill",u)}if(w){const A=this.getModifierSVGs();for(const G of A)for(const U of G.children)U.setAttribute("fill",u)}if(T){const A=this.getNoteheadSVGs();for(const G of A)for(const U of G.children)U.setAttribute("fill",u)}if(g){const A=this.getSlurSVGs();for(const G of A)for(const U of G.children)U.setAttribute("fill",u)}if(x){const A=this.getStemSVG();A&&A.setAttribute("stroke",u)}if(P){const A=this.getTieSVGs();for(const G of A)for(const U of G.children)U.setAttribute("fill",u)}}}y.VexFlowGraphicalNote=s},3753(St,y,p){var d=this&&this.__importDefault||function(g){return g&&g.__esModule?g:{default:g}};Object.defineProperty(y,"__esModule",{value:!0}),y.VexFlowGraphicalSymbolFactory=void 0;var l=d(p(3206)).default.Flow;const m=p(4332),o=p(5246),s=p(6670),h=p(437),u=p(9635),f=p(6659),r=p(4134),b=p(6014),S=p(6173),v=p(5866),w=p(3849),T=p(6362);y.VexFlowGraphicalSymbolFactory=class{createMusicSystem(g,x){return new m.VexFlowMusicSystem(g,x)}createStaffLine(g,x){return new v.VexFlowStaffLine(g,x)}createGraphicalMeasure(g,x,P=!1){return new o.VexFlowMeasure(x,g,void 0)}createMultiRestMeasure(g,x,P){return new w.VexFlowMultiRestMeasure(x,g,P)}createTabStaffMeasure(g,x){return new S.VexFlowTabMeasure(x,g)}createExtraGraphicalMeasure(g){const x=new o.VexFlowMeasure(g.ParentStaff,void 0,g);return x.IsExtraGraphicalMeasure=!0,x.ExtraGraphicalMeasurePreviousMeasure=g.Measures.last(),x}createStaffEntry(g,x){return new s.VexFlowStaffEntry(x,g,void 0)}createVoiceEntry(g,x){return new r.VexFlowVoiceEntry(g,x)}createNote(g,x,P,_=h.OctaveEnum.NONE,B,k=void 0){return new u.VexFlowGraphicalNote(g,x,P,_,B,k)}createGraceNote(g,x,P,_,B=h.OctaveEnum.NONE){return new u.VexFlowGraphicalNote(g,x,P,B,_)}addGraphicalAccidental(g,x){g.setAccidental(x)}addFermataAtTiedEndNote(g,x){}createInStaffClef(g,x){const P=g,_=b.VexFlowConverter.Clef(x,"small");P.vfClefBefore=new l.ClefNote(_.type,_.size,_.annotation)}createChordSymbols(g,x,P,_){const B=x.parentMeasure.parentSourceMeasure.Rules;let k=0;const R=B.ChordSymbolXSpacing;for(const F of g.ChordContainers){if(!F)continue;let A=x.PositionAndShape;x.graphicalVoiceEntries.length===1&&x.graphicalVoiceEntries[0].notes.length===1&&x.graphicalVoiceEntries[0].notes[0].sourceNote.isWholeRest()&&(A=x.parentMeasure.PositionAndShape,k+=x.parentMeasure.beginInstructionsWidth,k+=B.ChordSymbolWholeMeasureRestXOffset);const G=new f.GraphicalChordSymbolContainer(F,A,B.ChordSymbolTextHeight,P,_,B),U=G.GetChordSymbolContainer.Placement,C=G.GraphicalLabel;U===T.PlacementEnum.Below?C.PositionAndShape.RelativePosition.y=B.StaffHeight+B.ChordSymbolYOffset:C.PositionAndShape.RelativePosition.y-=B.ChordSymbolYOffset,C.setLabelPositionAndShapeBorders();let z=0;C.PositionAndShape.Size.width=0&&(z.parentVoiceEntry.PositionAndShape.RelativePosition.y=(C.StringNumberTab-1)*this.rules.TabStaffInterlineHeightForBboxes)}else for(const A of this.getVoicesWithinMeasure())for(const G of A.VoiceEntries)for(const U of G.Notes){if(U.isRest())continue;const C=this.rules.GNote(U);if(!(C!=null&&C.vfnote))return;const z=C.vfnote[0];let W=0;C.parentVoiceEntry.parentVoiceEntry.StemDirection===w.StemDirectionType.Up&&C.vfnote[0].getDuration()!=="w"?W+=3.5:W+=.5,W+=-C.notehead(z).line+C.parentVoiceEntry.notes.last().notehead().line,C.PositionAndShape.RelativePosition.y=W}}getVoicesWithinMeasure(){const A=[];for(const G of this.staffEntries)for(const U of G.graphicalVoiceEntries)A.indexOf(U.parentVoiceEntry.ParentVoice)===-1&&A.push(U.parentVoiceEntry.ParentVoice);return A}getGraphicalVoiceEntriesPerVoice(A){const G=[];for(const U of this.staffEntries)for(const C of U.graphicalVoiceEntries)C.parentVoiceEntry.ParentVoice===A&&G.push(C);return G}getRestFilledVexFlowStaveNotesPerVoice(A){let G,U=this.getGraphicalVoiceEntriesPerVoice(A);for(let W=0;W0){r.default.trace(`Ghost Found in between (measure ${this.MeasureNumber})`);const H=this.createGhostGves(tt);U.splice(W,0,...H),W+=H.length}}else{const tt=g.Fraction.minus(N,this.parentSourceMeasure.AbsoluteTimestamp);if(tt.RealValue>0){r.default.trace(`Ghost Found at start (measure ${this.MeasureNumber})`);const H=this.createGhostGves(tt);U.splice(0,0,...H),W+=H.length}}G=Y}const C=g.Fraction.plus(this.parentSourceMeasure.AbsoluteTimestamp,this.parentSourceMeasure.Duration),z=g.Fraction.minus(C,G);if(z.RealValue>0){r.default.trace(`Ghost Found at end (measure ${this.MeasureNumber})`);const W=this.createGhostGves(z);U=U.concat(W)}return U}createGhostGves(A){const G=h.VexFlowConverter.GhostNotes(A),U=[];for(const C of G){const z=new T.VexFlowVoiceEntry(void 0,void 0,this.rules);z.vfStaveNote=C,U.push(z)}return U}handleBeam(A,G){const U=A.sourceNote.ParentVoiceEntry.ParentVoice.VoiceId;let C,z=this.beams[U];z||(z=this.beams[U]=[]);for(const $ of z)$[0]===G&&(C=$);C||(C=[G,[]],z.push(C));const W=A.parentVoiceEntry;C[1].indexOf(W)<0&&C[1].push(W)}handleTuplet(A,G){const U=A.sourceNote.ParentVoiceEntry.ParentVoice.VoiceId;G=A.sourceNote.NoteTuplet;let C,z=this.tuplets[U];z||(z=this.tuplets[U]=[]);for(const $ of z)$[0]===G&&(C=$);C||(C=[G,[]],z.push(C));const W=A.parentVoiceEntry;C[1].indexOf(W)<0&&C[1].push(W)}finalizeBeams(){var G;if(this.vfbeams={},this.isTabMeasure&&!this.rules.TabBeamsRendered)return;const A=[];for(const U in this.beams)if(this.beams.hasOwnProperty(U)){let C=this.vfbeams[U];C||(C=this.vfbeams[U]=[]);for(const z of this.beams[U]){let W=!1;for(const st of z[0].Notes)if(st.Length.RealValue>=new g.Fraction(1,4).RealValue&&(!st.TypeLength||st.TypeLength.RealValue>.125)){W=!0;break}if(W){r.default.debug("Beam between note >= quarter, likely tremolo, currently unsupported. continuing.");continue}const $=[],N=z[0],Y=z[1];let tt=!0;for(const st of Y)st.parentVoiceEntry.ParentVoice===N.Notes[0].ParentVoiceEntry.ParentVoice&&(tt=st.parentVoiceEntry.WantedStemDirection===w.StemDirectionType.Undefined);let H,rt=!1;const ct=[];for(const st of Y){const ot=st.vfStaveNote;ot&&($.push(ot),A.push(ot)),st.parentVoiceEntry.IsGrace&&(rt=!0),st.parentVoiceEntry.StemColor&&this.rules.ColoringEnabled&&ct.push(st.parentVoiceEntry.StemColor)}if($.length>1){const st=new l.Beam($,tt);if(((G=N.SecondaryBreakIndices)==null?void 0:G.length)>0&&st.breakSecondaryAt(N.SecondaryBreakIndices),rt&&(st.render_options.beam_width=3,st.render_options.partial_beam_length=4),ct.length>=2&&this.rules.ColorBeams){H=ct[0];for(const ot of ct)if(ot!==H){H=void 0;break}st.setStyle({fillStyle:H,strokeStyle:H})}this.rules.FlatBeams&&(st.render_options.flat_beams=!0,st.render_options.flat_beam_offset=this.rules.FlatBeamOffset,st.render_options.flat_beam_offset_per_beam=this.rules.FlatBeamOffsetPerBeam),C.push(st)}else r.default.debug("Warning! Beam with no notes!")}}this.rules.AutoBeamNotes&&this.autoBeamNotes(A)}autoBeamNotes(A){if(!this.rules.AutoBeamTabs&&this.isTabMeasure)return;let G,U=60,C=[],z=[],W=[];this.autoTupletVfBeams=[];const $=[];this.autoVfBeams=[];let N=this.parentSourceMeasure.ActiveTimeSignature;N||(N=this.parentSourceMeasure.Duration);for(const H of this.staffEntries)for(const rt of H.graphicalVoiceEntries){const ct=rt.vfStaveNote,st=rt.notes[0],ot={vfStaveNote:ct,sourceNote:st.sourceNote},ht=H.relInMeasureTimestamp.isOnBeat(N),lt=z.length>=2,O=st.sourceNote.Length.RealValue-new g.Fraction(1,4).RealValue>-g.Fraction.FloatInaccuracyTolerance,D=rt.parentVoiceEntry.IsGrace||O||A.contains(ct);if(D||ht){if(lt){for(const Q of z)C.push(Q);$.push(C.slice()),C=[]}if(z=[],D)continue}const j=rt.notes[0].sourceNote.NoteTuplet;if(j){let Q=!1;for(const J of j.Notes){for(const q of J)if(q.NoteTypeXml>=B.NoteType.QUARTER||q.ParentVoiceEntry.IsGrace||q.isRest()&&!this.rules.AutoBeamOptions.beam_rests){Q=!0;break}if(Q)break}if(G){if(G!==j){if(W.length>1){const J=[];for(const it of W)J.push(it.vfStaveNote);const q=new l.Beam(J,!0);this.rules.FlatBeams&&(q.render_options.flat_beams=!0,q.render_options.flat_beam_offset=this.rules.FlatBeamOffset,q.render_options.flat_beam_offset_per_beam=this.rules.FlatBeamOffsetPerBeam),this.autoTupletVfBeams.push(q);const et=new u.Beam(U++);et.AutoGenerated=!0;for(const it of W)et.addNoteToBeam(it.sourceNote)}W=[],G=j}}else G=j;Q||W.push(ot);continue}G=void 0,z.push(ot)}if(W.length>=2){const H=[];for(const st of W)H.push(st.vfStaveNote);const rt=new l.Beam(H,!0);this.rules.FlatBeams&&(rt.render_options.flat_beams=!0,rt.render_options.flat_beam_offset=this.rules.FlatBeamOffset,rt.render_options.flat_beam_offset_per_beam=this.rules.FlatBeamOffsetPerBeam),this.autoTupletVfBeams.push(rt);const ct=new u.Beam(U++);ct.AutoGenerated=!0;for(const st of W)ct.addNoteToBeam(st.sourceNote)}if(z.length>=2){for(const H of z)C.push(H);$.push(C)}const Y=this.rules.AutoBeamOptions,tt={beam_middle_only:Y.beam_middle_rests_only,beam_rests:Y.beam_rests,maintain_stem_directions:Y.maintain_stem_directions};if(Y.groups&&Y.groups.length){const H=[];for(const rt of Y.groups)H.push(new l.Fraction(rt[0],rt[1]));tt.groups=H}for(const H of $){const rt=[];for(const st of H)rt.push(st.vfStaveNote);const ct=l.Beam.generateBeams(rt,tt);for(const st of ct)this.rules.FlatBeams&&(st.render_options.flat_beams=!0,st.render_options.flat_beam_offset=this.rules.FlatBeamOffset,st.render_options.flat_beam_offset_per_beam=this.rules.FlatBeamOffsetPerBeam),this.autoVfBeams.push(st)}}finalizeTuplets(){this.vftuplets={};for(const A in this.tuplets)if(this.tuplets.hasOwnProperty(A)){let G=this.vftuplets[A];G||(G=this.vftuplets[A]=[]);for(const U of this.tuplets[A]){const C=[],z=U[1];for(const W of z)C.push(W.vfStaveNote);if(C.length>1){const W=U[0],$=W.Notes[0][0].NormalNotes,N=W.shouldBeBracketed(this.rules.TupletsBracketedUseXMLValue,this.rules.TupletsBracketed,this.rules.TripletsBracketed,this.isTabMeasure,this.rules.TabTupletsBracketed);let Y=l.Tuplet.LOCATION_TOP;W.tupletLabelNumberPlacement===_.PlacementEnum.Below&&(Y=l.Tuplet.LOCATION_BOTTOM);let tt=0;if(this.isTabMeasure&&(tt=10*this.rules.TabTupletYOffsetBottom,Y===l.Tuplet.LOCATION_TOP)){tt=-10*this.rules.TabTupletYOffsetTop;const rt=W.Notes[0][0];rt!=null&&rt.hasTabEffects()&&(tt-=10*this.rules.TabTupletYOffsetEffects)}const H=new l.Tuplet(C,{bracketed:N,location:Y,notes_occupied:$,num_notes:W.TupletLabelNumber,ratioed:W.Ratioed,y_offset:tt});G.push(H)}else r.default.debug("Warning! Tuplet with no notes! Trying to ignore, but this is a serious problem.")}}}layoutStaffEntry(A){}graphicalMeasureCreatedCalculations(){let A,G=[];const U=[];for(const z of this.staffEntries){A=!1,G=[];for(const W of z.graphicalVoiceEntries)if(W.parentVoiceEntry.IsGrace)G.push(W),U.push(W),A||(A=W.parentVoiceEntry.GraceSlur);else if(W.vfStaveNote=h.VexFlowConverter.StaveNote(W),G.length>0){const $=[];for(let tt=0;tt0&&(H.GraceSlash=!1);const rt=h.VexFlowConverter.StaveNote(H);H.vfStaveNote=rt,$.push(rt)}const N=new l.GraceNoteGroup($,A);let Y=this.rules.GraceNoteGroupXMargin;$.length>1&&(Y/=3),N.spacing=10*Y,W.vfStaveNote.addModifier(0,N),G=[]}}if(G.length>0)for(const z of G)z.vfStaveNote=h.VexFlowConverter.StaveNote(z),z.parentVoiceEntry.GraceAfterMainNote=!0;this.finalizeBeams(),this.finalizeTuplets();const C=this.getVoicesWithinMeasure();if(this.rules.RenderFingerings)for(const z of this.staffEntries)z.setModifierXOffsets();for(const z of C){if(!z)continue;this.vfVoices[z.VoiceId]=new l.Voice({beat_value:this.parentSourceMeasure.ActiveTimeSignature.Denominator,num_beats:this.parentSourceMeasure.ActiveTimeSignature.Numerator,resolution:l.RESOLUTION}).setMode(l.Voice.Mode.SOFT);const W=this.getRestFilledVexFlowStaveNotesPerVoice(z);for(const $ of W){if($.parentVoiceEntry&&$.parentVoiceEntry.IsGrace&&!$.parentVoiceEntry.GraceAfterMainNote)continue;const N=$;if(N.vfStaveNote.getTicks().denominator===0&&(N.vfStaveNote.getTicks().denominator=1),$.notes.length>0&&$.notes[0].sourceNote&&$.notes[0].sourceNote.NoteTuplet){const tt=$.notes[0].graphicalNoteLength,H=N.vfStaveNote.getTicks();H.numerator=tt.Numerator*l.RESOLUTION,H.denominator=tt.Denominator,H.simplify()}const Y=N.parentStaffEntry;if(Y&&Y.vfClefBefore){if($.notes[0]&&!$.notes[0].sourceNote.PrintObject){const rt=this.rules.DefaultColorMusic||"#000000";Y.vfClefBefore.setStyle({fillStyle:rt,strokeStyle:rt})}const tt=new f([Y.vfClefBefore]),H=N.vfStaveNote;H&&typeof H.addModifier=="function"&&H.addModifier(0,tt)}$.notes.length!==0&&$.notes[0]&&$.notes[0].sourceNote.PrintObject?($.parentVoiceEntry&&this.rules.RenderFingerings&&(this.rules.FingeringPosition!==_.PlacementEnum.Left&&this.rules.FingeringPosition!==_.PlacementEnum.Right||this.createFingerings($),this.createStringNumber($)),this.createArpeggio($),this.vfVoices[z.VoiceId].addTickable(N.vfStaveNote)):this.vfVoices[z.VoiceId].addTickable(N.vfStaveNote)}}this.setStemDirectionFromVexFlow();for(const z of U)this.createFingerings(z),this.createStringNumber(z),this.createArpeggio(z);this.createArticulations(),this.createOrnaments()}createArpeggio(A){if(A.parentVoiceEntry&&A.parentVoiceEntry.Arpeggio){const G=A.parentVoiceEntry.Arpeggio;if(A.notes&&A.notes.length>1){const U=h.VexFlowConverter.StrokeTypeFromArpeggioType(G.type),C=new l.Stroke(U,{all_voices:this.rules.ArpeggiosGoAcrossVoices});this.rules.RenderArpeggios&&A.vfStaveNote.addStroke(0,C)}else r.default.debug(`[OSMD] arpeggio in measure ${this.MeasureNumber} could not be drawn. + voice entry had less than two notes, arpeggio is likely between voice entries, not currently supported in Vexflow.`)}}setStemDirectionFromVexFlow(){for(const A of this.staffEntries)for(const G of A.graphicalVoiceEntries)for(const U of G.notes){const C=U.vfnote;if(C&&C[0])switch(C[0].getStemDirection()){case l.Stem.UP:G.parentVoiceEntry.StemDirection=w.StemDirectionType.Up;break;case l.Stem.DOWN:G.parentVoiceEntry.StemDirection=w.StemDirectionType.Down}}}createArticulations(){for(let A=0,G=this.staffEntries.length;AU){let W=0;for(const $ of A.notes)if($.sourceNote.Fingering)W++;else{if(W>C.length-1)break;$.sourceNote.Fingering=C[W],W++}}let z=-1;for(const W of A.notes){const $=W.sourceNote.Fingering;if(!$){z++;continue}z++;let N=this.rules.FingeringPosition;this.rules.FingeringPositionGrace===_.PlacementEnum.AboveOrBelow&&(this.isUpperStaffOfInstrument()?N=_.PlacementEnum.Above:this.isLowerStaffOfInstrument()&&(N=_.PlacementEnum.Below)),$.placement!==_.PlacementEnum.NotYetDefined&&(N=$.placement);let Y,tt=this.rules.FingeringOffsetX;switch(N){default:case _.PlacementEnum.Left:Y=l.StaveModifier.Position.LEFT,tt-=W.baseFingeringXOffset*b.unitInPixels;break;case _.PlacementEnum.Right:Y=l.StaveModifier.Position.RIGHT,tt+=W.baseFingeringXOffset*b.unitInPixels;break;case _.PlacementEnum.Above:Y=l.StaveModifier.Position.ABOVE;break;case _.PlacementEnum.Below:Y=l.StaveModifier.Position.BELOW;break;case _.PlacementEnum.NotYetDefined:const rt=A.parentStaffEntry.sourceStaffEntry.ParentStaff;A.notes.length>1||A.parentStaffEntry.graphicalVoiceEntries.length>1?Y=l.StaveModifier.Position.LEFT:rt.idInMusicSheet===0?(Y=l.StaveModifier.Position.ABOVE,N=_.PlacementEnum.Above):(Y=l.StaveModifier.Position.BELOW,N=_.PlacementEnum.Below)}const H=new l.FretHandFinger($.value);if(H.setPosition(Y),H.setOffsetX(tt),N===_.PlacementEnum.Above||N===_.PlacementEnum.Below){const rt=N===_.PlacementEnum.Above?-1:1,ct=N===_.PlacementEnum.Above?z:U-1-z;if(this.rules.FingeringInsideStafflines&&U>1){const st=H.getWidth()/2,ot=2.5*U;H.setOffsetY(rt*(ct+ot)*st)}else if(!this.rules.FingeringInsideStafflines){const st=new l.StringNumber($.value);st.radius=0,st.setPosition(Y),st.setOffsetY(rt*ct*st.getWidth()*2/3),G.vfStaveNote.addModifier(z,st);continue}}G.vfStaveNote.addModifier(z,H)}}createStringNumber(A){if(!this.rules.RenderStringNumbersClassical)return;const G=A;A.notes.forEach((U,C)=>{const z=U.sourceNote.StringInstruction;if(z){let W=z.value;switch(W){case"1":W="I";break;case"2":W="II";break;case"3":W="III";break;case"4":W="IV";break;case"5":W="V";break;case"6":W="VI"}const $=new l.StringNumber(W);$.radius=0;const N=-this.rules.StringNumberOffsetY;A.notes.length>1||A.parentStaffEntry.graphicalVoiceEntries.length>1?($.setOffsetX(13*U.baseStringNumberXOffset),$.setPosition(l.Modifier.Position.RIGHT)):$.setPosition(l.Modifier.Position.ABOVE),$.setOffsetY(N),G.vfStaveNote.addModifier(C,$)}})}lineTo(A,G,U=0){const C=new l.StaveConnector(A.getVFStave(),this.stave);C.setType(G),U!==0&&C.setXShift(U),this.connectors.push(C)}getVFStave(){return this.stave}updateInstructionWidth(){let A=0,G=0;const U=this.stave.getModifiers();for(const C of U)C.getPosition()===R.BEGIN?A+=C.getWidth()+C.getPadding(void 0):C.getPosition()===R.END&&(G+=C.getWidth()+C.getPadding(void 0));this.beginInstructionsWidth=(A??0)/b.unitInPixels,this.endInstructionsWidth=(G??0)/b.unitInPixels}addStaveTie(A,G){this.vfTies.push(A),G.vfTie=A,G.Tie.TieDirection===_.PlacementEnum.Below&&A.setDirection(1)}}var R;y.VexFlowMeasure=k,(function(F){F[F.LEFT=1]="LEFT",F[F.RIGHT=2]="RIGHT",F[F.ABOVE=3]="ABOVE",F[F.BELOW=4]="BELOW",F[F.BEGIN=5]="BEGIN",F[F.END=6]="END"})(R||(y.StavePositionEnum=R={}))},3849(St,y,p){var d=this&&this.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(y,"__esModule",{value:!0}),y.VexFlowMultiRestMeasure=void 0;var l=d(p(3206)).default.Flow;const m=p(5246);class o extends m.VexFlowMeasure{constructor(h,u=void 0,f=void 0){super(h,u,f),this.minimumStaffEntriesWidth=-1,f?this.rules=f.ParentMusicSystem.rules:u&&(this.rules=u.Rules),this.resetLayout(),this.multiRestElement=new l.MultiMeasureRest(u.multipleRestMeasures,{})}draw(h){var f,r;const u=h.openGroup();u&&((f=u.classList)==null||f.add("vf-measure"),(r=u.classList)==null||r.add("multi"),u.id=`${this.MeasureNumber}`),this.stave.setContext(h).draw(),this.multiRestElementSVG=h.openGroup("multirest"),this.multiRestElement.setStave(this.stave),this.multiRestElement.setContext(h),this.multiRestElement.draw(),this.multiRestElement.id=`vf-multi${this.MeasureNumber}`,h.closeGroup(),h.closeGroup();for(const b of this.connectors)b.setContext(h).draw()}format(){var h,u;for(const f of this.staffEntries){const r=this.PositionAndShape.Size.width-this.beginInstructionsWidth;f.PositionAndShape.RelativePosition.x=this.PositionAndShape.Size.width/2+this.beginInstructionsWidth/3,f.PositionAndShape.RelativePosition.y=0;const b=(u=(h=f.graphicalVoiceEntries[0])==null?void 0:h.notes[0])==null?void 0:u.PositionAndShape;b.BorderLeft=-r/3,b.BorderRight=r/3,b.BorderTop=1,b.BorderBottom=3,f.PositionAndShape.calculateBoundingBox()}}getVoicesWithinMeasure(){return[]}getGraphicalVoiceEntriesPerVoice(h){return[]}getRestFilledVexFlowStaveNotesPerVoice(h){return[]}handleBeam(h,u){}handleTuplet(h,u){}finalizeBeams(){}finalizeTuplets(){}layoutStaffEntry(h){}graphicalMeasureCreatedCalculations(){}createArticulations(){}createOrnaments(){}createFingerings(h){}getVFStave(){return this.stave}}y.VexFlowMultiRestMeasure=o},806(St,y,p){var d=this&&this.__importDefault||function(ct){return ct&&ct.__esModule?ct:{default:ct}};Object.defineProperty(y,"__esModule",{value:!0}),y.VexFlowMusicSheetCalculator=void 0;const l=p(7921),m=p(3753),o=p(5748),s=p(1327),h=p(5054),u=p(2561),f=p(8215),r=p(7785),b=d(p(3206));var S=b.default.Flow;const v=d(p(3065)),w=p(9479),T=p(2395),g=p(7751),x=p(9310),P=p(7809),_=p(7533),B=p(4022),k=p(2400),R=p(9161),F=p(624),A=p(7506),G=p(5282),U=p(6014),C=p(4980),z=p(6659),W=p(6954),$=p(7109),N=p(512),Y=p(813),tt=p(1216),H=p(2907);class rt extends l.MusicSheetCalculator{constructor(st){var ot,ht,lt,O,D,j,Q,J;super(),this.beamsNeedUpdate=!1,this.previousLyricOverflowsByStaff=new Map,this.previousChordOverflowsByStaff=new Map,this.rules=st,l.MusicSheetCalculator.symbolFactory=new m.VexFlowGraphicalSymbolFactory,l.MusicSheetCalculator.TextMeasurer=new r.VexFlowTextMeasurer(this.rules),l.MusicSheetCalculator.stafflineNoteCalculator=new A.VexflowStafflineNoteCalculator(this.rules),((ot=this.rules.DefaultVexFlowNoteFont)==null?void 0:ot.toLowerCase())==="gonville"?b.default.Flow.DEFAULT_FONT_STACK=[(ht=b.default.Flow.Fonts)==null?void 0:ht.Gonville,(lt=b.default.Flow.Fonts)==null?void 0:lt.Bravura,(O=b.default.Flow.Fonts)==null?void 0:O.Custom]:((D=this.rules.DefaultVexFlowNoteFont)==null?void 0:D.toLowerCase())==="petaluma"&&(b.default.Flow.DEFAULT_FONT_STACK=[(j=b.default.Flow.Fonts)==null?void 0:j.Petaluma,(Q=b.default.Flow.Fonts)==null?void 0:Q.Gonville,(J=b.default.Flow.Fonts)==null?void 0:J.Bravura])}clearRecreatedObjects(){super.clearRecreatedObjects(),l.MusicSheetCalculator.stafflineNoteCalculator=new A.VexflowStafflineNoteCalculator(this.rules);for(const st of this.graphicalMusicSheet.MeasureList)for(const ot of st)ot==null||ot.clean()}formatMeasures(){for(const st of this.graphicalMusicSheet.MeasureList)if(st&&st[0]){st.find(ot=>ot==null?void 0:ot.isVisible()).format();for(const ot of st){for(const ht of ot.staffEntries)ht.calculateXPosition();ot.finalizeBeams()}}this.beamsNeedUpdate=!1}calculateMeasureXLayout(st){const ot=[];for(const J of st)J!=null&&J.isVisible()&&ot.push(J);if(ot.length===0)return 0;st=ot;const ht=[],lt=new S.Formatter({softmaxFactor:this.rules.SoftmaxFactorVexFlow});let O=st[0].staffEntries.length,D=1;for(const J of st){if(!J)continue;let q=0;for(const dt of J.staffEntries)q+=dt.setMaxAccidentals();J.parentSourceMeasure.ImplicitMeasure&&(O=Math.max(J.staffEntries.length,O),D=Math.max(J.staffEntries.length+q,D));const et=J.vfVoices,it=[];for(const dt in et)if(et.hasOwnProperty(dt)){const mt=et[dt];J.hasOnlyRests&&!mt.ticksUsed.equals(mt.totalTicks)&&(mt.ticksUsed=mt.totalTicks),it.push(mt),ht.push(mt)}it.length!==0?lt.joinVoices(it):v.default.debug("Found a measure with no voices. Continuing anyway.",et)}let j=12;const Q=st[0].parentSourceMeasure;if(ht.length>0){if(j=lt.preCalculateMinTotalWidth(ht)/w.unitInPixels*this.rules.VoiceSpacingMultiplierVexflow+this.rules.VoiceSpacingAddendVexflow+.3*O,Q==null?void 0:Q.ImplicitMeasure){j=Q.Duration.RealValue/Q.ActiveTimeSignature.RealValue*j;let et=0;const it=Q.measureListIndex;if(it>1)for(const dt of this.graphicalMusicSheet.MeasureList[it-1]){const mt=dt==null?void 0:dt.parentSourceMeasure.endingBarStyleEnum;if(mt===W.SystemLinesEnum.ThinBold||mt===W.SystemLinesEnum.DotsThinBold){et=this.rules.PickupMeasureRepetitionSpacing;break}}j+=et,O>1?j+=.3*D*1.5:it>1&&O===1&&(j+=this.rules.PickupMeasureSpacingSingleNoteAddend),j*=this.rules.PickupMeasureWidthMultiplier}l.MusicSheetCalculator.setMeasuresMinStaffEntriesWidth(st,j);const J=(et,it)=>{lt.formatToStave(ht,it.getVFStave())},q=(et,it)=>{lt.formatToStave(ht,it.getVFStave(),{align_rests:!0,context:void 0})};for(const et of st){if(this.rules.AlignRests===F.AlignRestOption.Never)et.formatVoices=J;else if(this.rules.AlignRests===F.AlignRestOption.Always)et.formatVoices=q;else if(this.rules.AlignRests===F.AlignRestOption.Auto){let it=!1;for(const dt of et.staffEntries){let mt=0,yt=0;for(const Et of dt.graphicalVoiceEntries)if(Et.parentVoiceEntry.IsGrace||Et&&Et.notes&&Et.notes[0]&&Et.notes[0].sourceNote&&Et.notes[0].sourceNote.PrintObject&&mt++,Et&&Et.notes&&Et.notes[0]&&Et.notes[0].sourceNote&&Et.notes[0].sourceNote.isRest()&&Et.notes[0].sourceNote.PrintObject&&yt++,mt>1&&yt>=1){it=!0;break}if(it)break}et.formatVoices=it?q:J}if(et===st[0]){const it=et;it.formatVoices(j*w.unitInPixels,it)}}}for(const J of st)if(J)for(const q of J.staffEntries)q.calculateXPosition();for(const J of st){if(!J)continue;const q=J.vfVoices,et=[];for(const it in q)q.hasOwnProperty(it)&&et.push(q[it]);et.length!==0?lt.joinVoices(et):v.default.debug("Found a measure with no voices. Continuing anyway.",q)}return j}calculateElongationFactor(st,ot,ht,lt,O,D,j,Q){let J=O,q=0,et=!1;for(const it of st){const dt=it.GraphicalLabel.Label.textAlignment;let mt=j,yt=Q;if(et=!1,it instanceof T.GraphicalLyricEntry&&it.ParentLyricWord){it.LyricsEntry.SyllableIndex>0&&(mt=this.rules.BetweenSyllableMinimumDistance,_.TextAlignment.IsCenterAligned(dt)&&(mt+=1));const $t=it.ParentLyricWord.GetLyricWord.Syllables;$t.length>1&&it.LyricsEntry.SyllableIndex<$t.length-1&&(et=!0,this.dashSpace===void 0&&(this.dashSpace=1.5),yt-=this.dashSpace)}const Et=it instanceof T.GraphicalLyricEntry?it.GraphicalLabel.PositionAndShape:it.PositionAndShape,Dt=Et.Size.width;let Vt,Nt,It,Ct,zt=ot.PositionAndShape.RelativePosition.x+Et.BorderLeft;it instanceof z.GraphicalChordSymbolContainer&&it.PositionAndShape.Parent.DataObject instanceof o.GraphicalMeasure&&(zt=this.rules.ChordSymbolWholeMeasureRestXOffset+Et.BorderMarginLeft+it.PositionAndShape.Parent.DataObject.beginInstructionsWidth),ht[q]!==void 0&&ht[q].extend,ht[q]&&(Nt=zt-ht[q].xPosition);const Xt=lt*O;_.TextAlignment.IsCenterAligned(dt)?(yt/=4,It=Xt-zt,Ct=Dt/2-yt,ht[q]&&(Vt=ht[q].labelWidth/2+Dt/2+mt)):_.TextAlignment.IsLeft(dt)&&(It=Xt-zt,Ct=Dt-yt,ht[q]&&(Vt=ht[q].labelWidth+mt));let Ut,Kt=1;Ut=It>0?Ct/It:(zt+Ct)/lt;let qt=1;it instanceof T.GraphicalLyricEntry&&it.LyricsEntry?ht[q]&&(qt=Vt/Nt,ht[q].sourceNoteDuration.Denominator>4&&(qt*=1.1)):ht[q]&&(qt=Vt/Nt),Kt=Math.max(Ut,qt),J=Math.max(J,Kt);let Qt=Math.max(Vt-Nt||0,0);ht[q]&&(Qt+=ht[q].cumulativeOverlap),ht[q]={cumulativeOverlap:Qt,extend:it instanceof T.GraphicalLyricEntry&&it.LyricsEntry.extend,labelWidth:Dt,measureNumber:D,needsDashSpaceAtEnd:et,sourceNoteDuration:it instanceof T.GraphicalLyricEntry&&it.LyricsEntry&&it.LyricsEntry.Parent.Notes[0].Length,text:it instanceof T.GraphicalLyricEntry?it.LyricsEntry.Text:it.GraphicalLabel.Label.text,xPosition:zt},q++}return J}calculateElongationFactorFromStaffEntries(st,ot,ht,lt,O,D){let j=ht;const Q={},J={};if(O)for(let q=0;q0&&(Q[q]={cumulativeOverlap:0,extend:!1,labelWidth:et,measureNumber:lt-1,sourceNoteDuration:new u.Fraction(1,4),text:"",xPosition:0})}if(D)for(let q=0;q0&&(J[q]={cumulativeOverlap:0,extend:!1,labelWidth:et,measureNumber:lt-1,sourceNoteDuration:new u.Fraction(1,4),text:"",xPosition:0})}for(const q of st)q.LyricsEntries.length>0&&this.rules.RenderLyrics&&(j=this.calculateElongationFactor(q.LyricsEntries,q,Q,ot,j,lt,this.rules.HorizontalBetweenLyricsDistance,this.rules.LyricOverlapAllowedIntoNextMeasure)),q.graphicalChordContainers.length>0&&this.rules.RenderChordSymbols&&(j=this.calculateElongationFactor(q.graphicalChordContainers,q,J,ot,j,lt,this.rules.ChordSymbolXSpacing,this.rules.ChordOverlapAllowedIntoNextMeasure));return{factor:j,lastLyricEntryDict:Q,lastChordEntryDict:J}}calculateMeasureWidthFromStaffEntries(st,ot){let ht=1;const lt=[],O=new Set;for(const j of st){if(!j||j.staffEntries.length===0||!j.isVisible())continue;const Q=j.ParentStaff;O.add(Q);const J=this.previousLyricOverflowsByStaff.get(Q),q=this.previousChordOverflowsByStaff.get(Q),et=this.calculateElongationFactorFromStaffEntries(j.staffEntries,ot,ht,j.MeasureNumber,J,q);ht=et.factor,lt.push({staff:Q,lastLyricEntryDict:et.lastLyricEntryDict,lastChordEntryDict:et.lastChordEntryDict})}ht=Math.min(ht,this.rules.MaximumLyricsElongationFactor);const D=ot*ht;for(const j of lt){const Q=this.computeContainerOverflows(j.lastLyricEntryDict,D),J=this.computeContainerOverflows(j.lastChordEntryDict,D);this.previousLyricOverflowsByStaff.set(j.staff,Q),this.previousChordOverflowsByStaff.set(j.staff,J)}for(const j of Array.from(this.previousLyricOverflowsByStaff.keys()))O.has(j)||this.previousLyricOverflowsByStaff.delete(j);for(const j of Array.from(this.previousChordOverflowsByStaff.keys()))O.has(j)||this.previousChordOverflowsByStaff.delete(j);return D}computeContainerOverflows(st,ot){const ht=[];for(const lt of Object.keys(st)){const O=Number(lt),D=st[O];if(!D)continue;const j=D.xPosition+D.labelWidth;let Q=Math.max(0,j-ot);D.needsDashSpaceAtEnd&&this.dashSpace!==void 0&&(Q+=this.dashSpace),ht[O]=Q}return ht}createGraphicalTie(st,ot,ht,lt,O){return new h.GraphicalTie(st,lt,O)}updateStaffLineBorders(st){st.SkyBottomLineCalculator.updateStaffLineBorders()}graphicalMeasureCreatedCalculations(st){st.rules=this.rules,st.graphicalMeasureCreatedCalculations()}layoutVoiceEntry(st,ot,ht,lt){for(let O=0;O=2&&(D=lt.vfnote[0],Q=lt.vfnote[1]);let J=0;if(O&&O.vfnote&&O.vfnote.length>=2&&(j=O.vfnote[0],J=O.vfnote[1]),ot){if(D){const q=new S.StaveTie({first_indices:[Q],first_note:D});lt.parentVoiceEntry.parentStaffEntry.parentMeasure.addStaveTie(q,st)}if(j){const q=new S.StaveTie({last_indices:[J],last_note:j});O.parentVoiceEntry.parentStaffEntry.parentMeasure.addStaveTie(q,st)}}else if(D||j){let q;if(ht)if(st.Tie.Type==="S"){const et=st.StartNote.sourceNote,it=st.EndNote.sourceNote;let dt=1;et.FretNumber>it.FretNumber&&(dt=-1),q=new S.TabSlide({first_indices:[Q],first_note:D,last_indices:[J],last_note:j},dt)}else q=new S.TabTie({first_indices:[Q],first_note:D,last_indices:[J],last_note:j},st.Tie.Type);else{q=new S.StaveTie({first_indices:[Q],first_note:D,last_indices:[J],last_note:j});const et=st.Tie.getTieDirection(lt.sourceNote);et===C.PlacementEnum.Below?q.setDirection(1):et===C.PlacementEnum.Above&&q.setDirection(-1)}O.parentVoiceEntry.parentStaffEntry.parentMeasure.addStaveTie(q,st)}}calculateDynamicExpressionsForMultiExpression(st,ot,ht){if(otthis.rules.MaxMeasureToDrawIndex)return;const lt=st.AbsoluteTimestamp,O=this.graphicalMusicSheet.MeasureList[ot],D=O[ht].ParentStaffLine,j=O[ht],Q=st.StartingContinuousDynamic,J=Q!==void 0&&!Q.IsStartOfSoftAccent,q=this.getRelativePositionInStaffLineFromTimestamp(lt,ht,D,D==null?void 0:D.isPartOfMultiStaffInstrument(),void 0,J);if(q.x<=0&&(q.x=j.beginInstructionsWidth+this.rules.RhythmRightMargin),st.InstantaneousDynamic){const et=new P.VexFlowInstantaneousDynamicExpression(st.InstantaneousDynamic,D,j);this.calculateGraphicalInstantaneousDynamicExpression(et,q,lt),this.dynamicExpressionMap.set(lt.RealValue,et.PositionAndShape)}if(Q){const et=new k.VexFlowContinuousDynamicExpression(Q,D,j.parentSourceMeasure);if(et.StartMeasure=j,et.IsSoftAccent=st.StartingContinuousDynamic.IsStartOfSoftAccent,!et.IsVerbal&&Q.EndMultiExpression)try{this.calculateGraphicalContinuousDynamic(et,q),et.updateSkyBottomLine()}catch{}else et.IsVerbal?this.calculateGraphicalVerbalContinuousDynamic(et,q):v.default.warn("This continuous dynamic is not covered. measure"+st.SourceMeasureParent.MeasureNumber)}}createMetronomeMark(st){var et,it;const ot=st.ParentMultiTempoExpression.SourceMeasureParent.MeasureNumber,ht=Math.max(st.StaffNumber-1,0),lt=this.graphicalMusicSheet.findGraphicalMeasureByMeasureNumber(ot,ht),O=lt===this.graphicalMusicSheet.MeasureList[0][0];if(lt.hasMetronomeMark)return;const D=lt.getVFStave();let j=this.rules.MetronomeMarkYShift,Q=!1;for(const dt of st.parentMeasure.TempoExpressions){const mt=((et=dt.InstantaneousTempo)==null?void 0:et.TempoType)===R.TempoType.metronomeMark;if(dt.getPlacementOfFirstEntry()===C.PlacementEnum.Above&&!mt){Q=!0;break}}Q&&(j-=1.4);const J=(it=this.graphicalMusicSheet.MeasureList[0][0].ParentStaffLine)==null?void 0:it.SkyLine;if(st.metronomeNoteGroupLeft&&st.metronomeNoteGroupRight){const dt=this.buildNoteEquationForVexFlow(st.metronomeNoteGroupLeft,st.metronomeNoteGroupRight);D.setTempo({noteEquation:dt},j*w.unitInPixels)}else{let dt="q";if(st.beatUnit){const mt=G.NoteTypeHandler.getNoteDurationFromType(st.beatUnit);dt=U.VexFlowConverter.durations(mt,!1)[0]}D.setTempo({bpm:st.TempoInBpm,dots:st.dotted,duration:dt},j*w.unitInPixels)}const q=O?this.rules.MetronomeMarkXShift*w.unitInPixels:0;D.getModifiers()[D.getModifiers().length-1].setShiftX(q),lt.hasMetronomeMark=!0,J&&(J[0]=Math.min(J[0],-4.5+j))}buildNoteEquationForVexFlow(st,ot){const ht=lt=>{const O={notes:lt.notes.map(D=>{const j=G.NoteTypeHandler.getNoteDurationFromType(D.type);return{duration:U.VexFlowConverter.durations(j,!1)[0],dots:D.dots,beam:D.beam}})};return lt.tuplet&&(O.tuplet={actualNotes:lt.tuplet.actualNotes,normalNotes:lt.tuplet.normalNotes,bracket:lt.tuplet.bracket,showNumber:lt.tuplet.showNumber}),O};return{left:ht(st),right:ht(ot)}}calculateRehearsalMark(st){const ot=st.rehearsalExpression;if(!ot)return;const ht=this.graphicalMusicSheet.MeasureList[0][0].MeasureNumber,lt=Math.max(st.MeasureNumber-ht,0);for(const O of this.graphicalMusicSheet.MeasureList[lt]){const D=O==null?void 0:O.getVFStave();if(!D||!O.isVisible())continue;let j=-this.rules.RehearsalMarkYOffsetDefault-this.rules.RehearsalMarkYOffset;O.parentSourceMeasure.isReducedToMultiRest&&(j+=this.rules.RehearsalMarkYOffsetAddedForRehearsalMarks);let Q=this.rules.RehearsalMarkXOffsetDefault+this.rules.RehearsalMarkXOffset;st.IsSystemStartMeasure&&(Q+=this.rules.RehearsalMarkXOffsetSystemStartMeasure);const J=this.rules.RehearsalMarkFontSize;return void D.setSection(ot.label,j,Q,J)}}calculateSingleOctaveShift(st,ot,ht,lt){var mt,yt;const O=ot.OctaveShiftStart,D=O.ParentStartMultiExpression.Timestamp,j=(mt=O.ParentEndMultiExpression)==null?void 0:mt.Timestamp,Q=this.rules.MinMeasureToDrawIndex,J=this.rules.MaxMeasureToDrawIndex;let q,et,it=this.graphicalMusicSheet.MeasureList[ht][lt].ParentStaffLine;if(it||(it=this.graphicalMusicSheet.MeasureList[Q][lt].ParentStaffLine),q=O.ParentEndMultiExpression?this.graphicalMusicSheet.getGraphicalMeasureFromSourceMeasureAndIndex(O.ParentEndMultiExpression.SourceMeasureParent,lt):this.graphicalMusicSheet.getLastGraphicalMeasureFromIndex(lt,!0),q.MeasureNumber>J+1&&(q=this.graphicalMusicSheet.getLastGraphicalMeasureFromIndex(lt,!0)),et=O.ParentStartMultiExpression?this.graphicalMusicSheet.getGraphicalMeasureFromSourceMeasureAndIndex(O.ParentStartMultiExpression.SourceMeasureParent,lt):this.graphicalMusicSheet.MeasureList[Q][lt],et.MeasureNumberJ||q.parentSourceMeasure.measureListIndexJ)return;let dt=q.ParentStaffLine;if(dt||(dt=it),q&&it&&dt){const Et=new x.VexFlowOctaveShift(O,it.PositionAndShape);if(!Et.startNote){let Nt;for(const It of et.staffEntries)if(It){Nt=It;break}if(!Nt||(Et.setStartNote(Nt),!Et.startNote))return}if(!Et.endNote){let Nt;for(let It=q.staffEntries.length-1;It>=0;It++)if(q.staffEntries[It]){Nt=q.staffEntries[It];break}if(!Nt)return void(Et.graphicalEndAtMeasureEnd=!0);if(Et.setEndNote(Nt),!Et.endNote)return}let Dt=et.findGraphicalStaffEntryFromTimestamp(D);Dt||(Dt=et.staffEntries[0]);let Vt=q.findGraphicalStaffEntryFromTimestamp(j);if(!Vt)for(let Nt=q.staffEntries.length-1;Nt>=0;Nt--){const It=q.staffEntries[Nt];if((yt=It.relInMeasureTimestamp)!=null&&yt.lte(j)){Vt=It;break}}if(Vt||(Vt=q.staffEntries[q.staffEntries.length-1]),Et.setStartNote(Dt),dt!==it){Et.endsOnDifferentStaffLine=!0;let Nt=this.findLastStafflineMeasure(it);Nt===void 0&&(Nt=q);const It=Nt.staffEntries[Nt.staffEntries.length-1];if(Et.setEndNote(It),Et.graphicalEndAtMeasureEnd=!0,Et.endMeasure=Nt,dt.ParentMusicSystem.Id-it.ParentMusicSystem.Id>0)for(let Ct=it.ParentMusicSystem.Id;Ct0?O.endVoiceEntryIndex:-1;qt.setEndNote(ie,oe),Ut.OctaveShifts.push(qt),this.calculateOctaveShiftSkyBottomLine($t,ie,qt,Ut)}this.calculateOctaveShiftSkyBottomLine(Dt,It,Et,it)}else Et.setEndNote(Vt,O.endVoiceEntryIndex>0?O.endVoiceEntryIndex:-1),this.calculateOctaveShiftSkyBottomLine(Dt,Vt,Et,it);it.OctaveShifts.push(Et)}else v.default.warn("End measure or staffLines for octave shift are undefined! This should not happen!")}findLastStafflineMeasure(st){for(let ot=st.Measures.length-1;ot>=0;ot--){const ht=st.Measures[ot];if(ht.staffEntries.length>0)return ht}}calculateSinglePedal(st,ot,ht,lt){var mt;const O=ot.PedalStart,D=O.ParentStartMultiExpression.Timestamp,j=(mt=O.ParentEndMultiExpression)==null?void 0:mt.Timestamp,Q=this.rules.MinMeasureToDrawIndex,J=this.rules.MaxMeasureToDrawIndex;let q,et,it=this.graphicalMusicSheet.MeasureList[ht][lt].ParentStaffLine;if(it||(it=this.graphicalMusicSheet.MeasureList[Q][lt].ParentStaffLine),q=O.ParentEndMultiExpression?this.graphicalMusicSheet.getGraphicalMeasureFromSourceMeasureAndIndex(O.ParentEndMultiExpression.SourceMeasureParent,lt):this.graphicalMusicSheet.getLastGraphicalMeasureFromIndex(lt,!0),q.MeasureNumber>J+1&&(q=this.graphicalMusicSheet.getLastGraphicalMeasureFromIndex(lt,!0)),O.ParentEndMultiExpression?et=this.graphicalMusicSheet.getGraphicalMeasureFromSourceMeasureAndIndex(O.ParentStartMultiExpression.SourceMeasureParent,lt):(et=this.graphicalMusicSheet.getGraphicalMeasureFromSourceMeasureAndIndex(O.ParentStartMultiExpression.SourceMeasureParent,lt),et||(et=this.graphicalMusicSheet.MeasureList[Q][lt])),et.MeasureNumberJ||q.parentSourceMeasure.measureListIndexJ)return;let dt=q.ParentStaffLine;if(dt||(dt=it),q&&it&&dt){let yt=!1;it!==dt&&(yt=!0);const Et=new $.VexFlowPedal(O,it.PositionAndShape,!1,yt);Et.setEndsStave(q,j);let Dt=et.findGraphicalStaffEntryFromTimestamp(D);Dt||(Dt=et.staffEntries[0]);let Vt=q.findGraphicalStaffEntryFromTimestamp(j);if(Vt||(Vt=q.staffEntries[q.staffEntries.length-1]),!Et.setStartNote(Dt))return;if(Et.setBeginsStave(Et.startNote.isRest(),D),dt!==it)if(Et.pedalSymbol===N.MusicSymbol.PEDAL_SYMBOL){Et.setEndNote(Vt),Et.setEndMeasure(q),Et.ReleaseText=" ",Et.CalculateBoundingBox(),this.calculatePedalSkyBottomLine(Et.startVfVoiceEntry,Et.endVfVoiceEntry,Et,it);const Nt=dt.Measures[0],It=new $.VexFlowPedal(O,Nt.PositionAndShape);Et.setEndsStave(q,j);const Ct=Nt.staffEntries[0];if(!It.setStartNote(Ct))return;It.setEndNote(Vt),It.setEndMeasure(q),Et.setEndMeasure(q),dt.Pedals.push(It),It.CalculateBoundingBox(),It.DepressText=" ",this.calculatePedalSkyBottomLine(It.startVfVoiceEntry,It.endVfVoiceEntry,It,dt)}else{let Nt=this.findLastStafflineMeasure(it);Nt===void 0&&(Nt=q);const It=Nt.staffEntries[Nt.staffEntries.length-1];Et.setEndNote(It),Et.setEndMeasure(q),Et.ChangeEnd=!1;const Ct=dt.ParentMusicSystem.Id-it.ParentMusicSystem.Id;if(Ct>0){let zt=1;for(let Xt=it.ParentMusicSystem.Id;XtJ+1&&(q=this.graphicalMusicSheet.getLastGraphicalMeasureFromIndex(lt,!0)),et=O.ParentEndMultiExpression?this.graphicalMusicSheet.getGraphicalMeasureFromSourceMeasureAndIndex(O.ParentStartMultiExpression.SourceMeasureParent,lt):this.graphicalMusicSheet.MeasureList[Q][lt],et.MeasureNumberJ||q.parentSourceMeasure.measureListIndexJ)return;let dt=q.ParentStaffLine;if(dt||(dt=it),q&&it&&dt){const yt=new H.VexFlowVibratoBracket(O,it.PositionAndShape,et.ParentStaff.isTab);let Et=et.findGraphicalStaffEntryFromTimestamp(D);Et||(Et=et.staffEntries[0]);let Dt=q.findGraphicalStaffEntryFromTimestamp(j);if(Dt||(Dt=q.staffEntries[q.staffEntries.length-1]),yt.setStartNote(Et),dt!==it){let Vt=it.Measures[it.Measures.length-1];Vt===void 0&&(Vt=q);const Nt=Vt.staffEntries[Vt.staffEntries.length-1];if(Nt&&yt.setEndNote(Nt),dt.ParentMusicSystem.Id-it.ParentMusicSystem.Id>0)for(let It=it.ParentMusicSystem.Id;Itq){const Nt=q;q=et,et=Nt}lt.SkyBottomLineCalculator.updateBottomLineInRange(et,q,it+Dt)}for(const Dt of lt.Pedals){const Vt=Dt,Nt=Vt.getPedalMarking();if(it>Nt.line+3+(lt.StaffLines.length-1)){const It=Nt.render_options.text_margin_right/10;let Ct,zt=Vt.startVfVoiceEntry.PositionAndShape.AbsolutePosition.x-It;Vt.setLine(it-3-(lt.StaffLines.length-1));let Xt=(mt=Vt.endVfVoiceEntry)==null?void 0:mt.PositionAndShape;if(Xt||(Xt=Vt.endMeasure.PositionAndShape),Vt.EndSymbolPositionAndShape){const Ut=j.render_options.glyph_point_size/20;Ct=zt+3.4;const Kt=Xt.AbsolutePosition.x-It,qt=Kt+1.5;lt.SkyBottomLineCalculator.updateBottomLineInRange(zt,Ct,it+Ut),lt.SkyBottomLineCalculator.updateBottomLineInRange(Kt,qt,it+Ut)}else{const Ut=Nt.render_options.bracket_height/10;if(Nt.EndsStave)Ct=Xt.AbsolutePosition.x+Xt.Size.width-It;else switch(j.style){case D.BRACKET_OPEN_END:case D.BRACKET_OPEN_BOTH:case D.MIXED_OPEN_END:Ct=Xt.AbsolutePosition.x+Xt.BorderRight-It;break;default:Ct=Xt.AbsolutePosition.x+Xt.BorderLeft-It}const Kt=(Et=(yt=Vt.endVfVoiceEntry)==null?void 0:yt.parentStaffEntry)==null?void 0:Et.vfClefBefore;if(Kt&&(Ct+=Kt.getWidth()/10),zt>Ct){const qt=zt;zt=Ct,Ct=qt}lt.SkyBottomLineCalculator.updateBottomLineInRange(zt,Ct,it+Ut)}}}}calculateOctaveShiftSkyBottomLine(st,ot,ht,lt){if(!ot)return void v.default.warn("octaveshift: no endStaffEntry");let O=ot.PositionAndShape;ht.graphicalEndAtMeasureEnd&&(O=ot.parentMeasure.PositionAndShape);let D=st.PositionAndShape.Size.width,j=O.Size.width;st.hasOnlyRests()?D=-D:D/=2,ht.graphicalEndAtMeasureEnd||(ot.hasOnlyRests()?j*=2:j/=2,st===ot&&(j*=2));let Q=st.PositionAndShape.AbsolutePosition.x-D,J=O.AbsolutePosition.x+j;if(Q>J){const it=Q;Q=J,J=it}ht.PositionAndShape.Size.width=J-Q;const q=ht.getTextBracket(),et=q.font.size/10;if(q.position===S.TextBracket.Positions.TOP){const it=Math.ceil(lt.SkyBottomLineCalculator.getSkyLineMinInRange(Q,J));if(it===1/0)return;q.start.getStave().options.top_text_position=Math.abs(it),lt.SkyBottomLineCalculator.updateSkyLineInRange(Q,J,it-2*et)}else{const it=lt.SkyBottomLineCalculator.getBottomLineMaxInRange(Q,J);if(it===1/0)return;q.start.getStave().options.bottom_text_position=it,lt.SkyBottomLineCalculator.updateBottomLineInRange(Q,J,it+1.5*et)}}calculateWordRepetitionInstruction(st,ot){let ht;const lt=this.graphicalMusicSheet.MeasureList[ot];for(let O=0,D=lt.length;Oht.StaffLines));let ot=0;for(const ht of st)for(const lt of ht.Measures)lt&&ot++;if(this.rules.AlwaysSetPreferredSkyBottomLineBackendAutomatically&&this.rules.setPreferredSkyBottomLineBackendAutomatically(ot),ot>=this.rules.SkyBottomLineBatchMinMeasures)new s.SkyBottomLineBatchCalculator(st,this.rules.PreferredSkyBottomLineBatchCalculatorBackend).calculateLines();else for(const ht of st)ht.SkyBottomLineCalculator.calculateLines()}calculateExpressionAlignements(){for(const st of this.musicSystems)for(const ot of st.StaffLines)try{ot.AlignmentManager.alignDynamicExpressions(),ot.AbstractExpressions.forEach(ht=>{ht.updateSkyBottomLine()})}catch{}}handleTiedGraphicalNote(st,ot,ht,lt,O,D,j,Q){}handleBeam(st,ot,ht){st.parentVoiceEntry.parentStaffEntry.parentMeasure.handleBeam(st,ot)}handleVoiceEntryLyrics(st,ot,ht){st.LyricsEntries.forEach((lt,O)=>{const D=new T.GraphicalLyricEntry(O,ot,this.rules.LyricsHeight,this.rules.StaffHeight);if(ot.LyricsEntries.push(D),D.GraphicalLabel.setLabelPositionAndShapeBorders(),O.Word){const j=O.Word.Syllables.indexOf(O);let Q=ht.indexOf(O.Word);if(Q===-1&&(ht.push(O.Word),Q=ht.indexOf(O.Word)),this.graphicalLyricWords.length===0||Q>this.graphicalLyricWords.length-1){const J=new g.GraphicalLyricWord(O.Word);D.ParentLyricWord=J,J.GraphicalLyricsEntries[j]=D,this.graphicalLyricWords.push(J)}else{const J=this.graphicalLyricWords[Q];D.ParentLyricWord=J,J.GraphicalLyricsEntries[j]=D,J.isFilled()&&(ht.splice(Q,1),this.graphicalLyricWords.splice(this.graphicalLyricWords.indexOf(J),1))}}})}handleVoiceEntryOrnaments(st,ot,ht){}handleVoiceEntryArticulations(st,ot,ht){}handleVoiceEntryTechnicalInstructions(st,ot,ht){}handleTuplet(st,ot,ht){st.parentVoiceEntry.parentStaffEntry.parentMeasure.handleTuplet(st,ot)}findIndexGraphicalSlurFromSlur(st,ot){for(let ht=0;ht=0){const et=lt[q];et.staffEntries.indexOf(D)===-1&&et.staffEntries.push(D),lt.splice(q,1)}}}for(const j of lt)j.staffEntries.indexOf(D)===-1&&j.staffEntries.push(D)}}for(const ot of this.musicSystems)for(const ht of ot.StaffLines){const lt=ht.GraphicalSlurs.sort(B.GraphicalSlur.Compare);for(const O of lt)O.slur.isCrossed()||O.calculateCurve(this.rules)}}calculateGlissandi(){const st={};for(const ot of this.graphicalMusicSheet.MeasureList[0])st[ot.ParentStaff.idInMusicSheet]=[];for(const ot of this.musicSystems)for(const ht of ot.StaffLines){const lt=st[ht.ParentStaff.idInMusicSheet];for(let O=0;O=0){const et=lt[q];et.staffEntries.indexOf(D)===-1&&et.staffEntries.push(D),lt.splice(q,1)}}}}for(const j of lt)j.staffEntries.indexOf(D)===-1&&j.staffEntries.push(D)}}for(const ot of this.musicSystems)for(const ht of ot.StaffLines)for(const lt of ht.GraphicalGlissandi)if(ht.ParentStaff.isTab){const O=lt.Glissando.StartNote,D=lt.Glissando.EndNote,j=lt.staffEntries[0].findGraphicalNoteFromNote(O),Q=lt.staffEntries.last().findGraphicalNoteFromNote(D);if(!j&&!Q)return;let J,q,et,it,dt=1;O.FretNumber>D.FretNumber&&(dt=-1),j&&j.vfnote&&j.vfnote.length>=2&&(et=j.vfnote[0],J=[0]),Q&&Q.vfnote&&Q.vfnote.length>=2&&(it=Q.vfnote[0],q=[0]);const mt=new S.TabSlide({first_indices:J,first_note:et,last_indices:q,last_note:it},dt),yt=j==null?void 0:j.parentVoiceEntry.parentStaffEntry.parentMeasure;yt&&(yt.vfTies.push(mt),lt.vfTie=mt);const Et=Q==null?void 0:Q.parentVoiceEntry.parentStaffEntry.parentMeasure;Et&&(Et.vfTies.push(mt),lt.vfTie=mt)}}}y.VexFlowMusicSheetCalculator=rt},9479(St,y,p){var d=this&&this.__importDefault||function(P){return P&&P.__esModule?P:{default:P}};Object.defineProperty(y,"__esModule",{value:!0}),y.VexFlowMusicSheetDrawer=y.unitInPixels=void 0;const l=d(p(3206)),m=p(1932),o=p(200),s=p(9409),h=p(7785),u=p(2683),f=p(6362),r=p(3361),b=p(5023),S=d(p(3065)),v=p(1066),w=p(3661),T=p(5824),g=p(9436);y.unitInPixels=10;class x extends m.MusicSheetDrawer{constructor(_=new w.DrawingParameters){super(new h.VexFlowTextMeasurer(_.Rules),_),this.backends=[],this.zoom=1,this.pageIdx=0}get Backends(){return this.backends}drawSheet(_){var B,k,R;this.rules.DefaultVexFlowNoteFont==="gonville"&&(l.default.Flow.DEFAULT_FONT_STACK=[(B=l.default.Flow.Fonts)==null?void 0:B.Gonville,(k=l.default.Flow.Fonts)==null?void 0:k.Bravura,(R=l.default.Flow.Fonts)==null?void 0:R.Custom]),l.default.Flow.STAVE_LINE_THICKNESS=this.rules.StaffLineWidth*y.unitInPixels,l.default.Flow.STEM_WIDTH=this.rules.StemWidth*y.unitInPixels,l.default.Flow.DEFAULT_NOTATION_FONT_SCALE=this.rules.VexFlowDefaultNotationFontScale,l.default.Flow.DEFAULT_TAB_FONT_SCALE=this.rules.VexFlowDefaultTabFontScale,this.pageIdx=0;for(const F of _.MusicPages){if(F.PageNumber>this.rules.MaxPageToDrawNumber)break;const A=this.backends[this.pageIdx];A.graphicalMusicPage=F,A.scale(this.zoom),this.pageIdx+=1}this.pageIdx=0,this.backend=this.backends[0],super.drawSheet(_)}drawPage(_){_&&(this.backend=this.backends[_.PageNumber-1],super.drawPage(_),this.pageIdx+=1)}clear(){for(const _ of this.backends)_.clear()}setZoom(_){this.zoom=_}calculatePixelDistance(_){return _*y.unitInPixels}drawStaffLine(_){var F,A,G;const B=this.backend.getContext(),k=B.openGroup();k&&(k.classList.add("staffline"),_.ParentStaff&&(k.id=`${(F=_.ParentStaff.ParentInstrument)==null?void 0:F.Name}${(A=_.ParentStaff.ParentInstrument)==null?void 0:A.Id}-${(G=_.ParentStaff)==null?void 0:G.Id}`)),super.drawStaffLine(_);const R=_.PositionAndShape.AbsolutePosition;this.rules.RenderSlurs&&this.drawSlurs(_,R),this.rules.RenderGlissandi&&this.drawGlissandi(_,R),B.closeGroup()}drawSlurs(_,B){for(const k of _.GraphicalSlurs)k.slur.isCrossed()||this.drawSlur(k,B)}drawGlissandi(_,B){for(const k of _.GraphicalGlissandi)this.drawGlissando(k,B)}drawGlissando(_,B){if(_.StaffLine.ParentStaff.isTab||_.calculateLine(this.rules),_.Line){const k=new s.PointF2D(_.Line.Start.x+B.x,_.Line.Start.y),R=new s.PointF2D(_.Line.End.x+B.x,_.Line.End.y);_.Line.SVGElement=this.drawLine(k,R,_.Color,_.Width)}else{const k=_.vfTie;if(k){const R=this.backend.getContext();k.setContext(R),k.draw()}}}drawSlur(_,B){const k=[],R=new s.PointF2D(_.bezierStartPt.x+B.x,_.bezierStartPt.y+B.y),F=new s.PointF2D(_.bezierStartControlPt.x+B.x,_.bezierStartControlPt.y+B.y),A=new s.PointF2D(_.bezierEndControlPt.x+B.x,_.bezierEndControlPt.y+B.y),G=new s.PointF2D(_.bezierEndPt.x+B.x,_.bezierEndPt.y+B.y);k.push(this.applyScreenTransformation(R)),k.push(this.applyScreenTransformation(F)),k.push(this.applyScreenTransformation(A)),k.push(this.applyScreenTransformation(G)),_.placement===f.PlacementEnum.Above?(R.y-=.05,F.y-=.3,A.y-=.3,G.y-=.05):(R.y+=.05,F.y+=.3,A.y+=.3,G.y+=.05),k.push(this.applyScreenTransformation(R)),k.push(this.applyScreenTransformation(F)),k.push(this.applyScreenTransformation(A)),k.push(this.applyScreenTransformation(G));const U=this.rules.GNote(_.slur.StartNote);_.SVGElement=this.backend.renderCurve(k,!0,U)}drawMeasure(_){_.setAbsoluteCoordinates(_.PositionAndShape.AbsolutePosition.x*y.unitInPixels,_.PositionAndShape.AbsolutePosition.y*y.unitInPixels);try{_.draw(this.backend.getContext())}catch(k){S.default.warn("VexFlowMusicSheetDrawer.drawMeasure",k)}let B=0;for(const k of _.staffEntries)this.drawStaffEntry(k),B=this.drawBuzzRolls(k,B)}drawBuzzRolls(_,B){var k;for(const R of _.graphicalVoiceEntries)for(const F of R.notes)if((k=F.sourceNote.TremoloInfo)!=null&&k.tremoloUnmeasured){const A=this.rules.TremoloBuzzRollThickness,G=.9,U=.5,C=F;let z,W;const $=C.vfnote[0].getStemDirection();let N;if(this.backend instanceof g.SvgVexFlowBackend&&(N=C.getStemSVG()),(N==null?void 0:N.getBbox)!==void 0){const ot=N.getBBox();z=new s.PointF2D(ot.x/10,ot.y/10),W=ot.height/10}else W=C.vfnote[0].getStemLength()/10,z=new s.PointF2D(C.vfnote[0].getStem().x_begin/10,C.vfnote[0].getStem().y_top/10),$===1&&(z.y-=W);let Y=z.y+W/3;C.vfnote[0].getBeamCount()>1&&(Y=z.y+W/2,$===-1&&(Y-=U+.2));const tt=z.x-.5,H=Y,rt=[],ct=[new s.PointF2D(0,-A),new s.PointF2D(G-A,0),new s.PointF2D(-G+A,-U),new s.PointF2D(0,-A),new s.PointF2D(G,0),new s.PointF2D(0,A),new s.PointF2D(-G+A,0),new s.PointF2D(G-A,U),new s.PointF2D(0,A),new s.PointF2D(-G,0)];let st=new s.PointF2D(tt,H);rt.push(st);for(const ot of ct)st=rt.last(),rt.push(new s.PointF2D(st.x+ot.x,st.y-ot.y));this.DrawPath(rt,C.ParentMusicPage,!0,`buzzRoll${B}`),B++}return B}drawLine(_,B,k="#000000FF",R=.2){return _=this.applyScreenTransformation(_),B=this.applyScreenTransformation(B),this.backend.renderLine(_,B,k,R*y.unitInPixels)}DrawOverlayLine(_,B,k,R="#FF0000FF",F=.2,A){if(!k.PageNumber||k.PageNumber>this.backends.length||k.PageNumber<1)return void console.log("VexFlowMusicSheetDrawer.drawOverlayLine: invalid page number / music page number doesn't correspond to an existing backend.");const G=k.PageNumber-1,U=this.backends[G];return _=this.applyScreenTransformation(_),B=this.applyScreenTransformation(B),A||(A=`overlayLine ${_.x}/${_.y}`),U.renderLine(_,B,R,F*y.unitInPixels,A)}DrawPath(_,B,k=!0,R){const F=B.PageNumber-1,A=this.backends[F],G=[];for(const U of _)G.push(this.applyScreenTransformation(U));return A.renderPath(G,k,R)}drawSkyLine(_){const B=_.PositionAndShape.AbsolutePosition,k=_.PositionAndShape.Size.width;this.drawSampledLine(_.SkyLine,B,k)}drawBottomLine(_){const B=new s.PointF2D(_.PositionAndShape.AbsolutePosition.x,_.PositionAndShape.AbsolutePosition.y),k=_.PositionAndShape.Size.width;this.drawSampledLine(_.BottomLine,B,k,"#0000FFFF")}drawSampledLine(_,B,k,R="#FF0000FF"){const F=[];let A=0;for(let U=0;U<_.length;U++)_[U]!==A&&(F.push(U),A=_[U]);const G=B;if(F.length>0){const U=this.rules.SamplingUnit;let C,z,W=new s.PointF2D(G.x,G.y),$=new s.PointF2D(F[0]/U+G.x,G.y);this.drawLine(W,$,R),_[0]>=0&&(C=new s.PointF2D(F[0]/U+G.x,G.y),z=new s.PointF2D(F[0]/U+G.x,G.y+_[F[0]]),this.drawLine(C,z,R));for(let N=1;N0)for(const B of _.FingeringEntries)B.SVGNode=this.drawLabel(B,u.GraphicalLayers.Notes);if(_.graphicalChordContainers!==void 0&&_.graphicalChordContainers.length>0)for(const B of _.graphicalChordContainers){const k=B.GraphicalLabel;k.SVGNode=this.drawLabel(k,u.GraphicalLayers.Notes)}this.rules.RenderLyrics&&_.LyricsEntries.length>0&&this.drawLyrics(_.LyricsEntries,u.GraphicalLayers.Notes)}drawLyrics(_,B){_.forEach(k=>{var F;const R=k.GraphicalLabel;R.Label.colorDefault=this.rules.DefaultColorLyrics,R.SVGNode=this.drawLabel(R,B),(F=R.SVGNode)==null||F.classList.add("lyrics")})}drawInstrumentBrace(_,B){const k=this.backend.getContext();k.openGroup("brace"),_.draw(k),k.closeGroup()}drawGroupBracket(_,B){const k=this.backend.getContext();k.openGroup("bracket"),_.draw(k),k.closeGroup()}drawOctaveShifts(_){for(const B of _.OctaveShifts)if(B){const k=B,R=this.backend.getContext(),F=k.getTextBracket();this.rules.DefaultColorMusic&&(F.render_options.color=this.rules.DefaultColorMusic),F.setContext(R);try{F.draw()}catch(A){S.default.warn(A)}}}drawPedals(_){for(const B of _.Pedals)if(B){const k=B,R=this.backend.getContext(),F=k.getPedalMarking();F.render_options.color=this.rules.DefaultColorMusic,F.setContext(R),F.draw()}}drawWavyLines(_){for(const B of _.WavyLines)if(B){const k=B,R=this.backend.getContext(),F=k.getVibratoBracket();F.setContext(R),F.draw()}}drawExpressions(_){var B;for(const k of _.AbstractExpressions)if(k instanceof b.GraphicalInstantaneousDynamicExpression)this.drawInstantaneousDynamic(k);else if(k instanceof r.GraphicalInstantaneousTempoExpression){if(((B=k.SourceExpression.parentMeasure)==null?void 0:B.MeasureNumber)<=1&&!this.rules.RenderFirstTempoExpression)continue;const R=k.GraphicalLabel;R.SVGNode=this.drawLabel(R,u.GraphicalLayers.Notes)}else if(k instanceof v.GraphicalContinuousDynamicExpression)this.drawContinuousDynamic(k);else if(k instanceof T.GraphicalUnknownExpression){const R=k.Label;R.SVGNode=this.drawLabel(R,u.GraphicalLayers.Notes)}else S.default.warn("Unkown type of expression!")}drawInstantaneousDynamic(_){const B=_.Label;B.SVGNode=this.drawLabel(B,u.GraphicalLayers.Notes)}drawContinuousDynamic(_){if(_.IsVerbal){const B=_.Label;B.SVGNode=this.drawLabel(B,u.GraphicalLayers.Notes)}else for(const B of _.Lines){const k=new s.PointF2D(_.ParentStaffLine.PositionAndShape.AbsolutePosition.x+B.Start.x,_.ParentStaffLine.PositionAndShape.AbsolutePosition.y+B.Start.y),R=new s.PointF2D(_.ParentStaffLine.PositionAndShape.AbsolutePosition.x+B.End.x,_.ParentStaffLine.PositionAndShape.AbsolutePosition.y+B.End.y);B.SVGElement=this.drawLine(k,R,B.colorHex??"#000000",B.Width)}}renderLabel(_,B,k,R,F,A){var N;if(!_.Label.print)return;const G=_.Label.fontHeight*y.unitInPixels,{font:U}=_.Label;let C;this.rules.ColoringEnabled&&(C=_.Label.colorDefault,_.ColorXML&&(C=_.ColorXML),C||(C=this.rules.DefaultColorLabel));let z,{fontStyle:W,fontFamily:$}=_.Label;W||(W=this.rules.DefaultFontStyle),$||($=this.rules.DefaultFontFamily);for(let Y=0;Y<((N=_.TextLines)==null?void 0:N.length);Y++){const tt=_.TextLines[Y],H=this.calculatePixelDistance(tt.xOffset),rt=new s.PointF2D(A.x+H,A.y),ct=this.backend.renderText(G,W,U,tt.text,F,rt,C,_.Label.fontFamily);z?z.appendChild(ct):z=ct,A.y=A.y+F,_.TextLines.length>1&&(A.y+=this.rules.SpacingBetweenTextLines)}return z}renderRectangle(_,B,k,R,F){return this.backend.renderRectangle(_,k,R,F)}applyScreenTransformation(_){return new s.PointF2D(_.x*y.unitInPixels,_.y*y.unitInPixels)}applyScreenTransformationForRect(_){return new o.RectangleF2D(_.x*y.unitInPixels,_.y*y.unitInPixels,_.width*y.unitInPixels,_.height*y.unitInPixels)}}y.VexFlowMusicSheetDrawer=x},4332(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.VexFlowMusicSystem=void 0;const d=p(5221),l=p(6954),m=p(67),o=p(4284),s=p(6014),h=p(3109),u=p(7098);class f extends d.MusicSystem{constructor(b,S){super(b),this.rules=S}calculateBorders(b){if(this.staffLines.length===0)return;const S=this.calcBracketsWidth();this.boundingBox.BorderLeft=-S,this.boundingBox.BorderMarginLeft=-S,this.boundingBox.XBordersHaveBeenSet=!0;const v=this.staffLines[0].SkyBottomLineCalculator.getSkyLineMin();this.boundingBox.BorderTop=v,this.boundingBox.BorderMarginTop=v;const w=this.staffLines[this.staffLines.length-1],T=w.SkyBottomLineCalculator.getBottomLineMax()+w.PositionAndShape.RelativePosition.y;this.boundingBox.BorderBottom=T,this.boundingBox.BorderMarginBottom=T,this.boundingBox.XBordersHaveBeenSet=!0,this.boundingBox.YBordersHaveBeenSet=!0}createSystemLine(b,S,v,w,T,g,x=void 0){const P=g;let _=!1;if(x){_=!0,x.addMeasureLine(v,w),P&&P.addMeasureLine(v,w,_);let B=0;if(v===l.SystemLinesEnum.BoldThinDots&&w===m.SystemLinePosition.MeasureBegin&&g.beginInstructionsWidth>0&&(B=P.getVFStave().getModifierXShift(0)),x.lineTo(g,s.VexFlowConverter.line(v,w),B),v===l.SystemLinesEnum.DotsBoldBoldDots){const k=x.ParentStaffLine.Measures.indexOf(x)+1,R=x.ParentStaffLine.Measures[k],F=g.ParentStaffLine.Measures[k];R&&F&&(R.lineTo(F,s.VexFlowConverter.line(l.SystemLinesEnum.BoldThinDots,w)),R.addMeasureLine(l.SystemLinesEnum.BoldThinDots,w))}}else P&&P.addMeasureLine(v,w,_);return new o.SystemLine(v,w,this,g,x)}createInstrumentBracket(b,S){const v=b,w=S,T=new u.VexFlowInstrumentBrace(v,w);this.InstrumentBrackets.push(T)}createGroupBracket(b,S,v){const w=b,T=S;if(v===0){const g=new h.VexFlowInstrumentBracket(w,T,v);this.GroupBrackets.push(g)}else{const g=new u.VexFlowInstrumentBrace(w,T,v);this.GroupBrackets.push(g)}}}y.VexFlowMusicSystem=f},9310(St,y,p){var d=this&&this.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(y,"__esModule",{value:!0}),y.VexFlowOctaveShift=void 0;var l=d(p(3206)).default.Flow;const m=p(2768),o=p(437),s=d(p(3065));class h extends m.GraphicalOctaveShift{constructor(f,r){switch(super(f,r),f.Type){case o.OctaveEnum.VA8:this.position=l.TextBracket.Positions.TOP,this.supscript="va",this.text="8";break;case o.OctaveEnum.MA15:this.position=l.TextBracket.Positions.TOP,this.supscript="ma",this.text="15";break;case o.OctaveEnum.VB8:this.position=l.TextBracket.Positions.BOTTOM,this.supscript="vb",this.text="8";break;case o.OctaveEnum.MB15:this.position=l.TextBracket.Positions.BOTTOM,this.supscript="mb",this.text="15";break;default:s.default.error("Unknown or NONE octaveshift. This should not be called!")}}setStartNote(f){for(const r of f.graphicalVoiceEntries){const b=r;if(b!=null&&b.vfStaveNote)return this.startNote=b.vfStaveNote,!0}return!1}setEndNote(f,r=-1){var S;const b=f.graphicalVoiceEntries;for(let v=(r>=0?Math.min(r,b.length):b.length)-1;v>=0;v--){const w=b[v];if(w!=null&&w.vfStaveNote)return this.endNote=w.vfStaveNote,this.endMeasure=f.parentMeasure,(S=this.endMeasure)!=null&&S.parentSourceMeasure.Rules.OctaveShiftOnWholeMeasureNoteUntilEndOfMeasure&&w.notes[0].sourceNote.isWholeMeasureNote()&&(this.graphicalEndAtMeasureEnd=!0),!0}return!1}getTextBracket(){let f,r=this.endNote;const b=this;this.graphicalEndAtMeasureEnd&&(f={getAbsoluteX:()=>10*(b.endMeasure.PositionAndShape.AbsolutePosition.x+b.endMeasure.PositionAndShape.Size.width),getGlyph:()=>({getWidth:()=>0})}),f&&(r=f);const S=new l.TextBracket({position:this.position,start:this.startNote,stop:r,superscript:this.supscript,text:this.text});return this.endsOnDifferentStaffLine&&(S.render_options.show_bracket=!1),S}}y.VexFlowOctaveShift=h},7109(St,y,p){var d=this&&this.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(y,"__esModule",{value:!0}),y.VexFlowPedal=void 0;const l=d(p(3206)),m=p(6438),o=p(7824),s=p(512);class h extends o.GraphicalPedal{constructor(f,r,b=!1,S=!1){switch(super(f,r),this.vfStyle=l.default.Flow.PedalMarking.Styles.BRACKET,this.ChangeBegin=!1,this.ChangeEnd=!1,this.line=-3,this.EndSymbolPositionAndShape=void 0,this.ChangeBegin=f.ChangeBegin,this.ChangeEnd=f.ChangeEnd,this.pedalSymbol){case s.MusicSymbol.PEDAL_SYMBOL:this.vfStyle=l.default.Flow.PedalMarking.Styles.TEXT,this.EndSymbolPositionAndShape=new m.BoundingBox(this,r);break;case s.MusicSymbol.PEDAL_MIXED:this.vfStyle=b&&S?l.default.Flow.PedalMarking.Styles.BRACKET_OPEN_BOTH:b?l.default.Flow.PedalMarking.Styles.BRACKET_OPEN_BEGIN:S?l.default.Flow.PedalMarking.Styles.MIXED_OPEN_END:l.default.Flow.PedalMarking.Styles.MIXED;break;case s.MusicSymbol.PEDAL_BRACKET:default:this.vfStyle=b&&S?l.default.Flow.PedalMarking.Styles.BRACKET_OPEN_BOTH:b?l.default.Flow.PedalMarking.Styles.BRACKET_OPEN_BEGIN:S?l.default.Flow.PedalMarking.Styles.BRACKET_OPEN_END:l.default.Flow.PedalMarking.Styles.BRACKET}}setStartNote(f){if(!f)return!1;for(const r of f.graphicalVoiceEntries){const b=r;if(b!=null&&b.vfStaveNote)return this.startNote=b.vfStaveNote,this.startVfVoiceEntry=b,!0}return!1}setEndNote(f){if(!f)return!1;for(const r of f.graphicalVoiceEntries){const b=r;if(b!=null&&b.vfStaveNote)return this.endNote=b.vfStaveNote,this.endVfVoiceEntry=b,!0}return!1}setEndMeasure(f){this.endMeasure=f}CalculateBoundingBox(){}setLine(f){this.line=f}getPedalMarking(){const f=new l.default.Flow.PedalMarking([this.startNote,this.endNote]);return this.endMeasure&&f.setEndStave(this.endMeasure.getVFStave()),f.setStyle(this.vfStyle),f.setLine(this.line),f.setCustomText(this.DepressText,this.ReleaseText),this.endVfVoiceEntry&&!this.getPedal.EndsStave||(f.EndsStave=!0),this.getPedal.BeginsStave&&(f.BeginsStave=!0),f.ChangeBegin=this.ChangeBegin,f.ChangeEnd=this.ChangeEnd,f}setEndsStave(f,r){r!=null&&r.gte(f.parentSourceMeasure.Duration)&&(this.getPedal.EndsStave=!0)}setBeginsStave(f,r){f&&r.RealValue===0&&(this.getPedal.BeginsStave=!0)}}y.VexFlowPedal=h},5468(St,y,p){var d=this&&this.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(y,"__esModule",{value:!0}),y.VexFlowSlur=y.CurvePositionEnum=void 0;var l,m=d(p(3206)).default.Flow;(function(s){s[s.NEAR_HEAD=1]="NEAR_HEAD",s[s.NEAR_TOP=2]="NEAR_TOP"})(l||(y.CurvePositionEnum=l={}));class o{constructor(h){this.vfStartNote=void 0,this.vfEndNote=void 0,this.parentSlur=h}static createFromVexflowSlur(h){return new o(h.parentSlur)}get vfSlur(){return this.parentSlur}curve_Options(){return{cps:[{x:0,y:10},{x:0,y:10}],invert:!1,position:l.NEAR_TOP,position_end:l.NEAR_TOP,spacing:2,thickness:2,x_shift:0,y_shift:10}}createVexFlowCurve(){this.vfCurve=new m.Curve(this.vfStartNote,this.vfEndNote,void 0)}}y.VexFlowSlur=o},6670(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.VexFlowStaffEntry=void 0;const d=p(348),l=p(9479),m=p(8233);class o extends d.GraphicalStaffEntry{constructor(h,u,f){super(h,u,f)}calculateXPosition(){const h=this.parentMeasure.getVFStave();let u=0;for(const f of this.graphicalVoiceEntries)if(f.vfStaveNote){if(f.vfStaveNote.setStave(h),!f.vfStaveNote.preFormatted)continue;f.applyBordersFromVexflow();let r=!1,b=this.PositionAndShape;f.notes[0].sourceNote.isWholeRest()&&!this.hasOnlyRests()&&(r=!0,b=f.PositionAndShape),this.parentMeasure.ParentStaff.isTab?b.RelativePosition.x=(f.vfStaveNote.getAbsoluteX()+f.vfStaveNote.glyph.getWidth())/l.unitInPixels:(b.RelativePosition.x=f.vfStaveNote.getBoundingBox().getX()/l.unitInPixels,r&&(b.RelativePosition.x-=h.getNoteStartX()/l.unitInPixels,b.RelativePosition.x-=1.3));const S=f.notes[0].sourceNote;S.isRest()&&S.Length.RealValue===this.parentMeasure.parentSourceMeasure.ActiveTimeSignature.RealValue&&(b.RelativePosition.x+=this.parentMeasure.parentSourceMeasure.Rules.WholeRestXShiftVexflow-.1,f.PositionAndShape.BorderLeft=-.7,f.PositionAndShape.BorderRight=.7),f.PositionAndShape.BorderLeftb.staffLine),f=this.calculateModifierXOffsets(u,.5),r=this.calculateModifierXOffsets(u,1);h.forEach((b,S)=>{b.baseFingeringXOffset=f[S],b.baseStringNumberXOffset=r[S]})}calculateModifierXOffsets(h,u){const f=[];for(let r=0;r=0;v--){if(Math.abs(h[r]-h[v])<=u&&b===f[v]){b++,S=!0;break}S=!1}f.push(b)}return f}}y.VexFlowStaffEntry=o},5866(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.VexFlowStaffLine=void 0;const d=p(2919),l=p(1083);class m extends d.StaffLine{constructor(s,h){super(s,h),this.slursInVFStaffLine=[],this.alignmentManager=new l.AlignmentManager(this)}get SlursInVFStaffLine(){return this.slursInVFStaffLine}addVFSlurToVFStaffline(s){this.slursInVFStaffLine.push(s)}get AlignmentManager(){return this.alignmentManager}}y.VexFlowStaffLine=m},6173(St,y,p){var d=this&&this.__importDefault||function(f){return f&&f.__esModule?f:{default:f}};Object.defineProperty(y,"__esModule",{value:!0}),y.VexFlowTabMeasure=void 0;var l=d(p(3206)).default.Flow;const m=p(5246),o=p(6014),s=d(p(3065)),h=p(164);class u extends m.VexFlowMeasure{constructor(r,b=void 0,S=void 0){super(r,b,S),this.isTabMeasure=!0}resetLayout(){const r=this.ParentStaff.StafflineCount??6;this.stave=new l.TabStave(0,0,0,{space_above_staff_ln:0,space_below_staff_ln:0,num_lines:r}),this.updateInstructionWidth()}graphicalMeasureCreatedCalculations(){for(let b=0,S=this.staffEntries.length;b1){const g=o.VexFlowConverter.StrokeTypeFromArpeggioType(T.type),x=new l.Stroke(g,{all_voices:this.rules.ArpeggiosGoAcrossVoices});this.rules.RenderArpeggios&&w.vfStaveNote.addStroke(0,x)}else s.default.debug(`[OSMD] arpeggio in measure ${this.MeasureNumber} could not be drawn. + voice entry had less than two notes, arpeggio is likely between voice entries, not currently supported in Vexflow.`)}if(w.vfGhostNotes)for(const T of w.vfGhostNotes)this.vfVoices[b.VoiceId].addTickable(T);else this.vfVoices[b.VoiceId].addTickable(w.vfStaveNote)}else if(w.vfGhostNotes)for(const T of w.vfGhostNotes)this.vfVoices[b.VoiceId].addTickable(T);else this.vfVoices[b.VoiceId].addTickable(w.vfStaveNote)}}}addClefAtBegin(r){r.ClefType===h.ClefEnum.TAB&&super.addClefAtBegin(r)}draw(r){super.draw(r);const b=this.parentSourceMeasure;b.multipleRestMeasures&&this.rules.RenderMultipleRestMeasures&&(this.multiRestElement=new l.MultiMeasureRest(b.multipleRestMeasures,{}),this.multiRestElement.setStave(this.stave),this.multiRestElement.setContext(r),this.multiRestElement.draw())}}y.VexFlowTabMeasure=u},7785(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.VexFlowTextMeasurer=void 0;const d=p(6014);y.VexFlowTextMeasurer=class{constructor(l){this.fontSize=20,this.fontSizeStandard=this.fontSize;const m=document.createElement("canvas");this.context=m.getContext("2d"),this.rules=l}computeTextWidthToHeightRatio(l,m,o,s=void 0,h=this.fontSize){return this.context.font=d.VexFlowConverter.font(h,o,m,this.rules,s),this.context.measureText(l).width/h}setFontSize(l=this.fontSizeStandard){return this.fontSize=l,l}}},2907(St,y,p){var d=this&&this.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(y,"__esModule",{value:!0}),y.VexFlowVibratoBracket=void 0;const l=p(7753),m=d(p(3206));class o extends l.GraphicalWavyLine{get ToEndOfStopStave(){return this.toEndOfStopStave}constructor(h,u,f=!1){super(h,u),this.line=1,this.isVibrato=!1,this.toEndOfStopStave=!1,this.isVibrato=f}setStartNote(h){for(const u of h.graphicalVoiceEntries){const f=u;if(f!=null&&f.vfStaveNote)return this.startNote=f.vfStaveNote,this.startVfVoiceEntry=f,!0}return!1}setEndNote(h){for(const u of h.graphicalVoiceEntries){const f=u;if(f!=null&&f.vfStaveNote){this.endNote=f.vfStaveNote,this.endVfVoiceEntry=f;const r=this.endVfVoiceEntry.parentStaffEntry.parentMeasure.staffEntries,b=r[r.length-1];return this.toEndOfStopStave=b===this.endVfVoiceEntry.parentStaffEntry,!0}}return!1}CalculateBoundingBox(){const h=this.getVibratoBracket();this.boundingBox.Size.height=.2*h.render_options.wave_height}getVibratoBracket(){const h=new m.default.Flow.VibratoBracket({start:this.startNote,stop:this.endNote,toEndOfStopStave:this.toEndOfStopStave});return h.setLine(this.line),this.isVibrato?h.render_options.vibrato_width=20:h.render_options.wave_girth=4,h}}y.VexFlowVibratoBracket=o},4134(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.VexFlowVoiceEntry=void 0;const d=p(4548),l=p(9479),m=p(4434),o=p(4064);class s extends d.GraphicalVoiceEntry{constructor(u,f,r){super(u,f,r)}applyBordersFromVexflow(){const u=this.vfStaveNote;if(!u.getNoteHeadBeginX)return;const f=u.getBoundingBox(),r=u.getNoteHeadBeginX()-f.x;this.PositionAndShape.RelativePosition.y=f.y/l.unitInPixels,this.PositionAndShape.BorderTop=0,this.PositionAndShape.BorderBottom=f.h/l.unitInPixels;const b=(u.width-(u.paddingRight??0))/2;this.PositionAndShape.BorderLeft=-(r+b)/l.unitInPixels,this.PositionAndShape.BorderRight=(f.w-r)/l.unitInPixels}set vfStaveNote(u){this.mVexFlowStaveNote=u}get vfStaveNote(){return this.mVexFlowStaveNote}applyCustomNoteheads(){const u=this.vfStaveNote;if(u)for(let f=0;ff.length-1)return-1;for(let S=b;Sthis.rules.PercussionOneLineCutoff&&!S&&!this.rules.PercussionUseCajon2NoteSystem)return f;const v=f,w=f.sourceNote.Pitch;let T=this.baseLineNote,g=this.baseLineOctave;if(this.rules.PercussionUseCajon2NoteSystem?w.FundamentalNote===d.NoteEnum.C&&(T=d.NoteEnum.G,g=1):this.rules.PercussionUseXMLDisplayStep&&f.sourceNote.displayStepUnpitched!==void 0&&(T=f.sourceNote.displayStepUnpitched,g=f.sourceNote.displayOctaveUnpitched+this.rules.PercussionOneLineXMLDisplayStepOctaveOffset),b.length<=this.rules.PercussionForceVoicesOneLineCutoff)v.setAccidental(new d.Pitch(T,g,w.Accidental));else{const x=h.PitchIndexOf(b,w);if(x>-1){const P=Math.ceil(b.length/2);if(!this.rules.PercussionUseXMLDisplayStep)if(x>=P)switch(g=2,(x-P)%5){case 1:T=d.NoteEnum.E;break;case 2:T=d.NoteEnum.G;break;case 3:T=d.NoteEnum.B;break;case 4:T=d.NoteEnum.D,g=3;break;default:T=d.NoteEnum.C}else switch(x%5){case 1:T=d.NoteEnum.F;break;case 2:T=d.NoteEnum.D;break;case 3:T=d.NoteEnum.B,g=0;break;case 4:T=d.NoteEnum.G,g=0;break;default:T=d.NoteEnum.A}const _=new d.Pitch(T,g,w.Accidental);v.setAccidental(_);const B=v.parentVoiceEntry.parentVoiceEntry;!this.rules.SetWantedStemDirectionByXml&&B.Notes.length<2&&(_.Octave>this.baseLineOctave||_.FundamentalNote===this.baseLineNote&&_.Octave===this.baseLineOctave?v.parentVoiceEntry.parentVoiceEntry.WantedStemDirection=s.StemDirectionType.Up:v.parentVoiceEntry.parentVoiceEntry.WantedStemDirection=s.StemDirectionType.Down)}}return v}getStafflineUniquePositionCount(f){return this.staffPitchListMapping.containsKey(f)?this.staffPitchListMapping.getValue(f).length:0}}y.VexflowStafflineNoteCalculator=h},7499(St,y,p){var d=this&&this.__createBinding||(Object.create?function(m,o,s,h){h===void 0&&(h=s);var u=Object.getOwnPropertyDescriptor(o,s);u&&!("get"in u?!o.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return o[s]}}),Object.defineProperty(m,h,u)}:function(m,o,s,h){h===void 0&&(h=s),m[h]=o[s]}),l=this&&this.__exportStar||function(m,o){for(var s in m)s==="default"||Object.prototype.hasOwnProperty.call(o,s)||d(o,m,s)};Object.defineProperty(y,"__esModule",{value:!0}),l(p(1083),y),l(p(9834),y),l(p(9436),y),l(p(1902),y),l(p(2400),y),l(p(6014),y),l(p(1216),y),l(p(9635),y),l(p(3753),y),l(p(7809),y),l(p(7098),y),l(p(3109),y),l(p(5246),y),l(p(3849),y),l(p(806),y),l(p(9479),y),l(p(4332),y),l(p(9310),y),l(p(5468),y),l(p(6670),y),l(p(5866),y),l(p(7506),y),l(p(6173),y),l(p(7785),y),l(p(4134),y)},3508(St,y,p){var d=this&&this.__importDefault||function(b){return b&&b.__esModule?b:{default:b}};Object.defineProperty(y,"__esModule",{value:!0}),y.WebGLSkyBottomLineBatchCalculatorBackend=void 0;const l=p(5479),m=p(3667),o=d(p(5340)),s=d(p(5166)),h=d(p(3065)),u=p(813);function f(b,S,v){const w=b.createShader(S);if(!w)throw h.default.warn("WebGLSkyBottomLineCalculatorBackend: Could not create a WebGL shader"),new Error("Could not create a WebGL shader");if(b.shaderSource(w,v),b.compileShader(w),!b.getShaderParameter(w,b.COMPILE_STATUS))throw h.default.warn(`Shader compilation failed `+b.getShaderInfoLog(w)),b.deleteShader(w),new Error("WebGL shader compilation failed");return w}class r extends m.SkyBottomLineBatchCalculatorBackend{constructor(S,v){super(S,v)}getPreferredRenderingConfiguration(S,v){const w=Math.min(4096,(function(){const g=document.createElement("canvas").getContext("webgl");return g.getParameter(g.MAX_TEXTURE_SIZE)})()),T=Math.ceil(S);return{elementWidth:T,numColumns:Math.min(5,Math.floor(w/T)),numRows:Math.min(5,Math.floor(w/v))}}onInitialize(S){const{elementWidth:v,elementHeight:w,numColumns:T,numRows:g}=S,x=document.createElement("canvas");x.width=v*T,x.height=g;const P=x.getContext("webgl");if(!P)throw h.default.warn("WebGLSkyBottomLineCalculatorBackend: No WebGL support"),new Error("No WebGL support");this.gl=P;const _=(function(B,k,R){const F=B.createProgram();if(!F)throw h.default.warn("WebGLSkyBottomLineCalculatorBackend: Could not create a WebGL program"),new Error("Could not create a WebGL program");if(B.attachShader(F,k),B.attachShader(F,R),B.linkProgram(F),!B.getProgramParameter(F,B.LINK_STATUS))throw h.default.warn(`WebGLSkyBottomLineCalculatorBackend: WebGL program link failed -`+B.getProgramInfoLog(F)),B.deleteProgram(F),new Error("WebGL program link failed");return F})(P,f(P,P.VERTEX_SHADER,a.default),f(P,P.FRAGMENT_SHADER,(function(B,k){let R=B;for(const[F,A]of Object.entries(k)){const G=new RegExp(`#define ${F} .*`);R=R.replace(G,`#define ${F} ${A}`)}return R})(s.default,{NUM_ROWS:g,ELEMENT_HEIGHT:w})));(function(B,k){const R=B.createBuffer();if(!R)throw h.default.warn("WebGLSkyBottomLineCalculatorBackend: WebGL buffer creation failed"),new Error("WebGL buffer creation failed");B.bindBuffer(B.ARRAY_BUFFER,R),B.bufferData(B.ARRAY_BUFFER,new Float32Array(u.CollectionUtil.flat([[-1,-1],[1,-1],[1,1],[-1,-1],[1,1],[-1,1]])),B.STATIC_DRAW),B.useProgram(k);const F=B.getAttribLocation(k,"a_position");B.enableVertexAttribArray(F),B.vertexAttribPointer(F,2,B.FLOAT,!1,0,0)})(P,_),this.texture=(function(B,k){const R=B.createTexture();if(!R)throw h.default.warn("WebGLSkyBottomLineCalculatorBackend: WebGL texture creation failed"),new Error("WebGL texture creation failed");B.activeTexture(B.TEXTURE0+0),B.bindTexture(B.TEXTURE_2D,R),B.texParameteri(B.TEXTURE_2D,B.TEXTURE_WRAP_S,B.CLAMP_TO_EDGE),B.texParameteri(B.TEXTURE_2D,B.TEXTURE_WRAP_T,B.CLAMP_TO_EDGE),B.texParameteri(B.TEXTURE_2D,B.TEXTURE_MIN_FILTER,B.NEAREST),B.texParameteri(B.TEXTURE_2D,B.TEXTURE_MAG_FILTER,B.NEAREST);const F=B.getUniformLocation(k,"u_image");if(!F)throw h.default.warn("WebGLSkyBottomLineCalculatorBackend: WebGL invalid uniform name"),new Error("WebGL invalid uniform name");return B.uniform1i(F,0),R})(P,_)}calculateFromCanvas(S,v,w,T,g){const x=this.gl,{elementWidth:P,elementHeight:_,numColumns:B}=g;x.viewport(0,0,x.canvas.width,x.canvas.height),x.bindTexture(x.TEXTURE_2D,this.texture),x.texImage2D(x.TEXTURE_2D,0,x.RGBA,x.RGBA,x.UNSIGNED_BYTE,S),x.drawArrays(x.TRIANGLES,0,6);const k=new Uint8Array(x.canvas.width*x.canvas.height*4);x.readPixels(0,0,x.canvas.width,x.canvas.height,x.RGBA,x.UNSIGNED_BYTE,k);const R=[];for(let F=0;F0&&this.Voices[0].Visible}isVisible(){if(!this.Visible)return!1;for(const h of this.Staves)if(h.Visible)return!0;return!1}set Visible(h){for(let u=0,f=this.Voices.length;u=0;h--)if(s=this.timestamps[h],a.gte(s.$from))return s;return this.timestamps[0]}absoluteEnrolledToSheetTimestamp(a){if(this.timestamps.length===0)return a;const s=this.getCurrentRepetitionTimestampTransform(a);return d.Fraction.plus(a,d.Fraction.minus(s.to,s.$from))}get Parts(){return this.parts}get MusicSheet(){return this.musicSheet}getIterator(a){return a?new l.MusicPartManagerIterator(this.musicSheet,a,void 0):new l.MusicPartManagerIterator(this.musicSheet,this.musicSheet.SelectionStart,this.musicSheet.SelectionEnd)}setSelectionStart(a){this.musicSheet.SelectionStart=a,this.musicSheet.SelectionEnd=void 0}setSelectionRange(a,s){this.musicSheet.SelectionStart=a??this.sheetStart,this.musicSheet.SelectionEnd=s??this.sheetEnd}calcMapping(){const a=[],s=this.getIterator();let h=s.CurrentRepetition,u=new m(s.CurrentEnrolledTimestamp.clone(),s.CurrentSourceTimestamp.clone(),void 0,0);for(a.push(u);!s.EndReached;){if(s.JumpOccurred||h!==s.CurrentRepetition){if(h=s.CurrentRepetition,s.backJumpOccurred){const f=s.JumpResponsibleRepetition;u.nextBackJump=s.CurrentEnrolledTimestamp,u.curRepetition=f,u.curRepetitionIteration=s.CurrentJumpResponsibleRepetitionIterationBeforeJump;for(let r=this.timestamps.length-2;r>=0&&!a[r].to.lt(f.AbsoluteTimestamp)&&!a[r].curRepetition;r--)a[r].nextBackJump=u.nextBackJump,a[r].curRepetition=f,a[r].curRepetitionIteration=u.curRepetitionIteration}u=new m(s.CurrentEnrolledTimestamp.clone(),s.CurrentSourceTimestamp.clone(),void 0,0),a.push(u)}s.moveToNext()}this.timestamps=a}};class m{constructor(s,h,u,f){this.$from=s,this.to=h,this.curRepetition=u,this.curRepetitionIteration=f,this.nextBackJump=void 0,this.nextForwardJump=void 0}}y.TimestampTransform=m},474(St,y,p){var d=this&&this.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(y,"__esModule",{value:!0}),y.MusicPartManagerIterator=void 0;const l=p(2561),m=p(1110),a=p(9288),s=p(5875),h=d(p(3065)),u=p(4064);class f{constructor(b,S,v){this.currentMeasureIndex=0,this.currentPartIndex=0,this.currentVoiceEntryIndex=-1,this.currentDynamicEntryIndex=0,this.currentTempoEntryIndex=0,this.currentDynamicChangingExpressions=[],this.repetitionIterationCountDictKeys=[],this.repetitionIterationCountDictValues=[],this.currentRepetition=void 0,this.endReached=!1,this.frontReached=!1,this.currentTimeStamp=new l.Fraction(0,1),this.currentEnrolledMeasureTimestamp=new l.Fraction(0,1),this.currentRelativeInMeasureTimestamp=new l.Fraction(0,1),this.currentVerticalContainerInMeasureTimestamp=new l.Fraction(0,1),this.jumpResponsibleRepetition=void 0,this.activeDynamicExpressions=[],this.SkipInvisibleNotes=!0;try{this.frontReached=!0,this.musicSheet=b,this.currentBpm=b.userStartTempoInBPM,this.currentVoiceEntries=void 0,this.frontReached=!1;for(const w of this.musicSheet.Repetitions)this.setRepetitionIterationCount(w,1);for(let w=0;w0&&(this.currentBpm=S)}else this.musicSheet.IgnoreTempoInstructions||(b=this.CurrentTempoChangingExpression.InstantaneousTempo)!=null&&b.TempoInBpm&&(this.currentBpm=this.CurrentTempoChangingExpression.InstantaneousTempo.TempoInBpm)}moveToNextVisibleVoiceEntry(b){for(;!this.endReached;)if(this.moveToNext(),this.checkEntries(b))return}resetRepetitionIterationCount(b){return this.setRepetitionIterationCount(b,1),1}incrementRepetitionIterationCount(b){return this.repetitionIterationCountDictKeys.indexOf(b)===-1?this.setRepetitionIterationCount(b,1):this.setRepetitionIterationCount(b,this.getRepetitionIterationCount(b)+1)}setRepetitionIterationCount(b,S){const v=this.repetitionIterationCountDictKeys.indexOf(b);return v===-1?(this.repetitionIterationCountDictKeys.push(b),this.repetitionIterationCountDictValues.push(S)):this.repetitionIterationCountDictValues[v]=S,S}getRepetitionIterationCount(b){const S=this.repetitionIterationCountDictKeys.indexOf(b);if(S!==-1)return this.repetitionIterationCountDictValues[S]}handleRepetitionsAtMeasureBegin(){for(let b=0,S=this.currentMeasure.FirstRepetitionInstructions.length;b=this.JumpResponsibleRepetition.StartIndex&&w.EndIndex<=this.JumpResponsibleRepetition.EndIndex&&this.resetRepetitionIterationCount(w)}}handleRepetitionsAtMeasureEnd(){for(let b=0,S=this.currentMeasure.LastRepetitionInstructions.length;b-1&&this.getRepetitionIterationCount(w)=this.JumpResponsibleRepetition.StartIndex&&w.EndIndex<=this.JumpResponsibleRepetition.EndIndex&&this.resetRepetitionIterationCount(w),this.repetitionIterationCountDictKeys.contains(w))){const T=w.getForwardJumpTargetForIteration(this.getRepetitionIterationCount(w));if(T>=0)return this.currentMeasureIndex=T,this.currentMeasure=this.musicSheet.SourceMeasures[this.currentMeasureIndex],this.currentVoiceEntryIndex=-1,this.jumpResponsibleRepetition=w,void(this.forwardJumpOccurred=!0);T===-2&&(this.endReached=!0)}}}this.currentMeasureIndex++,this.JumpResponsibleRepetition!==void 0&&this.currentMeasureIndex>this.JumpResponsibleRepetition.EndIndex&&(this.jumpResponsibleRepetition=void 0)}doBackJump(b){b.SkipRepetition||this.musicSheet.Rules.CursorIgnoreRepetitions||(this.currentMeasureIndex=b.getBackwardJumpTarget(),this.currentMeasure=this.musicSheet.SourceMeasures[this.currentMeasureIndex],this.currentVoiceEntryIndex=-1,this.incrementRepetitionIterationCount(b),this.jumpResponsibleRepetition=b,this.backJumpOccurred=!0)}activateCurrentRhythmInstructions(){if(this.currentMeasure!==void 0&&this.currentMeasure.FirstInstructionsStaffEntries.length>0&&this.currentMeasure.FirstInstructionsStaffEntries[0]!==void 0){const b=this.currentMeasure.FirstInstructionsStaffEntries[0].Instructions;for(let S=0,v=b.length;S0&&(this.currentDynamicEntryIndex>=b.length||b[this.currentDynamicEntryIndex].parMultiExpression().AbsoluteTimestamp.gte(this.CurrentSourceTimestamp));)this.currentDynamicEntryIndex--;for(;this.currentDynamicEntryIndex0&&(this.currentTempoEntryIndex>=S.length||S[this.currentTempoEntryIndex].AbsoluteTimestamp.gte(this.CurrentSourceTimestamp));)this.currentTempoEntryIndex--;for(;this.currentTempoEntryIndex0){this.currentVoiceEntryIndex--;const b=this.currentMeasure.VerticalSourceStaffEntryContainers[this.currentVoiceEntryIndex];this.currentVoiceEntries=this.getVoiceEntries(b),this.currentVerticalContainerInMeasureTimestamp=b.Timestamp,this.currentRelativeInMeasureTimestamp=this.currentVerticalContainerInMeasureTimestamp,this.currentTimeStamp=l.Fraction.plus(this.currentMeasure.AbsoluteTimestamp,this.currentVerticalContainerInMeasureTimestamp),this.activateCurrentDynamicOrTempoInstructions();const S=this.musicSheet.SelectionEnd;return S&&this.currentTimeStamp.lt(S)&&(this.endReached=!1),void(this.currentMeasureIndex=this.musicSheet.SourceMeasures.indexOf(this.CurrentMeasure))}if(this.currentVoiceEntryIndex===0&&this.currentMeasureIndex!==0){const b=this.musicSheet.SourceMeasures[this.currentMeasureIndex-1];this.currentMeasureIndex--,this.currentMeasure=this.musicSheet.SourceMeasures[this.currentMeasureIndex];const S=b.VerticalSourceStaffEntryContainers[b.VerticalSourceStaffEntryContainers.length-1];this.currentVoiceEntries=this.getVoiceEntries(S),this.currentVerticalContainerInMeasureTimestamp=S.Timestamp,this.currentVoiceEntryIndex=b.VerticalSourceStaffEntryContainers.length-1,this.currentRelativeInMeasureTimestamp=this.currentVerticalContainerInMeasureTimestamp,this.currentTimeStamp=l.Fraction.plus(this.currentMeasure.AbsoluteTimestamp,S.Timestamp),this.activateCurrentDynamicOrTempoInstructions();const v=this.musicSheet.SelectionEnd;return void(v&&this.currentTimeStamp.lt(v)&&(this.endReached=!1))}this.frontReached=!0,this.currentTimeStamp=new l.Fraction(-1,1)}recursiveMove(){if(this.currentVoiceEntryIndex++,this.currentVoiceEntryIndex===0&&(this.handleRepetitionsAtMeasureBegin(),this.activateCurrentRhythmInstructions()),this.currentVoiceEntryIndex>=0&&this.currentVoiceEntryIndex=0&&this.currentMeasureIndex0){if(!b)return!0;for(let v=0,w=S.length;v0){const g=this.TimestampSortedTempoExpressionsList[0];if(g.InstantaneousTempo)return g.InstantaneousTempo.TempoInBpm;if(g.ContinuousTempo)return g.ContinuousTempo.StartTempo}return this.userStartTempoInBPM}get Errors(){return this.musicSheetErrors.measureErrors}get FirstMeasureNumber(){try{return this.getFirstSourceMeasure().MeasureNumber}catch(g){return b.default.info("MusicSheet.FirstMeasureNumber: ",g),0}}get LastMeasureNumber(){try{return this.getLastSourceMeasure().MeasureNumber}catch(g){return b.default.info("MusicSheet.LastMeasureNumber: ",g),0}}get CurrentEnrolledPosition(){return this.currentEnrolledPosition.clone()}set CurrentEnrolledPosition(g){this.currentEnrolledPosition=g.clone()}get Transpose(){return this.transpose}set Transpose(g){this.transpose=g}get FullNameString(){return this.ComposerString+" "+this.TitleString}get IdString(){return this.idString}set IdString(g){this.idString=g}getEnrolledSelectionStartTimeStampWorkaround(){const g=this.MusicPartManager.getIterator(this.SelectionStart);return l.Fraction.createFromFraction(g.CurrentEnrolledTimestamp)}get SheetEndTimestamp(){const g=this.getLastSourceMeasure();return l.Fraction.plus(g.AbsoluteTimestamp,g.Duration)}getSourceMeasureFromTimeStamp(g){for(let x=0,P=this.sourceMeasures.length;x0&&_.Voices[0].Visible&&g.push(_)}return g}}y.MusicSheet=w,w.defaultTitle="defaultTitle"},1325(St,y){Object.defineProperty(y,"__esModule",{value:!0}),y.MappingSourceMusicPart=void 0,y.MappingSourceMusicPart=class{constructor(p,d,l,m=-1,a=!1){this.repetitionRun=-1,this.sourceMusicPart=p,this.parentPartListEntry=l,this.startTimestamp=d.clone(),this.repetitionRun=m,this.parentRepetition=l,this.isEnding=a}get IsRepetition(){return this.parentRepetition!==void 0}get IsEnding(){return this.isEnding}get IsLastRepetitionRun(){return this.IsRepetition&&this.repetitionRun+1===this.parentRepetition.UserNumberOfRepetitions}get RepetitionRun(){return this.repetitionRun}get ParentPartListEntry(){return this.parentPartListEntry}get SourceMusicPart(){return this.sourceMusicPart}get StartTimestamp(){return this.startTimestamp}CompareTo(p){return p?this.startTimestamp.CompareTo(p.startTimestamp):1}}},7551(St,y){Object.defineProperty(y,"__esModule",{value:!0}),y.PartListEntry=void 0,y.PartListEntry=class{constructor(p){this.enrolledTimestamps=[],this.visible=!0,this.musicSheet=p}get Visible(){return this.visible}set Visible(p){this.visible=p}getFirstSourceMeasure(){return this.musicSheet.SourceMeasures[this.startIndex]}getLastSourceMeasure(){return this.musicSheet.SourceMeasures[this.endIndex]}}},6001(St,y,p){var d=this&&this.__importDefault||function(f){return f&&f.__esModule?f:{default:f}};Object.defineProperty(y,"__esModule",{value:!0}),y.RepetitionEndingPart=y.Repetition=void 0;const l=p(3457),m=p(2561),a=p(7551),s=d(p(3065));class h extends a.PartListEntry{constructor(r,b=!1){super(r),this.SkipRepetition=!1,this.userNumberOfRepetitions=0,this.backwardJumpInstructions=[],this.endingParts=[],this.endingIndexDict={},this.visibles=[],this.fromWords=!1,this.repetitonIterationOrder=[],this.numberOfEndings=1,this.musicSheet2=r,this.virtualOverallRepetition=b}get BackwardJumpInstructions(){return this.backwardJumpInstructions}get EndingIndexDict(){return this.endingIndexDict}get EndingParts(){return this.endingParts}get Visibles(){return this.visibles}set Visibles(r){this.visibles=r}get DefaultNumberOfRepetitions(){let r=2;return this.virtualOverallRepetition&&(r=1),Math.max(r,Object.keys(this.endingIndexDict).length,this.checkRepetitionForMultipleLyricVerses())}get UserNumberOfRepetitions(){return this.userNumberOfRepetitions}set UserNumberOfRepetitions(r){this.userNumberOfRepetitions=r,this.repetitonIterationOrder=[];const b=this.userNumberOfRepetitions-this.NumberOfEndings;for(let S=1;S<=this.userNumberOfRepetitions;S++)S<=b?this.repetitonIterationOrder.push(1):this.repetitonIterationOrder.push(S-b)}getForwardJumpTargetForIteration(r){const b=this.repetitonIterationOrder[r-1];return this.endingIndexDict[b]?this.endingIndexDict[b].part.StartIndex:-1}getBackwardJumpTarget(){return this.startMarker.measureIndex}setEndingsStartIndex(r,b){const S=new u(new l.SourceMusicPart(this.musicSheet2,b,b));this.endingParts.push(S);for(const v of r)try{this.endingIndexDict[v]=S,S.endingIndices.push(v),this.numberOfEndings=this.xmlMeasureList.length)return!1;this.currentMeasure=R,this.followingMultirestMeasures=Math.max(this.followingMultirestMeasures-1,0),this.inSourceMeasureInstrumentIndex=this.musicSheet.getGlobalStaffIndexOfFirstStaff(this.instrument),this.repetitionInstructionReader&&this.repetitionInstructionReader.prepareReadingMeasure(R,this.currentXmlMeasureIndex);let G=new u.Fraction(0,1),U=new u.Fraction(0,1),C=!1;this.maxTieNoteFraction=new u.Fraction(0,1);let z=!1;try{const rt=this.xmlMeasureList[this.currentXmlMeasureIndex],ct=rt.elements();let st;R.Rules.UseXMLMeasureNumbers&&!Number.isInteger(R.MeasureNumberXML)&&(st=parseInt((W=rt.attribute("number"))==null?void 0:W.value,10),Number.isInteger(st)&&(R.MeasureNumberXML=st));const at=rt.attribute("osmdWidthFactor");if(at){const lt=Number.parseFloat(at.value);typeof lt!="number"||isNaN(lt)?w.default.info(`xml parse: osmdWidthFactor invalid for measure ${st}`):R.WidthFactor=lt}let ht;for(let lt=0;lt0&&(ht=ct[lt-1]),O.name==="print"){const D=O.attribute("new-system");(D==null?void 0:D.value)==="yes"&&(R.printNewSystemXml=!0);const j=O.attribute("new-page");(j==null?void 0:j.value)==="yes"&&(R.printNewPageXml=!0)}else if(O.name==="attributes"){const D=O.element("divisions");if(D&&(this.divisions=parseInt(D.value,10),isNaN(this.divisions))){const J=f.ITextTranslation.translateText("ReaderErrorMessages/DivisionError","Invalid divisions value at Instrument: ");if(w.default.debug("InstrumentReader.readNextXmlMeasure",J),this.divisions=this.readDivisionsFromNotes(),!(this.divisions>0))throw C=!0,new r.MusicSheetReadingException(J+this.instrument.Name);this.musicSheet.SheetErrors.push(J+this.instrument.Name)}if(!O.element("divisions")&&this.divisions===0&&this.currentXmlMeasureIndex===0){const J=f.ITextTranslation.translateText("ReaderErrorMessages/DivisionError","Invalid divisions value at Instrument: ");if(this.divisions=this.readDivisionsFromNotes(),!(this.divisions>0))throw C=!0,new r.MusicSheetReadingException(J+this.instrument.Name);this.musicSheet.SheetErrors.push(J+this.instrument.Name)}this.addAbstractInstruction(O,A,ht,G.clone()),G.Equals(new u.Fraction(0,1))&&this.isAttributesNodeAtBeginOfMeasure(this.xmlMeasureList[this.currentXmlMeasureIndex],O)&&this.saveAbstractInstructionList(this.instrument.Staves.length,!0),this.isAttributesNodeAtEndOfMeasure(this.xmlMeasureList[this.currentXmlMeasureIndex],O,G)&&this.saveClefInstructionAtEndOfMeasure();const j=O.elements("staff-details");for(const J of j){const q=J.element("staff-lines");if(q){let et=1;const it=J.attribute("number");it&&(et=parseInt(it.value,10)),this.instrument.Staves[et-1].StafflineCount=parseInt(q.value,10)}}const Q=O.element("measure-style");if(Q){const J=Q.element("multiple-rest");if(J){const q=J.value;let et=0;try{et=Number.parseInt(q,10),R.multipleRestMeasures!==void 0&&et!==R.multipleRestMeasures?R.multipleRestMeasures=0:(R.multipleRestMeasures=et,this.currentMultirestStartMeasure=R,this.followingMultirestMeasures=et+1)}catch(it){console.log("multirest parse error: "+it)}}}}else if(O.name==="note"){let D=!0;(($=O.attribute("print-object"))==null?void 0:$.value)==="no"&&(D=!1);const j=this.getNoteStaff(O);this.currentStaff=this.instrument.Staves[j-1];const Q=O.element("chord")!==void 0;if(O.element("voice")){const Qt=parseInt(O.element("voice").value,10);this.currentVoiceGenerator=this.getOrCreateVoiceGenerator(Qt,j-1)}else Q&&this.currentVoiceGenerator||(this.currentVoiceGenerator=this.getOrCreateVoiceGenerator(1,j-1));let J,q=0,et=new u.Fraction(0,1),it=2;const dt=O.element("rest")!==void 0;if(O.element("duration")){if(this.divisions===0&&this.currentXmlMeasureIndex===0){if(this.divisions=this.readDivisionsFromNotes(),this.divisions===0){const Qt=f.ITextTranslation.translateText("ReaderErrorMessages/DivisionError","Invalid divisions value at Instrument: ");throw C=!0,new r.MusicSheetReadingException(Qt+this.instrument.Name)}this.musicSheet.SheetErrors.push(f.ITextTranslation.translateText("ReaderErrorMessages/DivisionError","Invalid divisions value at Instrument: ")+this.instrument.Name)}if(q=parseInt(O.element("duration").value,10),isNaN(q)){const Qt=f.ITextTranslation.translateText("ReaderErrorMessages/NoteDurationError","Invalid Note Duration.");this.musicSheet.SheetErrors.pushMeasureError(Qt),w.default.debug("InstrumentReader.readNextXmlMeasure",Qt);continue}if(et=new u.Fraction(q,4*this.divisions),dt&&et.RealValue>((N=this.ActiveRhythm)==null?void 0:N.Rhythm.RealValue)&&(et=this.ActiveRhythm.Rhythm.clone()),q===0?et=this.getNoteDurationFromTypeNode(O):J=this.getNoteDurationFromTypeNode(O),O.element("time-modification")){et=this.getNoteDurationForTuplet(O);const Qt=O.element("time-modification");Qt!=null&&Qt.element("normal-notes")&&(it=parseInt(Qt.element("normal-notes").value,10))}}const mt=O.combinedElement("notations"),yt=O.element("grace")!==void 0||q===0||Q&&z;let Et=!1,Dt=!1;if(yt){const Qt=O.element("grace");Qt&&Qt.attributes()&&Qt.attribute("slash")&&Qt.attribute("slash").value==="yes"&&(Et=!0),et=this.getNoteDurationFromTypeNode(O),mt&&mt.element("slur")&&(Dt=!0)}const[Vt,Nt]=this.getCueNoteAndNoteTypeXml(O),[It,Ct,zt]=this.getStemDirectionAndColors(O);let Xt;if(mt){const Qt=mt.element("ornaments");Qt&&(Xt=this.getTremoloInfo(Qt),this.getWavyLines(Qt,O,G,U))}const Ut=Q?U.clone():G.clone();this.currentStaffEntry=this.currentMeasure.findOrCreateStaffEntry(Ut,this.inSourceMeasureInstrumentIndex+j-1,this.currentStaff).staffEntry,(!this.currentVoiceGenerator.hasVoiceEntry()||!Q&&!yt&&!z||yt&&!z||yt&&!Q||!yt&&z)&&this.currentVoiceGenerator.createVoiceEntry(Ut,this.currentStaffEntry,!yt,yt,Et,Dt),yt||Q||(U=G.clone(),G.Add(et)),Q&&this.currentStaffEntry!==void 0&&this.currentStaffEntry.ParentStaff!==this.currentStaff&&(this.currentStaffEntry=this.currentVoiceGenerator.checkForStaffEntryLink(this.inSourceMeasureInstrumentIndex+j-1,this.currentStaff,this.currentStaffEntry,this.currentMeasure));const Kt=this.currentStaffEntry!==void 0&&this.currentStaffEntry.Timestamp!==void 0&&this.currentStaffEntry.Timestamp.Equals(new u.Fraction(0,1))&&!this.currentStaffEntry.hasNotes();this.saveAbstractInstructionList(this.instrument.Staves.length,Kt),this.activeRhythm;const qt=O.elements("dot").length;if(this.currentVoiceGenerator.read(O,et,J,Nt,it,dt,this.currentStaffEntry,this.currentMeasure,F,this.maxTieNoteFraction,Q,A,D,Vt,yt,It,Xt,Ct,zt,qt),mt!==void 0&&mt.element("dynamics")){const Qt=this.expressionReaders[this.readExpressionStaffNumber(O)-1];Qt&&(Qt.readExpressionParameters(O,this.instrument,this.divisions,G,U,this.currentMeasure.MeasureNumber,!1),Qt.read(O,this.currentMeasure,U))}z=yt}else if(O.name==="forward"){const D=parseInt(O.element("duration").value,10);G.Add(new u.Fraction(D,4*this.divisions))}else if(O.name==="backup"){const D=parseInt(O.element("duration").value,10);G.Sub(new u.Fraction(D,4*this.divisions)),G.IsNegative()&&(G=new u.Fraction(0,1)),U.Sub(new u.Fraction(D,4*this.divisions)),U.IsNegative()&&(U=new u.Fraction(0,1))}else if(O.name==="direction"){const D=O.elements("direction-type"),j=D[0];let Q=Math.min(1,G.RealValue);this.activeRhythm!==void 0&&this.activeRhythm.Rhythm&&(Q/=this.activeRhythm.Rhythm.RealValue);let J=!1;if(this.repetitionInstructionReader&&(J=this.repetitionInstructionReader.handleRepetitionInstructionsFromWordsOrSymbols(j,Q)),!J){let q=this.expressionReaders[0];const et=this.readExpressionStaffNumber(O)-1;if(etit.element("octave-shift"))){q.readExpressionParameters(O,this.instrument,this.divisions,G,U,this.currentMeasure.MeasureNumber,!0);let it,dt=0;(tt=(Y=this.currentStaffEntry)==null?void 0:Y.Timestamp)!=null&&tt.Equals(G)?(dt=this.currentStaffEntry.VoiceEntries.length,it=G.clone()):it=U.clone(),q.addOctaveShift(O,this.currentMeasure,it,dt)}D.some(it=>it.element("pedal"))&&(q.readExpressionParameters(O,this.instrument,this.divisions,G,U,this.currentMeasure.MeasureNumber,!0),q.addPedalMarking(O,this.currentMeasure,G.clone())),q.readExpressionParameters(O,this.instrument,this.divisions,G,U,this.currentMeasure.MeasureNumber,!1),q.read(O,this.currentMeasure,G,U.clone())}}}else if(O.name==="barline"){this.repetitionInstructionReader&&this.repetitionInstructionReader.handleLineRepetitionInstructions(O)&&(this.currentMeasure.HasEndLine=!0);const D=O.attribute("location"),j=(D==null?void 0:D.value)??"right";if(lt===ct.length-1||j==="right"){const Q=(H=O.element("bar-style"))==null?void 0:H.value;Q&&(this.currentMeasure.endingBarStyleXml=Q,this.currentMeasure.endingBarStyleEnum=k.SystemLinesEnumHelper.xmlBarlineStyleToSystemLinesEnum(Q))}}else if(O.name==="sound")try{if(O.attribute("tempo")){const D=parseFloat(O.attribute("tempo").value);this.currentXmlMeasureIndex===0&&(this.musicSheet.DefaultStartTempoInBpm=D,this.musicSheet.HasBPMInfo=!0)}}catch(D){w.default.debug("InstrumentReader.readTempoInstruction",D)}else if(O.name==="harmony"){const D=this.getNoteStaff(O);this.currentStaff=this.instrument.Staves[D-1];const j=G.clone();this.currentStaffEntry=this.currentMeasure.findOrCreateStaffEntry(j,this.inSourceMeasureInstrumentIndex+D-1,this.currentStaff).staffEntry,this.currentStaffEntry.ChordContainers.push(g.ChordSymbolReader.readChordSymbol(O,this.musicSheet,this.activeKey))}}for(const lt in this.voiceGeneratorsDict)this.voiceGeneratorsDict.hasOwnProperty(lt)&&this.voiceGeneratorsDict[lt].checkForOpenBeam();if(this.currentXmlMeasureIndex===this.xmlMeasureList.length-1){for(let lt=0;lt0?this.musicSheet.SourceMeasures[0]:this.currentMeasure;const A=new a.ClefInstruction(b.ClefEnum.G,0,2);let G;F.FirstInstructionsStaffEntries[R]?(G=F.FirstInstructionsStaffEntries[R],G.removeFirstInstructionOfTypeClefInstruction()):(G=new m.SourceStaffEntry(void 0,void 0),F.FirstInstructionsStaffEntries[R]=G),A.Parent=G,G.Instructions.splice(0,0,A)}createDefaultKeyInstruction(){let R;R=this.musicSheet.SourceMeasures.length>0?this.musicSheet.SourceMeasures[0]:this.currentMeasure;const F=new s.KeyInstruction(void 0,0,v.KeyEnum.major);for(let A=this.inSourceMeasureInstrumentIndex;A0&&A[G-1].name==="backup")return!0;let U=-1;for(let C=0;C0||U<0}isAttributesNodeAtEndOfMeasure(R,F,A){var z;if(A.Equals((z=this.ActiveRhythm)==null?void 0:z.Rhythm))return!0;const G=R.elements().slice();let U=0;for(let W=0;WC}getNoteDurationFromTypeNode(R){const F=R.element("type");if(F){const A=F.value;return B.NoteTypeHandler.getNoteDurationFromType(A)}return new u.Fraction(0,4*this.divisions)}addAbstractInstruction(R,F,A,G){if(R.element("divisions")&&R.elements().length===1)return;const U=R.element("transpose");if(U){const W=U.element("chromatic");W&&(this.instrument.PlaybackTranspose=parseInt(W.value,10))}const C=R.elements("clef");let z;if(C.length>0)for(let W=0,$=C.length;W<$;++W){const N=C[W];let Y=b.ClefEnum.G,tt=2,H=1,rt=0;const ct=N.element("line");if(ct)try{tt=parseInt(ct.value,10)}catch(lt){z=f.ITextTranslation.translateText("ReaderErrorMessages/ClefLineError","Invalid clef line. Using default."),this.musicSheet.SheetErrors.pushMeasureError(z),tt=2,w.default.debug("InstrumentReader.addAbstractInstruction",z,lt)}const st=N.element("sign");if(st)try{Y=b.ClefEnum[st.value],a.ClefInstruction.isSupportedClef(Y)||(z=f.ITextTranslation.translateText("ReaderErrorMessages/ClefError","Unsupported clef. Using default."),this.musicSheet.SheetErrors.pushMeasureError(z),Y=b.ClefEnum.G,tt=2),Y===b.ClefEnum.TAB&&(rt=-1)}catch(lt){z=f.ITextTranslation.translateText("ReaderErrorMessages/ClefError","Invalid clef. Using default."),this.musicSheet.SheetErrors.pushMeasureError(z),Y=b.ClefEnum.G,tt=2,w.default.debug("InstrumentReader.addAbstractInstruction",z,lt)}const at=N.element("clef-octave-change");if(at)try{rt=parseInt(at.value,10)}catch{z=f.ITextTranslation.translateText("ReaderErrorMessages/ClefOctaveError","Invalid clef octave. Using default."),this.musicSheet.SheetErrors.pushMeasureError(z),rt=0}if(N.hasAttributes&&N.attribute("number"))try{H=parseInt(N.attribute("number").value,10),H>this.currentClefNumber&&(H=this.currentClefNumber),this.currentClefNumber=H+1}catch{z=f.ITextTranslation.translateText("ReaderErrorMessages/ClefError","Invalid clef. Using default."),this.musicSheet.SheetErrors.pushMeasureError(z),H=1,this.currentClefNumber=H+1}const ht=new a.ClefInstruction(Y,rt,tt);this.abstractInstructions.push([H,ht,G])}if(R.element("key")!==void 0&&this.instrument.MidiInstrumentId!==T.MidiInstrument.Percussion){let W=0;const $=R.element("key").element("fifths");if($)try{W=parseInt($.value,10)}catch(H){z=f.ITextTranslation.translateText("ReaderErrorMessages/KeyError","Invalid key. Set to default."),this.musicSheet.SheetErrors.pushMeasureError(z),W=0,w.default.debug("InstrumentReader.addAbstractInstruction",z,H)}let N=v.KeyEnum.none,Y=R.element("key");if(Y&&(Y=Y.element("mode")),Y)try{N=v.KeyEnum[Y.value]}catch(H){z=f.ITextTranslation.translateText("ReaderErrorMessages/KeyError","Invalid key/mode. Set to default."),this.musicSheet.SheetErrors.pushMeasureError(z),N=v.KeyEnum.major,w.default.debug("InstrumentReader.addAbstractInstruction",z,H)}const tt=new s.KeyInstruction(void 0,W,N);this.abstractInstructions.push([1,tt,G])}if(R.element("time")){const W=R.element("time");let $=S.RhythmSymbolEnum.NONE,N=!0;if(W!==void 0&&W.hasAttributes){const at=W.attribute("symbol");at&&(at.value==="common"?$=S.RhythmSymbolEnum.COMMON:at.value==="cut"&&($=S.RhythmSymbolEnum.CUT));const ht=W.attribute("print-object");ht&&ht.value==="no"&&(N=!1)}let Y=0,tt=0;const H=W&&W.element("senza-misura")!==void 0,rt=R.elements("time"),ct=[],st=[];for(let at=0,ht=rt.length;at0&&st!==void 0&&ct.length===st.length){const ht=ct.length,lt=new Array(ht);let O=0;for(let D=0;D=0;A--){const G=this.abstractInstructions[A],U=G[0],C=G[1],z=G[2];if(C instanceof a.ClefInstruction){const W=C;if(this.currentXmlMeasureIndex===0||U<=this.activeClefs.length&&W!==this.activeClefs[U-1])if(F||this.currentStaffEntry===void 0||this.currentStaffEntry.hasNotes()||U-1!==this.instrument.Staves.indexOf(this.currentStaffEntry.ParentStaff))if(F){if(z.RealValue!==0)continue;let $;if(this.currentMeasure){const N=W,Y=this.inSourceMeasureInstrumentIndex+U-1,tt=this.currentMeasure.FirstInstructionsStaffEntries[Y];if(this.currentXmlMeasureIndex===0)if(tt)if(this.currentMeasure.FirstInstructionsStaffEntries[Y]===void 0||tt.Instructions[0]instanceof a.ClefInstruction){const H=new m.SourceStaffEntry(void 0,void 0);this.currentMeasure.LastInstructionsStaffEntries[Y]=H,N.Parent=H,H.Instructions.push(N)}else $=tt,N.Parent=$,$.removeFirstInstructionOfTypeClefInstruction(),$.Instructions.splice(0,0,N),this.activeClefsHaveBeenInitialized[U-1]=!0;else $=new m.SourceStaffEntry(void 0,void 0),this.currentMeasure.FirstInstructionsStaffEntries[Y]=$,N.Parent=$,$.Instructions.push(N),this.activeClefsHaveBeenInitialized[U-1]=!0;else if(this.activeClefsHaveBeenInitialized[U-1]){let H=this.previousMeasure;this.followingMultirestMeasures>0&&this.currentMeasure.Rules.RenderMultipleRestMeasures&&(H=this.currentMultirestStartMeasure);const rt=new m.SourceStaffEntry(void 0,void 0);H.LastInstructionsStaffEntries[Y]=rt,N.Parent=rt,rt.Instructions.push(N)}else{const H=this.musicSheet.SourceMeasures[0];H.FirstInstructionsStaffEntries[Y]?($=H.FirstInstructionsStaffEntries[Y],$.removeFirstInstructionOfTypeClefInstruction()):$=new m.SourceStaffEntry(void 0,void 0),N.Parent=$,$.Instructions.splice(0,0,N),this.activeClefsHaveBeenInitialized[U-1]=!0}this.activeClefs[U-1]=W,this.abstractInstructions.splice(A,1)}}else{let $;const N=this.activeRhythm.Rhythm;N.RealValue>0&&z.RealValue/N.RealValue>.9&&N.RealValue!==z.RealValue&&(this.currentMeasure.LastInstructionsStaffEntries[U-1]||(this.currentMeasure.LastInstructionsStaffEntries[U-1]=new m.SourceStaffEntry(void 0,this.instrument.Staves[U-1])),$=this.currentMeasure.LastInstructionsStaffEntries[U-1]),$&&(W.Parent=$,$.Instructions.push(W),this.activeClefs[U-1]=W,this.abstractInstructions.splice(A,1))}else{const $=W,N=this.currentStaffEntry;if(z&&Math.abs(z.RealValue-N.Timestamp.RealValue)>.01)continue;$.Parent=N,N.removeFirstInstructionOfTypeClefInstruction(),N.Instructions.push($),this.activeClefs[U-1]=W,this.abstractInstructions.splice(A,1)}else U<=this.activeClefs.length&&W===this.activeClefs[U-1]&&this.abstractInstructions.splice(A,1)}if(C instanceof s.KeyInstruction){const W=C;if(this.activeKey&&this.activeKey.Key===W.Key)this.abstractInstructions.splice(A,1);else{let $;if(this.activeKey=W,this.abstractInstructions.splice(A,1),this.activeKeyHasBeenInitialized?$=this.currentMeasure:(this.activeKeyHasBeenInitialized=!0,$=this.currentXmlMeasureIndex>0?this.musicSheet.SourceMeasures[0]:this.currentMeasure),$)for(let N=this.inSourceMeasureInstrumentIndex;N=0;R--){const F=this.abstractInstructions[R][0],A=this.abstractInstructions[R][1];if(A instanceof a.ClefInstruction){const G=A;if(!this.activeClefs[F-1]||G.ClefType!==this.activeClefs[F-1].ClefType||G.ClefType===this.activeClefs[F-1].ClefType&&G.Line!==this.activeClefs[F-1].Line){const U=new m.SourceStaffEntry(void 0,void 0);this.currentMeasure.LastInstructionsStaffEntries[this.inSourceMeasureInstrumentIndex+F-1]=U;const C=G;C.Parent=U,U.Instructions.push(C),this.activeClefs[F-1]=G,this.abstractInstructions.splice(R,1)}}}}getNoteDurationForTuplet(R){const F=R.element("duration"),A=Number.parseInt(F.value,10);return new u.Fraction(A,4*this.divisions)}readExpressionStaffNumber(R){let F=1;if(R.element("staff")){const A=R.element("staff");if(A)try{F=parseInt(A.value,10)}catch(G){const U=f.ITextTranslation.translateText("ReaderErrorMessages/ExpressionStaffError","Invalid Expression staff number. Set to default.");this.musicSheet.SheetErrors.pushMeasureError(U),F=1,w.default.debug("InstrumentReader.readExpressionStaffNumber",U,G)}}return F}readDivisionsFromNotes(){let R=0,F=this.currentXmlMeasureIndex,A=!1;for(;!A;){const G=this.xmlMeasureList[F].elements();for(let U=0,C=G.length;U0){A=!0;break}}if(R===0&&(F++,F===this.xmlMeasureList.length)){const U=f.ITextTranslation.translateText("ReaderErrorMEssages/DivisionsError","Invalid divisions value at Instrument: ");throw new r.MusicSheetReadingException(U+this.instrument.Name)}}return R}getCueNoteAndNoteTypeXml(R){let F=!1;R.element("cue")&&(F=!0);const A=R.element("type");let G=B.NoteType.UNDEFINED;if(A){const U=A.attribute("size");(U==null?void 0:U.value)==="cue"&&(F=!0),G=B.NoteTypeHandler.StringToNoteType(A.value)}return[F,G]}getStemDirectionType(R){switch(R.value){case"down":return _.StemDirectionType.Down;case"up":return _.StemDirectionType.Up;case"double":return _.StemDirectionType.Double;case"none":return _.StemDirectionType.None;default:return _.StemDirectionType.Undefined}}getNoteHeadColorXml(R){const F=R.element("notehead");if(F){const A=F.attribute("color");if(A)return this.parseXmlColor(A.value)}return null}getNoteColorXml(R){const F=R.attribute("color");return F?this.parseXmlColor(F.value):null}getTremoloInfo(R){let F,A;const G=R.element("tremolo");if(G){const U=G.attribute("type");if(U){if(U.value==="single"){const C=parseInt(G.value,10);C>0&&(F=C)}else F=0;U.value==="unmeasured"&&(A=!0)}}return{tremoloStrokes:F,tremoloUnmeasured:A}}getWavyLines(R,F,A,G){const U=R.elements("wavy-line");if(U)for(const C of U){const z=this.expressionReaders[this.readExpressionStaffNumber(F)-1];z&&(z.readExpressionParameters(C,this.instrument,this.divisions,A,G,this.currentMeasure.MeasureNumber,!1),z.addWavyLine(C,this.currentMeasure,A,G))}}getNoteStaff(R){let F=1;return this.instrument.Staves.length>1&&R.element("staff")&&(F=parseInt(R.element("staff").value,10),isNaN(F)&&(w.default.debug("InstrumentReader.readNextXmlMeasure.get staff number"),F=1)),F}}},9099(St,y,p){var d=this&&this.__importDefault||function(R){return R&&R.__esModule?R:{default:R}};Object.defineProperty(y,"__esModule",{value:!0}),y.MusicSheetReader=void 0;const l=p(427),m=p(4387),a=p(2561),s=p(1272),h=p(9252),u=p(9767),f=p(7307),r=d(p(3065)),b=p(9288),S=p(9288),v=p(2369),w=p(7586),T=p(5294),g=p(164),x=p(7435),P=p(5749),_=p(9713),B=p(7503),k=p(7533);y.MusicSheetReader=class{constructor(R=void 0,F=new _.EngravingRules){this.completeNumberOfStaves=0,this.pluginManager=new B.ReaderPluginManager,this.afterSheetReadingModules=R||[],this.repetitionInstructionReader=P.MusicSymbolModuleFactory.createRepetitionInstructionReader(),this.repetitionCalculator=P.MusicSymbolModuleFactory.createRepetitionCalculator(),this.rules=F}get PluginManager(){return this.pluginManager}get CompleteNumberOfStaves(){return this.completeNumberOfStaves}static doCalculationsAfterDurationHasBeenSet(R){for(const F of R)F.doCalculationsAfterDurationHasBeenSet()}createMusicSheet(R,F){try{return this._createMusicSheet(R,F)}catch(A){return void r.default.error("MusicSheetReader.CreateMusicSheet",A)}}_removeFromArray(R,F){const A=R.indexOf(F);A!==-1&&R.splice(A,1)}trimString(R){return R.replace(/^\s+|\s+$/g,"")}_lastElement(R){return R[R.length-1]}_createMusicSheet(R,F){const A=[];let G=0;this.musicSheet=new l.MusicSheet,this.musicSheet.Path=F,this.musicSheet.Rules=this.rules;const U=R.attribute("osmdMeasureWidthFactor");if(U){const tt=Number.parseFloat(U.value);typeof tt!="number"||isNaN(tt)?r.default.info("xml parse: osmdMeasureWidthFactor invalid"):this.musicSheet.MeasureWidthFactor=tt}if(!R)throw new f.MusicSheetReadingException("Undefined root element");this.pushSheetLabels(R,F);const C=R.element("part-list");if(!C)throw new f.MusicSheetReadingException("Undefined partListNode");const z=R.elements("part"),W=C.elements();this.initializeReading(W,z,A);let $=!0;this.currentFraction=new a.Fraction(0,1);let N=!1,Y=R.element("identification");for(Y&&(Y=Y.element("encoding")),Y&&(Y=Y.element("software")),Y!==void 0&&Y.value==="Guitar Pro 5"&&(N=!0);$;){this.currentMeasure!==void 0&&this.currentMeasure.HasEndLine&&this.rules.NewPartAndSystemAfterFinalBarline&&(G=0),this.currentMeasure=new m.SourceMeasure(this.completeNumberOfStaves,this.musicSheet.Rules);for(const tt of A)try{$=$&&tt.readNextXmlMeasure(this.currentMeasure,this.currentFraction,N)}catch(H){const rt=u.ITextTranslation.translateText("ReaderErrorMessages/InstrumentError","Error while reading instruments.");throw new f.MusicSheetReadingException(rt,H)}$&&(this.musicSheet.addMeasure(this.currentMeasure),this.checkIfRhythmInstructionsAreSetAndEqual(A),this.checkSourceMeasureForNullEntries(),G=this.setSourceMeasureDuration(A,G),this.currentMeasure.AbsoluteTimestamp=this.currentFraction.clone(),this.musicSheet.SheetErrors.finalizeMeasure(this.currentMeasure.MeasureNumber),this.currentFraction.Add(this.currentMeasure.Duration),this.previousMeasure=this.currentMeasure)}this.repetitionInstructionReader&&(this.repetitionInstructionReader.removeRedundantInstructions(),this.repetitionCalculator&&this.repetitionCalculator.calculateRepetitions(this.musicSheet,this.repetitionInstructionReader.repetitionInstructions)),this.musicSheet.checkForInstrumentWithNoVoice(),this.musicSheet.fillStaffList();for(let tt=0,H=this.afterSheetReadingModules.length;ttA){if(this.areRhythmInstructionsMixed(F)&&z.SymbolEnum!==S.RhythmSymbolEnum.NONE)continue;A=z.Rhythm.RealValue,G=F.indexOf(z)}}if(F.length>0&&F.length0)&&F++,this.currentMeasure.Duration=C,this.currentMeasure.ActiveTimeSignature=A,this.currentMeasure.MeasureNumber=F;for(let z=0;zR.Denominator){const A=F.Denominator/R.Denominator;R.expand(A)}}checkIfMeasureIsImplicit(R,F){return!(this.previousMeasure||!R.lt(F))||!!this.previousMeasure&&a.Fraction.plus(this.previousMeasure.Duration,R).Equals(F)}allInstrumentsHaveSameDuration(R,F){let A=0;for(let G=0,U=R.length;G=0;R--)for(let F=this.currentMeasure.VerticalSourceStaffEntryContainers[R].StaffEntries.length-1;F>=0;F--){const A=this.currentMeasure.VerticalSourceStaffEntryContainers[R].StaffEntries[F];if(A)for(let G=A.VoiceEntries.length-1;G>=0;G--){const U=A.VoiceEntries[G];U.Notes.length===0&&(this._removeFromArray(U.ParentVoice.VoiceEntries,U),this._removeFromArray(A.VoiceEntries,U))}A!==void 0&&A.VoiceEntries.length===0&&A.ChordContainers.length===0&&(this.currentMeasure.VerticalSourceStaffEntryContainers[R].StaffEntries[F]=void 0)}for(let R=this.currentMeasure.VerticalSourceStaffEntryContainers.length-1;R>=0;R--){let F=0;for(let A=0,G=this.currentMeasure.VerticalSourceStaffEntryContainers[R].StaffEntries.length;A0){const A=F[0].elements("rights");if(A.length>0)for(let G=0,U=A.length;GF||at)if(A||at){if(ct||O==="right")U?U+=` +`+B.getProgramInfoLog(F)),B.deleteProgram(F),new Error("WebGL program link failed");return F})(P,f(P,P.VERTEX_SHADER,o.default),f(P,P.FRAGMENT_SHADER,(function(B,k){let R=B;for(const[F,A]of Object.entries(k)){const G=new RegExp(`#define ${F} .*`);R=R.replace(G,`#define ${F} ${A}`)}return R})(s.default,{NUM_ROWS:g,ELEMENT_HEIGHT:w})));(function(B,k){const R=B.createBuffer();if(!R)throw h.default.warn("WebGLSkyBottomLineCalculatorBackend: WebGL buffer creation failed"),new Error("WebGL buffer creation failed");B.bindBuffer(B.ARRAY_BUFFER,R),B.bufferData(B.ARRAY_BUFFER,new Float32Array(u.CollectionUtil.flat([[-1,-1],[1,-1],[1,1],[-1,-1],[1,1],[-1,1]])),B.STATIC_DRAW),B.useProgram(k);const F=B.getAttribLocation(k,"a_position");B.enableVertexAttribArray(F),B.vertexAttribPointer(F,2,B.FLOAT,!1,0,0)})(P,_),this.texture=(function(B,k){const R=B.createTexture();if(!R)throw h.default.warn("WebGLSkyBottomLineCalculatorBackend: WebGL texture creation failed"),new Error("WebGL texture creation failed");B.activeTexture(B.TEXTURE0+0),B.bindTexture(B.TEXTURE_2D,R),B.texParameteri(B.TEXTURE_2D,B.TEXTURE_WRAP_S,B.CLAMP_TO_EDGE),B.texParameteri(B.TEXTURE_2D,B.TEXTURE_WRAP_T,B.CLAMP_TO_EDGE),B.texParameteri(B.TEXTURE_2D,B.TEXTURE_MIN_FILTER,B.NEAREST),B.texParameteri(B.TEXTURE_2D,B.TEXTURE_MAG_FILTER,B.NEAREST);const F=B.getUniformLocation(k,"u_image");if(!F)throw h.default.warn("WebGLSkyBottomLineCalculatorBackend: WebGL invalid uniform name"),new Error("WebGL invalid uniform name");return B.uniform1i(F,0),R})(P,_)}calculateFromCanvas(S,v,w,T,g){const x=this.gl,{elementWidth:P,elementHeight:_,numColumns:B}=g;x.viewport(0,0,x.canvas.width,x.canvas.height),x.bindTexture(x.TEXTURE_2D,this.texture),x.texImage2D(x.TEXTURE_2D,0,x.RGBA,x.RGBA,x.UNSIGNED_BYTE,S),x.drawArrays(x.TRIANGLES,0,6);const k=new Uint8Array(x.canvas.width*x.canvas.height*4);x.readPixels(0,0,x.canvas.width,x.canvas.height,x.RGBA,x.UNSIGNED_BYTE,k);const R=[];for(let F=0;F0&&this.Voices[0].Visible}isVisible(){if(!this.Visible)return!1;for(const h of this.Staves)if(h.Visible)return!0;return!1}set Visible(h){for(let u=0,f=this.Voices.length;u=0;h--)if(s=this.timestamps[h],o.gte(s.$from))return s;return this.timestamps[0]}absoluteEnrolledToSheetTimestamp(o){if(this.timestamps.length===0)return o;const s=this.getCurrentRepetitionTimestampTransform(o);return d.Fraction.plus(o,d.Fraction.minus(s.to,s.$from))}get Parts(){return this.parts}get MusicSheet(){return this.musicSheet}getIterator(o){return o?new l.MusicPartManagerIterator(this.musicSheet,o,void 0):new l.MusicPartManagerIterator(this.musicSheet,this.musicSheet.SelectionStart,this.musicSheet.SelectionEnd)}setSelectionStart(o){this.musicSheet.SelectionStart=o,this.musicSheet.SelectionEnd=void 0}setSelectionRange(o,s){this.musicSheet.SelectionStart=o??this.sheetStart,this.musicSheet.SelectionEnd=s??this.sheetEnd}calcMapping(){const o=[],s=this.getIterator();let h=s.CurrentRepetition,u=new m(s.CurrentEnrolledTimestamp.clone(),s.CurrentSourceTimestamp.clone(),void 0,0);for(o.push(u);!s.EndReached;){if(s.JumpOccurred||h!==s.CurrentRepetition){if(h=s.CurrentRepetition,s.backJumpOccurred){const f=s.JumpResponsibleRepetition;u.nextBackJump=s.CurrentEnrolledTimestamp,u.curRepetition=f,u.curRepetitionIteration=s.CurrentJumpResponsibleRepetitionIterationBeforeJump;for(let r=this.timestamps.length-2;r>=0&&!o[r].to.lt(f.AbsoluteTimestamp)&&!o[r].curRepetition;r--)o[r].nextBackJump=u.nextBackJump,o[r].curRepetition=f,o[r].curRepetitionIteration=u.curRepetitionIteration}u=new m(s.CurrentEnrolledTimestamp.clone(),s.CurrentSourceTimestamp.clone(),void 0,0),o.push(u)}s.moveToNext()}this.timestamps=o}};class m{constructor(s,h,u,f){this.$from=s,this.to=h,this.curRepetition=u,this.curRepetitionIteration=f,this.nextBackJump=void 0,this.nextForwardJump=void 0}}y.TimestampTransform=m},474(St,y,p){var d=this&&this.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(y,"__esModule",{value:!0}),y.MusicPartManagerIterator=void 0;const l=p(2561),m=p(1110),o=p(9288),s=p(5875),h=d(p(3065)),u=p(4064);class f{constructor(b,S,v){this.currentMeasureIndex=0,this.currentPartIndex=0,this.currentVoiceEntryIndex=-1,this.currentDynamicEntryIndex=0,this.currentTempoEntryIndex=0,this.currentDynamicChangingExpressions=[],this.repetitionIterationCountDictKeys=[],this.repetitionIterationCountDictValues=[],this.currentRepetition=void 0,this.endReached=!1,this.frontReached=!1,this.currentTimeStamp=new l.Fraction(0,1),this.currentEnrolledMeasureTimestamp=new l.Fraction(0,1),this.currentRelativeInMeasureTimestamp=new l.Fraction(0,1),this.currentVerticalContainerInMeasureTimestamp=new l.Fraction(0,1),this.jumpResponsibleRepetition=void 0,this.activeDynamicExpressions=[],this.SkipInvisibleNotes=!0;try{this.frontReached=!0,this.musicSheet=b,this.currentBpm=b.userStartTempoInBPM,this.currentVoiceEntries=void 0,this.frontReached=!1;for(const w of this.musicSheet.Repetitions)this.setRepetitionIterationCount(w,1);for(let w=0;w0&&(this.currentBpm=S)}else this.musicSheet.IgnoreTempoInstructions||(b=this.CurrentTempoChangingExpression.InstantaneousTempo)!=null&&b.TempoInBpm&&(this.currentBpm=this.CurrentTempoChangingExpression.InstantaneousTempo.TempoInBpm)}moveToNextVisibleVoiceEntry(b){for(;!this.endReached;)if(this.moveToNext(),this.checkEntries(b))return}resetRepetitionIterationCount(b){return this.setRepetitionIterationCount(b,1),1}incrementRepetitionIterationCount(b){return this.repetitionIterationCountDictKeys.indexOf(b)===-1?this.setRepetitionIterationCount(b,1):this.setRepetitionIterationCount(b,this.getRepetitionIterationCount(b)+1)}setRepetitionIterationCount(b,S){const v=this.repetitionIterationCountDictKeys.indexOf(b);return v===-1?(this.repetitionIterationCountDictKeys.push(b),this.repetitionIterationCountDictValues.push(S)):this.repetitionIterationCountDictValues[v]=S,S}getRepetitionIterationCount(b){const S=this.repetitionIterationCountDictKeys.indexOf(b);if(S!==-1)return this.repetitionIterationCountDictValues[S]}handleRepetitionsAtMeasureBegin(){for(let b=0,S=this.currentMeasure.FirstRepetitionInstructions.length;b=this.JumpResponsibleRepetition.StartIndex&&w.EndIndex<=this.JumpResponsibleRepetition.EndIndex&&this.resetRepetitionIterationCount(w)}}handleRepetitionsAtMeasureEnd(){for(let b=0,S=this.currentMeasure.LastRepetitionInstructions.length;b-1&&this.getRepetitionIterationCount(w)=this.JumpResponsibleRepetition.StartIndex&&w.EndIndex<=this.JumpResponsibleRepetition.EndIndex&&this.resetRepetitionIterationCount(w),this.repetitionIterationCountDictKeys.contains(w))){const T=w.getForwardJumpTargetForIteration(this.getRepetitionIterationCount(w));if(T>=0)return this.currentMeasureIndex=T,this.currentMeasure=this.musicSheet.SourceMeasures[this.currentMeasureIndex],this.currentVoiceEntryIndex=-1,this.jumpResponsibleRepetition=w,void(this.forwardJumpOccurred=!0);T===-2&&(this.endReached=!0)}}}this.currentMeasureIndex++,this.JumpResponsibleRepetition!==void 0&&this.currentMeasureIndex>this.JumpResponsibleRepetition.EndIndex&&(this.jumpResponsibleRepetition=void 0)}doBackJump(b){b.SkipRepetition||this.musicSheet.Rules.CursorIgnoreRepetitions||(this.currentMeasureIndex=b.getBackwardJumpTarget(),this.currentMeasure=this.musicSheet.SourceMeasures[this.currentMeasureIndex],this.currentVoiceEntryIndex=-1,this.incrementRepetitionIterationCount(b),this.jumpResponsibleRepetition=b,this.backJumpOccurred=!0)}activateCurrentRhythmInstructions(){if(this.currentMeasure!==void 0&&this.currentMeasure.FirstInstructionsStaffEntries.length>0&&this.currentMeasure.FirstInstructionsStaffEntries[0]!==void 0){const b=this.currentMeasure.FirstInstructionsStaffEntries[0].Instructions;for(let S=0,v=b.length;S0&&(this.currentDynamicEntryIndex>=b.length||b[this.currentDynamicEntryIndex].parMultiExpression().AbsoluteTimestamp.gte(this.CurrentSourceTimestamp));)this.currentDynamicEntryIndex--;for(;this.currentDynamicEntryIndex0&&(this.currentTempoEntryIndex>=S.length||S[this.currentTempoEntryIndex].AbsoluteTimestamp.gte(this.CurrentSourceTimestamp));)this.currentTempoEntryIndex--;for(;this.currentTempoEntryIndex0){this.currentVoiceEntryIndex--;const b=this.currentMeasure.VerticalSourceStaffEntryContainers[this.currentVoiceEntryIndex];this.currentVoiceEntries=this.getVoiceEntries(b),this.currentVerticalContainerInMeasureTimestamp=b.Timestamp,this.currentRelativeInMeasureTimestamp=this.currentVerticalContainerInMeasureTimestamp,this.currentTimeStamp=l.Fraction.plus(this.currentMeasure.AbsoluteTimestamp,this.currentVerticalContainerInMeasureTimestamp),this.activateCurrentDynamicOrTempoInstructions();const S=this.musicSheet.SelectionEnd;return S&&this.currentTimeStamp.lt(S)&&(this.endReached=!1),void(this.currentMeasureIndex=this.musicSheet.SourceMeasures.indexOf(this.CurrentMeasure))}if(this.currentVoiceEntryIndex===0&&this.currentMeasureIndex!==0){const b=this.musicSheet.SourceMeasures[this.currentMeasureIndex-1];this.currentMeasureIndex--,this.currentMeasure=this.musicSheet.SourceMeasures[this.currentMeasureIndex];const S=b.VerticalSourceStaffEntryContainers[b.VerticalSourceStaffEntryContainers.length-1];this.currentVoiceEntries=this.getVoiceEntries(S),this.currentVerticalContainerInMeasureTimestamp=S.Timestamp,this.currentVoiceEntryIndex=b.VerticalSourceStaffEntryContainers.length-1,this.currentRelativeInMeasureTimestamp=this.currentVerticalContainerInMeasureTimestamp,this.currentTimeStamp=l.Fraction.plus(this.currentMeasure.AbsoluteTimestamp,S.Timestamp),this.activateCurrentDynamicOrTempoInstructions();const v=this.musicSheet.SelectionEnd;return void(v&&this.currentTimeStamp.lt(v)&&(this.endReached=!1))}this.frontReached=!0,this.currentTimeStamp=new l.Fraction(-1,1)}recursiveMove(){if(this.currentVoiceEntryIndex++,this.currentVoiceEntryIndex===0&&(this.handleRepetitionsAtMeasureBegin(),this.activateCurrentRhythmInstructions()),this.currentVoiceEntryIndex>=0&&this.currentVoiceEntryIndex=0&&this.currentMeasureIndex0){if(!b)return!0;for(let v=0,w=S.length;v0){const g=this.TimestampSortedTempoExpressionsList[0];if(g.InstantaneousTempo)return g.InstantaneousTempo.TempoInBpm;if(g.ContinuousTempo)return g.ContinuousTempo.StartTempo}return this.userStartTempoInBPM}get Errors(){return this.musicSheetErrors.measureErrors}get FirstMeasureNumber(){try{return this.getFirstSourceMeasure().MeasureNumber}catch(g){return b.default.info("MusicSheet.FirstMeasureNumber: ",g),0}}get LastMeasureNumber(){try{return this.getLastSourceMeasure().MeasureNumber}catch(g){return b.default.info("MusicSheet.LastMeasureNumber: ",g),0}}get CurrentEnrolledPosition(){return this.currentEnrolledPosition.clone()}set CurrentEnrolledPosition(g){this.currentEnrolledPosition=g.clone()}get Transpose(){return this.transpose}set Transpose(g){this.transpose=g}get FullNameString(){return this.ComposerString+" "+this.TitleString}get IdString(){return this.idString}set IdString(g){this.idString=g}getEnrolledSelectionStartTimeStampWorkaround(){const g=this.MusicPartManager.getIterator(this.SelectionStart);return l.Fraction.createFromFraction(g.CurrentEnrolledTimestamp)}get SheetEndTimestamp(){const g=this.getLastSourceMeasure();return l.Fraction.plus(g.AbsoluteTimestamp,g.Duration)}getSourceMeasureFromTimeStamp(g){for(let x=0,P=this.sourceMeasures.length;x0&&_.Voices[0].Visible&&g.push(_)}return g}}y.MusicSheet=w,w.defaultTitle="defaultTitle"},1325(St,y){Object.defineProperty(y,"__esModule",{value:!0}),y.MappingSourceMusicPart=void 0,y.MappingSourceMusicPart=class{constructor(p,d,l,m=-1,o=!1){this.repetitionRun=-1,this.sourceMusicPart=p,this.parentPartListEntry=l,this.startTimestamp=d.clone(),this.repetitionRun=m,this.parentRepetition=l,this.isEnding=o}get IsRepetition(){return this.parentRepetition!==void 0}get IsEnding(){return this.isEnding}get IsLastRepetitionRun(){return this.IsRepetition&&this.repetitionRun+1===this.parentRepetition.UserNumberOfRepetitions}get RepetitionRun(){return this.repetitionRun}get ParentPartListEntry(){return this.parentPartListEntry}get SourceMusicPart(){return this.sourceMusicPart}get StartTimestamp(){return this.startTimestamp}CompareTo(p){return p?this.startTimestamp.CompareTo(p.startTimestamp):1}}},7551(St,y){Object.defineProperty(y,"__esModule",{value:!0}),y.PartListEntry=void 0,y.PartListEntry=class{constructor(p){this.enrolledTimestamps=[],this.visible=!0,this.musicSheet=p}get Visible(){return this.visible}set Visible(p){this.visible=p}getFirstSourceMeasure(){return this.musicSheet.SourceMeasures[this.startIndex]}getLastSourceMeasure(){return this.musicSheet.SourceMeasures[this.endIndex]}}},6001(St,y,p){var d=this&&this.__importDefault||function(f){return f&&f.__esModule?f:{default:f}};Object.defineProperty(y,"__esModule",{value:!0}),y.RepetitionEndingPart=y.Repetition=void 0;const l=p(3457),m=p(2561),o=p(7551),s=d(p(3065));class h extends o.PartListEntry{constructor(r,b=!1){super(r),this.SkipRepetition=!1,this.userNumberOfRepetitions=0,this.backwardJumpInstructions=[],this.endingParts=[],this.endingIndexDict={},this.visibles=[],this.fromWords=!1,this.repetitonIterationOrder=[],this.numberOfEndings=1,this.musicSheet2=r,this.virtualOverallRepetition=b}get BackwardJumpInstructions(){return this.backwardJumpInstructions}get EndingIndexDict(){return this.endingIndexDict}get EndingParts(){return this.endingParts}get Visibles(){return this.visibles}set Visibles(r){this.visibles=r}get DefaultNumberOfRepetitions(){let r=2;return this.virtualOverallRepetition&&(r=1),Math.max(r,Object.keys(this.endingIndexDict).length,this.checkRepetitionForMultipleLyricVerses())}get UserNumberOfRepetitions(){return this.userNumberOfRepetitions}set UserNumberOfRepetitions(r){this.userNumberOfRepetitions=r,this.repetitonIterationOrder=[];const b=this.userNumberOfRepetitions-this.NumberOfEndings;for(let S=1;S<=this.userNumberOfRepetitions;S++)S<=b?this.repetitonIterationOrder.push(1):this.repetitonIterationOrder.push(S-b)}getForwardJumpTargetForIteration(r){const b=this.repetitonIterationOrder[r-1];return this.endingIndexDict[b]?this.endingIndexDict[b].part.StartIndex:-1}getBackwardJumpTarget(){return this.startMarker.measureIndex}setEndingsStartIndex(r,b){const S=new u(new l.SourceMusicPart(this.musicSheet2,b,b));this.endingParts.push(S);for(const v of r)try{this.endingIndexDict[v]=S,S.endingIndices.push(v),this.numberOfEndings=this.xmlMeasureList.length)return!1;this.currentMeasure=R,this.followingMultirestMeasures=Math.max(this.followingMultirestMeasures-1,0),this.inSourceMeasureInstrumentIndex=this.musicSheet.getGlobalStaffIndexOfFirstStaff(this.instrument),this.repetitionInstructionReader&&this.repetitionInstructionReader.prepareReadingMeasure(R,this.currentXmlMeasureIndex);let G=new u.Fraction(0,1),U=new u.Fraction(0,1),C=!1;this.maxTieNoteFraction=new u.Fraction(0,1);let z=!1;try{const rt=this.xmlMeasureList[this.currentXmlMeasureIndex],ct=rt.elements();let st;R.Rules.UseXMLMeasureNumbers&&!Number.isInteger(R.MeasureNumberXML)&&(st=parseInt((W=rt.attribute("number"))==null?void 0:W.value,10),Number.isInteger(st)&&(R.MeasureNumberXML=st));const ot=rt.attribute("osmdWidthFactor");if(ot){const lt=Number.parseFloat(ot.value);typeof lt!="number"||isNaN(lt)?w.default.info(`xml parse: osmdWidthFactor invalid for measure ${st}`):R.WidthFactor=lt}let ht;for(let lt=0;lt0&&(ht=ct[lt-1]),O.name==="print"){const D=O.attribute("new-system");(D==null?void 0:D.value)==="yes"&&(R.printNewSystemXml=!0);const j=O.attribute("new-page");(j==null?void 0:j.value)==="yes"&&(R.printNewPageXml=!0)}else if(O.name==="attributes"){const D=O.element("divisions");if(D&&(this.divisions=parseInt(D.value,10),isNaN(this.divisions))){const J=f.ITextTranslation.translateText("ReaderErrorMessages/DivisionError","Invalid divisions value at Instrument: ");if(w.default.debug("InstrumentReader.readNextXmlMeasure",J),this.divisions=this.readDivisionsFromNotes(),!(this.divisions>0))throw C=!0,new r.MusicSheetReadingException(J+this.instrument.Name);this.musicSheet.SheetErrors.push(J+this.instrument.Name)}if(!O.element("divisions")&&this.divisions===0&&this.currentXmlMeasureIndex===0){const J=f.ITextTranslation.translateText("ReaderErrorMessages/DivisionError","Invalid divisions value at Instrument: ");if(this.divisions=this.readDivisionsFromNotes(),!(this.divisions>0))throw C=!0,new r.MusicSheetReadingException(J+this.instrument.Name);this.musicSheet.SheetErrors.push(J+this.instrument.Name)}this.addAbstractInstruction(O,A,ht,G.clone()),G.Equals(new u.Fraction(0,1))&&this.isAttributesNodeAtBeginOfMeasure(this.xmlMeasureList[this.currentXmlMeasureIndex],O)&&this.saveAbstractInstructionList(this.instrument.Staves.length,!0),this.isAttributesNodeAtEndOfMeasure(this.xmlMeasureList[this.currentXmlMeasureIndex],O,G)&&this.saveClefInstructionAtEndOfMeasure();const j=O.elements("staff-details");for(const J of j){const q=J.element("staff-lines");if(q){let et=1;const it=J.attribute("number");it&&(et=parseInt(it.value,10)),this.instrument.Staves[et-1].StafflineCount=parseInt(q.value,10)}}const Q=O.element("measure-style");if(Q){const J=Q.element("multiple-rest");if(J){const q=J.value;let et=0;try{et=Number.parseInt(q,10),R.multipleRestMeasures!==void 0&&et!==R.multipleRestMeasures?R.multipleRestMeasures=0:(R.multipleRestMeasures=et,this.currentMultirestStartMeasure=R,this.followingMultirestMeasures=et+1)}catch(it){console.log("multirest parse error: "+it)}}}}else if(O.name==="note"){let D=!0;(($=O.attribute("print-object"))==null?void 0:$.value)==="no"&&(D=!1);const j=this.getNoteStaff(O);this.currentStaff=this.instrument.Staves[j-1];const Q=O.element("chord")!==void 0;if(O.element("voice")){const Qt=parseInt(O.element("voice").value,10);this.currentVoiceGenerator=this.getOrCreateVoiceGenerator(Qt,j-1)}else Q&&this.currentVoiceGenerator||(this.currentVoiceGenerator=this.getOrCreateVoiceGenerator(1,j-1));let J,q=0,et=new u.Fraction(0,1),it=2;const dt=O.element("rest")!==void 0;if(O.element("duration")){if(this.divisions===0&&this.currentXmlMeasureIndex===0){if(this.divisions=this.readDivisionsFromNotes(),this.divisions===0){const Qt=f.ITextTranslation.translateText("ReaderErrorMessages/DivisionError","Invalid divisions value at Instrument: ");throw C=!0,new r.MusicSheetReadingException(Qt+this.instrument.Name)}this.musicSheet.SheetErrors.push(f.ITextTranslation.translateText("ReaderErrorMessages/DivisionError","Invalid divisions value at Instrument: ")+this.instrument.Name)}if(q=parseInt(O.element("duration").value,10),isNaN(q)){const Qt=f.ITextTranslation.translateText("ReaderErrorMessages/NoteDurationError","Invalid Note Duration.");this.musicSheet.SheetErrors.pushMeasureError(Qt),w.default.debug("InstrumentReader.readNextXmlMeasure",Qt);continue}if(et=new u.Fraction(q,4*this.divisions),dt&&et.RealValue>((N=this.ActiveRhythm)==null?void 0:N.Rhythm.RealValue)&&(et=this.ActiveRhythm.Rhythm.clone()),q===0?et=this.getNoteDurationFromTypeNode(O):J=this.getNoteDurationFromTypeNode(O),O.element("time-modification")){et=this.getNoteDurationForTuplet(O);const Qt=O.element("time-modification");Qt!=null&&Qt.element("normal-notes")&&(it=parseInt(Qt.element("normal-notes").value,10))}}const mt=O.combinedElement("notations"),yt=O.element("grace")!==void 0||q===0||Q&&z;let Et=!1,Dt=!1;if(yt){const Qt=O.element("grace");Qt&&Qt.attributes()&&Qt.attribute("slash")&&Qt.attribute("slash").value==="yes"&&(Et=!0),et=this.getNoteDurationFromTypeNode(O),mt&&mt.element("slur")&&(Dt=!0)}const[Vt,Nt]=this.getCueNoteAndNoteTypeXml(O),[It,Ct,zt]=this.getStemDirectionAndColors(O);let Xt;if(mt){const Qt=mt.element("ornaments");Qt&&(Xt=this.getTremoloInfo(Qt),this.getWavyLines(Qt,O,G,U))}const Ut=Q?U.clone():G.clone();this.currentStaffEntry=this.currentMeasure.findOrCreateStaffEntry(Ut,this.inSourceMeasureInstrumentIndex+j-1,this.currentStaff).staffEntry,(!this.currentVoiceGenerator.hasVoiceEntry()||!Q&&!yt&&!z||yt&&!z||yt&&!Q||!yt&&z)&&this.currentVoiceGenerator.createVoiceEntry(Ut,this.currentStaffEntry,!yt,yt,Et,Dt),yt||Q||(U=G.clone(),G.Add(et)),Q&&this.currentStaffEntry!==void 0&&this.currentStaffEntry.ParentStaff!==this.currentStaff&&(this.currentStaffEntry=this.currentVoiceGenerator.checkForStaffEntryLink(this.inSourceMeasureInstrumentIndex+j-1,this.currentStaff,this.currentStaffEntry,this.currentMeasure));const Kt=this.currentStaffEntry!==void 0&&this.currentStaffEntry.Timestamp!==void 0&&this.currentStaffEntry.Timestamp.Equals(new u.Fraction(0,1))&&!this.currentStaffEntry.hasNotes();this.saveAbstractInstructionList(this.instrument.Staves.length,Kt),this.activeRhythm;const qt=O.elements("dot").length;if(this.currentVoiceGenerator.read(O,et,J,Nt,it,dt,this.currentStaffEntry,this.currentMeasure,F,this.maxTieNoteFraction,Q,A,D,Vt,yt,It,Xt,Ct,zt,qt),mt!==void 0&&mt.element("dynamics")){const Qt=this.expressionReaders[this.readExpressionStaffNumber(O)-1];Qt&&(Qt.readExpressionParameters(O,this.instrument,this.divisions,G,U,this.currentMeasure.MeasureNumber,!1),Qt.read(O,this.currentMeasure,U))}z=yt}else if(O.name==="forward"){const D=parseInt(O.element("duration").value,10);G.Add(new u.Fraction(D,4*this.divisions))}else if(O.name==="backup"){const D=parseInt(O.element("duration").value,10);G.Sub(new u.Fraction(D,4*this.divisions)),G.IsNegative()&&(G=new u.Fraction(0,1)),U.Sub(new u.Fraction(D,4*this.divisions)),U.IsNegative()&&(U=new u.Fraction(0,1))}else if(O.name==="direction"){const D=O.elements("direction-type"),j=D[0];let Q=Math.min(1,G.RealValue);this.activeRhythm!==void 0&&this.activeRhythm.Rhythm&&(Q/=this.activeRhythm.Rhythm.RealValue);let J=!1;if(this.repetitionInstructionReader&&(J=this.repetitionInstructionReader.handleRepetitionInstructionsFromWordsOrSymbols(j,Q)),!J){let q=this.expressionReaders[0];const et=this.readExpressionStaffNumber(O)-1;if(etit.element("octave-shift"))){q.readExpressionParameters(O,this.instrument,this.divisions,G,U,this.currentMeasure.MeasureNumber,!0);let it,dt=0;(tt=(Y=this.currentStaffEntry)==null?void 0:Y.Timestamp)!=null&&tt.Equals(G)?(dt=this.currentStaffEntry.VoiceEntries.length,it=G.clone()):it=U.clone(),q.addOctaveShift(O,this.currentMeasure,it,dt)}D.some(it=>it.element("pedal"))&&(q.readExpressionParameters(O,this.instrument,this.divisions,G,U,this.currentMeasure.MeasureNumber,!0),q.addPedalMarking(O,this.currentMeasure,G.clone())),q.readExpressionParameters(O,this.instrument,this.divisions,G,U,this.currentMeasure.MeasureNumber,!1),q.read(O,this.currentMeasure,G,U.clone())}}}else if(O.name==="barline"){this.repetitionInstructionReader&&this.repetitionInstructionReader.handleLineRepetitionInstructions(O)&&(this.currentMeasure.HasEndLine=!0);const D=O.attribute("location"),j=(D==null?void 0:D.value)??"right";if(lt===ct.length-1||j==="right"){const Q=(H=O.element("bar-style"))==null?void 0:H.value;Q&&(this.currentMeasure.endingBarStyleXml=Q,this.currentMeasure.endingBarStyleEnum=k.SystemLinesEnumHelper.xmlBarlineStyleToSystemLinesEnum(Q))}}else if(O.name==="sound")try{if(O.attribute("tempo")){const D=parseFloat(O.attribute("tempo").value);this.currentXmlMeasureIndex===0&&(this.musicSheet.DefaultStartTempoInBpm=D,this.musicSheet.HasBPMInfo=!0)}}catch(D){w.default.debug("InstrumentReader.readTempoInstruction",D)}else if(O.name==="harmony"){const D=this.getNoteStaff(O);this.currentStaff=this.instrument.Staves[D-1];const j=G.clone();this.currentStaffEntry=this.currentMeasure.findOrCreateStaffEntry(j,this.inSourceMeasureInstrumentIndex+D-1,this.currentStaff).staffEntry,this.currentStaffEntry.ChordContainers.push(g.ChordSymbolReader.readChordSymbol(O,this.musicSheet,this.activeKey))}}for(const lt in this.voiceGeneratorsDict)this.voiceGeneratorsDict.hasOwnProperty(lt)&&this.voiceGeneratorsDict[lt].checkForOpenBeam();if(this.currentXmlMeasureIndex===this.xmlMeasureList.length-1){for(let lt=0;lt0?this.musicSheet.SourceMeasures[0]:this.currentMeasure;const A=new o.ClefInstruction(b.ClefEnum.G,0,2);let G;F.FirstInstructionsStaffEntries[R]?(G=F.FirstInstructionsStaffEntries[R],G.removeFirstInstructionOfTypeClefInstruction()):(G=new m.SourceStaffEntry(void 0,void 0),F.FirstInstructionsStaffEntries[R]=G),A.Parent=G,G.Instructions.splice(0,0,A)}createDefaultKeyInstruction(){let R;R=this.musicSheet.SourceMeasures.length>0?this.musicSheet.SourceMeasures[0]:this.currentMeasure;const F=new s.KeyInstruction(void 0,0,v.KeyEnum.major);for(let A=this.inSourceMeasureInstrumentIndex;A0&&A[G-1].name==="backup")return!0;let U=-1;for(let C=0;C0||U<0}isAttributesNodeAtEndOfMeasure(R,F,A){var z;if(A.Equals((z=this.ActiveRhythm)==null?void 0:z.Rhythm))return!0;const G=R.elements().slice();let U=0;for(let W=0;WC}getNoteDurationFromTypeNode(R){const F=R.element("type");if(F){const A=F.value;return B.NoteTypeHandler.getNoteDurationFromType(A)}return new u.Fraction(0,4*this.divisions)}addAbstractInstruction(R,F,A,G){if(R.element("divisions")&&R.elements().length===1)return;const U=R.element("transpose");if(U){const W=U.element("chromatic");W&&(this.instrument.PlaybackTranspose=parseInt(W.value,10))}const C=R.elements("clef");let z;if(C.length>0)for(let W=0,$=C.length;W<$;++W){const N=C[W];let Y=b.ClefEnum.G,tt=2,H=1,rt=0;const ct=N.element("line");if(ct)try{tt=parseInt(ct.value,10)}catch(lt){z=f.ITextTranslation.translateText("ReaderErrorMessages/ClefLineError","Invalid clef line. Using default."),this.musicSheet.SheetErrors.pushMeasureError(z),tt=2,w.default.debug("InstrumentReader.addAbstractInstruction",z,lt)}const st=N.element("sign");if(st)try{Y=b.ClefEnum[st.value],o.ClefInstruction.isSupportedClef(Y)||(z=f.ITextTranslation.translateText("ReaderErrorMessages/ClefError","Unsupported clef. Using default."),this.musicSheet.SheetErrors.pushMeasureError(z),Y=b.ClefEnum.G,tt=2),Y===b.ClefEnum.TAB&&(rt=-1)}catch(lt){z=f.ITextTranslation.translateText("ReaderErrorMessages/ClefError","Invalid clef. Using default."),this.musicSheet.SheetErrors.pushMeasureError(z),Y=b.ClefEnum.G,tt=2,w.default.debug("InstrumentReader.addAbstractInstruction",z,lt)}const ot=N.element("clef-octave-change");if(ot)try{rt=parseInt(ot.value,10)}catch{z=f.ITextTranslation.translateText("ReaderErrorMessages/ClefOctaveError","Invalid clef octave. Using default."),this.musicSheet.SheetErrors.pushMeasureError(z),rt=0}if(N.hasAttributes&&N.attribute("number"))try{H=parseInt(N.attribute("number").value,10),H>this.currentClefNumber&&(H=this.currentClefNumber),this.currentClefNumber=H+1}catch{z=f.ITextTranslation.translateText("ReaderErrorMessages/ClefError","Invalid clef. Using default."),this.musicSheet.SheetErrors.pushMeasureError(z),H=1,this.currentClefNumber=H+1}const ht=new o.ClefInstruction(Y,rt,tt);this.abstractInstructions.push([H,ht,G])}if(R.element("key")!==void 0&&this.instrument.MidiInstrumentId!==T.MidiInstrument.Percussion){let W=0;const $=R.element("key").element("fifths");if($)try{W=parseInt($.value,10)}catch(H){z=f.ITextTranslation.translateText("ReaderErrorMessages/KeyError","Invalid key. Set to default."),this.musicSheet.SheetErrors.pushMeasureError(z),W=0,w.default.debug("InstrumentReader.addAbstractInstruction",z,H)}let N=v.KeyEnum.none,Y=R.element("key");if(Y&&(Y=Y.element("mode")),Y)try{N=v.KeyEnum[Y.value]}catch(H){z=f.ITextTranslation.translateText("ReaderErrorMessages/KeyError","Invalid key/mode. Set to default."),this.musicSheet.SheetErrors.pushMeasureError(z),N=v.KeyEnum.major,w.default.debug("InstrumentReader.addAbstractInstruction",z,H)}const tt=new s.KeyInstruction(void 0,W,N);this.abstractInstructions.push([1,tt,G])}if(R.element("time")){const W=R.element("time");let $=S.RhythmSymbolEnum.NONE,N=!0;if(W!==void 0&&W.hasAttributes){const ot=W.attribute("symbol");ot&&(ot.value==="common"?$=S.RhythmSymbolEnum.COMMON:ot.value==="cut"&&($=S.RhythmSymbolEnum.CUT));const ht=W.attribute("print-object");ht&&ht.value==="no"&&(N=!1)}let Y=0,tt=0;const H=W&&W.element("senza-misura")!==void 0,rt=R.elements("time"),ct=[],st=[];for(let ot=0,ht=rt.length;ot0&&st!==void 0&&ct.length===st.length){const ht=ct.length,lt=new Array(ht);let O=0;for(let D=0;D=0;A--){const G=this.abstractInstructions[A],U=G[0],C=G[1],z=G[2];if(C instanceof o.ClefInstruction){const W=C;if(this.currentXmlMeasureIndex===0||U<=this.activeClefs.length&&W!==this.activeClefs[U-1])if(F||this.currentStaffEntry===void 0||this.currentStaffEntry.hasNotes()||U-1!==this.instrument.Staves.indexOf(this.currentStaffEntry.ParentStaff))if(F){if(z.RealValue!==0)continue;let $;if(this.currentMeasure){const N=W,Y=this.inSourceMeasureInstrumentIndex+U-1,tt=this.currentMeasure.FirstInstructionsStaffEntries[Y];if(this.currentXmlMeasureIndex===0)if(tt)if(this.currentMeasure.FirstInstructionsStaffEntries[Y]===void 0||tt.Instructions[0]instanceof o.ClefInstruction){const H=new m.SourceStaffEntry(void 0,void 0);this.currentMeasure.LastInstructionsStaffEntries[Y]=H,N.Parent=H,H.Instructions.push(N)}else $=tt,N.Parent=$,$.removeFirstInstructionOfTypeClefInstruction(),$.Instructions.splice(0,0,N),this.activeClefsHaveBeenInitialized[U-1]=!0;else $=new m.SourceStaffEntry(void 0,void 0),this.currentMeasure.FirstInstructionsStaffEntries[Y]=$,N.Parent=$,$.Instructions.push(N),this.activeClefsHaveBeenInitialized[U-1]=!0;else if(this.activeClefsHaveBeenInitialized[U-1]){let H=this.previousMeasure;this.followingMultirestMeasures>0&&this.currentMeasure.Rules.RenderMultipleRestMeasures&&(H=this.currentMultirestStartMeasure);const rt=new m.SourceStaffEntry(void 0,void 0);H.LastInstructionsStaffEntries[Y]=rt,N.Parent=rt,rt.Instructions.push(N)}else{const H=this.musicSheet.SourceMeasures[0];H.FirstInstructionsStaffEntries[Y]?($=H.FirstInstructionsStaffEntries[Y],$.removeFirstInstructionOfTypeClefInstruction()):$=new m.SourceStaffEntry(void 0,void 0),N.Parent=$,$.Instructions.splice(0,0,N),this.activeClefsHaveBeenInitialized[U-1]=!0}this.activeClefs[U-1]=W,this.abstractInstructions.splice(A,1)}}else{let $;const N=this.activeRhythm.Rhythm;N.RealValue>0&&z.RealValue/N.RealValue>.9&&N.RealValue!==z.RealValue&&(this.currentMeasure.LastInstructionsStaffEntries[U-1]||(this.currentMeasure.LastInstructionsStaffEntries[U-1]=new m.SourceStaffEntry(void 0,this.instrument.Staves[U-1])),$=this.currentMeasure.LastInstructionsStaffEntries[U-1]),$&&(W.Parent=$,$.Instructions.push(W),this.activeClefs[U-1]=W,this.abstractInstructions.splice(A,1))}else{const $=W,N=this.currentStaffEntry;if(z&&Math.abs(z.RealValue-N.Timestamp.RealValue)>.01)continue;$.Parent=N,N.removeFirstInstructionOfTypeClefInstruction(),N.Instructions.push($),this.activeClefs[U-1]=W,this.abstractInstructions.splice(A,1)}else U<=this.activeClefs.length&&W===this.activeClefs[U-1]&&this.abstractInstructions.splice(A,1)}if(C instanceof s.KeyInstruction){const W=C;if(this.activeKey&&this.activeKey.Key===W.Key)this.abstractInstructions.splice(A,1);else{let $;if(this.activeKey=W,this.abstractInstructions.splice(A,1),this.activeKeyHasBeenInitialized?$=this.currentMeasure:(this.activeKeyHasBeenInitialized=!0,$=this.currentXmlMeasureIndex>0?this.musicSheet.SourceMeasures[0]:this.currentMeasure),$)for(let N=this.inSourceMeasureInstrumentIndex;N=0;R--){const F=this.abstractInstructions[R][0],A=this.abstractInstructions[R][1];if(A instanceof o.ClefInstruction){const G=A;if(!this.activeClefs[F-1]||G.ClefType!==this.activeClefs[F-1].ClefType||G.ClefType===this.activeClefs[F-1].ClefType&&G.Line!==this.activeClefs[F-1].Line){const U=new m.SourceStaffEntry(void 0,void 0);this.currentMeasure.LastInstructionsStaffEntries[this.inSourceMeasureInstrumentIndex+F-1]=U;const C=G;C.Parent=U,U.Instructions.push(C),this.activeClefs[F-1]=G,this.abstractInstructions.splice(R,1)}}}}getNoteDurationForTuplet(R){const F=R.element("duration"),A=Number.parseInt(F.value,10);return new u.Fraction(A,4*this.divisions)}readExpressionStaffNumber(R){let F=1;if(R.element("staff")){const A=R.element("staff");if(A)try{F=parseInt(A.value,10)}catch(G){const U=f.ITextTranslation.translateText("ReaderErrorMessages/ExpressionStaffError","Invalid Expression staff number. Set to default.");this.musicSheet.SheetErrors.pushMeasureError(U),F=1,w.default.debug("InstrumentReader.readExpressionStaffNumber",U,G)}}return F}readDivisionsFromNotes(){let R=0,F=this.currentXmlMeasureIndex,A=!1;for(;!A;){const G=this.xmlMeasureList[F].elements();for(let U=0,C=G.length;U0){A=!0;break}}if(R===0&&(F++,F===this.xmlMeasureList.length)){const U=f.ITextTranslation.translateText("ReaderErrorMEssages/DivisionsError","Invalid divisions value at Instrument: ");throw new r.MusicSheetReadingException(U+this.instrument.Name)}}return R}getCueNoteAndNoteTypeXml(R){let F=!1;R.element("cue")&&(F=!0);const A=R.element("type");let G=B.NoteType.UNDEFINED;if(A){const U=A.attribute("size");(U==null?void 0:U.value)==="cue"&&(F=!0),G=B.NoteTypeHandler.StringToNoteType(A.value)}return[F,G]}getStemDirectionType(R){switch(R.value){case"down":return _.StemDirectionType.Down;case"up":return _.StemDirectionType.Up;case"double":return _.StemDirectionType.Double;case"none":return _.StemDirectionType.None;default:return _.StemDirectionType.Undefined}}getNoteHeadColorXml(R){const F=R.element("notehead");if(F){const A=F.attribute("color");if(A)return this.parseXmlColor(A.value)}return null}getNoteColorXml(R){const F=R.attribute("color");return F?this.parseXmlColor(F.value):null}getTremoloInfo(R){let F,A;const G=R.element("tremolo");if(G){const U=G.attribute("type");if(U){if(U.value==="single"){const C=parseInt(G.value,10);C>0&&(F=C)}else F=0;U.value==="unmeasured"&&(A=!0)}}return{tremoloStrokes:F,tremoloUnmeasured:A}}getWavyLines(R,F,A,G){const U=R.elements("wavy-line");if(U)for(const C of U){const z=this.expressionReaders[this.readExpressionStaffNumber(F)-1];z&&(z.readExpressionParameters(C,this.instrument,this.divisions,A,G,this.currentMeasure.MeasureNumber,!1),z.addWavyLine(C,this.currentMeasure,A,G))}}getNoteStaff(R){let F=1;return this.instrument.Staves.length>1&&R.element("staff")&&(F=parseInt(R.element("staff").value,10),isNaN(F)&&(w.default.debug("InstrumentReader.readNextXmlMeasure.get staff number"),F=1)),F}}},9099(St,y,p){var d=this&&this.__importDefault||function(R){return R&&R.__esModule?R:{default:R}};Object.defineProperty(y,"__esModule",{value:!0}),y.MusicSheetReader=void 0;const l=p(427),m=p(4387),o=p(2561),s=p(1272),h=p(9252),u=p(9767),f=p(7307),r=d(p(3065)),b=p(9288),S=p(9288),v=p(2369),w=p(7586),T=p(5294),g=p(164),x=p(7435),P=p(5749),_=p(9713),B=p(7503),k=p(7533);y.MusicSheetReader=class{constructor(R=void 0,F=new _.EngravingRules){this.completeNumberOfStaves=0,this.pluginManager=new B.ReaderPluginManager,this.afterSheetReadingModules=R||[],this.repetitionInstructionReader=P.MusicSymbolModuleFactory.createRepetitionInstructionReader(),this.repetitionCalculator=P.MusicSymbolModuleFactory.createRepetitionCalculator(),this.rules=F}get PluginManager(){return this.pluginManager}get CompleteNumberOfStaves(){return this.completeNumberOfStaves}static doCalculationsAfterDurationHasBeenSet(R){for(const F of R)F.doCalculationsAfterDurationHasBeenSet()}createMusicSheet(R,F){try{return this._createMusicSheet(R,F)}catch(A){return void r.default.error("MusicSheetReader.CreateMusicSheet",A)}}_removeFromArray(R,F){const A=R.indexOf(F);A!==-1&&R.splice(A,1)}trimString(R){return R.replace(/^\s+|\s+$/g,"")}_lastElement(R){return R[R.length-1]}_createMusicSheet(R,F){const A=[];let G=0;this.musicSheet=new l.MusicSheet,this.musicSheet.Path=F,this.musicSheet.Rules=this.rules;const U=R.attribute("osmdMeasureWidthFactor");if(U){const tt=Number.parseFloat(U.value);typeof tt!="number"||isNaN(tt)?r.default.info("xml parse: osmdMeasureWidthFactor invalid"):this.musicSheet.MeasureWidthFactor=tt}if(!R)throw new f.MusicSheetReadingException("Undefined root element");this.pushSheetLabels(R,F);const C=R.element("part-list");if(!C)throw new f.MusicSheetReadingException("Undefined partListNode");const z=R.elements("part"),W=C.elements();this.initializeReading(W,z,A);let $=!0;this.currentFraction=new o.Fraction(0,1);let N=!1,Y=R.element("identification");for(Y&&(Y=Y.element("encoding")),Y&&(Y=Y.element("software")),Y!==void 0&&Y.value==="Guitar Pro 5"&&(N=!0);$;){this.currentMeasure!==void 0&&this.currentMeasure.HasEndLine&&this.rules.NewPartAndSystemAfterFinalBarline&&(G=0),this.currentMeasure=new m.SourceMeasure(this.completeNumberOfStaves,this.musicSheet.Rules);for(const tt of A)try{$=$&&tt.readNextXmlMeasure(this.currentMeasure,this.currentFraction,N)}catch(H){const rt=u.ITextTranslation.translateText("ReaderErrorMessages/InstrumentError","Error while reading instruments.");throw new f.MusicSheetReadingException(rt,H)}$&&(this.musicSheet.addMeasure(this.currentMeasure),this.checkIfRhythmInstructionsAreSetAndEqual(A),this.checkSourceMeasureForNullEntries(),G=this.setSourceMeasureDuration(A,G),this.currentMeasure.AbsoluteTimestamp=this.currentFraction.clone(),this.musicSheet.SheetErrors.finalizeMeasure(this.currentMeasure.MeasureNumber),this.currentFraction.Add(this.currentMeasure.Duration),this.previousMeasure=this.currentMeasure)}this.repetitionInstructionReader&&(this.repetitionInstructionReader.removeRedundantInstructions(),this.repetitionCalculator&&this.repetitionCalculator.calculateRepetitions(this.musicSheet,this.repetitionInstructionReader.repetitionInstructions)),this.musicSheet.checkForInstrumentWithNoVoice(),this.musicSheet.fillStaffList();for(let tt=0,H=this.afterSheetReadingModules.length;ttA){if(this.areRhythmInstructionsMixed(F)&&z.SymbolEnum!==S.RhythmSymbolEnum.NONE)continue;A=z.Rhythm.RealValue,G=F.indexOf(z)}}if(F.length>0&&F.length0)&&F++,this.currentMeasure.Duration=C,this.currentMeasure.ActiveTimeSignature=A,this.currentMeasure.MeasureNumber=F;for(let z=0;zR.Denominator){const A=F.Denominator/R.Denominator;R.expand(A)}}checkIfMeasureIsImplicit(R,F){return!(this.previousMeasure||!R.lt(F))||!!this.previousMeasure&&o.Fraction.plus(this.previousMeasure.Duration,R).Equals(F)}allInstrumentsHaveSameDuration(R,F){let A=0;for(let G=0,U=R.length;G=0;R--)for(let F=this.currentMeasure.VerticalSourceStaffEntryContainers[R].StaffEntries.length-1;F>=0;F--){const A=this.currentMeasure.VerticalSourceStaffEntryContainers[R].StaffEntries[F];if(A)for(let G=A.VoiceEntries.length-1;G>=0;G--){const U=A.VoiceEntries[G];U.Notes.length===0&&(this._removeFromArray(U.ParentVoice.VoiceEntries,U),this._removeFromArray(A.VoiceEntries,U))}A!==void 0&&A.VoiceEntries.length===0&&A.ChordContainers.length===0&&(this.currentMeasure.VerticalSourceStaffEntryContainers[R].StaffEntries[F]=void 0)}for(let R=this.currentMeasure.VerticalSourceStaffEntryContainers.length-1;R>=0;R--){let F=0;for(let A=0,G=this.currentMeasure.VerticalSourceStaffEntryContainers[R].StaffEntries.length;A0){const A=F[0].elements("rights");if(A.length>0)for(let G=0,U=A.length;GF||ot)if(A||ot){if(ct||O==="right")U?U+=` `+lt:U=lt;else if(rt||O!=="right"&&O!=="left")G?G+=` `+lt:G=lt;else if(O==="left"){this.musicSheet.Lyricist||(this.musicSheet.Lyricist=new x.Label(lt));break}}else A=lt}}}}if(!this.musicSheet.Title&&A&&(this.musicSheet.Title=new x.Label(this.trimString(A))),!this.musicSheet.Subtitle&&G&&(this.musicSheet.Subtitle=new x.Label(this.trimString(G))),U){let N=!1;this.musicSheet.Composer?(U.match(` `)??[]).length+1>=(this.musicSheet.Composer.text.match(` -`)??[]).length+1&&(N=!0):N=!0,N&&(this.musicSheet.Composer=new x.Label(this.trimString(U)))}}readTitleAndComposerFromCreditsLegacy(R){var $,N,Y;const F=this.computeSystemYCoordinates(R);if(F===0)return;let A,G,U,C=1,z=0;const W=R.elements("credit");for(let tt=0,H=W.length;ttF||O){if(!this.musicSheet.Title&&!O){const j=(Y=ct.attribute("font-size"))==null?void 0:Y.value;if(j){const Q=parseFloat(j);C0&&N.MidiInstrumentId!==g.MidiInstrument.Percussion&&(ct.midiInstrumentID=Math.max(0,parseInt(lt.value,10)-1));else if(lt.name==="midi-unpitched")ct.fixedKey=Math.max(0,parseInt(lt.value,10));else if(lt.name==="volume")try{const O=parseFloat(lt.value);ct.volume=O/127}catch(O){r.default.debug("ExpressionReader.readExpressionParameters","read volume",O)}else if(lt.name==="pan")try{const O=parseFloat(lt.value);ct.pan=O/64}catch(O){r.default.debug("ExpressionReader.readExpressionParameters","read pan",O)}}catch(O){r.default.info("MusicSheetReader.createInstrumentGroups midi settings: ",O)}}}}catch(ct){r.default.info("MusicSheetReader.createInstrumentGroups: ",ct)}}if(N.SubInstruments.length===0){const tt=new T.SubInstrument(N);N.SubInstruments.push(tt)}A[$]=N,G?(G.InstrumentalGroups.push(N),this.musicSheet.Instruments.push(N)):(this.musicSheet.InstrumentalGroups.push(N),this.musicSheet.Instruments.push(N))}else if(W.name==="part-group"&&W.attribute("type").value==="start"){const $=new w.InstrumentalGroup("group",this.musicSheet,G);G?G.InstrumentalGroups.push($):this.musicSheet.InstrumentalGroups.push($),G=$}else if(W.name==="part-group"&&W.attribute("type").value==="stop"&&G){if(G.InstrumentalGroups.length===1){const $=G.InstrumentalGroups[0];G.Parent?(G.Parent.InstrumentalGroups.push($),this._removeFromArray(G.Parent.InstrumentalGroups,G)):(this.musicSheet.InstrumentalGroups.push($),this._removeFromArray(this.musicSheet.InstrumentalGroups,G))}G=G.Parent}}}catch(U){const C=u.ITextTranslation.translateText("ReaderErrorMessages/InstrumentError","Error while reading Instruments");throw new f.MusicSheetReadingException(C,U)}for(let U=0,C=this.musicSheet.Instruments.length;U0){const U=G[0];if(U){let C=U.element("attributes");C&&(C=C.element("staves")),C?F+=parseInt(C.value,10):F++}}}if(isNaN(F)||F<=0){const A=u.ITextTranslation.translateText("ReaderErrorMessages/StaffError","Invalid number of staves.");throw new f.MusicSheetReadingException(A)}return F}getInstrumentNumberOfStavesFromXml(R){let F=0;const A=R.element("measure");if(A){const G=A.element("attributes");let U;G&&(U=G.element("staves")),F=G&&U?parseInt(U.value,10):1}if(isNaN(F)||F<=0){const G=u.ITextTranslation.translateText("ReaderErrorMessages/StaffError","Invalid number of Staves.");throw new f.MusicSheetReadingException(G)}return F}}},5749(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.MusicSymbolModuleFactory=void 0;const d=p(7631),l=p(6302);y.MusicSymbolModuleFactory=class{static createRepetitionInstructionReader(){return new d.RepetitionInstructionReader}static createRepetitionCalculator(){return new l.RepetitionCalculator}}},4127(St,y,p){var d=this&&this.__importDefault||function(S){return S&&S.__esModule?S:{default:S}};Object.defineProperty(y,"__esModule",{value:!0}),y.ArticulationReader=void 0;const l=p(1336),m=d(p(3065)),a=p(3123),s=p(8215),h=p(6362),u=p(8233),f=p(9003),r=p(9019),b=p(8045);y.ArticulationReader=class{constructor(S){this.rules=S}getAccEnumFromString(S){switch(S){case"sharp":return u.AccidentalEnum.SHARP;case"flat":return u.AccidentalEnum.FLAT;case"natural":return u.AccidentalEnum.NATURAL;case"double-sharp":case"sharp-sharp":return u.AccidentalEnum.DOUBLESHARP;case"double-flat":case"flat-flat":return u.AccidentalEnum.DOUBLEFLAT;case"triple-sharp":return u.AccidentalEnum.TRIPLESHARP;case"triple-flat":return u.AccidentalEnum.TRIPLEFLAT;case"quarter-sharp":return u.AccidentalEnum.QUARTERTONESHARP;case"quarter-flat":return u.AccidentalEnum.QUARTERTONEFLAT;case"three-quarters-sharp":return u.AccidentalEnum.THREEQUARTERSSHARP;case"three-quarters-flat":return u.AccidentalEnum.THREEQUARTERSFLAT;case"slash-quarter-sharp":return u.AccidentalEnum.SLASHQUARTERSHARP;case"slash-sharp":return u.AccidentalEnum.SLASHSHARP;case"double-slash-flat":return u.AccidentalEnum.DOUBLESLASHFLAT;case"sori":return u.AccidentalEnum.SORI;case"koron":return u.AccidentalEnum.KORON;default:return u.AccidentalEnum.NONE}}addArticulationExpression(S,v){var w,T;if(S!==void 0&&S.elements().length>0){const g=S.elements();for(let x=0,P=g.length;x0&&v.Articulations[0].articulationEnum!==l.ArticulationEnum.staccato&&v.Articulations.splice(0,0,A);else if(B==="breathmark")R===h.PlacementEnum.NotYetDefined&&(A.placement=h.PlacementEnum.Above);else if(B==="strongaccent"){const G=(T=_==null?void 0:_.attribute("type"))==null?void 0:T.value;G==="up"?A.articulationEnum=l.ArticulationEnum.marcatoup:G==="down"&&(A.articulationEnum=l.ArticulationEnum.marcatodown)}else if(k===l.ArticulationEnum.softaccent){const G=v.ParentSourceStaffEntry.ParentStaff.Id-1;R===h.PlacementEnum.NotYetDefined&&(R=h.PlacementEnum.Above,G>0&&(R=h.PlacementEnum.Below));const U=v.ParentSourceStaffEntry.VerticalContainerParent.ParentMeasure,C=new r.MultiExpression(U,v.Timestamp);C.StartingContinuousDynamic=new b.ContinuousDynamicExpression(b.ContDynamicEnum.crescendo,R,G,U,-1),C.StartingContinuousDynamic.IsStartOfSoftAccent=!0,C.StartingContinuousDynamic.StartMultiExpression=C,C.StartingContinuousDynamic.EndMultiExpression=C,C.EndingContinuousDynamic=new b.ContinuousDynamicExpression(b.ContDynamicEnum.diminuendo,R,G,U,-1),C.EndingContinuousDynamic.StartMultiExpression=C,C.EndingContinuousDynamic.EndMultiExpression=C,U.StaffLinkedExpressions[G].push(C)}v.hasArticulation(A)||v.Articulations.push(A)}}catch(k){return void m.default.debug("addArticulationExpression","Invalid note articulation.",k)}}}}addFermata(S,v){var g;let w=l.ArticulationEnum.fermata;S.attributes().length>0&&S.attribute("type")&&S.attribute("type").value==="inverted"&&(w=l.ArticulationEnum.invertedfermata);let T=h.PlacementEnum.Above;((g=S.attribute("placement"))==null?void 0:g.value)==="below"&&(T=h.PlacementEnum.Below),v.Articulations.push(new f.Articulation(w,T))}addTechnicalArticulations(S,v,w){var P,_;const T={bend:l.ArticulationEnum.bend,"down-bow":l.ArticulationEnum.downbow,"open-string":l.ArticulationEnum.naturalharmonic,"snap-pizzicato":l.ArticulationEnum.snappizzicato,stopped:l.ArticulationEnum.lefthandpizzicato,"up-bow":l.ArticulationEnum.upbow,harmonic:l.ArticulationEnum.naturalharmonic};for(const B in T){if(!T.hasOwnProperty(B))continue;const k=T[B],R=S.element(B);if(R){let F;((P=R.attribute("placement"))==null?void 0:P.value)==="above"&&(F=h.PlacementEnum.Above),((_=R.attribute("placement"))==null?void 0:_.value)==="below"&&(F=h.PlacementEnum.Below);const A=new f.Articulation(k,F);v.hasArticulation(A)||v.Articulations.push(A)}}const g=S.elements("fingering");for(const B of g){const k=this.createTechnicalInstruction(B,w);k.type=a.TechnicalInstructionType.Fingering,w.Fingering||(w.Fingering=k),v.TechnicalInstructions.push(k)}const x=S.element("string");if(x){const B=this.createTechnicalInstruction(x,w);B.type=a.TechnicalInstructionType.String,w.StringInstruction=B,v.TechnicalInstructions.push(B)}}createTechnicalInstruction(S,v){const w=new a.TechnicalInstruction;w.sourceNote=v,w.value=S.value;const T=S.attribute("placement");return this.rules.FingeringPositionFromXML&&(w.placement=this.getPlacement(T)),w}getPlacement(S,v=h.PlacementEnum.NotYetDefined){if(v!==h.PlacementEnum.NotYetDefined)return v;if(!S)return h.PlacementEnum.NotYetDefined;switch(S.value){case"above":return h.PlacementEnum.Above;case"below":return h.PlacementEnum.Below;case"left":return h.PlacementEnum.Left;case"right":return h.PlacementEnum.Right;default:return h.PlacementEnum.NotYetDefined}}addOrnament(S,v){if(S){let w;const T={"delayed-inverted-turn":s.OrnamentEnum.DelayedInvertedTurn,"delayed-turn":s.OrnamentEnum.DelayedTurn,"inverted-mordent":s.OrnamentEnum.InvertedMordent,"inverted-turn":s.OrnamentEnum.InvertedTurn,mordent:s.OrnamentEnum.Mordent,"trill-mark":s.OrnamentEnum.Trill,turn:s.OrnamentEnum.Turn};for(const g in T){if(!T.hasOwnProperty(g))continue;const x=S.element(g);if(x){w=new s.OrnamentContainer(T[g]);const P=x.attribute("placement");P&&P.value==="below"&&(w.placement=h.PlacementEnum.Below)}}if(w){const g=S.elements("accidental-mark");if(g){let x=h.PlacementEnum.Below,P=u.AccidentalEnum.NONE;const _=g;for(let B=0,k=_.length;B0?A.RealValue>0?(W=l.Fraction.multiply(l.Fraction.minus(A,G),W),this.directionTimestamp=l.Fraction.plus(W,A)):this.directionTimestamp=l.Fraction.createFromFraction(W):this.offsetDivisions<0&&(A.RealValue>0?(W=l.Fraction.multiply(l.Fraction.minus(A,G),W),this.directionTimestamp=l.Fraction.minus(A,W)):this.directionTimestamp=l.Fraction.createFromFraction(W));const $=k.elements("direction-type"),N=k.attribute("placement");if(N)try{const Y=N.value;Y==="below"?this.placement=v.PlacementEnum.Below:Y==="above"&&(this.placement=v.PlacementEnum.Above)}catch(Y){const tt=T.ITextTranslation.translateText("ReaderErrorMessages/ExpressionPlacementError","Invalid expression placement -> set to default.");g.default.debug("ExpressionReader.readExpressionParameters",tt,Y),this.musicSheet.SheetErrors.pushMeasureError(tt),this.placement=v.PlacementEnum.Below}try{for(const Y of $){const tt=Y.element("wedge");if(tt){const H=tt.attribute("default-y");H&&(this.WedgeYPosXml=parseInt(H.value,10),this.placement===v.PlacementEnum.NotYetDefined&&this.readExpressionPlacement(H,"read wedge y pos"))}if(this.placement===v.PlacementEnum.NotYetDefined){const H=Y.element("dynamics");if(H){const st=H.attribute("default-y");st&&this.readExpressionPlacement(st,"read dynamics y pos")}const rt=Y.element("words");if(rt){const st=rt.attribute("default-y");st&&this.readExpressionPlacement(st,"read words y pos")}const ct=Y.element("rehearsal");if(ct){const st=ct.attribute("default-y");st&&this.readExpressionPlacement(st,"read rehearsal pos")}}}}catch(Y){const tt=T.ITextTranslation.translateText("ReaderErrorMessages/ExpressionPlacementError","Invalid expression placement. Set to default.");g.default.debug("ExpressionReader.readExpressionParameters",tt,Y),this.musicSheet.SheetErrors.pushMeasureError(tt),this.placement=v.PlacementEnum.Below}this.placement===v.PlacementEnum.NotYetDefined&&(R.Staves.length>1?this.placement=v.PlacementEnum.Below:R.HasLyrics?this.placement=v.PlacementEnum.Above:this.placement=v.PlacementEnum.Below)}read(k,R,F,A=void 0){let G=!1,U=!1;const C=F.clone(),z=k.element("offset");if(z!=null&&z.value){const N=Number.parseInt(z.value,10);C.Add(new l.Fraction(N,4*this.divisions))}const W=k.element("sound");if(W){const N=W.attribute("tempo"),Y=W.attribute("dynamics");if(N){const tt=N.value.match(/^(\d+)(\.\d+)?$/);(tt==null?void 0:tt.length)>0?this.soundTempo=Math.round(Number.parseFloat(N.value)):(g.default.info("invalid xml tempo: "+N.value),this.soundTempo=100),R.TempoInBPM=this.soundTempo,this.musicSheet.DefaultStartTempoInBpm===0&&(this.musicSheet.DefaultStartTempoInBpm=this.soundTempo),this.musicSheet.HasBPMInfo=!0,G=!0}if(Y){const tt=Y.value.match(/\d+/);this.soundDynamic=tt!==void 0?parseInt(tt[0],10):100,U=!0}}const $=k.elements("direction-type");for(const N of $){let Y=N.element("metronome");if(Y){const tt=Y.elements("metronome-note"),H=Y.element("metronome-relation");if(tt.length>0&&H)this.parseComplexMetronomeMark(Y,tt,H,R,C);else{const rt=Y.element("beat-unit"),ct=Y.element("beat-unit-dot")!==void 0,st=Y.element("per-minute");if(rt!==void 0&&st){Y.hasAttributes&&Y.attribute("default-x")!==void 0&&(this.directionTimestamp=l.Fraction.createFromFraction(C));const at=st.value.match(/(\d+\.?\d*)/),ht=at?parseFloat(at[1]):NaN;this.createNewTempoExpressionIfNeeded(R);const lt=new r.InstantaneousTempoExpression(void 0,this.placement,this.staffNumber,ht,this.currentMultiTempoExpression,!0);lt.parentMeasure=R,this.soundTempo=ht,R.TempoInBPM=this.soundTempo*(ct?1.5:1),this.musicSheet.DefaultStartTempoInBpm===0&&(this.musicSheet.DefaultStartTempoInBpm=this.soundTempo),this.musicSheet.HasBPMInfo=!0,lt.dotted=ct,lt.beatUnit=rt.value,this.currentMultiTempoExpression.addExpression(lt,""),this.currentMultiTempoExpression.CombinedExpressionsText="test"}}continue}if(Y=N.element("dynamics"),Y){const tt=k.element("notations")!==void 0;this.interpretInstantaneousDynamics(Y,R,C,tt);continue}if(Y=N.element("words"),Y)if(G){this.createNewTempoExpressionIfNeeded(R),this.currentMultiTempoExpression.CombinedExpressionsText=Y.value;const tt=new r.InstantaneousTempoExpression(Y.value,this.placement,this.staffNumber,this.soundTempo,this.currentMultiTempoExpression);this.currentMultiTempoExpression.addExpression(tt,"")}else U||this.interpretWords(Y,R,C);else Y=N.element("wedge"),Y?this.interpretWedge(k,Y,R,A,R.MeasureNumber):(Y=N.element("rehearsal"),Y&&this.interpretRehearsalMark(Y,R,F,R.MeasureNumber))}}closeOpenExpressions(k,R){for(const F of this.openContinuousDynamicExpressions)this.createNewMultiExpressionIfNeeded(k,F.NumberXml,R),this.closeOpenContinuousDynamic(F,k,R);this.openContinuousTempoExpression&&this.closeOpenContinuousTempo(l.Fraction.plus(k.AbsoluteTimestamp,R))}addOctaveShift(k,R,F,A=0){var W;let G=1;const U=k.element("staff");if(U)try{G=parseInt(U.value,10)}catch($){const N=T.ITextTranslation.translateText("ReaderErrorMessages/OctaveShiftStaffError","Invalid octave shift staff number. Set to default");this.musicSheet.SheetErrors.pushMeasureError(N),G=1,g.default.debug("ExpressionReader.addOctaveShift",N,$)}const C=k.elements("direction-type"),z=this.readPlacement(k);for(const $ of C){const N=$.element("octave-shift");if(N!==void 0&&N.hasAttributes)try{const Y=this.readNumber(N);if(N.attribute("size")){const tt=parseInt(N.attribute("size").value,10);let H=0;tt===8?H=1:tt===15&&(H=2);let rt=(W=N.attribute("type"))==null?void 0:W.value;if(rt||(z===v.PlacementEnum.Above?rt="down":z===v.PlacementEnum.Below&&(rt="up")),rt==="up"||rt==="down"){const ct=new u.OctaveShift(rt,H);ct.StaffNumber=G,ct.numberXml=Y,this.getMultiExpression=this.createNewMultiExpressionIfNeeded(R,Y),this.getMultiExpression.OctaveShiftStart=ct,ct.ParentStartMultiExpression=this.getMultiExpression,this.openOctaveShifts.set(Y,ct);const st=this.pendingOctaveShiftStops.get(Y);st&&(this.pendingOctaveShiftStops.delete(Y),this.getMultiExpression=this.createNewMultiExpressionIfNeeded(st.measure,Y,st.endTimestamp),this.getMultiExpression.OctaveShiftEnd=ct,ct.ParentEndMultiExpression=this.getMultiExpression,this.openOctaveShifts.delete(Y))}else if(rt==="stop"){const ct=this.openOctaveShifts.get(Y);if(ct)ct.endVoiceEntryIndex=A,this.getMultiExpression=this.createNewMultiExpressionIfNeeded(R,ct.numberXml,F),this.getMultiExpression.OctaveShiftEnd=ct,ct.ParentEndMultiExpression=this.getMultiExpression,this.openOctaveShifts.delete(Y);else{const st=l.Fraction.minus(this.directionTimestamp,new l.Fraction(1,4*this.divisions));this.pendingOctaveShiftStops.set(Y,{measure:R,endTimestamp:st})}}else rt||g.default.debug("octave-shift missing type in xml")}}catch(Y){const tt=T.ITextTranslation.translateText("ReaderErrorMessages/OctaveShiftError","Error while reading octave shift.");this.musicSheet.SheetErrors.pushMeasureError(tt),g.default.debug("ExpressionReader.addOctaveShift",tt,Y)}}}addPedalMarking(k,R,F){var G,U,C;const A=k.elements("direction-type");for(const z of A){const W=z.element("pedal");if(W&&W.hasAttributes){let $=!1,N=!1;try{switch(((G=W.attribute("line"))==null?void 0:G.value)==="yes"?N=!0:((U=W.attribute("line"))==null?void 0:U.value)==="no"?(N=!1,$=!0):((C=W.attribute("sign"))==null?void 0:C.value)==="yes"?$=!0:($=!1,N=!0),W.attribute("type").value){case"start":this.openPedal&&this.openPedal.IsLine&&this.endOpenPedal(R),this.createNewMultiExpressionIfNeeded(R,-1),this.openPedal=new _.Pedal(N,$),this.getMultiExpression.PedalStart=this.openPedal,this.openPedal.ParentStartMultiExpression=this.getMultiExpression;break;case"stop":this.openPedal&&this.endOpenPedal(R,F);break;case"change":this.openPedal&&this.openPedal.IsLine&&(this.openPedal.ChangeEnd=!0,this.createNewMultiExpressionIfNeeded(R,-1),this.getMultiExpression.PedalEnd=this.openPedal,this.openPedal.ParentEndMultiExpression=this.getMultiExpression,this.createNewMultiExpressionIfNeeded(R,-1),this.openPedal=new _.Pedal(N,$),this.openPedal.ChangeBegin=!0,this.getMultiExpression.PedalStart=this.openPedal,this.openPedal.ParentStartMultiExpression=this.getMultiExpression)}}catch(Y){const tt=T.ITextTranslation.translateText("ReaderErrorMessages/PedalError","Error while reading pedal.");this.musicSheet.SheetErrors.pushMeasureError(tt),g.default.debug("ExpressionReader.addPedalMarking",tt,Y)}}}}endOpenPedal(k,R){this.createNewMultiExpressionIfNeeded(k,-1,R),this.getMultiExpression.PedalEnd=this.openPedal,this.openPedal.ParentEndMultiExpression=this.getMultiExpression,this.openPedal=void 0}addWavyLine(k,R,F,A){if(k&&k.hasAttributes)try{switch(k.attribute("type").value){case"start":this.createNewMultiExpressionIfNeeded(R,-1),this.openWavyLine=new B.WavyLine(this.placement),this.getMultiExpression.WavyLineStart=this.openWavyLine,this.openWavyLine.ParentStartMultiExpression=this.getMultiExpression;break;case"stop":this.openWavyLine&&(this.createNewMultiExpressionIfNeeded(R,-1,F),this.getMultiExpression.WavyLineEnd=this.openWavyLine,this.openWavyLine.ParentEndMultiExpression=this.getMultiExpression,this.openWavyLine=void 0)}}catch(G){const U=T.ITextTranslation.translateText("ReaderErrorMessages/WavyLineError","Error while reading wavy-line.");this.musicSheet.SheetErrors.pushMeasureError(U),g.default.debug("ExpressionReader.addWavyLine",U,G)}}initialize(){this.placement=v.PlacementEnum.NotYetDefined,this.soundTempo=0,this.soundDynamic=0,this.offsetDivisions=0}readPlacement(k){var F;const R=(F=k.attribute("placement"))==null?void 0:F.value;return R==="above"?v.PlacementEnum.Above:R==="below"?v.PlacementEnum.Below:v.PlacementEnum.NotYetDefined}readExpressionPlacement(k,R){try{const F=this.readPosition(k);F<0?this.placement=v.PlacementEnum.Below:F>0&&(this.placement=v.PlacementEnum.Above)}catch(F){g.default.debug("ExpressionReader.readExpressionParameters",R,F)}}readPosition(k){try{const R=parseInt(k.value,10);return R<0?this.placement=v.PlacementEnum.Below:R>0&&(this.placement=v.PlacementEnum.Above),R}catch(R){g.default.debug("ExpressionReader.readExpressionParameters",R)}}parseComplexMetronomeMark(k,R,F,A,G){var H;k.hasAttributes&&k.attribute("default-x")!==void 0&&(this.directionTimestamp=l.Fraction.createFromFraction(G));const U=k.elements(),C=[],z=[];let W,$=!1;for(const rt of U){if(rt.name==="metronome-relation"){$=!0;continue}if(rt.name!=="metronome-note")continue;const ct=rt.element("metronome-type");if(!ct)continue;const st={type:ct.value,dots:rt.elements("metronome-dot").length},at=rt.element("metronome-beam");at&&(st.beam=at.value);const ht=rt.element("metronome-tuplet");if(ht&&(ht.hasAttributes?(H=ht.attribute("type"))==null?void 0:H.value:void 0)==="start"){const lt=ht.element("actual-notes"),O=ht.element("normal-notes"),D=ht.attribute("bracket"),j=ht.attribute("show-number");W={actualNotes:lt?parseInt(lt.value,10):3,normalNotes:O?parseInt(O.value,10):2,bracket:!D||D.value==="yes",showNumber:j?j.value:"actual"}}$?z.push(st):C.push(st)}const N={notes:C},Y={notes:z,tuplet:W};this.createNewTempoExpressionIfNeeded(A);const tt=new r.InstantaneousTempoExpression(void 0,this.placement,this.staffNumber,this.soundTempo,this.currentMultiTempoExpression,!0);tt.parentMeasure=A,tt.metronomeNoteGroupLeft=N,tt.metronomeNoteGroupRight=Y,tt.metronomeRelation=F.value,this.musicSheet.DefaultStartTempoInBpm===0&&(this.musicSheet.DefaultStartTempoInBpm=this.soundTempo),this.musicSheet.HasBPMInfo=!0,this.currentMultiTempoExpression.addExpression(tt,""),this.currentMultiTempoExpression.CombinedExpressionsText="test"}interpretInstantaneousDynamics(k,R,F,A){var G,U,C;if(k.hasElements){k.hasAttributes&&k.attribute("default-x")&&(this.directionTimestamp=l.Fraction.createFromFraction(F));const z=this.readNumber(k);let W=(G=k.elements()[0])==null?void 0:G.name;if(W==="other-dynamics"&&(W=k.elements()[0].value),W){if((U=R.Rules)!=null&&U.IgnoreRepeatedDynamics){let N;try{N=h.DynamicEnum[W]}catch{const tt=T.ITextTranslation.translateText("ReaderErrorMessages/DynamicError","Error while reading dynamic.");return void this.musicSheet.SheetErrors.pushMeasureError(tt)}if(((C=this.activeInstantaneousDynamic)==null?void 0:C.DynEnum)===N)return}A?this.createNewMultiExpressionIfNeeded(R,z,l.Fraction.createFromFraction(F)):this.createNewMultiExpressionIfNeeded(R,z);const $=new h.InstantaneousDynamicExpression(W,this.soundDynamic,this.placement,this.staffNumber,R);$.InMeasureTimestamp=F.clone(),this.getMultiExpression.addExpression($,""),this.activeInstantaneousDynamic?this.activeInstantaneousDynamic.DynEnum=$.DynEnum:this.activeInstantaneousDynamic=new h.InstantaneousDynamicExpression(W,0,v.PlacementEnum.NotYetDefined,1,R)}}}interpretWords(k,R,F){var tt;const A=k.value;if(R.Rules.IgnoreBracketsWords&&(/^\(\s*\)$/.test(A)||/^\[\s*\]$/.test(A)))return;let G;const U=k.attribute("font-style");let C,z,W;U&&(C=U.value,C==="italic"&&(G=x.FontStyles.Italic));const $=k.attribute("font-weight");$&&(z=$.value,z==="bold"&&(G=x.FontStyles.Bold,C==="italic"&&(G=x.FontStyles.BoldItalic)));const N=k.attribute("color");let Y;if(N&&(W=N.value),R.Rules.PlaceWordsInsideStafflineFromXml){const H=(tt=k.attribute("default-y"))==null?void 0:tt.value;(H==null?void 0:H.length)>0&&(Y=Number.parseInt(H,10))}if(A.length>0){if(k.hasAttributes&&k.attribute("default-x")&&(this.directionTimestamp=l.Fraction.createFromFraction(F)),this.checkIfWordsNodeIsRepetitionInstruction(A))return;this.fillMultiOrTempoExpression(A,R,F,G,W,Y),this.initialize()}}readNumber(k){var A;let R=1;const F=(A=k.attribute("number"))==null?void 0:A.value;return F&&(R=Number.parseInt(F,10)),R}interpretWedge(k,R,F,A,G){var z,W;R!==void 0&&R.hasAttributes&&R.attribute("default-x")&&(this.directionTimestamp=l.Fraction.createFromFraction(A));const U=this.readNumber(R),C=(W=(z=R.attribute("type"))==null?void 0:z.value)==null?void 0:W.toLowerCase();this.lastWedge&&this.lastWedge.parentMeasure.MeasureNumberXML===F.MeasureNumberXML&&this.lastWedge.StaffNumber===this.staffNumber&&this.placement===this.lastWedge.Placement&&this.WedgeYPosXml!==void 0&&this.lastWedge.YPosXml===this.WedgeYPosXml&&this.lastWedge.StartMultiExpression.Timestamp.Equals(this.directionTimestamp)&&this.lastWedge.DynamicType===a.ContDynamicEnum[C]||(C==="stop"?(this.createNewMultiExpressionIfNeeded(F,U,A),this.getMultiExpression.EndOffsetFraction=new l.Fraction(this.offsetDivisions,4*this.divisions)):this.createNewMultiExpressionIfNeeded(F,U),this.addWedge(R,F,A),this.initialize())}interpretRehearsalMark(k,R,F,A){R.rehearsalExpression=new P.RehearsalExpression(k.value,this.placement)}createNewMultiExpressionIfNeeded(k,R,F=void 0){F||(F=this.directionTimestamp);let A=this.getMultiExpression;return(!A||A&&(A.SourceMeasureParent!==k||A.numberXml!==R||A.SourceMeasureParent===k&&!A.Timestamp.Equals(F)))&&(this.getMultiExpression=A=new f.MultiExpression(k,l.Fraction.createFromFraction(F)),this.getMultiExpression.numberXml=R,k.StaffLinkedExpressions[this.globalStaffIndex].push(A)),A}createNewTempoExpressionIfNeeded(k){this.currentMultiTempoExpression&&this.currentMultiTempoExpression.SourceMeasureParent===k&&this.currentMultiTempoExpression.Timestamp===this.directionTimestamp||(this.currentMultiTempoExpression=new m.MultiTempoExpression(k,l.Fraction.createFromFraction(this.directionTimestamp)),k.TempoExpressions.push(this.currentMultiTempoExpression))}addWedge(k,R,F){if(k!==void 0&&k.hasAttributes){const A=this.readNumber(k),G=k.attribute("type").value.toLowerCase();try{if(G==="crescendo"||G==="diminuendo"){const U=new a.ContinuousDynamicExpression(a.ContDynamicEnum[G],this.placement,this.staffNumber,R,A);this.lastWedge=U,this.lastWedge.YPosXml=this.WedgeYPosXml,this.openContinuousDynamicExpressions.push(U);let C=this.getMultiExpression;C||(C=this.createNewMultiExpressionIfNeeded(R,A)),C.StartingContinuousDynamic=U,U.StartMultiExpression=C,this.activeInstantaneousDynamic!==void 0&&this.activeInstantaneousDynamic.StaffNumber===U.StaffNumber&&(this.activeInstantaneousDynamic=void 0)}else if(G==="stop")for(const U of this.openContinuousDynamicExpressions)U.NumberXml===A&&this.closeOpenContinuousDynamic(U,R,F)}catch(U){const C="ReaderErrorMessages/WedgeError, Error while reading Crescendo / Diminuendo.";this.musicSheet.SheetErrors.pushMeasureError(C),g.default.debug("ExpressionReader.addWedge",C,U)}}}fillMultiOrTempoExpression(k,R,F,A,G,U=void 0){if(!k)return;const C=k.trim();this.createExpressionFromString("",C,R,F,k,A,G,U)}createExpressionFromString(k,R,F,A,G,U,C,z=void 0){const W=r.InstantaneousTempoExpression.isInputStringInstantaneousTempo(R),$=s.ContinuousTempoExpression.isInputStringContinuousTempo(R);if(W||$){if(F.TempoExpressions.length>0)for(let H=0,rt=F.TempoExpressions.length;H0)for(let H=0,rt=F.TempoExpressions.length;H0&&!this.hasDigit(R)&&this.globalStaffIndex>0){if(ct.EntriesList[0].label.indexOf(R)>=0)return!1;break}}let Y=this.musicSheet.Rules.UnknownExpressionTextAlignment;this.musicSheet.Rules.CompactMode&&(Y=w.TextAlignmentEnum.LeftBottom);const tt=new S.UnknownExpression(R,this.placement,Y,this.staffNumber);return tt.fontStyle=U,tt.ColorXML=C,tt.defaultYXml=z,tt.parentMeasure=F,N.addExpression(tt,k),!1}closeOpenContinuousDynamic(k,R,F){if(!k)return;const A=k.NumberXml;k.EndMultiExpression=this.createNewMultiExpressionIfNeeded(R,A,F),k.StartMultiExpression.EndingContinuousDynamic=k,this.openContinuousDynamicExpressions=this.openContinuousDynamicExpressions.filter(G=>G!==k)}closeOpenContinuousTempo(k){this.openContinuousTempoExpression.AbsoluteEndTimestamp=k,this.openContinuousTempoExpression=void 0}checkIfWordsNodeIsRepetitionInstruction(k){return(k=k.trim().toLowerCase())==="coda"||k==="tocoda"||k==="to coda"||k==="fine"||k==="d.c."||k==="dacapo"||k==="da capo"||k==="d.s."||k==="dalsegno"||k==="dal segno"||k==="d.c. al fine"||k==="d.s. al fine"||k==="d.c. al coda"||k==="d.s. al coda"}hasDigit(k){return/\d/.test(k)}}},6030(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.LyricsReader=void 0;const d=p(649),l=p(2317),m=p(9767);y.LyricsReader=class{constructor(a){this.openLyricWords={},this.musicSheet=a}addLyricEntry(a,s){var h,u;if(a){const f=a;for(let r=0,b=f.length;r0)for(let F=R;F<_.length;F++){const A=_[F];A.name==="text"&&(B=A),A.name==="syllabic"&&(k=A)}B!==void 0&&k&&(w=B,v="middle")}let x,P="1";if(S.attributes()!==void 0&&S.attribute("number")&&(P=S.attribute("number").value),v==="single"||v==="end"){if(this.openLyricWords[P]){this.currentLyricWord=this.openLyricWords[P];const _=this.currentLyricWord.Syllables.length;x=new l.LyricsEntry(T,P,this.currentLyricWord,s,_),this.currentLyricWord.Syllables.push(x),delete this.openLyricWords[P],this.currentLyricWord=void 0}else x=new l.LyricsEntry(T,P,void 0,s);x.extend=S.element("extend")!==void 0}else if(v==="begin")this.openLyricWords[P]&&(delete this.openLyricWords[P],this.currentLyricWord=void 0),this.currentLyricWord=new d.LyricWord,this.openLyricWords[P]=this.currentLyricWord,x=new l.LyricsEntry(T,P,this.currentLyricWord,s,0),this.currentLyricWord.Syllables.push(x);else if(v==="middle")if(this.openLyricWords[P]){this.currentLyricWord=this.openLyricWords[P];const _=this.currentLyricWord.Syllables.length;x=new l.LyricsEntry(T,P,this.currentLyricWord,s,_),this.currentLyricWord.Syllables.push(x)}else x=new l.LyricsEntry(T,P,void 0,s);x&&(s.LyricsEntries[P]||(s.LyricsEntries.setValue(P,x),(u=(h=s.ParentSourceStaffEntry)==null?void 0:h.VerticalContainerParent)!=null&&u.ParentMeasure&&(s.ParentSourceStaffEntry.VerticalContainerParent.ParentMeasure.hasLyrics=!0)),s.ParentVoice.Parent.LyricVersesNumbers.includes(P)||s.ParentVoice.Parent.LyricVersesNumbers.push(P))}}}catch{const w=m.ITextTranslation.translateText("ReaderErrorMessages/LyricError","Error while reading lyric entry.");this.musicSheet.SheetErrors.pushMeasureError(w);continue}}}}}},6302(St,y,p){var d=this&&this.__importDefault||function(f){return f&&f.__esModule?f:{default:f}};Object.defineProperty(y,"__esModule",{value:!0}),y.RepetitionBuildingContainer=y.RepetitionCalculator=void 0;const l=p(1645),m=p(1645),a=p(7307),s=p(4076),h=d(p(3065));y.RepetitionCalculator=class{constructor(){this.repetitionInstructions=[],this.openRepetitions=[],this.lastRepetitionCommonPartStartIndex=0}calculateRepetitions(f,r){this.musicSheet=f,this.repetitionInstructions=r,this.openRepetitions.length=0,this.lastRepetitionCommonPartStartIndex=0;const b=this.musicSheet.SourceMeasures,S=new Set;for(let g=1;g1&&S.add(g)}let v=0;for(const g of this.repetitionInstructions){if(this.currentMeasureIndex=g.measureIndex,this.currentMeasureIndex>v){for(const x of S)if(x>v&&x<=this.currentMeasureIndex){for(;this.openRepetitions.length>0;)this.finalizeRepetition(this.openRepetitions.last());this.lastRepetitionCommonPartStartIndex=x;break}}v=this.currentMeasureIndex;try{this.currentMeasure=b[this.currentMeasureIndex],this.handleRepetitionInstructions(g)}catch(x){h.default.error("RepetitionCalculator: calculateRepetitions",x)}}for(;this.openRepetitions.length>0;)try{const g=this.openRepetitions.last();if(g.RepetitonUnderConstruction.FromWords){if(g.WaitingForCoda){let x=g.RepetitonUnderConstruction.BackwardJumpInstructions.last().measureIndex+1;x>=this.musicSheet.SourceMeasures.length&&(x=-1),g.RepetitonUnderConstruction.setEndingStartIndex(2,x)}else if(g.RepetitonUnderConstruction.BackwardJumpInstructions.length===0){this.openRepetitions.splice(this.openRepetitions.length-1,1);continue}}else if(g.RepetitonUnderConstruction.BackwardJumpInstructions.length===0){const x=b.length-1,P=new l.RepetitionInstruction(x,l.RepetitionInstructionEnum.BackJumpLine,l.AlignmentType.End,g.RepetitonUnderConstruction);g.RepetitonUnderConstruction.BackwardJumpInstructions.push(P),b[x].LastRepetitionInstructions.push(P)}this.finalizeRepetition(this.openRepetitions.last())}catch{try{const x=this.openRepetitions.last().RepetitonUnderConstruction;for(const P of this.repetitionInstructions)P.parentRepetition===x&&(P.parentRepetition=void 0);this.openRepetitions.splice(this.openRepetitions.length-1,1)}catch(x){h.default.error("RepetitionCalculator: calculateRepetitions2",x)}}let w=!1;const T=this.musicSheet.SourceMeasures.length-1;for(const g of this.musicSheet.Repetitions)if(g.StartIndex===0&&g.EndIndex===T){w=!0;break}if(!w){const g=new s.Repetition(this.musicSheet,!0);g.FromWords=!0,g.startMarker=new l.RepetitionInstruction(0,l.RepetitionInstructionEnum.StartLine),g.startMarker.parentRepetition=g,this.musicSheet.SourceMeasures[0].FirstRepetitionInstructions.push(g.startMarker),g.endMarker=new l.RepetitionInstruction(T,l.RepetitionInstructionEnum.BackJumpLine),g.endMarker.parentRepetition=g,g.BackwardJumpInstructions.push(g.endMarker),g.UserNumberOfRepetitions=g.DefaultNumberOfRepetitions,this.musicSheet.Repetitions.push(g)}for(let g=0,x=this.musicSheet.SourceMeasures.length;g1&&P.FirstRepetitionInstructions.sort(m.RepetitionInstructionComparer.Compare),P.LastRepetitionInstructions.length>1&&P.LastRepetitionInstructions.sort(m.RepetitionInstructionComparer.Compare)}}handleRepetitionInstructions(f){let r;switch(f.type){case l.RepetitionInstructionEnum.StartLine:r=this.createNewRepetition(this.currentMeasureIndex),f.parentRepetition=r.RepetitonUnderConstruction,r.RepetitonUnderConstruction.FromWords=!1,r.RepetitonUnderConstruction.startMarker=f,this.currentMeasure.FirstRepetitionInstructions.push(f);break;case l.RepetitionInstructionEnum.BackJumpLine:r=this.getOrCreateCurrentRepetition2(!1),f.parentRepetition=r.RepetitonUnderConstruction,r.RepetitonUnderConstruction.BackwardJumpInstructions.push(f),this.currentMeasure.LastRepetitionInstructions.push(f),r.RepetitonUnderConstruction.EndingParts.length===0&&this.finalizeRepetition(r);break;case l.RepetitionInstructionEnum.Ending:if(r=this.getOrCreateCurrentRepetition(),f.parentRepetition=r.RepetitonUnderConstruction,f.endingIndices.contains(1)&&f.alignment===l.AlignmentType.Begin){if(r.RepetitonUnderConstruction.BackwardJumpInstructions.length>0||r.RepetitonUnderConstruction.EndingIndexDict.hasOwnProperty(1)){r=void 0;for(let b=this.openRepetitions.length-1;b>=0;b--){const S=this.openRepetitions[b];if(S.RepetitonUnderConstruction.BackwardJumpInstructions.length===0)for(r=S;this.openRepetitions.length-1>b;){const v=this.openRepetitions.last();this.finalizeRepetition(v)}}r===void 0&&(r=this.createNewRepetition(0),r.RepetitonUnderConstruction.startMarker=new l.RepetitionInstruction(0,l.RepetitionInstructionEnum.None))}r.RepetitonUnderConstruction.forwardJumpInstruction===void 0&&(r.RepetitonUnderConstruction.forwardJumpInstruction=new l.RepetitionInstruction(this.currentMeasureIndex-1,l.RepetitionInstructionEnum.ForwardJump,l.AlignmentType.End,r.RepetitonUnderConstruction),this.musicSheet.SourceMeasures[this.currentMeasureIndex-1].LastRepetitionInstructions.push(r.RepetitonUnderConstruction.forwardJumpInstruction))}if(f.alignment===l.AlignmentType.Begin)r.RepetitonUnderConstruction.setEndingsStartIndex(f.endingIndices,this.currentMeasureIndex),this.currentMeasure.FirstRepetitionInstructions.push(f);else for(let b=0,S=f.endingIndices.length;b0&&Math.abs(r.RepetitonUnderConstruction.BackwardJumpInstructions.last().measureIndex-this.currentMeasureIndex)<=1)break;r=this.createNewRepetition(this.currentMeasureIndex),f.parentRepetition=r.RepetitonUnderConstruction,r.RepetitonUnderConstruction.FromWords=!0,r.SegnoFound=!0,r.RepetitonUnderConstruction.startMarker=f,this.currentMeasure.FirstRepetitionInstructions.push(f);break;case l.RepetitionInstructionEnum.Fine:if(this.openRepetitions.length===0||(r=this.getCurrentRepetition(!0),r===void 0))break;f.parentRepetition=r.RepetitonUnderConstruction,r.RepetitonUnderConstruction.FromWords=!0,r.RepetitonUnderConstruction.forwardJumpInstruction===void 0?(r.FineFound=!0,r.RepetitonUnderConstruction.forwardJumpInstruction=f,r.RepetitonUnderConstruction.setEndingStartIndex(2,-2),this.currentMeasure.LastRepetitionInstructions.push(f)):this.currentMeasure.LastRepetitionInstructions.push(new l.RepetitionInstruction(this.currentMeasureIndex,l.RepetitionInstructionEnum.Fine,l.AlignmentType.End,void 0));break;case l.RepetitionInstructionEnum.ToCoda:if(this.openRepetitions.length===0||(r=this.getCurrentRepetition(!0),r===void 0))break;r.RepetitonUnderConstruction.forwardJumpInstruction===void 0&&(f.parentRepetition=r.RepetitonUnderConstruction,r.RepetitonUnderConstruction.FromWords=!0,r.ToCodaFound=!0,r.RepetitonUnderConstruction.forwardJumpInstruction=f,this.currentMeasure.LastRepetitionInstructions.push(f));break;case l.RepetitionInstructionEnum.Coda:if(this.openRepetitions.length===0)break;r=this.getOrCreateCurrentRepetition2(!0),f.parentRepetition=r.RepetitonUnderConstruction,r.WaitingForCoda?(r.CodaFound=!0,r.RepetitonUnderConstruction.setEndingStartIndex(2,this.currentMeasureIndex),this.currentMeasure.LastRepetitionInstructions.push(f),this.finalizeRepetition(r),this.currentMeasureIndex>0&&(this.musicSheet.SourceMeasures[this.currentMeasureIndex-1].printNewSystemXml=!0)):r.ToCodaFound||(r.RepetitonUnderConstruction.BackwardJumpInstructions.length===0?(r.ToCodaFound=!0,r.RepetitonUnderConstruction.forwardJumpInstruction=new l.RepetitionInstruction(this.currentMeasureIndex,l.RepetitionInstructionEnum.ToCoda,l.AlignmentType.End,r.RepetitonUnderConstruction),this.currentMeasure.LastRepetitionInstructions.push(r.RepetitonUnderConstruction.forwardJumpInstruction)):this.currentMeasure.LastRepetitionInstructions.push(new l.RepetitionInstruction(this.currentMeasureIndex,l.RepetitionInstructionEnum.Coda,l.AlignmentType.Begin,void 0)));break;case l.RepetitionInstructionEnum.DaCapo:r=this.getOrCreateCurrentRepetition(),r.RepetitonUnderConstruction.BackwardJumpInstructions.length>0&&this.finalizeRepetition(r),r.RepetitonUnderConstruction.StartIndex!==0&&(r=this.createNewRepetition(0)),f.parentRepetition=r.RepetitonUnderConstruction,r.RepetitonUnderConstruction.FromWords=!0,r.RepetitonUnderConstruction.startMarker=new l.RepetitionInstruction(0,l.RepetitionInstructionEnum.None,l.AlignmentType.Begin,r.RepetitonUnderConstruction),r.RepetitonUnderConstruction.BackwardJumpInstructions.push(f),this.currentMeasure.LastRepetitionInstructions.push(f),r.RepetitonUnderConstruction.EndingParts.length===0&&this.finalizeRepetition(r);break;case l.RepetitionInstructionEnum.DalSegno:if(r=this.getOrCreateCurrentRepetition2(!0),r.RepetitonUnderConstruction.BackwardJumpInstructions.length>0&&(this.finalizeRepetition(r),r=this.createNewRepetition(0),r.RepetitonUnderConstruction.FromWords=!0,r.RepetitonUnderConstruction.startMarker=new l.RepetitionInstruction(0,l.RepetitionInstructionEnum.None,l.AlignmentType.Begin,r.RepetitonUnderConstruction)),f.parentRepetition=r.RepetitonUnderConstruction,!r.SegnoFound){const b=this.findInstructionInMainListBackwards(l.RepetitionInstructionEnum.Segno,f.measureIndex);b>=0&&(r.SegnoFound=!0,r.RepetitonUnderConstruction.startMarker=new l.RepetitionInstruction(b,l.RepetitionInstructionEnum.Segno,l.AlignmentType.Begin,r.RepetitonUnderConstruction),this.musicSheet.SourceMeasures[b].FirstRepetitionInstructions.splice(0,0,r.RepetitonUnderConstruction.startMarker))}r.RepetitonUnderConstruction.EndingIndexDict.hasOwnProperty(1)&&r.RepetitonUnderConstruction.setEndingEndIndex(1,this.currentMeasureIndex),r.RepetitonUnderConstruction.BackwardJumpInstructions.push(f),this.currentMeasure.LastRepetitionInstructions.push(f);break;case l.RepetitionInstructionEnum.DalSegnoAlFine:if(this.openRepetitions.length===0)break;if(r=this.getOrCreateCurrentRepetition2(!0),f.parentRepetition=r.RepetitonUnderConstruction,!r.SegnoFound){const b=this.findInstructionInMainListBackwards(l.RepetitionInstructionEnum.Segno,f.measureIndex);b>=0&&(r.SegnoFound=!0,r.RepetitonUnderConstruction.startMarker=new l.RepetitionInstruction(b,l.RepetitionInstructionEnum.Segno,l.AlignmentType.Begin,r.RepetitonUnderConstruction),this.musicSheet.SourceMeasures[b].FirstRepetitionInstructions.splice(0,0,r.RepetitonUnderConstruction.startMarker))}if(!r.FineFound){const b=this.findInstructionInMainListBackwards(l.RepetitionInstructionEnum.Fine,f.measureIndex);b>=0&&(r.FineFound=!0,r.RepetitonUnderConstruction.forwardJumpInstruction=new l.RepetitionInstruction(b,l.RepetitionInstructionEnum.Fine,l.AlignmentType.Begin,r.RepetitonUnderConstruction),r.RepetitonUnderConstruction.setEndingStartIndex(2,-2),this.musicSheet.SourceMeasures[b].LastRepetitionInstructions.splice(0,0,r.RepetitonUnderConstruction.forwardJumpInstruction))}r.RepetitonUnderConstruction.EndingIndexDict.hasOwnProperty(1)||r.RepetitonUnderConstruction.setEndingEndIndex(1,this.currentMeasureIndex),r.RepetitonUnderConstruction.BackwardJumpInstructions.push(f),this.currentMeasure.LastRepetitionInstructions.push(f);break;case l.RepetitionInstructionEnum.DaCapoAlFine:if(r=this.getOrCreateCurrentRepetition(),r.RepetitonUnderConstruction.BackwardJumpInstructions.length>0&&(this.finalizeRepetition(r),r=this.createNewRepetition(0)),r.RepetitonUnderConstruction.startMarker!==void 0&&r.RepetitonUnderConstruction.StartIndex!==0&&(r=this.createNewRepetition(0)),r.RepetitonUnderConstruction.startMarker=new l.RepetitionInstruction(0,l.RepetitionInstructionEnum.None,l.AlignmentType.Begin,r.RepetitonUnderConstruction),r.RepetitonUnderConstruction.FromWords=!0,f.parentRepetition=r.RepetitonUnderConstruction,!r.FineFound){const b=this.findInstructionInMainListBackwards(l.RepetitionInstructionEnum.Fine,f.measureIndex);b>=0&&(r.FineFound=!0,r.RepetitonUnderConstruction.forwardJumpInstruction=new l.RepetitionInstruction(b,l.RepetitionInstructionEnum.Fine,l.AlignmentType.Begin,r.RepetitonUnderConstruction),r.RepetitonUnderConstruction.setEndingStartIndex(2,-2),this.musicSheet.SourceMeasures[b].LastRepetitionInstructions.splice(0,0,r.RepetitonUnderConstruction.forwardJumpInstruction))}r.RepetitonUnderConstruction.EndingIndexDict.hasOwnProperty(1)||r.RepetitonUnderConstruction.setEndingEndIndex(1,this.currentMeasureIndex),r.RepetitonUnderConstruction.BackwardJumpInstructions.push(f),this.currentMeasure.LastRepetitionInstructions.push(f);break;case l.RepetitionInstructionEnum.DalSegnoAlCoda:if(this.openRepetitions.length===0)break;if(r=this.getOrCreateCurrentRepetition2(!0),f.parentRepetition=r.RepetitonUnderConstruction,!r.SegnoFound){const b=this.findInstructionInMainListBackwards(l.RepetitionInstructionEnum.Segno,f.measureIndex);b>=0&&(r.SegnoFound=!0,r.RepetitonUnderConstruction.startMarker=new l.RepetitionInstruction(b,l.RepetitionInstructionEnum.Segno,l.AlignmentType.Begin,r.RepetitonUnderConstruction),this.musicSheet.SourceMeasures[b].FirstRepetitionInstructions.splice(0,0,r.RepetitonUnderConstruction.startMarker))}if(!r.ToCodaFound){const b=this.findInstructionInMainListBackwards(l.RepetitionInstructionEnum.ToCoda,f.measureIndex);if(b>=0)r.RepetitonUnderConstruction.forwardJumpInstruction=new l.RepetitionInstruction(b,l.RepetitionInstructionEnum.ToCoda,l.AlignmentType.Begin,r.RepetitonUnderConstruction),this.musicSheet.SourceMeasures[b].LastRepetitionInstructions.splice(0,0,r.RepetitonUnderConstruction.forwardJumpInstruction),r.ToCodaFound=!0;else{const S=this.findInstructionInMainListBackwards(l.RepetitionInstructionEnum.Coda,f.measureIndex);S>=0&&(r.RepetitonUnderConstruction.forwardJumpInstruction=new l.RepetitionInstruction(S,l.RepetitionInstructionEnum.ToCoda,l.AlignmentType.Begin,r.RepetitonUnderConstruction),this.musicSheet.SourceMeasures[S].LastRepetitionInstructions.splice(0,0,r.RepetitonUnderConstruction.forwardJumpInstruction),r.ToCodaFound=!0)}}r.ToCodaFound&&(r.WaitingForCoda=!0),r.RepetitonUnderConstruction.EndingIndexDict.hasOwnProperty(1)||r.RepetitonUnderConstruction.setEndingEndIndex(1,this.currentMeasureIndex),r.RepetitonUnderConstruction.BackwardJumpInstructions.push(f),this.currentMeasure.LastRepetitionInstructions.push(f);break;case l.RepetitionInstructionEnum.DaCapoAlCoda:if(r=this.getOrCreateCurrentRepetition(),r.RepetitonUnderConstruction.BackwardJumpInstructions.length>0?(this.finalizeRepetition(r),r=this.createNewRepetition(0)):r.RepetitonUnderConstruction.EndingParts.length===0&&(r=this.createNewRepetition(0)),r.RepetitonUnderConstruction.startMarker!==void 0&&r.RepetitonUnderConstruction.StartIndex!==0&&(r=this.createNewRepetition(0)),r.RepetitonUnderConstruction.startMarker=new l.RepetitionInstruction(0,l.RepetitionInstructionEnum.None,l.AlignmentType.Begin,r.RepetitonUnderConstruction),r.RepetitonUnderConstruction.FromWords=!0,f.parentRepetition=r.RepetitonUnderConstruction,!r.ToCodaFound){const b=this.findInstructionInMainListBackwards(l.RepetitionInstructionEnum.ToCoda,f.measureIndex);if(b>=0)r.RepetitonUnderConstruction.forwardJumpInstruction=new l.RepetitionInstruction(b,l.RepetitionInstructionEnum.ToCoda,l.AlignmentType.Begin,r.RepetitonUnderConstruction),this.musicSheet.SourceMeasures[b].LastRepetitionInstructions.splice(0,0,r.RepetitonUnderConstruction.forwardJumpInstruction),r.ToCodaFound=!0;else{const S=this.findInstructionInMainListBackwards(l.RepetitionInstructionEnum.Coda,f.measureIndex);S>=0&&(r.RepetitonUnderConstruction.forwardJumpInstruction=new l.RepetitionInstruction(S,l.RepetitionInstructionEnum.ToCoda,l.AlignmentType.Begin,r.RepetitonUnderConstruction),this.musicSheet.SourceMeasures[S].LastRepetitionInstructions.splice(0,0,r.RepetitonUnderConstruction.forwardJumpInstruction),r.ToCodaFound=!0)}}r.ToCodaFound&&(r.WaitingForCoda=!0),r.RepetitonUnderConstruction.EndingIndexDict.hasOwnProperty(1)||r.RepetitonUnderConstruction.setEndingEndIndex(1,this.currentMeasureIndex),r.RepetitonUnderConstruction.BackwardJumpInstructions.push(f),this.currentMeasure.LastRepetitionInstructions.push(f);break;case l.RepetitionInstructionEnum.None:break;default:throw new a.ArgumentOutOfRangeException("currentRepetitionInstruction")}return!0}findInstructionInMainListBackwards(f,r){for(let b=this.repetitionInstructions.length-1;b>=0;b--){const S=this.repetitionInstructions[b];if(S.measureIndex<=r&&S.type===f)return S.measureIndex}return-1}finalizeRepetition(f){const r=f.RepetitonUnderConstruction;if(r.BackwardJumpInstructions.length>0){let b=!0;const S=this.getLastFinalizedRepetition();if(S!==void 0&&r.coversIdenticalMeasures(S)){if(r.NumberOfEndings>S.NumberOfEndings){const v=this.musicSheet.Repetitions.indexOf(S,0);v>-1&&this.musicSheet.Repetitions.splice(v,1),S.removeFromRepetitionInstructions(),this.musicSheet.Repetitions.push(r)}b=!1,r.removeFromRepetitionInstructions()}else this.musicSheet.Repetitions.push(r);if(b){r.startMarker.type===l.RepetitionInstructionEnum.None&&this.musicSheet.SourceMeasures[r.StartIndex].FirstRepetitionInstructions.push(r.startMarker);let v=r.DefaultNumberOfRepetitions;r.BackwardJumpInstructions.length===1&&r.BackwardJumpInstructions[0].Times>0&&(v=r.BackwardJumpInstructions[0].Times),r.UserNumberOfRepetitions=v}}this.openRepetitions.splice(this.openRepetitions.length-1,1)}getCurrentRepetition(f){let r;for(let b=this.openRepetitions.length-1;b>=0;b--)if(this.openRepetitions[b].RepetitonUnderConstruction.FromWords===f){for(r=this.openRepetitions[b];b0)return this.openRepetitions.last();const f=this.createNewRepetition(0);return f.RepetitonUnderConstruction.startMarker=new l.RepetitionInstruction(0,l.RepetitionInstructionEnum.None,l.AlignmentType.Begin,f.RepetitonUnderConstruction),f}getOrCreateCurrentRepetition2(f){let r;for(let b=this.openRepetitions.length-1;b>=0;b--)if(r=this.openRepetitions[b],r.RepetitonUnderConstruction.FromWords===f){for(;b0){const b=this.openRepetitions.last(),S=b.RepetitonUnderConstruction;if(S.BackwardJumpInstructions.length>0){const v=Object.keys(S.EndingIndexDict);(v.length===0||S.EndingIndexDict[v[v.length-1]].part.EndIndex>=0)&&this.finalizeRepetition(b)}}const r=new u(this.musicSheet);return this.lastRepetitionCommonPartStartIndex=f,this.openRepetitions.push(r),r}getLastFinalizedRepetition(){if(this.musicSheet.Repetitions.length>0)return this.musicSheet.Repetitions.last()}};class u{constructor(r){this.RepetitonUnderConstruction=new s.Repetition(r)}}y.RepetitionBuildingContainer=u},7631(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.RepetitionInstructionReader=void 0;const d=p(1645),l=p(1645),m=p(4356);y.RepetitionInstructionReader=class{set MusicSheet(a){this.musicSheet=a,this.xmlMeasureList=new Array(this.musicSheet.Instruments.length),this.repetitionInstructions=[]}prepareReadingMeasure(a,s){this.currentMeasureIndex=s}handleLineRepetitionInstructions(a){var h;let s=!1;if(a.elements().length>0){let u="",f=!1,r="",b="",S="";const v=[],w=a.element("bar-style");w&&(S=w.value),u=a.attributes().length>0&&a.attribute("location")?a.attribute("location").value:"right";const T=a.elements();for(let g=0,x=T.length;g0)if(u==="left"){if(b==="start"){const g=new d.RepetitionInstruction(this.currentMeasureIndex,d.RepetitionInstructionEnum.Ending,d.AlignmentType.Begin,void 0,v);this.addInstruction(this.repetitionInstructions,g)}if(r==="forward"){const g=new d.RepetitionInstruction(this.currentMeasureIndex,d.RepetitionInstructionEnum.StartLine);this.addInstruction(this.repetitionInstructions,g)}}else{if(b==="stop"){const g=new d.RepetitionInstruction(this.currentMeasureIndex,d.RepetitionInstructionEnum.Ending,d.AlignmentType.End,void 0,v);this.addInstruction(this.repetitionInstructions,g)}else if(b==="discontinue"){const g=new d.RepetitionInstruction(this.currentMeasureIndex,d.RepetitionInstructionEnum.Ending,d.AlignmentType.Discontinue,void 0,v);this.addInstruction(this.repetitionInstructions,g)}if(r==="backward"){const g=new d.RepetitionInstruction(this.currentMeasureIndex,d.RepetitionInstructionEnum.BackJumpLine);this.addInstruction(this.repetitionInstructions,g)}}}return s}handleRepetitionInstructionsFromWordsOrSymbols(a,s){const h=a.element("words"),u=this.currentMeasureIndex;if(h){const f="d\\s?\\.s\\.",r=h.value.trim().toLowerCase();if(m.StringUtil.StringContainsSeparatedWord(r,f+" al fine",!0)){const S=new d.RepetitionInstruction(u,d.RepetitionInstructionEnum.DalSegnoAlFine);return this.addInstruction(this.repetitionInstructions,S),!0}const b="d\\.\\s?c\\.";if(m.StringUtil.StringContainsSeparatedWord(r,b+" al coda",!0)){const S=new d.RepetitionInstruction(u,d.RepetitionInstructionEnum.DaCapoAlCoda);return this.addInstruction(this.repetitionInstructions,S),!0}if(m.StringUtil.StringContainsSeparatedWord(r,b+" al fine",!0)){const S=new d.RepetitionInstruction(u,d.RepetitionInstructionEnum.DaCapoAlFine);return this.addInstruction(this.repetitionInstructions,S),!0}if(m.StringUtil.StringContainsSeparatedWord(r,b+" al coda",!0)){const S=new d.RepetitionInstruction(u,d.RepetitionInstructionEnum.DaCapoAlCoda);return this.addInstruction(this.repetitionInstructions,S),!0}if(m.StringUtil.StringContainsSeparatedWord(r,b)||m.StringUtil.StringContainsSeparatedWord(r,"da\\s?capo",!0)){const S=new d.RepetitionInstruction(u,d.RepetitionInstructionEnum.DaCapo);return this.addInstruction(this.repetitionInstructions,S),!0}if(m.StringUtil.StringContainsSeparatedWord(r,f,!0)||m.StringUtil.StringContainsSeparatedWord(r,"dal\\s?segno",!0)){let S;return S=m.StringUtil.StringContainsSeparatedWord(r,"al\\s?coda",!0)?new d.RepetitionInstruction(u,d.RepetitionInstructionEnum.DalSegnoAlCoda):new d.RepetitionInstruction(u,d.RepetitionInstructionEnum.DalSegno),this.addInstruction(this.repetitionInstructions,S),!0}if(m.StringUtil.StringContainsSeparatedWord(r,"to\\s?coda",!0)||m.StringUtil.StringContainsSeparatedWord(r,"a (la )?coda",!0)){const S=new d.RepetitionInstruction(u,d.RepetitionInstructionEnum.ToCoda);return this.addInstruction(this.repetitionInstructions,S),!0}if(m.StringUtil.StringContainsSeparatedWord(r,"fine",!0)){const S=new d.RepetitionInstruction(u,d.RepetitionInstructionEnum.Fine);return this.addInstruction(this.repetitionInstructions,S),!0}if(m.StringUtil.StringContainsSeparatedWord(r,"coda",!0)){const S=new d.RepetitionInstruction(u,d.RepetitionInstructionEnum.Coda);return this.addInstruction(this.repetitionInstructions,S),!0}if(m.StringUtil.StringContainsSeparatedWord(r,"segno",!0)){const S=new d.RepetitionInstruction(u,d.RepetitionInstructionEnum.Segno);return this.addInstruction(this.repetitionInstructions,S),!0}}else{if(a.element("segno")){const f=new d.RepetitionInstruction(u,d.RepetitionInstructionEnum.Segno);return this.addInstruction(this.repetitionInstructions,f),!0}if(a.element("coda")){const f=new d.RepetitionInstruction(u,d.RepetitionInstructionEnum.Coda);return this.addInstruction(this.repetitionInstructions,f),!0}}return!1}removeRedundantInstructions(){let a=0,s=0,h=0,u=0;for(let f=0;f0&&this.findInstructionInPreviousMeasure(f,r.measureIndex,d.RepetitionInstructionEnum.ToCoda)&&(r.type=d.RepetitionInstructionEnum.None);break;case d.RepetitionInstructionEnum.Segno:if(a-u>0){let b=!1;for(let S=0,v=this.repetitionInstructions.length;S0?d.RepetitionInstructionEnum.DalSegnoAlCoda:d.RepetitionInstructionEnum.DalSegno,r.type=d.RepetitionInstructionEnum.None,b=!0;break;case d.RepetitionInstructionEnum.DalSegno:case d.RepetitionInstructionEnum.DalSegnoAlFine:case d.RepetitionInstructionEnum.DalSegnoAlCoda:r.type=d.RepetitionInstructionEnum.None,b=!0}if(b)break}if(b)break;r.type=h-s>0?d.RepetitionInstructionEnum.DalSegnoAlCoda:d.RepetitionInstructionEnum.DalSegno,r.alignment=d.AlignmentType.End,r.measureIndex--}}if(this.backwardSearchForPreviousIdenticalInstruction(f,r)||r.type===d.RepetitionInstructionEnum.None)this.repetitionInstructions.splice(f,1),f--;else switch(r.type){case d.RepetitionInstructionEnum.Fine:break;case d.RepetitionInstructionEnum.ToCoda:h++;break;case d.RepetitionInstructionEnum.Coda:s++;break;case d.RepetitionInstructionEnum.Segno:a++;break;case d.RepetitionInstructionEnum.DalSegnoAlFine:case d.RepetitionInstructionEnum.DalSegnoAlCoda:u++}}this.repetitionInstructions.sort(l.RepetitionInstructionComparer.Compare)}findInstructionInPreviousMeasure(a,s,h){for(let u=a-1;u>=0;u--){const f=this.repetitionInstructions[u];if(s-f.measureIndex===1&&f.type===h)return!0}return!1}backwardSearchForPreviousIdenticalInstruction(a,s){for(let h=a-1;h>=0;h--)if(this.repetitionInstructions[h].equals(s))return!0;return!1}addInstruction(a,s){let h=!0;for(let u=0,f=a.length;u0){const b=r.attribute("type").value;let S=1;try{r.attribute("number")&&(S=parseInt(r.attribute("number").value,10))}catch(g){m.default.debug("VoiceGenerator.addSlur number: ",g)}let v=s.PlacementEnum.NotYetDefined;const w=r.attribute("placement");w&&w.value&&(w.value==="above"?v=s.PlacementEnum.Above:w.value==="below"&&(v=s.PlacementEnum.Below));const T=r.attribute("orientation");if(T&&T.value&&(T.value==="over"?v=s.PlacementEnum.Above:T.value==="under"&&(v=s.PlacementEnum.Below)),b==="start"){let g=this.openSlurDict[S];g||(g=new l.Slur,this.openSlurDict[S]=g),g.StartNote=f,g.PlacementXml=v}else if(b==="stop"){const g=this.openSlurDict[S];if(g){const x=r.name;if(x==="slide"||x==="glissando"){const P=g.StartNote,_=new h.Glissando(P);_.AddNote(f),_.EndNote=f,f.NoteGlissando=_,delete this.openSlurDict[S]}else g.EndNote=f,f.isDuplicateSlur(g)||(f.NoteSlurs.push(g),g.StartNote.NoteSlurs.push(g)),delete this.openSlurDict[S]}}}}}catch{const b=a.ITextTranslation.translateText("ReaderErrorMessages/SlurError","Error while reading slur.");this.musicSheet.SheetErrors.pushMeasureError(b)}}}},1538(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.TempoSorter=y.TemposCalculator=void 0;const d=p(2561),l=p(899),m=p(6362),a=p(9161),s=p(5332);class h{calculate(r){h.processTempoExpressions(r)}static processTempoExpressions(r){var g;const b=[];for(let x=0,P=r.SourceMeasures;x=0&&_.SourceMeasureParent.TempoExpressions.splice(B,1)}else v.push(_),w=_}T=S;for(let x=0;xB&&C.beginsWithRepetition()){k--;break}k++}const F=r.SourceMeasures[k];let A,G=d.Fraction.plus(F.AbsoluteTimestamp,d.Fraction.minus(F.Duration,new d.Fraction(1,64)));x0&&(S.TempoInBpm=r.DefaultStartTempoInBpm),S.TempoInBpm===0&&(S.TempoInBpm=a.InstantaneousTempoExpression.getDefaultValueForInstTempo[a.InstTempo.moderato])),S.TempoInBpm}}y.TemposCalculator=h;class u{static Compare(r,b){let S=0;if(S=u.CompareNumber(r.AbsoluteTimestamp.RealValue,b.AbsoluteTimestamp.RealValue),S!==0)return S;const v=u.calcSortPriority(r),w=u.calcSortPriority(b);return S=u.CompareNumber(v,w),S}static calcSortPriority(r){if(r.InstantaneousTempo!=null){switch(r.InstantaneousTempo.TempoType){case a.TempoType.metronomeMark:return 1;case a.TempoType.inst:return 2;case a.TempoType.change:switch(r.InstantaneousTempo.ChangeSubType){case a.ChangeSubType.atempo:case a.ChangeSubType.doppioMovimento:return 3;case a.ChangeSubType.tempoprimo:return 4}}return 5}return 9}static CompareNumber(r,b){return r0||Et.length>0)&&!this.currentNote.ParentVoiceEntry.IsGrace&&(this.slurReader.addSlur(yt,this.currentNote),Et.length>0&&this.slurReader.addSlur(Et,this.currentNote),Dt.length>0&&this.slurReader.addSlur(Dt,this.currentNote));const Vt=mt.elements("tuplet");Vt.length>0&&(this.openTupletNumber=this.addTuplet(z,Vt),dt=!0);const Nt=mt.element("arpeggiate");if(Nt!==void 0){let zt;if(this.currentVoiceEntry.Arpeggio)zt=this.currentVoiceEntry.Arpeggio;else{let Xt=!1;for(const Ut of this.currentStaffEntry.VoiceEntries)if(Ut.Arpeggio){Xt=!0,zt=Ut.Arpeggio;break}if(!Xt){let Ut=A.ArpeggioType.ARPEGGIO_DIRECTIONLESS;const Kt=Nt.attribute("direction");if(Kt)switch(Kt.value){case"up":Ut=A.ArpeggioType.ROLL_UP;break;case"down":Ut=A.ArpeggioType.ROLL_DOWN;break;default:Ut=A.ArpeggioType.ARPEGGIO_DIRECTIONLESS}zt=new A.Arpeggio(this.currentVoiceEntry,Ut),this.currentVoiceEntry.Arpeggio=zt}}zt.addNote(this.currentNote)}const It=mt.elements("tied");It.length>0&&this.addTie(It,ct,st,r.TieTypes.SIMPLE);const Ct=mt.element("technical");if(Ct){const zt=Ct.elements("hammer-on");zt.length>0&&this.addTie(zt,ct,st,r.TieTypes.HAMMERON);const Xt=Ct.elements("pull-off");Xt.length>0&&this.addTie(Xt,ct,st,r.TieTypes.PULLOFF)}}z.element("time-modification")===void 0||dt||this.handleTimeModificationNode(z)}catch(it){_.default.warn(it);const dt=v.ITextTranslation.translateText("ReaderErrorMessages/NoteError","Ignored erroneous Note.");this.musicSheet.SheetErrors.pushMeasureError(dt),this.musicSheet.SheetErrors.pushMeasureError(it)}return this.currentNote}checkForStaffEntryLink(z,W,$,N){const Y=new P.StaffEntryLink(this.currentVoiceEntry);Y.LinkStaffEntries.push($),$.Link=Y;const tt=this.currentVoiceEntry.Timestamp.clone(),H=N.getVerticalContainerByTimestamp(tt);return($=H.StaffEntries[z])||($=new h.SourceStaffEntry(H,W),H.StaffEntries[z]=$),$.VoiceEntries.push(this.currentVoiceEntry),Y.LinkStaffEntries.push($),$.Link=Y,$}checkForOpenBeam(){this.openBeams.length>0&&this.currentNote&&this.handleOpenBeam()}checkOpenTies(){const z=this.openTieDict;for(const W in z)if(z.hasOwnProperty(W)){const $=z[W];S.Fraction.plus($.StartNote.ParentStaffEntry.Timestamp,$.Duration).lt($.StartNote.SourceMeasure.Duration)&&delete z[W]}}hasVoiceEntry(){return this.currentVoiceEntry!==void 0}readArticulations(z,W,$){const N=z.element("articulations");N&&this.articulationReader.addArticulationExpression(N,W);const Y=z.element("fermata");Y&&this.articulationReader.addFermata(Y,W);const tt=z.element("technical");tt&&this.articulationReader.addTechnicalArticulations(tt,W,$);const H=z.element("ornaments");H&&this.articulationReader.addOrnament(H,W)}addSingleNote(z,W,$,N,Y,tt,H,rt,ct,st,at,ht,lt,O){let D,j,Q,J,q=0,et=g.AccidentalEnum.NONE,it=x.NoteEnum.C,dt=x.NoteEnum.C,mt=0,yt=0;const Et=z.elements();for(let Ut=0,Kt=Et.length;Ut0&&this.openBeams.last().ExtendedNoteList.push(D),D}addNoteInfo(z,W,$,N,Y,tt,H,rt,ct){z.NoteTypeXml=W,z.PrintObject=$,z.IsCueNote=N,z.NormalNotes=Y,z.displayStepUnpitched=tt,z.displayOctaveUnpitched=H,z.NoteheadColorXml=rt,z.NoteheadColor=rt}createBeam(z,W){var $;try{const N=z.element("beam");let Y;if(N!==void 0&&N.hasAttributes&&(Y=N.attribute("number")),Y){let tt=parseInt(Y.value,10);const H=z.elements("beam"),rt=H[0].value;H&&(rt==="begin"?(tt===(($=this.openBeams.last())==null?void 0:$.BeamNumber)?(this.beamNumberOffset++,tt+=this.beamNumberOffset):this.openBeams.last()&&this.handleOpenBeam(),this.openBeams.push(new u.Beam(tt,this.beamNumberOffset))):tt+=this.beamNumberOffset);let ct=!1;if(!(tt>0&&tt<=this.openBeams.length&&this.openBeams[tt-1]))return void _.default.debug("[OSMD] invalid beamnumber");for(let st=0,at=this.openBeams[tt-1].Notes.length;st1){for(let at=1;at0&&st.SecondaryBreakIndices.push(ht);break}}rt==="end"&&this.endBeam()}}}catch(N){const Y=v.ITextTranslation.translateText("ReaderErrorMessages/BeamError","Error while reading beam.");throw this.musicSheet.SheetErrors.pushMeasureError(Y),new T.MusicSheetReadingException("",N)}}endBeam(){this.openBeams.pop(),this.beamNumberOffset=Math.max(0,this.beamNumberOffset-1)}handleOpenBeam(){const z=this.openBeams.last();if(z.Notes.length!==0){if(z.Notes.length===1)return z.Notes[0].NoteBeam=void 0,void this.endBeam();if(this.currentNote===k.CollectionUtil.last(z.Notes))this.endBeam();else{const W=k.CollectionUtil.last(z.Notes).ParentStaffEntry,$=this.currentMeasure.getVerticalContainerIndexByTimestamp(W.Timestamp),N=W.VerticalContainerParent.StaffEntries.indexOf(W);if($1){let Y=z.element("time-modification");Y&&(Y=Y.element("actual-notes"));const tt=W;for(let H=0,rt=tt.length;H1&&this.openTupletNumber--),this.tupletDict[D]=Q;const q=[];q.push(this.currentNote),Q.Notes.push(q),Q.Fractions.push(this.getTupletNoteDurationFromType(z)),this.currentNote.NoteTuplet=Q,this.openTupletNumber=D}else if(O.value==="stop"){let D=1;ct.attribute("number")&&(D=parseInt(ct.attribute("number").value,10));const j=this.tupletDict[D];if(j){const Q=ct.attribute("placement");Q&&(Q.value==="below"?j.tupletLabelNumberPlacement=C.PlacementEnum.Below:j.tupletLabelNumberPlacement=C.PlacementEnum.Above,j.PlacementFromXml=!0);const J=[];if(J.push(this.currentNote),j.Notes.push(J),!j.PlacementFromXml){let q=!1;for(const et of j.Notes){for(const it of et)if(!it.isRest()){it.StemDirectionXml===a.StemDirectionType.Down?j.tupletLabelNumberPlacement=C.PlacementEnum.Below:j.tupletLabelNumberPlacement=C.PlacementEnum.Above,q=!0;break}if(q)break}}j.Fractions.push(this.getTupletNoteDurationFromType(z)),this.currentNote.NoteTuplet=j,delete this.tupletDict[D],Object.keys(this.tupletDict).length===0?this.openTupletNumber=0:Object.keys(this.tupletDict).length>1&&this.openTupletNumber--}}}}}else if(W[0]){const Y=W[0];if(Y.hasAttributes){const tt=Y.attribute("type").value;let H=1;Y.attribute("number")&&(H=parseInt(Y.attribute("number").value,10));const rt=isNaN(H),ct=this.readShowNumberNoneGiven(Y),st=Y.attribute("bracket");st&&st.value==="yes"?(N=!0,$=!0):st&&st.value==="no"&&($=!1);let at=this.musicSheet.Rules.TupletsRatioed;const ht=Y.attribute("show-number");if(ht&&ht.value==="both"&&this.musicSheet.Rules.TupletsRatioedUseXMLValue&&(at=!0),tt==="start"){let lt=0,O=z.element("time-modification");if(O&&(O=O.element("actual-notes")),O&&(lt=parseInt(O.value,10),isNaN(lt))){const J=v.ITextTranslation.translateText("ReaderErrorMessages/TupletNoteDurationError","Invalid tuplet note duration.");throw this.musicSheet.SheetErrors.pushMeasureError(J),new T.MusicSheetReadingException(J)}rt&&(this.openTupletNumber++,H=this.openTupletNumber);let D=this.tupletDict[H];D||(D=this.tupletDict[H]=new b.Tuplet(lt,N),D.Ratioed=at,D.BracketedXmlValue=$,D.ShowNumberNoneGivenInXml=ct,D.tupletLabelNumberPlacement=C.PlacementEnum.Above);const j=Y.attribute("placement");j&&(j.value==="below"?D.tupletLabelNumberPlacement=C.PlacementEnum.Below:D.tupletLabelNumberPlacement=C.PlacementEnum.Above,D.PlacementFromXml=!0);const Q=[];Q.push(this.currentNote),D.Notes.push(Q),D.Fractions.push(this.getTupletNoteDurationFromType(z)),this.currentNote.NoteTuplet=D,this.openTupletNumber=H}else if(tt==="stop"){rt&&(H=this.openTupletNumber);const lt=this.tupletDict[this.openTupletNumber];if(lt){const O=Y.attribute("placement");O&&(O.value==="below"?lt.tupletLabelNumberPlacement=C.PlacementEnum.Below:lt.tupletLabelNumberPlacement=C.PlacementEnum.Above,lt.PlacementFromXml=!0);const D=[];if(D.push(this.currentNote),lt.Notes.push(D),!lt.PlacementFromXml){let j=!1;for(const Q of lt.Notes){for(const J of Q)if(!J.isRest()){J.StemDirectionXml===a.StemDirectionType.Down?lt.tupletLabelNumberPlacement=C.PlacementEnum.Below:lt.tupletLabelNumberPlacement=C.PlacementEnum.Above,j=!0;break}if(j)break}}lt.Fractions.push(this.getTupletNoteDurationFromType(z)),this.currentNote.NoteTuplet=lt,Object.keys(this.tupletDict).length===0?this.openTupletNumber=0:Object.keys(this.tupletDict).length>1&&this.openTupletNumber--,delete this.tupletDict[H]}}}}return this.openTupletNumber}readShowNumberNoneGiven(z){const W=z.attribute("show-number");return!(!(W!=null&&W.value)||W.value!=="none")}handleTimeModificationNode(z){if(this.tupletDict[this.openTupletNumber])try{const W=this.tupletDict[this.openTupletNumber],$=k.CollectionUtil.last(W.Notes);let N;$[0].ParentVoiceEntry.Timestamp.Equals(this.currentVoiceEntry.Timestamp)?N=$:(N=[],W.Notes.push(N),W.Fractions.push(this.getTupletNoteDurationFromType(z))),N.push(this.currentNote),this.currentNote.NoteTuplet=W}catch(W){const $=v.ITextTranslation.translateText("ReaderErrorMessages/TupletNumberError","Invalid tuplet number.");throw this.musicSheet.SheetErrors.pushMeasureError($),W}else if(this.currentVoiceEntry.Notes.length>0){const W=this.currentVoiceEntry.Notes[0];if(W.NoteTuplet){const $=W.NoteTuplet;k.CollectionUtil.last($.Notes).push(this.currentNote),this.currentNote.NoteTuplet=$}}}addTie(z,W,$,N){if(z){if(z.length===1){const Y=z[0];if(Y!==void 0&&Y.attributes()){const tt=this.getTieDirection(Y),H=Y.attribute("type").value;try{if(H==="start"){const rt=this.findCurrentNoteInTieDict(this.currentNote);rt<0&&delete this.openTieDict[rt];const ct=this.getNextAvailableNumberForTie(),st=new f.Tie(this.currentNote,N);this.openTieDict[ct]=st,st.TieNumber=ct,st.TieDirection=tt}else if(H==="stop"){const rt=this.findCurrentNoteInTieDict(this.currentNote),ct=this.openTieDict[rt];ct&&(ct.AddNote(this.currentNote),delete this.openTieDict[rt])}}catch{const ct=v.ITextTranslation.translateText("ReaderErrorMessages/TieError","Error while reading tie.");this.musicSheet.SheetErrors.pushMeasureError(ct)}}}else if(z.length===2){const Y=this.findCurrentNoteInTieDict(this.currentNote);if(Y>=0){const tt=this.openTieDict[Y];tt.AddNote(this.currentNote);for(const H of z)if(H.attribute("type").value==="start"){const rt=this.getTieDirection(H);tt.NoteIndexToTieDirection[tt.Notes.length-1]=rt}}}}}getTieDirection(z){let W=C.PlacementEnum.NotYetDefined;const $=z.attribute("placement");$&&($.value==="above"?W=C.PlacementEnum.Above:$.value==="below"&&(W=C.PlacementEnum.Below));const N=z.attribute("orientation");return N&&(N.value==="over"?W=C.PlacementEnum.Above:N.value==="under"&&(W=C.PlacementEnum.Below)),W}getNextAvailableNumberForTie(){const z=Object.keys(this.openTieDict);if(z.length===0)return 1;z.sort((W,$)=>+W-+$);for(let W=0;W0&&(v+="("+w.adds.join(",")+")"),w.alts.length>0&&(v+="(alt "+w.alts.join(",")+")"),w.subs.length>0&&(v+="(omit "+w.subs.join(",")+")"),f.BassPitch){let P=f.BassPitch;l.MusicSheetCalculator.transposeCalculator&&(P=l.MusicSheetCalculator.transposeCalculator.transposePitch(f.BassPitch,b,r)),v+="/",v+=d.Pitch.getNoteEnumString(P.FundamentalNote),v+=f.getTextForAccidental(P.Accidental)}return v}getTextForAccidental(f){const r=this.rules.ChordAccidentalTexts.getValue(f);return r!==void 0?r:""}getTextFromChordKindEnum(f){return this.rules.ChordSymbolLabelTexts.getValue(f)??""}},y.Degree=class{constructor(f,r,b){this.value=f,this.alteration=r,this.text=b}};class s{constructor(r,b,S){this.alternateName=r,this.chordKind=b,this.degrees=S}static createCustomChord(r,b,S){return new s(r,b,S)}static renameCustomChord(r,b,S){for(const v of S)v.alternateName===r&&(v.alternateName=b)}}var h,u;y.CustomChord=s,(function(f){f[f.add=0]="add",f[f.alter=1]="alter",f[f.subtract=2]="subtract"})(h||(y.ChordDegreeText=h={})),(function(f){f[f.major=0]="major",f[f.minor=1]="minor",f[f.augmented=2]="augmented",f[f.diminished=3]="diminished",f[f.dominant=4]="dominant",f[f.majorseventh=5]="majorseventh",f[f.minorseventh=6]="minorseventh",f[f.diminishedseventh=7]="diminishedseventh",f[f.augmentedseventh=8]="augmentedseventh",f[f.halfdiminished=9]="halfdiminished",f[f.majorminor=10]="majorminor",f[f.majorsixth=11]="majorsixth",f[f.minorsixth=12]="minorsixth",f[f.dominantninth=13]="dominantninth",f[f.majorninth=14]="majorninth",f[f.minorninth=15]="minorninth",f[f.dominant11th=16]="dominant11th",f[f.major11th=17]="major11th",f[f.minor11th=18]="minor11th",f[f.dominant13th=19]="dominant13th",f[f.major13th=20]="major13th",f[f.minor13th=21]="minor13th",f[f.suspendedsecond=22]="suspendedsecond",f[f.suspendedfourth=23]="suspendedfourth",f[f.Neapolitan=24]="Neapolitan",f[f.Italian=25]="Italian",f[f.French=26]="French",f[f.German=27]="German",f[f.pedal=28]="pedal",f[f.power=29]="power",f[f.Tristan=30]="Tristan",f[f.none=31]="none"})(u||(y.ChordSymbolEnum=u={}))},6362(St,y){var p;Object.defineProperty(y,"__esModule",{value:!0}),y.PlacementEnum=y.AbstractExpression=void 0,y.AbstractExpression=class{constructor(d){this.placement=d}static isStringInStringList(d,l){for(let m=0,a=d.length;m=a.allargando&&h<=a.ritenuto}get TempoType(){return this.tempoType}set TempoType(h){this.tempoType=h}get StartTempo(){return this.startTempo}set StartTempo(h){this.startTempo=h}get EndTempo(){return this.endTempo}set EndTempo(h){this.endTempo=h}get AbsoluteStartTimestamp(){return d.Fraction.plus(this.parentMultiTempoExpression.SourceMeasureParent.AbsoluteTimestamp,this.parentMultiTempoExpression.Timestamp)}get AbsoluteEndTimestamp(){return this.absoluteEndTimestamp}set AbsoluteEndTimestamp(h){this.absoluteEndTimestamp=h,this.AbsoluteTimeSpan=d.Fraction.minus(this.AbsoluteEndTimestamp,this.AbsoluteStartTimestamp).RealValue}get AbsoluteTimestamp(){return this.ParentMultiTempoExpression.AbsoluteTimestamp}getAbsoluteFloatTimestamp(){return this.ParentMultiTempoExpression.AbsoluteTimestamp.RealValue}getInterpolatedTempo(h){const u=d.Fraction.plus(this.parentMultiTempoExpression.SourceMeasureParent.AbsoluteTimestamp,this.parentMultiTempoExpression.Timestamp);if(h.lt(u))return-1;if(this.absoluteEndTimestamp.lt(h))return-2;const f=d.Fraction.minus(h,u).RealValue/d.Fraction.minus(this.absoluteEndTimestamp,u).RealValue;return Math.max(0,Math.min(250,this.startTempo+(this.endTempo-this.startTempo)*f))}setTempoType(){m.isStringInStringList(m.listContinuousTempoFaster,this.label)?this.tempoType=a.accelerando:m.isStringInStringList(m.listContinuousTempoSlower,this.label)&&(this.tempoType=a.ritardando)}getTempoFactor(h=this.Label){return 1}}var a;y.ContinuousTempoExpression=m,m.listContinuousTempoFaster=["accelerando","accel","piu mosso","poco piu","stretto"],m.listContinuousTempoSlower=["poco meno","meno mosso","piu lento","calando","allargando","rallentando","ritardando","ritenuto","ritard.","ritard","rit.","rit","riten.","riten"],(function(s){s[s.accelerando=0]="accelerando",s[s.stretto=1]="stretto",s[s.stringendo=2]="stringendo",s[s.mosso=3]="mosso",s[s.piuMosso=4]="piuMosso",s[s.allargando=5]="allargando",s[s.calando=6]="calando",s[s.menoMosso=7]="menoMosso",s[s.rallentando=8]="rallentando",s[s.ritardando=9]="ritardando",s[s.ritard=10]="ritard",s[s.rit=11]="rit",s[s.ritenuto=12]="ritenuto",s[s.rubato=13]="rubato",s[s.precipitando=14]="precipitando"})(a||(y.ContinuousTempoType=a={}))},437(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.OctaveEnum=y.OctaveShift=void 0;const d=p(8233);var l;y.OctaveShift=class{constructor(m,a){this.numberXml=1,this.endVoiceEntryIndex=0,this.setOctaveShiftValue(m,a)}get Type(){return this.octaveValue}set Type(m){this.octaveValue=m}get StaffNumber(){return this.staffNumber}set StaffNumber(m){this.staffNumber=m}get ParentStartMultiExpression(){return this.startMultiExpression}set ParentStartMultiExpression(m){this.startMultiExpression=m}get ParentEndMultiExpression(){return this.endMultiExpression}set ParentEndMultiExpression(m){this.endMultiExpression=m}setOctaveShiftValue(m,a){this.octaveValue=a===1&&m==="down"?l.VA8:a===1&&m==="up"?l.VB8:a===2&&m==="down"?l.MA15:a===2&&m==="up"?l.MB15:l.NONE}static getPitchFromOctaveShift(m,a){if(!m)return;if(m.OctaveShiftApplied)return m;let s=m.Octave;switch(a){case l.VA8:s-=1;break;case l.VB8:s+=1;break;case l.MA15:s-=2;break;case l.MB15:s+=2;break;case l.NONE:default:s+=0}const h=new d.Pitch(m.FundamentalNote,s,m.Accidental);return h.OctaveShiftApplied=!0,h}},(function(m){m[m.VA8=0]="VA8",m[m.VB8=1]="VB8",m[m.MA15=2]="MA15",m[m.MB15=3]="MB15",m[m.NONE=4]="NONE"})(l||(y.OctaveEnum=l={}))},3253(St,y){Object.defineProperty(y,"__esModule",{value:!0}),y.Pedal=void 0,y.Pedal=class{constructor(p=!1,d=!0){this.ChangeEnd=!1,this.ChangeBegin=!1,this.EndsStave=!1,this.BeginsStave=!1,this.line=p,this.sign=d}get IsLine(){return this.line}get IsSign(){return this.sign}}},6229(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.Slur=void 0;const d=p(2561);y.Slur=class{constructor(){}get StartNote(){return this.startNote}set StartNote(l){this.startNote=l}get EndNote(){return this.endNote}set EndNote(l){this.endNote=l}startNoteHasMoreStartingSlurs(){if(!this.startNote)return!1;for(let l=0,m=this.startNote.NoteSlurs.length;l0&&(this.expressions[0].expression instanceof l.InstantaneousDynamicExpression||this.expressions[0].expression instanceof m.ContinuousDynamicExpression||this.expressions[0].expression instanceof a.MoodExpression||this.expressions[0].expression instanceof s.UnknownExpression)&&(r=this.expressions[0].expression.Placement),r}getFontstyleOfFirstEntry(){let r=u.FontStyles.Regular;return this.expressions.length>0&&(this.expressions[0].expression instanceof m.ContinuousDynamicExpression||this.expressions[0].expression instanceof a.MoodExpression?r=u.FontStyles.Italic:this.expressions[0].expression instanceof s.UnknownExpression&&(r=this.expressions[0].expression.fontStyle??u.FontStyles.Regular)),r}getColorXMLOfFirstEntry(){let r;return this.expressions.length>=1&&(r=this.expressions[0].expression.ColorXML),r}addExpression(r,b){r instanceof l.InstantaneousDynamicExpression?(this.instantaneousDynamic&&this.removeExpressionFromEntryList(this.InstantaneousDynamic),this.instantaneousDynamic=r,this.instantaneousDynamic.ParentMultiExpression=this):r instanceof m.ContinuousDynamicExpression?this.startingContinuousDynamic=r:r instanceof a.MoodExpression?this.moodList.push(r):r instanceof s.UnknownExpression&&this.unknownList.push(r),this.addExpressionToEntryList(r,b)}CompareTo(r){return this.Timestamp.RealValue>r.Timestamp.RealValue?1:this.Timestamp.RealValue0&&(this.expressions[0].Expression instanceof l.InstantaneousTempoExpression||this.expressions[0].Expression instanceof s.ContinuousTempoExpression)&&(u=this.expressions[0].Expression.Placement),u}getFontstyleOfFirstEntry(){let u=a.FontStyles.Regular;return this.expressions[0].Expression instanceof l.InstantaneousTempoExpression?u=a.FontStyles.Bold:this.expressions[0].Expression instanceof s.ContinuousTempoExpression&&(u=a.FontStyles.Italic),u}addExpression(u,f){if(this.checkIfAlreadyExists(u))return;u instanceof l.InstantaneousTempoExpression?this.instantaneousTempo=u:u instanceof s.ContinuousTempoExpression&&(this.continuousTempo=u);const r=new h;r.prefix=f,r.Expression=u,r.label=u.Label,this.expressions.push(r)}CompareTo(u){return this.Timestamp.RealValue>u.Timestamp.RealValue?1:this.Timestamp.RealValue0)for(let f=0;f=0}getAlterationForPitch(u){return this.keyType>0&&this.alteratedNotes.indexOf(u.FundamentalNote)<=this.keyType?m.AccidentalEnum.SHARP:this.keyType<0&&this.alteratedNotes.indexOf(u.FundamentalNote)<=Math.abs(this.keyType)?m.AccidentalEnum.FLAT:m.AccidentalEnum.NONE}ToString(){return"Key: "+this.keyType+this.mode}OperatorEquals(u){const f=this;return f===u||!(!f||!u)&&f.Key===u.Key&&f.Mode===u.Mode}OperatorNotEqual(u){return!this.OperatorEquals(u)}}var s;y.KeyInstruction=a,a.sharpPositionList=[l.NoteEnum.F,l.NoteEnum.C,l.NoteEnum.G,l.NoteEnum.D,l.NoteEnum.A,l.NoteEnum.E,l.NoteEnum.B],a.flatPositionList=[l.NoteEnum.B,l.NoteEnum.E,l.NoteEnum.A,l.NoteEnum.D,l.NoteEnum.G,l.NoteEnum.C,l.NoteEnum.F],y.NoteEnumToHalfToneLink=class{constructor(h,u){this.note=h,this.halfTone=u}},(function(h){h[h.major=0]="major",h[h.minor=1]="minor",h[h.none=2]="none",h[h.dorian=3]="dorian",h[h.phrygian=4]="phrygian",h[h.lydian=5]="lydian",h[h.mixolydian=6]="mixolydian",h[h.aeolian=7]="aeolian",h[h.ionian=8]="ionian",h[h.locrian=9]="locrian"})(s||(y.KeyEnum=s={}))},1645(St,y){var p,d;Object.defineProperty(y,"__esModule",{value:!0}),y.AlignmentType=y.RepetitionInstructionEnum=y.RepetitionInstruction=y.RepetitionInstructionComparer=void 0,y.RepetitionInstructionComparer=class{static Compare(l,m){if(l.parentRepetition!==void 0&&m.parentRepetition){if(l.alignment===d.End&&m.alignment===d.End){if(l.parentRepetition.StartIndexm.parentRepetition.StartIndex)return-1}if(l.alignment===d.Begin&&m.alignment===d.Begin){if(l.parentRepetition.EndIndexm.parentRepetition.EndIndex)return-1}}return 0}},y.RepetitionInstruction=class{constructor(l,m,a=d.End,s=void 0,h=void 0){this.endingIndices=void 0,this.measureIndex=l,h&&(this.endingIndices=h.slice()),this.type=m,this.alignment=a,this.parentRepetition=s}CompareTo(l){const m=l;if(this.measureIndex>m.measureIndex)return 1;if(this.measureIndex=0&&(this.syllableIndex=h)}get Text(){return this.text}set Text(l){this.text=l}get Word(){return this.word}get Parent(){return this.parent}set Parent(l){this.parent=l}get VerseNumber(){return this.verseNumber}get SyllableIndex(){return this.syllableIndex}get IsTranslation(){return this.VerseNumber.endsWith("translation")}get IsChorus(){return this.VerseNumber.startsWith("chorus")}get FontStyle(){return this.IsChorus||this.IsTranslation?d.FontStyles.Italic:d.FontStyles.Regular}}},649(St,y){Object.defineProperty(y,"__esModule",{value:!0}),y.LyricWord=void 0,y.LyricWord=class{constructor(){this.syllables=[]}get Syllables(){return this.syllables}containsVoiceEntry(p){for(let d=0,l=this.Syllables.length;d2:(l.default.warn("notehead: sourceNote and filledXmlAttribute undefined."),f=!0)),this.filled=f}get SourceNote(){return this.sourceNote}get Shape(){return this.shape}get Filled(){return this.filled}static ShapeTypeXmlToShape(h){switch(h.toLowerCase()){case"normal":return a.NORMAL;case"none":return a.NONE;case"x":return a.X;case"slash":return a.SLASH;case"diamond":return a.DIAMOND;case"square":case"la":return a.SQUARE;case"do":case"triangle":return a.TRIANGLE;case"inverted triangle":return a.TRIANGLE_INVERTED;case"rectangle":return a.RECTANGLE;case"circle-x":return a.CIRCLEX;default:return l.default.info("unsupported/unhandled xml notehead '"+h+"'. Using normal notehead."),a.NORMAL}}}var a;y.Notehead=m,(function(s){s[s.CIRCLEX=0]="CIRCLEX",s[s.DIAMOND=1]="DIAMOND",s[s.NORMAL=2]="NORMAL",s[s.NONE=3]="NONE",s[s.RECTANGLE=4]="RECTANGLE",s[s.SLASH=5]="SLASH",s[s.SQUARE=6]="SQUARE",s[s.TRIANGLE=7]="TRIANGLE",s[s.TRIANGLE_INVERTED=8]="TRIANGLE_INVERTED",s[s.X=9]="X"})(a||(y.NoteHeadShape=a={}))},8215(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.OrnamentEnum=y.OrnamentContainer=void 0;const d=p(8233),l=p(6362);var m;y.OrnamentContainer=class{constructor(a){this.placement=l.PlacementEnum.Above,this.accidentalAbove=d.AccidentalEnum.NONE,this.accidentalBelow=d.AccidentalEnum.NONE,this.ornament=a}get GetOrnament(){return this.ornament}get AccidentalAbove(){return this.accidentalAbove}set AccidentalAbove(a){this.accidentalAbove=a}get AccidentalBelow(){return this.accidentalBelow}set AccidentalBelow(a){this.accidentalBelow=a}},(function(a){a[a.Trill=0]="Trill",a[a.Turn=1]="Turn",a[a.InvertedTurn=2]="InvertedTurn",a[a.DelayedTurn=3]="DelayedTurn",a[a.DelayedInvertedTurn=4]="DelayedInvertedTurn",a[a.Mordent=5]="Mordent",a[a.InvertedMordent=6]="InvertedMordent"})(m||(y.OrnamentEnum=m={}))},4387(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.SourceMeasure=void 0;const d=p(2561),l=p(3236),m=p(2369),a=p(1645),s=p(1336),h=p(164),u=p(4543),f=p(6954);y.SourceMeasure=class{constructor(r,b){this.printNewSystemXml=!1,this.printNewPageXml=!1,this.IsSystemStartMeasure=!1,this.WidthFactor=1,this.hasLyrics=!1,this.hasMoodExpressions=!1,this.allRests=!1,this.isReducedToMultiRest=!1,this.multipleRestMeasureNumber=0,this.staffLinkedExpressions=[],this.tempoExpressions=[],this.verticalSourceStaffEntryContainers=[],this.graphicalMeasureErrors=[],this.firstRepetitionInstructions=[],this.lastRepetitionInstructions=[],this.completeNumberOfStaves=r,this.implicitMeasure=!1,this.hasEndLine=!1,this.endingBarStyleXml="",this.endingBarStyleEnum=f.SystemLinesEnum.SingleThin,this.firstInstructionsStaffEntries=new Array(r),this.lastInstructionsStaffEntries=new Array(r),this.rules=b,this.TempoInBPM=0;for(let S=0;S1)return r[this.measureListIndex-1]}get Rules(){return this.rules}get VerticalMeasureList(){return this.verticalMeasureList}set VerticalMeasureList(r){this.verticalMeasureList=r}get TempoInBPM(){return this.tempoInBPM}set TempoInBPM(r){this.tempoInBPM=r}findOrCreateStaffEntry(r,b,S){let v,w;for(const g of this.verticalSourceStaffEntryContainers)if(g.Timestamp.Equals(r)){w=g;break}if(w)return w.StaffEntries[b]?v=w.StaffEntries[b]:(v=new m.SourceStaffEntry(w,S),w.StaffEntries[b]=v),{createdNewContainer:!1,staffEntry:v};const T=this.verticalSourceStaffEntryContainers[this.verticalSourceStaffEntryContainers.length-1];if(this.verticalSourceStaffEntryContainers.length===0||T.Timestamp.lt(r)){const g=new l.VerticalSourceStaffEntryContainer(this,r.clone(),this.completeNumberOfStaves);this.verticalSourceStaffEntryContainers.push(g),v=new m.SourceStaffEntry(g,S),g.StaffEntries[b]=v}else for(let g=this.verticalSourceStaffEntryContainers.length-1;g>=0;g--){if(this.verticalSourceStaffEntryContainers[g].Timestamp.lt(r)){const x=new l.VerticalSourceStaffEntryContainer(this,r.clone(),this.completeNumberOfStaves);this.verticalSourceStaffEntryContainers.splice(g+1,0,x),v=new m.SourceStaffEntry(x,S),x.StaffEntries[b]=v;break}if(g===0){const x=new l.VerticalSourceStaffEntryContainer(this,r.clone(),this.completeNumberOfStaves);this.verticalSourceStaffEntryContainers.splice(g,0,x),v=new m.SourceStaffEntry(x,S),x.StaffEntries[b]=v;break}}return{createdNewContainer:!0,staffEntry:v}}findOrCreateVoiceEntry(r,b){let S,v=!1;for(const w of r.VoiceEntries)if(w.ParentVoice===b){S=w;break}return S||(S=new s.VoiceEntry(r.Timestamp,b,r),v=!0),{createdVoiceEntry:v,voiceEntry:S}}getPreviousSourceStaffEntryFromIndex(r,b){for(let S=b-1;S>=0;S--)if(this.verticalSourceStaffEntryContainers[S][r])return this.verticalSourceStaffEntryContainers[S][r]}getVerticalContainerIndexByTimestamp(r){for(let b=0,S=this.VerticalSourceStaffEntryContainers.length;b=0;_--){const B=this.verticalSourceStaffEntryContainers[_][g+x];if(B!==void 0&&B.hasTie()&&T.lt(d.Fraction.plus(B.Timestamp,B.calculateMaxNoteLength()))){T=d.Fraction.plus(B.Timestamp,B.calculateMaxNoteLength());break}}}v.push(T)}for(let w=0,T=v.length;w0)return!0}return!1}beginsWithRepetition(){return this.beginsWithLineRepetition()||this.beginsWithWordRepetition()}beginsWithLineRepetition(){for(let r=0,b=this.FirstRepetitionInstructions.length;r=0;v--)if(S=this.verticalSourceStaffEntryContainers[v].StaffEntries[r],S&&(!b||S.VoiceEntries.length>0))return S}canBeReducedToMultiRest(){var S,v;if(this.firstRepetitionInstructions.length>0||this.lastRepetitionInstructions.length>0)return!1;let r=!0,b=!1;for(const w of this.verticalSourceStaffEntryContainers)if(w){for(const T of w.StaffEntries)if(T&&T.ParentStaff.isVisible()){if(T.ChordContainers.length>0)return!1;T.ParentStaff.hasLyrics&&(b=!0);for(const g of T.VoiceEntries){for(const x of g.Notes)if(!x.isRest()){r=!1;break}if(!r)break}}}if(!r||b||this.hasMoodExpressions||this.tempoExpressions.length>0)return!1;for(const w of this.staffLinkedExpressions)if(w.length>0)return!1;for(const w of this.lastInstructionsStaffEntries)for(let T=0,g=w==null?void 0:w.Instructions.length;T0)return!0;return!1}hasTie(){for(let s=0,h=this.VoiceEntries.length;s0}}y.TabNote=l},5274(St,y,p){var d=this&&this.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(y,"__esModule",{value:!0}),y.Tie=void 0;const l=p(2561),m=p(6362),a=d(p(3065));y.Tie=class{constructor(s,h){this.notes=[],this.TieNumber=1,this.TieDirection=m.PlacementEnum.NotYetDefined,this.NoteIndexToTieDirection={},this.AddNote(s),this.type=h}getTieDirection(s){if(!s)return this.TieDirection;for(let h=0;h=0;d--)for(let l=0;l0)return!0;return!1}isStaccato(){for(const S of this.Articulations)if(S.articulationEnum===f.staccato)return!0;return!1}isAccent(){for(const S of this.Articulations)if(S.articulationEnum===f.accent||S.articulationEnum===f.strongaccent)return!0;return!1}getVerseNumberForLyricEntry(S){let v="1";return this.lyricsEntries.forEach((w,T)=>{S===T&&(v=w)}),v}createVoiceEntriesForOrnament(S,v){S||(S=this);const w=[];if(!S.ornamentContainer)return;const T=this.notes[0],g=T.Length,x=S.ParentVoice,P=S.Timestamp;let _=d.Fraction.createFromFraction(P);switch(S.ornamentContainer.GetOrnament){case a.OrnamentEnum.Trill:{const B=new d.Fraction(g.Numerator,8*g.Denominator),k=T.Pitch.getTransposedPitch(1);let R=v.getAlterationForPitch(k);S.OrnamentContainer.AccidentalAbove!==s.AccidentalEnum.NONE&&(R=S.ornamentContainer.AccidentalAbove);for(let F=0;F<8;F++)_=d.Fraction.plus(P,new d.Fraction(F*B.Numerator,B.Denominator)),F%2==0?this.createBaseVoiceEntry(_,B,x,T,w):this.createAlteratedVoiceEntry(_,B,x,T.SourceMeasure,k,R,w);break}case a.OrnamentEnum.Turn:{const B=new d.Fraction(g.Numerator,4*g.Denominator),k=T.Pitch.getTransposedPitch(-1),R=v.getAlterationForPitch(k),F=T.Pitch.getTransposedPitch(1),A=v.getAlterationForPitch(F);this.createAlteratedVoiceEntry(_,B,x,T.SourceMeasure,F,A,w),_.Add(B),this.createBaseVoiceEntry(_,B,x,T,w),_.Add(B),this.createAlteratedVoiceEntry(_,B,x,T.SourceMeasure,k,R,w),_.Add(B),this.createBaseVoiceEntry(_,B,x,T,w);break}case a.OrnamentEnum.InvertedTurn:{const B=new d.Fraction(g.Numerator,4*g.Denominator),k=T.Pitch.getTransposedPitch(-1),R=v.getAlterationForPitch(k),F=T.Pitch.getTransposedPitch(1),A=v.getAlterationForPitch(F);this.createAlteratedVoiceEntry(_,B,x,T.SourceMeasure,k,R,w),_.Add(B),this.createBaseVoiceEntry(_,B,x,T,w),_.Add(B),this.createAlteratedVoiceEntry(_,B,x,T.SourceMeasure,F,A,w),_.Add(B),this.createBaseVoiceEntry(_,B,x,T,w);break}case a.OrnamentEnum.DelayedTurn:{const B=new d.Fraction(g.Numerator,2*g.Denominator),k=T.Pitch.getTransposedPitch(-1),R=v.getAlterationForPitch(k),F=T.Pitch.getTransposedPitch(1),A=v.getAlterationForPitch(F);this.createBaseVoiceEntry(_,B,x,T,w),_=d.Fraction.plus(P,B),B.Denominator=8*g.Denominator,this.createAlteratedVoiceEntry(_,B,x,T.SourceMeasure,F,A,w),_.Add(B),this.createBaseVoiceEntry(_,B,x,T,w),_.Add(B),this.createAlteratedVoiceEntry(_,B,x,T.SourceMeasure,k,R,w),_.Add(B),this.createBaseVoiceEntry(_,B,x,T,w);break}case a.OrnamentEnum.DelayedInvertedTurn:{const B=new d.Fraction(g.Numerator,2*g.Denominator),k=T.Pitch.getTransposedPitch(-1),R=v.getAlterationForPitch(k),F=T.Pitch.getTransposedPitch(1),A=v.getAlterationForPitch(F);this.createBaseVoiceEntry(_,B,x,T,w),_=d.Fraction.plus(P,B),B.Denominator=8*g.Denominator,this.createAlteratedVoiceEntry(_,B,x,T.SourceMeasure,k,R,w),_.Add(B),this.createBaseVoiceEntry(_,B,x,T,w),_.Add(B),this.createAlteratedVoiceEntry(_,B,x,T.SourceMeasure,F,A,w),_.Add(B),this.createBaseVoiceEntry(_,B,x,T,w);break}case a.OrnamentEnum.Mordent:{const B=new d.Fraction(g.Numerator,4*g.Denominator),k=T.Pitch.getTransposedPitch(1),R=v.getAlterationForPitch(k);this.createBaseVoiceEntry(_,B,x,T,w),_.Add(B),this.createAlteratedVoiceEntry(_,B,x,T.SourceMeasure,k,R,w),B.Denominator=2*g.Denominator,_=d.Fraction.plus(P,B),this.createBaseVoiceEntry(_,B,x,T,w);break}case a.OrnamentEnum.InvertedMordent:{const B=new d.Fraction(g.Numerator,4*g.Denominator),k=T.Pitch.getTransposedPitch(-1),R=v.getAlterationForPitch(k);this.createBaseVoiceEntry(_,B,x,T,w),_.Add(B),this.createAlteratedVoiceEntry(_,B,x,T.SourceMeasure,k,R,w),B.Denominator=2*g.Denominator,_=d.Fraction.plus(P,B),this.createBaseVoiceEntry(_,B,x,T,w);break}default:throw new RangeError}return w}createBaseVoiceEntry(S,v,w,T,g){const x=new u(S,w,T.ParentStaffEntry),P=new m.Pitch(T.Pitch.FundamentalNote,T.Pitch.Octave,T.Pitch.Accidental),_=new l.Note(x,void 0,v,P,T.SourceMeasure);x.Notes.push(_),g.push(x)}createAlteratedVoiceEntry(S,v,w,T,g,x,P){const _=new u(S,w,void 0),B=new m.Pitch(g.FundamentalNote,g.Octave,x),k=new l.Note(_,void 0,v,B,T);_.Notes.push(k),P.push(_)}}var f,r;y.VoiceEntry=u,(function(b){b[b.accent=0]="accent",b[b.strongaccent=1]="strongaccent",b[b.softaccent=2]="softaccent",b[b.marcatoup=3]="marcatoup",b[b.marcatodown=4]="marcatodown",b[b.invertedstrongaccent=5]="invertedstrongaccent",b[b.staccato=6]="staccato",b[b.staccatissimo=7]="staccatissimo",b[b.spiccato=8]="spiccato",b[b.tenuto=9]="tenuto",b[b.fermata=10]="fermata",b[b.invertedfermata=11]="invertedfermata",b[b.breathmark=12]="breathmark",b[b.caesura=13]="caesura",b[b.lefthandpizzicato=14]="lefthandpizzicato",b[b.naturalharmonic=15]="naturalharmonic",b[b.snappizzicato=16]="snappizzicato",b[b.upbow=17]="upbow",b[b.downbow=18]="downbow",b[b.scoop=19]="scoop",b[b.plop=20]="plop",b[b.doit=21]="doit",b[b.falloff=22]="falloff",b[b.stress=23]="stress",b[b.unstress=24]="unstress",b[b.detachedlegato=25]="detachedlegato",b[b.otherarticulation=26]="otherarticulation",b[b.bend=27]="bend"})(f||(y.ArticulationEnum=f={})),(function(b){b[b.Undefined=-1]="Undefined",b[b.Up=0]="Up",b[b.Down=1]="Down",b[b.None=2]="None",b[b.Double=3]="Double"})(r||(y.StemDirectionType=r={}))},7456(St,y,p){var d=this&&this.__createBinding||(Object.create?function(m,a,s,h){h===void 0&&(h=s);var u=Object.getOwnPropertyDescriptor(a,s);u&&!("get"in u?!a.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return a[s]}}),Object.defineProperty(m,h,u)}:function(m,a,s,h){h===void 0&&(h=s),m[h]=a[s]}),l=this&&this.__exportStar||function(m,a){for(var s in m)s==="default"||Object.prototype.hasOwnProperty.call(a,s)||d(a,m,s)};Object.defineProperty(y,"__esModule",{value:!0}),l(p(4236),y),l(p(8365),y),l(p(9719),y),l(p(7718),y),l(p(4249),y),l(p(1850),y),l(p(4064),y),l(p(5282),y),l(p(8215),y),l(p(4387),y),l(p(2369),y),l(p(1910),y),l(p(6644),y),l(p(5274),y),l(p(4268),y),l(p(3236),y),l(p(5534),y),l(p(1336),y),l(p(9184),y),l(p(1850),y),l(p(5282),y),l(p(4387),y),l(p(2369),y),l(p(3236),y),l(p(5274),y)},1745(St,y,p){var d=this&&this.__createBinding||(Object.create?function(m,a,s,h){h===void 0&&(h=s);var u=Object.getOwnPropertyDescriptor(a,s);u&&!("get"in u?!a.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return a[s]}}),Object.defineProperty(m,h,u)}:function(m,a,s,h){h===void 0&&(h=s),m[h]=a[s]}),l=this&&this.__exportStar||function(m,a){for(var s in m)s==="default"||Object.prototype.hasOwnProperty.call(a,s)||d(a,m,s)};Object.defineProperty(y,"__esModule",{value:!0}),l(p(7307),y),l(p(9252),y),l(p(7586),y),l(p(7435),y),l(p(427),y),l(p(5294),y),l(p(7456),y),l(p(4076),y),l(p(1121),y),l(p(6352),y),l(p(899),y),l(p(2870),y)},3173(St,y){Object.defineProperty(y,"__esModule",{value:!0}),y.AJAX=void 0,y.AJAX=class{static ajax(p,d=9e3){let l;const m=p.indexOf(".mxl")>-1?"text/plain; charset=x-user-defined":"application/xml";if(XMLHttpRequest)l=new XMLHttpRequest;else{if(!ActiveXObject)return Promise.reject(new Error("XMLHttp not supported."));l=new ActiveXObject("Microsoft.XMLHTTP")}return l.timeout=d,new Promise((a,s)=>{l.onreadystatechange=()=>{l.readyState===XMLHttpRequest.DONE&&(l.status===200||l.status===0&&l.responseText?a(l.responseText):s(new Error("Could not retrieve requested URL "+l.status)))},l.ontimeout=h=>{s(new Error("Server request Timeout"))},l.overrideMimeType(m),l.open("GET",p,!0),l.send()})}}},6597(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.Cursor=void 0;const d=p(2561),l=p(624);y.Cursor=class{constructor(m,a,s){this.hidden=!0,this.currentPageNumber=1,this.skipInvisibleNotes=!0,this.container=m,this.openSheetMusicDisplay=a,this.rules=this.openSheetMusicDisplay.EngravingRules,this.cursorOptions=s;let h=0;for(this.cursorElementId="cursorImg-0";document.getElementById(this.cursorElementId);)h++,this.cursorElementId=`cursorImg-${h}`;const u=document.createElement("img");u.id=this.cursorElementId,u.style.position="absolute",this.cursorOptions.follow===!0?(this.wantedZIndex="-1",u.style.zIndex=this.wantedZIndex):(this.wantedZIndex="-2",u.style.zIndex=this.wantedZIndex),this.cursorElement=u,this.container.appendChild(u)}adjustToBackgroundColor(){let m;m=this.rules.PageBackgroundColor?"1":this.wantedZIndex,this.cursorElement.style.zIndex=m}init(m,a){this.manager=m,this.graphic=a,this.reset(),this.hidden=!0,this.hide()}show(){this.hidden=!1,this.update(),this.adjustToBackgroundColor()}resetIterator(){if(!this.openSheetMusicDisplay.Sheet||!this.openSheetMusicDisplay.Sheet.SourceMeasures)return void console.log("OSMD.Cursor.resetIterator(): sheet or measures were null/undefined.");const m=this.openSheetMusicDisplay.Sheet.SourceMeasures.length-1;let a=this.rules.MinMeasureToDrawIndex;a=Math.min(a,m);let s=this.rules.MaxMeasureToDrawIndex;if(s=Math.min(s,m),this.openSheetMusicDisplay.Sheet&&this.openSheetMusicDisplay.Sheet.SourceMeasures.length>a&&(this.openSheetMusicDisplay.Sheet.SelectionStart=this.openSheetMusicDisplay.Sheet.SourceMeasures[a].AbsoluteTimestamp),this.openSheetMusicDisplay.Sheet&&this.openSheetMusicDisplay.Sheet.SourceMeasures.length>s){const h=this.openSheetMusicDisplay.Sheet.SourceMeasures[s];this.openSheetMusicDisplay.Sheet.SelectionEnd=d.Fraction.plus(h.AbsoluteTimestamp,h.Duration)}this.iterator=this.manager.getIterator(),this.iterator.SkipInvisibleNotes=this.skipInvisibleNotes}getStaffEntryFromVoiceEntry(m){const a=m.ParentSourceStaffEntry.VerticalContainerParent.ParentMeasure.measureListIndex,s=m.ParentSourceStaffEntry.ParentStaff.idInMusicSheet;return this.graphic.findGraphicalStaffEntryFromMeasureList(s,a,m.ParentSourceStaffEntry)}update(){if(this.hidden||this.hidden===void 0||this.hidden===null)return;this.updateCurrentPage();const m=this.iterator;let a,s=m.CurrentVisibleVoiceEntries(),h=m.CurrentMeasureIndex,u=0,f=0,r=0;if(s.length!==0||m.FrontReached||m.EndReached||(m.moveToPrevious(),s=m.CurrentVisibleVoiceEntries(),m.moveToNext()),m.FrontReached&&s.length===0){m.moveToNext(),s=m.CurrentVisibleVoiceEntries();const T=this.findVisibleGraphicalMeasure(m.CurrentMeasureIndex);u=T.PositionAndShape.AbsolutePosition.x,a=T.ParentMusicSystem,m.moveToPrevious()}else if(m.EndReached||!m.CurrentVoiceEntries||s.length===0){m.moveToPrevious(),s=m.CurrentVisibleVoiceEntries(),h=m.CurrentMeasureIndex;const T=this.findVisibleGraphicalMeasure(m.CurrentMeasureIndex);u=T.PositionAndShape.AbsolutePosition.x+T.PositionAndShape.Size.width,a=T.ParentMusicSystem,m.moveToNext()}else if(m.CurrentMeasure.isReducedToMultiRest){const T=this.findVisibleGraphicalMeasure(m.CurrentMeasureIndex),g=T.parentSourceMeasure.multipleRestMeasures,x=m.CurrentMeasure.multipleRestMeasureNumber/(g+1),P=T.PositionAndShape.Size.width-T.beginInstructionsWidth;u=T.PositionAndShape.AbsolutePosition.x+T.beginInstructionsWidth+x*P,a=T.ParentMusicSystem}else{const T=s.map(g=>this.getStaffEntryFromVoiceEntry(g)).sort((g,x)=>{var P,_,B,k;return((_=(P=g==null?void 0:g.PositionAndShape)==null?void 0:P.AbsolutePosition)==null?void 0:_.x)<=((k=(B=x==null?void 0:x.PositionAndShape)==null?void 0:B.AbsolutePosition)==null?void 0:k.x)?-1:1})[0];T&&(u=T.PositionAndShape.AbsolutePosition.x,a=T.parentMeasure.ParentMusicSystem)}if(!(a!=null&&a.StaffLines[0]))return;f=a.PositionAndShape.AbsolutePosition.y+a.StaffLines[0].PositionAndShape.RelativePosition.y;let b=a.PositionAndShape.AbsolutePosition.y;const S=a.StaffLines[a.StaffLines.length-1];S&&(b+=S.PositionAndShape.RelativePosition.y+S.StaffHeight),r=b-f;const v=this.findVisibleGraphicalMeasure(h);if(!v)return;const w=v.PositionAndShape;if(this.updateWidthAndStyle(w,u,f,r),this.openSheetMusicDisplay.FollowCursor&&this.cursorOptions.follow)if(this.openSheetMusicDisplay.EngravingRules.RenderSingleHorizontalStaffline)this.cursorElement.scrollIntoView({behavior:"smooth",inline:"center"});else{const T=this.cursorElement.getBoundingClientRect().top;this.cursorElement.scrollIntoView({behavior:T<1e3?"smooth":"auto",block:"center"})}this.cursorElement.style.display=""}findVisibleGraphicalMeasure(m){for(let a=0;a{s.push(...h.Notes)}),s}GNotesUnderCursor(m){const a=this.VoicesUnderCursor(m),s=[];return a.forEach(h=>{s.push(...h.Notes.map(u=>this.rules.GNote(u)))}),s}updateCurrentPage(){let m=this.iterator.currentTimeStamp;m.RealValue<0&&(m=new d.Fraction(0,0));for(const a of this.graphic.MusicPages)if(a.MusicSystems.last().GetSystemsLastTimeStamp().gt(m)){const s=a.PageNumber;return s!==this.currentPageNumber&&(this.container.removeChild(this.cursorElement),this.container=document.getElementById("osmdCanvasPage"+s),this.container.appendChild(this.cursorElement)),this.currentPageNumber=s}return 1}get SkipInvisibleNotes(){return this.skipInvisibleNotes}set SkipInvisibleNotes(m){this.skipInvisibleNotes=m,this.iterator.SkipInvisibleNotes=m}get CursorOptions(){return this.cursorOptions}set CursorOptions(m){this.cursorOptions=m}Dispose(){this.hide(),this.container.removeChild(this.cursorElement),this.rules=void 0,this.openSheetMusicDisplay=void 0,this.cursorOptions=void 0}nextMeasure(){const m=this.Iterator.CurrentMeasure;let a=this.Iterator.currentTimeStamp.RealValue;this.next();let s=0;for(;this.Iterator.CurrentMeasure===m&&this.Iterator.currentTimeStamp.RealValue!==a&&s<999;)a=this.Iterator.currentTimeStamp.RealValue,this.next(),s++}previousMeasure(){const m=this.Iterator.CurrentMeasure;let a=this.Iterator.currentTimeStamp.RealValue;this.previous();let s=0;for(;this.Iterator.CurrentMeasure===m&&this.Iterator.currentTimeStamp.RealValue!==a&&s<999;)a=this.Iterator.currentTimeStamp.RealValue,this.previous(),s++;for(s=0;this.Iterator.CurrentRelativeInMeasureTimestamp.RealValue!==0&&s<999;)this.previous(),s++}}},624(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.OSMDOptions=y.SkyBottomLineBatchCalculatorBackendType=y.BackendType=y.FillEmptyMeasuresWithWholeRests=y.AlignRestOption=y.CursorType=void 0;const d=p(4146);var l,m,a,s,h;(function(u){u[u.Standard=0]="Standard",u[u.ThinLeft=1]="ThinLeft",u[u.ShortThinTopLeft=2]="ShortThinTopLeft",u[u.CurrentArea=3]="CurrentArea",u[u.CurrentAreaLeft=4]="CurrentAreaLeft"})(l||(y.CursorType=l={})),(function(u){u[u.Never=0]="Never",u[u.Always=1]="Always",u[u.Auto=2]="Auto"})(m||(y.AlignRestOption=m={})),(function(u){u[u.No=0]="No",u[u.YesVisible=1]="YesVisible",u[u.YesInvisible=2]="YesInvisible"})(a||(y.FillEmptyMeasuresWithWholeRests=a={})),(function(u){u[u.SVG=0]="SVG",u[u.Canvas=1]="Canvas"})(s||(y.BackendType=s={})),(function(u){u[u.Plain=0]="Plain",u[u.WebGL=1]="WebGL"})(h||(y.SkyBottomLineBatchCalculatorBackendType=h={})),y.OSMDOptions=class{static OSMDOptionsStandard(){return{autoResize:!0,backend:"svg",drawingParameters:d.DrawingParametersEnum.default}}static BackendTypeFromString(u){return u&&u.toLowerCase()==="canvas"?s.Canvas:s.SVG}}},7103(St,y,p){var d=this&&this.__importDefault||function(U){return U&&U.__esModule?U:{default:U}};Object.defineProperty(y,"__esModule",{value:!0}),y.OpenSheetMusicDisplay=void 0;const l=p(3902),m=p(806),a=p(9099),s=p(8724),h=p(7921),u=p(9479),f=p(9436),r=p(9834),b=p(6597),S=p(6888),v=p(3173),w=d(p(3065)),T=p(3661),g=p(4146),x=p(4434),P=p(624),_=p(9713),B=p(6362),k=p(3263),R=p(2683),F=p(8233),A=p(1538);class G{constructor(C,z=P.OSMDOptions.OSMDOptionsStandard()){if(this.version="1.9.9-release",this.cursorsOptions=[],this.cursors=[],this.zoom=1,this.zoomUpdated=!1,this.loadUrlTimeout=5e3,typeof C=="string"?this.container=document.getElementById(C):C&&"appendChild"in C&&(this.container=C),!this.container)throw new Error("Please pass a valid div container to OpenSheetMusicDisplay");z.autoResize===void 0&&(z.autoResize=!0),this.backendType=P.BackendType.SVG,this.setOptions(z)}get cursor(){return this.cursors[0]}get Cursor(){return this.cursor}load(C,z="Untitled Score"){this.reset();const W=this;if(C instanceof Blob){const ct=new S.MXLFile(C);return ct.tryUnzip().then(()=>ct.unzipSuccessful?ct.getXmlString().then(st=>W.load(st)):C instanceof Blob?C.text().then(st=>W.load(st)):void 0)}if(typeof C=="string"){const ct=C;if(ct.startsWith("PK"))return w.default.debug("[OSMD] This is a zip file, unpack it first: "+ct),S.MXLHelper.MXLtoXMLstring(ct).then(at=>W.load(at),at=>{throw w.default.debug(at),new Error("OpenSheetMusicDisplay: Invalid MXL file")});if(ct.startsWith(""))return w.default.debug("[OSMD] UTF with BOM detected, truncate first 3 bytes and pass along: "+ct),W.load(ct.substring(3));let st=ct;if(/^\s/.test(st)&&(st=st.trim()),st.startsWith("W.load(at),at=>{throw at});console.error("[OSMD] osmd.load(string): Could not process string. Did not find {z.init(this.sheet.MusicPartManager,this.graphic)}),this.drawingParameters.DrawingParametersEnum===g.DrawingParametersEnum.leadsheet&&(this.graphic.LeadSheet=!0)}render(){var z;if(!this.graphic)throw new Error("OSMD: load() needs to be called before render()");(z=this.drawer)==null||z.clear(),this.Sheet.SourceMeasures[0].ImplicitMeasure&&(this.rules.MinMeasureToDrawNumber>1&&(this.rules.MinMeasureToDrawIndex=this.rules.MinMeasureToDrawNumber),this.rules.MaxMeasureToDrawNumber>0&&(this.rules.MaxMeasureToDrawIndex=this.rules.MaxMeasureToDrawNumber));let C=this.container.offsetWidth;this.rules.RenderSingleHorizontalStaffline&&(C=this.rules.SheetMaximumWidth),this.sheet.pageWidth=C/this.zoom/10,this.rules.PageFormat&&!this.rules.PageFormat.IsUndefined?(this.rules.PageHeight=this.sheet.pageWidth/this.rules.PageFormat.aspectRatio,w.default.debug("[OSMD] PageHeight: "+this.rules.PageHeight)):(w.default.debug("[OSMD] endless/undefined pageformat, id: "+this.rules.PageFormat.idString),this.rules.PageHeight=100001),this.graphic.reCalculate(),this.drawingParameters.drawCursors&&(this.graphic.Cursors.length=0),this.createOrRefreshRenderBackend(),this.needBackendUpdate=!1,this.drawer.setZoom(this.zoom),this.drawer.drawSheet(this.graphic),this.enableOrDisableCursors(this.drawingParameters.drawCursors),this.drawingParameters.drawCursors&&this.cursors.forEach(W=>{W.update()}),this.zoomUpdated=!1,this.rules.RenderCount++}createOrRefreshRenderBackend(){if(this.drawer&&this.drawer.Backends){this.drawer.Backends[0]&&this.drawer.Backends[0].removeAllChildrenFromContainer(this.container);for(const $ of this.drawer.Backends)$.free();this.drawer.Backends.clear()}this.drawingParameters.Rules=this.rules,this.drawer=new u.VexFlowMusicSheetDrawer(this.drawingParameters),this.drawer.drawableBoundingBoxElement=this.DrawBoundingBox,this.drawer.bottomLineVisible=this.drawBottomLine,this.drawer.skyLineVisible=this.drawSkyLine;let C,z=this.container.offsetWidth;this.rules.RenderSingleHorizontalStaffline&&(z=10*(this.EngravingRules.PageLeftMargin+this.graphic.MusicPages[0].PositionAndShape.Size.width+this.EngravingRules.PageRightMargin)*this.zoom);const W=32767;for(const $ of this.graphic.MusicPages){if($.PageNumber>this.rules.MaxPageToDrawNumber)break;const N=this.createBackend(this.backendType,$),Y=" exceeds CanvasBackend limit of 32767. Cutting off score.";N.getOSMDBackendType()===P.BackendType.Canvas&&z>W&&(w.default.warn("[OSMD] Warning: width of "+z+Y),z=W),this.rules.PageFormat&&!this.rules.PageFormat.IsUndefined?C=z/this.rules.PageFormat.aspectRatio:(C=$.PositionAndShape.Size.height,C+=this.rules.PageBottomMargin,N.getOSMDBackendType()===P.BackendType.Canvas&&(C+=.1),C+=$.PositionAndShape.BorderTop,this.rules.RenderTitle&&(C+=this.rules.TitleTopDistance),C*=10*this.zoom),N.getOSMDBackendType()===P.BackendType.Canvas&&C>W&&(w.default.warn("[OSMD] Warning: height of "+C+Y),C=Math.min(C,W)),N.resize(z,C),N.clear(),N.getContext().setFillStyle(this.rules.DefaultColorMusic),N.getContext().setStrokeStyle(this.rules.DefaultColorMusic),this.drawer.Backends.push(N),this.graphic.drawer=this.drawer}}exportSVG(){if(this.drawer)for(const C of this.drawer.Backends)C instanceof f.SvgVexFlowBackend&&C.export()}IsReadyToRender(){return this.graphic!==void 0}clear(){var C;(C=this.drawer)==null||C.clear(),this.reset()}setOptions(C){if(this.rules||(this.rules=new _.EngravingRules),this.drawingParameters||C.drawingParameters?C.drawingParameters&&(this.drawingParameters?this.drawingParameters.DrawingParametersEnum=g.DrawingParametersEnum[C.drawingParameters.toLowerCase()]:this.drawingParameters=new T.DrawingParameters(g.DrawingParametersEnum[C.drawingParameters],this.rules)):this.drawingParameters=new T.DrawingParameters(g.DrawingParametersEnum.default,this.rules),C==null)return void w.default.warn(`warning: osmd.setOptions() called without an options parameter, has no effect. +`)??[]).length+1&&(N=!0):N=!0,N&&(this.musicSheet.Composer=new x.Label(this.trimString(U)))}}readTitleAndComposerFromCreditsLegacy(R){var $,N,Y;const F=this.computeSystemYCoordinates(R);if(F===0)return;let A,G,U,C=1,z=0;const W=R.elements("credit");for(let tt=0,H=W.length;ttF||O){if(!this.musicSheet.Title&&!O){const j=(Y=ct.attribute("font-size"))==null?void 0:Y.value;if(j){const Q=parseFloat(j);C0&&N.MidiInstrumentId!==g.MidiInstrument.Percussion&&(ct.midiInstrumentID=Math.max(0,parseInt(lt.value,10)-1));else if(lt.name==="midi-unpitched")ct.fixedKey=Math.max(0,parseInt(lt.value,10));else if(lt.name==="volume")try{const O=parseFloat(lt.value);ct.volume=O/127}catch(O){r.default.debug("ExpressionReader.readExpressionParameters","read volume",O)}else if(lt.name==="pan")try{const O=parseFloat(lt.value);ct.pan=O/64}catch(O){r.default.debug("ExpressionReader.readExpressionParameters","read pan",O)}}catch(O){r.default.info("MusicSheetReader.createInstrumentGroups midi settings: ",O)}}}}catch(ct){r.default.info("MusicSheetReader.createInstrumentGroups: ",ct)}}if(N.SubInstruments.length===0){const tt=new T.SubInstrument(N);N.SubInstruments.push(tt)}A[$]=N,G?(G.InstrumentalGroups.push(N),this.musicSheet.Instruments.push(N)):(this.musicSheet.InstrumentalGroups.push(N),this.musicSheet.Instruments.push(N))}else if(W.name==="part-group"&&W.attribute("type").value==="start"){const $=new w.InstrumentalGroup("group",this.musicSheet,G);G?G.InstrumentalGroups.push($):this.musicSheet.InstrumentalGroups.push($),G=$}else if(W.name==="part-group"&&W.attribute("type").value==="stop"&&G){if(G.InstrumentalGroups.length===1){const $=G.InstrumentalGroups[0];G.Parent?(G.Parent.InstrumentalGroups.push($),this._removeFromArray(G.Parent.InstrumentalGroups,G)):(this.musicSheet.InstrumentalGroups.push($),this._removeFromArray(this.musicSheet.InstrumentalGroups,G))}G=G.Parent}}}catch(U){const C=u.ITextTranslation.translateText("ReaderErrorMessages/InstrumentError","Error while reading Instruments");throw new f.MusicSheetReadingException(C,U)}for(let U=0,C=this.musicSheet.Instruments.length;U0){const U=G[0];if(U){let C=U.element("attributes");C&&(C=C.element("staves")),C?F+=parseInt(C.value,10):F++}}}if(isNaN(F)||F<=0){const A=u.ITextTranslation.translateText("ReaderErrorMessages/StaffError","Invalid number of staves.");throw new f.MusicSheetReadingException(A)}return F}getInstrumentNumberOfStavesFromXml(R){let F=0;const A=R.element("measure");if(A){const G=A.element("attributes");let U;G&&(U=G.element("staves")),F=G&&U?parseInt(U.value,10):1}if(isNaN(F)||F<=0){const G=u.ITextTranslation.translateText("ReaderErrorMessages/StaffError","Invalid number of Staves.");throw new f.MusicSheetReadingException(G)}return F}}},5749(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.MusicSymbolModuleFactory=void 0;const d=p(7631),l=p(6302);y.MusicSymbolModuleFactory=class{static createRepetitionInstructionReader(){return new d.RepetitionInstructionReader}static createRepetitionCalculator(){return new l.RepetitionCalculator}}},4127(St,y,p){var d=this&&this.__importDefault||function(S){return S&&S.__esModule?S:{default:S}};Object.defineProperty(y,"__esModule",{value:!0}),y.ArticulationReader=void 0;const l=p(1336),m=d(p(3065)),o=p(3123),s=p(8215),h=p(6362),u=p(8233),f=p(9003),r=p(9019),b=p(8045);y.ArticulationReader=class{constructor(S){this.rules=S}getAccEnumFromString(S){switch(S){case"sharp":return u.AccidentalEnum.SHARP;case"flat":return u.AccidentalEnum.FLAT;case"natural":return u.AccidentalEnum.NATURAL;case"double-sharp":case"sharp-sharp":return u.AccidentalEnum.DOUBLESHARP;case"double-flat":case"flat-flat":return u.AccidentalEnum.DOUBLEFLAT;case"triple-sharp":return u.AccidentalEnum.TRIPLESHARP;case"triple-flat":return u.AccidentalEnum.TRIPLEFLAT;case"quarter-sharp":return u.AccidentalEnum.QUARTERTONESHARP;case"quarter-flat":return u.AccidentalEnum.QUARTERTONEFLAT;case"three-quarters-sharp":return u.AccidentalEnum.THREEQUARTERSSHARP;case"three-quarters-flat":return u.AccidentalEnum.THREEQUARTERSFLAT;case"slash-quarter-sharp":return u.AccidentalEnum.SLASHQUARTERSHARP;case"slash-sharp":return u.AccidentalEnum.SLASHSHARP;case"double-slash-flat":return u.AccidentalEnum.DOUBLESLASHFLAT;case"sori":return u.AccidentalEnum.SORI;case"koron":return u.AccidentalEnum.KORON;default:return u.AccidentalEnum.NONE}}addArticulationExpression(S,v){var w,T;if(S!==void 0&&S.elements().length>0){const g=S.elements();for(let x=0,P=g.length;x0&&v.Articulations[0].articulationEnum!==l.ArticulationEnum.staccato&&v.Articulations.splice(0,0,A);else if(B==="breathmark")R===h.PlacementEnum.NotYetDefined&&(A.placement=h.PlacementEnum.Above);else if(B==="strongaccent"){const G=(T=_==null?void 0:_.attribute("type"))==null?void 0:T.value;G==="up"?A.articulationEnum=l.ArticulationEnum.marcatoup:G==="down"&&(A.articulationEnum=l.ArticulationEnum.marcatodown)}else if(k===l.ArticulationEnum.softaccent){const G=v.ParentSourceStaffEntry.ParentStaff.Id-1;R===h.PlacementEnum.NotYetDefined&&(R=h.PlacementEnum.Above,G>0&&(R=h.PlacementEnum.Below));const U=v.ParentSourceStaffEntry.VerticalContainerParent.ParentMeasure,C=new r.MultiExpression(U,v.Timestamp);C.StartingContinuousDynamic=new b.ContinuousDynamicExpression(b.ContDynamicEnum.crescendo,R,G,U,-1),C.StartingContinuousDynamic.IsStartOfSoftAccent=!0,C.StartingContinuousDynamic.StartMultiExpression=C,C.StartingContinuousDynamic.EndMultiExpression=C,C.EndingContinuousDynamic=new b.ContinuousDynamicExpression(b.ContDynamicEnum.diminuendo,R,G,U,-1),C.EndingContinuousDynamic.StartMultiExpression=C,C.EndingContinuousDynamic.EndMultiExpression=C,U.StaffLinkedExpressions[G].push(C)}v.hasArticulation(A)||v.Articulations.push(A)}}catch(k){return void m.default.debug("addArticulationExpression","Invalid note articulation.",k)}}}}addFermata(S,v){var g;let w=l.ArticulationEnum.fermata;S.attributes().length>0&&S.attribute("type")&&S.attribute("type").value==="inverted"&&(w=l.ArticulationEnum.invertedfermata);let T=h.PlacementEnum.Above;((g=S.attribute("placement"))==null?void 0:g.value)==="below"&&(T=h.PlacementEnum.Below),v.Articulations.push(new f.Articulation(w,T))}addTechnicalArticulations(S,v,w){var P,_;const T={bend:l.ArticulationEnum.bend,"down-bow":l.ArticulationEnum.downbow,"open-string":l.ArticulationEnum.naturalharmonic,"snap-pizzicato":l.ArticulationEnum.snappizzicato,stopped:l.ArticulationEnum.lefthandpizzicato,"up-bow":l.ArticulationEnum.upbow,harmonic:l.ArticulationEnum.naturalharmonic};for(const B in T){if(!T.hasOwnProperty(B))continue;const k=T[B],R=S.element(B);if(R){let F;((P=R.attribute("placement"))==null?void 0:P.value)==="above"&&(F=h.PlacementEnum.Above),((_=R.attribute("placement"))==null?void 0:_.value)==="below"&&(F=h.PlacementEnum.Below);const A=new f.Articulation(k,F);v.hasArticulation(A)||v.Articulations.push(A)}}const g=S.elements("fingering");for(const B of g){const k=this.createTechnicalInstruction(B,w);k.type=o.TechnicalInstructionType.Fingering,w.Fingering||(w.Fingering=k),v.TechnicalInstructions.push(k)}const x=S.element("string");if(x){const B=this.createTechnicalInstruction(x,w);B.type=o.TechnicalInstructionType.String,w.StringInstruction=B,v.TechnicalInstructions.push(B)}}createTechnicalInstruction(S,v){const w=new o.TechnicalInstruction;w.sourceNote=v,w.value=S.value;const T=S.attribute("placement");return this.rules.FingeringPositionFromXML&&(w.placement=this.getPlacement(T)),w}getPlacement(S,v=h.PlacementEnum.NotYetDefined){if(v!==h.PlacementEnum.NotYetDefined)return v;if(!S)return h.PlacementEnum.NotYetDefined;switch(S.value){case"above":return h.PlacementEnum.Above;case"below":return h.PlacementEnum.Below;case"left":return h.PlacementEnum.Left;case"right":return h.PlacementEnum.Right;default:return h.PlacementEnum.NotYetDefined}}addOrnament(S,v){if(S){let w;const T={"delayed-inverted-turn":s.OrnamentEnum.DelayedInvertedTurn,"delayed-turn":s.OrnamentEnum.DelayedTurn,"inverted-mordent":s.OrnamentEnum.InvertedMordent,"inverted-turn":s.OrnamentEnum.InvertedTurn,mordent:s.OrnamentEnum.Mordent,"trill-mark":s.OrnamentEnum.Trill,turn:s.OrnamentEnum.Turn};for(const g in T){if(!T.hasOwnProperty(g))continue;const x=S.element(g);if(x){w=new s.OrnamentContainer(T[g]);const P=x.attribute("placement");P&&P.value==="below"&&(w.placement=h.PlacementEnum.Below)}}if(w){const g=S.elements("accidental-mark");if(g){let x=h.PlacementEnum.Below,P=u.AccidentalEnum.NONE;const _=g;for(let B=0,k=_.length;B0?A.RealValue>0?(W=l.Fraction.multiply(l.Fraction.minus(A,G),W),this.directionTimestamp=l.Fraction.plus(W,A)):this.directionTimestamp=l.Fraction.createFromFraction(W):this.offsetDivisions<0&&(A.RealValue>0?(W=l.Fraction.multiply(l.Fraction.minus(A,G),W),this.directionTimestamp=l.Fraction.minus(A,W)):this.directionTimestamp=l.Fraction.createFromFraction(W));const $=k.elements("direction-type"),N=k.attribute("placement");if(N)try{const Y=N.value;Y==="below"?this.placement=v.PlacementEnum.Below:Y==="above"&&(this.placement=v.PlacementEnum.Above)}catch(Y){const tt=T.ITextTranslation.translateText("ReaderErrorMessages/ExpressionPlacementError","Invalid expression placement -> set to default.");g.default.debug("ExpressionReader.readExpressionParameters",tt,Y),this.musicSheet.SheetErrors.pushMeasureError(tt),this.placement=v.PlacementEnum.Below}try{for(const Y of $){const tt=Y.element("wedge");if(tt){const H=tt.attribute("default-y");H&&(this.WedgeYPosXml=parseInt(H.value,10),this.placement===v.PlacementEnum.NotYetDefined&&this.readExpressionPlacement(H,"read wedge y pos"))}if(this.placement===v.PlacementEnum.NotYetDefined){const H=Y.element("dynamics");if(H){const st=H.attribute("default-y");st&&this.readExpressionPlacement(st,"read dynamics y pos")}const rt=Y.element("words");if(rt){const st=rt.attribute("default-y");st&&this.readExpressionPlacement(st,"read words y pos")}const ct=Y.element("rehearsal");if(ct){const st=ct.attribute("default-y");st&&this.readExpressionPlacement(st,"read rehearsal pos")}}}}catch(Y){const tt=T.ITextTranslation.translateText("ReaderErrorMessages/ExpressionPlacementError","Invalid expression placement. Set to default.");g.default.debug("ExpressionReader.readExpressionParameters",tt,Y),this.musicSheet.SheetErrors.pushMeasureError(tt),this.placement=v.PlacementEnum.Below}this.placement===v.PlacementEnum.NotYetDefined&&(R.Staves.length>1?this.placement=v.PlacementEnum.Below:R.HasLyrics?this.placement=v.PlacementEnum.Above:this.placement=v.PlacementEnum.Below)}read(k,R,F,A=void 0){let G=!1,U=!1;const C=F.clone(),z=k.element("offset");if(z!=null&&z.value){const N=Number.parseInt(z.value,10);C.Add(new l.Fraction(N,4*this.divisions))}const W=k.element("sound");if(W){const N=W.attribute("tempo"),Y=W.attribute("dynamics");if(N){const tt=N.value.match(/^(\d+)(\.\d+)?$/);(tt==null?void 0:tt.length)>0?this.soundTempo=Math.round(Number.parseFloat(N.value)):(g.default.info("invalid xml tempo: "+N.value),this.soundTempo=100),R.TempoInBPM=this.soundTempo,this.musicSheet.DefaultStartTempoInBpm===0&&(this.musicSheet.DefaultStartTempoInBpm=this.soundTempo),this.musicSheet.HasBPMInfo=!0,G=!0}if(Y){const tt=Y.value.match(/\d+/);this.soundDynamic=tt!==void 0?parseInt(tt[0],10):100,U=!0}}const $=k.elements("direction-type");for(const N of $){let Y=N.element("metronome");if(Y){const tt=Y.elements("metronome-note"),H=Y.element("metronome-relation");if(tt.length>0&&H)this.parseComplexMetronomeMark(Y,tt,H,R,C);else{const rt=Y.element("beat-unit"),ct=Y.element("beat-unit-dot")!==void 0,st=Y.element("per-minute");if(rt!==void 0&&st){Y.hasAttributes&&Y.attribute("default-x")!==void 0&&(this.directionTimestamp=l.Fraction.createFromFraction(C));const ot=st.value.match(/(\d+\.?\d*)/),ht=ot?parseFloat(ot[1]):NaN;this.createNewTempoExpressionIfNeeded(R);const lt=new r.InstantaneousTempoExpression(void 0,this.placement,this.staffNumber,ht,this.currentMultiTempoExpression,!0);lt.parentMeasure=R,this.soundTempo=ht,R.TempoInBPM=this.soundTempo*(ct?1.5:1),this.musicSheet.DefaultStartTempoInBpm===0&&(this.musicSheet.DefaultStartTempoInBpm=this.soundTempo),this.musicSheet.HasBPMInfo=!0,lt.dotted=ct,lt.beatUnit=rt.value,this.currentMultiTempoExpression.addExpression(lt,""),this.currentMultiTempoExpression.CombinedExpressionsText="test"}}continue}if(Y=N.element("dynamics"),Y){const tt=k.element("notations")!==void 0;this.interpretInstantaneousDynamics(Y,R,C,tt);continue}if(Y=N.element("words"),Y)if(G){this.createNewTempoExpressionIfNeeded(R),this.currentMultiTempoExpression.CombinedExpressionsText=Y.value;const tt=new r.InstantaneousTempoExpression(Y.value,this.placement,this.staffNumber,this.soundTempo,this.currentMultiTempoExpression);this.currentMultiTempoExpression.addExpression(tt,"")}else U||this.interpretWords(Y,R,C);else Y=N.element("wedge"),Y?this.interpretWedge(k,Y,R,A,R.MeasureNumber):(Y=N.element("rehearsal"),Y&&this.interpretRehearsalMark(Y,R,F,R.MeasureNumber))}}closeOpenExpressions(k,R){for(const F of this.openContinuousDynamicExpressions)this.createNewMultiExpressionIfNeeded(k,F.NumberXml,R),this.closeOpenContinuousDynamic(F,k,R);this.openContinuousTempoExpression&&this.closeOpenContinuousTempo(l.Fraction.plus(k.AbsoluteTimestamp,R))}addOctaveShift(k,R,F,A=0){var W;let G=1;const U=k.element("staff");if(U)try{G=parseInt(U.value,10)}catch($){const N=T.ITextTranslation.translateText("ReaderErrorMessages/OctaveShiftStaffError","Invalid octave shift staff number. Set to default");this.musicSheet.SheetErrors.pushMeasureError(N),G=1,g.default.debug("ExpressionReader.addOctaveShift",N,$)}const C=k.elements("direction-type"),z=this.readPlacement(k);for(const $ of C){const N=$.element("octave-shift");if(N!==void 0&&N.hasAttributes)try{const Y=this.readNumber(N);if(N.attribute("size")){const tt=parseInt(N.attribute("size").value,10);let H=0;tt===8?H=1:tt===15&&(H=2);let rt=(W=N.attribute("type"))==null?void 0:W.value;if(rt||(z===v.PlacementEnum.Above?rt="down":z===v.PlacementEnum.Below&&(rt="up")),rt==="up"||rt==="down"){const ct=new u.OctaveShift(rt,H);ct.StaffNumber=G,ct.numberXml=Y,this.getMultiExpression=this.createNewMultiExpressionIfNeeded(R,Y),this.getMultiExpression.OctaveShiftStart=ct,ct.ParentStartMultiExpression=this.getMultiExpression,this.openOctaveShifts.set(Y,ct);const st=this.pendingOctaveShiftStops.get(Y);st&&(this.pendingOctaveShiftStops.delete(Y),this.getMultiExpression=this.createNewMultiExpressionIfNeeded(st.measure,Y,st.endTimestamp),this.getMultiExpression.OctaveShiftEnd=ct,ct.ParentEndMultiExpression=this.getMultiExpression,this.openOctaveShifts.delete(Y))}else if(rt==="stop"){const ct=this.openOctaveShifts.get(Y);if(ct)ct.endVoiceEntryIndex=A,this.getMultiExpression=this.createNewMultiExpressionIfNeeded(R,ct.numberXml,F),this.getMultiExpression.OctaveShiftEnd=ct,ct.ParentEndMultiExpression=this.getMultiExpression,this.openOctaveShifts.delete(Y);else{const st=l.Fraction.minus(this.directionTimestamp,new l.Fraction(1,4*this.divisions));this.pendingOctaveShiftStops.set(Y,{measure:R,endTimestamp:st})}}else rt||g.default.debug("octave-shift missing type in xml")}}catch(Y){const tt=T.ITextTranslation.translateText("ReaderErrorMessages/OctaveShiftError","Error while reading octave shift.");this.musicSheet.SheetErrors.pushMeasureError(tt),g.default.debug("ExpressionReader.addOctaveShift",tt,Y)}}}addPedalMarking(k,R,F){var G,U,C;const A=k.elements("direction-type");for(const z of A){const W=z.element("pedal");if(W&&W.hasAttributes){let $=!1,N=!1;try{switch(((G=W.attribute("line"))==null?void 0:G.value)==="yes"?N=!0:((U=W.attribute("line"))==null?void 0:U.value)==="no"?(N=!1,$=!0):((C=W.attribute("sign"))==null?void 0:C.value)==="yes"?$=!0:($=!1,N=!0),W.attribute("type").value){case"start":this.openPedal&&this.openPedal.IsLine&&this.endOpenPedal(R),this.createNewMultiExpressionIfNeeded(R,-1),this.openPedal=new _.Pedal(N,$),this.getMultiExpression.PedalStart=this.openPedal,this.openPedal.ParentStartMultiExpression=this.getMultiExpression;break;case"stop":this.openPedal&&this.endOpenPedal(R,F);break;case"change":this.openPedal&&this.openPedal.IsLine&&(this.openPedal.ChangeEnd=!0,this.createNewMultiExpressionIfNeeded(R,-1),this.getMultiExpression.PedalEnd=this.openPedal,this.openPedal.ParentEndMultiExpression=this.getMultiExpression,this.createNewMultiExpressionIfNeeded(R,-1),this.openPedal=new _.Pedal(N,$),this.openPedal.ChangeBegin=!0,this.getMultiExpression.PedalStart=this.openPedal,this.openPedal.ParentStartMultiExpression=this.getMultiExpression)}}catch(Y){const tt=T.ITextTranslation.translateText("ReaderErrorMessages/PedalError","Error while reading pedal.");this.musicSheet.SheetErrors.pushMeasureError(tt),g.default.debug("ExpressionReader.addPedalMarking",tt,Y)}}}}endOpenPedal(k,R){this.createNewMultiExpressionIfNeeded(k,-1,R),this.getMultiExpression.PedalEnd=this.openPedal,this.openPedal.ParentEndMultiExpression=this.getMultiExpression,this.openPedal=void 0}addWavyLine(k,R,F,A){if(k&&k.hasAttributes)try{switch(k.attribute("type").value){case"start":this.createNewMultiExpressionIfNeeded(R,-1),this.openWavyLine=new B.WavyLine(this.placement),this.getMultiExpression.WavyLineStart=this.openWavyLine,this.openWavyLine.ParentStartMultiExpression=this.getMultiExpression;break;case"stop":this.openWavyLine&&(this.createNewMultiExpressionIfNeeded(R,-1,F),this.getMultiExpression.WavyLineEnd=this.openWavyLine,this.openWavyLine.ParentEndMultiExpression=this.getMultiExpression,this.openWavyLine=void 0)}}catch(G){const U=T.ITextTranslation.translateText("ReaderErrorMessages/WavyLineError","Error while reading wavy-line.");this.musicSheet.SheetErrors.pushMeasureError(U),g.default.debug("ExpressionReader.addWavyLine",U,G)}}initialize(){this.placement=v.PlacementEnum.NotYetDefined,this.soundTempo=0,this.soundDynamic=0,this.offsetDivisions=0}readPlacement(k){var F;const R=(F=k.attribute("placement"))==null?void 0:F.value;return R==="above"?v.PlacementEnum.Above:R==="below"?v.PlacementEnum.Below:v.PlacementEnum.NotYetDefined}readExpressionPlacement(k,R){try{const F=this.readPosition(k);F<0?this.placement=v.PlacementEnum.Below:F>0&&(this.placement=v.PlacementEnum.Above)}catch(F){g.default.debug("ExpressionReader.readExpressionParameters",R,F)}}readPosition(k){try{const R=parseInt(k.value,10);return R<0?this.placement=v.PlacementEnum.Below:R>0&&(this.placement=v.PlacementEnum.Above),R}catch(R){g.default.debug("ExpressionReader.readExpressionParameters",R)}}parseComplexMetronomeMark(k,R,F,A,G){var H;k.hasAttributes&&k.attribute("default-x")!==void 0&&(this.directionTimestamp=l.Fraction.createFromFraction(G));const U=k.elements(),C=[],z=[];let W,$=!1;for(const rt of U){if(rt.name==="metronome-relation"){$=!0;continue}if(rt.name!=="metronome-note")continue;const ct=rt.element("metronome-type");if(!ct)continue;const st={type:ct.value,dots:rt.elements("metronome-dot").length},ot=rt.element("metronome-beam");ot&&(st.beam=ot.value);const ht=rt.element("metronome-tuplet");if(ht&&(ht.hasAttributes?(H=ht.attribute("type"))==null?void 0:H.value:void 0)==="start"){const lt=ht.element("actual-notes"),O=ht.element("normal-notes"),D=ht.attribute("bracket"),j=ht.attribute("show-number");W={actualNotes:lt?parseInt(lt.value,10):3,normalNotes:O?parseInt(O.value,10):2,bracket:!D||D.value==="yes",showNumber:j?j.value:"actual"}}$?z.push(st):C.push(st)}const N={notes:C},Y={notes:z,tuplet:W};this.createNewTempoExpressionIfNeeded(A);const tt=new r.InstantaneousTempoExpression(void 0,this.placement,this.staffNumber,this.soundTempo,this.currentMultiTempoExpression,!0);tt.parentMeasure=A,tt.metronomeNoteGroupLeft=N,tt.metronomeNoteGroupRight=Y,tt.metronomeRelation=F.value,this.musicSheet.DefaultStartTempoInBpm===0&&(this.musicSheet.DefaultStartTempoInBpm=this.soundTempo),this.musicSheet.HasBPMInfo=!0,this.currentMultiTempoExpression.addExpression(tt,""),this.currentMultiTempoExpression.CombinedExpressionsText="test"}interpretInstantaneousDynamics(k,R,F,A){var G,U,C;if(k.hasElements){k.hasAttributes&&k.attribute("default-x")&&(this.directionTimestamp=l.Fraction.createFromFraction(F));const z=this.readNumber(k);let W=(G=k.elements()[0])==null?void 0:G.name;if(W==="other-dynamics"&&(W=k.elements()[0].value),W){if((U=R.Rules)!=null&&U.IgnoreRepeatedDynamics){let N;try{N=h.DynamicEnum[W]}catch{const tt=T.ITextTranslation.translateText("ReaderErrorMessages/DynamicError","Error while reading dynamic.");return void this.musicSheet.SheetErrors.pushMeasureError(tt)}if(((C=this.activeInstantaneousDynamic)==null?void 0:C.DynEnum)===N)return}A?this.createNewMultiExpressionIfNeeded(R,z,l.Fraction.createFromFraction(F)):this.createNewMultiExpressionIfNeeded(R,z);const $=new h.InstantaneousDynamicExpression(W,this.soundDynamic,this.placement,this.staffNumber,R);$.InMeasureTimestamp=F.clone(),this.getMultiExpression.addExpression($,""),this.activeInstantaneousDynamic?this.activeInstantaneousDynamic.DynEnum=$.DynEnum:this.activeInstantaneousDynamic=new h.InstantaneousDynamicExpression(W,0,v.PlacementEnum.NotYetDefined,1,R)}}}interpretWords(k,R,F){var tt;const A=k.value;if(R.Rules.IgnoreBracketsWords&&(/^\(\s*\)$/.test(A)||/^\[\s*\]$/.test(A)))return;let G;const U=k.attribute("font-style");let C,z,W;U&&(C=U.value,C==="italic"&&(G=x.FontStyles.Italic));const $=k.attribute("font-weight");$&&(z=$.value,z==="bold"&&(G=x.FontStyles.Bold,C==="italic"&&(G=x.FontStyles.BoldItalic)));const N=k.attribute("color");let Y;if(N&&(W=N.value),R.Rules.PlaceWordsInsideStafflineFromXml){const H=(tt=k.attribute("default-y"))==null?void 0:tt.value;(H==null?void 0:H.length)>0&&(Y=Number.parseInt(H,10))}if(A.length>0){if(k.hasAttributes&&k.attribute("default-x")&&(this.directionTimestamp=l.Fraction.createFromFraction(F)),this.checkIfWordsNodeIsRepetitionInstruction(A))return;this.fillMultiOrTempoExpression(A,R,F,G,W,Y),this.initialize()}}readNumber(k){var A;let R=1;const F=(A=k.attribute("number"))==null?void 0:A.value;return F&&(R=Number.parseInt(F,10)),R}interpretWedge(k,R,F,A,G){var z,W;R!==void 0&&R.hasAttributes&&R.attribute("default-x")&&(this.directionTimestamp=l.Fraction.createFromFraction(A));const U=this.readNumber(R),C=(W=(z=R.attribute("type"))==null?void 0:z.value)==null?void 0:W.toLowerCase();this.lastWedge&&this.lastWedge.parentMeasure.MeasureNumberXML===F.MeasureNumberXML&&this.lastWedge.StaffNumber===this.staffNumber&&this.placement===this.lastWedge.Placement&&this.WedgeYPosXml!==void 0&&this.lastWedge.YPosXml===this.WedgeYPosXml&&this.lastWedge.StartMultiExpression.Timestamp.Equals(this.directionTimestamp)&&this.lastWedge.DynamicType===o.ContDynamicEnum[C]||(C==="stop"?(this.createNewMultiExpressionIfNeeded(F,U,A),this.getMultiExpression.EndOffsetFraction=new l.Fraction(this.offsetDivisions,4*this.divisions)):this.createNewMultiExpressionIfNeeded(F,U),this.addWedge(R,F,A),this.initialize())}interpretRehearsalMark(k,R,F,A){R.rehearsalExpression=new P.RehearsalExpression(k.value,this.placement)}createNewMultiExpressionIfNeeded(k,R,F=void 0){F||(F=this.directionTimestamp);let A=this.getMultiExpression;return(!A||A&&(A.SourceMeasureParent!==k||A.numberXml!==R||A.SourceMeasureParent===k&&!A.Timestamp.Equals(F)))&&(this.getMultiExpression=A=new f.MultiExpression(k,l.Fraction.createFromFraction(F)),this.getMultiExpression.numberXml=R,k.StaffLinkedExpressions[this.globalStaffIndex].push(A)),A}createNewTempoExpressionIfNeeded(k){this.currentMultiTempoExpression&&this.currentMultiTempoExpression.SourceMeasureParent===k&&this.currentMultiTempoExpression.Timestamp===this.directionTimestamp||(this.currentMultiTempoExpression=new m.MultiTempoExpression(k,l.Fraction.createFromFraction(this.directionTimestamp)),k.TempoExpressions.push(this.currentMultiTempoExpression))}addWedge(k,R,F){if(k!==void 0&&k.hasAttributes){const A=this.readNumber(k),G=k.attribute("type").value.toLowerCase();try{if(G==="crescendo"||G==="diminuendo"){const U=new o.ContinuousDynamicExpression(o.ContDynamicEnum[G],this.placement,this.staffNumber,R,A);this.lastWedge=U,this.lastWedge.YPosXml=this.WedgeYPosXml,this.openContinuousDynamicExpressions.push(U);let C=this.getMultiExpression;C||(C=this.createNewMultiExpressionIfNeeded(R,A)),C.StartingContinuousDynamic=U,U.StartMultiExpression=C,this.activeInstantaneousDynamic!==void 0&&this.activeInstantaneousDynamic.StaffNumber===U.StaffNumber&&(this.activeInstantaneousDynamic=void 0)}else if(G==="stop")for(const U of this.openContinuousDynamicExpressions)U.NumberXml===A&&this.closeOpenContinuousDynamic(U,R,F)}catch(U){const C="ReaderErrorMessages/WedgeError, Error while reading Crescendo / Diminuendo.";this.musicSheet.SheetErrors.pushMeasureError(C),g.default.debug("ExpressionReader.addWedge",C,U)}}}fillMultiOrTempoExpression(k,R,F,A,G,U=void 0){if(!k)return;const C=k.trim();this.createExpressionFromString("",C,R,F,k,A,G,U)}createExpressionFromString(k,R,F,A,G,U,C,z=void 0){const W=r.InstantaneousTempoExpression.isInputStringInstantaneousTempo(R),$=s.ContinuousTempoExpression.isInputStringContinuousTempo(R);if(W||$){if(F.TempoExpressions.length>0)for(let H=0,rt=F.TempoExpressions.length;H0)for(let H=0,rt=F.TempoExpressions.length;H0&&!this.hasDigit(R)&&this.globalStaffIndex>0){if(ct.EntriesList[0].label.indexOf(R)>=0)return!1;break}}let Y=this.musicSheet.Rules.UnknownExpressionTextAlignment;this.musicSheet.Rules.CompactMode&&(Y=w.TextAlignmentEnum.LeftBottom);const tt=new S.UnknownExpression(R,this.placement,Y,this.staffNumber);return tt.fontStyle=U,tt.ColorXML=C,tt.defaultYXml=z,tt.parentMeasure=F,N.addExpression(tt,k),!1}closeOpenContinuousDynamic(k,R,F){if(!k)return;const A=k.NumberXml;k.EndMultiExpression=this.createNewMultiExpressionIfNeeded(R,A,F),k.StartMultiExpression.EndingContinuousDynamic=k,this.openContinuousDynamicExpressions=this.openContinuousDynamicExpressions.filter(G=>G!==k)}closeOpenContinuousTempo(k){this.openContinuousTempoExpression.AbsoluteEndTimestamp=k,this.openContinuousTempoExpression=void 0}checkIfWordsNodeIsRepetitionInstruction(k){return(k=k.trim().toLowerCase())==="coda"||k==="tocoda"||k==="to coda"||k==="fine"||k==="d.c."||k==="dacapo"||k==="da capo"||k==="d.s."||k==="dalsegno"||k==="dal segno"||k==="d.c. al fine"||k==="d.s. al fine"||k==="d.c. al coda"||k==="d.s. al coda"}hasDigit(k){return/\d/.test(k)}}},6030(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.LyricsReader=void 0;const d=p(649),l=p(2317),m=p(9767);y.LyricsReader=class{constructor(o){this.openLyricWords={},this.musicSheet=o}addLyricEntry(o,s){var h,u;if(o){const f=o;for(let r=0,b=f.length;r0)for(let F=R;F<_.length;F++){const A=_[F];A.name==="text"&&(B=A),A.name==="syllabic"&&(k=A)}B!==void 0&&k&&(w=B,v="middle")}let x,P="1";if(S.attributes()!==void 0&&S.attribute("number")&&(P=S.attribute("number").value),v==="single"||v==="end"){if(this.openLyricWords[P]){this.currentLyricWord=this.openLyricWords[P];const _=this.currentLyricWord.Syllables.length;x=new l.LyricsEntry(T,P,this.currentLyricWord,s,_),this.currentLyricWord.Syllables.push(x),delete this.openLyricWords[P],this.currentLyricWord=void 0}else x=new l.LyricsEntry(T,P,void 0,s);x.extend=S.element("extend")!==void 0}else if(v==="begin")this.openLyricWords[P]&&(delete this.openLyricWords[P],this.currentLyricWord=void 0),this.currentLyricWord=new d.LyricWord,this.openLyricWords[P]=this.currentLyricWord,x=new l.LyricsEntry(T,P,this.currentLyricWord,s,0),this.currentLyricWord.Syllables.push(x);else if(v==="middle")if(this.openLyricWords[P]){this.currentLyricWord=this.openLyricWords[P];const _=this.currentLyricWord.Syllables.length;x=new l.LyricsEntry(T,P,this.currentLyricWord,s,_),this.currentLyricWord.Syllables.push(x)}else x=new l.LyricsEntry(T,P,void 0,s);x&&(s.LyricsEntries[P]||(s.LyricsEntries.setValue(P,x),(u=(h=s.ParentSourceStaffEntry)==null?void 0:h.VerticalContainerParent)!=null&&u.ParentMeasure&&(s.ParentSourceStaffEntry.VerticalContainerParent.ParentMeasure.hasLyrics=!0)),s.ParentVoice.Parent.LyricVersesNumbers.includes(P)||s.ParentVoice.Parent.LyricVersesNumbers.push(P))}}}catch{const w=m.ITextTranslation.translateText("ReaderErrorMessages/LyricError","Error while reading lyric entry.");this.musicSheet.SheetErrors.pushMeasureError(w);continue}}}}}},6302(St,y,p){var d=this&&this.__importDefault||function(f){return f&&f.__esModule?f:{default:f}};Object.defineProperty(y,"__esModule",{value:!0}),y.RepetitionBuildingContainer=y.RepetitionCalculator=void 0;const l=p(1645),m=p(1645),o=p(7307),s=p(4076),h=d(p(3065));y.RepetitionCalculator=class{constructor(){this.repetitionInstructions=[],this.openRepetitions=[],this.lastRepetitionCommonPartStartIndex=0}calculateRepetitions(f,r){this.musicSheet=f,this.repetitionInstructions=r,this.openRepetitions.length=0,this.lastRepetitionCommonPartStartIndex=0;const b=this.musicSheet.SourceMeasures,S=new Set;for(let g=1;g1&&S.add(g)}let v=0;for(const g of this.repetitionInstructions){if(this.currentMeasureIndex=g.measureIndex,this.currentMeasureIndex>v){for(const x of S)if(x>v&&x<=this.currentMeasureIndex){for(;this.openRepetitions.length>0;)this.finalizeRepetition(this.openRepetitions.last());this.lastRepetitionCommonPartStartIndex=x;break}}v=this.currentMeasureIndex;try{this.currentMeasure=b[this.currentMeasureIndex],this.handleRepetitionInstructions(g)}catch(x){h.default.error("RepetitionCalculator: calculateRepetitions",x)}}for(;this.openRepetitions.length>0;)try{const g=this.openRepetitions.last();if(g.RepetitonUnderConstruction.FromWords){if(g.WaitingForCoda){let x=g.RepetitonUnderConstruction.BackwardJumpInstructions.last().measureIndex+1;x>=this.musicSheet.SourceMeasures.length&&(x=-1),g.RepetitonUnderConstruction.setEndingStartIndex(2,x)}else if(g.RepetitonUnderConstruction.BackwardJumpInstructions.length===0){this.openRepetitions.splice(this.openRepetitions.length-1,1);continue}}else if(g.RepetitonUnderConstruction.BackwardJumpInstructions.length===0){const x=b.length-1,P=new l.RepetitionInstruction(x,l.RepetitionInstructionEnum.BackJumpLine,l.AlignmentType.End,g.RepetitonUnderConstruction);g.RepetitonUnderConstruction.BackwardJumpInstructions.push(P),b[x].LastRepetitionInstructions.push(P)}this.finalizeRepetition(this.openRepetitions.last())}catch{try{const x=this.openRepetitions.last().RepetitonUnderConstruction;for(const P of this.repetitionInstructions)P.parentRepetition===x&&(P.parentRepetition=void 0);this.openRepetitions.splice(this.openRepetitions.length-1,1)}catch(x){h.default.error("RepetitionCalculator: calculateRepetitions2",x)}}let w=!1;const T=this.musicSheet.SourceMeasures.length-1;for(const g of this.musicSheet.Repetitions)if(g.StartIndex===0&&g.EndIndex===T){w=!0;break}if(!w){const g=new s.Repetition(this.musicSheet,!0);g.FromWords=!0,g.startMarker=new l.RepetitionInstruction(0,l.RepetitionInstructionEnum.StartLine),g.startMarker.parentRepetition=g,this.musicSheet.SourceMeasures[0].FirstRepetitionInstructions.push(g.startMarker),g.endMarker=new l.RepetitionInstruction(T,l.RepetitionInstructionEnum.BackJumpLine),g.endMarker.parentRepetition=g,g.BackwardJumpInstructions.push(g.endMarker),g.UserNumberOfRepetitions=g.DefaultNumberOfRepetitions,this.musicSheet.Repetitions.push(g)}for(let g=0,x=this.musicSheet.SourceMeasures.length;g1&&P.FirstRepetitionInstructions.sort(m.RepetitionInstructionComparer.Compare),P.LastRepetitionInstructions.length>1&&P.LastRepetitionInstructions.sort(m.RepetitionInstructionComparer.Compare)}}handleRepetitionInstructions(f){let r;switch(f.type){case l.RepetitionInstructionEnum.StartLine:r=this.createNewRepetition(this.currentMeasureIndex),f.parentRepetition=r.RepetitonUnderConstruction,r.RepetitonUnderConstruction.FromWords=!1,r.RepetitonUnderConstruction.startMarker=f,this.currentMeasure.FirstRepetitionInstructions.push(f);break;case l.RepetitionInstructionEnum.BackJumpLine:r=this.getOrCreateCurrentRepetition2(!1),f.parentRepetition=r.RepetitonUnderConstruction,r.RepetitonUnderConstruction.BackwardJumpInstructions.push(f),this.currentMeasure.LastRepetitionInstructions.push(f),r.RepetitonUnderConstruction.EndingParts.length===0&&this.finalizeRepetition(r);break;case l.RepetitionInstructionEnum.Ending:if(r=this.getOrCreateCurrentRepetition(),f.parentRepetition=r.RepetitonUnderConstruction,f.endingIndices.contains(1)&&f.alignment===l.AlignmentType.Begin){if(r.RepetitonUnderConstruction.BackwardJumpInstructions.length>0||r.RepetitonUnderConstruction.EndingIndexDict.hasOwnProperty(1)){r=void 0;for(let b=this.openRepetitions.length-1;b>=0;b--){const S=this.openRepetitions[b];if(S.RepetitonUnderConstruction.BackwardJumpInstructions.length===0)for(r=S;this.openRepetitions.length-1>b;){const v=this.openRepetitions.last();this.finalizeRepetition(v)}}r===void 0&&(r=this.createNewRepetition(0),r.RepetitonUnderConstruction.startMarker=new l.RepetitionInstruction(0,l.RepetitionInstructionEnum.None))}r.RepetitonUnderConstruction.forwardJumpInstruction===void 0&&(r.RepetitonUnderConstruction.forwardJumpInstruction=new l.RepetitionInstruction(this.currentMeasureIndex-1,l.RepetitionInstructionEnum.ForwardJump,l.AlignmentType.End,r.RepetitonUnderConstruction),this.musicSheet.SourceMeasures[this.currentMeasureIndex-1].LastRepetitionInstructions.push(r.RepetitonUnderConstruction.forwardJumpInstruction))}if(f.alignment===l.AlignmentType.Begin)r.RepetitonUnderConstruction.setEndingsStartIndex(f.endingIndices,this.currentMeasureIndex),this.currentMeasure.FirstRepetitionInstructions.push(f);else for(let b=0,S=f.endingIndices.length;b0&&Math.abs(r.RepetitonUnderConstruction.BackwardJumpInstructions.last().measureIndex-this.currentMeasureIndex)<=1)break;r=this.createNewRepetition(this.currentMeasureIndex),f.parentRepetition=r.RepetitonUnderConstruction,r.RepetitonUnderConstruction.FromWords=!0,r.SegnoFound=!0,r.RepetitonUnderConstruction.startMarker=f,this.currentMeasure.FirstRepetitionInstructions.push(f);break;case l.RepetitionInstructionEnum.Fine:if(this.openRepetitions.length===0||(r=this.getCurrentRepetition(!0),r===void 0))break;f.parentRepetition=r.RepetitonUnderConstruction,r.RepetitonUnderConstruction.FromWords=!0,r.RepetitonUnderConstruction.forwardJumpInstruction===void 0?(r.FineFound=!0,r.RepetitonUnderConstruction.forwardJumpInstruction=f,r.RepetitonUnderConstruction.setEndingStartIndex(2,-2),this.currentMeasure.LastRepetitionInstructions.push(f)):this.currentMeasure.LastRepetitionInstructions.push(new l.RepetitionInstruction(this.currentMeasureIndex,l.RepetitionInstructionEnum.Fine,l.AlignmentType.End,void 0));break;case l.RepetitionInstructionEnum.ToCoda:if(this.openRepetitions.length===0||(r=this.getCurrentRepetition(!0),r===void 0))break;r.RepetitonUnderConstruction.forwardJumpInstruction===void 0&&(f.parentRepetition=r.RepetitonUnderConstruction,r.RepetitonUnderConstruction.FromWords=!0,r.ToCodaFound=!0,r.RepetitonUnderConstruction.forwardJumpInstruction=f,this.currentMeasure.LastRepetitionInstructions.push(f));break;case l.RepetitionInstructionEnum.Coda:if(this.openRepetitions.length===0)break;r=this.getOrCreateCurrentRepetition2(!0),f.parentRepetition=r.RepetitonUnderConstruction,r.WaitingForCoda?(r.CodaFound=!0,r.RepetitonUnderConstruction.setEndingStartIndex(2,this.currentMeasureIndex),this.currentMeasure.LastRepetitionInstructions.push(f),this.finalizeRepetition(r),this.currentMeasureIndex>0&&(this.musicSheet.SourceMeasures[this.currentMeasureIndex-1].printNewSystemXml=!0)):r.ToCodaFound||(r.RepetitonUnderConstruction.BackwardJumpInstructions.length===0?(r.ToCodaFound=!0,r.RepetitonUnderConstruction.forwardJumpInstruction=new l.RepetitionInstruction(this.currentMeasureIndex,l.RepetitionInstructionEnum.ToCoda,l.AlignmentType.End,r.RepetitonUnderConstruction),this.currentMeasure.LastRepetitionInstructions.push(r.RepetitonUnderConstruction.forwardJumpInstruction)):this.currentMeasure.LastRepetitionInstructions.push(new l.RepetitionInstruction(this.currentMeasureIndex,l.RepetitionInstructionEnum.Coda,l.AlignmentType.Begin,void 0)));break;case l.RepetitionInstructionEnum.DaCapo:r=this.getOrCreateCurrentRepetition(),r.RepetitonUnderConstruction.BackwardJumpInstructions.length>0&&this.finalizeRepetition(r),r.RepetitonUnderConstruction.StartIndex!==0&&(r=this.createNewRepetition(0)),f.parentRepetition=r.RepetitonUnderConstruction,r.RepetitonUnderConstruction.FromWords=!0,r.RepetitonUnderConstruction.startMarker=new l.RepetitionInstruction(0,l.RepetitionInstructionEnum.None,l.AlignmentType.Begin,r.RepetitonUnderConstruction),r.RepetitonUnderConstruction.BackwardJumpInstructions.push(f),this.currentMeasure.LastRepetitionInstructions.push(f),r.RepetitonUnderConstruction.EndingParts.length===0&&this.finalizeRepetition(r);break;case l.RepetitionInstructionEnum.DalSegno:if(r=this.getOrCreateCurrentRepetition2(!0),r.RepetitonUnderConstruction.BackwardJumpInstructions.length>0&&(this.finalizeRepetition(r),r=this.createNewRepetition(0),r.RepetitonUnderConstruction.FromWords=!0,r.RepetitonUnderConstruction.startMarker=new l.RepetitionInstruction(0,l.RepetitionInstructionEnum.None,l.AlignmentType.Begin,r.RepetitonUnderConstruction)),f.parentRepetition=r.RepetitonUnderConstruction,!r.SegnoFound){const b=this.findInstructionInMainListBackwards(l.RepetitionInstructionEnum.Segno,f.measureIndex);b>=0&&(r.SegnoFound=!0,r.RepetitonUnderConstruction.startMarker=new l.RepetitionInstruction(b,l.RepetitionInstructionEnum.Segno,l.AlignmentType.Begin,r.RepetitonUnderConstruction),this.musicSheet.SourceMeasures[b].FirstRepetitionInstructions.splice(0,0,r.RepetitonUnderConstruction.startMarker))}r.RepetitonUnderConstruction.EndingIndexDict.hasOwnProperty(1)&&r.RepetitonUnderConstruction.setEndingEndIndex(1,this.currentMeasureIndex),r.RepetitonUnderConstruction.BackwardJumpInstructions.push(f),this.currentMeasure.LastRepetitionInstructions.push(f);break;case l.RepetitionInstructionEnum.DalSegnoAlFine:if(this.openRepetitions.length===0)break;if(r=this.getOrCreateCurrentRepetition2(!0),f.parentRepetition=r.RepetitonUnderConstruction,!r.SegnoFound){const b=this.findInstructionInMainListBackwards(l.RepetitionInstructionEnum.Segno,f.measureIndex);b>=0&&(r.SegnoFound=!0,r.RepetitonUnderConstruction.startMarker=new l.RepetitionInstruction(b,l.RepetitionInstructionEnum.Segno,l.AlignmentType.Begin,r.RepetitonUnderConstruction),this.musicSheet.SourceMeasures[b].FirstRepetitionInstructions.splice(0,0,r.RepetitonUnderConstruction.startMarker))}if(!r.FineFound){const b=this.findInstructionInMainListBackwards(l.RepetitionInstructionEnum.Fine,f.measureIndex);b>=0&&(r.FineFound=!0,r.RepetitonUnderConstruction.forwardJumpInstruction=new l.RepetitionInstruction(b,l.RepetitionInstructionEnum.Fine,l.AlignmentType.Begin,r.RepetitonUnderConstruction),r.RepetitonUnderConstruction.setEndingStartIndex(2,-2),this.musicSheet.SourceMeasures[b].LastRepetitionInstructions.splice(0,0,r.RepetitonUnderConstruction.forwardJumpInstruction))}r.RepetitonUnderConstruction.EndingIndexDict.hasOwnProperty(1)||r.RepetitonUnderConstruction.setEndingEndIndex(1,this.currentMeasureIndex),r.RepetitonUnderConstruction.BackwardJumpInstructions.push(f),this.currentMeasure.LastRepetitionInstructions.push(f);break;case l.RepetitionInstructionEnum.DaCapoAlFine:if(r=this.getOrCreateCurrentRepetition(),r.RepetitonUnderConstruction.BackwardJumpInstructions.length>0&&(this.finalizeRepetition(r),r=this.createNewRepetition(0)),r.RepetitonUnderConstruction.startMarker!==void 0&&r.RepetitonUnderConstruction.StartIndex!==0&&(r=this.createNewRepetition(0)),r.RepetitonUnderConstruction.startMarker=new l.RepetitionInstruction(0,l.RepetitionInstructionEnum.None,l.AlignmentType.Begin,r.RepetitonUnderConstruction),r.RepetitonUnderConstruction.FromWords=!0,f.parentRepetition=r.RepetitonUnderConstruction,!r.FineFound){const b=this.findInstructionInMainListBackwards(l.RepetitionInstructionEnum.Fine,f.measureIndex);b>=0&&(r.FineFound=!0,r.RepetitonUnderConstruction.forwardJumpInstruction=new l.RepetitionInstruction(b,l.RepetitionInstructionEnum.Fine,l.AlignmentType.Begin,r.RepetitonUnderConstruction),r.RepetitonUnderConstruction.setEndingStartIndex(2,-2),this.musicSheet.SourceMeasures[b].LastRepetitionInstructions.splice(0,0,r.RepetitonUnderConstruction.forwardJumpInstruction))}r.RepetitonUnderConstruction.EndingIndexDict.hasOwnProperty(1)||r.RepetitonUnderConstruction.setEndingEndIndex(1,this.currentMeasureIndex),r.RepetitonUnderConstruction.BackwardJumpInstructions.push(f),this.currentMeasure.LastRepetitionInstructions.push(f);break;case l.RepetitionInstructionEnum.DalSegnoAlCoda:if(this.openRepetitions.length===0)break;if(r=this.getOrCreateCurrentRepetition2(!0),f.parentRepetition=r.RepetitonUnderConstruction,!r.SegnoFound){const b=this.findInstructionInMainListBackwards(l.RepetitionInstructionEnum.Segno,f.measureIndex);b>=0&&(r.SegnoFound=!0,r.RepetitonUnderConstruction.startMarker=new l.RepetitionInstruction(b,l.RepetitionInstructionEnum.Segno,l.AlignmentType.Begin,r.RepetitonUnderConstruction),this.musicSheet.SourceMeasures[b].FirstRepetitionInstructions.splice(0,0,r.RepetitonUnderConstruction.startMarker))}if(!r.ToCodaFound){const b=this.findInstructionInMainListBackwards(l.RepetitionInstructionEnum.ToCoda,f.measureIndex);if(b>=0)r.RepetitonUnderConstruction.forwardJumpInstruction=new l.RepetitionInstruction(b,l.RepetitionInstructionEnum.ToCoda,l.AlignmentType.Begin,r.RepetitonUnderConstruction),this.musicSheet.SourceMeasures[b].LastRepetitionInstructions.splice(0,0,r.RepetitonUnderConstruction.forwardJumpInstruction),r.ToCodaFound=!0;else{const S=this.findInstructionInMainListBackwards(l.RepetitionInstructionEnum.Coda,f.measureIndex);S>=0&&(r.RepetitonUnderConstruction.forwardJumpInstruction=new l.RepetitionInstruction(S,l.RepetitionInstructionEnum.ToCoda,l.AlignmentType.Begin,r.RepetitonUnderConstruction),this.musicSheet.SourceMeasures[S].LastRepetitionInstructions.splice(0,0,r.RepetitonUnderConstruction.forwardJumpInstruction),r.ToCodaFound=!0)}}r.ToCodaFound&&(r.WaitingForCoda=!0),r.RepetitonUnderConstruction.EndingIndexDict.hasOwnProperty(1)||r.RepetitonUnderConstruction.setEndingEndIndex(1,this.currentMeasureIndex),r.RepetitonUnderConstruction.BackwardJumpInstructions.push(f),this.currentMeasure.LastRepetitionInstructions.push(f);break;case l.RepetitionInstructionEnum.DaCapoAlCoda:if(r=this.getOrCreateCurrentRepetition(),r.RepetitonUnderConstruction.BackwardJumpInstructions.length>0?(this.finalizeRepetition(r),r=this.createNewRepetition(0)):r.RepetitonUnderConstruction.EndingParts.length===0&&(r=this.createNewRepetition(0)),r.RepetitonUnderConstruction.startMarker!==void 0&&r.RepetitonUnderConstruction.StartIndex!==0&&(r=this.createNewRepetition(0)),r.RepetitonUnderConstruction.startMarker=new l.RepetitionInstruction(0,l.RepetitionInstructionEnum.None,l.AlignmentType.Begin,r.RepetitonUnderConstruction),r.RepetitonUnderConstruction.FromWords=!0,f.parentRepetition=r.RepetitonUnderConstruction,!r.ToCodaFound){const b=this.findInstructionInMainListBackwards(l.RepetitionInstructionEnum.ToCoda,f.measureIndex);if(b>=0)r.RepetitonUnderConstruction.forwardJumpInstruction=new l.RepetitionInstruction(b,l.RepetitionInstructionEnum.ToCoda,l.AlignmentType.Begin,r.RepetitonUnderConstruction),this.musicSheet.SourceMeasures[b].LastRepetitionInstructions.splice(0,0,r.RepetitonUnderConstruction.forwardJumpInstruction),r.ToCodaFound=!0;else{const S=this.findInstructionInMainListBackwards(l.RepetitionInstructionEnum.Coda,f.measureIndex);S>=0&&(r.RepetitonUnderConstruction.forwardJumpInstruction=new l.RepetitionInstruction(S,l.RepetitionInstructionEnum.ToCoda,l.AlignmentType.Begin,r.RepetitonUnderConstruction),this.musicSheet.SourceMeasures[S].LastRepetitionInstructions.splice(0,0,r.RepetitonUnderConstruction.forwardJumpInstruction),r.ToCodaFound=!0)}}r.ToCodaFound&&(r.WaitingForCoda=!0),r.RepetitonUnderConstruction.EndingIndexDict.hasOwnProperty(1)||r.RepetitonUnderConstruction.setEndingEndIndex(1,this.currentMeasureIndex),r.RepetitonUnderConstruction.BackwardJumpInstructions.push(f),this.currentMeasure.LastRepetitionInstructions.push(f);break;case l.RepetitionInstructionEnum.None:break;default:throw new o.ArgumentOutOfRangeException("currentRepetitionInstruction")}return!0}findInstructionInMainListBackwards(f,r){for(let b=this.repetitionInstructions.length-1;b>=0;b--){const S=this.repetitionInstructions[b];if(S.measureIndex<=r&&S.type===f)return S.measureIndex}return-1}finalizeRepetition(f){const r=f.RepetitonUnderConstruction;if(r.BackwardJumpInstructions.length>0){let b=!0;const S=this.getLastFinalizedRepetition();if(S!==void 0&&r.coversIdenticalMeasures(S)){if(r.NumberOfEndings>S.NumberOfEndings){const v=this.musicSheet.Repetitions.indexOf(S,0);v>-1&&this.musicSheet.Repetitions.splice(v,1),S.removeFromRepetitionInstructions(),this.musicSheet.Repetitions.push(r)}b=!1,r.removeFromRepetitionInstructions()}else this.musicSheet.Repetitions.push(r);if(b){r.startMarker.type===l.RepetitionInstructionEnum.None&&this.musicSheet.SourceMeasures[r.StartIndex].FirstRepetitionInstructions.push(r.startMarker);let v=r.DefaultNumberOfRepetitions;r.BackwardJumpInstructions.length===1&&r.BackwardJumpInstructions[0].Times>0&&(v=r.BackwardJumpInstructions[0].Times),r.UserNumberOfRepetitions=v}}this.openRepetitions.splice(this.openRepetitions.length-1,1)}getCurrentRepetition(f){let r;for(let b=this.openRepetitions.length-1;b>=0;b--)if(this.openRepetitions[b].RepetitonUnderConstruction.FromWords===f){for(r=this.openRepetitions[b];b0)return this.openRepetitions.last();const f=this.createNewRepetition(0);return f.RepetitonUnderConstruction.startMarker=new l.RepetitionInstruction(0,l.RepetitionInstructionEnum.None,l.AlignmentType.Begin,f.RepetitonUnderConstruction),f}getOrCreateCurrentRepetition2(f){let r;for(let b=this.openRepetitions.length-1;b>=0;b--)if(r=this.openRepetitions[b],r.RepetitonUnderConstruction.FromWords===f){for(;b0){const b=this.openRepetitions.last(),S=b.RepetitonUnderConstruction;if(S.BackwardJumpInstructions.length>0){const v=Object.keys(S.EndingIndexDict);(v.length===0||S.EndingIndexDict[v[v.length-1]].part.EndIndex>=0)&&this.finalizeRepetition(b)}}const r=new u(this.musicSheet);return this.lastRepetitionCommonPartStartIndex=f,this.openRepetitions.push(r),r}getLastFinalizedRepetition(){if(this.musicSheet.Repetitions.length>0)return this.musicSheet.Repetitions.last()}};class u{constructor(r){this.RepetitonUnderConstruction=new s.Repetition(r)}}y.RepetitionBuildingContainer=u},7631(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.RepetitionInstructionReader=void 0;const d=p(1645),l=p(1645),m=p(4356);y.RepetitionInstructionReader=class{set MusicSheet(o){this.musicSheet=o,this.xmlMeasureList=new Array(this.musicSheet.Instruments.length),this.repetitionInstructions=[]}prepareReadingMeasure(o,s){this.currentMeasureIndex=s}handleLineRepetitionInstructions(o){var h;let s=!1;if(o.elements().length>0){let u="",f=!1,r="",b="",S="";const v=[],w=o.element("bar-style");w&&(S=w.value),u=o.attributes().length>0&&o.attribute("location")?o.attribute("location").value:"right";const T=o.elements();for(let g=0,x=T.length;g0)if(u==="left"){if(b==="start"){const g=new d.RepetitionInstruction(this.currentMeasureIndex,d.RepetitionInstructionEnum.Ending,d.AlignmentType.Begin,void 0,v);this.addInstruction(this.repetitionInstructions,g)}if(r==="forward"){const g=new d.RepetitionInstruction(this.currentMeasureIndex,d.RepetitionInstructionEnum.StartLine);this.addInstruction(this.repetitionInstructions,g)}}else{if(b==="stop"){const g=new d.RepetitionInstruction(this.currentMeasureIndex,d.RepetitionInstructionEnum.Ending,d.AlignmentType.End,void 0,v);this.addInstruction(this.repetitionInstructions,g)}else if(b==="discontinue"){const g=new d.RepetitionInstruction(this.currentMeasureIndex,d.RepetitionInstructionEnum.Ending,d.AlignmentType.Discontinue,void 0,v);this.addInstruction(this.repetitionInstructions,g)}if(r==="backward"){const g=new d.RepetitionInstruction(this.currentMeasureIndex,d.RepetitionInstructionEnum.BackJumpLine);this.addInstruction(this.repetitionInstructions,g)}}}return s}handleRepetitionInstructionsFromWordsOrSymbols(o,s){const h=o.element("words"),u=this.currentMeasureIndex;if(h){const f="d\\s?\\.s\\.",r=h.value.trim().toLowerCase();if(m.StringUtil.StringContainsSeparatedWord(r,f+" al fine",!0)){const S=new d.RepetitionInstruction(u,d.RepetitionInstructionEnum.DalSegnoAlFine);return this.addInstruction(this.repetitionInstructions,S),!0}const b="d\\.\\s?c\\.";if(m.StringUtil.StringContainsSeparatedWord(r,b+" al coda",!0)){const S=new d.RepetitionInstruction(u,d.RepetitionInstructionEnum.DaCapoAlCoda);return this.addInstruction(this.repetitionInstructions,S),!0}if(m.StringUtil.StringContainsSeparatedWord(r,b+" al fine",!0)){const S=new d.RepetitionInstruction(u,d.RepetitionInstructionEnum.DaCapoAlFine);return this.addInstruction(this.repetitionInstructions,S),!0}if(m.StringUtil.StringContainsSeparatedWord(r,b+" al coda",!0)){const S=new d.RepetitionInstruction(u,d.RepetitionInstructionEnum.DaCapoAlCoda);return this.addInstruction(this.repetitionInstructions,S),!0}if(m.StringUtil.StringContainsSeparatedWord(r,b)||m.StringUtil.StringContainsSeparatedWord(r,"da\\s?capo",!0)){const S=new d.RepetitionInstruction(u,d.RepetitionInstructionEnum.DaCapo);return this.addInstruction(this.repetitionInstructions,S),!0}if(m.StringUtil.StringContainsSeparatedWord(r,f,!0)||m.StringUtil.StringContainsSeparatedWord(r,"dal\\s?segno",!0)){let S;return S=m.StringUtil.StringContainsSeparatedWord(r,"al\\s?coda",!0)?new d.RepetitionInstruction(u,d.RepetitionInstructionEnum.DalSegnoAlCoda):new d.RepetitionInstruction(u,d.RepetitionInstructionEnum.DalSegno),this.addInstruction(this.repetitionInstructions,S),!0}if(m.StringUtil.StringContainsSeparatedWord(r,"to\\s?coda",!0)||m.StringUtil.StringContainsSeparatedWord(r,"a (la )?coda",!0)){const S=new d.RepetitionInstruction(u,d.RepetitionInstructionEnum.ToCoda);return this.addInstruction(this.repetitionInstructions,S),!0}if(m.StringUtil.StringContainsSeparatedWord(r,"fine",!0)){const S=new d.RepetitionInstruction(u,d.RepetitionInstructionEnum.Fine);return this.addInstruction(this.repetitionInstructions,S),!0}if(m.StringUtil.StringContainsSeparatedWord(r,"coda",!0)){const S=new d.RepetitionInstruction(u,d.RepetitionInstructionEnum.Coda);return this.addInstruction(this.repetitionInstructions,S),!0}if(m.StringUtil.StringContainsSeparatedWord(r,"segno",!0)){const S=new d.RepetitionInstruction(u,d.RepetitionInstructionEnum.Segno);return this.addInstruction(this.repetitionInstructions,S),!0}}else{if(o.element("segno")){const f=new d.RepetitionInstruction(u,d.RepetitionInstructionEnum.Segno);return this.addInstruction(this.repetitionInstructions,f),!0}if(o.element("coda")){const f=new d.RepetitionInstruction(u,d.RepetitionInstructionEnum.Coda);return this.addInstruction(this.repetitionInstructions,f),!0}}return!1}removeRedundantInstructions(){let o=0,s=0,h=0,u=0;for(let f=0;f0&&this.findInstructionInPreviousMeasure(f,r.measureIndex,d.RepetitionInstructionEnum.ToCoda)&&(r.type=d.RepetitionInstructionEnum.None);break;case d.RepetitionInstructionEnum.Segno:if(o-u>0){let b=!1;for(let S=0,v=this.repetitionInstructions.length;S0?d.RepetitionInstructionEnum.DalSegnoAlCoda:d.RepetitionInstructionEnum.DalSegno,r.type=d.RepetitionInstructionEnum.None,b=!0;break;case d.RepetitionInstructionEnum.DalSegno:case d.RepetitionInstructionEnum.DalSegnoAlFine:case d.RepetitionInstructionEnum.DalSegnoAlCoda:r.type=d.RepetitionInstructionEnum.None,b=!0}if(b)break}if(b)break;r.type=h-s>0?d.RepetitionInstructionEnum.DalSegnoAlCoda:d.RepetitionInstructionEnum.DalSegno,r.alignment=d.AlignmentType.End,r.measureIndex--}}if(this.backwardSearchForPreviousIdenticalInstruction(f,r)||r.type===d.RepetitionInstructionEnum.None)this.repetitionInstructions.splice(f,1),f--;else switch(r.type){case d.RepetitionInstructionEnum.Fine:break;case d.RepetitionInstructionEnum.ToCoda:h++;break;case d.RepetitionInstructionEnum.Coda:s++;break;case d.RepetitionInstructionEnum.Segno:o++;break;case d.RepetitionInstructionEnum.DalSegnoAlFine:case d.RepetitionInstructionEnum.DalSegnoAlCoda:u++}}this.repetitionInstructions.sort(l.RepetitionInstructionComparer.Compare)}findInstructionInPreviousMeasure(o,s,h){for(let u=o-1;u>=0;u--){const f=this.repetitionInstructions[u];if(s-f.measureIndex===1&&f.type===h)return!0}return!1}backwardSearchForPreviousIdenticalInstruction(o,s){for(let h=o-1;h>=0;h--)if(this.repetitionInstructions[h].equals(s))return!0;return!1}addInstruction(o,s){let h=!0;for(let u=0,f=o.length;u0){const b=r.attribute("type").value;let S=1;try{r.attribute("number")&&(S=parseInt(r.attribute("number").value,10))}catch(g){m.default.debug("VoiceGenerator.addSlur number: ",g)}let v=s.PlacementEnum.NotYetDefined;const w=r.attribute("placement");w&&w.value&&(w.value==="above"?v=s.PlacementEnum.Above:w.value==="below"&&(v=s.PlacementEnum.Below));const T=r.attribute("orientation");if(T&&T.value&&(T.value==="over"?v=s.PlacementEnum.Above:T.value==="under"&&(v=s.PlacementEnum.Below)),b==="start"){let g=this.openSlurDict[S];g||(g=new l.Slur,this.openSlurDict[S]=g),g.StartNote=f,g.PlacementXml=v}else if(b==="stop"){const g=this.openSlurDict[S];if(g){const x=r.name;if(x==="slide"||x==="glissando"){const P=g.StartNote,_=new h.Glissando(P);_.AddNote(f),_.EndNote=f,f.NoteGlissando=_,delete this.openSlurDict[S]}else g.EndNote=f,f.isDuplicateSlur(g)||(f.NoteSlurs.push(g),g.StartNote.NoteSlurs.push(g)),delete this.openSlurDict[S]}}}}}catch{const b=o.ITextTranslation.translateText("ReaderErrorMessages/SlurError","Error while reading slur.");this.musicSheet.SheetErrors.pushMeasureError(b)}}}},1538(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.TempoSorter=y.TemposCalculator=void 0;const d=p(2561),l=p(899),m=p(6362),o=p(9161),s=p(5332);class h{calculate(r){h.processTempoExpressions(r)}static processTempoExpressions(r){var g;const b=[];for(let x=0,P=r.SourceMeasures;x=0&&_.SourceMeasureParent.TempoExpressions.splice(B,1)}else v.push(_),w=_}T=S;for(let x=0;xB&&C.beginsWithRepetition()){k--;break}k++}const F=r.SourceMeasures[k];let A,G=d.Fraction.plus(F.AbsoluteTimestamp,d.Fraction.minus(F.Duration,new d.Fraction(1,64)));x0&&(S.TempoInBpm=r.DefaultStartTempoInBpm),S.TempoInBpm===0&&(S.TempoInBpm=o.InstantaneousTempoExpression.getDefaultValueForInstTempo[o.InstTempo.moderato])),S.TempoInBpm}}y.TemposCalculator=h;class u{static Compare(r,b){let S=0;if(S=u.CompareNumber(r.AbsoluteTimestamp.RealValue,b.AbsoluteTimestamp.RealValue),S!==0)return S;const v=u.calcSortPriority(r),w=u.calcSortPriority(b);return S=u.CompareNumber(v,w),S}static calcSortPriority(r){if(r.InstantaneousTempo!=null){switch(r.InstantaneousTempo.TempoType){case o.TempoType.metronomeMark:return 1;case o.TempoType.inst:return 2;case o.TempoType.change:switch(r.InstantaneousTempo.ChangeSubType){case o.ChangeSubType.atempo:case o.ChangeSubType.doppioMovimento:return 3;case o.ChangeSubType.tempoprimo:return 4}}return 5}return 9}static CompareNumber(r,b){return r0||Et.length>0)&&!this.currentNote.ParentVoiceEntry.IsGrace&&(this.slurReader.addSlur(yt,this.currentNote),Et.length>0&&this.slurReader.addSlur(Et,this.currentNote),Dt.length>0&&this.slurReader.addSlur(Dt,this.currentNote));const Vt=mt.elements("tuplet");Vt.length>0&&(this.openTupletNumber=this.addTuplet(z,Vt),dt=!0);const Nt=mt.element("arpeggiate");if(Nt!==void 0){let zt;if(this.currentVoiceEntry.Arpeggio)zt=this.currentVoiceEntry.Arpeggio;else{let Xt=!1;for(const Ut of this.currentStaffEntry.VoiceEntries)if(Ut.Arpeggio){Xt=!0,zt=Ut.Arpeggio;break}if(!Xt){let Ut=A.ArpeggioType.ARPEGGIO_DIRECTIONLESS;const Kt=Nt.attribute("direction");if(Kt)switch(Kt.value){case"up":Ut=A.ArpeggioType.ROLL_UP;break;case"down":Ut=A.ArpeggioType.ROLL_DOWN;break;default:Ut=A.ArpeggioType.ARPEGGIO_DIRECTIONLESS}zt=new A.Arpeggio(this.currentVoiceEntry,Ut),this.currentVoiceEntry.Arpeggio=zt}}zt.addNote(this.currentNote)}const It=mt.elements("tied");It.length>0&&this.addTie(It,ct,st,r.TieTypes.SIMPLE);const Ct=mt.element("technical");if(Ct){const zt=Ct.elements("hammer-on");zt.length>0&&this.addTie(zt,ct,st,r.TieTypes.HAMMERON);const Xt=Ct.elements("pull-off");Xt.length>0&&this.addTie(Xt,ct,st,r.TieTypes.PULLOFF)}}z.element("time-modification")===void 0||dt||this.handleTimeModificationNode(z)}catch(it){_.default.warn(it);const dt=v.ITextTranslation.translateText("ReaderErrorMessages/NoteError","Ignored erroneous Note.");this.musicSheet.SheetErrors.pushMeasureError(dt),this.musicSheet.SheetErrors.pushMeasureError(it)}return this.currentNote}checkForStaffEntryLink(z,W,$,N){const Y=new P.StaffEntryLink(this.currentVoiceEntry);Y.LinkStaffEntries.push($),$.Link=Y;const tt=this.currentVoiceEntry.Timestamp.clone(),H=N.getVerticalContainerByTimestamp(tt);return($=H.StaffEntries[z])||($=new h.SourceStaffEntry(H,W),H.StaffEntries[z]=$),$.VoiceEntries.push(this.currentVoiceEntry),Y.LinkStaffEntries.push($),$.Link=Y,$}checkForOpenBeam(){this.openBeams.length>0&&this.currentNote&&this.handleOpenBeam()}checkOpenTies(){const z=this.openTieDict;for(const W in z)if(z.hasOwnProperty(W)){const $=z[W];S.Fraction.plus($.StartNote.ParentStaffEntry.Timestamp,$.Duration).lt($.StartNote.SourceMeasure.Duration)&&delete z[W]}}hasVoiceEntry(){return this.currentVoiceEntry!==void 0}readArticulations(z,W,$){const N=z.element("articulations");N&&this.articulationReader.addArticulationExpression(N,W);const Y=z.element("fermata");Y&&this.articulationReader.addFermata(Y,W);const tt=z.element("technical");tt&&this.articulationReader.addTechnicalArticulations(tt,W,$);const H=z.element("ornaments");H&&this.articulationReader.addOrnament(H,W)}addSingleNote(z,W,$,N,Y,tt,H,rt,ct,st,ot,ht,lt,O){let D,j,Q,J,q=0,et=g.AccidentalEnum.NONE,it=x.NoteEnum.C,dt=x.NoteEnum.C,mt=0,yt=0;const Et=z.elements();for(let Ut=0,Kt=Et.length;Ut0&&this.openBeams.last().ExtendedNoteList.push(D),D}addNoteInfo(z,W,$,N,Y,tt,H,rt,ct){z.NoteTypeXml=W,z.PrintObject=$,z.IsCueNote=N,z.NormalNotes=Y,z.displayStepUnpitched=tt,z.displayOctaveUnpitched=H,z.NoteheadColorXml=rt,z.NoteheadColor=rt}createBeam(z,W){var $;try{const N=z.element("beam");let Y;if(N!==void 0&&N.hasAttributes&&(Y=N.attribute("number")),Y){let tt=parseInt(Y.value,10);const H=z.elements("beam"),rt=H[0].value;H&&(rt==="begin"?(tt===(($=this.openBeams.last())==null?void 0:$.BeamNumber)?(this.beamNumberOffset++,tt+=this.beamNumberOffset):this.openBeams.last()&&this.handleOpenBeam(),this.openBeams.push(new u.Beam(tt,this.beamNumberOffset))):tt+=this.beamNumberOffset);let ct=!1;if(!(tt>0&&tt<=this.openBeams.length&&this.openBeams[tt-1]))return void _.default.debug("[OSMD] invalid beamnumber");for(let st=0,ot=this.openBeams[tt-1].Notes.length;st1){for(let ot=1;ot0&&st.SecondaryBreakIndices.push(ht);break}}rt==="end"&&this.endBeam()}}}catch(N){const Y=v.ITextTranslation.translateText("ReaderErrorMessages/BeamError","Error while reading beam.");throw this.musicSheet.SheetErrors.pushMeasureError(Y),new T.MusicSheetReadingException("",N)}}endBeam(){this.openBeams.pop(),this.beamNumberOffset=Math.max(0,this.beamNumberOffset-1)}handleOpenBeam(){const z=this.openBeams.last();if(z.Notes.length!==0){if(z.Notes.length===1)return z.Notes[0].NoteBeam=void 0,void this.endBeam();if(this.currentNote===k.CollectionUtil.last(z.Notes))this.endBeam();else{const W=k.CollectionUtil.last(z.Notes).ParentStaffEntry,$=this.currentMeasure.getVerticalContainerIndexByTimestamp(W.Timestamp),N=W.VerticalContainerParent.StaffEntries.indexOf(W);if($1){let Y=z.element("time-modification");Y&&(Y=Y.element("actual-notes"));const tt=W;for(let H=0,rt=tt.length;H1&&this.openTupletNumber--),this.tupletDict[D]=Q;const q=[];q.push(this.currentNote),Q.Notes.push(q),Q.Fractions.push(this.getTupletNoteDurationFromType(z)),this.currentNote.NoteTuplet=Q,this.openTupletNumber=D}else if(O.value==="stop"){let D=1;ct.attribute("number")&&(D=parseInt(ct.attribute("number").value,10));const j=this.tupletDict[D];if(j){const Q=ct.attribute("placement");Q&&(Q.value==="below"?j.tupletLabelNumberPlacement=C.PlacementEnum.Below:j.tupletLabelNumberPlacement=C.PlacementEnum.Above,j.PlacementFromXml=!0);const J=[];if(J.push(this.currentNote),j.Notes.push(J),!j.PlacementFromXml){let q=!1;for(const et of j.Notes){for(const it of et)if(!it.isRest()){it.StemDirectionXml===o.StemDirectionType.Down?j.tupletLabelNumberPlacement=C.PlacementEnum.Below:j.tupletLabelNumberPlacement=C.PlacementEnum.Above,q=!0;break}if(q)break}}j.Fractions.push(this.getTupletNoteDurationFromType(z)),this.currentNote.NoteTuplet=j,delete this.tupletDict[D],Object.keys(this.tupletDict).length===0?this.openTupletNumber=0:Object.keys(this.tupletDict).length>1&&this.openTupletNumber--}}}}}else if(W[0]){const Y=W[0];if(Y.hasAttributes){const tt=Y.attribute("type").value;let H=1;Y.attribute("number")&&(H=parseInt(Y.attribute("number").value,10));const rt=isNaN(H),ct=this.readShowNumberNoneGiven(Y),st=Y.attribute("bracket");st&&st.value==="yes"?(N=!0,$=!0):st&&st.value==="no"&&($=!1);let ot=this.musicSheet.Rules.TupletsRatioed;const ht=Y.attribute("show-number");if(ht&&ht.value==="both"&&this.musicSheet.Rules.TupletsRatioedUseXMLValue&&(ot=!0),tt==="start"){let lt=0,O=z.element("time-modification");if(O&&(O=O.element("actual-notes")),O&&(lt=parseInt(O.value,10),isNaN(lt))){const J=v.ITextTranslation.translateText("ReaderErrorMessages/TupletNoteDurationError","Invalid tuplet note duration.");throw this.musicSheet.SheetErrors.pushMeasureError(J),new T.MusicSheetReadingException(J)}rt&&(this.openTupletNumber++,H=this.openTupletNumber);let D=this.tupletDict[H];D||(D=this.tupletDict[H]=new b.Tuplet(lt,N),D.Ratioed=ot,D.BracketedXmlValue=$,D.ShowNumberNoneGivenInXml=ct,D.tupletLabelNumberPlacement=C.PlacementEnum.Above);const j=Y.attribute("placement");j&&(j.value==="below"?D.tupletLabelNumberPlacement=C.PlacementEnum.Below:D.tupletLabelNumberPlacement=C.PlacementEnum.Above,D.PlacementFromXml=!0);const Q=[];Q.push(this.currentNote),D.Notes.push(Q),D.Fractions.push(this.getTupletNoteDurationFromType(z)),this.currentNote.NoteTuplet=D,this.openTupletNumber=H}else if(tt==="stop"){rt&&(H=this.openTupletNumber);const lt=this.tupletDict[this.openTupletNumber];if(lt){const O=Y.attribute("placement");O&&(O.value==="below"?lt.tupletLabelNumberPlacement=C.PlacementEnum.Below:lt.tupletLabelNumberPlacement=C.PlacementEnum.Above,lt.PlacementFromXml=!0);const D=[];if(D.push(this.currentNote),lt.Notes.push(D),!lt.PlacementFromXml){let j=!1;for(const Q of lt.Notes){for(const J of Q)if(!J.isRest()){J.StemDirectionXml===o.StemDirectionType.Down?lt.tupletLabelNumberPlacement=C.PlacementEnum.Below:lt.tupletLabelNumberPlacement=C.PlacementEnum.Above,j=!0;break}if(j)break}}lt.Fractions.push(this.getTupletNoteDurationFromType(z)),this.currentNote.NoteTuplet=lt,Object.keys(this.tupletDict).length===0?this.openTupletNumber=0:Object.keys(this.tupletDict).length>1&&this.openTupletNumber--,delete this.tupletDict[H]}}}}return this.openTupletNumber}readShowNumberNoneGiven(z){const W=z.attribute("show-number");return!(!(W!=null&&W.value)||W.value!=="none")}handleTimeModificationNode(z){if(this.tupletDict[this.openTupletNumber])try{const W=this.tupletDict[this.openTupletNumber],$=k.CollectionUtil.last(W.Notes);let N;$[0].ParentVoiceEntry.Timestamp.Equals(this.currentVoiceEntry.Timestamp)?N=$:(N=[],W.Notes.push(N),W.Fractions.push(this.getTupletNoteDurationFromType(z))),N.push(this.currentNote),this.currentNote.NoteTuplet=W}catch(W){const $=v.ITextTranslation.translateText("ReaderErrorMessages/TupletNumberError","Invalid tuplet number.");throw this.musicSheet.SheetErrors.pushMeasureError($),W}else if(this.currentVoiceEntry.Notes.length>0){const W=this.currentVoiceEntry.Notes[0];if(W.NoteTuplet){const $=W.NoteTuplet;k.CollectionUtil.last($.Notes).push(this.currentNote),this.currentNote.NoteTuplet=$}}}addTie(z,W,$,N){if(z){if(z.length===1){const Y=z[0];if(Y!==void 0&&Y.attributes()){const tt=this.getTieDirection(Y),H=Y.attribute("type").value;try{if(H==="start"){const rt=this.findCurrentNoteInTieDict(this.currentNote);rt<0&&delete this.openTieDict[rt];const ct=this.getNextAvailableNumberForTie(),st=new f.Tie(this.currentNote,N);this.openTieDict[ct]=st,st.TieNumber=ct,st.TieDirection=tt}else if(H==="stop"){const rt=this.findCurrentNoteInTieDict(this.currentNote),ct=this.openTieDict[rt];ct&&(ct.AddNote(this.currentNote),delete this.openTieDict[rt])}}catch{const ct=v.ITextTranslation.translateText("ReaderErrorMessages/TieError","Error while reading tie.");this.musicSheet.SheetErrors.pushMeasureError(ct)}}}else if(z.length===2){const Y=this.findCurrentNoteInTieDict(this.currentNote);if(Y>=0){const tt=this.openTieDict[Y];tt.AddNote(this.currentNote);for(const H of z)if(H.attribute("type").value==="start"){const rt=this.getTieDirection(H);tt.NoteIndexToTieDirection[tt.Notes.length-1]=rt}}}}}getTieDirection(z){let W=C.PlacementEnum.NotYetDefined;const $=z.attribute("placement");$&&($.value==="above"?W=C.PlacementEnum.Above:$.value==="below"&&(W=C.PlacementEnum.Below));const N=z.attribute("orientation");return N&&(N.value==="over"?W=C.PlacementEnum.Above:N.value==="under"&&(W=C.PlacementEnum.Below)),W}getNextAvailableNumberForTie(){const z=Object.keys(this.openTieDict);if(z.length===0)return 1;z.sort((W,$)=>+W-+$);for(let W=0;W0&&(v+="("+w.adds.join(",")+")"),w.alts.length>0&&(v+="(alt "+w.alts.join(",")+")"),w.subs.length>0&&(v+="(omit "+w.subs.join(",")+")"),f.BassPitch){let P=f.BassPitch;l.MusicSheetCalculator.transposeCalculator&&(P=l.MusicSheetCalculator.transposeCalculator.transposePitch(f.BassPitch,b,r)),v+="/",v+=d.Pitch.getNoteEnumString(P.FundamentalNote),v+=f.getTextForAccidental(P.Accidental)}return v}getTextForAccidental(f){const r=this.rules.ChordAccidentalTexts.getValue(f);return r!==void 0?r:""}getTextFromChordKindEnum(f){return this.rules.ChordSymbolLabelTexts.getValue(f)??""}},y.Degree=class{constructor(f,r,b){this.value=f,this.alteration=r,this.text=b}};class s{constructor(r,b,S){this.alternateName=r,this.chordKind=b,this.degrees=S}static createCustomChord(r,b,S){return new s(r,b,S)}static renameCustomChord(r,b,S){for(const v of S)v.alternateName===r&&(v.alternateName=b)}}var h,u;y.CustomChord=s,(function(f){f[f.add=0]="add",f[f.alter=1]="alter",f[f.subtract=2]="subtract"})(h||(y.ChordDegreeText=h={})),(function(f){f[f.major=0]="major",f[f.minor=1]="minor",f[f.augmented=2]="augmented",f[f.diminished=3]="diminished",f[f.dominant=4]="dominant",f[f.majorseventh=5]="majorseventh",f[f.minorseventh=6]="minorseventh",f[f.diminishedseventh=7]="diminishedseventh",f[f.augmentedseventh=8]="augmentedseventh",f[f.halfdiminished=9]="halfdiminished",f[f.majorminor=10]="majorminor",f[f.majorsixth=11]="majorsixth",f[f.minorsixth=12]="minorsixth",f[f.dominantninth=13]="dominantninth",f[f.majorninth=14]="majorninth",f[f.minorninth=15]="minorninth",f[f.dominant11th=16]="dominant11th",f[f.major11th=17]="major11th",f[f.minor11th=18]="minor11th",f[f.dominant13th=19]="dominant13th",f[f.major13th=20]="major13th",f[f.minor13th=21]="minor13th",f[f.suspendedsecond=22]="suspendedsecond",f[f.suspendedfourth=23]="suspendedfourth",f[f.Neapolitan=24]="Neapolitan",f[f.Italian=25]="Italian",f[f.French=26]="French",f[f.German=27]="German",f[f.pedal=28]="pedal",f[f.power=29]="power",f[f.Tristan=30]="Tristan",f[f.none=31]="none"})(u||(y.ChordSymbolEnum=u={}))},6362(St,y){var p;Object.defineProperty(y,"__esModule",{value:!0}),y.PlacementEnum=y.AbstractExpression=void 0,y.AbstractExpression=class{constructor(d){this.placement=d}static isStringInStringList(d,l){for(let m=0,o=d.length;m=o.allargando&&h<=o.ritenuto}get TempoType(){return this.tempoType}set TempoType(h){this.tempoType=h}get StartTempo(){return this.startTempo}set StartTempo(h){this.startTempo=h}get EndTempo(){return this.endTempo}set EndTempo(h){this.endTempo=h}get AbsoluteStartTimestamp(){return d.Fraction.plus(this.parentMultiTempoExpression.SourceMeasureParent.AbsoluteTimestamp,this.parentMultiTempoExpression.Timestamp)}get AbsoluteEndTimestamp(){return this.absoluteEndTimestamp}set AbsoluteEndTimestamp(h){this.absoluteEndTimestamp=h,this.AbsoluteTimeSpan=d.Fraction.minus(this.AbsoluteEndTimestamp,this.AbsoluteStartTimestamp).RealValue}get AbsoluteTimestamp(){return this.ParentMultiTempoExpression.AbsoluteTimestamp}getAbsoluteFloatTimestamp(){return this.ParentMultiTempoExpression.AbsoluteTimestamp.RealValue}getInterpolatedTempo(h){const u=d.Fraction.plus(this.parentMultiTempoExpression.SourceMeasureParent.AbsoluteTimestamp,this.parentMultiTempoExpression.Timestamp);if(h.lt(u))return-1;if(this.absoluteEndTimestamp.lt(h))return-2;const f=d.Fraction.minus(h,u).RealValue/d.Fraction.minus(this.absoluteEndTimestamp,u).RealValue;return Math.max(0,Math.min(250,this.startTempo+(this.endTempo-this.startTempo)*f))}setTempoType(){m.isStringInStringList(m.listContinuousTempoFaster,this.label)?this.tempoType=o.accelerando:m.isStringInStringList(m.listContinuousTempoSlower,this.label)&&(this.tempoType=o.ritardando)}getTempoFactor(h=this.Label){return 1}}var o;y.ContinuousTempoExpression=m,m.listContinuousTempoFaster=["accelerando","accel","piu mosso","poco piu","stretto"],m.listContinuousTempoSlower=["poco meno","meno mosso","piu lento","calando","allargando","rallentando","ritardando","ritenuto","ritard.","ritard","rit.","rit","riten.","riten"],(function(s){s[s.accelerando=0]="accelerando",s[s.stretto=1]="stretto",s[s.stringendo=2]="stringendo",s[s.mosso=3]="mosso",s[s.piuMosso=4]="piuMosso",s[s.allargando=5]="allargando",s[s.calando=6]="calando",s[s.menoMosso=7]="menoMosso",s[s.rallentando=8]="rallentando",s[s.ritardando=9]="ritardando",s[s.ritard=10]="ritard",s[s.rit=11]="rit",s[s.ritenuto=12]="ritenuto",s[s.rubato=13]="rubato",s[s.precipitando=14]="precipitando"})(o||(y.ContinuousTempoType=o={}))},437(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.OctaveEnum=y.OctaveShift=void 0;const d=p(8233);var l;y.OctaveShift=class{constructor(m,o){this.numberXml=1,this.endVoiceEntryIndex=0,this.setOctaveShiftValue(m,o)}get Type(){return this.octaveValue}set Type(m){this.octaveValue=m}get StaffNumber(){return this.staffNumber}set StaffNumber(m){this.staffNumber=m}get ParentStartMultiExpression(){return this.startMultiExpression}set ParentStartMultiExpression(m){this.startMultiExpression=m}get ParentEndMultiExpression(){return this.endMultiExpression}set ParentEndMultiExpression(m){this.endMultiExpression=m}setOctaveShiftValue(m,o){this.octaveValue=o===1&&m==="down"?l.VA8:o===1&&m==="up"?l.VB8:o===2&&m==="down"?l.MA15:o===2&&m==="up"?l.MB15:l.NONE}static getPitchFromOctaveShift(m,o){if(!m)return;if(m.OctaveShiftApplied)return m;let s=m.Octave;switch(o){case l.VA8:s-=1;break;case l.VB8:s+=1;break;case l.MA15:s-=2;break;case l.MB15:s+=2;break;case l.NONE:default:s+=0}const h=new d.Pitch(m.FundamentalNote,s,m.Accidental);return h.OctaveShiftApplied=!0,h}},(function(m){m[m.VA8=0]="VA8",m[m.VB8=1]="VB8",m[m.MA15=2]="MA15",m[m.MB15=3]="MB15",m[m.NONE=4]="NONE"})(l||(y.OctaveEnum=l={}))},3253(St,y){Object.defineProperty(y,"__esModule",{value:!0}),y.Pedal=void 0,y.Pedal=class{constructor(p=!1,d=!0){this.ChangeEnd=!1,this.ChangeBegin=!1,this.EndsStave=!1,this.BeginsStave=!1,this.line=p,this.sign=d}get IsLine(){return this.line}get IsSign(){return this.sign}}},6229(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.Slur=void 0;const d=p(2561);y.Slur=class{constructor(){}get StartNote(){return this.startNote}set StartNote(l){this.startNote=l}get EndNote(){return this.endNote}set EndNote(l){this.endNote=l}startNoteHasMoreStartingSlurs(){if(!this.startNote)return!1;for(let l=0,m=this.startNote.NoteSlurs.length;l0&&(this.expressions[0].expression instanceof l.InstantaneousDynamicExpression||this.expressions[0].expression instanceof m.ContinuousDynamicExpression||this.expressions[0].expression instanceof o.MoodExpression||this.expressions[0].expression instanceof s.UnknownExpression)&&(r=this.expressions[0].expression.Placement),r}getFontstyleOfFirstEntry(){let r=u.FontStyles.Regular;return this.expressions.length>0&&(this.expressions[0].expression instanceof m.ContinuousDynamicExpression||this.expressions[0].expression instanceof o.MoodExpression?r=u.FontStyles.Italic:this.expressions[0].expression instanceof s.UnknownExpression&&(r=this.expressions[0].expression.fontStyle??u.FontStyles.Regular)),r}getColorXMLOfFirstEntry(){let r;return this.expressions.length>=1&&(r=this.expressions[0].expression.ColorXML),r}addExpression(r,b){r instanceof l.InstantaneousDynamicExpression?(this.instantaneousDynamic&&this.removeExpressionFromEntryList(this.InstantaneousDynamic),this.instantaneousDynamic=r,this.instantaneousDynamic.ParentMultiExpression=this):r instanceof m.ContinuousDynamicExpression?this.startingContinuousDynamic=r:r instanceof o.MoodExpression?this.moodList.push(r):r instanceof s.UnknownExpression&&this.unknownList.push(r),this.addExpressionToEntryList(r,b)}CompareTo(r){return this.Timestamp.RealValue>r.Timestamp.RealValue?1:this.Timestamp.RealValue0&&(this.expressions[0].Expression instanceof l.InstantaneousTempoExpression||this.expressions[0].Expression instanceof s.ContinuousTempoExpression)&&(u=this.expressions[0].Expression.Placement),u}getFontstyleOfFirstEntry(){let u=o.FontStyles.Regular;return this.expressions[0].Expression instanceof l.InstantaneousTempoExpression?u=o.FontStyles.Bold:this.expressions[0].Expression instanceof s.ContinuousTempoExpression&&(u=o.FontStyles.Italic),u}addExpression(u,f){if(this.checkIfAlreadyExists(u))return;u instanceof l.InstantaneousTempoExpression?this.instantaneousTempo=u:u instanceof s.ContinuousTempoExpression&&(this.continuousTempo=u);const r=new h;r.prefix=f,r.Expression=u,r.label=u.Label,this.expressions.push(r)}CompareTo(u){return this.Timestamp.RealValue>u.Timestamp.RealValue?1:this.Timestamp.RealValue0)for(let f=0;f=0}getAlterationForPitch(u){return this.keyType>0&&this.alteratedNotes.indexOf(u.FundamentalNote)<=this.keyType?m.AccidentalEnum.SHARP:this.keyType<0&&this.alteratedNotes.indexOf(u.FundamentalNote)<=Math.abs(this.keyType)?m.AccidentalEnum.FLAT:m.AccidentalEnum.NONE}ToString(){return"Key: "+this.keyType+this.mode}OperatorEquals(u){const f=this;return f===u||!(!f||!u)&&f.Key===u.Key&&f.Mode===u.Mode}OperatorNotEqual(u){return!this.OperatorEquals(u)}}var s;y.KeyInstruction=o,o.sharpPositionList=[l.NoteEnum.F,l.NoteEnum.C,l.NoteEnum.G,l.NoteEnum.D,l.NoteEnum.A,l.NoteEnum.E,l.NoteEnum.B],o.flatPositionList=[l.NoteEnum.B,l.NoteEnum.E,l.NoteEnum.A,l.NoteEnum.D,l.NoteEnum.G,l.NoteEnum.C,l.NoteEnum.F],y.NoteEnumToHalfToneLink=class{constructor(h,u){this.note=h,this.halfTone=u}},(function(h){h[h.major=0]="major",h[h.minor=1]="minor",h[h.none=2]="none",h[h.dorian=3]="dorian",h[h.phrygian=4]="phrygian",h[h.lydian=5]="lydian",h[h.mixolydian=6]="mixolydian",h[h.aeolian=7]="aeolian",h[h.ionian=8]="ionian",h[h.locrian=9]="locrian"})(s||(y.KeyEnum=s={}))},1645(St,y){var p,d;Object.defineProperty(y,"__esModule",{value:!0}),y.AlignmentType=y.RepetitionInstructionEnum=y.RepetitionInstruction=y.RepetitionInstructionComparer=void 0,y.RepetitionInstructionComparer=class{static Compare(l,m){if(l.parentRepetition!==void 0&&m.parentRepetition){if(l.alignment===d.End&&m.alignment===d.End){if(l.parentRepetition.StartIndexm.parentRepetition.StartIndex)return-1}if(l.alignment===d.Begin&&m.alignment===d.Begin){if(l.parentRepetition.EndIndexm.parentRepetition.EndIndex)return-1}}return 0}},y.RepetitionInstruction=class{constructor(l,m,o=d.End,s=void 0,h=void 0){this.endingIndices=void 0,this.measureIndex=l,h&&(this.endingIndices=h.slice()),this.type=m,this.alignment=o,this.parentRepetition=s}CompareTo(l){const m=l;if(this.measureIndex>m.measureIndex)return 1;if(this.measureIndex=0&&(this.syllableIndex=h)}get Text(){return this.text}set Text(l){this.text=l}get Word(){return this.word}get Parent(){return this.parent}set Parent(l){this.parent=l}get VerseNumber(){return this.verseNumber}get SyllableIndex(){return this.syllableIndex}get IsTranslation(){return this.VerseNumber.endsWith("translation")}get IsChorus(){return this.VerseNumber.startsWith("chorus")}get FontStyle(){return this.IsChorus||this.IsTranslation?d.FontStyles.Italic:d.FontStyles.Regular}}},649(St,y){Object.defineProperty(y,"__esModule",{value:!0}),y.LyricWord=void 0,y.LyricWord=class{constructor(){this.syllables=[]}get Syllables(){return this.syllables}containsVoiceEntry(p){for(let d=0,l=this.Syllables.length;d2:(l.default.warn("notehead: sourceNote and filledXmlAttribute undefined."),f=!0)),this.filled=f}get SourceNote(){return this.sourceNote}get Shape(){return this.shape}get Filled(){return this.filled}static ShapeTypeXmlToShape(h){switch(h.toLowerCase()){case"normal":return o.NORMAL;case"none":return o.NONE;case"x":return o.X;case"slash":return o.SLASH;case"diamond":return o.DIAMOND;case"square":case"la":return o.SQUARE;case"do":case"triangle":return o.TRIANGLE;case"inverted triangle":return o.TRIANGLE_INVERTED;case"rectangle":return o.RECTANGLE;case"circle-x":return o.CIRCLEX;default:return l.default.info("unsupported/unhandled xml notehead '"+h+"'. Using normal notehead."),o.NORMAL}}}var o;y.Notehead=m,(function(s){s[s.CIRCLEX=0]="CIRCLEX",s[s.DIAMOND=1]="DIAMOND",s[s.NORMAL=2]="NORMAL",s[s.NONE=3]="NONE",s[s.RECTANGLE=4]="RECTANGLE",s[s.SLASH=5]="SLASH",s[s.SQUARE=6]="SQUARE",s[s.TRIANGLE=7]="TRIANGLE",s[s.TRIANGLE_INVERTED=8]="TRIANGLE_INVERTED",s[s.X=9]="X"})(o||(y.NoteHeadShape=o={}))},8215(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.OrnamentEnum=y.OrnamentContainer=void 0;const d=p(8233),l=p(6362);var m;y.OrnamentContainer=class{constructor(o){this.placement=l.PlacementEnum.Above,this.accidentalAbove=d.AccidentalEnum.NONE,this.accidentalBelow=d.AccidentalEnum.NONE,this.ornament=o}get GetOrnament(){return this.ornament}get AccidentalAbove(){return this.accidentalAbove}set AccidentalAbove(o){this.accidentalAbove=o}get AccidentalBelow(){return this.accidentalBelow}set AccidentalBelow(o){this.accidentalBelow=o}},(function(o){o[o.Trill=0]="Trill",o[o.Turn=1]="Turn",o[o.InvertedTurn=2]="InvertedTurn",o[o.DelayedTurn=3]="DelayedTurn",o[o.DelayedInvertedTurn=4]="DelayedInvertedTurn",o[o.Mordent=5]="Mordent",o[o.InvertedMordent=6]="InvertedMordent"})(m||(y.OrnamentEnum=m={}))},4387(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.SourceMeasure=void 0;const d=p(2561),l=p(3236),m=p(2369),o=p(1645),s=p(1336),h=p(164),u=p(4543),f=p(6954);y.SourceMeasure=class{constructor(r,b){this.printNewSystemXml=!1,this.printNewPageXml=!1,this.IsSystemStartMeasure=!1,this.WidthFactor=1,this.hasLyrics=!1,this.hasMoodExpressions=!1,this.allRests=!1,this.isReducedToMultiRest=!1,this.multipleRestMeasureNumber=0,this.staffLinkedExpressions=[],this.tempoExpressions=[],this.verticalSourceStaffEntryContainers=[],this.graphicalMeasureErrors=[],this.firstRepetitionInstructions=[],this.lastRepetitionInstructions=[],this.completeNumberOfStaves=r,this.implicitMeasure=!1,this.hasEndLine=!1,this.endingBarStyleXml="",this.endingBarStyleEnum=f.SystemLinesEnum.SingleThin,this.firstInstructionsStaffEntries=new Array(r),this.lastInstructionsStaffEntries=new Array(r),this.rules=b,this.TempoInBPM=0;for(let S=0;S1)return r[this.measureListIndex-1]}get Rules(){return this.rules}get VerticalMeasureList(){return this.verticalMeasureList}set VerticalMeasureList(r){this.verticalMeasureList=r}get TempoInBPM(){return this.tempoInBPM}set TempoInBPM(r){this.tempoInBPM=r}findOrCreateStaffEntry(r,b,S){let v,w;for(const g of this.verticalSourceStaffEntryContainers)if(g.Timestamp.Equals(r)){w=g;break}if(w)return w.StaffEntries[b]?v=w.StaffEntries[b]:(v=new m.SourceStaffEntry(w,S),w.StaffEntries[b]=v),{createdNewContainer:!1,staffEntry:v};const T=this.verticalSourceStaffEntryContainers[this.verticalSourceStaffEntryContainers.length-1];if(this.verticalSourceStaffEntryContainers.length===0||T.Timestamp.lt(r)){const g=new l.VerticalSourceStaffEntryContainer(this,r.clone(),this.completeNumberOfStaves);this.verticalSourceStaffEntryContainers.push(g),v=new m.SourceStaffEntry(g,S),g.StaffEntries[b]=v}else for(let g=this.verticalSourceStaffEntryContainers.length-1;g>=0;g--){if(this.verticalSourceStaffEntryContainers[g].Timestamp.lt(r)){const x=new l.VerticalSourceStaffEntryContainer(this,r.clone(),this.completeNumberOfStaves);this.verticalSourceStaffEntryContainers.splice(g+1,0,x),v=new m.SourceStaffEntry(x,S),x.StaffEntries[b]=v;break}if(g===0){const x=new l.VerticalSourceStaffEntryContainer(this,r.clone(),this.completeNumberOfStaves);this.verticalSourceStaffEntryContainers.splice(g,0,x),v=new m.SourceStaffEntry(x,S),x.StaffEntries[b]=v;break}}return{createdNewContainer:!0,staffEntry:v}}findOrCreateVoiceEntry(r,b){let S,v=!1;for(const w of r.VoiceEntries)if(w.ParentVoice===b){S=w;break}return S||(S=new s.VoiceEntry(r.Timestamp,b,r),v=!0),{createdVoiceEntry:v,voiceEntry:S}}getPreviousSourceStaffEntryFromIndex(r,b){for(let S=b-1;S>=0;S--)if(this.verticalSourceStaffEntryContainers[S][r])return this.verticalSourceStaffEntryContainers[S][r]}getVerticalContainerIndexByTimestamp(r){for(let b=0,S=this.VerticalSourceStaffEntryContainers.length;b=0;_--){const B=this.verticalSourceStaffEntryContainers[_][g+x];if(B!==void 0&&B.hasTie()&&T.lt(d.Fraction.plus(B.Timestamp,B.calculateMaxNoteLength()))){T=d.Fraction.plus(B.Timestamp,B.calculateMaxNoteLength());break}}}v.push(T)}for(let w=0,T=v.length;w0)return!0}return!1}beginsWithRepetition(){return this.beginsWithLineRepetition()||this.beginsWithWordRepetition()}beginsWithLineRepetition(){for(let r=0,b=this.FirstRepetitionInstructions.length;r=0;v--)if(S=this.verticalSourceStaffEntryContainers[v].StaffEntries[r],S&&(!b||S.VoiceEntries.length>0))return S}canBeReducedToMultiRest(){var S,v;if(this.firstRepetitionInstructions.length>0||this.lastRepetitionInstructions.length>0)return!1;let r=!0,b=!1;for(const w of this.verticalSourceStaffEntryContainers)if(w){for(const T of w.StaffEntries)if(T&&T.ParentStaff.isVisible()){if(T.ChordContainers.length>0)return!1;T.ParentStaff.hasLyrics&&(b=!0);for(const g of T.VoiceEntries){for(const x of g.Notes)if(!x.isRest()){r=!1;break}if(!r)break}}}if(!r||b||this.hasMoodExpressions||this.tempoExpressions.length>0)return!1;for(const w of this.staffLinkedExpressions)if(w.length>0)return!1;for(const w of this.lastInstructionsStaffEntries)for(let T=0,g=w==null?void 0:w.Instructions.length;T0)return!0;return!1}hasTie(){for(let s=0,h=this.VoiceEntries.length;s0}}y.TabNote=l},5274(St,y,p){var d=this&&this.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(y,"__esModule",{value:!0}),y.Tie=void 0;const l=p(2561),m=p(6362),o=d(p(3065));y.Tie=class{constructor(s,h){this.notes=[],this.TieNumber=1,this.TieDirection=m.PlacementEnum.NotYetDefined,this.NoteIndexToTieDirection={},this.AddNote(s),this.type=h}getTieDirection(s){if(!s)return this.TieDirection;for(let h=0;h=0;d--)for(let l=0;l0)return!0;return!1}isStaccato(){for(const S of this.Articulations)if(S.articulationEnum===f.staccato)return!0;return!1}isAccent(){for(const S of this.Articulations)if(S.articulationEnum===f.accent||S.articulationEnum===f.strongaccent)return!0;return!1}getVerseNumberForLyricEntry(S){let v="1";return this.lyricsEntries.forEach((w,T)=>{S===T&&(v=w)}),v}createVoiceEntriesForOrnament(S,v){S||(S=this);const w=[];if(!S.ornamentContainer)return;const T=this.notes[0],g=T.Length,x=S.ParentVoice,P=S.Timestamp;let _=d.Fraction.createFromFraction(P);switch(S.ornamentContainer.GetOrnament){case o.OrnamentEnum.Trill:{const B=new d.Fraction(g.Numerator,8*g.Denominator),k=T.Pitch.getTransposedPitch(1);let R=v.getAlterationForPitch(k);S.OrnamentContainer.AccidentalAbove!==s.AccidentalEnum.NONE&&(R=S.ornamentContainer.AccidentalAbove);for(let F=0;F<8;F++)_=d.Fraction.plus(P,new d.Fraction(F*B.Numerator,B.Denominator)),F%2==0?this.createBaseVoiceEntry(_,B,x,T,w):this.createAlteratedVoiceEntry(_,B,x,T.SourceMeasure,k,R,w);break}case o.OrnamentEnum.Turn:{const B=new d.Fraction(g.Numerator,4*g.Denominator),k=T.Pitch.getTransposedPitch(-1),R=v.getAlterationForPitch(k),F=T.Pitch.getTransposedPitch(1),A=v.getAlterationForPitch(F);this.createAlteratedVoiceEntry(_,B,x,T.SourceMeasure,F,A,w),_.Add(B),this.createBaseVoiceEntry(_,B,x,T,w),_.Add(B),this.createAlteratedVoiceEntry(_,B,x,T.SourceMeasure,k,R,w),_.Add(B),this.createBaseVoiceEntry(_,B,x,T,w);break}case o.OrnamentEnum.InvertedTurn:{const B=new d.Fraction(g.Numerator,4*g.Denominator),k=T.Pitch.getTransposedPitch(-1),R=v.getAlterationForPitch(k),F=T.Pitch.getTransposedPitch(1),A=v.getAlterationForPitch(F);this.createAlteratedVoiceEntry(_,B,x,T.SourceMeasure,k,R,w),_.Add(B),this.createBaseVoiceEntry(_,B,x,T,w),_.Add(B),this.createAlteratedVoiceEntry(_,B,x,T.SourceMeasure,F,A,w),_.Add(B),this.createBaseVoiceEntry(_,B,x,T,w);break}case o.OrnamentEnum.DelayedTurn:{const B=new d.Fraction(g.Numerator,2*g.Denominator),k=T.Pitch.getTransposedPitch(-1),R=v.getAlterationForPitch(k),F=T.Pitch.getTransposedPitch(1),A=v.getAlterationForPitch(F);this.createBaseVoiceEntry(_,B,x,T,w),_=d.Fraction.plus(P,B),B.Denominator=8*g.Denominator,this.createAlteratedVoiceEntry(_,B,x,T.SourceMeasure,F,A,w),_.Add(B),this.createBaseVoiceEntry(_,B,x,T,w),_.Add(B),this.createAlteratedVoiceEntry(_,B,x,T.SourceMeasure,k,R,w),_.Add(B),this.createBaseVoiceEntry(_,B,x,T,w);break}case o.OrnamentEnum.DelayedInvertedTurn:{const B=new d.Fraction(g.Numerator,2*g.Denominator),k=T.Pitch.getTransposedPitch(-1),R=v.getAlterationForPitch(k),F=T.Pitch.getTransposedPitch(1),A=v.getAlterationForPitch(F);this.createBaseVoiceEntry(_,B,x,T,w),_=d.Fraction.plus(P,B),B.Denominator=8*g.Denominator,this.createAlteratedVoiceEntry(_,B,x,T.SourceMeasure,k,R,w),_.Add(B),this.createBaseVoiceEntry(_,B,x,T,w),_.Add(B),this.createAlteratedVoiceEntry(_,B,x,T.SourceMeasure,F,A,w),_.Add(B),this.createBaseVoiceEntry(_,B,x,T,w);break}case o.OrnamentEnum.Mordent:{const B=new d.Fraction(g.Numerator,4*g.Denominator),k=T.Pitch.getTransposedPitch(1),R=v.getAlterationForPitch(k);this.createBaseVoiceEntry(_,B,x,T,w),_.Add(B),this.createAlteratedVoiceEntry(_,B,x,T.SourceMeasure,k,R,w),B.Denominator=2*g.Denominator,_=d.Fraction.plus(P,B),this.createBaseVoiceEntry(_,B,x,T,w);break}case o.OrnamentEnum.InvertedMordent:{const B=new d.Fraction(g.Numerator,4*g.Denominator),k=T.Pitch.getTransposedPitch(-1),R=v.getAlterationForPitch(k);this.createBaseVoiceEntry(_,B,x,T,w),_.Add(B),this.createAlteratedVoiceEntry(_,B,x,T.SourceMeasure,k,R,w),B.Denominator=2*g.Denominator,_=d.Fraction.plus(P,B),this.createBaseVoiceEntry(_,B,x,T,w);break}default:throw new RangeError}return w}createBaseVoiceEntry(S,v,w,T,g){const x=new u(S,w,T.ParentStaffEntry),P=new m.Pitch(T.Pitch.FundamentalNote,T.Pitch.Octave,T.Pitch.Accidental),_=new l.Note(x,void 0,v,P,T.SourceMeasure);x.Notes.push(_),g.push(x)}createAlteratedVoiceEntry(S,v,w,T,g,x,P){const _=new u(S,w,void 0),B=new m.Pitch(g.FundamentalNote,g.Octave,x),k=new l.Note(_,void 0,v,B,T);_.Notes.push(k),P.push(_)}}var f,r;y.VoiceEntry=u,(function(b){b[b.accent=0]="accent",b[b.strongaccent=1]="strongaccent",b[b.softaccent=2]="softaccent",b[b.marcatoup=3]="marcatoup",b[b.marcatodown=4]="marcatodown",b[b.invertedstrongaccent=5]="invertedstrongaccent",b[b.staccato=6]="staccato",b[b.staccatissimo=7]="staccatissimo",b[b.spiccato=8]="spiccato",b[b.tenuto=9]="tenuto",b[b.fermata=10]="fermata",b[b.invertedfermata=11]="invertedfermata",b[b.breathmark=12]="breathmark",b[b.caesura=13]="caesura",b[b.lefthandpizzicato=14]="lefthandpizzicato",b[b.naturalharmonic=15]="naturalharmonic",b[b.snappizzicato=16]="snappizzicato",b[b.upbow=17]="upbow",b[b.downbow=18]="downbow",b[b.scoop=19]="scoop",b[b.plop=20]="plop",b[b.doit=21]="doit",b[b.falloff=22]="falloff",b[b.stress=23]="stress",b[b.unstress=24]="unstress",b[b.detachedlegato=25]="detachedlegato",b[b.otherarticulation=26]="otherarticulation",b[b.bend=27]="bend"})(f||(y.ArticulationEnum=f={})),(function(b){b[b.Undefined=-1]="Undefined",b[b.Up=0]="Up",b[b.Down=1]="Down",b[b.None=2]="None",b[b.Double=3]="Double"})(r||(y.StemDirectionType=r={}))},7456(St,y,p){var d=this&&this.__createBinding||(Object.create?function(m,o,s,h){h===void 0&&(h=s);var u=Object.getOwnPropertyDescriptor(o,s);u&&!("get"in u?!o.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return o[s]}}),Object.defineProperty(m,h,u)}:function(m,o,s,h){h===void 0&&(h=s),m[h]=o[s]}),l=this&&this.__exportStar||function(m,o){for(var s in m)s==="default"||Object.prototype.hasOwnProperty.call(o,s)||d(o,m,s)};Object.defineProperty(y,"__esModule",{value:!0}),l(p(4236),y),l(p(8365),y),l(p(9719),y),l(p(7718),y),l(p(4249),y),l(p(1850),y),l(p(4064),y),l(p(5282),y),l(p(8215),y),l(p(4387),y),l(p(2369),y),l(p(1910),y),l(p(6644),y),l(p(5274),y),l(p(4268),y),l(p(3236),y),l(p(5534),y),l(p(1336),y),l(p(9184),y),l(p(1850),y),l(p(5282),y),l(p(4387),y),l(p(2369),y),l(p(3236),y),l(p(5274),y)},1745(St,y,p){var d=this&&this.__createBinding||(Object.create?function(m,o,s,h){h===void 0&&(h=s);var u=Object.getOwnPropertyDescriptor(o,s);u&&!("get"in u?!o.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return o[s]}}),Object.defineProperty(m,h,u)}:function(m,o,s,h){h===void 0&&(h=s),m[h]=o[s]}),l=this&&this.__exportStar||function(m,o){for(var s in m)s==="default"||Object.prototype.hasOwnProperty.call(o,s)||d(o,m,s)};Object.defineProperty(y,"__esModule",{value:!0}),l(p(7307),y),l(p(9252),y),l(p(7586),y),l(p(7435),y),l(p(427),y),l(p(5294),y),l(p(7456),y),l(p(4076),y),l(p(1121),y),l(p(6352),y),l(p(899),y),l(p(2870),y)},3173(St,y){Object.defineProperty(y,"__esModule",{value:!0}),y.AJAX=void 0,y.AJAX=class{static ajax(p,d=9e3){let l;const m=p.indexOf(".mxl")>-1?"text/plain; charset=x-user-defined":"application/xml";if(XMLHttpRequest)l=new XMLHttpRequest;else{if(!ActiveXObject)return Promise.reject(new Error("XMLHttp not supported."));l=new ActiveXObject("Microsoft.XMLHTTP")}return l.timeout=d,new Promise((o,s)=>{l.onreadystatechange=()=>{l.readyState===XMLHttpRequest.DONE&&(l.status===200||l.status===0&&l.responseText?o(l.responseText):s(new Error("Could not retrieve requested URL "+l.status)))},l.ontimeout=h=>{s(new Error("Server request Timeout"))},l.overrideMimeType(m),l.open("GET",p,!0),l.send()})}}},6597(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.Cursor=void 0;const d=p(2561),l=p(624);y.Cursor=class{constructor(m,o,s){this.hidden=!0,this.currentPageNumber=1,this.skipInvisibleNotes=!0,this.container=m,this.openSheetMusicDisplay=o,this.rules=this.openSheetMusicDisplay.EngravingRules,this.cursorOptions=s;let h=0;for(this.cursorElementId="cursorImg-0";document.getElementById(this.cursorElementId);)h++,this.cursorElementId=`cursorImg-${h}`;const u=document.createElement("img");u.id=this.cursorElementId,u.style.position="absolute",this.cursorOptions.follow===!0?(this.wantedZIndex="-1",u.style.zIndex=this.wantedZIndex):(this.wantedZIndex="-2",u.style.zIndex=this.wantedZIndex),this.cursorElement=u,this.container.appendChild(u)}adjustToBackgroundColor(){let m;m=this.rules.PageBackgroundColor?"1":this.wantedZIndex,this.cursorElement.style.zIndex=m}init(m,o){this.manager=m,this.graphic=o,this.reset(),this.hidden=!0,this.hide()}show(){this.hidden=!1,this.update(),this.adjustToBackgroundColor()}resetIterator(){if(!this.openSheetMusicDisplay.Sheet||!this.openSheetMusicDisplay.Sheet.SourceMeasures)return void console.log("OSMD.Cursor.resetIterator(): sheet or measures were null/undefined.");const m=this.openSheetMusicDisplay.Sheet.SourceMeasures.length-1;let o=this.rules.MinMeasureToDrawIndex;o=Math.min(o,m);let s=this.rules.MaxMeasureToDrawIndex;if(s=Math.min(s,m),this.openSheetMusicDisplay.Sheet&&this.openSheetMusicDisplay.Sheet.SourceMeasures.length>o&&(this.openSheetMusicDisplay.Sheet.SelectionStart=this.openSheetMusicDisplay.Sheet.SourceMeasures[o].AbsoluteTimestamp),this.openSheetMusicDisplay.Sheet&&this.openSheetMusicDisplay.Sheet.SourceMeasures.length>s){const h=this.openSheetMusicDisplay.Sheet.SourceMeasures[s];this.openSheetMusicDisplay.Sheet.SelectionEnd=d.Fraction.plus(h.AbsoluteTimestamp,h.Duration)}this.iterator=this.manager.getIterator(),this.iterator.SkipInvisibleNotes=this.skipInvisibleNotes}getStaffEntryFromVoiceEntry(m){const o=m.ParentSourceStaffEntry.VerticalContainerParent.ParentMeasure.measureListIndex,s=m.ParentSourceStaffEntry.ParentStaff.idInMusicSheet;return this.graphic.findGraphicalStaffEntryFromMeasureList(s,o,m.ParentSourceStaffEntry)}update(){if(this.hidden||this.hidden===void 0||this.hidden===null)return;this.updateCurrentPage();const m=this.iterator;let o,s=m.CurrentVisibleVoiceEntries(),h=m.CurrentMeasureIndex,u=0,f=0,r=0;if(s.length!==0||m.FrontReached||m.EndReached||(m.moveToPrevious(),s=m.CurrentVisibleVoiceEntries(),m.moveToNext()),m.FrontReached&&s.length===0){m.moveToNext(),s=m.CurrentVisibleVoiceEntries();const T=this.findVisibleGraphicalMeasure(m.CurrentMeasureIndex);u=T.PositionAndShape.AbsolutePosition.x,o=T.ParentMusicSystem,m.moveToPrevious()}else if(m.EndReached||!m.CurrentVoiceEntries||s.length===0){m.moveToPrevious(),s=m.CurrentVisibleVoiceEntries(),h=m.CurrentMeasureIndex;const T=this.findVisibleGraphicalMeasure(m.CurrentMeasureIndex);u=T.PositionAndShape.AbsolutePosition.x+T.PositionAndShape.Size.width,o=T.ParentMusicSystem,m.moveToNext()}else if(m.CurrentMeasure.isReducedToMultiRest){const T=this.findVisibleGraphicalMeasure(m.CurrentMeasureIndex),g=T.parentSourceMeasure.multipleRestMeasures,x=m.CurrentMeasure.multipleRestMeasureNumber/(g+1),P=T.PositionAndShape.Size.width-T.beginInstructionsWidth;u=T.PositionAndShape.AbsolutePosition.x+T.beginInstructionsWidth+x*P,o=T.ParentMusicSystem}else{const T=s.map(g=>this.getStaffEntryFromVoiceEntry(g)).sort((g,x)=>{var P,_,B,k;return((_=(P=g==null?void 0:g.PositionAndShape)==null?void 0:P.AbsolutePosition)==null?void 0:_.x)<=((k=(B=x==null?void 0:x.PositionAndShape)==null?void 0:B.AbsolutePosition)==null?void 0:k.x)?-1:1})[0];T&&(u=T.PositionAndShape.AbsolutePosition.x,o=T.parentMeasure.ParentMusicSystem)}if(!(o!=null&&o.StaffLines[0]))return;f=o.PositionAndShape.AbsolutePosition.y+o.StaffLines[0].PositionAndShape.RelativePosition.y;let b=o.PositionAndShape.AbsolutePosition.y;const S=o.StaffLines[o.StaffLines.length-1];S&&(b+=S.PositionAndShape.RelativePosition.y+S.StaffHeight),r=b-f;const v=this.findVisibleGraphicalMeasure(h);if(!v)return;const w=v.PositionAndShape;if(this.updateWidthAndStyle(w,u,f,r),this.openSheetMusicDisplay.FollowCursor&&this.cursorOptions.follow)if(this.openSheetMusicDisplay.EngravingRules.RenderSingleHorizontalStaffline)this.cursorElement.scrollIntoView({behavior:"smooth",inline:"center"});else{const T=this.cursorElement.getBoundingClientRect().top;this.cursorElement.scrollIntoView({behavior:T<1e3?"smooth":"auto",block:"center"})}this.cursorElement.style.display=""}findVisibleGraphicalMeasure(m){for(let o=0;o{s.push(...h.Notes)}),s}GNotesUnderCursor(m){const o=this.VoicesUnderCursor(m),s=[];return o.forEach(h=>{s.push(...h.Notes.map(u=>this.rules.GNote(u)))}),s}updateCurrentPage(){let m=this.iterator.currentTimeStamp;m.RealValue<0&&(m=new d.Fraction(0,0));for(const o of this.graphic.MusicPages)if(o.MusicSystems.last().GetSystemsLastTimeStamp().gt(m)){const s=o.PageNumber;return s!==this.currentPageNumber&&(this.container.removeChild(this.cursorElement),this.container=document.getElementById("osmdCanvasPage"+s),this.container.appendChild(this.cursorElement)),this.currentPageNumber=s}return 1}get SkipInvisibleNotes(){return this.skipInvisibleNotes}set SkipInvisibleNotes(m){this.skipInvisibleNotes=m,this.iterator.SkipInvisibleNotes=m}get CursorOptions(){return this.cursorOptions}set CursorOptions(m){this.cursorOptions=m}Dispose(){this.hide(),this.container.removeChild(this.cursorElement),this.rules=void 0,this.openSheetMusicDisplay=void 0,this.cursorOptions=void 0}nextMeasure(){const m=this.Iterator.CurrentMeasure;let o=this.Iterator.currentTimeStamp.RealValue;this.next();let s=0;for(;this.Iterator.CurrentMeasure===m&&this.Iterator.currentTimeStamp.RealValue!==o&&s<999;)o=this.Iterator.currentTimeStamp.RealValue,this.next(),s++}previousMeasure(){const m=this.Iterator.CurrentMeasure;let o=this.Iterator.currentTimeStamp.RealValue;this.previous();let s=0;for(;this.Iterator.CurrentMeasure===m&&this.Iterator.currentTimeStamp.RealValue!==o&&s<999;)o=this.Iterator.currentTimeStamp.RealValue,this.previous(),s++;for(s=0;this.Iterator.CurrentRelativeInMeasureTimestamp.RealValue!==0&&s<999;)this.previous(),s++}}},624(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.OSMDOptions=y.SkyBottomLineBatchCalculatorBackendType=y.BackendType=y.FillEmptyMeasuresWithWholeRests=y.AlignRestOption=y.CursorType=void 0;const d=p(4146);var l,m,o,s,h;(function(u){u[u.Standard=0]="Standard",u[u.ThinLeft=1]="ThinLeft",u[u.ShortThinTopLeft=2]="ShortThinTopLeft",u[u.CurrentArea=3]="CurrentArea",u[u.CurrentAreaLeft=4]="CurrentAreaLeft"})(l||(y.CursorType=l={})),(function(u){u[u.Never=0]="Never",u[u.Always=1]="Always",u[u.Auto=2]="Auto"})(m||(y.AlignRestOption=m={})),(function(u){u[u.No=0]="No",u[u.YesVisible=1]="YesVisible",u[u.YesInvisible=2]="YesInvisible"})(o||(y.FillEmptyMeasuresWithWholeRests=o={})),(function(u){u[u.SVG=0]="SVG",u[u.Canvas=1]="Canvas"})(s||(y.BackendType=s={})),(function(u){u[u.Plain=0]="Plain",u[u.WebGL=1]="WebGL"})(h||(y.SkyBottomLineBatchCalculatorBackendType=h={})),y.OSMDOptions=class{static OSMDOptionsStandard(){return{autoResize:!0,backend:"svg",drawingParameters:d.DrawingParametersEnum.default}}static BackendTypeFromString(u){return u&&u.toLowerCase()==="canvas"?s.Canvas:s.SVG}}},7103(St,y,p){var d=this&&this.__importDefault||function(U){return U&&U.__esModule?U:{default:U}};Object.defineProperty(y,"__esModule",{value:!0}),y.OpenSheetMusicDisplay=void 0;const l=p(3902),m=p(806),o=p(9099),s=p(8724),h=p(7921),u=p(9479),f=p(9436),r=p(9834),b=p(6597),S=p(6888),v=p(3173),w=d(p(3065)),T=p(3661),g=p(4146),x=p(4434),P=p(624),_=p(9713),B=p(6362),k=p(3263),R=p(2683),F=p(8233),A=p(1538);class G{constructor(C,z=P.OSMDOptions.OSMDOptionsStandard()){if(this.version="1.9.9-release",this.cursorsOptions=[],this.cursors=[],this.zoom=1,this.zoomUpdated=!1,this.loadUrlTimeout=5e3,typeof C=="string"?this.container=document.getElementById(C):C&&"appendChild"in C&&(this.container=C),!this.container)throw new Error("Please pass a valid div container to OpenSheetMusicDisplay");z.autoResize===void 0&&(z.autoResize=!0),this.backendType=P.BackendType.SVG,this.setOptions(z)}get cursor(){return this.cursors[0]}get Cursor(){return this.cursor}load(C,z="Untitled Score"){this.reset();const W=this;if(C instanceof Blob){const ct=new S.MXLFile(C);return ct.tryUnzip().then(()=>ct.unzipSuccessful?ct.getXmlString().then(st=>W.load(st)):C instanceof Blob?C.text().then(st=>W.load(st)):void 0)}if(typeof C=="string"){const ct=C;if(ct.startsWith("PK"))return w.default.debug("[OSMD] This is a zip file, unpack it first: "+ct),S.MXLHelper.MXLtoXMLstring(ct).then(ot=>W.load(ot),ot=>{throw w.default.debug(ot),new Error("OpenSheetMusicDisplay: Invalid MXL file")});if(ct.startsWith(""))return w.default.debug("[OSMD] UTF with BOM detected, truncate first 3 bytes and pass along: "+ct),W.load(ct.substring(3));let st=ct;if(/^\s/.test(st)&&(st=st.trim()),st.startsWith("W.load(ot),ot=>{throw ot});console.error("[OSMD] osmd.load(string): Could not process string. Did not find {z.init(this.sheet.MusicPartManager,this.graphic)}),this.drawingParameters.DrawingParametersEnum===g.DrawingParametersEnum.leadsheet&&(this.graphic.LeadSheet=!0)}render(){var z;if(!this.graphic)throw new Error("OSMD: load() needs to be called before render()");(z=this.drawer)==null||z.clear(),this.Sheet.SourceMeasures[0].ImplicitMeasure&&(this.rules.MinMeasureToDrawNumber>1&&(this.rules.MinMeasureToDrawIndex=this.rules.MinMeasureToDrawNumber),this.rules.MaxMeasureToDrawNumber>0&&(this.rules.MaxMeasureToDrawIndex=this.rules.MaxMeasureToDrawNumber));let C=this.container.offsetWidth;this.rules.RenderSingleHorizontalStaffline&&(C=this.rules.SheetMaximumWidth),this.sheet.pageWidth=C/this.zoom/10,this.rules.PageFormat&&!this.rules.PageFormat.IsUndefined?(this.rules.PageHeight=this.sheet.pageWidth/this.rules.PageFormat.aspectRatio,w.default.debug("[OSMD] PageHeight: "+this.rules.PageHeight)):(w.default.debug("[OSMD] endless/undefined pageformat, id: "+this.rules.PageFormat.idString),this.rules.PageHeight=100001),this.graphic.reCalculate(),this.drawingParameters.drawCursors&&(this.graphic.Cursors.length=0),this.createOrRefreshRenderBackend(),this.needBackendUpdate=!1,this.drawer.setZoom(this.zoom),this.drawer.drawSheet(this.graphic),this.enableOrDisableCursors(this.drawingParameters.drawCursors),this.drawingParameters.drawCursors&&this.cursors.forEach(W=>{W.update()}),this.zoomUpdated=!1,this.rules.RenderCount++}createOrRefreshRenderBackend(){if(this.drawer&&this.drawer.Backends){this.drawer.Backends[0]&&this.drawer.Backends[0].removeAllChildrenFromContainer(this.container);for(const $ of this.drawer.Backends)$.free();this.drawer.Backends.clear()}this.drawingParameters.Rules=this.rules,this.drawer=new u.VexFlowMusicSheetDrawer(this.drawingParameters),this.drawer.drawableBoundingBoxElement=this.DrawBoundingBox,this.drawer.bottomLineVisible=this.drawBottomLine,this.drawer.skyLineVisible=this.drawSkyLine;let C,z=this.container.offsetWidth;this.rules.RenderSingleHorizontalStaffline&&(z=10*(this.EngravingRules.PageLeftMargin+this.graphic.MusicPages[0].PositionAndShape.Size.width+this.EngravingRules.PageRightMargin)*this.zoom);const W=32767;for(const $ of this.graphic.MusicPages){if($.PageNumber>this.rules.MaxPageToDrawNumber)break;const N=this.createBackend(this.backendType,$),Y=" exceeds CanvasBackend limit of 32767. Cutting off score.";N.getOSMDBackendType()===P.BackendType.Canvas&&z>W&&(w.default.warn("[OSMD] Warning: width of "+z+Y),z=W),this.rules.PageFormat&&!this.rules.PageFormat.IsUndefined?C=z/this.rules.PageFormat.aspectRatio:(C=$.PositionAndShape.Size.height,C+=this.rules.PageBottomMargin,N.getOSMDBackendType()===P.BackendType.Canvas&&(C+=.1),C+=$.PositionAndShape.BorderTop,this.rules.RenderTitle&&(C+=this.rules.TitleTopDistance),C*=10*this.zoom),N.getOSMDBackendType()===P.BackendType.Canvas&&C>W&&(w.default.warn("[OSMD] Warning: height of "+C+Y),C=Math.min(C,W)),N.resize(z,C),N.clear(),N.getContext().setFillStyle(this.rules.DefaultColorMusic),N.getContext().setStrokeStyle(this.rules.DefaultColorMusic),this.drawer.Backends.push(N),this.graphic.drawer=this.drawer}}exportSVG(){if(this.drawer)for(const C of this.drawer.Backends)C instanceof f.SvgVexFlowBackend&&C.export()}IsReadyToRender(){return this.graphic!==void 0}clear(){var C;(C=this.drawer)==null||C.clear(),this.reset()}setOptions(C){if(this.rules||(this.rules=new _.EngravingRules),this.drawingParameters||C.drawingParameters?C.drawingParameters&&(this.drawingParameters?this.drawingParameters.DrawingParametersEnum=g.DrawingParametersEnum[C.drawingParameters.toLowerCase()]:this.drawingParameters=new T.DrawingParameters(g.DrawingParametersEnum[C.drawingParameters],this.rules)):this.drawingParameters=new T.DrawingParameters(g.DrawingParametersEnum.default,this.rules),C==null)return void w.default.warn(`warning: osmd.setOptions() called without an options parameter, has no effect. example usage: osmd.setOptions({drawCredits: false, drawPartNames: false})`);this.OnXMLRead=function($){return $},C.onXMLRead&&(this.OnXMLRead=C.onXMLRead);let z=!this.drawer||!this.drawer.Backends||this.drawer.Backends.length<1;if(C.backend!==void 0){const $=P.OSMDOptions.BackendTypeFromString(C.backend);z=z||this.backendType!==$,this.backendType=$}this.needBackendUpdate=z,C.autoBeam!==void 0&&(this.rules.AutoBeamNotes=C.autoBeam);const W=C.autoBeamOptions;if(W&&(W.maintain_stem_directions===void 0&&(W.maintain_stem_directions=!1),this.rules.AutoBeamOptions=W,W.groups&&W.groups.length)){for(const $ of W.groups)if($.length!==2)throw new Error("Each fraction in autoBeamOptions.groups must be of length 2, e.g. [3,4] for beaming three fourths")}C.percussionOneLineCutoff!==void 0&&(this.rules.PercussionOneLineCutoff=C.percussionOneLineCutoff),this.rules.PercussionOneLineCutoff!==0&&C.percussionForceVoicesOneLineCutoff!==void 0&&(this.rules.PercussionForceVoicesOneLineCutoff=C.percussionForceVoicesOneLineCutoff),C.alignRests!==void 0&&(this.rules.AlignRests=C.alignRests),C.coloringMode!==void 0&&this.setColoringMode(C),C.coloringEnabled!==void 0&&(this.rules.ColoringEnabled=C.coloringEnabled),C.colorStemsLikeNoteheads!==void 0&&(this.rules.ColorStemsLikeNoteheads=C.colorStemsLikeNoteheads),C.disableCursor&&(this.drawingParameters.drawCursors=!1),C.drawHiddenNotes&&(this.drawingParameters.drawHiddenNotes=!0),C.drawCredits!==void 0&&(this.drawingParameters.DrawCredits=C.drawCredits),C.drawComposer!==void 0&&(this.drawingParameters.DrawComposer=C.drawComposer),C.drawTitle!==void 0&&(this.drawingParameters.DrawTitle=C.drawTitle),C.drawSubtitle!==void 0&&(this.drawingParameters.DrawSubtitle=C.drawSubtitle),C.drawLyricist!==void 0&&(this.drawingParameters.DrawLyricist=C.drawLyricist),C.drawMetronomeMarks!==void 0&&(this.rules.MetronomeMarksDrawn=C.drawMetronomeMarks),C.drawPartNames!==void 0&&(this.drawingParameters.DrawPartNames=C.drawPartNames,C.drawPartAbbreviations||(this.rules.RenderPartAbbreviations=C.drawPartNames)),C.drawPartAbbreviations!==void 0&&(this.rules.RenderPartAbbreviations=C.drawPartAbbreviations),C.drawFingerings===!1&&(this.rules.RenderFingerings=!1),C.drawMeasureNumbers!==void 0&&(this.rules.RenderMeasureNumbers=C.drawMeasureNumbers),C.drawMeasureNumbersOnlyAtSystemStart&&(this.rules.RenderMeasureNumbersOnlyAtSystemStart=C.drawMeasureNumbersOnlyAtSystemStart),C.drawLyrics!==void 0&&(this.rules.RenderLyrics=C.drawLyrics),C.drawTimeSignatures!==void 0&&(this.rules.RenderTimeSignatures=C.drawTimeSignatures),C.drawSlurs!==void 0&&(this.rules.RenderSlurs=C.drawSlurs),C.measureNumberInterval!==void 0&&(this.rules.MeasureNumberLabelOffset=C.measureNumberInterval),C.useXMLMeasureNumbers!==void 0&&(this.rules.UseXMLMeasureNumbers=C.useXMLMeasureNumbers),C.fingeringPosition!==void 0&&(this.rules.FingeringPosition=B.AbstractExpression.PlacementEnumFromString(C.fingeringPosition)),C.fingeringInsideStafflines!==void 0&&(this.rules.FingeringInsideStafflines=C.fingeringInsideStafflines),C.newSystemFromXML!==void 0&&(this.rules.NewSystemAtXMLNewSystemAttribute=C.newSystemFromXML),C.newSystemFromNewPageInXML!==void 0&&(this.rules.NewSystemAtXMLNewPageAttribute=C.newSystemFromNewPageInXML),C.newPageFromXML!==void 0&&(this.rules.NewPageAtXMLNewPageAttribute=C.newPageFromXML),C.fillEmptyMeasuresWithWholeRest!==void 0&&(this.rules.FillEmptyMeasuresWithWholeRest=C.fillEmptyMeasuresWithWholeRest),C.followCursor!==void 0&&(this.FollowCursor=C.followCursor),C.setWantedStemDirectionByXml!==void 0&&(this.rules.SetWantedStemDirectionByXml=C.setWantedStemDirectionByXml),C.darkMode?(this.rules.applyDefaultColorMusic("#FFFFFF"),this.rules.PageBackgroundColor="#000000",this.rules.DarkModeEnabled=!0):C.darkMode===!1&&(this.rules.applyDefaultColorMusic("#000000"),this.rules.PageBackgroundColor=void 0,this.rules.DarkModeEnabled=!1),C.defaultColorMusic&&this.rules.applyDefaultColorMusic(C.defaultColorMusic),C.defaultColorNotehead&&(this.rules.DefaultColorNotehead=C.defaultColorNotehead),C.defaultColorRest&&(this.rules.DefaultColorRest=C.defaultColorRest),C.defaultColorStem&&(this.rules.DefaultColorStem=C.defaultColorStem),C.defaultColorLabel&&(this.rules.DefaultColorLabel=C.defaultColorLabel),C.defaultColorTitle&&(this.rules.DefaultColorTitle=C.defaultColorTitle),C.defaultFontFamily&&(this.rules.DefaultFontFamily=C.defaultFontFamily),C.defaultFontStyle&&(this.rules.DefaultFontStyle=C.defaultFontStyle),C.drawUpToMeasureNumber>=0&&(this.rules.MaxMeasureToDrawIndex=Math.max(C.drawUpToMeasureNumber-1,0),this.rules.MaxMeasureToDrawNumber=C.drawUpToMeasureNumber),C.drawFromMeasureNumber>=0&&(this.rules.MinMeasureToDrawIndex=Math.max(C.drawFromMeasureNumber-1,0),this.rules.MinMeasureToDrawNumber=C.drawFromMeasureNumber),C.drawUpToPageNumber&&(this.rules.MaxPageToDrawNumber=C.drawUpToPageNumber),C.drawUpToSystemNumber&&(this.rules.MaxSystemToDrawNumber=C.drawUpToSystemNumber),C.tupletsRatioed&&(this.rules.TupletsRatioed=!0),C.tupletsBracketed&&(this.rules.TupletsBracketed=!0),C.tripletsBracketed&&(this.rules.TripletsBracketed=!0),C.autoResize?(this.resizeHandlerAttached||this.autoResize(),this.autoResizeEnabled=!0):C.autoResize===!1&&(this.autoResizeEnabled=!1),C.pageFormat!==void 0&&this.setPageFormat(C.pageFormat),C.pageBackgroundColor!==void 0&&(this.rules.PageBackgroundColor=C.pageBackgroundColor),C.renderSingleHorizontalStaffline!==void 0&&(this.rules.RenderSingleHorizontalStaffline=C.renderSingleHorizontalStaffline),C.spacingFactorSoftmax!==void 0&&(this.rules.SoftmaxFactorVexFlow=C.spacingFactorSoftmax),C.spacingBetweenTextLines!==void 0&&(this.rules.SpacingBetweenTextLines=C.spacingBetweenTextLines),C.stretchLastSystemLine!==void 0&&(this.rules.StretchLastSystemLine=C.stretchLastSystemLine),C.autoGenerateMultipleRestMeasuresFromRestMeasures!==void 0&&(this.rules.AutoGenerateMultipleRestMeasuresFromRestMeasures=C.autoGenerateMultipleRestMeasuresFromRestMeasures),C.cursorsOptions!==void 0?this.cursorsOptions=C.cursorsOptions:this.cursorsOptions=[{type:P.CursorType.Standard,color:this.EngravingRules.DefaultColorCursor,alpha:.5,follow:!0}],C.preferredSkyBottomLineBatchCalculatorBackend!==void 0&&(this.rules.PreferredSkyBottomLineBatchCalculatorBackend=C.preferredSkyBottomLineBatchCalculatorBackend),C.skyBottomLineBatchMinMeasures!==void 0&&(this.rules.SkyBottomLineBatchMinMeasures=C.skyBottomLineBatchMinMeasures)}setColoringMode(C){if(C.coloringMode===x.ColoringModes.XML)return void(this.rules.ColoringMode=x.ColoringModes.XML);const z=[F.NoteEnum.C,F.NoteEnum.D,F.NoteEnum.E,F.NoteEnum.F,F.NoteEnum.G,F.NoteEnum.A,F.NoteEnum.B];let W;if(C.coloringMode===x.ColoringModes.CustomColorSet){if(!C.coloringSetCustom||C.coloringSetCustom.length!==8)throw new Error("Invalid amount of colors: With coloringModes.customColorSet, you have to provide a coloringSetCustom parameter (array) with 8 strings (C to B, rest note).");for(const N of C.coloringSetCustom)if(!/^#[0-9a-fA-F]{6}$/.test(N))throw new Error(`One of the color strings in options.coloringSetCustom was not a valid HTML Hex color: -`+N);W=C.coloringSetCustom}else if(C.coloringMode===x.ColoringModes.AutoColoring){W=[];const N=Object.keys(R.AutoColorSet);for(let Y=0;Y{C.hide()}),this.sheet=void 0,this.graphic=void 0,this.zoom=1,this.rules.RenderCount=0}autoResize(){const C=this;this.handleResize(()=>{},()=>{var z;((z=this.graphic)==null?void 0:z.GetCalculator)instanceof m.VexFlowMusicSheetCalculator&&(this.graphic.GetCalculator.beamsNeedUpdate=!0),C.IsReadyToRender()&&C.renderAndScrollBack()})}renderAndScrollBack(){const C=window.scrollY/document.body.scrollHeight;this.render();const z=document.body.scrollHeight*C;window.scrollTo({top:z,behavior:"instant"})}handleResize(C,z){let W,$;const N=this;function Y(){N.AutoResizeEnabled&&(W=new Date().getTime(),$||(C(),W=new Date().getTime(),$=window.setTimeout(tt,200)))}function tt(){$=void 0,window.clearTimeout($),new Date().getTime()-W<200?$=window.setTimeout(tt,200):z()}window.attachEvent?window.attachEvent("onresize",Y):window.addEventListener("resize",Y),this.resizeHandlerAttached=!0,window.setTimeout(C,0),window.setTimeout(z,1)}enableOrDisableCursors(C){var z,W,$,N;if(this.drawingParameters.drawCursors=C,C)for(let Y=0;Y{Y.hide()})}createBackend(C,z){let W;return W=C===void 0||C===P.BackendType.SVG?new f.SvgVexFlowBackend(this.rules):new r.CanvasVexFlowBackend(this.rules),W.graphicalMusicPage=z,W.initialize(this.container,this.zoom),W}static StringToPageFormat(C){let z=_.PageFormat.UndefinedPageFormat;if(C.match("^[0-9]+x[0-9]+$")){const W=C.split("x"),$=Number.parseInt(W[0],10),N=Number.parseInt(W[1],10);$>0&&$<32768&&N>0&&N<32768&&(z=new _.PageFormat($,N,`customPageFormat${C}`))}return C=(C=(C=C.replace(" ","_")).replace("Landscape","L")).replace("Portrait","P"),G.PageFormatStandards.hasOwnProperty(C)&&(z=G.PageFormatStandards[C]),z}setPageFormat(C){const z=G.StringToPageFormat(C);this.needBackendUpdate=!z.Equals(this.rules.PageFormat),this.rules.PageFormat=z}setCustomPageFormat(C,z){if(C>0&&z>0){const W=new _.PageFormat(C,z);this.rules.PageFormat=W}}set DrawSkyLine(C){this.drawSkyLine=C,this.drawer&&(this.drawer.skyLineVisible=C)}get DrawSkyLine(){return this.drawer.skyLineVisible}set DrawBottomLine(C){this.drawBottomLine=C,this.drawer&&(this.drawer.bottomLineVisible=C)}get DrawBottomLine(){return this.drawer.bottomLineVisible}set DrawBoundingBox(C){this.setDrawBoundingBox(C,!0)}get DrawBoundingBox(){return this.drawBoundingBox}setDrawBoundingBox(C,z=!1){this.drawBoundingBox=C,this.drawer&&(this.drawer.drawableBoundingBoxElement=C),z&&this.renderAndScrollBack()}get AutoResizeEnabled(){return this.autoResizeEnabled}set AutoResizeEnabled(C){this.autoResizeEnabled=C}get Zoom(){return this.zoom}set Zoom(C){var z;this.zoom=C,this.zoomUpdated=!0,((z=this.graphic)==null?void 0:z.GetCalculator)instanceof m.VexFlowMusicSheetCalculator&&(this.graphic.GetCalculator.beamsNeedUpdate=this.zoomUpdated)}set FollowCursor(C){this.followCursor=C}get FollowCursor(){return this.followCursor}set TransposeCalculator(C){h.MusicSheetCalculator.transposeCalculator=C}get TransposeCalculator(){return h.MusicSheetCalculator.transposeCalculator}get Sheet(){return this.sheet}get Drawer(){return this.drawer}get GraphicSheet(){return this.graphic}get DrawingParameters(){return this.drawingParameters}get EngravingRules(){return this.rules}get Version(){return this.version}}y.OpenSheetMusicDisplay=G,G.PageFormatStandards={A3_L:new _.PageFormat(420,297,"A3_L"),A3_P:new _.PageFormat(297,420,"A3_P"),A4_L:new _.PageFormat(297,210,"A4_L"),A4_P:new _.PageFormat(210,297,"A4_P"),A5_L:new _.PageFormat(210,148,"A5_L"),A5_P:new _.PageFormat(148,210,"A5_P"),A6_L:new _.PageFormat(148,105,"A6_L"),A6_P:new _.PageFormat(105,148,"A6_P"),Endless:_.PageFormat.UndefinedPageFormat,Letter_L:new _.PageFormat(279.4,215.9,"Letter_L"),Letter_P:new _.PageFormat(215.9,279.4,"Letter_P")}},5955(St,y,p){var d=this&&this.__createBinding||(Object.create?function(m,a,s,h){h===void 0&&(h=s);var u=Object.getOwnPropertyDescriptor(a,s);u&&!("get"in u?!a.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return a[s]}}),Object.defineProperty(m,h,u)}:function(m,a,s,h){h===void 0&&(h=s),m[h]=a[s]}),l=this&&this.__exportStar||function(m,a){for(var s in m)s==="default"||Object.prototype.hasOwnProperty.call(a,s)||d(a,m,s)};Object.defineProperty(y,"__esModule",{value:!0}),l(p(3173),y),l(p(6597),y),l(p(624),y),l(p(7103),y)},8628(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.TransposeCalculator=void 0;const d=p(9735);class l{transposePitch(a,s,h){if(h===0)return a;let u=d.NoteEnum.C,f=0,r=d.AccidentalEnum.NONE;const b=d.Pitch.CalculateTransposedHalfTone(a,h);let S=b.halftone,v=b.overflow;for(let w=0;wS)break}for(let w=0;wS){let T=w;const g=d.Pitch.HalfTonesFromAccidental(a.Accidental),x=g>0,P=g<0,_=s.Key>0,B=s.Key<0;let k=!0;for(_?k=!0:B?k=!1:(x||P)&&(k=x),k&&T--;T<0;)T+=7,S+=12,v--;for(;T>=7;)T-=7,S-=12,v++;u=l.noteEnums[T],r=d.Pitch.AccidentalFromHalfTones(S-u),f=a.Octave+v;break}return new d.Pitch(u,f,r)}transposeKey(a,s){let h=0,u=0,f=a.keyTypeOriginal;if(s%12==0)return a.Key=a.keyTypeOriginal,void(a.isTransposedBy=s);for(f>6?f-=12:f<-6&&(f+=12);h=12;)r-=12;for(;r<0;)r+=12;a.Key=l.keyMapping[r],a.isTransposedBy=s}}y.TransposeCalculator=l,l.keyMapping=[0,-5,2,-3,4,-1,6,1,-4,3,-2,5],l.noteEnums=[d.NoteEnum.C,d.NoteEnum.D,d.NoteEnum.E,d.NoteEnum.F,d.NoteEnum.G,d.NoteEnum.A,d.NoteEnum.B]},8659(St,y,p){var d=this&&this.__createBinding||(Object.create?function(m,a,s,h){h===void 0&&(h=s);var u=Object.getOwnPropertyDescriptor(a,s);u&&!("get"in u?!a.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return a[s]}}),Object.defineProperty(m,h,u)}:function(m,a,s,h){h===void 0&&(h=s),m[h]=a[s]}),l=this&&this.__exportStar||function(m,a){for(var s in m)s==="default"||Object.prototype.hasOwnProperty.call(a,s)||d(a,m,s)};Object.defineProperty(y,"__esModule",{value:!0}),l(p(8628),y)},363(St,y,p){var d=this&&this.__createBinding||(Object.create?function(m,a,s,h){h===void 0&&(h=s);var u=Object.getOwnPropertyDescriptor(a,s);u&&!("get"in u?!a.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return a[s]}}),Object.defineProperty(m,h,u)}:function(m,a,s,h){h===void 0&&(h=s),m[h]=a[s]}),l=this&&this.__exportStar||function(m,a){for(var s in m)s==="default"||Object.prototype.hasOwnProperty.call(a,s)||d(a,m,s)};Object.defineProperty(y,"__esModule",{value:!0}),l(p(8659),y)},813(St,y){Object.defineProperty(y,"__esModule",{value:!0}),y.CollectionUtil=void 0,Array.prototype.last||Object.defineProperty(Array.prototype,"last",{enumerable:!1,writable:!0,value:function(){return this[this.length-1]}}),Array.prototype.clear||Object.defineProperty(Array.prototype,"clear",{enumerable:!1,writable:!0,value:function(){this.length=0}}),Array.prototype.contains||Object.defineProperty(Array.prototype,"contains",{enumerable:!1,writable:!0,value:function(p){return this.indexOf(p)!==-1}}),y.CollectionUtil=class{static contains2(p,d){for(let l=0;l0&&(s=s.rightCh);return s},a.prototype.transplant=function(s,h){s.parent===null?this.root=h:s===s.parent.leftCh?s.parent.leftCh=h:s.parent.rightCh=h,h!==null&&(h.parent=s.parent)},a.prototype.removeNode=function(s){if(s.leftCh===null)this.transplant(s,s.rightCh);else if(s.rightCh===null)this.transplant(s,s.leftCh);else{var h=this.minimumAux(s.rightCh);h.parent!==s&&(this.transplant(h,h.rightCh),h.rightCh=s.rightCh,h.rightCh.parent=h),this.transplant(s,h),h.leftCh=s.leftCh,h.leftCh.parent=h}},a.prototype.inorderTraversalAux=function(s,h,u){s===null||u.stop||(this.inorderTraversalAux(s.leftCh,h,u),u.stop||(u.stop=h(s.element)===!1,u.stop||this.inorderTraversalAux(s.rightCh,h,u)))},a.prototype.levelTraversalAux=function(s,h){var u=new l.default;for(s!==null&&u.enqueue(s),s=u.dequeue()||null;s!=null;){if(h(s.element)===!1)return;s.leftCh!==null&&u.enqueue(s.leftCh),s.rightCh!==null&&u.enqueue(s.rightCh),s=u.dequeue()||null}},a.prototype.preorderTraversalAux=function(s,h,u){s===null||u.stop||(u.stop=h(s.element)===!1,u.stop||(this.preorderTraversalAux(s.leftCh,h,u),u.stop||this.preorderTraversalAux(s.rightCh,h,u)))},a.prototype.postorderTraversalAux=function(s,h,u){s===null||u.stop||(this.postorderTraversalAux(s.leftCh,h,u),u.stop||(this.postorderTraversalAux(s.rightCh,h,u),u.stop||(u.stop=h(s.element)===!1)))},a.prototype.minimumAux=function(s){for(;s!=null&&s.leftCh!==null;)s=s.leftCh;return s},a.prototype.maximumAux=function(s){for(;s!=null&&s.rightCh!==null;)s=s.rightCh;return s},a.prototype.heightAux=function(s){return s===null?-1:Math.max(this.heightAux(s.leftCh),this.heightAux(s.rightCh))+1},a.prototype.insertNode=function(s){for(var h=null,u=this.root;u!==null;){var f=this.compare(s.element,u.element);if(f===0)return null;f<0?(h=u,u=u.leftCh):(h=u,u=u.rightCh)}return s.parent=h,h===null?this.root=s:this.compare(s.element,h.element)<0?h.leftCh=s:h.rightCh=s,s},a.prototype.createNode=function(s){return{element:s,leftCh:null,rightCh:null,parent:null}},a})();y.default=m},2909(St,y,p){Object.defineProperty(y,"__esModule",{value:!0});var d=p(4831),l=p(6119),m=p(2091),a=(function(){function s(h){this.toStrF=h||d.defaultToString,this.dictionary=new l.default(this.toStrF),this.nElements=0}return s.prototype.add=function(h,u){if(u===void 0&&(u=1),d.isUndefined(h)||u<=0)return!1;if(this.contains(h))this.dictionary.getValue(h).copies+=u;else{var f={value:h,copies:u};this.dictionary.setValue(h,f)}return this.nElements+=u,!0},s.prototype.count=function(h){return this.contains(h)?this.dictionary.getValue(h).copies:0},s.prototype.contains=function(h){return this.dictionary.containsKey(h)},s.prototype.remove=function(h,u){if(u===void 0&&(u=1),d.isUndefined(h)||u<=0)return!1;if(this.contains(h)){var f=this.dictionary.getValue(h);return u>f.copies?this.nElements-=f.copies:this.nElements-=u,f.copies-=u,f.copies<=0&&this.dictionary.remove(h),!0}return!1},s.prototype.toArray=function(){for(var h=[],u=0,f=this.dictionary.values();u=this.data.length?s>=this.data.length?-1:s:this.compare(this.data[s],this.data[h])<=0?s:h},a.prototype.siftUp=function(s){for(var h=this.parentIndex(s);s>0&&this.compare(this.data[h],this.data[s])>0;)l.swap(this.data,h,s),s=h,h=this.parentIndex(s)},a.prototype.siftDown=function(s){for(var h=this.minIndex(this.leftChildIndex(s),this.rightChildIndex(s));h>=0&&this.compare(this.data[s],this.data[h])>0;)l.swap(this.data,h,s),s=h,h=this.minIndex(this.leftChildIndex(s),this.rightChildIndex(s))},a.prototype.peek=function(){return this.data.length>0?this.data[0]:void 0},a.prototype.add=function(s){return!d.isUndefined(s)&&(this.data.push(s),this.siftUp(this.data.length-1),!0)},a.prototype.removeRoot=function(){if(this.data.length>0){var s=this.data[0];return this.data[0]=this.data[this.data.length-1],this.data.splice(this.data.length-1,1),this.data.length>0&&this.siftDown(0),s}},a.prototype.contains=function(s){var h=d.compareToEquals(this.compare);return l.contains(this.data,s,h)},a.prototype.size=function(){return this.data.length},a.prototype.isEmpty=function(){return this.data.length<=0},a.prototype.clear=function(){this.data.length=0},a.prototype.forEach=function(s){l.forEach(this.data,s)},a})();y.default=m},1846(St,y,p){var d,l=this&&this.__extends||(d=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,b){r.__proto__=b}||function(r,b){for(var S in b)b.hasOwnProperty(S)&&(r[S]=b[S])},function(r,b){function S(){this.constructor=r}d(r,b),r.prototype=b===null?Object.create(b):(S.prototype=b.prototype,new S)});Object.defineProperty(y,"__esModule",{value:!0});var m=p(6119),a=p(4831),s=(function(){function r(b,S){this.key=b,this.value=S}return r.prototype.unlink=function(){this.prev.next=this.next,this.next.prev=this.prev},r})(),h=(function(){function r(){this.key=null,this.value=null}return r.prototype.unlink=function(){this.prev.next=this.next,this.next.prev=this.prev},r})();function u(r){return!r.next}var f=(function(r){function b(S){var v=r.call(this,S)||this;return v.head=new h,v.tail=new h,v.head.next=v.tail,v.tail.prev=v.head,v}return l(b,r),b.prototype.appendToTail=function(S){var v=this.tail.prev;v.next=S,S.prev=v,S.next=this.tail,this.tail.prev=S},b.prototype.getLinkedDictionaryPair=function(S){if(!a.isUndefined(S)){var v="$"+this.toStr(S);return this.table[v]}},b.prototype.getValue=function(S){var v=this.getLinkedDictionaryPair(S);if(!a.isUndefined(v))return v.value},b.prototype.remove=function(S){var v=this.getLinkedDictionaryPair(S);if(!a.isUndefined(v))return r.prototype.remove.call(this,S),v.unlink(),v.value},b.prototype.clear=function(){r.prototype.clear.call(this),this.head.next=this.tail,this.tail.prev=this.head},b.prototype.replace=function(S,v){var w="$"+this.toStr(v.key);v.next=S.next,v.prev=S.prev,this.remove(S.key),v.prev.next=v,v.next.prev=v,this.table[w]=v,++this.nElements},b.prototype.setValue=function(S,v){if(!a.isUndefined(S)&&!a.isUndefined(v)){var w=this.getLinkedDictionaryPair(S),T=new s(S,v),g="$"+this.toStr(S);return a.isUndefined(w)?(this.appendToTail(T),this.table[g]=T,void++this.nElements):(this.replace(w,T),w.value)}},b.prototype.keys=function(){var S=[];return this.forEach(function(v,w){S.push(v)}),S},b.prototype.values=function(){var S=[];return this.forEach(function(v,w){S.push(w)}),S},b.prototype.forEach=function(S){for(var v=this.head.next;!u(v);){if(S(v.key,v.value)===!1)return;v=v.next}},b})(m.default);y.default=f},4538(St,y,p){Object.defineProperty(y,"__esModule",{value:!0});var d=p(4831),l=p(4713),m=(function(){function a(){this.firstNode=null,this.lastNode=null,this.nElements=0}return a.prototype.add=function(s,h){if(d.isUndefined(h)&&(h=this.nElements),h<0||h>this.nElements||d.isUndefined(s))return!1;var u=this.createNode(s);if(this.nElements===0||this.lastNode===null)this.firstNode=u,this.lastNode=u;else if(h===this.nElements)this.lastNode.next=u,this.lastNode=u;else if(h===0)u.next=this.firstNode,this.firstNode=u;else{var f=this.nodeAtIndex(h-1);if(f===null)return!1;u.next=f.next,f.next=u}return this.nElements++,!0},a.prototype.first=function(){if(this.firstNode!==null)return this.firstNode.element},a.prototype.last=function(){if(this.lastNode!==null)return this.lastNode.element},a.prototype.elementAtIndex=function(s){var h=this.nodeAtIndex(s);if(h!==null)return h.element},a.prototype.indexOf=function(s,h){var u=h||d.defaultEquals;if(d.isUndefined(s))return-1;for(var f=this.firstNode,r=0;f!==null;){if(u(f.element,s))return r;r++,f=f.next}return-1},a.prototype.contains=function(s,h){return this.indexOf(s,h)>=0},a.prototype.remove=function(s,h){var u=h||d.defaultEquals;if(this.nElements<1||d.isUndefined(s))return!1;for(var f=null,r=this.firstNode;r!==null;){if(u(r.element,s))return f===null?(this.firstNode=r.next,r===this.lastNode&&(this.lastNode=null)):r===this.lastNode?(this.lastNode=f,f.next=r.next,r.next=null):(f.next=r.next,r.next=null),this.nElements--,!0;f=r,r=r.next}return!1},a.prototype.clear=function(){this.firstNode=null,this.lastNode=null,this.nElements=0},a.prototype.equals=function(s,h){var u=h||d.defaultEquals;return s instanceof a&&this.size()===s.size()&&this.equalsAux(this.firstNode,s.firstNode,u)},a.prototype.equalsAux=function(s,h,u){for(;s!==null&&h!==null;){if(!u(s.element,h.element))return!1;s=s.next,h=h.next}return!0},a.prototype.removeElementAtIndex=function(s){if(!(s<0||s>=this.nElements||this.firstNode===null||this.lastNode===null)){var h;if(this.nElements===1)h=this.firstNode.element,this.firstNode=null,this.lastNode=null;else{var u=this.nodeAtIndex(s-1);u===null?(h=this.firstNode.element,this.firstNode=this.firstNode.next):u.next===this.lastNode&&(h=this.lastNode.element,this.lastNode=u),u!==null&&u.next!==null&&(h=u.next.element,u.next=u.next.next)}return this.nElements--,h}},a.prototype.forEach=function(s){for(var h=this.firstNode;h!==null&&s(h.element)!==!1;)h=h.next},a.prototype.reverse=function(){for(var s=null,h=this.firstNode,u=null;h!==null;)u=h.next,h.next=s,s=h,h=u;u=this.firstNode,this.firstNode=this.lastNode,this.lastNode=u},a.prototype.toArray=function(){for(var s=[],h=this.firstNode;h!==null;)s.push(h.element),h=h.next;return s},a.prototype.size=function(){return this.nElements},a.prototype.isEmpty=function(){return this.nElements<=0},a.prototype.toString=function(){return l.toString(this.toArray())},a.prototype.nodeAtIndex=function(s){if(s<0||s>=this.nElements)return null;if(s===this.nElements-1)return this.lastNode;for(var h=this.firstNode,u=0;u-1&&this.insertIdIntoRoot(a,s),this.nodes)if(this.nodes.hasOwnProperty(h)){var u=this.findNodeId(h,m);u>-1&&this.insertIdIntoNode(h,a,u)}},l.prototype.insertIdAfterId=function(m,a){var s=this.findRootId(m);for(var h in s>-1&&this.insertIdIntoRoot(a,s+1),this.nodes)if(this.nodes.hasOwnProperty(h)){var u=this.findNodeId(h,m);u>-1&&this.insertIdIntoNode(h,a,u+1)}},l.prototype.insertIdIntoId=function(m,a){this.nodeInsertAtEnd(m,a),this.nodes[a]=[]},l.prototype.insertIdIntoRoot=function(m,a){if(a===void 0)this.rootInsertAtEnd(m);else if(a<0){var s=this.rootIds.length;this.rootIds.splice(a+s+1,0,m)}else this.rootIds.splice(a,0,m);this.nodes[m]=this.nodes[m]||[]},l.prototype.insertIdIntoNode=function(m,a,s){if(this.nodes[m]=this.nodes[m]||[],this.nodes[a]=this.nodes[a]||[],s===void 0)this.nodeInsertAtEnd(m,a);else if(s<0){var h=this.nodes[m].length;this.nodes[m].splice(s+h+1,0,a)}else this.nodes[m].splice(s,0,a)},l.prototype.moveId=function(m,a,s){var h=m,u=this.findRootId(h);for(var f in this.nodes[a],this.nodes)if(this.nodes.hasOwnProperty(f)){this.findNodeId(f,a);break}var r=a,b=this.findRootId(r);for(var f in this.nodes[a],this.nodes)if(this.nodes.hasOwnProperty(f)){this.findNodeId(f,a);break}if(u>-1){if(b>-1)switch(this.rootDelete(u),b>u&&b--,s){case p.BEFORE:this.insertIdIntoRoot(h,b);break;case p.AFTER:this.insertIdIntoRoot(h,b+1);break;case p.INSIDE_AT_START:this.nodeInsertAtStart(r,h);break;case p.INSIDE_AT_END:this.nodeInsertAtEnd(r,h)}else for(var f in this.rootDelete(u),this.nodes)if(this.nodes.hasOwnProperty(f)&&(S=this.findNodeId(f,r))>-1){switch(s){case p.BEFORE:this.insertIdIntoNode(f,h,S);break;case p.AFTER:this.insertIdIntoNode(f,h,S+1);break;case p.INSIDE_AT_START:this.nodeInsertAtStart(r,h);break;case p.INSIDE_AT_END:this.nodeInsertAtEnd(r,h)}break}}else if(b>-1){for(var f in this.nodes)if(this.nodes.hasOwnProperty(f)&&(S=this.findNodeId(f,h))>-1){this.nodeDeleteAtIndex(f,S);break}switch(s){case p.BEFORE:this.insertIdIntoRoot(h,b);break;case p.AFTER:this.insertIdIntoRoot(h,b+1);break;case p.INSIDE_AT_START:this.nodeInsertAtStart(r,h);break;case p.INSIDE_AT_END:this.nodeInsertAtEnd(r,h)}}else{for(var f in this.nodes)if(this.nodes.hasOwnProperty(f)&&(S=this.findNodeId(f,h))>-1){this.nodeDeleteAtIndex(f,S);break}for(var f in this.nodes){var S;if(this.nodes.hasOwnProperty(f)&&(S=this.findNodeId(f,r))>-1){switch(s){case p.BEFORE:this.insertIdIntoNode(f,h,S);break;case p.AFTER:this.insertIdIntoNode(f,h,S+1);break;case p.INSIDE_AT_START:this.nodeInsertAtStart(r,h);break;case p.INSIDE_AT_END:this.nodeInsertAtEnd(r,h)}break}}}},l.prototype.swapArrayElements=function(m,a,s){var h=m[a];return m[a]=m[s],m[s]=h,m},l.prototype.rootDeleteId=function(m){var a=this.findRootId(m);a>-1&&this.rootDelete(a)},l.prototype.nodeAndSubNodesDelete=function(m){for(var a=[],s=0;sh.size())return!1;var u=!0;return this.forEach(function(f){return!!h.contains(f)||(u=!1,!1)}),u},s.prototype.remove=function(h){return!!this.contains(h)&&(this.dictionary.remove(h),!0)},s.prototype.forEach=function(h){this.dictionary.forEach(function(u,f){return h(f)})},s.prototype.toArray=function(){return this.dictionary.values()},s.prototype.isEmpty=function(){return this.dictionary.isEmpty()},s.prototype.size=function(){return this.dictionary.size()},s.prototype.clear=function(){this.dictionary.clear()},s.prototype.toString=function(){return l.toString(this.toArray())},s})();y.default=a},2083(St,y,p){Object.defineProperty(y,"__esModule",{value:!0});var d=p(4538),l=(function(){function m(){this.list=new d.default}return m.prototype.push=function(a){return this.list.add(a,0)},m.prototype.add=function(a){return this.list.add(a,0)},m.prototype.pop=function(){return this.list.removeElementAtIndex(0)},m.prototype.peek=function(){return this.list.first()},m.prototype.size=function(){return this.list.size()},m.prototype.contains=function(a,s){return this.list.contains(a,s)},m.prototype.isEmpty=function(){return this.list.isEmpty()},m.prototype.clear=function(){this.list.clear()},m.prototype.forEach=function(a){this.list.forEach(a)},m})();y.default=l},4713(St,y,p){Object.defineProperty(y,"__esModule",{value:!0});var d=p(4831);function l(m,a,s){for(var h=s||d.defaultEquals,u=m.length,f=0;f=0;u--)if(h(m[u],a))return u;return-1},y.contains=function(m,a,s){return l(m,a,s)>=0},y.remove=function(m,a,s){var h=l(m,a,s);return!(h<0||(m.splice(h,1),0))},y.frequency=function(m,a,s){for(var h=s||d.defaultEquals,u=m.length,f=0,r=0;r=m.length||s<0||s>=m.length)return!1;var h=m[a];return m[a]=m[s],m[s]=h,!0},y.toString=function(m){return"["+m.toString()+"]"},y.forEach=function(m,a){for(var s=0,h=m;sXn});const d=()=>{};d.L=(vt,i)=>{if(!i)return;const c=Array.prototype.slice.call(i).join(" ");window.console.log(vt+": "+c)},d.MakeException=vt=>class extends Error{constructor(i,c){super(i),this.name=vt,this.message=i,this.data=c}},d.RERR=d.RuntimeError=class{constructor(vt,i){this.code=vt,this.message=i}toString(){return"[RuntimeError] "+this.code+":"+this.message}},d.Merge=(vt,i)=>{for(const c in i)vt[c]=i[c];return vt},d.Min=Math.min,d.Max=Math.max,d.forEach=(vt,i)=>{for(let c=0;cvt%i>=i/2?parseInt(vt/i,10)*i+i:parseInt(vt/i,10)*i,d.MidLine=(vt,i)=>{let c=i+(vt-i)/2;return c%2>0&&(c=d.RoundN(10*c,5)/10),c},d.SortAndUnique=(vt,i,c)=>{if(vt.length>1){const M=[];let I;vt.sort(i);for(let V=0;V{let c=vt.length;for(;c--;)if(vt[c]===i)return!0;return!1},d.getCanvasContext=vt=>{if(!vt)throw new d.RERR("BadArgument","Invalid canvas selector: "+vt);const i=document.getElementById(vt);if(!i||!i.getContext)throw new d.RERR("UnsupportedBrowserError","This browser does not support HTML5 Canvas");return i.getContext("2d")},d.drawDot=(vt,i,c,M="#55")=>{vt.save(),vt.setFillStyle(M),vt.beginPath(),vt.arc(i,c,3,0,2*Math.PI,!0),vt.closePath(),vt.fill(),vt.restore()},d.BM=(vt,i)=>{const c=new Date().getTime();i();const M=new Date().getTime()-c;d.L(vt+M+"ms")},d.StackTrace=()=>new Error().stack,d.W=(...vt)=>{const i=vt.join(" ");window.console.log("Warning: ",i,d.StackTrace())},(d.Prefix=vt=>d.Prefix.prefix+vt).prefix="vf-";class l{static GCD(i,c){if(typeof i!="number"||typeof c!="number")throw new d.RERR("BadArgument",`Invalid numbers: ${i}, ${c}`);let M;for(;c!==0;)M=c,c=i%c,i=M;return i}static LCM(i,c){return i*c/l.GCD(i,c)}static LCMM(i){if(i.length===0)return 0;if(i.length===1)return i[0];if(i.length===2)return l.LCM(i[0],i[1]);{const c=i[0];return i.shift(),l.LCM(c,l.LCMM(i))}}constructor(i,c){this.set(i,c)}set(i,c){return this.numerator=i===void 0?1:i,this.denominator=c===void 0?1:c,this}value(){return this.numerator/this.denominator}simplify(){let i=this.numerator,c=this.denominator;const M=l.GCD(i,c);return i/=M,c/=M,c<0&&(c=-c,i=-i),this.set(i,c)}add(i,c){let M,I;i instanceof l?(M=i.numerator,I=i.denominator):(M=i!==void 0?i:0,I=c!==void 0?c:1);const V=l.LCM(this.denominator,I),X=V/this.denominator,Z=V/I,nt=this.numerator*X+M*Z;return this.set(nt,V)}subtract(i,c){let M,I;i instanceof l?(M=i.numerator,I=i.denominator):(M=i!==void 0?i:0,I=c!==void 0?c:1);const V=l.LCM(this.denominator,I),X=V/this.denominator,Z=V/I,nt=this.numerator*X-M*Z;return this.set(nt,V)}multiply(i,c){let M,I;return i instanceof l?(M=i.numerator,I=i.denominator):(M=i!==void 0?i:1,I=c!==void 0?c:1),this.set(this.numerator*M,this.denominator*I)}divide(i,c){let M,I;return i instanceof l?(M=i.numerator,I=i.denominator):(M=i!==void 0?i:1,I=c!==void 0?c:1),this.set(this.numerator*I,this.denominator*M)}equals(i){const c=l.__compareA.copy(i).simplify(),M=l.__compareB.copy(this).simplify();return c.numerator===M.numerator&&c.denominator===M.denominator}greaterThan(i){const c=l.__compareB.copy(this);return c.subtract(i),c.numerator>0}greaterThanEquals(i){const c=l.__compareB.copy(this);return c.subtract(i),c.numerator>=0}lessThan(i){return!this.greaterThanEquals(i)}lessThanEquals(i){return!this.greaterThan(i)}clone(){return new l(this.numerator,this.denominator)}copy(i){return typeof i=="number"?this.set(i||0,1):this.set(i.numerator,i.denominator)}quotient(){return Math.floor(this.numerator/this.denominator)}fraction(){return this.numerator%this.denominator}abs(){return this.denominator=Math.abs(this.denominator),this.numerator=Math.abs(this.numerator),this}toString(){return this.numerator+"/"+this.denominator}toSimplifiedString(){return l.__tmp.copy(this).simplify().toString()}toMixedString(){let i="";const c=this.quotient(),M=l.__tmp.copy(this);return c<0?M.abs().fraction():M.fraction(),c!==0?(i+=c,M.numerator!==0&&(i+=" "+M.toSimplifiedString())):i=M.numerator===0?"0":M.toSimplifiedString(),i}parse(i){const c=i.split("/"),M=parseInt(c[0],10),I=c[1]?parseInt(c[1],10):1;return this.set(M,I)}}l.__compareA=new l,l.__compareB=new l,l.__tmp=new l;const m=d.MakeException("RegistryError");function a(vt,i,c,M,I){vt[i][c]||(vt[i][c]={}),vt[i][c][M]=I}class s{static get INDEXES(){return["type"]}constructor(){this.clear()}static enableDefaultRegistry(i){s.defaultRegistry=i}static getDefaultRegistry(){return s.defaultRegistry}static disableDefaultRegistry(){s.defaultRegistry=null}clear(){return this.index={id:{},type:{},class:{}},this}updateIndex({id:i,name:c,value:M,oldValue:I}){const V=this.getElementById(i);I!==null&&this.index[c][I]&&delete this.index[c][I][i],M!==null&&a(this.index,c,M,V.getAttribute("id"),V)}register(i,c){if(!(c=c||i.getAttribute("id")))throw new m("Can't add element without `id` attribute to registry",i);return i.setAttribute("id",c),a(this.index,"id",c,c,i),s.INDEXES.forEach(M=>{this.updateIndex({id:c,name:M,value:i.getAttribute(M),oldValue:null})}),i.onRegister(this),this}getElementById(i){return this.index.id[i]?this.index.id[i][i]:null}getElementsByAttribute(i,c){const M=this.index[i];return M&&M[c]?Object.keys(M[c]).map(I=>M[c][I]):[]}getElementsByType(i){return this.getElementsByAttribute("type",i)}getElementsByClass(i){return this.getElementsByAttribute("class",i)}onUpdate({id:i,name:c,value:M,oldValue:I}){return(function(V,X){return V.filter(Z=>Z===X).length>0})(s.INDEXES.concat(["id","class"]),c)?(this.updateIndex({id:i,name:c,value:M,oldValue:I}),this):this}}s.defaultRegistry=null;class h{static newID(){return"auto"+h.ID++}constructor({type:i}={}){this.attrs={id:h.newID(),el:null,type:i||"Base",classes:{}},this.boundingBox=null,this.context=null,this.rendered=!1,s.getDefaultRegistry()&&s.getDefaultRegistry().register(this)}setStyle(i){return this.style=i,this}getStyle(){return this.style}applyStyle(i=this.context,c=this.getStyle()){return c?(i.save(),c.shadowColor&&i.setShadowColor(c.shadowColor),c.shadowBlur&&i.setShadowBlur(c.shadowBlur),c.fillStyle&&i.setFillStyle(c.fillStyle),c.strokeStyle&&i.setStrokeStyle(c.strokeStyle),c.lineWidth&&i.setLineWidth(c.lineWidth),this):this}restoreStyle(i=this.context,c=this.getStyle()){return c?(i.restore(),this):this}drawWithStyle(){this.checkContext(),this.applyStyle(),this.draw(),this.restoreStyle()}hasClass(i){return this.attrs.classes[i]===!0}addClass(i){return this.attrs.classes[i]=!0,this.registry&&this.registry.onUpdate({id:this.getAttribute("id"),name:"class",value:i,oldValue:null}),this}removeClass(i){return delete this.attrs.classes[i],this.registry&&this.registry.onUpdate({id:this.getAttribute("id"),name:"class",value:null,oldValue:i}),this}onRegister(i){return this.registry=i,this}isRendered(){return this.rendered}setRendered(i=!0){return this.rendered=i,this}getAttributes(){return this.attrs}getAttribute(i){return this.attrs[i]}setAttribute(i,c){const M=this.attrs.id,I=this.attrs[i];return this.attrs[i]=c,this.registry&&this.registry.onUpdate({id:M,name:i,value:c,oldValue:I}),this}getContext(){return this.context}setContext(i){return this.context=i,this}getBoundingBox(){return this.boundingBox}checkContext(){if(!this.context)throw new d.RERR("NoContext","No rendering context attached to instance");return this.context}}h.ID=1e3;class u{constructor(i,c,M,I){this.x1=Number.NaN,this.y1=Number.NaN,this.x2=Number.NaN,this.y2=Number.NaN,this.addPoint(i,c),this.addPoint(M,I)}width(){return this.x2-this.x1}height(){return this.y2-this.y1}addPoint(i,c){i!=null&&((isNaN(this.x1)||isNaN(this.x2))&&(this.x1=i,this.x2=i),ithis.x2&&(this.x2=i)),c!=null&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=c,this.y2=c),cthis.y2&&(this.y2=c))}addX(i){this.addPoint(i,null)}addY(i){this.addPoint(null,i)}addQuadraticCurve(i,c,M,I,V,X){const Z=i+.6666666666666666*(M-i),nt=c+2/3*(I-c),ot=Z+1/3*(V-i),ft=nt+1/3*(X-c);this.addBezierCurve(i,c,Z,nt,ot,ft,V,X)}addBezierCurve(i,c,M,I,V,X,Z,nt){const ot=[i,c],ft=[M,I],pt=[V,X],gt=[Z,nt];let bt;this.addPoint(ot[0],ot[1]),this.addPoint(gt[0],gt[1]);const Mt=(_t,Tt)=>Math.pow(1-_t,3)*ot[Tt]+3*Math.pow(1-_t,2)*_t*ft[Tt]+3*(1-_t)*Math.pow(_t,2)*pt[Tt]+Math.pow(_t,3)*gt[Tt];for(bt=0;bt<=1;bt++){const _t=6*ot[bt]-12*ft[bt]+6*pt[bt],Tt=-3*ot[bt]+9*ft[bt]-9*pt[bt]+3*gt[bt],Ft=3*ft[bt]-3*ot[bt];if(Tt===0){if(_t===0)continue;const ne=-Ft/_t;0{if(!vt)throw new d.RERR("BadArgument","Invalid clef: "+vt);const i=v.clefProperties.values[vt];if(!i)throw new d.RERR("BadArgument","Invalid clef: "+vt);return i}};v.clefProperties.values={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}},v.keyProperties=(vt,i,c)=>{i===void 0&&(i="treble");const M={octave_shift:0};typeof c=="object"&&d.Merge(M,c);const I=vt.split("/");if(I.length<2)throw new d.RERR("BadArguments",`Key must have note + octave and an optional glyph: ${vt}`);const V=I[0].toUpperCase(),X=v.keyProperties.note_values[V];if(!X)throw new d.RERR("BadArguments","Invalid key name: "+V);X.octave&&(I[1]=X.octave);let Z=parseInt(I[1],10);Z-=M.octave_shift;let nt=(7*Z-28+X.index)/2;nt+=v.clefProperties(i).line_shift;let ot=0;nt<=0&&2*nt%2==0&&(ot=1),nt>=6&&2*nt%2==0&&(ot=-1);const ft=X.int_val!==void 0?12*Z+X.int_val:null,pt=X.code,gt=X.shift_right;let bt={};if(I.length>2&&I[2]){const Mt=I[2].toUpperCase();bt=v.keyProperties.customNoteHeads[Mt]||{}}return{key:V,octave:Z,line:nt,int_value:ft,accidental:X.accidental,code:pt,stroke:ot,shift_right:gt,displaced:!1,...bt}},v.keyProperties.note_values={C:{index:0,int_val:0,accidental:null},CN:{index:0,int_val:0,accidental:"n"},"C#":{index:0,int_val:1,accidental:"#"},"C##":{index:0,int_val:2,accidental:"##"},CB:{index:0,int_val:-1,accidental:"b"},CBB:{index:0,int_val:-2,accidental:"bb"},D:{index:1,int_val:2,accidental:null},DN:{index:1,int_val:2,accidental:"n"},"D#":{index:1,int_val:3,accidental:"#"},"D##":{index:1,int_val:4,accidental:"##"},DB:{index:1,int_val:1,accidental:"b"},DBB:{index:1,int_val:0,accidental:"bb"},E:{index:2,int_val:4,accidental:null},EN:{index:2,int_val:4,accidental:"n"},"E#":{index:2,int_val:5,accidental:"#"},"E##":{index:2,int_val:6,accidental:"##"},EB:{index:2,int_val:3,accidental:"b"},EBB:{index:2,int_val:2,accidental:"bb"},F:{index:3,int_val:5,accidental:null},FN:{index:3,int_val:5,accidental:"n"},"F#":{index:3,int_val:6,accidental:"#"},"F##":{index:3,int_val:7,accidental:"##"},FB:{index:3,int_val:4,accidental:"b"},FBB:{index:3,int_val:3,accidental:"bb"},G:{index:4,int_val:7,accidental:null},GN:{index:4,int_val:7,accidental:"n"},"G#":{index:4,int_val:8,accidental:"#"},"G##":{index:4,int_val:9,accidental:"##"},GB:{index:4,int_val:6,accidental:"b"},GBB:{index:4,int_val:5,accidental:"bb"},A:{index:5,int_val:9,accidental:null},AN:{index:5,int_val:9,accidental:"n"},"A#":{index:5,int_val:10,accidental:"#"},"A##":{index:5,int_val:11,accidental:"##"},AB:{index:5,int_val:8,accidental:"b"},ABB:{index:5,int_val:7,accidental:"bb"},B:{index:6,int_val:11,accidental:null},BN:{index:6,int_val:11,accidental:"n"},"B#":{index:6,int_val:12,accidental:"#"},"B##":{index:6,int_val:13,accidental:"##"},BB:{index:6,int_val:10,accidental:"b"},BBB:{index:6,int_val:9,accidental:"bb"},R:{index:6,int_val:9,rest:!0},X:{index:6,accidental:"",octave:4,code:"v3e",shift_right:5.5}},v.keyProperties.customNoteHeads={D0:{code:"v27",shift_right:0,stem_up_x_offset:0,stem_down_x_offset:0,stem_up_y_offset:-1,stem_down_y_offset:0},D1:{code:"v2d",shift_right:-.5},D2:{code:"v22",shift_right:-.5},D3:{code:"v70",shift_right:-.5},T0:{code:"v49",shift_right:-2,stem_up_y_offset:-4,stem_down_y_offset:4},T1:{code:"v93",shift_right:.5,stem_up_y_offset:-4,stem_down_y_offset:4},T2:{code:"v40",shift_right:.5,stem_up_y_offset:-4,stem_down_y_offset:4},T3:{code:"v7d",shift_right:.5,stem_up_y_offset:-4,stem_down_y_offset:4},TI:{code:"v11",shift_right:0,stem_up_y_shift:5,stem_down_y_shift:5,stem_up_x_offset:6,stem_down_x_offset:4},X0:{code:"v92",stem_up_x_offset:-2,stem_down_x_offset:0,stem_up_y_offset:4,stem_down_y_offset:4},X1:{code:"v95",shift_right:-.5,stem_up_y_offset:4,stem_down_y_offset:4},X2:{code:"v3e",shift_right:.5,stem_up_y_offset:4,stem_down_y_offset:4},X3:{code:"v3b",shift_right:0,stem_up_x_offset:-1.2,stem_down_x_offset:0,stem_up_y_offset:-1,stem_down_y_offset:2},S1:{code:"vd3",shift_right:0},S2:{code:"vd2",shift_right:0},R1:{code:"vd5",shift_right:0},R2:{code:"vd4",shift_right:0},rwl:{code:"rwl",shift_right:0},rhl:{code:"rhl",shift_right:0}},v.integerToNote=vt=>{if(vt===void 0)throw new d.RERR("BadArguments","Undefined integer for integerToNote");if(vt<-2)throw new d.RERR("BadArguments",`integerToNote requires integer > -2: ${vt}`);const i=v.integerToNote.table[vt];if(!i)throw new d.RERR("BadArguments",`Unknown note value for integer: ${vt}`);return i},v.integerToNote.table={0:"C",1:"C#",2:"D",3:"D#",4:"E",5:"F",6:"F#",7:"G",8:"G#",9:"A",10:"A#",11:"B"},v.tabToGlyph=(vt,i=1,c=!1)=>{let M=null,I=0,V=0;if(vt.toString().toUpperCase()==="X"){M="v7f",c&&(M="v3e");const X=new S(M,v.DEFAULT_TABLATURE_FONT_SCALE*i).getMetrics();I=X.width,V=-X.height/2}else I=v.textWidth(vt.toString());return{text:vt,code:M,getWidth:()=>I*i,shift_y:V}},v.textWidth=vt=>7*vt.toString().length,v.articulationCodes=vt=>v.articulationCodes.articulations[vt],v.articulationCodes.articulations={"a.":{code:"v23",between_lines:!0},av:{code:"v28",between_lines:!0},"a>":{code:"v42",between_lines:!0},"a-":{code:"v25",between_lines:!0},"a^":{code:"va",between_lines:!1},"a+":{code:"v8b",between_lines:!1},ao:{code:"v94",between_lines:!1},ah:{code:"vb9",between_lines:!1},"a@a":{code:"v43",between_lines:!1},"a@u":{code:"v5b",between_lines:!1},"a|":{code:"v75",between_lines:!1},am:{code:"v97",between_lines:!1},"a,":{code:"vb3",between_lines:!1}},v.accidentalCodes=vt=>v.accidentalCodes.accidentals[vt],v.accidentalCodes.accidentals={"#":{code:"v18",parenRightPaddingAdjustment:-1},"##":{code:"v7f",parenRightPaddingAdjustment:-1},b:{code:"v44",parenRightPaddingAdjustment:-2},bb:{code:"v26",parenRightPaddingAdjustment:-2},n:{code:"v4e",parenRightPaddingAdjustment:-1},"{":{code:"v9c",parenRightPaddingAdjustment:-1},"}":{code:"v84",parenRightPaddingAdjustment:-1},db:{code:"v9e",parenRightPaddingAdjustment:-1},d:{code:"vab",parenRightPaddingAdjustment:0},bbs:{code:"v90",parenRightPaddingAdjustment:-1},"++":{code:"v51",parenRightPaddingAdjustment:-1},"+":{code:"v78",parenRightPaddingAdjustment:-1},"+-":{code:"v8d",parenRightPaddingAdjustment:-1},"++-":{code:"v7a",parenRightPaddingAdjustment:-1},bs:{code:"vb7",parenRightPaddingAdjustment:-1},bss:{code:"v39",parenRightPaddingAdjustment:-1},o:{code:"vd0",parenRightPaddingAdjustment:-1},k:{code:"vd1",parenRightPaddingAdjustment:-1},ashs:{code:"vd6",parenRightPaddingAdjustment:-1},afhf:{code:"vd7",parenRightPaddingAdjustment:-1}},v.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]}},v.ornamentCodes=vt=>v.ornamentCodes.ornaments[vt],v.ornamentCodes.ornaments={mordent:{code:"v1e"},mordent_inverted:{code:"v45"},turn:{code:"v72"},turn_inverted:{code:"v33"},tr:{code:"v1f"},upprall:{code:"v60"},downprall:{code:"vb4"},prallup:{code:"v6d"},pralldown:{code:"v2c"},upmordent:{code:"v29"},downmordent:{code:"v68"},lineprall:{code:"v20"},prallprall:{code:"v86"}},v.keySignature=vt=>{const i=v.keySignature.keySpecs[vt];if(!i)throw new d.RERR("BadKeySignature",`Bad key signature spec: '${vt}'`);if(!i.acc)return[];const c=v.keySignature.accidentalList(i.acc),M=[];for(let I=0;I({b:[2,.5,2.5,1,3,1.5,3.5],"#":[0,1.5,-.5,1,2.5,.5,2]})[vt],v.parseNoteDurationString=vt=>{if(typeof vt!="string")return null;const i=/(\d*\/?\d+|[a-z])(d*)([nrhms]|$)/.exec(vt);if(!i)return null;const c=i[1],M=i[2].length;let I=i[3];return I.length===0&&(I="n"),{duration:c,dots:M,type:I}},v.parseNoteStruct=vt=>{const i=vt.duration,c=v.parseNoteDurationString(i);if(!c)return null;let M=v.durationToTicks(c.duration);if(M==null)return null;let I=vt.type;const V=[];if(I){if(!v.getGlyphProps.validTypes[I])return null}else I=c.type||"n",vt.keys!==void 0&&vt.keys.forEach((nt,ot)=>{const ft=nt.split("/");ft&&ft.length===3&&(V[ot]=ft[2])});const X=vt.dots?vt.dots:c.dots;if(typeof X!="number")return null;let Z=M;for(let nt=0;nt{const i=v.durationAliases[vt];if(i!==void 0&&(vt=i),v.durationToTicks.durations[vt]===void 0)throw new d.RERR("BadArguments",`The provided duration is not valid: ${vt}`);return vt},v.durationToFraction=vt=>new l().parse(v.sanitizeDuration(vt)),v.durationToNumber=vt=>v.durationToFraction(vt).value(),v.durationToTicks=vt=>{vt=v.sanitizeDuration(vt);const i=v.durationToTicks.durations[vt];return i===void 0?null:i},v.durationToTicks.durations={"1/2":2*v.RESOLUTION,1:v.RESOLUTION/1,2:v.RESOLUTION/2,4:v.RESOLUTION/4,8:v.RESOLUTION/8,16:v.RESOLUTION/16,32:v.RESOLUTION/32,64:v.RESOLUTION/64,128:v.RESOLUTION/128,256:v.RESOLUTION/256},v.durationAliases={w:"1",h:"2",q:"4",b:"256"},v.getGlyphProps=(vt,i)=>{vt=v.sanitizeDuration(vt);const c=v.getGlyphProps.duration_codes[vt];if(c===void 0)return null;i||(i="n");let M=c.type[i];if(M===void 0){const I=v.keyProperties.customNoteHeads[i.toUpperCase()];if(I===void 0)return null;M={code_head:I.code,...I}}return{...c.common,...M}},v.getGlyphProps.validTypes={n:{name:"note"},r:{name:"rest"},h:{name:"harmonic"},m:{name:"muted"},s:{name:"slash"}},v.getGlyphProps.duration_codes={"1/2":{common:{getWidth(vt=v.DEFAULT_NOTATION_FONT_SCALE){return new S(this.code_head||"v53",vt).getMetrics().width},stem:!1,stem_offset:0,flag:!1,stem_up_extension:-v.STEM_HEIGHT,stem_down_extension:-v.STEM_HEIGHT,tabnote_stem_up_extension:-v.STEM_HEIGHT,tabnote_stem_down_extension:-v.STEM_HEIGHT,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"v53"},h:{code_head:"v59"},m:{code_head:"vf",stem_offset:0},r:{code_head:"v31",rest:!0,position:"B/5",dot_shiftY:.5},s:{getWidth:()=>v.SLASH_NOTEHEAD_WIDTH,position:"B/4"}}},1:{common:{getWidth(vt=v.DEFAULT_NOTATION_FONT_SCALE){return new S(this.code_head||"v1d",vt).getMetrics().width},stem:!1,stem_offset:0,flag:!1,stem_up_extension:-v.STEM_HEIGHT,stem_down_extension:-v.STEM_HEIGHT,tabnote_stem_up_extension:-v.STEM_HEIGHT,tabnote_stem_down_extension:-v.STEM_HEIGHT,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"v1d"},h:{code_head:"v46"},m:{code_head:"v92",stem_offset:-3},r:{code_head:"v5c",rest:!0,position:"D/5",dot_shiftY:.5},s:{getWidth:()=>v.SLASH_NOTEHEAD_WIDTH,position:"B/4"}}},2:{common:{getWidth(vt=v.DEFAULT_NOTATION_FONT_SCALE){return new S(this.code_head||"v81",vt).getMetrics().width},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:"v81"},h:{code_head:"v2d"},m:{code_head:"v95",stem_offset:-3},r:{code_head:"vc",stem:!1,rest:!0,position:"B/4",dot_shiftY:-.5},s:{getWidth:()=>v.SLASH_NOTEHEAD_WIDTH,position:"B/4"}}},4:{common:{getWidth(vt=v.DEFAULT_NOTATION_FONT_SCALE){return new S(this.code_head||"vb",vt).getMetrics().width},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:"vb"},h:{code_head:"v22"},m:{code_head:"v3e",stem_offset:-3},r:{code_head:"v7c",stem:!1,rest:!0,position:"B/4",dot_shiftY:-.5,line_above:1.5,line_below:1.5},s:{getWidth:()=>v.SLASH_NOTEHEAD_WIDTH,position:"B/4"}}},8:{common:{getWidth(vt=v.DEFAULT_NOTATION_FONT_SCALE){return new S(this.code_head||"vb",vt).getMetrics().width},stem:!0,stem_offset:0,flag:!0,beam_count:1,code_flag_upstem:"v54",code_flag_downstem:"v9a",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:"vb"},h:{code_head:"v22"},m:{code_head:"v3e"},r:{code_head:"va5",stem:!1,flag:!1,rest:!0,position:"B/4",dot_shiftY:-.5,line_above:1,line_below:1},s:{getWidth:()=>v.SLASH_NOTEHEAD_WIDTH,position:"B/4"}}},16:{common:{beam_count:2,getWidth(vt=v.DEFAULT_NOTATION_FONT_SCALE){return new S(this.code_head||"vb",vt).getMetrics().width},stem:!0,stem_offset:0,flag:!0,code_flag_upstem:"v3f",code_flag_downstem:"v8f",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:"vb"},h:{code_head:"v22"},m:{code_head:"v3e"},r:{code_head:"v3c",stem:!1,flag:!1,rest:!0,position:"B/4",dot_shiftY:-.5,line_above:1,line_below:2},s:{getWidth:()=>v.SLASH_NOTEHEAD_WIDTH,position:"B/4"}}},32:{common:{beam_count:3,getWidth(vt=v.DEFAULT_NOTATION_FONT_SCALE){return new S(this.code_head||"vb",vt).getMetrics().width},stem:!0,stem_offset:0,flag:!0,code_flag_upstem:"v47",code_flag_downstem:"v2a",stem_up_extension:9,stem_down_extension:9,tabnote_stem_up_extension:8,tabnote_stem_down_extension:5,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"vb"},h:{code_head:"v22"},m:{code_head:"v3e"},r:{code_head:"v55",stem:!1,flag:!1,rest:!0,position:"B/4",dot_shiftY:-1.5,line_above:2,line_below:2},s:{getWidth:()=>v.SLASH_NOTEHEAD_WIDTH,position:"B/4"}}},64:{common:{beam_count:4,getWidth(vt=v.DEFAULT_NOTATION_FONT_SCALE){return new S(this.code_head||"vb",vt).getMetrics().width},stem:!0,stem_offset:0,flag:!0,code_flag_upstem:"va9",code_flag_downstem:"v58",stem_up_extension:13,stem_down_extension:13,tabnote_stem_up_extension:12,tabnote_stem_down_extension:9,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"vb"},h:{code_head:"v22"},m:{code_head:"v3e"},r:{code_head:"v38",stem:!1,flag:!1,rest:!0,position:"B/4",dot_shiftY:-1.5,line_above:2,line_below:3},s:{getWidth:()=>v.SLASH_NOTEHEAD_WIDTH,position:"B/4"}}},128:{common:{beam_count:5,getWidth(vt=v.DEFAULT_NOTATION_FONT_SCALE){return new S(this.code_head||"vb",vt).getMetrics().width},stem:!0,stem_offset:0,flag:!0,code_flag_upstem:"v9b",code_flag_downstem:"v30",stem_up_extension:22,stem_down_extension:22,tabnote_stem_up_extension:21,tabnote_stem_down_extension:18,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"vb"},h:{code_head:"v22"},m:{code_head:"v3e"},r:{code_head:"vaa",stem:!1,flag:!1,rest:!0,position:"B/4",dot_shiftY:1.5,line_above:3,line_below:3},s:{getWidth:()=>v.SLASH_NOTEHEAD_WIDTH,position:"B/4"}}}},v.smufl={},v.smufl.to_code_points={bracketTop:"v1b",bracketBottom:"v10",barlineTick:"v6f",segno:"v8c",coda:"v4d",gClef:"v83",cClef:"vad",fClef:"v79",unpitchedPercussionClef1:"v59","6stringTabClef":"v2f",timeSig0:"v0",timeSig1:"v1",timeSig2:"v2",timeSig3:"v3",timeSig4:"v4",timeSig5:"v5",timeSig6:"v6",timeSig7:"v7",timeSig8:"v8",timeSig9:"v9",timeSigCommon:"v41",timeSigCutCommon:"vb6",noteheadDoubleWhole:"v53",noteheadWhole:"v1d",noteheadHalf:"v81",noteheadBlack:"vb",noteheadXWhole:"v92",noteheadXHalf:"v95",noteheadXBlack:"v3e",noteheadCircleX:"v3b",noteheadTriangleUpWhole:"v49",noteheadTriangleUpHalf:"v93",noteheadTriangleUpBlack:"v40",noteheadDiamondWhole:"v46",noteheadDiamondHalf:"v2d",noteheadDiamondBlack:"v22",augmentationDot:"v23",tremolo1:"v74",flag8thUp:"v54",flag8thDown:"v9a",flag16thUp:"v3f",flag16thDown:"v8f",flag32ndUp:"v47",flag32ndDown:"v2a",flag64thUp:"va9",flag64thDown:"v58",flag128thUp:"v9b",flag128thDown:"v30",accidentalFlat:"v44",accidentalNatural:"v4e",accidentalSharp:"v18",accidentalDoubleSharp:"v7f",accidentalDoubleFlat:"v26",accidentalParensLeft:"v9c",accidentalParensRight:"v84",accidentalQuarterToneFlatStein:"vab",accidentalThreeQuarterTonesFlatZimmermann:"v9e",accidentalQuarterToneSharpStein:"v78",accidentalThreeQuarterTonesSharpStein:"v51",accidentalBuyukMucennebFlat:"v39",accidentalBakiyeFlat:"vb7",accidentalKomaSharp:"v51",accidentalKucukMucennebSharp:"v8d",accidentalKoron:"vd1",accidentalSori:"vd0",articAccentAbove:"v42",articAccentBelow:"v42",articTenutoAbove:"v25",articTenutoBelow:"v25",articStaccatoAbove:"v23",articStaccatoBelow:"v23",articStaccatissimoAbove:"v28",articMarcatoAbove:"va",fermataAbove:"v43",fermataBelow:"v5b",breathMarkComma:"v6c",breathMarkUpbow:"v8a",caesura:"v34",caesuraCurved:"v4b",restMaxima:"v59",restDoubleWhole:"v31",restWhole:"v5c",restHalf:"vc",restQuarter:"v7c",rest8th:"va5",rest16th:"v3c",rest32nd:"v55",rest64th:"v38",rest128th:"vaa",dynamicPiano:"vbf",dynamicMezzo:"v62",dynamicForte:"vba",dynamicRinforzando:"vba",dynamicSforzando:"v4a",dynamicZ:"v80",ornamentTrill:"v1f",ornamentTurn:"v72",ornamentTurnSlash:"v33",ornamentMordent:"v45",ornamentMordentInverted:"v1e",ornamentTremblement:"v86",ornamentPrecompAppoggTrill:"v20",ornamentPrecompSlideTrillDAnglebert:"v60",ornamentPrecompSlideTrillBach:"v29",ornamentPrecompTrillSuffixDandrieu:"v6d",ornamentPrecompDoubleCadenceUpperPrefix:"vb4",ornamentPrecompDoubleCadenceUpperPrefixTurn:"v68",ornamentPrecompTrillLowerSuffix:"v2c",stringsDownBow:"v94",stringsUpBow:"v75",stringsHarmonic:"vb9",pluckedSnapPizzicatoAbove:"v94",pluckedLeftHandPizzicato:"v8b",keyboardPedalPed:"v36",keyboardPedalUp:"v5d",pictChokeCymbal:"vb3",wiggleArpeggiatoUp:"va3",arrowheadBlackUp:"vc3",arrowheadBlackDown:"v52"},v.TIME4_4={num_beats:4,beat_value:4,resolution:v.RESOLUTION};class w{static get WIDTH(){return 600}static get HEIGHT(){return 400}static get CANVAS_BROWSER_SIZE_LIMIT(){return 32767}static SanitizeCanvasDims(i,c){return Math.max(i,c)>this.CANVAS_BROWSER_SIZE_LIMIT&&(d.W("Canvas dimensions exceed browser limit. Cropping to "+this.CANVAS_BROWSER_SIZE_LIMIT),i>this.CANVAS_BROWSER_SIZE_LIMIT&&(i=this.CANVAS_BROWSER_SIZE_LIMIT),c>this.CANVAS_BROWSER_SIZE_LIMIT&&(c=this.CANVAS_BROWSER_SIZE_LIMIT)),[i,c]}constructor(i){this.vexFlowCanvasContext=i,i.canvas?this.canvas=i.canvas:this.canvas={width:w.WIDTH,height:w.HEIGHT}}clear(){this.vexFlowCanvasContext.clearRect(0,0,this.canvas.width,this.canvas.height)}openGroup(){}closeGroup(){}add(){}setFont(i,c,M){return this.vexFlowCanvasContext.font=(M||"")+" "+c+"pt "+i,this}setRawFont(i){return this.vexFlowCanvasContext.font=i,this}setFillStyle(i){return this.vexFlowCanvasContext.fillStyle=i,this}setBackgroundFillStyle(i){return this.background_fillStyle=i,this}setStrokeStyle(i){return this.vexFlowCanvasContext.strokeStyle=i,this}setShadowColor(i){return this.vexFlowCanvasContext.shadowColor=i,this}setShadowBlur(i){return this.vexFlowCanvasContext.shadowBlur=i,this}setLineWidth(i){return this.vexFlowCanvasContext.lineWidth=i,this}setLineCap(i){return this.vexFlowCanvasContext.lineCap=i,this}setLineDash(i){return this.vexFlowCanvasContext.lineDash=i,this}scale(i,c){return this.vexFlowCanvasContext.scale(parseFloat(i),parseFloat(c))}resize(i,c){return[i,c]=this.SanitizeCanvasDims(parseInt(i,10),parseInt(c,10)),this.vexFlowCanvasContext.resize(i,c)}rect(i,c,M,I){return this.vexFlowCanvasContext.rect(i,c,M,I)}fillRect(i,c,M,I){return this.vexFlowCanvasContext.fillRect(i,c,M,I)}clearRect(i,c,M,I){return this.vexFlowCanvasContext.clearRect(i,c,M,I)}beginPath(){return this.vexFlowCanvasContext.beginPath()}moveTo(i,c){return this.vexFlowCanvasContext.moveTo(i,c)}lineTo(i,c){return this.vexFlowCanvasContext.lineTo(i,c)}bezierCurveTo(i,c,M,I,V,X){return this.vexFlowCanvasContext.bezierCurveTo(i,c,M,I,V,X)}quadraticCurveTo(i,c,M,I){return this.vexFlowCanvasContext.quadraticCurveTo(i,c,M,I)}arc(i,c,M,I,V,X){return this.vexFlowCanvasContext.arc(i,c,M,I,V,X)}glow(){return this.vexFlowCanvasContext.glow()}fill(){return this.vexFlowCanvasContext.fill()}stroke(){return this.vexFlowCanvasContext.stroke()}closePath(){return this.vexFlowCanvasContext.closePath()}measureText(i){return this.vexFlowCanvasContext.measureText(i)}fillText(i,c,M){return this.vexFlowCanvasContext.fillText(i,c,M)}save(){return this.vexFlowCanvasContext.save()}restore(){return this.vexFlowCanvasContext.restore()}}class T{constructor(i){this.element=i,this.paper=Raphael(i),this.path="",this.pen={x:0,y:0},this.lineWidth=1,this.state={scale:{x:1,y:1},font_family:"Arial",font_size:8,font_weight:800},this.attributes={"stroke-width":.3,fill:"black",stroke:"black",font:"10pt Arial"},this.background_attributes={"stroke-width":0,fill:"white",stroke:"white",font:"10pt Arial"},this.shadow_attributes={width:0,color:"black"},this.state_stack=[]}openGroup(){}closeGroup(){}add(){}setFont(i,c,M){return this.state.font_family=i,this.state.font_size=c,this.state.font_weight=M,this.attributes.font=(this.state.font_weight||"")+" "+this.state.font_size*this.state.scale.x+"pt "+this.state.font_family,this}setRawFont(i){return this.attributes.font=i,this}setFillStyle(i){return this.attributes.fill=i,this}setBackgroundFillStyle(i){return this.background_attributes.fill=i,this.background_attributes.stroke=i,this}setStrokeStyle(i){return this.attributes.stroke=i,this}setShadowColor(i){return this.shadow_attributes.color=i,this}setShadowBlur(i){return this.shadow_attributes.width=i,this}setLineWidth(i){this.attributes["stroke-width"]=i,this.lineWidth=i}setLineDash(){return this}setLineCap(){return this}scale(i,c){return this.state.scale={x:i,y:c},this.attributes.transform="S"+i+","+c+",0,0",this.attributes.scale=i+","+c+",0,0",this.attributes.font=this.state.font_size*this.state.scale.x+"pt "+this.state.font_family,this.background_attributes.transform="S"+i+","+c+",0,0",this.background_attributes.font=this.state.font_size*this.state.scale.x+"pt "+this.state.font_family,this}clear(){this.paper.clear()}resize(i,c){return this.element.style.width=i,this.paper.setSize(i,c),this}setViewBox(i){this.paper.canvas.setAttribute("viewBox",i)}rect(i,c,M,I){return I<0&&(c+=I,I=-I),this.paper.rect(i,c,M-.5,I-.5).attr(this.attributes).attr("fill","none").attr("stroke-width",this.lineWidth),this}fillRect(i,c,M,I){return I<0&&(c+=I,I=-I),this.paper.rect(i,c,M-.5,I-.5).attr(this.attributes),this}clearRect(i,c,M,I){return I<0&&(c+=I,I=-I),this.paper.rect(i,c,M-.5,I-.5).attr(this.background_attributes),this}beginPath(){return this.path="",this.pen.x=0,this.pen.y=0,this}moveTo(i,c){return this.path+="M"+i+","+c,this.pen.x=i,this.pen.y=c,this}lineTo(i,c){return this.path+="L"+i+","+c,this.pen.x=i,this.pen.y=c,this}bezierCurveTo(i,c,M,I,V,X){return this.path+="C"+i+","+c+","+M+","+I+","+V+","+X,this.pen.x=V,this.pen.y=X,this}quadraticCurveTo(i,c,M,I){return this.path+="Q"+i+","+c+","+M+","+I,this.pen.x=M,this.pen.y=I,this}arc(i,c,M,I,V,X){function Z(ot){for(;ot<0;)ot+=2*Math.PI;for(;ot>2*Math.PI;)ot-=2*Math.PI;return ot}if((I=Z(I))>(V=Z(V))){const ot=I;I=V,V=ot,X=!X}const nt=V-I;return nt>Math.PI?(this.arcHelper(i,c,M,I,I+nt/2,X),this.arcHelper(i,c,M,I+nt/2,V,X)):this.arcHelper(i,c,M,I,V,X),this}arcHelper(i,c,M,I,V,X){const Z=i+M*Math.cos(I),nt=c+M*Math.sin(I),ot=i+M*Math.cos(V),ft=c+M*Math.sin(V);let pt=0,gt=0;X?(gt=1,V-IMath.PI&&(pt=1),this.path+="M"+Z+","+nt+",A"+M+","+M+",0,"+pt+","+gt+","+ot+","+ft+"M"+this.pen.x+","+this.pen.y}glow(){const i=this.paper.set();if(this.shadow_attributes.width>0){const c=this.shadow_attributes,M=c.width/2;for(let I=1;I<=M;I++)i.push(this.paper.path(this.path).attr({stroke:c.color,"stroke-linejoin":"round","stroke-linecap":"round","stroke-width":+(c.width/M*I).toFixed(3),opacity:+((c.opacity||.3)/M).toFixed(3),transform:this.attributes.transform,scale:this.attributes.scale}))}return i}fill(){const i=this.paper.path(this.path).attr(this.attributes).attr("stroke-width",0);return this.glow(i),this}stroke(){const i=this.lineWidth*(this.state.scale.x+this.state.scale.y)/2,c=this.paper.path(this.path).attr(this.attributes).attr("fill","none").attr("stroke-width",i);return this.glow(c),this}closePath(){return this.path+="Z",this}measureText(i){const c=this.paper.text(0,0,i).attr(this.attributes).attr("fill","none").attr("stroke","none"),M=c.getBBox();return c.remove(),{width:M.width,height:M.height}}fillText(i,c,M){return this.paper.text(c+this.measureText(i).width/2,M-this.state.font_size/(2.25*this.state.scale.y),i).attr(this.attributes),this}save(){return this.state_stack.push({state:{font_family:this.state.font_family},attributes:{font:this.attributes.font,fill:this.attributes.fill,stroke:this.attributes.stroke,"stroke-width":this.attributes["stroke-width"]},shadow_attributes:{width:this.shadow_attributes.width,color:this.shadow_attributes.color}}),this}restore(){const i=this.state_stack.pop();return this.state.font_family=i.state.font_family,this.attributes.font=i.attributes.font,this.attributes.fill=i.attributes.fill,this.attributes.stroke=i.attributes.stroke,this.attributes["stroke-width"]=i.attributes["stroke-width"],this.shadow_attributes.width=i.shadow_attributes.width,this.shadow_attributes.color=i.shadow_attributes.color,this}}const g={path:{x:!0,y:!0,width:!0,height:!0},rect:{},text:{width:!0,height:!0}};{const vt={"font-family":!0,"font-weight":!0,"font-style":!0,"font-size":!0};d.Merge(g.rect,vt),d.Merge(g.path,vt)}class x{constructor(i){this.element=i,this.svgNS="http://www.w3.org/2000/svg";const c=this.create("svg");this.element.appendChild(c),this.svg=c,this.groups=[this.svg],this.parent=this.svg,this.path="",this.pen={x:NaN,y:NaN},this.lineWidth=1,this.state={scale:{x:1,y:1},"font-family":"Arial","font-size":"8pt","font-weight":"normal"},this.attributes={"stroke-width":.3,fill:"black",stroke:"black","stroke-dasharray":"none","font-family":"Arial","font-size":"10pt","font-weight":"normal","font-style":"normal"},this.background_attributes={"stroke-width":0,fill:"white",stroke:"white","stroke-dasharray":"none","font-family":"Arial","font-size":"10pt","font-weight":"normal","font-style":"normal"},this.shadow_attributes={width:0,color:"black"},this.state_stack=[],this.iePolyfill()}create(i){return document.createElementNS(this.svgNS,i)}openGroup(i,c,M){const I=this.create("g");return this.groups.push(I),this.parent.appendChild(I),this.parent=I,i&&I.setAttribute("class",d.Prefix(i)),c&&I.setAttribute("id",d.Prefix(c)),M&&M.pointerBBox&&I.setAttribute("pointer-events","bounding-box"),I}closeGroup(){this.groups.pop(),this.parent=this.groups[this.groups.length-1]}add(i){this.parent.appendChild(i)}iePolyfill(){typeof navigator<"u"&&(this.ie=/MSIE 9/i.test(navigator.userAgent)||/MSIE 10/i.test(navigator.userAgent)||/rv:11\.0/i.test(navigator.userAgent)||/Trident/i.test(navigator.userAgent))}setFont(i,c,M){let I=!1,V=!1,X="normal";typeof M=="string"&&(M.indexOf("italic")!==-1&&(M=M.replace(/italic/g,""),V=!0),M.indexOf("bold")!==-1&&(M=M.replace(/bold/g,""),I=!0),M=M.replace(/ /g,"")),X=V?"italic":X;const Z={"font-family":i,"font-size":c+"pt","font-weight":M=(M=I?"bold":M)===void 0||M===""?"normal":M,"font-style":X};return this.fontSize=Number(c),d.Merge(this.attributes,Z),d.Merge(this.state,Z),this}setRawFont(i){const c=(i=i.trim()).split(" ");return this.attributes["font-family"]=c[1],this.state["font-family"]=c[1],this.attributes["font-size"]=c[0],this.state["font-size"]=c[0],this.fontSize=Number(c[0].match(/\d+/)),this}setFillStyle(i){return this.attributes.fill=i,this}setBackgroundFillStyle(i){return this.background_attributes.fill=i,this.background_attributes.stroke=i,this}setStrokeStyle(i){return this.attributes.stroke=i,this}setShadowColor(i){return this.shadow_attributes.color=i,this}setShadowBlur(i){return this.shadow_attributes.width=i,this}setLineWidth(i){this.attributes["stroke-width"]=i,this.lineWidth=i}setLineDash(i){if(Object.prototype.toString.call(i)==="[object Array]")return i=i.join(", "),this.attributes["stroke-dasharray"]=i,this;throw new d.RERR("ArgumentError","lineDash must be an array of integers.")}setLineCap(i){return this.attributes["stroke-linecap"]=i,this}resize(i,c){this.width=i,this.height=c,this.element.style.width=i;const M={width:i,height:c};return this.applyAttributes(this.svg,M),this.scale(this.state.scale.x,this.state.scale.y),this}scale(i,c){this.state.scale={x:i,y:c};const M=this.width/i,I=this.height/c;return this.setViewBox(0,0,M,I),this}setViewBox(...i){if(i.length===1){const[c]=i;this.svg.setAttribute("viewBox",c)}else{const[c,M,I,V]=i,X=c+" "+M+" "+I+" "+V;this.svg.setAttribute("viewBox",X)}}applyAttributes(i,c){const M=g[i.nodeName];return Object.keys(c).forEach(I=>{M&&M[I]||i.setAttributeNS(null,I,c[I])}),i}clear(){for(;this.svg.lastChild;)this.svg.removeChild(this.svg.lastChild);this.scale(this.state.scale.x,this.state.scale.y)}rect(i,c,M,I,V){I<0&&(c+=I,I*=-1);const X=this.create("rect");return V===void 0&&(V={fill:"none","stroke-width":this.lineWidth,stroke:this.attributes.stroke}),d.Merge(V,{x:i,y:c,width:M,height:I}),this.applyAttributes(X,V),this.add(X),this}fillRect(i,c,M,I){return I<0&&(c+=I,I*=-1),this.rect(i,c,M,I,this.attributes),this}clearRect(i,c,M,I){return this.rect(i,c,M,I,this.background_attributes),this}beginPath(){return this.path="",this.pen.x=NaN,this.pen.y=NaN,this}moveTo(i,c){return this.path+="M"+i+" "+c,this.pen.x=i,this.pen.y=c,this}lineTo(i,c){return this.path+="L"+i+" "+c,this.pen.x=i,this.pen.y=c,this}bezierCurveTo(i,c,M,I,V,X){return this.path+="C"+i+" "+c+","+M+" "+I+","+V+" "+X,this.pen.x=V,this.pen.y=X,this}quadraticCurveTo(i,c,M,I){return this.path+="Q"+i+" "+c+","+M+" "+I,this.pen.x=M,this.pen.y=I,this}arc(i,c,M,I,V,X){function Z(ot){for(;ot<0;)ot+=2*Math.PI;for(;ot>2*Math.PI;)ot-=2*Math.PI;return ot}if((I=Z(I))>(V=Z(V))){const ot=I;I=V,V=ot,X=!X}const nt=V-I;return nt>Math.PI?(this.arcHelper(i,c,M,I,I+nt/2,X),this.arcHelper(i,c,M,I+nt/2,V,X)):this.arcHelper(i,c,M,I,V,X),this}arcHelper(i,c,M,I,V,X){const Z=i+M*Math.cos(I),nt=c+M*Math.sin(I),ot=i+M*Math.cos(V),ft=c+M*Math.sin(V);let pt=0,gt=0;X?(gt=1,V-IMath.PI&&(pt=1),this.path+="M"+Z+" "+nt+" A"+M+" "+M+" 0 "+pt+" "+gt+" "+ot+" "+ft,isNaN(this.pen.x)||isNaN(this.pen.y)||(this.peth+="M"+this.pen.x+" "+this.pen.y)}closePath(){return this.path+="Z",this}glow(){if(this.shadow_attributes.width>0){const i=this.shadow_attributes,c=i.width/2;for(let M=1;M<=c;M++){const I={stroke:i.color,"stroke-linejoin":"round","stroke-linecap":"round","stroke-width":+(.4*i.width/c*M).toFixed(3),opacity:+((i.opacity||.3)/c).toFixed(3)},V=this.create("path");I.d=this.path,this.applyAttributes(V,I),this.add(V)}}return this}fill(i){this.glow();const c=this.create("path");let M=i;return i===void 0?(d.Merge(i={},this.attributes),i.stroke="none",M=i):(M=i,d.Merge(M,this.attributes),i.class&&(M.class=i.class),i.id&&(M.id=i.id)),i.d=this.path,this.applyAttributes(c,i),this.add(c),this}stroke(i=void 0){this.glow();const c=this.create("path"),M={};return d.Merge(M,this.attributes),i&&d.Merge(M,i),M.fill="none",M["stroke-width"]=this.lineWidth,M.d=this.path,this.applyAttributes(c,M),this.add(c),this}measureText(i){const c=this.create("text");if(typeof c.getBBox!="function")return{x:0,y:0,width:0,height:0};c.textContent=i,this.applyAttributes(c,this.attributes),this.svg.appendChild(c);let M=c.getBBox();return this.ie&&i!==""&&this.attributes["font-style"]==="italic"&&(M=this.ieMeasureTextFix(M,i)),this.svg.removeChild(c),M}ieMeasureTextFix(i){const c=1.196*Number(this.fontSize)+1.9598,M=i.width-c,I=i.height-1.5;return{x:i.x,y:i.y,width:M,height:I}}fillText(i,c,M){if(!i||i.length<=0)return;const I={};d.Merge(I,this.attributes),I.stroke="none",I.x=c,I.y=M;const V=this.create("text");V.textContent=i,this.applyAttributes(V,I),this.add(V)}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 i=this.state_stack.pop();return this.state["font-family"]=i.state["font-family"],this.state["font-weight"]=i.state["font-weight"],this.state["font-style"]=i.state["font-style"],this.state["font-size"]=i.state["font-size"],this.state.scale=i.state.scale,this.attributes["font-family"]=i.attributes["font-family"],this.attributes["font-weight"]=i.attributes["font-weight"],this.attributes["font-style"]=i.attributes["font-style"],this.attributes["font-size"]=i.attributes["font-size"],this.attributes.fill=i.attributes.fill,this.attributes.stroke=i.attributes.stroke,this.attributes["stroke-width"]=i.attributes["stroke-width"],this.attributes["stroke-dasharray"]=i.attributes["stroke-dasharray"],this.shadow_attributes.width=i.shadow_attributes.width,this.shadow_attributes.color=i.shadow_attributes.color,this.lineWidth=i.lineWidth,this}}let P=null;class _{static get Backends(){return{CANVAS:1,RAPHAEL:2,SVG:3,VML:4}}static get LineEndType(){return{NONE:1,UP:2,DOWN:3}}static get USE_CANVAS_PROXY(){return!1}static get lastContext(){return P}static set lastContext(i){P=i}static buildContext(i,c,M,I,V){const X=new _(i,c);M&&I&&X.resize(M,I),V||(V="#FFF");const Z=X.getContext();return Z.setBackgroundFillStyle(V),_.lastContext=Z,Z}static getCanvasContext(i,c,M,I){return _.buildContext(i,_.Backends.CANVAS,c,M,I)}static getRaphaelContext(i,c,M,I){return _.buildContext(i,_.Backends.RAPHAEL,c,M,I)}static getSVGContext(i,c,M,I){return _.buildContext(i,_.Backends.SVG,c,M,I)}static bolsterCanvasContext(i){return _.USE_CANVAS_PROXY?new w(i):(i.vexFlowCanvasContext=i,["clear","setFont","setRawFont","setFillStyle","setBackgroundFillStyle","setStrokeStyle","setShadowColor","setShadowBlur","setLineWidth","setLineCap","setLineDash","openGroup","closeGroup","getGroup"].forEach(c=>{i[c]=i[c]||w.prototype[c]}),i)}static drawDashedLine(i,c,M,I,V,X){i.beginPath();const Z=I-c,nt=V-M,ot=Math.atan2(nt,Z);let ft=c,pt=M;i.moveTo(c,M);let gt=0,bt=!0;for(;!(Z<0?ft<=I:ft>=I)||!(nt<0?pt<=V:pt>=V);){const Mt=X[gt++%X.length],_t=ft+Math.cos(ot)*Mt;ft=Z<0?Math.max(I,_t):Math.min(I,_t);const Tt=pt+Math.sin(ot)*Mt;pt=nt<0?Math.max(V,Tt):Math.min(V,Tt),bt?i.lineTo(ft,pt):i.moveTo(ft,pt),bt=!bt}i.closePath(),i.stroke()}constructor(i,c){if(this.elementId=i,!this.elementId)throw new d.RERR("BadArgument","Invalid id for renderer.");if(this.element=document.getElementById(i),this.element||(this.element=i),this.ctx=null,this.paper=null,this.backend=c,this.backend===_.Backends.CANVAS){if(!this.element.getContext)throw new d.RERR("BadElement",`Can't get canvas context from element: ${i}`);this.ctx=_.bolsterCanvasContext(this.element.getContext("2d",{willReadFrequently:!0}))}else if(this.backend===_.Backends.RAPHAEL)this.ctx=new T(this.element);else{if(this.backend!==_.Backends.SVG)throw new d.RERR("InvalidBackend",`No support for backend: ${this.backend}`);this.ctx=new x(this.element)}}resize(i,c){if(this.backend===_.Backends.CANVAS){if(!this.element.getContext)throw new d.RERR("BadElement",`Can't get canvas context from element: ${this.elementId}`);[i,c]=w.SanitizeCanvasDims(i,c);const M=window.devicePixelRatio||1;this.element.width=i*M,this.element.height=c*M,this.element.style.width=i+"px",this.element.style.height=c+"px",this.ctx=_.bolsterCanvasContext(this.element.getContext("2d",{willReadFrequently:!0})),this.ctx.scale(M,M)}else this.ctx.resize(i,c);return this}getContext(){return this.ctx}}class B extends h{static get CATEGORY(){return"stem"}static get UP(){return 1}static get DOWN(){return-1}static get WIDTH(){return v.STEM_WIDTH}static get HEIGHT(){return v.STEM_HEIGHT}constructor(i={}){super(),this.setAttribute("type","Stem"),this.x_begin=i.x_begin||0,this.x_end=i.x_end||0,this.y_top=i.y_top||0,this.y_bottom=i.y_bottom||0,this.stem_extension=i.stem_extension||0,this.stem_direction=i.stem_direction||0,this.hide=i.hide||!1,this.isStemlet=i.isStemlet||!1,this.stemletHeight=i.stemletHeight||0,this.renderHeightAdjustment=0,this.setOptions(i)}setOptions(i){this.stem_up_y_offset=i.stem_up_y_offset||0,this.stem_down_y_offset=i.stem_down_y_offset||0}setNoteHeadXBounds(i,c){return this.x_begin=i,this.x_end=c,this}setDirection(i){this.stem_direction=i}setExtension(i){this.stem_extension=i}getExtension(){return this.stem_extension}setYBounds(i,c){this.y_top=i,this.y_bottom=c}getCategory(){return B.CATEGORY}getHeight(){const i=this.stem_direction===B.UP?this.stem_up_y_offset:this.stem_down_y_offset;return(this.y_bottom-this.y_top)*this.stem_direction+(B.HEIGHT-i+this.stem_extension)*this.stem_direction}getBoundingBox(){throw new d.RERR("NotImplemented","getBoundingBox() not implemented.")}getExtents(){const i=this.stem_direction===B.UP,c=[this.y_top,this.y_bottom],M=B.HEIGHT+this.stem_extension,I=(i?Math.min:Math.max)(...c),V=(i?Math.max:Math.min)(...c);return{topY:I+M*-this.stem_direction,baseY:V}}setVisibility(i){return this.hide=!i,this}setStemlet(i,c){return this.isStemlet=i,this.stemletHeight=c,this}draw(){if(this.setRendered(),this.hide)return;const i=this.checkContext();let c,M;const I=this.stem_direction;I===B.DOWN?(c=this.x_begin,M=this.y_top+this.stem_down_y_offset):(c=this.x_end,M=this.y_bottom-this.stem_up_y_offset);const V=this.getHeight();(function(...Z){B.DEBUG&&d.L("Vex.Flow.Stem",Z)})("Rendering stem - ","Top Y: ",this.y_top,"Bottom Y: ",this.y_bottom);const X=this.isStemlet?V-this.stemletHeight*this.stem_direction:0;if(i.save(),this.applyStyle(i),i.beginPath(),i.setLineWidth(B.WIDTH),i.moveTo(c,M-X),i.lineTo(c,M-V-this.renderHeightAdjustment*I),i.svg){const Z={class:d.Prefix("stem")};this.id&&(Z.id=this.id),i.stroke(Z)}else i.stroke();this.restoreStyle(i),i.restore()}}class k extends h{static get LOCATION_TOP(){return 1}static get LOCATION_BOTTOM(){return-1}static get NESTING_OFFSET(){return 15}constructor(i,c){if(super(),this.setAttribute("type","Tuplet"),!i||!i.length)throw new d.RuntimeError("BadArguments","No notes provided for tuplet.");this.options=d.Merge({},c),this.notes=i,this.num_notes="num_notes"in this.options?this.options.num_notes:i.length,this.options.beats_occupied&&this.beatsOccupiedDeprecationWarning(),this.notes_occupied=this.options.notes_occupied||this.options.beats_occupied||2,"bracketed"in this.options?this.bracketed=this.options.bracketed:this.bracketed=i.some(M=>M.beam===null),this.ratioed="ratioed"in this.options?this.options.ratioed:Math.abs(this.notes_occupied-this.num_notes)>1,this.point=28,this.y_pos=16,this.x_pos=100,this.width=200,this.location=this.options.location||k.LOCATION_TOP,te.AlignRestsToNotes(i,!0,!0),this.resolveGlyphs(),this.attach()}attach(){for(let i=0;i=1;)this.numerator_glyphs.unshift(new S("v"+i%10,this.point)),i=parseInt(i/10,10);for(this.denom_glyphs=[],i=this.notes_occupied;i>=1;)this.denom_glyphs.unshift(new S("v"+i%10,this.point)),i=parseInt(i/10,10)}getNestedTupletCount(){const i=this.location,c=this.notes[0];let M=V(c,i),I=V(c,i);function V(X,Z){return X.tupletStack.filter(nt=>nt.location===Z).length}return this.notes.forEach(X=>{const Z=V(X,i);M=Z>M?Z:M,I=ZI&&(I=X)}}return I+i+c}draw(){this.checkContext(),this.setRendered();const i=this.notes[0],c=this.notes[this.notes.length-1];this.bracketed?(this.x_pos=i.getTieLeftX()-5,this.width=c.getTieRightX()-this.x_pos+5):(this.x_pos=i.getStemX(),this.width=c.getStemX()-this.x_pos),this.y_pos=this.getYPosition();const M=(Z,nt)=>Z+nt.getMetrics().width;let I=this.numerator_glyphs.reduce(M,0);this.ratioed&&(I=this.denom_glyphs.reduce(M,I),I+=.32*this.point);const V=this.x_pos+this.width/2-I/2;if(this.bracketed){const Z=this.width/2-I/2-5;Z>0&&(this.context.fillRect(this.x_pos,this.y_pos,Z,1),this.context.fillRect(this.x_pos+this.width/2+I/2+5,this.y_pos,Z,1),this.context.fillRect(this.x_pos,this.y_pos+(this.location===k.LOCATION_BOTTOM),1,10*this.location),this.context.fillRect(this.x_pos+this.width,this.y_pos+(this.location===k.LOCATION_BOTTOM),1,10*this.location))}let X=0;if(this.RenderTupletNumber!==!1&&this.numerator_glyphs.forEach(Z=>{Z.render(this.context,V+X,this.y_pos+this.point/3-2),X+=Z.getMetrics().width}),this.ratioed){const Z=V+X+.16*this.point,nt=.06*this.point;this.context.beginPath(),this.context.arc(Z,this.y_pos-.08*this.point,nt,0,2*Math.PI,!0),this.context.closePath(),this.context.fill(),this.context.beginPath(),this.context.arc(Z,this.y_pos+.12*this.point,nt,0,2*Math.PI,!0),this.context.closePath(),this.context.fill(),X+=.32*this.point,this.denom_glyphs.forEach(ot=>{ot.render(this.context,V+X,this.y_pos+this.point/3-2),X+=ot.getMetrics().width})}}}function R(vt){let i=0;return vt.forEach(c=>{c.keyProps&&c.keyProps.forEach(M=>{i+=M.line-3})}),i>=0?B.DOWN:B.UP}const F="L",A="B";class G extends h{static getDefaultBeamGroups(i){i&&i!=="c"||(i="4/4");const c={"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"]}[i];if(c!==void 0)return c.map(M=>new l().parse(M));{const M=parseInt(i.split("/")[0],10),I=parseInt(i.split("/")[1],10);if(M%3==0)return[new l(3,I)];if(I>4)return[new l(2,I)];if(I<=4)return[new l(1,I)]}return[new l(1,4)]}static applyAndGetBeams(i,c,M){return G.generateBeams(i.getTickables(),{groups:M,stem_direction:c})}static generateBeams(i,c){c||(c={}),c.groups&&c.groups.length||(c.groups=[new l(2,8)]);const M=c.groups.map(gt=>{if(!gt.multiply)throw new d.RuntimeError("InvalidBeamGroups","The beam groups must be an array of Vex.Flow.Fractions");return gt.clone().multiply(v.RESOLUTION,1)}),I=i;let V=0,X=[],Z=[];function nt(){M.length-1>V?V+=1:V=0}(function(){let gt=[];I.forEach(bt=>{if(gt=[],bt.shouldIgnoreTicks())return X.push(Z),void(Z=gt);Z.push(bt);const Mt=M[V].clone(),_t=Z.reduce((Ft,Zt)=>Zt.getTicks().clone().add(Ft),new l(0,1)),Tt=v.durationToNumber(bt.duration)<8;Tt&&bt.tuplet&&(Mt.numerator*=2),_t.greaterThan(Mt)?(Tt||gt.push(Z.pop()),X.push(Z),Z=gt,nt()):_t.equals(Mt)&&(X.push(Z),Z=gt,nt())}),Z.length>0&&X.push(Z)})(),(function(){const gt=[];X.forEach(bt=>{let Mt=[];bt.forEach((_t,Tt,Ft)=>{const Zt=Tt===0||Tt===Ft.length-1,Yt=Ft[Tt-1],ee=!c.beam_rests&&_t.isRest(),ne=c.beam_rests&&c.beam_middle_only&&_t.isRest()&&Zt;let he=!1;if(c.maintain_stem_directions&&Yt&&!_t.isRest()&&!Yt.isRest()){const Le=Yt.getStemDirection();he=_t.getStemDirection()!==Le}const me=parseInt(_t.duration,10)<8;ee||ne||he||me?(Mt.length>0&>.push(Mt),Mt=he?[_t]:[]):Mt.push(_t)}),Mt.length>0&>.push(Mt)}),X=gt})(),X.forEach(gt=>{let bt;if(c.maintain_stem_directions){const Mt=(function(_t){for(let Tt=0;Tt<_t.length;Tt++){const Ft=_t[Tt];if(!Ft.isRest())return Ft}return!1})(gt);bt=Mt?Mt.getStemDirection():B.UP}else bt=c.stem_direction?c.stem_direction:R(gt);(function(Mt,_t){Mt.forEach(Tt=>{Tt.setStemDirection(_t)})})(gt,bt)});const ot=X.filter(gt=>{if(gt.length>1){let bt=!0;return gt.forEach(Mt=>{Mt.getIntrinsicTicks()>=v.durationToTicks("4")&&(bt=!1)}),bt}return!1}),ft=(function(){const gt=[];return X.forEach(bt=>{let Mt=null;bt.forEach(_t=>{_t.tuplet&&Mt!==_t.tuplet&&(Mt=_t.tuplet,gt.push(Mt))})}),gt})(),pt=[];return ot.forEach(gt=>{const bt=new G(gt);c.show_stemlets&&(bt.render_options.show_stemlets=!0),c.secondary_breaks&&(bt.render_options.secondary_break_ticks=v.durationToTicks(c.secondary_breaks)),c.flat_beams===!0&&(bt.render_options.flat_beams=!0,bt.render_options.flat_beam_offset=c.flat_beam_offset),pt.push(bt)}),ft.forEach(gt=>{const bt=gt.notes[0].stem_direction===B.DOWN?k.LOCATION_BOTTOM:k.LOCATION_TOP;gt.setTupletLocation(bt);let Mt=!1;for(let _t=0;_t=v.durationToTicks("4"))throw new d.RuntimeError("BadArguments","Beams can only be applied to notes shorter than a quarter note.");let M,I;for(this.stem_direction=B.UP,M=0;MZ+nt.stem_direction,0)>-1?B.UP:B.DOWN),M=0;Mi.getGlyph().beam_count).reduce((i,c)=>c>i?c:i)}breakSecondaryAt(i){return this.break_on_indices=i,this}getSlopeY(i,c,M,I){return M+(i-c)*I}calculateSlope(){const{notes:i,stem_direction:c,render_options:{max_slope:M,min_slope:I,slope_iterations:V,slope_cost:X}}=this,Z=i[0],nt=((bt,Mt)=>{const _t=bt.getStemExtents().topY,Tt=bt.getStemX();return(Mt.getStemExtents().topY-_t)/(Mt.getStemX()-Tt)})(Z,i[i.length-1]),ot=(M-I)/V;let ft=Number.MAX_VALUE,pt=0,gt=0;for(let bt=I;bt<=M;bt+=ot){let Mt=0,_t=0;for(let Zt=1;Zt_t)&&(ot=_t,Z=Math.min(...Mt.getYs()),nt=Mt.getBeamCount())}let ft=X/i.length;const pt=I+nt*(1.5*M),gt=Z+pt*-c;c===B.DOWN&&ftgt&&(ft=Z-pt),V+this.render_options.flat_beam_offset_per_beam>0?(c===B.DOWN&&ft>V&&!this.render_options.flat_beams||c===B.UP&&ft0){let c=this.render_options.flat_beam_offset;this.render_options.flat_beam_offset_per_beam&&(c+=this.render_options.flat_beam_offset_per_beam*this.getBeamCount());let M=this.notes[0].note_heads[0].y;const I=this.stem_direction>0?Math.min:Math.max;for(const V of this.notes)for(const X of V.note_heads)M=I(M,X.y);i=M+c*-this.stem_direction}return i}applyStemExtensions(){const{notes:i,slope:c,y_shift:M,stem_direction:I,beam_count:V,render_options:{show_stemlets:X,stemlet_extension:Z,beam_width:nt}}=this,ot=i[0],ft=this.getBeamYToDraw(),pt=ot.getStemX();for(let gt=0;gt=8&&(gt=this.break_on_indices.indexOf(ft)!==-1,this.render_options.secondary_break_ticks&&nt>=this.render_options.secondary_break_ticks&&(nt=0,gt=!0));const bt=pt.getIntrinsicTicks(){i.getStem()&&(this.context.openGroup("stem",i.getAttribute("id")+"-stem"),i.getStem().setContext(this.context).draw(),this.context.closeGroup())},this)}drawBeamLines(){this.checkContext();const i=["4","8","16","32","64"],c=this.notes[0];let M=this.getBeamYToDraw();const I=c.getStemX(),V=this.render_options.beam_width*this.stem_direction,X={};for(const Z of this.notes)X[Z.getAttribute("id")]=0;for(let Z=0;Z{i.getStave()||i.setStave(this.stave)}),this.preFormatted=!0),this}draw(i=this.context,c=this.stave){this.setRendered();let M=null;for(let I=0;I0&&M){const X=V.getBoundingBox();X&&M.mergeWith(X)}V.setContext(i),V.drawWithStyle()}this.boundingBox=M}}function C(vt,i,c,M,I){if(i!==z.type.BOLD_DOUBLE_LEFT&&i!==z.type.BOLD_DOUBLE_RIGHT)throw new d.RERR("InvalidConnector","A REPEAT_BEGIN or REPEAT_END type must be provided.");let V=3,X=3.5;i===z.type.BOLD_DOUBLE_RIGHT&&(V=-5,X=3),vt.fillRect(c+V,M,1,I-M),vt.fillRect(c-2,M,X,I-M)}class z extends h{static get type(){return{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}}static get typeString(){return{singleRight:z.type.SINGLE_RIGHT,singleLeft:z.type.SINGLE_LEFT,single:z.type.SINGLE,double:z.type.DOUBLE,brace:z.type.BRACE,bracket:z.type.BRACKET,boldDoubleLeft:z.type.BOLD_DOUBLE_LEFT,boldDoubleRight:z.type.BOLD_DOUBLE_RIGHT,thinDouble:z.type.THIN_DOUBLE,none:z.type.NONE}}constructor(i,c){super(),this.setAttribute("type","StaveConnector"),this.thickness=v.STAVE_LINE_THICKNESS,this.width=3,this.top_stave=i,this.bottom_stave=c,this.type=z.type.DOUBLE,this.font={family:"times",size:16,weight:"normal"},this.x_shift=0,this.texts=[]}setType(i){return(i=typeof i=="string"?z.typeString[i]:i)>=z.type.SINGLE_RIGHT&&i<=z.type.NONE&&(this.type=i),this}setText(i,c){return this.texts.push({content:i,options:d.Merge({shift_x:0,shift_y:0},c)}),this}setFont(i){d.Merge(this.font,i)}setXShift(i){if(typeof i!="number")throw d.RERR("InvalidType","x_shift must be a Number");return this.x_shift=i,this}draw(){const i=this.checkContext();this.setRendered();let c=this.top_stave.getYForLine(0),M=this.bottom_stave.getYForLine(this.bottom_stave.getNumLines()-1)+this.thickness,I=this.width,V=this.top_stave.getX();(this.type===z.type.SINGLE_RIGHT||this.type===z.type.BOLD_DOUBLE_RIGHT||this.type===z.type.THIN_DOUBLE)&&(V=this.top_stave.getX()+this.top_stave.width);let X=M-c;switch(this.type){case z.type.SINGLE:case z.type.SINGLE_LEFT:case z.type.SINGLE_RIGHT:I=1;break;case z.type.DOUBLE:V-=this.width+2;break;case z.type.BRACE:{I=12;const Z=this.top_stave.getX()-2+this.x_shift,nt=c,ot=Z,ft=M,pt=Z-I,gt=nt+X/2,bt=pt-.9*I,Mt=nt+.2*X,_t=Z+1.1*I,Tt=gt-.135*X,Ft=_t,Zt=gt+.135*X,Yt=bt,ee=ft-.2*X,ne=pt-I,he=ee,me=Z+.4*I,Le=gt+.135*X,Ee=me,vi=gt-.135*X,ri=ne,je=Mt;i.beginPath(),i.moveTo(Z,nt),i.bezierCurveTo(bt,Mt,_t,Tt,pt,gt),i.bezierCurveTo(Ft,Zt,Yt,ee,ot,ft),i.bezierCurveTo(ne,he,me,Le,pt,gt),i.bezierCurveTo(Ee,vi,ri,je,Z,nt),i.fill(),i.stroke();break}case z.type.BRACKET:c-=4,M+=4,X=M-c,S.renderGlyph(i,V-5,c-3,40,"v1b",!0),S.renderGlyph(i,V-5,M+3,40,"v10",!0),V-=this.width+2;break;case z.type.BOLD_DOUBLE_LEFT:C(i,this.type,V+this.x_shift,c,M);break;case z.type.BOLD_DOUBLE_RIGHT:C(i,this.type,V,c,M);break;case z.type.THIN_DOUBLE:I=1;break;case z.type.NONE:break;default:throw new d.RERR("InvalidType",`The provided StaveConnector.type (${this.type}) is invalid`)}this.type!==z.type.BRACE&&this.type!==z.type.BOLD_DOUBLE_LEFT&&this.type!==z.type.BOLD_DOUBLE_RIGHT&&this.type!==z.type.NONE&&i.fillRect(V,c,I,X),this.type===z.type.THIN_DOUBLE&&i.fillRect(V-3,c,I,X),i.save(),i.lineWidth=2,i.setFont(this.font.family,this.font.size,this.font.weight);for(let Z=0;Z0){const Tt=_t.space.deviation,Ft=Tt>=0?"+":"";i.setFillStyle("red"),i.fillText(Ft+Math.round(Tt),Z+c.getXShift(),M-10)}i.restore()}constructor(i){if(super(),this.setAttribute("type","Note"),!i)throw new d.RuntimeError("BadArguments","Note must have valid initialization data to identify duration and type.");const c=v.parseNoteStruct(i);if(!c)throw new d.RuntimeError("BadArguments",`Invalid note initialization object: ${JSON.stringify(i)}`);if(this.duration=c.duration,this.dots=c.dots,this.noteType=c.type,this.customTypes=c.customTypes,i.duration_override?this.setDuration(i.duration_override):this.setIntrinsicTicks(c.ticks),this.modifiers=[],this.glyph=v.getGlyphProps(this.duration,this.noteType),this.customGlyphs=this.customTypes.map(M=>v.getGlyphProps(this.duration,M)),this.positions&&(typeof this.positions!="object"||!this.positions.length))throw new d.RuntimeError("BadArguments","Note keys must be array type.");this.playNote=null,this.tickContext=null,this.modifierContext=null,this.ignore_ticks=!1,this.width=0,this.extraLeftPx=0,this.extraRightPx=0,this.x_shift=0,this.left_modPx=0,this.right_modPx=0,this.voice=null,this.preFormatted=!1,this.ys=[],i.align_center&&this.setCenterAlignment(i.align_center),this.stave=null,this.render_options={annotation_spacing:5,stave_padding:$.STAVEPADDING}}getPlayNote(){return this.playNote}setPlayNote(i){return this.playNote=i,this}isRest(){return!1}addStroke(i,c){return c.setNote(this),c.setIndex(i),this.modifiers.push(c),this.setPreFormatted(!1),this}getStave(){return this.stave}setStave(i){return this.stave=i,this.setYs([i.getYForLine(0)]),this.context=this.stave.context,this}getCategory(){return $.CATEGORY}setContext(i){return this.context=i,this}getExtraLeftPx(){return this.extraLeftPx}getExtraRightPx(){return this.extraRightPx}setExtraLeftPx(i){return this.extraLeftPx=i,this}setExtraRightPx(i){return this.extraRightPx=i,this}shouldIgnoreTicks(){return this.ignore_ticks}getLineNumber(){return 0}getLineForRest(){return 0}getGlyph(){return this.glyph}getGlyphWidth(){return this.glyph.getWidth(this.render_options.glyph_font_scale)}setYs(i){return this.ys=i,this}getYs(){if(this.ys.length===0)throw new d.RERR("NoYValues","No Y-values calculated for this note.");return this.ys}getYForTopText(i){if(!this.stave)throw new d.RERR("NoStave","No stave attached to this note.");return this.stave.getYForTopText(i)}getBoundingBox(){return null}getVoice(){if(!this.voice)throw new d.RERR("NoVoice","Note has no voice.");return this.voice}setVoice(i){return this.voice=i,this.preFormatted=!1,this}getTickContext(){return this.tickContext}setTickContext(i){return this.tickContext=i,this.preFormatted=!1,this}getDuration(){return this.duration}isDotted(){return this.dots>0}hasStem(){return!1}getDots(){return this.dots}getNoteType(){return this.noteType}setBeam(){return this}setModifierContext(i){return this.modifierContext=i,this}addModifier(i,c=0){return i.setNote(this),i.setIndex(c),this.modifiers.push(i),this.setPreFormatted(!1),this}getModifierStartXY(){if(!this.preFormatted)throw new d.RERR("UnformattedNote","Can't call GetModifierStartXY on an unformatted note");return{x:this.getAbsoluteX(),y:this.ys[0]}}getMetrics(){if(!this.preFormatted)throw new d.RERR("UnformattedNote","Can't call getMetrics on an unformatted note.");let i=0,c=0;this.modifierContext!=null&&(i=this.modifierContext.state.left_shift,c=this.modifierContext.state.right_shift);const M=this.getWidth();return{width:M,noteWidth:M-i-c-this.extraLeftPx-this.extraRightPx,left_shift:this.x_shift,modLeftPx:i,modRightPx:c,extraLeftPx:this.extraLeftPx,extraRightPx:this.extraRightPx}}setWidth(i){this.width=i}getWidth(){if(!this.preFormatted)throw new d.RERR("UnformattedNote","Can't call GetWidth on an unformatted note.");return this.width+(this.modifierContext?this.modifierContext.getWidth():0)}setXShift(i){return this.x_shift=i,this}getXShift(){return this.x_shift}getX(){if(!this.tickContext)throw new d.RERR("NoTickContext","Note needs a TickContext assigned for an X-Value");return this.tickContext.getX()+this.x_shift}getAbsoluteX(){if(!this.tickContext)throw new d.RERR("NoTickContext","Note needs a TickContext assigned for an X-Value");let i=this.tickContext.getX();return this.stave&&(i+=this.stave.getNoteStartX()+this.render_options.stave_padding),this.isCenterAligned()&&(i+=this.getCenterXShift()),i}setPreFormatted(i){if(this.preFormatted=i,this.preFormatted){const c=this.tickContext.getExtraPx();this.left_modPx=Math.max(this.left_modPx,c.left),this.right_modPx=Math.max(this.right_modPx,c.right)}}}class N extends ${static get CATEGORY(){return"notehead"}constructor(i){if(super(i),this.setAttribute("type","NoteHead"),this.index=i.index,this.x_shift=i.x_shift||0,this.x=(i.x||0)+this.x_shift,this.y=i.y||0,this.note_type=i.note_type,this.duration=i.duration,this.displaced=i.displaced||!1,this.stem_direction=i.stem_direction||ct.STEM_UP,this.line=i.line,this.glyph=v.getGlyphProps(this.duration,this.note_type),!this.glyph)throw new d.RuntimeError("BadArguments",`No glyph found for duration '${this.duration}' and type '${this.note_type}'`);this.glyph_code=this.glyph.code_head,this.x_shift_ledger_rest=0,this.y_shift_ledger_rest=0,this.x_shift=i.x_shift||0,this.glyph.rest&&(this.line>5||this.line<0)&&(this.isLedgerLinedRest=!0,this.duration==="h"?(i.custom_glyph_code="rhl",this.x_shift_ledger_rest-=4):this.duration==="w"&&(i.custom_glyph_code="rwl",this.x_shift_ledger_rest-=4,this.y_shift_ledger_rest=-5)),i.custom_glyph_code&&(this.custom_glyph=!0,this.glyph_code=i.custom_glyph_code,this.stem_up_x_offset=i.stem_up_x_offset||0,this.stem_down_x_offset=i.stem_down_x_offset||0,this.stem_up_y_shift=i.stem_up_y_shift||0,this.stem_down_y_shift=i.stem_down_y_shift||0),this.style=i.style,this.slashed=i.slashed,d.Merge(this.render_options,{glyph_font_scale:i.glyph_font_scale||v.DEFAULT_NOTATION_FONT_SCALE,stroke_px:3}),this.setWidth(this.glyph.getWidth(this.render_options.glyph_font_scale))}getCategory(){return N.CATEGORY}getWidth(){return this.width}isDisplaced(){return this.displaced===!0}getGlyph(){return this.glyph}setX(i){return this.x=i,this}getY(){return this.y}setY(i){return this.y=i,this}getLine(){return this.line}setLine(i){return this.line=i,this}getAbsoluteX(){const i=this.preFormatted?super.getAbsoluteX():this.x,c=B.WIDTH/2;return i+(this.displaced?(this.width-c)*this.stem_direction:0)}getBoundingBox(){if(!this.preFormatted)throw new d.RERR("UnformattedNote","Can't call getBoundingBox on an unformatted note.");const i=this.stave.getSpacingBetweenLines(),c=i/2,M=this.y-c;return new v.BoundingBox(this.getAbsoluteX(),M,this.width,i)}setStave(i){const c=this.getLine();return this.stave=i,this.setY(i.getYForNote(c)),this.context=this.stave.context,this}preFormat(){if(this.preFormatted)return this;const i=this.getWidth()+this.extraLeftPx+this.extraRightPx;return this.setWidth(i),this.setPreFormatted(!0),this}draw(){this.checkContext(),this.setRendered();const i=this.context;let c=this.getAbsoluteX(),M=this.y;this.custom_glyph&&(c+=this.x_shift_ledger_rest,this.stem_direction===B.UP?(c+=this.stem_up_x_offset,M+=this.stem_up_y_shift||0):this.stem_direction===B.DOWN&&(c+=this.stem_down_x_offset,M+=this.stem_down_y_shift||0),M+=this.y_shift_ledger_rest),(function(...X){N.DEBUG&&d.L("Vex.Flow.NoteHead",X)})("Drawing note head '",this.note_type,this.duration,"' at",c,M);const I=this.stem_direction,V=this.render_options.glyph_font_scale;if(this.style&&this.applyStyle(i),this.note_type==="s"){const X=this.stave.getSpacingBetweenLines();(function(Z,nt,ot,ft,pt,gt){const bt=v.SLASH_NOTEHEAD_WIDTH;Z.save(),Z.setLineWidth(v.STEM_WIDTH);let Mt=!1;if(v.durationToNumber(nt)>2&&(Mt=!0),Mt||(ot-=v.STEM_WIDTH/2*pt),Z.beginPath(),Z.moveTo(ot,ft+gt),Z.lineTo(ot,ft+1),Z.lineTo(ot+bt,ft-gt),Z.lineTo(ot+bt,ft),Z.lineTo(ot,ft+gt),Z.closePath(),Mt?Z.fill():Z.stroke(),v.durationToFraction(nt).equals(.5)){const _t=[-3,-1,bt+1,bt+3];for(let Tt=0;Tt<_t.length;Tt++)Z.beginPath(),Z.moveTo(ot+_t[Tt],ft-10),Z.lineTo(ot+_t[Tt],ft+11),Z.stroke()}Z.restore()})(i,this.duration,c,M,I,X)}else S.renderGlyph(i,c,M,V,this.glyph_code,this.id);this.style&&this.restoreStyle(i)}}class Y extends ${constructor(i){super(i),this.setAttribute("type","StemmableNote"),this.stem=null,this.stemExtensionOverride=null,this.beam=null,this.renderFlag=!0}getStem(){return this.stem}setStem(i){return this.stem=i,this}buildStem(){const i=new B;return this.setStem(i),this}buildFlag(){const{glyph:i,beam:c}=this,M=c===null&&this.renderFlag;if(i&&i.flag&&M){const I=this.getStemDirection()===B.DOWN?i.code_flag_downstem:i.code_flag_upstem;this.flag=new S(I,this.render_options.glyph_font_scale)}}getTopGlyph(){return this.getStemDirection()===B.DOWN?this.customGlyphs[this.customGlyphs.length-1]:this.customGlyphs[0]}getStemLength(){return B.HEIGHT+this.getStemExtension()}getBeamCount(){const i=this.getGlyph();return i?i.beam_count:0}getStemMinumumLength(){let i=v.durationToFraction(this.duration).value()<=1?0:20;switch(this.duration){case"8":this.beam==null&&(i=35);break;case"16":i=this.beam==null?35:25;break;case"32":i=this.beam==null?45:35;break;case"64":i=this.beam==null?50:40;break;case"128":i=this.beam==null?55:45}return i}getStemDirection(){return this.stem_direction}setStemDirection(i){if(i||(i=B.UP),i!==B.UP&&i!==B.DOWN)throw new d.RERR("BadArgument",`Invalid stem direction: ${i}`);if(this.stem_direction=i,this.stem){this.stem.setDirection(i),this.stem.setExtension(this.getStemExtension());const c=this.getTopGlyph()||this.getGlyph();this.stem.setOptions({stem_up_y_offset:c.stem_up_y_offset,stem_down_y_offset:c.stem_down_y_offset})}return this.reset(),this.flag&&this.renderFlag&&this.buildFlag(),this.beam=null,this.preFormatted&&this.preFormat(),this}getStemX(){const i=this.getAbsoluteX()+this.x_shift,c=this.getAbsoluteX()+this.x_shift+this.getGlyphWidth();return this.stem_direction===B.DOWN?i:c}getCenterGlyphX(){return this.getAbsoluteX()+this.x_shift+this.getGlyphWidth()/2}getStemExtension(){const i=this.getGlyph();return this.stemExtensionOverride!=null?this.stemExtensionOverride:i?this.getStemDirection()===1?i.stem_up_extension:i.stem_down_extension:0}setStemLength(i){return this.stemExtensionOverride=i-B.HEIGHT,this}getStemExtents(){return this.stem.getExtents()}setBeam(i){return this.beam=i,this}getYForTopText(i){const c=this.getStemExtents();return this.hasStem()?Math.min(this.stave.getYForTopText(i),c.topY-this.render_options.annotation_spacing*(i+1)):this.stave.getYForTopText(i)}getYForBottomText(i){const c=this.getStemExtents();return this.hasStem()?Math.max(this.stave.getYForTopText(i),c.baseY+this.render_options.annotation_spacing*i):this.stave.getYForBottomText(i)}hasFlag(){return this.renderFlag&&v.getGlyphProps(this.duration).flag&&!this.beam}postFormat(){return this.beam&&this.beam.postFormat(),this.postFormatted=!0,this}drawStem(i){this.checkContext(),this.setRendered(),this.setStem(new B(i)),this.stem.setContext(this.context).draw()}}class tt extends h{static get CATEGORY(){return"none"}static get Position(){return{LEFT:1,RIGHT:2,ABOVE:3,BELOW:4}}static get PositionString(){return{above:tt.Position.ABOVE,below:tt.Position.BELOW,left:tt.Position.LEFT,right:tt.Position.RIGHT}}constructor(){super(),this.setAttribute("type","Modifier"),this.width=0,this.note=null,this.index=null,this.text_line=0,this.position=tt.Position.LEFT,this.modifier_context=null,this.x_shift=0,this.y_shift=0,this.spacingFromNextModifier=0}getCategory(){return tt.CATEGORY}getWidth(){return this.width}setWidth(i){return this.width=i,this}getNote(){return this.note}setNote(i){return this.note=i,this}getIndex(){return this.index}setIndex(i){return this.index=i,this}getModifierContext(){return this.modifier_context}setModifierContext(i){return this.modifier_context=i,this}getPosition(){return this.position}setPosition(i){return this.position=typeof i=="string"?tt.PositionString[i]:i,this}setTextLine(i){return this.text_line=i,this}setYShift(i){return this.y_shift=i,this}setSpacingFromNextModifier(i){this.spacingFromNextModifier=i}getSpacingFromNextModifier(){return this.spacingFromNextModifier}setXShift(i){this.x_shift=0,this.position===tt.Position.LEFT?this.x_shift-=i:this.x_shift+=i}getXShift(){return this.x_shift}draw(){throw this.checkContext(),new d.RERR("MethodNotImplemented","draw() not implemented for this modifier.")}alignSubNotesWithNote(i,c){const M=c.getTickContext(),I=M.getExtraPx(),V=M.getX()-I.left-I.extraLeft+this.getSpacingFromNextModifier();i.forEach(X=>{const Z=X.getTickContext();X.setStave(c.stave),Z.setXOffset(V)})}}class H extends tt{static get CATEGORY(){return"dots"}static format(i,c){const M=c.right_shift;if(!i||i.length===0)return!1;const I=[],V={};for(let gt=0;gtbt.line-gt.line);let X=M,Z=0,nt=null,ot=null,ft=null,pt=0;for(let gt=0;gtZ?X:Z,nt=Tt,ot=Mt}return c.right_shift+=Z,!0}constructor(){super(),this.setAttribute("type","Dot"),this.note=null,this.index=null,this.position=tt.Position.RIGHT,this.radius=2,this.setWidth(5),this.dot_shiftY=0}getCategory(){return H.CATEGORY}setNote(i){this.note=i,this.note.getCategory()==="gracenotes"&&(this.radius*=.5,this.setWidth(3))}setDotShiftY(i){return this.dot_shiftY=i,this}draw(){if(this.checkContext(),this.setRendered(),!this.note||this.index===null)throw new d.RERR("NoAttachedNote","Can't draw dot without a note and index.");const i=this.note.stave.options.spacing_between_lines_px,c=this.note.getModifierStartXY(this.position,this.index,{forceFlagRight:!0});this.note.getCategory()==="tabnotes"&&(c.y=this.note.getStemExtents().baseY);const M=c.x+this.x_shift+this.width-this.radius,I=c.y+this.y_shift+this.dot_shiftY*i,V=this.context;V.beginPath(),V.arc(M,I,this.radius,0,2*Math.PI,!1),V.fill()}}function rt(vt,i,c){if(vt.note.shiftRestVerticalDisabled)return;const M=(i.isrest?0:1)*c;vt.line+=M,vt.maxLine+=M,vt.minLine+=M,vt.note.setKeyLine(0,vt.note.getKeyLine(0)+M)}class ct extends Y{static get CATEGORY(){return"stavenotes"}static get STEM_UP(){return B.UP}static get STEM_DOWN(){return B.DOWN}static get DEFAULT_LEDGER_LINE_OFFSET(){return 3}static format(i,c){if(!i||i.length<2)return!1;const M=[],I=i[0].stagger_same_whole_notes;for(let gt=0;gt2?M[1]:null;let nt=V>2?M[2]:M[1];V!==2||X.stemDirection!==-1||nt.stemDirection!==1||X.isrest||nt.isRest||(X=M[1],nt=M[0]);const ot=Math.max(X.voice_shift,nt.voice_shift);let ft,pt=0;if(V===2){const gt=X.stemDirection===nt.stemDirection?0:.5;if(X.stemDirection===nt.stemDirection&&X.minLine<=nt.maxLine&&(X.isrest||(ft=Math.abs(X.line-(nt.maxLine+.5)),ft=Math.max(ft,X.stemMin),X.minLine=X.line-ft,X.note.setStemLength(10*ft))),X.minLine<=nt.maxLine+gt)if(X.isrest)rt(X,nt,1),X.note.hasLedgerLinedRest&&(X.note.shiftRestVerticalDisabled=!0);else if(nt.isrest)rt(nt,X,-1),nt.note.hasLedgerLinedRest&&(nt.note.shiftRestVerticalDisabled=!0);else{pt=ot;const bt=Math.abs(X.line-nt.line);let Mt=0,_t=0;X.note.duration==="h"?Mt++:X.note.duration==="w"&&_t++,nt.note.duration==="h"?Mt++:nt.note.duration==="w"&&_t++;let Tt=Mt===1||_t===1||X.note.dots!==nt.note.dots;if(I&&(Tt||(Tt=_t===2)),bt===0&&Tt){if(nt.note.setXShift(pt),X.note.dots>0){let Ft=0;for(const Zt of X.note.modifiers)if(Zt instanceof H&&(Ft++,Zt.setYShift(-10*(nt.maxLine-X.line+1)),Ft===X.note.dots))break}}else bt<1&&bt>0?nt.note.setXShift(pt):X.note.voice!==nt.note.voice&&X.stemDirection===nt.stemDirection&&(X.line>nt.line?X.stemDirection===1?nt.note.renderFlag=!1:X.note.renderFlag=!1:nt.line>X.line?nt.stemDirection===1?X.note.renderFlag=!1:nt.note.renderFlag=!1:nt.stemDirection===1&&(nt.stemDirection=-1,nt.note.setStemDirection(-1)))}return!0}return Z!==null&&Z.minLinec.postFormat()),!0)}constructor(i){if(super(i),this.setAttribute("type","StaveNote"),this.keys=i.keys,this.clef=i.clef,this.octave_shift=i.octave_shift,this.beam=null,this.glyph=v.getGlyphProps(this.duration,this.noteType),!this.glyph)throw new d.RuntimeError("BadArguments",`Invalid note initialization data (No glyph found): ${JSON.stringify(i)}`);this.displaced=!1,this.dot_shiftY=0,this.addDotsCount=0,this.keyProps=[],this.use_default_head_x=!1,this.paddingRight=0,this.note_heads=[],this.modifiers=[],d.Merge(this.render_options,{glyph_font_scale:i.glyph_font_scale||v.DEFAULT_NOTATION_FONT_SCALE,stroke_px:i.stroke_px||ct.DEFAULT_LEDGER_LINE_OFFSET}),this.calculateKeyProps(),this.buildStem(),i.auto_stem?this.autoStem():this.setStemDirection(i.stem_direction),this.reset(),this.buildFlag()}reset(){super.reset();const i=this.note_heads.map(M=>M.getStyle()),c=[];this.note_heads.forEach(M=>c.push(M.note_type)),this.buildNoteHeads(),this.note_heads.forEach((M,I)=>{M.setStyle(i[I]),c[I]&&(M.note_type=c[I])}),this.stave&&this.note_heads.forEach(M=>M.setStave(this.stave)),this.calcExtraPx()}setBeam(i){return this.beam=i,this.calcExtraPx(),this}getCategory(){return ct.CATEGORY}buildStem(){this.setStem(new B({hide:!!this.isRest()})),this.stem.id=d.Prefix(`${this.getAttribute("id")}-stem`)}buildNoteHeads(){this.note_heads=[];const i=this.getStemDirection(),c=this.getKeys();let M,I,V,X=null,Z=null,nt=!1;i===B.UP?(M=0,I=c.length,V=1):i===B.DOWN&&(M=c.length-1,I=-1,V=-1);for(let ot=M;ot!==I;ot+=V){const ft=this.keyProps[ot],pt=ft.line;X===null?X=pt:(Z=Math.abs(X-pt),Z===0||Z===.5?nt=!nt:(nt=!1,this.use_default_head_x=!0)),X=pt;const gt=new N({duration:this.duration,note_type:this.noteType,displaced:nt,stem_direction:i,custom_glyph_code:ft.code,glyph_font_scale:this.render_options.glyph_font_scale,x_shift:ft.shift_right,stem_up_x_offset:ft.stem_up_x_offset,stem_down_x_offset:ft.stem_down_x_offset,stem_up_y_shift:ft.stem_up_y_shift,stem_down_y_shift:ft.stem_down_y_shift,line:ft.line});gt.isLedgerLinedRest&&(this.hasLedgerLinedRest=!0),gt.id=this.stem.id=d.Prefix(`${this.getAttribute("id")}-stem${ot}`),this.note_heads[ot]=gt}}autoStem(){this.minLine=this.keyProps[0].line,this.maxLine=this.keyProps[this.keyProps.length-1].line;const i=(this.minLine+this.maxLine)/2<3?B.UP:B.DOWN;this.setStemDirection(i)}calculateKeyProps(){let i=null;for(let c=0;c0&&(this.keyProps[c-1].displaced=!0)),i=X,this.keyProps.push(V)}i=-1/0,this.keyProps.forEach(c=>{c.linec.line-M.line)}getBoundingBox(){if(!this.preFormatted)throw new d.RERR("UnformattedNote","Can't call getBoundingBox on an unformatted note.");const{width:i,modLeftPx:c,extraLeftPx:M}=this.getMetrics(),I=this.getAbsoluteX()-c-M-this.paddingRight;let V=0,X=0;const Z=this.getStave().getSpacingBetweenLines()/2,nt=2*Z;if(this.isRest()){const ot=this.ys[0],ft=v.durationToFraction(this.duration);ft.equals(1)||ft.equals(2)?(V=ot-Z,X=ot+Z):(V=ot-this.glyph.line_above*nt,X=ot+this.glyph.line_below*nt)}else if(this.glyph.stem){const ot=this.getStemExtents();ot.baseY+=Z*this.stem_direction,V=Math.min(ot.topY,ot.baseY),X=Math.max(ot.topY,ot.baseY)}else{V=null,X=null;for(let ot=0;otc&&(c=I):I1}hasStem(){return this.glyph.stem}hasFlag(){return super.hasFlag()&&!this.isRest()&&this.renderFlag}getStemX(){return this.noteType==="r"?this.getCenterGlyphX():super.getStemX()+B.WIDTH/(2*-this.getStemDirection())}getYForTopText(i){const c=this.getStemExtents();return Math.min(this.stave.getYForTopText(i),c.topY-this.render_options.annotation_spacing*(i+1))}getYForBottomText(i){const c=this.getStemExtents();return Math.max(this.stave.getYForTopText(i),c.baseY+this.render_options.annotation_spacing*i)}setStave(i){super.setStave(i);const c=this.note_heads.map(M=>(M.setStave(i),M.getY()));if(this.setYs(c),this.stem){const{y_top:M,y_bottom:I}=this.getNoteHeadBounds();this.stem.setYBounds(M,I)}return this}getKeys(){return this.keys}getKeyProps(){return this.keyProps}isDisplaced(){return this.displaced}setNoteDisplaced(i){return this.displaced=i,this}getTieRightX(){let i=this.getAbsoluteX();return i+=this.getGlyphWidth()+this.x_shift+this.extraRightPx,this.modifierContext&&(i+=this.modifierContext.getExtraRightPx()),i}getTieLeftX(){let i=this.getAbsoluteX();return i+=this.x_shift-this.extraLeftPx,i}getLineForRest(){let i=this.keyProps[0].line;if(this.keyProps.length>1){const c=this.keyProps[this.keyProps.length-1].line,M=Math.max(i,c),I=Math.min(i,c);i=d.MidLine(M,I)}return i}getModifierStartXY(i,c,M){if(M=M||{},!this.preFormatted)throw new d.RERR("UnformattedNote","Can't call GetModifierStartXY on an unformatted note");if(this.ys.length===0)throw new d.RERR("NoYValues","No Y-Values calculated for this note.");const{ABOVE:I,BELOW:V,LEFT:X,RIGHT:Z}=tt.Position;let nt=0;return i===X?nt=-2:i===Z?(nt=this.getGlyphWidth()+this.x_shift+2,this.stem_direction===B.UP&&this.hasFlag()&&(M.forceFlagRight||((ot,ft)=>ft===(ot.getStemDirection()===B.UP?ot.keyProps.length-1:0))(this,c))&&(nt+=this.flag.getMetrics().width)):i!==V&&i!==I||(nt=this.getGlyphWidth()/2),{x:this.getAbsoluteX()+nt,y:this.ys[c]}}setStyle(i){super.setStyle(i),this.note_heads.forEach(c=>c.setStyle(i)),this.stem&&this.stem.setStyle(i)}setStemStyle(i){this.stem&&this.getStem().setStyle(i)}getStemStyle(){return this.stem.getStyle()}setLedgerLineStyle(i){this.ledgerLineStyle=i}getLedgerLineStyle(){return this.ledgerLineStyle}setFlagStyle(i){this.flagStyle=i}getFlagStyle(){return this.flagStyle}setKeyStyle(i,c){return this.note_heads[i].setStyle(c),this}setKeyLine(i,c){return this.keyProps[i].line=c,this.reset(),this}getKeyLine(i){return this.keyProps[i].line}addToModifierContext(i){this.setModifierContext(i);for(let c=0;c{const gt=pt.getLine(),bt=pt.getY();(i===null||btc)&&(c=bt),I===null&&pt.isDisplaced()&&(I=pt.getAbsoluteX()),M!==null||pt.isDisplaced()||(M=pt.getAbsoluteX()),V=gt>V?gt:V,X=gt{let he;he=ne&&ee?_t-M:ee?Mt-M:bt-M;const me=ee&&ne?X:V;I.beginPath(),I.moveTo(he,Yt),I.lineTo(he+me,Yt),I.stroke()},Ft={...i.getStyle()||{},...this.getLedgerLineStyle()||{}};this.applyStyle(I,Ft);const Zt=Z>=6||nt<=0;Zt&&I.openGroup("ledgers",this.getAttribute("id")+"ledgers");for(let Yt=6;Yt<=Z;++Yt){const ee=Mt!==null&&Yt<=ft,ne=bt!==null&&Yt<=ot;Tt(i.getYForNote(Yt),ee,ne)}for(let Yt=0;Yt>=nt;--Yt){const ee=Mt!==null&&Yt>=gt,ne=bt!==null&&Yt>=pt;Tt(i.getYForNote(Yt),ee,ne)}Zt&&I.closeGroup(),this.restoreStyle(I,Ft)}drawModifiers(){if(!this.context)throw new d.RERR("NoCanvasContext","Can't draw without a canvas context.");const i=this.context;i.openGroup("modifiers");for(let c=0;c{this.context.openGroup("notehead",null,{pointerBBox:!0}),i.setContext(this.context).draw(),this.context.closeGroup()})}drawStem(i){if(!this.context)throw new d.RERR("NoCanvasContext","Can't draw without a canvas context.");i&&this.setStem(new B(i)),this.stem.id=d.Prefix(`${this.getAttribute("id")}-stem`),this.stem&&(this.context.openGroup("stem",null,{pointerBBox:!0}),this.stem.setContext(this.context).draw(),this.context.closeGroup())}draw(){if(!this.context)throw new d.RERR("NoCanvasContext","Can't draw without a canvas context.");if(!this.stave)throw new d.RERR("NoStave","Can't draw without a stave.");if(this.ys.length===0)throw new d.RERR("NoYValues","Can't draw note without Y values.");const i=this.getNoteHeadBeginX(),c=this.hasStem()&&!this.beam;if(this.note_heads.forEach(M=>M.setX(i)),this.stem){const M=this.getStemX();this.stem.setNoteHeadXBounds(M,M)}(function(...M){ct.DEBUG&&d.L("Vex.Flow.StaveNote",M)})("Rendering ",this.isChord()?"chord :":"note :",this.keys),this.drawLedgerLines(),this.applyStyle(),this.setAttribute("el",this.context.openGroup("stavenote",this.getAttribute("id"))),this.context.openGroup("note",null,{pointerBBox:!0}),c&&this.drawStem(),this.drawNoteHeads(),this.drawFlag(),this.context.closeGroup(),this.drawModifiers(),this.context.closeGroup(),this.restoreStyle(),this.setRendered()}}class st extends tt{static get CATEGORY(){return"frethandfinger"}static format(i,c){const{left_shift:M,right_shift:I}=c;if(!i||i.length===0)return!1;const V=[];let X=null,Z=0,nt=0;for(let _t=0;_tTt.line-_t.line);let ot=0,ft=0,pt=0,gt=0,bt=null,Mt=null;for(let _t=0;_tpt?Tt:pt):Zt===tt.Position.RIGHT&&(Yt.setXShift(ft),Tt=nt+me,gt=Tt>gt?Tt:gt),bt=ee,Mt=Ft}return c.left_shift+=pt,c.right_shift+=gt,!0}constructor(i){super(),this.setAttribute("type","FretHandFinger"),this.note=null,this.index=null,this.finger=i,this.width=7,this.position=tt.Position.LEFT,this.x_shift=0,this.y_shift=0,this.x_offset=0,this.y_offset=0,this.font={family:"sans-serif",size:9,weight:"bold"}}getCategory(){return st.CATEGORY}setFretHandFinger(i){return this.finger=i,this}setOffsetX(i){return this.x_offset=i,this}setOffsetY(i){return this.y_offset=i,this}draw(){if(this.checkContext(),!this.note||this.index==null)throw new d.RERR("NoAttachedNote","Can't draw string number without a note and index.");this.setRendered();const i=this.context,c=this.note.getModifierStartXY(this.position,this.index);let M=c.x+this.x_shift+this.x_offset,I=c.y+this.y_shift+this.y_offset+5;switch(this.position){case tt.Position.ABOVE:M-=4,I-=12;break;case tt.Position.BELOW:M-=2,I+=10;break;case tt.Position.LEFT:M-=this.width;break;case tt.Position.RIGHT:M+=1;break;default:throw new d.RERR("InvalidPostion",`The position ${this.position} does not exist`)}i.save(),i.setFont(this.font.family,this.font.size,this.font.weight),i.fillText(""+this.finger,M,I),i.restore()}}class at{static get NUM_TONES(){return 12}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],dorian:[2,1,2,2,2,1,2],mixolydian:[2,2,1,2,2,1,2],minor:[2,1,2,2,1,2,2]}}static get scaleTypes(){return{M:at.scales.major,m:at.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(i){return!(i==null||i<0||i>=at.NUM_TONES)}isValidIntervalValue(i){return this.isValidNoteValue(i)}getNoteParts(i){if(!i||i.length<1)throw new d.RERR("BadArguments","Invalid note name: "+i);if(i.length>3)throw new d.RERR("BadArguments","Invalid note name: "+i);const c=i.toLowerCase(),M=/^([cdefgab])(b|bb|n|#|##)?$/.exec(c);if(M!=null)return{root:M[1],accidental:M[2]};throw new d.RERR("BadArguments","Invalid note name: "+i)}getKeyParts(i){if(!i||i.length<1)throw new d.RERR("BadArguments","Invalid key: "+i);const c=i.toLowerCase(),M=/^([cdefgab])(b|#)?(mel|harm|m|M)?$/.exec(c);if(M!=null){const I=M[1],V=M[2];let X=M[3];return X||(X="M"),{root:I,accidental:V,type:X}}throw new d.RERR("BadArguments",`Invalid key: ${i}`)}getNoteValue(i){const c=at.noteValues[i];if(c==null)throw new d.RERR("BadArguments",`Invalid note name: ${i}`);return c.int_val}getIntervalValue(i){const c=at.intervals[i];if(c==null)throw new d.RERR("BadArguments",`Invalid interval name: ${i}`);return c}getCanonicalNoteName(i){if(!this.isValidNoteValue(i))throw new d.RERR("BadArguments",`Invalid note value: ${i}`);return at.canonical_notes[i]}getCanonicalIntervalName(i){if(!this.isValidIntervalValue(i))throw new d.RERR("BadArguments",`Invalid interval value: ${i}`);return at.diatonic_intervals[i]}getRelativeNoteValue(i,c,M){if(M==null&&(M=1),M!==1&&M!==-1)throw new d.RERR("BadArguments",`Invalid direction: ${M}`);let I=(i+M*c)%at.NUM_TONES;return I<0&&(I+=at.NUM_TONES),I}getRelativeNoteName(i,c){const M=this.getNoteParts(i),I=this.getNoteValue(M.root);let V=c-I;if(Math.abs(V)>at.NUM_TONES-3){let Z=1;V>0&&(Z=-1);const nt=(c+1+(I+1))%at.NUM_TONES*Z;if(Math.abs(nt)>2)throw new d.RERR("BadArguments",`Notes not related: ${i}, ${c})`);V=nt}if(Math.abs(V)>2)throw new d.RERR("BadArguments",`Notes not related: ${i}, ${c})`);let X=M.root;if(V>0)for(let Z=1;Z<=V;++Z)X+="#";else if(V<0)for(let Z=-1;Z>=V;--Z)X+="b";return X}getScaleTones(i,c){const M=[i];let I=i;for(let V=0;Vvt.getMetrics().width;class O extends tt{static get CATEGORY(){return"accidentals"}static format(i,c){const M=c.left_shift+1;if(!i||i.length===0)return;const I=[];let V,X=null,Z=0;for(let Tt=0;TtFt.line-Tt.line);const nt=[];let ot=0,ft=null;for(let Tt=0;Ttot?Ft.shift:ot,ft=Ft.line}let pt=0;for(let Tt=0;Ttnt[Zt+je],ne=je=>je.map(ee),he=(je,ki)=>{const[Vi,Yn]=ne([je,ki]).map(pn=>pn.line);return Vi-Yn},me=(...je)=>je.map(ne).every(ki=>!this.checkCollision(...ki)),Le=Yt-Zt+1;let Ee,vi,ri=this.checkCollision(nt[Zt],nt[Yt])?"a":"b";switch(Le){case 3:ri==="a"&&he(1,2)===.5&&he(0,1)!==.5&&(ri="second_on_bottom");break;case 4:me([0,2],[1,3])&&(ri="spaced_out_tetrachord");break;case 5:ri==="b"&&me([1,3])&&(ri="spaced_out_pentachord",me([0,2],[2,4])&&(ri="very_spaced_out_pentachord"));break;case 6:me([0,3],[1,4],[2,5])&&(ri="spaced_out_hexachord"),me([0,2],[2,4],[1,3],[3,5])&&(ri="very_spaced_out_hexachord")}if(Le>=7){let je=2,ki=!0;for(;ki===!0;){ki=!1;for(let Vi=0;Vi+jevi?pt:vi}else for(Ee=Tt;Ee<=Yt;Ee++)vi=v.accidentalColumnsTable[Le][ri][Ee-Tt],nt[Ee].column=vi,pt=pt>vi?pt:vi;Tt=Yt}const gt=[],bt=[];for(let Tt=0;Tt<=pt;Tt++)gt[Tt]=0,bt[Tt]=0;gt[0]=ot+M,bt[0]=ot+M,nt.forEach(Tt=>{Tt.width>gt[Tt.column]&&(gt[Tt.column]=Tt.width)});for(let Tt=1;Tt{let Ft=0;const Zt=_t+Tt.numAcc;for(;_t0?(I=c.flatLine||c.dblSharpLine?2.5:3,i.dblSharpLine&&(M-=.5)):(I=i.flatLine||i.dblSharpLine?2.5:3,c.dblSharpLine&&(M-=.5));const V=Math.abs(M){const nt=new l(0,1);Z.getTickables().forEach(ot=>{if(ot.shouldIgnoreTicks())return;const ft=I[nt.value()];ft?ft.push(ot):(M.push(nt.value()),I[nt.value()]=[ot]),nt.add(ot.getTicks())})});const V=new at;c||(c="C");const X=V.createScaleMap(c);M.forEach(Z=>{const nt=I[Z],ot=[],ft=pt=>{pt.isRest()||pt.shouldIgnoreTicks()||(pt.keys.forEach((gt,bt)=>{const Mt=V.getNoteParts(gt.split("/")[0]),_t=Mt.accidental||"n",Tt=Mt.root+_t,Ft=X[Mt.root]===Tt,Zt=ot.indexOf(Tt)>-1;if(!Ft||Ft&&Zt){X[Mt.root]=Tt;const Yt=new O(_t);pt.addAccidental(bt,Yt),ot.push(Tt)}}),pt.getModifiers().forEach(gt=>{gt.getCategory()==="gracenotegroups"&>.getGraceNotes().forEach(ft)}))};nt.forEach(ft)})}constructor(i=null){if(super(),this.setAttribute("type","Accidental"),ht("New accidental: ",i),this.note=null,this.index=null,this.type=i,this.position=tt.Position.LEFT,this.render_options={font_scale:38,stroke_px:3,parenLeftPadding:2,parenRightPadding:2},this.accidental=v.accidentalCodes(this.type),!this.accidental)throw new d.RERR("ArgumentError",`Unknown accidental type: ${i}`);this.cautionary=!1,this.parenLeft=null,this.parenRight=null,this.reset()}reset(){const i=this.render_options.font_scale;this.glyph=new S(this.accidental.code,i),this.glyph.setOriginX(1),this.cautionary&&(this.parenLeft=new S(v.accidentalCodes("{").code,i),this.parenRight=new S(v.accidentalCodes("}").code,i),this.parenLeft.setOriginX(1),this.parenRight.setOriginX(1))}getCategory(){return O.CATEGORY}getWidth(){const i=this.cautionary?lt(this.parenLeft)+lt(this.parenRight)+this.render_options.parenLeftPadding+this.render_options.parenRightPadding:0;return lt(this.glyph)+i}setNote(i){if(!i)throw new d.RERR("ArgumentError",`Bad note value: ${i}`);this.note=i,this.note.getCategory()==="gracenotes"&&(this.render_options.font_scale=25,this.reset())}setAsCautionary(){return this.cautionary=!0,this.render_options.font_scale=28,this.reset(),this}draw(){const{context:i,type:c,position:M,note:I,index:V,cautionary:X,x_shift:Z,y_shift:nt,glyph:ot,parenLeft:ft,parenRight:pt,render_options:{parenLeftPadding:gt,parenRightPadding:bt}}=this;if(this.checkContext(),!I||V==null)throw new d.RERR("NoAttachedNote","Can't draw accidental without a note and index.");const Mt=I.getModifierStartXY(M,V);let _t=Mt.x+Z;const Tt=Mt.y+nt;ht("Rendering: ",c,_t,Tt),X?(pt.render(i,_t,Tt),_t-=lt(pt),_t-=bt,_t-=this.accidental.parenRightPaddingAdjustment,ot.render(i,_t,Tt),_t-=lt(ot),_t-=gt,ft.render(i,_t,Tt)):ot.render(i,_t,Tt),this.setRendered()}}class D extends tt{static get CATEGORY(){return"notesubgroup"}static format(i,c){if(!i||i.length===0)return!1;let M=0;for(let I=0;I{c.ignore_ticks=!1}),this.width=0,this.preFormatted=!1,this.formatter=new te,this.voice=new U({num_beats:4,beat_value:4,resolution:v.RESOLUTION}).setStrict(!1),this.voice.addTickables(this.subNotes),this}getCategory(){return D.CATEGORY}preFormat(){this.preFormatted||(this.formatter.joinVoices([this.voice]).format([this.voice],0),this.setWidth(this.formatter.getMinTotalWidth()),this.preFormatted=!0)}setNote(i){this.note=i}setWidth(i){this.width=i}getWidth(){return this.width}draw(){this.checkContext();const i=this.getNote();if(!i||this.index===null)throw new d.RuntimeError("NoAttachedNote","Can't draw notes without a parent note and parent note index.");this.setRendered(),this.alignSubNotesWithNote(this.subNotes,i),this.subNotes.forEach(c=>c.setContext(this.context).drawWithStyle())}}class j extends h{constructor(i,c){super(),this.setAttribute("type","StaveTie"),this.notes=i,this.context=null,this.text=c,this.direction=null,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,font:{family:"Arial",size:10,style:""}},this.font=this.render_options.font,this.setNotes(i)}setFont(i){return this.font=i,this}setDirection(i){return this.direction=i,this}setNotes(i){if(!i.first_note&&!i.last_note)throw new d.RuntimeError("BadArguments","Tie needs to have either first_note or last_note set.");if(i.first_indices||(i.first_indices=[0]),i.last_indices||(i.last_indices=[0]),i.first_indices.length!==i.last_indices.length)throw new d.RuntimeError("BadArguments","Tied notes must have similar index sizes");return this.first_note=i.first_note,this.first_indices=i.first_indices,this.last_note=i.last_note,this.last_indices=i.last_indices,this}isPartial(){return!this.first_note||!this.last_note}renderTie(i){var nt;if(i.first_ys.length===0||i.last_ys.length===0)throw new d.RERR("BadArguments","No Y-values to render");const c=this.context;let M=this.render_options.cp1,I=this.render_options.cp2;Math.abs(i.last_x_px-i.first_x_px)<10&&(M=2,I=8);const V=this.render_options.first_x_shift,X=this.render_options.last_x_shift,Z=this.render_options.y_shift*i.direction;for(let ot=0;ot1){const c=new G(i);c.render_options.beam_width=3,c.render_options.partial_beam_length=4,this.beams.push(c)}return this}setNote(i){this.note=i}setWidth(i){this.width=i}getWidth(){return this.width}getGraceNotes(){return this.grace_notes}draw(){this.checkContext();const i=this.getNote();if((function(...c){J.DEBUG&&d.L("Vex.Flow.GraceNoteGroup",c)})("Drawing grace note group for:",i),!i||this.index===null)throw new d.RuntimeError("NoAttachedNote","Can't draw grace note without a parent note and parent note index.");if(this.setRendered(),this.alignSubNotesWithNote(this.getGraceNotes(),i),this.grace_notes.forEach(c=>{c.setContext(this.context).draw()}),this.beams.forEach(c=>{c.setContext(this.context).draw()}),this.show_slur){const c=this.getNote().getCategory()===ct.CATEGORY,M=c?j:Q;this.slur=new M({last_note:this.grace_notes[0],first_note:i,first_indices:[0],last_indices:[0]}),this.slur.render_options.cp2=12,this.slur.render_options.y_shift=(c?7:5)+this.render_options.slur_y_shift,this.slur.setContext(this.context).draw()}}}class q extends tt{static get CATEGORY(){return"strokes"}static get Type(){return{BRUSH_DOWN:1,BRUSH_UP:2,ROLL_DOWN:3,ROLL_UP:4,RASQUEDO_DOWN:5,RASQUEDO_UP:6,ARPEGGIO_DIRECTIONLESS:7}}static format(i,c){const M=c.left_shift;if(!i||i.length===0)return this;const I=i.map(Z=>{const nt=Z.getNote();if(nt instanceof ct){const{line:ot,displaced:ft}=nt.getKeyProps()[Z.getIndex()];return{line:ot,shift:ft?nt.getExtraLeftPx():0,stroke:Z}}{const{str:ot}=nt.getPositions()[Z.getIndex()];return{line:ot,shift:0,stroke:Z}}}),V=M,X=I.reduce((Z,{stroke:nt,shift:ot})=>(nt.setXShift(V+ot),Math.max(nt.getWidth()+0,Z)),0);return c.left_shift+=X,!0}constructor(i,c){super(),this.setAttribute("type","Stroke"),this.note=null,this.options=d.Merge({},c),this.all_voices=!("all_voices"in this.options)||this.options.all_voices,this.note_end=null,this.index=null,this.type=i,this.position=tt.Position.LEFT,this.render_options={font_scale:38,stroke_px:3,stroke_spacing:10},this.font={family:"serif",size:10,weight:"bold italic"},this.setXShift(0),this.setWidth(10)}getCategory(){return q.CATEGORY}getPosition(){return this.position}addEndNote(i){return this.note_end=i,this}draw(){if(this.checkContext(),this.setRendered(),!this.note||this.index==null)throw new d.RERR("NoAttachedNote","Can't draw stroke without a note and index.");const i=this.note.getModifierStartXY(this.position,this.index);let c=this.note.getYs(),M=i.y,I=i.y;const V=i.x-5,X=this.note.stave.options.spacing_between_lines_px,Z=this.getModifierContext().getModifiers(this.note.getCategory());for(let bt=0;btee.line-Yt.line);let Mt=0,_t=0,Tt=0,Ft=null,Zt=null;for(X=0;X_t?Yt:_t):ot===tt.Position.RIGHT&&(Z.setXShift(Mt),Yt+=he,Tt=Yt>Tt?Yt:Tt),Ft=ee,Zt=nt}return c.left_shift+=_t,c.right_shift+=Tt,!0}constructor(i){super(),this.setAttribute("type","StringNumber"),this.note=null,this.last_note=null,this.index=null,this.string_number=i,this.setWidth(20),this.position=tt.Position.ABOVE,this.x_shift=0,this.y_shift=0,this.x_offset=0,this.y_offset=0,this.dashed=!0,this.leg=_.LineEndType.NONE,this.radius=8,this.font={family:"sans-serif",size:10,weight:"bold"}}getCategory(){return et.CATEGORY}getNote(){return this.note}setNote(i){return this.note=i,this}getIndex(){return this.index}setIndex(i){return this.index=i,this}setLineEndType(i){return i>=_.LineEndType.NONE&&i<=_.LineEndType.DOWN&&(this.leg=i),this}setStringNumber(i){return this.string_number=i,this}setOffsetX(i){return this.x_offset=i,this}setOffsetY(i){return this.y_offset=i,this}setLastNote(i){return this.last_note=i,this}setDashed(i){return this.dashed=i,this}draw(){const i=this.checkContext();if(!this.note||this.index==null)throw new d.RERR("NoAttachedNote","Can't draw string number without a note and index.");this.setRendered();const c=this.note.stave.options.spacing_between_lines_px,M=this.note.getModifierStartXY(this.position,this.index);let I=M.x+this.x_shift+this.x_offset,V=M.y+this.y_shift+this.y_offset;switch(this.position){case tt.Position.ABOVE:case tt.Position.BELOW:{const Z=this.note.getStemExtents();let nt=Z.topY,ot=Z.baseY+2;this.note.stem_direction===ct.STEM_DOWN&&(nt=Z.baseY,ot=Z.topY-2),V=this.position===tt.Position.ABOVE?this.note.hasStem()?nt-1.75*c:M.y-1.75*c:this.note.hasStem()?ot+1.5*c:M.y+1.75*c,V+=this.y_shift+this.y_offset;break}case tt.Position.LEFT:I-=this.radius/2+5;break;case tt.Position.RIGHT:I+=this.radius/2+6;break;default:throw new d.RERR("InvalidPosition",`The position ${this.position} is invalid`)}i.save(),i.beginPath(),i.arc(I,V,this.radius,0,2*Math.PI,!1),i.lineWidth=1.5,i.stroke(),i.setFont(this.font.family,this.font.size,this.font.weight);const X=I-i.measureText(this.string_number).width/2;if(i.fillText(""+this.string_number,X,V+4.5),this.last_note!=null){const Z=this.last_note.getStemX()-this.note.getX()+5;let nt,ot;switch(i.strokeStyle="#000000",i.lineCap="round",i.lineWidth=.6,this.dashed?_.drawDashedLine(i,I+10,V,I+Z,V,[3,3]):_.drawDashedLine(i,I+10,V,I+Z,V,[3,0]),this.leg){case _.LineEndType.UP:nt=-10,ot=this.dashed?[3,3]:[3,0],_.drawDashedLine(i,I+Z,V,I+Z,V+nt,ot);break;case _.LineEndType.DOWN:nt=10,ot=this.dashed?[3,3]:[3,0],_.drawDashedLine(i,I+Z,V,I+Z,V+nt,ot)}}i.restore()}}class it extends W{static getNextContext(i){const c=i.tContexts,M=c.indexOf(i);return c[M+1]}constructor(){super(),this.setAttribute("type","TickContext"),this.currentTick=new l(0,1),this.maxTicks=new l(0,1),this.minTicks=null,this.padding=3,this.x=0,this.xBase=0,this.xOffset=0,this.tickables=[],this.notePx=0,this.extraLeftPx=0,this.extraRightPx=0,this.tContexts=[]}getX(){return this.x}setX(i){return this.x=i,this.xBase=i,this.xOffset=0,this}getXBase(){return this.xBase}setXBase(i){this.xBase=i,this.x=i+this.xOffset}getXOffset(){return this.xOffset}setXOffset(i){this.xOffset=i,this.x=this.xBase+i}getWidth(){return this.width+2*this.padding}setPadding(i){return this.padding=i,this}getMaxTicks(){return this.maxTicks}getMinTicks(){return this.minTicks}getTickables(){return this.tickables}getCenterAlignedTickables(){return this.tickables.filter(i=>i.isCenterAligned())}getMetrics(){const{width:i,notePx:c,extraLeftPx:M,extraRightPx:I}=this;return{width:i,notePx:c,extraLeftPx:M,extraRightPx:I}}getCurrentTick(){return this.currentTick}setCurrentTick(i){this.currentTick=i,this.preFormatted=!1}getExtraPx(){let i=0,c=0,M=0,I=0;for(let V=0;V.5*vt(i/.5),Et=(vt,i)=>i===dt?vt<=5:vt>=1,Dt=(vt,i)=>Et(vt,i)?i===dt?Math.ceil:Math.floor:Math.round,Vt=vt=>{const i=vt.getCategory();return i==="stavenotes"||i==="gracenotes"};class Nt extends tt{static get CATEGORY(){return"articulations"}static get INITIAL_OFFSET(){return-.5}static format(i,c){if(!i||i.length===0)return!1;const M=(V,X,Z)=>yt(Dt(X,Z),V.glyph.getMetrics().height/10+.5);i.filter(V=>V.getPosition()===dt).forEach(V=>{V.setTextLine(c.top_text_line),c.top_text_line+=M(V,c.top_text_line,dt)}),i.filter(V=>V.getPosition()===mt).forEach(V=>{V.setTextLine(c.text_line),c.text_line+=M(V,c.text_line,mt)});const I=i.map(V=>V.getWidth()).reduce((V,X)=>Math.max(X,V));return c.left_shift+=I/2,c.right_shift+=I/2,!0}static easyScoreHook({articulations:i},c,M){if(!i)return;const I={staccato:"a.",tenuto:"a-"};i.split(",").map(V=>V.trim().split(".")).map(([V,X])=>{const Z={type:I[V]};return X&&(Z.position=tt.PositionString[X]),M.getFactory().Articulation(Z)}).map(V=>c.addModifier(0,V))}constructor(i){if(super(),this.setAttribute("type","Articulation"),this.note=null,this.index=null,this.type=i,this.position=mt,this.render_options={font_scale:38},this.breathMarkDistance=.8,this.articulation=v.articulationCodes(this.type),this.type==="abr"&&(this.articulation={code:"v6c",between_lines:!1}),!this.articulation)throw new d.RERR("ArgumentError",`Articulation not found: ${this.type}`);this.glyph=new S(this.articulation.code,this.render_options.font_scale),this.setWidth(this.glyph.getMetrics().width)}getCategory(){return Nt.CATEGORY}draw(){const{note:i,index:c,position:M,glyph:I,articulation:{between_lines:V},text_line:X,context:Z}=this;if(this.checkContext(),!i||c==null)throw new d.RERR("NoAttachedNote","Can't draw Articulation without a note and index.");this.setRendered();const nt=i.getStave(),ot=nt.getSpacingBetweenLines(),ft=i.getCategory()==="tabnotes";let{x:pt}=i.getModifierStartXY(M,c);if(this.type==="abr"){let Tt=0;const Ft=i.getTickContext(),Zt=it.getNextContext(Ft),Yt=Ft.getX();if(Zt&&Zt.x>Ft.x)Tt=(Zt.getX()-Yt)*this.breathMarkDistance;else{const ee=i.getStave();Tt=(ee.getX()+ee.getWidth()-Yt+ee.start_x)*this.breathMarkDistance}if(pt+=Tt,pt>nt.end_x){const ee=nt.start_x+Yt;pt=ee+(nt.end_x-ee)*this.breathMarkDistance}}const gt=this.getXShift();gt&&(pt+=gt);const bt=!V||ft,Mt=((Tt,Ft)=>{const Zt=Ft===dt&&Tt.getStemDirection()===B.UP||Ft===mt&&Tt.getStemDirection()===B.DOWN;return Vt(Tt)?Tt.hasStem()&&Zt?.5:1:Tt.hasStem()&&Zt?1:0})(i,M);let _t={[dt]:()=>{I.setOrigin(.5,1);const Tt=((Ft,Zt)=>{const Yt=Ft.getStave(),ee=Ft.getStemDirection(),{topY:ne,baseY:he}=Ft.getStemExtents();if(Vt(Ft))return Ft.hasStem()?ee===B.UP?ne:he:Math.min(...Ft.getYs());if(Ft.getCategory()==="tabnotes")return Ft.hasStem()&&ee===B.UP?ne:Yt.getYForTopText(Zt);throw new d.RERR("UnknownCategory","Only can get the top and bottom ys of stavenotes and tabnotes")})(i,X)-(X+Mt)*ot;return bt?Math.min(nt.getYForTopText(Nt.INITIAL_OFFSET),Tt):Tt},[mt]:()=>{I.setOrigin(.5,0);const Tt=((Ft,Zt)=>{const Yt=Ft.getStave(),ee=Ft.getStemDirection(),{topY:ne,baseY:he}=Ft.getStemExtents();if(Vt(Ft))return Ft.hasStem()?ee===B.UP?he:ne:Math.max(...Ft.getYs());if(Ft.getCategory()==="tabnotes")return Ft.hasStem()?ee===B.UP?Yt.getYForBottomText(Zt):ne:Yt.getYForBottomText(Zt);throw new d.RERR("UnknownCategory","Only can get the top and bottom ys of stavenotes and tabnotes")})(i,X)+(X+Mt)*ot;return bt?Math.max(nt.getYForBottomText(Nt.INITIAL_OFFSET),Tt):Tt}}[M]();if(this.y_shift&&(_t+=this.y_shift),!ft){const Tt=M===dt?-1:1,Ft=ft?i.positions[c].str:i.getKeyProps()[c].line,Zt=(i.getYs()[c]-_t)/ot+Ft,Yt=((ee,ne,he,me)=>{const Le=yt(Dt(ne,he),ne);return ee&&Et(Le,he)&&Le%1==0?Le+.5*-me:Le})(V,Zt,M,Tt);Et(Yt,M)&&I.setOrigin(.5,.5),_t+=Math.abs(Yt-Zt)*ot*Tt}(function(...Tt){Nt.DEBUG&&d.L("Vex.Flow.Articulation",Tt)})(`Rendering articulation at (x: ${pt}, y: ${_t})`),I.render(Z,pt,_t)}}class It extends tt{static get CATEGORY(){return"ornaments"}static format(i,c){if(!i||i.length===0)return!1;let M=0;for(let I=0;I0&&I--;for(let nt=0;nt{Ut("Preformatting ModifierContext: ",i.CATEGORY),i.format(this.getModifiers(i.CATEGORY),this.state,this)}),this.width=this.state.left_shift+this.state.right_shift,this.preFormatted=!0)}postFormat(){this.postFormatted||this.POSTFORMAT.forEach(i=>{Ut("Postformatting ModifierContext: ",i.CATEGORY),i.postFormat(this.getModifiers(i.CATEGORY),this)})}}function qt(vt,i,c,M){let I=i;for(c+=1;c{if(nt.getMode()===U.Mode.STRICT&&!nt.isComplete())throw new d.RERR("IncompleteVoice","Voice does not have enough notes.");return Math.max(Z,l.LCM(Z,nt.getResolutionMultiplier()))},1),I={},V=[],X=[];return vt.forEach(Z=>{const nt=new l(0,M);Z.getTickables().forEach(ot=>{const ft=nt.numerator;if(!I[ft]){const pt=new i;X.push(pt),I[ft]=pt}c(ot,I[ft]),V.push(ft),nt.add(ot.getTicks())})}),{map:I,array:X,list:d.SortAndUnique(V,(Z,nt)=>Z-nt,(Z,nt)=>Z===nt),resolutionMultiplier:M}}class te{static SimpleFormat(i,c=0,{paddingBetween:M=10}={}){i.reduce((I,V)=>{V.addToModifierContext(new Kt);const X=new it().addTickable(V).preFormat(),Z=X.getExtraPx();return X.setX(I+Z.left),I+X.getWidth()+Z.right+M},c)}static plotDebugging(i,c,M,I,V){const X=M+$.STAVEPADDING,Z=c.contextGaps;i.save(),i.setFont("Arial",8,""),Z.gaps.forEach(nt=>{var ot,ft,pt;ot=X+nt.x1,ft=X+nt.x2,pt="#aaa",i.beginPath(),i.setStrokeStyle(pt),i.setFillStyle(pt),i.setLineWidth(1),i.fillRect(ot,I,ft-ot,V-I),i.fillText(Math.round(nt.x2-nt.x1),X+nt.x1,V+12)}),i.fillText(Math.round(Z.total)+"px",X-20,V+12),i.setFillStyle("red"),i.fillText("Loss: "+c.lossHistory.map(nt=>Math.round(nt)),X-20,V+22),i.restore()}static FormatAndDraw(i,c,M,I){const V={auto_beam:!1,align_rests:!1};typeof I=="object"?d.Merge(V,I):typeof I=="boolean"&&(V.auto_beam=I);const X=new U(v.TIME4_4).setMode(U.Mode.SOFT).addTickables(M),Z=V.auto_beam?G.applyAndGetBeams(X):[];return new te().joinVoices([X],{align_rests:V.align_rests}).formatToStave([X],c,{align_rests:V.align_rests,stave:c}),X.setStave(c).draw(i,c),Z.forEach(nt=>nt.setContext(i).draw()),X.getBoundingBox()}static FormatAndDrawTab(i,c,M,I,V,X,Z){const nt={auto_beam:X,align_rests:!1};typeof Z=="object"?d.Merge(nt,Z):typeof Z=="boolean"&&(nt.auto_beam=Z);const ot=new U(v.TIME4_4).setMode(U.Mode.SOFT).addTickables(V),ft=new U(v.TIME4_4).setMode(U.Mode.SOFT).addTickables(I),pt=nt.auto_beam?G.applyAndGetBeams(ot):[];new te().joinVoices([ot],{align_rests:nt.align_rests}).joinVoices([ft]).formatToStave([ot,ft],M,{align_rests:nt.align_rests}),ot.draw(i,M),ft.draw(i,c),pt.forEach(gt=>gt.setContext(i).draw()),new z(M,c).setContext(i).draw()}static AlignRestsToNotes(i,c,M){return i.forEach((I,V)=>{if(I instanceof ct&&I.isRest()){if(I.tuplet&&!M)return;const X=I.getGlyph().position.toUpperCase();if(X!=="R/4"&&X!=="B/4")return;if(c||I.beam!=null){const Z=I.getKeyProps()[0];if(V===0)Z.line=qt(i,Z.line,V,!1),I.setKeyLine(0,Z.line);else if(V>0&&Vte.AlignRestsToNotes(M.getTickables(),c))}preCalculateMinTotalWidth(i){if(this.hasMinTotalWidth)return this.minTotalWidth;if(!this.tickContexts){if(!i)throw new d.RERR("BadArgument","'voices' required to run preCalculateMinTotalWidth");this.createTickContexts(i)}const{list:c,map:M}=this.tickContexts;return this.minTotalWidth=c.map(I=>{const V=M[I];return V.preFormat(),V.getWidth()}).reduce((I,V)=>I+V,0),this.hasMinTotalWidth=!0,this.minTotalWidth}getMinTotalWidth(){if(!this.hasMinTotalWidth)throw new d.RERR("NoMinTotalWidth","Call 'preCalculateMinTotalWidth' or 'preFormat' before calling 'getMinTotalWidth'");return this.minTotalWidth}createModifierContexts(i){const c=Qt(i,Kt,(M,I)=>M.addToModifierContext(I));return this.modiferContexts=c,c}createTickContexts(i){const c=Qt(i,it,(M,I)=>I.addTickable(M));return c.array.forEach(M=>{M.tContexts=c.array}),this.totalTicks=i[0].getTicksUsed().clone(),this.tickContexts=c,c}preFormat(i=0,c,M,I){const V=this.tickContexts,{list:X,map:Z,resolutionMultiplier:nt}=V;M&&I&&M.forEach(Tt=>Tt.setStave(I).preFormat());let ot=0,ft=0;const pt=i/2;if(this.minTotalWidth=0,X.forEach(Tt=>{const Ft=Z[Tt];c&&Ft.setContext(c),Ft.preFormat();const Zt=Ft.getWidth();this.minTotalWidth+=Zt;const Yt=Ft.getMetrics();ot=ot+ft+Yt.extraLeftPx,Ft.setX(ot),ft=Zt-Yt.extraLeftPx}),this.minTotalWidth=ot+ft,this.hasMinTotalWidth=!0,i<=0)return;const gt=i-this.minTotalWidth;let bt=this.totalTicks.value();bt===0&&(bt=1);const Mt=gt/(bt*nt);let _t=0;X.forEach((Tt,Ft)=>{const Zt=X[Ft-1]||0,Yt=Z[Tt];_t+=(Tt-Zt)*Mt,Yt.setX(Yt.getX()+_t),Yt.getCenterAlignedTickables().forEach(ee=>{ee.center_x_shift=pt-Yt.getX()})}),X.length!==1&&(this.justifyWidth=i,this.lossHistory=[],this.evaluate())}evaluate(){const i=this.justifyWidth;this.contextGaps={total:0,gaps:[]},this.tickContexts.list.forEach((I,V)=>{if(V===0)return;const X=this.tickContexts.list[V-1],Z=this.tickContexts.map[X],nt=this.tickContexts.map[I],ot=Z.getMetrics(),ft=Z.getX()+ot.width,pt=nt.getX(),gt=pt-ft;this.contextGaps.total+=gt,this.contextGaps.gaps.push({x1:ft,x2:pt}),nt.getFormatterMetrics().freedom.left=gt,Z.getFormatterMetrics().freedom.right=gt});const c=this.durationStats={};this.voices.forEach(I=>{I.getTickables().forEach((V,X,Z)=>{const nt=V.getTicks().clone().simplify().toString(),ot=V.getMetrics(),ft=V.getFormatterMetrics(),pt=V.getX()+ot.noteWidth+ot.modRightPx+ot.extraRightPx;let gt=0;if(X{I.getTickables().forEach(V=>{const X=V.getTicks().clone().simplify().toString(),Z=V.getFormatterMetrics();Z.iterations+=1,Z.space.deviation=Z.space.used-c[X].mean,Z.duration=X,Z.space.mean=c[X].mean,M+=Math.pow(c[X].mean,2)})}),this.totalCost=Math.sqrt(M),this.lossHistory.push(this.totalCost),this}tune(){let i=0;return this.tickContexts.list.forEach((c,M,I)=>{const V=this.tickContexts.map[c],X=M>0?this.tickContexts.map[I[M-1]]:null,Z=Mft.getFormatterMetrics().space.deviation).reduce((ft,pt)=>ft+pt);nt>0?i=-Math.min(V.getFormatterMetrics().freedom.right,Math.abs(nt)):nt<0&&(i=Z?Math.min(Z.getFormatterMetrics().freedom.right,Math.abs(nt)):0);const ot=Math.min(5,Math.abs(i));i=i>0?ot:-ot}),this.evaluate()}postFormat(){const i=c=>c.list.forEach(M=>c.map[M].postFormat());return i(this.modiferContexts),i(this.tickContexts),this}joinVoices(i){return this.createModifierContexts(i),this.hasMinTotalWidth=!1,this}format(i,c,M){const I={align_rests:!1,context:null,stave:null};return d.Merge(I,M),this.voices=i,this.alignRests(i,I.align_rests),this.createTickContexts(i),this.preFormat(c,I.context,i,I.stave),I.stave&&this.postFormat(),this}formatToStave(i,c,M){const I=c.getNoteEndX()-c.getNoteStartX()-10;(function(...X){te.DEBUG&&d.L("Vex.Flow.Formatter",X)})("Formatting voices to width: ",I);const V={context:c.getContext()};return d.Merge(V,M),this.format(i,I,V)}}class ie extends h{static get Position(){return{LEFT:1,RIGHT:2,ABOVE:3,BELOW:4,BEGIN:5,END:6}}constructor(){super(),this.setAttribute("type","StaveModifier"),this.padding=10,this.position=ie.Position.ABOVE,this.layoutMetrics=null}getPosition(){return this.position}setPosition(i){return this.position=i,this}getStave(){return this.stave}setStave(i){return this.stave=i,this}getWidth(){return this.width}setWidth(i){return this.width=i,this}getX(){return this.x}setX(i){return this.x=i,this}getCategory(){return""}makeSpacer(i){return{getContext:()=>!0,setStave(){},renderToStave(){},getMetrics:()=>({width:i})}}placeGlyphOnLine(i,c,M){i.setYShift(c.getYForLine(M)-c.getYForGlyphs())}getPadding(i){return i!==void 0&&i<2?0:this.padding}setPadding(i){return this.padding=i,this}setLayoutMetrics(i){return this.layoutMetrics=i,this}getLayoutMetrics(){return this.layoutMetrics}}class $t extends ie{static get CATEGORY(){return"barlines"}static get type(){return{SINGLE:1,DOUBLE:2,END:3,REPEAT_BEGIN:4,REPEAT_END:5,REPEAT_BOTH:6,NONE:7,DOUBLE_HEAVY:8}}static get typeString(){return{single:$t.type.SINGLE,double:$t.type.DOUBLE,doubleheavy:$t.type.DOUBLE_HEAVY,end:$t.type.END,repeatBegin:$t.type.REPEAT_BEGIN,repeatEnd:$t.type.REPEAT_END,repeatBoth:$t.type.REPEAT_BOTH,none:$t.type.NONE}}constructor(i){super(),this.setAttribute("type","Barline"),this.thickness=v.STAVE_LINE_THICKNESS;const c=$t.type;this.widths={},this.widths[c.SINGLE]=5,this.widths[c.DOUBLE]=5,this.widths[c.DOUBLE_HEAVY]=5,this.widths[c.END]=5,this.widths[c.REPEAT_BEGIN]=5,this.widths[c.REPEAT_END]=5,this.widths[c.REPEAT_BOTH]=5,this.widths[c.NONE]=5,this.paddings={},this.paddings[c.SINGLE]=0,this.paddings[c.DOUBLE]=0,this.paddings[c.DOUBLE_HEAVY]=0,this.paddings[c.END]=5,this.paddings[c.REPEAT_BEGIN]=10,this.paddings[c.REPEAT_END]=10,this.paddings[c.REPEAT_BOTH]=15,this.paddings[c.NONE]=0,this.layoutMetricsMap={},this.layoutMetricsMap[c.SINGLE]={xMin:0,xMax:1,paddingLeft:5,paddingRight:5},this.layoutMetricsMap[c.DOUBLE]={xMin:-3,xMax:1,paddingLeft:5,paddingRight:5},this.layoutMetricsMap[c.DOUBLE_HEAVY]={xMin:-5,xMax:4,paddingLeft:5,paddingRight:5},this.layoutMetricsMap[c.END]={xMin:-5,xMax:1,paddingLeft:5,paddingRight:5},this.layoutMetricsMap[c.REPEAT_END]={xMin:-10,xMax:1,paddingLeft:5,paddingRight:5},this.layoutMetricsMap[c.REPEAT_BEGIN]={xMin:-2,xMax:10,paddingLeft:5,paddingRight:5},this.layoutMetricsMap[c.REPEAT_BOTH]={xMin:-10,xMax:10,paddingLeft:5,paddingRight:5},this.layoutMetricsMap[c.NONE]={xMin:0,xMax:0,paddingLeft:5,paddingRight:5},this.setPosition(ie.Position.BEGIN),this.setType(i)}getCategory(){return $t.CATEGORY}getType(){return this.type}setType(i){return this.type=typeof i=="string"?$t.typeString[i]:i,this.setWidth(this.widths[this.type]),this.setPadding(this.paddings[this.type]),this.setLayoutMetrics(this.layoutMetricsMap[this.type]),this}draw(i){switch(i.checkContext(),this.setRendered(),this.type){case $t.type.SINGLE:this.drawVerticalBar(i,this.x,!1);break;case $t.type.DOUBLE:this.drawVerticalBar(i,this.x,!0);break;case $t.type.DOUBLE_HEAVY:this.drawVerticalBar(i,this.x,!0,!0);break;case $t.type.END:this.drawVerticalEndBar(i,this.x);break;case $t.type.REPEAT_BEGIN:this.drawRepeatBar(i,this.x,!0),i.getX()!==this.x&&this.drawVerticalBar(i,i.getX());break;case $t.type.REPEAT_END:this.drawRepeatBar(i,this.x,!1);break;case $t.type.REPEAT_BOTH:this.drawRepeatBar(i,this.x,!1),this.drawRepeatBar(i,this.x,!0)}}drawVerticalBar(i,c,M,I){i.checkContext();const V=i.getTopLineTopY(),X=i.getBottomLineBottomY();let Z=1,nt=1,ot=c-3,ft=c;I&&(Z=3,nt=3,ot=c-5,ft=c),M&&i.context.fillRect(ot,V,Z,X-V),i.context.fillRect(ft,V,nt,X-V)}drawVerticalEndBar(i,c){i.checkContext();const M=i.getTopLineTopY(),I=i.getBottomLineBottomY();i.context.fillRect(c-5,M,1,I-M),i.context.fillRect(c-2,M,3,I-M)}drawRepeatBar(i,c,M){i.checkContext();const I=i.getTopLineTopY(),V=i.getBottomLineBottomY();let X=3;M||(X=-5),i.context.fillRect(c+X,I,1,V-I),i.context.fillRect(c-2,I,3,V-I),M?X+=4:X-=4;const Z=c+X+1;let nt=(i.getNumLines()-1)*i.getSpacingBetweenLines();nt=nt/2-i.getSpacingBetweenLines()/2;let ot=I+nt+1;i.context.beginPath(),i.context.arc(Z,ot,2,0,2*Math.PI,!1),i.context.fill(),ot+=i.getSpacingBetweenLines(),i.context.beginPath(),i.context.arc(Z,ot,2,0,2*Math.PI,!1),i.context.fill()}}class ae extends ie{static get CATEGORY(){return"repetitions"}static get type(){return{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}}constructor(i,c,M){super(),this.setAttribute("type","Repetition"),this.symbol_type=i,this.x=c,this.x_shift=0,this.y_shift=M,this.font={family:"times",size:12,weight:"bold italic"}}getCategory(){return ae.CATEGORY}setShiftX(i){return this.x_shift=i,this}setShiftY(i){return this.y_shift=i,this}setX(i){return this.x=i,this}draw(i,c){switch(this.setRendered(),this.symbol_type){case ae.type.CODA_RIGHT:this.drawCodaFixed(i,c+i.width);break;case ae.type.CODA_LEFT:this.drawSymbolText(i,c,"Coda",!0);break;case ae.type.SEGNO_LEFT:this.drawSignoFixed(i,c);break;case ae.type.SEGNO_RIGHT:this.drawSignoFixed(i,c+i.width);break;case ae.type.DC:this.drawSymbolText(i,c,"D.C.",!1);break;case ae.type.DC_AL_CODA:this.drawSymbolText(i,c,"D.C. al",!0);break;case ae.type.DC_AL_FINE:this.drawSymbolText(i,c,"D.C. al Fine",!1);break;case ae.type.DS:this.drawSymbolText(i,c,"D.S.",!1);break;case ae.type.DS_AL_CODA:this.drawSymbolText(i,c,"D.S. al",!0);break;case ae.type.DS_AL_FINE:this.drawSymbolText(i,c,"D.S. al Fine",!1);break;case ae.type.FINE:this.drawSymbolText(i,c,"Fine",!1);break;case ae.type.TO_CODA:this.drawSymbolText(i,c,"To",!0)}return this}drawCodaFixed(i,c){const M=i.getYForTopText(i.options.num_lines)+this.y_shift;return S.renderGlyph(i.context,this.x+c+this.x_shift,M+25,40,"v4d",!0),this}drawSignoFixed(i,c){const M=i.getYForTopText(i.options.num_lines)+this.y_shift;return S.renderGlyph(i.context,this.x+c+this.x_shift,M+25,30,"v8c",!0),this}drawSymbolText(i,c,M,I){const V=i.checkContext();V.save(),V.setFont(this.font.family,this.font.size,this.font.weight);let X=0+this.x_shift,Z=c+this.x_shift;if(this.symbol_type===ae.type.CODA_LEFT?(X=this.x+this.x_shift,Z=X+V.measureText(M).width+12):(this.x_shift=-(X+V.measureText(M).width+12+i.options.vertical_bar_width+12),X=this.x+this.x_shift+i.options.vertical_bar_width,Z=X+V.measureText(M).width+12),this.xShiftAsPercentOfStaveWidth){const ot=i.width*this.xShiftAsPercentOfStaveWidth;this.symbol_type!==ae.type.DC_AL_FINE&&this.symbol_type!==ae.type.FINE&&this.symbol_type!==ae.type.DC&&this.symbol_type!==ae.type.DS_AL_FINE&&this.symbol_type!==ae.type.DS&&this.symbol_type!==ae.type.FINE||(X+=ot)}const nt=i.getYForTopText(i.options.num_lines)+this.y_shift+25;return I&&S.renderGlyph(V,Z,nt,40,"v4d",!0),V.fillText(M,X,nt+5),V.restore(),this}}class Ke extends ie{static get CATEGORY(){return"stavesection"}constructor(i,c,M){super(),this.setAttribute("type","StaveSection"),this.setWidth(16),this.section=i,this.x=c,this.shift_x=0,this.shift_y=M,this.font={family:"sans-serif",size:12,weight:"bold"}}getCategory(){return Ke.CATEGORY}setStaveSection(i){return this.section=i,this}setShiftX(i){return this.shift_x=i,this}setShiftY(i){return this.shift_y=i,this}draw(i,c){const M=i.checkContext();this.setRendered(),M.save(),M.lineWidth=2,M.setFont(this.font.family,this.font.size,this.font.weight);const I=M.measureText(""+this.section),V=I.width;let X=I.height;!X&&I.emHeightAscent>=0&&(X=I.emHeightAscent+2),X||(X=I.fontBoundingBoxAscent+3);let Z=V+6;Z<18&&(Z=18);const nt=X+this.font.size/10,ot=i.getYForTopText(3)+19-1.15*nt+this.shift_y;let ft=this.x+c;return M.beginPath(),M.lineWidth=2,M.rect(ft,ot+X/4,Z,nt),M.stroke(),ft+=(Z-V)/2,M.fillText(""+this.section,ft,ot+nt),M.restore(),this}}class De extends ie{static get CATEGORY(){return"stavetempo"}constructor(i,c,M){super(),this.setAttribute("type","StaveTempo"),this.tempo=i,this.position=tt.Position.ABOVE,this.x=c,this.shift_x=10,this.shift_y=M,this.font={family:"times",size:14,weight:"bold"},this.render_options={glyph_font_scale:30}}getCategory(){return De.CATEGORY}setTempo(i){return this.tempo=i,this}setShiftX(i){return this.shift_x=i,this}setShiftY(i){return this.shift_y=i,this}draw(i,c){const M=i.checkContext();this.setRendered(),M.openGroup("stavetempo");const I=this.render_options,V=I.glyph_font_scale/38,X=this.tempo.name,Z=this.tempo.duration,nt=this.tempo.dots,ot=this.tempo.bpm,ft=this.tempo.noteEquation,pt=this.font;let gt=this.x+this.shift_x+c;const bt=i.getYForTopText(1)+this.shift_y;if(M.save(),X&&(M.setFont(pt.family,pt.size,pt.weight),M.fillText(X,gt,bt),gt+=M.measureText(X).width),ft)gt=this.drawNoteEquation(M,gt,bt,V,ft);else if(Z&&ot){M.setFont(pt.family,pt.size,"normal"),X&&(gt+=M.measureText(" ").width,M.fillText("(",gt,bt),gt+=M.measureText("(").width);const Mt=v.getGlyphProps(Z);if(gt+=3*V,S.renderGlyph(M,gt,bt,I.glyph_font_scale,Mt.code_head),gt+=Mt.getWidth()*V,Mt.stem){let _t=30;Mt.beam_count&&(_t+=3*(Mt.beam_count-1)),_t*=V;const Tt=bt-_t;M.fillRect(gt-V,Tt,V,_t),Mt.flag&&(S.renderGlyph(M,gt,Tt,I.glyph_font_scale,Mt.code_flag_upstem),nt||(gt+=6*V))}for(let _t=0;_t0){const Mt=ft[0],_t=ft[ft.length-1];let Tt=Mt.y_top;for(const ne of ft)Tt=Math.min(Tt,ne.y_top);const Ft=1.25*V,Zt=Tt-1.5*V,Yt=Mt.x-.5*V,ee=_t.stemX+Ft;if(ot.bracket){const ne=V;i.beginPath(),i.moveTo(Yt,Zt+ne),i.lineTo(Yt,Zt);const he=(Yt+ee)/2,me=ot.showNumber==="both"?`${ot.actualNotes}:${ot.normalNotes}`:`${ot.actualNotes}`;i.setFont(this.font.family,this.font.size-3,"bold");const Le=i.measureText(me).width,Ee=Le/2+2*I;i.lineTo(he-Ee,Zt),i.stroke(),i.beginPath(),i.moveTo(he+Ee,Zt),i.lineTo(ee,Zt),i.lineTo(ee,Zt+ne),i.stroke(),i.fillText(me,he-Le/2,Zt-1*I)}else if(ot.showNumber!=="none"){const ne=(Yt+ee)/2,he=ot.showNumber==="both"?`${ot.actualNotes}:${ot.normalNotes}`:`${ot.actualNotes}`;i.setFont(this.font.family,this.font.size-3,"bold");const me=i.measureText(he).width;i.fillText(he,ne-me/2,Zt-1*I)}}return c}}class Xe extends ${static get Justification(){return{LEFT:1,CENTER:2,RIGHT:3}}static get GLYPHS(){return{segno:{code:"v8c",point:40,x_shift:0,y_shift:-10},tr:{code:"v1f",point:40,x_shift:0,y_shift:0},mordent_upper:{code:"v1e",point:40,x_shift:0,y_shift:0},mordent_lower:{code:"v45",point:40,x_shift:0,y_shift:0},f:{code:"vba",point:40,x_shift:0,y_shift:0},p:{code:"vbf",point:40,x_shift:0,y_shift:0},m:{code:"v62",point:40,x_shift:0,y_shift:0},s:{code:"v4a",point:40,x_shift:0,y_shift:0},z:{code:"v80",point:40,x_shift:0,y_shift:0},coda:{code:"v4d",point:40,x_shift:0,y_shift:-8},pedal_open:{code:"v36",point:40,x_shift:0,y_shift:0},pedal_close:{code:"v5d",point:40,x_shift:0,y_shift:3},caesura_straight:{code:"v34",point:40,x_shift:0,y_shift:2},caesura_curved:{code:"v4b",point:40,x_shift:0,y_shift:2},breath:{code:"v6c",point:40,x_shift:0,y_shift:0},tick:{code:"v6f",point:50,x_shift:0,y_shift:0},turn:{code:"v72",point:40,x_shift:0,y_shift:0},turn_inverted:{code:"v33",point:40,x_shift:0,y_shift:0},mordent:{code:"v1e",point:40,x_shift:0,y_shift:0}}}constructor(i){if(super(i),this.setAttribute("type","TextNote"),this.text=i.text,this.superscript=i.superscript,this.subscript=i.subscript,this.glyph_type=i.glyph,this.glyph=null,this.font={family:"Arial",size:12,weight:""},i.font&&(this.font=i.font),this.glyph_type){const c=Xe.GLYPHS[this.glyph_type];if(!c)throw new d.RERR("Invalid glyph type: "+this.glyph_type);this.glyph=new S(c.code,c.point,{cache:!1}),c.width?this.setWidth(c.width):this.setWidth(this.glyph.getMetrics().width),this.glyph_struct=c}else this.setWidth(v.textWidth(this.text));this.line=i.line||0,this.smooth=i.smooth||!1,this.ignore_ticks=i.ignore_ticks||!1,this.justification=Xe.Justification.LEFT}setJustification(i){return this.justification=i,this}setLine(i){return this.line=i,this}preFormat(){this.checkContext(),this.preFormatted||(this.smooth?this.setWidth(0):this.glyph||this.setWidth(this.context.measureText(this.text).width),this.justification===Xe.Justification.CENTER?this.extraLeftPx=this.width/2:this.justification===Xe.Justification.RIGHT&&(this.extraLeftPx=this.width),this.setPreFormatted(!0))}draw(){if(this.checkContext(),!this.stave)throw new d.RERR("NoStave","Can't draw without a stave.");this.setRendered();const i=this.context;let c,M=this.getAbsoluteX();if(this.justification===Xe.Justification.CENTER?M-=this.getWidth()/2:this.justification===Xe.Justification.RIGHT&&(M-=this.getWidth()),this.glyph)c=this.stave.getYForLine(this.line+-3),this.glyph.render(this.context,M+this.glyph_struct.x_shift,c+this.glyph_struct.y_shift);else{c=this.stave.getYForLine(this.line+-3),this.applyStyle(i),i.setFont(this.font.family,this.font.size,this.font.weight),i.fillText(this.text,M,c);const I=i.measureText("M").width,V=i.measureText(this.text).width;this.superscript&&(i.setFont(this.font.family,this.font.size/1.3,this.font.weight),i.fillText(this.superscript,M+V+2,c-I/2.2)),this.subscript&&(i.setFont(this.font.family,this.font.size/1.3,this.font.weight),i.fillText(this.subscript,M+V+2,c+I/2.2-1)),this.restoreStyle(i)}}}class Pi extends ie{static get CATEGORY(){return"stavetext"}constructor(i,c,M){super(),this.setAttribute("type","StaveText"),this.setWidth(16),this.text=i,this.position=c,this.options={shift_x:0,shift_y:0,justification:Xe.Justification.CENTER},d.Merge(this.options,M),this.font={family:"times",size:16,weight:"normal"}}getCategory(){return Pi.CATEGORY}setStaveText(i){return this.text=i,this}setShiftX(i){return this.shift_x=i,this}setShiftY(i){return this.shift_y=i,this}setFont(i){d.Merge(this.font,i)}setText(i){this.text=i}draw(i){const c=i.checkContext();this.setRendered(),c.save(),c.lineWidth=2,c.setFont(this.font.family,this.font.size,this.font.weight);const M=c.measureText(""+this.text).width;let I,V;const X=ie.Position,Z=Xe.Justification;switch(this.position){case X.LEFT:case X.RIGHT:V=(i.getYForLine(0)+i.getBottomLineY())/2+this.options.shift_y,I=this.position===X.LEFT?i.getX()-M-24+this.options.shift_x:i.getX()+i.getWidth()+24+this.options.shift_x;break;case X.ABOVE:case X.BELOW:I=i.getX()+this.options.shift_x,this.options.justification===Z.CENTER?I+=i.getWidth()/2-M/2:this.options.justification===Z.RIGHT&&(I+=i.getWidth()-M),V=this.position===X.ABOVE?i.getYForTopText(2)+this.options.shift_y:i.getYForBottomText(2)+this.options.shift_y;break;default:throw new d.RERR("InvalidPosition","Value Must be in Modifier.Position.")}return c.fillText(""+this.text,I,V+4),c.restore(),this}}class oi extends ie{static get CATEGORY(){return"clefs"}static get types(){return{treble:{code:"v83",line:3},bass:{code:"v79",line:1},alto:{code:"vad",line:2},tenor:{code:"vad",line:1},percussion:{code:"v59",line:2},soprano:{code:"vad",line:4},"mezzo-soprano":{code:"vad",line:3},"baritone-c":{code:"vad",line:0},"baritone-f":{code:"v79",line:2},subbass:{code:"v79",line:0},french:{code:"v83",line:4},tab:{code:"v2f"}}}static get sizes(){return{default:{point:40,width:26},small:{point:32,width:20}}}static get annotations(){return{"8va":{code:"v8",sizes:{default:{point:20,attachments:{treble:{line:-1.2,x_shift:11}}},small:{point:18,attachments:{treble:{line:-.4,x_shift:8}}}}},"8vb":{code:"v8",sizes:{default:{point:20,attachments:{treble:{line:6.3,x_shift:10},bass:{line:4,x_shift:1}}},small:{point:18,attachments:{treble:{line:5.8,x_shift:6},bass:{line:3.5,x_shift:.5}}}}}}}constructor(i,c,M){super(),this.setAttribute("type","Clef"),this.setPosition(ie.Position.BEGIN),this.setType(i,c,M),this.setWidth(oi.sizes[this.size].width),(function(...I){oi.DEBUG&&d.L("Vex.Flow.Clef",I)})("Creating clef:",i)}getCategory(){return oi.CATEGORY}setType(i,c,M){if(this.type=i,this.clef=oi.types[i],this.size=c===void 0?"default":c,this.clef.point=oi.sizes[this.size].point,this.glyph=new S(this.clef.code,this.clef.point),M!==void 0){const I=oi.annotations[M];this.annotation={code:I.code,point:I.sizes[this.size].point,line:I.sizes[this.size].attachments[this.type].line,x_shift:I.sizes[this.size].attachments[this.type].x_shift},this.attachment=new S(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(){if(this.type==="tab"&&!this.stave)throw new d.RERR("ClefError","Can't get width without stave.");return this.width}setStave(i){if(this.stave=i,this.type!=="tab")return this;let c,M;const I=this.stave.getOptions().num_lines;switch(I){case 8:c=55,M=14;break;case 7:c=47,M=8;break;case 6:c=40,M=1;break;case 5:c=30,M=-6;break;case 4:c=23,M=-12;break;case 3:c=16,M=-18;break;default:throw new d.RERR("ClefError",`Invalid number of lines: ${I}`)}return this.glyph.setPoint(c),this.glyph.setYShift(M),this}draw(){if(!this.x)throw new d.RERR("ClefError","Can't draw clef without x.");if(!this.stave)throw new d.RERR("ClefError","Can't draw clef without stave.");this.setRendered(),this.glyph.setStave(this.stave),this.glyph.setContext(this.stave.context),this.clef.line!==void 0&&this.placeGlyphOnLine(this.glyph,this.stave,this.clef.line),this.stave.context.openGroup("clef"),this.glyph.renderToStave(this.x),this.annotation!==void 0&&(this.placeGlyphOnLine(this.attachment,this.stave,this.annotation.line),this.attachment.setStave(this.stave),this.attachment.setContext(this.stave.context),this.attachment.renderToStave(this.x)),this.stave.context.closeGroup()}}class we extends ie{static get CATEGORY(){return"keysignatures"}static get accidentalSpacing(){return{"#":{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}}}constructor(i,c,M){super(),this.setAttribute("type","KeySignature"),this.setKeySig(i,c,M),this.setPosition(ie.Position.BEGIN),this.glyphFontScale=38,this.glyphs=[],this.xPositions=[],this.paddingForced=!1}getCategory(){return we.CATEGORY}convertToGlyph(i,c){const M=v.accidentalCodes(i.type),I=new S(M.code,this.glyphFontScale);let V=1;if(i.type==="n"&&c){const nt=we.accidentalSpacing[c.type];nt&&(V=c.line>=i.line?nt.above:nt.below)}this.placeGlyphOnLine(I,this.stave,i.line),this.glyphs.push(I);const X=this.xPositions[this.xPositions.length-1],Z=I.getMetrics().width+V;this.xPositions.push(X+Z),this.width+=Z}cancelKey(i){return this.formatted=!1,this.cancelKeySpec=i,this}convertToCancelAccList(i){const c=v.keySignature(i),M=this.accList.length>0&&c.length>0&&c[0].type!==this.accList[0].type,I=M?c.length:c.length-this.accList.length;if(I<1)return;const V=[];for(let X=0;X0?i[0].type:null;let M;if(this.cancelKeySpec&&(M=this.convertToCancelAccList(this.cancelKeySpec)),this.alterKeySpec&&this.convertToAlterAccList(this.alterKeySpec),this.accList.length>0){const I=(this.position===ie.Position.END?this.stave.endClef:this.stave.clef)||this.stave.clef;M&&this.convertAccLines(I,M.type,M.accList),this.convertAccLines(I,c,i);for(let V=0;V0){const i=this.stave.context.openGroup("keysignature");for(let c=0;c{const V=I.split("/").filter(X=>X!=="");if(V.length!==2)throw new d.RERR("BadTimeSignature",`Invalid time spec: ${I}. Must be in the form "/"`);V.forEach(X=>{if(isNaN(Number(X)))throw new d.RERR("BadTimeSignature",`Invalid time spec: ${I}. Must contain two valid numbers.`)})})(i);const[c,M]=i.split("/").map(I=>I.split(""));return{num:!0,glyph:this.makeTimeSignatureGlyph(c,M)}}makeTimeSignatureGlyph(i,c){const M=new S("v0",this.point);M.topGlyphs=[],M.botGlyphs=[];let I=0;for(let pt=0;ptV?I:V,Z=M.getMetrics().x_min;M.getMetrics=()=>({x_min:Z,x_max:Z+X,width:X});const nt=(X-I)/2,ot=(X-V)/2,ft=this;return M.renderToStave=function(pt){let gt=pt+nt;for(let bt=0;bt{M.getNoteStartX()>c&&(c=M.getNoteStartX())}),i.forEach(M=>{M.setNoteStartX(c)}),c=0,i.forEach(M=>{M.getModifiers(ie.Position.BEGIN,$t.CATEGORY).forEach(I=>{I.getType()==$t.type.REPEAT_BEGIN&&I.getX()>c&&(c=I.getX())})}),i.forEach(M=>{M.getModifiers(ie.Position.BEGIN,$t.CATEGORY).forEach(I=>{I.getType()==$t.type.REPEAT_BEGIN&&I.setX(c)})}),c=0,i.forEach(M=>{M.getModifiers(ie.Position.BEGIN,Ge.CATEGORY).forEach(I=>{I.getX()>c&&(c=I.getX())})}),i.forEach(M=>{M.getModifiers(ie.Position.BEGIN,Ge.CATEGORY).forEach(I=>{I.setX(c)})})}getOptions(){return this.options}setNoteStartX(i){return this.formatted||this.format(),this.setStartX(i),this}setStartX(i){this.start_x=i}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.x+this.width}getX(){return this.x}getNumLines(){return this.options.num_lines}setNumLines(i){return this.options.num_lines=parseInt(i,10),this.resetLines(),this}setY(i){return this.y=i,this}getTopLineTopY(){return this.getYForLine(0)-v.STAVE_LINE_THICKNESS/2}getBottomLineBottomY(){return this.getYForLine(this.getNumLines()-1)+v.STAVE_LINE_THICKNESS/2}setX(i){const c=i-this.x;this.formatted=!1,this.x=i,this.start_x+=c,this.end_x+=c;for(let M=0;MM.getWidth()&&(c-=M.getWidth()),c}setRepetitionTypeLeft(i,c){return this.modifiers.push(new ae(i,this.x,c)),this}setRepetitionTypeRight(i,c){return this.modifiers.push(new ae(i,this.x,c)),this}setVoltaType(i,c,M){return this.modifiers.push(new xi(i,c,this.x,M)),this}setSection(i,c,M=0,I=12){const V=new Ke(i,this.x+M,c);return V.font.size=I,this.modifiers.push(V),this}setTempo(i,c){return this.modifiers.push(new De(i,this.x,c)),this}setText(i,c,M){return this.modifiers.push(new Pi(i,c,M)),this}getHeight(){return this.height}getSpacingBetweenLines(){return this.options.spacing_between_lines_px}getBoundingBox(){return new f(this.x,this.y,this.width,this.getBottomY()-this.y)}getBottomY(){const i=this.options,c=i.spacing_between_lines_px;return this.getYForLine(i.num_lines)+i.space_below_staff_ln*c}getBottomLineY(){return this.getYForLine(this.options.num_lines)}getYForLine(i){const c=this.options,M=c.spacing_between_lines_px,I=c.space_above_staff_ln;return this.y+i*M+I*M}getLineForY(i){const c=this.options,M=c.spacing_between_lines_px,I=c.space_above_staff_ln;return(i-this.y)/M-I}getYForTopText(i){const c=i||0;return this.getYForLine(-c-this.options.top_text_position)}getYForBottomText(i){const c=i||0;return this.getYForLine(this.options.bottom_text_position+c)}getYForNote(i){const c=this.options,M=c.spacing_between_lines_px,I=c.space_above_staff_ln;return this.y+I*M+5*M-i*M}getYForGlyphs(){return this.getYForLine(3)}addModifier(i,c){return c!==void 0&&i.setPosition(c),i.setStave(this),this.formatted=!1,this.modifiers.push(i),this}addEndModifier(i){return this.addModifier(i,ie.Position.END),this}setBegBarType(i){const{SINGLE:c,REPEAT_BEGIN:M,NONE:I}=$t.type;return i!==c&&i!==M&&i!==I||(this.modifiers[0].setType(i),this.formatted=!1),this}setEndBarType(i){return i!==$t.type.REPEAT_BEGIN&&(this.modifiers[1].setType(i),this.formatted=!1),this}setClef(i,c,M,I){I===void 0&&(I=ie.Position.BEGIN),I===ie.Position.END?this.endClef=i:this.clef=i;const V=this.getModifiers(I,oi.CATEGORY);return V.length===0?this.addClef(i,c,M,I):V[0].setType(i,c,M),this}setEndClef(i,c,M){return this.setClef(i,c,M,ie.Position.END),this}setKeySignature(i,c,M){M===void 0&&(M=ie.Position.BEGIN);const I=this.getModifiers(M,we.CATEGORY);return I.length===0?this.addKeySignature(i,c,M):I[0].setKeySig(i,c),this}setEndKeySignature(i,c){return this.setKeySignature(i,c,ie.Position.END),this}setTimeSignature(i,c,M){M===void 0&&(M=ie.Position.BEGIN);const I=this.getModifiers(M,Ge.CATEGORY);return I.length===0?this.addTimeSignature(i,c,M):I[0].setTimeSig(i),this}setEndTimeSignature(i,c){return this.setTimeSignature(i,c,ie.Position.END),this}addKeySignature(i,c,M){return M===void 0&&(M=ie.Position.BEGIN),this.addModifier(new we(i,c).setPosition(M),M),this}addClef(i,c,M,I){return I===void 0||I===ie.Position.BEGIN?this.clef=i:I===ie.Position.END&&(this.endClef=i),this.addModifier(new oi(i,c,M),I),this}addEndClef(i,c,M){return this.addClef(i,c,M,ie.Position.END),this}addTimeSignature(i,c,M){return this.addModifier(new Ge(i,c),M),this}addEndTimeSignature(i,c){return this.addTimeSignature(i,c,ie.Position.END),this}addTrebleGlyph(){return this.addClef("treble"),this}getModifiers(i,c){return i===void 0&&c===void 0?this.modifiers:this.modifiers.filter(M=>!(i!==void 0&&i!==M.getPosition()||c!==void 0&&c!==M.getCategory()))}sortByCategory(i,c){for(let M=i.length-1;M>=0;M--)for(let I=0;Ic[i[I+1].getCategory()]){const V=i[I];i[I]=i[I+1],i[I+1]=V}}format(){const i=this.modifiers[0],c=this.modifiers[1],M=this.getModifiers(ie.Position.BEGIN),I=this.getModifiers(ie.Position.END);let V,X,Z;this.sortByCategory(M,{barlines:0,clefs:1,keysignatures:2,timesignatures:3}),this.sortByCategory(I,{timesignatures:0,keysignatures:1,barlines:2,clefs:3}),M.length>1&&i.getType()===$t.type.REPEAT_BEGIN&&(M.push(M.splice(0,1)[0]),M.splice(0,0,new $t($t.type.SINGLE))),I.indexOf(c)>0&&I.splice(0,0,new $t($t.type.NONE));let nt=0,ot=this.x;for(let gt=0;gtot?ot=bt:Z.setX(ot),ot+=V,X+V===0&&nt--}ot>this.start_x&&this.setStartX(ot),ot=this.x+this.width;const ft={left:0,right:0,paddingRight:0,paddingLeft:0};let pt=0;for(let gt=0;gt0){this.context.save(),this.context.setFont(this.font.family,this.font.size,this.font.weight);const V=this.context.measureText(""+this.measure).width;I=this.getYForTopText(0)+3,this.context.fillText(""+this.measure,this.x-V/2,I),this.context.restore()}return this}drawVertical(i,c){this.drawVerticalFixed(this.x+i,c)}drawVerticalFixed(i,c){this.checkContext();const M=this.getYForLine(0),I=this.getYForLine(this.options.num_lines-1);c&&this.context.fillRect(i-3,M,1,I-M+1),this.context.fillRect(i,M,1,I-M+1)}drawVerticalBar(i){this.drawVerticalBarFixed(this.x+i,!1)}drawVerticalBarFixed(i){this.checkContext();const c=this.getYForLine(0),M=this.getYForLine(this.options.num_lines-1);this.context.fillRect(i,c,1,M-c+1)}getConfigForLines(){return this.options.line_config}setConfigForLine(i,c){if(i>=this.options.num_lines||i<0)throw new d.RERR("StaveConfigError","The line number must be within the range of the number of lines in the Stave.");if(c.visible===void 0)throw new d.RERR("StaveConfigError","The line configuration object is missing the 'visible' property.");if(typeof c.visible!="boolean")throw new d.RERR("StaveConfigError","The line configuration objects 'visible' property must be true or false.");return this.options.line_config[i]=c,this}setConfigForLines(i){if(i.length!==this.options.num_lines)throw new d.RERR("StaveConfigError","The length of the lines configuration array must match the number of lines in the Stave");for(const c in i)i[c]||(i[c]=this.options.line_config[c]),d.Merge(this.options.line_config[c],i[c]);return this.options.line_config=i,this}}class Re extends Ce{constructor(i,c,M,I){const V={spacing_between_lines_px:13,num_lines:6,top_text_position:1};d.Merge(V,I),super(i,c,M,V),this.setAttribute("type","TabStave")}getYForGlyphs(){return this.getYForLine(2.5)}addTabGlyph(){return this.addClef("tab"),this}}class He extends Y{static get CATEGORY(){return"tabnotes"}constructor(i,c){if(super(i),this.setAttribute("type","TabNote"),this.ghost=!1,this.positions=i.positions,d.Merge(this.render_options,{glyph_font_scale:v.DEFAULT_TABLATURE_FONT_SCALE,draw_stem:c,draw_dots:c,draw_stem_through_stave:!1,y_shift:0,scale:1,font:"10pt Arial"}),this.glyph=v.getGlyphProps(this.duration,this.noteType),!this.glyph)throw new d.RuntimeError("BadArguments",`Invalid note initialization data (No glyph found): ${JSON.stringify(i)}`);this.buildStem(),i.stem_direction?this.setStemDirection(i.stem_direction):this.setStemDirection(B.UP),this.ghost=!1,this.updateWidth()}reset(){this.stave&&this.setStave(this.stave)}getCategory(){return He.CATEGORY}setGhost(i){return this.ghost=i,this.updateWidth(),this}hasStem(){return this.render_options.draw_stem}getStemExtension(){const i=this.getGlyph();return this.stem_extension_override!=null?this.stem_extension_override:i?this.getStemDirection()===1?i.tabnote_stem_up_extension:i.tabnote_stem_down_extension:0}addDot(){const i=new H;return this.dots+=1,this.addModifier(i,0)}updateWidth(){this.glyphs=[],this.width=0;for(let i=0;ithis.width}setStave(i){let c;if(super.setStave(i),this.context=i.context,this.context){const I=this.context;for(this.width=0,c=0;cV.width),this.width=Math.max(V.getWidth(),this.width)}this.glyph.getWidth=()=>this.width}const M=this.positions.map(({str:I})=>i.getYForLine(I-1));return this.setYs(M),this.stem&&this.stem.setYBounds(this.getStemY(),this.getStemY()),this}getPositions(){return this.positions}addToModifierContext(i){this.setModifierContext(i);for(let c=0;c{(i.getCategory()!=="dots"||this.render_options.draw_dots)&&(i.setContext(this.context),i.drawWithStyle())})}drawStemThrough(){const i=this.getStemX(),c=this.getStemY(),M=this.context,I=this.render_options.draw_stem_through_stave;if(this.render_options.draw_stem&&I){const V=(function(Z,nt){const ot=[];let ft=[];for(let pt=1;pt<=Z;pt++)nt.indexOf(pt)>-1?(ot.push(ft),ft=[]):ft.push(pt);return ft.length>0&&ot.push(ft),ot})(this.stave.getNumLines(),this.positions.map(Z=>Z.str)),X=(function(Z,nt,ot,ft){const pt=ft!==1,gt=ft!==-1,bt=ot.getSpacingBetweenLines(),Mt=ot.getNumLines(),_t=[];return nt.forEach(Tt=>{const Ft=Tt.indexOf(Mt)>-1,Zt=Tt.indexOf(1)>-1;if(pt&&Zt||gt&&Ft)return;Tt.length===1&&Tt.push(Tt[0]);const Yt=[];Tt.forEach((ee,ne,he)=>{const me=ee===1,Le=ee===Mt;let Ee=ot.getYForLine(ee-1);ne!==0||me?ne!==he.length-1||Le||(Ee+=bt/2-1):Ee-=bt/2-1,Yt.push(Ee),ft===1&&me?Yt.push(Z-2):ft===-1&&Le&&Yt.push(Z+2)}),_t.push(Yt.sort((ee,ne)=>ee-ne))}),_t})(c,V,this.getStave(),this.getStemDirection());M.save(),M.setLineWidth(B.WIDTH),X.forEach(Z=>{Z.length!==0&&(M.beginPath(),M.moveTo(i,Z[0]),M.lineTo(i,Z[Z.length-1]),M.stroke(),M.closePath())}),M.restore()}}drawPositions(){var I,V;const i=this.context,c=this.getAbsoluteX(),M=this.ys;for(let X=0;X=1&&Z[0].getCategory()==="barlines"&&(V-=Z[0].getPadding()),isNaN(this.render_options.padding_left)||(I=c.getX()+this.render_options.padding_left),isNaN(this.render_options.padding_right)||(V=c.getX()+c.getWidth()-this.render_options.padding_right),this.xs.left=I,this.xs.right=V,this.render_options.use_symbols?this.drawSymbols(i,I,V,M):this.drawLine(i,I,V,M),this.render_options.show_number){const nt="/"+this.number_of_measures,ot=new Ge(null,void 0,!1);ot.point=this.render_options.number_glyph_point,ot.setTimeSig(nt),ot.setStave(c),ot.x=I+.5*(V-I)-.5*ot.timeSig.glyph.getMetrics().width,ot.bottomLine=this.render_options.number_line,ot.setContext(i).draw()}}}class nn extends ${static get CATEGORY(){return"clefnote"}constructor(i,c,M){super({duration:"b"}),this.setAttribute("type","ClefNote"),this.setType(i,c,M),this.ignore_ticks=!0}setType(i,c,M){return this.type=i,this.clef_obj=new oi(i,c,M),this.clef=this.clef_obj.clef,this.glyph=new S(this.clef.code,this.clef.point),this.setWidth(this.glyph.getMetrics().width),this}getClef(){return this.clef}setContext(i){return this.context=i,this.glyph.setContext(this.context),this}getBoundingBox(){return super.getBoundingBox()}addToModifierContext(){return this}getCategory(){return nn.CATEGORY}preFormat(){return this.setPreFormatted(!0),this}draw(){if(!this.stave)throw new d.RERR("NoStave","Can't draw without a stave.");this.glyph.getContext()||this.glyph.setContext(this.context),this.setRendered();const i=this.getAbsoluteX();if(this.glyph.setStave(this.stave),this.glyph.setYShift(this.stave.getYForLine(this.clef.line)-this.stave.getYForGlyphs()),this.glyph.renderToStave(i),this.clef_obj.annotation!==void 0){const c=new S(this.clef_obj.annotation.code,this.clef_obj.annotation.point);c.getContext()||c.setContext(this.context),c.setStave(this.stave),c.setYShift(this.stave.getYForLine(this.clef_obj.annotation.line)-this.stave.getYForGlyphs()),c.setXShift(this.clef_obj.annotation.x_shift),c.renderToStave(i)}}}class _s extends ${constructor(i,c,M){super({duration:"b"}),this.setAttribute("type","KeySigNote"),this.keySignature=new we(i,c,M),this.ignore_ticks=!0}getBoundingBox(){return super.getBoundingBox()}addToModifierContext(){return this}preFormat(){return this.setPreFormatted(!0),this.keySignature.setStave(this.stave),this.keySignature.format(),this.setWidth(this.keySignature.width),this}draw(){this.stave.checkContext(),this.setRendered(),this.keySignature.x=this.getAbsoluteX(),this.keySignature.setContext(this.context),this.keySignature.draw()}}class ws extends ${constructor(i,c){super({duration:"b"}),this.setAttribute("type","TimeSigNote");const M=new Ge(i,c);this.timeSig=M.getTimeSig(),this.setWidth(this.timeSig.glyph.getMetrics().width),this.ignore_ticks=!0}getBoundingBox(){return super.getBoundingBox()}addToModifierContext(){return this}preFormat(){return this.setPreFormatted(!0),this}draw(){this.stave.checkContext(),this.setRendered(),this.timeSig.glyph.getContext()||this.timeSig.glyph.setContext(this.context),this.timeSig.glyph.setStave(this.stave),this.timeSig.glyph.setYShift(this.stave.getYForLine(this.timeSig.line)-this.stave.getYForGlyphs()),this.timeSig.glyph.renderToStave(this.getAbsoluteX())}}class Mi extends Q{static get SLIDE_UP(){return 1}static get SLIDE_DOWN(){return-1}static createSlideUp(i){return new Mi(i,Mi.SLIDE_UP)}static createSlideDown(i){return new Mi(i,Mi.SLIDE_DOWN)}constructor(i,c){if(super(i,"sl."),this.setAttribute("type","TabSlide"),!c){const M=i.first_note.getPositions()[0].fret,I=i.last_note.getPositions()[0].fret;c=parseInt(M,10)>parseInt(I,10)?Mi.SLIDE_DOWN:Mi.SLIDE_UP}this.slide_direction=c,this.render_options.cp1=11,this.render_options.cp2=14,this.render_options.y_shift=.5,this.setFont({font:"Times",size:10,style:"bold italic"}),this.setNotes(i)}renderTie(i){if(i.first_ys.length===0||i.last_ys.length===0)throw new d.RERR("BadArguments","No Y-values to render");const c=this.context,M=i.first_x_px,I=i.first_ys,V=i.last_x_px,X=this.slide_direction;if(X!==Mi.SLIDE_UP&&X!==Mi.SLIDE_DOWN)throw new d.RERR("BadSlide","Invalid slide direction");for(let Z=0;Zthis.numStrings)throw new d.RERR("BadArguments",`String number must be between 1 and ${this.numStrings}:${i}`);return this.tuningValues[c-1]}getValueForFret(i,c){const M=this.getValueForString(c),I=parseInt(i,10);if(I<0)throw new d.RERR("BadArguments","Fret number must be 0 or higher: "+i);return M+I}getNoteForFret(i,c){const M=this.getValueForFret(i,c),I=Math.floor(M/12),V=M%12;return v.integerToNote(V)+"/"+I}}class rn extends h{static get type(){return{CRESC:1,DECRESC:2}}static FormatByTicksAndDraw(i,c,M,I,V,X){const Z=c.pixelsPerTick;if(Z==null)throw new d.RuntimeError("BadArguments","A valid Formatter must be provide to draw offsets by ticks.");const nt=Z*X.left_shift_ticks,ot=Z*X.right_shift_ticks,ft={height:X.height,y_shift:X.y_shift,left_shift_px:nt,right_shift_px:ot};new rn({first_note:M.first_note,last_note:M.last_note},I).setContext(i).setRenderOptions(ft).setPosition(V).draw()}constructor(i,c){super(),this.setAttribute("type","StaveHairpin"),this.notes=i,this.hairpin=c,this.position=tt.Position.BELOW,this.render_options={height:10,y_shift:0,left_shift_px:0,right_shift_px:0},this.setNotes(i)}setPosition(i){return i!==tt.Position.ABOVE&&i!==tt.Position.BELOW||(this.position=i),this}setRenderOptions(i){return i.height!=null&&i.y_shift!=null&&i.left_shift_px!=null&&i.right_shift_px!=null&&(this.render_options=i),this}setNotes(i){if(!i.first_note&&!i.last_note)throw new d.RuntimeError("BadArguments","Hairpin needs to have either first_note or last_note set.");return this.first_note=i.first_note,this.last_note=i.last_note,this}renderHairpin(i){const c=this.checkContext();let M=this.render_options.y_shift+20,I=i.first_y;this.position===tt.Position.ABOVE&&(M=30-M,I=i.first_y-i.staff_height);const V=this.render_options.left_shift_px,X=this.render_options.right_shift_px;switch(c.beginPath(),this.hairpin){case rn.type.CRESC:c.moveTo(i.last_x+X,I+M),c.lineTo(i.first_x+V,I+this.render_options.height/2+M),c.lineTo(i.last_x+X,I+this.render_options.height+M);break;case rn.type.DECRESC:c.moveTo(i.first_x+V,I+M),c.lineTo(i.last_x+X,I+this.render_options.height/2+M),c.lineTo(i.first_x+V,I+this.render_options.height+M)}c.stroke(),c.closePath()}draw(){this.checkContext(),this.setRendered();const i=this.first_note,c=this.last_note,M=i.getModifierStartXY(this.position,0),I=c.getModifierStartXY(this.position,0);return this.renderHairpin({first_x:M.x,last_x:I.x,first_y:i.getStave().y+i.getStave().height,last_y:c.getStave().y+c.getStave().height,staff_height:i.getStave().height}),!0}}class Ci extends h{static get Position(){return{NEAR_HEAD:1,NEAR_TOP:2}}static get PositionString(){return{nearHead:Ci.Position.NEAR_HEAD,nearTop:Ci.Position.NEAR_TOP}}constructor(i,c,M){super(),this.setAttribute("type","Curve"),this.render_options={spacing:2,thickness:2,x_shift:0,y_shift:10,position:Ci.Position.NEAR_HEAD,position_end:Ci.Position.NEAR_HEAD,invert:!1,cps:[{x:0,y:10},{x:0,y:10}]},d.Merge(this.render_options,M),this.setNotes(i,c)}setNotes(i,c){if(!i&&!c)throw new d.RuntimeError("BadArguments","Curve needs to have either first_note or last_note set.");return this.from=i,this.to=c,this}isPartial(){return!this.from||!this.to}renderCurve(i){const c=this.context,M=this.render_options.cps,I=this.render_options.x_shift,V=this.render_options.y_shift*i.direction,X=i.first_x+I,Z=i.first_y+V,nt=i.last_x-I,ot=i.last_y+V,ft=this.render_options.thickness,pt=(nt-X)/(M.length+2);c.beginPath(),c.moveTo(X,Z),c.bezierCurveTo(X+pt+M[0].x,Z+M[0].y*i.direction,nt-pt+M[1].x,ot+M[1].y*i.direction,nt,ot),c.bezierCurveTo(nt-pt+M[1].x,ot+(M[1].y+ft)*i.direction,X+pt+M[0].x,Z+(M[0].y+ft)*i.direction,X,Z),c.stroke(),c.closePath(),c.fill()}draw(){this.checkContext(),this.setRendered();const i=this.from,c=this.to;let M,I,V,X,Z,nt="baseY",ot="baseY";function ft(bt){return typeof bt=="string"?Ci.PositionString[bt]:bt}const pt=ft(this.render_options.position),gt=ft(this.render_options.position_end);return pt===Ci.Position.NEAR_TOP&&(nt="topY",ot="topY"),gt===Ci.Position.NEAR_HEAD?ot="baseY":gt===Ci.Position.NEAR_TOP&&(ot="topY"),i?(M=i.getTieRightX(),Z=i.getStemDirection(),V=i.getStemExtents()[nt]):(M=c.getStave().getTieStartX(),V=c.getStemExtents()[nt]),c?(I=c.getTieLeftX(),Z=c.getStemDirection(),X=c.getStemExtents()[ot]):(I=i.getStave().getTieEndX(),X=i.getStemExtents()[ot]),this.renderCurve({first_x:M,last_x:I,first_y:V,last_y:X,direction:Z*(this.render_options.invert===!0?-1:1)}),!0}}function La(...vt){An.DEBUG&&d.L("Vex.Flow.TextDynamics",vt)}class An extends ${static get GLYPHS(){return{f:{code:"vba",width:12},p:{code:"vbf",width:14},m:{code:"v62",width:17},s:{code:"v4a",width:10},z:{code:"v80",width:12},r:{code:"vb1",width:12}}}constructor(i){super(i),this.setAttribute("type","TextDynamics"),this.sequence=i.text.toLowerCase(),this.line=i.line||0,this.glyphs=[],d.Merge(this.render_options,{glyph_font_size:40}),La("New Dynamics Text: ",this.sequence)}setLine(i){return this.line=i,this}preFormat(){let i=0;return this.sequence.split("").forEach(c=>{const M=An.GLYPHS[c];if(!M)throw new d.RERR("Invalid dynamics character: "+c);const I=this.render_options.glyph_font_size,V=new S(M.code,I);this.glyphs.push(V),i+=M.width}),this.setWidth(i),this.preFormatted=!0,this}draw(){this.setRendered();const i=this.getAbsoluteX(),c=this.stave.getYForLine(this.line+-3);La("Rendering Dynamics: ",this.sequence);let M=i;this.glyphs.forEach((I,V)=>{const X=this.sequence[V];I.render(this.context,M,c),M+=An.GLYPHS[X].width})}}function Ks(vt,i,c,M,I,V,X){vt.beginPath(),vt.moveTo(i,c),vt.lineTo(M,I),vt.lineTo(V,X),vt.lineTo(i,c),vt.closePath(),vt.fill()}class yi extends h{static get TextVerticalPosition(){return{TOP:1,BOTTOM:2}}static get TextJustification(){return{LEFT:1,CENTER:2,RIGHT:3}}constructor(i){super(),this.setAttribute("type","StaveLine"),this.notes=i,this.text="",this.font={family:"Arial",size:10,weight:""},this.render_options={padding_left:4,padding_right:3,line_width:1,line_dash:null,rounded_end:!0,color:null,draw_start_arrow:!1,draw_end_arrow:!1,arrowhead_length:10,arrowhead_angle:Math.PI/8,text_position_vertical:yi.TextVerticalPosition.TOP,text_justification:yi.TextJustification.CENTER},this.setNotes(i)}setFont(i){return this.font=i,this}setText(i){return this.text=i,this}setNotes(i){if(!i.first_note&&!i.last_note)throw new d.RuntimeError("BadArguments","Notes needs to have either first_note or last_note set.");if(i.first_indices||(i.first_indices=[0]),i.last_indices||(i.last_indices=[0]),i.first_indices.length!==i.last_indices.length)throw new d.RuntimeError("BadArguments","Connected notes must have similar index sizes");return this.first_note=i.first_note,this.first_indices=i.first_indices,this.last_note=i.last_note,this.last_indices=i.last_indices,this}applyLineStyle(){const i=this.checkContext(),c=this.render_options;c.line_dash&&i.setLineDash(c.line_dash),c.line_width&&i.setLineWidth(c.line_width),c.rounded_end?i.setLineCap("round"):i.setLineCap("square")}applyFontStyle(){const i=this.checkContext();this.font&&i.setFont(this.font.family,this.font.size,this.font.weight),this.render_options.color&&(i.setStrokeStyle(this.render_options.color),i.setFillStyle(this.render_options.color))}draw(){const i=this.checkContext();this.setRendered();const c=this.first_note,M=this.last_note,I=this.render_options;let V,X;i.save(),this.applyLineStyle(),this.first_indices.forEach((gt,bt)=>{const Mt=this.last_indices[bt];V=c.getModifierStartXY(2,gt),X=M.getModifierStartXY(1,Mt);const _t=V.y>X.y;V.x+=c.getMetrics().modRightPx+I.padding_left,X.x-=M.getMetrics().modLeftPx+I.padding_right;const Tt=c.getGlyph().getWidth();c.getKeyProps()[gt].displaced&&c.getStemDirection()===1&&(V.x+=Tt+I.padding_left),M.getKeyProps()[Mt].displaced&&M.getStemDirection()===-1&&(X.x-=Tt+I.padding_right),V.y+=_t?-3:1,X.y+=_t?2:0,(function(Ft,Zt,Yt,ee){const ne=ee.draw_start_arrow&&ee.draw_end_arrow,he=Zt.x,me=Zt.y,Le=Yt.x,Ee=Yt.y,vi=Math.sqrt((Le-he)*(Le-he)+(Ee-me)*(Ee-me)),ri=(vi-ee.arrowhead_length/3)/vi;let je,ki,Vi,Yn;ee.draw_end_arrow||ne?(je=Math.round(he+(Le-he)*ri),ki=Math.round(me+(Ee-me)*ri)):(je=Le,ki=Ee),ee.draw_start_arrow||ne?(Vi=he+(Le-he)*(1-ri),Yn=me+(Ee-me)*(1-ri)):(Vi=he,Yn=me),ee.color&&(Ft.setStrokeStyle(ee.color),Ft.setFillStyle(ee.color)),Ft.beginPath(),Ft.moveTo(Vi,Yn),Ft.lineTo(je,ki),Ft.stroke(),Ft.closePath();const pn=Math.atan2(Ee-me,Le-he),gn=Math.abs(ee.arrowhead_length/Math.cos(ee.arrowhead_angle));let qn,on,Ti,Kn,Qn,ln;(ee.draw_end_arrow||ne)&&(qn=pn+Math.PI+ee.arrowhead_angle,Ti=Le+Math.cos(qn)*gn,Kn=Ee+Math.sin(qn)*gn,on=pn+Math.PI-ee.arrowhead_angle,Qn=Le+Math.cos(on)*gn,ln=Ee+Math.sin(on)*gn,Ks(Ft,Ti,Kn,Le,Ee,Qn,ln)),(ee.draw_start_arrow||ne)&&(qn=pn+ee.arrowhead_angle,Ti=he+Math.cos(qn)*gn,Kn=me+Math.sin(qn)*gn,on=pn-ee.arrowhead_angle,Qn=he+Math.cos(on)*gn,ln=me+Math.sin(on)*gn,Ks(Ft,Ti,Kn,he,me,Qn,ln))})(i,V,X,this.render_options)}),i.restore();const Z=i.measureText(this.text).width,nt=I.text_justification;let ot,ft=0;nt===yi.TextJustification.LEFT?ft=V.x:nt===yi.TextJustification.CENTER?ft=(X.x-V.x)/2+V.x-Z/2:nt===yi.TextJustification.RIGHT&&(ft=X.x-Z);const pt=I.text_position_vertical;return pt===yi.TextVerticalPosition.TOP?ot=c.getStave().getYForTopText():pt===yi.TextVerticalPosition.BOTTOM&&(ot=c.getStave().getYForBottomText(v.TEXT_HEIGHT_OFFSET_HACK)),i.save(),this.applyFontStyle(),i.fillText(this.text,ft,ot),i.restore(),this}}function Or(vt,i,c,M,I){const V=be.GLYPHS[vt];new S(V.code,I).render(i,c+V.x_shift,M+V.y_shift)}class be extends h{static get GLYPHS(){return{pedal_depress:{code:"v36",x_shift:-10,y_shift:0},pedal_release:{code:"v5d",x_shift:-2,y_shift:3}}}static get Styles(){return{TEXT:1,BRACKET:2,MIXED:3,MIXED_OPEN_END:4,BRACKET_OPEN_BEGIN:5,BRACKET_OPEN_END:6,BRACKET_OPEN_BOTH:7}}static get StylesString(){return{text:be.Styles.TEXT,bracket:be.Styles.BRACKET,mixed:be.Styles.MIXED,mixed_open_end:be.Styles.MIXED_OPEN_END,bracket_open_begin:be.Styles.BRACKET_OPEN_BEGIN,bracket_open_end:be.Styles.BRACKET_OPEN_END,bracket_open_both:be.Styles.BRACKET_OPEN_BOTH}}static createSustain(i){return new be(i)}static createSostenuto(i){const c=new be(i);return c.setStyle(be.Styles.MIXED),c.setCustomText("Sost. Ped."),c}static createUnaCorda(i){const c=new be(i);return c.setStyle(be.Styles.TEXT),c.setCustomText("una corda","tre corda"),c}constructor(i){super(),this.setAttribute("type","PedalMarking"),this.EndsStave=!1,this.ChangeBegin=!1,this.ChangeEnd=!1,this.notes=i,this.style=be.TEXT,this.line=0,this.custom_depress_text="",this.custom_release_text="",this.font={family:"Times New Roman",size:12,weight:"italic bold"},this.render_options={bracket_height:10,text_margin_right:6,bracket_line_width:1,glyph_point_size:40,color:"black"}}setEndStave(i){if(this.endStave=i,this.endStaveAddedWidth=0,this.startMargin=0,this.endMargin=0,Array.isArray(this.endStave.modifiers))for(let c=0;c3)throw new d.RERR("InvalidParameter","The style must be one found in PedalMarking.Styles");return this.style=i,this}setLine(i){return this.line=i,this}drawBracketed(){const i=this.context;let c,M,I=!1;const V=this;this.notes.forEach((X,Z,nt)=>{I=!I;let ot=0;if(X?(ot=X.getNoteHeadBeginX(),this.BeginsStave&&(ot=X.getStave().getNoteStartX())):ot=this.endStave.end_x+this.endStaveAddedWidth,this.EndsStave)I?this.ChangeBegin&&(ot=X.getAbsoluteX()):(ot=X?this.ChangeEnd?X.getAbsoluteX():X.getStave().end_x+this.endStaveAddedWidth-V.render_options.text_margin_right:this.endStave.end_x+this.endStaveAddedWidth-V.render_options.text_margin_right,this.endMargin=-V.render_options.text_margin_right);else if(X)if(I)this.ChangeBegin&&(ot=X.getAbsoluteX());else switch(V.style){case be.Styles.BRACKET_OPEN_END:case be.Styles.BRACKET_OPEN_BOTH:case be.Styles.MIXED_OPEN_END:ot=X.getNoteHeadEndX();break;default:this.ChangeEnd?ot=X.getAbsoluteX():(ot=X.getNoteHeadBeginX()-V.render_options.text_margin_right,this.startMargin=-V.render_options.text_margin_right)}let ft=this.endStave;X&&(ft=X.getStave());let pt=ft.getYForBottomText(V.line+3);M&&M>pt&&(pt=M);const gt=nt[Z+1]===X,bt=nt[Z-1]===X;let Mt=0;if(I)if(Mt=bt?5:0,V.style!==be.Styles.MIXED&&V.style!==be.Styles.MIXED_OPEN_END||bt)i.beginPath(),V.style===be.Styles.BRACKET_OPEN_BEGIN||V.style===be.Styles.BRACKET_OPEN_BOTH?i.moveTo(ot+Mt,pt):(this.ChangeBegin&&(ot+=5),i.moveTo(ot,pt-V.render_options.bracket_height),this.ChangeBegin&&(ot+=5),i.lineTo(ot+Mt,pt)),i.stroke(),i.closePath();else if(V.custom_depress_text){const _t=i.measureText(V.custom_depress_text).width;i.fillText(V.custom_depress_text,ot-_t/2,pt),Mt=_t/2+V.render_options.text_margin_right}else Or("pedal_depress",i,ot,pt,V.render_options.glyph_point_size),Mt=20+V.render_options.text_margin_right;else Mt=gt&&!this.EndsStave?-5:0,i.beginPath(),i.moveTo(c,M),i.lineTo(ot+Mt,pt),V.style!==be.Styles.BRACKET_OPEN_END&&V.style!==be.Styles.MIXED_OPEN_END&&V.style!==be.Styles.BRACKET_OPEN_BOTH&&(this.ChangeEnd&&(ot+=5),i.lineTo(ot,pt-V.render_options.bracket_height)),i.stroke(),i.closePath();c=ot+Mt,M=pt})}drawText(){const i=this.context;let c=!1;const M=this,I=M.render_options.glyph_point_size;this.notes.forEach(V=>{if(!V)return;c=!c;const X=V.getStave(),Z=V.getAbsoluteX(),nt=X.getYForBottomText(M.line+3);let ot=0;c?M.custom_depress_text?(ot=i.measureText(M.custom_depress_text).width,i.fillText(M.custom_depress_text,Z-ot/2,nt)):Or("pedal_depress",i,Z,nt,I):M.custom_release_text?(ot=i.measureText(M.custom_release_text).width,i.fillText(M.custom_release_text,Z-ot/2,nt)):Or("pedal_release",i,Z,nt,I)})}draw(){const i=this.checkContext();this.setRendered(),i.save(),i.setStrokeStyle(this.render_options.color),i.setFillStyle(this.render_options.color),i.setFont(this.font.family,this.font.size,this.font.weight),be.DEBUG&&d.L("Vex.Flow.PedalMarking",["Rendering Pedal Marking"]),this.style===be.Styles.BRACKET||this.style===be.Styles.MIXED||this.style===be.Styles.MIXED_OPEN_END||this.style===be.Styles.BRACKET_OPEN_BEGIN||this.style===be.Styles.BRACKET_OPEN_END||this.style===be.Styles.BRACKET_OPEN_BOTH?(i.setLineWidth(this.render_options.bracket_line_width),this.drawBracketed()):this.style===be.Styles.TEXT&&this.drawText(),i.restore()}}class di extends h{static get Positions(){return{TOP:1,BOTTOM:-1}}static get PositionString(){return{top:di.Positions.TOP,bottom:di.Positions.BOTTOM}}constructor({start:i,stop:c,text:M="",superscript:I="",position:V=di.Positions.TOP}){super(),this.setAttribute("type","TextBracket"),this.start=i,this.stop=c,this.text=M,this.superscript=I,this.position=typeof V=="string"?di.PositionString[V]:V,this.line=1,this.font={family:"Serif",size:15,weight:"italic"},this.render_options={dashed:!0,dash:[5],color:"black",line_width:1,show_bracket:!0,bracket_height:8,underline_superscript:!0}}applyStyle(i){return i.setFont(this.font.family,this.font.size,this.font.weight),i.setStrokeStyle(this.render_options.color),i.setFillStyle(this.render_options.color),i.setLineWidth(this.render_options.line_width),this}setDashed(i,c){return this.render_options.dashed=i,c&&(this.render_options.dash=c),this}setFont(i){return this.font={...this.font,...i},this}setLine(i){return this.line=i,this}draw(){const i=this.context;this.setRendered();let c=0;switch(this.position){case di.Positions.TOP:c=this.start.getStave().getYForTopText(this.line);break;case di.Positions.BOTTOM:c=this.start.getStave().getYForBottomText(this.line+v.TEXT_HEIGHT_OFFSET_HACK);break;default:throw new d.RERR("InvalidPosition",`The position ${this.position} is invalid`)}const M={x:this.start.getAbsoluteX(),y:c},I={x:this.stop.getAbsoluteX(),y:c};(function(...Mt){di.DEBUG&&d.L("Vex.Flow.TextBracket",Mt)})("Rendering TextBracket: start:",M,"stop:",I,"y:",c);const V=this.render_options.bracket_height*this.position;i.save(),this.applyStyle(i),i.fillText(this.text,M.x,M.y);let X=i.measureText(this.text).width;X>0||(X=10*this.text.length);let Z=i.measureText("M").width;Z>0||(Z=20);const nt=M.y-Z/2.5;i.setFont(this.font.family,this.font.size/1.4,this.font.weight),i.fillText(this.superscript,M.x+X+1,nt);let ot=i.measureText(this.superscript).width;ot>0||(ot=12,this.superscript.includes("m")&&(ot+=5));let ft=i.measureText("M").width;ft>0||(ft=10);let pt=M.x,gt=nt,bt=I.x+this.stop.getGlyph().getWidth();this.position===di.Positions.TOP?(pt+=X+ot+5,gt-=ft/2.7):this.position===di.Positions.BOTTOM&&(gt+=ft/2.7,pt+=X+2,this.render_options.underline_superscript||(pt+=ot)),this.render_options.dashed?(bt0||c===!0;return!c||V>0||(this.pos=I),Z?this.matchSuccess():this.matchFail(I),{success:Z,results:M,numMatches:V}}expectZeroOrMore(i){return this.expectOneOrMore(i,!0)}expect(i){let c;if((function(...I){Ze.DEBUG&&d.L("Vex.Flow.Parser",I)})("Evaluating rules:",i),!i)throw new Dr("Invalid Rule: "+i,i);const M=i.bind(this.grammar)();if(M.token)c=this.matchToken(M.token,M.noSpace===!0),c.success&&(this.pos+=c.incrementPos);else{if(!M.expect)throw new Dr("Bad grammar! No `token` or `expect` property",M);c=M.oneOrMore?this.expectOneOrMore(M):M.zeroOrMore?this.expectZeroOrMore(M):this.expectOne(M)}return c.matches=[],c.results&&c.results.forEach(I=>c.matches.push(Ri(I))),M.run&&c.success&&M.run(c),c}}function We(...vt){Pn.DEBUG&&d.L("Vex.Flow.EasyScore",vt)}const Wn=d.MakeException("EasyScoreError");class Aa{constructor(i){this.builder=i}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:i=>this.builder.addChord(i.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:i=>this.builder.addSingleNote(i.matches[0],i.matches[1],i.matches[2])}}ACCIDENTAL(){return{expect:[this.ACCIDENTALS],maybe:!0}}DOTS(){return{expect:[this.DOT],zeroOrMore:!0,run:i=>this.builder.setNoteDots(i.matches[0])}}TYPE(){return{expect:[this.SLASH,this.MAYBESLASH,this.TYPES],maybe:!0,run:i=>this.builder.setNoteType(i.matches[2])}}DURATION(){return{expect:[this.SLASH,this.DURATIONS],maybe:!0,run:i=>this.builder.setNoteDuration(i.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:i=>this.builder.addNoteOption(i.matches[0],i.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:"bbs|bb|bss|bs|b|db|d|##|#|n|\\+\\+-|\\+-|\\+\\+|\\+|k|o"}}DURATIONS(){return{token:"[0-9whq]+"}}TYPES(){return{token:"[rRsSxX]"}}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 Ko{constructor(i){this.factory=i,this.commitHooks=[],this.reset()}reset(i={}){this.options={stem:"auto",clef:"treble"},this.elements={notes:[],accidentals:[]},this.rollingDuration="8",this.resetPiece(),Object.assign(this.options,i)}getFactory(){return this.factory}getElements(){return this.elements}addCommitHook(i){this.commitHooks.push(i)}resetPiece(){We("resetPiece"),this.piece={chord:[],duration:this.rollingDuration,dots:0,type:void 0,options:{}}}setNoteDots(i){We("setNoteDots:",i),i&&(this.piece.dots=i.length)}setNoteDuration(i){We("setNoteDuration:",i),this.rollingDuration=this.piece.duration=i||this.rollingDuration}setNoteType(i){We("setNoteType:",i),i&&(this.piece.type=i)}addNoteOption(i,c){We("addNoteOption: key:",i,"value:",c),this.piece.options[i]=c}addNote(i,c,M){We("addNote:",i,c,M),this.piece.chord.push({key:i,accid:c,octave:M})}addSingleNote(i,c,M){We("addSingleNote:",i,c,M),this.addNote(i,c,M)}addChord(i){We("startChord"),typeof i[0]!="object"?this.addSingleNote(i[0]):i.forEach(c=>{c&&this.addNote(...c)}),We("endChord")}commitPiece(){We("commitPiece");const{factory:i}=this;if(!i)return;const c={...this.options,...this.piece.options},{stem:M,clef:I}=c,V=M.toLowerCase()==="auto",X=V||M.toLowerCase()!=="up"?ct.STEM_DOWN:ct.STEM_UP,{chord:Z,duration:nt,dots:ot,type:ft}=this.piece,pt=Z.map(Mt=>Mt.key+"/"+Mt.octave),gt=i.StaveNote({keys:pt,duration:nt,dots:ot,type:ft,clef:I,auto_stem:V});V||gt.setStemDirection(X);const bt=Z.map(Mt=>Mt.accid||null);bt.forEach((Mt,_t)=>{Mt&>.addAccidental(_t,i.Accidental({type:Mt}))});for(let Mt=0;MtMt(c,gt,this)),this.elements.notes.push(gt),this.elements.accidentals.concat(bt),this.resetPiece()}}function Qo({id:vt},i){vt!==void 0&&i.setAttribute("id",vt)}function Pa(vt,i){vt.class&&vt.class.split(/\s*,\s*/).forEach(c=>i.addClass(c))}class Pn{constructor(i={}){this.setOptions(i),this.defaults={clef:"treble",time:"4/4",stem:"auto"}}set(i){return Object.assign(this.defaults,i),this}setOptions(i){return this.options={factory:null,builder:null,commitHooks:[Qo,Pa,Nt.easyScoreHook],throwOnError:!1,...i},this.factory=this.options.factory,this.builder=this.options.builder||new Ko(this.factory),this.grammar=new Aa(this.builder),this.parser=new Ze(this.grammar),this.options.commitHooks.forEach(c=>this.addCommitHook(c)),this}setContext(i){return this.factory&&this.factory.setContext(i),this}parse(i,c={}){this.builder.reset(c);const M=this.parser.parse(i);if(!M.success&&this.options.throwOnError)throw new Wn("Error parsing line: "+i,M);return M}beam(i,c={}){return this.factory.Beam({notes:i,options:c}),i}tuplet(i,c={}){return this.factory.Tuplet({notes:i,options:c}),i}notes(i,c={}){return c={clef:this.defaults.clef,stem:this.defaults.stem,...c},this.parse(i,c),this.builder.getElements().notes}voice(i,c){return c={time:this.defaults.time,...c},this.factory.Voice(c).addTickables(i)}addCommitHook(i){return this.builder.addCommitHook(i)}}const Js=d.MakeException("FactoryError");function Fe(vt={},i){const c=i.options;return(vt=Object.assign(i,vt)).options=Object.assign(c,vt.options),vt}class Fi{constructor(i){(function(...M){Fi.DEBUG&&d.L("Vex.Flow.Factory",M)})("New factory: ",i);const c={stave:{space:10},renderer:{context:null,elementId:"",backend:_.Backends.SVG,width:500,height:200,background:"#FFF"},font:{face:"Arial",point:10,style:""}};this.options=c,this.setOptions(i)}static newFromElementId(i,c=500,M=200){return new Fi({renderer:{elementId:i,width:c,height:M}})}reset(){this.renderQ=[],this.systems=[],this.staves=[],this.voices=[],this.stave=null}getOptions(){return this.options}setOptions(i){for(const c of["stave","renderer","font"])Object.assign(this.options[c],i[c]);(this.options.renderer.elementId!==null||this.options.renderer.context)&&this.initRenderer(),this.reset()}initRenderer(){const{elementId:i,backend:c,width:M,height:I,background:V}=this.options.renderer;if(i==="")throw new Js("HTML DOM element not set in Factory");this.context=_.buildContext(i,c,M,I,V)}getContext(){return this.context}setContext(i){return this.context=i,this}getStave(){return this.stave}getVoices(){return this.voices}space(i){return this.options.stave.space*i}Stave(i){i=Fe(i,{x:0,y:0,width:this.options.renderer.width-this.space(1),options:{spacing_between_lines_px:this.options.stave.space}});const c=new Ce(i.x,i.y,i.width,i.options);return this.staves.push(c),c.setContext(this.context),this.stave=c,c}TabStave(i){i=Fe(i,{x:0,y:0,width:this.options.renderer.width-this.space(1),options:{spacing_between_lines_px:1.3*this.options.stave.space}});const c=new Re(i.x,i.y,i.width,i.options);return this.staves.push(c),c.setContext(this.context),this.stave=c,c}StaveNote(i){const c=new ct(i);return this.stave&&c.setStave(this.stave),c.setContext(this.context),this.renderQ.push(c),c}GhostNote(i){const c=new Qs(i);return this.stave&&c.setStave(this.stave),c.setContext(this.context),this.renderQ.push(c),c}TextNote(i){const c=new Xe(i);return this.stave&&c.setStave(this.stave),c.setContext(this.context),this.renderQ.push(c),c}BarNote(i){i=Fe(i,{type:"single",options:{}});const c=new Ls(i.type);return this.stave&&c.setStave(this.stave),c.setContext(this.context),this.renderQ.push(c),c}ClefNote(i){i=Fe(i,{type:"treble",options:{size:"default"}});const c=new nn(i.type,i.options.size,i.options.annotation);return this.stave&&c.setStave(this.stave),c.setContext(this.context),this.renderQ.push(c),c}TimeSigNote(i){i=Fe(i,{time:"4/4",options:{}});const c=new ws(i.time);return this.stave&&c.setStave(this.stave),c.setContext(this.context),this.renderQ.push(c),c}KeySigNote(i){const c=new _s(i.key,i.cancelKey,i.alterKey);return this.stave&&c.setStave(this.stave),c.setContext(this.context),this.renderQ.push(c),c}TabNote(i){const c=new He(i);return this.stave&&c.setStave(this.stave),c.setContext(this.context),this.renderQ.push(c),c}GraceNote(i){const c=new Yi(i);return this.stave&&c.setStave(this.stave),c.setContext(this.context),c}GraceNoteGroup(i){const c=new J(i.notes,i.slur);return c.setContext(this.context),c}Accidental(i){i=Fe(i,{type:null,options:{}});const c=new O(i.type);return c.setContext(this.context),c}Annotation(i){i=Fe(i,{text:"p",vJustify:"below",hJustify:"center",fontFamily:"Times",fontSize:14,fontWeight:"bold italic",options:{}});const c=new Ct(i.text);return c.setJustification(i.hJustify),c.setVerticalJustification(i.vJustify),c.setFont(i.fontFamily,i.fontSize,i.fontWeight),c.setContext(this.context),c}Articulation(i){i=Fe(i,{type:"a.",position:"above",options:{}});const c=new Nt(i.type);return c.setPosition(i.position),c.setContext(this.context),c}TextDynamics(i){i=Fe(i,{text:"p",duration:"q",dots:0,line:0,options:{}});const c=new An({text:i.text,line:i.line,duration:i.duration,dots:i.dots});return this.stave&&c.setStave(this.stave),c.setContext(this.context),this.renderQ.push(c),c}Fingering(i){i=Fe(i,{number:"0",position:"left",options:{}});const c=new st(i.number);return c.setPosition(i.position),c.setContext(this.context),c}StringNumber(i){i=Fe(i,{number:"0",position:"left",options:{}});const c=new et(i.number);return c.setPosition(i.position),c.setContext(this.context),c}TickContext(){return new it().setContext(this.context)}ModifierContext(){return new Kt}MultiMeasureRest(i){const c=new Ts(i.number_of_measures,i);return c.setContext(this.context),this.renderQ.push(c),c}Voice(i){i=Fe(i,{time:"4/4",options:{}});const c=new U(i.time);return this.voices.push(c),c}StaveConnector(i){i=Fe(i,{top_stave:null,bottom_stave:null,type:"double",options:{}});const c=new z(i.top_stave,i.bottom_stave);return c.setType(i.type).setContext(this.context),this.renderQ.push(c),c}Formatter(){return new te}Tuplet(i){i=Fe(i,{notes:[],options:{}});const c=new k(i.notes,i.options).setContext(this.context);return this.renderQ.push(c),c}Beam(i){i=Fe(i,{notes:[],options:{autoStem:!1,secondaryBeamBreaks:[]}});const c=new G(i.notes,i.options.autoStem).setContext(this.context);return c.breakSecondaryAt(i.options.secondaryBeamBreaks),this.renderQ.push(c),c}Curve(i){i=Fe(i,{from:null,to:null,options:{}});const c=new Ci(i.from,i.to,i.options).setContext(this.context);return this.renderQ.push(c),c}StaveTie(i){i=Fe(i,{from:null,to:null,first_indices:[0],last_indices:[0],text:null,options:{direction:void 0}});const c=new j({first_note:i.from,last_note:i.to,first_indices:i.first_indices,last_indices:i.last_indices},i.text);return i.options.direction&&c.setDirection(i.options.direction),c.setContext(this.context),this.renderQ.push(c),c}StaveLine(i){i=Fe(i,{from:null,to:null,first_indices:[0],last_indices:[0],options:{}});const c=new yi({first_note:i.from,last_note:i.to,first_indices:i.first_indices,last_indices:i.last_indices});return i.options.text&&c.setText(i.options.text),i.options.font&&c.setFont(i.options.font),c.setContext(this.context),this.renderQ.push(c),c}VibratoBracket(i){i=Fe(i,{from:null,to:null,options:{harsh:!1}});const c=new Te({start:i.from,stop:i.to});return i.options.line&&c.setLine(i.options.line),i.options.harsh&&c.setHarsh(i.options.harsh),c.setContext(this.context),this.renderQ.push(c),c}TextBracket(i){i=Fe(i,{from:null,to:null,text:"",options:{superscript:"",position:1}});const c=new di({start:i.from,stop:i.to,text:i.text,superscript:i.options.superscript,position:i.options.position});return i.options.line&&c.setLine(i.options.line),i.options.font&&c.setFont(i.options.font),c.setContext(this.context),this.renderQ.push(c),c}System(i={}){i.factory=this;const c=new jn(i).setContext(this.context);return this.systems.push(c),c}EasyScore(i={}){return i.factory=this,new Pn(i)}PedalMarking(i={}){i=Fe(i,{notes:[],options:{style:"mixed"}});const c=new be(i.notes);return c.setStyle(be.StylesString[i.options.style]),c.setContext(this.context),this.renderQ.push(c),c}NoteSubGroup(i={}){i=Fe(i,{notes:[],options:{}});const c=new D(i.notes);return c.setContext(this.context),c}draw(){this.systems.forEach(i=>i.setContext(this.context).format()),this.staves.forEach(i=>i.setContext(this.context).draw()),this.voices.forEach(i=>i.setContext(this.context).draw()),this.renderQ.forEach(i=>{i.isRendered()||i.setContext(this.context).draw()}),this.systems.forEach(i=>i.setContext(this.context).draw()),this.reset()}}function Cn(vt,i){const c=i.options;return(vt=Object.assign(i,vt)).options=Object.assign(c,vt.options),vt}class jn extends h{constructor(i={}){super(),this.setAttribute("type","System"),this.setOptions(i),this.parts=[]}setOptions(i={}){this.options=Cn(i,{x:10,y:10,width:500,connector:null,spaceBetweenStaves:12,factory:null,debugFormatter:!1,formatIterations:0,options:{}}),this.factory=this.options.factory||new Fi({renderer:{el:null}})}setContext(i){return super.setContext(i),this.factory.setContext(i),this}addConnector(i="double"){return this.connector=this.factory.StaveConnector({top_stave:this.parts[0].stave,bottom_stave:this.parts[this.parts.length-1].stave,type:i}),this.connector}addStave(i){return(i=Cn(i,{stave:null,voices:[],spaceAbove:0,spaceBelow:0,debugNoteMetrics:!1,options:{left_bar:!1}})).stave||(i.stave=this.factory.Stave({x:this.options.x,y:this.options.y,width:this.options.width,options:i.options})),i.voices.forEach(c=>c.setContext(this.context).setStave(i.stave).getTickables().forEach(M=>M.setStave(i.stave))),this.parts.push(i),i.stave}format(){const i=new te;this.formatter=i;let c=this.options.y,M=0,I=[];const V=[];this.parts.forEach(Z=>{c+=Z.stave.space(Z.spaceAbove),Z.stave.setY(c),i.joinVoices(Z.voices),c+=Z.stave.space(Z.spaceBelow),c+=Z.stave.space(this.options.spaceBetweenStaves),Z.debugNoteMetrics&&(V.push({y:c,voice:Z.voices[0]}),c+=15),I=I.concat(Z.voices),M=Math.max(M,Z.stave.getNoteStartX())}),this.parts.forEach(Z=>Z.stave.setNoteStartX(M));const X=this.options.width-(M-this.options.x)-$.STAVEPADDING;i.format(I,X);for(let Z=0;Z{c.voice.getTickables().forEach(M=>$.plotMetrics(i,M,c.y))})}}(d.Flow=v).Element=h,d.Flow.Fraction=l,d.Flow.Renderer=_,d.Flow.Formatter=te,d.Flow.Music=at,d.Flow.Glyph=S,d.Flow.Stave=Ce,d.Flow.StaveNote=ct,d.Flow.StaveModifier=ie,d.Flow.StaveTempo=De,d.Flow.Voice=U,d.Flow.Accidental=O,d.Flow.Beam=G,d.Flow.StaveTie=j,d.Flow.TabStave=Re,d.Flow.TabNote=He,d.Flow.Bend=zt,d.Flow.Vibrato=Xt,d.Flow.VibratoBracket=Te,d.Flow.Note=$,d.Flow.ModifierContext=Kt,d.Flow.MultiMeasureRest=Ts,d.Flow.TickContext=it,d.Flow.Articulation=Nt,d.Flow.Annotation=Ct,d.Flow.Barline=$t,d.Flow.NoteHead=N,d.Flow.StaveConnector=z,d.Flow.ClefNote=nn,d.Flow.KeySignature=we,d.Flow.KeySigNote=_s,d.Flow.TimeSignature=Ge,d.Flow.TimeSigNote=ws,d.Flow.Stem=B,d.Flow.TabTie=Q,d.Flow.Clef=oi,d.Flow.Dot=H,d.Flow.Modifier=tt,d.Flow.TabSlide=Mi,d.Flow.Tuplet=k,d.Flow.GraceNote=Yi,d.Flow.GraceTabNote=sn,d.Flow.Tuning=Ln,d.Flow.KeyManager=class{constructor(vt){this.music=new at,this.setKey(vt)}setKey(vt){return this.key=vt,this.reset(),this}getKey(){return this.key}reset(){if(this.keyParts=this.music.getKeyParts(this.key),this.keyString=this.keyParts.root,this.keyParts.accidental&&(this.keyString+=this.keyParts.accidental),!at.scaleTypes[this.keyParts.type])throw new d.RERR("BadArguments",`Unsupported key type: ${this.key}`);this.scale=this.music.getScaleTones(this.music.getNoteValue(this.keyString),at.scaleTypes[this.keyParts.type]),this.scaleMap={},this.scaleMapByValue={},this.originalScaleMapByValue={};const vt=at.root_indices[this.keyParts.root];for(let i=0;i{C.hide()}),this.sheet=void 0,this.graphic=void 0,this.zoom=1,this.rules.RenderCount=0}autoResize(){const C=this;this.handleResize(()=>{},()=>{var z;((z=this.graphic)==null?void 0:z.GetCalculator)instanceof m.VexFlowMusicSheetCalculator&&(this.graphic.GetCalculator.beamsNeedUpdate=!0),C.IsReadyToRender()&&C.renderAndScrollBack()})}renderAndScrollBack(){const C=window.scrollY/document.body.scrollHeight;this.render();const z=document.body.scrollHeight*C;window.scrollTo({top:z,behavior:"instant"})}handleResize(C,z){let W,$;const N=this;function Y(){N.AutoResizeEnabled&&(W=new Date().getTime(),$||(C(),W=new Date().getTime(),$=window.setTimeout(tt,200)))}function tt(){$=void 0,window.clearTimeout($),new Date().getTime()-W<200?$=window.setTimeout(tt,200):z()}window.attachEvent?window.attachEvent("onresize",Y):window.addEventListener("resize",Y),this.resizeHandlerAttached=!0,window.setTimeout(C,0),window.setTimeout(z,1)}enableOrDisableCursors(C){var z,W,$,N;if(this.drawingParameters.drawCursors=C,C)for(let Y=0;Y{Y.hide()})}createBackend(C,z){let W;return W=C===void 0||C===P.BackendType.SVG?new f.SvgVexFlowBackend(this.rules):new r.CanvasVexFlowBackend(this.rules),W.graphicalMusicPage=z,W.initialize(this.container,this.zoom),W}static StringToPageFormat(C){let z=_.PageFormat.UndefinedPageFormat;if(C.match("^[0-9]+x[0-9]+$")){const W=C.split("x"),$=Number.parseInt(W[0],10),N=Number.parseInt(W[1],10);$>0&&$<32768&&N>0&&N<32768&&(z=new _.PageFormat($,N,`customPageFormat${C}`))}return C=(C=(C=C.replace(" ","_")).replace("Landscape","L")).replace("Portrait","P"),G.PageFormatStandards.hasOwnProperty(C)&&(z=G.PageFormatStandards[C]),z}setPageFormat(C){const z=G.StringToPageFormat(C);this.needBackendUpdate=!z.Equals(this.rules.PageFormat),this.rules.PageFormat=z}setCustomPageFormat(C,z){if(C>0&&z>0){const W=new _.PageFormat(C,z);this.rules.PageFormat=W}}set DrawSkyLine(C){this.drawSkyLine=C,this.drawer&&(this.drawer.skyLineVisible=C)}get DrawSkyLine(){return this.drawer.skyLineVisible}set DrawBottomLine(C){this.drawBottomLine=C,this.drawer&&(this.drawer.bottomLineVisible=C)}get DrawBottomLine(){return this.drawer.bottomLineVisible}set DrawBoundingBox(C){this.setDrawBoundingBox(C,!0)}get DrawBoundingBox(){return this.drawBoundingBox}setDrawBoundingBox(C,z=!1){this.drawBoundingBox=C,this.drawer&&(this.drawer.drawableBoundingBoxElement=C),z&&this.renderAndScrollBack()}get AutoResizeEnabled(){return this.autoResizeEnabled}set AutoResizeEnabled(C){this.autoResizeEnabled=C}get Zoom(){return this.zoom}set Zoom(C){var z;this.zoom=C,this.zoomUpdated=!0,((z=this.graphic)==null?void 0:z.GetCalculator)instanceof m.VexFlowMusicSheetCalculator&&(this.graphic.GetCalculator.beamsNeedUpdate=this.zoomUpdated)}set FollowCursor(C){this.followCursor=C}get FollowCursor(){return this.followCursor}set TransposeCalculator(C){h.MusicSheetCalculator.transposeCalculator=C}get TransposeCalculator(){return h.MusicSheetCalculator.transposeCalculator}get Sheet(){return this.sheet}get Drawer(){return this.drawer}get GraphicSheet(){return this.graphic}get DrawingParameters(){return this.drawingParameters}get EngravingRules(){return this.rules}get Version(){return this.version}}y.OpenSheetMusicDisplay=G,G.PageFormatStandards={A3_L:new _.PageFormat(420,297,"A3_L"),A3_P:new _.PageFormat(297,420,"A3_P"),A4_L:new _.PageFormat(297,210,"A4_L"),A4_P:new _.PageFormat(210,297,"A4_P"),A5_L:new _.PageFormat(210,148,"A5_L"),A5_P:new _.PageFormat(148,210,"A5_P"),A6_L:new _.PageFormat(148,105,"A6_L"),A6_P:new _.PageFormat(105,148,"A6_P"),Endless:_.PageFormat.UndefinedPageFormat,Letter_L:new _.PageFormat(279.4,215.9,"Letter_L"),Letter_P:new _.PageFormat(215.9,279.4,"Letter_P")}},5955(St,y,p){var d=this&&this.__createBinding||(Object.create?function(m,o,s,h){h===void 0&&(h=s);var u=Object.getOwnPropertyDescriptor(o,s);u&&!("get"in u?!o.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return o[s]}}),Object.defineProperty(m,h,u)}:function(m,o,s,h){h===void 0&&(h=s),m[h]=o[s]}),l=this&&this.__exportStar||function(m,o){for(var s in m)s==="default"||Object.prototype.hasOwnProperty.call(o,s)||d(o,m,s)};Object.defineProperty(y,"__esModule",{value:!0}),l(p(3173),y),l(p(6597),y),l(p(624),y),l(p(7103),y)},8628(St,y,p){Object.defineProperty(y,"__esModule",{value:!0}),y.TransposeCalculator=void 0;const d=p(9735);class l{transposePitch(o,s,h){if(h===0)return o;let u=d.NoteEnum.C,f=0,r=d.AccidentalEnum.NONE;const b=d.Pitch.CalculateTransposedHalfTone(o,h);let S=b.halftone,v=b.overflow;for(let w=0;wS)break}for(let w=0;wS){let T=w;const g=d.Pitch.HalfTonesFromAccidental(o.Accidental),x=g>0,P=g<0,_=s.Key>0,B=s.Key<0;let k=!0;for(_?k=!0:B?k=!1:(x||P)&&(k=x),k&&T--;T<0;)T+=7,S+=12,v--;for(;T>=7;)T-=7,S-=12,v++;u=l.noteEnums[T],r=d.Pitch.AccidentalFromHalfTones(S-u),f=o.Octave+v;break}return new d.Pitch(u,f,r)}transposeKey(o,s){let h=0,u=0,f=o.keyTypeOriginal;if(s%12==0)return o.Key=o.keyTypeOriginal,void(o.isTransposedBy=s);for(f>6?f-=12:f<-6&&(f+=12);h=12;)r-=12;for(;r<0;)r+=12;o.Key=l.keyMapping[r],o.isTransposedBy=s}}y.TransposeCalculator=l,l.keyMapping=[0,-5,2,-3,4,-1,6,1,-4,3,-2,5],l.noteEnums=[d.NoteEnum.C,d.NoteEnum.D,d.NoteEnum.E,d.NoteEnum.F,d.NoteEnum.G,d.NoteEnum.A,d.NoteEnum.B]},8659(St,y,p){var d=this&&this.__createBinding||(Object.create?function(m,o,s,h){h===void 0&&(h=s);var u=Object.getOwnPropertyDescriptor(o,s);u&&!("get"in u?!o.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return o[s]}}),Object.defineProperty(m,h,u)}:function(m,o,s,h){h===void 0&&(h=s),m[h]=o[s]}),l=this&&this.__exportStar||function(m,o){for(var s in m)s==="default"||Object.prototype.hasOwnProperty.call(o,s)||d(o,m,s)};Object.defineProperty(y,"__esModule",{value:!0}),l(p(8628),y)},363(St,y,p){var d=this&&this.__createBinding||(Object.create?function(m,o,s,h){h===void 0&&(h=s);var u=Object.getOwnPropertyDescriptor(o,s);u&&!("get"in u?!o.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return o[s]}}),Object.defineProperty(m,h,u)}:function(m,o,s,h){h===void 0&&(h=s),m[h]=o[s]}),l=this&&this.__exportStar||function(m,o){for(var s in m)s==="default"||Object.prototype.hasOwnProperty.call(o,s)||d(o,m,s)};Object.defineProperty(y,"__esModule",{value:!0}),l(p(8659),y)},813(St,y){Object.defineProperty(y,"__esModule",{value:!0}),y.CollectionUtil=void 0,Array.prototype.last||Object.defineProperty(Array.prototype,"last",{enumerable:!1,writable:!0,value:function(){return this[this.length-1]}}),Array.prototype.clear||Object.defineProperty(Array.prototype,"clear",{enumerable:!1,writable:!0,value:function(){this.length=0}}),Array.prototype.contains||Object.defineProperty(Array.prototype,"contains",{enumerable:!1,writable:!0,value:function(p){return this.indexOf(p)!==-1}}),y.CollectionUtil=class{static contains2(p,d){for(let l=0;l0&&(s=s.rightCh);return s},o.prototype.transplant=function(s,h){s.parent===null?this.root=h:s===s.parent.leftCh?s.parent.leftCh=h:s.parent.rightCh=h,h!==null&&(h.parent=s.parent)},o.prototype.removeNode=function(s){if(s.leftCh===null)this.transplant(s,s.rightCh);else if(s.rightCh===null)this.transplant(s,s.leftCh);else{var h=this.minimumAux(s.rightCh);h.parent!==s&&(this.transplant(h,h.rightCh),h.rightCh=s.rightCh,h.rightCh.parent=h),this.transplant(s,h),h.leftCh=s.leftCh,h.leftCh.parent=h}},o.prototype.inorderTraversalAux=function(s,h,u){s===null||u.stop||(this.inorderTraversalAux(s.leftCh,h,u),u.stop||(u.stop=h(s.element)===!1,u.stop||this.inorderTraversalAux(s.rightCh,h,u)))},o.prototype.levelTraversalAux=function(s,h){var u=new l.default;for(s!==null&&u.enqueue(s),s=u.dequeue()||null;s!=null;){if(h(s.element)===!1)return;s.leftCh!==null&&u.enqueue(s.leftCh),s.rightCh!==null&&u.enqueue(s.rightCh),s=u.dequeue()||null}},o.prototype.preorderTraversalAux=function(s,h,u){s===null||u.stop||(u.stop=h(s.element)===!1,u.stop||(this.preorderTraversalAux(s.leftCh,h,u),u.stop||this.preorderTraversalAux(s.rightCh,h,u)))},o.prototype.postorderTraversalAux=function(s,h,u){s===null||u.stop||(this.postorderTraversalAux(s.leftCh,h,u),u.stop||(this.postorderTraversalAux(s.rightCh,h,u),u.stop||(u.stop=h(s.element)===!1)))},o.prototype.minimumAux=function(s){for(;s!=null&&s.leftCh!==null;)s=s.leftCh;return s},o.prototype.maximumAux=function(s){for(;s!=null&&s.rightCh!==null;)s=s.rightCh;return s},o.prototype.heightAux=function(s){return s===null?-1:Math.max(this.heightAux(s.leftCh),this.heightAux(s.rightCh))+1},o.prototype.insertNode=function(s){for(var h=null,u=this.root;u!==null;){var f=this.compare(s.element,u.element);if(f===0)return null;f<0?(h=u,u=u.leftCh):(h=u,u=u.rightCh)}return s.parent=h,h===null?this.root=s:this.compare(s.element,h.element)<0?h.leftCh=s:h.rightCh=s,s},o.prototype.createNode=function(s){return{element:s,leftCh:null,rightCh:null,parent:null}},o})();y.default=m},2909(St,y,p){Object.defineProperty(y,"__esModule",{value:!0});var d=p(4831),l=p(6119),m=p(2091),o=(function(){function s(h){this.toStrF=h||d.defaultToString,this.dictionary=new l.default(this.toStrF),this.nElements=0}return s.prototype.add=function(h,u){if(u===void 0&&(u=1),d.isUndefined(h)||u<=0)return!1;if(this.contains(h))this.dictionary.getValue(h).copies+=u;else{var f={value:h,copies:u};this.dictionary.setValue(h,f)}return this.nElements+=u,!0},s.prototype.count=function(h){return this.contains(h)?this.dictionary.getValue(h).copies:0},s.prototype.contains=function(h){return this.dictionary.containsKey(h)},s.prototype.remove=function(h,u){if(u===void 0&&(u=1),d.isUndefined(h)||u<=0)return!1;if(this.contains(h)){var f=this.dictionary.getValue(h);return u>f.copies?this.nElements-=f.copies:this.nElements-=u,f.copies-=u,f.copies<=0&&this.dictionary.remove(h),!0}return!1},s.prototype.toArray=function(){for(var h=[],u=0,f=this.dictionary.values();u=this.data.length?s>=this.data.length?-1:s:this.compare(this.data[s],this.data[h])<=0?s:h},o.prototype.siftUp=function(s){for(var h=this.parentIndex(s);s>0&&this.compare(this.data[h],this.data[s])>0;)l.swap(this.data,h,s),s=h,h=this.parentIndex(s)},o.prototype.siftDown=function(s){for(var h=this.minIndex(this.leftChildIndex(s),this.rightChildIndex(s));h>=0&&this.compare(this.data[s],this.data[h])>0;)l.swap(this.data,h,s),s=h,h=this.minIndex(this.leftChildIndex(s),this.rightChildIndex(s))},o.prototype.peek=function(){return this.data.length>0?this.data[0]:void 0},o.prototype.add=function(s){return!d.isUndefined(s)&&(this.data.push(s),this.siftUp(this.data.length-1),!0)},o.prototype.removeRoot=function(){if(this.data.length>0){var s=this.data[0];return this.data[0]=this.data[this.data.length-1],this.data.splice(this.data.length-1,1),this.data.length>0&&this.siftDown(0),s}},o.prototype.contains=function(s){var h=d.compareToEquals(this.compare);return l.contains(this.data,s,h)},o.prototype.size=function(){return this.data.length},o.prototype.isEmpty=function(){return this.data.length<=0},o.prototype.clear=function(){this.data.length=0},o.prototype.forEach=function(s){l.forEach(this.data,s)},o})();y.default=m},1846(St,y,p){var d,l=this&&this.__extends||(d=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,b){r.__proto__=b}||function(r,b){for(var S in b)b.hasOwnProperty(S)&&(r[S]=b[S])},function(r,b){function S(){this.constructor=r}d(r,b),r.prototype=b===null?Object.create(b):(S.prototype=b.prototype,new S)});Object.defineProperty(y,"__esModule",{value:!0});var m=p(6119),o=p(4831),s=(function(){function r(b,S){this.key=b,this.value=S}return r.prototype.unlink=function(){this.prev.next=this.next,this.next.prev=this.prev},r})(),h=(function(){function r(){this.key=null,this.value=null}return r.prototype.unlink=function(){this.prev.next=this.next,this.next.prev=this.prev},r})();function u(r){return!r.next}var f=(function(r){function b(S){var v=r.call(this,S)||this;return v.head=new h,v.tail=new h,v.head.next=v.tail,v.tail.prev=v.head,v}return l(b,r),b.prototype.appendToTail=function(S){var v=this.tail.prev;v.next=S,S.prev=v,S.next=this.tail,this.tail.prev=S},b.prototype.getLinkedDictionaryPair=function(S){if(!o.isUndefined(S)){var v="$"+this.toStr(S);return this.table[v]}},b.prototype.getValue=function(S){var v=this.getLinkedDictionaryPair(S);if(!o.isUndefined(v))return v.value},b.prototype.remove=function(S){var v=this.getLinkedDictionaryPair(S);if(!o.isUndefined(v))return r.prototype.remove.call(this,S),v.unlink(),v.value},b.prototype.clear=function(){r.prototype.clear.call(this),this.head.next=this.tail,this.tail.prev=this.head},b.prototype.replace=function(S,v){var w="$"+this.toStr(v.key);v.next=S.next,v.prev=S.prev,this.remove(S.key),v.prev.next=v,v.next.prev=v,this.table[w]=v,++this.nElements},b.prototype.setValue=function(S,v){if(!o.isUndefined(S)&&!o.isUndefined(v)){var w=this.getLinkedDictionaryPair(S),T=new s(S,v),g="$"+this.toStr(S);return o.isUndefined(w)?(this.appendToTail(T),this.table[g]=T,void++this.nElements):(this.replace(w,T),w.value)}},b.prototype.keys=function(){var S=[];return this.forEach(function(v,w){S.push(v)}),S},b.prototype.values=function(){var S=[];return this.forEach(function(v,w){S.push(w)}),S},b.prototype.forEach=function(S){for(var v=this.head.next;!u(v);){if(S(v.key,v.value)===!1)return;v=v.next}},b})(m.default);y.default=f},4538(St,y,p){Object.defineProperty(y,"__esModule",{value:!0});var d=p(4831),l=p(4713),m=(function(){function o(){this.firstNode=null,this.lastNode=null,this.nElements=0}return o.prototype.add=function(s,h){if(d.isUndefined(h)&&(h=this.nElements),h<0||h>this.nElements||d.isUndefined(s))return!1;var u=this.createNode(s);if(this.nElements===0||this.lastNode===null)this.firstNode=u,this.lastNode=u;else if(h===this.nElements)this.lastNode.next=u,this.lastNode=u;else if(h===0)u.next=this.firstNode,this.firstNode=u;else{var f=this.nodeAtIndex(h-1);if(f===null)return!1;u.next=f.next,f.next=u}return this.nElements++,!0},o.prototype.first=function(){if(this.firstNode!==null)return this.firstNode.element},o.prototype.last=function(){if(this.lastNode!==null)return this.lastNode.element},o.prototype.elementAtIndex=function(s){var h=this.nodeAtIndex(s);if(h!==null)return h.element},o.prototype.indexOf=function(s,h){var u=h||d.defaultEquals;if(d.isUndefined(s))return-1;for(var f=this.firstNode,r=0;f!==null;){if(u(f.element,s))return r;r++,f=f.next}return-1},o.prototype.contains=function(s,h){return this.indexOf(s,h)>=0},o.prototype.remove=function(s,h){var u=h||d.defaultEquals;if(this.nElements<1||d.isUndefined(s))return!1;for(var f=null,r=this.firstNode;r!==null;){if(u(r.element,s))return f===null?(this.firstNode=r.next,r===this.lastNode&&(this.lastNode=null)):r===this.lastNode?(this.lastNode=f,f.next=r.next,r.next=null):(f.next=r.next,r.next=null),this.nElements--,!0;f=r,r=r.next}return!1},o.prototype.clear=function(){this.firstNode=null,this.lastNode=null,this.nElements=0},o.prototype.equals=function(s,h){var u=h||d.defaultEquals;return s instanceof o&&this.size()===s.size()&&this.equalsAux(this.firstNode,s.firstNode,u)},o.prototype.equalsAux=function(s,h,u){for(;s!==null&&h!==null;){if(!u(s.element,h.element))return!1;s=s.next,h=h.next}return!0},o.prototype.removeElementAtIndex=function(s){if(!(s<0||s>=this.nElements||this.firstNode===null||this.lastNode===null)){var h;if(this.nElements===1)h=this.firstNode.element,this.firstNode=null,this.lastNode=null;else{var u=this.nodeAtIndex(s-1);u===null?(h=this.firstNode.element,this.firstNode=this.firstNode.next):u.next===this.lastNode&&(h=this.lastNode.element,this.lastNode=u),u!==null&&u.next!==null&&(h=u.next.element,u.next=u.next.next)}return this.nElements--,h}},o.prototype.forEach=function(s){for(var h=this.firstNode;h!==null&&s(h.element)!==!1;)h=h.next},o.prototype.reverse=function(){for(var s=null,h=this.firstNode,u=null;h!==null;)u=h.next,h.next=s,s=h,h=u;u=this.firstNode,this.firstNode=this.lastNode,this.lastNode=u},o.prototype.toArray=function(){for(var s=[],h=this.firstNode;h!==null;)s.push(h.element),h=h.next;return s},o.prototype.size=function(){return this.nElements},o.prototype.isEmpty=function(){return this.nElements<=0},o.prototype.toString=function(){return l.toString(this.toArray())},o.prototype.nodeAtIndex=function(s){if(s<0||s>=this.nElements)return null;if(s===this.nElements-1)return this.lastNode;for(var h=this.firstNode,u=0;u-1&&this.insertIdIntoRoot(o,s),this.nodes)if(this.nodes.hasOwnProperty(h)){var u=this.findNodeId(h,m);u>-1&&this.insertIdIntoNode(h,o,u)}},l.prototype.insertIdAfterId=function(m,o){var s=this.findRootId(m);for(var h in s>-1&&this.insertIdIntoRoot(o,s+1),this.nodes)if(this.nodes.hasOwnProperty(h)){var u=this.findNodeId(h,m);u>-1&&this.insertIdIntoNode(h,o,u+1)}},l.prototype.insertIdIntoId=function(m,o){this.nodeInsertAtEnd(m,o),this.nodes[o]=[]},l.prototype.insertIdIntoRoot=function(m,o){if(o===void 0)this.rootInsertAtEnd(m);else if(o<0){var s=this.rootIds.length;this.rootIds.splice(o+s+1,0,m)}else this.rootIds.splice(o,0,m);this.nodes[m]=this.nodes[m]||[]},l.prototype.insertIdIntoNode=function(m,o,s){if(this.nodes[m]=this.nodes[m]||[],this.nodes[o]=this.nodes[o]||[],s===void 0)this.nodeInsertAtEnd(m,o);else if(s<0){var h=this.nodes[m].length;this.nodes[m].splice(s+h+1,0,o)}else this.nodes[m].splice(s,0,o)},l.prototype.moveId=function(m,o,s){var h=m,u=this.findRootId(h);for(var f in this.nodes[o],this.nodes)if(this.nodes.hasOwnProperty(f)){this.findNodeId(f,o);break}var r=o,b=this.findRootId(r);for(var f in this.nodes[o],this.nodes)if(this.nodes.hasOwnProperty(f)){this.findNodeId(f,o);break}if(u>-1){if(b>-1)switch(this.rootDelete(u),b>u&&b--,s){case p.BEFORE:this.insertIdIntoRoot(h,b);break;case p.AFTER:this.insertIdIntoRoot(h,b+1);break;case p.INSIDE_AT_START:this.nodeInsertAtStart(r,h);break;case p.INSIDE_AT_END:this.nodeInsertAtEnd(r,h)}else for(var f in this.rootDelete(u),this.nodes)if(this.nodes.hasOwnProperty(f)&&(S=this.findNodeId(f,r))>-1){switch(s){case p.BEFORE:this.insertIdIntoNode(f,h,S);break;case p.AFTER:this.insertIdIntoNode(f,h,S+1);break;case p.INSIDE_AT_START:this.nodeInsertAtStart(r,h);break;case p.INSIDE_AT_END:this.nodeInsertAtEnd(r,h)}break}}else if(b>-1){for(var f in this.nodes)if(this.nodes.hasOwnProperty(f)&&(S=this.findNodeId(f,h))>-1){this.nodeDeleteAtIndex(f,S);break}switch(s){case p.BEFORE:this.insertIdIntoRoot(h,b);break;case p.AFTER:this.insertIdIntoRoot(h,b+1);break;case p.INSIDE_AT_START:this.nodeInsertAtStart(r,h);break;case p.INSIDE_AT_END:this.nodeInsertAtEnd(r,h)}}else{for(var f in this.nodes)if(this.nodes.hasOwnProperty(f)&&(S=this.findNodeId(f,h))>-1){this.nodeDeleteAtIndex(f,S);break}for(var f in this.nodes){var S;if(this.nodes.hasOwnProperty(f)&&(S=this.findNodeId(f,r))>-1){switch(s){case p.BEFORE:this.insertIdIntoNode(f,h,S);break;case p.AFTER:this.insertIdIntoNode(f,h,S+1);break;case p.INSIDE_AT_START:this.nodeInsertAtStart(r,h);break;case p.INSIDE_AT_END:this.nodeInsertAtEnd(r,h)}break}}}},l.prototype.swapArrayElements=function(m,o,s){var h=m[o];return m[o]=m[s],m[s]=h,m},l.prototype.rootDeleteId=function(m){var o=this.findRootId(m);o>-1&&this.rootDelete(o)},l.prototype.nodeAndSubNodesDelete=function(m){for(var o=[],s=0;sh.size())return!1;var u=!0;return this.forEach(function(f){return!!h.contains(f)||(u=!1,!1)}),u},s.prototype.remove=function(h){return!!this.contains(h)&&(this.dictionary.remove(h),!0)},s.prototype.forEach=function(h){this.dictionary.forEach(function(u,f){return h(f)})},s.prototype.toArray=function(){return this.dictionary.values()},s.prototype.isEmpty=function(){return this.dictionary.isEmpty()},s.prototype.size=function(){return this.dictionary.size()},s.prototype.clear=function(){this.dictionary.clear()},s.prototype.toString=function(){return l.toString(this.toArray())},s})();y.default=o},2083(St,y,p){Object.defineProperty(y,"__esModule",{value:!0});var d=p(4538),l=(function(){function m(){this.list=new d.default}return m.prototype.push=function(o){return this.list.add(o,0)},m.prototype.add=function(o){return this.list.add(o,0)},m.prototype.pop=function(){return this.list.removeElementAtIndex(0)},m.prototype.peek=function(){return this.list.first()},m.prototype.size=function(){return this.list.size()},m.prototype.contains=function(o,s){return this.list.contains(o,s)},m.prototype.isEmpty=function(){return this.list.isEmpty()},m.prototype.clear=function(){this.list.clear()},m.prototype.forEach=function(o){this.list.forEach(o)},m})();y.default=l},4713(St,y,p){Object.defineProperty(y,"__esModule",{value:!0});var d=p(4831);function l(m,o,s){for(var h=s||d.defaultEquals,u=m.length,f=0;f=0;u--)if(h(m[u],o))return u;return-1},y.contains=function(m,o,s){return l(m,o,s)>=0},y.remove=function(m,o,s){var h=l(m,o,s);return!(h<0||(m.splice(h,1),0))},y.frequency=function(m,o,s){for(var h=s||d.defaultEquals,u=m.length,f=0,r=0;r=m.length||s<0||s>=m.length)return!1;var h=m[o];return m[o]=m[s],m[s]=h,!0},y.toString=function(m){return"["+m.toString()+"]"},y.forEach=function(m,o){for(var s=0,h=m;sXn});const d=()=>{};d.L=(vt,i)=>{if(!i)return;const c=Array.prototype.slice.call(i).join(" ");window.console.log(vt+": "+c)},d.MakeException=vt=>class extends Error{constructor(i,c){super(i),this.name=vt,this.message=i,this.data=c}},d.RERR=d.RuntimeError=class{constructor(vt,i){this.code=vt,this.message=i}toString(){return"[RuntimeError] "+this.code+":"+this.message}},d.Merge=(vt,i)=>{for(const c in i)vt[c]=i[c];return vt},d.Min=Math.min,d.Max=Math.max,d.forEach=(vt,i)=>{for(let c=0;cvt%i>=i/2?parseInt(vt/i,10)*i+i:parseInt(vt/i,10)*i,d.MidLine=(vt,i)=>{let c=i+(vt-i)/2;return c%2>0&&(c=d.RoundN(10*c,5)/10),c},d.SortAndUnique=(vt,i,c)=>{if(vt.length>1){const M=[];let I;vt.sort(i);for(let V=0;V{let c=vt.length;for(;c--;)if(vt[c]===i)return!0;return!1},d.getCanvasContext=vt=>{if(!vt)throw new d.RERR("BadArgument","Invalid canvas selector: "+vt);const i=document.getElementById(vt);if(!i||!i.getContext)throw new d.RERR("UnsupportedBrowserError","This browser does not support HTML5 Canvas");return i.getContext("2d")},d.drawDot=(vt,i,c,M="#55")=>{vt.save(),vt.setFillStyle(M),vt.beginPath(),vt.arc(i,c,3,0,2*Math.PI,!0),vt.closePath(),vt.fill(),vt.restore()},d.BM=(vt,i)=>{const c=new Date().getTime();i();const M=new Date().getTime()-c;d.L(vt+M+"ms")},d.StackTrace=()=>new Error().stack,d.W=(...vt)=>{const i=vt.join(" ");window.console.log("Warning: ",i,d.StackTrace())},(d.Prefix=vt=>d.Prefix.prefix+vt).prefix="vf-";class l{static GCD(i,c){if(typeof i!="number"||typeof c!="number")throw new d.RERR("BadArgument",`Invalid numbers: ${i}, ${c}`);let M;for(;c!==0;)M=c,c=i%c,i=M;return i}static LCM(i,c){return i*c/l.GCD(i,c)}static LCMM(i){if(i.length===0)return 0;if(i.length===1)return i[0];if(i.length===2)return l.LCM(i[0],i[1]);{const c=i[0];return i.shift(),l.LCM(c,l.LCMM(i))}}constructor(i,c){this.set(i,c)}set(i,c){return this.numerator=i===void 0?1:i,this.denominator=c===void 0?1:c,this}value(){return this.numerator/this.denominator}simplify(){let i=this.numerator,c=this.denominator;const M=l.GCD(i,c);return i/=M,c/=M,c<0&&(c=-c,i=-i),this.set(i,c)}add(i,c){let M,I;i instanceof l?(M=i.numerator,I=i.denominator):(M=i!==void 0?i:0,I=c!==void 0?c:1);const V=l.LCM(this.denominator,I),X=V/this.denominator,Z=V/I,nt=this.numerator*X+M*Z;return this.set(nt,V)}subtract(i,c){let M,I;i instanceof l?(M=i.numerator,I=i.denominator):(M=i!==void 0?i:0,I=c!==void 0?c:1);const V=l.LCM(this.denominator,I),X=V/this.denominator,Z=V/I,nt=this.numerator*X-M*Z;return this.set(nt,V)}multiply(i,c){let M,I;return i instanceof l?(M=i.numerator,I=i.denominator):(M=i!==void 0?i:1,I=c!==void 0?c:1),this.set(this.numerator*M,this.denominator*I)}divide(i,c){let M,I;return i instanceof l?(M=i.numerator,I=i.denominator):(M=i!==void 0?i:1,I=c!==void 0?c:1),this.set(this.numerator*I,this.denominator*M)}equals(i){const c=l.__compareA.copy(i).simplify(),M=l.__compareB.copy(this).simplify();return c.numerator===M.numerator&&c.denominator===M.denominator}greaterThan(i){const c=l.__compareB.copy(this);return c.subtract(i),c.numerator>0}greaterThanEquals(i){const c=l.__compareB.copy(this);return c.subtract(i),c.numerator>=0}lessThan(i){return!this.greaterThanEquals(i)}lessThanEquals(i){return!this.greaterThan(i)}clone(){return new l(this.numerator,this.denominator)}copy(i){return typeof i=="number"?this.set(i||0,1):this.set(i.numerator,i.denominator)}quotient(){return Math.floor(this.numerator/this.denominator)}fraction(){return this.numerator%this.denominator}abs(){return this.denominator=Math.abs(this.denominator),this.numerator=Math.abs(this.numerator),this}toString(){return this.numerator+"/"+this.denominator}toSimplifiedString(){return l.__tmp.copy(this).simplify().toString()}toMixedString(){let i="";const c=this.quotient(),M=l.__tmp.copy(this);return c<0?M.abs().fraction():M.fraction(),c!==0?(i+=c,M.numerator!==0&&(i+=" "+M.toSimplifiedString())):i=M.numerator===0?"0":M.toSimplifiedString(),i}parse(i){const c=i.split("/"),M=parseInt(c[0],10),I=c[1]?parseInt(c[1],10):1;return this.set(M,I)}}l.__compareA=new l,l.__compareB=new l,l.__tmp=new l;const m=d.MakeException("RegistryError");function o(vt,i,c,M,I){vt[i][c]||(vt[i][c]={}),vt[i][c][M]=I}class s{static get INDEXES(){return["type"]}constructor(){this.clear()}static enableDefaultRegistry(i){s.defaultRegistry=i}static getDefaultRegistry(){return s.defaultRegistry}static disableDefaultRegistry(){s.defaultRegistry=null}clear(){return this.index={id:{},type:{},class:{}},this}updateIndex({id:i,name:c,value:M,oldValue:I}){const V=this.getElementById(i);I!==null&&this.index[c][I]&&delete this.index[c][I][i],M!==null&&o(this.index,c,M,V.getAttribute("id"),V)}register(i,c){if(!(c=c||i.getAttribute("id")))throw new m("Can't add element without `id` attribute to registry",i);return i.setAttribute("id",c),o(this.index,"id",c,c,i),s.INDEXES.forEach(M=>{this.updateIndex({id:c,name:M,value:i.getAttribute(M),oldValue:null})}),i.onRegister(this),this}getElementById(i){return this.index.id[i]?this.index.id[i][i]:null}getElementsByAttribute(i,c){const M=this.index[i];return M&&M[c]?Object.keys(M[c]).map(I=>M[c][I]):[]}getElementsByType(i){return this.getElementsByAttribute("type",i)}getElementsByClass(i){return this.getElementsByAttribute("class",i)}onUpdate({id:i,name:c,value:M,oldValue:I}){return(function(V,X){return V.filter(Z=>Z===X).length>0})(s.INDEXES.concat(["id","class"]),c)?(this.updateIndex({id:i,name:c,value:M,oldValue:I}),this):this}}s.defaultRegistry=null;class h{static newID(){return"auto"+h.ID++}constructor({type:i}={}){this.attrs={id:h.newID(),el:null,type:i||"Base",classes:{}},this.boundingBox=null,this.context=null,this.rendered=!1,s.getDefaultRegistry()&&s.getDefaultRegistry().register(this)}setStyle(i){return this.style=i,this}getStyle(){return this.style}applyStyle(i=this.context,c=this.getStyle()){return c?(i.save(),c.shadowColor&&i.setShadowColor(c.shadowColor),c.shadowBlur&&i.setShadowBlur(c.shadowBlur),c.fillStyle&&i.setFillStyle(c.fillStyle),c.strokeStyle&&i.setStrokeStyle(c.strokeStyle),c.lineWidth&&i.setLineWidth(c.lineWidth),this):this}restoreStyle(i=this.context,c=this.getStyle()){return c?(i.restore(),this):this}drawWithStyle(){this.checkContext(),this.applyStyle(),this.draw(),this.restoreStyle()}hasClass(i){return this.attrs.classes[i]===!0}addClass(i){return this.attrs.classes[i]=!0,this.registry&&this.registry.onUpdate({id:this.getAttribute("id"),name:"class",value:i,oldValue:null}),this}removeClass(i){return delete this.attrs.classes[i],this.registry&&this.registry.onUpdate({id:this.getAttribute("id"),name:"class",value:null,oldValue:i}),this}onRegister(i){return this.registry=i,this}isRendered(){return this.rendered}setRendered(i=!0){return this.rendered=i,this}getAttributes(){return this.attrs}getAttribute(i){return this.attrs[i]}setAttribute(i,c){const M=this.attrs.id,I=this.attrs[i];return this.attrs[i]=c,this.registry&&this.registry.onUpdate({id:M,name:i,value:c,oldValue:I}),this}getContext(){return this.context}setContext(i){return this.context=i,this}getBoundingBox(){return this.boundingBox}checkContext(){if(!this.context)throw new d.RERR("NoContext","No rendering context attached to instance");return this.context}}h.ID=1e3;class u{constructor(i,c,M,I){this.x1=Number.NaN,this.y1=Number.NaN,this.x2=Number.NaN,this.y2=Number.NaN,this.addPoint(i,c),this.addPoint(M,I)}width(){return this.x2-this.x1}height(){return this.y2-this.y1}addPoint(i,c){i!=null&&((isNaN(this.x1)||isNaN(this.x2))&&(this.x1=i,this.x2=i),ithis.x2&&(this.x2=i)),c!=null&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=c,this.y2=c),cthis.y2&&(this.y2=c))}addX(i){this.addPoint(i,null)}addY(i){this.addPoint(null,i)}addQuadraticCurve(i,c,M,I,V,X){const Z=i+.6666666666666666*(M-i),nt=c+2/3*(I-c),at=Z+1/3*(V-i),ft=nt+1/3*(X-c);this.addBezierCurve(i,c,Z,nt,at,ft,V,X)}addBezierCurve(i,c,M,I,V,X,Z,nt){const at=[i,c],ft=[M,I],pt=[V,X],gt=[Z,nt];let bt;this.addPoint(at[0],at[1]),this.addPoint(gt[0],gt[1]);const Mt=(_t,Tt)=>Math.pow(1-_t,3)*at[Tt]+3*Math.pow(1-_t,2)*_t*ft[Tt]+3*(1-_t)*Math.pow(_t,2)*pt[Tt]+Math.pow(_t,3)*gt[Tt];for(bt=0;bt<=1;bt++){const _t=6*at[bt]-12*ft[bt]+6*pt[bt],Tt=-3*at[bt]+9*ft[bt]-9*pt[bt]+3*gt[bt],Ft=3*ft[bt]-3*at[bt];if(Tt===0){if(_t===0)continue;const ne=-Ft/_t;0{if(!vt)throw new d.RERR("BadArgument","Invalid clef: "+vt);const i=v.clefProperties.values[vt];if(!i)throw new d.RERR("BadArgument","Invalid clef: "+vt);return i}};v.clefProperties.values={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}},v.keyProperties=(vt,i,c)=>{i===void 0&&(i="treble");const M={octave_shift:0};typeof c=="object"&&d.Merge(M,c);const I=vt.split("/");if(I.length<2)throw new d.RERR("BadArguments",`Key must have note + octave and an optional glyph: ${vt}`);const V=I[0].toUpperCase(),X=v.keyProperties.note_values[V];if(!X)throw new d.RERR("BadArguments","Invalid key name: "+V);X.octave&&(I[1]=X.octave);let Z=parseInt(I[1],10);Z-=M.octave_shift;let nt=(7*Z-28+X.index)/2;nt+=v.clefProperties(i).line_shift;let at=0;nt<=0&&2*nt%2==0&&(at=1),nt>=6&&2*nt%2==0&&(at=-1);const ft=X.int_val!==void 0?12*Z+X.int_val:null,pt=X.code,gt=X.shift_right;let bt={};if(I.length>2&&I[2]){const Mt=I[2].toUpperCase();bt=v.keyProperties.customNoteHeads[Mt]||{}}return{key:V,octave:Z,line:nt,int_value:ft,accidental:X.accidental,code:pt,stroke:at,shift_right:gt,displaced:!1,...bt}},v.keyProperties.note_values={C:{index:0,int_val:0,accidental:null},CN:{index:0,int_val:0,accidental:"n"},"C#":{index:0,int_val:1,accidental:"#"},"C##":{index:0,int_val:2,accidental:"##"},CB:{index:0,int_val:-1,accidental:"b"},CBB:{index:0,int_val:-2,accidental:"bb"},D:{index:1,int_val:2,accidental:null},DN:{index:1,int_val:2,accidental:"n"},"D#":{index:1,int_val:3,accidental:"#"},"D##":{index:1,int_val:4,accidental:"##"},DB:{index:1,int_val:1,accidental:"b"},DBB:{index:1,int_val:0,accidental:"bb"},E:{index:2,int_val:4,accidental:null},EN:{index:2,int_val:4,accidental:"n"},"E#":{index:2,int_val:5,accidental:"#"},"E##":{index:2,int_val:6,accidental:"##"},EB:{index:2,int_val:3,accidental:"b"},EBB:{index:2,int_val:2,accidental:"bb"},F:{index:3,int_val:5,accidental:null},FN:{index:3,int_val:5,accidental:"n"},"F#":{index:3,int_val:6,accidental:"#"},"F##":{index:3,int_val:7,accidental:"##"},FB:{index:3,int_val:4,accidental:"b"},FBB:{index:3,int_val:3,accidental:"bb"},G:{index:4,int_val:7,accidental:null},GN:{index:4,int_val:7,accidental:"n"},"G#":{index:4,int_val:8,accidental:"#"},"G##":{index:4,int_val:9,accidental:"##"},GB:{index:4,int_val:6,accidental:"b"},GBB:{index:4,int_val:5,accidental:"bb"},A:{index:5,int_val:9,accidental:null},AN:{index:5,int_val:9,accidental:"n"},"A#":{index:5,int_val:10,accidental:"#"},"A##":{index:5,int_val:11,accidental:"##"},AB:{index:5,int_val:8,accidental:"b"},ABB:{index:5,int_val:7,accidental:"bb"},B:{index:6,int_val:11,accidental:null},BN:{index:6,int_val:11,accidental:"n"},"B#":{index:6,int_val:12,accidental:"#"},"B##":{index:6,int_val:13,accidental:"##"},BB:{index:6,int_val:10,accidental:"b"},BBB:{index:6,int_val:9,accidental:"bb"},R:{index:6,int_val:9,rest:!0},X:{index:6,accidental:"",octave:4,code:"v3e",shift_right:5.5}},v.keyProperties.customNoteHeads={D0:{code:"v27",shift_right:0,stem_up_x_offset:0,stem_down_x_offset:0,stem_up_y_offset:-1,stem_down_y_offset:0},D1:{code:"v2d",shift_right:-.5},D2:{code:"v22",shift_right:-.5},D3:{code:"v70",shift_right:-.5},T0:{code:"v49",shift_right:-2,stem_up_y_offset:-4,stem_down_y_offset:4},T1:{code:"v93",shift_right:.5,stem_up_y_offset:-4,stem_down_y_offset:4},T2:{code:"v40",shift_right:.5,stem_up_y_offset:-4,stem_down_y_offset:4},T3:{code:"v7d",shift_right:.5,stem_up_y_offset:-4,stem_down_y_offset:4},TI:{code:"v11",shift_right:0,stem_up_y_shift:5,stem_down_y_shift:5,stem_up_x_offset:6,stem_down_x_offset:4},X0:{code:"v92",stem_up_x_offset:-2,stem_down_x_offset:0,stem_up_y_offset:4,stem_down_y_offset:4},X1:{code:"v95",shift_right:-.5,stem_up_y_offset:4,stem_down_y_offset:4},X2:{code:"v3e",shift_right:.5,stem_up_y_offset:4,stem_down_y_offset:4},X3:{code:"v3b",shift_right:0,stem_up_x_offset:-1.2,stem_down_x_offset:0,stem_up_y_offset:-1,stem_down_y_offset:2},S1:{code:"vd3",shift_right:0},S2:{code:"vd2",shift_right:0},R1:{code:"vd5",shift_right:0},R2:{code:"vd4",shift_right:0},rwl:{code:"rwl",shift_right:0},rhl:{code:"rhl",shift_right:0}},v.integerToNote=vt=>{if(vt===void 0)throw new d.RERR("BadArguments","Undefined integer for integerToNote");if(vt<-2)throw new d.RERR("BadArguments",`integerToNote requires integer > -2: ${vt}`);const i=v.integerToNote.table[vt];if(!i)throw new d.RERR("BadArguments",`Unknown note value for integer: ${vt}`);return i},v.integerToNote.table={0:"C",1:"C#",2:"D",3:"D#",4:"E",5:"F",6:"F#",7:"G",8:"G#",9:"A",10:"A#",11:"B"},v.tabToGlyph=(vt,i=1,c=!1)=>{let M=null,I=0,V=0;if(vt.toString().toUpperCase()==="X"){M="v7f",c&&(M="v3e");const X=new S(M,v.DEFAULT_TABLATURE_FONT_SCALE*i).getMetrics();I=X.width,V=-X.height/2}else I=v.textWidth(vt.toString());return{text:vt,code:M,getWidth:()=>I*i,shift_y:V}},v.textWidth=vt=>7*vt.toString().length,v.articulationCodes=vt=>v.articulationCodes.articulations[vt],v.articulationCodes.articulations={"a.":{code:"v23",between_lines:!0},av:{code:"v28",between_lines:!0},"a>":{code:"v42",between_lines:!0},"a-":{code:"v25",between_lines:!0},"a^":{code:"va",between_lines:!1},"a+":{code:"v8b",between_lines:!1},ao:{code:"v94",between_lines:!1},ah:{code:"vb9",between_lines:!1},"a@a":{code:"v43",between_lines:!1},"a@u":{code:"v5b",between_lines:!1},"a|":{code:"v75",between_lines:!1},am:{code:"v97",between_lines:!1},"a,":{code:"vb3",between_lines:!1}},v.accidentalCodes=vt=>v.accidentalCodes.accidentals[vt],v.accidentalCodes.accidentals={"#":{code:"v18",parenRightPaddingAdjustment:-1},"##":{code:"v7f",parenRightPaddingAdjustment:-1},b:{code:"v44",parenRightPaddingAdjustment:-2},bb:{code:"v26",parenRightPaddingAdjustment:-2},n:{code:"v4e",parenRightPaddingAdjustment:-1},"{":{code:"v9c",parenRightPaddingAdjustment:-1},"}":{code:"v84",parenRightPaddingAdjustment:-1},db:{code:"v9e",parenRightPaddingAdjustment:-1},d:{code:"vab",parenRightPaddingAdjustment:0},bbs:{code:"v90",parenRightPaddingAdjustment:-1},"++":{code:"v51",parenRightPaddingAdjustment:-1},"+":{code:"v78",parenRightPaddingAdjustment:-1},"+-":{code:"v8d",parenRightPaddingAdjustment:-1},"++-":{code:"v7a",parenRightPaddingAdjustment:-1},bs:{code:"vb7",parenRightPaddingAdjustment:-1},bss:{code:"v39",parenRightPaddingAdjustment:-1},o:{code:"vd0",parenRightPaddingAdjustment:-1},k:{code:"vd1",parenRightPaddingAdjustment:-1},ashs:{code:"vd6",parenRightPaddingAdjustment:-1},afhf:{code:"vd7",parenRightPaddingAdjustment:-1}},v.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]}},v.ornamentCodes=vt=>v.ornamentCodes.ornaments[vt],v.ornamentCodes.ornaments={mordent:{code:"v1e"},mordent_inverted:{code:"v45"},turn:{code:"v72"},turn_inverted:{code:"v33"},tr:{code:"v1f"},upprall:{code:"v60"},downprall:{code:"vb4"},prallup:{code:"v6d"},pralldown:{code:"v2c"},upmordent:{code:"v29"},downmordent:{code:"v68"},lineprall:{code:"v20"},prallprall:{code:"v86"}},v.keySignature=vt=>{const i=v.keySignature.keySpecs[vt];if(!i)throw new d.RERR("BadKeySignature",`Bad key signature spec: '${vt}'`);if(!i.acc)return[];const c=v.keySignature.accidentalList(i.acc),M=[];for(let I=0;I({b:[2,.5,2.5,1,3,1.5,3.5],"#":[0,1.5,-.5,1,2.5,.5,2]})[vt],v.parseNoteDurationString=vt=>{if(typeof vt!="string")return null;const i=/(\d*\/?\d+|[a-z])(d*)([nrhms]|$)/.exec(vt);if(!i)return null;const c=i[1],M=i[2].length;let I=i[3];return I.length===0&&(I="n"),{duration:c,dots:M,type:I}},v.parseNoteStruct=vt=>{const i=vt.duration,c=v.parseNoteDurationString(i);if(!c)return null;let M=v.durationToTicks(c.duration);if(M==null)return null;let I=vt.type;const V=[];if(I){if(!v.getGlyphProps.validTypes[I])return null}else I=c.type||"n",vt.keys!==void 0&&vt.keys.forEach((nt,at)=>{const ft=nt.split("/");ft&&ft.length===3&&(V[at]=ft[2])});const X=vt.dots?vt.dots:c.dots;if(typeof X!="number")return null;let Z=M;for(let nt=0;nt{const i=v.durationAliases[vt];if(i!==void 0&&(vt=i),v.durationToTicks.durations[vt]===void 0)throw new d.RERR("BadArguments",`The provided duration is not valid: ${vt}`);return vt},v.durationToFraction=vt=>new l().parse(v.sanitizeDuration(vt)),v.durationToNumber=vt=>v.durationToFraction(vt).value(),v.durationToTicks=vt=>{vt=v.sanitizeDuration(vt);const i=v.durationToTicks.durations[vt];return i===void 0?null:i},v.durationToTicks.durations={"1/2":2*v.RESOLUTION,1:v.RESOLUTION/1,2:v.RESOLUTION/2,4:v.RESOLUTION/4,8:v.RESOLUTION/8,16:v.RESOLUTION/16,32:v.RESOLUTION/32,64:v.RESOLUTION/64,128:v.RESOLUTION/128,256:v.RESOLUTION/256},v.durationAliases={w:"1",h:"2",q:"4",b:"256"},v.getGlyphProps=(vt,i)=>{vt=v.sanitizeDuration(vt);const c=v.getGlyphProps.duration_codes[vt];if(c===void 0)return null;i||(i="n");let M=c.type[i];if(M===void 0){const I=v.keyProperties.customNoteHeads[i.toUpperCase()];if(I===void 0)return null;M={code_head:I.code,...I}}return{...c.common,...M}},v.getGlyphProps.validTypes={n:{name:"note"},r:{name:"rest"},h:{name:"harmonic"},m:{name:"muted"},s:{name:"slash"}},v.getGlyphProps.duration_codes={"1/2":{common:{getWidth(vt=v.DEFAULT_NOTATION_FONT_SCALE){return new S(this.code_head||"v53",vt).getMetrics().width},stem:!1,stem_offset:0,flag:!1,stem_up_extension:-v.STEM_HEIGHT,stem_down_extension:-v.STEM_HEIGHT,tabnote_stem_up_extension:-v.STEM_HEIGHT,tabnote_stem_down_extension:-v.STEM_HEIGHT,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"v53"},h:{code_head:"v59"},m:{code_head:"vf",stem_offset:0},r:{code_head:"v31",rest:!0,position:"B/5",dot_shiftY:.5},s:{getWidth:()=>v.SLASH_NOTEHEAD_WIDTH,position:"B/4"}}},1:{common:{getWidth(vt=v.DEFAULT_NOTATION_FONT_SCALE){return new S(this.code_head||"v1d",vt).getMetrics().width},stem:!1,stem_offset:0,flag:!1,stem_up_extension:-v.STEM_HEIGHT,stem_down_extension:-v.STEM_HEIGHT,tabnote_stem_up_extension:-v.STEM_HEIGHT,tabnote_stem_down_extension:-v.STEM_HEIGHT,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"v1d"},h:{code_head:"v46"},m:{code_head:"v92",stem_offset:-3},r:{code_head:"v5c",rest:!0,position:"D/5",dot_shiftY:.5},s:{getWidth:()=>v.SLASH_NOTEHEAD_WIDTH,position:"B/4"}}},2:{common:{getWidth(vt=v.DEFAULT_NOTATION_FONT_SCALE){return new S(this.code_head||"v81",vt).getMetrics().width},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:"v81"},h:{code_head:"v2d"},m:{code_head:"v95",stem_offset:-3},r:{code_head:"vc",stem:!1,rest:!0,position:"B/4",dot_shiftY:-.5},s:{getWidth:()=>v.SLASH_NOTEHEAD_WIDTH,position:"B/4"}}},4:{common:{getWidth(vt=v.DEFAULT_NOTATION_FONT_SCALE){return new S(this.code_head||"vb",vt).getMetrics().width},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:"vb"},h:{code_head:"v22"},m:{code_head:"v3e",stem_offset:-3},r:{code_head:"v7c",stem:!1,rest:!0,position:"B/4",dot_shiftY:-.5,line_above:1.5,line_below:1.5},s:{getWidth:()=>v.SLASH_NOTEHEAD_WIDTH,position:"B/4"}}},8:{common:{getWidth(vt=v.DEFAULT_NOTATION_FONT_SCALE){return new S(this.code_head||"vb",vt).getMetrics().width},stem:!0,stem_offset:0,flag:!0,beam_count:1,code_flag_upstem:"v54",code_flag_downstem:"v9a",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:"vb"},h:{code_head:"v22"},m:{code_head:"v3e"},r:{code_head:"va5",stem:!1,flag:!1,rest:!0,position:"B/4",dot_shiftY:-.5,line_above:1,line_below:1},s:{getWidth:()=>v.SLASH_NOTEHEAD_WIDTH,position:"B/4"}}},16:{common:{beam_count:2,getWidth(vt=v.DEFAULT_NOTATION_FONT_SCALE){return new S(this.code_head||"vb",vt).getMetrics().width},stem:!0,stem_offset:0,flag:!0,code_flag_upstem:"v3f",code_flag_downstem:"v8f",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:"vb"},h:{code_head:"v22"},m:{code_head:"v3e"},r:{code_head:"v3c",stem:!1,flag:!1,rest:!0,position:"B/4",dot_shiftY:-.5,line_above:1,line_below:2},s:{getWidth:()=>v.SLASH_NOTEHEAD_WIDTH,position:"B/4"}}},32:{common:{beam_count:3,getWidth(vt=v.DEFAULT_NOTATION_FONT_SCALE){return new S(this.code_head||"vb",vt).getMetrics().width},stem:!0,stem_offset:0,flag:!0,code_flag_upstem:"v47",code_flag_downstem:"v2a",stem_up_extension:9,stem_down_extension:9,tabnote_stem_up_extension:8,tabnote_stem_down_extension:5,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"vb"},h:{code_head:"v22"},m:{code_head:"v3e"},r:{code_head:"v55",stem:!1,flag:!1,rest:!0,position:"B/4",dot_shiftY:-1.5,line_above:2,line_below:2},s:{getWidth:()=>v.SLASH_NOTEHEAD_WIDTH,position:"B/4"}}},64:{common:{beam_count:4,getWidth(vt=v.DEFAULT_NOTATION_FONT_SCALE){return new S(this.code_head||"vb",vt).getMetrics().width},stem:!0,stem_offset:0,flag:!0,code_flag_upstem:"va9",code_flag_downstem:"v58",stem_up_extension:13,stem_down_extension:13,tabnote_stem_up_extension:12,tabnote_stem_down_extension:9,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"vb"},h:{code_head:"v22"},m:{code_head:"v3e"},r:{code_head:"v38",stem:!1,flag:!1,rest:!0,position:"B/4",dot_shiftY:-1.5,line_above:2,line_below:3},s:{getWidth:()=>v.SLASH_NOTEHEAD_WIDTH,position:"B/4"}}},128:{common:{beam_count:5,getWidth(vt=v.DEFAULT_NOTATION_FONT_SCALE){return new S(this.code_head||"vb",vt).getMetrics().width},stem:!0,stem_offset:0,flag:!0,code_flag_upstem:"v9b",code_flag_downstem:"v30",stem_up_extension:22,stem_down_extension:22,tabnote_stem_up_extension:21,tabnote_stem_down_extension:18,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"vb"},h:{code_head:"v22"},m:{code_head:"v3e"},r:{code_head:"vaa",stem:!1,flag:!1,rest:!0,position:"B/4",dot_shiftY:1.5,line_above:3,line_below:3},s:{getWidth:()=>v.SLASH_NOTEHEAD_WIDTH,position:"B/4"}}}},v.smufl={},v.smufl.to_code_points={bracketTop:"v1b",bracketBottom:"v10",barlineTick:"v6f",segno:"v8c",coda:"v4d",gClef:"v83",cClef:"vad",fClef:"v79",unpitchedPercussionClef1:"v59","6stringTabClef":"v2f",timeSig0:"v0",timeSig1:"v1",timeSig2:"v2",timeSig3:"v3",timeSig4:"v4",timeSig5:"v5",timeSig6:"v6",timeSig7:"v7",timeSig8:"v8",timeSig9:"v9",timeSigCommon:"v41",timeSigCutCommon:"vb6",noteheadDoubleWhole:"v53",noteheadWhole:"v1d",noteheadHalf:"v81",noteheadBlack:"vb",noteheadXWhole:"v92",noteheadXHalf:"v95",noteheadXBlack:"v3e",noteheadCircleX:"v3b",noteheadTriangleUpWhole:"v49",noteheadTriangleUpHalf:"v93",noteheadTriangleUpBlack:"v40",noteheadDiamondWhole:"v46",noteheadDiamondHalf:"v2d",noteheadDiamondBlack:"v22",augmentationDot:"v23",tremolo1:"v74",flag8thUp:"v54",flag8thDown:"v9a",flag16thUp:"v3f",flag16thDown:"v8f",flag32ndUp:"v47",flag32ndDown:"v2a",flag64thUp:"va9",flag64thDown:"v58",flag128thUp:"v9b",flag128thDown:"v30",accidentalFlat:"v44",accidentalNatural:"v4e",accidentalSharp:"v18",accidentalDoubleSharp:"v7f",accidentalDoubleFlat:"v26",accidentalParensLeft:"v9c",accidentalParensRight:"v84",accidentalQuarterToneFlatStein:"vab",accidentalThreeQuarterTonesFlatZimmermann:"v9e",accidentalQuarterToneSharpStein:"v78",accidentalThreeQuarterTonesSharpStein:"v51",accidentalBuyukMucennebFlat:"v39",accidentalBakiyeFlat:"vb7",accidentalKomaSharp:"v51",accidentalKucukMucennebSharp:"v8d",accidentalKoron:"vd1",accidentalSori:"vd0",articAccentAbove:"v42",articAccentBelow:"v42",articTenutoAbove:"v25",articTenutoBelow:"v25",articStaccatoAbove:"v23",articStaccatoBelow:"v23",articStaccatissimoAbove:"v28",articMarcatoAbove:"va",fermataAbove:"v43",fermataBelow:"v5b",breathMarkComma:"v6c",breathMarkUpbow:"v8a",caesura:"v34",caesuraCurved:"v4b",restMaxima:"v59",restDoubleWhole:"v31",restWhole:"v5c",restHalf:"vc",restQuarter:"v7c",rest8th:"va5",rest16th:"v3c",rest32nd:"v55",rest64th:"v38",rest128th:"vaa",dynamicPiano:"vbf",dynamicMezzo:"v62",dynamicForte:"vba",dynamicRinforzando:"vba",dynamicSforzando:"v4a",dynamicZ:"v80",ornamentTrill:"v1f",ornamentTurn:"v72",ornamentTurnSlash:"v33",ornamentMordent:"v45",ornamentMordentInverted:"v1e",ornamentTremblement:"v86",ornamentPrecompAppoggTrill:"v20",ornamentPrecompSlideTrillDAnglebert:"v60",ornamentPrecompSlideTrillBach:"v29",ornamentPrecompTrillSuffixDandrieu:"v6d",ornamentPrecompDoubleCadenceUpperPrefix:"vb4",ornamentPrecompDoubleCadenceUpperPrefixTurn:"v68",ornamentPrecompTrillLowerSuffix:"v2c",stringsDownBow:"v94",stringsUpBow:"v75",stringsHarmonic:"vb9",pluckedSnapPizzicatoAbove:"v94",pluckedLeftHandPizzicato:"v8b",keyboardPedalPed:"v36",keyboardPedalUp:"v5d",pictChokeCymbal:"vb3",wiggleArpeggiatoUp:"va3",arrowheadBlackUp:"vc3",arrowheadBlackDown:"v52"},v.TIME4_4={num_beats:4,beat_value:4,resolution:v.RESOLUTION};class w{static get WIDTH(){return 600}static get HEIGHT(){return 400}static get CANVAS_BROWSER_SIZE_LIMIT(){return 32767}static SanitizeCanvasDims(i,c){return Math.max(i,c)>this.CANVAS_BROWSER_SIZE_LIMIT&&(d.W("Canvas dimensions exceed browser limit. Cropping to "+this.CANVAS_BROWSER_SIZE_LIMIT),i>this.CANVAS_BROWSER_SIZE_LIMIT&&(i=this.CANVAS_BROWSER_SIZE_LIMIT),c>this.CANVAS_BROWSER_SIZE_LIMIT&&(c=this.CANVAS_BROWSER_SIZE_LIMIT)),[i,c]}constructor(i){this.vexFlowCanvasContext=i,i.canvas?this.canvas=i.canvas:this.canvas={width:w.WIDTH,height:w.HEIGHT}}clear(){this.vexFlowCanvasContext.clearRect(0,0,this.canvas.width,this.canvas.height)}openGroup(){}closeGroup(){}add(){}setFont(i,c,M){return this.vexFlowCanvasContext.font=(M||"")+" "+c+"pt "+i,this}setRawFont(i){return this.vexFlowCanvasContext.font=i,this}setFillStyle(i){return this.vexFlowCanvasContext.fillStyle=i,this}setBackgroundFillStyle(i){return this.background_fillStyle=i,this}setStrokeStyle(i){return this.vexFlowCanvasContext.strokeStyle=i,this}setShadowColor(i){return this.vexFlowCanvasContext.shadowColor=i,this}setShadowBlur(i){return this.vexFlowCanvasContext.shadowBlur=i,this}setLineWidth(i){return this.vexFlowCanvasContext.lineWidth=i,this}setLineCap(i){return this.vexFlowCanvasContext.lineCap=i,this}setLineDash(i){return this.vexFlowCanvasContext.lineDash=i,this}scale(i,c){return this.vexFlowCanvasContext.scale(parseFloat(i),parseFloat(c))}resize(i,c){return[i,c]=this.SanitizeCanvasDims(parseInt(i,10),parseInt(c,10)),this.vexFlowCanvasContext.resize(i,c)}rect(i,c,M,I){return this.vexFlowCanvasContext.rect(i,c,M,I)}fillRect(i,c,M,I){return this.vexFlowCanvasContext.fillRect(i,c,M,I)}clearRect(i,c,M,I){return this.vexFlowCanvasContext.clearRect(i,c,M,I)}beginPath(){return this.vexFlowCanvasContext.beginPath()}moveTo(i,c){return this.vexFlowCanvasContext.moveTo(i,c)}lineTo(i,c){return this.vexFlowCanvasContext.lineTo(i,c)}bezierCurveTo(i,c,M,I,V,X){return this.vexFlowCanvasContext.bezierCurveTo(i,c,M,I,V,X)}quadraticCurveTo(i,c,M,I){return this.vexFlowCanvasContext.quadraticCurveTo(i,c,M,I)}arc(i,c,M,I,V,X){return this.vexFlowCanvasContext.arc(i,c,M,I,V,X)}glow(){return this.vexFlowCanvasContext.glow()}fill(){return this.vexFlowCanvasContext.fill()}stroke(){return this.vexFlowCanvasContext.stroke()}closePath(){return this.vexFlowCanvasContext.closePath()}measureText(i){return this.vexFlowCanvasContext.measureText(i)}fillText(i,c,M){return this.vexFlowCanvasContext.fillText(i,c,M)}save(){return this.vexFlowCanvasContext.save()}restore(){return this.vexFlowCanvasContext.restore()}}class T{constructor(i){this.element=i,this.paper=Raphael(i),this.path="",this.pen={x:0,y:0},this.lineWidth=1,this.state={scale:{x:1,y:1},font_family:"Arial",font_size:8,font_weight:800},this.attributes={"stroke-width":.3,fill:"black",stroke:"black",font:"10pt Arial"},this.background_attributes={"stroke-width":0,fill:"white",stroke:"white",font:"10pt Arial"},this.shadow_attributes={width:0,color:"black"},this.state_stack=[]}openGroup(){}closeGroup(){}add(){}setFont(i,c,M){return this.state.font_family=i,this.state.font_size=c,this.state.font_weight=M,this.attributes.font=(this.state.font_weight||"")+" "+this.state.font_size*this.state.scale.x+"pt "+this.state.font_family,this}setRawFont(i){return this.attributes.font=i,this}setFillStyle(i){return this.attributes.fill=i,this}setBackgroundFillStyle(i){return this.background_attributes.fill=i,this.background_attributes.stroke=i,this}setStrokeStyle(i){return this.attributes.stroke=i,this}setShadowColor(i){return this.shadow_attributes.color=i,this}setShadowBlur(i){return this.shadow_attributes.width=i,this}setLineWidth(i){this.attributes["stroke-width"]=i,this.lineWidth=i}setLineDash(){return this}setLineCap(){return this}scale(i,c){return this.state.scale={x:i,y:c},this.attributes.transform="S"+i+","+c+",0,0",this.attributes.scale=i+","+c+",0,0",this.attributes.font=this.state.font_size*this.state.scale.x+"pt "+this.state.font_family,this.background_attributes.transform="S"+i+","+c+",0,0",this.background_attributes.font=this.state.font_size*this.state.scale.x+"pt "+this.state.font_family,this}clear(){this.paper.clear()}resize(i,c){return this.element.style.width=i,this.paper.setSize(i,c),this}setViewBox(i){this.paper.canvas.setAttribute("viewBox",i)}rect(i,c,M,I){return I<0&&(c+=I,I=-I),this.paper.rect(i,c,M-.5,I-.5).attr(this.attributes).attr("fill","none").attr("stroke-width",this.lineWidth),this}fillRect(i,c,M,I){return I<0&&(c+=I,I=-I),this.paper.rect(i,c,M-.5,I-.5).attr(this.attributes),this}clearRect(i,c,M,I){return I<0&&(c+=I,I=-I),this.paper.rect(i,c,M-.5,I-.5).attr(this.background_attributes),this}beginPath(){return this.path="",this.pen.x=0,this.pen.y=0,this}moveTo(i,c){return this.path+="M"+i+","+c,this.pen.x=i,this.pen.y=c,this}lineTo(i,c){return this.path+="L"+i+","+c,this.pen.x=i,this.pen.y=c,this}bezierCurveTo(i,c,M,I,V,X){return this.path+="C"+i+","+c+","+M+","+I+","+V+","+X,this.pen.x=V,this.pen.y=X,this}quadraticCurveTo(i,c,M,I){return this.path+="Q"+i+","+c+","+M+","+I,this.pen.x=M,this.pen.y=I,this}arc(i,c,M,I,V,X){function Z(at){for(;at<0;)at+=2*Math.PI;for(;at>2*Math.PI;)at-=2*Math.PI;return at}if((I=Z(I))>(V=Z(V))){const at=I;I=V,V=at,X=!X}const nt=V-I;return nt>Math.PI?(this.arcHelper(i,c,M,I,I+nt/2,X),this.arcHelper(i,c,M,I+nt/2,V,X)):this.arcHelper(i,c,M,I,V,X),this}arcHelper(i,c,M,I,V,X){const Z=i+M*Math.cos(I),nt=c+M*Math.sin(I),at=i+M*Math.cos(V),ft=c+M*Math.sin(V);let pt=0,gt=0;X?(gt=1,V-IMath.PI&&(pt=1),this.path+="M"+Z+","+nt+",A"+M+","+M+",0,"+pt+","+gt+","+at+","+ft+"M"+this.pen.x+","+this.pen.y}glow(){const i=this.paper.set();if(this.shadow_attributes.width>0){const c=this.shadow_attributes,M=c.width/2;for(let I=1;I<=M;I++)i.push(this.paper.path(this.path).attr({stroke:c.color,"stroke-linejoin":"round","stroke-linecap":"round","stroke-width":+(c.width/M*I).toFixed(3),opacity:+((c.opacity||.3)/M).toFixed(3),transform:this.attributes.transform,scale:this.attributes.scale}))}return i}fill(){const i=this.paper.path(this.path).attr(this.attributes).attr("stroke-width",0);return this.glow(i),this}stroke(){const i=this.lineWidth*(this.state.scale.x+this.state.scale.y)/2,c=this.paper.path(this.path).attr(this.attributes).attr("fill","none").attr("stroke-width",i);return this.glow(c),this}closePath(){return this.path+="Z",this}measureText(i){const c=this.paper.text(0,0,i).attr(this.attributes).attr("fill","none").attr("stroke","none"),M=c.getBBox();return c.remove(),{width:M.width,height:M.height}}fillText(i,c,M){return this.paper.text(c+this.measureText(i).width/2,M-this.state.font_size/(2.25*this.state.scale.y),i).attr(this.attributes),this}save(){return this.state_stack.push({state:{font_family:this.state.font_family},attributes:{font:this.attributes.font,fill:this.attributes.fill,stroke:this.attributes.stroke,"stroke-width":this.attributes["stroke-width"]},shadow_attributes:{width:this.shadow_attributes.width,color:this.shadow_attributes.color}}),this}restore(){const i=this.state_stack.pop();return this.state.font_family=i.state.font_family,this.attributes.font=i.attributes.font,this.attributes.fill=i.attributes.fill,this.attributes.stroke=i.attributes.stroke,this.attributes["stroke-width"]=i.attributes["stroke-width"],this.shadow_attributes.width=i.shadow_attributes.width,this.shadow_attributes.color=i.shadow_attributes.color,this}}const g={path:{x:!0,y:!0,width:!0,height:!0},rect:{},text:{width:!0,height:!0}};{const vt={"font-family":!0,"font-weight":!0,"font-style":!0,"font-size":!0};d.Merge(g.rect,vt),d.Merge(g.path,vt)}class x{constructor(i){this.element=i,this.svgNS="http://www.w3.org/2000/svg";const c=this.create("svg");this.element.appendChild(c),this.svg=c,this.groups=[this.svg],this.parent=this.svg,this.path="",this.pen={x:NaN,y:NaN},this.lineWidth=1,this.state={scale:{x:1,y:1},"font-family":"Arial","font-size":"8pt","font-weight":"normal"},this.attributes={"stroke-width":.3,fill:"black",stroke:"black","stroke-dasharray":"none","font-family":"Arial","font-size":"10pt","font-weight":"normal","font-style":"normal"},this.background_attributes={"stroke-width":0,fill:"white",stroke:"white","stroke-dasharray":"none","font-family":"Arial","font-size":"10pt","font-weight":"normal","font-style":"normal"},this.shadow_attributes={width:0,color:"black"},this.state_stack=[],this.iePolyfill()}create(i){return document.createElementNS(this.svgNS,i)}openGroup(i,c,M){const I=this.create("g");return this.groups.push(I),this.parent.appendChild(I),this.parent=I,i&&I.setAttribute("class",d.Prefix(i)),c&&I.setAttribute("id",d.Prefix(c)),M&&M.pointerBBox&&I.setAttribute("pointer-events","bounding-box"),I}closeGroup(){this.groups.pop(),this.parent=this.groups[this.groups.length-1]}add(i){this.parent.appendChild(i)}iePolyfill(){typeof navigator<"u"&&(this.ie=/MSIE 9/i.test(navigator.userAgent)||/MSIE 10/i.test(navigator.userAgent)||/rv:11\.0/i.test(navigator.userAgent)||/Trident/i.test(navigator.userAgent))}setFont(i,c,M){let I=!1,V=!1,X="normal";typeof M=="string"&&(M.indexOf("italic")!==-1&&(M=M.replace(/italic/g,""),V=!0),M.indexOf("bold")!==-1&&(M=M.replace(/bold/g,""),I=!0),M=M.replace(/ /g,"")),X=V?"italic":X;const Z={"font-family":i,"font-size":c+"pt","font-weight":M=(M=I?"bold":M)===void 0||M===""?"normal":M,"font-style":X};return this.fontSize=Number(c),d.Merge(this.attributes,Z),d.Merge(this.state,Z),this}setRawFont(i){const c=(i=i.trim()).split(" ");return this.attributes["font-family"]=c[1],this.state["font-family"]=c[1],this.attributes["font-size"]=c[0],this.state["font-size"]=c[0],this.fontSize=Number(c[0].match(/\d+/)),this}setFillStyle(i){return this.attributes.fill=i,this}setBackgroundFillStyle(i){return this.background_attributes.fill=i,this.background_attributes.stroke=i,this}setStrokeStyle(i){return this.attributes.stroke=i,this}setShadowColor(i){return this.shadow_attributes.color=i,this}setShadowBlur(i){return this.shadow_attributes.width=i,this}setLineWidth(i){this.attributes["stroke-width"]=i,this.lineWidth=i}setLineDash(i){if(Object.prototype.toString.call(i)==="[object Array]")return i=i.join(", "),this.attributes["stroke-dasharray"]=i,this;throw new d.RERR("ArgumentError","lineDash must be an array of integers.")}setLineCap(i){return this.attributes["stroke-linecap"]=i,this}resize(i,c){this.width=i,this.height=c,this.element.style.width=i;const M={width:i,height:c};return this.applyAttributes(this.svg,M),this.scale(this.state.scale.x,this.state.scale.y),this}scale(i,c){this.state.scale={x:i,y:c};const M=this.width/i,I=this.height/c;return this.setViewBox(0,0,M,I),this}setViewBox(...i){if(i.length===1){const[c]=i;this.svg.setAttribute("viewBox",c)}else{const[c,M,I,V]=i,X=c+" "+M+" "+I+" "+V;this.svg.setAttribute("viewBox",X)}}applyAttributes(i,c){const M=g[i.nodeName];return Object.keys(c).forEach(I=>{M&&M[I]||i.setAttributeNS(null,I,c[I])}),i}clear(){for(;this.svg.lastChild;)this.svg.removeChild(this.svg.lastChild);this.scale(this.state.scale.x,this.state.scale.y)}rect(i,c,M,I,V){I<0&&(c+=I,I*=-1);const X=this.create("rect");return V===void 0&&(V={fill:"none","stroke-width":this.lineWidth,stroke:this.attributes.stroke}),d.Merge(V,{x:i,y:c,width:M,height:I}),this.applyAttributes(X,V),this.add(X),this}fillRect(i,c,M,I){return I<0&&(c+=I,I*=-1),this.rect(i,c,M,I,this.attributes),this}clearRect(i,c,M,I){return this.rect(i,c,M,I,this.background_attributes),this}beginPath(){return this.path="",this.pen.x=NaN,this.pen.y=NaN,this}moveTo(i,c){return this.path+="M"+i+" "+c,this.pen.x=i,this.pen.y=c,this}lineTo(i,c){return this.path+="L"+i+" "+c,this.pen.x=i,this.pen.y=c,this}bezierCurveTo(i,c,M,I,V,X){return this.path+="C"+i+" "+c+","+M+" "+I+","+V+" "+X,this.pen.x=V,this.pen.y=X,this}quadraticCurveTo(i,c,M,I){return this.path+="Q"+i+" "+c+","+M+" "+I,this.pen.x=M,this.pen.y=I,this}arc(i,c,M,I,V,X){function Z(at){for(;at<0;)at+=2*Math.PI;for(;at>2*Math.PI;)at-=2*Math.PI;return at}if((I=Z(I))>(V=Z(V))){const at=I;I=V,V=at,X=!X}const nt=V-I;return nt>Math.PI?(this.arcHelper(i,c,M,I,I+nt/2,X),this.arcHelper(i,c,M,I+nt/2,V,X)):this.arcHelper(i,c,M,I,V,X),this}arcHelper(i,c,M,I,V,X){const Z=i+M*Math.cos(I),nt=c+M*Math.sin(I),at=i+M*Math.cos(V),ft=c+M*Math.sin(V);let pt=0,gt=0;X?(gt=1,V-IMath.PI&&(pt=1),this.path+="M"+Z+" "+nt+" A"+M+" "+M+" 0 "+pt+" "+gt+" "+at+" "+ft,isNaN(this.pen.x)||isNaN(this.pen.y)||(this.peth+="M"+this.pen.x+" "+this.pen.y)}closePath(){return this.path+="Z",this}glow(){if(this.shadow_attributes.width>0){const i=this.shadow_attributes,c=i.width/2;for(let M=1;M<=c;M++){const I={stroke:i.color,"stroke-linejoin":"round","stroke-linecap":"round","stroke-width":+(.4*i.width/c*M).toFixed(3),opacity:+((i.opacity||.3)/c).toFixed(3)},V=this.create("path");I.d=this.path,this.applyAttributes(V,I),this.add(V)}}return this}fill(i){this.glow();const c=this.create("path");let M=i;return i===void 0?(d.Merge(i={},this.attributes),i.stroke="none",M=i):(M=i,d.Merge(M,this.attributes),i.class&&(M.class=i.class),i.id&&(M.id=i.id)),i.d=this.path,this.applyAttributes(c,i),this.add(c),this}stroke(i=void 0){this.glow();const c=this.create("path"),M={};return d.Merge(M,this.attributes),i&&d.Merge(M,i),M.fill="none",M["stroke-width"]=this.lineWidth,M.d=this.path,this.applyAttributes(c,M),this.add(c),this}measureText(i){const c=this.create("text");if(typeof c.getBBox!="function")return{x:0,y:0,width:0,height:0};c.textContent=i,this.applyAttributes(c,this.attributes),this.svg.appendChild(c);let M=c.getBBox();return this.ie&&i!==""&&this.attributes["font-style"]==="italic"&&(M=this.ieMeasureTextFix(M,i)),this.svg.removeChild(c),M}ieMeasureTextFix(i){const c=1.196*Number(this.fontSize)+1.9598,M=i.width-c,I=i.height-1.5;return{x:i.x,y:i.y,width:M,height:I}}fillText(i,c,M){if(!i||i.length<=0)return;const I={};d.Merge(I,this.attributes),I.stroke="none",I.x=c,I.y=M;const V=this.create("text");V.textContent=i,this.applyAttributes(V,I),this.add(V)}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 i=this.state_stack.pop();return this.state["font-family"]=i.state["font-family"],this.state["font-weight"]=i.state["font-weight"],this.state["font-style"]=i.state["font-style"],this.state["font-size"]=i.state["font-size"],this.state.scale=i.state.scale,this.attributes["font-family"]=i.attributes["font-family"],this.attributes["font-weight"]=i.attributes["font-weight"],this.attributes["font-style"]=i.attributes["font-style"],this.attributes["font-size"]=i.attributes["font-size"],this.attributes.fill=i.attributes.fill,this.attributes.stroke=i.attributes.stroke,this.attributes["stroke-width"]=i.attributes["stroke-width"],this.attributes["stroke-dasharray"]=i.attributes["stroke-dasharray"],this.shadow_attributes.width=i.shadow_attributes.width,this.shadow_attributes.color=i.shadow_attributes.color,this.lineWidth=i.lineWidth,this}}let P=null;class _{static get Backends(){return{CANVAS:1,RAPHAEL:2,SVG:3,VML:4}}static get LineEndType(){return{NONE:1,UP:2,DOWN:3}}static get USE_CANVAS_PROXY(){return!1}static get lastContext(){return P}static set lastContext(i){P=i}static buildContext(i,c,M,I,V){const X=new _(i,c);M&&I&&X.resize(M,I),V||(V="#FFF");const Z=X.getContext();return Z.setBackgroundFillStyle(V),_.lastContext=Z,Z}static getCanvasContext(i,c,M,I){return _.buildContext(i,_.Backends.CANVAS,c,M,I)}static getRaphaelContext(i,c,M,I){return _.buildContext(i,_.Backends.RAPHAEL,c,M,I)}static getSVGContext(i,c,M,I){return _.buildContext(i,_.Backends.SVG,c,M,I)}static bolsterCanvasContext(i){return _.USE_CANVAS_PROXY?new w(i):(i.vexFlowCanvasContext=i,["clear","setFont","setRawFont","setFillStyle","setBackgroundFillStyle","setStrokeStyle","setShadowColor","setShadowBlur","setLineWidth","setLineCap","setLineDash","openGroup","closeGroup","getGroup"].forEach(c=>{i[c]=i[c]||w.prototype[c]}),i)}static drawDashedLine(i,c,M,I,V,X){i.beginPath();const Z=I-c,nt=V-M,at=Math.atan2(nt,Z);let ft=c,pt=M;i.moveTo(c,M);let gt=0,bt=!0;for(;!(Z<0?ft<=I:ft>=I)||!(nt<0?pt<=V:pt>=V);){const Mt=X[gt++%X.length],_t=ft+Math.cos(at)*Mt;ft=Z<0?Math.max(I,_t):Math.min(I,_t);const Tt=pt+Math.sin(at)*Mt;pt=nt<0?Math.max(V,Tt):Math.min(V,Tt),bt?i.lineTo(ft,pt):i.moveTo(ft,pt),bt=!bt}i.closePath(),i.stroke()}constructor(i,c){if(this.elementId=i,!this.elementId)throw new d.RERR("BadArgument","Invalid id for renderer.");if(this.element=document.getElementById(i),this.element||(this.element=i),this.ctx=null,this.paper=null,this.backend=c,this.backend===_.Backends.CANVAS){if(!this.element.getContext)throw new d.RERR("BadElement",`Can't get canvas context from element: ${i}`);this.ctx=_.bolsterCanvasContext(this.element.getContext("2d",{willReadFrequently:!0}))}else if(this.backend===_.Backends.RAPHAEL)this.ctx=new T(this.element);else{if(this.backend!==_.Backends.SVG)throw new d.RERR("InvalidBackend",`No support for backend: ${this.backend}`);this.ctx=new x(this.element)}}resize(i,c){if(this.backend===_.Backends.CANVAS){if(!this.element.getContext)throw new d.RERR("BadElement",`Can't get canvas context from element: ${this.elementId}`);[i,c]=w.SanitizeCanvasDims(i,c);const M=window.devicePixelRatio||1;this.element.width=i*M,this.element.height=c*M,this.element.style.width=i+"px",this.element.style.height=c+"px",this.ctx=_.bolsterCanvasContext(this.element.getContext("2d",{willReadFrequently:!0})),this.ctx.scale(M,M)}else this.ctx.resize(i,c);return this}getContext(){return this.ctx}}class B extends h{static get CATEGORY(){return"stem"}static get UP(){return 1}static get DOWN(){return-1}static get WIDTH(){return v.STEM_WIDTH}static get HEIGHT(){return v.STEM_HEIGHT}constructor(i={}){super(),this.setAttribute("type","Stem"),this.x_begin=i.x_begin||0,this.x_end=i.x_end||0,this.y_top=i.y_top||0,this.y_bottom=i.y_bottom||0,this.stem_extension=i.stem_extension||0,this.stem_direction=i.stem_direction||0,this.hide=i.hide||!1,this.isStemlet=i.isStemlet||!1,this.stemletHeight=i.stemletHeight||0,this.renderHeightAdjustment=0,this.setOptions(i)}setOptions(i){this.stem_up_y_offset=i.stem_up_y_offset||0,this.stem_down_y_offset=i.stem_down_y_offset||0}setNoteHeadXBounds(i,c){return this.x_begin=i,this.x_end=c,this}setDirection(i){this.stem_direction=i}setExtension(i){this.stem_extension=i}getExtension(){return this.stem_extension}setYBounds(i,c){this.y_top=i,this.y_bottom=c}getCategory(){return B.CATEGORY}getHeight(){const i=this.stem_direction===B.UP?this.stem_up_y_offset:this.stem_down_y_offset;return(this.y_bottom-this.y_top)*this.stem_direction+(B.HEIGHT-i+this.stem_extension)*this.stem_direction}getBoundingBox(){throw new d.RERR("NotImplemented","getBoundingBox() not implemented.")}getExtents(){const i=this.stem_direction===B.UP,c=[this.y_top,this.y_bottom],M=B.HEIGHT+this.stem_extension,I=(i?Math.min:Math.max)(...c),V=(i?Math.max:Math.min)(...c);return{topY:I+M*-this.stem_direction,baseY:V}}setVisibility(i){return this.hide=!i,this}setStemlet(i,c){return this.isStemlet=i,this.stemletHeight=c,this}draw(){if(this.setRendered(),this.hide)return;const i=this.checkContext();let c,M;const I=this.stem_direction;I===B.DOWN?(c=this.x_begin,M=this.y_top+this.stem_down_y_offset):(c=this.x_end,M=this.y_bottom-this.stem_up_y_offset);const V=this.getHeight();(function(...Z){B.DEBUG&&d.L("Vex.Flow.Stem",Z)})("Rendering stem - ","Top Y: ",this.y_top,"Bottom Y: ",this.y_bottom);const X=this.isStemlet?V-this.stemletHeight*this.stem_direction:0;if(i.save(),this.applyStyle(i),i.beginPath(),i.setLineWidth(B.WIDTH),i.moveTo(c,M-X),i.lineTo(c,M-V-this.renderHeightAdjustment*I),i.svg){const Z={class:d.Prefix("stem")};this.id&&(Z.id=this.id),i.stroke(Z)}else i.stroke();this.restoreStyle(i),i.restore()}}class k extends h{static get LOCATION_TOP(){return 1}static get LOCATION_BOTTOM(){return-1}static get NESTING_OFFSET(){return 15}constructor(i,c){if(super(),this.setAttribute("type","Tuplet"),!i||!i.length)throw new d.RuntimeError("BadArguments","No notes provided for tuplet.");this.options=d.Merge({},c),this.notes=i,this.num_notes="num_notes"in this.options?this.options.num_notes:i.length,this.options.beats_occupied&&this.beatsOccupiedDeprecationWarning(),this.notes_occupied=this.options.notes_occupied||this.options.beats_occupied||2,"bracketed"in this.options?this.bracketed=this.options.bracketed:this.bracketed=i.some(M=>M.beam===null),this.ratioed="ratioed"in this.options?this.options.ratioed:Math.abs(this.notes_occupied-this.num_notes)>1,this.point=28,this.y_pos=16,this.x_pos=100,this.width=200,this.location=this.options.location||k.LOCATION_TOP,$t.AlignRestsToNotes(i,!0,!0),this.resolveGlyphs(),this.attach()}attach(){for(let i=0;i=1;)this.numerator_glyphs.unshift(new S("v"+i%10,this.point)),i=parseInt(i/10,10);for(this.denom_glyphs=[],i=this.notes_occupied;i>=1;)this.denom_glyphs.unshift(new S("v"+i%10,this.point)),i=parseInt(i/10,10)}getNestedTupletCount(){const i=this.location,c=this.notes[0];let M=V(c,i),I=V(c,i);function V(X,Z){return X.tupletStack.filter(nt=>nt.location===Z).length}return this.notes.forEach(X=>{const Z=V(X,i);M=Z>M?Z:M,I=ZI&&(I=X)}}return I+i+c}draw(){this.checkContext(),this.setRendered();const i=this.notes[0],c=this.notes[this.notes.length-1];this.bracketed?(this.x_pos=i.getTieLeftX()-5,this.width=c.getTieRightX()-this.x_pos+5):(this.x_pos=i.getStemX(),this.width=c.getStemX()-this.x_pos),this.y_pos=this.getYPosition();const M=(Z,nt)=>Z+nt.getMetrics().width;let I=this.numerator_glyphs.reduce(M,0);this.ratioed&&(I=this.denom_glyphs.reduce(M,I),I+=.32*this.point);const V=this.x_pos+this.width/2-I/2;if(this.bracketed){const Z=this.width/2-I/2-5;Z>0&&(this.context.fillRect(this.x_pos,this.y_pos,Z,1),this.context.fillRect(this.x_pos+this.width/2+I/2+5,this.y_pos,Z,1),this.context.fillRect(this.x_pos,this.y_pos+(this.location===k.LOCATION_BOTTOM),1,10*this.location),this.context.fillRect(this.x_pos+this.width,this.y_pos+(this.location===k.LOCATION_BOTTOM),1,10*this.location))}let X=0;if(this.RenderTupletNumber!==!1&&this.numerator_glyphs.forEach(Z=>{Z.render(this.context,V+X,this.y_pos+this.point/3-2),X+=Z.getMetrics().width}),this.ratioed){const Z=V+X+.16*this.point,nt=.06*this.point;this.context.beginPath(),this.context.arc(Z,this.y_pos-.08*this.point,nt,0,2*Math.PI,!0),this.context.closePath(),this.context.fill(),this.context.beginPath(),this.context.arc(Z,this.y_pos+.12*this.point,nt,0,2*Math.PI,!0),this.context.closePath(),this.context.fill(),X+=.32*this.point,this.denom_glyphs.forEach(at=>{at.render(this.context,V+X,this.y_pos+this.point/3-2),X+=at.getMetrics().width})}}}function R(vt){let i=0;return vt.forEach(c=>{c.keyProps&&c.keyProps.forEach(M=>{i+=M.line-3})}),i>=0?B.DOWN:B.UP}const F="L",A="B";class G extends h{static getDefaultBeamGroups(i){i&&i!=="c"||(i="4/4");const c={"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"]}[i];if(c!==void 0)return c.map(M=>new l().parse(M));{const M=parseInt(i.split("/")[0],10),I=parseInt(i.split("/")[1],10);if(M%3==0)return[new l(3,I)];if(I>4)return[new l(2,I)];if(I<=4)return[new l(1,I)]}return[new l(1,4)]}static applyAndGetBeams(i,c,M){return G.generateBeams(i.getTickables(),{groups:M,stem_direction:c})}static generateBeams(i,c){c||(c={}),c.groups&&c.groups.length||(c.groups=[new l(2,8)]);const M=c.groups.map(gt=>{if(!gt.multiply)throw new d.RuntimeError("InvalidBeamGroups","The beam groups must be an array of Vex.Flow.Fractions");return gt.clone().multiply(v.RESOLUTION,1)}),I=i;let V=0,X=[],Z=[];function nt(){M.length-1>V?V+=1:V=0}(function(){let gt=[];I.forEach(bt=>{if(gt=[],bt.shouldIgnoreTicks())return X.push(Z),void(Z=gt);Z.push(bt);const Mt=M[V].clone(),_t=Z.reduce((Ft,Zt)=>Zt.getTicks().clone().add(Ft),new l(0,1)),Tt=v.durationToNumber(bt.duration)<8;Tt&&bt.tuplet&&(Mt.numerator*=2),_t.greaterThan(Mt)?(Tt||gt.push(Z.pop()),X.push(Z),Z=gt,nt()):_t.equals(Mt)&&(X.push(Z),Z=gt,nt())}),Z.length>0&&X.push(Z)})(),(function(){const gt=[];X.forEach(bt=>{let Mt=[];bt.forEach((_t,Tt,Ft)=>{const Zt=Tt===0||Tt===Ft.length-1,Yt=Ft[Tt-1],ee=!c.beam_rests&&_t.isRest(),ne=c.beam_rests&&c.beam_middle_only&&_t.isRest()&&Zt;let he=!1;if(c.maintain_stem_directions&&Yt&&!_t.isRest()&&!Yt.isRest()){const Le=Yt.getStemDirection();he=_t.getStemDirection()!==Le}const me=parseInt(_t.duration,10)<8;ee||ne||he||me?(Mt.length>0&>.push(Mt),Mt=he?[_t]:[]):Mt.push(_t)}),Mt.length>0&>.push(Mt)}),X=gt})(),X.forEach(gt=>{let bt;if(c.maintain_stem_directions){const Mt=(function(_t){for(let Tt=0;Tt<_t.length;Tt++){const Ft=_t[Tt];if(!Ft.isRest())return Ft}return!1})(gt);bt=Mt?Mt.getStemDirection():B.UP}else bt=c.stem_direction?c.stem_direction:R(gt);(function(Mt,_t){Mt.forEach(Tt=>{Tt.setStemDirection(_t)})})(gt,bt)});const at=X.filter(gt=>{if(gt.length>1){let bt=!0;return gt.forEach(Mt=>{Mt.getIntrinsicTicks()>=v.durationToTicks("4")&&(bt=!1)}),bt}return!1}),ft=(function(){const gt=[];return X.forEach(bt=>{let Mt=null;bt.forEach(_t=>{_t.tuplet&&Mt!==_t.tuplet&&(Mt=_t.tuplet,gt.push(Mt))})}),gt})(),pt=[];return at.forEach(gt=>{const bt=new G(gt);c.show_stemlets&&(bt.render_options.show_stemlets=!0),c.secondary_breaks&&(bt.render_options.secondary_break_ticks=v.durationToTicks(c.secondary_breaks)),c.flat_beams===!0&&(bt.render_options.flat_beams=!0,bt.render_options.flat_beam_offset=c.flat_beam_offset),pt.push(bt)}),ft.forEach(gt=>{const bt=gt.notes[0].stem_direction===B.DOWN?k.LOCATION_BOTTOM:k.LOCATION_TOP;gt.setTupletLocation(bt);let Mt=!1;for(let _t=0;_t=v.durationToTicks("4"))throw new d.RuntimeError("BadArguments","Beams can only be applied to notes shorter than a quarter note.");let M,I;for(this.stem_direction=B.UP,M=0;MZ+nt.stem_direction,0)>-1?B.UP:B.DOWN),M=0;Mi.getGlyph().beam_count).reduce((i,c)=>c>i?c:i)}breakSecondaryAt(i){return this.break_on_indices=i,this}getSlopeY(i,c,M,I){return M+(i-c)*I}calculateSlope(){const{notes:i,stem_direction:c,render_options:{max_slope:M,min_slope:I,slope_iterations:V,slope_cost:X}}=this,Z=i[0],nt=((bt,Mt)=>{const _t=bt.getStemExtents().topY,Tt=bt.getStemX();return(Mt.getStemExtents().topY-_t)/(Mt.getStemX()-Tt)})(Z,i[i.length-1]),at=(M-I)/V;let ft=Number.MAX_VALUE,pt=0,gt=0;for(let bt=I;bt<=M;bt+=at){let Mt=0,_t=0;for(let Zt=1;Zt_t)&&(at=_t,Z=Math.min(...Mt.getYs()),nt=Mt.getBeamCount())}let ft=X/i.length;const pt=I+nt*(1.5*M),gt=Z+pt*-c;c===B.DOWN&&ftgt&&(ft=Z-pt),V+this.render_options.flat_beam_offset_per_beam>0?(c===B.DOWN&&ft>V&&!this.render_options.flat_beams||c===B.UP&&ft0){let c=this.render_options.flat_beam_offset;this.render_options.flat_beam_offset_per_beam&&(c+=this.render_options.flat_beam_offset_per_beam*this.getBeamCount());let M=this.notes[0].note_heads[0].y;const I=this.stem_direction>0?Math.min:Math.max;for(const V of this.notes)for(const X of V.note_heads)M=I(M,X.y);i=M+c*-this.stem_direction}return i}applyStemExtensions(){const{notes:i,slope:c,y_shift:M,stem_direction:I,beam_count:V,render_options:{show_stemlets:X,stemlet_extension:Z,beam_width:nt}}=this,at=i[0],ft=this.getBeamYToDraw(),pt=at.getStemX();for(let gt=0;gt=8&&(gt=this.break_on_indices.indexOf(ft)!==-1,this.render_options.secondary_break_ticks&&nt>=this.render_options.secondary_break_ticks&&(nt=0,gt=!0));const bt=pt.getIntrinsicTicks(){i.getStem()&&(this.context.openGroup("stem",i.getAttribute("id")+"-stem"),i.getStem().setContext(this.context).draw(),this.context.closeGroup())},this)}drawBeamLines(){this.checkContext();const i=["4","8","16","32","64"],c=this.notes[0];let M=this.getBeamYToDraw();const I=c.getStemX(),V=this.render_options.beam_width*this.stem_direction,X={};for(const Z of this.notes)X[Z.getAttribute("id")]=0;for(let Z=0;Z{i.getStave()||i.setStave(this.stave)}),this.preFormatted=!0),this}draw(i=this.context,c=this.stave){this.setRendered();let M=null;for(let I=0;I0&&M){const X=V.getBoundingBox();X&&M.mergeWith(X)}V.setContext(i),V.drawWithStyle()}this.boundingBox=M}}function C(vt,i,c,M,I){if(i!==z.type.BOLD_DOUBLE_LEFT&&i!==z.type.BOLD_DOUBLE_RIGHT)throw new d.RERR("InvalidConnector","A REPEAT_BEGIN or REPEAT_END type must be provided.");let V=3,X=3.5;i===z.type.BOLD_DOUBLE_RIGHT&&(V=-5,X=3),vt.fillRect(c+V,M,1,I-M),vt.fillRect(c-2,M,X,I-M)}class z extends h{static get type(){return{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}}static get typeString(){return{singleRight:z.type.SINGLE_RIGHT,singleLeft:z.type.SINGLE_LEFT,single:z.type.SINGLE,double:z.type.DOUBLE,brace:z.type.BRACE,bracket:z.type.BRACKET,boldDoubleLeft:z.type.BOLD_DOUBLE_LEFT,boldDoubleRight:z.type.BOLD_DOUBLE_RIGHT,thinDouble:z.type.THIN_DOUBLE,none:z.type.NONE}}constructor(i,c){super(),this.setAttribute("type","StaveConnector"),this.thickness=v.STAVE_LINE_THICKNESS,this.width=3,this.top_stave=i,this.bottom_stave=c,this.type=z.type.DOUBLE,this.font={family:"times",size:16,weight:"normal"},this.x_shift=0,this.texts=[]}setType(i){return(i=typeof i=="string"?z.typeString[i]:i)>=z.type.SINGLE_RIGHT&&i<=z.type.NONE&&(this.type=i),this}setText(i,c){return this.texts.push({content:i,options:d.Merge({shift_x:0,shift_y:0},c)}),this}setFont(i){d.Merge(this.font,i)}setXShift(i){if(typeof i!="number")throw d.RERR("InvalidType","x_shift must be a Number");return this.x_shift=i,this}draw(){const i=this.checkContext();this.setRendered();let c=this.top_stave.getYForLine(0),M=this.bottom_stave.getYForLine(this.bottom_stave.getNumLines()-1)+this.thickness,I=this.width,V=this.top_stave.getX();(this.type===z.type.SINGLE_RIGHT||this.type===z.type.BOLD_DOUBLE_RIGHT||this.type===z.type.THIN_DOUBLE)&&(V=this.top_stave.getX()+this.top_stave.width);let X=M-c;switch(this.type){case z.type.SINGLE:case z.type.SINGLE_LEFT:case z.type.SINGLE_RIGHT:I=1;break;case z.type.DOUBLE:V-=this.width+2;break;case z.type.BRACE:{I=12;const Z=this.top_stave.getX()-2+this.x_shift,nt=c,at=Z,ft=M,pt=Z-I,gt=nt+X/2,bt=pt-.9*I,Mt=nt+.2*X,_t=Z+1.1*I,Tt=gt-.135*X,Ft=_t,Zt=gt+.135*X,Yt=bt,ee=ft-.2*X,ne=pt-I,he=ee,me=Z+.4*I,Le=gt+.135*X,Ee=me,vi=gt-.135*X,ri=ne,je=Mt;i.beginPath(),i.moveTo(Z,nt),i.bezierCurveTo(bt,Mt,_t,Tt,pt,gt),i.bezierCurveTo(Ft,Zt,Yt,ee,at,ft),i.bezierCurveTo(ne,he,me,Le,pt,gt),i.bezierCurveTo(Ee,vi,ri,je,Z,nt),i.fill(),i.stroke();break}case z.type.BRACKET:c-=4,M+=4,X=M-c,S.renderGlyph(i,V-5,c-3,40,"v1b",!0),S.renderGlyph(i,V-5,M+3,40,"v10",!0),V-=this.width+2;break;case z.type.BOLD_DOUBLE_LEFT:C(i,this.type,V+this.x_shift,c,M);break;case z.type.BOLD_DOUBLE_RIGHT:C(i,this.type,V,c,M);break;case z.type.THIN_DOUBLE:I=1;break;case z.type.NONE:break;default:throw new d.RERR("InvalidType",`The provided StaveConnector.type (${this.type}) is invalid`)}this.type!==z.type.BRACE&&this.type!==z.type.BOLD_DOUBLE_LEFT&&this.type!==z.type.BOLD_DOUBLE_RIGHT&&this.type!==z.type.NONE&&i.fillRect(V,c,I,X),this.type===z.type.THIN_DOUBLE&&i.fillRect(V-3,c,I,X),i.save(),i.lineWidth=2,i.setFont(this.font.family,this.font.size,this.font.weight);for(let Z=0;Z0){const Tt=_t.space.deviation,Ft=Tt>=0?"+":"";i.setFillStyle("red"),i.fillText(Ft+Math.round(Tt),Z+c.getXShift(),M-10)}i.restore()}constructor(i){if(super(),this.setAttribute("type","Note"),!i)throw new d.RuntimeError("BadArguments","Note must have valid initialization data to identify duration and type.");const c=v.parseNoteStruct(i);if(!c)throw new d.RuntimeError("BadArguments",`Invalid note initialization object: ${JSON.stringify(i)}`);if(this.duration=c.duration,this.dots=c.dots,this.noteType=c.type,this.customTypes=c.customTypes,i.duration_override?this.setDuration(i.duration_override):this.setIntrinsicTicks(c.ticks),this.modifiers=[],this.glyph=v.getGlyphProps(this.duration,this.noteType),this.customGlyphs=this.customTypes.map(M=>v.getGlyphProps(this.duration,M)),this.positions&&(typeof this.positions!="object"||!this.positions.length))throw new d.RuntimeError("BadArguments","Note keys must be array type.");this.playNote=null,this.tickContext=null,this.modifierContext=null,this.ignore_ticks=!1,this.width=0,this.extraLeftPx=0,this.extraRightPx=0,this.x_shift=0,this.left_modPx=0,this.right_modPx=0,this.voice=null,this.preFormatted=!1,this.ys=[],i.align_center&&this.setCenterAlignment(i.align_center),this.stave=null,this.render_options={annotation_spacing:5,stave_padding:$.STAVEPADDING}}getPlayNote(){return this.playNote}setPlayNote(i){return this.playNote=i,this}isRest(){return!1}addStroke(i,c){return c.setNote(this),c.setIndex(i),this.modifiers.push(c),this.setPreFormatted(!1),this}getStave(){return this.stave}setStave(i){return this.stave=i,this.setYs([i.getYForLine(0)]),this.context=this.stave.context,this}getCategory(){return $.CATEGORY}setContext(i){return this.context=i,this}getExtraLeftPx(){return this.extraLeftPx}getExtraRightPx(){return this.extraRightPx}setExtraLeftPx(i){return this.extraLeftPx=i,this}setExtraRightPx(i){return this.extraRightPx=i,this}shouldIgnoreTicks(){return this.ignore_ticks}getLineNumber(){return 0}getLineForRest(){return 0}getGlyph(){return this.glyph}getGlyphWidth(){return this.glyph.getWidth(this.render_options.glyph_font_scale)}setYs(i){return this.ys=i,this}getYs(){if(this.ys.length===0)throw new d.RERR("NoYValues","No Y-values calculated for this note.");return this.ys}getYForTopText(i){if(!this.stave)throw new d.RERR("NoStave","No stave attached to this note.");return this.stave.getYForTopText(i)}getBoundingBox(){return null}getVoice(){if(!this.voice)throw new d.RERR("NoVoice","Note has no voice.");return this.voice}setVoice(i){return this.voice=i,this.preFormatted=!1,this}getTickContext(){return this.tickContext}setTickContext(i){return this.tickContext=i,this.preFormatted=!1,this}getDuration(){return this.duration}isDotted(){return this.dots>0}hasStem(){return!1}getDots(){return this.dots}getNoteType(){return this.noteType}setBeam(){return this}setModifierContext(i){return this.modifierContext=i,this}addModifier(i,c=0){return i.setNote(this),i.setIndex(c),this.modifiers.push(i),this.setPreFormatted(!1),this}getModifierStartXY(){if(!this.preFormatted)throw new d.RERR("UnformattedNote","Can't call GetModifierStartXY on an unformatted note");return{x:this.getAbsoluteX(),y:this.ys[0]}}getMetrics(){if(!this.preFormatted)throw new d.RERR("UnformattedNote","Can't call getMetrics on an unformatted note.");let i=0,c=0;this.modifierContext!=null&&(i=this.modifierContext.state.left_shift,c=this.modifierContext.state.right_shift);const M=this.getWidth();return{width:M,noteWidth:M-i-c-this.extraLeftPx-this.extraRightPx,left_shift:this.x_shift,modLeftPx:i,modRightPx:c,extraLeftPx:this.extraLeftPx,extraRightPx:this.extraRightPx}}setWidth(i){this.width=i}getWidth(){if(!this.preFormatted)throw new d.RERR("UnformattedNote","Can't call GetWidth on an unformatted note.");return this.width+(this.modifierContext?this.modifierContext.getWidth():0)}setXShift(i){return this.x_shift=i,this}getXShift(){return this.x_shift}getX(){if(!this.tickContext)throw new d.RERR("NoTickContext","Note needs a TickContext assigned for an X-Value");return this.tickContext.getX()+this.x_shift}getAbsoluteX(){if(!this.tickContext)throw new d.RERR("NoTickContext","Note needs a TickContext assigned for an X-Value");let i=this.tickContext.getX();return this.stave&&(i+=this.stave.getNoteStartX()+this.render_options.stave_padding),this.isCenterAligned()&&(i+=this.getCenterXShift()),i}setPreFormatted(i){if(this.preFormatted=i,this.preFormatted){const c=this.tickContext.getExtraPx();this.left_modPx=Math.max(this.left_modPx,c.left),this.right_modPx=Math.max(this.right_modPx,c.right)}}}class N extends ${static get CATEGORY(){return"notehead"}constructor(i){if(super(i),this.setAttribute("type","NoteHead"),this.index=i.index,this.x_shift=i.x_shift||0,this.x=(i.x||0)+this.x_shift,this.y=i.y||0,this.note_type=i.note_type,this.duration=i.duration,this.displaced=i.displaced||!1,this.stem_direction=i.stem_direction||ct.STEM_UP,this.line=i.line,this.glyph=v.getGlyphProps(this.duration,this.note_type),!this.glyph)throw new d.RuntimeError("BadArguments",`No glyph found for duration '${this.duration}' and type '${this.note_type}'`);this.glyph_code=this.glyph.code_head,this.x_shift_ledger_rest=0,this.y_shift_ledger_rest=0,this.x_shift=i.x_shift||0,this.glyph.rest&&(this.line>5||this.line<0)&&(this.isLedgerLinedRest=!0,this.duration==="h"?(i.custom_glyph_code="rhl",this.x_shift_ledger_rest-=4):this.duration==="w"&&(i.custom_glyph_code="rwl",this.x_shift_ledger_rest-=4,this.y_shift_ledger_rest=-5)),i.custom_glyph_code&&(this.custom_glyph=!0,this.glyph_code=i.custom_glyph_code,this.stem_up_x_offset=i.stem_up_x_offset||0,this.stem_down_x_offset=i.stem_down_x_offset||0,this.stem_up_y_shift=i.stem_up_y_shift||0,this.stem_down_y_shift=i.stem_down_y_shift||0),this.style=i.style,this.slashed=i.slashed,d.Merge(this.render_options,{glyph_font_scale:i.glyph_font_scale||v.DEFAULT_NOTATION_FONT_SCALE,stroke_px:3}),this.setWidth(this.glyph.getWidth(this.render_options.glyph_font_scale))}getCategory(){return N.CATEGORY}getWidth(){return this.width}isDisplaced(){return this.displaced===!0}getGlyph(){return this.glyph}setX(i){return this.x=i,this}getY(){return this.y}setY(i){return this.y=i,this}getLine(){return this.line}setLine(i){return this.line=i,this}getAbsoluteX(){const i=this.preFormatted?super.getAbsoluteX():this.x,c=B.WIDTH/2;return i+(this.displaced?(this.width-c)*this.stem_direction:0)}getBoundingBox(){if(!this.preFormatted)throw new d.RERR("UnformattedNote","Can't call getBoundingBox on an unformatted note.");const i=this.stave.getSpacingBetweenLines(),c=i/2,M=this.y-c;return new v.BoundingBox(this.getAbsoluteX(),M,this.width,i)}setStave(i){const c=this.getLine();return this.stave=i,this.setY(i.getYForNote(c)),this.context=this.stave.context,this}preFormat(){if(this.preFormatted)return this;const i=this.getWidth()+this.extraLeftPx+this.extraRightPx;return this.setWidth(i),this.setPreFormatted(!0),this}draw(){this.checkContext(),this.setRendered();const i=this.context;let c=this.getAbsoluteX(),M=this.y;this.custom_glyph&&(c+=this.x_shift_ledger_rest,this.stem_direction===B.UP?(c+=this.stem_up_x_offset,M+=this.stem_up_y_shift||0):this.stem_direction===B.DOWN&&(c+=this.stem_down_x_offset,M+=this.stem_down_y_shift||0),M+=this.y_shift_ledger_rest),(function(...X){N.DEBUG&&d.L("Vex.Flow.NoteHead",X)})("Drawing note head '",this.note_type,this.duration,"' at",c,M);const I=this.stem_direction,V=this.render_options.glyph_font_scale;if(this.style&&this.applyStyle(i),this.note_type==="s"){const X=this.stave.getSpacingBetweenLines();(function(Z,nt,at,ft,pt,gt){const bt=v.SLASH_NOTEHEAD_WIDTH;Z.save(),Z.setLineWidth(v.STEM_WIDTH);let Mt=!1;if(v.durationToNumber(nt)>2&&(Mt=!0),Mt||(at-=v.STEM_WIDTH/2*pt),Z.beginPath(),Z.moveTo(at,ft+gt),Z.lineTo(at,ft+1),Z.lineTo(at+bt,ft-gt),Z.lineTo(at+bt,ft),Z.lineTo(at,ft+gt),Z.closePath(),Mt?Z.fill():Z.stroke(),v.durationToFraction(nt).equals(.5)){const _t=[-3,-1,bt+1,bt+3];for(let Tt=0;Tt<_t.length;Tt++)Z.beginPath(),Z.moveTo(at+_t[Tt],ft-10),Z.lineTo(at+_t[Tt],ft+11),Z.stroke()}Z.restore()})(i,this.duration,c,M,I,X)}else S.renderGlyph(i,c,M,V,this.glyph_code,this.id);this.style&&this.restoreStyle(i)}}class Y extends ${constructor(i){super(i),this.setAttribute("type","StemmableNote"),this.stem=null,this.stemExtensionOverride=null,this.beam=null,this.renderFlag=!0}getStem(){return this.stem}setStem(i){return this.stem=i,this}buildStem(){const i=new B;return this.setStem(i),this}buildFlag(){const{glyph:i,beam:c}=this,M=c===null&&this.renderFlag;if(i&&i.flag&&M){const I=this.getStemDirection()===B.DOWN?i.code_flag_downstem:i.code_flag_upstem;this.flag=new S(I,this.render_options.glyph_font_scale)}}getTopGlyph(){return this.getStemDirection()===B.DOWN?this.customGlyphs[this.customGlyphs.length-1]:this.customGlyphs[0]}getStemLength(){return B.HEIGHT+this.getStemExtension()}getBeamCount(){const i=this.getGlyph();return i?i.beam_count:0}getStemMinumumLength(){let i=v.durationToFraction(this.duration).value()<=1?0:20;switch(this.duration){case"8":this.beam==null&&(i=35);break;case"16":i=this.beam==null?35:25;break;case"32":i=this.beam==null?45:35;break;case"64":i=this.beam==null?50:40;break;case"128":i=this.beam==null?55:45}return i}getStemDirection(){return this.stem_direction}setStemDirection(i){if(i||(i=B.UP),i!==B.UP&&i!==B.DOWN)throw new d.RERR("BadArgument",`Invalid stem direction: ${i}`);if(this.stem_direction=i,this.stem){this.stem.setDirection(i),this.stem.setExtension(this.getStemExtension());const c=this.getTopGlyph()||this.getGlyph();this.stem.setOptions({stem_up_y_offset:c.stem_up_y_offset,stem_down_y_offset:c.stem_down_y_offset})}return this.reset(),this.flag&&this.renderFlag&&this.buildFlag(),this.beam=null,this.preFormatted&&this.preFormat(),this}getStemX(){const i=this.getAbsoluteX()+this.x_shift,c=this.getAbsoluteX()+this.x_shift+this.getGlyphWidth();return this.stem_direction===B.DOWN?i:c}getCenterGlyphX(){return this.getAbsoluteX()+this.x_shift+this.getGlyphWidth()/2}getStemExtension(){const i=this.getGlyph();return this.stemExtensionOverride!=null?this.stemExtensionOverride:i?this.getStemDirection()===1?i.stem_up_extension:i.stem_down_extension:0}setStemLength(i){return this.stemExtensionOverride=i-B.HEIGHT,this}getStemExtents(){return this.stem.getExtents()}setBeam(i){return this.beam=i,this}getYForTopText(i){const c=this.getStemExtents();return this.hasStem()?Math.min(this.stave.getYForTopText(i),c.topY-this.render_options.annotation_spacing*(i+1)):this.stave.getYForTopText(i)}getYForBottomText(i){const c=this.getStemExtents();return this.hasStem()?Math.max(this.stave.getYForTopText(i),c.baseY+this.render_options.annotation_spacing*i):this.stave.getYForBottomText(i)}hasFlag(){return this.renderFlag&&v.getGlyphProps(this.duration).flag&&!this.beam}postFormat(){return this.beam&&this.beam.postFormat(),this.postFormatted=!0,this}drawStem(i){this.checkContext(),this.setRendered(),this.setStem(new B(i)),this.stem.setContext(this.context).draw()}}class tt extends h{static get CATEGORY(){return"none"}static get Position(){return{LEFT:1,RIGHT:2,ABOVE:3,BELOW:4}}static get PositionString(){return{above:tt.Position.ABOVE,below:tt.Position.BELOW,left:tt.Position.LEFT,right:tt.Position.RIGHT}}constructor(){super(),this.setAttribute("type","Modifier"),this.width=0,this.note=null,this.index=null,this.text_line=0,this.position=tt.Position.LEFT,this.modifier_context=null,this.x_shift=0,this.y_shift=0,this.spacingFromNextModifier=0}getCategory(){return tt.CATEGORY}getWidth(){return this.width}setWidth(i){return this.width=i,this}getNote(){return this.note}setNote(i){return this.note=i,this}getIndex(){return this.index}setIndex(i){return this.index=i,this}getModifierContext(){return this.modifier_context}setModifierContext(i){return this.modifier_context=i,this}getPosition(){return this.position}setPosition(i){return this.position=typeof i=="string"?tt.PositionString[i]:i,this}setTextLine(i){return this.text_line=i,this}setYShift(i){return this.y_shift=i,this}setSpacingFromNextModifier(i){this.spacingFromNextModifier=i}getSpacingFromNextModifier(){return this.spacingFromNextModifier}setXShift(i){this.x_shift=0,this.position===tt.Position.LEFT?this.x_shift-=i:this.x_shift+=i}getXShift(){return this.x_shift}draw(){throw this.checkContext(),new d.RERR("MethodNotImplemented","draw() not implemented for this modifier.")}alignSubNotesWithNote(i,c){const M=c.getTickContext(),I=M.getExtraPx(),V=M.getX()-I.left-I.extraLeft+this.getSpacingFromNextModifier();i.forEach(X=>{const Z=X.getTickContext();X.setStave(c.stave),Z.setXOffset(V)})}}class H extends tt{static get CATEGORY(){return"dots"}static format(i,c){const M=c.right_shift;if(!i||i.length===0)return!1;const I=[],V={};for(let gt=0;gtbt.line-gt.line);let X=M,Z=0,nt=null,at=null,ft=null,pt=0;for(let gt=0;gtZ?X:Z,nt=Tt,at=Mt}return c.right_shift+=Z,!0}constructor(){super(),this.setAttribute("type","Dot"),this.note=null,this.index=null,this.position=tt.Position.RIGHT,this.radius=2,this.setWidth(5),this.dot_shiftY=0}getCategory(){return H.CATEGORY}setNote(i){this.note=i,this.note.getCategory()==="gracenotes"&&(this.radius*=.5,this.setWidth(3))}setDotShiftY(i){return this.dot_shiftY=i,this}draw(){if(this.checkContext(),this.setRendered(),!this.note||this.index===null)throw new d.RERR("NoAttachedNote","Can't draw dot without a note and index.");const i=this.note.stave.options.spacing_between_lines_px,c=this.note.getModifierStartXY(this.position,this.index,{forceFlagRight:!0});this.note.getCategory()==="tabnotes"&&(c.y=this.note.getStemExtents().baseY);const M=c.x+this.x_shift+this.width-this.radius,I=c.y+this.y_shift+this.dot_shiftY*i,V=this.context;V.beginPath(),V.arc(M,I,this.radius,0,2*Math.PI,!1),V.fill()}}function rt(vt,i,c){if(vt.note.shiftRestVerticalDisabled)return;const M=(i.isrest?0:1)*c;vt.line+=M,vt.maxLine+=M,vt.minLine+=M,vt.note.setKeyLine(0,vt.note.getKeyLine(0)+M)}class ct extends Y{static get CATEGORY(){return"stavenotes"}static get STEM_UP(){return B.UP}static get STEM_DOWN(){return B.DOWN}static get DEFAULT_LEDGER_LINE_OFFSET(){return 3}static format(i,c){if(!i||i.length<2)return!1;const M=[],I=i[0].stagger_same_whole_notes;for(let gt=0;gt2?M[1]:null;let nt=V>2?M[2]:M[1];V!==2||X.stemDirection!==-1||nt.stemDirection!==1||X.isrest||nt.isRest||(X=M[1],nt=M[0]);const at=Math.max(X.voice_shift,nt.voice_shift);let ft,pt=0;if(V===2){const gt=X.stemDirection===nt.stemDirection?0:.5;if(X.stemDirection===nt.stemDirection&&X.minLine<=nt.maxLine&&(X.isrest||(ft=Math.abs(X.line-(nt.maxLine+.5)),ft=Math.max(ft,X.stemMin),X.minLine=X.line-ft,X.note.setStemLength(10*ft))),X.minLine<=nt.maxLine+gt)if(X.isrest)rt(X,nt,1),X.note.hasLedgerLinedRest&&(X.note.shiftRestVerticalDisabled=!0);else if(nt.isrest)rt(nt,X,-1),nt.note.hasLedgerLinedRest&&(nt.note.shiftRestVerticalDisabled=!0);else{pt=at;const bt=Math.abs(X.line-nt.line);let Mt=0,_t=0;X.note.duration==="h"?Mt++:X.note.duration==="w"&&_t++,nt.note.duration==="h"?Mt++:nt.note.duration==="w"&&_t++;let Tt=Mt===1||_t===1||X.note.dots!==nt.note.dots;if(I&&(Tt||(Tt=_t===2)),bt===0&&Tt){if(nt.note.setXShift(pt),X.note.dots>0){let Ft=0;for(const Zt of X.note.modifiers)if(Zt instanceof H&&(Ft++,Zt.setYShift(-10*(nt.maxLine-X.line+1)),Ft===X.note.dots))break}}else bt<1&&bt>0?nt.note.setXShift(pt):X.note.voice!==nt.note.voice&&X.stemDirection===nt.stemDirection&&(X.line>nt.line?X.stemDirection===1?nt.note.renderFlag=!1:X.note.renderFlag=!1:nt.line>X.line?nt.stemDirection===1?X.note.renderFlag=!1:nt.note.renderFlag=!1:nt.stemDirection===1&&(nt.stemDirection=-1,nt.note.setStemDirection(-1)))}return!0}return Z!==null&&Z.minLinec.postFormat()),!0)}constructor(i){if(super(i),this.setAttribute("type","StaveNote"),this.keys=i.keys,this.clef=i.clef,this.octave_shift=i.octave_shift,this.beam=null,this.glyph=v.getGlyphProps(this.duration,this.noteType),!this.glyph)throw new d.RuntimeError("BadArguments",`Invalid note initialization data (No glyph found): ${JSON.stringify(i)}`);this.displaced=!1,this.dot_shiftY=0,this.addDotsCount=0,this.keyProps=[],this.use_default_head_x=!1,this.paddingRight=0,this.note_heads=[],this.modifiers=[],d.Merge(this.render_options,{glyph_font_scale:i.glyph_font_scale||v.DEFAULT_NOTATION_FONT_SCALE,stroke_px:i.stroke_px||ct.DEFAULT_LEDGER_LINE_OFFSET}),this.calculateKeyProps(),this.buildStem(),i.auto_stem?this.autoStem():this.setStemDirection(i.stem_direction),this.reset(),this.buildFlag()}reset(){super.reset();const i=this.note_heads.map(M=>M.getStyle()),c=[];this.note_heads.forEach(M=>c.push(M.note_type)),this.buildNoteHeads(),this.note_heads.forEach((M,I)=>{M.setStyle(i[I]),c[I]&&(M.note_type=c[I])}),this.stave&&this.note_heads.forEach(M=>M.setStave(this.stave)),this.calcExtraPx()}setBeam(i){return this.beam=i,this.calcExtraPx(),this}getCategory(){return ct.CATEGORY}buildStem(){this.setStem(new B({hide:!!this.isRest()})),this.stem.id=d.Prefix(`${this.getAttribute("id")}-stem`)}buildNoteHeads(){this.note_heads=[];const i=this.getStemDirection(),c=this.getKeys();let M,I,V,X=null,Z=null,nt=!1;i===B.UP?(M=0,I=c.length,V=1):i===B.DOWN&&(M=c.length-1,I=-1,V=-1);for(let at=M;at!==I;at+=V){const ft=this.keyProps[at],pt=ft.line;X===null?X=pt:(Z=Math.abs(X-pt),Z===0||Z===.5?nt=!nt:(nt=!1,this.use_default_head_x=!0)),X=pt;const gt=new N({duration:this.duration,note_type:this.noteType,displaced:nt,stem_direction:i,custom_glyph_code:ft.code,glyph_font_scale:this.render_options.glyph_font_scale,x_shift:ft.shift_right,stem_up_x_offset:ft.stem_up_x_offset,stem_down_x_offset:ft.stem_down_x_offset,stem_up_y_shift:ft.stem_up_y_shift,stem_down_y_shift:ft.stem_down_y_shift,line:ft.line});gt.isLedgerLinedRest&&(this.hasLedgerLinedRest=!0),gt.id=this.stem.id=d.Prefix(`${this.getAttribute("id")}-stem${at}`),this.note_heads[at]=gt}}autoStem(){this.minLine=this.keyProps[0].line,this.maxLine=this.keyProps[this.keyProps.length-1].line;const i=(this.minLine+this.maxLine)/2<3?B.UP:B.DOWN;this.setStemDirection(i)}calculateKeyProps(){let i=null;for(let c=0;c0&&(this.keyProps[c-1].displaced=!0)),i=X,this.keyProps.push(V)}i=-1/0,this.keyProps.forEach(c=>{c.linec.line-M.line)}getBoundingBox(){if(!this.preFormatted)throw new d.RERR("UnformattedNote","Can't call getBoundingBox on an unformatted note.");const{width:i,modLeftPx:c,extraLeftPx:M}=this.getMetrics(),I=this.getAbsoluteX()-c-M-this.paddingRight;let V=0,X=0;const Z=this.getStave().getSpacingBetweenLines()/2,nt=2*Z;if(this.isRest()){const at=this.ys[0],ft=v.durationToFraction(this.duration);ft.equals(1)||ft.equals(2)?(V=at-Z,X=at+Z):(V=at-this.glyph.line_above*nt,X=at+this.glyph.line_below*nt)}else if(this.glyph.stem){const at=this.getStemExtents();at.baseY+=Z*this.stem_direction,V=Math.min(at.topY,at.baseY),X=Math.max(at.topY,at.baseY)}else{V=null,X=null;for(let at=0;atc&&(c=I):I1}hasStem(){return this.glyph.stem}hasFlag(){return super.hasFlag()&&!this.isRest()&&this.renderFlag}getStemX(){return this.noteType==="r"?this.getCenterGlyphX():super.getStemX()+B.WIDTH/(2*-this.getStemDirection())}getYForTopText(i){const c=this.getStemExtents();return Math.min(this.stave.getYForTopText(i),c.topY-this.render_options.annotation_spacing*(i+1))}getYForBottomText(i){const c=this.getStemExtents();return Math.max(this.stave.getYForTopText(i),c.baseY+this.render_options.annotation_spacing*i)}setStave(i){super.setStave(i);const c=this.note_heads.map(M=>(M.setStave(i),M.getY()));if(this.setYs(c),this.stem){const{y_top:M,y_bottom:I}=this.getNoteHeadBounds();this.stem.setYBounds(M,I)}return this}getKeys(){return this.keys}getKeyProps(){return this.keyProps}isDisplaced(){return this.displaced}setNoteDisplaced(i){return this.displaced=i,this}getTieRightX(){let i=this.getAbsoluteX();return i+=this.getGlyphWidth()+this.x_shift+this.extraRightPx,this.modifierContext&&(i+=this.modifierContext.getExtraRightPx()),i}getTieLeftX(){let i=this.getAbsoluteX();return i+=this.x_shift-this.extraLeftPx,i}getLineForRest(){let i=this.keyProps[0].line;if(this.keyProps.length>1){const c=this.keyProps[this.keyProps.length-1].line,M=Math.max(i,c),I=Math.min(i,c);i=d.MidLine(M,I)}return i}getModifierStartXY(i,c,M){if(M=M||{},!this.preFormatted)throw new d.RERR("UnformattedNote","Can't call GetModifierStartXY on an unformatted note");if(this.ys.length===0)throw new d.RERR("NoYValues","No Y-Values calculated for this note.");const{ABOVE:I,BELOW:V,LEFT:X,RIGHT:Z}=tt.Position;let nt=0;return i===X?nt=-2:i===Z?(nt=this.getGlyphWidth()+this.x_shift+2,this.stem_direction===B.UP&&this.hasFlag()&&(M.forceFlagRight||((at,ft)=>ft===(at.getStemDirection()===B.UP?at.keyProps.length-1:0))(this,c))&&(nt+=this.flag.getMetrics().width)):i!==V&&i!==I||(nt=this.getGlyphWidth()/2),{x:this.getAbsoluteX()+nt,y:this.ys[c]}}setStyle(i){super.setStyle(i),this.note_heads.forEach(c=>c.setStyle(i)),this.stem&&this.stem.setStyle(i)}setStemStyle(i){this.stem&&this.getStem().setStyle(i)}getStemStyle(){return this.stem.getStyle()}setLedgerLineStyle(i){this.ledgerLineStyle=i}getLedgerLineStyle(){return this.ledgerLineStyle}setFlagStyle(i){this.flagStyle=i}getFlagStyle(){return this.flagStyle}setKeyStyle(i,c){return this.note_heads[i].setStyle(c),this}setKeyLine(i,c){return this.keyProps[i].line=c,this.reset(),this}getKeyLine(i){return this.keyProps[i].line}addToModifierContext(i){this.setModifierContext(i);for(let c=0;c{const gt=pt.getLine(),bt=pt.getY();(i===null||btc)&&(c=bt),I===null&&pt.isDisplaced()&&(I=pt.getAbsoluteX()),M!==null||pt.isDisplaced()||(M=pt.getAbsoluteX()),V=gt>V?gt:V,X=gt{let he;he=ne&&ee?_t-M:ee?Mt-M:bt-M;const me=ee&&ne?X:V;I.beginPath(),I.moveTo(he,Yt),I.lineTo(he+me,Yt),I.stroke()},Ft={...i.getStyle()||{},...this.getLedgerLineStyle()||{}};this.applyStyle(I,Ft);const Zt=Z>=6||nt<=0;Zt&&I.openGroup("ledgers",this.getAttribute("id")+"ledgers");for(let Yt=6;Yt<=Z;++Yt){const ee=Mt!==null&&Yt<=ft,ne=bt!==null&&Yt<=at;Tt(i.getYForNote(Yt),ee,ne)}for(let Yt=0;Yt>=nt;--Yt){const ee=Mt!==null&&Yt>=gt,ne=bt!==null&&Yt>=pt;Tt(i.getYForNote(Yt),ee,ne)}Zt&&I.closeGroup(),this.restoreStyle(I,Ft)}drawModifiers(){if(!this.context)throw new d.RERR("NoCanvasContext","Can't draw without a canvas context.");const i=this.context;i.openGroup("modifiers");for(let c=0;c{this.context.openGroup("notehead",null,{pointerBBox:!0}),i.setContext(this.context).draw(),this.context.closeGroup()})}drawStem(i){if(!this.context)throw new d.RERR("NoCanvasContext","Can't draw without a canvas context.");i&&this.setStem(new B(i)),this.stem.id=d.Prefix(`${this.getAttribute("id")}-stem`),this.stem&&(this.context.openGroup("stem",null,{pointerBBox:!0}),this.stem.setContext(this.context).draw(),this.context.closeGroup())}draw(){if(!this.context)throw new d.RERR("NoCanvasContext","Can't draw without a canvas context.");if(!this.stave)throw new d.RERR("NoStave","Can't draw without a stave.");if(this.ys.length===0)throw new d.RERR("NoYValues","Can't draw note without Y values.");const i=this.getNoteHeadBeginX(),c=this.hasStem()&&!this.beam;if(this.note_heads.forEach(M=>M.setX(i)),this.stem){const M=this.getStemX();this.stem.setNoteHeadXBounds(M,M)}(function(...M){ct.DEBUG&&d.L("Vex.Flow.StaveNote",M)})("Rendering ",this.isChord()?"chord :":"note :",this.keys),this.drawLedgerLines(),this.applyStyle(),this.setAttribute("el",this.context.openGroup("stavenote",this.getAttribute("id"))),this.context.openGroup("note",null,{pointerBBox:!0}),c&&this.drawStem(),this.drawNoteHeads(),this.drawFlag(),this.context.closeGroup(),this.drawModifiers(),this.context.closeGroup(),this.restoreStyle(),this.setRendered()}}class st extends tt{static get CATEGORY(){return"frethandfinger"}static format(i,c){const{left_shift:M,right_shift:I}=c;if(!i||i.length===0)return!1;const V=[];let X=null,Z=0,nt=0;for(let _t=0;_tTt.line-_t.line);let at=0,ft=0,pt=0,gt=0,bt=null,Mt=null;for(let _t=0;_tpt?Tt:pt):Zt===tt.Position.RIGHT&&(Yt.setXShift(ft),Tt=nt+me,gt=Tt>gt?Tt:gt),bt=ee,Mt=Ft}return c.left_shift+=pt,c.right_shift+=gt,!0}constructor(i){super(),this.setAttribute("type","FretHandFinger"),this.note=null,this.index=null,this.finger=i,this.width=7,this.position=tt.Position.LEFT,this.x_shift=0,this.y_shift=0,this.x_offset=0,this.y_offset=0,this.font={family:"sans-serif",size:9,weight:"bold"}}getCategory(){return st.CATEGORY}setFretHandFinger(i){return this.finger=i,this}setOffsetX(i){return this.x_offset=i,this}setOffsetY(i){return this.y_offset=i,this}draw(){if(this.checkContext(),!this.note||this.index==null)throw new d.RERR("NoAttachedNote","Can't draw string number without a note and index.");this.setRendered();const i=this.context,c=this.note.getModifierStartXY(this.position,this.index);let M=c.x+this.x_shift+this.x_offset,I=c.y+this.y_shift+this.y_offset+5;switch(this.position){case tt.Position.ABOVE:M-=4,I-=12;break;case tt.Position.BELOW:M-=2,I+=10;break;case tt.Position.LEFT:M-=this.width;break;case tt.Position.RIGHT:M+=1;break;default:throw new d.RERR("InvalidPostion",`The position ${this.position} does not exist`)}i.save(),i.setFont(this.font.family,this.font.size,this.font.weight),i.fillText(""+this.finger,M,I),i.restore()}}class ot{static get NUM_TONES(){return 12}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],dorian:[2,1,2,2,2,1,2],mixolydian:[2,2,1,2,2,1,2],minor:[2,1,2,2,1,2,2]}}static get scaleTypes(){return{M:ot.scales.major,m:ot.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(i){return!(i==null||i<0||i>=ot.NUM_TONES)}isValidIntervalValue(i){return this.isValidNoteValue(i)}getNoteParts(i){if(!i||i.length<1)throw new d.RERR("BadArguments","Invalid note name: "+i);if(i.length>3)throw new d.RERR("BadArguments","Invalid note name: "+i);const c=i.toLowerCase(),M=/^([cdefgab])(b|bb|n|#|##)?$/.exec(c);if(M!=null)return{root:M[1],accidental:M[2]};throw new d.RERR("BadArguments","Invalid note name: "+i)}getKeyParts(i){if(!i||i.length<1)throw new d.RERR("BadArguments","Invalid key: "+i);const c=i.toLowerCase(),M=/^([cdefgab])(b|#)?(mel|harm|m|M)?$/.exec(c);if(M!=null){const I=M[1],V=M[2];let X=M[3];return X||(X="M"),{root:I,accidental:V,type:X}}throw new d.RERR("BadArguments",`Invalid key: ${i}`)}getNoteValue(i){const c=ot.noteValues[i];if(c==null)throw new d.RERR("BadArguments",`Invalid note name: ${i}`);return c.int_val}getIntervalValue(i){const c=ot.intervals[i];if(c==null)throw new d.RERR("BadArguments",`Invalid interval name: ${i}`);return c}getCanonicalNoteName(i){if(!this.isValidNoteValue(i))throw new d.RERR("BadArguments",`Invalid note value: ${i}`);return ot.canonical_notes[i]}getCanonicalIntervalName(i){if(!this.isValidIntervalValue(i))throw new d.RERR("BadArguments",`Invalid interval value: ${i}`);return ot.diatonic_intervals[i]}getRelativeNoteValue(i,c,M){if(M==null&&(M=1),M!==1&&M!==-1)throw new d.RERR("BadArguments",`Invalid direction: ${M}`);let I=(i+M*c)%ot.NUM_TONES;return I<0&&(I+=ot.NUM_TONES),I}getRelativeNoteName(i,c){const M=this.getNoteParts(i),I=this.getNoteValue(M.root);let V=c-I;if(Math.abs(V)>ot.NUM_TONES-3){let Z=1;V>0&&(Z=-1);const nt=(c+1+(I+1))%ot.NUM_TONES*Z;if(Math.abs(nt)>2)throw new d.RERR("BadArguments",`Notes not related: ${i}, ${c})`);V=nt}if(Math.abs(V)>2)throw new d.RERR("BadArguments",`Notes not related: ${i}, ${c})`);let X=M.root;if(V>0)for(let Z=1;Z<=V;++Z)X+="#";else if(V<0)for(let Z=-1;Z>=V;--Z)X+="b";return X}getScaleTones(i,c){const M=[i];let I=i;for(let V=0;Vvt.getMetrics().width;class O extends tt{static get CATEGORY(){return"accidentals"}static format(i,c){const M=c.left_shift+1;if(!i||i.length===0)return;const I=[];let V,X=null,Z=0;for(let Tt=0;TtFt.line-Tt.line);const nt=[];let at=0,ft=null;for(let Tt=0;Ttat?Ft.shift:at,ft=Ft.line}let pt=0;for(let Tt=0;Ttnt[Zt+je],ne=je=>je.map(ee),he=(je,ki)=>{const[Vi,Yn]=ne([je,ki]).map(pn=>pn.line);return Vi-Yn},me=(...je)=>je.map(ne).every(ki=>!this.checkCollision(...ki)),Le=Yt-Zt+1;let Ee,vi,ri=this.checkCollision(nt[Zt],nt[Yt])?"a":"b";switch(Le){case 3:ri==="a"&&he(1,2)===.5&&he(0,1)!==.5&&(ri="second_on_bottom");break;case 4:me([0,2],[1,3])&&(ri="spaced_out_tetrachord");break;case 5:ri==="b"&&me([1,3])&&(ri="spaced_out_pentachord",me([0,2],[2,4])&&(ri="very_spaced_out_pentachord"));break;case 6:me([0,3],[1,4],[2,5])&&(ri="spaced_out_hexachord"),me([0,2],[2,4],[1,3],[3,5])&&(ri="very_spaced_out_hexachord")}if(Le>=7){let je=2,ki=!0;for(;ki===!0;){ki=!1;for(let Vi=0;Vi+jevi?pt:vi}else for(Ee=Tt;Ee<=Yt;Ee++)vi=v.accidentalColumnsTable[Le][ri][Ee-Tt],nt[Ee].column=vi,pt=pt>vi?pt:vi;Tt=Yt}const gt=[],bt=[];for(let Tt=0;Tt<=pt;Tt++)gt[Tt]=0,bt[Tt]=0;gt[0]=at+M,bt[0]=at+M,nt.forEach(Tt=>{Tt.width>gt[Tt.column]&&(gt[Tt.column]=Tt.width)});for(let Tt=1;Tt{let Ft=0;const Zt=_t+Tt.numAcc;for(;_t0?(I=c.flatLine||c.dblSharpLine?2.5:3,i.dblSharpLine&&(M-=.5)):(I=i.flatLine||i.dblSharpLine?2.5:3,c.dblSharpLine&&(M-=.5));const V=Math.abs(M){const nt=new l(0,1);Z.getTickables().forEach(at=>{if(at.shouldIgnoreTicks())return;const ft=I[nt.value()];ft?ft.push(at):(M.push(nt.value()),I[nt.value()]=[at]),nt.add(at.getTicks())})});const V=new ot;c||(c="C");const X=V.createScaleMap(c);M.forEach(Z=>{const nt=I[Z],at=[],ft=pt=>{pt.isRest()||pt.shouldIgnoreTicks()||(pt.keys.forEach((gt,bt)=>{const Mt=V.getNoteParts(gt.split("/")[0]),_t=Mt.accidental||"n",Tt=Mt.root+_t,Ft=X[Mt.root]===Tt,Zt=at.indexOf(Tt)>-1;if(!Ft||Ft&&Zt){X[Mt.root]=Tt;const Yt=new O(_t);pt.addAccidental(bt,Yt),at.push(Tt)}}),pt.getModifiers().forEach(gt=>{gt.getCategory()==="gracenotegroups"&>.getGraceNotes().forEach(ft)}))};nt.forEach(ft)})}constructor(i=null){if(super(),this.setAttribute("type","Accidental"),ht("New accidental: ",i),this.note=null,this.index=null,this.type=i,this.position=tt.Position.LEFT,this.render_options={font_scale:38,stroke_px:3,parenLeftPadding:2,parenRightPadding:2},this.accidental=v.accidentalCodes(this.type),!this.accidental)throw new d.RERR("ArgumentError",`Unknown accidental type: ${i}`);this.cautionary=!1,this.parenLeft=null,this.parenRight=null,this.reset()}reset(){const i=this.render_options.font_scale;this.glyph=new S(this.accidental.code,i),this.glyph.setOriginX(1),this.cautionary&&(this.parenLeft=new S(v.accidentalCodes("{").code,i),this.parenRight=new S(v.accidentalCodes("}").code,i),this.parenLeft.setOriginX(1),this.parenRight.setOriginX(1))}getCategory(){return O.CATEGORY}getWidth(){const i=this.cautionary?lt(this.parenLeft)+lt(this.parenRight)+this.render_options.parenLeftPadding+this.render_options.parenRightPadding:0;return lt(this.glyph)+i}setNote(i){if(!i)throw new d.RERR("ArgumentError",`Bad note value: ${i}`);this.note=i,this.note.getCategory()==="gracenotes"&&(this.render_options.font_scale=25,this.reset())}setAsCautionary(){return this.cautionary=!0,this.render_options.font_scale=28,this.reset(),this}draw(){const{context:i,type:c,position:M,note:I,index:V,cautionary:X,x_shift:Z,y_shift:nt,glyph:at,parenLeft:ft,parenRight:pt,render_options:{parenLeftPadding:gt,parenRightPadding:bt}}=this;if(this.checkContext(),!I||V==null)throw new d.RERR("NoAttachedNote","Can't draw accidental without a note and index.");const Mt=I.getModifierStartXY(M,V);let _t=Mt.x+Z;const Tt=Mt.y+nt;ht("Rendering: ",c,_t,Tt),X?(pt.render(i,_t,Tt),_t-=lt(pt),_t-=bt,_t-=this.accidental.parenRightPaddingAdjustment,at.render(i,_t,Tt),_t-=lt(at),_t-=gt,ft.render(i,_t,Tt)):at.render(i,_t,Tt),this.setRendered()}}class D extends tt{static get CATEGORY(){return"notesubgroup"}static format(i,c){if(!i||i.length===0)return!1;let M=0;for(let I=0;I{c.ignore_ticks=!1}),this.width=0,this.preFormatted=!1,this.formatter=new $t,this.voice=new U({num_beats:4,beat_value:4,resolution:v.RESOLUTION}).setStrict(!1),this.voice.addTickables(this.subNotes),this}getCategory(){return D.CATEGORY}preFormat(){this.preFormatted||(this.formatter.joinVoices([this.voice]).format([this.voice],0),this.setWidth(this.formatter.getMinTotalWidth()),this.preFormatted=!0)}setNote(i){this.note=i}setWidth(i){this.width=i}getWidth(){return this.width}draw(){this.checkContext();const i=this.getNote();if(!i||this.index===null)throw new d.RuntimeError("NoAttachedNote","Can't draw notes without a parent note and parent note index.");this.setRendered(),this.alignSubNotesWithNote(this.subNotes,i),this.subNotes.forEach(c=>c.setContext(this.context).drawWithStyle())}}class j extends h{constructor(i,c){super(),this.setAttribute("type","StaveTie"),this.notes=i,this.context=null,this.text=c,this.direction=null,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,font:{family:"Arial",size:10,style:""}},this.font=this.render_options.font,this.setNotes(i)}setFont(i){return this.font=i,this}setDirection(i){return this.direction=i,this}setNotes(i){if(!i.first_note&&!i.last_note)throw new d.RuntimeError("BadArguments","Tie needs to have either first_note or last_note set.");if(i.first_indices||(i.first_indices=[0]),i.last_indices||(i.last_indices=[0]),i.first_indices.length!==i.last_indices.length)throw new d.RuntimeError("BadArguments","Tied notes must have similar index sizes");return this.first_note=i.first_note,this.first_indices=i.first_indices,this.last_note=i.last_note,this.last_indices=i.last_indices,this}isPartial(){return!this.first_note||!this.last_note}renderTie(i){var nt;if(i.first_ys.length===0||i.last_ys.length===0)throw new d.RERR("BadArguments","No Y-values to render");const c=this.context;let M=this.render_options.cp1,I=this.render_options.cp2;Math.abs(i.last_x_px-i.first_x_px)<10&&(M=2,I=8);const V=this.render_options.first_x_shift,X=this.render_options.last_x_shift,Z=this.render_options.y_shift*i.direction;for(let at=0;at1){const c=new G(i);c.render_options.beam_width=3,c.render_options.partial_beam_length=4,this.beams.push(c)}return this}setNote(i){this.note=i}setWidth(i){this.width=i}getWidth(){return this.width}getGraceNotes(){return this.grace_notes}draw(){this.checkContext();const i=this.getNote();if((function(...c){J.DEBUG&&d.L("Vex.Flow.GraceNoteGroup",c)})("Drawing grace note group for:",i),!i||this.index===null)throw new d.RuntimeError("NoAttachedNote","Can't draw grace note without a parent note and parent note index.");if(this.setRendered(),this.alignSubNotesWithNote(this.getGraceNotes(),i),this.grace_notes.forEach(c=>{c.setContext(this.context).draw()}),this.beams.forEach(c=>{c.setContext(this.context).draw()}),this.show_slur){const c=this.getNote().getCategory()===ct.CATEGORY,M=c?j:Q;this.slur=new M({last_note:this.grace_notes[0],first_note:i,first_indices:[0],last_indices:[0]}),this.slur.render_options.cp2=12,this.slur.render_options.y_shift=(c?7:5)+this.render_options.slur_y_shift,this.slur.setContext(this.context).draw()}}}class q extends tt{static get CATEGORY(){return"strokes"}static get Type(){return{BRUSH_DOWN:1,BRUSH_UP:2,ROLL_DOWN:3,ROLL_UP:4,RASQUEDO_DOWN:5,RASQUEDO_UP:6,ARPEGGIO_DIRECTIONLESS:7}}static format(i,c){const M=c.left_shift;if(!i||i.length===0)return this;const I=i.map(Z=>{const nt=Z.getNote();if(nt instanceof ct){const{line:at,displaced:ft}=nt.getKeyProps()[Z.getIndex()];return{line:at,shift:ft?nt.getExtraLeftPx():0,stroke:Z}}{const{str:at}=nt.getPositions()[Z.getIndex()];return{line:at,shift:0,stroke:Z}}}),V=M,X=I.reduce((Z,{stroke:nt,shift:at})=>(nt.setXShift(V+at),Math.max(nt.getWidth()+0,Z)),0);return c.left_shift+=X,!0}constructor(i,c){super(),this.setAttribute("type","Stroke"),this.note=null,this.options=d.Merge({},c),this.all_voices=!("all_voices"in this.options)||this.options.all_voices,this.note_end=null,this.index=null,this.type=i,this.position=tt.Position.LEFT,this.render_options={font_scale:38,stroke_px:3,stroke_spacing:10},this.font={family:"serif",size:10,weight:"bold italic"},this.setXShift(0),this.setWidth(10)}getCategory(){return q.CATEGORY}getPosition(){return this.position}addEndNote(i){return this.note_end=i,this}draw(){if(this.checkContext(),this.setRendered(),!this.note||this.index==null)throw new d.RERR("NoAttachedNote","Can't draw stroke without a note and index.");const i=this.note.getModifierStartXY(this.position,this.index);let c=this.note.getYs(),M=i.y,I=i.y;const V=i.x-5,X=this.note.stave.options.spacing_between_lines_px,Z=this.getModifierContext().getModifiers(this.note.getCategory());for(let bt=0;btee.line-Yt.line);let Mt=0,_t=0,Tt=0,Ft=null,Zt=null;for(X=0;X_t?Yt:_t):at===tt.Position.RIGHT&&(Z.setXShift(Mt),Yt+=he,Tt=Yt>Tt?Yt:Tt),Ft=ee,Zt=nt}return c.left_shift+=_t,c.right_shift+=Tt,!0}constructor(i){super(),this.setAttribute("type","StringNumber"),this.note=null,this.last_note=null,this.index=null,this.string_number=i,this.setWidth(20),this.position=tt.Position.ABOVE,this.x_shift=0,this.y_shift=0,this.x_offset=0,this.y_offset=0,this.dashed=!0,this.leg=_.LineEndType.NONE,this.radius=8,this.font={family:"sans-serif",size:10,weight:"bold"}}getCategory(){return et.CATEGORY}getNote(){return this.note}setNote(i){return this.note=i,this}getIndex(){return this.index}setIndex(i){return this.index=i,this}setLineEndType(i){return i>=_.LineEndType.NONE&&i<=_.LineEndType.DOWN&&(this.leg=i),this}setStringNumber(i){return this.string_number=i,this}setOffsetX(i){return this.x_offset=i,this}setOffsetY(i){return this.y_offset=i,this}setLastNote(i){return this.last_note=i,this}setDashed(i){return this.dashed=i,this}draw(){const i=this.checkContext();if(!this.note||this.index==null)throw new d.RERR("NoAttachedNote","Can't draw string number without a note and index.");this.setRendered();const c=this.note.stave.options.spacing_between_lines_px,M=this.note.getModifierStartXY(this.position,this.index);let I=M.x+this.x_shift+this.x_offset,V=M.y+this.y_shift+this.y_offset;switch(this.position){case tt.Position.ABOVE:case tt.Position.BELOW:{const Z=this.note.getStemExtents();let nt=Z.topY,at=Z.baseY+2;this.note.stem_direction===ct.STEM_DOWN&&(nt=Z.baseY,at=Z.topY-2),V=this.position===tt.Position.ABOVE?this.note.hasStem()?nt-1.75*c:M.y-1.75*c:this.note.hasStem()?at+1.5*c:M.y+1.75*c,V+=this.y_shift+this.y_offset;break}case tt.Position.LEFT:I-=this.radius/2+5;break;case tt.Position.RIGHT:I+=this.radius/2+6;break;default:throw new d.RERR("InvalidPosition",`The position ${this.position} is invalid`)}i.save(),i.beginPath(),i.arc(I,V,this.radius,0,2*Math.PI,!1),i.lineWidth=1.5,i.stroke(),i.setFont(this.font.family,this.font.size,this.font.weight);const X=I-i.measureText(this.string_number).width/2;if(i.fillText(""+this.string_number,X,V+4.5),this.last_note!=null){const Z=this.last_note.getStemX()-this.note.getX()+5;let nt,at;switch(i.strokeStyle="#000000",i.lineCap="round",i.lineWidth=.6,this.dashed?_.drawDashedLine(i,I+10,V,I+Z,V,[3,3]):_.drawDashedLine(i,I+10,V,I+Z,V,[3,0]),this.leg){case _.LineEndType.UP:nt=-10,at=this.dashed?[3,3]:[3,0],_.drawDashedLine(i,I+Z,V,I+Z,V+nt,at);break;case _.LineEndType.DOWN:nt=10,at=this.dashed?[3,3]:[3,0],_.drawDashedLine(i,I+Z,V,I+Z,V+nt,at)}}i.restore()}}class it extends W{static getNextContext(i){const c=i.tContexts,M=c.indexOf(i);return c[M+1]}constructor(){super(),this.setAttribute("type","TickContext"),this.currentTick=new l(0,1),this.maxTicks=new l(0,1),this.minTicks=null,this.padding=3,this.x=0,this.xBase=0,this.xOffset=0,this.tickables=[],this.notePx=0,this.extraLeftPx=0,this.extraRightPx=0,this.tContexts=[]}getX(){return this.x}setX(i){return this.x=i,this.xBase=i,this.xOffset=0,this}getXBase(){return this.xBase}setXBase(i){this.xBase=i,this.x=i+this.xOffset}getXOffset(){return this.xOffset}setXOffset(i){this.xOffset=i,this.x=this.xBase+i}getWidth(){return this.width+2*this.padding}setPadding(i){return this.padding=i,this}getMaxTicks(){return this.maxTicks}getMinTicks(){return this.minTicks}getTickables(){return this.tickables}getCenterAlignedTickables(){return this.tickables.filter(i=>i.isCenterAligned())}getMetrics(){const{width:i,notePx:c,extraLeftPx:M,extraRightPx:I}=this;return{width:i,notePx:c,extraLeftPx:M,extraRightPx:I}}getCurrentTick(){return this.currentTick}setCurrentTick(i){this.currentTick=i,this.preFormatted=!1}getExtraPx(){let i=0,c=0,M=0,I=0;for(let V=0;V.5*vt(i/.5),Et=(vt,i)=>i===dt?vt<=5:vt>=1,Dt=(vt,i)=>Et(vt,i)?i===dt?Math.ceil:Math.floor:Math.round,Vt=vt=>{const i=vt.getCategory();return i==="stavenotes"||i==="gracenotes"};class Nt extends tt{static get CATEGORY(){return"articulations"}static get INITIAL_OFFSET(){return-.5}static format(i,c){if(!i||i.length===0)return!1;const M=(V,X,Z)=>yt(Dt(X,Z),V.glyph.getMetrics().height/10+.5);i.filter(V=>V.getPosition()===dt).forEach(V=>{V.setTextLine(c.top_text_line),c.top_text_line+=M(V,c.top_text_line,dt)}),i.filter(V=>V.getPosition()===mt).forEach(V=>{V.setTextLine(c.text_line),c.text_line+=M(V,c.text_line,mt)});const I=i.map(V=>V.getWidth()).reduce((V,X)=>Math.max(X,V));return c.left_shift+=I/2,c.right_shift+=I/2,!0}static easyScoreHook({articulations:i},c,M){if(!i)return;const I={staccato:"a.",tenuto:"a-"};i.split(",").map(V=>V.trim().split(".")).map(([V,X])=>{const Z={type:I[V]};return X&&(Z.position=tt.PositionString[X]),M.getFactory().Articulation(Z)}).map(V=>c.addModifier(0,V))}constructor(i){if(super(),this.setAttribute("type","Articulation"),this.note=null,this.index=null,this.type=i,this.position=mt,this.render_options={font_scale:38},this.breathMarkDistance=.8,this.articulation=v.articulationCodes(this.type),this.type==="abr"&&(this.articulation={code:"v6c",between_lines:!1}),!this.articulation)throw new d.RERR("ArgumentError",`Articulation not found: ${this.type}`);this.glyph=new S(this.articulation.code,this.render_options.font_scale),this.setWidth(this.glyph.getMetrics().width)}getCategory(){return Nt.CATEGORY}draw(){const{note:i,index:c,position:M,glyph:I,articulation:{between_lines:V},text_line:X,context:Z}=this;if(this.checkContext(),!i||c==null)throw new d.RERR("NoAttachedNote","Can't draw Articulation without a note and index.");this.setRendered();const nt=i.getStave(),at=nt.getSpacingBetweenLines(),ft=i.getCategory()==="tabnotes";let{x:pt}=i.getModifierStartXY(M,c);if(this.type==="abr"){let Tt=0;const Ft=i.getTickContext(),Zt=it.getNextContext(Ft),Yt=Ft.getX();if(Zt&&Zt.x>Ft.x)Tt=(Zt.getX()-Yt)*this.breathMarkDistance;else{const ee=i.getStave();Tt=(ee.getX()+ee.getWidth()-Yt+ee.start_x)*this.breathMarkDistance}if(pt+=Tt,pt>nt.end_x){const ee=nt.start_x+Yt;pt=ee+(nt.end_x-ee)*this.breathMarkDistance}}const gt=this.getXShift();gt&&(pt+=gt);const bt=!V||ft,Mt=((Tt,Ft)=>{const Zt=Ft===dt&&Tt.getStemDirection()===B.UP||Ft===mt&&Tt.getStemDirection()===B.DOWN;return Vt(Tt)?Tt.hasStem()&&Zt?.5:1:Tt.hasStem()&&Zt?1:0})(i,M);let _t={[dt]:()=>{I.setOrigin(.5,1);const Tt=((Ft,Zt)=>{const Yt=Ft.getStave(),ee=Ft.getStemDirection(),{topY:ne,baseY:he}=Ft.getStemExtents();if(Vt(Ft))return Ft.hasStem()?ee===B.UP?ne:he:Math.min(...Ft.getYs());if(Ft.getCategory()==="tabnotes")return Ft.hasStem()&&ee===B.UP?ne:Yt.getYForTopText(Zt);throw new d.RERR("UnknownCategory","Only can get the top and bottom ys of stavenotes and tabnotes")})(i,X)-(X+Mt)*at;return bt?Math.min(nt.getYForTopText(Nt.INITIAL_OFFSET),Tt):Tt},[mt]:()=>{I.setOrigin(.5,0);const Tt=((Ft,Zt)=>{const Yt=Ft.getStave(),ee=Ft.getStemDirection(),{topY:ne,baseY:he}=Ft.getStemExtents();if(Vt(Ft))return Ft.hasStem()?ee===B.UP?he:ne:Math.max(...Ft.getYs());if(Ft.getCategory()==="tabnotes")return Ft.hasStem()?ee===B.UP?Yt.getYForBottomText(Zt):ne:Yt.getYForBottomText(Zt);throw new d.RERR("UnknownCategory","Only can get the top and bottom ys of stavenotes and tabnotes")})(i,X)+(X+Mt)*at;return bt?Math.max(nt.getYForBottomText(Nt.INITIAL_OFFSET),Tt):Tt}}[M]();if(this.y_shift&&(_t+=this.y_shift),!ft){const Tt=M===dt?-1:1,Ft=ft?i.positions[c].str:i.getKeyProps()[c].line,Zt=(i.getYs()[c]-_t)/at+Ft,Yt=((ee,ne,he,me)=>{const Le=yt(Dt(ne,he),ne);return ee&&Et(Le,he)&&Le%1==0?Le+.5*-me:Le})(V,Zt,M,Tt);Et(Yt,M)&&I.setOrigin(.5,.5),_t+=Math.abs(Yt-Zt)*at*Tt}(function(...Tt){Nt.DEBUG&&d.L("Vex.Flow.Articulation",Tt)})(`Rendering articulation at (x: ${pt}, y: ${_t})`),I.render(Z,pt,_t)}}class It extends tt{static get CATEGORY(){return"ornaments"}static format(i,c){if(!i||i.length===0)return!1;let M=0;for(let I=0;I0&&I--;for(let nt=0;nt{Ut("Preformatting ModifierContext: ",i.CATEGORY),i.format(this.getModifiers(i.CATEGORY),this.state,this)}),this.width=this.state.left_shift+this.state.right_shift,this.preFormatted=!0)}postFormat(){this.postFormatted||this.POSTFORMAT.forEach(i=>{Ut("Postformatting ModifierContext: ",i.CATEGORY),i.postFormat(this.getModifiers(i.CATEGORY),this)})}}function qt(vt,i,c,M){let I=i;for(c+=1;c{if(nt.getMode()===U.Mode.STRICT&&!nt.isComplete())throw new d.RERR("IncompleteVoice","Voice does not have enough notes.");return Math.max(Z,l.LCM(Z,nt.getResolutionMultiplier()))},1),I={},V=[],X=[];return vt.forEach(Z=>{const nt=new l(0,M);Z.getTickables().forEach(at=>{const ft=nt.numerator;if(!I[ft]){const pt=new i;X.push(pt),I[ft]=pt}c(at,I[ft]),V.push(ft),nt.add(at.getTicks())})}),{map:I,array:X,list:d.SortAndUnique(V,(Z,nt)=>Z-nt,(Z,nt)=>Z===nt),resolutionMultiplier:M}}class $t{static SimpleFormat(i,c=0,{paddingBetween:M=10}={}){i.reduce((I,V)=>{V.addToModifierContext(new Kt);const X=new it().addTickable(V).preFormat(),Z=X.getExtraPx();return X.setX(I+Z.left),I+X.getWidth()+Z.right+M},c)}static plotDebugging(i,c,M,I,V){const X=M+$.STAVEPADDING,Z=c.contextGaps;i.save(),i.setFont("Arial",8,""),Z.gaps.forEach(nt=>{var at,ft,pt;at=X+nt.x1,ft=X+nt.x2,pt="#aaa",i.beginPath(),i.setStrokeStyle(pt),i.setFillStyle(pt),i.setLineWidth(1),i.fillRect(at,I,ft-at,V-I),i.fillText(Math.round(nt.x2-nt.x1),X+nt.x1,V+12)}),i.fillText(Math.round(Z.total)+"px",X-20,V+12),i.setFillStyle("red"),i.fillText("Loss: "+c.lossHistory.map(nt=>Math.round(nt)),X-20,V+22),i.restore()}static FormatAndDraw(i,c,M,I){const V={auto_beam:!1,align_rests:!1};typeof I=="object"?d.Merge(V,I):typeof I=="boolean"&&(V.auto_beam=I);const X=new U(v.TIME4_4).setMode(U.Mode.SOFT).addTickables(M),Z=V.auto_beam?G.applyAndGetBeams(X):[];return new $t().joinVoices([X],{align_rests:V.align_rests}).formatToStave([X],c,{align_rests:V.align_rests,stave:c}),X.setStave(c).draw(i,c),Z.forEach(nt=>nt.setContext(i).draw()),X.getBoundingBox()}static FormatAndDrawTab(i,c,M,I,V,X,Z){const nt={auto_beam:X,align_rests:!1};typeof Z=="object"?d.Merge(nt,Z):typeof Z=="boolean"&&(nt.auto_beam=Z);const at=new U(v.TIME4_4).setMode(U.Mode.SOFT).addTickables(V),ft=new U(v.TIME4_4).setMode(U.Mode.SOFT).addTickables(I),pt=nt.auto_beam?G.applyAndGetBeams(at):[];new $t().joinVoices([at],{align_rests:nt.align_rests}).joinVoices([ft]).formatToStave([at,ft],M,{align_rests:nt.align_rests}),at.draw(i,M),ft.draw(i,c),pt.forEach(gt=>gt.setContext(i).draw()),new z(M,c).setContext(i).draw()}static AlignRestsToNotes(i,c,M){return i.forEach((I,V)=>{if(I instanceof ct&&I.isRest()){if(I.tuplet&&!M)return;const X=I.getGlyph().position.toUpperCase();if(X!=="R/4"&&X!=="B/4")return;if(c||I.beam!=null){const Z=I.getKeyProps()[0];if(V===0)Z.line=qt(i,Z.line,V,!1),I.setKeyLine(0,Z.line);else if(V>0&&V$t.AlignRestsToNotes(M.getTickables(),c))}preCalculateMinTotalWidth(i){if(this.hasMinTotalWidth)return this.minTotalWidth;if(!this.tickContexts){if(!i)throw new d.RERR("BadArgument","'voices' required to run preCalculateMinTotalWidth");this.createTickContexts(i)}const{list:c,map:M}=this.tickContexts;return this.minTotalWidth=c.map(I=>{const V=M[I];return V.preFormat(),V.getWidth()}).reduce((I,V)=>I+V,0),this.hasMinTotalWidth=!0,this.minTotalWidth}getMinTotalWidth(){if(!this.hasMinTotalWidth)throw new d.RERR("NoMinTotalWidth","Call 'preCalculateMinTotalWidth' or 'preFormat' before calling 'getMinTotalWidth'");return this.minTotalWidth}createModifierContexts(i){const c=Qt(i,Kt,(M,I)=>M.addToModifierContext(I));return this.modiferContexts=c,c}createTickContexts(i){const c=Qt(i,it,(M,I)=>I.addTickable(M));return c.array.forEach(M=>{M.tContexts=c.array}),this.totalTicks=i[0].getTicksUsed().clone(),this.tickContexts=c,c}preFormat(i=0,c,M,I){const V=this.tickContexts,{list:X,map:Z,resolutionMultiplier:nt}=V;M&&I&&M.forEach(Tt=>Tt.setStave(I).preFormat());let at=0,ft=0;const pt=i/2;if(this.minTotalWidth=0,X.forEach(Tt=>{const Ft=Z[Tt];c&&Ft.setContext(c),Ft.preFormat();const Zt=Ft.getWidth();this.minTotalWidth+=Zt;const Yt=Ft.getMetrics();at=at+ft+Yt.extraLeftPx,Ft.setX(at),ft=Zt-Yt.extraLeftPx}),this.minTotalWidth=at+ft,this.hasMinTotalWidth=!0,i<=0)return;const gt=i-this.minTotalWidth;let bt=this.totalTicks.value();bt===0&&(bt=1);const Mt=gt/(bt*nt);let _t=0;X.forEach((Tt,Ft)=>{const Zt=X[Ft-1]||0,Yt=Z[Tt];_t+=(Tt-Zt)*Mt,Yt.setX(Yt.getX()+_t),Yt.getCenterAlignedTickables().forEach(ee=>{ee.center_x_shift=pt-Yt.getX()})}),X.length!==1&&(this.justifyWidth=i,this.lossHistory=[],this.evaluate())}evaluate(){const i=this.justifyWidth;this.contextGaps={total:0,gaps:[]},this.tickContexts.list.forEach((I,V)=>{if(V===0)return;const X=this.tickContexts.list[V-1],Z=this.tickContexts.map[X],nt=this.tickContexts.map[I],at=Z.getMetrics(),ft=Z.getX()+at.width,pt=nt.getX(),gt=pt-ft;this.contextGaps.total+=gt,this.contextGaps.gaps.push({x1:ft,x2:pt}),nt.getFormatterMetrics().freedom.left=gt,Z.getFormatterMetrics().freedom.right=gt});const c=this.durationStats={};this.voices.forEach(I=>{I.getTickables().forEach((V,X,Z)=>{const nt=V.getTicks().clone().simplify().toString(),at=V.getMetrics(),ft=V.getFormatterMetrics(),pt=V.getX()+at.noteWidth+at.modRightPx+at.extraRightPx;let gt=0;if(X{I.getTickables().forEach(V=>{const X=V.getTicks().clone().simplify().toString(),Z=V.getFormatterMetrics();Z.iterations+=1,Z.space.deviation=Z.space.used-c[X].mean,Z.duration=X,Z.space.mean=c[X].mean,M+=Math.pow(c[X].mean,2)})}),this.totalCost=Math.sqrt(M),this.lossHistory.push(this.totalCost),this}tune(){let i=0;return this.tickContexts.list.forEach((c,M,I)=>{const V=this.tickContexts.map[c],X=M>0?this.tickContexts.map[I[M-1]]:null,Z=Mft.getFormatterMetrics().space.deviation).reduce((ft,pt)=>ft+pt);nt>0?i=-Math.min(V.getFormatterMetrics().freedom.right,Math.abs(nt)):nt<0&&(i=Z?Math.min(Z.getFormatterMetrics().freedom.right,Math.abs(nt)):0);const at=Math.min(5,Math.abs(i));i=i>0?at:-at}),this.evaluate()}postFormat(){const i=c=>c.list.forEach(M=>c.map[M].postFormat());return i(this.modiferContexts),i(this.tickContexts),this}joinVoices(i){return this.createModifierContexts(i),this.hasMinTotalWidth=!1,this}format(i,c,M){const I={align_rests:!1,context:null,stave:null};return d.Merge(I,M),this.voices=i,this.alignRests(i,I.align_rests),this.createTickContexts(i),this.preFormat(c,I.context,i,I.stave),I.stave&&this.postFormat(),this}formatToStave(i,c,M){const I=c.getNoteEndX()-c.getNoteStartX()-10;(function(...X){$t.DEBUG&&d.L("Vex.Flow.Formatter",X)})("Formatting voices to width: ",I);const V={context:c.getContext()};return d.Merge(V,M),this.format(i,I,V)}}class ie extends h{static get Position(){return{LEFT:1,RIGHT:2,ABOVE:3,BELOW:4,BEGIN:5,END:6}}constructor(){super(),this.setAttribute("type","StaveModifier"),this.padding=10,this.position=ie.Position.ABOVE,this.layoutMetrics=null}getPosition(){return this.position}setPosition(i){return this.position=i,this}getStave(){return this.stave}setStave(i){return this.stave=i,this}getWidth(){return this.width}setWidth(i){return this.width=i,this}getX(){return this.x}setX(i){return this.x=i,this}getCategory(){return""}makeSpacer(i){return{getContext:()=>!0,setStave(){},renderToStave(){},getMetrics:()=>({width:i})}}placeGlyphOnLine(i,c,M){i.setYShift(c.getYForLine(M)-c.getYForGlyphs())}getPadding(i){return i!==void 0&&i<2?0:this.padding}setPadding(i){return this.padding=i,this}setLayoutMetrics(i){return this.layoutMetrics=i,this}getLayoutMetrics(){return this.layoutMetrics}}class Jt extends ie{static get CATEGORY(){return"barlines"}static get type(){return{SINGLE:1,DOUBLE:2,END:3,REPEAT_BEGIN:4,REPEAT_END:5,REPEAT_BOTH:6,NONE:7,DOUBLE_HEAVY:8}}static get typeString(){return{single:Jt.type.SINGLE,double:Jt.type.DOUBLE,doubleheavy:Jt.type.DOUBLE_HEAVY,end:Jt.type.END,repeatBegin:Jt.type.REPEAT_BEGIN,repeatEnd:Jt.type.REPEAT_END,repeatBoth:Jt.type.REPEAT_BOTH,none:Jt.type.NONE}}constructor(i){super(),this.setAttribute("type","Barline"),this.thickness=v.STAVE_LINE_THICKNESS;const c=Jt.type;this.widths={},this.widths[c.SINGLE]=5,this.widths[c.DOUBLE]=5,this.widths[c.DOUBLE_HEAVY]=5,this.widths[c.END]=5,this.widths[c.REPEAT_BEGIN]=5,this.widths[c.REPEAT_END]=5,this.widths[c.REPEAT_BOTH]=5,this.widths[c.NONE]=5,this.paddings={},this.paddings[c.SINGLE]=0,this.paddings[c.DOUBLE]=0,this.paddings[c.DOUBLE_HEAVY]=0,this.paddings[c.END]=5,this.paddings[c.REPEAT_BEGIN]=10,this.paddings[c.REPEAT_END]=10,this.paddings[c.REPEAT_BOTH]=15,this.paddings[c.NONE]=0,this.layoutMetricsMap={},this.layoutMetricsMap[c.SINGLE]={xMin:0,xMax:1,paddingLeft:5,paddingRight:5},this.layoutMetricsMap[c.DOUBLE]={xMin:-3,xMax:1,paddingLeft:5,paddingRight:5},this.layoutMetricsMap[c.DOUBLE_HEAVY]={xMin:-5,xMax:4,paddingLeft:5,paddingRight:5},this.layoutMetricsMap[c.END]={xMin:-5,xMax:1,paddingLeft:5,paddingRight:5},this.layoutMetricsMap[c.REPEAT_END]={xMin:-10,xMax:1,paddingLeft:5,paddingRight:5},this.layoutMetricsMap[c.REPEAT_BEGIN]={xMin:-2,xMax:10,paddingLeft:5,paddingRight:5},this.layoutMetricsMap[c.REPEAT_BOTH]={xMin:-10,xMax:10,paddingLeft:5,paddingRight:5},this.layoutMetricsMap[c.NONE]={xMin:0,xMax:0,paddingLeft:5,paddingRight:5},this.setPosition(ie.Position.BEGIN),this.setType(i)}getCategory(){return Jt.CATEGORY}getType(){return this.type}setType(i){return this.type=typeof i=="string"?Jt.typeString[i]:i,this.setWidth(this.widths[this.type]),this.setPadding(this.paddings[this.type]),this.setLayoutMetrics(this.layoutMetricsMap[this.type]),this}draw(i){switch(i.checkContext(),this.setRendered(),this.type){case Jt.type.SINGLE:this.drawVerticalBar(i,this.x,!1);break;case Jt.type.DOUBLE:this.drawVerticalBar(i,this.x,!0);break;case Jt.type.DOUBLE_HEAVY:this.drawVerticalBar(i,this.x,!0,!0);break;case Jt.type.END:this.drawVerticalEndBar(i,this.x);break;case Jt.type.REPEAT_BEGIN:this.drawRepeatBar(i,this.x,!0),i.getX()!==this.x&&this.drawVerticalBar(i,i.getX());break;case Jt.type.REPEAT_END:this.drawRepeatBar(i,this.x,!1);break;case Jt.type.REPEAT_BOTH:this.drawRepeatBar(i,this.x,!1),this.drawRepeatBar(i,this.x,!0)}}drawVerticalBar(i,c,M,I){i.checkContext();const V=i.getTopLineTopY(),X=i.getBottomLineBottomY();let Z=1,nt=1,at=c-3,ft=c;I&&(Z=3,nt=3,at=c-5,ft=c),M&&i.context.fillRect(at,V,Z,X-V),i.context.fillRect(ft,V,nt,X-V)}drawVerticalEndBar(i,c){i.checkContext();const M=i.getTopLineTopY(),I=i.getBottomLineBottomY();i.context.fillRect(c-5,M,1,I-M),i.context.fillRect(c-2,M,3,I-M)}drawRepeatBar(i,c,M){i.checkContext();const I=i.getTopLineTopY(),V=i.getBottomLineBottomY();let X=3;M||(X=-5),i.context.fillRect(c+X,I,1,V-I),i.context.fillRect(c-2,I,3,V-I),M?X+=4:X-=4;const Z=c+X+1;let nt=(i.getNumLines()-1)*i.getSpacingBetweenLines();nt=nt/2-i.getSpacingBetweenLines()/2;let at=I+nt+1;i.context.beginPath(),i.context.arc(Z,at,2,0,2*Math.PI,!1),i.context.fill(),at+=i.getSpacingBetweenLines(),i.context.beginPath(),i.context.arc(Z,at,2,0,2*Math.PI,!1),i.context.fill()}}class oe extends ie{static get CATEGORY(){return"repetitions"}static get type(){return{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}}constructor(i,c,M){super(),this.setAttribute("type","Repetition"),this.symbol_type=i,this.x=c,this.x_shift=0,this.y_shift=M,this.font={family:"times",size:12,weight:"bold italic"}}getCategory(){return oe.CATEGORY}setShiftX(i){return this.x_shift=i,this}setShiftY(i){return this.y_shift=i,this}setX(i){return this.x=i,this}draw(i,c){switch(this.setRendered(),this.symbol_type){case oe.type.CODA_RIGHT:this.drawCodaFixed(i,c+i.width);break;case oe.type.CODA_LEFT:this.drawSymbolText(i,c,"Coda",!0);break;case oe.type.SEGNO_LEFT:this.drawSignoFixed(i,c);break;case oe.type.SEGNO_RIGHT:this.drawSignoFixed(i,c+i.width);break;case oe.type.DC:this.drawSymbolText(i,c,"D.C.",!1);break;case oe.type.DC_AL_CODA:this.drawSymbolText(i,c,"D.C. al",!0);break;case oe.type.DC_AL_FINE:this.drawSymbolText(i,c,"D.C. al Fine",!1);break;case oe.type.DS:this.drawSymbolText(i,c,"D.S.",!1);break;case oe.type.DS_AL_CODA:this.drawSymbolText(i,c,"D.S. al",!0);break;case oe.type.DS_AL_FINE:this.drawSymbolText(i,c,"D.S. al Fine",!1);break;case oe.type.FINE:this.drawSymbolText(i,c,"Fine",!1);break;case oe.type.TO_CODA:this.drawSymbolText(i,c,"To",!0)}return this}drawCodaFixed(i,c){const M=i.getYForTopText(i.options.num_lines)+this.y_shift;return S.renderGlyph(i.context,this.x+c+this.x_shift,M+25,40,"v4d",!0),this}drawSignoFixed(i,c){const M=i.getYForTopText(i.options.num_lines)+this.y_shift;return S.renderGlyph(i.context,this.x+c+this.x_shift,M+25,30,"v8c",!0),this}drawSymbolText(i,c,M,I){const V=i.checkContext();V.save(),V.setFont(this.font.family,this.font.size,this.font.weight);let X=0+this.x_shift,Z=c+this.x_shift;if(this.symbol_type===oe.type.CODA_LEFT?(X=this.x+this.x_shift,Z=X+V.measureText(M).width+12):(this.x_shift=-(X+V.measureText(M).width+12+i.options.vertical_bar_width+12),X=this.x+this.x_shift+i.options.vertical_bar_width,Z=X+V.measureText(M).width+12),this.xShiftAsPercentOfStaveWidth){const at=i.width*this.xShiftAsPercentOfStaveWidth;this.symbol_type!==oe.type.DC_AL_FINE&&this.symbol_type!==oe.type.FINE&&this.symbol_type!==oe.type.DC&&this.symbol_type!==oe.type.DS_AL_FINE&&this.symbol_type!==oe.type.DS&&this.symbol_type!==oe.type.FINE||(X+=at)}const nt=i.getYForTopText(i.options.num_lines)+this.y_shift+25;return I&&S.renderGlyph(V,Z,nt,40,"v4d",!0),V.fillText(M,X,nt+5),V.restore(),this}}class Ke extends ie{static get CATEGORY(){return"stavesection"}constructor(i,c,M){super(),this.setAttribute("type","StaveSection"),this.setWidth(16),this.section=i,this.x=c,this.shift_x=0,this.shift_y=M,this.font={family:"sans-serif",size:12,weight:"bold"}}getCategory(){return Ke.CATEGORY}setStaveSection(i){return this.section=i,this}setShiftX(i){return this.shift_x=i,this}setShiftY(i){return this.shift_y=i,this}draw(i,c){const M=i.checkContext();this.setRendered(),M.save(),M.lineWidth=2,M.setFont(this.font.family,this.font.size,this.font.weight);const I=M.measureText(""+this.section),V=I.width;let X=I.height;!X&&I.emHeightAscent>=0&&(X=I.emHeightAscent+2),X||(X=I.fontBoundingBoxAscent+3);let Z=V+6;Z<18&&(Z=18);const nt=X+this.font.size/10,at=i.getYForTopText(3)+19-1.15*nt+this.shift_y;let ft=this.x+c;return M.beginPath(),M.lineWidth=2,M.rect(ft,at+X/4,Z,nt),M.stroke(),ft+=(Z-V)/2,M.fillText(""+this.section,ft,at+nt),M.restore(),this}}class De extends ie{static get CATEGORY(){return"stavetempo"}constructor(i,c,M){super(),this.setAttribute("type","StaveTempo"),this.tempo=i,this.position=tt.Position.ABOVE,this.x=c,this.shift_x=10,this.shift_y=M,this.font={family:"times",size:14,weight:"bold"},this.render_options={glyph_font_scale:30}}getCategory(){return De.CATEGORY}setTempo(i){return this.tempo=i,this}setShiftX(i){return this.shift_x=i,this}setShiftY(i){return this.shift_y=i,this}draw(i,c){const M=i.checkContext();this.setRendered(),M.openGroup("stavetempo");const I=this.render_options,V=I.glyph_font_scale/38,X=this.tempo.name,Z=this.tempo.duration,nt=this.tempo.dots,at=this.tempo.bpm,ft=this.tempo.noteEquation,pt=this.font;let gt=this.x+this.shift_x+c;const bt=i.getYForTopText(1)+this.shift_y;if(M.save(),X&&(M.setFont(pt.family,pt.size,pt.weight),M.fillText(X,gt,bt),gt+=M.measureText(X).width),ft)gt=this.drawNoteEquation(M,gt,bt,V,ft);else if(Z&&at){M.setFont(pt.family,pt.size,"normal"),X&&(gt+=M.measureText(" ").width,M.fillText("(",gt,bt),gt+=M.measureText("(").width);const Mt=v.getGlyphProps(Z);if(gt+=3*V,S.renderGlyph(M,gt,bt,I.glyph_font_scale,Mt.code_head),gt+=Mt.getWidth()*V,Mt.stem){let _t=30;Mt.beam_count&&(_t+=3*(Mt.beam_count-1)),_t*=V;const Tt=bt-_t;M.fillRect(gt-V,Tt,V,_t),Mt.flag&&(S.renderGlyph(M,gt,Tt,I.glyph_font_scale,Mt.code_flag_upstem),nt||(gt+=6*V))}for(let _t=0;_t0){const Mt=ft[0],_t=ft[ft.length-1];let Tt=Mt.y_top;for(const ne of ft)Tt=Math.min(Tt,ne.y_top);const Ft=1.25*V,Zt=Tt-1.5*V,Yt=Mt.x-.5*V,ee=_t.stemX+Ft;if(at.bracket){const ne=V;i.beginPath(),i.moveTo(Yt,Zt+ne),i.lineTo(Yt,Zt);const he=(Yt+ee)/2,me=at.showNumber==="both"?`${at.actualNotes}:${at.normalNotes}`:`${at.actualNotes}`;i.setFont(this.font.family,this.font.size-3,"bold");const Le=i.measureText(me).width,Ee=Le/2+2*I;i.lineTo(he-Ee,Zt),i.stroke(),i.beginPath(),i.moveTo(he+Ee,Zt),i.lineTo(ee,Zt),i.lineTo(ee,Zt+ne),i.stroke(),i.fillText(me,he-Le/2,Zt-1*I)}else if(at.showNumber!=="none"){const ne=(Yt+ee)/2,he=at.showNumber==="both"?`${at.actualNotes}:${at.normalNotes}`:`${at.actualNotes}`;i.setFont(this.font.family,this.font.size-3,"bold");const me=i.measureText(he).width;i.fillText(he,ne-me/2,Zt-1*I)}}return c}}class Xe extends ${static get Justification(){return{LEFT:1,CENTER:2,RIGHT:3}}static get GLYPHS(){return{segno:{code:"v8c",point:40,x_shift:0,y_shift:-10},tr:{code:"v1f",point:40,x_shift:0,y_shift:0},mordent_upper:{code:"v1e",point:40,x_shift:0,y_shift:0},mordent_lower:{code:"v45",point:40,x_shift:0,y_shift:0},f:{code:"vba",point:40,x_shift:0,y_shift:0},p:{code:"vbf",point:40,x_shift:0,y_shift:0},m:{code:"v62",point:40,x_shift:0,y_shift:0},s:{code:"v4a",point:40,x_shift:0,y_shift:0},z:{code:"v80",point:40,x_shift:0,y_shift:0},coda:{code:"v4d",point:40,x_shift:0,y_shift:-8},pedal_open:{code:"v36",point:40,x_shift:0,y_shift:0},pedal_close:{code:"v5d",point:40,x_shift:0,y_shift:3},caesura_straight:{code:"v34",point:40,x_shift:0,y_shift:2},caesura_curved:{code:"v4b",point:40,x_shift:0,y_shift:2},breath:{code:"v6c",point:40,x_shift:0,y_shift:0},tick:{code:"v6f",point:50,x_shift:0,y_shift:0},turn:{code:"v72",point:40,x_shift:0,y_shift:0},turn_inverted:{code:"v33",point:40,x_shift:0,y_shift:0},mordent:{code:"v1e",point:40,x_shift:0,y_shift:0}}}constructor(i){if(super(i),this.setAttribute("type","TextNote"),this.text=i.text,this.superscript=i.superscript,this.subscript=i.subscript,this.glyph_type=i.glyph,this.glyph=null,this.font={family:"Arial",size:12,weight:""},i.font&&(this.font=i.font),this.glyph_type){const c=Xe.GLYPHS[this.glyph_type];if(!c)throw new d.RERR("Invalid glyph type: "+this.glyph_type);this.glyph=new S(c.code,c.point,{cache:!1}),c.width?this.setWidth(c.width):this.setWidth(this.glyph.getMetrics().width),this.glyph_struct=c}else this.setWidth(v.textWidth(this.text));this.line=i.line||0,this.smooth=i.smooth||!1,this.ignore_ticks=i.ignore_ticks||!1,this.justification=Xe.Justification.LEFT}setJustification(i){return this.justification=i,this}setLine(i){return this.line=i,this}preFormat(){this.checkContext(),this.preFormatted||(this.smooth?this.setWidth(0):this.glyph||this.setWidth(this.context.measureText(this.text).width),this.justification===Xe.Justification.CENTER?this.extraLeftPx=this.width/2:this.justification===Xe.Justification.RIGHT&&(this.extraLeftPx=this.width),this.setPreFormatted(!0))}draw(){if(this.checkContext(),!this.stave)throw new d.RERR("NoStave","Can't draw without a stave.");this.setRendered();const i=this.context;let c,M=this.getAbsoluteX();if(this.justification===Xe.Justification.CENTER?M-=this.getWidth()/2:this.justification===Xe.Justification.RIGHT&&(M-=this.getWidth()),this.glyph)c=this.stave.getYForLine(this.line+-3),this.glyph.render(this.context,M+this.glyph_struct.x_shift,c+this.glyph_struct.y_shift);else{c=this.stave.getYForLine(this.line+-3),this.applyStyle(i),i.setFont(this.font.family,this.font.size,this.font.weight),i.fillText(this.text,M,c);const I=i.measureText("M").width,V=i.measureText(this.text).width;this.superscript&&(i.setFont(this.font.family,this.font.size/1.3,this.font.weight),i.fillText(this.superscript,M+V+2,c-I/2.2)),this.subscript&&(i.setFont(this.font.family,this.font.size/1.3,this.font.weight),i.fillText(this.subscript,M+V+2,c+I/2.2-1)),this.restoreStyle(i)}}}class Pi extends ie{static get CATEGORY(){return"stavetext"}constructor(i,c,M){super(),this.setAttribute("type","StaveText"),this.setWidth(16),this.text=i,this.position=c,this.options={shift_x:0,shift_y:0,justification:Xe.Justification.CENTER},d.Merge(this.options,M),this.font={family:"times",size:16,weight:"normal"}}getCategory(){return Pi.CATEGORY}setStaveText(i){return this.text=i,this}setShiftX(i){return this.shift_x=i,this}setShiftY(i){return this.shift_y=i,this}setFont(i){d.Merge(this.font,i)}setText(i){this.text=i}draw(i){const c=i.checkContext();this.setRendered(),c.save(),c.lineWidth=2,c.setFont(this.font.family,this.font.size,this.font.weight);const M=c.measureText(""+this.text).width;let I,V;const X=ie.Position,Z=Xe.Justification;switch(this.position){case X.LEFT:case X.RIGHT:V=(i.getYForLine(0)+i.getBottomLineY())/2+this.options.shift_y,I=this.position===X.LEFT?i.getX()-M-24+this.options.shift_x:i.getX()+i.getWidth()+24+this.options.shift_x;break;case X.ABOVE:case X.BELOW:I=i.getX()+this.options.shift_x,this.options.justification===Z.CENTER?I+=i.getWidth()/2-M/2:this.options.justification===Z.RIGHT&&(I+=i.getWidth()-M),V=this.position===X.ABOVE?i.getYForTopText(2)+this.options.shift_y:i.getYForBottomText(2)+this.options.shift_y;break;default:throw new d.RERR("InvalidPosition","Value Must be in Modifier.Position.")}return c.fillText(""+this.text,I,V+4),c.restore(),this}}class ai extends ie{static get CATEGORY(){return"clefs"}static get types(){return{treble:{code:"v83",line:3},bass:{code:"v79",line:1},alto:{code:"vad",line:2},tenor:{code:"vad",line:1},percussion:{code:"v59",line:2},soprano:{code:"vad",line:4},"mezzo-soprano":{code:"vad",line:3},"baritone-c":{code:"vad",line:0},"baritone-f":{code:"v79",line:2},subbass:{code:"v79",line:0},french:{code:"v83",line:4},tab:{code:"v2f"}}}static get sizes(){return{default:{point:40,width:26},small:{point:32,width:20}}}static get annotations(){return{"8va":{code:"v8",sizes:{default:{point:20,attachments:{treble:{line:-1.2,x_shift:11}}},small:{point:18,attachments:{treble:{line:-.4,x_shift:8}}}}},"8vb":{code:"v8",sizes:{default:{point:20,attachments:{treble:{line:6.3,x_shift:10},bass:{line:4,x_shift:1}}},small:{point:18,attachments:{treble:{line:5.8,x_shift:6},bass:{line:3.5,x_shift:.5}}}}}}}constructor(i,c,M){super(),this.setAttribute("type","Clef"),this.setPosition(ie.Position.BEGIN),this.setType(i,c,M),this.setWidth(ai.sizes[this.size].width),(function(...I){ai.DEBUG&&d.L("Vex.Flow.Clef",I)})("Creating clef:",i)}getCategory(){return ai.CATEGORY}setType(i,c,M){if(this.type=i,this.clef=ai.types[i],this.size=c===void 0?"default":c,this.clef.point=ai.sizes[this.size].point,this.glyph=new S(this.clef.code,this.clef.point),M!==void 0){const I=ai.annotations[M];this.annotation={code:I.code,point:I.sizes[this.size].point,line:I.sizes[this.size].attachments[this.type].line,x_shift:I.sizes[this.size].attachments[this.type].x_shift},this.attachment=new S(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(){if(this.type==="tab"&&!this.stave)throw new d.RERR("ClefError","Can't get width without stave.");return this.width}setStave(i){if(this.stave=i,this.type!=="tab")return this;let c,M;const I=this.stave.getOptions().num_lines;switch(I){case 8:c=55,M=14;break;case 7:c=47,M=8;break;case 6:c=40,M=1;break;case 5:c=30,M=-6;break;case 4:c=23,M=-12;break;case 3:c=16,M=-18;break;default:throw new d.RERR("ClefError",`Invalid number of lines: ${I}`)}return this.glyph.setPoint(c),this.glyph.setYShift(M),this}draw(){if(!this.x)throw new d.RERR("ClefError","Can't draw clef without x.");if(!this.stave)throw new d.RERR("ClefError","Can't draw clef without stave.");this.setRendered(),this.glyph.setStave(this.stave),this.glyph.setContext(this.stave.context),this.clef.line!==void 0&&this.placeGlyphOnLine(this.glyph,this.stave,this.clef.line),this.stave.context.openGroup("clef"),this.glyph.renderToStave(this.x),this.annotation!==void 0&&(this.placeGlyphOnLine(this.attachment,this.stave,this.annotation.line),this.attachment.setStave(this.stave),this.attachment.setContext(this.stave.context),this.attachment.renderToStave(this.x)),this.stave.context.closeGroup()}}class we extends ie{static get CATEGORY(){return"keysignatures"}static get accidentalSpacing(){return{"#":{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}}}constructor(i,c,M){super(),this.setAttribute("type","KeySignature"),this.setKeySig(i,c,M),this.setPosition(ie.Position.BEGIN),this.glyphFontScale=38,this.glyphs=[],this.xPositions=[],this.paddingForced=!1}getCategory(){return we.CATEGORY}convertToGlyph(i,c){const M=v.accidentalCodes(i.type),I=new S(M.code,this.glyphFontScale);let V=1;if(i.type==="n"&&c){const nt=we.accidentalSpacing[c.type];nt&&(V=c.line>=i.line?nt.above:nt.below)}this.placeGlyphOnLine(I,this.stave,i.line),this.glyphs.push(I);const X=this.xPositions[this.xPositions.length-1],Z=I.getMetrics().width+V;this.xPositions.push(X+Z),this.width+=Z}cancelKey(i){return this.formatted=!1,this.cancelKeySpec=i,this}convertToCancelAccList(i){const c=v.keySignature(i),M=this.accList.length>0&&c.length>0&&c[0].type!==this.accList[0].type,I=M?c.length:c.length-this.accList.length;if(I<1)return;const V=[];for(let X=0;X0?i[0].type:null;let M;if(this.cancelKeySpec&&(M=this.convertToCancelAccList(this.cancelKeySpec)),this.alterKeySpec&&this.convertToAlterAccList(this.alterKeySpec),this.accList.length>0){const I=(this.position===ie.Position.END?this.stave.endClef:this.stave.clef)||this.stave.clef;M&&this.convertAccLines(I,M.type,M.accList),this.convertAccLines(I,c,i);for(let V=0;V0){const i=this.stave.context.openGroup("keysignature");for(let c=0;c{const V=I.split("/").filter(X=>X!=="");if(V.length!==2)throw new d.RERR("BadTimeSignature",`Invalid time spec: ${I}. Must be in the form "/"`);V.forEach(X=>{if(isNaN(Number(X)))throw new d.RERR("BadTimeSignature",`Invalid time spec: ${I}. Must contain two valid numbers.`)})})(i);const[c,M]=i.split("/").map(I=>I.split(""));return{num:!0,glyph:this.makeTimeSignatureGlyph(c,M)}}makeTimeSignatureGlyph(i,c){const M=new S("v0",this.point);M.topGlyphs=[],M.botGlyphs=[];let I=0;for(let pt=0;ptV?I:V,Z=M.getMetrics().x_min;M.getMetrics=()=>({x_min:Z,x_max:Z+X,width:X});const nt=(X-I)/2,at=(X-V)/2,ft=this;return M.renderToStave=function(pt){let gt=pt+nt;for(let bt=0;bt{M.getNoteStartX()>c&&(c=M.getNoteStartX())}),i.forEach(M=>{M.setNoteStartX(c)}),c=0,i.forEach(M=>{M.getModifiers(ie.Position.BEGIN,Jt.CATEGORY).forEach(I=>{I.getType()==Jt.type.REPEAT_BEGIN&&I.getX()>c&&(c=I.getX())})}),i.forEach(M=>{M.getModifiers(ie.Position.BEGIN,Jt.CATEGORY).forEach(I=>{I.getType()==Jt.type.REPEAT_BEGIN&&I.setX(c)})}),c=0,i.forEach(M=>{M.getModifiers(ie.Position.BEGIN,Ge.CATEGORY).forEach(I=>{I.getX()>c&&(c=I.getX())})}),i.forEach(M=>{M.getModifiers(ie.Position.BEGIN,Ge.CATEGORY).forEach(I=>{I.setX(c)})})}getOptions(){return this.options}setNoteStartX(i){return this.formatted||this.format(),this.setStartX(i),this}setStartX(i){this.start_x=i}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.x+this.width}getX(){return this.x}getNumLines(){return this.options.num_lines}setNumLines(i){return this.options.num_lines=parseInt(i,10),this.resetLines(),this}setY(i){return this.y=i,this}getTopLineTopY(){return this.getYForLine(0)-v.STAVE_LINE_THICKNESS/2}getBottomLineBottomY(){return this.getYForLine(this.getNumLines()-1)+v.STAVE_LINE_THICKNESS/2}setX(i){const c=i-this.x;this.formatted=!1,this.x=i,this.start_x+=c,this.end_x+=c;for(let M=0;MM.getWidth()&&(c-=M.getWidth()),c}setRepetitionTypeLeft(i,c){return this.modifiers.push(new oe(i,this.x,c)),this}setRepetitionTypeRight(i,c){return this.modifiers.push(new oe(i,this.x,c)),this}setVoltaType(i,c,M){return this.modifiers.push(new xi(i,c,this.x,M)),this}setSection(i,c,M=0,I=12){const V=new Ke(i,this.x+M,c);return V.font.size=I,this.modifiers.push(V),this}setTempo(i,c){return this.modifiers.push(new De(i,this.x,c)),this}setText(i,c,M){return this.modifiers.push(new Pi(i,c,M)),this}getHeight(){return this.height}getSpacingBetweenLines(){return this.options.spacing_between_lines_px}getBoundingBox(){return new f(this.x,this.y,this.width,this.getBottomY()-this.y)}getBottomY(){const i=this.options,c=i.spacing_between_lines_px;return this.getYForLine(i.num_lines)+i.space_below_staff_ln*c}getBottomLineY(){return this.getYForLine(this.options.num_lines)}getYForLine(i){const c=this.options,M=c.spacing_between_lines_px,I=c.space_above_staff_ln;return this.y+i*M+I*M}getLineForY(i){const c=this.options,M=c.spacing_between_lines_px,I=c.space_above_staff_ln;return(i-this.y)/M-I}getYForTopText(i){const c=i||0;return this.getYForLine(-c-this.options.top_text_position)}getYForBottomText(i){const c=i||0;return this.getYForLine(this.options.bottom_text_position+c)}getYForNote(i){const c=this.options,M=c.spacing_between_lines_px,I=c.space_above_staff_ln;return this.y+I*M+5*M-i*M}getYForGlyphs(){return this.getYForLine(3)}addModifier(i,c){return c!==void 0&&i.setPosition(c),i.setStave(this),this.formatted=!1,this.modifiers.push(i),this}addEndModifier(i){return this.addModifier(i,ie.Position.END),this}setBegBarType(i){const{SINGLE:c,REPEAT_BEGIN:M,NONE:I}=Jt.type;return i!==c&&i!==M&&i!==I||(this.modifiers[0].setType(i),this.formatted=!1),this}setEndBarType(i){return i!==Jt.type.REPEAT_BEGIN&&(this.modifiers[1].setType(i),this.formatted=!1),this}setClef(i,c,M,I){I===void 0&&(I=ie.Position.BEGIN),I===ie.Position.END?this.endClef=i:this.clef=i;const V=this.getModifiers(I,ai.CATEGORY);return V.length===0?this.addClef(i,c,M,I):V[0].setType(i,c,M),this}setEndClef(i,c,M){return this.setClef(i,c,M,ie.Position.END),this}setKeySignature(i,c,M){M===void 0&&(M=ie.Position.BEGIN);const I=this.getModifiers(M,we.CATEGORY);return I.length===0?this.addKeySignature(i,c,M):I[0].setKeySig(i,c),this}setEndKeySignature(i,c){return this.setKeySignature(i,c,ie.Position.END),this}setTimeSignature(i,c,M){M===void 0&&(M=ie.Position.BEGIN);const I=this.getModifiers(M,Ge.CATEGORY);return I.length===0?this.addTimeSignature(i,c,M):I[0].setTimeSig(i),this}setEndTimeSignature(i,c){return this.setTimeSignature(i,c,ie.Position.END),this}addKeySignature(i,c,M){return M===void 0&&(M=ie.Position.BEGIN),this.addModifier(new we(i,c).setPosition(M),M),this}addClef(i,c,M,I){return I===void 0||I===ie.Position.BEGIN?this.clef=i:I===ie.Position.END&&(this.endClef=i),this.addModifier(new ai(i,c,M),I),this}addEndClef(i,c,M){return this.addClef(i,c,M,ie.Position.END),this}addTimeSignature(i,c,M){return this.addModifier(new Ge(i,c),M),this}addEndTimeSignature(i,c){return this.addTimeSignature(i,c,ie.Position.END),this}addTrebleGlyph(){return this.addClef("treble"),this}getModifiers(i,c){return i===void 0&&c===void 0?this.modifiers:this.modifiers.filter(M=>!(i!==void 0&&i!==M.getPosition()||c!==void 0&&c!==M.getCategory()))}sortByCategory(i,c){for(let M=i.length-1;M>=0;M--)for(let I=0;Ic[i[I+1].getCategory()]){const V=i[I];i[I]=i[I+1],i[I+1]=V}}format(){const i=this.modifiers[0],c=this.modifiers[1],M=this.getModifiers(ie.Position.BEGIN),I=this.getModifiers(ie.Position.END);let V,X,Z;this.sortByCategory(M,{barlines:0,clefs:1,keysignatures:2,timesignatures:3}),this.sortByCategory(I,{timesignatures:0,keysignatures:1,barlines:2,clefs:3}),M.length>1&&i.getType()===Jt.type.REPEAT_BEGIN&&(M.push(M.splice(0,1)[0]),M.splice(0,0,new Jt(Jt.type.SINGLE))),I.indexOf(c)>0&&I.splice(0,0,new Jt(Jt.type.NONE));let nt=0,at=this.x;for(let gt=0;gtat?at=bt:Z.setX(at),at+=V,X+V===0&&nt--}at>this.start_x&&this.setStartX(at),at=this.x+this.width;const ft={left:0,right:0,paddingRight:0,paddingLeft:0};let pt=0;for(let gt=0;gt0){this.context.save(),this.context.setFont(this.font.family,this.font.size,this.font.weight);const V=this.context.measureText(""+this.measure).width;I=this.getYForTopText(0)+3,this.context.fillText(""+this.measure,this.x-V/2,I),this.context.restore()}return this}drawVertical(i,c){this.drawVerticalFixed(this.x+i,c)}drawVerticalFixed(i,c){this.checkContext();const M=this.getYForLine(0),I=this.getYForLine(this.options.num_lines-1);c&&this.context.fillRect(i-3,M,1,I-M+1),this.context.fillRect(i,M,1,I-M+1)}drawVerticalBar(i){this.drawVerticalBarFixed(this.x+i,!1)}drawVerticalBarFixed(i){this.checkContext();const c=this.getYForLine(0),M=this.getYForLine(this.options.num_lines-1);this.context.fillRect(i,c,1,M-c+1)}getConfigForLines(){return this.options.line_config}setConfigForLine(i,c){if(i>=this.options.num_lines||i<0)throw new d.RERR("StaveConfigError","The line number must be within the range of the number of lines in the Stave.");if(c.visible===void 0)throw new d.RERR("StaveConfigError","The line configuration object is missing the 'visible' property.");if(typeof c.visible!="boolean")throw new d.RERR("StaveConfigError","The line configuration objects 'visible' property must be true or false.");return this.options.line_config[i]=c,this}setConfigForLines(i){if(i.length!==this.options.num_lines)throw new d.RERR("StaveConfigError","The length of the lines configuration array must match the number of lines in the Stave");for(const c in i)i[c]||(i[c]=this.options.line_config[c]),d.Merge(this.options.line_config[c],i[c]);return this.options.line_config=i,this}}class Re extends Ce{constructor(i,c,M,I){const V={spacing_between_lines_px:13,num_lines:6,top_text_position:1};d.Merge(V,I),super(i,c,M,V),this.setAttribute("type","TabStave")}getYForGlyphs(){return this.getYForLine(2.5)}addTabGlyph(){return this.addClef("tab"),this}}class He extends Y{static get CATEGORY(){return"tabnotes"}constructor(i,c){if(super(i),this.setAttribute("type","TabNote"),this.ghost=!1,this.positions=i.positions,d.Merge(this.render_options,{glyph_font_scale:v.DEFAULT_TABLATURE_FONT_SCALE,draw_stem:c,draw_dots:c,draw_stem_through_stave:!1,y_shift:0,scale:1,font:"10pt Arial"}),this.glyph=v.getGlyphProps(this.duration,this.noteType),!this.glyph)throw new d.RuntimeError("BadArguments",`Invalid note initialization data (No glyph found): ${JSON.stringify(i)}`);this.buildStem(),i.stem_direction?this.setStemDirection(i.stem_direction):this.setStemDirection(B.UP),this.ghost=!1,this.updateWidth()}reset(){this.stave&&this.setStave(this.stave)}getCategory(){return He.CATEGORY}setGhost(i){return this.ghost=i,this.updateWidth(),this}hasStem(){return this.render_options.draw_stem}getStemExtension(){const i=this.getGlyph();return this.stem_extension_override!=null?this.stem_extension_override:i?this.getStemDirection()===1?i.tabnote_stem_up_extension:i.tabnote_stem_down_extension:0}addDot(){const i=new H;return this.dots+=1,this.addModifier(i,0)}updateWidth(){this.glyphs=[],this.width=0;for(let i=0;ithis.width}setStave(i){let c;if(super.setStave(i),this.context=i.context,this.context){const I=this.context;for(this.width=0,c=0;cV.width),this.width=Math.max(V.getWidth(),this.width)}this.glyph.getWidth=()=>this.width}const M=this.positions.map(({str:I})=>i.getYForLine(I-1));return this.setYs(M),this.stem&&this.stem.setYBounds(this.getStemY(),this.getStemY()),this}getPositions(){return this.positions}addToModifierContext(i){this.setModifierContext(i);for(let c=0;c{(i.getCategory()!=="dots"||this.render_options.draw_dots)&&(i.setContext(this.context),i.drawWithStyle())})}drawStemThrough(){const i=this.getStemX(),c=this.getStemY(),M=this.context,I=this.render_options.draw_stem_through_stave;if(this.render_options.draw_stem&&I){const V=(function(Z,nt){const at=[];let ft=[];for(let pt=1;pt<=Z;pt++)nt.indexOf(pt)>-1?(at.push(ft),ft=[]):ft.push(pt);return ft.length>0&&at.push(ft),at})(this.stave.getNumLines(),this.positions.map(Z=>Z.str)),X=(function(Z,nt,at,ft){const pt=ft!==1,gt=ft!==-1,bt=at.getSpacingBetweenLines(),Mt=at.getNumLines(),_t=[];return nt.forEach(Tt=>{const Ft=Tt.indexOf(Mt)>-1,Zt=Tt.indexOf(1)>-1;if(pt&&Zt||gt&&Ft)return;Tt.length===1&&Tt.push(Tt[0]);const Yt=[];Tt.forEach((ee,ne,he)=>{const me=ee===1,Le=ee===Mt;let Ee=at.getYForLine(ee-1);ne!==0||me?ne!==he.length-1||Le||(Ee+=bt/2-1):Ee-=bt/2-1,Yt.push(Ee),ft===1&&me?Yt.push(Z-2):ft===-1&&Le&&Yt.push(Z+2)}),_t.push(Yt.sort((ee,ne)=>ee-ne))}),_t})(c,V,this.getStave(),this.getStemDirection());M.save(),M.setLineWidth(B.WIDTH),X.forEach(Z=>{Z.length!==0&&(M.beginPath(),M.moveTo(i,Z[0]),M.lineTo(i,Z[Z.length-1]),M.stroke(),M.closePath())}),M.restore()}}drawPositions(){var I,V;const i=this.context,c=this.getAbsoluteX(),M=this.ys;for(let X=0;X=1&&Z[0].getCategory()==="barlines"&&(V-=Z[0].getPadding()),isNaN(this.render_options.padding_left)||(I=c.getX()+this.render_options.padding_left),isNaN(this.render_options.padding_right)||(V=c.getX()+c.getWidth()-this.render_options.padding_right),this.xs.left=I,this.xs.right=V,this.render_options.use_symbols?this.drawSymbols(i,I,V,M):this.drawLine(i,I,V,M),this.render_options.show_number){const nt="/"+this.number_of_measures,at=new Ge(null,void 0,!1);at.point=this.render_options.number_glyph_point,at.setTimeSig(nt),at.setStave(c),at.x=I+.5*(V-I)-.5*at.timeSig.glyph.getMetrics().width,at.bottomLine=this.render_options.number_line,at.setContext(i).draw()}}}class nn extends ${static get CATEGORY(){return"clefnote"}constructor(i,c,M){super({duration:"b"}),this.setAttribute("type","ClefNote"),this.setType(i,c,M),this.ignore_ticks=!0}setType(i,c,M){return this.type=i,this.clef_obj=new ai(i,c,M),this.clef=this.clef_obj.clef,this.glyph=new S(this.clef.code,this.clef.point),this.setWidth(this.glyph.getMetrics().width),this}getClef(){return this.clef}setContext(i){return this.context=i,this.glyph.setContext(this.context),this}getBoundingBox(){return super.getBoundingBox()}addToModifierContext(){return this}getCategory(){return nn.CATEGORY}preFormat(){return this.setPreFormatted(!0),this}draw(){if(!this.stave)throw new d.RERR("NoStave","Can't draw without a stave.");this.glyph.getContext()||this.glyph.setContext(this.context),this.setRendered();const i=this.getAbsoluteX();if(this.glyph.setStave(this.stave),this.glyph.setYShift(this.stave.getYForLine(this.clef.line)-this.stave.getYForGlyphs()),this.glyph.renderToStave(i),this.clef_obj.annotation!==void 0){const c=new S(this.clef_obj.annotation.code,this.clef_obj.annotation.point);c.getContext()||c.setContext(this.context),c.setStave(this.stave),c.setYShift(this.stave.getYForLine(this.clef_obj.annotation.line)-this.stave.getYForGlyphs()),c.setXShift(this.clef_obj.annotation.x_shift),c.renderToStave(i)}}}class _s extends ${constructor(i,c,M){super({duration:"b"}),this.setAttribute("type","KeySigNote"),this.keySignature=new we(i,c,M),this.ignore_ticks=!0}getBoundingBox(){return super.getBoundingBox()}addToModifierContext(){return this}preFormat(){return this.setPreFormatted(!0),this.keySignature.setStave(this.stave),this.keySignature.format(),this.setWidth(this.keySignature.width),this}draw(){this.stave.checkContext(),this.setRendered(),this.keySignature.x=this.getAbsoluteX(),this.keySignature.setContext(this.context),this.keySignature.draw()}}class ws extends ${constructor(i,c){super({duration:"b"}),this.setAttribute("type","TimeSigNote");const M=new Ge(i,c);this.timeSig=M.getTimeSig(),this.setWidth(this.timeSig.glyph.getMetrics().width),this.ignore_ticks=!0}getBoundingBox(){return super.getBoundingBox()}addToModifierContext(){return this}preFormat(){return this.setPreFormatted(!0),this}draw(){this.stave.checkContext(),this.setRendered(),this.timeSig.glyph.getContext()||this.timeSig.glyph.setContext(this.context),this.timeSig.glyph.setStave(this.stave),this.timeSig.glyph.setYShift(this.stave.getYForLine(this.timeSig.line)-this.stave.getYForGlyphs()),this.timeSig.glyph.renderToStave(this.getAbsoluteX())}}class Mi extends Q{static get SLIDE_UP(){return 1}static get SLIDE_DOWN(){return-1}static createSlideUp(i){return new Mi(i,Mi.SLIDE_UP)}static createSlideDown(i){return new Mi(i,Mi.SLIDE_DOWN)}constructor(i,c){if(super(i,"sl."),this.setAttribute("type","TabSlide"),!c){const M=i.first_note.getPositions()[0].fret,I=i.last_note.getPositions()[0].fret;c=parseInt(M,10)>parseInt(I,10)?Mi.SLIDE_DOWN:Mi.SLIDE_UP}this.slide_direction=c,this.render_options.cp1=11,this.render_options.cp2=14,this.render_options.y_shift=.5,this.setFont({font:"Times",size:10,style:"bold italic"}),this.setNotes(i)}renderTie(i){if(i.first_ys.length===0||i.last_ys.length===0)throw new d.RERR("BadArguments","No Y-values to render");const c=this.context,M=i.first_x_px,I=i.first_ys,V=i.last_x_px,X=this.slide_direction;if(X!==Mi.SLIDE_UP&&X!==Mi.SLIDE_DOWN)throw new d.RERR("BadSlide","Invalid slide direction");for(let Z=0;Zthis.numStrings)throw new d.RERR("BadArguments",`String number must be between 1 and ${this.numStrings}:${i}`);return this.tuningValues[c-1]}getValueForFret(i,c){const M=this.getValueForString(c),I=parseInt(i,10);if(I<0)throw new d.RERR("BadArguments","Fret number must be 0 or higher: "+i);return M+I}getNoteForFret(i,c){const M=this.getValueForFret(i,c),I=Math.floor(M/12),V=M%12;return v.integerToNote(V)+"/"+I}}class rn extends h{static get type(){return{CRESC:1,DECRESC:2}}static FormatByTicksAndDraw(i,c,M,I,V,X){const Z=c.pixelsPerTick;if(Z==null)throw new d.RuntimeError("BadArguments","A valid Formatter must be provide to draw offsets by ticks.");const nt=Z*X.left_shift_ticks,at=Z*X.right_shift_ticks,ft={height:X.height,y_shift:X.y_shift,left_shift_px:nt,right_shift_px:at};new rn({first_note:M.first_note,last_note:M.last_note},I).setContext(i).setRenderOptions(ft).setPosition(V).draw()}constructor(i,c){super(),this.setAttribute("type","StaveHairpin"),this.notes=i,this.hairpin=c,this.position=tt.Position.BELOW,this.render_options={height:10,y_shift:0,left_shift_px:0,right_shift_px:0},this.setNotes(i)}setPosition(i){return i!==tt.Position.ABOVE&&i!==tt.Position.BELOW||(this.position=i),this}setRenderOptions(i){return i.height!=null&&i.y_shift!=null&&i.left_shift_px!=null&&i.right_shift_px!=null&&(this.render_options=i),this}setNotes(i){if(!i.first_note&&!i.last_note)throw new d.RuntimeError("BadArguments","Hairpin needs to have either first_note or last_note set.");return this.first_note=i.first_note,this.last_note=i.last_note,this}renderHairpin(i){const c=this.checkContext();let M=this.render_options.y_shift+20,I=i.first_y;this.position===tt.Position.ABOVE&&(M=30-M,I=i.first_y-i.staff_height);const V=this.render_options.left_shift_px,X=this.render_options.right_shift_px;switch(c.beginPath(),this.hairpin){case rn.type.CRESC:c.moveTo(i.last_x+X,I+M),c.lineTo(i.first_x+V,I+this.render_options.height/2+M),c.lineTo(i.last_x+X,I+this.render_options.height+M);break;case rn.type.DECRESC:c.moveTo(i.first_x+V,I+M),c.lineTo(i.last_x+X,I+this.render_options.height/2+M),c.lineTo(i.first_x+V,I+this.render_options.height+M)}c.stroke(),c.closePath()}draw(){this.checkContext(),this.setRendered();const i=this.first_note,c=this.last_note,M=i.getModifierStartXY(this.position,0),I=c.getModifierStartXY(this.position,0);return this.renderHairpin({first_x:M.x,last_x:I.x,first_y:i.getStave().y+i.getStave().height,last_y:c.getStave().y+c.getStave().height,staff_height:i.getStave().height}),!0}}class Ci extends h{static get Position(){return{NEAR_HEAD:1,NEAR_TOP:2}}static get PositionString(){return{nearHead:Ci.Position.NEAR_HEAD,nearTop:Ci.Position.NEAR_TOP}}constructor(i,c,M){super(),this.setAttribute("type","Curve"),this.render_options={spacing:2,thickness:2,x_shift:0,y_shift:10,position:Ci.Position.NEAR_HEAD,position_end:Ci.Position.NEAR_HEAD,invert:!1,cps:[{x:0,y:10},{x:0,y:10}]},d.Merge(this.render_options,M),this.setNotes(i,c)}setNotes(i,c){if(!i&&!c)throw new d.RuntimeError("BadArguments","Curve needs to have either first_note or last_note set.");return this.from=i,this.to=c,this}isPartial(){return!this.from||!this.to}renderCurve(i){const c=this.context,M=this.render_options.cps,I=this.render_options.x_shift,V=this.render_options.y_shift*i.direction,X=i.first_x+I,Z=i.first_y+V,nt=i.last_x-I,at=i.last_y+V,ft=this.render_options.thickness,pt=(nt-X)/(M.length+2);c.beginPath(),c.moveTo(X,Z),c.bezierCurveTo(X+pt+M[0].x,Z+M[0].y*i.direction,nt-pt+M[1].x,at+M[1].y*i.direction,nt,at),c.bezierCurveTo(nt-pt+M[1].x,at+(M[1].y+ft)*i.direction,X+pt+M[0].x,Z+(M[0].y+ft)*i.direction,X,Z),c.stroke(),c.closePath(),c.fill()}draw(){this.checkContext(),this.setRendered();const i=this.from,c=this.to;let M,I,V,X,Z,nt="baseY",at="baseY";function ft(bt){return typeof bt=="string"?Ci.PositionString[bt]:bt}const pt=ft(this.render_options.position),gt=ft(this.render_options.position_end);return pt===Ci.Position.NEAR_TOP&&(nt="topY",at="topY"),gt===Ci.Position.NEAR_HEAD?at="baseY":gt===Ci.Position.NEAR_TOP&&(at="topY"),i?(M=i.getTieRightX(),Z=i.getStemDirection(),V=i.getStemExtents()[nt]):(M=c.getStave().getTieStartX(),V=c.getStemExtents()[nt]),c?(I=c.getTieLeftX(),Z=c.getStemDirection(),X=c.getStemExtents()[at]):(I=i.getStave().getTieEndX(),X=i.getStemExtents()[at]),this.renderCurve({first_x:M,last_x:I,first_y:V,last_y:X,direction:Z*(this.render_options.invert===!0?-1:1)}),!0}}function Ao(...vt){An.DEBUG&&d.L("Vex.Flow.TextDynamics",vt)}class An extends ${static get GLYPHS(){return{f:{code:"vba",width:12},p:{code:"vbf",width:14},m:{code:"v62",width:17},s:{code:"v4a",width:10},z:{code:"v80",width:12},r:{code:"vb1",width:12}}}constructor(i){super(i),this.setAttribute("type","TextDynamics"),this.sequence=i.text.toLowerCase(),this.line=i.line||0,this.glyphs=[],d.Merge(this.render_options,{glyph_font_size:40}),Ao("New Dynamics Text: ",this.sequence)}setLine(i){return this.line=i,this}preFormat(){let i=0;return this.sequence.split("").forEach(c=>{const M=An.GLYPHS[c];if(!M)throw new d.RERR("Invalid dynamics character: "+c);const I=this.render_options.glyph_font_size,V=new S(M.code,I);this.glyphs.push(V),i+=M.width}),this.setWidth(i),this.preFormatted=!0,this}draw(){this.setRendered();const i=this.getAbsoluteX(),c=this.stave.getYForLine(this.line+-3);Ao("Rendering Dynamics: ",this.sequence);let M=i;this.glyphs.forEach((I,V)=>{const X=this.sequence[V];I.render(this.context,M,c),M+=An.GLYPHS[X].width})}}function Ks(vt,i,c,M,I,V,X){vt.beginPath(),vt.moveTo(i,c),vt.lineTo(M,I),vt.lineTo(V,X),vt.lineTo(i,c),vt.closePath(),vt.fill()}class yi extends h{static get TextVerticalPosition(){return{TOP:1,BOTTOM:2}}static get TextJustification(){return{LEFT:1,CENTER:2,RIGHT:3}}constructor(i){super(),this.setAttribute("type","StaveLine"),this.notes=i,this.text="",this.font={family:"Arial",size:10,weight:""},this.render_options={padding_left:4,padding_right:3,line_width:1,line_dash:null,rounded_end:!0,color:null,draw_start_arrow:!1,draw_end_arrow:!1,arrowhead_length:10,arrowhead_angle:Math.PI/8,text_position_vertical:yi.TextVerticalPosition.TOP,text_justification:yi.TextJustification.CENTER},this.setNotes(i)}setFont(i){return this.font=i,this}setText(i){return this.text=i,this}setNotes(i){if(!i.first_note&&!i.last_note)throw new d.RuntimeError("BadArguments","Notes needs to have either first_note or last_note set.");if(i.first_indices||(i.first_indices=[0]),i.last_indices||(i.last_indices=[0]),i.first_indices.length!==i.last_indices.length)throw new d.RuntimeError("BadArguments","Connected notes must have similar index sizes");return this.first_note=i.first_note,this.first_indices=i.first_indices,this.last_note=i.last_note,this.last_indices=i.last_indices,this}applyLineStyle(){const i=this.checkContext(),c=this.render_options;c.line_dash&&i.setLineDash(c.line_dash),c.line_width&&i.setLineWidth(c.line_width),c.rounded_end?i.setLineCap("round"):i.setLineCap("square")}applyFontStyle(){const i=this.checkContext();this.font&&i.setFont(this.font.family,this.font.size,this.font.weight),this.render_options.color&&(i.setStrokeStyle(this.render_options.color),i.setFillStyle(this.render_options.color))}draw(){const i=this.checkContext();this.setRendered();const c=this.first_note,M=this.last_note,I=this.render_options;let V,X;i.save(),this.applyLineStyle(),this.first_indices.forEach((gt,bt)=>{const Mt=this.last_indices[bt];V=c.getModifierStartXY(2,gt),X=M.getModifierStartXY(1,Mt);const _t=V.y>X.y;V.x+=c.getMetrics().modRightPx+I.padding_left,X.x-=M.getMetrics().modLeftPx+I.padding_right;const Tt=c.getGlyph().getWidth();c.getKeyProps()[gt].displaced&&c.getStemDirection()===1&&(V.x+=Tt+I.padding_left),M.getKeyProps()[Mt].displaced&&M.getStemDirection()===-1&&(X.x-=Tt+I.padding_right),V.y+=_t?-3:1,X.y+=_t?2:0,(function(Ft,Zt,Yt,ee){const ne=ee.draw_start_arrow&&ee.draw_end_arrow,he=Zt.x,me=Zt.y,Le=Yt.x,Ee=Yt.y,vi=Math.sqrt((Le-he)*(Le-he)+(Ee-me)*(Ee-me)),ri=(vi-ee.arrowhead_length/3)/vi;let je,ki,Vi,Yn;ee.draw_end_arrow||ne?(je=Math.round(he+(Le-he)*ri),ki=Math.round(me+(Ee-me)*ri)):(je=Le,ki=Ee),ee.draw_start_arrow||ne?(Vi=he+(Le-he)*(1-ri),Yn=me+(Ee-me)*(1-ri)):(Vi=he,Yn=me),ee.color&&(Ft.setStrokeStyle(ee.color),Ft.setFillStyle(ee.color)),Ft.beginPath(),Ft.moveTo(Vi,Yn),Ft.lineTo(je,ki),Ft.stroke(),Ft.closePath();const pn=Math.atan2(Ee-me,Le-he),gn=Math.abs(ee.arrowhead_length/Math.cos(ee.arrowhead_angle));let qn,an,Ti,Kn,Qn,ln;(ee.draw_end_arrow||ne)&&(qn=pn+Math.PI+ee.arrowhead_angle,Ti=Le+Math.cos(qn)*gn,Kn=Ee+Math.sin(qn)*gn,an=pn+Math.PI-ee.arrowhead_angle,Qn=Le+Math.cos(an)*gn,ln=Ee+Math.sin(an)*gn,Ks(Ft,Ti,Kn,Le,Ee,Qn,ln)),(ee.draw_start_arrow||ne)&&(qn=pn+ee.arrowhead_angle,Ti=he+Math.cos(qn)*gn,Kn=me+Math.sin(qn)*gn,an=pn-ee.arrowhead_angle,Qn=he+Math.cos(an)*gn,ln=me+Math.sin(an)*gn,Ks(Ft,Ti,Kn,he,me,Qn,ln))})(i,V,X,this.render_options)}),i.restore();const Z=i.measureText(this.text).width,nt=I.text_justification;let at,ft=0;nt===yi.TextJustification.LEFT?ft=V.x:nt===yi.TextJustification.CENTER?ft=(X.x-V.x)/2+V.x-Z/2:nt===yi.TextJustification.RIGHT&&(ft=X.x-Z);const pt=I.text_position_vertical;return pt===yi.TextVerticalPosition.TOP?at=c.getStave().getYForTopText():pt===yi.TextVerticalPosition.BOTTOM&&(at=c.getStave().getYForBottomText(v.TEXT_HEIGHT_OFFSET_HACK)),i.save(),this.applyFontStyle(),i.fillText(this.text,ft,at),i.restore(),this}}function Or(vt,i,c,M,I){const V=be.GLYPHS[vt];new S(V.code,I).render(i,c+V.x_shift,M+V.y_shift)}class be extends h{static get GLYPHS(){return{pedal_depress:{code:"v36",x_shift:-10,y_shift:0},pedal_release:{code:"v5d",x_shift:-2,y_shift:3}}}static get Styles(){return{TEXT:1,BRACKET:2,MIXED:3,MIXED_OPEN_END:4,BRACKET_OPEN_BEGIN:5,BRACKET_OPEN_END:6,BRACKET_OPEN_BOTH:7}}static get StylesString(){return{text:be.Styles.TEXT,bracket:be.Styles.BRACKET,mixed:be.Styles.MIXED,mixed_open_end:be.Styles.MIXED_OPEN_END,bracket_open_begin:be.Styles.BRACKET_OPEN_BEGIN,bracket_open_end:be.Styles.BRACKET_OPEN_END,bracket_open_both:be.Styles.BRACKET_OPEN_BOTH}}static createSustain(i){return new be(i)}static createSostenuto(i){const c=new be(i);return c.setStyle(be.Styles.MIXED),c.setCustomText("Sost. Ped."),c}static createUnaCorda(i){const c=new be(i);return c.setStyle(be.Styles.TEXT),c.setCustomText("una corda","tre corda"),c}constructor(i){super(),this.setAttribute("type","PedalMarking"),this.EndsStave=!1,this.ChangeBegin=!1,this.ChangeEnd=!1,this.notes=i,this.style=be.TEXT,this.line=0,this.custom_depress_text="",this.custom_release_text="",this.font={family:"Times New Roman",size:12,weight:"italic bold"},this.render_options={bracket_height:10,text_margin_right:6,bracket_line_width:1,glyph_point_size:40,color:"black"}}setEndStave(i){if(this.endStave=i,this.endStaveAddedWidth=0,this.startMargin=0,this.endMargin=0,Array.isArray(this.endStave.modifiers))for(let c=0;c3)throw new d.RERR("InvalidParameter","The style must be one found in PedalMarking.Styles");return this.style=i,this}setLine(i){return this.line=i,this}drawBracketed(){const i=this.context;let c,M,I=!1;const V=this;this.notes.forEach((X,Z,nt)=>{I=!I;let at=0;if(X?(at=X.getNoteHeadBeginX(),this.BeginsStave&&(at=X.getStave().getNoteStartX())):at=this.endStave.end_x+this.endStaveAddedWidth,this.EndsStave)I?this.ChangeBegin&&(at=X.getAbsoluteX()):(at=X?this.ChangeEnd?X.getAbsoluteX():X.getStave().end_x+this.endStaveAddedWidth-V.render_options.text_margin_right:this.endStave.end_x+this.endStaveAddedWidth-V.render_options.text_margin_right,this.endMargin=-V.render_options.text_margin_right);else if(X)if(I)this.ChangeBegin&&(at=X.getAbsoluteX());else switch(V.style){case be.Styles.BRACKET_OPEN_END:case be.Styles.BRACKET_OPEN_BOTH:case be.Styles.MIXED_OPEN_END:at=X.getNoteHeadEndX();break;default:this.ChangeEnd?at=X.getAbsoluteX():(at=X.getNoteHeadBeginX()-V.render_options.text_margin_right,this.startMargin=-V.render_options.text_margin_right)}let ft=this.endStave;X&&(ft=X.getStave());let pt=ft.getYForBottomText(V.line+3);M&&M>pt&&(pt=M);const gt=nt[Z+1]===X,bt=nt[Z-1]===X;let Mt=0;if(I)if(Mt=bt?5:0,V.style!==be.Styles.MIXED&&V.style!==be.Styles.MIXED_OPEN_END||bt)i.beginPath(),V.style===be.Styles.BRACKET_OPEN_BEGIN||V.style===be.Styles.BRACKET_OPEN_BOTH?i.moveTo(at+Mt,pt):(this.ChangeBegin&&(at+=5),i.moveTo(at,pt-V.render_options.bracket_height),this.ChangeBegin&&(at+=5),i.lineTo(at+Mt,pt)),i.stroke(),i.closePath();else if(V.custom_depress_text){const _t=i.measureText(V.custom_depress_text).width;i.fillText(V.custom_depress_text,at-_t/2,pt),Mt=_t/2+V.render_options.text_margin_right}else Or("pedal_depress",i,at,pt,V.render_options.glyph_point_size),Mt=20+V.render_options.text_margin_right;else Mt=gt&&!this.EndsStave?-5:0,i.beginPath(),i.moveTo(c,M),i.lineTo(at+Mt,pt),V.style!==be.Styles.BRACKET_OPEN_END&&V.style!==be.Styles.MIXED_OPEN_END&&V.style!==be.Styles.BRACKET_OPEN_BOTH&&(this.ChangeEnd&&(at+=5),i.lineTo(at,pt-V.render_options.bracket_height)),i.stroke(),i.closePath();c=at+Mt,M=pt})}drawText(){const i=this.context;let c=!1;const M=this,I=M.render_options.glyph_point_size;this.notes.forEach(V=>{if(!V)return;c=!c;const X=V.getStave(),Z=V.getAbsoluteX(),nt=X.getYForBottomText(M.line+3);let at=0;c?M.custom_depress_text?(at=i.measureText(M.custom_depress_text).width,i.fillText(M.custom_depress_text,Z-at/2,nt)):Or("pedal_depress",i,Z,nt,I):M.custom_release_text?(at=i.measureText(M.custom_release_text).width,i.fillText(M.custom_release_text,Z-at/2,nt)):Or("pedal_release",i,Z,nt,I)})}draw(){const i=this.checkContext();this.setRendered(),i.save(),i.setStrokeStyle(this.render_options.color),i.setFillStyle(this.render_options.color),i.setFont(this.font.family,this.font.size,this.font.weight),be.DEBUG&&d.L("Vex.Flow.PedalMarking",["Rendering Pedal Marking"]),this.style===be.Styles.BRACKET||this.style===be.Styles.MIXED||this.style===be.Styles.MIXED_OPEN_END||this.style===be.Styles.BRACKET_OPEN_BEGIN||this.style===be.Styles.BRACKET_OPEN_END||this.style===be.Styles.BRACKET_OPEN_BOTH?(i.setLineWidth(this.render_options.bracket_line_width),this.drawBracketed()):this.style===be.Styles.TEXT&&this.drawText(),i.restore()}}class di extends h{static get Positions(){return{TOP:1,BOTTOM:-1}}static get PositionString(){return{top:di.Positions.TOP,bottom:di.Positions.BOTTOM}}constructor({start:i,stop:c,text:M="",superscript:I="",position:V=di.Positions.TOP}){super(),this.setAttribute("type","TextBracket"),this.start=i,this.stop=c,this.text=M,this.superscript=I,this.position=typeof V=="string"?di.PositionString[V]:V,this.line=1,this.font={family:"Serif",size:15,weight:"italic"},this.render_options={dashed:!0,dash:[5],color:"black",line_width:1,show_bracket:!0,bracket_height:8,underline_superscript:!0}}applyStyle(i){return i.setFont(this.font.family,this.font.size,this.font.weight),i.setStrokeStyle(this.render_options.color),i.setFillStyle(this.render_options.color),i.setLineWidth(this.render_options.line_width),this}setDashed(i,c){return this.render_options.dashed=i,c&&(this.render_options.dash=c),this}setFont(i){return this.font={...this.font,...i},this}setLine(i){return this.line=i,this}draw(){const i=this.context;this.setRendered();let c=0;switch(this.position){case di.Positions.TOP:c=this.start.getStave().getYForTopText(this.line);break;case di.Positions.BOTTOM:c=this.start.getStave().getYForBottomText(this.line+v.TEXT_HEIGHT_OFFSET_HACK);break;default:throw new d.RERR("InvalidPosition",`The position ${this.position} is invalid`)}const M={x:this.start.getAbsoluteX(),y:c},I={x:this.stop.getAbsoluteX(),y:c};(function(...Mt){di.DEBUG&&d.L("Vex.Flow.TextBracket",Mt)})("Rendering TextBracket: start:",M,"stop:",I,"y:",c);const V=this.render_options.bracket_height*this.position;i.save(),this.applyStyle(i),i.fillText(this.text,M.x,M.y);let X=i.measureText(this.text).width;X>0||(X=10*this.text.length);let Z=i.measureText("M").width;Z>0||(Z=20);const nt=M.y-Z/2.5;i.setFont(this.font.family,this.font.size/1.4,this.font.weight),i.fillText(this.superscript,M.x+X+1,nt);let at=i.measureText(this.superscript).width;at>0||(at=12,this.superscript.includes("m")&&(at+=5));let ft=i.measureText("M").width;ft>0||(ft=10);let pt=M.x,gt=nt,bt=I.x+this.stop.getGlyph().getWidth();this.position===di.Positions.TOP?(pt+=X+at+5,gt-=ft/2.7):this.position===di.Positions.BOTTOM&&(gt+=ft/2.7,pt+=X+2,this.render_options.underline_superscript||(pt+=at)),this.render_options.dashed?(bt0||c===!0;return!c||V>0||(this.pos=I),Z?this.matchSuccess():this.matchFail(I),{success:Z,results:M,numMatches:V}}expectZeroOrMore(i){return this.expectOneOrMore(i,!0)}expect(i){let c;if((function(...I){Ze.DEBUG&&d.L("Vex.Flow.Parser",I)})("Evaluating rules:",i),!i)throw new Dr("Invalid Rule: "+i,i);const M=i.bind(this.grammar)();if(M.token)c=this.matchToken(M.token,M.noSpace===!0),c.success&&(this.pos+=c.incrementPos);else{if(!M.expect)throw new Dr("Bad grammar! No `token` or `expect` property",M);c=M.oneOrMore?this.expectOneOrMore(M):M.zeroOrMore?this.expectZeroOrMore(M):this.expectOne(M)}return c.matches=[],c.results&&c.results.forEach(I=>c.matches.push(Ri(I))),M.run&&c.success&&M.run(c),c}}function We(...vt){Pn.DEBUG&&d.L("Vex.Flow.EasyScore",vt)}const Wn=d.MakeException("EasyScoreError");class Po{constructor(i){this.builder=i}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:i=>this.builder.addChord(i.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:i=>this.builder.addSingleNote(i.matches[0],i.matches[1],i.matches[2])}}ACCIDENTAL(){return{expect:[this.ACCIDENTALS],maybe:!0}}DOTS(){return{expect:[this.DOT],zeroOrMore:!0,run:i=>this.builder.setNoteDots(i.matches[0])}}TYPE(){return{expect:[this.SLASH,this.MAYBESLASH,this.TYPES],maybe:!0,run:i=>this.builder.setNoteType(i.matches[2])}}DURATION(){return{expect:[this.SLASH,this.DURATIONS],maybe:!0,run:i=>this.builder.setNoteDuration(i.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:i=>this.builder.addNoteOption(i.matches[0],i.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:"bbs|bb|bss|bs|b|db|d|##|#|n|\\+\\+-|\\+-|\\+\\+|\\+|k|o"}}DURATIONS(){return{token:"[0-9whq]+"}}TYPES(){return{token:"[rRsSxX]"}}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 Ka{constructor(i){this.factory=i,this.commitHooks=[],this.reset()}reset(i={}){this.options={stem:"auto",clef:"treble"},this.elements={notes:[],accidentals:[]},this.rollingDuration="8",this.resetPiece(),Object.assign(this.options,i)}getFactory(){return this.factory}getElements(){return this.elements}addCommitHook(i){this.commitHooks.push(i)}resetPiece(){We("resetPiece"),this.piece={chord:[],duration:this.rollingDuration,dots:0,type:void 0,options:{}}}setNoteDots(i){We("setNoteDots:",i),i&&(this.piece.dots=i.length)}setNoteDuration(i){We("setNoteDuration:",i),this.rollingDuration=this.piece.duration=i||this.rollingDuration}setNoteType(i){We("setNoteType:",i),i&&(this.piece.type=i)}addNoteOption(i,c){We("addNoteOption: key:",i,"value:",c),this.piece.options[i]=c}addNote(i,c,M){We("addNote:",i,c,M),this.piece.chord.push({key:i,accid:c,octave:M})}addSingleNote(i,c,M){We("addSingleNote:",i,c,M),this.addNote(i,c,M)}addChord(i){We("startChord"),typeof i[0]!="object"?this.addSingleNote(i[0]):i.forEach(c=>{c&&this.addNote(...c)}),We("endChord")}commitPiece(){We("commitPiece");const{factory:i}=this;if(!i)return;const c={...this.options,...this.piece.options},{stem:M,clef:I}=c,V=M.toLowerCase()==="auto",X=V||M.toLowerCase()!=="up"?ct.STEM_DOWN:ct.STEM_UP,{chord:Z,duration:nt,dots:at,type:ft}=this.piece,pt=Z.map(Mt=>Mt.key+"/"+Mt.octave),gt=i.StaveNote({keys:pt,duration:nt,dots:at,type:ft,clef:I,auto_stem:V});V||gt.setStemDirection(X);const bt=Z.map(Mt=>Mt.accid||null);bt.forEach((Mt,_t)=>{Mt&>.addAccidental(_t,i.Accidental({type:Mt}))});for(let Mt=0;MtMt(c,gt,this)),this.elements.notes.push(gt),this.elements.accidentals.concat(bt),this.resetPiece()}}function Qa({id:vt},i){vt!==void 0&&i.setAttribute("id",vt)}function Co(vt,i){vt.class&&vt.class.split(/\s*,\s*/).forEach(c=>i.addClass(c))}class Pn{constructor(i={}){this.setOptions(i),this.defaults={clef:"treble",time:"4/4",stem:"auto"}}set(i){return Object.assign(this.defaults,i),this}setOptions(i){return this.options={factory:null,builder:null,commitHooks:[Qa,Co,Nt.easyScoreHook],throwOnError:!1,...i},this.factory=this.options.factory,this.builder=this.options.builder||new Ka(this.factory),this.grammar=new Po(this.builder),this.parser=new Ze(this.grammar),this.options.commitHooks.forEach(c=>this.addCommitHook(c)),this}setContext(i){return this.factory&&this.factory.setContext(i),this}parse(i,c={}){this.builder.reset(c);const M=this.parser.parse(i);if(!M.success&&this.options.throwOnError)throw new Wn("Error parsing line: "+i,M);return M}beam(i,c={}){return this.factory.Beam({notes:i,options:c}),i}tuplet(i,c={}){return this.factory.Tuplet({notes:i,options:c}),i}notes(i,c={}){return c={clef:this.defaults.clef,stem:this.defaults.stem,...c},this.parse(i,c),this.builder.getElements().notes}voice(i,c){return c={time:this.defaults.time,...c},this.factory.Voice(c).addTickables(i)}addCommitHook(i){return this.builder.addCommitHook(i)}}const Js=d.MakeException("FactoryError");function Fe(vt={},i){const c=i.options;return(vt=Object.assign(i,vt)).options=Object.assign(c,vt.options),vt}class Fi{constructor(i){(function(...M){Fi.DEBUG&&d.L("Vex.Flow.Factory",M)})("New factory: ",i);const c={stave:{space:10},renderer:{context:null,elementId:"",backend:_.Backends.SVG,width:500,height:200,background:"#FFF"},font:{face:"Arial",point:10,style:""}};this.options=c,this.setOptions(i)}static newFromElementId(i,c=500,M=200){return new Fi({renderer:{elementId:i,width:c,height:M}})}reset(){this.renderQ=[],this.systems=[],this.staves=[],this.voices=[],this.stave=null}getOptions(){return this.options}setOptions(i){for(const c of["stave","renderer","font"])Object.assign(this.options[c],i[c]);(this.options.renderer.elementId!==null||this.options.renderer.context)&&this.initRenderer(),this.reset()}initRenderer(){const{elementId:i,backend:c,width:M,height:I,background:V}=this.options.renderer;if(i==="")throw new Js("HTML DOM element not set in Factory");this.context=_.buildContext(i,c,M,I,V)}getContext(){return this.context}setContext(i){return this.context=i,this}getStave(){return this.stave}getVoices(){return this.voices}space(i){return this.options.stave.space*i}Stave(i){i=Fe(i,{x:0,y:0,width:this.options.renderer.width-this.space(1),options:{spacing_between_lines_px:this.options.stave.space}});const c=new Ce(i.x,i.y,i.width,i.options);return this.staves.push(c),c.setContext(this.context),this.stave=c,c}TabStave(i){i=Fe(i,{x:0,y:0,width:this.options.renderer.width-this.space(1),options:{spacing_between_lines_px:1.3*this.options.stave.space}});const c=new Re(i.x,i.y,i.width,i.options);return this.staves.push(c),c.setContext(this.context),this.stave=c,c}StaveNote(i){const c=new ct(i);return this.stave&&c.setStave(this.stave),c.setContext(this.context),this.renderQ.push(c),c}GhostNote(i){const c=new Qs(i);return this.stave&&c.setStave(this.stave),c.setContext(this.context),this.renderQ.push(c),c}TextNote(i){const c=new Xe(i);return this.stave&&c.setStave(this.stave),c.setContext(this.context),this.renderQ.push(c),c}BarNote(i){i=Fe(i,{type:"single",options:{}});const c=new Ls(i.type);return this.stave&&c.setStave(this.stave),c.setContext(this.context),this.renderQ.push(c),c}ClefNote(i){i=Fe(i,{type:"treble",options:{size:"default"}});const c=new nn(i.type,i.options.size,i.options.annotation);return this.stave&&c.setStave(this.stave),c.setContext(this.context),this.renderQ.push(c),c}TimeSigNote(i){i=Fe(i,{time:"4/4",options:{}});const c=new ws(i.time);return this.stave&&c.setStave(this.stave),c.setContext(this.context),this.renderQ.push(c),c}KeySigNote(i){const c=new _s(i.key,i.cancelKey,i.alterKey);return this.stave&&c.setStave(this.stave),c.setContext(this.context),this.renderQ.push(c),c}TabNote(i){const c=new He(i);return this.stave&&c.setStave(this.stave),c.setContext(this.context),this.renderQ.push(c),c}GraceNote(i){const c=new Yi(i);return this.stave&&c.setStave(this.stave),c.setContext(this.context),c}GraceNoteGroup(i){const c=new J(i.notes,i.slur);return c.setContext(this.context),c}Accidental(i){i=Fe(i,{type:null,options:{}});const c=new O(i.type);return c.setContext(this.context),c}Annotation(i){i=Fe(i,{text:"p",vJustify:"below",hJustify:"center",fontFamily:"Times",fontSize:14,fontWeight:"bold italic",options:{}});const c=new Ct(i.text);return c.setJustification(i.hJustify),c.setVerticalJustification(i.vJustify),c.setFont(i.fontFamily,i.fontSize,i.fontWeight),c.setContext(this.context),c}Articulation(i){i=Fe(i,{type:"a.",position:"above",options:{}});const c=new Nt(i.type);return c.setPosition(i.position),c.setContext(this.context),c}TextDynamics(i){i=Fe(i,{text:"p",duration:"q",dots:0,line:0,options:{}});const c=new An({text:i.text,line:i.line,duration:i.duration,dots:i.dots});return this.stave&&c.setStave(this.stave),c.setContext(this.context),this.renderQ.push(c),c}Fingering(i){i=Fe(i,{number:"0",position:"left",options:{}});const c=new st(i.number);return c.setPosition(i.position),c.setContext(this.context),c}StringNumber(i){i=Fe(i,{number:"0",position:"left",options:{}});const c=new et(i.number);return c.setPosition(i.position),c.setContext(this.context),c}TickContext(){return new it().setContext(this.context)}ModifierContext(){return new Kt}MultiMeasureRest(i){const c=new Ts(i.number_of_measures,i);return c.setContext(this.context),this.renderQ.push(c),c}Voice(i){i=Fe(i,{time:"4/4",options:{}});const c=new U(i.time);return this.voices.push(c),c}StaveConnector(i){i=Fe(i,{top_stave:null,bottom_stave:null,type:"double",options:{}});const c=new z(i.top_stave,i.bottom_stave);return c.setType(i.type).setContext(this.context),this.renderQ.push(c),c}Formatter(){return new $t}Tuplet(i){i=Fe(i,{notes:[],options:{}});const c=new k(i.notes,i.options).setContext(this.context);return this.renderQ.push(c),c}Beam(i){i=Fe(i,{notes:[],options:{autoStem:!1,secondaryBeamBreaks:[]}});const c=new G(i.notes,i.options.autoStem).setContext(this.context);return c.breakSecondaryAt(i.options.secondaryBeamBreaks),this.renderQ.push(c),c}Curve(i){i=Fe(i,{from:null,to:null,options:{}});const c=new Ci(i.from,i.to,i.options).setContext(this.context);return this.renderQ.push(c),c}StaveTie(i){i=Fe(i,{from:null,to:null,first_indices:[0],last_indices:[0],text:null,options:{direction:void 0}});const c=new j({first_note:i.from,last_note:i.to,first_indices:i.first_indices,last_indices:i.last_indices},i.text);return i.options.direction&&c.setDirection(i.options.direction),c.setContext(this.context),this.renderQ.push(c),c}StaveLine(i){i=Fe(i,{from:null,to:null,first_indices:[0],last_indices:[0],options:{}});const c=new yi({first_note:i.from,last_note:i.to,first_indices:i.first_indices,last_indices:i.last_indices});return i.options.text&&c.setText(i.options.text),i.options.font&&c.setFont(i.options.font),c.setContext(this.context),this.renderQ.push(c),c}VibratoBracket(i){i=Fe(i,{from:null,to:null,options:{harsh:!1}});const c=new Te({start:i.from,stop:i.to});return i.options.line&&c.setLine(i.options.line),i.options.harsh&&c.setHarsh(i.options.harsh),c.setContext(this.context),this.renderQ.push(c),c}TextBracket(i){i=Fe(i,{from:null,to:null,text:"",options:{superscript:"",position:1}});const c=new di({start:i.from,stop:i.to,text:i.text,superscript:i.options.superscript,position:i.options.position});return i.options.line&&c.setLine(i.options.line),i.options.font&&c.setFont(i.options.font),c.setContext(this.context),this.renderQ.push(c),c}System(i={}){i.factory=this;const c=new jn(i).setContext(this.context);return this.systems.push(c),c}EasyScore(i={}){return i.factory=this,new Pn(i)}PedalMarking(i={}){i=Fe(i,{notes:[],options:{style:"mixed"}});const c=new be(i.notes);return c.setStyle(be.StylesString[i.options.style]),c.setContext(this.context),this.renderQ.push(c),c}NoteSubGroup(i={}){i=Fe(i,{notes:[],options:{}});const c=new D(i.notes);return c.setContext(this.context),c}draw(){this.systems.forEach(i=>i.setContext(this.context).format()),this.staves.forEach(i=>i.setContext(this.context).draw()),this.voices.forEach(i=>i.setContext(this.context).draw()),this.renderQ.forEach(i=>{i.isRendered()||i.setContext(this.context).draw()}),this.systems.forEach(i=>i.setContext(this.context).draw()),this.reset()}}function Cn(vt,i){const c=i.options;return(vt=Object.assign(i,vt)).options=Object.assign(c,vt.options),vt}class jn extends h{constructor(i={}){super(),this.setAttribute("type","System"),this.setOptions(i),this.parts=[]}setOptions(i={}){this.options=Cn(i,{x:10,y:10,width:500,connector:null,spaceBetweenStaves:12,factory:null,debugFormatter:!1,formatIterations:0,options:{}}),this.factory=this.options.factory||new Fi({renderer:{el:null}})}setContext(i){return super.setContext(i),this.factory.setContext(i),this}addConnector(i="double"){return this.connector=this.factory.StaveConnector({top_stave:this.parts[0].stave,bottom_stave:this.parts[this.parts.length-1].stave,type:i}),this.connector}addStave(i){return(i=Cn(i,{stave:null,voices:[],spaceAbove:0,spaceBelow:0,debugNoteMetrics:!1,options:{left_bar:!1}})).stave||(i.stave=this.factory.Stave({x:this.options.x,y:this.options.y,width:this.options.width,options:i.options})),i.voices.forEach(c=>c.setContext(this.context).setStave(i.stave).getTickables().forEach(M=>M.setStave(i.stave))),this.parts.push(i),i.stave}format(){const i=new $t;this.formatter=i;let c=this.options.y,M=0,I=[];const V=[];this.parts.forEach(Z=>{c+=Z.stave.space(Z.spaceAbove),Z.stave.setY(c),i.joinVoices(Z.voices),c+=Z.stave.space(Z.spaceBelow),c+=Z.stave.space(this.options.spaceBetweenStaves),Z.debugNoteMetrics&&(V.push({y:c,voice:Z.voices[0]}),c+=15),I=I.concat(Z.voices),M=Math.max(M,Z.stave.getNoteStartX())}),this.parts.forEach(Z=>Z.stave.setNoteStartX(M));const X=this.options.width-(M-this.options.x)-$.STAVEPADDING;i.format(I,X);for(let Z=0;Z{c.voice.getTickables().forEach(M=>$.plotMetrics(i,M,c.y))})}}(d.Flow=v).Element=h,d.Flow.Fraction=l,d.Flow.Renderer=_,d.Flow.Formatter=$t,d.Flow.Music=ot,d.Flow.Glyph=S,d.Flow.Stave=Ce,d.Flow.StaveNote=ct,d.Flow.StaveModifier=ie,d.Flow.StaveTempo=De,d.Flow.Voice=U,d.Flow.Accidental=O,d.Flow.Beam=G,d.Flow.StaveTie=j,d.Flow.TabStave=Re,d.Flow.TabNote=He,d.Flow.Bend=zt,d.Flow.Vibrato=Xt,d.Flow.VibratoBracket=Te,d.Flow.Note=$,d.Flow.ModifierContext=Kt,d.Flow.MultiMeasureRest=Ts,d.Flow.TickContext=it,d.Flow.Articulation=Nt,d.Flow.Annotation=Ct,d.Flow.Barline=Jt,d.Flow.NoteHead=N,d.Flow.StaveConnector=z,d.Flow.ClefNote=nn,d.Flow.KeySignature=we,d.Flow.KeySigNote=_s,d.Flow.TimeSignature=Ge,d.Flow.TimeSigNote=ws,d.Flow.Stem=B,d.Flow.TabTie=Q,d.Flow.Clef=ai,d.Flow.Dot=H,d.Flow.Modifier=tt,d.Flow.TabSlide=Mi,d.Flow.Tuplet=k,d.Flow.GraceNote=Yi,d.Flow.GraceTabNote=sn,d.Flow.Tuning=Ln,d.Flow.KeyManager=class{constructor(vt){this.music=new ot,this.setKey(vt)}setKey(vt){return this.key=vt,this.reset(),this}getKey(){return this.key}reset(){if(this.keyParts=this.music.getKeyParts(this.key),this.keyString=this.keyParts.root,this.keyParts.accidental&&(this.keyString+=this.keyParts.accidental),!ot.scaleTypes[this.keyParts.type])throw new d.RERR("BadArguments",`Unsupported key type: ${this.key}`);this.scale=this.music.getScaleTones(this.music.getNoteValue(this.keyString),ot.scaleTypes[this.keyParts.type]),this.scaleMap={},this.scaleMapByValue={},this.originalScaleMapByValue={};const vt=ot.root_indices[this.keyParts.root];for(let i=0;i{for(var p in y)le.o(y,p)&&!le.o(St,p)&&Object.defineProperty(St,p,{enumerable:!0,get:y[p]})},le.g=(function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}})(),le.o=(St,y)=>Object.prototype.hasOwnProperty.call(St,y),le.r=St=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(St,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(St,"__esModule",{value:!0})},le(8156)})())})(qo)),qo.exports}var V2=k2();const G2=({xmlContent:Wt,hasMelody:Jt})=>{const se=Ve.useRef(null),Lt=Ve.useRef(null);return Ve.useEffect(()=>{!se.current||!Wt||(Lt.current||(Lt.current=new V2.OpenSheetMusicDisplay(se.current,{autoResize:!0,backend:"svg",drawTitle:!0,drawSubtitle:!1,drawComposer:!0,drawCredits:!1,drawPartNames:!0,drawingParameters:"compacttight"})),Lt.current.load(Wt).then(()=>{var le;(le=Lt.current)==null||le.render()}).catch(le=>{console.error("OSMD render error:",le)}))},[Wt]),Gt.jsxs("div",{className:"bg-white rounded-xl shadow-sm border border-slate-200 p-6 overflow-x-auto",children:[Gt.jsxs("div",{className:"flex items-center justify-between mb-4 pb-2 border-b border-slate-100",children:[Gt.jsxs("div",{className:"flex items-center gap-2",children:[Gt.jsx("h3",{className:"text-base font-semibold text-slate-800",children:Jt?"Lead Sheet & Companion Score (Melody + 3rds & 7ths)":"Voice-Led Companion Score (3rds & 7ths)"}),Jt&&Gt.jsx("span",{className:"px-2 py-0.5 rounded text-[11px] font-semibold bg-emerald-50 text-emerald-700 border border-emerald-200",children:"Dual Staff System"})]}),Gt.jsx("span",{className:"text-xs text-slate-500",children:"Rendered via in-browser SVG"})]}),Gt.jsx("div",{ref:se,className:"w-full min-w-[600px]"})]})};/** +`}},Lt={};function ae(St){var y=Lt[St];if(y!==void 0)return y.exports;var p=Lt[St]={exports:{}};return re[St].call(p.exports,p,p.exports,ae),p.exports}return ae.d=(St,y)=>{for(var p in y)ae.o(y,p)&&!ae.o(St,p)&&Object.defineProperty(St,p,{enumerable:!0,get:y[p]})},ae.g=(function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}})(),ae.o=(St,y)=>Object.prototype.hasOwnProperty.call(St,y),ae.r=St=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(St,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(St,"__esModule",{value:!0})},ae(8156)})())})(qa)),qa.exports}var V2=k2();const G2=({xmlContent:Ht,hasMelody:te})=>{const re=Ve.useRef(null),Lt=Ve.useRef(null);return Ve.useEffect(()=>{if(!(!re.current||!Ht)){Lt.current||(Lt.current=new V2.OpenSheetMusicDisplay(re.current,{autoResize:!0,backend:"svg",drawTitle:!0,drawSubtitle:!1,drawComposer:!0,drawCredits:!1,drawPartNames:!0,drawingParameters:"compacttight"}));try{Lt.current.clear(),Lt.current.load(Ht).then(()=>{var ae;(ae=Lt.current)==null||ae.render()}).catch(ae=>{console.error("OSMD render error:",ae)})}catch(ae){console.error("OSMD load error:",ae)}}},[Ht]),Gt.jsxs("div",{className:"bg-white rounded-xl shadow-sm border border-slate-200 p-6 overflow-x-auto",children:[Gt.jsxs("div",{className:"flex items-center justify-between mb-4 pb-2 border-b border-slate-100",children:[Gt.jsxs("div",{className:"flex items-center gap-2",children:[Gt.jsx("h3",{className:"text-base font-semibold text-slate-800",children:te?"Lead Sheet & Companion Score (Melody + 3rds & 7ths)":"Voice-Led Companion Score (3rds & 7ths)"}),te&&Gt.jsx("span",{className:"px-2 py-0.5 rounded text-[11px] font-semibold bg-emerald-50 text-emerald-700 border border-emerald-200",children:"Dual Staff System"})]}),Gt.jsx("span",{className:"text-xs text-slate-500",children:"Rendered via in-browser SVG"})]}),Gt.jsx("div",{ref:re,className:"w-full min-w-[600px]"})]})};/** * @license lucide-react v1.47.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const z2=Wt=>Wt==null?void 0:Wt.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/** + */const z2=Ht=>Ht==null?void 0:Ht.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/** * @license lucide-react v1.47.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */function U2(Wt,Jt,se=[]){if(Jt==null)throw new Error("[lucide]: iconNode is required when icon name is used");return{name:z2(Wt),size:24,node:Jt,...se.length>0?{aliases:se}:{}}}/** + */function U2(Ht,te,re=[]){if(te==null)throw new Error("[lucide]: iconNode is required when icon name is used");return{name:z2(Ht),size:24,node:te,...re.length>0?{aliases:re}:{}}}/** * @license lucide-react v1.47.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const H2=Wt=>{let Jt="",se=!1;for(const Lt of Wt){if(Lt==="-"||Lt==="_"||Lt<=" "){se=Jt.length>0;continue}Jt.length===0?Jt+=Lt.toLowerCase():Jt+=se?Lt.toUpperCase():Lt,se=!1}return Jt};/** + */const H2=Ht=>{let te="",re=!1;for(const Lt of Ht){if(Lt==="-"||Lt==="_"||Lt<=" "){re=te.length>0;continue}te.length===0?te+=Lt.toLowerCase():te+=re?Lt.toUpperCase():Lt,re=!1}return te};/** * @license lucide-react v1.47.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const W2=Wt=>{const Jt=H2(Wt);return Jt.charAt(0).toUpperCase()+Jt.slice(1)};/** + */const W2=Ht=>{const te=H2(Ht);return te.charAt(0).toUpperCase()+te.slice(1)};/** * @license lucide-react v1.47.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const Mh=(...Wt)=>Wt.filter((Jt,se,Lt)=>!!Jt&&Jt.trim()!==""&&Lt.indexOf(Jt)===se).join(" ").trim();/** + */const Mh=(...Ht)=>Ht.filter((te,re,Lt)=>!!te&&te.trim()!==""&&Lt.indexOf(te)===re).join(" ").trim();/** * @license lucide-react v1.47.0 - ISC * * This source code is licensed under the ISC license. @@ -159,22 +159,22 @@ void main() { * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */function Eh(Wt){return Wt!=null}function j2(Wt,Jt={}){var s,h;const se=Jt.attributeNames??{},Lt=u=>se[u]??u,le=Wt.size??Wt.width??qs.width,St=Wt.size??Wt.height??qs.height,y=((s=Wt.aliases)==null?void 0:s.filter(u=>typeof u=="string"&&u.trim()!=="").map(u=>`lucide-${u}`))??[],p=[...Wt.name?[`lucide-${Wt.name}`]:[],...y],d=((h=Jt.className)==null?void 0:h.split(" ").filter(Boolean))??[],l=Jt.includeDefaultClasses===!1?Mh(...d):Mh("lucide",...p,...d),m=Jt.absoluteStrokeWidth?Number(Jt.strokeWidth??qs["stroke-width"])*Number(Wt.size??Wt.width??qs.width)/Number(Jt.size??Jt.width??qs.width):Jt.strokeWidth??qs["stroke-width"];return["svg",{...Object.entries(qs).reduce((u,[f,r])=>(u[Lt(f)]=r,u),{}),..."color"in Jt&&Jt.color&&{[Lt("stroke")]:Jt.color},..."size"in Jt&&Eh(Jt.size)&&{[Lt("width")]:Jt.size,[Lt("height")]:Jt.size},..."width"in Jt&&Eh(Jt.width)&&{[Lt("width")]:Jt.width},..."height"in Jt&&Eh(Jt.height)&&{[Lt("height")]:Jt.height},[Lt("stroke-width")]:m,...l&&{[Lt("class")]:l},[Lt("viewBox")]:`0 0 ${le} ${St}`,...Jt.hasA11yProp===!1?{[Lt("aria-hidden")]:"true"}:{},..."attributes"in Jt&&Jt.attributes},Wt.node.map(u=>{const[f,r,b]=u,S=Jt.nonScalingStroke?{[Lt("vector-effect")]:"non-scaling-stroke",...r}:r;return b?[f,S,b]:[f,S]})]}/** + */function Eh(Ht){return Ht!=null}function j2(Ht,te={}){var s,h;const re=te.attributeNames??{},Lt=u=>re[u]??u,ae=Ht.size??Ht.width??qs.width,St=Ht.size??Ht.height??qs.height,y=((s=Ht.aliases)==null?void 0:s.filter(u=>typeof u=="string"&&u.trim()!=="").map(u=>`lucide-${u}`))??[],p=[...Ht.name?[`lucide-${Ht.name}`]:[],...y],d=((h=te.className)==null?void 0:h.split(" ").filter(Boolean))??[],l=te.includeDefaultClasses===!1?Mh(...d):Mh("lucide",...p,...d),m=te.absoluteStrokeWidth?Number(te.strokeWidth??qs["stroke-width"])*Number(Ht.size??Ht.width??qs.width)/Number(te.size??te.width??qs.width):te.strokeWidth??qs["stroke-width"];return["svg",{...Object.entries(qs).reduce((u,[f,r])=>(u[Lt(f)]=r,u),{}),..."color"in te&&te.color&&{[Lt("stroke")]:te.color},..."size"in te&&Eh(te.size)&&{[Lt("width")]:te.size,[Lt("height")]:te.size},..."width"in te&&Eh(te.width)&&{[Lt("width")]:te.width},..."height"in te&&Eh(te.height)&&{[Lt("height")]:te.height},[Lt("stroke-width")]:m,...l&&{[Lt("class")]:l},[Lt("viewBox")]:`0 0 ${ae} ${St}`,...te.hasA11yProp===!1?{[Lt("aria-hidden")]:"true"}:{},..."attributes"in te&&te.attributes},Ht.node.map(u=>{const[f,r,b]=u,S=te.nonScalingStroke?{[Lt("vector-effect")]:"non-scaling-stroke",...r}:r;return b?[f,S,b]:[f,S]})]}/** * @license lucide-react v1.47.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */function X2(Wt,Jt={}){return j2(Wt,{...Jt,attributeNames:{...Jt.attributeNames,class:"className","stroke-width":"strokeWidth","stroke-linecap":"strokeLinecap","stroke-linejoin":"strokeLinejoin","vector-effect":"vectorEffect"}})}/** + */function X2(Ht,te={}){return j2(Ht,{...te,attributeNames:{...te.attributeNames,class:"className","stroke-width":"strokeWidth","stroke-linecap":"strokeLinecap","stroke-linejoin":"strokeLinejoin","vector-effect":"vectorEffect"}})}/** * @license lucide-react v1.47.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const Y2=Wt=>{for(const Jt in Wt)if(Jt.startsWith("aria-")||Jt==="role"||Jt==="title")return!0;return!1},q2=Ve.createContext({}),K2=()=>Ve.useContext(q2),Q2=Ve.forwardRef(({color:Wt,size:Jt,width:se,height:Lt,strokeWidth:le,absoluteStrokeWidth:St,nonScalingStroke:y,className:p="",children:d,iconNode:l=[],icon:m={node:l,aliases:[],size:24},...a},s)=>{const{size:h=24,strokeWidth:u=2,absoluteStrokeWidth:f=!1,nonScalingStroke:r=!1,color:b="currentColor",className:S=""}=K2()??{},v=!!d||Y2(a),[w,T,g=[]]=X2(m,{color:Wt??b,width:se??Jt??h,height:Lt??Jt??h,strokeWidth:le??u,absoluteStrokeWidth:St??f,nonScalingStroke:y??r,className:Mh(S,p),hasA11yProp:v,attributes:a});return Ve.createElement(w,{ref:s,...T},[...g.map(([x,P])=>Ve.createElement(x,P)),...Array.isArray(d)?d:[d]])});/** + */const Y2=Ht=>{for(const te in Ht)if(te.startsWith("aria-")||te==="role"||te==="title")return!0;return!1},q2=Ve.createContext({}),K2=()=>Ve.useContext(q2),Q2=Ve.forwardRef(({color:Ht,size:te,width:re,height:Lt,strokeWidth:ae,absoluteStrokeWidth:St,nonScalingStroke:y,className:p="",children:d,iconNode:l=[],icon:m={node:l,aliases:[],size:24},...o},s)=>{const{size:h=24,strokeWidth:u=2,absoluteStrokeWidth:f=!1,nonScalingStroke:r=!1,color:b="currentColor",className:S=""}=K2()??{},v=!!d||Y2(o),[w,T,g=[]]=X2(m,{color:Ht??b,width:re??te??h,height:Lt??te??h,strokeWidth:ae??u,absoluteStrokeWidth:St??f,nonScalingStroke:y??r,className:Mh(S,p),hasA11yProp:v,attributes:o});return Ve.createElement(w,{ref:s,...T},[...g.map(([x,P])=>Ve.createElement(x,P)),...Array.isArray(d)?d:[d]])});/** * @license lucide-react v1.47.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */function Ms(Wt,Jt=[],se=[]){const Lt=typeof Wt=="string"?U2(Wt,Jt,se):Wt,le=Ve.forwardRef(({className:St,...y},p)=>Ve.createElement(Q2,{ref:p,icon:Lt,className:St,...y}));return Lt.name&&(le.displayName=W2(Lt.name)),le}/** + */function Ms(Ht,te=[],re=[]){const Lt=typeof Ht=="string"?U2(Ht,te,re):Ht,ae=Ve.forwardRef(({className:St,...y},p)=>Ve.createElement(Q2,{ref:p,icon:Lt,className:St,...y}));return Lt.name&&(ae.displayName=W2(Lt.name)),ae}/** * @license lucide-react v1.47.0 - ISC * * This source code is licensed under the ISC license. @@ -214,4 +214,4 @@ void main() { * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const Y1={name:"upload",size:24,node:[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]};Y1.node;const F1=Ms(Y1),t0=["Autumn Leaves","Blue in Green","Giant Steps","Waltz for Debby","Donna Lee","A Night in Tunisia","Take Five","Jordu","All The Things You Are","Round Midnight"],e0=()=>{const[Wt,Jt]=Ve.useState([]),[se,Lt]=Ve.useState("search"),[le,St]=Ve.useState(""),[y,p]=Ve.useState([]),[d,l]=Ve.useState(null),[m,a]=Ve.useState(!1),[s,h]=Ve.useState("waltz_for_debby"),[u,f]=Ve.useState(""),[r,b]=Ve.useState(null),[S,v]=Ve.useState(!1),[w,T]=Ve.useState(null),[g,x]=Ve.useState(null),[P,_]=Ve.useState(null),[B,k]=Ve.useState(!1);Ve.useEffect(()=>{fetch("/api/samples").then(C=>C.ok?C.json():[]).then(C=>Jt(C)).catch(()=>{}),R({standard:"Autumn Leaves"})},[]),Ve.useEffect(()=>{if(!le.trim()){fetch("/api/standards?limit=12").then(z=>z.ok?z.json():[]).then(z=>p(z)).catch(()=>{});return}a(!0);const C=setTimeout(()=>{fetch(`/api/standards?q=${encodeURIComponent(le)}&limit=24`).then(z=>z.ok?z.json():[]).then(z=>{p(z),a(!1)}).catch(()=>a(!1))},150);return()=>clearTimeout(C)},[le]);const R=async C=>{v(!0),T(null);try{let z,W;if(C.file){const N=new FormData;N.append("file",C.file),z=await fetch("/api/analyze",{method:"POST",body:N});const Y=new FormData;Y.append("file",C.file),W=await fetch("/api/companion/xml",{method:"POST",body:Y})}else{const N=JSON.stringify({sample:C.sample,content:C.content,standard:C.standard});z=await fetch("/api/analyze",{method:"POST",headers:{"Content-Type":"application/json"},body:N}),W=await fetch("/api/companion/xml",{method:"POST",headers:{"Content-Type":"application/json"},body:N})}if(!z.ok){const N=await z.text();throw new Error(N||"Failed to analyze tune")}const $=await z.json();if(x($),W.ok){const N=await W.text();_(N)}else _(null)}catch(z){T(z.message||"An error occurred during analysis")}finally{v(!1)}},F=C=>{l(C),R({standard:C.title})},A=C=>{if(C.preventDefault(),se==="search")y.length>0?F(y[0]):le.trim()&&R({standard:le.trim()});else if(se==="sample")R({sample:s});else if(se==="text"){if(!u.trim()){T("Please enter an iReal Pro URL or MusicXML content.");return}R({content:u.trim()})}else if(se==="upload"){if(!r){T("Please select a MusicXML or iReal file to upload.");return}R({file:r})}},G=()=>{if(!P)return;const C=new Blob([P],{type:"application/vnd.recordare.musicxml+xml"}),z=URL.createObjectURL(C),W=document.createElement("a");W.href=z,W.download=`${((g==null?void 0:g.title)||"tune").replace(/\s+/g,"_")}_guide_tones.musicxml`,W.click(),URL.revokeObjectURL(z)},U=async()=>{if(g){k(!0);try{let C;if(se==="upload"&&r){const N=new FormData;N.append("file",r),C=await fetch("/api/companion/pdf",{method:"POST",body:N})}else{const N=JSON.stringify({sample:se==="sample"?s:void 0,content:se==="text"?u.trim():void 0,standard:se==="search"?(d==null?void 0:d.title)||g.title:void 0});C=await fetch("/api/companion/pdf",{method:"POST",headers:{"Content-Type":"application/json"},body:N})}if(!C.ok){const N=await C.text();throw new Error(N||"LilyPond compilation error. Ensure LilyPond is installed on the host.")}const z=await C.blob(),W=URL.createObjectURL(z),$=document.createElement("a");$.href=W,$.download=`${g.title.replace(/\s+/g,"_")}_guide_tones.pdf`,$.click(),URL.revokeObjectURL(W)}catch(C){alert(`PDF Error: ${C.message}`)}finally{k(!1)}}};return Gt.jsxs("div",{className:"min-h-screen bg-slate-50 text-slate-900 flex flex-col",children:[Gt.jsx("header",{className:"bg-white border-b border-slate-200 sticky top-0 z-20",children:Gt.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 h-16 flex items-center justify-between",children:[Gt.jsxs("div",{className:"flex items-center gap-3",children:[Gt.jsx("div",{className:"w-10 h-10 rounded-xl bg-gradient-to-tr from-blue-600 to-indigo-600 flex items-center justify-center text-white shadow-md shadow-blue-500/20",children:Gt.jsx($2,{className:"w-5 h-5"})}),Gt.jsxs("div",{children:[Gt.jsx("h1",{className:"text-lg font-bold tracking-tight text-slate-900 leading-none",children:"jazz-tools"}),Gt.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Harmonic Journey & Voice-Led Guide Tone Engine"})]})]}),Gt.jsx("div",{className:"flex items-center gap-3 text-xs",children:Gt.jsx("span",{className:"hidden sm:inline-flex items-center px-2.5 py-1 rounded-full bg-slate-100 text-slate-700 font-medium",children:"1,400 Standards • Web • LilyPond"})})]})}),Gt.jsxs("main",{className:"flex-1 max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8 w-full space-y-6",children:[Gt.jsxs("div",{className:"bg-white rounded-2xl shadow-sm border border-slate-200 overflow-hidden",children:[Gt.jsxs("div",{className:"flex border-b border-slate-200 bg-slate-50/75 overflow-x-auto",children:[Gt.jsxs("button",{onClick:()=>Lt("search"),className:`px-5 py-3 text-sm font-medium border-b-2 transition-colors flex items-center gap-2 whitespace-nowrap ${se==="search"?"border-blue-600 text-blue-600 bg-white":"border-transparent text-slate-600 hover:text-slate-900"}`,children:[Gt.jsx(D1,{className:"w-4 h-4"}),"Search Standards (1,400)"]}),Gt.jsxs("button",{onClick:()=>Lt("sample"),className:`px-5 py-3 text-sm font-medium border-b-2 transition-colors flex items-center gap-2 whitespace-nowrap ${se==="sample"?"border-blue-600 text-blue-600 bg-white":"border-transparent text-slate-600 hover:text-slate-900"}`,children:[Gt.jsx(xh,{className:"w-4 h-4"}),"Demo Tunes"]}),Gt.jsxs("button",{onClick:()=>Lt("text"),className:`px-5 py-3 text-sm font-medium border-b-2 transition-colors flex items-center gap-2 whitespace-nowrap ${se==="text"?"border-blue-600 text-blue-600 bg-white":"border-transparent text-slate-600 hover:text-slate-900"}`,children:[Gt.jsx(J2,{className:"w-4 h-4"}),"iReal URL / XML Text"]}),Gt.jsxs("button",{onClick:()=>Lt("upload"),className:`px-5 py-3 text-sm font-medium border-b-2 transition-colors flex items-center gap-2 whitespace-nowrap ${se==="upload"?"border-blue-600 text-blue-600 bg-white":"border-transparent text-slate-600 hover:text-slate-900"}`,children:[Gt.jsx(F1,{className:"w-4 h-4"}),"Upload File"]})]}),Gt.jsxs("form",{onSubmit:A,className:"p-6 space-y-4",children:[se==="search"&&Gt.jsxs("div",{className:"space-y-4",children:[Gt.jsxs("div",{className:"relative",children:[Gt.jsx(D1,{className:"w-5 h-5 absolute left-3.5 top-3.5 text-slate-400"}),Gt.jsx("input",{type:"text",value:le,onChange:C=>St(C.target.value),placeholder:"Search 1,400 jazz standards by title or composer (e.g. Autumn Leaves, Giant Steps, Bill Evans, Jobim)...",className:"w-full pl-11 pr-10 py-3 rounded-xl border border-slate-300 focus:ring-2 focus:ring-blue-500 focus:outline-none text-sm placeholder:text-slate-400 shadow-sm"}),m&&Gt.jsx(O1,{className:"w-4 h-4 animate-spin absolute right-3.5 top-3.5 text-slate-400"})]}),Gt.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:[Gt.jsx("span",{className:"text-xs font-semibold text-slate-400 uppercase tracking-wider mr-1",children:"Popular:"}),t0.map(C=>Gt.jsx("button",{type:"button",onClick:()=>{St(C),R({standard:C})},className:"px-2.5 py-1 rounded-lg bg-slate-100 hover:bg-slate-200 text-slate-700 text-xs font-medium transition-colors",children:C},C))]}),y.length>0&&Gt.jsxs("div",{className:"pt-2",children:[Gt.jsx("span",{className:"text-xs font-semibold text-slate-400 uppercase tracking-wider block mb-2",children:le?`Matching Standards (${y.length})`:"Catalog Preview"}),Gt.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-2.5 max-h-60 overflow-y-auto p-1 border border-slate-100 rounded-xl bg-slate-50/50",children:y.map(C=>{const z=(g==null?void 0:g.title.toLowerCase())===C.title.toLowerCase();return Gt.jsxs("button",{type:"button",onClick:()=>F(C),className:`p-2.5 rounded-xl text-left border transition-all flex items-center justify-between group ${z?"bg-blue-50 border-blue-300 shadow-xs":"bg-white hover:bg-blue-50/50 border-slate-200/80 hover:border-blue-200"}`,children:[Gt.jsxs("div",{className:"min-w-0 pr-2",children:[Gt.jsxs("div",{className:"flex items-center gap-1.5",children:[Gt.jsx("p",{className:`text-sm font-semibold truncate ${z?"text-blue-900":"text-slate-800"}`,children:C.title}),C.hasMelody&&Gt.jsx("span",{className:"px-1.5 py-0.2 rounded text-[10px] font-semibold bg-emerald-100 text-emerald-800 border border-emerald-200 flex-shrink-0",title:"Includes full melody staff",children:"🎵 Melody"})]}),Gt.jsx("p",{className:"text-xs text-slate-500 truncate",children:C.composer||"Jazz Standard"})]}),Gt.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[C.key&&Gt.jsx("span",{className:"px-2 py-0.5 rounded text-[11px] font-mono font-medium bg-slate-100 text-slate-600",children:C.key}),Gt.jsx(xh,{className:`w-3.5 h-3.5 opacity-0 group-hover:opacity-100 transition-opacity ${z?"opacity-100 text-blue-600":"text-slate-400"}`})]})]},C.id)})})]})]}),se==="sample"&&Gt.jsxs("div",{className:"flex flex-wrap gap-3 items-center",children:[Gt.jsx("span",{className:"text-xs font-semibold text-slate-500 uppercase",children:"Select Standard:"}),Wt.map(C=>Gt.jsxs("button",{type:"button",onClick:()=>{h(C.id),R({sample:C.id})},className:`px-4 py-2 rounded-xl text-sm font-medium transition-all flex items-center gap-2 ${s===C.id?"bg-blue-600 text-white shadow-sm":"bg-slate-100 hover:bg-slate-200 text-slate-800"}`,children:[Gt.jsx("span",{children:C.title}),Gt.jsxs("span",{className:"text-xs opacity-75",children:["by ",C.composer]})]},C.id))]}),se==="text"&&Gt.jsx("div",{className:"space-y-2",children:Gt.jsx("textarea",{value:u,onChange:C=>f(C.target.value),placeholder:"Paste an irealb:// link, playlist html, song name, or MusicXML score content...",rows:4,className:"w-full text-xs font-mono p-3 rounded-xl border border-slate-300 focus:ring-2 focus:ring-blue-500 focus:outline-none"})}),se==="upload"&&Gt.jsxs("div",{className:"border-2 border-dashed border-slate-300 rounded-xl p-6 text-center hover:bg-slate-50 transition-colors",children:[Gt.jsx("input",{type:"file",accept:".musicxml,.xml,.html,.htm",onChange:C=>{var z;return b(((z=C.target.files)==null?void 0:z[0])||null)},className:"hidden",id:"file-upload"}),Gt.jsxs("label",{htmlFor:"file-upload",className:"cursor-pointer block",children:[Gt.jsx(F1,{className:"w-8 h-8 mx-auto text-slate-400 mb-2"}),Gt.jsx("span",{className:"text-sm font-semibold text-blue-600 hover:underline",children:r?r.name:"Click to upload MusicXML or iReal file"}),Gt.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Supports .musicxml, .xml, .html"})]})]}),Gt.jsx("div",{className:"flex justify-end pt-2",children:Gt.jsx("button",{type:"submit",disabled:S,className:"px-6 py-2.5 bg-blue-600 hover:bg-blue-700 disabled:bg-blue-400 text-white rounded-xl font-medium text-sm shadow-sm transition-all flex items-center gap-2",children:S?Gt.jsxs(Gt.Fragment,{children:[Gt.jsx(O1,{className:"w-4 h-4 animate-spin"}),"Analyzing..."]}):Gt.jsxs(Gt.Fragment,{children:[Gt.jsx(xh,{className:"w-4 h-4 fill-white"}),"Analyze & Voice Lead"]})})})]})]}),w&&Gt.jsxs("div",{className:"bg-red-50 border border-red-200 text-red-700 p-4 rounded-xl flex items-start gap-3",children:[Gt.jsx(Z2,{className:"w-5 h-5 flex-shrink-0 text-red-500 mt-0.5"}),Gt.jsxs("div",{children:[Gt.jsx("p",{className:"text-sm font-semibold",children:"Error analyzing tune"}),Gt.jsx("p",{className:"text-xs mt-1 text-red-600",children:w})]})]}),g&&Gt.jsxs("div",{className:"space-y-6",children:[Gt.jsxs("div",{className:"bg-white rounded-2xl shadow-sm border border-slate-200 p-6 flex flex-col md:flex-row md:items-center justify-between gap-4",children:[Gt.jsxs("div",{children:[Gt.jsx("h2",{className:"text-2xl font-black tracking-tight text-slate-900",children:g.title}),g.composer&&Gt.jsxs("p",{className:"text-sm text-slate-500 mt-0.5",children:["by ",g.composer]}),Gt.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-3",children:[Gt.jsxs("span",{className:"px-2.5 py-1 rounded-md bg-slate-100 text-slate-700 text-xs font-semibold",children:["Key: ",g.key||"Modal/C"]}),Gt.jsxs("span",{className:"px-2.5 py-1 rounded-md bg-slate-100 text-slate-700 text-xs font-semibold",children:["Time: ",g.timeSignature[0],"/",g.timeSignature[1]]}),Gt.jsxs("span",{className:"px-2.5 py-1 rounded-md bg-slate-100 text-slate-700 text-xs font-semibold",children:[g.measureCount," Measures"]}),g.hasMelody?Gt.jsxs("span",{className:"px-2.5 py-1 rounded-md bg-emerald-100 text-emerald-800 text-xs font-semibold flex items-center gap-1 border border-emerald-200 shadow-xs",children:["🎵 Full Melody Included (",g.melodyNotesCount," notes)"]}):Gt.jsx("span",{className:"px-2.5 py-1 rounded-md bg-slate-100 text-slate-600 text-xs font-medium",children:"Chord Chart (Voice-Led Guide Tones)"})]})]}),Gt.jsxs("div",{className:"flex items-center gap-3",children:[Gt.jsxs("button",{onClick:G,disabled:!P,className:"px-4 py-2 border border-slate-300 hover:bg-slate-50 text-slate-700 rounded-xl text-xs font-semibold flex items-center gap-1.5 transition-colors",children:[Gt.jsx(B1,{className:"w-4 h-4 text-slate-500"}),"MusicXML"]}),Gt.jsxs("button",{onClick:U,disabled:B,className:"px-4 py-2 bg-slate-900 hover:bg-slate-800 text-white rounded-xl text-xs font-semibold flex items-center gap-1.5 shadow-sm transition-colors",children:[Gt.jsx(B1,{className:"w-4 h-4"}),B?"Compiling PDF...":"LilyPond PDF"]})]})]}),Gt.jsx(B2,{spans:g.journeySpans}),Gt.jsx(O2,{devices:g.devices}),P&&Gt.jsx(G2,{xmlContent:P,hasMelody:g.hasMelody}),Gt.jsx(D2,{measures:g.measures})]})]})]})};I2.createRoot(document.getElementById("root")).render(Gt.jsx(V1.StrictMode,{children:Gt.jsx(e0,{})})); + */const Y1={name:"upload",size:24,node:[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]};Y1.node;const F1=Ms(Y1),t0=["Autumn Leaves","Blue in Green","Giant Steps","Waltz for Debby","Donna Lee","A Night in Tunisia","Take Five","Jordu","All The Things You Are","Round Midnight"],e0=()=>{const[Ht,te]=Ve.useState([]),[re,Lt]=Ve.useState("search"),[ae,St]=Ve.useState(""),[y,p]=Ve.useState([]),[d,l]=Ve.useState(null),[m,o]=Ve.useState(!1),[s,h]=Ve.useState("waltz_for_debby"),[u,f]=Ve.useState(""),[r,b]=Ve.useState(null),[S,v]=Ve.useState(!1),[w,T]=Ve.useState(null),[g,x]=Ve.useState(null),[P,_]=Ve.useState(null),[B,k]=Ve.useState(!1);Ve.useEffect(()=>{fetch("/api/samples").then(C=>C.ok?C.json():[]).then(C=>te(C)).catch(()=>{}),R({standard:"Autumn Leaves"})},[]),Ve.useEffect(()=>{if(!ae.trim()){fetch("/api/standards?limit=12").then(z=>z.ok?z.json():[]).then(z=>p(z)).catch(()=>{});return}o(!0);const C=setTimeout(()=>{fetch(`/api/standards?q=${encodeURIComponent(ae)}&limit=24`).then(z=>z.ok?z.json():[]).then(z=>{p(z),o(!1)}).catch(()=>o(!1))},150);return()=>clearTimeout(C)},[ae]);const R=async C=>{v(!0),T(null);try{let z,W;if(C.file){const N=new FormData;N.append("file",C.file),z=await fetch("/api/analyze",{method:"POST",body:N});const Y=new FormData;Y.append("file",C.file),W=await fetch("/api/companion/xml",{method:"POST",body:Y})}else{const N=JSON.stringify({sample:C.sample,content:C.content,standard:C.standard});z=await fetch("/api/analyze",{method:"POST",headers:{"Content-Type":"application/json"},body:N}),W=await fetch("/api/companion/xml",{method:"POST",headers:{"Content-Type":"application/json"},body:N})}if(!z.ok){const N=await z.text();throw new Error(N||"Failed to analyze tune")}const $=await z.json();if(x($),W.ok){const N=await W.text();_(N)}else _(null)}catch(z){T(z.message||"An error occurred during analysis")}finally{v(!1)}},F=C=>{l(C),R({standard:C.title})},A=C=>{if(C.preventDefault(),re==="search")y.length>0?F(y[0]):ae.trim()&&R({standard:ae.trim()});else if(re==="sample")R({sample:s});else if(re==="text"){if(!u.trim()){T("Please enter an iReal Pro URL or MusicXML content.");return}R({content:u.trim()})}else if(re==="upload"){if(!r){T("Please select a MusicXML or iReal file to upload.");return}R({file:r})}},G=()=>{if(!P)return;const C=new Blob([P],{type:"application/vnd.recordare.musicxml+xml"}),z=URL.createObjectURL(C),W=document.createElement("a");W.href=z,W.download=`${((g==null?void 0:g.title)||"tune").replace(/\s+/g,"_")}_guide_tones.musicxml`,W.click(),URL.revokeObjectURL(z)},U=async()=>{if(g){k(!0);try{let C;if(re==="upload"&&r){const N=new FormData;N.append("file",r),C=await fetch("/api/companion/pdf",{method:"POST",body:N})}else{const N=JSON.stringify({sample:re==="sample"?s:void 0,content:re==="text"?u.trim():void 0,standard:re==="search"?(d==null?void 0:d.title)||g.title:void 0});C=await fetch("/api/companion/pdf",{method:"POST",headers:{"Content-Type":"application/json"},body:N})}if(!C.ok){const N=await C.text();throw new Error(N||"LilyPond compilation error. Ensure LilyPond is installed on the host.")}const z=await C.blob(),W=URL.createObjectURL(z),$=document.createElement("a");$.href=W,$.download=`${g.title.replace(/\s+/g,"_")}_guide_tones.pdf`,$.click(),URL.revokeObjectURL(W)}catch(C){alert(`PDF Error: ${C.message}`)}finally{k(!1)}}};return Gt.jsxs("div",{className:"min-h-screen bg-slate-50 text-slate-900 flex flex-col",children:[Gt.jsx("header",{className:"bg-white border-b border-slate-200 sticky top-0 z-20",children:Gt.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 h-16 flex items-center justify-between",children:[Gt.jsxs("div",{className:"flex items-center gap-3",children:[Gt.jsx("div",{className:"w-10 h-10 rounded-xl bg-gradient-to-tr from-blue-600 to-indigo-600 flex items-center justify-center text-white shadow-md shadow-blue-500/20",children:Gt.jsx($2,{className:"w-5 h-5"})}),Gt.jsxs("div",{children:[Gt.jsx("h1",{className:"text-lg font-bold tracking-tight text-slate-900 leading-none",children:"jazz-tools"}),Gt.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Harmonic Journey & Voice-Led Guide Tone Engine"})]})]}),Gt.jsx("div",{className:"flex items-center gap-3 text-xs",children:Gt.jsx("span",{className:"hidden sm:inline-flex items-center px-2.5 py-1 rounded-full bg-slate-100 text-slate-700 font-medium",children:"1,400 Standards • Web • LilyPond"})})]})}),Gt.jsxs("main",{className:"flex-1 max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8 w-full space-y-6",children:[Gt.jsxs("div",{className:"bg-white rounded-2xl shadow-sm border border-slate-200 overflow-hidden",children:[Gt.jsxs("div",{className:"flex border-b border-slate-200 bg-slate-50/75 overflow-x-auto",children:[Gt.jsxs("button",{onClick:()=>Lt("search"),className:`px-5 py-3 text-sm font-medium border-b-2 transition-colors flex items-center gap-2 whitespace-nowrap ${re==="search"?"border-blue-600 text-blue-600 bg-white":"border-transparent text-slate-600 hover:text-slate-900"}`,children:[Gt.jsx(D1,{className:"w-4 h-4"}),"Search Standards (1,400)"]}),Gt.jsxs("button",{onClick:()=>Lt("sample"),className:`px-5 py-3 text-sm font-medium border-b-2 transition-colors flex items-center gap-2 whitespace-nowrap ${re==="sample"?"border-blue-600 text-blue-600 bg-white":"border-transparent text-slate-600 hover:text-slate-900"}`,children:[Gt.jsx(xh,{className:"w-4 h-4"}),"Demo Tunes"]}),Gt.jsxs("button",{onClick:()=>Lt("text"),className:`px-5 py-3 text-sm font-medium border-b-2 transition-colors flex items-center gap-2 whitespace-nowrap ${re==="text"?"border-blue-600 text-blue-600 bg-white":"border-transparent text-slate-600 hover:text-slate-900"}`,children:[Gt.jsx(J2,{className:"w-4 h-4"}),"iReal URL / XML Text"]}),Gt.jsxs("button",{onClick:()=>Lt("upload"),className:`px-5 py-3 text-sm font-medium border-b-2 transition-colors flex items-center gap-2 whitespace-nowrap ${re==="upload"?"border-blue-600 text-blue-600 bg-white":"border-transparent text-slate-600 hover:text-slate-900"}`,children:[Gt.jsx(F1,{className:"w-4 h-4"}),"Upload File"]})]}),Gt.jsxs("form",{onSubmit:A,className:"p-6 space-y-4",children:[re==="search"&&Gt.jsxs("div",{className:"space-y-4",children:[Gt.jsxs("div",{className:"relative",children:[Gt.jsx(D1,{className:"w-5 h-5 absolute left-3.5 top-3.5 text-slate-400"}),Gt.jsx("input",{type:"text",value:ae,onChange:C=>St(C.target.value),placeholder:"Search 1,400 jazz standards by title or composer (e.g. Autumn Leaves, Giant Steps, Bill Evans, Jobim)...",className:"w-full pl-11 pr-10 py-3 rounded-xl border border-slate-300 focus:ring-2 focus:ring-blue-500 focus:outline-none text-sm placeholder:text-slate-400 shadow-sm"}),m&&Gt.jsx(O1,{className:"w-4 h-4 animate-spin absolute right-3.5 top-3.5 text-slate-400"})]}),Gt.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:[Gt.jsx("span",{className:"text-xs font-semibold text-slate-400 uppercase tracking-wider mr-1",children:"Popular:"}),t0.map(C=>Gt.jsx("button",{type:"button",onClick:()=>{St(C),R({standard:C})},className:"px-2.5 py-1 rounded-lg bg-slate-100 hover:bg-slate-200 text-slate-700 text-xs font-medium transition-colors",children:C},C))]}),y.length>0&&Gt.jsxs("div",{className:"pt-2",children:[Gt.jsx("span",{className:"text-xs font-semibold text-slate-400 uppercase tracking-wider block mb-2",children:ae?`Matching Standards (${y.length})`:"Catalog Preview"}),Gt.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-2.5 max-h-60 overflow-y-auto p-1 border border-slate-100 rounded-xl bg-slate-50/50",children:y.map(C=>{const z=(g==null?void 0:g.title.toLowerCase())===C.title.toLowerCase();return Gt.jsxs("button",{type:"button",onClick:()=>F(C),className:`p-2.5 rounded-xl text-left border transition-all flex items-center justify-between group ${z?"bg-blue-50 border-blue-300 shadow-xs":"bg-white hover:bg-blue-50/50 border-slate-200/80 hover:border-blue-200"}`,children:[Gt.jsxs("div",{className:"min-w-0 pr-2",children:[Gt.jsxs("div",{className:"flex items-center gap-1.5",children:[Gt.jsx("p",{className:`text-sm font-semibold truncate ${z?"text-blue-900":"text-slate-800"}`,children:C.title}),C.hasMelody&&Gt.jsx("span",{className:"px-1.5 py-0.2 rounded text-[10px] font-semibold bg-emerald-100 text-emerald-800 border border-emerald-200 flex-shrink-0",title:"Includes full melody staff",children:"🎵 Melody"})]}),Gt.jsx("p",{className:"text-xs text-slate-500 truncate",children:C.composer||"Jazz Standard"})]}),Gt.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[C.key&&Gt.jsx("span",{className:"px-2 py-0.5 rounded text-[11px] font-mono font-medium bg-slate-100 text-slate-600",children:C.key}),Gt.jsx(xh,{className:`w-3.5 h-3.5 opacity-0 group-hover:opacity-100 transition-opacity ${z?"opacity-100 text-blue-600":"text-slate-400"}`})]})]},C.id)})})]})]}),re==="sample"&&Gt.jsxs("div",{className:"flex flex-wrap gap-3 items-center",children:[Gt.jsx("span",{className:"text-xs font-semibold text-slate-500 uppercase",children:"Select Standard:"}),Ht.map(C=>Gt.jsxs("button",{type:"button",onClick:()=>{h(C.id),R({sample:C.id})},className:`px-4 py-2 rounded-xl text-sm font-medium transition-all flex items-center gap-2 ${s===C.id?"bg-blue-600 text-white shadow-sm":"bg-slate-100 hover:bg-slate-200 text-slate-800"}`,children:[Gt.jsx("span",{children:C.title}),Gt.jsxs("span",{className:"text-xs opacity-75",children:["by ",C.composer]})]},C.id))]}),re==="text"&&Gt.jsx("div",{className:"space-y-2",children:Gt.jsx("textarea",{value:u,onChange:C=>f(C.target.value),placeholder:"Paste an irealb:// link, playlist html, song name, or MusicXML score content...",rows:4,className:"w-full text-xs font-mono p-3 rounded-xl border border-slate-300 focus:ring-2 focus:ring-blue-500 focus:outline-none"})}),re==="upload"&&Gt.jsxs("div",{className:"border-2 border-dashed border-slate-300 rounded-xl p-6 text-center hover:bg-slate-50 transition-colors",children:[Gt.jsx("input",{type:"file",accept:".musicxml,.xml,.html,.htm",onChange:C=>{var z;return b(((z=C.target.files)==null?void 0:z[0])||null)},className:"hidden",id:"file-upload"}),Gt.jsxs("label",{htmlFor:"file-upload",className:"cursor-pointer block",children:[Gt.jsx(F1,{className:"w-8 h-8 mx-auto text-slate-400 mb-2"}),Gt.jsx("span",{className:"text-sm font-semibold text-blue-600 hover:underline",children:r?r.name:"Click to upload MusicXML or iReal file"}),Gt.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Supports .musicxml, .xml, .html"})]})]}),Gt.jsx("div",{className:"flex justify-end pt-2",children:Gt.jsx("button",{type:"submit",disabled:S,className:"px-6 py-2.5 bg-blue-600 hover:bg-blue-700 disabled:bg-blue-400 text-white rounded-xl font-medium text-sm shadow-sm transition-all flex items-center gap-2",children:S?Gt.jsxs(Gt.Fragment,{children:[Gt.jsx(O1,{className:"w-4 h-4 animate-spin"}),"Analyzing..."]}):Gt.jsxs(Gt.Fragment,{children:[Gt.jsx(xh,{className:"w-4 h-4 fill-white"}),"Analyze & Voice Lead"]})})})]})]}),w&&Gt.jsxs("div",{className:"bg-red-50 border border-red-200 text-red-700 p-4 rounded-xl flex items-start gap-3",children:[Gt.jsx(Z2,{className:"w-5 h-5 flex-shrink-0 text-red-500 mt-0.5"}),Gt.jsxs("div",{children:[Gt.jsx("p",{className:"text-sm font-semibold",children:"Error analyzing tune"}),Gt.jsx("p",{className:"text-xs mt-1 text-red-600",children:w})]})]}),g&&Gt.jsxs("div",{className:"space-y-6",children:[Gt.jsxs("div",{className:"bg-white rounded-2xl shadow-sm border border-slate-200 p-6 flex flex-col md:flex-row md:items-center justify-between gap-4",children:[Gt.jsxs("div",{children:[Gt.jsx("h2",{className:"text-2xl font-black tracking-tight text-slate-900",children:g.title}),g.composer&&Gt.jsxs("p",{className:"text-sm text-slate-500 mt-0.5",children:["by ",g.composer]}),Gt.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-3",children:[Gt.jsxs("span",{className:"px-2.5 py-1 rounded-md bg-slate-100 text-slate-700 text-xs font-semibold",children:["Key: ",g.key||"Modal/C"]}),Gt.jsxs("span",{className:"px-2.5 py-1 rounded-md bg-slate-100 text-slate-700 text-xs font-semibold",children:["Time: ",g.timeSignature?`${g.timeSignature[0]}/${g.timeSignature[1]}`:"4/4"]}),Gt.jsxs("span",{className:"px-2.5 py-1 rounded-md bg-slate-100 text-slate-700 text-xs font-semibold",children:[g.measureCount," Measures"]}),g.hasMelody?Gt.jsxs("span",{className:"px-2.5 py-1 rounded-md bg-emerald-100 text-emerald-800 text-xs font-semibold flex items-center gap-1 border border-emerald-200 shadow-xs",children:["🎵 Full Melody Included (",g.melodyNotesCount," notes)"]}):Gt.jsx("span",{className:"px-2.5 py-1 rounded-md bg-slate-100 text-slate-600 text-xs font-medium",children:"Chord Chart (Voice-Led Guide Tones)"})]})]}),Gt.jsxs("div",{className:"flex items-center gap-3",children:[Gt.jsxs("button",{onClick:G,disabled:!P,className:"px-4 py-2 border border-slate-300 hover:bg-slate-50 text-slate-700 rounded-xl text-xs font-semibold flex items-center gap-1.5 transition-colors",children:[Gt.jsx(B1,{className:"w-4 h-4 text-slate-500"}),"MusicXML"]}),Gt.jsxs("button",{onClick:U,disabled:B,className:"px-4 py-2 bg-slate-900 hover:bg-slate-800 text-white rounded-xl text-xs font-semibold flex items-center gap-1.5 shadow-sm transition-colors",children:[Gt.jsx(B1,{className:"w-4 h-4"}),B?"Compiling PDF...":"LilyPond PDF"]})]})]}),Gt.jsx(B2,{spans:g.journeySpans}),Gt.jsx(O2,{devices:g.devices}),P&&Gt.jsx(G2,{xmlContent:P,hasMelody:g.hasMelody}),Gt.jsx(D2,{measures:g.measures})]})]})]})};I2.createRoot(document.getElementById("root")).render(Gt.jsx(V1.StrictMode,{children:Gt.jsx(e0,{})})); diff --git a/web/dist/index.html b/web/dist/index.html index 54a0941..4f43961 100644 --- a/web/dist/index.html +++ b/web/dist/index.html @@ -5,7 +5,7 @@ jazz-tools - Harmonic Analysis & Companion Generator - + diff --git a/web/src/App.tsx b/web/src/App.tsx index cf334e9..f0eabc6 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -490,7 +490,7 @@ export const App: React.FC = () => { Key: {analysis.key || 'Modal/C'} - Time: {analysis.timeSignature[0]}/{analysis.timeSignature[1]} + Time: {analysis.timeSignature ? `${analysis.timeSignature[0]}/${analysis.timeSignature[1]}` : '4/4'} {analysis.measureCount} Measures diff --git a/web/src/components/ChordsTable.tsx b/web/src/components/ChordsTable.tsx index 9c868af..f9e461d 100644 --- a/web/src/components/ChordsTable.tsx +++ b/web/src/components/ChordsTable.tsx @@ -4,6 +4,9 @@ import { MeasureDTO } from '../types'; export const ChordsTable: React.FC<{ measures: MeasureDTO[] }> = ({ measures }) => { if (!measures || measures.length === 0) return null; + const hasAnyChords = measures.some((m) => m.chords && m.chords.length > 0); + if (!hasAnyChords) return null; + return (
@@ -25,7 +28,7 @@ export const ChordsTable: React.FC<{ measures: MeasureDTO[] }> = ({ measures }) {measures.flatMap((m) => - m.chords.map((c, cIdx) => ( + (m.chords || []).map((c, cIdx) => ( {cIdx === 0 ? m.number : ''} diff --git a/web/src/components/ScoreViewer.tsx b/web/src/components/ScoreViewer.tsx index d1eba11..fc80bd3 100644 --- a/web/src/components/ScoreViewer.tsx +++ b/web/src/components/ScoreViewer.tsx @@ -26,11 +26,16 @@ export const ScoreViewer: React.FC = ({ xmlContent, hasMelody }) => { }); } - osmdRef.current.load(xmlContent).then(() => { - osmdRef.current?.render(); - }).catch(err => { - console.error("OSMD render error:", err); - }); + try { + osmdRef.current.clear(); + osmdRef.current.load(xmlContent).then(() => { + osmdRef.current?.render(); + }).catch(err => { + console.error("OSMD render error:", err); + }); + } catch (err) { + console.error("OSMD load error:", err); + } }, [xmlContent]); return ( diff --git a/web/src/types.ts b/web/src/types.ts index c9611f6..d6abe78 100644 --- a/web/src/types.ts +++ b/web/src/types.ts @@ -43,7 +43,7 @@ export interface ChordDTO { export interface MeasureDTO { number: number; - chords: ChordDTO[]; + chords?: ChordDTO[]; melody?: MelodyNoteDTO[]; }