/*!
* alphaTab v1.8.4 (, build 34)
*
* Copyright © 2026, Daniel Kuschny and Contributors, All rights reserved.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Integrated Libraries:
*
* Library: TinySoundFont
* License: MIT
* Copyright: Copyright (C) 2017, 2018 Bernhard Schelling
* URL: https://github.com/schellingb/TinySoundFont
* Purpose: SoundFont loading and Audio Synthesis
*
* Library: SFZero
* License: MIT
* Copyright: Copyright (C) 2012 Steve Folta ()
* URL: https://github.com/stevefolta/SFZero
* Purpose: TinySoundFont is based on SFZEro
*
* Library: Haxe Standard Library
* License: MIT
* Copyright: Copyright (C)2005-2025 Haxe Foundation
* URL: https://github.com/HaxeFoundation/haxe/tree/development/std
* Purpose: XML Parser & Zip Inflate Algorithm
*
* Library: SharpZipLib
* License: MIT
* Copyright: Copyright © 2000-2018 SharpZipLib Contributors
* URL: https://github.com/icsharpcode/SharpZipLib
* Purpose: Zip Deflate Algorithm for writing compressed Zips
*
* Library: NVorbis
* License: MIT
* Copyright: Copyright (c) 2020 Andrew Ward
* URL: https://github.com/NVorbis/NVorbis
* Purpose: Vorbis Stream Decoding
*
* Library: libvorbis
* License: BSD-3-Clause
* Copyright: Copyright (c) 2002-2020 Xiph.org Foundation
* URL: https://github.com/xiph/vorbis
* Purpose: NVorbis adopted some code from libvorbis.
*
* @preserve
* @license
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).alphaTab={})}(this,function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});var e=Object.defineProperty,s=(t,s)=>{let i={};for(var n in t)e(i,n,{get:t[n],enumerable:!0});return s||e(i,Symbol.toStringTag,{value:"Module"}),i},i=class{t;i=new Set;constructor(t){this.t=t,window.addEventListener("resize",this.o.bind(this),!1)}observe(t){this.i.add(t)}unobserve(t){this.i.delete(t)}disconnect(){this.i.clear()}o(){const t=[];for(const e of this.i)t.push({target:e,contentRect:void 0,borderBoxSize:void 0,contentBoxSize:[],devicePixelContentBoxSize:[]});this.t(t,this)}},n=class{t;l=[];p=null;constructor(t){this.t=t,window.addEventListener("resize",()=>this.m,!0),document.addEventListener("scroll",()=>this.m,!0)}m(){this.p||(this.p=setTimeout(()=>{this.k(),this.p=null},100))}observe(t){this.l.indexOf(t)>=0||(this.l.push(t),this.m())}unobserve(t){this.l=this.l.filter(e=>e!==t)}k(){const t=[];for(const e of this.l){const s=e.getBoundingClientRect();s.top+s.height>=0&&s.top<=window.innerHeight&&s.left+s.width>=0&&s.left<=window.innerWidth&&t.push({target:e,isIntersecting:!0})}t.length&&this.t(t,this)}};void 0===Symbol.dispose&&(Symbol.dispose=Symbol("Symbol.dispose")),"undefined"!=typeof window&&("ResizeObserver"in globalThis||(globalThis.ResizeObserver=i),"IntersectionObserver"in globalThis||(globalThis.IntersectionObserver=n),"replaceChildren"in Element.prototype||(Element.prototype.replaceChildren=function(...t){this.innerHTML="",this.append(...t)},Document.prototype.replaceChildren=Element.prototype.replaceChildren,DocumentFragment.prototype.replaceChildren=Element.prototype.replaceChildren)),"replaceAll"in String.prototype||(String.prototype.replaceAll=function(t,e){return this.replace(new RegExp(t,"g"),e)});var r=function(t){return t[t.General=0]="General",t[t.Format=1]="Format",t[t.AlphaTex=2]="AlphaTex",t}({}),a=class extends Error{type;constructor(t,e="",s){super(e??"",{cause:s}),this.type=t}},h=class t{static version="1.8.4";static date="2026-07-05T14:46:18.224Z";static commit="022a45c8e42370f9e12e68949d11eada370da83d";static print(e){e(`alphaTab ${t.version}`),e(`commit: ${t.commit}`),e(`build date: ${t.date}`)}},o=function(t){return t[t.PPP=0]="PPP",t[t.PP=1]="PP",t[t.P=2]="P",t[t.MP=3]="MP",t[t.MF=4]="MF",t[t.F=5]="F",t[t.FF=6]="FF",t[t.FFF=7]="FFF",t[t.PPPP=8]="PPPP",t[t.PPPPP=9]="PPPPP",t[t.PPPPPP=10]="PPPPPP",t[t.FFFF=11]="FFFF",t[t.FFFFF=12]="FFFFF",t[t.FFFFFF=13]="FFFFFF",t[t.SF=14]="SF",t[t.SFP=15]="SFP",t[t.SFPP=16]="SFPP",t[t.FP=17]="FP",t[t.RF=18]="RF",t[t.RFZ=19]="RFZ",t[t.SFZ=20]="SFZ",t[t.SFFZ=21]="SFFZ",t[t.FZ=22]="FZ",t[t.N=23]="N",t[t.PF=24]="PF",t[t.SFZP=25]="SFZP",t}({}),c=class t{static QuarterTime=960;static S=15;static VelocityIncrement=16;static ticksToMillis(e,s){return e*(6e4/(s*t.QuarterTime))|0}static millisToTicks(e,s){return e/(6e4/(s*t.QuarterTime))|0}static toTicks(e){return t.valueToTicks(e)}static valueToTicks(e){let s=e;return s<0&&(s=1/-s),t.QuarterTime*(4/s)|0}static applyDot(t,e){return e?t+3*(t/4|0):t+(t/2|0)}static applyTuplet(t,e,s){return t*s/e|0}static removeTuplet(t,e,s){return t*e/s|0}static dynamicToVelocity(e,s=0){let i=1;switch(e){case o.PPP:i=t.S+0*t.VelocityIncrement;break;case o.PP:i=t.S+1*t.VelocityIncrement;break;case o.P:i=t.S+2*t.VelocityIncrement;break;case o.MP:i=t.S+3*t.VelocityIncrement;break;case o.MF:i=t.S+4*t.VelocityIncrement;break;case o.F:i=t.S+5*t.VelocityIncrement;break;case o.FF:i=t.S+6*t.VelocityIncrement;break;case o.FFF:i=t.S+7*t.VelocityIncrement;break;case o.PPPP:i=10;break;case o.PPPPP:i=5;break;case o.PPPPPP:i=3;break;case o.FFFF:i=t.S+8*t.VelocityIncrement;break;case o.FFFFF:i=t.S+9*t.VelocityIncrement;break;case o.FFFFFF:i=t.S+10*t.VelocityIncrement;break;case o.SF:case o.SFP:case o.SFZP:case o.SFPP:case o.SFZ:case o.FZ:i=t.S+6*t.VelocityIncrement;break;case o.FP:case o.RF:case o.RFZ:case o.SFFZ:i=t.S+5*t.VelocityIncrement;break;case o.N:i=1;break;case o.PF:i=t.S+(4.5*t.VelocityIncrement|0)}return i+=s*t.VelocityIncrement,Math.min(Math.max(i,1),127)}},l=function(t){return t[t.Tempo=0]="Tempo",t[t.Volume=1]="Volume",t[t.Instrument=2]="Instrument",t[t.Balance=3]="Balance",t[t.SyncPoint=4]="SyncPoint",t[t.Bank=4]="Bank",t}({}),u=class{barOccurence=0;millisecondOffset=0},d=class t{isLinear=!1;type=0;value=0;syncPointValue;ratioPosition=0;text="";isVisible=!0;static buildTempoAutomation(e,s,i,n,r=!0){(n<1||n>5)&&(n=2);const a=new Float32Array([1,.5,1,1.5,2,3]),h=new t;return h.type=0,h.isLinear=e,h.ratioPosition=s,h.value=i*a[n],h.isVisible=r,h}static buildInstrumentAutomation(e,s,i){const n=new t;return n.type=2,n.isLinear=e,n.ratioPosition=s,n.value=i,n}},f=class{static MaxPosition=60;static MaxValue=12;offset;value;constructor(t=0,e=0){this.offset=t,this.value=e}},p=function(t){return t[t.Default=0]="Default",t[t.Gradual=1]="Gradual",t[t.Fast=2]="Fast",t}({}),b=function(t){return t[t.None=0]="None",t[t.Custom=1]="Custom",t[t.Bend=2]="Bend",t[t.Release=3]="Release",t[t.BendRelease=4]="BendRelease",t[t.Hold=5]="Hold",t[t.Prebend=6]="Prebend",t[t.PrebendBend=7]="PrebendBend",t[t.PrebendRelease=8]="PrebendRelease",t}({}),m=function(t){return t[t.None=0]="None",t[t.BrushUp=1]="BrushUp",t[t.BrushDown=2]="BrushDown",t[t.ArpeggioUp=3]="ArpeggioUp",t[t.ArpeggioDown=4]="ArpeggioDown",t}({}),g=function(t){return t[t.None=0]="None",t[t.Crescendo=1]="Crescendo",t[t.Decrescendo=2]="Decrescendo",t}({}),w=function(t){return t[t.QuadrupleWhole=-4]="QuadrupleWhole",t[t.DoubleWhole=-2]="DoubleWhole",t[t.Whole=1]="Whole",t[t.Half=2]="Half",t[t.Quarter=4]="Quarter",t[t.Eighth=8]="Eighth",t[t.Sixteenth=16]="Sixteenth",t[t.ThirtySecond=32]="ThirtySecond",t[t.SixtyFourth=64]="SixtyFourth",t[t.OneHundredTwentyEighth=128]="OneHundredTwentyEighth",t[t.TwoHundredFiftySixth=256]="TwoHundredFiftySixth",t}({}),y=function(t){return t[t.None=0]="None",t[t.OnBeat=1]="OnBeat",t[t.BeforeBeat=2]="BeforeBeat",t[t.BendGrace=3]="BendGrace",t}({}),k=function(t){return t[t.None=0]="None",t[t.Normal=1]="Normal",t[t.Heavy=2]="Heavy",t[t.Tenuto=3]="Tenuto",t}({}),S=function(t){return t[t.Unknown=-2]="Unknown",t[t.NoOrDead=-1]="NoOrDead",t[t.Thumb=0]="Thumb",t[t.IndexFinger=1]="IndexFinger",t[t.MiddleFinger=2]="MiddleFinger",t[t.AnnularFinger=3]="AnnularFinger",t[t.LittleFinger=4]="LittleFinger",t}({}),B=function(t){return t[t.None=0]="None",t[t.Natural=1]="Natural",t[t.Artificial=2]="Artificial",t[t.Pinch=3]="Pinch",t[t.Tap=4]="Tap",t[t.Semi=5]="Semi",t[t.Feedback=6]="Feedback",t}({}),_=function(t){return t[t.Default=0]="Default",t[t.ForceNone=1]="ForceNone",t[t.ForceNatural=2]="ForceNatural",t[t.ForceSharp=3]="ForceSharp",t[t.ForceDoubleSharp=4]="ForceDoubleSharp",t[t.ForceFlat=5]="ForceFlat",t[t.ForceDoubleFlat=6]="ForceDoubleFlat",t}({}),x=function(t){return t[t._=0]="_15ma",t[t.T=1]="_8va",t[t.Regular=2]="Regular",t[t.M=3]="_8vb",t[t.L=4]="_15mb",t}({}),T=function(t){return t[t.None=0]="None",t[t.IntoFromBelow=1]="IntoFromBelow",t[t.IntoFromAbove=2]="IntoFromAbove",t}({}),M=function(t){return t[t.None=0]="None",t[t.Shift=1]="Shift",t[t.Legato=2]="Legato",t[t.OutUp=3]="OutUp",t[t.OutDown=4]="OutDown",t[t.PickSlideDown=5]="PickSlideDown",t[t.PickSlideUp=6]="PickSlideUp",t}({}),v=class{originNote;destinationNote;segments=[]},N=function(t){return t[t.HammerPull=0]="HammerPull",t[t.LegatoSlide=1]="LegatoSlide",t}({}),P=function(t){return t[t.None=0]="None",t[t.Slight=1]="Slight",t[t.Wide=2]="Wide",t}({}),C=function(t){return t[t.Hidden=0]="Hidden",t[t.ShowWithBeams=1]="ShowWithBeams",t[t.ShowWithBars=2]="ShowWithBars",t[t.Automatic=3]="Automatic",t}({}),E=function(t){return t[t.ScoreDefault=0]="ScoreDefault",t[t.ScoreForcePiano=1]="ScoreForcePiano",t[t.SingleNoteEffectBand=2]="SingleNoteEffectBand",t[t.SingleNoteEffectBandForcePiano=3]="SingleNoteEffectBandForcePiano",t}({}),F=function(t){return t[t.GuitarPro=0]="GuitarPro",t[t.SongBook=1]="SongBook",t}({}),A=function(t){return t[t.ScoreTitle=0]="ScoreTitle",t[t.ScoreSubTitle=1]="ScoreSubTitle",t[t.ScoreArtist=2]="ScoreArtist",t[t.ScoreAlbum=3]="ScoreAlbum",t[t.ScoreWords=4]="ScoreWords",t[t.ScoreMusic=5]="ScoreMusic",t[t.ScoreWordsAndMusic=6]="ScoreWordsAndMusic",t[t.ScoreCopyright=7]="ScoreCopyright",t[t.GuitarTuning=8]="GuitarTuning",t[t.TrackNames=9]="TrackNames",t[t.ChordDiagrams=10]="ChordDiagrams",t[t.ParenthesisOnTiedBends=11]="ParenthesisOnTiedBends",t[t.TabNotesOnTiedBends=12]="TabNotesOnTiedBends",t[t.ZerosOnDiveWhammys=13]="ZerosOnDiveWhammys",t[t.EffectAlternateEndings=14]="EffectAlternateEndings",t[t.EffectCapo=15]="EffectCapo",t[t.EffectChordNames=16]="EffectChordNames",t[t.EffectCrescendo=17]="EffectCrescendo",t[t.EffectDynamics=18]="EffectDynamics",t[t.EffectFadeIn=19]="EffectFadeIn",t[t.EffectFermata=20]="EffectFermata",t[t.EffectFingering=21]="EffectFingering",t[t.EffectHarmonics=22]="EffectHarmonics",t[t.EffectLetRing=23]="EffectLetRing",t[t.EffectLyrics=24]="EffectLyrics",t[t.EffectMarker=25]="EffectMarker",t[t.EffectOttavia=26]="EffectOttavia",t[t.EffectPalmMute=27]="EffectPalmMute",t[t.EffectPickSlide=28]="EffectPickSlide",t[t.EffectPickStroke=29]="EffectPickStroke",t[t.EffectSlightBeatVibrato=30]="EffectSlightBeatVibrato",t[t.EffectSlightNoteVibrato=31]="EffectSlightNoteVibrato",t[t.EffectTap=32]="EffectTap",t[t.EffectTempo=33]="EffectTempo",t[t.EffectText=34]="EffectText",t[t.EffectTrill=35]="EffectTrill",t[t.EffectTripletFeel=36]="EffectTripletFeel",t[t.EffectWhammyBar=37]="EffectWhammyBar",t[t.EffectWideBeatVibrato=38]="EffectWideBeatVibrato",t[t.EffectWideNoteVibrato=39]="EffectWideNoteVibrato",t[t.EffectLeftHandTap=40]="EffectLeftHandTap",t[t.EffectFreeTime=41]="EffectFreeTime",t[t.EffectSustainPedal=42]="EffectSustainPedal",t[t.EffectGolpe=43]="EffectGolpe",t[t.EffectWahPedal=44]="EffectWahPedal",t[t.EffectBeatBarre=45]="EffectBeatBarre",t[t.EffectNoteOrnament=46]="EffectNoteOrnament",t[t.EffectRasgueado=47]="EffectRasgueado",t[t.EffectDirections=48]="EffectDirections",t[t.EffectBeatTimer=49]="EffectBeatTimer",t[t.EffectWhammyBarLine=50]="EffectWhammyBarLine",t[t.EffectNumberedNotationKeySignature=51]="EffectNumberedNotationKeySignature",t[t.ChordDiagramFretboardNumbers=52]="ChordDiagramFretboardNumbers",t[t.BarNumber=53]="BarNumber",t[t.RepeatCount=54]="RepeatCount",t[t.ScoreBendSlur=55]="ScoreBendSlur",t[t.EffectHammerOnPullOffText=56]="EffectHammerOnPullOffText",t[t.EffectSlideText=57]="EffectSlideText",t}({}),D=class t{notationMode=0;fingeringMode=0;elements=new Map;static defaultElements=new Map([[13,!1]]);rhythmMode=3;rhythmHeight=25;transpositionPitches=[];displayTranspositionPitches=[];smallGraceTabNotes=!0;extendBendArrowsOnTiedNotes=!0;extendLineEffectsToBeatEnd=!1;slurHeight=5;isNotationElementVisible(e){return this.elements.has(e)?this.elements.get(e):!t.defaultElements.has(e)||t.defaultElements.get(e)}},L=class{W;R=void 0;get hasValue(){return void 0!==this.R}constructor(t){this.W=t}get value(){return void 0===this.R&&(this.R=this.W()),this.R}reset(){this.R=void 0}},W=function(t){return t[t.None=0]="None",t[t.Debug=1]="Debug",t[t.Info=2]="Info",t[t.Warning=3]="Warning",t[t.Error=4]="Error",t}({}),R=class t{static logLevel=W.Info;static O(t,e){return`[AlphaTab][${t}] ${e}`}debug(e,s,...i){console.debug(t.O(e,s),...i)}warning(e,s,...i){console.warn(t.O(e,s),...i)}info(e,s,...i){console.info(t.O(e,s),...i)}error(e,s,...i){console.error(t.O(e,s),...i)}},O=class t{static logLevel=W.Info;static log=new R;static I(e){return t.logLevel!==W.None&&e>=t.logLevel}static debug(e,s,...i){t.I(W.Debug)&&t.log.debug(e,s,...i)}static warning(e,s,...i){t.I(W.Warning)&&t.log.warning(e,s,...i)}static info(e,s,...i){t.I(W.Info)&&t.log.info(e,s,...i)}static error(e,s,...i){t.I(W.Error)&&t.log.error(e,s,...i)}},I=function(t){return t[t.None=0]="None",t[t.Natural=1]="Natural",t[t.Sharp=2]="Sharp",t[t.Flat=3]="Flat",t[t.NaturalQuarterNoteUp=4]="NaturalQuarterNoteUp",t[t.SharpQuarterNoteUp=5]="SharpQuarterNoteUp",t[t.FlatQuarterNoteUp=6]="FlatQuarterNoteUp",t[t.DoubleSharp=7]="DoubleSharp",t[t.DoubleFlat=8]="DoubleFlat",t}({}),G=function(t){return t[t.Neutral=0]="Neutral",t[t.C3=1]="C3",t[t.C4=2]="C4",t[t.F4=3]="F4",t[t.G2=4]="G2",t}({}),H=function(t){return t[t.None=0]="None",t[t.Simple=1]="Simple",t[t.FirstOfDouble=2]="FirstOfDouble",t[t.SecondOfDouble=3]="SecondOfDouble",t}({}),$=class{colors=new Map},V=function(t){return t[t.Cb=-7]="Cb",t[t.Gb=-6]="Gb",t[t.Db=-5]="Db",t[t.Ab=-4]="Ab",t[t.Eb=-3]="Eb",t[t.Bb=-2]="Bb",t[t.F=-1]="F",t[t.C=0]="C",t[t.G=1]="G",t[t.D=2]="D",t[t.A=3]="A",t[t.E=4]="E",t[t.B=5]="B",t[t.FSharp=6]="FSharp",t[t.CSharp=7]="CSharp",t}({}),z=function(t){return t[t.Major=0]="Major",t[t.Minor=1]="Minor",t}({}),U=function(t){return t[t.Down=0]="Down",t[t.Hold=1]="Hold",t[t.Up=2]="Up",t}({}),X=class{ratioPosition=0;pedalType=0;bar;nextPedalMarker=null;previousPedalMarker=null},j=function(t){return t[t.StandardNotationRepeats=0]="StandardNotationRepeats",t[t.GuitarTabsRepeats=1]="GuitarTabsRepeats",t[t.SlashRepeats=2]="SlashRepeats",t[t.NumberedRepeats=3]="NumberedRepeats",t[t.StandardNotationBarNumber=4]="StandardNotationBarNumber",t[t.GuitarTabsBarNumber=5]="GuitarTabsBarNumber",t[t.SlashBarNumber=6]="SlashBarNumber",t[t.NumberedBarNumber=7]="NumberedBarNumber",t[t.StandardNotationBarLines=8]="StandardNotationBarLines",t[t.GuitarTabsBarLines=9]="GuitarTabsBarLines",t[t.SlashBarLines=10]="SlashBarLines",t[t.NumberedBarLines=11]="NumberedBarLines",t[t.StandardNotationClef=12]="StandardNotationClef",t[t.GuitarTabsClef=13]="GuitarTabsClef",t[t.StandardNotationKeySignature=14]="StandardNotationKeySignature",t[t.NumberedKeySignature=15]="NumberedKeySignature",t[t.StandardNotationTimeSignature=16]="StandardNotationTimeSignature",t[t.GuitarTabsTimeSignature=17]="GuitarTabsTimeSignature",t[t.SlashTimeSignature=18]="SlashTimeSignature",t[t.NumberedTimeSignature=19]="NumberedTimeSignature",t[t.StandardNotationStaffLine=20]="StandardNotationStaffLine",t[t.GuitarTabsStaffLine=21]="GuitarTabsStaffLine",t[t.SlashStaffLine=22]="SlashStaffLine",t[t.NumberedStaffLine=23]="NumberedStaffLine",t}({}),J=class extends ${},q=function(t){return t[t.Automatic=0]="Automatic",t[t.Dashed=1]="Dashed",t[t.Dotted=2]="Dotted",t[t.Heavy=3]="Heavy",t[t.HeavyHeavy=4]="HeavyHeavy",t[t.HeavyLight=5]="HeavyLight",t[t.LightHeavy=6]="LightHeavy",t[t.LightLight=7]="LightLight",t[t.None=8]="None",t[t.Regular=9]="Regular",t[t.Short=10]="Short",t[t.Tick=11]="Tick",t}({}),Y=class t{static H=0;static resetIds(){t.H=0}id=t.H++;index=0;nextBar=null;previousBar=null;clef=G.G2;clefOttava=x.Regular;staff;voices=[];simileMark=H.None;$=new Set([0]);get isMultiVoice(){return this.$.size>1}get filledVoices(){return this.$}displayScale=1;displayWidth=-1;sustainPedals=[];get masterBar(){return this.staff.track.score.masterBars[this.index]}V=!0;U=!0;get isEmpty(){return this.V}get hasChanges(){return 0===this.index||(this.keySignature!==this.previousBar.keySignature||this.keySignatureType!==this.previousBar.keySignatureType||this.clef!==this.previousBar.clef||this.clefOttava!==this.previousBar.clefOttava||(this.simileMark!==H.None||this.sustainPedals.length>0||0!==this.barLineLeft||0!==this.barLineRight))}get isRestOnly(){return this.U}barLineLeft=0;barLineRight=0;keySignature=V.C;keySignatureType=z.Major;barNumberDisplay;shortestDuration=w.DoubleWhole;getActualBarLineLeft(e){return t.X(this,!1,e)}getActualBarLineRight(){return t.X(this,!0,!1)}static j(t,e,s){let i;return i=e?t.isRepeatEnd?6:t.nextMasterBar?t.isFreeTime?1:t.isDoubleBar?7:9:6:t.isRepeatStart?5:s?9:8,i}static X(e,s,i){const n=e.masterBar,r=s?e.barLineRight:e.barLineLeft;let a;return a=0===r?t.j(n,s,i):r,a}style;addVoice(t){t.bar=this,t.index=this.voices.length,this.voices.push(t)}finish(t,e=null){this.$.clear(),this.$.add(0),this.V=!0,this.U=!0,this.shortestDuration=w.DoubleWhole;for(let s=0,i=this.voices.length;s<i;s++){const i=this.voices[s];i.finish(t,e),i.isEmpty||(this.V=!1,this.$.add(s),i.shortestDuration>this.shortestDuration&&(this.shortestDuration=i.shortestDuration)),i.isRestOnly||(this.U=!1)}const s=this.sustainPedals;if(s.length>0){let t=null;this.sustainPedals=[],this.previousBar&&this.previousBar.sustainPedals.length>0&&(t=this.previousBar.sustainPedals[this.previousBar.sustainPedals.length-1],2===t.pedalType&&(t=null));const e=null!==t&&2!==t.pedalType;for(const i of s){if(t&&2!==t.pedalType){if(t.bar===this&&i.ratioPosition<=t.ratioPosition)continue;t.nextPedalMarker=i,i.previousPedalMarker=t}e&&0===i.pedalType&&(i.pedalType=1),i.bar=this,this.sustainPedals.push(i),t=i}}else if(this.previousBar&&this.previousBar.sustainPedals.length>0){const t=this.previousBar.sustainPedals[this.previousBar.sustainPedals.length-1];if(2!==t.pedalType){const e=new X;e.ratioPosition=0,e.bar=this,e.pedalType=1,this.sustainPedals.push(e),t.nextPedalMarker=e,e.previousPedalMarker=t}}}calculateDuration(){let t=0;for(const e of this.voices){const s=e.calculateDuration();s>t&&(t=s)}return t}},K=function(t){return t[t.NoTripletFeel=0]="NoTripletFeel",t[t.Triplet16th=1]="Triplet16th",t[t.Triplet8th=2]="Triplet8th",t[t.Dotted16th=3]="Dotted16th",t[t.Dotted8th=4]="Dotted8th",t[t.Scottish16th=5]="Scottish16th",t[t.Scottish8th=6]="Scottish8th",t}({}),Q=class t{J;groups=new Map;uniqueId="";timeSignatureNumerator=0;timeSignatureDenominator=0;static createSimple(e,s,i,n){const r=new t;return r.timeSignatureNumerator=e,r.timeSignatureDenominator=s,r.groups.set(i,n),r.finish(),r}findRule(t){const e=this.J;if(e)return[e,this.groups.get(e)];if(t<w.Quarter)return[t,[]];let s=t;do{const t=s;if(this.groups.has(t))return[t,this.groups.get(t)];s*=2}while(s<=w.TwoHundredFiftySixth);s=t/2;do{const t=s;if(this.groups.has(t))return[t,this.groups.get(t)];s/=2}while(s>w.Half);return[t,[]]}finish(){let t=`${this.timeSignatureNumerator}_${this.timeSignatureDenominator}`;for(const[e,s]of this.groups){t+=`__${e}`;let i=s.length;for(let t=s.length-1;t>=0&&0===s[t];t--)i=t;i<s.length&&s.splice(i,s.length-i),t+=`_${s.join("_")}`,1===this.groups.size&&(this.J=e)}this.uniqueId=t}},Z=class{static MaxAlternateEndings=8;alternateEndings=0;nextMasterBar=null;previousMasterBar=null;index=0;get hasChanges(){return 0!==this.index&&(this.timeSignatureCommon!==this.previousMasterBar.timeSignatureCommon||this.timeSignatureNumerator!==this.previousMasterBar.timeSignatureNumerator||this.timeSignatureDenominator!==this.previousMasterBar.timeSignatureDenominator||this.tripletFeel!==this.previousMasterBar.tripletFeel||(0!==this.alternateEndings||this.isRepeatStart||this.isRepeatEnd||this.isFreeTime||this.isSectionStart||this.tempoAutomations.length>0||this.syncPoints&&this.syncPoints.length>0||null!==this.fermata&&this.fermata.size>0||null!==this.directions&&this.directions.size>0||this.isAnacrusis))}get keySignature(){return this.score.tracks[0].staves[0].bars[this.index].keySignature}set keySignature(t){this.score.tracks[0].staves[0].bars[this.index].keySignature=t}get keySignatureType(){return this.score.tracks[0].staves[0].bars[this.index].keySignatureType}set keySignatureType(t){this.score.tracks[0].staves[0].bars[this.index].keySignatureType=t}isDoubleBar=!1;isRepeatStart=!1;get isRepeatEnd(){return this.repeatCount>0}repeatCount=0;repeatGroup;timeSignatureNumerator=4;timeSignatureDenominator=4;timeSignatureCommon=!1;beamingRules;actualBeamingRules;isFreeTime=!1;tripletFeel=K.NoTripletFeel;section=null;get isSectionStart(){return!!this.section}get tempoAutomation(){return this.tempoAutomations.length>0?this.tempoAutomations[0]:null}tempoAutomations=[];syncPoints;score;fermata=null;start=0;isAnacrusis=!1;displayScale=1;displayWidth=-1;directions=null;calculateDuration(t=!0){if(this.isAnacrusis&&t){let t=0;for(const e of this.score.tracks)for(const s of e.staves){const e=this.index<s.bars.length?s.bars[this.index].calculateDuration():0;e>t&&(t=e)}return t}return this.timeSignatureNumerator*c.valueToTicks(this.timeSignatureDenominator)}addFermata(t,e){let s=this.fermata;null===s&&(s=new Map,this.fermata=s),s.set(t,e)}addDirection(t){null==this.directions&&(this.directions=new Set),this.directions.add(t)}getFermata(t){const e=this.fermata;return null===e?null:e.has(t.playbackStart)?e.get(t.playbackStart):0===t.index&&e.has(0)?e.get(0):null}addSyncPoint(t){this.syncPoints||(this.syncPoints=[]),this.syncPoints.push(t)}finish(t){let e=this.beamingRules;if(e&&(e.timeSignatureNumerator=this.timeSignatureNumerator,e.timeSignatureDenominator=this.timeSignatureDenominator,e.finish()),this.index>0){this.start=this.previousMasterBar.start+this.previousMasterBar.calculateDuration();const s=t.has("beamingRules")?t.get("beamingRules"):void 0;s&&s.uniqueId===e?.uniqueId?(this.beamingRules=void 0,e=s):e||(e=s)}this.actualBeamingRules=e,this.beamingRules&&t.set("beamingRules",e)}},tt=function(t){return t[t.NoBrackets=0]="NoBrackets",t[t.GroupStaves=1]="GroupStaves",t[t.GroupSimilarInstruments=2]="GroupSimilarInstruments",t}({}),et=function(t){return t[t.Hidden=0]="Hidden",t[t.FirstSystem=1]="FirstSystem",t[t.AllSystems=2]="AllSystems",t}({}),st=function(t){return t[t.FullName=0]="FullName",t[t.ShortName=1]="ShortName",t}({}),it=function(t){return t[t.Horizontal=0]="Horizontal",t[t.Vertical=1]="Vertical",t}({}),nt=function(t){return t[t.AllBars=0]="AllBars",t[t.FirstOfSystem=1]="FirstOfSystem",t[t.Hide=2]="Hide",t}({}),rt=class{hideDynamics=!1;bracketExtendMode=1;useSystemSignSeparator=!1;globalDisplayTuning=!0;perTrackDisplayTuning=null;globalDisplayChordDiagramsOnTop=!0;perTrackChordDiagramsOnTop=null;globalDisplayChordDiagramsInScore=!1;singleTrackTrackNamePolicy=1;multiTrackTrackNamePolicy=1;firstSystemTrackNameMode=1;otherSystemsTrackNameMode=1;firstSystemTrackNameOrientation=1;otherSystemsTrackNameOrientation=1;multiTrackMultiBarRest=!1;perTrackMultiBarRest=null;extendBarLines=!1;hideEmptyStaves=!1;hideEmptyStavesInFirstSystem=!1;showSingleStaffBrackets=!1;barNumberDisplay=0},at=class{masterBars=[];opening=null;get openings(){const t=this.opening;return t?[t]:[]}closings=[];get isOpened(){return!0===this.opening?.isRepeatStart}isClosed=!1;addMasterBar(t){null===this.opening&&(this.opening=t),this.masterBars.push(t),t.repeatGroup=this,t.isRepeatEnd&&(this.closings.push(t),this.isClosed=!0)}},ht=class{beats=[];id="empty";isComplete=!1;addBeat(t){t.graceIndex=this.beats.length,t.graceGroup=this,this.beats.push(t)}finish(){this.beats.length>0&&(this.id=`${this.beats[0].absoluteDisplayStart}_${this.beats[0].voice.index}`)}},ot=function(t){return t[t.Glyphs=0]="Glyphs",t}({}),ct=class extends ${},lt=class t{q;V=!0;U=!0;static Y=0;static resetIds(){t.Y=0}id=t.Y++;index=0;bar;beats=[];get isEmpty(){return this.V}style;forceNonEmpty(){this.V=!1}get isRestOnly(){return this.U}shortestDuration=w.DoubleWhole;insertBeat(t,e){e.nextBeat=t.nextBeat,e.nextBeat&&(e.nextBeat.previousBeat=e),e.previousBeat=t,e.voice=this,t.nextBeat=e,this.beats.splice(t.index+1,0,e)}addBeat(t){t.voice=this,t.index=this.beats.length,this.beats.push(t),t.isEmpty||(this.V=!1),t.isRest||(this.U=!1)}K(t,e=null){if(this.bar){if(t.index<this.beats.length-1)t.nextBeat=this.beats[t.index+1],t.nextBeat.previousBeat=t;else if(t.isLastOfVoice&&t.voice.bar.nextBar){const e=this.bar.nextBar.voices[this.index];e.beats.length>0?(t.nextBeat=e.beats[0],t.nextBeat.previousBeat=t):t.nextBeat.previousBeat=t}t.chain(e)}}addGraceBeat(t){if(0===this.beats.length)return void this.addBeat(t);const e=this.beats[this.beats.length-1];this.beats.splice(this.beats.length-1,1),this.addBeat(t),this.addBeat(e),this.V=!1,this.U=!1}getBeatAtPlaybackStart(t){return this.q.has(t)?this.q.get(t):null}finish(t,e=null){this.V=!0,this.U=!0,this.q=new Map;let s=null;for(let t=0;t<this.beats.length;t++){const i=this.beats[t];i.index=t,this.K(i,e),i.graceType===y.None?(i.graceGroup=s,s&&(s.isComplete=!0),s=null):(s||(s=new ht),s.addBeat(i)),i.isEmpty||(this.V=!1),i.isRest||(this.U=!1)}let i=0,n=0;this.shortestDuration=w.DoubleWhole;for(let s=0;s<this.beats.length;s++){const r=this.beats[s];if(r.index=s,r.finish(t,e),r.graceType===y.None){if(r.duration>this.shortestDuration&&(this.shortestDuration=r.duration),r.graceGroup){const t=r.graceGroup.beats[0],e=r.graceGroup.beats[r.graceGroup.beats.length-1];if(t.graceType!==y.BendGrace){const s=e.playbackStart+e.playbackDuration-t.playbackStart;switch(t.graceType){case y.BeforeBeat:t.previousBeat?(t.previousBeat.playbackDuration-=s,n=t.previousBeat.voice===this?t.previousBeat.playbackStart+t.previousBeat.playbackDuration:-s):n=-s;for(const t of r.graceGroup.beats)this.q.delete(t.playbackStart),t.playbackStart=n,this.q.set(t.playbackStart,r),n+=t.playbackDuration;break;case y.OnBeat:r.playbackDuration-=s,n=e.voice===this?e.playbackStart+e.playbackDuration:-s}}}r.displayStart=i,r.playbackStart=n,this.q.set(r.playbackStart,r)}else r.displayStart=i,r.playbackStart=n;r.fermata?this.bar.masterBar.addFermata(r.playbackStart,r.fermata):r.fermata=this.bar.masterBar.getFermata(r),r.finishTuplet(),r.graceGroup&&r.graceGroup.finish(),i+=r.displayDuration,n+=r.playbackDuration}}calculateDuration(){if(this.isEmpty||0===this.beats.length)return 0;const t=this.beats[this.beats.length-1],e=this.beats[0];return t.playbackStart+t.playbackDuration-e.playbackStart}},ut=function(t){return t[t.Left=0]="Left",t[t.Center=1]="Center",t[t.Right=2]="Right",t}({}),dt=function(t){return t[t.Top=0]="Top",t[t.Middle=1]="Middle",t[t.Bottom=2]="Bottom",t[t.Alphabetic=3]="Alphabetic",t}({}),ft=class{width;height;constructor(t,e){this.width=t,this.height=e}},pt=class{static fillMusicFontSymbolSafe(t,e,s,i,n,r){t.settings.display.resources.engravingSettings.hasSymbol(n)&&t.fillMusicFontSymbol(e,s,i,n,r)}static fillMusicFontSymbolsSafe(t,e,s,i,n,r){const a=n.filter(e=>t.settings.display.resources.engravingSettings.hasSymbol(e));0!==a.length&&t.fillMusicFontSymbols(e,s,i,a,r)}},bt=function(t){return t[t.Title=0]="Title",t[t.SubTitle=1]="SubTitle",t[t.Artist=2]="Artist",t[t.Album=3]="Album",t[t.Words=4]="Words",t[t.Music=5]="Music",t[t.WordsAndMusic=6]="WordsAndMusic",t[t.Transcriber=7]="Transcriber",t[t.Copyright=8]="Copyright",t[t.CopyrightSecondLine=9]="CopyrightSecondLine",t[t.ChordDiagramList=10]="ChordDiagramList",t}({}),mt=class t{template;isVisible;textAlign;constructor(t="",e=void 0,s=ut.Left){this.template=t,this.isVisible=e,this.textAlign=s}static equals(t,e){return(void 0===t.isVisible||t.isVisible)===(void 0===e.isVisible||e.isVisible)&&(t.template===e.template&&t.textAlign===e.textAlign)}buildText(e){let s=!1,i=!1;const n=this.template.replace(t.Z,(t,n)=>{i=!0;let r="";switch(n){case"TITLE":r=e.title;break;case"SUBTITLE":r=e.subTitle;break;case"ARTIST":r=e.artist;break;case"ALBUM":r=e.album;break;case"WORDS":case"WORDSMUSIC":r=e.words;break;case"MUSIC":r=e.music;break;case"TABBER":r=e.tab;break;case"COPYRIGHT":r=e.copyright;break;default:r=""}return r&&(s=!0),r});return i&&!s?"":n}static Z=/%([^%]+)%/g},gt=class extends ${headerAndFooter=new Map;static defaultHeaderAndFooter=new Map([[0,new mt("%TITLE%",void 0,ut.Center)],[1,new mt("%SUBTITLE%",void 0,ut.Center)],[2,new mt("%ARTIST%",void 0,ut.Center)],[3,new mt("%ALBUM%",void 0,ut.Center)],[4,new mt("Words by %WORDS%",void 0,ut.Left)],[5,new mt("Music by %MUSIC%",void 0,ut.Right)],[6,new mt("Words & Music by %MUSIC%",void 0,ut.Right)],[7,new mt("Tabbed by %TABBER%",!1,ut.Right)],[8,new mt("%COPYRIGHT%",void 0,ut.Center)],[9,new mt("All Rights Reserved - International Copyright Secured",!0,ut.Center)]])},wt=class{tt=null;et=[];st=0;static resetIds(){Y.resetIds(),Xt.resetIds(),lt.resetIds(),At.resetIds()}album="";artist="";copyright="";instructions="";music="";notices="";subTitle="";title="";words="";tab="";get tempo(){return this.masterBars.length&&this.masterBars[0].tempoAutomations.length>0?this.masterBars[0].tempoAutomations[0].value:120}get tempoLabel(){return this.masterBars.length&&this.masterBars[0].tempoAutomations.length>0?this.masterBars[0].tempoAutomations[0].text:""}masterBars=[];tracks=[];defaultSystemsLayout=3;systemsLayout=[];stylesheet=new rt;backingTrack;style;rebuildRepeatGroups(){this.tt=null,this.et=[],this.st=0;for(const t of this.masterBars)this.it(t)}addMasterBar(t){t.score=this,t.index=this.masterBars.length,0!==this.masterBars.length&&(t.previousMasterBar=this.masterBars[this.masterBars.length-1],t.previousMasterBar.nextMasterBar=t,t.start=t.previousMasterBar.start+(t.previousMasterBar.isAnacrusis?0:t.previousMasterBar.calculateDuration())),this.it(t),this.masterBars.push(t)}it(t){t.isRepeatStart?(this.tt?.isClosed&&(this.et.pop(),this.st--),this.tt=new at,this.et.push(this.tt),this.st++):this.tt||(this.tt=new at,this.et.push(this.tt)),this.tt.addMasterBar(t),t.isRepeatEnd&&this.st>1&&(this.et.pop(),this.st--,this.tt=this.et.length>0?this.et[this.et.length-1]:null)}addTrack(t){t.score=this,t.index=this.tracks.length,this.tracks.push(t)}finish(t){const e=new Map;for(let s=0,i=this.tracks.length;s<i;s++)this.tracks[s].finish(t,e);for(const t of this.masterBars)t.finish(e)}applyFlatSyncPoints(t){for(const t of this.masterBars)t.syncPoints=void 0;for(const e of t){const t=new d;t.ratioPosition=Math.min(1,Math.max(0,e.barPosition)),t.type=l.SyncPoint,t.syncPointValue=new u,t.syncPointValue.millisecondOffset=e.millisecondOffset,t.syncPointValue.barOccurence=e.barOccurence,e.barIndex<this.masterBars.length&&this.masterBars[e.barIndex].addSyncPoint(t)}for(const t of this.masterBars)t.syncPoints&&t.syncPoints.sort((t,e)=>{const s=t.syncPointValue.barOccurence-e.syncPointValue.barOccurence;return 0!==s?s:t.ratioPosition-e.ratioPosition})}exportFlatSyncPoints(){const t=[];for(const e of this.masterBars){const s=e.syncPoints;if(s)for(const i of s)t.push({barIndex:e.index,barOccurence:i.syncPointValue.barOccurence,barPosition:i.ratioPosition,millisecondOffset:i.syncPointValue.millisecondOffset})}return t}},yt=class t{static DefaultChannelCount=17;static MetronomeKey=33;static AudioChannels=2;static MinVolume=0;static MinProgram=0;static MaxProgram=127;static MinPlaybackSpeed=.125;static MaxPlaybackSpeed=8;static PercussionChannel=9;static PercussionBank=128;static MaxPitchWheel=16384;static MaxPitchWheel20=4294967296;static DefaultPitchWheel=t.MaxPitchWheel/2;static MicroBufferCount=32;static MicroBufferSize=64;static AudibleLevelThreshold=.001},kt=class{note=null;tone=new St;octave=0;get realValue(){return 12*this.octave+this.tone.noteValue}},St=class{noteValue;accidentalMode;constructor(t=0,e=_.Default){this.noteValue=t,this.accidentalMode=e}},Bt=class t{static nt=t.rt();static rt(){return new Map(Object.values(w).filter(t=>"number"==typeof t).map(t=>[t,t<0?0:0|Math.log2(t)]))}static getIndex(e){return t.nt.get(e)}static keySignatureIsFlat(t){return t<0}static keySignatureIsNatural(t){return 0===t}static keySignatureIsSharp(t){return t>0}static applyPitchOffsets(t,e){for(let s=0;s<e.tracks.length;s++){if(s<t.notation.displayTranspositionPitches.length)for(const i of e.tracks[s].staves)i.displayTranspositionPitch=-t.notation.displayTranspositionPitches[s];if(s<t.notation.transpositionPitches.length)for(const i of e.tracks[s].staves)i.transpositionPitch=-t.notation.transpositionPitches[s]}}static isTuning(e){return!!t.parseTuning(e)}static tuningLetters=new Set([67,68,69,70,71,65,66,99,100,101,102,103,97,98,35]);static parseTuning(e){let s="",i="";for(let n=0;n<e.length;n++){const r=e.charCodeAt(n);if(r>=48&&r<=57){if(!s)return null;i+=String.fromCharCode(r)}else if(0===s.length){if(!t.tuningLetters.has(r))return null;s+=String.fromCharCode(r)}else s+=String.fromCharCode(r)}if(!i||!s)return null;const n=new kt;n.octave=Number.parseInt(i,10)+1,n.note=s.toLowerCase();const r=t.getToneForText(n.note);return null===r?null:(n.tone=r,n.tone.noteValue<0&&(n.octave--,n.tone.noteValue+=12),n)}static getTuningForText(e){const s=t.parseTuning(e);return s?s.realValue:-1}static getToneForText(e){const s=e.substring(0,1),i=e.substring(1);let n,r;switch(s.toLowerCase()){case"c":n=0;break;case"d":n=2;break;case"e":n=4;break;case"f":n=5;break;case"g":n=7;break;case"a":n=9;break;case"b":n=11;break;default:return null}if(!t.accidentalModeMapping.has(i))return null;switch(r=t.parseAccidentalMode(i),r){case _.Default:case _.ForceNone:case _.ForceNatural:break;case _.ForceSharp:n++;break;case _.ForceDoubleSharp:n+=2;break;case _.ForceFlat:n--;break;case _.ForceDoubleFlat:n-=2}return new St(n,r)}static reverseAccidentalModeMapping=new Map([[_.Default,"d"],[_.ForceNone,"forcenone"],[_.ForceNatural,"forcenatural"],[_.ForceSharp,"#"],[_.ForceDoubleSharp,"x"],[_.ForceFlat,"b"],[_.ForceDoubleFlat,"bb"]]);static accidentalModeMapping=new Map([["default",_.Default],["d",_.Default],["",_.Default],["forcenone",_.ForceNone],["-",_.ForceNone],["forcenatural",_.ForceNatural],["n",_.ForceNatural],["forcesharp",_.ForceSharp],["#",_.ForceSharp],["forcedoublesharp",_.ForceDoubleSharp],["##",_.ForceDoubleSharp],["x",_.ForceDoubleSharp],["forceflat",_.ForceFlat],["b",_.ForceFlat],["forcedoubleflat",_.ForceDoubleFlat],["bb",_.ForceDoubleFlat]]);static parseAccidentalMode(e){const s=e.toLowerCase();return t.accidentalModeMapping.has(s)?t.accidentalModeMapping.get(s):_.Default}static newGuid(){return`${Math.floor(65536*(1+Math.random())).toString(16).substring(1)+Math.floor(65536*(1+Math.random())).toString(16).substring(1)}-${Math.floor(65536*(1+Math.random())).toString(16).substring(1)}-${Math.floor(65536*(1+Math.random())).toString(16).substring(1)}-${Math.floor(65536*(1+Math.random())).toString(16).substring(1)}-${Math.floor(65536*(1+Math.random())).toString(16).substring(1)}${Math.floor(65536*(1+Math.random())).toString(16).substring(1)}${Math.floor(65536*(1+Math.random())).toString(16).substring(1)}`}static isAlmostEqualTo(t,e){return Math.abs(t-e)<1e-5}static toHexString(t,e=0){let s="";do{s=String.fromCharCode("0123456789ABCDEF".charCodeAt(15&t))+s,t>>=4}while(t>0);for(;s.length<e;)s=`0${s}`;return s}static getAlternateEndingsList(t){const e=[];for(let s=0;s<Z.MaxAlternateEndings;s++)t&1<<s&&e.push(s);return e}static deltaFretToHarmonicValue(t){switch(t){case 2:return 2.4;case 3:return 3.2;case 4:case 5:case 7:case 9:case 12:case 16:case 17:case 19:case 24:return t;case 8:return 8.2;case 10:return 9.6;case 14:case 15:return 14.7;case 21:case 22:return 21.7;default:return 12}}static clamp(t,e,s){return t<=e?e:t>=s?s:t}static buildMultiBarRestInfo(t,e,s){if(!t)return null;const i=t[0].score.stylesheet;if(!(t.length>1?i.multiTrackMultiBarRest:!0===i.perTrackMultiBarRest?.has(t[0].index)))return null;const n=new Map,r=t[0].score;let a=e,h=r.tempo;for(;a<=s;){const i=a;let o=null;for(;a<=s;){const s=r.masterBars[a];let n=!1;for(const t of s.tempoAutomations)t.value!==h&&(n=!0),h=t.value;if(s.alternateEndings||s.isRepeatStart&&s.index!==i||s.isFreeTime||s.isAnacrusis||null!==s.section||s.index!==i&&n||null!==s.fermata&&s.fermata.size>0||null!==s.directions&&s.directions.size>0)break;if(i>e&&s.previousMasterBar&&(s.timeSignatureCommon!==s.previousMasterBar.timeSignatureCommon||s.timeSignatureNumerator!==s.previousMasterBar.timeSignatureNumerator||s.timeSignatureDenominator!==s.previousMasterBar.timeSignatureDenominator||s.tripletFeel!==s.previousMasterBar.tripletFeel))break;let c=!0;for(const e of t){for(const t of e.staves){const e=t.bars[s.index];if(!e.isRestOnly){c=!1;break}if(e.index>0&&(e.keySignature!==e.previousBar.keySignature||e.keySignatureType!==e.previousBar.keySignatureType)){c=!1;break}}if(!c)break}if(!c)break;if(a++,s.index>i&&(null===o?o=[s.index]:o.push(s.index)),s.isRepeatEnd)break}o?n.set(i,o):a++}return n}static computeFirstDisplayedBarIndex(t,e){let s=e.display.startBar;return s--,s=Math.min(t.masterBars.length-1,Math.max(0,s)),s}static computeLastDisplayedBarIndex(t,e,s){let i=e.display.barCount;return i<0&&(i=t.masterBars.length),i=s+i-1,i=Math.min(t.masterBars.length-1,Math.max(0,i)),i}static getOrCreateHeaderFooterStyle(t,e){let s,i=t.style;if(t.style||(i=new gt,t.style=i),i.headerAndFooter.has(e))s=i.headerAndFooter.get(e);else{if(s=new mt,gt.defaultHeaderAndFooter.has(e)){const t=gt.defaultHeaderAndFooter.get(e);s.template=t.template,s.textAlign=t.textAlign}i.headerAndFooter.set(e,s)}return s}static consolidate(t){if(0===t.masterBars.length){const e=new Z;t.addMasterBar(e);const s=new d;s.isLinear=!1,s.type=l.Tempo,s.value=t.tempo,e.tempoAutomations.push(s);const i=new Y;t.tracks[0].staves[0].addBar(i);const n=new lt;i.addVoice(n);const r=new Xt;return r.isEmpty=!0,void n.addBeat(r)}const e=new Set([yt.PercussionChannel]);for(const s of t.tracks){if(1===s.staves.length&&s.staves[0].isPercussion)s.playbackInfo.primaryChannel=yt.PercussionChannel,s.playbackInfo.secondaryChannel=yt.PercussionChannel;else{if(s.playbackInfo.primaryChannel!==yt.PercussionChannel)for(;e.has(s.playbackInfo.primaryChannel);)s.playbackInfo.primaryChannel++;if(e.add(s.playbackInfo.primaryChannel),s.playbackInfo.secondaryChannel!==yt.PercussionChannel)for(;e.has(s.playbackInfo.secondaryChannel);)s.playbackInfo.secondaryChannel++;e.add(s.playbackInfo.secondaryChannel)}for(const e of s.staves){for(const t of e.bars)for(const e of t.voices)if(e.isEmpty&&0===e.beats.length){const t=new Xt;t.isEmpty=!0,e.addBeat(t)}const s=0===e.bars.length?1:e.bars[0].voices.length;for(;e.bars.length<t.masterBars.length;){const t=new Y;e.addBar(t);const i=t.previousBar;i&&(t.clef=i.clef,t.clefOttava=i.clefOttava,t.keySignature=t.previousBar.keySignature,t.keySignatureType=t.previousBar.keySignatureType);for(let e=0;e<s;e++){const e=new lt;t.addVoice(e);const s=new Xt;s.isEmpty=!0,e.addBeat(s)}}}}if(t.masterBars.length>0&&!t.masterBars[0].tempoAutomations.find(t=>t.type===l.Tempo&&0===t.ratioPosition)){const e=new d;e.isLinear=!1,e.type=l.Tempo,e.value=t.tempo,e.text=t.tempoLabel,e.isVisible=!1,t.masterBars[0].tempoAutomations.push(e)}}static trimEmptyBarsAtEnd(t){for(;t.masterBars.length>1;){const e=t.masterBars.length-1,s=t.masterBars[e];if(s.hasChanges)return;for(const s of t.tracks)for(const t of s.staves)if(e<t.bars.length){const s=t.bars[e];if(!s.isEmpty||s.hasChanges)return}for(const s of t.tracks)for(const t of s.staves)if(e<t.bars.length){const s=t.bars[e];t.bars.pop(),s.previousBar.nextBar=null}t.masterBars.pop(),s.previousMasterBar.nextMasterBar=null}}static displayTranspositionPitches=new Map([[24,-12],[25,-12],[26,-12],[27,-12],[28,-12],[29,-12],[30,-12],[31,-12],[32,-12],[33,-12],[34,-12],[35,-12],[36,-12],[37,-12],[38,-12],[39,-12],[43,-12]]);static flooredDivision(t,e){return t-e*Math.floor(t/e)}static ht(t){const e=[];for(const s of t){const t=[];e.push(t);for(const e of s){const s=Number.parseInt(e.charAt(0),10)*("b"===e.charAt(1)?-1:1);t.push(s)}}return e}static ot=t.ht([["7b","6b","5b","4b","3b","2b","1b","0#","1#","2#","3#","4#","5#","6#","7#"],["2b","1b","0#","1#","2#","3#","4#","5#","6#","7#","4b","3b","2b","1b","0#"],["3#","4#","7b","6b","5b","4b","3b","2b","1b","0#","1#","2#","3#","4#","5#"],["4b","3b","2b","1b","0#","1#","2#","3#","4#","5#","6#","7#","4b","3b","2b"],["1#","2#","3#","4#","7b","6b","5b","4b","3b","2b","1b","0#","1#","2#","3#"],["6b","5b","4b","3b","2b","1b","0#","1#","2#","3#","4#","5#","6#","7#","4b"],["1b","0#","1#","2#","3#","4#","7b","6#","7#","4b","3b","2b","1b","0#","1#"],["4#","7b","6b","5b","4b","3b","2b","1b","0#","1#","2#","3#","4#","5#","6#"],["3b","2b","1b","0#","1#","2#","3#","4#","5#","6#","7#","4b","3b","2b","1b"],["2#","3#","4#","7b","6b","5b","4b","3b","2b","1b","0#","1#","2#","3#","4#"],["5b","4b","3b","2b","1b","0#","1#","2#","3#","4#","5#","6#","7#","4b","3b"],["0#","1#","2#","3#","4#","7b","6b","6#","4b","3b","2b","1b","0#","1#","2#"]]);static transposeKey(e,s){if(0===s)return e;if(s<0){const i=t.ot[-s].indexOf(e);return-1===i?e:i-7}return t.ot[s][e+7]}static toArticulationId(t){return t.replace(/[^a-zA-Z0-9]/g,"").toLowerCase()}static minBoundingBox(t,e){return Number.isNaN(t)?e:Number.isNaN(e)||t<e?t:e}static maxBoundingBox(t,e){return Number.isNaN(t)?e:Number.isNaN(e)||t>e?t:e}static getSystemLayout(t,e,s){let i,n;return 1===s.length?(i=s[0].defaultSystemsLayout,n=s[0].systemsLayout):(i=t.defaultSystemsLayout,n=t.systemsLayout),e<n.length?n[e]:i}static ct=[0,2,4,5,7,9,11];static lt=[{degree:0,accidentalOffset:0},{degree:0,accidentalOffset:1},{degree:1,accidentalOffset:0},{degree:1,accidentalOffset:1},{degree:2,accidentalOffset:0},{degree:3,accidentalOffset:0},{degree:3,accidentalOffset:1},{degree:4,accidentalOffset:0},{degree:4,accidentalOffset:1},{degree:5,accidentalOffset:0},{degree:5,accidentalOffset:1},{degree:6,accidentalOffset:0}];static ut=[{degree:0,accidentalOffset:0},{degree:1,accidentalOffset:-1},{degree:1,accidentalOffset:0},{degree:2,accidentalOffset:-1},{degree:2,accidentalOffset:0},{degree:3,accidentalOffset:0},{degree:4,accidentalOffset:-1},{degree:4,accidentalOffset:0},{degree:5,accidentalOffset:-1},{degree:5,accidentalOffset:0},{degree:6,accidentalOffset:-1},{degree:6,accidentalOffset:0}];static dt=[[{degree:0,accidentalOffset:0},{degree:1,accidentalOffset:-2},{degree:6,accidentalOffset:1}],[{degree:0,accidentalOffset:1},{degree:1,accidentalOffset:-1},{degree:6,accidentalOffset:2}],[{degree:1,accidentalOffset:0},{degree:0,accidentalOffset:2},{degree:2,accidentalOffset:-2}],[{degree:1,accidentalOffset:1},{degree:2,accidentalOffset:-1},{degree:3,accidentalOffset:-2}],[{degree:2,accidentalOffset:0},{degree:1,accidentalOffset:2},{degree:3,accidentalOffset:-1}],[{degree:3,accidentalOffset:0},{degree:2,accidentalOffset:1},{degree:4,accidentalOffset:-2}],[{degree:3,accidentalOffset:1},{degree:4,accidentalOffset:-1},{degree:2,accidentalOffset:2}],[{degree:4,accidentalOffset:0},{degree:3,accidentalOffset:2},{degree:5,accidentalOffset:-2}],[{degree:4,accidentalOffset:1},{degree:5,accidentalOffset:-1}],[{degree:5,accidentalOffset:0},{degree:4,accidentalOffset:2},{degree:6,accidentalOffset:-2}],[{degree:5,accidentalOffset:1},{degree:6,accidentalOffset:-1},{degree:0,accidentalOffset:-2}],[{degree:6,accidentalOffset:0},{degree:5,accidentalOffset:2},{degree:0,accidentalOffset:-1}]];static ft=[3,0,4,1,5,2,6];static bt=[6,2,5,1,4,0,3];static gt=t.wt();static yt=new Map([[-2,I.DoubleFlat],[-1,I.Flat],[0,I.Natural],[1,I.Sharp],[2,I.DoubleSharp]]);static kt=new Map([[_.ForceSharp,1],[_.ForceDoubleSharp,2],[_.ForceFlat,-1],[_.ForceDoubleFlat,-2],[_.ForceNatural,0],[_.ForceNone,0],[_.Default,NaN]]);static wt(){const e=[];for(let s=-7;s<=7;s++){const i=[0,0,0,0,0,0,0];if(s>0)for(let e=0;e<s;e++)i[t.ft[e]]=1;else if(s<0)for(let e=0;e<-s;e++)i[t.bt[e]]=-1;e.push(i)}return e}static getKeySignatureAccidentalOffset(e,s){return t.gt[e+7][s]}static resolveSpelling(e,s,i){const n=t.flooredDivision(s,12),r=t.St(e,n),a=t.kt.has(i)?t.kt.get(i):NaN;let h=r;if(!Number.isNaN(a)){const e=t.dt[n].find(t=>t.accidentalOffset===a);e&&(h=e)}const o=t.ct[h.degree]+h.accidentalOffset,c=Math.floor((s-o)/12)-1;return{degree:h.degree,accidentalOffset:h.accidentalOffset,chroma:n,octave:c}}static computeAccidental(e,s,i,n,r=null){const a=t.resolveSpelling(e,i,s);return t.computeAccidentalForSpelling(e,s,a,n,r)}static computeAccidentalForSpelling(e,s,i,n,r=null){if(s===_.ForceNone)return I.None;if(n)return i.accidentalOffset>0?I.SharpQuarterNoteUp:i.accidentalOffset<0?I.FlatQuarterNoteUp:I.NaturalQuarterNoteUp;const a=i.accidentalOffset,h=t.getKeySignatureAccidentalOffset(e,i.degree);return r===a||null==r&&a===h?I.None:t.accidentalOffsetToType(a)}static accidentalOffsetToType(e){return t.yt.has(e)?t.yt.get(e):I.None}static St(e,s){const i=t.dt[s].find(s=>t.getKeySignatureAccidentalOffset(e,s.degree)===s.accidentalOffset);return i||(t.keySignatureIsFlat(e)?t.ut[s]:t.lt[s])}static Bt=[0,4,1,5,2,6,3,0,4,1,5,2,6,3,0];static _t=[5,2,6,3,0,4,1,5,2,6,3,0,4,1,5];static getKeySignatureTonicDegree(e,s){const i=e+7;return s===z.Minor?t._t[i]:t.Bt[i]}},_t=function(t){return t[t.None=0]="None",t[t.Up=1]="Up",t[t.Down=2]="Down",t}({}),xt=function(t){return t[t.None=-1]="None",t[t.Space=32]="Space",t[t.Brace=57344]="Brace",t[t.BracketTop=57347]="BracketTop",t[t.BracketBottom=57348]="BracketBottom",t[t.SystemDivider=57351]="SystemDivider",t[t.GClef=57424]="GClef",t[t.GClef15mb=57425]="GClef15mb",t[t.GClef8vb=57426]="GClef8vb",t[t.GClef8va=57427]="GClef8va",t[t.GClef15ma=57428]="GClef15ma",t[t.CClef=57436]="CClef",t[t.CClef8vb=57437]="CClef8vb",t[t.FClef=57442]="FClef",t[t.FClef15mb=57443]="FClef15mb",t[t.FClef8vb=57444]="FClef8vb",t[t.FClef8va=57445]="FClef8va",t[t.FClef15ma=57446]="FClef15ma",t[t.UnpitchedPercussionClef1=57449]="UnpitchedPercussionClef1",t[t.SixStringTabClef=57453]="SixStringTabClef",t[t.FourStringTabClef=57454]="FourStringTabClef",t[t.Clef8=57469]="Clef8",t[t.Clef15=57470]="Clef15",t[t.TimeSig0=57472]="TimeSig0",t[t.TimeSig1=57473]="TimeSig1",t[t.TimeSig2=57474]="TimeSig2",t[t.TimeSig3=57475]="TimeSig3",t[t.TimeSig4=57476]="TimeSig4",t[t.TimeSig5=57477]="TimeSig5",t[t.TimeSig6=57478]="TimeSig6",t[t.TimeSig7=57479]="TimeSig7",t[t.TimeSig8=57480]="TimeSig8",t[t.TimeSig9=57481]="TimeSig9",t[t.TimeSigCommon=57482]="TimeSigCommon",t[t.TimeSigCutCommon=57483]="TimeSigCutCommon",t[t.NoteheadDoubleWholeSquare=57505]="NoteheadDoubleWholeSquare",t[t.NoteheadDoubleWhole=57504]="NoteheadDoubleWhole",t[t.NoteheadWhole=57506]="NoteheadWhole",t[t.NoteheadHalf=57507]="NoteheadHalf",t[t.NoteheadBlack=57508]="NoteheadBlack",t[t.NoteheadNull=57509]="NoteheadNull",t[t.NoteheadXOrnate=57514]="NoteheadXOrnate",t[t.NoteheadPlusDoubleWhole=57516]="NoteheadPlusDoubleWhole",t[t.NoteheadPlusWhole=57517]="NoteheadPlusWhole",t[t.NoteheadPlusHalf=57518]="NoteheadPlusHalf",t[t.NoteheadPlusBlack=57519]="NoteheadPlusBlack",t[t.NoteheadSquareWhite=57528]="NoteheadSquareWhite",t[t.NoteheadSquareBlack=57529]="NoteheadSquareBlack",t[t.NoteheadTriangleUpDoubleWhole=57530]="NoteheadTriangleUpDoubleWhole",t[t.NoteheadTriangleUpWhole=57531]="NoteheadTriangleUpWhole",t[t.NoteheadTriangleUpHalf=57532]="NoteheadTriangleUpHalf",t[t.NoteheadTriangleUpBlack=57534]="NoteheadTriangleUpBlack",t[t.NoteheadTriangleRightWhite=57537]="NoteheadTriangleRightWhite",t[t.NoteheadTriangleRightBlack=57538]="NoteheadTriangleRightBlack",t[t.NoteheadTriangleDownDoubleWhole=57548]="NoteheadTriangleDownDoubleWhole",t[t.NoteheadTriangleDownWhole=57540]="NoteheadTriangleDownWhole",t[t.NoteheadTriangleDownHalf=57541]="NoteheadTriangleDownHalf",t[t.NoteheadTriangleDownBlack=57543]="NoteheadTriangleDownBlack",t[t.NoteheadDiamondDoubleWhole=57559]="NoteheadDiamondDoubleWhole",t[t.NoteheadDiamondWhole=57560]="NoteheadDiamondWhole",t[t.NoteheadDiamondHalf=57561]="NoteheadDiamondHalf",t[t.NoteheadDiamondBlack=57563]="NoteheadDiamondBlack",t[t.NoteheadDiamondBlackWide=57564]="NoteheadDiamondBlackWide",t[t.NoteheadDiamondWhite=57565]="NoteheadDiamondWhite",t[t.NoteheadDiamondWhiteWide=57566]="NoteheadDiamondWhiteWide",t[t.NoteheadCircleXDoubleWhole=57520]="NoteheadCircleXDoubleWhole",t[t.NoteheadCircleXWhole=57521]="NoteheadCircleXWhole",t[t.NoteheadCircleXHalf=57522]="NoteheadCircleXHalf",t[t.NoteheadCircleX=57523]="NoteheadCircleX",t[t.NoteheadXDoubleWhole=57510]="NoteheadXDoubleWhole",t[t.NoteheadXWhole=57511]="NoteheadXWhole",t[t.NoteheadXHalf=57512]="NoteheadXHalf",t[t.NoteheadXBlack=57513]="NoteheadXBlack",t[t.NoteheadParenthesis=57550]="NoteheadParenthesis",t[t.NoteheadSlashedBlack1=57551]="NoteheadSlashedBlack1",t[t.NoteheadSlashedBlack2=57552]="NoteheadSlashedBlack2",t[t.NoteheadSlashedHalf1=57553]="NoteheadSlashedHalf1",t[t.NoteheadSlashedHalf2=57554]="NoteheadSlashedHalf2",t[t.NoteheadSlashedWhole1=57555]="NoteheadSlashedWhole1",t[t.NoteheadSlashedWhole2=57556]="NoteheadSlashedWhole2",t[t.NoteheadSlashedDoubleWhole1=57557]="NoteheadSlashedDoubleWhole1",t[t.NoteheadSlashedDoubleWhole2=57558]="NoteheadSlashedDoubleWhole2",t[t.NoteheadCircledBlack=57572]="NoteheadCircledBlack",t[t.NoteheadCircledHalf=57573]="NoteheadCircledHalf",t[t.NoteheadCircledWhole=57574]="NoteheadCircledWhole",t[t.NoteheadCircledDoubleWhole=57575]="NoteheadCircledDoubleWhole",t[t.NoteheadCircleSlash=57591]="NoteheadCircleSlash",t[t.NoteheadHeavyX=57592]="NoteheadHeavyX",t[t.NoteheadHeavyXHat=57593]="NoteheadHeavyXHat",t[t.NoteheadSlashHorizontalEnds=57601]="NoteheadSlashHorizontalEnds",t[t.NoteheadSlashWhiteWhole=57602]="NoteheadSlashWhiteWhole",t[t.NoteheadSlashWhiteHalf=57603]="NoteheadSlashWhiteHalf",t[t.NoteheadRoundWhiteWithDot=57621]="NoteheadRoundWhiteWithDot",t[t.NoteheadSquareBlackLarge=57626]="NoteheadSquareBlackLarge",t[t.NoteheadSquareBlackWhite=57627]="NoteheadSquareBlackWhite",t[t.NoteheadClusterDoubleWhole3rd=57640]="NoteheadClusterDoubleWhole3rd",t[t.NoteheadClusterWhole3rd=57641]="NoteheadClusterWhole3rd",t[t.NoteheadClusterHalf3rd=57642]="NoteheadClusterHalf3rd",t[t.NoteheadClusterQuarter3rd=57643]="NoteheadClusterQuarter3rd",t[t.NoteShapeRoundWhite=57776]="NoteShapeRoundWhite",t[t.NoteShapeRoundBlack=57777]="NoteShapeRoundBlack",t[t.NoteShapeSquareWhite=57778]="NoteShapeSquareWhite",t[t.NoteShapeSquareBlack=57779]="NoteShapeSquareBlack",t[t.NoteShapeTriangleRightWhite=57780]="NoteShapeTriangleRightWhite",t[t.NoteShapeTriangleRightBlack=57781]="NoteShapeTriangleRightBlack",t[t.NoteShapeTriangleLeftWhite=57782]="NoteShapeTriangleLeftWhite",t[t.NoteShapeTriangleLeftBlack=57783]="NoteShapeTriangleLeftBlack",t[t.NoteShapeDiamondWhite=57784]="NoteShapeDiamondWhite",t[t.NoteShapeDiamondBlack=57785]="NoteShapeDiamondBlack",t[t.NoteShapeTriangleUpWhite=57786]="NoteShapeTriangleUpWhite",t[t.NoteShapeTriangleUpBlack=57787]="NoteShapeTriangleUpBlack",t[t.NoteShapeMoonWhite=57788]="NoteShapeMoonWhite",t[t.NoteShapeMoonBlack=57789]="NoteShapeMoonBlack",t[t.NoteShapeTriangleRoundWhite=57790]="NoteShapeTriangleRoundWhite",t[t.NoteShapeTriangleRoundBlack=57791]="NoteShapeTriangleRoundBlack",t[t.NoteQuarterUp=57813]="NoteQuarterUp",t[t.Note8thUp=57815]="Note8thUp",t[t.MetNoteQuarterUp=60581]="MetNoteQuarterUp",t[t.MetNote8thUp=60583]="MetNote8thUp",t[t.MetAugmentationDot=60599]="MetAugmentationDot",t[t.ArrowheadBlackUp=60280]="ArrowheadBlackUp",t[t.ArrowheadBlackDown=60284]="ArrowheadBlackDown",t[t.AugmentationDot=57831]="AugmentationDot",t[t.TextBlackNoteLongStem=57841]="TextBlackNoteLongStem",t[t.TextBlackNoteFrac8thLongStem=57843]="TextBlackNoteFrac8thLongStem",t[t.TextBlackNoteFrac16thLongStem=57845]="TextBlackNoteFrac16thLongStem",t[t.TextBlackNoteFrac32ndLongStem=57846]="TextBlackNoteFrac32ndLongStem",t[t.TextCont8thBeamLongStem=57848]="TextCont8thBeamLongStem",t[t.TextCont16thBeamLongStem=57850]="TextCont16thBeamLongStem",t[t.TextCont32ndBeamLongStem=57851]="TextCont32ndBeamLongStem",t[t.TextAugmentationDot=57852]="TextAugmentationDot",t[t.TextTupletBracketStartLongStem=57857]="TextTupletBracketStartLongStem",t[t.TextTuplet3LongStem=57858]="TextTuplet3LongStem",t[t.TextTupletBracketEndLongStem=57859]="TextTupletBracketEndLongStem",t[t.Tremolo1=57888]="Tremolo1",t[t.Tremolo2=57889]="Tremolo2",t[t.Tremolo3=57890]="Tremolo3",t[t.Tremolo4=57891]="Tremolo4",t[t.Tremolo5=57892]="Tremolo5",t[t.BuzzRoll=57898]="BuzzRoll",t[t.Flag8thUp=57920]="Flag8thUp",t[t.Flag8thDown=57921]="Flag8thDown",t[t.Flag16thUp=57922]="Flag16thUp",t[t.Flag16thDown=57923]="Flag16thDown",t[t.Flag32ndUp=57924]="Flag32ndUp",t[t.Flag32ndDown=57925]="Flag32ndDown",t[t.Flag64thUp=57926]="Flag64thUp",t[t.Flag64thDown=57927]="Flag64thDown",t[t.Flag128thUp=57928]="Flag128thUp",t[t.Flag128thDown=57929]="Flag128thDown",t[t.Flag256thUp=57930]="Flag256thUp",t[t.Flag256thDown=57931]="Flag256thDown",t[t.AccidentalFlat=57952]="AccidentalFlat",t[t.AccidentalNatural=57953]="AccidentalNatural",t[t.AccidentalSharp=57954]="AccidentalSharp",t[t.AccidentalDoubleSharp=57955]="AccidentalDoubleSharp",t[t.AccidentalDoubleFlat=57956]="AccidentalDoubleFlat",t[t.AccidentalQuarterToneFlatArrowUp=57968]="AccidentalQuarterToneFlatArrowUp",t[t.AccidentalQuarterToneSharpNaturalArrowUp=57970]="AccidentalQuarterToneSharpNaturalArrowUp",t[t.AccidentalThreeQuarterTonesSharpArrowUp=57972]="AccidentalThreeQuarterTonesSharpArrowUp",t[t.RepeatDot=57412]="RepeatDot",t[t.Segno=57415]="Segno",t[t.Coda=57416]="Coda",t[t.ArticAccentAbove=58528]="ArticAccentAbove",t[t.ArticAccentBelow=58529]="ArticAccentBelow",t[t.ArticStaccatoAbove=58530]="ArticStaccatoAbove",t[t.ArticStaccatoBelow=58531]="ArticStaccatoBelow",t[t.ArticTenutoAbove=58532]="ArticTenutoAbove",t[t.ArticTenutoBelow=58533]="ArticTenutoBelow",t[t.ArticMarcatoAbove=58540]="ArticMarcatoAbove",t[t.ArticMarcatoBelow=58541]="ArticMarcatoBelow",t[t.FermataAbove=58560]="FermataAbove",t[t.FermataShortAbove=58564]="FermataShortAbove",t[t.FermataLongAbove=58566]="FermataLongAbove",t[t.RestLonga=58593]="RestLonga",t[t.RestDoubleWhole=58594]="RestDoubleWhole",t[t.RestWhole=58595]="RestWhole",t[t.RestHalf=58596]="RestHalf",t[t.RestQuarter=58597]="RestQuarter",t[t.Rest8th=58598]="Rest8th",t[t.Rest16th=58599]="Rest16th",t[t.Rest32nd=58600]="Rest32nd",t[t.Rest64th=58601]="Rest64th",t[t.Rest128th=58602]="Rest128th",t[t.Rest256th=58603]="Rest256th",t[t.RestHBarLeft=58607]="RestHBarLeft",t[t.RestHBarMiddle=58608]="RestHBarMiddle",t[t.RestHBarRight=58609]="RestHBarRight",t[t.Repeat1Bar=58624]="Repeat1Bar",t[t.Repeat2Bars=58625]="Repeat2Bars",t[t.Ottava=58640]="Ottava",t[t.OttavaAlta=58641]="OttavaAlta",t[t.OttavaBassaVb=58652]="OttavaBassaVb",t[t.Quindicesima=58644]="Quindicesima",t[t.QuindicesimaAlta=58645]="QuindicesimaAlta",t[t.DynamicPPPPPP=58663]="DynamicPPPPPP",t[t.DynamicPPPPP=58664]="DynamicPPPPP",t[t.DynamicPPPP=58665]="DynamicPPPP",t[t.DynamicPPP=58666]="DynamicPPP",t[t.DynamicPP=58667]="DynamicPP",t[t.DynamicPiano=58656]="DynamicPiano",t[t.DynamicMP=58668]="DynamicMP",t[t.DynamicMF=58669]="DynamicMF",t[t.DynamicPF=58670]="DynamicPF",t[t.DynamicForte=58658]="DynamicForte",t[t.DynamicFF=58671]="DynamicFF",t[t.DynamicFFF=58672]="DynamicFFF",t[t.DynamicFFFF=58673]="DynamicFFFF",t[t.DynamicFFFFF=58674]="DynamicFFFFF",t[t.DynamicFFFFFF=58675]="DynamicFFFFFF",t[t.DynamicFortePiano=58676]="DynamicFortePiano",t[t.DynamicNiente=58662]="DynamicNiente",t[t.DynamicSforzando1=58678]="DynamicSforzando1",t[t.DynamicSforzandoPiano=58679]="DynamicSforzandoPiano",t[t.DynamicSforzandoPianissimo=58680]="DynamicSforzandoPianissimo",t[t.DynamicSforzato=58681]="DynamicSforzato",t[t.DynamicSforzatoPiano=58682]="DynamicSforzatoPiano",t[t.DynamicSforzatoFF=58683]="DynamicSforzatoFF",t[t.DynamicRinforzando1=58684]="DynamicRinforzando1",t[t.DynamicRinforzando2=58685]="DynamicRinforzando2",t[t.DynamicForzando=58677]="DynamicForzando",t[t.DynamicCrescendoHairpin=58686]="DynamicCrescendoHairpin",t[t.GraceNoteSlashStemUp=58724]="GraceNoteSlashStemUp",t[t.GraceNoteSlashStemDown=58725]="GraceNoteSlashStemDown",t[t.OrnamentTrill=58726]="OrnamentTrill",t[t.OrnamentTurn=58727]="OrnamentTurn",t[t.OrnamentTurnInverted=58728]="OrnamentTurnInverted",t[t.OrnamentShortTrill=58732]="OrnamentShortTrill",t[t.OrnamentMordent=58733]="OrnamentMordent",t[t.StringsDownBow=58896]="StringsDownBow",t[t.StringsUpBow=58898]="StringsUpBow",t[t.KeyboardPedalPed=58960]="KeyboardPedalPed",t[t.KeyboardPedalUp=58965]="KeyboardPedalUp",t[t.PictEdgeOfCymbal=59177]="PictEdgeOfCymbal",t[t.GuitarString0=59443]="GuitarString0",t[t.GuitarString1=59444]="GuitarString1",t[t.GuitarString2=59445]="GuitarString2",t[t.GuitarString3=59446]="GuitarString3",t[t.GuitarString4=59447]="GuitarString4",t[t.GuitarString5=59448]="GuitarString5",t[t.GuitarString6=59449]="GuitarString6",t[t.GuitarString7=59450]="GuitarString7",t[t.GuitarString8=59451]="GuitarString8",t[t.GuitarString9=59452]="GuitarString9",t[t.GuitarOpenPedal=59453]="GuitarOpenPedal",t[t.GuitarClosePedal=59455]="GuitarClosePedal",t[t.GuitarGolpe=59458]="GuitarGolpe",t[t.GuitarFadeIn=59459]="GuitarFadeIn",t[t.GuitarFadeOut=59460]="GuitarFadeOut",t[t.GuitarVolumeSwell=59461]="GuitarVolumeSwell",t[t.FretboardFilledCircle=59480]="FretboardFilledCircle",t[t.FretboardX=59481]="FretboardX",t[t.FretboardO=59482]="FretboardO",t[t.Tuplet0=59520]="Tuplet0",t[t.Tuplet1=59521]="Tuplet1",t[t.Tuplet2=59522]="Tuplet2",t[t.Tuplet3=59523]="Tuplet3",t[t.Tuplet4=59524]="Tuplet4",t[t.Tuplet5=59525]="Tuplet5",t[t.Tuplet6=59526]="Tuplet6",t[t.Tuplet7=59527]="Tuplet7",t[t.Tuplet8=59528]="Tuplet8",t[t.Tuplet9=59529]="Tuplet9",t[t.TupletColon=59530]="TupletColon",t[t.WiggleTrill=60068]="WiggleTrill",t[t.GuitarVibratoStroke=60082]="GuitarVibratoStroke",t[t.GuitarWideVibratoStroke=60083]="GuitarWideVibratoStroke",t[t.WiggleVibratoMediumFast=60126]="WiggleVibratoMediumFast",t[t.WiggleSawtoothNarrow=60090]="WiggleSawtoothNarrow",t[t.WiggleSawtooth=60091]="WiggleSawtooth",t[t.OctaveBaselineM=60565]="OctaveBaselineM",t[t.OctaveBaselineB=60563]="OctaveBaselineB",t[t.GuitarLeftHandTapping=59456]="GuitarLeftHandTapping",t[t.Fingering0=60688]="Fingering0",t[t.Fingering1=60689]="Fingering1",t[t.Fingering2=60690]="Fingering2",t[t.Fingering3=60691]="Fingering3",t[t.Fingering4=60692]="Fingering4",t[t.Fingering5=60693]="Fingering5",t[t.FingeringPLower=60695]="FingeringPLower",t[t.FingeringTLower=60696]="FingeringTLower",t[t.FingeringILower=60697]="FingeringILower",t[t.FingeringMLower=60698]="FingeringMLower",t[t.FingeringALower=60699]="FingeringALower",t[t.FingeringCLower=60700]="FingeringCLower",t}({}),Tt=class t{static xt=[];static Tt=new Set;static Mt(){const e=t.xt;if(0===e.length)for(const s of Object.values(xt).filter(t=>"number"==typeof t)){const i=s;e.push(i),xt[i].toLowerCase().endsWith("black")&&t.Tt.add(i)}}static getAllMusicFontSymbols(){return t.Mt(),t.xt}static isBlackNoteHead(e){return t.Mt(),t.Tt.has(e)}},Mt=function(t){return t[t.Above=0]="Above",t[t.Inside=1]="Inside",t[t.Below=2]="Below",t[t.Outside=3]="Outside",t}({}),vt=class t{id=0;get uniqueId(){return`${this.elementType}.${this.id}`}elementType;staffLine;noteHeadDefault;noteHeadHalf;noteHeadWhole;techniqueSymbol;techniqueSymbolPlacement;outputMidiNumber;constructor(t="",e=0,s=0,i=xt.None,n=xt.None,r=xt.None,a=xt.None,h=1,o=0){this.id=o,this.elementType=t,this.outputMidiNumber=s,this.staffLine=e,this.noteHeadDefault=i,this.noteHeadHalf=n!==xt.None?n:i,this.noteHeadWhole=r!==xt.None?r:i,this.techniqueSymbol=a,this.techniqueSymbolPlacement=h}static create(e=0,s="",i=0,n=0,r=xt.None,a=xt.None,h=xt.None,o=xt.None,c=1){return new t(s,i,n,r,a,h,o,c,e)}getSymbol(t){switch(t){case w.Whole:return this.noteHeadWhole;case w.Half:return this.noteHeadHalf;default:return this.noteHeadDefault}}},Nt=class t{static instrumentArticulations=new Map([vt.create(38,"Snare",3,38,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole),vt.create(37,"Snare",3,37,xt.NoteheadXBlack,xt.NoteheadXBlack,xt.NoteheadXBlack),vt.create(91,"Snare",3,38,xt.NoteheadDiamondWhite,xt.NoteheadDiamondWhite,xt.NoteheadDiamondWhite),vt.create(42,"Charley",-1,42,xt.NoteheadXBlack,xt.NoteheadXBlack,xt.NoteheadXBlack),vt.create(92,"Charley",-1,46,xt.NoteheadCircleSlash,xt.NoteheadCircleSlash,xt.NoteheadCircleSlash),vt.create(46,"Charley",-1,46,xt.NoteheadCircleX,xt.NoteheadCircleX,xt.NoteheadCircleX),vt.create(44,"Charley",9,44,xt.NoteheadXBlack,xt.NoteheadXBlack,xt.NoteheadXBlack),vt.create(35,"Acoustic Kick Drum",8,35,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole),vt.create(36,"Kick Drum",7,36,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole),vt.create(50,"Tom Very High",1,50,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole),vt.create(48,"Tom High",2,48,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole),vt.create(47,"Tom Medium",4,47,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole),vt.create(45,"Tom Low",5,45,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole),vt.create(43,"Tom Very Low",6,43,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole),vt.create(93,"Ride",0,51,xt.NoteheadXBlack,xt.NoteheadXBlack,xt.NoteheadXBlack,xt.PictEdgeOfCymbal,Mt.Above),vt.create(51,"Ride",0,51,xt.NoteheadXBlack,xt.NoteheadXBlack,xt.NoteheadXBlack),vt.create(53,"Ride",0,53,xt.NoteheadDiamondWhite,xt.NoteheadDiamondWhite,xt.NoteheadDiamondWhite),vt.create(94,"Ride",0,51,xt.NoteheadXBlack,xt.NoteheadXBlack,xt.NoteheadXBlack,xt.ArticStaccatoAbove,Mt.Outside),vt.create(55,"Splash",-2,55,xt.NoteheadXBlack,xt.NoteheadXBlack,xt.NoteheadXBlack),vt.create(95,"Splash",-2,55,xt.NoteheadXBlack,xt.NoteheadXBlack,xt.NoteheadXBlack,xt.ArticStaccatoAbove,Mt.Outside),vt.create(52,"China",-3,52,xt.NoteheadHeavyXHat,xt.NoteheadHeavyXHat,xt.NoteheadHeavyXHat),vt.create(96,"China",-3,52,xt.NoteheadHeavyXHat,xt.NoteheadHeavyXHat,xt.NoteheadHeavyXHat),vt.create(49,"Crash High",-2,49,xt.NoteheadHeavyX,xt.NoteheadHeavyX,xt.NoteheadHeavyX),vt.create(97,"Crash High",-2,49,xt.NoteheadHeavyX,xt.NoteheadHeavyX,xt.NoteheadHeavyX,xt.ArticStaccatoAbove,Mt.Outside),vt.create(57,"Crash Medium",-1,57,xt.NoteheadHeavyX,xt.NoteheadHeavyX,xt.NoteheadHeavyX),vt.create(98,"Crash Medium",-1,57,xt.NoteheadHeavyX,xt.NoteheadHeavyX,xt.NoteheadHeavyX,xt.ArticStaccatoAbove,Mt.Outside),vt.create(99,"Cowbell Low",1,56,xt.NoteheadTriangleUpBlack,xt.NoteheadTriangleUpHalf,xt.NoteheadTriangleUpWhole),vt.create(100,"Cowbell Low",1,56,xt.NoteheadXBlack,xt.NoteheadXHalf,xt.NoteheadXWhole),vt.create(56,"Cowbell Medium",0,56,xt.NoteheadTriangleUpBlack,xt.NoteheadTriangleUpHalf,xt.NoteheadTriangleUpWhole),vt.create(101,"Cowbell Medium",0,56,xt.NoteheadXBlack,xt.NoteheadXHalf,xt.NoteheadXWhole),vt.create(102,"Cowbell High",-1,56,xt.NoteheadTriangleUpBlack,xt.NoteheadTriangleUpHalf,xt.NoteheadTriangleUpWhole),vt.create(103,"Cowbell High",-1,56,xt.NoteheadXBlack,xt.NoteheadXHalf,xt.NoteheadXWhole),vt.create(77,"Woodblock Low",-9,77,xt.NoteheadTriangleUpBlack,xt.NoteheadTriangleUpBlack,xt.NoteheadTriangleUpBlack),vt.create(76,"Woodblock High",-10,76,xt.NoteheadTriangleUpBlack,xt.NoteheadTriangleUpBlack,xt.NoteheadTriangleUpBlack),vt.create(60,"Bongo High",-4,60,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole),vt.create(104,"Bongo High",-5,60,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole,xt.NoteheadParenthesis,Mt.Inside),vt.create(105,"Bongo High",-6,60,xt.NoteheadXBlack,xt.NoteheadXBlack,xt.NoteheadXBlack),vt.create(61,"Bongo Low",-7,61,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole),vt.create(106,"Bongo Low",-8,61,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole,xt.NoteheadParenthesis,Mt.Inside),vt.create(107,"Bongo Low",-16,61,xt.NoteheadXBlack,xt.NoteheadXBlack,xt.NoteheadXBlack),vt.create(66,"Timbale Low",10,66,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole),vt.create(65,"Timbale High",9,65,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole),vt.create(68,"Agogo Low",12,68,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole),vt.create(67,"Agogo High",11,67,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole),vt.create(64,"Conga Low",17,64,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole),vt.create(108,"Conga Low",16,64,xt.NoteheadXBlack,xt.NoteheadXBlack,xt.NoteheadXBlack),vt.create(109,"Conga Low",15,64,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole,xt.NoteheadParenthesis,Mt.Inside),vt.create(63,"Conga High",14,63,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole),vt.create(110,"Conga High",13,63,xt.NoteheadXBlack,xt.NoteheadXBlack,xt.NoteheadXBlack),vt.create(62,"Conga High",19,62,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole,xt.NoteheadParenthesis,Mt.Inside),vt.create(72,"Whistle Low",-11,72,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole),vt.create(71,"Whistle High",-17,71,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole),vt.create(73,"Guiro",38,73,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole),vt.create(74,"Guiro",37,74,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole),vt.create(86,"Surdo",36,86,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole),vt.create(87,"Surdo",35,87,xt.NoteheadXBlack,xt.NoteheadXBlack,xt.NoteheadXBlack,xt.NoteheadParenthesis,Mt.Inside),vt.create(54,"Tambourine",3,54,xt.NoteheadTriangleUpBlack,xt.NoteheadTriangleUpBlack,xt.NoteheadTriangleUpBlack),vt.create(111,"Tambourine",2,54,xt.NoteheadTriangleUpBlack,xt.NoteheadTriangleUpBlack,xt.NoteheadTriangleUpBlack,xt.StringsUpBow,Mt.Above),vt.create(112,"Tambourine",1,54,xt.NoteheadTriangleUpBlack,xt.NoteheadTriangleUpBlack,xt.NoteheadTriangleUpBlack,xt.StringsDownBow,Mt.Above),vt.create(113,"Tambourine",-7,54,xt.NoteheadXBlack,xt.NoteheadXBlack,xt.NoteheadXBlack),vt.create(79,"Cuica",30,79,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole),vt.create(78,"Cuica",29,78,xt.NoteheadXBlack,xt.NoteheadXBlack,xt.NoteheadXBlack),vt.create(58,"Vibraslap",28,58,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole),vt.create(81,"Triangle",27,81,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole),vt.create(80,"Triangle",26,80,xt.NoteheadXBlack,xt.NoteheadXBlack,xt.NoteheadXBlack,xt.NoteheadParenthesis,Mt.Inside),vt.create(114,"Grancassa",25,43,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole),vt.create(115,"Piatti",18,49,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole),vt.create(116,"Piatti",24,49,xt.NoteheadXBlack,xt.NoteheadXBlack,xt.NoteheadXBlack),vt.create(69,"Cabasa",23,69,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole),vt.create(117,"Cabasa",22,69,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole,xt.StringsUpBow,Mt.Outside),vt.create(85,"Castanets",21,85,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole),vt.create(75,"Claves",20,75,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole),vt.create(70,"Left Maraca",-12,70,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole),vt.create(118,"Left Maraca",-13,70,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole,xt.StringsUpBow,Mt.Outside),vt.create(119,"Right Maraca",-14,70,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole),vt.create(120,"Right Maraca",-15,70,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole,xt.StringsUpBow,Mt.Outside),vt.create(82,"Shaker",-23,82,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole),vt.create(122,"Shaker",-24,82,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole,xt.StringsUpBow,Mt.Outside),vt.create(84,"Bell Tree",-18,53,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole),vt.create(123,"Bell Tree",-19,53,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole,xt.StringsUpBow,Mt.Outside),vt.create(83,"Jingle Bell",-20,53,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole),vt.create(83,"Tinkle Bell",-20,53,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole),vt.create(124,"Golpe",-21,62,xt.NoteheadNull,xt.NoteheadNull,xt.NoteheadNull,xt.GuitarGolpe,Mt.Below),vt.create(125,"Golpe",-22,62,xt.NoteheadNull,xt.NoteheadNull,xt.NoteheadNull,xt.GuitarGolpe,Mt.Above),vt.create(39,"Hand Clap",3,39,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole),vt.create(40,"Electric Snare",3,40,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole),vt.create(31,"Sticks",3,40,xt.NoteheadSlashedBlack2,xt.NoteheadSlashedBlack2,xt.NoteheadSlashedBlack2),vt.create(41,"Very Low Floor Tom",5,41,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole),vt.create(59,"Ride Cymbal 2",2,59,xt.NoteheadXBlack,xt.NoteheadXBlack,xt.NoteheadXBlack,xt.PictEdgeOfCymbal,Mt.Above),vt.create(126,"Ride Cymbal 2",2,59,xt.NoteheadXBlack,xt.NoteheadXBlack,xt.NoteheadXBlack),vt.create(127,"Ride Cymbal 2",2,59,xt.NoteheadDiamondWhite,xt.NoteheadDiamondWhite,xt.NoteheadDiamondWhite),vt.create(29,"Ride Cymbal 2",2,59,xt.NoteheadXBlack,xt.NoteheadXBlack,xt.NoteheadXBlack,xt.ArticStaccatoAbove,Mt.Outside),vt.create(30,"Reverse Cymbal",-3,49,xt.NoteheadXBlack,xt.NoteheadXBlack,xt.NoteheadXBlack),vt.create(33,"Metronome",3,37,xt.NoteheadXBlack,xt.NoteheadXBlack,xt.NoteheadXBlack),vt.create(34,"Metronome",3,38,xt.NoteheadBlack,xt.NoteheadBlack,xt.NoteheadBlack)].map(t=>[t.uniqueId,t]));static vt=new Map([["Snare (hit)","Snare.38"],["Snare (side stick)","Snare.37"],["Snare (rim shot)","Snare.91"],["Hi-Hat (closed)","Charley.42"],["Hi-Hat (half)","Charley.92"],["Hi-Hat (open)","Charley.46"],["Pedal Hi-Hat (hit)","Charley.44"],["Kick (hit)","Acoustic Kick Drum.35"],["Kick (hit) 2","Kick Drum.36"],["High Floor Tom (hit)","Tom Very High.50"],["High Tom (hit)","Tom High.48"],["Mid Tom (hit)","Tom Medium.47"],["Low Tom (hit)","Tom Low.45"],["Very Low Tom (hit)","Tom Very Low.43"],["Ride (edge)","Ride.93"],["Ride (middle)","Ride.51"],["Ride (bell)","Ride.53"],["Ride (choke)","Ride.94"],["Splash (hit)","Splash.55"],["Splash (choke)","Splash.95"],["China (hit)","China.52"],["China (choke)","China.96"],["Crash high (hit)","Crash High.49"],["Crash high (choke)","Crash High.97"],["Crash medium (hit)","Crash Medium.57"],["Crash medium (choke)","Crash Medium.98"],["Cowbell low (hit)","Cowbell Low.99"],["Cowbell low (tip)","Cowbell Low.100"],["Cowbell medium (hit)","Cowbell Medium.56"],["Cowbell medium (tip)","Cowbell Medium.101"],["Cowbell high (hit)","Cowbell High.102"],["Cowbell high (tip)","Cowbell High.103"],["Woodblock low (hit)","Woodblock Low.77"],["Woodblock high (hit)","Woodblock High.76"],["Bongo High (hit)","Bongo High.60"],["Bongo High (mute)","Bongo High.104"],["Bongo High (slap)","Bongo High.105"],["Bongo Low (hit)","Bongo Low.61"],["Bongo Low (mute)","Bongo Low.106"],["Bongo Low (slap)","Bongo Low.107"],["Timbale low (hit)","Timbale Low.66"],["Timbale high (hit)","Timbale High.65"],["Agogo low (hit)","Agogo Low.68"],["Agogo high (hit)","Agogo High.67"],["Conga low (hit)","Conga Low.64"],["Conga low (slap)","Conga Low.108"],["Conga low (mute)","Conga Low.109"],["Conga high (hit)","Conga High.63"],["Conga high (slap)","Conga High.110"],["Conga high (mute)","Conga High.62"],["Whistle low (hit)","Whistle Low.72"],["Whistle high (hit)","Whistle High.71"],["Guiro (hit)","Guiro.73"],["Guiro (scrap-return)","Guiro.74"],["Surdo (hit)","Surdo.86"],["Surdo (mute)","Surdo.87"],["Tambourine (hit)","Tambourine.54"],["Tambourine (return)","Tambourine.111"],["Tambourine (roll)","Tambourine.112"],["Tambourine (hand)","Tambourine.113"],["Cuica (open)","Cuica.79"],["Cuica (mute)","Cuica.78"],["Vibraslap (hit)","Vibraslap.58"],["Triangle (hit)","Triangle.81"],["Triangle (mute)","Triangle.80"],["Grancassa (hit)","Grancassa.114"],["Piatti (hit)","Piatti.115"],["Piatti (hand)","Piatti.116"],["Cabasa (hit)","Cabasa.69"],["Cabasa (return)","Cabasa.117"],["Castanets (hit)","Castanets.85"],["Claves (hit)","Claves.75"],["Left Maraca (hit)","Left Maraca.70"],["Left Maraca (return)","Left Maraca.118"],["Right Maraca (hit)","Right Maraca.119"],["Right Maraca (return)","Right Maraca.120"],["Shaker (hit)","Shaker.82"],["Shaker (return)","Shaker.122"],["Bell Tree (hit)","Bell Tree.84"],["Bell Tree (return)","Bell Tree.123"],["Jingle Bell (hit)","Jingle Bell.83"],["Tinkle Bell (hit)","Tinkle Bell.83"],["Golpe (thumb)","Golpe.124"],["Golpe (finger)","Golpe.125"],["Hand Clap (hit)","Hand Clap.39"],["Electric Snare (hit)","Electric Snare.40"],["Snare (side stick) 2","Sticks.31"],["Low Floor Tom (hit)","Very Low Floor Tom.41"],["Ride (edge) 2","Ride Cymbal 2.59"],["Ride (middle) 2","Ride Cymbal 2.126"],["Ride (bell) 2","Ride Cymbal 2.127"],["Ride (choke) 2","Ride Cymbal 2.29"],["Reverse Cymbal (hit)","Reverse Cymbal.30"],["Metronome (hit)","Metronome.33"],["Metronome (bell)","Metronome.34"]]);static Nt=[[35,35,35],[38,91,37],[99,100,99],[56,100,56],[102,103,102],[43,43,43],[45,45,45],[47,47,47],[48,48,48],[50,50,50],[42,92,46],[44,44,44],[57,98,57],[49,97,49],[55,95,55],[51,93,127],[52,96,52]];static articulationFromElementVariation(e,s){return e<t.Nt.length?(s>=t.Nt.length&&(s=0),t.Nt[e][s]):38}static getArticulationName(e){const s=t.getArticulation(e);if(s){const e=s.uniqueId;for(const[s,i]of t.instrumentArticulationNames)if(i===e)return s}else{const s=`.${e.percussionArticulation}`;for(const[e,i]of t.instrumentArticulationNames)if(i.endsWith(s))return e}return"Snare (hit)"}static getArticulation(e){const s=e.percussionArticulation;if(s<0)return null;const i=e.beat.voice.bar.staff.track.percussionArticulations;return s<i.length?i[s]:t.getArticulationById(s)}static Pt;static Ct(){let e=t.Pt;if(!e){e=new Map;for(const s of t.instrumentArticulations.values())e.set(s.id,s);t.Pt=e}return e}static instrumentArticulationIds(){return t.Ct().keys()}static getArticulationById(e){const s=t.Ct();return s.has(e)?s.get(e):null}static getElementAndVariation(e){const s=t.getArticulation(e);if(!s)return[-1,-1];for(let e=0;e<t.Nt.length;e++){const i=t.Nt[e];for(let n=0;n<i.length;n++)if(t.getArticulationById(i[n])?.outputMidiNumber===s.outputMidiNumber)return[e,n]}return[-1,-1]}static instrumentArticulationNames=t.Et([new Map([["Hand (hit)","Bongo Low.61"],["Tinkle Bell (hat)","Tingle Bell.83"],["Cymbal (hit)","Reverse Cymbal.30"],["Snare (side stick) 3","Snare.37"],["Snare (hit) 2","Snare.38"],["Snare (hit) 3","Snare.40"],["Agogo tow (hit)","Agogo Low.68"],["Triangle (rnute)","Triangle.80"],["Hand (mute)","Bongo High.104"],["Hand (slap)","Bongo High.105"],["Hand (mute) 2","Bongo Low.106"],["Hand (slap) 2","Bongo Low.107"],["Piatti (hat)","Piatti.115"],["Bell Tee (return)","Bell Tree.123"]]),t.vt]);static Et(t){const e=new Map(t[0]);for(let s=1;s<t.length;s++)for(const[i,n]of t[s])e.set(i,n);return e}static Ft;static tryMatchKnownArticulation(e){let s=t.Ft;if(!s){s=new Map;for(const e of t.instrumentArticulations.values())s.has(e.outputMidiNumber)||s.set(e.outputMidiNumber,e);t.Ft=s}return s.has(e.outputMidiNumber)?s.get(e.outputMidiNumber).id:-1}static At;static getInstrumentArticulationByUniqueId(e){let s=t.At;if(!s){s=new Map;for(const e of t.instrumentArticulations.values())s.set(e.uniqueId,e);t.At=s}return s.has(e)?s.get(e):void 0}},Pt=function(t){return t[t.None=0]="None",t[t.InvertedTurn=1]="InvertedTurn",t[t.Turn=2]="Turn",t[t.UpperMordent=3]="UpperMordent",t[t.LowerMordent=4]="LowerMordent",t}({}),Ct=class{tieDestinationNoteId=-1;tieOriginNoteId=-1;slurDestinationNoteId=-1;slurOriginNoteId=-1;hammerPullDestinationNoteId=-1;hammerPullOriginNoteId=-1;slideTargetNoteId=-1;slideOriginNoteId=-1},Et=function(t){return t[t.Effects=0]="Effects",t[t.StandardNotationNoteHead=1]="StandardNotationNoteHead",t[t.StandardNotationAccidentals=2]="StandardNotationAccidentals",t[t.StandardNotationEffects=3]="StandardNotationEffects",t[t.GuitarTabFretNumber=4]="GuitarTabFretNumber",t[t.GuitarTabEffects=5]="GuitarTabEffects",t[t.SlashNoteHead=6]="SlashNoteHead",t[t.SlashEffects=7]="SlashEffects",t[t.NumberedNumber=8]="NumberedNumber",t[t.NumberedAccidentals=9]="NumberedAccidentals",t[t.NumberedEffects=10]="NumberedEffects",t}({}),Ft=class extends ${noteHead;noteHeadCenterOnStem},At=class t{static globalNoteId=0;static resetIds(){t.globalNoteId=0}id=t.globalNoteId++;index=0;accentuated=k.None;bendType=b.None;bendStyle=p.Default;bendOrigin=null;isContinuedBend=!1;bendPoints=null;maxBendPoint=null;get hasBend(){return null!==this.bendPoints&&this.bendType!==b.None}get isStringed(){return this.string>=0}fret=-1;string=-1;showStringNumber=!1;get isPiano(){return!this.isStringed&&this.octave>=0&&this.tone>=0}octave=-1;tone=-1;get isPercussion(){return!this.isStringed&&this.percussionArticulation>=0}get element(){return this.isPercussion?Nt.getElementAndVariation(this)[0]:-1}get variation(){return this.isPercussion?Nt.getElementAndVariation(this)[1]:-1}percussionArticulation=-1;isVisible=!0;isLeftHandTapped=!1;isHammerPullOrigin=!1;get isHammerPullDestination(){return!!this.hammerPullOrigin}hammerPullOrigin=null;hammerPullDestination=null;get isSlurOrigin(){return!!this.slurDestination}isSlurDestination=!1;slurOrigin=null;slurDestination=null;get isHarmonic(){return this.harmonicType!==B.None}harmonicType=B.None;harmonicValue=0;isGhost=!1;isLetRing=!1;letRingDestination=null;isPalmMute=!1;palmMuteDestination=null;isDead=!1;isStaccato=!1;slideInType=T.None;slideOutType=M.None;slideTarget=null;slideOrigin=null;vibrato=P.None;tieOrigin=null;tieDestination=null;isTieDestination=!1;get isTieOrigin(){return null!==this.tieDestination}leftHandFinger=S.Unknown;rightHandFinger=S.Unknown;get isFingering(){return this.leftHandFinger!==S.Unknown||this.rightHandFinger!==S.Unknown}trillValue=-1;get trillFret(){return this.trillValue-this.stringTuning}get isTrill(){return this.trillValue>=0}trillSpeed=w.ThirtySecond;durationPercent=1;accidentalMode=_.Default;beat;dynamics=o.F;isEffectSlurOrigin=!1;hasEffectSlur=!1;get isEffectSlurDestination(){return!!this.effectSlurOrigin}effectSlurOrigin=null;effectSlurDestination=null;effectSlur=null;ornament=Pt.None;style;get stringTuning(){return this.beat.voice.bar.staff.capo+t.getStringTuning(this.beat.voice.bar.staff,this.string)}static getStringTuning(t,e){return t.tuning.length>0?t.tuning[t.tuning.length-(e-1)-1]:0}get realValue(){return this.calculateRealValue(!0,!0)}get realValueWithoutHarmonic(){return this.calculateRealValue(!0,!1)}calculateRealValue(t,e){const s=t?this.beat.voice.bar.staff.transpositionPitch:0;if(e){let e=this.calculateRealValue(t,!1);return this.isStringed&&(this.harmonicType===B.Natural?e=this.harmonicPitch+this.stringTuning-s:e+=this.harmonicPitch),e}return this.isPercussion?this.percussionArticulation:this.isStringed?this.fret+this.stringTuning-s:this.isPiano?12*this.octave+this.tone-s:0}get harmonicPitch(){if(this.harmonicType===B.None||!this.isStringed)return 0;const t=this.harmonicValue;return Bt.isAlmostEqualTo(t,2.4)?36:Bt.isAlmostEqualTo(t,2.7)?34:t<3?0:t<=3.5?31:t<=4?28:t<=5?24:t<=6?34:t<=7?19:t<=8.5?36:t<=9?28:t<=10?34:t<=11?0:t<=12?12:t<14?0:t<=15?34:t<=16?28:t<=17?36:t<=18?0:t<=19?19:t<=21?0:t<=22?36:t<=24?24:0}get initialBendValue(){return this.hasBend?Math.floor(this.bendPoints[0].value/2):this.bendOrigin?Math.floor(this.bendOrigin.bendPoints[this.bendOrigin.bendPoints.length-1].value/2):this.isTieDestination&&this.tieOrigin.bendOrigin?Math.floor(this.tieOrigin.bendOrigin.bendPoints[this.tieOrigin.bendOrigin.bendPoints.length-1].value/2):this.beat.hasWhammyBar?Math.floor(this.beat.whammyBarPoints[0].value/2):this.beat.isContinuedWhammy?Math.floor(this.beat.previousBeat.whammyBarPoints[this.beat.previousBeat.whammyBarPoints.length-1].value/2):0}get displayValue(){return this.displayValueWithoutBend+this.initialBendValue}get displayValueWithoutBend(){let t=this.realValue;switch(this.harmonicType!==B.Natural&&this.harmonicType!==B.None&&(t-=this.harmonicPitch),this.beat.ottava){case x._:t-=24;break;case x.T:t-=12;break;case x.Regular:break;case x.M:t+=12;break;case x.L:t+=24}switch(this.beat.voice.bar.clefOttava){case x._:t-=24;break;case x.T:t-=12;break;case x.Regular:break;case x.M:t+=12;break;case x.L:t+=24}return t-this.beat.voice.bar.staff.displayTranspositionPitch}get hasQuarterToneOffset(){return this.hasBend?this.bendPoints[0].value%2!=0:this.bendOrigin?this.bendOrigin.bendPoints[this.bendOrigin.bendPoints.length-1].value%2!=0:this.beat.hasWhammyBar?this.beat.whammyBarPoints[0].value%2!=0:!!this.beat.isContinuedWhammy&&this.beat.previousBeat.whammyBarPoints[this.beat.previousBeat.whammyBarPoints.length-1].value%2!=0}addBendPoint(t){let e=this.bendPoints;null===e&&(e=[],this.bendPoints=e),e.push(t),(!this.maxBendPoint||t.value>this.maxBendPoint.value)&&(this.maxBendPoint=t),this.bendType===b.None&&(this.bendType=b.Custom)}finish(e,s=null){const i=new L(()=>t.nextNoteOnSameLine(this)),n=e&&e.notation.notationMode===F.SongBook;if(this.isTieDestination&&(this.chain(s),n&&this.tieOrigin&&this.tieOrigin.isLetRing&&(this.isLetRing=!0)),this.isLetRing&&(i.value&&i.value.isLetRing?this.letRingDestination=i.value:this.letRingDestination=this,n&&this.isTieDestination&&!this.tieOrigin.hasBend&&(this.isVisible=!1)),this.isPalmMute&&(i.value&&i.value.isPalmMute?this.palmMuteDestination=i.value:this.palmMuteDestination=this),this.isHammerPullOrigin){const e=t.findHammerPullDestination(this);e?(this.hammerPullDestination=e,e.hammerPullOrigin=this):this.isHammerPullOrigin=!1}switch(this.slideOutType){case M.Shift:case M.Legato:this.slideTarget||(this.slideTarget=i.value),this.slideTarget?this.slideTarget.slideOrigin=this:this.slideOutType=M.None}let r=null,a=null;if(this.isHammerPullOrigin&&this.hammerPullDestination?(r=this.hammerPullDestination,a=N.HammerPull):this.slideOutType===M.Legato&&this.slideTarget&&(r=this.slideTarget,a=N.LegatoSlide),r)if(this.hasEffectSlur=!0,this.effectSlurOrigin&&this.beat.pickStroke===_t.None){const t=this.effectSlurOrigin;t.effectSlurDestination=r,r.effectSlurOrigin=t,this.effectSlurOrigin=null,null!==a&&null!==t.effectSlur&&(t.effectSlur.destinationNote=r,t.effectSlur.segments.push({fromNote:this,toNote:r,kind:a,text:null}))}else{this.isEffectSlurOrigin=!0,this.effectSlurDestination=r,r.effectSlurOrigin=this;const t=new v;t.originNote=this,t.destinationNote=r,null!==a&&t.segments.push({fromNote:this,toNote:r,kind:a,text:null}),this.effectSlur=t}const h=this.bendPoints,o=null!=h&&h.length>0;if(o){const t=this.isTieDestination&&this.tieOrigin.hasBend;this.isContinuedBend=t}else this.bendType=b.None;if(o&&this.bendType===b.Custom)if(4===h.length){const t=h[0],e=h[1],s=h[2],i=h[3];e.value===s.value?i.value>t.value?e.value>i.value?this.bendType=b.BendRelease:!this.isContinuedBend&&t.value>0?(this.bendType=b.PrebendBend,h.splice(2,1),h.splice(1,1)):(this.bendType=b.Bend,h.splice(2,1),h.splice(1,1)):i.value<t.value?this.isContinuedBend?(this.bendType=b.Release,h.splice(2,1),h.splice(1,1)):(this.bendType=b.PrebendRelease,h.splice(2,1),h.splice(1,1)):e.value>t.value?this.bendType=b.BendRelease:t.value>0&&!this.isContinuedBend?(this.bendType=b.Prebend,h.splice(2,1),h.splice(1,1)):(this.bendType=b.Hold,h.splice(2,1),h.splice(1,1)):O.warning("Model","Unsupported bend type detected, fallback to custom",null)}else if(3===h.length){const t=h[0],e=h[1],s=h[2];s.value>t.value?e.value>s.value?(this.bendType=b.BendRelease,h.splice(1,0,new f(e.offset,e.value))):!this.isContinuedBend&&t.value>0?(this.bendType=b.PrebendBend,h.splice(1,1)):(this.bendType=b.Bend,h.splice(1,1)):s.value<t.value?this.isContinuedBend?(this.bendType=b.Release,h.splice(1,1)):(this.bendType=b.PrebendRelease,h.splice(1,1)):e.value>t.value?(this.bendType=b.BendRelease,h.splice(1,0,new f(e.offset,e.value))):t.value>0&&!this.isContinuedBend?(this.bendType=b.Prebend,h.splice(1,1)):(this.bendType=b.Hold,h.splice(1,1))}else if(2===h.length){const t=h[0],e=h[1];e.value>t.value?!this.isContinuedBend&&t.value>0?this.bendType=b.PrebendBend:this.bendType=b.Bend:e.value<t.value?this.isContinuedBend?this.bendType=b.Release:this.bendType=b.PrebendRelease:t.value>0&&!this.isContinuedBend?this.bendType=b.Prebend:this.bendType=b.Hold}this.initialBendValue>0&&(this.accidentalMode=_.Default)}static Dt=3;static nextNoteOnSameLine(e){let s=e.beat.nextBeat;for(;s&&s.voice.bar.index<=e.beat.voice.bar.index+t.Dt;){const t=s.getNoteOnString(e.string);if(t)return t;s=s.nextBeat}return null}static findHammerPullDestination(e){let s=e.beat.nextBeat;for(;s&&s.voice.bar.index<=e.beat.voice.bar.index+t.Dt;){let t=s.getNoteOnString(e.string);if(t)return t;for(let i=e.string;i>0;i--)if(t=s.getNoteOnString(i),t){if(t.isLeftHandTapped)return t;break}for(let i=e.string;i<=e.beat.voice.bar.staff.tuning.length;i++)if(t=s.getNoteOnString(i),t){if(t.isLeftHandTapped)return t;break}s=s.nextBeat}return null}static findTieOrigin(e){let s=e.beat.previousBeat;for(;s&&s.voice.bar.index>=e.beat.voice.bar.index-t.Dt;){if(e.isStringed){const t=s.getNoteOnString(e.string);if(t)return t}else if(-1===e.octave&&-1===e.tone){if(e.index<s.notes.length)return s.notes[e.index]}else{const t=s.getNoteWithRealValue(e.realValue);if(t)return t}s=s.previousBeat}return null}static Lt="NoteIdLookup";Wt=null;chain(e=null){if(null!==e)if(null!==this.Wt){let s;e.has(t.Lt)?s=e.get(t.Lt):(s=new Map,e.set(t.Lt,s)),-1===this.Wt.hammerPullDestinationNoteId&&-1===this.Wt.tieDestinationNoteId&&-1===this.Wt.slurDestinationNoteId&&-1===this.Wt.slideTargetNoteId||s.set(this.id,this),-1!==this.Wt.hammerPullOriginNoteId&&(this.hammerPullOrigin=s.get(this.Wt.hammerPullOriginNoteId),this.hammerPullOrigin.hammerPullDestination=this),-1!==this.Wt.tieOriginNoteId&&(this.tieOrigin=s.get(this.Wt.tieOriginNoteId),this.tieOrigin.tieDestination=this),-1!==this.Wt.slurOriginNoteId&&(this.slurOrigin=s.get(this.Wt.slurOriginNoteId),this.slurOrigin.slurDestination=this),-1!==this.Wt.slideOriginNoteId&&(this.slideOrigin=s.get(this.Wt.slideOriginNoteId),this.slideOrigin.slideTarget=this),this.Wt=null}else{if(!this.isTieDestination&&null===this.tieOrigin)return;const e=this.tieOrigin??t.findTieOrigin(this);e?(e.tieDestination=this,this.tieOrigin=e,this.fret=e.fret,this.octave=e.octave,this.tone=e.tone,e.hasBend&&(this.bendOrigin=this.tieOrigin)):this.isTieDestination=!1}}toJson(t){null!==this.tieDestination&&t.set("tiedestinationnoteid",this.tieDestination.id),null!==this.tieOrigin&&t.set("tieoriginnoteid",this.tieOrigin.id),null!==this.slurDestination&&t.set("slurdestinationnoteid",this.slurDestination.id),null!==this.slurOrigin&&t.set("sluroriginnoteid",this.slurOrigin.id),null!==this.hammerPullOrigin&&t.set("hammerpulloriginnoteid",this.hammerPullOrigin.id),null!==this.hammerPullDestination&&t.set("hammerpulldestinationnoteid",this.hammerPullDestination.id),null!==this.slideTarget&&t.set("slidetargetnoteid",this.slideTarget.id),null!==this.slideOrigin&&t.set("slideoriginnoteid",this.slideOrigin.id)}setProperty(t,e){switch(t){case"tiedestinationnoteid":return null==this.Wt&&(this.Wt=new Ct),this.Wt.tieDestinationNoteId=e,!0;case"tieoriginnoteid":return null==this.Wt&&(this.Wt=new Ct),this.Wt.tieOriginNoteId=e,!0;case"slurdestinationnoteid":return null==this.Wt&&(this.Wt=new Ct),this.Wt.slurDestinationNoteId=e,!0;case"sluroriginnoteid":return null==this.Wt&&(this.Wt=new Ct),this.Wt.slurOriginNoteId=e,!0;case"hammerpulloriginnoteid":return null==this.Wt&&(this.Wt=new Ct),this.Wt.hammerPullOriginNoteId=e,!0;case"hammerpulldestinationnoteid":return null==this.Wt&&(this.Wt=new Ct),this.Wt.hammerPullDestinationNoteId=e,!0;case"slidetargetnoteid":return null==this.Wt&&(this.Wt=new Ct),this.Wt.slideTargetNoteId=e,!0;case"slideoriginnoteid":return null==this.Wt&&(this.Wt=new Ct),this.Wt.slideOriginNoteId=e,!0}return!1}},Dt=class t{static Rt=1920;static Ot=960;static It=480;static Gt=240;static Ht=120;static $t=60;static Vt=30;static zt=15;static Ut=[t.Rt,t.Ot,t.It,t.Gt,t.Ht,t.$t,t.Vt,t.zt];Xt=!0;totalDuration=0;beats=[];voice;isFull=!1;constructor(t){this.voice=t}check(e){if(0===this.beats.length)return this.beats.push(e),this.totalDuration+=e.playbackDuration,!0;if(e.graceType!==y.None)return!0;if(e.voice!==this.voice||this.isFull||e.tupletNumerator!==this.beats[0].tupletNumerator||e.tupletDenominator!==this.beats[0].tupletDenominator)return!1;if(e.displayDuration!==this.beats[0].displayDuration&&(this.Xt=!1),this.beats.push(e),this.totalDuration+=e.displayDuration,this.Xt)this.beats.length===this.beats[0].tupletNumerator&&(this.isFull=!0);else{const e=this.beats[0].tupletNumerator/this.beats[0].tupletDenominator|0;for(const s of t.Ut)if(this.totalDuration===s*e){this.isFull=!0;break}}return!0}},Lt=function(t){return t[t.None=0]="None",t[t.Custom=1]="Custom",t[t.Dive=2]="Dive",t[t.Dip=3]="Dip",t[t.Hold=4]="Hold",t[t.Predive=5]="Predive",t[t.PrediveDive=6]="PrediveDive",t}({}),Wt=function(t){return t[t.None=0]="None",t[t.Thumb=1]="Thumb",t[t.Finger=2]="Finger",t}({}),Rt=function(t){return t[t.None=0]="None",t[t.FadeIn=1]="FadeIn",t[t.FadeOut=2]="FadeOut",t[t.VolumeSwell=3]="VolumeSwell",t}({}),Ot=function(t){return t[t.None=0]="None",t[t.Open=1]="Open",t[t.Closed=2]="Closed",t}({}),It=function(t){return t[t.None=0]="None",t[t.Full=1]="Full",t[t.Half=2]="Half",t}({}),Gt=function(t){return t[t.None=0]="None",t[t.Ii=1]="Ii",t[t.Mi=2]="Mi",t[t.MiiTriplet=3]="MiiTriplet",t[t.MiiAnapaest=4]="MiiAnapaest",t[t.PmpTriplet=5]="PmpTriplet",t[t.PmpAnapaest=6]="PmpAnapaest",t[t.PeiTriplet=7]="PeiTriplet",t[t.PeiAnapaest=8]="PeiAnapaest",t[t.PaiTriplet=9]="PaiTriplet",t[t.PaiAnapaest=10]="PaiAnapaest",t[t.AmiTriplet=11]="AmiTriplet",t[t.AmiAnapaest=12]="AmiAnapaest",t[t.Ppp=13]="Ppp",t[t.Amii=14]="Amii",t[t.Amip=15]="Amip",t[t.Eami=16]="Eami",t[t.Eamii=17]="Eamii",t[t.Peami=18]="Peami",t}({}),Ht=function(t){return t[t.Default=0]="Default",t[t.BuzzRoll=1]="BuzzRoll",t}({}),$t=class{static minMarks=0;static maxMarks=5;marks=0;style=0;getDuration(t){let e=this.marks;e<1&&(e=1);const s=t*Math.pow(2,e);return s<=w.TwoHundredFiftySixth?s:w.TwoHundredFiftySixth}getDurationAsTicks(t){let e=this.marks;e<1&&(e=1);const s=t*Math.pow(2,e);return c.valueToTicks(s)}},Vt=function(t){return t[t.Auto=0]="Auto",t[t.ForceSplitToNext=1]="ForceSplitToNext",t[t.ForceMergeWithNext=2]="ForceMergeWithNext",t[t.ForceSplitOnSecondaryToNext=3]="ForceSplitOnSecondaryToNext",t}({}),zt=function(t){return t[t.Effects=0]="Effects",t[t.StandardNotationStem=1]="StandardNotationStem",t[t.StandardNotationFlags=2]="StandardNotationFlags",t[t.StandardNotationBeams=3]="StandardNotationBeams",t[t.StandardNotationTuplet=4]="StandardNotationTuplet",t[t.StandardNotationEffects=5]="StandardNotationEffects",t[t.StandardNotationRests=6]="StandardNotationRests",t[t.GuitarTabStem=7]="GuitarTabStem",t[t.GuitarTabFlags=8]="GuitarTabFlags",t[t.GuitarTabBeams=9]="GuitarTabBeams",t[t.GuitarTabTuplet=10]="GuitarTabTuplet",t[t.GuitarTabEffects=11]="GuitarTabEffects",t[t.GuitarTabRests=12]="GuitarTabRests",t[t.SlashStem=13]="SlashStem",t[t.SlashFlags=14]="SlashFlags",t[t.SlashBeams=15]="SlashBeams",t[t.SlashTuplet=16]="SlashTuplet",t[t.SlashRests=17]="SlashRests",t[t.SlashEffects=18]="SlashEffects",t[t.NumberedDuration=19]="NumberedDuration",t[t.NumberedEffects=20]="NumberedEffects",t[t.NumberedRests=21]="NumberedRests",t[t.NumberedTuplet=22]="NumberedTuplet",t}({}),Ut=class extends ${},Xt=class t{static jt=0;static resetIds(){t.jt=0}id=t.jt++;index=0;previousBeat=null;nextBeat=null;get isLastOfVoice(){return this.index===this.voice.beats.length-1}voice;notes=[];noteStringLookup=new Map;noteValueLookup=new Map;isEmpty=!1;whammyStyle=p.Default;ottava=x.Regular;fermata=null;isLegatoOrigin=!1;get isLegatoDestination(){return!!this.previousBeat&&this.previousBeat.isLegatoOrigin}minNote=null;maxNote=null;maxStringNote=null;minStringNote=null;duration=w.Quarter;get isRest(){return this.isEmpty||!this.deadSlapped&&0===this.notes.length}get isFullBarRest(){return this.isRest&&1===this.voice.beats.length&&this.duration===w.Whole}isLetRing=!1;isPalmMute=!1;automations=[];dots=0;get fadeIn(){return this.fade===Rt.FadeIn}set fadeIn(t){this.fade=t?Rt.FadeIn:Rt.None}fade=Rt.None;lyrics=null;get hasRasgueado(){return this.rasgueado!==Gt.None}pop=!1;slap=!1;tap=!1;text=null;slashed=!1;deadSlapped=!1;brushType=m.None;brushDuration=0;tupletDenominator=-1;tupletNumerator=-1;get hasTuplet(){return!(-1===this.tupletDenominator&&-1===this.tupletNumerator||1===this.tupletDenominator&&1===this.tupletNumerator)}tupletGroup=null;isContinuedWhammy=!1;whammyBarType=Lt.None;whammyBarPoints=null;maxWhammyPoint=null;minWhammyPoint=null;get hasWhammyBar(){return null!==this.whammyBarPoints&&this.whammyBarType!==Lt.None}vibrato=P.None;chordId=null;get hasChord(){return!!this.chordId}get chord(){return this.chordId?this.voice.bar.staff.getChord(this.chordId):null}graceType=y.None;graceGroup=null;graceIndex=-1;pickStroke=_t.None;get isTremolo(){return void 0!==this.tremoloPicking}tremoloPicking;get tremoloSpeed(){const t=this.tremoloPicking;return t?t.getDuration(this.duration):null}set tremoloSpeed(t){if(null===t)return void(this.tremoloPicking=void 0);let e=this.tremoloPicking;switch(void 0===e&&(e=new $t,this.tremoloPicking=e),t){case w.Eighth:e.marks=1;break;case w.Sixteenth:e.marks=2;break;case w.ThirtySecond:e.marks=3;break;case w.SixtyFourth:e.marks=4;break;case w.OneHundredTwentyEighth:e.marks=5}}crescendo=g.None;displayStart=0;get displayEnd(){return this.displayStart+this.displayDuration}playbackStart=0;displayDuration=0;playbackDuration=0;overrideDisplayDuration;golpe=Wt.None;get absoluteDisplayStart(){return this.voice.bar.masterBar.start+this.displayStart}get absolutePlaybackStart(){return this.voice.bar.masterBar.start+this.playbackStart}dynamics=o.F;invertBeamDirection=!1;preferredBeamDirection=null;isEffectSlurOrigin=!1;get isEffectSlurDestination(){return!!this.effectSlurOrigin}effectSlurOrigin=null;effectSlurDestination=null;get effectSlur(){for(const t of this.notes)if(null!==t.effectSlur)return t.effectSlur;return null}beamingMode=0;wahPedal=Ot.None;barreFret=-1;barreShape=It.None;get isBarre(){return this.barreShape!==It.None&&this.barreFret>=0}rasgueado=Gt.None;showTimer=!1;timer=null;style;addWhammyBarPoint(t){let e=this.whammyBarPoints;null===e&&(e=[],this.whammyBarPoints=e),e.push(t),(!this.maxWhammyPoint||t.value>this.maxWhammyPoint.value)&&(this.maxWhammyPoint=t),(!this.minWhammyPoint||t.value<this.minWhammyPoint.value)&&(this.minWhammyPoint=t),this.whammyBarType===Lt.None&&(this.whammyBarType=Lt.Custom)}removeWhammyBarPoint(t){const e=this.whammyBarPoints;if(null===e||t<0||t>=e.length)return;e.splice(t,1);const s=e[t];if(s===this.maxWhammyPoint){this.maxWhammyPoint=null;for(const t of e)(!this.maxWhammyPoint||t.value>this.maxWhammyPoint.value)&&(this.maxWhammyPoint=t)}if(s===this.minWhammyPoint){this.minWhammyPoint=null;for(const t of e)(!this.minWhammyPoint||t.value<this.minWhammyPoint.value)&&(this.minWhammyPoint=t)}}addNote(t){t.beat=this,t.index=this.notes.length,this.notes.push(t),t.isStringed&&this.noteStringLookup.set(t.string,t)}removeNote(t){const e=this.notes.indexOf(t);e>=0&&(this.notes.splice(e,1),t.isStringed&&this.noteStringLookup.delete(t.string))}getAutomation(t){for(let e=0,s=this.automations.length;e<s;e++){const s=this.automations[e];if(s.type===t)return s}return null}getNoteOnString(t){return this.noteStringLookup.has(t)?this.noteStringLookup.get(t):null}Jt(){if(void 0!==this.overrideDisplayDuration)return this.overrideDisplayDuration;if(this.isFullBarRest)return this.voice.bar.masterBar.calculateDuration();let t=c.toTicks(this.duration);return 2===this.dots?t=c.applyDot(t,!0):1===this.dots&&(t=c.applyDot(t,!1)),this.tupletDenominator>0&&this.tupletNumerator>=0&&(t=c.applyTuplet(t,this.tupletNumerator,this.tupletDenominator)),t}updateDurations(){const t=this.Jt();switch(this.playbackDuration=t,this.graceType){case y.BeforeBeat:case y.OnBeat:switch(this.duration){case w.Sixteenth:this.playbackDuration=c.toTicks(w.SixtyFourth);break;case w.ThirtySecond:this.playbackDuration=c.toTicks(w.OneHundredTwentyEighth);break;default:this.playbackDuration=c.toTicks(w.ThirtySecond)}this.displayDuration=0;break;case y.BendGrace:this.playbackDuration/=2,this.displayDuration=0;break;default:this.displayDuration=t;const e=this.previousBeat;e&&e.graceType===y.BendGrace&&(this.playbackDuration=e.playbackDuration)}}finishTuplet(){const t=this.previousBeat;let e=t?t.tupletGroup:null;(this.hasTuplet||this.graceType!==y.None&&e)&&(t&&e&&e.check(this)||(e=new Dt(this.voice),e.check(this)),this.tupletGroup=e);const s=this.voice.bar.masterBar.calculateDuration(!1),i=[];for(const t of this.automations)0===t.ratioPosition&&(t.ratioPosition=this.playbackStart/s),t.type!==l.Tempo&&i.push(t);this.automations=i}finish(e,s=null){switch(null===this.getAutomation(l.Instrument)&&0===this.index&&0===this.voice.index&&0===this.voice.bar.index&&0===this.voice.bar.staff.index&&this.automations.push(d.buildInstrumentAutomation(!1,0,this.voice.bar.staff.track.playbackInfo.program)),this.graceType){case y.OnBeat:case y.BeforeBeat:const t=this.graceGroup.beats.length;this.duration=1===t?w.Eighth:2===t?w.Sixteenth:w.ThirtySecond}this.brushType===m.None&&(this.brushDuration=0);const i=this.tremoloPicking;void 0!==i&&(i.marks<$t.minMarks||i.marks>$t.maxMarks)&&(this.tremoloPicking=void 0);const n=e?e.notation.notationMode:F.GuitarPro;let r="grad"===this.text||"grad."===this.text;r&&n===F.SongBook&&(this.text="");let a=!1;this.minNote=null,this.maxNote=null,this.minStringNote=null,this.maxStringNote=null;let h=0,o=!1;for(let t=0,i=this.notes.length;t<i;t++){const i=this.notes[t];if(i.dynamics=this.dynamics,i.finish(e,s),i.isLetRing&&(this.isLetRing=!0),i.isPalmMute&&(this.isPalmMute=!0),n===F.SongBook&&i.hasBend&&this.graceType!==y.BendGrace){if(!i.isTieOrigin)switch(i.bendType){case b.Bend:case b.PrebendRelease:case b.PrebendBend:a=!0}r||i.bendStyle===p.Gradual?(r=!0,i.bendStyle=p.Gradual,a=!1):i.bendStyle=p.Fast}i.isVisible&&(h++,(!this.minNote||i.realValue<this.minNote.realValue)&&(this.minNote=i),(!this.maxNote||i.realValue>this.maxNote.realValue)&&(this.maxNote=i),(!this.minStringNote||i.string<this.minStringNote.string)&&(this.minStringNote=i),(!this.maxStringNote||i.string>this.maxStringNote.string)&&(this.maxStringNote=i),i.hasEffectSlur&&(o=!0))}if(o&&(this.effectSlurOrigin?(this.effectSlurOrigin.effectSlurDestination=this.nextBeat,this.effectSlurOrigin.effectSlurDestination&&(this.effectSlurOrigin.effectSlurDestination.effectSlurOrigin=this.effectSlurOrigin),this.effectSlurOrigin=null):(this.isEffectSlurOrigin=!0,this.effectSlurDestination=this.nextBeat,this.effectSlurDestination&&(this.effectSlurDestination.effectSlurOrigin=this))),this.notes.length>0&&0===h&&(this.isEmpty=!0),this.isRest||this.isLetRing&&this.isPalmMute)this.isRest&&this.previousBeat&&e&&e.notation.notationMode===F.GuitarPro&&(this.previousBeat.isLetRing&&(this.isLetRing=!0),this.previousBeat.isPalmMute&&(this.isPalmMute=!0));else{let t=this.previousBeat;for(;t&&t.isRest;)this.isLetRing||(t.isLetRing=!1),this.isPalmMute||(t.isPalmMute=!1),t=t.previousBeat}const c=this.whammyBarPoints,u=null!==c&&c.length>0;if(u){const t=!!this.previousBeat&&this.previousBeat.hasWhammyBar;this.isContinuedWhammy=t}else this.whammyBarType=Lt.None;if(u&&this.whammyBarType===Lt.Custom)if(n===F.SongBook&&(this.whammyStyle=r?p.Gradual:p.Fast),4===c.length){const t=c[0],e=c[1],s=c[2],i=c[3];e.value===s.value&&(t.value<e.value&&e.value<i.value||t.value>e.value&&e.value>i.value?(0===t.value||this.isContinuedWhammy?this.whammyBarType=Lt.Dive:this.whammyBarType=Lt.PrediveDive,c.splice(2,1),c.splice(1,1)):t.value>e.value&&e.value<i.value||t.value<e.value&&e.value>i.value?(this.whammyBarType=Lt.Dip,e.offset!==s.offset&&n!==F.SongBook||c.splice(2,1)):t.value===e.value&&e.value===i.value&&(0===t.value||this.isContinuedWhammy?this.whammyBarType=Lt.Hold:this.whammyBarType=Lt.Predive,c.splice(2,1),c.splice(1,1)))}else if(3===c.length){const t=c[0],e=c[1],s=c[2];t.value<e.value&&e.value<s.value||t.value>e.value&&e.value>s.value?(0===t.value||this.isContinuedWhammy?this.whammyBarType=Lt.Dive:this.whammyBarType=Lt.PrediveDive,c.splice(1,1)):t.value>e.value&&e.value<s.value||t.value<e.value&&e.value>s.value?this.whammyBarType=Lt.Dip:t.value===e.value&&e.value===s.value&&(0===t.value||this.isContinuedWhammy?this.whammyBarType=Lt.Hold:this.whammyBarType=Lt.Predive,c.splice(1,1))}else if(2===c.length){const t=c[0],e=c[1];t.value<e.value||t.value>e.value?0===t.value||this.isContinuedWhammy?this.whammyBarType=Lt.Dive:this.whammyBarType=Lt.PrediveDive:t.value===e.value&&(0===t.value||this.isContinuedWhammy?this.whammyBarType=Lt.Hold:this.whammyBarType=Lt.Predive)}if(this.updateDurations(),a){const e=Qt.clone(this);e.id=t.jt++,e.pickStroke=_t.None;for(let t=0,s=e.notes.length;t<s;t++){const s=e.notes[t],i=this.notes[t];if(s.bendType=b.None,s.maxBendPoint=null,s.bendPoints=null,s.bendStyle=p.Default,s.id=At.globalNoteId++,i.isTieOrigin&&(s.tieDestination=i.tieDestination,i.tieDestination.tieOrigin=s),i.isTieDestination&&(s.tieOrigin=i.tieOrigin?i.tieOrigin:null,i.tieOrigin.tieDestination=s),i.hasBend&&i.isTieOrigin){const t=At.findTieOrigin(i);if(t&&t.hasBend){s.bendType=b.Hold;const t=i.bendPoints[i.bendPoints.length-1];s.addBendPoint(new f(0,t.value)),s.addBendPoint(new f(f.MaxPosition,t.value))}}s.isTieDestination=!0}this.graceType=y.BendGrace,this.graceGroup=new ht,this.graceGroup.addBeat(this),this.graceGroup.isComplete=!0,this.graceGroup.finish(),this.updateDurations(),this.voice.insertBeat(this,e),e.graceGroup=new ht,e.graceGroup.addBeat(this),e.graceGroup.isComplete=!0,e.graceGroup.finish()}}isBefore(t){return this.voice.bar.index<t.voice.bar.index||t.voice.bar.index===this.voice.bar.index&&this.index<t.index}isAfter(t){return this.voice.bar.index>t.voice.bar.index||t.voice.bar.index===this.voice.bar.index&&this.index>t.index}hasNoteOnString(t){return this.noteStringLookup.has(t)}getNoteWithRealValue(t){return this.noteValueLookup.has(t)?this.noteValueLookup.get(t):null}chain(t=null){for(const e of this.notes)this.noteValueLookup.set(e.realValue,e),e.chain(t)}},jt=class{static clone(t){const e=new f;return e.offset=t.offset,e.value=t.value,e}},Jt=class{static clone(t){const e=new At;if(e.index=t.index,e.accentuated=t.accentuated,e.bendType=t.bendType,e.bendStyle=t.bendStyle,e.isContinuedBend=t.isContinuedBend,t.bendPoints){e.bendPoints=[];for(const s of t.bendPoints)e.addBendPoint(jt.clone(s))}return e.fret=t.fret,e.string=t.string,e.showStringNumber=t.showStringNumber,e.octave=t.octave,e.tone=t.tone,e.percussionArticulation=t.percussionArticulation,e.isVisible=t.isVisible,e.isLeftHandTapped=t.isLeftHandTapped,e.isHammerPullOrigin=t.isHammerPullOrigin,e.isSlurDestination=t.isSlurDestination,e.harmonicType=t.harmonicType,e.harmonicValue=t.harmonicValue,e.isGhost=t.isGhost,e.isLetRing=t.isLetRing,e.isPalmMute=t.isPalmMute,e.isDead=t.isDead,e.isStaccato=t.isStaccato,e.slideInType=t.slideInType,e.slideOutType=t.slideOutType,e.vibrato=t.vibrato,e.isTieDestination=t.isTieDestination,e.leftHandFinger=t.leftHandFinger,e.rightHandFinger=t.rightHandFinger,e.trillValue=t.trillValue,e.trillSpeed=t.trillSpeed,e.durationPercent=t.durationPercent,e.accidentalMode=t.accidentalMode,e.dynamics=t.dynamics,e.ornament=t.ornament,e}},qt=class{static clone(t){const e=new u;return e.barOccurence=t.barOccurence,e.millisecondOffset=t.millisecondOffset,e}},Yt=class{static clone(t){const e=new d;return e.isLinear=t.isLinear,e.type=t.type,e.value=t.value,e.syncPointValue=t.syncPointValue?qt.clone(t.syncPointValue):void 0,e.ratioPosition=t.ratioPosition,e.text=t.text,e.isVisible=t.isVisible,e}},Kt=class{static clone(t){const e=new $t;return e.marks=t.marks,e.style=t.style,e}},Qt=class{static clone(t){const e=new Xt;e.index=t.index,e.notes=[];for(const s of t.notes)e.addNote(Jt.clone(s));e.isEmpty=t.isEmpty,e.whammyStyle=t.whammyStyle,e.ottava=t.ottava,e.isLegatoOrigin=t.isLegatoOrigin,e.duration=t.duration,e.isLetRing=t.isLetRing,e.isPalmMute=t.isPalmMute,e.automations=[];for(const s of t.automations)e.automations.push(Yt.clone(s));if(e.dots=t.dots,e.fade=t.fade,e.lyrics=t.lyrics?t.lyrics.slice():null,e.pop=t.pop,e.slap=t.slap,e.tap=t.tap,e.text=t.text,e.slashed=t.slashed,e.deadSlapped=t.deadSlapped,e.brushType=t.brushType,e.brushDuration=t.brushDuration,e.tupletDenominator=t.tupletDenominator,e.tupletNumerator=t.tupletNumerator,e.isContinuedWhammy=t.isContinuedWhammy,e.whammyBarType=t.whammyBarType,t.whammyBarPoints){e.whammyBarPoints=[];for(const s of t.whammyBarPoints)e.addWhammyBarPoint(jt.clone(s))}return e.vibrato=t.vibrato,e.chordId=t.chordId,e.graceType=t.graceType,e.pickStroke=t.pickStroke,e.tremoloPicking=t.tremoloPicking?Kt.clone(t.tremoloPicking):void 0,e.crescendo=t.crescendo,e.displayStart=t.displayStart,e.playbackStart=t.playbackStart,e.displayDuration=t.displayDuration,e.playbackDuration=t.playbackDuration,e.overrideDisplayDuration=t.overrideDisplayDuration,e.golpe=t.golpe,e.dynamics=t.dynamics,e.invertBeamDirection=t.invertBeamDirection,e.preferredBeamDirection=t.preferredBeamDirection,e.isEffectSlurOrigin=t.isEffectSlurOrigin,e.beamingMode=t.beamingMode,e.wahPedal=t.wahPedal,e.barreFret=t.barreFret,e.barreShape=t.barreShape,e.rasgueado=t.rasgueado,e.showTimer=t.showTimer,e.timer=t.timer,e}},Zt=class t{static qt(t){const e=new Map;for(const[s,i]of t)e.has(i)||e.set(i,s);return e}static whammyType=new Map([["custom",1],["dive",2],["dip",3],["hold",4],["predive",5],["predivedive",6]]);static whammyTypeReversed=t.qt(t.whammyType);static bendStyle=new Map([["default",0],["gradual",1],["fast",2]]);static bendStyleReversed=t.qt(t.bendStyle);static graceType=new Map([["onbeat",1],["beforebeat",2],["bendgrace",3],["ob",1],["bb",2],["b",3]]);static graceTypeReversed=t.qt(t.graceType);static fermataType=new Map([["short",0],["medium",1],["long",2]]);static fermataTypeReversed=t.qt(t.fermataType);static alphaTexAccidentalMode=new Map([["auto",0],["explicit",1]]);static alphaTexAccidentalModeReversed=t.qt(t.alphaTexAccidentalMode);static alphaTexVoiceMode=new Map([["staffwise",0],["barwise",1]]);static alphaTexVoiceModeReversed=t.qt(t.alphaTexVoiceMode);static noteAccidentalMode=new Map([["default",0],["forcenone",1],["forcenatural",2],["forcesharp",3],["forcedoublesharp",4],["forceflat",5],["forcedoubleflat",6],["d",0],["-",1],["n",2],["#",3],["##",4],["x",4],["b",5],["bb",6]]);static noteAccidentalModeReversed=t.qt(t.noteAccidentalMode);static barreShape=new Map([["full",1],["half",2]]);static barreShapeReversed=t.qt(t.barreShape);static ottavia=new Map([["15ma",0],["8va",1],["regular",2],["8vb",3],["15mb",4],["15ma",0],["8va",1],["8vb",3],["15mb",4]]);static ottaviaReversed=t.qt(t.ottavia);static rasgueado=new Map([["ii",1],["mi",2],["miitriplet",3],["miianapaest",4],["pmptriplet",5],["pmpanapaest",6],["peitriplet",7],["peianapaest",8],["paitriplet",9],["paianapaest",10],["amitriplet",11],["amianapaest",12],["ppp",13],["amii",14],["amip",15],["eami",16],["eamii",17],["peami",18]]);static rasgueadoReversed=t.qt(t.rasgueado);static dynamicValue=new Map([["ppp",0],["pp",1],["p",2],["mp",3],["mf",4],["f",5],["ff",6],["fff",7],["pppp",8],["ppppp",9],["pppppp",10],["ffff",11],["fffff",12],["ffffff",13],["sf",14],["sfp",15],["sfpp",16],["fp",17],["rf",18],["rfz",19],["sfz",20],["sffz",21],["fz",22],["n",23],["pf",24],["sfzp",25]]);static dynamicValueReversed=t.qt(t.dynamicValue);static bracketExtendMode=new Map([["nobrackets",0],["groupstaves",1],["groupsimilarinstruments",2]]);static bracketExtendModeReversed=t.qt(t.bracketExtendMode);static trackNamePolicy=new Map([["hidden",0],["firstsystem",1],["allsystems",2]]);static trackNamePolicyReversed=t.qt(t.trackNamePolicy);static trackNameOrientation=new Map([["horizontal",0],["vertical",1]]);static trackNameOrientationReversed=t.qt(t.trackNameOrientation);static trackNameMode=new Map([["fullname",0],["shortname",1]]);static trackNameModeReversed=t.qt(t.trackNameMode);static textAlign=new Map([["left",0],["center",1],["right",2]]);static textAlignReversed=t.qt(t.textAlign);static bendType=new Map([["custom",1],["bend",2],["release",3],["bendrelease",4],["hold",5],["prebend",6],["prebendbend",7],["prebendrelease",8]]);static bendTypeReversed=t.qt(t.bendType);static keySignature=new Map([["cb",-7],["gb",-6],["db",-5],["ab",-4],["eb",-3],["bb",-2],["f",-1],["c",0],["g",1],["d",2],["a",3],["e",4],["b",5],["f#",6],["c#",7],["cbmajor",-7],["abminor",-7],["gbmajor",-6],["ebminor",-6],["dbmajor",-5],["bbminor",-5],["abmajor",-4],["fminor",-4],["ebmajor",-3],["cminor",-3],["bbmajor",-2],["gminor",-2],["fmajor",-1],["dminor",-1],["cmajor",0],["aminor",0],["gmajor",1],["eminor",1],["dmajor",2],["bminor",2],["amajor",3],["f#minor",3],["emajor",4],["c#minor",4],["bmajor",5],["g#minor",5],["f#major",6],["d#minor",6],["f#",6],["c#major",7],["a#minor",7],["c#",7]]);static keySignatureReversed=t.qt(t.keySignature);static keySignatureType=new Map([["major",0],["minor",1],["cb",0],["cbmajor",0],["gb",0],["gbmajor",0],["db",0],["dbmajor",0],["ab",0],["abmajor",0],["eb",0],["ebmajor",0],["bb",0],["bbmajor",0],["f",0],["fmajor",0],["c",0],["cmajor",0],["g",0],["gmajor",0],["d",0],["dmajor",0],["a",0],["amajor",0],["e",0],["emajor",0],["b",0],["bmajor",0],["f#",0],["f#major",0],["c#",0],["c#major",0],["abminor",1],["ebminor",1],["bbminor",1],["fminor",1],["cminor",1],["gminor",1],["dminor",1],["aminor",1],["eminor",1],["bminor",1],["f#minor",1],["c#minor",1],["g#minor",1],["d#minor",1],["a#minor",1]]);static keySignatureTypeReversed=t.qt(t.keySignatureType);static clef=new Map([["neutral",0],["c3",1],["c4",2],["f4",3],["g2",4],["n",0],["alto",1],["tenor",2],["bass",3],["treble",4]]);static clefReversed=t.qt(t.clef);static tripletFeel=new Map([["none",0],["triplet16th",1],["triplet8th",2],["dotted16th",3],["dotted8th",4],["scottish16th",5],["scottish8th",6],["none",0],["no",0],["notripletfeel",0],["t16",1],["triplet-16th",1],["t8",2],["triplet-8th",2],["d16",3],["dotted-16th",3],["d8",4],["dotted-8th",4],["s16",5],["scottish-16th",5],["s8",6],["scottish-8th",6]]);static tripletFeelReversed=t.qt(t.tripletFeel);static barLineStyle=new Map([["automatic",0],["dashed",1],["dotted",2],["heavy",3],["heavyheavy",4],["heavylight",5],["lightheavy",6],["lightlight",7],["none",8],["regular",9],["short",10],["tick",11]]);static barLineStyleReversed=t.qt(t.barLineStyle);static simileMark=new Map([["none",0],["simple",1],["firstofdouble",2],["secondofdouble",3]]);static simileMarkReversed=t.qt(t.simileMark);static direction=new Map([["fine",0],["segno",1],["segnosegno",2],["coda",3],["doublecoda",4],["dacapo",5],["dacapoalcoda",6],["dacapoaldoublecoda",7],["dacapoalfine",8],["dalsegno",9],["dalsegnoalcoda",10],["dalsegnoaldoublecoda",11],["dalsegnoalfine",12],["dalsegnosegno",13],["dalsegnosegnoalcoda",14],["dalsegnosegnoaldoublecoda",15],["dalsegnosegnoalfine",16],["dacoda",17],["dadoublecoda",18]]);static directionReversed=t.qt(t.direction);static tremoloPickingStyle=new Map([["default",0],["buzzroll",1]]);static tremoloPickingStyleReversed=t.qt(t.tremoloPickingStyle);static barNumberDisplay=new Map([["allbars",0],["firstofsystem",1],["hide",2]]);static barNumberDisplayReversed=t.qt(t.barNumberDisplay);static keySignaturesMinorReversed=new Map([[-7,"abminor"],[-6,"ebminor"],[-5,"bbminor"],[-4,"fminor"],[-3,"cminor"],[-2,"gminor"],[-1,"dminor"],[0,"aminor"],[1,"eminor"],[2,"bminor"],[3,"f#minor"],[4,"c#minor"],[5,"g#minor"],[6,"d#minor"],[7,"a#minor"]]);static keySignaturesMajorReversed=new Map([[-7,"cb"],[-6,"gb"],[-5,"db"],[-4,"ab"],[-3,"eb"],[-2,"bb"],[-1,"f"],[0,"c"],[1,"g"],[2,"d"],[3,"a"],[4,"e"],[5,"b"],[6,"f#"],[7,"c#"]])},te=class t{static Yt(t){return t?{expectedTypes:new Set(t[0]),parseMode:t[1],allowedValues:t.length>2&&t[2]&&t[2].length>0?new Set(t[2]):void 0,reservedIdentifiers:t.length>3&&t[3]&&t[3].length>0?new Set(t[3]):void 0}:null}static Kt(e){return null==e?null:e.map(e=>({isStrict:e.length>0&&null===e[0],parameters:e.map(t.Yt).filter(t=>null!==t)}))}static Qt(e){return new Map(e.map(e=>[e[0],null===e[1]?null:new Map(e[1].map(e=>[e[0],t.Kt(e[1])]))]))}static Zt(e){return new Map(e.map(e=>[e[0],t.Kt(e[1])]))}static te(e){return new Map(e.map(e=>[e[0],t.Kt(e[1])]))}static scoreMetaDataSignatures=t.te([["title",[[[[17,10],0],[[17],1],[[10,17],1,["left","center","right"]]]]],["subtitle",[[[[17,10],0],[[17],1],[[10,17],1,["left","center","right"]]]]],["artist",[[[[17,10],0],[[17],1],[[10,17],1,["left","center","right"]]]]],["album",[[[[17,10],0],[[17],1],[[10,17],1,["left","center","right"]]]]],["words",[[[[17,10],0],[[17],1],[[10,17],1,["left","center","right"]]]]],["music",[[[[17,10],0],[[17],1],[[10,17],1,["left","center","right"]]]]],["wordsandmusic",[[[[17],0],[[10,17],1,["left","center","right"]]]]],["copyright",[[[[17,10],0],[[17],1],[[10,17],1,["left","center","right"]]]]],["copyright2",[[[[17],0],[[10,17],1,["left","center","right"]]]]],["instructions",[[[[17,10],0]]]],["notices",[[[[17,10],0]]]],["tab",[[[[17,10],0],[[17],1],[[10,17],1,["left","center","right"]]]]],["systemslayout",[[[[16],5]]]],["defaultsystemslayout",[[[[16],0]]]],["showdynamics",null],["hidedynamics",null],["usesystemsignseparator",null],["multibarrest",null],["bracketextendmode",[[[[10,17],0,["nobrackets","groupstaves","groupsimilarinstruments"]]]]],["singletracktracknamepolicy",[[[[10,17],0,["hidden","firstsystem","allsystems"]]]]],["multitracktracknamepolicy",[[[[10,17],0,["hidden","firstsystem","allsystems"]]]]],["firstsystemtracknamemode",[[[[10,17],0,["fullname","shortname"]]]]],["othersystemstracknamemode",[[[[10,17],0,["fullname","shortname"]]]]],["firstsystemtracknameorientation",[[[[10,17],0,["horizontal","vertical"]]]]],["othersystemstracknameorientation",[[[[10,17],0,["horizontal","vertical"]]]]],["extendbarlines",null],["chorddiagramsinscore",[[[[10],1,["true","false"]]]]],["hideemptystaves",null],["hideemptystavesinfirstsystem",null],["showsinglestaffbrackets",null],["defaultbarnumberdisplay",[[[[10,17],0,["allbars","firstofsystem","hide"]]]]]]);static staffMetaDataSignatures=t.te([["tuning",[[[[10,17],0,["piano","none","voice"]]],[[[10,17],5]]]],["chord",[[[[17,10],0],[[10,17,16],5]]]],["capo",[[[[16],0]]]],["lyrics",[[[[17],0]],[[[16],0],[[17],0]]]],["articulation",[[[[10],0,["defaults"]]],[[[17,10],0],[[16],0]]]],["displaytranspose",[[[[16],0]]]],["transpose",[[[[16],0]]]],["instrument",[[[[16],0]],[[[17,10],0]],[[[10],0,["percussion"]]]]]]);static structuralMetaDataSignatures=t.te([["track",[[[[17],1],[[17],1]]]],["staff",null],["voice",null]]);static barMetaDataSignatures=t.te([["ts",[[[[10,17],0,["common"]]],[[[16],0],[[16],0]]]],["ro",null],["rc",[[[[16],0]]]],["ae",[[[[16,13],4]]]],["ks",[[[[10,17],0,["cb","gb","db","ab","eb","bb","f","c","g","d","a","e","b","f#","c#","cbmajor","abminor","gbmajor","ebminor","dbmajor","bbminor","abmajor","fminor","ebmajor","cminor","bbmajor","gminor","fmajor","dminor","cmajor","aminor","gmajor","eminor","dmajor","bminor","amajor","f#minor","emajor","c#minor","bmajor","g#minor","f#major","d#minor","f#","c#major","a#minor","c#"]]]]],["clef",[[[[10,16,17],0,["neutral","c3","c4","f4","g2","n","alto","tenor","bass","treble"]]]]],["ottava",[[[[10,17],0,["15ma","8va","regular","8vb","15mb","15ma","8va","8vb","15mb"]]]]],["tempo",[[[[16],2],[[17],1]],[null,[[16],2],[[17],0],[[16],1],[[10],1,["hide"]]]]],["tf",[[[[10,16,17],0,["none","triplet16th","triplet8th","dotted16th","dotted8th","scottish16th","scottish8th","none","no","notripletfeel","t16","triplet-16th","t8","triplet-8th","d16","dotted-16th","d8","dotted-8th","s16","scottish-16th","s8","scottish-8th"]]]]],["ac",null],["section",[[[[17,10],0]],[[[17,10],0],[[17,10],0,null,["x","-","r"]]]]],["jump",[[[[10,17],0,["fine","segno","segnosegno","coda","doublecoda","dacapo","dacapoalcoda","dacapoaldoublecoda","dacapoalfine","dalsegno","dalsegnoalcoda","dalsegnoaldoublecoda","dalsegnoalfine","dalsegnosegno","dalsegnosegnoalcoda","dalsegnosegnoaldoublecoda","dalsegnosegnoalfine","dacoda","dadoublecoda"]]]]],["ft",null],["simile",[[[[10,17],0,["none","simple","firstofdouble","secondofdouble"]]]]],["barlineleft",[[[[10,17],0,["automatic","dashed","dotted","heavy","heavyheavy","heavylight","lightheavy","lightlight","none","regular","short","tick"]]]]],["barlineright",[[[[10,17],0,["automatic","dashed","dotted","heavy","heavyheavy","heavylight","lightheavy","lightlight","none","regular","short","tick"]]]]],["scale",[[[[16],2]]]],["width",[[[[16],2]]]],["sync",[[[[16],0],[[16],0],[[16],0],[[16],3]]]],["accidentals",[[[[10,17],0,["auto","explicit"]]]]],["spd",[[[[16],2]]]],["sph",[[[[16],2]]]],["spu",[[[[16],2]]]],["db",null],["voicemode",[[[[10,17],0,["staffwise","barwise"]]]]],["barnumberdisplay",[[[[10,17],0,["allbars","firstofsystem","hide"]]]]],["beaming",[[[[16],0],[[16],5]]]]]);static metaDataProperties=t.Qt([["track",[["color",[[[[17],0]]]],["systemslayout",[[[[16],5]]]],["defaultsystemslayout",[[[[16],0]]]],["solo",null],["mute",null],["volume",[[[[16],0]]]],["balance",[[[[16],0]]]],["instrument",[[[[16],0]],[[[17,10],0]],[[[10],0,["percussion"]]]]],["bank",[[[[16],0]]]],["multibarrest",null]]],["staff",[["score",[[[[16],1]]]],["tabs",null],["slash",null],["numbered",null]]],["voice",null],["title",null],["subtitle",null],["artist",null],["album",null],["words",null],["music",null],["wordsandmusic",null],["copyright",null],["copyright2",null],["instructions",null],["notices",null],["tab",null],["systemslayout",null],["defaultsystemslayout",null],["showdynamics",null],["hidedynamics",null],["usesystemsignseparator",null],["multibarrest",null],["bracketextendmode",null],["singletracktracknamepolicy",null],["multitracktracknamepolicy",null],["firstsystemtracknamemode",null],["othersystemstracknamemode",null],["firstsystemtracknameorientation",null],["othersystemstracknameorientation",null],["extendbarlines",null],["chorddiagramsinscore",null],["hideemptystaves",null],["hideemptystavesinfirstsystem",null],["showsinglestaffbrackets",null],["defaultbarnumberdisplay",null],["tuning",[["hide",null],["label",[[[[17],0]]]]]],["chord",[["firstfret",[[[[16],0]]]],["barre",[[[[16],5]]]],["showdiagram",[[],[[[17],0,["true","false"]]],[[[10],0,["true","false"]]],[[[16],0,["1","0"]]]]],["showfingering",[[],[[[17],0,["true","false"]]],[[[10],0,["true","false"]]],[[[16],0,["1","0"]]]]],["showname",[[],[[[17],0,["true","false"]]],[[[10],0,["true","false"]]],[[[16],0,["1","0"]]]]]]],["capo",null],["lyrics",null],["articulation",null],["displaytranspose",null],["transpose",null],["instrument",null],["ts",null],["ro",null],["rc",null],["ae",null],["ks",null],["clef",null],["ottava",null],["tempo",null],["tf",null],["ac",null],["section",null],["jump",null],["ft",null],["simile",null],["barlineleft",null],["barlineright",null],["scale",null],["width",null],["sync",null],["accidentals",null],["spd",null],["sph",null],["spu",null],["db",null],["voicemode",null],["barnumberdisplay",null],["beaming",null]]);static metaDataSignatures=[t.scoreMetaDataSignatures,t.staffMetaDataSignatures,t.structuralMetaDataSignatures,t.barMetaDataSignatures];static durationChangeProperties=t.Zt([["tu",[[[[16],0,["3","5","6","7","9","10","12"]]],[[[16],0],[[16],0]]]]]);static beatProperties=t.Zt([["f",null],["fo",null],["vs",null],["v",null],["vw",null],["s",null],["p",null],["tt",null],["d",null],["dd",null],["su",null],["sd",null],["cre",null],["dec",null],["spd",null],["sph",null],["spu",null],["spe",null],["slashed",null],["ds",null],["glpf",null],["glpt",null],["waho",null],["wahc",null],["legatoorigin",null],["timer",null],["tu",[[[[16],0,["3","5","6","7","9","10","12"]]],[[[16],0],[[16],0]]]],["txt",[[[[17,10],0]]]],["lyrics",[[[[17],0]],[[[16],0],[[17],0]]]],["tb",[[[[16],5]],[[[10,17],0,["custom","dive","dip","hold","predive","predivedive"]],[[16],5]],[[[10,17],0,["default","gradual","fast"]],[[16],5]],[[[10,17],0,["custom","dive","dip","hold","predive","predivedive"]],[[10,17],0,["default","gradual","fast"]],[[16],5]]]],["tbe",[[[[16],5]],[[[10,17],0,["custom","dive","dip","hold","predive","predivedive"]],[[16],5]],[[[10,17],0,["default","gradual","fast"]],[[16],5]],[[[10,17],0,["custom","dive","dip","hold","predive","predivedive"]],[[10,17],0,["default","gradual","fast"]],[[16],5]]]],["bu",[[[[16],1]]]],["bd",[[[[16],1]]]],["au",[[[[16],1]]]],["ad",[[[[16],1]]]],["ch",[[[[17,10],0]]]],["gr",[[[[10,17],1,["onbeat","beforebeat","bendgrace","ob","bb","b"]]]]],["dy",[[[[10,17],0,["ppp","pp","p","mp","mf","f","ff","fff","pppp","ppppp","pppppp","ffff","fffff","ffffff","sf","sfp","sfpp","fp","rf","rfz","sfz","sffz","fz","n","pf","sfzp"]]]]],["tempo",[[[[16],0],[[10],1,["hide"]]],[[[16],0],[[17],0],[[10],1,["hide"]]]]],["volume",[[[[16],0]]]],["balance",[[[[16],0]]]],["tp",[[[[16],0],[[10,17],1,["default","buzzroll"]]]]],["barre",[[[[16],0],[[10,17],1,["full","half"]]]]],["rasg",[[[[10,17],0,["ii","mi","miitriplet","miianapaest","pmptriplet","pmpanapaest","peitriplet","peianapaest","paitriplet","paianapaest","amitriplet","amianapaest","ppp","amii","amip","eami","eamii","peami"]]]]],["ot",[[[[10,17],0,["15ma","8va","regular","8vb","15mb","15ma","8va","8vb","15mb"]]]]],["instrument",[[[[16],0]],[[[17,10],0]],[[[10],0,["percussion"]]]]],["bank",[[[[16],0]]]],["fermata",[[[[10,17],0,["short","medium","long"]],[[16],3]]]],["beam",[[[[10,17],0,["invert","up","down","auto","split","merge","splitsecondary"]]]]]]);static noteProperties=t.Zt([["nh",null],["ah",[[[[16],1]]]],["th",[[[[16],1]]]],["ph",[[[[16],1]]]],["sh",[[[[16],1]]]],["fh",[[[[16],1]]]],["v",null],["vw",null],["sl",null],["ss",null],["sib",null],["sia",null],["sou",null],["sod",null],["psu",null],["psd",null],["h",null],["lht",null],["g",null],["ac",null],["hac",null],["ten",null],["tr",[[[[16],0],[[16],1,["16","32","64"]]]]],["pm",null],["st",null],["lr",null],["x",null],["t",null],["turn",null],["iturn",null],["umordent",null],["lmordent",null],["string",null],["hide",null],["b",[[[[16],5]],[[[10,17],0,["custom","bend","release","bendrelease","hold","prebend","prebendbend","prebendrelease"]],[[16],5]],[[[10,17],0,["default","gradual","fast"]],[[16],5]],[[[10,17],0,["custom","bend","release","bendrelease","hold","prebend","prebendbend","prebendrelease"]],[[10,17],0,["default","gradual","fast"]],[[16],5]]]],["be",[[[[16],5]],[[[10,17],0,["custom","bend","release","bendrelease","hold","prebend","prebendbend","prebendrelease"]],[[16],5]],[[[10,17],0,["default","gradual","fast"]],[[16],5]],[[[10,17],0,["custom","bend","release","bendrelease","hold","prebend","prebendbend","prebendrelease"]],[[10,17],0,["default","gradual","fast"]],[[16],5]]]],["lf",[[[[16],0,["1","2","3","4","5"]]]]],["rf",[[[[16],0,["1","2","3","4","5"]]]]],["acc",[[[[10,17],0,["default","forcenone","forcenatural","forcesharp","forcedoublesharp","forceflat","forcedoubleflat","d","-","n","#","##","x","b","bb"]]]]],["slur",[[[[17],0]],[[[10],0]]]],["-",null]])},ee=function(t){return t[t.Dot=0]="Dot",t[t.Backslash=1]="Backslash",t[t.DoubleBackslash=2]="DoubleBackslash",t[t.Pipe=3]="Pipe",t[t.LBrace=4]="LBrace",t[t.RBrace=5]="RBrace",t[t.LParen=6]="LParen",t[t.RParen=7]="RParen",t[t.Colon=8]="Colon",t[t.Asterisk=9]="Asterisk",t[t.Ident=10]="Ident",t[t.Tag=11]="Tag",t[t.Meta=12]="Meta",t[t.Arguments=13]="Arguments",t[t.Props=14]="Props",t[t.Prop=15]="Prop",t[t.Number=16]="Number",t[t.String=17]="String",t[t.Score=18]="Score",t[t.Bar=19]="Bar",t[t.Beat=20]="Beat",t[t.Duration=21]="Duration",t[t.NoteList=22]="NoteList",t[t.Note=23]="Note",t}({}),se=function(t){return t[t.Hint=0]="Hint",t[t.Warning=1]="Warning",t[t.Error=2]="Error",t}({}),ie=function(t){return t[t.AT001=1]="AT001",t[t.AT002=2]="AT002",t[t.AT003=3]="AT003",t[t.AT004=4]="AT004",t[t.AT005=5]="AT005",t[t.AT006=6]="AT006",t[t.AT200=200]="AT200",t[t.AT201=201]="AT201",t[t.AT202=202]="AT202",t[t.AT203=203]="AT203",t[t.AT204=204]="AT204",t[t.AT205=205]="AT205",t[t.AT206=206]="AT206",t[t.AT207=207]="AT207",t[t.AT208=208]="AT208",t[t.AT209=209]="AT209",t[t.AT210=210]="AT210",t[t.AT211=211]="AT211",t[t.AT212=212]="AT212",t[t.AT213=213]="AT213",t[t.AT214=214]="AT214",t[t.AT215=215]="AT215",t[t.AT216=216]="AT216",t[t.AT217=217]="AT217",t[t.AT218=218]="AT218",t[t.AT219=219]="AT219",t[t.AT220=220]="AT220",t[t.AT300=300]="AT300",t[t.AT301=301]="AT301",t[t.AT302=302]="AT302",t[t.AT303=303]="AT303",t[t.AT304=304]="AT304",t[t.AT305=305]="AT305",t[t.AT306=306]="AT306",t[t.AT400=400]="AT400",t}({}),ne=class{ee=!1;items=[];get errors(){return this.items.filter(t=>2===t.severity)}get hasErrors(){return this.ee}push(t){this.items.push(t),2===t.severity&&(this.ee=!0)}[Symbol.iterator](){return this.items[Symbol.iterator]()}},re=function(t){return t[t.Auto=0]="Auto",t[t.Explicit=1]="Explicit",t}({}),ae=function(t){return t[t.StaffWise=0]="StaffWise",t[t.BarWise=1]="BarWise",t}({}),he=function(t){return t[t.Pitched=0]="Pitched",t[t.Fretted=1]="Fretted",t[t.Articulation=2]="Articulation",t}({}),oe=function(t){return t[t.Required=0]="Required",t[t.Optional=1]="Optional",t[t.RequiredAsFloat=2]="RequiredAsFloat",t[t.OptionalAsFloat=3]="OptionalAsFloat",t[t.RequiredAsValueList=4]="RequiredAsValueList",t[t.ValueListWithoutParenthesis=5]="ValueListWithoutParenthesis",t}({}),ce=class t{static se=new ArrayBuffer(8);static ie=new Uint8Array(t.se);static ne=new DataView(t.se);static float64ToBytes(e){return t.ne.setFloat64(0,e,!0),t.ie}static bytesToInt64LE(e){t.ie.set(e,0);const s=t.ne.getBigInt64(0,!0);return s<=Number.MAX_SAFE_INTEGER&&s>=Number.MIN_SAFE_INTEGER?Number(s):Number.MAX_SAFE_INTEGER}static bytesToFloat64LE(e){return t.ie.set(e,0),t.ne.getFloat64(0,!0)}static bytesToFloat32LE(e){return t.ie.set(e,0),t.ne.getFloat32(0,!0)}static float32BEToBytes(e){return t.ne.setFloat32(0,e,!1),t.ie.slice(0,4)}static uint16ToInt16(e){return t.ne.setUint16(0,e,!0),t.ne.getInt16(0,!0)}static int16ToUint32(e){return t.ne.setInt16(0,e,!0),t.ne.getUint32(0,!0)}static int32ToUint16(e){return t.ne.setInt32(0,e,!0),t.ne.getUint16(0,!0)}static int32ToInt16(e){return t.ne.setInt32(0,e,!0),t.ne.getInt16(0,!0)}static int32ToUint32(e){return t.ne.setInt32(0,e,!0),t.ne.getUint32(0,!0)}static uint8ToInt8(e){return t.ne.setUint8(0,e),t.ne.getInt8(0)}},le=class t{static readInt32BE(t){return t.readByte()<<24|t.readByte()<<16|t.readByte()<<8|t.readByte()}static readFloat32BE(t){const e=new Uint8Array(4);return t.read(e,0,e.length),e.reverse(),ce.bytesToFloat32LE(e)}static readFloat64BE(t){const e=new Uint8Array(8);return t.read(e,0,e.length),e.reverse(),ce.bytesToFloat64LE(e)}static readInt32LE(t){const e=t.readByte(),s=t.readByte(),i=t.readByte();return t.readByte()<<24|i<<16|s<<8|e}static readInt64LE(t){const e=new Uint8Array(8);return t.read(e,0,e.length),ce.bytesToInt64LE(e)}static readUInt32LE(t){const e=t.readByte(),s=t.readByte(),i=t.readByte();return t.readByte()<<24|i<<16|s<<8|e}static decodeUInt32LE(t,e){const s=t[e],i=t[e+1],n=t[e+2];return t[e+3]<<24|n<<16|i<<8|s}static readUInt16LE(t){const e=t.readByte(),s=t.readByte();return ce.int32ToUint16(s<<8|e)}static readInt16LE(t){const e=t.readByte(),s=t.readByte();return ce.int32ToInt16(s<<8|e)}static readUInt32BE(t){const e=t.readByte(),s=t.readByte(),i=t.readByte(),n=t.readByte();return ce.int32ToUint32(e<<24|s<<16|i<<8|n)}static readUInt16BE(t){const e=t.readByte(),s=t.readByte();return ce.int32ToInt16(e<<8|s)}static readInt16BE(t){const e=t.readByte(),s=t.readByte();return ce.int32ToInt16(e<<8|s)}static readByteArray(t,e){const s=new Uint8Array(e);return t.read(s,0,e),s}static read8BitChars(e,s){const i=new Uint8Array(s);return e.read(i,0,i.length),t.toString(i,"utf-8")}static read8BitString(t){let e="",s=t.readByte();for(;0!==s;)e+=String.fromCharCode(s),s=t.readByte();return e}static read8BitStringLength(t,e){let s="",i=-1;for(let n=0;n<e;n++){const e=t.readByte();0===e&&-1===i&&(i=n),s+=String.fromCharCode(e)}const n=s;return i>=0?n.substr(0,i):n}static readSInt8(t){const e=t.readByte();return-256*((255&e)>>7)+(255&e)}static readInt24(t,e){let s=t[e]|t[e+1]<<8|t[e+2]<<16;return 8388608&~s||(s|=255<<24),s}static readInt16(t,e){return ce.int32ToInt16(t[e]|t[e+1]<<8)}static toString(e,s){const i=t.re(e);return i&&(s=i),s||(s="utf-8"),new TextDecoder(s).decode(e)}static re(t){return t.length>2&&254===t[0]&&255===t[1]?"utf-16be":t.length>2&&255===t[0]&&254===t[1]?"utf-16le":t.length>4&&0===t[0]&&0===t[1]&&254===t[2]&&255===t[3]?"utf-32be":t.length>4&&255===t[0]&&254===t[1]&&0===t[2]&&0===t[3]?"utf-32le":null}static stringToBytes(t){return(new TextEncoder).encode(t)}static writeInt32BE(t,e){t.writeByte(e>>24&255),t.writeByte(e>>16&255),t.writeByte(e>>8&255),t.writeByte(255&e)}static writeInt32LE(t,e){t.writeByte(255&e),t.writeByte(e>>8&255),t.writeByte(e>>16&255),t.writeByte(e>>24&255)}static writeUInt16LE(t,e){t.writeByte(255&e),t.writeByte(e>>8&255)}static writeInt16LE(t,e){t.writeByte(255&e),t.writeByte(e>>8&255)}static writeInt16BE(t,e){t.writeByte(e>>8&255),t.writeByte(255&e)}static writeFloat32BE(t,e){const s=ce.float32BEToBytes(e);t.write(s,0,s.length)}static*iterateCodepoints(e){let s=0;for(;s<e.length;){let i=e.charCodeAt(s);t.isLeadingSurrogate(i)&&s+1<e.length&&(s++,i=1024*(i-55296)+(e.charCodeAt(s)-56320)+65536),s++,yield i}}static isLeadingSurrogate(t){return t>=55296&&t<=56319}static isTrailingSurrogate(t){return t>=56320&&t<=57343}},ue=class t{static ae=0;he;oe=t.ae;ce=0;le=1;ue=1;fatalError=!1;de={line:0,col:0,offset:0};fe;pe;be;me;lexerDiagnostics=new ne;constructor(e){this.he=[...le.iterateCodepoints(e)],this.ce=0,this.le=1,this.ue=1,this.oe=this.he.length>0?this.he[0]:t.ae}peekToken(){if(this.fatalError)return;let t=this.me;return t||(t=this.ge(),this.me=t,t)}extendToFloat(e){if(46!==this.oe||this.ce+1>=this.he.length||!t.we(this.he[this.ce+1]))return e;let s=this.ce+2;for(;s<this.he.length&&t.we(this.he[s]);)s++;if(s<this.he.length&&t.ye(this.he[s]))return e;const i=s-this.ce-1;return this.ce+=i,this.ue+=i,this.ke(),e.end=this.Se(),e.value=Number.parseFloat(String.fromCodePoint(...this.he.slice(e.start.offset,e.end.offset))),e}advance(){this.be=this.me,this.me=void 0}ke(){const e=this.he;let s=this.ce;if(s<e.length-1){10===e[s]?(this.pe=void 0,++this.le,this.ue=1):++this.ue,++s;const t=e[s];return this.oe=t,this.ce=s,t}return this.oe!==t.ae&&(this.oe=t.ae,++this.ue,this.ce=e.length),t.ae}previousTokenEndLocation(){return this.be?.end??this.Se()}currentTokenLocation(){return this.me?.start??this.Se()}Se(){return{line:this.le,col:this.ue,offset:this.ce}}ge(){for(this.fe=void 0;this.oe!==t.ae&&!this.fatalError;)if(this.de=this.Se(),t.Be.has(this.oe)){const e=t.Be.get(this.oe)(this);if(e)return this.pe=e,e}else{if(t.ye(this.oe)){const t=this._e();return this.pe=t,t}this.oe=this.ke()}}xe(){this.oe=this.ke(),47===this.oe?this.Te():42===this.oe?this.Me():(this.lexerDiagnostics.push({code:ie.AT001,message:`Unexpected character at comment start, expected '//' or '/*' but found '/${String.fromCodePoint(this.oe)}'`,severity:se.Error,start:this.de,end:this.Se()}),this.fatalError=!0)}static Be=new Map([[47,t=>t.xe()],[34,t=>t.ve()],[39,t=>t.ve()],[45,t=>t._e()],[46,t=>t.Ne({nodeType:ee.Dot})],[58,t=>t.Ne({nodeType:ee.Colon})],[40,t=>t.Ne({nodeType:ee.LParen})],[41,t=>t.Ne({nodeType:ee.RParen})],[123,t=>t.Ne({nodeType:ee.LBrace})],[125,t=>t.Ne({nodeType:ee.RBrace})],[124,t=>t.Ne({nodeType:ee.Pipe})],[42,t=>t.Ne({nodeType:ee.Asterisk})],[92,t=>t.Pe()],[9,t=>t.Ce()],[10,t=>t.Ce()],[11,t=>t.Ce()],[13,t=>t.Ce()],[32,t=>t.Ce()]]);Pe(){const e=this.Se();let s,i;this.oe=this.ke(),92===this.oe?(this.oe=this.ke(),i=this.Se(),s={nodeType:ee.DoubleBackslash,start:e,end:i}):(i=this.Se(),s={nodeType:ee.Backslash,start:e,end:i});let n="";for(;t.ye(this.oe);)n+=String.fromCodePoint(this.oe),this.oe=this.ke();if(0!==n.length)return{nodeType:ee.Tag,leadingComments:this.fe,start:this.de,end:this.Se(),prefix:s,tag:{nodeType:ee.Ident,text:n,start:i,end:this.Se()}};this.lexerDiagnostics.push({code:ie.AT002,message:"Missing identifier after meta data start",severity:se.Error,start:this.de,end:this.Se()})}Ne(t){return t.leadingComments=this.fe,t.start=this.de,this.oe=this.ke(),t.end=this.Se(),t}ve(){const e=this.oe;this.oe=this.ke();let s="",i=-1;for(;this.oe!==e&&this.oe!==t.ae;){let n=-1;if(92===this.oe)if(this.oe=this.ke(),92===this.oe)n=92;else if(this.oe===e)n=e;else if(82===this.oe||114===this.oe)n=13;else if(78===this.oe||110===this.oe)n=10;else if(84===this.oe||116===this.oe)n=9;else{if(117!==this.oe)return this.lexerDiagnostics.push({code:ie.AT005,message:`Unsupported escape sequence. Expected '\\n', '\\r', '\\t', or '\\uXXXX' but found '\\${String.fromCodePoint(this.oe)}'.`,severity:se.Error,start:this.de,end:this.Se()}),void(this.fatalError=!0);{let e="";for(let s=0;s<4;s++){if(this.oe=this.ke(),this.oe===t.ae)return this.lexerDiagnostics.push({code:ie.AT003,message:"Unexpected end of file. Need 4 hex characters on a \\uXXXX escape sequence",severity:se.Error,start:this.de,end:this.Se()}),void(this.fatalError=!0);e+=String.fromCodePoint(this.oe)}if(n=Number.parseInt(e,16),Number.isNaN(n))return this.lexerDiagnostics.push({code:ie.AT004,message:"Invalid unicode value. Need 4 hex characters on a \\uXXXX escape sequence.",severity:se.Error,start:this.de,end:this.Se()}),void(this.fatalError=!0)}}else n=this.oe;le.isLeadingSurrogate(i)&&le.isTrailingSurrogate(n)?(n=1024*(i-55296)+(n-56320)+65536,s+=String.fromCodePoint(n)):le.isLeadingSurrogate(n)||(le.isLeadingSurrogate(i)&&(s+=String.fromCodePoint(i)),n>0&&(s+=String.fromCodePoint(n))),i=n,this.oe=this.ke()}if(this.oe===t.ae)return this.lexerDiagnostics.push({code:ie.AT006,message:"Unexpected end of file. String not closed.",severity:se.Error,start:this.de,end:this.Se()}),void(this.fatalError=!0);const n={nodeType:ee.String,text:s,leadingComments:this.fe,start:this.de,end:this.Se()};return this.oe=this.ke(),n}Me(){const e=this.pe,s={start:this.de,end:this.Se(),text:"",multiLine:!0};for(;this.oe!==t.ae;)if(42===this.oe){if(this.oe=this.ke(),47===this.oe){this.oe=this.ke();break}s.text+=`*${String.fromCodePoint(this.oe)}`,s.end.line=this.le,s.end.col=this.ue,s.end.offset=this.ce}else this.oe=this.ke(),s.text+=String.fromCodePoint(this.oe),s.end.line=this.le,s.end.col=this.ue,s.end.offset=this.ce;e?(e.trailingComments??=[],e.trailingComments.push(s)):(this.fe??=[],this.fe.push(s))}_e(){let e="",s=!0,i=this.oe;45===i&&(e+=String.fromCodePoint(i),i=this.ke(),t.we(i)||(s=!1));let n=!0;do{s?t.we(i)?(e+=String.fromCodePoint(i),i=this.ke(),n=!0):t.ye(i)?(s=!1,e+=String.fromCodePoint(i),i=this.ke(),n=!0):n=!1:t.ye(i)?(e+=String.fromCodePoint(i),i=this.ke(),n=!0):n=!1}while(n);return s?{nodeType:ee.Number,leadingComments:this.fe,start:this.de,end:this.Se(),value:Number.parseInt(e,10)}:{nodeType:ee.Ident,leadingComments:this.fe,start:this.de,end:this.Se(),text:e}}Te(){const e=this.pe,s={start:this.de,end:this.Se(),text:"",multiLine:!1};let i=this.oe;for(;i!==t.ae&&(i=this.ke(),10!==i&&i!==t.ae);)s.text+=String.fromCodePoint(i),s.end.line=this.le,s.end.col=this.ue,s.end.offset=this.ce;e?(e.trailingComments??=[],e.trailingComments.push(s)):(this.fe??=[],this.fe.push(s))}Ce(){let e=this.oe;for(;t.Ee(e);)10===e&&(this.pe=void 0),e=this.ke()}static we(t){return t>=48&&t<=57}static Fe(){const e=new Set;for(const s of t.Be.keys())e.add(s);return e.delete(45),e.add(t.ae),e}static Ae=t.Fe();static ye(e){return!t.Ae.has(e)}static Ee(t){return 32===t||10===t||13===t||9===t||11===t}},de=function(t){return t[t.ForModelImport=0]="ForModelImport",t[t.Full=1]="Full",t}({}),fe=class t{lexer;De;Le=be.instance;mode=0;get lexerDiagnostics(){return this.lexer.lexerDiagnostics}parserDiagnostics=new ne;addParserDiagnostic(t){this.parserDiagnostics.push(t)}unexpectedToken(t,e,s){t?this.addParserDiagnostic({code:ie.AT202,message:`Unexpected '${ee[t.nodeType]}' token. Expected one of following: ${e.map(t=>ee[t]).join(",")}`,severity:se.Error,start:t.start,end:t.end}):this.addParserDiagnostic({code:ie.AT203,start:this.lexer.currentTokenLocation(),end:this.lexer.currentTokenLocation(),severity:se.Error,message:"Unexpected end of file."}),s&&(this.lexer.fatalError=!0)}constructor(t){this.lexer=new ue(t)}read(){return this.We(),this.De}We(){this.De={nodeType:ee.Score,bars:[],start:this.lexer.currentTokenLocation()};try{this.Re()}finally{this.De.end=this.lexer.previousTokenEndLocation()}}Re(){let t=this.lexer.peekToken();for(;t;)this.Oe(),t=this.lexer.peekToken()}Oe(){const t={nodeType:ee.Bar,metaData:[],beats:[],pipe:void 0,start:this.lexer.currentTokenLocation()};this.De.bars.push(t);try{this.Ie(t),this.Ge(t);const e=this.lexer.peekToken();e?.nodeType===ee.Pipe&&(t.pipe=e,this.lexer.advance()),(t.metaData.length>0||t.beats.length>0||t.pipe)&&(t.end=this.lexer.previousTokenEndLocation())}finally{t.end=this.lexer.previousTokenEndLocation()}}Ie(t){let e=this.lexer.peekToken();for(;e&&(e.nodeType===ee.Tag||e.nodeType===ee.Dot);)e.nodeType===ee.Dot?(this.lexer.advance(),this.addParserDiagnostic({code:ie.AT400,message:"The dots separating score metadata, score contents and the sync points can be removed.",severity:se.Hint,start:e.start,end:e.end})):this.He(t.metaData),e=this.lexer.peekToken()}Ge(t){let e=this.lexer.peekToken();for(;e&&e.nodeType!==ee.Pipe&&e.nodeType!==ee.Dot&&e.nodeType!==ee.Tag;){const s=this.$e();s&&t.beats.push(s),e=this.lexer.peekToken()}}$e(){const t={nodeType:ee.Beat,durationChange:void 0,notes:void 0,rest:void 0,beatEffects:void 0,beatMultiplier:void 0,beatMultiplierValue:void 0,start:this.lexer.peekToken()?.start};try{if(this.Ve(t),this.ze(t),!t.notes&&!t.rest)return t;this.Ue(t),this.Xe(t),t.beatEffects=this.je(t=>this.Le.readBeatPropertyArguments(this,t)),void 0!==t.beatMultiplierValue&&t.beatEffects?.openBrace&&this.addParserDiagnostic({code:ie.AT304,message:"The beat multiplier should be specified after the beat effects.",severity:se.Warning,start:t.beatMultiplier.start,end:t.beatMultiplierValue.end}),this.Xe(t)}finally{t.end=this.lexer.previousTokenEndLocation()}return t}Ue(t){const e=this.lexer.peekToken();if(e?.nodeType!==ee.Dot)return;t.durationDot=e,this.lexer.advance();const s=this.lexer.peekToken();if(s?.nodeType===ee.Number)return t.durationValue=s,void this.lexer.advance();s?.nodeType!==ee.Tag?s&&this.unexpectedToken(s,[ee.Number],!0):t.durationDot=void 0}Ve(t){const e=this.lexer.peekToken();if(e?.nodeType!==ee.Colon)return;this.lexer.advance();const s={nodeType:ee.Duration,colon:e,value:void 0,properties:void 0,start:e.start};t.durationChange=s;try{const t=this.lexer.peekToken();if(!t||t.nodeType!==ee.Number)return void this.addParserDiagnostic({code:ie.AT201,message:"Missing duration value after ':'.",severity:se.Error,start:e.start,end:e.end});this.lexer.advance(),s.value=t,s.properties=this.je(t=>this.Le.readDurationChangePropertyArguments(this,t))}finally{s.end=this.lexer.previousTokenEndLocation()}}ze(t){const e=this.lexer.peekToken();if(e)if(e.nodeType===ee.Ident&&"r"===e.text)t.rest=e,this.lexer.advance();else if(e.nodeType===ee.LParen)t.notes=this.Je(e);else{const s=this.qe(e);s&&(t.notes={nodeType:ee.NoteList,openParenthesis:void 0,notes:[s],closeParenthesis:void 0,start:s.start,end:s.end})}}Xe(t){const e=this.lexer.peekToken();if(!e||e.nodeType!==ee.Asterisk)return;this.lexer.advance(),t.beatMultiplier=e;const s=this.lexer.peekToken();s&&s.nodeType===ee.Number?(t.beatMultiplierValue=s,this.lexer.advance()):this.addParserDiagnostic({code:ie.AT200,message:"Missing beat multiplier value after '*'.",severity:se.Error,start:t.beatMultiplier.start,end:t.beatMultiplier.end})}Je(t){const e={nodeType:ee.NoteList,openParenthesis:void 0,notes:[],closeParenthesis:void 0,start:this.lexer.currentTokenLocation()};try{e.openParenthesis=t,this.lexer.advance();let s=this.lexer.peekToken();for(;s&&s.nodeType!==ee.RParen;){const t=this.qe(s);if(!t)break;e.notes.push(t),s=this.lexer.peekToken()}const i=this.lexer.peekToken();i?.nodeType===ee.RParen?(e.closeParenthesis=i,this.lexer.advance()):this.addParserDiagnostic({code:ie.AT206,message:"Unexpected end of file. Group not closed.",severity:se.Error,start:i?.start??this.lexer.currentTokenLocation(),end:i?.end??this.lexer.currentTokenLocation()})}finally{e.end=this.lexer.previousTokenEndLocation()}return e}qe(t){const e={nodeType:ee.Note,noteValue:{nodeType:ee.Ident,text:""},start:t.start};try{let s=!1;switch(t.nodeType){case ee.Number:e.noteValue=t,this.lexer.advance(),s=!0;break;case ee.String:case ee.Ident:switch(e.noteValue=t,this.lexer.advance(),e.noteValue.text){case"x":case"-":s=!0}break;default:return void this.unexpectedToken(t,[ee.Number,ee.String,ee.Ident],!0)}if(s){const t=this.lexer.peekToken();if(t?.nodeType===ee.Dot){const s=t;this.lexer.advance();const i=this.lexer.peekToken();if(!i)return void this.unexpectedToken(i,[ee.Number],!0);if(i.nodeType===ee.Tag)return e;if(i.nodeType!==ee.Number)return void this.unexpectedToken(i,[ee.Number],!0);e.noteStringDot=s,e.noteString=i,this.lexer.advance()}}e.noteEffects=this.je(t=>this.Le.readNotePropertyArguments(this,t))}finally{e.end=this.lexer.previousTokenEndLocation()}return e}static Ye=new Set(["chord"]);He(e){const s=this.lexer.peekToken();if(!s||s.nodeType!==ee.Tag)return;const i={nodeType:ee.Meta,tag:s,start:s.start,properties:void 0,propertiesBeforeArguments:!1};this.lexer.advance(),e.push(i);try{const e=t.Ye.has(i.tag.tag.text),s=this.lexer.peekToken();e&&s?.nodeType===ee.LBrace?(i.propertiesBeforeArguments=!0,i.properties=this.je(t=>this.Le.readMetaDataPropertyArguments(this,i.tag,t)),i.arguments=this.argumentList(),i.arguments||(i.arguments=this.Le.readMetaDataArguments(this,i.tag),i.arguments&&i.arguments.arguments.length>1&&(this.addParserDiagnostic({code:ie.AT301,message:"Metadata arguments should be wrapped into parenthesis.",severity:se.Warning,start:i.arguments?.start??i.start,end:i.arguments?.end??i.end}),this.addParserDiagnostic({code:ie.AT302,message:"Metadata arguments should be placed before metadata properties.",severity:se.Warning,start:i.arguments?.start??i.start,end:i.arguments?.end??i.end})))):(this.Le.hasMetaDataArguments(i.tag)&&(i.arguments=this.argumentList(),i.arguments||(i.arguments=this.Le.readMetaDataArguments(this,i.tag),i.arguments&&i.arguments.arguments.length>1&&this.addParserDiagnostic({code:ie.AT301,message:"Metadata arguments should be wrapped into parenthesis.",severity:se.Warning,start:i.arguments?.start??i.start,end:i.arguments?.end??i.end}))),i.properties=this.je(t=>this.Le.readMetaDataPropertyArguments(this,i.tag,t)))}finally{i.end=this.lexer.previousTokenEndLocation()}return i}je(t){const e=this.lexer.peekToken();if(!e||e.nodeType!==ee.LBrace)return;const s={nodeType:ee.Props,openBrace:e,properties:[],closeBrace:void 0,start:e.start};this.lexer.advance();try{let e=this.lexer.peekToken();for(;e?.nodeType===ee.Ident;)s.properties.push(this.Ke(e,t)),e=this.lexer.peekToken();const i=this.lexer.peekToken();i?.nodeType===ee.RBrace?(s.closeBrace=i,this.lexer.advance()):this.addParserDiagnostic({code:ie.AT206,message:"Unexpected end of file. Group not closed.",severity:se.Error,start:this.lexer.currentTokenLocation(),end:this.lexer.currentTokenLocation()})}finally{s.end=this.lexer.previousTokenEndLocation()}return s}Ke(t,e){const s={nodeType:ee.Prop,property:t,arguments:void 0};this.lexer.advance(),s.start=s.property.start;try{s.arguments=this.argumentList(),s.arguments||(s.arguments=e(s),s.arguments&&s.arguments.arguments.length>1&&this.addParserDiagnostic({code:ie.AT303,message:"Property args should be wrapped into parenthesis.",severity:se.Warning,start:s.arguments.start,end:s.arguments.end}))}finally{s.end=this.lexer.previousTokenEndLocation()}return s}argumentList(){const t=this.lexer.peekToken();if(t?.nodeType!==ee.LParen)return;const e={nodeType:ee.Arguments,openParenthesis:t,arguments:[],closeParenthesis:void 0,start:t.start};this.lexer.advance();try{let t=this.lexer.peekToken();for(;t&&t?.nodeType!==ee.RParen;){switch(t.nodeType){case ee.Ident:case ee.String:e.arguments.push(t),this.lexer.advance();break;case ee.Number:e.arguments.push(this.lexer.extendToFloat(t)),this.lexer.advance();break;default:this.unexpectedToken(t,[ee.Ident,ee.String,ee.Number],!1),this.lexer.advance()}t=this.lexer.peekToken()}const s=this.lexer.peekToken();s?.nodeType===ee.RParen?(e.closeParenthesis=s,this.lexer.advance()):this.addParserDiagnostic({code:ie.AT206,message:"Unexpected end of file. Group not closed.",severity:se.Error,start:this.lexer.currentTokenLocation(),end:this.lexer.currentTokenLocation()})}finally{e.end=this.lexer.previousTokenEndLocation()}return e}},pe=class t{static ident(t){return{nodeType:ee.Ident,text:t}}static string(t){return{nodeType:ee.String,text:t}}static number(t){return{nodeType:ee.Number,value:t}}static meta(t,e,s){return{nodeType:ee.Meta,tag:{nodeType:ee.Tag,prefix:{nodeType:ee.Backslash},tag:{nodeType:ee.Ident,text:t}},arguments:e,properties:s,propertiesBeforeArguments:!1}}static identMeta(e,s){return t.meta(e,t.identValue(s))}static numberMeta(e,s){return t.meta(e,t.numberValue(s))}static args(t,e=void 0){const s={nodeType:ee.Arguments,arguments:t.filter(t=>void 0!==t)};if((void 0===e?s.arguments.length>1:e)&&(s.openParenthesis={nodeType:ee.LParen},s.closeParenthesis={nodeType:ee.RParen}),0!==s.arguments.length)return s}static stringValue(e){return t.args([t.string(e)])}static identValue(e){return t.args([t.ident(e)])}static numberValue(e){return t.args([t.number(e)])}static props(e){const s={nodeType:ee.Props,properties:[],openBrace:{nodeType:ee.LBrace},closeBrace:{nodeType:ee.RBrace}};for(const i of e)i&&s.properties.push({nodeType:ee.Prop,property:t.ident(i[0]),arguments:i[1]});return s}static prop(e,s,i){e.push({nodeType:ee.Prop,property:t.ident(s),arguments:i})}},be=class t{static instance=new t;static Qe=new Set([ee.LParen,ee.String,ee.Ident,ee.Number]);hasMetaDataArguments(t){const e=t.tag.text.toLowerCase();for(const t of te.metaDataSignatures)if(t.has(e))return null!==t.get(e);return!0}readMetaDataArguments(t,e){const s=e.tag.text.toLowerCase();for(const e of te.metaDataSignatures)if(e.has(s)){const i=e.get(s);return i?this.Ze(t,i):void 0}t.addParserDiagnostic({code:ie.AT204,message:`Unrecognized metadata '${e.tag.text}'.`,severity:se.Error,start:e.start,end:e.end}),t.lexer.fatalError=!0}readMetaDataPropertyArguments(t,e,s){const i=e.tag.text.toLowerCase();if(!te.metaDataProperties.has(i))return;const n=te.metaDataProperties.get(i);return n?this.ts(t,[n],s):this.ts(t,[],s)}readBeatPropertyArguments(t,e){return this.ts(t,[te.beatProperties],e)}readDurationChangePropertyArguments(t,e){return this.ts(t,[te.durationChangeProperties],e)}readNotePropertyArguments(t,e){return this.ts(t,[te.noteProperties,te.beatProperties],e)}ts(t,e,s){const i=s.property.text.toLowerCase(),n=new Set([ee.Ident,ee.RBrace]);for(const s of e)if(s.has(i)){const e=s.get(i);return e?this.Ze(t,e,n):void this.es(t,[],n)}let r=t.lexer.peekToken();for(;r&&r.nodeType!==ee.Ident&&r.nodeType!==ee.RBrace;)t.lexer.advance(),r=t.lexer.peekToken();t.addParserDiagnostic({code:ie.AT205,message:`Unrecognized property '${s.property.text}'.`,severity:se.Error,start:s.property.start,end:r?.start??t.lexer.currentTokenLocation()})}Ze(t,e,s){if(1===e.length&&0===e[0].parameters.length)return;const i=[],n=t.lexer.peekToken()?.start,r=void 0!==s,a=new Map(e.map((t,e)=>[e,{signature:t,parameterIndex:0,parameterHasValues:!1,parameterValueMatches:0}])),h=this.ss(t,a,i,s),o=this.ns(t,a,i,s,e,n);return r&&this.es(t,e,s),this.rs(i,n,t.lexer.previousTokenEndLocation(),o,h)}ns(e,s,i,n,r,a){const h=e.lexer.peekToken();let o=!1;return 1!==s.size&&void 0===h?(e.addParserDiagnostic({code:ie.AT203,start:e.lexer.currentTokenLocation(),end:e.lexer.currentTokenLocation(),severity:se.Error,message:"Unexpected end of file."}),o=!0):0===s.size&&(void 0!==h&&0===i.length&&n&&!n.has(h.nodeType)&&(i.push(e.lexer.peekToken()),e.lexer.advance()),e.addParserDiagnostic({code:ie.AT219,message:`Error parsing arguments: no overload matched arguments ${t.generateSignaturesFromArguments(i)}. Signatures:\n${t.generateSignatures(r)}`,severity:se.Error,start:a,end:e.lexer.previousTokenEndLocation()}),o=!0),o}rs(e,s,i,n,r){if(0===e.length)return;const a=pe.args(e,!1);return a.start=s,a.end=i,a.validated=!n,r&&(r.length>1&&t.sortCandidates(r),a.signatureCandidateIndices=r.map(t=>t[0])),a}ss(e,s,i,n){const r=e.mode===de.Full,a=(t,n)=>{const a=s.get(n);if(t.nodeType===ee.LParen){const t=e.argumentList();if(t)for(const e of t.arguments)r&&(e.parameterIndices||(e.parameterIndices=new Map),e.parameterIndices.set(n,a.parameterIndex)),i.push(e)}else{const s=t;r&&(s.parameterIndices||(s.parameterIndices=new Map),s.parameterIndices.set(n,a.parameterIndex)),0!==i.length&&i[i.length-1]===s||(i.push(s),e.lexer.advance())}},h=t=>{e.lexer.extendToFloat(t)},o=t.Qe;for(;s.size>1||s.size>0&&!t.hs(s);){const i=e.lexer.peekToken();if(!i||!o.has(i.nodeType))break;if(!t.filterSignatureCandidates(s,i,void 0!==n&&n.has(i.nodeType),a,h))break}const c=e.mode===de.Full?Array.from(s.entries()):void 0;return t.filterIncompleteCandidates(s),c}static sortCandidates(t){t.length<2||t.sort((t,e)=>{const s=Math.abs(t[1].parameterIndex-t[1].signature.parameters.length),i=Math.abs(e[1].parameterIndex-e[1].signature.parameters.length);if(s===i){const s=t[1].parameterValueMatches;return e[1].parameterValueMatches-s}return s-i})}es(e,s,i){const n=e.lexer.currentTokenLocation();let r=e.lexer.peekToken(),a=!1;const h=t.Qe;for(;r&&!i.has(r.nodeType);)h.has(r.nodeType)?(e.lexer.advance(),a=!0,r=e.lexer.peekToken()):r=void 0;a&&e.addParserDiagnostic({code:ie.AT220,message:`Error parsing arguments: unexpected additional arguments. Signatures:\n${t.generateSignatures(s)}`,severity:se.Error,start:n,end:e.lexer.previousTokenEndLocation()})}static hs(t){for(const e of t.values())if(e.parameterIndex===e.signature.parameters.length)return!0;return!1}static filterIncompleteCandidates(t){const e=new Set;for(const[s,i]of t)for(let t=i.parameterIndex;t<i.signature.parameters.length;t++)switch(i.signature.parameters[t].parseMode){case oe.Required:case oe.RequiredAsFloat:e.add(s)}for(const s of e)t.delete(s)}static generateSignaturesFromArguments(t){return t?`(${t.map(t=>ee[t.nodeType]).join(", ")})`:"()"}static generateSignatures(e,s){return 0===e.length?"()":e.map((e,i)=>t.cs(e,void 0!==s&&s.size>1&&s.has(i))).join("\n")}static cs(e,s){const i=s?" ~":"";return`(${e.parameters.map(t.ls).join(", ")})${i}`}static ls(t,e){const s=Array.from(t.expectedTypes);let i=`v${e}`;switch(t.parseMode){case oe.Optional:case oe.OptionalAsFloat:i+="?"}if(t.allowedValues&&t.allowedValues.size<5){const e=Array.from(t.allowedValues);if(s[0]===ee.String)i=e.map(t=>`"${t}"`).join("|");else i=e.join("|")}else i=Array.from(t.expectedTypes).map(t=>ee[t]).join("|");switch(t.parseMode){case oe.RequiredAsValueList:case oe.ValueListWithoutParenthesis:i+="[]"}return i}static filterSignatureCandidates(e,s,i,n,r){const a=new Set;let h=!1;for(const[o,c]of e){let e=!1;for(;!e;){const l=c.parameterIndex<c.signature.parameters.length?c.signature.parameters[c.parameterIndex]:void 0;if(l)if(c.signature.isStrict&&c.parameterIndex>0)a.add(o),e=!0;else if((l.expectedTypes.has(s.nodeType)||t.us(s,l))&&t.ds(s,l,r))switch(e=!0,h=!0,n(s,o),l.allowedValues&&c.parameterValueMatches++,l.parseMode){case oe.ValueListWithoutParenthesis:c.parameterHasValues=!0;break;case oe.RequiredAsValueList:default:c.parameterIndex++,c.parameterHasValues=!1}else switch(l.parseMode){case oe.ValueListWithoutParenthesis:c.parameterIndex++,c.parameterHasValues=!1;break;case oe.Required:case oe.RequiredAsFloat:a.add(o),e=!0;break;case oe.Optional:case oe.OptionalAsFloat:case oe.RequiredAsValueList:c.parameterIndex++,c.parameterHasValues=!1}else i||a.add(o),e=!0}}if(h)for(const t of a)e.delete(t);return h}static ds(t,e,s){switch(t.nodeType){case ee.Ident:const i=t;return e?.allowedValues?e.allowedValues.has(i.text.toLowerCase()):!e?.reservedIdentifiers||!e.reservedIdentifiers.has(i.text.toLowerCase());case ee.String:const n=t;return!e?.allowedValues||e.allowedValues.has(n.text.toLowerCase());case ee.Number:switch(e?.parseMode??oe.Optional){case oe.RequiredAsFloat:case oe.OptionalAsFloat:return s?.(t),!0;default:return!0}case ee.LParen:return!0}return!1}static us(t,e){return t.nodeType===ee.LParen&&(e.expectedTypes.has(ee.Arguments)||e.parseMode===oe.ValueListWithoutParenthesis||e.parseMode===oe.RequiredAsValueList)}},me=function(t){return t[t.Applied=0]="Applied",t[t.NotAppliedSemanticError=1]="NotAppliedSemanticError",t[t.NotAppliedUnrecognizedMarker=2]="NotAppliedUnrecognizedMarker",t}({}),ge=function(t){return t[t.AppliedNewTrack=0]="AppliedNewTrack",t[t.AppliedNewStaff=1]="AppliedNewStaff",t[t.AppliedNewVoice=2]="AppliedNewVoice",t[t.NotAppliedSemanticError=3]="NotAppliedSemanticError",t[t.NotAppliedUnrecognizedMarker=4]="NotAppliedUnrecognizedMarker",t}({}),we=class t{static fs=new Map([["acousticgrandpiano",0],["brightacousticpiano",1],["electricgrandpiano",2],["honkytonkpiano",3],["electricpiano1",4],["electricpiano2",5],["harpsichord",6],["clavinet",7],["celesta",8],["glockenspiel",9],["musicbox",10],["vibraphone",11],["marimba",12],["xylophone",13],["tubularbells",14],["dulcimer",15],["drawbarorgan",16],["percussiveorgan",17],["rockorgan",18],["churchorgan",19],["reedorgan",20],["accordion",21],["harmonica",22],["tangoaccordion",23],["acousticguitarnylon",24],["acousticguitarsteel",25],["electricguitarjazz",26],["electricguitarclean",27],["electricguitarmuted",28],["overdrivenguitar",29],["distortionguitar",30],["guitarharmonics",31],["acousticbass",32],["electricbassfinger",33],["electricbasspick",34],["fretlessbass",35],["slapbass1",36],["slapbass2",37],["synthbass1",38],["synthbass2",39],["violin",40],["viola",41],["cello",42],["contrabass",43],["tremolostrings",44],["pizzicatostrings",45],["orchestralharp",46],["timpani",47],["stringensemble1",48],["stringensemble2",49],["synthstrings1",50],["synthstrings2",51],["choiraahs",52],["voiceoohs",53],["synthvoice",54],["orchestrahit",55],["trumpet",56],["trombone",57],["tuba",58],["mutedtrumpet",59],["frenchhorn",60],["brasssection",61],["synthbrass1",62],["synthbrass2",63],["sopranosax",64],["altosax",65],["tenorsax",66],["baritonesax",67],["oboe",68],["englishhorn",69],["bassoon",70],["clarinet",71],["piccolo",72],["flute",73],["recorder",74],["panflute",75],["blownbottle",76],["shakuhachi",77],["whistle",78],["ocarina",79],["lead1square",80],["lead2sawtooth",81],["lead3calliope",82],["lead4chiff",83],["lead5charang",84],["lead6voice",85],["lead7fifths",86],["lead8bassandlead",87],["pad1newage",88],["pad2warm",89],["pad3polysynth",90],["pad4choir",91],["pad5bowed",92],["pad6metallic",93],["pad7halo",94],["pad8sweep",95],["fx1rain",96],["fx2soundtrack",97],["fx3crystal",98],["fx4atmosphere",99],["fx5brightness",100],["fx6goblins",101],["fx7echoes",102],["fx8scifi",103],["sitar",104],["banjo",105],["shamisen",106],["koto",107],["kalimba",108],["bagpipe",109],["fiddle",110],["shanai",111],["tinklebell",112],["agogo",113],["steeldrums",114],["woodblock",115],["taikodrum",116],["melodictom",117],["synthdrum",118],["reversecymbal",119],["guitarfretnoise",120],["breathnoise",121],["seashore",122],["birdtweet",123],["telephonering",124],["helicopter",125],["applause",126],["gunshot",127]]);static getValue(e){return t.fs||(t.fs=new Map),e=e.toLowerCase().replaceAll(" ",""),t.fs.has(e)?t.fs.get(e):0}static getName(e){for(const[s,i]of t.fs)if(i===e)return s;return e.toString()}static isPiano(t){return t<=7||t>=16&&t<=23}static isGuitar(t){return t>=24&&t<=39||105===t||43===t}static isBass(t){return t>=32&&t<=39}static bankToLsbMsb(t){return[127&t,t>>7&127]}},ye=class{name="";firstFret=1;strings=[];barreFrets=[];staff;showName=!0;showDiagram=!0;showFingering=!0;get uniqueId(){return[this.name,this.firstFret.toString(),this.strings.join(","),this.barreFrets.join(","),this.showDiagram.toString(),this.showFingering.toString(),this.showName.toString()].join("|")}},ke=class extends a{constructor(t){super(r.Format,t)}},Se=class t{static BlackRgb="#000000";constructor(t,e,s,i=255){this.raw=(255&i)<<24|(255&t)<<16|(255&e)<<8|255&s,this.updateRgba()}updateRgba(){255===this.a?this.rgba=`#${Bt.toHexString(this.r,2)}${Bt.toHexString(this.g,2)}${Bt.toHexString(this.b,2)}`:this.rgba=`rgba(${this.r},${this.g},${this.b},${this.a/255})`}raw=0;get a(){return this.raw>>24&255}get r(){return this.raw>>16&255}get g(){return this.raw>>8&255}get b(){return 255&this.raw}rgba;static random(e=100){return new t(255*Math.random()|0,255*Math.random()|0,255*Math.random()|0,e)}static fromJson(e){if(e instanceof t)return e;switch(typeof e){case"number":{const s=new t(0,0,0,0);return s.raw=e,s.updateRgba(),s}case"string":{const s=e;if(s.startsWith("#")){if(4===s.length)return new t(17*Number.parseInt(s[1],16),17*Number.parseInt(s[2],16),17*Number.parseInt(s[3],16));if(5===s.length)return new t(17*Number.parseInt(s[1],16),17*Number.parseInt(s[2],16),17*Number.parseInt(s[3],16),17*Number.parseInt(s[4],16));if(7===s.length)return new t(Number.parseInt(s.substring(1,3),16),Number.parseInt(s.substring(3,5),16),Number.parseInt(s.substring(5,7),16));if(9===s.length)return new t(Number.parseInt(s.substring(1,3),16),Number.parseInt(s.substring(3,5),16),Number.parseInt(s.substring(5,7),16),Number.parseInt(s.substring(7,9),16))}else if(s.startsWith("rgba")||s.startsWith("rgb")){const e=s.indexOf("("),i=s.lastIndexOf(")");if(-1===e||-1===i)throw new ke("No values specified for rgb/rgba function");const n=s.substring(e+1,i).split(",");if(3===n.length)return new t(Number.parseInt(n[0],10),Number.parseInt(n[1],10),Number.parseInt(n[2],10));if(4===n.length)return new t(Number.parseInt(n[0],10),Number.parseInt(n[1],10),Number.parseInt(n[2],10),255*Number.parseFloat(n[3]))}return null}}throw new ke("Unsupported format for color")}static toJson(t){return null===t?null:t.raw}},Be=function(t){return t[t.Short=0]="Short",t[t.Medium=1]="Medium",t[t.Long=2]="Long",t}({}),_e=class{type=0;length=0},xe=class t{static ps=10;static bs=9;static gs=13;static ws=32;static ys=93;static ks=91;static Ss=45;startBar=0;text="";chunks;finish(t=!1){this.chunks=[],this.Bs(this.text,0,this.chunks,t)}Bs(e,s,i,n){if(!e)return;let r=1,a=1,h=!1,o=0;for(;s<e.length;){const i=e.charCodeAt(s);switch(r){case 0:switch(i){case t.ps:case t.gs:case t.bs:break;case t.ws:if(!h){r=a;continue}break;default:h=!1,r=a;continue}break;case 1:if(i!==t.ks){o=s,r=2;continue}r=3;break;case 3:if(i===t.ys)r=1;break;case 2:switch(i){case t.Ss:r=4;break;case t.gs:case t.ps:case t.ws:const i=e.substr(o,s-o);this._s(i,n),r=0,a=1}break;case 4:if(i!==t.Ss){const t=e.substr(o,s-o);this._s(t,n),h=!0,r=0,a=1;continue}}s+=1}2===r&&s!==o&&this._s(e.substr(o,s-o),n)}_s(t,e){t=this.xs(t),(!e||t.length>0&&"-"!==t)&&this.chunks.push(t)}xs(t){const e=t.split("+").join(" ");let s=e.length;for(;s>0&&"_"===e.charAt(s-1);)s--;return s!==e.length?e.substr(0,s):e}},Te=class{marker="";text=""},Me=class t{static Ts=[];static Ms=[];static vs=[];static Ns=[];static Ps=new Map;static noteNames=["C","Db","D","Eb","E","F","Gb","G","Ab","A","Bb","B"];static getTextForTuning(e,s){const i=t.getTextPartsForTuning(e);return s?i.join(""):i[0]}static getTextPartsForTuning(e,s=-1){const i=e/12|0,n=e%12;return[t.noteNames[n],(i+s).toString()]}static getDefaultTuningFor(e){if(t.Ps.has(e)){const s=t.Ps.get(e);return new t(s.name,s.tunings,s.isStandard)}return null}static getPresetsFor(e){switch(e){case 7:return t.Ts;case 6:return t.Ms;case 5:return t.vs;case 4:return t.Ns}return[]}static initialize(){t.Ps.set(7,new t("Guitar 7 strings",[64,59,55,50,45,40,35],!0)),t.Ts.push(t.Ps.get(7)),t.Ps.set(6,new t("Guitar Standard Tuning",[64,59,55,50,45,40],!0)),t.Ms.push(t.Ps.get(6)),t.Ms.push(new t("Guitar Tune down ½ step",[63,58,54,49,44,39],!1)),t.Ms.push(new t("Guitar Tune down 1 step",[62,57,53,48,43,38],!1)),t.Ms.push(new t("Guitar Tune down 2 step",[60,55,51,46,41,36],!1)),t.Ms.push(new t("Guitar Dropped D Tuning",[64,59,55,50,45,38],!1)),t.Ms.push(new t("Guitar Dropped D Tuning variant",[64,57,55,50,45,38],!1)),t.Ms.push(new t("Guitar Double Dropped D Tuning",[62,59,55,50,45,38],!1)),t.Ms.push(new t("Guitar Dropped E Tuning",[66,61,57,52,47,40],!1)),t.Ms.push(new t("Guitar Dropped C Tuning",[62,57,53,48,43,36],!1)),t.Ms.push(new t("Guitar Open C Tuning",[64,60,55,48,43,36],!1)),t.Ms.push(new t("Guitar Open Cm Tuning",[63,60,55,48,43,36],!1)),t.Ms.push(new t("Guitar Open C6 Tuning",[64,57,55,48,43,36],!1)),t.Ms.push(new t("Guitar Open Cmaj7 Tuning",[64,59,55,52,43,36],!1)),t.Ms.push(new t("Guitar Open D Tuning",[62,57,54,50,45,38],!1)),t.Ms.push(new t("Guitar Open Dm Tuning",[62,57,53,50,45,38],!1)),t.Ms.push(new t("Guitar Open D5 Tuning",[62,57,50,50,45,38],!1)),t.Ms.push(new t("Guitar Open D6 Tuning",[62,59,54,50,45,38],!1)),t.Ms.push(new t("Guitar Open Dsus4 Tuning",[62,57,55,50,45,38],!1)),t.Ms.push(new t("Guitar Open E Tuning",[64,59,56,52,47,40],!1)),t.Ms.push(new t("Guitar Open Em Tuning",[64,59,55,52,47,40],!1)),t.Ms.push(new t("Guitar Open Esus11 Tuning",[64,59,55,52,45,40],!1)),t.Ms.push(new t("Guitar Open F Tuning",[65,60,53,48,45,41],!1)),t.Ms.push(new t("Guitar Open G Tuning",[62,59,55,50,43,38],!1)),t.Ms.push(new t("Guitar Open Gm Tuning",[62,58,55,50,43,38],!1)),t.Ms.push(new t("Guitar Open G6 Tuning",[64,59,55,50,43,38],!1)),t.Ms.push(new t("Guitar Open Gsus4 Tuning",[62,60,55,50,43,38],!1)),t.Ms.push(new t("Guitar Open A Tuning",[64,61,57,52,45,40],!1)),t.Ms.push(new t("Guitar Open Am Tuning",[64,60,57,52,45,40],!1)),t.Ms.push(new t("Guitar Nashville Tuning",[64,59,67,62,57,52],!1)),t.Ms.push(new t("Bass 6 Strings Tuning",[48,43,38,33,28,23],!1)),t.Ms.push(new t("Lute or Vihuela Tuning",[64,59,54,50,45,40],!1)),t.Ps.set(5,new t("Bass 5 Strings Tuning",[43,38,33,28,23],!0)),t.vs.push(t.Ps.get(5)),t.vs.push(new t("Banjo Dropped C Tuning",[62,59,55,48,67],!1)),t.vs.push(new t("Banjo Open D Tuning",[62,57,54,50,69],!1)),t.vs.push(new t("Banjo Open G Tuning",[62,59,55,50,67],!1)),t.vs.push(new t("Banjo G Minor Tuning",[62,58,55,50,67],!1)),t.vs.push(new t("Banjo G Modal Tuning",[62,57,55,50,67],!1)),t.Ps.set(4,new t("Bass Standard Tuning",[43,38,33,28],!0)),t.Ns.push(t.Ps.get(4)),t.Ns.push(new t("Bass Tune down ½ step",[42,37,32,27],!1)),t.Ns.push(new t("Bass Tune down 1 step",[41,36,31,26],!1)),t.Ns.push(new t("Bass Tune down 2 step",[39,34,29,24],!1)),t.Ns.push(new t("Bass Dropped D Tuning",[43,38,33,26],!1)),t.Ns.push(new t("Ukulele C Tuning",[45,40,36,43],!1)),t.Ns.push(new t("Ukulele G Tuning",[52,47,43,38],!1)),t.Ns.push(new t("Mandolin Standard Tuning",[64,57,50,43],!1)),t.Ns.push(new t("Mandolin or Violin Tuning",[76,69,62,55],!1)),t.Ns.push(new t("Viola Tuning",[69,62,55,48],!1)),t.Ns.push(new t("Cello Tuning",[57,50,43,36],!1))}static findTuning(e){const s=t.getPresetsFor(e.length);for(let i=0,n=s.length;i<n;i++){const n=s[i];let r=!0;for(let t=0,s=e.length;t<s;t++)if(e[t]!==n.tunings[t]){r=!1;break}if(r)return new t(n.name,n.tunings,n.isStandard)}return null}isStandard;name;tunings;constructor(t="",e=null,s=!1){this.isStandard=s,this.name=t,this.tunings=e??[]}reset(){this.isStandard=!1,this.name="",this.tunings=[]}finish(){const e=t.findTuning(this.tunings);e&&(0===this.name.length&&(this.name=e.name),this.isStandard=e.isStandard)}};Me.initialize();var ve=class t{static DefaultStandardNotationLineCount=5;index=0;track;bars=[];chords=null;capo=0;transpositionPitch=0;displayTranspositionPitch=0;stringTuning=new Me("",[],!1);get tuning(){return this.stringTuning.tunings}get tuningName(){return this.stringTuning.name}get isStringed(){return this.stringTuning.tunings.length>0}showSlash=!1;showNumbered=!1;showTablature=!0;showStandardNotation=!0;isPercussion=!1;standardNotationLineCount=t.DefaultStandardNotationLineCount;$=new Set([0]);get filledVoices(){return this.$}finish(t,e=null){this.isPercussion&&(this.stringTuning.tunings=[],this.showTablature=!1,this.displayTranspositionPitch=0),this.stringTuning.finish(),0===this.stringTuning.tunings.length&&(this.showTablature=!1);for(let s=0,i=this.bars.length;s<i;s++){this.bars[s].finish(t,e);for(const t of this.bars[s].filledVoices)this.$.add(t)}}addChord(t,e){e.staff=this;let s=this.chords;null===s&&(s=new Map,this.chords=s),s.set(t,e)}hasChord(t){return this.chords?.has(t)??!1}getChord(t){return this.chords?.get(t)??null}addBar(t){const e=this.bars;t.staff=this,t.index=e.length,e.length>0&&(t.previousBar=e[e.length-1],t.previousBar.nextBar=t),e.push(t)}},Ne=class{volume=15;balance=8;port=1;program=0;bank=0;primaryChannel=0;secondaryChannel=0;isMute=!1;isSolo=!1},Pe=function(t){return t[t.TrackName=0]="TrackName",t[t.BracesAndBrackets=1]="BracesAndBrackets",t[t.SystemSeparator=2]="SystemSeparator",t[t.StringTuning=3]="StringTuning",t}({}),Ce=class extends ${},Ee=class t{static Cs=10;index=0;score;staves=[];playbackInfo=new Ne;color=new Se(200,0,0,255);name="";isVisibleOnMultiTrack=!0;shortName="";defaultSystemsLayout=3;systemsLayout=[];lineBreaks;get isPercussion(){return this.staves.some(t=>t.isPercussion)}addLineBreaks(t){this.lineBreaks||(this.lineBreaks=new Set),this.lineBreaks.add(t)}percussionArticulations=[];style;ensureStaveCount(t){for(;this.staves.length<t;)this.addStaff(new ve)}addStaff(t){t.index=this.staves.length,t.track=this,this.staves.push(t)}finish(e,s=null){this.shortName||(this.shortName=this.name,this.shortName.length>t.Cs&&(this.shortName=this.shortName.substr(0,t.Cs)));for(const t of this.staves)t.finish(e,s),t.isPercussion&&(this.playbackInfo.program=0)}applyLyrics(t){for(const e of t)e.finish();const e=this.staves[0];for(let s=0;s<t.length;s++){const i=t[s];if(i.startBar>=0&&i.startBar<e.bars.length){let n=e.bars[i.startBar].voices[0].beats[0];for(let e=0;e<i.chunks.length&&n;e++){for(;n&&(n.isEmpty||n.isRest);)n=n.nextBeat;n&&(n.lyrics||(n.lyrics=new Array(t.length),n.lyrics.fill("")),n.lyrics[s]=i.chunks[e],n=n.nextBeat)}}}}},Fe=function(t){return t[t.Up=0]="Up",t[t.Down=1]="Down",t}({}),Ae=class t{static instance=new t;static Es=new Set([1,2,4,8,16,32,64,128]);applyScoreMetaData(e,s,i){const n=this.Fs(e,[te.scoreMetaDataSignatures],i,i.tag.tag.text.toLowerCase(),i.arguments);if(void 0!==n)return n;switch(i.tag.tag.text.toLowerCase()){case"title":return s.title=i.arguments.arguments[0].text,this.As(e,s,bt.Title,i),me.Applied;case"subtitle":return s.subTitle=i.arguments.arguments[0].text,this.As(e,s,bt.SubTitle,i),me.Applied;case"artist":return s.artist=i.arguments.arguments[0].text,this.As(e,s,bt.Artist,i),me.Applied;case"album":return s.album=i.arguments.arguments[0].text,this.As(e,s,bt.Album,i),me.Applied;case"words":return s.words=i.arguments.arguments[0].text,this.As(e,s,bt.Words,i),me.Applied;case"music":return s.music=i.arguments.arguments[0].text,this.As(e,s,bt.Music,i),me.Applied;case"copyright":return s.copyright=i.arguments.arguments[0].text,this.As(e,s,bt.Copyright,i),me.Applied;case"instructions":return s.instructions=i.arguments.arguments[0].text,me.Applied;case"notices":return s.notices=i.arguments.arguments[0].text,me.Applied;case"tab":return s.tab=i.arguments.arguments[0].text,this.As(e,s,bt.Transcriber,i),me.Applied;case"copyright2":return this.As(e,s,bt.CopyrightSecondLine,i,0),me.Applied;case"wordsandmusic":return this.As(e,s,bt.WordsAndMusic,i,0),me.Applied;case"defaultsystemslayout":return s.defaultSystemsLayout=i.arguments.arguments[0].value,me.Applied;case"systemslayout":for(const t of i.arguments.arguments)s.systemsLayout.push(t.value);return me.Applied;case"hidedynamics":return s.stylesheet.hideDynamics=!0,me.Applied;case"showdynamics":return s.stylesheet.hideDynamics=!1,me.Applied;case"extendbarlines":return s.stylesheet.extendBarLines=!0,me.Applied;case"bracketextendmode":const n=t.Ds(e,i.arguments,"bracket extend mode",Zt.bracketExtendMode);return void 0===n?me.NotAppliedSemanticError:(s.stylesheet.bracketExtendMode=n,me.Applied);case"usesystemsignseparator":return s.stylesheet.useSystemSignSeparator=!0,me.Applied;case"multibarrest":return s.stylesheet.multiTrackMultiBarRest=!0,me.Applied;case"singletracktracknamepolicy":const r=t.Ds(e,i.arguments,"track name policy",Zt.trackNamePolicy);return void 0===r?me.NotAppliedSemanticError:(s.stylesheet.singleTrackTrackNamePolicy=r,me.Applied);case"multitracktracknamepolicy":const a=t.Ds(e,i.arguments,"track name policy",Zt.trackNamePolicy);return void 0===a?me.NotAppliedSemanticError:(s.stylesheet.multiTrackTrackNamePolicy=a,me.Applied);case"firstsystemtracknamemode":const h=t.Ds(e,i.arguments,"track name mode",Zt.trackNameMode);return void 0===h?me.NotAppliedSemanticError:(s.stylesheet.firstSystemTrackNameMode=h,me.Applied);case"othersystemstracknamemode":const o=t.Ds(e,i.arguments,"track name mode",Zt.trackNameMode);return void 0===o?me.NotAppliedSemanticError:(s.stylesheet.otherSystemsTrackNameMode=o,me.Applied);case"firstsystemtracknameorientation":const c=t.Ds(e,i.arguments,"track name orientation",Zt.trackNameOrientation);return void 0===c?me.NotAppliedSemanticError:(s.stylesheet.firstSystemTrackNameOrientation=c,me.Applied);case"othersystemstracknameorientation":const l=t.Ds(e,i.arguments,"track name orientation",Zt.trackNameOrientation);return void 0===l?me.NotAppliedSemanticError:(s.stylesheet.otherSystemsTrackNameOrientation=l,me.Applied);case"chorddiagramsinscore":return s.stylesheet.globalDisplayChordDiagramsInScore=!i.arguments||t.Ls(i.arguments.arguments,0),me.Applied;case"hideemptystaves":return s.stylesheet.hideEmptyStaves=!0,me.Applied;case"hideemptystavesinfirstsystem":return s.stylesheet.hideEmptyStavesInFirstSystem=!0,me.Applied;case"showsinglestaffbrackets":return s.stylesheet.showSingleStaffBrackets=!0,me.Applied;case"defaultbarnumberdisplay":const u=t.Ds(e,i.arguments,"bar number display",Zt.barNumberDisplay);return void 0===u?me.NotAppliedSemanticError:(s.stylesheet.barNumberDisplay=u,me.Applied);default:return me.NotAppliedUnrecognizedMarker}}Fs(t,e,s,i,n){const r=e.find(t=>t.has(i));if(!r)return me.NotAppliedUnrecognizedMarker;const a=r.get(i);if(a)return this.Ws(t,a,s,n)?void 0:me.NotAppliedSemanticError;n&&n.arguments.length>0&&t.addSemanticDiagnostic({code:ie.AT300,message:"Expected no arguments, but found some.",start:n.start,end:n.end,severity:se.Warning})}applyStaffMetaData(e,s,i){const n=this.Fs(e,[te.staffMetaDataSignatures],i,i.tag.tag.text.toLowerCase(),i.arguments);if(void 0!==n)return n;switch(i.tag.tag.text.toLowerCase()){case"capo":return s.capo=i.arguments.arguments[0].value,me.Applied;case"tuning":const n=[];let r=!1,a="";for(let t=0;t<i.arguments.arguments.length;t++){const h=i.arguments.arguments[t],o=h.text;switch(o){case"piano":case"none":case"voice":e.applyStaffNoteKind(s,he.Pitched),t=i.arguments.arguments.length;break;case"hide":r=!0,e.addSemanticDiagnostic({code:ie.AT305,message:"This value should be rather specified via the properties.",start:h.start,end:h.end,severity:se.Warning});break;default:const c=Bt.parseTuning(o);if(c)n.push(c.realValue);else if(t===i.arguments.arguments.length-1&&n.length>0)a=o,e.addSemanticDiagnostic({code:ie.AT305,message:"This value should be rather specified via the properties.",start:h.start,end:h.end,severity:se.Warning});else{const t=Array.from(Bt.tuningLetters).join(","),s=Array.from(Bt.accidentalModeMapping.keys()).join(",");e.addSemanticDiagnostic({code:ie.AT209,message:`Unexpected tuning value '${o}', expected: <note><accidental><octave> where <note>=oneOf(${t}) <accidental>=oneOf(${s}), <octave>=number`,start:h.start,end:h.end,severity:se.Error})}}}return e.state.staffHasExplicitTuning.add(s),e.state.staffTuningApplied.delete(s),s.stringTuning=new Me,s.stringTuning.tunings=n,s.stringTuning.name=a,this.Rs(e,s,s.stringTuning,i),r&&(s.track.score.stylesheet.perTrackDisplayTuning||(s.track.score.stylesheet.perTrackDisplayTuning=new Map),s.track.score.stylesheet.perTrackDisplayTuning.set(s.track.index,!1)),me.Applied;case"instrument":return e.state.staffTuningApplied.delete(s),this.Os(e,s.track,i.arguments),me.Applied;case"bank":return s.track.playbackInfo.bank=i.arguments.arguments[0].value,me.Applied;case"lyrics":const h=new xe;return h.startBar=0,h.text="",2===i.arguments.arguments.length?(h.startBar=i.arguments.arguments[0].value,h.text=i.arguments.arguments[1].text):h.text=i.arguments.arguments[0].text,e.state.lyrics.get(s.track.index).push(h),me.Applied;case"chord":const o=new ye;this.Is(e,o,i),o.name=i.arguments.arguments[0].text;for(let t=1;t<i.arguments.arguments.length;t++){const s=i.arguments.arguments[t];if(s.nodeType===ee.Number)o.strings.push(s.value);else if(s.nodeType===ee.Ident){const t=s.text;"x"===t?o.strings.push(-1):e.addSemanticDiagnostic({code:ie.AT209,message:`Unexpected chord value '${t}', expected: 'x'`,severity:se.Error,start:s.start,end:s.end})}}return s.addChord(t.Gs(s,o.name),o),me.Applied;case"articulation":const c=e.state.percussionArticulationNames,l=i.arguments.arguments[0].text;if("defaults"===l){for(const[t,e]of Nt.instrumentArticulationNames)c.set(t.toLowerCase(),e),c.set(Bt.toArticulationId(t),e);return me.Applied}if(2===i.arguments.arguments.length){const t=i.arguments.arguments[1].value,s=Nt.getArticulationById(t);if(s)return c.set(l.toLowerCase(),s.uniqueId),me.Applied;{const s=Array.from(Nt.instrumentArticulationIds()).map(t=>`${t}`).join(",");return e.addSemanticDiagnostic({code:ie.AT209,message:`Unexpected articulation value '${t}', expected: ${s}`,start:i.arguments.arguments[1].start,end:i.arguments.arguments[1].end,severity:se.Error}),me.NotAppliedSemanticError}}return me.Applied;case"accidentals":return t.Hs(e,i.arguments);case"displaytranspose":return s.displayTranspositionPitch=-1*i.arguments.arguments[0].value,e.state.staffHasExplicitDisplayTransposition.add(s),me.Applied;case"transpose":return s.transpositionPitch=-1*i.arguments.arguments[0].value,me.Applied;default:return me.NotAppliedUnrecognizedMarker}}applyBarMetaData(e,s,i){const n=this.Fs(e,[te.barMetaDataSignatures],i,i.tag.tag.text.toLowerCase(),i.arguments);if(void 0!==n)return n;switch(i.tag.tag.text.toLowerCase()){case"sync":const n=this.$s(i);return e.state.syncPoints.push(n),me.Applied;case"tempo":let r=0;const a=i.arguments.arguments[r++].value;let h="",o=!0,c=0;for(;r<i.arguments.arguments.length;){switch(i.arguments.arguments[r].nodeType){case ee.Ident:case ee.String:const t=i.arguments.arguments[r].text;"hide"===t?o=!1:h=t;break;case ee.Number:c=i.arguments.arguments[r].value}r++}let u=s.masterBar.tempoAutomations.find(t=>t.ratioPosition===c);return u||(u=new d,s.masterBar.tempoAutomations.push(u)),u.isLinear=!1,u.type=l.Tempo,u.value=a,u.text=h,u.ratioPosition=c,u.isVisible=o,me.Applied;case"rc":return s.masterBar.repeatCount=i.arguments.arguments[0].value,me.Applied;case"ae":for(const t of i.arguments.arguments)if(t.nodeType===ee.Number){const i=t.value;if(i<1||i>31)return e.addSemanticDiagnostic({code:ie.AT211,message:"Value is out of valid range. Allowed range: %s, Actual Value: %s",severity:se.Error,start:t.start,end:t.end}),me.NotAppliedSemanticError;s.masterBar.alternateEndings|=1<<i-1}else e.addSemanticDiagnostic({code:ie.AT202,message:`Unexpected '${ee[t.nodeType]}' token. Expected one of following: ${ee[ee.Number]}`,severity:se.Error,start:t.start,end:t.end});return me.Applied;case"ts":switch(i.arguments.arguments[0].nodeType){case ee.Number:if(s.masterBar.timeSignatureNumerator=0|i.arguments.arguments[0].value,(s.masterBar.timeSignatureNumerator<1||s.masterBar.timeSignatureNumerator>32)&&e.addSemanticDiagnostic({code:ie.AT211,message:`Value is out of valid range. Allowed range: 1-32, Actual Value: ${s.masterBar.timeSignatureNumerator}`,start:i.arguments.arguments[0].start,end:i.arguments.arguments[0].end,severity:se.Error}),s.masterBar.timeSignatureDenominator=0|i.arguments.arguments[1].value,!t.Es.has(s.masterBar.timeSignatureDenominator)){const n=Array.from(t.Es).join(", ");e.addSemanticDiagnostic({code:ie.AT211,message:`Value is out of valid range. Allowed range: ${n}, Actual Value: ${s.masterBar.timeSignatureDenominator}`,start:i.arguments.arguments[0].start,end:i.arguments.arguments[0].end,severity:se.Error})}break;case ee.Ident:case ee.String:const n=i.arguments.arguments[0].text;if("common"!==n.toLowerCase())return e.addSemanticDiagnostic({code:ie.AT209,message:`Unexpected time signature value '${n}', expected: common or two numbers`,severity:se.Error,start:i.arguments.arguments[0].start,end:i.arguments.arguments[0].end}),me.NotAppliedSemanticError;s.masterBar.timeSignatureCommon=!0,s.masterBar.timeSignatureNumerator=4,s.masterBar.timeSignatureDenominator=4}return me.Applied;case"beaming":return this.Vs(e,i,s.masterBar);case"ks":const f=t.Ds(e,i.arguments,"key signature",Zt.keySignature);if(void 0===f)return me.NotAppliedSemanticError;const p=t.Ds(e,i.arguments,"key signature type",Zt.keySignatureType);return void 0===p?me.NotAppliedSemanticError:(s.keySignature=f,s.keySignatureType=p,me.Applied);case"clef":switch(i.arguments.arguments[0].nodeType){case ee.Ident:case ee.String:const n=t.Ds(e,i.arguments,"clef",Zt.clef);if(void 0===n)return me.NotAppliedSemanticError;s.clef=n;break;case ee.Number:const r=i.arguments.arguments[0].value;switch(r){case 0:s.clef=G.Neutral;break;case 43:s.clef=G.G2;break;case 65:s.clef=G.F4;break;case 48:s.clef=G.C3;break;case 60:s.clef=G.C4;break;default:return e.addSemanticDiagnostic({code:ie.AT209,message:`Unexpected clef value '${r}', expected: ${Array.from(Zt.clef.keys()).join(",")}`,severity:se.Error,start:i.arguments.arguments[0].start,end:i.arguments.arguments[0].end}),me.NotAppliedSemanticError}}return me.Applied;case"section":const b=new Te;return 1===i.arguments.arguments.length?b.text=i.arguments.arguments[0].text:(b.marker=i.arguments.arguments[0].text,b.text=i.arguments.arguments[1].text),s.masterBar.section=b,me.Applied;case"tf":switch(i.arguments.arguments[0].nodeType){case ee.Ident:case ee.String:const n=t.Ds(e,i.arguments,"triplet feel",Zt.tripletFeel);if(void 0===n)return me.NotAppliedSemanticError;s.masterBar.tripletFeel=n;break;case ee.Number:const r=i.arguments.arguments[0].value;switch(r){case 0:s.masterBar.tripletFeel=K.NoTripletFeel;break;case 1:s.masterBar.tripletFeel=K.Triplet16th;break;case 2:s.masterBar.tripletFeel=K.Triplet8th;break;case 3:s.masterBar.tripletFeel=K.Dotted16th;break;case 4:s.masterBar.tripletFeel=K.Dotted8th;break;case 5:s.masterBar.tripletFeel=K.Scottish16th;break;case 6:s.masterBar.tripletFeel=K.Scottish8th;break;default:return e.addSemanticDiagnostic({code:ie.AT209,message:`Unexpected triplet feel value '${r}', expected: ${Array.from(Zt.tripletFeel.keys()).join(",")}`,severity:se.Error,start:i.arguments.arguments[0].start,end:i.arguments.arguments[0].end}),me.NotAppliedSemanticError}}return me.Applied;case"barlineleft":const m=t.Ds(e,i.arguments,"bar line",Zt.barLineStyle);return void 0===m?me.NotAppliedSemanticError:(s.barLineLeft=m,me.Applied);case"barlineright":const g=t.Ds(e,i.arguments,"bar line",Zt.barLineStyle);return void 0===g?me.NotAppliedSemanticError:(s.barLineRight=g,me.Applied);case"accidentals":return t.Hs(e,i.arguments);case"voicemode":return t.zs(e,i.arguments);case"jump":const w=t.Ds(e,i.arguments,"direction",Zt.direction);return void 0===w?me.NotAppliedSemanticError:(s.masterBar.addDirection(w),me.Applied);case"ottava":const y=t.Ds(e,i.arguments,"clef ottava",Zt.ottavia);return void 0===y?me.NotAppliedSemanticError:(s.clefOttava=y,me.Applied);case"simile":const k=t.Ds(e,i.arguments,"simile mark",Zt.simileMark);return void 0===k?me.NotAppliedSemanticError:(s.simileMark=k,me.Applied);case"width":return s.masterBar.displayWidth=i.arguments.arguments[0].value,s.displayWidth=s.masterBar.displayWidth,me.Applied;case"scale":return s.masterBar.displayScale=i.arguments.arguments[0].value,s.displayScale=s.masterBar.displayScale,me.Applied;case"spd":const S=new X;return S.pedalType=U.Down,S.ratioPosition=i.arguments.arguments[0].value,s.sustainPedals.push(S),me.Applied;case"spu":const B=new X;return B.pedalType=U.Up,B.ratioPosition=i.arguments.arguments[0].value,s.sustainPedals.push(B),me.Applied;case"sph":const _=new X;return _.pedalType=U.Hold,_.ratioPosition=i.arguments.arguments[0].value,s.sustainPedals.push(_),me.Applied;case"ft":return s.masterBar.isFreeTime=!0,me.Applied;case"ro":return s.masterBar.isRepeatStart=!0,me.Applied;case"ac":return s.masterBar.isAnacrusis=!0,me.Applied;case"db":return s.masterBar.isDoubleBar=!0,s.barLineRight=q.LightLight,me.Applied;case"barnumberdisplay":const x=t.Ds(e,i.arguments,"bar number display",Zt.barNumberDisplay);return void 0===x?me.NotAppliedSemanticError:(s.barNumberDisplay=x,me.Applied);default:return me.NotAppliedUnrecognizedMarker}}Vs(t,e,s){let i=w.Eighth;const n=[],r=e.arguments.arguments[0].value;switch(r){case 4:i=w.QuadrupleWhole;break;case 8:i=w.Eighth;break;case 16:i=w.Sixteenth;break;case 32:i=w.ThirtySecond;break;default:return t.addSemanticDiagnostic({code:ie.AT209,message:`Value is out of valid range. Allowed range: 4,8,16 or 32, Actual Value: ${r}`,severity:se.Error,start:e.arguments.arguments[0].start,end:e.arguments.arguments[0].end}),me.NotAppliedSemanticError}for(let s=1;s<e.arguments.arguments.length;s++){if(e.arguments.arguments[s].value<1)return t.addSemanticDiagnostic({code:ie.AT209,message:`Value is out of valid range. Allowed range: >0, Actual Value: ${r}`,severity:se.Error,start:e.arguments.arguments[s].start,end:e.arguments.arguments[s].end}),me.NotAppliedSemanticError;n.push(e.arguments.arguments[s].value)}return s.beamingRules||(s.beamingRules=new Q),s.beamingRules.groups.set(i,n),me.Applied}static Hs(e,s){const i=t.Ds(e,s,"accidental mode",Zt.alphaTexAccidentalMode);return void 0===i?me.NotAppliedSemanticError:(e.state.accidentalMode=i,me.Applied)}static zs(e,s){const i=t.Ds(e,s,"voice mode",Zt.alphaTexVoiceMode);return void 0===i?me.NotAppliedSemanticError:(e.state.voiceMode=i,me.Applied)}static Gs(t,e){return e.toLowerCase()+t.index+t.track.index}$s(t){const e=t.arguments.arguments[0].value,s=t.arguments.arguments[1].value,i=t.arguments.arguments[2].value;let n=0;return t.arguments.arguments.length>3&&(n=t.arguments.arguments[3].value),{barIndex:e,barOccurence:s,barPosition:n,millisecondOffset:i}}Ws(t,e,s,i){if(!i)return!!e.some(t=>0===t.parameters.length||!t.parameters.some(t=>t.parseMode===oe.Required||t.parseMode===oe.RequiredAsFloat||t.parseMode===oe.RequiredAsValueList))||(t.addSemanticDiagnostic({code:ie.AT219,message:`Error parsing arguments: no overload matched arguments ${be.generateSignaturesFromArguments(void 0)}. Signatures: ${be.generateSignatures(e)}`,severity:se.Error,start:s.start,end:s.end}),!1);if(i.validated)return!0;let n=!1;const r=new Map(e.map((t,e)=>[e,{signature:t,parameterIndex:0,parameterValueMatches:0,parameterHasValues:!1}])),a=t.parseMode===de.Full,h=a?(t,e)=>{const s=r.get(e),i=t;i.parameterIndices||(i.parameterIndices=new Map),i.parameterIndices.set(e,s.parameterIndex)}:(t,e)=>{};for(const t of i.arguments)if(be.filterSignatureCandidates(r,t,!1,h),0===r.size)break;const o=a?Array.from(r.entries()):void 0;return be.filterIncompleteCandidates(r),0===r.size&&(t.addSemanticDiagnostic({code:ie.AT219,message:`Error parsing arguments: no overload matched arguments ${be.generateSignaturesFromArguments(i.arguments)}. Signatures:\n${be.generateSignatures(e)}`,severity:se.Error,start:i.start,end:i.end}),n=!0),o&&(be.sortCandidates(o),i.signatureCandidateIndices=o.map(t=>t[0])),!n}As(e,s,i,n,r=1){const a=n.arguments.arguments.length-r;if(a<1)return;const h=Bt.getOrCreateHeaderFooterStyle(s,i);void 0===h.isVisible&&(h.isVisible=!0);const o=n.arguments.arguments[r].text;if(o?h.template=o:h.isVisible=!1,a<2)return;const c=t.Ds(e,n.arguments,"textAlign",Zt.textAlign,r+1);void 0!==c&&(h.textAlign=c)}Os(t,e,s){switch(s.arguments[0].nodeType){case ee.Number:const i=s.arguments[0].value;i>=0&&i<=127?e.playbackInfo.program=i:t.addSemanticDiagnostic({code:ie.AT211,message:`Value is out of valid range. Allowed range: 0-127, Actual Value: ${i}`,start:s.arguments[0].start,end:s.arguments[0].end,severity:se.Error});break;case ee.Ident:case ee.String:const n=s.arguments[0].text.toLowerCase();if("percussion"===n){for(const s of e.staves)t.applyStaffNoteKind(s,he.Articulation);e.playbackInfo.primaryChannel=yt.PercussionChannel,e.playbackInfo.secondaryChannel=yt.PercussionChannel}else e.playbackInfo.program=we.getValue(n)}}Is(e,s,i){if(i.properties)for(const n of i.properties.properties)if(this.Us(e,[te.metaDataProperties.get("chord")],n))switch(n.property.text.toLowerCase()){case"firstfret":s.firstFret=n.arguments.arguments[0].value;break;case"showdiagram":s.showDiagram=t.Ls(n.arguments.arguments,0);break;case"showfingering":s.showFingering=t.Ls(n.arguments.arguments,0);break;case"showname":s.showName=t.Ls(n.arguments.arguments,0);break;case"barre":s.barreFrets=n.arguments.arguments.map(t=>t.value)}}Rs(t,e,s,i){if(i.properties)for(const n of i.properties.properties)if(this.Us(t,[te.metaDataProperties.get("tuning")],n))switch(n.property.text.toLowerCase()){case"hide":e.track.score.stylesheet.perTrackDisplayTuning||(e.track.score.stylesheet.perTrackDisplayTuning=new Map),e.track.score.stylesheet.perTrackDisplayTuning.set(e.track.index,!1);break;case"label":s.name=n.arguments.arguments[0].text}}static Ls(t,e){if(e>=t.length)return!0;const s=t[e];switch(s.nodeType){case ee.String:case ee.Ident:return"false"!==s.text;case ee.Number:return 0!==s.value;default:return!1}}applyStructuralMetaData(t,e){const s=this.Fs(t,[te.structuralMetaDataSignatures],e,e.tag.tag.text.toLowerCase(),e.arguments);if(void 0!==s)switch(s){case me.NotAppliedSemanticError:return ge.NotAppliedSemanticError;case me.NotAppliedUnrecognizedMarker:return ge.NotAppliedUnrecognizedMarker}switch(e.tag.tag.text.toLowerCase()){case"staff":const s=t.startNewStaff();return this.Xs(t,s,e),ge.AppliedNewStaff;case"track":const i=t.startNewTrack();return e.arguments&&e.arguments.arguments.length>0&&(i.name=e.arguments.arguments[0].text,e.arguments.arguments.length>1&&(i.shortName=e.arguments.arguments[1].text)),this.js(t,i,e),ge.AppliedNewTrack;case"voice":return t.startNewVoice(),ge.AppliedNewVoice;default:return ge.NotAppliedUnrecognizedMarker}}Us(t,e,s){const i=this.Fs(t,e,s,s.property.text.toLowerCase(),s.arguments);if(void 0!==i)switch(i){case me.Applied:case me.NotAppliedSemanticError:return!1;case me.NotAppliedUnrecognizedMarker:const i=e.flatMap(t=>Array.from(t.keys()));return t.addSemanticDiagnostic({code:ie.AT212,message:`Unrecogized property '${s.property.text}', expected one of ${i}`,severity:se.Error,start:s.start,end:s.end}),!1}return!0}Xs(t,e,s){if(!s.properties)return;let i=!1,n=!1,r=!1,a=!1;for(const h of s.properties.properties)if(this.Us(t,[te.metaDataProperties.get("staff")],h))switch(h.property.text.toLowerCase()){case"score":i=!0,h.arguments&&h.arguments.arguments.length>0&&(e.standardNotationLineCount=h.arguments.arguments[0].value);break;case"tabs":n=!0;break;case"slash":r=!0;break;case"numbered":a=!0}(i||n||r||a)&&(e.showStandardNotation=i,e.showTablature=n,e.showSlash=r,e.showNumbered=a)}js(t,e,s){if(s.properties)for(const i of s.properties.properties)if(this.Us(t,[te.metaDataProperties.get("track")],i))switch(i.property.text.toLowerCase()){case"color":try{e.color=Se.fromJson(i.arguments.arguments[0].text)}catch{t.addSemanticDiagnostic({code:ie.AT213,message:"Invalid format for color",severity:se.Error,start:i.arguments.arguments[0].start,end:i.arguments.arguments[0].end})}break;case"defaultsystemslayout":e.defaultSystemsLayout=i.arguments.arguments[0].value;break;case"systemslayout":e.systemsLayout=i.arguments.arguments.map(t=>t.value);break;case"volume":e.playbackInfo.volume=i.arguments.arguments[0].value;break;case"balance":e.playbackInfo.balance=i.arguments.arguments[0].value;break;case"mute":e.playbackInfo.isMute=!0;break;case"solo":e.playbackInfo.isSolo=!0;break;case"multibarrest":e.score.stylesheet.perTrackMultiBarRest||(e.score.stylesheet.perTrackMultiBarRest=new Set),e.score.stylesheet.perTrackMultiBarRest.add(e.index);break;case"instrument":this.Os(t,e,i.arguments);break;case"bank":e.playbackInfo.bank=i.arguments.arguments[0].value}}applyBeatDurationProperty(e,s){const i=this.Fs(e,[te.durationChangeProperties],s,s.property.text.toLowerCase(),s.arguments);if(void 0!==i)return i;if("tu"===s.property.text.toLowerCase()){if(2===s.arguments.arguments.length)e.state.currentTupletNumerator=s.arguments.arguments[0].value,e.state.currentTupletDenominator=s.arguments.arguments[1].value;else{const i=s.arguments.arguments[0].value;e.state.currentTupletNumerator=i;const n=t.Js(i);n<0?(e.addSemanticDiagnostic({code:ie.AT209,message:`Unexpected default tuplet value '${i}', expected: 3, 5, 6, 7, 9, 10, 11 or 12`,severity:se.Error,start:s.arguments.arguments[0].start,end:s.arguments.arguments[0].end}),e.state.currentTupletNumerator=-1,e.state.currentTupletDenominator=-1):e.state.currentTupletDenominator=n}return me.Applied}return me.NotAppliedUnrecognizedMarker}static Js(t){switch(t){case 3:return 2;case 5:case 6:case 7:return 4;case 9:case 10:case 11:case 12:return 8;default:return-1}}qs=void 0;get allKnownMetaDataTags(){if(!this.qs){this.qs=new Set;const t=[te.scoreMetaDataSignatures.keys(),te.structuralMetaDataSignatures.keys(),te.staffMetaDataSignatures.keys(),te.barMetaDataSignatures.keys()];for(const e of t)for(const t of e)this.qs.add(t)}return this.qs}Ys=void 0;get knownScoreMetaDataTags(){return this.Ys||(this.Ys=new Set(te.scoreMetaDataSignatures.keys())),this.Ys}Ks=void 0;get knownStructuralMetaDataTags(){return this.Ks||(this.Ks=new Set(te.structuralMetaDataSignatures.keys())),this.Ks}Qs=void 0;get knownBarMetaDataTags(){return this.Qs||(this.Qs=new Set(te.barMetaDataSignatures.keys())),this.Qs}Zs=void 0;get knownStaffMetaDataTags(){return this.Zs||(this.Zs=new Set(te.staffMetaDataSignatures.keys())),this.Zs}ti=void 0;get knownBeatDurationProperties(){return this.ti||(this.ti=new Set(te.durationChangeProperties.keys())),this.ti}ei=void 0;get knownBeatProperties(){return this.ei||(this.ei=new Set(te.beatProperties.keys())),this.ei}si=void 0;get knownNoteProperties(){return this.si||(this.si=new Set(te.noteProperties.keys())),this.si}applyBeatProperty(e,s,i){const n=i.property.text.toLowerCase(),r=this.Fs(e,[te.beatProperties],i,n,i.arguments);if(void 0!==r)return r;switch(n){case"f":return s.fade=Rt.FadeIn,me.Applied;case"fo":return s.fade=Rt.FadeOut,me.Applied;case"vs":return s.fade=Rt.VolumeSwell,me.Applied;case"v":return s.vibrato=P.Slight,me.Applied;case"vw":return s.vibrato=P.Wide,me.Applied;case"s":return s.slap=!0,me.Applied;case"p":return s.pop=!0,me.Applied;case"tt":return s.tap=!0,me.Applied;case"txt":return s.text=i.arguments.arguments[0].text,me.Applied;case"lyrics":let r=0,a="";for(2===i.arguments.arguments.length?(r=i.arguments.arguments[0].value,a=i.arguments.arguments[1].text):a=i.arguments.arguments[0].text,s.lyrics||(s.lyrics=[]);s.lyrics.length<=r;)s.lyrics.push("");return s.lyrics[r]=a,me.Applied;case"dd":return s.dots=2,me.Applied;case"d":return s.dots=1,me.Applied;case"su":return s.pickStroke=_t.Up,me.Applied;case"sd":return s.pickStroke=_t.Down,me.Applied;case"tu":if(2===i.arguments.arguments.length)s.tupletNumerator=i.arguments.arguments[0].value,s.tupletDenominator=i.arguments.arguments[1].value;else{const n=i.arguments.arguments[0].value;s.tupletNumerator=n;const r=t.Js(n);if(r<0)return e.addSemanticDiagnostic({code:ie.AT209,message:`Unexpected default tuplet value '${n}', expected: 3, 5, 6, 7, 9, 10, 11 or 12`,severity:se.Error,start:i.arguments.arguments[0].start,end:i.arguments.arguments[0].end}),s.tupletNumerator=-1,s.tupletDenominator=-1,me.NotAppliedSemanticError;s.tupletDenominator=r}return me.Applied;case"tb":case"tbe":let h=0,o=!0,c=!1;for(;o;)switch(i.arguments.arguments[h].nodeType){case ee.Ident:case ee.String:const n=i.arguments.arguments[h].text.toLowerCase();if(Zt.whammyType.has(n))s.whammyBarType=Zt.whammyType.get(n),c=!0,h++;else{if(!Zt.bendStyle.has(n))return c?t.Ds(e,i.arguments,"whammy style",Zt.bendStyle,h):t.Ds(e,i.arguments,"whammy type",Zt.whammyType,h),me.NotAppliedSemanticError;s.whammyStyle=Zt.bendStyle.get(n),h++}break;default:o=!1}const u=this.ii(e,i,h,"tbe"===n);if(u)for(const t of u)s.addWhammyBarPoint(t);return me.Applied;case"bu":return t.ni(s,i,m.BrushUp,.25),me.Applied;case"bd":return t.ni(s,i,m.BrushDown,.25),me.Applied;case"au":return t.ni(s,i,m.ArpeggioUp,1),me.Applied;case"ad":return t.ni(s,i,m.ArpeggioDown,1),me.Applied;case"ch":const f=i.arguments.arguments[0].text,p=t.Gs(s.voice.bar.staff,f);if(!s.voice.bar.staff.hasChord(p)){const t=new ye;t.showDiagram=!1,t.name=f,s.voice.bar.staff.addChord(p,t)}return s.chordId=p,me.Applied;case"gr":if(i.arguments&&i.arguments.arguments.length>0){const n=t.Ds(e,i.arguments,"whammy style",Zt.graceType);if(void 0===n)return me.NotAppliedSemanticError;s.graceType=n}else s.graceType=y.BeforeBeat;return me.Applied;case"dy":const b=t.Ds(e,i.arguments,"dynamic",Zt.dynamicValue);return void 0===b?me.NotAppliedSemanticError:(s.dynamics=b,e.state.currentDynamics=b,me.Applied);case"cre":return s.crescendo=g.Crescendo,me.Applied;case"dec":return s.crescendo=g.Decrescendo,me.Applied;case"tempo":const w=i.arguments.arguments[0].value;let k="",S=!0;if(i.arguments.arguments.length>2){k=i.arguments.arguments[1].text;const t=i.arguments.arguments[2].text;if("hide"!==t)return e.addSemanticDiagnostic({code:ie.AT209,message:`Unexpected third tempo property value '${t}', expected: 'hide'`,severity:se.Error,start:i.arguments.arguments[2].start,end:i.arguments.arguments[2].end}),me.NotAppliedSemanticError;S=!1}else i.arguments.arguments.length>1&&(k=i.arguments.arguments[1].text,"hide"===k&&(S=!1,k=""));const B=new d;return B.isLinear=!1,B.type=l.Tempo,B.value=w,B.text=k,B.isVisible=S,s.automations.push(B),s.voice.bar.masterBar.tempoAutomations.push(B),me.Applied;case"volume":const _=new d;return _.isLinear=!0,_.type=l.Volume,_.value=i.arguments.arguments[0].value,s.automations.push(_),me.Applied;case"balance":const x=new d;return x.isLinear=!0,x.type=l.Balance,x.value=Bt.clamp(i.arguments.arguments[0].value,0,16),s.automations.push(x),me.Applied;case"tp":const T=new $t;if(s.tremoloPicking=T,i.arguments&&i.arguments.arguments.length>0){if(i.arguments.arguments.length>0){const t=i.arguments.arguments[0].value;if(t>=$t.minMarks&&t<=$t.maxMarks)T.marks=t;else switch(t){case 8:T.marks=1;break;case 16:T.marks=2;break;case 32:T.marks=3;break;default:return e.addSemanticDiagnostic({code:ie.AT209,message:`Unexpected tremolo marks value '${t}, expected: ${$t.minMarks}-${$t.maxMarks}, or legacy: 8, 16 or 32`,severity:se.Error,start:i.arguments.arguments[0].start,end:i.arguments.arguments[0].end}),me.NotAppliedSemanticError}}if(i.arguments.arguments.length>1){const s=t.Ds(e,i.arguments,"tremolo picking style",Zt.tremoloPickingStyle,1);if(void 0===s)return me.NotAppliedSemanticError;T.style=s}}return me.Applied;case"spd":return t.ri(e,s,U.Down),me.Applied;case"sph":return t.ri(e,s,U.Hold),me.Applied;case"spu":return t.ri(e,s,U.Up),me.Applied;case"spe":return t.ri(e,s,U.Up,!0),me.Applied;case"slashed":return s.slashed=!0,me.Applied;case"ds":return s.deadSlapped=!0,1===s.notes.length&&s.notes[0].isDead&&s.removeNote(s.notes[0]),me.Applied;case"glpf":return s.golpe=Wt.Finger,me.Applied;case"glpt":return s.golpe=Wt.Thumb,me.Applied;case"waho":return s.wahPedal=Ot.Open,me.Applied;case"wahc":return s.wahPedal=Ot.Closed,me.Applied;case"barre":if(s.barreFret=i.arguments.arguments[0].value,s.barreShape=It.Full,i.arguments.arguments.length>1){const n=t.Ds(e,i.arguments,"barre shape",Zt.barreShape,1);if(void 0===n)return me.NotAppliedSemanticError;s.barreShape=n}return me.Applied;case"rasg":const M=t.Ds(e,i.arguments,"rasgueado pattern",Zt.rasgueado);return void 0===M?me.NotAppliedSemanticError:(s.rasgueado=M,me.Applied);case"ot":const v=t.Ds(e,i.arguments,"ottava",Zt.ottavia);return void 0===v?me.NotAppliedSemanticError:(s.ottava=v,me.Applied);case"legatoorigin":return s.isLegatoOrigin=!0,me.Applied;case"instrument":let N=0;switch(i.arguments.arguments[0].nodeType){case ee.Ident:case ee.String:N=we.getValue(i.arguments.arguments[0].text);break;case ee.Number:N=i.arguments.arguments[0].value}const C=new d;return C.isLinear=!1,C.type=l.Instrument,C.value=N,s.automations.push(C),me.Applied;case"bank":const E=new d;return E.isLinear=!1,E.type=l.Bank,E.value=i.arguments.arguments[0].value,s.automations.push(E),me.Applied;case"fermata":const F=t.Ds(e,i.arguments,"fermata",Zt.fermataType);if(void 0===F)return me.NotAppliedSemanticError;const A=new _e;return A.type=F,i.arguments.arguments.length>1&&(A.length=i.arguments.arguments[1].value),s.fermata=A,me.Applied;case"beam":const D=i.arguments.arguments[0].text;switch(D.toLowerCase()){case"invert":s.invertBeamDirection=!0;break;case"up":s.preferredBeamDirection=Fe.Up;break;case"down":s.preferredBeamDirection=Fe.Down;break;case"auto":s.beamingMode=Vt.Auto;break;case"split":s.beamingMode=Vt.ForceSplitToNext;break;case"merge":s.beamingMode=Vt.ForceMergeWithNext;break;case"splitsecondary":s.beamingMode=Vt.ForceSplitOnSecondaryToNext;break;default:return e.addSemanticDiagnostic({code:ie.AT209,message:`Unexpected beam value '${D}', expected: ${["invert","up","down","auto","split","merge","splitsecondary"].join(",")}`,severity:se.Error,start:i.arguments.arguments[0].start,end:i.arguments.arguments[0].end}),me.NotAppliedSemanticError}return me.Applied;case"timer":return s.showTimer=!0,me.Applied}return me.NotAppliedUnrecognizedMarker}static ri(t,e,s,i=!1){const n=new X;n.pedalType=s,n.ratioPosition=i?1:.001*e.voice.bar.sustainPedals.length,t.state.sustainPedalToBeat.set(n,e),e.voice.bar.sustainPedals.push(n)}static ni(t,e,s,i){t.brushType=s,e.arguments&&e.arguments.arguments.length>0?t.brushDuration=e.arguments.arguments[0].value:(t.updateDurations(),t.brushDuration=t.playbackDuration*i/t.notes.length)}applyNoteProperty(e,s,i){const n=i.property.text.toLowerCase(),r=this.Fs(e,[te.noteProperties],i,n,i.arguments);if(void 0!==r)return r;switch(n){case"b":case"be":let r=0,a=!0,h=!1;for(;a;)switch(i.arguments.arguments[r].nodeType){case ee.Ident:case ee.String:const n=i.arguments.arguments[r].text.toLowerCase();if(Zt.bendType.has(n))s.bendType=Zt.bendType.get(n),h=!0,r++;else{if(!Zt.bendStyle.has(n))return h?t.Ds(e,i.arguments,"bend style",Zt.bendStyle,r):t.Ds(e,i.arguments,"bend type",Zt.bendType,r),me.NotAppliedSemanticError;s.bendStyle=Zt.bendStyle.get(n),r++}break;default:a=!1}const o=this.ii(e,i,r,"be"===n);if(o)for(const t of o)s.addBendPoint(t);return me.Applied;case"nh":return s.harmonicType=B.Natural,s.harmonicValue=Bt.deltaFretToHarmonicValue(s.fret),me.Applied;case"ah":return s.harmonicType=B.Artificial,s.harmonicValue=t.ai(i.arguments,s.harmonicValue),me.Applied;case"th":return s.harmonicType=B.Tap,s.harmonicValue=t.ai(i.arguments,s.harmonicValue),me.Applied;case"ph":return s.harmonicType=B.Pinch,s.harmonicValue=t.ai(i.arguments,s.harmonicValue),me.Applied;case"sh":return s.harmonicType=B.Semi,s.harmonicValue=t.ai(i.arguments,s.harmonicValue),me.Applied;case"fh":return s.harmonicType=B.Feedback,s.harmonicValue=t.ai(i.arguments,s.harmonicValue),me.Applied;case"tr":const c=i.arguments.arguments[0].value;let l=w.Sixteenth;if(i.arguments.arguments.length>1){const t=i.arguments.arguments[1].value;switch(t){case 16:l=w.Sixteenth;break;case 32:l=w.ThirtySecond;break;case 64:l=w.SixtyFourth;break;default:return e.addSemanticDiagnostic({code:ie.AT209,message:`Unexpected trill duration value '${t}', expected: 16, 32 or 64`,severity:se.Error,start:i.arguments.arguments[1].start,end:i.arguments.arguments[1].end}),me.NotAppliedSemanticError}}return s.trillValue=c+s.stringTuning,s.trillSpeed=l,me.Applied;case"v":return s.vibrato=P.Slight,me.Applied;case"vw":return s.vibrato=P.Wide,me.Applied;case"sl":return s.slideOutType=M.Legato,me.Applied;case"ss":return s.slideOutType=M.Shift,me.Applied;case"sib":return s.slideInType=T.IntoFromBelow,me.Applied;case"sia":return s.slideInType=T.IntoFromAbove,me.Applied;case"sou":return s.slideOutType=M.OutUp,me.Applied;case"sod":return s.slideOutType=M.OutDown,me.Applied;case"psd":return s.slideOutType=M.PickSlideDown,me.Applied;case"psu":return s.slideOutType=M.PickSlideUp,me.Applied;case"h":return s.isHammerPullOrigin=!0,me.Applied;case"lht":return s.isLeftHandTapped=!0,me.Applied;case"g":return s.isGhost=!0,me.Applied;case"ac":return s.accentuated=k.Normal,me.Applied;case"hac":return s.accentuated=k.Heavy,me.Applied;case"ten":return s.accentuated=k.Tenuto,me.Applied;case"pm":return s.isPalmMute=!0,me.Applied;case"st":return s.isStaccato=!0,me.Applied;case"lr":return s.isLetRing=!0,me.Applied;case"x":return s.isDead=!0,me.Applied;case"-":case"t":return s.isTieDestination=!0,me.Applied;case"lf":let u=S.Thumb;if(i.arguments&&i.arguments.arguments.length>0){const s=t.hi(e,i.arguments);if(void 0===s)return me.NotAppliedSemanticError;u=s}return s.leftHandFinger=u,me.Applied;case"rf":let d=S.Thumb;if(i.arguments&&i.arguments.arguments.length>0){const s=t.hi(e,i.arguments);if(void 0===s)return me.NotAppliedSemanticError;d=s}return s.rightHandFinger=d,me.Applied;case"acc":return s.accidentalMode=Bt.parseAccidentalMode(i.arguments.arguments[0].text),me.Applied;case"turn":return s.ornament=Pt.Turn,me.Applied;case"iturn":return s.ornament=Pt.InvertedTurn,me.Applied;case"umordent":return s.ornament=Pt.UpperMordent,me.Applied;case"lmordent":return s.ornament=Pt.LowerMordent,me.Applied;case"string":return s.showStringNumber=!0,me.Applied;case"hide":return s.isVisible=!1,me.Applied;case"slur":const f=i.arguments.arguments[0].text;if(e.state.slurs.has(f)){const t=e.state.slurs.get(f);t.slurDestination=s,s.slurOrigin=t,s.isSlurDestination=!0}else e.state.slurs.set(f,s);return me.Applied;default:return this.applyBeatProperty(e,s.beat,i)}return me.NotAppliedUnrecognizedMarker}static hi(t,e){const s=e.arguments[0].value;switch(s){case 1:return S.Thumb;case 2:return S.IndexFinger;case 3:return S.MiddleFinger;case 4:return S.AnnularFinger;case 5:return S.LittleFinger;default:return void t.addSemanticDiagnostic({code:ie.AT211,message:`Value is out of valid range. Allowed range: 1-5, Actual Value: ${s}`,start:e.arguments[0].start,end:e.arguments[0].end,severity:se.Error})}}static ai(t,e){return t&&(e=t.arguments[0].value),e}ii(t,e,s,i){let n=e.arguments.arguments,r=n.length-s,a=e.arguments;r>0&&n[s].nodeType===ee.Arguments&&(n=n[s].arguments,s=0,r=n.length,a=n[s]);const h=i?2:1;if(r%h!==0){const s=Math.ceil(r/h),i=s*h;return void t.addSemanticDiagnostic({code:ie.AT214,message:`The '${e.property.text}' effect needs ${h} arguments per item. With ${s} points, ${i} arguments are needed, only ${r} arguments found.`,severity:se.Error,start:a.end,end:a.end})}const o=[];let c=s;for(;c<n.length;){let t=0,e=0;i?(t=n[c++].value,e=n[c++].value):(t=0,e=n[c++].value),o.push(new f(t,e))}if(o.length>0){if(o.length>60&&o.splice(60,o.length-60),i)o.sort((t,e)=>t.offset-e.offset);else{const t=o.length,e=f.MaxPosition/(t-1)|0;let s=0;for(;s<t;)o[s].offset=Math.min(f.MaxPosition,s*e),s++}return o}}static Ds(t,e,s,i,n=0){if(n>=e.arguments.length)return;const r=e.arguments[n].text;return i.has(r.toLowerCase())?i.get(r.toLowerCase()):void t.addSemanticDiagnostic({code:ie.AT209,message:`Unexpected ${s} value '${r}', expected: ${Array.from(i.keys()).join(",")}`,severity:se.Error,start:e.arguments[n].start,end:e.arguments[n].end})}static oi=new wt;static ci=new Ee;buildScoreMetaDataNodes(e){const s=[];return t.li(s,"album",e,e.album,bt.Album),t.li(s,"artist",e,e.artist,bt.Artist),t.li(s,"copyright",e,e.copyright,bt.Copyright),t.li(s,"copyright2",e,void 0,bt.CopyrightSecondLine),t.li(s,"wordsandmusic",e,void 0,bt.WordsAndMusic,!0),t.li(s,"instructions",e,e.instructions,void 0),t.li(s,"music",e,e.music,bt.Music),t.li(s,"notices",e,e.notices,void 0),t.li(s,"subtitle",e,e.subTitle,bt.SubTitle),t.li(s,"title",e,e.title,bt.Title),t.li(s,"words",e,e.words,bt.Words),t.li(s,"tab",e,e.tab,bt.Transcriber),e.defaultSystemsLayout!==t.oi.defaultSystemsLayout&&s.push(pe.numberMeta("defaultSystemsLayout",e.defaultSystemsLayout)),e.systemsLayout.length>0&&s.push(pe.meta("systemsLayout",pe.args(e.systemsLayout.map(t=>pe.number(t))))),t.ui(s,e.stylesheet),s.length>0&&(s[0].leadingComments=[{text:"Score Metadata",multiLine:!1}]),s}static ui(e,s){const i=e.length;s.hideDynamics&&e.push(pe.meta("hideDynamics")),s.bracketExtendMode!==t.oi.stylesheet.bracketExtendMode&&e.push(pe.identMeta("bracketExtendMode",Zt.bracketExtendModeReversed.get(s.bracketExtendMode))),s.useSystemSignSeparator&&e.push(pe.meta("useSystemSignSeparator")),s.multiTrackMultiBarRest&&e.push(pe.meta("multiBarRest")),s.singleTrackTrackNamePolicy!==t.oi.stylesheet.singleTrackTrackNamePolicy&&e.push(pe.identMeta("singleTrackTrackNamePolicy",Zt.trackNamePolicyReversed.get(s.singleTrackTrackNamePolicy))),s.multiTrackTrackNamePolicy!==t.oi.stylesheet.multiTrackTrackNamePolicy&&e.push(pe.identMeta("multiTrackTrackNamePolicy",Zt.trackNamePolicyReversed.get(s.multiTrackTrackNamePolicy))),s.firstSystemTrackNameMode!==t.oi.stylesheet.firstSystemTrackNameMode&&e.push(pe.identMeta("firstSystemTrackNameMode",Zt.trackNameModeReversed.get(s.firstSystemTrackNameMode))),s.otherSystemsTrackNameMode!==t.oi.stylesheet.otherSystemsTrackNameMode&&e.push(pe.identMeta("otherSystemsTrackNameMode",Zt.trackNameModeReversed.get(s.otherSystemsTrackNameMode))),s.firstSystemTrackNameOrientation!==t.oi.stylesheet.firstSystemTrackNameOrientation&&e.push(pe.identMeta("firstSystemTrackNameOrientation",Zt.trackNameOrientationReversed.get(s.firstSystemTrackNameOrientation))),s.otherSystemsTrackNameOrientation!==t.oi.stylesheet.otherSystemsTrackNameOrientation&&e.push(pe.identMeta("otherSystemsTrackNameOrientation",Zt.trackNameOrientationReversed.get(s.otherSystemsTrackNameOrientation))),s.extendBarLines&&e.push(pe.meta("extendBarLines")),s.globalDisplayChordDiagramsInScore&&e.push(pe.meta("chordDiagramsInScore")),s.hideEmptyStaves&&e.push(pe.meta("hideEmptyStaves")),s.hideEmptyStavesInFirstSystem&&e.push(pe.meta("hideEmptyStavesInFirstSystem")),s.showSingleStaffBrackets&&e.push(pe.meta("showSingleStaffBrackets")),s.barNumberDisplay!==nt.AllBars&&e.push(pe.identMeta("defaultBarNumberDisplay",nt[s.barNumberDisplay])),i<e.length&&(e[i].leadingComments=[{multiLine:!1,text:"Score Stylesheet"}])}static li(t,e,s,i,n,r=!1){if(void 0!==i&&0===i.length&&!r)return;const a=[];if(void 0!==i&&a.push(pe.string(i)),void 0!==n){const t=s.style&&s.style.headerAndFooter.has(n)?s.style.headerAndFooter.get(n):void 0,e=gt.defaultHeaderAndFooter.has(n)?gt.defaultHeaderAndFooter.get(n):void 0;!t||e&&mt.equals(e,t)||(a.push(pe.string(!1===t.isVisible?"":t.template)),a.push(pe.ident(Zt.textAlignReversed.get(t.textAlign))))}void 0===i&&0===a.length||void 0!==i&&0===i.length&&1===a.length||t.push(pe.meta(e,pe.args(a)))}buildSyncPointNodes(t){const e=[],s=t.exportFlatSyncPoints();for(const t of s)e.push(pe.meta("sync",pe.args([pe.number(t.barIndex),pe.number(t.barOccurence),pe.number(t.millisecondOffset),t.barPosition>0?pe.number(t.barPosition):void 0])));return e}buildBarMetaDataNodes(e,s,i,n){const r=[];if(t.di(s,e,r,n,i),!s)return r;0===i&&0===e.index&&0===e.track.index&&t.fi(r,s.masterBar);const a=r.length;0===i&&0===s.index&&0===e.index&&0===e.track.index&&r.push(pe.identMeta("accidentals","auto")),0!==s.index&&s.clef===s.previousBar?.clef||r.push(pe.identMeta("clef",Zt.clefReversed.get(s.clef))),(0===s.index&&s.clefOttava!==x.Regular||s.clefOttava!==s.previousBar?.clefOttava)&&r.push(pe.identMeta("ottava",Zt.ottaviaReversed.get(s.clefOttava))),(0===s.index&&s.simileMark!==H.None||s.simileMark!==s.previousBar?.simileMark)&&r.push(pe.identMeta("simile",Zt.simileMarkReversed.get(s.simileMark))),1!==s.displayScale&&r.push(pe.numberMeta("scale",s.displayScale)),s.displayWidth>0&&r.push(pe.numberMeta("width",s.displayWidth));for(const t of s.sustainPedals){let e="";switch(t.pedalType){case U.Down:e="spd";break;case U.Hold:e="sph";break;case U.Up:e="spu"}e&&r.push(pe.numberMeta(e,t.ratioPosition))}if(s.barLineLeft!==q.Automatic&&r.push(pe.identMeta("barLineLeft",Zt.barLineStyleReversed.get(s.barLineLeft))),s.barLineRight!==q.Automatic&&r.push(pe.identMeta("barLineRight",Zt.barLineStyleReversed.get(s.barLineRight))),0===s.index||s.keySignature!==s.previousBar.keySignature||s.keySignatureType!==s.previousBar.keySignatureType){let t="";t=s.keySignatureType===z.Minor?Zt.keySignaturesMinorReversed.get(s.keySignature):Zt.keySignaturesMajorReversed.get(s.keySignature),r.push(pe.identMeta("ks",t))}return a<r.length&&(r[a].leadingComments=[{multiLine:!1,text:`Bar ${s.index+1} Metadata`}]),void 0!==s.barNumberDisplay&&r.push(pe.identMeta("barNumberDisplay",nt[s.barNumberDisplay])),r}static pi(e,s){const i=e.length;if(0!==s.capo&&e.push(pe.numberMeta("capo",s.capo)),s.isPercussion)e.push(pe.identMeta("articulation","defaults"));else if(s.isStringed){const t=pe.meta("tuning",pe.args(s.stringTuning.tunings.map(t=>pe.ident(Me.getTextForTuning(t,!0)))));e.push(t),s.track.score.stylesheet.perTrackDisplayTuning&&s.track.score.stylesheet.perTrackDisplayTuning.has(s.track.index)&&(t.properties=pe.props([["hide",void 0]])),s.stringTuning.name.length>0&&(t.properties??=pe.props([]),pe.prop(t.properties.properties,"label",pe.stringValue(s.stringTuning.name)))}0!==s.transpositionPitch&&e.push(pe.numberMeta("transpose",-s.transpositionPitch));const n=Bt.displayTranspositionPitches.has(s.track.playbackInfo.program)?Bt.displayTranspositionPitches.get(s.track.playbackInfo.program):0;if(s.displayTranspositionPitch!==n&&e.push(pe.numberMeta("displaytranspose",-s.displayTranspositionPitch)),null!=s.chords)for(const[i,n]of s.chords)e.push(t.bi(n));i<e.length&&(e[i].leadingComments=[{multiLine:!1,text:`Staff ${s.index+1} Metadata`}])}static bi(t){const e=pe.meta("chord",pe.args([pe.string(t.name)],!0),pe.props([t.firstFret>=0?["firstfret",pe.numberValue(t.firstFret)]:void 0,["showdiagram",pe.identValue(t.showDiagram?"true":"false")],["showfingering",pe.identValue(t.showFingering?"true":"false")],["showname",pe.identValue(t.showName?"true":"false")],t.barreFrets.length>0?["barre",pe.args(t.barreFrets.map(t=>pe.number(t)))]:void 0]));for(let s=0;s<t.staff.tuning.length;s++)s<t.strings.length&&t.strings[s]>=0?e.arguments.arguments.push(pe.number(t.strings[s])):e.arguments.arguments.push(pe.ident("x"));return e}static fi(t,e){const s=t.length;if(0!==e.alternateEndings&&t.push(pe.meta("ae",pe.args(Bt.getAlternateEndingsList(e.alternateEndings).map(t=>pe.number(t+1))))),e.isRepeatStart&&t.push(pe.meta("ro")),e.isRepeatEnd&&t.push(pe.numberMeta("rc",e.repeatCount)),0!==e.index&&e.timeSignatureCommon===e.previousMasterBar?.timeSignatureCommon&&e.timeSignatureNumerator===e.previousMasterBar.timeSignatureNumerator&&e.timeSignatureDenominator===e.previousMasterBar.timeSignatureDenominator||(e.timeSignatureCommon?t.push(pe.identMeta("ts","common")):t.push(pe.meta("ts",pe.args([pe.number(e.timeSignatureNumerator),pe.number(e.timeSignatureDenominator)])))),e.beamingRules)for(const[s,i]of e.beamingRules.groups){const e=pe.args([pe.number(s)],!0);for(const t of i)e.arguments.push(pe.number(t));t.push(pe.meta("beaming",e))}if((e.index>0&&e.tripletFeel!==e.previousMasterBar?.tripletFeel||0===e.index&&e.tripletFeel!==K.NoTripletFeel)&&t.push(pe.identMeta("tf",Zt.tripletFeelReversed.get(e.tripletFeel))),e.isFreeTime&&t.push(pe.meta("ft")),null!=e.section&&t.push(pe.meta("section",pe.args([pe.string(e.section.marker),pe.string(e.section.text)]))),e.isAnacrusis&&t.push(pe.meta("ac")),1!==e.displayScale&&t.push(pe.numberMeta("scale",e.displayScale)),e.displayWidth>0&&t.push(pe.numberMeta("width",e.displayWidth)),e.directions)for(const s of e.directions)t.push(pe.identMeta("jump",Zt.directionReversed.get(s)));for(const s of e.tempoAutomations){const e=pe.meta("tempo",pe.args([pe.number(s.value),s.text?pe.string(s.text):void 0,s.ratioPosition>0?pe.number(s.ratioPosition):void 0,s.isVisible?void 0:pe.ident("hide")]));1===e.arguments.arguments.length&&(e.arguments.openParenthesis=void 0,e.arguments.closeParenthesis=void 0),t.push(e)}s<t.length&&(t[s].leadingComments=[{multiLine:!1,text:`Masterbar ${e.index+1} Metadata`}])}static di(e,s,i,n,r){if((void 0===e||0===e.index)&&(0===r&&(0===s.index&&i.push(t.mi(s.track)),i.push(t.gi(s)),t.pi(i,s)),n)){const t=pe.meta("voice");t.trailingComments=[{multiLine:!0,text:`Voice ${r+1}`}],i.push(t)}}static gi(t){const e=pe.meta("staff",void 0,pe.props([t.showStandardNotation?["score",pe.args([t.standardNotationLineCount!==ve.DefaultStandardNotationLineCount?pe.number(t.standardNotationLineCount):void 0])]:void 0,t.showTablature?["tabs",void 0]:void 0,t.showSlash?["slash",void 0]:void 0,t.showNumbered?["numbered",void 0]:void 0]));return e.properties&&e.properties.properties.length>0&&(e.properties.properties[0].leadingComments=[{multiLine:!1,text:"Staff Properties"}]),e}static mi(e){const s=pe.meta("track",pe.args([pe.string(e.name),e.shortName.length>0?pe.string(e.shortName):void 0]),pe.props([e.color.rgba!==t.ci.color.rgba?["color",pe.stringValue(e.color.rgba)]:void 0,e.defaultSystemsLayout!==t.ci.defaultSystemsLayout?["defaultSystemsLayout",pe.numberValue(e.defaultSystemsLayout)]:void 0,e.systemsLayout.length?["systemsLayout",pe.args(e.systemsLayout.map(t=>pe.number(t)))]:void 0,["volume",pe.numberValue(e.playbackInfo.volume)],["balance",pe.numberValue(e.playbackInfo.balance)],e.playbackInfo.isMute?["mute",void 0]:void 0,e.playbackInfo.isSolo?["solo",void 0]:void 0,e.score.stylesheet.perTrackMultiBarRest&&e.score.stylesheet.perTrackMultiBarRest.has(e.index)?["multiBarRest",void 0]:void 0,["instrument",pe.identValue(e.isPercussion?"percussion":we.getName(e.playbackInfo.program))],e.playbackInfo.bank>0?["bank",pe.numberValue(e.playbackInfo.bank)]:void 0]));return s.properties&&s.properties.properties.length>0&&(s.properties.properties[0].leadingComments=[{multiLine:!1,text:"Track Properties"}]),s}buildNoteEffects(t){const e=[];if(t.hasBend){const s=pe.args([pe.ident(Zt.bendTypeReversed.get(t.bendType)),t.bendStyle!==p.Default?pe.ident(Zt.bendStyleReversed.get(t.bendStyle)):void 0],!0);for(const e of t.bendPoints)s.arguments.push(pe.number(e.offset)),s.arguments.push(pe.number(e.value));pe.prop(e,"be",s)}let s="";switch(t.harmonicType){case B.Natural:pe.prop(e,"nh");break;case B.Artificial:s="ah";break;case B.Pinch:s="ph";break;case B.Tap:s="th";break;case B.Semi:s="sh";break;case B.Feedback:s="fh"}switch(s&&pe.prop(e,s,pe.numberValue(t.harmonicValue)),t.showStringNumber&&pe.prop(e,"string"),t.isTrill&&pe.prop(e,"tr",pe.args([pe.number(t.trillFret),pe.number(t.trillSpeed)])),t.vibrato){case P.Slight:pe.prop(e,"v");break;case P.Wide:pe.prop(e,"vw")}switch(t.slideInType){case T.IntoFromBelow:pe.prop(e,"sib");break;case T.IntoFromAbove:pe.prop(e,"sia")}switch(t.slideOutType){case M.Shift:pe.prop(e,"ss");break;case M.Legato:pe.prop(e,"sl");break;case M.OutUp:pe.prop(e,"sou");break;case M.OutDown:pe.prop(e,"sod");break;case M.PickSlideDown:pe.prop(e,"psd");break;case M.PickSlideUp:pe.prop(e,"psu")}switch(t.isHammerPullOrigin&&pe.prop(e,"h"),t.isLeftHandTapped&&pe.prop(e,"lht"),t.isGhost&&pe.prop(e,"g"),t.accentuated){case k.Normal:pe.prop(e,"ac");break;case k.Heavy:pe.prop(e,"hac");break;case k.Tenuto:pe.prop(e,"ten")}if(t.isPalmMute&&pe.prop(e,"pm"),t.isStaccato&&pe.prop(e,"st"),t.isLetRing&&pe.prop(e,"lr"),t.isDead&&pe.prop(e,"x"),t.isTieDestination&&pe.prop(e,"t"),t.leftHandFinger>=S.Thumb&&pe.prop(e,"lf",pe.numberValue(t.leftHandFinger+1)),t.rightHandFinger>=S.Thumb&&pe.prop(e,"rf",pe.numberValue(t.rightHandFinger+1)),t.isVisible||pe.prop(e,"hide"),t.isSlurOrigin){const s=`s${t.id}`;pe.prop(e,"slur",pe.identValue(s))}if(t.isSlurDestination){const s=`s${t.slurOrigin.id}`;pe.prop(e,"slur",pe.identValue(s))}switch(t.accidentalMode===_.Default||t.beat.voice.bar.keySignature===V.C&&t.accidentalMode===_.ForceNatural||pe.prop(e,"acc",pe.identValue(Bt.reverseAccidentalModeMapping.get(t.accidentalMode))),t.ornament){case Pt.InvertedTurn:pe.prop(e,"iturn");break;case Pt.Turn:pe.prop(e,"turn");break;case Pt.UpperMordent:pe.prop(e,"umordent");break;case Pt.LowerMordent:pe.prop(e,"lmordent")}return e}buildBeatEffects(t){const e=[];switch(t.fade){case Rt.FadeIn:pe.prop(e,"f");break;case Rt.FadeOut:pe.prop(e,"fo");break;case Rt.VolumeSwell:pe.prop(e,"vs")}if(t.vibrato===P.Slight?pe.prop(e,"v"):t.vibrato===P.Wide&&pe.prop(e,"vw"),t.slap&&pe.prop(e,"s"),t.pop&&pe.prop(e,"p"),t.tap&&pe.prop(e,"tt"),t.dots>=2?pe.prop(e,"dd"):t.dots>0&&pe.prop(e,"d"),t.pickStroke===_t.Up?pe.prop(e,"su"):t.pickStroke===_t.Down&&pe.prop(e,"sd"),t.hasTuplet&&pe.prop(e,"tu",pe.args([pe.number(t.tupletNumerator),pe.number(t.tupletDenominator)])),t.hasWhammyBar){const s=pe.args([pe.ident(Zt.whammyTypeReversed.get(t.whammyBarType)),pe.ident(Zt.bendStyleReversed.get(t.whammyStyle))],!0);for(const e of t.whammyBarPoints)s.arguments.push(pe.number(e.offset)),s.arguments.push(pe.number(e.value));pe.prop(e,"tbe",s)}let s="";switch(t.brushType){case m.BrushUp:s="bu";break;case m.BrushDown:s="bd";break;case m.ArpeggioUp:s="au";break;case m.ArpeggioDown:s="ad"}if(s&&pe.prop(e,s,pe.numberValue(t.brushDuration)),null!=t.chord&&pe.prop(e,"ch",pe.stringValue(t.chord.name)),t.ottava!==x.Regular&&pe.prop(e,"ot",pe.identValue(Zt.ottaviaReversed.get(t.ottava))),t.hasRasgueado&&pe.prop(e,"rasg",pe.identValue(Zt.rasgueadoReversed.get(t.rasgueado))),null!=t.text&&pe.prop(e,"txt",pe.stringValue(t.text)),null!=t.lyrics&&t.lyrics.length>0)if(t.lyrics.length>1)for(let s=0;s<t.lyrics.length;s++)pe.prop(e,"lyrics",pe.args([pe.number(s),pe.string(t.lyrics[s])]));else pe.prop(e,"lyrics",pe.stringValue(t.lyrics[0]));if(t.graceType!==y.None&&pe.prop(e,"gr",t.graceType===y.BeforeBeat?void 0:pe.identValue(Zt.graceTypeReversed.get(t.graceType))),t.isTremolo){const s=[pe.number(t.tremoloPicking.marks)];t.tremoloPicking.style!==Ht.Default&&s.push(pe.ident(Ht[t.tremoloPicking.style])),pe.prop(e,"tp",pe.args(s))}switch(t.crescendo){case g.Crescendo:pe.prop(e,"cre");break;case g.Decrescendo:pe.prop(e,"dec")}(0===t.voice.bar.index&&0===t.index||t.dynamics!==t.previousBeat?.dynamics)&&pe.prop(e,"dy",pe.identValue(Zt.dynamicValueReversed.get(t.dynamics))),null!=t.fermata&&pe.prop(e,"fermata",pe.args([pe.ident(Zt.fermataTypeReversed.get(t.fermata.type)),pe.number(t.fermata.length)])),t.isLegatoOrigin&&pe.prop(e,"legatoorigin");for(const s of t.automations)switch(s.type){case l.Tempo:pe.prop(e,"tempo",pe.args([pe.number(s.value),0===s.text.length?void 0:pe.string(s.text)]));break;case l.Volume:pe.prop(e,"volume",pe.numberValue(s.value));break;case l.Instrument:t.voice.bar.staff.isPercussion||pe.prop(e,"instrument",pe.identValue(we.getName(s.value)));break;case l.Balance:pe.prop(e,"balance",pe.numberValue(s.value))}switch(t.wahPedal){case Ot.Open:pe.prop(e,"waho");break;case Ot.Closed:pe.prop(e,"wahc")}switch(t.isBarre&&pe.prop(e,"barre",pe.args([pe.number(t.barreFret),pe.ident(Zt.barreShapeReversed.get(t.barreShape))])),t.slashed&&pe.prop(e,"slashed"),t.deadSlapped&&pe.prop(e,"ds"),t.golpe){case Wt.Thumb:pe.prop(e,"glpt");break;case Wt.Finger:pe.prop(e,"glpf")}t.invertBeamDirection?pe.prop(e,"beam",pe.identValue("invert")):null!==t.preferredBeamDirection&&pe.prop(e,"beam",pe.identValue(Fe[t.preferredBeamDirection]));let i="";switch(t.beamingMode){case Vt.ForceSplitToNext:i="split";break;case Vt.ForceMergeWithNext:i="merge";break;case Vt.ForceSplitOnSecondaryToNext:i="splitsecondary"}return i&&pe.prop(e,"beam",pe.identValue(i)),t.showTimer&&pe.prop(e,"timer"),e}},De=class extends a{constructor(){super(r.Format,"Unexpected end of data within reader")}},Le=class extends a{constructor(t){super(r.Format,t)}},We=class{wi;constructor(t){this.wi=t}get position(){return this.wi.position}set position(t){this.wi.position=t}get length(){return this.wi.length}reset(){this.wi.reset()}skip(t){this.wi.skip(t)}yi(t){if(this.length-this.position<t)throw new De}readByte(){return this.yi(1),this.wi.readByte()}read(t,e,s){return this.yi(s),this.wi.read(t,e,s)}readAll(){return this.wi.readAll()}},Re=class{data;settings;init(t,e){this.data=t instanceof We?t:new We(t),this.settings=e,wt.resetIds()}},Oe=class extends a{constructor(t=null,e){super(r.Format,t??"Unsupported format",e)}},Ie=class t{ki;length=0;position=0;get bytesWritten(){return this.position}getBuffer(){return this.ki}static empty(){return t.withCapacity(0)}static withCapacity(e){const s=new t;return s.ki=new Uint8Array(e),s}static fromBuffer(e){const s=new t;return s.ki=e,s.length=e.length,s}static fromString(e){const s=le.stringToBytes(e);return t.fromBuffer(s)}reset(){this.position=0}skip(t){this.position+=t}readByte(){return this.length-this.position<=0?-1:this.ki[this.position++]}read(t,e,s){let i=this.length-this.position;return i>s&&(i=s),i<=0?0:(t.set(this.ki.subarray(this.position,this.position+i),e),this.position+=i,i)}writeByte(t){const e=this.position+1;this.Si(e),this.ki[this.position]=255&t,e>this.length&&(this.length=e),this.position=e}write(t,e,s){const i=this.position+s;this.Si(i);const n=Math.min(s,t.length-e);this.ki.set(t.subarray(e,e+n),this.position),i>this.length&&(this.length=i),this.position=i}Si(t){if(t>this.ki.length){let e=t;e<256&&(e=256),e<2*this.ki.length&&(e=2*this.ki.length);const s=new Uint8Array(e);this.length>0&&s.set(this.ki.subarray(0,0+this.length),0),this.ki=s}}readAll(){return this.toArray()}toArray(){const t=new Uint8Array(this.length);return t.set(this.ki.subarray(0,0+this.length),0),t}copyTo(t){t.write(this.ki,0,this.length)}},Ge=class t extends a{lexerDiagnostics;parserDiagnostics;semanticDiagnostics;*iterateDiagnostics(){if(this.lexerDiagnostics)for(const t of this.lexerDiagnostics.items)yield t;if(this.parserDiagnostics)for(const t of this.parserDiagnostics.items)yield t;if(this.semanticDiagnostics)for(const t of this.semanticDiagnostics.items)yield t}constructor(t,e,s,i){super(r.AlphaTex,t),this.lexerDiagnostics=e,this.parserDiagnostics=s,this.semanticDiagnostics=i}toString(){return[this.message,"lexer diagnostics:",t.Bi(this.lexerDiagnostics,"  "),"parser diagnostics:",t.Bi(this.parserDiagnostics,"  "),"semantic diagnostics:",t.Bi(this.semanticDiagnostics,"  ")].join("\n")}static Bi(e,s){return e?e.items.map(e=>`${s}${se[e.severity]} AT${e.code.toString().padStart(3,"0")}${t._i(e)}: ${e.message}`).join("\n"):`${s}none`}static _i(t){let e="";return t.start&&(e+=`(${t.start.line},${t.start.col})`),t.end&&(e.length>0&&(e+="->"),e+=`(${t.end.line},${t.end.col})`),e}},He=class{trackChannel=0;score;currentTrack;currentStaff;barIndex=0;voiceIndex=0;ignoredInitialVoice=!1;ignoredInitialStaff=!1;ignoredInitialTrack=!1;currentDuration=w.Quarter;articulationUniqueIdToIndex=new Map;hasAnyProperData=!1;percussionArticulationNames=new Map;slurs=new Map;lyrics=new Map;sustainPedalToBeat=new Map;staffTuningApplied=new Set;staffNoteKind=new Map;staffHasExplicitTuning=new Set;staffHasExplicitDisplayTransposition=new Set;staffDisplayTranspositionApplied=new Set;staffInitialClef=new Map;syncPoints=[];currentDynamics=o.F;accidentalMode=re.Explicit;voiceMode=ae.StaffWise;currentTupletNumerator=-1;currentTupletDenominator=-1;scoreNode},$e=class extends Re{xi;Ti=Ae.instance;Ni=new He;get state(){return this.Ni}get scoreNode(){return this.Ni.scoreNode}get name(){return"AlphaTex"}get lexerDiagnostics(){return this.xi.lexerDiagnostics}get parserDiagnostics(){return this.xi.parserDiagnostics}get parser(){return this.xi}get parseMode(){return this.xi.mode}logErrors=!1;semanticDiagnostics=new ne;addSemanticDiagnostic(t){this.semanticDiagnostics.push(t)}initFromString(t,e){this.data=Ie.empty(),this.xi=new fe(t),this.settings=e,wt.resetIds()}readScore(){let t;this.Ni=new He,this.Pi(),this.data.length>0&&(this.xi=new fe(le.toString(this.data.readAll(),this.settings.importer.encoding)));try{t=this.xi.read(),this.Ni.scoreNode=t}catch(t){throw this.logErrors&&O.error("AlphaTex",`Error while parsing alphaTex: ${t.toString()}`),new Oe("Error parsing alphaTex, check inner error for details",t)}if(this.xi.parserDiagnostics.hasErrors||this.xi.lexer.lexerDiagnostics.hasErrors){const t=new Ge("There are errors in the parsed alphaTex, check the diagnostics for details",this.lexerDiagnostics,this.parserDiagnostics,this.semanticDiagnostics);throw this.logErrors&&O.error("AlphaTex",`Error while parsing alphaTex: ${t.toString()}`),new Oe("Error parsing alphaTex, check diagnostics on inner error for details",t)}if(this.Re(t),this.semanticDiagnostics.hasErrors){if(this.Ni.hasAnyProperData){const t=new Ge("There are errors in the parsed alphaTex, check the diagnostics for details",this.lexerDiagnostics,this.parserDiagnostics,this.semanticDiagnostics);throw this.logErrors&&O.error("AlphaTex",`Error while parsing alphaTex: ${t.toString()}`),t}throw new Oe("No alphaTex data found")}Bt.consolidate(this.Ni.score),this.Ni.score.finish(this.settings),Bt.trimEmptyBarsAtEnd(this.Ni.score),this.Ni.score.rebuildRepeatGroups(),this.Ni.score.applyFlatSyncPoints(this.Ni.syncPoints);for(const[t,e]of this.Ni.lyrics)this.Ni.score.tracks[t].applyLyrics(e);for(const[t,e]of this.Ni.sustainPedalToBeat)if(t.ratioPosition<1){const s=e.voice.bar.masterBar.calculateDuration();t.ratioPosition=e.playbackStart/s}return this.Ni.score}Pi(){this.Ni.score=new wt,this.Ci()}Ci(){this.Ni.currentTrack=new Ee,this.Ni.currentTrack.ensureStaveCount(1),this.Ni.currentTrack.playbackInfo.program=25,this.Ni.currentTrack.playbackInfo.primaryChannel=this.Ni.trackChannel++,this.Ni.currentTrack.playbackInfo.secondaryChannel=this.Ni.trackChannel++;const t=this.Ni.currentTrack.staves[0];t.displayTranspositionPitch=0,t.stringTuning=Me.getDefaultTuningFor(6),this.Ni.articulationUniqueIdToIndex.clear(),this.Ei(t),this.Ni.score.addTrack(this.Ni.currentTrack),this.Ni.lyrics.set(this.Ni.currentTrack.index,[]),this.Ni.currentDynamics=o.F,this.Ni.currentTupletDenominator=-1,this.Ni.currentTupletNumerator=-1}Ei(t){this.Ni.currentStaff&&(this.Fi(this.Ni.currentStaff),this.Ai(this.Ni.currentStaff)),this.Ni.currentStaff=t,this.Ni.slurs.clear(),this.Ni.barIndex=0,this.Ni.voiceIndex=0}Re(t){if(t.bars.length>0){let e=!1;for(const s of t.bars)switch(this.Oe(s,e),this.state.voiceMode){case ae.StaffWise:this.Ni.barIndex++,e=!0;break;case ae.BarWise:s.pipe&&(this.Ni.barIndex++,this.Ni.voiceIndex=0,this.Ni.ignoredInitialVoice=!1,e=!0)}}else this.Di(this.Ni.currentStaff),this.Fi(this.Ni.currentStaff),this.Ai(this.Ni.currentStaff)}Oe(t,e){const s=this.Li(t,e);this.Fi(this.Ni.currentStaff),this.Ai(this.Ni.currentStaff),0===s.index&&this.Ni.staffInitialClef.has(this.Ni.currentStaff)&&(s.clef=this.Ni.staffInitialClef.get(this.Ni.currentStaff));const i=s.voices[this.Ni.voiceIndex];for(const e of t.beats)this.$e(i,e);if(0===i.beats.length){const t=new Xt;t.isEmpty=!0,i.addBeat(t)}}$e(t,e){if(e.durationChange&&this.Ue(e.durationChange),!e.notes&&!e.rest)return;const s=new Xt;if(t.addBeat(s),e.notes)for(const t of e.notes.notes)this.qe(s,t);else e.rest;e.durationValue&&(this.Ni.currentDuration=this.Wi(e.durationValue)),s.duration=this.Ni.currentDuration,s.dynamics=this.Ni.currentDynamics,-1===this.Ni.currentTupletNumerator||s.hasTuplet||(s.tupletNumerator=this.Ni.currentTupletNumerator,s.tupletDenominator=this.Ni.currentTupletDenominator);let i=1;void 0!==e.beatMultiplierValue&&(i=e.beatMultiplierValue.value),e.beatEffects&&this.Ri(s,e.beatEffects);for(let e=0;e<i-1;e++)t.addBeat(Qt.clone(s))}Ri(t,e){for(const s of e.properties)switch(this.Ti.applyBeatProperty(this,t,s)){case me.Applied:case me.NotAppliedSemanticError:this.Ni.hasAnyProperData=!0;break;case me.NotAppliedUnrecognizedMarker:const t=Array.from(this.Ti.knownBeatProperties).join(",");this.addSemanticDiagnostic({code:ie.AT212,message:`Unrecogized property '${s.property.text}', expected one of ${t}`,severity:se.Error,start:s.start,end:s.end})}}Ue(t){if(t.value&&(this.Ni.currentDuration=this.Wi(t.value)),this.Ni.currentTupletNumerator=-1,this.Ni.currentTupletDenominator=-1,t.properties)for(const e of t.properties.properties)switch(this.Ti.applyBeatDurationProperty(this,e)){case me.Applied:case me.NotAppliedSemanticError:this.Ni.hasAnyProperData=!0;break;case me.NotAppliedUnrecognizedMarker:const t=Array.from(this.Ti.knownBeatDurationProperties).join(",");this.addSemanticDiagnostic({code:ie.AT212,message:`Unrecogized property '${e.property.text}', expected one of ${t}`,severity:se.Error,start:e.start,end:e.end})}}Wi(t){switch(t.value){case-4:return w.QuadrupleWhole;case-2:return w.DoubleWhole;case 1:return w.Whole;case 2:return w.Half;case 4:return w.Quarter;case 8:return w.Eighth;case 16:return w.Sixteenth;case 32:return w.ThirtySecond;case 64:return w.SixtyFourth;case 128:return w.OneHundredTwentyEighth;case 256:return w.TwoHundredFiftySixth;default:return this.addSemanticDiagnostic({code:ie.AT209,message:`Unexpected duration value '${t.value}', expected: -4, -2, 1, 2, 4, 8, 16, 32, 64, 128 or 256`,severity:se.Error,start:t.start,end:t.end}),this.Ni.currentDuration}}qe(t,e){let s=!1,i=!1,n=-1,r="",a=-1,h=-1,o=_.Default;const c=e.noteValue;let l,u=this.Ni.staffNoteKind.has(this.Ni.currentStaff)?this.Ni.staffNoteKind.get(this.Ni.currentStaff):void 0;switch(c.nodeType){case ee.Number:n=c.value,l=void 0!==e.noteString?he.Fretted:he.Articulation;break;case ee.String:case ee.Ident:const t=c.text;if(s="x"===t,i="-"===t,i||s)n=0,l=e.noteStringDot&&e.noteString?he.Fretted:void 0;else{const e=Bt.parseTuning(t);if(e)l=he.Pitched,a=e.octave,h=e.tone.noteValue,this.Ni.accidentalMode===re.Explicit&&(o=e.tone.accidentalMode);else{l=he.Articulation;const e=t.toLowerCase(),s=this.Ni.percussionArticulationNames;if(void 0===u&&0===s.size)for(const[t,e]of Nt.instrumentArticulationNames)Nt.getInstrumentArticulationByUniqueId(e)&&(s.set(t.toLowerCase(),e),s.set(Bt.toArticulationId(t),e));if(!s.has(e))return this.addSemanticDiagnostic({code:ie.AT209,message:`Unexpected percussion articulation value '${e}', expected: oneOf(${Array.from(this.Ni.percussionArticulationNames.keys()).join(",")}).`,severity:se.Error,start:c.start,end:c.end}),void(r=Array.from(Nt.instrumentArticulationNames.values())[0]);r=s.get(e)}}}void 0!==l?void 0===u?(u=l,this.applyStaffNoteKind(this.Ni.currentStaff,u)):u!==l&&this.addSemanticDiagnostic({code:ie.AT218,message:`Wrong note kind '${he[l]}' for staff with note kind ''${he[u]}'. Do not mix incompatible staves and notes.`,severity:se.Error,start:c.start,end:c.end}):void 0!==u&&(l=u);const d=new At;if(d.isDead=s,(s||i)&&(d.fret=n),d.isTieDestination=i,void 0!==l&&l===u)switch(l){case he.Pitched:d.octave=a,d.tone=h,d.accidentalMode=o;break;case he.Fretted:if(!e.noteString)return void this.addSemanticDiagnostic({code:ie.AT207,message:"Missing string for fretted note.",severity:se.Error,start:c.end,end:c.end});const t=e.noteString.value;if(t<1||t>this.Ni.currentStaff.tuning.length)return void this.addSemanticDiagnostic({code:ie.AT208,message:`Note string is out of range. Available range: 1-${this.Ni.currentStaff.tuning.length}`,severity:se.Error,start:c.end,end:c.end});d.string=this.Ni.currentStaff.tuning.length-(t-1),i||(d.fret=n);break;case he.Articulation:let s=0;if(0===r.length&&n>0){const t=Nt.getArticulationById(n);t&&(r=t.uniqueId)}if(this.Ni.articulationUniqueIdToIndex.has(r))s=this.Ni.articulationUniqueIdToIndex.get(r);else{s=this.Ni.currentTrack.percussionArticulations.length;const t=Nt.getInstrumentArticulationByUniqueId(r);if(null===t)return void this.addSemanticDiagnostic({code:ie.AT209,message:`Unexpected articulation value '${n}', expected: oneOf(${Array.from(Nt.instrumentArticulations.keys()).join(",")}).`,severity:se.Error,start:c.end,end:c.end});this.Ni.currentTrack.percussionArticulations.push(t),this.Ni.articulationUniqueIdToIndex.set(r,s)}d.percussionArticulation=s}t.addNote(d),this.Ni.hasAnyProperData=!0,e.noteEffects&&this.Oi(d,e.noteEffects)}getStaffNoteKind(t){return this.Ni.staffNoteKind.has(t)?this.Ni.staffNoteKind.get(t):void 0}applyStaffNoteKind(t,e){switch(this.Ni.staffNoteKind.set(t,e),e){case he.Pitched:t.isPercussion=!1,t.stringTuning.reset(),this.Ni.staffHasExplicitDisplayTransposition.has(t)||(t.displayTranspositionPitch=0);break;case he.Fretted:t.isPercussion=!1,this.Fi(t),this.Ai(t);break;case he.Articulation:t.isPercussion=!0,t.stringTuning.reset(),this.Ni.staffHasExplicitDisplayTransposition.has(t)||(t.displayTranspositionPitch=0)}}Oi(t,e){for(const s of e.properties){let e=this.Ti.applyNoteProperty(this,t,s);switch(e===me.NotAppliedUnrecognizedMarker&&(e=this.Ti.applyBeatProperty(this,t.beat,s)),e){case me.Applied:case me.NotAppliedSemanticError:break;case me.NotAppliedUnrecognizedMarker:const t=Array.from(this.Ti.knownNoteProperties).concat(Array.from(this.Ti.knownBeatProperties)).join(",");this.addSemanticDiagnostic({code:ie.AT212,message:`Unrecogized property '${s.property.text}', expected one of ${t}`,severity:se.Error,start:s.start,end:s.end})}}}Ai(t){if(!this.Ni.staffDisplayTranspositionApplied.has(t)&&!this.Ni.staffHasExplicitDisplayTransposition.has(t)){const e=t.track.playbackInfo.program;Bt.displayTranspositionPitches.has(e)?t.displayTranspositionPitch=Bt.displayTranspositionPitches.get(e):this.Ni.currentStaff.displayTranspositionPitch=0,this.Ni.staffDisplayTranspositionApplied.add(t)}}Fi(t){const e=t.track.playbackInfo.program;this.Ni.staffTuningApplied.has(t)||this.Ni.staffHasExplicitTuning.has(t)||(t.stringTuning.reset(),15===e||e>=24&&e<=31?t.stringTuning.tunings=Me.getDefaultTuningFor(6).tunings:e>=32&&e<=39?(t.stringTuning.tunings=[43,38,33,28],this.Ni.staffInitialClef.set(t,G.F4)):40===e||44===e||45===e||48===e||49===e||50===e||51===e?t.stringTuning.tunings=[52,57,50,43]:41===e?t.stringTuning.tunings=[57,50,43,36]:42===e?t.stringTuning.tunings=[45,38,31,24]:43===e?t.stringTuning.tunings=[43,38,33,28]:105===e?t.stringTuning.tunings=[50,47,43,38,55]:106===e?t.stringTuning.tunings=[57,52,45]:107===e?t.stringTuning.tunings=[52,45,38,31]:110===e?t.stringTuning.tunings=[64,57,50,43]:this.Ni.staffNoteKind.has(t)&&this.Ni.staffNoteKind.get(t)===he.Fretted&&(t.stringTuning=Me.getDefaultTuningFor(6)),this.Ni.staffTuningApplied.add(t))}Li(t,e){let s=this.Ni.score.masterBars.length>0?void 0:[],i=this.Ni.currentStaff,n=!1,h=!1,o=!1,c=!1;const l=()=>{s&&(s=void 0,i=this.Ni.currentStaff,n=!1,h=!1,o=!1,c=!1)},u=new L(()=>{o||e||this.Ni.barIndex++;const t=this.Di(this.Ni.currentStaff);if(s){for(const e of s)this.Ti.applyBarMetaData(this,t,e);l()}return t});for(const e of t.metaData){const t=e.tag.tag.text.toLowerCase();if(this.Ti.knownStructuralMetaDataTags.has(t)){switch(this.Ni.hasAnyProperData=!0,this.Ti.applyStructuralMetaData(this,e)){case ge.AppliedNewTrack:h||n?c=!0:(n=!0,i=this.Ni.currentStaff),u.reset();break;case ge.AppliedNewStaff:h?c=!0:(h=!0,i=this.Ni.currentStaff),u.reset();break;case ge.AppliedNewVoice:o=!0}if(s&&c){if(0!==i.bars.length)throw new a(r.AlphaTex,"Unexpected internal error, didn't expect a filled staff after multiple \\track and/or \\staff tags. Please report this problem providing the input alphaTex.");{const t=new Y;i.addBar(t);const e=new lt;if(t.addVoice(e),i.bars.length>this.Ni.score.masterBars.length){const t=new Z;this.Ni.score.addMasterBar(t)}for(const e of s)this.Ti.applyBarMetaData(this,t,e);l()}}}else if(this.Ti.knownScoreMetaDataTags.has(e.tag.tag.text.toLowerCase()))this.Ni.hasAnyProperData=!0,this.Ti.applyScoreMetaData(this,this.Ni.score,e);else if(this.Ti.knownStaffMetaDataTags.has(e.tag.tag.text.toLowerCase()))this.Ni.hasAnyProperData=!0,this.Ti.applyStaffMetaData(this,this.Ni.currentStaff,e);else if(this.Ti.knownBarMetaDataTags.has(e.tag.tag.text.toLowerCase()))this.Ni.hasAnyProperData=!0,s?s.push(e):this.Ti.applyBarMetaData(this,u.value,e);else{const t=Array.from(this.Ti.allKnownMetaDataTags).join(",");this.addSemanticDiagnostic({code:ie.AT204,message:`Unrecognized metadata '${e.tag.tag.text}', expected one of: ${t}`,severity:se.Error,start:e.tag.start,end:e.tag.end})}}return u.value}Di(t){if(this.Ni.barIndex<t.bars.length)return t.bars[this.Ni.barIndex];const e=0===t.bars.length?this.Ni.voiceIndex+1:t.bars[0].voices.length,s=new Y;t.addBar(s),s.previousBar&&(s.clef=s.previousBar.clef,s.clefOttava=s.previousBar.clefOttava,s.keySignature=s.previousBar.keySignature,s.keySignatureType=s.previousBar.keySignatureType),this.Ni.barIndex=s.index,s.index>0&&(s.clef=s.previousBar.clef);for(let t=0;t<e;t++){const t=new lt;s.addVoice(t)}if(this.Ni.currentStaff.bars.length>this.Ni.score.masterBars.length){const t=new Z;this.Ni.score.addMasterBar(t),t.index>0&&(t.timeSignatureDenominator=t.previousMasterBar.timeSignatureDenominator,t.timeSignatureNumerator=t.previousMasterBar.timeSignatureNumerator,t.tripletFeel=t.previousMasterBar.tripletFeel)}return s}startNewStaff(){if(this.Ni.ignoredInitialVoice=!1,this.Ni.ignoredInitialStaff||this.Ni.currentTrack.staves[0].bars.length>0){const t=this.Ni.currentStaff.isPercussion;this.Ni.currentTrack.ensureStaveCount(this.Ni.currentTrack.staves.length+1);const e=this.Ni.currentTrack.staves[this.Ni.currentTrack.staves.length-1];this.Ei(e),t&&this.applyPercussionStaff(this.Ni.currentStaff),this.Ni.currentDynamics=o.F}else this.Ni.ignoredInitialStaff=!0;return this.Ni.currentStaff}applyPercussionStaff(t){t.isPercussion=!0,t.showTablature=!1,t.track.playbackInfo.program=0}startNewTrack(){return this.Ni.ignoredInitialVoice=!1,this.Ni.ignoredInitialStaff=!1,this.Ni.ignoredInitialTrack||this.Ni.score.masterBars.length>0?this.Ci():this.Ni.ignoredInitialTrack=!0,this.Ni.currentTrack}startNewVoice(){let t=0===this.Ni.voiceIndex&&!this.Ni.ignoredInitialVoice;if(t)if(0===this.Ni.currentStaff.bars.length)t=!0;else switch(this.Ni.voiceMode){case ae.StaffWise:t=1===this.Ni.currentStaff.bars.length&&this.Ni.currentStaff.bars[0].isEmpty;break;case ae.BarWise:t=!(this.Ni.barIndex<this.Ni.currentStaff.bars.length)||this.Ni.currentStaff.bars[this.Ni.barIndex].voices[0].isEmpty}if(t)this.Ni.ignoredInitialVoice=!0;else{switch(this.Ni.voiceMode){case ae.StaffWise:this.Ni.voiceIndex++,this.Ni.barIndex=0,this.Ni.currentTupletDenominator=-1,this.Ni.currentTupletNumerator=-1;break;case ae.BarWise:this.Ni.voiceIndex++,this.Ni.currentTupletDenominator=-1,this.Ni.currentTupletNumerator=-1}for(const t of this.Ni.currentStaff.bars)for(;t.voices.length<=this.Ni.voiceIndex;)t.addVoice(new lt)}}},Ve=class{},ze=class extends Ve{n;constructor(t){super(),this.n=t}},Ue=class extends Ve{left;right;constructor(t,e){super(),this.left=t,this.right=e}},Xe=class extends Ve{n;table;constructor(t,e){super(),this.n=t,this.table=e}},je=class t{static make(e,s,i,n){const r=[],a=[];if(n>32)throw new ke("Invalid huffman");for(let t=0;t<n;t++)r.push(0),a.push(0);for(let t=0;t<i;t++){const i=e[t+s];if(i>=n)throw new ke("Invalid huffman");r[i]++}let h=0;for(let t=1;t<n-1;t++)h=h+r[t]<<1,a[t]=h;const o=new Map;for(let t=0;t<i;t++){const i=e[t+s];if(0!==i){const e=a[i-1];a[i-1]=e+1,o.set(e<<5|i,t)}}return t.Gi(new Ue(t.Hi(o,n,0,1),t.Hi(o,n,1,1)))}static Hi(e,s,i,n){if(n>s)throw new ke("Invalid huffman");const r=i<<5|n;return e.has(r)?new ze(e.get(r)):(i<<=1,n+=1,new Ue(t.Hi(e,s,i,n),t.Hi(e,s,1|i,n)))}static Gi(e){const s=t.$i(e);if(0===s)return e;if(1===s){if(e instanceof Ue)return new Ue(t.Gi(e.left),t.Gi(e.right));throw new ke("assert")}const i=1<<s,n=[];for(let t=0;t<i;t++)n.push(new ze(-1));return t.Vi(n,0,0,s,e),new Xe(s,n)}static Vi(e,s,i,n,r){r instanceof Ue&&n>0?(t.Vi(e,s,i+1,n-1,r.left),t.Vi(e,s|1<<i,i+1,n-1,r.right)):e[s]=t.Gi(r)}static $i(e){if(e instanceof ze)return 0;if(e instanceof Xe)throw new ke("assert");if(e instanceof Ue){const s=t.$i(e.left),i=t.$i(e.right);return 1+(s<i?s:i)}return 0}},Je=class t{static zi=32768;static Ui=65536;buffer=new Uint8Array(t.Ui);pos=0;slide(){const e=new Uint8Array(t.Ui);this.pos-=t.zi,e.set(this.buffer.subarray(t.zi,t.zi+this.pos),0),this.buffer=e}addBytes(e,s,i){this.pos+i>t.Ui&&this.slide(),this.buffer.set(e.subarray(s,s+i),this.pos),this.pos+=i}addByte(e){this.pos===t.Ui&&this.slide(),this.buffer[this.pos]=e,this.pos++}getLastChar(){return this.buffer[this.pos-1]}available(){return this.pos}},qe=class t{static Xi=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,-1,-1];static ji=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258];static Ji=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,-1,-1];static qi=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577];static Yi=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];static Ki=t.Qi();static Qi(){const t=[];for(let e=0;e<288;e++)t.push(e<=143?8:e<=255?9:e<=279?7:8);return je.make(t,0,288,10)}Zi=0;tn=0;Ni=1;en=!1;sn=t.Ki;nn=null;rn=0;an=0;hn=0;cn=null;ln=0;un;dn=[];pn=new Je;constructor(t){this.un=t;for(let t=0;t<19;t++)this.dn.push(-1)}readBytes(t,e,s){if(this.hn=s,this.ln=e,this.cn=t,s>0)for(;this.bn(););return s-this.hn}bn(){switch(this.Ni){case 0:const e=this.un.readByte();if(8!=(15&e))throw new ke("Invalid data");const s=this.un.readByte(),i=!!(32&s);if(((e<<8)+s)%31!=0)throw new ke("Invalid data");if(i)throw new ke("Unsupported dictionary");return this.Ni=1,!0;case 4:return this.Ni=7,!0;case 7:return!1;case 1:switch(this.en=this.mn(),this.gn(2)){case 0:if(this.rn=le.readUInt16LE(this.un),le.readUInt16LE(this.un)!==65535-this.rn)throw new ke("Invalid data");this.Ni=3;const e=this.bn();return this.wn(),e;case 1:return this.sn=t.Ki,this.nn=null,this.Ni=2,!0;case 2:const s=this.gn(5)+257,i=this.gn(5)+1,n=this.gn(4)+4;for(let e=0;e<n;e++)this.dn[t.Yi[e]]=this.gn(3);for(let e=n;e<19;e++)this.dn[t.Yi[e]]=0;this.sn=je.make(this.dn,0,19,8);const r=[];for(let t=0;t<s+i;t++)r.push(0);return this.yn(r,s+i),this.nn=je.make(r,s,i,16),this.sn=je.make(r,0,s,16),this.Ni=2,!0;default:throw new ke("Invalid data")}case 3:{const t=this.rn<this.hn?this.rn:this.hn,e=le.readByteArray(this.un,t);return this.rn-=t,this.kn(e,0,t),0===this.rn&&(this.Ni=this.en?4:1),this.hn>0}case 6:{const t=this.rn<this.hn?this.rn:this.hn;return this.Sn(t),this.rn-=t,0===this.rn&&(this.Ni=2),this.hn>0}case 5:for(;this.rn>0&&this.hn>0;){const t=this.rn<this.an?this.rn:this.an,e=this.hn<t?this.hn:t;this.Bn(this.an,e),this.rn-=e}return 0===this.rn&&(this.Ni=2),this.hn>0;case 2:let n=this._n(this.sn);if(n<256)return this.xn(n),this.hn>0;if(256===n)return this.Ni=this.en?4:1,!0;n=n-257&255;let r=t.Xi[n];if(-1===r)throw new ke("Invalid data");this.rn=t.ji[n]+this.gn(r);const a=this.nn,h=a?this._n(a):this.Tn(5);if(r=t.Ji[h],-1===r)throw new ke("Invalid data");if(this.an=t.qi[h]+this.gn(r),this.an>this.pn.available())throw new ke("Invalid data");return this.Ni=1===this.an?6:5,!0}return!1}Sn(t){const e=this.pn.getLastChar();for(let s=0;s<t;s++)this.xn(e)}xn(t){this.pn.addByte(t),this.cn[this.ln]=t,this.hn--,this.ln++}Bn(t,e){this.kn(this.pn.buffer,this.pn.pos-t,e)}mn(){0===this.Zi&&(this.Zi=8,this.tn=this.un.readByte());const t=!(1&~this.tn);return this.Zi--,this.tn=this.tn>>1,t}gn(t){for(;this.Zi<t;)this.tn=this.tn|this.un.readByte()<<this.Zi,this.Zi+=8;const e=this.tn&(1<<t)-1;return this.Zi-=t,this.tn=this.tn>>t,e}Tn(t){return 0===t?0:this.mn()?1<<t-1|this.Tn(t-1):this.Tn(t-1)}wn(){this.tn=0,this.Zi=0}kn(t,e,s){this.pn.addBytes(t,e,s),this.cn.set(t.subarray(e,e+s),this.ln),this.hn-=s,this.ln+=s}yn(t,e){let s=0,i=0;for(;s<e;){const n=this._n(this.sn);switch(n){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:case 10:case 11:case 12:case 13:case 14:case 15:i=n,t[s]=n,s++;break;case 16:const r=s+3+this.gn(2);if(r>e)throw new ke("Invalid data");for(;s<r;)t[s]=i,s++;break;case 17:if(s+=3+this.gn(3),s>e)throw new ke("Invalid data");break;case 18:if(s+=11+this.gn(7),s>e)throw new ke("Invalid data");break;default:throw new ke("Invalid data")}}}_n(t){if(t instanceof ze)return t.n;if(t instanceof Ue)return this._n(this.mn()?t.right:t.left);if(t instanceof Xe)return this._n(t.table[this.gn(t.n)]);throw new ke("Invalid data")}},Ye=class{static OptionalDataDescriptorSignature=134695760;static CompressionMethodDeflate=8;static LocalFileHeaderSignature=67324752;static CentralFileHeaderSignature=33639248;static EndOfCentralDirSignature=101010256;fullName;fileName;data;constructor(t,e){this.fullName=t;const s=t.lastIndexOf("/");this.fileName=-1===s||s===t.length-1?this.fullName:t.substr(s+1),this.data=e}},Ke=class{wi;Mn;constructor(t,e){this.wi=t,this.Mn=e}read(){const t=[];for(;;){const e=this.vn();if(!e)break;t.push(e)}return t}vn(){const t=this.wi;if(le.readInt32LE(t)!==Ye.LocalFileHeaderSignature)return null;le.readUInt16LE(t);const e=le.readUInt16LE(t),s=le.readUInt16LE(t),i=0!==s;if(i&&s!==Ye.CompressionMethodDeflate)return null;le.readInt16LE(this.wi),le.readInt16LE(this.wi),le.readInt32LE(t),le.readInt32LE(t);const n=le.readInt32LE(t);if(n>this.Mn)throw new Le("Zip contains files exceeding the configured maxDecodingBufferSize");const r=le.readInt16LE(t);if(r>this.Mn)throw new Le("Zip contains file names exceeding the configured maxDecodingBufferSize");const a=le.readInt16LE(t),h=le.toString(le.readByteArray(t,r),"utf-8");let o;if(t.skip(a),i){const t=Ie.empty(),e=new qe(this.wi),s=new Uint8Array(65536);for(;;){const i=e.readBytes(s,0,s.length);if(t.write(s,0,i),t.length>this.Mn)throw new Le(`Zip entry "${h}" contains data exceeding the configured maxDecodingBufferSize`);if(i<s.length)break}o=t.toArray()}else o=le.readByteArray(this.wi,n);return 8&e&&(le.readInt32LE(this.wi)===Ye.OptionalDataDescriptorSignature&&le.readInt32LE(this.wi),le.readInt32LE(this.wi),le.readInt32LE(this.wi)),new Ye(h,o)}},Qe=function(t){return t[t.None=0]="None",t[t.Element=1]="Element",t[t.Text=2]="Text",t[t.CDATA=3]="CDATA",t[t.Document=4]="Document",t[t.DocumentType=5]="DocumentType",t[t.Comment=6]="Comment",t}({}),Ze=class t{nodeType=0;localName=null;value=null;childNodes=[];attributes=new Map;firstChild=null;firstElement=null;*childElements(){for(const t of this.childNodes)1===t.nodeType&&(yield t)}addChild(t){this.childNodes.push(t),this.firstChild=t,1!==t.nodeType&&3!==t.nodeType||(this.firstElement=t)}getAttribute(t,e=""){return this.attributes.has(t)?this.attributes.get(t):e}getElementsByTagName(t,e=!1){const s=[];return this.Nn(this.childNodes,s,t,e),s}Nn(t,e,s,i=!1){for(const n of t)n&&1===n.nodeType&&n.localName===s&&e.push(n),i&&this.Nn(n.childNodes,e,s,!0)}findChildElement(t){for(const e of this.childNodes)if(e&&1===e.nodeType&&e.localName===t)return e;return null}addElement(e){const s=new t;return s.nodeType=1,s.localName=e,this.addChild(s),s}get innerText(){if(1===this.nodeType||4===this.nodeType){if(this.firstElement&&3===this.firstElement.nodeType)return this.firstElement.innerText;let t="";for(const e of this.childNodes)t+=e.innerText?.toString();return t.trim()}return this.value??""}set innerText(e){const s=new t;s.nodeType=2,s.value=e,this.childNodes=[s]}setCData(e){const s=new t;s.nodeType=3,s.value=e,this.childNodes=[s]}},ts=class extends a{xml;pos=0;constructor(t,e,s){super(r.Format,t),this.xml=e,this.pos=s}},es=class t{static CharCodeLF=10;static CharCodeTab=9;static CharCodeCR=13;static CharCodeSpace=32;static CharCodeLowerThan=60;static CharCodeAmp=38;static CharCodeBrackedClose=93;static CharCodeBrackedOpen=91;static CharCodeGreaterThan=62;static CharCodeExclamation=33;static CharCodeUpperD=68;static CharCodeLowerD=100;static CharCodeMinus=45;static CharCodeQuestion=63;static CharCodeSlash=47;static CharCodeEquals=61;static CharCodeDoubleQuote=34;static CharCodeSingleQuote=39;static CharCodeSharp=35;static CharCodeLowerX=120;static CharCodeLowerA=97;static CharCodeLowerZ=122;static CharCodeUpperA=65;static CharCodeUpperZ=90;static CharCode0=48;static CharCode9=57;static CharCodeColon=58;static CharCodeDot=46;static CharCodeUnderscore=95;static CharCodeSemi=59;static Pn=new Map([["lt","<"],["gt",">"],["amp","&"],["quot",'"'],["apos","'"]]);static parse(e,s,i){let n=e.charCodeAt(s),r=1,a=1,h=0,o="",c=1,l=null,u=null,d=0,f=0;for(;s<e.length;){switch(n=e.charCodeAt(s),r){case 0:switch(n){case t.CharCodeLF:case t.CharCodeCR:case t.CharCodeTab:case t.CharCodeSpace:break;default:r=a;continue}break;case 1:if(n!==t.CharCodeLowerThan){h=s,r=13;continue}r=0,a=2;break;case 13:if(n===t.CharCodeLowerThan){o+=e.substr(h,s-h);const t=new Ze;t.nodeType=Qe.Text,t.value=o,o="",i.addChild(t),r=0,a=2}else n===t.CharCodeAmp&&(o+=e.substr(h,s-h),r=18,c=13,h=s+1);break;case 17:if(n===t.CharCodeBrackedClose&&e.charCodeAt(s+1)===t.CharCodeBrackedClose&&e.charCodeAt(s+2)===t.CharCodeGreaterThan){const t=new Ze;t.nodeType=Qe.CDATA,t.value=e.substr(h,s-h),i.addChild(t),s+=2,r=1}break;case 2:switch(n){case t.CharCodeExclamation:if(e.charCodeAt(s+1)===t.CharCodeBrackedOpen){if(s+=2,"CDATA["!==e.substr(s,6).toUpperCase())throw new ts("Expected <![CDATA[",e,s);r=17,h=(s+=5)+1}else if(e.charCodeAt(s+1)===t.CharCodeUpperD||e.charCodeAt(s+1)===t.CharCodeLowerD){if("OCTYPE"!==e.substr(s+2,6).toUpperCase())throw new ts("Expected <!DOCTYPE",e,s);r=16,h=(s+=8)+1}else{if(e.charCodeAt(s+1)!==t.CharCodeMinus||e.charCodeAt(s+2)!==t.CharCodeMinus)throw new ts("Expected \x3c!--",e,s);r=15,h=(s+=2)+1}break;case t.CharCodeQuestion:r=14,h=s;break;case t.CharCodeSlash:if(!i)throw new ts("Expected node name",e,s);h=s+1,r=0,a=10;break;default:r=3,h=s;continue}break;case 3:if(!t.Cn(n)){if(s===h)throw new ts("Expected node name",e,s);l=new Ze,l.nodeType=Qe.Element,l.localName=e.substr(h,s-h),i.addChild(l),r=0,a=4;continue}break;case 4:switch(n){case t.CharCodeSlash:r=11;break;case t.CharCodeGreaterThan:r=9;break;default:r=5,h=s;continue}break;case 5:if(!t.Cn(n)){if(h===s)throw new ts("Expected attribute name",e,s);if(u=e.substr(h,s-h),l.attributes.has(u))throw new ts(`Duplicate attribute [${u}]`,e,s);r=0,a=6;continue}break;case 6:if(n!==t.CharCodeEquals)throw new ts("Expected =",e,s);r=0,a=7;break;case 7:switch(n){case t.CharCodeDoubleQuote:case t.CharCodeSingleQuote:o="",r=8,h=s+1,f=n}break;case 8:if(n===t.CharCodeAmp)o+=e.substr(h,s-h),r=18,c=8,h=s+1;else if(n===f){o+=e.substr(h,s-h);const t=o;o="",l.attributes.set(u,t),r=0,a=4}break;case 9:h=s=t.parse(e,s,l),r=1;break;case 11:if(n!==t.CharCodeGreaterThan)throw new ts("Expected >",e,s);r=1;break;case 12:if(n===t.CharCodeGreaterThan)return s;throw new ts("Expected >",e,s);case 10:if(!t.Cn(n)){if(h===s)throw new ts("Expected node name",e,s);if(e.substr(h,s-h)!==i.localName)throw new ts(`Expected </${i.localName}>`,e,s);r=0,a=12;continue}break;case 15:n===t.CharCodeMinus&&e.charCodeAt(s+1)===t.CharCodeMinus&&e.charCodeAt(s+2)===t.CharCodeGreaterThan&&(s+=2,r=1);break;case 16:if(n===t.CharCodeBrackedOpen)d++;else if(n===t.CharCodeBrackedClose)d--;else if(n===t.CharCodeGreaterThan&&0===d){const t=new Ze;t.nodeType=Qe.DocumentType,t.value=e.substr(h,s-h),i.addChild(t),r=1}break;case 14:n===t.CharCodeQuestion&&e.charCodeAt(s+1)===t.CharCodeGreaterThan&&(s++,r=1);break;case 18:if(n===t.CharCodeSemi){const i=e.substr(h,s-h);if(i.charCodeAt(0)===t.CharCodeSharp){const e=i.charCodeAt(1)===t.CharCodeLowerX?Number.parseInt(`0${i.substr(1,i.length-1)}`,10):Number.parseInt(i.substr(1,i.length-1),10);o+=String.fromCharCode(e)}else t.Pn.has(i)?o+=t.Pn.get(i):o+=`&${i};`.toString();h=s+1,r=c}else t.Cn(n)||n===t.CharCodeSharp||(o+="&",o+=e.substr(h,s-h),h=--s+1,r=c)}s++}if(1===r&&(h=s,r=13),13===r){if(s!==h){o+=e.substr(h,s-h);const t=new Ze;t.nodeType=Qe.Text,t.value=o,i.addChild(t)}return s}if(18===r&&13===c){o+="&",o+=e.substr(h,s-h);const t=new Ze;return t.nodeType=Qe.Text,t.value=o,i.addChild(t),s}throw new ts("Unexpected end",e,s)}static Cn(e){return e>=t.CharCodeLowerA&&e<=t.CharCodeLowerZ||e>=t.CharCodeUpperA&&e<=t.CharCodeUpperZ||e>=t.CharCode0&&e<=t.CharCode9||e===t.CharCodeColon||e===t.CharCodeDot||e===t.CharCodeUnderscore||e===t.CharCodeMinus}},ss=class t{En=[];Fn;An;Dn;Ln;constructor(t,e){this.Fn=t,this.An=e,this.Ln="",this.Dn=!0}writeNode(t){switch(t.nodeType){case Qe.None:break;case Qe.Element:this.En.length>0&&this.Wn(),this.Rn(`<${t.localName}`);for(const[e,s]of t.attributes)this.Rn(` ${e}="`),this.On(s),this.Rn('"');if(0===t.childNodes.length)this.Rn("/>");else{if(this.Rn(">"),1!==t.childNodes.length||t.firstElement){this.In();for(const e of t.childNodes)e.nodeType!==Qe.Element&&e.nodeType!==Qe.Comment||this.writeNode(e);this.Gn(),this.Wn()}else this.writeNode(t.childNodes[0]);this.Rn(`</${t.localName}>`)}break;case Qe.Text:t.value&&this.Rn(t.value);break;case Qe.CDATA:null!==t.value&&this.Rn(`<![CDATA[${t.value}]]>`);break;case Qe.Document:this.An&&this.Rn('<?xml version="1.0" encoding="utf-8"?>');for(const e of t.childNodes)this.writeNode(e);break;case Qe.DocumentType:this.Rn(`<!DOCTYPE ${t.value}>`);break;case Qe.Comment:this.Rn(`\x3c!-- ${t.value} --\x3e`)}}Gn(){this.Ln=this.Ln.substr(0,this.Ln.length-this.Fn.length)}In(){this.Ln+=this.Fn}On(t){for(let e=0;e<t.length;e++){const s=t.charAt(e);switch(s){case"<":this.En.push("&lt;");break;case">":this.En.push("&gt;");break;case"&":this.En.push("&amp;");break;case"'":this.En.push("&apos;");break;case'"':this.En.push("&quot;");break;default:this.En.push(s)}}}static write(e,s,i){const n=new t(s,i);return n.writeNode(e),n.toString()}Rn(t){this.Dn&&this.En.push(this.Ln),this.En.push(t),this.Dn=!1}Wn(t=null){t&&this.Rn(t),this.Fn.length>0&&!this.Dn&&(this.En.push("\n"),this.Dn=!0)}toString(){return this.En.join("").trimRight()}},is=class extends Ze{constructor(){super(),this.nodeType=Qe.Document}parse(t){es.parse(t,0,this)}toString(){return this.toFormattedString()}toFormattedString(t="",e=!1){return ss.write(this,t,e)}},ns=class{noteRange=1;x=0;y=0},rs=class extends ns{align=ut.Left;frame=0;text="";fontFace="";weight=0;height=0},as=class extends ns{chord=new ye},hs=class extends ns{},os=class extends ns{},cs=class extends ns{number=0},ls=class extends ns{decrescendo=!1},us=class extends ns{allNumbers=!1;firstNumber=0;lastNumber=0},ds=class extends ns{octave=1},fs=class extends ns{},ps=class{defaultClef=G.G2;description="";percussion=!1;instrument=0;volume=0;transpose=0;index=0},bs=class{from=0;to=0;curly=!1},ms=class{currentBarIndex=-1;currentBarComplete=!0;currentBarDuration=0;currentPosition=0;voiceStemDir=null;repeatCount=0;repeatEnd=null},gs=class t{score;Hn=0;$n=Vt.Auto;Vn;zn;Un=!0;Xn=-1;parseXml(t,e){this.Vn=new Map,this.jn=[],this.Jn=new Map,this.zn=new Map,this.qn=new Map,this.Yn=new Map,this.Un=!0;const s=new is;try{s.parse(t)}catch(t){throw new Oe("Could not parse XML",t)}this.Kn(s),this.Qn(),this.score.finish(e)}Qn(){Bt.consolidate(this.score),t.Zn(this.qn,(t,e)=>{e.isLegatoOrigin=!0}),t.Zn(this.Yn,(t,e)=>{e.crescendo=t.decrescendo?g.Decrescendo:g.Crescendo})}static Zn(t,e){for(const[s,i]of t){const t=i.noteRange;let n=s;for(let s=0;s<t;s++)if(e(i,n),n.index+1<n.voice.beats.length)n=n.voice.beats[n.index+1];else{if(!(n.voice.bar.index+1<n.voice.bar.staff.bars.length))break;n=n.voice.bar.staff.bars[n.voice.bar.index+1].voices[n.voice.index].beats[0]}}}Kn(t){const e=t.firstElement;if(!e)throw new Oe("No valid XML");if("score"!==e.localName)throw new Oe('Root node of XML was not "score"');this.score=new wt;for(const t of e.childElements())switch(t.localName){case"info":this.tr(t);break;case"layout":this.er(t);break;case"gallery":this.sr(t);break;case"pageObjects":this.ir(t);break;case"systems":this.nr(t)}}rr=new Map;er(t){for(const e of t.childElements())switch(e.localName){case"staves":this.ar(e);break;case"brackets":this.hr(e)}const e=this.cr.filter(t=>!!t.curly);e.sort((t,e)=>t.from-e.from);let s=0,i=null;for(let t=0;t<this.lr.length;t++){const n=this.lr[t];for(;s<e.length&&t>e[s].to;)s++;i&&s<e.length&&t>e[s].from&&t<=e[s].to?i.ensureStaveCount(i.staves.length+1):(i=new Ee,i.ensureStaveCount(1),i.name=n.description,i.playbackInfo.volume=Math.floor(n.volume/128*16),i.playbackInfo.program=n.instrument,n.percussion?(i.playbackInfo.primaryChannel=9,i.playbackInfo.secondaryChannel=9):(i.playbackInfo.primaryChannel=this.Hn++,i.playbackInfo.secondaryChannel=this.Hn++),this.score.addTrack(i));const r=i.staves[i.staves.length-1];r.isPercussion=n.percussion,r.transpositionPitch=n.transpose,r.displayTranspositionPitch=0,r.showTablature=!1,this.rr.set(n.index,r)}}cr=[];hr(t){for(const e of t.childElements())if("bracket"===e.localName)this.ur(e)}ur(t){const e=new bs;e.from=Number.parseInt(t.getAttribute("from"),10),e.to=Number.parseInt(t.getAttribute("to"),10),t.attributes.has("curly")&&(e.curly="true"===t.attributes.get("curly")),this.cr.push(e)}ar(t){for(const e of t.childElements())if("staffLayout"===e.localName)this.dr(e)}pr=new Map;lr=[];dr(t){const e=new ps;e.description=t.getAttribute("description");for(const s of t.childElements())switch(s.localName){case"notation":s.attributes.has("defaultClef")&&(e.defaultClef=this.br(s.attributes.get("defaultClef")));break;case"sound":s.attributes.has("percussion")&&(e.percussion="true"===s.attributes.get("percussion")),s.attributes.has("instr")&&(e.instrument=Number.parseInt(s.attributes.get("instr"),10)),s.attributes.has("volume")&&(e.volume=Number.parseInt(s.attributes.get("volume"),10)),s.attributes.has("transpose")&&(e.transpose=Number.parseInt(s.attributes.get("transpose"),10))}this.pr.set(e.description,e),e.index=this.lr.length,this.lr.push(e)}br(t){switch(t){case"treble":return G.G2;case"bass":return G.F4;case"alto":case"tenor":return G.C4}return G.G2}mr(t){return t.endsWith("-")?x.M:t.endsWith("+")?x.T:x.Regular}nr(t){for(const e of t.childElements())if("system"===e.localName)this.gr(e)}gr(t){t.attributes.has("tempo")&&0===this.score.masterBars.length&&(this.Xn=Number.parseInt(t.attributes.get("tempo"),10)),"0"===t.getAttribute("beamGrouping")&&(this.$n=Vt.ForceSplitToNext);for(const e of t.childElements())if("staves"===e.localName)this.wr(t,e);this.Un=!1}wr(t,e){const s=this.score.masterBars.length;for(const i of e.childElements())if("staff"===i.localName)this.yr(t,s,i)}kr=new Z;Sr;yr(t,e,s){const i=s.getAttribute("layout");this.Sr=this.pr.get(i),this.kr.timeSignatureNumerator=4,this.kr.timeSignatureDenominator=4,this.kr.timeSignatureCommon=!1,this.Br(s.getAttribute("defaultTime"));const n=this.rr.get(this.Sr.index);for(;n.bars.length<e;)this._r(n);for(const r of s.childElements())if("voices"===r.localName)this.Tr(i,n,t,e,r)}Br(t){switch(t){case"allaBreve":case"C":this.kr.timeSignatureNumerator=2,this.kr.timeSignatureDenominator=2,this.kr.timeSignatureCommon=!0;break;case"longAllaBreve":this.kr.timeSignatureNumerator=4,this.kr.timeSignatureDenominator=4,this.kr.timeSignatureCommon=!0;break;default:if(t.indexOf("/")>0){const e=t.split("/");this.kr.timeSignatureNumerator=Number.parseInt(e[0],10),this.kr.timeSignatureDenominator=Number.parseInt(e[1],10),this.kr.timeSignatureCommon=!1}}}Tr(t,e,s,i,n){let r=0;for(const a of n.childElements())if("voice"===a.localName)this.Mr(t,e,s,r,i,a),r++}vr(t,e){return e<t.bars.length?t.bars[e]:this._r(t)}_r(t){const e=new Y;if(t.bars.length>0?(e.clef=t.bars[t.bars.length-1].clef,e.clefOttava=t.bars[t.bars.length-1].clefOttava,e.keySignature=t.bars[t.bars.length-1].keySignature,e.keySignatureType=t.bars[t.bars.length-1].keySignatureType):e.clef=this.Sr.defaultClef,t.addBar(e),t.bars.length>this.score.masterBars.length){const t=new Z;this.score.addMasterBar(t),t.index>0?t.tripletFeel=t.previousMasterBar.tripletFeel:this.Xn>0&&t.tempoAutomations.push(d.buildTempoAutomation(!1,0,this.Xn,0)),t.timeSignatureDenominator=this.kr.timeSignatureDenominator,t.timeSignatureNumerator=this.kr.timeSignatureNumerator,t.timeSignatureCommon=this.kr.timeSignatureCommon}return e}Nr=new Map;Pr;Cr;Er;Fr(t,e){this.Pr.currentBarIndex++,this.Cr=this.vr(t,this.Pr.currentBarIndex),this.Pr.currentBarDuration=this.Cr.masterBar.calculateDuration(!1),this.Pr.currentBarComplete=!1,this.Pr.currentPosition=0,this.Ar(t,e)}Mr(t,e,s,i,n,r){const a=`${t}_${i}`;if(this.Pr&&!this.Pr.currentBarComplete&&(this.Cr.masterBar.isAnacrusis=!0),this.Nr.has(a)?(this.Pr=this.Nr.get(a),this.Cr=this.vr(e,this.Pr.currentBarIndex),this.Ar(e,i)):(this.Pr=new ms,this.Pr.currentBarIndex=n-1,this.Nr.set(a,this.Pr),this.Fr(e,i)),r.attributes.has("stemDir"))switch(r.attributes.get("stemDir")){case"up":this.Pr.voiceStemDir=Fe.Up;break;case"down":this.Pr.voiceStemDir=Fe.Down;break;default:this.Pr.voiceStemDir=null}else this.Pr.voiceStemDir=null;const h=r.findChildElement("noteObjects");if(s.attributes.has("tempo")){const t=new d;t.isLinear=!0,t.type=l.Tempo,t.value=Number.parseInt(s.attributes.get("tempo"),10),t.ratioPosition=this.Pr.currentPosition/this.Pr.currentBarDuration,this.Cr.masterBar.tempoAutomations.push(t)}if(h)for(const t of h.childElements())switch(this.Pr.currentBarComplete&&"barline"!==t.localName&&this.Fr(e,i),t.localName){case"clefSign":this.Cr.clef=this.br(t.getAttribute("clef")),this.Cr.clefOttava=this.mr(t.getAttribute("clef"));break;case"keySign":this.Cr.keySignature=Number.parseInt(t.getAttribute("fifths"),10);break;case"timeSign":this.Br(t.getAttribute("time")),this.Cr.masterBar.timeSignatureDenominator=this.kr.timeSignatureDenominator,this.Cr.masterBar.timeSignatureNumerator=this.kr.timeSignatureNumerator,this.Cr.masterBar.timeSignatureCommon=this.kr.timeSignatureCommon,this.Pr.currentPosition=0,this.Pr.currentBarDuration=this.Cr.masterBar.calculateDuration(!1);break;case"barline":switch(t.getAttribute("type")){case"double":this.Cr.barLineRight=q.LightLight,this.Pr.currentBarComplete||(this.Cr.masterBar.isAnacrusis=!0),this.Pr.currentBarComplete=!0;break;case"end":this.Pr.currentBarComplete||(this.Cr.masterBar.isAnacrusis=!0);break;case"repEnd":this.Pr.repeatEnd=this.Cr.masterBar,this.Cr.masterBar.repeatCount<this.Pr.repeatCount&&(this.Cr.masterBar.repeatCount=this.Pr.repeatCount),this.Dr(t),this.Pr.currentBarComplete||(this.Cr.masterBar.isAnacrusis=!0),this.Pr.currentBarComplete=!0;break;case"repBegin":this.Fr(e,i),this.Cr.masterBar.isRepeatStart=!0,this.Pr.repeatEnd=null,this.Pr.repeatCount=0;break;case"repEndBegin":this.Pr.repeatEnd=this.Cr.masterBar,this.Cr.masterBar.repeatCount<this.Pr.repeatCount&&(this.Cr.masterBar.repeatCount=this.Pr.repeatCount),this.Dr(t),this.Fr(e,i),this.Cr.masterBar.isRepeatStart=!0;break;default:this.Pr.currentBarComplete||(this.Cr.masterBar.isAnacrusis=!0),this.Pr.currentBarComplete=!0}break;case"chord":const s=new Xt;this.Lr(s,this.Er),s.beamingMode=this.$n,this.Pr.voiceStemDir&&(s.preferredBeamDirection=this.Pr.voiceStemDir),this.Wi(s,t.findChildElement("duration")),s.updateDurations(),this.Pr.currentPosition+=s.playbackDuration,this.Er.addBeat(s),this.Wr(s,t),this.Pr.currentPosition>=this.Pr.currentBarDuration&&(this.Pr.currentBarComplete=!0);break;case"rest":const n=this.Rr(t.findChildElement("duration"));n&&(this.Lr(n,this.Er),n.updateDurations(),this.Pr.currentPosition+=n.playbackDuration,this.Er.addBeat(n),this.Pr.currentPosition>=this.Pr.currentBarDuration&&(this.Pr.currentBarComplete=!0))}}Lr(t,e){const s=this.Or(e);s&&(t.dynamics=s.dynamics)}Or(t){if(t.beats.length>0)return t.beats[t.beats.length-1];if(t.bar.index>0){const e=t.bar.staff.bars[t.bar.index-1];if(t.index<e.voices.length){const s=e.voices[t.index];return this.Or(s)}}return null}Ar(t,e){for(;this.Cr.voices.length<e+1;)this.Cr.addVoice(new lt);(!this.zn.has(t.track.index)||this.zn.get(t.track.index)<this.Cr.voices.length)&&this.zn.set(t.track.index,this.Cr.voices.length),this.Er=this.Cr.voices[e]}Wr(t,e){const s=new At;for(const i of e.childElements())switch(i.localName){case"stem":switch(i.getAttribute("dir")){case"up":t.preferredBeamDirection=Fe.Up;break;case"down":t.preferredBeamDirection=Fe.Down}break;case"articulation":switch(i.getAttribute("type")){case"staccato":s.isStaccato=!0;break;case"normalAccent":s.accentuated=k.Normal;break;case"strongAccent":s.accentuated=k.Heavy}break;case"lyric":this.Ir(t,i);break;case"drawObjects":this.Gr(t,i);break;case"heads":this.Hr(t,s,i);break;case"beam":switch(i.getAttribute("group")){case"force":t.beamingMode=Vt.ForceMergeWithNext;break;case"divide":t.beamingMode=Vt.ForceSplitToNext}}}Hr(t,e,s){for(const i of s.childElements())if("head"===i.localName)this.$r(t,e,i)}jn;Jn;qn;Yn;$r(t,e,s){const i=new At,n=Bt.parseTuning(s.getAttribute("pitch"));i.octave=n.octave-1,i.tone=n.tone.noteValue,i.isStaccato=e.isStaccato,i.accentuated=e.accentuated,t.addNote(i);for(const t of s.childElements())switch(t.localName){case"alter":t.attributes.has("step")&&(i.tone+=Number.parseInt(t.attributes.get("step"),10));break;case"tie":t.attributes.has("begin")?this.Jn.has(i.id)||(this.Jn.set(i.id,!0),this.jn.push(i)):t.attributes.has("end")&&this.jn.length>0&&!i.isTieDestination&&(i.isTieDestination=!0,i.tieOrigin=this.jn[0],this.jn.splice(0,1),this.Jn.delete(i.id))}}Gr(t,e){for(const s of e.childElements())if("drawObj"===s.localName){const e=this.Vr(s);if(e)if(e instanceof rs)e.fontFace.startsWith("capella")?"u"===e.text?(t.fermata=new _e,t.fermata.type=Be.Medium):"f"===e.text?t.dynamics=o.F:"j"===e.text&&(t.dynamics=o.MF):this.Un&&""===this.score.title&&e.align===ut.Center&&e.height>16&&e.weight>400?this.score.title=e.text:this.Un&&""===this.score.artist&&e.align===ut.Center&&e.y<0?this.score.artist=e.text:this.Un&&""===this.score.music&&e.align===ut.Right&&e.y<0?this.score.music=e.text:e.text.startsWith("by capella")||(t.text=e.text);else if(e instanceof as);else if(e instanceof os)t.vibrato=P.Slight;else if(e instanceof ls)t.crescendo=e.decrescendo?g.Decrescendo:g.Crescendo,e.noteRange++,this.Yn.set(t,e);else if(e instanceof hs){const s=e;this.qn.set(t,s)}else e instanceof us&&this.zr(e)}}Dr(t){for(const e of t.childElements())if("drawObj"===e.localName){const t=this.Vr(e);t&&t instanceof us&&this.zr(t)}}zr(t){if(t.lastNumber>0?(this.Pr.repeatCount=t.lastNumber,this.Pr.repeatEnd&&this.Pr.repeatEnd.repeatCount<this.Pr.repeatCount&&(this.Pr.repeatEnd.repeatCount=this.Pr.repeatCount)):t.firstNumber>0&&(this.Pr.repeatCount=t.firstNumber,this.Pr.repeatEnd&&this.Pr.repeatEnd.repeatCount<this.Pr.repeatCount&&(this.Pr.repeatEnd.repeatCount=this.Pr.repeatCount)),t.lastNumber>0&&t.firstNumber>0){let e=0;for(let s=t.firstNumber;s<=t.lastNumber;s++)e|=1<<s-1;this.Cr.masterBar.alternateEndings=e}else t.lastNumber>0?this.Cr.masterBar.alternateEndings=1<<t.lastNumber-1:t.firstNumber>0&&(this.Cr.masterBar.alternateEndings=1<<t.firstNumber-1)}Ir(t,e){for(const s of e.childElements())if("verse"===s.localName){t.lyrics||(t.lyrics=[]);let e=s.innerText;"true"===s.getAttribute("hyphen")&&(e+="-"),t.lyrics.push(e)}}Rr(t){const e=t.getAttribute("base");if(-1!==e.indexOf("/")){const e=new Xt;return e.beamingMode=this.$n,this.Wi(e,t),e}if(1===Number.parseInt(e,10)){const t=new Xt;return t.beamingMode=this.$n,t.duration=w.Whole,t}return O.warning("Importer","Multi-Bar rests are not supported"),null}Ur(t){switch(t){case"2/1":return w.DoubleWhole;case"1/1":return w.Whole;case"1/2":return w.Half;case"1/4":return w.Quarter;case"1/8":return w.Eighth;case"1/16":return w.Sixteenth;case"1/32":return w.ThirtySecond;case"1/64":return w.SixtyFourth;case"1/128":return w.OneHundredTwentyEighth;default:return O.warning("Importer","Unsupported duration"),w.Quarter}}Wi(t,e){const s=e.getAttribute("base");t.duration=this.Ur(s),e.attributes.has("dots")&&(t.dots=Number.parseInt(e.attributes.get("dots"),10));const i=e.findChildElement("tuplet");if(i){t.tupletNumerator=Number.parseInt(i.getAttribute("count"),10);const e="true"===i.getAttribute("tripartite")?3:1,s="true"===i.getAttribute("prolong")?0:1;let n=0;for(;e*Math.pow(2,n+s)<t.tupletNumerator;)n++;t.tupletDenominator=e*Math.pow(2,n)}}ir(t){for(const e of t.childElements())if("drawObj"===e.localName){const t=this.Vr(e);if(t&&t instanceof rs)switch(t.align){case ut.Center:this.score.title?this.score.subTitle||(this.score.subTitle=e.innerText):this.score.title=e.innerText;break;case ut.Right:this.score.artist||(this.score.artist=e.innerText)}}}sr(t){for(const e of t.childElements())if("drawObj"===e.localName){const t=this.Vr(e);t&&this.Vn.set(e.getAttribute("name"),t)}}Vr(t){let e=null,s=1;for(const i of t.childElements())switch(i.localName){case"text":e=this.Xr(i);break;case"guitar":e=this.jr(i);break;case"slur":e=this.Jr(i);break;case"wavyLine":e=this.qr(i);break;case"bracket":e=this.Yr(i);break;case"wedge":e=this.Kr(i);break;case"volta":e=this.Qr(i);break;case"octaveClef":e=this.Zr(i);break;case"trill":e=this.ta(i);break;case"basic":i.attributes.has("noteRange")&&(s=Number.parseInt(i.attributes.get("noteRange"),10))}return e&&(e.noteRange=s),e}ta(t){return new fs}Zr(t){const e=new ds;return t.attributes.has("octave")&&(e.octave=Number.parseInt(t.attributes.get("octave"),10)),e}Qr(t){const e=new us;return e.allNumbers="true"===t.attributes.get("allNumbers"),t.attributes.has("firstNumber")&&(e.firstNumber=Number.parseInt(t.attributes.get("firstNumber"),10)),t.attributes.has("lastNumber")&&(e.lastNumber=Number.parseInt(t.attributes.get("lastNumber"),10)),e}Kr(t){const e=new ls;return e.decrescendo="true"===t.attributes.get("decrescendo"),e}Yr(t){const e=new cs;return t.attributes.has("number")&&(e.number=Number.parseInt(t.attributes.get("number"),10)),e}qr(t){return new os}Jr(t){return new hs}jr(t){const e=new as,s=t.innerText.trim();for(let t=0;t<s.length;t++)"/"===s.charAt(t)?e.chord.strings.push(0):e.chord.strings.push(Number.parseInt(s.charAt(t),10));return e}Xr(t){const e=new rs;switch(t.attributes.has("x")&&(e.x=Number.parseFloat(t.attributes.get("x"))),t.attributes.has("x")&&(e.y=Number.parseFloat(t.attributes.get("y"))),t.getAttribute("align")){case"left":e.align=ut.Left;break;case"center":e.align=ut.Center;break;case"right":e.align=ut.Right}switch(t.getAttribute("frame")){case"rectangle":e.frame=1;break;case"ellipse":e.frame=2;break;case"circle":e.frame=3;break;case"none":e.frame=0}if(t.firstElement)for(const s of t.childElements())switch(s.localName){case"font":e.fontFace=s.getAttribute("face"),s.attributes.has("weight")&&(e.weight=Number.parseInt(s.attributes.get("weight"),10)),s.attributes.has("height")&&(e.height=Number.parseInt(s.attributes.get("height"),10));break;case"content":e.text=s.innerText}else e.text=t.innerText;return e}tr(t){for(const e of t.childElements())switch(e.localName){case"author":this.score.tab=e.firstChild.innerText;break;case"comment":this.score.notices=e.firstChild.innerText}}},ws=class extends Re{get name(){return"Capella"}readScore(){O.debug(this.name,"Loading ZIP entries");let t,e=null;if(t=new Ke(this.data,this.settings.importer.maxDecodingBufferSize).read(),O.debug(this.name,"Zip entries loaded"),t.length>0){for(const s of t)if("score.xml"===s.fileName)e=le.toString(s.data,this.settings.importer.encoding)}else this.data.reset(),e=le.toString(this.data.readAll(),this.settings.importer.encoding);if(!e)throw new Oe("No valid capella file");O.debug(this.name,"Start Parsing score.xml");try{const t=new gs;return t.parseXml(e,this.settings),O.debug(this.name,"score.xml parsed"),t.score}catch(t){throw new Oe("Failed to parse CapXML",t)}}},ys=function(t){return t[t.TargetFine=0]="TargetFine",t[t.TargetSegno=1]="TargetSegno",t[t.TargetSegnoSegno=2]="TargetSegnoSegno",t[t.TargetCoda=3]="TargetCoda",t[t.TargetDoubleCoda=4]="TargetDoubleCoda",t[t.JumpDaCapo=5]="JumpDaCapo",t[t.JumpDaCapoAlCoda=6]="JumpDaCapoAlCoda",t[t.JumpDaCapoAlDoubleCoda=7]="JumpDaCapoAlDoubleCoda",t[t.JumpDaCapoAlFine=8]="JumpDaCapoAlFine",t[t.JumpDalSegno=9]="JumpDalSegno",t[t.JumpDalSegnoAlCoda=10]="JumpDalSegnoAlCoda",t[t.JumpDalSegnoAlDoubleCoda=11]="JumpDalSegnoAlDoubleCoda",t[t.JumpDalSegnoAlFine=12]="JumpDalSegnoAlFine",t[t.JumpDalSegnoSegno=13]="JumpDalSegnoSegno",t[t.JumpDalSegnoSegnoAlCoda=14]="JumpDalSegnoSegnoAlCoda",t[t.JumpDalSegnoSegnoAlDoubleCoda=15]="JumpDalSegnoSegnoAlDoubleCoda",t[t.JumpDalSegnoSegnoAlFine=16]="JumpDalSegnoSegnoAlFine",t[t.JumpDaCoda=17]="JumpDaCoda",t[t.JumpDaDoubleCoda=18]="JumpDaDoubleCoda",t}({}),ks=class t extends Re{static ea="FICHIER GUITAR PRO ";static sa=new Map([[27,42],[28,60],[29,29],[30,30],[32,31]]);ia=0;We;na=K.NoTripletFeel;ra=0;aa=[];ha=0;oa=0;ca=[];la=new Set;ua=new Map;da=new Map;fa=new Map;pa=new Map;Xn;get name(){return"Guitar Pro 3-5"}readScore(){if(this.pa.clear(),this.readVersion(),this.We=new wt,this.readScoreInformation(),this.ia<500&&(this.na=Ss.gpReadBool(this.data)?K.Triplet8th:K.NoTripletFeel),this.ia>=400&&this.readLyrics(),this.ia>=510&&this.data.skip(19),this.Xn=d.buildTempoAutomation(!1,0,0,0),this.ia>=500&&(this.readPageSetup(),this.Xn.text=Ss.gpReadStringIntByte(this.data,this.settings.importer.encoding,this.settings.importer.maxDecodingBufferSize)),this.Xn.value=le.readInt32LE(this.data),this.ia>=510&&Ss.gpReadBool(this.data),le.readInt32LE(this.data),this.ia>=400&&this.data.readByte(),this.readPlaybackInfos(),this.ia>=500&&(this.ba(ys.TargetCoda),this.ba(ys.TargetDoubleCoda),this.ba(ys.TargetSegno),this.ba(ys.TargetSegnoSegno),this.ba(ys.TargetFine),this.ba(ys.JumpDaCapo),this.ba(ys.JumpDaCapoAlCoda),this.ba(ys.JumpDaCapoAlDoubleCoda),this.ba(ys.JumpDaCapoAlFine),this.ba(ys.JumpDalSegno),this.ba(ys.JumpDalSegnoAlCoda),this.ba(ys.JumpDalSegnoAlDoubleCoda),this.ba(ys.JumpDalSegnoAlFine),this.ba(ys.JumpDalSegnoSegno),this.ba(ys.JumpDalSegnoSegnoAlCoda),this.ba(ys.JumpDalSegnoSegnoAlDoubleCoda),this.ba(ys.JumpDalSegnoSegnoAlFine),this.ba(ys.JumpDaCoda),this.ba(ys.JumpDaDoubleCoda),this.data.skip(4)),this.ha=le.readInt32LE(this.data),this.ma(this.ha,t.ga,"bar count"),this.oa=le.readInt32LE(this.data),this.ma(this.oa,t.wa,"track count"),this.readMasterBars(),this.readTracks(),this.readBars(),this.We.masterBars.length>0){const t=d.buildTempoAutomation(!1,0,this.We.tempo,2);t.text=this.We.tempoLabel,this.We.masterBars[0].tempoAutomations.push(t)}return Bt.consolidate(this.We),this.We.finish(this.settings),this.aa&&this.ra>=0&&this.We.tracks[this.ra].applyLyrics(this.aa),this.We}ba(t){let e,s=le.readInt16LE(this.data);-1!==s&&(s--,this.pa.has(s)?e=this.pa.get(s):(e=[],this.pa.set(s,e)),e.push(t))}readVersion(){let e=Ss.gpReadStringByteLength(this.data,30,this.settings.importer.encoding);if(!e.startsWith(t.ea))throw new Oe("Unsupported format");e=e.substr(t.ea.length+1);const s=e.indexOf(String.fromCharCode(46));this.ia=100*Number.parseInt(e.substr(0,s),10)+Number.parseInt(e.substr(s+1),10),O.debug(this.name,`Guitar Pro version ${e} detected`)}readScoreInformation(){this.We.title=Ss.gpReadStringIntUnused(this.data,this.settings.importer.encoding,this.settings.importer.maxDecodingBufferSize),this.We.subTitle=Ss.gpReadStringIntUnused(this.data,this.settings.importer.encoding,this.settings.importer.maxDecodingBufferSize),this.We.artist=Ss.gpReadStringIntUnused(this.data,this.settings.importer.encoding,this.settings.importer.maxDecodingBufferSize),this.We.album=Ss.gpReadStringIntUnused(this.data,this.settings.importer.encoding,this.settings.importer.maxDecodingBufferSize),this.We.words=Ss.gpReadStringIntUnused(this.data,this.settings.importer.encoding,this.settings.importer.maxDecodingBufferSize),this.We.music=this.ia>=500?Ss.gpReadStringIntUnused(this.data,this.settings.importer.encoding,this.settings.importer.maxDecodingBufferSize):this.We.words,this.We.copyright=Ss.gpReadStringIntUnused(this.data,this.settings.importer.encoding,this.settings.importer.maxDecodingBufferSize),this.We.tab=Ss.gpReadStringIntUnused(this.data,this.settings.importer.encoding,this.settings.importer.maxDecodingBufferSize),this.We.instructions=Ss.gpReadStringIntUnused(this.data,this.settings.importer.encoding,this.settings.importer.maxDecodingBufferSize);const e=le.readInt32LE(this.data);this.ma(e,t.ya,"notice line count");let s="";for(let t=0;t<e;t++)t>0&&(s+="\r\n"),s+=Ss.gpReadStringIntUnused(this.data,this.settings.importer.encoding,this.settings.importer.maxDecodingBufferSize)?.toString();this.We.notices=s}static ya=1e3;static ga=1e3;static wa=100;static ka=100;static Sa=4*f.MaxPosition;ma(t,e,s){if(t>e)throw new Le(`'${s}' with value ${t} has exceeded the internal safety threshold of ${e}`)}readLyrics(){this.aa=[],this.ra=le.readInt32LE(this.data)-1;for(let t=0;t<5;t++){const t=new xe;t.startBar=le.readInt32LE(this.data)-1,t.text=Ss.gpReadStringInt(this.data,this.settings.importer.encoding,this.settings.importer.maxDecodingBufferSize),this.aa.push(t)}}readPageSetup(){this.data.skip(28);const t=le.readInt16LE(this.data);Bt.getOrCreateHeaderFooterStyle(this.We,bt.Title).isVisible=!!(1&t),Bt.getOrCreateHeaderFooterStyle(this.We,bt.Title).template=Ss.gpReadStringIntByte(this.data,this.settings.importer.encoding,this.settings.importer.maxDecodingBufferSize),Bt.getOrCreateHeaderFooterStyle(this.We,bt.SubTitle).isVisible=!!(2&t),Bt.getOrCreateHeaderFooterStyle(this.We,bt.SubTitle).template=Ss.gpReadStringIntByte(this.data,this.settings.importer.encoding,this.settings.importer.maxDecodingBufferSize),Bt.getOrCreateHeaderFooterStyle(this.We,bt.Artist).isVisible=!!(4&t),Bt.getOrCreateHeaderFooterStyle(this.We,bt.Artist).template=Ss.gpReadStringIntByte(this.data,this.settings.importer.encoding,this.settings.importer.maxDecodingBufferSize),Bt.getOrCreateHeaderFooterStyle(this.We,bt.Album).isVisible=!!(8&t),Bt.getOrCreateHeaderFooterStyle(this.We,bt.Album).template=Ss.gpReadStringIntByte(this.data,this.settings.importer.encoding,this.settings.importer.maxDecodingBufferSize),Bt.getOrCreateHeaderFooterStyle(this.We,bt.Words).isVisible=!!(16&t),Bt.getOrCreateHeaderFooterStyle(this.We,bt.Words).template=Ss.gpReadStringIntByte(this.data,this.settings.importer.encoding,this.settings.importer.maxDecodingBufferSize),Bt.getOrCreateHeaderFooterStyle(this.We,bt.Music).isVisible=!!(32&t),Bt.getOrCreateHeaderFooterStyle(this.We,bt.Music).template=Ss.gpReadStringIntByte(this.data,this.settings.importer.encoding,this.settings.importer.maxDecodingBufferSize),Bt.getOrCreateHeaderFooterStyle(this.We,bt.WordsAndMusic).isVisible=!!(64&t),Bt.getOrCreateHeaderFooterStyle(this.We,bt.WordsAndMusic).template=Ss.gpReadStringIntByte(this.data,this.settings.importer.encoding,this.settings.importer.maxDecodingBufferSize),Bt.getOrCreateHeaderFooterStyle(this.We,bt.Copyright).isVisible=!!(128&t),Bt.getOrCreateHeaderFooterStyle(this.We,bt.Copyright).template=Ss.gpReadStringIntByte(this.data,this.settings.importer.encoding,this.settings.importer.maxDecodingBufferSize),Bt.getOrCreateHeaderFooterStyle(this.We,bt.CopyrightSecondLine).isVisible=!!(128&t),Bt.getOrCreateHeaderFooterStyle(this.We,bt.CopyrightSecondLine).template=Ss.gpReadStringIntByte(this.data,this.settings.importer.encoding,this.settings.importer.maxDecodingBufferSize),Ss.gpReadStringIntByte(this.data,this.settings.importer.encoding,this.settings.importer.maxDecodingBufferSize)}readPlaybackInfos(){this.ca=[];let t=0;for(let e=0;e<64;e++){const e=new Ne;e.primaryChannel=t++,e.secondaryChannel=t++,e.program=le.readInt32LE(this.data),e.volume=this.data.readByte(),e.balance=this.data.readByte(),this.data.skip(6),this.ca.push(e)}}readMasterBars(){for(let t=0;t<this.ha;t++)this.readMasterBar()}readMasterBar(){let t=null;this.We.masterBars.length>0&&(t=this.We.masterBars[this.We.masterBars.length-1]);const e=new Z;!t&&this.Xn.value>0&&e.tempoAutomations.push(this.Xn);const s=this.data.readByte();if(1&s?e.timeSignatureNumerator=this.data.readByte():t&&(e.timeSignatureNumerator=t.timeSignatureNumerator),2&s?e.timeSignatureDenominator=this.data.readByte():t&&(e.timeSignatureDenominator=t.timeSignatureDenominator),e.isRepeatStart=!!(4&s),8&s&&(e.repeatCount=this.data.readByte()+(this.ia>=500?0:1)),16&s&&this.ia<500){let s=t,i=0;for(;s&&(!s.isRepeatEnd||s===t)&&!s.isRepeatStart;)i|=s.alternateEndings,s=s.previousMasterBar;let n=0;const r=this.data.readByte();for(let t=0;t<8;t++){const e=1<<t;r>t&&0===(i&e)&&(n|=e)}e.alternateEndings=n}if(32&s){const t=new Te;t.text=Ss.gpReadStringIntByte(this.data,this.settings.importer.encoding,this.settings.importer.maxDecodingBufferSize),t.marker="",Ss.gpReadColor(this.data,!1),e.section=t}if(64&s&&this.da.set(this.We.masterBars.length,[le.readSInt8(this.data),this.data.readByte()]),this.ia>=500&&3&s&&this.data.skip(4),this.ia>=500&&(e.alternateEndings=this.data.readByte()),this.ia>=500){switch(this.data.readByte()){case 1:e.tripletFeel=K.Triplet8th;break;case 2:e.tripletFeel=K.Triplet16th}this.data.readByte()}else e.tripletFeel=this.na;const i=!!(128&s);e.isDoubleBar=i;const n=this.We.masterBars.length;if(this.pa.has(n))for(const t of this.pa.get(n))e.addDirection(t);this.We.addMasterBar(e),i&&this.la.add(e.index)}readTracks(){for(let t=0;t<this.oa;t++)this.readTrack()}static Ba=Bt.parseTuning("B1").realValue;readTrack(){const e=new Ee;e.ensureStaveCount(1),this.We.addTrack(e);const s=e.staves[0],i=this.data.readByte();e.name=Ss.gpReadStringByteLength(this.data,40,this.settings.importer.encoding),1&i&&(s.isPercussion=!0),this.ia>=500&&(e.isVisibleOnMultiTrack=!!(8&i)),null===this.We.stylesheet.perTrackDisplayTuning&&(this.We.stylesheet.perTrackDisplayTuning=new Map),this.We.stylesheet.perTrackDisplayTuning.set(e.index,!!(128&i));const n=le.readInt32LE(this.data),r=[];for(let t=0;t<7;t++){const e=le.readInt32LE(this.data);n>t&&r.push(e)}s.stringTuning.tunings=r;const a=le.readInt32LE(this.data),h=le.readInt32LE(this.data)-1,o=le.readInt32LE(this.data)-1;if(this.data.skip(4),h>=0&&h<this.ca.length){const t=this.ca[h];t.port=a,t.isSolo=!!(16&i),t.isMute=!!(32&i),t.secondaryChannel=o,we.isGuitar(t.program)&&(s.displayTranspositionPitch=-12),e.playbackInfo=t}if(s.capo=le.readInt32LE(this.data),e.color=Ss.gpReadColor(this.data,!1),this.ia>=500){const i=this.data.readByte();s.showTablature=!!(1&i),s.showStandardNotation=!!(2&i);const n=!!(100&i);null===this.We.stylesheet.perTrackChordDiagramsOnTop&&(this.We.stylesheet.perTrackChordDiagramsOnTop=new Map),this.We.stylesheet.perTrackChordDiagramsOnTop.set(e.index,n),this.data.readByte(),this.data.readByte(),e.playbackInfo.bank=this.data.readByte(),this.data.readByte(),12===le.readInt32LE(this.data)||r[r.length-1]<t.Ba?this.ua.set(e.index,G.F4):this.ua.set(e.index,G.G2),le.readInt32LE(this.data),le.readInt32LE(this.data),this.data.skip(10),this.data.readByte(),this.data.readByte(),this._a(),this.ia>=510&&(this.data.skip(4),Ss.gpReadStringIntByte(this.data,this.settings.importer.encoding,this.settings.importer.maxDecodingBufferSize),Ss.gpReadStringIntByte(this.data,this.settings.importer.encoding,this.settings.importer.maxDecodingBufferSize))}else r[r.length-1]<t.Ba?this.ua.set(e.index,G.F4):this.ua.set(e.index,G.G2)}readBars(){for(let t=0;t<this.ha;t++)for(let t=0;t<this.oa;t++)this.readBar(this.We.tracks[t])}readBar(t){const e=new Y,s=t.staves[0];if(s.isPercussion?e.clef=G.Neutral:this.ua.has(t.index)&&(e.clef=this.ua.get(t.index)),s.addBar(e),this.da.has(e.index)){const t=this.da.get(e.index);e.keySignature=t[0],e.keySignatureType=t[1]}else e.index>0&&(e.keySignature=e.previousBar.keySignature,e.keySignatureType=e.previousBar.keySignatureType);this.la.has(e.index)&&(e.barLineRight=q.LightLight);let i=1;this.ia>=500&&(this.data.readByte(),i=2);for(let s=0;s<i;s++)this.readVoice(t,e)}readVoice(e,s){const i=le.readInt32LE(this.data);if(0===i)return;const n=new lt;s.addVoice(n),this.ma(i,t.ka,"beat count");for(let t=0;t<i;t++)this.readBeat(e,s,n)}readBeat(t,e,s){const i=new Xt,n=this.data.readByte();switch(1&n&&(i.dots=1),64&n&&(i.isEmpty=!(2&this.data.readByte())),s.addBeat(i),le.readSInt8(this.data)){case-2:i.duration=w.Whole;break;case-1:i.duration=w.Half;break;case 0:i.duration=w.Quarter;break;case 1:i.duration=w.Eighth;break;case 2:i.duration=w.Sixteenth;break;case 3:i.duration=w.ThirtySecond;break;case 4:i.duration=w.SixtyFourth;break;default:i.duration=w.Quarter}if(32&n)switch(i.tupletNumerator=le.readInt32LE(this.data),i.tupletNumerator){case 1:i.tupletDenominator=1;break;case 3:i.tupletDenominator=2;break;case 5:case 6:case 7:i.tupletDenominator=4;break;case 9:case 10:case 11:case 12:case 13:i.tupletDenominator=8;break;case 2:case 4:case 8:break;default:i.tupletNumerator=1,i.tupletDenominator=1}2&n&&this.readChord(i);const r=this.settings.importer.beatTextAsLyrics&&t.index!==this.ra;if(4&n){const e=Ss.gpReadStringIntUnused(this.data,this.settings.importer.encoding,this.settings.importer.maxDecodingBufferSize);if(r){const s=new xe;s.text=e.trim(),s.finish(!0);const i=[];for(let t=s.chunks.length-1;t>=0;t--)i.push(s.chunks[t]);this.fa.set(t.index,i)}else i.text=e}let a=B.None;8&n&&(a=this.readBeatEffects(i)),16&n&&this.readMixTableChange(i);const h=this.data.readByte();for(let n=6;n>=0;n--)if(h&1<<n&&6-n<e.staff.tuning.length){const r=this.readNote(t,e,s,i,6-n);a!==B.None&&(r.harmonicType=a,r.harmonicValue=Bt.deltaFretToHarmonicValue(r.fret))}if(this.ia>=500){const t=le.readInt16LE(this.data);if(1&t&&i.index>0&&(s.beats[i.index-1].beamingMode=Vt.ForceSplitToNext),2&t&&(i.preferredBeamDirection=Fe.Down),4&t&&i.index>0&&(s.beats[i.index-1].beamingMode=Vt.ForceMergeWithNext),8&t&&(i.preferredBeamDirection=Fe.Up),16&t&&(i.ottava=x.T),32&t&&(i.ottava=x.M),64&t&&(i.ottava=x._),256&t&&(i.ottava=x.L),2048&t){const t=0!==this.data.readByte();i.index>0&&t&&(s.beats[i.index-1].beamingMode=Vt.ForceSplitOnSecondaryToNext)}}r&&!i.isRest&&this.fa.has(t.index)&&this.fa.get(t.index).length>0&&(i.lyrics=[this.fa.get(t.index).pop()])}readChord(t){const e=new ye,s=Bt.newGuid();if(this.ia>=500){this.data.skip(17),e.name=Ss.gpReadStringByteLength(this.data,21,this.settings.importer.encoding),this.data.skip(4),e.firstFret=le.readInt32LE(this.data);for(let s=0;s<7;s++){const i=le.readInt32LE(this.data);s<t.voice.bar.staff.tuning.length&&e.strings.push(i)}const s=this.data.readByte(),i=new Uint8Array(5);this.data.read(i,0,i.length);for(let t=0;t<s;t++)e.barreFrets.push(i[t]);this.data.skip(26)}else if(0!==this.data.readByte())if(this.ia>=400){this.data.skip(16),e.name=Ss.gpReadStringByteLength(this.data,21,this.settings.importer.encoding),this.data.skip(4),e.firstFret=le.readInt32LE(this.data);for(let s=0;s<7;s++){const i=le.readInt32LE(this.data);s<t.voice.bar.staff.tuning.length&&e.strings.push(i)}const s=this.data.readByte(),i=new Uint8Array(5);this.data.read(i,0,i.length);for(let t=0;t<s;t++)e.barreFrets.push(i[t]);this.data.skip(26)}else{this.data.skip(25),e.name=Ss.gpReadStringByteLength(this.data,34,this.settings.importer.encoding),e.firstFret=le.readInt32LE(this.data);for(let s=0;s<6;s++){const i=le.readInt32LE(this.data);s<t.voice.bar.staff.tuning.length&&e.strings.push(i)}this.data.skip(36)}else{const s=this.ia>=406?7:6;if(e.name=Ss.gpReadStringIntByte(this.data,this.settings.importer.encoding,this.settings.importer.maxDecodingBufferSize),e.firstFret=le.readInt32LE(this.data),e.firstFret>0)for(let i=0;i<s;i++){const s=le.readInt32LE(this.data);i<t.voice.bar.staff.tuning.length&&e.strings.push(s)}}e.name&&(t.chordId=s,t.voice.bar.staff.addChord(t.chordId,e))}readBeatEffects(e){const s=this.data.readByte();let i=0;if(this.ia>=400&&(i=this.data.readByte()),16&s&&(e.fade=Rt.FadeIn),(this.ia<400&&1&s||2&s)&&(e.vibrato=P.Slight),1&i&&(e.rasgueado=Gt.Ii),32&s&&this.ia>=400)switch(le.readSInt8(this.data)){case 1:e.tap=!0;break;case 2:e.slap=!0;break;case 3:e.pop=!0}else if(32&s){switch(le.readSInt8(this.data)){case 1:e.tap=!0;break;case 2:e.slap=!0;break;case 3:e.pop=!0}this.data.skip(4)}if(4&i&&this.readTremoloBarEffect(e),64&s){let s=0,i=0;this.ia<500?(i=this.data.readByte(),s=this.data.readByte()):(s=this.data.readByte(),i=this.data.readByte()),s>0?(e.brushType=m.BrushUp,e.brushDuration=t.xa(s)):i>0&&(e.brushType=m.BrushDown,e.brushDuration=t.xa(i))}if(2&i)switch(le.readSInt8(this.data)){case 0:e.pickStroke=_t.None;break;case 1:e.pickStroke=_t.Up;break;case 2:e.pickStroke=_t.Down}if(this.ia<400){if(4&s)return B.Natural;if(8&s)return B.Artificial}return B.None}readTremoloBarEffect(e){this.data.readByte(),le.readInt32LE(this.data);const s=le.readInt32LE(this.data);if(this.ma(s,t.Sa,"tremolo bar point count"),s>0)for(let i=0;i<s;i++){const s=new f(0,0);s.offset=le.readInt32LE(this.data),s.value=le.readInt32LE(this.data)/t.Ta|0,Ss.gpReadBool(this.data),e.addWhammyBarPoint(s)}}static xa(t){switch(t){case 1:case 2:return 30;case 3:return 60;case 4:return 120;case 5:return 240;case 6:return 480;default:return 0}}_a(){this.data.skip(4),this.data.skip(4),this.data.skip(4),this.data.skip(4)}readMixTableChange(t){const e=new Bs;e.instrument=le.readSInt8(this.data),this.ia>=500&&this._a(),e.volume=le.readSInt8(this.data),e.balance=le.readSInt8(this.data);const s=le.readSInt8(this.data),i=le.readSInt8(this.data),n=le.readSInt8(this.data),r=le.readSInt8(this.data);if(this.ia>=500&&(e.tempoName=Ss.gpReadStringIntByte(this.data,this.settings.importer.encoding,this.settings.importer.maxDecodingBufferSize)),e.tempo=le.readInt32LE(this.data),e.volume>=0&&this.data.readByte(),e.balance>=0&&this.data.readByte(),s>=0&&this.data.readByte(),i>=0&&this.data.readByte(),n>=0&&this.data.readByte(),r>=0&&this.data.readByte(),e.tempo>=0&&(e.duration=le.readSInt8(this.data),this.ia>=510&&this.data.readByte()),this.ia>=400&&this.data.readByte(),this.ia>=500){const e=le.readSInt8(this.data);e>=100?t.wahPedal=Ot.Closed:e>=0&&(t.wahPedal=Ot.Open)}if(this.ia>=510&&(Ss.gpReadStringIntByte(this.data,this.settings.importer.encoding,this.settings.importer.maxDecodingBufferSize),Ss.gpReadStringIntByte(this.data,this.settings.importer.encoding,this.settings.importer.maxDecodingBufferSize)),e.volume>=0){const s=new d;s.isLinear=!0,s.type=l.Volume,s.value=e.volume,t.automations.push(s)}if(e.balance>=0){const s=new d;s.isLinear=!0,s.type=l.Balance,s.value=e.balance,t.automations.push(s)}if(e.instrument>=0){const s=new d;s.isLinear=!0,s.type=l.Instrument,s.value=e.instrument,t.automations.push(s)}if(e.tempo>=0){const s=new d;s.isLinear=!0,s.type=l.Tempo,s.value=e.tempo,t.automations.push(s),t.voice.bar.masterBar.tempoAutomations.some(t=>t.ratioPosition===s.ratioPosition&&t.value===s.value)||t.voice.bar.masterBar.tempoAutomations.push(s)}}readNote(e,s,i,n,r){const a=new At;a.string=s.staff.tuning.length-r;const h=this.data.readByte();if(2&h?a.accentuated=k.Heavy:64&h&&(a.accentuated=k.Normal),a.isGhost=!!(4&h),32&h){const t=this.data.readByte();3===t?a.isDead=!0:2===t&&(a.isTieDestination=!0)}if(1&h&&this.ia<500&&(this.data.readByte(),this.data.readByte()),16&h){const t=le.readSInt8(this.data);a.dynamics=this.toDynamicValue(t),n.dynamics=a.dynamics}32&h&&(a.fret=le.readSInt8(this.data)),128&h&&(a.leftHandFinger=le.readSInt8(this.data),a.rightHandFinger=le.readSInt8(this.data));let o=!1;if(this.ia>=500&&(1&h&&(a.durationPercent=le.readFloat64BE(this.data)),o=!!(2&this.data.readByte())),n.addNote(a),8&h&&this.readNoteEffects(e,i,n,a),s.staff.isPercussion&&(a.percussionArticulation=t.sa.has(a.fret)?t.sa.get(a.fret):a.fret,a.string=-1,a.fret=-1),o){const t=Bt.computeAccidental(s.keySignature,_.Default,a.realValueWithoutHarmonic,!1);t===I.Sharp?a.accidentalMode=_.ForceFlat:t===I.Flat&&(a.accidentalMode=_.ForceSharp)}return a}toDynamicValue(t){switch(t){case 1:return o.PPP;case 2:return o.PP;case 3:return o.P;case 4:return o.MP;case 5:return o.MF;case 6:default:return o.F;case 7:return o.FF;case 8:return o.FFF}}readNoteEffects(t,e,s,i){const n=this.data.readByte();let r=0;this.ia>=400&&(r=this.data.readByte()),1&n&&this.readBend(i),16&n&&this.readGrace(e,i),4&r&&this.readTremoloPicking(s),8&r?this.readSlide(i):this.ia<400&&4&n&&(i.slideOutType=M.Shift),16&r&&this.readArtificialHarmonic(i),32&r&&this.readTrill(i),i.isLetRing=!!(8&n),i.isHammerPullOrigin=!!(2&n),64&r&&(i.vibrato=P.Slight),i.isPalmMute=!!(2&r),i.isStaccato=!!(1&r)}static Ta=25;readBend(e){this.data.readByte(),le.readInt32LE(this.data);const s=le.readInt32LE(this.data);if(this.ma(s,t.Sa,"note bend point count"),s>0)for(let i=0;i<s;i++){const s=new f(0,0);s.offset=le.readInt32LE(this.data),s.value=le.readInt32LE(this.data)/t.Ta|0,Ss.gpReadBool(this.data),e.addBendPoint(s)}}readGrace(t,e){const s=new Xt,i=new At;switch(i.string=e.string,i.fret=le.readSInt8(this.data),s.duration=w.ThirtySecond,s.dynamics=this.toDynamicValue(le.readSInt8(this.data)),le.readSInt8(this.data)){case 0:case 2:break;case 1:i.slideOutType=M.Legato,i.slideTarget=e;break;case 3:i.isHammerPullOrigin=!0}if(i.dynamics=s.dynamics,this.data.skip(1),this.ia<500)s.graceType=y.BeforeBeat;else{const t=this.data.readByte();i.isDead=!!(1&t),s.graceType=2&t?y.OnBeat:y.BeforeBeat}t.addGraceBeat(s),s.addNote(i)}readTremoloPicking(t){const e=new $t;t.tremoloPicking=e,e.marks=this.data.readByte()}readSlide(t){if(this.ia>=500){const e=le.readSInt8(this.data);1&e?t.slideOutType=M.Shift:2&e?t.slideOutType=M.Legato:4&e?t.slideOutType=M.OutDown:8&e&&(t.slideOutType=M.OutUp),16&e?t.slideInType=T.IntoFromBelow:32&e&&(t.slideInType=T.IntoFromAbove)}else switch(le.readSInt8(this.data)){case 1:t.slideOutType=M.Shift;break;case 2:t.slideOutType=M.Legato;break;case 3:t.slideOutType=M.OutDown;break;case 4:t.slideOutType=M.OutUp;break;case-1:t.slideInType=T.IntoFromBelow;break;case-2:t.slideInType=T.IntoFromAbove}}readArtificialHarmonic(t){const e=this.data.readByte();if(this.ia>=500)switch(e){case 1:t.harmonicType=B.Natural,t.harmonicValue=Bt.deltaFretToHarmonicValue(t.fret);break;case 2:const e=this.data.readByte();let s=this.data.readByte();255===s&&(s=-1);const i=this.data.readByte(),n=e+s,r=(t.fret+t.stringTuning)%12;let a=n+12*i;a<r&&(a+=12);const h=a-r;t.harmonicType=B.Artificial,t.harmonicValue=Bt.deltaFretToHarmonicValue(h);break;case 3:t.harmonicType=B.Tap,t.harmonicValue=Bt.deltaFretToHarmonicValue(this.data.readByte());break;case 4:t.harmonicType=B.Pinch,t.harmonicValue=Bt.deltaFretToHarmonicValue(12);break;case 5:t.harmonicType=B.Semi,t.harmonicValue=Bt.deltaFretToHarmonicValue(12)}else if(this.ia>=400)switch(e){case 1:t.harmonicType=B.Natural,t.harmonicValue=Bt.deltaFretToHarmonicValue(t.fret);break;case 3:t.harmonicType=B.Tap,t.harmonicValue=Bt.deltaFretToHarmonicValue(12);break;case 4:t.harmonicType=B.Pinch,t.harmonicValue=Bt.deltaFretToHarmonicValue(12);break;case 5:t.harmonicType=B.Semi,t.harmonicValue=Bt.deltaFretToHarmonicValue(12);break;case 15:t.harmonicType=B.Artificial,t.harmonicValue=Bt.deltaFretToHarmonicValue(5);break;case 17:t.harmonicType=B.Artificial,t.harmonicValue=Bt.deltaFretToHarmonicValue(7);break;case 22:t.harmonicType=B.Artificial,t.harmonicValue=Bt.deltaFretToHarmonicValue(12)}}readTrill(t){switch(t.trillValue=this.data.readByte()+t.stringTuning,this.data.readByte()){case 1:t.trillSpeed=w.Sixteenth;break;case 2:t.trillSpeed=w.ThirtySecond;break;case 3:t.trillSpeed=w.SixtyFourth}}},Ss=class t{static gpReadColor(t,e=!1){const s=t.readByte(),i=t.readByte(),n=t.readByte();let r=255;return e?r=t.readByte():t.skip(1),new Se(s,i,n,r)}static gpReadBool(t){return 0!==t.readByte()}static gpReadStringIntUnused(e,s,i){return e.skip(4),t.gpReadString(e,e.readByte(),s,i)}static gpReadStringInt(e,s,i){return t.gpReadString(e,le.readInt32LE(e),s,i)}static gpReadStringIntByte(e,s,i){const n=le.readInt32LE(e)-1;return e.readByte(),t.gpReadString(e,n,s,i)}static gpReadString(t,e,s,i){if(e>i)throw new Le(`Detected string exceeding maxDecodingBufferSize at offset ${t.position}`);const n=new Uint8Array(e);return t.read(n,0,n.length),le.toString(n,s)}static gpWriteString(t,e){const s=le.stringToBytes(e);t.writeByte(e.length),t.write(s,0,s.length)}static gpReadStringByteLength(t,e,s){const i=t.readByte(),n=new Uint8Array(e);t.read(n,0,e);const r=Math.min(i,e);return le.toString(n.subarray(0,r),s)}},Bs=class{volume=-1;balance=-1;instrument=-1;tempoName="";tempo=-1;duration=-1},_s=class{x;y;w;h;scaleWith(t){this.x*=t,this.y*=t,this.w*=t,this.h*=t}constructor(t=0,e=0,s=0,i=0){this.x=t,this.y=e,this.h=i,this.w=s}},xs=class t{Ma=new Map;raw=new Map;constructor(t,e=0){t&&this.va(t,e)}va(t,e){const s=Ie.fromBuffer(t),i=le.readInt32BE(s);for(let t=0;t<i;t++){const t=Ss.gpReadString(s,s.readByte(),"utf-8",e),i=s.readByte();switch(this.Ma.set(t,i),i){case 0:const i=1===s.readByte();this.addValue(t,i);break;case 1:const n=le.readInt32BE(s);this.addValue(t,n);break;case 2:const r=le.readFloat32BE(s);this.addValue(t,r);break;case 3:const a=Ss.gpReadString(s,le.readInt16BE(s),"utf-8",e);this.addValue(t,a);break;case 4:const h=le.readInt32BE(s),o=le.readInt32BE(s);this.addValue(t,new f(h,o));break;case 5:const c=le.readInt32BE(s),l=le.readInt32BE(s);this.addValue(t,new f(c,l));break;case 6:const u=new _s;u.x=le.readInt32BE(s),u.y=le.readInt32BE(s),u.w=le.readInt32BE(s),u.h=le.readInt32BE(s),this.addValue(t,u);break;case 7:const d=Ss.gpReadColor(s,!0);this.addValue(t,d)}}}apply(t){for(const[e,s]of this.raw)switch(e){case"StandardNotation/hideDynamics":t.stylesheet.hideDynamics=s;break;case"System/bracketExtendMode":t.stylesheet.bracketExtendMode=s;break;case"Global/useSystemSignSeparator":t.stylesheet.useSystemSignSeparator=s;break;case"Global/DisplayTuning":t.stylesheet.globalDisplayTuning=s;break;case"Global/DrawChords":t.stylesheet.globalDisplayChordDiagramsOnTop=s;break;case"System/drawChordInScore":t.stylesheet.globalDisplayChordDiagramsInScore=s;break;case"System/showTrackNameSingle":s||(t.stylesheet.singleTrackTrackNamePolicy=et.Hidden);break;case"System/showTrackNameMulti":s||(t.stylesheet.multiTrackTrackNamePolicy=et.Hidden);break;case"System/trackNameModeSingle":if(t.stylesheet.singleTrackTrackNamePolicy!==et.Hidden)switch(s){case 0:case 1:t.stylesheet.singleTrackTrackNamePolicy=et.FirstSystem;break;case 2:t.stylesheet.singleTrackTrackNamePolicy=et.AllSystems}break;case"System/trackNameModeMulti":if(t.stylesheet.multiTrackTrackNamePolicy!==et.Hidden)switch(s){case 0:case 1:t.stylesheet.multiTrackTrackNamePolicy=et.FirstSystem;break;case 2:t.stylesheet.multiTrackTrackNamePolicy=et.AllSystems}break;case"System/shortTrackNameOnFirstSystem":t.stylesheet.firstSystemTrackNameMode=s?st.ShortName:st.FullName;break;case"System/shortTrackNameOnOtherSystems":t.stylesheet.otherSystemsTrackNameMode=s?st.ShortName:st.FullName;break;case"System/horizontalTrackNameOnFirstSystem":t.stylesheet.firstSystemTrackNameOrientation=s?it.Horizontal:it.Vertical;break;case"System/horizontalTrackNameOnOtherSystems":t.stylesheet.otherSystemsTrackNameOrientation=s?it.Horizontal:it.Vertical;break;case"System/ExtendedBarLines":t.stylesheet.extendBarLines=s;break;case"Header/Title":Bt.getOrCreateHeaderFooterStyle(t,bt.Title).template=s;break;case"Header/TitleAlignment":Bt.getOrCreateHeaderFooterStyle(t,bt.Title).textAlign=this.Na(s);break;case"Header/drawTitle":Bt.getOrCreateHeaderFooterStyle(t,bt.Title).isVisible=s;break;case"Header/Subtitle":Bt.getOrCreateHeaderFooterStyle(t,bt.SubTitle).template=s;break;case"Header/SubtitleAlignment":Bt.getOrCreateHeaderFooterStyle(t,bt.SubTitle).textAlign=this.Na(s);break;case"Header/drawSubtitle":Bt.getOrCreateHeaderFooterStyle(t,bt.SubTitle).isVisible=s;break;case"Header/Artist":Bt.getOrCreateHeaderFooterStyle(t,bt.Artist).template=s;break;case"Header/ArtistAlignment":Bt.getOrCreateHeaderFooterStyle(t,bt.Artist).textAlign=this.Na(s);break;case"Header/drawArtist":Bt.getOrCreateHeaderFooterStyle(t,bt.Artist).isVisible=s;break;case"Header/Album":Bt.getOrCreateHeaderFooterStyle(t,bt.Album).template=s;break;case"Header/AlbumAlignment":Bt.getOrCreateHeaderFooterStyle(t,bt.Album).textAlign=this.Na(s);break;case"Header/drawAlbum":Bt.getOrCreateHeaderFooterStyle(t,bt.Album).isVisible=s;break;case"Header/Words":Bt.getOrCreateHeaderFooterStyle(t,bt.Words).template=s;break;case"Header/WordsAlignment":Bt.getOrCreateHeaderFooterStyle(t,bt.Words).textAlign=this.Na(s);break;case"Header/drawWords":Bt.getOrCreateHeaderFooterStyle(t,bt.Words).isVisible=s;break;case"Header/Music":Bt.getOrCreateHeaderFooterStyle(t,bt.Music).template=s;break;case"Header/MusicAlignment":Bt.getOrCreateHeaderFooterStyle(t,bt.Music).textAlign=this.Na(s);break;case"Header/drawMusic":Bt.getOrCreateHeaderFooterStyle(t,bt.Music).isVisible=s;break;case"Header/WordsAndMusic":Bt.getOrCreateHeaderFooterStyle(t,bt.WordsAndMusic).template=s;break;case"Header/WordsAndMusicAlignment":Bt.getOrCreateHeaderFooterStyle(t,bt.WordsAndMusic).textAlign=this.Na(s);break;case"Header/drawWordsAndMusic":Bt.getOrCreateHeaderFooterStyle(t,bt.WordsAndMusic).isVisible=s;break;case"Header/Tabber":Bt.getOrCreateHeaderFooterStyle(t,bt.Transcriber).template=s;break;case"Header/TabberAlignment":Bt.getOrCreateHeaderFooterStyle(t,bt.Transcriber).textAlign=this.Na(s);break;case"Header/drawTabber":Bt.getOrCreateHeaderFooterStyle(t,bt.Transcriber).isVisible=s;break;case"Footer/Copyright":Bt.getOrCreateHeaderFooterStyle(t,bt.Copyright).template=s;break;case"Footer/CopyrightAlignment":Bt.getOrCreateHeaderFooterStyle(t,bt.Copyright).textAlign=this.Na(s);break;case"Footer/drawCopyright":Bt.getOrCreateHeaderFooterStyle(t,bt.Copyright).isVisible=s;break;case"Footer/Copyright2":Bt.getOrCreateHeaderFooterStyle(t,bt.CopyrightSecondLine).template=s;break;case"Footer/Copyright2Alignment":Bt.getOrCreateHeaderFooterStyle(t,bt.CopyrightSecondLine).textAlign=this.Na(s);break;case"Footer/drawCopyright2":Bt.getOrCreateHeaderFooterStyle(t,bt.CopyrightSecondLine).isVisible=s;break;case"System/barIndexDrawType":switch(s){case 0:t.stylesheet.barNumberDisplay=nt.AllBars;break;case 1:t.stylesheet.barNumberDisplay=nt.FirstOfSystem;break;case 2:t.stylesheet.barNumberDisplay=nt.Hide}}}Na(t){switch(t){case 0:return ut.Left;case 1:return ut.Center;case 2:return ut.Right}return ut.Left}addValue(t,e,s){this.raw.set(t,e),void 0!==s&&this.Ma.set(t,s)}writeTo(t){le.writeInt32BE(t,this.raw.size);for(const[e,s]of this.raw){const i=this.Pa(e,s);switch(Ss.gpWriteString(t,e),t.writeByte(i),i){case 0:t.writeByte(s?1:0);break;case 1:le.writeInt32BE(t,s);break;case 2:le.writeFloat32BE(t,s);break;case 3:const e=le.stringToBytes(s);le.writeInt16BE(t,e.length),t.write(e,0,e.length);break;case 4:case 5:le.writeInt32BE(t,s.offset),le.writeInt32BE(t,s.value);break;case 6:le.writeInt32BE(t,s.x),le.writeInt32BE(t,s.y),le.writeInt32BE(t,s.w),le.writeInt32BE(t,s.h);break;case 7:t.writeByte(s.r),t.writeByte(s.g),t.writeByte(s.b),t.writeByte(s.a)}}}Pa(t,e){if(this.Ma.has(t))return this.Ma.get(t);const s=typeof e;switch(typeof e){case"string":return 3;case"number":return e===(0|e)?1:2;case"object":if(e instanceof f)return 4;if(e instanceof _s)return 6;if(e instanceof Se)return 7}throw new a(r.General,`Unknown value type in BinaryStylesheet: ${s}`)}static writeForScore(e){const s=new t;switch(s.addValue("StandardNotation/hideDynamics",e.stylesheet.hideDynamics,0),s.addValue("System/bracketExtendMode",e.stylesheet.bracketExtendMode,1),s.addValue("Global/useSystemSignSeparator",e.stylesheet.useSystemSignSeparator,0),s.addValue("Global/DisplayTuning",e.stylesheet.globalDisplayTuning,0),s.addValue("Global/DrawChords",e.stylesheet.globalDisplayChordDiagramsOnTop,0),s.addValue("System/drawChordInScore",e.stylesheet.globalDisplayChordDiagramsInScore,0),e.stylesheet.singleTrackTrackNamePolicy){case et.Hidden:s.addValue("System/showTrackNameSingle",!1,0);break;case et.FirstSystem:s.addValue("System/trackNameModeSingle",0,1);break;case et.AllSystems:s.addValue("System/trackNameModeSingle",2,1)}switch(e.stylesheet.multiTrackTrackNamePolicy){case et.Hidden:s.addValue("System/showTrackNameMulti",!1,0);break;case et.FirstSystem:s.addValue("System/trackNameModeMulti",0,1);break;case et.AllSystems:s.addValue("System/trackNameModeMulti",2,1)}switch(e.stylesheet.firstSystemTrackNameMode){case st.FullName:s.addValue("System/shortTrackNameOnFirstSystem",!1,0);break;case st.ShortName:s.addValue("System/shortTrackNameOnFirstSystem",!0,0)}switch(e.stylesheet.otherSystemsTrackNameMode){case st.FullName:s.addValue("System/shortTrackNameOnOtherSystems",!1,0);break;case st.ShortName:s.addValue("System/shortTrackNameOnOtherSystems",!0,0)}switch(e.stylesheet.firstSystemTrackNameOrientation){case it.Horizontal:s.addValue("System/horizontalTrackNameOnFirstSystem",!0,0);break;case it.Vertical:s.addValue("System/horizontalTrackNameOnFirstSystem",!1,0)}switch(e.stylesheet.otherSystemsTrackNameOrientation){case it.Horizontal:s.addValue("System/horizontalTrackNameOnOtherSystems",!0,0);break;case it.Vertical:s.addValue("System/horizontalTrackNameOnOtherSystems",!1,0)}s.addValue("System/ExtendedBarLines",e.stylesheet.extendBarLines,0);const i=e.style;if(i)for(const[e,n]of i.headerAndFooter)switch(e){case bt.Title:t.Ca(s,n,"Header/","Title");break;case bt.SubTitle:t.Ca(s,n,"Header/","Subtitle");break;case bt.Artist:t.Ca(s,n,"Header/","Artist");break;case bt.Album:t.Ca(s,n,"Header/","Album");break;case bt.Words:t.Ca(s,n,"Header/","Words");break;case bt.Music:t.Ca(s,n,"Header/","Music");break;case bt.WordsAndMusic:t.Ca(s,n,"Header/","WordsAndMusic");break;case bt.Transcriber:t.Ca(s,n,"Header/","Tabber");break;case bt.Copyright:t.Ca(s,n,"Footer/","Copyright");break;case bt.CopyrightSecondLine:t.Ca(s,n,"Footer/","Copyright2")}switch(e.stylesheet.barNumberDisplay){case nt.AllBars:s.addValue("System/barIndexDrawType",0,1);break;case nt.FirstOfSystem:s.addValue("System/barIndexDrawType",1,1);break;case nt.Hide:s.addValue("System/barIndexDrawType",2,1)}const n=Ie.withCapacity(128);return s.writeTo(n),n.toArray()}static Ca(t,e,s,i){t.addValue(`${s}${i}`,e.template,3),t.addValue(`${s}${i}Alignment`,e.textAlign,1),void 0!==e.isVisible&&t.addValue(`${s}draw${i}`,e.isVisible,0)}},Ts=class{rawAudioFile},Ms=class{id="";dots=0;tupletDenominator=-1;tupletNumerator=-1;value=w.Quarter},vs=class{name="";path="";role="";get uniqueId(){return`${this.path};${this.name};${this.role}`}program=0;bank=0},Ns=class t{static Ea="-1";static Fa=f.MaxPosition/100;static Aa=.04;static Da=44100;score;La;Wa;Ra;Oa;Ia;Ga;Ha;$a;Va;za;Ua;Xa;ja;Ja;qa;Ya;Ka;Qa;Za;th;eh=!1;sh;ih=!1;nh=0;la=new Set;da=new Map;loadAsset;parseXml(t,e){this.Wa=new Map,this.Ra=new Map,this.Oa=new Map,this.Ia=[],this.Ga=new Map,this.Ha=[],this.$a=[],this.za=new Map,this.Va=new Map,this.Ua=new Map,this.Xa=new Map,this.Ja=new Map,this.ja=new Map,this.qa=new Map,this.Ka=new Map,this.Ya=new Map,this.Qa=new Map,this.Za=new Map,this.th=new Map,this.ih=!1;const s=new is;try{s.parse(t)}catch(t){throw new Oe("Could not parse XML",t)}if(this.Kn(s),this.rh(),Bt.consolidate(this.score),this.score.finish(e),!this.ih&&this.Za.size>0)for(const[t,e]of this.Za)this.Ga.get(t).applyLyrics(e)}Kn(t){const e=t.firstElement;if(e){if("GPIF"!==e.localName)throw new Oe("Root node of XML was not GPIF");this.score=new wt;for(const t of e.childElements())switch(t.localName){case"Score":this.ah(t);break;case"MasterTrack":this.hh(t);break;case"BackingTrack":this.oh(t);break;case"Tracks":this.uh(t);break;case"MasterBars":this.dh(t);break;case"Bars":this.fh(t);break;case"Voices":this.Tr(t);break;case"Beats":this.ph(t);break;case"Notes":this.bh(t);break;case"Rhythms":this.mh(t);break;case"Assets":this.gh(t)}}}gh(t){for(const e of t.childElements())if("Asset"===e.localName)e.getAttribute("id")===this.La&&this.wh(e)}wh(t){let e="";for(const s of t.childElements())if("EmbeddedFilePath"===s.localName)e=s.innerText;const s=this.loadAsset;if(s){const t=s(e);t?this.score.backingTrack.rawAudioFile=t:this.score.backingTrack=void 0}}ah(e){for(const s of e.childElements())switch(s.localName){case"Title":this.score.title=s.innerText;break;case"SubTitle":this.score.subTitle=s.innerText;break;case"Artist":this.score.artist=s.innerText;break;case"Album":this.score.album=s.innerText;break;case"Words":this.score.words=s.innerText;break;case"Music":this.score.music=s.innerText;break;case"WordsAndMusic":const e=s.innerText;""!==e&&(e&&!this.score.words&&(this.score.words=e),e&&!this.score.music&&(this.score.music=e));break;case"Copyright":this.score.copyright=s.innerText;break;case"Tabber":this.score.tab=s.innerText;break;case"Instructions":this.score.instructions=s.innerText;break;case"Notices":this.score.notices=s.innerText;break;case"ScoreSystemsDefaultLayout":this.score.defaultSystemsLayout=t.yh(s.innerText,4);break;case"ScoreSystemsLayout":this.score.systemsLayout=t.kh(s.innerText).map(e=>t.yh(e,4))}}static yh(t,e){if(!t)return e;const s=Number.parseInt(t,10);return Number.isNaN(s)?e:s}static Sh(t,e){if(!t)return e;const s=Number.parseFloat(t);return Number.isNaN(s)?e:s}static kh(t,e=" "){return t?t.split(e).map(t=>t.trim()).filter(t=>t.length>0):[]}oh(e){const s=new Ts;let i=!1,n="",r="";for(const s of e.childElements())switch(s.localName){case"Enabled":i="true"===s.innerText;break;case"Source":n=s.innerText;break;case"AssetId":r=s.innerText;break;case"FramePadding":this.nh=t.yh(s.innerText,0)/t.Da*1e3}i&&"Local"===n&&(this.score.backingTrack=s,this.La=r)}hh(e){for(const s of e.childElements())switch(s.localName){case"Automations":this.Bh(s,this.Wa,null,null);break;case"Tracks":this.Ia=t.kh(s.innerText);break;case"Anacrusis":this.eh=!0}}Bh(t,e,s,i){for(const n of t.childElements())if("Automation"===n.localName)this._h(n,e,s,i)}_h(e,s,i,n){let r,a=null,h=!1,o=-1,c=0,f=0,p=null,b=0,m=null,g=!0;for(const s of e.childElements())switch(s.localName){case"Type":a=s.innerText;break;case"Linear":h="true"===s.innerText.toLowerCase();break;case"Bar":o=t.yh(s.innerText,0);break;case"Position":c=t.Sh(s.innerText,0);break;case"Value":if(s.firstElement&&s.firstElement.nodeType===Qe.CDATA)p=s.innerText;else if(s.firstElement&&s.firstElement.nodeType===Qe.Element&&"SyncPoint"===a){r=new u;for(const e of s.childElements())switch(e.localName){case"BarIndex":o=t.yh(e.innerText,0);break;case"BarOccurrence":r.barOccurence=t.yh(e.innerText,0);break;case"FrameOffset":const s=t.Sh(e.innerText,0);r.millisecondOffset=s/t.Da*1e3}}else{const e=t.kh(s.innerText);1===e.length?(f=t.Sh(e[0],0),b=1):(f=t.Sh(e[0],0),b=t.yh(e[1],0))}break;case"Text":m=s.innerText;break;case"Visible":g="true"===s.innerText.toLowerCase()}if(!a)return;const w=[];switch(a){case"Tempo":w.push(d.buildTempoAutomation(h,c,f,b,g));break;case"SyncPoint":const t=new d;t.type=l.SyncPoint,t.isLinear=h,t.ratioPosition=c,t.syncPointValue=r,t.isVisible=g,w.push(t);break;case"Sound":if(p&&i&&i.has(p)){const t=new d;t.type=l.Bank,t.ratioPosition=c,t.value=i.get(p).bank,t.isVisible=g,w.push(t);const e=d.buildInstrumentAutomation(h,c,i.get(p).program);w.push(e)}break;case"SustainPedal":if(n){let t;n.has(o)?t=n.get(o):(t=[],n.set(o,t));const e=new X;switch(e.ratioPosition=c,b){case 1:e.pedalType=U.Down;break;case 3:e.pedalType=U.Up}t.push(e)}}if(w.length){if(m)for(const t of w)t.text=m;if(o>=0){s.has(o)||s.set(o,[]);for(const t of w)s.get(o).push(t)}}}uh(t){for(const e of t.childElements())if("Track"===e.localName)this.xh(e)}xh(e){this.sh=new Map;const s=new Ee;s.ensureStaveCount(1);s.staves[0].showStandardNotation=!0;const i=e.getAttribute("id");for(const n of e.childElements())switch(n.localName){case"Name":s.name=n.innerText;break;case"Color":const e=t.kh(n.innerText);e.length>=3&&(s.color=new Se(t.yh(e[0],0),t.yh(e[1],0),t.yh(e[2],0),255));break;case"Instrument":const r=n.getAttribute("ref");(r.endsWith("-gs")||r.endsWith("GrandStaff"))&&(s.ensureStaveCount(2),s.staves[1].showStandardNotation=!0);break;case"InstrumentSet":this.Th(s,n);break;case"NotationPatch":this.Mh(s,n);break;case"ShortName":s.shortName=n.innerText;break;case"SystemsDefautLayout":s.defaultSystemsLayout=t.yh(n.innerText,4);break;case"SystemsLayout":s.systemsLayout=t.kh(n.innerText).map(e=>t.yh(e,4));break;case"Lyrics":this.Nh(i,n);break;case"Properties":this.Ph(s,n);break;case"GeneralMidi":case"MidiConnection":case"MIDISettings":this.Ch(s,n);break;case"Sounds":this.Eh(i,s,n);break;case"PlaybackState":const a=n.innerText;s.playbackInfo.isSolo="Solo"===a,s.playbackInfo.isMute="Mute"===a;break;case"PartSounding":this.Fh(i,s,n);break;case"Staves":this.wr(s,n);break;case"Transpose":this.Ah(i,s,n);break;case"RSE":this.Dh(s,n);break;case"Automations":this.Lh(i,n)}this.Ga.set(i,s)}Lh(t,e){const s=new Map;this.Ra.set(t,s);const i=new Map;this.Oa.set(t,i),this.Bh(e,s,this.th.get(t),i)}Mh(e,s){for(const i of s.childElements())switch(i.localName){case"LineCount":const s=t.yh(i.innerText,5);for(const t of e.staves)t.standardNotationLineCount=s;break;case"Elements":this.Wh(e,i,!1)}}Th(e,s){for(const i of s.childElements())switch(i.localName){case"Type":if("drumKit"===i.innerText)for(const t of e.staves)t.isPercussion=!0;break;case"Elements":this.Wh(e,i,!0);break;case"LineCount":const s=t.yh(i.innerText,5);for(const t of e.staves)t.standardNotationLineCount=s}}Wh(t,e,s){for(const i of e.childElements())if("Element"===i.localName)this.Rh(t,i,s)}Rh(t,e,s){const i=e.findChildElement("Name")?.innerText??"";for(const n of e.childElements())switch(n.localName){case"Name":case"Articulations":this.Oh(t,n,s,i)}}Oh(t,e,s,i){for(const n of e.childElements())if("Articulation"===n.localName)this.Ih(t,n,s,i)}Ih(e,s,i,n){const r=new vt;r.outputMidiNumber=-1,r.elementType=n;let a="";for(const e of s.childElements()){const s=e.innerText;switch(e.localName){case"Name":a=e.innerText;break;case"InputMidiNumbers":r.id=t.yh(s.split(" ")[0],0);break;case"OutputMidiNumber":r.outputMidiNumber=t.yh(s,0);break;case"TechniqueSymbol":r.techniqueSymbol=t.parseTechniqueSymbol(s);break;case"TechniquePlacement":r.techniqueSymbolPlacement=t.parseTechniqueSymbolPlacement(s);break;case"Noteheads":const i=t.kh(s);i.length>=1&&(r.noteHeadDefault=t.parseNoteHead(i[0])),i.length>=2&&(r.noteHeadHalf=t.parseNoteHead(i[1])),i.length>=3&&(r.noteHeadWhole=t.parseNoteHead(i[2])),r.noteHeadHalf===xt.None&&(r.noteHeadHalf=r.noteHeadDefault),r.noteHeadWhole===xt.None&&(r.noteHeadWhole=r.noteHeadDefault);break;case"StaffLine":r.staffLine=t.yh(s,0)}}const h=`${n}.${a}`;i?(e.percussionArticulations.push(r),this.sh.set(h,r)):this.sh.has(h)&&(this.sh.get(h).staffLine=r.staffLine)}static parseTechniqueSymbol(t){switch(t){case"pictEdgeOfCymbal":return xt.PictEdgeOfCymbal;case"articStaccatoAbove":return xt.ArticStaccatoAbove;case"noteheadParenthesis":return xt.NoteheadParenthesis;case"stringsUpBow":return xt.StringsUpBow;case"stringsDownBow":return xt.StringsDownBow;case"guitarGolpe":return xt.GuitarGolpe;default:return xt.None}}static parseTechniqueSymbolPlacement(t){switch(t){case"outside":default:return Mt.Outside;case"inside":return Mt.Inside;case"above":return Mt.Above;case"below":return Mt.Below}}static parseNoteHead(t){switch(t){case"noteheadDoubleWholeSquare":return xt.NoteheadDoubleWholeSquare;case"noteheadDoubleWhole":return xt.NoteheadDoubleWhole;case"noteheadWhole":return xt.NoteheadWhole;case"noteheadHalf":return xt.NoteheadHalf;case"noteheadBlack":return xt.NoteheadBlack;case"noteheadNull":return xt.NoteheadNull;case"noteheadXOrnate":return xt.NoteheadXOrnate;case"noteheadTriangleUpWhole":return xt.NoteheadTriangleUpWhole;case"noteheadTriangleUpHalf":return xt.NoteheadTriangleUpHalf;case"noteheadTriangleUpBlack":return xt.NoteheadTriangleUpBlack;case"noteheadDiamondBlackWide":return xt.NoteheadDiamondBlackWide;case"noteheadDiamondWhite":return xt.NoteheadDiamondWhite;case"noteheadDiamondWhiteWide":return xt.NoteheadDiamondWhiteWide;case"noteheadCircleX":return xt.NoteheadCircleX;case"noteheadXWhole":return xt.NoteheadXWhole;case"noteheadXHalf":return xt.NoteheadXHalf;case"noteheadXBlack":return xt.NoteheadXBlack;case"noteheadParenthesis":return xt.NoteheadParenthesis;case"noteheadSlashedBlack2":return xt.NoteheadSlashedBlack2;case"noteheadCircleSlash":return xt.NoteheadCircleSlash;case"noteheadHeavyX":return xt.NoteheadHeavyX;case"noteheadHeavyXHat":return xt.NoteheadHeavyXHat;default:return O.warning("GPIF","Unknown notehead symbol",t),xt.None}}wr(t,e){let s=0;for(const i of e.childElements())if("Staff"===i.localName){t.ensureStaveCount(s+1);const e=t.staves[s];this.yr(e,i),s++}}yr(t,e){for(const s of e.childElements())if("Properties"===s.localName)this.Gh(t,s)}Gh(t,e){for(const s of e.childElements())if("Property"===s.localName)this.Hh(t,s)}Hh(e,s){switch(s.getAttribute("name")){case"Tuning":for(const i of s.childElements())switch(i.localName){case"Pitches":const n=t.kh(s.findChildElement("Pitches")?.innerText),r=new Array(n.length);for(let e=0;e<r.length;e++)r[r.length-1-e]=t.yh(n[e],0);e.stringTuning.tunings=r;break;case"Label":e.stringTuning.name=i.innerText}e.isPercussion||(e.showTablature=!0);break;case"DiagramCollection":case"ChordCollection":this.$h(e,s);break;case"CapoFret":e.capo=t.yh(s.findChildElement("Fret")?.innerText,0)}}Nh(t,e){const s=[];for(const t of e.childElements())if("Line"===t.localName)s.push(this.Vh(t));this.Za.set(t,s)}Vh(e){const s=new xe;for(const i of e.childElements())switch(i.localName){case"Offset":s.startBar=t.yh(i.innerText,0);break;case"Text":s.text=i.innerText}return s}zh(t,e){const s=e.findChildElement("Items");if(s)for(const e of s.childElements())if("Item"===e.localName)this.Uh(t,e)}$h(t,e){const s=e.findChildElement("Items");if(s)for(const e of s.childElements())if("Item"===e.localName)this.Xh(t,e)}Uh(t,e){const s=new ye,i=e.getAttribute("id");for(const e of t.staves)e.addChord(i,s);this.jh(s,e)}Xh(t,e){const s=new ye,i=e.getAttribute("id");t.addChord(i,s),this.jh(s,e)}jh(e,s){e.name=s.getAttribute("name");const i=s.findChildElement("Diagram");if(!i)return e.showDiagram=!1,void(e.showFingering=!1);const n=t.yh(i.getAttribute("stringCount"),6),r=t.yh(i.getAttribute("baseFret"),0);e.firstFret=r+1;for(let t=0;t<n;t++)e.strings.push(-1);for(const s of i.childElements())switch(s.localName){case"Fret":const i=t.yh(s.getAttribute("string"),0);e.strings[n-i-1]=r+t.yh(s.getAttribute("fret"),0);break;case"Fingering":const a=new Map;for(const i of s.childElements())if("Position"===i.localName){let s=S.Unknown;const n=r+t.yh(i.getAttribute("fret"),0);switch(i.getAttribute("finger")){case"Index":s=S.IndexFinger;break;case"Middle":s=S.MiddleFinger;break;case"Rank":s=S.AnnularFinger;break;case"Pinky":s=S.LittleFinger;break;case"Thumb":s=S.Thumb}s!==S.Unknown&&(a.has(s)?e.barreFrets.push(n):a.set(s,!0))}break;case"Property":switch(s.getAttribute("name")){case"ShowName":e.showName="true"===s.getAttribute("value");break;case"ShowDiagram":e.showDiagram="true"===s.getAttribute("value");break;case"ShowFingering":e.showFingering="true"===s.getAttribute("value")}}}Ph(t,e){for(const s of e.childElements())if("Property"===s.localName)this.Jh(t,s)}Jh(e,s){switch(s.getAttribute("name")){case"Tuning":const i=t.kh(s.findChildElement("Pitches")?.innerText),n=new Array(i.length);for(let e=0;e<n.length;e++)n[n.length-1-e]=t.yh(i[e],0);for(const t of e.staves)t.stringTuning.tunings=n,t.showStandardNotation=!0,t.showTablature=!0;break;case"DiagramCollection":case"ChordCollection":this.zh(e,s);break;case"CapoFret":const r=t.yh(s.findChildElement("Fret")?.innerText,0);for(const t of e.staves)t.capo=r}}Ch(e,s){for(const i of s.childElements())switch(i.localName){case"Program":e.playbackInfo.program=t.yh(i.innerText,0);break;case"Port":e.playbackInfo.port=t.yh(i.innerText,0);break;case"PrimaryChannel":e.playbackInfo.primaryChannel=t.yh(i.innerText,0);break;case"SecondaryChannel":e.playbackInfo.secondaryChannel=t.yh(i.innerText,0)}if("Percussion"===s.getAttribute("table"))for(const t of e.staves)t.isPercussion=!0}Eh(t,e,s){for(const i of s.childElements())if("Sound"===i.localName)this.qh(t,e,i)}qh(t,e,s){const i=new vs;for(const t of s.childElements())switch(t.localName){case"Name":i.name=t.innerText;break;case"Path":i.path=t.innerText;break;case"Role":i.role=t.innerText;break;case"MIDI":this.Yh(i,t)}this.th.has(t)||(this.th.set(t,new Map),e.playbackInfo.program=i.program,e.playbackInfo.bank=i.bank),this.th.get(t).set(i.uniqueId,i)}Yh(e,s){let i=0,n=0;for(const r of s.childElements())switch(r.localName){case"Program":e.program=t.yh(r.innerText,0);break;case"MSB":i=t.yh(r.innerText,0);break;case"LSB":n=t.yh(r.innerText,0)}e.bank=(127&i)<<7|n}Fh(e,s,i){for(const n of i.childElements())switch(n.localName){case"TranspositionPitch":for(const e of s.staves)e.displayTranspositionPitch=t.yh(n.innerText,0);break;case"NominalKey":const i=Math.max(0,Me.noteNames.indexOf(n.innerText));this.Kh.set(e,i)}}Kh=new Map;Ah(e,s,i){let n=0,r=0;for(const e of i.childElements())switch(e.localName){case"Chromatic":r=t.yh(e.innerText,0);break;case"Octave":n=t.yh(e.innerText,0)}const a=12*n+r;for(const t of s.staves)t.displayTranspositionPitch=a;const h=Bt.flooredDivision(a,12);this.Kh.set(e,h)}Dh(t,e){for(const s of e.childElements())if("ChannelStrip"===s.localName)this.Qh(t,s)}Qh(t,e){for(const s of e.childElements())if("Parameters"===s.localName)this.Zh(t,s)}Zh(e,s){if(s.firstChild&&s.firstChild.value){const i=t.kh(s.firstChild.value);i.length>=12&&(e.playbackInfo.balance=Math.floor(16*t.Sh(i[11],.5)),e.playbackInfo.volume=Math.floor(16*t.Sh(i[12],.9)))}}dh(t){for(const e of t.childElements())if("MasterBar"===e.localName)this.eo(e)}eo(e){const s=new Z;0===this.Ha.length&&this.eh&&(s.isAnacrusis=!0);for(const i of e.childElements())switch(i.localName){case"Time":const e=i.innerText.split("/");s.timeSignatureNumerator=t.yh(e[0],4),s.timeSignatureDenominator=t.yh(e[1],4);break;case"FreeTime":s.isFreeTime=!0;break;case"DoubleBar":s.isDoubleBar=!0,this.la.add(s);break;case"Section":s.section=new Te,s.section.marker=i.findChildElement("Letter")?.innerText??"",s.section.text=i.findChildElement("Text")?.innerText??"";break;case"Repeat":"true"===i.getAttribute("start").toLowerCase()&&(s.isRepeatStart=!0),"true"===i.getAttribute("end").toLowerCase()&&i.getAttribute("count")&&(s.repeatCount=t.yh(i.getAttribute("count"),1));break;case"AlternateEndings":const n=t.kh(i.innerText);let r=0;for(let e=0;e<n.length;e++)r|=1<<-1+t.yh(n[e],0);s.alternateEndings=r;break;case"Bars":this.$a.push(t.kh(i.innerText));break;case"TripletFeel":switch(i.innerText){case"NoTripletFeel":s.tripletFeel=K.NoTripletFeel;break;case"Triplet8th":s.tripletFeel=K.Triplet8th;break;case"Triplet16th":s.tripletFeel=K.Triplet16th;break;case"Dotted8th":s.tripletFeel=K.Dotted8th;break;case"Dotted16th":s.tripletFeel=K.Dotted16th;break;case"Scottish8th":s.tripletFeel=K.Scottish8th;break;case"Scottish16th":s.tripletFeel=K.Scottish16th}break;case"Key":const a=t.yh(i.findChildElement("AccidentalCount")?.innerText,0),h=i.findChildElement("Mode");let o=z.Major;if(h)switch(h.innerText.toLowerCase()){case"major":o=z.Major;break;case"minor":o=z.Minor}this.da.set(this.Ha.length,[a,o]);break;case"Fermatas":this.so(s,i);break;case"XProperties":this.no(s,i);break;case"Directions":this.ro(s,i)}this.Ha.push(s)}ro(t,e){for(const s of e.childElements())switch(s.localName){case"Target":switch(s.innerText){case"Coda":t.addDirection(ys.TargetCoda);break;case"DoubleCoda":t.addDirection(ys.TargetDoubleCoda);break;case"Segno":t.addDirection(ys.TargetSegno);break;case"SegnoSegno":t.addDirection(ys.TargetSegnoSegno);break;case"Fine":t.addDirection(ys.TargetFine)}break;case"Jump":switch(s.innerText){case"DaCapo":t.addDirection(ys.JumpDaCapo);break;case"DaCapoAlCoda":t.addDirection(ys.JumpDaCapoAlCoda);break;case"DaCapoAlDoubleCoda":t.addDirection(ys.JumpDaCapoAlDoubleCoda);break;case"DaCapoAlFine":t.addDirection(ys.JumpDaCapoAlFine);break;case"DaSegno":t.addDirection(ys.JumpDalSegno);break;case"DaSegnoAlCoda":t.addDirection(ys.JumpDalSegnoAlCoda);break;case"DaSegnoAlDoubleCoda":t.addDirection(ys.JumpDalSegnoAlDoubleCoda);break;case"DaSegnoAlFine":t.addDirection(ys.JumpDalSegnoAlFine);break;case"DaSegnoSegno":t.addDirection(ys.JumpDalSegnoSegno);break;case"DaSegnoSegnoAlCoda":t.addDirection(ys.JumpDalSegnoSegnoAlCoda);break;case"DaSegnoSegnoAlDoubleCoda":t.addDirection(ys.JumpDalSegnoSegnoAlDoubleCoda);break;case"DaSegnoSegnoAlFine":t.addDirection(ys.JumpDalSegnoSegnoAlFine);break;case"DaCoda":t.addDirection(ys.JumpDaCoda);break;case"DaDoubleCoda":t.addDirection(ys.JumpDaDoubleCoda)}}}so(t,e){for(const s of e.childElements())if("Fermata"===s.localName)this.ao(t,s)}ao(e,s){let i=0;const n=new _e;for(const e of s.childElements())switch(e.localName){case"Type":switch(e.innerText){case"Short":n.type=Be.Short;break;case"Medium":n.type=Be.Medium;break;case"Long":n.type=Be.Long}break;case"Length":n.length=t.Sh(e.innerText,0);break;case"Offset":const s=e.innerText.split("/");2===s.length&&(i=t.yh(s[0],4)/t.yh(s[1],4)*c.QuarterTime|0)}e.addFermata(i,n)}fh(t){for(const e of t.childElements())if("Bar"===e.localName)this.ho(e)}ho(e){const s=new Y,i=e.getAttribute("id");for(const n of e.childElements())switch(n.localName){case"Voices":this.za.set(i,t.kh(n.innerText));break;case"Clef":switch(n.innerText){case"Neutral":s.clef=G.Neutral;break;case"G2":s.clef=G.G2;break;case"F4":s.clef=G.F4;break;case"C4":s.clef=G.C4;break;case"C3":s.clef=G.C3}break;case"Ottavia":switch(n.innerText){case"8va":s.clefOttava=x.T;break;case"15ma":s.clefOttava=x._;break;case"8vb":s.clefOttava=x.M;break;case"15mb":s.clefOttava=x.L}break;case"SimileMark":switch(n.innerText){case"Simple":s.simileMark=H.Simple;break;case"FirstOfDouble":s.simileMark=H.FirstOfDouble;break;case"SecondOfDouble":s.simileMark=H.SecondOfDouble}break;case"XProperties":this.oo(n,s)}this.Va.set(i,s)}Tr(t){for(const e of t.childElements())if("Voice"===e.localName)this.Mr(e)}Mr(e){const s=new lt,i=e.getAttribute("id");for(const s of e.childElements())if("Beats"===s.localName)this.Xa.set(i,t.kh(s.innerText));this.Ua.set(i,s)}ph(t){for(const e of t.childElements())if("Beat"===e.localName)this.co(e)}co(e){const s=new Xt,i=e.getAttribute("id");for(const n of e.childElements())switch(n.localName){case"Notes":this.Ka.set(i,t.kh(n.innerText));break;case"Rhythm":this.ja.set(i,n.getAttribute("ref"));break;case"Fadding":switch(n.innerText){case"FadeIn":s.fade=Rt.FadeIn;break;case"FadeOut":s.fade=Rt.FadeOut;break;case"VolumeSwell":s.fade=Rt.VolumeSwell}break;case"Tremolo":const e=new $t;switch(s.tremoloPicking=e,n.innerText){case"1/2":e.marks=1;break;case"1/4":e.marks=2;break;case"1/8":e.marks=3}break;case"Chord":s.chordId=n.innerText;break;case"Hairpin":switch(n.innerText){case"Crescendo":s.crescendo=g.Crescendo;break;case"Decrescendo":s.crescendo=g.Decrescendo}break;case"Arpeggio":"Up"===n.innerText?s.brushType=m.ArpeggioUp:s.brushType=m.ArpeggioDown;break;case"Properties":this.lo(n,s);break;case"XProperties":this.uo(n,s);break;case"FreeText":s.text=n.innerText;break;case"TransposedPitchStemOrientation":switch(n.innerText){case"Upward":s.preferredBeamDirection=Fe.Up;break;case"Downward":s.preferredBeamDirection=Fe.Down}break;case"Dynamic":switch(n.innerText){case"PPP":s.dynamics=o.PPP;break;case"PP":s.dynamics=o.PP;break;case"P":s.dynamics=o.P;break;case"MP":s.dynamics=o.MP;break;case"MF":s.dynamics=o.MF;break;case"F":s.dynamics=o.F;break;case"FF":s.dynamics=o.FF;break;case"FFF":s.dynamics=o.FFF}break;case"GraceNotes":switch(n.innerText){case"OnBeat":s.graceType=y.OnBeat;break;case"BeforeBeat":s.graceType=y.BeforeBeat}break;case"Legato":"true"===n.getAttribute("origin")&&(s.isLegatoOrigin=!0);break;case"Whammy":const r=new f(0,0);r.value=this.do(t.Sh(n.getAttribute("originValue"),0)),r.offset=this.fo(t.Sh(n.getAttribute("originOffset"),0)),s.addWhammyBarPoint(r);const a=new f(0,0);a.value=this.do(t.Sh(n.getAttribute("middleValue"),0)),a.offset=this.fo(t.Sh(n.getAttribute("middleOffset1"),0)),s.addWhammyBarPoint(a);const h=new f(0,0);h.value=this.do(t.Sh(n.getAttribute("middleValue"),0)),h.offset=this.fo(t.Sh(n.getAttribute("middleOffset2"),0)),s.addWhammyBarPoint(h);const c=new f(0,0);c.value=this.do(t.Sh(n.getAttribute("destinationValue"),0)),c.offset=this.fo(t.Sh(n.getAttribute("destinationOffset"),0)),s.addWhammyBarPoint(c);break;case"Ottavia":switch(n.innerText){case"8va":s.ottava=x.T;break;case"8vb":s.ottava=x.M;break;case"15ma":s.ottava=x._;break;case"15mb":s.ottava=x.L}break;case"Lyrics":s.lyrics=this.po(n),this.ih=!0;break;case"Slashed":s.slashed=!0;break;case"DeadSlapped":s.deadSlapped=!0;break;case"Golpe":switch(n.innerText){case"Finger":s.golpe=Wt.Finger;break;case"Thumb":s.golpe=Wt.Thumb}break;case"Wah":switch(n.innerText){case"Open":s.wahPedal=Ot.Open;break;case"Closed":s.wahPedal=Ot.Closed}break;case"UserTransposedPitchStemOrientation":switch(n.innerText){case"Downward":s.preferredBeamDirection=Fe.Down;break;case"Upward":s.preferredBeamDirection=Fe.Up}break;case"Timer":s.showTimer=!0,s.timer=t.yh(n.innerText,-1),s.timer<0&&(s.timer=null)}this.Ja.set(i,s)}po(t){const e=[];for(const s of t.childElements())if("Line"===s.localName)e.push(s.innerText);return e}uo(e,s){for(const i of e.childElements())if("XProperty"===i.localName){let e=0;switch(i.getAttribute("id")){case"1124204546":switch(e=t.yh(i.findChildElement("Int")?.innerText,0),e){case 1:s.beamingMode=Vt.ForceMergeWithNext;break;case 2:s.beamingMode=Vt.ForceSplitToNext}break;case"1124204552":if(e=t.yh(i.findChildElement("Int")?.innerText,0),1===e)s.beamingMode!==Vt.ForceSplitToNext&&(s.beamingMode=Vt.ForceSplitOnSecondaryToNext);break;case"1124204545":e=t.yh(i.findChildElement("Int")?.innerText,0),s.invertBeamDirection=1===e;break;case"687935489":e=t.yh(i.findChildElement("Int")?.innerText,0),s.brushDuration=e}}}oo(e,s){for(const i of e.childElements())if("XProperty"===i.localName)if("1124139520"===i.getAttribute("id")){const e=i.findChildElement("Double")??i.findChildElement("Float");s.displayScale=t.Sh(e?.innerText,1)}}no(e,s){let i,n=NaN;for(const r of s.childElements())if("XProperty"===r.localName){const s=r.getAttribute("id");switch(s){case"1124073984":e.displayScale=t.Sh(r.findChildElement("Double")?.innerText,1);break;case"1124139010":n=t.yh(r.findChildElement("Int")?.innerText,NaN);break;default:const a=t.yh(s,0);if(a>=1124139264&&a<=1124139295){const e=a-1124139264,s=t.yh(r.findChildElement("Int")?.innerText,NaN);for(void 0===i&&(i=[]);i.length<e+1;)i.push(0);i[e]=s}}}if(!Number.isNaN(n)&&i){const t=new Q;t.groups.set(n,i),e.beamingRules=t}}lo(e,s){let i=!1,n=null,r=null,a=null,h=null,o=null;for(const c of e.childElements())if("Property"===c.localName)switch(c.getAttribute("name")){case"Brush":"Up"===c.findChildElement("Direction")?.innerText?s.brushType=m.BrushUp:s.brushType=m.BrushDown;break;case"PickStroke":"Up"===c.findChildElement("Direction")?.innerText?s.pickStroke=_t.Up:s.pickStroke=_t.Down;break;case"Slapped":c.findChildElement("Enable")&&(s.slap=!0);break;case"Popped":c.findChildElement("Enable")&&(s.pop=!0);break;case"VibratoWTremBar":switch(c.findChildElement("Strength")?.innerText){case"Wide":s.vibrato=P.Wide;break;case"Slight":s.vibrato=P.Slight}break;case"WhammyBar":i=!0;break;case"WhammyBarExtend":break;case"WhammyBarOriginValue":n||(n=new f(0,0)),n.value=this.do(t.Sh(c.findChildElement("Float")?.innerText,0));break;case"WhammyBarOriginOffset":n||(n=new f(0,0)),n.offset=this.fo(t.Sh(c.findChildElement("Float")?.innerText,0));break;case"WhammyBarMiddleValue":r=this.do(t.Sh(c.findChildElement("Float")?.innerText,0));break;case"WhammyBarMiddleOffset1":a=this.fo(t.Sh(c.findChildElement("Float")?.innerText,0));break;case"WhammyBarMiddleOffset2":h=this.fo(t.Sh(c.findChildElement("Float")?.innerText,0));break;case"WhammyBarDestinationValue":o||(o=new f(f.MaxPosition,0)),o.value=this.do(t.Sh(c.findChildElement("Float")?.innerText,0));break;case"WhammyBarDestinationOffset":o||(o=new f(0,0)),o.offset=this.fo(t.Sh(c.findChildElement("Float")?.innerText,0));break;case"BarreFret":s.barreFret=t.yh(c.findChildElement("Fret")?.innerText,0);break;case"BarreString":switch(c.findChildElement("String")?.innerText){case"0":s.barreShape=It.Full;break;case"1":s.barreShape=It.Half}break;case"Rasgueado":switch(c.findChildElement("Rasgueado")?.innerText){case"ii_1":s.rasgueado=Gt.Ii;break;case"mi_1":s.rasgueado=Gt.Mi;break;case"mii_1":s.rasgueado=Gt.MiiTriplet;break;case"mii_2":s.rasgueado=Gt.MiiAnapaest;break;case"pmp_1":s.rasgueado=Gt.PmpTriplet;break;case"pmp_2":s.rasgueado=Gt.PmpAnapaest;break;case"pei_1":s.rasgueado=Gt.PeiTriplet;break;case"pei_2":s.rasgueado=Gt.PeiAnapaest;break;case"pai_1":s.rasgueado=Gt.PaiTriplet;break;case"pai_2":s.rasgueado=Gt.PaiAnapaest;break;case"ami_1":s.rasgueado=Gt.AmiTriplet;break;case"ami_2":s.rasgueado=Gt.AmiAnapaest;break;case"ppp_1":s.rasgueado=Gt.Ppp;break;case"amii_1":s.rasgueado=Gt.Amii;break;case"amip_1":s.rasgueado=Gt.Amip;break;case"eami_1":s.rasgueado=Gt.Eami;break;case"eamii_1":s.rasgueado=Gt.Eamii;break;case"peami_1":s.rasgueado=Gt.Peami}}i&&(n||(n=new f(0,0)),o||(o=new f(f.MaxPosition,0)),s.addWhammyBarPoint(n),a&&r&&s.addWhammyBarPoint(new f(a,r)),h&&r&&s.addWhammyBarPoint(new f(h,r)),a||h||!r||s.addWhammyBarPoint(new f(f.MaxPosition/2|0,r)),s.addWhammyBarPoint(o))}bh(t){for(const e of t.childElements())if("Note"===e.localName)this.bo(e)}bo(e){const s=new At,i=e.getAttribute("id");for(const n of e.childElements())switch(n.localName){case"Properties":this.mo(n,s,i);break;case"AntiAccent":"normal"===n.innerText.toLowerCase()&&(s.isGhost=!0);break;case"LetRing":s.isLetRing=!0;break;case"Trill":s.trillValue=t.yh(n.innerText,-1),s.trillSpeed=w.Sixteenth;break;case"Accent":const e=t.yh(n.innerText,0);1&e&&(s.isStaccato=!0),4&e&&(s.accentuated=k.Heavy),8&e&&(s.accentuated=k.Normal),16&e&&(s.accentuated=k.Tenuto);break;case"Tie":"true"===n.getAttribute("destination").toLowerCase()&&(s.isTieDestination=!0);break;case"Vibrato":switch(n.innerText){case"Slight":s.vibrato=P.Slight;break;case"Wide":s.vibrato=P.Wide}break;case"LeftFingering":switch(n.innerText){case"P":s.leftHandFinger=S.Thumb;break;case"I":s.leftHandFinger=S.IndexFinger;break;case"M":s.leftHandFinger=S.MiddleFinger;break;case"A":s.leftHandFinger=S.AnnularFinger;break;case"C":s.leftHandFinger=S.LittleFinger}break;case"RightFingering":switch(n.innerText){case"P":s.rightHandFinger=S.Thumb;break;case"I":s.rightHandFinger=S.IndexFinger;break;case"M":s.rightHandFinger=S.MiddleFinger;break;case"A":s.rightHandFinger=S.AnnularFinger;break;case"C":s.rightHandFinger=S.LittleFinger}break;case"InstrumentArticulation":s.percussionArticulation=t.yh(n.innerText,0);break;case"Ornament":switch(n.innerText){case"Turn":s.ornament=Pt.Turn;break;case"InvertedTurn":s.ornament=Pt.InvertedTurn;break;case"UpperMordent":s.ornament=Pt.UpperMordent;break;case"LowerMordent":s.ornament=Pt.LowerMordent}}this.Ya.set(i,s)}mo(e,s,i){let n=!1,r=null,a=null,h=null,o=null,c=null,l=-1,u=-1,d=!1;for(const p of e.childElements())if("Property"===p.localName)switch(p.getAttribute("name")){case"ShowStringNumber":p.findChildElement("Enable")&&(s.showStringNumber=!0);break;case"String":s.string=t.yh(p.findChildElement("String")?.innerText,0)+1;break;case"Fret":s.fret=t.yh(p.findChildElement("Fret")?.innerText,0);break;case"Element":l=t.yh(p.findChildElement("Element")?.innerText,0);break;case"Variation":u=t.yh(p.findChildElement("Variation")?.innerText,0);break;case"Tapped":this.Qa.set(i,!0);break;case"HarmonicType":const e=p.findChildElement("HType");if(e)switch(e.innerText.toLowerCase()){case"noharmonic":s.harmonicType=B.None;break;case"natural":s.harmonicType=B.Natural;break;case"artificial":s.harmonicType=B.Artificial;break;case"pinch":s.harmonicType=B.Pinch;break;case"tap":s.harmonicType=B.Tap;break;case"semi":s.harmonicType=B.Semi;break;case"feedback":s.harmonicType=B.Feedback}break;case"HarmonicFret":const b=p.findChildElement("HFret");b&&(s.harmonicValue=t.Sh(b.innerText,0));break;case"Muted":p.findChildElement("Enable")&&(s.isDead=!0);break;case"PalmMuted":p.findChildElement("Enable")&&(s.isPalmMute=!0);break;case"Octave":s.octave=t.yh(p.findChildElement("Number")?.innerText,0),-1===s.tone&&(s.tone=0);break;case"Tone":s.tone=t.yh(p.findChildElement("Step")?.innerText,0);break;case"ConcertPitch":d||this.wo(p,s);break;case"TransposedPitch":s.accidentalMode=_.Default,this.wo(p,s),d=!0;break;case"Bended":n=!0;break;case"BendOriginValue":r||(r=new f(0,0)),r.value=this.do(t.Sh(p.findChildElement("Float")?.innerText,0));break;case"BendOriginOffset":r||(r=new f(0,0)),r.offset=this.fo(t.Sh(p.findChildElement("Float")?.innerText,0));break;case"BendMiddleValue":a=this.do(t.Sh(p.findChildElement("Float")?.innerText,0));break;case"BendMiddleOffset1":h=this.fo(t.Sh(p.findChildElement("Float")?.innerText,0));break;case"BendMiddleOffset2":o=this.fo(t.Sh(p.findChildElement("Float")?.innerText,0));break;case"BendDestinationValue":c||(c=new f(f.MaxPosition,0)),c.value=this.do(t.Sh(p.findChildElement("Float")?.innerText,0));break;case"BendDestinationOffset":c||(c=new f(0,0)),c.offset=this.fo(t.Sh(p.findChildElement("Float")?.innerText,0));break;case"HopoOrigin":p.findChildElement("Enable")&&(s.isHammerPullOrigin=!0);break;case"HopoDestination":break;case"LeftHandTapped":s.isLeftHandTapped=!0;break;case"Slide":const m=t.yh(p.findChildElement("Flags")?.innerText,0);1&m?s.slideOutType=M.Shift:2&m?s.slideOutType=M.Legato:4&m?s.slideOutType=M.OutDown:8&m&&(s.slideOutType=M.OutUp),16&m?s.slideInType=T.IntoFromBelow:32&m&&(s.slideInType=T.IntoFromAbove),64&m?s.slideOutType=M.PickSlideDown:128&m&&(s.slideOutType=M.PickSlideUp)}n&&(r||(r=new f(0,0)),c||(c=new f(f.MaxPosition,0)),s.addBendPoint(r),h&&a&&s.addBendPoint(new f(h,a)),o&&a&&s.addBendPoint(new f(o,a)),h||o||!a||s.addBendPoint(new f(f.MaxPosition/2|0,a)),s.addBendPoint(c)),-1!==l&&-1!==u&&(s.percussionArticulation=Nt.articulationFromElementVariation(l,u))}wo(t,e){const s=t.findChildElement("Pitch");if(s)for(const t of s.childElements())if("Accidental"===t.localName)switch(t.innerText){case"":e.accidentalMode=_.ForceNatural;break;case"x":e.accidentalMode=_.ForceDoubleSharp;break;case"#":e.accidentalMode=_.ForceSharp;break;case"b":e.accidentalMode=_.ForceFlat;break;case"bb":e.accidentalMode=_.ForceDoubleFlat}}do(e){return e*t.Aa|0}fo(e){return e*t.Fa}mh(t){for(const e of t.childElements())if("Rhythm"===e.localName)this.yo(e)}yo(e){const s=new Ms,i=e.getAttribute("id");s.id=i;for(const i of e.childElements())switch(i.localName){case"NoteValue":switch(i.innerText){case"Long":s.value=w.QuadrupleWhole;break;case"DoubleWhole":s.value=w.DoubleWhole;break;case"Whole":s.value=w.Whole;break;case"Half":s.value=w.Half;break;case"Quarter":s.value=w.Quarter;break;case"Eighth":s.value=w.Eighth;break;case"16th":s.value=w.Sixteenth;break;case"32nd":s.value=w.ThirtySecond;break;case"64th":s.value=w.SixtyFourth;break;case"128th":s.value=w.OneHundredTwentyEighth;break;case"256th":s.value=w.TwoHundredFiftySixth}break;case"PrimaryTuplet":s.tupletNumerator=t.yh(i.getAttribute("num"),-1),s.tupletDenominator=t.yh(i.getAttribute("den"),-1);break;case"AugmentationDot":s.dots=t.yh(i.getAttribute("count"),0)}this.qa.set(i,s)}rh(){for(let t=0,e=this.Ha.length;t<e;t++){const e=this.Ha[t];this.score.addMasterBar(e)}const e=this.Ha[this.Ha.length-1];this.la.has(e)&&(this.la.delete(e),e.isDoubleBar=!1);const s=[];for(const t of this.Ia){if(!t)continue;const e=this.Ga.get(t);this.score.addTrack(e),s.push(t)}let i;for(const e of this.$a){let n=0,r=0;i=[V.C,z.Major],this.Kh.has(s[0])&&(i=[Bt.transposeKey(i[0],this.Kh.get(s[0])),i[1]]);for(let a=0;a<e.length&&r<this.score.tracks.length;a++){const h=e[a];if(h!==t.Ea){const e=this.Va.get(h),a=this.score.tracks[r],o=a.staves[n];o.addBar(e);const c=o.bars.length-1;if(this.da.has(c)&&(i=this.da.get(c),this.Kh.has(s[r])&&(i=[Bt.transposeKey(i[0],this.Kh.get(s[r])),i[1]])),e.keySignature=i[0],e.keySignatureType=i[1],this.la.has(e.masterBar)&&(e.barLineRight=q.LightLight),this.za.has(h))for(const s of this.za.get(h))if(s!==t.Ea){const i=this.Ua.get(s);if(e.addVoice(i),this.Xa.has(s))for(const e of this.Xa.get(s))if(e!==t.Ea){const s=Qt.clone(this.Ja.get(e));i.addBeat(s);const n=this.ja.get(e),r=this.qa.get(n);if(s.duration=r.value,s.dots=r.dots,s.tupletNumerator=r.tupletNumerator,s.tupletDenominator=r.tupletDenominator,this.Ka.has(e))for(const i of this.Ka.get(e))if(i!==t.Ea){const t=Jt.clone(this.Ya.get(i));o.isPercussion?(t.fret=-1,t.string=-1):t.percussionArticulation=-1,s.addNote(t),this.Qa.has(i)&&(s.tap=!0)}}}else{const t=new lt;e.addVoice(t);const s=new Xt;s.isEmpty=!0,s.duration=w.Quarter,t.addBeat(s)}n===a.staves.length-1?(r++,n=0):n++,i=[V.C,z.Major],r<s.length&&this.Kh.has(s[r])&&(i=[Bt.transposeKey(i[0],this.Kh.get(s[r])),i[1]])}else r++}}for(const t of this.Ia){if(!t)continue;const e=this.Ga.get(t);let s=!1;for(const t of e.staves)if(t.isPercussion){s=!0;break}if(s||(e.percussionArticulations=[]),this.Ra.has(t)){const s=this.Ra.get(t);for(const[t,i]of s)if(e.staves.length>0&&t<e.staves[0].bars.length){const s=e.staves[0].bars[t];if(s.voices.length>0&&s.voices[0].beats.length>0){const t=s.voices[0].beats[0];for(const e of i)e.type===l.Bank&&0===e.value&&0===s.index||t.automations.push(e)}}}if(this.Oa.has(t)){const s=this.Oa.get(t);for(const[t,i]of s)if(e.staves.length>0&&t<e.staves[0].bars.length){e.staves[0].bars[t].sustainPedals=i}}}for(const[t,e]of this.Wa){if(t<0||t>=this.score.masterBars.length)continue;const s=this.score.masterBars[t];for(let t=0,i=e.length;t<i;t++){const i=e[t];switch(i.type){case l.Tempo:s.tempoAutomations.push(i);break;case l.SyncPoint:i.syncPointValue.millisecondOffset-=this.nh,s.addSyncPoint(i)}}}}},Ps=class{isMultiRest=!1;trackViewGroups=[]},Cs=class{showNumbered=!1;showSlash=!1;showStandardNotation=!1;showTablature=!1},Es=class{scoreViews=[];apply(t){if(this.scoreViews.length>0){let e=0;t.stylesheet.multiTrackMultiBarRest=this.scoreViews[0].isMultiRest;for(const s of this.scoreViews[0].trackViewGroups){if(e<t.tracks.length){const i=t.tracks[e];for(const t of i.staves)t.isPercussion||(t.showTablature=s.showTablature),t.showStandardNotation=s.showStandardNotation,t.showSlash=s.showSlash,t.showNumbered=s.showNumbered}e++}for(let s=1;s<this.scoreViews.length;s++)this.scoreViews[s].isMultiRest&&(t.stylesheet.perTrackMultiBarRest||(t.stylesheet.perTrackMultiBarRest=new Set),e=s-1,t.stylesheet.perTrackMultiBarRest.add(e))}}constructor(t){const e=Ie.fromBuffer(t),s=le.readInt32BE(e);for(let t=0;t<s;t++){const t=new Ps;this.scoreViews.push(t),t.isMultiRest=Ss.gpReadBool(e);const s=le.readInt32BE(e);for(let i=0;i<s;i++){let s=e.readByte();0===s&&(s=1);const i=new Cs;i.showStandardNotation=!!(1&s),i.showTablature=!!(2&s),i.showSlash=!!(4&s),i.showNumbered=!!(8&s),t.trackViewGroups.push(i)}}}static writeForScore(t){const e=Ie.withCapacity(128),s=[new Ps];s[0].isMultiRest=t.stylesheet.multiTrackMultiBarRest;for(const e of t.tracks){const i=new Cs;i.showStandardNotation=e.staves[0].showStandardNotation,i.showTablature=e.staves[0].showTablature,i.showSlash=e.staves[0].showSlash,i.showNumbered=e.staves[0].showNumbered,s[0].trackViewGroups.push(i);const n=new Ps;n.isMultiRest=!0===t.stylesheet.perTrackMultiBarRest?.has(e.index),n.trackViewGroups.push(i),s.push(n)}le.writeInt32BE(e,s.length);for(const t of s){e.writeByte(t.isMultiRest?1:0),le.writeInt32BE(e,t.trackViewGroups.length);for(const s of t.trackViewGroups){let t=0;s.showStandardNotation&&(t|=1),s.showTablature&&(t|=2),s.showSlash&&(t|=4),s.showNumbered&&(t|=8),e.writeByte(t)}}return le.writeInt32BE(e,1),e.toArray()}},Fs=class{trackViewGroups=[]},As=class{isVisible=!1},Ds=class{zoomLevel=4;view=0;muiltiVoiceCursor=!1;scoreViews=[];constructor(t,e){const s=Ie.fromBuffer(e);this.zoomLevel=le.readInt32BE(s),this.view=s.readByte(),this.muiltiVoiceCursor=0!==s.readByte();const i=t.scoreViews.length;for(let e=0;e<i;e++){const i=new Fs;this.scoreViews.push(i);const n=t.scoreViews[e];for(let t=0;t<n.trackViewGroups.length;t++){const t=new As;t.isVisible=0!==s.readByte(),i.trackViewGroups.push(t)}}}apply(t){if(this.scoreViews.length>0){let e=0;for(const s of this.scoreViews[0].trackViewGroups){if(e<t.tracks.length){t.tracks[e].isVisibleOnMultiTrack=s.isVisible}e++}}}static writeForScore(t){const e=Ie.withCapacity(128);le.writeInt32BE(e,4),e.writeByte(0);const s=t.tracks.length>0&&t.tracks[0].staves[0].bars[0].isMultiVoice;e.writeByte(s?255:0);for(const s of t.tracks)e.writeByte(s.isVisibleOnMultiTrack?255:0);for(const s of t.tracks)e.writeByte(255);return e.toArray()}},Ls=class extends Re{get name(){return"Guitar Pro 7-8"}readScore(){O.debug(this.name,"Loading ZIP entries");const t=new Ke(this.data,this.settings.importer.maxDecodingBufferSize);let e;try{e=t.read()}catch(t){throw new Oe("No Zip archive",t)}O.debug(this.name,"Zip entries loaded");let s=null,i=null,n=null,r=null;const a=new Map;for(const t of e)switch(a.set(t.fullName,t),t.fileName){case"score.gpif":s=le.toString(t.data,this.settings.importer.encoding);break;case"BinaryStylesheet":i=t.data;break;case"PartConfiguration":n=t.data;break;case"LayoutConfiguration":r=t.data}if(!s)throw new Oe("No score.gpif found in zip archive");O.debug(this.name,"Start Parsing score.gpif");const h=new Ns;h.loadAsset=t=>{if(a.has(t))return a.get(t).data},h.parseXml(s,this.settings),O.debug(this.name,"score.gpif parsed");const o=h.score;i&&(O.debug(this.name,"Start Parsing BinaryStylesheet"),new xs(i,this.settings.importer.maxDecodingBufferSize).apply(o),O.debug(this.name,"BinaryStylesheet parsed"));let c=null;return n&&(O.debug(this.name,"Start Parsing Part Configuration"),c=new Es(n),c.apply(o),O.debug(this.name,"Part Configuration parsed")),r&&null!=c&&(O.debug(this.name,"Start Parsing Layout Configuration"),new Ds(c,r).apply(o),O.debug(this.name,"Layout Configuration parsed")),o}},Ws=class t{static ko=8;So=0;Bo=t.ko;_o;constructor(t){this._o=t}readByte(){return this.readBits(8)}readBytes(t){const e=new Uint8Array(t);for(let s=0;s<t;s++)e[s]=255&this.readByte();return e}readBits(t){let e=0,s=t-1;for(;s>=0;)e|=this.readBit()<<s,s--;return e}readBitsReversed(t){let e=0;for(let s=0;s<t;s++)e|=this.readBit()<<s;return e}readBit(){if(this.Bo>=8){if(this.So=this._o.readByte(),-1===this.So)throw new De;this.Bo=0}const e=this.So>>t.ko-this.Bo-1&1;return this.Bo++,e}readAll(){const t=Ie.empty();try{for(;;)t.writeByte(255&this.readByte())}catch(t){if(!(t instanceof De))throw t}return t.toArray()}},Rs=class{fileName="";fileSize=0;data=null},Os=class{static HeaderBcFs="BCFS";static HeaderBcFz="BCFZ";fileFilter;files=[];constructor(){this.files=[],this.fileFilter=t=>!0}load(t){const e=new Ws(t);this.xo(e)}readHeader(t){return this.To(t.readBytes(4),0,4)}decompress(t,e=!1){const s=Ie.empty();let i;const n=this.Mo(t.readBytes(4),0);try{for(;s.length<n;)if(1===t.readBits(1)){const e=t.readBits(4),n=t.readBitsReversed(e),r=t.readBitsReversed(e),a=s.length-n,h=Math.min(n,r);i=s.getBuffer(),s.write(i,a,h)}else{const e=t.readBitsReversed(2);for(let i=0;i<e;i++)s.writeByte(t.readByte())}}catch(t){if(!(t instanceof De))throw t}i=s.getBuffer();const r=e?4:0,a=s.length-r,h=new Uint8Array(a),o=a;return h.set(i.subarray(r,r+o),0),h}xo(t){const e=this.readHeader(t);if("BCFZ"===e)this.vo(this.decompress(t,!0));else{if("BCFS"!==e)throw new Oe("Unsupported format");this.vo(t.readAll())}}vo(t){const e=4096;let s=e;for(;s+3<t.length;){if(2===this.Mo(t,s)){const i=new Rs;i.fileName=this.To(t,s+4,127),i.fileSize=this.Mo(t,s+140);const n=!this.fileFilter||this.fileFilter(i.fileName);n&&this.files.push(i);const r=s+148;let a=0,h=0;const o=n?Ie.withCapacity(i.fileSize):null;for(;a=this.Mo(t,r+4*h++),0!==a;)s=a*e,n&&o.write(t,s,e);if(n){i.data=new Uint8Array(Math.min(i.fileSize,o.length));const t=o.toArray();i.data.set(t.subarray(0,0+i.data.length),0)}}s+=e}}To(t,e,s){let i="";for(let n=0;n<s;n++){const s=255&t[e+n];if(0===s)break;i+=String.fromCharCode(s)}return i}Mo(t,e){return t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e]}},Is=class extends Re{get name(){return"Guitar Pro 6"}readScore(){O.debug(this.name,"Loading GPX filesystem");const t=new Os;t.fileFilter=t=>t.endsWith("score.gpif")||t.endsWith("BinaryStylesheet")||t.endsWith("PartConfiguration")||t.endsWith("LayoutConfiguration"),t.load(this.data),O.debug(this.name,"GPX filesystem loaded");let e=null,s=null,i=null,n=null;for(const r of t.files)switch(r.fileName){case"score.gpif":e=le.toString(r.data,this.settings.importer.encoding);break;case"BinaryStylesheet":s=r.data;break;case"PartConfiguration":i=r.data;break;case"LayoutConfiguration":n=r.data}if(!e)throw new Oe("No score.gpif found in GPX");O.debug(this.name,"Start Parsing score.gpif");const r=new Ns;r.parseXml(e,this.settings),O.debug(this.name,"score.gpif parsed");const a=r.score;s&&(O.debug(this.name,"Start Parsing BinaryStylesheet"),new xs(s,this.settings.importer.maxDecodingBufferSize).apply(a),O.debug(this.name,"BinaryStylesheet parsed"));let h=null;return i&&(O.debug(this.name,"Start Parsing Part Configuration"),h=new Es(i),h.apply(a),O.debug(this.name,"Part Configuration parsed")),n&&null!=h&&(O.debug(this.name,"Start Parsing Layout Configuration"),new Ds(h,n).apply(a),O.debug(this.name,"Layout Configuration parsed")),a}},Gs=class{maxSteps=-1e3;maxStepsNote=null;minSteps=-1e3;minStepsNote=null},Hs=class t{Oe;No;static Po=7;static Co=[38,32,30,26,38];static Eo=[0,1,2,3,4,5,6];Fo=new Map;Ao=new Map;Do=new Map;Lo=new Map;Wo=new Map;maxStepsBeat=null;minStepsBeat=null;maxSteps=-1e3;minSteps=-1e3;constructor(t){this.No=t,this.Oe=t.bar}static getPercussionSteps(t){return Nt.getArticulation(t)?.staffLine??0}static getNoteValue(t){return t.displayValue}applyAccidental(e){const s=t.getNoteValue(e),i=e.hasQuarterToneOffset;return this.Ro(s,i,e.beat,!1,e)}applyAccidentalForValue(t,e,s,i){return this.Ro(e,s,t,i,null)}static computeStepsWithoutAccidentals(e,s){let i=0;const n=t.getNoteValue(s);if(s.isPercussion)i=t.getPercussionSteps(s);else{const r=Bt.resolveSpelling(e.keySignature,n,s.accidentalMode);i=t.calculateNoteSteps(e.clef,r)}return i}Ro(e,s,i,n,r=null){let a=0,h=I.None;if(null!=r&&r.isPercussion)a=t.getPercussionSteps(r);else{const i=r?r.accidentalMode:_.Default,n=Bt.resolveSpelling(this.Oe.keySignature,e,i);a=t.calculateNoteSteps(this.Oe.clef,n);const o=this.Fo.has(a)?this.Fo.get(a):null;h=Bt.computeAccidentalForSpelling(this.Oe.keySignature,i,n,s,o);let c=!1;switch(h){case I.NaturalQuarterNoteUp:case I.SharpQuarterNoteUp:case I.FlatQuarterNoteUp:break;default:if(r&&r.isTieDestination&&0===r.beat.index){const t=this.No.scoreRenderer.layout?.getRendererForBar(this.No.staff.staffId,r.tieOrigin.beat.voice.bar);t&&t.staff===this.No.staff&&t.accidentalHelper.getNoteSteps(r.tieOrigin)===a&&(c=!0)}c&&(h=I.None)}s||h===I.None||this.Fo.set(a,n.accidentalOffset)}return r?(this.Ao.set(r.id,a),this.Lo.set(e,r)):this.Do.set(e,a),(-1e3===this.minSteps||this.minSteps<a)&&(this.minSteps=a,this.minStepsBeat=i),(-1e3===this.maxSteps||this.maxSteps>a)&&(this.maxSteps=a,this.maxStepsBeat=i),n||this.Oo(i,a,r),h}Oo(t,e,s){let i;this.Wo.has(t.id)?i=this.Wo.get(t.id):(i=new Gs,this.Wo.set(t.id,i)),(-1e3===i.minSteps||e<i.minSteps)&&(i.minSteps=e,i.minStepsNote=s),(-1e3===i.minSteps||e>i.maxSteps)&&(i.maxSteps=e,i.maxStepsNote=s)}getMaxSteps(t){return this.Wo.has(t.id)?this.Wo.get(t.id).maxSteps:0}getMaxStepsNote(t){return this.Wo.has(t.id)?this.Wo.get(t.id).maxStepsNote:null}getMinSteps(t){return this.Wo.has(t.id)?this.Wo.get(t.id).minSteps:0}getMinStepsNote(t){return this.Wo.has(t.id)?this.Wo.get(t.id).minStepsNote:null}static calculateNoteSteps(e,s){const i=e;let n=t.Co[i];return n-=s.octave*t.Po,n-=t.Eo[s.degree],n}getNoteSteps(t){return this.Ao.get(t.id)}getNoteStepsForValue(t,e=!1){return this.Do.has(t)?this.Do.get(t):e&&this.Lo.has(t)?this.getNoteSteps(this.Lo.get(t)):0}},$s=class{slurStarts;currentDynamics=o.F;tieStarts;tieStartIds;slideOrigins=new Map;transpose=0;isExplicitlyBeamed=!1;constructor(){this.tieStarts=new Set,this.tieStartIds=new Map,this.slideOrigins=new Map,this.slurStarts=new Map}},Vs=class extends vt{outputMidiChannel=-1;outputMidiProgram=-1;outputMidiBank=-1;outputVolume=-1;outputBalance=-1},zs=class t{track;firstArticulation;instruments=new Map;Io=new Map;Go=0;Ho=new Map;constructor(t){this.track=t}getLyricLine(t){if(this.Ho.has(t))return this.Ho.get(t);const e=this.Go;return this.Ho.set(t,e),this.Go++,e}static $o=vt.create(0,"Default",0,0,xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole);getOrCreateArticulation(e,s){const i=12*s.octave+s.tone,n=`${e}_${i}`;if(this.Io.has(n))return this.Io.get(n);let r;r=this.instruments.has(e)?this.instruments.get(e):t.$o;const a=this.track.percussionArticulations.length,h=s.beat.voice.bar;let o;if(0===i)o=4;else{const t=Bt.resolveSpelling(h.keySignature,i,_.Default);o=Hs.calculateNoteSteps(h.clef,t)}const c=o-(9-(2*s.beat.voice.bar.staff.standardNotationLineCount-1)),l=vt.create(r.id,r.elementType,c,r.outputMidiNumber,r.noteHeadDefault,r.noteHeadHalf,r.noteHeadWhole,r.techniqueSymbol,r.techniqueSymbolPlacement);return this.Io.set(n,a),this.track.percussionArticulations.push(l),a}},Us=class t extends Re{We;Vo=new Map;zo=new Map;Uo=new Map;Xo;jo;Jo=1;qo=o.F;get name(){return"MusicXML"}readScore(){const t=this.Yo(),e=new is;try{e.parse(t)}catch(t){throw new Oe("Unsupported format",t)}return this.We=new wt,this.We.stylesheet.hideDynamics=!0,this.Kn(e),Bt.consolidate(this.We),this.We.finish(this.settings),this.We.rebuildRepeatGroups(),this.We}Yo(){const t=new Ke(this.data,this.settings.importer.maxDecodingBufferSize);let e;try{e=t.read()}catch{e=[]}if(0===e.length)return this.data.reset(),le.toString(this.data.readAll(),this.settings.importer.encoding);const s=e.find(t=>"META-INF/container.xml"===t.fullName);if(!s)throw new Oe("No compressed MusicXML");const i=new is;try{i.parse(le.toString(s.data,this.settings.importer.encoding))}catch(t){throw new Oe("Malformed container.xml, could not parse as XML",t)}const n=i.firstElement;if(!n||"container"!==n.localName)throw new Oe("Malformed container.xml, root element not 'container'");const r=n.findChildElement("rootfiles");if(!r)throw new Oe("Malformed container.xml, 'container/rootfiles' not found");let a="";for(const t of r.childElements())if("rootfile"===t.localName){a=t.getAttribute("full-path");break}if(!a)throw new Oe("Unsupported compressed MusicXML, missing rootfile");const h=e.find(t=>t.fullName===a);if(!h)throw new Oe(`Malformed container.xml, '${a}' not contained in zip`);return le.toString(h.data,this.settings.importer.encoding)}Kn(t){const e=t.firstElement;if(!e)throw new Oe("Unsupported format");switch(e.localName){case"score-partwise":this.Ko(e);break;case"score-timewise":this.Qo(e);break;default:throw new Oe("Unsupported format")}}Ko(t){for(const e of t.childElements())switch(e.localName){case"credit":this.Zo(e);break;case"identification":this.tc(e);break;case"movement-title":this.ec(e);break;case"part":this.sc(e);break;case"part-list":this.nc(e);break;case"work":this.rc(e)}}Qo(t){let e=0;for(const s of t.childElements())switch(s.localName){case"credit":this.Zo(s);break;case"identification":this.tc(s);break;case"movement-title":this.ec(s);break;case"part-list":this.nc(s);break;case"work":this.rc(s);break;case"measure":this.ac(s,e),e++}}Zo(e){if("1"!==e.getAttribute("page","1"))return;const s=[];let i=null,n="";for(const t of e.childElements())switch(t.localName){case"credit-type":s.push(t.innerText);break;case"credit-words":null===i&&(i=t),n+=t.innerText}if(s.length>0)for(const e of s)switch(e){case"title":this.We.title=t.hc(n);break;case"subtitle":this.We.subTitle=t.hc(n);break;case"composer":case"arranger":this.We.artist=t.hc(n);break;case"lyricist":this.We.words=t.hc(n);break;case"rights":this.We.copyright=t.hc(n)}else if(i){const e=i.getAttribute("font-size","0"),s=i.getAttribute("font-size","top"),r=i.getAttribute("halign","left");if("top"===s){if(n.includes("copyright")||n.includes("Copyright")||n.includes("©")||n.includes("(c)")||n.includes("(C)"))return void(this.We.copyright=t.hc(n));if("center"===r||"center"===e){if(0===this.We.title.length)return void(this.We.title=t.hc(n));if(0===this.We.subTitle.length)return void(this.We.subTitle=t.hc(n));if(0===this.We.album.length)return void(this.We.album=t.hc(n))}else if(("right"===r||"right"===e)&&0===this.We.music.length)return void(this.We.music=t.hc(n));if(0===this.We.artist.length)return void(this.We.artist=t.hc(n));if(0===this.We.words.length)return void(this.We.words=t.hc(n))}}}static hc(t){return t.replaceAll("\r","").replaceAll("\n"," ").replaceAll("\t","  ").replaceAll(" "," ")}tc(e){for(const s of e.childElements())switch(s.localName){case"creator":if(s.attributes.has("type"))switch(s.attributes.get("type")){case"composer":this.We.artist=t.hc(s.innerText);break;case"lyricist":this.We.words=t.hc(s.innerText);break;case"arranger":this.We.music=t.hc(s.innerText)}else this.We.artist=t.hc(s.innerText);break;case"rights":this.We.copyright.length>0&&(this.We.copyright+=", "),this.We.copyright+=s.innerText,s.attributes.has("type")&&(this.We.copyright+=` (${s.attributes.get("type")})`);break;case"encoding":this.oc(s)}}oc(e){for(const s of e.childElements())switch(s.localName){case"encoder":this.We.tab.length>0&&(this.We.tab+=", "),this.We.tab+=s.innerText,s.attributes.has("type")&&(this.We.tab+=` (${s.attributes.get("type")})`);break;case"encoding-description":this.We.notices+=t.hc(s.innerText)}}ec(e){0===this.We.title.length?this.We.title=t.hc(e.innerText):this.We.subTitle=t.hc(e.innerText)}nc(t){for(const e of t.childElements())if("score-part"===e.localName)this.cc(e)}cc(e){const s=new Ee;s.ensureStaveCount(1),this.We.addTrack(s);const i=e.attributes.get("id"),n=new zs(s);this.Vo.set(i,n),this.zo.set(s.index,n);for(const i of e.childElements())switch(i.localName){case"part-name":s.name=t.hc(i.innerText);break;case"part-name-display":s.name=this.lc(i);break;case"part-abbreviation":s.shortName=t.hc(i.innerText);break;case"part-abbreviation-display":s.shortName=this.lc(i);break;case"score-instrument":this.uc(i,n);break;case"midi-device":i.attributes.has("port")&&(s.playbackInfo.port=Number.parseInt(i.attributes.get("port"),10));break;case"midi-instrument":this.dc(i,n)}n.firstArticulation&&(n.firstArticulation.outputMidiProgram>=0&&(s.playbackInfo.program=n.firstArticulation.outputMidiProgram),n.firstArticulation.outputMidiBank>=0&&(s.playbackInfo.bank=n.firstArticulation.outputMidiBank),n.firstArticulation.outputBalance>=0&&(s.playbackInfo.balance=n.firstArticulation.outputBalance),n.firstArticulation.outputVolume>=0&&(s.playbackInfo.volume=n.firstArticulation.outputVolume),n.firstArticulation.outputMidiChannel>=0&&(s.playbackInfo.primaryChannel=n.firstArticulation.outputMidiChannel,s.playbackInfo.secondaryChannel=n.firstArticulation.outputMidiChannel))}uc(t,e){const s=new Vs;e.firstArticulation||(e.firstArticulation=s),e.instruments.set(t.getAttribute("id",""),s)}dc(e,s){const i=e.getAttribute("id","");if(!s.instruments.has(i))return;const n=s.instruments.get(i);for(const s of e.childElements())switch(s.localName){case"midi-channel":n.outputMidiChannel=Number.parseInt(s.innerText,10)-1;break;case"midi-bank":n.outputMidiBank=Number.parseInt(s.innerText,10)-1;break;case"midi-program":n.outputMidiProgram=Number.parseInt(s.innerText,10)-1;break;case"midi-unpitched":n.outputMidiNumber=Number.parseInt(s.innerText,10)-1;break;case"volume":n.outputVolume=t.fc(Number.parseFloat(s.innerText));break;case"pan":n.outputBalance=t.bc(Number.parseFloat(s.innerText))}n.id=Nt.tryMatchKnownArticulation(n),n.id<0&&(n.id=0)}static fc(e){return 0|t.mc(0,100,0,16,e)}static bc(e){return 0|t.mc(-90,90,0,16,e)}static mc(t,e,s,i,n){return s+(i-s)*((n-t)/(e-t))}lc(e){let s="";for(const t of e.childElements())switch(t.localName){case"display-text":s+=t.innerText;break;case"accidental-text":switch(t.innerText){case"sharp":s+="♯";break;case"natural":s+="♮";break;case"flat":s+="♭";break;case"double-sharp":s+="𝄪";break;case"sharp-sharp":s+="♯♯";break;case"flat-flat":s+="𝄫";break;case"natural-sharp":s+="♮♯";break;case"natural-flat":s+="♮♭";break;case"sharp-down":s+="𝄱";break;case"sharp-up":s+="𝄰";break;case"natural-down":s+="𝄯";break;case"natural-up":s+="𝄮";break;case"flat-down":s+="𝄭";break;case"flat-up":s+="𝄬";break;case"arrow-down":s+="↓";break;case"arrow-up":s+="↑";break;case"triple-sharp":s+="♯𝄪";break;case"triple-flat":s+="𝄬𝄬𝄬";break;case"sharp-1":s+="♯¹";break;case"sharp-2":s+="♯²";break;case"sharp-3":s+="♯³";break;case"sharp-4":s+="♯⁴";break;case"sharp-5":s+="♯⁵";break;case"flat-1":s+="♭¹";break;case"flat-2":s+="♭²";break;case"flat-3":s+="♭³";break;case"flat-4":s+="♭⁴";break;case"flat-5":s+="♭⁵"}}return t.hc(s)}rc(e){for(const s of e.childElements())if("work-title"===s.localName)this.We.title=t.hc(s.innerText)}sc(t){const e=t.attributes.get("id");if(!e||!this.Vo.has(e))return;const s=this.Vo.get(e).track;let i=0;for(const e of t.childElements())if("measure"===e.localName)this.gc(e,s,i),i++;this.Xo=void 0}gc(t,e,s){const i=this.wc(t,s),n="yes"===t.attributes.get("implicit");this.yc(t,i,e,n,!0),this.jo=void 0}ac(t,e){const s=this.wc(t,e),i="yes"===t.attributes.get("implicit");for(const e of t.childElements())switch(e.localName){case"part":this.kc(e,s,i),this.Xo=void 0;break;case"print":this.Sc(e,s,void 0,!0)}this.jo=void 0}wc(t,e){const s="yes"===t.attributes.get("implicit");for(;this.We.masterBars.length<=e;){const t=new Z;s&&(t.isAnacrusis=!0),this.We.addMasterBar(t),t.index>0&&(t.timeSignatureDenominator=t.previousMasterBar.timeSignatureDenominator,t.timeSignatureNumerator=t.previousMasterBar.timeSignatureNumerator,t.tripletFeel=t.previousMasterBar.tripletFeel)}return this.We.masterBars[e]}kc(t,e,s){const i=t.attributes.get("id");if(!i||!this.Vo.has(i))return;const n=this.Vo.get(i).track;this.yc(t,e,n,s,!1)}Bc=0;_c=null;yc(t,e,s,i,n){this.Bc=0,this._c=null,e.alternateEndings=this.xc;const r=[];for(const i of t.childElements())switch(i.localName){case"note":this.bo(i,e,s);break;case"backup":this.Tc(i);break;case"forward":this.Mc(i);break;case"direction":this.vc(i,e,s);break;case"attributes":this.Nc(i,e,s);break;case"harmony":this.Pc(i,s);break;case"print":this.Sc(i,e,s,!0);break;case"sound":this.qh(i,e,s);break;case"barline":r.push(i)}for(const t of r)this.Cc(t,e,s);this.Ec(e,s);const a=this.Fc(s,0),h=this.vr(a,e);h.barNumberDisplay=i?nt.Hide:n?this.jo??this.Xo:this.Xo??this.jo,this.Ac=null}Sc(t,e,s,i){let n;void 0!==s&&("yes"===t.getAttribute("new-system","no")||"yes"===t.getAttribute("new-page","no"))&&s.addLineBreaks(e.index);for(const e of t.childElements())if("measure-numbering"===e.localName)switch(e.innerText){case"none":n=nt.Hide;break;case"measure":n=nt.AllBars;break;case"system":n=nt.FirstOfSystem}i?this.jo=n:this.Xo=n}Ec(t,e){if(null!==this.Dc){for(const s of e.staves){const e=this.vr(s,t);e.simileMark=this.Dc,e.simileMark!==H.None&&this.Lc(e)}this.Dc===H.FirstOfDouble?this.Dc=H.SecondOfDouble:this.Dc=null}if(null!==this.Wc){const s=Array.from(this.Wc.keys());for(const i of s){const s=this.Fc(e,i),n=this.vr(s,t);n.simileMark=this.Wc.get(i),n.simileMark!==H.None&&this.Lc(n),n.simileMark===H.FirstOfDouble?this.Wc.set(i,H.SecondOfDouble):this.Wc.delete(i)}0===this.Wc.size&&(this.Wc=null)}}Lc(t){for(const e of t.voices){const t=new Xt;t.isEmpty=!0,e.addBeat(t)}}Cc(t,e,s){for(const i of t.childElements())switch(i.localName){case"bar-style":this.Rc(i,e,s,t.getAttribute("location","right"));break;case"ending":this.Oc(i,e);break;case"repeat":this.Ic(i,e)}}Ic(t,e){const s=t.getAttribute("direction");let i=Number.parseInt(t.getAttribute("times"),10);(i<0||Number.isNaN(i))&&(i=2),"backward"===s?e.repeatCount=i:"forward"===s&&(e.isRepeatStart=!0)}xc=0;Oc(t,e){const s=t.getAttribute("number").split(",").map(t=>Number.parseInt(t,10));let i=0;for(const t of s)i|=1<<t-1&255;switch(e.alternateEndings=i,t.getAttribute("type","")){case"start":this.xc=this.xc|i;break;case"stop":case"discontinue":this.xc=this.xc&~i}}Rc(t,e,s,i){let n=q.Automatic;switch(t.innerText){case"dashed":n=q.Dashed;break;case"dotted":n=q.Dotted;break;case"heavy":n=q.Heavy;break;case"heavy-heavy":n=q.HeavyHeavy;break;case"heavy-light":n=q.HeavyLight;break;case"light-heavy":n=q.LightHeavy;break;case"light-light":n=q.LightLight;break;case"none":n=q.None;break;case"regular":n=q.Regular;break;case"short":n=q.Short;break;case"tick":n=q.Tick}for(const t of s.staves){const s=this.vr(t,e);switch(i){case"left":s.barLineLeft=n;break;case"right":s.barLineRight=n}}}qh(e,s,i){for(const t of e.childElements())switch(t.localName){case"midi-instrument":this.Gc(t,s);break;case"swing":this.Hc(t,s)}if(e.attributes.has("coda")&&s.addDirection(ys.TargetCoda),e.attributes.has("tocoda")&&s.addDirection(ys.JumpDaCoda),e.attributes.has("dacapo")&&s.addDirection(ys.JumpDaCapo),e.attributes.has("dalsegno")&&s.addDirection(ys.JumpDalSegno),e.attributes.has("fine")&&s.addDirection(ys.TargetFine),e.attributes.has("segno")&&s.addDirection(ys.TargetSegno),e.attributes.has("pan")){this.$c||(this.$c=[]);const s=new d;s.type=l.Balance,s.value=t.bc(Number.parseFloat(e.attributes.get("pan"))),this.$c.push(s)}if(e.attributes.has("tempo")){this.$c||(this.$c=[]);const s=new d;s.type=l.Tempo,s.value=t.fc(Number.parseFloat(e.attributes.get("tempo"))),this.$c.push(s)}}Hc(t,e){let s=0,i=0,n=null;for(const r of t.childElements())switch(r.localName){case"straight":return void(e.tripletFeel=K.NoTripletFeel);case"first":s=Number.parseInt(r.innerText,10);break;case"second":i=Number.parseInt(r.innerText,10);break;case"swing-type":n=this.Vc(r)}n||(n=w.Eighth),n===w.Eighth?2===s&&1===i?e.tripletFeel=K.Triplet8th:3===s&&1===i?e.tripletFeel=K.Dotted8th:1===s&&3===i&&(e.tripletFeel=K.Scottish8th):n===w.Sixteenth&&(2===s&&1===i?e.tripletFeel=K.Triplet16th:3===s&&1===i?e.tripletFeel=K.Dotted16th:1===s&&3===i&&(e.tripletFeel=K.Scottish16th))}$c=null;zc=null;Uc=null;Xc=!1;jc=!1;Jc=null;qc=null;Gc(e,s){let i;for(const s of e.childElements())switch(s.localName){case"midi-bank":this.$c||(this.$c=[]),i=new d,i.type=l.Bank,i.value=Number.parseInt(s.innerText,10)-1,this.$c.push(i);break;case"midi-program":this.$c||(this.$c=[]),i=new d,i.type=l.Instrument,i.value=Number.parseInt(s.innerText,10)-1,this.$c.push(i);break;case"volume":this.$c||(this.$c=[]),i=new d,i.type=l.Volume,i.value=t.fc(Number.parseFloat(s.innerText)),this.$c.push(i);break;case"pan":this.$c||(this.$c=[]),i=new d,i.type=l.Balance,i.value=t.bc(Number.parseFloat(s.innerText)),this.$c.push(i)}}Pc(t,e){const s=new ye;let i=!1,n="";for(const e of t.childElements())switch(e.localName){case"root":s.name=this.Yc(e);break;case"kind":s.name=s.name+this.Kc(e),"yes"===e.getAttribute("parentheses-degrees","no")&&(i=!0);break;case"frame":this.Qc(e,s);break;case"degree":n+=this.Zc(e)}n&&(s.name+=i?`(${n})`:n),"yes"===t.getAttribute("print-frame","no")&&(s.showDiagram=!0,this.We.stylesheet.globalDisplayChordDiagramsInScore=!0),"yes"===t.getAttribute("print-object","yes")&&(s.showDiagram=!0),null===this.zc&&(this.zc=s)}Zc(t){let e="",s="",i="";for(const n of t.childElements())switch(n.localName){case"degree-value":e=n.innerText;break;case"degree-alter":switch(n.innerText){case"-1":s="♭";break;case"1":s="♯"}break;case"degree-type":i+=n.getAttribute("text","")}return`${i}${s}${e}`}Yc(t){let e="",s="";for(const i of t.childElements())switch(i.localName){case"root-step":e=i.innerText;break;case"root-alter":switch(Number.parseFloat(i.innerText)){case-2:s="bb";break;case-1:s="b";break;case 0:s="";break;case 1:s="#";break;case 2:s="##"}}return e+s}Kc(t){const e=t.getAttribute("text");let s="";if(e)s=e;else{const e=t.innerText;switch(e){case"major":s="";break;case"minor":s="m";break;case"augmented":s="+";break;case"diminished":s="○";break;case"dominant":s="7";break;case"major-seventh":s="7M";break;case"minor-seventh":s="m7";break;case"diminished-seventh":s="○7";break;case"augmented-seventh":s="+7";break;case"half-diminished":s="⍉";break;case"major-minor":s="mMaj";break;case"major-sixth":s="maj6";break;case"minor-sixth":s="m6";break;case"dominant-ninth":s="9";break;case"major-ninth":s="maj9";break;case"minor-ninth":s="m9";break;case"dominant-11th":s="11";break;case"major-11th":s="maj11";break;case"minor-11th":s="m11";break;case"dominant-13th":s="13";break;case"major-13th":s="maj13";break;case"minor-13th":s="m13";break;case"suspended-second":s="sus2";break;case"suspended-fourth":s="sus4";break;case"Neapolitan":s="♭II";break;case"Italian":s="It⁺⁶";break;case"French":case"German":s="Fr⁺⁶";break;default:s=e}}return s}Qc(t,e){for(const s of t.childElements())switch(s.localName){case"frame-strings":const t=Number.parseInt(s.innerText,10);e.strings=new Array(t);for(let s=0;s<t;s++)e.strings[s]=-1;break;case"first-fret":e.firstFret=Number.parseInt(s.innerText,10);break;case"frame-note":let i=null,n=null;for(const t of s.childElements())switch(t.localName){case"string":i=Number.parseInt(t.innerText,10);break;case"fret":n=Number.parseInt(t.innerText,10),i&&n>=0&&(e.strings[i-1]=n);break;case"barre":i&&n&&"start"===t.getAttribute("type")&&e.barreFrets.push(n)}}}Nc(t,e,s){let i,n,r;if(null==this._c)for(const a of t.childElements())switch(a.localName){case"divisions":this.Jo=Number.parseFloat(a.innerText);break;case"key":this.tl(a,e,s);break;case"time":this.Br(a,e);break;case"staves":s.ensureStaveCount(Number.parseInt(a.innerText,10));break;case"clef":i=Number.parseInt(a.getAttribute("number","1"),10)-1,n=this.Fc(s,i),r=this.vr(n,e),this.br(a,r);break;case"staff-details":i=Number.parseInt(a.getAttribute("number","1"),10)-1,n=this.Fc(s,i),this.el(a,n);break;case"transpose":this.Ah(a,s);break;case"measure-style":this.sl(a,s,!1)}else for(const e of t.childElements())switch(e.localName){case"divisions":this.Jo=Number.parseFloat(e.innerText);break;case"measure-style":this.sl(e,s,!0)}}Dc=null;Wc=null;il=!1;sl(t,e,s){for(const e of t.childElements())switch(e.localName){case"measure-repeat":if(!s){let s=null;switch(e.getAttribute("type")){case"start":switch(Number.parseInt(e.getAttribute("slashes","1"),10)){case 1:s=H.Simple;break;case 2:s=H.FirstOfDouble}break;case"stop":s=null}if(t.attributes.has("number")){this.Wc=this.Wc??new Map;const e=Number.parseInt(t.attributes.get("number"),10)-1;null==s?this.Wc.delete(e):this.Wc.set(e,s)}else this.Dc=s}break;case"slash":switch(e.getAttribute("type")){case"start":this.il=!0;break;case"stop":this.il=!1}}}Ah(t,e){let s=0;for(const e of t.childElements())switch(e.localName){case"chromatic":s+=Number.parseFloat(e.innerText);break;case"octave-change":s+=12*Number.parseFloat(e.innerText)}if(t.attributes.has("number")){const i=this.Fc(e,Number.parseInt(t.attributes.get("number"),10)-1);this.nl(i).transpose=s,i.displayTranspositionPitch=s}else for(const t of e.staves)this.nl(t).transpose=s,t.displayTranspositionPitch=s}el(t,e){for(const s of t.childElements())switch(s.localName){case"staff-lines":e.standardNotationLineCount=Number.parseInt(s.innerText,10);break;case"staff-tuning":this.rl(s,e);break;case"capo":e.capo=Number.parseInt(s.innerText,10)}}rl(t,e){0===e.stringTuning.tunings.length&&(e.showTablature=!0,e.showStandardNotation=!1,e.stringTuning.tunings=new Array(e.standardNotationLineCount).fill(0));const s=Number.parseInt(t.getAttribute("line"),10);let i="C",n="",r=0;for(const e of t.childElements())switch(e.localName){case"tuning-step":i=e.innerText;break;case"tuning-alter":r=Number.parseFloat(e.innerText);break;case"tuning-octave":n=e.innerText}const a=Bt.getTuningForText(i+n)+r;e.tuning[e.tuning.length-s]=a}br(t,e){let s="s",i=0;for(const n of t.childElements())switch(n.localName){case"sign":s=n.innerText.toLowerCase();break;case"line":i=Number.parseInt(n.innerText,10);break;case"clef-octave-change":switch(Number.parseInt(n.innerText,10)){case-2:e.clefOttava=x.L;break;case-1:e.clefOttava=x.M;break;case 1:e.clefOttava=x.T;break;case 2:e.clefOttava=x.L}}switch(s){case"g":default:e.clef=G.G2;break;case"f":e.clef=G.F4;break;case"c":e.clef=3===i?G.C3:G.C4;break;case"percussion":e.clef=G.Neutral,0===e.index&&(e.staff.isPercussion=!0);break;case"tab":e.clef=G.G2,e.staff.showTablature=!0}}Br(t,e){let s=!1,i=!1;for(const n of t.childElements()){const t=n.innerText;switch(n.localName){case"beats":s||(-1===t.indexOf("+")?e.timeSignatureNumerator=Number.parseInt(t,10):e.timeSignatureNumerator=t.split("+").map(t=>Number.parseInt(t,10)).reduce((t,e)=>e+t,0),s=!0);break;case"beat-type":i||(-1===t.indexOf("+")?e.timeSignatureDenominator=Number.parseInt(t,10):e.timeSignatureDenominator=t.split("+").map(t=>Number.parseInt(t,10)).reduce((t,e)=>e+t,0),i=!0)}}switch(t.getAttribute("symbol","")){case"common":case"cut":e.timeSignatureCommon=!0}}Ac=null;tl(t,e,s){let i,n,r=-V.C,a="";for(const e of t.childElements())switch(e.localName){case"fifths":r=Number.parseInt(e.innerText,10);break;case"mode":a=e.innerText}if(i=-7<=r&&r<=7?r:V.C,n="minor"===a?z.Minor:z.Major,t.attributes.has("number")){const r=this.Fc(s,Number.parseInt(t.attributes.get("number"),10)-1),a=this.vr(r,e);a.keySignature=i,a.keySignatureType=n}else{this.Ac=[i,n];for(const t of s.staves)t.bars.length>e.index&&(t.bars[e.index].keySignature=i,t.bars[e.index].keySignatureType=n)}}vc(t,e,s){const i=[];let n=null,r=-1,a=-1;for(const e of t.childElements())switch(e.localName){case"direction-type":const t=e.firstElement;t&&i.push(t);break;case"offset":n=Number.parseFloat(e.innerText);break;case"voice":break;case"staff":r=Number.parseInt(e.innerText,10)-1;break;case"sound":e.attributes.has("tempo")&&(a=Number.parseFloat(e.attributes.get("tempo")))}let h=null;h=r>=0?this.Fc(s,r):null!==this._c?this._c.voice.bar.staff:this.Fc(s,0);const o=h?this.vr(h,e):null,c=()=>{let t=this.Bc;null!==n&&(t+=n);return t/e.calculateDuration(!1)};if(a>0){const t=new d;t.type=l.Tempo,t.value=a,t.ratioPosition=c(),this.al(e,t)||e.tempoAutomations.push(t)}let u="";for(const t of i)switch(t.localName){case"rehearsal":e.section=new Te,e.section.marker=t.innerText;break;case"segno":e.addDirection(ys.TargetSegno);break;case"coda":e.addDirection(ys.TargetCoda);break;case"words":u=t.innerText;break;case"wedge":switch(t.getAttribute("type")){case"crescendo":this.Uc=g.Crescendo;break;case"diminuendo":this.Uc=g.Decrescendo;break;case"stop":this.Uc=null}break;case"dynamics":const s=this.hl(t);null!==s&&(this.qo=s,this.We.stylesheet.hideDynamics=!1);break;case"dashes":const i=t.getAttribute("type","start");switch(u){case"LetRing":this.Xc="start"===i||"continue"===i;break;case"P.M.":this.jc="start"===i||"continue"===i}u="";break;case"pedal":const n=this.ol(t);if(n&&o){n.ratioPosition=c();const t=o.sustainPedals.length>0&&o.sustainPedals[o.sustainPedals.length-1].pedalType!==U.Up;(n.pedalType!==U.Up||t)&&o.sustainPedals.push(n)}break;case"metronome":this.cl(t,e,c());break;case"octave-shift":this.Jc=this.ll(t)}u&&(this.qc=u)}ll(t){const e=t.getAttribute("type");switch(Number.parseInt(t.getAttribute("size","8"),10)){case 15:switch(e){case"up":return x.L;case"down":return x._;case"stop":return x.Regular;case"continue":return this.Jc}break;case 8:switch(e){case"up":return x.M;case"down":return x.T;case"stop":return x.Regular;case"continue":return this.Jc}}return null}cl(t,e,s){let i=null,n=-1;for(const e of t.childElements())switch(e.localName){case"beat-unit":i=this.Vc(e);break;case"per-minute":n=Number.parseFloat(e.innerText)}if(null!==i&&n>0){const t=new d;t.type=l.Tempo,t.value=n*(i/4),t.ratioPosition=s,this.al(e,t)||e.tempoAutomations.push(t)}}al(t,e){for(const s of t.tempoAutomations)if(e.ratioPosition===s.ratioPosition&&e.value===s.value)return!0;return!1}ol(t){const e=new X;switch(t.getAttribute("type")){case"start":e.pedalType=U.Down;break;case"stop":e.pedalType=U.Up;break;case"continue":e.pedalType=U.Hold;break;default:return null}return e}hl(t){for(const e of t.childElements()){const t=e.localName.toUpperCase();switch(t){case"PPP":case"PP":case"P":case"MP":case"MF":case"F":case"FF":case"FFF":case"PPPP":case"PPPPP":case"PPPPPP":case"FFFF":case"FFFFF":case"FFFFFF":case"SF":case"SFP":case"SFPP":case"FP":case"RF":case"RFZ":case"SFZ":case"SFFZ":case"FZ":case"N":case"PF":case"SFZP":return o[t]}}return null}Mc(t){for(const e of t.childElements())if("duration"===e.localName)this.Bc+=this.ul(Number.parseFloat(e.innerText))}Tc(t){for(const e of t.childElements())if("duration"===e.localName)if(this._c){let t=this.Bc;t-=this.ul(Number.parseFloat(e.innerText)),t<0&&(t=0),this.Bc=t}}Fc(t,e){for(;t.staves.length<=e;){const e=new ve;t.addStaff(e),this.We.masterBars.length>0&&this.vr(e,this.We.masterBars[this.We.masterBars.length-1])}return t.staves[e]}vr(t,e){const s=0===t.bars.length?1:t.bars[0].voices.length;for(;t.bars.length<=e.index;){const e=new Y;t.addBar(e),e.previousBar&&(e.clef=e.previousBar.clef,e.clefOttava=e.previousBar.clefOttava,e.keySignature=e.previousBar.keySignature,e.keySignatureType=e.previousBar.keySignatureType),null!=this.Ac&&(e.keySignature=this.Ac[0],e.keySignatureType=this.Ac[1]);for(let t=0;t<s;t++){const t=new lt;e.addVoice(t)}}return t.bars[e.index]}dl(t,e){let s=!1;for(;t.voices.length<=e;)t.addVoice(new lt),s=!0;if(s)for(const s of t.staff.bars)for(;s.voices.length<=e;)s.addVoice(new lt);return t.voices[e]}bo(t,e,s){let i=null,n=y.None,r=0,a=null,h=!1,o=0,l=0,u=-1,d=null,f=0,p=-1,b=-1,m=null,g=null,k=!1,S=null;const B="no"!==t.getAttribute("print-object","yes"),_=()=>{if(null!==i)return;h&&!this._c&&(O.warning("MusicXML","Malformed MusicXML, <chord /> cannot be set on the first note of a measure"),h=!1),h&&!g&&(O.warning("MusicXML","Cannot mix <chord /> and <rest />"),h=!1);const t=this.Fc(s,o);if(h)return i=this._c,void i.addNote(g);const k=this.vr(t,e),S=this.dl(k,l),B=0===S.beats.length?0:S.beats[S.beats.length-1].displayEnd;let _=this.Bc-B;if(_>0){if(this._c&&this._c.beamingMode===Vt.ForceMergeWithNext&&this._c.voice.bar.staff.index!==o&&S.beats.length>0&&S.beats[S.beats.length-1].beamingMode===Vt.ForceMergeWithNext){const t=S.beats[S.beats.length-1].duration;for(;_>0;){const e=this.fl(_,t);if(null===e)break;this.pl(e,S),_-=e.playbackDuration}}if(_>0){const t=new Xt;t.dynamics=this.qo,t.isEmpty=!0,t.duration=w.TwoHundredFiftySixth,t.overrideDisplayDuration=_,t.updateDurations(),this.pl(t,S)}}else _<0&&O.error("MusicXML","Unsupported forward/backup detected. Cannot fill new beats into already filled area of voice");u<0&&null!==d&&(u=c.toTicks(d),f>0&&(u=c.applyDot(u,2===f)));const x=new Xt;i=x,null===a?x.beamingMode=this.nl(t).isExplicitlyBeamed?Vt.ForceSplitToNext:Vt.Auto:(x.beamingMode=a,this.nl(t).isExplicitlyBeamed=!0),x.isEmpty=!1,x.dynamics=this.qo,this.il&&(x.slashed=!0);const T=this.$c;if(this.$c=null,null!==T)for(const t of T)x.automations.push(t);const M=this.zc;this.zc=null,null!==M&&(x.chordId=M.uniqueId,S.bar.staff.hasChord(M.uniqueId)||S.bar.staff.addChord(x.chordId,M));const v=this.Uc;null!==v&&(x.crescendo=v);const N=this.Jc;null!==N&&(x.ottava=N),x.isLetRing=this.Xc,x.isPalmMute=this.jc,this.qc&&(x.text=this.qc,this.qc=null),null!==g&&x.addNote(g),this.pl(x,S),n!==y.None?(x.graceType=n,this.bl(x,r,null,!1)):(x.tupletNumerator=p,x.tupletDenominator=b,x.dots=f,x.preferredBeamDirection=m,this.bl(x,u,d,!0)),this.Bc=x.displayEnd,this._c=x};for(const e of t.childElements())switch(e.localName){case"grace":const t=Number.parseFloat(e.getAttribute("make-time","-1"));t>=0?(r=this.ul(t),n=y.BeforeBeat):n=y.OnBeat,"yes"===e.getAttribute("slash")&&(n=y.BeforeBeat);break;case"chord":h=!0;break;case"cue":return;case"pitch":g=this.ml(e),k=!0;break;case"unpitched":g=this.gl(e,s);break;case"rest":g=null,null===d&&(d=w.Whole);break;case"duration":u=this.Wi(e);break;case"instrument":S=e.getAttribute("id","");break;case"voice":l=Number.parseInt(e.innerText,10),Number.isNaN(l)?(O.warning("MusicXML","Voices need to be specified as numbers"),l=0):l-=1;break;case"type":d=this.Vc(e);break;case"dot":f++;break;case"accidental":null===g?O.warning("MusicXML","Malformed MusicXML, missing pitch or unpitched for note"):this.wl(e,g);break;case"time-modification":for(const t of e.childElements())switch(t.localName){case"actual-notes":p=Number.parseInt(t.innerText,10);break;case"normal-notes":b=Number.parseInt(t.innerText,10)}break;case"stem":m=this.yl(e);break;case"notehead":null===g?O.warning("MusicXML","Malformed MusicXML, missing pitch or unpitched for note"):this.kl(e,g,d??w.Quarter,m??this.Sl(g));break;case"staff":o=Number.parseInt(e.innerText,10)-1;break;case"beam":if("1"===e.getAttribute("number","1"))switch(e.innerText){case"begin":case"continue":a=Vt.ForceMergeWithNext;break;case"end":a=Vt.ForceSplitToNext}break;case"notations":_(),this.Bl(e,g,i);break;case"lyric":_(),this.Ir(e,i,s);break;case"play":this._l(e,g)}if(k){const t=this.Fc(s,o),e=this.nl(t).transpose;if(0!==e){const t=12*g.octave+g.tone+e;g.octave=t/12|0,g.tone=t-12*g.octave}}_(),null!==g&&this.xl(g,s,S,k,B)}xl(t,e,s,i,n){if(t.isVisible=n,t.percussionArticulation>=0)return;const r=this.zo.get(e.index);if(null!==s)t.percussionArticulation=r.getOrCreateArticulation(s,t);else if(t.beat.voice.bar.staff.isPercussion&&i){const e=Nt.getArticulationById(t.displayValue);e&&(t.percussionArticulation=e.id)}else i||(t.percussionArticulation=r.getOrCreateArticulation("",t))}_l(t,e){for(const s of t.childElements())if("mute"===s.localName)e&&"palm"===s.innerText&&(e.isPalmMute=!0)}static Tl=71;Sl(e){return e.calculateRealValue(!1,!1)<t.Tl?Fe.Down:Fe.Up}kl(t,e,s,i){"yes"===t.getAttribute("parentheses","no")&&(e.isGhost=!0);const n=t.getAttribute("filled","");let r;switch("yes"===n?r=!0:"no"===n&&(r=!1),e.style=new Ft,t.innerText){case"arrow down":e.style.noteHeadCenterOnStem=!0,this.Ml(e,s,r,xt.NoteheadTriangleDownDoubleWhole,xt.NoteheadTriangleDownWhole,xt.NoteheadTriangleDownHalf,xt.NoteheadTriangleDownBlack);break;case"arrow up":e.style.noteHeadCenterOnStem=!0,this.Ml(e,s,r,xt.NoteheadTriangleUpDoubleWhole,xt.NoteheadTriangleUpWhole,xt.NoteheadTriangleUpHalf,xt.NoteheadTriangleUpBlack);break;case"back slashed":this.Ml(e,s,r,xt.NoteheadSlashedDoubleWhole2,xt.NoteheadSlashedWhole2,xt.NoteheadSlashedHalf2,xt.NoteheadSlashedBlack2);break;case"circle dot":e.style.noteHead=xt.NoteheadRoundWhiteWithDot;break;case"circle-x":this.Ml(e,s,r,xt.NoteheadCircleXDoubleWhole,xt.NoteheadCircleXWhole,xt.NoteheadCircleXHalf,xt.NoteheadCircleX);break;case"circled":this.Ml(e,s,r,xt.NoteheadCircledDoubleWhole,xt.NoteheadCircledWhole,xt.NoteheadCircledHalf,xt.NoteheadCircledBlack);break;case"cluster":this.Ml(e,s,r,xt.NoteheadClusterDoubleWhole3rd,xt.NoteheadClusterWhole3rd,xt.NoteheadClusterHalf3rd,xt.NoteheadClusterQuarter3rd);break;case"cross":this.Ml(e,s,r,xt.NoteheadPlusDoubleWhole,xt.NoteheadPlusWhole,xt.NoteheadPlusHalf,xt.NoteheadPlusBlack);break;case"diamond":this.Ml(e,s,r,xt.NoteheadDiamondDoubleWhole,xt.NoteheadDiamondWhole,xt.NoteheadDiamondHalf,xt.NoteheadDiamondBlack);break;case"do":this.Ml(e,s,r,xt.NoteShapeTriangleUpWhite,xt.NoteShapeTriangleUpWhite,xt.NoteShapeTriangleUpWhite,xt.NoteShapeTriangleUpBlack);break;case"fa":i===Fe.Up?this.Ml(e,s,r,xt.NoteShapeTriangleRightWhite,xt.NoteShapeTriangleRightWhite,xt.NoteShapeTriangleRightWhite,xt.NoteShapeTriangleRightBlack):this.Ml(e,s,r,xt.NoteShapeTriangleLeftWhite,xt.NoteShapeTriangleLeftWhite,xt.NoteShapeTriangleLeftWhite,xt.NoteShapeTriangleLeftBlack);break;case"fa up":this.Ml(e,s,r,xt.NoteShapeTriangleLeftWhite,xt.NoteShapeTriangleLeftWhite,xt.NoteShapeTriangleLeftWhite,xt.NoteShapeTriangleLeftBlack);break;case"inverted triangle":this.Ml(e,s,r,xt.NoteheadTriangleDownDoubleWhole,xt.NoteheadTriangleDownWhole,xt.NoteheadTriangleDownHalf,xt.NoteheadTriangleDownBlack);break;case"la":case"square":this.Ml(e,s,r,xt.NoteShapeSquareWhite,xt.NoteShapeSquareWhite,xt.NoteShapeSquareWhite,xt.NoteShapeSquareBlack);break;case"left triangle":this.Ml(e,s,r,xt.NoteheadTriangleRightWhite,xt.NoteheadTriangleRightWhite,xt.NoteheadTriangleRightWhite,xt.NoteheadTriangleRightBlack);break;case"mi":this.Ml(e,s,r,xt.NoteShapeDiamondWhite,xt.NoteShapeDiamondWhite,xt.NoteShapeDiamondWhite,xt.NoteShapeDiamondBlack);break;case"none":e.style.noteHead=xt.NoteheadNull;break;case"normal":this.Ml(e,s,r,xt.NoteheadDoubleWhole,xt.NoteheadWhole,xt.NoteheadHalf,xt.NoteheadBlack);break;case"re":this.Ml(e,s,r,xt.NoteShapeMoonWhite,xt.NoteShapeMoonWhite,xt.NoteShapeMoonWhite,xt.NoteShapeMoonBlack);break;case"rectangle":this.Ml(e,s,r,xt.NoteheadSquareWhite,xt.NoteheadSquareWhite,xt.NoteheadSquareWhite,xt.NoteheadSquareBlack);break;case"slash":this.Ml(e,s,r,xt.NoteheadSlashWhiteWhole,xt.NoteheadSlashWhiteWhole,xt.NoteheadSlashWhiteHalf,xt.NoteheadSlashHorizontalEnds);break;case"slashed":this.Ml(e,s,r,xt.NoteheadSlashedDoubleWhole1,xt.NoteheadSlashedWhole1,xt.NoteheadSlashedHalf1,xt.NoteheadSlashedBlack1);break;case"so":this.Ml(e,s,r,xt.NoteShapeRoundWhite,xt.NoteShapeRoundWhite,xt.NoteShapeRoundWhite,xt.NoteShapeRoundBlack);break;case"ti":this.Ml(e,s,r,xt.NoteShapeTriangleRoundWhite,xt.NoteShapeTriangleRoundWhite,xt.NoteShapeTriangleRoundWhite,xt.NoteShapeTriangleRoundBlack);break;case"triangle":this.Ml(e,s,r,xt.NoteheadTriangleUpDoubleWhole,xt.NoteheadTriangleUpWhole,xt.NoteheadTriangleUpHalf,xt.NoteheadTriangleUpBlack);break;case"x":this.Ml(e,s,r,xt.NoteheadXDoubleWhole,xt.NoteheadXWhole,xt.NoteheadXHalf,xt.NoteheadXBlack)}}fl(t,e){let s=c.toTicks(e);for(;s>t;){if(e===w.TwoHundredFiftySixth)return null;e*=2,s=c.toTicks(e)}const i=new Xt;return i.dynamics=this.qo,i.isEmpty=!1,i.duration=e,i.overrideDisplayDuration=s,i.updateDurations(),i}pl(t,e){if(e.beats.length>0){const s=e.beats[e.beats.length-1];s.nextBeat=t,t.previousBeat=s;let i=s;for(;null!==i&&i.graceType!==y.None;)i=i.index>0?i.previousBeat:null;null!==i&&(t.displayStart=i.displayEnd)}e.addBeat(t)}ul(t){return t*c.QuarterTime/this.Jo}Vc(t){switch(t.innerText){case"1024th":case"512th":case"256th":return w.TwoHundredFiftySixth;case"128th":return w.OneHundredTwentyEighth;case"64th":return w.SixtyFourth;case"32nd":return w.ThirtySecond;case"16th":return w.Sixteenth;case"eighth":return w.Eighth;case"quarter":return w.Quarter;case"half":return w.Half;case"whole":return w.Whole;case"breve":return w.DoubleWhole;case"long":return w.QuadrupleWhole}return null}static vl=[w.TwoHundredFiftySixth,w.OneHundredTwentyEighth,w.SixtyFourth,w.ThirtySecond,w.Sixteenth,w.Eighth,w.Quarter,w.Half,w.Whole,w.DoubleWhole,w.QuadrupleWhole];static Nl=t.vl.map(t=>c.toTicks(t));bl(e,s,i,n){if(!i)for(let e=0;e<t.vl.length&&s>=t.Nl[e];e++)i=t.vl[e];e.duration=i??w.Sixteenth,n&&(e.overrideDisplayDuration=s),e.updateDurations()}Ir(t,e,s){const i=this.zo.get(s.index).getLyricLine(t.getAttribute("number",""));for(null===e.lyrics&&(e.lyrics=[]);e.lyrics.length<=i;)e.lyrics.push("");for(const s of t.childElements())switch(s.localName){case"text":e.lyrics[i]?e.lyrics[i]+=` ${s.innerText}`:e.lyrics[i]=s.innerText;break;case"elision":e.lyrics[i]+=s.innerText}}Bl(t,e,s){for(const i of t.childElements())switch(i.localName){case"tied":e&&this.Pl(i,e,s.voice.bar.staff);break;case"slur":e&&this.Jr(i,e);break;case"glissando":e&&this.Cl(i,e);break;case"slide":e&&this.El(i,e);break;case"ornaments":e&&this.Fl(i,e);break;case"technical":this.Al(i,e,s);break;case"articulations":e&&this.Oh(i,e);break;case"dynamics":const t=this.hl(i);null!==t&&(s.dynamics=t,this.qo=t);break;case"fermata":this.ao(i,s);break;case"arpeggiate":this.Dl(i,s)}}nl(t){if(!this.Uo.has(t)){const e=new $s;return this.Uo.set(t,e),e}return this.Uo.get(t)}Cl(t,e){const s=t.getAttribute("type"),i=t.getAttribute("number","1"),n=this.nl(e.beat.voice.bar.staff);switch(s){case"start":n.slideOrigins.set(i,e);break;case"stop":if(n.slideOrigins.has(i)){const t=n.slideOrigins.get(i);t.slideTarget=e,e.slideOrigin=t,t.slideOutType=M.Shift}}}Jr(t,e){const s=t.getAttribute("number","1"),i=this.nl(e.beat.voice.bar.staff);switch(t.getAttribute("type")){case"start":i.slurStarts.set(s,e);break;case"stop":if(i.slurStarts.has(s)){e.isSlurDestination=!0;const t=i.slurStarts.get(s);t.slurDestination=e,e.slurOrigin=t,i.slurStarts.delete(s)}}}Dl(t,e){switch(t.getAttribute("direction","down")){case"down":e.brushType=m.ArpeggioDown;break;case"up":e.brushType=m.ArpeggioUp}}ao(t,e){let s;switch(t.innerText){case"normal":default:s=Be.Medium;break;case"angled":s=Be.Short;break;case"square":s=Be.Long}e.fermata=new _e,e.fermata.type=s}Oh(t,e){for(const s of t.childElements())switch(s.localName){case"accent":e.accentuated=k.Normal;break;case"strong-accent":e.accentuated=k.Heavy;break;case"staccato":e.isStaccato=!0;break;case"tenuto":e.accentuated=k.Tenuto}}Al(t,e,s){const i=[];for(const n of t.childElements())switch(n.localName){case"up-bow":s.pickStroke=_t.Up;break;case"down-bow":s.pickStroke=_t.Down;break;case"harmonic":break;case"fingering":e&&(e.leftHandFinger=this.Ll(n));break;case"pluck":e&&(e.rightHandFinger=this.Ll(n));break;case"fret":e&&(e.fret=Number.parseInt(n.innerText,10));break;case"string":e&&(e.string=s.voice.bar.staff.tuning.length-Number.parseInt(n.innerText,10)+1);break;case"hammer-on":case"pull-off":e&&(e.isHammerPullOrigin=!0);break;case"bend":i.push(n);break;case"tap":s.tap=!0;break;case"smear":e&&(e.vibrato=P.Slight);break;case"golpe":switch(n.getAttribute("placement","above")){case"above":s.golpe=Wt.Finger;break;case"below":s.golpe=Wt.Thumb}}e&&i.length>0&&this.Wl(i,e)}Wl(t,e){const s=f.MaxPosition/t.length;let i=0,n=0,r=!0;for(const a of t){const t=a.findChildElement("bend-alter");if(t){const h=Math.round(2*Math.abs(Number.parseFloat(t.innerText)));a.findChildElement("pre-bend")?r?(i+=h,e.addBendPoint(new f(n,i)),n+=s,e.addBendPoint(new f(n,i)),r=!1):n+=s:a.findChildElement("release")?(r&&(i+=h),e.addBendPoint(new f(n,i)),n+=s,i-=h,e.addBendPoint(new f(n,i)),r=!1):(e.addBendPoint(new f(n,i)),i+=h,n+=s,e.addBendPoint(new f(n,i)),r=!1)}}}Ll(t){switch(t.innerText){case"0":return S.NoOrDead;case"1":case"p":case"t":return S.Thumb;case"2":case"i":return S.IndexFinger;case"3":case"m":return S.MiddleFinger;case"4":case"a":return S.AnnularFinger;case"5":case"c":return S.LittleFinger}return S.Unknown}Rl=-1;Fl(t,e){let s=-1;for(const i of t.childElements())switch(i.localName){case"trill-mark":s=Number.parseInt(i.getAttribute("trill-step","2"),10),e.isStringed?e.trillValue=e.stringTuning+s:e.isPercussion||(e.trillValue=e.calculateRealValue(!1,!1)+s);break;case"turn":e.ornament=Pt.Turn;break;case"inverted-turn":e.ornament=Pt.InvertedTurn;break;case"wavy-line":s>0?"start"===i.getAttribute("type")&&(this.Rl=s):this.Rl>0?"stop"===i.getAttribute("type")?this.Rl=-1:e.isStringed?e.trillValue=e.stringTuning+this.Rl:e.isPercussion||(e.trillValue=e.calculateRealValue(!1,!1)+this.Rl):e.vibrato=P.Slight;break;case"mordent":e.ornament=Pt.LowerMordent;break;case"inverted-mordent":e.ornament=Pt.UpperMordent;break;case"tremolo":const t=new $t;e.beat.tremoloPicking=t,t.marks=Number.parseInt(i.innerText,10),("unmeasured"===i.getAttribute("type","")&&0===t.marks||"buzzRoll"===i.getAttribute("smufl",""))&&(t.style=Ht.BuzzRoll)}}El(t,e){const s=t.getAttribute("type"),i=t.getAttribute("number","1"),n=this.nl(e.beat.voice.bar.staff);switch(s){case"start":n.slideOrigins.set(i,e);break;case"stop":if(n.slideOrigins.has(i)){const t=n.slideOrigins.get(i);t.slideTarget=e,e.slideOrigin=t,t.slideOutType=M.Shift}}}Pl(t,e,s){const i=t.getAttribute("type"),n=t.getAttribute("number",""),r=this.nl(s);if("start"===i){if(n){if(r.tieStartIds.has(n)){const t=r.tieStartIds.get(n);r.tieStarts.delete(t)}r.tieStartIds.set(n,e)}r.tieStarts.add(e)}else if("stop"===i&&!e.isTieDestination){let t=null;if(n){if(!r.tieStartIds.has(n))return;t=r.tieStartIds.get(n),r.tieStartIds.delete(n),r.tieStarts.delete(e)}else{const s=this.Ol(e);for(const e of r.tieStarts)if(this.Ol(e)===s){t=e,r.tieStarts.delete(t);break}}if(!t)return;e.isTieDestination=!0,e.tieOrigin=t}}yl(t){switch(t.innerText){case"down":return Fe.Down;case"up":return Fe.Up;default:return null}}wl(t,e){switch(t.innerText){case"sharp":e.accidentalMode=_.ForceSharp;break;case"natural":e.accidentalMode=_.ForceNatural;break;case"flat":e.accidentalMode=_.ForceFlat;break;case"double-sharp":e.accidentalMode=_.ForceDoubleSharp;break;case"flat-flat":e.accidentalMode=_.ForceDoubleFlat}}Ol(t){return 12*t.octave+t.tone}Wi(t){return this.ul(Number.parseFloat(t.innerText))}gl(t,e){let s="",i=0;for(const e of t.childElements())switch(e.localName){case"display-step":s=e.innerText;break;case"display-octave":i=Number.parseInt(e.innerText,10)+1}const n=new At;if(""===s)n.octave=0,n.tone=0;else{const t=12*i+(Bt.getToneForText(s)?.noteValue??0);n.octave=t/12|0,n.tone=t-12*n.octave}return n}ml(t){let e="",s=0,i=0;for(const n of t.childElements())switch(n.localName){case"step":e=n.innerText;break;case"alter":s=Number.parseFloat(n.innerText),Number.isNaN(s)&&(s=0);break;case"octave":i=Number.parseInt(n.innerText,10)+1}s|=0;const n=12*i+(Bt.getToneForText(e)?.noteValue??0)+s,r=new At;return r.octave=n/12|0,r.tone=n-12*r.octave,r}Ml(t,e,s,i,n,r,a){if(void 0===s)switch(e){case w.QuadrupleWhole:case w.DoubleWhole:t.style.noteHead=i;break;case w.Whole:t.style.noteHead=n;break;case w.Half:t.style.noteHead=r;break;default:t.style.noteHead=a}else if(!0===s)t.style.noteHead=a;else switch(e){case w.QuadrupleWhole:case w.DoubleWhole:t.style.noteHead=i;break;case w.Whole:t.style.noteHead=n;break;case w.Half:default:t.style.noteHead=r}}},Xs=function(t){return t[t.Page=0]="Page",t[t.Horizontal=1]="Horizontal",t[t.Parchment=2]="Parchment",t}({}),js=class{Il=[];Gl;constructor(t=void 0){this.Gl=t}on(t){return this.Il.push(t),this.Gl?.()&&t(),()=>{this.off(t)}}off(t){this.Il=this.Il.filter(e=>e!==t)}trigger(){for(const t of this.Il)t()}},Js=class{Il=[];Gl;constructor(t=void 0){this.Gl=t}on(t){if(this.Il.push(t),this.Gl){const e=this.Gl();null!==e&&t(e)}return()=>{this.off(t)}}off(t){this.Il=this.Il.filter(e=>e!==t)}trigger(t){for(const e of this.Il)e(t)}},qs=class{device;constructor(t){this.device=t}get deviceId(){return this.device.deviceId}get label(){return this.device.label}isDefault=!1},Ys=class t{static Hl=[];static findKnownDevice(e){return t.Hl.find(t=>t.deviceId===e)}static createAudioContext(){if("AudioContext"in Bu.globalThis)return new AudioContext;if("webkitAudioContext"in Bu.globalThis)return new webkitAudioContext;throw new a(r.General,"AudioContext not found")}static async checkSinkIdSupport(){return"setSinkId"in t.createAudioContext()||(O.warning("WebAudio","Browser does not support changing the output device"),!1)}static async enumerateOutputDevices(){try{if(!await t.checkSinkIdSupport())return[];try{await navigator.mediaDevices.getUserMedia({audio:!0})}catch(t){O.warning("WebAudio","Output device permission rejected",t)}const e=await navigator.mediaDevices.enumerateDevices();let s="",i="";const n=new Map;for(const t of e)"audiooutput"===t.kind&&(n.set(t.groupId,new qs(t)),"default"!==t.deviceId&&""!==t.deviceId||(s=t.groupId,i=t.deviceId));const r=Array.from(n.values());let a=r.find(t=>t.deviceId===i);return a||(a=r.find(t=>t.device.groupId===s)),!a&&r.length>0&&(a=r[0]),a&&(a.isDefault=!0),t.Hl=r,r}catch(t){return O.error("WebAudio","Failed to enumerate output devices",t),[]}}},Ks=class t{static BufferSize=4096;static PreferredSampleRate=44100;context=null;buffer=null;source=null;$l;get sampleRate(){return this.context?this.context.sampleRate:t.PreferredSampleRate}activate(t){this.context||(this.context=Ys.createAudioContext()),"suspended"!==this.context.state&&"interrupted"!==this.context.state||(O.debug("WebAudio","Audio Context is suspended, trying resume"),this.context.resume().then(()=>{O.debug("WebAudio",`Audio Context resume success: state=${this.context?.state}, sampleRate:${this.context?.sampleRate}`),t&&t()},t=>{O.warning("WebAudio",`Audio Context resume failed: state=${this.context?.state}, sampleRate:${this.context?.sampleRate}, reason=${t}`)}))}Vl(){const e=navigator.userAgent;if(-1!==e.indexOf("iPhone")||-1!==e.indexOf("iPad")){const e=Ys.createAudioContext(),s=e.createBuffer(1,1,t.PreferredSampleRate),i=e.createBufferSource();i.buffer=s,i.connect(e.destination),i.start(0),i.disconnect(0),e.close()}}open(t){this.Vl(),this.context=Ys.createAudioContext(),"suspended"===this.context.state&&this.zl()}zl(){this.$l=(()=>{this.activate(()=>{this.Ul()})}).bind(this),document.body.addEventListener("touchend",this.$l,!1),document.body.addEventListener("click",this.$l,!1)}Ul(){const t=this.$l;t&&(document.body.removeEventListener("touchend",t,!1),document.body.removeEventListener("click",t,!1))}play(){const e=this.context;this.activate(),this.buffer=e.createBuffer(2,t.BufferSize,e.sampleRate),this.source=e.createBufferSource(),this.source.buffer=this.buffer,this.source.loop=!0}pause(){this.source&&(this.source.stop(0),this.source.disconnect()),this.source=null}destroy(){this.pause(),this.context?.close(),this.context=null,this.Ul()}ready=new js;samplesPlayed=new Js;sampleRequest=new js;onSamplesPlayed(t){this.samplesPlayed.trigger(t)}onSampleRequest(){this.sampleRequest.trigger()}onReady(){this.ready.trigger()}enumerateOutputDevices(){return Ys.enumerateOutputDevices()}async setOutputDevice(t){await Ys.checkSinkIdSupport()&&(t?await this.context.setSinkId(t.deviceId):await this.context.setSinkId(""))}async getOutputDevice(){if(!await Ys.checkSinkIdSupport())return null;const t=this.context.sinkId;if("string"!=typeof t||""===t||"default"===t)return null;let e=Ys.findKnownDevice(t);if(e)return e;const s=await this.enumerateOutputDevices();return e=s.find(e=>e.deviceId===t),e||(O.warning("WebAudio","Could not find output device in device list",t,s),null)}},Qs=class extends a{xhr;constructor(t,e){super(r.General,t),this.xhr=e}},Zs=class{static clone(t){const e=new si;return e.musicFontSize=t.musicFontSize,e.oneStaffSpace=t.oneStaffSpace,e.tabLineSpacing=t.tabLineSpacing,e.arrowShaftThickness=t.arrowShaftThickness,e.barlineSeparation=t.barlineSeparation,e.beamSpacing=t.beamSpacing,e.beamThickness=t.beamThickness,e.bracketThickness=t.bracketThickness,e.dashedBarlineDashLength=t.dashedBarlineDashLength,e.dashedBarlineGapLength=t.dashedBarlineGapLength,e.dashedBarlineThickness=t.dashedBarlineThickness,e.hairpinThickness=t.hairpinThickness,e.legerLineThickness=t.legerLineThickness,e.legerLineExtension=t.legerLineExtension,e.octaveLineThickness=t.octaveLineThickness,e.pedalLineThickness=t.pedalLineThickness,e.repeatBarlineDotSeparation=t.repeatBarlineDotSeparation,e.repeatEndingLineThickness=t.repeatEndingLineThickness,e.slurMidpointThickness=t.slurMidpointThickness,e.staffLineThickness=t.staffLineThickness,e.stemThickness=t.stemThickness,e.thickBarlineThickness=t.thickBarlineThickness,e.thinBarlineThickness=t.thinBarlineThickness,e.thinThickBarlineSeparation=t.thinThickBarlineSeparation,e.tieMidpointThickness=t.tieMidpointThickness,e.tupletBracketThickness=t.tupletBracketThickness,e.stemUp=new Map(t.stemUp),e.stemDown=new Map(t.stemDown),e.repeatOffsetX=new Map(t.repeatOffsetX),e.standardStemLength=t.standardStemLength,e.stemFlagOffsets=new Map(t.stemFlagOffsets),e.glyphTop=new Map(t.glyphTop),e.glyphBottom=new Map(t.glyphBottom),e.glyphWidths=new Map(t.glyphWidths),e.glyphHeights=new Map(t.glyphHeights),e.numberedBarRendererBarSize=t.numberedBarRendererBarSize,e.numberedBarRendererBarSpacing=t.numberedBarRendererBarSpacing,e.numberedDashGlyphPadding=t.numberedDashGlyphPadding,e.numberedDashGlyphWidth=t.numberedDashGlyphWidth,e.lineRangedGlyphDashGap=t.lineRangedGlyphDashGap,e.lineRangedGlyphDashSize=t.lineRangedGlyphDashSize,e.preNoteEffectPadding=t.preNoteEffectPadding,e.postNoteEffectPadding=t.postNoteEffectPadding,e.onNoteEffectPadding=t.onNoteEffectPadding,e.stringNumberCirclePadding=t.stringNumberCirclePadding,e.rowContainerPadding=t.rowContainerPadding,e.rowContainerGap=t.rowContainerGap,e.alternateEndingsPadding=t.alternateEndingsPadding,e.sustainPedalLinePadding=t.sustainPedalLinePadding,e.tieHeight=t.tieHeight,e.beatTimerPadding=t.beatTimerPadding,e.bendNoteHeadElementPadding=t.bendNoteHeadElementPadding,e.ghostParenthesisWidth=t.ghostParenthesisWidth,e.ghostParenthesisPadding=t.ghostParenthesisPadding,e.brokenBeamWidth=t.brokenBeamWidth,e.tabWhammyTextPadding=t.tabWhammyTextPadding,e.tabWhammyPerHalfHeight=t.tabWhammyPerHalfHeight,e.tabWhammyDashSize=t.tabWhammyDashSize,e.songBookWhammyDipHeight=t.songBookWhammyDipHeight,e.deadSlappedLineWidth=t.deadSlappedLineWidth,e.leftHandTabTieWidth=t.leftHandTabTieWidth,e.tabBendDashSize=t.tabBendDashSize,e.tabBendStaffPadding=t.tabBendStaffPadding,e.tabBendPerValueHeight=t.tabBendPerValueHeight,e.tabBendLabelPadding=t.tabBendLabelPadding,e.simpleSlideWidth=t.simpleSlideWidth,e.simpleSlideHeight=t.simpleSlideHeight,e.chordDiagramPaddingX=t.chordDiagramPaddingX,e.chordDiagramPaddingY=t.chordDiagramPaddingY,e.chordDiagramStringSpacing=t.chordDiagramStringSpacing,e.chordDiagramFretSpacing=t.chordDiagramFretSpacing,e.chordDiagramNutHeight=t.chordDiagramNutHeight,e.chordDiagramFretHeight=t.chordDiagramFretHeight,e.chordDiagramLineWidth=t.chordDiagramLineWidth,e.tripletFeelBracketPadding=t.tripletFeelBracketPadding,e.accidentalPadding=t.accidentalPadding,e.preBeatGlyphSpacing=t.preBeatGlyphSpacing,e.tempoNoteScale=t.tempoNoteScale,e.tuningGlyphCircleNumberScale=t.tuningGlyphCircleNumberScale,e.tuningGlyphStringColumnScale=t.tuningGlyphStringColumnScale,e.tuningGlyphStringRowPadding=t.tuningGlyphStringRowPadding,e.directionsScale=t.directionsScale,e.multiVoiceDisplacedNoteHeadSpacing=t.multiVoiceDisplacedNoteHeadSpacing,e.stemFlagHeight=new Map(t.stemFlagHeight),e}},ti=class{static parseEnum(t,e){switch(typeof t){case"string":const s=Number.parseInt(t,10);return Number.isNaN(s)?e[Object.keys(e).find(e=>e.toLowerCase()===t.toLowerCase())]:s;case"number":return t;case"undefined":case"object":return}throw new a(r.Format,`Could not parse enum value '${t}'`)}static parseEnumExact(t,e){if(t in e)return e[t]}static forEach(t,e){if(t instanceof Map)t.forEach(e);else if("object"==typeof t)for(const s in t)e(t[s],s)}static getValue(t,e){return t instanceof Map?t.get(e):"object"==typeof t?t[e]:null}},ei=class{topY=0;bottomY=0;x=0},si=class t{static Xl;static GraceScale=.75;static get bravuraDefaults(){let e=t.Xl;return e||(e=new t,e.fillFromSmufl(t.bravuraMetadata),t.Xl=e),Zs.clone(e)}musicFontSize=0;oneStaffSpace=0;tabLineSpacing=0;arrowShaftThickness=0;barlineSeparation=0;beamSpacing=0;beamThickness=0;bracketThickness=0;dashedBarlineDashLength=0;dashedBarlineGapLength=0;dashedBarlineThickness=0;hairpinThickness=0;legerLineThickness=0;legerLineExtension=0;octaveLineThickness=0;pedalLineThickness=0;repeatBarlineDotSeparation=0;repeatEndingLineThickness=0;slurMidpointThickness=0;staffLineThickness=0;stemThickness=0;thickBarlineThickness=0;thinBarlineThickness=0;thinThickBarlineSeparation=0;tieMidpointThickness=0;tupletBracketThickness=0;stemUp=new Map;stemDown=new Map;repeatOffsetX=new Map;standardStemLength=0;stemFlagOffsets=new Map;glyphTop=new Map;glyphBottom=new Map;glyphWidths=new Map;glyphHeights=new Map;hasSymbol(t){return this.glyphWidths.get(t)>0&&this.glyphHeights.get(t)>0}fillFromSmufl(e,s=36){this.musicFontSize=s,this.oneStaffSpace=s/4,this.tabLineSpacing=Math.floor(1.5*this.oneStaffSpace),this.arrowShaftThickness=e.engravingDefaults.arrowShaftThickness*this.oneStaffSpace,this.barlineSeparation=e.engravingDefaults.barlineSeparation*this.oneStaffSpace,this.beamSpacing=e.engravingDefaults.beamSpacing*this.oneStaffSpace,this.beamThickness=e.engravingDefaults.beamThickness*this.oneStaffSpace,this.bracketThickness=e.engravingDefaults.bracketThickness*this.oneStaffSpace,this.dashedBarlineDashLength=e.engravingDefaults.dashedBarlineDashLength*this.oneStaffSpace,this.dashedBarlineGapLength=e.engravingDefaults.dashedBarlineGapLength*this.oneStaffSpace,this.dashedBarlineThickness=e.engravingDefaults.dashedBarlineThickness*this.oneStaffSpace,this.hairpinThickness=e.engravingDefaults.hairpinThickness*this.oneStaffSpace,this.legerLineExtension=e.engravingDefaults.legerLineExtension*this.oneStaffSpace,this.legerLineThickness=e.engravingDefaults.legerLineThickness*this.oneStaffSpace,this.octaveLineThickness=e.engravingDefaults.octaveLineThickness*this.oneStaffSpace,this.pedalLineThickness=e.engravingDefaults.pedalLineThickness*this.oneStaffSpace,this.repeatBarlineDotSeparation=e.engravingDefaults.repeatBarlineDotSeparation*this.oneStaffSpace,this.repeatEndingLineThickness=e.engravingDefaults.repeatEndingLineThickness*this.oneStaffSpace,this.slurMidpointThickness=e.engravingDefaults.slurMidpointThickness*this.oneStaffSpace,this.staffLineThickness=e.engravingDefaults.staffLineThickness*this.oneStaffSpace,this.stemThickness=e.engravingDefaults.stemThickness*this.oneStaffSpace,this.thickBarlineThickness=e.engravingDefaults.thickBarlineThickness*this.oneStaffSpace,this.thinBarlineThickness=e.engravingDefaults.thinBarlineThickness*this.oneStaffSpace,"number"==typeof e.engravingDefaults.thinThickBarlineSeparation?this.thinThickBarlineSeparation=e.engravingDefaults.thinThickBarlineSeparation*this.oneStaffSpace:this.thinThickBarlineSeparation=e.engravingDefaults.barlineSeparation*this.oneStaffSpace,this.tieMidpointThickness=e.engravingDefaults.tieMidpointThickness*this.oneStaffSpace,this.tupletBracketThickness=e.engravingDefaults.tupletBracketThickness*this.oneStaffSpace;const i=3*this.oneStaffSpace;this.standardStemLength=i,this.stemFlagOffsets.set(w.QuadrupleWhole,0),this.stemFlagOffsets.set(w.DoubleWhole,0),this.stemFlagOffsets.set(w.Whole,0),this.stemFlagOffsets.set(w.Half,0),this.stemFlagOffsets.set(w.Quarter,0),this.stemFlagOffsets.set(w.Eighth,0),this.stemFlagOffsets.set(w.Sixteenth,0),this.stemFlagOffsets.set(w.ThirtySecond,0),this.stemFlagOffsets.set(w.SixtyFourth,0),this.stemFlagOffsets.set(w.OneHundredTwentyEighth,0),this.stemFlagOffsets.set(w.TwoHundredFiftySixth,0),this.stemFlagHeight.set(w.QuadrupleWhole,0),this.stemFlagHeight.set(w.DoubleWhole,0),this.stemFlagHeight.set(w.Whole,0),this.stemFlagHeight.set(w.Half,0),this.stemFlagHeight.set(w.Quarter,0),this.stemFlagHeight.set(w.Eighth,1*this.oneStaffSpace),this.stemFlagHeight.set(w.Sixteenth,1.5*this.oneStaffSpace),this.stemFlagHeight.set(w.ThirtySecond,2*this.oneStaffSpace),this.stemFlagHeight.set(w.SixtyFourth,3*this.oneStaffSpace),this.stemFlagHeight.set(w.OneHundredTwentyEighth,3.5*this.oneStaffSpace),this.stemFlagHeight.set(w.TwoHundredFiftySixth,4.2*this.oneStaffSpace);for(const[s,i]of Object.entries(e.glyphsWithAnchors)){const e=t.jl(s);if(e){if(i.stemDownNW){const t=new ei;t.x=i.stemDownNW[0]*this.oneStaffSpace,t.topY=i.stemDownNW[1]*this.oneStaffSpace,i.stemDownSW?t.bottomY=i.stemDownSW[1]*this.oneStaffSpace:t.bottomY=0,this.stemDown.set(e,t)}if(i.stemUpSE){const t=new ei,s=i.stemUpSE[0]*this.oneStaffSpace;t.bottomY=i.stemUpSE[1]*this.oneStaffSpace,i.stemUpNW?(t.x=i.stemUpNW[0]*this.oneStaffSpace,t.topY=i.stemUpNW[1]*this.oneStaffSpace):(t.x=s-this.stemThickness,t.topY=0),this.stemUp.set(e,t)}if(i.repeatOffset&&this.repeatOffsetX.set(e,i.repeatOffset[0]*this.oneStaffSpace),i.stemUpNW){const t=i.stemUpNW[1]*this.oneStaffSpace;switch(e){case xt.Flag8thUp:this.stemFlagOffsets.set(w.Eighth,t);break;case xt.Flag16thUp:this.stemFlagOffsets.set(w.Sixteenth,t);break;case xt.Flag32ndUp:this.stemFlagOffsets.set(w.ThirtySecond,t);break;case xt.Flag64thUp:this.stemFlagOffsets.set(w.SixtyFourth,t);break;case xt.Flag128thUp:this.stemFlagOffsets.set(w.OneHundredTwentyEighth,t);break;case xt.Flag256thUp:this.stemFlagOffsets.set(w.TwoHundredFiftySixth,t)}}}}const n=new Set,r=e.glyphBBoxes;if(r)for(const[e,s]of Object.entries(r)){const i=t.jl(e);i&&(n.add(i),this.glyphTop.set(i,s.bBoxNE[1]*this.oneStaffSpace),this.glyphBottom.set(i,s.bBoxSW[1]*this.oneStaffSpace),this.glyphWidths.set(i,(s.bBoxNE[0]-s.bBoxSW[0])*this.oneStaffSpace),this.glyphHeights.set(i,(s.bBoxNE[1]-s.bBoxSW[1])*this.oneStaffSpace))}const a=new Set([xt.None,xt.Space,xt.NoteheadNull]);for(const t of Tt.getAllMusicFontSymbols())n.has(t)||(a.has(t)||O.warning("SmuFL",`The provided SmuFL font is missing the glyph ${xt[t]} needed by alphaTab, the music notation might not show all details`),this.glyphTop.set(t,0),this.glyphBottom.set(t,0),this.glyphWidths.set(t,0),this.glyphHeights.set(t,0));this.numberedBarRendererBarSize=2*this.staffLineThickness,this.numberedBarRendererBarSpacing=this.beamSpacing,this.preNoteEffectPadding=.4*this.oneStaffSpace,this.postNoteEffectPadding=.2*this.oneStaffSpace,this.lineRangedGlyphDashGap=.5*this.oneStaffSpace,this.lineRangedGlyphDashSize=1*this.oneStaffSpace,this.numberedDashGlyphPadding=.3*this.oneStaffSpace,this.numberedDashGlyphPadding=.3*this.oneStaffSpace,this.stringNumberCirclePadding=.3*this.oneStaffSpace,this.rowContainerPadding=Math.ceil(.3*this.oneStaffSpace),this.rowContainerGap=Math.ceil(1*this.oneStaffSpace),this.onNoteEffectPadding=.2*this.oneStaffSpace,this.alternateEndingsPadding=.3*this.oneStaffSpace,this.sustainPedalLinePadding=.5*this.oneStaffSpace,this.tieHeight=1.2*this.oneStaffSpace,this.beatTimerPadding=.22*this.oneStaffSpace,this.bendNoteHeadElementPadding=.22*this.oneStaffSpace,this.ghostParenthesisWidth=.6*this.oneStaffSpace,this.ghostParenthesisPadding=.3*this.oneStaffSpace,this.brokenBeamWidth=1*this.oneStaffSpace,this.tabWhammyTextPadding=.4*this.oneStaffSpace,this.tabWhammyDashSize=.4*this.oneStaffSpace,this.tabBendDashSize=.4*this.oneStaffSpace,this.songBookWhammyDipHeight=.6*this.oneStaffSpace,this.tabWhammyPerHalfHeight=.6*this.oneStaffSpace,this.tabBendStaffPadding=.5*this.oneStaffSpace,this.tabBendPerValueHeight=.6*this.oneStaffSpace,this.tabBendLabelPadding=.3*this.oneStaffSpace,this.leftHandTabTieWidth=2.2*this.oneStaffSpace,this.numberedDashGlyphWidth=1.5*this.oneStaffSpace,this.deadSlappedLineWidth=.25*this.oneStaffSpace,this.simpleSlideWidth=1.3*this.oneStaffSpace,this.simpleSlideHeight=.3*this.oneStaffSpace,this.chordDiagramPaddingX=Math.ceil(.5*this.oneStaffSpace),this.chordDiagramPaddingY=Math.ceil(.2*this.oneStaffSpace),this.chordDiagramStringSpacing=Math.ceil(1.1*this.oneStaffSpace),this.chordDiagramFretSpacing=Math.ceil(1.3*this.oneStaffSpace),this.chordDiagramNutHeight=Math.ceil(.33*this.oneStaffSpace),this.chordDiagramFretHeight=Math.ceil(.1*this.oneStaffSpace),this.chordDiagramLineWidth=Math.ceil(.11*this.oneStaffSpace),this.tripletFeelBracketPadding=.2*this.oneStaffSpace,this.accidentalPadding=.1*this.oneStaffSpace,this.preBeatGlyphSpacing=.5*this.oneStaffSpace,this.multiVoiceDisplacedNoteHeadSpacing=.2*this.oneStaffSpace,this.tuningGlyphStringRowPadding=.2*this.oneStaffSpace}static smuflNameToGlyphNameMapping=new Map([["4stringTabClef","FourStringTabClef"],["6stringTabClef","SixStringTabClef"]]);static jl(e){const s=t.smuflNameToGlyphNameMapping.has(e)?t.smuflNameToGlyphNameMapping.get(e):e.substring(0,1).toUpperCase()+e.substring(1);return ti.parseEnumExact(s,xt)}numberedBarRendererBarSize=0;numberedBarRendererBarSpacing=0;numberedDashGlyphPadding=0;numberedDashGlyphWidth=0;lineRangedGlyphDashGap=0;lineRangedGlyphDashSize=0;preNoteEffectPadding=0;postNoteEffectPadding=0;onNoteEffectPadding=0;stringNumberCirclePadding=0;rowContainerPadding=0;rowContainerGap=0;alternateEndingsPadding=0;sustainPedalLinePadding=0;tieHeight=0;beatTimerPadding=0;bendNoteHeadElementPadding=0;ghostParenthesisWidth=0;ghostParenthesisPadding=0;brokenBeamWidth=0;tabWhammyTextPadding=0;tabWhammyPerHalfHeight=0;tabWhammyDashSize=0;songBookWhammyDipHeight=0;deadSlappedLineWidth=0;leftHandTabTieWidth=0;tabBendDashSize=0;tabBendStaffPadding=0;tabBendPerValueHeight=0;tabBendLabelPadding=0;simpleSlideWidth=0;simpleSlideHeight=0;chordDiagramPaddingX=0;chordDiagramPaddingY=0;chordDiagramStringSpacing=0;chordDiagramFretSpacing=0;chordDiagramNutHeight=0;chordDiagramFretHeight=0;chordDiagramLineWidth=0;tripletFeelBracketPadding=0;accidentalPadding=0;preBeatGlyphSpacing=0;tempoNoteScale=.7;tuningGlyphCircleNumberScale=.7;tuningGlyphStringColumnScale=1.5;tuningGlyphStringRowPadding=0;directionsScale=.6;multiVoiceDisplacedNoteHeadSpacing=0;getStemLength(t,e){return this.standardStemLength+(e?this.stemFlagOffsets.get(t):0)}stemFlagHeight=new Map;static bravuraMetadata={engravingDefaults:{arrowShaftThickness:.16,barlineSeparation:.4,beamSpacing:.25,beamThickness:.5,bracketThickness:.5,dashedBarlineDashLength:.5,dashedBarlineGapLength:.25,dashedBarlineThickness:.16,hairpinThickness:.16,legerLineExtension:.4,legerLineThickness:.16,lyricLineThickness:.16,octaveLineThickness:.16,pedalLineThickness:.16,repeatBarlineDotSeparation:.16,repeatEndingLineThickness:.16,slurEndpointThickness:.1,slurMidpointThickness:.22,staffLineThickness:.13,stemThickness:.12,subBracketThickness:.16,textEnclosureThickness:.16,thickBarlineThickness:.5,thinBarlineThickness:.16,tieEndpointThickness:.1,tieMidpointThickness:.22,thinThickBarlineSeparation:.4,tupletBracketThickness:.16},glyphBBoxes:{FourStringTabClef:{bBoxNE:[1.088,2.016],bBoxSW:[-.012,-2.032]},SixStringTabClef:{bBoxNE:[1.632,3.056],bBoxSW:[-.012,-2.992]},accidentalDoubleFlat:{bBoxNE:[1.644,1.748],bBoxSW:[0,-.7]},accidentalDoubleSharp:{bBoxNE:[.988,.508],bBoxSW:[0,-.5]},accidentalFlat:{bBoxNE:[.904,1.756],bBoxSW:[0,-.7]},accidentalNatural:{bBoxNE:[.672,1.364],bBoxSW:[0,-1.34]},accidentalQuarterToneFlatArrowUp:{bBoxNE:[.992,2.316],bBoxSW:[-.168,-.708]},accidentalQuarterToneSharpNaturalArrowUp:{bBoxNE:[.848,2.188],bBoxSW:[-.104,-1.36]},accidentalSharp:{bBoxNE:[.996,1.4],bBoxSW:[0,-1.392]},accidentalThreeQuarterTonesSharpArrowUp:{bBoxNE:[1.1,2.12],bBoxSW:[0,-1.388]},arrowheadBlackDown:{bBoxNE:[.912,1.196],bBoxSW:[0,0]},arrowheadBlackUp:{bBoxNE:[.912,1.196],bBoxSW:[0,0]},articAccentAbove:{bBoxNE:[1.356,.98],bBoxSW:[0,.004]},articAccentBelow:{bBoxNE:[1.356,0],bBoxSW:[0,-.976]},articMarcatoAbove:{bBoxNE:[.94,1.012],bBoxSW:[-.004,-.004]},articMarcatoBelow:{bBoxNE:[.94,0],bBoxSW:[-.004,-1.016]},articStaccatoAbove:{bBoxNE:[.336,.336],bBoxSW:[0,0]},articStaccatoBelow:{bBoxNE:[.336,0],bBoxSW:[0,-.336]},articTenutoAbove:{bBoxNE:[1.352,.192],bBoxSW:[-.004,0]},articTenutoBelow:{bBoxNE:[1.352,0],bBoxSW:[-.004,-.192]},augmentationDot:{bBoxNE:[.4,.2],bBoxSW:[0,-.2]},brace:{bBoxNE:[.328,3.988],bBoxSW:[.008,0]},bracketBottom:{bBoxNE:[1.876,0],bBoxSW:[0,-1.18]},bracketTop:{bBoxNE:[1.876,1.18],bBoxSW:[0,0]},buzzRoll:{bBoxNE:[.624,.464],bBoxSW:[-.62,-.464]},cClef:{bBoxNE:[2.796,2.024],bBoxSW:[0,-2.024]},cClef8vb:{bBoxNE:[2.796,2.024],bBoxSW:[0,-2.964]},clef15:{bBoxNE:[1.436,1.02],bBoxSW:[0,-.012]},clef8:{bBoxNE:[.82,.988],bBoxSW:[0,0]},coda:{bBoxNE:[3.82,3.592],bBoxSW:[-.016,-.632]},dynamicCrescendoHairpin:{bBoxNE:[2.944,1.424],bBoxSW:[.016,.372]},dynamicFF:{bBoxNE:[2.44,1.776],bBoxSW:[-.54,-.608]},dynamicFFF:{bBoxNE:[3.32,1.776],bBoxSW:[-.62,-.608]},dynamicFFFF:{bBoxNE:[4.28,1.776],bBoxSW:[-.62,-.608]},dynamicFFFFF:{bBoxNE:[5.24,1.776],bBoxSW:[-.62,-.608]},dynamicFFFFFF:{bBoxNE:[6.2,1.776],bBoxSW:[-.62,-.608]},dynamicForte:{bBoxNE:[1.456,1.776],bBoxSW:[-.564,-.608]},dynamicFortePiano:{bBoxNE:[2.476,1.776],bBoxSW:[-.564,-.608]},dynamicForzando:{bBoxNE:[1.988,1.776],bBoxSW:[-.564,-.608]},dynamicMF:{bBoxNE:[3.272,1.724],bBoxSW:[-.08,-.66]},dynamicMP:{bBoxNE:[3.3,1.096],bBoxSW:[-.08,-.568]},dynamicNiente:{bBoxNE:[1.232,1.096],bBoxSW:[-.092,-.04]},dynamicPF:{bBoxNE:[3.08,1.776],bBoxSW:[-.288,-.608]},dynamicPP:{bBoxNE:[2.912,1.096],bBoxSW:[-.328,-.568]},dynamicPPP:{bBoxNE:[4.292,1.096],bBoxSW:[-.368,-.568]},dynamicPPPP:{bBoxNE:[5.672,1.096],bBoxSW:[-.408,-.568]},dynamicPPPPP:{bBoxNE:[7.092,1.096],bBoxSW:[-.408,-.568]},dynamicPPPPPP:{bBoxNE:[8.512,1.096],bBoxSW:[-.408,-.568]},dynamicPiano:{bBoxNE:[1.464,1.096],bBoxSW:[-.356,-.568]},dynamicRinforzando1:{bBoxNE:[2.5,1.776],bBoxSW:[-.08,-.608]},dynamicRinforzando2:{bBoxNE:[2.976,1.776],bBoxSW:[-.08,-.608]},dynamicSforzando1:{bBoxNE:[2.416,1.776],bBoxSW:[0,-.608]},dynamicSforzandoPianissimo:{bBoxNE:[4.796,1.776],bBoxSW:[0,-.608]},dynamicSforzandoPiano:{bBoxNE:[3.38,1.776],bBoxSW:[0,-.608]},dynamicSforzato:{bBoxNE:[2.932,1.776],bBoxSW:[0,-.608]},dynamicSforzatoFF:{bBoxNE:[3.856,1.776],bBoxSW:[0,-.608]},dynamicSforzatoPiano:{bBoxNE:[4.304,1.776],bBoxSW:[0,-.608]},fClef:{bBoxNE:[2.736,1.048],bBoxSW:[-.02,-2.54]},fClef15ma:{bBoxNE:[2.736,1.984],bBoxSW:[-.02,-2.54]},fClef15mb:{bBoxNE:[2.736,1.048],bBoxSW:[-.02,-2.968]},fClef8va:{bBoxNE:[2.736,1.98],bBoxSW:[-.02,-2.54]},fClef8vb:{bBoxNE:[2.736,1.048],bBoxSW:[-.02,-2.976]},fermataAbove:{bBoxNE:[2.42,1.316],bBoxSW:[.012,-.012]},fermataLongAbove:{bBoxNE:[2.412,1.332],bBoxSW:[0,-.004]},fermataShortAbove:{bBoxNE:[2.416,1.364],bBoxSW:[0,0]},fingering0:{bBoxNE:[.94,1.004],bBoxSW:[.08,-.004]},fingering1:{bBoxNE:[.548,1.016],bBoxSW:[.08,0]},fingering2:{bBoxNE:[.888,1.012],bBoxSW:[.08,-.012]},fingering3:{bBoxNE:[.82,1.008],bBoxSW:[.08,0]},fingering4:{bBoxNE:[.864,1.012],bBoxSW:[.08,.004]},fingering5:{bBoxNE:[.82,1.032],bBoxSW:[.08,0]},fingeringALower:{bBoxNE:[1.068,1.032],bBoxSW:[0,-.02]},fingeringCLower:{bBoxNE:[.888,1.044],bBoxSW:[0,-.028]},fingeringILower:{bBoxNE:[.656,1.54],bBoxSW:[-.052,-.028]},fingeringMLower:{bBoxNE:[1.66,1.028],bBoxSW:[-.032,-.016]},fingeringPLower:{bBoxNE:[1.088,1.028],bBoxSW:[-.216,-.612]},fingeringTLower:{bBoxNE:[.604,1.484],bBoxSW:[0,-.028]},flag128thDown:{bBoxNE:[1.092,3.248],bBoxSW:[0,-2.32]},flag128thUp:{bBoxNE:[1.044,2.132],bBoxSW:[0,-3.248]},flag16thDown:{bBoxNE:[1.1635806326044895,3.2480256],bBoxSW:[0,-.036]},flag16thUp:{bBoxNE:[1.116,.008],bBoxSW:[0,-3.252]},flag256thDown:{bBoxNE:[1.196,3.252],bBoxSW:[0,-3.004]},flag256thUp:{bBoxNE:[1.056,2.816],bBoxSW:[0,-3.248]},flag32ndDown:{bBoxNE:[1.092,3.248],bBoxSW:[0,-.688]},flag32ndUp:{bBoxNE:[1.044,.596],bBoxSW:[0,-3.248]},flag64thDown:{bBoxNE:[1.092,3.248],bBoxSW:[0,-1.504]},flag64thUp:{bBoxNE:[1.044,1.388],bBoxSW:[0,-3.248]},flag8thDown:{bBoxNE:[1.224,3.232896633157715],bBoxSW:[0,-.056]},flag8thUp:{bBoxNE:[1.056,.036],bBoxSW:[0,-3.240768470618394]},fretboardFilledCircle:{bBoxNE:[.564,.564],bBoxSW:[0,0]},fretboardO:{bBoxNE:[.564,.564],bBoxSW:[0,0]},fretboardX:{bBoxNE:[.596,.596],bBoxSW:[0,0]},gClef:{bBoxNE:[2.684,4.392],bBoxSW:[0,-2.632]},gClef15ma:{bBoxNE:[2.684,5.276],bBoxSW:[0,-2.632]},gClef15mb:{bBoxNE:[2.684,4.392],bBoxSW:[0,-3.524]},gClef8va:{bBoxNE:[2.684,5.28],bBoxSW:[0,-2.632]},gClef8vb:{bBoxNE:[2.684,4.392],bBoxSW:[0,-3.512]},graceNoteSlashStemDown:{bBoxNE:[2.02,0],bBoxSW:[0,-1.604]},graceNoteSlashStemUp:{bBoxNE:[2.02,1.604],bBoxSW:[0,0]},guitarClosePedal:{bBoxNE:[1.144,1.14],bBoxSW:[0,-.004]},guitarFadeIn:{bBoxNE:[1.448,1.46],bBoxSW:[0,0]},guitarFadeOut:{bBoxNE:[1.448,1.46],bBoxSW:[0,0]},guitarGolpe:{bBoxNE:[1.08,1.128],bBoxSW:[.004,0]},guitarLeftHandTapping:{bBoxNE:[1.588,1.364],bBoxSW:[0,-.224]},guitarOpenPedal:{bBoxNE:[1.144,1.144],bBoxSW:[0,0]},guitarString0:{bBoxNE:[2.164,2.156],bBoxSW:[.004,0]},guitarString1:{bBoxNE:[2.16,2.156],bBoxSW:[0,0]},guitarString2:{bBoxNE:[2.16,2.156],bBoxSW:[0,0]},guitarString3:{bBoxNE:[2.16,2.156],bBoxSW:[0,0]},guitarString4:{bBoxNE:[2.164,2.156],bBoxSW:[.004,0]},guitarString5:{bBoxNE:[2.16,2.156],bBoxSW:[0,0]},guitarString6:{bBoxNE:[2.16,2.156],bBoxSW:[0,0]},guitarString7:{bBoxNE:[2.16,2.156],bBoxSW:[0,0]},guitarString8:{bBoxNE:[2.16,2.156],bBoxSW:[0,0]},guitarString9:{bBoxNE:[2.16,2.156],bBoxSW:[0,0]},guitarVibratoStroke:{bBoxNE:[.668,.476],bBoxSW:[-.056,0]},guitarVolumeSwell:{bBoxNE:[2.896,1.46],bBoxSW:[0,0]},guitarWideVibratoStroke:{bBoxNE:[.908,.896],bBoxSW:[-.096,0]},keyboardPedalPed:{bBoxNE:[4.076,2.22],bBoxSW:[0,-.032]},keyboardPedalUp:{bBoxNE:[1.8,1.8],bBoxSW:[0,0]},metAugmentationDot:{bBoxNE:[.4,.2],bBoxSW:[0,-.2]},metNote8thUp:{bBoxNE:[2.132,2.784],bBoxSW:[0,-.564]},metNoteQuarterUp:{bBoxNE:[1.328,2.752],bBoxSW:[0,-.564]},note8thUp:{bBoxNE:[2.264,3.492],bBoxSW:[0,-.552]},noteQuarterUp:{bBoxNE:[1.328,3.5],bBoxSW:[0,-.564]},noteShapeDiamondBlack:{bBoxNE:[1.444,.548],bBoxSW:[0,-.552]},noteShapeDiamondWhite:{bBoxNE:[1.444,.544],bBoxSW:[0,-.556]},noteShapeMoonBlack:{bBoxNE:[1.444,.5],bBoxSW:[0,-.5]},noteShapeMoonWhite:{bBoxNE:[1.444,.5],bBoxSW:[0,-.5]},noteShapeRoundBlack:{bBoxNE:[1.456,.552],bBoxSW:[0,-.552]},noteShapeRoundWhite:{bBoxNE:[1.464,.548],bBoxSW:[0,-.548]},noteShapeSquareBlack:{bBoxNE:[1.44,.46],bBoxSW:[0,-.46]},noteShapeSquareWhite:{bBoxNE:[1.44,.46],bBoxSW:[0,-.46]},noteShapeTriangleLeftBlack:{bBoxNE:[1.44,.5],bBoxSW:[0,-.5]},noteShapeTriangleLeftWhite:{bBoxNE:[1.44,.5],bBoxSW:[0,-.5]},noteShapeTriangleRightBlack:{bBoxNE:[1.44,.5],bBoxSW:[0,-.5]},noteShapeTriangleRightWhite:{bBoxNE:[1.44,.5],bBoxSW:[0,-.5]},noteShapeTriangleRoundBlack:{bBoxNE:[1.424,.5],bBoxSW:[0,-.5]},noteShapeTriangleRoundWhite:{bBoxNE:[1.424,.5],bBoxSW:[0,-.5]},noteShapeTriangleUpBlack:{bBoxNE:[1.424,.5],bBoxSW:[0,-.5]},noteShapeTriangleUpWhite:{bBoxNE:[1.424,.5],bBoxSW:[0,-.5]},noteheadBlack:{bBoxNE:[1.18,.5],bBoxSW:[0,-.5]},noteheadCircleSlash:{bBoxNE:[1,.5],bBoxSW:[0,-.5]},noteheadCircleX:{bBoxNE:[.996,.5],bBoxSW:[0,-.5]},noteheadCircleXDoubleWhole:{bBoxNE:[1.688,.62],bBoxSW:[0,-.62]},noteheadCircleXHalf:{bBoxNE:[1,.5],bBoxSW:[0,-.5]},noteheadCircleXWhole:{bBoxNE:[.996,.5],bBoxSW:[0,-.5]},noteheadCircledBlack:{bBoxNE:[1.284,.668],bBoxSW:[-.084,-.684]},noteheadCircledDoubleWhole:{bBoxNE:[2.412,.852],bBoxSW:[0,-.872]},noteheadCircledHalf:{bBoxNE:[1.244,.668],bBoxSW:[-.072,-.648]},noteheadCircledWhole:{bBoxNE:[1.748,.844],bBoxSW:[0,-.9]},noteheadClusterDoubleWhole3rd:{bBoxNE:[2.428,1.62],bBoxSW:[0,-.62]},noteheadClusterHalf3rd:{bBoxNE:[1.264,1.5],bBoxSW:[0,-.5]},noteheadClusterQuarter3rd:{bBoxNE:[1.44,1.5],bBoxSW:[0,-.5]},noteheadClusterWhole3rd:{bBoxNE:[1.7,1.5],bBoxSW:[0,-.5]},noteheadDiamondBlack:{bBoxNE:[1,.5],bBoxSW:[0,-.5]},noteheadDiamondBlackWide:{bBoxNE:[1.4,.5],bBoxSW:[0,-.5]},noteheadDiamondDoubleWhole:{bBoxNE:[1.728,.62],bBoxSW:[0,-.62]},noteheadDiamondHalf:{bBoxNE:[1.004,.5],bBoxSW:[0,-.5]},noteheadDiamondWhite:{bBoxNE:[1,.5],bBoxSW:[0,-.5]},noteheadDiamondWhiteWide:{bBoxNE:[1.4,.5],bBoxSW:[0,-.5]},noteheadDiamondWhole:{bBoxNE:[1.08,.5],bBoxSW:[0,-.5]},noteheadDoubleWhole:{bBoxNE:[2.396,.62],bBoxSW:[0,-.62]},noteheadDoubleWholeSquare:{bBoxNE:[1.664,.792],bBoxSW:[0,-.76]},noteheadHalf:{bBoxNE:[1.18,.5],bBoxSW:[0,-.5]},noteheadHeavyX:{bBoxNE:[1.54,.5],bBoxSW:[0,-.5]},noteheadHeavyXHat:{bBoxNE:[1.828,1.04],bBoxSW:[-.292,-.5]},noteheadParenthesis:{bBoxNE:[1.472,.728],bBoxSW:[-.292,-.72]},noteheadPlusBlack:{bBoxNE:[.996,.5],bBoxSW:[-.004,-.5]},noteheadPlusDoubleWhole:{bBoxNE:[1.892,.62],bBoxSW:[0,-.62]},noteheadPlusHalf:{bBoxNE:[1.044,.5],bBoxSW:[0,-.5]},noteheadPlusWhole:{bBoxNE:[1.14,.5],bBoxSW:[0,-.5]},noteheadRoundWhiteWithDot:{bBoxNE:[1.004,.5],bBoxSW:[0,-.5]},noteheadSlashHorizontalEnds:{bBoxNE:[2.12,1],bBoxSW:[0,-1]},noteheadSlashWhiteHalf:{bBoxNE:[3.12,1],bBoxSW:[0,-1]},noteheadSlashWhiteWhole:{bBoxNE:[3.92,1],bBoxSW:[0,-1]},noteheadSlashedBlack1:{bBoxNE:[1.5,.668],bBoxSW:[-.32,-.66]},noteheadSlashedBlack2:{bBoxNE:[1.504,.672],bBoxSW:[-.316,-.656]},noteheadSlashedDoubleWhole1:{bBoxNE:[2.384,.672],bBoxSW:[0,-.716]},noteheadSlashedDoubleWhole2:{bBoxNE:[2.384,.676],bBoxSW:[0,-.712]},noteheadSlashedHalf1:{bBoxNE:[1.544,.64],bBoxSW:[-.268,-.568]},noteheadSlashedHalf2:{bBoxNE:[1.52,.672],bBoxSW:[-.292,-.536]},noteheadSlashedWhole1:{bBoxNE:[1.732,.592],bBoxSW:[-.088,-.628]},noteheadSlashedWhole2:{bBoxNE:[1.744,.604],bBoxSW:[-.072,-.616]},noteheadSquareBlack:{bBoxNE:[1.252,.5],bBoxSW:[0,-.5]},noteheadSquareBlackLarge:{bBoxNE:[2,1],bBoxSW:[0,-1]},noteheadSquareBlackWhite:{bBoxNE:[2,1],bBoxSW:[0,-1]},noteheadSquareWhite:{bBoxNE:[1.252,.5],bBoxSW:[0,-.5]},noteheadTriangleDownBlack:{bBoxNE:[1.168,.5],bBoxSW:[0,-.5]},noteheadTriangleDownDoubleWhole:{bBoxNE:[1.932,.62],bBoxSW:[0,-.62]},noteheadTriangleDownHalf:{bBoxNE:[1.14,.5],bBoxSW:[0,-.5]},noteheadTriangleDownWhole:{bBoxNE:[1.276,.5],bBoxSW:[0,-.5]},noteheadTriangleRightBlack:{bBoxNE:[1.356,.5],bBoxSW:[0,-.5]},noteheadTriangleRightWhite:{bBoxNE:[1.356,.5],bBoxSW:[0,-.5]},noteheadTriangleUpBlack:{bBoxNE:[1.172,.5],bBoxSW:[0,-.5]},noteheadTriangleUpDoubleWhole:{bBoxNE:[1.932,.62],bBoxSW:[0,-.62]},noteheadTriangleUpHalf:{bBoxNE:[1.14,.5],bBoxSW:[0,-.5]},noteheadTriangleUpWhole:{bBoxNE:[1.276,.5],bBoxSW:[0,-.5]},noteheadWhole:{bBoxNE:[1.688,.5],bBoxSW:[0,-.5]},noteheadXBlack:{bBoxNE:[1.16,.5],bBoxSW:[0,-.5]},noteheadXDoubleWhole:{bBoxNE:[2.184,.62],bBoxSW:[0,-.62]},noteheadXHalf:{bBoxNE:[1.336,.5],bBoxSW:[0,-.5]},noteheadXOrnate:{bBoxNE:[.988,.504],bBoxSW:[0,-.504]},noteheadXWhole:{bBoxNE:[1.508,.5],bBoxSW:[0,-.5]},octaveBaselineB:{bBoxNE:[.796,1.352],bBoxSW:[0,-.04]},octaveBaselineM:{bBoxNE:[1.524,.928],bBoxSW:[0,-.02]},ornamentMordent:{bBoxNE:[2.916,1.276],bBoxSW:[.004,-.292]},ornamentShortTrill:{bBoxNE:[2.9,.98],bBoxSW:[0,0]},ornamentTrill:{bBoxNE:[2.084,1.56],bBoxSW:[0,-.04]},ornamentTurn:{bBoxNE:[1.84,.872],bBoxSW:[0,0]},ornamentTurnInverted:{bBoxNE:[1.828,.872],bBoxSW:[-.012,0]},ottava:{bBoxNE:[1.544,1.852],bBoxSW:[0,-.04]},ottavaAlta:{bBoxNE:[3.54,1.852],bBoxSW:[0,-.04]},ottavaBassaVb:{bBoxNE:[3.184,1.852],bBoxSW:[0,-.04]},pictEdgeOfCymbal:{bBoxNE:[4.828,2.14],bBoxSW:[.004,0]},quindicesima:{bBoxNE:[2.668,1.844],bBoxSW:[0,-.04]},quindicesimaAlta:{bBoxNE:[5.26,1.844],bBoxSW:[0,-.04]},repeat1Bar:{bBoxNE:[2.128,1.116],bBoxSW:[0,-1]},repeat2Bars:{bBoxNE:[3.048,1.116],bBoxSW:[0,-1]},repeatDot:{bBoxNE:[.4,.2],bBoxSW:[0,-.2]},rest128th:{bBoxNE:[1.94,2.756],bBoxSW:[0,-3]},rest16th:{bBoxNE:[1.28,.716],bBoxSW:[0,-2]},rest256th:{bBoxNE:[2.164,2.784],bBoxSW:[0,-4]},rest32nd:{bBoxNE:[1.452,1.704],bBoxSW:[0,-2]},rest64th:{bBoxNE:[1.692,1.72],bBoxSW:[0,-3.012]},rest8th:{bBoxNE:[.988,.696],bBoxSW:[0,-1.004]},restDoubleWhole:{bBoxNE:[.5,1],bBoxSW:[0,0]},restHBarLeft:{bBoxNE:[1.5,1.048],bBoxSW:[0,-1.08]},restHBarMiddle:{bBoxNE:[1.42,.384],bBoxSW:[-.108,-.416]},restHBarRight:{bBoxNE:[1.5,1.048],bBoxSW:[0,-1.08]},restHalf:{bBoxNE:[1.128,.568],bBoxSW:[0,-.008]},restLonga:{bBoxNE:[.5,1],bBoxSW:[0,-.996]},restQuarter:{bBoxNE:[1.08,1.492],bBoxSW:[.004,-1.5]},restWhole:{bBoxNE:[1.128,.036],bBoxSW:[0,-.54]},segno:{bBoxNE:[2.2,3.036],bBoxSW:[.016,-.108]},stringsDownBow:{bBoxNE:[1.248,1.272],bBoxSW:[0,0]},stringsUpBow:{bBoxNE:[.996,1.98],bBoxSW:[.004,.004]},systemDivider:{bBoxNE:[4.232,4.24],bBoxSW:[0,-.272]},textAugmentationDot:{bBoxNE:[.4,.256],bBoxSW:[0,-.144]},textBlackNoteFrac16thLongStem:{bBoxNE:[1.368,3.512],bBoxSW:[0,-.56]},textBlackNoteFrac32ndLongStem:{bBoxNE:[1.368,3.512],bBoxSW:[0,-.56]},textBlackNoteFrac8thLongStem:{bBoxNE:[1.368,3.512],bBoxSW:[0,-.56]},textBlackNoteLongStem:{bBoxNE:[1.328,3.512],bBoxSW:[0,-.564]},textCont16thBeamLongStem:{bBoxNE:[1.368,3.512],bBoxSW:[0,2.264]},textCont32ndBeamLongStem:{bBoxNE:[1.368,3.512],bBoxSW:[0,1.504]},textCont8thBeamLongStem:{bBoxNE:[1.368,3.512],bBoxSW:[0,3.012]},textTuplet3LongStem:{bBoxNE:[.94,5.3],bBoxSW:[0,4.2]},textTupletBracketEndLongStem:{bBoxNE:[1.272,4.764],bBoxSW:[0,3.94]},textTupletBracketStartLongStem:{bBoxNE:[1.272,4.764],bBoxSW:[0,3.94]},timeSig0:{bBoxNE:[1.8,1.004],bBoxSW:[.08,-1]},timeSig1:{bBoxNE:[1.256,1.004],bBoxSW:[.08,-1]},timeSig2:{bBoxNE:[1.704,1.016],bBoxSW:[.08,-1.028]},timeSig3:{bBoxNE:[1.604,.996],bBoxSW:[.08,-1.004]},timeSig4:{bBoxNE:[1.8,1.004],bBoxSW:[.08,-1]},timeSig5:{bBoxNE:[1.532,.984],bBoxSW:[.08,-1.004]},timeSig6:{bBoxNE:[1.656,1.004],bBoxSW:[.08,-.996]},timeSig7:{bBoxNE:[1.684,.996],bBoxSW:[.08,-1]},timeSig8:{bBoxNE:[1.664,1.036],bBoxSW:[.08,-1.036]},timeSig9:{bBoxNE:[1.656,1.004],bBoxSW:[.08,-.996]},timeSigCommon:{bBoxNE:[1.696,1.004],bBoxSW:[.02,-.996]},timeSigCutCommon:{bBoxNE:[1.672,1.444],bBoxSW:[0,-1.436]},tremolo1:{bBoxNE:[.6,.376],bBoxSW:[-.6,-.372]},tremolo2:{bBoxNE:[.596,.748],bBoxSW:[-.604,-.748]},tremolo3:{bBoxNE:[.6,1.112],bBoxSW:[-.6,-1.12]},tremolo4:{bBoxNE:[.6,1.496],bBoxSW:[-.6,-1.48]},tremolo5:{bBoxNE:[.6,1.88],bBoxSW:[-.604,-1.84]},tuplet0:{bBoxNE:[1.2731041262817027,1.5],bBoxSW:[-.001204330173715796,-.032]},tuplet1:{bBoxNE:[1.024,1.488],bBoxSW:[.04,0]},tuplet2:{bBoxNE:[1.316,1.5],bBoxSW:[.04,-.024]},tuplet3:{bBoxNE:[1.224,1.5],bBoxSW:[.04,-.032]},tuplet4:{bBoxNE:[1.252,1.488],bBoxSW:[.04,0]},tuplet5:{bBoxNE:[1.308,1.492],bBoxSW:[.04,-.032]},tuplet6:{bBoxNE:[1.256,1.5],bBoxSW:[.04105974105482295,-.032]},tuplet7:{bBoxNE:[1.332,1.488],bBoxSW:[.12,-.016]},tuplet8:{bBoxNE:[1.292,1.5],bBoxSW:[.04,-.032]},tuplet9:{bBoxNE:[1.254940258945177,1.5],bBoxSW:[.04,-.032]},tupletColon:{bBoxNE:[.484,1.072],bBoxSW:[.04,.232]},unpitchedPercussionClef1:{bBoxNE:[1.528,1],bBoxSW:[0,-1]},wiggleSawtooth:{bBoxNE:[3.06,1.06],bBoxSW:[-.068,-1.068]},wiggleSawtoothNarrow:{bBoxNE:[2.06,1.064],bBoxSW:[-.072,-1.064]},wiggleTrill:{bBoxNE:[1.08,.836],bBoxSW:[-.144,.392]},wiggleVibratoMediumFast:{bBoxNE:[1.292,.8],bBoxSW:[-.104,-.164]}},glyphsWithAnchors:{accidentalDoubleFlat:{cutOutNE:[.988,.644],cutOutSE:[1.336,-.396]},accidentalFlat:{cutOutNE:[.252,.656],cutOutSE:[.504,-.476]},accidentalNatural:{cutOutNE:[.192,.776],cutOutSW:[.476,-.828]},accidentalQuarterToneFlatArrowUp:{cutOutNE:[.604,.664],cutOutSE:[.62,-.452]},accidentalQuarterToneSharpNaturalArrowUp:{cutOutSW:[.616,-.868]},accidentalSharp:{cutOutNE:[.84,.896],cutOutNW:[.144,.568],cutOutSE:[.84,-.596],cutOutSW:[.144,-.896]},accidentalThreeQuarterTonesSharpArrowUp:{cutOutNW:[.272,1.304],cutOutSE:[.86,-.584],cutOutSW:[.132,-.888]},dynamicFF:{opticalCenter:[1.852,0]},dynamicFFF:{opticalCenter:[2.472,0]},dynamicFFFF:{opticalCenter:[2.824,0]},dynamicFFFFF:{opticalCenter:[2.976,0]},dynamicFFFFFF:{opticalCenter:[3.504,0]},dynamicForte:{opticalCenter:[1.256,0]},dynamicFortePiano:{opticalCenter:[1.5,0]},dynamicForzando:{opticalCenter:[1.352,0]},dynamicMF:{opticalCenter:[1.796,0]},dynamicMP:{opticalCenter:[1.848,0]},dynamicNiente:{opticalCenter:[.616,0]},dynamicPF:{opticalCenter:[1.68,0]},dynamicPP:{opticalCenter:[1.708,0]},dynamicPPP:{opticalCenter:[2.368,0]},dynamicPPPP:{opticalCenter:[3.004,0]},dynamicPPPPP:{opticalCenter:[3.552,0]},dynamicPPPPPP:{opticalCenter:[4.248,0]},dynamicPiano:{opticalCenter:[1.22,0]},dynamicRinforzando1:{opticalCenter:[1.564,0]},dynamicRinforzando2:{opticalCenter:[2.084,0]},dynamicSforzando1:{opticalCenter:[1.3,0]},dynamicSforzandoPianissimo:{opticalCenter:[1.972,0]},dynamicSforzandoPiano:{opticalCenter:[1.904,0]},dynamicSforzato:{opticalCenter:[1.76,0]},dynamicSforzatoFF:{opticalCenter:[2.276,0]},dynamicSforzatoPiano:{opticalCenter:[1.848,0]},flag128thDown:{stemDownSW:[0,-2.076]},flag128thUp:{stemUpNW:[0,1.9]},flag16thDown:{stemDownSW:[0,.128]},flag16thUp:{stemUpNW:[0,-.088]},flag256thDown:{stemDownSW:[0,-2.812]},flag256thUp:{stemUpNW:[0,2.592]},flag32ndDown:{stemDownSW:[0,-.448]},flag32ndUp:{stemUpNW:[0,.376]},flag64thDown:{stemDownSW:[0,-1.244]},flag64thUp:{stemUpNW:[0,1.172]},flag8thDown:{graceNoteSlashNW:[-.596,2.168],graceNoteSlashSE:[1.328,.628],stemDownSW:[0,.132]},flag8thUp:{graceNoteSlashNE:[1.284,-.796],graceNoteSlashSW:[-.644,-2.456],stemUpNW:[0,-.04]},guitarVibratoStroke:{repeatOffset:[.608,0]},guitarWideVibratoStroke:{repeatOffset:[.82,0]},noteShapeDiamondBlack:{stemDownNW:[0,0],stemUpSE:[1.444,0]},noteShapeDiamondWhite:{stemDownNW:[0,0],stemUpSE:[1.436,0]},noteShapeMoonBlack:{stemDownNW:[0,.068],stemUpSE:[1.44,.068]},noteShapeMoonWhite:{stemDownNW:[0,.072],stemUpSE:[1.444,.068]},noteShapeRoundBlack:{stemDownNW:[0,-.168],stemUpSE:[1.444,.184]},noteShapeRoundWhite:{stemDownNW:[0,-.168],stemUpSE:[1.456,.192]},noteShapeSquareBlack:{stemDownNW:[0,.46],stemUpSE:[1.44,-.46]},noteShapeSquareWhite:{stemDownNW:[0,.46],stemUpSE:[1.44,-.46]},noteShapeTriangleLeftBlack:{stemDownNW:[0,.5],stemUpSE:[1.436,-.5]},noteShapeTriangleLeftWhite:{stemDownNW:[0,.5],stemUpSE:[1.436,-.5]},noteShapeTriangleRightBlack:{stemDownNW:[0,.476],stemUpSE:[1.44,-.5]},noteShapeTriangleRightWhite:{stemDownNW:[0,.476],stemUpSE:[1.44,-.5]},noteShapeTriangleRoundBlack:{stemDownNW:[0,.172],stemUpSE:[1.424,.172]},noteShapeTriangleRoundWhite:{stemDownNW:[0,.172],stemUpSE:[1.424,.172]},noteShapeTriangleUpBlack:{stemDownNW:[0,-.5],stemUpSE:[1.424,-.5]},noteShapeTriangleUpWhite:{stemDownNW:[0,-.5],stemUpSE:[1.424,-.5]},noteheadBlack:{cutOutNW:[.208,.3],cutOutSE:[.94,-.296],splitStemDownNE:[.968,-.248],splitStemDownNW:[.12,-.416],splitStemUpSE:[1.092,.392],splitStemUpSW:[.312,.356],stemDownNW:[0,-.168],stemUpSE:[1.18,.168]},noteheadCircleSlash:{stemDownNW:[.004,0],stemUpSE:[1,0]},noteheadCircleX:{stemDownNW:[0,0],stemUpSE:[.996,0]},noteheadCircleXDoubleWhole:{noteheadOrigin:[.352,0]},noteheadCircleXHalf:{stemDownNW:[0,0],stemUpSE:[1,0]},noteheadCircledBlack:{stemDownNW:[0,-.164],stemUpSE:[1.18,.168]},noteheadCircledDoubleWhole:{noteheadOrigin:[.356,0]},noteheadCircledHalf:{stemDownNW:[0,-.144],stemUpSE:[1.172,.156]},noteheadClusterDoubleWhole3rd:{noteheadOrigin:[.364,0]},noteheadClusterHalf3rd:{stemDownNW:[0,-.164],stemUpSE:[1.264,1.144]},noteheadClusterQuarter3rd:{stemDownNW:[0,.26],stemUpSE:[1.44,.744]},noteheadDiamondBlack:{stemDownNW:[0,0],stemUpSE:[1,0]},noteheadDiamondBlackWide:{stemDownNW:[0,0],stemUpSE:[1.4,0]},noteheadDiamondDoubleWhole:{noteheadOrigin:[.324,0]},noteheadDiamondHalf:{stemDownNW:[0,0],stemUpSE:[1.004,0]},noteheadDiamondWhite:{stemDownNW:[0,0],stemUpSE:[1,0]},noteheadDiamondWhiteWide:{stemDownNW:[0,.004],stemUpSE:[1.4,0]},noteheadDoubleWhole:{noteheadOrigin:[.36,0]},noteheadHalf:{cutOutNW:[.204,.296],cutOutSE:[.98,-.3],splitStemDownNE:[.956,-.3],splitStemDownNW:[.128,-.428],splitStemUpSE:[1.108,.372],splitStemUpSW:[.328,.38],stemDownNW:[0,-.168],stemUpSE:[1.18,.168]},noteheadHeavyX:{stemDownNW:[0,-.436],stemUpSE:[1.54,.44]},noteheadHeavyXHat:{stemDownNW:[0,-.436],stemUpSE:[1.54,.456]},noteheadPlusBlack:{stemDownNW:[-.004,0],stemUpSE:[.996,0]},noteheadPlusDoubleWhole:{noteheadOrigin:[.372,0]},noteheadPlusHalf:{stemDownNW:[0,-.112],stemUpSE:[1.044,.088]},noteheadRoundWhiteWithDot:{stemDownNW:[0,0],stemUpSE:[1.004,0]},noteheadSlashHorizontalEnds:{stemDownNW:[0,-1],stemUpSE:[2.12,1]},noteheadSlashWhiteHalf:{stemDownNW:[0,-1],stemUpSE:[3.12,1]},noteheadSlashedBlack1:{stemDownNW:[0,-.172],stemUpSE:[1.18,.164]},noteheadSlashedBlack2:{stemDownNW:[0,-.172],stemUpSE:[1.18,.164]},noteheadSlashedDoubleWhole1:{noteheadOrigin:[.356,0]},noteheadSlashedDoubleWhole2:{noteheadOrigin:[.356,0]},noteheadSlashedHalf1:{stemDownNW:[0,-.168],stemUpSE:[1.168,.164]},noteheadSlashedHalf2:{stemDownNW:[0,-.164],stemUpSE:[1.172,.168]},noteheadSquareBlack:{stemDownNW:[0,-.5],stemUpSE:[1.252,.5]},noteheadSquareBlackLarge:{stemDownNW:[0,0],stemUpSE:[2,0]},noteheadSquareBlackWhite:{stemDownNW:[0,-1],stemUpSE:[2,1]},noteheadSquareWhite:{stemDownNW:[0,-.5],stemUpSE:[1.252,.5]},noteheadTriangleDownBlack:{stemDownNW:[0,.5],stemUpSE:[1.168,.5]},noteheadTriangleDownDoubleWhole:{noteheadOrigin:[.384,0]},noteheadTriangleDownHalf:{stemDownNW:[0,.464],stemUpSE:[1.14,.464]},noteheadTriangleRightBlack:{stemDownNW:[0,-.5],stemUpSE:[1.356,.5]},noteheadTriangleRightWhite:{stemDownNW:[0,-.5],stemUpSE:[1.356,.5]},noteheadTriangleUpBlack:{stemDownNW:[0,-.5],stemUpSE:[1.172,-.5]},noteheadTriangleUpDoubleWhole:{noteheadOrigin:[.34,0]},noteheadTriangleUpHalf:{stemDownNW:[0,-.46],stemUpSE:[1.14,-.46]},noteheadWhole:{cutOutNW:[.172,.332],cutOutSE:[1.532,-.364]},noteheadXBlack:{stemDownNW:[0,-.44],stemUpSE:[1.16,.444]},noteheadXDoubleWhole:{noteheadOrigin:[.348,0]},noteheadXHalf:{stemDownNW:[0,-.412],stemUpSE:[1.336,.412]},noteheadXOrnate:{stemDownNW:[0,-.312],stemUpSE:[.988,.316]},wiggleSawtooth:{repeatOffset:[2.992,0]},wiggleSawtoothNarrow:{repeatOffset:[1.996,0]},wiggleTrill:{repeatOffset:[.948,0]},wiggleVibratoMediumFast:{repeatOffset:[1.18,0]}}}},ii=class{startPos;endPos;text;constructor(t,e,s){this.text=t,this.startPos=e,this.endPos=s}},ni=class t{style="normal";variant="normal";weight="normal";stretch="normal";lineHeight="normal";size="1rem";families=[];parseOnlyFamilies=!1;Jl;ql=-1;un="";Yl=null;constructor(t){this.un=t,this.Jl=this.Kl(t)}Kl(t){const e=[];let s=0;for(;s<t.length;){let i=s;for(;i<t.length&&" "!==t.charAt(i);)i++;i>s&&e.push(new ii(t.substring(s,i),s,i)),s=i+1}return e}parse(){if(this.Ql(),1===this.Jl.length)switch(this.Yl?.text){case"caption":case"icon":case"menu":case"message-box":case"small-caption":case"status-bar":case"inherit":return}this.parseOnlyFamilies||(this.Zl(),this.tu()),this.eu()}static parseFamilies(e){const s=new t(e);return s.parseOnlyFamilies=!0,s.parse(),s.families}eu(){if(!this.Yl){if(this.parseOnlyFamilies)return;throw new Error("Missing font list")}const t=this.un.substr(this.Yl.startPos).trim();let e=0;for(;e<t.length;){const s=t.charAt(e);if(" "===s||","===s)e++;else if('"'===s||"'"===s){const i=this.su(t,e+1,s);this.families.push(t.substring(e+1,i).split(`\\${s}`).join(s)),e=i+1}else{const s=this.su(t,e+1,",");this.families.push(t.substring(e,s).trim()),e=s+1}}}su(t,e,s){let i=!1;for(;e<t.length;){const n=t.charAt(e);if(!i&&n===s)return e;i=!i&&"\\"===n,e+=1}return t.length}tu(){if(!this.Yl)throw new Error("Missing font size");const t=this.Yl.text.split("/");if(t.length>=3)throw new Error(`Invalid font size '${this.Yl}' specified`);if(this.iu(),t.length>=2)if("/"===t[1]){if(!this.Yl)throw new Error("Missing line-height after font size");this.lineHeight=this.Yl.text,this.iu()}else this.size=t[0],this.lineHeight=t[1];else{if(!(t.length>=1))throw new Error("Missing font size");if(this.size=t[0],this.Yl&&0===this.Yl.text.indexOf("/"))if("/"===this.Yl.text){if(this.iu(),!this.Yl)throw new Error("Missing line-height after font size");this.lineHeight=this.Yl.text,this.iu()}else this.lineHeight=this.Yl.text.substr(1),this.iu()}}iu(){this.ql++,this.ql<this.Jl.length?this.Yl=this.Jl[this.ql]:this.Yl=null}Zl(){let t=!1,e=!1,s=!1,i=3;const n=[];for(;;){if(!this.Yl)return;const r=this.Yl.text;switch(r){case"normal":case"inherit":n.push(r),i--,this.iu();break;case"italic":case"oblique":this.style=r,t=!0,i--,this.iu();break;case"small-caps":this.variant=r,e=!0,i--,this.iu();break;case"bold":case"bolder":case"lighter":case"100":case"200":case"300":case"400":case"500":case"600":case"700":case"800":case"900":this.weight=r,s=!0,i--,this.iu();break;default:return}if(0===i)break}for(;n.length>0;){const i=n.pop();s?e?t||(this.style=i):this.variant=i:this.weight=i}}Ql(){this.ql=-1,this.iu()}static quoteFont(t){return-1===t.indexOf(" ")?t:`"${t.replaceAll('"','\\"')}"`}},ri=function(t){return t[t.Plain=0]="Plain",t[t.Italic=1]="Italic",t}({}),ai=function(t){return t[t.Regular=0]="Regular",t[t.Bold=1]="Bold",t}({}),hi=class t{nu;ru=0;au;hu;ou;zi;Ql(){this.ru=0,this.nu=this.toCssString()}get family(){return this.au[0]}set family(t){this.families=ni.parseFamilies(t)}get families(){return this.au}set families(t){this.au=t,this.Ql()}get size(){return this.zi}set size(t){this.zi=t,this.Ql()}get style(){return this.hu}set style(t){this.hu=t,this.Ql()}get weight(){return this.ou}set weight(t){this.ou=t,this.Ql()}get isBold(){return 1===this.weight}get isItalic(){return 1===this.style}constructor(t,e,s=0,i=0){this.au=ni.parseFamilies(t),this.zi=e,this.hu=s,this.ou=i,this.nu=this.toCssString()}withSize(e){return t.withFamilyList(this.au,e,this.hu,this.ou)}static withFamilyList(e,s,i=0,n=0){const r=new t("",s,i,n);return r.families=e,r}toCssString(t=1){if(!(this.nu&&Math.abs(t-this.ru)<.01)){let e="";this.isBold&&(e+="bold "),this.isItalic&&(e+="italic "),e+=this.size*t,e+="px ",e+=this.families.map(t=>ni.quoteFont(t)).join(", "),this.nu=e,this.ru=t}return this.nu}static fromJson(e){if(e instanceof t)return e;switch(typeof e){case"undefined":default:return;case"object":{const s=e,i=s.get("families"),n=s.get("size"),r=ti.parseEnum(s.get("style"),ri),a=ti.parseEnum(s.get("weight"),ai);return t.withFamilyList(i,n,r,a)}case"string":{const s=new ni(e);s.parse();const i=s.families,n=s.size.toLowerCase();let r=0;switch(n){case"xx-small":r=7;break;case"x-small":r=10;break;case"small":case"smaller":r=13;break;case"medium":r=16;break;case"large":case"larger":r=18;break;case"x-large":r=24;break;case"xx-large":r=32;break;default:try{r=n.endsWith("em")?16*Number.parseFloat(n.substr(0,n.length-2)):n.endsWith("pt")?16*Number.parseFloat(n.substr(0,n.length-2))/12:n.endsWith("px")?Number.parseFloat(n.substr(0,n.length-2)):12}catch{r=12}}let a=0;"italic"===s.style&&(a=1);let h=0;switch(s.weight.toLowerCase()){case"normal":case"lighter":break;default:h=1}return t.withFamilyList(i,r,a,h)}}}static toJson(t){if(!t)return;const e=new Map;return e.set("families",t.families),e.set("size",t.size),e.set("style",t.style),e.set("weight",t.weight),e}},oi=class t{static cu="Arial, sans-serif";static lu="Georgia, serif";static uu=new hi(t.lu,12,ri.Italic);static defaultFonts=new Map([[A.ScoreTitle,new hi(t.lu,32,ri.Plain)],[A.ScoreSubTitle,new hi(t.lu,20,ri.Plain)],[A.ScoreArtist,new hi(t.lu,20,ri.Plain)],[A.ScoreAlbum,new hi(t.lu,20,ri.Plain)],[A.ScoreWords,new hi(t.lu,15,ri.Plain)],[A.ScoreMusic,new hi(t.lu,15,ri.Plain)],[A.ScoreWordsAndMusic,new hi(t.lu,15,ri.Plain)],[A.ScoreCopyright,new hi(t.cu,12,ri.Plain,ai.Bold)],[A.EffectBeatTimer,new hi(t.lu,12,ri.Plain)],[A.EffectDirections,new hi(t.lu,14,ri.Plain)],[A.ChordDiagramFretboardNumbers,new hi(t.cu,11,ri.Plain)],[A.EffectFingering,new hi(t.lu,14,ri.Plain)],[A.EffectMarker,new hi(t.lu,14,ri.Plain,ai.Bold)],[A.EffectCapo,t.uu],[A.EffectFreeTime,t.uu],[A.EffectLyrics,t.uu],[A.EffectTap,t.uu],[A.ChordDiagrams,t.uu],[A.EffectChordNames,t.uu],[A.EffectText,t.uu],[A.EffectPalmMute,t.uu],[A.EffectLetRing,t.uu],[A.EffectBeatBarre,t.uu],[A.EffectTripletFeel,t.uu],[A.EffectHarmonics,t.uu],[A.EffectPickSlide,t.uu],[A.GuitarTuning,t.uu],[A.EffectRasgueado,t.uu],[A.EffectWhammyBar,t.uu],[A.TrackNames,t.uu],[A.RepeatCount,new hi(t.cu,11,ri.Plain)],[A.BarNumber,new hi(t.cu,11,ri.Plain)],[A.ScoreBendSlur,new hi(t.cu,11,ri.Plain)],[A.EffectAlternateEndings,new hi(t.lu,15,ri.Plain)],[A.EffectHammerOnPullOffText,t.uu],[A.EffectSlideText,t.uu]]);smuflFontFamilyName;engravingSettings=si.bravuraDefaults;get copyrightFont(){return this.elementFonts.get(A.ScoreCopyright)}set copyrightFont(t){this.elementFonts.set(A.ScoreCopyright,t)}get titleFont(){return this.elementFonts.get(A.ScoreTitle)}set titleFont(t){this.elementFonts.set(A.ScoreTitle,t)}get subTitleFont(){return this.elementFonts.get(A.ScoreSubTitle)}set subTitleFont(t){this.elementFonts.set(A.ScoreSubTitle,t)}get wordsFont(){return this.elementFonts.get(A.ScoreWords)}set wordsFont(t){this.elementFonts.set(A.ScoreWords,t)}get timerFont(){return this.elementFonts.get(A.EffectBeatTimer)}set timerFont(t){this.elementFonts.set(A.EffectBeatTimer,t)}get directionsFont(){return this.elementFonts.get(A.EffectDirections)}set directionsFont(t){this.elementFonts.set(A.EffectDirections,t)}get fretboardNumberFont(){return this.elementFonts.get(A.ChordDiagramFretboardNumbers)}set fretboardNumberFont(t){this.elementFonts.set(A.ChordDiagramFretboardNumbers,t)}fingeringFont=t.uu;inlineFingeringFont=t.uu;get markerFont(){return this.elementFonts.get(A.EffectMarker)}set markerFont(t){this.elementFonts.set(A.EffectMarker,t)}effectFont=t.uu;get barNumberFont(){return this.elementFonts.get(A.BarNumber)}set barNumberFont(t){this.elementFonts.set(A.BarNumber,t)}elementFonts=new Map;numberedNotationFont=new hi(t.cu,16,ri.Plain);numberedNotationGraceFont=new hi(t.cu,14,ri.Plain);tablatureFont=new hi(t.cu,14,ri.Plain);graceFont=new hi(t.cu,12,ri.Plain);staffLineColor=new Se(165,165,165,255);barSeparatorColor=new Se(34,34,17,255);barNumberColor=new Se(200,0,0,255);mainGlyphColor=new Se(0,0,0,255);secondaryGlyphColor=new Se(0,0,0,100);scoreInfoColor=new Se(0,0,0,255);constructor(){for(const[e,s]of t.defaultFonts)this.elementFonts.set(e,s.withSize(s.size))}getFontForElement(t){let e=A.ScoreWords;switch(t){case bt.Title:e=A.ScoreTitle;break;case bt.SubTitle:e=A.ScoreSubTitle;break;case bt.Artist:e=A.ScoreArtist;break;case bt.Album:e=A.ScoreAlbum;break;case bt.Words:e=A.ScoreWords;break;case bt.Music:e=A.ScoreMusic;break;case bt.WordsAndMusic:e=A.ScoreWordsAndMusic;break;case bt.Copyright:case bt.CopyrightSecondLine:e=A.ScoreCopyright;break;default:e=A.ScoreWords}return this.getFontForNotationElement(e)}getFontForNotationElement(e){return this.elementFonts.has(e)?this.elementFonts.get(e):t.defaultFonts.get(e)}},ci=function(t){return t[t.Default=0]="Default",t[t.ScoreTab=1]="ScoreTab",t[t.Score=2]="Score",t[t.Tab=3]="Tab",t[t.TabMixed=4]="TabMixed",t}({}),li=function(t){return t[t.Automatic=0]="Automatic",t[t.UseModelLayout=1]="UseModelLayout",t}({}),ui=class{scale=1;stretchForce=1;layoutMode=Xs.Page;staveProfile=ci.Default;barsPerRow=-1;startBar=1;barCount=-1;barCountPerPartial=10;justifyLastSystem=!1;resources=new oi;padding=[35,35];firstSystemPaddingTop=0;systemPaddingTop=10;systemPaddingBottom=10;lastSystemPaddingBottom=5;systemLabelPaddingLeft=0;systemLabelPaddingRight=3;accoladeBarPaddingRight=3;firstNotationStaffPaddingTop=0;lastNotationStaffPaddingBottom=0;notationStaffPaddingTop=0;notationStaffPaddingBottom=0;effectStaffPaddingTop=0;effectStaffPaddingBottom=0;firstStaffPaddingLeft=6;staffPaddingLeft=2;effectBandPaddingBottom=2;trackStaffPaddingBetween=5;lyricLinesPaddingBetween=5;systemsLayoutMode=0},di=class{encoding="utf-8";mergePartGroupsInMusicXml=!1;beatTextAsLyrics=!1;maxDecodingBufferSize=128e6},fi=function(t){return t[t.Off=0]="Off",t[t.Continuous=1]="Continuous",t[t.OffScreen=2]="OffScreen",t[t.Smooth=3]="Smooth",t}({}),pi=class{noteWideLength=240;noteWideAmplitude=1;noteSlightLength=360;noteSlightAmplitude=.5;beatWideLength=480;beatWideAmplitude=2;beatSlightLength=480;beatSlightAmplitude=2},bi=class{simpleSlidePitchOffset=6;simpleSlideDurationRatio=.25;shiftSlideDurationRatio=.5},mi=function(t){return t[t.WebAudioAudioWorklets=0]="WebAudioAudioWorklets",t[t.WebAudioScriptProcessor=1]="WebAudioScriptProcessor",t}({}),gi=function(t){return t[t.Disabled=0]="Disabled",t[t.EnabledAutomatic=1]="EnabledAutomatic",t[t.EnabledSynthesizer=2]="EnabledSynthesizer",t[t.EnabledBackingTrack=3]="EnabledBackingTrack",t[t.EnabledExternalMedia=4]="EnabledExternalMedia",t}({}),wi=class{soundFont=null;scrollElement="html,body";outputMode=0;enablePlayer=!1;playerMode=0;enableCursor=!0;enableAnimatedBeatCursor=!0;enableElementHighlighting=!0;enableUserInteraction=!0;scrollOffsetX=0;scrollOffsetY=0;scrollMode=1;scrollSpeed=300;nativeBrowserSmoothScroll=!0;songBookBendDuration=75;songBookDipDuration=150;vibrato=new pi;slide=new bi;playTripletFeel=!0;bufferTimeInMilliseconds=500},yi=class t{static fromJson(e,s){s&&ti.forEach(s,(s,i)=>t.setProperty(e,i.toLowerCase(),s))}static toJson(t){if(!t)return null;const e=new Map;if(e.set("scriptfile",t.scriptFile),e.set("fontdirectory",t.fontDirectory),null!==t.smuflFontSources){const s=new Map;e.set("smuflfontsources",s);for(const[e,i]of t.smuflFontSources)s.set(e.toString(),i)}return e.set("file",t.file),e.set("tex",t.tex),e.set("tracks",t.tracks),e.set("enablelazyloading",t.enableLazyLoading),e.set("engine",t.engine),e.set("loglevel",t.logLevel),e.set("useworkers",t.useWorkers),e.set("includenotebounds",t.includeNoteBounds),e}static setProperty(t,e,s){switch(e){case"scriptfile":return t.scriptFile=s,!0;case"fontdirectory":return t.fontDirectory=s,!0;case"smuflfontsources":return t.smuflFontSources=new Map,ti.forEach(s,(e,s)=>{t.smuflFontSources.set(ti.parseEnum(s,_u),e)}),!0;case"file":return t.file=s,!0;case"tex":return t.tex=s,!0;case"tracks":return t.tracks=s,!0;case"enablelazyloading":return t.enableLazyLoading=s,!0;case"engine":return t.engine=s,!0;case"loglevel":return t.logLevel=ti.parseEnum(s,W),!0;case"useworkers":return t.useWorkers=s,!0;case"includenotebounds":return t.includeNoteBounds=s,!0}return!1}},ki=class t{static fromJson(e,s){s&&ti.forEach(s,(s,i)=>t.setProperty(e,i.toLowerCase(),s))}static toJson(t){if(!t)return null;const e=new Map;return e.set("topy",t.topY),e.set("bottomy",t.bottomY),e.set("x",t.x),e}static setProperty(t,e,s){switch(e){case"topy":return t.topY=s,!0;case"bottomy":return t.bottomY=s,!0;case"x":return t.x=s,!0}return!1}},Si=class t{static fromJson(e,s){s&&ti.forEach(s,(s,i)=>t.setProperty(e,i.toLowerCase(),s))}static toJson(t){if(!t)return null;const e=new Map;e.set("musicfontsize",t.musicFontSize),e.set("onestaffspace",t.oneStaffSpace),e.set("tablinespacing",t.tabLineSpacing),e.set("arrowshaftthickness",t.arrowShaftThickness),e.set("barlineseparation",t.barlineSeparation),e.set("beamspacing",t.beamSpacing),e.set("beamthickness",t.beamThickness),e.set("bracketthickness",t.bracketThickness),e.set("dashedbarlinedashlength",t.dashedBarlineDashLength),e.set("dashedbarlinegaplength",t.dashedBarlineGapLength),e.set("dashedbarlinethickness",t.dashedBarlineThickness),e.set("hairpinthickness",t.hairpinThickness),e.set("legerlinethickness",t.legerLineThickness),e.set("legerlineextension",t.legerLineExtension),e.set("octavelinethickness",t.octaveLineThickness),e.set("pedallinethickness",t.pedalLineThickness),e.set("repeatbarlinedotseparation",t.repeatBarlineDotSeparation),e.set("repeatendinglinethickness",t.repeatEndingLineThickness),e.set("slurmidpointthickness",t.slurMidpointThickness),e.set("stafflinethickness",t.staffLineThickness),e.set("stemthickness",t.stemThickness),e.set("thickbarlinethickness",t.thickBarlineThickness),e.set("thinbarlinethickness",t.thinBarlineThickness),e.set("thinthickbarlineseparation",t.thinThickBarlineSeparation),e.set("tiemidpointthickness",t.tieMidpointThickness),e.set("tupletbracketthickness",t.tupletBracketThickness);{const s=new Map;e.set("stemup",s);for(const[e,i]of t.stemUp)s.set(e.toString(),ki.toJson(i))}{const s=new Map;e.set("stemdown",s);for(const[e,i]of t.stemDown)s.set(e.toString(),ki.toJson(i))}{const s=new Map;e.set("repeatoffsetx",s);for(const[e,i]of t.repeatOffsetX)s.set(e.toString(),i)}e.set("standardstemlength",t.standardStemLength);{const s=new Map;e.set("stemflagoffsets",s);for(const[e,i]of t.stemFlagOffsets)s.set(e.toString(),i)}{const s=new Map;e.set("glyphtop",s);for(const[e,i]of t.glyphTop)s.set(e.toString(),i)}{const s=new Map;e.set("glyphbottom",s);for(const[e,i]of t.glyphBottom)s.set(e.toString(),i)}{const s=new Map;e.set("glyphwidths",s);for(const[e,i]of t.glyphWidths)s.set(e.toString(),i)}{const s=new Map;e.set("glyphheights",s);for(const[e,i]of t.glyphHeights)s.set(e.toString(),i)}e.set("numberedbarrendererbarsize",t.numberedBarRendererBarSize),e.set("numberedbarrendererbarspacing",t.numberedBarRendererBarSpacing),e.set("numbereddashglyphpadding",t.numberedDashGlyphPadding),e.set("numbereddashglyphwidth",t.numberedDashGlyphWidth),e.set("linerangedglyphdashgap",t.lineRangedGlyphDashGap),e.set("linerangedglyphdashsize",t.lineRangedGlyphDashSize),e.set("prenoteeffectpadding",t.preNoteEffectPadding),e.set("postnoteeffectpadding",t.postNoteEffectPadding),e.set("onnoteeffectpadding",t.onNoteEffectPadding),e.set("stringnumbercirclepadding",t.stringNumberCirclePadding),e.set("rowcontainerpadding",t.rowContainerPadding),e.set("rowcontainergap",t.rowContainerGap),e.set("alternateendingspadding",t.alternateEndingsPadding),e.set("sustainpedallinepadding",t.sustainPedalLinePadding),e.set("tieheight",t.tieHeight),e.set("beattimerpadding",t.beatTimerPadding),e.set("bendnoteheadelementpadding",t.bendNoteHeadElementPadding),e.set("ghostparenthesiswidth",t.ghostParenthesisWidth),e.set("ghostparenthesispadding",t.ghostParenthesisPadding),e.set("brokenbeamwidth",t.brokenBeamWidth),e.set("tabwhammytextpadding",t.tabWhammyTextPadding),e.set("tabwhammyperhalfheight",t.tabWhammyPerHalfHeight),e.set("tabwhammydashsize",t.tabWhammyDashSize),e.set("songbookwhammydipheight",t.songBookWhammyDipHeight),e.set("deadslappedlinewidth",t.deadSlappedLineWidth),e.set("lefthandtabtiewidth",t.leftHandTabTieWidth),e.set("tabbenddashsize",t.tabBendDashSize),e.set("tabbendstaffpadding",t.tabBendStaffPadding),e.set("tabbendpervalueheight",t.tabBendPerValueHeight),e.set("tabbendlabelpadding",t.tabBendLabelPadding),e.set("simpleslidewidth",t.simpleSlideWidth),e.set("simpleslideheight",t.simpleSlideHeight),e.set("chorddiagrampaddingx",t.chordDiagramPaddingX),e.set("chorddiagrampaddingy",t.chordDiagramPaddingY),e.set("chorddiagramstringspacing",t.chordDiagramStringSpacing),e.set("chorddiagramfretspacing",t.chordDiagramFretSpacing),e.set("chorddiagramnutheight",t.chordDiagramNutHeight),e.set("chorddiagramfretheight",t.chordDiagramFretHeight),e.set("chorddiagramlinewidth",t.chordDiagramLineWidth),e.set("tripletfeelbracketpadding",t.tripletFeelBracketPadding),e.set("accidentalpadding",t.accidentalPadding),e.set("prebeatglyphspacing",t.preBeatGlyphSpacing),e.set("temponotescale",t.tempoNoteScale),e.set("tuningglyphcirclenumberscale",t.tuningGlyphCircleNumberScale),e.set("tuningglyphstringcolumnscale",t.tuningGlyphStringColumnScale),e.set("tuningglyphstringrowpadding",t.tuningGlyphStringRowPadding),e.set("directionsscale",t.directionsScale),e.set("multivoicedisplacednoteheadspacing",t.multiVoiceDisplacedNoteHeadSpacing);{const s=new Map;e.set("stemflagheight",s);for(const[e,i]of t.stemFlagHeight)s.set(e.toString(),i)}return e}static setProperty(t,e,s){switch(e){case"musicfontsize":return t.musicFontSize=s,!0;case"onestaffspace":return t.oneStaffSpace=s,!0;case"tablinespacing":return t.tabLineSpacing=s,!0;case"arrowshaftthickness":return t.arrowShaftThickness=s,!0;case"barlineseparation":return t.barlineSeparation=s,!0;case"beamspacing":return t.beamSpacing=s,!0;case"beamthickness":return t.beamThickness=s,!0;case"bracketthickness":return t.bracketThickness=s,!0;case"dashedbarlinedashlength":return t.dashedBarlineDashLength=s,!0;case"dashedbarlinegaplength":return t.dashedBarlineGapLength=s,!0;case"dashedbarlinethickness":return t.dashedBarlineThickness=s,!0;case"hairpinthickness":return t.hairpinThickness=s,!0;case"legerlinethickness":return t.legerLineThickness=s,!0;case"legerlineextension":return t.legerLineExtension=s,!0;case"octavelinethickness":return t.octaveLineThickness=s,!0;case"pedallinethickness":return t.pedalLineThickness=s,!0;case"repeatbarlinedotseparation":return t.repeatBarlineDotSeparation=s,!0;case"repeatendinglinethickness":return t.repeatEndingLineThickness=s,!0;case"slurmidpointthickness":return t.slurMidpointThickness=s,!0;case"stafflinethickness":return t.staffLineThickness=s,!0;case"stemthickness":return t.stemThickness=s,!0;case"thickbarlinethickness":return t.thickBarlineThickness=s,!0;case"thinbarlinethickness":return t.thinBarlineThickness=s,!0;case"thinthickbarlineseparation":return t.thinThickBarlineSeparation=s,!0;case"tiemidpointthickness":return t.tieMidpointThickness=s,!0;case"tupletbracketthickness":return t.tupletBracketThickness=s,!0;case"stemup":return t.stemUp=new Map,ti.forEach(s,(e,s)=>{const i=new ei;ki.fromJson(i,e),t.stemUp.set(ti.parseEnum(s,xt),i)}),!0;case"stemdown":return t.stemDown=new Map,ti.forEach(s,(e,s)=>{const i=new ei;ki.fromJson(i,e),t.stemDown.set(ti.parseEnum(s,xt),i)}),!0;case"repeatoffsetx":return t.repeatOffsetX=new Map,ti.forEach(s,(e,s)=>{t.repeatOffsetX.set(ti.parseEnum(s,xt),e)}),!0;case"standardstemlength":return t.standardStemLength=s,!0;case"stemflagoffsets":return t.stemFlagOffsets=new Map,ti.forEach(s,(e,s)=>{t.stemFlagOffsets.set(ti.parseEnum(s,w),e)}),!0;case"glyphtop":return t.glyphTop=new Map,ti.forEach(s,(e,s)=>{t.glyphTop.set(ti.parseEnum(s,xt),e)}),!0;case"glyphbottom":return t.glyphBottom=new Map,ti.forEach(s,(e,s)=>{t.glyphBottom.set(ti.parseEnum(s,xt),e)}),!0;case"glyphwidths":return t.glyphWidths=new Map,ti.forEach(s,(e,s)=>{t.glyphWidths.set(ti.parseEnum(s,xt),e)}),!0;case"glyphheights":return t.glyphHeights=new Map,ti.forEach(s,(e,s)=>{t.glyphHeights.set(ti.parseEnum(s,xt),e)}),!0;case"numberedbarrendererbarsize":return t.numberedBarRendererBarSize=s,!0;case"numberedbarrendererbarspacing":return t.numberedBarRendererBarSpacing=s,!0;case"numbereddashglyphpadding":return t.numberedDashGlyphPadding=s,!0;case"numbereddashglyphwidth":return t.numberedDashGlyphWidth=s,!0;case"linerangedglyphdashgap":return t.lineRangedGlyphDashGap=s,!0;case"linerangedglyphdashsize":return t.lineRangedGlyphDashSize=s,!0;case"prenoteeffectpadding":return t.preNoteEffectPadding=s,!0;case"postnoteeffectpadding":return t.postNoteEffectPadding=s,!0;case"onnoteeffectpadding":return t.onNoteEffectPadding=s,!0;case"stringnumbercirclepadding":return t.stringNumberCirclePadding=s,!0;case"rowcontainerpadding":return t.rowContainerPadding=s,!0;case"rowcontainergap":return t.rowContainerGap=s,!0;case"alternateendingspadding":return t.alternateEndingsPadding=s,!0;case"sustainpedallinepadding":return t.sustainPedalLinePadding=s,!0;case"tieheight":return t.tieHeight=s,!0;case"beattimerpadding":return t.beatTimerPadding=s,!0;case"bendnoteheadelementpadding":return t.bendNoteHeadElementPadding=s,!0;case"ghostparenthesiswidth":return t.ghostParenthesisWidth=s,!0;case"ghostparenthesispadding":return t.ghostParenthesisPadding=s,!0;case"brokenbeamwidth":return t.brokenBeamWidth=s,!0;case"tabwhammytextpadding":return t.tabWhammyTextPadding=s,!0;case"tabwhammyperhalfheight":return t.tabWhammyPerHalfHeight=s,!0;case"tabwhammydashsize":return t.tabWhammyDashSize=s,!0;case"songbookwhammydipheight":return t.songBookWhammyDipHeight=s,!0;case"deadslappedlinewidth":return t.deadSlappedLineWidth=s,!0;case"lefthandtabtiewidth":return t.leftHandTabTieWidth=s,!0;case"tabbenddashsize":return t.tabBendDashSize=s,!0;case"tabbendstaffpadding":return t.tabBendStaffPadding=s,!0;case"tabbendpervalueheight":return t.tabBendPerValueHeight=s,!0;case"tabbendlabelpadding":return t.tabBendLabelPadding=s,!0;case"simpleslidewidth":return t.simpleSlideWidth=s,!0;case"simpleslideheight":return t.simpleSlideHeight=s,!0;case"chorddiagrampaddingx":return t.chordDiagramPaddingX=s,!0;case"chorddiagrampaddingy":return t.chordDiagramPaddingY=s,!0;case"chorddiagramstringspacing":return t.chordDiagramStringSpacing=s,!0;case"chorddiagramfretspacing":return t.chordDiagramFretSpacing=s,!0;case"chorddiagramnutheight":return t.chordDiagramNutHeight=s,!0;case"chorddiagramfretheight":return t.chordDiagramFretHeight=s,!0;case"chorddiagramlinewidth":return t.chordDiagramLineWidth=s,!0;case"tripletfeelbracketpadding":return t.tripletFeelBracketPadding=s,!0;case"accidentalpadding":return t.accidentalPadding=s,!0;case"prebeatglyphspacing":return t.preBeatGlyphSpacing=s,!0;case"temponotescale":return t.tempoNoteScale=s,!0;case"tuningglyphcirclenumberscale":return t.tuningGlyphCircleNumberScale=s,!0;case"tuningglyphstringcolumnscale":return t.tuningGlyphStringColumnScale=s,!0;case"tuningglyphstringrowpadding":return t.tuningGlyphStringRowPadding=s,!0;case"directionsscale":return t.directionsScale=s,!0;case"multivoicedisplacednoteheadspacing":return t.multiVoiceDisplacedNoteHeadSpacing=s,!0;case"stemflagheight":return t.stemFlagHeight=new Map,ti.forEach(s,(e,s)=>{t.stemFlagHeight.set(ti.parseEnum(s,w),e)}),!0}return!1}},Bi=class t{static fromJson(e,s){s&&ti.forEach(s,(s,i)=>t.setProperty(e,i.toLowerCase(),s))}static toJson(t){if(!t)return null;const e=new Map;e.set("smuflfontfamilyname",t.smuflFontFamilyName),e.set("engravingsettings",Si.toJson(t.engravingSettings));{const s=new Map;e.set("elementfonts",s);for(const[e,i]of t.elementFonts)s.set(e.toString(),hi.toJson(i))}return e.set("numberednotationfont",hi.toJson(t.numberedNotationFont)),e.set("numberednotationgracefont",hi.toJson(t.numberedNotationGraceFont)),e.set("tablaturefont",hi.toJson(t.tablatureFont)),e.set("gracefont",hi.toJson(t.graceFont)),e.set("stafflinecolor",Se.toJson(t.staffLineColor)),e.set("barseparatorcolor",Se.toJson(t.barSeparatorColor)),e.set("barnumbercolor",Se.toJson(t.barNumberColor)),e.set("mainglyphcolor",Se.toJson(t.mainGlyphColor)),e.set("secondaryglyphcolor",Se.toJson(t.secondaryGlyphColor)),e.set("scoreinfocolor",Se.toJson(t.scoreInfoColor)),e}static setProperty(t,e,s){switch(e){case"smuflfontfamilyname":return t.smuflFontFamilyName=s,!0;case"elementfonts":return ti.forEach(s,(e,s)=>{t.elementFonts.set(ti.parseEnum(s,A),hi.fromJson(e))}),!0;case"numberednotationfont":return t.numberedNotationFont=hi.fromJson(s),!0;case"numberednotationgracefont":return t.numberedNotationGraceFont=hi.fromJson(s),!0;case"tablaturefont":return t.tablatureFont=hi.fromJson(s),!0;case"gracefont":return t.graceFont=hi.fromJson(s),!0;case"stafflinecolor":return t.staffLineColor=Se.fromJson(s),!0;case"barseparatorcolor":return t.barSeparatorColor=Se.fromJson(s),!0;case"barnumbercolor":return t.barNumberColor=Se.fromJson(s),!0;case"mainglyphcolor":return t.mainGlyphColor=Se.fromJson(s),!0;case"secondaryglyphcolor":return t.secondaryGlyphColor=Se.fromJson(s),!0;case"scoreinfocolor":return t.scoreInfoColor=Se.fromJson(s),!0}return["engravingsettings"].indexOf(e)>=0&&(Si.fromJson(t.engravingSettings,s),!0)}},_i=class t{static fromJson(e,s){s&&ti.forEach(s,(s,i)=>t.setProperty(e,i.toLowerCase(),s))}static toJson(t){if(!t)return null;const e=new Map;return e.set("scale",t.scale),e.set("stretchforce",t.stretchForce),e.set("layoutmode",t.layoutMode),e.set("staveprofile",t.staveProfile),e.set("barsperrow",t.barsPerRow),e.set("startbar",t.startBar),e.set("barcount",t.barCount),e.set("barcountperpartial",t.barCountPerPartial),e.set("justifylastsystem",t.justifyLastSystem),e.set("resources",Bi.toJson(t.resources)),e.set("padding",t.padding),e.set("firstsystempaddingtop",t.firstSystemPaddingTop),e.set("systempaddingtop",t.systemPaddingTop),e.set("systempaddingbottom",t.systemPaddingBottom),e.set("lastsystempaddingbottom",t.lastSystemPaddingBottom),e.set("systemlabelpaddingleft",t.systemLabelPaddingLeft),e.set("systemlabelpaddingright",t.systemLabelPaddingRight),e.set("accoladebarpaddingright",t.accoladeBarPaddingRight),e.set("firstnotationstaffpaddingtop",t.firstNotationStaffPaddingTop),e.set("lastnotationstaffpaddingbottom",t.lastNotationStaffPaddingBottom),e.set("notationstaffpaddingtop",t.notationStaffPaddingTop),e.set("notationstaffpaddingbottom",t.notationStaffPaddingBottom),e.set("effectstaffpaddingtop",t.effectStaffPaddingTop),e.set("effectstaffpaddingbottom",t.effectStaffPaddingBottom),e.set("firststaffpaddingleft",t.firstStaffPaddingLeft),e.set("staffpaddingleft",t.staffPaddingLeft),e.set("effectbandpaddingbottom",t.effectBandPaddingBottom),e.set("trackstaffpaddingbetween",t.trackStaffPaddingBetween),e.set("lyriclinespaddingbetween",t.lyricLinesPaddingBetween),e.set("systemslayoutmode",t.systemsLayoutMode),e}static setProperty(t,e,s){switch(e){case"scale":return t.scale=s,!0;case"stretchforce":return t.stretchForce=s,!0;case"layoutmode":return t.layoutMode=ti.parseEnum(s,Xs),!0;case"staveprofile":return t.staveProfile=ti.parseEnum(s,ci),!0;case"barsperrow":return t.barsPerRow=s,!0;case"startbar":return t.startBar=s,!0;case"barcount":return t.barCount=s,!0;case"barcountperpartial":return t.barCountPerPartial=s,!0;case"justifylastsystem":return t.justifyLastSystem=s,!0;case"padding":return t.padding=s,!0;case"firstsystempaddingtop":return t.firstSystemPaddingTop=s,!0;case"systempaddingtop":return t.systemPaddingTop=s,!0;case"systempaddingbottom":return t.systemPaddingBottom=s,!0;case"lastsystempaddingbottom":return t.lastSystemPaddingBottom=s,!0;case"systemlabelpaddingleft":return t.systemLabelPaddingLeft=s,!0;case"systemlabelpaddingright":return t.systemLabelPaddingRight=s,!0;case"accoladebarpaddingright":return t.accoladeBarPaddingRight=s,!0;case"firstnotationstaffpaddingtop":return t.firstNotationStaffPaddingTop=s,!0;case"lastnotationstaffpaddingbottom":return t.lastNotationStaffPaddingBottom=s,!0;case"notationstaffpaddingtop":return t.notationStaffPaddingTop=s,!0;case"notationstaffpaddingbottom":return t.notationStaffPaddingBottom=s,!0;case"effectstaffpaddingtop":return t.effectStaffPaddingTop=s,!0;case"effectstaffpaddingbottom":return t.effectStaffPaddingBottom=s,!0;case"firststaffpaddingleft":return t.firstStaffPaddingLeft=s,!0;case"staffpaddingleft":return t.staffPaddingLeft=s,!0;case"effectbandpaddingbottom":return t.effectBandPaddingBottom=s,!0;case"trackstaffpaddingbetween":return t.trackStaffPaddingBetween=s,!0;case"lyriclinespaddingbetween":return t.lyricLinesPaddingBetween=s,!0;case"systemslayoutmode":return t.systemsLayoutMode=ti.parseEnum(s,li),!0}if(["resources"].indexOf(e)>=0)return Bi.fromJson(t.resources,s),!0;for(const i of["resources"])if(0===e.indexOf(i)&&Bi.setProperty(t.resources,e.substring(i.length),s))return!0;return!1}},xi=class t{static fromJson(e,s){s&&ti.forEach(s,(s,i)=>t.setProperty(e,i.toLowerCase(),s))}static toJson(t){if(!t)return null;const e=new Map;e.set("notationmode",t.notationMode),e.set("fingeringmode",t.fingeringMode);{const s=new Map;e.set("elements",s);for(const[e,i]of t.elements)s.set(e.toString(),i)}return e.set("rhythmmode",t.rhythmMode),e.set("rhythmheight",t.rhythmHeight),e.set("transpositionpitches",t.transpositionPitches),e.set("displaytranspositionpitches",t.displayTranspositionPitches),e.set("smallgracetabnotes",t.smallGraceTabNotes),e.set("extendbendarrowsontiednotes",t.extendBendArrowsOnTiedNotes),e.set("extendlineeffectstobeatend",t.extendLineEffectsToBeatEnd),e.set("slurheight",t.slurHeight),e}static setProperty(t,e,s){switch(e){case"notationmode":return t.notationMode=ti.parseEnum(s,F),!0;case"fingeringmode":return t.fingeringMode=ti.parseEnum(s,E),!0;case"elements":return t.elements=new Map,ti.forEach(s,(e,s)=>{t.elements.set(ti.parseEnum(s,A),e)}),!0;case"rhythmmode":return t.rhythmMode=ti.parseEnum(s,C),!0;case"rhythmheight":return t.rhythmHeight=s,!0;case"transpositionpitches":return t.transpositionPitches=s,!0;case"displaytranspositionpitches":return t.displayTranspositionPitches=s,!0;case"smallgracetabnotes":return t.smallGraceTabNotes=s,!0;case"extendbendarrowsontiednotes":return t.extendBendArrowsOnTiedNotes=s,!0;case"extendlineeffectstobeatend":return t.extendLineEffectsToBeatEnd=s,!0;case"slurheight":return t.slurHeight=s,!0}return!1}},Ti=class t{static fromJson(e,s){s&&ti.forEach(s,(s,i)=>t.setProperty(e,i.toLowerCase(),s))}static toJson(t){if(!t)return null;const e=new Map;return e.set("encoding",t.encoding),e.set("mergepartgroupsinmusicxml",t.mergePartGroupsInMusicXml),e.set("beattextaslyrics",t.beatTextAsLyrics),e.set("maxdecodingbuffersize",t.maxDecodingBufferSize),e}static setProperty(t,e,s){switch(e){case"encoding":return t.encoding=s,!0;case"mergepartgroupsinmusicxml":return t.mergePartGroupsInMusicXml=s,!0;case"beattextaslyrics":return t.beatTextAsLyrics=s,!0;case"maxdecodingbuffersize":return t.maxDecodingBufferSize=s,!0}return!1}},Mi=class t{static fromJson(e,s){s&&ti.forEach(s,(s,i)=>t.setProperty(e,i.toLowerCase(),s))}static toJson(t){if(!t)return null;const e=new Map;return e.set("notewidelength",t.noteWideLength),e.set("notewideamplitude",t.noteWideAmplitude),e.set("noteslightlength",t.noteSlightLength),e.set("noteslightamplitude",t.noteSlightAmplitude),e.set("beatwidelength",t.beatWideLength),e.set("beatwideamplitude",t.beatWideAmplitude),e.set("beatslightlength",t.beatSlightLength),e.set("beatslightamplitude",t.beatSlightAmplitude),e}static setProperty(t,e,s){switch(e){case"notewidelength":return t.noteWideLength=s,!0;case"notewideamplitude":return t.noteWideAmplitude=s,!0;case"noteslightlength":return t.noteSlightLength=s,!0;case"noteslightamplitude":return t.noteSlightAmplitude=s,!0;case"beatwidelength":return t.beatWideLength=s,!0;case"beatwideamplitude":return t.beatWideAmplitude=s,!0;case"beatslightlength":return t.beatSlightLength=s,!0;case"beatslightamplitude":return t.beatSlightAmplitude=s,!0}return!1}},vi=class t{static fromJson(e,s){s&&ti.forEach(s,(s,i)=>t.setProperty(e,i.toLowerCase(),s))}static toJson(t){if(!t)return null;const e=new Map;return e.set("simpleslidepitchoffset",t.simpleSlidePitchOffset),e.set("simpleslidedurationratio",t.simpleSlideDurationRatio),e.set("shiftslidedurationratio",t.shiftSlideDurationRatio),e}static setProperty(t,e,s){switch(e){case"simpleslidepitchoffset":return t.simpleSlidePitchOffset=s,!0;case"simpleslidedurationratio":return t.simpleSlideDurationRatio=s,!0;case"shiftslidedurationratio":return t.shiftSlideDurationRatio=s,!0}return!1}},Ni=class t{static fromJson(e,s){s&&ti.forEach(s,(s,i)=>t.setProperty(e,i.toLowerCase(),s))}static toJson(t){if(!t)return null;const e=new Map;return e.set("soundfont",t.soundFont),e.set("outputmode",t.outputMode),e.set("enableplayer",t.enablePlayer),e.set("playermode",t.playerMode),e.set("enablecursor",t.enableCursor),e.set("enableanimatedbeatcursor",t.enableAnimatedBeatCursor),e.set("enableelementhighlighting",t.enableElementHighlighting),e.set("enableuserinteraction",t.enableUserInteraction),e.set("scrolloffsetx",t.scrollOffsetX),e.set("scrolloffsety",t.scrollOffsetY),e.set("scrollmode",t.scrollMode),e.set("scrollspeed",t.scrollSpeed),e.set("nativebrowsersmoothscroll",t.nativeBrowserSmoothScroll),e.set("songbookbendduration",t.songBookBendDuration),e.set("songbookdipduration",t.songBookDipDuration),e.set("vibrato",Mi.toJson(t.vibrato)),e.set("slide",vi.toJson(t.slide)),e.set("playtripletfeel",t.playTripletFeel),e.set("buffertimeinmilliseconds",t.bufferTimeInMilliseconds),e}static setProperty(t,e,s){switch(e){case"soundfont":return t.soundFont=s,!0;case"scrollelement":return t.scrollElement=s,!0;case"outputmode":return t.outputMode=ti.parseEnum(s,mi),!0;case"enableplayer":return t.enablePlayer=s,!0;case"playermode":return t.playerMode=ti.parseEnum(s,gi),!0;case"enablecursor":return t.enableCursor=s,!0;case"enableanimatedbeatcursor":return t.enableAnimatedBeatCursor=s,!0;case"enableelementhighlighting":return t.enableElementHighlighting=s,!0;case"enableuserinteraction":return t.enableUserInteraction=s,!0;case"scrolloffsetx":return t.scrollOffsetX=s,!0;case"scrolloffsety":return t.scrollOffsetY=s,!0;case"scrollmode":return t.scrollMode=ti.parseEnum(s,fi),!0;case"scrollspeed":return t.scrollSpeed=s,!0;case"nativebrowsersmoothscroll":return t.nativeBrowserSmoothScroll=s,!0;case"songbookbendduration":return t.songBookBendDuration=s,!0;case"songbookdipduration":return t.songBookDipDuration=s,!0;case"playtripletfeel":return t.playTripletFeel=s,!0;case"buffertimeinmilliseconds":return t.bufferTimeInMilliseconds=s,!0}if(["vibrato"].indexOf(e)>=0)return Mi.fromJson(t.vibrato,s),!0;for(const i of["vibrato"])if(0===e.indexOf(i)&&Mi.setProperty(t.vibrato,e.substring(i.length),s))return!0;if(["slide"].indexOf(e)>=0)return vi.fromJson(t.slide,s),!0;for(const i of["slide"])if(0===e.indexOf(i)&&vi.setProperty(t.slide,e.substring(i.length),s))return!0;return!1}},Pi=class t{static fromJson(e,s){s&&ti.forEach(s,(s,i)=>t.setProperty(e,i.toLowerCase(),s))}static toJson(t){if(!t)return null;const e=new Map;return e.set("indent",t.indent),e.set("comments",t.comments),e}static setProperty(t,e,s){switch(e){case"indent":return t.indent=s,!0;case"comments":return t.comments=s,!0}return!1}},Ci=class t{static fromJson(e,s){s&&ti.forEach(s,(s,i)=>t.setProperty(e,i.toLowerCase(),s))}static toJson(t){if(!t)return null;const e=new Map;return e.set("core",yi.toJson(t.core)),e.set("display",_i.toJson(t.display)),e.set("notation",xi.toJson(t.notation)),e.set("importer",Ti.toJson(t.importer)),e.set("player",Ni.toJson(t.player)),e.set("exporter",Pi.toJson(t.exporter)),e}static setProperty(t,e,s){if(["core",""].indexOf(e)>=0)return yi.fromJson(t.core,s),!0;for(const i of["core",""])if(0===e.indexOf(i)&&yi.setProperty(t.core,e.substring(i.length),s))return!0;if(["display",""].indexOf(e)>=0)return _i.fromJson(t.display,s),!0;for(const i of["display",""])if(0===e.indexOf(i)&&_i.setProperty(t.display,e.substring(i.length),s))return!0;if(["notation"].indexOf(e)>=0)return xi.fromJson(t.notation,s),!0;for(const i of["notation"])if(0===e.indexOf(i)&&xi.setProperty(t.notation,e.substring(i.length),s))return!0;if(["importer"].indexOf(e)>=0)return Ti.fromJson(t.importer,s),!0;for(const i of["importer"])if(0===e.indexOf(i)&&Ti.setProperty(t.importer,e.substring(i.length),s))return!0;if(["player"].indexOf(e)>=0)return Ni.fromJson(t.player,s),!0;for(const i of["player"])if(0===e.indexOf(i)&&Ni.setProperty(t.player,e.substring(i.length),s))return!0;if(["exporter"].indexOf(e)>=0)return Pi.fromJson(t.exporter,s),!0;for(const i of["exporter"])if(0===e.indexOf(i)&&Pi.setProperty(t.exporter,e.substring(i.length),s))return!0;return!1}},Ei=class{indent=2;comments=!1},Fi=class t{core=new xu;display=new ui;notation=new D;importer=new di;player=new wi;exporter=new Ei;setSongBookModeSettings(){this.notation.notationMode=F.SongBook,this.notation.smallGraceTabNotes=!1,this.notation.fingeringMode=E.SingleNoteEffectBand,this.notation.extendBendArrowsOnTiedNotes=!1,this.notation.elements.set(A.ParenthesisOnTiedBends,!1),this.notation.elements.set(A.TabNotesOnTiedBends,!1),this.notation.elements.set(A.ZerosOnDiveWhammys,!0)}static get songBook(){const e=new t;return e.setSongBookModeSettings(),e}fillFromJson(t){Ci.fromJson(this,t)}handleBackwardsCompatibility(){this.player.playerMode===gi.Disabled&&this.player.enablePlayer&&(this.player.playerMode=gi.EnabledAutomatic)}},Ai=class t{static loadAlphaTex(t,e){const s=new $e;return s.logErrors=!0,s.initFromString(t,e??new Fi),s.readScore()}static loadScoreAsync(e,s,i,n){const r=new XMLHttpRequest;r.open("GET",e,!0,null,null),r.responseType="arraybuffer",r.onreadystatechange=()=>{if(r.readyState===XMLHttpRequest.DONE){const e=r.response;if(200===r.status||0===r.status&&e)try{const e=r.response,i=new Uint8Array(e);s(t.loadScoreFromBytes(i,n))}catch(t){i(t)}else 0===r.status?i(new Qs("You are offline!!\n Please Check Your Network.",r)):404===r.status?i(new Qs("Requested URL not found.",r)):500===r.status?i(new Qs("Internel Server Error.",r)):"parsererror"===r.statusText?i(new Qs("Error.\nParsing JSON Request failed.",r)):"timeout"===r.statusText?i(new Qs("Request Time out.",r)):i(new Qs(`Unknow Error: ${r.responseText}`,r))}},r.send()}static loadScoreFromBytes(t,e){e||(e=new Fi);const s=Bu.buildImporters();O.debug("ScoreLoader",`Loading score from ${t.length} bytes using ${s.length} importers`);let i=null;const n=new We(Ie.fromBuffer(t));for(const t of s){n.reset();try{O.debug("ScoreLoader",`Importing using importer ${t.name}`),t.init(n,e),i=t.readScore(),O.debug("ScoreLoader",`Score imported using ${t.name}`);break}catch(e){if(!(e instanceof Oe))throw O.error("ScoreLoader","Score import failed due to unexpected error: ",e),e;O.debug("ScoreLoader",`${t.name} does not support the file`)}}if(i)return i;throw new Oe("No compatible importer found for file")}},Di=class{mouseEvent;get isLeftMouseButton(){return 0===this.mouseEvent.button}getX(t){const e=t.element,s=e.getBoundingClientRect().left+e.ownerDocument.defaultView.pageXOffset;return this.mouseEvent.pageX-s}getY(t){const e=t.element,s=e.getBoundingClientRect().top+e.ownerDocument.defaultView.pageYOffset;return this.mouseEvent.pageY-s}preventDefault(){this.mouseEvent.preventDefault()}constructor(t){this.mouseEvent=t}},Li=class t{static du=new L(()=>new ResizeObserver(t=>{for(const e of t){const t=new CustomEvent("resize",{detail:e});e.target.dispatchEvent(t)}}));fu=0;get width(){return this.element.offsetWidth}set width(t){this.element.style.width=`${t}px`}get scrollLeft(){return this.element.scrollLeft}set scrollLeft(t){this.element.scrollLeft=t}get scrollTop(){return this.element.scrollTop}set scrollTop(t){this.element.scrollTop=t}get height(){return this.element.offsetHeight}set height(t){this.element.style.height=t>=0?`${t}px`:"100%"}get isVisible(){return!!this.element.offsetWidth||!!this.element.offsetHeight||!!this.element.getClientRects().length}element;constructor(e){this.element=e,this.mouseDown={on:t=>{const e=e=>{t(new Di(e))};return this.element.addEventListener("mousedown",e,!0),()=>{this.element.removeEventListener("mousedown",e,!0)}},off:t=>{}},this.mouseUp={on:t=>{const e=e=>{t(new Di(e))};return this.element.addEventListener("mouseup",e,!0),()=>{this.element.removeEventListener("mouseup",e,!0)}},off:t=>{}},this.mouseMove={on:t=>{const e=e=>{t(new Di(e))};return this.element.addEventListener("mousemove",e,!0),()=>{this.element.removeEventListener("mousemove",e,!0)}},off:t=>{}};const s=this;this.resize={on:function(e){return 0===s.fu&&t.du.value.observe(s.element),s.element.addEventListener("resize",e,!0),s.fu++,()=>this.off(e)},off:e=>{this.element.removeEventListener("resize",e,!0),this.fu--,this.fu<=0&&(this.fu=0,t.du.value.unobserve(this.element))}}}stopAnimation(){this.element.style.transition="none"}transitionToX(t,e){this.element.style.transition=`transform ${t}ms linear`,this.setBounds(e,NaN,NaN,NaN)}lastBounds=new _s;setBounds(t,e,s,i){Number.isNaN(t)&&(t=this.lastBounds.x),Number.isNaN(e)&&(e=this.lastBounds.y),Number.isNaN(s)&&(s=this.lastBounds.w),Number.isNaN(i)&&(i=this.lastBounds.h),this.element.style.transform=`translate(${t}px, ${e}px) scale(${s}, ${i})`,this.element.style.transformOrigin="top left",this.lastBounds.x=t,this.lastBounds.y=e,this.lastBounds.w=s,this.lastBounds.h=i}resize;mouseDown;mouseMove;mouseUp;appendChild(t){this.element.appendChild(t.element)}clear(){this.element.innerText=""}},Wi=function(t){return t[t.Browser=0]="Browser",t[t.NodeJs=1]="NodeJs",t[t.BrowserModule=2]="BrowserModule",t}({}),Ri=class{characterWidths;characterHeights;constructor(t,e){this.characterWidths=t,this.characterHeights=e}},Oi=class t{static fontSizeLookupTables=new Map;static ControlChars=32;static generateFontLookup(e){if(!t.fontSizeLookupTables.has(e))if(Bu.isRunningInWorker||Bu.webPlatform===Wi.NodeJs){const s=new Ri(new Uint8Array([8]),new Uint8Array([10]));t.fontSizeLookupTables.set(e,s)}else{const s=document.createElement("canvas").getContext("2d");s.font=`11px ${e}`;const i=[],n=[];for(let e=t.ControlChars;e<255;e++){const t=String.fromCharCode(e),r=s.measureText(t);i.push(r.width);const a=r.actualBoundingBoxDescent+r.actualBoundingBoxAscent;n.push(a)}const r=new Ri(new Uint8Array(i),new Uint8Array(n));t.fontSizeLookupTables.set(e,r)}}static measureString(e,s,i,n,r){let a;let h=s[0];for(let e=0;e<s.length;e++)if(t.fontSizeLookupTables.has(s[e])){h=s[e];break}t.fontSizeLookupTables.has(h)||t.generateFontLookup(h),a=t.fontSizeLookupTables.get(h);let o=1;n===ri.Italic&&(o*=1.1),r===ai.Bold&&(o*=1.1);let c=0,l=0;for(let s=0;s<e.length;s++){const n=Math.min(a.characterWidths.length-1,e.charCodeAt(s)-t.ControlChars);n>=0&&(c+=a.characterWidths[n]*i/11,l=Math.max(l,a.characterHeights[n]*i/11))}return o*=1.07,new ft(c*o,l)}},Ii=class{pu;au;bu=!1;isFontLoaded=!1;fontLoaded=new Js;constructor(t){this.pu=t,this.au=t}checkForFontAvailability(){if(Bu.isRunningInWorker)return void(this.isFontLoaded=!1);if(this.bu)return;this.bu=!0;let t=0;const e=window.setInterval(()=>{O.warning("Rendering",`Could not load font '${this.au[0]}' within ${5*(t+1)} seconds`,null),this.au.length>1?(this.au.shift(),t=0):t++},5e3);O.debug("Font",`Start checking for font availablility: ${this.au.join(", ")}`);const s=t=>{this.au.length>1?(O.debug("Font",`[${this.au[0]}] Loading Failed, switching to ${this.au[1]}`,t),this.au.shift(),window.setTimeout(()=>{n()},0)):(O.error("Font",`[${this.pu.join(",")}] Loading Failed, rendering cannot start`,t),window.clearInterval(e))},i=t=>{O.debug("Font",`[${t}] Font API signaled available`),this.isFontLoaded=!0,window.clearInterval(e),this.fontLoaded.trigger(this.au[0])},n=async()=>{for(const t of this.au)if(await this.mu(t,!1))return void i(t);try{await document.fonts.load(`1em ${this.au[0]}`)}catch(t){s(t)}return O.debug("Font",`[${this.au[0]}] Font API signaled loaded`),await this.mu(this.au[0],!0)?i(this.au[0]):s("Font not available"),!0};document.fonts.ready.then(()=>{n()})}mu(t,e){return new Promise(s=>{const i=`1em ${t}`;if(document.fonts.check(i))s(!0);else if(e){O.debug("Font",`Font ${t} not available, creating test element to trigger load`);const e=document.createElement("div");e.style.font=i,e.style.opacity="0",e.style.position="absolute",e.style.top="0",e.style.left="0",e.innerText=`Trigger ${t} load`,document.body.appendChild(e),setTimeout(()=>{document.body.removeChild(e),document.fonts.check(i)?s(!0):s(!1)},200)}else s(!1)})}},Gi=class{ki;gu=0;wu=0;count=0;constructor(t){this.ki=new Float32Array(t)}clear(){this.wu=0,this.gu=0,this.count=0,this.ki=new Float32Array(this.ki.length)}write(t,e,s){let i=0;s>this.ki.length-this.count&&(s=this.ki.length-this.count);const n=Math.min(this.ki.length-this.gu,s);return this.ki.set(t.subarray(e,e+n),this.gu),this.gu+=n,this.gu%=this.ki.length,i+=n,i<s&&(this.ki.set(t.subarray(e+i,e+i+s-i),this.gu),this.gu+=s-i,i=s),this.count+=i,i}read(t,e,s){s>this.count&&(s=this.count);let i=0;const n=Math.min(this.ki.length-this.wu,s);return t.set(this.ki.subarray(this.wu,this.wu+n),e),i+=n,this.wu+=n,this.wu%=this.ki.length,i<s&&(t.set(this.ki.subarray(this.wu,this.wu+s-i),e+i),this.wu+=s-i,i=s),this.count-=i,i}},Hi=class extends Ks{yu=null;ku;Su=0;Bu=0;open(t){super.open(t),this.Su=Math.floor(t*this.sampleRate/1e3/Ks.BufferSize),this.ku=new Gi(Ks.BufferSize*this.Su),this.onReady()}play(){super.play();const t=this.context;this.yu=t.createScriptProcessor(4096,0,2),this.yu.onaudioprocess=this._u.bind(this),this.ku.clear(),this.xu(),this.source=t.createBufferSource(),this.source.buffer=this.buffer,this.source.loop=!0,this.source.connect(this.yu,0,0),this.source.start(0),this.yu.connect(t.destination,0,0)}pause(){super.pause(),this.yu&&this.yu.disconnect(0),this.yu=null}addSamples(t){this.ku.write(t,0,t.length),this.Bu--}resetSamples(){this.ku.clear()}xu(){const t=this.Su/2|0,e=t*Ks.BufferSize;if(this.ku.count+this.Bu*Ks.BufferSize<e){for(let e=0;e<t;e++)this.onSampleRequest();this.Bu+=t}}Tu=new Float32Array(0);_u(t){const e=t.outputBuffer.getChannelData(0),s=t.outputBuffer.getChannelData(1),i=e.length+s.length;let n=this.Tu;n.length!==i&&(n=new Float32Array(i),this.Tu=n);const r=this.ku.read(n,0,Math.min(n.length,this.ku.count));let a=0;const h=Math.min(e.length,r);for(let t=0;t<h;t++)e[t]=n[a++],s[t]=n[a++];if(r<e.length)for(let t=r;t<e.length;t++)e[t]=0,s[t]=0;this.onSamplesPlayed(r/yt.AudioChannels),this.xu()}},$i=class t{static fromJson(e,s){s&&ti.forEach(s,(s,i)=>t.setProperty(e,i,s))}static toJson(t){if(!t)return null;const e=new Map;{const s=new Map;e.set("groups",s);for(const[e,i]of t.groups)s.set(e.toString(),i)}return e}static setProperty(t,e,s){return"groups"===e&&(t.groups=new Map,ti.forEach(s,(e,s)=>{t.groups.set(ti.parseEnum(s,w),e)}),!0)}},Vi=class t{static fromJson(e,s){s&&ti.forEach(s,(s,i)=>t.setProperty(e,i,s))}static toJson(t){if(!t)return null;const e=new Map;return e.set("marker",t.marker),e.set("text",t.text),e}static setProperty(t,e,s){switch(e){case"marker":return t.marker=s,!0;case"text":return t.text=s,!0}return!1}},zi=class t{static fromJson(e,s){s&&ti.forEach(s,(s,i)=>t.setProperty(e,i,s))}static toJson(t){if(!t)return null;const e=new Map;return e.set("baroccurence",t.barOccurence),e.set("millisecondoffset",t.millisecondOffset),e}static setProperty(t,e,s){switch(e){case"baroccurence":return t.barOccurence=s,!0;case"millisecondoffset":return t.millisecondOffset=s,!0}return!1}},Ui=class t{static fromJson(e,s){s&&ti.forEach(s,(s,i)=>t.setProperty(e,i,s))}static toJson(t){if(!t)return null;const e=new Map;return e.set("islinear",t.isLinear),e.set("type",t.type),e.set("value",t.value),t.syncPointValue&&e.set("syncpointvalue",zi.toJson(t.syncPointValue)),e.set("ratioposition",t.ratioPosition),e.set("text",t.text),e.set("isvisible",t.isVisible),e}static setProperty(t,e,s){switch(e){case"islinear":return t.isLinear=s,!0;case"type":return t.type=ti.parseEnum(s,l),!0;case"value":return t.value=s,!0;case"syncpointvalue":return s?(t.syncPointValue=new u,zi.fromJson(t.syncPointValue,s)):t.syncPointValue=void 0,!0;case"ratioposition":return t.ratioPosition=s,!0;case"text":return t.text=s,!0;case"isvisible":return t.isVisible=s,!0}return!1}},Xi=class t{static fromJson(e,s){s&&ti.forEach(s,(s,i)=>t.setProperty(e,i,s))}static toJson(t){if(!t)return null;const e=new Map;return e.set("type",t.type),e.set("length",t.length),e}static setProperty(t,e,s){switch(e){case"type":return t.type=ti.parseEnum(s,Be),!0;case"length":return t.length=s,!0}return!1}},ji=class t{static fromJson(e,s){s&&ti.forEach(s,(s,i)=>t.setProperty(e,i,s))}static toJson(t){if(!t)return null;const e=new Map;if(e.set("alternateendings",t.alternateEndings),e.set("isdoublebar",t.isDoubleBar),e.set("isrepeatstart",t.isRepeatStart),e.set("repeatcount",t.repeatCount),e.set("timesignaturenumerator",t.timeSignatureNumerator),e.set("timesignaturedenominator",t.timeSignatureDenominator),e.set("timesignaturecommon",t.timeSignatureCommon),t.beamingRules&&e.set("beamingrules",$i.toJson(t.beamingRules)),e.set("isfreetime",t.isFreeTime),e.set("tripletfeel",t.tripletFeel),t.section&&e.set("section",Vi.toJson(t.section)),e.set("tempoautomations",t.tempoAutomations.map(t=>Ui.toJson(t))),void 0!==t.syncPoints&&e.set("syncpoints",t.syncPoints?.map(t=>Ui.toJson(t))),null!==t.fermata){const s=new Map;e.set("fermata",s);for(const[e,i]of t.fermata)s.set(e.toString(),Xi.toJson(i))}if(e.set("start",t.start),e.set("isanacrusis",t.isAnacrusis),e.set("displayscale",t.displayScale),e.set("displaywidth",t.displayWidth),null!==t.directions){const s=[];e.set("directions",s);for(const e of t.directions)s.push(e)}return e}static setProperty(t,e,s){switch(e){case"alternateendings":return t.alternateEndings=s,!0;case"isdoublebar":return t.isDoubleBar=s,!0;case"isrepeatstart":return t.isRepeatStart=s,!0;case"repeatcount":return t.repeatCount=s,!0;case"timesignaturenumerator":return t.timeSignatureNumerator=s,!0;case"timesignaturedenominator":return t.timeSignatureDenominator=s,!0;case"timesignaturecommon":return t.timeSignatureCommon=s,!0;case"beamingrules":return s?(t.beamingRules=new Q,$i.fromJson(t.beamingRules,s)):t.beamingRules=void 0,!0;case"isfreetime":return t.isFreeTime=s,!0;case"tripletfeel":return t.tripletFeel=ti.parseEnum(s,K),!0;case"section":return s?(t.section=new Te,Vi.fromJson(t.section,s)):t.section=null,!0;case"tempoautomations":t.tempoAutomations=[];for(const e of s){const s=new d;Ui.fromJson(s,e),t.tempoAutomations.push(s)}return!0;case"syncpoints":if(s){t.syncPoints=[];for(const e of s){const s=new d;Ui.fromJson(s,e),t.addSyncPoint(s)}}return!0;case"fermata":return t.fermata=new Map,ti.forEach(s,(e,s)=>{const i=new _e;Xi.fromJson(i,e),t.addFermata(Number.parseInt(s),i)}),!0;case"start":return t.start=s,!0;case"isanacrusis":return t.isAnacrusis=s,!0;case"displayscale":return t.displayScale=s,!0;case"displaywidth":return t.displayWidth=s,!0;case"directions":for(const e of s)t.addDirection(ti.parseEnum(e,ys));return!0}return!1}},Ji=class t{static fromJson(e,s){s&&ti.forEach(s,(s,i)=>t.setProperty(e,i,s))}static toJson(t){if(!t)return null;const e=new Map;return e.set("offset",t.offset),e.set("value",t.value),e}static setProperty(t,e,s){switch(e){case"offset":return t.offset=s,!0;case"value":return t.value=s,!0}return!1}},qi=class t{static fromJson(e,s){s&&ti.forEach(s,(s,i)=>t.setProperty(e,i,s))}static toJson(t){if(!t)return null;const e=new Map;e.set("notehead",t.noteHead),e.set("noteheadcenteronstem",t.noteHeadCenterOnStem);{const s=new Map;e.set("colors",s);for(const[e,i]of t.colors)s.set(e.toString(),Se.toJson(i))}return e}static setProperty(t,e,s){switch(e){case"notehead":return t.noteHead=ti.parseEnum(s,xt),!0;case"noteheadcenteronstem":return t.noteHeadCenterOnStem=s,!0;case"colors":return t.colors=new Map,ti.forEach(s,(e,s)=>{t.colors.set(ti.parseEnum(s,Et),Se.fromJson(e))}),!0}return!1}},Yi=class t{static fromJson(e,s){s&&ti.forEach(s,(s,i)=>t.setProperty(e,i,s))}static toJson(t){if(!t)return null;const e=new Map;return e.set("id",t.id),e.set("accentuated",t.accentuated),e.set("bendtype",t.bendType),e.set("bendstyle",t.bendStyle),e.set("iscontinuedbend",t.isContinuedBend),null!==t.bendPoints&&e.set("bendpoints",t.bendPoints?.map(t=>Ji.toJson(t))),e.set("fret",t.fret),e.set("string",t.string),e.set("showstringnumber",t.showStringNumber),e.set("octave",t.octave),e.set("tone",t.tone),e.set("percussionarticulation",t.percussionArticulation),e.set("isvisible",t.isVisible),e.set("islefthandtapped",t.isLeftHandTapped),e.set("ishammerpullorigin",t.isHammerPullOrigin),e.set("isslurdestination",t.isSlurDestination),e.set("harmonictype",t.harmonicType),e.set("harmonicvalue",t.harmonicValue),e.set("isghost",t.isGhost),e.set("isletring",t.isLetRing),e.set("ispalmmute",t.isPalmMute),e.set("isdead",t.isDead),e.set("isstaccato",t.isStaccato),e.set("slideintype",t.slideInType),e.set("slideouttype",t.slideOutType),e.set("vibrato",t.vibrato),e.set("istiedestination",t.isTieDestination),e.set("lefthandfinger",t.leftHandFinger),e.set("righthandfinger",t.rightHandFinger),e.set("trillvalue",t.trillValue),e.set("trillspeed",t.trillSpeed),e.set("durationpercent",t.durationPercent),e.set("accidentalmode",t.accidentalMode),e.set("dynamics",t.dynamics),e.set("ornament",t.ornament),t.style&&e.set("style",qi.toJson(t.style)),t.toJson(e),e}static setProperty(t,e,s){switch(e){case"id":return t.id=s,!0;case"accentuated":return t.accentuated=ti.parseEnum(s,k),!0;case"bendtype":return t.bendType=ti.parseEnum(s,b),!0;case"bendstyle":return t.bendStyle=ti.parseEnum(s,p),!0;case"iscontinuedbend":return t.isContinuedBend=s,!0;case"bendpoints":if(s){t.bendPoints=[];for(const e of s){const s=new f;Ji.fromJson(s,e),t.addBendPoint(s)}}return!0;case"fret":return t.fret=s,!0;case"string":return t.string=s,!0;case"showstringnumber":return t.showStringNumber=s,!0;case"octave":return t.octave=s,!0;case"tone":return t.tone=s,!0;case"percussionarticulation":return t.percussionArticulation=s,!0;case"isvisible":return t.isVisible=s,!0;case"islefthandtapped":return t.isLeftHandTapped=s,!0;case"ishammerpullorigin":return t.isHammerPullOrigin=s,!0;case"isslurdestination":return t.isSlurDestination=s,!0;case"harmonictype":return t.harmonicType=ti.parseEnum(s,B),!0;case"harmonicvalue":return t.harmonicValue=s,!0;case"isghost":return t.isGhost=s,!0;case"isletring":return t.isLetRing=s,!0;case"ispalmmute":return t.isPalmMute=s,!0;case"isdead":return t.isDead=s,!0;case"isstaccato":return t.isStaccato=s,!0;case"slideintype":return t.slideInType=ti.parseEnum(s,T),!0;case"slideouttype":return t.slideOutType=ti.parseEnum(s,M),!0;case"vibrato":return t.vibrato=ti.parseEnum(s,P),!0;case"istiedestination":return t.isTieDestination=s,!0;case"lefthandfinger":return t.leftHandFinger=ti.parseEnum(s,S),!0;case"righthandfinger":return t.rightHandFinger=ti.parseEnum(s,S),!0;case"trillvalue":return t.trillValue=s,!0;case"trillspeed":return t.trillSpeed=ti.parseEnum(s,w),!0;case"durationpercent":return t.durationPercent=s,!0;case"accidentalmode":return t.accidentalMode=ti.parseEnum(s,_),!0;case"dynamics":return t.dynamics=ti.parseEnum(s,o),!0;case"ornament":return t.ornament=ti.parseEnum(s,Pt),!0;case"style":return s?(t.style=new Ft,qi.fromJson(t.style,s)):t.style=void 0,!0}return t.setProperty(e,s)}},Ki=class t{static fromJson(e,s){s&&ti.forEach(s,(s,i)=>t.setProperty(e,i,s))}static toJson(t){if(!t)return null;const e=new Map;return e.set("marks",t.marks),e.set("style",t.style),e}static setProperty(t,e,s){switch(e){case"marks":return t.marks=s,!0;case"style":return t.style=ti.parseEnum(s,Ht),!0}return!1}},Qi=class t{static fromJson(e,s){s&&ti.forEach(s,(s,i)=>t.setProperty(e,i,s))}static toJson(t){if(!t)return null;const e=new Map;{const s=new Map;e.set("colors",s);for(const[e,i]of t.colors)s.set(e.toString(),Se.toJson(i))}return e}static setProperty(t,e,s){return"colors"===e&&(t.colors=new Map,ti.forEach(s,(e,s)=>{t.colors.set(ti.parseEnum(s,zt),Se.fromJson(e))}),!0)}},Zi=class t{static fromJson(e,s){s&&ti.forEach(s,(s,i)=>t.setProperty(e,i,s))}static toJson(t){if(!t)return null;const e=new Map;return e.set("id",t.id),e.set("notes",t.notes.map(t=>Yi.toJson(t))),e.set("isempty",t.isEmpty),e.set("whammystyle",t.whammyStyle),e.set("ottava",t.ottava),e.set("islegatoorigin",t.isLegatoOrigin),e.set("duration",t.duration),e.set("automations",t.automations.map(t=>Ui.toJson(t))),e.set("dots",t.dots),e.set("fade",t.fade),e.set("lyrics",t.lyrics),e.set("pop",t.pop),e.set("slap",t.slap),e.set("tap",t.tap),e.set("text",t.text),e.set("slashed",t.slashed),e.set("deadslapped",t.deadSlapped),e.set("brushtype",t.brushType),e.set("brushduration",t.brushDuration),e.set("tupletdenominator",t.tupletDenominator),e.set("tupletnumerator",t.tupletNumerator),e.set("iscontinuedwhammy",t.isContinuedWhammy),e.set("whammybartype",t.whammyBarType),null!==t.whammyBarPoints&&e.set("whammybarpoints",t.whammyBarPoints?.map(t=>Ji.toJson(t))),e.set("vibrato",t.vibrato),e.set("chordid",t.chordId),e.set("gracetype",t.graceType),e.set("pickstroke",t.pickStroke),t.tremoloPicking&&e.set("tremolopicking",Ki.toJson(t.tremoloPicking)),e.set("crescendo",t.crescendo),e.set("displaystart",t.displayStart),e.set("playbackstart",t.playbackStart),e.set("displayduration",t.displayDuration),e.set("playbackduration",t.playbackDuration),e.set("overridedisplayduration",t.overrideDisplayDuration),e.set("golpe",t.golpe),e.set("dynamics",t.dynamics),e.set("invertbeamdirection",t.invertBeamDirection),e.set("preferredbeamdirection",t.preferredBeamDirection),e.set("beamingmode",t.beamingMode),e.set("wahpedal",t.wahPedal),e.set("barrefret",t.barreFret),e.set("barreshape",t.barreShape),e.set("rasgueado",t.rasgueado),e.set("showtimer",t.showTimer),e.set("timer",t.timer),t.style&&e.set("style",Qi.toJson(t.style)),e}static setProperty(t,e,s){switch(e){case"id":return t.id=s,!0;case"notes":t.notes=[];for(const e of s){const s=new At;Yi.fromJson(s,e),t.addNote(s)}return!0;case"isempty":return t.isEmpty=s,!0;case"whammystyle":return t.whammyStyle=ti.parseEnum(s,p),!0;case"ottava":return t.ottava=ti.parseEnum(s,x),!0;case"islegatoorigin":return t.isLegatoOrigin=s,!0;case"duration":return t.duration=ti.parseEnum(s,w),!0;case"automations":t.automations=[];for(const e of s){const s=new d;Ui.fromJson(s,e),t.automations.push(s)}return!0;case"dots":return t.dots=s,!0;case"fade":return t.fade=ti.parseEnum(s,Rt),!0;case"lyrics":return t.lyrics=s,!0;case"pop":return t.pop=s,!0;case"slap":return t.slap=s,!0;case"tap":return t.tap=s,!0;case"text":return t.text=s,!0;case"slashed":return t.slashed=s,!0;case"deadslapped":return t.deadSlapped=s,!0;case"brushtype":return t.brushType=ti.parseEnum(s,m),!0;case"brushduration":return t.brushDuration=s,!0;case"tupletdenominator":return t.tupletDenominator=s,!0;case"tupletnumerator":return t.tupletNumerator=s,!0;case"iscontinuedwhammy":return t.isContinuedWhammy=s,!0;case"whammybartype":return t.whammyBarType=ti.parseEnum(s,Lt),!0;case"whammybarpoints":if(s){t.whammyBarPoints=[];for(const e of s){const s=new f;Ji.fromJson(s,e),t.addWhammyBarPoint(s)}}return!0;case"vibrato":return t.vibrato=ti.parseEnum(s,P),!0;case"chordid":return t.chordId=s,!0;case"gracetype":return t.graceType=ti.parseEnum(s,y),!0;case"pickstroke":return t.pickStroke=ti.parseEnum(s,_t),!0;case"tremolopicking":return s?(t.tremoloPicking=new $t,Ki.fromJson(t.tremoloPicking,s)):t.tremoloPicking=void 0,!0;case"crescendo":return t.crescendo=ti.parseEnum(s,g),!0;case"displaystart":return t.displayStart=s,!0;case"playbackstart":return t.playbackStart=s,!0;case"displayduration":return t.displayDuration=s,!0;case"playbackduration":return t.playbackDuration=s,!0;case"overridedisplayduration":return t.overrideDisplayDuration=s,!0;case"golpe":return t.golpe=ti.parseEnum(s,Wt),!0;case"dynamics":return t.dynamics=ti.parseEnum(s,o),!0;case"invertbeamdirection":return t.invertBeamDirection=s,!0;case"preferredbeamdirection":return t.preferredBeamDirection=ti.parseEnum(s,Fe)??null,!0;case"beamingmode":return t.beamingMode=ti.parseEnum(s,Vt),!0;case"wahpedal":return t.wahPedal=ti.parseEnum(s,Ot),!0;case"barrefret":return t.barreFret=s,!0;case"barreshape":return t.barreShape=ti.parseEnum(s,It),!0;case"rasgueado":return t.rasgueado=ti.parseEnum(s,Gt),!0;case"showtimer":return t.showTimer=s,!0;case"timer":return t.timer=s,!0;case"style":return s?(t.style=new Ut,Qi.fromJson(t.style,s)):t.style=void 0,!0}return!1}},tn=class t{static fromJson(e,s){s&&ti.forEach(s,(s,i)=>t.setProperty(e,i,s))}static toJson(t){if(!t)return null;const e=new Map;{const s=new Map;e.set("colors",s);for(const[e,i]of t.colors)s.set(e.toString(),Se.toJson(i))}return e}static setProperty(t,e,s){return"colors"===e&&(t.colors=new Map,ti.forEach(s,(e,s)=>{t.colors.set(ti.parseEnum(s,ot),Se.fromJson(e))}),!0)}},en=class t{static fromJson(e,s){s&&ti.forEach(s,(s,i)=>t.setProperty(e,i,s))}static toJson(t){if(!t)return null;const e=new Map;return e.set("id",t.id),e.set("beats",t.beats.map(t=>Zi.toJson(t))),t.style&&e.set("style",tn.toJson(t.style)),e}static setProperty(t,e,s){switch(e){case"id":return t.id=s,!0;case"beats":t.beats=[];for(const e of s){const s=new Xt;Zi.fromJson(s,e),t.addBeat(s)}return!0;case"style":return s?(t.style=new ct,tn.fromJson(t.style,s)):t.style=void 0,!0}return!1}},sn=class t{static fromJson(e,s){s&&ti.forEach(s,(s,i)=>t.setProperty(e,i,s))}static toJson(t){if(!t)return null;const e=new Map;return e.set("ratioposition",t.ratioPosition),e.set("pedaltype",t.pedalType),e}static setProperty(t,e,s){switch(e){case"ratioposition":return t.ratioPosition=s,!0;case"pedaltype":return t.pedalType=ti.parseEnum(s,U),!0}return!1}},nn=class t{static fromJson(e,s){s&&ti.forEach(s,(s,i)=>t.setProperty(e,i,s))}static toJson(t){if(!t)return null;const e=new Map;{const s=new Map;e.set("colors",s);for(const[e,i]of t.colors)s.set(e.toString(),Se.toJson(i))}return e}static setProperty(t,e,s){return"colors"===e&&(t.colors=new Map,ti.forEach(s,(e,s)=>{t.colors.set(ti.parseEnum(s,j),Se.fromJson(e))}),!0)}},rn=class t{static fromJson(e,s){s&&ti.forEach(s,(s,i)=>t.setProperty(e,i,s))}static toJson(t){if(!t)return null;const e=new Map;return e.set("id",t.id),e.set("clef",t.clef),e.set("clefottava",t.clefOttava),e.set("voices",t.voices.map(t=>en.toJson(t))),e.set("similemark",t.simileMark),e.set("displayscale",t.displayScale),e.set("displaywidth",t.displayWidth),e.set("sustainpedals",t.sustainPedals.map(t=>sn.toJson(t))),e.set("barlineleft",t.barLineLeft),e.set("barlineright",t.barLineRight),e.set("keysignature",t.keySignature),e.set("keysignaturetype",t.keySignatureType),e.set("barnumberdisplay",t.barNumberDisplay),t.style&&e.set("style",nn.toJson(t.style)),e}static setProperty(t,e,s){switch(e){case"id":return t.id=s,!0;case"clef":return t.clef=ti.parseEnum(s,G),!0;case"clefottava":return t.clefOttava=ti.parseEnum(s,x),!0;case"voices":t.voices=[];for(const e of s){const s=new lt;en.fromJson(s,e),t.addVoice(s)}return!0;case"similemark":return t.simileMark=ti.parseEnum(s,H),!0;case"displayscale":return t.displayScale=s,!0;case"displaywidth":return t.displayWidth=s,!0;case"sustainpedals":t.sustainPedals=[];for(const e of s){const s=new X;sn.fromJson(s,e),t.sustainPedals.push(s)}return!0;case"barlineleft":return t.barLineLeft=ti.parseEnum(s,q),!0;case"barlineright":return t.barLineRight=ti.parseEnum(s,q),!0;case"keysignature":return t.keySignature=ti.parseEnum(s,V),!0;case"keysignaturetype":return t.keySignatureType=ti.parseEnum(s,z),!0;case"barnumberdisplay":return t.barNumberDisplay=ti.parseEnum(s,nt),!0;case"style":return s?(t.style=new J,nn.fromJson(t.style,s)):t.style=void 0,!0}return!1}},an=class t{static fromJson(e,s){s&&ti.forEach(s,(s,i)=>t.setProperty(e,i,s))}static toJson(t){if(!t)return null;const e=new Map;return e.set("name",t.name),e.set("firstfret",t.firstFret),e.set("strings",t.strings),e.set("barrefrets",t.barreFrets),e.set("showname",t.showName),e.set("showdiagram",t.showDiagram),e.set("showfingering",t.showFingering),e}static setProperty(t,e,s){switch(e){case"name":return t.name=s,!0;case"firstfret":return t.firstFret=s,!0;case"strings":return t.strings=s,!0;case"barrefrets":return t.barreFrets=s,!0;case"showname":return t.showName=s,!0;case"showdiagram":return t.showDiagram=s,!0;case"showfingering":return t.showFingering=s,!0}return!1}},hn=class t{static fromJson(e,s){s&&ti.forEach(s,(s,i)=>t.setProperty(e,i,s))}static toJson(t){if(!t)return null;const e=new Map;return e.set("isstandard",t.isStandard),e.set("name",t.name),e.set("tunings",t.tunings),e}static setProperty(t,e,s){switch(e){case"isstandard":return t.isStandard=s,!0;case"name":return t.name=s,!0;case"tunings":return t.tunings=s,!0}return!1}},on=class t{static fromJson(e,s){s&&ti.forEach(s,(s,i)=>t.setProperty(e,i,s))}static toJson(t){if(!t)return null;const e=new Map;if(e.set("bars",t.bars.map(t=>rn.toJson(t))),null!==t.chords){const s=new Map;e.set("chords",s);for(const[e,i]of t.chords)s.set(e.toString(),an.toJson(i))}return e.set("capo",t.capo),e.set("transpositionpitch",t.transpositionPitch),e.set("displaytranspositionpitch",t.displayTranspositionPitch),e.set("stringtuning",hn.toJson(t.stringTuning)),e.set("showslash",t.showSlash),e.set("shownumbered",t.showNumbered),e.set("showtablature",t.showTablature),e.set("showstandardnotation",t.showStandardNotation),e.set("ispercussion",t.isPercussion),e.set("standardnotationlinecount",t.standardNotationLineCount),e}static setProperty(t,e,s){switch(e){case"bars":t.bars=[];for(const e of s){const s=new Y;rn.fromJson(s,e),t.addBar(s)}return!0;case"chords":return t.chords=new Map,ti.forEach(s,(e,s)=>{const i=new ye;an.fromJson(i,e),t.addChord(s,i)}),!0;case"capo":return t.capo=s,!0;case"transpositionpitch":return t.transpositionPitch=s,!0;case"displaytranspositionpitch":return t.displayTranspositionPitch=s,!0;case"stringtuning":return hn.fromJson(t.stringTuning,s),!0;case"showslash":return t.showSlash=s,!0;case"shownumbered":return t.showNumbered=s,!0;case"showtablature":return t.showTablature=s,!0;case"showstandardnotation":return t.showStandardNotation=s,!0;case"ispercussion":return t.isPercussion=s,!0;case"standardnotationlinecount":return t.standardNotationLineCount=s,!0}return!1}},cn=class t{static fromJson(e,s){s&&ti.forEach(s,(s,i)=>t.setProperty(e,i,s))}static toJson(t){if(!t)return null;const e=new Map;return e.set("volume",t.volume),e.set("balance",t.balance),e.set("port",t.port),e.set("program",t.program),e.set("bank",t.bank),e.set("primarychannel",t.primaryChannel),e.set("secondarychannel",t.secondaryChannel),e.set("ismute",t.isMute),e.set("issolo",t.isSolo),e}static setProperty(t,e,s){switch(e){case"volume":return t.volume=s,!0;case"balance":return t.balance=s,!0;case"port":return t.port=s,!0;case"program":return t.program=s,!0;case"bank":return t.bank=s,!0;case"primarychannel":return t.primaryChannel=s,!0;case"secondarychannel":return t.secondaryChannel=s,!0;case"ismute":return t.isMute=s,!0;case"issolo":return t.isSolo=s,!0}return!1}},ln=class t{static fromJson(e,s){s&&ti.forEach(s,(s,i)=>t.setProperty(e,i,s))}static toJson(t){if(!t)return null;const e=new Map;return e.set("id",t.id),e.set("elementtype",t.elementType),e.set("staffline",t.staffLine),e.set("noteheaddefault",t.noteHeadDefault),e.set("noteheadhalf",t.noteHeadHalf),e.set("noteheadwhole",t.noteHeadWhole),e.set("techniquesymbol",t.techniqueSymbol),e.set("techniquesymbolplacement",t.techniqueSymbolPlacement),e.set("outputmidinumber",t.outputMidiNumber),e}static setProperty(t,e,s){switch(e){case"id":return t.id=s,!0;case"elementtype":return t.elementType=s,!0;case"staffline":return t.staffLine=s,!0;case"noteheaddefault":return t.noteHeadDefault=ti.parseEnum(s,xt),!0;case"noteheadhalf":return t.noteHeadHalf=ti.parseEnum(s,xt),!0;case"noteheadwhole":return t.noteHeadWhole=ti.parseEnum(s,xt),!0;case"techniquesymbol":return t.techniqueSymbol=ti.parseEnum(s,xt),!0;case"techniquesymbolplacement":return t.techniqueSymbolPlacement=ti.parseEnum(s,Mt),!0;case"outputmidinumber":return t.outputMidiNumber=s,!0}return!1}},un=class t{static fromJson(e,s){s&&ti.forEach(s,(s,i)=>t.setProperty(e,i,s))}static toJson(t){if(!t)return null;const e=new Map;{const s=new Map;e.set("colors",s);for(const[e,i]of t.colors)s.set(e.toString(),Se.toJson(i))}return e}static setProperty(t,e,s){return"colors"===e&&(t.colors=new Map,ti.forEach(s,(e,s)=>{t.colors.set(ti.parseEnum(s,Pe),Se.fromJson(e))}),!0)}},dn=class t{static fromJson(e,s){s&&ti.forEach(s,(s,i)=>t.setProperty(e,i,s))}static toJson(t){if(!t)return null;const e=new Map;if(e.set("staves",t.staves.map(t=>on.toJson(t))),e.set("playbackinfo",cn.toJson(t.playbackInfo)),e.set("color",Se.toJson(t.color)),e.set("name",t.name),e.set("isvisibleonmultitrack",t.isVisibleOnMultiTrack),e.set("shortname",t.shortName),e.set("defaultsystemslayout",t.defaultSystemsLayout),e.set("systemslayout",t.systemsLayout),void 0!==t.lineBreaks){const s=[];e.set("linebreaks",s);for(const e of t.lineBreaks)s.push(e)}return e.set("percussionarticulations",t.percussionArticulations.map(t=>ln.toJson(t))),t.style&&e.set("style",un.toJson(t.style)),e}static setProperty(t,e,s){switch(e){case"staves":t.staves=[];for(const e of s){const s=new ve;on.fromJson(s,e),t.addStaff(s)}return!0;case"playbackinfo":return cn.fromJson(t.playbackInfo,s),!0;case"color":return t.color=Se.fromJson(s),!0;case"name":return t.name=s,!0;case"isvisibleonmultitrack":return t.isVisibleOnMultiTrack=s,!0;case"shortname":return t.shortName=s,!0;case"defaultsystemslayout":return t.defaultSystemsLayout=s,!0;case"systemslayout":return t.systemsLayout=s,!0;case"linebreaks":for(const e of s)t.addLineBreaks(e);return!0;case"percussionarticulations":t.percussionArticulations=[];for(const e of s){const s=new vt;ln.fromJson(s,e),t.percussionArticulations.push(s)}return!0;case"style":return s?(t.style=new Ce,un.fromJson(t.style,s)):t.style=void 0,!0}return!1}},fn=class t{static fromJson(e,s){s&&ti.forEach(s,(s,i)=>t.setProperty(e,i,s))}static toJson(t){if(!t)return null;const e=new Map;if(e.set("hidedynamics",t.hideDynamics),e.set("bracketextendmode",t.bracketExtendMode),e.set("usesystemsignseparator",t.useSystemSignSeparator),e.set("globaldisplaytuning",t.globalDisplayTuning),null!==t.perTrackDisplayTuning){const s=new Map;e.set("pertrackdisplaytuning",s);for(const[e,i]of t.perTrackDisplayTuning)s.set(e.toString(),i)}if(e.set("globaldisplaychorddiagramsontop",t.globalDisplayChordDiagramsOnTop),null!==t.perTrackChordDiagramsOnTop){const s=new Map;e.set("pertrackchorddiagramsontop",s);for(const[e,i]of t.perTrackChordDiagramsOnTop)s.set(e.toString(),i)}if(e.set("globaldisplaychorddiagramsinscore",t.globalDisplayChordDiagramsInScore),e.set("singletracktracknamepolicy",t.singleTrackTrackNamePolicy),e.set("multitracktracknamepolicy",t.multiTrackTrackNamePolicy),e.set("firstsystemtracknamemode",t.firstSystemTrackNameMode),e.set("othersystemstracknamemode",t.otherSystemsTrackNameMode),e.set("firstsystemtracknameorientation",t.firstSystemTrackNameOrientation),e.set("othersystemstracknameorientation",t.otherSystemsTrackNameOrientation),e.set("multitrackmultibarrest",t.multiTrackMultiBarRest),null!==t.perTrackMultiBarRest){const s=[];e.set("pertrackmultibarrest",s);for(const e of t.perTrackMultiBarRest)s.push(e)}return e.set("extendbarlines",t.extendBarLines),e.set("hideemptystaves",t.hideEmptyStaves),e.set("hideemptystavesinfirstsystem",t.hideEmptyStavesInFirstSystem),e.set("showsinglestaffbrackets",t.showSingleStaffBrackets),e.set("barnumberdisplay",t.barNumberDisplay),e}static setProperty(t,e,s){switch(e){case"hidedynamics":return t.hideDynamics=s,!0;case"bracketextendmode":return t.bracketExtendMode=ti.parseEnum(s,tt),!0;case"usesystemsignseparator":return t.useSystemSignSeparator=s,!0;case"globaldisplaytuning":return t.globalDisplayTuning=s,!0;case"pertrackdisplaytuning":return t.perTrackDisplayTuning=new Map,ti.forEach(s,(e,s)=>{t.perTrackDisplayTuning.set(Number.parseInt(s),e)}),!0;case"globaldisplaychorddiagramsontop":return t.globalDisplayChordDiagramsOnTop=s,!0;case"pertrackchorddiagramsontop":return t.perTrackChordDiagramsOnTop=new Map,ti.forEach(s,(e,s)=>{t.perTrackChordDiagramsOnTop.set(Number.parseInt(s),e)}),!0;case"globaldisplaychorddiagramsinscore":return t.globalDisplayChordDiagramsInScore=s,!0;case"singletracktracknamepolicy":return t.singleTrackTrackNamePolicy=ti.parseEnum(s,et),!0;case"multitracktracknamepolicy":return t.multiTrackTrackNamePolicy=ti.parseEnum(s,et),!0;case"firstsystemtracknamemode":return t.firstSystemTrackNameMode=ti.parseEnum(s,st),!0;case"othersystemstracknamemode":return t.otherSystemsTrackNameMode=ti.parseEnum(s,st),!0;case"firstsystemtracknameorientation":return t.firstSystemTrackNameOrientation=ti.parseEnum(s,it),!0;case"othersystemstracknameorientation":return t.otherSystemsTrackNameOrientation=ti.parseEnum(s,it),!0;case"multitrackmultibarrest":return t.multiTrackMultiBarRest=s,!0;case"pertrackmultibarrest":return t.perTrackMultiBarRest=new Set(s),!0;case"extendbarlines":return t.extendBarLines=s,!0;case"hideemptystaves":return t.hideEmptyStaves=s,!0;case"hideemptystavesinfirstsystem":return t.hideEmptyStavesInFirstSystem=s,!0;case"showsinglestaffbrackets":return t.showSingleStaffBrackets=s,!0;case"barnumberdisplay":return t.barNumberDisplay=ti.parseEnum(s,nt),!0}return!1}},pn=class t{static fromJson(e,s){s&&ti.forEach(s,(s,i)=>t.setProperty(e,i,s))}static toJson(t){return t?new Map:null}static setProperty(t,e,s){return!1}},bn=class t{static fromJson(e,s){s&&ti.forEach(s,(s,i)=>t.setProperty(e,i,s))}static toJson(t){if(!t)return null;const e=new Map;return e.set("template",t.template),e.set("isvisible",t.isVisible),e.set("textalign",t.textAlign),e}static setProperty(t,e,s){switch(e){case"template":return t.template=s,!0;case"isvisible":return t.isVisible=s,!0;case"textalign":return t.textAlign=ti.parseEnum(s,ut),!0}return!1}},mn=class t{static fromJson(e,s){s&&ti.forEach(s,(s,i)=>t.setProperty(e,i,s))}static toJson(t){if(!t)return null;const e=new Map;{const s=new Map;e.set("headerandfooter",s);for(const[e,i]of t.headerAndFooter)s.set(e.toString(),bn.toJson(i))}{const s=new Map;e.set("colors",s);for(const[e,i]of t.colors)s.set(e.toString(),Se.toJson(i))}return e}static setProperty(t,e,s){switch(e){case"headerandfooter":return t.headerAndFooter=new Map,ti.forEach(s,(e,s)=>{const i=new mt;bn.fromJson(i,e),t.headerAndFooter.set(ti.parseEnum(s,bt),i)}),!0;case"colors":return t.colors=new Map,ti.forEach(s,(e,s)=>{t.colors.set(ti.parseEnum(s,bt),Se.fromJson(e))}),!0}return!1}},gn=class t{static fromJson(e,s){s&&ti.forEach(s,(s,i)=>t.setProperty(e,i,s))}static toJson(t){if(!t)return null;const e=new Map;return e.set("album",t.album),e.set("artist",t.artist),e.set("copyright",t.copyright),e.set("instructions",t.instructions),e.set("music",t.music),e.set("notices",t.notices),e.set("subtitle",t.subTitle),e.set("title",t.title),e.set("words",t.words),e.set("tab",t.tab),e.set("masterbars",t.masterBars.map(t=>ji.toJson(t))),e.set("tracks",t.tracks.map(t=>dn.toJson(t))),e.set("defaultsystemslayout",t.defaultSystemsLayout),e.set("systemslayout",t.systemsLayout),e.set("stylesheet",fn.toJson(t.stylesheet)),t.backingTrack&&e.set("backingtrack",pn.toJson(t.backingTrack)),t.style&&e.set("style",mn.toJson(t.style)),e}static setProperty(t,e,s){switch(e){case"album":return t.album=s,!0;case"artist":return t.artist=s,!0;case"copyright":return t.copyright=s,!0;case"instructions":return t.instructions=s,!0;case"music":return t.music=s,!0;case"notices":return t.notices=s,!0;case"subtitle":return t.subTitle=s,!0;case"title":return t.title=s,!0;case"words":return t.words=s,!0;case"tab":return t.tab=s,!0;case"masterbars":t.masterBars=[];for(const e of s){const s=new Z;ji.fromJson(s,e),t.addMasterBar(s)}return!0;case"tracks":t.tracks=[];for(const e of s){const s=new Ee;dn.fromJson(s,e),t.addTrack(s)}return!0;case"defaultsystemslayout":return t.defaultSystemsLayout=s,!0;case"systemslayout":return t.systemsLayout=s,!0;case"stylesheet":return fn.fromJson(t.stylesheet,s),!0;case"backingtrack":return s?(t.backingTrack=new Ts,pn.fromJson(t.backingTrack,s)):t.backingTrack=void 0,!0;case"style":return s?(t.style=new gt,mn.fromJson(t.style,s)):t.style=void 0,!0}return!1}},wn=function(t){return t[t.SingleTrackMultiChannel=0]="SingleTrackMultiChannel",t[t.MultiTrack=1]="MultiTrack",t}({}),yn=class{events=[];addEvent(t){if(0===this.events.length||t.tick>=this.events[this.events.length-1].tick)this.events.push(t);else{let e=this.events.length;for(;e>0&&this.events[e-1].tick>t.tick;)e--;this.events.splice(e,0,t)}}writeTo(t){const e=Ie.empty();let s=0;for(const t of this.events){const i=t.tick-s;kn.writeVariableInt(e,i),t.writeTo(e),s=t.tick}const i=new Uint8Array([77,84,114,107]);t.write(i,0,i.length);const n=e.toArray();le.writeInt32BE(t,n.length),t.write(n,0,n.length)}},kn=class{format=0;division=c.QuarterTime;tickShift=0;get events(){if(1===this.tracks.length)return this.tracks[0].events;const t=[];for(const t of this.tracks)this.events.push(...t.events);return t.sort((t,e)=>t.tick-e.tick),t}tracks=[];Mu(t){for(;this.tracks.length<t;)this.tracks.push(new yn)}addEvent(t){0===this.format?(this.Mu(1),this.tracks[0].addEvent(t)):(this.Mu(t.track+1),this.tracks[t.track].addEvent(t))}toBinary(){const t=Ie.empty();return this.writeTo(t),t.toArray()}writeTo(t){const e=new Uint8Array([77,84,104,100]);t.write(e,0,e.length),le.writeInt32BE(t,6),le.writeInt16BE(t,this.format),le.writeInt16BE(t,this.tracks.length),le.writeInt16BE(t,this.division);for(const e of this.tracks)e.writeTo(t)}static writeVariableInt(t,e){const s=new Uint8Array(4);let i=0;do{s[i++]=127&e,e>>=7}while(e>0);for(;i>0;)i--,i>0?t.writeByte(128|s[i]):t.writeByte(s[i])}},Sn=function(t){return t[t.TimeSignature=88]="TimeSignature",t[t.NoteOn=128]="NoteOn",t[t.NoteOff=144]="NoteOff",t[t.ControlChange=176]="ControlChange",t[t.ProgramChange=192]="ProgramChange",t[t.TempoChange=81]="TempoChange",t[t.PitchBend=224]="PitchBend",t[t.PerNotePitchBend=96]="PerNotePitchBend",t[t.EndOfTrack=47]="EndOfTrack",t[t.AlphaTabRest=241]="AlphaTabRest",t[t.AlphaTabMetronome=242]="AlphaTabMetronome",t[t.SystemExclusive=240]="SystemExclusive",t[t.SystemExclusive2=247]="SystemExclusive2",t[t.Meta=255]="Meta",t}({}),Bn=class{track;tick;type;constructor(t,e,s){this.track=t,this.tick=e,this.type=s}get command(){return this.type}get message(){return 0}get data1(){return 0}get data2(){return 0}},_n=class extends Bn{numerator;denominatorIndex;midiClocksPerMetronomeClick;thirtySecondNodesInQuarter;constructor(t,e,s,i,n,r){super(t,e,88),this.track=t,this.tick=e,this.numerator=s,this.denominatorIndex=i,this.midiClocksPerMetronomeClick=n,this.thirtySecondNodesInQuarter=r}writeTo(t){t.writeByte(255),t.writeByte(88),kn.writeVariableInt(t,4),t.writeByte(255&this.numerator),t.writeByte(255&this.denominatorIndex),t.writeByte(255&this.midiClocksPerMetronomeClick),t.writeByte(255&this.thirtySecondNodesInQuarter)}},xn=class t extends Bn{static AlphaTabManufacturerId=125;static MetronomeEventId=0;static RestEventId=1;writeTo(e){e.writeByte(240);const s=Ie.withCapacity(16);s.writeByte(t.AlphaTabManufacturerId),this.writeEventData(s),s.writeByte(247),kn.writeVariableInt(e,s.length),s.copyTo(e)}},Tn=class extends xn{metronomeNumerator;metronomeDurationInTicks;metronomeDurationInMilliseconds;isMetronome=!0;constructor(t,e,s,i,n){super(t,e,242),this.metronomeNumerator=s,this.metronomeDurationInMilliseconds=n,this.metronomeDurationInTicks=i}writeEventData(t){t.writeByte(xn.MetronomeEventId),t.writeByte(this.metronomeNumerator),le.writeInt32LE(t,this.metronomeDurationInTicks),le.writeInt32LE(t,this.metronomeDurationInMilliseconds)}},Mn=class extends xn{channel;constructor(t,e,s){super(t,e,241),this.channel=s}writeEventData(t){t.writeByte(xn.RestEventId),t.writeByte(this.channel)}},vn=class extends Bn{channel;noteKey;noteVelocity;constructor(t,e,s,i,n,r){super(t,e,s),this.channel=i,this.noteKey=n,this.noteVelocity=r}get data1(){return this.noteKey}get data2(){return this.noteVelocity}},Nn=class extends vn{constructor(t,e,s,i,n){super(t,e,128,s,i,n)}writeTo(t){t.writeByte(15&this.channel|144),t.writeByte(255&this.noteKey),t.writeByte(255&this.noteVelocity)}},Pn=class extends vn{constructor(t,e,s,i,n){super(t,e,144,s,i,n)}writeTo(t){t.writeByte(15&this.channel|128),t.writeByte(255&this.noteKey),t.writeByte(255&this.noteVelocity)}},Cn=class extends Bn{channel;controller;value;constructor(t,e,s,i,n){super(t,e,176),this.channel=s,this.controller=i,this.value=n}writeTo(t){t.writeByte(15&this.channel|176),t.writeByte(255&this.controller),t.writeByte(255&this.value)}get data1(){return this.controller}get data2(){return this.value}},En=class extends Bn{channel;program;constructor(t,e,s,i){super(t,e,192),this.channel=s,this.program=i}writeTo(t){t.writeByte(15&this.channel|192),t.writeByte(255&this.program)}get data1(){return this.program}},Fn=class extends Bn{get microSecondsPerQuarterNote(){return 6e7/this.beatsPerMinute}set microSecondsPerQuarterNote(t){this.beatsPerMinute=6e7/t}beatsPerMinute=0;constructor(t,e){super(0,t,81),this.microSecondsPerQuarterNote=e}writeTo(t){t.writeByte(255),t.writeByte(81),t.writeByte(3),t.writeByte(this.microSecondsPerQuarterNote>>16&255),t.writeByte(this.microSecondsPerQuarterNote>>8&255),t.writeByte(255&this.microSecondsPerQuarterNote)}},An=class extends Bn{channel;value;constructor(t,e,s,i){super(t,e,224),this.channel=s,this.value=i}writeTo(t){t.writeByte(15&this.channel|224),t.writeByte(127&this.value),t.writeByte(this.value>>7&127)}get data1(){return 127&this.value}get data2(){return this.value>>7&127}},Dn=class extends Bn{channel;noteKey;value;constructor(t,e,s,i,n){super(t,e,96),this.channel=s,this.noteKey=i,this.value=n}writeTo(t){throw new a(r.General,"Note Bend (Midi2.0) events cannot be exported to SMF1.0")}},Ln=class extends Bn{constructor(t,e){super(t,e,47)}writeTo(t){t.writeByte(255),t.writeByte(47),t.writeByte(0)}},Wn=class t{static vu(t,e){if(e instanceof Map){if("fromEntries"in Object)return Object.fromEntries(e);const t={};for(const[s,i]of e)t[s]=i;return t}return ArrayBuffer.isView(e)?Array.apply([],[e]):e}static scoreToJson(e){const s=t.scoreToJsObject(e);return JSON.stringify(s,t.vu)}static jsonToScore(e,s){return t.jsObjectToScore(JSON.parse(e),s)}static scoreToJsObject(t){return gn.toJson(t)}static jsObjectToScore(t,e){const s=new wt;return gn.fromJson(s,t),s.finish(e??new Fi),s}static settingsToJson(e){const s=t.settingsToJsObject(e);return JSON.stringify(s,t.vu)}static jsonToSettings(e){return t.jsObjectToSettings(JSON.parse(e))}static settingsToJsObject(t){return Ci.toJson(t)}static jsObjectToSettings(t){const e=new Fi;return Ci.fromJson(e,t),e}static jsObjectToMidiFile(e){const s=new kn;return ti.forEach(e,(e,i)=>{switch(i){case"tickShift":s.tickShift=e;break;case"division":s.division=e;break;case"tracks":for(const i of e){const e=t.Nu(i);s.tracks.push(e)}}}),s}static Nu(e){const s=new yn;return ti.forEach(e,(e,i)=>{if("events"===i)for(const i of e){const e=t.jsObjectToMidiEvent(i);s.events.push(e)}}),s}static jsObjectToMidiEvent(t){const e=ti.getValue(t,"track"),s=ti.getValue(t,"tick"),i=ti.getValue(t,"type");switch(i){case Sn.TimeSignature:return new _n(e,s,ti.getValue(t,"numerator"),ti.getValue(t,"denominatorIndex"),ti.getValue(t,"midiClocksPerMetronomeClick"),ti.getValue(t,"thirdySecondNodesInQuarter"));case Sn.AlphaTabRest:return new Mn(e,s,ti.getValue(t,"channel"));case Sn.AlphaTabMetronome:return new Tn(e,s,ti.getValue(t,"metronomeNumerator"),ti.getValue(t,"metronomeDurationInTicks"),ti.getValue(t,"metronomeDurationInMilliseconds"));case Sn.NoteOn:return new Nn(e,s,ti.getValue(t,"channel"),ti.getValue(t,"noteKey"),ti.getValue(t,"noteVelocity"));case Sn.NoteOff:return new Pn(e,s,ti.getValue(t,"channel"),ti.getValue(t,"noteKey"),ti.getValue(t,"noteVelocity"));case Sn.ControlChange:return new Cn(e,s,ti.getValue(t,"channel"),ti.getValue(t,"controller"),ti.getValue(t,"value"));case Sn.ProgramChange:return new En(e,s,ti.getValue(t,"channel"),ti.getValue(t,"program"));case Sn.TempoChange:const i=new Fn(s,0);return i.beatsPerMinute=ti.getValue(t,"beatsPerMinute"),i;case Sn.PitchBend:return new An(e,s,ti.getValue(t,"channel"),ti.getValue(t,"value"));case Sn.PerNotePitchBend:return new Dn(e,s,ti.getValue(t,"channel"),ti.getValue(t,"noteKey"),ti.getValue(t,"value"));case Sn.EndOfTrack:return new Ln(e,s)}throw new a(r.Format,`Unknown Midi Event type: ${i}`)}static midiFileToJsObject(e){const s=new Map;s.set("division",e.division),s.set("tickShift",e.tickShift);const i=[];for(const s of e.tracks)i.push(t.Pu(s));return s.set("tracks",i),s}static Pu(e){const s=new Map,i=[];for(const s of e.events)i.push(t.midiEventToJsObject(s));return s.set("events",i),s}static midiEventToJsObject(t){const e=new Map;switch(e.set("track",t.track),e.set("tick",t.tick),e.set("type",t.type),t.type){case Sn.TimeSignature:e.set("numerator",t.numerator),e.set("denominatorIndex",t.denominatorIndex),e.set("midiClocksPerMetronomeClick",t.midiClocksPerMetronomeClick),e.set("thirdySecondNodesInQuarter",t.thirtySecondNodesInQuarter);break;case Sn.AlphaTabRest:e.set("channel",t.channel);break;case Sn.AlphaTabMetronome:e.set("metronomeNumerator",t.metronomeNumerator),e.set("metronomeDurationInMilliseconds",t.metronomeDurationInMilliseconds),e.set("metronomeDurationInTicks",t.metronomeDurationInTicks);break;case Sn.NoteOn:case Sn.NoteOff:e.set("channel",t.channel),e.set("noteKey",t.noteKey),e.set("noteVelocity",t.noteVelocity);break;case Sn.ControlChange:e.set("channel",t.channel),e.set("controller",t.controller),e.set("value",t.value);break;case Sn.ProgramChange:e.set("channel",t.channel),e.set("program",t.program);break;case Sn.TempoChange:e.set("beatsPerMinute",t.beatsPerMinute);break;case Sn.PitchBend:e.set("channel",t.channel),e.set("value",t.value);break;case Sn.PerNotePitchBend:e.set("channel",t.channel),e.set("noteKey",t.noteKey),e.set("value",t.value);case Sn.EndOfTrack:}return e}},Rn=class{events;constructor(t){this.events=t}},On=class{playbackRange;constructor(t){this.playbackRange=t}},In=function(t){return t[t.Paused=0]="Paused",t[t.Playing=1]="Playing",t}({}),Gn=class{state;stopped;constructor(t,e){this.state=t,this.stopped=e}},Hn=class{currentTime;endTime;currentTick;endTick;isSeek;originalTempo=0;modifiedTempo=0;constructor(t,e,s,i,n,r,a){this.currentTime=t,this.endTime=e,this.currentTick=s,this.endTick=i,this.isSeek=n,this.originalTempo=r,this.modifiedTempo=a}},$n=class{Cu;cn;Eu=!1;Fu=!1;Au=!1;Ni=In.Paused;Du=0;Lu=0;Wu=0;Ru=0;Ou=!1;Iu=null;Gu=[];Hu;$u=new Hn(0,0,0,0,!1,120,120);get output(){return this.cn}get isReady(){return this.Fu&&this.Au}get isReadyForPlayback(){return this.Eu}get state(){return this.Ni}get logLevel(){return O.logLevel}get worker(){return this.Cu}set logLevel(t){O.logLevel=t,this.Cu.postMessage({cmd:"alphaSynth.setLogLevel",value:t})}get masterVolume(){return this.Du}set masterVolume(t){t=Math.max(t,yt.MinVolume),this.Du=t,this.Cu.postMessage({cmd:"alphaSynth.setMasterVolume",value:t})}get metronomeVolume(){return this.Lu}set metronomeVolume(t){t=Math.max(t,yt.MinVolume),this.Lu=t,this.Cu.postMessage({cmd:"alphaSynth.setMetronomeVolume",value:t})}get countInVolume(){return this.Wu}set countInVolume(t){t=Math.max(t,yt.MinVolume),this.Wu=t,this.Cu.postMessage({cmd:"alphaSynth.setCountInVolume",value:t})}get midiEventsPlayedFilter(){return this.Gu}set midiEventsPlayedFilter(t){this.Gu=t,this.Cu.postMessage({cmd:"alphaSynth.setMidiEventsPlayedFilter",value:Bu.prepareForPostMessage(t)})}get playbackSpeed(){return this.Ru}set playbackSpeed(t){t=Bt.clamp(t,yt.MinPlaybackSpeed,yt.MaxPlaybackSpeed),this.Ru=t,this.Cu.postMessage({cmd:"alphaSynth.setPlaybackSpeed",value:t})}get loadedMidiInfo(){return this.loadedMidiInfo}get currentPosition(){return this.$u}get tickPosition(){return this.$u.currentTick}set tickPosition(t){t<0&&(t=0),this.$u=new Hn(this.$u.currentTime,this.$u.endTime,t,this.$u.endTick,!0,this.$u.originalTempo,this.$u.modifiedTempo),this.Cu.postMessage({cmd:"alphaSynth.setTickPosition",value:t})}get timePosition(){return this.$u.currentTime}set timePosition(t){t<0&&(t=0),this.$u=new Hn(t,this.$u.endTime,this.$u.currentTick,this.$u.endTick,!0,this.$u.originalTempo,this.$u.modifiedTempo),this.Cu.postMessage({cmd:"alphaSynth.setTimePosition",value:t})}get isLooping(){return this.Ou}set isLooping(t){this.Ou=t,this.Cu.postMessage({cmd:"alphaSynth.setIsLooping",value:t})}get playbackRange(){return this.Iu}set playbackRange(t){t&&(t.startTick<0&&(t.startTick=0),t.endTick<0&&(t.endTick=0)),this.Iu=t,this.Cu.postMessage({cmd:"alphaSynth.setPlaybackRange",value:Bu.prepareForPostMessage(t)})}constructor(t,e,s){this.Eu=!1,this.Fu=!1,this.Au=!1,this.Ni=In.Paused,this.Du=0,this.Lu=0,this.Ru=0,this.Ou=!1,this.Iu=null,this.cn=t,this.cn.ready.on(this.Vu.bind(this)),this.cn.samplesPlayed.on(this.onOutputSamplesPlayed.bind(this)),this.cn.sampleRequest.on(this.onOutputSampleRequest.bind(this)),this.cn.open(e.player.bufferTimeInMilliseconds),this.Cu=s,this.Cu.addEventListener("message",t=>this.handleWorkerMessage(t)),this.Cu.postMessage({cmd:"alphaSynth.initialize",sampleRate:this.cn.sampleRate,logLevel:e.core.logLevel,bufferTimeInMilliseconds:e.player.bufferTimeInMilliseconds}),this.masterVolume=1,this.playbackSpeed=1,this.metronomeVolume=0}destroy(){this.Cu.postMessage({cmd:"alphaSynth.destroy"})}play(){return this.cn.activate(),this.Cu.postMessage({cmd:"alphaSynth.play"}),!0}pause(){this.Cu.postMessage({cmd:"alphaSynth.pause"})}playPause(){this.cn.activate(),this.Cu.postMessage({cmd:"alphaSynth.playPause"})}stop(){this.Cu.postMessage({cmd:"alphaSynth.stop"})}playOneTimeMidiFile(t){this.Cu.postMessage({cmd:"alphaSynth.playOneTimeMidiFile",midi:Wn.midiFileToJsObject(Bu.prepareForPostMessage(t))})}loadSoundFont(t,e){this.Cu.postMessage({cmd:"alphaSynth.loadSoundFontBytes",data:Bu.prepareForPostMessage(t),append:e})}resetSoundFonts(){this.Cu.postMessage({cmd:"alphaSynth.resetSoundFonts"})}loadMidiFile(t){this.Cu.postMessage({cmd:"alphaSynth.loadMidi",midi:Wn.midiFileToJsObject(Bu.prepareForPostMessage(t))})}applyTranspositionPitches(t){this.Cu.postMessage({cmd:"alphaSynth.applyTranspositionPitches",transpositionPitches:Bu.prepareForPostMessage(t)})}setChannelTranspositionPitch(t,e){this.Cu.postMessage({cmd:"alphaSynth.setChannelTranspositionPitch",channel:t,semitones:e})}setChannelMute(t,e){this.Cu.postMessage({cmd:"alphaSynth.setChannelMute",channel:t,mute:e})}resetChannelStates(){this.Cu.postMessage({cmd:"alphaSynth.resetChannelStates"})}setChannelSolo(t,e){this.Cu.postMessage({cmd:"alphaSynth.setChannelSolo",channel:t,solo:e})}setChannelVolume(t,e){e=Math.max(e,yt.MinVolume),this.Cu.postMessage({cmd:"alphaSynth.setChannelVolume",channel:t,volume:e})}handleWorkerMessage(t){const e=t.data;switch(e.cmd){case"alphaSynth.ready":this.Fu=!0,this.zu();break;case"alphaSynth.destroyed":this.Cu.terminate();break;case"alphaSynth.readyForPlayback":this.Eu=!0,this.Uu();break;case"alphaSynth.positionChanged":this.$u=e.args,this.positionChanged.trigger(this.$u);break;case"alphaSynth.midiEventsPlayed":this.midiEventsPlayed.trigger(new Rn(e.events.map(Wn.jsObjectToMidiEvent)));break;case"alphaSynth.playerStateChanged":this.Ni=e.state,this.stateChanged.trigger(new Gn(e.state,e.stopped));break;case"alphaSynth.playbackRangeChanged":this.Iu=e.playbackRange,this.playbackRangeChanged.trigger(new On(this.Iu));break;case"alphaSynth.finished":this.finished.trigger();break;case"alphaSynth.soundFontLoaded":this.soundFontLoaded.trigger();break;case"alphaSynth.soundFontLoadFailed":this.soundFontLoadFailed.trigger(e.error);break;case"alphaSynth.midiLoaded":this.Uu(),this.Hu=e.args,this.midiLoaded.trigger(this.Hu);break;case"alphaSynth.midiLoadFailed":this.Uu(),this.midiLoadFailed.trigger(e.error);break;case"alphaSynth.output.addSamples":this.cn.addSamples(e.samples);break;case"alphaSynth.output.play":this.cn.play();break;case"alphaSynth.output.pause":this.cn.pause();break;case"alphaSynth.output.destroy":this.cn.destroy();break;case"alphaSynth.output.resetSamples":this.cn.resetSamples()}}zu(){this.isReady&&this.ready.trigger()}Uu(){this.isReadyForPlayback&&this.readyForPlayback.trigger()}ready=new js;readyForPlayback=new js;finished=new js;soundFontLoaded=new js;soundFontLoadFailed=new Js;midiLoaded=new Js;midiLoadFailed=new Js;stateChanged=new Js;positionChanged=new Js;midiEventsPlayed=new Js;playbackRangeChanged=new Js;onOutputSampleRequest(){this.Cu.postMessage({cmd:"alphaSynth.output.sampleRequest"})}onOutputSamplesPlayed(t){this.Cu.postMessage({cmd:"alphaSynth.output.samplesPlayed",samples:t})}Vu(){this.Au=!0,this.zu()}loadBackingTrack(t){}updateSyncPoints(t){}},Vn=class{masterBarBounds;visualBounds;realBounds;bar;beats=[];addBeat(t){t.barBounds=this,this.beats.push(t),this.masterBarBounds.addBeat(t)}findBeatAtPos(t){let e=null;for(const s of this.beats)if(!e||s.realBounds.x<t)e=s;else if(s.realBounds.x>t)break;return e}finish(t=1){this.realBounds.scaleWith(t),this.visualBounds.scaleWith(t),this.beats.sort((t,e)=>t.realBounds.x-e.realBounds.x);for(const e of this.beats)e.finish(t)}},zn=class{barBounds;visualBounds;onNotesX=0;realBounds;beat;notes=null;addNote(t){this.notes||(this.notes=[]),t.beatBounds=this,this.notes.push(t)}findNoteAtPos(t,e){const s=this.notes;if(!s)return null;for(const i of s){const s=i.noteHeadBounds.y+i.noteHeadBounds.h,n=i.noteHeadBounds.x+i.noteHeadBounds.w;if(i.noteHeadBounds.x<=t&&i.noteHeadBounds.y<=e&&t<=n&&e<=s)return i.note}return null}finish(t=1){if(this.realBounds.scaleWith(t),this.visualBounds.scaleWith(t),this.onNotesX*=t,this.notes)for(const e of this.notes)e.finish(t)}},Un=class{index=0;isFirstOfLine=!1;visualBounds;realBounds;lineAlignedBounds;bars=[];staffSystemBounds=null;get staveGroupBounds(){return this.staffSystemBounds}addBar(t){t.masterBarBounds=this,this.bars.push(t)}findBeatAtPos(t){let e=null;for(const s of this.bars){const i=s.findBeatAtPos(t);if(i&&(!e||e.realBounds.x<i.realBounds.x)){const s=Math.abs(i.realBounds.x-t);(!e||s<1e7)&&(e=i)}}return e?e.beat:null}finish(t=1){this.realBounds.scaleWith(t),this.visualBounds.scaleWith(t),this.lineAlignedBounds.scaleWith(t),this.bars.sort((t,e)=>t.realBounds.y<e.realBounds.y?-1:t.realBounds.y>e.realBounds.y?1:t.realBounds.x<e.realBounds.x?-1:t.realBounds.x>e.realBounds.x?1:0);for(const e of this.bars)e.finish(t)}addBeat(t){this.staffSystemBounds.boundsLookup.addBeat(t)}},Xn=class{beatBounds;noteHeadBounds;note;finish(t=1){this.noteHeadBounds.scaleWith(t)}},jn=class{index=0;visualBounds;realBounds;bars=[];boundsLookup;isFinished=!1;finish(t=1){if(!this.isFinished){this.realBounds.scaleWith(t),this.visualBounds.scaleWith(t);for(const e of this.bars)e.finish(t);this.isFinished=!0}}addBar(t){this.boundsLookup.addMasterBar(t),t.staffSystemBounds=this,this.bars.push(t)}findBarAtPos(t){let e=null;for(const s of this.bars)if(!e||s.realBounds.x<t)e=s;else if(t>s.realBounds.x+s.realBounds.w)break;return e}},Jn=class t{toJson(){const e=new Map,s=[];e.set("staffSystems",s);for(const e of this.staffSystems){const i=new Map;i.set("visualBounds",t.Xu(e.visualBounds)),i.set("realBounds",t.Xu(e.realBounds));const n=[];i.set("bars",n);for(const s of e.bars){const e=new Map;e.set("lineAlignedBounds",t.Xu(s.lineAlignedBounds)),e.set("visualBounds",t.Xu(s.visualBounds)),e.set("realBounds",t.Xu(s.realBounds)),e.set("index",s.index),e.set("isFirstOfLine",s.isFirstOfLine);const i=[];e.set("bars",i);for(const e of s.bars){const s=new Map;s.set("visualBounds",t.Xu(e.visualBounds)),s.set("realBounds",t.Xu(e.realBounds));const n=[];s.set("beats",n);for(const s of e.beats){const e=new Map;if(e.set("visualBounds",t.Xu(s.visualBounds)),e.set("realBounds",t.Xu(s.realBounds)),e.set("onNotesX",s.onNotesX),e.set("beatIndex",s.beat.index),e.set("voiceIndex",s.beat.voice.index),e.set("barIndex",s.beat.voice.bar.index),e.set("staffIndex",s.beat.voice.bar.staff.index),e.set("trackIndex",s.beat.voice.bar.staff.track.index),s.notes){const i=[];e.set("notes",i);for(const e of s.notes){const s=new Map;s.set("index",e.note.index),s.set("noteHeadBounds",t.Xu(e.noteHeadBounds)),i.push(s)}}n.push(e)}i.push(s)}n.push(e)}s.push(i)}return e}static fromJson(e,s){if(null===e)return null;const i=new t,n=e.get("staffSystems");for(const e of n){const n=new jn;n.visualBounds=t.ju(e.get("visualBounds")),n.realBounds=t.ju(e.get("realBounds")),i.addStaffSystem(n);for(const n of e.get("bars")){const e=new Un;e.index=n.get("index"),e.isFirstOfLine=n.get("isFirstOfLine"),e.lineAlignedBounds=t.ju(n.get("lineAlignedBounds")),e.visualBounds=t.ju(n.get("visualBounds")),e.realBounds=t.ju(n.get("realBounds")),i.addMasterBar(e);for(const i of n.get("bars")){const n=new Vn;n.visualBounds=t.ju(i.get("visualBounds")),n.realBounds=t.ju(i.get("realBounds")),e.addBar(n);for(const e of i.get("beats")){const i=new zn;if(i.visualBounds=t.ju(e.get("visualBounds")),i.realBounds=t.ju(e.get("realBounds")),i.onNotesX=e.get("onNotesX"),i.beat=s.tracks[e.get("trackIndex")].staves[e.get("staffIndex")].bars[e.get("barIndex")].voices[e.get("voiceIndex")].beats[e.get("beatIndex")],e.has("notes")){i.notes=[];for(const s of e.get("notes")){const e=new Xn;e.note=i.beat.notes[s.get("index")],e.noteHeadBounds=t.ju(s.get("noteHeadBounds")),i.addNote(e)}}n.addBeat(i)}}}}return i}static ju(t){const e=new _s;return e.x=t.get("x"),e.y=t.get("y"),e.w=t.get("w"),e.h=t.get("h"),e}static Xu(t){const e=new Map;return e.set("x",t.x),e.set("y",t.y),e.set("w",t.w),e.set("h",t.h),e}q=new Map;Ju=new Map;qu=null;staffSystems=[];isFinished=!1;finish(t=1){for(const e of this.staffSystems)e.finish(t);this.isFinished=!0}resetForPartialUpdate(){this.isFinished=!1}clearFromMasterBar(t){let e=-1;for(let s=0;s<this.staffSystems.length;s++){const i=this.staffSystems[s].bars;if(i.length>0&&i[0].index>=t){e=s;break}}-1!==e&&this.staffSystems.splice(e,this.staffSystems.length-e);for(const e of Array.from(this.Ju.keys()))e>=t&&this.Ju.delete(e);for(const e of Array.from(this.q.keys())){const s=this.q.get(e),i=s.filter(e=>e.beat.voice.bar.index<t);0===i.length?this.q.delete(e):i.length!==s.length&&this.q.set(e,i)}this.qu=null}addStaffSystem(t){t.index=this.staffSystems.length,t.boundsLookup=this,this.staffSystems.push(t),this.qu=t}addMasterBar(t){t.staffSystemBounds?this.Ju.set(t.index,t):(t.staffSystemBounds=this.qu,this.Ju.set(t.index,t),this.qu.addBar(t))}addBeat(t){this.q.has(t.beat.id)||this.q.set(t.beat.id,[]),this.q.get(t.beat.id)?.push(t)}findMasterBarByIndex(t){return this.Ju.has(t)?this.Ju.get(t):null}findMasterBar(t){const e=t.index;return this.Ju.has(e)?this.Ju.get(e):null}findBeat(t){const e=this.findBeats(t);return e?e[0]:null}findBeats(t){const e=t.id;return this.q.has(e)?this.q.get(e):null}getBeatAtPos(t,e){let s=0,i=this.staffSystems.length-1,n=-1;for(;s<=i;){const t=(i+s)/2|0,r=this.staffSystems[t];if(e>=r.realBounds.y&&e<=r.realBounds.y+r.realBounds.h){n=t;break}e<r.realBounds.y?i=t-1:s=t+1}if(-1===n)return null;const r=this.staffSystems[n].findBarAtPos(t);return r?r.findBeatAtPos(t):null}getNoteAtPos(t,e,s){const i=this.findBeats(t);if(i)for(const t of i){const i=t.findNoteAtPos(e,s);if(i)return i}return null}},qn=class{Yu;Ku;Qu=0;boundsLookup=null;constructor(t,e){this.Yu=t,this.Ku=e,this.Ku.postMessage({cmd:"alphaTab.initialize",settings:this.Zu(t.settings)}),this.Ku.addEventListener("message",t=>this.td(t))}destroy(){this.Ku.terminate()}updateSettings(t){this.Ku.postMessage({cmd:"alphaTab.updateSettings",settings:this.Zu(t)})}Zu(t){const e=Wn.settingsToJsObject(Bu.prepareForPostMessage(t));return e.delete("player"),e}render(t){this.Ku.postMessage({cmd:"alphaTab.render",renderHints:t})}resizeRender(){this.Ku.postMessage({cmd:"alphaTab.resizeRender"})}renderResult(t){this.Ku.postMessage({cmd:"alphaTab.renderResult",resultId:t})}get width(){return this.Qu}set width(t){this.Qu=t,this.Ku.postMessage({cmd:"alphaTab.setWidth",width:t})}td(t){const e=t.data;switch(e.cmd){case"alphaTab.preRender":this.preRender.trigger(e.resize);break;case"alphaTab.partialRenderFinished":this.partialRenderFinished.trigger(e.result);break;case"alphaTab.partialLayoutFinished":this.partialLayoutFinished.trigger(e.result);break;case"alphaTab.renderFinished":this.renderFinished.trigger(e.result);break;case"alphaTab.postRenderFinished":this.Yu.score&&e.boundsLookup&&(this.boundsLookup=Jn.fromJson(e.boundsLookup,this.Yu.score),this.boundsLookup?.finish()),this.postRenderFinished.trigger();break;case"alphaTab.error":this.error.trigger(e.error)}}renderScore(t,e,s){const i=null==t?null:Wn.scoreToJsObject(Bu.prepareForPostMessage(t));this.Ku.postMessage({cmd:"alphaTab.renderScore",score:i,trackIndexes:Bu.prepareForPostMessage(e),fontSizes:Oi.fontSizeLookupTables,renderHints:s})}preRender=new Js;partialRenderFinished=new Js;partialLayoutFinished=new Js;renderFinished=new Js;postRenderFinished=new js;error=new Js},Yn=class{cursorWrapper;barCursor;beatCursor;selectionWrapper;constructor(t,e,s,i){this.cursorWrapper=t,this.barCursor=e,this.beatCursor=s,this.selectionWrapper=i}},Kn=class extends Li{ed;sd;centerAtPosition=!1;constructor(t,e,s){super(t),this.ed=e,this.sd=s}get width(){return this.element.offsetWidth/this.ed}set width(t){this.element.style.width=t*this.ed+"px"}get height(){return this.element.offsetHeight/this.sd}set height(t){this.element.style.height=t>=0?t*this.sd+"px":"100%"}setBounds(t,e,s,i){Number.isNaN(t)&&(t=this.lastBounds.x),Number.isNaN(e)&&(e=this.lastBounds.y),Number.isNaN(s)?s=this.lastBounds.w:s/=this.ed,Number.isNaN(i)?i=this.lastBounds.h:i/=this.sd;let n=`translate(${t}px, ${e}px) scale(${s}, ${i})`;this.centerAtPosition&&(n+=" translateX(-50%)"),this.element.style.transform=n,this.element.style.transformOrigin="top left",this.lastBounds.x=t,this.lastBounds.y=e,this.lastBounds.w=s,this.lastBounds.h=i}},Qn=class{sampleRate=44100;audioElement;nd=0;get backingTrackDuration(){const t=this.audioElement.duration??0;return Number.isFinite(t)?1e3*t:0}get playbackRate(){return this.audioElement.playbackRate}set playbackRate(t){this.audioElement.playbackRate=t}get masterVolume(){return this.audioElement.volume}set masterVolume(t){this.audioElement.volume=t}seekTo(t){this.audioElement.currentTime=t/1e3}loadBackingTrack(t){this.audioElement?.src&&URL.revokeObjectURL(this.audioElement.src);const e=new Blob([t.rawAudioFile]),s=this.audioElement.playbackRate;this.audioElement.src=URL.createObjectURL(e),this.audioElement.playbackRate=s}open(t){const e=document.createElement("audio");e.style.display="none",document.body.appendChild(e),e.addEventListener("seeked",()=>{this.rd()}),e.addEventListener("timeupdate",()=>{this.rd()}),this.audioElement=e,this.ready.trigger()}rd(){const t=1e3*this.audioElement.currentTime;this.timeUpdate.trigger(t)}play(){this.audioElement.play(),this.nd=window.setInterval(()=>{this.rd()},50)}destroy(){const t=this.audioElement;t&&document.body.removeChild(t)}pause(){this.audioElement.pause(),window.clearInterval(this.nd)}addSamples(t){}resetSamples(){}activate(){}ready=new js;samplesPlayed=new Js;timeUpdate=new Js;sampleRequest=new js;async enumerateOutputDevices(){return Ys.enumerateOutputDevices()}async setOutputDevice(t){await Ys.checkSinkIdSupport()&&(t?await this.audioElement.setSinkId(t.deviceId):await this.audioElement.setSinkId(""))}async getOutputDevice(){if(!await Ys.checkSinkIdSupport())return null;const t=this.audioElement.sinkId;if("string"!=typeof t||""===t||"default"===t)return null;let e=Ys.findKnownDevice(t);if(e)return e;const s=await this.enumerateOutputDevices();return e=s.find(e=>e.deviceId===t),e||(O.warning("WebAudio","Could not find output device in device list",t,s),null)}},Zn=class{value;next;constructor(t){this.value=t}},tr=class{ad;hd;get isEmpty(){return void 0===this.ad}clear(){this.ad=void 0,this.hd=void 0}enqueue(t){const e=new Zn(t);this.hd?(this.hd.next=e,this.hd=e):(this.ad=e,this.hd=e)}enqueueFront(t){const e=new Zn(t);e.next=this.ad,this.ad?this.ad=e:(this.ad=e,this.hd=e)}peek(){const t=this.ad;if(t)return t.value}dequeue(){const t=this.ad;if(!t)return;const e=t.next;return this.ad=e,e||(this.hd=void 0),t.value}},er=class{soundFonts;sampleRate=44100;useSyncPoints=!1;masterVolume=1;metronomeVolume=0;playbackRange;trackVolume=new Map;trackTranspositionPitches=new Map},sr=class{samples;currentTime=0;endTime=0;currentTick=0;endTick=0},ir=class t{eventIndex;event;isMetronome;time=0;constructor(t,e){this.eventIndex=t,this.event=e,this.isMetronome=this.event.type===Sn.AlphaTabMetronome}static newMetronomeEvent(e,s,i,n,r){return new t(e,new Tn(0,s,i,n,r))}},nr=class{masterBarIndex=0;masterBarOccurence=0;synthBpm=0;synthTime=0;synthTick=0;syncTime=0;syncBpm=0;updateSyncBpm(t,e){const s=(t-this.synthTime)/(e-this.syncTime)*this.synthBpm;this.syncBpm=s}},rr=class{bpm;ticks;time;constructor(t,e,s){this.bpm=t,this.ticks=e,this.time=s}},ar=class{tempoChanges=[];tempoChangeIndex=0;syncPoints=[];firstProgramEventPerChannel=new Map;firstTimeSignatureNumerator=0;firstTimeSignatureDenominator=0;synthData=[];division=c.QuarterTime;eventIndex=0;currentTime=0;syncPointIndex=0;playbackRange=null;playbackRangeStartTime=0;playbackRangeEndTime=0;endTick=0;endTime=0;currentTempo=0;syncPointTempo=0;metronomeChannel=yt.DefaultChannelCount-1},hr=class t{od;ld;ud;dd=null;fd=null;get metronomeChannel(){return this.ud.metronomeChannel}get isPlayingMain(){return this.ld===this.ud}get isPlayingOneTimeMidi(){return this.ld===this.dd}get isPlayingCountIn(){return this.ld===this.fd}constructor(t){this.od=t,this.ud=new ar,this.ld=this.ud}get mainPlaybackRange(){return this.ud.playbackRange}set mainPlaybackRange(t){this.ud.playbackRange=t,t&&(this.ud.playbackRangeStartTime=this.pd(this.ud,t.startTick,1),this.ud.playbackRangeEndTime=this.pd(this.ud,t.endTick,1))}isLooping=!1;get currentTime(){return this.ld.currentTime/this.playbackSpeed}get currentEndTick(){return this.ld.endTick}get currentEndTime(){return this.ld.endTime/this.playbackSpeed}get currentTempo(){return this.ld.currentTempo}get modifiedTempo(){return this.ld.syncPointTempo*this.playbackSpeed}get syncPointTempo(){return this.ld.syncPointTempo}get currentSyncPoints(){return this.ld.syncPoints}playbackSpeed=1;mainSeek(t){if(t*=this.playbackSpeed,this.mainPlaybackRange&&(t<this.ud.playbackRangeStartTime?t=this.ud.playbackRangeStartTime:t>this.ud.playbackRangeEndTime&&(t=this.ud.playbackRangeEndTime)),t>this.ud.currentTime)this.bd(t-this.ud.currentTime);else if(t<this.ud.currentTime){if(this.ud.currentTime=0,this.ud.eventIndex=0,this.ud.syncPointIndex=0,this.ud.tempoChangeIndex=0,this.ud.currentTempo=this.ud.tempoChanges[0].bpm,this.ud.syncPointTempo=this.ud.syncPoints.length>0?this.ud.syncPoints[0].syncBpm:this.ud.currentTempo,this.isPlayingMain){const t=this.od.metronomeVolume;this.od.noteOffAll(!0),this.od.resetSoft(),this.od.setupMetronomeChannel(this.metronomeChannel,t)}this.bd(t)}}bd(t){if(t<=0)return;const e=Date.now(),s=this.ud.currentTime+t;if(this.isPlayingMain)for(;this.ud.currentTime<s;)this.md(s-this.ud.currentTime)&&this.od.synthesizeSilent(yt.MicroBufferSize);this.ud.currentTime=s;const i=Date.now()-e;O.debug("Sequencer",`Silent seek finished in ${i}ms (main)`)}loadOneTimeMidi(t){this.dd=this.createStateFromFile(t),this.ld=this.dd}instrumentPrograms=new Set;percussionKeys=new Set;loadMidi(t){this.instrumentPrograms.clear(),this.percussionKeys.clear(),this.ud=this.createStateFromFile(t),this.ld=this.ud}createStateFromFile(e){const s=new ar;this.percussionKeys.add(yt.MetronomeKey),s.tempoChanges=[],s.division=e.division,s.eventIndex=0,s.currentTime=0,s.synthData=[];let i=120,n=0,r=0,a=0,h=0,o=0,c=e.tickShift,l=0,u=0,d=0;for(const f of e.events){const p=new ir(s.synthData.length,f);s.synthData.push(p);const b=f.tick-d;if(n+=b,r+=b*(6e4/(i*e.division)),p.time=r,d=f.tick,h>0)for(;c<n;){const t=ir.newMetronomeEvent(s.synthData.length,c,Math.floor(c/h)%a,h,o);s.synthData.push(t),t.time=l,c+=h,l+=o}if(f.type===Sn.TempoChange){const a=f;i=t.gd(a.beatsPerMinute),s.tempoChanges.push(new rr(i,n,r)),o=h*(6e4/(i*e.division))}else if(f.type===Sn.TimeSignature){const t=f,n=Math.pow(2,t.denominatorIndex);a=t.numerator,h=s.division*(4/n)|0,o=h*(6e4/(i*e.division)),0===s.firstTimeSignatureDenominator&&(s.firstTimeSignatureNumerator=t.numerator,s.firstTimeSignatureDenominator=n)}else if(f.type===Sn.ProgramChange){const t=f,e=t.channel;s.firstProgramEventPerChannel.has(e)||s.firstProgramEventPerChannel.set(e,p),e>u&&(u=e),e!==yt.PercussionChannel&&this.instrumentPrograms.add(t.program)}else if(f.type===Sn.NoteOn){const t=f;t.channel===yt.PercussionChannel&&this.percussionKeys.add(t.noteKey),t.channel>u&&(u=t.channel)}}return s.currentTempo=s.tempoChanges.length>0?s.tempoChanges[0].bpm:i,s.syncPointTempo=s.currentTempo,s.synthData.sort((t,e)=>t.time>e.time?1:t.time<e.time?-1:t.eventIndex-e.eventIndex),s.endTime=r,s.endTick=n,s.metronomeChannel=u+1,s}fillMidiEventQueue(){return this.md(-1)}fillMidiEventQueueToEndTime(t){for(;this.ud.currentTime<t;)this.md(t-this.ud.currentTime)&&this.od.synthesizeSilent(yt.MicroBufferSize);let e=!1;for(this.ld.currentTime=t;this.ld.eventIndex<this.ld.synthData.length&&this.ld.synthData[this.ld.eventIndex].time<this.ld.currentTime;){const t=this.ld.synthData[this.ld.eventIndex];this.od.dispatchEvent(t),this.ld.eventIndex++,e=!0}return e}md(t){let e=yt.MicroBufferSize/this.od.outSampleRate*1e3*this.playbackSpeed,s=this.wd;t>0&&(t<e&&(e=t),s=Math.min(this.wd,this.ld.currentTime+t));let i=!1;for(this.ld.currentTime+=e;this.ld.eventIndex<this.ld.synthData.length&&this.ld.synthData[this.ld.eventIndex].time<this.ld.currentTime&&this.ld.currentTime<s;)this.od.dispatchEvent(this.ld.synthData[this.ld.eventIndex]),this.ld.eventIndex++,i=!0;return i}mainTickPositionToTimePosition(t){return this.pd(this.ud,t,this.playbackSpeed)}mainUpdateSyncPoints(e){const s=this.ud;if(e.sort((t,e)=>t.synthTick-e.synthTick),s.syncPoints=[],e.length>=0){let i=120,n=0,r=0,a=0;for(let h=0;h<e.length;h++){const o=e[h];let c,l,u,d=0;if(0===h)c=i,l=0,u=0;else{const s=e[h-1];c=t.gd(s.syncBpm),l=s.syncTime,u=s.synthTick}for(;a<s.tempoChanges.length&&s.tempoChanges[a].ticks<=o.synthTick;){if(d=s.tempoChanges[a].ticks-n,d>0){n+=d,r+=d*(6e4/(i*s.division));const t=(n-u)*((o.syncTime-l)/(o.synthTick-u))+l,e=new nr;e.synthTick=n,e.synthBpm=i,e.synthTime=r,e.syncTime=t,e.syncBpm=c}i=t.gd(s.tempoChanges[a].bpm),a++}d=o.synthTick-n,n+=d,r+=d*(6e4/(i*s.division)),s.syncPoints.push(o)}}s.syncPointIndex=0,s.syncPointTempo=s.syncPoints.length>0?s.syncPoints[0].syncBpm:s.currentTempo}currentTimePositionToTickPosition(e){const s=this.ld;if(0===s.tempoChanges.length)return 0;e*=this.playbackSpeed,this.yd(s,e);const i=s.tempoChanges[s.tempoChangeIndex],n=(e-i.time)/(6e4/(t.gd(i.bpm)*s.division))|0;return i.ticks+n+1}static gd(t){return Math.max(t,1)}currentUpdateCurrentTempo(t){this.yd(this.ud,t*this.playbackSpeed)}yd(t,e){let s=t.tempoChangeIndex;for(e<t.tempoChanges[s].time&&(s=0);s+1<t.tempoChanges.length&&t.tempoChanges[s+1].time<=e;)s++;s!==t.tempoChangeIndex&&(t.tempoChangeIndex=s,t.currentTempo=t.tempoChanges[t.tempoChangeIndex].bpm,0===t.syncPoints.length&&(t.syncPointTempo=t.currentTempo))}currentUpdateSyncPoints(t){this.kd(this.ud,t)}kd(t,e){const s=t.syncPoints;if(s.length>0){let i=Math.min(t.syncPointIndex,s.length-1);for(e<s[i].syncTime&&(i=0);i+1<s.length&&s[i+1].syncTime<=e;)i++;i!==t.syncPointIndex&&(t.syncPointIndex=i,t.syncPointTempo=s[i].syncBpm)}else t.syncPointTempo=t.currentTempo}mainTimePositionFromBackingTrack(t,e){const s=this.ud,i=s.syncPoints;if(t<0||0===i.length)return t;this.kd(this.ud,t);const n=Math.min(s.syncPointIndex,i.length-1),r=i[n],a=t-r.syncTime;let h;if(n+1<i.length){const t=i[n+1],e=a/(t.syncTime-r.syncTime);h=(t.synthTime-r.synthTime)*e}else{const t=a/(e-r.syncTime);h=(s.endTime-r.synthTime)*t}return(r.synthTime+h)/this.playbackSpeed}mainTimePositionToBackingTrack(t,e){const s=this.ud,i=s.syncPoints;if(t<0||0===i.length)return t;t*=this.playbackSpeed;let n=Math.min(s.syncPointIndex,i.length-1);for(t<i[n].synthTime&&(n=0);n+1<i.length&&i[n+1].synthTime<=t;)n++;const r=i[n],a=t-r.synthTime;let h;if(n+1<i.length){const t=i[n+1],e=a/(t.synthTime-r.synthTime),s=t.syncTime-r.syncTime;h=r.syncTime+s*e}else{const t=a/(s.endTime-r.synthTime),i=e-r.syncTime;h=r.syncTime+i*t}return h}pd(t,e,s){let i=0,n=120,r=0;for(const s of t.tempoChanges){if(e<s.ticks)break;i=s.time,n=s.bpm,r=s.ticks}return i+=(e-=r)*(6e4/(n*t.division)),i/s}get wd(){return this.isPlayingMain&&this.mainPlaybackRange?this.ld.playbackRangeEndTime:this.ld.endTime}get isFinished(){return this.ld.currentTime>=this.wd}stop(){this.isPlayingMain&&this.mainPlaybackRange?this.ld.currentTime=this.mainPlaybackRange.startTick:this.ld.currentTime=0,this.ld.eventIndex=0}resetOneTimeMidi(){this.dd=null,this.ld=this.ud}resetCountIn(){this.fd=null,this.ld=this.ud}startCountIn(){this.generateCountInMidi(),this.ld=this.fd,this.stop(),this.od.noteOffAll(!0)}generateCountInMidi(){const t=new ar;t.division=this.ud.division;let e=120,s=4,i=4;0===this.ud.eventIndex?(e=this.ud.tempoChanges[0].bpm,s=this.ud.firstTimeSignatureNumerator,i=this.ud.firstTimeSignatureDenominator):(e=this.od.currentTempo,s=this.od.timeSignatureNumerator,i=this.od.timeSignatureDenominator),t.tempoChanges.push(new rr(e,0,0));const n=t.division*(4/i)|0,r=n*(6e4/(e*this.ud.division));let a=0,h=0;for(let e=0;e<s;e++){const s=ir.newMetronomeEvent(t.synthData.length,a,e,n,r);t.synthData.push(s),s.time=h,a+=n,h+=r}t.synthData.sort((t,e)=>t.time>e.time?1:t.time<e.time?-1:t.eventIndex-e.eventIndex),t.endTime=h,t.endTick=a,t.currentTempo=e,t.syncPointTempo=e,this.fd=t}},or=class t{static HeaderSize=8;id="";size=0;static load(e,s,i){if(e&&t.HeaderSize>e.size)return!1;if(i.position+t.HeaderSize>=i.length)return!1;if(s.id=le.read8BitStringLength(i,4),s.id.charCodeAt(0)<=32||s.id.charCodeAt(0)>=122)return!1;if(s.size=le.readUInt32LE(i),e&&t.HeaderSize+s.size>e.size)return!1;e&&(e.size-=t.HeaderSize+s.size);const n="RIFF"===s.id,r="LIST"===s.id;return(!n||!e)&&(!n&&!r||(s.id=le.read8BitStringLength(i,4),!(s.id.charCodeAt(0)<=32||s.id.charCodeAt(0)>=122)&&(s.size-=4,!0)))}},cr=class{packetData;isBeginningOfStream;isEndOfStream;granulePosition;constructor(t,e,s,i){this.packetData=t,this.isBeginningOfStream=e,this.isEndOfStream=s,this.granulePosition=s?i:null}addData(t){const e=this.packetData,s=new Uint8Array(e.length+t.length);s.set(e,0),s.set(t,e.length)}},lr=class{wi;constructor(t){this.wi=t}read(){const t=[];for(;this.Sd(t););return t}Sd(t){return!!this.Bd()&&this._d(t)}Bd(){for(let t=0;t<65536;t++){if(1399285583===le.readInt32LE(this.wi))return!0;this.wi.position-=3}return!1}_d(t){const e=this.wi.readByte();if(-1===e||0!==e)return!1;const s=this.wi.readByte(),i=le.readInt64LE(this.wi);this.wi.skip(4),this.wi.skip(4),this.wi.skip(4);const n=this.wi.readByte();if(-1===n)return!1;const h=[];let o=0;for(let t=0;t<n;t++){const t=this.wi.readByte();o===h.length&&h.push(0),h[o]+=t,t<255&&o++}for(let e=0;e<h.length;e++){const n=new Uint8Array(h[e]);if(this.wi.read(n,0,n.length)!==n.length)return!1;if(1&s){if(0===t.length)throw new a(r.Format,"OGG: Continuation page without any previous packets");t[t.length-1].addData(n)}else{const r=new cr(n,!!(2&s)&&0===e,!!(4&s)&&e===h.length-1,i);t.push(r)}}return!0}},ur=class{audioChannels=0;audioSampleRate=0;samples=new Float32Array(0);bitrateMaximum=0;bitrateNominal=0;bitrateMinimum=0;blocksize0=0;blocksize1=0},dr=class{value=0;bitsRead=0},fr=class t{static ko=8;_o;xd=0n;Td=0n;Md=0n;constructor(t){this._o=t}readByte(){return this.readBits(t.ko)}readBit(){return 1===this.readBits(1)}readBytes(t){const e=new Uint8Array(t);for(let s=0;s<t;s++)e[s]=255&this.readByte();return e}readBits(t){if(0===t)return 0;const e=this.tryPeekBits(t);return this.skipBits(t),e.value}tryPeekBits(t){if(t<0||t>32)throw new a(r.General,"IO: Cannot read more than 32 bits in one go");if(0===t)return new dr;const e=new dr;for(;this.Td<t;){const t=BigInt(this._o.readByte());if(-1n===t)return e.bitsRead=Number(this.Td),e.value=Number(this.xd),this.xd=0n,this.Td=0n,e;this.xd=(255n&t)<<this.Td|this.xd,this.Td+=8n,this.Td>32&&(this.Md=t>>40n-this.Td&255n)}let s=this.xd;return t<64&&(s&=(1n<<BigInt(t))-1n),e.value=Number(s),e.bitsRead=t,e}skipBits(t){let e=BigInt(t);if(0===t);else if(this.Td>e){if(this.xd=t>31?0n:this.xd>>e,this.Td>32){const s=this.Td-32n;this.xd=this.xd|this.Md<<this.Td-e-s,s>t&&(this.Md=this.Md>>e&255n)}this.Td-=e}else if(this.Td===e)this.xd=0n,this.Td=0n;else{for(e-=this.Td,this.Td=0n,this.xd=0n;e>8;){if(-1===this._o.readByte()){e=0n;break}e-=8n}if(e>0){const t=BigInt(this._o.readByte());-1n===t||(this.xd=t>>e,this.Td=8n-e)}}}},pr=class{codebooks=[];timeDomainTransforms=[];floors=[];residues=[];mappings=[];modes=[]},br=class{static ilog(t){let e=0;for(;t>0;)++e,t>>=1;return e}static bitReverse(t,e=32){let s=BigInt(t);return s=(s&BigInt(2863311530))>>1n|(s&BigInt(1431655765))<<1n,s=(s&BigInt(3435973836))>>2n|(s&BigInt(858993459))<<2n,s=(s&BigInt(4042322160))>>4n|(s&BigInt(252645135))<<4n,s=(s&BigInt(4278255360))>>8n|(s&BigInt(16711935))<<8n,s=(s>>16n|s<<16n)>>32n-BigInt(e),Number(BigInt.asUintN(32,s))}static convertFromVorbisFloat32(t){const e=BigInt(t);let s=e&BigInt(2097151);const i=e&BigInt(2147483648),n=(e&BigInt(2145386496))>>21n;return 0n!==i&&(s=-s),Number(s)*Math.pow(2,Number(n)-788)}},mr=class{vd;constructor(t){this.vd=t}get(t){return this.vd[t]}},gr=class t{static instance=new t;get(t){return t}},wr=class{dn;Nd=0;Pd=null;Cd=null;Ed=0;Fd;dimensions=0;entries=0;mapType=0;constructor(t,e){if(5653314!==t.readBits(24))throw new a(r.Format,"Vorbis: Book header had invalid signature!");this.dimensions=t.readBits(16),this.entries=t.readBits(24),this.dn=new Int32Array(this.entries),this.Ad(t,e),this.Dd(t)}get(t,e){return this.Fd[t*this.dimensions+e]}decodeScalar(t){let e=t.tryPeekBits(this.Ed);if(0===e.bitsRead)return-1;let s=this.Cd[e.value];if(null!=s)return t.skipBits(s.length),s.value;if(e=t.tryPeekBits(this.Nd),null!==this.Pd)for(let i=0;i<this.Pd.length;i++){s=this.Pd[i];const n=e.value&s.mask;if(s.bits===n)return t.skipBits(s.length),s.value}return-1}Ad(t,e){let s,i,n=0;if(t.readBit()){let e=t.readBits(5)+1;for(let s=0;s<this.entries;){let i=t.readBits(br.ilog(this.entries-s));for(;--i>=0;)this.dn[s++]=e;++e}n=0,s=!1,i=e}else{i=-1,s=t.readBit();for(let e=0;e<this.entries;e++)!s||t.readBit()?(this.dn[e]=t.readBits(5)+1,++n):this.dn[e]=-1,this.dn[e]>i&&(i=this.dn[e])}if(this.Nd=i,i>-1){let t,i=null;s&&n>=this.entries>>2&&(i=new Int32Array(this.entries),i.set(this.dn.subarray(0,this.entries),0),s=!1),t=s?n:0;let h=null,o=null;if(s?0!==t&&(i=new Int32Array(t),o=new Int32Array(t),h=new Int32Array(t)):o=new Int32Array(this.entries),!this.Ld(s,o,i,this.dn,this.entries,h))throw new a(r.Format,"Vorbis: Failed to compute codewords");const c=null==h?gr.instance:new mr(h);e.generateTable(c,i??this.dn,o),this.Cd=e.prefixTree,this.Ed=e.tableBits,this.Pd=e.overflowList}}Ld(t,e,s,i,n,r){const a=new Uint32Array(32);let h=0,o=0;for(h=0;h<n&&!(i[h]>0);++h);if(h===n)return!0;this.Wd(t,e,s,0,h,o++,i[h],r);for(let t=1;t<=i[h];++t)a[t]=1<<32-t;for(let c=h+1;c<n;++c){let n=i[c];if(n<=0)continue;for(;n>0&&0===a[n];)--n;if(0===n)return!1;const h=a[n];if(a[n]=0,this.Wd(t,e,s,br.bitReverse(h),c,o++,i[c],r),n!==i[c])for(let t=i[c];t>n;--t)a[t]=h+(1<<32-t)}return!0}Wd(t,e,s,i,n,r,a,h){t?(e[r]=i,s[r]=a,h[r]=n):e[n]=i}Dd(t){if(this.mapType=t.readBits(4),0===this.mapType)return;const e=br.convertFromVorbisFloat32(t.readBits(32)),s=br.convertFromVorbisFloat32(t.readBits(32)),i=t.readBits(4)+1,n=t.readBit();let r=this.entries*this.dimensions;const a=new Float32Array(r);1===this.mapType&&(r=this.Rd());const h=new Uint32Array(r);for(let e=0;e<r;e++)h[e]=t.readBits(i);if(1===this.mapType)for(let t=0;t<this.entries;t++){let i=0,o=1;for(let c=0;c<this.dimensions;c++){const l=h[t/o%r|0]*s+e+i;a[t*this.dimensions+c]=l,n&&(i=l),o*=r}}else for(let t=0;t<this.entries;t++){let i=0,r=t*this.dimensions;for(let o=0;o<this.dimensions;o++){const c=h[r]*s+e+i;a[t*this.dimensions+o]=c,n&&(i=c),++r}}this.Fd=a}Rd(){let t=Math.floor(Math.exp(Math.log(this.entries)/this.dimensions));return Math.floor(Math.pow(t+1,this.dimensions))<=this.entries&&++t,t}},yr=class{value=0;length=0;bits=0;mask=0},kr=class t{static maxTableBits=10;tableBits=0;prefixTree=[];overflowList=null;generateTable(e,s,i){const n=new Array(s.length);let r=0;for(let t=0;t<n.length;t++){const a=new yr;a.value=e.get(t),a.length=s[t]<=0?99999:s[t],a.bits=i[t],a.mask=(1<<s[t])-1,n[t]=a,s[t]>0&&r<s[t]&&(r=s[t])}n.sort((t,e)=>{const s=t.length-e.length;return 0===s?t.bits-e.bits:s});const a=r>t.maxTableBits?t.maxTableBits:r,h=[];let o=null;for(let t=0;t<n.length&&n[t].length<99999;t++){const e=n[t].length;if(e>a)for(o=[];t<n.length&&n[t].length<99999;t++)o.push(n[t]);else{const s=1<<a-e,i=n[t];for(let t=0;t<s;t++){const s=t<<e|i.bits;for(;h.length<=s;)h.push(null);h[s]=i}}}for(;h.length<1<<a;)h.push(null);this.tableBits=a,this.prefixTree=h,this.overflowList=o}},Sr=class{constructor(t){t.readBits(16)}},Br=class{coeff;amp=0;get executeChannel(){return(this.forceEnergy||this.amp>0)&&!this.forceNoEnergy}forceEnergy=!1;forceNoEnergy=!1;constructor(t){this.coeff=t}},_r=class t{Od;Id;Gd;Hd;$d;Vd;zd;Ud;Xd;jd;constructor(t,e,s,i){if(this.Od=t.readBits(8),this.Id=t.readBits(16),this.Gd=t.readBits(16),this.Hd=t.readBits(6),this.$d=t.readBits(8),this.zd=new Array(t.readBits(4)+1),this.Od<1||this.Id<1||this.Gd<1||0===this.zd.length)throw new a(r.Format,"Vorbis: Invalid Floor0 Data");this.Vd=(1<<this.Hd)-1;for(let e=0;e<this.zd.length;e++){const s=t.readBits(8);if(s<0||s>=i.length)throw new a(r.Format,"Vorbis: Invalid Floor0 Data");const n=i[s];if(0===n.mapType||n.dimensions<1)throw new a(r.Format,"Vorbis: Invalid Floor0 Data");this.zd[e]=n}this.Ud=br.ilog(this.zd.length),this.jd=new Map([[e,this.Jd(e/2)],[s,this.Jd(s/2)]]),this.Xd=new Map([[e,this.qd(e/2)],[s,this.qd(s/2)]])}Jd(e){const s=this.Gd/t.Yd(this.Id/2),i=new Int32Array(e+1);for(let n=0;n<e-1;n++)i[n]=Math.min(this.Gd-1,Math.floor(t.Yd(this.Id/2/e*n)*s));return i[e]=-1,i}static Yd(t){return 13.1*Math.atan(74e-5*t)+2.24*Math.atan(1.85e-8*t*t)+1e-4*t}qd(t){const e=Math.PI/this.Gd,s=new Float32Array(t);for(let i=0;i<t;i++)s[i]=2*Math.cos(e*i);return s}unpack(t,e,s){const i=new Br(new Float32Array(this.Od+1));if(i.amp=t.readBits(this.Hd),i.amp>0){i.amp=i.amp/this.Vd*this.$d;const e=t.readBits(this.Ud);if(e>=this.zd.length)return i.amp=0,i;const s=this.zd[e];for(let e=0;e<this.Od;){const n=s.decodeScalar(t);if(-1===n)return i.amp=0,i;for(let t=0;e<this.Od&&t<s.dimensions;t++,e++)i.coeff[e]=s.get(n,t)}let n=0;for(let t=0;t<this.Od;){for(let e=0;t<this.Od&&e<s.dimensions;t++,e++)i.coeff[t]+=n;n=i.coeff[t-1]}}return i}apply(t,e,s){const i=t,n=e/2;if(i.amp>0){const t=this.jd.get(e),r=this.Xd.get(e);let a=0;for(a=0;a<this.Od;a++)i.coeff[a]=2*Math.cos(i.coeff[a]);for(a=0;a<n;){let e=0;const n=t[a];let h=.5,o=.5;const c=r[n];for(e=1;e<this.Od;e+=2)o*=c-i.coeff[e-1],h*=c-i.coeff[e];for(e===this.Od?(o*=c-i.coeff[e-1],h*=h*(4-c*c),o*=o):(h*=h*(2-c),o*=o*(2+c)),o=i.amp/Math.sqrt(h+o)-this.$d,o=Math.exp(.11512925*o),s[a]*=o;t[++a]===n;)s[a]*=o}}else s.fill(0,0,n)}},xr=class{posts=new Int32Array(64);postCount=0;get executeChannel(){return(this.forceEnergy||this.postCount>0)&&!this.forceNoEnergy}forceEnergy=!1;forceNoEnergy=!1},Tr=class t{static Kd=[256,128,86,64];static Qd=[8,7,7,6];Zd;tf;ef;sf;if;nf;rf;af;hf;cf;lf;uf;df;ff;constructor(e,s){let i=-1;this.Zd=new Int32Array(e.readBits(5));for(let t=0;t<this.Zd.length;t++)this.Zd[t]=e.readBits(4),this.Zd[t]>i&&(i=this.Zd[t]);++i,this.tf=new Int32Array(i),this.ef=new Int32Array(i),this.uf=new Array(i),this.if=new Int32Array(i),this.df=new Array(i),this.ff=new Array(i);for(let t=0;t<i;t++){this.tf[t]=e.readBits(3)+1,this.ef[t]=e.readBits(2),this.ef[t]>0&&(this.if[t]=e.readBits(8),this.uf[t]=s[this.if[t]]),this.df[t]=new Array(1<<this.ef[t]),this.ff[t]=new Int32Array(this.df[t].length);for(let i=0;i<this.df[t].length;i++){const n=e.readBits(8)-1;n>=0&&(this.df[t][i]=s[n]),this.ff[t][i]=n}}this.hf=e.readBits(2),this.cf=t.Kd[this.hf],this.lf=t.Qd[this.hf],++this.hf;const n=e.readBits(4),h=[];h.push(0),h.push(1<<n);for(let t=0;t<this.Zd.length;t++){const s=this.Zd[t];for(let t=0;t<this.tf[s];t++)h.push(e.readBits(n))}this.sf=new Int32Array(h),this.rf=new Int32Array(h.length),this.nf=new Int32Array(h.length),this.af=new Int32Array(h.length),this.af[0]=0,this.af[1]=1;for(let t=2;t<this.rf.length;t++){this.rf[t]=0,this.nf[t]=1,this.af[t]=t;for(let e=2;e<t;e++){const s=this.sf[e];s<this.sf[t]?s>this.sf[this.rf[t]]&&(this.rf[t]=e):s<this.sf[this.nf[t]]&&(this.nf[t]=e)}}for(let t=0;t<this.af.length-1;t++)for(let e=t+1;e<this.af.length;e++){if(this.sf[t]===this.sf[e])throw new a(r.Format,"Vorbis: Invalid Floor1 Data");if(this.sf[this.af[t]]>this.sf[this.af[e]]){const s=this.af[t];this.af[t]=this.af[e],this.af[e]=s}}}unpack(t,e,s){const i=new xr;if(t.readBit()){let e=2;i.posts[0]=t.readBits(this.lf),i.posts[1]=t.readBits(this.lf);for(let s=0;s<this.Zd.length;s++){const n=this.Zd[s],r=this.tf[n],a=this.ef[n],h=(1<<a)-1;let o=0;if(a>0&&(o=this.uf[n].decodeScalar(t),-1===o)){e=0;break}for(let c=0;c<r;c++){const r=this.df[n][o&h];if(o>>=a,null!=r&&(i.posts[e]=r.decodeScalar(t),-1===i.posts[e])){e=0,s=this.Zd.length;break}++e}}i.postCount=e}return i}apply(t,e,s){const i=t,n=e/2;if(i.postCount>0){const t=this.pf(i);let e=0,r=i.posts[0]*this.hf;for(let a=1;a<i.postCount;a++){const h=this.af[a];if(t[h]){const t=this.sf[h],a=i.posts[h]*this.hf;e<n&&this.bf(e,r,Math.min(t,n),a,s),e=t,r=a}if(e>=n)break}e<n&&this.bf(e,r,n,r,s)}else s.fill(0,0,n)}pf(t){const e=new Array(64);e.fill(!1),e[0]=!0,e[1]=!0;const s=new Int32Array(64);s[0]=t.posts[0],s[1]=t.posts[1];for(let i=2;i<t.postCount;i++){const n=this.rf[i],r=this.nf[i],a=this.mf(this.sf[n],s[n],this.sf[r],s[r],this.sf[i]),h=t.posts[i],o=this.cf-a,c=a;let l;l=o<c?2*o:2*c,0!==h?(e[n]=!0,e[r]=!0,e[i]=!0,s[i]=h>=l?o>c?h-c+a:a-h+o-1:h%2==1?a-(h+1)/2:a+h/2):(e[i]=!1,s[i]=a)}for(let e=0;e<t.postCount;e++)t.posts[e]=s[e];return e}mf(t,e,s,i,n){const r=i-e,a=s-t,h=Math.abs(r)*(n-t)/a|0;return r<0?e-h:e+h}bf(e,s,i,n,r){const a=n-s,h=i-e;let o=Math.abs(a);const c=1-2*(a>>31&1),l=a/h|0;let u=e,d=s,f=-h;for(r[e]*=t.gf[s],o-=Math.abs(l)*h;++u<i;)d+=l,f+=o,f>=0&&(f-=h,d+=c),r[u]*=t.gf[d]}static gf=new Float32Array([1.0649863e-7,1.1341951e-7,1.2079015e-7,1.2863978e-7,1.3699951e-7,1.4590251e-7,1.5538408e-7,1.6548181e-7,1.7623575e-7,1.8768855e-7,1.9988561e-7,2.128753e-7,2.2670913e-7,2.4144197e-7,2.5713223e-7,2.7384213e-7,2.9163793e-7,3.1059021e-7,3.3077411e-7,3.5226968e-7,3.7516214e-7,3.9954229e-7,4.255068e-7,4.5315863e-7,4.8260743e-7,5.1396998e-7,5.4737065e-7,5.8294187e-7,6.2082472e-7,6.6116941e-7,7.0413592e-7,7.4989464e-7,7.9862701e-7,8.505263e-7,9.0579828e-7,9.6466216e-7,10273513e-13,10941144e-13,11652161e-13,12409384e-13,13215816e-13,14074654e-13,14989305e-13,15963394e-13,17000785e-13,18105592e-13,19282195e-13,20535261e-13,21869758e-13,23290978e-13,24804557e-13,26416497e-13,2813319e-12,29961443e-13,31908506e-13,33982101e-13,36190449e-13,38542308e-13,41047004e-13,4371447e-12,46555282e-13,49580707e-13,5280274e-12,5623416e-12,59888572e-13,63780469e-13,67925283e-13,72339451e-13,77040476e-13,82047e-10,87378876e-13,93057248e-13,99104632e-13,10554501e-12,11240392e-12,11970856e-12,12748789e-12,13577278e-12,14459606e-12,15399272e-12,16400004e-12,17465768e-12,18600792e-12,19809576e-12,21096914e-12,22467911e-12,23928002e-12,25482978e-12,27139006e-12,28902651e-12,30780908e-12,32781225e-12,34911534e-12,37180282e-12,39596466e-12,42169667e-12,4491009e-11,47828601e-12,50936773e-12,54246931e-12,57772202e-12,61526565e-12,65524908e-12,69783085e-12,74317983e-12,79147585e-12,8429104e-11,89768747e-12,95602426e-12,.00010181521,.00010843174,.00011547824,.00012298267,.00013097477,.00013948625,.00014855085,.00015820453,.00016848555,.00017943469,.00019109536,.00020351382,.00021673929,.00023082423,.00024582449,.00026179955,.00027881276,.00029693158,.00031622787,.00033677814,.00035866388,.00038197188,.00040679456,.00043323036,.00046138411,.00049136745,.00052329927,.00055730621,.00059352311,.00063209358,.00067317058,716917e-9,.0007635063,.00081312324,.00086596457,.00092223983,.00098217216,.0010459992,.0011139742,.0011863665,.0012634633,.0013455702,.0014330129,.0015261382,.0016253153,.0017309374,.0018434235,.0019632195,.0020908006,.0022266726,.0023713743,.0025254795,.0026895994,.0028643847,.0030505286,.0032487691,.0034598925,.0036847358,.0039241906,.0041792066,.004450795,.0047400328,.0050480668,.0053761186,.0057254891,.0060975636,.0064938176,.0069158225,.0073652516,.0078438871,.0083536271,.0088964928,.009474637,.010090352,.01074608,.011444421,.012188144,.012980198,.013823725,.014722068,.015678791,.016697687,.017782797,.018938423,.020169149,.021479854,.022875735,.02436233,.025945531,.027631618,.029427276,.031339626,.033376252,.035545228,.037855157,.040315199,.042935108,.045725273,.048696758,.051861348,.055231591,.05882085,.062643361,.066714279,.071049749,.075666962,.080584227,.085821044,.091398179,.097337747,.1036633,.11039993,.11757434,.12521498,.13335215,.14201813,.15124727,.16107617,.1715438,.18269168,.19456402,.20720788,.22067342,.23501402,.25028656,.26655159,.28387361,.30232132,.32196786,.34289114,.36517414,.38890521,.41417847,.44109412,.4697589,.50028648,.53279791,.56742212,.6042964,.64356699,.68538959,.72993007,.77736504,.8278826,.88168307,.9389798,1])},Mr=class{floor;constructor(t,e,s,i){const n=t.readBits(16);switch(n){case 0:this.floor=new _r(t,e,s,i);break;case 1:this.floor=new Tr(t,i);break;default:throw new a(r.Format,`Vorbis: Invalid Floor type: ${n}`)}}apply(t,e,s){this.floor.apply(t,e,s)}unpack(t,e,s){return this.floor.unpack(t,e,s)}},vr=class t{wf;yf;kf;Sf;Bf;_f;zd;xf;Tf;Mf;constructor(e,s,i){this.yf=e.readBits(24),this.kf=e.readBits(24),this.Sf=e.readBits(24)+1,this.Bf=e.readBits(6)+1,this.xf=i[e.readBits(8)],this.Tf=new Int32Array(this.Bf);let n=0;for(let s=0;s<this.Bf;s++){const i=e.readBits(3);e.readBit()?this.Tf[s]=e.readBits(5)<<3|i:this.Tf[s]=i,n+=t.vf(this.Tf[s])}const h=new Int32Array(n);for(let t=0;t<n;t++)if(h[t]=e.readBits(8),0===i[h[t]].mapType)throw new a(r.Format,"Vorbis: Invalid Residue 0");const o=this.xf.entries;let c=this.xf.dimensions,l=1;for(;c>0;){if(l*=this.Bf,l>o)throw new a(r.Format,"Vorbis: Invalid Residue 0");--c}this.zd=new Array(this.Bf),n=0;let u,d=0;for(let t=0;t<this.Bf;t++)if(u=br.ilog(this.Tf[t]),this.zd[t]=new Array(u),u>0){d=Math.max(d,u);for(let e=0;e<u;e++)(this.Tf[t]&1<<e)>0&&(this.zd[t][e]=i[h[n++]])}this._f=d,this.Mf=new Array(l);for(let t=0;t<l;t++){let e=t,s=l/this.Bf|0;this.Mf[t]=new Int32Array(this.xf.dimensions);for(let i=0;i<this.xf.dimensions;i++){const n=e/s|0;e-=n*s,s=s/this.Bf|0,this.Mf[t][i]=n}}this.wf=s}static vf(t){let e=0;for(;0!==t;)e+=1&t,t>>=1;return e}decode(t,e,s,i){const n=(this.kf<s/2?this.kf:s/2)-this.yf;if(n>0&&-1!==e.indexOf(!1)){const e=n/this.Sf,s=(e+this.xf.dimensions-1)/this.xf.dimensions|0,r=[];for(let t=0;t<this.wf;t++)r.push(new Array(s));for(let s=0;s<this._f;s++)for(let n=0,a=0;n<e;a++){if(0===s)for(let i=0;i<this.wf;i++){const h=this.xf.decodeScalar(t);if(!(h>=0&&h<this.Mf.length)){n=e,s=this._f;break}r[i][a]=this.Mf[h]}for(let h=0;n<e&&h<this.xf.dimensions;h++,n++){const o=this.yf+n*this.Sf;for(let c=0;c<this.wf;c++){const l=r[c][a][h];if(this.Tf[l]&1<<s){const r=this.zd[l][s];if(r&&this.writeVectors(r,t,i,c,o,this.Sf)){n=e,s=this._f;break}}}}}}}writeVectors(t,e,s,i,n,r){const a=s[i],h=r/t.dimensions,o=new Int32Array(h);for(let s=0;s<h;s++)if(o[s]=t.decodeScalar(e),-1===o[s])return!0;for(let e=0;e<t.dimensions;e++)for(let s=0;s<h;s++,n++)a[n]+=t.get(o[s],e);return!1}},Nr=class extends vr{writeVectors(t,e,s,i,n,r){const a=s[i];for(let s=0;s<r;){const i=t.decodeScalar(e);if(-1===i)return!0;for(let e=0;e<t.dimensions;s++,e++)a[n+s]+=t.get(i,e)}return!1}},Pr=class extends vr{Nf;constructor(t,e,s){super(t,1,s),this.Nf=e}decode(t,e,s,i){super.decode(t,e,s*this.Nf,i)}writeVectors(t,e,s,i,n,r){let a=0;n/=this.Nf;for(let i=0;i<r;){const r=t.decodeScalar(e);if(-1===r)return!0;for(let e=0;e<t.dimensions;e++,i++)s[a][n]+=t.get(r,e),++a===this.Nf&&(a=0,n++)}return!1}},Cr=class{residue;constructor(t,e,s){const i=t.readBits(16);switch(i){case 0:this.residue=new vr(t,e,s);break;case 1:this.residue=new Nr(t,e,s);break;case 2:this.residue=new Pr(t,e,s);break;default:throw new a(r.Format,`Vorbis: Invalid Residue type: ${i}`)}}decode(t,e,s,i){this.residue.decode(t,e,s,i)}},Er=class{Pf;Cf;Ef;Ff;Af;Df;Lf;constructor(t,e,s,i,n){if(0!==t.readBits(16))throw new a(r.Format,"Vorbis: Invalid mapping type!");let h=1;t.readBit()&&(h+=t.readBits(4));let o=0;t.readBit()&&(o=t.readBits(8)+1);const c=br.ilog(e-1);this.Cf=new Int32Array(o),this.Ef=new Int32Array(o);for(let s=0;s<o;s++){const i=t.readBits(c),n=t.readBits(c);if(i===n||i>e-1||n>e-1)throw new a(r.Format,"Vorbis: Invalid magnitude or angle in mapping header!");this.Cf[s]=n,this.Ef[s]=i}if(0!==t.readBits(2))throw new a(r.Format,"Vorbis: Reserved bits not 0 in mapping header.");const l=new Int32Array(e);if(h>1)for(let s=0;s<e;s++)if(l[s]=t.readBits(4),l[s]>h)throw new a(r.Format,"Vorbis: Invalid channel mux submap index in mapping header!");this.Ff=new Array(h),this.Af=new Array(h);for(let e=0;e<h;e++){t.skipBits(8);const n=t.readBits(8);if(n>=s.length)throw new a(r.Format,"Vorbis: Invalid floor number in mapping header!");const h=t.readBits(8);if(h>=i.length)throw new a(r.Format,"Vorbis: Invalid residue number in mapping header!");this.Ff[e]=s[n],this.Af[e]=i[h]}this.Df=new Array(e),this.Lf=new Array(e);for(let t=0;t<e;t++)this.Df[t]=this.Ff[l[t]],this.Lf[t]=this.Af[l[t]];this.Pf=n}decodePacket(t,e,s){const i=e>>1,n=new Array(this.Df.length),r=new Array(this.Df.length);r.fill(!1);for(let a=0;a<this.Df.length;a++)n[a]=this.Df[a].unpack(t,e,a),r[a]=!n[a].executeChannel,s[a].fill(0,0,i);for(let t=0;t<this.Cf.length;t++)(n[this.Cf[t]].executeChannel||n[this.Ef[t]].executeChannel)&&(n[this.Cf[t]].forceEnergy=!0,n[this.Ef[t]].forceEnergy=!0);for(let i=0;i<this.Ff.length;i++){for(let t=0;t<this.Df.length;t++)this.Ff[i]===this.Df[t]&&this.Af[i]===this.Lf[t]||(n[t].forceNoEnergy=!0);this.Af[i].decode(t,r,e,s)}for(let t=this.Cf.length-1;t>=0;t--)if(n[this.Cf[t]].executeChannel||n[this.Ef[t]].executeChannel){const e=s[this.Ef[t]],n=s[this.Cf[t]];for(let t=0;t<i;t++){let s,i;const r=e[t],a=n[t];r>0?a>0?(s=r,i=r-a):(i=r,s=r+a):a>0?(s=r,i=r+a):(i=r,s=r-a),e[t]=s,n[t]=i}}for(let t=0;t<this.Df.length;t++)n[t].executeChannel?(this.Df[t].apply(n[t],e,s[t]),this.Pf.reverse(s[t],e)):s[t].fill(0,i,2*i)}},Fr=class{packetStartIndex=0;packetTotalLength=0;packetValidLength=0},Ar=class{overlapInfo=new Fr;windowIndex=0},Dr=class{samplePosition=null;constructor(t=null){this.samplePosition=t}},Lr=class t{static Wf=1.57079632695;wf;Rf;Of;If;Gf;Hf=null;constructor(e,s,i,n,h){if(this.wf=s,this.Rf=e.readBit(),0!==e.readBits(32))throw new a(r.Format,"Vorbis: Mode header had invalid window or transform type!");const o=e.readBits(8);if(o>=h.length)throw new a(r.Format,"Vorbis: Mode header had invalid mapping index!");this.If=h[o],this.Rf?(this.Of=n,this.Gf=[t.$f(i,n,i),t.$f(n,n,i),t.$f(i,n,n),t.$f(n,n,n)],this.Hf=[t.Vf(i,n,i),t.Vf(n,n,i),t.Vf(i,n,n),t.Vf(n,n,n)]):(this.Of=i,this.Gf=[t.$f(i,i,i)])}decode(t,e){const s=this.zf(t);this.If.decodePacket(t,this.Of,e);const i=this.Gf[s.windowIndex];for(let t=0;t<this.Of;t++)for(let s=0;s<this.wf;s++)e[s][t]*=i[t];return s.overlapInfo}zf(t){const e=new Ar;if(this.Rf){const s=t.readBit(),i=t.readBit();e.windowIndex=(s?1:0)+(i?2:0);const n=this.Hf[e.windowIndex];e.overlapInfo.packetStartIndex=n.packetStartIndex,e.overlapInfo.packetValidLength=n.packetValidLength,e.overlapInfo.packetTotalLength=n.packetTotalLength}else e.windowIndex=0,e.overlapInfo.packetStartIndex=0,e.overlapInfo.packetValidLength=this.Of/2,e.overlapInfo.packetTotalLength=this.Of;return e}static $f(e,s,i){const n=new Float32Array(s),r=e/2,a=i/2,h=s/4-r/2,o=s-s/4-a/2;for(let e=0;e<r;e++){let s=Math.sin((e+.5)/r*t.Wf);s*=s,n[h+e]=Math.sin(s*t.Wf)}for(let t=h+r;t<o;t++)n[t]=1;for(let e=0;e<a;e++){let s=Math.sin((a-e-.5)/a*t.Wf);s*=s,n[o+e]=Math.sin(s*t.Wf)}return n}static Vf(t,e,s){const i=s/4,n=e/4-t/4,r=e/4*3+i,a=r-2*i,h=new Fr;return h.packetStartIndex=n,h.packetValidLength=a,h.packetTotalLength=r,h}},Wr=class t{static Uf=3.141592653589793;Xf;jf;Jf;qf;Yf;Kf;Qf;Zf;tp;constructor(e){this.Xf=e,this.jf=e>>1,this.Jf=this.jf>>1,this.qf=this.Jf>>1,this.Yf=br.ilog(e)-1,this.Kf=new Float32Array(this.jf),this.Qf=new Float32Array(this.jf),this.Zf=new Float32Array(this.Jf);let s=0,i=0;for(;s<this.Jf;++s,i+=2)this.Kf[i]=Math.cos(4*s*t.Uf/e),this.Kf[i+1]=-Math.sin(4*s*t.Uf/e),this.Qf[i]=.5*Math.cos((i+1)*t.Uf/e/2),this.Qf[i+1]=.5*Math.sin((i+1)*t.Uf/e/2);for(s=0,i=0;s<this.qf;++s,i+=2)this.Zf[i]=Math.cos(2*(i+1)*t.Uf/e),this.Zf[i+1]=-Math.sin(2*(i+1)*t.Uf/e);this.tp=new Uint16Array(this.qf);for(let t=0;t<this.qf;++t)this.tp[t]=ce.int32ToUint16(br.bitReverse(t,this.Yf-3)<<2)}calcReverse(t){let e,s;const i=new Float32Array(this.jf);{let e=this.jf-2,s=0,n=0;const r=this.jf;for(;n!==r;)i[e+1]=t[n]*this.Kf[s]-t[n+2]*this.Kf[s+1],i[e]=t[n]*this.Kf[s+1]+t[n+2]*this.Kf[s],e-=2,s+=2,n+=4;for(n=this.jf-3;e>=0;)i[e+1]=-t[n+2]*this.Kf[s]- -t[n]*this.Kf[s+1],i[e]=-t[n+2]*this.Kf[s+1]+-t[n]*this.Kf[s],e-=2,s+=2,n-=4}e=t,s=i;{let t=this.jf-8,i=this.Jf,n=0,r=this.Jf,a=0;for(;t>=0;){let h,o;o=s[i+1]-s[n+1],h=s[i]-s[n],e[r+1]=s[i+1]+s[n+1],e[r]=s[i]+s[n],e[a+1]=o*this.Kf[t+4]-h*this.Kf[t+5],e[a]=h*this.Kf[t+4]+o*this.Kf[t+5],o=s[i+3]-s[n+3],h=s[i+2]-s[n+2],e[r+3]=s[i+3]+s[n+3],e[r+2]=s[i+2]+s[n+2],e[a+3]=o*this.Kf[t]-h*this.Kf[t+1],e[a+2]=h*this.Kf[t]+o*this.Kf[t+1],t-=8,r+=4,a+=4,i+=4,n+=4}}this.ep(this.Xf>>4,e,this.jf-1-0*this.Jf,-this.qf),this.ep(this.Xf>>4,e,this.jf-1-1*this.Jf,-this.qf),this.sp(this.Xf>>5,e,this.jf-1-0*this.qf,-(this.Xf>>4),16),this.sp(this.Xf>>5,e,this.jf-1-1*this.qf,-(this.Xf>>4),16),this.sp(this.Xf>>5,e,this.jf-1-2*this.qf,-(this.Xf>>4),16),this.sp(this.Xf>>5,e,this.jf-1-3*this.qf,-(this.Xf>>4),16);let n=2;for(;n<this.Yf-3>>1;++n){const t=this.Xf>>n+2,s=t>>1,i=1<<n+1;for(let r=0;r<i;++r)this.sp(this.Xf>>n+4,e,this.jf-1-t*r,-s,1<<n+3)}for(;n<this.Yf-6;++n){const t=this.Xf>>n+2,s=1<<n+3,i=t>>1,r=this.Xf>>n+6,a=1<<n+1;let h=this.jf-1,o=0;for(let n=r;n>0;--n)this.ip(a,e,h,-i,o,s,t),o+=4*s,h-=8}this.np(this.Xf>>5,e,this.jf-1,this.Xf);{let t=0,i=this.Jf-4,n=this.jf-4;for(;i>=0;){let r;r=this.tp[t],s[n+3]=e[r],s[n+2]=e[r+1],s[i+3]=e[r+2],s[i+2]=e[r+3],r=this.tp[t+1],s[n+1]=e[r],s[n]=e[r+1],s[i+1]=e[r+2],s[i]=e[r+3],i-=4,n-=4,t+=2}}{let t=0,e=0,i=this.jf-4;for(;e<i;){let n,r,a,h,o,c;n=s[e]-s[i+2],r=s[e+1]+s[i+3],a=this.Zf[t+1]*n+this.Zf[t]*r,h=this.Zf[t+1]*r-this.Zf[t]*n,o=s[e]+s[i+2],c=s[e+1]-s[i+3],s[e]=o+a,s[e+1]=c+h,s[i+2]=o-a,s[i+3]=h-c,n=s[e+2]-s[i],r=s[e+3]+s[i+1],a=this.Zf[t+3]*n+this.Zf[t+2]*r,h=this.Zf[t+3]*r-this.Zf[t+2]*n,o=s[e+2]+s[i],c=s[e+3]-s[i+1],s[e+2]=o+a,s[e+3]=c+h,s[i]=o-a,s[i+1]=h-c,t+=4,e+=4,i-=4}}{let e=this.jf-8,s=this.jf-8,n=0,r=this.jf-4,a=this.jf,h=this.Xf-4;for(;s>=0;){let o,c,l,u;u=i[s+6]*this.Qf[e+7]-i[s+7]*this.Qf[e+6],l=-i[s+6]*this.Qf[e+6]-i[s+7]*this.Qf[e+7],t[n]=u,t[r+3]=-u,t[a]=l,t[h+3]=l,c=i[s+4]*this.Qf[e+5]-i[s+5]*this.Qf[e+4],o=-i[s+4]*this.Qf[e+4]-i[s+5]*this.Qf[e+5],t[n+1]=c,t[r+2]=-c,t[a+1]=o,t[h+2]=o,u=i[s+2]*this.Qf[e+3]-i[s+3]*this.Qf[e+2],l=-i[s+2]*this.Qf[e+2]-i[s+3]*this.Qf[e+3],t[n+2]=u,t[r+1]=-u,t[a+2]=l,t[h+1]=l,c=i[s]*this.Qf[e+1]-i[s+1]*this.Qf[e],o=-i[s]*this.Qf[e]-i[s+1]*this.Qf[e+1],t[n+3]=c,t[r]=-c,t[a+3]=o,t[h]=o,e-=8,s-=8,n+=4,a+=4,r-=4,h-=4}}}sp(t,e,s,i,n){let r,a,h=s,o=h+i,c=0;for(let s=t>>2;s>0;--s)r=e[h]-e[o],a=e[h-1]-e[o-1],e[h]+=e[o],e[h-1]+=e[o-1],e[o]=r*this.Kf[c]-a*this.Kf[c+1],e[o-1]=a*this.Kf[c]+r*this.Kf[c+1],c+=n,r=e[h-2]-e[o-2],a=e[h-3]-e[o-3],e[h-2]+=e[o-2],e[h-3]+=e[o-3],e[o-2]=r*this.Kf[c]-a*this.Kf[c+1],e[o-3]=a*this.Kf[c]+r*this.Kf[c+1],c+=n,r=e[h-4]-e[o-4],a=e[h-5]-e[o-5],e[h-4]+=e[o-4],e[h-5]+=e[o-5],e[o-4]=r*this.Kf[c]-a*this.Kf[c+1],e[o-5]=a*this.Kf[c]+r*this.Kf[c+1],c+=n,r=e[h-6]-e[o-6],a=e[h-7]-e[o-7],e[h-6]+=e[o-6],e[h-7]+=e[o-7],e[o-6]=r*this.Kf[c]-a*this.Kf[c+1],e[o-7]=a*this.Kf[c]+r*this.Kf[c+1],c+=n,h-=8,o-=8}ep(t,e,s,i){let n=s,r=n+i,a=0;for(let s=t>>2;s>0;--s){let t,s;t=e[n]-e[r],s=e[n-1]-e[r-1],e[n]+=e[r],e[n-1]+=e[r-1],e[r]=t*this.Kf[a]-s*this.Kf[a+1],e[r-1]=s*this.Kf[a]+t*this.Kf[a+1],a+=8,t=e[n-2]-e[r-2],s=e[n-3]-e[r-3],e[n-2]+=e[r-2],e[n-3]+=e[r-3],e[r-2]=t*this.Kf[a]-s*this.Kf[a+1],e[r-3]=s*this.Kf[a]+t*this.Kf[a+1],a+=8,t=e[n-4]-e[r-4],s=e[n-5]-e[r-5],e[n-4]+=e[r-4],e[n-5]+=e[r-5],e[r-4]=t*this.Kf[a]-s*this.Kf[a+1],e[r-5]=s*this.Kf[a]+t*this.Kf[a+1],a+=8,t=e[n-6]-e[r-6],s=e[n-7]-e[r-7],e[n-6]+=e[r-6],e[n-7]+=e[r-7],e[r-6]=t*this.Kf[a]-s*this.Kf[a+1],e[r-7]=s*this.Kf[a]+t*this.Kf[a+1],a+=8,n-=8,r-=8}}ip(t,e,s,i,n,r,a){const h=this.Kf[n],o=this.Kf[n+1],c=this.Kf[n+r],l=this.Kf[n+r+1],u=this.Kf[n+2*r],d=this.Kf[n+2*r+1],f=this.Kf[n+3*r],p=this.Kf[n+3*r+1];let b,m,g=s,w=g+i;for(let s=t;s>0;--s)b=e[g]-e[w],m=e[g-1]-e[w-1],e[g]+=e[w],e[g-1]+=e[w-1],e[w]=b*h-m*o,e[w-1]=m*h+b*o,b=e[g-2]-e[w-2],m=e[g-3]-e[w-3],e[g-2]+=e[w-2],e[g-3]+=e[w-3],e[w-2]=b*c-m*l,e[w-3]=m*c+b*l,b=e[g-4]-e[w-4],m=e[g-5]-e[w-5],e[g-4]+=e[w-4],e[g-5]+=e[w-5],e[w-4]=b*u-m*d,e[w-5]=m*u+b*d,b=e[g-6]-e[w-6],m=e[g-7]-e[w-7],e[g-6]+=e[w-6],e[g-7]+=e[w-7],e[w-6]=b*f-m*p,e[w-7]=m*f+b*p,g-=a,w-=a}np(t,e,s,i){const n=i>>3,r=this.Kf[n];let a=s;const h=a-16*t;for(;a>h;){let t,s;t=e[a]-e[a-8],s=e[a-1]-e[a-9],e[a]+=e[a-8],e[a-1]+=e[a-9],e[a-8]=t,e[a-9]=s,t=e[a-2]-e[a-10],s=e[a-3]-e[a-11],e[a-2]+=e[a-10],e[a-3]+=e[a-11],e[a-10]=(t+s)*r,e[a-11]=(s-t)*r,t=e[a-12]-e[a-4],s=e[a-5]-e[a-13],e[a-4]+=e[a-12],e[a-5]+=e[a-13],e[a-12]=s,e[a-13]=t,t=e[a-14]-e[a-6],s=e[a-7]-e[a-15],e[a-6]+=e[a-14],e[a-7]+=e[a-15],e[a-14]=(t+s)*r,e[a-15]=(t-s)*r,this.rp(e,a),this.rp(e,a-8),a-=16}}rp(t,e){const s=t[e]-t[e-4],i=t[e]+t[e-4],n=t[e-2]+t[e-6],r=t[e-2]-t[e-6];t[e]=i+n,t[e-2]=i-n;const a=t[e-3]-t[e-7];t[e-4]=s+a,t[e-6]=s-a;const h=t[e-1]-t[e-5],o=t[e-1]+t[e-5],c=t[e-3]+t[e-7];t[e-1]=o+c,t[e-3]=o-c,t[e-5]=h-r,t[e-7]=h+r}},Rr=class{ap=new Map;reverse(t,e){let s;this.ap.has(e)?s=this.ap.get(e):(s=new Wr(e),this.ap.set(e,s)),s.calcReverse(t)}},Or=class t{hp;op;cp;lp=0;up;dp;fp;pp;bp;$u;mp;gp;wp;constructor(t,e,s){this.hp=t,this.op=e,this.cp=s,this.$u=0,this.dp=null,this.fp=0,this.pp=0,this.bp=0,this.up=null,this.gp=!1,this.mp=!1,this.wp=br.ilog(e.modes.length-1)}decode(){let t=new Float32Array(this.cp[this.cp.length-1].granulePosition*this.hp.audioChannels);const e=new Float32Array(.2*this.hp.audioSampleRate*this.hp.audioChannels);let s=0,i=0;for(;s=this.read(e,0,e.length),0!==s;){if(i+s>=t.length){const s=new Float32Array(t.length+e.length);s.set(t,0),t=s}t.set(e.subarray(0,s),i),i+=s}return t.subarray(0,i)}read(t,e,s){if(0===s)return 0;let i=e;const n=e+s;for(;i<n;){if(this.fp===this.pp){if(this.gp){this.up=null,this.dp=null;break}const t=this.yp((i-e)/this.hp.audioChannels);null===t&&(this.pp=this.bp),null===t||null===t.samplePosition||this.mp||(this.mp=!0,this.$u=t.samplePosition-(this.pp-this.fp)-(i-e)/this.hp.audioChannels)}const s=Math.min((n-i)/this.hp.audioChannels,this.pp-this.fp);s>0&&(i+=this.kp(t,i,s))}return s=i-e,this.$u+=s/this.hp.audioChannels,s}kp(t,e,s){let i=e;for(;s>0;this.fp++,s--)for(let e=0;e<this.hp.audioChannels;e++)t[i++]=this.dp[e][this.fp];return i-e}yp(e){const s=this.Sp();if(this.gp=this.gp||s.isEndOfStream,null==s.curPacket)return null;if(null!==s.samplePosition&&s.isEndOfStream){const t=this.$u+e+s.validLen-s.startIndex,i=s.samplePosition-t;i<0&&(s.validLen+=i,s.validLen<0&&(s.validLen=0))}return this.pp>0?(t.Bp(this.dp,s.curPacket,this.fp,this.bp,s.startIndex,this.hp.audioChannels),this.fp=s.startIndex):null==this.dp&&(this.fp=s.validLen),this.up=this.dp,this.pp=s.validLen,this.bp=s.totalLen,this.dp=s.curPacket,new Dr(s.samplePosition)}static Bp(t,e,s,i,n,r){for(;s<i;s++,n++)for(let i=0;i<r;i++)e[i][n]+=t[i][s]}Sp(){const t=new Ir;let e=null;if(this.lp>=this.cp.length)t.isEndOfStream=!0;else{e=this.cp[this.lp++];const s=new fr(Ie.fromBuffer(e.packetData));if(t.isEndOfStream=e.isEndOfStream,!s.readBit()){const i=this.op.modes[s.readBits(this.wp)];if(null==this.up){this.up=new Array(this.hp.audioChannels);for(let t=0;t<this.hp.audioChannels;t++)this.up[t]=new Float32Array(this.hp.blocksize1)}const n=i.decode(s,this.up);return t.startIndex=n.packetStartIndex,t.validLen=n.packetValidLength,t.totalLen=n.packetTotalLength,t.samplePosition=e.granulePosition,t.curPacket=this.up,t}}return t}},Ir=class{curPacket=null;startIndex=0;validLen=0;totalLen=0;isEndOfStream=!1;samplePosition=null},Gr=class t{static vorbisHeaderMarker=new Uint8Array(["v".charCodeAt(0),"o".charCodeAt(0),"r".charCodeAt(0),"b".charCodeAt(0),"i".charCodeAt(0),"s".charCodeAt(0)]);cp;lp;constructor(t){this.lp=-1,this.cp=t}read(){let t;for(;;){if(t=this._p(),null==t)return null;if(t.isBeginningOfStream){const e=this.xp(t);if(null!=e)return e}}}_p(){return this.lp++,this.lp<this.cp.length?this.cp[this.lp]:null}xp(t){const e=new ur;if(!this.Tp(e,t))return null;if(!this.Mp(this._p()))return null;const s=new pr;if(!this.vp(e,s,this._p()))return null;const i=[];let n;for(;n=this._p(),null!=n&&(i.push(n),!n.isEndOfStream););return e.samples=new Or(e,s,i).decode(),e}Np(e,s){const i=new Uint8Array(7);if(s.read(i,0,i.length),i[0]!==e)return!1;for(let e=0;e<t.vorbisHeaderMarker.length;e++)if(i[1+e]!==t.vorbisHeaderMarker[e])return!1;return!0}Pp(e,s){const i=s.readBytes(7);if(i[0]!==e)return!1;for(let e=0;e<t.vorbisHeaderMarker.length;e++)if(i[1+e]!==t.vorbisHeaderMarker[e])return!1;return!0}Tp(e,s){const i=Ie.fromBuffer(s.packetData);if(!this.Np(1,i))return!1;if(0!==le.readUInt32LE(i))return!1;if(e.audioChannels=i.readByte(),e.audioSampleRate=le.readUInt32LE(i),e.audioChannels<=0||e.audioSampleRate<=0)return!1;e.bitrateMaximum=le.readInt32LE(i),e.bitrateNominal=le.readInt32LE(i),e.bitrateMinimum=le.readInt32LE(i);const n=i.readByte();return e.blocksize0=1<<(15&n),e.blocksize1=1<<(n>>4),!(e.blocksize0>e.blocksize1||!t.Cp(e.blocksize0)||!t.Cp(e.blocksize0))&&0!==i.readByte()}static Cp(t){switch(t){case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:return!0;default:return!1}}Mp(t){if(null==t)return!1;const e=Ie.fromBuffer(t.packetData);if(!this.Np(3,e))return!1;const s=le.readUInt32LE(e);e.skip(s);const i=le.readUInt32LE(e);for(let t=0;t<i;t++){const t=le.readUInt32LE(e);e.skip(t)}return 0!==e.readByte()}vp(t,e,s){if(null==s)return!1;const i=new fr(Ie.fromBuffer(s.packetData)),n=new Rr,r=new kr;if(!this.Pp(5,i))return!1;let a=i.readByte()+1;for(let t=0;t<a;t++)e.codebooks.push(new wr(i,r));a=i.readBits(6)+1;for(let t=0;t<a;t++)e.timeDomainTransforms.push(new Sr(i));a=i.readBits(6)+1;for(let s=0;s<a;s++)e.floors.push(new Mr(i,t.blocksize0,t.blocksize1,e.codebooks));a=i.readBits(6)+1;for(let s=0;s<a;s++)e.residues.push(new Cr(i,t.audioChannels,e.codebooks));a=i.readBits(6)+1;for(let s=0;s<a;s++)e.mappings.push(new Er(i,t.audioChannels,e.floors,e.residues,n));a=i.readBits(6)+1;for(let s=0;s<a;s++)e.modes.push(new Lr(i,t.audioChannels,t.blocksize0,t.blocksize1,e.mappings));return!!i.readBit()}},Hr=class{streams=[];constructor(t){const e=new Gr(new lr(t).read());for(;;){const t=e.read();if(null==t)break;this.streams.push(t)}}},$r=class{phdrs=[];pbags=[];pmods=[];pgens=[];insts=[];ibags=[];imods=[];igens=[];sHdrs=[];sampleData=new Uint8Array(0);Ep=new Map;decodeSamples(t,e,s){const i=`${t}_${e}_${s}`;if(!this.Ep.has(i)){let n;const r=this.sampleData.slice(t,e);if(s)n=new Hr(Ie.fromBuffer(r)).streams[0].samples;else{const t=new DataView(r.buffer,r.byteOffset,r.length);n=new Float32Array(r.length/2);for(let e=0;e<n.length;e++)n[e]=t.getInt16(2*e,!0)/32767}return this.Ep.set(i,n),n}return this.Ep.get(i)}load(t){const e=new or,s=new or;if(!or.load(null,e,t)||"sfbk"!==e.id)throw new ke("Soundfont is not a valid Soundfont2 file");for(;or.load(e,s,t);){const e=new or;if("pdta"===s.id)for(;or.load(s,e,t);)switch(e.id){case"phdr":for(let s=0,i=e.size/qr.SizeInFile|0;s<i;s++)this.phdrs.push(new qr(t));break;case"pbag":for(let s=0,i=e.size/jr.SizeInFile|0;s<i;s++)this.pbags.push(new jr(t));break;case"pmod":for(let s=0,i=e.size/Yr.SizeInFile|0;s<i;s++)this.pmods.push(new Yr(t));break;case"pgen":for(let s=0,i=e.size/Jr.SizeInFile|0;s<i;s++)this.pgens.push(new Jr(t));break;case"inst":for(let s=0,i=e.size/Xr.SizeInFile|0;s<i;s++)this.insts.push(new Xr(t));break;case"ibag":for(let s=0,i=e.size/Vr.SizeInFile|0;s<i;s++)this.ibags.push(new Vr(t));break;case"imod":for(let s=0,i=e.size/zr.SizeInFile|0;s<i;s++)this.imods.push(new zr(t));break;case"igen":for(let s=0,i=e.size/Ur.SizeInFile|0;s<i;s++)this.igens.push(new Ur(t));break;case"shdr":for(let s=0,i=e.size/Kr.SizeInFile|0;s<i;s++)this.sHdrs.push(new Kr(t));break;default:t.position+=e.size}else if("sdta"===s.id)for(;or.load(s,e,t);)if("smpl"===e.id)this.sampleData=new Uint8Array(e.size),t.read(this.sampleData,0,e.size);else t.position+=e.size;else t.position+=s.size}}},Vr=class{static SizeInFile=4;instGenNdx;instModNdx;constructor(t){this.instGenNdx=le.readUInt16LE(t),this.instModNdx=le.readUInt16LE(t)}},zr=class{static SizeInFile=10;modSrcOper;modDestOper;modAmount;modAmtSrcOper;modTransOper;constructor(t){this.modSrcOper=le.readUInt16LE(t),this.modDestOper=le.readUInt16LE(t),this.modAmount=le.readInt16LE(t),this.modAmtSrcOper=le.readUInt16LE(t),this.modTransOper=le.readUInt16LE(t)}},Ur=class{static SizeInFile=4;genOper;genAmount;constructor(t){this.genOper=le.readUInt16LE(t),this.genAmount=new Qr(t)}},Xr=class{static SizeInFile=22;instName;instBagNdx;constructor(t){this.instName=le.read8BitStringLength(t,20),this.instBagNdx=le.readUInt16LE(t)}},jr=class{static SizeInFile=4;genNdx;modNdx;constructor(t){this.genNdx=le.readUInt16LE(t),this.modNdx=le.readUInt16LE(t)}},Jr=class{static SizeInFile=4;static GenInstrument=41;static GenKeyRange=43;static GenVelRange=44;static GenSampleId=53;genOper;genAmount;constructor(t){this.genOper=le.readUInt16LE(t),this.genAmount=new Qr(t)}},qr=class{static SizeInFile=38;presetName;preset;bank;presetBagNdx;library;genre;morphology;constructor(t){this.presetName=le.read8BitStringLength(t,20),this.preset=le.readUInt16LE(t),this.bank=le.readUInt16LE(t),this.presetBagNdx=le.readUInt16LE(t),this.library=le.readUInt32LE(t),this.genre=le.readUInt32LE(t),this.morphology=le.readUInt32LE(t)}},Yr=class{static SizeInFile=10;modSrcOper;modDestOper;modAmount;modAmtSrcOper;modTransOper;constructor(t){this.modSrcOper=le.readUInt16LE(t),this.modDestOper=le.readUInt16LE(t),this.modAmount=le.readUInt16LE(t),this.modAmtSrcOper=le.readUInt16LE(t),this.modTransOper=le.readUInt16LE(t)}},Kr=class{static SizeInFile=46;sampleName;start;end;startLoop;endLoop;sampleRate;originalPitch;pitchCorrection;sampleLink;sampleType;constructor(t){this.sampleName=le.read8BitStringLength(t,20),this.start=le.readUInt32LE(t),this.end=le.readUInt32LE(t),this.startLoop=le.readUInt32LE(t),this.endLoop=le.readUInt32LE(t),this.sampleRate=le.readUInt32LE(t),this.originalPitch=t.readByte(),this.pitchCorrection=le.readSInt8(t),this.sampleLink=le.readUInt16LE(t),this.sampleType=le.readUInt16LE(t)}},Qr=class{wordAmount;get shortAmount(){return ce.uint16ToInt16(this.wordAmount)}get lowByteAmount(){return 255&this.wordAmount}get highByteAmount(){return(65280&this.wordAmount)>>8&255}constructor(t){this.wordAmount=le.readUInt16LE(t)}},Zr=class{presetIndex=0;bank=0;pitchWheel=0;perNotePitchWheel=new Map;midiPan=0;midiVolume=0;midiExpression=0;midiRpn=0;midiData=0;panOffset=0;gainDb=0;pitchRange=0;tuning=0;mixVolume=0;mute=!1;solo=!1},ta=class{activeChannel=0;channelList=[];setupVoice(t,e){const s=this.channelList[this.activeChannel],i=e.region.pan+s.panOffset;e.playingChannel=this.activeChannel,e.mixVolume=s.mixVolume,e.noteGainDb+=s.gainDb,e.updatePitchRatio(s,t.outSampleRate),i<=-.5?(e.panFactorLeft=1,e.panFactorRight=0):i>=.5?(e.panFactorLeft=0,e.panFactorRight=1):(e.panFactorLeft=Math.sqrt(.5-i),e.panFactorRight=Math.sqrt(.5+i))}},ea=function(t){return t[t.None=0]="None",t[t.Continuous=1]="Continuous",t[t.Sustain=2]="Sustain",t}({}),sa=function(t){return t[t.StereoInterleaved=0]="StereoInterleaved",t[t.StereoUnweaved=1]="StereoUnweaved",t[t.Mono=2]="Mono",t}({}),ia=class{name="";presetNumber=0;bank=0;regions=null},na=class{static timecents2Secs(t){return Math.pow(2,t/1200)}static decibelsToGain(t){return t>-100?Math.pow(10,.05*t):0}static gainToDecibels(t){return t<=1e-5?-100:20*Math.log10(t)}static cents2Hertz(t){return 8.176*Math.pow(2,t/1200)}},ra=class{delay=0;attack=0;hold=0;decay=0;sustain=0;release=0;keynumToHold=0;keynumToDecay=0;constructor(t){t&&(this.delay=t.delay,this.attack=t.attack,this.hold=t.hold,this.decay=t.decay,this.sustain=t.sustain,this.release=t.release,this.keynumToHold=t.keynumToHold,this.keynumToDecay=t.keynumToDecay)}clear(){this.delay=0,this.attack=0,this.hold=0,this.decay=0,this.sustain=0,this.release=0,this.keynumToHold=0,this.keynumToDecay=0}envToSecs(t){this.delay=this.delay<-11950?0:na.timecents2Secs(this.delay),this.attack=this.attack<-11950?0:na.timecents2Secs(this.attack),this.release=this.release<-11950?0:na.timecents2Secs(this.release),0===this.keynumToHold&&(this.hold=this.hold<-11950?0:na.timecents2Secs(this.hold)),0===this.keynumToDecay&&(this.decay=this.decay<-11950?0:na.timecents2Secs(this.decay)),this.sustain<0?this.sustain=0:this.sustain=t?na.decibelsToGain(-this.sustain/10):1-this.sustain/1e3}},aa=class t{static Fp=new Float32Array(0);loopMode=ea.None;samples=t.Fp;sampleRate=0;loKey=0;hiKey=0;loVel=0;hiVel=0;group=0;offset=0;end=0;loopStart=0;loopEnd=0;transpose=0;tune=0;pitchKeyCenter=0;pitchKeyTrack=0;attenuation=0;pan=0;ampEnv=new ra;modEnv=new ra;initialFilterQ=0;initialFilterFc=0;modEnvToPitch=0;modEnvToFilterFc=0;modLfoToFilterFc=0;modLfoToVolume=0;delayModLFO=0;freqModLFO=0;modLfoToPitch=0;delayVibLFO=0;freqVibLFO=0;vibLfoToPitch=0;constructor(t){t&&(this.loopMode=t.loopMode,this.samples=t.samples,this.sampleRate=t.sampleRate,this.loKey=t.loKey,this.hiKey=t.hiKey,this.loVel=t.loVel,this.hiVel=t.hiVel,this.group=t.group,this.offset=t.offset,this.end=t.end,this.loopStart=t.loopStart,this.loopEnd=t.loopEnd,this.transpose=t.transpose,this.tune=t.tune,this.pitchKeyCenter=t.pitchKeyCenter,this.pitchKeyTrack=t.pitchKeyTrack,this.attenuation=t.attenuation,this.pan=t.pan,this.ampEnv=new ra(t.ampEnv),this.modEnv=new ra(t.modEnv),this.initialFilterQ=t.initialFilterQ,this.initialFilterFc=t.initialFilterFc,this.modEnvToPitch=t.modEnvToPitch,this.modEnvToFilterFc=t.modEnvToFilterFc,this.modLfoToFilterFc=t.modLfoToFilterFc,this.modLfoToVolume=t.modLfoToVolume,this.delayModLFO=t.delayModLFO,this.freqModLFO=t.freqModLFO,this.modLfoToPitch=t.modLfoToPitch,this.delayVibLFO=t.delayVibLFO,this.freqVibLFO=t.freqVibLFO,this.vibLfoToPitch=t.vibLfoToPitch)}clear(e){this.loopMode=ea.None,this.samples=t.Fp,this.sampleRate=0,this.loKey=0,this.hiKey=0,this.loVel=0,this.hiVel=0,this.group=0,this.offset=0,this.end=0,this.loopStart=0,this.loopEnd=0,this.transpose=0,this.tune=0,this.pitchKeyCenter=0,this.pitchKeyTrack=0,this.attenuation=0,this.pan=0,this.ampEnv.clear(),this.modEnv.clear(),this.initialFilterQ=0,this.initialFilterFc=0,this.modEnvToPitch=0,this.modEnvToFilterFc=0,this.modLfoToFilterFc=0,this.modLfoToVolume=0,this.delayModLFO=0,this.freqModLFO=0,this.modLfoToPitch=0,this.delayVibLFO=0,this.freqVibLFO=0,this.vibLfoToPitch=0,this.hiKey=127,this.hiVel=127,this.pitchKeyCenter=60,e||(this.pitchKeyTrack=100,this.pitchKeyCenter=-1,this.ampEnv.delay=-12e3,this.ampEnv.attack=-12e3,this.ampEnv.hold=-12e3,this.ampEnv.decay=-12e3,this.ampEnv.release=-12e3,this.modEnv.delay=-12e3,this.modEnv.attack=-12e3,this.modEnv.hold=-12e3,this.modEnv.decay=-12e3,this.modEnv.release=-12e3,this.initialFilterFc=13500,this.delayModLFO=-12e3,this.delayVibLFO=-12e3)}operator(t,e){switch(t){case 0:this.offset+=ce.int16ToUint32(e.shortAmount);break;case 1:this.end+=ce.int16ToUint32(e.shortAmount);break;case 2:this.loopStart+=ce.int16ToUint32(e.shortAmount);break;case 3:this.loopEnd+=ce.int16ToUint32(e.shortAmount);break;case 4:this.offset+=32768*ce.int16ToUint32(e.shortAmount);break;case 5:this.modLfoToPitch=e.shortAmount;break;case 6:this.vibLfoToPitch=e.shortAmount;break;case 7:this.modEnvToPitch=e.shortAmount;break;case 8:this.initialFilterFc=e.shortAmount;break;case 9:this.initialFilterQ=e.shortAmount;break;case 10:this.modLfoToFilterFc=e.shortAmount;break;case 11:this.modEnvToFilterFc=e.shortAmount;break;case 12:this.end+=32768*ce.int16ToUint32(e.shortAmount);break;case 13:this.modLfoToVolume=e.shortAmount;break;case 17:this.pan=e.shortAmount/1e3;break;case 21:this.delayModLFO=e.shortAmount;break;case 22:this.freqModLFO=e.shortAmount;break;case 23:this.delayVibLFO=e.shortAmount;break;case 24:this.freqVibLFO=e.shortAmount;break;case 25:this.modEnv.delay=e.shortAmount;break;case 26:this.modEnv.attack=e.shortAmount;break;case 27:this.modEnv.hold=e.shortAmount;break;case 28:this.modEnv.decay=e.shortAmount;break;case 29:this.modEnv.sustain=e.shortAmount;break;case 30:this.modEnv.release=e.shortAmount;break;case 31:this.modEnv.keynumToHold=e.shortAmount;break;case 32:this.modEnv.keynumToDecay=e.shortAmount;break;case 33:this.ampEnv.delay=e.shortAmount;break;case 34:this.ampEnv.attack=e.shortAmount;break;case 35:this.ampEnv.hold=e.shortAmount;break;case 36:this.ampEnv.decay=e.shortAmount;break;case 37:this.ampEnv.sustain=e.shortAmount;break;case 38:this.ampEnv.release=e.shortAmount;break;case 39:this.ampEnv.keynumToHold=e.shortAmount;break;case 40:this.ampEnv.keynumToDecay=e.shortAmount;break;case 43:this.loKey=e.lowByteAmount,this.hiKey=e.highByteAmount;break;case 44:this.loVel=e.lowByteAmount,this.hiVel=e.highByteAmount;break;case 45:this.loopStart+=32768*ce.int16ToUint32(e.shortAmount);break;case 48:this.attenuation+=.1*e.shortAmount;break;case 50:this.loopEnd+=32768*ce.int16ToUint32(e.shortAmount);break;case 51:this.transpose+=e.shortAmount;break;case 52:this.tune+=e.shortAmount;break;case 54:this.loopMode=3&~e.wordAmount?1==(3&e.wordAmount)?ea.Continuous:ea.None:ea.Sustain;break;case 56:this.pitchKeyTrack=e.shortAmount;break;case 57:this.group=e.wordAmount;break;case 58:this.pitchKeyCenter=e.shortAmount}}},ha=function(t){return t[t.None=0]="None",t[t.Delay=1]="Delay",t[t.Attack=2]="Attack",t[t.Hold=3]="Hold",t[t.Decay=4]="Decay",t[t.Sustain=5]="Sustain",t[t.Release=6]="Release",t[t.Done=7]="Done",t}({}),oa=class t{static Ap=.01;level=0;slope=0;samplesUntilNextSegment=0;segment=0;midiVelocity=0;parameters=null;segmentIsExponential=!1;isAmpEnv=!1;nextSegment(e,s){if(this.parameters)for(;;)switch(e){case 0:if(this.samplesUntilNextSegment=this.parameters.delay*s|0,this.samplesUntilNextSegment>0)return this.segment=1,this.segmentIsExponential=!1,this.level=0,void(this.slope=0);e=1;break;case 1:if(this.samplesUntilNextSegment=this.parameters.attack*s|0,this.samplesUntilNextSegment>0)return this.isAmpEnv||(this.samplesUntilNextSegment=this.parameters.attack*((145-this.midiVelocity)/144)*s|0),this.segment=2,this.segmentIsExponential=!1,this.level=0,void(this.slope=1/this.samplesUntilNextSegment);e=2;break;case 2:if(this.samplesUntilNextSegment=this.parameters.hold*s|0,this.samplesUntilNextSegment>0)return this.segment=3,this.segmentIsExponential=!1,this.level=1,void(this.slope=0);e=3;break;case 3:if(this.samplesUntilNextSegment=this.parameters.decay*s|0,this.samplesUntilNextSegment>0){if(this.segment=4,this.level=1,this.isAmpEnv){const t=-9.226/this.samplesUntilNextSegment;this.slope=Math.exp(t),this.segmentIsExponential=!0,this.parameters.sustain>0&&(this.samplesUntilNextSegment=Math.log(this.parameters.sustain)/t|0)}else this.slope=-1/this.samplesUntilNextSegment,this.samplesUntilNextSegment=this.parameters.decay*(1-this.parameters.sustain)*s|0,this.segmentIsExponential=!1;return}e=4;break;case 4:return this.segment=5,this.level=this.parameters.sustain,this.slope=0,this.samplesUntilNextSegment=2147483647,void(this.segmentIsExponential=!1);case 5:if(this.segment=6,this.samplesUntilNextSegment=(this.parameters.release<=0?t.Ap:this.parameters.release)*s|0,this.isAmpEnv){const t=-9.226/this.samplesUntilNextSegment;this.slope=Math.exp(t),this.segmentIsExponential=!0}else this.slope=-this.level/this.samplesUntilNextSegment,this.segmentIsExponential=!1;return;default:return this.segment=7,this.segmentIsExponential=!1,this.level=0,this.slope=0,void(this.samplesUntilNextSegment=134217727)}}setup(t,e,s,i,n){this.parameters=new ra(t),this.parameters.keynumToHold>0&&(this.parameters.hold+=this.parameters.keynumToHold*(60-e),this.parameters.hold=this.parameters.hold<-1e4?0:na.timecents2Secs(this.parameters.hold)),this.parameters.keynumToDecay>0&&(this.parameters.decay+=this.parameters.keynumToDecay*(60-e),this.parameters.decay=this.parameters.decay<-1e4?0:na.timecents2Secs(this.parameters.decay)),this.midiVelocity=0|s,this.isAmpEnv=i,this.nextSegment(0,n)}process(t,e){this.slope>0&&(this.segmentIsExponential?this.level*=Math.pow(this.slope,t):this.level+=this.slope*t),this.samplesUntilNextSegment-=t,this.samplesUntilNextSegment<=0&&this.nextSegment(this.segment,e)}},ca=class{samplesUntil=0;level=0;delta=0;setup(t,e,s){this.samplesUntil=t*s|0,this.delta=4*na.cents2Hertz(e)/s,this.level=0}process(t){this.samplesUntil>t?this.samplesUntil-=t:(this.level+=this.delta*t,this.level>1?(this.delta=-this.delta,this.level=2-this.level):this.level<-1&&(this.delta=-this.delta,this.level=-2-this.level))}},la=class{qInv=0;a0=0;a1=0;b1=0;b2=0;z1=0;z2=0;active=!1;constructor(t){t&&(this.qInv=t.qInv,this.a0=t.a0,this.a1=t.a1,this.b1=t.b1,this.b2=t.b2,this.z1=t.z1,this.z2=t.z2,this.active=t.active)}setup(t){const e=Math.tan(Math.PI*t),s=e*e,i=1/(1+e*this.qInv+s);this.a0=s*i,this.a1=2*this.a0,this.b1=2*(s-1)*i,this.b2=(1-e*this.qInv+s)*i}process(t){const e=t*this.a0+this.z1;return this.z1=t*this.a1+this.z2-this.b1*e,this.z2=t*this.a0-this.b2*e,e}},ua=class t{static renderEffectSampleBlock=yt.MicroBufferSize;playingPreset=0;playingKey=0;playingChannel=0;region=null;pitchInputTimecents=0;pitchOutputFactor=0;sourceSamplePosition=0;noteGainDb=0;panFactorLeft=0;panFactorRight=0;playIndex=0;loopStart=0;loopEnd=0;ampEnv=new oa;modEnv=new oa;lowPass=new la;modLfo=new ca;vibLfo=new ca;mixVolume=0;mute=!1;updatePitchRatio(t,e){let s=t.pitchWheel;t.perNotePitchWheel.has(this.playingKey)&&(s+=t.perNotePitchWheel.get(this.playingKey)-8192);const i=8192===s?t.tuning:s/16383*t.pitchRange*2-t.pitchRange+t.tuning;this.calcPitchRatio(i,e)}calcPitchRatio(t,e){if(!this.region)return;const s=this.playingKey+this.region.transpose+this.region.tune/100;let i=this.region.pitchKeyCenter+(s-this.region.pitchKeyCenter)*(this.region.pitchKeyTrack/100);0!==t&&(i+=t),this.pitchInputTimecents=100*i,this.pitchOutputFactor=this.region.sampleRate/(na.timecents2Secs(100*this.region.pitchKeyCenter)*e)}end(t){this.region&&(this.ampEnv.nextSegment(ha.Sustain,t),this.modEnv.nextSegment(ha.Sustain,t),this.region.loopMode===ea.Sustain&&(this.loopEnd=this.loopStart))}endQuick(t){this.ampEnv.parameters.release=0,this.ampEnv.nextSegment(ha.Sustain,t),this.modEnv.parameters.release=0,this.modEnv.nextSegment(ha.Sustain,t)}render(e,s,i,n,r){if(!this.region)return;const a=this.region,h=a.samples;let o=0,c=e.outputMode===sa.StereoUnweaved?n:-1;const l=0!==a.modEnvToPitch||0!==a.modEnvToFilterFc,u=this.modLfo.delta>0&&(0!==a.modLfoToPitch||0!==a.modLfoToFilterFc||0!==a.modLfoToVolume),d=this.vibLfo.delta>0&&0!==a.vibLfoToPitch,f=this.loopStart<this.loopEnd,p=this.loopStart,b=this.loopEnd,m=a.end,g=b+1;let w=this.sourceSamplePosition;const y=new la(this.lowPass),k=0!==a.modLfoToFilterFc||0!==a.modEnvToFilterFc;let S=0,B=0,_=0,x=0;const T=0!==a.modLfoToPitch||0!==a.modEnvToPitch||0!==a.vibLfoToPitch;let M=0,v=0,N=0,P=0;const C=0!==a.modLfoToVolume;let E=0,F=0;for(k?(S=e.outSampleRate,B=a.initialFilterFc,_=a.modLfoToFilterFc,x=a.modEnvToFilterFc):(S=0,B=0,_=0,x=0),T?(M=0,v=a.modLfoToPitch,N=a.vibLfoToPitch,P=a.modEnvToPitch):(M=na.timecents2Secs(this.pitchInputTimecents)*this.pitchOutputFactor,v=0,N=0,P=0),C?F=.1*a.modLfoToVolume:(E=na.decibelsToGain(this.noteGainDb),F=0);n>0;){let a,A,D=0,L=n>t.renderEffectSampleBlock?t.renderEffectSampleBlock:n;if(n-=L,k){const t=B+this.modLfo.level*_+this.modEnv.level*x;y.active=t<=13500,y.active&&y.setup(na.cents2Hertz(t)/S)}switch(T&&(M=na.timecents2Secs(this.pitchInputTimecents+(this.modLfo.level*v+this.vibLfo.level*N+this.modEnv.level*P))*this.pitchOutputFactor),C&&(E=na.decibelsToGain(this.noteGainDb+this.modLfo.level*F)),this.ampEnv.process(L,e.outSampleRate),l&&this.modEnv.process(L,e.outSampleRate),a=E*this.ampEnv.level,r?a=0:a*=this.mixVolume,u&&this.modLfo.process(L),d&&this.vibLfo.process(L),e.outputMode){case sa.StereoInterleaved:for(A=a*this.panFactorLeft,D=a*this.panFactorRight;L-- >0&&w<m;){const t=0|w,e=t>=b&&f?p:t+1,n=w-t;let r=h[t]*(1-n)+h[e]*n;y.active&&(r=y.process(r)),s[i+o]+=r*A,o++,s[i+o]+=r*D,o++,w+=M,w>=g&&f&&(w-=b-p+1)}break;case sa.StereoUnweaved:for(A=a*this.panFactorLeft,D=a*this.panFactorRight;L-- >0&&w<m;){const t=0|w,e=t>=b&&f?p:t+1,n=w-t;let r=h[t]*(1-n)+h[e]*n;y.active&&(r=y.process(r)),s[i+o]+=r*A,o++,s[i+c]+=r*D,c++,w+=M,w>=g&&f&&(w-=b-p+1)}break;case sa.Mono:for(;L-- >0&&w<m;){const t=0|w,e=t>=b&&f?p:t+1,n=w-t;let r=h[t]*(1-n)+h[e]*n;y.active&&(r=y.process(r)),s[i+o]=r*a,o++,w+=M,w>=g&&f&&(w-=b-p+1)}}const W=this.ampEnv.segment===ha.Release&&Math.abs(a)<yt.AudibleLevelThreshold;if(w>=m||this.ampEnv.segment===ha.Done||W)return void this.kill()}this.sourceSamplePosition=w,(y.active||k)&&(this.lowPass=y)}kill(){this.playingPreset=-1}},da=function(t){return t[t.BankSelectCoarse=0]="BankSelectCoarse",t[t.ModulationCoarse=1]="ModulationCoarse",t[t.DataEntryCoarse=6]="DataEntryCoarse",t[t.VolumeCoarse=7]="VolumeCoarse",t[t.PanCoarse=10]="PanCoarse",t[t.ExpressionControllerCoarse=11]="ExpressionControllerCoarse",t[t.BankSelectFine=32]="BankSelectFine",t[t.ModulationFine=33]="ModulationFine",t[t.DataEntryFine=38]="DataEntryFine",t[t.VolumeFine=39]="VolumeFine",t[t.PanFine=42]="PanFine",t[t.ExpressionControllerFine=43]="ExpressionControllerFine",t[t.HoldPedal=64]="HoldPedal",t[t.LegatoPedal=68]="LegatoPedal",t[t.NonRegisteredParameterFine=98]="NonRegisteredParameterFine",t[t.NonRegisteredParameterCourse=99]="NonRegisteredParameterCourse",t[t.RegisteredParameterFine=100]="RegisteredParameterFine",t[t.RegisteredParameterCourse=101]="RegisteredParameterCourse",t[t.AllSoundOff=120]="AllSoundOff",t[t.ResetControllers=121]="ResetControllers",t[t.AllNotesOff=123]="AllNotesOff",t}({}),fa=class t{Dp=new tr;Lp=new Map;Wp=new Map;Rp=!1;Op=new Map;Ip=new Map;currentTempo=0;timeSignatureNumerator=0;timeSignatureDenominator=0;Gp=yt.DefaultChannelCount-1;constructor(t){this.outSampleRate=t}synthesize(t,e,s){return this.Hp(t,e,s)}synthesizeSilent(t){this.Hp(null,0,t)}channelGetMixVolume(t){return this.wf&&t<this.wf.channelList.length?this.wf.channelList[t].mixVolume:1}channelSetMixVolume(t,e){const s=this.$p(t);for(const s of this.Vp)s.playingChannel===t&&-1!==s.playingPreset&&(s.mixVolume=e);s.mixVolume=e}channelSetMute(t,e){e?this.Lp.set(t,!0):this.Lp.delete(t)}channelSetSolo(t,e){e?this.Wp.set(t,!0):this.Wp.delete(t),this.Rp=this.Wp.size>0}resetChannelStates(){this.Lp=new Map,this.Wp=new Map,this.Ip=new Map,this.applyTranspositionPitches(new Map),this.Rp=!1}setChannelTranspositionPitch(t,e){let s=0;this.Ip.has(t)&&(s=this.Ip.get(t)),0===e?this.Ip.delete(t):this.Ip.set(t,e);for(const i of this.Vp)if(i.playingChannel===t&&9!==i.playingChannel){let t=0;t-=s,t+=e,i.playingKey+=t,this.wf&&i.updatePitchRatio(this.wf.channelList[i.playingChannel],this.outSampleRate)}}applyTranspositionPitches(t){const e=this.Op;for(const s of this.Vp)if(s.playingChannel>=0&&9!==s.playingChannel){let i=0;e.has(s.playingChannel)&&(i-=e.get(s.playingChannel)),t.has(s.playingChannel)&&(i+=t.get(s.playingChannel)),s.playingKey+=i,this.wf&&s.updatePitchRatio(this.wf.channelList[s.playingChannel],this.outSampleRate)}this.Op=t}dispatchEvent(t){this.Dp.enqueue(t)}Hp(t,e,s){const i=this.Rp,n=[];for(;!this.Dp.isEmpty;){const t=this.Dp.dequeue();t.isMetronome&&this.metronomeVolume>0?(this.channelNoteOff(this.Gp,yt.MetronomeKey),this.channelNoteOn(this.Gp,yt.MetronomeKey,95/127)):t.event&&this.processMidiMessage(t.event),n.push(t)}for(const n of this.Vp)if(-1!==n.playingPreset){const r=n.playingChannel,a=this.Lp.has(r)||i&&r!==this.Gp&&!this.Wp.has(r);t?n.render(this,t,e,s,a):n.kill()}return n}processMidiMessage(t){switch(t.type){case Sn.TimeSignature:const e=t;this.timeSignatureNumerator=e.numerator,this.timeSignatureDenominator=Math.pow(2,e.denominatorIndex);break;case Sn.NoteOn:const s=t;this.channelNoteOn(s.channel,s.noteKey,s.noteVelocity/127);break;case Sn.NoteOff:const i=t;this.channelNoteOff(i.channel,i.noteKey);break;case Sn.ControlChange:const n=t;this.channelMidiControl(n.channel,n.controller,n.value);break;case Sn.ProgramChange:const r=t;this.channelSetPresetNumber(r.channel,r.program,9===r.channel);break;case Sn.TempoChange:const a=t;this.currentTempo=a.beatsPerMinute;break;case Sn.PitchBend:const h=t;this.channelSetPitchWheel(h.channel,h.value);break;case Sn.PerNotePitchBend:const o=t;let c=o.value;c=c*yt.MaxPitchWheel/yt.MaxPitchWheel20,this.channelSetPerNotePitchWheel(o.channel,o.noteKey,c)}}get metronomeVolume(){return this.channelGetMixVolume(this.Gp)}set metronomeVolume(t){this.setupMetronomeChannel(this.Gp,t)}setupMetronomeChannel(t,e){this.Gp=t,this.channelSetMixVolume(t,e),e>0&&(this.channelSetVolume(t,1),this.channelSetPresetNumber(t,0,!0))}get masterVolume(){return na.decibelsToGain(this.globalGainDb)}set masterVolume(t){const e=na.gainToDecibels(t),s=e-this.globalGainDb;if(0!==s){for(const t of this.Vp)-1!==t.playingPreset&&(t.noteGainDb+=s);this.globalGainDb=e}}resetSoft(){for(const t of this.Vp)-1!==t.playingPreset&&(t.ampEnv.segment<ha.Release||0!==t.ampEnv.parameters.release)&&t.endQuick(this.outSampleRate);if(this.wf)for(const t of this.wf.channelList)t.presetIndex=0,t.bank=0,t.pitchWheel=8192,t.midiPan=8192,t.perNotePitchWheel.clear(),t.midiVolume=16383,t.midiExpression=16383,t.midiRpn=65535,t.midiData=0,t.panOffset=0,t.gainDb=0,t.pitchRange=2,t.tuning=0}presets=null;Vp=[];wf=null;zp=0;get presetCount(){return this.presets?.length??0}outputMode=sa.StereoInterleaved;outSampleRate=0;globalGainDb=0;reset(){for(const t of this.Vp)-1!==t.playingPreset&&(t.ampEnv.segment<ha.Release||0!==t.ampEnv.parameters.release)&&t.endQuick(this.outSampleRate);this.wf=null}setOutput(t,e,s){this.outputMode=t,this.outSampleRate=e>=1?e:44100,this.globalGainDb=s}noteOn(t,e,s){if(!this.presets)return;const i=127*s|0;if(t<0||t>=this.presets.length)return;if(s<=0)return void this.noteOff(t,e);const n=this.zp++;for(const r of this.presets[t].regions){if(e<r.loKey||e>r.hiKey||i<r.loVel||i>r.hiVel)continue;let a=null;if(0!==r.group)for(const e of this.Vp)e.playingPreset===t&&e.region.group===r.group?e.endQuick(this.outSampleRate):-1!==e.playingPreset||a||(a=e);else for(const t of this.Vp)-1===t.playingPreset&&(a=t);if(!a){for(let t=0;t<4;t++){const t=new ua;t.playingPreset=-1,this.Vp.push(t)}a=this.Vp[this.Vp.length-4]}a.region=r,a.playingPreset=t,a.playingKey=e,a.playIndex=n,a.noteGainDb=this.globalGainDb-r.attenuation-na.gainToDecibels(1/s),this.wf?this.wf.setupVoice(this,a):(a.calcPitchRatio(0,this.outSampleRate),a.panFactorLeft=Math.sqrt(.5-r.pan),a.panFactorRight=Math.sqrt(.5+r.pan)),a.sourceSamplePosition=r.offset;const h=r.loopMode!==ea.None&&r.loopStart<r.loopEnd;a.loopStart=h?r.loopStart:0,a.loopEnd=h?r.loopEnd:0,a.ampEnv.setup(r.ampEnv,e,i,!0,this.outSampleRate),a.modEnv.setup(r.modEnv,e,i,!1,this.outSampleRate);const o=r.initialFilterQ/10;a.lowPass.qInv=1/Math.pow(10,o/20),a.lowPass.z1=0,a.lowPass.z2=0,a.lowPass.active=r.initialFilterFc<=13500,a.lowPass.active&&a.lowPass.setup(na.cents2Hertz(r.initialFilterFc)/this.outSampleRate),a.modLfo.setup(r.delayModLFO,r.freqModLFO,this.outSampleRate),a.vibLfo.setup(r.delayVibLFO,r.freqVibLFO,this.outSampleRate)}}bankNoteOn(t,e,s,i){const n=this.Xp(t,e);return-1!==n&&(this.noteOn(n,s,i),!0)}noteOff(t,e){let s=null,i=null;const n=[];for(const r of this.Vp)r.playingPreset!==t||r.playingKey!==e||r.ampEnv.segment>=ha.Release||(!s||r.playIndex<s.playIndex?(s=r,i=r,n.push(r)):r.playIndex===s.playIndex&&(i=r,n.push(r)));if(s)for(const r of n)r!==s&&r!==i&&(r.playIndex!==s.playIndex||r.playingPreset!==t||r.playingKey!==e||r.ampEnv.segment>=ha.Release)||r.end(this.outSampleRate)}bankNoteOff(t,e,s){const i=this.Xp(t,e);return-1!==i&&(this.noteOff(i,s),!0)}noteOffAll(t){for(const e of this.Vp)-1!==e.playingPreset&&(t?e.endQuick(this.outSampleRate):e.ampEnv.segment<ha.Release&&e.end(this.outSampleRate))}get activeVoiceCount(){let t=0;for(const e of this.Vp)-1!==e.playingPreset&&t++;return t}$p(t){if(this.wf&&t<this.wf.channelList.length)return this.wf.channelList[t];this.wf||(this.wf=new ta);for(let e=this.wf.channelList.length;e<=t;e++){const t=new Zr;t.presetIndex=0,t.bank=0,t.pitchWheel=8192,t.midiPan=8192,t.midiVolume=16383,t.midiExpression=16383,t.midiRpn=65535,t.midiData=0,t.panOffset=0,t.gainDb=0,t.pitchRange=2,t.tuning=0,t.mixVolume=1,this.wf.channelList.push(t)}return this.wf.channelList[t]}Xp(t,e){if(!this.presets)return-1;for(let s=this.presets.length-1;s>=0;s--){const i=this.presets[s];if(i.presetNumber===e&&i.bank===t)return s}return-1}getPresetName(t){return this.presets?t<0||t>=this.presets.length?null:this.presets[t].name:null}bankGetPresetName(t,e){return this.getPresetName(this.Xp(t,e))}channelNoteOn(t,e,s){!this.wf||t>this.wf.channelList.length||(this.Op.has(t)&&(e+=this.Op.get(t)),this.Ip.has(t)&&(e+=this.Ip.get(t)),this.wf.activeChannel=t,this.noteOn(this.wf.channelList[t].presetIndex,e,s))}channelNoteOff(t,e){this.Op.has(t)&&(e+=this.Op.get(t)),this.Ip.has(t)&&(e+=this.Ip.get(t));const s=[];let i=null,n=null;for(const r of this.Vp)-1===r.playingPreset||r.playingChannel!==t||r.playingKey!==e||r.ampEnv.segment>=ha.Release||(!i||r.playIndex<i.playIndex?(i=r,n=r,s.push(r)):r.playIndex===i.playIndex&&(n=r,s.push(r)));if(this.$p(t).perNotePitchWheel.delete(e),i)for(const r of s)r!==i&&r!==n&&(r.playIndex!==i.playIndex||-1===r.playingPreset||r.playingChannel!==t||r.playingKey!==e||r.ampEnv.segment>=ha.Release)||r.end(this.outSampleRate)}channelNoteOffAll(t){this.$p(t).perNotePitchWheel.clear();for(const e of this.Vp)-1!==e.playingPreset&&e.playingChannel===t&&e.ampEnv.segment<ha.Release&&e.end(this.outSampleRate)}channelSoundsOffAll(t){this.$p(t).perNotePitchWheel.clear();for(const e of this.Vp)-1!==e.playingPreset&&e.playingChannel===t&&(e.ampEnv.segment<ha.Release||0===e.ampEnv.parameters.release)&&e.endQuick(this.outSampleRate)}channelSetPresetIndex(t,e){this.$p(t).presetIndex=ce.int32ToUint16(e)}channelSetPresetNumber(t,e,s=!1){const i=this.$p(t);let n=0;return s?(n=this.Xp(128|32767&i.bank,e),-1===n&&(n=this.Xp(128,e)),-1===n&&(n=this.Xp(128,0)),-1===n&&(n=this.Xp(2047&i.bank,e))):n=this.Xp(2047&i.bank,e),i.presetIndex=n,-1!==n}channelSetBank(t,e){this.$p(t).bank=ce.int32ToUint16(e)}channelSetBankPreset(t,e,s){const i=this.$p(t),n=this.Xp(e,s);return-1!==n&&(i.presetIndex=ce.int32ToUint16(n),i.bank=ce.int32ToUint16(e),!0)}channelSetPan(t,e){for(const s of this.Vp)if(s.playingChannel===t&&-1!==s.playingPreset){const t=s.region.pan+e-.5;t<=-.5?(s.panFactorLeft=1,s.panFactorRight=0):t>=.5?(s.panFactorLeft=0,s.panFactorRight=1):(s.panFactorLeft=Math.sqrt(.5-t),s.panFactorRight=Math.sqrt(.5+t))}this.$p(t).panOffset=e-.5}channelSetVolume(t,e){const s=this.$p(t),i=na.gainToDecibels(e),n=i-s.gainDb;if(0!==n){for(const e of this.Vp)e.playingChannel===t&&-1!==e.playingPreset&&(e.noteGainDb+=n);s.gainDb=i}}channelSetPitchWheel(t,e){const s=this.$p(t);s.pitchWheel!==e&&(s.pitchWheel=ce.int32ToUint16(e),this.jp(t,s))}channelSetPerNotePitchWheel(t,e,s){this.Op.has(t)&&(e+=this.Op.get(t)),this.Ip.has(t)&&(e+=this.Ip.get(t));const i=this.$p(t);i.perNotePitchWheel.has(e)&&i.perNotePitchWheel.get(e)===s||(i.perNotePitchWheel.set(e,s),this.jp(t,i,e))}jp(t,e,s=-1){for(const i of this.Vp)i.playingChannel!==t||-1===i.playingPreset||-1!==s&&i.playingKey!==s||i.updatePitchRatio(e,this.outSampleRate)}channelSetPitchRange(t,e){const s=this.$p(t);s.pitchRange!==e&&(s.pitchRange=e,8192!==s.pitchWheel&&this.jp(t,s))}channelSetTuning(t,e){const s=this.$p(t);s.tuning!==e&&(s.tuning=e,this.jp(t,s))}channelMidiControl(t,e,s){const i=this.$p(t);switch(e){case da.DataEntryFine:return i.midiData=ce.int32ToUint16(16256&i.midiData|s),void(0===i.midiRpn?this.channelSetPitchRange(t,(i.midiData>>7)+.01*(127&i.midiData)):1===i.midiRpn?this.channelSetTuning(t,(0|i.tuning)+(i.midiData-8192)/8192):2===i.midiRpn&&this.channelSetTuning(t,s-64+(i.tuning-(0|i.tuning))));case da.VolumeCoarse:return i.midiVolume=ce.int32ToUint16(127&i.midiVolume|s<<7),void this.channelSetVolume(t,Math.pow(i.midiVolume/16383*(i.midiExpression/16383),3));case da.VolumeFine:return i.midiVolume=ce.int32ToUint16(16256&i.midiVolume|s),void this.channelSetVolume(t,Math.pow(i.midiVolume/16383*(i.midiExpression/16383),3));case da.ExpressionControllerCoarse:return i.midiExpression=ce.int32ToUint16(127&i.midiExpression|s<<7),void this.channelSetVolume(t,Math.pow(i.midiVolume/16383*(i.midiExpression/16383),3));case da.ExpressionControllerFine:return i.midiExpression=ce.int32ToUint16(16256&i.midiExpression|s),void this.channelSetVolume(t,Math.pow(i.midiVolume/16383*(i.midiExpression/16383),3));case da.PanCoarse:return i.midiPan=ce.int32ToUint16(127&i.midiPan|s<<7),void this.channelSetPan(t,i.midiPan/16383);case da.PanFine:return i.midiPan=ce.int32ToUint16(16256&i.midiPan|s),void this.channelSetPan(t,i.midiPan/16383);case da.DataEntryCoarse:return i.midiData=ce.int32ToUint16(127&i.midiData|s<<7),void(0===i.midiRpn?this.channelSetPitchRange(t,(i.midiData>>7)+.01*(127&i.midiData)):1===i.midiRpn?this.channelSetTuning(t,(0|i.tuning)+(i.midiData-8192)/8192):2===i.midiRpn&&e===da.DataEntryCoarse&&this.channelSetTuning(t,s-64+(i.tuning-(0|i.tuning))));case da.BankSelectCoarse:return void(i.bank=ce.int32ToUint16(32768|s));case da.BankSelectFine:return void(i.bank=ce.int32ToUint16((32768&i.bank?(127&i.bank)<<7:0)|s));case da.RegisteredParameterCourse:return void(i.midiRpn=ce.int32ToUint16(127&(65535===i.midiRpn?0:i.midiRpn)|s<<7));case da.RegisteredParameterFine:return void(i.midiRpn=ce.int32ToUint16(16256&(65535===i.midiRpn?0:i.midiRpn)|s));case da.NonRegisteredParameterFine:case da.NonRegisteredParameterCourse:return void(i.midiRpn=65535);case da.AllSoundOff:return void this.channelSoundsOffAll(t);case da.AllNotesOff:return void this.channelNoteOffAll(t);case da.ResetControllers:return i.midiVolume=16383,i.midiExpression=16383,i.midiPan=8192,i.bank=0,this.channelSetVolume(t,1),this.channelSetPan(t,.5),void this.channelSetPitchRange(t,2)}}channelGetPresetIndex(t){return this.wf&&t<this.wf.channelList.length?this.wf.channelList[t].presetIndex:0}channelGetPresetBank(t){return this.wf&&t<this.wf.channelList.length?32767&this.wf.channelList[t].bank:0}channelGetPan(t){return this.wf&&t<this.wf.channelList.length?this.wf.channelList[t].panOffset-.5:.5}channelGetVolume(t){return this.wf&&t<this.wf.channelList.length?na.decibelsToGain(this.wf.channelList[t].gainDb):1}channelGetPitchWheel(t){return this.wf&&t<this.wf.channelList.length?this.wf.channelList[t].pitchWheel:8192}channelGetPitchRange(t){return this.wf&&t<this.wf.channelList.length?this.wf.channelList[t].pitchRange:2}channelGetTuning(t){return this.wf&&t<this.wf.channelList.length?this.wf.channelList[t].tuning:0}resetPresets(){this.presets=[]}loadPresets(e,s,i,n){const r=[];for(let n=0;n<e.phdrs.length-1;n++){const a=e.phdrs[n];let h=0;const o=new ia;r.push(o),o.name=a.presetName,o.bank=a.bank,o.presetNumber=a.preset;let c=0;for(let t=a.presetBagNdx;t<e.phdrs[n+1].presetBagNdx;t++){let s=0,i=127,n=0,r=127;for(let a=e.pbags[t].genNdx;a<e.pbags[t+1].genNdx;a++){const t=e.pgens[a];if(t.genOper===Jr.GenKeyRange){s=t.genAmount.lowByteAmount,i=t.genAmount.highByteAmount;continue}if(t.genOper===Jr.GenVelRange){n=t.genAmount.lowByteAmount,r=t.genAmount.highByteAmount;continue}if(t.genOper!==Jr.GenInstrument)continue;if(t.genAmount.wordAmount>=e.insts.length)continue;for(let a=e.insts[t.genAmount.wordAmount].instBagNdx;a<e.insts[t.genAmount.wordAmount+1].instBagNdx;a++){let t=0,h=127,o=0,l=127;for(let u=e.ibags[a].instGenNdx;u<e.ibags[a+1].instGenNdx;u++){const a=e.igens[u];a.genOper!==Jr.GenKeyRange?a.genOper!==Jr.GenVelRange?53===a.genOper&&h>=s&&t<=i&&l>=n&&o<=r&&c++:(o=a.genAmount.lowByteAmount,l=a.genAmount.highByteAmount):(t=a.genAmount.lowByteAmount,h=a.genAmount.highByteAmount)}}}}o.regions=new Array(c);let l=new aa;l.clear(!0);for(let r=a.presetBagNdx;r<e.phdrs[n+1].presetBagNdx;r++){const n=e.pbags[r],c=new aa(l);let u=!1;for(let l=n.genNdx;l<e.pbags[r+1].genNdx;l++){const n=e.pgens[l];if(n.genOper===Jr.GenInstrument){const r=n.genAmount.wordAmount;if(r>=e.insts.length)continue;let l=new aa;l.clear(!1);const d=e.insts[r];for(let n=d.instBagNdx;n<e.insts[r+1].instBagNdx;n++){const r=e.ibags[n],u=new aa(l);let f=!1;for(let l=r.instGenNdx;l<e.ibags[n+1].instGenNdx;l++){const n=e.igens[l];if(n.genOper===Jr.GenSampleId){if(u.hiKey<c.loKey||u.loKey>c.hiKey)continue;if(u.hiVel<c.loVel||u.loVel>c.hiVel)continue;c.loKey>u.loKey&&(u.loKey=c.loKey),c.hiKey<u.hiKey&&(u.hiKey=c.hiKey),c.loVel>u.loVel&&(u.loVel=c.loVel),c.hiVel<u.hiVel&&(u.hiVel=c.hiVel),u.offset+=c.offset,u.end+=c.end,u.loopStart+=c.loopStart,u.loopEnd+=c.loopEnd,u.transpose+=c.transpose,u.tune+=c.tune,u.pitchKeyTrack+=c.pitchKeyTrack,u.attenuation+=c.attenuation,u.pan+=c.pan,u.ampEnv.delay+=c.ampEnv.delay,u.ampEnv.attack+=c.ampEnv.attack,u.ampEnv.hold+=c.ampEnv.hold,u.ampEnv.decay+=c.ampEnv.decay,u.ampEnv.sustain+=c.ampEnv.sustain,u.ampEnv.release+=c.ampEnv.release,u.modEnv.delay+=c.modEnv.delay,u.modEnv.attack+=c.modEnv.attack,u.modEnv.hold+=c.modEnv.hold,u.modEnv.decay+=c.modEnv.decay,u.modEnv.sustain+=c.modEnv.sustain,u.modEnv.release+=c.modEnv.release,u.initialFilterQ+=c.initialFilterQ,u.initialFilterFc+=c.initialFilterFc,u.modEnvToPitch+=c.modEnvToPitch,u.modEnvToFilterFc+=c.modEnvToFilterFc,u.delayModLFO+=c.delayModLFO,u.freqModLFO+=c.freqModLFO,u.modLfoToPitch+=c.modLfoToPitch,u.modLfoToFilterFc+=c.modLfoToFilterFc,u.modLfoToVolume+=c.modLfoToVolume,u.delayVibLFO+=c.delayVibLFO,u.freqVibLFO+=c.freqVibLFO,u.vibLfoToPitch+=c.vibLfoToPitch,u.ampEnv.envToSecs(!0),u.modEnv.envToSecs(!1),u.delayModLFO=u.delayModLFO<-11950?0:na.timecents2Secs(u.delayModLFO),u.delayVibLFO=u.delayVibLFO<-11950?0:na.timecents2Secs(u.delayVibLFO),u.pan<-.5?u.pan=-.5:u.pan>.5&&(u.pan=.5),(u.initialFilterQ<1500||u.initialFilterQ>13500)&&(u.initialFilterQ=0);const r=e.sHdrs[n.genAmount.wordAmount];u.offset+=r.start,u.end+=r.end,u.loopStart+=r.startLoop,u.loopEnd+=r.endLoop,r.endLoop>0&&(u.loopEnd-=1),-1===u.pitchKeyCenter&&(u.pitchKeyCenter=r.originalPitch),u.tune+=r.pitchCorrection,u.sampleRate=r.sampleRate;const l=a.bank===yt.PercussionBank;l&&t.Jp(i,u.loKey,u.hiKey)||!l&&s.has(a.preset)?1&r.sampleType?(O.debug("AlphaSynth",`Loading of used sample ${r.sampleName} for preset ${a.presetName} (bank ${o.bank} program ${o.presetNumber})`),16&r.sampleType?u.samples=e.decodeSamples(r.start,r.end,!0):(u.samples=e.decodeSamples(2*u.offset,2*u.end,!1),u.loopStart>0&&(u.loopStart-=u.offset),u.loopEnd>0&&(u.loopEnd-=u.offset)),u.offset=0,u.end=u.samples.length-1):(O.warning("AlphaSynth",`Skipping load of unsupported sample ${r.sampleName} for preset ${a.presetName}, sample type ${r.sampleType} is not supported (bank ${o.bank} program ${o.presetNumber})`),u.samples=new Float32Array(0)):(O.debug("AlphaSynth",`Skipping load of unused sample ${r.sampleName} for preset ${a.presetName} (bank ${o.bank} program ${o.presetNumber})`),u.samples=new Float32Array(0)),o.regions[h]=new aa(u),h++,f=!0}else u.operator(n.genOper,n.genAmount)}r!==e.ibags[d.instBagNdx]||f||(l=new aa(u))}u=!0}else c.operator(n.genOper,n.genAmount)}n!==e.pbags[a.presetBagNdx]||u||(l=c)}}if(n&&this.presets)for(const t of r)this.presets.push(t);else this.presets=r}static Jp(t,e,s){for(let i=e;i<=s;i++)if(t.has(i))return!0;return!1}hasSamplesForProgram(t){const e=this.presets;if(!e)return!1;for(const s of e)if(s.presetNumber===t)for(const t of s.regions)if(t.samples.length>0)return!0;return!1}hasSamplesForPercussion(t){const e=this.presets;if(!e)return!1;for(const s of e)if(s.bank===yt.PercussionBank)for(const e of s.regions)if(e.loKey>=t&&e.hiKey<=t&&e.samples.length>0)return!0;return!1}},pa=class{sequencer;synthesizer;isSoundFontLoaded=!1;qp=!1;Yp=0;Kp=0;Lu=0;Wu=0;playedEventsQueue=new tr;midiEventsPlayedFilterSet=new Set;Qp=0;Zp=!1;cn;Hu;$u=new Hn(0,0,0,0,!1,120,120);get output(){return this.cn}isReady=!1;get isReadyForPlayback(){return this.isReady&&this.isSoundFontLoaded&&this.qp}state=In.Paused;get logLevel(){return O.logLevel}set logLevel(t){O.logLevel=t}get masterVolume(){return this.synthesizer.masterVolume}set masterVolume(t){t=Math.max(t,yt.MinVolume),this.updateMasterVolume(t)}updateMasterVolume(t){this.synthesizer.masterVolume=t}get metronomeVolume(){return this.Lu}set metronomeVolume(t){t=Math.max(t,yt.MinVolume),this.Lu=t,this.synthesizer.metronomeVolume=t}get countInVolume(){return this.Wu}set countInVolume(t){t=Math.max(t,yt.MinVolume),this.Wu=t}get midiEventsPlayedFilter(){return Array.from(this.midiEventsPlayedFilterSet)}set midiEventsPlayedFilter(t){this.midiEventsPlayedFilterSet=new Set(t)}get playbackSpeed(){return this.sequencer.playbackSpeed}set playbackSpeed(t){t=Bt.clamp(t,yt.MinPlaybackSpeed,yt.MaxPlaybackSpeed),this.updatePlaybackSpeed(t)}updatePlaybackSpeed(t){const e=this.sequencer.playbackSpeed;this.sequencer.playbackSpeed=t,this.timePosition=this.timePosition*(e/t)}get loadedMidiInfo(){return this.Hu}get currentPosition(){return this.$u}get tickPosition(){return this.Yp}set tickPosition(t){this.timePosition=this.sequencer.mainTickPositionToTimePosition(t)}get timePosition(){return this.Kp}set timePosition(t){O.debug("AlphaSynth",`Seeking to position ${t}ms (main)`),this.sequencer.mainSeek(t),this.updateTimePosition(t,!0),this.sequencer.isPlayingMain&&(this.Qp=0,this.output.resetSamples())}get playbackRange(){return this.sequencer.mainPlaybackRange}set playbackRange(t){this.sequencer.mainPlaybackRange=t,t&&(this.tickPosition=t.startTick),this.playbackRangeChanged.trigger(new On(t))}get isLooping(){return this.sequencer.isLooping}set isLooping(t){this.sequencer.isLooping=t}destroy(){O.debug("AlphaSynth","Destroying player"),this.stop(),this.output.destroy()}constructor(t,e,s){O.debug("AlphaSynth","Initializing player"),this.state=In.Paused,this.ready=new js(()=>this.isReady),this.readyForPlayback=new js(()=>this.isReadyForPlayback),this.midiLoaded=new Js(()=>this.Hu?this.Hu:null),this.stateChanged=new Js(()=>new Gn(this.state,!1)),this.positionChanged=new Js(()=>this.$u),this.playbackRangeChanged=new Js(()=>this.playbackRange?new On(this.playbackRange):null),O.debug("AlphaSynth","Creating output"),this.cn=t,O.debug("AlphaSynth","Creating synthesizer"),this.synthesizer=e,this.sequencer=new hr(this.synthesizer),O.debug("AlphaSynth","Opening output"),this.output.ready.on(()=>{this.isReady=!0,this.ready.trigger(),this.Uu()}),this.output.sampleRequest.on(()=>{this.onSampleRequest()}),this.output.samplesPlayed.on(this.tb.bind(this)),this.output.open(s)}onSampleRequest(){if(this.state===In.Playing&&(!this.sequencer.isFinished||this.synthesizer.activeVoiceCount>0)){let t=new Float32Array(yt.MicroBufferSize*yt.MicroBufferCount*yt.AudioChannels),e=0;for(let s=0;s<yt.MicroBufferCount;s++){this.sequencer.fillMidiEventQueue();const s=this.synthesizer.synthesize(t,e,yt.MicroBufferSize);e+=yt.MicroBufferSize*yt.AudioChannels;for(const t of s)this.midiEventsPlayedFilterSet.has(t.event.type)&&this.playedEventsQueue.enqueue(t);if(this.sequencer.isFinished)break}e<t.length&&(t=t.subarray(0,e)),this.Qp+=t.length,this.output.addSamples(t),this.sequencer.isFinished&&this.synthesizer.noteOffAll(!0)}else{const t=new Float32Array(0);this.output.addSamples(t)}}play(){return!(this.state!==In.Paused||!this.qp)&&(this.output.activate(),this.eb(),this.Wu>0&&(O.debug("AlphaSynth","Starting countin"),this.sequencer.startCountIn(),this.synthesizer.setupMetronomeChannel(this.sequencer.metronomeChannel,this.Wu),this.updateTimePosition(0,!0)),this.output.play(),!0)}eb(){this.sequencer.isPlayingOneTimeMidi&&(O.debug("AlphaSynth","Cancelling one time midi"),this.sb()),O.debug("AlphaSynth","Starting playback"),this.synthesizer.setupMetronomeChannel(this.sequencer.metronomeChannel,this.metronomeVolume),this.Zp=!1,this.state=In.Playing,this.stateChanged.trigger(new Gn(this.state,!1))}pause(){this.state!==In.Paused&&this.qp&&(O.debug("AlphaSynth","Pausing playback"),this.state=In.Paused,this.stateChanged.trigger(new Gn(this.state,!1)),this.output.pause(),this.synthesizer.noteOffAll(!1))}playPause(){this.state===In.Paused&&this.qp?this.play():this.pause()}stop(){this.qp&&(O.debug("AlphaSynth","Stopping playback"),this.state=In.Paused,this.output.pause(),this.Qp=0,this.sequencer.stop(),this.synthesizer.noteOffAll(!0),this.tickPosition=this.sequencer.mainPlaybackRange?this.sequencer.mainPlaybackRange.startTick:0,this.stateChanged.trigger(new Gn(this.state,!0)))}playOneTimeMidiFile(t){this.sequencer.isPlayingOneTimeMidi?this.sb():this.pause(),this.sequencer.loadOneTimeMidi(t),this.synthesizer.noteOffAll(!0),this.updateTimePosition(0,!0),this.Qp=0,this.output.resetSamples(),this.output.activate(),this.Zp=!1,this.state=In.Playing,this.output.play()}resetSoundFonts(){this.stop(),this.synthesizer.resetPresets(),this.ib=[],this.isSoundFontLoaded=!1,this.soundFontLoaded.trigger()}ib=[];loadSoundFont(t,e){this.pause();const s=Ie.fromBuffer(t);try{O.debug("AlphaSynth","Loading soundfont from bytes");const t=new $r;t.load(s),e||(this.ib=[]),this.ib.push(t),this.isSoundFontLoaded=!0,this.soundFontLoaded.trigger(),O.debug("AlphaSynth","soundFont successfully loaded"),this.Uu()}catch(t){O.error("AlphaSynth",`Could not load soundfont from bytes ${t}`),this.soundFontLoadFailed.trigger(t)}}Uu(){if(this.isReadyForPlayback){this.synthesizer.setupMetronomeChannel(this.sequencer.metronomeChannel,this.metronomeVolume);const t=this.sequencer.instrumentPrograms,e=this.sequencer.percussionKeys;let s=!1;for(const i of this.ib)this.synthesizer.loadPresets(i,t,e,s),s=!0;this.readyForPlayback.trigger()}}loadMidiFile(t){this.stop();try{O.debug("AlphaSynth","Loading midi from model"),this.sequencer.loadMidi(t),this.qp=!0,this.Hu=new Hn(0,this.sequencer.currentEndTime,0,this.sequencer.currentEndTick,!1,this.sequencer.currentTempo,this.sequencer.modifiedTempo),this.midiLoaded.trigger(this.Hu),O.debug("AlphaSynth","Midi successfully loaded"),this.Uu(),this.tickPosition=0}catch(t){O.error("AlphaSynth",`Could not load midi from model ${t}`),this.midiLoadFailed.trigger(t)}}applyTranspositionPitches(t){this.synthesizer.applyTranspositionPitches(t)}setChannelTranspositionPitch(t,e){this.synthesizer.setChannelTranspositionPitch(t,e)}setChannelMute(t,e){this.synthesizer.channelSetMute(t,e)}resetChannelStates(){this.synthesizer.resetChannelStates()}setChannelSolo(t,e){this.synthesizer.channelSetSolo(t,e)}setChannelVolume(t,e){e=Math.max(e,yt.MinVolume),this.synthesizer.channelSetMixVolume(t,e)}tb(t){if(0===t)return;const e=t/this.synthesizer.outSampleRate*1e3;this.Qp-=t*yt.AudioChannels,this.updateTimePosition(this.Kp+e,!1),this.checkForFinish()}checkForFinish(){let t=0,e=0;this.playbackRange&&this.sequencer.isPlayingMain?(t=this.playbackRange.startTick,e=this.playbackRange.endTick):e=this.sequencer.currentEndTick,this.Yp>=e&&(this.Qp<=0?(this.Qp=0,this.sequencer.isPlayingCountIn?(O.debug("AlphaSynth","Finished playback (count-in)"),this.sequencer.resetCountIn(),this.timePosition=this.sequencer.currentTime,this.eb(),this.output.resetSamples()):this.sequencer.isPlayingOneTimeMidi?(O.debug("AlphaSynth","Finished playback (one time)"),this.output.resetSamples(),this.state=In.Paused,this.sb()):this.isLooping?(O.debug("AlphaSynth","Finished playback (main looping)"),this.finished.trigger(),this.tickPosition=t,this.Zp=!1):this.synthesizer.activeVoiceCount>0?this.Zp||(O.debug("AlphaSynth","Signaling synth to stop all voices (all samples played)"),this.synthesizer.noteOffAll(!0),this.Zp=!0):(this.Zp=!1,O.debug("AlphaSynth","Finished playback (main)"),this.finished.trigger(),this.stop())):this.Zp||(O.debug("AlphaSynth","Signaling synth to stop all voices (not all samples played)"),this.synthesizer.noteOffAll(!0),this.Zp=!0))}sb(){this.output.pause(),this.output.resetSamples(),this.synthesizer.noteOffAll(!0),this.sequencer.resetOneTimeMidi(),this.timePosition=this.sequencer.currentTime}nb(t){let e=this.Kp,s=this.sequencer.currentTimePositionToTickPosition(e);const i=this.sequencer.currentEndTime,n=this.sequencer.currentEndTick;return e>i&&(e=i,s=n),new Hn(e,i,s,n,t,this.sequencer.currentTempo,this.sequencer.modifiedTempo)}updateTimePosition(t,e){this.Kp=t;const s=this.nb(e);this.Yp=s.currentTick;const i=this.sequencer.isPlayingMain?"main":this.sequencer.isPlayingCountIn?"count-in":"one-time";if(O.debug("AlphaSynth",`Position changed: (time: ${s.currentTime}/${s.endTime}, tick: ${s.currentTick}/${s.endTick}, Active Voices: ${this.synthesizer.activeVoiceCount} (${i}), Tempo original: ${this.sequencer.currentTempo}, Tempo modified: ${this.sequencer.modifiedTempo})`),this.sequencer.isPlayingMain&&(this.$u=s,this.positionChanged.trigger(s)),e)this.playedEventsQueue.clear();else{const t=[];for(;!this.playedEventsQueue.isEmpty&&this.playedEventsQueue.peek().time<s.currentTime;){const e=this.playedEventsQueue.dequeue();t.push(e.event)}t.length>0&&(t.reverse(),this.midiEventsPlayed.trigger(new Rn(t)))}}ready;readyForPlayback=new js;finished=new js;soundFontLoaded=new js;soundFontLoadFailed=new Js;midiLoaded;midiLoadFailed=new Js;stateChanged;positionChanged;midiEventsPlayed=new Js;playbackRangeChanged;hasSamplesForProgram(t){return this.synthesizer.hasSamplesForProgram(t)}hasSamplesForPercussion(t){return this.synthesizer.hasSamplesForPercussion(t)}loadBackingTrack(t){}updateSyncPoints(t){}},ba=class extends pa{constructor(t,e){super(t,new fa(t.sampleRate),e)}exportAudio(t,e,s,i){const n=new ma(t);n.loadMidiFile(e),t.useSyncPoints&&n.updateSyncPoints(s),n.applyTranspositionPitches(i);for(const[e,s]of t.trackTranspositionPitches)n.setChannelTranspositionPitch(e,s);for(const[e,s]of t.trackVolume)n.channelSetMixVolume(e,s);if(t.soundFonts)for(const e of t.soundFonts)n.loadSoundFont(e);else n.loadPresets(this.synthesizer.presets);return t.playbackRange&&n.limitExport(t.playbackRange),n.setup(),n}},ma=class{Cu;rb;constructor(t){this.Cu=new fa(t.sampleRate),this.rb=new hr(this.Cu),this.Cu.masterVolume=Math.max(t.masterVolume,yt.MinVolume),this.Cu.metronomeVolume=Math.max(t.metronomeVolume,yt.MinVolume)}loadSoundFont(t){const e=Ie.fromBuffer(t),s=new $r;s.load(e);const i=this.rb.instrumentPrograms,n=this.rb.percussionKeys;this.Cu.loadPresets(s,i,n,!0)}loadPresets(t){this.Cu.presets=t}limitExport(t){this.rb.mainPlaybackRange=t,this.rb.mainSeek(this.rb.mainTickPositionToTimePosition(t.startTick))}setChannelTranspositionPitch(t,e){this.Cu.setChannelTranspositionPitch(t,e)}applyTranspositionPitches(t){this.Cu.applyTranspositionPitches(t)}loadMidiFile(t){this.rb.loadMidi(t)}updateSyncPoints(t){this.rb.mainUpdateSyncPoints(t)}channelSetMixVolume(t,e){e=Math.max(e,yt.MinVolume),this.Cu.channelSetMixVolume(t,e)}ab=0;hb=0;setup(){this.Cu.setupMetronomeChannel(this.rb.metronomeChannel,this.Cu.metronomeVolume);const t=this.rb.currentSyncPoints,e=this.rb.currentEndTime;if(0===t.length)this.hb=e;else{const e=t[t.length-1];let s=e.syncTime;const i=this.rb.currentEndTick-e.synthTick;i>0&&(s+=c.ticksToMillis(i,e.syncBpm)),this.hb=s}}render(t){if(this.rb.isFinished)return;const e=1e3*yt.MicroBufferSize/this.Cu.outSampleRate,s=Math.ceil(t/e);let i=new Float32Array(yt.MicroBufferSize*s*yt.AudioChannels);const n=this.rb.currentSyncPoints;let r=0,a=this.ab;for(let t=0;t<s;t++){if(n.length>0){this.rb.currentUpdateSyncPoints(a),this.rb.currentUpdateCurrentTempo(this.rb.currentTime);const t=this.rb.syncPointTempo/this.rb.currentTempo;this.rb.playbackSpeed!==t&&(this.rb.playbackSpeed=t)}if(this.rb.fillMidiEventQueue(),this.Cu.synthesize(i,r,yt.MicroBufferSize),r+=yt.MicroBufferSize*yt.AudioChannels,a+=e,this.rb.isFinished)break}r<i.length&&(i=i.subarray(0,r));const h=new sr;return h.currentTime=this.ab,h.endTime=this.hb,h.currentTick=this.rb.currentTimePositionToTickPosition(this.rb.currentTime),h.endTick=this.rb.currentEndTick,this.ab+=t,h.samples=i,this.rb.isFinished&&this.Cu.noteOffAll(!0),h}},ga=class{Dp=new tr;masterVolume=1;metronomeVolume=0;outSampleRate=44100;currentTempo=120;timeSignatureNumerator=4;timeSignatureDenominator=4;activeVoiceCount=0;output;noteOffAll(t){}resetSoft(){}resetPresets(){}loadPresets(t,e,s,i){}setupMetronomeChannel(t,e){}synthesizeSilent(t){this.fakeSynthesize()}ob(t){}dispatchEvent(t){this.Dp.enqueue(t)}synthesize(t,e,s){return this.fakeSynthesize()}fakeSynthesize(){const t=[];for(;!this.Dp.isEmpty;){const e=this.Dp.dequeue();e.isMetronome&&this.metronomeVolume>0||e.event&&this.ob(e.event),t.push(e)}return t}applyTranspositionPitches(t){}setChannelTranspositionPitch(t,e){}channelSetMute(t,e){}channelSetSolo(t,e){}resetChannelStates(){}channelSetMixVolume(t,e){}hasSamplesForProgram(t){return!0}hasSamplesForPercussion(t){return!0}},wa=class extends pa{cb;constructor(t,e){super(t,new ga,e),this.synthesizer.output=t,this.cb=t,t.timeUpdate.on(e=>{const s=this.sequencer.mainTimePositionFromBackingTrack(e,t.backingTrackDuration);this.sequencer.fillMidiEventQueueToEndTime(s),this.synthesizer.fakeSynthesize(),this.updateTimePosition(s,!1),this.checkForFinish()})}updateMasterVolume(t){super.updateMasterVolume(t),this.cb.masterVolume=t}updatePlaybackSpeed(t){super.updatePlaybackSpeed(t),this.cb.playbackRate=t}onSampleRequest(){}loadMidiFile(t){this.isSoundFontLoaded||(this.isSoundFontLoaded=!0,this.soundFontLoaded.trigger()),super.loadMidiFile(t)}updateTimePosition(t,e){super.updateTimePosition(t,e),e&&this.cb.seekTo(this.sequencer.mainTimePositionToBackingTrack(t,this.cb.backingTrackDuration))}loadBackingTrack(t){const e=t.backingTrack;e&&(this.cb.loadBackingTrack(e),this.timePosition=0)}updateSyncPoints(t){this.sequencer.mainUpdateSyncPoints(t),this.tickPosition=this.tickPosition}},ya=class t{static lb=1;Ku;ub;fb;pb;bb=null;constructor(e,s){this.fb=t.lb++,this.Ku=e,this.pb=s}async initialize(t,e,s,i){const n=t=>this.handleWorkerMessage(t);this.Ku.worker.addEventListener("message",n),this.ub=()=>{this.Ku.worker.removeEventListener("message",n)},this.bb=Promise.withResolvers(),this.Ku.worker.postMessage({cmd:"alphaSynth.exporter.initialize",exporterId:this.fb,options:Bu.prepareForPostMessage(t),midi:Wn.midiFileToJsObject(Bu.prepareForPostMessage(e)),syncPoints:Bu.prepareForPostMessage(s),transpositionPitches:Bu.prepareForPostMessage(i)}),await this.bb.promise}handleWorkerMessage(t){const e=t.data;switch(e.cmd){case"alphaSynth.exporter.initialized":if(e.exporterId!==this.fb)return;this.bb?.resolve(null),this.bb=null;break;case"alphaSynth.exporter.error":if(e.exporterId!==this.fb)return;this.bb?.reject(e.error),this.bb=null;break;case"alphaSynth.exporter.rendered":if(e.exporterId!==this.fb)return;this.bb?.resolve(e.chunk),this.bb=null;break;case"alphaSynth.destroyed":this.bb?.reject(new a(r.General,"Worker was destroyed")),this.bb=null}}async render(t){if(this.bb)throw new a(r.General,"There is already an ongoing operation, wait for initialize to complete before requesting render");return this.bb=Promise.withResolvers(),this.Ku.worker.postMessage({cmd:"alphaSynth.exporter.render",exporterId:this.fb,milliseconds:t}),await this.bb.promise}destroy(){this.Ku.worker.postMessage({cmd:"alphaSynth.exporter.destroy",exporterId:this.fb}),this.ub(),this.pb&&this.Ku.destroy()}[Symbol.dispose](){this.destroy()}},ka=class{id=Bt.newGuid();reuseViewport=!0;x=0;y=0;width=0;height=0;totalWidth=0;totalHeight=0;firstMasterBarIndex=-1;lastMasterBarIndex=-1;renderResult=null},Sa=class{mb=Xs.Page;gb=null;wb=null;canvas=null;score=null;tracks=null;layout=null;settings;boundsLookup=null;width=0;constructor(t){this.settings=t,this.yb(),this.kb()}destroy(){this.score=null,this.canvas?.destroy(),this.canvas=null,this.layout=null,this.boundsLookup=null,this.tracks=null}yb(){return this.gb!==this.settings.core.engine&&(this.canvas?.destroy(),this.canvas=Bu.getRenderEngineFactory(this.settings.core.engine).createCanvas(),this.gb=this.settings.core.engine,!0)}kb(){return(!this.layout||this.mb!==this.settings.display.layoutMode)&&(this.layout=Bu.getLayoutEngineFactory(this.settings.display.layoutMode).createLayout(this),this.mb=this.settings.display.layoutMode,!0)}renderScore(t,e,s){try{this.score=t;let i=null;if(null!=t&&null!=e){if(e){i=[];for(const s of e)s>=0&&s<t.tracks.length&&i.push(t.tracks[s])}else i=t.tracks.slice(0);0===i.length&&t.tracks.length>0&&i.push(t.tracks[0])}this.tracks=i,this.render(s)}catch(t){this.error.trigger(t)}}renderTracks(t){0===t.length?this.score=null:this.score=t[0].score,this.tracks=t,this.render()}updateSettings(t){this.settings=t}renderResult(t){try{const e=this.layout;e?(O.debug("Rendering",`Request render of lazy partial ${t}`),e.renderLazyPartial(t)):O.warning("Rendering",`Request render of lazy partial ${t} ignored, no layout exists`)}catch(t){this.error.trigger(t)}}render(t){if(0!==this.width)if(void 0!==t?.firstChangedMasterBar&&this.boundsLookup?this.boundsLookup.resetForPartialUpdate():this.boundsLookup=new Jn,this.yb(),this.canvas.lineWidth=1,this.canvas.settings=this.settings,this.tracks&&0!==this.tracks.length&&this.score){O.debug("Rendering",`Rendering ${this.tracks.length} tracks`);for(let t=0;t<this.tracks.length;t++){const e=this.tracks[t];O.debug("Rendering",`Track ${t}: ${e.name}`)}this.preRender.trigger(!1),this.kb(),this.Sb(t),O.debug("Rendering","Rendering finished")}else O.debug("Rendering","Clearing rendered tracks because no score or tracks are set"),this.preRender.trigger(!1),this.wb=null,this._b(),this.postRenderFinished.trigger(),O.debug("Rendering","Clearing finished");else O.warning("Rendering","AlphaTab skipped rendering because of width=0 (element invisible)",null)}resizeRender(){this.kb()||this.yb()||this.wb!==this.tracks||!this.tracks?(O.debug("Rendering","Starting full rerendering due to layout or canvas change",null),this.render()):this.layout.supportsResize?(O.debug("Rendering","Starting optimized rerendering for resize"),this.boundsLookup=new Jn,this.preRender.trigger(!0),this.canvas.settings=this.settings,this.layout.resize(),this._b(),this.postRenderFinished.trigger()):O.debug("Rendering","Current layout does not support dynamic resizing, nothing was done",null),O.debug("Rendering","Resize finished")}Sb(t){O.debug("Rendering",`Rendering at scale ${this.settings.display.scale} with layout ${this.layout.name}`,null),this.layout.layoutAndRender(t),this.wb=this.tracks,this._b(),this.postRenderFinished.trigger()}preRender=new Js;renderFinished=new Js;partialRenderFinished=new Js;partialLayoutFinished=new Js;postRenderFinished=new js;error=new Js;_b(){this.boundsLookup?.finish(this.settings.display.scale);const t=new ka;t.totalHeight=this.layout.height,t.totalWidth=this.layout.width,t.renderResult=this.canvas.onRenderFinished(),this.renderFinished.trigger(t)}},Ba=class t{xb=new Map;Yu;Tb=null;Mb=null;Nb=0;Pb=null;Fb;Lb=new Map;Wb=new Map;Rb;rootContainerBecameVisible=new js;canRenderChanged=new js;get resizeThrottle(){return 10}rootContainer;areWorkersSupported;get canRender(){return this.Ob()}Ob(){let t=!1;for(const e of this.xb.values())e.isFontLoaded||(t=!0);return!t&&(O.debug("Font",`All fonts loaded: ${this.xb.size}`),!0)}Ib(t){Oi.generateFontLookup(t),this.Ob()&&this.canRenderChanged.trigger()}constructor(t){if(Bu.webPlatform!==Wi.Browser&&Bu.webPlatform!==Wi.BrowserModule)throw new a(r.General,"Usage of AlphaTabApi is only possible in browser environments. For usage in node use the Low Level APIs");t.classList.add("alphaTab"),this.rootContainer=new Li(t),this.areWorkersSupported="Worker"in window,this.Fb=new IntersectionObserver(this.Hb.bind(this),{threshold:[0,.01,1]}),this.Fb.observe(t)}Hb(t){for(const e of t){const t=e.target;if(t===this.rootContainer.element)e.isIntersecting&&(this.rootContainerBecameVisible.trigger(),this.Fb.unobserve(this.rootContainer.element));else if("layoutResultId"in t&&this.Yu.settings.core.enableLazyLoading){const s=t;e.isIntersecting?s.renderedResultId!==s.layoutResultId?this.Wb.has(s.layoutResultId)?1!==s.resultState&&(s.resultState=1,this.Yu.renderer.renderResult(s.layoutResultId)):t.replaceChildren():3===s.resultState&&(t.replaceChildren(...s.renderedResult),s.resultState=2):2===s.resultState&&(s.resultState=3,s.replaceChildren())}}}createWorkerRenderer(){let e;try{return e=t.createAlphaTabWebWorker(this.Yu.settings),new qn(this.Yu,e)}catch(t){return O.error("Renderer","Failed to create worker for background rendering, fallback to non-worker rendering",t),new Sa(this.Yu.settings)}}initialize(t,e){let s;this.Yu=t,s=e instanceof Fi?e:Wn.jsObjectToSettings(e);const i=this.$b();Ci.fromJson(s,i),s.notation.notationMode===F.SongBook&&s.setSongBookModeSettings(),t.settings=s,this.Vb(s),this.Pb=this.parseTracks(s.core.tracks),this.Tb="";const n=t.container;s.core.tex&&(this.Tb=n.element.textContent,n.element.innerText=""),this.zb(s),s.display.resources.smuflFontFamilyName=this.Rb.familyName,this.Mb=s.core.file}Vb(t){for(const e of t.display.resources.elementFonts.values())this.Ub(e);this.Ub(t.display.resources.graceFont),this.Ub(t.display.resources.tablatureFont),this.Ub(t.display.resources.numberedNotationFont),this.Ub(t.display.resources.numberedNotationGraceFont)}Ub(t){if(!this.xb.has(t.families.join(", "))){const e=new Ii(t.families);this.xb.set(t.families.join(", "),e),e.fontLoaded.on(this.Ib.bind(this)),e.checkForFontAvailability()}}destroy(){const e=this.rootContainer.element;e.innerHTML="";const s=this.Rb,i=s.elements.get(e.ownerDocument);i&&(i.usages--,i.usages<=0&&(i.element.remove(),s.elements.delete(e.ownerDocument))),0===s.elements.size&&t.Xb.delete(s.hash)}createCanvasElement(){const t=document.createElement("div");return t.classList.add("at-surface",`at${this.Rb.fontSuffix}`),t.style.fontSize="0",t.style.overflow="hidden",t.style.lineHeight="0",t.style.position="relative",new Li(t)}setCanvasOverflow(t,e,s){const i=t.element;0===e?(i.style.boxSizing="",i.style.paddingRight="",i.style.paddingBottom=""):s?(i.style.boxSizing="content-box",i.style.paddingBottom=`${e}px`):(i.style.boxSizing="content-box",i.style.paddingRight=`${e}px`)}triggerEvent(t,e,s=null,i){const n=t.element;e=`alphaTab.${e}`;const r=document.createEvent("CustomEvent"),a=i?i.mouseEvent:null;if(r.initCustomEvent(e,!1,!1,s),a&&(r.originalEvent=a),n.dispatchEvent(r),window&&"jQuery"in window){const t=window.jQuery,i=[];i.push(s),a&&i.push(a),t(n).trigger(e,i)}}load(t,e,s){if(t instanceof wt)return e(t),!0;if(t instanceof ArrayBuffer){const s=new Uint8Array(t);return e(Ai.loadScoreFromBytes(s,this.Yu.settings)),!0}return t instanceof Uint8Array?(e(Ai.loadScoreFromBytes(t,this.Yu.settings)),!0):"string"==typeof t&&(Ai.loadScoreAsync(t,e,s,this.Yu.settings),!0)}loadSoundFont(t,e){return!!this.Yu.player&&(t instanceof ArrayBuffer?(this.Yu.player.loadSoundFont(new Uint8Array(t),e),!0):t instanceof Uint8Array?(this.Yu.player.loadSoundFont(t,e),!0):"string"==typeof t&&(this.Yu.loadSoundFontFromUrl(t,e),!0))}initialRender(){this.Yu.renderer.preRender.on(t=>{this.Nb=0,this.Wb.clear(),this.Lb.clear()});const t=()=>{this.Yu.renderer.width=0|this.rootContainer.width,this.Yu.renderer.updateSettings(this.Yu.settings),this.Tb?(this.Yu.tex(this.Tb,this.Pb??void 0),this.Pb=null):this.Mb&&Ai.loadScoreAsync(this.Mb,t=>{this.Yu.renderScore(t,this.Pb??void 0),this.Pb=null},t=>{this.Yu.onError(t)},this.Yu.settings)};this.rootContainer.isVisible?t():this.rootContainerBecameVisible.on(t)}zb(e){const s=this.Yu.container.element.ownerDocument;t.createSharedStyleElement(s);const i=e.core.smuflFontSources??xu.buildDefaultSmuflFontSources(e.core.fontDirectory),n=t.jb(i.values()),r=t.Xb;if(r.has(n)){const t=r.get(n);return t.checker.fontLoaded.on(this.Ib.bind(this)),this.Jb(t,s),void(this.Rb=t)}const a=0===r.size?"":String(r.size),h=`alphaTab${a}`,o=`\n            @font-face {\n                font-display: block;\n                font-family: '${h}';\n                src: ${Array.from(i.entries()).map(e=>`url(${JSON.stringify(e[1])}) format('${t.qb(e[0])}')`).join(",")};\n                font-weight: normal;\n                font-style: normal;\n            }\n            .at-surface.at${a} .at {\n                font-family: '${h}';\n                speak: none;\n                font-style: normal;\n                font-weight: normal;\n                font-variant: normal;\n                text-transform: none;\n                line-height: 1;\n                line-height: 1;\n                -webkit-font-smoothing: antialiased;\n                -moz-osx-font-smoothing: grayscale;\n                font-size: ${e.display.resources.engravingSettings.musicFontSize}px;\n                overflow: visible !important;\n            }`,c=new Ii([h]);c.fontLoaded.on(this.Ib.bind(this)),this.xb.set(h,c),c.checkForFontAvailability();const l={hash:n,familyName:h,elements:new Map,fontSuffix:a,checker:c,cssSource:o};this.Jb(l,s),r.set(n,l),this.Rb=l}Jb(t,e){if(t.elements.has(e))return void t.elements.get(e).usages++;const s=e.createElement("style");s.id=`alphaTabStyle${t.fontSuffix}`,s.innerHTML=t.cssSource,e.getElementsByTagName("head").item(0).appendChild(s),t.elements.set(e,{element:s,usages:1})}static qb(t){switch(t){case _u.EmbeddedOpenType:return"embedded-opentype";case _u.Woff:return"woff";case _u.Woff2:return"woff2";case _u.OpenType:return"opentype";case _u.TrueType:return"truetype";case _u.Svg:return"svg"}}static Xb=new Map;static jb(t,e=0){let s=3735928559^e,i=1103547991^e;for(const e of t)for(let t=0;t<e.length;t++){const n=e.charCodeAt(t);s=Math.imul(s^n,2654435761),i=Math.imul(i^n,1597334677)}return s=Math.imul(s^s>>>16,2246822507),s^=Math.imul(i^i>>>13,3266489909),i=Math.imul(i^i>>>16,2246822507),i^=Math.imul(s^s>>>13,3266489909),4294967296*(2097151&i)+(s>>>0)}static createSharedStyleElement(t){let e=t.getElementById("alphaTabStyle");e||(e=document.createElement("style"),e.id="alphaTabStyleShared",e.innerHTML="\n                .at-surface * {\n                    cursor: default;\n                    vertical-align: top;\n                    overflow: visible;\n                }\n                .at-surface-svg text {\n                    dominant-baseline: alphabetic;\n                    white-space:pre;\n                }",document.getElementsByTagName("head").item(0).appendChild(e))}parseTracks(t){if(!t)return[];const e=[];if("string"==typeof t)try{if("all"===t)return[-1];t=JSON.parse(t)}catch{t=[0]}if("number"==typeof t)e.push(t);else if("length"in t){const s=t.length,i=t;for(let t=0;t<s;t++){const s=i[t];let n=0;n="number"==typeof s?s:"index"in s?s.index:Number.parseInt(s.toString(),10),(n>=0||-1===n)&&e.push(n)}}else"index"in t&&e.push(t.index);return e}$b(){const t=new Map,e=this.Yu.container.element;if(e.dataset)for(const s of Object.keys(e.dataset)){let i=e.dataset[s];try{i=JSON.parse(i)}catch{""===i&&(i=null)}t.set(s,i)}else for(let s=0;s<e.attributes.length;s++){const i=e.attributes.item(s),n=i.nodeName;if(n.startsWith("data-")){const e=n.substr(5).split("-");let s=e[0];for(let t=1;t<e.length;t++)s+=e[t].substr(0,1).toUpperCase()+e[t].substr(1);let r=i.nodeValue;try{r=JSON.parse(r)}catch{""===r&&(r=null)}t.set(s,r)}}return t}beginUpdateRenderResults(t){if(!this.Wb.has(t.id))return;const e=this.Wb.get(t.id),s=t.renderResult;"string"==typeof s?e.innerHTML=s:"nodeType"in s&&e.replaceChildren(s),e.resultState=2,e.renderedResultId=t.id,e.renderedResult=Array.from(e.children)}beginAppendRenderResults(t){const e=this.Yu.canvasElement.element;if(t){let s;this.Nb<e.childElementCount?s=e.childNodes.item(this.Nb):(s=document.createElement("div"),e.appendChild(s)),s.style.zIndex="1",s.style.position="absolute",s.style.left=`${t.x}px`,s.style.top=`${t.y}px`,s.style.width=`${t.width}px`,s.style.height=`${t.height}px`,s.style.display="inline-block",s.layoutResultId=t.id,s.resultState=0,s.renderedResultId=void 0,s.renderedResult=void 0,t.reuseViewport||(s.textContent=""),this.Wb.set(t.id,s);for(let e=t.firstMasterBarIndex;e<=t.lastMasterBarIndex;e++)e>=0&&this.Lb.set(e,s);this.Yu.settings.core.enableLazyLoading&&(this.Fb.unobserve(s),this.Fb.observe(s)),this.Nb++}else for(;e.childElementCount>this.Nb;)this.Yu.settings.core.enableLazyLoading&&this.Fb.unobserve(e.lastChild),e.removeChild(e.lastElementChild)}createWorkerPlayer(){let e=null;const s="ScriptProcessorNode"in window;if(window.isSecureContext&&"AudioWorkletNode"in window&&this.Yu.settings.player.outputMode===mi.WebAudioAudioWorklets){let s;O.debug("Player","Will use webworkers for synthesizing and web audio api with worklets for playback");try{s=t.createAlphaSynthWebWorker(this.Yu.settings)}catch(t){return O.error("Player","Failed to create worker for synthesizing audio",t),null}e=new $n(new xa(this.Yu.settings),this.Yu.settings,s)}else if(s){let s;O.debug("Player","Will use webworkers for synthesizing and web audio api with ScriptProcessor for playback");try{s=t.createAlphaSynthWebWorker(this.Yu.settings)}catch(t){return O.error("Player","Failed to create worker for synthesizing audio",t),null}e=new $n(new Hi,this.Yu.settings,s)}return e?e.ready.on(()=>{this.Yu.settings.player.soundFont&&this.Yu.loadSoundFontFromUrl(this.Yu.settings.player.soundFont,!1)}):O.error("Player","Player requires webworkers and web audio api, browser unsupported",null),e}createWorkerAudioExporter(t){const e=null===t||!(t instanceof $n);return e&&(t=this.createWorkerPlayer()),new ya(t,e)}beginInvoke(t){window.requestAnimationFrame(()=>{t()})}Yb=[];highlightElements(t,e){const s=this.Lb.get(e);if(s){const e=s.getElementsByClassName(t);for(let t=0;t<e.length;t++)e.item(t).classList.add("at-highlight"),this.Yb.push(e.item(t))}}removeHighlights(){const t=this.Yb;if(t){for(const e of t)e.classList.remove("at-highlight");this.Yb=[]}}destroyCursors(){const t=this.Yu.container.element,e=t.querySelector(".at-cursors");t.removeChild(e)}createCursors(){const t=this.Yu.container.element,e=document.createElement("div");e.classList.add("at-cursors");const s=document.createElement("div");s.classList.add("at-selection");const i=this.createScalingElement(),n=this.createScalingElement(),r=i.element;r.classList.add("at-cursor-bar");const a=n.element;return a.classList.add("at-cursor-beat"),t.style.position="relative",t.style.textAlign="left",e.style.position="absolute",e.style.zIndex="1000",e.style.display="inline",e.style.pointerEvents="none",s.style.position="absolute",r.style.position="absolute",r.style.left="0",r.style.top="0",r.style.willChange="transform",i.width=1,i.height=1,i.setBounds(0,0,1,1),a.style.position="absolute",a.style.transition="all 0s linear",a.style.left="0",a.style.top="0",a.style.willChange="transform",n.width=3,n.height=1,n.centerAtPosition=!0,n.setBounds(0,0,1,1),t.insertBefore(e,t.firstChild),e.appendChild(s),e.appendChild(r),e.appendChild(a),new Yn(new Li(e),i,n,new Li(s))}getOffset(t,e){const s=e.element,i=s.getBoundingClientRect();let n=i.top+s.ownerDocument.defaultView.pageYOffset,r=i.left+s.ownerDocument.defaultView.pageXOffset;if(t){const e=t.element,s=e.nodeName.toLowerCase();if("html"!==s&&"body"!==s){const s=this.getOffset(null,t);n=n+e.scrollTop-s.y,r=r+e.scrollLeft-s.x}}const a=new _s;return a.x=r,a.y=n,a.w=i.width,a.h=i.height,a}Kb=null;getScrollContainer(){if(this.Kb)return this.Kb;let t="string"==typeof this.Yu.settings.player.scrollElement?document.querySelector(this.Yu.settings.player.scrollElement):this.Yu.settings.player.scrollElement;const e=t.nodeName.toLowerCase();return"html"!==e&&"body"!==e||(t="scrollingElement"in document?document.scrollingElement:-1!==navigator.userAgent.indexOf("WebKit")?document.body:document.documentElement),this.Kb=new Li(t),this.Kb}createSelectionElement(){return this.createScalingElement()}createScalingElement(){const t=document.createElement("div");t.style.position="absolute";const e=new Kn(t,100,100);return e.width=1,e.height=1,e.setBounds(0,0,1,1),e}scrollToY(t,e,s){this.Qb(t.element,e,s)}scrollToX(t,e,s){this.Zb(t.element,e,s)}stopScrolling(t){const e=this.tm.get(t.element);void 0!==e&&this.sm.delete(e)}get im(){const t=this.Yu.settings.player;return t.nativeBrowserSmoothScroll&&t.scrollMode!==fi.Smooth}nm=0;sm=new Set;tm=new Map;Qb(t,e,s){this.im?t.scrollTo({top:e,behavior:"smooth"}):this.rm(t,t.scrollTop,e,s,e=>{t.scrollTop=e})}rm(t,e,s,i,n){const r=this.tm.get(t);if(void 0!==r&&this.sm.delete(r),0===i)return void n(s);const a=this.nm++;this.tm.set(t,a),this.sm.add(a);const h=s-e;let o=0;const c=t=>{if(!this.sm.has(a))return;0===o&&(o=t);const s=t-o;n(e+h*Math.min(s/i,1)|0),s<i?window.requestAnimationFrame(c):this.sm.delete(a)};window.requestAnimationFrame(c)}Zb(t,e,s){this.im?t.scrollTo({left:e,behavior:"smooth"}):this.rm(t,t.scrollLeft,e,s,e=>{t.scrollLeft=e})}createBackingTrackPlayer(){return new wa(new Qn,this.Yu.settings.player.bufferTimeInMilliseconds)}throttle(t,e){let s=0;return()=>{Bu.globalThis.clearTimeout(s),s=Bu.globalThis.setTimeout(t,e)}}static createAlphaTabWebWorker;static createAlphaSynthWebWorker;static createAlphaSynthAudioWorklet},_a=class t{static am=!1;static init(){t.am||(t.am=!0,registerProcessor("alphatab",class t extends AudioWorkletProcessor{static BufferSize=4096;Tu=new Float32Array(0);ku;Su=0;Bu=0;hm=!1;constructor(e){super(e),O.debug("WebAudio","creating processor"),this.Su=Math.floor(e.processorOptions.bufferTimeInMilliseconds*sampleRate/1e3/t.BufferSize),this.ku=new Gi(t.BufferSize*this.Su),this.port.addEventListener("message",t=>this.om(t)),this.port.start()}om(t){const e=t.data;switch(e.cmd){case"alphaSynth.output.addSamples":const t=e.samples;this.ku.write(t,0,t.length),this.Bu--;break;case"alphaSynth.output.resetSamples":this.ku.clear();break;case"alphaSynth.output.stop":this.hm=!0}}process(t,e,s){if(1!==e.length&&2!==e[0].length)return!1;const i=e[0][0],n=e[0][1];if(!i||!n)return!0;const r=i.length+n.length;let a=this.Tu;a.length!==r&&(a=new Float32Array(r),this.Tu=a);const h=this.ku.read(a,0,Math.min(a.length,this.ku.count));let o=0;const c=Math.min(i.length,h);for(let t=0;t<c;t++)i[t]=a[o++],n[t]=a[o++];if(h<i.length)for(let t=h;t<i.length;t++)i[t]=0,n[t]=0;return this.port.postMessage({cmd:"alphaSynth.output.samplesPlayed",samples:h/yt.AudioChannels}),this.xu(),this.ku.count>0||!this.hm}xu(){const e=this.Su/2|0,s=e*t.BufferSize;if(this.ku.count+this.Bu*t.BufferSize<s){for(let t=0;t<e;t++)this.port.postMessage({cmd:"alphaSynth.output.sampleRequest"});this.Bu+=e}}}))}},xa=class extends Ks{lm=null;um=0;dm;fm;pm;constructor(t){super(),this.dm=t,this.fm=t=>this.om(t)}open(t){super.open(t),this.um=t,this.onReady()}play(){super.play();const t=this.context;this.pm&&(this.pm=void 0),Ba.createAlphaSynthAudioWorklet(t,this.dm).then(()=>{this.lm=new AudioWorkletNode(t,"alphatab",{numberOfOutputs:1,outputChannelCount:[2],processorOptions:{bufferTimeInMilliseconds:this.um}}),this.lm.port.addEventListener("message",this.fm),this.lm.port.start(),this.source.connect(this.lm),this.source.start(0),this.lm.connect(t.destination);const e=this.pm;if(e){for(const t of e)this.lm.port.postMessage(t);this.pm=void 0}},t=>{O.error("WebAudio",`Audio Worklet creation failed: reason=${t}`)})}om(t){const e=t.data;switch(e.cmd){case"alphaSynth.output.samplesPlayed":this.onSamplesPlayed(e.samples);break;case"alphaSynth.output.sampleRequest":this.onSampleRequest()}}pause(){super.pause(),this.lm&&(this.lm.port.postMessage({cmd:"alphaSynth.output.stop"}),this.lm.port.removeEventListener("message",this.fm),this.lm.disconnect()),this.lm=null,this.pm=void 0}bm(t){const e=this.lm;e?e.port.postMessage(t):(this.pm??=[],this.pm.push(t))}addSamples(t){this.bm({cmd:"alphaSynth.output.addSamples",samples:Bu.prepareForPostMessage(t)})}resetSamples(){this.bm({cmd:"alphaSynth.output.resetSamples"})}},Ta=class{gm;wm;ym=null;km;Sm=new Se(0,0,0,255);Bm=new hi("Arial",10,ri.Plain);_m;xm=0;settings;constructor(){this.gm=document.createElement("canvas"),this.gm.width=10,this.gm.height=10,this.gm.style.width="10px",this.gm.style.height="10px",this.wm=this.gm.getContext("2d"),this.wm.textBaseline="hanging"}destroy(){}onRenderFinished(){return null}beginRender(t,e){this._m=new hi(this.settings.display.resources.smuflFontFamilyName,this.settings.display.resources.engravingSettings.musicFontSize,ri.Plain,ai.Regular);const s=this.settings.display.scale;this.ym=document.createElement("canvas"),this.ym.width=t*Bu.highDpiFactor|0,this.ym.height=e*Bu.highDpiFactor|0,this.ym.style.width=`${t}px`,this.ym.style.height=`${e}px`,this.km=this.ym.getContext("2d"),this.km.textBaseline="hanging",this.km.scale(Bu.highDpiFactor*s,Bu.highDpiFactor*s),this.km.lineWidth=this.xm}endRender(){const t=this.ym;return this.ym=null,t}get color(){return this.Sm}set color(t){this.Sm.rgba!==t.rgba&&(this.Sm=t,this.km.strokeStyle=t.rgba,this.km.fillStyle=t.rgba)}get lineWidth(){return this.xm}set lineWidth(t){this.xm=t,this.km&&(this.km.lineWidth=t)}fillRect(t,e,s,i){s>0&&this.km.fillRect(t,e,s,i)}strokeRect(t,e,s,i){const n=this.lineWidth%2==0?0:.5;this.km.strokeRect(t+n,e+n,s,i)}beginPath(){this.km.beginPath()}closePath(){this.km.closePath()}moveTo(t,e){this.km.moveTo(t,e)}lineTo(t,e){this.km.lineTo(t,e)}quadraticCurveTo(t,e,s,i){this.km.quadraticCurveTo(t,e,s,i)}bezierCurveTo(t,e,s,i,n,r){this.km.bezierCurveTo(t,e,s,i,n,r)}fillCircle(t,e,s){this.km.beginPath(),this.km.arc(t,e,s,0,2*Math.PI,!0),this.fill()}strokeCircle(t,e,s){this.km.beginPath(),this.km.arc(t,e,s,0,2*Math.PI,!0),this.stroke()}fill(){this.km.fill(),this.km.beginPath()}stroke(){this.km.stroke(),this.km.beginPath()}get font(){return this.Bm}set font(t){this.Bm=t,this.km&&(this.km.font=t.toCssString(1)),this.wm.font=t.toCssString(1)}get textAlign(){switch(this.km.textAlign){case"left":default:return ut.Left;case"center":return ut.Center;case"right":return ut.Right}}set textAlign(t){switch(t){case ut.Left:this.km.textAlign="left";break;case ut.Center:this.km.textAlign="center";break;case ut.Right:this.km.textAlign="right"}}get textBaseline(){switch(this.km.textBaseline){case"hanging":default:return dt.Top;case"middle":return dt.Middle;case"bottom":return dt.Bottom;case"alphabetic":return dt.Alphabetic}}set textBaseline(t){switch(t){case dt.Top:this.km.textBaseline="hanging";break;case dt.Middle:this.km.textBaseline="middle";break;case dt.Bottom:this.km.textBaseline="bottom";break;case dt.Alphabetic:this.km.textBaseline="alphabetic"}}beginGroup(t){}endGroup(){}fillText(t,e,s){this.km.fillText(t,e,s)}measureText(t){const e=this.wm.measureText(t);return new ft(e.width,e.actualBoundingBoxDescent+e.actualBoundingBoxAscent)}fillMusicFontSymbol(t,e,s,i,n=!1){i!==xt.None&&this.Tm(t,e,s,String.fromCharCode(i),n)}fillMusicFontSymbols(t,e,s,i,n=!1){let r="";for(const t of i)t!==xt.None&&(r+=String.fromCharCode(t));this.Tm(t,e,s,r,n)}Tm(t,e,s,i,n){const r=this.km.textAlign,a=this.km.textBaseline,h=this.km.font;this.km.font=this._m.toCssString(s),this.km.textBaseline="alphabetic",this.km.textAlign=n?"center":"left",this.km.fillText(i,t,e),this.km.textBaseline=a,this.km.font=h,this.km.textAlign=r}beginRotate(t,e,s){this.km.save(),this.km.translate(t,e),this.km.rotate(s*Math.PI/180)}endRotate(){this.km.restore()}},Ma=class t{Mm;vm;tickShift=0;constructor(t,e=!1){this.Mm=t,this.vm=e}addTickShift(t){this.Mm.tickShift=t,this.tickShift=t}addTimeSignature(t,e,s){t+=this.tickShift;let i=0,n=s;for(;n>>=1,n>0;)i++;this.Mm.addEvent(new _n(0,t,e,i,48,8))}addRest(t,e,s){e+=this.tickShift,this.vm||this.Mm.addEvent(new Mn(t,e,s))}addNote(e,s,i,n,r,a){s+=this.tickShift,this.Mm.addEvent(new Nn(e,s,a,t.Nm(n),t.Nm(r))),this.Mm.addEvent(new Pn(e,s+i,a,t.Nm(n),t.Nm(r)))}static Nm(t){return t>127?127:t<0?0:t}addControlChange(e,s,i,n,r){s+=this.tickShift,this.Mm.addEvent(new Cn(e,s,i,n,t.Nm(r)))}addProgramChange(t,e,s,i){e+=this.tickShift,this.Mm.addEvent(new En(t,e,s,i))}addTempo(t,e){t+=this.tickShift;const s=new Fn(t,0);s.beatsPerMinute=e,this.Mm.addEvent(s)}addBend(t,e,s,i){e+=this.tickShift,i=i>=yt.MaxPitchWheel?yt.MaxPitchWheel:Math.floor(i),this.Mm.addEvent(new An(t,e,s,i))}addNoteBend(t,e,s,i,n){e+=this.tickShift,this.vm?this.addBend(t,e,s,n):(n=n*yt.MaxPitchWheel20/yt.MaxPitchWheel,this.Mm.addEvent(new Dn(t,e,s,i,n)))}finishTrack(t,e){e+=this.tickShift,this.Mm.format!==wn.MultiTrack&&0!==t||this.Mm.addEvent(new Ln(t,e))}},va=class{group;opening;iterations;closingIndex=0;constructor(t,e){this.group=t,this.opening=e,t.closings=t.closings.sort((t,e)=>t.index-e.index),this.iterations=t.closings.map(t=>0)}},Na=class{We;Pm=[];Cm=new Set;Em=0;Ni=0;shouldPlay=!0;index=0;currentTick=0;get finished(){return this.index>=this.We.masterBars.length}constructor(t){this.We=t}processCurrent(){const t=this.We.masterBars[this.index];if(0===this.Ni){let e=t.alternateEndings;if(0===e&&(e=this.Em),t===t.repeatGroup.opening&&t.repeatGroup.isClosed&&!this.Cm.has(t.repeatGroup)){const s=new va(t.repeatGroup,t);this.Pm.push(s),this.Cm.add(t.repeatGroup),this.Em=0,e=t.alternateEndings}if(0===this.Pm.length||0===e)this.shouldPlay=!0;else{const t=this.Pm[this.Pm.length-1],s=t.iterations[t.closingIndex];this.Em=e,this.shouldPlay=!!(e&1<<s)}}else this.shouldPlay=!0;this.shouldPlay&&(this.currentTick+=t.calculateDuration())}moveNext(){this.Fm()||this.Am()}Dm(){this.Cm.clear(),this.Em=0,this.Pm=[]}Lm(t,e,s){return!!t.has(e)&&(this.index=0,this.Ni=s,this.Dm(),!0)}Wm(t,e,s,i){if(t.has(e)){const t=this.Rm(i,this.index,!0);return-1!==t&&(this.index=t,this.Ni=s,this.Dm(),!0)}return!1}Om(t,e,s){if(t.has(e)){const t=this.Rm(s,this.index,!1);return-1===t?(this.index++,!0):(this.index=t,this.Ni=0,!0)}return!1}Fm(){const t=this.We.masterBars[this.index],e=null!==t.directions&&t.directions.size>0;if(0===this.Ni&&!e)return!1;if(!e)return this.index++,!0;switch(this.Ni){case 0:return!!(this.Lm(t.directions,ys.JumpDaCapo,1)||this.Lm(t.directions,ys.JumpDaCapoAlCoda,2)||this.Lm(t.directions,ys.JumpDaCapoAlDoubleCoda,3)||this.Lm(t.directions,ys.JumpDaCapoAlFine,4))||(!!(this.Wm(t.directions,ys.JumpDalSegno,1,ys.TargetSegno)||this.Wm(t.directions,ys.JumpDalSegnoAlCoda,2,ys.TargetSegno)||this.Wm(t.directions,ys.JumpDalSegnoAlDoubleCoda,3,ys.TargetSegno)||this.Wm(t.directions,ys.JumpDalSegnoAlFine,4,ys.TargetSegno))||!!(this.Wm(t.directions,ys.JumpDalSegnoSegno,1,ys.TargetSegnoSegno)||this.Wm(t.directions,ys.JumpDalSegnoSegnoAlCoda,2,ys.TargetSegnoSegno)||this.Wm(t.directions,ys.JumpDalSegnoSegnoAlDoubleCoda,3,ys.TargetSegnoSegno)||this.Wm(t.directions,ys.JumpDalSegnoSegnoAlFine,4,ys.TargetSegnoSegno)));case 1:return this.index++,!0;case 2:return this.Om(t.directions,ys.JumpDaCoda,ys.TargetCoda)||this.index++,!0;case 3:return this.Om(t.directions,ys.JumpDaDoubleCoda,ys.TargetDoubleCoda)||this.index++,!0;case 4:return t.directions.has(ys.TargetFine)?(this.index=this.We.masterBars.length,!0):(this.index++,!0)}return!0}Rm(t,e,s){let i;return s?(i=this.Im(t,e),-1===i&&(i=this.Gm(t,e)),i):(i=this.Gm(t,e),-1===i&&(i=this.Im(t,e)),i)}Gm(t,e){let s=e;for(;s<this.We.masterBars.length;){const e=this.We.masterBars[s].directions;if(e&&e.has(t))return s;s++}return-1}Im(t,e){let s=e;for(;s>=0;){const e=this.We.masterBars[s].directions;if(e&&e.has(t))return s;s--}return-1}Am(){const t=this.We.masterBars[this.index].repeatCount-1;if(this.Pm.length>0&&t>0){const e=this.Pm[this.Pm.length-1];if(e.iterations[e.closingIndex]<t){this.index=e.opening.index,e.iterations[e.closingIndex]++;for(let t=0;t<e.closingIndex;t++)e.iterations[t]=0;e.closingIndex=0,this.Em=0}else e.closingIndex<e.group.closings.length-1?(e.closingIndex++,this.index++):(this.Pm.pop(),this.Cm.delete(e.group),this.index++)}else this.index++}},Pa=class{beat;playbackStart;constructor(t,e){this.beat=t,this.playbackStart=e}},Ca=class{Hm=new Map;start;end;highlightedBeats=[];nextBeat=null;previousBeat=null;get duration(){return this.end-this.start}constructor(t,e){this.start=t,this.end=e}highlightBeat(t,e){this.Hm.has(t.id)||(this.Hm.set(t.id,!0),this.highlightedBeats.push(new Pa(t,e)))}getVisibleBeatAtStart(t){for(const e of this.highlightedBeats)if(e.playbackStart===this.start&&t.has(e.beat.voice.bar.staff.track.index))return e.beat;return null}getVisibleBeatAtStartWithChecker(t){for(const e of this.highlightedBeats)if(e.playbackStart===this.start&&t.isVisible(e.beat))return e.beat;return null}},Ea=class{tick;tempo;constructor(t,e){this.tick=t,this.tempo=e}},Fa=class{start=0;end=0;get tempo(){return this.tempoChanges[0].tempo}tempoChanges=[];masterBar;firstBeat=null;lastBeat=null;$m(t,e){null==this.firstBeat||null==t||null==this.lastBeat?(this.firstBeat=e,this.lastBeat=e):(e.nextBeat=t.nextBeat,e.previousBeat=t,t.nextBeat&&(t.nextBeat.previousBeat=e),t.nextBeat=e,t===this.lastBeat&&(this.lastBeat=e))}Vm(t,e){null==this.firstBeat||null==t||null==this.lastBeat?(this.firstBeat=e,this.lastBeat=e):(e.previousBeat=t.previousBeat,e.nextBeat=t,t.previousBeat&&(t.previousBeat.nextBeat=e),t.previousBeat=e,t===this.firstBeat&&(this.firstBeat=e))}nextMasterBar=null;previousMasterBar=null;addBeat(t,e,s,i){const n=s+i;if(null==this.firstBeat){const i=new Ca(s,n);i.highlightBeat(t,e),this.$m(this.firstBeat,i)}else if(s>=this.lastBeat.end){const s=new Ca(this.lastBeat.end,n);s.highlightBeat(t,e),this.$m(this.lastBeat,s)}else{let i=null;if(s<this.firstBeat.start)i=this.firstBeat;else{let t=this.firstBeat;for(;null!=t;){if(s>=t.start&&s<t.end){i=t;break}t=t.nextBeat}if(null===i)throw new a(r.General,"Error on building lookup, unknown variant")}if(s<i.start)if(n===i.start){const n=new Ca(s,i.start);n.highlightBeat(t,e),this.Vm(this.firstBeat,n)}else if(n<i.end){const r=new Ca(s,i.start);r.highlightBeat(t,e),this.Vm(i,r);const a=new Ca(i.start,n);for(const t of i.highlightedBeats)a.highlightBeat(t.beat,t.playbackStart);a.highlightBeat(t,e),this.Vm(i,a),i.start=n}else if(n===i.end){const n=new Ca(s,i.start);n.highlightBeat(t,e),i.highlightBeat(t,e),this.Vm(i,n)}else{const r=new Ca(s,i.start);r.highlightBeat(t,e),i.highlightBeat(t,e),this.Vm(i,r),this.addBeat(t,e,i.end,n-i.end)}else if(s>i.start)if(n===i.end){const n=new Ca(i.start,s);for(const t of i.highlightedBeats)n.highlightBeat(t.beat,t.playbackStart);i.start=s,i.highlightBeat(t,e),this.Vm(i,n)}else if(n<i.end){const r=new Ca(i.start,s);this.Vm(i,r);const a=new Ca(s,n);this.Vm(i,a);for(const t of i.highlightedBeats)r.highlightBeat(t.beat,t.playbackStart),a.highlightBeat(t.beat,t.playbackStart);a.highlightBeat(t,e),i.start=n}else{const r=new Ca(i.start,s);for(const t of i.highlightedBeats)r.highlightBeat(t.beat,t.playbackStart);i.start=s,i.highlightBeat(t,e),this.Vm(i,r),this.addBeat(t,e,i.end,n-i.end)}else if(n===i.end)i.highlightBeat(t,e);else if(n<i.end){const s=new Ca(i.start,n);for(const t of i.highlightedBeats)s.highlightBeat(t.beat,t.playbackStart);s.highlightBeat(t,e),i.start=n,this.Vm(i,s)}else i.highlightBeat(t,e),this.addBeat(t,e,i.end,n-i.end)}}},Aa=class{startTick=0;endTick=0},Da=function(t){return t[t.Unknown=0]="Unknown",t[t.ToNextBext=1]="ToNextBext",t[t.ToEndOfBar=2]="ToEndOfBar",t[t.ToEndOfBeat=3]="ToEndOfBeat",t}({}),La=class{beat;masterBar;beatLookup;nextBeat=null;tickDuration=0;duration=0;cursorMode=0;get start(){return this.masterBar.start+this.beatLookup.start}get end(){return this.start+this.tickDuration}constructor(t){this.masterBar=t}calculateDuration(){if(1===this.masterBar.tempoChanges.length)this.duration=c.ticksToMillis(this.tickDuration,this.masterBar.tempoChanges[0].tempo);else{let t=0,e=this.start,s=this.masterBar.tempoChanges[0].tempo;const i=this.end;for(const n of this.masterBar.tempoChanges)if(n.tick<e)s=n.tempo;else{if(n.tick>i)break;t+=c.ticksToMillis(n.tick-e,s),s=n.tempo,e=n.tick}i>e&&(t+=c.ticksToMillis(i-e,s)),this.duration=t}}},Wa=class{zm;constructor(t){this.zm=t}isVisible(t){return this.zm.has(t.voice.bar.staff.track.index)}},Ra=class{Um=null;masterBarLookup=new Map;beatLookup=new Map;masterBars=[];multiBarRestInfo=null;playbackRange=null;findBeat(t,e,s=null){return this.findBeatWithChecker(new Wa(t),e,s)}findBeatWithChecker(t,e,s=null){let i=null;if(s&&(i=this.Xm(t,s,e)),i||(i=this.jm(t,s,e,!1)),i){const t=this.playbackRange;if(null!==t&&i.start>=t.endTick)return null}return i}Xm(t,e,s){if(s>=e.start&&s<e.end)return e;if(e.nextBeat&&s>=e.nextBeat.start&&s<e.nextBeat.end&&(void 0===t||t.isVisible(e.nextBeat.beat))){const s=e.nextBeat;return this.Jm(s,t),s}return null}qm(t,e){const s=this.multiBarRestInfo.get(t.masterBar.masterBar.index);let i=t.masterBar;for(let t=0;t<s.length&&i;t++)i=i.nextMasterBar;i?i.nextMasterBar?(t.nextBeat=this.Ym(e,i.nextMasterBar,i.nextMasterBar.start,!0),t.nextBeat?(t.tickDuration=t.nextBeat.start-t.start,t.cursorMode=1,(t.nextBeat.masterBar.masterBar.index!==i.masterBar.index+1&&(t.nextBeat.masterBar.masterBar.index!==i.masterBar.index||t.nextBeat.beat.playbackStart<=t.beat.playbackStart)||null!==this.playbackRange&&this.playbackRange.endTick<=t.nextBeat.start)&&(t.cursorMode=3)):(t.tickDuration=i.nextMasterBar.end-t.start,t.cursorMode=3)):(t.tickDuration=i.end-t.start,t.cursorMode=3):(O.warning("Synth","MultiBar Rest Info and the nextMasterBar are out of sync, this is an unexpected error. Please report it as bug.  (broken chain fill-next)"),t.tickDuration=(t.masterBar.end-t.masterBar.start)*(s.length+1),t.cursorMode=3),t.calculateDuration()}Jm(t,e){this.Km(t)?this.qm(t,e):this.Qm(t,e)}Qm(t,e){t.nextBeat=this.Zm(t.masterBar,t.beatLookup.nextBeat,t.end,e,!0),null==t.nextBeat&&(t.nextBeat=this.jm(e,t,t.end,!0)),t.nextBeat?(t.tickDuration=t.nextBeat.start-t.start,t.cursorMode=1,t.calculateDuration()):(t.tickDuration=t.masterBar.end-t.start,t.cursorMode=3,t.calculateDuration()),t.nextBeat&&(t.nextBeat.masterBar.masterBar.index!==t.masterBar.masterBar.index+1&&(t.nextBeat.masterBar.masterBar.index!==t.masterBar.masterBar.index||t.nextBeat.beat.playbackStart<=t.beat.playbackStart)||null!==this.playbackRange&&this.playbackRange.endTick<=t.nextBeat.start)&&(t.cursorMode=3)}Km(t){return this.tg(t.masterBar.masterBar.index,t.beat)}tg(t,e){return this.multiBarRestInfo&&this.multiBarRestInfo.has(t)&&e.isRest&&e.voice.bar.isRestOnly}jm(t,e,s,i){let n=null;return null!=e&&(e.masterBar.start<=s&&e.masterBar.end>s?n=e.masterBar:e.masterBar.nextMasterBar&&e.masterBar.nextMasterBar.start<=s&&e.masterBar.nextMasterBar.end>s&&(n=e.masterBar.nextMasterBar)),n||(n=this.eg(s)),n?this.Ym(t,n,s,i):null}Ym(t,e,s,i){let n=e;for(;n;){if(n.firstBeat){const e=this.Zm(n,n.firstBeat,s,t,i);if(e)return e}n=n.nextMasterBar}return null}Zm(t,e,s,i,n){if(!e)return null;let r=null,a=null;const h=s-t.start;for(;null!=e&&null==a;){if((e.start<=h||n&&h<0)&&h<e.end){if(r=e,a=e.getVisibleBeatAtStartWithChecker(i),!a)if(n){let s=t;for(;null!=s&&null==a;){for(;null!=e;){if(a=e.getVisibleBeatAtStartWithChecker(i),a){r=e,t=s;break}e=e.nextBeat}a&&r||(s=s.nextMasterBar,e=s?.firstBeat??null)}}else{let s=t;for(;null!=s&&null==a;){for(;null!=e;){if(a=e.getVisibleBeatAtStartWithChecker(i),a){r=e,t=s;break}e=e.previousBeat}a&&r||(s=s.previousMasterBar,e=s?.firstBeat??null)}}}else if(e.end>h)break;e=e?.nextBeat??null}return null==a?null:this.sg(t,r,a,n,i)}sg(t,e,s,i,n){const r=new La(t);if(r.beat=s,r.beatLookup=e,r.tickDuration=e.end-e.start,i){if(this.Km(r)){const s=this.multiBarRestInfo.get(t.masterBar.index);let i=t;for(let t=0;t<s.length&&i;t++)i=i.nextMasterBar;i?i.nextMasterBar?r.tickDuration=i.nextMasterBar.start-e.start:r.tickDuration=i.end-e.start:O.warning("Synth","MultiBar Rest Info and the nextMasterBar are out of sync, this is an unexpected error. Please report it as bug.  (broken chain stretch-result)")}}else this.Jm(r,n);return r.calculateDuration(),r}eg(t){if(t<=0&&this.masterBars.length>0)return this.masterBars[0];const e=this.masterBars;let s=0,i=e.length-1;for(;s<=i;){const n=(i+s)/2|0,r=e[n];if(t>=r.start&&t<r.end)return r;t<r.start?i=n-1:s=n+1}return null}getMasterBar(t){if(!this.masterBarLookup.has(t.index)){const e=new Fa;return e.masterBar=t,e}return this.masterBarLookup.get(t.index)}getMasterBarStart(t){return this.masterBarLookup.has(t.index)?this.masterBarLookup.get(t.index).start:0}getBeatStart(t){return this.masterBarLookup.has(t.voice.bar.index)&&this.beatLookup.has(t.id)?this.masterBarLookup.get(t.voice.bar.index).start+this.beatLookup.get(t.id).startTick:0}getRelativeBeatPlaybackRange(t){if(this.beatLookup.has(t.id))return this.beatLookup.get(t.id)}addMasterBar(t){this.masterBars.push(t),this.Um&&(t.previousMasterBar=this.Um,this.Um.nextMasterBar=t),this.Um=t,this.masterBarLookup.has(t.masterBar.index)||this.masterBarLookup.set(t.masterBar.index,t)}addBeat(t,e,s){if(!this.beatLookup.has(t.id)){const i=new Aa;i.startTick=e,i.endTick=e+s,this.beatLookup.set(t.id,i)}const i=this.Um;if(i)if(e<0&&i.previousMasterBar){const n=i.previousMasterBar.end-i.previousMasterBar.start,r=n+e,a=r+s;if(i.previousMasterBar.addBeat(t,r,r,s),a>n){const n=s+e;i.addBeat(t,e,0,n)}}else i.addBeat(t,e,e,s)}},Oa=class{noteOnly=0;untilTieOrSlideEnd=0;letRingEnd=0;beatDurationFactor=1},Ia=class{firstBeatDuration=0;secondBeatStartOffset=0;secondBeatDuration=0},Ga=class{durations=[];brushInfos=[]},Ha=class{synthTick=0;synthTime=0;currentTempo=0;automationToSyncPoint=new Map;syncPoints;createNewSyncPoints=!1},$a=class t{static ig=30;static ng=80;We;dm;Ti;rg=new Map;ag=0;hg=new Set;tickLookup=new Ra;applyTranspositionPitches=!0;syncPoints=[];transpositionPitches=new Map;constructor(t,e,s){this.We=t,this.dm=e||new Fi,this.Ti=s}generate(){this.transpositionPitches.clear(),this.hg.clear(),this.ag=0;for(const t of this.We.tracks)this.og(t);O.debug("Midi","Begin midi generation"),this.syncPoints=[],t.cg(this.We,this.syncPoints,!1,(t,e,s,i,n)=>{this.lg(t,e,s,i,n),0===t.index&&0===n&&this.ug()},(t,e,s)=>{for(const i of this.We.tracks)for(const n of i.staves)t<n.bars.length&&this.dg(n.bars[t],e,s)},t=>{for(const e of this.We.tracks)this.Ti.finishTrack(e.index,t)}),O.debug("Midi","Midi generation done")}ug(){let t=0;for(const e of this.We.tracks)for(const s of e.staves)for(const e of s.bars[0].voices)if(!e.isEmpty){const s=e.beats[0];s.playbackStart<t&&(t=s.playbackStart)}t=Math.abs(t),this.Ti.addTickShift(t)}og(t){this.fg(t,t.playbackInfo.primaryChannel,t.playbackInfo),t.playbackInfo.primaryChannel!==t.playbackInfo.secondaryChannel&&this.fg(t,t.playbackInfo.secondaryChannel,t.playbackInfo)}pg(t,e,s,i){this.rg.has(s)&&this.rg.get(s)===i||(this.Ti.addProgramChange(t.index,e,s,i),this.rg.set(s,i))}bg(t,e,s,i){const n=we.bankToLsbMsb(i);this.Ti.addControlChange(t.index,e,s,da.BankSelectCoarse,n[1]),this.Ti.addControlChange(t.index,e,s,da.BankSelectFine,n[0])}static buildTranspositionPitches(t,e){const s=new Map;for(const i of t.tracks){const t=i.index<e.notation.transpositionPitches.length?e.notation.transpositionPitches[i.index]:-i.staves[0].transpositionPitch;s.set(i.playbackInfo.primaryChannel,t),s.set(i.playbackInfo.secondaryChannel,t)}return s}fg(e,s,i){const n=e.index<this.dm.notation.transpositionPitches.length?this.dm.notation.transpositionPitches[e.index]:-e.staves[0].transpositionPitch;this.transpositionPitches.set(s,n);const r=t.mg(i.volume),a=t.mg(i.balance);this.Ti.addControlChange(e.index,0,s,da.VolumeCoarse,r),this.Ti.addControlChange(e.index,0,s,da.PanCoarse,a),this.Ti.addControlChange(e.index,0,s,da.ExpressionControllerCoarse,127),this.Ti.addControlChange(e.index,0,s,da.RegisteredParameterFine,0),this.Ti.addControlChange(e.index,0,s,da.RegisteredParameterCourse,0),this.Ti.addControlChange(e.index,0,s,da.DataEntryFine,0),this.Ti.addControlChange(e.index,0,s,da.DataEntryCoarse,t.gg),this.bg(e,0,s,i.bank),this.pg(e,0,s,i.program)}static generateSyncPoints(e,s=!1){const i=[];return t.cg(e,i,s,(t,e,s,i,n)=>{},(t,e,s)=>{},t=>{}),i}static buildModifiedTempoLookup(e){return t.cg(e,[],!1,(t,e,s,i,n)=>{},(t,e,s)=>{},t=>{}).automationToSyncPoint}static cg(e,s,i,n,r,a){const h=new Na(e),o=new Ha;o.currentTempo=e.tempo,o.syncPoints=s,o.createNewSyncPoints=i;let l=null;const u=new Map;for(;!h.finished;){const s=h.index,i=e.masterBars[s],a=h.currentTick;if(h.processCurrent(),h.shouldPlay){let e=u.has(s)?u.get(s):-1;e++,u.set(s,e),n(i,l,a,o.currentTempo,e),r(s,a,i.tempoAutomations.length>0?i.tempoAutomations[0].value:o.currentTempo),o.synthTick=a,t.wg(i,e,o)}h.moveNext(),l=i}if(s.length>0){const t=s[s.length-1],e=h.currentTick-t.synthTick;if(e>0){const i=new nr;i.masterBarIndex=l.index,i.masterBarOccurence=u.get(l.index)-1,i.synthTick=h.currentTick,i.synthBpm=o.currentTempo,o.createNewSyncPoints?(i.syncBpm=t.synthBpm,i.synthBpm=t.synthBpm):1===s.length?i.syncBpm=t.synthBpm:i.syncBpm=s[s.length-2].syncBpm,i.synthTime=t.synthTime+c.ticksToMillis(e,t.synthBpm),i.syncTime=t.syncTime+c.ticksToMillis(e,i.syncBpm),o.createNewSyncPoints||t.updateSyncBpm(i.synthTime,i.syncTime),s.push(i)}}return a(h.currentTick),o}static wg(e,s,i){const n=e.calculateDuration(),r=e.syncPoints,a=i.synthTick;i.createNewSyncPoints?t.yg(e,s,i):r?t.kg(e,s,i):t.Sg(e,i);const h=a+n,o=h-i.synthTick;o>0&&(i.synthTime+=c.ticksToMillis(o,i.currentTempo),i.synthTick=h)}static yg(t,e,s){const i=s.synthTick;if(0===t.index&&0===e){s.currentTempo=t.score.tempo;const n=new nr;n.masterBarIndex=t.index,n.masterBarOccurence=e,n.synthTick=i,n.synthBpm=s.currentTempo,n.synthTime=s.synthTime,n.syncBpm=s.currentTempo,n.syncTime=s.synthTime,s.syncPoints.push(n)}const n=t.calculateDuration();for(const r of t.tempoAutomations){const a=i+r.ratioPosition*n,h=a-s.synthTick;if(h>0&&(s.synthTick=a,s.synthTime+=c.ticksToMillis(h,s.currentTempo)),r.value!==s.currentTempo){s.currentTempo=r.value;const i=new nr;i.masterBarIndex=t.index,i.masterBarOccurence=e,i.synthTick=a,i.synthBpm=s.currentTempo,i.synthTime=s.synthTime,i.syncBpm=s.currentTempo,i.syncTime=s.synthTime,s.syncPoints.push(i)}}}static kg(t,e,s){const i=s.synthTick,n=t.calculateDuration();let r,a=0;for(const h of t.syncPoints){if(h.syncPointValue.barOccurence!==e)continue;const o=i+h.ratioPosition*n;for(;a<t.tempoAutomations.length&&t.tempoAutomations[a].ratioPosition<=h.ratioPosition;){const e=t.tempoAutomations[a],h=i+e.ratioPosition*n;r=h-s.synthTick,r>0&&(s.synthTick=h,s.synthTime+=c.ticksToMillis(r,s.currentTempo)),s.currentTempo=e.value,a++}r=o-s.synthTick,r>0&&(s.synthTick=o,s.synthTime+=c.ticksToMillis(r,s.currentTempo)),s.syncPoints.length>0&&s.syncPoints[s.syncPoints.length-1].updateSyncBpm(s.synthTime,h.syncPointValue.millisecondOffset);const l=new nr;l.masterBarIndex=t.index,l.masterBarOccurence=e,l.synthTick=o,l.synthBpm=s.currentTempo,l.synthTime=s.synthTime,l.syncTime=h.syncPointValue.millisecondOffset,l.syncBpm=0,s.syncPoints.push(l),s.automationToSyncPoint.set(h,l)}for(;a<t.tempoAutomations.length;){const e=t.tempoAutomations[a],h=i+e.ratioPosition*n;r=h-s.synthTick,r>0&&(s.synthTick=h,s.synthTime+=c.ticksToMillis(r,s.currentTempo)),s.currentTempo=e.value,a++}}static Sg(t,e){const s=e.synthTick,i=t.calculateDuration();for(const n of t.tempoAutomations){const t=s+n.ratioPosition*i,r=t-e.synthTick;r>0&&(e.synthTick=t,e.synthTime+=c.ticksToMillis(r,e.currentTempo)),e.currentTempo=n.value}}static mg(t){const e=Math.max(-32768,Math.min(32767,8*t-1));return Math.max(e,-1)+1}lg(t,e,s,i,n){e&&e.timeSignatureDenominator===t.timeSignatureDenominator&&e.timeSignatureNumerator===t.timeSignatureNumerator||this.Ti.addTimeSignature(s,t.timeSignatureNumerator,t.timeSignatureDenominator);const r=t.calculateDuration(),a=new Fa;if(t.tempoAutomations.length>0){t.tempoAutomations[0].ratioPosition>0&&a.tempoChanges.push(new Ea(s,i));for(const e of t.tempoAutomations){const t=s+r*e.ratioPosition;this.Ti.addTempo(t,e.value),a.tempoChanges.push(new Ea(t,e.value))}}else e?a.tempoChanges.push(new Ea(s,i)):(this.Ti.addTempo(s,t.score.tempo),a.tempoChanges.push(new Ea(s,t.score.tempo)));a.masterBar=t,a.start=s,a.end=a.start+r,this.tickLookup.addMasterBar(a)}dg(t,e,s){const i=this.Bg(t),n=this.ag;for(const r of i.voices)this.ag=n,this._g(r,e,t,s);const r=i.masterBar,a=r.calculateDuration(),h=r.tempoAutomations.slice();if(0===h.length)this.ag=n+c.ticksToMillis(a,s);else{this.ag=n;let t=e,i=s;const r=e+a;for(const e of h){const s=a*e.ratioPosition-t;s>0&&(this.ag+=c.ticksToMillis(s,i)),i=e.value,t+=s}const o=r-t;o>0&&(this.ag+=c.ticksToMillis(o,i))}i.id!==t.id&&this.tickLookup.addBeat(t.voices[0].beats[0],0,a)}Bg(t){switch(t.simileMark){case H.Simple:t.previousBar&&(t=this.Bg(t.previousBar));break;case H.FirstOfDouble:case H.SecondOfDouble:t.previousBar&&t.previousBar.previousBar&&(t=this.Bg(t.previousBar.previousBar))}return t}_g(t,e,s,i){if(t.isEmpty&&(!t.bar.isEmpty||0!==t.index))return;const n=s.masterBar.tempoAutomations.slice();let r=i;const a=s.masterBar.calculateDuration();for(const i of t.beats){const t=i.playbackStart/a;for(;n.length>0&&n[0].ratioPosition<=t;)r=n.shift().value;this.xg(i,e,s,r)}}Tg=null;xg(e,s,i,n){let r=e.playbackStart,a=e.playbackDuration;const h=e.voice.bar.masterBar.calculateDuration();e.voice.bar.isEmpty&&1===e.voice.beats.length?a=h:e.voice.bar.masterBar.tripletFeel!==K.NoTripletFeel&&this.dm.player.playTripletFeel&&(this.Tg?(r-=this.Tg.secondBeatStartOffset,a=this.Tg.secondBeatDuration,this.Tg=null):(this.Tg=t.Mg(r,a,e),this.Tg&&(a=this.Tg.firstBeatDuration))),e.showTimer&&!this.hg.has(e.id)&&(e.timer=this.ag,this.hg.add(e.id)),this.ag+=c.ticksToMillis(a,n),i===e.voice.bar&&this.tickLookup.addBeat(e,r,a);const o=e.voice.bar.staff.track;for(const t of e.automations)this.vg(e,t,s);if(e.isRest)this.Ti.addRest(o.index,s+r,o.playbackInfo.primaryChannel);else if(e.deadSlapped)this.Ng(e,s+r);else{const t=this.Pg(e),i=this.Cg(e,a);for(const h of e.notes)this.Eg(h,s+r,a,n,t,i)}if(e.fade!==Rt.None&&this.Fg(e,s+r,a),e.vibrato!==P.None){let t=240,i=3;switch(e.vibrato){case P.Slight:t=this.dm.player.vibrato.beatSlightLength,i=this.dm.player.vibrato.beatSlightAmplitude;break;case P.Wide:t=this.dm.player.vibrato.beatWideLength,i=this.dm.player.vibrato.beatWideAmplitude}this.Ag(s+r,e.playbackDuration,t,0,i,(t,s)=>{this.Ti.addBend(e.voice.bar.staff.track.index,t,o.playbackInfo.secondaryChannel,s)})}}static Mg(t,e,s){let i;switch(s.voice.bar.masterBar.tripletFeel){case K.Triplet8th:case K.Dotted8th:case K.Scottish8th:i=w.Eighth;break;case K.Triplet16th:case K.Dotted16th:case K.Scottish16th:i=w.Sixteenth;break;default:return null}const n=c.toTicks(i);if(e!==n)return null;if(t%(2*n)!=0)return null;if(!s.nextBeat||s.nextBeat.voice!==s.voice||s.nextBeat.playbackDuration!==n||s.nextBeat.playbackStart!==t+n)return null;const r=new Ia;switch(s.voice.bar.masterBar.tripletFeel){case K.Triplet8th:r.firstBeatDuration=c.applyTuplet(c.toTicks(w.Quarter),3,2),r.secondBeatDuration=c.applyTuplet(c.toTicks(w.Eighth),3,2);break;case K.Dotted8th:r.firstBeatDuration=c.applyDot(c.toTicks(w.Eighth),!1),r.secondBeatDuration=c.toTicks(w.Sixteenth);break;case K.Scottish8th:r.firstBeatDuration=c.toTicks(w.Sixteenth),r.secondBeatDuration=c.applyDot(c.toTicks(w.Eighth),!1);break;case K.Triplet16th:r.firstBeatDuration=c.applyTuplet(c.toTicks(w.Eighth),3,2),r.secondBeatDuration=c.applyTuplet(c.toTicks(w.Sixteenth),3,2);break;case K.Dotted16th:r.firstBeatDuration=c.applyDot(c.toTicks(w.Sixteenth),!1),r.secondBeatDuration=c.toTicks(w.ThirtySecond);break;case K.Scottish16th:r.firstBeatDuration=c.toTicks(w.ThirtySecond),r.secondBeatDuration=c.applyDot(c.toTicks(w.Sixteenth),!1)}return r.secondBeatStartOffset=e-r.firstBeatDuration,r}Ng(t,e){const s=c.toTicks(w.SixtyFourth),i=t.voice.bar.staff;if(i.tuning.length>0)for(const t of i.tuning)this.Ti.addNote(i.track.index,e,s,t,c.dynamicToVelocity(o.F),i.track.playbackInfo.primaryChannel)}Dg(t){return t.hasBend||t.beat.hasWhammyBar||t.beat.vibrato!==P.None}Lg(t,e){if(this.Dg(e))return t.playbackInfo.secondaryChannel;let s=e;for(;s.isTieDestination;)if(s=s.tieOrigin,this.Dg(s))return t.playbackInfo.secondaryChannel;for(s=e;s.isTieOrigin;)if(s=s.tieDestination,this.Dg(s))return t.playbackInfo.secondaryChannel;return t.playbackInfo.primaryChannel}Eg(e,s,i,n,r,a){const h=e.beat.voice.bar.staff.track,o=e.beat.voice.bar.staff;let c=e.calculateRealValue(this.applyTranspositionPitches,!0);if(e.isPercussion){const t=Nt.getArticulation(e);t&&(c=t.outputMidiNumber)}const l=null==a&&e.isStringed&&e.string<=r.length?r[e.string-1]:0,u=s+l,d=this.Wg(e,i,n);d.untilTieOrSlideEnd-=l,d.noteOnly-=l,d.letRingEnd-=l;const f=t.Rg(e),p=this.Lg(h,e);let b=0;const m=Math.max(d.untilTieOrSlideEnd,d.letRingEnd);b=e.hasBend?t.getPitchWheel(e.bendPoints[0].value):e.beat.hasWhammyBar?t.getPitchWheel(e.beat.whammyBarPoints[0].value):e.isTieDestination||e.slideOrigin&&e.slideOrigin.slideOutType===M.Legato?-1:t.getPitchWheel(0),b>=0&&this.Ti.addNoteBend(h.index,u,p,c,b),e.beat.hasRasgueado?this.Og(h,e,u,c,f,p,a):e.ornament===Pt.None?!e.isTrill||o.isPercussion?e.beat.isTremolo?this.Ig(e,u,d,c,f,p):(e.hasBend?this.Gg(e,u,d,c,p,n):e.beat.hasWhammyBar&&0===e.index?this.Hg(e.beat,u,d,p,n):e.slideInType!==T.None||e.slideOutType!==M.None?this.$g(e,u,d,c,p,n):(e.vibrato!==P.None||e.isTieDestination&&e.tieOrigin.vibrato!==P.None)&&this.Vg(e,u,d,c,p),e.isTieDestination||e.slideOrigin&&e.slideOrigin.slideOutType===M.Legato||this.Ti.addNote(h.index,u,m,c,f,p)):this.zg(e,u,d,c,f,p):this.Ug(h,e,u,m,c,f,p)}static Xg=[2,2,2,1,1,2,2,2,2,2,1,1];static ornamentKeysDown=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1];Ug(e,s,i,n,r,a,h){let o,l;const u=r%12,d=1/3;switch(s.ornament){case Pt.Turn:o=[r+t.Xg[u],r,r+t.ornamentKeysDown[u]],l=[c.toTicks(w.Sixteenth)*d,c.toTicks(w.Sixteenth)*d,c.toTicks(w.Sixteenth)*d];break;case Pt.InvertedTurn:o=[r+t.ornamentKeysDown[u],r,r+t.Xg[u]],l=[c.toTicks(w.Sixteenth)*d,c.toTicks(w.Sixteenth)*d,c.toTicks(w.Sixteenth)*d];break;case Pt.UpperMordent:o=[r,r+t.Xg[u]],l=[c.toTicks(w.ThirtySecond),c.toTicks(w.ThirtySecond)];break;case Pt.LowerMordent:o=[r,r+t.ornamentKeysDown[u]],l=[c.toTicks(w.ThirtySecond),c.toTicks(w.ThirtySecond)];break;default:return}let f=1;n<c.QuarterTime&&(f=n/c.QuarterTime),a-=c.VelocityIncrement;let p=0;for(let t=0;t<o.length;t++){const s=l[t]*f;this.Ti.addNote(e.index,i,s,o[t],a,h),i+=s,p+=s}const b=n-p;this.Ti.addNote(e.index,i,b,r,a,h)}Wg(e,s,i){const n=new Oa;if(n.beatDurationFactor=s/c.toTicks(e.beat.duration),n.noteOnly=s,n.untilTieOrSlideEnd=s,n.letRingEnd=s,e.isDead)return n.noteOnly=this.jg(t.ig,s,i),n.untilTieOrSlideEnd=n.noteOnly,n.letRingEnd=n.noteOnly,n;if(e.isPalmMute)return n.noteOnly=this.jg(t.ng,s,i),n.untilTieOrSlideEnd=n.noteOnly,n.letRingEnd=n.noteOnly,n;if(e.isStaccato)return n.noteOnly=s/2|0,n.untilTieOrSlideEnd=n.noteOnly,n.letRingEnd=n.noteOnly,n;if(e.isTieOrigin){const t=e.tieDestination;if(t)if(e.isTieDestination)n.untilTieOrSlideEnd=s+this.Wg(t,t.beat.playbackDuration,i).untilTieOrSlideEnd;else{const s=e.beat.absolutePlaybackStart,r=this.Wg(t,t.beat.playbackDuration,i);n.untilTieOrSlideEnd=t.beat.absolutePlaybackStart+r.untilTieOrSlideEnd-s}}else if(e.slideOutType===M.Legato){const t=e.slideTarget;if(t){const s=e.beat.absolutePlaybackStart,r=this.Wg(t,t.beat.playbackDuration,i);n.untilTieOrSlideEnd=t.beat.absolutePlaybackStart+r.untilTieOrSlideEnd-s}}if(e.isLetRing&&this.dm.notation.notationMode===F.GuitarPro){let t=e.beat,i=0;const r=e.beat.voice.bar.masterBar.calculateDuration();for(;t.nextBeat;){const s=t.nextBeat;if(s.isRest)break;if(e.isStringed&&s.hasNoteOnString(e.string))break;if(t=t.nextBeat,i=t.absolutePlaybackStart-e.beat.absolutePlaybackStart+t.playbackDuration,i>r){i=r;break}}t===e.beat?n.letRingEnd=s:n.letRingEnd=i}else n.letRingEnd=n.untilTieOrSlideEnd;return n}jg(t,e,s){const i=s*t/f.MaxPosition|0;return Math.min(i,e)}static Rg(t){let e=0;switch(!t.beat.voice.bar.staff.isPercussion&&t.hammerPullOrigin&&e--,t.isGhost&&e--,t.accentuated){case k.Normal:e++;break;case k.Heavy:e+=2}return c.dynamicToVelocity(t.dynamics,e)}Fg(e,s,i){const n=e.voice.bar.staff.track;switch(e.fade){case Rt.FadeIn:this.Jg(n,s,i,0,t.mg(n.playbackInfo.volume));break;case Rt.FadeOut:this.Jg(n,s,i,t.mg(n.playbackInfo.volume),0);break;case Rt.VolumeSwell:const e=i/2|0;this.Jg(n,s,e,0,t.mg(n.playbackInfo.volume)),this.Jg(n,s+e,e,t.mg(n.playbackInfo.volume),0)}}Jg(t,e,s,i,n){const r=(n-i)/(s=.8*s|0),a=s/120+1|0,h=e+s;for(let s=0;s<a;s++){const o=s===a-1,c=o?h:e+120*s,l=o?n:Math.round(i+(c-e)*r);this.Ti.addControlChange(t.index,c,t.playbackInfo.primaryChannel,da.VolumeCoarse,l),this.Ti.addControlChange(t.index,c,t.playbackInfo.secondaryChannel,da.VolumeCoarse,l)}}Vg(t,e,s,i,n){let r=0,a=0;switch(t.vibrato!==P.None?t.vibrato:t.isTieDestination?t.tieOrigin.vibrato:P.Slight){case P.Slight:r=this.dm.player.vibrato.noteSlightLength,a=this.dm.player.vibrato.noteSlightAmplitude;break;case P.Wide:r=this.dm.player.vibrato.noteWideLength,a=this.dm.player.vibrato.noteWideAmplitude;break;default:return}const h=t.beat.voice.bar.staff.track;let o=0;if(t.isTieDestination&&t.tieOrigin.hasBend){const e=t.tieOrigin.bendPoints;o=e[e.length-1].value}this.Ag(e,s.noteOnly,r,o,a,(t,e)=>{this.Ti.addNoteBend(h.index,t,n,i,e)})}vibratoResolution=16;Ag(e,s,i,n,r,a){const h=this.vibratoResolution,o=i/2|0,c=e+s;for(;e<c;){let s=0;const l=e+i<c?i:c-e;for(;s<l;){const i=n+r*Math.sin(s*Math.PI/o);a(e+s|0,t.getPitchWheel(i)),s+=h}e+=i}a(0|c,t.getPitchWheel(n))}static gg=16;static qg=yt.DefaultPitchWheel/t.gg;static Yg=6;static Kg=150;static getPitchWheel(e){return yt.DefaultPitchWheel+e/2*t.qg}$g(t,e,s,i,n,r){const a=t.slideOutType===M.Legato?s.noteOnly:s.untilTieOrSlideEnd,h=[],o=t.beat.voice.bar.staff.track,c=this.dm.player.slide.simpleSlidePitchOffset,l=Math.floor(f.MaxPosition*this.dm.player.slide.simpleSlideDurationRatio),u=Math.floor(f.MaxPosition*this.dm.player.slide.shiftSlideDurationRatio);switch(t.slideInType){case T.IntoFromAbove:h.push(new f(0,c)),h.push(new f(l,0));break;case T.IntoFromBelow:h.push(new f(0,-c)),h.push(new f(l,0))}switch(t.slideOutType){case M.Legato:case M.Shift:h.push(new f(u,0));const e=2*(t.slideTarget.calculateRealValue(this.applyTranspositionPitches,!0)-t.calculateRealValue(this.applyTranspositionPitches,!0));h.push(new f(f.MaxPosition,e));break;case M.OutDown:h.push(new f(f.MaxPosition-l,0)),h.push(new f(f.MaxPosition,-c));break;case M.OutUp:h.push(new f(f.MaxPosition-l,0)),h.push(new f(f.MaxPosition,c))}this.Qg(e,a,h,r,(t,e)=>{this.Ti.addNoteBend(o.index,t,n,i,e)})}Gg(e,s,i,n,r,a){const h=e.bendPoints,o=e.beat.voice.bar.staff.track,l=(t,e)=>{this.Ti.addNoteBend(o.index,t,r,n,e)};let u,d=null;if(e.isTieOrigin&&this.dm.notation.extendBendArrowsOnTiedNotes){let t=e;for(;t.isTieOrigin&&!t.tieDestination.hasBend&&t.tieDestination.vibrato===P.None;)t=t.tieDestination;u=t.beat.absolutePlaybackStart-e.beat.absolutePlaybackStart+this.Wg(t,t.beat.playbackDuration,a).noteOnly}else if(e.isTieOrigin&&e.beat.graceType!==y.None){switch(e.tieDestination.bendType){case b.Bend:case b.BendRelease:case b.PrebendBend:d=e.tieDestination.bendPoints[1].value;break;case b.Prebend:case b.PrebendRelease:d=e.tieDestination.bendPoints[0].value}u=Math.max(i.noteOnly,c.millisToTicks(this.dm.player.songBookBendDuration,a))}else u=i.noteOnly;h[0].value>0&&!e.isContinuedBend&&s>0&&s--;const m=Math.min(u,c.millisToTicks(this.dm.player.songBookBendDuration,a));let g=[];switch(e.bendType){case b.Custom:g=h;break;case b.Bend:case b.Release:switch(e.bendStyle){case p.Default:g=h;break;case p.Gradual:g.push(new f(0,e.bendPoints[0].value)),(!d||d<e.bendPoints[1].value)&&(d=e.bendPoints[1].value),g.push(new f(f.MaxPosition,d));break;case p.Fast:return(!d||d<e.bendPoints[1].value)&&(d=e.bendPoints[1].value),void(e.beat.graceType===y.BendGrace?this.Zg(s,u,!0,[e.bendPoints[0].value,d],m,a,l):this.Zg(s,u,!1,[e.bendPoints[0].value,d],m,a,l))}break;case b.BendRelease:switch(e.bendStyle){case p.Default:g=h;break;case p.Gradual:g.push(new f(0,e.bendPoints[0].value)),g.push(new f(f.MaxPosition/2|0,e.bendPoints[1].value)),g.push(new f(f.MaxPosition,e.bendPoints[2].value));break;case p.Fast:return void this.Zg(s,u,!1,[e.bendPoints[0].value,e.bendPoints[1].value,e.bendPoints[2].value],m,a,l)}break;case b.Hold:case b.Prebend:g=h;break;case b.PrebendBend:switch(e.bendStyle){case p.Default:g=h;break;case p.Gradual:g.push(new f(0,e.bendPoints[0].value)),g.push(new f(f.MaxPosition,e.bendPoints[1].value));break;case p.Fast:return l(s,0|t.getPitchWheel(e.bendPoints[0].value)),(!d||d<e.bendPoints[1].value)&&(d=e.bendPoints[1].value),void this.Zg(s,u,!1,[e.bendPoints[0].value,d],m,a,l)}break;case b.PrebendRelease:switch(e.bendStyle){case p.Default:g=h;break;case p.Gradual:g.push(new f(0,e.bendPoints[0].value)),g.push(new f(f.MaxPosition,e.bendPoints[1].value));break;case p.Fast:return l(s,0|t.getPitchWheel(e.bendPoints[0].value)),void this.Zg(s,u,!1,[e.bendPoints[0].value,e.bendPoints[1].value],m,a,l)}}this.Qg(s,u,g,a,l)}Zg(e,s,i,n,r,a,h){const o=i?e:e+s-r,c=r/(n.length-1);for(let e=0;e<n.length-1;e++){const s=t.getPitchWheel(n[e]),i=t.getPitchWheel(n[e+1]),r=o+c*e;this.tw(r,c,s,i,a,h)}}Hg(e,s,i,n,r){const a=e.whammyBarPoints,h=e.voice.bar.staff.track,o=i.noteOnly;a[0].value>0&&!e.isContinuedWhammy&&s--;const l=(t,e)=>{this.Ti.addBend(h.index,t,n,e)};let u=[];switch(e.whammyBarType){case Lt.Custom:u=a;break;case Lt.Dive:switch(e.whammyStyle){case p.Default:u=a;break;case p.Gradual:u.push(new f(0,a[0].value)),u.push(new f(f.MaxPosition,a[1].value));break;case p.Fast:const t=Math.min(o,c.millisToTicks(this.dm.player.songBookBendDuration,r));return void this.Zg(s,o,!1,[a[0].value,a[1].value],t,r,l)}break;case Lt.Dip:switch(e.whammyStyle){case p.Default:u=a;break;case p.Gradual:u.push(new f(0,a[0].value)),u.push(new f(f.MaxPosition/2|0,a[1].value)),u.push(new f(f.MaxPosition,a[2].value));break;case p.Fast:const t=Math.min(o,c.millisToTicks(this.dm.player.songBookDipDuration,r));return void this.Zg(s,o,!0,[a[0].value,a[1].value,a[2].value],t,r,l)}break;case Lt.Hold:case Lt.Predive:u=a;break;case Lt.PrediveDive:switch(e.whammyStyle){case p.Default:u=a;break;case p.Gradual:u.push(new f(0,a[0].value)),u.push(new f(f.MaxPosition/2|0,a[0].value)),u.push(new f(f.MaxPosition,a[1].value));break;case p.Fast:const e=t.getPitchWheel(a[0].value);this.Ti.addBend(h.index,s,n,0|e);const i=Math.min(o,c.millisToTicks(this.dm.player.songBookBendDuration,r));return void this.Zg(s,o,!1,[a[0].value,a[1].value],i,r,l)}}this.Qg(s,o,u,r,l)}Qg(e,s,i,n,r){const a=s/f.MaxPosition;for(let s=0;s<i.length-1;s++){const h=i[s],o=i[s+1],c=t.getPitchWheel(h.value),l=t.getPitchWheel(o.value),u=a*(o.offset-h.offset),d=e+a*h.offset;this.tw(d,u,c,l,n,r)}}tw(e,s,i,n,r,a){const h=c.ticksToMillis(s,r),o=Math.abs(n-i)/t.qg,l=Math.max(t.Yg*o,h/t.Kg),u=s/l,d=(n-i)/l,f=e+s;for(let t=0;t<l;t++)a(0|e,Math.round(i)),i+=d,e+=u;a(0|f,n)}Og(t,e,s,i,n,r,a){let h=s;for(let s=0;s<a.durations.length;s++){const o=a.brushInfos[s],c=e.isStringed&&e.string<=o.length?o[e.string-1]:0,l=a.durations[s];this.Ti.addNote(t.index,h+c,l-c,i,n,r),h+=l}}zg(t,e,s,i,n,r){const a=t.beat.voice.bar.staff.track,h=t.stringTuning+t.trillFret;let o=c.toTicks(t.trillSpeed),l=!0,u=e;const d=e+s.untilTieOrSlideEnd;for(;u+10<d;)u+o>=d&&(o=d-u),this.Ti.addNote(a.index,u,o,l?i:h,n,r),l=!l,u+=o}Ig(t,e,s,i,n,r){const a=t.beat.voice.bar.staff.track;if(0===t.beat.tremoloPicking.marks)return;let h=t.beat.tremoloPicking.getDurationAsTicks(t.beat.duration)*s.beatDurationFactor,o=e;const c=e+s.untilTieOrSlideEnd;for(;o+10<c;)o+h>=c&&(h=c-o),this.Ti.addNote(a.index,o,h,i,n,r),o+=h}static ew=new Map([[Gt.Ii,[m.BrushDown,m.BrushUp]],[Gt.Mi,[m.BrushDown,m.BrushDown]],[Gt.MiiTriplet,[m.BrushDown,m.BrushDown,m.BrushUp]],[Gt.MiiAnapaest,[m.BrushDown,m.BrushDown,m.BrushUp]],[Gt.PmpTriplet,[m.BrushUp,m.BrushDown,m.BrushDown]],[Gt.PmpAnapaest,[m.BrushUp,m.BrushDown,m.BrushDown]],[Gt.PeiTriplet,[m.BrushUp,m.BrushDown,m.BrushDown]],[Gt.PeiAnapaest,[m.BrushUp,m.BrushDown,m.BrushDown]],[Gt.PaiTriplet,[m.BrushUp,m.BrushDown,m.BrushDown]],[Gt.PaiAnapaest,[m.BrushUp,m.BrushDown,m.BrushDown]],[Gt.AmiTriplet,[m.BrushDown,m.BrushDown,m.BrushDown]],[Gt.AmiAnapaest,[m.BrushDown,m.BrushDown,m.BrushDown]],[Gt.Ppp,[m.None,m.BrushDown,m.BrushUp]],[Gt.Amii,[m.BrushDown,m.BrushDown,m.BrushDown,m.BrushUp]],[Gt.Amip,[m.BrushDown,m.BrushDown,m.BrushDown,m.BrushUp]],[Gt.Eami,[m.BrushDown,m.BrushDown,m.BrushDown,m.BrushDown]],[Gt.Eamii,[m.BrushDown,m.BrushDown,m.BrushDown,m.BrushDown,m.BrushUp]],[Gt.Peami,[m.BrushDown,m.BrushDown,m.BrushDown,m.BrushDown,m.BrushUp]]]);static sw=new Map([[Gt.Ii,[c.toTicks(w.Eighth),c.toTicks(w.Eighth)]],[Gt.Mi,[c.toTicks(w.Eighth),c.toTicks(w.Eighth)]],[Gt.MiiTriplet,[c.toTicks(w.Eighth)/3,c.toTicks(w.Eighth)/3,c.toTicks(w.Eighth)/3]],[Gt.MiiAnapaest,[c.toTicks(w.Sixteenth),c.toTicks(w.Sixteenth),c.toTicks(w.Eighth)]],[Gt.PmpTriplet,[c.toTicks(w.Eighth)/3,c.toTicks(w.Eighth)/3,c.toTicks(w.Eighth)/3]],[Gt.PmpAnapaest,[c.toTicks(w.Sixteenth)/3,c.toTicks(w.Sixteenth)/3,c.toTicks(w.Eighth)/3]],[Gt.PeiTriplet,[c.toTicks(w.Eighth)/3,c.toTicks(w.Eighth)/3,c.toTicks(w.Eighth)/3]],[Gt.PeiAnapaest,[c.toTicks(w.Sixteenth),c.toTicks(w.Sixteenth),c.toTicks(w.Eighth)]],[Gt.PaiTriplet,[c.toTicks(w.Eighth)/3,c.toTicks(w.Eighth)/3,c.toTicks(w.Eighth)/3]],[Gt.PaiAnapaest,[c.toTicks(w.Sixteenth),c.toTicks(w.Sixteenth),c.toTicks(w.Eighth)]],[Gt.AmiTriplet,[c.toTicks(w.Eighth)/3,c.toTicks(w.Eighth)/3,c.toTicks(w.Eighth)/3]],[Gt.AmiAnapaest,[c.toTicks(w.Sixteenth)/3,c.toTicks(w.Sixteenth)/3,c.toTicks(w.Eighth)/3]],[Gt.Ppp,[c.toTicks(w.Sixteenth)/3,c.toTicks(w.Sixteenth)/3,c.toTicks(w.Eighth)/3]],[Gt.Amii,[c.toTicks(w.Sixteenth)/3,c.toTicks(w.Sixteenth)/3,c.toTicks(w.Sixteenth)/3,c.toTicks(w.Eighth)]],[Gt.Amip,[c.toTicks(w.Sixteenth)/3,c.toTicks(w.Sixteenth)/3,c.toTicks(w.Sixteenth)/3,c.toTicks(w.Eighth)]],[Gt.Eami,[c.toTicks(w.Sixteenth),c.toTicks(w.Sixteenth),c.toTicks(w.Sixteenth),c.toTicks(w.Sixteenth)]],[Gt.Eamii,[c.toTicks(w.Sixteenth)/5,c.toTicks(w.Sixteenth)/5,c.toTicks(w.Sixteenth)/5,c.toTicks(w.Sixteenth)/5,c.toTicks(w.Sixteenth)/5]],[Gt.Peami,[c.toTicks(w.Sixteenth)/5,c.toTicks(w.Sixteenth)/5,c.toTicks(w.Sixteenth)/5,c.toTicks(w.Sixteenth)/5,c.toTicks(w.Sixteenth)/5]]]);Cg(e,s){if(!e.hasRasgueado)return null;const i=new Ga,n=t.sw.get(e.rasgueado).reduce((t,e)=>t+e,0);i.durations=t.sw.get(e.rasgueado).map(t=>s*t/n),i.brushInfos=new Array(i.durations.length);const r=c.toTicks(w.Sixteenth);let a=0,h=0;for(const t of e.notes)t.isTieDestination||(a|=1<<t.string-1,h++);const o=t.ew.get(e.rasgueado);for(let t=0;t<i.durations.length;t++){const s=i.durations[t]*r/c.QuarterTime,n=new Int32Array(e.voice.bar.staff.tuning.length);i.brushInfos[t]=n;const l=o[t];l!==m.None&&this.iw(e,n,l===m.ArpeggioDown||l===m.BrushDown,a,h,s)}return i}Pg(t){const e=new Int32Array(t.voice.bar.staff.tuning.length);if(t.brushType){let s=0,i=0;for(const e of t.notes)e.isTieDestination||(s|=1<<e.string-1,i++);this.iw(t,e,t.brushType===m.ArpeggioDown||t.brushType===m.BrushDown,s,i,t.brushDuration)}return e}iw(t,e,s,i,n,r){if(t.notes.length>0){let a=0;const h=r/(n-1)|0;for(let n=0;n<t.voice.bar.staff.tuning.length;n++){const t=s?n:e.length-1-n;i&1<<t&&(e[t]=a,a+=h)}}return e}vg(e,s,i){switch(s.type){case l.Instrument:this.pg(e.voice.bar.staff.track,e.playbackStart+i,e.voice.bar.staff.track.playbackInfo.primaryChannel,255&s.value),this.pg(e.voice.bar.staff.track,e.playbackStart+i,e.voice.bar.staff.track.playbackInfo.secondaryChannel,255&s.value);break;case l.Bank:this.bg(e.voice.bar.staff.track,e.playbackStart+i,e.voice.bar.staff.track.playbackInfo.primaryChannel,s.value),this.bg(e.voice.bar.staff.track,e.playbackStart+i,e.voice.bar.staff.track.playbackInfo.secondaryChannel,s.value);break;case l.Balance:const n=t.mg(s.value);this.Ti.addControlChange(e.voice.bar.staff.track.index,e.playbackStart+i,e.voice.bar.staff.track.playbackInfo.primaryChannel,da.PanCoarse,n),this.Ti.addControlChange(e.voice.bar.staff.track.index,e.playbackStart+i,e.voice.bar.staff.track.playbackInfo.secondaryChannel,da.PanCoarse,n);break;case l.Volume:const r=t.mg(s.value);this.Ti.addControlChange(e.voice.bar.staff.track.index,e.playbackStart+i,e.voice.bar.staff.track.playbackInfo.primaryChannel,da.VolumeCoarse,r),this.Ti.addControlChange(e.voice.bar.staff.track.index,e.playbackStart+i,e.voice.bar.staff.track.playbackInfo.secondaryChannel,da.VolumeCoarse,r)}}prepareSingleBeat(e){let s=-1,i=-1,n=e;for(;n&&(-1===s||-1===i);){for(const t of e.automations)switch(t.type){case l.Instrument:i=t.value;break;case l.Tempo:s=t.value}n=n.previousBeat}const r=e.voice.bar.staff.track,a=e.voice.bar.masterBar;-1===s&&(s=a.score.tempo);const h=e.playbackStart/a.calculateDuration();for(const t of a.tempoAutomations){if(!(t.ratioPosition<=h))break;s=t.value}-1===i&&(i=r.playbackInfo.program);const o=r.playbackInfo.volume;this.og(r),this.Ti.addTimeSignature(0,a.timeSignatureNumerator,a.timeSignatureDenominator),this.Ti.addTempo(0,s);const c=t.mg(o);return this.Ti.addControlChange(0,0,r.playbackInfo.primaryChannel,da.VolumeCoarse,c),this.Ti.addControlChange(0,0,r.playbackInfo.secondaryChannel,da.VolumeCoarse,c),s}generateSingleBeat(t){const e=this.prepareSingleBeat(t);this.xg(t,-t.playbackStart,t.voice.bar,e)}generateSingleNote(t){const e=this.prepareSingleBeat(t.beat);this.Eg(t,0,t.beat.playbackDuration,e,new Int32Array(t.beat.voice.bar.staff.tuning.length),null)}},Va=class{onAttach(t){}onDetach(t){}placeBeatCursor(t,e,s){const i=e.barBounds.masterBarBounds.visualBounds;t.transitionToX(0,s),t.setBounds(s,i.y,1,i.h)}placeBarCursor(t,e){const s=e.barBounds.masterBarBounds.visualBounds;t.setBounds(s.x,s.y,s.w,s.h)}transitionBeatCursor(t,e,s,i,n,r){const a=r===Da.ToNextBext?2:1;i=s+(i-s)*a,n*=a,t.transitionToX(n,i)}},za=class{onAttach(t){}onDetach(t){}placeBeatCursor(t,e,s){const i=e.barBounds.masterBarBounds.visualBounds;t.transitionToX(0,e.onNotesX),t.setBounds(e.onNotesX,i.y,1,i.h)}placeBarCursor(t,e){const s=e.barBounds.masterBarBounds.visualBounds;t.setBounds(s.x,s.y,s.w,s.h)}transitionBeatCursor(t,e,s,i,n,r){this.placeBeatCursor(t,e,s)}},Ua=function(t){return t[t.PreNotes=0]="PreNotes",t[t.OnNotes=1]="OnNotes",t[t.MiddleNotes=2]="MiddleNotes",t[t.Stem=3]="Stem",t[t.PostNotes=4]="PostNotes",t[t.EndBeat=5]="EndBeat",t}({}),Xa=class{x;y;width=0;height=0;renderer;constructor(t,e){this.x=t,this.y=e}getBoundingBoxTop(){return this.y}getBoundingBoxBottom(){return this.getBoundingBoxTop()+this.height}doLayout(){}paint(t,e,s){}},ja=class extends Xa{scaleToWidth(t){this.width=t}},Ja=class t extends ja{nw=[];rw=0;beat;preNotes;onNotes;getLowestNoteY(t){return this.onNotes.getLowestNoteY(t)}getHighestNoteY(t){return this.onNotes.getHighestNoteY(t)}get beatId(){return this.beat.id}get isLastOfVoice(){return this.beat.isLastOfVoice}get displayDuration(){return this.beat.displayDuration}get graceIndex(){return this.beat.graceIndex}get graceType(){return this.beat.graceType}get absoluteDisplayStart(){return this.beat.absoluteDisplayStart}get graceGroup(){return this.beat.graceGroup}get voiceIndex(){return this.beat.voice.index}get isFirstOfTupletGroup(){return this.beat.hasTuplet&&this.beat.tupletGroup.beats[0].id===this.beat.id}get tupletGroup(){return this.beat.tupletGroup}get onTimeX(){return this.onNotes.x+this.onNotes.onTimeX}constructor(t){super(0,0),this.beat=t,this.nw=[]}getNoteY(t,e){return this.onNotes.y+this.onNotes.getNoteY(t,e)}getRestY(t){return this.onNotes.y+this.onNotes.getRestY(t)}getNoteX(t,e){return this.onNotes.x+this.onNotes.getNoteX(t,e)}addTie(t){t.renderer=this.renderer,this.nw.push(t),this.renderer.registerTie(t)}getBoundingBoxTop(){let t=Bt.minBoundingBox(this.preNotes.getBoundingBoxTop(),this.onNotes.getBoundingBoxTop());return Number.isNaN(t)&&(t=this.renderer.middleYPosition),t}getBoundingBoxBottom(){let t=Bt.maxBoundingBox(this.preNotes.getBoundingBoxBottom(),this.onNotes.getBoundingBoxBottom());return Number.isNaN(t)&&(t=this.renderer.middleYPosition),t}drawBeamHelperAsFlags(t){return t.hasFlag(!1,void 0)}get postBeatStretch(){return this.onNotes.computedWidth+this.rw-this.onNotes.onTimeX}registerLayoutingInfo(t){const e=this.preNotes.computedWidth+this.onNotes.onTimeX;let s=this.postBeatStretch;for(const t of this.nw)s+=t.width;t.addBeatSpring(this,e,s),t.setBeatSizes(this,{preBeatSize:this.preNotes.width,onBeatSize:this.onNotes.width})}applyLayoutingInfo(t){this.updateWidth()}doLayout(){this.preNotes.x=0,this.preNotes.renderer=this.renderer,this.preNotes.container=this,this.preNotes.doLayout(),this.onNotes.x=this.preNotes.x+this.preNotes.width,this.onNotes.renderer=this.renderer,this.onNotes.container=this,this.onNotes.doLayout(),this.createBeatTies(),this.updateWidth()}createBeatTies(){let t=this.beat.notes.length-1;for(;t>=0;)this.createTies(this.beat.notes[t--])}doMultiVoiceLayout(){}updateWidth(){let t=this.preNotes.width+this.onNotes.width,e=0;for(const t of this.nw){const s=t;s.width>e&&(e=s.width)}this.rw=e,t+=e,this.width=t}createTies(t){}static getGroupId(t){return`b${t.id}`}paint(e,s,i){if(this.preNotes.isEmpty&&this.onNotes.isEmpty&&0===this.nw.length)return;i.beginGroup(t.getGroupId(this.beat)),this.preNotes.paint(e+this.x,s+this.y,i),this.onNotes.paint(e+this.x,s+this.y,i);const n=e-this.renderer.beatGlyphsStart-this.renderer.x,r=s-this.renderer.y;for(let t=0,e=this.nw.length;t<e;t++){const e=this.nw[t];e.renderer=this.renderer,e.paint(n,r,i)}i.endGroup()}buildBoundingsLookup(t,e,s){const i=new zn;if(i.beat=this.beat,this.beat.isEmpty)i.visualBounds=new _s,i.visualBounds.x=e+this.x,i.visualBounds.y=t.visualBounds.y,i.visualBounds.w=this.width,i.visualBounds.h=t.visualBounds.h,i.realBounds=new _s,i.realBounds.x=e+this.x,i.realBounds.y=t.realBounds.y,i.realBounds.w=this.width,i.realBounds.h=t.realBounds.h,i.onNotesX=e+this.x+this.onNotes.x+this.onNotes.onTimeX;else{i.visualBounds=new _s,i.visualBounds.x=e+this.x,this.preNotes.isEmpty?this.onNotes.isEmpty?i.visualBounds.x=e+this.x:i.visualBounds.x=e+this.x+this.onNotes.x:i.visualBounds.x=e+this.x+this.preNotes.x;let s=0;s=this.onNotes.isEmpty?this.preNotes.isEmpty?e+this.x+this.width:e+this.x+this.preNotes.x+this.preNotes.width:e+this.x+this.onNotes.x+this.onNotes.onTimeX+this.postBeatStretch,i.visualBounds.w=s-i.visualBounds.x,i.visualBounds.y=t.visualBounds.y,i.visualBounds.h=t.visualBounds.h,i.realBounds=new _s,i.realBounds.x=e+this.x,i.realBounds.y=t.realBounds.y,i.realBounds.w=this.width,i.realBounds.h=t.realBounds.h,i.onNotesX=e+this.x+this.onNotes.x+this.onNotes.onTimeX}t.addBeat(i),this.renderer.settings.core.includeNoteBounds&&this.onNotes.buildBoundingsLookup(i,e+this.x,s+this.y)}getBeatX(t,e=!1){switch(t){case Ua.PreNotes:return this.preNotes.x;case Ua.OnNotes:return this.onNotes.x;case Ua.MiddleNotes:return this.onNotes.x+this.onNotes.middleX;case Ua.Stem:return this.onNotes.x+this.onNotes.stemX;case Ua.PostNotes:const t=e?this.renderer.layoutingInfo.getBeatSizes(this.beat)?.onBeatSize??this.onNotes.width:this.onNotes.width;return this.onNotes.x+t;case Ua.EndBeat:return this.width}return this.preNotes.x}},qa=class{aw;hw;dm;Qu=0;We=null;ow=null;get instance(){return this.aw}set instance(t){this.aw=t;const e=this.hw;if(e)for(const t of e)t();if(t){const e=[];e.push(t.preRender.on(t=>this.preRender.trigger(t))),e.push(t.renderFinished.on(t=>this.renderFinished.trigger(t))),e.push(t.partialRenderFinished.on(t=>this.partialRenderFinished.trigger(t))),e.push(t.partialLayoutFinished.on(t=>this.partialLayoutFinished.trigger(t))),e.push(t.postRenderFinished.on(()=>this.postRenderFinished.trigger())),e.push(t.error.on(t=>this.error.trigger(t))),this.hw=e,this.dm&&t.updateSettings(this.dm),t.width=this.Qu,null!==this.We&&t.renderScore(this.We,this.ow)}else this.hw=void 0}get boundsLookup(){return this.aw?this.aw.boundsLookup:null}get width(){return this.aw?this.aw.width:0}set width(t){this.Qu=t,this.aw&&(this.aw.width=t)}render(t){this.aw?.render(t)}resizeRender(){this.aw?.resizeRender()}renderScore(t,e,s){this.We=t,this.ow=e,this.aw?.renderScore(t,e,s)}renderResult(t){this.aw?.renderResult(t)}updateSettings(t){this.dm=t,this.aw?.updateSettings(t)}destroy(){this.aw?.destroy(),this.aw=void 0}preRender=new Js;renderFinished=new Js;partialRenderFinished=new Js;partialLayoutFinished=new Js;postRenderFinished=new js;error=new Js},Ya=class{oldWidth=0;newWidth=0;settings=null},Ka=class{api;lastScroll=-1;constructor(t){this.api=t}[Symbol.dispose](){}forceScrollTo(t){this.cw(t,!0),this.lastScroll=-1}cw(t,e){const s=this.calculateLastScroll(t);(s!==this.lastScroll||e)&&(this.lastScroll=s,this.doScroll(t))}onBeatCursorUpdating(t,e,s,i,n,r){this.cw(t,!1)}},Qa=class extends Ka{calculateLastScroll(t){return t.barBounds.masterBarBounds.realBounds.y}doScroll(t){const e=this.api.uiFacade,s=this.api.settings,i=e.getScrollContainer(),n=e.getOffset(i,this.api.container),r=t.barBounds.masterBarBounds.realBounds.y+s.player.scrollOffsetY;e.scrollToY(i,n.y+r,this.api.settings.player.scrollSpeed)}},Za=class extends Ka{calculateLastScroll(t){return t.barBounds.masterBarBounds.realBounds.y}doScroll(t){const e=this.api.uiFacade,s=this.api.settings,i=e.getScrollContainer(),n=i.scrollTop+e.getOffset(null,i).h,r=t.barBounds.masterBarBounds;if(r.visualBounds.y+r.visualBounds.h>=n||r.visualBounds.y<i.scrollTop){const t=r.realBounds.y+s.player.scrollOffsetY;e.scrollToY(i,t,s.player.scrollSpeed)}}},th=class{Yu;lw=-1;uw;constructor(t){this.Yu=t,this.uw=t.uiFacade.getScrollContainer().resize.on(()=>{const e=t.uiFacade.getScrollContainer(),s=t.settings.player.scrollOffsetX,i=e.width+s;t.uiFacade.setCanvasOverflow(t.canvasElement,i,!0)})}[Symbol.dispose](){this.Yu.uiFacade.setCanvasOverflow(this.Yu.canvasElement,0,!0),this.uw()}forceScrollTo(t){const e=this.Yu.uiFacade,s=this.Yu.settings,i=e.getScrollContainer(),n=t.barBounds.masterBarBounds.realBounds.y+s.player.scrollOffsetY;e.scrollToY(i,n,0),this.lw=-1}onBeatCursorUpdating(t,e,s,i,n,r){const a=this.Yu.uiFacade,h=this.Yu.settings,o=t.barBounds.masterBarBounds,c=o.realBounds.y+h.player.scrollOffsetY;if(c===this.lw&&r>0)return;const l=a.getScrollContainer();if(a.scrollToY(l,c,0),0===r)return void(this.lw=-1);this.lw=c;const u=c+o.realBounds.h,d=this.dw(o);a.scrollToY(l,u,d)}dw(t){const e=t.staffSystemBounds.bars,s=this.Yu.tickCache;let i=0;const n=this.Yu.score.masterBars;for(const t of e){const e=n[t.index],r=s.getMasterBar(e),a=s.getMasterBar(e).tempoChanges;let h=a[0].tempo,o=a[0].tick;for(let t=1;t<a.length;t++){const e=a[t].tick-o;i+=c.ticksToMillis(e,h),h=a[t].tempo,o=a[t].tick}const l=r.end-o;i+=c.ticksToMillis(l,h)}return i}},eh=class extends Ka{calculateLastScroll(t){return t.barBounds.masterBarBounds.visualBounds.x}doScroll(t){const e=this.api.uiFacade,s=this.api.settings,i=e.getScrollContainer(),n=t.barBounds.masterBarBounds.realBounds.x+s.player.scrollOffsetX;e.scrollToX(i,n,s.player.scrollSpeed)}},sh=class extends Ka{calculateLastScroll(t){return t.barBounds.masterBarBounds.visualBounds.x}doScroll(t){const e=this.api.uiFacade,s=this.api.settings,i=e.getScrollContainer(),n=i.scrollLeft+e.getOffset(null,i).w,r=t.barBounds.masterBarBounds;if(r.visualBounds.x+r.visualBounds.w>=n||r.visualBounds.x<i.scrollLeft){const t=r.realBounds.x+s.player.scrollOffsetX;e.scrollToX(i,t,s.player.scrollSpeed)}}},ih=class{Yu;lw=-1;uw;constructor(t){this.Yu=t,this.uw=t.uiFacade.getScrollContainer().resize.on(()=>{const e=t.uiFacade.getScrollContainer(),s=t.settings.player.scrollOffsetX,i=e.width+s;t.uiFacade.setCanvasOverflow(t.canvasElement,i,!1)})}[Symbol.dispose](){this.uw(),this.Yu.uiFacade.setCanvasOverflow(this.Yu.canvasElement,0,!1)}forceScrollTo(t){const e=this.Yu.uiFacade,s=this.Yu.settings,i=e.getScrollContainer(),n=t.onNotesX+s.player.scrollOffsetY;e.scrollToY(i,n,0),this.lw=-1}onBeatCursorUpdating(t,e,s,i,n,r){const a=this.Yu.uiFacade;if(n===this.lw&&r>0)return;const h=this.Yu.settings,o=a.getScrollContainer();if(a.scrollToX(o,i+h.player.scrollOffsetX,0),0===r)return void(this.lw=-1);this.lw=n;const c=n+h.player.scrollOffsetX;a.scrollToX(o,c,r)}},nh=class{activeBeats;constructor(t){this.activeBeats=t}},rh=class{Du=1;Lu=0;Wu=0;Ru=1;Ou=!1;Gu=[];aw;hw;midiTickShift=0;constructor(){this.ready=new js(()=>this.isReady),this.readyForPlayback=new js(()=>this.isReadyForPlayback),this.midiLoaded=new Js(()=>this.aw?.loadedMidiInfo??null),this.stateChanged=new Js(()=>new Gn(this.state,!1)),this.positionChanged=new Js(()=>this.currentPosition),this.playbackRangeChanged=new Js(()=>{const t=this.playbackRange;return t?new On(t):null})}get instance(){return this.aw}set instance(t){this.aw=t;const e=this.hw;if(e)for(const t of e)t();if(t){const e=[];e.push(t.ready.on(()=>this.ready.trigger())),e.push(t.readyForPlayback.on(()=>this.readyForPlayback.trigger())),e.push(t.finished.on(()=>this.finished.trigger())),e.push(t.soundFontLoaded.on(()=>this.soundFontLoaded.trigger())),e.push(t.soundFontLoadFailed.on(t=>this.soundFontLoadFailed.trigger(t))),e.push(t.midiLoaded.on(t=>{this.midiLoaded.trigger(this.fw(t))})),e.push(t.midiLoadFailed.on(t=>this.midiLoadFailed.trigger(t))),e.push(t.stateChanged.on(t=>this.stateChanged.trigger(t))),e.push(t.positionChanged.on(t=>{this.positionChanged.trigger(this.fw(t))})),e.push(t.midiEventsPlayed.on(t=>this.midiEventsPlayed.trigger(t))),e.push(t.playbackRangeChanged.on(t=>this.playbackRangeChanged.trigger(this.pw(t)))),this.hw=e,this.isReady?(t.masterVolume=this.Du,t.metronomeVolume=this.Lu,t.countInVolume=this.Wu,t.playbackSpeed=this.Ru,t.isLooping=this.Ou,t.midiEventsPlayedFilter=this.Gu,this.ready.trigger()):e.push(t.ready.on(()=>{t.masterVolume=this.Du,t.metronomeVolume=this.Lu,t.countInVolume=this.Wu,t.playbackSpeed=this.Ru,t.isLooping=this.Ou,t.midiEventsPlayedFilter=this.Gu}))}else this.hw=void 0}get output(){return this.aw.output}get isReady(){return!!this.aw&&this.aw.isReady}get isReadyForPlayback(){return!!this.aw&&this.aw.isReadyForPlayback}get state(){return this.aw?this.aw.state:In.Paused}get logLevel(){return O.logLevel}set logLevel(t){O.logLevel=t,this.aw&&(this.aw.logLevel=t)}get masterVolume(){return this.Du}set masterVolume(t){t=Math.max(t,yt.MinVolume),this.Du=t,this.aw&&(this.aw.masterVolume=t)}get metronomeVolume(){return this.Lu}set metronomeVolume(t){t=Math.max(t,yt.MinVolume),this.Lu=t,this.aw&&(this.aw.metronomeVolume=t)}get playbackSpeed(){return this.Ru}set playbackSpeed(t){this.Ru=t,this.aw&&(this.aw.playbackSpeed=t)}get loadedMidiInfo(){return this.aw?this.fw(this.aw.loadedMidiInfo):void 0}get currentPosition(){return this.aw?this.fw(this.aw.currentPosition):new Hn(0,0,0,0,!1,120,120)}get tickPosition(){return this.aw?this.bw(this.aw.tickPosition):0}set tickPosition(t){this.aw&&(this.aw.tickPosition=this.mw(t))}get timePosition(){return this.aw?this.aw.timePosition:0}set timePosition(t){this.aw&&(this.aw.timePosition=t)}get playbackRange(){return this.aw?this.gw(this.aw.playbackRange):null}set playbackRange(t){this.aw&&(this.aw.playbackRange=this.ww(t))}get isLooping(){return this.Ou}set isLooping(t){this.Ou=t,this.aw&&(this.aw.isLooping=t)}get countInVolume(){return this.Wu}set countInVolume(t){this.Wu=t,this.aw&&(this.aw.countInVolume=t)}get midiEventsPlayedFilter(){return this.Gu}set midiEventsPlayedFilter(t){this.Gu=t,this.aw&&(this.aw.midiEventsPlayedFilter=t)}destroy(){this.aw&&(this.aw.destroy(),this.aw=void 0)}play(){return!!this.aw&&this.aw.play()}pause(){this.aw&&this.aw.pause()}playPause(){this.aw&&this.aw.playPause()}stop(){this.aw&&this.aw.stop()}playOneTimeMidiFile(t){this.aw&&this.aw.playOneTimeMidiFile(t)}loadSoundFont(t,e){this.aw&&this.aw.loadSoundFont(t,e)}resetSoundFonts(){this.aw&&this.aw.resetSoundFonts()}loadMidiFile(t){this.aw&&this.aw.loadMidiFile(t)}loadBackingTrack(t){this.aw&&this.aw.loadBackingTrack(t)}updateSyncPoints(t){this.aw&&this.aw.updateSyncPoints(t)}applyTranspositionPitches(t){this.aw&&this.aw.applyTranspositionPitches(t)}setChannelTranspositionPitch(t,e){this.aw&&this.aw.setChannelTranspositionPitch(t,e)}setChannelMute(t,e){this.aw&&this.aw.setChannelMute(t,e)}resetChannelStates(){this.aw&&this.aw.resetChannelStates()}setChannelSolo(t,e){this.aw&&this.aw.setChannelSolo(t,e)}setChannelVolume(t,e){this.aw&&this.aw.setChannelVolume(t,e)}ready;readyForPlayback;finished=new js;soundFontLoaded=new js;soundFontLoadFailed=new Js;midiLoaded;midiLoadFailed=new Js;stateChanged;positionChanged;midiEventsPlayed=new Js;playbackRangeChanged;pw(t){return null==t.playbackRange?t:this.midiTickShift>0?new On(this.gw(t.playbackRange)):t}gw(t){if(null==t)return t;const e=this.midiTickShift;if(e>0){const s=new Aa;return s.startTick=t.startTick-e,s.endTick=t.endTick-e,s}return t}ww(t){if(null==t)return t;const e=this.midiTickShift;if(e>0){const s=new Aa;return s.startTick=t.startTick+e,s.endTick=t.endTick+e,s}return t}fw(t){if(!t)return t;const e=this.midiTickShift;return e>0?new Hn(t.currentTime,t.endTime,t.currentTick-e,t.endTick-e,t.isSeek,t.originalTempo,t.modifiedTempo):t}bw(t){return t-this.midiTickShift}mw(t){return t+this.midiTickShift}},ah=class{sampleRate=44100;yw=0;Ti;get handler(){return this.Ti}set handler(t){t&&0!==this.yw&&(t.seekTo(this.yw),this.yw=0),this.Ti=t}get backingTrackDuration(){return this.handler?.backingTrackDuration??0}get playbackRate(){return this.handler?.playbackRate??1}set playbackRate(t){const e=this.handler;e&&(e.playbackRate=t)}get masterVolume(){return this.handler?.masterVolume??1}set masterVolume(t){const e=this.handler;e&&(e.masterVolume=t)}seekTo(t){const e=this.handler;e?e.seekTo(t):this.yw=t}loadBackingTrack(t){}open(t){this.ready.trigger()}updatePosition(t){this.timeUpdate.trigger(t)}play(){this.handler?.play()}destroy(){}pause(){this.handler?.pause()}addSamples(t){}resetSamples(){}activate(){}ready=new js;samplesPlayed=new Js;timeUpdate=new Js;sampleRequest=new js;async enumerateOutputDevices(){return[]}async setOutputDevice(t){}async getOutputDevice(){return null}},hh=class extends wa{get handler(){return this.output.handler}set handler(t){this.output.handler=t}constructor(t){super(new ah,t)}},oh=class{bounds=null;isVisible(t){const e=this.bounds;return!!e&&null!==e.findBeat(t)}},ch=class{kw=0;ow=null;Sw=null;Bw=new oh;_w=!1;We=null;xw=[];Tw=gi.Disabled;Mw;Nw;Pw;Cw;Ew;get midiTickShift(){return this.Mw.midiTickShift}get actualPlayerMode(){return this.Tw}uiFacade;container;get renderer(){return this.Nw}get score(){return this.We}settings;get tracks(){return this.xw}canvasElement;constructor(t,e){this.uiFacade=t,this.container=t.rootContainer,this.activeBeatsChanged=new Js(()=>{const t=this.Fw;return this.Mw.state===In.Playing&&t?new nh(t.beatLookup.highlightedBeats.map(t=>t.beat)):null}),this.playedBeatChanged=new Js(()=>{const t=this.Fw;return this.Mw.state===In.Playing&&t?t.beat:null}),this.scoreLoaded=new Js(()=>this.We?this.We:null),this.midiLoaded=new Js(()=>this.Mw.loadedMidiInfo??null),t.initialize(this,e),O.logLevel=this.settings.core.logLevel,this.settings.handleBackwardsCompatibility(),Bu.printEnvironmentInfo(!1),this.canvasElement=t.createCanvasElement(),this.container.appendChild(this.canvasElement),this.Nw=new qa,this.settings.core.useWorkers&&this.uiFacade.areWorkersSupported&&Bu.getRenderEngineFactory(this.settings.core.engine).supportsWorkers?this.Nw.instance=this.uiFacade.createWorkerRenderer():this.Nw.instance=new Sa(this.settings),this.container.resize.on(this.uiFacade.throttle(()=>{this._w||this.container.width!==this.Nw.width&&this.triggerResize()},t.resizeThrottle));const s=new Ya;s.oldWidth=this.Nw.width,s.newWidth=0|this.container.width,s.settings=this.settings,this.Aw(s),this.Nw.preRender.on(this.Dw.bind(this)),this.Nw.renderFinished.on(t=>{this._b(t)}),this.Nw.postRenderFinished.on(()=>{const t=Date.now()-this.kw;O.debug("rendering",`Rendering completed in ${t}ms`),this.Lw()}),this.Nw.preRender.on(t=>{this.kw=Date.now()}),this.Nw.partialLayoutFinished.on(t=>this.Ww(t,!1)),this.Nw.partialRenderFinished.on(this.Rw.bind(this)),this.Nw.renderFinished.on(t=>{this.Ww(t,!0)}),this.Nw.error.on(this.onError.bind(this)),this.Ow(),this.settings.player.playerMode!==gi.Disabled&&this.Iw(),this.Gw(),this.uiFacade.beginInvoke(()=>{this.uiFacade.initialRender()})}Ow(){const t=new rh;this.Mw=t,t.ready.on(()=>{this.loadMidiForScore()}),t.readyForPlayback.on(()=>{if(this.Hw(),this.tracks)for(const e of this.tracks){const s=e.playbackInfo.volume/16;t.setChannelVolume(e.playbackInfo.primaryChannel,s),t.setChannelVolume(e.playbackInfo.secondaryChannel,s)}}),t.soundFontLoaded.on(this.$w.bind(this)),t.soundFontLoadFailed.on(t=>{this.onError(t)}),t.midiLoaded.on(this.Vw.bind(this)),t.midiLoadFailed.on(t=>{this.onError(t)}),t.stateChanged.on(this.zw.bind(this)),t.positionChanged.on(this.Uw.bind(this)),t.midiEventsPlayed.on(this.Xw.bind(this)),t.playbackRangeChanged.on(this.jw.bind(this)),t.finished.on(this.Jw.bind(this))}destroy(){this._w=!0,this.Mw.destroy(),this.uiFacade.destroy(),this.Nw.destroy()}updateSettings(){this.settings.handleBackwardsCompatibility();const t=this.score;t&&Bt.applyPitchOffsets(this.settings,t),this.qw(),this.Nw.updateSettings(this.settings),this.Iw(),this.Yw()}qw(){const t=this.Nw;this.settings.core.useWorkers&&this.uiFacade.areWorkersSupported&&Bu.getRenderEngineFactory(this.settings.core.engine).supportsWorkers?t.instance instanceof Sa&&(t.destroy(),t.instance=this.uiFacade.createWorkerRenderer()):t.instance instanceof Sa||(t.destroy(),t.instance=new Sa(this.settings))}load(t,e){try{return this.uiFacade.load(t,t=>{this.renderScore(t,e)},t=>{this.onError(t)})}catch(t){return this.onError(t),!1}}renderScore(t,e,s){const i=[];if(e)if(0===e.length)t.tracks.length>0&&i.push(t.tracks[0]);else if(1===e.length&&-1===e[0])for(const e of t.tracks)i.push(e);else for(const s of e)s>=0&&s<=t.tracks.length&&i.push(t.tracks[s]);else t.tracks.length>0&&i.push(t.tracks[0]);this.Kw(t,i,s)}renderTracks(t,e){if(t.length>0){const s=t[0].score;for(const e of t)if(e.score!==s)return void this.onError(new a(r.General,"All rendered tracks must belong to the same score."));this.Kw(s,t,e)}}Kw(t,e,s){if(Bt.applyPitchOffsets(this.settings,t),t!==this.score){this.We=t,this.xw=e,this.Qw=null,this.ow=[];for(const t of e)this.ow.push(t.index);this.Sw=new Set(this.ow),this.Zw(t),this.loadMidiForScore(),this.render(s)}else{this.xw=e;const i=Bt.computeFirstDisplayedBarIndex(t,this.settings),n=Bt.computeLastDisplayedBarIndex(t,this.settings,i);this.Qw&&(this.Qw.multiBarRestInfo=Bt.buildMultiBarRestInfo(this.tracks,i,n)),this.ow=[];for(const t of e)this.ow.push(t.index);this.Sw=new Set(this.ow),this.render(s)}}triggerResize(){if(this.container.isVisible){const t=new Ya;t.oldWidth=this.Nw.width,t.newWidth=this.container.width,t.settings=this.settings,this.Aw(t),this.Nw.updateSettings(this.settings),this.Nw.width=this.container.width,this.Nw.resizeRender()}else O.warning("Rendering","AlphaTab container was invisible while autosizing, waiting for element to become visible",null),this.uiFacade.rootContainerBecameVisible.on(()=>{O.debug("Rendering","AlphaTab container became visible, doing autosizing",null),this.triggerResize()})}Ww(t,e){e&&(this.canvasElement.width=t.totalWidth,this.canvasElement.height=t.totalHeight,this.ty&&(this.ty.width=t.totalWidth,this.ty.height=t.totalHeight)),(t.width>0||t.height>0)&&this.uiFacade.beginAppendRenderResults(t),e&&this.uiFacade.beginAppendRenderResults(null)}Rw(t){t&&t.renderResult&&this.uiFacade.beginUpdateRenderResults(t)}tex(t,e){try{const s=new $e;s.logErrors=!0,s.initFromString(t,this.settings);const i=s.readScore();this.renderScore(i,e)}catch(t){this.onError(t)}}loadSoundFont(t,e=!1){return this.uiFacade.loadSoundFont(t,e)}resetSoundFonts(){this.Mw.resetSoundFonts()}render(t){this.uiFacade.canRender?(this.Nw.width=this.container.width,this.Nw.renderScore(this.score,this.ow,t)):this.uiFacade.canRenderChanged.on(()=>this.render(t))}get customCursorHandler(){return this.Ew}set customCursorHandler(t){if(this.Ew===t)return;const e=this.Ew??this.Cw;if(this.Ew=t,this.ty){const s=new Yn(this.ty,this.ey,this.sy,this.iy);e?.onDetach(s),t?t?.onDetach(s):this.Cw&&this.Cw.onAttach(s)}}Qw=null;customScrollHandler;get tickCache(){return this.Qw}get boundsLookup(){return this.Nw.boundsLookup}get player(){return this.Mw.instance?this.Mw:null}get isReadyForPlayback(){return this.Mw.isReadyForPlayback}get playerState(){return this.Mw.state}get masterVolume(){return this.Mw.masterVolume}set masterVolume(t){this.Mw.masterVolume=t}get metronomeVolume(){return this.Mw.metronomeVolume}set metronomeVolume(t){this.Mw.metronomeVolume=t}get countInVolume(){return this.Mw.countInVolume}set countInVolume(t){this.Mw.countInVolume=t}get midiEventsPlayedFilter(){return this.Mw.midiEventsPlayedFilter}set midiEventsPlayedFilter(t){this.Mw.midiEventsPlayedFilter=t}get tickPosition(){return this.Mw.tickPosition}set tickPosition(t){this.Mw.tickPosition=t}get timePosition(){return this.Mw.timePosition}set timePosition(t){this.Mw.timePosition=t}get endTick(){return this.Mw.currentPosition.endTick}get endTime(){return this.Mw.currentPosition.endTime}get playbackRange(){return this.Mw.playbackRange}set playbackRange(t){this.Mw.playbackRange=t,this.Qw&&(this.Qw.playbackRange=t),this.ny(t)}get playbackSpeed(){return this.Mw.playbackSpeed}set playbackSpeed(t){this.Mw.playbackSpeed=t}get isLooping(){return this.Mw.isLooping}set isLooping(t){this.Mw.isLooping=t}hy(){this.Mw.destroy(),this.oy=0,this.ly()}Iw(){let t=this.settings.player.playerMode;if(t===gi.EnabledAutomatic){const e=this.score;if(!e)return!1;t=e?.backingTrack?.rawAudioFile?gi.EnabledBackingTrack:gi.EnabledSynthesizer}let e=null;if(t===this.Tw)return this.uy(),!1;switch(this.hy(),this.uy(),t){case gi.Disabled:e=null;break;case gi.EnabledSynthesizer:e=this.uiFacade.createWorkerPlayer();break;case gi.EnabledBackingTrack:e=this.uiFacade.createBackingTrackPlayer();break;case gi.EnabledExternalMedia:e=new hh(this.settings.player.bufferTimeInMilliseconds)}return this.Tw=t,!!e&&(this.Mw.instance=e,!1)}loadMidiForScore(){if(!this.score)return;const t=this.score;O.debug("AlphaTab","Generating Midi");const e=new kn,s=new Ma(e),i=new $a(t,this.settings,s),n=Bt.computeFirstDisplayedBarIndex(t,this.settings),r=Bt.computeLastDisplayedBarIndex(t,this.settings,n);i.tickLookup.multiBarRestInfo=Bt.buildMultiBarRestInfo(this.tracks,n,r),i.applyTranspositionPitches=!1,i.generate(),this.Qw=i.tickLookup,this.Qw.playbackRange=this.playbackRange,this.py(e);const a=this.Mw;a.midiTickShift=s.tickShift,a.loadMidiFile(e),a.loadBackingTrack(t),a.updateSyncPoints(i.syncPoints),a.applyTranspositionPitches(i.transpositionPitches)}updateSyncPoints(){if(!this.score)return;const t=this.score;this.Mw.updateSyncPoints($a.generateSyncPoints(t))}changeTrackVolume(t,e){for(const s of t)this.Mw.setChannelVolume(s.playbackInfo.primaryChannel,e),this.Mw.setChannelVolume(s.playbackInfo.secondaryChannel,e)}changeTrackSolo(t,e){for(const s of t)this.Mw.setChannelSolo(s.playbackInfo.primaryChannel,e),this.Mw.setChannelSolo(s.playbackInfo.secondaryChannel,e)}changeTrackMute(t,e){for(const s of t)this.Mw.setChannelMute(s.playbackInfo.primaryChannel,e),this.Mw.setChannelMute(s.playbackInfo.secondaryChannel,e)}changeTrackTranspositionPitch(t,e){for(const s of t)this.Mw.setChannelTranspositionPitch(s.playbackInfo.primaryChannel,e),this.Mw.setChannelTranspositionPitch(s.playbackInfo.secondaryChannel,e)}play(){return this.Mw.play()}pause(){this.Mw.pause()}playPause(){this.Mw.playPause()}stop(){this.Mw.stop()}playBeat(t){const e=new kn,s=new Ma(e);new $a(t.voice.bar.staff.track.score,this.settings,s).generateSingleBeat(t),this.Mw.playOneTimeMidiFile(e)}playNote(t){const e=new kn,s=new Ma(e);new $a(t.beat.voice.bar.staff.track.score,this.settings,s).generateSingleNote(t),this.Mw.playOneTimeMidiFile(e)}ty=null;ey=null;sy=null;iy=null;oy=0;Fw=null;by=null;my=!0;gy=In.Paused;wy=null;ly(){this.ty&&((this.customCursorHandler??this.Cw)?.onDetach(new Yn(this.ty,this.ey,this.sy,this.iy)),this.uiFacade.destroyCursors(),this.ty=null,this.ey=null,this.sy=null,this.iy=null)}yy(){if(this.ty)return;const t=this.uiFacade.createCursors();t&&(this.ty=t.cursorWrapper,this.ey=t.barCursor,this.sy=t.beatCursor,this.iy=t.selectionWrapper,(this.customCursorHandler??this.Cw)?.onAttach(t),this.my=!0);const e=this.Fw;e&&this.ky(e,!1,this.oy>10,1,!0)}uy(){this.Sy(),this.By();const t=this._y;t?this.yy():!t&&this.ty&&this.ly()}xy=!1;Sy(){const t=this.Cw,e=this.settings.player.enableAnimatedBeatCursor;void 0!==t&&this.xy===e||(this.Cw=e?new Va:new za)}Ty=fi.Off;My=!0;By(){const t=this.Pw,e=this.settings.player.scrollMode,s=Bu.getLayoutEngineFactory(this.settings.display.layoutMode).vertical;if(this.Ty!==e||this.My!==s){if(t){t[Symbol.dispose]();const e=this.uiFacade.getScrollContainer();this.uiFacade.stopScrolling(e)}switch(e){case fi.Off:this.Pw=void 0;break;case fi.Continuous:this.Pw=s?new Qa(this):new eh(this);break;case fi.OffScreen:this.Pw=s?new Za(this):new sh(this);break;case fi.Smooth:this.Pw=s?new th(this):new ih(this)}}}vy(t,e,s,i=!1,n=!1){this.oy=t;const r=this.Qw;if(r){const a=r.findBeatWithChecker(this.Bw,t,this.Fw);a&&this.ky(a,e,i,s,n||this.playerState===In.Paused)}}ky(t,e,s,i,n=!1){const r=t.beat;if(!r)return;const a=this.Nw.boundsLookup;if(!a)return;const h=this.Fw,o=this.wy,c=this.gy;if(!n&&r===h?.beat&&a===o&&c===this.Mw.state&&h?.start===t.start)return;const l=a.findBeat(r);l&&(this.Fw=t,this.wy=a,this.gy=this.Mw.state,this.uiFacade.beginInvoke(()=>{this.Ny(t,e,a,l,s,i,n)}))}scrollToCursor(){const t=this.by;if(t){const e=this.customScrollHandler??this.Pw;e&&e.forceScrollTo(t)}}Ny(t,e,s,i,n,r,a){const h=t.beat,o=t.nextBeat?.beat;let c=t.duration;const l=t.beatLookup.highlightedBeats,u=t.cursorMode,d=this.customCursorHandler??this.Cw,f=this.sy,p=this.ey,b=i.barBounds.masterBarBounds,m=b.visualBounds,g=this.by;this.by=i,p&&d.placeBarCursor(p,i);const w=this.Mw.state===In.Playing&&!e;let y=i.realBounds.x+i.realBounds.w,k=null;o&&u===Da.ToNextBext&&(k=s.findBeat(o),k&&k.barBounds.masterBarBounds.staffSystemBounds===b.staffSystemBounds&&(y=k.onNotesX));let S=i.onNotesX;if(f){const e=y-i.onNotesX,s=this.oy-t.start;let n=t.tickDuration>0?s/t.tickDuration:0;n>1&&(n=1),S=i.onNotesX+e*n,c-=c*n,c/=r,w?((!g||a||this.my||m.y!==g.barBounds.masterBarBounds.visualBounds.y||S<g.onNotesX||b.index>g.barBounds.masterBarBounds.index+1||m.h!==g.barBounds.masterBarBounds.visualBounds.h)&&d.placeBeatCursor(f,i,S),this.uiFacade.beginInvoke(()=>{d.transitionBeatCursor(f,i,S,y,c,u)})):(c=0,d.placeBeatCursor(f,i,S)),this.my=!1}else this.my=!0;this.uiFacade.removeHighlights();let B=!1;if(w){if(this.settings.player.enableElementHighlighting)for(const t of l){const e=Ja.getGroupId(t.beat);this.uiFacade.highlightElements(e,h.voice.bar.index)}n=!e,B=!0}if(n&&!this.Py&&this.settings.player.scrollMode!==fi.Off){const t=this.customScrollHandler??this.Pw;t&&t.onBeatCursorUpdating(i,null===k?void 0:k,u,S,y,c)}B&&(this.Cy(h),this.Ey(new nh(l.map(t=>t.beat))))}playedBeatChanged;Cy(t){this._w||(this.playedBeatChanged.trigger(t),this.uiFacade.triggerEvent(this.container,"playedBeatChanged",t))}activeBeatsChanged;Ey(t){this._w||(this.activeBeatsChanged.trigger(t),this.uiFacade.triggerEvent(this.container,"activeBeatsChanged",t))}Py=!1;Fy=!1;Ay;Dy;beatMouseDown=new Js;beatMouseMove=new Js;beatMouseUp=new Js;noteMouseDown=new Js;noteMouseMove=new Js;noteMouseUp=new Js;get _y(){return this.settings.player.playerMode!==gi.Disabled&&this.settings.player.enableCursor}Ly(t,e){this._w||(this._y&&this.settings.player.enableUserInteraction&&(this.Ay={beat:e},this.Dy=void 0),this.Py=!0,this.beatMouseDown.trigger(e),this.uiFacade.triggerEvent(this.container,"beatMouseDown",e,t))}Wy(t,e){this._w||(this.Fy=!0,this.noteMouseDown.trigger(e),this.uiFacade.triggerEvent(this.container,"noteMouseDown",e,t))}Ry(t,e){this._w||(this.settings.player.enableUserInteraction&&(this.Dy&&this.Dy.beat===e||(this.Dy={beat:e},this.Oy(this.Ay,this.Dy))),this.beatMouseMove.trigger(e),this.uiFacade.triggerEvent(this.container,"beatMouseMove",e,t))}Iy(t,e){this._w||(this.noteMouseMove.trigger(e),this.uiFacade.triggerEvent(this.container,"noteMouseMove",e,t))}Gy(t,e){this._w||(this._y&&this.settings.player.enableUserInteraction&&this.applyPlaybackRangeFromHighlight(),this.beatMouseUp.trigger(e),this.uiFacade.triggerEvent(this.container,"beatMouseUp",e,t),this.Py=!1)}Hy(t,e){this._w||(this.noteMouseUp.trigger(e),this.uiFacade.triggerEvent(this.container,"noteMouseUp",e,t),this.Fy=!1)}ny(t){if(this.Qw)if(t){const e=this.Qw.findBeat(this.Sw,t.startTick),s=this.Qw.findBeat(this.Sw,t.endTick);if(e&&s){const t={beat:e.beat},i={beat:s.beat};this.Oy(t,i)}}else this.Oy(void 0,void 0)}Gw(){this.canvasElement.mouseDown.on(t=>{if(!t.isLeftMouseButton)return;this.settings.player.enableUserInteraction&&t.preventDefault();const e=t.getX(this.canvasElement),s=t.getY(this.canvasElement),i=this.Nw.boundsLookup?.getBeatAtPos(e,s)??null;if(i&&(this.Ly(t,i),this.settings.core.includeNoteBounds)){const n=this.Nw.boundsLookup?.getNoteAtPos(i,e,s);n&&this.Wy(t,n)}}),this.canvasElement.mouseMove.on(t=>{if(!this.Py)return;const e=t.getX(this.canvasElement),s=t.getY(this.canvasElement),i=this.Nw.boundsLookup?.getBeatAtPos(e,s)??null;if(i&&(this.Ry(t,i),this.Fy)){const n=this.Nw.boundsLookup?.getNoteAtPos(i,e,s);n&&this.Iy(t,n)}}),this.canvasElement.mouseUp.on(t=>{if(!this.Py)return;this.settings.player.enableUserInteraction&&t.preventDefault();const e=t.getX(this.canvasElement),s=t.getY(this.canvasElement),i=this.Nw.boundsLookup?.getBeatAtPos(e,s)??null;if(this.Gy(t,i),this.Fy)if(i){const n=this.Nw.boundsLookup?.getNoteAtPos(i,e,s)??null;this.Hy(t,n)}else this.Hy(t,null)}),this.Nw.postRenderFinished.on(()=>{this.Ay&&this._y&&this.settings.player.enableUserInteraction&&this.Oy(this.Ay,this.Dy)})}highlightPlaybackRange(t,e){this.Ay={beat:t},this.Dy={beat:e},this.Oy(this.Ay,this.Dy)}applyPlaybackRangeFromHighlight(){if(this.Dy){const t=this.Qw?.getBeatStart(this.Ay.beat)??this.Ay.beat.absolutePlaybackStart;if((this.Qw?.getBeatStart(this.Dy.beat)??this.Dy.beat.absolutePlaybackStart)<t){const t=this.Ay;this.Ay=this.Dy,this.Dy=t}}if(this.Ay&&this.Qw){const t=this.Qw,e=t.getMasterBarStart(this.Ay.beat.voice.bar.masterBar),s=t.getRelativeBeatPlaybackRange(this.Ay.beat)?.startTick??this.Ay.beat.playbackStart;if(this.Fw=null,this.Mw.state===In.Paused&&this.vy(e+s,!1,1),this.tickPosition=e+s,this.Dy&&this.Ay.beat!==this.Dy.beat){const i=t.getMasterBarStart(this.Dy.beat.voice.bar.masterBar),n=t.getRelativeBeatPlaybackRange(this.Dy.beat)?.endTick??this.Dy.beat.playbackStart+this.Dy.beat.playbackDuration,r=new Aa;r.startTick=e+s,r.endTick=i+n-50,this.playbackRange=r}else this.Ay=void 0,this.playbackRange=null,this.Oy(this.Ay,this.Dy)}}clearPlaybackRangeHighlight(){this.Oy(void 0,void 0)}playbackRangeHighlightChanged=new Js;Oy(t,e){const s=this.Nw.boundsLookup;if(!s)return void this.playbackRangeHighlightChanged.trigger({});const i=this.iy;if(!i)return void this.playbackRangeHighlightChanged.trigger({});if(i.clear(),!t||!e||t.beat===e.beat)return void this.playbackRangeHighlightChanged.trigger({});t.bounds||(t.bounds=s.findBeat(t.beat)??void 0),e.bounds||(e.bounds=s.findBeat(e.beat)??void 0);const n=this.Qw?.getBeatStart(t.beat)??t.beat.absolutePlaybackStart;if((this.Qw?.getBeatStart(e.beat)??e.beat.absolutePlaybackStart)<n){const s=t;t=e,e=s}const r={startBeat:t.beat,startBeatBounds:t.bounds,endBeat:e.beat,endBeatBounds:e.bounds,highlightBlocks:[]};let a=t.bounds.realBounds.x;0===t.beat.index&&(a=t.bounds.barBounds.masterBarBounds.realBounds.x);let h=e.bounds.realBounds.x+e.bounds.realBounds.w;if(e.beat.index===e.beat.voice.beats.length-1&&(h=e.bounds.barBounds.masterBarBounds.realBounds.x+e.bounds.barBounds.masterBarBounds.realBounds.w),t.bounds.barBounds.masterBarBounds.staffSystemBounds!==e.bounds.barBounds.masterBarBounds.staffSystemBounds){const n=t.bounds.barBounds.masterBarBounds.staffSystemBounds.visualBounds.x,o=t.bounds.barBounds.masterBarBounds.staffSystemBounds.visualBounds.x+t.bounds.barBounds.masterBarBounds.staffSystemBounds.visualBounds.w,c=this.uiFacade.createSelectionElement(),l=new _s(a,t.bounds.barBounds.masterBarBounds.visualBounds.y,o-a,t.bounds.barBounds.masterBarBounds.visualBounds.h);c.setBounds(l.x,l.y,l.w,l.h),r.highlightBlocks.push(l),i.appendChild(c);const u=t.bounds.barBounds.masterBarBounds.staffSystemBounds.index+1,d=e.bounds.barBounds.masterBarBounds.staffSystemBounds.index;for(let t=u;t<d;t++){const e=s.staffSystems[t],a=this.uiFacade.createSelectionElement(),h=new _s(n,e.visualBounds.y,o-n,e.visualBounds.h);r.highlightBlocks.push(h),a.setBounds(h.x,h.y,h.w,h.h),i.appendChild(a)}const f=this.uiFacade.createSelectionElement(),p=new _s(n,e.bounds.barBounds.masterBarBounds.visualBounds.y,h-n,e.bounds.barBounds.masterBarBounds.visualBounds.h);r.highlightBlocks.push(p),f.setBounds(p.x,p.y,p.w,p.h),i.appendChild(f)}else{const e=this.uiFacade.createSelectionElement(),s=new _s(a,t.bounds.barBounds.masterBarBounds.visualBounds.y,h-a,t.bounds.barBounds.masterBarBounds.visualBounds.h);e.setBounds(s.x,s.y,s.w,s.h),r.highlightBlocks.push(s),i.appendChild(e)}this.playbackRangeHighlightChanged.trigger(r)}scoreLoaded;Zw(t){this._w||(this.scoreLoaded.trigger(t),this.uiFacade.triggerEvent(this.container,"scoreLoaded",t),this.Iw()||this.loadMidiForScore())}resize=new Js;Aw(t){this._w||(this.resize.trigger(t),this.uiFacade.triggerEvent(this.container,"resize",t))}renderStarted=new Js;Dw(t){this._w||(this.renderStarted.trigger(t),this.uiFacade.triggerEvent(this.container,"renderStarted",t))}renderFinished=new Js;_b(t){this._w||(this.renderFinished.trigger(t),this.uiFacade.triggerEvent(this.container,"renderFinished",t))}postRenderFinished=new js;Lw(){this._w||(this.Bw.bounds=this.boundsLookup,this.Fw=null,this.vy(this.oy,!1,1,!0,!0),this.Ay&&this.highlightPlaybackRange(this.Ay.beat,this.Dy.beat),this.postRenderFinished.trigger(),this.uiFacade.triggerEvent(this.container,"postRenderFinished",null))}error=new Js;onError(t){this._w||(O.error("API","An unexpected error occurred",t),this.error.trigger(t),this.uiFacade.triggerEvent(this.container,"error",t))}get playerReady(){return this.Mw.readyForPlayback}Hw(){this._w||this.uiFacade.triggerEvent(this.container,"playerReady",null)}get playerFinished(){return this.Mw.finished}Jw(){this._w||this.uiFacade.triggerEvent(this.container,"playerFinished",null)}get soundFontLoaded(){return this.Mw.soundFontLoaded}$w(){this._w||this.uiFacade.triggerEvent(this.container,"soundFontLoaded",null)}midiLoad=new Js;py(t){this._w||(this.midiLoad.trigger(t),this.uiFacade.triggerEvent(this.container,"midiLoad",t))}midiLoaded;Vw(t){this._w||(this.midiLoaded.trigger(t),this.uiFacade.triggerEvent(this.container,"midiFileLoaded",t))}get playerStateChanged(){return this.Mw.stateChanged}zw(t){if(!this._w){if(!t.stopped&&t.state===In.Paused){const t=this.Fw,e=this.Qw;t&&e&&(this.Mw.tickPosition=e.getBeatStart(t.beat),this.scrollToCursor())}this.uiFacade.triggerEvent(this.container,"playerStateChanged",t)}}get playerPositionChanged(){return this.Mw.positionChanged}Uw(t){this._w||(this.uiFacade.beginInvoke(()=>{const e=t.modifiedTempo/t.originalTempo;this.vy(t.currentTick,!1,e,!1,t.isSeek)}),this.uiFacade.triggerEvent(this.container,"playerPositionChanged",t))}get midiEventsPlayed(){return this.Mw.midiEventsPlayed}Xw(t){this._w||this.uiFacade.triggerEvent(this.container,"midiEventsPlayed",t)}get playbackRangeChanged(){return this.Mw.playbackRangeChanged}jw(t){this._w||this.uiFacade.triggerEvent(this.container,"playbackRangeChanged",t)}settingsUpdated=new js;Yw(){this._w||(this.settingsUpdated.trigger(),this.uiFacade.triggerEvent(this.container,"settingsUpdated",null))}async enumerateOutputDevices(){return await this.Mw.output.enumerateOutputDevices()}async setOutputDevice(t){await this.Mw.output.setOutputDevice(t)}async getOutputDevice(){return await this.Mw.output.getOutputDevice()}async exportAudio(t){if(!this.score)throw new a(r.General,"No song loaded");let e;if(this.Tw===gi.EnabledSynthesizer)e=this.uiFacade.createWorkerAudioExporter(this.Mw.instance);else e=this.uiFacade.createWorkerAudioExporter(null);const s=this.score,i=new kn,n=new Ma(i),h=new $a(s,this.settings,n);h.applyTranspositionPitches=!1,h.generate();const o=new er;o.soundFonts=t.soundFonts,o.sampleRate=t.sampleRate,o.useSyncPoints=t.useSyncPoints,o.masterVolume=t.masterVolume,o.metronomeVolume=t.metronomeVolume,o.playbackRange=t.playbackRange;for(const[e,s]of t.trackVolume)if(e<this.score.tracks.length){const t=this.score.tracks[e];o.trackVolume.set(t.playbackInfo.primaryChannel,s),o.trackVolume.set(t.playbackInfo.secondaryChannel,s)}for(const[e,s]of t.trackTranspositionPitches)if(e<this.score.tracks.length){const t=this.score.tracks[e];o.trackTranspositionPitches.set(t.playbackInfo.primaryChannel,s),o.trackTranspositionPitches.set(t.playbackInfo.secondaryChannel,s)}return await e.initialize(o,i,h.syncPoints,h.transpositionPitches),e}},lh=class{loaded;total;constructor(t,e){this.loaded=t,this.total=e}},uh=class t extends ch{constructor(t,e){super(new Ba(t),e)}tex(t,e){const s=this.uiFacade;super.tex(t,s.parseTracks(e))}print(e,s=null){const i=window.open("","","width=0,height=0"),n=i.document.createElement("div");e?n.style.width=e:this.settings.display.layoutMode===Xs.Horizontal?n.style.width="297mm":n.style.width="210mm",i.document.write("\n        <!DOCTYPE html>\n        <html>\n          <head>\n            <style>\n            .at-surface {\n                width: auto !important;\n                height: auto !important;\n            }\n            .at-surface > div {\n                position: relative!important;\n                left: auto !important;\n                top: auto !important;\n                break-inside: avoid;\n            }\n            </style>\n          </head>\n          <body></body>\n        </html>\n        ");const r=this.score;r&&(r.artist&&r.title?i.document.title=`${r.title} - ${r.artist}`:r.title&&(i.document.title=`${r.title}`)),i.document.body.appendChild(n);const a=void 0!==window.screenLeft?window.screenLeft:window.left,h=void 0!==window.screenTop?window.screenTop:window.top,o="innerWidth"in window?window.innerWidth:"clientWidth"in document.documentElement?document.documentElement.clientWidth:window.screen.width,c="innerHeight"in window?window.innerHeight:"clientHeight"in document.documentElement?document.documentElement.clientHeight:window.screen.height,l=n.offsetWidth+50,u=window.innerHeight,d=(o/2|0)-(l/2|0)+a,f=(c/2|0)-(u/2|0)+h;i.resizeTo(l,u),i.moveTo(d,f),i.focus();const p=Wn.jsObjectToSettings(Wn.settingsToJsObject(this.settings));p.core.enableLazyLoading=!1,p.core.useWorkers=!0,p.core.file=null,p.core.tracks=null,p.player.enableCursor=!1,p.player.playerMode=gi.Disabled,p.player.enableElementHighlighting=!1,p.player.enableUserInteraction=!1,p.player.soundFont=null,p.display.scale=.8,p.display.stretchForce=.8,Ci.fromJson(p,s);const b=new t(n,p);i.onunload=()=>{b.destroy()},b.renderer.postRenderFinished.on(()=>{i.print()}),b.renderTracks(this.tracks)}downloadMidi(t=wn.SingleTrackMultiChannel){if(!this.score)return;const e=new kn;e.format=t;const s=new Ma(e,!0);new $a(this.score,this.settings,s).generate();const i=e.toBinary(),n=this.score.title?`${this.score.title}.mid`:"File.mid",r=document.createElement("a");r.download=n;const a=new Blob([i],{type:"audio/midi"});r.href=URL.createObjectURL(a),r.style.display="none",document.body.appendChild(r),r.click(),document.body.removeChild(r)}changeTrackMute(t,e){const s=this.$y(this.uiFacade.parseTracks(t));super.changeTrackMute(s,e)}changeTrackSolo(t,e){const s=this.$y(this.uiFacade.parseTracks(t));super.changeTrackSolo(s,e)}changeTrackVolume(t,e){const s=this.$y(this.uiFacade.parseTracks(t));super.changeTrackVolume(s,e)}$y(t){if(!this.score)return[];const e=[];if(1===t.length&&-1===t[0])for(const t of this.score.tracks)e.push(t);else for(const s of t)s>=0&&s<this.score.tracks.length&&e.push(this.score.tracks[s]);return e}soundFontLoad=new Js;loadSoundFontFromUrl(t,e){const s=this.player;if(!s)return;O.debug("AlphaSynth",`Start loading Soundfont from url ${t}`);const i=new XMLHttpRequest;i.open("GET",t,!0,null,null),i.responseType="arraybuffer",i.onload=t=>{const s=new Uint8Array(i.response);this.loadSoundFont(s,e)},i.onerror=t=>{O.error("AlphaSynth",`Loading failed: ${t.message}`),s.soundFontLoadFailed.trigger(new Qs(t.message,i))},i.onprogress=t=>{O.debug("AlphaSynth",`Soundfont downloading: ${t.loaded}/${t.total} bytes`);const e=new lh(t.loaded,t.total);this.soundFontLoad.trigger(e),this.uiFacade.triggerEvent(this.container,"soundFontLoad",e)},i.send()}},dh=class{exec(t,e,s){if("string"!=typeof e&&(s=[e],e="init"),95===e.charCodeAt(0)||"exec"===e)return null;const i=new jQuery(t),n=i.data("alphaTab");if("destroy"===e&&!n)return null;if("init"!==e&&!n)throw new Error("alphaTab not initialized");const r=this[e];if(r){const t=[i,n].concat(s);return r.apply(this,t)}return O.error("Api",`Method '${e}' does not exist on jQuery.alphaTab`),null}init(t,e,s){if(!e){e=new uh(t[0],s),t.data("alphaTab",e);for(const i of this.Vy)i(t,e,s)}}destroy(t,e){t.removeData("alphaTab"),e.destroy()}print(t,e,s,i){e.print(s,i)}load(t,e,s,i){return e.load(s,i)}render(t,e){e.render()}renderScore(t,e,s,i){e.renderScore(s,i)}renderTracks(t,e,s){e.renderTracks(s)}invalidate(t,e){e.render()}tex(t,e,s,i){e.tex(s,i)}muteTrack(t,e,s,i){e.changeTrackMute(s,i)}soloTrack(t,e,s,i){e.changeTrackSolo(s,i)}trackVolume(t,e,s,i){e.changeTrackVolume(s,i)}loadSoundFont(t,e,s,i){e.loadSoundFont(s,i)}resetSoundFonts(t,e){e.resetSoundFonts()}pause(t,e){e.pause()}play(t,e){return e.play()}playPause(t,e){e.playPause()}stop(t,e){e.stop()}api(t,e){return e}player(t,e){return e.player}isReadyForPlayback(t,e){return e.isReadyForPlayback}playerState(t,e){return e.playerState}masterVolume(t,e,s){return"number"==typeof s&&(e.masterVolume=s),e.masterVolume}metronomeVolume(t,e,s){return"number"==typeof s&&(e.metronomeVolume=s),e.metronomeVolume}countInVolume(t,e,s){return"number"==typeof s&&(e.countInVolume=s),e.countInVolume}midiEventsPlayedFilter(t,e,s){return Array.isArray(s)&&(e.midiEventsPlayedFilter=s),e.midiEventsPlayedFilter}playbackSpeed(t,e,s){return"number"==typeof s&&(e.playbackSpeed=s),e.playbackSpeed}tickPosition(t,e,s){return"number"==typeof s&&(e.tickPosition=s),e.tickPosition}timePosition(t,e,s){return"number"==typeof s&&(e.timePosition=s),e.timePosition}loop(t,e,s){return"boolean"==typeof s&&(e.isLooping=s),e.isLooping}renderer(t,e){return e.renderer}score(t,e){return e.score}settings(t,e){return e.settings}tracks(t,e){return e.tracks}Vy=[];zy(t){this.Vy.push(t)}static restore(t){new jQuery(t).empty().removeData("alphaTab")}};function fh(){var t="function"==typeof SuppressedError?SuppressedError:function(t,e){var s=Error();return s.name="SuppressedError",s.error=t,s.suppressed=e,s},e={},s=[];function i(t,e){if(null!=e){if(Object(e)!==e)throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");if(t)var i=e[Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose")];if(void 0===i&&(i=e[Symbol.dispose||Symbol.for("Symbol.dispose")],t))var n=i;if("function"!=typeof i)throw new TypeError("Object is not disposable.");n&&(i=function(){try{n.call(e)}catch(t){return Promise.reject(t)}}),s.push({v:e,d:i,a:t})}else t&&s.push({d:e,a:t});return e}return{e:e,u:i.bind(null,!1),a:i.bind(null,!0),d:function(){var i,n=this.e,r=0;function a(){for(;i=s.pop();)try{if(!i.a&&1===r)return r=0,s.push(i),Promise.resolve().then(a);if(i.d){var t=i.d.call(i.v);if(i.a)return r|=2,Promise.resolve(t).then(a,h)}else r|=1}catch(t){return h(t)}if(1===r)return n!==e?Promise.reject(n):Promise.resolve();if(n!==e)throw n}function h(s){return n=n!==e?new t(s,n):s,a()}return a()}}}var ph=class t{static Uy;static Xy=null;static enable(e,s){t.Uy=s,t.initializeMusicFont(t.Uy.AlphaSkiaTypeface.register(e))}static initializeMusicFont(e){t.Xy=new t.Uy.AlphaSkiaTextStyle([e.familyName],e.weight,e.isItalic)}static registerFont(e,s){const i=t.Uy.AlphaSkiaTypeface.register(e.buffer);return s||(s=hi.withFamilyList([i.familyName],12,i.isItalic?ri.Italic:ri.Plain,i.weight>400?ai.Bold:ai.Regular)),s}ym;Sm=new Se(0,0,0,0);xm=0;jy=null;Jy=1;qy=new Map;Bm=new hi("Arial",10,ri.Plain);Yy=null;settings;get font(){return this.Bm}set font(e){if(this.Bm===e)return;this.Bm=e;const s=this.Ky(e);if(this.qy.has(s))this.jy=this.qy.get(s);else{const i=new t.Uy.AlphaSkiaTextStyle(e.families,e.weight===ai.Bold?700:400,e.isItalic);this.qy.set(s,i),this.jy=i}}Ky(t){return[...t.families,t.weight.toString(),t.isItalic?"italic":"upright"].join("_")}constructor(){this.ym=new t.Uy.AlphaSkiaCanvas,this.color=new Se(0,0,0,255)}destroy(){this.ym[Symbol.dispose]();for(const t of this.qy.values())t[Symbol.dispose]()}onRenderFinished(){return null}beginRender(e,s){this.Jy=this.settings.display.scale,this.ym.beginRender(e,s,Bu.highDpiFactor);const i=this.settings.display.resources.smuflFontFamilyName;i&&i!==t.Xy.familyNames[0]?this.qy.has(i)?this.Yy=this.qy.get(i):(this.Yy=new t.Uy.AlphaSkiaTextStyle([i],t.Xy.weight,t.Xy.isItalic),this.qy.set(i,this.Yy)):this.Yy=t.Xy}endRender(){return this.ym.endRender()}get color(){return this.Sm}set color(e){this.Sm.rgba!==e.rgba&&(this.Sm=e,this.ym.color=t.Uy.AlphaSkiaCanvas.rgbaToColor(e.r,e.g,e.b,e.a))}get lineWidth(){return this.xm}set lineWidth(t){this.xm=t,this.ym.lineWidth=t}fillRect(t,e,s,i){s>0&&this.ym.fillRect(t*this.Jy,e*this.Jy,s*this.Jy,i*this.Jy)}strokeRect(t,e,s,i){const n=this.lineWidth%2==0?0:.5;this.ym.strokeRect(t*this.Jy+n,e*this.Jy+n,s*this.Jy,i*this.Jy)}beginPath(){this.ym.beginPath()}closePath(){this.ym.closePath()}moveTo(t,e){this.ym.moveTo(t*this.Jy,e*this.Jy)}lineTo(t,e){this.ym.lineTo(t*this.Jy,e*this.Jy)}quadraticCurveTo(t,e,s,i){this.ym.quadraticCurveTo(t*this.Jy,e*this.Jy,s*this.Jy,i*this.Jy)}bezierCurveTo(t,e,s,i,n,r){this.ym.bezierCurveTo(t*this.Jy,e*this.Jy,s*this.Jy,i*this.Jy,n*this.Jy,r*this.Jy)}fillCircle(t,e,s){this.ym.fillCircle(t*this.Jy,e*this.Jy,s*this.Jy)}strokeCircle(t,e,s){this.ym.strokeCircle(t*this.Jy,e*this.Jy,s*this.Jy)}fill(){this.ym.fill()}stroke(){this.ym.stroke()}textAlign=ut.Left;textBaseline=dt.Top;beginGroup(t){}endGroup(){}fillText(e,s,i){if(0===e.length)return;let n=t.Uy.AlphaSkiaTextAlign.Left;switch(this.textAlign){case ut.Left:n=t.Uy.AlphaSkiaTextAlign.Left;break;case ut.Center:n=t.Uy.AlphaSkiaTextAlign.Center;break;case ut.Right:n=t.Uy.AlphaSkiaTextAlign.Right}let r=t.Uy.AlphaSkiaTextBaseline.Top;switch(this.textBaseline){case dt.Top:r=t.Uy.AlphaSkiaTextBaseline.Top;break;case dt.Middle:r=t.Uy.AlphaSkiaTextBaseline.Middle;break;case dt.Bottom:r=t.Uy.AlphaSkiaTextBaseline.Bottom;break;case dt.Alphabetic:r=t.Uy.AlphaSkiaTextBaseline.Alphabetic}this.ym.fillText(e,this.jy,this.Bm.size*this.Jy,s*this.Jy,i*this.Jy,n,r)}measureText(e){try{var s=fh();const i=s.u(this.ym.measureText(e,this.jy,this.Bm.size,t.Uy.AlphaSkiaTextAlign.Left,t.Uy.AlphaSkiaTextBaseline.Alphabetic)),[n,r]=this.Qy(i,e);return new ft(n,r)}catch(t){s.e=t}finally{s.d()}}Qy(t,e){let s=t.width;if(e.length>0&&s<1)for(let e=0;e<5&&(s=t.width,!(s>1));e++);return[s,t.actualBoundingBoxAscent+t.actualBoundingBoxDescent]}fillMusicFontSymbol(t,e,s,i,n){i!==xt.None&&this.Tm(t,e,s,String.fromCharCode(i),n)}fillMusicFontSymbols(t,e,s,i,n){let r="";for(const t of i)t!==xt.None&&(r+=String.fromCharCode(t));this.Tm(t,e,s,r,n)}Tm(e,s,i,n,r){this.ym.fillText(n,this.Yy,this.settings.display.resources.engravingSettings.musicFontSize*this.Jy*i,e*this.Jy,s*this.Jy,r?t.Uy.AlphaSkiaTextAlign.Center:t.Uy.AlphaSkiaTextAlign.Left,t.Uy.AlphaSkiaTextBaseline.Alphabetic)}beginRotate(t,e,s){this.ym.beginRotate(t*this.Jy,e*this.Jy,s)}endRotate(){this.ym.endRotate()}},bh=class t{buffer="";Zy="";tk=!0;scale=1;color=new Se(255,255,255,255);lineWidth=1;font=new hi("Arial",10,ri.Plain);textAlign=ut.Left;textBaseline=dt.Top;settings;destroy(){}beginRender(t,e){this.scale=this.settings.display.scale,this.buffer=`<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="${0|t}px" height="${0|e}px" class="at-surface-svg">\n`,this.Zy="",this.tk=!0,this.textBaseline=dt.Top}beginGroup(t){this.buffer+=`<g class="${t}">`}endGroup(){this.buffer+="</g>"}endRender(){return this.buffer+="</svg>",this.buffer}fillRect(t,e,s,i){s>0&&(this.buffer+=`<rect x="${t*this.scale}" y="${e*this.scale}" width="${s*this.scale}" height="${i*this.scale}" fill="${this.color.rgba}" />\n`)}strokeRect(t,e,s,i){const n=this.lineWidth*this.scale%2==0?0:.5;this.buffer+=`<rect x="${t*this.scale+n}" y="${e*this.scale+n}" width="${s*this.scale}" height="${i*this.scale}" stroke="${this.color.rgba}"`,1!==this.lineWidth&&(this.buffer+=` stroke-width="${this.lineWidth*this.scale}"`),this.buffer+=' fill="transparent" />\n'}beginPath(){}closePath(){this.Zy+=" z"}moveTo(t,e){this.Zy+=` M${t*this.scale},${e*this.scale}`}lineTo(t,e){this.tk=!1,this.Zy+=` L${t*this.scale},${e*this.scale}`}quadraticCurveTo(t,e,s,i){this.tk=!1,this.Zy+=` Q${t*this.scale},${e*this.scale},${s*this.scale},${i*this.scale}`}bezierCurveTo(t,e,s,i,n,r){this.tk=!1,this.Zy+=` C${t*this.scale},${e*this.scale},${s*this.scale},${i*this.scale},${n*this.scale},${r*this.scale}`}fillCircle(t,e,s){this.tk=!1,t*=this.scale,e*=this.scale,s*=this.scale,this.Zy+=` M${t-s},${e} A1,1 0 0,0 ${t+s},${e} A1,1 0 0,0 ${t-s},${e} z`,this.fill()}strokeCircle(t,e,s){this.tk=!1,t*=this.scale,e*=this.scale,s*=this.scale,this.Zy+=` M${t-s},${e} A1,1 0 0,0 ${t+s},${e} A1,1 0 0,0 ${t-s},${e} z`,this.stroke()}fill(){this.tk||(this.buffer+=`<path d="${this.Zy}"`,"#000000"!==this.color.rgba&&(this.buffer+=` fill="${this.color.rgba}"`),this.buffer+=' style="stroke: none"/>'),this.Zy="",this.tk=!0}stroke(){if(!this.tk){let t=`<path d="${this.Zy}" stroke="${this.color.rgba}"`;1===this.lineWidth&&1===this.scale||(t+=` stroke-width="${this.lineWidth*this.scale}"`),t+=' style="fill: none" />',this.buffer+=t}this.Zy="",this.tk=!0}fillText(e,s,i){if(""===e)return;let n=`<text x="${s*this.scale}" y="${i*this.scale}" style='stroke: none; font:${this.font.toCssString(this.settings.display.scale)}; ${this.getSvgBaseLine()}'`;"#000000"!==this.color.rgba&&(n+=` fill="${this.color.rgba}"`),this.textAlign!==ut.Left&&(n+=` text-anchor="${this.getSvgTextAlignment(this.textAlign)}"`),n+=`>${t.ek(e)}</text>`,this.buffer+=n}static ek(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}getSvgTextAlignment(t){switch(t){case ut.Left:return"start";case ut.Center:return"middle";case ut.Right:return"end"}return""}getSvgBaseLine(){switch(this.textBaseline){case dt.Top:return"dominant-baseline: hanging";case dt.Bottom:return"dominant-baseline: ideographic";case dt.Alphabetic:return"";case dt.Middle:return"dominant-baseline: middle";default:return""}}measureText(t){return t?Oi.measureString(t,this.font.families,this.font.size,this.font.style,this.font.weight):new ft(0,0)}onRenderFinished(){return null}beginRotate(t,e,s){this.buffer+=`<g transform="translate(${t*this.scale} ,${e*this.scale}) rotate( ${s})">`}endRotate(){this.buffer+="</g>"}},mh=class extends bh{fillMusicFontSymbol(t,e,s,i,n){i!==xt.None&&this.Tm(t,e,s,`&#${i};`,n)}fillMusicFontSymbols(t,e,s,i,n){let r="";for(const t of i)t!==xt.None&&(r+=`&#${t};`);this.Tm(t,e,s,r,n)}Tm(t,e,s,i,n){t*=this.scale,e*=this.scale,this.buffer+=`<g transform="translate(${t} ${e})" class="at" ><text`;const r=this.scale*s;this.buffer+=1!==r?` style="font-size: ${100*r}%; stroke:none"`:' style="stroke:none"',"#000000"!==this.color.rgba&&(this.buffer+=` fill="${this.color.rgba}"`),n&&(this.buffer+=` text-anchor="${this.getSvgTextAlignment(ut.Center)}"`),this.buffer+=`>${i}</text></g>`}},gh=class t{static preferredSampleRate=0;sk;get sampleRate(){return t.preferredSampleRate}constructor(t){this.sk=t}open(t){O.debug("AlphaSynth","Initializing synth worker"),this.sk.addEventListener("message",this.om.bind(this)),this.ready.trigger()}destroy(){this.sk.postMessage({cmd:"alphaSynth.output.destroy"})}om(t){const e=t.data;switch(e.cmd){case"alphaSynth.output.sampleRequest":this.sampleRequest.trigger();break;case"alphaSynth.output.samplesPlayed":this.samplesPlayed.trigger(e.samples)}}ready=new js;samplesPlayed=new Js;sampleRequest=new js;addSamples(t){this.sk.postMessage({cmd:"alphaSynth.output.addSamples",samples:Bu.prepareForPostMessage(t)})}play(){this.sk.postMessage({cmd:"alphaSynth.output.play"})}pause(){this.sk.postMessage({cmd:"alphaSynth.output.pause"})}resetSamples(){this.sk.postMessage({cmd:"alphaSynth.output.resetSamples"})}activate(){}async enumerateOutputDevices(){return[]}async setOutputDevice(t){}async getOutputDevice(){return null}},wh=class t{Mw;sk;ik=new Map;constructor(t){this.sk=t,t.addEventListener("message",t=>this.handleMessage(t))}static init(){new t(Bu.getGlobalWorkerScope())}handleMessage(t){const e=t.data;switch(e.cmd){case"alphaSynth.initialize":gh.preferredSampleRate=e.sampleRate,O.logLevel=e.logLevel,this.Mw=new ba(new gh(this.sk),e.bufferTimeInMilliseconds),this.Mw.positionChanged.on(t=>this.onPositionChanged(t)),this.Mw.stateChanged.on(t=>this.onPlayerStateChanged(t)),this.Mw.finished.on(()=>this.onFinished()),this.Mw.soundFontLoaded.on(()=>this.onSoundFontLoaded()),this.Mw.soundFontLoadFailed.on(t=>this.onSoundFontLoadFailed(t)),this.Mw.midiLoaded.on(t=>this.onMidiLoaded(t)),this.Mw.midiLoadFailed.on(t=>this.onMidiLoadFailed(t)),this.Mw.readyForPlayback.on(()=>this.onReadyForPlayback()),this.Mw.midiEventsPlayed.on(t=>this.onMidiEventsPlayed(t)),this.Mw.playbackRangeChanged.on(t=>this.onPlaybackRangeChanged(t)),this.sk.postMessage({cmd:"alphaSynth.ready"});break;case"alphaSynth.setLogLevel":O.logLevel=e.value;break;case"alphaSynth.setMasterVolume":this.Mw.masterVolume=e.value;break;case"alphaSynth.setMetronomeVolume":this.Mw.metronomeVolume=e.value;break;case"alphaSynth.setPlaybackSpeed":this.Mw.playbackSpeed=e.value;break;case"alphaSynth.setTickPosition":this.Mw.tickPosition=e.value;break;case"alphaSynth.setTimePosition":this.Mw.timePosition=e.value;break;case"alphaSynth.setPlaybackRange":this.Mw.playbackRange=e.value;break;case"alphaSynth.setIsLooping":this.Mw.isLooping=e.value;break;case"alphaSynth.setCountInVolume":this.Mw.countInVolume=e.value;break;case"alphaSynth.setMidiEventsPlayedFilter":this.Mw.midiEventsPlayedFilter=e.value;break;case"alphaSynth.play":this.Mw.play();break;case"alphaSynth.pause":this.Mw.pause();break;case"alphaSynth.playPause":this.Mw.playPause();break;case"alphaSynth.stop":this.Mw.stop();break;case"alphaSynth.playOneTimeMidiFile":this.Mw.playOneTimeMidiFile(Wn.jsObjectToMidiFile(e.midi));break;case"alphaSynth.loadSoundFontBytes":this.Mw.loadSoundFont(e.data,e.append);break;case"alphaSynth.resetSoundFonts":this.Mw.resetSoundFonts();break;case"alphaSynth.loadMidi":this.Mw.loadMidiFile(Wn.jsObjectToMidiFile(e.midi));break;case"alphaSynth.setChannelMute":this.Mw.setChannelMute(e.channel,e.mute);break;case"alphaSynth.setChannelTranspositionPitch":this.Mw.setChannelTranspositionPitch(e.channel,e.semitones);break;case"alphaSynth.setChannelSolo":this.Mw.setChannelSolo(e.channel,e.solo);break;case"alphaSynth.setChannelVolume":this.Mw.setChannelVolume(e.channel,e.volume);break;case"alphaSynth.resetChannelStates":this.Mw.resetChannelStates();break;case"alphaSynth.destroy":this.Mw.destroy(),this.sk.postMessage({cmd:"alphaSynth.destroyed"});break;case"alphaSynth.applyTranspositionPitches":this.Mw.applyTranspositionPitches(e.transpositionPitches)}e.cmd.startsWith("alphaSynth.exporter")&&this.nk(t)}nk(t){const e=t.data,s=e.cmd;let i,n=0;try{switch(s){case"alphaSynth.exporter.initialize":n=e.exporterId,i=this.Mw.exportAudio(e.options,Wn.jsObjectToMidiFile(e.midi),e.syncPoints,e.transpositionPitches),this.ik.set(e.exporterId,i),this.sk.postMessage({cmd:"alphaSynth.exporter.initialized",exporterId:e.exporterId});break;case"alphaSynth.exporter.render":if(n=e.exporterId,this.ik.has(e.exporterId)){i=this.ik.get(e.exporterId);const t=i.render(e.milliseconds);this.sk.postMessage({cmd:"alphaSynth.exporter.rendered",exporterId:e.exporterId,chunk:t})}else this.sk.postMessage({cmd:"alphaSynth.exporter.error",exporterId:e.exporterId,error:new Error("Unknown exporter ID")});break;case"alphaSynth.exporter.destroy":n=e.exporterId,this.ik.delete(e.exporterId)}}catch(t){this.sk.postMessage({cmd:"alphaSynth.exporter.error",exporterId:n,error:t})}}onPositionChanged(t){this.sk.postMessage({cmd:"alphaSynth.positionChanged",args:t})}onPlayerStateChanged(t){this.sk.postMessage({cmd:"alphaSynth.playerStateChanged",state:t.state,stopped:t.stopped})}onFinished(){this.sk.postMessage({cmd:"alphaSynth.finished"})}onSoundFontLoaded(){this.sk.postMessage({cmd:"alphaSynth.soundFontLoaded"})}onSoundFontLoadFailed(t){this.sk.postMessage({cmd:"alphaSynth.soundFontLoadFailed",error:t})}onMidiLoaded(t){this.sk.postMessage({cmd:"alphaSynth.midiLoaded",args:t})}onMidiLoadFailed(t){this.sk.postMessage({cmd:"alphaSynth.midiLoadFailed",error:t})}onReadyForPlayback(){this.sk.postMessage({cmd:"alphaSynth.readyForPlayback"})}onMidiEventsPlayed(t){this.sk.postMessage({cmd:"alphaSynth.midiEventsPlayed",events:t.events.map(Wn.midiEventToJsObject)})}onPlaybackRangeChanged(t){this.sk.postMessage({cmd:"alphaSynth.playbackRangeChanged",playbackRange:t.playbackRange})}},yh=class t{Nw;sk;constructor(t){this.sk=t,t.addEventListener("message",t=>this.om(t))}static init(){new t(Bu.getGlobalWorkerScope())}om(t){const e=t.data;if(e?.cmd)switch(e.cmd){case"alphaTab.initialize":const t=Wn.jsObjectToSettings(e.settings);O.logLevel=t.core.logLevel,this.Nw=new Sa(t),this.Nw.partialRenderFinished.on(t=>{this.sk.postMessage({cmd:"alphaTab.partialRenderFinished",result:t})}),this.Nw.partialLayoutFinished.on(t=>{this.sk.postMessage({cmd:"alphaTab.partialLayoutFinished",result:t})}),this.Nw.renderFinished.on(t=>{this.sk.postMessage({cmd:"alphaTab.renderFinished",result:t})}),this.Nw.postRenderFinished.on(()=>{this.sk.postMessage({cmd:"alphaTab.postRenderFinished",boundsLookup:this.Nw.boundsLookup?.toJson()??null})}),this.Nw.preRender.on(t=>{this.sk.postMessage({cmd:"alphaTab.preRender",resize:t})}),this.Nw.error.on(this.rk.bind(this));break;case"alphaTab.render":this.Nw.render(e.renderHints);break;case"alphaTab.resizeRender":this.Nw.resizeRender();break;case"alphaTab.renderResult":this.Nw.renderResult(e.resultId);break;case"alphaTab.setWidth":this.Nw.width=e.width;break;case"alphaTab.renderScore":this.ak(e.fontSizes);const s=e.renderHints,i=null==e.score?null:Wn.jsObjectToScore(e.score,this.Nw.settings);this.hk(i,e.trackIndexes,s);break;case"alphaTab.updateSettings":this.ck(e.settings)}}ak(t){for(const[e,s]of t)Oi.fontSizeLookupTables.set(e,s)}ck(t){Ci.fromJson(this.Nw.settings,t)}hk(t,e,s){try{this.Nw.renderScore(t,e,s)}catch(t){this.rk(t)}}rk(t){O.error("Worker","An unexpected error occurred in worker",t),this.sk.postMessage({cmd:"alphaTab.error",error:t})}},kh=function(t){return t[t.OwnedTop=0]="OwnedTop",t[t.OwnedBottom=1]="OwnedBottom",t[t.SharedTop=2]="SharedTop",t[t.SharedBottom=3]="SharedBottom",t}({}),Sh=class{hideOnMultiTrack=!1;hideOnPercussionTrack=!1;effectBands;constructor(t){this.effectBands=t}canCreate(t,e){return!this.hideOnPercussionTrack||!e.isPercussion}},Bh=function(t){return t[t.SinglePreBeat=0]="SinglePreBeat",t[t.SingleOnBeat=1]="SingleOnBeat",t[t.SingleOnBeatToEnd=2]="SingleOnBeatToEnd",t[t.GroupedOnBeat=3]="GroupedOnBeat",t[t.GroupedOnBeatToEnd=4]="GroupedOnBeatToEnd",t[t.FullBar=5]="FullBar",t}({}),_h=class extends Xa{beat=null;nextGlyph=null;previousGlyph=null;constructor(t=0,e=0){super(t,e)}},xh=class extends _h{lk;uk="";dk;fk;In;constructor(t,e,s,i,n,r){super(t,e),this.lk=Bt.getAlternateEndingsList(s),this.dk=i,this.fk=n,this.In=r}doLayout(){super.doLayout(),this.height=this.renderer.resources.elementFonts.get(A.EffectAlternateEndings).size+2*this.renderer.smuflMetrics.alternateEndingsPadding;let t="";for(let e=0,s=this.lk.length;e<s;e++)t+=this.lk[e]+1,t+=". ";this.uk=t}paint(t,e,s){let i=this.fk?this.width-s.lineWidth:this.width;if(this.renderer.bar.getActualBarLineRight()===q.LightHeavy&&(i-=this.renderer.smuflMetrics.thickBarlineThickness+this.renderer.smuflMetrics.barlineSeparation),t=(0|t)+s.lineWidth/2,e=(0|e)+s.lineWidth/2,this.In&&(t+=this.renderer.smuflMetrics.alternateEndingsPadding,i-=this.renderer.smuflMetrics.alternateEndingsPadding),this.dk?(s.moveTo(t+this.x,e+this.y+this.height),s.lineTo(t+this.x,e+this.y)):s.moveTo(t+this.x,e+this.y),s.lineTo(t+this.x+i,e+this.y),this.fk&&s.lineTo(t+this.x+i,e+this.y+this.height),s.stroke(),this.dk){const i=s.textBaseline;s.textBaseline=dt.Top,s.font=this.renderer.resources.elementFonts.get(A.EffectAlternateEndings),s.fillText(this.uk,t+this.x+this.renderer.smuflMetrics.alternateEndingsPadding,e+this.y+this.renderer.smuflMetrics.alternateEndingsPadding),s.textBaseline=i}}},Th=class{get effectId(){return this.notationElement.toString()}finalizeBand(t){}onAlignGlyphs(t){}},Mh=class extends Th{get notationElement(){return A.EffectAlternateEndings}get hideOnMultiTrack(){return!0}get canShareBand(){return!1}get sizingMode(){return Bh.FullBar}shouldCreateGlyph(t,e){return 0===e.voice.index&&0===e.index&&0!==e.voice.bar.masterBar.alternateEndings}createNewGlyph(t,e){const s=e.voice.bar.masterBar,i=null===s.previousMasterBar||s.alternateEndings!==s.previousMasterBar.alternateEndings;let n=s.isRepeatEnd||null===s.nextMasterBar||s.alternateEndings!==s.nextMasterBar.alternateEndings;s.repeatGroup.closings.some(t=>t.index>=s.index)||(n=!1);const r=null!==s.previousMasterBar&&s.alternateEndings!==s.previousMasterBar.alternateEndings&&s.previousMasterBar.alternateEndings>0;return new xh(0,0,s.alternateEndings,i,n,r)}canExpand(t,e){return!0}},vh=class extends _h{endPosition;forceGroupedRendering=!1;endOnBarLine=!1;constructor(t){super(),this.endPosition=t}get isLinkedWithPrevious(){return!!this.previousGlyph&&this.previousGlyph.renderer.staff?.system===this.renderer.staff.system}get isLinkedWithNext(){return!!this.nextGlyph&&this.nextGlyph.renderer.isFinalized&&this.nextGlyph.renderer.staff?.system===this.renderer.staff.system}paint(t,e,s){if(this.isLinkedWithPrevious)return;if(!this.isLinkedWithNext&&!this.forceGroupedRendering)return void this.paintNonGrouped(t,e,s);let i;if(!this.isLinkedWithNext&&this.forceGroupedRendering)i=this;else for(i=this.nextGlyph;i.isLinkedWithNext;)i=i.nextGlyph;const n=i.renderer,r=i.beat,a=this.endPosition,h=t-this.renderer.x,o=this.calculateEndX(n,r,h,a);this.paintGrouped(t,e,o,s)}calculateEndX(t,e,s,i){return e?s+t.x+t.getBeatX(e,i):s+t.x+this.x+this.width}paintNonGrouped(t,e,s){const i=t-this.renderer.x,n=this.calculateEndX(this.renderer,this.beat,i,this.endPosition);this.paintGrouped(t,e,n,s)}},Nh=class extends vh{pk;bk;mk=0;gk;constructor(t,e,s=!0){super(Ua.OnNotes),this.pk=t,this.bk=s,this.gk=e}doLayout(){this.renderer.settings.notation.extendLineEffectsToBeatEnd&&(this.endPosition=Ua.EndBeat,this.forceGroupedRendering=!0),super.doLayout(),this.renderer.scoreRenderer.canvas.font=this.renderer.resources.elementFonts.get(this.gk);const t=this.renderer.scoreRenderer.canvas.measureText(this.pk);this.height=t.height,this.mk=t.width}paintNonGrouped(t,e,s){s.font=this.renderer.resources.elementFonts.get(this.gk);const i=s.textBaseline;s.textBaseline=dt.Middle,s.fillText(this.pk,t+this.x-this.mk/2,e+this.y+this.height/2),s.textBaseline=i}paintGrouped(t,e,s,i){this.paintNonGrouped(t,e,i);const n=this.renderer.smuflMetrics.lineRangedGlyphDashGap,r=this.renderer.smuflMetrics.lineRangedGlyphDashSize,a=this.renderer.smuflMetrics.pedalLineThickness,h=t+this.x+this.mk/2+n/2,o=e+this.y+this.height/2-a/2;if(this.bk){if(s>h){let t=h;for(;t<s;){const e=Math.min(t+r,s);i.fillRect(t,o,e-t,a),t+=r+n}i.fillRect(s,o-r/2+a/2,a,r)}}else i.fillRect(h,o,s-h,a),i.fillRect(s-a,o,a,r/2)}},Ph=class t extends Th{get notationElement(){return A.EffectLetRing}get canShareBand(){return!1}get hideOnMultiTrack(){return!1}shouldCreateGlyph(t,e){return e.isBarre}get sizingMode(){return Bh.GroupedOnBeat}createNewGlyph(e,s){let i="";switch(s.barreShape){case It.None:case It.Full:break;case It.Half:i+="1/2"}return i+=`B ${t.toRoman(s.barreFret)}`,new Nh(i,A.EffectBeatBarre,!1)}static wk=new Map([["L",50],["XL",40],["X",10],["IX",9],["V",5],["IV",4],["I",1]]);static toRoman(e){let s="";if(e>0)for(const[i,n]of t.wk){const t=Math.floor(e/n);e-=t*n,s+=i.repeat(t)}return s}canExpand(t,e){return t.barreFret===e.barreFret&&t.barreShape===e.barreShape}},Ch=class extends _h{p;yk="";kk=0;Sk=0;constructor(t){super(0,0),this.p=t}doLayout(){const t=this.p/6e4|0,e=(this.p-6e4*t)/1e3|0;this.yk=`${t}:${e.toString().padStart(2,"0")}`;const s=this.renderer.scoreRenderer.canvas;s.font=this.renderer.resources.elementFonts.get(A.EffectBeatTimer);const i=s.measureText(this.yk);this.Sk=s.font.size+2*this.renderer.smuflMetrics.beatTimerPadding,this.kk=i.width+2*this.renderer.smuflMetrics.beatTimerPadding,this.height=this.Sk+2*this.renderer.smuflMetrics.beatTimerPadding}paint(t,e,s){const i=this.kk/2|0;s.strokeRect(t+this.x-i,e+this.y+this.renderer.smuflMetrics.beatTimerPadding,this.kk,this.Sk);const n=s.font,r=s.textBaseline,a=s.textAlign;s.font=this.renderer.resources.elementFonts.get(A.EffectBeatTimer),s.textBaseline=dt.Middle,s.textAlign=ut.Center,s.fillText(this.yk,t+this.x,e+this.y+this.height/2),s.font=n,s.textBaseline=r,s.textAlign=a}},Eh=class extends Th{get notationElement(){return A.EffectBeatTimer}get hideOnMultiTrack(){return!0}get canShareBand(){return!0}get sizingMode(){return Bh.SingleOnBeat}shouldCreateGlyph(t,e){return e.showTimer}createNewGlyph(t,e){return new Ch(e.timer??0)}canExpand(t,e){return!0}},Fh=class extends _h{Bk;_k=null;font;textAlign;textBaseline;colorOverride;constructor(t,e,s,i,n=ut.Left,r=null,a){super(t,e),this.Bk=s.split("\n"),this.font=i,this.textAlign=n,this.textBaseline=r,this.colorOverride=a}doLayout(){super.doLayout(),this._k=[];const t=this.renderer.scoreRenderer.canvas;for(const e of this.Bk){t.font=this.font;const s=t.measureText(e),i=s.height;this._k.push(i),this.height+=i,this.width=Math.max(this.width,s.width)}}paint(t,e,s){const i=s.color;s.color=this.colorOverride??i,s.font=this.font;const n=s.textAlign,r=s.textBaseline;s.textAlign=this.textAlign,null!==this.textBaseline&&(s.textBaseline=this.textBaseline);let a=e+this.y;for(let e=0;e<this.Bk.length;e++)s.fillText(this.Bk[e],t+this.x,a),a+=this._k[e];s.textAlign=n,s.textBaseline=r,s.color=i}},Ah=class extends Th{get notationElement(){return A.EffectCapo}get hideOnMultiTrack(){return!1}get canShareBand(){return!1}get sizingMode(){return Bh.SingleOnBeat}shouldCreateGlyph(t,e){return 0===e.index&&0===e.voice.bar.index&&0!==e.voice.bar.staff.capo}createNewGlyph(t,e){return new Fh(0,0,`Capo. fret ${e.voice.bar.staff.capo}`,t.resources.elementFonts.get(A.EffectCapo),ut.Left)}canExpand(t,e){return!1}},Dh=class t extends _h{static xk=5;Tk;Mk=0;vk=0;Nk=0;Pk;gk;constructor(t,e,s,i,n=!1){super(t,e),this.Tk=s,this.Pk=n,this.gk=i}doLayout(){super.doLayout();const e=this.renderer.resources.elementFonts.get(this.gk);if(this.Mk=1.5*e.size,this.vk=1.5*e.size,this.height=this.Mk,this.width=2*this.renderer.smuflMetrics.chordDiagramPaddingX,this.renderer.settings.notation.isNotationElementVisible(A.ChordDiagramFretboardNumbers))this.Tk.firstFret>1?this.Nk=this.renderer.smuflMetrics.chordDiagramFretSpacing:this.Nk=0,this.height+=this.vk+t.xk*this.renderer.smuflMetrics.chordDiagramFretSpacing+2*this.renderer.smuflMetrics.chordDiagramPaddingY,this.width+=this.Nk+(this.Tk.strings.length-1)*this.renderer.smuflMetrics.chordDiagramStringSpacing;else if(this.Tk.showName){const t=this.renderer.scoreRenderer.canvas;t.font=e,this.width+=t.measureText(this.Tk.name).width}}paint(t,e,s){t+=this.x+this.renderer.smuflMetrics.chordDiagramPaddingX+this.Nk,e+=this.y,this.Pk&&(t-=this.width/2);const i=this.renderer.resources,n=i.engravingSettings.chordDiagramLineWidth,r=this.width-2*this.renderer.smuflMetrics.chordDiagramPaddingX-this.Nk+n,a=s.textAlign,h=s.textBaseline,o=i.elementFonts.get(this.gk);s.font=o,s.textAlign=ut.Center,s.textBaseline=dt.Top,this.Tk.showName&&s.fillText(this.Tk.name,t+r/2,e+o.size/2),this.renderer.settings.notation.isNotationElementVisible(A.ChordDiagramFretboardNumbers)&&this.Ck(t,e,s,r),s.textAlign=a,s.textBaseline=h}Ck(e,s,i,n){s+=this.Mk;const r=this.renderer.resources,a=this.renderer.smuflMetrics.chordDiagramStringSpacing,h=this.renderer.smuflMetrics.chordDiagramFretSpacing,o=r.engravingSettings.glyphHeights.get(xt.FretboardFilledCircle),c=r.engravingSettings.glyphTop.get(xt.FretboardFilledCircle),l=r.engravingSettings.glyphHeights.get(xt.FretboardX)/2,u=r.engravingSettings.glyphHeights.get(xt.FretboardO)/2,d=r.engravingSettings.chordDiagramLineWidth;i.font=r.elementFonts.get(A.ChordDiagramFretboardNumbers),i.textBaseline=dt.Middle;for(let t=0;t<this.Tk.strings.length;t++){const n=e+t*a,r=s+this.vk/2;let h=this.Tk.strings[this.Tk.strings.length-t-1];h<0?pt.fillMusicFontSymbolSafe(i,n,r+l,1,xt.FretboardX,!0):0===h?pt.fillMusicFontSymbolSafe(i,n,r+u,1,xt.FretboardO,!0):(h-=this.Tk.firstFret-1,i.fillText(h.toString(),n,r))}s+=this.vk;for(let n=0;n<this.Tk.strings.length;n++){const r=e+n*a;i.fillRect(r,s,d,h*t.xk+1)}this.Tk.firstFret>1?(i.textAlign=ut.Left,i.fillText(this.Tk.firstFret.toString(),e-this.Nk,s+h/2),i.fillRect(e,s,n,d)):i.fillRect(e,s-this.renderer.smuflMetrics.chordDiagramNutHeight/2,n,this.renderer.smuflMetrics.chordDiagramNutHeight);for(let r=0;r<=t.xk;r++){const t=s+r*h;i.fillRect(e,t,n,this.renderer.smuflMetrics.chordDiagramFretHeight)}const f=new Map;for(const t of this.Tk.barreFrets)f.set(t-this.Tk.firstFret,[-1,-1]);for(let t=0;t<this.Tk.strings.length;t++){let n=this.Tk.strings[t];if(n>0){if(n-=this.Tk.firstFret,f.has(n)){const e=f.get(n);(-1===e[0]||t<e[0])&&(e[0]=t),(-1===e[1]||t>e[1])&&(e[1]=t)}const r=s+n*h+h/2+.5,l=e+(this.Tk.strings.length-t-1)*a+d/2;pt.fillMusicFontSymbolSafe(i,l,r+c-o/2,1,xt.FretboardFilledCircle,!0)}}for(const[t,n]of f){const r=s+t*h+h/2+.5,c=e+(this.Tk.strings.length-n[1]-1)*a,l=e+(this.Tk.strings.length-n[0]-1)*a;i.fillRect(c,r-o/2,l-c,o)}}},Lh=class extends Th{get notationElement(){return A.EffectChordNames}get hideOnMultiTrack(){return!1}get canShareBand(){return!0}get sizingMode(){return Bh.SingleOnBeat}shouldCreateGlyph(t,e){return e.hasChord}createNewGlyph(t,e){return e.voice.bar.staff.track.score.stylesheet.globalDisplayChordDiagramsInScore?new Dh(0,0,e.chord,A.EffectChordNames,!0):new Fh(0,0,e.chord.name,t.resources.elementFonts.get(A.EffectChordNames),ut.Center)}canExpand(t,e){return!1}},Wh=class extends vh{Yn;constructor(t,e,s){super(Ua.EndBeat),this.Yn=g.None,this.Yn=s,this.x=t,this.y=e}doLayout(){super.doLayout(),this.height=this.renderer.smuflMetrics.glyphHeights.get(xt.DynamicCrescendoHairpin)}paintGrouped(t,e,s,i){const n=t+this.x,r=this.height,a=this.renderer.smuflMetrics.glyphWidths.get(xt.NoteheadBlack)/2;i.beginPath(),this.Yn===g.Crescendo?(s-=a,i.moveTo(s,e+this.y),i.lineTo(n,e+this.y+r/2),i.lineTo(s,e+this.y+r)):(s-=a,i.moveTo(n,e+this.y),i.lineTo(s,e+this.y+r/2),i.lineTo(n,e+this.y+r));const h=i.lineWidth;i.lineWidth=this.renderer.smuflMetrics.hairpinThickness,i.stroke(),i.lineWidth=h}},Rh=class extends Th{get notationElement(){return A.EffectCrescendo}get hideOnMultiTrack(){return!1}get canShareBand(){return!0}get sizingMode(){return Bh.GroupedOnBeatToEnd}shouldCreateGlyph(t,e){return e.crescendo!==g.None}createNewGlyph(t,e){return new Wh(0,0,e.crescendo)}canExpand(t,e){return t.crescendo===e.crescendo}},Oh=class extends Xa{Ek;Jy=1;constructor(t){super(0,0),this.Ek=t}doLayout(){this.height=0;const t=this.renderer.smuflMetrics.directionsScale;this.Jy=t;for(const e of this.Ek){const s=this.renderer.smuflMetrics.glyphHeights.get(e)*t;s>this.height&&(this.height=s)}}paint(t,e,s){s.fillMusicFontSymbols(t+this.x,e+this.y+this.height,this.Jy,this.Ek,!0)}},Ih=class extends Xa{yk;constructor(t){super(0,0),this.yk=t}doLayout(){const t=this.renderer.scoreRenderer.canvas;t.font=this.renderer.resources.elementFonts.get(A.EffectDirections),this.height=t.measureText(this.yk).height}paint(t,e,s){const i=s.font,n=s.textBaseline,r=s.textAlign;s.font=this.renderer.resources.elementFonts.get(A.EffectDirections),s.textBaseline=dt.Middle,s.textAlign=ut.Right,s.fillText(this.yk,t+this.x,e+this.y+this.height/2),s.font=i,s.textBaseline=n,s.textAlign=r}},Gh=class extends _h{Fk;Ak=[];Dk=[];constructor(t,e,s){super(t,e),this.Fk=s}doLayout(){const t=this.Fk;t.has(ys.TargetSegnoSegno)&&this.Ak.push(new Oh([xt.Segno,xt.Segno])),t.has(ys.TargetSegno)&&this.Ak.push(new Oh([xt.Segno])),t.has(ys.TargetDoubleCoda)&&this.Ak.push(new Oh([xt.Coda,xt.Coda])),t.has(ys.TargetCoda)&&this.Ak.push(new Oh([xt.Coda])),t.has(ys.TargetFine)&&this.Dk.push(new Ih("Fine")),t.has(ys.JumpDaDoubleCoda)&&this.Dk.push(new Ih("To Double Coda")),t.has(ys.JumpDaCoda)&&this.Dk.push(new Ih("To Coda")),t.has(ys.JumpDalSegnoSegno)&&this.Dk.push(new Ih("D.S.S.")),t.has(ys.JumpDalSegnoSegnoAlCoda)&&this.Dk.push(new Ih("D.S.S. al Coda")),t.has(ys.JumpDalSegnoSegnoAlDoubleCoda)&&this.Dk.push(new Ih("D.S.S. al Double Coda")),t.has(ys.JumpDalSegnoSegnoAlFine)&&this.Dk.push(new Ih("D.S.S. al Fine")),t.has(ys.JumpDalSegno)&&this.Dk.push(new Ih("D.S.")),t.has(ys.JumpDalSegnoAlCoda)&&this.Dk.push(new Ih("D.S. al Coda")),t.has(ys.JumpDalSegnoAlDoubleCoda)&&this.Dk.push(new Ih("D.S. al Double Coda")),t.has(ys.JumpDalSegnoAlFine)&&this.Dk.push(new Ih("D.S. al Fine")),t.has(ys.JumpDaCapo)&&this.Dk.push(new Ih("D.C.")),t.has(ys.JumpDaCapoAlCoda)&&this.Dk.push(new Ih("D.C. al Coda")),t.has(ys.JumpDaCapoAlDoubleCoda)&&this.Dk.push(new Ih("D.C. al Double Coda")),t.has(ys.JumpDaCapoAlFine)&&this.Dk.push(new Ih("D.C. al Fine"));const e=this.Lk(this.Ak),s=this.Lk(this.Dk);this.height=Math.max(e,s)}Lk(t){let e=0;const s=this.renderer.settings.display.effectBandPaddingBottom;for(const i of t)i.y=e,i.renderer=this.renderer,i.doLayout(),e+=i.height+s;return e}paint(t,e,s){for(const i of this.Ak)i.paint(t+this.x,e+this.y,s);for(const i of this.Dk)i.paint(t+this.x+this.width,e+this.y,s)}},Hh=class extends Th{get notationElement(){return A.EffectDirections}get hideOnMultiTrack(){return!0}get canShareBand(){return!1}get sizingMode(){return Bh.FullBar}shouldCreateGlyph(t,e){return 0===e.voice.index&&0===e.index&&null!==e.voice.bar.masterBar.directions&&e.voice.bar.masterBar.directions.size>0}createNewGlyph(t,e){return new Gh(0,0,e.voice.bar.masterBar.directions)}canExpand(t,e){return!0}},$h=class extends _h{glyphScale=0;symbol;center=!1;colorOverride;offsetX=0;offsetY=0;constructor(t,e,s,i){super(t,e),this.glyphScale=s,this.symbol=i}getBoundingBoxTop(){const t=this.renderer.smuflMetrics.glyphTop.get(this.symbol);return this.y-this.offsetY-t}doLayout(){this.width=this.renderer.smuflMetrics.glyphWidths.get(this.symbol)*this.glyphScale,this.height=this.renderer.smuflMetrics.glyphHeights.get(this.symbol)*this.glyphScale}paint(t,e,s){if(0===this.width&&0===this.height)return;const i=s.color;this.colorOverride&&(s.color=this.colorOverride),s.fillMusicFontSymbol(t+this.x+this.offsetX,e+this.y+this.offsetY,this.glyphScale,this.symbol,this.center),s.color=i}},Vh=class extends _h{glyphScale=0;symbols;center=!1;colorOverride;offsetX=0;offsetY=0;constructor(t,e,s,i){super(t,e),this.glyphScale=s,this.symbols=i}getBoundingBoxTop(){let t=0;for(let e=0;e<this.symbols.length;e++){const s=this.renderer.smuflMetrics.glyphTop.get(this.symbols[e]);(0===e||s<t)&&(t=s)}return this.y-this.offsetY-t}doLayout(){this.width=0,this.height=0;for(let t=0;t<this.symbols.length;t++){const e=this.renderer.smuflMetrics.glyphWidths.get(this.symbols[t])*this.glyphScale,s=this.renderer.smuflMetrics.glyphHeights.get(this.symbols[t])*this.glyphScale;(0===t||e>this.width)&&(this.width=e),(0===t||s>this.height)&&(this.height=s)}}paint(t,e,s){if(0===this.width&&0===this.height)return;const i=s.color;this.colorOverride&&(s.color=this.colorOverride),s.fillMusicFontSymbols(t+this.x+this.offsetX,e+this.y+this.offsetY,this.glyphScale,this.symbols,this.center),s.color=i}},zh=class t extends $h{constructor(e,s,i){super(e,s,1,t.Wk(i))}doLayout(){super.doLayout(),this.center=!0,this.height=this.renderer.smuflMetrics.glyphHeights.get(xt.DynamicForte);const t=this.renderer.smuflMetrics.glyphTop.get(xt.DynamicForte);this.offsetY=t}static Wk(t){switch(t){case o.PPP:return xt.DynamicPPP;case o.PP:return xt.DynamicPP;case o.P:return xt.DynamicPiano;case o.MP:return xt.DynamicMP;case o.MF:return xt.DynamicMF;case o.F:return xt.DynamicForte;case o.FF:return xt.DynamicFF;case o.FFF:return xt.DynamicFFF;case o.PPPP:return xt.DynamicPPPP;case o.PPPPP:case o.PPPPPP:return xt.DynamicPPPPP;case o.FFFF:return xt.DynamicFFFF;case o.FFFFF:return xt.DynamicFFFFF;case o.FFFFFF:return xt.DynamicFFFFFF;case o.SF:return xt.DynamicSforzando1;case o.SFP:return xt.DynamicSforzandoPiano;case o.SFPP:return xt.DynamicSforzandoPianissimo;case o.FP:return xt.DynamicFortePiano;case o.RF:return xt.DynamicRinforzando1;case o.RFZ:return xt.DynamicRinforzando2;case o.SFZ:return xt.DynamicSforzato;case o.SFFZ:return xt.DynamicSforzatoFF;case o.FZ:return xt.DynamicForzando;case o.N:return xt.DynamicNiente;case o.PF:return xt.DynamicPF;case o.SFZP:return xt.DynamicSforzatoPiano;default:return xt.None}}},Uh=class extends Th{get notationElement(){return A.EffectDynamics}get hideOnMultiTrack(){return!1}get canShareBand(){return!1}get sizingMode(){return Bh.SingleOnBeat}shouldCreateGlyph(t,e){return this.Rk(e)}Rk(t){if(t.voice.bar.staff.track.score.stylesheet.hideDynamics||t.isEmpty||t.voice.isEmpty||t.isRest)return!1;const e=this.Ok(t);let s=0===t.voice.index&&!e||t.dynamics!==e?.dynamics;if(s&&t.voice.index>0)for(const e of t.voice.bar.voices)if(e.index<t.voice.index){const i=e.getBeatAtPlaybackStart(t.playbackStart);i&&t.dynamics===i.dynamics&&this.Rk(i)&&(s=!1)}return s}Ok(t){let e=t.previousBeat;for(;null!=e;){if(!e.isRest)return e;e=e.previousBeat}return null}createNewGlyph(t,e){return new zh(0,0,e.dynamics)}canExpand(t,e){return!0}},Xh=class t extends $h{constructor(e){super(0,0,1,t.Wk(e)),this.center=!0}static Wk(t){switch(t){case Rt.FadeIn:return xt.GuitarFadeIn;case Rt.FadeOut:return xt.GuitarFadeOut;case Rt.VolumeSwell:return xt.GuitarVolumeSwell}return xt.None}paint(t,e,s){super.paint(t,e+this.height,s)}},jh=class extends Th{get notationElement(){return A.EffectFadeIn}get hideOnMultiTrack(){return!1}get canShareBand(){return!0}get sizingMode(){return Bh.SingleOnBeat}shouldCreateGlyph(t,e){return e.fade!==Rt.None}createNewGlyph(t,e){return new Xh(e.fade)}canExpand(t,e){return!0}},Jh=class t extends $h{constructor(e,s,i){super(e,s,1,t.Wk(i))}static Wk(t){switch(t){case Be.Short:return xt.FermataShortAbove;case Be.Medium:return xt.FermataAbove;case Be.Long:return xt.FermataLongAbove;default:return xt.None}}paint(t,e,s){super.paint(t-this.width/2,e+this.height,s)}},qh=class extends Th{get notationElement(){return A.EffectFermata}get hideOnMultiTrack(){return!1}get canShareBand(){return!1}get sizingMode(){return Bh.SingleOnBeat}shouldCreateGlyph(t,e){return 0===e.voice.index&&!!e.fermata}createNewGlyph(t,e){return new Jh(0,0,e.fermata.type)}canExpand(t,e){return!0}},Yh=class extends Xa{glyphs=null;get isEmpty(){return!this.glyphs||0===this.glyphs.length}getBoundingBoxTop(){let t=NaN;const e=this.glyphs;if(e)for(const s of e)t=Bt.minBoundingBox(t,s.getBoundingBoxTop());return t}getBoundingBoxBottom(){let t=NaN;const e=this.glyphs;if(e)for(const s of e)t=Bt.maxBoundingBox(t,s.getBoundingBoxBottom());return t}doLayout(){if(!this.glyphs||0===this.glyphs.length)return void(this.width=0);let t=0,e=0;for(let s=0,i=this.glyphs.length;s<i;s++){const i=this.glyphs[s];i.renderer=this.renderer,i.doLayout(),t=Math.max(t,i.width),e=Math.max(e,i.y+i.height)}this.width=t,this.height=e}addGlyph(t){this.glyphs||(this.glyphs=[]),this.renderer&&(t.renderer=this.renderer),this.glyphs.push(t)}paint(t,e,s){const i=this.glyphs;if(i&&0!==i.length)for(const n of i)n.paint(t+this.x,e+this.y,s)}},Kh=class t{static score(e,s,i,n=!1){if(!i.style&&!n)return;const r=t.Ik(e.settings.display.resources,s);return new Qh(e,s,i.style,r)}static scoreColor(e,s,i){const n=t.Ik(e,s);if(i.style&&i.style.colors.has(s))return i.style.colors.get(s)??n}static Ik(t,e){return t.mainGlyphColor}static bar(t,e,s,i=!1){if(!s.style&&!i)return;let n=t.settings.display.resources.mainGlyphColor;switch(e){case j.StandardNotationRepeats:case j.GuitarTabsRepeats:case j.SlashRepeats:case j.NumberedRepeats:case j.StandardNotationClef:case j.GuitarTabsClef:case j.StandardNotationKeySignature:case j.NumberedKeySignature:case j.StandardNotationTimeSignature:case j.GuitarTabsTimeSignature:case j.SlashTimeSignature:case j.NumberedTimeSignature:break;case j.StandardNotationBarLines:case j.GuitarTabsBarLines:case j.SlashBarLines:case j.NumberedBarLines:n=t.settings.display.resources.barSeparatorColor;break;case j.StandardNotationBarNumber:case j.SlashBarNumber:case j.NumberedBarNumber:case j.GuitarTabsBarNumber:n=t.settings.display.resources.barNumberColor;break;case j.StandardNotationStaffLine:case j.GuitarTabsStaffLine:case j.SlashStaffLine:case j.NumberedStaffLine:n=t.settings.display.resources.staffLineColor}return new Qh(t,e,s.style,n)}static voice(t,e,s,i=!1){if(!s.style&&!i)return;const n=0===s.index?t.settings.display.resources.mainGlyphColor:t.settings.display.resources.secondaryGlyphColor;return new Qh(t,e,s.style,n)}static trackColor(e,s,i){const n=t.Gk(e,s);if(i.style&&i.style.colors.has(s))return i.style.colors.get(s)??n}static Gk(t,e){let s=t.mainGlyphColor;switch(e){case Pe.TrackName:case Pe.SystemSeparator:case Pe.StringTuning:break;case Pe.BracesAndBrackets:s=t.barSeparatorColor}return s}static track(e,s,i,n=!1){if(!i.style&&!n)return;const r=t.Gk(e.settings.display.resources,s);return new Qh(e,s,i.style,r)}static beatColor(e,s,i){const n=t.Hk(e,s,i);if(i.style&&i.style.colors.has(s))return i.style.colors.get(s)??n}static Hk(t,e,s){return 0===s.voice.index?t.mainGlyphColor:t.secondaryGlyphColor}static beat(e,s,i,n=!1){if(!i.style&&!n)return;const r=t.Hk(e.settings.display.resources,s,i);return new Qh(e,s,i.style,r)}static noteColor(e,s,i){const n=t.$k(e,s,i);if(i.style&&i.style.colors.has(s))return i.style.colors.get(s)??n}static $k(t,e,s){return 0===s.beat.voice.index?t.mainGlyphColor:t.secondaryGlyphColor}static note(t,e,s,i=!1){if(!s.style&&!i)return;const n=0===s.beat.voice.index?t.settings.display.resources.mainGlyphColor:t.settings.display.resources.secondaryGlyphColor;return new Qh(t,e,s.style,n)}},Qh=class{ym;Vk;constructor(t,e,s,i){this.ym=t,s&&s.colors.has(e)?(this.Vk=t.color,t.color=s.colors.get(e)??i):s||(this.Vk=t.color,t.color=i)}[Symbol.dispose](){this.Vk&&(this.ym.color=this.Vk)}},Zh=class{line=0;symbols;color;constructor(t,e){this.line=t,this.symbols=e}},to=class t extends Yh{zk=new Map;constructor(){super(0,0)}get isEmpty(){return 0===this.zk.size}addFingers(e){const s=this.renderer.settings;if(s.notation.fingeringMode!==E.ScoreDefault&&s.notation.fingeringMode!==E.ScoreForcePiano)return;const i=t.fingerToMusicFontSymbol(this.renderer.settings,e.beat,e.leftHandFinger,!0);i!==xt.None&&this.Uk(e,i);const n=t.fingerToMusicFontSymbol(this.renderer.settings,e.beat,e.rightHandFinger,!1);n!==xt.None&&this.Uk(e,n)}static fingerToMusicFontSymbol(t,e,s,i){if(t.notation.fingeringMode===E.ScoreForcePiano||t.notation.fingeringMode===E.SingleNoteEffectBandForcePiano||we.isPiano(e.voice.bar.staff.track.playbackInfo.program))switch(s){case S.Unknown:case S.NoOrDead:return xt.None;case S.Thumb:return xt.Fingering1;case S.IndexFinger:return xt.Fingering2;case S.MiddleFinger:return xt.Fingering3;case S.AnnularFinger:return xt.Fingering4;case S.LittleFinger:return xt.Fingering5;default:return xt.None}if(i)switch(s){case S.Unknown:return xt.None;case S.NoOrDead:return xt.Fingering0;case S.Thumb:return xt.FingeringTLower;case S.IndexFinger:return xt.Fingering1;case S.MiddleFinger:return xt.Fingering2;case S.AnnularFinger:return xt.Fingering3;case S.LittleFinger:return xt.Fingering4;default:return xt.None}switch(s){case S.Unknown:case S.NoOrDead:return xt.None;case S.Thumb:return xt.FingeringPLower;case S.IndexFinger:return xt.FingeringILower;case S.MiddleFinger:return xt.FingeringMLower;case S.AnnularFinger:return xt.FingeringALower;case S.LittleFinger:return xt.FingeringCLower;default:return xt.None}}Uk(t,e){const s=this.renderer,i=s.getNoteSteps(t);if(this.zk.has(i))this.zk.get(i).symbols.push(e);else{const n=new Zh(i,[e]);n.color=Kh.noteColor(s.resources,Et.StandardNotationEffects,t),this.zk.set(i,n)}}doLayout(){const t=this.renderer;for(const[e,s]of this.zk){const e=new Vh(0,0,1,s.symbols);e.colorOverride=s.color,e.renderer=t,e.y=t.getScoreY(s.line),e.doLayout(),e.offsetY=e.height/2,this.addGlyph(e),this.width=Math.max(this.width,e.width)}for(const t of this.glyphs){const e=t;e.x=this.width/2,e.center=!0}}},eo=class extends Th{get notationElement(){return A.EffectFingering}get hideOnMultiTrack(){return!1}get canShareBand(){return!0}get sizingMode(){return Bh.SingleOnBeat}shouldCreateGlyph(t,e){return!(0!==e.voice.index||e.isRest||t.notation.fingeringMode!==E.SingleNoteEffectBand&&t.notation.fingeringMode!==E.SingleNoteEffectBandForcePiano)&&(1===e.notes.length&&e.notes[0].isFingering)}createNewGlyph(t,e){let s=S.Unknown,i=!1;const n=e.notes[0];n.leftHandFinger!==S.Unknown?(s=n.leftHandFinger,i=!0):n.rightHandFinger!==S.Unknown&&(s=n.rightHandFinger);const r=new $h(0,0,1,to.fingerToMusicFontSymbol(t.settings,e,s,i));return r.center=!0,r.renderer=t,r.doLayout(),r.offsetY=t.smuflMetrics.glyphTop.get(r.symbol),r}canExpand(t,e){return!0}},so=class extends Th{get notationElement(){return A.EffectText}get hideOnMultiTrack(){return!1}get canShareBand(){return!0}get sizingMode(){return Bh.SinglePreBeat}shouldCreateGlyph(t,e){const s=e.voice.bar.masterBar;return 0===e.voice.bar.staff.index&&0===e.voice.index&&0===e.index&&s.isFreeTime&&(0===s.index||s.isFreeTime!==s.previousMasterBar.isFreeTime)}createNewGlyph(t,e){return new Fh(0,0,"Free time",t.resources.elementFonts.get(A.EffectFreeTime),ut.Left)}canExpand(t,e){return!0}},io=class extends $h{constructor(t,e,s=!1){super(t,e,si.GraceScale,xt.GuitarGolpe),this.center=s}doLayout(){super.doLayout(),this.offsetY=this.height}},no=class extends Th{Xk;constructor(t){super(),this.Xk=t}get notationElement(){return A.EffectGolpe}get effectId(){return`${super.effectId}.${Wt[this.Xk]}`}get hideOnMultiTrack(){return!1}get canShareBand(){return!0}get sizingMode(){return Bh.SingleOnBeat}shouldCreateGlyph(t,e){return e.golpe===this.Xk}createNewGlyph(t,e){return new io(0,0,!0)}canExpand(t,e){return!1}},ro=class extends Th{lastCreateInfo=null;shouldCreateGlyph(t,e){this.lastCreateInfo=[];for(let t=0,s=e.notes.length;t<s;t++){const s=e.notes[t];this.shouldCreateGlyphForNote(s)&&this.lastCreateInfo.push(s)}return this.lastCreateInfo.length>0}get hideOnMultiTrack(){return!1}get canShareBand(){return!0}canExpand(t,e){return!0}},ao=class t extends ro{jk;$e=null;Jk;get effectId(){return this.Jk}get notationElement(){return A.EffectHarmonics}constructor(t){switch(super(),this.jk=t,t){case B.None:this.Jk="harmonics-none";break;case B.Natural:this.Jk="harmonics-natural";break;case B.Artificial:this.Jk="harmonics-artificial";break;case B.Pinch:this.Jk="harmonics-pinch";break;case B.Tap:this.Jk="harmonics-tap";break;case B.Semi:this.Jk="harmonics-semi";break;case B.Feedback:this.Jk="harmonics-feedback";break;default:this.Jk=""}}shouldCreateGlyphForNote(t){return!(!t.isHarmonic||t.harmonicType!==this.jk)&&(t.beat!==this.$e&&(this.$e=t.beat),!0)}get sizingMode(){return Bh.GroupedOnBeat}createNewGlyph(e,s){return new Nh(t.harmonicToString(this.jk),A.EffectHarmonics)}static harmonicToString(t){switch(t){case B.Natural:return"N.H.";case B.Artificial:return"A.H.";case B.Pinch:return"P.H.";case B.Tap:return"T.H.";case B.Semi:return"S.H.";case B.Feedback:return"Fdbk."}return""}},ho=class extends $h{constructor(){super(0,0,1,xt.GuitarLeftHandTapping),this.center=!0}doLayout(){super.doLayout(),this.offsetY=this.renderer.smuflMetrics.glyphTop.get(this.symbol)}},oo=class extends ro{get notationElement(){return A.EffectTap}get sizingMode(){return Bh.SingleOnBeat}shouldCreateGlyphForNote(t){return t.isLeftHandTapped}createNewGlyph(t,e){return new ho}},co=class extends Th{get notationElement(){return A.EffectLetRing}get canShareBand(){return!1}get hideOnMultiTrack(){return!1}shouldCreateGlyph(t,e){return e.isLetRing}get sizingMode(){return Bh.GroupedOnBeat}createNewGlyph(t,e){return new Nh("LetRing",A.EffectLetRing)}canExpand(t,e){return!0}},lo=class extends _h{Bk;qk=[];font;textAlign;constructor(t,e,s,i,n=ut.Center){super(t,e),this.Bk=s,this.font=i,this.textAlign=n}doLayout(){super.doLayout();const t=this.renderer.settings.display.lyricLinesPaddingBetween,e=this.renderer.scoreRenderer.canvas;e.font=this.font;let s=0;for(const i of this.Bk){this.qk.push(s);s+=e.measureText(i.length>0?i:" ").height+t}s-=t,this.height=s}paint(t,e,s){s.font=this.font;const i=s.textAlign;s.textAlign=this.textAlign;for(let i=0;i<this.Bk.length;i++)this.Bk[i]&&s.fillText(this.Bk[i],t+this.x,e+this.y+this.qk[i]);s.textAlign=i}},uo=class extends Th{get notationElement(){return A.EffectLyrics}get hideOnMultiTrack(){return!1}get canShareBand(){return!1}get sizingMode(){return Bh.SingleOnBeat}shouldCreateGlyph(t,e){return!!e.lyrics}createNewGlyph(t,e){return new lo(0,0,e.lyrics,t.resources.elementFonts.get(A.EffectLyrics),ut.Center)}canExpand(t,e){return!0}},fo=class extends Th{get notationElement(){return A.EffectMarker}get hideOnMultiTrack(){return!0}get canShareBand(){return!0}get sizingMode(){return Bh.SinglePreBeat}shouldCreateGlyph(t,e){return 0===e.voice.bar.staff.index&&0===e.voice.index&&0===e.index&&e.voice.bar.masterBar.isSectionStart}createNewGlyph(t,e){return new Fh(0,0,e.voice.bar.masterBar.section.marker?`[${e.voice.bar.masterBar.section.marker}] ${e.voice.bar.masterBar.section.text}`:e.voice.bar.masterBar.section.text,t.resources.elementFonts.get(A.EffectMarker),ut.Left)}canExpand(t,e){return!0}},po=class t extends $h{constructor(e){super(0,0,1,t.Wk(e)),this.center=!0}static Wk(t){switch(t){case Pt.InvertedTurn:return xt.OrnamentTurnInverted;case Pt.Turn:return xt.OrnamentTurn;case Pt.UpperMordent:return xt.OrnamentShortTrill;case Pt.LowerMordent:return xt.OrnamentMordent}return xt.None}doLayout(){super.doLayout(),this.height=this.renderer.smuflMetrics.glyphHeights.get(xt.OrnamentMordent),this.offsetY=this.renderer.smuflMetrics.glyphTop.get(xt.OrnamentMordent)}},bo=class extends Th{get notationElement(){return A.EffectNoteOrnament}get hideOnMultiTrack(){return!1}get canShareBand(){return!0}get sizingMode(){return Bh.SingleOnBeat}shouldCreateGlyph(t,e){return e.notes.some(t=>t.ornament!==Pt.None)}createNewGlyph(t,e){return new po(e.notes.find(t=>t.ornament!==Pt.None).ornament)}canExpand(t,e){return!1}},mo=class t extends $h{constructor(e,s,i,n){super(e,s,n,t.getMusicSymbol(i))}static getMusicSymbol(t){switch(t){case I.Natural:return xt.AccidentalNatural;case I.Sharp:return xt.AccidentalSharp;case I.Flat:return xt.AccidentalFlat;case I.NaturalQuarterNoteUp:return xt.AccidentalQuarterToneSharpNaturalArrowUp;case I.SharpQuarterNoteUp:return xt.AccidentalThreeQuarterTonesSharpArrowUp;case I.FlatQuarterNoteUp:return xt.AccidentalQuarterToneFlatArrowUp;case I.DoubleSharp:return xt.AccidentalDoubleSharp;case I.DoubleFlat:return xt.AccidentalDoubleFlat}return xt.None}},go=class extends _h{Yk;Kk;yk="";Qk=I.None;Zk=0;tS=0;constructor(t,e,s,i){super(t,e),this.Yk=s,this.Kk=i}doLayout(){super.doLayout();let t="",e="",s=I.None;switch(this.Kk){case z.Major:switch(t="1 = ",this.Yk){case V.Cb:e="  C",s=I.Flat;break;case V.Gb:e="  G",s=I.Flat;break;case V.Db:e="  D",s=I.Flat;break;case V.Ab:e="  A",s=I.Flat;break;case V.Eb:e="  E",s=I.Flat;break;case V.Bb:e="  B",s=I.Flat;break;case V.F:e="F";break;case V.C:e="C",s=I.None;break;case V.G:e="G",s=I.None;break;case V.D:e="D",s=I.None;break;case V.A:e="A",s=I.None;break;case V.E:e="E",s=I.None;break;case V.B:e="B",s=I.None;break;case V.FSharp:e="  F",s=I.Sharp;break;case V.CSharp:e="  C",s=I.Sharp}break;case z.Minor:switch(t="6 = ",this.Yk){case V.Cb:e="  a",s=I.Flat;break;case V.Gb:e="  e",s=I.Flat;break;case V.Db:e="  b",s=I.Flat;break;case V.Ab:e="f",s=I.None;break;case V.Eb:e="c",s=I.None;break;case V.Bb:e="g",s=I.None;break;case V.F:e="d";break;case V.C:e="a",s=I.None;break;case V.G:e="e",s=I.None;break;case V.D:e="b",s=I.None;break;case V.A:e="  f",s=I.Sharp;break;case V.E:e="  c",s=I.Sharp;break;case V.B:e="  g",s=I.Sharp;break;case V.FSharp:e="  d",s=I.Sharp;break;case V.CSharp:e="  a",s=I.Sharp}}this.yk=t+e,this.Qk=s;const i=this.renderer.scoreRenderer.canvas,n=this.renderer.settings;i.font=n.display.resources.numberedNotationFont,this.Zk=i.measureText(t).width;const r=i.measureText(t+e);this.tS=0===this.renderer.index?n.display.firstStaffPaddingLeft:n.display.staffPaddingLeft,this.width=this.tS+r.width,this.height=r.height}paint(t,e,s){const i=Kh.bar(s,j.NumberedKeySignature,this.renderer.bar);try{s.font=this.renderer.resources.numberedNotationFont,s.textBaseline=dt.Alphabetic,s.fillText(this.yk,t+this.x+this.tS,e+this.y+this.height),this.Qk!==I.None&&pt.fillMusicFontSymbolSafe(s,t+this.x+this.tS+this.Zk,e+this.y+this.height,1,mo.getMusicSymbol(this.Qk),!1)}finally{i?.[Symbol.dispose]?.()}}},wo=class extends Th{get notationElement(){return A.EffectNumberedNotationKeySignature}get hideOnMultiTrack(){return!1}get canShareBand(){return!1}get sizingMode(){return Bh.FullBar}shouldCreateGlyph(t,e){const s=e.voice.bar;return 0===e.index&&0===e.voice.index&&(!s.previousBar||s.keySignature!==s.previousBar.keySignature)}createNewGlyph(t,e){return new go(0,0,t.bar.keySignature,t.bar.keySignatureType)}canExpand(t,e){return!1}},yo=class extends vh{eS;sS;constructor(t,e){super(Ua.PostNotes),this.eS=t,this.sS=e}doLayout(){super.doLayout(),this.height=this.renderer.smuflMetrics.glyphHeights.get(xt.QuindicesimaAlta)}paintNonGrouped(t,e,s){this.iS(t,e,s)}iS(t,e,s){let i=0;switch(this.eS){case x._:i=this.renderer.smuflMetrics.glyphWidths.get(xt.QuindicesimaAlta),pt.fillMusicFontSymbolSafe(s,t+this.x-i/2,e+this.y+this.height,1,xt.QuindicesimaAlta,!1);break;case x.T:i=this.renderer.smuflMetrics.glyphWidths.get(xt.OttavaAlta),pt.fillMusicFontSymbolSafe(s,t+this.x-i/2,e+this.y+this.height,1,xt.OttavaAlta,!1);break;case x.M:i=this.renderer.smuflMetrics.glyphWidths.get(xt.OttavaBassaVb),pt.fillMusicFontSymbolSafe(s,t+this.x-i/2,e+this.y+this.height,1,xt.OttavaBassaVb,!1);break;case x.L:i=1*(this.renderer.smuflMetrics.glyphWidths.get(xt.Quindicesima)+this.renderer.smuflMetrics.glyphWidths.get(xt.OctaveBaselineM)+this.renderer.smuflMetrics.glyphWidths.get(xt.OctaveBaselineB)),pt.fillMusicFontSymbolsSafe(s,t+this.x-i/2,e+this.y+this.height,1,[xt.Quindicesima,xt.OctaveBaselineM,xt.OctaveBaselineB],!1)}return i/2}paintGrouped(t,e,s,i){const n=this.iS(t,e,i),r=this.renderer.smuflMetrics.lineRangedGlyphDashGap,a=t+this.x+n+r;let h=e+this.y;const o=.5*this.height;h+=this.sS?0:this.height;const c=this.renderer.smuflMetrics.lineRangedGlyphDashSize,l=i.lineWidth;if(i.lineWidth=this.renderer.smuflMetrics.octaveLineThickness,s>a){let t=a;for(;t<s;)i.beginPath(),i.moveTo(t,0|h),i.lineTo(Math.min(t+c,s),0|h),t+=c+r,i.stroke();i.beginPath(),this.sS?(i.moveTo(s,h),i.lineTo(s,h+o)):(i.moveTo(s,h),i.lineTo(s,h-o)),i.stroke()}i.lineWidth=l}},ko=class extends Th{sS;get effectId(){return"ottavia-"+(this.sS?"above":"below")}get notationElement(){return A.EffectOttavia}get hideOnMultiTrack(){return!1}get canShareBand(){return!0}get sizingMode(){return Bh.GroupedOnBeat}constructor(t){super(),this.sS=t}shouldCreateGlyph(t,e){switch(e.ottava){case x._:case x.T:return this.sS;case x.M:case x.L:return!this.sS}return!1}createNewGlyph(t,e){return new yo(e.ottava,this.sS)}canExpand(t,e){return t.ottava===e.ottava}},So=class extends ro{get notationElement(){return A.EffectPalmMute}shouldCreateGlyphForNote(t){return t.isPalmMute}get sizingMode(){return Bh.GroupedOnBeat}createNewGlyph(t,e){return new Nh("P.M.",A.EffectPalmMute)}},Bo=class extends ro{get notationElement(){return A.EffectPickSlide}shouldCreateGlyphForNote(t){return t.slideOutType===M.PickSlideDown||t.slideOutType===M.PickSlideUp}get sizingMode(){return Bh.GroupedOnBeat}createNewGlyph(t,e){return new Nh("P.S.",A.EffectPickSlide)}},_o=class t extends $h{constructor(e,s,i){super(e,s,si.GraceScale,t.Wk(i)),this.center=!0}doLayout(){super.doLayout(),this.offsetY=this.height}static Wk(t){switch(t){case _t.Up:return xt.StringsUpBow;case _t.Down:return xt.StringsDownBow;default:return xt.None}}},xo=class extends Th{get notationElement(){return A.EffectPickStroke}get hideOnMultiTrack(){return!1}get canShareBand(){return!0}get sizingMode(){return Bh.SingleOnBeat}shouldCreateGlyph(t,e){return e.pickStroke!==_t.None}createNewGlyph(t,e){return new _o(0,0,e.pickStroke)}canExpand(t,e){return!0}},To=class extends Th{get notationElement(){return A.EffectRasgueado}get canShareBand(){return!1}get hideOnMultiTrack(){return!1}shouldCreateGlyph(t,e){return e.hasRasgueado}get sizingMode(){return Bh.GroupedOnBeat}createNewGlyph(t,e){return new Nh("rasg.",A.EffectRasgueado)}canExpand(t,e){return!0}},Mo=class t extends Xa{nS=[];rS=[];aS;isEmpty=!0;previousBand=null;isLinkedToPrevious=!1;firstBeat=null;lastBeat=null;height=0;originalHeight=0;voice;info;slot=null;constructor(t,e,s){super(0,0),this.voice=t,this.info=e,this.aS=s}*iterateAllGlyphs(){for(const t of this.rS)for(const e of t.values())yield e}finalizeBand(){this.info.finalizeBand(this)}doLayout(){super.doLayout();for(let t=0;t<this.renderer.bar.voices.length;t++)this.rS.push(new Map),this.nS.push([])}static shouldCreateGlyph(t,e,s){return e.shouldCreateGlyph(s.settings,t)&&(!e.hideOnMultiTrack||0===s.staff.trackIndex)}createGlyph(e){if(e.voice===this.voice&&t.shouldCreateGlyph(e,this.info,this.renderer)){if(this.isEmpty=!1,this.firstBeat&&!e.isBefore(this.firstBeat)||(this.firstBeat=e),!this.lastBeat||e.isAfter(this.lastBeat))switch(this.lastBeat=e,this.info.sizingMode){case Bh.SingleOnBeatToEnd:case Bh.GroupedOnBeatToEnd:this.lastBeat.nextBeat&&(this.lastBeat=this.lastBeat.nextBeat)}const t=this.hS(this.info.sizingMode,e);t.height>this.height&&(this.height=t.height,this.originalHeight=t.height)}}resetHeight(){this.height=this.originalHeight}hS(t,e){let s;switch(t){case Bh.FullBar:case Bh.SinglePreBeat:case Bh.SingleOnBeat:case Bh.SingleOnBeatToEnd:return s=this.info.createNewGlyph(this.renderer,e),s.renderer=this.renderer,s.beat=e,s.doLayout(),this.rS[e.voice.index].set(e.index,s),this.nS[e.voice.index].push(s),s;case Bh.GroupedOnBeat:case Bh.GroupedOnBeatToEnd:const i=t===Bh.GroupedOnBeat?Bh.SingleOnBeat:Bh.SingleOnBeatToEnd;if(e.index>0||this.renderer.index>0){const t=e.previousBeat;if(this.info.shouldCreateGlyph(this.renderer.settings,t)){let s=null;if(e.index>0&&this.rS[e.voice.index].has(t.index))s=this.rS[e.voice.index].get(t.index);else if(this.renderer.index>0){const e=this.aS.previousContainer.getBand(t.voice,this.info.effectId);if(e){const i=e.rS[t.voice.index];i.has(t.index)&&(s=i.get(t.index))}}const n=this.hS(i,e);return s&&this.info.canExpand(t,e)&&(s.nextGlyph=n,n.previousGlyph=s,this.isLinkedToPrevious=!0),n}return this.hS(i,e)}return this.hS(i,e);default:return this.hS(Bh.SingleOnBeat,e)}}paint(t,e,s){super.paint(t,e,s);for(let i=0,n=this.nS.length;i<n;i++){const n=this.nS[i];for(let i=0,r=n.length;i<r;i++){const r=n[i],a=Kh.beat(s,zt.Effects,r.beat,!1);try{r.paint(t+this.x,e+this.y,s)}finally{a?.[Symbol.dispose]?.()}}}}alignGlyphs(){for(let t=0;t<this.rS.length;t++)for(const e of this.rS[t].keys()){const s=this.renderer.bar.voices[t].beats[e];this.oS(this.info.sizingMode,s)}this.info.onAlignGlyphs(this)}oS(t,e){const s=this.rS[e.voice.index].get(e.index),i=this.renderer.getBeatContainer(e);switch(t){case Bh.SinglePreBeat:const t=this.renderer.layoutingInfo.getPreBeatSize(e);s.x=this.renderer.beatGlyphsStart+i.x+i.onTimeX-t;break;case Bh.SingleOnBeat:case Bh.GroupedOnBeat:s.x=this.renderer.beatGlyphsStart+i.x+i.onTimeX;break;case Bh.SingleOnBeatToEnd:case Bh.GroupedOnBeatToEnd:s.x=this.renderer.beatGlyphsStart+i.x+i.onTimeX,i.isLastOfVoice?s.width=this.renderer.width-s.x:s.width=this.renderer.layoutingInfo.getPostBeatSize(e);break;case Bh.FullBar:s.width=this.renderer.width}}},vo=class{uniqueEffectId=null;y=0;height=0;firstBeat=null;lastBeat=null},No=class{bands;shared;constructor(){this.bands=[],this.shared=new vo}update(t){t.info.canShareBand||(this.shared.uniqueEffectId=t.info.effectId),t.slot=this,this.bands.push(t),t.height>this.shared.height&&(this.shared.height=t.height),this.shared.firstBeat&&!t.firstBeat.isBefore(this.shared.firstBeat)||(this.shared.firstBeat=t.firstBeat),this.shared.lastBeat&&!t.lastBeat.isAfter(this.shared.lastBeat)||(this.shared.lastBeat=t.lastBeat)}canBeUsed(t){return!((this.shared.uniqueEffectId||!t.info.canShareBand)&&t.info.effectId!==this.shared.uniqueEffectId)&&(!this.shared.firstBeat||(this.shared.lastBeat===t.firstBeat||(!!this.shared.lastBeat.isBefore(t.firstBeat)||!!this.shared.lastBeat.isBefore(this.shared.firstBeat))))}},Po=class{cS;lS;slots;owner;constructor(t){this.slots=[],this.cS=new Map,this.lS=new Map,this.owner=t}reset(){this.cS.clear(),this.lS.clear(),this.slots=[]}getOrCreateSlot(t){if(this.lS.has(t))return this.lS.get(t);if(this.cS.has(t.info.effectId)){const e=this.cS.get(t.info.effectId);if(e.canBeUsed(t))return this.lS.set(t,e),e}for(const e of this.slots)if(e.canBeUsed(t))return this.lS.set(t,e),e;const e=new No;return this.slots.push(e),this.lS.set(t,e),e}register(t){const e=this.getOrCreateSlot(t);e.update(t),this.cS.set(t.info.effectId,e)}sortSlots(t){for(const e of this.slots)e.bands.sort((e,s)=>t.get(e.info)-t.get(s.info));this.slots.sort((e,s)=>t.get(e.bands[0].info)-t.get(s.bands[0].info))}},Co=class{uS=[];dS=new Map;fS=null;pS=new Map;height=0;infos;Nw;bS;alignGlyphs(){for(const t of this.uS)t.alignGlyphs()}get previousContainer(){return 0===this.Nw.index?void 0:this.bS?this.Nw.previousRenderer.topEffects:this.Nw.previousRenderer.bottomEffects}get isLinkedToPreviousRenderer(){return this.uS.some(t=>t.isLinkedToPrevious)}constructor(t,e){this.Nw=t,this.bS=e}reLayout(){this.resetEffectBandSizingInfo(),this.sizeAndAlignEffectBands()}afterStaffBarReverted(){this.resetEffectBandSizingInfo(),this.sizeAndAlignEffectBands()}createVoiceGlyphs(t){let e=0;const s=this.Nw,i=s.settings.notation;for(const n of this.infos){if(!i.isNotationElementVisible(n.effect.notationElement))continue;let r;this.pS.set(n.effect,n.order??e);for(const e of t.beats)!r&&Mo.shouldCreateGlyph(e,n.effect,s)&&(r=new Mo(t,n.effect,this),r.renderer=this.Nw,r.doLayout(),this.uS.push(r),this.dS.set(`${t.index}.${n.effect.effectId}`,r)),void 0!==r&&r.createGlyph(e);e++}}doLayout(){this.pS.clear(),this.uS=[],this.dS=new Map,this.resetEffectBandSizingInfo()}resetEffectBandSizingInfo(){this.Nw.index>0?this.fS=this.previousContainer.fS:this.fS&&this.fS.owner===this?this.fS.reset():this.fS=new Po(this)}finalizeEffects(){return this.mS(!0)}updateEffectBandHeights(){return this.mS(!1)}mS(t){if(!this.fS)return!1;let e=0;const s=this.Nw.settings.display.effectBandPaddingBottom;for(const i of this.fS.slots){i.shared.y=e;for(const s of i.bands)e+=0,s.y=e,t&&s.finalizeBand(),s.height=i.shared.height;e+=i.shared.height+s}return e=Math.ceil(e),e!==this.height&&(this.height=e,!0)}sizeAndAlignEffectBands(t=!0){for(const e of this.uS)e.resetHeight(),e.alignGlyphs(),t&&!e.isEmpty&&this.fS.register(e);t&&this.fS.sortSlots(this.pS)}paint(t,e,s){const i=this.Nw.resources;for(const n of this.uS)s.color=0===n.voice.index?i.mainGlyphColor:i.secondaryGlyphColor,n.isEmpty||n.paint(t,e,s)}getBand(t,e){const s=`${t.index}.${e}`;return this.dS.has(s)?this.dS.get(s):null}},Eo=class extends Yh{gap=0;constructor(){super(0,0),this.glyphs=[]}doLayout(){}addGlyph(t){t.x=this.width,t.renderer=this.renderer,t.doLayout(),this.width=t.x+t.width+this.gap,super.addGlyph(t)}},Fo=class extends Xa{static KeySizeBeat="Beat";voiceDrawOrder;gS=new Map;beatGlyphs=new Map;tupletGroups=new Map;constructor(){super(0,0)}getBoundingBoxTop(){let t=NaN;for(const e of this.beatGlyphs.values())for(const s of e)t=Bt.minBoundingBox(t,s.getBoundingBoxTop());return t}getBoundingBoxBottom(){let t=NaN;for(const e of this.beatGlyphs.values())for(const s of e)t=Bt.maxBoundingBox(t,s.getBoundingBoxBottom());return t}scaleToWidth(t){const e=this.renderer.layoutingInfo.spaceToForce(t);this.wS(e)}wS(t){this.width=this.renderer.layoutingInfo.calculateVoiceWidth(t);const e=this.renderer.layoutingInfo.buildOnTimePositions(t);for(const t of this.beatGlyphs.values())for(let s=0,i=t.length;s<i;s++){const n=t[s];if(n.graceType===y.None)n.x=e.get(n.absoluteDisplayStart)-n.onTimeX;else{const i=n.graceGroup.beats[0].absoluteDisplayStart,r=n.graceGroup.id;if(n.graceGroup.isComplete&&e.has(i)){n.x=e.get(i)-n.onTimeX;const t=this.renderer.layoutingInfo.allGraceRods.get(r),s=n.graceGroup.beats[n.graceGroup.beats.length-1].nextBeat,a=s?this.renderer.layoutingInfo.getPreBeatSize(s):0;n.x-=a,n.x-=t[n.graceIndex].postSpringWidth,n.x+=t[n.graceIndex].graceBeatWidth;const h=t[n.graceGroup.beats.length-1];n.x-=h.graceBeatWidth}else{const e=this.renderer.layoutingInfo.incompleteGraceRods.get(r),i=e[n.graceIndex].postSpringWidth-e[n.graceIndex].preSpringWidth;s>0?0===n.graceIndex?n.x=t[s-1].x+t[s-1].width:n.x=t[s-1].x+e[n.graceIndex-1].postSpringWidth-e[n.graceIndex-1].preSpringWidth-i:n.x=-i}}if(s>0){const e=n.x-t[s-1].x;t[s-1].scaleToWidth(e)}if(s===i-1){const e=this.width-t[t.length-1].x;n.scaleToWidth(e)}}}registerLayoutingInfo(t){for(const e of this.beatGlyphs.values())for(const s of e)s.registerLayoutingInfo(t)}applyLayoutingInfo(t){for(const e of this.beatGlyphs.values()){for(const s of e)s.applyLayoutingInfo(t);this.wS(Math.max(this.renderer.settings.display.stretchForce,t.minStretchForce))}}addGlyph(t){let e;this.beatGlyphs.has(t.voiceIndex)?e=this.beatGlyphs.get(t.voiceIndex):(e=[],this.beatGlyphs.set(t.voiceIndex,e)),t.x=0===e.length?0:e[e.length-1].x+e[e.length-1].width,t.renderer=this.renderer,e.push(t);const s=t.beatId;s>=0&&this.gS.set(s,t);const i=t.x+t.width;if(i>this.width&&(this.width=i),t.isFirstOfTupletGroup){let e;this.tupletGroups.has(t.voiceIndex)?e=this.tupletGroups.get(t.voiceIndex):(e=[],this.tupletGroups.set(t.voiceIndex,e)),e.push(t.tupletGroup)}}getBeatX(t,e=Ua.PreNotes,s=!1){const i=this.getBeatContainer(t);return i?i.x+i.getBeatX(e,s):0}getLowestNoteY(t,e){const s=this.getBeatContainer(t);return s?s.y+s.getLowestNoteY(e):0}getHighestNoteY(t,e){const s=this.getBeatContainer(t);return s?s.y+s.getHighestNoteY(e):0}getNoteX(t,e){const s=this.getBeatContainer(t.beat);return s?s.x+s.getNoteX(t,e):0}getNoteY(t,e){const s=this.getBeatContainer(t.beat);return s?s.y+s.getNoteY(t,e):0}getRestY(t,e){const s=this.getBeatContainer(t);return s?s.y+s.getRestY(e):0}getBeatContainer(t){if(this.gS.has(t.id))return this.gS.get(t.id)}buildBoundingsLookup(t,e,s){for(const[i,n]of this.beatGlyphs){const r=this.renderer.bar.voices[i];if(0===i||!r.isEmpty)for(const i of n)i.buildBoundingsLookup(t,e+this.x,s+this.y)}}doLayout(){for(const t of this.beatGlyphs.values()){let e=0;for(const s of t)s.x=e,s.doLayout(),e+=s.width;e>this.width&&(this.width=e)}this.renderer.bar.isMultiVoice&&this.yS(),this.voiceDrawOrder=Array.from(this.beatGlyphs.keys()),Bu.sortDescending(this.voiceDrawOrder)}yS(){for(const t of this.beatGlyphs.values()){let e=0;for(const s of t)s.x=e,s.doMultiVoiceLayout(),e+=s.width;e>this.width&&(this.width=e)}}paint(t,e,s){for(const i of this.voiceDrawOrder){const n=this.beatGlyphs.get(i),r=this.renderer.bar.voices[i],a=Kh.voice(s,ot.Glyphs,r,!0);try{for(let i=0,r=n.length;i<r;i++)n[i].paint(t+this.x,e+this.y,s)}finally{a?.[Symbol.dispose]?.()}}}},Ao=class t extends Xa{tieDirection=Fe.Up;slurEffectId;isForEnd;constructor(t,e){super(0,0),this.slurEffectId=t,this.isForEnd=e}kS=0;SS=0;BS=0;_S=0;xS=0;TS;MS=!1;vS=[];NS=0;PS=0;get checkForOverflow(){return this.MS&&void 0!==this.TS}getBoundingBoxTop(){return this.TS?this.TS.y:this.SS}getBoundingBoxBottom(){return this.TS?this.TS.y+this.TS.h:this.SS}doLayout(){this.width=0;const e=this.lookupStartBeatRenderer(),s=this.lookupEndBeatRenderer();this.kS=0,this.BS=0,this.SS=0,this._S=0,this.height=0,this.tieDirection=this.calculateTieDirection();const i=this.isForEnd;if(this.MS=!1,i){if(e.staff!==s.staff){const t=e.staff.barRenderers[0];this.kS=t.x,this.BS=this.calculateEndX();const i=e.scoreRenderer.layout.slurRegistry.completeMultiSystemSlur(this);this.SS=i?i.calculateMultiSystemSlurY(s):this.caclculateEndY(),this._S=this.caclculateEndY(),this.MS=e.staff!==s.staff}}else{if(e!==s)if(this.kS=this.calculateStartX(),this.SS=this.calculateStartY(),s&&e.staff===s.staff)this.BS=this.calculateEndX(),this._S=this.caclculateEndY();else{const t=e.staff.barRenderers[e.staff.barRenderers.length-1];this.BS=t.x+t.width,this._S=this.SS,e.scoreRenderer.layout.slurRegistry.startMultiSystemSlur(this)}else this.MS=!0,this.kS=this.calculateStartX(),this.BS=this.calculateEndX(),this.SS=this.calculateStartY(),this._S=this.caclculateEndY();this.MS=!0}this.TS=void 0,this.y=Math.min(this.SS,this._S);const n=this.tieDirection===Fe.Down;let r,a=[];if(this.shouldDrawBendSlur())this.xS=0,r=t.calculateBendSlurHeight(this.kS,this.SS,this.BS,this._S,n,this.renderer.smuflMetrics.tieHeight);else{this.xS=this.getTieHeight(this.kS,this.SS,this.BS,this._S);const e=this.renderer.smuflMetrics.tieMidpointThickness;a=t.CS(1,this.kS,this.SS,this.BS,this._S,n,this.xS,e),r=t.ES(a,this.kS,this.SS,this.BS,this._S,n,e)}this.TS=r,this.NS=0;const h=this.getSlurLabels();if(null!==h&&h.length>0&&this.shouldPaintLabels()){const t=this.renderer.settings.display.resources,e=.25*this.renderer.smuflMetrics.oneStaffSpace;let s=0;const i=a.length>0?.125*a[7]+.375*a[9]+.375*a[11]+.125*a[13]:(this.SS+this._S)/2;for(const e of h){const n=this.resolveLabelAnchorX(e.fromNote),r=this.resolveLabelAnchorX(e.toNote);if(null===n||null===r)continue;const a=(n+r)/2;if(a<this.kS||a>this.BS)continue;const h=t.getFontForNotationElement(e.element);let o;h.size>s&&(s=h.size),this.NS<this.vS.length?(o=this.vS[this.NS],o.x=a,o.y=i,o.text=e.text,o.element=e.element):(o={x:a,y:i,text:e.text,element:e.element},this.vS.push(o)),this.NS++}this.NS>0&&(this.tieDirection===Fe.Up?(r.y-=s+e,this.PS=-(s+e)):this.PS=e,r.h+=s+e)}if(this.height=r.h,this.tieDirection===Fe.Up){const t=this.y-r.y;t>0&&(this.y-=t)}}paint(e,s,i){if(!this.MS)return;const n=this.tieDirection===Fe.Down;if(this.shouldDrawBendSlur()?t.drawBendSlur(i,e+this.kS,s+this.SS,e+this.BS,s+this._S,n,this.renderer.smuflMetrics.tieHeight):t.paintTie(i,1,e+this.kS,s+this.SS,e+this.BS,s+this._S,n,this.xS,this.renderer.smuflMetrics.tieMidpointThickness),this.NS>0){const t=i.textAlign,n=i.textBaseline;i.textAlign=ut.Center,i.textBaseline=dt.Top;const r=this.renderer.resources;let a=-1;for(let t=0;t<this.NS;t++){const n=this.vS[t];n.element!==a&&(i.font=r.getFontForNotationElement(n.element),a=n.element),i.fillText(n.text,e+n.x,s+n.y+this.PS)}i.textAlign=t,i.textBaseline=n}}getSlurLabels(){return null}shouldPaintLabels(){return!this.shouldDrawBendSlur()}resolveLabelAnchorX(t){const e=t.beat.voice.bar;let s=null;const i=this.lookupStartBeatRenderer();if(null!==i&&i.bar===e)s=i;else{const t=this.lookupEndBeatRenderer();s=null!==t&&t.bar===e?t:this.renderer.scoreRenderer.layout.getRendererForBar(this.renderer.staff.staffId,e)}return null===s?null:s.x+s.getNoteX(t,jo.Center)}getTieHeight(t,e,s,i){return this.renderer.smuflMetrics.tieHeight}calculateMultiSystemSlurY(t){const e=this.lookupStartBeatRenderer(),s=this.calculateStartY()-e.y;return t.y+s}shouldCreateMultiSystemSlur(t){const e=this.lookupEndBeatRenderer()?.staff;return!e||t.staff.system.index<e.system.index}static calculateActualTieHeight(e,s,i,n,r,a,h,o){const c=t.CS(e,s,i,n,r,a,h,o);return t.ES(c,s,i,n,r,a,o)}static ES(t,e,s,i,n,r,a){if(0===t.length)return new _s(e,s,i-e,n-s);const h=t[0],o=t[1],c=t[2],l=t[3],u=t[4],d=t[5],f=t[6],p=t[7],b=.125*h+.375*c+.375*u+.125*f,m=.125*o+.375*l+.375*d+.125*p,g=Math.min(h,f,b),w=Math.max(h,f,b);let y=Math.min(o,p,m),k=Math.max(o,p,m);r?k+=a:y-=a;const S=new _s;return S.x=g,S.y=y,S.w=w-g,S.h=k-y,S}static CS(e,s,i,n,r,a,h,o){if(s===n&&i===r)return[];if(n<s){let t=s;s=n,n=t,t=i,i=r,r=t}h*=e,o*=e,a&&(h*=-1,o*=-1),e>=1&&(o*=1.2);const c=r-i,l=n-s,u=Math.sqrt(l*l+c*c);let d=s+.25*u,f=i-h,p=s+.75*u,b=i-h,m=s+.75*u,g=i-h-o,w=s+.25*u,y=i-h-o;const k=Math.atan2(c,l);return[d,f]=t.FS(d,f,s,i,k),[p,b]=t.FS(p,b,s,i,k),[m,g]=t.FS(m,g,s,i,k),[w,y]=t.FS(w,y,s,i,k),[s,i,d,f,p,b,n,r,m,g,w,y,s,i]}static FS(t,e,s,i,n){const r=t-s,a=e-i;return[s+(r*Math.cos(n)-a*Math.sin(n)),i+(r*Math.sin(n)+a*Math.cos(n))]}static paintTie(e,s,i,n,r,a,h,o,c){const l=t.CS(s,i,n,r,a,h,o,c);e.beginPath(),e.moveTo(l[0],l[1]),e.bezierCurveTo(l[2],l[3],l[4],l[5],l[6],l[7]),e.bezierCurveTo(l[8],l[9],l[10],l[11],l[12],l[13]),e.closePath(),e.fill()}static calculateBendSlurTopY(t,e,s,i,n,r,a){let h=i-e,o=s-t;const c=Math.sqrt(h*h+o*o);n?h*=-1:o*=-1,h/=c,o/=c;let l=a*r;return s-t<20&&(l/=2),(i+e)/2+l*o}static calculateBendSlurHeight(t,e,s,i,n,r){let a=i-e,h=s-t;const o=Math.sqrt(a*a+h*h);n?a*=-1:h*=-1,a/=o,h/=o;let c=r;s-t<20&&(c/=2);const l=(i+e)/2+c*h,u=Math.min(e,i,l),d=Math.max(e,i,l);return new _s(t,Math.min(e,i,l),s-t,d-u)}static drawBendSlur(t,e,s,i,n,r,a,h){let o=n-s,c=i-e;const l=Math.sqrt(o*o+c*c);r?o*=-1:c*=-1,o/=l,c/=l;let u=a;i-e<20&&(u/=2);const d=(i+e)/2+u*o,f=(n+s)/2+u*c;if(t.beginPath(),t.moveTo(e,s),t.lineTo(d,f),t.lineTo(i,n),t.stroke(),h){const e=t.measureText(h).width,s=r?0:-t.font.size;t.fillText(h,d-e/2,f+s)}}},Do=class extends Ao{startNote;endNote;startNoteRenderer=null;endNoteRenderer=null;constructor(t,e,s,i){super(t,i),this.startNote=e,this.endNote=s}get isLeftHandTap(){return this.startNote===this.endNote}getTieHeight(t,e,s,i){return this.isLeftHandTap?this.renderer.smuflMetrics.tieHeight:super.getTieHeight(t,e,s,i)}calculateTieDirection(){return this.lookupStartBeatRenderer().getBeatDirection(this.startNote.beat)===Fe.Up?Fe.Down:Fe.Up}calculateStartX(){const t=this.lookupStartBeatRenderer();return this.isLeftHandTap?this.calculateEndX()-t.smuflMetrics.leftHandTabTieWidth:t.x+t.getNoteX(this.startNote,this.getStartNotePosition())}getStartNotePosition(){return jo.Center}calculateStartY(){const t=this.lookupStartBeatRenderer();return this.isLeftHandTap?t.y+t.getNoteY(this.startNote,Xo.Center):this.tieDirection===Fe.Up?t.y+t.getNoteY(this.startNote,Xo.Top):t.y+t.getNoteY(this.startNote,Xo.Bottom)}calculateEndX(){const t=this.lookupEndBeatRenderer();return t?this.isLeftHandTap?t.x+t.getNoteX(this.endNote,jo.Left):t.x+t.getNoteX(this.endNote,jo.Center):this.calculateStartY()+this.renderer.smuflMetrics.leftHandTabTieWidth}getEndNotePosition(){return jo.Center}caclculateEndY(){const t=this.lookupEndBeatRenderer();return t?this.isLeftHandTap?t.y+t.getNoteY(this.endNote,Xo.Center):this.tieDirection===Fe.Up?t.y+t.getNoteY(this.endNote,Xo.Top):t.y+t.getNoteY(this.endNote,Xo.Bottom):this.calculateStartY()}lookupEndBeatRenderer(){return this.endNoteRenderer||(this.endNoteRenderer=this.renderer.scoreRenderer.layout.getRendererForBar(this.renderer.staff.staffId,this.endNote.beat.voice.bar)),this.endNoteRenderer}lookupStartBeatRenderer(){return this.startNoteRenderer||(this.startNoteRenderer=this.renderer.scoreRenderer.layout.getRendererForBar(this.renderer.staff.staffId,this.startNote.beat.voice.bar)),this.startNoteRenderer}shouldDrawBendSlur(){return!1}},Lo=class extends Ao{AS;constructor(t){super(t.slurEffectId,!1),this.AS=t}lookupStartBeatRenderer(){return this.renderer}lookupEndBeatRenderer(){return this.renderer}shouldDrawBendSlur(){return!1}calculateTieDirection(){return this.AS.tieDirection}calculateStartY(){return this.AS.calculateMultiSystemSlurY(this.renderer)}caclculateEndY(){return this.calculateStartY()}calculateStartX(){return this.renderer.staff.barRenderers[0].x}calculateEndX(){const t=this.renderer.staff.barRenderers[this.renderer.staff.barRenderers.length-1];return t.x+t.width}},Wo=class t extends Xa{Jy=0;DS;Ek=[];constructor(e,s,i,n,r=1){super(e,s),this.Ek=t.getSymbols(i),this.Jy=r,this.DS=n}static getSymbols(e){const s=[];for(;e>0;){const i=e%10;s.unshift(t.getSymbol(i)),e=e/10|0}return s}static getSymbol(t){switch(t){case 0:return xt.TimeSig0;case 1:return xt.TimeSig1;case 2:return xt.TimeSig2;case 3:return xt.TimeSig3;case 4:return xt.TimeSig4;case 5:return xt.TimeSig5;case 6:return xt.TimeSig6;case 7:return xt.TimeSig7;case 8:return xt.TimeSig8;case 9:return xt.TimeSig9;default:return xt.None}}doLayout(){let t=0;for(const e of this.Ek)t+=this.renderer.smuflMetrics.glyphWidths.get(e);this.width=t}paint(t,e,s){switch(this.DS){case dt.Top:e+=this.renderer.smuflMetrics.glyphBottom.get(this.Ek[0]);break;case dt.Bottom:e+=this.renderer.smuflMetrics.glyphTop.get(this.Ek[0])}s.fillMusicFontSymbols(t+this.x,e+this.y,this.Jy,this.Ek)}},Ro=class t extends Xa{static LS=[xt.RestHBarLeft,xt.RestHBarMiddle,xt.RestHBarMiddle,xt.RestHBarMiddle,xt.RestHBarRight];WS=[];RS=0;constructor(){super(0,0)}doLayout(){const e=this.renderer.smuflMetrics;this.width=t.LS.reduce((t,s)=>t+e.glyphWidths.get(s),0);const s=this.renderer.additionalMultiRestBars.length+1;this.WS=Wo.getSymbols(s),this.RS=this.renderer.getLineY(-1.5);const i=e.glyphTop.get(this.WS[0]);this.renderer.registerOverflowTop(Math.abs(this.RS)+i)}paint(e,s,i){i.fillMusicFontSymbols(e+this.x,s+this.y+this.renderer.height/2,1,t.LS);const n=this.renderer.getLineY(-1.5);i.fillMusicFontSymbols(e+this.x+this.width/2,s+this.y+n|0,1,this.WS,!0)}},Oo=class extends ja{OS;constructor(){super(0,0)}get absoluteDisplayStart(){return this.renderer.bar.masterBar.start}get beatId(){return-1}get onTimeX(){return 0}get graceType(){return y.None}get graceIndex(){return 0}get graceGroup(){return null}get voiceIndex(){return 0}get isFirstOfTupletGroup(){return!1}get tupletGroup(){return null}get isLastOfVoice(){return!0}get displayDuration(){return 0}getRestY(t){const e=this.OS;if(e)switch(t){case Xo.Top:return e.y;case Xo.TopWithStem:return e.y-this.renderer.smuflMetrics.getStemLength(w.Quarter,!0);case Xo.Center:case Xo.StemUp:case Xo.StemDown:return e.y+e.height/2;case Xo.Bottom:return e.y+e.height;case Xo.BottomWithStem:return e.y+e.height+this.renderer.smuflMetrics.getStemLength(w.Quarter,!0)}return 0}getNoteY(t,e){return this.getRestY(e)}getHighestNoteY(t){return this.getRestY(t)}getLowestNoteY(t){return this.getRestY(t)}getNoteX(t,e){const s=this.OS;if(s)switch(e){case jo.Left:return s.x;case jo.Center:return s.x+s.width/2;case jo.Right:return s.x+s.width}return 0}getBeatX(t,e){const s=this.OS;if(s)switch(t){case Ua.PreNotes:return s.x;case Ua.OnNotes:case Ua.MiddleNotes:case Ua.Stem:case Ua.PostNotes:return s.x+s.width;case Ua.EndBeat:return this.width}return 0}registerLayoutingInfo(t){const e=this.OS?.width??0;t.addBeatSpring(this,0,e)}applyLayoutingInfo(t){}buildBoundingsLookup(t,e,s){}doLayout(){this.renderer.showMultiBarRest&&(this.OS=new Ro,this.OS.renderer=this.renderer,this.OS.doLayout(),this.width=this.OS.width)}doMultiVoiceLayout(){}getBoundingBoxTop(){return this.OS?.getBoundingBoxTop()??NaN}getBoundingBoxBottom(){return this.OS?.getBoundingBoxBottom()??NaN}paint(t,e,s){this.OS?.paint(t+this.x,e+this.y,s)}},Io=class{startBeat=null;startX=0;startY=0;endBeat=null;endX=0;endY=0;calcY(t){return this.startX===this.endX?this.startY:(this.endY-this.startY)/(this.endX-this.startX)*(t-this.startX)+this.startY}},Go=class t{IS;Nw;GS;voice=null;beats=[];shortestDuration=w.QuadrupleWhole;hasTuplet=!1;slashBeats=[];restBeats=[];lowestNoteInHelper=null;HS=-1;highestNoteInHelper=null;$S=-1;invertBeamDirection=!1;preferredBeamDirection=null;graceType=y.None;get isRestBeamHelper(){return 1===this.beats.length&&this.beats[0].isRest}hasStem(e,s){return e&&t.beatHasStem(s)||!e&&t.beatHasStem(s)}static beatHasStem(t){return t.duration>w.Whole}hasFlag(e,s){return e&&t.beatHasFlag(s)||!e&&1===this.beats.length&&t.beatHasFlag(this.beats[0])}static beatHasFlag(t){return!t.deadSlapped&&!t.isRest&&(t.duration>w.Quarter||t.graceType!==y.None)}constructor(t,e,s){this.IS=t,this.Nw=e,this.beats=[],this.GS=s}alignWithBeats(){this.drawingInfos.clear()}finish(){this.Nw.completeBeamingHelper(this)}static computeLineHeightsForRest(t){switch(t){case w.QuadrupleWhole:case w.DoubleWhole:return[2,2];case w.Whole:return[0,1];case w.Half:return[1,0];case w.Quarter:return[3,3];case w.Eighth:return[2,2];case w.Sixteenth:return[2,4];case w.ThirtySecond:return[4,4];case w.SixtyFourth:return[4,6];case w.OneHundredTwentyEighth:return[6,6];case w.TwoHundredFiftySixth:return[6,8]}return[0,0]}checkBeat(t){t.invertBeamDirection&&(this.invertBeamDirection=!0),this.voice||(this.voice=t.voice);let e=!1;if(0===this.beats.length)e=!0;else switch(this.beats[this.beats.length-1].beamingMode){case Vt.Auto:case Vt.ForceSplitOnSecondaryToNext:e=this.VS(this.beats[this.beats.length-1],t);break;case Vt.ForceSplitToNext:e=!1;break;case Vt.ForceMergeWithNext:e=!0}return e&&(null==this.preferredBeamDirection&&null!==t.preferredBeamDirection&&(this.preferredBeamDirection=t.preferredBeamDirection),t.hasTuplet&&(this.hasTuplet=!0),t.graceType!==y.None&&(this.graceType=t.graceType),t.isRest?0===this.beats.length?this.beats.push(t):this.restBeats.push(t):(this.isRestBeamHelper&&(this.beats=[]),this.beats.push(t),this.zS(t.minNote),this.zS(t.maxNote),this.shortestDuration<t.duration&&(this.shortestDuration=t.duration)),t.slashed&&this.slashBeats.push(t)),e}zS(t){if(!t)return;let e,s;this.voice&&t.isPercussion?(e=-Hs.getPercussionSteps(t),s=e):(e=Hs.getNoteValue(t),s=e,t.harmonicType!==B.None&&t.harmonicType!==B.Natural&&(s=t.realValue-this.IS.displayTranspositionPitch)),(!this.lowestNoteInHelper||e<this.HS)&&(this.lowestNoteInHelper=t,this.HS=e),(!this.highestNoteInHelper||s>this.$S)&&(this.highestNoteInHelper=t,this.$S=s)}VS(e,s){if(!e||!s||e.graceType!==s.graceType||e.graceType===y.BendGrace||s.graceType===y.BendGrace||e.deadSlapped||s.deadSlapped)return!1;if(e.graceType!==y.None&&s.graceType!==y.None)return!0;if(e.voice.bar!==s.voice.bar)return!1;const i=e.playbackStart,n=s.playbackStart;return t.US(e.duration)&&t.US(s.duration)?e.tupletGroup===s.tupletGroup&&(!!(e.hasTuplet&&s.hasTuplet&&e.tupletGroup===s.tupletGroup&&e.tupletGroup.isFull)||this.GS.calculateGroupIndex(i)===this.GS.calculateGroupIndex(n)):i===n}static US(t){switch(t){case w.Whole:case w.Half:case w.Quarter:return!1;default:return!0}}static isFullBarJoin(t,e,s){return Bt.getIndex(t.duration)-2-s>0&&Bt.getIndex(e.duration)-2-s>0}get beatOfLowestNote(){return this.lowestNoteInHelper.beat}get beatOfHighestNote(){return this.highestNoteInHelper.beat}drawingInfos=new Map},Ho=class{topY=0;bottomY=0;constructor(t,e){this.topY=t,this.bottomY=e}},$o=class{beat;topY=-1e3;bottomY=-1e3;slots=[];constructor(t){this.beat=t}addSlot(t,e){if(this.slots.push(new Ho(t,e)),-1e3===this.topY)this.topY=t,this.bottomY=e;else{const s=Math.min(t,e),i=Math.max(t,e);s<this.topY&&(this.topY=s),i>this.bottomY&&(this.bottomY=i)}}},Vo=class{reservedLayoutAreasByDisplayTime=new Map;restDurationsByDisplayTime=new Map;getBeatMinMaxY(){let t=-1e3,e=-1e3;for(const s of this.reservedLayoutAreasByDisplayTime.values())-1e3===t?(t=s.topY,e=s.bottomY):(t>s.topY&&(t=s.topY),e<s.bottomY&&(e=s.bottomY));return-1e3===t?[0,0]:[t,e]}reserveBeatSlot(t,e,s){e!==s&&(this.reservedLayoutAreasByDisplayTime.has(t.displayStart)||this.reservedLayoutAreasByDisplayTime.set(t.displayStart,new $o(t)),this.reservedLayoutAreasByDisplayTime.get(t.displayStart).addSlot(e,s),t.isRest&&this.registerRest(t))}registerRest(t){this.restDurationsByDisplayTime.has(t.displayStart)||this.restDurationsByDisplayTime.set(t.displayStart,new Map),this.restDurationsByDisplayTime.get(t.displayStart).has(t.playbackDuration)||this.restDurationsByDisplayTime.get(t.displayStart).set(t.playbackDuration,t.id)}applyRestCollisionOffset(t,e,s){if(t.voice.index>0&&this.reservedLayoutAreasByDisplayTime.has(t.playbackStart)){const i=Go.computeLineHeightsForRest(t.duration).map(t=>t*s),n=e-i[0],r=e+i[1];let a=n;const h=this.reservedLayoutAreasByDisplayTime.get(t.playbackStart);let o=!1;for(const t of h.slots)if(n>=t.topY&&n<=t.bottomY||r>=t.topY&&r<=t.bottomY){o=!0;break}if(o){a=1===t.voice.index?h.topY-i[1]-i[0]:h.bottomY;const e=a+i[0]+i[1],r=2*s,o=Math.ceil(Math.abs(a-n)/r);return h.addSlot(a,e),a<n?o*-r:o*r}}return 0}},zo=class t{XS=0;jS=[];JS;constructor(t,e,s){this.XS=e,this.jS=s,this.JS=t}calculateGroupIndex(t){if(0===this.jS.length)return t;t%=this.JS;const e=Math.floor(t/this.XS);return this.jS[e]}static build(e,s,i){const n=e.calculateDuration(!1),r=c.toTicks(s),a=n/r;if(a<0||0===i.length)return new t(0,0,[]);let h=0,o=i[h];const l=[];for(let t=0;t<a;t++)h<i.length?(l.push(h),o--,o<=0&&(h++,h<i.length&&(o=i[h]))):(l.push(h),h++);return new t(n,r,l)}},Uo=class t{Nw;qS=new Map;beamHelpers=[];collisionHelper;preferredBeamDirection=null;constructor(t){this.Nw=t,this.collisionHelper=new Vo}initialize(){const e=this.Nw,s=this.Nw.bar,i=s.masterBar,n=i.actualBeamingRules??t.YS(i),r=n.findRule(s.shortestDuration),a=`beaming_${n.uniqueId}_${r[0]}`;let h=this.Nw.scoreRenderer.layout.beamingRuleLookups.has(a)?this.Nw.scoreRenderer.layout.beamingRuleLookups.get(a):void 0;h||(h=zo.build(i,r[0],r[1]),this.Nw.scoreRenderer.layout.beamingRuleLookups.set(a,h));let o=null,c=null;for(let t=0,i=s.voices.length;t<i;t++){const i=s.voices[t];this.beamHelpers.push([]);for(let t=0,n=i.beats.length;t<n;t++){const n=i.beats[t];let r;n.graceType!==y.None?r=c:(r=o,c&&c.finish(),c=null),r&&r.checkBeat(n)||(r&&r.finish(),r=new Go(s.staff,e,h),r.preferredBeamDirection=this.preferredBeamDirection,r.checkBeat(n),n.graceType!==y.None?c=r:o=r,this.beamHelpers[i.index].push(r)),this.qS.set(n.id,r)}o&&o.finish(),c&&c.finish(),o=null,c=null}}static KS;static YS(e){let s=t.KS;s||(s=new Map([Q.createSimple(2,16,w.Sixteenth,[1,1]),Q.createSimple(1,8,w.Eighth,[1]),Q.createSimple(1,4,w.Quarter,[1]),Q.createSimple(3,16,w.Sixteenth,[3]),Q.createSimple(4,16,w.Sixteenth,[2,2]),Q.createSimple(2,8,w.Eighth,[1,1]),Q.createSimple(5,16,w.Sixteenth,[3,2]),Q.createSimple(6,16,w.Sixteenth,[3,3]),Q.createSimple(3,8,w.Eighth,[3]),Q.createSimple(4,8,w.Eighth,[2,2]),Q.createSimple(2,4,w.Quarter,[1,1]),Q.createSimple(9,16,w.Sixteenth,[3,3,3]),Q.createSimple(5,8,w.Eighth,[3,2]),Q.createSimple(12,16,w.Sixteenth,[3,3,3,3]),Q.createSimple(6,8,w.Eighth,[3,3,3]),Q.createSimple(3,4,w.Quarter,[1,1,1]),Q.createSimple(7,8,w.Eighth,[4,3]),Q.createSimple(8,8,w.Eighth,[3,3,2]),Q.createSimple(4,4,w.Quarter,[1,1,1,1]),Q.createSimple(9,8,w.Eighth,[3,3,3]),Q.createSimple(10,8,w.Eighth,[4,3,3]),Q.createSimple(5,4,w.Quarter,[1,1,1,1,1]),Q.createSimple(12,8,w.Eighth,[3,3,3,3]),Q.createSimple(6,4,w.Quarter,[1,1,1,1,1,1]),Q.createSimple(15,8,w.Eighth,[3,3,3,3,3,3]),Q.createSimple(8,4,w.Quarter,[1,1,1,1,1,1,1,1]),Q.createSimple(18,8,w.Eighth,[3,3,3,3,3,3])].map(t=>[`${t.timeSignatureNumerator}_${t.timeSignatureDenominator}`,t])),t.KS=s);const i=`${e.timeSignatureNumerator}_${e.timeSignatureDenominator}`;if(s.has(i))return s.get(i);let n=c.QuarterTime;if(8===e.timeSignatureDenominator)e.timeSignatureNumerator%3==0&&(n+=c.QuarterTime/2|0);const r=Math.ceil(e.calculateDuration(!1)/n),a=n/c.QuarterTime*2,h=new Q,o=[];for(let t=0;t<r;t++)o.push(a);return h.groups.set(w.Eighth,o),h.timeSignatureNumerator=e.timeSignatureNumerator,h.timeSignatureDenominator=e.timeSignatureDenominator,h.finish(),s.set(i,h),h}getBeamingHelperForBeat(t){return this.qS.has(t.id)?this.qS.get(t.id):void 0}},Xo=function(t){return t[t.TopWithStem=0]="TopWithStem",t[t.Top=1]="Top",t[t.Center=2]="Center",t[t.Bottom=3]="Bottom",t[t.BottomWithStem=4]="BottomWithStem",t[t.StemUp=5]="StemUp",t[t.StemDown=6]="StemDown",t}({}),jo=function(t){return t[t.Left=0]="Left",t[t.Center=1]="Center",t[t.Right=2]="Right",t}({}),Jo=class{QS=new Eo;voiceContainer=new Fo;ZS=new Eo;nw=[];tB;topEffects;bottomEffects;get nextRenderer(){return this.bar&&this.bar.nextBar?this.scoreRenderer.layout.getRendererForBar(this.staff.staffId,this.bar.nextBar):null}get previousRenderer(){return this.bar&&this.bar.previousBar?this.scoreRenderer.layout.getRendererForBar(this.staff.staffId,this.bar.previousBar):null}scoreRenderer;staff;layoutingInfo;bar;additionalMultiRestBars=null;get lastBar(){return this.additionalMultiRestBars?this.additionalMultiRestBars[this.additionalMultiRestBars.length-1]:this.bar}x=0;y=0;width=0;computedWidth=0;height=0;index=0;eB=0;sB=0;beatEffectsMinY=NaN;beatEffectsMaxY=NaN;get topOverflow(){return this.eB+this.topEffects.height}get bottomOverflow(){return this.sB+this.bottomEffects.height}helpers;get collisionHelper(){return this.helpers.collisionHelper}isLinkedToPrevious=!1;canWrap=!0;get showMultiBarRest(){return!0}constructor(t,e){this.scoreRenderer=t,this.bar=e,this.helpers=new Uo(this),this.topEffects=new Co(this,!0),this.bottomEffects=new Co(this,!1)}registerTie(t){this.nw.push(t)}get middleYPosition(){return 0}registerBeatEffectOverflows(t,e){const s=this.beatEffectsMinY;(Number.isNaN(s)||t<s)&&(this.beatEffectsMinY=t);const i=this.beatEffectsMaxY;(Number.isNaN(i)||e>i)&&(this.beatEffectsMaxY=e)}registerOverflowTop(t){return(t=Math.ceil(t))>this.eB&&(this.eB=t,!0)}registerOverflowBottom(t){return(t=Math.ceil(t))>this.sB&&(this.sB=t,!0)}get fixedOverhead(){return this.QS.width+this.ZS.width}scaleToWidth(t){const e=t-this.QS.width-this.ZS.width;this.voiceContainer.scaleToWidth(e);for(const t of this.helpers.beamHelpers)for(const e of t)e.alignWithBeats();this.ZS.x=this.QS.x+this.QS.width+e,this.width=t,this.topEffects.alignGlyphs(),this.bottomEffects.alignGlyphs()}get resources(){return this.settings.display.resources}get smuflMetrics(){return this.resources.engravingSettings}get settings(){return this.scoreRenderer.settings}wasFirstOfStaff=!1;get isFirstOfStaff(){return 0===this.index}get isLastOfStaff(){return this.index===this.staff.barRenderers.length-1}get isLast(){return!this.bar||this.bar.index===this.scoreRenderer.layout.lastBarIndex}iB(){const t=this.layoutingInfo,e=this.QS.width;t.preBeatSize<e&&(t.preBeatSize=e),this.voiceContainer.registerLayoutingInfo(t);const s=this.ZS.width;t.postBeatSize<s&&(t.postBeatSize=s)}nB=0;afterReverted(){this.staff=void 0,this.registerMultiSystemSlurs(void 0),this.isFinalized=!1}afterStaffBarReverted(){this.topEffects.afterStaffBarReverted(),this.bottomEffects.afterStaffBarReverted(),this.rB()}applyLayoutingInfo(){if(this.nB>=this.layoutingInfo.version)return!1;this.topEffects.resetEffectBandSizingInfo(),this.bottomEffects.resetEffectBandSizingInfo(),this.nB=this.layoutingInfo.version,this.QS.width=this.layoutingInfo.preBeatSize;const t=this.voiceContainer;return t.x=this.QS.x+this.QS.width,t.applyLayoutingInfo(this.layoutingInfo),this.ZS.x=Math.floor(t.x+t.width),this.ZS.width=this.layoutingInfo.postBeatSize,this.width=Math.ceil(this.ZS.x+this.ZS.width),this.computedWidth=this.width,this.topEffects.sizeAndAlignEffectBands(),this.bottomEffects.sizeAndAlignEffectBands(),this.rB(),!0}isFinalized=!1;registerMultiSystemSlurs(t){if(!t)return void(this.tB=void 0);let e;for(const s of t){const t=new Lo(s);t.renderer=this,t.tieDirection=s.tieDirection,e||(e=[]),e.push(t)}this.tB=e}aB(t,e,s){let i=!1;for(const n of t){const t=n;if(t.doLayout(),n.checkForOverflow){const n=t.getBoundingBoxTop(),r=t.getBoundingBoxBottom()-s;r>0&&this.registerOverflowBottom(r)&&(i=!0);const a=n-e;a<0&&this.registerOverflowTop(-1*a)&&(i=!0)}}return i}finalizeRenderer(){this.isFinalized=!0;let t=!1;const e=this.y,s=this.y+this.height;this.aB(this.nw,e,s)&&(t=!0);const i=this.tB;i&&this.aB(i,e,s)&&(t=!0);const n=this.topEffects.finalizeEffects(),r=this.bottomEffects.finalizeEffects();return(n||r)&&(t=!0),t&&(this.updateSizes(),this.rB()),t}rB(){this.staff.registerOverflowTop(this.topOverflow),this.staff.registerOverflowBottom(this.bottomOverflow)}doLayout(){if(this.bar){this.helpers.initialize(),this.nw=[],this.QS.renderer=this,this.voiceContainer.renderer=this,this.ZS.renderer=this,this.topEffects.doLayout(),this.bottomEffects.doLayout(),this.bar.simileMark===H.SecondOfDouble&&(this.canWrap=!1),this.createPreBeatGlyphs(),this.createBeatGlyphs(),this.createPostBeatGlyphs(),this.iB(),this.topEffects.sizeAndAlignEffectBands(!1),this.bottomEffects.sizeAndAlignEffectBands(!1),this.updateSizes();for(const t of this.helpers.beamHelpers)for(const e of t)e.finish();this.computedWidth=this.width,this.calculateOverflows(0,this.height)}}calculateOverflows(t,e){const s=this.QS.glyphs;if(s)for(const t of s){const s=t.getBoundingBoxTop();s<0&&this.registerOverflowTop(-1*s);const i=t.getBoundingBoxBottom();i>e&&this.registerOverflowBottom(i-e)}const i=this.ZS.glyphs;if(i)for(const t of i){const s=t.getBoundingBoxTop();s<0&&this.registerOverflowTop(-1*s);const i=t.getBoundingBoxBottom();i>e&&this.registerOverflowBottom(i-e)}const n=this.voiceContainer,r=n.getBoundingBoxTop();r<0&&this.registerOverflowTop(-1*r);const a=n.getBoundingBoxBottom();a>e&&this.registerOverflowBottom(a-e);const h=this.beatEffectsMinY;!Number.isNaN(h)&&h<0&&this.registerOverflowTop(-1*h);const o=this.beatEffectsMaxY;!Number.isNaN(o)&&o>e&&this.registerOverflowBottom(o-e)}updateSizes(){this.staff.registerStaffTop(0),this.voiceContainer.x=this.QS.x+this.QS.width,this.ZS.x=Math.floor(this.voiceContainer.x+this.voiceContainer.width),this.width=Math.ceil(this.ZS.x+this.ZS.width);const t=this.topEffects.updateEffectBandHeights(),e=this.bottomEffects.updateEffectBandHeights();(t||e)&&this.rB(),this.height+=this.layoutingInfo.height,this.height=Math.ceil(this.height),this.staff.registerStaffBottom(this.height)}addPreBeatGlyph(t){t.renderer=this,this.QS.addGlyph(t)}addBeatGlyph(t){t.renderer=this,this.voiceContainer.addGlyph(t)}getBeatContainer(t){return this.voiceContainer.getBeatContainer(t)}paint(t,e,s){this.paintContent(t,e,s);const i=e+this.y-this.staff.topOverflow;this.topEffects.paint(t+this.x,i,s);const n=e+this.y+this.height+this.staff.bottomOverflow-this.bottomEffects.height;this.bottomEffects.paint(t+this.x,n,s)}paintContent(t,e,s){this.paintBackground(t,e,s),s.color=this.resources.mainGlyphColor,this.QS.paint(t+this.x,e+this.y,s),this.voiceContainer.paint(t+this.x,e+this.y,s),s.color=this.resources.mainGlyphColor,this.ZS.paint(t+this.x,e+this.y,s),this.hB(t,e,s)}hB(t,e,s){const i=this.tB;if(i)for(const n of i)n.paint(t,e,s)}paintBackground(t,e,s){this.layoutingInfo.paint(t+this.x+this.QS.x+this.QS.width,e+this.y+this.height,s)}buildBoundingsLookup(t,e,s){const i=new Vn;i.bar=this.bar,i.visualBounds=new _s,i.visualBounds.x=e+this.x,i.visualBounds.y=s+this.y,i.visualBounds.w=this.width,i.visualBounds.h=this.height,i.realBounds=new _s,i.realBounds.x=e+this.x,i.realBounds.y=s+this.y,i.realBounds.w=this.width,i.realBounds.h=this.height,t.addBar(i),this.voiceContainer.buildBoundingsLookup(i,e+this.x,s+this.y)}addPostBeatGlyph(t){this.ZS.addGlyph(t)}createPreBeatGlyphs(){this.wasFirstOfStaff=this.isFirstOfStaff}createBeatGlyphs(){if(this.additionalMultiRestBars){const t=new Oo;this.addBeatGlyph(t)}else for(const t of this.bar.filledVoices)this.createVoiceGlyphs(this.bar.voices[t]);this.voiceContainer.doLayout(),(this.topEffects.isLinkedToPreviousRenderer||this.bottomEffects.isLinkedToPreviousRenderer)&&(this.isLinkedToPrevious=!0)}createVoiceGlyphs(t){this.topEffects.createVoiceGlyphs(t),this.bottomEffects.createVoiceGlyphs(t)}createPostBeatGlyphs(){}get beatGlyphsStart(){return this.voiceContainer.x}get postBeatGlyphsStart(){return this.ZS.x}getBeatX(t,e=Ua.PreNotes,s=!1){return this.beatGlyphsStart+this.voiceContainer.getBeatX(t,e,s)}getRatioPositionX(t){const e=this.bar.isEmpty?this.beatGlyphsStart:this.getBeatX(this.bar.voices[0].beats[0],Ua.MiddleNotes);return e+(this.postBeatGlyphsStart-e)*t}getNoteX(t,e){return this.beatGlyphsStart+this.voiceContainer.getNoteX(t,e)}getNoteY(t,e){return this.voiceContainer.y+ +this.voiceContainer.getNoteY(t,e)}getRestY(t,e){return this.voiceContainer.y+ +this.voiceContainer.getRestY(t,e)}reLayout(){this.topEffects.reLayout(),this.bottomEffects.reLayout(),this.updateSizes(),(this.wasFirstOfStaff&&!this.isFirstOfStaff||!this.wasFirstOfStaff&&this.isFirstOfStaff)&&(this.recreatePreBeatGlyphs(),this.ZS.doLayout()),this.iB(),this.calculateOverflows(0,this.height)}recreatePreBeatGlyphs(){this.QS=new Eo,this.QS.renderer=this,this.createPreBeatGlyphs()}paintSimileMark(t,e,s){const i=Kh.voice(s,ot.Glyphs,this.bar.voices[0],!0);try{switch(this.bar.simileMark){case H.Simple:s.beginGroup(Ja.getGroupId(this.bar.voices[0].beats[0])),pt.fillMusicFontSymbolSafe(s,t+this.x+this.width/2,e+this.y+this.height/2,1,xt.Repeat1Bar,!0),s.endGroup();break;case H.SecondOfDouble:s.beginGroup(Ja.getGroupId(this.bar.voices[0].beats[0])),s.beginGroup(Ja.getGroupId(this.bar.previousBar.voices[0].beats[0])),pt.fillMusicFontSymbolSafe(s,t+this.x,e+this.y+this.height/2,1,xt.Repeat2Bars,!0),s.endGroup(),s.endGroup()}}finally{i?.[Symbol.dispose]?.()}}completeBeamingHelper(t){}},qo=class extends vh{Xk;oB=xt.None;cB=0;lB=0;uB;constructor(t,e,s,i=!1){super(Ua.EndBeat),this.Xk=s,this.x=t,this.y=e,this.uB=i}doLayout(){switch(super.doLayout(),this.Xk){case P.Slight:this.oB=this.slightVibratoGlyph;break;case P.Wide:this.oB=this.wideVibratoGlyph}this.cB=this.renderer.smuflMetrics.repeatOffsetX.get(this.oB),this.lB=this.renderer.smuflMetrics.glyphTop.get(this.oB),this.height=this.renderer.smuflMetrics.glyphHeights.get(this.oB)}paintGrouped(t,e,s,i){let n=(s-(t+this.x))/this.cB;this.uB||(n=Math.floor(n)),n<1&&(n=1);const r=[];for(let t=0;t<n;t++)r.push(this.oB);i.fillMusicFontSymbols(t+this.x,e+this.y+this.lB,1,r,!1)}},Yo=class extends qo{get slightVibratoGlyph(){return xt.GuitarVibratoStroke}get wideVibratoGlyph(){return xt.GuitarWideVibratoStroke}},Ko=class extends f{lineValue=0;constructor(t=0,e=0){super(t,e),this.lineValue=e}},Qo=class t extends Xa{dB=[];fB=new Map;pB=-1;bB=-1;mB=-1;gB=-1;wB=-1;yB=-1;kB=-1;checkForOverflow=!1;constructor(){super(0,0)}addBends(t){this.dB.push(t);const e=this.SB(t);this.fB.set(t.id,e),(-1===this.kB||this.kB<t.maxBendPoint.value)&&(this.kB=t.maxBendPoint.value);let s=0;switch(t.bendType){case b.Bend:s=e[1].value,t.isTieOrigin?(-1===this.gB||s<this.gB)&&(this.gB=s):(-1===this.mB||s<this.mB)&&(this.mB=s);break;case b.Release:s=e[1].value,t.isTieOrigin?(-1===this.yB||s<this.yB)&&(this.yB=s):s>0&&(-1===this.wB||s<this.wB)&&(this.wB=s);break;case b.BendRelease:s=e[1].value,(-1===this.bB||s<this.bB)&&(this.bB=s),s=e[2].value,t.isTieOrigin?(-1===this.yB||s<this.yB)&&(this.yB=s):s>0&&(-1===this.wB||s<this.wB)&&(this.wB=s);break;case b.Prebend:s=e[0].value,(-1===this.pB||s<this.pB)&&(this.pB=s);break;case b.PrebendBend:s=e[0].value,(-1===this.pB||s<this.pB)&&(this.pB=s),s=e[1].value,t.isTieOrigin?(-1===this.gB||s<this.gB)&&(this.gB=s):(-1===this.mB||s<this.mB)&&(this.mB=s);break;case b.PrebendRelease:s=e[0].value,(-1===this.pB||s<this.pB)&&(this.pB=s),s=e[1].value,t.isTieOrigin?(-1===this.yB||s<this.yB)&&(this.yB=s):s>0&&(-1===this.wB||s<this.wB)&&(this.wB=s)}}doLayout(){super.doLayout(),this.BB();let t=0;for(const e of this.dB){const s=this.fB.get(e.id);switch(e.bendType){case b.Bend:s[1].lineValue=e.isTieOrigin?this.gB:this.mB;break;case b.Release:t=e.isTieOrigin?this.yB:this.wB,t>=0&&(s[1].lineValue=t);break;case b.BendRelease:s[1].lineValue=this.bB,t=e.isTieOrigin?this.yB:this.wB,t>=0&&(s[2].lineValue=t);break;case b.Prebend:s[0].lineValue=this.pB;break;case b.PrebendBend:s[0].lineValue=this.pB,s[1].lineValue=e.isTieOrigin?this.gB:this.mB;break;case b.PrebendRelease:s[0].lineValue=this.pB,t=e.isTieOrigin?this.yB:this.wB,t>=0&&(s[1].lineValue=t)}}this.width=0,this.dB.sort((t,e)=>t.isStringed?t.string-e.string:t.realValue-e.realValue)}BB(){const t=this.renderer.resources,e=this.renderer.smuflMetrics;let s=this.kB*e.tabBendPerValueHeight;s+=e.tabBendStaffPadding;const i=this.renderer.scoreRenderer.canvas;i.font=t.tablatureFont;s+=i.measureText("full").height+t.engravingSettings.tabBendLabelPadding,this.renderer.registerOverflowTop(s)}SB(t){const e=[];switch(t.bendType){case b.Custom:for(const s of t.bendPoints)e.push(new Ko(s.offset,s.value));break;case b.BendRelease:e.push(new Ko(0,t.bendPoints[0].value)),e.push(new Ko(f.MaxPosition/2|0,t.bendPoints[1].value)),e.push(new Ko(f.MaxPosition,t.bendPoints[3].value));break;case b.Bend:case b.Hold:case b.Prebend:case b.PrebendBend:case b.PrebendRelease:case b.Release:e.push(new Ko(0,t.bendPoints[0].value)),e.push(new Ko(f.MaxPosition,t.bendPoints[1].value))}return e}paint(t,e,s){const i=s.color;this.dB.length>1&&(s.color=this.renderer.resources.secondaryGlyphColor);for(const n of this.dB){const r=this.renderer;let a=n,h=!1,o=null,c=!1,l=null;for(;a.isTieOrigin;){const t=a.tieDestination;if(o=this.renderer.scoreRenderer.layout.getRendererForBar(this.renderer.staff.staffId,t.beat.voice.bar),!o||r.staff!==o.staff)break;if(a=t,h=!0,a.hasBend||!this.renderer.settings.notation.extendBendArrowsOnTiedNotes||a.vibrato!==P.None){c=!0;break}}l=a.beat,o=this.renderer.scoreRenderer.layout.getRendererForBar(this.renderer.staff.staffId,l.voice.bar),l.isLastOfVoice&&!a.hasBend&&this.renderer.settings.notation.extendBendArrowsOnTiedNotes&&(l=null);const u=r.smuflMetrics,d=u.glyphWidths.get(xt.ArrowheadBlackDown),f=e+r.y-u.tabBendStaffPadding;let p=t+r.x;const m=this.fB.get(n.id);m[0].value>0||n.isContinuedBend?p+=r.getBeatX(n.beat,Ua.MiddleNotes):p+=r.getNoteX(n,jo.Right);let g=0;!l||l.isLastOfVoice&&!c?(g=t+o.x+o.postBeatGlyphsStart,g-=this.renderer.smuflMetrics.postNoteEffectPadding):c||!l.nextBeat?g=t+o.x+o.getBeatX(l,Ua.MiddleNotes):n.bendType===b.Hold?g=t+o.x+o.getBeatX(l.nextBeat,Ua.OnNotes):(g=t+o.x+o.getBeatX(l.nextBeat,Ua.PreNotes),g-=this.renderer.smuflMetrics.postNoteEffectPadding),h||(g-=d/2),this._B(s,p,f,g,r,n,m),this.xB(s,t,g+d/2,f-u.tabBendPerValueHeight*m[m.length-1].lineValue,o,a),s.color=i}}xB(t,e,s,i,n,r){if(r.isTieDestination&&r.vibrato!==P.None&&!r.hasBend){const a=e+n.x,h=new Yo(s-a,0,r.vibrato);h.beat=r.beat,h.renderer=n,h.doLayout(),h.paint(a,i,t)}}_B(t,e,s,i,n,r,a){const h=t.lineWidth,o=this.renderer.resources,c=t.textBaseline;t.textBaseline=dt.Alphabetic,t.lineWidth=o.engravingSettings.arrowShaftThickness;const l=(i-e)/f.MaxPosition;for(let i=0,h=a.length-1;i<h;i++){const h=a[i];let o=a[i+1];0!==i||0===h.value||r.isTieDestination||this.TB(t,e,s,l,n,r,new Ko(0,0),h),r.bendType!==b.Prebend?(0===i&&(e+=this.renderer.smuflMetrics.postNoteEffectPadding),this.TB(t,e,s,l,n,r,h,o)):r.isTieOrigin&&r.tieDestination.hasBend&&(o=new Ko(f.MaxPosition,h.value),o.lineValue=h.lineValue,this.TB(t,e,s,l,n,r,h,o))}t.lineWidth=h,t.textBaseline=c}MB(t,e,s,i,n,r,a){if(r.value===a.value){if(r.lineValue>0){let n=i;const r=this.renderer.smuflMetrics.tabBendDashSize,a=e+r;if((n-e)/(2*r)<1)t.moveTo(n,s),t.lineTo(e,s);else for(;n>a;)t.moveTo(n,s),t.lineTo(n-r,s),n-=2*r;t.stroke()}}else if(i>e){const h=a.value>r.value?3:-3;t.moveTo(e,s),t.bezierCurveTo((e+i)/2,s,i,s,i,n+h),t.stroke()}else t.moveTo(e,s),t.lineTo(i,n),t.stroke()}TB(t,e,s,i,n,r,a,h){const o=n.lineOffset/2,c=n.resources,l=c.engravingSettings,u=e+i*a.offset;let d;0===a.value?(d=s+l.tabBendStaffPadding,h.offset===a.offset?d+=n.getNoteY(r.beat.maxStringNote,Xo.Top)-o:d+=n.getNoteY(r,Xo.Center)):d=s-l.tabBendPerValueHeight*a.lineValue;const f=e+i*h.offset;let p;p=0===h.lineValue?s+l.tabBendStaffPadding+n.getNoteY(r.beat.maxStringNote,Xo.Center):s-l.tabBendPerValueHeight*h.lineValue,this.MB(t,u,d,f,p,a,h);const b=l.glyphWidths.get(xt.ArrowheadBlackDown);if(a.value!==h.value){const e=h.value>a.value;this.vB(t,f,p,d,b,e),this.NB(t,u,d,f,p,r,c.graceFont),this.PB(t,d,f,p-l.tabBendLabelPadding,a,h,c.tablatureFont)}}NB(t,e,s,i,n,r,a){if(r.bendStyle===p.Gradual){const r="grad.",h=t.measureText(r);t.font=a;let o=0,c=0;if(s>n){const t=Math.abs(s-n);o=t>h.height?s-t/2:s,c=(e+i-h.width)/2}else o=s,c=i-h.width;t.fillText(r,c,o)}}PB(e,s,i,n,r,a,h){if(0!==a.value){const o=a.value>r.value;let c=a.value,l="";if(4===c)l="full",c-=4;else if(c>=4||c<=-4){const t=c/4|0;l+=t,c-=4*t}if(c>0&&(l+=t.getFractionSign(c)),""!==l){const t=o?n:s+1*Math.abs(n-s)/3;e.font=h;const r=i-e.measureText(l).width/2;e.fillText(l,r,t)}}}vB(t,e,s,i,n,r){r?(s+n>i&&(s=i-n),t.beginPath(),t.moveTo(e,s),t.lineTo(e-.5*n,s+n),t.lineTo(e+.5*n,s+n),t.closePath(),t.fill()):(s<i&&(s=i+n),t.beginPath(),t.moveTo(e,s),t.lineTo(e-.5*n,s-n),t.lineTo(e+.5*n,s-n),t.closePath(),t.fill())}static getFractionSign(t){switch(t){case 1:return"¼";case 2:return"½";case 3:return"¾";default:return`${t}/ 4`}}},Zo=class extends _h{$e;fB;CB=!1;originalTopOffset=0;originalBottomOffset=0;topOffset=0;bottomOffset=0;constructor(t){super(0,0),this.$e=t,this.fB=this.SB(t)}SB(t){if(t.whammyBarType===Lt.Custom)return t.whammyBarPoints;const e=[];switch(t.whammyBarType){case Lt.Dive:case Lt.Hold:case Lt.PrediveDive:case Lt.Predive:e.push(new f(0,t.whammyBarPoints[0].value)),e.push(new f(f.MaxPosition,t.whammyBarPoints[1].value));break;case Lt.Dip:e.push(new f(0,t.whammyBarPoints[0].value)),e.push(new f(f.MaxPosition/2|0,t.whammyBarPoints[1].value)),e.push(new f(f.MaxPosition,t.whammyBarPoints[t.whammyBarPoints.length-1].value))}return e}doLayout(){if(super.doLayout(),this.$e.whammyBarType===Lt.Custom)return;this.CB=this.renderer.settings.notation.notationMode===F.SongBook&&this.$e.whammyBarType===Lt.Dip;const t=this.$e.minWhammyPoint,e=this.$e.maxWhammyPoint;let s=e.value>0?-this.EB(e.value):0,i=t.value<0?-this.EB(t.value):0;const n=this.renderer.scoreRenderer.canvas;n.font=this.renderer.resources.tablatureFont;const r=n.measureText("-1").height+this.renderer.smuflMetrics.tabWhammyTextPadding;if((0!==s||0!==this.$e.whammyBarPoints[0].value||this.renderer.settings.notation.isNotationElementVisible(A.ZerosOnDiveWhammys))&&(s-=r),0!==i)if(this.CB)s-=r;else{const t=i-r;t<s&&(s=t)}s=Math.abs(s),i=Math.abs(i),this.topOffset=s,this.bottomOffset=i,this.originalTopOffset=s,this.originalBottomOffset=i,this.height=s+i,this.width=0}EB(t){if(0===t)return 0;let e=this.renderer.smuflMetrics.tabWhammyPerHalfHeight+Math.log2(Math.abs(t)/2)*this.renderer.smuflMetrics.tabWhammyPerHalfHeight;return t<0&&(e=-e),e}paint(t,e,s){const i=Kh.beat(s,zt.StandardNotationEffects,this.$e);try{const i=this.renderer;let n=this.$e.nextBeat,r=null,a=Ua.PreNotes;n&&(r=this.renderer.scoreRenderer.layout.getRendererForBar(this.renderer.staff.staffId,n.voice.bar),r&&r.staff===i.staff&&(r===i||n.hasWhammyBar)?a=!n.hasWhammyBar||i.settings.notation.notationMode===F.SongBook&&n.whammyBarType===Lt.Dip?Ua.PreNotes:Ua.MiddleNotes:(n=null,r=null));let h=0,o=0;this.CB?(h=t+i.getBeatX(this.$e,Ua.OnNotes,!0),o=t+i.getBeatX(this.$e,Ua.PostNotes,!0)):(h=t+i.getBeatX(this.$e,Ua.MiddleNotes,!0),o=r?t-i.x+r.x+r.getBeatX(n,a,!0):t+i.getBeatX(this.$e,Ua.EndBeat)-i.smuflMetrics.postNoteEffectPadding);const c=s.textAlign,l=s.textBaseline;if(s.textAlign=ut.Center,s.textBaseline=dt.Alphabetic,s.font=this.renderer.resources.tablatureFont,this.fB.length>=2){const t=(o-h)/f.MaxPosition;s.beginPath();const i=e+this.topOffset;let n=this.$e.whammyStyle===p.Gradual?"grad.":"";for(let e=0,r=this.fB.length-1;e<r;e++){const r=this.fB[e],a=this.fB[e+1];let o=0===e;0!==e||0===r.value||this.$e.isContinuedWhammy||(this.FB(!1,new f(0,0),r,h,i,t,s),o=!1),this.FB(o,r,a,h,i,t,s,n),n=""}s.stroke()}s.textAlign=c,s.textBaseline=l}finally{i?.[Symbol.dispose]?.()}}FB(t,e,s,i,n,r,a,h){const o=i+r*e.offset,c=i+r*s.offset,l=n-this.EB(e.value),u=n-this.EB(s.value);if(e.offset===s.offset){const t=this.renderer.smuflMetrics.tabWhammyDashSize;if(Math.abs(u-l)/(2*t)<1)a.moveTo(o,l),a.lineTo(c,u);else{const e=Math.max(l,u);let s=Math.min(l,u);for(;e>s;)a.moveTo(o,s),a.lineTo(o,s+t),s+=2*t}a.stroke()}else if(e.value===s.value){const t=this.renderer.smuflMetrics.tabWhammyDashSize;if(Math.abs(c-o)/(2*t)<1)a.moveTo(o,l),a.lineTo(c,u);else{let e=Math.max(o,c);const s=Math.min(o,c);for(;e>s;)a.moveTo(e,l),a.lineTo(e-t,l),e-=2*t}a.stroke()}else a.moveTo(o,l),a.lineTo(c,u);const d=this.renderer.smuflMetrics.tabWhammyTextPadding;!t||this.$e.isContinuedWhammy||this.CB||(this.renderer.settings.notation.isNotationElementVisible(A.ZerosOnDiveWhammys)&&a.fillText("0",o,l-d),h&&a.fillText(h,o,l-d));let f=Math.abs(s.value);if((0!==f||this.renderer.settings.notation.isNotationElementVisible(A.ZerosOnDiveWhammys)&&!this.CB)&&e.value!==s.value){let t="";if(s.value<0&&(t+="-"),f>=4){const e=f/4|0;t+=e,f-=4*e}else 0===f&&(t+="0");f>0&&(t+=Qo.getFractionSign(f));let i=0;i=this.CB||e.offset===s.offset?Math.min(l,u):u;const n=c;a.fillText(t,n,i-d)}}},tc=class extends Th{get notationElement(){return A.EffectWhammyBar}get effectId(){return`${super.effectId}.simpledip`}get hideOnMultiTrack(){return!1}get canShareBand(){return!1}get sizingMode(){return Bh.SingleOnBeat}shouldCreateGlyph(t,e){return t.notation.notationMode===F.SongBook&&e.hasWhammyBar&&e.whammyBarType===Lt.Dip}createNewGlyph(t,e){return new Zo(e)}canExpand(t,e){return!0}},ec=class extends qo{get slightVibratoGlyph(){return xt.WiggleSawtoothNarrow}get wideVibratoGlyph(){return xt.WiggleSawtooth}},sc=class extends Th{get notationElement(){return A.EffectSlightBeatVibrato}get hideOnMultiTrack(){return!1}get canShareBand(){return!0}get sizingMode(){return Bh.GroupedOnBeatToEnd}shouldCreateGlyph(t,e){return e.vibrato===P.Slight}createNewGlyph(t,e){return new ec(0,0,P.Slight)}canExpand(t,e){return!0}},ic=class extends ro{AB;get notationElement(){return A.EffectSlightNoteVibrato}shouldCreateGlyphForNote(t){let e=t.vibrato===P.Slight||t.isTieDestination&&t.tieOrigin.vibrato===P.Slight;return this.AB&&e&&t.isTieDestination&&t.tieOrigin.hasBend&&(e=!1),e}get sizingMode(){return Bh.GroupedOnBeatToEnd}createNewGlyph(t,e){return new Yo(0,0,P.Slight)}constructor(t){super(),this.AB=t}},nc=class extends _h{constructor(){super(0,0)}doLayout(){super.doLayout(),this.height=this.renderer.smuflMetrics.glyphHeights.get(xt.KeyboardPedalPed)}paint(t,e,s){const i=this.renderer,n=e+this.y,r=this.height,a=i.bar.sustainPedals,h=this.renderer.smuflMetrics.glyphWidths.get(xt.KeyboardPedalPed),o=this.renderer.smuflMetrics.glyphWidths.get(xt.KeyboardPedalUp);let c=0;for(;c<a.length;){let e=a[c];for(;null!=e;){const i=t+this.renderer.getRatioPositionX(e.ratioPosition);let l=0;if(e.pedalType===U.Down?(pt.fillMusicFontSymbolSafe(s,i,n+r,1,xt.KeyboardPedalPed,!0),l=h/2+this.renderer.smuflMetrics.sustainPedalLinePadding):e.pedalType===U.Up&&(pt.fillMusicFontSymbolSafe(s,i,n+r,1,xt.KeyboardPedalUp,!0),l=o/2+this.renderer.smuflMetrics.sustainPedalLinePadding),e.nextPedalMarker)if(e.nextPedalMarker.bar===e.bar){let a=t+this.renderer.getRatioPositionX(e.nextPedalMarker.ratioPosition);switch(e.nextPedalMarker.pedalType){case U.Down:a-=h/2;break;case U.Hold:break;case U.Up:a-=o/2}const c=i+l;a>c&&s.fillRect(c,n+r-this.renderer.smuflMetrics.pedalLineThickness,a-c,this.renderer.smuflMetrics.pedalLineThickness)}else{const e=t+this.x+this.width,a=i+l;s.fillRect(a,n+r-this.renderer.smuflMetrics.pedalLineThickness,e-a,this.renderer.smuflMetrics.pedalLineThickness)}if(0===c&&e.previousPedalMarker){const e=t+this.x,a=i-l;s.fillRect(e,n+r-this.renderer.smuflMetrics.pedalLineThickness,a-e,this.renderer.smuflMetrics.pedalLineThickness)}c++,null!=e.nextPedalMarker&&e.nextPedalMarker.bar!==e.bar?(e=null,c=a.length):e=e.nextPedalMarker}}}},rc=class extends Th{get notationElement(){return A.EffectSustainPedal}get hideOnMultiTrack(){return!1}get canShareBand(){return!1}get sizingMode(){return Bh.FullBar}shouldCreateGlyph(t,e){return 0===e.voice.index&&0===e.index&&e.voice.bar.sustainPedals.length>0}createNewGlyph(t,e){return new nc}canExpand(t,e){return!0}},ac=class t extends Th{get notationElement(){return A.EffectWhammyBarLine}get hideOnMultiTrack(){return!1}get canShareBand(){return!1}get sizingMode(){return Bh.GroupedOnBeatToEnd}shouldCreateGlyph(t,e){return e.hasWhammyBar}createNewGlyph(t,e){return new Zo(e)}canExpand(t,e){return e.hasWhammyBar}static offsetSharedDataKey="tab.whammy.offset";onAlignGlyphs(e){const s=e.renderer.staff.getSharedLayoutData(t.offsetSharedDataKey,[0,0]);e.renderer.staff.setSharedLayoutData(t.offsetSharedDataKey,s);for(const t of e.iterateAllGlyphs()){const e=t;e.originalTopOffset>s[0]&&(s[0]=e.originalTopOffset),e.originalBottomOffset>s[1]&&(s[1]=e.originalBottomOffset)}}finalizeBand(e){const s=e.renderer.staff.getSharedLayoutData(t.offsetSharedDataKey,[0,0]),i=s[0],n=s[1];for(const t of e.iterateAllGlyphs()){const e=t;e.topOffset=i,e.bottomOffset=n,e.height=i+n}e.slot.shared.height=i+n,e.height=i+n}},hc=class extends Th{get notationElement(){return A.EffectTap}get hideOnMultiTrack(){return!1}get canShareBand(){return!0}get sizingMode(){return Bh.SingleOnBeat}shouldCreateGlyph(t,e){return e.slap||e.pop||e.tap}createNewGlyph(t,e){const s=t.resources;return e.slap?new Fh(0,0,"S",s.elementFonts.get(A.EffectTap),ut.Center):e.pop?new Fh(0,0,"P",s.elementFonts.get(A.EffectTap),ut.Center):new Fh(0,0,"T",s.elementFonts.get(A.EffectTap),ut.Center)}canExpand(t,e){return!0}},oc=class extends _h{DB;constructor(t){super(0,0),this.DB=t}doLayout(){super.doLayout();const t=this.renderer.resources;this.height=this.renderer.smuflMetrics.glyphHeights.get(xt.MetNoteQuarterUp)*t.engravingSettings.tempoNoteScale}paint(t,e,s){for(const i of this.DB){let n=t+this.renderer.getRatioPositionX(i.ratioPosition);const r=this.renderer.resources;s.font=r.elementFonts.get(A.EffectMarker);const a=e+this.y+this.height+this.renderer.smuflMetrics.glyphBottom.get(xt.MetNoteQuarterUp)*r.engravingSettings.tempoNoteScale,h=s.textBaseline;if(s.textBaseline=dt.Alphabetic,i.text){const t=`${i.text} `,e=s.measureText(t);s.fillText(t,n,a),n+=e.width}else n-=r.engravingSettings.glyphWidths.get(xt.MetNoteQuarterUp)/2;pt.fillMusicFontSymbolSafe(s,n,a,r.engravingSettings.tempoNoteScale,xt.MetNoteQuarterUp),n+=this.renderer.smuflMetrics.glyphWidths.get(xt.MetNoteQuarterUp)*r.engravingSettings.tempoNoteScale,s.fillText(` = ${i.value.toString()}`,n,a),s.textBaseline=h,n+=s.measureText(` = ${i.value.toString()}`).width}}},cc=class extends Th{get notationElement(){return A.EffectTempo}get hideOnMultiTrack(){return!0}get canShareBand(){return!1}get sizingMode(){return Bh.SinglePreBeat}shouldCreateGlyph(t,e){return 0===e.voice.bar.staff.index&&0===e.voice.index&&0===e.index&&e.voice.bar.masterBar.tempoAutomations.some(t=>t.isVisible)}createNewGlyph(t,e){return new oc(e.voice.bar.masterBar.tempoAutomations.filter(t=>t.isVisible))}canExpand(t,e){return!0}},lc=class extends Th{get notationElement(){return A.EffectText}get hideOnMultiTrack(){return!1}get canShareBand(){return!1}get sizingMode(){return Bh.SingleOnBeat}shouldCreateGlyph(t,e){return!!e.text}createNewGlyph(t,e){return new Fh(0,0,e.text,t.resources.elementFonts.get(A.EffectText),ut.Left)}canExpand(t,e){return!0}},uc=class extends vh{constructor(t,e){super(Ua.EndBeat),this.x=t,this.y=e}doLayout(){super.doLayout(),this.height=this.renderer.smuflMetrics.glyphHeights.get(xt.OrnamentTrill)}paintGrouped(t,e,s,i){const n=this.renderer.smuflMetrics.glyphWidths.get(xt.OrnamentTrill),r=t+this.x+n,a=this.renderer.smuflMetrics.repeatOffsetX.get(xt.WiggleTrill),h=Math.ceil((s-r)/a),o=[xt.OrnamentTrill];for(let t=0;t<h;t++)o.push(xt.WiggleTrill);i.fillMusicFontSymbols(t+this.x-n/2,e+this.y+this.height,1,o,!1)}},dc=class extends ro{get notationElement(){return A.EffectTrill}shouldCreateGlyphForNote(t){return t.isTrill}get sizingMode(){return Bh.GroupedOnBeatToEnd}createNewGlyph(t,e){return new uc(0,0)}},fc=class extends _h{LB;WB=0;RB=0;constructor(t){super(0,0),this.LB=t}doLayout(){super.doLayout();const t=this.renderer.smuflMetrics.tempoNoteScale;this.height=this.renderer.smuflMetrics.glyphHeights.get(xt.MetNoteQuarterUp)*t,this.WB=this.renderer.smuflMetrics.glyphHeights.get(xt.Tuplet3)*t,this.RB=this.renderer.smuflMetrics.tripletFeelBracketPadding,this.height+=this.WB}paint(t,e,s){t+=this.x,e+=this.y;let i=0,n=0;switch(this.LB){case K.NoTripletFeel:i=0,n=0;break;case K.Triplet8th:i=0,n=2;break;case K.Triplet16th:i=1,n=3;break;case K.Dotted8th:i=0,n=4;break;case K.Dotted16th:i=1,n=5;break;case K.Scottish8th:i=0,n=6;break;case K.Scottish16th:i=1,n=7}const r=this.renderer.smuflMetrics.tempoNoteScale,a=e+this.renderer.smuflMetrics.glyphTop.get(xt.MetNoteQuarterUp)*r,h=e+this.height,o=s.textBaseline;s.textBaseline=dt.Bottom,s.font=this.renderer.resources.elementFonts.get(A.EffectTripletFeel),s.fillText("(",t,h),t+=s.measureText("( ").width,t=this.OB(t,a+this.WB,s,i),s.fillText(" = ",t,h),t+=s.measureText(" = ").width,t=this.OB(t,a+this.WB,s,n),s.fillText(" )",t,h),s.textBaseline=o}OB(t,e,s,i){const n=this.renderer.smuflMetrics.tempoNoteScale;let r=[],a=[];const h=[];let o=xt.None;switch(i){case 0:h.push(ut.Center),r=[xt.MetNoteQuarterUp],a=[xt.MetNoteQuarterUp];break;case 1:h.push(ut.Center),h.push(ut.Center),r=[xt.MetNoteQuarterUp],a=[xt.MetNoteQuarterUp];break;case 2:r=[xt.MetNoteQuarterUp],a=[xt.MetNote8thUp],o=xt.Tuplet3;break;case 3:h.push(ut.Center),h.push(ut.Right),r=[xt.MetNoteQuarterUp],a=[xt.MetNoteQuarterUp],o=xt.Tuplet3;break;case 4:h.push(ut.Center),h.push(ut.Right),r=[xt.MetNoteQuarterUp,xt.Space,xt.MetAugmentationDot],a=[xt.MetNoteQuarterUp];break;case 5:h.push(ut.Center),h.push(ut.Center),h.push(ut.Right),r=[xt.MetNoteQuarterUp,xt.Space,xt.MetAugmentationDot],a=[xt.MetNoteQuarterUp];break;case 6:h.push(ut.Center),h.push(ut.Left),r=[xt.MetNoteQuarterUp],a=[xt.MetNoteQuarterUp,xt.Space,xt.MetAugmentationDot];break;case 7:h.push(ut.Center),h.push(ut.Center),h.push(ut.Left),r=[xt.MetNoteQuarterUp],a=[xt.MetNoteQuarterUp,xt.Space,xt.MetAugmentationDot]}const c=this.renderer.smuflMetrics.glyphWidths.get(xt.MetNoteQuarterUp)*n,l=t+c-this.renderer.smuflMetrics.stemThickness*n,u=l+2*c+this.renderer.smuflMetrics.stemThickness*n,d=this.renderer.smuflMetrics.tempoNoteScale*this.renderer.smuflMetrics.beamThickness,f=this.renderer.smuflMetrics.tempoNoteScale*this.renderer.smuflMetrics.beamSpacing,p=this.renderer.smuflMetrics.brokenBeamWidth*n;let b=e-this.renderer.smuflMetrics.glyphHeights.get(xt.MetNoteQuarterUp)*n+d;if(o!==xt.None){const e=(t+u)/2,i=b-this.WB-this.RB,r=this.renderer.smuflMetrics.glyphTop.get(o)*n,a=this.renderer.smuflMetrics.glyphWidths.get(o)*n;pt.fillMusicFontSymbolSafe(s,e,i+r,n,o,!0);const h=e-a/2-this.RB,c=e+a/2+this.RB,l=this.WB/2,d=s.lineWidth;s.beginPath(),s.moveTo(t,i+l+l),s.lineTo(t,i+l),s.lineTo(h,i+l),s.moveTo(c,i+l),s.lineTo(u,i+l),s.lineTo(u,i+l+l),s.lineWidth=this.renderer.smuflMetrics.tupletBracketThickness*n,s.stroke(),s.lineWidth=d}s.fillMusicFontSymbols(t,e,n,r,!1),t+=c,t+=c,s.fillMusicFontSymbols(t,e,n,a,!1),t+=c,a[a.length-1]!==xt.MetAugmentationDot&&a[0]!==xt.MetNote8thUp||(t+=c);for(const t of h){switch(t){case ut.Left:s.fillRect(l,b,p,d);break;case ut.Center:s.fillRect(l,b,u-l,d);break;case ut.Right:s.fillRect(u-p,b,p,d)}b+=d+f}return t}},pc=class extends Th{get notationElement(){return A.EffectTripletFeel}get hideOnMultiTrack(){return!0}get canShareBand(){return!1}get sizingMode(){return Bh.SinglePreBeat}shouldCreateGlyph(t,e){return 0===e.index&&(0===e.voice.bar.masterBar.index&&e.voice.bar.masterBar.tripletFeel!==K.NoTripletFeel||e.voice.bar.masterBar.index>0&&e.voice.bar.masterBar.tripletFeel!==e.voice.bar.masterBar.previousMasterBar.tripletFeel)}createNewGlyph(t,e){return new fc(e.voice.bar.masterBar.tripletFeel)}canExpand(t,e){return!0}},bc=class t extends $h{constructor(e){super(0,0,1,t.Wk(e)),this.center=!0}static Wk(t){switch(t){case Ot.Open:return xt.GuitarOpenPedal;case Ot.Closed:return xt.GuitarClosePedal}return xt.None}paint(t,e,s){super.paint(t,e+this.height,s)}},mc=class extends Th{get notationElement(){return A.EffectWahPedal}get hideOnMultiTrack(){return!1}get canShareBand(){return!0}get sizingMode(){return Bh.SingleOnBeat}shouldCreateGlyph(t,e){return e.wahPedal!==Ot.None}createNewGlyph(t,e){return new bc(e.wahPedal)}canExpand(t,e){return!1}},gc=class extends Th{get notationElement(){return A.EffectWhammyBar}get hideOnMultiTrack(){return!1}get canShareBand(){return!1}get sizingMode(){return Bh.GroupedOnBeat}shouldCreateGlyph(t,e){return e.hasWhammyBar}createNewGlyph(t,e){return new Nh("w/bar",A.EffectWhammyBar)}canExpand(t,e){return!0}},wc=class extends Th{get notationElement(){return A.EffectWideBeatVibrato}get hideOnMultiTrack(){return!1}get canShareBand(){return!0}get sizingMode(){return Bh.GroupedOnBeatToEnd}shouldCreateGlyph(t,e){return e.vibrato===P.Wide}createNewGlyph(t,e){return new ec(0,0,P.Wide)}canExpand(t,e){return!0}},yc=class extends ro{get notationElement(){return A.EffectWideNoteVibrato}shouldCreateGlyphForNote(t){return t.vibrato===P.Wide||t.isTieDestination&&t.tieOrigin.vibrato===P.Wide}get sizingMode(){return Bh.GroupedOnBeatToEnd}createNewGlyph(t,e){return new Yo(0,0,P.Wide)}},kc=class extends Yh{IB=0;GB;constructor(t,e,s=ut.Center){super(t,e),this.glyphs=[],this.GB=s}doLayout(){const t=this.renderer.smuflMetrics.rowContainerGap,e=this.IB-t;let s=0;switch(this.GB){case ut.Left:s=0;break;case ut.Center:s=(this.width-e)/2;break;case ut.Right:s=this.width-e}for(const e of this.glyphs)e.x=s,s+=e.width+t}addGlyphToRow(t){this.glyphs.push(t),this.IB+=t.width+this.renderer.smuflMetrics.rowContainerGap,t.height>this.height&&(this.height=t.height)}},Sc=class extends Yh{HB=[];GB;constructor(t,e,s=ut.Center){super(t,e),this.height=0,this.glyphs=[],this.GB=s}doLayout(){let t=0,e=0;const s=this.renderer.smuflMetrics.rowContainerGap;this.HB=[];let i=new kc(t,e,this.GB);i.renderer=this.renderer,i.width=this.width;for(const n of this.glyphs){const r=t+n.width+s;r<this.width?(i.addGlyphToRow(n),t=Math.ceil(r)):(i.isEmpty||(i.doLayout(),this.HB.push(i),e+=i.height+s),t=0,i=new kc(t,e,this.GB),i.renderer=this.renderer,i.width=this.width,i.addGlyphToRow(n),t+=Math.ceil(n.width+s))}i.isEmpty||(i.doLayout(),this.HB.push(i),e+=Math.ceil(i.height+this.renderer.smuflMetrics.rowContainerPadding)),this.height=e}paint(t,e,s){for(const i of this.HB)i.paint(t+this.x,e+this.y,s)}},Bc=class extends Sc{addChord(t){if(t.strings.length>0){const e=new Dh(0,0,t,A.ChordDiagrams);e.renderer=this.renderer,e.doLayout(),this.glyphs.push(e)}}paint(t,e,s){if(this.glyphs.length>0){const i=Kh.score(s,bt.ChordDiagramList,this.renderer.scoreRenderer.score);try{super.paint(t,e,s)}finally{i?.[Symbol.dispose]?.()}}}},_c=class extends Sc{constructor(t,e){super(t,e,ut.Left)}},xc=class extends Yh{$B;VB;colorOverride;constructor(t,e,s,i){super(t,e),this.$B=s,this.VB=i,this.glyphs=[]}doLayout(){if(!(this.glyphs.length>0)){this.zB(this.$B);for(const t of this.glyphs)t.renderer=this.renderer,t.doLayout()}}paint(t,e,s){const i=s.color;this.colorOverride&&(s.color=this.colorOverride),super.paint(t,e,s),s.color=i}zB(t){const e=this.renderer.resources;if(this.height=0,this.VB.length>0){const t=new Fh(0,this.height,this.VB,e.elementFonts.get(A.GuitarTuning),ut.Left);t.renderer=this.renderer,t.doLayout(),this.height+=t.height,this.addGlyph(t)}if(t.name.length>0){const s=new Fh(0,this.height,t.name,e.elementFonts.get(A.GuitarTuning),ut.Left);s.renderer=this.renderer,s.doLayout(),this.height+=s.height,this.addGlyph(s)}const s=this.renderer.smuflMetrics.tuningGlyphCircleNumberScale,i=this.renderer.smuflMetrics.glyphHeights.get(xt.GuitarString0)*s;this.renderer.scoreRenderer.canvas.font=e.elementFonts.get(A.GuitarTuning);const n=(i+this.renderer.scoreRenderer.canvas.measureText(" = Gb").width)*e.engravingSettings.tuningGlyphStringColumnScale;if(this.width=Math.max(this.renderer.scoreRenderer.canvas.measureText(this.VB).width,Math.max(this.renderer.scoreRenderer.canvas.measureText(t.name).width,2*n)),!t.isStandard){const r=0|Math.ceil(t.tunings.length/2);let a=0;const h=this.height+this.renderer.smuflMetrics.tuningGlyphStringRowPadding;let o=h;for(let c=0,l=t.tunings.length;c<l;c++){const l=xt.GuitarString0+(c+1);this.addGlyph(new $h(a,o+i,s,l));const u=` = ${Me.getTextForTuning(t.tunings[c],!1)}`;this.addGlyph(new Fh(a+i,o+i/2,u,e.elementFonts.get(A.GuitarTuning),ut.Left,dt.Middle)),o+=i+this.renderer.smuflMetrics.tuningGlyphStringRowPadding;const d=o;this.height<d&&(this.height=d),c===r-1&&(o=h,a+=n)}}}},Tc=class t{rr=new Map;clear(){this.rr.clear()}startMultiSystemSlur(e){const s=t.UB(e.renderer.staff);let i;this.rr.has(s)?i=this.rr.get(s):(i={startedSlurs:new Map},this.rr.set(s,i)),i.startedSlurs.set(e.slurEffectId,{startGlyph:e})}static UB(t){return`${t.modelStaff.index}.${t.modelStaff.track.index}.${t.staffId}`}completeMultiSystemSlur(e){const s=t.UB(e.renderer.staff);if(!this.rr.has(s))return;const i=this.rr.get(s);if(i.startedSlurs.has(e.slurEffectId)){const t=i.startedSlurs.get(e.slurEffectId);return t.endGlyph=e,t.startGlyph}}*getAllContinuations(e){const s=t.UB(e.staff);if(!this.rr.has(s)||e.index>0)return;const i=this.rr.get(s);for(const t of i.startedSlurs.values())t.startGlyph.shouldCreateMultiSystemSlur(e)&&(yield t.startGlyph)}},Mc=class{W;XB=new Map;staffTrackGroup;system;barRenderers=[];x=0;y=0;height=0;index=0;staffIndex=0;isVisible=!1;jB=0;get isFirstInSystem(){return this.system.firstVisibleStaff===this}topEffectInfos=[];bottomEffectInfos=[];trackIndex=0;modelStaff;get staffId(){return this.W.staffId}staffTop=0;topPadding=0;bottomPadding=0;staffBottom=0;get contentTop(){return this.y+this.staffTop+this.topPadding+this.topOverflow}get contentBottom(){return this.y+this.topPadding+this.topOverflow+this.staffBottom}constructor(t,e,s,i){this.W=i,this.trackIndex=e,this.modelStaff=s,this.system=t;for(const t of i.effectBands)if(!t.shouldCreate||t.shouldCreate(s))switch(t.mode){case kh.OwnedTop:case kh.SharedTop:this.topEffectInfos.push(t);break;case kh.OwnedBottom:case kh.SharedBottom:this.bottomEffectInfos.push(t)}this.JB()}getSharedLayoutData(t,e){return this.XB.has(t)?this.XB.get(t):e}setSharedLayoutData(t,e){this.XB.set(t,e)}registerStaffTop(t){t>this.staffTop&&(this.staffTop=t)}registerStaffBottom(t){t>this.staffBottom&&(this.staffBottom=t)}addBarRenderer(t){t.staff=this,t.index=this.barRenderers.length,t.reLayout(),this.barRenderers.push(t),this.system.layout.registerBarRenderer(this.staffId,t),(t.bar.isEmpty||t.bar.isRestOnly)&&this.jB++,this.JB()}JB(){const t=this.modelStaff.track.score.stylesheet;t.hideEmptyStaves&&(t.hideEmptyStavesInFirstSystem||this.system.index>0)?this.isVisible=this.jB<this.barRenderers.length:this.isVisible=!0}addBar(t,e,s){const i=this.W.create(this.system.layout.renderer,t);i.topEffects.infos=this.topEffectInfos,i.bottomEffects.infos=this.bottomEffectInfos,i.additionalMultiRestBars=s,i.staff=this,i.index=this.barRenderers.length,i.layoutingInfo=e,i.doLayout(),this.barRenderers.push(i),this.system.layout.registerBarRenderer(this.staffId,i),(t.isEmpty||t.isRestOnly)&&this.jB++,this.JB()}revertLastBar(){this.resetSharedLayoutData();const t=this.barRenderers[this.barRenderers.length-1];this.barRenderers.splice(this.barRenderers.length-1,1),this.topOverflow=0,this.bottomOverflow=0;for(const t of this.barRenderers)t.afterStaffBarReverted();return(t.bar.isEmpty||t.bar.isRestOnly)&&this.jB--,this.JB(),t}resetSharedLayoutData(){this.XB.clear()}topOverflow=0;registerOverflowTop(t){t>this.topOverflow&&(this.topOverflow=t)}bottomOverflow=0;registerOverflowBottom(t){t>this.bottomOverflow&&(this.bottomOverflow=t)}calculateHeightForAccolade(){this.qB(),this.height=this.barRenderers.length>0?this.barRenderers[0].height:0,this.height>0&&(this.height+=Math.ceil(this.topPadding+this.topOverflow+this.bottomOverflow+this.bottomPadding))}qB(){const t=0===this.index,e=this.index===this.system.staves.length-1,s=this.system.layout.renderer.settings.display;this.topPadding=t?s.firstNotationStaffPaddingTop:s.notationStaffPaddingTop,this.bottomPadding=e?s.lastNotationStaffPaddingBottom:s.notationStaffPaddingBottom}finalizeStaff(){this.qB(),this.height=0;let t=!1,e=this.topOverflow;for(const e of this.barRenderers)e.registerMultiSystemSlurs(this.system.layout.slurRegistry.getAllContinuations(e)),e.finalizeRenderer()&&(t=!0),this.height=Math.max(this.height,e.height);if(t){e=this.topOverflow;for(const t of this.barRenderers)t.y=this.topPadding+e;for(const t of this.barRenderers)t.finalizeRenderer()}this.height>0&&(this.height+=this.topPadding+e+this.bottomOverflow+this.bottomPadding),this.height=Math.ceil(this.height),this.JB()}paint(t,e,s,i,n){if(0!==this.height&&0!==n)for(let r=i,a=Math.min(i+n,this.barRenderers.length);r<a;r++)this.barRenderers[r].paint(t+this.x,e+this.y,s)}},vc=class{timePosition=0;longestDuration=0;smallestDuration=0;force=0;springConstant=0;get springWidth(){return this.preSpringWidth+this.postSpringWidth}preBeatWidth=0;graceBeatWidth=0;postSpringWidth=0;get preSpringWidth(){return this.preBeatWidth+this.graceBeatWidth}allDurations=new Set},Nc=class t{static YB=30;static KB=7;QB=[];ZB=-1;t_=0;e_=new Map;s_=0;i_=new Map;n_=t.YB;version=0;preBeatSize=0;postBeatSize=0;minStretchForce=0;totalSpringConstant=0;get localMinDuration(){return this.n_}computedWithMinDuration=0;r_(t){this.minStretchForce<t&&(this.minStretchForce=t)}getBeatSizes(t){const e=t.absoluteDisplayStart;if(this.i_.has(e))return this.i_.get(e)}setBeatSizes(t,e){const s=t.absoluteDisplayStart;if(this.i_.has(s)){const t=this.i_.get(s);t.onBeatSize<e.onBeatSize&&(t.onBeatSize=e.onBeatSize),t.preBeatSize<e.preBeatSize&&(t.preBeatSize=e.preBeatSize)}else this.i_.set(s,e)}getPreBeatSize(t){if(t.graceType!==y.None){const e=t.graceGroup.id;return this.allGraceRods.get(e)[t.graceIndex].preBeatWidth}const e=t.absoluteDisplayStart;return this.springs.has(e)?this.springs.get(e).preBeatWidth:0}getPostBeatSize(t){if(t.graceType!==y.None){const e=t.graceGroup.id;return this.allGraceRods.get(e)[t.graceIndex].postSpringWidth}const e=t.absoluteDisplayStart;return this.springs.has(e)?this.springs.get(e).postSpringWidth:0}incompleteGraceRods=new Map;allGraceRods=new Map;springs=new Map;addSpring(t,e,s,i,n){let r;if(this.version++,this.springs.has(t))r=this.springs.get(t),r.postSpringWidth<n&&(r.postSpringWidth=n),r.graceBeatWidth<s&&(r.graceBeatWidth=s),r.preBeatWidth<i&&(r.preBeatWidth=i),e<r.smallestDuration&&(r.smallestDuration=e),e>r.longestDuration&&(r.longestDuration=e),r.allDurations.add(e);else{if(r=new vc,r.timePosition=t,r.allDurations.add(e),this.QB.length>0){let s=e;const i=this.QB[this.QB.length-1];for(const e of i.allDurations)i.timePosition+e>=t&&e<s&&(s=e);e<this.n_&&(this.n_=e)}r.longestDuration=e,r.postSpringWidth=n,r.graceBeatWidth=s,r.preBeatWidth=i,this.springs.set(t,r);const a=this.QB;let h=a.length-1;for(;h>0&&a[h].timePosition>t;)h--;this.QB.splice(h+1,0,r)}return(-1===this.ZB||this.ZB>t)&&(this.ZB=t),r}addBeatSpring(t,e,s){const i=t.absoluteDisplayStart;if(t.graceType!==y.None){const n=t.graceGroup.id;this.allGraceRods.has(n)||this.allGraceRods.set(n,new Array(t.graceGroup.beats.length)),t.graceGroup.isComplete||this.incompleteGraceRods.has(n)||this.incompleteGraceRods.set(n,new Array(t.graceGroup.beats.length));const r=this.allGraceRods.get(n)[t.graceIndex];if(r)r.postSpringWidth<s&&(r.postSpringWidth=s),r.preBeatWidth<e&&(r.preBeatWidth=e);else{const r=new vc;r.timePosition=i,r.postSpringWidth=s,r.preBeatWidth=e,t.graceGroup.isComplete||(this.incompleteGraceRods.get(n)[t.graceIndex]=r),this.allGraceRods.get(n)[t.graceIndex]=r}}else{let n=0;if(t.graceGroup&&this.allGraceRods.has(t.graceGroup.id))for(const e of this.allGraceRods.get(t.graceGroup.id))n+=e.springWidth;this.addSpring(i,t.displayDuration,n,e,s)}}finish(){for(const[t,e]of this.allGraceRods){let t=0;for(const s of e)t+=s.preBeatWidth,s.graceBeatWidth=t,t+=s.postSpringWidth}this.s_=0;for(const t of this.incompleteGraceRods.values())for(const e of t)this.s_+=e.preBeatWidth+e.postSpringWidth;this.a_(this.n_),this.computedWithMinDuration=this.n_,this.version++}recomputeSpringConstants(t){this.a_(t),this.computedWithMinDuration=t,this.version++}a_(t){let e=0;const s=this.QB;if(0===s.length)return this.totalSpringConstant=-1,void(this.minStretchForce=-1);for(let i=0;i<s.length;i++){const n=s[i];let r=0;if(i===s.length-1)r=n.longestDuration;else{const t=s[i+1];r=Math.abs(t.timePosition-n.timePosition)}n.springConstant=this.h_(n,r,t),e+=1/n.springConstant}this.totalSpringConstant=1/e,this.minStretchForce=0;for(let t=0;t<s.length;t++){const e=s[t];let i=0;if(t===s.length-1)i=e.postSpringWidth;else{const n=s[t+1];i=e.postSpringWidth+n.preSpringWidth}0===t&&(i+=e.preSpringWidth);const n=i*e.springConstant;this.r_(n)}}height=0;paint(t,e,s){}h_(e,s,i){s<=0&&(s=c.toTicks(w.TwoHundredFiftySixth)),0===e.smallestDuration&&(e.smallestDuration=s);const n=e.smallestDuration,r=t.KB;return n/s*(1/((1+.85*Math.log2(s/i))*r))}spaceToForce(t){return-1!==this.totalSpringConstant?(this.QB.length>0&&(t-=this.QB[0].preSpringWidth),t-=this.s_,Math.max(t,0)*this.totalSpringConstant):-1}calculateVoiceWidth(t){let e=0;return-1!==this.totalSpringConstant&&(e=this.o_(t,this.totalSpringConstant)),this.QB.length>0&&(e+=this.QB[0].preSpringWidth),e+=this.s_,e}o_(t,e){return t/e}buildOnTimePositions(t){if(-1===this.totalSpringConstant)return new Map;if(Bt.isAlmostEqualTo(this.t_,t)&&this.e_)return this.e_;this.t_=t;const e=new Map;this.e_=e;const s=this.QB;if(0===s.length)return e;let i=s[0].preSpringWidth;for(let n=0;n<s.length;n++)e.set(s[n].timePosition,i),i+=this.o_(t,s[n].springConstant);return e}},Pc=class{width=0;isLinkedToPrevious=!1;canWrap=!0;masterBar;additionalMultiBarRestIndexes=null;maxFixedOverhead=0;maxContentWidth=0;get lastMasterBarIndex(){return this.additionalMultiBarRestIndexes?this.additionalMultiBarRestIndexes[this.additionalMultiBarRestIndexes.length-1]:this.masterBar.index}renderers=[];layoutingInfo},Cc=class{track;staffSystem;staves=[];firstVisibleStaff;lastVisibleStaff;bracket=null;constructor(t,e){this.staffSystem=t,this.track=e}addStaff(t){this.staves.push(t)}},Ec=class{c_;firstStaffInBracket;lastStaffInBracket;firstVisibleStaffInBracket;lastVisibleStaffInBracket;drawAsBrace=!1;braceScale=1;width=0;index=0;canPaint=!1;constructor(t){this.c_=t}updateCanPaint(){let t,e;for(let s=this.firstStaffInBracket.index;s<=this.lastStaffInBracket.index;s++){const i=this.c_.allStaves[s];i.isVisible&&(t||(t=i),e=i)}this.firstVisibleStaffInBracket=t,this.lastVisibleStaffInBracket=e,t&&e&&(this.c_.layout.renderer.score.stylesheet.showSingleStaffBrackets||t!==e)?this.canPaint=!0:this.canPaint=!1}finalizeBracket(t){if(!this.canPaint)return void(this.width=0);const e=t.glyphHeights.get(xt.Brace),s=t.glyphWidths.get(xt.Brace);if(this.drawAsBrace?this.width=s:this.width=t.bracketThickness,!this.drawAsBrace)return;const i=this.firstVisibleStaffInBracket.contentTop,n=(this.lastVisibleStaffInBracket.contentBottom-i)/e;this.braceScale=n,this.width=s*this.braceScale}},Fc=class t extends Ec{track;constructor(e,s){super(e),this.track=s,this.drawAsBrace=t.isTrackDrawAsBrace(s)}includesStaff(t){return t.modelStaff.track===this.track}static isTrackDrawAsBrace(t){return t.staves.filter(t=>t.showStandardNotation).length>1}},Ac=class extends Fc{includesStaff(t){return t.modelStaff.track===this.track||!this.drawAsBrace&&this.track.playbackInfo.program===t.modelStaff.track.playbackInfo.program}},Dc=class{l_=!1;cr=[];u_=new Map;d_=0;f_=!1;x=0;y=0;index=0;accoladeWidth=0;isFull=!1;width=0;computedWidth=0;totalBarDisplayScale=0;totalFixedOverhead=0;totalContentWidth=0;minDuration=-1;isMinDurationDirty=!1;shareMinDurationAcrossBars=!0;isLast=!1;masterBarsRenderers=[];staves=[];layout;topPadding;bottomPadding;allStaves=[];firstVisibleStaff;constructor(t){this.layout=t,this.topPadding=t.renderer.settings.display.systemPaddingTop,this.bottomPadding=t.renderer.settings.display.systemPaddingBottom}get firstBarIndex(){return this.masterBarsRenderers[0].masterBar.index}get lastBarIndex(){return this.masterBarsRenderers[this.masterBarsRenderers.length-1].lastMasterBarIndex}addMasterBarRenderers(t,e){if(0===t.length)return null;this.masterBarsRenderers.push(e),e.layoutingInfo.preBeatSize=0;let s,i=0,n=!1;for(const t of this.staves){let r,a;for(const h of t.staves){const t=e.renderers[i++];h.addBarRenderer(t),h.isVisible&&(n=!0,r||(r=h),s||(s=h),a=h)}t.firstVisibleStaff=r,t.lastVisibleStaff=a,s||(s=r)}if(!n){const t=this.staves[0],e=t.staves[0];e.isVisible=!0,t.firstVisibleStaff=e,t.lastVisibleStaff=e,s=e}return this.firstVisibleStaff=s,this.p_(t),this.b_(e.layoutingInfo),this.m_(),e}addBars(t,e,s){const i=new Pc;let n;i.additionalMultiBarRestIndexes=s,i.layoutingInfo=new Nc,i.masterBar=t[0].score.masterBars[e],this.masterBarsRenderers.push(i);let r=!1;const a=i.layoutingInfo;for(const t of this.staves){let h,o;for(const n of t.staves){const c=t.track.staves[n.modelStaff.index].bars[e],l=null==s?null:s.map(e=>t.track.staves[n.modelStaff.index].bars[e]);n.addBar(c,a,l),n.isVisible&&(r=!0,h||(h=n),o=n);const u=n.barRenderers[n.barRenderers.length-1];i.renderers.push(u),u.isLinkedToPrevious&&(i.isLinkedToPrevious=!0),u.canWrap||(i.canWrap=!1)}t.firstVisibleStaff=h,t.lastVisibleStaff=o,n||(n=h)}if(!r){const t=this.staves[0],e=t.staves[0];e.isVisible=!0,t.firstVisibleStaff=e,t.lastVisibleStaff=e,n=e}return this.firstVisibleStaff=n,this.p_(t),a.finish(),this.b_(a),i.width=this.m_(),i}b_(t){if(!this.shareMinDurationAcrossBars)return;const e=t.localMinDuration;(-1===this.minDuration||e<this.minDuration)&&(this.masterBarsRenderers.length>1&&e!==this.minDuration&&(this.isMinDurationDirty=!0),this.minDuration=e),t.computedWithMinDuration>this.minDuration&&t.recomputeSpringConstants(this.minDuration)}reconcileMinDurationIfDirty(){if(!this.isMinDurationDirty)return;let t=this.accoladeWidth,e=0,s=0;for(const i of this.masterBarsRenderers){i.layoutingInfo.computedWithMinDuration>this.minDuration&&i.layoutingInfo.recomputeSpringConstants(this.minDuration);let n=0,r=0,a=0;for(const t of i.renderers){t.applyLayoutingInfo(),t.computedWidth>a&&(a=t.computedWidth);const e=t.fixedOverhead;e>n&&(n=e);const s=Math.max(0,t.computedWidth-e);s>r&&(r=s)}i.maxFixedOverhead=n,i.maxContentWidth=r,i.width=a,t+=a,e+=n,s+=r}this.width=t,this.computedWidth=t,this.totalFixedOverhead=e,this.totalContentWidth=s,this.isMinDurationDirty=!1}getBarDisplayScale(t){return this.staves.length>1?t.bar.masterBar.displayScale:t.bar.displayScale}revertLastBar(){if(this.masterBarsRenderers.length>1){const t=this.masterBarsRenderers[this.masterBarsRenderers.length-1];this.masterBarsRenderers.splice(this.masterBarsRenderers.length-1,1);let e,s=0,i=0;for(const t of this.staves){let n,r;for(const e of t.staves){const t=e.revertLastBar(),a=t.computedWidth;a>s&&(s=a),t.afterReverted(),i=this.getBarDisplayScale(t),e.isVisible&&(n||(n=e),r=e)}t.firstVisibleStaff=n,t.lastVisibleStaff=r,e||(e=n)}return this.firstVisibleStaff=e,this.width-=s,this.computedWidth-=s,this.totalBarDisplayScale-=i,this.totalFixedOverhead-=t.maxFixedOverhead,this.totalContentWidth-=t.maxContentWidth,t}return null}m_(){let t=0,e=0,s=0,i=0;for(const n of this.allStaves){const r=n.barRenderers[n.barRenderers.length-1];r.applyLayoutingInfo(),i=this.getBarDisplayScale(r),r.computedWidth>t&&(t=r.computedWidth);const a=r.fixedOverhead;a>e&&(e=a);const h=Math.max(0,r.computedWidth-a);h>s&&(s=h)}const n=this.masterBarsRenderers[this.masterBarsRenderers.length-1];return n.maxFixedOverhead=e,n.maxContentWidth=s,this.totalBarDisplayScale+=i,this.totalFixedOverhead+=e,this.totalContentWidth+=s,this.width+=t,this.computedWidth+=t,t}p_(t){const e=this.layout.renderer.settings;if(this.l_)for(const t of this.cr)t.updateCanPaint(),t.finalizeBracket(e.display.resources.engravingSettings);else{this.l_=!0,this.accoladeWidth=0;const s=this.layout.renderer.score.stylesheet;if(this.layout.renderer.settings.notation.isNotationElementVisible(A.TrackNames)){const i=1===this.layout.renderer.tracks.length?s.singleTrackTrackNamePolicy:s.multiTrackTrackNamePolicy,n=0===this.index?s.firstSystemTrackNameMode:s.otherSystemsTrackNameMode,r=0===this.index?s.firstSystemTrackNameOrientation:s.otherSystemsTrackNameOrientation;let a=!1;switch(i){case et.Hidden:break;case et.FirstSystem:a=0===this.index;break;case et.AllSystems:a=!0}let h=!1;if(a){const s=this.layout.renderer.canvas;s.font=e.display.resources.elementFonts.get(A.TrackNames);for(const e of t){let t="";switch(n){case st.FullName:t=e.name;break;case st.ShortName:t=e.shortName}if(t.length>0){h=!0;const e=s.measureText(t);switch(r){case it.Horizontal:this.accoladeWidth=Math.ceil(Math.max(this.accoladeWidth,e.width));break;case it.Vertical:this.accoladeWidth=Math.ceil(Math.max(this.accoladeWidth,e.height))}}}this.accoladeWidth+=e.display.systemLabelPaddingLeft,h&&(this.accoladeWidth+=e.display.systemLabelPaddingRight)}}let i=0;for(const t of this.allStaves)t.y=i,t.calculateHeightForAccolade(),i+=t.height;let n=0;for(const t of this.cr)t.updateCanPaint(),t.finalizeBracket(e.display.resources.engravingSettings),n=Math.max(n,t.width);this.accoladeWidth+=n,this.width+=this.accoladeWidth,this.computedWidth+=this.accoladeWidth}}g_(t){for(let e=0,s=this.staves.length;e<s;e++){const s=this.staves[e];if(s.track===t)return s}return null}addStaff(t){const e=t.modelStaff.track;let s=this.g_(e);s||(s=new Cc(this,e),this.staves.push(s)),t.staffTrackGroup=s,t.system=this,t.index=this.allStaves.length,this.allStaves.push(t),s.addStaff(t);let i=this.cr.find(e=>e.includesStaff(t));if(!i)switch(e.score.stylesheet.bracketExtendMode){case tt.NoBrackets:break;case tt.GroupStaves:i=new Fc(this,e),i.index=this.cr.length,this.cr.push(i);break;case tt.GroupSimilarInstruments:i=new Ac(this,e),i.index=this.cr.length,this.cr.push(i)}i&&(i.firstStaffInBracket||(i.firstStaffInBracket=t),i.lastStaffInBracket=t,s.bracket=i,this.u_.set(t,i))}get height(){return Math.ceil(this.d_+this.topPadding+this.bottomPadding)}paint(t,e,s){if(this.paintPartial(t+this.x,e+this.y+this.topPadding,s,0,this.masterBarsRenderers.length),this.f_){const i=Kh.track(s,Pe.SystemSeparator,this.allStaves[0].modelStaff.track);try{const i=this.layout.renderer.settings.display.resources.engravingSettings,n=Math.min(0,i.glyphBottom.get(xt.SystemDivider)??0);pt.fillMusicFontSymbolSafe(s,t+this.x,e+this.y+this.height+n,1,xt.SystemDivider,!1),pt.fillMusicFontSymbolSafe(s,t+this.x+this.width-i.glyphWidths.get(xt.SystemDivider),e+this.y+this.height+n,1,xt.SystemDivider,!1)}finally{i?.[Symbol.dispose]?.()}}}paintPartial(t,e,s,i,n){for(const r of this.allStaves)r.isVisible&&r.paint(t,e,s,i,n);const r=this.layout.renderer.settings.display.resources;if(this.staves.length>0&&0===i){s.color=r.barSeparatorColor;const i=this.layout.renderer.settings,n=this.layout.renderer.settings.notation.isNotationElementVisible(A.TrackNames);if(s.font=r.elementFonts.get(A.TrackNames),n){const n=this.layout.renderer.score.stylesheet,r=1===this.layout.renderer.tracks.length?n.singleTrackTrackNamePolicy:n.multiTrackTrackNamePolicy,a=0===this.index?n.firstSystemTrackNameMode:n.otherSystemsTrackNameMode,h=0===this.index?n.firstSystemTrackNameOrientation:n.otherSystemsTrackNameOrientation;let o=!1;switch(r){case et.Hidden:break;case et.FirstSystem:o=0===this.index;break;case et.AllSystems:o=!0}if(o){const n=s.textBaseline,r=s.textAlign;for(const n of this.staves)if(n.firstVisibleStaff){const r=e+n.firstVisibleStaff.contentTop,o=e+n.lastVisibleStaff.contentBottom;let c="";switch(a){case st.FullName:c=n.track.name;break;case st.ShortName:c=n.track.shortName}const l=Kh.track(s,Pe.TrackName,n.track);try{if(c.length>0){const e=t+n.staves[0].x-i.display.accoladeBarPaddingRight-(n.bracket?.width??0)-i.display.systemLabelPaddingRight;switch(h){case it.Horizontal:s.textBaseline=dt.Middle,s.textAlign=ut.Right,s.fillText(c,e,(r+o)/2);break;case it.Vertical:s.textBaseline=dt.Bottom,s.textAlign=ut.Center,s.beginRotate(e,(r+o)/2,-90.1),s.fillText(c,0,0),s.endRotate()}}}finally{l?.[Symbol.dispose]?.()}}s.textBaseline=n,s.textAlign=r}}const a=!this.layout.renderer.score.stylesheet.extendBarLines;if(this.allStaves.length>0&&a){let i=null;for(const n of this.allStaves)if(n.isVisible){if(null!==i){const a=i.contentBottom,h=n.contentTop,o=t+i.x,c=i.barRenderers[0],l=Kh.bar(s,c.staffLineBarSubElement,c.bar);try{const t=Math.ceil(h-a);s.fillRect(o,e+a,r.engravingSettings.thinBarlineThickness,t)}finally{l?.[Symbol.dispose]?.()}}i=n}}this.w_(t,e,s)}}w_(t,e,s){const i=this.layout.renderer.settings;for(const n of this.cr)if(n.canPaint){const r=t+n.firstVisibleStaffInBracket.x,a=n.width,h=i.display.accoladeBarPaddingRight;let o=e+n.firstVisibleStaffInBracket.contentTop,c=e+n.lastVisibleStaffInBracket.contentBottom;if(n.drawAsBrace)pt.fillMusicFontSymbolSafe(s,r-h-a,c,n.braceScale,xt.Brace);else if(n.firstVisibleStaffInBracket!==n.lastVisibleStaffInBracket){const t=.25*i.display.resources.engravingSettings.oneStaffSpace;o-=t,c+=t;const e=3;s.fillRect(r-h-a,o-e,a,Math.ceil(c-o+2*e));const n=r-h-a;pt.fillMusicFontSymbolSafe(s,n,o,1,xt.BracketTop),pt.fillMusicFontSymbolSafe(s,n,Math.floor(c),1,xt.BracketBottom)}}}finalizeSystem(){const t=this.layout.renderer.settings;if(0===this.index&&(this.topPadding=t.display.firstSystemPaddingTop),this.isLast)this.bottomPadding=t.display.lastSystemPaddingBottom;else if(this.layout.renderer.score.stylesheet.useSystemSignSeparator&&this.layout.renderer.tracks.length>1){const e=t.display.resources.engravingSettings.glyphHeights.get(xt.SystemDivider);this.bottomPadding=Math.max(this.bottomPadding,e),this.f_=!0}if(!this.y_()){this.staves[0].staves[0].isVisible=!0,this.y_(!0)}for(const e of this.cr)e.finalizeBracket(t.display.resources.engravingSettings)}y_(t=!1){let e=0;const s=this.layout.renderer.settings,i=s.display.resources.engravingSettings,n=i.glyphHeights.get(xt.BracketTop),r=i.glyphHeights.get(xt.BracketBottom);let a,h=0,o=!1;for(const i of this.staves){let c,l;for(const u of i.staves){void 0!==a&&a.trackIndex!==u.trackIndex&&(e+=s.display.trackStaffPaddingBetween);const i=this.u_.has(u)?this.u_.get(u):void 0,d=i&&!i.drawAsBrace&&i.canPaint;if(d&&i.firstStaffInBracket===u){const t=n-u.topOverflow;t>0&&(e+=t)}if(u.x=this.accoladeWidth,u.y=e,t||u.finalizeStaff(),u.isVisible&&(e+=u.height,o=!0,a=u,c||(c=u),l=u),h=0,d&&i.lastStaffInBracket===u){const t=r-u.bottomOverflow;t>0&&(u.isVisible?e+=t:h=t)}}if(i.firstVisibleStaff=c,i.lastVisibleStaff=l,this.firstVisibleStaff||(this.firstVisibleStaff=c),t)break}return h&&(e+=h),this.d_=e,o}buildBoundingsLookup(t,e){if(this.layout.renderer.boundsLookup.isFinished)return;const s=this.allStaves[0],i=this.allStaves[this.allStaves.length-1],n=(e+=this.topPadding)+this.y+s.y,r=e+this.y+i.y+i.height-n,a=e+this.y,h=e+this.y+this.height-a,o=e+this.y+s.y+s.topPadding+s.topOverflow,c=e+this.y+i.y+i.height-i.bottomPadding-i.bottomOverflow-o,l=this.x+s.x,u=new jn;u.visualBounds=new _s,u.visualBounds.x=t+this.x,u.visualBounds.y=e+this.y,u.visualBounds.w=this.width,u.visualBounds.h=this.height-this.topPadding-this.bottomPadding,u.realBounds=new _s,u.realBounds.x=t+this.x,u.realBounds.y=e+this.y,u.realBounds.w=this.width,u.realBounds.h=this.height,this.layout.renderer.boundsLookup.addStaffSystem(u);const d=new Map;for(let t=0;t<this.staves.length;t++)for(const s of this.staves[t].staves)if(s.isVisible)for(const t of s.barRenderers){let i;d.has(t.bar.masterBar.index)?i=d.get(t.bar.masterBar.index):(i=new Un,i.index=t.bar.masterBar.index,i.isFirstOfLine=t.isFirstOfStaff,i.realBounds=new _s,i.realBounds.x=l+t.x,i.realBounds.y=a,i.realBounds.w=t.width,i.realBounds.h=h,i.visualBounds=new _s,i.visualBounds.x=l+t.x,i.visualBounds.y=n,i.visualBounds.w=t.width,i.visualBounds.h=r,i.lineAlignedBounds=new _s,i.lineAlignedBounds.x=l+t.x,i.lineAlignedBounds.y=o,i.lineAlignedBounds.w=t.width,i.lineAlignedBounds.h=c,this.layout.renderer.boundsLookup.addMasterBar(i),d.set(i.index,i)),t.buildBoundingsLookup(i,l,e+this.y+s.y)}}getBarX(t){if(0===this.allStaves.length||0===this.layout.renderer.tracks.length)return 0;const e=this.layout.renderer.tracks[0].staves[0].bars[t];return this.layout.getRendererForBar(this.allStaves[0].staffId,e).x}},Lc=class t{k_=new Map;pagePadding=null;profile=new Set;renderer;width=0;height=0;multiBarRestInfo=null;get scaledWidth(){return Math.round(this.width/this.renderer.settings.display.scale)}headerGlyphs=new Map;footerGlyphs=new Map;chordDiagrams=null;tuningGlyph=null;constructor(t){this.renderer=t}slurRegistry=new Tc;beamingRuleLookups=new Map;resize(){this.S_.clear(),this.slurRegistry.clear(),this.doResize()}layoutAndRender(t){this.slurRegistry.clear();const e=this.renderer.score;this.firstBarIndex=Bt.computeFirstDisplayedBarIndex(e,this.renderer.settings),this.lastBarIndex=Bt.computeLastDisplayedBarIndex(e,this.renderer.settings,this.firstBarIndex),this.multiBarRestInfo=Bt.buildMultiBarRestInfo(this.renderer.tracks,this.firstBarIndex,this.lastBarIndex),void 0!==t?.firstChangedMasterBar&&this.doUpdateForBars(t)||(this.S_.clear(),this.beamingRuleLookups.clear(),this.k_.clear(),this.profile=Bu.staveProfiles.get(this.renderer.settings.display.staveProfile),this.pagePadding=this.renderer.settings.display.padding.map(t=>t/this.renderer.settings.display.scale),this.pagePadding||(this.pagePadding=[0,0,0,0]),1===this.pagePadding.length?this.pagePadding=[this.pagePadding[0],this.pagePadding[0],this.pagePadding[0],this.pagePadding[0]]:2===this.pagePadding.length&&(this.pagePadding=[this.pagePadding[0],this.pagePadding[1],this.pagePadding[0],this.pagePadding[1]]),this.B_(),this.doLayoutAndRender(t))}S_=new Map;getExistingPartialArgs(t){return this.S_.has(t)?this.S_.get(t).args:void 0}registerPartial(t,e){if(0===t.height)return;const s=this.renderer.settings.display.scale;if(t.x*=s,t.y*=s,t.width*=s,t.height*=s,t.totalWidth*=s,t.totalHeight*=s,this.renderer.settings.core.enableLazyLoading){const s={args:t,renderCallback:e};this.S_.set(t.id,s),this.renderer.partialLayoutFinished.trigger(t)}else this.renderer.partialLayoutFinished.trigger(t),this.__(t,e)}__(t,e){const s=this.renderer.canvas;s.beginRender(t.width,t.height),e(s),t.renderResult=s.endRender(),this.renderer.partialRenderFinished.trigger(t)}renderLazyPartial(t){if(this.S_.has(t)){const e=this.S_.get(t);this.__(e.args,e.renderCallback)}}static headerElements=new L(()=>new Map([[bt.Title,A.ScoreTitle],[bt.SubTitle,A.ScoreSubTitle],[bt.Artist,A.ScoreArtist],[bt.Album,A.ScoreAlbum],[bt.Words,A.ScoreWords],[bt.Music,A.ScoreMusic],[bt.WordsAndMusic,A.ScoreWordsAndMusic],[bt.Transcriber,void 0]]));static footerElements=new L(()=>new Map([[bt.Copyright,A.ScoreCopyright],[bt.CopyrightSecondLine,void 0]]));x_(t,e,s,i){switch(s){case bt.WordsAndMusic:if(e.words!==e.music)return;break;case bt.Words:case bt.Music:if(e.words===e.music)return;break;case bt.CopyrightSecondLine:if(!this.footerGlyphs.has(bt.Copyright))return}const n=t.display.resources,r=t.notation,a=e.style&&e.style.headerAndFooter.has(s)?e.style.headerAndFooter.get(s):gt.defaultHeaderAndFooter.get(s);let h=void 0===a.isVisible||a.isVisible;if(void 0!==i&&(h=r.isNotationElementVisible(i)),!h)return;const o=a.buildText(e);return o?new Fh(0,0,o,n.getFontForElement(s),a.textAlign,void 0,Kh.scoreColor(n,s,e)):void 0}B_(){O.debug("ScoreLayout","Creating score info glyphs");const e=this.renderer.settings,s=this.renderer.score;this.headerGlyphs=new Map,this.footerGlyphs=new Map;const i=new Jo(this.renderer,this.renderer.tracks[0].staves[0].bars[0]);for(const[n,r]of t.headerElements.value){const t=this.x_(e,s,n,r);t&&(t.renderer=i,t.doLayout(),this.headerGlyphs.set(n,t))}for(const[n,r]of t.footerElements.value){const t=this.x_(e,s,n,r);t&&(t.renderer=i,t.doLayout(),this.footerGlyphs.set(n,t))}const n=e.notation,r=e.display.resources;if(n.isNotationElementVisible(A.GuitarTuning)){const t=[];for(const e of this.renderer.tracks)for(const i of e.staves){let n=!i.isPercussion&&i.isStringed&&i.tuning.length>0&&i.showTablature;if(s.stylesheet.perTrackDisplayTuning&&s.stylesheet.perTrackDisplayTuning.has(e.index)&&!1===s.stylesheet.perTrackDisplayTuning.get(e.index)&&(n=!1),n){t.push(i);break}}if(t.length>0&&s.stylesheet.globalDisplayTuning){this.tuningGlyph=new _c(0,0),this.tuningGlyph.renderer=i;for(const e of t)if(e.stringTuning.tunings.length>0){const s=t.length>1?e.track.name:"",n=new xc(0,0,e.stringTuning,s);n.colorOverride=Kh.trackColor(r,Pe.StringTuning,e.track),n.renderer=i,n.doLayout(),this.tuningGlyph.addGlyph(n)}}else this.tuningGlyph=null}if(n.isNotationElementVisible(A.ChordDiagrams)){this.chordDiagrams=new Bc(0,0),this.chordDiagrams.renderer=i;const t=new Set;for(const e of this.renderer.tracks)if(s.stylesheet.globalDisplayChordDiagramsOnTop&&(null==s.stylesheet.perTrackChordDiagramsOnTop||!s.stylesheet.perTrackChordDiagramsOnTop.has(e.index)||s.stylesheet.perTrackChordDiagramsOnTop.get(e.index)))for(const s of e.staves){const e=s.chords;if(e)for(const[,s]of e)t.has(s.uniqueId)||s.showDiagram&&(t.add(s.uniqueId),this.chordDiagrams.addChord(s))}this.chordDiagrams.isEmpty&&(this.chordDiagrams=null)}else this.chordDiagrams=null}firstBarIndex=0;lastBarIndex=0;createEmptyStaffSystem(t){const e=new Dc(this);e.index=t;const s=Bu.defaultRenderers,i=[];for(let t=0;t<this.renderer.tracks.length;t++){const n=this.renderer.tracks[t];for(let r=0;r<n.staves.length;r++){const a=n.staves[r];let h,o=[],c=[];for(const r of s)if(this.profile.has(r.staffId)&&r.canCreate(n,a)){const s=new Mc(e,t,a,r);s.topEffectInfos.splice(0,0,...o),s.bottomEffectInfos.push(...c),h=s,i.push(s),o=[],c=[]}else for(const t of r.effectBands)switch(t.mode){case kh.SharedTop:o.push(t);break;case kh.SharedBottom:c.push(t)}h&&(o.length>0&&h.bottomEffectInfos.push(...o),c.length>0&&h.bottomEffectInfos.push(...c))}}for(const t of i)e.addStaff(t);return e}registerBarRenderer(t,e){if(this.k_.has(t)||this.k_.set(t,new Map),this.k_.get(t).set(e.bar.id,e),e.additionalMultiRestBars)for(const s of e.additionalMultiRestBars)this.k_.get(t).set(s.id,e)}getRendererForBar(t,e){const s=e.id;return this.k_.has(t)&&this.k_.get(t).has(s)?this.k_.get(t).get(s):null}layoutAndRenderBottomScoreInfo(e){e=Math.round(e);const s=new ka;s.x=0,s.y=e;let i=0;const n=this.renderer.settings.display.resources,r=[];let a=0;for(const[e,s]of t.footerElements.value)if(this.footerGlyphs.has(e)){const t=this.footerGlyphs.get(e);t.y=i,this.alignScoreInfoGlyph(t),i+=t.height,r.push(t),a=Math.max(a,Math.round(t.x+t.width))}return i=Math.round(i),r.length>0&&(s.width=a,s.height=i,s.totalWidth=this.scaledWidth,s.totalHeight=e+s.height,this.registerPartial(s,t=>{t.color=n.scoreInfoColor,t.textAlign=ut.Left,t.textBaseline=dt.Top;for(const e of r)e.paint(0,0,t)})),e+i}alignScoreInfoGlyph(t){if(Bu.getLayoutEngineFactory(this.renderer.settings.display.layoutMode).vertical)switch(t.textAlign){case ut.Left:t.x=this.pagePadding[0];break;case ut.Center:t.x=this.scaledWidth/2;break;case ut.Right:t.x=this.scaledWidth-this.pagePadding[2]}else t.x=this.firstBarX,t.textAlign=ut.Left}T_(t){const e=this.renderer.settings.display.resources,s=e.elementFonts.has(A.ScoreCopyright)?e.elementFonts.get(A.ScoreCopyright).families:e.tablatureFont.families,i=hi.withFamilyList(s,12,ri.Plain,ai.Bold),n=new Jo(this.renderer,this.renderer.tracks[0].staves[0].bars[0]),r=new Fh(0,0,"rendered by alphaTab",i,ut.Center,void 0,e.mainGlyphColor);r.renderer=n,r.doLayout(),this.alignScoreInfoGlyph(r);const a=new ka;return a.width=r.x+r.width,a.x=0,a.height=12,a.y=t,a.totalWidth=this.scaledWidth,a.totalHeight=t+12,a.firstMasterBarIndex=-1,a.lastMasterBarIndex=-1,this.registerPartial(a,t=>{t.color=e.mainGlyphColor,t.font=i,t.textAlign=ut.Left,t.textBaseline=dt.Top,r.paint(0,0,t)}),t+12}},Wc=class{x=0;width=0;masterBars=[];results=[]},Rc=class extends Lc{c_=null;get name(){return"HorizontalScreen"}get supportsResize(){return!1}get firstBarX(){let t=this.pagePadding[0];return this.c_&&(t+=this.c_.accoladeWidth),t}doResize(){}doUpdateForBars(t){return!1}doLayoutAndRender(t){const e=this.renderer.score;let s=this.renderer.settings.display.startBar;s--,s=Math.min(e.masterBars.length-1,Math.max(0,s));let i=s,n=this.renderer.settings.display.barCount;n<=0&&(n=e.masterBars.length),n=s+n-1,n=Math.min(e.masterBars.length-1,Math.max(0,n)),this.c_=this.createEmptyStaffSystem(0),this.c_.shareMinDurationAcrossBars=!1,this.c_.isLast=!0,this.c_.x=this.pagePadding[0],this.c_.y=this.pagePadding[1];const r=this.renderer.settings.display.barCountPerPartial,a=[];let h=new Wc;for(;i<=n;){const t=this.multiBarRestInfo,s=null!==t&&t.has(i)?t.get(i):null,n=this.c_.addBars(this.renderer.tracks,i,s);h.masterBars.length>=r&&!n.isLinkedToPrevious&&(h=this.M_(a,h)),this.v_(n),h.results.push(n),h.masterBars.push(e.masterBars[i]),h.width+=n.width,i++}h.masterBars.length>0&&this.M_(a,h),this.N_(),this.height=Math.floor(this.c_.y+this.c_.height),this.width=this.c_.x+this.c_.width+this.pagePadding[2],i=0;let o=0;for(let e=0;e<a.length;e++){const s=a[e],n=new ka;n.reuseViewport=t?.reuseViewport??!1,n.x=o,n.y=0,n.totalWidth=this.width,n.totalHeight=this.height,n.width=s.width,n.height=this.height,n.firstMasterBarIndex=s.masterBars[0].index,n.lastMasterBarIndex=s.masterBars[s.masterBars.length-1].index,o+=s.width;const r=i,h=e;this.c_.buildBoundingsLookup(0,0),this.registerPartial(n,t=>{let e=this.c_.getBarX(s.masterBars[0].index)+this.c_.accoladeWidth;0===h&&(e-=this.c_.x+this.c_.accoladeWidth),t.color=this.renderer.settings.display.resources.mainGlyphColor,t.textAlign=ut.Left,O.debug(this.name,`Rendering partial from bar ${s.masterBars[0].index} to ${s.masterBars[s.masterBars.length-1].index}`,null),this.c_.paintPartial(-e,this.c_.y,t,r,s.masterBars.length)}),i+=s.masterBars.length}this.height=this.layoutAndRenderBottomScoreInfo(this.height),this.height=this.T_(this.height),this.height+=this.pagePadding[3],this.height*=this.renderer.settings.display.scale}v_(t){t.width=0,this.c_.width-=t.width;for(const e of t.renderers){const s=e.staff.system.staves.length>1?e.bar.masterBar.displayWidth:e.bar.displayWidth;s>0&&e.scaleToWidth(s);const i=e.x+e.width;i>t.width&&(t.width=i)}this.c_.width+=t.width}M_(t,e){0===t.length&&(e.width+=this.c_.accoladeWidth+this.pagePadding[0]),t.push(e),O.debug(this.name,`Finished partial from bar ${e.masterBars[0].index} to ${e.masterBars[e.masterBars.length-1].index}`,null);const s=new Wc;return s.x=e.x+e.width,s}N_(){this.P_(),this.c_.finalizeSystem()}P_(){this.width=0;const t=this.c_;for(const e of t.allStaves){e.resetSharedLayoutData();let s=0;for(const t of e.barRenderers)t.x=s,t.y=e.topPadding+e.topOverflow,t.scaleToWidth(t.width),s+=t.width;s>this.width&&(t.width=s)}t.width+=t.accoladeWidth}},Oc=class extends Lc{C_=[];E_=[];F_=[];A_=!1;D_=[];L_=[];doLayoutAndRender(t){let e=this.pagePadding[1];this.width=this.renderer.width,this.E_=[],this.D_=[],this.L_=[],this.A_=t?.reuseViewport??!1,this.C_=[],e=this.W_(e,-1),e=this.R_(e,-1),e=this.O_(e,-1),e=this.I_(e,this.firstBarIndex),e=this.layoutAndRenderBottomScoreInfo(e),e=this.T_(e),this.height=(e+this.pagePadding[3])*this.renderer.settings.display.scale}registerPartial(t,e){t.reuseViewport=this.A_,super.registerPartial(t,e)}reregisterPartial(t){const e=this.getExistingPartialArgs(t);e&&(e.reuseViewport=this.A_,this.renderer.partialLayoutFinished.trigger(e))}get supportsResize(){return!0}get firstBarX(){let t=this.pagePadding[0];return this.C_.length>0&&(t+=this.C_[0].accoladeWidth),t}doUpdateForBars(t){this.A_=t.reuseViewport??!1;const e=t.firstChangedMasterBar,s=this.C_.findIndex(t=>{const s=t.masterBarsRenderers[0].masterBar.index,i=t.masterBarsRenderers[t.masterBarsRenderers.length-1].masterBar.index;return s<=e&&e<=i});if(-1===s||!this.renderer.settings.core.enableLazyLoading)return!1;const i=this.C_[s].masterBarsRenderers[0].masterBar.index;this.renderer.boundsLookup.clearFromMasterBar(i);const n=this.C_.splice(s,this.C_.length-s);this.L_.splice(s,this.L_.length-s);const r=n[0];let a=r.y;const h=r.masterBarsRenderers[0].masterBar.index;for(const t of this.D_)this.reregisterPartial(t);for(let t=0;t<s;t++)this.reregisterPartial(this.L_[t]);return a=this.I_(a,h),a=this.layoutAndRenderBottomScoreInfo(a),a=this.T_(a),this.height=(a+this.pagePadding[3])*this.renderer.settings.display.scale,!0}doResize(){let t=this.pagePadding[1];this.width=this.renderer.width;const e=this.height;this.A_=!0,t=this.W_(t,e),t=this.R_(t,e),t=this.O_(t,e),t=this.G_(t,e),t=this.layoutAndRenderBottomScoreInfo(t),t=this.T_(t),this.height=(t+this.pagePadding[3])*this.renderer.settings.display.scale}R_(t,e=-1){if(!this.tuningGlyph)return t;const s=this.renderer.settings.display.resources;this.tuningGlyph.x=this.pagePadding[0],this.tuningGlyph.width=this.scaledWidth-this.pagePadding[0]-this.pagePadding[2],this.tuningGlyph.doLayout();const i=Math.round(this.tuningGlyph.height),n=new ka;return n.x=0,n.y=t,n.width=this.scaledWidth,n.height=i,n.totalWidth=this.scaledWidth,n.totalHeight=e<0?t+n.height:e,this.registerPartial(n,t=>{t.color=s.scoreInfoColor,t.textAlign=ut.Center,this.tuningGlyph.paint(0,0,t)}),this.D_.push(n.id),t+i}O_(t,e=-1){if(!this.chordDiagrams)return t;const s=this.renderer.settings.display.resources;this.chordDiagrams.x=this.pagePadding[0],this.chordDiagrams.width=this.scaledWidth-this.pagePadding[0]-this.pagePadding[2],this.chordDiagrams.doLayout();const i=Math.round(this.chordDiagrams.height),n=new ka;return n.x=0,n.y=t,n.width=this.scaledWidth,n.height=i,n.totalWidth=this.scaledWidth,n.totalHeight=e<0?t+i:e,this.registerPartial(n,t=>{t.color=s.scoreInfoColor,t.textAlign=ut.Center,this.chordDiagrams.paint(0,0,t)}),this.D_.push(n.id),t+i}W_(t,e=-1){O.debug(this.name,"Layouting score info");const s=new ka;s.x=0,s.y=t;let i=0;const n=this.renderer.settings.display.resources,r=[];for(const[t,e]of Lc.headerElements.value)if(this.headerGlyphs.has(t)){const e=this.headerGlyphs.get(t);e.y=i,this.alignScoreInfoGlyph(e);let s=e.font.size;t===bt.Words&&this.headerGlyphs.has(bt.Music)&&this.headerGlyphs.get(bt.Music).textAlign!==e.textAlign&&(s=0),i+=s,r.push(e)}return r.length>0&&(i=Math.floor(i+17),s.width=this.scaledWidth,s.height=i,s.totalWidth=this.scaledWidth,s.totalHeight=e<0?t+s.height:e,this.registerPartial(s,t=>{t.color=n.scoreInfoColor,t.textAlign=ut.Center;for(const e of r)e.paint(0,0,t)}),this.D_.push(s.id)),t+i}G_(t,e){const s=this.getBarsPerSystem(0)>0;if(this.L_=[],s)for(let s=0;s<this.C_.length;s++){const i=this.C_[s];i.width=i.computedWidth,this.H_(i),t+=this.V_(i,e)}else{for(const t of this.E_)for(const e of t.renderers)e.afterReverted();this.C_=[];let s=0;const i=this.z_;let n=this.createEmptyStaffSystem(this.C_.length);for(n.x=this.pagePadding[0],n.y=t;s<this.E_.length;){let r=this.E_[s];if(n.width+r.width<=i||0===n.masterBarsRenderers.length)n.addMasterBarRenderers(this.renderer.tracks,r),s++,this.U_(s)&&(n.isFull=!0);else{for(;r&&!r.canWrap&&n.masterBarsRenderers.length>1;)r=n.revertLastBar(),s--;n.isFull=!0}n.isFull&&(n.isLast=this.lastBarIndex===n.lastBarIndex,this.C_.push(n),this.H_(n),t+=this.V_(n,e),n=this.createEmptyStaffSystem(this.C_.length),n.x=this.pagePadding[0],n.y=t)}n.isLast=this.lastBarIndex===n.lastBarIndex,this.H_(n),t+=this.V_(n,e)}return t}I_(t,e){let s=e;const i=this.lastBarIndex;for(;s<=i;){const e=this.X_(s,i);this.C_.push(e),e.x=this.pagePadding[0],e.y=t,s=e.lastBarIndex+1,this.H_(e),O.debug(this.name,`Rendering partial from bar ${e.firstBarIndex} to ${e.lastBarIndex}`,null),t+=this.V_(e,t)}return t}V_(t,e){const s=Math.floor(t.height),i=new ka;return i.x=0,i.y=t.y,i.totalWidth=this.scaledWidth,i.totalHeight=e,i.width=this.scaledWidth,i.height=s,i.firstMasterBarIndex=t.firstBarIndex,i.lastMasterBarIndex=t.lastBarIndex,t.buildBoundingsLookup(0,0),this.registerPartial(i,e=>{this.renderer.canvas.color=this.renderer.settings.display.resources.mainGlyphColor,this.renderer.canvas.textAlign=ut.Left,t.paint(0,-i.y/this.renderer.settings.display.scale,e)}),this.L_.push(i.id),s}H_(t){t.reconcileMinDurationIfDirty(),t.isFull||t.width>this.z_||this.renderer.settings.display.justifyLastSystem?this.j_(t,this.z_):this.j_(t,t.width),t.finalizeSystem()}j_(t,e){const s=e-t.accoladeWidth,i=this.shouldApplyBarScale,n=i?t.totalBarDisplayScale:t.totalContentWidth,r=Math.max(0,s-t.totalFixedOverhead),a=n>0?r/n:0;for(const e of t.allStaves){e.resetSharedLayoutData();let s=0;for(let n=0;n<e.barRenderers.length;n++){const r=e.barRenderers[n],h=t.masterBarsRenderers[n];r.x=s,r.y=e.topPadding+e.topOverflow;const o=i?t.getBarDisplayScale(r):h.maxContentWidth,c=h.maxFixedOverhead+o*a;r.scaleToWidth(c),s+=r.width}}t.width=e}X_(t,e){const s=this.createEmptyStaffSystem(this.C_.length),i=this.getBarsPerSystem(s.index),n=this.z_,r=e+1;let a=t;for(;a<r;){if(this.F_.length>0)for(const t of this.F_)s.addMasterBarRenderers(this.renderer.tracks,t),a=t.lastMasterBarIndex;else{const t=this.multiBarRestInfo,e=null!==t&&t.has(a)?t.get(a):null,i=s.addBars(this.renderer.tracks,a,e);this.E_.push(i),a=i.lastMasterBarIndex}this.F_=[];let t=!1;if((-1===i&&s.width>=n&&0!==s.masterBarsRenderers.length||s.masterBarsRenderers.length===i+1)&&(t=!0),t){let t=s.revertLastBar();if(t)for(this.F_.push(t);t&&!t.canWrap&&s.masterBarsRenderers.length>1;)t=s.revertLastBar(),t&&this.F_.push(t);return s.isFull=!0,s.isLast=!1,this.F_.reverse(),s}if(this.U_(a))return s.isFull=!0,s.isLast=!1,s;s.x=0,a++}return s.isLast=e===s.lastBarIndex,s}U_(t){let e=!1,s=!0;for(const i of this.renderer.tracks)i.lineBreaks&&i.lineBreaks.has(t+1)?e=!0:s=!1;return e&&s}get z_(){return this.scaledWidth-this.pagePadding[0]-this.pagePadding[2]}},Ic=class extends Oc{get name(){return"PageView"}getBarsPerSystem(t){let e=this.renderer.settings.display.barsPerRow;return this.renderer.settings.display.systemsLayoutMode===li.UseModelLayout&&(e=Bt.getSystemLayout(this.renderer.score,t,this.renderer.tracks)),e}get shouldApplyBarScale(){return this.renderer.settings.display.systemsLayoutMode===li.UseModelLayout}},Gc=class extends Oc{get name(){return"Parchment"}getBarsPerSystem(t){return Bt.getSystemLayout(this.renderer.score,t,this.renderer.tracks)}get shouldApplyBarScale(){return!0}},Hc=class extends Xa{doLayout(){this.width=this.renderer.smuflMetrics.thinBarlineThickness}paint(t,e,s){this.paintExtended(t,e,s,this.height)}},$c=class extends Hc{J_;constructor(t,e,s){super(t,e),this.J_=s}doLayout(){this.width=this.J_?this.renderer.smuflMetrics.repeatEndingLineThickness:this.renderer.smuflMetrics.thinBarlineThickness}paintExtended(t,e,s,i){s.fillRect(t+this.x,e+this.y,this.renderer.smuflMetrics.thinBarlineThickness,i)}},Vc=class extends Hc{paintExtended(t,e,s,i){const n=this.renderer.smuflMetrics.thinBarlineThickness/2,r=this.renderer.getLineHeight(1);let a=e+this.y+.5*r+n;const h=e+this.y+i;for(;a<h;)s.fillCircle(t+this.x,a,n),a+=r}},zc=class extends Hc{paintExtended(t,e,s,i){const n=this.renderer.smuflMetrics.dashedBarlineDashLength,r=t+this.x-this.width/2,a=Math.ceil(i/2/n),h=e+this.y+i,o=this.renderer.smuflMetrics.dashedBarlineGapLength,c=s.lineWidth;if(s.lineWidth=this.renderer.smuflMetrics.dashedBarlineThickness,s.beginPath(),a<1)s.moveTo(r,e+this.y),s.lineTo(r,h);else{let t=e+this.y;for(;t<h;){s.moveTo(r,t);const e=Math.min(h-t,n);s.lineTo(r,t+e),t+=n+o}}s.stroke(),s.lineWidth=c}},Uc=class extends Hc{doLayout(){this.width=this.renderer.smuflMetrics.thickBarlineThickness}paintExtended(t,e,s,i){s.fillRect(t+this.x,e+this.y,this.width,i)}},Xc=class extends Hc{doLayout(){this.width=this.renderer.smuflMetrics.glyphWidths.get(xt.RepeatDot)}paintExtended(t,e,s,i){const n=this.renderer,r=n.heightLineCount%2==0?1:.5,a=e+this.y+this.height/2,h=n.getLineHeight(r),o=n.smuflMetrics.glyphTop.get(xt.RepeatDot)-n.smuflMetrics.glyphHeights.get(xt.RepeatDot)/2;pt.fillMusicFontSymbolSafe(s,t+this.x,a+o-h,1,xt.RepeatDot),pt.fillMusicFontSymbolSafe(s,t+this.x,a+o+h,1,xt.RepeatDot)}},jc=class extends Hc{paintExtended(t,e,s,i){const n=this.renderer;if(n.drawnLineCount-1<=2)return;const r=n.smuflMetrics.staffLineThickness/2,a=(n.drawnLineCount-1)/2,h=n.getLineY(a-1)-r,o=n.getLineY(a+1)+r;s.fillRect(t+this.x,e+h,n.smuflMetrics.thinBarlineThickness,o-h)}},Jc=class extends Hc{paintExtended(t,e,s,i){const n=this.renderer.getLineHeight(1),r=-n/2+1;s.fillRect(t+this.x,e+this.y+r,1,n)}},qc=class extends Eo{q_;Y_;constructor(t,e){super(),this.q_=t,this.Y_=e}doLayout(){const t=this.renderer.bar,e=t.masterBar,s=this.q_?t.getActualBarLineRight():t.getActualBarLineLeft(0===this.renderer.index),i=this.q_&&e.isRepeatEnd||!this.q_&&e.isRepeatStart;let n=q.Automatic;if(!this.q_){const t=this.renderer.previousRenderer;if(t&&t.staff===this.renderer.staff&&(n=t.bar.getActualBarLineRight(),s===n))return}switch(this.q_&&e.isRepeatEnd&&(this.addGlyph(new Xc(0,0)),this.width+=this.renderer.smuflMetrics.repeatBarlineDotSeparation),s){case q.Dashed:this.addGlyph(new zc(0,0));break;case q.Dotted:this.addGlyph(new Vc(0,0));break;case q.Heavy:n!==q.LightHeavy&&n!==q.HeavyHeavy&&this.addGlyph(new Uc(0,0));break;case q.HeavyHeavy:n!==q.LightHeavy&&n!==q.Heavy&&this.addGlyph(new Uc(0,0)),this.width+=this.renderer.smuflMetrics.barlineSeparation,this.addGlyph(new Uc(0,0));break;case q.HeavyLight:n!==q.LightHeavy&&n!==q.Heavy&&n!==q.HeavyHeavy&&this.addGlyph(new Uc(0,0)),this.width+=this.renderer.smuflMetrics.thinThickBarlineSeparation,this.addGlyph(new $c(0,0,i));break;case q.LightHeavy:n!==q.HeavyLight&&n!==q.Regular&&n!==q.LightLight&&this.addGlyph(new $c(0,0,i)),this.width+=this.renderer.smuflMetrics.thinThickBarlineSeparation,this.addGlyph(new Uc(0,0));break;case q.LightLight:n!==q.HeavyLight&&n!==q.Regular&&this.addGlyph(new $c(0,0,i)),this.width+=this.renderer.smuflMetrics.barlineSeparation,this.addGlyph(new $c(0,0,i));break;case q.None:break;case q.Regular:n!==q.HeavyLight&&n!==q.LightLight&&this.addGlyph(new $c(0,0,i));break;case q.Short:this.addGlyph(new jc(0,0));break;case q.Tick:this.addGlyph(new Jc(0,0))}this.q_||e.isRepeatStart&&(this.width+=this.renderer.smuflMetrics.repeatBarlineDotSeparation,this.addGlyph(new Xc(0,0)));const r=this.renderer,a=r.smuflMetrics.staffLineThickness;let h=this.y,o=this.y;r.drawnLineCount<2||!this.q_&&r.isFirstOfStaff||this.q_&&r.isLastOfStaff?(h-=a,o+=r.height):(h+=r.getLineY(0)-a/2,o+=r.getLineY(r.drawnLineCount-1)+a/2);const c=o-h;let l=0;if(this.Y_&&this.q_){const t=Math.ceil(this.width);l=t-this.width,this.width=t}for(const t of this.glyphs)t.y=h,t.x+=l,t.height=c}paint(t,e,s){const i=this.glyphs;if(!i)return;const n=this.renderer,r=Kh.bar(s,n.barLineBarSubElement,this.renderer.bar,!0);try{let r=this.height;const a=n.staff,h=a.system.allStaves;let o=!1;if(this.Y_&&a.index<h.length-1){const t=h[a.index+1],e=a.y+n.y;r=t.y+t.topOverflow+n.smuflMetrics.staffLineThickness-e,o=!0}for(const n of i)o?n.paintExtended(t,e,s,r):n.paint(t,e,s)}finally{r?.[Symbol.dispose]?.()}}},Yc=class extends Xa{K_;constructor(t,e,s){super(t,e),this.K_=`${s}  `}doLayout(){this.renderer.scoreRenderer.canvas.font=this.renderer.resources.elementFonts.get(A.BarNumber);const t=this.renderer.scoreRenderer.canvas.measureText(this.K_);this.width=t.width,this.height=t.height,this.y-=this.height}paint(t,e,s){if(!this.renderer.staff.isFirstInSystem)return;const i=Kh.bar(s,this.renderer.barNumberBarSubElement,this.renderer.bar,!0);try{const i=this.renderer.resources,n=s.textBaseline;s.font=i.elementFonts.get(A.BarNumber),s.textBaseline=dt.Top,s.fillText(this.K_,t+this.x,e+this.y),s.textBaseline=n}finally{i?.[Symbol.dispose]?.()}}},Kc=class extends Do{shouldDrawBendSlur(){return this.renderer.settings.notation.extendBendArrowsOnTiedNotes&&!!this.startNote.bendOrigin&&this.startNote.isTieOrigin}calculateTieDirection(){return Fe.Up}},Qc=class{x=0;y=-3e3;width=0},Zc=class extends Yh{constructor(){super(0,0)}doLayout(){if(!this.glyphs||0===this.glyphs.length)return void(this.width=0);this.glyphs.sort((t,e)=>t.y<e.y?-1:t.y>e.y?1:0);const t=[];t.push(new Qc);for(let e=0,s=this.glyphs.length;e<s;e++){const s=this.glyphs[e];s.renderer=this.renderer,s.doLayout();let i=0;for(;t[i].y>s.y;)i++,i===t.length&&t.push(new Qc);s.x=i,t[i].y=s.y+s.height,t[i].width<s.width&&(t[i].width=s.width)}this.width=0;const e=this.renderer.smuflMetrics.accidentalPadding;for(const s of t)this.width+=s.width+e,s.x=this.width;for(let e=0,s=this.glyphs.length;e<s;e++){const s=this.glyphs[e],i=t[s.x];s.x=this.width-i.x}}},tl=class extends $h{constructor(t,e){super(t,e,1,xt.AugmentationDot)}doLayout(){super.doLayout(),this.offsetX=this.width/2,this.width*=1.5}},el=class extends Yh{rS=[];Q_=[];container;computedWidth=0;constructor(){super(0,0)}doLayout(){let t=0;if(this.glyphs)for(let e=0,s=this.glyphs.length;e<s;e++){const s=this.glyphs[e];s.x=t,s.renderer=this.renderer,s.doLayout(),t+=s.width}this.width=t,this.computedWidth=t}noteLoop(t){for(let e=this.container.beat.notes.length-1;e>=0;e--)t(this.container.beat.notes[e])}addEffect(t){super.addGlyph(t),this.rS.push(t)}addNormal(t){super.addGlyph(t),this.Q_.push(t)}get effectElement(){}paint(t,e,s){this.Z_(t,e,s),this.tx(t,e,s)}tx(t,e,s){for(const i of this.Q_)i.paint(t+this.x,e+this.y,s)}Z_(t,e,s){try{var i=fh();i.u(this.effectElement?Kh.beat(s,this.effectElement,this.container.beat):void 0);for(const i of this.rS)i.paint(t+this.x,e+this.y,s)}catch(t){i.e=t}finally{i.d()}}},sl=class extends el{onTimeX=0;middleX=0;stemX=0},il=class extends Xa{sx=0;constructor(){super(0,0)}getBoundingBoxTop(){return this.sx}getBoundingBoxBottom(){return this.sx+this.height}doLayout(){this.width=this.renderer.smuflMetrics.glyphWidths.get(xt.NoteheadSlashWhiteHalf);const t=this.renderer,e=t.getLineHeight(t.heightLineCount-1),s=t.getLineY(0)+(t.drawnLineCount>0?t.getLineHeight(t.drawnLineCount-1):0)/2-e/2;this.height=e,this.sx=s}paint(t,e,s){const i=this.height,n=this.sx,r=s.lineWidth;s.lineWidth=this.renderer.smuflMetrics.deadSlappedLineWidth,s.moveTo(t+this.x,e+n),s.lineTo(t+this.x+this.width,e+n+i),s.moveTo(t+this.x,e+n+i),s.lineTo(t+this.x+this.width,e+n),s.stroke(),s.lineWidth=r}},nl=class extends Xa{ix;$e;K_;nx;hx=0;ox=0;constructor(t,e,s,i,n,r){super(t,e),this.ix=i,this.K_=s,this.$e=n,this.nx=r}getBoundingBoxTop(){let t=-this.height/2;return this.nx>0&&this.hx<t&&(t=this.hx),this.y+t}getBoundingBoxBottom(){let t=this.height/2;const e=this.hx+Math.abs(this.nx)*this.ox*2;return this.nx<0&&t<e&&(t=e),this.y+t}paint(t,e,s){try{var i=fh();i.u(this.$e.isRest?Kh.beat(s,zt.NumberedRests,this.$e):this.$e.notes.length>0?Kh.note(s,Et.NumberedNumber,this.$e.notes[0]):void 0);const n=this.renderer.resources;s.font=this.ix?n.numberedNotationGraceFont:n.numberedNotationFont;const r=s.textBaseline;s.textBaseline=dt.Middle,s.textAlign=ut.Left,s.fillText(this.K_.toString(),t+this.x,e+this.y),s.textBaseline=r;const a=Math.abs(this.nx);let h=this.hx+n.engravingSettings.glyphTop.get(xt.AugmentationDot);for(let i=0;i<a;i++)pt.fillMusicFontSymbolSafe(s,t+this.x+this.width/2,e+this.y+h,1,xt.AugmentationDot,!0),h+=2*this.ox}catch(t){i.e=t}finally{i.d()}}doLayout(){const t=this.renderer.resources,e=this.ix?t.numberedNotationGraceFont:t.numberedNotationFont,s=this.renderer.scoreRenderer.canvas;s.font=e;const i=s.measureText(`${this.K_}`);this.height=i.height,this.width=i.width;const n=this.nx,r=t.engravingSettings.glyphHeights.get(xt.AugmentationDot),a=Math.abs(n)*r*2;n>0?this.hx=-this.height/2-a-t.engravingSettings.glyphTop.get(xt.AugmentationDot):n<0&&(this.hx=this.height/2+r+t.engravingSettings.glyphTop.get(xt.AugmentationDot)),this.ox=r}},rl=class extends Xa{constructor(t,e,s){super(t,e),this.width=s}getBoundingBoxTop(){return NaN}getBoundingBoxBottom(){return NaN}},al=class extends el{accidental=I.None;skipLayout=!1;get effectElement(){return zt.NumberedEffects}doLayout(){if(!this.skipLayout){if(!this.container.beat.isRest&&!this.container.beat.isEmpty){const t=new Zc;if(t.renderer=this.renderer,this.container.beat.notes.length>0){const e=this.container.beat.notes[0],s=Bt.resolveSpelling(this.renderer.bar.keySignature,e.displayValue,e.accidentalMode),i=Bt.getKeySignatureAccidentalOffset(this.renderer.bar.keySignature,s.degree),n=s.accidentalOffset-i;let r=I.None;if(e.accidentalMode!==_.ForceNone&&(e.hasQuarterToneOffset?r=n>0?I.SharpQuarterNoteUp:n<0?I.FlatQuarterNoteUp:I.NaturalQuarterNoteUp:0!==n&&(r=Bt.accidentalOffsetToType(n))),r!==I.None){this.accidental=r;const s=this.renderer,i=Kh.noteColor(s.resources,Et.NumberedAccidentals,e),n=new mo(0,s.getLineY(0),r,e.beat.graceType!==y.None?si.GraceScale*si.GraceScale:si.GraceScale);n.colorOverride=i,n.renderer=this.renderer,t.addGlyph(n),this.addNormal(t),this.addNormal(new rl(0,0,this.renderer.smuflMetrics.preNoteEffectPadding))}}}super.doLayout()}}},hl=class t extends sl{noteHeads=null;deadSlapped=null;get effectElement(){return zt.NumberedEffects}getNoteX(t,e){let s=null;if(this.noteHeads?s=this.noteHeads:this.deadSlapped&&(s=this.deadSlapped),s){let t=s.x;switch(e){case jo.Left:break;case jo.Center:t+=s.width/2;break;case jo.Right:t+=s.width}return t}return 0}buildBoundingsLookup(t,e,s){if(this.noteHeads&&this.container.beat.notes.length>0){const i=new Xn;i.note=this.container.beat.notes[0],i.noteHeadBounds=new _s,i.noteHeadBounds.x=e+this.x+this.noteHeads.x,i.noteHeadBounds.y=s+this.y+this.noteHeads.y-this.noteHeads.height/2,i.noteHeadBounds.w=this.width,i.noteHeadBounds.h=this.height,t.addNote(i)}}getLowestNoteY(t){return this.lx(t)}getHighestNoteY(t){return this.lx(t)}getNoteY(t,e){return this.lx(e)}getRestY(t){return this.lx(t)}lx(t){let e=null;if(this.noteHeads?e=this.noteHeads:this.deadSlapped&&(e=this.deadSlapped),e){let s=this.y+e.y;switch(t){case Xo.Top:case Xo.TopWithStem:s-=e.height/2;break;case Xo.Center:break;case Xo.Bottom:case Xo.BottomWithStem:s+=e.height/2;case Xo.StemUp:case Xo.StemDown:}return s}return 0}static ux=[59,66,61,68,63,70,65,60,67,62,69,64,71,66,61];static bx=[68,63,70,65,60,67,62,69,64,71,66,61,68,63,70];doLayout(){const e=this.renderer;e.shortestDuration<this.container.beat.duration&&(e.shortestDuration=this.container.beat.duration);let s=0;if(!this.container.beat.isEmpty){const i=e.getLineY(0);let n="0";if(this.container.beat.notes.length>0){const e=this.container.beat.notes[0];if(e.isDead)n="X";else{const i=this.renderer.bar.keySignature,r=this.renderer.bar.keySignatureType,a=i+7,h=(r===z.Minor?t.bx:t.ux)[a],o=Bt.resolveSpelling(i,e.displayValue,e.accidentalMode),c=Bt.getKeySignatureTonicDegree(i,r),l=r===z.Minor?(c+2)%7:c;n=((o.degree-l+7)%7+1).toString();const u=e.displayValue-h;s=Math.floor(u/12)}}if(this.container.beat.deadSlapped){const t=new il;t.renderer=this.renderer,t.doLayout(),this.deadSlapped=t,this.addEffect(t)}else{const t=this.container.beat.graceType!==y.None,e=new nl(0,i,n,t,this.container.beat,s);this.noteHeads=e,this.addNormal(e)}if(this.container.beat.dots>0&&this.container.beat.duration>=w.Quarter)for(let t=0;t<this.container.beat.dots;t++){const t=new tl(0,i);t.renderer=this.renderer,this.addEffect(t)}}super.doLayout(),this.container.beat.isEmpty?this.onTimeX=this.width/2:this.noteHeads?this.onTimeX=this.noteHeads.x+this.noteHeads.width/2:this.deadSlapped&&(this.onTimeX=this.deadSlapped.x+this.deadSlapped.width/2),this.middleX=this.onTimeX,this.stemX=this.middleX}},ol=class t extends Do{calculateTieDirection(){return this.isLeftHandTap?Fe.Up:t.getBeamDirectionForNote(this.startNote)}static getBeamDirectionForNote(t){return t.string>3?Fe.Up:Fe.Down}},cl=class{static build(t,e){return t.kind===N.LegatoSlide?{fromNote:t.fromNote,toNote:t.toNote,text:null!==t.text?t.text:"sl.",element:A.EffectSlideText}:{fromNote:t.fromNote,toNote:t.toNote,text:null!==t.text?t.text:e?"H":"P",element:A.EffectHammerOnPullOffText}}},ll=class extends ol{mx;gx=null;constructor(t,e,s,i,n){super(t,e,s,n),this.mx=i}getTieHeight(t,e,s,i){return Math.log(s-t+1)*this.renderer.settings.notation.slurHeight/2}getSlurLabels(){if(null===this.gx){this.gx=[];const t=this.startNote.effectSlur;if(null!==t){const e=this.renderer.settings.notation;for(const s of t.segments){const t=cl.build(s,s.toNote.fret>=s.fromNote.fret);e.isNotationElementVisible(t.element)&&this.gx.push(t)}}}return this.gx.length>0?this.gx:null}tryExpand(t,e,s,i){if(this.mx!==s)return!1;if(this.startNote.beat.id!==t.beat.id)return!1;if(this.endNote.beat.id!==e.beat.id)return!1;if(this.renderer===this.lookupEndBeatRenderer()!==i)return!1;if(this.tieDirection!==ol.getBeamDirectionForNote(t))return!1;switch(this.tieDirection){case Fe.Up:t.realValue>this.startNote.realValue&&(this.startNote=t,this.gx=null),e.realValue>this.endNote.realValue&&(this.endNote=e);break;case Fe.Down:t.realValue<this.startNote.realValue&&(this.startNote=t,this.gx=null),e.realValue<this.endNote.realValue&&(this.endNote=e)}return!0}},ul=class extends ll{calculateTieDirection(){return Fe.Up}},dl=class extends Ja{qn=new Map;wx=[];yx;hasAdditionalNumbers=!1;*iterateAdditionalNumbers(){const t=this.yx;if(t)for(const e of t)e instanceof fl&&(yield e)}constructor(t){super(t),this.preNotes=new al,this.onNotes=new hl}addDash(t){let e=this.yx;e||(e=[],this.yx=e),e.push(t)}addNotes(t){let e=this.yx;e||(e=[],this.yx=e),e.push(t),this.hasAdditionalNumbers=!0}doLayout(){this.qn.clear(),this.wx=[],super.doLayout()}buildBoundingsLookup(t,e,s){super.buildBoundingsLookup(t,e,s);const i=this.yx;if(i){const e=t.beats[t.beats.length-1],s=i[i.length-1],n=s.x+s.contentWidth;e.visualBounds.w=n-e.visualBounds.x;const r=s.x+s.width;e.realBounds.w=r-e.realBounds.x}}createTies(t){if(t.isVisible){if(t.isTieOrigin&&t.tieDestination.isVisible&&!this.qn.has("numbered.tie")){const e=new Kc(`numbered.tie.${t.beat.id}`,t,t.tieDestination,!1);this.addTie(e),this.qn.set(e.slurEffectId,e)}if(t.isTieDestination){const e=new Kc(`numbered.tie.${t.tieOrigin.beat.id}`,t.tieOrigin,t,!0);this.addTie(e)}if(t.isLeftHandTapped&&!t.isHammerPullDestination&&!this.qn.has(`numbered.tie.leftHandTap.${t.beat.id}`)){const e=new Kc(`numbered.tie.leftHandTap.${t.beat.id}`,t,t,!1);this.addTie(e),this.qn.set(e.slurEffectId,e)}if(t.isEffectSlurOrigin&&t.effectSlurDestination){let e=!1;for(const s of this.wx)if(s.tryExpand(t,t.effectSlurDestination,!1,!1)){e=!0;break}if(!e){const e=new ul("numbered.slur.effect",t,t.effectSlurDestination,!1,!1);this.wx.push(e),this.addTie(e),this.qn.set(e.slurEffectId,e),this.qn.set("numbered.slur.effect",e)}}if(t.isEffectSlurDestination&&t.effectSlurOrigin){let e=!1;for(const s of this.wx)if(s.tryExpand(t.effectSlurOrigin,t,!1,!0)){e=!0;break}if(!e){const e=new ul("numbered.slur.effect",t.effectSlurOrigin,t,!1,!0);this.wx.push(e),this.addTie(e),this.qn.set(e.slurEffectId,e),this.qn.set("numbered.slur.effect",e)}}}}},fl=class t extends dl{kx;Sx;constructor(e,s,i){super(e),this.kx=s,this.Sx=i,this.preNotes.skipLayout=!0,this.barCount=t.Bx(i)}static Bx(t){return t>=c.toTicks(w.Eighth)?1:t>=c.toTicks(w.Sixteenth)?2:t>=c.toTicks(w.ThirtySecond)?3:t>=c.toTicks(w.SixtyFourth)?4:t>=c.toTicks(w.OneHundredTwentyEighth)?5:t>=c.toTicks(w.TwoHundredFiftySixth)?6:0}barCount;get beatId(){return-1}get contentWidth(){return this.onNotes.width}get absoluteDisplayStart(){return this.kx}get displayDuration(){return this.Sx}get graceType(){return y.None}get graceIndex(){return 0}get graceGroup(){return null}get isFirstOfTupletGroup(){return!1}get tupletGroup(){return null}get isLastOfVoice(){return!1}buildBoundingsLookup(t,e,s){}},pl=class extends ja{kx;_x;constructor(t,e){super(0,0),this.kx=e,this._x=t}get beatId(){return-1}get contentWidth(){return this.renderer.smuflMetrics.numberedDashGlyphWidth}get absoluteDisplayStart(){return this.kx}get displayDuration(){return c.QuarterTime}get onTimeX(){return this.renderer.smuflMetrics.numberedDashGlyphWidth/2}get graceType(){return y.None}get graceIndex(){return 0}get graceGroup(){return null}get voiceIndex(){return this._x}get isFirstOfTupletGroup(){return!1}get tupletGroup(){return null}get isLastOfVoice(){return!1}getLowestNoteY(t){return 0}getHighestNoteY(t){return 0}getNoteY(t,e){return 0}doMultiVoiceLayout(){}getRestY(t){return 0}getNoteX(t,e){return 0}getBeatX(t,e){return 0}registerLayoutingInfo(t){const e=this.renderer.smuflMetrics.numberedDashGlyphWidth;t.addBeatSpring(this,e/2,e/2)}applyLayoutingInfo(t){}buildBoundingsLookup(t,e,s){}paint(t,e,s){const i=this.renderer,n=i.smuflMetrics.numberedDashGlyphWidth,r=i.smuflMetrics.numberedBarRendererBarSize,a=Math.ceil(e+i.getLineY(0)-r);s.fillRect(t+this.x,a,n,r)}},bl=class extends Xa{xx;colorOverride;constructor(t){super(0,0),this.xx=t}doLayout(){super.doLayout(),this.width=this.renderer.smuflMetrics.ghostParenthesisWidth+this.renderer.smuflMetrics.ghostParenthesisPadding}paint(t,e,s){const i=s.color;this.colorOverride&&(s.color=this.colorOverride),this.xx?Ao.paintTie(s,1,t+this.x+this.renderer.smuflMetrics.ghostParenthesisWidth,e+this.y+this.height,t+this.x+this.renderer.smuflMetrics.ghostParenthesisWidth,e+this.y,!1,this.renderer.smuflMetrics.ghostParenthesisWidth/2,this.renderer.smuflMetrics.tieMidpointThickness):Ao.paintTie(s,1,t+this.x+this.renderer.smuflMetrics.ghostParenthesisPadding,e+this.y,t+this.x+this.renderer.smuflMetrics.ghostParenthesisPadding,e+this.y+this.height,!1,this.renderer.smuflMetrics.ghostParenthesisWidth/2,this.renderer.smuflMetrics.tieMidpointThickness),s.color=i}},ml=class extends Yh{Tx=0;Mx=0;vx;Nx;barSubElement=j.StandardNotationTimeSignature;constructor(t,e,s,i,n,r){super(t,e),this.Tx=s,this.Mx=i,this.vx=n,this.Nx=r}paint(t,e,s){const i=Kh.bar(s,this.barSubElement,this.renderer.bar);try{super.paint(t,e,s)}finally{i?.[Symbol.dispose]?.()}}doLayout(){if(this.vx&&2===this.Tx&&2===this.Mx){const t=new $h(0,0,this.commonScale,xt.TimeSigCutCommon);this.addGlyph(t),super.doLayout()}else if(this.vx&&4===this.Tx&&4===this.Mx){const t=new $h(0,0,this.commonScale,xt.TimeSigCommon);this.addGlyph(t),super.doLayout()}else{const t=new Wo(0,0,this.Tx,dt.Top,this.numberScale),e=new Wo(0,0,this.Mx,dt.Bottom,this.numberScale);this.addGlyph(t),this.addGlyph(e),super.doLayout();const s=this.width;t.x=(s-t.width)/2,e.x=(s-e.width)/2,this.width=Math.max(t.x+t.width,e.x+e.width)}if(this.Nx){const t=2*this.renderer.smuflMetrics.oneStaffSpace,e=new bl(!0);e.renderer=this.renderer,e.y=-t,e.height=2*t,e.doLayout();for(const t of this.glyphs)t.x+=e.width;this.width+=e.width,this.addGlyph(e);const s=new bl(!1);s.renderer=this.renderer,s.x=this.width,s.y=-t,s.height=2*t,s.doLayout(),this.addGlyph(s),this.width+=s.width}}},gl=class extends ml{get commonScale(){return 1}get numberScale(){return 1}},wl=class t extends $h{constructor(e,s,i,n,r){super(e,s,r?si.GraceScale:1,t.getSymbol(i,n,r))}paint(t,e,s){const i=s.color;super.paint(t,e,s),s.color=i}static getSymbol(t,e,s){if(s&&(t=w.Eighth),e===Fe.Up)switch(t){case w.Eighth:return xt.Flag8thUp;case w.Sixteenth:return xt.Flag16thUp;case w.ThirtySecond:return xt.Flag32ndUp;case w.SixtyFourth:return xt.Flag64thUp;case w.OneHundredTwentyEighth:return xt.Flag128thUp;case w.TwoHundredFiftySixth:return xt.Flag256thUp;default:return xt.Flag8thUp}switch(t){case w.Eighth:return xt.Flag8thDown;case w.Sixteenth:return xt.Flag16thDown;case w.ThirtySecond:return xt.Flag32ndDown;case w.SixtyFourth:return xt.Flag64thDown;case w.OneHundredTwentyEighth:case w.TwoHundredFiftySixth:return xt.Flag128thDown;default:return xt.Flag8thDown}}},yl=class extends Xa{Px=0;constructor(t,e,s){super(t,e),this.Px=0,this.Px=s}doLayout(){this.renderer.scoreRenderer.canvas.font=this.renderer.resources.elementFonts.get(A.RepeatCount);const t=this.renderer.scoreRenderer.canvas.measureText(`x${this.Px}`);this.width=0,this.height=t.height,this.y-=t.height}paint(t,e,s){const i=Kh.bar(s,this.renderer.repeatsBarSubElement,this.renderer.bar);try{const i=this.renderer.resources,n=s.textAlign;s.font=i.elementFonts.get(A.RepeatCount),s.textAlign=ut.Right;const r=`x${this.Px}`,a=s.measureText(r).width/1.5;s.fillText(r,t+this.x-a,e+this.y),s.textAlign=n}finally{i?.[Symbol.dispose]?.()}}},kl=class t extends Jo{firstLineY=0;Cx=!1;tupletSize=0;get lineOffset(){return this.lineSpacing}get tupletOffset(){return.5*this.smuflMetrics.oneStaffSpace}get topGlyphOverflow(){return 0}get bottomGlyphOverflow(){return 0}initLineBasedSizes(){this.height=this.lineOffset*(this.heightLineCount-1)}updateSizes(){this.initLineBasedSizes(),this.adjustSizes(),this.updateFirstLineY(),super.updateSizes()}adjustSizes(){}updateFirstLineY(){const t=this.lineOffset*(this.heightLineCount-1),e=0===this.drawnLineCount?0:(this.drawnLineCount-1)*this.lineOffset,s=this.smuflMetrics.staffLineThickness/2;this.firstLineY=((t-e)/2|0)-s}doLayout(){this.initLineBasedSizes(),this.updateFirstLineY(),this.tupletSize=this.smuflMetrics.glyphHeights.get(xt.Tuplet0),super.doLayout()}getLineY(t){return this.firstLineY+this.getLineHeight(t)}getLineHeight(t){return this.lineOffset*t}paintContent(t,e,s){super.paintContent(t,e,s),this.paintBeams(t,e,s,this.flagsSubElement,this.beamsSubElement),this.paintTuplets(t,e,s,this.tupletSubElement)}paintBackground(t,e,s){super.paintBackground(t,e,s),this.paintStaffLines(t,e,s),this.paintSimileMark(t,e,s)}paintStaffLines(t,e,s){const i=Kh.bar(s,this.staffLineBarSubElement,this.bar,!0);try{const i=[];for(let t=0,e=this.drawnLineCount;t<e;t++)i.push([]);this.additionalMultiRestBars||this.collectSpaces(i);for(const t of i)t.sort((t,e)=>t[0]>e[0]?1:t[0]<e[0]?-1:0);const n=this.width,r=this.smuflMetrics.staffLineThickness/2;for(let a=0;a<this.drawnLineCount;a++){const h=this.getLineY(a)-r;let o=0;for(const n of i[a])s.fillRect(t+this.x+o,e+this.y+h,n[0]-o,this.smuflMetrics.staffLineThickness),o=n[0]+n[1];s.fillRect(t+this.x+o,e+this.y+h,n-o,this.smuflMetrics.staffLineThickness)}}finally{i?.[Symbol.dispose]?.()}}collectSpaces(t){}createStartSpacing(){if(this.Cx)return!1;const t=0===this.index?this.settings.display.firstStaffPaddingLeft:this.settings.display.staffPaddingLeft;return this.addPreBeatGlyph(new rl(0,0,t)),this.Cx=!0,!0}paintTuplets(t,e,s,i,n=!1){for(const r of this.voiceContainer.voiceDrawOrder)if(this.voiceContainer.tupletGroups.has(r)){const a=this.voiceContainer.tupletGroups.get(r);for(const r of a)this.Ex(t,e,s,r,i,n)}}getBeatDirection(t){const e=this.helpers.getBeamingHelperForBeat(t);return e?this.getBeamDirection(e):Fe.Up}getTupletBeamDirection(t){return this.getBeamDirection(t)}calculateBeamYWithDirection(t,e,s){return this.ensureBeamDrawingInfo(t,s),t.drawingInfos.get(s).calcY(e)}Ex(t,e,s,i,n,r){const a=this.resources,h=s.textAlign,o=s.textBaseline;let c;s.color=0===i.voice.index?this.resources.mainGlyphColor:this.resources.secondaryGlyphColor,s.textAlign=ut.Center,s.textBaseline=dt.Middle;const l=i.beats[0].tupletNumerator,u=i.beats[0].tupletDenominator;if(2===l&&3===u)c=[xt.Tuplet2];else if(3===l&&2===u)c=[xt.Tuplet3];else if(4===l&&6===u)c=[xt.Tuplet4];else if(5===l&&4===u)c=[xt.Tuplet5];else if(6===l&&4===u)c=[xt.Tuplet6];else if(7===l&&4===u)c=[xt.Tuplet7];else if(9===l&&8===u)c=[xt.Tuplet9];else if(10===l&&8===u)c=[xt.Tuplet1,xt.Tuplet0];else if(11===l&&8===u)c=[xt.Tuplet1,xt.Tuplet1];else if(12===l&&8===u)c=[xt.Tuplet1,xt.Tuplet2];else if(13===l&&8===u)c=[xt.Tuplet1,xt.Tuplet3];else{c=[];const t=xt.Tuplet0;if(l>10){const e=Math.floor(l/10);c.push(t+e),c.push(t+(l-10*e))}else c.push(t+l);if(c.push(xt.TupletColon),u>10){const e=Math.floor(u/10);c.push(t+e),c.push(t+(u-10*e))}else c.push(t+u)}const d=this.tupletOffset,f=this.tupletSize,p=d+.5*f,b=Kh.beat(s,n,i.beats[0]);try{const n=s.lineWidth;if(s.lineWidth=this.smuflMetrics.tupletBracketThickness,1!==i.beats.length&&i.isFull){const n=i.beats[0],h=i.beats[i.beats.length-1];let o=null,l=null;for(let t=0;t<i.beats.length;t++)if(!i.beats[t].isRest){o=i.beats[t];break}for(let t=i.beats.length-1;t>=0;t--)if(!i.beats[t].isRest){l=i.beats[t];break}let u=!1;o||(o=n,u=!0),l||(l=h);const d=this.getBeatX(n,Ua.OnNotes),b=this.getBeatX(h,Ua.PostNotes),m=this.helpers.getBeamingHelperForBeat(o),g=this.helpers.getBeamingHelperForBeat(l),w=this.getTupletBeamDirection(m);let y,k;u?(y=w===Fe.Up?Math.min(this.getRestY(o,Xo.Top),this.getRestY(l,Xo.Top)):Math.max(this.getRestY(o,Xo.Bottom),this.getRestY(l,Xo.Bottom)),k=y):(y=this.calculateBeamYWithDirection(m,d,w),k=this.calculateBeamYWithDirection(g,b,w)),w===Fe.Down?(y+=p,k+=p):(y-=p,k-=p);const S=c.reduce((t,e)=>t+a.engravingSettings.glyphWidths.get(e),0),B=.5*a.engravingSettings.oneStaffSpace,_=(d+b)/2,x=_-S/2-B,T=_+S/2+B,M=(k-y)/(b-d),v=y-M*d,N=M*x+v,P=M*_+v,C=M*T+v,E=w===Fe.Down?y-.5*f:y+.5*f,F=w===Fe.Down?k-.5*f:k+.5*f,A=s.lineWidth%2==0?0:.5;t+=A,e+=A,x>d&&(s.beginPath(),s.moveTo(t+this.x+d,e+this.y+E),r?s.quadraticCurveTo(t+this.x+(x+d)/2,e+this.y+N,t+this.x+x,e+this.y+N):(s.lineTo(t+this.x+d,e+this.y+y),s.lineTo(t+this.x+x,e+this.y+N)),s.moveTo(t+this.x+T,e+this.y+C),r?s.quadraticCurveTo(t+this.x+(b+T)/2,e+this.y+C,t+this.x+b,e+this.y+F):(s.lineTo(t+this.x+b,e+this.y+k),s.lineTo(t+this.x+b,e+this.y+F)),s.stroke()),s.fillMusicFontSymbols(t+this.x+_,e+this.y+P+.5*f,1,c,!0)}else for(const n of i.beats){const i=this.helpers.getBeamingHelperForBeat(n);if(!i)continue;const r=this.getTupletBeamDirection(i),a=this.getBeatX(n,Ua.Stem);let h=this.calculateBeamYWithDirection(i,a,r);r===Fe.Down?h+=p:h-=p,s.fillMusicFontSymbols(t+this.x+a,e+this.y+h+.5*f,1,c,!0)}s.textAlign=h,s.textBaseline=o,s.lineWidth=n}finally{b?.[Symbol.dispose]?.()}}paintBeams(t,e,s,i,n){for(const r of this.voiceContainer.voiceDrawOrder)for(const a of this.helpers.beamHelpers[r])this.paintBeamHelper(t,e,s,a,i,n)}drawBeamHelperAsFlags(t){return 1===t.beats.length}hasFlag(t){if(t.isRest)return!1;const e=this.helpers.getBeamingHelperForBeat(t);return e?e.hasFlag(this.drawBeamHelperAsFlags(e),t):Go.beatHasFlag(t)}hasStem(t){if(t.isRest)return!1;const e=this.helpers.getBeamingHelperForBeat(t);return e?e.hasStem(this.drawBeamHelperAsFlags(e),t):Go.beatHasStem(t)}paintBeamHelper(t,e,s,i,n,r){s.color=0===i.voice.index?this.resources.mainGlyphColor:this.resources.secondaryGlyphColor,this.shouldPaintBeamingHelper(i)&&(this.drawBeamHelperAsFlags(i)?this.paintFlag(t,e,s,i,n):this.paintBar(t,e,s,i,r))}shouldPaintBeamingHelper(t){return!t.isRestBeamHelper}shouldPaintFlag(t){return t.graceType!==y.BendGrace&&(!t.deadSlapped&&((t.graceType===y.None||this.settings.notation.notationMode!==F.SongBook)&&(t.duration!==w.Whole&&t.duration!==w.DoubleWhole&&t.duration!==w.QuadrupleWhole)))}paintFlag(t,e,s,i,n){for(const r of i.beats){if(!this.shouldPaintFlag(r))continue;const a=r.graceType!==y.None,h=this.getBeatX(r,Ua.Stem),o=this.getBeamDirection(i),c=e+this.y+this.getFlagTopY(r,o),l=e+this.y+this.getFlagBottomY(r,o);let u=0;if(u=o===Fe.Down?l:c,!i.hasStem(!0,r))continue;this.paintBeamingStem(r,e+this.y,t+this.x+h,c,l,s);const d=Kh.beat(s,n,r);try{let e=0;if(i.hasFlag(!0,r)){const i=new wl(t+this.x+h,u,r.duration,o,a);i.renderer=this,i.doLayout(),i.paint(0,0,s),e=i.width/2}r.graceType===y.BeforeBeat&&(o===Fe.Down?pt.fillMusicFontSymbolSafe(s,t+this.x+h+e/2,(c+l-this.smuflMetrics.glyphHeights.get(xt.GraceNoteSlashStemDown))/2,si.GraceScale,xt.GraceNoteSlashStemDown,!0):pt.fillMusicFontSymbolSafe(s,t+this.x+h+e/2,(c+l+this.smuflMetrics.glyphHeights.get(xt.GraceNoteSlashStemUp))/2,si.GraceScale,xt.GraceNoteSlashStemUp,!0))}finally{d?.[Symbol.dispose]?.()}}}recreatePreBeatGlyphs(){this.Cx=!1,super.recreatePreBeatGlyphs()}calculateBeamY(t,e){return this.calculateBeamYWithDirection(t,e,this.getBeamDirection(t))}createPreBeatGlyphs(){super.createPreBeatGlyphs(),this.addPreBeatGlyph(new qc(!1,this.bar.staff.track.score.stylesheet.extendBarLines)),this.createLinePreBeatGlyphs();let t=!1;0===this.index&&(t=this.createStartSpacing()),this.shouldCreateBarNumber()?this.addPreBeatGlyph(new Yc(0,this.getLineHeight(-.5),this.bar.index+1)):t||this.addPreBeatGlyph(new rl(0,0,this.smuflMetrics.oneStaffSpace))}shouldCreateBarNumber(){let t=nt.AllBars;switch(t=this.settings.notation.isNotationElementVisible(A.BarNumber)?void 0!==this.bar.barNumberDisplay?this.bar.barNumberDisplay:this.bar.staff.track.score.stylesheet.barNumberDisplay:nt.Hide,t){case nt.AllBars:return!0;case nt.FirstOfSystem:return this.isFirstOfStaff;case nt.Hide:return!1}return!0}createPostBeatGlyphs(){super.createPostBeatGlyphs();const t=this.lastBar;this.addPostBeatGlyph(new qc(!0,this.bar.staff.track.score.stylesheet.extendBarLines)),t.masterBar.isRepeatEnd&&t.masterBar.repeatCount>2&&this.settings.notation.isNotationElementVisible(A.RepeatCount)&&this.addPostBeatGlyph(new yl(0,this.getLineHeight(-.5),this.bar.masterBar.repeatCount))}paintBar(e,s,i,n,r){const a=this.getBeamDirection(n),h=n.graceType!==y.None?si.GraceScale:1;let o=(this.beamSpacing+this.beamThickness)*h,c=this.beamThickness*h;a===Fe.Down&&(o=-o,c=-c);for(let l=0,u=n.beats.length;l<u;l++){const u=n.beats[l];if(u.deadSlapped)continue;const d=this.getBeatX(u,Ua.Stem);let f=s+this.y;a===Fe.Up?f+=this.getFlagBottomY(u,a):f+=this.getFlagTopY(u,a);const p=s+this.y+this.calculateBeamY(n,d);let b,m;f<p?(b=f,m=p):(b=p,m=f),this.paintBeamingStem(u,s+this.y,e+this.x+d,b,m,i);const g=Kh.beat(i,r,u);try{const r=this.smuflMetrics.brokenBeamWidth*h,a=Bt.getIndex(u.duration)-2,f=s+this.y,p=this.smuflMetrics.stemThickness;for(let s=0;s<a;s++){let h=Math.floor(d+p),b=0,m=0,g=0;const w=f+s*o;if(l<n.beats.length-1){const o=Go.isFullBarJoin(u,n.beats[l+1],s);if(s===a-1&&o&&u.beamingMode===Vt.ForceSplitOnSecondaryToNext)b=Math.ceil(h+r),m=w+this.calculateBeamY(n,h),g=w+this.calculateBeamY(n,b),t.paintSingleBar(i,e+this.x+h,m,e+this.x+b,g,c),b=Math.floor(this.getBeatX(n.beats[l+1],Ua.Stem)),h=Math.floor(b-r),m=w+this.calculateBeamY(n,h),g=w+this.calculateBeamY(n,b),t.paintSingleBar(i,e+this.x+h,m,e+this.x+b,g,c);else{if(o)b=Math.ceil(this.getBeatX(n.beats[l+1],Ua.Stem));else{if(0!==l&&Go.isFullBarJoin(n.beats[l-1],u,s))continue;b=Math.ceil(h+r)}m=w+this.calculateBeamY(n,h),g=w+this.calculateBeamY(n,b),t.paintSingleBar(i,e+this.x+h,m,e+this.x+b,g,c)}}else l>0&&!Go.isFullBarJoin(u,n.beats[l-1],s)&&(b=Math.ceil(d),h=Math.floor(d-r),m=w+this.calculateBeamY(n,h),g=w+this.calculateBeamY(n,b),t.paintSingleBar(i,e+this.x+h,m,e+this.x+b,g,c))}}finally{g?.[Symbol.dispose]?.()}}if(n.graceType===y.BeforeBeat){const t=this.getBeatX(n.beats[0],Ua.Stem),r=this.smuflMetrics.glyphWidths.get(xt.Flag8thUp)*si.GraceScale;let h=s+this.y+this.calculateBeamY(n,t)|0;h+=c+o,a===Fe.Down?pt.fillMusicFontSymbolSafe(i,e+this.x+t+r/2,h,si.GraceScale,xt.GraceNoteSlashStemDown,!0):pt.fillMusicFontSymbolSafe(i,e+this.x+t+r/2,h,si.GraceScale,xt.GraceNoteSlashStemUp,!0)}}static paintSingleBar(t,e,s,i,n,r){t.beginPath(),t.moveTo(e,s),t.lineTo(i,n),t.lineTo(i,n+r),t.lineTo(e,s+r),t.closePath(),t.fill()}calculateBeamingOverflows(t,e){let s=0,i=0;for(const t of this.helpers.beamHelpers)for(const e of t)if(this.shouldPaintBeamingHelper(e))if(1===e.beats.length&&e.beats[0].duration>=w.Half){const t=this.getTupletBeamDirection(e),n=this.getBeamDirection(e),r=this.smuflMetrics.stemFlagOffsets.get(e.beats[0].duration);if(n===Fe.Up){let a=this.getFlagTopY(e.beats[0],n)-r;if(e.hasTuplet&&t===n&&(a-=this.tupletSize+this.tupletOffset),a<s&&(s=a),e.hasTuplet&&t!==n){let s=this.getFlagBottomY(e.beats[0],t);s+=this.tupletSize+this.tupletOffset,s>i&&(i=s)}}else{let a=this.getFlagBottomY(e.beats[0],n)+r;if(e.hasTuplet&&t===n&&(a+=this.tupletSize+this.tupletOffset),a>i&&(i=a),e.hasTuplet&&t!==n){let i=this.getFlagTopY(e.beats[0],t);i-=this.tupletSize+this.tupletOffset,i<s&&(s=i)}}}else{const t=this.getBeamDirection(e);this.ensureBeamDrawingInfo(e,t);const n=e.drawingInfos.get(t),r=this.getTupletBeamDirection(e);if(t===Fe.Up){let a=Math.min(n.startY,n.endY);e.hasTuplet&&r===t&&(a-=this.tupletSize+this.tupletOffset),a<s&&(s=a);let h=this.voiceContainer.getLowestNoteY(e.beatOfLowestNote,Xo.Bottom);e.hasTuplet&&r!==t&&(h+=this.tupletSize+this.tupletOffset),h>i&&(i=h)}else{let a=Math.max(n.startY,n.endY);e.hasTuplet&&r===t&&(a+=this.tupletSize+this.tupletOffset),a>i&&(i=a);let h=this.voiceContainer.getHighestNoteY(e.beatOfHighestNote,Xo.Top);e.hasTuplet&&r!==t&&(h-=this.tupletSize+this.tupletOffset),h<s&&(s=h)}}else if(e.hasTuplet&&e.isRestBeamHelper){const t=e.beats[0].tupletGroup,n=t.beats[0],r=t.beats[t.beats.length-1];if(this.getTupletBeamDirection(e)===Fe.Up){const t=Math.min(this.getRestY(n,Xo.Top),this.getRestY(r,Xo.Top))-this.tupletSize-this.tupletOffset;t<s&&(s=t)}else{const t=Math.max(this.getRestY(n,Xo.Bottom),this.getRestY(r,Xo.Bottom))+this.tupletSize+this.tupletOffset;t>i&&(i=t)}}s<t&&this.registerOverflowTop(Math.abs(s)),i>e&&this.registerOverflowBottom(Math.abs(i)-e)}initializeBeamDrawingInfo(t,e){const s=new Io,i=t.beats[0],n=t.beats[t.beats.length-1];s.startBeat=i,s.startX=this.getBeatX(i,Ua.Stem),s.startY=e===Fe.Up?this.getFlagTopY(i,e):this.getFlagBottomY(i,e),s.endBeat=n,s.endX=this.getBeatX(n,Ua.Stem),s.endY=e===Fe.Up?this.getFlagTopY(n,e):this.getFlagBottomY(n,e);const r=this.smuflMetrics.oneStaffSpace;return e===Fe.Down&&s.startY>s.endY&&s.startY-s.endY>r&&(s.endY=s.startY-r),e===Fe.Down&&s.endY>s.startY&&s.endY-s.startY>r&&(s.startY=s.endY-r),e===Fe.Up&&s.startY<s.endY&&s.endY-s.startY>r&&(s.endY=s.startY+r),e===Fe.Up&&s.endY<s.startY&&s.startY-s.endY>r&&(s.startY=s.endY+r),s}get beamSpacing(){return this.smuflMetrics.beamSpacing}get beamThickness(){return this.smuflMetrics.beamThickness}ensureBeamDrawingInfo(t,e){if(t.drawingInfos.has(e))return;const s=this.initializeBeamDrawingInfo(t,e);t.drawingInfos.set(e,s);const i=Bt.getIndex(t.shortestDuration)-2,n=this.applyBarShift(t,e,s,i);if(t.beats.length>1){if(e===Fe.Up){const i=n+this.getFlagTopY(t.beatOfHighestNote,e),r=s.calcY(this.getBeatX(t.beatOfHighestNote,Ua.Stem))-i;r>0&&(s.startY-=r,s.endY-=r)}else{const i=n+this.getFlagBottomY(t.beatOfLowestNote,e)-s.calcY(this.getBeatX(t.beatOfLowestNote,Ua.Stem));i>0&&(s.startY+=i,s.endY+=i)}let r=0;if(t.restBeats.length>0){const e=t.graceType!==y.None?si.GraceScale:1;r=i*(this.beamSpacing+this.beamThickness)*e}for(const i of t.restBeats)if(i.isRest&&i.index<t.beats[t.beats.length-1].index)if(e===Fe.Up){const t=this.getBeatContainer(i).getBoundingBoxTop()-r,e=s.calcY(this.getBeatX(i,Ua.Stem))-t;e>0&&(s.startY-=e,s.endY-=e)}else if(e===Fe.Down){const t=this.getBeatContainer(i).getBoundingBoxBottom()+r-s.calcY(this.getBeatX(i,Ua.Stem));t>0&&(s.startY+=t,s.endY+=t)}if(t.slashBeats.length>0)for(const i of t.slashBeats){const t=s.calcY(this.getBeatX(i,Ua.Stem)),n=(e===Fe.Up?this.getFlagTopY(i,e):this.getFlagBottomY(i,e))-t;n>0&&(s.startY+=n,s.endY+=n)}}Fe.Up,s.startY=Math.round(s.startY),s.endY=Math.round(s.endY)}applyBarShift(t,e,s,i){let n=0;const r=t.isRestBeamHelper,a=t.graceType!==y.None?si.GraceScale:1;if(i>2&&!r){const t=this.beamSpacing*a,r=this.beamThickness*a,h=i*r+(i-1)*t;if(e===Fe.Up){const e=s.startY+2*r+t-h,i=s.startY-e;i>0&&(n=-1*i,s.startY-=i,s.endY-=i)}else{const e=s.startY-2*r+t+h-s.startY;e>0&&(n=e,s.startY+=e,s.endY+=e)}}return n}getMinLineOfBeat(t){return 0}getMaxLineOfBeat(t){return 0}},Sl=class extends kl{static StaffId="numbered";simpleWhammyOverflow=0;Fx;shortestDuration=w.QuadrupleWhole;get dotSpacing(){return 2*this.smuflMetrics.glyphHeights.get(xt.AugmentationDot)}get repeatsBarSubElement(){return j.NumberedRepeats}get barNumberBarSubElement(){return j.NumberedBarNumber}get barLineBarSubElement(){return j.NumberedBarLines}get staffLineBarSubElement(){return j.NumberedStaffLine}constructor(t,e){super(t,e),this.Fx=!e.staff.showSlash&&!e.staff.showTablature&&!e.staff.showStandardNotation}get lineSpacing(){return this.smuflMetrics.oneStaffSpace}get heightLineCount(){return 5}get drawnLineCount(){return 0}get bottomGlyphOverflow(){return 0}get flagsSubElement(){return zt.NumberedDuration}get beamsSubElement(){return zt.NumberedDuration}get tupletSubElement(){return zt.NumberedTuplet}shouldPaintBeamingHelper(t){return!0}paintFlag(t,e,s,i,n){this.paintBar(t,e,s,i,n)}paintBar(t,e,s,i,n){if(0!==i.beats.length&&i.graceType===y.None)for(let r=0,a=i.beats.length;r<a;r++){const a=i.beats[r],h=Kh.beat(s,n,a);try{const n=this.getBeamDirection(i),h=i.graceType!==y.None?si.GraceScale:1;let o=(this.beamSpacing+this.beamThickness)*h,c=this.beamThickness*h;n===Fe.Down&&(o=-o,c=-c);let l=Bt.getIndex(a.duration)-2,u=this.getBeatX(a,Ua.PreNotes),d=0,f=0;r===i.beats.length-1?(d=u,f=this.getBeatX(a,Ua.PostNotes)):(d=u,f=this.getBeatX(i.beats[r+1],Ua.PreNotes));const p=e+this.y+this.calculateBeamY(i,u);for(let e=0;e<l;e++){const i=p+e*o;kl.paintSingleBar(s,t+this.x+d,i,t+this.x+f,i,c)}const b=this.voiceContainer.getBeatContainer(a);if(b&&b.hasAdditionalNumbers)for(const e of b.iterateAdditionalNumbers()){l=e.barCount,u=this.beatGlyphsStart+e.x+e.getBeatX(Ua.PreNotes,!1);for(let i=0;i<l;i++){const n=p+i*o,r=this.beatGlyphsStart+e.x+e.getBeatX(Ua.PostNotes,!1);kl.paintSingleBar(s,t+this.x+u,n,t+this.x+r,n,c)}}}finally{h?.[Symbol.dispose]?.()}}}calculateOverflows(t,e){super.calculateOverflows(t,e),this.bar.isEmpty||this.calculateBeamingOverflows(t,e)}getNoteLine(t){return 0}Ax(t){const e=Bt.getIndex(t.duration)-2;let s=0;if(e>0){const t=this.smuflMetrics;s=t.numberedBarRendererBarSpacing+e*(t.numberedBarRendererBarSpacing+t.numberedBarRendererBarSize)}return s}getFlagTopY(t,e){const s=this.Ax(t),i=this.voiceContainer.getBeatContainer(t);return i?e===Fe.Up?i.getBoundingBoxTop()-s:i.getBoundingBoxBottom():e===Fe.Up?this.voiceContainer.getBoundingBoxTop()-s:this.voiceContainer.getBoundingBoxBottom()}getFlagBottomY(t,e){const s=this.Ax(t),i=this.voiceContainer.getBeatContainer(t);return i?e===Fe.Down?i.getBoundingBoxBottom()+s:this.getLineY(0):e===Fe.Down?this.voiceContainer.getBoundingBoxBottom()+s:this.getLineY(0)}getBeamDirection(t){return Fe.Down}getTupletBeamDirection(t){return Fe.Up}createPreBeatGlyphs(){this.wasFirstOfStaff=this.isFirstOfStaff,(0===this.index||this.bar.masterBar.isRepeatStart&&this.Fx)&&this.addPreBeatGlyph(new qc(!1,this.bar.staff.track.score.stylesheet.extendBarLines)),this.createLinePreBeatGlyphs();const t=this.createStartSpacing();this.shouldCreateBarNumber()?this.addPreBeatGlyph(new Yc(0,this.getLineHeight(-.5),this.bar.index+1)):t||this.addPreBeatGlyph(new rl(0,0,this.smuflMetrics.oneStaffSpace))}createLinePreBeatGlyphs(){this.Fx&&(!this.bar.previousBar||this.bar.previousBar&&this.bar.masterBar.timeSignatureNumerator!==this.bar.previousBar.masterBar.timeSignatureNumerator||this.bar.previousBar&&this.bar.masterBar.timeSignatureDenominator!==this.bar.previousBar.masterBar.timeSignatureDenominator||this.bar.previousBar&&this.bar.masterBar.isFreeTime&&this.bar.masterBar.isFreeTime!==this.bar.previousBar.masterBar.isFreeTime)&&(this.createStartSpacing(),this.Dx())}Dx(){const t=this.bar.masterBar,e=new gl(0,this.getLineY(0),t.timeSignatureNumerator,t.timeSignatureDenominator,t.timeSignatureCommon,t.isFreeTime&&(null==t.previousMasterBar||t.isFreeTime!==t.previousMasterBar.isFreeTime));e.barSubElement=j.NumberedTimeSignature,this.addPreBeatGlyph(e)}createPostBeatGlyphs(){this.Fx&&super.createPostBeatGlyphs()}createVoiceGlyphs(t){if(t.index>0)return;super.createVoiceGlyphs(t);const e=this.bar.masterBar.start;for(const s of t.beats){const i=new dl(s);if(this.addBeatGlyph(i),s.duration<w.Quarter){const n=s.displayStart+s.displayDuration;let r=s.displayStart+c.QuarterTime;for(;r<n;){if(n-r>=c.QuarterTime){const s=new pl(t.index,e+r);this.addBeatGlyph(s),i.addDash(s)}else if(s.duration===w.Half&&s.dots>1){const t=new fl(s,e+r,n-r);this.addBeatGlyph(t),i.addNotes(t)}r+=c.QuarterTime}}}}paintBeamingStem(t,e,s,i,n,r){}get beamSpacing(){return this.smuflMetrics.numberedBarRendererBarSpacing}get beamThickness(){return this.smuflMetrics.numberedBarRendererBarSize}paintBeamHelper(t,e,s,i,n,r){0===i.voice?.index&&super.paintBeamHelper(t,e,s,i,n,r)}applyBarShift(t,e,s,i){return 0}calculateBeamYWithDirection(t,e,s){this.ensureBeamDrawingInfo(t,s);const i=t.drawingInfos.get(s);return s===Fe.Up?Math.min(i.startY,i.endY):Math.max(i.startY,i.endY)}paintTuplets(t,e,s,i,n=!1){super.paintTuplets(t,e,s,i,!0)}},Bl=class extends Sh{get staffId(){return Sl.StaffId}create(t,e){return new Sl(t,e)}canCreate(t,e){return super.canCreate(t,e)&&e.showNumbered}},_l=class t extends $h{Lx;Wx;Rx;constructor(e,s,i,n){super(e,s,1,t.Wk(i,n)),this.Lx=i,this.Wx=n}getBoundingBoxTop(){let t=super.getBoundingBoxTop();const e=this.Rx;if(e){const s=this.y+e.getBoundingBoxTop();t=Bt.minBoundingBox(t,s)}return t}getBoundingBoxBottom(){let t=super.getBoundingBoxBottom();const e=this.Rx;if(e){const s=this.y+e.getBoundingBoxBottom();t=Bt.maxBoundingBox(t,s)}return t}doLayout(){switch(this.center=!0,super.doLayout(),this.width=this.renderer.smuflMetrics.glyphWidths.get(xt.GClef),this.offsetX=this.width/2,this.Rx=void 0,this.Lx){case G.C3:case G.C4:if(this.Wx===x.M)return;break;case G.F4:case G.G2:return}let t,e=!1;switch(this.Wx){case x._:t=xt.Clef15,e=!0;break;case x.T:t=xt.Clef8,e=!0;break;case x.M:t=xt.Clef8;break;case x.L:t=xt.Clef15;break;default:return}const s=this.width/2,i=e?this.renderer.smuflMetrics.glyphTop.get(this.symbol):this.renderer.smuflMetrics.glyphBottom.get(this.symbol)-this.renderer.smuflMetrics.glyphHeights.get(t);this.Rx=new $h(s,-i,1,t),this.Rx.center=!0,this.Rx.renderer=this.renderer,this.Rx.doLayout()}static Wk(t,e){switch(t){case G.Neutral:return xt.UnpitchedPercussionClef1;case G.C3:case G.C4:return e===x.M?xt.CClef8vb:xt.CClef;case G.F4:switch(e){case x._:return xt.FClef15ma;case x.T:return xt.FClef8va;case x.M:return xt.FClef8vb;case x.L:return xt.FClef15mb;default:return xt.FClef}case G.G2:switch(e){case x._:return xt.GClef15ma;case x.T:return xt.GClef8va;case x.M:return xt.GClef8vb;case x.L:return xt.GClef15mb;default:return xt.GClef}default:return xt.None}}paint(t,e,s){const i=Kh.bar(s,j.StandardNotationClef,this.renderer.bar);try{super.paint(t,e,s);const i=this.Rx;i&&i.paint(t+this.x,e+this.y,s)}finally{i?.[Symbol.dispose]?.()}}},xl=class extends Eo{paint(t,e,s){const i=Kh.bar(s,j.StandardNotationKeySignature,this.renderer.bar);try{super.paint(t,e,s)}finally{i?.[Symbol.dispose]?.()}}},Tl=class t extends _h{qe;constructor(t,e,s){super(t,e),this.qe=s}static Wk(t,e){switch(t){case k.None:return xt.None;case k.Normal:return e?xt.ArticAccentAbove:xt.ArticAccentBelow;case k.Heavy:return e?xt.ArticMarcatoAbove:xt.ArticMarcatoBelow;case k.Tenuto:return e?xt.ArticTenutoAbove:xt.ArticTenutoBelow;default:return xt.None}}doLayout(){this.width=this.renderer.smuflMetrics.glyphWidths.get(xt.ArticAccentAbove),this.height=this.renderer.smuflMetrics.glyphHeights.get(xt.ArticAccentAbove)}paint(e,s,i){const n=this.renderer.getBeatDirection(this.qe.beat),r=t.Wk(this.qe.accentuated,n===Fe.Down),a=n===Fe.Up?s+this.y:s+this.y+this.height;pt.fillMusicFontSymbolSafe(i,e+this.x,a,1,r,!0)}},Ml=class extends $h{constructor(t,e){super(t,e,si.GraceScale,xt.ArticStaccatoAbove),this.center=!0}doLayout(){super.doLayout(),this.offsetY=this.height}},vl=class extends $h{centerOnStem=!1;constructor(t,e,s,i){super(t,e,s?si.GraceScale:1,i)}paint(t,e,s){this.centerOnStem&&(this.center=!0),super.paint(t,e,s)}},Nl=class t extends vl{constructor(e,s,i,n){super(e,s,n,t.getSymbol(i))}static getSymbol(t){switch(t){case w.QuadrupleWhole:return xt.NoteheadDoubleWholeSquare;case w.DoubleWhole:return xt.NoteheadDoubleWhole;case w.Whole:return xt.NoteheadWhole;case w.Half:return xt.NoteheadHalf;default:return xt.NoteheadBlack}}},Pl=class extends vl{constructor(t,e,s){super(t,e,s,xt.NoteheadXOrnate)}},Cl=class t extends vl{constructor(e,s,i,n){super(e,s,n,t.Wk(i))}static Wk(t){switch(t){case w.QuadrupleWhole:case w.DoubleWhole:case w.Whole:case w.Half:return xt.NoteheadDiamondWhiteWide;default:return xt.NoteheadDiamondBlackWide}}},El=class{steps=0;isGhost;color;constructor(t,e,s){this.steps=t,this.isGhost=e,this.color=s}},Fl=class extends Xa{xx;zk=[];Ox=[];isEmpty=!0;constructor(t){super(0,0),this.xx=t}addParenthesis(t){const e=this.renderer,s=e.getNoteSteps(t),i=t.isGhost||this.Ix(t)&&e.settings.notation.isNotationElementVisible(A.ParenthesisOnTiedBends),n=Kh.noteColor(e.resources,Et.Effects,t);this.Gx(new El(s,i,n))}addParenthesisOnSteps(t,e){const s=new El(t,e,void 0);this.Gx(s)}Gx(t){this.zk.push(t),t.isGhost&&(this.isEmpty=!1)}Ix(t){return!!t.isTieDestination&&(!!t.tieOrigin.hasBend||this.Ix(t.tieOrigin))}doLayout(){const t=this.renderer;this.zk.sort((t,e)=>t.steps-e.steps);let e=null;const s=t.getScoreHeight(1);for(let i=0,n=this.zk.length;i<n;i++){let n;if(this.zk[i].isGhost)if(e){const n=t.getScoreY(this.zk[i].steps)+s;e.height=n-e.y}else n=new bl(this.xx),n.colorOverride=this.zk[i].color,n.renderer=this.renderer,n.y=t.getScoreY(this.zk[i].steps)-s,n.height=2*s,n.doLayout(),this.Ox.push(n),e=n;else e=null}this.width=this.Ox.length>0?this.Ox[0].width:0}paint(t,e,s){super.paint(t,e,s);for(const i of this.Ox)i.paint(t+this.x,e+this.y,s)}},Al=class extends vl{ix;Hx;constructor(t,e,s,i,n){super(t,e,n,s.getSymbol(i)),this.ix=n,this.Hx=s}paint(t,e,s){const i=s.color;this.colorOverride&&(s.color=this.colorOverride);const n=this.ix?1:0;pt.fillMusicFontSymbolSafe(s,t+this.x,e+this.y+n,this.glyphScale,this.symbol,!1),this.Hx.techniqueSymbol!==xt.None&&this.Hx.techniqueSymbolPlacement===Mt.Inside&&pt.fillMusicFontSymbolSafe(s,t+this.x,e+this.y+n,this.glyphScale,this.Hx.techniqueSymbol,!1),s.color=i}doLayout(){super.doLayout(),0===this.width&&(this.height=this.renderer.smuflMetrics.glyphWidths.get(xt.NoteheadBlack)),0===this.height&&(this.height=this.renderer.smuflMetrics.glyphHeights.get(xt.NoteheadBlack))}},Dl=class extends $h{constructor(t,e){super(t,e,.5,xt.PictEdgeOfCymbal),this.center=!0}doLayout(){super.doLayout(),this.offsetY=this.height}},Ll=class t{mainVoiceDirection=Fe.Up;groups=new Map;minX=0;maxX=0;$x=!1;constructor(t){this.mainVoiceDirection=t}update(){let t=0,e=0;for(const s of this.groups.values()){const i=s.minX+s.multiVoiceShiftX,n=s.maxX+s.multiVoiceShiftX;i<t&&(t=i),e<n&&(e=n)}this.minX=t,this.maxX=e}finish(t){if(!this.$x){this.$x=!0;for(const e of this.groups.values())this.Vx(e,t);this.update()}}Vx(e,s){if(this.mainVoiceDirection===e.direction)return;const i=this.groups.get(this.mainVoiceDirection),n=t.zx(i,e),r=s.multiVoiceDisplacedNoteHeadSpacing;switch(n){case 0:return;case 3:t.Ux(i,e)||(i.direction===Fe.Up?e.displacedNotes?e.multiVoiceShiftX=e.stemX+e.correctNotes.width+r:e.multiVoiceShiftX=e.correctNotes.width+r:i.multiVoiceShiftX=e.stemX+r);break;case 1:i.direction===Fe.Up?i.displacedNotes?e.multiVoiceShiftX=i.stemX:e.multiVoiceShiftX=i.stemX-e.stemX:i.displacedNotes?e.multiVoiceShiftX=-e.stemX:i.multiVoiceShiftX=e.stemX-i.stemX;break;case 2:i.direction===Fe.Up?(i.multiVoiceShiftX=i.stemX,e.hasFlag&&(i.multiVoiceShiftX+=r)):(e.multiVoiceShiftX=e.stemX,i.hasFlag&&(e.multiVoiceShiftX+=r));break;case 4:(i.hasStem||e.hasStem)&&(i.direction===Fe.Up?(i.multiVoiceShiftX=i.stemX,e.hasFlag?i.multiVoiceShiftX+=r:i.multiVoiceShiftX-=r):(e.multiVoiceShiftX=e.stemX,i.hasFlag?e.multiVoiceShiftX+=r:e.multiVoiceShiftX-=r))}}static Ux(e,s){const i=e.direction===Fe.Up?e.maxStep:e.minStep,n=s.direction===Fe.Up?s.maxStep:s.minStep,r=e.correctNotes.notes.get(i);if(r.length>1)return!1;const a=s.correctNotes.notes.get(n);return!(a.length>1)&&t.Xx(r[0].glyph,a[0].glyph)}static Xx(t,e){return t.glyphScale===e.glyphScale&&t.centerOnStem===e.centerOnStem&&Tt.isBlackNoteHead(t.symbol)&&Tt.isBlackNoteHead(e.symbol)}static zx(t,e){let s=0;if(t.direction===Fe.Up){const i=t.maxStep;s=e.minStep-i}else s=t.minStep-e.maxStep;return 0===s?3:1===s?1:-1===s?2:s<0?4:0}},Wl=class t extends Xa{zk=[];jx;noteGroup;minStepsNote=null;maxStepsNote=null;get stemX(){return this.noteGroup?this.noteGroup.stemX+this.noteGroup.multiVoiceShiftX:0}noteStartX=0;onTimeX=0;constructor(){super(0,0)}getBoundingBoxTop(){return this.minStepsNote?this.minStepsNote.glyph.getBoundingBoxTop():this.y}getBoundingBoxBottom(){return this.maxStepsNote?this.maxStepsNote.glyph.getBoundingBoxBottom():this.y+this.height}add(t,e){const s={glyph:t,steps:e};this.zk.push(s),(!this.minStepsNote||this.minStepsNote.steps>s.steps)&&(this.minStepsNote=s),(!this.maxStepsNote||this.maxStepsNote.steps<s.steps)&&(this.maxStepsNote=s)}Jx(t){const e=this.direction;let s;t.groups||(t.mainVoiceDirection=e),e===Fe.Up?this.zk.sort((t,e)=>e.steps-t.steps):this.zk.sort((t,e)=>t.steps-e.steps);const i=this.hasFlag,n=this.hasStem;return t.groups.has(e)?(s=t.groups.get(e),i&&(s.hasFlag=i),n&&(s.hasStem=n)):(s={correctNotes:{notes:new Map,width:0,minX:NaN},direction:e,stemX:0,maxX:NaN,minX:NaN,minStep:NaN,maxStep:NaN,multiVoiceShiftX:0,hasFlag:i,hasStem:n},t.groups.set(e,s)),s}doLayout(){const t=this.getScoreChordNoteHeadInfo(),e=this.Jx(t);this.noteGroup=e,this.jx=t,this.qx(e),this.Yx(e),t.update(),this.Kx()}Kx(){const t=this.noteGroup;this.onTimeX=t.correctNotes.minX+t.correctNotes.width/2,this.width=this.noteStartX+t.multiVoiceShiftX+t.maxX-t.minX}doMultiVoiceLayout(){this.jx.finish(this.renderer.smuflMetrics),this.Kx()}Yx(t){t.direction===Fe.Up?(this.Qx(t,t.correctNotes,!0),t.displacedNotes&&this.Qx(t,t.displacedNotes,!1)):(this.Qx(t,t.correctNotes,!1),t.displacedNotes&&this.Qx(t,t.displacedNotes,!0))}Qx(t,e,s){const i=this.scale,n=this.renderer.smuflMetrics;for(const r of e.notes.values())for(const a of r){a.glyph.x=t.stemX,a.glyph.centerOnStem||(s?n.stemUp.has(a.glyph.symbol)?a.glyph.x-=n.stemUp.get(a.glyph.symbol).x*i:a.glyph.x-=n.glyphWidths.get(a.glyph.symbol)*i:n.stemDown.has(a.glyph.symbol)&&(a.glyph.x+=n.stemDown.get(a.glyph.symbol).x*i)),e.width=Math.max(e.width,a.glyph.width),(Number.isNaN(e.minX)||a.glyph.x<e.minX)&&(e.minX=a.glyph.x),(Number.isNaN(t.minX)||a.glyph.x<t.minX)&&(t.minX=a.glyph.x);const r=a.glyph.x+a.glyph.width;(Number.isNaN(t.maxX)||r>t.maxX)&&(t.maxX=r)}}static Zx(t,e){return t.notes.has(e.steps)||t.notes.has(e.steps+1)||t.notes.has(e.steps-1)}qx(e){for(const s of this.zk){s.glyph.renderer=this.renderer,s.glyph.doLayout();let i,n;t.Zx(e.correctNotes,s)?(e.displacedNotes||(e.displacedNotes={notes:new Map,width:0,minX:0}),i=e.displacedNotes):i=e.correctNotes,i.notes.has(s.steps)?n=i.notes.get(s.steps):(n=[],i.notes.set(s.steps,n)),n.push(s),(Number.isNaN(e.minStep)||s.steps<e.minStep)&&(e.minStep=s.steps),(Number.isNaN(e.maxStep)||s.steps>e.maxStep)&&(e.maxStep=s.steps),this.tT(s,e)}}tT(t,e){const s=this.renderer.smuflMetrics,i=this.scale;let n;n=e.direction===Fe.Up||e.displacedNotes?s.stemUp.has(t.glyph.symbol)?s.stemUp.get(t.glyph.symbol).x*i:s.glyphWidths.get(t.glyph.symbol)*i:s.stemDown.has(t.glyph.symbol)?s.stemDown.get(t.glyph.symbol).x*i:0,n+=this.noteStartX,n>e.stemX&&(e.stemX=n)}paint(t,e,s){t+=this.x,e+=this.y,this.eT(t,e,s);t+=this.noteGroup.multiVoiceShiftX;const i=this.zk;for(const n of i)n.glyph.renderer=this.renderer,n.glyph.paint(t,e,s)}eT(t,e,s){if(!this.minStepsNote)return;const i=this.renderer,n=Kh.bar(s,j.StandardNotationStaffLine,i.bar,!0);try{const n=this.scale,r=this.renderer.smuflMetrics.legerLineExtension*n,a=this.width+2*r-this.noteStartX,h=i.getLineHeight(1),o=i.getLineY(-1),c=i.getLineY(i.drawnLineCount),l=i.getLineY(this.minStepsNote.steps/2),u=i.getLineY(this.maxStepsNote.steps/2),d=this.renderer.smuflMetrics.legerLineThickness*n/2;let f=o;for(;f>=l;)s.fillRect(t-r+this.noteStartX,e+f-d,a,this.renderer.smuflMetrics.legerLineThickness*n),f-=h;for(f=c;f<=u;)s.fillRect(t-r+this.noteStartX,e+f-d,a,this.renderer.smuflMetrics.legerLineThickness*n),f+=h}finally{n?.[Symbol.dispose]?.()}}},Rl=class t extends $h{constructor(e,s,i){super(e,s,1,t.Wk(i))}static Wk(t){if(t.style===Ht.BuzzRoll)return xt.BuzzRoll;switch(t.marks){case 1:return xt.Tremolo1;case 2:return xt.Tremolo2;case 3:return xt.Tremolo3;case 4:return xt.Tremolo4;case 5:return xt.Tremolo5;default:return xt.None}}stemExtensionHeight=0;alignTremoloPickingGlyph(t,e,s,i){const n=this.renderer,r=n.smuflMetrics;let a=0;const h=r.glyphHeights.get(xt.Tremolo1)/2,o=this.height/2,c=this.symbol===xt.Tremolo1,l=n.lineSpacing,u=c?l:l/2;if(t===Fe.Up){let t=e;t+=r.stemFlagHeight.get(i),t-=r.stemFlagOffsets.get(i),a=u*Math.ceil(t/u);const n=s-l;n<a+o&&(a=n-o),t+=h;const c=a-o;this.stemExtensionHeight=t>c?t-c:0}else{let t=e;t-=r.stemFlagHeight.get(i),t+=r.stemFlagOffsets.get(i),a=u*Math.floor(t/u);const n=s+l;n>a-o&&(a=n+o),t-=h;const c=a+o;this.stemExtensionHeight=t<c?c-t:0}this.y=a}},Ol=class extends Wl{sT=new Map;dB=[];iT=null;nT=null;rT=0;aboveBeatEffects=new Map;belowBeatEffects=new Map;beat;get direction(){return this.renderer.getBeatDirection(this.beat)}get hasFlag(){return this.renderer.hasFlag(this.beat)}get hasStem(){return this.renderer.hasStem(this.beat)}get scale(){return this.beat.graceType!==y.None?si.GraceScale:1}getScoreChordNoteHeadInfo(){if(this.beat.graceType!==y.None)return new Ll(this.direction);const t=this.beat.voice.bar.staff,e=`score.noteheads.${t.track.index}.${t.index}.${this.beat.voice.bar.index}.${this.beat.absoluteDisplayStart}`;let s=this.renderer.staff.getSharedLayoutData(e,void 0);return s||(s=new Ll(this.direction),this.renderer.staff.setSharedLayoutData(e,s)),s}getNoteX(t,e){if(this.sT.has(t.id)){const s=this.sT.get(t.id);let i=this.x+s.x;switch(e){case jo.Left:break;case jo.Center:i+=s.width/2;break;case jo.Right:i+=s.width}return i}return 0}getNoteY(t,e){if(this.sT.has(t.id)){const s=this.sT.get(t.id);return this.lx(s,e)}return 0}getLowestNoteY(t){return this.maxStepsNote?this.lx(this.maxStepsNote.glyph,t):0}getHighestNoteY(t){return this.minStepsNote?this.lx(this.minStepsNote.glyph,t):0}lx(t,e){let s=this.y+t.y;const i=this.renderer,n=this.beat.graceType!==y.None?si.GraceScale:1;switch(e){case Xo.TopWithStem:s-=(i.smuflMetrics.stemUp.has(t.symbol)?i.smuflMetrics.stemUp.get(t.symbol).bottomY:0)*n,s-=i.smuflMetrics.getStemLength(this.beat.duration,i.hasFlag(this.beat))*n,s-=this.rT;let e=i.centerStaffStemY(this.direction);return e-=this.rT,Math.min(e,s);case Xo.Top:s-=t.height/2;break;case Xo.Center:break;case Xo.Bottom:s+=t.height/2;break;case Xo.BottomWithStem:s-=(this.renderer.smuflMetrics.stemDown.has(t.symbol)?this.renderer.smuflMetrics.stemDown.get(t.symbol).topY:-this.renderer.smuflMetrics.glyphHeights.get(t.symbol)/2)*n,s+=i.smuflMetrics.getStemLength(this.beat.duration,i.hasFlag(this.beat))*n,s+=this.rT;let r=i.centerStaffStemY(this.direction);return r+=this.rT,Math.max(r,s);case Xo.StemUp:s-=(i.smuflMetrics.stemUp.has(t.symbol)?i.smuflMetrics.stemUp.get(t.symbol).bottomY:0)*n;break;case Xo.StemDown:s-=(i.smuflMetrics.stemDown.has(t.symbol)?i.smuflMetrics.stemDown.get(t.symbol).topY:-i.smuflMetrics.glyphHeights.get(t.symbol)/2)*n}return s}addMainNoteGlyph(t,e,s){super.add(t,s),this.sT.set(e.id,t),this.dB.push(e)}addEffectNoteGlyph(t,e){super.add(t,e)}doLayout(){super.doLayout();const t=this.renderer;this.beat.deadSlapped&&(this.iT=new il,this.iT.renderer=this.renderer,this.iT.doLayout(),this.width=this.iT.width,this.onTimeX=this.width/2);let e=0,s=0;const i=this.renderer.smuflMetrics.onNoteEffectPadding;this.beat.deadSlapped?(s=t.getScoreY(0),e=t.getScoreY(t.heightLineCount)):this.direction===Fe.Up?(s=this.lx(this.maxStepsNote.glyph,Xo.Bottom)+i,e=this.lx(this.minStepsNote.glyph,Xo.TopWithStem)-i):(s=this.lx(this.maxStepsNote.glyph,Xo.BottomWithStem)+i,e=this.lx(this.minStepsNote.glyph,Xo.Top)-i);let n=null,r=null;for(const t of this.aboveBeatEffects.values())t.renderer=this.renderer,t.doLayout(),e-=t.height,t.y=e,(null===n||n>e)&&(n=e),(null===r||r<e)&&(r=e),e-=i;for(const t of this.belowBeatEffects.values())t.renderer=this.renderer,t.doLayout(),t.y=s,(null===n||n>s)&&(n=s),(null===r||r<s)&&(r=s),s+=t.height+i;null!==n&&t.registerBeatEffectOverflows(n,r??0),this.beat.isTremolo&&!this.beat.deadSlapped&&(this.nT=new Rl(0,0,this.beat.tremoloPicking),this.nT.renderer=this.renderer,this.nT.doLayout(),this.aT())}aT(){const t=this.nT,e=this.direction;e===Fe.Up?t.alignTremoloPickingGlyph(e,this.getHighestNoteY(Xo.TopWithStem),this.getHighestNoteY(Xo.Center),this.beat.duration):t.alignTremoloPickingGlyph(e,this.getLowestNoteY(Xo.BottomWithStem),this.getLowestNoteY(Xo.Center),this.beat.duration),this.rT=t.stemExtensionHeight;let s=this.stemX;this.beat.duration<w.Half&&(s=this.width/2),t.x=s}buildBoundingsLookup(t,e,s){for(const i of this.dB)if(this.sT.has(i.id)){const n=this.sT.get(i.id),r=new Xn;r.note=i,r.noteHeadBounds=new _s,r.noteHeadBounds.x=e+this.x+n.x,r.noteHeadBounds.y=s+this.y+n.y-n.height/2,r.noteHeadBounds.w=n.width,r.noteHeadBounds.h=n.height,t.addNote(r)}}paint(t,e,s){this.Z_(t,e,s),super.paint(t,e,s)}Z_(t,e,s){const i=Kh.beat(s,zt.StandardNotationEffects,this.beat);try{for(const i of this.aboveBeatEffects.values())i.paint(t+this.x+this.width/2,e+this.y,s);for(const i of this.belowBeatEffects.values())i.paint(t+this.x+this.width/2,e+this.y,s);this.nT&&this.nT.paint(t,e,s),this.iT&&this.iT.paint(t,e,s)}finally{i?.[Symbol.dispose]?.()}}},Il=class t extends $h{constructor(e,s,i){super(e,s,1,t.getSymbol(i))}static getSymbol(t){switch(t){case w.QuadrupleWhole:return xt.RestLonga;case w.DoubleWhole:return xt.RestDoubleWhole;case w.Whole:return xt.RestWhole;case w.Half:return xt.RestHalf;case w.Quarter:return xt.RestQuarter;case w.Eighth:return xt.Rest8th;case w.Sixteenth:return xt.Rest16th;case w.ThirtySecond:return xt.Rest32nd;case w.SixtyFourth:return xt.Rest64th;case w.OneHundredTwentyEighth:return xt.Rest128th;case w.TwoHundredFiftySixth:return xt.Rest256th;default:return xt.None}}paint(t,e,s){this.internalPaint(t,e,s,zt.StandardNotationRests)}internalPaint(t,e,s,i){const n=Kh.beat(s,i,this.beat);try{super.paint(t,e,s)}finally{n?.[Symbol.dispose]?.()}}},Gl=class extends Wl{$e;hT=!1;oT=new Map;cT=new Zc;lT=null;uT=null;isEmpty=!0;dT;get scale(){return si.GraceScale}get hasFlag(){return!1}get hasStem(){return!1}get direction(){return Fe.Up}constructor(t,e,s=!1){super(),this.$e=e,this.dT=t,this.hT=s,s&&(this.lT=new Fl(!0),this.uT=new Fl(!1))}getScoreChordNoteHeadInfo(){const t=this.$e.voice.bar.staff,e=`score.noteheads.${this.dT}.${t.track.index}.${t.index}.${this.$e.absoluteDisplayStart}`;let s=this.renderer.staff.getSharedLayoutData(e,void 0);return s||(s=new Ll(this.direction),this.renderer.staff.setSharedLayoutData(e,s)),new Ll(this.direction)}containsNoteValue(t){return this.oT.has(t)}getNoteValueY(t){return this.oT.has(t)?this.y+this.oT.get(t).y:0}addGlyph(t,e,s){const i=this.renderer,n=new Nl(0,0,w.Quarter,!0),r=i.accidentalHelper.applyAccidentalForValue(this.$e,t,e,!0),a=i.accidentalHelper.getNoteStepsForValue(t,!1);if(n.y=i.getScoreY(a),this.hT&&(this.lT.renderer=this.renderer,this.uT.renderer=this.renderer,this.lT.addParenthesisOnSteps(a,!0),this.uT.addParenthesisOnSteps(a,!0)),r!==I.None){const t=new mo(0,n.y,r,si.GraceScale);t.renderer=this.renderer,this.cT.renderer=this.renderer,this.cT.addGlyph(t)}this.oT.set(t,n),this.add(n,a),this.isEmpty=!1}doLayout(){let t=0;this.hT&&(this.lT.x=t,this.lT.renderer=this.renderer,this.lT.doLayout(),t+=this.lT.width+this.renderer.smuflMetrics.bendNoteHeadElementPadding),this.cT.isEmpty||(t+=this.cT.width+this.renderer.smuflMetrics.bendNoteHeadElementPadding,this.cT.x=t,this.cT.renderer=this.renderer,this.cT.doLayout(),t+=this.cT.width+this.renderer.smuflMetrics.bendNoteHeadElementPadding),this.noteStartX=t,super.doLayout(),this.hT&&(this.uT.x=this.width+this.renderer.smuflMetrics.bendNoteHeadElementPadding,this.uT.renderer=this.renderer,this.uT.doLayout(),this.width+=this.uT.width+this.renderer.smuflMetrics.bendNoteHeadElementPadding)}paint(t,e,s){this.cT.isEmpty||this.cT.paint(t+this.x,e+this.y,s),this.hT&&(this.lT.paint(t+this.x,e+this.y,s),this.uT.paint(t+this.x,e+this.y,s)),super.paint(t,e,s)}},Hl=class extends Yh{drawBendSlur(t,e,s,i,n,r,a){Ao.drawBendSlur(t,e,s,i,n,r,this.renderer.smuflMetrics.tieHeight,a)}doLayout(){if(this.glyphs){this.width=0;for(const t of this.glyphs)t.doLayout(),this.width+=t.width}}getTieDirection(t,e){return e.getBeatDirection(t)===Fe.Up?Fe.Down:Fe.Up}},$l=class extends Hl{aS;$e;fT=null;checkForOverflow=!1;constructor(t){super(0,0),this.aS=t,this.$e=t.beat}get hasBoundingBox(){const t=this.fT;return!!t&&(!!t.minStepsNote&&!!t.maxStepsNote)}getBoundingBoxTop(){return this.fT?.minStepsNote?this.fT.minStepsNote.glyph.getBoundingBoxTop():super.getBoundingBoxTop()}getBoundingBoxBottom(){return this.fT?.maxStepsNote?this.fT.maxStepsNote.glyph.getBoundingBoxBottom():super.getBoundingBoxBottom()}doMultiVoiceLayout(){this.fT?.doMultiVoiceLayout()}doLayout(){const t=this.renderer,e=t.settings.notation.notationMode;switch(this.$e.whammyBarType){case Lt.None:case Lt.Custom:case Lt.Hold:return;case Lt.Dive:case Lt.PrediveDive:{const e=new Gl("postwhammy",this.$e,!1);this.fT=e,e.renderer=t;const s=this.$e.whammyBarPoints[this.$e.whammyBarPoints.length-1];for(const t of this.$e.notes)t.isTieOrigin||e.addGlyph(this.pT(t,s),s.value%2!=0,void 0);e.doLayout(),this.addGlyph(e)}break;case Lt.Dip:if(e===F.SongBook)return;{const e=new Gl("middlewhammy",this.$e,!1);if(e.renderer=t,t.settings.notation.notationMode===F.GuitarPro){const t=this.$e.whammyBarPoints[1];for(const s of this.$e.notes)e.addGlyph(this.pT(s,this.$e.whammyBarPoints[1]),t.value%2!=0,void 0)}e.doLayout(),this.addGlyph(e);const s=new Gl("postwhammy",this.$e,!1);if(s.renderer=t,this.fT=s,t.settings.notation.notationMode===F.GuitarPro){const t=this.$e.whammyBarPoints[this.$e.whammyBarPoints.length-1];for(const e of this.$e.notes)s.addGlyph(this.pT(e,t),t.value%2!=0,void 0)}s.doLayout(),this.addGlyph(s)}case Lt.Predive:}super.doLayout(),this.width=this.width/2}paint(t,e,s){const i=this.$e;switch(i.whammyBarType){case Lt.None:case Lt.Custom:return}const n=this.renderer.settings.notation.notationMode,r=this.renderer.scoreRenderer.layout.getRendererForBar(this.renderer.staff.staffId,i.voice.bar),a=Kh.beat(s,zt.StandardNotationEffects,i);try{const a=t+r.x+r.getBeatX(i,Ua.MiddleNotes),h=this.getTieDirection(i,r);let o=1===this.$e.notes.length?h:Fe.Up;const c=s.textAlign,l=this.renderer.smuflMetrics.glyphHeights.get(xt.NoteheadBlack);for(let c=0;c<i.notes.length;c++){const u=i.notes[c],d=Kh.note(s,Et.StandardNotationEffects,u);try{let d=e+r.y;c>0&&c>=(this.$e.notes.length/2|0)&&(o=Fe.Down),o===Fe.Down?d+=r.getNoteY(u,Xo.Bottom):d+=r.getNoteY(u,Xo.Top);let f=t+r.x+r.getBeatX(i,Ua.EndBeat);if(f-=this.renderer.smuflMetrics.postNoteEffectPadding,this.fT){f-=this.fT.width-this.fT.onTimeX}const b=i.whammyStyle===p.Gradual&&0===c?"grad.":"";let m=null;u.isTieOrigin&&(m=this.renderer.scoreRenderer.layout.getRendererForBar(this.renderer.staff.staffId,u.tieDestination.beat.voice.bar),m&&m.staff===r.staff?f=t+m.x+m.getBeatX(u.tieDestination.beat,Ua.MiddleNotes):m=null);let g=l*si.GraceScale*.5;o===Fe.Up&&(g=-g);const w=i.whammyBarPoints.length>0?this.pT(u,i.whammyBarPoints[i.whammyBarPoints.length-1]):0;let y=0,k=!1;switch(this.glyphs&&this.glyphs[0].containsNoteValue(w)?(y=this.glyphs[0].getNoteValueY(w)+g,k=!0):m&&(u.isTieOrigin&&u.tieDestination.beat.hasWhammyBar||u.beat.isContinuedWhammy)?(y=e+m.y+m.getNoteY(u.tieDestination,Xo.Top),k=!0,o===Fe.Down&&(y+=l)):u.isTieOrigin&&(y=m?e+m.y+m.getNoteY(u.tieDestination,Xo.Top):d,o===Fe.Down&&(y+=l)),i.whammyBarType){case Lt.Hold:u.isTieOrigin&&Ao.paintTie(s,1,a,d,f,y,h===Fe.Down,this.renderer.smuflMetrics.tieHeight,this.renderer.smuflMetrics.slurMidpointThickness);break;case Lt.Dive:if(0===c){const t=this.glyphs[0];t.x=f-t.onTimeX;const i=this.glyphs[0].y;t.y=e+r.y,t.paint(0,0,s),t.containsNoteValue(w)&&(y-=i,y+=t.y)}k?this.drawBendSlur(s,a,d,f,y,o===Fe.Down,b):u.isTieOrigin&&Ao.paintTie(s,1,a,d,f,y,h===Fe.Down,this.renderer.smuflMetrics.tieHeight,this.renderer.smuflMetrics.slurMidpointThickness);break;case Lt.Dip:if(n===F.SongBook)u.isTieOrigin&&Ao.paintTie(s,1,a,d,f,y,h===Fe.Down,this.renderer.smuflMetrics.tieHeight,this.renderer.smuflMetrics.slurMidpointThickness);else{const t=(a+f)/2,n=this.glyphs[0];n.x=t-n.onTimeX,n.y=e+r.y,n.paint(0,0,s);const h=this.pT(u,i.whammyBarPoints[1]),c=n.getNoteValueY(h)+g;this.drawBendSlur(s,a,d,t,c,o===Fe.Down,b);const l=this.glyphs[1];l.x=f-l.onTimeX,l.y=e+r.y,l.paint(0,0,s),y=l.getNoteValueY(w)+g,this.drawBendSlur(s,t,c,f,y,o===Fe.Down,b)}break;case Lt.PrediveDive:case Lt.Predive:let l=t+r.x+r.getBeatX(u.beat,Ua.PreNotes);l+=this.aS.prebendNoteHeadOffset;const p=e+r.y+r.getScoreY(r.accidentalHelper.getNoteStepsForValue(u.displayValue-(u.beat.whammyBarPoints[0].value/2|0),!1))+g;if(this.drawBendSlur(s,l,p,a,d,o===Fe.Down,b),this.glyphs){const t=this.glyphs[0];t.x=f-t.onTimeX,t.y=e+r.y,t.paint(0,0,s),this.drawBendSlur(s,a,d,f,y,o===Fe.Down,b)}}}finally{d?.[Symbol.dispose]?.()}}s.textAlign=c}finally{a?.[Symbol.dispose]?.()}}pT(t,e){return t.displayValueWithoutBend+(e.value/2|0)}},Vl=class t extends vl{beatEffects=new Map;noteHeadElement=Et.SlashNoteHead;effectElement=zt.SlashEffects;stemX=0;constructor(e,s,i){super(e,s,i.graceType!==y.None,t.getSymbol(i.duration)),this.beat=i}paint(t,e,s){try{var i=fh();i.u(0===this.beat.notes.length?void 0:Kh.note(s,this.noteHeadElement,this.beat.notes[0])),super.paint(t,e,s),this.Z_(t,e,s)}catch(t){i.e=t}finally{i.d()}}Z_(t,e,s){const i=Kh.beat(s,this.effectElement,this.beat);try{for(const i of this.beatEffects.values())i.paint(t+this.x,e+this.y,s)}finally{i?.[Symbol.dispose]?.()}}doLayout(){super.doLayout();const t=this.renderer,e=t.smuflMetrics.onNoteEffectPadding;let s=t.smuflMetrics.glyphHeights.get(this.symbol),i=NaN,n=NaN;for(const r of this.beatEffects.values())r.y+=s,r.x+=this.width/2,r.renderer=t,s+=r.height+e,r.doLayout(),(Number.isNaN(i)||i>s)&&(i=s),(Number.isNaN(n)||n<s)&&(n=s);Number.isNaN(i)||t.registerBeatEffectOverflows(i,n);const r=t.getBeatDirection(this.beat),a=this.symbol;if(r===Fe.Up){const e=t.smuflMetrics.stemUp.has(a)?t.smuflMetrics.stemUp.get(a).x:0;this.stemX=e}else{const e=t.smuflMetrics.stemDown.has(a)?t.smuflMetrics.stemDown.get(a).x:0;this.stemX=e}}static getSymbol(t){switch(t){case w.QuadrupleWhole:case w.DoubleWhole:case w.Whole:return xt.NoteheadSlashWhiteWhole;case w.Half:return xt.NoteheadSlashWhiteHalf;default:return xt.NoteheadSlashHorizontalEnds}}},zl=class extends _h{bT=new Set;addString(t){this.bT.add(t)}doLayout(){const t=this.renderer.smuflMetrics.glyphWidths.get(xt.GuitarString0)*this.renderer.smuflMetrics.tuningGlyphCircleNumberScale;this.height=(t+this.renderer.smuflMetrics.stringNumberCirclePadding)*this.bT.size,this.width=t}paint(t,e,s){const i=this.renderer.bar.staff.tuning.length;let n=0;const r=this.renderer.smuflMetrics.glyphWidths.get(xt.GuitarString0)*this.renderer.smuflMetrics.tuningGlyphCircleNumberScale;for(const a of this.bT){const h=i-a,o=xt.GuitarString1+h;pt.fillMusicFontSymbolSafe(s,t+this.x,e+this.y+r+n,this.renderer.smuflMetrics.tuningGlyphCircleNumberScale,o,!0),n+=r+this.renderer.smuflMetrics.stringNumberCirclePadding}}},Ul=class extends sl{mT=NaN;gT=!1;wT;noteHeads=null;restGlyph=null;get effectElement(){return zt.StandardNotationEffects}buildBoundingsLookup(t,e,s){this.noteHeads&&this.noteHeads.buildBoundingsLookup(t,e+this.x,s+this.y)}getBoundingBoxTop(){let t=this.y;return this.noteHeads?t=this.noteHeads.getBoundingBoxTop():this.restGlyph&&(t=this.restGlyph.getBoundingBoxTop()),this.wT?.hasBoundingBox&&(t=Math.min(t,this.wT.getBoundingBoxTop())),t}getBoundingBoxBottom(){let t=this.y+this.height;return this.noteHeads?t=this.noteHeads.getBoundingBoxBottom():this.restGlyph&&(t=this.restGlyph.getBoundingBoxBottom()),this.wT?.hasBoundingBox&&(t=Math.max(t,this.wT.getBoundingBoxBottom())),t}getLowestNoteY(t){return this.noteHeads?this.noteHeads.getLowestNoteY(t):0}getHighestNoteY(t){return this.noteHeads?this.noteHeads.getHighestNoteY(t):0}getNoteY(t,e){return t.beat.slashed&&(t=t.beat.notes[0]),this.noteHeads?this.noteHeads.getNoteY(t,e):0}getNoteX(t,e){return t.beat.slashed&&(t=t.beat.notes[0]),this.noteHeads?this.noteHeads.getNoteX(t,e):0}getRestY(t){const e=this.restGlyph;if(e)switch(t){case Xo.TopWithStem:return e.getBoundingBoxTop()-this.renderer.smuflMetrics.getStemLength(w.Quarter,!0);case Xo.Top:return e.getBoundingBoxTop();case Xo.Center:case Xo.StemUp:case Xo.StemDown:return e.getBoundingBoxTop()+e.height/2;case Xo.Bottom:return e.getBoundingBoxBottom();case Xo.BottomWithStem:return e.getBoundingBoxBottom()+this.renderer.smuflMetrics.getStemLength(w.Quarter,!0)}return 0}applyRestCollisionOffset(){if(this.restGlyph&&Number.isNaN(this.mT)){this.mT=this.renderer.collisionHelper.applyRestCollisionOffset(this.container.beat,this.restGlyph.y,this.renderer.getScoreHeight(1)),this.y+=this.mT;const t=this.renderer.collisionHelper.restDurationsByDisplayTime;t.has(this.container.beat.playbackStart)&&t.get(this.container.beat.playbackStart).has(this.container.beat.playbackDuration)&&t.get(this.container.beat.playbackStart).get(this.container.beat.playbackDuration)!==this.container.beat.id&&(this.gT=!0)}}paint(t,e,s){this.gT||super.paint(t,e,s)}doMultiVoiceLayout(){this.applyRestCollisionOffset(),this.noteHeads?.doMultiVoiceLayout(),this.wT?.doMultiVoiceLayout();let t=0;if(this.glyphs)for(const e of this.glyphs)e.x=t,t+=e.width;this.width=t,this.computedWidth=t,this.yT()}doLayout(){this.zB(),super.doLayout(),this.yT()}yT(){this.container.beat.isEmpty?(this.onTimeX=this.width/2,this.middleX=this.onTimeX,this.stemX=this.middleX):this.restGlyph?(this.onTimeX=this.restGlyph.x+this.restGlyph.width/2,this.middleX=this.onTimeX,this.stemX=this.middleX):this.noteHeads&&(this.onTimeX=this.noteHeads.x+this.noteHeads.onTimeX,this.middleX=this.noteHeads.x+this.noteHeads.width/2,this.stemX=this.noteHeads.x+this.noteHeads.stemX)}zB(){this.container.beat.isEmpty||(this.container.beat.isRest?this.kT():this.ST())}ST(){const t=this.renderer,e=new Ol;this.noteHeads=e,e.beat=this.container.beat;const s=new Fl(!1);if(s.renderer=this.renderer,this.container.beat.slashed){const e=t.heightLineCount-1,s=new Vl(0,t.getScoreY(e),this.container.beat);s.colorOverride=Kh.noteColor(t.resources,Et.StandardNotationNoteHead,this.container.beat.notes[0]),this.noteHeads.addMainNoteGlyph(s,this.container.beat.notes[0],e)}else for(const t of this.container.beat.notes)t.isVisible&&(this.BT(t),s.addParenthesis(t));if(this.addNormal(e),s.isEmpty||this.addEffect(s),this.container.beat.hasWhammyBar){const t=new $l(this.container);this.wT=t,t.renderer=this.renderer,t.doLayout(),this.container.addTie(t)}if(this.container.beat.dots>0)for(let e=0;e<this.container.beat.dots;e++){const e=new Yh(0,0);e.renderer=this.renderer;for(const s of this.container.beat.notes)if(s.isVisible){this._T(t.getNoteSteps(s),e).colorOverride=Kh.noteColor(t.resources,Et.StandardNotationEffects,s)}this.addEffect(e)}if(this.renderer.bar.isMultiVoice){let e=0,s=0;const i=t.getBeatDirection(this.container.beat);let n=0;this.container.beat.hasTuplet&&(n+=t.tupletOffset+t.tupletSize),i===Fe.Up?(e=this.getHighestNoteY(Xo.TopWithStem)-n,s=this.getLowestNoteY(Xo.Bottom)):(e=this.getHighestNoteY(Xo.Top),s=this.getLowestNoteY(Xo.BottomWithStem)+n),this.renderer.collisionHelper.reserveBeatSlot(this.container.beat,e,s)}}kT(){const t=this.renderer;let e=2*Math.ceil((this.renderer.bar.staff.standardNotationLineCount-1)/2);this.container.beat.duration===w.Whole&&1!==this.renderer.bar.staff.standardNotationLineCount&&3!==this.renderer.bar.staff.standardNotationLineCount&&(e-=2);const s=new Il(0,t.getScoreY(e),this.container.beat.duration);if(this.restGlyph=s,s.beat=this.container.beat,this.addNormal(s),this.renderer.bar.isMultiVoice)if(0===this.container.beat.voice.index){const e=Go.computeLineHeightsForRest(this.container.beat.duration),i=s.y-t.getScoreHeight(e[0]),n=s.y+t.getScoreHeight(e[1]);this.renderer.collisionHelper.reserveBeatSlot(this.container.beat,i,n)}else this.renderer.collisionHelper.registerRest(this.container.beat);if(this.container.beat.dots>0)for(let t=0;t<this.container.beat.dots;t++){const t=new Yh(0,0);t.renderer=this.renderer,this._T(e,t),this.addEffect(t)}}_T(t,e){const s=this.renderer,i=new tl(0,s.getScoreY(t));return e.addGlyph(i),i}xT(t){const e=this.container.beat.graceType!==y.None,s=t.style;if(void 0!==s?.noteHead){const i=new Nl(0,0,t.beat.duration,e);return i.symbol=s.noteHead,s.noteHeadCenterOnStem&&(i.centerOnStem=!0),i}if(t.beat.voice.bar.staff.isPercussion){const s=Nt.getArticulation(t);if(s)return new Al(0,0,s,t.beat.duration,e);O.warning("Rendering",`No articulation found for percussion instrument ${t.percussionArticulation}`)}return t.isDead?new Pl(0,0,e):t.beat.graceType===y.BendGrace?new Nl(0,0,w.Quarter,!0):t.harmonicType===B.Natural?new Cl(0,0,t.beat.duration,e):new Nl(0,0,t.beat.duration,e)}BT(t){if(t.beat.graceType===y.BendGrace&&!t.hasBend)return;const e=this.renderer,s=this.xT(t);s.colorOverride=Kh.noteColor(e.resources,Et.StandardNotationNoteHead,t);let i=e.getNoteSteps(t);if(s.y=e.getScoreY(i),this.noteHeads.addMainNoteGlyph(s,t,i),!t.beat.slashed&&t.harmonicType!==B.None&&t.harmonicType!==B.Natural){const n=t.displayValue+t.harmonicPitch,r=new Cl(0,0,t.beat.duration,this.container.beat.graceType!==y.None);r.colorOverride=s.colorOverride,i=e.accidentalHelper.getNoteStepsForValue(n,!1),r.y=e.getScoreY(i),this.noteHeads.addEffectNoteGlyph(r,i)}const n=this.noteHeads.belowBeatEffects,r=this.noteHeads.aboveBeatEffects,a=e.getBeatDirection(this.container.beat)===Fe.Up?this.noteHeads.belowBeatEffects:this.noteHeads.aboveBeatEffects;if(t.isStaccato&&!n.has("Staccato")&&a.set("Staccato",new Ml(0,0)),t.accentuated!==k.Normal||n.has("Accent")||a.set("Accent",new Tl(0,0,t)),t.accentuated!==k.Heavy||n.has("HAccent")||a.set("HAccent",new Tl(0,0,t)),t.accentuated!==k.Tenuto||n.has("Tenuto")||a.set("Tenuto",new Tl(0,0,t)),t.showStringNumber&&t.isStringed){let e;r.has("StringNumber")?e=r.get("StringNumber"):(e=new zl(0,0),r.set("StringNumber",e)),e.addString(t.string)}if(t.isPercussion){const e=Nt.getArticulation(t);if(e&&e.techniqueSymbolPlacement!==Mt.Inside){let t;switch(e.techniqueSymbolPlacement){case Mt.Above:t=this.noteHeads.aboveBeatEffects;break;case Mt.Below:t=this.noteHeads.belowBeatEffects;break;case Mt.Outside:t=a;break;default:return}switch(e.techniqueSymbol){case xt.PictEdgeOfCymbal:t.set("PictEdgeOfCymbal",new Dl(0,0));break;case xt.ArticStaccatoAbove:t.set("ArticStaccatoAbove",new Ml(0,0));break;case xt.StringsUpBow:t.set("StringsUpBow",new _o(0,0,_t.Up));break;case xt.StringsDownBow:t.set("StringsDownBow",new _o(0,0,_t.Down));break;case xt.GuitarGolpe:t.set("GuitarGolpe",new io(0,0,!0))}}}}},Xl=class extends Xa{$e;TT;constructor(t){super(0,0),this.$e=t}doLayout(){if(this.$e.brushType===m.ArpeggioUp||this.$e.brushType===m.ArpeggioDown){const t=new Yo(0,0,P.Slight,!0);t.renderer=this.renderer,t.doLayout(),this.TT=t,this.width=t.height}else this.width=0}paint(t,e,s){if(this.$e.brushType===m.ArpeggioUp||this.$e.brushType===m.ArpeggioDown){const i=this.renderer,n=i.lineOffset,r=e+this.y+(i.getNoteY(this.$e.maxNote,Xo.Bottom)-n),a=e+this.y+i.getNoteY(this.$e.minNote,Xo.Top)+n,h=t+this.x+this.width/2,o=this.renderer.smuflMetrics.glyphWidths.get(xt.ArrowheadBlackDown),c=this.TT;if(this.$e.brushType===m.ArpeggioUp){const e=r+o,i=a-o;c.width=Math.abs(i-e),s.beginRotate(t+this.x,i,-90),c.paint(0,0,s),s.endRotate(),s.beginPath(),s.moveTo(h,a),s.lineTo(h+o/2,a-o),s.lineTo(h-o/2,a-o),s.closePath(),s.fill()}else if(this.$e.brushType===m.ArpeggioDown){const e=r+o;c.width=Math.abs(a-e),s.beginRotate(t+this.x,e,90),c.paint(0,-c.height,s),s.endRotate(),s.beginPath(),s.moveTo(h,r),s.lineTo(h+o/2,r+o),s.lineTo(h-o/2,r+o),s.closePath(),s.fill()}}}},jl=class extends el{MT=null;get prebendNoteHeadOffset(){return this.MT?this.MT.x+this.MT.onTimeX:0}get effectElement(){return zt.StandardNotationEffects}accidentals=null;doMultiVoiceLayout(){this.MT?.doMultiVoiceLayout()}doLayout(){this.container.beat.isRest||this.zB(),super.doLayout()}zB(){const t=new Zc;t.renderer=this.renderer;const e=new to;e.renderer=this.renderer;const s=new Fl(!0);s.renderer=this.renderer;let i=null,n=!1;for(const r of this.container.beat.notes){const a=Kh.noteColor(this.renderer.resources,Et.StandardNotationEffects,r);if(r.isVisible){if(r.hasBend)switch(r.bendType){case b.PrebendBend:case b.Prebend:case b.PrebendRelease:i||(i=new Gl("prebend",this.container.beat,!0),i.renderer=this.renderer),i.addGlyph(r.displayValue-(r.bendPoints[0].value/2|0),!1,a)}else if(r.beat.hasWhammyBar)switch(r.beat.whammyBarType){case Lt.PrediveDive:case Lt.Predive:i||(i=new Gl("prebend",this.container.beat,!0),i.renderer=this.renderer),i.addGlyph(r.displayValue-(r.beat.whammyBarPoints[0].value/2|0),!1,a)}switch(this.vT(r,t),s.addParenthesis(r),e.addFingers(r),r.slideInType){case T.IntoFromBelow:case T.IntoFromAbove:n=!0}}}n&&this.addNormal(new rl(0,0,this.renderer.smuflMetrics.simpleSlideWidth*(this.container.beat.graceType!==y.None?si.GraceScale:1))),this.MT=i,i&&(this.addEffect(i),this.addNormal(new rl(0,0,this.renderer.smuflMetrics.preNoteEffectPadding*(this.container.beat.graceType!==y.None?si.GraceScale:1)))),this.container.beat.brushType!==m.None&&(this.addEffect(new Xl(this.container.beat)),this.addNormal(new rl(0,0,this.renderer.smuflMetrics.preNoteEffectPadding*(this.container.beat.graceType!==y.None?si.GraceScale:1)))),e.isEmpty||(this.isEmpty||this.addNormal(new rl(0,0,this.renderer.smuflMetrics.preNoteEffectPadding*(this.container.beat.graceType!==y.None?si.GraceScale:1))),this.addEffect(e),this.addNormal(new rl(0,0,this.renderer.smuflMetrics.preNoteEffectPadding*(this.container.beat.graceType!==y.None?si.GraceScale:1)))),s.isEmpty||this.addEffect(s),t.isEmpty||(this.accidentals=t,this.isEmpty||this.addNormal(new rl(0,0,this.renderer.smuflMetrics.preNoteEffectPadding*(this.container.beat.graceType!==y.None?si.GraceScale:1))),this.addNormal(t),this.addNormal(new rl(0,0,this.renderer.smuflMetrics.preNoteEffectPadding*(this.container.beat.graceType!==y.None?si.GraceScale:1))))}vT(t,e){const s=this.renderer;let i=s.accidentalHelper.applyAccidental(t),n=s.getNoteSteps(t);const r=this.container.beat.graceType!==y.None,a=Kh.noteColor(s.resources,Et.StandardNotationAccidentals,t),h=r?si.GraceScale:1;if(i!==I.None){const t=new mo(0,s.getScoreY(n),i,h);t.colorOverride=a,t.renderer=this.renderer,e.addGlyph(t)}if(t.harmonicType!==B.None&&t.harmonicType!==B.Natural){const o=t.displayValue+t.harmonicPitch;i=s.accidentalHelper.applyAccidentalForValue(t.beat,o,r,!1),n=s.accidentalHelper.getNoteStepsForValue(o,!1);const c=new mo(0,s.getScoreY(n),i,h);c.colorOverride=a,c.renderer=this.renderer,e.addGlyph(c)}}},Jl=class extends Hl{$e;dB=[];NT=null;PT=null;aS;checkForOverflow=!1;constructor(t){super(0,0),this.$e=t.beat,this.aS=t}doLayout(){super.doLayout(),this.width=0}getBoundingBoxTop(){return super.getBoundingBoxTop()-this.CT(Fe.Up)}getBoundingBoxBottom(){return super.getBoundingBoxBottom()+this.CT(Fe.Down)}doMultiVoiceLayout(){this.PT?.doMultiVoiceLayout(),this.NT?.doMultiVoiceLayout()}CT(t){const e=this.getTieDirection(this.$e,this.renderer);if(e!==t)return 0;let s=0;for(const t of this.dB){if(t.isTieOrigin)continue;switch(t.bendType){case b.Custom:case b.Prebend:case b.Hold:continue}const i=2*this.renderer.getBeatContainer(this.$e).width;let n=0,r=0;switch(t.bendType){case b.Bend:case b.PrebendBend:n=this.NT.minStepsNote.glyph.getBoundingBoxTop(),r=i;break;case b.BendRelease:n=this.PT.minStepsNote.glyph.getBoundingBoxTop(),r=i/2;break;case b.Release:case b.PrebendRelease:n=this.NT.maxStepsNote.glyph.getBoundingBoxTop(),r=i}const a=this.renderer.getNoteY(t,Xo.Top);let h=Math.abs(Ao.calculateBendSlurTopY(0,a,r,n,e===Fe.Down,1,this.renderer.smuflMetrics.tieHeight)-n);if(t.bendStyle===p.Gradual){const t=this.renderer.resources,e=this.renderer.scoreRenderer.canvas;e.font=t.elementFonts.get(A.ScoreBendSlur),h+=e.measureText("grad.").height}h>s&&(s=h)}return s}addBends(t){if(this.dB.push(t),t.isTieOrigin)return;const e=Kh.noteColor(this.renderer.resources,Et.StandardNotationEffects,t);switch(t.bendType){case b.Bend:case b.PrebendRelease:case b.PrebendBend:{let s=this.NT;s||(s=new Gl("postbend",t.beat,!1),s.renderer=this.renderer,this.NT=s,this.addGlyph(s));const i=t.bendPoints[t.bendPoints.length-1];s.addGlyph(this.pT(t,i),i.value%2!=0,e)}break;case b.Release:if(!t.isTieOrigin){let s=this.NT;s||(s=new Gl("postbend",t.beat,!1),s.renderer=this.renderer,this.NT=s,this.addGlyph(s));const i=t.bendPoints[t.bendPoints.length-1];s.addGlyph(this.pT(t,i),i.value%2!=0,e)}break;case b.BendRelease:{let s=this.PT;s||(s=new Gl("middlebend",t.beat,!1),this.PT=s,s.renderer=this.renderer,this.addGlyph(s));const i=t.bendPoints[1];s.addGlyph(this.pT(t,t.bendPoints[1]),i.value%2!=0,e);let n=this.NT;n||(n=new Gl("postbend",t.beat,!1),n.renderer=this.renderer,this.NT=n,this.addGlyph(n));const r=t.bendPoints[t.bendPoints.length-1];n.addGlyph(this.pT(t,r),r.value%2!=0,e)}}}paint(t,e,s){const i=this.renderer.scoreRenderer.layout.getRendererForBar(this.renderer.staff.staffId,this.$e.voice.bar),n=t+i.x+i.getBeatX(this.$e,Ua.MiddleNotes);let r=t+i.x;if(this.$e.isLastOfVoice?r+=i.getBeatX(this.$e,Ua.EndBeat):r+=i.getBeatX(this.$e.nextBeat,Ua.PreNotes),r-=this.renderer.smuflMetrics.postNoteEffectPadding,this.NT){r-=this.NT.width-this.NT.onTimeX}const a=(n+r)/2;this.PT&&(this.PT.x=a-this.PT.onTimeX,this.PT.y=e+i.y,this.PT.paint(0,0,s)),this.NT&&(this.NT.x=r-this.NT.onTimeX,this.NT.y=e+i.y,this.NT.paint(0,0,s)),this.dB.sort((t,e)=>e.displayValue-t.displayValue),this.renderer.settings.notation.isNotationElementVisible(A.ScoreBendSlur)&&this.ET(t,e,s,i,n,a,r)}ET(t,e,s,i,n,r,a){const h=this.$e.graceType===y.BendGrace?this.$e.nextBeat:this.$e;let o=1===this.dB.length?this.getTieDirection(h,i):Fe.Up;const c=this.renderer.smuflMetrics.glyphHeights.get(xt.NoteheadBlack);s.font=this.renderer.resources.elementFonts.get(A.ScoreBendSlur);for(let h=0;h<this.dB.length;h++){const l=this.dB[h],u=Kh.note(s,Et.StandardNotationEffects,l);try{h>0&&h>=(this.dB.length/2|0)&&(o=Fe.Down);let u=e+i.y+i.getNoteY(l,Xo.Top),d=c*si.GraceScale*.5;o===Fe.Down&&(u+=c);const f=l.bendStyle===p.Gradual?"grad.":"";if(l.isTieOrigin){const r=l.tieDestination,a=r?this.renderer.scoreRenderer.layout.getRendererForBar(this.renderer.staff.staffId,r.beat.voice.bar):null;if(a&&a.staff===i.staff){const i=t+a.x+a.getBeatX(r.beat,Ua.MiddleNotes);let h=e+a.y+a.getNoteY(r,Xo.Top);o===Fe.Down&&(h+=c),l.bendType===b.Hold||l.bendType===b.Prebend?Ao.paintTie(s,1,n,u,i,h,o===Fe.Down,this.renderer.smuflMetrics.tieHeight,this.renderer.smuflMetrics.slurMidpointThickness):this.drawBendSlur(s,n,u,i,h,o===Fe.Down,f)}else{const r=t+i.x+i.width,a=l.tieDestination.displayValue;i.accidentalHelper.applyAccidentalForValue(l.beat,a,!1,!0);const h=e+i.y+i.getScoreY(i.accidentalHelper.getNoteStepsForValue(a,!1));l.bendType===b.Hold||l.bendType===b.Prebend?Ao.paintTie(s,1,n,u,r,h,o===Fe.Down,this.renderer.smuflMetrics.tieHeight,this.renderer.smuflMetrics.slurMidpointThickness):this.drawBendSlur(s,n,u,r,h,o===Fe.Down,f)}switch(l.bendType){case b.Prebend:case b.PrebendBend:case b.PrebendRelease:let r=t+i.x+i.getBeatX(l.beat,Ua.PreNotes);r+=this.aS.prebendNoteHeadOffset;const a=e+i.y+i.getScoreY(i.accidentalHelper.getNoteStepsForValue(l.displayValue-(l.bendPoints[0].value/2|0),!1))+d;this.drawBendSlur(s,r,a,n,u,o===Fe.Down)}}else{o===Fe.Up&&(d=-d);let h=0,c=0;switch(l.bendType){case b.Bend:h=this.pT(l,l.bendPoints[l.bendPoints.length-1]),c=this.NT.getNoteValueY(h)+d,this.drawBendSlur(s,n,u,a,c,o===Fe.Down,f);break;case b.BendRelease:const p=this.pT(l,l.bendPoints[1]),m=this.PT.getNoteValueY(p)+d;this.drawBendSlur(s,n,u,r,m,o===Fe.Down,f),h=this.pT(l,l.bendPoints[l.bendPoints.length-1]),c=this.NT.getNoteValueY(h)+d,this.drawBendSlur(s,r,m,a,c,o===Fe.Down,f);break;case b.Release:this.glyphs&&(h=this.pT(l,l.bendPoints[l.bendPoints.length-1]),c=this.glyphs[0].getNoteValueY(h)+d,this.drawBendSlur(s,n,u,a,c,o===Fe.Down,f));break;case b.Prebend:case b.PrebendBend:case b.PrebendRelease:let g=t+i.x+i.getBeatX(l.beat,Ua.PreNotes);g+=this.aS.prebendNoteHeadOffset;const w=e+i.y+i.getScoreY(i.accidentalHelper.getNoteStepsForValue(l.displayValue-(l.bendPoints[0].value/2|0),!1))+d;this.drawBendSlur(s,g,w,n,u,o===Fe.Down),this.glyphs&&(h=this.pT(l,l.bendPoints[l.bendPoints.length-1]),c=this.glyphs[0].getNoteValueY(h)+d,this.drawBendSlur(s,n,u,a,c,o===Fe.Down,f))}}}finally{u?.[Symbol.dispose]?.()}}}pT(t,e){return t.displayValueWithoutBend+(e.value/2|0)}},ql=class extends Ao{startBeat;endBeat;startBeatRenderer=null;endBeatRenderer=null;constructor(t,e,s,i){super(t,i),this.startBeat=e,this.endBeat=s}doLayout(){super.doLayout()}lookupStartBeatRenderer(){return this.startBeatRenderer||(this.startBeatRenderer=this.renderer.scoreRenderer.layout.getRendererForBar(this.renderer.staff.staffId,this.startBeat.voice.bar)),this.startBeatRenderer}lookupEndBeatRenderer(){return this.endBeatRenderer||(this.endBeatRenderer=this.renderer.scoreRenderer.layout.getRendererForBar(this.renderer.staff.staffId,this.endBeat.voice.bar)),this.endBeatRenderer}shouldDrawBendSlur(){return!1}calculateTieDirection(){return this.startBeat.isRest?Fe.Up:this.lookupStartBeatRenderer().getBeatDirection(this.startBeat)===Fe.Up?Fe.Down:Fe.Up}calculateStartX(){const t=this.lookupStartBeatRenderer();return t.x+t.getBeatX(this.startBeat,Ua.MiddleNotes)}calculateStartY(){const t=this.lookupStartBeatRenderer();if(this.startBeat.isRest){if(this.tieDirection===Fe.Up)return t.y+t.getRestY(this.startBeat,Xo.Top);return t.y+t.getRestY(this.startBeat,Xo.Bottom)}return this.tieDirection===Fe.Up?t.y+t.getNoteY(this.startBeat.maxNote,Xo.Top):t.y+t.getNoteY(this.startBeat.minNote,Xo.Bottom)}calculateEndX(){const t=this.lookupEndBeatRenderer();if(!t)return this.calculateStartX()+this.renderer.smuflMetrics.leftHandTabTieWidth;const e=t.getBeatDirection(this.endBeat);return t.x+t.getBeatX(this.endBeat,this.endBeat.duration>w.Whole&&e===this.tieDirection?Ua.Stem:Ua.MiddleNotes)}caclculateEndY(){const t=this.lookupEndBeatRenderer();if(!t)return this.calculateStartY();if(this.endBeat.isRest){if(this.tieDirection===Fe.Up)return t.y+t.getRestY(this.endBeat,Xo.Top);return t.y+t.getRestY(this.endBeat,Xo.Bottom)}const e=this.lookupStartBeatRenderer().getBeatDirection(this.startBeat),s=t.getBeatDirection(this.endBeat);if(e!==s&&this.startBeat.graceType===y.None){if(s===this.tieDirection){if(this.tieDirection===Fe.Up)return t.y+t.getNoteY(this.endBeat.maxNote,Xo.TopWithStem);return t.y+t.getNoteY(this.endBeat.minNote,Xo.BottomWithStem)}return this.tieDirection===Fe.Up?t.y+t.getNoteY(this.endBeat.maxNote,Xo.BottomWithStem):t.y+t.getNoteY(this.endBeat.minNote,Xo.TopWithStem)}return this.tieDirection===Fe.Up?t.y+t.getNoteY(this.endBeat.maxNote,Xo.Top):t.y+t.getNoteY(this.endBeat.minNote,Xo.Bottom)}},Yl=class extends Xa{FT;AT;DT;LT;checkForOverflow=!1;constructor(t,e,s,i){super(0,0),this.FT=e,this.AT=t,this.DT=s,this.LT=i}doLayout(){this.width=0}paint(t,e,s){this.WT(t,e,s),this.RT(t,e,s)}WT(t,e,s){const i=this.renderer,n=i.smuflMetrics.simpleSlideWidth;let r=t+i.x+i.getNoteX(this.DT,jo.Left)-i.smuflMetrics.preNoteEffectPadding;const a=e+i.y+i.getNoteY(this.DT,Xo.Center);let h=r-n,o=e+i.y;switch(this.AT){case T.IntoFromBelow:o+=i.getNoteY(this.DT,Xo.Bottom);break;case T.IntoFromAbove:o+=i.getNoteY(this.DT,Xo.Top);break;default:return}const c=this.OT(i,this.DT.beat);h-=c,r-=c,this.IT(s,!1,h,r,o,a)}OT(t,e){return t.getBeatContainer(e).accidentalsWidth}RT(t,e,s){const i=this.renderer,n=i.smuflMetrics.simpleSlideWidth,r=i.smuflMetrics.postNoteEffectPadding;let a=0,h=0,o=0,c=0,l=!1;switch(this.FT){case M.Shift:case M.Legato:if(a=t+i.x+i.getBeatX(this.DT.beat,Ua.PostNotes)+r,h=e+i.y+i.getNoteY(this.DT,Xo.Center),this.DT.slideTarget){const s=this.renderer.scoreRenderer.layout.getRendererForBar(this.renderer.staff.staffId,this.DT.slideTarget.beat.voice.bar);s&&s.staff===i.staff?(o=t+s.x+s.getBeatX(this.DT.slideTarget.beat,Ua.PreNotes)-r,c=e+s.y+s.getNoteY(this.DT.slideTarget,Xo.Center)):(o=t+i.x+i.width,c=this.DT.slideTarget.realValue>this.DT.realValue?e+i.y+i.getNoteY(this.DT,Xo.Top):e+i.y+i.getNoteY(this.DT,Xo.Bottom))}else o=t+i.x+this.LT.x,c=h;break;case M.OutUp:a=t+i.x+i.getNoteX(this.DT,jo.Right)+r,h=e+i.y+i.getNoteY(this.DT,Xo.Center),o=a+n,c=e+i.y+i.getNoteY(this.DT,Xo.Top);break;case M.OutDown:a=t+i.x+i.getNoteX(this.DT,jo.Right)+r,h=e+i.y+i.getNoteY(this.DT,Xo.Center),o=a+n,c=e+i.y+i.getNoteY(this.DT,Xo.Bottom);break;case M.PickSlideUp:a=t+i.x+i.getNoteX(this.DT,jo.Right)+2*r,h=e+i.y+i.getNoteY(this.DT,Xo.Center),c=e+i.y+i.getNoteY(this.DT,Xo.Top),o=t+i.x+i.width,this.DT.beat.nextBeat&&this.DT.beat.nextBeat.voice===this.DT.beat.voice&&(o=t+i.x+i.getBeatX(this.DT.beat.nextBeat,Ua.PreNotes)),l=!0;break;case M.PickSlideDown:a=t+i.x+i.getNoteX(this.DT,jo.Right)+2*r,h=e+i.y+i.getNoteY(this.DT,Xo.Center),c=e+i.y+i.getNoteY(this.DT,Xo.Bottom),o=t+i.x+i.width,this.DT.beat.nextBeat&&this.DT.beat.nextBeat.voice===this.DT.beat.voice&&(o=t+i.x+i.getBeatX(this.DT.beat.nextBeat,Ua.PreNotes)),l=!0;break;default:return}this.IT(s,l,a,o,h,c)}IT(t,e,s,i,n,r){if(e){const e=new Yo(0,0,P.Slight);e.renderer=this.renderer,e.doLayout(),n-=e.height/2;const a=i-s,h=(r-=e.height/2)-n,o=Math.sqrt(Math.pow(h,2)+Math.pow(a,2));e.width=a;const c=Math.asin(h/o)*(180/Math.PI);t.beginRotate(s,n,c),e.paint(0,0,t),t.endRotate()}else t.beginPath(),t.moveTo(s,n),t.lineTo(i,r),t.stroke()}},Kl=class extends Do{shouldDrawBendSlur(){return this.renderer.settings.notation.extendBendArrowsOnTiedNotes&&!!this.startNote.bendOrigin&&this.startNote.isTieOrigin}calculateStartX(){return this.isLeftHandTap?this.calculateEndX()-this.renderer.smuflMetrics.leftHandTabTieWidth:this.renderer.x+this.renderer.getBeatX(this.startNote.beat,Ua.PostNotes)}calculateEndX(){const t=this.lookupEndBeatRenderer();return t?this.isLeftHandTap?t.x+t.getNoteX(this.endNote,jo.Left):t.x+t.getBeatX(this.endNote.beat,Ua.PreNotes):this.calculateStartX()+this.renderer.smuflMetrics.leftHandTabTieWidth}},Ql=class extends Kl{gx=null;getTieHeight(t,e,s,i){return Math.log2(s-t+1)*this.renderer.settings.notation.slurHeight/2}getSlurLabels(){if(null===this.gx){this.gx=[];const t=this.startNote.beat.effectSlur;if(null!==t){const e=this.renderer.settings.notation;for(const s of t.segments){const t=cl.build(s,s.toNote.realValue>=s.fromNote.realValue);e.isNotationElementVisible(t.element)&&this.gx.push(t)}}}return this.gx.length>0?this.gx:null}calculateStartX(){return this.renderer.x+(this.GT()?this.renderer.getBeatX(this.startNote.beat,Ua.MiddleNotes):this.renderer.getNoteX(this.startNote,jo.Right))}calculateStartY(){if(this.GT()){if(this.tieDirection===Fe.Up)return this.renderer.y+this.renderer.getNoteY(this.startNote,Xo.Top);return this.renderer.y+this.renderer.getNoteY(this.startNote,Xo.Bottom)}return this.renderer.y+this.renderer.getNoteY(this.startNote,Xo.Center)}calculateEndX(){const t=this.lookupEndBeatRenderer();return t?this.HT()?this.$T()?t.x+t.getBeatX(this.endNote.beat,Ua.Stem):t.x+t.getNoteX(this.endNote,jo.Center):t.x+t.getBeatX(this.endNote.beat,Ua.PreNotes):this.calculateStartX()+this.renderer.smuflMetrics.leftHandTabTieWidth}caclculateEndY(){const t=this.lookupEndBeatRenderer();if(!t)return this.calculateStartY();if(this.HT()){if(this.$T()){if(this.tieDirection===Fe.Up)return t.y+t.getNoteY(this.endNote,Xo.TopWithStem);return t.y+t.getNoteY(this.endNote,Xo.BottomWithStem)}return this.tieDirection===Fe.Up?t.y+t.getNoteY(this.endNote,Xo.Top):t.y+t.getNoteY(this.endNote,Xo.Bottom)}return t.y+t.getNoteY(this.endNote,Xo.Center)}GT(){return this.startNote===this.startNote.beat.maxNote&&this.tieDirection===Fe.Up||this.startNote===this.startNote.beat.minNote&&this.tieDirection===Fe.Down}HT(){return this.startNote.beat.graceType===y.None&&(this.endNote===this.endNote.beat.maxNote&&this.tieDirection===Fe.Up||this.endNote===this.endNote.beat.minNote&&this.tieDirection===Fe.Down)}$T(){const t=this.lookupStartBeatRenderer().getBeatDirection(this.startNote.beat),e=this.lookupEndBeatRenderer();return t!==(e?e.getBeatDirection(this.endNote.beat):t)&&this.startNote.beat.graceType===y.None}},Zl=class extends Ja{VT=null;zT=null;UT=null;constructor(t){super(t),this.preNotes=new jl,this.onNotes=new Ul}get prebendNoteHeadOffset(){return this.preNotes.prebendNoteHeadOffset}get accidentalsWidth(){const t=this.preNotes;return t&&t.accidentals?t.accidentals.width:0}doMultiVoiceLayout(){this.preNotes.x=0,this.preNotes.doMultiVoiceLayout(),this.onNotes.x=this.preNotes.x+this.preNotes.width,this.onNotes.doMultiVoiceLayout(),this.VT?.doMultiVoiceLayout()}doLayout(){this.zT=null,this.UT=null;const t=this.renderer,e=this.beat,s=e.graceType!==y.None;if(t.hasFlag(e)){const i=t.getBeatDirection(e),n=s?si.GraceScale:1,r=wl.getSymbol(e.duration,i,s),a=t.smuflMetrics.glyphWidths.get(r)*n;this.XT=a}else if(s){const e=t.smuflMetrics.glyphWidths.get(xt.Flag8thUp)*si.GraceScale;this.XT=e}super.doLayout(),this.VT&&(this.VT.renderer=this.renderer,this.VT.doLayout(),this.updateWidth())}getBoundingBoxTop(){return null!==this.VT?Bt.minBoundingBox(this.VT.getBoundingBoxTop(),super.getBoundingBoxTop()):super.getBoundingBoxTop()}getBoundingBoxBottom(){return null!==this.VT?Bt.maxBoundingBox(this.VT.getBoundingBoxBottom(),super.getBoundingBoxTop()):super.getBoundingBoxBottom()}createTies(t){if(t.isVisible){if(t.isTieOrigin&&!t.hasBend&&!t.beat.hasWhammyBar&&t.beat.graceType!==y.BendGrace&&t.tieDestination&&t.tieDestination.isVisible){const e=new Kl(`score.tie.${t.id}`,t,t.tieDestination,!1);this.addTie(e)}if(t.isTieDestination&&!t.tieOrigin.hasBend&&!t.beat.hasWhammyBar){const e=new Kl(`score.tie.${t.tieOrigin.id}`,t.tieOrigin,t,!0);this.addTie(e)}if(t.slideInType!==T.None||t.slideOutType!==M.None){const e=new Yl(t.slideInType,t.slideOutType,t,this);this.addTie(e)}if(t.isSlurOrigin&&t.slurDestination&&t.slurDestination.isVisible){const e=new Ql(`score.slur.${t.id}`,t,t.slurDestination,!1);this.addTie(e)}if(t.isSlurDestination){const e=new Ql(`score.slur.${t.slurOrigin.id}`,t.slurOrigin,t,!0);this.addTie(e)}if(!this.zT&&t.isEffectSlurOrigin&&t.effectSlurDestination){const e=new Ql(`score.slur.effect.${t.beat.id}`,t,t.effectSlurDestination,!1);this.zT=e,this.addTie(e)}if(!this.UT&&t.beat.isEffectSlurDestination&&t.beat.effectSlurOrigin){const e=this.renderer.getBeatDirection(t.beat),s=e===Fe.Up?t.beat.effectSlurOrigin.minNote:t.beat.effectSlurOrigin.maxNote,i=e===Fe.Up?t.beat.minNote:t.beat.maxNote,n=new Ql(`score.slur.effect.${s.beat.id}`,s,i,!0);this.UT=n,this.addTie(n)}if(t.hasBend){if(!this.VT){const t=new Jl(this);this.VT=t,t.renderer=this.renderer,this.addTie(t)}this.VT.addBends(t)}if(this.beat.isLegatoOrigin){if(!this.beat.previousBeat||!this.beat.previousBeat.isLegatoOrigin){let t=this.beat.nextBeat;for(;t.nextBeat&&t.nextBeat.isLegatoDestination;)t=t.nextBeat;this.addTie(new ql(`score.legato.${this.beat.id}`,this.beat,t,!1))}}else if(this.beat.isLegatoDestination&&!this.beat.isLegatoOrigin){let t=this.beat.previousBeat;for(;t.previousBeat&&t.previousBeat.isLegatoOrigin;)t=t.previousBeat;this.addTie(new ql(`score.legato.${t.id}`,t,this.beat,!0))}}}XT=0;get postBeatStretch(){return super.postBeatStretch+this.XT}updateWidth(){super.updateWidth(),this.width+=this.XT}},tu=class t extends kl{static StaffId="score";static jT=[-1,2,-2,1,4,0,3];static JT=[3,0,4,1,5,2,6];accidentalHelper;constructor(t,e){super(t,e),this.accidentalHelper=new Hs(this)}get repeatsBarSubElement(){return j.StandardNotationRepeats}get barNumberBarSubElement(){return j.StandardNotationBarNumber}get barLineBarSubElement(){return j.StandardNotationBarLines}get staffLineBarSubElement(){return j.StandardNotationStaffLine}get lineSpacing(){return this.smuflMetrics.oneStaffSpace}get heightLineCount(){return Math.max(5,this.bar.staff.standardNotationLineCount)}get drawnLineCount(){return this.bar.staff.standardNotationLineCount}getScoreY(t){return super.getLineY(t/2)}getScoreHeight(t){return super.getLineHeight(t/2)}calculateOverflows(t,e){super.calculateOverflows(t,e),this.bar.isEmpty||this.calculateBeamingOverflows(t,e)}get flagsSubElement(){return zt.StandardNotationFlags}get beamsSubElement(){return zt.StandardNotationBeams}get tupletSubElement(){return zt.StandardNotationTuplet}getFlagTopY(t,e){const s=e===Fe.Up?Xo.TopWithStem:Xo.StemDown;return t.isRest?this.getRestY(t,s):this.voiceContainer.getHighestNoteY(t,s)}getFlagBottomY(t,e){const s=e===Fe.Up?Xo.StemUp:Xo.BottomWithStem;return t.isRest?this.getRestY(t,s):this.voiceContainer.getLowestNoteY(t,s)}getBeamDirection(t){return this.qT.has(t)?this.qT.get(t):Fe.Up}centerStaffStemY(t){return this.bar.staff.standardNotationLineCount===ve.DefaultStandardNotationLineCount?this.getScoreY(this.bar.staff.standardNotationLineCount-1):t===Fe.Up?this.getScoreY(2*this.bar.staff.standardNotationLineCount):this.getScoreY(0)}get middleYPosition(){return this.getScoreY(this.bar.staff.standardNotationLineCount-1)}applyLayoutingInfo(){const t=super.applyLayoutingInfo();if(t&&this.bar.isMultiVoice){const t=this.getScoreY(-2),e=this.getScoreY(2*this.heightLineCount),s=this.helpers.collisionHelper.getBeatMinMaxY();s[0]<t&&this.registerOverflowTop(Math.abs(s[0])),s[1]>e&&this.registerOverflowBottom(Math.abs(s[1])-e)}return t}getMinLineOfBeat(t){return this.accidentalHelper.getMinSteps(t)/2}getMaxLineOfBeat(t){return this.accidentalHelper.getMaxSteps(t)/2}createLinePreBeatGlyphs(){let t=!1;if(this.isFirstOfStaff||this.bar.clef!==this.bar.previousBar.clef||this.bar.clefOttava!==this.bar.previousBar.clefOttava){let e=0;switch(this.bar.clef){case G.Neutral:e=this.bar.staff.standardNotationLineCount-1;break;case G.F4:e=2;break;case G.C3:e=4;break;case G.C4:e=2;break;case G.G2:e=6}this.createStartSpacing(),this.addPreBeatGlyph(new _l(0,this.getScoreY(e),this.bar.clef,this.bar.clefOttava)),this.addPreBeatGlyph(new rl(0,0,this.smuflMetrics.preBeatGlyphSpacing)),t=!0}(t||0===this.index&&this.bar.keySignature!==V.C||this.bar.previousBar&&this.bar.keySignature!==this.bar.previousBar.keySignature)&&(this.createStartSpacing(),this.YT()),(!this.bar.previousBar||this.bar.previousBar&&this.bar.masterBar.timeSignatureNumerator!==this.bar.previousBar.masterBar.timeSignatureNumerator||this.bar.previousBar&&this.bar.masterBar.timeSignatureDenominator!==this.bar.previousBar.masterBar.timeSignatureDenominator||this.bar.previousBar&&this.bar.masterBar.isFreeTime&&this.bar.masterBar.isFreeTime!==this.bar.previousBar.masterBar.isFreeTime)&&(this.createStartSpacing(),this.Dx())}YT(){let e=0;const s=this.bar.keySignature,i=this.bar.previousBar?this.bar.previousBar.keySignature:0;switch(this.bar.clef){case G.Neutral:e=0;break;case G.G2:e=1;break;case G.F4:e=3;break;case G.C3:e=2;break;case G.C4:e=0}const n=new xl;n.gap=this.smuflMetrics.accidentalPadding,n.renderer=this;const r=new Map,a=[];if(Bt.keySignatureIsSharp(s))for(let i=0;i<Math.abs(s);i++){const s=t.jT[i]+e;a.push(new mo(0,this.getScoreY(s),I.Sharp,1)),r.set(s,!0)}else for(let i=0;i<Math.abs(s);i++){const s=t.JT[i]+e;a.push(new mo(0,this.getScoreY(s),I.Flat,1)),r.set(s,!0)}if(this.bar.keySignature===V.C){const s=Math.abs(i),a=Bt.keySignatureIsSharp(i)?t.jT:t.JT;for(let t=0;t<s;t++){const s=a[t]+e;r.has(s)||n.addGlyph(new mo(0,this.getScoreY(a[t]+e),I.Natural,1))}}for(const t of a)n.addGlyph(t);this.addPreBeatGlyph(n),n.isEmpty||this.addPreBeatGlyph(new rl(0,0,this.smuflMetrics.preBeatGlyphSpacing))}Dx(){const t=this.bar.staff.standardNotationLineCount-1;this.addPreBeatGlyph(new gl(0,this.getScoreY(t),this.bar.masterBar.timeSignatureNumerator,this.bar.masterBar.timeSignatureDenominator,this.bar.masterBar.timeSignatureCommon,this.bar.masterBar.isFreeTime)),this.addPreBeatGlyph(new rl(0,0,this.smuflMetrics.preBeatGlyphSpacing))}createVoiceGlyphs(t){super.createVoiceGlyphs(t);for(const e of t.beats)this.addBeatGlyph(new Zl(e))}getNoteLine(t){return this.accidentalHelper.getNoteSteps(t)/2}getNoteSteps(t){return this.accidentalHelper.getNoteSteps(t)}qT=new Map;completeBeamingHelper(t){const e=this.KT(t);this.qT.set(t,e)}KT(t){if(!t.voice)return Fe.Up;if(null!==t.preferredBeamDirection)return t.preferredBeamDirection;if(t.voice.index>0)return this.QT(t,Fe.Down);if(t.voice.bar.isMultiVoice)return this.QT(t,Fe.Up);if(t.beats[0].graceType!==y.None)return this.QT(t,Fe.Up);if(1===t.beats.length&&t.beats[0].slashed)return this.QT(t,Fe.Down);if(t.highestNoteInHelper&&t.lowestNoteInHelper){const e=(this.ZT(t.highestNoteInHelper)+this.ZT(t.lowestNoteInHelper))/2;return this.QT(t,this.middleYPosition<e?Fe.Up:Fe.Down)}return this.QT(t,Fe.Up)}ZT(t){const e=Hs.computeStepsWithoutAccidentals(this.bar,t);return this.getScoreY(e)}QT(t,e){return t.invertBeamDirection?e===Fe.Down?Fe.Up:Fe.Down:e}paintBeamingStem(t,e,s,i,n,r){const a=Kh.beat(r,zt.StandardNotationStem,t);try{r.fillRect(s,i,this.smuflMetrics.stemThickness,n-i)}finally{a?.[Symbol.dispose]?.()}}},eu=class extends Sh{get staffId(){return tu.StaffId}create(t,e){return new tu(t,e)}canCreate(t,e){return super.canCreate(t,e)&&e.showStandardNotation}},su=class extends Il{paint(t,e,s){super.internalPaint(t,e,s,zt.SlashRests)}},iu=class extends sl{nT;rT=0;noteHeads=null;deadSlapped=null;restGlyph=null;get effectElement(){return zt.SlashEffects}getNoteX(t,e){let s=null;if(this.noteHeads?s=this.noteHeads:this.deadSlapped&&(s=this.deadSlapped),s){let t=s.x;switch(e){case jo.Left:break;case jo.Center:t+=s.width/2;break;case jo.Right:t+=s.width}return t}return 0}buildBoundingsLookup(t,e,s){if(this.noteHeads&&this.container.beat.notes.length>0){const i=new Xn;i.note=this.container.beat.notes[0],i.noteHeadBounds=new _s,i.noteHeadBounds.x=e+this.x+this.noteHeads.x,i.noteHeadBounds.y=s+this.y+this.noteHeads.y-this.noteHeads.height/2,i.noteHeadBounds.w=this.width,i.noteHeadBounds.h=this.height,t.addNote(i)}}getLowestNoteY(t){return this.lx(t)}getHighestNoteY(t){return this.lx(t)}getRestY(t){const e=this.restGlyph;if(e)switch(t){case Xo.TopWithStem:return e.getBoundingBoxTop()-this.renderer.smuflMetrics.getStemLength(w.Quarter,!0);case Xo.Top:return e.getBoundingBoxTop();case Xo.Center:case Xo.StemUp:case Xo.StemDown:return e.getBoundingBoxTop()+e.height/2;case Xo.Bottom:return e.getBoundingBoxBottom();case Xo.BottomWithStem:return e.getBoundingBoxBottom()+this.renderer.smuflMetrics.getStemLength(w.Quarter,!0)}return 0}getNoteY(t,e){return this.lx(e)}lx(t){let e=null,s=xt.None,i=!1;if(this.noteHeads?(e=this.noteHeads,s=Vl.getSymbol(this.container.beat.duration),i=!0):this.deadSlapped&&(e=this.deadSlapped),e){let n=this.y+e.y;const r=this.renderer,a=this.container.beat,h=a.graceType!==y.None?si.GraceScale:1;switch(t){case Xo.TopWithStem:return i?(n-=(r.smuflMetrics.stemUp.has(s)?r.smuflMetrics.stemUp.get(s).bottomY:0)*h,n-=r.smuflMetrics.getStemLength(a.duration,r.hasFlag(a))*h,n-=this.rT):n-=e.height/2,n;case Xo.Top:n-=e.height/2;break;case Xo.Center:break;case Xo.Bottom:n+=e.height/2;break;case Xo.BottomWithStem:return i?(n-=(r.smuflMetrics.stemDown.has(s)?r.smuflMetrics.stemDown.get(s).topY:-r.smuflMetrics.glyphHeights.get(s)/2)*h,n+=r.smuflMetrics.getStemLength(a.duration,r.hasFlag(a))*h,n+=this.rT):n+=e.height/2,n;case Xo.StemUp:n-=this.renderer.smuflMetrics.stemUp.has(s)?this.renderer.smuflMetrics.stemUp.get(s).bottomY:0;break;case Xo.StemDown:n-=this.renderer.smuflMetrics.stemDown.has(s)?this.renderer.smuflMetrics.stemDown.get(s).topY:0}return n}return 0}doLayout(){const t=this.renderer,e=t.getLineY(0);if(this.container.beat.deadSlapped){const t=new il;t.renderer=this.renderer,t.doLayout(),this.deadSlapped=t,this.addEffect(t)}else if(!this.container.beat.isEmpty)if(this.container.beat.isRest){const t=new su(0,e,this.container.beat.duration);this.restGlyph=t,t.beat=this.container.beat,this.addNormal(t)}else{const t=new Vl(0,e,this.container.beat);this.noteHeads=t,t.beat=this.container.beat,this.addNormal(t),this.container.beat.isTremolo&&(this.nT=new Rl(0,0,this.container.beat.tremoloPicking),this.nT.renderer=this.renderer,this.nT.doLayout(),this.aT())}if(this.container.beat.dots>0)for(let s=0;s<this.container.beat.dots;s++)this.addEffect(new tl(0,e-t.getLineHeight(.5)));super.doLayout(),this.container.beat.isEmpty?(this.onTimeX=this.width/2,this.stemX=this.onTimeX):this.restGlyph?(this.onTimeX=this.restGlyph.x+this.restGlyph.width/2,this.stemX=this.onTimeX):this.noteHeads?(this.onTimeX=this.noteHeads.x+this.noteHeads.width/2,this.stemX=this.noteHeads.x+this.noteHeads.stemX):this.deadSlapped&&(this.onTimeX=this.deadSlapped.x+this.deadSlapped.width/2,this.stemX=this.onTimeX),this.middleX=this.onTimeX;const s=this.nT;s&&(s.x=this.container.beat.duration<w.Half?this.width/2:this.stemX)}aT(){const t=this.nT;t.alignTremoloPickingGlyph(Fe.Up,this.lx(Xo.TopWithStem),this.lx(Xo.Center),this.container.beat.duration),this.rT=t.stemExtensionHeight;let e=this.stemX;this.container.beat.duration<w.Half&&(e=this.width/2),t.x=e}paint(t,e,s){super.paint(t,e,s);const i=this.nT;i&&i.paint(t+this.x,e+this.y,s)}},nu=class extends Do{calculateTieDirection(){return Fe.Down}getStartNotePosition(){return jo.Right}getEndNotePosition(){return jo.Left}},ru=class extends Ja{tM=null;constructor(t){super(t),this.preNotes=new el,this.onNotes=new iu}doLayout(){const t=this.renderer,e=this.beat,s=e.graceType!==y.None;if(t.hasFlag(e)){const i=t.getBeatDirection(e),n=s?si.GraceScale:1,r=wl.getSymbol(e.duration,i,s),a=t.smuflMetrics.glyphWidths.get(r)*n;this.XT=a}else if(s){const e=t.smuflMetrics.glyphWidths.get(xt.Flag8thUp)*si.GraceScale;this.XT=e}super.doLayout()}createTies(t){if(t.isVisible){if(!this.tM&&t.isTieOrigin&&t.tieDestination.isVisible){const e=new nu("slash.tie",t,t.tieDestination,!1);this.tM=e,this.addTie(e)}if(!this.tM&&t.isTieDestination){const e=new nu("slash.tie",t.tieOrigin,t,!0);this.tM=e,this.addTie(e)}}}XT=0;get postBeatStretch(){return super.postBeatStretch+this.XT}updateWidth(){super.updateWidth(),this.width+=this.XT}},au=class extends kl{static StaffId="slash";simpleWhammyOverflow=0;eM;constructor(t,e){super(t,e),this.eM=!e.staff.showTablature&&!e.staff.showStandardNotation,this.helpers.preferredBeamDirection=Fe.Up}get repeatsBarSubElement(){return j.SlashRepeats}get barNumberBarSubElement(){return j.SlashBarNumber}get barLineBarSubElement(){return j.SlashBarLines}get staffLineBarSubElement(){return j.SlashStaffLine}get lineSpacing(){return this.smuflMetrics.oneStaffSpace}get heightLineCount(){return 5}get drawnLineCount(){return 1}get bottomGlyphOverflow(){return 0}get flagsSubElement(){return zt.SlashFlags}get beamsSubElement(){return zt.SlashBeams}get tupletSubElement(){return zt.SlashTuplet}doLayout(){super.doLayout(),this.voiceContainer.tupletGroups.size>0&&this.registerOverflowTop(this.tupletSize)}getNoteLine(t){return 0}getFlagTopY(t,e){const s=e===Fe.Up?Xo.TopWithStem:Xo.StemDown;return t.notes.length>0?this.getNoteY(t.notes[0],s):this.getRestY(t,s)}getFlagBottomY(t,e){const s=e===Fe.Up?Xo.StemUp:Xo.BottomWithStem;return t.notes.length>0?this.getNoteY(t.notes[0],s):this.getRestY(t,s)}getBeamDirection(t){return Fe.Up}createLinePreBeatGlyphs(){this.eM&&(!this.bar.previousBar||this.bar.previousBar&&this.bar.masterBar.timeSignatureNumerator!==this.bar.previousBar.masterBar.timeSignatureNumerator||this.bar.previousBar&&this.bar.masterBar.timeSignatureDenominator!==this.bar.previousBar.masterBar.timeSignatureDenominator||this.bar.previousBar&&this.bar.masterBar.isFreeTime&&this.bar.masterBar.isFreeTime!==this.bar.previousBar.masterBar.isFreeTime)&&(this.createStartSpacing(),this.Dx())}Dx(){this.addPreBeatGlyph(new rl(0,0,this.smuflMetrics.oneStaffSpace));const t=this.bar.masterBar,e=new gl(0,this.getLineY(0),t.timeSignatureNumerator,t.timeSignatureDenominator,t.timeSignatureCommon,t.isFreeTime&&(null==t.previousMasterBar||t.isFreeTime!==t.previousMasterBar.isFreeTime));e.barSubElement=j.SlashTimeSignature,this.addPreBeatGlyph(e)}createVoiceGlyphs(t){if(!(t.index>0)){super.createVoiceGlyphs(t);for(const e of t.beats)this.addBeatGlyph(new ru(e))}}calculateOverflows(t,e){super.calculateOverflows(t,e),this.bar.isEmpty||this.calculateBeamingOverflows(t,e)}shouldPaintBeamingHelper(t){return super.shouldPaintBeamingHelper(t)&&0===t.voice.index}paintBeamingStem(t,e,s,i,n,r){const a=Kh.beat(r,zt.SlashStem,t);try{r.fillRect(s,i,this.smuflMetrics.stemThickness,n-i)}finally{a?.[Symbol.dispose]?.()}}paintBeamHelper(t,e,s,i,n,r){0===i.voice?.index&&super.paintBeamHelper(t,e,s,i,n,r)}},hu=class extends Sh{get staffId(){return au.StaffId}create(t,e){return new au(t,e)}canCreate(t,e){return super.canCreate(t,e)&&e.showSlash}},ou=class extends Xa{qe;sM=null;iM=null;nM=0;isEmpty=!1;noteStringWidth=0;constructor(t,e,s){super(t,e),this.qe=s}get tS(){return.25*this.renderer.lineSpacing}getBoundingBoxTop(){return this.y-this.height/2-this.tS}getBoundingBoxBottom(){return this.y+this.height/2}doLayout(){const t=this.qe;let e=t.fret-t.beat.voice.bar.staff.transpositionPitch;if(t.harmonicType===B.Natural&&0!==t.harmonicValue&&(e=t.harmonicValue-t.beat.voice.bar.staff.transpositionPitch),t.isTieDestination)0===t.beat.index&&this.renderer.settings.notation.notationMode===F.GuitarPro||(t.bendType===b.Bend||t.bendType===b.BendRelease)&&this.renderer.settings.notation.isNotationElementVisible(A.TabNotesOnTiedBends)?this.sM=`(${(t.tieOrigin.fret-t.beat.voice.bar.staff.transpositionPitch).toString()})`:this.sM="";else if(this.sM=t.isDead?"x":e.toString(),t.isGhost)this.sM=`(${this.sM})`;else if(t.harmonicType===B.Natural){const t=this.sM.indexOf(String.fromCharCode(46));t>=0&&(this.sM=this.sM.substr(0,t+2)),this.sM=`<${this.sM}>`}if(t.isTrill)this.iM=`(${(t.trillFret-t.beat.voice.bar.staff.transpositionPitch).toString()})`;else if(Bt.isAlmostEqualTo(t.harmonicValue,0))this.iM="";else switch(t.harmonicType){case B.Artificial:case B.Pinch:case B.Tap:case B.Semi:case B.Feedback:let s=(e+t.harmonicValue).toString();const i=s.indexOf(String.fromCharCode(46));i>=0&&(s=s.substr(0,i+2)),this.iM=`<${s}>`;break;default:this.iM=""}if(this.isEmpty=!this.sM,!this.isEmpty){this.renderer.scoreRenderer.canvas.font=this.renderer.resources.tablatureFont;const t=!!this.iM;this.noteStringWidth=this.renderer.scoreRenderer.canvas.measureText(this.sM+(t?" ":"")).width,this.width=this.noteStringWidth,this.height=this.renderer.scoreRenderer.canvas.font.size,t&&(this.renderer.scoreRenderer.canvas.font=this.renderer.resources.graceFont,this.nM=3+this.renderer.scoreRenderer.canvas.measureText(this.iM).width,this.width+=this.nM)}}paint(t,e,s){if(this.isEmpty)return;const i=this.noteStringWidth+this.nM,n=t+this.x+(this.width-i)/2,r=e+this.y;this.paintTrill(n,r,s);const a=Kh.note(s,Et.GuitarTabFretNumber,this.qe);try{s.fillText(this.sM,n,r)}finally{a?.[Symbol.dispose]?.()}}paintTrill(t,e,s){const i=Kh.note(s,Et.GuitarTabFretNumber,this.qe);try{const i=this.renderer.scoreRenderer.canvas.font;this.renderer.scoreRenderer.canvas.font=this.renderer.resources.graceFont,s.fillText(this.iM,t+this.noteStringWidth,e),this.renderer.scoreRenderer.canvas.font=i}finally{i?.[Symbol.dispose]?.()}}buildBoundingsLookup(t,e,s){const i=new Xn;i.note=this.qe,i.noteHeadBounds=new _s,i.noteHeadBounds.x=e+this.x,i.noteHeadBounds.y=s+this.y-this.height/2,i.noteHeadBounds.w=this.width,i.noteHeadBounds.h=this.height,t.addNote(i)}},cu=class extends Xa{dB=[];iT=null;ix;beat;maxStringNote=null;minStringNote=null;beatEffects=new Map;notesPerString=new Map;noteStringWidth=0;constructor(t,e,s){super(t,e),this.ix=s}buildBoundingsLookup(t,e,s){for(const i of this.dB)i.buildBoundingsLookup(t,e+this.x,s+this.y)}getNoteX(t,e){if(this.notesPerString.has(t.string)){const s=this.notesPerString.get(t.string);let i=this.x+s.x;switch(e){case jo.Left:break;case jo.Center:i+=s.noteStringWidth/2;break;case jo.Right:i+=s.width}return i}return 0}getLowestNoteY(t){return this.maxStringNote?this.getNoteY(this.maxStringNote,t):0}getHighestNoteY(t){return this.minStringNote?this.getNoteY(this.minStringNote,t):0}getNoteY(t,e){if(this.notesPerString.has(t.string)){const s=this.notesPerString.get(t.string);let i=this.y+s.y;switch(e){case Xo.Top:i-=s.height/2;break;case Xo.StemUp:i=this.y+s.getBoundingBoxTop();break;case Xo.Center:break;case Xo.Bottom:i+=s.height/2;break;case Xo.StemDown:i=this.y+s.getBoundingBoxBottom();break;case Xo.TopWithStem:i=-this.renderer.settings.notation.rhythmHeight,i-=this.calculateTremoloHeightForStem();break;case Xo.BottomWithStem:i=this.renderer.height+this.renderer.settings.notation.rhythmHeight,i+=this.calculateTremoloHeightForStem()}return i}return 0}calculateTremoloHeightForStem(){const t=this.beat;if(!t.isTremolo)return 0;if(t.duration<=w.Quarter)return 0;const e=Rl.Wk(t.tremoloPicking),s=this.renderer.smuflMetrics;return s.glyphHeights.has(e)?s.glyphHeights.get(e):0}doLayout(){let t=0;if(this.beat.deadSlapped)this.iT=new il,this.iT.renderer=this.renderer,this.iT.doLayout(),t=this.iT.width,this.noteStringWidth=t;else{let e=0;for(let s=0,i=this.dB.length;s<i;s++){const i=this.dB[s];i.renderer=this.renderer,i.doLayout(),i.width>t&&(t=i.width),i.noteStringWidth>e&&(e=i.noteStringWidth)}this.noteStringWidth=e;const s=this.renderer.resources.tablatureFont.size;let i=NaN,n=NaN,r=this.getNoteY(this.minStringNote,Xo.Center)+s/2;const a=this.renderer.smuflMetrics.onNoteEffectPadding;for(const t of this.beatEffects.values())t.y+=r,t.x+=this.width/2,t.renderer=this.renderer,t.doLayout(),r+=t.height+a,(Number.isNaN(i)||i>r)&&(i=r),(Number.isNaN(n)||n<r)&&(n=r);Number.isNaN(i)||this.renderer.registerBeatEffectOverflows(i,n)}this.width=t}addNoteGlyph(t,e){this.dB.push(t),this.notesPerString.set(e.string,t),(!this.minStringNote||e.string<this.minStringNote.string)&&(this.minStringNote=e),(!this.maxStringNote||e.string>this.maxStringNote.string)&&(this.maxStringNote=e)}paint(t,e,s){if(t+=this.x,e+=this.y,this.beat.deadSlapped)this.iT?.paint(t,e,s);else{const i=this.renderer.resources,n=s.textBaseline;s.textBaseline=dt.Middle,s.font=this.ix?i.graceFont:i.tablatureFont;const r=this.dB,a=this.width;for(const i of r)i.renderer=this.renderer,i.width=a,i.paint(t,e,s);s.textBaseline=n;const h=Kh.beat(s,zt.GuitarTabEffects,this.beat);try{for(const i of this.beatEffects.values())i.paint(t,e,s)}finally{h?.[Symbol.dispose]?.()}}}},lu=class extends $h{rM;constructor(t,e,s,i){super(t,e,1,Il.getSymbol(i)),this.rM=s}doLayout(){super.doLayout()}paint(t,e,s){if(this.rM){const i=Kh.beat(s,zt.GuitarTabRests,this.beat);try{super.paint(t,e,s)}finally{i?.[Symbol.dispose]?.()}}}},uu=class extends sl{slash=null;noteNumbers=null;restGlyph=null;get effectElement(){return zt.GuitarTabEffects}getNoteX(t,e){if(this.slash){let t=this.slash.x;switch(e){case jo.Left:break;case jo.Center:t+=this.slash.width/2;break;case jo.Right:t+=this.slash.width}return t}return this.noteNumbers?this.noteNumbers.getNoteX(t,e):0}getNoteY(t,e){return this.noteNumbers?this.noteNumbers.getNoteY(t,e):0}getRestY(t){const e=this.restGlyph;if(e)switch(t){case Xo.TopWithStem:return e.getBoundingBoxTop()-this.renderer.smuflMetrics.getStemLength(w.Quarter,!0);case Xo.Top:return e.getBoundingBoxTop();case Xo.Center:case Xo.StemUp:case Xo.StemDown:return e.getBoundingBoxTop()+e.height/2;case Xo.Bottom:return e.getBoundingBoxTop();case Xo.BottomWithStem:return e.getBoundingBoxBottom()+this.renderer.smuflMetrics.getStemLength(w.Quarter,!0)}return 0}getLowestNoteY(t){return this.noteNumbers?this.noteNumbers.getLowestNoteY(t):0}getHighestNoteY(t){return this.noteNumbers?this.noteNumbers.getHighestNoteY(t):0}buildBoundingsLookup(t,e,s){this.noteNumbers&&this.noteNumbers.buildBoundingsLookup(t,e+this.x,s+this.y)}doLayout(){const t=this.renderer,e=[];if(this.container.beat.isRest){const e=Math.floor((this.renderer.bar.staff.tuning.length-1)/2),s=t.getLineY(e),i=new lu(0,s,t.showRests,this.container.beat.duration);if(this.restGlyph=i,i.beat=this.container.beat,this.addNormal(i),this.container.beat.dots>0&&t.showRests)for(let t=0;t<this.container.beat.dots;t++)this.addEffect(new tl(0,s))}else{const s=this.renderer.settings.notation.smallGraceTabNotes&&this.container.beat.graceType!==y.None;let i;if(this.container.beat.slashed&&!this.container.beat.notes.some(t=>t.isTieDestination)){const e=Math.floor((this.renderer.bar.staff.tuning.length-1)/2),s=new Vl(0,t.getLineY(e),this.container.beat);s.noteHeadElement=Et.GuitarTabFretNumber,s.effectElement=zt.GuitarTabEffects,this.slash=s,s.beat=this.container.beat,this.addNormal(s),i=s.beatEffects}else{const t=new cu(0,0,s);this.noteNumbers=t,t.beat=this.container.beat;for(const t of this.container.beat.notes)t.isVisible&&this.BT(t);this.addNormal(t),i=t.beatEffects}if(this.container.beat.isTremolo&&!i.has("tremolo")){const t=new Rl(0,0,this.container.beat.tremoloPicking);t.offsetY=this.renderer.smuflMetrics.glyphTop.get(t.symbol),i.set("tremolo",t),e.push(t)}if(this.container.beat.dots>0&&t.rhythmMode!==C.Hidden){const t=this.getNoteY(this.container.beat.maxNote,Xo.BottomWithStem);for(let e=0;e<this.container.beat.dots;e++)this.addEffect(new tl(0,t))}}if(this.isEmpty)return;let s=0;for(let t=0,e=this.glyphs.length;t<e;t++){const e=this.glyphs[t];e.x=s,e.renderer=this.renderer,e.doLayout(),s+=e.width}this.width=s,this.computedWidth=s,this.container.beat.isEmpty?this.onTimeX=this.width/2:this.restGlyph?this.onTimeX=this.restGlyph.x+this.restGlyph.width/2:this.noteNumbers?this.onTimeX=this.noteNumbers.x+this.noteNumbers.noteStringWidth/2:this.slash&&(this.onTimeX=this.slash.x+this.slash.width/2),this.middleX=this.onTimeX,this.stemX=this.middleX;for(const t of e)t.x=this.onTimeX}BT(t){const e=this.renderer,s=new ou(0,0,t),i=e.getNoteLine(t);s.y=e.getLineY(i),s.renderer=this.renderer,s.doLayout(),this.noteNumbers.addNoteGlyph(s,t);const n=s.getBoundingBoxTop(),r=s.getBoundingBoxBottom();this.renderer.collisionHelper.reserveBeatSlot(this.container.beat,n,r);const a=e.minString,h=e.maxString;(Number.isNaN(a)||a<t.string)&&(e.minString=i),(Number.isNaN(h)||h>t.string)&&(e.maxString=i)}},du=class extends Xa{$e;TT;constructor(t){super(0,0),this.$e=t}doLayout(){if(this.width=this.renderer.smuflMetrics.glyphWidths.get(xt.ArrowheadBlackDown),this.$e.brushType===m.ArpeggioUp){const t=new Yo(0,0,P.Slight,!0);t.renderer=this.renderer,t.doLayout(),this.TT=t}else if(this.$e.brushType===m.ArpeggioDown){const t=new Yo(0,0,P.Slight,!0);t.renderer=this.renderer,t.doLayout(),this.TT=t}}paint(t,e,s){const i=this.renderer,n=e+this.x+i.getNoteY(this.$e.maxStringNote,Xo.Top),r=e+this.y+i.getNoteY(this.$e.minStringNote,Xo.Bottom),a=t+this.x+this.width/2,h=this.renderer.smuflMetrics.glyphWidths.get(xt.ArrowheadBlackDown);if(this.$e.brushType!==m.None){if(this.$e.brushType===m.BrushUp||this.$e.brushType===m.BrushDown)s.beginPath(),s.moveTo(a,n),s.lineTo(a,r),s.stroke();else if(this.$e.brushType===m.ArpeggioUp){const e=this.TT,i=n,a=r-h;e.width=Math.abs(a-i),s.beginRotate(t+this.x,a,-90),e.paint(0,(this.width-e.height)/2,s),s.endRotate()}else if(this.$e.brushType===m.ArpeggioDown){const e=this.TT,i=n+h;e.width=Math.abs(r-i),s.beginRotate(t+this.x,i,90),e.paint(0,-(this.width-e.height/2),s),s.endRotate()}this.$e.brushType===m.BrushUp||this.$e.brushType===m.ArpeggioUp?(s.beginPath(),s.moveTo(a,r),s.lineTo(a+h/2,r-h),s.lineTo(a-h/2,r-h),s.closePath(),s.fill()):(s.beginPath(),s.moveTo(a,n),s.lineTo(a+h/2,n+h),s.lineTo(a-h/2,n+h),s.closePath(),s.fill())}}},fu=class extends el{doLayout(){this.container.beat.brushType===m.None||this.container.beat.isRest||(this.addEffect(new du(this.container.beat)),this.addNormal(new rl(0,0,this.renderer.smuflMetrics.preNoteEffectPadding))),super.doLayout()}get effectElement(){return zt.GuitarTabEffects}},pu=class extends Xa{AT;FT;DT;LT;checkForOverflow=!1;constructor(t,e,s,i){super(0,0),this.AT=t,this.FT=e,this.DT=s,this.LT=i}doLayout(){this.width=0}paint(t,e,s){this.WT(t,e,s),this.aM(t,e,s)}WT(t,e,s){const i=this.renderer,n=this.renderer.smuflMetrics.simpleSlideWidth,r=this.renderer.smuflMetrics.simpleSlideHeight;let a=0,h=0,o=0,c=0;const l=this.renderer.smuflMetrics.preNoteEffectPadding;switch(this.AT){case T.IntoFromBelow:o=t+i.x+i.getNoteX(this.DT,jo.Left)-l,c=e+i.y+i.getNoteY(this.DT,Xo.Center)-r,a=o-n,h=e+i.y+i.getNoteY(this.DT,Xo.Center)+r;break;case T.IntoFromAbove:o=t+i.x+i.getNoteX(this.DT,jo.Left)-l,c=e+i.y+i.getNoteY(this.DT,Xo.Center)+r,a=o-n,h=e+i.y+i.getNoteY(this.DT,Xo.Center)-r;break;default:return}this.IT(s,!1,a,o,h,c)}aM(t,e,s){const i=this.renderer,n=this.renderer.smuflMetrics.simpleSlideWidth,r=this.renderer.smuflMetrics.simpleSlideHeight;let a=0,h=0,o=0,c=0,l=!1;const u=this.renderer.smuflMetrics.postNoteEffectPadding;switch(this.FT){case M.Shift:case M.Legato:if(a=t+i.x+i.getBeatX(this.DT.beat,Ua.PostNotes)+u,h=e+i.y+i.getNoteY(this.DT,Xo.Center),this.DT.slideTarget){const s=this.renderer.scoreRenderer.layout.getRendererForBar(this.renderer.staff.staffId,this.DT.slideTarget.beat.voice.bar);s&&s.staff===i.staff?(o=t+s.x+s.getBeatX(this.DT.slideTarget.beat,Ua.OnNotes)-u,c=e+s.y+s.getNoteY(this.DT.slideTarget,Xo.Center)):(o=t+i.x+i.width,c=h),this.DT.slideTarget.fret>this.DT.fret?(h+=r,c-=r):(h-=r,c+=r)}else o=t+i.x+this.LT.x,c=h;break;case M.OutUp:a=t+i.x+i.getNoteX(this.DT,jo.Right)+u,h=e+i.y+i.getNoteY(this.DT,Xo.Center)+r,o=a+n,c=e+i.y+i.getNoteY(this.DT,Xo.Center)-r;break;case M.OutDown:a=t+i.x+i.getNoteX(this.DT,jo.Right)+u,h=e+i.y+i.getNoteY(this.DT,Xo.Center)-r,o=a+n,c=e+i.y+i.getNoteY(this.DT,Xo.Center)+r;break;case M.PickSlideDown:a=t+i.x+i.getNoteX(this.DT,jo.Right)+2*u,h=e+i.y+i.getNoteY(this.DT,Xo.Center),o=t+i.x+i.width,c=h+3*r,this.DT.beat.nextBeat&&this.DT.beat.nextBeat.voice===this.DT.beat.voice&&(o=t+i.x+i.getBeatX(this.DT.beat.nextBeat,Ua.PreNotes)),l=!0;break;case M.PickSlideUp:a=t+i.x+i.getNoteX(this.DT,jo.Right)+2*u,h=e+i.y+i.getNoteY(this.DT,Xo.Center),o=t+i.x+i.width,c=h-3*r,this.DT.beat.nextBeat&&this.DT.beat.nextBeat.voice===this.DT.beat.voice&&(o=t+i.x+i.getBeatX(this.DT.beat.nextBeat,Ua.PreNotes)),l=!0;break;default:return}this.IT(s,l,a,o,h,c)}IT(t,e,s,i,n,r){if(e){const e=new Yo(0,0,P.Slight);e.renderer=this.renderer,e.doLayout(),n-=e.height/2;const a=i-s,h=(r-=e.height/2)-n,o=Math.sqrt(Math.pow(h,2)+Math.pow(a,2));e.width=a;const c=Math.asin(h/o)*(180/Math.PI);t.beginRotate(s,n,c),e.paint(0,0,t),t.endRotate()}else t.beginPath(),t.moveTo(s,n),t.lineTo(i,r),t.stroke()}},bu=class extends Ja{VT=null;wx=[];constructor(t){super(t),this.preNotes=new fu,this.onNotes=new uu}drawBeamHelperAsFlags(t){return t.hasFlag(this.renderer.drawBeamHelperAsFlags(t),this.beat)}doLayout(){this.wx=[],super.doLayout(),this.VT&&(this.VT.renderer=this.renderer,this.VT.doLayout(),this.updateWidth())}createTies(t){if(!t.isVisible)return;const e=this.renderer;if(t.isTieOrigin&&e.showTiedNotes&&t.tieDestination.isVisible){const e=new ol(`tab.tie.${t.id}`,t,t.tieDestination,!1);this.addTie(e)}if(t.isTieDestination&&e.showTiedNotes){const e=new ol(`tab.tie.${t.tieOrigin.id}`,t.tieOrigin,t,!0);this.addTie(e)}if(t.isLeftHandTapped&&!t.isHammerPullDestination){const e=new ol(`tab.tie.leftHandTap.${t.id}`,t,t,!1);this.addTie(e)}if(t.isEffectSlurOrigin&&t.effectSlurDestination){let e=!1;for(const s of this.wx)if(s.tryExpand(t,t.effectSlurDestination,!1,!1)){e=!0;break}if(!e){const e=new ll(`tab.slur.effect.${t.id}`,t,t.effectSlurDestination,!1,!1);this.wx.push(e),this.addTie(e)}}if(t.isEffectSlurDestination&&t.effectSlurOrigin){let e=!1;for(const s of this.wx)if(s.tryExpand(t.effectSlurOrigin,t,!1,!0)){e=!0;break}if(!e){const e=new ll(`tab.slur.effect.${t.effectSlurOrigin.id}`,t.effectSlurOrigin,t,!1,!0);this.wx.push(e),this.addTie(e)}}if(t.slideInType!==T.None||t.slideOutType!==M.None){const e=new pu(t.slideInType,t.slideOutType,t,this);this.addTie(e)}if(t.hasBend){if(!this.VT){const t=new Qo;this.VT=t,t.renderer=this.renderer,this.addTie(t)}this.VT.addBends(t)}}},mu=class extends $h{constructor(t,e){super(t,e,1,xt.SixStringTabClef)}doLayout(){this.symbol=this.renderer.bar.staff.tuning.length<=4?xt.FourStringTabClef:xt.SixStringTabClef,this.center=!0,super.doLayout(),this.width=this.renderer.smuflMetrics.glyphWidths.get(xt.GClef),this.offsetX=this.width/2}},gu=class extends ml{doLayout(){this.barSubElement=j.GuitarTabsTimeSignature,super.doLayout()}get commonScale(){return 1}get numberScale(){return this.renderer.bar.staff.tuning.length<=4?si.GraceScale:1}},wu=class extends kl{static StaffId="tab";hM=!1;showTimeSignature=!1;showRests=!1;showTiedNotes=!1;oM=!1;get showMultiBarRest(){return this.oM}get repeatsBarSubElement(){return j.GuitarTabsRepeats}get barNumberBarSubElement(){return j.GuitarTabsBarNumber}get barLineBarSubElement(){return j.GuitarTabsBarLines}get staffLineBarSubElement(){return j.GuitarTabsStaffLine}get lineSpacing(){return this.smuflMetrics.tabLineSpacing}get heightLineCount(){return this.bar.staff.tuning.length}get drawnLineCount(){return this.bar.staff.tuning.length}get rhythmMode(){let t=this.settings.notation.rhythmMode;return t===C.Automatic&&(t=this.bar.staff.showStandardNotation?C.Hidden:C.ShowWithBars),t}getNoteLine(t){return this.bar.staff.tuning.length-t.string}minString=NaN;maxString=NaN;collectSpaces(t){if(this.additionalMultiRestBars)return;const e=this.smuflMetrics.staffLineThickness,s=this.bar.staff.tuning;for(const i of this.voiceContainer.beatGlyphs.values())for(const n of i){const i=n.onNotes,r=i.noteNumbers;if(r)for(const[a,h]of r.notesPerString)h.isEmpty||t[s.length-a].push(new Float32Array([this.beatGlyphsStart+n.x+i.x+r.x-e,r.width+2*e]))}}doLayout(){this.bar.staff.showStandardNotation&&this.scoreRenderer.layout.profile.has(tu.StaffId)||(this.showTimeSignature=!0,this.showRests=!0,this.showTiedNotes=!0,this.oM=!0),super.doLayout(),0===this.minString&&this.registerOverflowTop(this.lineSpacing/2),this.maxString===this.bar.staff.tuning.length-1&&this.registerOverflowBottom(this.lineSpacing/2),this.rhythmMode!==C.Hidden&&(this.hM=this.voiceContainer.tupletGroups.size>0,this.hM&&this.registerOverflowBottom(this.settings.notation.rhythmHeight+this.tupletSize))}createLinePreBeatGlyphs(){if(this.isFirstOfStaff){const t=(this.bar.staff.tuning.length-1)/2;this.createStartSpacing(),this.addPreBeatGlyph(new mu(0,this.getLineY(t)))}this.showTimeSignature&&(!this.bar.previousBar||this.bar.previousBar&&this.bar.masterBar.timeSignatureNumerator!==this.bar.previousBar.masterBar.timeSignatureNumerator||this.bar.previousBar&&this.bar.masterBar.timeSignatureDenominator!==this.bar.previousBar.masterBar.timeSignatureDenominator||this.bar.previousBar&&this.bar.masterBar.isFreeTime&&this.bar.masterBar.isFreeTime!==this.bar.previousBar.masterBar.isFreeTime)&&(this.createStartSpacing(),this.Dx())}Dx(){this.addPreBeatGlyph(new rl(0,0,this.smuflMetrics.oneStaffSpace));const t=(this.bar.staff.tuning.length+1)/2-1;this.addPreBeatGlyph(new gu(0,this.getLineY(t),this.bar.masterBar.timeSignatureNumerator,this.bar.masterBar.timeSignatureDenominator,this.bar.masterBar.timeSignatureCommon,this.bar.masterBar.isFreeTime))}createVoiceGlyphs(t){super.createVoiceGlyphs(t);for(const e of t.beats)this.addBeatGlyph(new bu(e))}get flagsSubElement(){return zt.GuitarTabFlags}get beamsSubElement(){return zt.GuitarTabBeams}get tupletSubElement(){return zt.GuitarTabTuplet}paintBeams(t,e,s,i,n){this.rhythmMode!==C.Hidden&&super.paintBeams(t,e,s,i,n)}paintTuplets(t,e,s,i,n=!1){this.rhythmMode!==C.Hidden&&super.paintTuplets(t,e,s,i,n)}drawBeamHelperAsFlags(t){return super.drawBeamHelperAsFlags(t)||this.rhythmMode===C.ShowWithBeams}getFlagTopY(t,e){const s=t.maxStringNote,i=e===Fe.Up?Xo.TopWithStem:Xo.StemDown;return s?this.getNoteY(s,i):this.getRestY(t,i)}getFlagBottomY(t,e){const s=t.minStringNote,i=e===Fe.Up?Xo.StemUp:Xo.BottomWithStem;return s?this.getNoteY(s,i):this.getRestY(t,i)}getBeamDirection(t){return Fe.Down}shouldPaintFlag(t){return!!super.shouldPaintFlag(t)&&t.graceType===y.None}paintBeamingStem(t,e,s,i,n,r){if(n<i){const t=n;n=i,i=t}const a=Kh.beat(r,zt.GuitarTabStem,t);try{let a=[];if(this.helpers.collisionHelper.reservedLayoutAreasByDisplayTime.has(t.displayStart)&&(a=this.helpers.collisionHelper.reservedLayoutAreasByDisplayTime.get(t.displayStart).slots.slice(),a.sort((t,e)=>t.topY-e.topY)),1===a.length)return void r.fillRect(s,i,this.smuflMetrics.stemThickness,n-i);const h=n-e,o=a[a.length-1];r.fillRect(s,e+o.bottomY,this.smuflMetrics.stemThickness,h-o.bottomY);for(let t=a.length-1;t>0;t--){const i=a[t].topY,n=a[t-1].bottomY;n<i&&r.fillRect(s,e+n,this.smuflMetrics.stemThickness,i-n)}}finally{a?.[Symbol.dispose]?.()}}calculateOverflows(t,e){super.calculateOverflows(t,e),this.bar.isEmpty||this.rhythmMode!==C.Hidden&&this.calculateBeamingOverflows(t,e)}},yu=class extends Sh{get staffId(){return wu.StaffId}constructor(t){super(t),this.hideOnPercussionTrack=!0}canCreate(t,e){return e.showTablature&&e.tuning.length>0&&super.canCreate(t,e)}create(t,e){return new wu(t,e)}},ku=class{vertical;createLayout;constructor(t,e){this.vertical=t,this.createLayout=e}},Su=class{supportsWorkers;createCanvas;constructor(t,e){this.supportsWorkers=t,this.createCanvas=e}},Bu=class t{static highDpiFactor=1;static cM=void 0;static get globalThis(){if(void 0===t.cM){try{t.cM=globalThis}catch{}void 0===t.cM&&(t.cM=self),void 0===t.cM&&(t.cM=global),void 0===t.cM&&(t.cM=window),void 0===t.cM&&(t.cM=Function("return this")())}return t.cM}static getGlobalWorkerScope(){return t.globalThis}static webPlatform=t.lM();static isWebPackBundled=t.uM();static isViteBundled=t.dM();static scriptFile=t.fM();static fontDirectory=t.pM();static get isRunningInWorker(){return"WorkerGlobalScope"in t.globalThis}static get isRunningInAudioWorklet(){return"AudioWorkletGlobalScope"in t.globalThis}static fM(){if(!t.isRunningInWorker&&t.globalThis.ALPHATAB_ROOT){let e=t.globalThis.ALPHATAB_ROOT;return e=t.ensureFullUrl(e),e=t.bM(e),e}try{const t={}.url;if(t&&-1===t.indexOf("file://"))return t}catch{}return"document"in t.globalThis&&document.currentScript&&document.currentScript instanceof HTMLScriptElement?document.currentScript.src:null}static ensureFullUrl(e){if(!e)return"";if(!e.startsWith("http")&&!e.startsWith("https")&&!e.startsWith("file")){let s="";const i=t.globalThis.location;if(s+=i.protocol?.toString(),s+="//".toString(),i.hostname&&(s+=i.hostname?.toString()),i.port&&(s+=":".toString(),s+=i.port?.toString()),!e.startsWith("/")){const t=i.pathname.split("/").slice(0,-1).join("/");t.length>0&&(t.startsWith("/")||(s+="/".toString()),s+=t?.toString())}return e.startsWith("/")||(s+="/".toString()),s+=e?.toString(),s}return e}static bM(t){return t&&!t.endsWith(".js")&&(t.endsWith("/")||(t+="/"),t+="alphaTab.js"),t}static pM(){if(!t.isRunningInWorker&&t.globalThis.ALPHATAB_FONT)return t.ensureFullUrl(t.globalThis.ALPHATAB_FONT);const e=t.scriptFile;if(e){const t=e.lastIndexOf(String.fromCharCode(47));if(t>=0)return`${e.substr(0,t)}/font/`}return null}static mM(){if(!t.isRunningInWorker&&t.globalThis&&"jQuery"in t.globalThis){const e=t.globalThis.jQuery,s=new dh;e.fn.alphaTab=function(t){const e=Array.prototype.slice.call(arguments,1);return 1===this.length?s.exec(this[0],t,e):this.each((i,n)=>{s.exec(n,t,e)})},e.alphaTab={restore:dh.restore},e.fn.alphaTab.fn=s}}static renderEngines=t.gM();static layoutEngines=t.wM();static staveProfiles=t.yM();static getRenderEngineFactory(e){return e&&t.renderEngines.has(e)?t.renderEngines.get(e):t.renderEngines.get("default")}static getLayoutEngineFactory(e){return e&&t.layoutEngines.has(e)?t.layoutEngines.get(e):t.layoutEngines.get(Xs.Page)}static buildImporters(){return[new ks,new Is,new Ls,new Us,new ws,new $e]}static gM(){const e=new Map;return e.set("svg",new Su(!0,()=>new mh)),e.set("default",e.get("svg")),e.set("skia",new Su(!0,()=>new ph)),t.kM(e),e}static enableAlphaSkia(t,e){ph.enable(t,e)}static registerAlphaSkiaCustomFont(t){return ph.registerFont(t)}static kM(t){t.set("html5",new Su(!1,()=>new Ta))}static defaultRenderers=[new hu([{effect:new cc,mode:kh.SharedTop},{effect:new pc,mode:kh.SharedTop},{effect:new fo,mode:kh.SharedTop},{effect:new Hh,mode:kh.SharedTop},{effect:new so,mode:kh.SharedTop},{effect:new lc,mode:kh.SharedTop},{effect:new Eh,mode:kh.SharedTop},{effect:new Lh,mode:kh.SharedTop},{effect:new Mh,mode:kh.SharedTop,order:1e3}]),new eu([{effect:new Ah,mode:kh.SharedTop},{effect:new qh,mode:kh.SharedTop},{effect:new Ph,mode:kh.SharedTop},{effect:new bo,mode:kh.SharedTop},{effect:new To,mode:kh.SharedTop},{effect:new mc,mode:kh.SharedTop},{effect:new gc,mode:kh.OwnedTop},{effect:new tc,mode:kh.OwnedTop},{effect:new dc,mode:kh.OwnedTop},{effect:new ko(!0),mode:kh.OwnedTop},{effect:new oo,mode:kh.OwnedTop},{effect:new hc,mode:kh.OwnedTop},{effect:new wc,mode:kh.OwnedTop},{effect:new sc,mode:kh.OwnedTop},{effect:new yc,mode:kh.OwnedTop},{effect:new ic(!1),mode:kh.OwnedTop},{effect:new jh,mode:kh.OwnedTop,shouldCreate:t=>!t.showTablature},{effect:new co,mode:kh.OwnedTop,shouldCreate:t=>!t.showTablature},{effect:new xo,mode:kh.OwnedTop,shouldCreate:t=>!t.showTablature},{effect:new Bo,mode:kh.OwnedTop,shouldCreate:t=>!t.showTablature},{effect:new no(Wt.Finger),mode:kh.OwnedTop},{effect:new no(Wt.Thumb),mode:kh.OwnedBottom},{effect:new Rh,mode:kh.SharedBottom},{effect:new Uh,mode:kh.SharedBottom},{effect:new rc,mode:kh.SharedBottom}]),new Bl([{effect:new wo,mode:kh.OwnedTop,order:1e3}]),new yu([{effect:new uo,mode:kh.SharedTop},{effect:new ac,mode:kh.OwnedTop},{effect:new dc,mode:kh.OwnedTop},{effect:new wc,mode:kh.OwnedTop},{effect:new sc,mode:kh.OwnedTop},{effect:new yc,mode:kh.OwnedTop},{effect:new ic(!0),mode:kh.OwnedTop},{effect:new hc,mode:kh.OwnedTop},{effect:new jh,mode:kh.OwnedTop},{effect:new ao(B.Natural),mode:kh.OwnedTop},{effect:new ao(B.Artificial),mode:kh.OwnedTop},{effect:new ao(B.Pinch),mode:kh.OwnedTop},{effect:new ao(B.Tap),mode:kh.OwnedTop},{effect:new ao(B.Semi),mode:kh.OwnedTop},{effect:new ao(B.Feedback),mode:kh.OwnedTop},{effect:new co,mode:kh.OwnedTop},{effect:new eo,mode:kh.OwnedTop},{effect:new So,mode:kh.OwnedTop},{effect:new xo,mode:kh.OwnedTop},{effect:new Bo,mode:kh.OwnedTop},{effect:new oo,mode:kh.OwnedTop},{effect:new no(Wt.Finger),mode:kh.OwnedTop,shouldCreate:t=>!t.showStandardNotation},{effect:new no(Wt.Thumb),mode:kh.OwnedBottom,shouldCreate:t=>!t.showStandardNotation}])];static yM(){const t=new Map;return t.set(ci.Default,new Set([au.StaffId,tu.StaffId,Sl.StaffId,wu.StaffId])),t.set(ci.ScoreTab,new Set([au.StaffId,tu.StaffId,Sl.StaffId,wu.StaffId])),t.set(ci.Score,new Set([tu.StaffId])),t.set(ci.Tab,new Set([wu.StaffId])),t.set(ci.TabMixed,new Set([wu.StaffId])),t}static wM(){const t=new Map;return t.set(Xs.Page,new ku(!0,t=>new Ic(t))),t.set(Xs.Horizontal,new ku(!1,t=>new Rc(t))),t.set(Xs.Parchment,new ku(!0,t=>new Gc(t))),t}static initializeMain(e,s){t.isRunningInWorker||t.isRunningInAudioWorklet||(t.webPlatform!==Wi.Browser&&t.webPlatform!==Wi.BrowserModule||(t.mM(),t.highDpiFactor=window.devicePixelRatio),Ba.createAlphaTabWebWorker=t=>e(t,"alphaTab Renderer"),Ba.createAlphaSynthWebWorker=t=>e(t,"alphaSynth Worker"),Ba.createAlphaSynthAudioWorklet=s)}static get alphaTabWorker(){return t.globalThis.Worker}static get alphaTabUrl(){return t.globalThis.URL}static initializeWorker(){if(!t.isRunningInWorker)throw new a(r.General,"Not running in worker, cannot run worker initialization");yh.init(),wh.init()}static initializeAudioWorklet(){if(!t.isRunningInAudioWorklet)throw new a(r.General,"Not running in audio worklet, cannot run worklet initialization");_a.init()}static uM(){try{if("function"==typeof __webpack_require__)return"boolean"!=typeof __ALPHATAB_WEBPACK__&&O.warning("WebPack","Detected bundling with WebPack but @coderline/alphatab-webpack was not used! To ensure alphaTab works as expected use our bundler plugins. Learn more at https://www.alphatab.net/docs/getting-started/installation-webpack"),!0}catch{}return!1}static dM(){try{if("string"==typeof __BASE__)return"boolean"!=typeof __ALPHATAB_VITE__&&O.warning("Vite","Detected bundling with Vite but @coderline/alphatab-vite was not used! To ensure alphaTab works as expected use our bundler plugins. Learn more at https://www.alphatab.net/docs/getting-started/installation-vite"),!0}catch{}return!1}static lM(){if(!(void 0!==t.globalThis.Window&&t.globalThis instanceof t.globalThis.Window))try{if("[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0))return Wi.NodeJs}catch{}try{const t={}.url;if(t&&"string"==typeof t&&!t.startsWith("file://"))return Wi.BrowserModule}catch{}return Wi.Browser}static printEnvironmentInfo(e=!0){const s=e?t=>{O.log.debug("VersionInfo",t)}:t=>{O.debug("VersionInfo",t)};h.print(s),s(`High DPI: ${t.highDpiFactor}`),t.SM(s)}static SM(e){e(`Platform: ${Wi[t.webPlatform]}`),e(`WebPack: ${t.isWebPackBundled}`),e(`Vite: ${t.isViteBundled}`),t.webPlatform!==Wi.NodeJs&&(e(`Browser: ${navigator.userAgent}`),e(`Window Size: ${window.outerWidth}x${window.outerHeight}`),e(`Screen Size: ${window.screen.width}x${window.screen.height}`))}static prepareForPostMessage(e){if(!e)return e;if("object"==typeof e){const s=e.BM;if(s)return t.prepareForPostMessage(s)}return e}static quoteJsonString(t){return JSON.stringify(t)}static sortDescending(t){t.sort((t,e)=>e-t)}},_u=function(t){return t[t.EmbeddedOpenType=0]="EmbeddedOpenType",t[t.Woff=1]="Woff",t[t.Woff2=2]="Woff2",t[t.OpenType=3]="OpenType",t[t.TrueType=4]="TrueType",t[t.Svg=5]="Svg",t}({}),xu=class{scriptFile=null;fontDirectory=null;smuflFontSources=null;static buildDefaultSmuflFontSources(t){const e=new Map,s=t??"";return e.set(2,`${s}Bravura.woff2`),e.set(1,`${s}Bravura.woff`),e.set(3,`${s}Bravura.otf`),e}file=null;tex=!1;tracks=null;enableLazyLoading=!0;engine="default";logLevel=W.Info;useWorkers=!0;includeNoteBounds=!1;constructor(){this.scriptFile=Bu.scriptFile,this.fontDirectory=Bu.fontDirectory}},Tu=s({AlphaTexAccidentalMode:()=>re,AlphaTexDiagnosticBag:()=>ne,AlphaTexDiagnosticCode:()=>ie,AlphaTexDiagnosticsSeverity:()=>se,AlphaTexLexer:()=>ue,AlphaTexNodeType:()=>ee,AlphaTexParseMode:()=>de,AlphaTexParser:()=>fe,AlphaTexStaffNoteKind:()=>he,AlphaTexVoiceMode:()=>ae,ArgumentListParseTypesMode:()=>oe}),Mu=s({AlphaTexErrorWithDiagnostics:()=>Ge,AlphaTexImporter:()=>$e,ScoreImporter:()=>Re,ScoreLoader:()=>Ai,UnsupportedFormatError:()=>Oe,alphaTex:()=>Tu}),vu=s({ByteBuffer:()=>Ie,IOHelper:()=>le}),Nu=class{data;settings;init(t,e){this.data=t,this.settings=e}export(t,e=null){const s=Ie.withCapacity(1024);return this.init(s,e??new Fi),this.writeScore(t),s.toArray()}},Pu=class{tex="";isStartOfLine=!0;indentString="";currentIndent=0;indent(){this.indentString.length>0&&this.currentIndent++}outdent(){this.indentString.length>0&&this.currentIndent--}_M(){if(this.isStartOfLine&&this.indentString.length>0)for(let t=0;t<this.currentIndent;t++)this.tex+=this.indentString;this.isStartOfLine=!1}write(t){this._M(),this.tex+=t,this.isStartOfLine=!1}writeString(t){this._M(),this.tex+=Bu.quoteJsonString(t)}writeLine(t){this._M(),void 0!==t&&(this.tex+=t),this.indentString.length>0?this.tex+="\n":this.tex.endsWith(" ")||(this.tex+=" "),this.isStartOfLine=!0}},Cu=class{xM;TM=!1;get tex(){return this.xM.tex}constructor(t){const e=new Pu;this.TM=t.exporter.comments,e.indentString=t.exporter.indent>0?" ".repeat(t.exporter.indent):"",this.xM=e}writeScoreNode(t){this.MM(t.leadingComments);for(const e of t.bars)this.vM(e);this.MM(t.trailingComments)}vM(t){this.MM(t.leadingComments),this.NM(t.metaData),this.xM.indent();for(const e of t.beats)this.PM(e);this.xM.outdent(),this.MM(t.trailingComments),this.CM(t.pipe,!0)}PM(t){this.MM(t.leadingComments),t.durationChange&&this.EM(t.durationChange),t.rest?this.FM(t.rest):t.notes&&this.AM(t.notes),this.CM(t.durationDot,!1),this.FM(t.durationValue),this.CM(t.beatMultiplier,!1),this.FM(t.beatMultiplierValue),t.beatEffects&&this.DM(t.beatEffects,!1),this.MM(t.trailingComments),this.xM.writeLine()}AM(t){this.MM(t.leadingComments),this.CM(t.openParenthesis,!1);let e=!0;for(const s of t.notes)e||this.xM.write(" "),this.LM(s),e=!1;this.CM(t.closeParenthesis,!1),this.MM(t.trailingComments)}LM(t){this.MM(t.leadingComments),this.FM(t.noteValue),this.CM(t.noteStringDot,!1),this.FM(t.noteString),t.noteEffects&&this.DM(t.noteEffects,!1),this.MM(t.trailingComments)}EM(t){this.MM(t.leadingComments),this.CM(t.colon,!1),this.FM(t.value),t.properties&&(this.xM.write(" "),this.DM(t.properties,!1)),this.MM(t.trailingComments),this.xM.write(" ")}NM(t){for(const e of t)this.WM(e)}RM=0;OM=0;_x=0;WM(t){switch(t.tag.tag.text){case"track":this.OM>0&&this.xM.outdent(),this.RM>0&&this.xM.outdent();break;case"staff":this.OM>0&&this.xM.outdent();break;case"voice":this._x>0&&this.xM.outdent()}this.MM(t.leadingComments),this.CM(t.tag.prefix,!1),this.FM(t.tag.tag);let e=!0;switch(t.propertiesBeforeArguments?(t.properties&&(this.xM.write(" "),this.DM(t.properties,!1)),t.arguments&&(this.xM.write(" "),this.IM(t.arguments))):(t.arguments&&(this.xM.write(" "),this.IM(t.arguments)),t.properties&&(this.xM.write(" "),this.DM(t.properties,!0),e=!1)),t.trailingComments&&(this.xM.write(" "),this.MM(t.trailingComments)),t.tag.tag.text){case"track":this.RM++,this.OM=0,this._x=0,this.xM.indent();break;case"staff":this.OM++,this._x=0,this.xM.indent();break;case"voice":this._x++,this.xM.indent()}e&&this.xM.writeLine()}DM(t,e){this.MM(t.leadingComments),this.CM(t.openBrace,e),e&&this.xM.indent();let s=!0;for(const i of t.properties)s||e||this.xM.write(" "),this.GM(i),s=!1,e&&this.xM.writeLine();e&&this.xM.outdent(),this.CM(t.closeBrace,e),this.MM(t.trailingComments)}GM(t){this.MM(t.leadingComments),this.FM(t.property),t.arguments&&(this.xM.write(" "),this.IM(t.arguments)),this.MM(t.trailingComments)}IM(t){this.MM(t.leadingComments),this.CM(t.openParenthesis,!1);let e=!0;for(const s of t.arguments)e||this.xM.write(" "),this.FM(s),e=!1;this.CM(t.closeParenthesis,!1),this.MM(t.trailingComments)}FM(t){if(t){switch(this.MM(t.leadingComments),t.nodeType){case ee.Ident:this.xM.write(t.text);break;case ee.Arguments:this.IM(t);break;case ee.Number:this.xM.write(t.value.toString());break;case ee.String:this.xM.writeString(t.text)}this.MM(t.trailingComments)}}CM(t,e){if(t){switch(this.MM(t.leadingComments),t.nodeType){case ee.Dot:this.xM.write(".");break;case ee.Backslash:this.xM.write("\\");break;case ee.DoubleBackslash:this.xM.write("\\\\");break;case ee.Pipe:this.xM.write("|");break;case ee.LBrace:this.xM.write("{");break;case ee.RBrace:this.xM.write("}");break;case ee.LParen:this.xM.write("(");break;case ee.RParen:this.xM.write(")");break;case ee.Colon:this.xM.write(":");break;case ee.Asterisk:this.xM.write("*")}this.MM(t.trailingComments),e&&this.xM.writeLine()}}MM(t){if(this.TM&&t)for(const e of t){let t=e.text;t.startsWith(" ")||(t=` ${t}`),e.multiLine?(t.endsWith(" ")||(t+=" "),this.xM.write(`/*${t}*/`)):this.xM.writeLine(`//${t}`)}}},Eu=class extends Nu{Ti=Ae.instance;get name(){return"alphaTex"}exportToString(t,e=null){return this.settings=e??new Fi,this.scoreToAlphaTexString(t)}writeScore(t){const e=le.stringToBytes(this.scoreToAlphaTexString(t));this.data.write(e,0,e.length)}scoreToAlphaTexString(t){const e=new Cu(this.settings);return e.writeScoreNode(this.We(t)),e.tex}We(t){const e={nodeType:ee.Score,bars:[]};for(const s of t.tracks)this.HM(e,s);return 0===e.bars.length?e.bars.push({nodeType:ee.Bar,metaData:this.Ti.buildScoreMetaDataNodes(t),beats:[]}):e.bars[0].metaData=this.Ti.buildScoreMetaDataNodes(t).concat(e.bars[0].metaData),e.bars.push({nodeType:ee.Bar,metaData:this.Ti.buildSyncPointNodes(t),beats:[]}),e}HM(t,e){for(const s of e.staves)this.IS(t,s)}IS(t,e){const s=Math.max(...e.filledVoices)+1;if(0===e.bars.length){const s={nodeType:ee.Bar,metaData:this.Ti.buildBarMetaDataNodes(e,void 0,0,!1),beats:[],pipe:void 0};t.bars.push(s)}else for(let i=0;i<s;i++)this.$M(t,i,e,s>1)}$M(t,e,s,i){for(const n of s.bars)this.Oe(t,n,e,i)}Oe(t,e,s,i){const n={nodeType:ee.Bar,metaData:this.Ti.buildBarMetaDataNodes(e.staff,e,s,i),beats:[],pipe:void 0};if(e.isEmpty)n.trailingComments=[{multiLine:!1,text:`Bar ${e.index+1} / Voice ${s+1} no contents`}];else{const t=e.voices[s];if(t.isEmpty)n.trailingComments=[{multiLine:!1,text:`Bar ${e.index+1} / Voice ${s+1} no contents`}];else{for(const e of t.beats)n.beats.push(this.$e(e));n.beats.length>0&&(n.beats[0].leadingComments??=[],n.beats[0].leadingComments.unshift({multiLine:!1,text:`Bar ${e.index+1} / Voice ${s+1} contents`}))}}e.index<e.staff.bars.length-1&&(n.pipe={nodeType:ee.Pipe}),t.bars.push(n)}$e(t){const e={nodeType:ee.Beat,durationChange:void 0,notes:void 0,rest:void 0,beatEffects:void 0};return t.isRest?e.rest={nodeType:ee.Ident,text:"r"}:e.notes=this.dB(t.notes),e.durationDot={nodeType:ee.Dot},e.durationValue={nodeType:ee.Number,value:t.duration},e.beatEffects=this.Ri(t),e}Ri(t){const e=this.Ti.buildBeatEffects(t);return e.length>0?{nodeType:ee.Props,openBrace:{nodeType:ee.LBrace},properties:e,closeBrace:{nodeType:ee.RBrace}}:void 0}dB(t){const e={nodeType:ee.NoteList,openParenthesis:void 0,notes:[],closeParenthesis:void 0};(0===t.length||t.length>1)&&(e.openParenthesis={nodeType:ee.LParen},e.closeParenthesis={nodeType:ee.RParen});for(const s of t)e.notes.push(this.qe(s));return e}qe(t){const e={nodeType:ee.Note,noteValue:{nodeType:ee.Ident,text:""}};if(t.isPercussion)e.noteValue={nodeType:ee.String,text:Nt.getArticulationName(t)};else if(t.isPiano)e.noteValue={nodeType:ee.Ident,text:Me.getTextForTuning(t.realValueWithoutHarmonic,!0)};else{if(!t.isStringed)throw new Error("What kind of note");{e.noteValue={nodeType:ee.Number,value:t.fret},e.noteStringDot={nodeType:ee.Dot};const s=t.beat.voice.bar.staff.tuning.length-t.string+1;e.noteString={nodeType:ee.Number,value:s}}}return e.noteEffects=this.Oi(t),e}Oi(t){const e=this.Ti.buildNoteEffects(t);return e.length>0?{nodeType:ee.Props,openBrace:{nodeType:ee.LBrace},properties:e,closeBrace:{nodeType:ee.RBrace}}:void 0}},Fu=class{icon=10;instrumentSetName;instrumentSetType;constructor(t,e,s=null){if(this.icon=t,this.instrumentSetName=e,s)this.instrumentSetType=s;else{const t=e.split(" ");t[0]=t[0].substr(0,1).toLowerCase()+t[0].substr(1),this.instrumentSetType=t.join("")}}},Au=class t{lineCount=0;name="";type="";elements=[];static create(e,s,i,n){const r=new t;return r.name=e,r.type=s,r.lineCount=i,r.elements=n,r}},Du=class{name;type;soundbankName;articulations;constructor(t,e,s,i){this.name=t,this.type=e,this.soundbankName=s,this.articulations=i}},Lu=class t{name;staffLine;noteHeads;techniqueSymbol;techniqueSymbolPlacement;inputMidiNumbers;outputMidiNumber;outputRSESound;constructor(t,e,s,i,n,r,a,h){this.name=t,this.staffLine=e,this.noteHeads=s,this.techniqueSymbol=i,this.techniqueSymbolPlacement=n,this.inputMidiNumbers=r,this.outputMidiNumber=a,this.outputRSESound=h}static template(e,s,i){return new t(e,0,[],xt.None,Mt.Outside,s,0,i)}},Wu=class t{static VM=new Map([[0,new Fu(10,"Acoustic Piano")],[1,new Fu(10,"Acoustic Piano")],[2,new Fu(10,"Electric Piano")],[3,new Fu(10,"Acoustic Piano")],[4,new Fu(10,"Electric Piano")],[5,new Fu(10,"Electric Piano")],[6,new Fu(10,"Harpsichord")],[7,new Fu(10,"Harpsichord")],[8,new Fu(17,"Celesta")],[9,new Fu(17,"Vibraphone")],[10,new Fu(17,"Vibraphone")],[11,new Fu(17,"Vibraphone")],[12,new Fu(17,"Xylophone")],[13,new Fu(17,"Xylophone")],[14,new Fu(17,"Vibraphone")],[15,new Fu(8,"Banjo")],[16,new Fu(10,"Electric Organ")],[17,new Fu(10,"Electric Organ")],[18,new Fu(10,"Electric Organ")],[19,new Fu(10,"Electric Organ")],[20,new Fu(10,"Electric Organ")],[21,new Fu(10,"Electric Organ")],[22,new Fu(15,"Recorder")],[23,new Fu(10,"Electric Organ")],[24,new Fu(23,"Nylon Guitar")],[25,new Fu(1,"Steel Guitar")],[26,new Fu(1,"Electric Guitar")],[27,new Fu(4,"Electric Guitar")],[28,new Fu(4,"Electric Guitar")],[29,new Fu(4,"Electric Guitar")],[30,new Fu(1,"Electric Guitar")],[31,new Fu(1,"Electric Guitar")],[32,new Fu(5,"Acoustic Bass")],[33,new Fu(5,"Electric Bass")],[34,new Fu(5,"Electric Bass")],[35,new Fu(5,"Acoustic Bass")],[36,new Fu(5,"Electric Bass")],[37,new Fu(5,"Electric Bass")],[38,new Fu(12,"Synth Bass")],[39,new Fu(12,"Synth Bass")],[40,new Fu(11,"Violin")],[41,new Fu(11,"Viola")],[42,new Fu(11,"Cello")],[43,new Fu(11,"Contrabass")],[44,new Fu(11,"Violin")],[45,new Fu(11,"Violin")],[46,new Fu(10,"Harp")],[47,new Fu(20,"Timpani")],[48,new Fu(11,"Violin")],[49,new Fu(11,"Violin")],[50,new Fu(11,"Violin")],[51,new Fu(11,"Violin")],[52,new Fu(16,"Voice")],[53,new Fu(16,"Voice")],[54,new Fu(16,"Voice")],[55,new Fu(12,"Pad Synthesizer")],[56,new Fu(13,"Trumpet")],[57,new Fu(13,"Trombone")],[58,new Fu(13,"Tuba")],[59,new Fu(13,"Trumpet")],[60,new Fu(13,"French Horn")],[61,new Fu(13,"Trumpet")],[62,new Fu(13,"Trumpet")],[63,new Fu(13,"Trumpet")],[64,new Fu(14,"Saxophone")],[65,new Fu(14,"Saxophone")],[66,new Fu(14,"Saxophone")],[67,new Fu(14,"Saxophone")],[68,new Fu(14,"Oboe")],[69,new Fu(14,"English Horn")],[70,new Fu(14,"Bassoon")],[71,new Fu(14,"Clarinet")],[72,new Fu(14,"Piccolo")],[73,new Fu(15,"Flute")],[74,new Fu(15,"Recorder")],[75,new Fu(15,"Flute")],[76,new Fu(15,"Recorder")],[77,new Fu(15,"Flute")],[78,new Fu(15,"Recorder")],[79,new Fu(15,"Flute")],[80,new Fu(12,"Lead Synthesizer")],[81,new Fu(12,"Lead Synthesizer")],[82,new Fu(12,"Lead Synthesizer")],[83,new Fu(12,"Lead Synthesizer")],[84,new Fu(12,"Lead Synthesizer")],[85,new Fu(12,"Lead Synthesizer")],[86,new Fu(12,"Lead Synthesizer")],[87,new Fu(12,"Lead Synthesizer")],[88,new Fu(12,"Pad Synthesizer")],[89,new Fu(12,"Pad Synthesizer")],[90,new Fu(12,"Pad Synthesizer")],[91,new Fu(12,"Pad Synthesizer")],[92,new Fu(12,"Pad Synthesizer")],[93,new Fu(12,"Pad Synthesizer")],[94,new Fu(12,"Pad Synthesizer")],[95,new Fu(12,"Pad Synthesizer")],[96,new Fu(21,"Pad Synthesizer")],[97,new Fu(21,"Pad Synthesizer")],[98,new Fu(21,"Pad Synthesizer")],[99,new Fu(21,"Pad Synthesizer")],[100,new Fu(21,"Lead Synthesizer")],[101,new Fu(21,"Lead Synthesizer")],[102,new Fu(21,"Lead Synthesizer")],[103,new Fu(21,"Trumpet")],[104,new Fu(4,"Banjo")],[105,new Fu(8,"Banjo")],[106,new Fu(7,"Ukulele")],[107,new Fu(8,"Banjo")],[108,new Fu(17,"Xylophone")],[109,new Fu(14,"Bassoon")],[110,new Fu(11,"Violin")],[111,new Fu(15,"Flute")],[112,new Fu(17,"Xylophone")],[113,new Fu(19,"Celesta")],[114,new Fu(17,"Vibraphone")],[115,new Fu(19,"Xylophone")],[116,new Fu(20,"Xylophone")],[117,new Fu(20,"Xylophone")],[118,new Fu(20,"Xylophone")],[119,new Fu(19,"Celesta")],[120,new Fu(21,"Steel Guitar")],[121,new Fu(21,"Recorder")],[122,new Fu(21,"Recorder")],[123,new Fu(21,"Recorder")],[124,new Fu(21,"Recorder")],[125,new Fu(21,"Recorder")],[126,new Fu(21,"Recorder")],[127,new Fu(21,"Timpani")]]);static zM=Au.create("Drums","drumKit",5,[new Du("Snare","snare","Master-Snare",[Lu.template("Snare (hit)",[38],"stick.hit.hit"),Lu.template("Snare (side stick)",[37],"stick.hit.sidestick"),Lu.template("Snare (rim shot)",[91],"stick.hit.rimshot")]),new Du("Charley","hiHat","Master-Hihat",[Lu.template("Hi-Hat (closed)",[42],"stick.hit.closed"),Lu.template("Hi-Hat (half)",[92],"stick.hit.half"),Lu.template("Hi-Hat (open)",[46],"stick.hit.open"),Lu.template("Pedal Hi-Hat (hit)",[44],"pedal.hit.pedal")]),new Du("Acoustic Kick Drum","kickDrum","AcousticKick-Percu",[Lu.template("Kick (hit)",[35],"pedal.hit.hit")]),new Du("Kick Drum","kickDrum","Master-Kick",[Lu.template("Kick (hit)",[36],"pedal.hit.hit")]),new Du("Tom Very High","tom","Master-Tom05",[Lu.template("High Floor Tom (hit)",[50],"stick.hit.hit")]),new Du("Tom High","tom","Master-Tom04",[Lu.template("High Tom (hit)",[48],"stick.hit.hit")]),new Du("Tom Medium","tom","Master-Tom03",[Lu.template("Mid Tom (hit)",[47],"stick.hit.hit")]),new Du("Tom Low","tom","Master-Tom02",[Lu.template("Low Tom (hit)",[45],"stick.hit.hit")]),new Du("Tom Very Low","tom","Master-Tom01",[Lu.template("Very Low Tom (hit)",[43],"stick.hit.hit")]),new Du("Ride","ride","Master-Ride",[Lu.template("Ride (edge)",[93],"stick.hit.edge"),Lu.template("Ride (middle)",[51],"stick.hit.mid"),Lu.template("Ride (bell)",[53],"stick.hit.bell"),Lu.template("Ride (choke)",[94],"stick.hit.choke")]),new Du("Splash","splash","Master-Splash",[Lu.template("Splash (hit)",[55],"stick.hit.hit"),Lu.template("Splash (choke)",[95],"stick.hit.choke")]),new Du("China","china","Master-China",[Lu.template("China (hit)",[52],"stick.hit.hit"),Lu.template("China (choke)",[96],"stick.hit.choke")]),new Du("Crash High","crash","Master-Crash02",[Lu.template("Crash high (hit)",[49],"stick.hit.hit"),Lu.template("Crash high (choke)",[97],"stick.hit.choke")]),new Du("Crash Medium","crash","Master-Crash01",[Lu.template("Crash medium (hit)",[57],"stick.hit.hit"),Lu.template("Crash medium (choke)",[98],"stick.hit.choke")]),new Du("Cowbell Low","cowbell","CowbellBig-Percu",[Lu.template("Cowbell low (hit)",[99],"stick.hit.hit"),Lu.template("Cowbell low (tip)",[100],"stick.hit.tip")]),new Du("Cowbell Medium","cowbell","CowbellMid-Percu",[Lu.template("Cowbell medium (hit)",[56],"stick.hit.hit"),Lu.template("Cowbell medium (tip)",[101],"stick.hit.tip")]),new Du("Cowbell High","cowbell","CowbellSmall-Percu",[Lu.template("Cowbell high (hit)",[102],"stick.hit.hit"),Lu.template("Cowbell high (tip)",[103],"stick.hit.tip")]),new Du("Woodblock Low","woodblock","WoodblockLow-Percu",[Lu.template("Woodblock low (hit)",[77],"stick.hit.hit")]),new Du("Woodblock High","woodblock","WoodblockHigh-Percu",[Lu.template("Woodblock high (hit)",[76],"stick.hit.hit")]),new Du("Bongo High","bongo","BongoHigh-Percu",[Lu.template("Bongo High (hit)",[60],"hand.hit.hit"),Lu.template("Bongo High (mute)",[104],"hand.hit.mute"),Lu.template("Bongo High (slap)",[105],"hand.hit.slap")]),new Du("Bongo Low","bongo","BongoLow-Percu",[Lu.template("Bongo Low (hit)",[61],"hand.hit.hit"),Lu.template("Bongo Low (mute)",[106],"hand.hit.mute"),Lu.template("Bongo Low (slap)",[107],"hand.hit.slap")]),new Du("Timbale Low","timbale","TimbaleLow-Percu",[Lu.template("Timbale low (hit)",[66],"stick.hit.hit")]),new Du("Timbale High","timbale","TimbaleHigh-Percu",[Lu.template("Timbale high (hit)",[65],"stick.hit.hit")]),new Du("Agogo Low","agogo","AgogoLow-Percu",[Lu.template("Agogo low (hit)",[68],"stick.hit.hit")]),new Du("Agogo High","agogo","AgogoHigh-Percu",[Lu.template("Agogo high (hit)",[67],"stick.hit.hit")]),new Du("Conga Low","conga","CongaLow-Percu",[Lu.template("Conga low (hit)",[64],"hand.hit.hit"),Lu.template("Conga low (slap)",[108],"hand.hit.slap"),Lu.template("Conga low (mute)",[109],"hand.hit.mute")]),new Du("Conga High","conga","CongaHigh-Percu",[Lu.template("Conga high (hit)",[63],"hand.hit.hit"),Lu.template("Conga high (slap)",[110],"hand.hit.slap"),Lu.template("Conga high (mute)",[62],"hand.hit.mute")]),new Du("Whistle Low","whistle","WhistleLow-Percu",[Lu.template("Whistle low (hit)",[72],"blow.hit.hit")]),new Du("Whistle High","whistle","WhistleHigh-Percu",[Lu.template("Whistle high (hit)",[71],"blow.hit.hit")]),new Du("Guiro","guiro","Guiro-Percu",[Lu.template("Guiro (hit)",[73],"stick.hit.hit"),Lu.template("Guiro (scrap-return)",[74],"stick.scrape.return")]),new Du("Surdo","surdo","Surdo-Percu",[Lu.template("Surdo (hit)",[86],"brush.hit.hit"),Lu.template("Surdo (mute)",[87],"brush.hit.mute")]),new Du("Tambourine","tambourine","Tambourine-Percu",[Lu.template("Tambourine (hit)",[54],"hand.hit.hit"),Lu.template("Tambourine (return)",[111],"hand.hit.return"),Lu.template("Tambourine (roll)",[112],"hand.hit.roll"),Lu.template("Tambourine (hand)",[113],"hand.hit.handhit")]),new Du("Cuica","cuica","Cuica-Percu",[Lu.template("Cuica (open)",[79],"hand.hit.hit"),Lu.template("Cuica (mute)",[78],"hand.hit.mute")]),new Du("Vibraslap","vibraslap","Vibraslap-Percu",[Lu.template("Vibraslap (hit)",[58],"hand.hit.hit")]),new Du("Triangle","triangle","Triangle-Percu",[Lu.template("Triangle (hit)",[81],"stick.hit.hit"),Lu.template("Triangle (mute)",[80],"stick.hit.mute")]),new Du("Grancassa","grancassa","Grancassa-Percu",[Lu.template("Grancassa (hit)",[114],"mallet.hit.hit")]),new Du("Piatti","piatti","Piatti-Percu",[Lu.template("Piatti (hit)",[115],"hand.hit.hit"),Lu.template("Piatti (hand)",[116],"hand.hit.hit")]),new Du("Cabasa","cabasa","Cabasa-Percu",[Lu.template("Cabasa (hit)",[69],"hand.hit.hit"),Lu.template("Cabasa (return)",[117],"hand.hit.return")]),new Du("Castanets","castanets","Castanets-Percu",[Lu.template("Castanets (hit)",[85],"hand.hit.hit")]),new Du("Claves","claves","Claves-Percu",[Lu.template("Claves (hit)",[75],"stick.hit.hit")]),new Du("Left Maraca","maraca","Maracas-Percu",[Lu.template("Left Maraca (hit)",[70],"hand.hit.hit"),Lu.template("Left Maraca (return)",[118],"hand.hit.return")]),new Du("Right Maraca","maraca","Maracas-Percu",[Lu.template("Right Maraca (hit)",[119],"hand.hit.hit"),Lu.template("Right Maraca (return)",[120],"hand.hit.return")]),new Du("Shaker","shaker","ShakerStudio-Percu",[Lu.template("Shaker (hit)",[82],"hand.hit.hit"),Lu.template("Shaker (return)",[122],"hand.hit.return")]),new Du("Bell Tree","bellTree","BellTree-Percu",[Lu.template("Bell Tree (hit)",[84],"stick.hit.hit"),Lu.template("Bell Tree (return)",[123],"stick.hit.return")]),new Du("Jingle Bell","jingleBell","JingleBell-Percu",[Lu.template("Jingle Bell (hit)",[83],"stick.hit.hit")]),new Du("Tinkle Bell","jingleBell","JingleBell-Percu",[Lu.template("Tinkle Bell (hit)",[83],"stick.hit.hit")]),new Du("Golpe","unpitched","Golpe-Percu",[Lu.template("Golpe (thumb)",[124],"thumb.hit.body"),Lu.template("Golpe (finger)",[125],"finger4.hit.body")]),new Du("Hand Clap","handClap","GroupHandClap-Percu",[Lu.template("Hand Clap (hit)",[39],"hand.hit.hit")]),new Du("Electric Snare","snare","ElectricSnare-Percu",[Lu.template("Electric Snare (hit)",[40],"stick.hit.hit")]),new Du("Sticks","snare","Stick-Percu",[Lu.template("Snare (side stick)",[31],"stick.hit.sidestick")]),new Du("Very Low Floor Tom","tom","LowFloorTom-Percu",[Lu.template("Low Floor Tom (hit)",[41],"stick.hit.hit")]),new Du("Ride Cymbal 2","ride","Ride-Percu",[Lu.template("Ride (edge)",[59],"stick.hit.edge"),Lu.template("Ride (middle)",[126],"stick.hit.mid"),Lu.template("Ride (bell)",[127],"stick.hit.bell"),Lu.template("Ride (choke)",[29],"stick.hit.choke")]),new Du("Reverse Cymbal","crash","Reverse-Cymbal",[Lu.template("Reverse Cymbal (hit)",[30],"stick.hit.hit")]),new Du("Metronome","snare","Metronome-Percu",[Lu.template("Metronome (hit)",[33],"stick.hit.sidestick"),Lu.template("Metronome (bell)",[34],"stick.hit.hit")])]);static UM=void 0;static XM=void 0;static jM(){const e=t.zM,s=new Map,i=new Map;for(const t of e.elements)for(const e of t.articulations)for(const n of e.inputMidiNumbers){const r=`${t.name}.${n}`;s.set(r,t),i.set(r,e)}return t.UM=s,t.XM=i,s}static getIconId(e){return 9===e.primaryChannel?18:t.VM.has(e.program)?t.VM.get(e.program).icon:1}static buildInstrumentSet(e){return e.percussionArticulations.length>0||e.isPercussion?t.JM(e):t.qM(e)}static YM=new Du("Pitched","pitched","",[new Lu("",0,[xt.NoteheadBlack,xt.NoteheadHalf,xt.NoteheadWhole],xt.None,Mt.Outside,[],0,"")]);static qM(e){const s=new Au;s.lineCount=e.staves[0].standardNotationLineCount;const i=t.VM.has(e.playbackInfo.program)?t.VM.get(e.playbackInfo.program):t.VM.get(0);s.name=i.instrumentSetName,s.type=i.instrumentSetType;const n=new Du(t.YM.name,t.YM.type,t.YM.soundbankName,[t.YM.articulations[0]]);return s.elements.push(n),s}static JM(e){t.UM||t.jM();const s=new Au;s.lineCount=e.staves[0].standardNotationLineCount,s.name="Drums",s.type="drumKit";const i=e.percussionArticulations.length>0?e.percussionArticulations:Array.from(Nt.instrumentArticulations.values());let n;for(const e of i){const i=new Lu(e.elementType,e.staffLine,[e.noteHeadDefault,e.noteHeadHalf,e.noteHeadWhole],e.techniqueSymbol,e.techniqueSymbolPlacement,[e.id],e.outputMidiNumber,""),r=e.uniqueId;if(t.XM.has(r)){const e=t.XM.get(r);i.inputMidiNumbers=e.inputMidiNumbers,i.name=e.name,i.outputRSESound=e.outputRSESound}if(t.UM.has(r)){const i=t.UM.get(r);n&&n.name===e.elementType||(n=new Du(i.name,i.type,i.soundbankName,[]),s.elements.push(n))}else n&&n.name===e.elementType||(n=new Du(e.elementType,e.elementType,"",[]),s.elements.push(n));n.articulations.push(i)}return s}},Ru=class t{static Da=44100;KM=new Map;writeXml(t){const e=new is;return this.KM=new Map,this.QM(e,t),e.toFormattedString("",!0)}QM(t,e){const s=t.addElement("GPIF");s.addElement("GPVersion").innerText="8.1.3";const i=s.addElement("GPRevision");i.attributes.set("required","12024"),i.attributes.set("recommended","13000"),i.innerText="13007";const n=s.addElement("Encoding");n.addElement("EncodingDescription").innerText="GP8";const r=new Ze;r.nodeType=Qe.Comment,r.value=`Written by alphaTab ${h.version} (${h.commit})`,n.addChild(r),this.ZM(s,e),this.tv(s,e),this.ev(s,e),this.sv(s,e),this.iv(s,e),this.nv(s,e),this.rv(s,e);const a=s.addElement("Bars"),o=s.addElement("Voices"),c=s.addElement("Beats"),l=s.addElement("Notes"),u=s.addElement("Rhythms");for(const t of e.tracks)for(const e of t.staves)for(const t of e.bars){this.av(a,t);for(const e of t.voices){this.hv(o,e);for(const t of e.beats){this.ov(c,t,u);for(const e of t.notes)this.cv(l,e)}}}}rv(t,e){if(!e.backingTrack?.rawAudioFile)return;const s=t.addElement("Assets").addElement("Asset");s.attributes.set("id",this.La),this.backingTrackAssetFileName="Content/Assets/backing-track",s.addElement("EmbeddedFilePath").setCData(this.backingTrackAssetFileName)}La;lv;backingTrackAssetFileName;ev(t,e){if(!e.backingTrack?.rawAudioFile)return;const s=t.addElement("BackingTrack");this.La="0",s.addElement("IconId").innerText="21",s.addElement("Color").innerText="0 0 0",s.addElement("Name").setCData("Audio Track"),s.addElement("ShortName").setCData("a.track"),s.addElement("PlaybackState").innerText="Default",s.addElement("Enabled").innerText="true",s.addElement("Source").innerText="Local",s.addElement("AssetId").innerText="0";const i=s.addElement("ChannelStrip");i.addElement("Parameters").innerText="0.500000 0.500000 0.500000 0.500000 0.500000 0.500000 0.500000 0.500000 0.500000 0.000000 0.500000 0.500000 0.800000 0.500000 0.500000 0.500000",i.addElement("YouTubeVideoUrl").innerText="",i.addElement("Filter").innerText="6",i.addElement("FramesPerPixel").innerText="400";const n=void 0!==this.lv?this.lv:0;s.addElement("FramePadding").innerText=`${n}`,s.addElement("Semitones").innerText="0",s.addElement("Cents").innerText="0"}cv(t,e){const s=t.addElement("Note");s.attributes.set("id",e.id.toString()),this.uv(s,e),e.isGhost&&(s.addElement("AntiAccent").innerText="normal"),e.isLetRing&&s.addElement("LetRing"),e.isTrill&&(s.addElement("Trill").innerText=e.trillValue.toString());let i=0;switch(e.isStaccato&&(i|=1),e.accentuated){case k.Normal:i|=8;break;case k.Heavy:i|=4;break;case k.Tenuto:i|=16}if(i>0&&(s.addElement("Accent").innerText=i.toString()),e.isTieOrigin||e.isTieDestination){const t=s.addElement("Tie");t.attributes.set("origin",e.isTieOrigin?"true":"false"),t.attributes.set("destination",e.isTieDestination?"true":"false")}switch(e.vibrato){case P.Slight:s.addElement("Vibrato").innerText="Slight";break;case P.Wide:s.addElement("Vibrato").innerText="Wide"}if(e.isFingering){switch(e.leftHandFinger){case S.Thumb:s.addElement("LeftFingering").innerText="P";break;case S.IndexFinger:s.addElement("LeftFingering").innerText="I";break;case S.MiddleFinger:s.addElement("LeftFingering").innerText="M";break;case S.AnnularFinger:s.addElement("LeftFingering").innerText="A";break;case S.LittleFinger:s.addElement("LeftFingering").innerText="C"}switch(e.rightHandFinger){case S.Thumb:s.addElement("RightFingering").innerText="P";break;case S.IndexFinger:s.addElement("RightFingering").innerText="I";break;case S.MiddleFinger:s.addElement("RightFingering").innerText="M";break;case S.AnnularFinger:s.addElement("RightFingering").innerText="A";break;case S.LittleFinger:s.addElement("RightFingering").innerText="C"}}e.percussionArticulation>=0?s.addElement("InstrumentArticulation").innerText=e.percussionArticulation.toString():s.addElement("InstrumentArticulation").innerText="0",e.ornament!==Pt.None&&(s.addElement("Ornament").innerText=Pt[e.ornament])}uv(t,e){const s=t.addElement("Properties");if(this.dv(s,e),this.fv(s,e),e.isStringed&&(this.pv(s,"String","String",(e.string-1).toString()),this.pv(s,"Fret","Fret",e.fret.toString()),this.pv(s,"Midi","Number",e.realValue.toString()),e.showStringNumber&&this.pv(s,"ShowStringNumber","Enable",null)),e.isPiano&&(this.pv(s,"Octave","Number",e.octave.toString()),this.pv(s,"Tone","Step",e.tone.toString()),this.pv(s,"Midi","Number",e.realValue.toString())),e.beat.tap&&this.pv(s,"Tapped","Enable",null),e.harmonicType!==B.None){switch(e.harmonicType){case B.Natural:this.pv(s,"HarmonicType","HType","Natural");break;case B.Artificial:this.pv(s,"HarmonicType","HType","Artificial");break;case B.Pinch:this.pv(s,"HarmonicType","HType","Pinch");break;case B.Tap:this.pv(s,"HarmonicType","HType","Tap");break;case B.Semi:this.pv(s,"HarmonicType","HType","Semi");break;case B.Feedback:this.pv(s,"HarmonicType","HType","Feedback")}0!==e.harmonicValue&&this.pv(s,"HarmonicFret","HFret",e.harmonicValue.toString())}e.isDead&&this.pv(s,"Muted","Enable",null),e.isPalmMute&&this.pv(s,"PalmMuted","Enable",null),e.hasBend&&this.bv(s,e),e.isHammerPullOrigin&&this.pv(s,"HopoOrigin","Enable",null),e.isHammerPullDestination&&this.pv(s,"HopoDestination","Enable",null),e.isLeftHandTapped&&this.pv(s,"LeftHandTapped","Enable",null);let i=0;switch(e.slideInType){case T.IntoFromAbove:i|=32;break;case T.IntoFromBelow:i|=16}switch(e.slideOutType){case M.Shift:i|=1;break;case M.Legato:i|=2;break;case M.OutDown:i|=4;break;case M.OutUp:i|=8;break;case M.PickSlideDown:i|=64;break;case M.PickSlideUp:i|=128}i>0&&this.pv(s,"Slide","Flags",i.toString())}fv(t,e){e.isPercussion?this.mv(t,"ConcertPitch","C","-1",""):this.gv(t,"TransposedPitch",e.displayValueWithoutBend,e.accidentalMode,e.beat.voice.bar.keySignature)}dv(t,e){e.isPercussion?this.mv(t,"ConcertPitch","C","-1",""):this.gv(t,"ConcertPitch",e.realValueWithoutHarmonic,e.accidentalMode,e.beat.voice.bar.keySignature)}static wv=["C","C","D","D","E","F","F","G","G","A","A","B"];gv(e,s,i,n,r){let a=0,h=0,o="",c="";const l=()=>{switch(a=i%12,h=i/12|0,o=t.wv[a],Bt.computeAccidental(r,_.Default,i,!1)){case I.None:case I.Natural:c="";break;case I.Sharp:c="#";break;case I.Flat:c="b";break;case I.DoubleSharp:c="x";break;case I.DoubleFlat:c="bb"}};switch(l(),n){case _.Default:break;case _.ForceNone:case _.ForceNatural:c="";break;case _.ForceSharp:c="#";break;case _.ForceDoubleSharp:"#"===c&&(i-=2,l()),c="x";break;case _.ForceFlat:"#"===c&&(i+=1,l()),c="b";break;case _.ForceDoubleFlat:"#"===c&&(i+=2,l()),c="bb"}this.mv(e,s,o,h.toString(),c)}mv(t,e,s,i,n){const r=t.addElement("Property");r.attributes.set("name",e);const a=r.addElement("Pitch");a.addElement("Step").innerText=s,a.addElement("Accidental").innerText=n,a.addElement("Octave").innerText=i}bv(t,e){e.hasBend&&e.bendPoints.length<=4&&this.yv(t,e.bendPoints)}yv(t,e){this.pv(t,"Bended","Enable",null);const s=e[0],i=e[e.length-1];let n,r;switch(e.length){case 4:n=e[1],r=e[2];break;case 3:n=e[1],r=e[1];break;default:n=new f((s.offset+i.offset)/2,(s.value+i.value)/2),r=n}this.pv(t,"BendDestinationOffset","Float",this.fo(i.offset).toString()),this.pv(t,"BendDestinationValue","Float",this.do(i.value).toString()),this.pv(t,"BendMiddleOffset1","Float",this.fo(n.offset).toString()),this.pv(t,"BendMiddleOffset2","Float",this.fo(r.offset).toString()),this.pv(t,"BendMiddleValue","Float",this.do(n.value).toString()),this.pv(t,"BendOriginOffset","Float",this.fo(s.offset).toString()),this.pv(t,"BendOriginValue","Float",this.do(s.value).toString())}do(t){return 25*t}fo(t){return t/f.MaxPosition*100}ov(t,e,s){const i=t.addElement("Beat");if(i.attributes.set("id",e.id.toString()),i.addElement("Dynamic").innerText=o[e.dynamics],e.fade!==Rt.None&&(i.addElement("Fadding").innerText=Rt[e.fade]),e.isTremolo)switch(e.tremoloPicking.marks){case 1:i.addElement("Tremolo").innerText="1/2";break;case 2:i.addElement("Tremolo").innerText="1/4";break;case 3:i.addElement("Tremolo").innerText="1/8"}switch(e.hasChord&&i.addElement("Chord").setCData(e.chordId),e.crescendo!==g.None&&(i.addElement("Hairpin").innerText=g[e.crescendo]),e.brushType){case m.ArpeggioUp:i.addElement("Arpeggio").innerText="Up";break;case m.ArpeggioDown:i.addElement("Arpeggio").innerText="Down"}switch(e.text&&i.addElement("FreeText").setCData(e.text),e.graceType){case y.OnBeat:case y.BeforeBeat:i.addElement("GraceNotes").innerText=y[e.graceType]}if(e.ottava!==x.Regular&&(i.addElement("Ottavia").innerText=x[e.ottava].substr(1)),e.hasWhammyBar&&this.kv(i,e),e.isLegatoOrigin||e.isLegatoDestination){const t=i.addElement("Legato");t.attributes.set("origin",e.isLegatoOrigin?"true":"false"),t.attributes.set("destination",e.isLegatoDestination?"true":"false")}if(this.Sv(i,e,s),null!==e.preferredBeamDirection)switch(e.preferredBeamDirection){case Fe.Up:i.addElement("TransposedPitchStemOrientation").innerText="Upward",i.addElement("UserTransposedPitchStemOrientation").innerText="Upward";break;case Fe.Down:i.addElement("TransposedPitchStemOrientation").innerText="Downward",i.addElement("UserTransposedPitchStemOrientation").innerText="Downward"}i.addElement("ConcertPitchStemOrientation").innerText="Undefined",e.slashed&&i.addElement("Slashed"),e.deadSlapped&&i.addElement("DeadSlapped"),e.notes.length>0&&(i.addElement("Notes").innerText=e.notes.map(t=>t.id).join(" ")),e.golpe!==Wt.None&&(i.addElement("Golpe").innerText=Wt[e.golpe]),e.wahPedal!==Ot.None&&(i.addElement("Wah").innerText=Ot[e.wahPedal]),e.showTimer&&(i.addElement("Timer").innerText=(e.timer??0).toString()),this.Bv(i,e),this._v(i,e),e.lyrics&&e.lyrics.length>0&&this.xv(i,e.lyrics)}xv(t,e){const s=t.addElement("Lyrics");for(const t of e)s.addElement("Line").setCData(t)}_v(t,e){const s=t.addElement("XProperties");switch(e.brushDuration>0&&this.Tv(s,"687935489","Int",e.brushDuration.toString()),e.beamingMode){case Vt.ForceSplitToNext:this.Tv(s,"1124204546","Int","2");break;case Vt.ForceMergeWithNext:this.Tv(s,"1124204546","Int","1");break;case Vt.ForceSplitOnSecondaryToNext:this.Tv(s,"1124204552","Int","1")}}Bv(t,e){const s=t.addElement("Properties");switch(e.brushType){case m.BrushUp:this.pv(s,"Brush","Direction","Up");break;case m.BrushDown:this.pv(s,"Brush","Direction","Down")}switch(e.pickStroke){case _t.Up:this.pv(s,"PickStroke","Direction","Up");break;case _t.Down:this.pv(s,"PickStroke","Direction","Down")}switch(e.slap&&this.pv(s,"Slapped","Enable",null),e.pop&&this.pv(s,"Popped","Enable",null),e.vibrato){case P.Wide:this.pv(s,"VibratoWTremBar","Strength","Wide");break;case P.Slight:this.pv(s,"VibratoWTremBar","Strength","Slight")}if(e.isBarre)switch(this.pv(s,"BarreFret","Fret",e.barreFret.toString()),e.barreShape){case It.Full:this.pv(s,"BarreString","String","0");break;case It.Half:this.pv(s,"BarreString","String","1")}if(e.rasgueado!==Gt.None){let t="";switch(e.rasgueado){case Gt.Ii:t="ii_1";break;case Gt.Mi:t="mi_1";break;case Gt.MiiTriplet:t="mii_1";break;case Gt.MiiAnapaest:t="mii_2";break;case Gt.PmpTriplet:t="pmp_1";break;case Gt.PmpAnapaest:t="pmp_2";break;case Gt.PeiTriplet:t="pei_1";break;case Gt.PeiAnapaest:t="pei_2";break;case Gt.PaiTriplet:t="pai_1";break;case Gt.PaiAnapaest:t="pai_2";break;case Gt.AmiTriplet:t="ami_1";break;case Gt.AmiAnapaest:t="ami_2";break;case Gt.Ppp:t="ppp_1";break;case Gt.Amii:t="amii_1";break;case Gt.Amip:t="amip_1";break;case Gt.Eami:t="eami_1";break;case Gt.Eamii:t="eamii_1";break;case Gt.Peami:t="peami_1"}this.pv(s,"Rasgueado","Rasgueado",t)}}Sv(t,e,s){const i=`${e.duration}_${e.dots}_${e.tupletNumerator}_${e.tupletDenominator}';`;let n;if(this.KM.has(i))n=this.KM.get(i);else{n=this.KM.size.toString(),this.KM.set(i,n);const t=s.addElement("Rhythm");if(t.attributes.set("id",n),e.hasTuplet){const s=t.addElement("PrimaryTuplet");s.attributes.set("num",e.tupletNumerator.toString()),s.attributes.set("den",e.tupletDenominator.toString())}e.dots>0&&t.addElement("AugmentationDot").attributes.set("count",e.dots.toString());let r="Quarter";switch(e.duration){case w.QuadrupleWhole:r="Long";break;case w.DoubleWhole:r="DoubleWhole";break;case w.Whole:r="Whole";break;case w.Half:r="Half";break;case w.Quarter:r="Quarter";break;case w.Eighth:r="Eighth";break;case w.Sixteenth:r="16th";break;case w.ThirtySecond:r="32nd";break;case w.SixtyFourth:r="64th";break;case w.OneHundredTwentyEighth:r="128th";break;case w.TwoHundredFiftySixth:r="256th"}t.addElement("NoteValue").innerText=r}t.addElement("Rhythm").attributes.set("ref",n)}kv(t,e){e.hasWhammyBar&&e.whammyBarPoints.length<=4&&this.Mv(t,e.whammyBarPoints)}Mv(t,e){const s=t.addElement("Whammy"),i=e[0],n=e[e.length-1];let r,a;switch(e.length){case 4:r=e[1],a=e[2];break;case 3:r=e[1],a=e[1];break;default:r=new f((i.offset+n.offset)/2,(i.value+n.value)/2),a=r}s.attributes.set("destinationOffset",this.fo(n.offset).toString()),s.attributes.set("destinationValue",this.do(n.value).toString()),s.attributes.set("middleOffset1",this.fo(r.offset).toString()),s.attributes.set("middleOffset2",this.fo(a.offset).toString()),s.attributes.set("middleValue",this.do(r.value).toString()),s.attributes.set("originOffset",this.fo(i.offset).toString()),s.attributes.set("originValue",this.do(i.value).toString())}ZM(t,e){const s=t.addElement("Score");s.addElement("Title").setCData(e.title),s.addElement("SubTitle").setCData(e.subTitle),s.addElement("Artist").setCData(e.artist),s.addElement("Album").setCData(e.album),s.addElement("Words").setCData(e.words),s.addElement("Music").setCData(e.music),s.addElement("WordsAndMusic").setCData(e.words===e.music?e.words:""),s.addElement("Copyright").setCData(e.copyright),s.addElement("Tabber").setCData(e.tab),s.addElement("Instructions").setCData(e.instructions),s.addElement("Notices").setCData(e.notices),s.addElement("FirstPageHeader").setCData(""),s.addElement("FirstPageFooter").setCData(""),s.addElement("PageHeader").setCData(""),s.addElement("PageFooter").setCData(""),s.addElement("ScoreSystemsDefaultLayout").setCData(e.defaultSystemsLayout.toString()),s.addElement("ScoreSystemsLayout").setCData(e.systemsLayout.join(" ")),s.addElement("ScoreZoomPolicy").innerText="Value",s.addElement("ScoreZoom").innerText="1",s.addElement("MultiVoice").innerText="1>"}tv(e,s){const i=e.addElement("MasterTrack");i.addElement("Tracks").innerText=s.tracks.map(t=>t.index).join(" ");const n=i.addElement("Automations");if(s.masterBars.length>0&&s.masterBars[0].isAnacrusis&&i.addElement("Anacrusis"),0===s.masterBars[0].tempoAutomations.length){const t=n.addElement("Automation");t.addElement("Type").innerText="Tempo",t.addElement("Linear").innerText="false",t.addElement("Bar").innerText="0",t.addElement("Position").innerText="0",t.addElement("Visible").innerText="true",t.addElement("Value").innerText=`${s.tempo} 2`,s.tempoLabel&&(t.addElement("Text").innerText=s.tempoLabel)}const r=s.masterBars[0].syncPoints?s.masterBars[0].syncPoints.find(t=>0===t.ratioPosition&&0===t.syncPointValue.barOccurence):void 0,a=r?r.syncPointValue.millisecondOffset:0;this.lv=a/1e3*t.Da*-1|0;const h=new L(()=>$a.buildModifiedTempoLookup(s));for(const e of s.masterBars){for(const t of e.tempoAutomations){const s=n.addElement("Automation");s.addElement("Type").innerText="Tempo",s.addElement("Linear").innerText=t.isLinear?"true":"false",s.addElement("Bar").innerText=e.index.toString(),s.addElement("Position").innerText=t.ratioPosition.toString(),s.addElement("Visible").innerText=t.isVisible?"true":"false",s.addElement("Value").innerText=`${t.value} 2`,t.text&&(s.addElement("Text").innerText=t.text)}if(e.syncPoints)for(const i of e.syncPoints){const r=n.addElement("Automation");r.addElement("Type").innerText="SyncPoint",r.addElement("Linear").innerText="false",r.addElement("Bar").innerText=e.index.toString(),r.addElement("Position").innerText=i.ratioPosition.toString(),r.addElement("Visible").innerText=i.isVisible?"true":"false";const o=r.addElement("Value");o.addElement("BarIndex").innerText=e.index.toString(),o.addElement("BarOccurrence").innerText=i.syncPointValue.barOccurence.toString(),o.addElement("ModifiedTempo").innerText=h.value.get(i).syncBpm.toString(),o.addElement("OriginalTempo").innerText=s.tempo.toString();let c=(i.syncPointValue.millisecondOffset-a)/1e3*t.Da;c=Math.floor(c+.5),o.addElement("FrameOffset").innerText=c.toString()}}}sv(t,e){t.addElement("AudioTracks")}iv(t,e){const s=t.addElement("Tracks");for(const t of e.tracks)this.vv(s,t)}vv(t,e){const s=t.addElement("Track");s.attributes.set("id",e.index.toString()),s.addElement("Name").setCData(e.name),s.addElement("ShortName").setCData(e.shortName),s.addElement("Color").innerText=`${e.color.r} ${e.color.g} ${e.color.b}`,s.addElement("SystemsDefautLayout").innerText=e.defaultSystemsLayout.toString(),s.addElement("SystemsLayout").innerText=e.systemsLayout.join(" "),s.addElement("AutoBrush"),s.addElement("PalmMute").innerText="0",s.addElement("PlayingStyle").innerText=we.isGuitar(e.playbackInfo.program)?"StringedPick":"Default",s.addElement("UseOneChannelPerString"),s.addElement("IconId").innerText=Wu.getIconId(e.playbackInfo).toString(),this.Nv(s,e),this.Pv(s,e),this.Cv(s,e),s.addElement("ForcedSound").innerText="-1",this.Ev(s,e),e.playbackInfo.isSolo?s.addElement("PlaybackState").innerText="Solo":e.playbackInfo.isMute?s.addElement("PlaybackState").innerText="Mute":s.addElement("PlaybackState").innerText="Default",s.addElement("AudioEngineState").innerText="MIDI",this.Fv(s,e),this.Av(s,e),this.Dv(s,e)}Lv(t,e,s,i,n,r,a,h,o=0){const c=t.addElement("Sound");c.addElement("Name").setCData(s),c.addElement("Label").setCData(s),c.addElement("Path").setCData(i),c.addElement("Role").setCData(n);const l=c.addElement("MIDI"),u=we.bankToLsbMsb(h);l.addElement("LSB").innerText=u[0].toString(),l.addElement("MSB").innerText=u[1].toString(),l.addElement("Program").innerText=a.toString();const d=e.addElement("Automation");d.addElement("Type").innerText="Sound",d.addElement("Linear").innerText="false",d.addElement("Bar").innerText=r.toString(),d.addElement("Position").innerText=o.toString(),d.addElement("Visible").innerText="true",d.addElement("Value").setCData(`${i};${s};${n}`)}Dv(t,e){const s=t.addElement("Sounds"),i=t.addElement("Automations");if(e.staves.length>0&&e.staves[0].bars.length>0){const t=`Track_${e.index}_Initial`,n=`Midi/${e.playbackInfo.program}`,r="Factory";let a=!1,h=e.playbackInfo.bank;for(const o of e.staves)for(const c of o.bars)for(const o of c.voices)for(const u of o.beats){const o=u.getAutomation(l.Instrument),d=0===c.index&&0===u.index,f=u.getAutomation(l.Bank);if(f&&(h=f.value),o){const l=d?t:`ProgramChange_${u.id}`,f=d?n:`Midi/${o.value}`,p=d?r:"User";d||a||(this.Lv(s,i,t,n,r,e.staves[0].bars[0].index,e.playbackInfo.program,e.playbackInfo.bank),a=!0),this.Lv(s,i,l,f,p,c.index,o.value,h,o.ratioPosition),d&&(a=!0)}}}for(const t of e.staves)for(const e of t.bars)for(const t of e.sustainPedals)if(t.pedalType!==U.Hold){const s=i.addElement("Automation");switch(s.addElement("Type").innerText="SustainPedal",s.addElement("Linear").innerText="false",s.addElement("Bar").innerText=e.index.toString(),s.addElement("Position").innerText=t.ratioPosition.toString(),s.addElement("Visible").innerText="true",t.pedalType){case U.Down:s.addElement("Value").innerText="0 1";break;case U.Up:s.addElement("Value").innerText="0 3"}}}Ev(t,e){const s=t.addElement("MidiConnection");s.addElement("Port").innerText=e.playbackInfo.port.toString(),s.addElement("PrimaryChannel").innerText=e.playbackInfo.primaryChannel.toString(),s.addElement("SecondaryChannel").innerText=e.playbackInfo.secondaryChannel.toString(),s.addElement("ForeOneChannelPerString").innerText="false"}Cv(t,e){const s=t.addElement("RSE").addElement("ChannelStrip");s.attributes.set("version","E56");s.addElement("Parameters").innerText=`0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 1 0.5 ${e.playbackInfo.balance/16} ${e.playbackInfo.volume/16} 0.5 0.5 0.5`}Av(t,e){const s=t.addElement("Staves");for(const t of e.staves)this.Wv(s,t)}Wv(t,e){const s=t.addElement("Staff").addElement("Properties");if(this.pv(s,"CapoFret","Fret",e.capo.toString()),this.pv(s,"FretCount","Fret","24"),e.tuning.length>0){const t=s.addElement("Property");switch(t.attributes.set("name","Tuning"),t.addElement("Pitches").innerText=e.tuning.slice().reverse().join(" "),t.addElement("Label").setCData(e.tuningName),t.addElement("LabelVisible").innerText=e.tuningName?"true":"false",t.addElement("Flat"),e.tuning.length){case 3:t.addElement("Instrument").innerText="Shamisen";break;case 4:105===e.track.playbackInfo.program?t.addElement("Instrument").innerText="Banjo":42===e.track.playbackInfo.program?t.addElement("Instrument").innerText="Cello":43===e.track.playbackInfo.program?t.addElement("Instrument").innerText="Contrabass":40===e.track.playbackInfo.program?t.addElement("Instrument").innerText="Violin":41===e.track.playbackInfo.program?t.addElement("Instrument").innerText="Viola":t.addElement("Instrument").innerText="Bass";break;case 5:105===e.track.playbackInfo.program?t.addElement("Instrument").innerText="Banjo":t.addElement("Instrument").innerText="Bass";break;case 6:105===e.track.playbackInfo.program?t.addElement("Instrument").innerText="Banjo":e.track.playbackInfo.program<=39?t.addElement("Instrument").innerText="Bass":t.addElement("Instrument").innerText="Guitar";break;case 7:e.track.playbackInfo.program<=39?t.addElement("Instrument").innerText="Bass":t.addElement("Instrument").innerText="Guitar";break;default:t.addElement("Instrument").innerText="Guitar"}}this.pv(s,"PartialCapoFret","Fret","0"),this.pv(s,"PartialCapoStringFlags","Bitset",e.tuning.map(t=>"0").join("")),this.pv(s,"TuningFlat","Enable",null),this.Rv(s,e,"DiagramCollection"),this.Rv(s,e,"DiagramWorkingSet")}Rv(t,e,s){const i=t.addElement("Property");i.attributes.set("name",s);const n=i.addElement("Items"),r=e.chords;if(r)for(const[t,e]of r){const s=n.addElement("Item");s.attributes.set("id",t),s.attributes.set("name",e.name);const i=s.addElement("Diagram");i.attributes.set("stringCount",e.strings.length.toString()),i.attributes.set("fretCount","5"),i.attributes.set("baseFret",(e.firstFret-1).toString()),i.attributes.set("barStates",e.strings.map(t=>"1").join(" "));const r=[],a=new Map;for(let t=0;t<e.strings.length;t++){const s=e.strings[t];if(-1!==s){const n=i.addElement("Fret"),h=e.strings.length-1-t;n.attributes.set("string",h.toString()),n.attributes.set("fret",(s-e.firstFret+1).toString()),a.has(s)||(a.set(s,[]),r.push(s)),a.get(s).push(h)}}r.sort();const h=i.addElement("Fingering");if(e.barreFrets.length>0){const t=[S.LittleFinger,S.AnnularFinger,S.MiddleFinger,S.IndexFinger];for(const s of r){const i=a.get(s);if(i.length>1&&e.barreFrets.indexOf(s)>=0){const n=t.length>0?t.pop():S.IndexFinger;for(const t of i){const i=h.addElement("Position");switch(n){case S.LittleFinger:i.attributes.set("finger","Pinky");break;case S.AnnularFinger:i.attributes.set("finger","Ring");break;case S.MiddleFinger:i.attributes.set("finger","Middle");break;case S.IndexFinger:i.attributes.set("finger","Index")}i.attributes.set("fret",(s-e.firstFret+1).toString()),i.attributes.set("string",t.toString())}}}}const o=i.addElement("Property");o.attributes.set("name","ShowName"),o.attributes.set("type","bool"),o.attributes.set("value",e.showName?"true":"false");const c=i.addElement("Property");c.attributes.set("name","ShowDiagram"),c.attributes.set("type","bool"),c.attributes.set("value",e.showDiagram?"true":"false");const l=i.addElement("Property");l.attributes.set("name","ShowFingering"),l.attributes.set("type","bool"),l.attributes.set("value",e.showFingering?"true":"false");const u=i.addElement("Chord"),d=u.addElement("KeyNote");d.attributes.set("step","C"),d.attributes.set("accidental","Natural");const f=u.addElement("BassNote");f.attributes.set("step","C"),f.attributes.set("accidental","Natural");const p=u.addElement("Degree");p.attributes.set("interval","Third"),p.attributes.set("alteration","Major"),p.attributes.set("omitted","false");const b=u.addElement("Degree");b.attributes.set("interval","Fifth"),b.attributes.set("alteration","Perfect"),b.attributes.set("omitted","false")}}pv(t,e,s,i){const n=t.addElement("Property");n.attributes.set("name",e);const r=n.addElement(s);return null!==i&&(r.innerText=i),n}Tv(t,e,s,i){const n=t.addElement("XProperty");n.attributes.set("id",e);const r=n.addElement(s);return null!==i&&(r.innerText=i),n}Fv(t,e){const s=t.addElement("Lyrics");s.attributes.set("dispatched","true");const i=[];for(const t of e.staves[0].bars)for(const e of t.voices)if(!e.isEmpty)for(const s of e.beats)if(s.lyrics)for(let e=0;e<s.lyrics.length;e++){for(;e>=i.length;){const e=new xe;e.startBar=t.index,e.text="[Empty]",i.push(e)}const n=i[e];n.text="[Empty]"===n.text?s.lyrics[e]:`${n.text} ${s.lyrics[e].split(" ").join("+")}`}for(let t=0;t<i.length;t++){const e=s.addElement("Line");e.addElement("Text").setCData(i[t].text),e.addElement("Offset").innerText=i[t].startBar.toString()}}Pv(t,e){const s=t.addElement("Transpose"),i=Math.floor(e.staves[0].displayTranspositionPitch/12),n=e.staves[0].displayTranspositionPitch-12*i;s.addElement("Chromatic").innerText=n.toString(),s.addElement("Octave").innerText=i.toString()}Nv(t,e){const s=Wu.buildInstrumentSet(e),i=t.addElement("InstrumentSet");i.addElement("Name").innerText=s.name,i.addElement("Type").innerText=s.type,i.addElement("LineCount").innerText=s.lineCount.toString();const n=i.addElement("Elements");for(const t of s.elements){const e=n.addElement("Element");e.addElement("Name").innerText=t.name,e.addElement("Type").innerText=t.type,e.addElement("SoundbankName").innerText=t.soundbankName;const s=e.addElement("Articulations");for(const e of t.articulations){const t=s.addElement("Articulation");switch(t.addElement("Name").innerText=e.name,t.addElement("StaffLine").innerText=e.staffLine.toString(),t.addElement("Noteheads").innerText=[this.Ov(e.noteHeads[0]),this.Ov(e.noteHeads[1]),this.Ov(e.noteHeads[2])].join(" "),e.techniqueSymbolPlacement){case Mt.Below:t.addElement("TechniquePlacement").innerText="below";break;case Mt.Outside:t.addElement("TechniquePlacement").innerText="outside";break;case Mt.Inside:t.addElement("TechniquePlacement").innerText="inside";break;case Mt.Above:t.addElement("TechniquePlacement").innerText="above"}t.addElement("TechniqueSymbol").innerText=this.Ov(e.techniqueSymbol),t.addElement("InputMidiNumbers").innerText=e.inputMidiNumbers.map(t=>t.toString()).join(" "),t.addElement("OutputRSESound").innerText=e.outputRSESound,t.addElement("OutputMidiNumber").innerText=e.outputMidiNumber.toString()}}}Ov(t){if(t===xt.None)return"";const e=xt[t];return e.substring(0,1).toLowerCase()+e.substring(1)}nv(t,e){const s=t.addElement("MasterBars");for(const t of e.masterBars)this.Iv(s,t)}Iv(t,e){const s=t.addElement("MasterBar"),i=s.addElement("Key");let n=e.score.tracks[0].staves[0].bars[e.index].keySignature;const r=e.score.tracks[0].staves[0].bars[e.index].keySignatureType,a=Bt.flooredDivision(e.score.tracks[0].staves[0].displayTranspositionPitch,12);n=Bt.transposeKey(n,-a),i.addElement("AccidentalCount").innerText=n.toString(),i.addElement("Mode").innerText=z[r],i.addElement("Sharps").innerText="Sharps",s.addElement("Time").innerText=`${e.timeSignatureNumerator}/${e.timeSignatureDenominator}`,e.actualBeamingRules&&this.Gv(s,e),e.isFreeTime&&s.addElement("FreeTime");const h=[];for(const t of e.score.tracks)for(const s of t.staves)h.push(s.bars[e.index].id.toString());if(s.addElement("Bars").innerText=h.join(" "),e.isDoubleBar&&s.addElement("DoubleBar"),e.isSectionStart){const t=s.addElement("Section");t.addElement("Letter").setCData(e.section.marker),t.addElement("Text").setCData(e.section.text)}if(e.isRepeatStart||e.isRepeatEnd){const t=s.addElement("Repeat");t.attributes.set("start",e.isRepeatStart?"true":"false"),t.attributes.set("end",e.isRepeatEnd?"true":"false"),e.isRepeatEnd&&t.attributes.set("count",e.repeatCount.toString())}if(e.alternateEndings>0){let t=e.alternateEndings;const i=[];let n=0;for(;t>0;)1==(t>>n&1)&&(i.push(n+1),t&=~(1<<n)),n++;s.addElement("AlternateEndings").innerText=i.join(" ")}if(e.tripletFeel!==K.NoTripletFeel&&(s.addElement("TripletFeel").innerText=K[e.tripletFeel]),e.directions&&e.directions.size>0){const t=s.addElement("Directions");for(const s of e.directions)switch(s){case ys.TargetFine:t.addElement("Target").innerText="Fine";break;case ys.TargetSegno:t.addElement("Target").innerText="Segno";break;case ys.TargetSegnoSegno:t.addElement("Target").innerText="SegnoSegno";break;case ys.TargetCoda:t.addElement("Target").innerText="Coda";break;case ys.TargetDoubleCoda:t.addElement("Target").innerText="DoubleCoda";break;case ys.JumpDaCapo:t.addElement("Jump").innerText="DaCapo";break;case ys.JumpDaCapoAlCoda:t.addElement("Jump").innerText="DaCapoAlCoda";break;case ys.JumpDaCapoAlDoubleCoda:t.addElement("Jump").innerText="DaCapoAlDoubleCoda";break;case ys.JumpDaCapoAlFine:t.addElement("Jump").innerText="DaCapoAlFine";break;case ys.JumpDalSegno:t.addElement("Jump").innerText="DaSegno";break;case ys.JumpDalSegnoAlCoda:t.addElement("Jump").innerText="DaSegnoAlCoda";break;case ys.JumpDalSegnoAlDoubleCoda:t.addElement("Jump").innerText="DaSegnoAlDoubleCoda";break;case ys.JumpDalSegnoAlFine:t.addElement("Jump").innerText="DaSegnoAlFine";break;case ys.JumpDalSegnoSegno:t.addElement("Jump").innerText="DaSegnoSegno";break;case ys.JumpDalSegnoSegnoAlCoda:t.addElement("Jump").innerText="DaSegnoSegnoAlCoda";break;case ys.JumpDalSegnoSegnoAlDoubleCoda:t.addElement("Jump").innerText="DaSegnoSegnoAlDoubleCoda";break;case ys.JumpDalSegnoSegnoAlFine:t.addElement("Jump").innerText="DaSegnoSegnoAlFine";break;case ys.JumpDaCoda:t.addElement("Jump").innerText="DaCoda";break;case ys.JumpDaDoubleCoda:t.addElement("Jump").innerText="DaDoubleCoda"}}this.Hv(s,e)}Gv(t,e){const s=t.addElement("XProperties"),i=e.actualBeamingRules;if(i){const t=i.findRule(w.Eighth);let e=t[0],n=1;t[0]===w.Quarter&&(e=8,n=2),this.Tv(s,"1124139010","Int",e.toString());const r=1124139264;let a=0;for(;a<t[1].length;)this.Tv(s,(r+a).toString(),"Int",(t[1][a]*n).toString()),a++}}Hv(t,e){const s=e.fermata?.size??0;if(0!==s&&s>0){const s=t.addElement("Fermatas");for(const[t,i]of e.fermata)this.$v(s,t,i)}}$v(t,e,s){let i=-1,n=1;if(e>0)for(;n<10&&(i=e/c.QuarterTime*n,i!==Math.floor(i));)i=-1,n++;else i=0,n=1;if(-1===i)return;const r=t.addElement("Fermata");r.addElement("Type").innerText=Be[s.type],r.addElement("Length").innerText=s.length.toString(),r.addElement("Offset").innerText=`${i}/${n}`}av(t,e){const s=t.addElement("Bar");s.attributes.set("id",e.id.toString()),s.addElement("Voices").innerText=e.voices.map(t=>t.isEmpty?"-1":t.id.toString()).join(" "),s.addElement("Clef").innerText=G[e.clef],e.clefOttava!==x.Regular&&(s.addElement("Ottavia").innerText=x[e.clefOttava].substr(1)),e.simileMark!==H.None&&(s.addElement("SimileMark").innerText=H[e.simileMark])}hv(t,e){if(e.isEmpty)return;const s=t.addElement("Voice");s.attributes.set("id",e.id.toString()),s.addElement("Beats").innerText=e.beats.map(t=>t.id).join(" ")}},Ou=class t{static Vv=t.zv();static zv(){const t=new Uint32Array(256);for(let e=0;e<t.length;e++){let s=e;for(let t=0;t<8;t++)s=1&~s?s>>>1:s>>>1^3988292384;t[e]=s}return t}static Uv=4294967295;Xv=t.Uv;get value(){return~this.Xv}constructor(){this.reset()}update(e,s,i){for(let n=0;n<i;n++)this.Xv=t.Vv[255&(this.Xv^e[s+n])]^this.Xv>>>8}reset(){this.Xv=t.Uv}},Iu=class t{static maxWbits=15;static wsize=1<<t.maxWbits;static wmask=t.wsize-1;static minMatch=3;static maxMatch=258;static defaultMemLevel=8;static pendingBufSize=1<<t.defaultMemLevel+8;static hashBits=t.defaultMemLevel+7;static hashSize=1<<t.hashBits;static hashShift=(t.hashBits+t.minMatch-1)/t.minMatch;static hashMask=t.hashSize-1;static minLookahead=t.maxMatch+t.minMatch+1;static maxDist=t.wsize-t.minLookahead},Gu=class t{static jv=16;static Jv=17;static qv=18;freqs;length=null;minNumCodes;numCodes=0;Yv=null;Kv;Qv;sn;constructor(t,e,s,i){this.sn=t,this.minNumCodes=s,this.Qv=i,this.freqs=new Int16Array(e),this.Kv=new Int32Array(i)}reset(){for(let t=0;t<this.freqs.length;t++)this.freqs[t]=0;this.Yv=null,this.length=null}buildTree(){const t=this.freqs.length,e=new Int32Array(t);let s=0,i=0;for(let n=0;n<t;n++){const t=this.freqs[n];if(0!==t){let r=s++;for(;r>0;){const s=Math.floor((r-1)/2);if(!(this.freqs[e[s]]>t))break;e[r]=e[s],r=s}e[r]=n,i=n}}for(;s<2;){const t=i<2?++i:0;e[s++]=t}this.numCodes=Math.max(i+1,this.minNumCodes);const n=s,r=new Int32Array(4*s-2),a=new Int32Array(2*s-1);let h=n;for(let t=0;t<s;t++){const s=e[t];r[2*t]=s,r[2*t+1]=-1,a[t]=this.freqs[s]<<8,e[t]=t}do{const t=e[0];let i=e[--s],n=0,o=1;for(;o<s;)o+1<s&&a[e[o]]>a[e[o+1]]&&o++,e[n]=e[o],n=o,o=2*o+1;let c=a[i];for(;o=n,n>0&&(n=Math.floor((o-1)/2),a[e[n]]>c);)e[o]=e[n];e[o]=i;const l=e[0];i=h++,r[2*i]=t,r[2*i+1]=l;const u=Math.min(255&a[t],255&a[l]);for(c=a[t]+a[l]-u+1,a[i]=c,n=0,o=1;o<s;)o+1<s&&a[e[o]]>a[e[o+1]]&&o++,e[n]=e[o],n=o,o=2*n+1;for(;o=n,o>0&&(n=Math.floor((o-1)/2),a[e[n]]>c);)e[o]=e[n];e[o]=i}while(s>1);this.Zv(r)}Zv(t){this.length=new Uint8Array(this.freqs.length);const e=Math.floor(t.length/2),s=Math.floor((e+1)/2);let i=0;for(let t=0;t<this.Qv;t++)this.Kv[t]=0;const n=new Int32Array(e);n[e-1]=0;for(let s=e-1;s>=0;s--)if(-1!==t[2*s+1]){let e=n[s]+1;e>this.Qv&&(e=this.Qv,i++),n[t[2*s]]=e,n[t[2*s+1]]=e}else{const e=n[s];this.Kv[e-1]++,this.length[t[2*s]]=n[s]}if(0===i)return;let r=this.Qv-1;do{for(;0===this.Kv[--r];);do{this.Kv[r]--,this.Kv[++r]++,i-=1<<this.Qv-1-r}while(i>0&&r<this.Qv-1)}while(i>0);this.Kv[this.Qv-1]+=i,this.Kv[this.Qv-2]-=i;let a=2*s;for(let e=this.Qv;0!==e;e--){let s=this.Kv[e-1];for(;s>0;){const i=2*t[a++];-1===t[i+1]&&(this.length[t[i]]=e,s--)}}}getEncodedLength(){let t=0;for(let e=0;e<this.freqs.length;e++)t+=this.freqs[e]*this.length[e];return t}calcBLFreq(e){let s,i,n,r=-1,a=0;for(;a<this.numCodes;){n=1;const h=this.length[a];for(0===h?(s=138,i=3):(s=6,i=3,r!==h&&(e.freqs[h]++,n=0)),r=h,a++;a<this.numCodes&&r===this.length[a]&&(a++,!(++n>=s)););n<i?e.freqs[r]+=n:0!==r?e.freqs[t.jv]++:n<=10?e.freqs[t.Jv]++:e.freqs[t.qv]++}}setStaticCodes(t,e){this.Yv=t,this.length=e}buildCodes(){const t=new Int32Array(this.Qv);let e=0;this.Yv=new Int16Array(this.freqs.length);for(let s=0;s<this.Qv;s++)t[s]=e,e+=this.Kv[s]<<15-s;for(let e=0;e<this.numCodes;e++){const s=this.length[e];s>0&&(this.Yv[e]=Hu.bitReverse(t[s-1]),t[s-1]+=1<<16-s)}}writeTree(e){let s,i,n,r=-1,a=0;for(;a<this.numCodes;){n=1;const h=this.length[a];for(0===h?(s=138,i=3):(s=6,i=3,r!==h&&(e.writeSymbol(h),n=0)),r=h,a++;a<this.numCodes&&r===this.length[a]&&(a++,!(++n>=s)););if(n<i)for(;n-- >0;)e.writeSymbol(r);else 0!==r?(e.writeSymbol(t.jv),this.sn.pending.writeBits(n-3,2)):n<=10?(e.writeSymbol(t.Jv),this.sn.pending.writeBits(n-3,3)):(e.writeSymbol(t.qv),this.sn.pending.writeBits(n-11,7))}}writeSymbol(t){this.sn.pending.writeBits(65535&this.Yv[t],this.length[t])}},Hu=class t{static tN=1<<Iu.defaultMemLevel+6;static eN=286;static storedBlock=0;static staticTrees=1;static dynTrees=2;static sN=30;static iN=new Int16Array(t.eN);static nN=new Uint8Array(t.eN);static rN=new Int16Array(t.sN);static aN=new Uint8Array(t.sN);static staticInit(){let e=0;for(;e<144;)t.iN[e]=t.bitReverse(48+e<<8),t.nN[e++]=8;for(;e<256;)t.iN[e]=t.bitReverse(256+e<<7),t.nN[e++]=9;for(;e<280;)t.iN[e]=t.bitReverse(-256+e<<9),t.nN[e++]=7;for(;e<t.eN;)t.iN[e]=t.bitReverse(-88+e<<8),t.nN[e++]=8;for(e=0;e<t.sN;e++)t.rN[e]=t.bitReverse(e<<11),t.aN[e]=5}static hN=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];static oN=new Uint8Array([0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15]);static bitReverse(e){return t.oN[15&e]<<12|t.oN[e>>4&15]<<8|t.oN[e>>8&15]<<4|t.oN[e>>12]}static cN=19;static lN=256;pending;uN;dN;fN;pN;bN;mN=0;gN=0;constructor(e){this.pending=e,this.uN=new Gu(this,t.eN,257,15),this.dN=new Gu(this,t.sN,1,15),this.fN=new Gu(this,t.cN,4,7),this.pN=new Int16Array(t.tN),this.bN=new Uint8Array(t.tN)}isFull(){return this.mN>=t.tN}reset(){this.mN=0,this.gN=0,this.uN.reset(),this.dN.reset(),this.fN.reset()}flushStoredBlock(e,s,i,n){this.pending.writeBits((t.storedBlock<<1)+(n?1:0),3),this.pending.alignToByte(),this.pending.writeShort(i),this.pending.writeShort(~i),this.pending.writeBlock(e,s,i),this.reset()}flushBlock(e,s,i,n){this.uN.freqs[t.lN]++,this.uN.buildTree(),this.dN.buildTree(),this.uN.calcBLFreq(this.fN),this.dN.calcBLFreq(this.fN),this.fN.buildTree();let r=4;for(let e=18;e>r;e--)this.fN.length[t.hN[e]]>0&&(r=e+1);let a=14+3*r+this.fN.getEncodedLength()+this.uN.getEncodedLength()+this.dN.getEncodedLength()+this.gN,h=this.gN;for(let e=0;e<t.eN;e++)h+=this.uN.freqs[e]*t.nN[e];for(let e=0;e<t.sN;e++)h+=this.dN.freqs[e]*t.aN[e];a>=h&&(a=h),s>=0&&i+4<a>>3?this.flushStoredBlock(e,s,i,n):a===h?(this.pending.writeBits((t.staticTrees<<1)+(n?1:0),3),this.uN.setStaticCodes(t.iN,t.nN),this.dN.setStaticCodes(t.rN,t.aN),this.compressBlock(),this.reset()):(this.pending.writeBits((t.dynTrees<<1)+(n?1:0),3),this.sendAllTrees(r),this.compressBlock(),this.reset())}sendAllTrees(e){this.fN.buildCodes(),this.uN.buildCodes(),this.dN.buildCodes(),this.pending.writeBits(this.uN.numCodes-257,5),this.pending.writeBits(this.dN.numCodes-1,5),this.pending.writeBits(e-4,4);for(let s=0;s<e;s++)this.pending.writeBits(this.fN.length[t.hN[s]],3);this.uN.writeTree(this.fN),this.dN.writeTree(this.fN)}compressBlock(){for(let e=0;e<this.mN;e++){const s=255&this.bN[e];let i=this.pN[e];if(0!==i--){const e=t.wN(s);this.uN.writeSymbol(e);let n=Math.floor((e-261)/4);n>0&&n<=5&&this.pending.writeBits(s&(1<<n)-1,n);const r=t.yN(i);this.dN.writeSymbol(r),n=Math.floor(r/2)-1,n>0&&this.pending.writeBits(i&(1<<n)-1,n)}else this.uN.writeSymbol(s)}this.uN.writeSymbol(t.lN)}tallyDist(e,s){this.pN[this.mN]=e,this.bN[this.mN++]=s-3;const i=t.wN(s-3);this.uN.freqs[i]++,i>=265&&i<285&&(this.gN+=Math.floor((i-261)/4));const n=t.yN(e-1);return this.dN.freqs[n]++,n>=4&&(this.gN+=Math.floor(n/2)-1),this.isFull()}tallyLit(t){return this.pN[this.mN]=0,this.bN[this.mN++]=t,this.uN.freqs[t]++,this.isFull()}static wN(t){if(255===t)return 285;let e=257;for(;t>=8;)e+=4,t>>=1;return e+t}static yN(t){let e=0;for(;t>=4;)e+=2,t>>=1;return e+t}};Hu.staticInit();var $u=class t{static kN=4096;SN;BN=128;_N=128;xN=8;TN=0;MN;pn;ad;vN;NN=0;PN=null;CN=0;EN=0;FN=!1;AN=0;DN=0;LN;sn;inputCrc;constructor(t){this.LN=t,this.sn=new Hu(t),this.inputCrc=new Ou,this.pn=new Uint8Array(2*Iu.wsize),this.ad=new Int16Array(Iu.hashSize),this.vN=new Int16Array(Iu.wsize),this.SN=1,this.MN=1}reset(){this.sn.reset(),this.inputCrc.reset(),this.SN=1,this.MN=1,this.NN=0,this.FN=!1,this.DN=Iu.minMatch-1;for(let t=0;t<Iu.hashSize;t++)this.ad[t]=0;for(let t=0;t<Iu.wsize;t++)this.vN[t]=0}WN(){this.TN=this.pn[this.MN]<<Iu.hashShift^this.pn[this.MN+1]}needsInput(){return this.EN===this.CN}setInput(t,e,s){const i=e+s;this.PN=t,this.CN=e,this.EN=i}deflate(t,e){let s;do{this.fillWindow();const i=t&&this.CN===this.EN;s=this.RN(i,e)}while(this.LN.isFlushed&&s);return s}RN(e,s){if(this.NN<Iu.minLookahead&&!e)return!1;for(;this.NN>=Iu.minLookahead||e;){if(0===this.NN)return this.FN&&this.sn.tallyLit(255&this.pn[this.MN-1]),this.FN=!1,this.sn.flushBlock(this.pn,this.SN,this.MN-this.SN,s),this.SN=this.MN,!1;this.MN>=2*Iu.wsize-Iu.minLookahead&&this.ON();const e=this.AN;let i=this.DN;if(this.NN>=Iu.minMatch){const e=this.IN();0!==e&&this.MN-e<=Iu.maxDist&&this.GN(e)&&this.DN===Iu.minMatch&&this.MN-this.AN>t.kN&&(this.DN=Iu.minMatch-1)}if(i>=Iu.minMatch&&this.DN<=i){this.sn.tallyDist(this.MN-1-e,i),i-=2;do{this.MN++,this.NN--,this.NN>=Iu.minMatch&&this.IN()}while(--i>0);this.MN++,this.NN--,this.FN=!1,this.DN=Iu.minMatch-1}else this.FN&&this.sn.tallyLit(255&this.pn[this.MN-1]),this.FN=!0,this.MN++,this.NN--;if(this.sn.isFull()){let t=this.MN-this.SN;this.FN&&t--;const e=s&&0===this.NN&&!this.FN;return this.sn.flushBlock(this.pn,this.SN,t,e),this.SN+=t,!e}}return!0}GN(t){let e,s=this.MN;const i=s+Math.min(Iu.maxMatch,this.NN)-1,n=Math.max(s-Iu.maxDist,0),r=this.pn,a=this.vN;let h=this.BN;const o=Math.min(this._N,this.NN);if(this.DN=Math.max(this.DN,Iu.minMatch-1),s+this.DN>i)return!1;let c=r[s+this.DN-1],l=r[s+this.DN];this.DN>=this.xN&&(h>>=2);do{if(e=t,s=this.MN,r[e+this.DN]===l&&r[e+this.DN-1]===c&&r[e]===r[s]&&r[++e]===r[++s]){switch((i-s)%8){case 1:if(r[++s]===r[++e])break;break;case 2:if(r[++s]===r[++e]&&r[++s]===r[++e])break;break;case 3:if(r[++s]===r[++e]&&r[++s]===r[++e]&&r[++s]===r[++e])break;break;case 4:if(r[++s]===r[++e]&&r[++s]===r[++e]&&r[++s]===r[++e]&&r[++s]===r[++e])break;break;case 5:if(r[++s]===r[++e]&&r[++s]===r[++e]&&r[++s]===r[++e]&&r[++s]===r[++e]&&r[++s]===r[++e])break;break;case 6:if(r[++s]===r[++e]&&r[++s]===r[++e]&&r[++s]===r[++e]&&r[++s]===r[++e]&&r[++s]===r[++e]&&r[++s]===r[++e])break;break;case 7:if(r[++s]===r[++e]&&r[++s]===r[++e]&&r[++s]===r[++e]&&r[++s]===r[++e]&&r[++s]===r[++e]&&r[++s]===r[++e]&&r[++s]===r[++e])break}if(r[s]===r[e])do{if(s===i){++s,++e;break}}while(r[++s]===r[++e]&&r[++s]===r[++e]&&r[++s]===r[++e]&&r[++s]===r[++e]&&r[++s]===r[++e]&&r[++s]===r[++e]&&r[++s]===r[++e]&&r[++s]===r[++e]);if(s-this.MN>this.DN){if(this.AN=t,this.DN=s-this.MN,this.DN>=o)break;c=r[s-1],l=r[s]}t=65535&a[t&Iu.wmask]}}while(t>n&&0!==--h);return this.DN>=Iu.minMatch}IN(){const t=(this.TN<<Iu.hashShift^this.pn[this.MN+(Iu.minMatch-1)])&Iu.hashMask,e=this.ad[t];return this.vN[this.MN&Iu.wmask]=e,this.ad[t]=this.MN,this.TN=t,65535&e}fillWindow(){if(this.MN>=Iu.wsize+Iu.maxDist&&this.ON(),this.NN<Iu.minLookahead&&this.CN<this.EN){let t=2*Iu.wsize-this.NN-this.MN;t>this.EN-this.CN&&(t=this.EN-this.CN),this.pn.set(this.PN.subarray(this.CN,this.CN+t),this.MN+this.NN),this.inputCrc.update(this.PN,this.CN,t),this.CN+=t,this.NN+=t}this.NN>=Iu.minMatch&&this.WN()}ON(){this.pn.set(this.pn.subarray(Iu.wsize,Iu.wsize+Iu.wsize),0),this.AN-=Iu.wsize,this.MN-=Iu.wsize,this.SN-=Iu.wsize;for(let t=0;t<Iu.hashSize;++t){const e=65535&this.ad[t];this.ad[t]=e>=Iu.wsize?e-Iu.wsize:0}for(let t=0;t<Iu.wsize;t++){const e=65535&this.vN[t];this.vN[t]=e>=Iu.wsize?e-Iu.wsize:0}}},Vu=class{ki;HN=0;kf=0;tn=0;bitCount=0;get isFlushed(){return 0===this.kf}constructor(t){this.ki=new Uint8Array(t)}reset(){this.HN=0,this.kf=0,this.bitCount=0}writeShortMSB(t){this.ki[this.kf++]=t>>8&255,this.ki[this.kf++]=255&t}writeShort(t){this.ki[this.kf++]=t,this.ki[this.kf++]=t>>8}writeBlock(t,e,s){this.ki.set(t.subarray(e,e+s),this.kf),this.kf+=s}flush(t,e,s){return this.bitCount>=8&&(this.ki[this.kf++]=255&this.tn,this.tn>>=8,this.bitCount-=8),s>this.kf-this.HN?(s=this.kf-this.HN,t.set(this.ki.subarray(this.HN,this.HN+s),e),this.HN=0,this.kf=0):(t.set(this.ki.subarray(this.HN,this.HN+s),e),this.HN+=s),s}writeBits(t,e){this.tn|=t<<this.bitCount,this.bitCount+=e,this.bitCount>=16&&(this.ki[this.kf++]=255&this.tn,this.ki[this.kf++]=this.tn>>8&255,this.tn>>=16,this.bitCount-=16)}alignToByte(){this.bitCount>0&&(this.ki[this.kf++]=255&this.tn,this.bitCount>8&&(this.ki[this.kf++]=this.tn>>8&255)),this.tn=0,this.bitCount=0}},zu=class t{static $N=4;static isFinishing=8;static VN=16;static zN=20;static UN=28;static XN=30;Ni=0;LN;jN;get inputCrc(){return this.jN.inputCrc.value}constructor(){this.LN=new Vu(Iu.pendingBufSize),this.jN=new $u(this.LN),this.reset()}get isNeedingInput(){return this.jN.needsInput()}get isFinished(){return this.Ni===t.XN&&this.LN.isFlushed}reset(){this.Ni=t.VN,this.LN.reset(),this.jN.reset()}setInput(t,e,s){this.jN.setInput(t,e,s)}deflate(e,s,i){const n=i;for(;;){const r=this.LN.flush(e,s,i);if(s+=r,0===(i-=r)||this.Ni===t.XN)break;if(!this.jN.deflate(0!==(this.Ni&t.$N),0!==(this.Ni&t.isFinishing)))switch(this.Ni){case t.VN:return n-i;case t.zN:let e=8+(7&-this.LN.bitCount);for(;e>0;)this.LN.writeBits(2,10),e-=10;this.Ni=t.VN;break;case t.UN:this.LN.alignToByte(),this.Ni=t.XN}}return n-i}finish(){this.Ni|=t.$N|t.isFinishing}},Uu=class{entry;localHeaderOffset;compressedSize;crc32;compressionMode;constructor(t,e,s,i,n){this.entry=t,this.crc32=e,this.localHeaderOffset=s,this.compressionMode=i,this.compressedSize=n}},Xu=class{vd;JN=[];qN=new zu;constructor(t){this.vd=t}writeEntry(t){const e=Ye.CompressionMethodDeflate,s=Ie.empty(),i=this.YN(s,t.data,e),n=s.toArray(),r=new Uu(t,i,this.vd.bytesWritten,e,s.length);this.JN.push(r),le.writeInt32LE(this.vd,Ye.LocalFileHeaderSignature),le.writeUInt16LE(this.vd,10),le.writeUInt16LE(this.vd,2048),le.writeUInt16LE(this.vd,e),le.writeInt16LE(this.vd,0),le.writeInt16LE(this.vd,0),le.writeInt32LE(this.vd,i),le.writeInt32LE(this.vd,n.length),le.writeInt32LE(this.vd,t.data.length),le.writeInt16LE(this.vd,t.fullName.length),le.writeInt16LE(this.vd,0);const a=le.stringToBytes(t.fullName);this.vd.write(a,0,a.length),this.vd.write(n,0,n.length)}YN(t,e,s){if(s!==Ye.CompressionMethodDeflate){const s=new Ou;return s.update(e,0,e.length),t.write(e,0,e.length),s.value}const i=new Uint8Array(512);for(this.qN.reset(),this.qN.setInput(e,0,e.length);!this.qN.isNeedingInput;){const e=this.qN.deflate(i,0,i.length);if(e<=0)break;t.write(i,0,e)}for(this.qN.finish();!this.qN.isFinished;){const e=this.qN.deflate(i,0,i.length);if(e<=0)break;t.write(i,0,e)}return this.qN.inputCrc}end(){const t=this.vd.bytesWritten;for(const t of this.JN)this.KN(t);const e=this.vd.bytesWritten;this.QN(t,e)}QN(t,e){le.writeInt32LE(this.vd,Ye.EndOfCentralDirSignature),le.writeInt16LE(this.vd,0),le.writeInt16LE(this.vd,0),le.writeInt16LE(this.vd,this.JN.length),le.writeInt16LE(this.vd,this.JN.length),le.writeInt32LE(this.vd,e-t),le.writeInt32LE(this.vd,t),le.writeInt16LE(this.vd,0)}KN(t){le.writeInt32LE(this.vd,Ye.CentralFileHeaderSignature),le.writeUInt16LE(this.vd,10),le.writeUInt16LE(this.vd,10),le.writeUInt16LE(this.vd,2048),le.writeUInt16LE(this.vd,t.compressionMode),le.writeInt16LE(this.vd,0),le.writeInt16LE(this.vd,0),le.writeInt32LE(this.vd,t.crc32),le.writeInt32LE(this.vd,t.compressedSize),le.writeInt32LE(this.vd,t.entry.data.length),le.writeInt16LE(this.vd,t.entry.fullName.length),le.writeInt16LE(this.vd,0),le.writeInt16LE(this.vd,0),le.writeInt16LE(this.vd,0),le.writeInt16LE(this.vd,0),le.writeInt32LE(this.vd,0),le.writeInt32LE(this.vd,t.localHeaderOffset);const e=le.stringToBytes(t.entry.fullName);this.vd.write(e,0,e.length)}},ju=class extends Nu{get name(){return"Guitar Pro 7-8"}writeScore(t){O.debug(this.name,"Writing data entries");const e=new Ru,s=e.writeXml(t),i=xs.writeForScore(t),n=Es.writeForScore(t),r=Ds.writeForScore(t);O.debug(this.name,"Writing ZIP entries");const a=new Xu(this.data);a.writeEntry(new Ye("VERSION",le.stringToBytes("7.0"))),a.writeEntry(new Ye("Content/",new Uint8Array(0))),a.writeEntry(new Ye("Content/BinaryStylesheet",i)),a.writeEntry(new Ye("Content/PartConfiguration",n)),a.writeEntry(new Ye("Content/LayoutConfiguration",r)),a.writeEntry(new Ye("Content/score.gpif",le.stringToBytes(s))),e.backingTrackAssetFileName&&a.writeEntry(new Ye(e.backingTrackAssetFileName,t.backingTrack.rawAudioFile)),a.end()}},Ju=s({AlphaTexExporter:()=>Eu,Gp7Exporter:()=>ju,ScoreExporter:()=>Nu}),qu=class extends Bn{constructor(){super(0,0,Sn.EndOfTrack)}writeTo(t){throw new a(r.General,"Deprecated event, serialization not supported")}},Yu=function(t){return t[t.SequenceNumber=0]="SequenceNumber",t[t.TextEvent=1]="TextEvent",t[t.CopyrightNotice=2]="CopyrightNotice",t[t.SequenceOrTrackName=3]="SequenceOrTrackName",t[t.InstrumentName=4]="InstrumentName",t[t.LyricText=5]="LyricText",t[t.MarkerText=6]="MarkerText",t[t.CuePoint=7]="CuePoint",t[t.PatchName=8]="PatchName",t[t.PortName=9]="PortName",t[t.MidiChannel=32]="MidiChannel",t[t.MidiPort=33]="MidiPort",t[t.EndOfTrack=47]="EndOfTrack",t[t.Tempo=81]="Tempo",t[t.SmpteOffset=84]="SmpteOffset",t[t.TimeSignature=88]="TimeSignature",t[t.KeySignature=89]="KeySignature",t[t.SequencerSpecific=127]="SequencerSpecific",t}({}),Ku=class extends qu{get metaStatus(){return 47}},Qu=class extends Ku{data=new Uint8Array},Zu=class extends Ku{value=0},td=class extends qu{noteKey=0;pitch=0},ed=function(t){return t[t.SystemExclusive=240]="SystemExclusive",t[t.MtcQuarterFrame=241]="MtcQuarterFrame",t[t.SongPosition=242]="SongPosition",t[t.SongSelect=243]="SongSelect",t[t.TuneRequest=246]="TuneRequest",t[t.SystemExclusive2=247]="SystemExclusive2",t}({}),sd=class extends qu{},id=function(t){return t[t.MetronomeTick=0]="MetronomeTick",t[t.Rest=1]="Rest",t}({}),nd=class extends sd{static AlphaTabManufacturerId=125;data=new Uint8Array;get isMetronome(){return!1}get metronomeNumerator(){return-1}get metronomeDurationInTicks(){return-1}get metronomeDurationInMilliseconds(){return-1}get isRest(){return!1}get manufacturerId(){return 0}},rd=s({AlphaSynthMidiFileHandler:()=>Ma,AlphaTabMetronomeEvent:()=>Tn,AlphaTabRestEvent:()=>Mn,AlphaTabSysExEvent:()=>xn,AlphaTabSystemExclusiveEvents:()=>id,BeatTickLookup:()=>Ca,BeatTickLookupItem:()=>Pa,ControlChangeEvent:()=>Cn,ControllerType:()=>da,DeprecatedMidiEvent:()=>qu,EndOfTrackEvent:()=>Ln,MasterBarTickLookup:()=>Fa,MasterBarTickLookupTempoChange:()=>Ea,MetaDataEvent:()=>Qu,MetaEvent:()=>Ku,MetaEventType:()=>Yu,MetaNumberEvent:()=>Zu,Midi20PerNotePitchBendEvent:()=>td,MidiEvent:()=>Bn,MidiEventType:()=>Sn,MidiFile:()=>kn,MidiFileFormat:()=>wn,MidiFileGenerator:()=>$a,MidiTickLookup:()=>Ra,MidiTickLookupFindBeatResult:()=>La,MidiTickLookupFindBeatResultCursorMode:()=>Da,MidiTrack:()=>yn,NoteBendEvent:()=>Dn,NoteEvent:()=>vn,NoteOffEvent:()=>Pn,NoteOnEvent:()=>Nn,PitchBendEvent:()=>An,ProgramChangeEvent:()=>En,SystemCommonEvent:()=>sd,SystemCommonType:()=>ed,SystemExclusiveEvent:()=>nd,TempoChangeEvent:()=>Fn,TimeSignatureEvent:()=>_n}),ad=s({AccentuationType:()=>k,AccidentalType:()=>I,Automation:()=>d,AutomationType:()=>l,BackingTrack:()=>Ts,Bar:()=>Y,BarLineStyle:()=>q,BarNumberDisplay:()=>nt,BarStyle:()=>J,BarSubElement:()=>j,BarreShape:()=>It,BeamingRules:()=>Q,Beat:()=>Xt,BeatBeamingMode:()=>Vt,BeatStyle:()=>Ut,BeatSubElement:()=>zt,BendPoint:()=>f,BendStyle:()=>p,BendType:()=>b,BracketExtendMode:()=>tt,BrushType:()=>m,Chord:()=>ye,Clef:()=>G,Color:()=>Se,CrescendoType:()=>g,Direction:()=>ys,Duration:()=>w,DynamicValue:()=>o,ElementStyle:()=>$,FadeType:()=>Rt,Fermata:()=>_e,FermataType:()=>Be,Fingers:()=>S,Font:()=>hi,FontStyle:()=>ri,FontWeight:()=>ai,GolpeType:()=>Wt,GraceGroup:()=>ht,GraceType:()=>y,HarmonicType:()=>B,HeaderFooterStyle:()=>mt,InstrumentArticulation:()=>vt,JsonConverter:()=>Wn,KeySignature:()=>V,KeySignatureType:()=>z,Lyrics:()=>xe,MasterBar:()=>Z,MusicFontSymbol:()=>xt,Note:()=>At,NoteAccidentalMode:()=>_,NoteOrnament:()=>Pt,NoteStyle:()=>Ft,NoteSubElement:()=>Et,Ottavia:()=>x,PickStroke:()=>_t,PlaybackInformation:()=>Ne,Rasgueado:()=>Gt,RenderStylesheet:()=>rt,RepeatGroup:()=>at,Score:()=>wt,ScoreStyle:()=>gt,ScoreSubElement:()=>bt,Section:()=>Te,SimileMark:()=>H,SlideInType:()=>T,SlideOutType:()=>M,Staff:()=>ve,SustainPedalMarker:()=>X,SustainPedalMarkerType:()=>U,SyncPointData:()=>u,TechniqueSymbolPlacement:()=>Mt,Track:()=>Ee,TrackNameMode:()=>st,TrackNameOrientation:()=>it,TrackNamePolicy:()=>et,TrackStyle:()=>Ce,TrackSubElement:()=>Pe,TremoloPickingEffect:()=>$t,TremoloPickingStyle:()=>Ht,TripletFeel:()=>K,Tuning:()=>Me,TupletGroup:()=>Dt,VibratoType:()=>P,Voice:()=>lt,VoiceStyle:()=>ct,VoiceSubElement:()=>ot,WahPedal:()=>Ot,WhammyType:()=>Lt}),hd=s({BarBounds:()=>Vn,BeamDirection:()=>Fe,BeatBounds:()=>zn,Bounds:()=>_s,BoundsLookup:()=>Jn,MasterBarBounds:()=>Un,NoteBounds:()=>Xn,RenderFinishedEventArgs:()=>ka,ScoreRenderer:()=>Sa,StaffSystemBounds:()=>jn}),od=s({CssFontSvgCanvas:()=>mh,Cursors:()=>Yn,FontSizeDefinition:()=>Ri,FontSizes:()=>Oi,MeasuredText:()=>ft,SvgCanvas:()=>bh,TextAlign:()=>ut,TextBaseline:()=>dt}),cd=s({ActiveBeatsChangedEventArgs:()=>nh,AlphaSynth:()=>ba,AlphaSynthAudioWorkletOutput:()=>xa,AlphaSynthBase:()=>pa,AlphaSynthScriptProcessorOutput:()=>Hi,AlphaSynthWebAudioOutputBase:()=>Ks,AlphaSynthWebWorkerApi:()=>$n,AudioExportChunk:()=>sr,AudioExportOptions:()=>er,BackingTrackSyncPoint:()=>nr,CircularSampleBuffer:()=>Gi,MidiEventsPlayedEventArgs:()=>Rn,PlaybackRange:()=>Aa,PlaybackRangeChangedEventArgs:()=>On,PlayerState:()=>In,PlayerStateChangedEventArgs:()=>Gn,PositionChangedEventArgs:()=>Hn}),ld=s({});Bu.isRunningInWorker?Bu.initializeWorker():Bu.isRunningInAudioWorklet?Bu.initializeAudioWorklet():Bu.initializeMain(t=>{if(Bu.webPlatform===Wi.NodeJs)throw new a(r.General,"Workers not yet supported in Node.js");if(Bu.webPlatform===Wi.BrowserModule||Bu.isWebPackBundled||Bu.isViteBundled){O.debug("AlphaTab","Creating webworker");try{return new Bu.alphaTabWorker(new Bu.alphaTabUrl("./alphaTab.worker.ts",{}.url),{type:"module"})}catch(t){O.debug("AlphaTab","ESM webworker construction with direct URL failed",t)}let e="";try{e=new Bu.alphaTabUrl("./alphaTab.worker.ts",{}.url);const t=`import ${JSON.stringify(e)}`,s=new Blob([t],{type:"application/javascript"});return new Worker(URL.createObjectURL(s),{type:"module"})}catch(t){O.debug("AlphaTab","ESM webworker construction with blob import failed",e,t)}try{if(!t.core.scriptFile)throw new Error("Could not detect alphaTab script file");e=t.core.scriptFile;const s=`import ${JSON.stringify(t.core.scriptFile)}`,i=new Blob([s],{type:"application/javascript"});return new Worker(URL.createObjectURL(i),{type:"module"})}catch(e){O.debug("AlphaTab","ESM webworker construction with blob import failed",t.core.scriptFile,e)}}if(!t.core.scriptFile)throw new a(r.General,"Could not detect alphaTab script file, cannot initialize renderer");try{O.debug("AlphaTab","Creating Blob worker");const e=`importScripts('${t.core.scriptFile}')`,s=new Blob([e],{type:"application/javascript"});return new Worker(URL.createObjectURL(s))}catch{return O.warning("Rendering","Could not create inline worker, fallback to normal worker"),new Worker(t.core.scriptFile)}},(t,e)=>{if(Bu.webPlatform===Wi.NodeJs)throw new a(r.General,"Audio Worklets not yet supported in Node.js");if(Bu.webPlatform===Wi.BrowserModule||Bu.isWebPackBundled||Bu.isViteBundled){O.debug("AlphaTab","Creating Module worklet");const{audioWorklet:e}=t;return e.addModule(new Bu.alphaTabUrl("./alphaTab.worklet.ts",{}.url))}return O.debug("AlphaTab","Creating Script worklet"),t.audioWorklet.addModule(e.core.scriptFile)}),t.AlphaTabApi=uh,t.AlphaTabApiBase=ch,t.AlphaTabError=a,t.AlphaTabErrorType=r,t.ConsoleLogger=R,t.CoreSettings=xu,t.DisplaySettings=ui,t.EngravingSettings=si,t.EngravingStemInfo=ei,t.Environment=Bu,t.ExporterSettings=Ei,t.FileLoadError=Qs,t.FingeringMode=E,t.FontFileFormat=_u,t.FormatError=ke,t.ImporterSettings=di,t.LayoutMode=Xs,t.LogLevel=W,t.Logger=O,t.NotationElement=A,t.NotationMode=F,t.NotationSettings=D,t.PlayerMode=gi,t.PlayerOutputMode=mi,t.PlayerSettings=wi,t.ProgressEventArgs=lh,t.RenderEngineFactory=Su,t.RenderingResources=oi,t.ResizeEventArgs=Ya,t.ScrollMode=fi,t.Settings=Fi,t.SlidePlaybackSettings=bi,t.StaveProfile=ci,t.SystemsLayoutMode=li,t.TabRhythmMode=C,t.VibratoPlaybackSettings=pi,t.WebPlatform=Wi,Object.defineProperty(t,"exporter",{enumerable:!0,get:function(){return Ju}}),Object.defineProperty(t,"importer",{enumerable:!0,get:function(){return Mu}}),Object.defineProperty(t,"io",{enumerable:!0,get:function(){return vu}}),Object.defineProperty(t,"json",{enumerable:!0,get:function(){return ld}}),t.meta=h,Object.defineProperty(t,"midi",{enumerable:!0,get:function(){return rd}}),Object.defineProperty(t,"model",{enumerable:!0,get:function(){return ad}}),Object.defineProperty(t,"platform",{enumerable:!0,get:function(){return od}}),Object.defineProperty(t,"rendering",{enumerable:!0,get:function(){return hd}}),Object.defineProperty(t,"synth",{enumerable:!0,get:function(){return cd}})});