PageSourceSearch

https://biancajagger.org/assets/alphaTab-BzZ4Et2f.js

js biancajagger.org collected 2026-10-02 07:42:42 UTC 1,214,374 bytes, 66 lines download raw bytes

vendor: 4,107 bytes, line 1
1class kh{_callback;_targets=new Set;constructor(e){this._callback=e,window.addEventListener("resize",this._onWindowResize.bind(this),!1)}observe(e){this._targets.add(e)}unobserve(e){this._targets.delete(e)}disconnect(){this._targets.clear()}_onWindowResize(){const e=[];for(const t of this._targets)e.push({target:t,contentRect:void 0,borderBoxSize:void 0,contentBoxSize:[],devicePixelContentBoxSize:[]});this._callback(e,this)}}class wh{_callback;_elements=[];_timer=null;constructor(e){this._callback=e,window.addEventListener("resize",()=>this._check,!0),document.addEventListener("scroll",()=>this._check,!0)}_check(){this._timer||(this._timer=setTimeout(()=>{this._doCheck(),this._timer=null},100))}observe(e){this._elements.indexOf(e)>=0||(this._elements.push(e),this._check())}unobserve(e){this._elements=this._elements.filter(t=>t!==e)}_doCheck(){const e=[];for(const t of this._elements){const s=t.getBoundingClientRect();s.top+s.height>=0&&s.top<=window.innerHeight&&s.left+s.width>=0&&s.left<=window.innerWidth&&e.push({target:t,isIntersecting:!0})}e.length&&this._callback(e,this)}}typeof Symbol.dispose>"u"&&(Symbol.dispose=Symbol("Symbol.dispose")),typeof window<"u"&&("ResizeObserver"in globalThis||(globalThis.ResizeObserver=kh),"IntersectionObserver"in globalThis||(globalThis.IntersectionObserver=wh),"replaceChildren"in Element.prototype||(Element.prototype.replaceChildren=function(...a){this.innerHTML="",this.append(...a)},Document.prototype.replaceChildren=Element.prototype.replaceChildren,DocumentFragment.prototype.replaceChildren=Element.prototype.replaceChildren)),"replaceAll"in String.prototype||(String.prototype.replaceAll=function(a,e){return this.replace(new RegExp(a,"g"),e)});var Ge;(function(a){a[a.General=0]="General",a[a.Format=1]="Format",a[a.AlphaTex=2]="AlphaTex"})(Ge||(Ge={}));class Ye extends Error{type;constructor(e,t="",s){super(t??"",{cause:s}),this.type=e}}class qi{static version="1.8.0";static date="2026-01-12T15:41:07.446Z";static commit="b3039f03e18398df334fd99c8ec92ea94c1ebea1";static print(e){e(`alphaTab ${qi.version}`),e(`commit: ${qi.commit}`),e(`build date: ${qi.date}`)}}var se;(function(a){a[a.PPP=0]="PPP",a[a.PP=1]="PP",a[a.P=2]="P",a[a.MP=3]="MP",a[a.MF=4]="MF",a[a.F=5]="F",a[a.FF=6]="FF",a[a.FFF=7]="FFF",a[a.PPPP=8]="PPPP",a[a.PPPPP=9]="PPPPP",a[a.PPPPPP=10]="PPPPPP",a[a.FFFF=11]="FFFF",a[a.FFFFF=12]="FFFFF",a[a.FFFFFF=13]="FFFFFF",a[a.SF=14]="SF",a[a.SFP=15]="SFP",a[a.SFPP=16]="SFPP",a[a.FP=17]="FP",a[a.RF=18]="RF",a[a.RFZ=19]="RFZ",a[a.SFZ=20]="SFZ",a[a.SFFZ=21]="SFFZ",a[a.FZ=22]="FZ",a[a.N=23]="N",a[a.PF=24]="PF",a[a.SFZP=25]="SFZP"})(se||(se={}));class B{static QuarterTime=960;static _minVelocity=15;static VelocityIncrement=16;static ticksToMillis(e,t){return e*(6e4/(t*B.QuarterTime))|0}static millisToTicks(e,t){return e/(6e4/(t*B.QuarterTime))|0}static toTicks(e){return B.valueToTicks(e)}static valueToTicks(e){let t=e;return t<0&&(t=1/-t),B.QuarterTime*(4/t)|0}static applyDot(e,t){return t?e+(e/4|0)*3:e+(e/2|0)}static applyTuplet(e,t,s){return e*s/t|0}static removeTuplet(e,t,s){return e*t/s|0}static dynamicToVelocity(e,t=0){let s=1;switch(e){case se.PPP:s=B._minVelocity+0*B.VelocityIncrement;break;case se.PP:s=B._minVelocity+1*B.VelocityIncrement;break;case se.P:s=B._minVelocity+2*B.VelocityIncrement;break;case se.MP:s=B._minVelocity+3*B.VelocityIncrement;break;case se.MF:s=B._minVelocity+4*B.VelocityIncrement;break;case se.F:s=B._minVelocity+5*B.VelocityIncrement;break;case se.FF:s=B._minVelocity+6*B.VelocityIncrement;break;case se.FFF:s=B._minVelocity+7*B.VelocityIncrement;break;case se.PPPP:s=10;break;case se.PPPPP:s=5;break;case se.PPPPPP:s=3;break;case se.FFFF:s=B._minVelocity+8*B.VelocityIncrement;break;case se.FFFFF:s=B._minVelocity+9*B.VelocityIncrement;break;case se.FFFFFF:s=B._minVelocity+10*B.VelocityIncrement;break;case se.SF:case se.SFP:case se.SFZP:case se.SFPP:case se.SFZ:case se.FZ:s=B._minVelocity+6*B.VelocityIncrement;break;case se.FP:s=B._minVelocity+5*B.VelocityIncrement;break;case se.RF:case se.RFZ:case se.SFFZ:s=B._minVelocity+5*B.VelocityIncrement;break;case se.N:s=1;break;
1case se.PF:s=B._minVelocity+(4.5*B.VelocityIncrement|0);break}return s+=t*B.VelocityIncrement,Math.min(Math.max(s,1),127)}}var Re;(function(a){a[a.Tempo=0]="Tempo",a[a.Volume=1]="Volume",a[a.Instrument=2]="Instrument",a[a.Balance=3]="Balance",a[a.SyncPoint=4]="SyncPoint",a[a.Bank=4]="Bank"})(Re||(Re={}));class ra{barOccurence=0;millisecondOffset=0}class tt{isLinear=!1;type=Re.Tempo;value=0;syncPointValue;ratioPosition=0;text="";isVisible=!0;static buildTempoAutomation(e,t,s,i,r=!0){(i<1||i>5)&&(i=2);const n=new Float32Array([1,.5,1,1.5,2,3]),o=new tt;return o.type=Re.Tempo,o.isLinear=e,o.ratioPosition=t,o.value=s*n[i],o.isVisible=r,o}static buildInstrumentAutomation(e,t,s){const i=new tt;return i.type=Re.Instrument,i.isLinear=e,i.ratioPosition=t,i.value=s,i}}class G{static MaxPosition=60;static MaxValue=12;offset;value;constructor(e=0,t=0){this.offset=e,this.value=t}}var Ke;(function(a){a[a.Default=0]="Default",a[a.Gradual=1]="Gradual",a[a.Fast=2]="Fast"})(Ke||(Ke={}));var $;(function(a){a[a.None=0]="None",a[a.Custom=1]="Custom",a[a.Bend=2]="Bend",a[a.Release=3]="Release",a[a.BendRelease=4]="Ben
1dRelease",a[a.Hold=5]="Hold",a[a.Prebend=6]="Prebend",a[a.PrebendBend=7]="PrebendBend",a[a.PrebendRelease=8]="PrebendRelease"})($||($={}));var z;(function(a){a[a.None=0]="None",a[a.BrushUp=1]="BrushUp",a[a.BrushDown=2]="BrushDown",a[a.ArpeggioUp=3]="ArpeggioUp",a[a.ArpeggioDown=4]="ArpeggioDown"})(z||(z={}));var Gt;(function(a){a[a.None=0]="None",a[a.Crescendo=1]="Crescendo",a[a.Decrescendo=2]="Decrescendo"})(Gt||(Gt={}));var y;(function(a){a[a.QuadrupleWhole=-4]="QuadrupleWhole",a[a.DoubleWhole=-2]="DoubleWhole",a[a.Whole=1]="Whole",a[a.Half=2]="Half",a[a.Quarter=4]="Quarter",a[a.Eighth=8]="Eighth",a[a.Sixteenth=16]="Sixteenth",a[a.ThirtySecond=32]="ThirtySecond",a[a.SixtyFourth=64]="SixtyFourth",a[a.OneHundredTwentyEighth=128]="OneHundredTwentyEighth",a[a.TwoHundredFiftySixth=256]="TwoHundredFiftySixth"})(y||(y={}));var K;(function(a){a[a.None=0]="None",a[a.OnBeat=1]="OnBeat",a[a.BeforeBeat=2]="BeforeBeat",a[a.BendGrace=3]="BendGrace"})(K||(K={}));var ct;(function(a){a[a.None=0]="None",a[a.Normal=1]="Normal",a[a.Heavy=2]="Heavy",a[a.Tenuto=3]="Tenuto"})(ct||(ct={}));var ie;(function(a){a[a.Unknown=-2]="Unknown",a[a.NoOrDead=-1]="NoOrDead",a[a.Thumb=0]="Thumb",a[a.IndexFinger=1]="IndexFinger",a[a.MiddleFinger=2]="MiddleFinger",a[a.AnnularFinger=3]="AnnularFinger",a[a.LittleFinger=4]="LittleFinger"})(ie||(ie={}));var te;(function(a){a[a.None=0]="None",a[a.Natural=1]="Natural",a[a.Artificial=2]="Artificial",a[a.Pinch=3]="Pinch",a[a.Tap=4]="Tap",a[a.Semi=5]="Semi",a[a.Feedback=6]="Feedback"})(te||(te={}));var oe;(function(a){a[a.Default=0]="Default",a[a.ForceNone=1]="ForceNone",a[a.ForceNatural=2]="ForceNatural",a[a.ForceSharp=3]="ForceSharp",a[a.ForceDoubleSharp=4]="ForceDoubleSharp",a[a.ForceFlat=5]="ForceFlat",a[a.ForceDoubleFlat=6]="ForceDoubleFlat"})(oe||(oe={}));var le;(function(a){a[a._15ma=0]="_15ma",a[a._8va=1]="_8va",a[a.Regular=2]="Regular",a[a._8vb=3]="_8vb",a[a._15mb=4]="_15mb"})(le||(le={}));var St;(function(a){a[a.None=0]="None",a[a.IntoFromBelow=1]="IntoFromBelow",a[a.IntoFromAbove=2]="IntoFromAbove"})(St||(St={}));var he;(function(a){a[a.None=0]="None",a[a.Shift=1]="Shift",a[a.Legato=2]="Legato",a[a.OutUp=3]="OutUp",a[a.OutDown=4]="OutDown",a[a.PickSlideDown=5]="PickSlideDown",a[a.PickSlideUp=6]="PickSlideUp"})(he||(he={}));var Be;(function(a){a[a.None=0]="None",a[a.Slight=1]="Slight",a[a.Wide=2]="Wide"})(Be||(Be={}));var Cs;(function(a){a[a.Hidden=0]="Hidden",a[a.ShowWithBeams=1]="ShowWithBeams",a[a.ShowWithBars=2]="ShowWithBars",a[a.Automatic=3]="Automatic"})(Cs||(Cs={}));var Xs;(function(a){a[a.ScoreDefault=0]="ScoreDefault",a[a.ScoreForcePiano=1]="ScoreForcePiano",a[a.SingleNoteEffectBand=2]="SingleNoteEffectBand",a[a.SingleNoteEffectBandForcePiano=3]="SingleNoteEffectBandForcePiano"})(Xs||(Xs={}));var Vt;(function(a){a[a.GuitarPro=0]="GuitarPro",a[a.SongBook=1]="SongBook"})(Vt||(Vt={}));var C;(function(a){a[a.ScoreTitle=0]="ScoreTitle",a[a.ScoreSubTitle=1]="ScoreSubTitle",a[a.ScoreArtist=2]="ScoreArtist",a[a.ScoreAlbum=3]="ScoreAlbum",a[a.ScoreWords=4]="ScoreWords",a[a.ScoreMusic=5]="ScoreMusic",a[a.ScoreWordsAndMusic=6]="ScoreWordsAndMusic",a[a.ScoreCopyright=7]="ScoreCopyright",a[a.GuitarTuning=8]="GuitarTuning",a[a.TrackNames=9]="TrackNames",a[a.ChordDiagrams=10]="ChordDiagrams",a[a.ParenthesisOnTiedBends=11]="ParenthesisOnTiedBends",a[a.TabNotesOnTiedBends=12]="TabNotesOnTiedBends",a[a.ZerosOnDiveWhammys=13]="ZerosOnDiveWhammys",a[a.EffectAlternateEndings=14]="EffectAlternateEndings",a[a.EffectCapo=15]="EffectCapo",a[a.EffectChordNames=16]="EffectChordNames",a[a.EffectCrescendo=17]="EffectCrescendo",a[a.EffectDynamics=18]="EffectDynamics",a[a.EffectFadeIn=19]="EffectFadeIn",a[a.EffectFermata=20]="EffectFermata",a[a.EffectFingering=21]="EffectFingering",a[a.EffectHarmonics=22]="EffectHarmonics",a[a.EffectLetRing=23]="EffectLetRing",a[a.EffectLyrics=24]="EffectLyrics",a[a.EffectMarker=25]="EffectMarker",a[a.EffectOttavia=26]="EffectOttavia",a[a.EffectPalmMute=27]="EffectPalmMute",a[a.EffectPickSlide=28]="EffectPickSlide",a[a.EffectPickStroke=29]="EffectPickStroke",a[a.EffectSlightBeatVibrato=30]="EffectSlightBeatVibrato",a[a.EffectSlightNoteVibrato=31]="EffectSlightNoteVibrato",a[a.EffectTap=32]="EffectTap",a[a.EffectTempo=33]="Effe
1ctTempo",a[a.EffectText=34]="EffectText",a[a.EffectTrill=35]="EffectTrill",a[a.EffectTripletFeel=36]="EffectTripletFeel",a[a.EffectWhammyBar=37]="EffectWhammyBar",a[a.EffectWideBeatVibrato=38]="EffectWideBeatVibrato",a[a.EffectWideNoteVibrato=39]="EffectWideNoteVibrato",a[a.EffectLeftHandTap=40]="EffectLeftHandTap",a[a.EffectFreeTime=41]="EffectFreeTime",a[a.EffectSustainPedal=42]="EffectSustainPedal",a[a.EffectGolpe=43]="EffectGolpe",a[a.EffectWahPedal=44]="EffectWahPedal",a[a.EffectBeatBarre=45]="EffectBeatBarre",a[a.EffectNoteOrnament=46]="EffectNoteOrnament",a[a.EffectRasgueado=47]="EffectRasgueado",a[a.EffectDirections=48]="EffectDirections",a[a.EffectBeatTimer=49]="EffectBeatTimer",a[a.EffectWhammyBarLine=50]="EffectWhammyBarLine",a[a.EffectNumberedNotationKeySignature=51]="EffectNumberedNotationKeySignature",a[a.ChordDiagramFretboardNumbers=52]="ChordDiagramFretboardNumbers",a[a.BarNumber=53]="BarNumber",a[a.RepeatCount=54]="RepeatCount",a[a.ScoreBendSlur=55]="ScoreBendSlur"})(C||(C={}));class ya{notationMode=Vt.GuitarPro;fingeringMode=Xs.ScoreDefault;elements=new Map;static defaultElements=new Map([[C.ZerosOnDiveWhammys,!1]]);rhythmMode=Cs.Automatic;rhythmHeight=25;transpositionPitches=[];displayTranspositionPitches=[];smallGraceTabNotes=!0;extendBendArrowsOnTiedNotes=!0;extendLineEffectsToBeatEnd=!1;slurHeight=5;isNotationElementVisible(e){return this.elements.has(e)?this.elements.get(e):ya.defaultElements.has(e)?ya.defaultElements.get(e):!0}}class mr{_factory;_value=void 0;get hasValue(){return this._value!==void 0}constructor(e){this._factory=e}get value(){return this._value===void 0&&(this._value=this._factory()),this._value}reset(){this._value=void 0}}var Hs;(function(a){a[a.None=0]="None",a[a.Debug=1]="Debug",a[a.Info=2]="Info",a[a.Warning=3]="Warning",a[a.Error=4]="Error"})(Hs||(Hs={}));class or{static logLevel=Hs.Info;static _format(e,t){return`[AlphaTab][${e}] ${t}`}debug(e,t,...s){console.debug(or._format(e,t),...s)}warning(e,t,...s){console.warn(or._format(e,t),...s)}info(e,t,...s){console.info(or._format(e,t),...s)}error(e,t,...s){console.error(or._format(e,t),...s)}}class E{static logLevel=Hs.Info;static log=new or;static _shouldLog(e){return E.logLevel!==Hs.None&&e>=E.logLevel}static debug(e,t,...s){E._shouldLog(Hs.Debug)&&E.log.debug(e,t,...s)}static warning(e,t,...s){E._shouldLog(Hs.Warning)&&E.log.warning(e,t,...s)}static info(e,t,...s){E._shouldLog(Hs.Info)&&E.log.info(e,t,...s)}static error(e,t,...s){E._shouldLog(Hs.Error)&&E.log.error(e,t,...s)}}var ee;(function(a){a[a.None=0]="None",a[a.Natural=1]="Natural",a[a.Sharp=2]="Sharp",a[a.Flat=3]="Flat",a[a.NaturalQuarterNoteUp=4]="NaturalQuarterNoteUp",a[a.SharpQuarterNoteUp=5]="SharpQuarterNoteUp",a[a.FlatQuarterNoteUp=6]="FlatQuarterNoteUp",a[a.DoubleSharp=7]="DoubleSharp",a[a.DoubleFlat=8]="DoubleFlat"})(ee||(ee={}));var ve;(function(a){a[a.Neutral=0]="Neutral",a[a.C3=1]="C3",a[a.C4=2]="C4",a[a.F4=3]="F4",a[a.G2=4]="G2"})(ve||(ve={}));var xt;(function(a){a[a.None=0]="None",a[a.Simple=1]="Simple",a[a.FirstOfDouble=2]="FirstOfDouble",a[a.SecondOfDouble=3]="SecondOfDouble"})(xt||(xt={}));class tr{colors=new Map}var qe;(function(a){a[a.Cb=-7]="Cb",a[a.Gb=-6]="Gb",a[a.Db=-5]="Db",a[a.Ab=-4]="Ab",a[a.Eb=-3]="Eb",a[a.Bb=-2]="Bb",a[a.F=-1]="F",a[a.C=0]="C",a[a.G=1]="G",a[a.D=2]="D",a[a.A=3]="A",a[a.E=4]="E",a[a.B=5]="B",a[a.FSharp=6]="FSharp",a[a.CSharp=7]="CSharp"})(qe||(qe={}));var as;(function(a){a[a.Major=0]="Major",a[a.Minor=1]="Minor"})(as||(as={}));var it;(function(a){a[a.Down=0]="Down",a[a.Hold=1]="Hold",a[a.Up=2]="Up"})(it||(it={}));class _i{ratioPosition=0;pedalType=it.Down;bar;nextPedalMarker=null;previousPedalMarker=null}var Le;(function(a){a[a.StandardNotationRepeats=0]="StandardNotationRepeats",a[a.GuitarTabsRepeats=1]="GuitarTabsRepeats",a[a.SlashRepeats=2]="SlashRepeats",a[a.NumberedRepeats=3]="NumberedRepeats",a[a.StandardNotationBarNumber=4]="StandardNotationBarNumber",a[a.GuitarTabsBarNumber=5]="GuitarTabsBarNumber",a[a.SlashBarNumber=6]="SlashBarNumber",a[a.NumberedBarNumber=7]="NumberedBarNumber",a[a.StandardNotationBarLines=8]="StandardNotationBarLines",a[a.GuitarTabsBarLines=9]="GuitarTabsBarLines",a[a.SlashBarLines=10]="SlashBarLines",a[a.NumberedBarLines=11]="NumberedBarLines",a[a.StandardNotationClef=12]="StandardNotationClef",a[a.GuitarTabsClef=13]="GuitarTabsClef",a[a.StandardNotationKeySignature=14]="StandardNotationKeySignature",a[a.NumberedKeySignature=15]="NumberedKeySignature",a[a.StandardNotationTimeSignature=16]="StandardNotationTimeSignature",a[a.GuitarTabsTimeSignature=17]="GuitarTabsTimeSignature",a[a.SlashTimeSignature=18]="SlashTimeSignature",a[a.NumberedTimeSignature=19]="NumberedTimeSignature",a[a.StandardNotationStaffLine=20]="StandardNotationStaffLine",a[a.GuitarTabsStaffLine=21]="GuitarTabsStaffLine",a[a.SlashStaffLine=22]="SlashStaffLine",a[a.NumberedStaffLine=23]="NumberedStaffLine"})(Le||(Le={}));class Vl extends tr{}var ye;(function(a){a[a.Automatic=0]="Automatic",a[a.Dashed=1]="Dashed",a[a.Dotted=2]="Dotted",a[a.Heavy=3]="Heavy",a[a.HeavyHeavy=4]="HeavyHeavy",a[a.HeavyLight=5]="HeavyLight",a[a.LightHeavy=6]="LightHeavy",a[a.LightLight=7]="LightLight",a[a.None=8]="None",a[a.Regular=9]="Regular",a[a.Short=10]="Short",a[a.Tick=11]="Tick"})(ye||(ye={}));
1class ns{static _globalBarId=0;static resetIds(){ns._globalBarId=0}id=ns._globalBarId++;index=0;nextBar=null;previousBar=null;clef=ve.G2;clefOttava=le.Regular;staff;voices=[];simileMark=xt.None;_filledVoices=new Set([0]);get isMultiVoice(){return this._filledVoices.size>1}get filledVoices(){return this._filledVoices}displayScale=1;displayWidth=-1;sustainPedals=[];get masterBar(){return this.staff.track.score.masterBars[this.index]}_isEmpty=!0;_isRestOnly=!0;get isEmpty(){return this._isEmpty}get hasChanges(){return this.index===0||this.keySignature!==this.previousBar.keySignature||this.keySignatureType!==this.previousBar.keySignatureType||this.clef!==this.previousBar.clef||this.clefOttava!==this.previousBar.clefOttava?!0:this.simileMark!==xt.None||this.sustainPedals.length>0||this.barLineLeft!==ye.Automatic||this.barLineRight!==ye.Automatic}get isRestOnly(){return this._isRestOnly}barLineLeft=ye.Automatic;barLineRight=ye.Automatic;keySignature=qe.C;keySignatureType=as.Major;barNumberDisplay;shortestDuration=y.DoubleWhole;getActualBarLineLeft(e){return ns._actualBarLine(this,!1,e)}getActualBarLineRight(){return ns._actualBarLine(this,!0,!1)}static _automaticToActualType(e,t,s){let i;return t?e.isRepeatEnd?i=ye.LightHeavy:e.nextMasterBar?e.isFreeTime?i=ye.Dashed:e.isDoubleBar?i=ye.LightLight:i=ye.Regular:i=ye.LightHeavy:e.isRepeatStart?i=ye.HeavyLight:s?i=ye.Regular:i=ye.None,i}static _actualBarLine(e,t,s){const i=e.masterBar,r=t?e.barLineRight:e.barLineLeft;let n;return r===ye.Automatic?n=ns._automaticToActualType(i,t,s):n=r,n}style;addVoice(e){e.bar=this,e.index=this.voices.length,this.voices.push(e)}finish(e,t=null){this._filledVoices.clear(),this._filledVoices.add(0),this._isEmpty=!0,this._isRestOnly=!0,this.shortestDuration=y.DoubleWhole;for(let i=0,r=this.voices.length;i<r;i++){const n=this.voices[i];n.finish(e,t),n.isEmpty||(this._isEmpty=!1,this._filledVoices.add(i),n.shortestDuration>this.shortestDuration&&(this.shortestDuration=n.shortestDuration)),n.isRestOnly||(this._isRestOnly=!1)}const s=this.sustainPedals;if(s.length>0){let i=null;this.sustainPedals=[],this.previousBar&&this.previousBar.sustainPedals.length>0&&(i=this.previousBar.sustainPedals[this.previousBar.sustainPedals.length-1],i.pedalType===it.Up&&(i=null));const r=i!==null&&i.pedalType!==it.Up;for(const n of s){if(i&&i.pedalType!==it.Up){if(i.bar===this&&n.ratioPosition<=i.ratioPosition)continue;i.nextPedalMarker=n,n.previousPedalMarker=i}r&&n.pedalType===it.Down&&(n.pedalType=it.Hold),n.bar=this,this.sustainPedals.push(n),i=n}}else if(this.previousBar&&this.previousBar.sustainPedals.length>0){const i=this.previousBar.sustainPedals[this.previousBar.sustainPedals.length-1];if(i.pedalType!==it.Up){const r=new _i;r.ratioPosition=0,r.bar=this,r.pedalType=it.Hold,this.sustainPedals.push(r),i.nextPedalMarker=r,r.previousPedalMarker=i}}}calculateDuration(){let e=0;for(const t of this.voices){const s=t.calculateDuration();s>e&&(e=s)}return e}}var Ce;(function(a){a[a.NoTripletFeel=0]="NoTripletFeel",a[a.Triplet16th=1]="Triplet16th",a[a.Triplet8th=2]="Triplet8th",a[a.Dotted16th=3]="Dotted16th",a[a.Dotted8th=4]="Dotted8th",a[a.Scottish16th=5]="Scottish16th",a[a.Scottish8th=6]="Scottish8th"})(Ce||(Ce={}));class nt{_singleGroupKey;groups=new Map;uniqueId="";timeSignatureNumerator=0;timeSignatureDenominator=0;static createSimple(e,t,s,i){const r=new nt;return r.timeSignatureNumerator=e,r.timeSignatureDenominator=t,r.groups.set(s,i),r.finish(),r}findRule(e){const t=this._singleGroupKey;if(t)return[t,this.groups.get(t)];if(e<y.Quarter)return[e,[]];let s=e;do{const i=s;
1if(this.groups.has(i))return[i,this.groups.get(i)];s=s*2}while(s<=y.TwoHundredFiftySixth);s=e/2;do{const i=s;if(this.groups.has(i))return[i,this.groups.get(i)];s=s/2}while(s>y.Half);return[e,[]]}finish(){let e=`${this.timeSignatureNumerator}_${this.timeSignatureDenominator}`;for(const[t,s]of this.groups){e+=`__${t}`;let i=s.length;for(let r=s.length-1;r>=0&&s[r]===0;r--)i=r;i<s.length&&s.splice(i,s.length-i),e+=`_${s.join("_")}`,this.groups.size===1&&(this._singleGroupKey=t)}this.uniqueId=e}}class Qs{static MaxAlternateEndings=8;alternateEndings=0;nextMasterBar=null;previousMasterBar=null;index=0;get hasChanges(){return this.index===0?!1:this.timeSignatureCommon!==this.previousMasterBar.timeSignatureCommon||this.timeSignatureNumerator!==this.previousMasterBar.timeSignatureNumerator||this.timeSignatureDenominator!==this.previousMasterBar.timeSignatureDenominator||this.tripletFeel!==this.previousMasterBar.tripletFeel?!0:this.alternateEndings!==0||this.isRepeatStart||this.isRepeatEnd||this.isFreeTime||this.isSectionStart||this.tempoAutomations.length>0||this.syncPoints&&this.syncPoints.length>0||this.fermata!==null&&this.fermata.size>0||this.directions!==null&&this.directions.size>0||this.isAnacrusis}get keySignature(){return this.score.tracks[0].staves[0].bars[this.index].keySignature}set keySignature(e){this.score.tracks[0].staves[0].bars[this.index].keySignature=e}get keySignatureType(){return this.score.tracks[0].staves[0].bars[this.index].keySignatureType}set keySignatureType(e){this.score.tracks[0].staves[0].bars[this.index].keySignatureType=e}isDoubleBar=!1;isRepeatStart=!1;get isRepeatEnd(){return this.repeatCount>0}repeatCount=0;repeatGroup;timeSignatureNumerator=4;timeSignatureDenominator=4;timeSignatureCommon=!1;beamingRules;actualBeamingRules;isFreeTime=!1;tripletFeel=Ce.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(e=!0){if(this.isAnacrusis&&e){let t=0;for(const s of this.score.tracks)for(const i of s.staves){const r=this.index<i.bars.length?i.bars[this.index].calculateDuration():0;r>t&&(t=r)}return t}return this.timeSignatureNumerator*B.valueToTicks(this.timeSignatureDenominator)}addFermata(e,t){let s=this.fermata;s===null&&(s=new Map,this.fermata=s),s.set(e,t)}addDirection(e){this.directions==null&&(this.directions=new Set),this.directions.add(e)}getFermata(e){const t=this.fermata;return t===null?null:t.has(e.playbackStart)?t.get(e.playbackStart):e.index===0&&t.has(0)?t.get(0):null}addSyncPoint(e){this.syncPoints||(this.syncPoints=[]),this.syncPoints.push(e)}finish(e){let t=this.beamingRules;if(t&&(t.timeSignatureNumerator=this.timeSignatureNumerator,t.timeSignatureDenominator=this.timeSignatureDenominator,t.finish()),this.index>0){this.start=this.previousMasterBar.start+this.previousMasterBar.calculateDuration();const s=e.has("beamingRules")?e.get("beamingRules"):void 0;s&&s.uniqueId===t?.uniqueId?(this.beamingRules=void 0,t=s):t||(t=s)}this.actualBeamingRules=t,this.beamingRules&&e.set("beamingRules",t)}}var Fi;(function(a){a[a.NoBrackets=0]="NoBrackets",a[a.GroupStaves=1]="GroupStaves",a[a.GroupSimilarInstruments=2]="GroupSimilarInstruments"})(Fi||(Fi={}));var mt;(function(a){a[a.Hidden=0]="Hidden",a[a.FirstSystem=1]="FirstSystem",a[a.AllSystems=2]="AllSystems"})(mt||(mt={}));var Qt;(function(a){a[a.FullName=0]="FullName",a[a.ShortName=1]="ShortName"})(Qt||(Qt={}));var Kt;(function(a){a[a.Horizontal=0]="Horizontal",a[a.Vertical=1]="Vertical"})(Kt||(Kt={}));var vt;(function(a){a[a.AllBars=0]="AllBars",a[a.FirstOfSystem=1]="FirstOfSystem",a[a.Hide=2]="Hide"})(vt||(vt={}));class Hl{hideDynamics=!1;bracketExtendMode=Fi.GroupStaves;useSystemSignSeparator=!1;globalDisplayTuning=!0;perTrackDisplayTuning=null;globalDisplayChordDiagramsOnTop=!0;perTrackChordDiagramsOnTop=null;globalDisplayChordDiagramsInScore=!1;singleTrackTrackNamePolicy=mt.FirstSystem;multiTrackTrackNamePolicy=mt.FirstSystem;firstSystemTrackNameMode=Qt.ShortName;otherSystemsTrackNameMode=Qt.ShortName;firstSystemTrackNameOrientation=Kt.Vertical;otherSystemsTrackNameOrientation=Kt.Vertical;multiTrackMultiBarRest=!1;perTrackMultiBarRest=null;extendBarLines=!1;hideEmptyStaves=!1;hideEmptyStavesInFirstSystem=!1;showSingleStaffBrackets=!1;
1barNumberDisplay=vt.AllBars}class Rn{masterBars=[];opening=null;get openings(){const e=this.opening;return e?[e]:[]}closings=[];get isOpened(){return this.opening?.isRepeatStart===!0}isClosed=!1;addMasterBar(e){this.opening===null&&(this.opening=e),this.masterBars.push(e),e.repeatGroup=this,e.isRepeatEnd&&(this.closings.push(e),this.isClosed=!0)}}class ba{beats=[];id="empty";isComplete=!1;addBeat(e){e.graceIndex=this.beats.length,e.graceGroup=this,this.beats.push(e)}finish(){this.beats.length>0&&(this.id=`${this.beats[0].absoluteDisplayStart}_${this.beats[0].voice.index}`)}}var yr;(function(a){a[a.Glyphs=0]="Glyphs"})(yr||(yr={}));class Gl extends tr{}let ks=class On{_beatLookup;_isEmpty=!0;_isRestOnly=!0;static _globalVoiceId=0;static resetIds(){On._globalVoiceId=0}id=On._globalVoiceId++;index=0;bar;beats=[];get isEmpty(){return this._isEmpty}style;forceNonEmpty(){this._isEmpty=!1}get isRestOnly(){return this._isRestOnly}shortestDuration=y.DoubleWhole;insertBeat(e,t){t.nextBeat=e.nextBeat,t.nextBeat&&(t.nextBeat.previousBeat=t),t.previousBeat=e,t.voice=this,e.nextBeat=t,this.beats.splice(e.index+1,0,t)}addBeat(e){e.voice=this,e.index=this.beats.length,this.beats.push(e),e.isEmpty||(this._isEmpty=!1),e.isRest||(this._isRestOnly=!1)}_chain(e,t=null){if(this.bar){if(e.index<this.beats.length-1)e.nextBeat=this.beats[e.index+1],e.nextBeat.previousBeat=e;else if(e.isLastOfVoice&&e.voice.bar.nextBar){const s=this.bar.nextBar.voices[this.index];s.beats.length>0&&(e.nextBeat=s.beats[0]),e.nextBeat.previousBeat=e}e.chain(t)}}addGraceBeat(e){if(this.beats.length===0){this.addBeat(e);return}const t=this.beats[this.beats.length-1];this.beats.splice(this.beats.length-1,1),this.addBeat(e),this.addBeat(t),this._isEmpty=!1,this._isRestOnly=!1}getBeatAtPlaybackStart(e){return this._beatLookup.has(e)?this._beatLookup.get(e):null}finish(e,t=null){this._isEmpty=!0,this._isRestOnly=!0,this._beatLookup=new Map;let s=null;for(let n=0;n<this.beats.length;n++){const o=this.beats[n];o.index=n,this._chain(o,t),o.graceType===K.None?(o.graceGroup=s,s&&(s.isComplete=!0),s=null):(s||(s=new ba),s.addBeat(o)),o.isEmpty||(this._isEmpty=!1),o.isRest||(this._isRestOnly=!1)}let i=0,r=0;this.shortestDuration=y.DoubleWhole;for(let n=0;n<this.beats.length;n++){const o=this.beats[n];if(o.index=n,o.finish(e,t),o.graceType===K.None){if(o.duration>this.shortestDuration&&(this.shortestDuration=o.duration),o.graceGroup){const l=o.graceGroup.beats[0],h=o.graceGroup.beats[o.graceGroup.beats.length-1];if(l.graceType!==K.BendGrace){const c=h.playbackStart+h.playbackDuration-l.playbackStart;switch(l.graceType){case K.BeforeBeat:l.previousBeat?(l.previousBeat.playbackDuration-=c,l.previousBeat.voice===this?r=l.previousBeat.playbackStart+l.previousBeat.playbackDuration:r=-c):r=-c;for(const d of o.graceGroup.beats)this._beatLookup.delete(d.playbackStart),d.playbackStart=r,this._beatLookup.set(d.playbackStart,o),r+=d.playbackDuration;break;case K.OnBeat:o.playbackDuration-=c,h.voice===this?r=h.playbackStart+h.playbackDuration:r=-c;break}}}o.displayStart=i,o.playbackStart=r,this._beatLookup.set(o.playbackStart,o)}else o.displayStart=i,o.playbackStart=r;o.fermata?this.bar.masterBar.addFermata(o.playbackStart,o.fermata):o.fermata=this.bar.masterBar.getFermata(o),o.finishTuplet(),o.graceGroup&&o.graceGroup.finish(),i+=o.displayDuration,r+=o.playbackDuration}}calculateDuration(){if(this.isEmpty||this.beats.length===0)return 0;const e=this.beats[this.beats.length-1],t=this.beats[0];return e.playbackStart+e.playbackDuration-t.playbackStart}};var Y;(function(a){a[a.Left=0]="Left",a[a.Center=1]="Center",a[a.Right=2]="Right"})(Y||(Y={}));var He;(function(a){a[a.Top=0]="Top",a[a.Middle=1]="Middle",a[a.Bottom=2]="Bottom",a[a.Alphabetic=3]="Alphabetic"})(He||(He={}));class aa{width;height;constructor(e,t){this.width=e,this.height=t}}class pt{static fillMusicFontSymbolSafe(e,t,s,i,r,n){e.settings.display.resources.engravingSettings.hasSymbol(r)&&e.fillMusicFontSymbol(t,s,i,r,n)}static fillMusicFontSymbolsSafe(e,t,s,i,r,n){const o=r.filter(l=>e.settings.display.resources.engravingSettings.hasSymbol(l));o.length!==0&&e.fillMusicFontSymbols(t,s,i,o,n)}}var H;(function(a){a[a.Title=0]="Title",a[a.SubTitle=1]="SubTitle",a[a.Artist=2]="Artist",a[a.Album=3]="Album",a[a.Words=4]="Words",a[a.Music=5]="Music",a[a.WordsAndMusic=6]="WordsAndMusic",a[a.Transcriber=7]="Transcriber",a[a.Copyright=8]="Copyright",a[a.CopyrightSecondLine=9]="CopyrightSecondLine",a[a.ChordDiagramList=10]="ChordDiagramList"})(H||(H={}));class hs{template;isVisible;textAlign;constructor(e="",t=void 0,s=Y.Left){this.template=e,this.isVisible=t,this.textAlign=s}static equals(e,t){const s=e.isVisible!==void 0?e.isVisible:!0,i=t.isVisible!==void 0?t.isVisible:!0;return!(s!==i||e.template!==t.template||e.textAlign!==t.textAlign)}buildText(e){let t=!1,s=!1;const i=this.template.replace(hs._placeholderPattern,(r,n)=>{s=!0;let o="";switch(n){case"TITLE":o=e.title;break;case"SUBTITLE":o=e.subTitle;break;case"ARTIST":o=e.artist;break;case"ALBUM":o=e.album;break;case"WORDS":case"WORDSMUSIC":o=e.words;break;case"MUSIC":o=e.music;break;case"TABBER":o=e.tab;break;case"COPYRIGHT":o=e.copyright;break;default:o="";break}return o&&(t=!0),o});return s&&!t?"":i}static _placeholderPattern=/%([^%]+)%/g}class Mi extends tr{headerAndFooter=new Map;static defaultHeaderAndFooter=new Map([[H.Title,new hs("%TITLE%",void 0,Y.Center)],[H.SubTitle,new hs("%SUBTITLE%",void 0,Y.Center)],[H.Artist,new hs("%ARTIST%",void 0,Y.Center)],[H.Album,new hs("%ALBUM%",void 0,Y.Center)],[H.Words,new hs("Words by %WORDS%",void 0,Y.Left)],[H.Music,new hs("Music by %MUSIC%",void 0,Y.Right)],[H.WordsAndMusic,new hs("Words & Music by %MUSIC%",void 0,Y.Right)],[H.Transcriber,new hs("Tabbed by %TABBER%",!1,Y.Right)],[H.Copyright,
vendor: 4,654 bytes, line 1
1new hs("%COPYRIGHT%",void 0,Y.Center)],[H.CopyrightSecondLine,new hs("All Rights Reserved - International Copyright Secured",!0,Y.Center)]])}class Ks{_currentRepeatGroup=null;_openedRepeatGroups=[];_properlyOpenedRepeatGroups=0;static resetIds(){ns.resetIds(),Dt.resetIds(),ks.resetIds(),kt.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 Hl;backingTrack;style;rebuildRepeatGroups(){this._currentRepeatGroup=null,this._openedRepeatGroups=[],this._properlyOpenedRepeatGroups=0;for(const e of this.masterBars)this._addMasterBarToRepeatGroups(e)}addMasterBar(e){e.score=this,e.index=this.masterBars.length,this.masterBars.length!==0&&(e.previousMasterBar=this.masterBars[this.masterBars.length-1],e.previousMasterBar.nextMasterBar=e,e.start=e.previousMasterBar.start+(e.previousMasterBar.isAnacrusis?0:e.previousMasterBar.calculateDuration())),this._addMasterBarToRepeatGroups(e),this.masterBars.push(e)}_addMasterBarToRepeatGroups(e){e.isRepeatStart?(this._currentRepeatGroup?.isClosed&&(this._openedRepeatGroups.pop(),this._properlyOpenedRepeatGroups--),this._currentRepeatGroup=new Rn,this._openedRepeatGroups.push(this._currentRepeatGroup),this._properlyOpenedRepeatGroups++):this._currentRepeatGroup||(this._currentRepeatGroup=new Rn,this._openedRepeatGroups.push(this._currentRepeatGroup)),this._currentRepeatGroup.addMasterBar(e),e.isRepeatEnd&&this._properlyOpenedRepeatGroups>1&&(this._openedRepeatGroups.pop(),this._properlyOpenedRepeatGroups--,this._currentRepeatGroup=this._openedRepeatGroups.length>0?this._openedRepeatGroups[this._openedRepeatGroups.length-1]:null)}addTrack(e){e.score=this,e.index=this.tracks.length,this.tracks.push(e)}finish(e){const t=new Map;for(let s=0,i=this.tracks.length;s<i;s++)this.tracks[s].finish(e,t);for(const s of this.masterBars)s.finish(t)}applyFlatSyncPoints(e){for(const t of this.masterBars)t.syncPoints=void 0;for(const t of e){const s=new tt;s.ratioPosition=Math.min(1,Math.max(0,t.barPosition)),s.type=Re.SyncPoint,s.syncPointValue=new ra,s.syncPointValue.millisecondOffset=t.millisecondOffset,s.syncPointValue.barOccurence=t.barOccurence,t.barIndex<this.masterBars.length&&this.masterBars[t.barIndex].addSyncPoint(s)}for(const t of this.masterBars)t.syncPoints&&t.syncPoints.sort((s,i)=>{const r=s.syncPointValue.barOccurence-i.syncPointValue.barOccurence;return r!==0?r:s.ratioPosition-i.ratioPosition})}exportFlatSyncPoints(){const e=[];for(const t of this.masterBars){const s=t.syncPoints;if(s)for(const i of s)e.push({barIndex:t.index,barOccurence:i.syncPointValue.barOccurence,barPosition:i.ratioPosition,millisecondOffset:i.syncPointValue.millisecondOffset})}return e}}class de{static DefaultChannelCount=17;static MetronomeChannel=de.DefaultChannelCount-1;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=de.MaxPitchWheel/2;static MicroBufferCount=32;static MicroBufferSize=64}class Bh{note=null;tone=new Ul;octave=0;get realValue(){return this.octave*12+this.tone.noteValue}}class Ul{noteValue;accidentalMode;constructor(e=0,t=oe.Default){this.noteValue=e,this.accidentalMode=t}}class L{static _durationIndices=L._buildDurationIndices();static _buildDurationIndices(){return new Map(Object.values(y).filter(e=>typeof e=="number").map(e=>[e,e<0?0:Math.log2(e)|0]))}static getIndex(e){return L._durationIndices.get(e)}static keySignatureIsFlat(e){return e<0}static keySignatureIsNatural(e){return e===0}static keySignatureIsSharp(e){return e>0}static applyPitchOffsets(e,t){for(let s=0;s<t.tracks.length;s++){if(s<e.notation.displayTranspositionPitches.length)for(const i of t.tracks[s].staves)i.displayTranspositionPitch=-e.notation.displayTranspositionPitches[s];if(s<e.notation.transpositionPitches.length)for(const i of t.tracks[s].staves)i.transpositionPitch=-e.notation.transpositionPitches[s]}}static isTuning(e){return!!L.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 t="",s="";for(let n=0;n<e.length;n++){const o=e.charCodeAt(n);if(o>
1=48&&o<=57){if(!t)return null;s+=String.fromCharCode(o)}else if(t.length===0)if(L.tuningLetters.has(o))t+=String.fromCharCode(o);else return null;else t+=String.fromCharCode(o)}if(!s||!t)return null;const i=new Bh;i.octave=Number.parseInt(s,10)+1,i.note=t.toLowerCase();const r=L.getToneForText(i.note);return r===null?null:(i.tone=r,i.tone.noteValue<0&&(i.octave--,i.tone.noteValue+=12),i)}static getTuningForText(e){const t=L.parseTuning(e);return t?t.realValue:-1}static getToneForText(e){const t=e.substring(0,1),s=e.substring(1);let i,r;switch(t.toLowerCase()){case"c":i=0;break;case"d":i=2;break;case"e":i=4;break;case"f":i=5;break;case"g":i=7;break;case"a":i=9;break;case"b":i=11;break;default:return null}if(!L.accidentalModeMapping.has(s))return null;switch(r=L.parseAccidentalMode(s),r){case oe.Default:break;case oe.ForceNone:break;case oe.ForceNatural:break;case oe.ForceSharp:i++;break;case oe.ForceDoubleSharp:i+=2;break;case oe.ForceFlat:i--;break;case oe.ForceDoubleFlat:i-=2;break}return new Ul(i,r)}static reverseAccidentalModeMapping=new Map([[oe.Default,"d"],[oe.ForceNone,"forcenone"],[oe.ForceNatural,"forcenatural"],[oe.ForceSharp,"#"],[oe.ForceDoubleSharp,"x"],[oe.ForceFlat,"b"],[oe.ForceDoubleFlat,"bb"]]);static accidentalModeMapping=new Map([["default",oe.Default],["d",oe.Default],["",oe.Default],["forcenone",oe.ForceNone],["-",oe.ForceNone],["forcenatural",oe.ForceNatural],["n",oe.ForceNatural],["forcesharp",oe.ForceSharp],["#",oe.ForceSharp],["forcedoublesharp",oe.ForceDoubleSharp],["##",oe.ForceDoubleSharp],["x",oe.ForceDoubleSharp],["forceflat",oe.ForceFlat],["b",oe.ForceFlat],["forcedoubleflat",oe.ForceDoubleFlat],["bb",oe.ForceDoubleFlat]]);static parseAccidentalMode(e){const t=e.toLowerCase();return L.accidentalModeMapping.has(t)?L.accidentalModeMapping.get(t):oe.Default}static newGuid(){return`${Math.floor((1+Math.random())*65536).toString(16).substring(1)+Math.floor((1+Math.random())*65536).toString(16).substring(1)}-${Math.floor((1+Math.random())*65536).toString(16).substring(1)}-${Math.floor((1+Math.random())*65536).toString(16).substring(1)}-${Math.floor((1+Math.random())*65536).toString(16).substring(1)}-${Math.floor((1+Math.random())*65536).toString(16).substring(1)}${Math.floor((1+Math.random())*65536).toString(16).substring(1)}${Math.floor((1+Math.random())*65536).toString(16).substring(1)}`}static isAlmostEqualTo(e,t){return Math.abs(e-t)<1e-5}static toHexString(e,t=0){let s="";const i="0123456789ABCDEF";do s=String.fromCharCode(i.charCodeAt(e&15))+s,e=e>>4;while(e>0);for(;s.length<t;)s=`0${s}`;return s}static getAlternateEndingsList(e){const t=[];for(let s=0;s<Qs.MaxAlternateEndings;s++)(e&1<<s)!==0&&t.push(s);return t}static deltaFretToHarmonicValue(e){switch(e){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 e;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(e,t,s){return e<=t?t:e>=s?s:e}static buildMultiBarRestInfo(e,t,s){if(!e)return null;const i=e[0].score.stylesheet;if(!(e.length>1?i.multiTrackMultiBarRest:i.perTrackMultiBarRest?.has(e[0].index)===!0))return null;const n=new Map,o=e[0].score;let l=t,h=o.tempo;for(;l<=s;){const c=l;let d=null;for(;l<=s;){const f=o.masterBars[l];let p=!1;for(const m of f.tempoAutomations)m.value!==h&&(p=!0),h=m.value;if(f.alternateEndings||f.isRepeatStart&&f.index!==c||f.isFreeTime||f.isAnacrusis||f.section!==null||f.index!==c&&p||f.fermata!==null&&f.fermata.size>0||f.directions!==null&&f.directions.size>0||c>t&&f.previousMasterBar&&(f.timeSignatureCommon!==f.previousMasterBar.timeSignatureCommon||f.timeSignatureNumerator!==f.previousMasterBar.timeSignatureNumerator||f.timeSignatureDenominator!==f.previousMasterBar.timeSignatureDenominator||f.tripletFeel!==f.previousMasterBar.tripletFeel))break;let g=!0;for(const m of e){for(const b of m.staves){const S=b.bars[f.index];if(!S.isRestOnly){g=!1;break}if(S.index>0&&(S.keySignature!==S.previousBar.keySignature||S.keySignatureType!==S.previousBar.keySignatureType)){g=!1;break}}if(!g)break}if(!g||(l++,f.index>c&&(d===null?d=[f.index]:d.push(f.index)),f.isRepeatEnd))break}d?n.set(c,d):l++}return n}static computeFirstDisplayedBarIndex(e,t){let s=t.display.startBar;return s--,s=Math.min(e.masterBars.length-1,Math.max(0,s)),s}static computeLastDisplayedBarIndex(e,t,s){let i=t.display.barCount;return i<0&&(i=e.masterBars.length),i=s+i-1,i=Math.min(e.masterBars.length-1,Math.max(0,i)),i}static getOrCreateHeaderFooterStyle(e,t){let s=e.style;e.style||(s=new Mi,e.style=s);let i;if(s.headerAndFooter.has(t))i=s.headerAndFooter.get(t);else{if(i=new hs,Mi.defaultHeaderAndFooter.has(t)){const r=Mi.defaultHeaderAndFooter.get(t);i.template=r.template,i.textAlign=r.textAlign}s.headerAndFooter.set(t,i)}return i}static consolidate(e){if(e.masterBars.length===0){const s=new Qs;e.addMasterBar(s);const i=new tt;i.isLinear=!1,i.type=Re.Tempo,i.value=e.tempo,s.tempoAutomations.push(i);const r=new ns;e.tracks[0].staves[0].addBar(r);const n=new ks;r.addVoice(n);const o=new Dt;o.isEmpty=!0,n.addBeat(o);return}const t=new Set([de.PercussionChannel]);for(const s of e.tracks){if(s.staves.length===1&&s.staves[0].isPercussion)s.playbackInfo.primaryChannel=de.PercussionChannel,s.playbackInfo.secondaryChannel=de.PercussionChannel;else{if(s.playbackInfo.primaryChannel!==de.PercussionChannel)for(;t.has(s.playbackInfo.primaryChannel);)s.playbackInfo.primaryChannel++;if(t.add(s.playbackInfo.primaryChannel),s.playbackInfo.secondaryChannel!==de.PercussionChannel)for(;t.has(s.playbackInfo.secondaryChannel);)s.playbackInfo.secondaryChannel++;t.add(s.playbackInfo.secondaryChannel)}for(const i of s.staves){for(const n of i.bars)for(const o of n.voices)if(o.isEmpty&&o.beats.length===0){const l=new Dt;l.isEmpty=!0,o.addBeat(l)}const r=i.bars.length===0?1:i.bars[0].voices.length;for(;i.bars.length<e.masterBars.length;){const n=new ns;i.addBar(n);const o=n.previousBar;o&&(n.clef=o.clef,n.clefOttava=o.clefOttava,n.keySignature=n.previousBar.keySignature,n.keySignatureType=n.previousBar.keySignatureType);for(let l=0;l<r;l++){const h=new ks;n.addVoice(h);const c=new Dt;c.isEmpty=!0,h.addBeat(c)}}}}if(e.masterBars.length>0&&!e.masterBars[0].tempoAutomations.find(i=>i.type===Re.Tempo&&i.ratioPosition===0)){const i=new tt;i.isLinear=!1,i.type=Re.Tempo,i.value=e.tempo,i.text=e.tempoLabel,i.isVisible=!1,e.masterBars[0].tempoAutomations.push(i)}}static trimEmptyBarsAtEnd(e){for(;e.masterBars.length>1;){const t=e.masterBars.length-1,s=e.masterBars[t];if(s.hasChanges)return;for(const i of e.tracks)for(const r of i.staves)if(t<r.bars.length){const n=r.bars[t];if(!n.isEmpty||n.hasChanges)return}for(const i of e.tracks)for(const r of i.staves)if(t<r.bars.length){const n=r.bars[t];r.bars.pop(),n.previousBar.nextBar=null}e.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(e,t){return e-t*Math.floor(e/t)}static _translateKeyTransposeTable(e){const t=[];for(const s of e){const i=[];t.push(i);for(const r of s){const n=Number.parseInt(r.charAt(0),10)*(r.charAt(1)==="b"?-1:1);i.push(n)}}return t}static _keyTransposeTable=L._translateKeyTransposeTable([["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,t){if(t===0)return e;
1if(t<0){const i=L._keyTransposeTable[-t].indexOf(e);return i===-1?e:i-7}else return L._keyTransposeTable[t][e+7]}static _keySignatureLookup=[[!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0],[!0,!0,!0,!0,!0,!1,!0,!0,!0,!0,!0,!0],[!1,!0,!0,!0,!0,!1,!0,!0,!0,!0,!0,!0],[!1,!0,!0,!0,!0,!1,!1,!1,!0,!0,!0,!0],[!1,!1,!1,!0,!0,!1,!1,!1,!0,!0,!0,!0],[!1,!1,!1,!0,!0,!1,!1,!1,!1,!1,!0,!0],[!1,!1,!1,!1,!1,!1,!1,!1,!1,!1,!0,!0],[!1,!1,!1,!1,!1,!1,!1,!1,!1,!1,!1,!1],[!1,!1,!1,!1,!1,!0,!0,!1,!1,!1,!1,!1],[!0,!0,!1,!1,!1,!0,!0,!1,!1,!1,!1,!1],[!0,!0,!1,!1,!1,!0,!0,!0,!0,!1,!1,!1],[!0,!0,!0,!0,!1,!0,!0,!0,!0,!1,!1,!1],[!0,!0,!0,!0,!1,!0,!0,!0,!0,!0,!0,!1],[!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!1],[!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0]];static accidentalNotes=[!1,!0,!1,!0,!1,!1,!0,!1,!0,!1,!0,!1];static computeAccidental(e,t,s,i,r=null){const o=e+7,l=s%12,h=o<7?ee.Flat:ee.Sharp,c=L._keySignatureLookup[o][l],d=L.accidentalNotes[l];let f=ee.None;if(i)switch(f=d?h:ee.Natural,f){case ee.Natural:f=ee.NaturalQuarterNoteUp;break;case ee.Sharp:f=ee.SharpQuarterNoteUp;break;case ee.Flat:f=ee.FlatQuarterNoteUp;break}else{switch(t){case oe.ForceSharp:f=ee.Sharp;break;case oe.ForceDoubleSharp:f=ee.DoubleSharp;break;case oe.ForceFlat:f=ee.Flat;break;case oe.ForceDoubleFlat:f=ee.DoubleFlat;break;default:d?f=h:c&&(f=ee.Natural);break}f!==ee.None?r!=null?r===f&&(f=ee.None):c&&f===h&&(f=ee.None):r!==null&&(r===ee.Natural?f=ee.None:f=ee.Natural)}return f}static toArticulationId(e){return e.replace(/[^a-zA-Z0-9]/g,"").toLowerCase()}static minBoundingBox(e,t){return Number.isNaN(e)?t:Number.isNaN(t)||e<t?e:t}static maxBoundingBox(e,t){return Number.isNaN(e)?t:Number.isNaN(t)||e>t?e:t}static getSystemLayout(e,t,s){let i,r;return s.length===1?(i=s[0].defaultSystemsLayout,r=s[0].systemsLayout):(i=e.defaultSystemsLayout,r=e.systemsLayout),t<r.length?r[t]:i}}var Ct;(function(a){a[a.None=0]="None",a[a.Up=1]="Up",a[a.Down=2]="Down"})(Ct||(Ct={}));var u;(function(a){a[a.None=-1]="None",a[a.Space=32]="Space",a[a.Brace=57344]="Brace",a[a.BracketTop=57347]="BracketTop",a[a.BracketBottom=57348]="BracketBottom",a[a.SystemDivider=57351]="SystemDivider",a[a.GClef=57424]="GClef",a[a.GClef15mb=57425]="GClef15mb",a[a.GClef8vb=57426]="GClef8vb",a[a.GClef8va=57427]="GClef8va",a[a.GClef15ma=57428]="GClef15ma",a[a.CClef=57436]="CClef",a[a.CClef8vb=57437]="CClef8vb",a[a.FClef=57442]="FClef",a[a.FClef15mb=57443]="FClef15mb",a[a.FClef8vb=57444]="FClef8vb",a[a.FClef8va=57445]="FClef8va",a[a.FClef15ma=57446]="FClef15ma",a[a.UnpitchedPercussionClef1=57449]="UnpitchedPercussionClef1",a[a.SixStringTabClef=57453]="SixStringTabClef",a[a.FourStringTabClef=57454]="FourStringTabClef",a[a.Clef8=57469]="Clef8",a[a.Clef15=57470]="Clef15",a[a.TimeSig0=57472]="TimeSig0",a[a.TimeSig1=57473]="TimeSig1",a[a.TimeSig2=57474]="TimeSig2",a[a.TimeSig3=57475]="TimeSig3",a[a.TimeSig4=57476]="TimeSig4",a[a.TimeSig5=57477]="TimeSig5",a[a.TimeSig6=57478]="TimeSig6",a[a.TimeSig7=57479]="TimeSig7",a[a.TimeSig8=57480]="TimeSig8",a[a.TimeSig9=57481]="TimeSig9",a[a.TimeSigCommon=57482]="TimeSigCommon",a[a.TimeSigCutCommon=57483]="TimeSigCutCommon",a[a.NoteheadDoubleWholeSquare=57505]="NoteheadDoubleWholeSquare",a[a.NoteheadDoubleWhole=57504]="NoteheadDoubleWhole",a[a.NoteheadWhole=57506]="NoteheadWhole",a[a.NoteheadHalf=57507]="NoteheadHalf",a[a.NoteheadBlack=57508]="NoteheadBlack",a[a.NoteheadNull=57509]="NoteheadNull",a[a.NoteheadXOrnate=57514]="NoteheadXOrnate",a[a.NoteheadPlusDoubleWhole=57516]="NoteheadPlusDoubleWhole",a[a.NoteheadPlusWhole=57517]="NoteheadPlusWhole",a[a.NoteheadPlusHalf=57518]="NoteheadPlusHalf",a[a.NoteheadPlusBlack=57519]="NoteheadPlusBlack",a[a.NoteheadSquareWhite=57528]="NoteheadSquareWhite",a[a.NoteheadSquareBlack=57529]="NoteheadSquareBlack",a[a.NoteheadTriangleUpDoubleWhole=57530]="NoteheadTriangleUpDoubleWhole",a[a.NoteheadTriangleUpWhole=57531]="NoteheadTriangleUpWhole",a[a.NoteheadTriangleUpHalf=57532]="NoteheadTriangleUpHalf",a[a.NoteheadTriangleUpBlack=57534]="NoteheadTriangleUpBlack",a[a.NoteheadTriangleRightWhite=57537]="NoteheadTriangleRightWhite",a[a.NoteheadTriangleRightBlack=57538]="NoteheadTriangleRightBlack",a[a.NoteheadTriangleDownDoubleWhole=57548]="NoteheadTriangleDownDoubleWhole",a[a.NoteheadTriangleDownWhole=57540]="NoteheadTriangleDownWhole",a[a.NoteheadTriangleDownHalf=57541]="NoteheadTriangleDownHalf",a[a.NoteheadTriangleDownBlack=57543]="NoteheadTriangleDownBlack",a[a.NoteheadDiamondDoubleWhole=57559]="NoteheadDiamondDoubleWhole",a[a.NoteheadDiamondWhole=57560]="NoteheadDiamondWhole",a[a.NoteheadDiamondHalf=57561]="NoteheadDiamondHalf",a[a.NoteheadDiamondBlack=57563]="NoteheadDiamondBlack",a[a.NoteheadDiamondBlackWide=57564]="NoteheadDiamondBlackWide",a[a.NoteheadDiamondWhite=57565]="NoteheadDiamondWhite",a[a.NoteheadDiamondWhiteWide=57566]="NoteheadDiamondWhiteWide",a[a.NoteheadCircleXDoubleWhole=57520]="NoteheadCircleXDoubleWhole",a[a.NoteheadCircleXWhole=57521]="NoteheadCircleXWhole",a[a.NoteheadCircleXHalf=57522]="NoteheadCircleXHalf",a[a.NoteheadCircleX=57523]="NoteheadCircleX",a[a.NoteheadXDoubleWhole=57510]="NoteheadXDoubleWhole",a[a.NoteheadXWhole=57511]="NoteheadXWhole",a[a.NoteheadXHalf=57512]="NoteheadXHalf",a[a.NoteheadXBlack=57513]="NoteheadXBlack",a[a.NoteheadParenthesis=57550]="NoteheadParenthesis",a[a.NoteheadSlashedBlack1=57551]="NoteheadSlashedBlack1",a[a.NoteheadSlashedBlack2=57552]="NoteheadSlashedBlack2",a[a.NoteheadSlashed
1Half1=57553]="NoteheadSlashedHalf1",a[a.NoteheadSlashedHalf2=57554]="NoteheadSlashedHalf2",a[a.NoteheadSlashedWhole1=57555]="NoteheadSlashedWhole1",a[a.NoteheadSlashedWhole2=57556]="NoteheadSlashedWhole2",a[a.NoteheadSlashedDoubleWhole1=57557]="NoteheadSlashedDoubleWhole1",a[a.NoteheadSlashedDoubleWhole2=57558]="NoteheadSlashedDoubleWhole2",a[a.NoteheadCircledBlack=57572]="NoteheadCircledBlack",a[a.NoteheadCircledHalf=57573]="NoteheadCircledHalf",a[a.NoteheadCircledWhole=57574]="NoteheadCircledWhole",a[a.NoteheadCircledDoubleWhole=57575]="NoteheadCircledDoubleWhole",a[a.NoteheadCircleSlash=57591]="NoteheadCircleSlash",a[a.NoteheadHeavyX=57592]="NoteheadHeavyX",a[a.NoteheadHeavyXHat=57593]="NoteheadHeavyXHat",a[a.NoteheadSlashHorizontalEnds=57601]="NoteheadSlashHorizontalEnds",a[a.NoteheadSlashWhiteWhole=57602]="NoteheadSlashWhiteWhole",a[a.NoteheadSlashWhiteHalf=57603]="NoteheadSlashWhiteHalf",a[a.NoteheadRoundWhiteWithDot=57621]="NoteheadRoundWhiteWithDot",a[a.NoteheadSquareBlackLarge=57626]="NoteheadSquareBlackLarge",a[a.NoteheadSquareBlackWhite=57627]="NoteheadSquareBlackWhite",a[a.NoteheadClusterDoubleWhole3rd=57640]="NoteheadClusterDoubleWhole3rd",a[a.NoteheadClusterWhole3rd=57641]="NoteheadClusterWhole3rd",a[a.NoteheadClusterHalf3rd=57642]="NoteheadClusterHalf3rd",a[a.NoteheadClusterQuarter3rd=57643]="NoteheadClusterQuarter3rd",a[a.NoteShapeRoundWhite=57776]="NoteShapeRoundWhite",a[a.NoteShapeRoundBlack=57777]="NoteShapeRoundBlack",a[a.NoteShapeSquareWhite=57778]="NoteShapeSquareWhite",a[a.NoteShapeSquareBlack=57779]="NoteShapeSquareBlack",a[a.NoteShapeTriangleRightWhite=57780]="NoteShapeTriangleRightWhite",a[a.NoteShapeTriangleRightBlack=57781]="NoteShapeTriangleRightBlack",a[a.NoteShapeTriangleLeftWhite=57782]="NoteShapeTriangleLeftWhite",a[a.NoteShapeTriangleLeftBlack=57783]="NoteShapeTriangleLeftBlack",a[a.NoteShapeDiamondWhite=57784]="NoteShapeDiamondWhite",a[a.NoteShapeDiamondBlack=57785]="NoteShapeDiamondBlack",a[a.NoteShapeTriangleUpWhite=57786]="NoteShapeTriangleUpWhite",a[a.NoteShapeTriangleUpBlack=57787]="NoteShapeTriangleUpBlack",a[a.NoteShapeMoonWhite=57788]="NoteShapeMoonWhite",a[a.NoteShapeMoonBlack=57789]="NoteShapeMoonBlack",a[a.NoteShapeTriangleRoundWhite=57790]="NoteShapeTriangleRoundWhite",a[a.NoteShapeTriangleRoundBlack=57791]="NoteShapeTriangleRoundBlack",a[a.NoteQuarterUp=57813]="NoteQuarterUp",a[a.Note8thUp=57815]="Note8thUp",a[a.MetNoteQuarterUp=60581]="MetNoteQuarterUp",a[a.MetNote8thUp=60583]="MetNote8thUp",a[a.MetAugmentationDot=60599]="MetAugmentationDot",a[a.ArrowheadBlackUp=60280]="ArrowheadBlackUp",a[a.ArrowheadBlackDown=60284]="ArrowheadBlackDown",a[a.AugmentationDot=57831]="AugmentationDot",a[a.TextBlackNoteLongStem=57841]="TextBlackNoteLongStem",a[a.TextBlackNoteFrac8thLongStem=57843]="TextBlackNoteFrac8thLongStem",a[a.TextBlackNoteFrac16thLongStem=57845]="TextBlackNoteFrac16thLongStem",a[a.TextBlackNoteFrac32ndLongStem=57846]="TextBlackNoteFrac32ndLongStem",a[a.TextCont8thBeamLongStem=57848]="TextCont8thBeamLongStem",a[a.TextCont16thBeamLongStem=57850]="TextCont16thBeamLongStem",a[a.TextCont32ndBeamLongStem=57851]="TextCont32ndBeamLongStem",a[a.TextAugmentationDot=57852]="TextAugmentationDot",a[a.TextTupletBracketStartLongStem=57857]="TextTupletBracketStartLongStem",a[a.TextTuplet3LongStem=57858]="TextTuplet3LongStem",a[a.TextTupletBracketEndLongStem=57859]="TextTupletBracketEndLongStem",a[a.Tremolo1=57888]="Tremolo1",a[a.Tremolo2=57889]="Tremolo2",a[a.Tremolo3=57890]="Tremolo3",a[a.Tremolo4=57891]="Tremolo4",a[a.Tremolo5=57892]="Tremolo5",a[a.BuzzRoll=57898]="BuzzRoll",a[a.Flag8thUp=57920]="Flag8thUp",a[a.Flag8thDown=57921]="Flag8thDown",a[a.Flag16thUp=57922]="Flag16thUp",a[a.Flag16thDown=57923]="Flag16thDown",a[a.Flag32ndUp=57924]="Flag32ndUp",a[a.Flag32ndDown=57925]="Flag32ndDown",a[a.Flag64thUp=57926]="Flag64thUp",a[a.Flag64thDown=57927]="Flag64thDown",a[a.Flag128thUp=57928]="Flag128thUp",a[a.Flag128thDown=57929]="Flag128thDown",a[a.Flag256thUp=57930]="Flag256thUp",a[a.Flag256thDown=57931]="Flag256thDown",a[a.AccidentalFlat=57952]="AccidentalFlat",a[a.AccidentalNatural=57953]="AccidentalNatural",a[a.AccidentalSharp=57954]="AccidentalSharp",a[a.AccidentalDoubleSharp=57955]="AccidentalDoubleSharp",a[a.AccidentalDoubleFlat=57956]="AccidentalDoubleFlat",a[a.AccidentalQuarterToneFlatArrowUp=57968]="AccidentalQuarterToneFlatArrowUp",a[a.AccidentalQuarterToneSharpNaturalArrowUp=57970]="AccidentalQuarterToneSharpNaturalArrowUp",a[a.AccidentalThreeQuarterTonesSharpArrowUp=57972]="AccidentalThreeQuarterTonesSharpArrowUp",a[a.RepeatDot=57412]="RepeatDot",a[a.Segno=57415]="Segno",a[a.Coda=57416]="Coda",a[a.ArticAccentAbove=58528]="ArticAccentAbove",a[a.ArticAccentBelow=58529]="ArticAccentBelow",a[a.ArticStaccatoAbove=58530]="ArticStaccatoAbove",a[a.ArticStaccatoBelow=58531]="ArticStaccatoBelow",a[a.ArticTenutoAbove=58532]="ArticTenutoAbove",a[a.ArticTenutoBelow=58533]="ArticTenutoBelow",a[a.ArticMarcatoAbove=58540]="ArticMarcatoAbove",a[a.ArticMarcatoBelow=58541]="ArticMarcatoBelow",a[a.FermataAbove=58560]="FermataAbove",a[a.FermataShortAbove=58564]="FermataShortAbove",a[a.FermataLongAbove=58566]="FermataLongAbove",a[a.RestLonga=58593]="RestLonga",a[a.RestDoubleWhole=58594]="RestDoubleWhole",a[a.RestWhole=58595]="RestWhole",a[a.RestHalf=58596]="RestHalf",a[a.RestQuarter=58597]="RestQuarter",a[a.Rest8th=58598]="Rest8th",a[a.Rest16th=58599]="Rest16th",a[a.Rest32nd=58600]="Rest32nd",a[a.Rest64th=58601]="Rest64th",a[a.Rest128th=58602]="Rest128th",a[a.Rest256th=58603]="Rest256th",a[a.RestHBarLeft=58607]="RestHBarLeft",a[a.RestHBarMiddle=58608]="RestHBarMiddle",a[a.RestHBarRight=58609]="RestHBarRight",a[a.Repeat1Bar=58624]="Repeat1Bar",a[a.Repeat2Bars=58625]="Repeat2Bars",a[a.Ottava=58640]="Ottava",a[a.OttavaAlta=58641]="OttavaAlta",a[a.OttavaBassaVb=58652]="OttavaBassaVb",a[a.Quindicesima=58644]="Quindicesima",a[a.QuindicesimaAlta=58645]="QuindicesimaAlta",a[a.DynamicPPPPPP=58663]="DynamicPPPPPP",a[a.DynamicPPPPP=58664]="DynamicPPPPP",a[a.DynamicPPPP=58665]="DynamicPPPP",a[a.DynamicPPP=58666]="DynamicPPP",a[a.DynamicPP=58667]="DynamicPP",a[a.DynamicPiano=58656]="DynamicPiano",a[a.DynamicMP=58668]="DynamicMP",a[a.DynamicMF=58669]="DynamicMF",a[a.DynamicPF=58670]="DynamicPF",a[a.DynamicForte=58658]="DynamicForte",a[a.DynamicFF=58671]="DynamicFF",a[a.DynamicFFF=58672]="DynamicFFF",a[a.DynamicFFFF=58673]="DynamicFFFF",a[a.DynamicFFFFF=58674]="DynamicFFFFF",a[a.DynamicFFFFFF=58675]="DynamicFFFFFF",a[a.DynamicFortePiano=58676]="DynamicFortePiano",a[a.DynamicNiente=58662]="DynamicNiente",a[a.DynamicSforzando1=58678]="DynamicSforzando1",a[a.DynamicSforzandoPiano=58679]="DynamicSforzandoPiano",a[a.DynamicSforzandoPianissimo=58680]="DynamicSforzandoPianissimo",a[a.DynamicSforzato=58681]="DynamicSforzato",a[a.DynamicSforzatoPiano=58682]="DynamicSforzatoPiano",a[a.DynamicSforzatoFF=58683]="DynamicSforzatoFF",a[a.DynamicRinforzando1=58684]="DynamicRinforzando1",a[a.DynamicRinforzando2=58685]="DynamicRinforzando2",a[a.DynamicForzando=58677]="DynamicForzando",a[a.DynamicCrescendoHairpin=58686]="DynamicCrescendoHairpin",a[a.GraceNoteSlashStemUp=58724]="GraceNoteSlashStemUp",a[a.GraceNoteSlashStemDown=58725]="GraceNoteSlashStemDown",a[a.OrnamentTrill=58726]="OrnamentTrill",a[a.OrnamentTurn=58727]="OrnamentTurn",a[a.OrnamentTurnInverted=58728]="OrnamentTurnInverted",a[a.OrnamentShortTrill=58732]="OrnamentShortTrill",a[a.OrnamentMordent=58733]="OrnamentMordent",a[a.StringsDownBow=58896]="StringsDownBow",a[a.StringsUpBow=58898]="StringsUpBow",a[a.KeyboardPedalPed=58960]="KeyboardPedalPed",a[a.KeyboardPedalUp=58965]="KeyboardPedalUp",a[a.PictEdgeOfCymbal=59177]="PictEdgeOfCymbal",a[a.GuitarString0=59443]="GuitarString0",a[a.GuitarString1=59444]="GuitarString1",a[a.GuitarString2=59445]="GuitarString2",a[a.GuitarString3=59446]="GuitarString3",a[a.GuitarString4=59447]="GuitarString4",a[a.GuitarString5=59448]="GuitarString5",a[a.GuitarString6=59449]="GuitarString6",a[a.GuitarString7=59450]="GuitarString7",a[a.GuitarString8=59451]="GuitarString8",a[a.GuitarString9=59452]="GuitarString9",a[a.GuitarOpenPedal=59453]="GuitarOpenPedal",a[a.GuitarClosePedal=59455]="GuitarClosePedal",a[a.GuitarGolpe=59458]="GuitarGolpe",a[a.GuitarFadeIn=59459]="GuitarFadeIn",a[a.GuitarFadeOut=59460
1]="GuitarFadeOut",a[a.GuitarVolumeSwell=59461]="GuitarVolumeSwell",a[a.FretboardFilledCircle=59480]="FretboardFilledCircle",a[a.FretboardX=59481]="FretboardX",a[a.FretboardO=59482]="FretboardO",a[a.Tuplet0=59520]="Tuplet0",a[a.Tuplet1=59521]="Tuplet1",a[a.Tuplet2=59522]="Tuplet2",a[a.Tuplet3=59523]="Tuplet3",a[a.Tuplet4=59524]="Tuplet4",a[a.Tuplet5=59525]="Tuplet5",a[a.Tuplet6=59526]="Tuplet6",a[a.Tuplet7=59527]="Tuplet7",a[a.Tuplet8=59528]="Tuplet8",a[a.Tuplet9=59529]="Tuplet9",a[a.TupletColon=59530]="TupletColon",a[a.WiggleTrill=60068]="WiggleTrill",a[a.GuitarVibratoStroke=60082]="GuitarVibratoStroke",a[a.GuitarWideVibratoStroke=60083]="GuitarWideVibratoStroke",a[a.WiggleVibratoMediumFast=60126]="WiggleVibratoMediumFast",a[a.WiggleSawtoothNarrow=60090]="WiggleSawtoothNarrow",a[a.WiggleSawtooth=60091]="WiggleSawtooth",a[a.OctaveBaselineM=60565]="OctaveBaselineM",a[a.OctaveBaselineB=60563]="OctaveBaselineB",a[a.GuitarLeftHandTapping=59456]="GuitarLeftHandTapping",a[a.Fingering0=60688]="Fingering0",a[a.Fingering1=60689]="Fingering1",a[a.Fingering2=60690]="Fingering2",a[a.Fingering3=60691]="Fingering3",a[a.Fingering4=60692]="Fingering4",a[a.Fingering5=60693]="Fingering5",a[a.FingeringPLower=60695]="FingeringPLower",a[a.FingeringTLower=60696]="FingeringTLower",a[a.FingeringILower=60697]="FingeringILower",a[a.FingeringMLower=60698]="FingeringMLower",a[a.FingeringALower=60699]="FingeringALower",a[a.FingeringCLower=60700]="FingeringCLower"})(u||(u={}));class ii{static _allMusicFontSymbols=[];static _blackNoteHeadGlyphs=new Set;static _initialize(){const e=ii._allMusicFontSymbols;if(e.length===0)for(const t of Object.values(u).filter(s=>typeof s=="number")){const s=t;e.push(s),u[s].toLowerCase().endsWith("black")&&ii._blackNoteHeadGlyphs.add(s)}}static getAllMusicFontSymbols(){return ii._initialize(),ii._allMusicFontSymbols}static isBlackNoteHead(e){return ii._initialize(),ii._blackNoteHeadGlyphs.has(e)}}var $e;(function(a){a[a.Above=0]="Above",a[a.Inside=1]="Inside",a[a.Below=2]="Below",a[a.Outside=3]="Outside"})($e||($e={}));class X{id=0;get uniqueId(){return`${this.elementType}.${this.id}`}elementType;staffLine;noteHeadDefault;noteHeadHalf;noteHeadWhole;techniqueSymbol;techniqueSymbolPlacement;outputMidiNumber;constructor(e="",t=0,s=0,i=u.None,r=u.None,n=u.None,o=u.None,l=$e.Inside,h=0){this.id=h,this.elementType=e,this.outputMidiNumber=s,this.staffLine=t,this.noteHeadDefault=i,this.noteHeadHalf=r!==u.None?r:i,this.noteHeadWhole=n!==u.None?n:i,this.techniqueSymbol=o,this.techniqueSymbolPlacement=l}static create(e=0,t="",s=0,i=0,r=u.None,n=u.None,o=u.None,l=u.None,h=$e.Inside){return new X(t,s,i,r,n,o,l,h,e)}getSymbol(e){switch(e){case y.Whole:return this.noteHeadWhole;case y.Half:return this.noteHeadHalf;default:return this.noteHeadDefault}}}class Xe{static instrumentArticulations=new Map([X.create(38,"Snare",3,38,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole),X.create(37,"Snare",3,37,u.NoteheadXBlack,u.NoteheadXBlack,u.NoteheadXBlack),X.create(91,"Snare",3,38,u.NoteheadDiamondWhite,u.NoteheadDiamondWhite,u.NoteheadDiamondWhite),X.create(42,"Charley",-1,42,u.NoteheadXBlack,u.NoteheadXBlack,u.NoteheadXBlack),X.create(92,"Charley",-1,46,u.NoteheadCircleSlash,u.NoteheadCircleSlash,u.NoteheadCircleSlash),X.create(46,"Charley",-1,46,u.NoteheadCircleX,u.NoteheadCircleX,u.NoteheadCircleX),X.create(44,"Charley",9,44,u.NoteheadXBlack,u.NoteheadXBlack,u.NoteheadXBlack),X.create(35,"Acoustic Kick Drum",8,35,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole),X.create(36,"Kick Drum",7,36,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole),X.create(50,"Tom Very High",1,50,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole),X.create(48,"Tom High",2,48,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole),X.create(47,"Tom Medium",4,47,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole),X.create(45,"Tom Low",5,45,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole),X.create(43,"Tom Very Low",6,43,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole),X.create(93,"Ride",0,51,u.NoteheadXBlack,u.NoteheadXBlack,u.NoteheadXBlack,u.PictEdgeOfCymbal,$e.Above),X.create(51,"Ride",0,51,u.NoteheadXBlack,u.NoteheadXBlack,u.NoteheadXBlack),X.create(53,"Ride",0,53,u.NoteheadDiamondWhite,u.NoteheadDiamondWhite,u.NoteheadDiamondWhite),X.create(94,"Ride",0,51,u.NoteheadXBlack,u.NoteheadXBlack,u.NoteheadXBlack,u.ArticStaccatoAbove,$e.Outside),X.create(55,"Splash",-2,55,u.NoteheadXBlack,u.NoteheadXBlack,u.NoteheadXBlack),X.create(95,"Splash",-2,55,u.NoteheadXBlack,u.NoteheadXBlack,u.NoteheadXBlack,u.ArticStaccatoAbove,$e.Outside),X.create(52,"China",-3,52,u.N
1oteheadHeavyXHat,u.NoteheadHeavyXHat,u.NoteheadHeavyXHat),X.create(96,"China",-3,52,u.NoteheadHeavyXHat,u.NoteheadHeavyXHat,u.NoteheadHeavyXHat),X.create(49,"Crash High",-2,49,u.NoteheadHeavyX,u.NoteheadHeavyX,u.NoteheadHeavyX),X.create(97,"Crash High",-2,49,u.NoteheadHeavyX,u.NoteheadHeavyX,u.NoteheadHeavyX,u.ArticStaccatoAbove,$e.Outside),X.create(57,"Crash Medium",-1,57,u.NoteheadHeavyX,u.NoteheadHeavyX,u.NoteheadHeavyX),X.create(98,"Crash Medium",-1,57,u.NoteheadHeavyX,u.NoteheadHeavyX,u.NoteheadHeavyX,u.ArticStaccatoAbove,$e.Outside),X.create(99,"Cowbell Low",1,56,u.NoteheadTriangleUpBlack,u.NoteheadTriangleUpHalf,u.NoteheadTriangleUpWhole),X.create(100,"Cowbell Low",1,56,u.NoteheadXBlack,u.NoteheadXHalf,u.NoteheadXWhole),X.create(56,"Cowbell Medium",0,56,u.NoteheadTriangleUpBlack,u.NoteheadTriangleUpHalf,u.NoteheadTriangleUpWhole),X.create(101,"Cowbell Medium",0,56,u.NoteheadXBlack,u.NoteheadXHalf,u.NoteheadXWhole),X.create(102,"Cowbell High",-1,56,u.NoteheadTriangleUpBlack,u.NoteheadTriangleUpHalf,u.NoteheadTriangleUpWhole),X.create(103,"Cowbell High",-1,56,u.NoteheadXBlack,u.NoteheadXHalf,u.NoteheadXWhole),X.create(77,"Woodblock Low",-9,77,u.NoteheadTriangleUpBlack,u.NoteheadTriangleUpBlack,u.NoteheadTriangleUpBlack),X.create(76,"Woodblock High",-10,76,u.NoteheadTriangleUpBlack,u.NoteheadTriangleUpBlack,u.NoteheadTriangleUpBlack),X.create(60,"Bongo High",-4,60,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole),X.create(104,"Bongo High",-5,60,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole,u.NoteheadParenthesis,$e.Inside),X.create(105,"Bongo High",-6,60,u.NoteheadXBlack,u.NoteheadXBlack,u.NoteheadXBlack),X.create(61,"Bongo Low",-7,61,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole),X.create(106,"Bongo Low",-8,61,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole,u.NoteheadParenthesis,$e.Inside),X.create(107,"Bongo Low",-16,61,u.NoteheadXBlack,u.NoteheadXBlack,u.NoteheadXBlack),X.create(66,"Timbale Low",10,66,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole),X.create(65,"Timbale High",9,65,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole),X.create(68,"Agogo Low",12,68,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole),X.create(67,"Agogo High",11,67,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole),X.create(64,"Conga Low",17,64,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole),X.create(108,"Conga Low",16,64,u.NoteheadXBlack,u.NoteheadXBlack,u.NoteheadXBlack),X.create(109,"Conga Low",15,64,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole,u.NoteheadParenthesis,$e.Inside),X.create(63,"Conga High",14,63,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole),X.create(110,"Conga High",13,63,u.NoteheadXBlack,u.NoteheadXBlack,u.NoteheadXBlack),X.create(62,"Conga High",19,62,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole,u.NoteheadParenthesis,$e.Inside),X.create(72,"Whistle Low",-11,72,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole),X.create(71,"Whistle High",-17,71,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole),X.create(73,"Guiro",38,73,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole),X.create(74,"Guiro",37,74,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole),X.create(86,"Surdo",36,86,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole),X.create(87,"Surdo",35,87,u.NoteheadXBlack,u.NoteheadXBlack,u.NoteheadXBlack,u.NoteheadParenthesis,$e.Inside),X.create(54,"Tambourine",3,54,u.NoteheadTriangleUpBlack,u.NoteheadTriangleUpBlack,u.NoteheadTriangleUpBlack),X.create(111,"Tambourine",2,54,u.NoteheadTriangleUpBlack,u.NoteheadTriangleUpBlack,u.NoteheadTriangleUpBlack,u.StringsUpBow,$e.Above),X.create(112,"Tambourine",1,54,u.NoteheadTriangleUpBlack,u.NoteheadTriangleUpBlack,u.NoteheadTriangleUpBlack,u.StringsDownBow,$e.Above),X.create(113,"Tambourine",-7,54,u.NoteheadXBlack,u.NoteheadXBlack,u.NoteheadXBlack),X.create(79,"Cuica",30,79,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole),X.create(78,"Cuica",29,78,u.NoteheadXBlack,u.NoteheadXBlack,u.NoteheadXBlack),X.create(58,"Vibraslap",28,58,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole),X.create(81,"Triangle",27,81,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole),X.create(80,"Triangle",26,80,u.NoteheadXBlack,u.NoteheadXBlack,u.NoteheadXBlack,u.NoteheadParenthesis,$e.Inside),X.create(114,"Grancassa",25,43,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole),X.create(115,"Piatti",18,49,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole),X.create(116,"Piatti",24,49,u.NoteheadXBlack,u.NoteheadXBlack,u.NoteheadXBlack),X.create(69,"Cabasa",23,69,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole),X.create(117,"Cabasa",22,69,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole,u.StringsUpBow,$e.Outside),X.create(85,"Castanets",21,85,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole),X.create(75,"Claves",20,75,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole),X.create(70,"Left Maraca",-12,70,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole),X.create(118,"Left Maraca",-13,70,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole,u.StringsUpBow,$e.Outside),X.create(119,"Right Maraca",-14,70,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole),X.create(120,"Right Maraca",-15,70,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole,u.StringsUpBow,$e.Outside),X.create(82,"Shaker",-23,82,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole),X.create(122,"Shaker",-24,82,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole,u.StringsUpBow,$e.Outside),X.create(84,"Bell Tree",-18,53,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole),X.create(123,"Bell Tree",-19,53,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole,u.StringsUpBow,$e.Outside),X.create(83,"Jingle Bell",-20,53,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole),X.create(83,"Tinkle Bell",-20,53,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole),X.create(124,"Golpe",-21,62,u.NoteheadNull,u.NoteheadNull,u.NoteheadNull,u.GuitarGolpe,$e.Below),X.create(125,"Golpe",-22,62,u.NoteheadNull,u.NoteheadNull,u.NoteheadNull,u.GuitarGolpe,$e.Above),X.create(39,"Hand Clap",3,39,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole),X.create(40,"Electric Snare",3,40,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole),X.create(31,"Sticks",3,40,u.NoteheadSlashedBlack2,u.NoteheadSlashedBlack2,u.NoteheadSlashedBlack2),X.create(41,"Very Low Floor Tom",5,41,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole),X.create(59,"Ride Cymbal 2",2,59,u.NoteheadXBlack,u.NoteheadXBlack,u.NoteheadXBlack,u.PictEdgeOfCymbal,$e.Above),X.create(126,"Ride Cymbal 2",2,59,u.NoteheadXBlack,u.NoteheadXBlack,u.NoteheadXBlack),X.create(127,"Ride Cymbal 2",2,59,u.NoteheadDiamondWhite,u.NoteheadDiamondWhite,u.NoteheadDiamondWhite),X.create(29,"Ride Cymbal 2",2,59,u.NoteheadXBlack,u.NoteheadXBlack,u.NoteheadXBlack,u.ArticStaccatoAbove,$e.Outside),X.create(30,"Reverse Cymbal",-3,49,u.NoteheadXBlack,u.NoteheadXBlack,u.NoteheadXBlack),X.create(33,"Metronome",3,37,u.NoteheadXBlack,u.NoteheadXBlack,u.NoteheadXBlack),X.create(34,"Metronome",3,38,u.N
vendor: 17,018 bytes, line 1
1oteheadBlack,u.NoteheadBlack,u.NoteheadBlack)].map(e=>[e.uniqueId,e]));static _instrumentArticulationNames=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 _gp6ElementAndVariationToArticulation=[[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,t){return e<Xe._gp6ElementAndVariationToArticulation.length?(t>=Xe._gp6ElementAndVariationToArticulation.length&&(t=0),Xe._gp6ElementAndVariationToArticulation[e][t]):38}static getArticulationName(e){const t=Xe.getArticulation(e);if(t){const s=t.uniqueId;for(const[i,r]of Xe.instrumentArticulationNames)if(r===s)return i}else{const s=`.${e.percussionArticulation}`;for(const[i,r]of Xe.instrumentArticulationNames)if(r.endsWith(s))return i}return"unknown"}static getArticulation(e){const t=e.percussionArticulation;if(t<0)return null;const s=e.beat.voice.bar.staff.track.percussionArticulations;return t<s.length?s[t]:Xe.getArticulationById(t)}static _instrumentArticulationsById;static _initArticulationsById(){let e=Xe._instrumentArticulationsById;if(!e){e=new Map;for(const t of Xe.instrumentArticulations.values())e.set(t.id,t);Xe._instrumentArticulationsById=e}return e}static instrumentArticulationIds(){return Xe._initArticulationsById().keys()}static getArticulationById(e){const t=Xe._initArticulationsById();return t.has(e)?t.get(e):null}static getElementAndVariation(e){const t=Xe.getArticulation(e);if(!t)return[-1,-1];for(let s=0;s<Xe._gp6ElementAndVariationToArticulation.length;s++){const i=Xe._gp6ElementAndVariationToArticulation[s];for(let r=0;r<i.length;r++)if(Xe.getArticulationById(i[r])?.outputMidiNumber===t.outputMidiNumber)return[s,r]}return[-1,-1]}static instrumentArticulationNames=Xe._mergeNames([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"]]),Xe._instrumentArticulationNames]);static _mergeNames(e){const t=new Map(e[0]);for(let s=1;s<e.length;s++)for(const[i,r]of e[s])t.set(i,r);return t}static _articulationsByOutputNumber;static tryMatchKnownArticulation(e){let t=Xe._articulationsByOutputNumber;if(!t){t=new Map;for(const s of Xe.instrumentArticulations.values())t.has(s.outputMidiNumber)||t.set(s.outputMidiNumber,s);Xe._articulationsByOutputNumber=t}return t.has(e.outputMidiNumber)?t.get(e.outputMidiNumber).id:-1}static _instrumentArticulationsByUniqueId;static getInstrumentArticulationByUniqueId(e){let t=Xe._instrumentArticulationsByUniqueId;if(!t){t=new Map;for(const s of Xe.instrumentArticulations.values())t.set(s.uniqueId,s);Xe._instrumentArticulationsByUniqueId=t}return t.has(e)?t.get(e):void 0}}var ot;(function(a){a[a.None=0]="None",a[a.InvertedTurn=1]="InvertedTurn",a[a.Turn=2]="Turn",a[a.UpperMordent=3]="UpperMordent",a[a.LowerMordent=4]="LowerMordent"})(ot||(ot={}));class Ni{tieDestinationNoteId=-1;tieOriginNoteId=-1;slurDestinationNoteId=-1;slurOriginNoteId=-1;hammerPullDestinationNoteId=-1;hammerPullOriginNoteId=-1;slideTargetNoteId=-1;slideOriginNoteId=-1}var $t;(function(a){a[a.Effects=0]="Effects",a[a.StandardNotationNoteHead=1]="StandardNotationNoteHead",a[a.StandardNotationAccidentals=2]="StandardNotationAccidentals",a[a.StandardNotationEffects=3]="StandardNotationEffects",a[a.GuitarTabFretNumber=4]="GuitarTabFretNumber",a[a.GuitarTabEffects=5]="GuitarTabEffects",a[a.SlashNoteHead=6]="SlashNoteHead",a[a.SlashEffects=7]="SlashEffects",a[a.NumberedNumber=8]="NumberedNumber",a[a.NumberedAccidentals=9]="NumberedAccidentals",a[a.NumberedEffects=10]="NumberedEffects"})($t||($t={}));class Kn extends tr{noteHead;noteHeadCenterOnStem}class kt{static globalNoteId=0;static resetIds(){kt.globalNoteId=0}id=kt.globalNoteId++;index=0;accentuated=ct.None;bendType=$.None;bendStyle=Ke.Default;bendOrigin=null;isContinuedBend=!1;bendPoints=null;maxBendPoint=null;get hasBend(){return this.bendPoints!==null&&this.bendType!==$.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?Xe.getElementAndVariation(this)[0]:-1}get variation(){return this.isPercussion?Xe.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!==te.None}harmonicType=te.None;harmonicValue=0;isGhost=!1;isLetRing=!1;letRingDestination=null;isPalmMute=!1;palmMuteDestination=null;isDead=!1;isStaccato=!1;slideInType=St.None;slideOutType=he.None;slideTarget=null;slideOrigin=null;vibrato=Be.None;tieOrigin=null;tieDestination=null;isTieDestination=!1;get isTieOrigin(){return this.tieDestination!==null}leftHandFinger=ie.Unknown;rightHandFinger=ie.Unknown;get isFingering(){return this.leftHandFinger!==ie.Unknown||this.rightHandFinger!==ie.Unknown}trillValue=-1;get trillFret(){return this.trillValue-this.stringTuning}get isTrill(){return this.trillValue>=0}trillSpeed=y.ThirtySecond;durationPercent=1;accidentalMode=oe.Default;beat;dynamics=se.F;isEffectSlurOrigin=!1;hasEffectSlur=!1;get isEffectSlurDestination(){return!!this.effectSlurOrigin}effectSlurOrigin=null;effectSlurDestination=null;ornament=ot.None;style;get stringTuning(){return this.beat.voice.bar.staff.capo+kt.getStringTuning(this.beat.voice.bar.staff,this.string)}static getStringTuning(e,t){return e.tuning.length>0?e.tuning[e.tuning.length-(t-1)-1]:0}get realValue(){return this.calculateRealValue(!0,!0)}get realValueWithoutHarmonic(){return this.calculateRealValue(!0,!1)}calculateRealValue(e,t){const s=e?this.beat.voice.bar.staff.transpositionPitch:0;if(t){let i=this.calculateRealValue(e,!1);return this.isStringed&&(this.harmonicType===te.Natural?i=this.harmonicPitch+this.stringTuning-s:i+=this.harmonicPitch),i}return this.isPercussion?this.percussionArticulation:this.isStringed?this.fret+this.stringTuning-s:this.isPiano?this.octave*12+this.tone-s:0}get harmonicPitch(){if(this.harmonicType===te.None||!this.isStringed)return 0;const e=this.harmonicValue;return L.isAlmostEqualTo(e,2.4)?36:L.isAlmostEqualTo(e,2.7)?34:e<3?0:e<=3.5?31:e<=4?28:e<=5?24:e<=6?34:e<=7?19:e<=8.5?36:e<=9?28:e<=10?34:e<=11?0:e<=12?12:e<14?0:e<=15?34:e<=16?28:e<=17?36:e<=18?0:e<=19?19:e<=21?0:e<=22?36:e<=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 e=this.realValue;switch(this.harmonicType!==te.Natural&&this.harmonicType!==te.None&&(e-=this.harmonicPitch),this.beat.ottava){case le._15ma:e-=24;break;case le._8va:e-=12;break;case le.Regular:break;case le._8vb:e+=12;break;case le._15mb:e+=24;break}switch(this.beat.voice.bar.clefOttava){case le._15ma:e-=24;break;case le._8va:e-=12;break;case le.Regular:break;case le._8vb:e+=12;break;case le._15mb:e+=24;break}return e-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:!1}addBendPoint(e){let t=this.bendPoints;t===null&&(t=[],this.bendPoints=t),t.push(e),(!this.maxBendPoint||e.value>this.maxBendPoint.value)&&(this.maxBendPoint=e),this.bendType===$.None&&(this.bendType=$.Custom)}finish(e,t=null){const s=new mr(()=>kt.nextNoteOnSameLine(this)),i=e&&e.notation.notationMode===Vt.SongBook;if(this.isTieDestination&&(this.chain(t),i&&this.tieOrigin&&this.tieOrigin.isLetRing&&(this.isLetRing=!0)),this.isLetRing&&(!s.value||!s.value.isLetRing?this.letRingDestination=this:this.letRingDestination=s.value,i&&this.isTieDestination&&!this.tieOrigin.hasBend&&(this.isVisible=!1)),this.isPalmMute&&(!s.value||!s.value.isPalmMute?this.palmMuteDestination=this:this.palmMuteDestination=s.value),this.isHammerPullOrigin){const l=kt.findHammerPullDestination(this);l?(this.hammerPullDestination=l,l.hammerPullOrigin=this):this.isHammerPullOrigin=!1}switch(this.slideOutType){case he.Shift:case he.Legato:this.slideTarget||(this.slideTarget=s.value),this.slideTarget?this.slideTarget.slideOrigin=this:this.slideOutType=he.None;break}let r=null;this.isHammerPullOrigin&&this.hammerPullDestination?r=this.hammerPullDestination:this.slideOutType===he.Legato&&this.slideTarget&&(r=this.slideTarget),r&&(this.hasEffectSlur=!0,this.effectSlurOrigin&&this.beat.pickStroke===Ct.None?(this.effectSlurOrigin.effectSlurDestination=r,this.effectSlurOrigin.effectSlurDestination.effectSlurOrigin=this.effectSlurOrigin,this.effectSlurOrigin=null):(this.isEffectSlurOrigin=!0,this.effectSlurDestination=r,this.effectSlurDestination.effectSlurOrigin=this));const n=this.bendPoints,o=n!=null&&n.length>0;if(o){const l=this.isTieDestination&&this.tieOrigin.hasBend;this.isContinuedBend=l}else this.bendType=$.None;if(o&&this.bendType===$.Custom){if(n.length===4){const l=n[0],h=n[1],c=n[2],d=n[3];h.value===c.value?d.value>l.value?h.value>d.value?this.bendType=$.BendRelease:!this.isContinuedBend&&l.value>0?(this.bendType=$.PrebendBend,n.splice(2,1),n.splice(1,1)):(this.bendType=$.Bend,n.splice(2,1),n.splice(1,1)):d.value<l.value?this.isContinuedBend?(this.bendType=$.Release,n.splice(2,1),n.splice(1,1)):(this.bendType=$.PrebendRelease,n.splice(2,1),n.splice(1,1)):h.value>l.value?this.bendType=$.BendRelease:l.value>0&&!this.isContinuedBend?(this.bendType=$.Prebend,n.splice(2,1),n.splice(1,1)):(this.bendType=$.Hold,n.splice(2,1),n.splice(1,1)):E.warning("Model","Unsupported bend type detected, fallback to custom",null)}else if(n.length===3){const l=n[0],h=n[1],c=n[2];c.value>l.value?h.value>c.value?(this.bendType=$.BendRelease,n.splice(1,0,new G(h.offset,h.value))):!this.isContinuedBend&&l.value>0?(this.bendType=$.PrebendBend,n.splice(1,1)):(this.bendType=$.Bend,n.splice(1,1)):c.value<l.value?this.isContinuedBend?(this.bendType=$.Release,n.splice(1,1)):(this.bendType=$.PrebendRelease,n.splice(1,1)):h.value>l.value?(this.bendType=$.BendRelease,n.splice(1,0,new G(h.offset,h.value))):l.value>0&&!this.isContinuedBend?(this.bendType=$.Prebend,n.splice(1,1)):(this.bendType=$.Hold,n.splice(1,1))}else if(n.length===2){const l=n[0],h=n[1];h.value>l.value?!this.isContinuedBend&&l.value>0?this.bendType=$.PrebendBend:this.bendType=$.Bend:h.value<l.value?this.isContinuedBend?this.bendType=$.Release:this.bendType=$.PrebendRelease:l.value>0&&!this.isContinuedBend?this.bendType=$.Prebend:this.bendType=$.Hold}}this.initialBendValue>0&&(this.accidentalMode=oe.Default)}static _maxOffsetForSameLineSearch=3;static nextNoteOnSameLine(e){let t=e.beat.nextBeat;for(;t&&t.voice.bar.index<=e.beat.voice.bar.index+kt._maxOffsetForSameLineSearch;){const s=t.getNoteOnString(e.string);if(s)return s;t=t.nextBeat}return null}static findHammerPullDestination(e){let t=e.beat.nextBeat;for(;t&&t.voice.bar.index<=e.beat.voice.bar.index+kt._maxOffsetForSameLineSearch;){let s=t.getNoteOnString(e.string);if(s)return s;for(let i=e.string;i>0;i--)if(s=t.getNoteOnString(i),s){if(s.isLeftHandTapped)return s;break}for(let i=e.string;i<=e.beat.voice.bar.staff.tuning.length;i++)if(s=t.getNoteOnString(i),s){if(s.isLeftHandTapped)return s;break}t=t.nextBeat}return null}static findTieOrigin(e){let t=e.beat.previousBeat;for(;t&&t.voice.bar.index>=e.beat.voice.bar.index-kt._maxOffsetForSameLineSearch;){if(e.isStringed){const s=t.getNoteOnString(e.string);if(s)return s}else if(e.octave===-1&&e.tone===-1){if(e.index<t.notes.length)return t.notes[e.index]}else{const s=t.getNoteWithRealValue(e.realValue);if(s)return s}t=t.previousBeat}return null}static _noteIdLookupKey="NoteIdLookup";_noteIdBag=null;chain(e=null){if(e!==null)if(this._noteIdBag!==null){let t;e.has(kt._noteIdLookupKey)?t=e.get(kt._noteIdLookupKey):(t=new Map,e.set(kt._noteIdLookupKey,t)),(this._noteIdBag.hammerPullDestinationNoteId!==-1||this._noteIdBag.tieDestinationNoteId!==-1||this._noteIdBag.slurDestinationNoteId!==-1||this._noteIdBag.slideTargetNoteId!==-1)&&t.set(this.id,this),this._noteIdBag.hammerPullOriginNoteId!==-1&&(this.hammerPullOrigin=t.get(this._noteIdBag.hammerPullOriginNoteId),this.hammerPullOrigin.hammerPullDestination=this),this._noteIdBag.tieOriginNoteId!==-1&&(this.tieOrigin=t.get(this._noteIdBag.tieOriginNoteId),this.tieOrigin.tieDe
1stination=this),this._noteIdBag.slurOriginNoteId!==-1&&(this.slurOrigin=t.get(this._noteIdBag.slurOriginNoteId),this.slurOrigin.slurDestination=this),this._noteIdBag.slideOriginNoteId!==-1&&(this.slideOrigin=t.get(this._noteIdBag.slideOriginNoteId),this.slideOrigin.slideTarget=this),this._noteIdBag=null}else{if(!this.isTieDestination&&this.tieOrigin===null)return;const t=this.tieOrigin??kt.findTieOrigin(this);t?(t.tieDestination=this,this.tieOrigin=t,this.fret=t.fret,this.octave=t.octave,this.tone=t.tone,t.hasBend&&(this.bendOrigin=this.tieOrigin)):this.isTieDestination=!1}}toJson(e){this.tieDestination!==null&&e.set("tiedestinationnoteid",this.tieDestination.id),this.tieOrigin!==null&&e.set("tieoriginnoteid",this.tieOrigin.id),this.slurDestination!==null&&e.set("slurdestinationnoteid",this.slurDestination.id),this.slurOrigin!==null&&e.set("sluroriginnoteid",this.slurOrigin.id),this.hammerPullOrigin!==null&&e.set("hammerpulloriginnoteid",this.hammerPullOrigin.id),this.hammerPullDestination!==null&&e.set("hammerpulldestinationnoteid",this.hammerPullDestination.id),this.slideTarget!==null&&e.set("slidetargetnoteid",this.slideTarget.id),this.slideOrigin!==null&&e.set("slideoriginnoteid",this.slideOrigin.id)}setProperty(e,t){switch(e){case"tiedestinationnoteid":return this._noteIdBag==null&&(this._noteIdBag=new Ni),this._noteIdBag.tieDestinationNoteId=t,!0;case"tieoriginnoteid":return this._noteIdBag==null&&(this._noteIdBag=new Ni),this._noteIdBag.tieOriginNoteId=t,!0;case"slurdestinationnoteid":return this._noteIdBag==null&&(this._noteIdBag=new Ni),this._noteIdBag.slurDestinationNoteId=t,!0;case"sluroriginnoteid":return this._noteIdBag==null&&(this._noteIdBag=new Ni),this._noteIdBag.slurOriginNoteId=t,!0;case"hammerpulloriginnoteid":return this._noteIdBag==null&&(this._noteIdBag=new Ni),this._noteIdBag.hammerPullOriginNoteId=t,!0;case"hammerpulldestinationnoteid":return this._noteIdBag==null&&(this._noteIdBag=new Ni),this._noteIdBag.hammerPullDestinationNoteId=t,!0;case"slidetargetnoteid":return this._noteIdBag==null&&(this._noteIdBag=new Ni),this._noteIdBag.slideTargetNoteId=t,!0;case"slideoriginnoteid":return this._noteIdBag==null&&(this._noteIdBag=new Ni),this._noteIdBag.slideOriginNoteId=t,!0}return!1}}class Fs{static _halfTicks=1920;static _quarterTicks=960;static _eighthTicks=480;static _sixteenthTicks=240;static _thirtySecondTicks=120;static _sixtyFourthTicks=60;static _oneHundredTwentyEighthTicks=30;static _twoHundredFiftySixthTicks=15;static _allTicks=[Fs._halfTicks,Fs._quarterTicks,Fs._eighthTicks,Fs._sixteenthTicks,Fs._thirtySecondTicks,Fs._sixtyFourthTicks,Fs._oneHundredTwentyEighthTicks,Fs._twoHundredFiftySixthTicks];_isEqualLengthTuplet=!0;totalDuration=0;beats=[];voice;isFull=!1;constructor(e){this.voice=e}check(e){if(this.beats.length===0)return this.beats.push(e),this.totalDuration+=e.playbackDuration,!0;if(e.graceType!==K.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._isEqualLengthTuplet=!1),this.beats.push(e),this.totalDuration+=e.displayDuration,this._isEqualLengthTuplet)this.beats.length===this.beats[0].tupletNumerator&&(this.isFull=!0);else{const t=this.beats[0].tupletNumerator/this.beats[0].tupletDenominator|0;for(const s of Fs._allTicks)if(this.totalDuration===s*t){this.isFull=!0;break}}return!0}}var Pe;(function(a){a[a.None=0]="None",a[a.Custom=1]="Custom",a[a.Dive=2]="Dive",a[a.Dip=3]="Dip",a[a.Hold=4]="Hold",a[a.Predive=5]="Predive",a[a.PrediveDive=6]="PrediveDive"})(Pe||(Pe={}));var Xt;(function(a){a[a.None=0]="None",a[a.Thumb=1]="Thumb",a[a.Finger=2]="Finger"})(Xt||(Xt={}));var yt;(function(a){a[a.None=0]="None",a[a.FadeIn=1]="FadeIn",a[a.FadeOut=2]="FadeOut",a[a.VolumeSwell=3]="VolumeSwell"})(yt||(yt={}));var ss;(function(a){a[a.None=0]="None",a[a.Open=1]="Open",a[a.Closed=2]="Closed"})(ss||(ss={}));var xs;(function(a){a[a.None=0]="None",a[a.Full=1]="Full",a[a.Half=2]="Half"})(xs||(xs={}));var ne;(function(a){a[a.None=0]="None",a[a.Ii=1]="Ii",a[a.Mi=2]="Mi",a[a.MiiTriplet=3]="MiiTriplet",a[a.MiiAnapaest=4]="MiiAnapaest",a[a.PmpTriplet=5]="PmpTriplet",a[a.PmpAnapaest=6]="PmpAnapaest",a[a.PeiTriplet=7]="PeiTriplet",a[a.PeiAnapaest=8]="PeiAnapaest",a[a.PaiTriplet=9]="PaiTriplet",a[a.PaiAnapaest=10]="PaiAnapaest",a[a.AmiTriplet=11]="AmiTriplet",a[a.AmiAnapaest=12]="AmiAnapaest",a[a.Ppp=13]="Ppp",a[a.Amii=14]="Amii",a[a.Amip=15]="Amip",a[a.Eami=16]="Eami",a[a.Eamii=17]="Eamii",a[a.Peami=18]="Peami"})(ne||(ne={}));var wi;(function(a){a[a.Default=0]="Default",a[a.BuzzRoll=1]="BuzzRoll"})(wi||(wi={}));class Ts{static minMarks=0;static maxMarks=5;marks=0;style=wi.Default;getDuration(e){let t=this.marks;t<1&&(t=1);const i=e*Math.pow(2,t);return i<=y.TwoHundredFiftySixth?i:y.TwoHundredFiftySixth}getDurationAsTicks(e){let t=this.marks;t<1&&(t=1);const i=e*Math.pow(2,t);return B.valueToTicks(i)}}var st;(function(a){a[a.Auto=0]="Auto",a[a.ForceSplitToNext=1]="ForceSplitToNext",a[a.ForceMergeWithNext=2]="ForceMergeWithNext",a[a.ForceSplitOnSecondaryToNext=3]="ForceSplitOnSecondaryToNext"})(st||(st={}));var rt;(function(a){a[a.Effects=0]="Effects",a[a.StandardNotationStem=1]="StandardNotationStem",a[a.StandardNotationFlags=2]="StandardNotationFlags",a[a.StandardNotationBeams=3]="StandardNotationBeams",a[a.StandardNotationTuplet=4]="StandardNotationTuplet",a[a.StandardNotationEffects=5]="StandardNotationEffects",a[a.StandardNotationRests=6]="StandardNotationRests",a[a.GuitarTabStem=7]="GuitarTabStem",a[a.GuitarTabFlags=8]="GuitarTabFlags",a[a.GuitarTabBeams=9]="GuitarTabBeams",a[a.GuitarTabTuplet=10]="GuitarTabTuplet",a[a.GuitarTabEffects=11]="GuitarTabEffects",a[a.GuitarTabRests=12]="GuitarTabRests",a[a.SlashStem=13]="SlashStem",a[a.SlashFlags=14]="SlashFlags",a[a.SlashBeams=15]="SlashBeams",a[a.SlashTuplet=16]="SlashTuplet",a[a.SlashRests=17]="SlashRests",a[a.SlashEffects=18]="SlashEffects",a[a.NumberedDuration=19]="NumberedDuration",a[a.NumberedEffects=20]="NumberedEffects",a[a.NumberedRests=21]="NumberedRests",a[a.NumberedTuplet=22]="NumberedTuplet"})(rt||(rt={}));class zl extends tr{}class Dt{static _globalBeatId=0;static resetIds(){Dt._globalBeatId=0}id=Dt._globalBeatId++;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=Ke.Default;ottava=le.Regular;fermata=null;isLegatoOrigin=!1;get isLegatoDestination(){return!!this.previousBeat&&this.previousBeat.isLegatoOrigin}minNote=null;maxNote=null;maxStringNote=null;minStringNote=null;duration=y.Quarter;get isRest(){return this.isEmpty||!this.deadSlapped&&this.notes.length===0}get isFullBarRest(){return this.isRest&&this.voice.beats.length===1&&this.duration===y.Whole}isLetRing=!1;isPalmMute=!1;automations=[];dots=0;get fadeIn(){return this.fade===yt.FadeIn}set fadeIn(e){this.fade=e?yt.FadeIn:yt.None}fade=yt.None;lyrics=null;get hasRasgueado(){return this.rasgueado!==ne.None}pop=!1;slap=!1;tap=!1;text=null;slashed=!1;deadSlapped=!1;brushType=z.None;brushDuration=0;tupletDenominator=-1;tupletNumerator=-1;get hasTuplet(){return!(this.tupletDenominator===-1&&this.tupletNumerator===-1)&&!(this.tupletDenominator===1&&this.tupletNumerator===1)}tupletGroup=null;isContinuedWhammy=!1;whammyBarType=Pe.None;whammyBarPoints=null;maxWhammyPoint=null;minWhammyPoint=null;get hasWhammyBar(){return this.whammyBarPoints!==null&&this.whammyBarType!==Pe.None}vibrato=Be.None;chordId=null;get hasChord(){return!!this.chordId}get chord(){return this.chordId?this.voice.bar.staff.getChord(this.chordId):null}graceType=K.None;graceGroup=null;graceIndex=-1;pickStroke=Ct.None;get isTremolo(){return this.tremoloPicking!==void 0}tremoloPicking;get tremoloSpeed(){const e=this.tremoloPicking;return e?e.getDuration(this.duration):null}set tremoloSpeed(e){if(e===null){this.tremoloPicking=void 0;return}let t=this.tremoloPicking;switch(t===void 0&&(t=new Ts,this.tremoloPicking=t),e){case y.Eighth:t.marks=1;break;case y.Sixteenth:t.marks=2;break;case y.ThirtySecond:t.marks=3;break;case y.SixtyFourth:t.marks=4;break;case y.OneHundredTwentyEighth:t.marks=5;break}}crescendo=Gt.None;displayStart=0;get displayEnd(){return this.displayStart+this.displayDuration}playbackStart=0;displayDuration=0;playbackDuration=0;overrideDisplayDuration;golpe=Xt.None;get absoluteDisplayStart(){return this.voice.bar.masterBar.start+this.displayStart}get absolutePlaybackStart(){return this.voice.bar.masterBar.start+this.playbackStart}dynamics=se.F;invertBeamDirection=!1;preferredBeamDirection=null;isEffectSlurOrigin=!1;get isEffectSlurDestination(){return!!this.effectSlurOrigin}effectSlurOrigin=null;effectSlurDestination=null;beamingMode=st.Auto;wahPedal=ss.None;barreFret=-1;barreShape=xs.None;get isBarre(){return this.barreShape!==xs.None&&this.barreFret>=0}rasgueado=ne.None;showTimer=!1;timer=null;style;addWhammyBarPoint(e){let t=this.whammyBarPoints;t===null&&(t=[],this.whammyBarPoints=t),t.push(e),(!this.maxWhammyPoint||e.value>this.maxWhammyPoint.value)&&(this.maxWhammyPoint=e),(!this.minWhammyPoint||e.value<this.minWhammyPoint.value)&&(this.minWhammyPoint=e),this.whammyBarType===Pe.None&&(this.whammyBarType=Pe.Custom)}removeWhammyBarPoint(e){const t=this.whammyBarPoints;if(t===null||e<0||e>=t.length)return;t.splice(e,1);const s=t[e];if(s===this.maxWhammyPoint){this.maxWhammyPoint=null;for(const i of t)(!this.maxWhammyPoint||i.value>this.maxWhammyPoint.value)&&(this.maxWhammyPoint=i)}if(s===this.minWhammyPoint){this.minWhammyPoint=null;for(const i of t)(!this.minWhammyPoint||i.value<this.minWhammyPoint.value)&&(this.minWhammyPoint=i)}}
1addNote(e){e.beat=this,e.index=this.notes.length,this.notes.push(e),e.isStringed&&this.noteStringLookup.set(e.string,e)}removeNote(e){const t=this.notes.indexOf(e);t>=0&&(this.notes.splice(t,1),e.isStringed&&this.noteStringLookup.delete(e.string))}getAutomation(e){for(let t=0,s=this.automations.length;t<s;t++){const i=this.automations[t];if(i.type===e)return i}return null}getNoteOnString(e){return this.noteStringLookup.has(e)?this.noteStringLookup.get(e):null}_calculateDuration(){if(this.overrideDisplayDuration!==void 0)return this.overrideDisplayDuration;if(this.isFullBarRest)return this.voice.bar.masterBar.calculateDuration();let e=B.toTicks(this.duration);return this.dots===2?e=B.applyDot(e,!0):this.dots===1&&(e=B.applyDot(e,!1)),this.tupletDenominator>0&&this.tupletNumerator>=0&&(e=B.applyTuplet(e,this.tupletNumerator,this.tupletDenominator)),e}updateDurations(){const e=this._calculateDuration();switch(this.playbackDuration=e,this.graceType){case K.BeforeBeat:case K.OnBeat:switch(this.duration){case y.Sixteenth:this.playbackDuration=B.toTicks(y.SixtyFourth);break;case y.ThirtySecond:this.playbackDuration=B.toTicks(y.OneHundredTwentyEighth);break;default:this.playbackDuration=B.toTicks(y.ThirtySecond);break}this.displayDuration=0;break;case K.BendGrace:this.playbackDuration/=2,this.displayDuration=0;break;default:this.displayDuration=e;const t=this.previousBeat;t&&t.graceType===K.BendGrace&&(this.playbackDuration=t.playbackDuration);break}}finishTuplet(){const e=this.previousBeat;let t=e?e.tupletGroup:null;(this.hasTuplet||this.graceType!==K.None&&t)&&((!e||!t||!t.check(this))&&(t=new Fs(this.voice),t.check(this)),this.tupletGroup=t);const s=this.voice.bar.masterBar.calculateDuration(!1),i=[];for(const r of this.automations)r.ratioPosition===0&&(r.ratioPosition=this.playbackStart/s),r.type!==Re.Tempo&&i.push(r);this.automations=i}finish(e,t=null){switch(this.getAutomation(Re.Instrument)===null&&this.index===0&&this.voice.index===0&&this.voice.bar.index===0&&this.voice.bar.staff.index===0&&this.automations.push(tt.buildInstrumentAutomation(!1,0,this.voice.bar.staff.track.playbackInfo.program)),this.graceType){case K.OnBeat:case K.BeforeBeat:const d=this.graceGroup.beats.length;d===1?this.duration=y.Eighth:d===2?this.duration=y.Sixteenth:this.duration=y.ThirtySecond;break}this.brushType===z.None&&(this.brushDuration=0);const s=this.tremoloPicking;s!==void 0&&(s.marks<Ts.minMarks||s.marks>Ts.maxMarks)&&(this.tremoloPicking=void 0);const i=e?e.notation.notationMode:Vt.GuitarPro;let r=this.text==="grad"||this.text==="grad.";r&&i===Vt.SongBook&&(this.text="");let n=!1;this.minNote=null,this.maxNote=null,this.minStringNote=null,this.maxStringNote=null;let o=0,l=!1;for(let d=0,f=this.notes.length;d<f;d++){const p=this.notes[d];if(p.dynamics=this.dynamics,p.finish(e,t),p.isLetRing&&(this.isLetRing=!0),p.isPalmMute&&(this.isPalmMute=!0),i===Vt.SongBook&&p.hasBend&&this.graceType!==K.BendGrace){if(!p.isTieOrigin)switch(p.bendType){case $.Bend:case $.PrebendRelease:case $.PrebendBend:n=!0;break}r||p.bendStyle===Ke.Gradual?(r=!0,p.bendStyle=Ke.Gradual,n=!1):p.bendStyle=Ke.Fast}p.isVisible&&(o++,(!this.minNote||p.realValue<this.minNote.realValue)&&(this.minNote=p),(!this.maxNote||p.realValue>this.maxNote.realValue)&&(this.maxNote=p),(!this.minStringNote||p.string<this.minStringNote.string)&&(this.minStringNote=p),(!this.maxStringNote||p.string>this.maxStringNote.string)&&(this.maxStringNote=p),p.hasEffectSlur&&(l=!0))}if(l&&(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&&o===0&&(this.isEmpty=!0),!this.isRest&&(!this.isLetRing||!this.isPalmMute)){let d=this.previousBeat;for(;d&&d.isRest;)this.isLetRing||(d.isLetRing=!1),this.isPalmMute||(d.isPalmMute=!1),d=d.previousBeat}else this.isRest&&this.previousBeat&&e&&e.notation.notationMode===Vt.GuitarPro&&(this.previousBeat.isLetRing&&(this.isLetRing=!0),this.previousBeat.isPalmMute&&(this.isPalmMute=!0));const h=this.whammyBarPoints,c=h!==null&&h.length>0;if(c){const d=!!this.previousBeat&&this.previousBeat.hasWhammyBar;this.isContinuedWhammy=d}else this.whammyBarType=Pe.None;if(c&&this.whammyBarType===Pe.Custom){if(i===Vt.SongBook&&(this.whammyStyle=r?Ke.Gradual:Ke.Fast),h.length===4){const d=h[0],f=h[1],p=h[2],g=h[3];f.value===p.value&&(d.value<f.value&&f.value<g.value||d.value>f.value&&f.value>g.value?(d.value!==0&&!this.isContinuedWhammy?this.whammyBarType=Pe.PrediveDive:this.whammyBarType=Pe.Dive,h.splice(2,1),h.splice(1,1)):d.value>f.value&&f.value<g.value||d.value<f.value&&f.value>g.value?(this.whammyBarType=Pe.Dip,(f.offset===p.offset||i===Vt.SongBook)&&h.splice(2,1)):d.value===f.value&&f.value===g.value&&(d.value!==0&&!this.isContinuedWhammy?this.whammyBarType=Pe.Predive:this.whammyBarType=Pe.Hold,h.splice(2,1),h.splice(1,1)))}else if(h.length===3){const d=h[0],f=h[1],p=h[2];d.value<f.value&&f.value<p.value||d.value>f.value&&f.value>p.value?(d.value!==0&&!this.isContinuedWhammy?this.whammyBarType=Pe.PrediveDive:this.whammyBarType=Pe.Dive,h.splice(1,1)):d.value>f.value&&f.value<p.value||d.value<f.value&&f.value>p.value?this.whammyBarType=Pe.Dip:d.value===f.value&&f.value===p.value&&(d.value!==0&&!this.isContinuedWhammy?this.whammyBarType=Pe.Predive:this.whammyBarType=Pe.Hold,h.splice(1,1))}else if(h.length===2){const d=h[0],f=h[1];d.value<f.value||d.value>f.value?d.value!==0&&!this.isContinuedWhammy?this.whammyBarType=Pe.PrediveDive:this.whammyBarType=Pe.Dive:d.value===f.value&&(d.value!==0&&!this.isContinuedWhammy?this.whammyBarType=Pe.Predive:this.whammyBarType=Pe.Hold)}}if(this.updateDurations(),n){const d=Zn.clone(this);d.id=Dt._globalBeatId++,d.pickStroke=Ct.None;for(let f=0,p=d.notes.length;f<p;f++){const g=d.notes[f],m=this.notes[f];if(g.bendType=$.None,g.maxBendPoint=null,g.bendPoints=null,g.bendStyle=Ke.Default,g.id=kt.globalNoteId++,m.isTieOrigin&&(g.tieDestination=m.tieDestination,m.tieDestination.tieOrigin=g),m.isTieDestination&&(g.tieOrigin=m.tieOrigin?m.tieOrigin:null,m.tieOrigin.tieDe
vendor: 24,119 bytes, line 1
1stination=g),m.hasBend&&m.isTieOrigin){const b=kt.findTieOrigin(m);if(b&&b.hasBend){g.bendType=$.Hold;const S=m.bendPoints[m.bendPoints.length-1];g.addBendPoint(new G(0,S.value)),g.addBendPoint(new G(G.MaxPosition,S.value))}}g.isTieDestination=!0}this.graceType=K.BendGrace,this.graceGroup=new ba,this.graceGroup.addBeat(this),this.graceGroup.isComplete=!0,this.graceGroup.finish(),this.updateDurations(),this.voice.insertBeat(this,d),d.graceGroup=new ba,d.graceGroup.addBeat(this),d.graceGroup.isComplete=!0,d.graceGroup.finish()}}isBefore(e){return this.voice.bar.index<e.voice.bar.index||e.voice.bar.index===this.voice.bar.index&&this.index<e.index}isAfter(e){return this.voice.bar.index>e.voice.bar.index||e.voice.bar.index===this.voice.bar.index&&this.index>e.index}hasNoteOnString(e){return this.noteStringLookup.has(e)}getNoteWithRealValue(e){return this.noteValueLookup.has(e)?this.noteValueLookup.get(e):null}chain(e=null){for(const t of this.notes)this.noteValueLookup.set(t.realValue,t),t.chain(e)}}class Yl{static clone(e){const t=new G;return t.offset=e.offset,t.value=e.value,t}}class Xl{static clone(e){const t=new kt;if(t.index=e.index,t.accentuated=e.accentuated,t.bendType=e.bendType,t.bendStyle=e.bendStyle,t.isContinuedBend=e.isContinuedBend,e.bendPoints){t.bendPoints=[];for(const s of e.bendPoints)t.addBendPoint(Yl.clone(s))}return t.fret=e.fret,t.string=e.string,t.showStringNumber=e.showStringNumber,t.octave=e.octave,t.tone=e.tone,t.percussionArticulation=e.percussionArticulation,t.isVisible=e.isVisible,t.isLeftHandTapped=e.isLeftHandTapped,t.isHammerPullOrigin=e.isHammerPullOrigin,t.isSlurDestination=e.isSlurDestination,t.harmonicType=e.harmonicType,t.harmonicValue=e.harmonicValue,t.isGhost=e.isGhost,t.isLetRing=e.isLetRing,t.isPalmMute=e.isPalmMute,t.isDead=e.isDead,t.isStaccato=e.isStaccato,t.slideInType=e.slideInType,t.slideOutType=e.slideOutType,t.vibrato=e.vibrato,t.isTieDestination=e.isTieDestination,t.leftHandFinger=e.leftHandFinger,t.rightHandFinger=e.rightHandFinger,t.trillValue=e.trillValue,t.trillSpeed=e.trillSpeed,t.durationPercent=e.durationPercent,t.accidentalMode=e.accidentalMode,t.dynamics=e.dynamics,t.ornament=e.ornament,t}}class Th{static clone(e){const t=new ra;return t.barOccurence=e.barOccurence,t.millisecondOffset=e.millisecondOffset,t}}class xh{static clone(e){const t=new tt;return t.isLinear=e.isLinear,t.type=e.type,t.value=e.value,t.syncPointValue=e.syncPointValue?Th.clone(e.syncPointValue):void 0,t.ratioPosition=e.ratioPosition,t.text=e.text,t.isVisible=e.isVisible,t}}class Nh{static clone(e){const t=new Ts;return t.marks=e.marks,t.style=e.style,t}}class Zn{static clone(e){const t=new Dt;t.index=e.index,t.notes=[];for(const s of e.notes)t.addNote(Xl.clone(s));t.isEmpty=e.isEmpty,t.whammyStyle=e.whammyStyle,t.ottava=e.ottava,t.isLegatoOrigin=e.isLegatoOrigin,t.duration=e.duration,t.isLetRing=e.isLetRing,t.isPalmMute=e.isPalmMute,t.automations=[];for(const s of e.automations)t.automations.push(xh.clone(s));if(t.dots=e.dots,t.fade=e.fade,t.lyrics=e.lyrics?e.lyrics.slice():null,t.pop=e.pop,t.slap=e.slap,t.tap=e.tap,t.text=e.text,t.slashed=e.slashed,t.deadSlapped=e.deadSlapped,t.brushType=e.brushType,t.brushDuration=e.brushDuration,t.tupletDenominator=e.tupletDenominator,t.tupletNumerator=e.tupletNumerator,t.isContinuedWhammy=e.isContinuedWhammy,t.whammyBarType=e.whammyBarType,e.whammyBarPoints){t.whammyBarPoints=[];for(const s of e.whammyBarPoints)t.addWhammyBarPoint(Yl.clone(s))}return t.vibrato=e.vibrato,t.chordId=e.chordId,t.graceType=e.graceType,t.pickStroke=e.pickStroke,t.tremoloPicking=e.tremoloPicking?Nh.clone(e.tremoloPicking):void 0,t.crescendo=e.crescendo,t.displayStart=e.displayStart,t.playbackStart=e.playbackStart,t.displayDuration=e.displayDuration,t.playbackDuration=e.playbackDuration,t.overrideDisplayDuration=e.overrideDisplayDuration,t.golpe=e.golpe,t.dynamics=e.dynamics,t.invertBeamDirection=e.invertBeamDirection,t.preferredBeamDirection=e.preferredBeamDirection,t.isEffectSlurOrigin=e.isEffectSlurOrigin,t.beamingMode=e.beamingMode,t.wahPedal=e.wahPedal,t.barreFret=e.barreFret,t.barreShape=e.barreShape,t.rasgueado=e.rasgueado,t.showTimer=e.showTimer,t.timer=e.timer,t}}class V{static _reverse(e){const t=new Map;for(const[s,i]of e)t.has(i)||t.set(i,s);return t}static whammyType=new Map([["custom",1],["dive",2],["dip",3],["hold",4],["predive",5],["predivedive",6]]);static whammyTypeReversed=V._reverse(V.whammyType);static bendStyle=new Map([["default",0],["gradual",1],["fast",2]]);static bendStyleReversed=V._reverse(V.bendStyle);static graceType=new Map([["onbeat",1],["beforebeat",2],["bendgrace",3],["ob",1],["bb",2],["b",3]]);static graceTypeReversed=V._reverse(V.graceType);static fermataType=new Map([["short",0],["medium",1],["long",2]]);static fermataTypeReversed=V._reverse(V.fermataType);static alphaTexAccidentalMode=new Map([["auto",0],["explicit",1]]);static alphaTexAccidentalModeReversed=V._reverse(V.alphaTexAccidentalMode);static alphaTexVoiceMode=new Map([["staffwise",0],["barwise",1]]);static alphaTexVoiceModeReversed=V._reverse(V.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=V._reverse(V.noteAccidentalMode);static barreShape=new Map([["full",1],["half",2]]);static barreShapeReversed=V._reverse(V.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=V._reverse(V.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=V._reverse(V.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=V._reverse(V.dynamicValue);static bracketExtendMode=new Map([["nobrackets",0],["groupstaves",1],["groupsimilarinstruments",2]]);static bracketExtendModeReversed=V._reverse(V.bracketExtendMode);static trackNamePolicy=new Map([["hidden",0],["firstsystem",1],["allsystems",2]]);static trackNamePolicyReversed=V._reverse(V.trackNamePolicy);static trackNameOrientation=new Map([["horizontal",0],["vertical",1]]);static trackNameOrientationReversed=V._reverse(V.trackNameOrientation);static trackNameMode=new Map([["fullname",0],["shortname",1]]);static trackNameModeReversed=V._reverse(V.trackNameMode);static textAlign=new Map([["left",0],["center",1],["right",2]]);static textAlignReversed=V._reverse(V.textAlign);static bendType=new Map([["custom",1],["bend",2],["release",3],["bendrelease",4],["hold",5],["prebend",6],["prebendbend",7],["prebendrelease",8]]);static bendTypeReversed=V._reverse(V.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=V._reverse(V.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=V._reverse(V.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=V._reverse(V.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=V._reverse(V.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=V._reverse(V.barLineStyle);static simileMark=new Map([["none",0],["simple",1],["firstofdouble",2],["secondofdouble",3]]);static simileMarkReversed=V._reverse(V.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=V._reverse(V.direction);static tremoloPickingStyle=new Map([["default",0],["buzzroll",1]]);static tremoloPickingStyleReversed=V._reverse(V.tremoloPickingStyle);static barNumberDisplay=new Map([["allbars",0],["firstofsystem",1],["hide",2]]);static barNumberDisplayReversed=V._reverse(V.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#"]])}class Ve{static _param(e){return e?{expectedTypes:new Set(e[0]),parseMode:e[1],allowedValues:e.length>2&&e[2]&&e[2].length>0?new Set(e[2]):void 0,reservedIdentifiers:e.length>3&&e[3]&&e[3].length>0?new Set(e[3]):void 0}:null}static _simple(e){return e==null?null:e.map(t=>({isStrict:t.length>0&&t[0]===null,parameters:t.map(Ve._param).filter(s=>s!==null)}))}static _metaProps(e){return new Map(e.map(t=>[t[0],t[1]===null?null:new Map(t[1].map(s=>[s[0],Ve._simple(s[1])]))]))}static _props(e){return new Map(e.map(t=>[t[0],Ve._simple(t[1])]))}static _signatures(e){return new Map(e.map(t=>[t[0],Ve._simple(t[1])]))}static scoreMetaDataSignatures=Ve._signatures([["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=Ve._signatures([["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=Ve._signatures([["track",[[[[17],1],[[17],1]]]],["staff",null],["voice",null]]);static barMetaDataSignatures=Ve._signatures([["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=Ve._metaProps([["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=[Ve.scoreMetaDataSignatures,Ve.staffMetaDataSignatures,Ve.structuralMetaDataSignatures,Ve.barMetaDataSignatures];static durationChangeProperties=Ve._props([["tu",[[[[16],0,["3","5","6","7","9","10","12"]]],[[[16],0],[[16],0]]]]]);static beatProperties=Ve._props([["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=Ve._props([["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]])}var x;(function(a){a[a.Dot=0]="Dot",a[a.Backslash=1]="Backslash",a[a.DoubleBackslash=2]="DoubleBackslash",a[a.Pipe=3]="Pipe",a[a.LBrace=4]="LBrace",a[a.RBrace=5]="RBrace",a[a.LParen=6]="LParen",a[a.RParen=7]="RParen",a[a.Colon=8]="Colon",a[a.Asterisk=9]="Asterisk",a[a.Ident=10]="Ident",a[a.Tag=11]="Tag",a[a.Meta=12]="Meta",a[a.Arguments=13]="Arguments",a[a.Props=14]="Props",a[a.Prop=15]="Prop",a[a.Number=16]="Number",a[a.String=17]="String",a[a.Score=18]="Score",a[a.Bar=19]="Bar",a[a.Beat=20]="Beat",a[a.Duration=21]="Duration",a[a.NoteList=22]="NoteList",a[a.Note=23]="Note"})(x||(x={}));var ce;(function(a){a[a.Hint=0]="Hint",a[a.Warning=1]="Warning",a[a.Error=2]="Error"})(ce||(ce={}));var fe;(function(a){a[a.AT001=1]="AT001",a[a.AT002=2]="AT002",a[a.AT003=3]="AT003",a[a.AT004=4]="AT004",a[a.AT005=5]="AT005",a[a.AT006=6]="AT006",a[a.AT200=200]="AT200",a[a.AT201=201]="AT201",a[a.AT202=202]="AT202",a[a.AT203=203]="AT203",a[a.AT204=204]="AT204",a[a.AT205=205]="AT205",a[a.AT206=206]="AT206",a[a.AT207=207]="AT207",a[a.AT208=208]="AT208",a[a.AT209=209]="AT209",a[a.AT210=210]="AT210",a[a.AT211=211]="AT211",a[a.AT212=212]="AT212",a[a.AT213=213]="AT213",a[a.AT214=214]="AT214",a[a.AT215=215]="AT215",a[a.AT216=216]="AT216",a[a.AT217=217]="AT217",a[a.AT218=218]="AT218",a[a.AT219=219]="AT219",a[a.AT220=220]="AT220",a[a.AT300=300]="AT300",a[a.AT301=301]="AT301",a[a.AT302=302]="AT302",a[a.AT303=303]="AT303",a[a.AT304=304]="AT304",a[a.AT305=305]="AT305",a[a.AT306=306]="AT306",a[a.AT400=400]="AT400"})(fe||(fe={}));class pn{_hasErrors=!1;items=[];get errors(){return this.items.filter(e=>e.severity===ce.Error)}get hasErrors(){return this._hasErrors}push(e){this.items.push(e),e.severity===ce.Error&&(this._hasErrors=!0)}[Symbol.iterator](){return this.items[Symbol.iterator]()}}var Kr;(function(a){a[a.Auto=0]="Auto",a[a.Explicit=1]="Explicit"})(Kr||(Kr={}));var ri;(function(a){a[a.StaffWise=0]="StaffWise",a[a.BarWise=1]="BarWise"})(ri||(ri={}));var Jt;(function(a){a[a.Pitched=0]="Pitched",a[a.Fretted=1]="Fretted",a[a.Articulation=2]="Articulation"})(Jt||(Jt={}));var Pt;
1(function(a){a[a.Required=0]="Required",a[a.Optional=1]="Optional",a[a.RequiredAsFloat=2]="RequiredAsFloat",a[a.OptionalAsFloat=3]="OptionalAsFloat",a[a.RequiredAsValueList=4]="RequiredAsValueList",a[a.ValueListWithoutParenthesis=5]="ValueListWithoutParenthesis"})(Pt||(Pt={}));class be{static _conversionBuffer=new ArrayBuffer(8);static _conversionByteArray=new Uint8Array(be._conversionBuffer);static _dataView=new DataView(be._conversionBuffer);static float64ToBytes(e){return be._dataView.setFloat64(0,e,!0),be._conversionByteArray}static bytesToInt64LE(e){be._conversionByteArray.set(e,0);const t=be._dataView.getBigInt64(0,!0);return t<=Number.MAX_SAFE_INTEGER&&t>=Number.MIN_SAFE_INTEGER?Number(t):Number.MAX_SAFE_INTEGER}static bytesToFloat64LE(e){return be._conversionByteArray.set(e,0),be._dataView.getFloat64(0,!0)}static bytesToFloat32LE(e){return be._conversionByteArray.set(e,0),be._dataView.getFloat32(0,!0)}static float32BEToBytes(e){return be._dataView.setFloat32(0,e,!1),be._conversionByteArray.slice(0,4)}static uint16ToInt16(e){return be._dataView.setUint16(0,e,!0),be._dataView.getInt16(0,!0)}static int16ToUint32(e){return be._dataView.setInt16(0,e,!0),be._dataView.getUint32(0,!0)}static int32ToUint16(e){return be._dataView.setInt32(0,e,!0),be._dataView.getUint16(0,!0)}static int32ToInt16(e){return be._dataView.setInt32(0,e,!0),be._dataView.getInt16(0,!0)}static int32ToUint32(e){return be._dataView.setInt32(0,e,!0),be._dataView.getUint32(0,!0)}static uint8ToInt8(e){return be._dataView.setUint8(0,e),be._dataView.getInt8(0)}}class k{static readInt32BE(e){const t=e.readByte(),s=e.readByte(),i=e.readByte(),r=e.readByte();return t<<24|s<<16|i<<8|r}static readFloat32BE(e){const t=new Uint8Array(4);return e.read(t,0,t.length),t.reverse(),be.bytesToFloat32LE(t)}static readFloat64BE(e){const t=new Uint8Array(8);return e.read(t,0,t.length),t.reverse(),be.bytesToFloat64LE(t)}static readInt32LE(e){const t=e.readByte(),s=e.readByte(),i=e.readByte();return e.readByte()<<24|i<<16|s<<8|t}static readInt64LE(e){const t=new Uint8Array(8);return e.read(t,0,t.length),be.bytesToInt64LE(t)}static readUInt32LE(e){const t=e.readByte(),s=e.readByte(),i=e.readByte();return e.readByte()<<24|i<<16|s<<8|t}static decodeUInt32LE(e,t){const s=e[t],i=e[t+1],r=e[t+2];return e[t+3]<<24|r<<16|i<<8|s}static readUInt16LE(e){const t=e.readByte(),s=e.readByte();return be.int32ToUint16(s<<8|t)}static readInt16LE(e){const t=e.readByte(),s=e.readByte();return be.int32ToInt16(s<<8|t)}static readUInt32BE(e){const t=e.readByte(),s=e.readByte(),i=e.readByte(),r=e.readByte();return be.int32ToUint32(t<<24|s<<16|i<<8|r)}static readUInt16BE(e){const t=e.readByte(),s=e.readByte();return be.int32ToInt16(t<<8|s)}static readInt16BE(e){const t=e.readByte(),s=e.readByte();return be.int32ToInt16(t<<8|s)}static readByteArray(e,t){const s=new Uint8Array(t);return e.read(s,0,t),s}static read8BitChars(e,t){const s=new Uint8Array(t);return e.read(s,0,s.length),k.toString(s,"utf-8")}static read8BitString(e){let t="",s=e.readByte();for(;s!==0;)t+=String.fromCharCode(s),s=e.readByte();return t}static read8BitStringLength(e,t){let s="",i=-1;for(let n=0;n<t;n++){const o=e.readByte();o===0&&i===-1&&(i=n),s+=String.fromCharCode(o)}const r=s;return i>=0?r.substr(0,i):r}static readSInt8(e){const t=e.readByte();return((t&255)>>7)*-256+(t&255)}static readInt24(e,t){let s=e[t]|e[t+1]<<8|e[t+2]<<16;return(s&8388608)===8388608&&(s=s|255<<24),s}static readInt16(e,t){return be.int32ToInt16(e[t]|e[t+1]<<8)}static toString(e,t){const s=k._detectEncoding(e);return s&&(t=s),t||(t="utf-8"),new TextDecoder(t).decode(e.buffer)}static _detectEncoding(e){return e.length>2&&e[0]===254&&e[1]===255?"utf-16be":e.length>2&&e[0]===255&&e[1]===254?"utf-16le":e.length>4&&e[0]===0&&e[1]===0&&e[2]===254&&e[3]===255?"utf-32be":e.length>4&&e[0]===255&&e[1]===254&&e[2]===0&&e[3]===0?"utf-32le":null}static stringToBytes(e){return new TextEncoder().encode(e)}static writeInt32BE(e,t){e.writeByte(t>>24&255),e.writeByte(t>>16&255),e.writeByte(t>>8&255),e.writeByte(t>>0&255)}static writeInt32LE(e,t){e.writeByte(t>>0&255),e.writeByte(t>>8&255),e.writeByte(t>>16&255),e.writeByte(t>>24&255)}static writeUInt16LE(e,t){e.writeByte(t>>0&255),e.writeByte(t>>8&255)}static writeInt16LE(e,t){e.writeByte(t>>0&255),e.writeByte(t>>8&255)}static writeInt16BE(e,t){e.writeByte(t>>8&255),e.writeByte(t>>0&255)}static writeFloat32BE(e,t){const s=be.float32BEToBytes(t);e.write(s,0,s.length)}static*iterateCodepoints(e){let t=0;for(;t<e.length;){let s=e.charCodeAt(t);k.isLeadingSurrogate(s)&&t+1<e.length&&(t++,s=(s-55296)*1024+(e.charCodeAt(t)-56320)+65536),t++,yield s}}static isLeadingSurrogate(e){return e>=55296&&e<=56319}static isTrailingSurrogate(e){return e>=56320&&e<=57343}}class ft{static _eof=0;_codepoints;_codepoint=ft._eof;_offset=0;_line=1;_col=1;fatalError=!1;_tokenStart={line:0,col:0,offset:0};_leadingComments;_trailingCommentNode;_previousToken;_peekedToken;lexerDiagnostics=new pn;constructor(e){this._codepoints=[...k.iterateCodepoints(e)],this._offset=0,this._line=1,this._col=1,this._codepoint=this._codepoints.length>0?this._codepoints[0]:ft._eof}peekToken(){if(this.fatalError)return;let e=this._peekedToken;return e||(e=this._readToken(),this._peekedToken=e,e)}
1extendToFloat(e){if(this._codepoint!==46||this._offset+1>=this._codepoints.length||!ft._isDigit(this._codepoints[this._offset+1]))return e;let t=this._offset+2;for(;t<this._codepoints.length&&ft._isDigit(this._codepoints[t]);)t++;if(t<this._codepoints.length&&ft._isIdentifierCharacter(this._codepoints[t]))return e;const s=t-this._offset-1;return this._offset+=s,this._col+=s,this._nextCodepoint(),e.end=this._currentLexerLocation(),e.value=Number.parseFloat(String.fromCodePoint(...this._codepoints.slice(e.start.offset,e.end.offset))),e}advance(){this._previousToken=this._peekedToken,this._peekedToken=void 0}_nextCodepoint(){const e=this._codepoints;let t=this._offset;if(t<e.length-1){e[t]===10?(this._trailingCommentNode=void 0,++this._line,this._col=1):++this._col,++t;const i=e[t];return this._codepoint=i,this._offset=t,i}else this._codepoint!==ft._eof&&(this._codepoint=ft._eof,++this._col,this._offset=e.length);return ft._eof}previousTokenEndLocation(){return this._previousToken?.end??this._currentLexerLocation()}currentTokenLocation(){return this._peekedToken?.start??this._currentLexerLocation()}_currentLexerLocation(){return{line:this._line,col:this._col,offset:this._offset}}_readToken(){for(this._leadingComments=void 0;this._codepoint!==ft._eof&&!this.fatalError;)if(this._tokenStart=this._currentLexerLocation(),ft._terminalTokens.has(this._codepoint)){const e=ft._terminalTokens.get(this._codepoint)(this);if(e)return this._trailingCommentNode=e,e}else if(ft._isIdentifierCharacter(this._codepoint)){const e=this._numberOrIdentifier();return this._trailingCommentNode=e,e}else this._codepoint=this._nextCodepoint()}_comment(){this._codepoint=this._nextCodepoint(),this._codepoint===47?this._singleLineComment():this._codepoint===42?this._multiLineComment():(this.lexerDiagnostics.push({code:fe.AT001,message:`Unexpected character at comment start, expected '//' or '/*' but found '/${String.fromCodePoint(this._codepoint)}'`,severity:ce.Error,start:this._tokenStart,end:this._currentLexerLocation()}),this.fatalError=!0)}static _terminalTokens=new Map([[47,e=>e._comment()],[34,e=>e._string()],[39,e=>e._string()],[45,e=>e._numberOrIdentifier()],[46,e=>e._token({nodeType:x.Dot})],[58,e=>e._token({nodeType:x.Colon})],[40,e=>e._token({nodeType:x.LParen})],[41,e=>e._token({nodeType:x.RParen})],[123,e=>e._token({nodeType:x.LBrace})],[125,e=>e._token({nodeType:x.RBrace})],[124,e=>e._token({nodeType:x.Pipe})],[42,e=>e._token({nodeType:x.Asterisk})],[92,e=>e._metaCommand()],[9,e=>e._whitespace()],[10,e=>e._whitespace()],[11,e=>e._whitespace()],[13,e=>e._whitespace()],[32,e=>e._whitespace()]]);_metaCommand(){const e=this._currentLexerLocation();this._codepoint=this._nextCodepoint();let t,s;this._codepoint===92?(this._codepoint=this._nextCodepoint(),s=this._currentLexerLocation(),t={nodeType:x.DoubleBackslash,start:e,end:s}):(s=this._currentLexerLocation(),t={nodeType:x.Backslash,start:e,end:s});let i="";for(;ft._isIdentifierCharacter(this._codepoint);)i+=String.fromCodePoint(this._codepoint),this._codepoint=this._nextCodepoint();if(i.length===0){this.lexerDiagnostics.push({code:fe.AT002,message:"Missing identifier after meta data start",severity:ce.Error,start:this._tokenStart,end:this._currentLexerLocation()});return}return{nodeType:x.Tag,leadingComments:this._leadingComments,start:this._tokenStart,end:this._currentLexerLocation(),prefix:t,tag:{nodeType:x.Ident,text:i,start:s,end:this._currentLexerLocation()}}}_token(e){return e.leadingComments=this._leadingComments,e.start=this._tokenStart,this._codepoint=this._nextCodepoint(),e.end=this._currentLexerLocation(),e}_string(){const e=this._codepoint;this._codepoint=this._nextCodepoint();let t="",s=-1;for(;this._codepoint!==e&&this._codepoint!==ft._eof;){let r=-1;if(this._codepoint===92)if(this._codepoint=this._nextCodepoint(),this._codepoint===92)r=92;else if(this._codepoint===e)r=e;else if(this._codepoint===82||this._codepoint===114)r=13;else if(this._codepoint===78||this._codepoint===110)r=10;else if(this._codepoint===84||this._codepoint===116)r=9;else if(this._codepoint===117){let n="";for(let o=0;o<4;o++){if(this._codepoint=this._nextCodepoint(),this._codepoint===ft._eof){this.lexerDiagnostics.push({code:fe.AT003,message:"Unexpected end of file. Need 4 hex characters on a \\uXXXX escape sequence",severity:ce.Error,start:this._tokenStart,end:this._currentLexerLocation()}),this.fatalError=!0;return}n+=String.fromCodePoint(this._codepoint)}if(r=Number.parseInt(n,16),Number.isNaN(r)){this.lexerDiagnostics.push({code:fe.AT004,message:"Invalid unicode value. Need 4 hex characters on a \\uXXXX escape sequence.",severity:ce.Error,start:this._tokenStart,end:this._currentLexerLocation()}),this.fatalError=!0;return}}else{this.lexerDiagnostics.push({code:fe.AT005,message:`Unsupported escape sequence. Expected '\\n', '\\r', '\\t', or '\\uXXXX' but found '\\${String.fromCodePoint(this._codepoint)}'.`,severity:ce.Error,start:this._tokenStart,end:this._currentLexerLocation()}),this.fatalError=!0;return}else r=this._codepoint;k.isLeadingSurrogate(s)&&k.isTrailingSurrogate(r)?(r=(s-55296)*1024+(r-56320)+65536,t+=String.fromCodePoint(r)):k.isLeadingSurrogate(r)||(k.isLeadingSurrogate(s)&&(t+=String.fromCodePoint(s)),r>0&&(t+=String.fromCodePoint(r))),s=r,this._codepoint=this._nextCodepoint()}if(this._codepoint===ft._eof){this.lexerDiagnostics.push({code:fe.AT006,message:"Unexpected end of file. String not closed.",severity:ce.Error,start:this._tokenStart,end:this._currentLexerLocation()}),this.fatalError=!0;return}const i={nodeType:x.String,text:t,leadingComments:this._leadingComments,start:this._tokenStart,end:this._currentLexerLocation()};return this._codepoint=this._nextCodepoint(),i}_multiLineComment(){const e=this._trailingCommentNode,t={start:this._tokenStart,end:this._currentLexerLocation(),text:"",multiLine:!0};for(;this._codepoint!==ft._eof;)if(this._codepoint===42)if(this._codepoint=this._nextCodepoint(),this._codepoint===47){this._codepoint=this._nextCodepoint();break}else t.text+=`*${String.fromCodePoint(this._codepoint)}`,t.end.line=this._line,t.end.col=this._col,t.end.offset=this._offset;else this._codepoint=this._nextCodepoint(),t.text+=String.fromCodePoint(this._codepoint),t.end.line=this._line,t.end.col=this._col,t.end.offset=this._offset;e?(e.trailingComments??=[],e.trailingComments.push(t)):(this._leadingComments??=[],this._leadingComments.push(t))}_numberOrIdentifier(){let e="",t=!0,s=this._codepoint;s===45&&(e+=String.fromCodePoint(s),s=this._nextCodepoint(),ft._isDigit(s)||(t=!1));let i=!0;do t?ft._isDigit(s)?(e+=String.fromCodePoint(s),s=this._nextCodepoint(),i=!0):ft._isIdentifierCharacter(s)?(t=!1,e+=String.fromCodePoint(s),s=this._nextCodepoint(),i=!0):i=!1:ft._isIdentifierCharacter(s)?(e+=String.fromCodePoint(s),s=this._nextCodepoint(),i=!0):i=!1;while(i);return t?{nodeType:x.Number,leadingComments:this._leadingComments,start:this._tokenStart,end:this._currentLexerLocation(),value:Number.parseInt(e,10)}:{nodeType:x.Ident,leadingComments:this._leadingComments,start:this._tokenStart,end:this._currentLexerLocation(),text:e}}_singleLineComment(){const e=this._trailingCommentNode,t={start:this._tokenStart,end:this._currentLexerLocation(),text:"",multiLine:!1};let s=this._codepoint;for(;s!==ft._eof&&(s=this._nextCodepoint(),s!==10&&s!==ft._eof);)t.text+=String.fromCodePoint(s),t.end.line=this._line,t.end.col=this._col,t.end.offset=this._offset;e?(e.trailingComments??=[],e.trailingComments.push(t)):(this._leadingComments??=[],this._leadingComments.push(t))}_whitespace(){let e=this._codepoint;for(;ft._isWhiteSpace(e);)e===10&&(this._trailingCommentNode=void 0),e=this._nextCodepoint()}static _isDigit(e){return e>=48&&e<=57}static _buildNonIdentifierChars(){const e=new Set;for(const t of ft._terminalTokens.keys())e.add(t);return e.delete(45),e.add(ft._eof),e}static _nonIdentifierChars=ft._buildNonIdentifierChars();static _isIdentifierCharacter(e){return!ft._nonIdentifierChars.has(e)}static _isWhiteSpace(e){return e===32||e===10||e===13||e===9||e===11}
1}var Zi;(function(a){a[a.ForModelImport=0]="ForModelImport",a[a.Full=1]="Full"})(Zi||(Zi={}));class Zr{lexer;_scoreNode;_metaDataReader=At.instance;mode=Zi.ForModelImport;get lexerDiagnostics(){return this.lexer.lexerDiagnostics}parserDiagnostics=new pn;addParserDiagnostic(e){this.parserDiagnostics.push(e)}unexpectedToken(e,t,s){e?this.addParserDiagnostic({code:fe.AT202,message:`Unexpected '${x[e.nodeType]}' token. Expected one of following: ${t.map(i=>x[i]).join(",")}`,severity:ce.Error,start:e.start,end:e.end}):this.addParserDiagnostic({code:fe.AT203,start:this.lexer.currentTokenLocation(),end:this.lexer.currentTokenLocation(),severity:ce.Error,message:"Unexpected end of file."}),s&&(this.lexer.fatalError=!0)}constructor(e){this.lexer=new ft(e)}read(){return this._score(),this._scoreNode}_score(){this._scoreNode={nodeType:x.Score,bars:[],start:this.lexer.currentTokenLocation()};try{this._bars()}finally{this._scoreNode.end=this.lexer.previousTokenEndLocation()}}_bars(){let e=this.lexer.peekToken();for(;e;)this._bar(),e=this.lexer.peekToken()}_bar(){const e={nodeType:x.Bar,metaData:[],beats:[],pipe:void 0,start:this.lexer.currentTokenLocation()};this._scoreNode.bars.push(e);try{this._barMetaData(e),this._barBeats(e);const t=this.lexer.peekToken();t?.nodeType===x.Pipe&&(e.pipe=t,this.lexer.advance()),(e.metaData.length>0||e.beats.length>0||e.pipe)&&(e.end=this.lexer.previousTokenEndLocation())}finally{e.end=this.lexer.previousTokenEndLocation()}}_barMetaData(e){let t=this.lexer.peekToken();for(;t&&(t.nodeType===x.Tag||t.nodeType===x.Dot);)t.nodeType===x.Dot?(this.lexer.advance(),this.addParserDiagnostic({code:fe.AT400,message:"The dots separating score metadata, score contents and the sync points can be removed.",severity:ce.Hint,start:t.start,end:t.end})):this._metaData(e.metaData),t=this.lexer.peekToken()}_barBeats(e){let t=this.lexer.peekToken();for(;t&&t.nodeType!==x.Pipe&&t.nodeType!==x.Dot&&t.nodeType!==x.Tag;){const s=this._beat();s&&e.beats.push(s),t=this.lexer.peekToken()}}_beat(){const e={nodeType:x.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._beatDurationChange(e),this._beatContent(e),!e.notes&&!e.rest)return e;this._beatDuration(e),this._beatMultiplier(e),e.beatEffects=this._properties(t=>this._metaDataReader.readBeatPropertyArguments(this,t)),e.beatMultiplierValue!==void 0&&e.beatEffects?.openBrace&&this.addParserDiagnostic({code:fe.AT304,message:"The beat multiplier should be specified after the beat effects.",severity:ce.Warning,start:e.beatMultiplier.start,end:e.beatMultiplierValue.end}),this._beatMultiplier(e)}finally{e.end=this.lexer.previousTokenEndLocation()}return e}_beatDuration(e){const t=this.lexer.peekToken();if(t?.nodeType!==x.Dot)return;e.durationDot=t,this.lexer.advance();const s=this.lexer.peekToken();if(s?.nodeType===x.Number){e.durationValue=s,this.lexer.advance();return}else if(s?.nodeType===x.Tag){e.durationDot=void 0;return}else if(s)this.unexpectedToken(s,[x.Number],!0);else return}_beatDurationChange(e){const t=this.lexer.peekToken();if(t?.nodeType!==x.Colon)return;this.lexer.advance();const s={nodeType:x.Duration,colon:t,value:void 0,properties:void 0,start:t.start};e.durationChange=s;try{const i=this.lexer.peekToken();if(!i||i.nodeType!==x.Number){this.addParserDiagnostic({code:fe.AT201,message:"Missing duration value after ':'.",severity:ce.Error,start:t.start,end:t.end});return}this.lexer.advance(),s.value=i,s.properties=this._properties(r=>this._metaDataReader.readDurationChangePropertyArguments(this,r))}finally{s.end=this.lexer.previousTokenEndLocation()}}_beatContent(e){const t=this.lexer.peekToken();if(t)if(t.nodeType===x.Ident&&t.text==="r")e.rest=t,this.lexer.advance();else if(t.nodeType===x.LParen)e.notes=this._noteList(t);else{const s=this._note(t);s&&(e.notes={nodeType:x.NoteList,openParenthesis:void 0,notes:[s],closeParenthesis:void 0,start:s.start,end:s.end})}}_beatMultiplier(e){const t=this.lexer.peekToken();if(!t||t.nodeType!==x.Asterisk)return;this.lexer.advance(),e.beatMultiplier=t;const s=this.lexer.peekToken();if(!s||s.nodeType!==x.Number){this.addParserDiagnostic({code:fe.AT200,message:"Missing beat multiplier value after '*'.",severity:ce.Error,start:e.beatMultiplier.start,end:e.beatMultiplier.end});return}e.beatMultiplierValue=s,this.lexer.advance()}_noteList(e){const t={nodeType:x.NoteList,openParenthesis:void 0,notes:[],closeParenthesis:void 0,start:this.lexer.currentTokenLocation()};try{t.openParenthesis=e,this.lexer.advance();let s=this.lexer.peekToken();for(;s&&s.nodeType!==x.RParen;){const r=this._note(s);if(r)t.notes.push(r);else break;s=this.lexer.peekToken()}const i=this.lexer.peekToken();i?.nodeType===x.RParen?(t.closeParenthesis=i,this.lexer.advance()):this.addParserDiagnostic({code:fe.AT206,message:"Unexpected end of file. Group not closed.",severity:ce.Error,start:i?.start??this.lexer.currentTokenLocation(),end:i?.end??this.lexer.currentTokenLocation()})}finally{t.end=this.lexer.previousTokenEndLocation()}return t}_note(e){const t={nodeType:x.Note,noteValue:{nodeType:x.Ident,text:""},start:e.start};try{let s=!1;switch(e.nodeType){case x.Number:t.noteValue=e,this.lexer.advance(),s=!0;break;case x.String:switch(t.noteValue=e,this.lexer.advance(),t.noteValue.text){case"x":case"-":s=!0;break}break;case x.Ident:switch(t.noteValue=e,this.lexer.advance(),t.noteValue.text){case"x":case"-":s=!0;break}break;
vendor: 6,572 bytes, line 1
1default:this.unexpectedToken(e,[x.Number,x.String,x.Ident],!0);return}if(s){const i=this.lexer.peekToken();if(i?.nodeType===x.Dot){const r=i;this.lexer.advance();const n=this.lexer.peekToken();if(!n){this.unexpectedToken(n,[x.Number],!0);return}if(n.nodeType===x.Tag)return t;if(n.nodeType===x.Number)t.noteStringDot=r,t.noteString=n,this.lexer.advance();else{this.unexpectedToken(n,[x.Number],!0);return}}}t.noteEffects=this._properties(i=>this._metaDataReader.readNotePropertyArguments(this,i))}finally{t.end=this.lexer.previousTokenEndLocation()}return t}static _allowValuesAfterProperties=new Set(["chord"]);_metaData(e){const t=this.lexer.peekToken();if(!t||t.nodeType!==x.Tag)return;const s={nodeType:x.Meta,tag:t,start:t.start,properties:void 0,propertiesBeforeArguments:!1};this.lexer.advance(),e.push(s);try{const i=Zr._allowValuesAfterProperties.has(s.tag.tag.text),r=this.lexer.peekToken();i&&r?.nodeType===x.LBrace?(s.propertiesBeforeArguments=!0,s.properties=this._properties(n=>this._metaDataReader.readMetaDataPropertyArguments(this,s.tag,n)),s.arguments=this.argumentList(),s.arguments||(s.arguments=this._metaDataReader.readMetaDataArguments(this,s.tag),s.arguments&&s.arguments.arguments.length>1&&(this.addParserDiagnostic({code:fe.AT301,message:"Metadata arguments should be wrapped into parenthesis.",severity:ce.Warning,start:s.arguments?.start??s.start,end:s.arguments?.end??s.end}),this.addParserDiagnostic({code:fe.AT302,message:"Metadata arguments should be placed before metadata properties.",severity:ce.Warning,start:s.arguments?.start??s.start,end:s.arguments?.end??s.end})))):(this._metaDataReader.hasMetaDataArguments(s.tag)&&(s.arguments=this.argumentList(),s.arguments||(s.arguments=this._metaDataReader.readMetaDataArguments(this,s.tag),s.arguments&&s.arguments.arguments.length>1&&this.addParserDiagnostic({code:fe.AT301,message:"Metadata arguments should be wrapped into parenthesis.",severity:ce.Warning,start:s.arguments?.start??s.start,end:s.arguments?.end??s.end}))),s.properties=this._properties(n=>this._metaDataReader.readMetaDataPropertyArguments(this,s.tag,n)))}finally{s.end=this.lexer.previousTokenEndLocation()}return s}_properties(e){const t=this.lexer.peekToken();if(!t||t.nodeType!==x.LBrace)return;const s={nodeType:x.Props,openBrace:t,properties:[],closeBrace:void 0,start:t.start};this.lexer.advance();try{let i=this.lexer.peekToken();for(;i?.nodeType===x.Ident;)s.properties.push(this._property(i,e)),i=this.lexer.peekToken();const r=this.lexer.peekToken();r?.nodeType===x.RBrace?(s.closeBrace=r,this.lexer.advance()):this.addParserDiagnostic({code:fe.AT206,message:"Unexpected end of file. Group not closed.",severity:ce.Error,start:this.lexer.currentTokenLocation(),end:this.lexer.currentTokenLocation()})}finally{s.end=this.lexer.previousTokenEndLocation()}return s}_property(e,t){const s={nodeType:x.Prop,property:e,arguments:void 0};this.lexer.advance(),s.start=s.property.start;try{s.arguments=this.argumentList(),s.arguments||(s.arguments=t(s),s.arguments&&s.arguments.arguments.length>1&&this.addParserDiagnostic({code:fe.AT303,message:"Property args should be wrapped into parenthesis.",severity:ce.Warning,start:s.arguments.start,end:s.arguments.end}))}finally{s.end=this.lexer.previousTokenEndLocation()}return s}argumentList(){const e=this.lexer.peekToken();if(e?.nodeType!==x.LParen)return;const t={nodeType:x.Arguments,openParenthesis:e,arguments:[],closeParenthesis:void 0,start:e.start};this.lexer.advance();try{let s=this.lexer.peekToken();for(;s&&s?.nodeType!==x.RParen;){switch(s.nodeType){case x.Ident:t.arguments.push(s),this.lexer.advance();break;case x.String:t.arguments.push(s),this.lexer.advance();break;case x.Number:t.arguments.push(this.lexer.extendToFloat(s)),this.lexer.advance();break;default:this.unexpectedToken(s,[x.Ident,x.String,x.Number],!1),this.lexer.advance();break}s=this.lexer.peekToken()}const i=this.lexer.peekToken();i?.nodeType===x.RParen?(t.closeParenthesis=i,this.lexer.advance()):this.addParserDiagnostic({code:fe.AT206,message:"Unexpected end of file. Group not closed.",severity:ce.Error,start:this.lexer.currentTokenLocation(),end:this.lexer.currentTokenLocation()})}finally{t.end=this.lexer.previousTokenEndLocation()}return t}}class _{static ident(e){return{nodeType:x.Ident,text:e}}static string(e){return{nodeType:x.String,text:e}}static number(e){return{nodeType:x.Number,value:e}}static meta(e,t,s){return{nodeType:x.Meta,tag:{nodeType:x.Tag,prefix:{nodeType:x.Backslash},tag:{nodeType:x.Ident,text:e}},arguments:t,properties:s,propertiesBeforeArguments:!1}}static identMeta(e,t){return _.meta(e,_.identValue(t))}static numberMeta(e,t){return _.meta(e,_.numberValue(t))}static args(e,t=void 0){const s={nodeType:x.Arguments,arguments:e.filter(r=>r!==void 0)};if((t===void 0?s.arguments.length>1:t)&&(s.openParenthesis={nodeType:x.LParen},s.closeParenthesis={nodeType:x.RParen}),s.arguments.length!==0)return s}static stringValue(e){return _.args([_.string(e)])}static identValue(e){return _.args([_.ident(e)])}static numberValue(e){return _.args([_.number(e)])}static props(e){const t={nodeType:x.Props,properties:[],openBrace:{nodeType:x.LBrace},closeBrace:{nodeType:x.RBrace}};for(const s of e)s&&t.properties.push({nodeType:x.Prop,property:_.ident(s[0]),arguments:s[1]});return t}static prop(e,t,s){e.push({nodeType:x.Prop,property:_.ident(t),arguments:s})}}class At{static instance=new At;static _argumentTypes=new Set([x.LParen,x.String,x.Ident,x.Number]);hasMetaDataArguments(e){const t=e.tag.text.toLowerCase();for(const s of Ve.metaDataSignatures)if(s.has(t))return s.get(t)!==null;return!0}readMetaDataArguments(e,t){const s=t.tag.text.toLowerCase();for(const i of Ve.metaDataSignatures)if(i.has(s)){const r=i.get(s);return r?this._readArguments(e,r):void 0}e.addParserDiagnostic({code:fe.AT204,message:`Unrecognized metadata '${t.tag.text}'.`,severity:ce.Error,start:t.start,end:t.end}),e.lexer.fatalError=!0}readMetaDataPropertyArguments(e,t,s){const i=t.tag.text.toLowerCase();if(!Ve.metaDataProperties.has(i))return;const r=Ve.metaDataProperties.get(i);return r?this._readPropertyArguments(e,[r],s):this._readPropertyArguments(e,[],s)}readBeatPropertyArguments(e,t){return this._readPropertyArguments(e,[Ve.beatProperties],t)}readDurationChangePropertyArguments(e,t){return this._readPropertyArguments(e,[Ve.durationChangeProperties],t)}readNotePropertyArguments(e,t){return this._readPropertyArguments(e,[Ve.noteProperties,Ve.beatProperties],t)}_readPropertyArguments(e,t,s){const i=s.property.text.toLowerCase(),r=new Set([x.Ident,x.RBrace]);
1for(const o of t)if(o.has(i)){const l=o.get(i);if(l)return this._readArguments(e,l,r);this._skipRemainingArguments(e,[],r);return}let n=e.lexer.peekToken();for(;n&&n.nodeType!==x.Ident&&n.nodeType!==x.RBrace;)e.lexer.advance(),n=e.lexer.peekToken();e.addParserDiagnostic({code:fe.AT205,message:`Unrecognized property '${s.property.text}'.`,severity:ce.Error,start:s.property.start,end:n?.start??e.lexer.currentTokenLocation()})}_readArguments(e,t,s){if(t.length===1&&t[0].parameters.length===0)return;const i=[],r=e.lexer.peekToken()?.start,n=s!==void 0,o=new Map(t.map((c,d)=>[d,{signature:c,parameterIndex:0,parameterHasValues:!1,parameterValueMatches:0}])),l=this._filterCandidates(e,o,i,s),h=this._validateArguments(e,o,i,s,t,r);return n&&this._skipRemainingArguments(e,t,s),this._createArgumentList(i,r,e.lexer.previousTokenEndLocation(),h,l)}_validateArguments(e,t,s,i,r,n){const o=e.lexer.peekToken();let l=!1;return t.size!==1&&o===void 0?(e.addParserDiagnostic({code:fe.AT203,start:e.lexer.currentTokenLocation(),end:e.lexer.currentTokenLocation(),severity:ce.Error,message:"Unexpected end of file."}),l=!0):t.size===0&&(o!==void 0&&s.length===0&&i&&!i.has(o.nodeType)&&(s.push(e.lexer.peekToken()),e.lexer.advance()),e.addParserDiagnostic({code:fe.AT219,message:`Error parsing arguments: no overload matched arguments ${At.generateSignaturesFromArguments(s)}. Signatures:
2${At.generateSignatures(r)}`,severity:ce.Error,start:n,end:e.lexer.previousTokenEndLocation()}),l=!0),l}_createArgumentList(e,t,s,i,r){if(e.length===0)return;const n=_.args(e,!1);return n.start=t,n.end=s,n.validated=!i,r&&(r.length>1&&At.sortCandidates(r),n.signatureCandidateIndices=r.map(o=>o[0])),n}_filterCandidates(e,t,s,i){const r=e.mode===Zi.Full,n=(c,d)=>{const f=t.get(d);if(c.nodeType===x.LParen){const p=e.argumentList();if(p)for(const g of p.arguments)r&&(g.parameterIndices||(g.parameterIndices=new Map),g.parameterIndices.set(d,f.parameterIndex)),s.push(g)}else{const p=c;r&&(p.parameterIndices||(p.parameterIndices=new Map),p.parameterIndices.set(d,f.parameterIndex)),(s.length===0||s[s.length-1]!==p)&&(s.push(p),e.lexer.advance())}},o=c=>{e.lexer.extendToFloat(c)},l=At._argumentTypes;for(;t.size>1||t.size>0&&!At._hasExactMatch(t);){const c=e.lexer.peekToken();if(!c||!l.has(c.nodeType)||!At.filterSignatureCandidates(t,c,i!==void 0&&i.has(c.nodeType),n,o))break}const h=e.mode===Zi.Full?Array.from(t.entries()):void 0;return At.filterIncompleteCandidates(t),h}static sortCandidates(e){e.length<2||e.sort((t,s)=>{const i=Math.abs(t[1].parameterIndex-t[1].signature.parameters.length),r=Math.abs(s[1].parameterIndex-s[1].signature.parameters.length);if(i===r){const n=t[1].parameterValueMatches;return s[1].parameterValueMatches-n}return i-r})}_skipRemainingArguments(e,t,s){const i=e.lexer.currentTokenLocation();let r=e.lexer.peekToken(),n=!1;const o=At._argumentTypes;for(;r&&!s.has(r.nodeType);)o.has(r.nodeType)?(e.lexer.advance(),n=!0,r=e.lexer.peekToken()):r=void 0;n&&e.addParserDiagnostic({code:fe.AT220,message:`Error parsing arguments: unexpected additional arguments. Signatures:
3${At.generateSignatures(t)}`,severity:ce.Error,start:i,end:e.lexer.previousTokenEndLocation()})}static _hasExactMatch(e){for(const t of e.values())if(t.parameterIndex===t.signature.parameters.length)return!0;return!1}static filterIncompleteCandidates(e){const t=new Set;for(const[s,i]of e)for(let r=i.parameterIndex;r<i.signature.parameters.length;r++)switch(i.signature.parameters[r].parseMode){case Pt.Required:case Pt.RequiredAsFloat:t.add(s);break}for(const s of t)e.delete(s)}static generateSignaturesFromArguments(e){return e?`(${e.map(t=>x[t.nodeType]).join(", ")})`:"()"}static generateSignatures(e,t){return e.length===0?"()":e.map((s,i)=>At._generateSignature(s,t!==void 0&&t.size>1&&t.has(i))).join(`
4`)}static _generateSignature(e,t){const s=t?" ~":"";return`(${e.parameters.map(At._generateSignatureParameter).join(", ")})${s}`}static _generateSignatureParameter(e,t){const s=Array.from(e.expectedTypes);let i=`v${t}`;switch(e.parseMode){case Pt.Optional:case Pt.OptionalAsFloat:i+="?";break}if(e.allowedValues&&e.allowedValues.size<5){const r=Array.from(e.allowedValues);s[0]===x.String?i=r.map(n=>`"${n}"`).join("|"):i=r.join("|")}else i=Array.from(e.expectedTypes).map(r=>x[r]).join("|");switch(e.parseMode){case Pt.RequiredAsValueList:case Pt.ValueListWithoutParenthesis:i+="[]";break}return i}static filterSignatureCandidates(e,t,s,i,r){const n=new Set;let o=!1;for(const[l,h]of e){let c=!1;for(;!c;){const d=h.parameterIndex<h.signature.parameters.length?h.signature.parameters[h.parameterIndex]:void 0;if(!d)s||n.add(l),c=!0;else if(h.signature.isStrict&&h.parameterIndex>0)n.add(l),c=!0;else if((d.expectedTypes.has(t.nodeType)||At._isValueListMatch(t,d))&&At._checkArgumentMatch(t,d,r))switch(c=!0,o=!0,i(t,l),d.allowedValues&&h.parameterValueMatches++,d.parseMode){case Pt.ValueListWithoutParenthesis:h.parameterHasValues=!0;break;case Pt.RequiredAsValueList:h.parameterIndex++,h.parameterHasValues=!1;break;default:h.parameterIndex++,h.parameterHasValues=!1;break}else switch(d.parseMode){case Pt.ValueListWithoutParenthesis:h.parameterIndex++,h.parameterHasValues=!1;break;case Pt.Required:case Pt.RequiredAsFloat:n.add(l),c=!0;break;case Pt.Optional:case Pt.OptionalAsFloat:h.parameterIndex++,h.parameterHasValues=!1;break;case Pt.RequiredAsValueList:h.parameterIndex++,h.parameterHasValues=!1;break}}}if(o)for(const l of n)e.delete(l);return o}static _checkArgumentMatch(e,t,s){switch(e.nodeType){case x.Ident:const i=e;return t?.allowedValues?t.allowedValues.has(i.text.toLowerCase()):t?.reservedIdentifiers?!t.reservedIdentifiers.has(i.text.toLowerCase()):!0;case x.String:const r=e;return t?.allowedValues?t.allowedValues.has(r.text.toLowerCase()):!0;case x.Number:switch(t?.parseMode??Pt.Optional){case Pt.RequiredAsFloat:case Pt.OptionalAsFloat:return s?.(e),!0;default:return!0}case x.LParen:return!0}return!1}
4static _isValueListMatch(e,t){return e.nodeType!==x.LParen?!1:t.expectedTypes.has(x.Arguments)||t.parseMode===Pt.ValueListWithoutParenthesis||t.parseMode===Pt.RequiredAsValueList}}var w;(function(a){a[a.Applied=0]="Applied",a[a.NotAppliedSemanticError=1]="NotAppliedSemanticError",a[a.NotAppliedUnrecognizedMarker=2]="NotAppliedUnrecognizedMarker"})(w||(w={}));var Gs;(function(a){a[a.AppliedNewTrack=0]="AppliedNewTrack",a[a.AppliedNewStaff=1]="AppliedNewStaff",a[a.AppliedNewVoice=2]="AppliedNewVoice",a[a.NotAppliedSemanticError=3]="NotAppliedSemanticError",a[a.NotAppliedUnrecognizedMarker=4]="NotAppliedUnrecognizedMarker"})(Gs||(Gs={}));class Ss{static _values=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 Ss._values||(Ss._values=new Map),e=e.toLowerCase().replaceAll(" ",""),Ss._values.has(e)?Ss._values.get(e):0}static getName(e){for(const[t,s]of Ss._values)if(s===e)return t;return e.toString()}static isPiano(e){return e<=7||e>=16&&e<=23}static isGuitar(e){return e>=24&&e<=39||e===105||e===43}static isBass(e){return e>=32&&e<=39}static bankToLsbMsb(e){const t=e&127,s=e>>7&127;return[t,s]}}class Bi{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("|")}}class zt extends Ye{constructor(e){super(Ge.Format,e)}}class Fe{static BlackRgb="#000000";constructor(e,t,s,i=255){this.raw=(i&255)<<24|(e&255)<<16|(t&255)<<8|s&255,this.updateRgba()}updateRgba(){this.a===255?this.rgba=`#${L.toHexString(this.r,2)}${L.toHexString(this.g,2)}${L.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 this.raw&255}rgba;static random(e=100){return new Fe(Math.random()*255|0,Math.random()*255|0,Math.random()*255|0,e)}static fromJson(e){if(e instanceof Fe)return e;switch(typeof e){case"number":{const t=new Fe(0,0,0,0);return t.raw=e,t.updateRgba(),t}case"string":{const t=e;if(t.startsWith("#")){if(t.length===4)return new Fe(Number.parseInt(t[1],16)*17,Number.parseInt(t[2],16)*17,Number.parseInt(t[3],16)*17);if(t.length===5)return new Fe(Number.parseInt(t[1],16)*17,Number.parseInt(t[2],16)*17,Number.parseInt(t[3],16)*17,Number.parseInt(t[4],16)*17);if(t.length===7)return new Fe(Number.parseInt(t.substring(1,3),16),Number.parseInt(t.substring(3,5),16),Number.parseInt(t.substring(5,7),16));if(t.length===9)return new Fe(Number.parseInt(t.substring(1,3),16),Number.parseInt(t.substring(3,5),16),Number.parseInt(t.substring(5,7),16),Number.parseInt(t.substring(7,9),16))}else if(t.startsWith("rgba")||t.startsWith("rgb")){const s=t.indexOf("("),i=t.lastIndexOf(")");if(s===-1||i===-1)throw new zt("No values specified for rgb/rgba function");const r=t.substring(s+1,i).split(",");if(r.length===3)return new Fe(Number.parseInt(r[0],10),Number.parseInt(r[1],10),Number.parseInt(r[2],10));if(r.length===4)return new Fe(Number.parseInt(r[0],10),Number.parseInt(r[1],10),Number.parseInt(r[2],10),Number.parseFloat(r[3])*255)}return null}}throw new zt("Unsupported format for color")}static toJson(e){return e===null?null:e.raw}}var os;(function(a){a[a.Short=0]="Short",a[a.Medium=1]="Medium",a[a.Long=2]="Long"})(os||(os={}));class Br{type=os.Short;length=0}var jt;(function(a){a[a.IgnoreSpaces=0]="IgnoreSpaces",a[a.Begin=1]="Begin",a[a.Text=2]="Text",a[a.Comment=3]="Comment",a[a.Dash=4]="Dash"})(jt||(jt={}));class es{static _charCodeLF=10;static _charCodeTab=9;static _charCodeCR=13;static _charCodeSpace=32;static _charCodeBrackedClose=93;static _charCodeBrackedOpen=91;static _charCodeDash=45;startBar=0;text="";chunks;finish(e=!1){this.chunks=[],this._parse(this.text,0,this.chunks,e)}_parse(e,t,s,i){if(!e)return;let r=jt.Begin,n=jt.Begin,o=!1,l=0;for(;t<e.length;){const h=e.charCodeAt(t);
4switch(r){case jt.IgnoreSpaces:switch(h){case es._charCodeLF:case es._charCodeCR:case es._charCodeTab:break;case es._charCodeSpace:if(!o){r=n;continue}break;default:o=!1,r=n;continue}break;case jt.Begin:if(h===es._charCodeBrackedOpen)r=jt.Comment;else{l=t,r=jt.Text;continue}break;case jt.Comment:h===es._charCodeBrackedClose&&(r=jt.Begin);break;case jt.Text:switch(h){case es._charCodeDash:r=jt.Dash;break;case es._charCodeCR:case es._charCodeLF:case es._charCodeSpace:const c=e.substr(l,t-l);this._addChunk(c,i),r=jt.IgnoreSpaces,n=jt.Begin;break}break;case jt.Dash:if(h!==es._charCodeDash){const c=e.substr(l,t-l);this._addChunk(c,i),o=!0,r=jt.IgnoreSpaces,n=jt.Begin;continue}break}t+=1}r===jt.Text&&t!==l&&this._addChunk(e.substr(l,t-l),i)}_addChunk(e,t){e=this._prepareChunk(e),(!t||e.length>0&&e!=="-")&&this.chunks.push(e)}_prepareChunk(e){const t=e.split("+").join(" ");let s=t.length;for(;s>0&&t.charAt(s-1)==="_";)s--;return s!==t.length?t.substr(0,s):t}}class Tr{marker="";text=""}class I{static _sevenStrings=[];static _sixStrings=[];static _fiveStrings=[];static _fourStrings=[];static _defaultTunings=new Map;static noteNames=["C","Db","D","Eb","E","F","Gb","G","Ab","A","Bb","B"];static getTextForTuning(e,t){const s=I.getTextPartsForTuning(e);return t?s.join(""):s[0]}static getTextPartsForTuning(e,t=-1){const s=e/12|0,i=e%12;return[I.noteNames[i],(s+t).toString()]}static getDefaultTuningFor(e){if(I._defaultTunings.has(e)){const t=I._defaultTunings.get(e);return new I(t.name,t.tunings,t.isStandard)}return null}static getPresetsFor(e){switch(e){case 7:return I._sevenStrings;case 6:return I._sixStrings;case 5:return I._fiveStrings;case 4:return I._fourStrings}return[]}static initialize(){I._defaultTunings.set(7,new I("Guitar 7 strings",[64,59,55,50,45,40,35],!0)),I._sevenStrings.push(I._defaultTunings.get(7)),I._defaultTunings.set(6,new I("Guitar Standard Tuning",[64,59,55,50,45,40],!0)),I._sixStrings.push(I._defaultTunings.get(6)),I._sixStrings.push(new I("Guitar Tune down ½ step",[63,58,54,49,44,39],!1)),I._sixStrings.push(new I("Guitar Tune down 1 step",[62,57,53,48,43,38],!1)),I._sixStrings.push(new I("Guitar Tune down 2 step",[60,55,51,46,41,36],!1)),I._sixStrings.push(new I("Guitar Dropped D Tuning",[64,59,55,50,45,38],!1)),I._sixStrings.push(new I("Guitar Dropped D Tuning variant",[64,57,55,50,45,38],!1)),I._sixStrings.push(new I("Guitar Double Dropped D Tuning",[62,59,55,50,45,38],!1)),I._sixStrings.push(new I("Guitar Dropped E Tuning",[66,61,57,52,47,40],!1)),I._sixStrings.push(new I("Guitar Dropped C Tuning",[62,57,53,48,43,36],!1)),I._sixStrings.push(new I("Guitar Open C Tuning",[64,60,55,48,43,36],!1)),I._sixStrings.push(new I("Guitar Open Cm Tuning",[63,60,55,48,43,36],!1)),I._sixStrings.push(new I("Guitar Open C6 Tuning",[64,57,55,48,43,36],!1)),I._sixStrings.push(new I("Guitar Open Cmaj7 Tuning",[64,59,55,52,43,36],!1)),I._sixStrings.push(new I("Guitar Open D Tuning",[62,57,54,50,45,38],!1)),I._sixStrings.push(new I("Guitar Open Dm Tuning",[62,57,53,50,45,38],!1)),I._sixStrings.push(new I("Guitar Open D5 Tuning",[62,57,50,50,45,38],!1)),I._sixStrings.push(new I("Guitar Open D6 Tuning",[62,59,54,50,45,38],!1)),I._sixStrings.push(new I("Guitar Open Dsus4 Tuning",[62,57,55,50,45,38],!1)),I._sixStrings.push(new I("Guitar Open E Tuning",[64,59,56,52,47,40],!1)),I._sixStrings.push(new I("Guitar Open Em Tuning",[64,59,55,52,47,40],!1)),I._sixStrings.push(new I("Guitar Open Esus11 Tuning",[64,59,55,52,45,40],!1)),I._sixStrings.push(new I("Guitar Open F Tuning",[65,60,53,48,45,41],!1)),I._sixStrings.push(new I("Guitar Open G Tuning",[62,59,55,50,43,38],!1)),I._sixStrings.push(new I("Guitar Open Gm Tuning",[62,58,55,50,43,38],!1)),I._sixStrings.push(new I("Guitar Open G6 Tuning",[64,59,55,50,43,38],!1)),I._sixStrings.push(new I("Guitar Open Gsus4 Tuning",[62,60,55,50,43,38],!1)),I._sixStrings.push(new I("Guitar Open A Tuning",[64,61,57,52,45,40],!1)),I._sixStrings.push(new I("Guitar Open Am Tuning",[64,60,57,52,45,40],!1)),I._sixStrings.push(new I("Guitar Nashville Tuning",[64,59,67,62,57,52],!1)),I._sixStrings.push(new I("Bass 6 Strings Tuning",[48,43,38,33,28,23],!1)),I._sixStrings.push(new I("Lute or Vihuela Tuning",[64,59,54,50,45,40],!1)),I._defaultTunings.set(5,new I("Bass 5 Strings Tuning",[43,38,33,28,23],!0)),I._fiveStrings.push(I._defaultTunings.get(5)),I._fiveStrings.push(new I("Banjo Dropped C Tuning",[62,59,55,48,67],!1)),I._fiveStrings.push(new I("Banjo Open D Tuning",[62,57,54,50,69],!1)),I._fiveStrings.push(new I("Banjo Open G Tuning",[62,59,55,50,67],!1)),I._fiveStrings.push(new I("Banjo G Minor Tuning",[62,58,55,50,67],!1)),I._fiveStrings.push(new I("Banjo G Mod
4al Tuning",[62,57,55,50,67],!1)),I._defaultTunings.set(4,new I("Bass Standard Tuning",[43,38,33,28],!0)),I._fourStrings.push(I._defaultTunings.get(4)),I._fourStrings.push(new I("Bass Tune down ½ step",[42,37,32,27],!1)),I._fourStrings.push(new I("Bass Tune down 1 step",[41,36,31,26],!1)),I._fourStrings.push(new I("Bass Tune down 2 step",[39,34,29,24],!1)),I._fourStrings.push(new I("Bass Dropped D Tuning",[43,38,33,26],!1)),I._fourStrings.push(new I("Ukulele C Tuning",[45,40,36,43],!1)),I._fourStrings.push(new I("Ukulele G Tuning",[52,47,43,38],!1)),I._fourStrings.push(new I("Mandolin Standard Tuning",[64,57,50,43],!1)),I._fourStrings.push(new I("Mandolin or Violin Tuning",[76,69,62,55],!1)),I._fourStrings.push(new I("Viola Tuning",[69,62,55,48],!1)),I._fourStrings.push(new I("Cello Tuning",[57,50,43,36],!1))}static findTuning(e){const t=I.getPresetsFor(e.length);for(let s=0,i=t.length;s<i;s++){const r=t[s];let n=!0;for(let o=0,l=e.length;o<l;o++)if(e[o]!==r.tunings[o]){n=!1;break}if(n)return new I(r.name,r.tunings,r.isStandard)}return null}isStandard;name;tunings;constructor(e="",t=null,s=!1){this.isStandard=s,this.name=e,this.tunings=t??[]}reset(){this.isStandard=!1,this.name="",this.tunings=[]}finish(){const e=I.findTuning(this.tunings);e&&(this.name.length===0&&(this.name=e.name),this.isStandard=e.isStandard)}}I.initialize();class Oi{static DefaultStandardNotationLineCount=5;index=0;track;bars=[];chords=null;capo=0;transpositionPitch=0;displayTranspositionPitch=0;stringTuning=new I("",[],!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=Oi.DefaultStandardNotationLineCount;_filledVoices=new Set([0]);get filledVoices(){return this._filledVoices}finish(e,t=null){this.isPercussion&&(this.stringTuning.tunings=[],this.showTablature=!1,this.displayTranspositionPitch=0),this.stringTuning.finish(),this.stringTuning.tunings.length===0&&(this.showTablature=!1);for(let s=0,i=this.bars.length;s<i;s++){this.bars[s].finish(e,t);for(const r of this.bars[s].filledVoices)this._filledVoices.add(r)}}addChord(e,t){t.staff=this;let s=this.chords;s===null&&(s=new Map,this.chords=s),s.set(e,t)}hasChord(e){return this.chords?.has(e)??!1}getChord(e){return this.chords?.get(e)??null}addBar(e){const t=this.bars;e.staff=this,e.index=t.length,t.length>0&&(e.previousBar=t[t.length-1],e.previousBar.nextBar=e),t.push(e)}}class jn{volume=15;balance=8;port=1;program=0;bank=0;primaryChannel=0;secondaryChannel=0;isMute=!1;isSolo=!1}var $s;(function(a){a[a.TrackName=0]="TrackName",a[a.BracesAndBrackets=1]="BracesAndBrackets",a[a.SystemSeparator=2]="SystemSeparator",a[a.StringTuning=3]="StringTuning"})($s||($s={}));class $l extends tr{}class Zs{static _shortNameMaxLength=10;index=0;score;staves=[];playbackInfo=new jn;color=new Fe(200,0,0,255);name="";isVisibleOnMultiTrack=!0;shortName="";defaultSystemsLayout=3;systemsLayout=[];lineBreaks;get isPercussion(){return this.staves.some(e=>e.isPercussion)}addLineBreaks(e){this.lineBreaks||(this.lineBreaks=new Set),this.lineBreaks.add(e)}percussionArticulations=[];style;ensureStaveCount(e){for(;this.staves.length<e;)this.addStaff(new Oi)}addStaff(e){e.index=this.staves.length,e.track=this,this.staves.push(e)}finish(e,t=null){this.shortName||(this.shortName=this.name,this.shortName.length>Zs._shortNameMaxLength&&(this.shortName=this.shortName.substr(0,Zs._shortNameMaxLength)));for(const s of this.staves)s.finish(e,t),s.isPercussion&&(this.playbackInfo.program=0)}applyLyrics(e){for(const s of e)s.finish();const t=this.staves[0];for(let s=0;s<e.length;s++){const i=e[s];if(i.startBar>=0&&i.startBar<t.bars.length){let r=t.bars[i.startBar].voices[0].beats[0];for(let n=0;n<i.chunks.length&&r;n++){for(;r&&(r.isEmpty||r.isRest);)r=r.nextBeat;r&&(r.lyrics||(r.lyrics=new Array(e.length),r.lyrics.fill("")),r.lyrics[s]=i.chunks[n],r=r.nextBeat)}}}}}var P;(function(a){a[a.Up=0]="Up",a[a.Down=1]="Down"})(P||(P={}));class Z{static instance=new Z;static _timeSignatureDenominators=new Set([1,2,4,8,16,32,64,128]);applyScoreMetaData(e,t,s){const i=this._checkArgumentTypes(e,[Ve.scoreMetaDataSignatures],s,s.tag.tag.text.toLowerCase(),s.arguments);if(i!==void 0)return i;switch(s.tag.tag.text.toLowerCase()){case"title":return t.title=s.arguments.arguments[0].text,this._headerFooterStyle(e,t,H.Title,s),w.Applied;case"subtitle":return t.subTitle=s.arguments.arguments[0].text,this._headerFooterStyle(e,t,H.SubTitle,s),w.Applied;case"artist":return t.artist=s.arguments.arguments[0].text,this._headerFooterStyle(e,t,H.Artist,s),w.Applied;case"album":return t.album=s.arguments.arguments[0].text,this._headerFooterStyle(e,t,H.Album,s),w.Applied;case"words":return t.words=s.arguments.arguments[0].text,this._headerFooterStyle(e,t,H.Words,s),w.Applied;case"music":return t.music=s.arguments.arguments[0].text,this._headerFooterStyle(e,t,H.Music,s),w.Applied;case"copyright":return t.copyright=s.arguments.arguments[0].text,this._headerFooterStyle(e,t,H.Copyright,s),w.Applied;case"instructions":return t.instructions=s.arguments.arguments[0].text,w.Applied;case"notices":return t.notices=s.arguments.arguments[0].text,w.Applied;case"tab":return t.tab=s.arguments.arguments[0].text,this._headerFooterStyle(e,t,H.Transcriber,s),w.Applied;case"copyright2":return this._headerFooterStyle(e,t,H.CopyrightSecondLine,s,0),w.Applied;case"wordsandmusic":return this._headerFooterStyle(e,t,H.WordsAndMusic,s,0),w.Applied;case"defaultsystemslayout":return t.defaultSystemsLayout=s.arguments.arguments[0].value,w.Applied;case"systemslayout":for(const p of s.arguments.arguments)t.systemsLayout.push(p.value);return w.Applied;case"hidedynamics":return t.stylesheet.hideDynamics=!0,w.Applied;case"showdynamics":return t.stylesheet.hideDynamics=!1,w.Applied;case"extendbarlines":return t.stylesheet.extendBarLines=!0,w.Applied;case"bracketextendmode":const r=Z._parseEnumValue(e,s.arguments,"bracket extend mode",V.bracketExtendMode);return r===void 0?w.NotAppliedSemanticError:(t.stylesheet.bracketExtendMode=r,w.Applied);case"usesystemsignseparator":return t.stylesheet.useSystemSignSeparator=!0,w.Applied;case"multibarrest":return t.stylesheet.multiTrackMultiBarRest=!0,w.Applied;case"singletracktracknamepolicy":const n=Z._parseEnumValue(e,s.arguments,"track name policy",V.trackNamePolicy);return n===void 0?w.NotAppliedSemanticError:(t.stylesheet.singleTrackTrackNamePolicy=n,w.Applied);case"multitracktracknamepolicy":const o=Z._parseEnumValue(e,s.arguments,"track name policy",V.trackNamePolicy);return o===void 0?w.NotAppliedSemanticError:(t.stylesheet.multiTrackTrackNamePolicy=o,w.Applied);case"firstsystemtracknamemode":const l=Z._parseEnumValue(e,s.arguments,"track name mode",V.trackNameMode);return l===void 0?w.NotAppliedSemanticError:(t.stylesheet.firstSystemTrackNameMode=l,w.Applied);case"othersystemstracknamemode":const h=Z._parseEnumValue(e,s.arguments,"track name mode",V.trackNameMode);return h===void 0?w.NotAppliedSemanticError:(t.stylesheet.otherSystemsTrackNameMode=h,w.Applied);case"firstsystemtracknameorientation":const c=Z._parseEnumValue(e,s.arguments,"track name orientation",V.trackNameOrientation);return c===void 0?w.NotAppliedSemanticError:(t.stylesheet.firstSystemTrackNameOrientation=c,w.Applied);case"othersystemstracknameorientation":const d=Z._parseEnumValue(e,s.arguments,"track name orientation",V.trackNameOrientation);return d===void 0?w.NotAppliedSemanticError:(t.stylesheet.otherSystemsTrackNameOrientation=d,w.Applied);case"chorddiagramsinscore":return t.stylesheet.globalDisplayChordDiagramsInScore=s.arguments?Z._booleanLikeValue(s.arguments.arguments,0):!0,w.Applied;case"hideemptystaves":return t.stylesheet.hideEmptyStaves=!0,w.Applied;case"hideemptystavesinfirstsystem":return t.stylesheet.hideEmptyStavesInFirstSystem=!0,w.Applied;case"showsinglestaffbrackets":return t.stylesheet.showSingleStaffBrackets=!0,w.Applied;case"defaultbarnumberdisplay":const f=Z._parseEnumValue(e,s.arguments,"bar number display",V.barNumberDis
vendor: 5,352 bytes, line 4
4play);return f===void 0?w.NotAppliedSemanticError:(t.stylesheet.barNumberDisplay=f,w.Applied);default:return w.NotAppliedUnrecognizedMarker}}_checkArgumentTypes(e,t,s,i,r){const n=t.find(l=>l.has(i));if(!n)return w.NotAppliedUnrecognizedMarker;const o=n.get(i);if(!o){r&&r.arguments.length>0&&e.addSemanticDiagnostic({code:fe.AT300,message:"Expected no arguments, but found some.",start:r.start,end:r.end,severity:ce.Warning});return}if(!this._validateArgumentTypes(e,o,s,r))return w.NotAppliedSemanticError}applyStaffMetaData(e,t,s){const i=this._checkArgumentTypes(e,[Ve.staffMetaDataSignatures],s,s.tag.tag.text.toLowerCase(),s.arguments);if(i!==void 0)return i;switch(s.tag.tag.text.toLowerCase()){case"capo":return t.capo=s.arguments.arguments[0].value,w.Applied;case"tuning":const r=[];let n=!1,o="";for(let f=0;f<s.arguments.arguments.length;f++){const p=s.arguments.arguments[f],g=p.text;switch(g){case"piano":case"none":case"voice":e.applyStaffNoteKind(t,Jt.Pitched),f=s.arguments.arguments.length;break;case"hide":n=!0,e.addSemanticDiagnostic({code:fe.AT305,message:"This value should be rather specified via the properties.",start:p.start,end:p.end,severity:ce.Warning});break;default:const m=L.parseTuning(g);if(m)r.push(m.realValue);else if(f===s.arguments.arguments.length-1&&r.length>0)o=g,e.addSemanticDiagnostic({code:fe.AT305,message:"This value should be rather specified via the properties.",start:p.start,end:p.end,severity:ce.Warning});else{const b=Array.from(L.tuningLetters).join(","),S=Array.from(L.accidentalModeMapping.keys()).join(",");e.addSemanticDiagnostic({code:fe.AT209,message:`Unexpected tuning value '${g}', expected: <note><accidental><octave> where <note>=oneOf(${b}) <accidental>=oneOf(${S}), <octave>=number`,start:p.start,end:p.end,severity:ce.Error})}break}}return e.state.staffHasExplicitTuning.add(t),e.state.staffTuningApplied.delete(t),t.stringTuning=new I,t.stringTuning.tunings=r,t.stringTuning.name=o,this._tuningProperties(e,t,t.stringTuning,s),n&&(t.track.score.stylesheet.perTrackDisplayTuning||(t.track.score.stylesheet.perTrackDisplayTuning=new Map),t.track.score.stylesheet.perTrackDisplayTuning.set(t.track.index,!1)),w.Applied;case"instrument":return e.state.staffTuningApplied.delete(t),this._readTrackInstrument(e,t.track,s.arguments),w.Applied;case"bank":return t.track.playbackInfo.bank=s.arguments.arguments[0].value,w.Applied;case"lyrics":const l=new es;return l.startBar=0,l.text="",s.arguments.arguments.length===2?(l.startBar=s.arguments.arguments[0].value,l.text=s.arguments.arguments[1].text):l.text=s.arguments.arguments[0].text,e.state.lyrics.get(t.track.index).push(l),w.Applied;case"chord":const h=new Bi;this._chordProperties(e,h,s),h.name=s.arguments.arguments[0].text;for(let f=1;f<s.arguments.arguments.length;f++){const p=s.arguments.arguments[f];if(p.nodeType===x.Number)h.strings.push(p.value);else if(p.nodeType===x.Ident){const g=p.text;g==="x"?h.strings.push(-1):e.addSemanticDiagnostic({code:fe.AT209,message:`Unexpected chord value '${g}', expected: 'x'`,severity:ce.Error,start:p.start,end:p.end})}}return t.addChord(Z._getChordId(t,h.name),h),w.Applied;case"articulation":const c=e.state.percussionArticulationNames,d=s.arguments.arguments[0].text;if(d==="defaults"){for(const[f,p]of Xe.instrumentArticulationNames)c.set(f.toLowerCase(),p),c.set(L.toArticulationId(f),p);return w.Applied}if(s.arguments.arguments.length===2){const f=s.arguments.arguments[1].value,p=Xe.getArticulationById(f);if(p)return c.set(d.toLowerCase(),p.uniqueId),w.Applied;{const g=Array.from(Xe.instrumentArticulationIds()).map(m=>`${m}`).join(",");return e.addSemanticDiagnostic({code:fe.AT209,message:`Unexpected articulation value '${f}', expected: ${g}`,start:s.arguments.arguments[1].start,end:s.arguments.arguments[1].end,severity:ce.Error}),w.NotAppliedSemanticError}}return w.Applied;case"accidentals":return Z._handleAccidentalMode(e,s.arguments);case"displaytranspose":return t.displayTranspositionPitch=s.arguments.arguments[0].value*-1,e.state.staffHasExplicitDisplayTransposition.add(t),w.Applied;case"transpose":return t.transpositionPitch=s.arguments.arguments[0].value*-1,w.Applied;default:return w.NotAppliedUnrecognizedMarker}}applyBarMetaData(e,t,s){const i=this._checkArgumentTypes(e,[Ve.barMetaDataSignatures],s,s.tag.tag.text.toLowerCase(),s.arguments);if(i!==void 0)return i;switch(s.tag.tag.text.toLowerCase()){case"sync":const r=this._buildSyncPoint(s);return e.state.syncPoints.push(r),w.Applied;case"tempo":let n=0;const o=s.arguments.arguments[n++].value;let l="",h=!0,c=0;for(;n<s.arguments.arguments.length;){switch(s.arguments.arguments[n].nodeType){case x.Ident:case x.String:const Q=s.arguments.arguments[n].text;Q==="hide"?h=!1:l=Q;break;case x.Number:c=s.arguments.arguments[n].value;break}n++}let d=t.masterBar.tempoAutomations.find(Q=>Q.ratioPosition===c);return d||(d=new tt,t.masterBar.tempoAutomations.push(d)),d.isLinear=!1,d.type=Re.Tempo,d.value=o,d.text=l,d.ratioPosition=c,d.isVisible=h,w.Applied;case"rc":return t.masterBar.repeatCount=s.arguments.arguments[0].value,w.Applied;case"ae":for(const Q of s.arguments.arguments)if(Q.nodeType===x.Number){const me=Q.value;if(me<1||me>31)return e.addSemanticDiagnostic({code:fe.AT211,message:"Value is out of valid range. Allowed range: %s, Actual Value: %s",severity:ce.Error,start:Q.start,end:Q.end}
4),w.NotAppliedSemanticError;t.masterBar.alternateEndings|=1<<me-1}else e.addSemanticDiagnostic({code:fe.AT202,message:`Unexpected '${x[Q.nodeType]}' token. Expected one of following: ${x[x.Number]}`,severity:ce.Error,start:Q.start,end:Q.end});return w.Applied;case"ts":switch(s.arguments.arguments[0].nodeType){case x.Number:if(t.masterBar.timeSignatureNumerator=s.arguments.arguments[0].value|0,(t.masterBar.timeSignatureNumerator<1||t.masterBar.timeSignatureNumerator>32)&&e.addSemanticDiagnostic({code:fe.AT211,message:`Value is out of valid range. Allowed range: 1-32, Actual Value: ${t.masterBar.timeSignatureNumerator}`,start:s.arguments.arguments[0].start,end:s.arguments.arguments[0].end,severity:ce.Error}),t.masterBar.timeSignatureDenominator=s.arguments.arguments[1].value|0,!Z._timeSignatureDenominators.has(t.masterBar.timeSignatureDenominator)){const me=Array.from(Z._timeSignatureDenominators).join(", ");e.addSemanticDiagnostic({code:fe.AT211,message:`Value is out of valid range. Allowed range: ${me}, Actual Value: ${t.masterBar.timeSignatureDenominator}`,start:s.arguments.arguments[0].start,end:s.arguments.arguments[0].end,severity:ce.Error})}break;case x.Ident:case x.String:const Q=s.arguments.arguments[0].text;if(Q.toLowerCase()==="common")t.masterBar.timeSignatureCommon=!0,t.masterBar.timeSignatureNumerator=4,t.masterBar.timeSignatureDenominator=4;else return e.addSemanticDiagnostic({code:fe.AT209,message:`Unexpected time signature value '${Q}', expected: common or two numbers`,severity:ce.Error,start:s.arguments.arguments[0].start,end:s.arguments.arguments[0].end}),w.NotAppliedSemanticError;break}return w.Applied;case"beaming":return this._parseBeamingRule(e,s,t.masterBar);case"ks":const f=Z._parseEnumValue(e,s.arguments,"key signature",V.keySignature);if(f===void 0)return w.NotAppliedSemanticError;const p=Z._parseEnumValue(e,s.arguments,"key signature type",V.keySignatureType);return p===void 0?w.NotAppliedSemanticError:(t.keySignature=f,t.keySignatureType=p,w.Applied);case"clef":switch(s.arguments.arguments[0].nodeType){case x.Ident:case x.String:const Q=Z._parseEnumValue(e,s.arguments,"clef",V.clef);if(Q===void 0)return w.NotAppliedSemanticError;t.clef=Q;break;case x.Number:const me=s.arguments.arguments[0].value;switch(me){case 0:t.clef=ve.Neutral;break;case 43:t.clef=ve.G2;break;case 65:t.clef=ve.F4;break;case 48:t.clef=ve.C3;break;case 60:t.clef=ve.C4;break;default:return e.addSemanticDiagnostic({code:fe.AT209,message:`Unexpected clef value '${me}', expected: ${Array.from(V.clef.keys()).join(",")}`,severity:ce.Error,start:s.arguments.arguments[0].start,end:s.arguments.arguments[0].end}),w.NotAppliedSemanticError}break}return w.Applied;case"section":const g=new Tr;return s.arguments.arguments.length===1?g.text=s.arguments.arguments[0].text:(g.marker=s.arguments.arguments[0].text,g.text=s.arguments.arguments[1].text),t.masterBar.section=g,w.Applied;case"tf":switch(s.arguments.arguments[0].nodeType){case x.Ident:case x.String:const Q=Z._parseEnumValue(e,s.arguments,"triplet feel",V.tripletFeel);if(Q===void 0)return w.NotAppliedSemanticError;t.masterBar.tripletFeel=Q;break;case x.Number:const me=s.arguments.arguments[0].value;switch(me){case 0:t.masterBar.tripletFeel=Ce.NoTripletFeel;break;case 1:t.masterBar.tripletFeel=Ce.Triplet16th;break;case 2:t.masterBar.tripletFeel=Ce.Triplet8th;break;case 3:t.masterBar.tripletFeel=Ce.Dotted16th;break;case 4:t.masterBar.tripletFeel=Ce.Dotted8th;break;case 5:t.masterBar.tripletFeel=Ce.Scottish16th;break;case 6:t.masterBar.tripletFeel=Ce.Scottish8th;break;default:return e.addSemanticDiagnostic({code:fe.AT209,message:`Unexpected triplet feel value '${me}', expected: ${Array.from(V.tripletFeel.keys()).join(",")}`,severity:ce.Error,start:s.arguments.arguments[0].start,end:s.arguments.arguments[0].end}),w.NotAppliedSemanticError}break}return w.Applied;case"barlineleft":const m=Z._parseEnumValue(e,s.arguments,"bar line",V.barLineStyle);return m===void 0?w.NotAppliedSemanticError:(t.barLineLeft=m,w.Applied);case"barlineright":const b=Z._parseEnumValue(e,s.arguments,"bar line",V.barLineStyle);return b===void 0?w.NotAppliedSemanticError:(t.barLineRight=b,w.Applied);case"accidentals":return Z._handleAccidentalMode(e,s.arguments);case"voicemode":return Z._handleVoiceMode(e,s.arguments);case"jump":const S=Z._parseEnumValue(e,s.arguments,"direction",V.direction);return S===void 0?w.NotAppliedSemanticError:(t.masterBar.addDirection(S),w.Applied);case"ottava":const N=Z._parseEnumValue(e,s.arguments,"clef ottava",V.ottavia);return N===void 0?w.NotAppliedSemanticError:(t.clefOttava=N,w.Applied);case"simile":const v=Z._parseEnumValue(e,s.arguments,"simile mark",V.simileMark);return v===void 0?w.NotAppliedSemanticError:(t.simileMark=v,w.Applied);case"width":return t.masterBar.displayWidth=s.arguments.arguments[0].value,t.displayWidth=t.masterBar.displayWidth,w.Applied;case"scale":return t.masterBar.displayScale=s.arguments.arguments[0].value,t.displayScale=t.masterBar.displayScale,w.Applied;case"spd":const W=new _i;return W.pedalType=it.Down,W.ratioPosition=s.arguments.arguments[0].value,t.sustainPedals.push(W),w.Applied;case"spu":const j=new _i;return j.pedalType=it.Up,j.ratioPosition=s.arguments.arguments[0].value,t.sustainPedals.push(j),w.Applied;case"sph":const q=new _i;return q.pedalType=it.Hold,q.ratioPosition=s.arguments.arguments[0].value,t.sustainPedals.push(q),w.Applied;case"ft":return t.masterBar.isFreeTime=!0,w.Applied;case"ro":return t.masterBar.isRepeatStart=!0,w.Applied;case"ac":return t.masterBar.isAnacrusis=!0,w.Applied;case"db":return t.masterBar.isDoubleBar=!0,t.barLineRight=ye.LightLight,w.Applied;case"barnumberdisplay":const F=Z._parseEnumValue(e,s.arguments,"bar number display",V.barNumberDis
vendor: 10,827 bytes, lines 4-5
4play);return F===void 0?w.NotAppliedSemanticError:(t.barNumberDisplay=F,w.Applied);default:return w.NotAppliedUnrecognizedMarker}}_parseBeamingRule(e,t,s){let i=y.Eighth;const r=[],n=t.arguments.arguments[0].value;switch(n){case 4:i=y.QuadrupleWhole;break;case 8:i=y.Eighth;break;case 16:i=y.Sixteenth;break;case 32:i=y.ThirtySecond;break;default:return e.addSemanticDiagnostic({code:fe.AT209,message:`Value is out of valid range. Allowed range: 4,8,16 or 32, Actual Value: ${n}`,severity:ce.Error,start:t.arguments.arguments[0].start,end:t.arguments.arguments[0].end}),w.NotAppliedSemanticError}for(let o=1;o<t.arguments.arguments.length;o++){if(t.arguments.arguments[o].value<1)return e.addSemanticDiagnostic({code:fe.AT209,message:`Value is out of valid range. Allowed range: >0, Actual Value: ${n}`,severity:ce.Error,start:t.arguments.arguments[o].start,end:t.arguments.arguments[o].end}),w.NotAppliedSemanticError;r.push(t.arguments.arguments[o].value)}return s.beamingRules||(s.beamingRules=new nt),s.beamingRules.groups.set(i,r),w.Applied}static _handleAccidentalMode(e,t){const s=Z._parseEnumValue(e,t,"accidental mode",V.alphaTexAccidentalMode);return s===void 0?w.NotAppliedSemanticError:(e.state.accidentalMode=s,w.Applied)}static _handleVoiceMode(e,t){const s=Z._parseEnumValue(e,t,"voice mode",V.alphaTexVoiceMode);return s===void 0?w.NotAppliedSemanticError:(e.state.voiceMode=s,w.Applied)}static _getChordId(e,t){return t.toLowerCase()+e.index+e.track.index}_buildSyncPoint(e){const t=e.arguments.arguments[0].value,s=e.arguments.arguments[1].value,i=e.arguments.arguments[2].value;let r=0;return e.arguments.arguments.length>3&&(r=e.arguments.arguments[3].value),{barIndex:t,barOccurence:s,barPosition:r,millisecondOffset:i}}_validateArgumentTypes(e,t,s,i){if(!i)return t.some(d=>d.parameters.length===0||!d.parameters.some(f=>f.parseMode===Pt.Required||f.parseMode===Pt.RequiredAsFloat||f.parseMode===Pt.RequiredAsValueList))?!0:(e.addSemanticDiagnostic({code:fe.AT219,message:`Error parsing arguments: no overload matched arguments ${At.generateSignaturesFromArguments(void 0)}. Signatures: ${At.generateSignatures(t)}`,severity:ce.Error,start:s.start,end:s.end}),!1);if(i.validated)return!0;let r=!1;const n=new Map(t.map((c,d)=>[d,{signature:c,parameterIndex:0,parameterValueMatches:0,parameterHasValues:!1}])),o=e.parseMode===Zi.Full,l=o?(c,d)=>{const f=n.get(d),p=c;p.parameterIndices||(p.parameterIndices=new Map),p.parameterIndices.set(d,f.parameterIndex)}:(c,d)=>{};for(const c of i.arguments)if(At.filterSignatureCandidates(n,c,!1,l),n.size===0)break;const h=o?Array.from(n.entries()):void 0;return At.filterIncompleteCandidates(n),n.size===0&&(e.addSemanticDiagnostic({code:fe.AT219,message:`Error parsing arguments: no overload matched arguments ${At.generateSignaturesFromArguments(i.arguments)}. Signatures:
5${At.generateSignatures(t)}`,severity:ce.Error,start:i.start,end:i.end}),r=!0),h&&(At.sortCandidates(h),i.signatureCandidateIndices=h.map(c=>c[0])),!r}_headerFooterStyle(e,t,s,i,r=1){const n=i.arguments.arguments.length-r;if(n<1)return;const o=L.getOrCreateHeaderFooterStyle(t,s);o.isVisible===void 0&&(o.isVisible=!0);const l=i.arguments.arguments[r].text;if(l?o.template=l:o.isVisible=!1,n<2)return;const h=Z._parseEnumValue(e,i.arguments,"textAlign",V.textAlign,r+1);h!==void 0&&(o.textAlign=h)}_readTrackInstrument(e,t,s){switch(s.arguments[0].nodeType){case x.Number:const i=s.arguments[0].value;i>=0&&i<=127?t.playbackInfo.program=i:e.addSemanticDiagnostic({code:fe.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:ce.Error});break;case x.Ident:case x.String:const r=s.arguments[0].text.toLowerCase();if(r==="percussion"){for(const n of t.staves)e.applyStaffNoteKind(n,Jt.Articulation);t.playbackInfo.primaryChannel=de.PercussionChannel,t.playbackInfo.secondaryChannel=de.PercussionChannel}else t.playbackInfo.program=Ss.getValue(r);break}}_chordProperties(e,t,s){if(s.properties){for(const i of s.properties.properties)if(this._checkProperty(e,[Ve.metaDataProperties.get("chord")],i))switch(i.property.text.toLowerCase()){case"firstfret":t.firstFret=i.arguments.arguments[0].value;break;case"showdiagram":t.showDiagram=Z._booleanLikeValue(i.arguments.arguments,0);break;case"showfingering":t.showFingering=Z._booleanLikeValue(i.arguments.arguments,0);break;case"showname":t.showName=Z._booleanLikeValue(i.arguments.arguments,0);break;case"barre":t.barreFrets=i.arguments.arguments.map(r=>r.value);break}}}_tuningProperties(e,t,s,i){if(i.properties){for(const r of i.properties.properties)if(this._checkProperty(e,[Ve.metaDataProperties.get("tuning")],r))switch(r.property.text.toLowerCase()){case"hide":t.track.score.stylesheet.perTrackDisplayTuning||(t.track.score.stylesheet.perTrackDisplayTuning=new Map),t.track.score.stylesheet.perTrackDisplayTuning.set(t.track.index,!1);break;case"label":s.name=r.arguments.arguments[0].text;break}}}static _booleanLikeValue(e,t){if(t>=e.length)return!0;const s=e[t];switch(s.nodeType){case x.String:case x.Ident:return s.text!=="false";case x.Number:return s.value!==0;default:return!1}}applyStructuralMetaData(e,t){const s=this._checkArgumentTypes(e,[Ve.structuralMetaDataSignatures],t,t.tag.tag.text.toLowerCase(),t.arguments);if(s!==void 0)switch(s){case w.NotAppliedSemanticError:return Gs.NotAppliedSemanticError;case w.NotAppliedUnrecognizedMarker:return Gs.NotAppliedUnrecognizedMarker}switch(t.tag.tag.text.toLowerCase()){case"staff":const i=e.startNewStaff();return this._staffProperties(e,i,t),Gs.AppliedNewStaff;case"track":const r=e.startNewTrack();return t.arguments&&t.arguments.arguments.length>0&&(r.name=t.arguments.arguments[0].text,t.arguments.arguments.length>1&&(r.shortName=t.arguments.arguments[1].text)),this._trackProperties(e,r,t),Gs.AppliedNewTrack;case"voice":return e.startNewVoice(),Gs.AppliedNewVoice;default:return Gs.NotAppliedUnrecognizedMarker}}_checkProperty(e,t,s){const i=this._checkArgumentTypes(e,t,s,s.property.text.toLowerCase(),s.arguments);if(i!==void 0)switch(i){case w.Applied:case w.NotAppliedSemanticError:return!1;case w.NotAppliedUnrecognizedMarker:const r=t.flatMap(n=>Array.from(n.keys()));return e.addSemanticDiagnostic({code:fe.AT212,message:`Unrecogized property '${s.property.text}', expected one of ${r}`,severity:ce.Error,start:s.start,end:s.end}),!1}return!0}_staffProperties(e,t,s){if(!s.properties)return;let i=!1,r=!1,n=!1,o=!1;for(const l of s.properties.properties)if(this._checkProperty(e,[Ve.metaDataProperties.get("staff")],l))switch(l.property.text.toLowerCase()){case"score":i=!0,l.arguments&&l.arguments.arguments.length>0&&(t.standardNotationLineCount=l.arguments.arguments[0].value);break;case"tabs":r=!0;break;case"slash":n=!0;break;case"numbered":o=!0;break}(i||r||n||o)&&(t.showStandardNotation=i,t.showTablature=r,t.showSlash=n,t.showNumbered=o)}_trackProperties(e,t,s){if(s.properties){for(const i of s.properties.properties)if(this._checkProperty(e,[Ve.metaDataProperties.get("track")],i))switch(i.property.text.toLowerCase()){case"color":try{t.color=Fe.fromJson(i.arguments.arguments[0].text)}catch{e.addSemanticDiagnostic({code:fe.AT213,message:"Invalid format for color",severity:ce.Error,start:i.arguments.arguments[0].start,end:i.arguments.arguments[0].end})}break;case"defaultsystemslayout":t.defaultSystemsLayout=i.arguments.arguments[0].value;break;case"systemslayout":t.systemsLayout=i.arguments.arguments.map(r=>r.value);break;case"volume":t.playbackInfo.volume=i.arguments.arguments[0].value;break;case"balance":t.playbackInfo.balance=i.arguments.arguments[0].value;break;case"mute":t.playbackInfo.isMute=!0;break;case"solo":t.playbackInfo.isSolo=!0;break;case"multibarrest":t.score.stylesheet.perTrackMultiBarRest||(t.score.stylesheet.perTrackMultiBarRest=new Set),t.score.stylesheet.perTrackMultiBarRest.add(t.index);break;case"instrument":this._readTrackInstrument(e,t,i.arguments);break;case"bank":t.playbackInfo.bank=i.arguments.arguments[0].value;break}}}applyBeatDurationProperty(e,t){const s=this._checkArgumentTypes(e,[Ve.durationChangeProperties],t,t.property.text.toLowerCase(),t.arguments);if(s!==void 0)return s;switch(t.property.text.toLowerCase()){case"tu":if(t.arguments.arguments.length===2)e.state.currentTupletNumerator=t.arguments.arguments[0].value,e.state.currentTupletDenominator=t.arguments.arguments[1].value;else{const i=t.arguments.arguments[0].value;e.state.currentTupletNumerator=i;const r=Z._getTupletDenominator(i);r<0?(e.addSemanticDiagnostic({code:fe.AT209,message:`Unexpected default tuplet value '${i}', expected: 3, 5, 6, 7, 9, 10, 11 or 12`,severity:ce.Error,start:t.arguments.arguments[0].start,end:t.arguments.arguments[0].end}),e.state.currentTupletNumerator=-1,e.state.currentTupletDenominator=-1):e.state.currentTupletDenominator=r}return w.Applied}return w.NotAppliedUnrecognizedMarker}static _getTupletDenominator(e){switch(e){case 3:return 2;case 5:return 4;case 6:return 4;case 7:return 4;case 9:return 8;case 10:return 8;case 11:return 8;case 12:return 8;default:return-1}}_allKnownBarMetaDataTags=void 0;get allKnownMetaDataTags(){if(!this._allKnownBarMetaDataTags){this._allKnownBarMetaDataTags=new Set;const e=[Ve.scoreMetaDataSignatures.keys(),Ve.structuralMetaDataSignatures.keys(),Ve.staffMetaDataSignatures.keys(),Ve.barMetaDataSignatures.keys()];for(const t of e)for(const s of t)this._allKnownBarMetaDataTags.add(s)}return this._allKnownBarMetaDataTags}_knownScoreMetaDataTags=void 0;get knownScoreMetaDataTags(){return this._knownScoreMetaDataTags||(this._knownScoreMetaDataTags=new Set(Ve.scoreMetaDataSignatures.keys())),this._knownScoreMetaDataTags}_knownStructuralMetaDataTags=void 0;get knownStructuralMetaDataTags(){return this._knownStructuralMetaDataTags||(this._knownStructuralMetaDataTags=new Set(Ve.structuralMetaDataSignatures.keys())),this._knownStructuralMetaDataTags}_knownBarMetaDataTags=void 0;get knownBarMetaDataTags(){return this._knownBarMetaDataTags||(this._knownBarMetaDataTags=new Set(Ve.barMetaDataSignatures.keys())),this._knownBarMetaDataTags}_knownStaffMetaDataTags=void 0;get knownStaffMetaDataTags(){return this._knownStaffMetaDataTags||(this._knownStaffMetaDataTags=new Set(Ve.staffMetaDataSignatures.keys())),this._knownStaffMetaDataTags}_knownBeatDurationProperties=void 0;get knownBeatDurationProperties(){return this._knownBeatDurationProperties||(this._knownBeatDurationProperties=new Set(Ve.durationChangeProperties.keys())),this._knownBeatDurationProperties}_knownBeatProperties=void 0;get knownBeatProperties(){return this._knownBeatProperties||(this._knownBeatProperties=new Set(Ve.beatProperties.keys())),this._knownBeatProperties}_knownNoteProperties=void 0;get knownNoteProperties(){return this._knownNoteProperties||(this._knownNoteProperties=new Set(Ve.n
5oteProperties.keys())),this._knownNoteProperties}applyBeatProperty(e,t,s){const i=s.property.text.toLowerCase(),r=this._checkArgumentTypes(e,[Ve.beatProperties],s,i,s.arguments);if(r!==void 0)return r;switch(i){case"f":return t.fade=yt.FadeIn,w.Applied;case"fo":return t.fade=yt.FadeOut,w.Applied;case"vs":return t.fade=yt.VolumeSwell,w.Applied;case"v":return t.vibrato=Be.Slight,w.Applied;case"vw":return t.vibrato=Be.Wide,w.Applied;case"s":return t.slap=!0,w.Applied;case"p":return t.pop=!0,w.Applied;case"tt":return t.tap=!0,w.Applied;case"txt":return t.text=s.arguments.arguments[0].text,w.Applied;case"lyrics":let n=0,o="";for(s.arguments.arguments.length===2?(n=s.arguments.arguments[0].value,o=s.arguments.arguments[1].text):o=s.arguments.arguments[0].text,t.lyrics||(t.lyrics=[]);t.lyrics.length<=n;)t.lyrics.push("");return t.lyrics[n]=o,w.Applied;case"dd":return t.dots=2,w.Applied;case"d":return t.dots=1,w.Applied;case"su":return t.pickStroke=Ct.Up,w.Applied;case"sd":return t.pickStroke=Ct.Down,w.Applied;case"tu":if(s.arguments.arguments.length===2)t.tupletNumerator=s.arguments.arguments[0].value,t.tupletDenominator=s.arguments.arguments[1].value;else{const De=s.arguments.arguments[0].value;t.tupletNumerator=De;const vs=Z._getTupletDenominator(De);if(vs<0)return e.addSemanticDiagnostic({code:fe.AT209,message:`Unexpected default tuplet value '${De}', expected: 3, 5, 6, 7, 9, 10, 11 or 12`,severity:ce.Error,start:s.arguments.arguments[0].start,end:s.arguments.arguments[0].end}),t.tupletNumerator=-1,t.tupletDenominator=-1,w.NotAppliedSemanticError;t.tupletDenominator=vs}return w.Applied;case"tb":case"tbe":let l=0,h=!0,c=!1;for(;h;)switch(s.arguments.arguments[l].nodeType){case x.Ident:case x.String:const De=s.arguments.arguments[l].text.toLowerCase();if(V.whammyType.has(De))t.whammyBarType=V.whammyType.get(De),c=!0,l++;else if(V.bendStyle.has(De))t.whammyStyle=V.bendStyle.get(De),l++;else return c?Z._parseEnumValue(e,s.arguments,"whammy style",V.bendStyle,l):Z._parseEnumValue(e,s.arguments,"whammy type",V.whammyType,l),w.NotAppliedSemanticError;break;default:h=!1;break}const d=this._getBendPoints(e,s,l,i==="tbe");if(d)for(const De of d)t.addWhammyBarPoint(De);return w.Applied;case"bu":return Z._applyBrush(t,s,z.BrushUp,.25),w.Applied;case"bd":return Z._applyBrush(t,s,z.BrushDown,.25),w.Applied;case"au":return Z._applyBrush(t,s,z.ArpeggioUp,1),w.Applied;case"ad":return Z._applyBrush(t,s,z.ArpeggioDown,1),w.Applied;case"ch":const f=s.arguments.arguments[0].text,p=Z._getChordId(t.voice.bar.staff,f);if(!t.voice.bar.staff.hasChord(p)){const De=new Bi;De.showDiagram=!1,De.name=f,t.voice.bar.staff.addChord(p,De)}return t.chordId=p,w.Applied;case"gr":if(s.arguments&&s.arguments.arguments.length>0){const De=Z._parseEnumValue(e,s.arguments,"whammy style",V.graceType);if(De===void 0)return w.NotAppliedSemanticError;t.graceType=De}else t.graceType=K.BeforeBeat;return w.Applied;case"dy":const g=Z._parseEnumValue(e,s.arguments,"dynamic",V.dynamicValue);return g===void 0?w.NotAppliedSemanticError:(t.dynamics=g,e.state.currentDynamics=g,w.Applied);case"cre":return t.crescendo=Gt.Crescendo,w.Applied;case"dec":return t.crescendo=Gt.Decrescendo,w.Applied;case"tempo":const m=s.arguments.arguments[0].value;let b="",S=!0;if(s.arguments.arguments.length>2){b=s.arguments.arguments[1].text;const De=s.arguments.arguments[2].text;if(De==="hide")S=!1;else return e.addSemanticDiagnostic({code:fe.AT209,message:`Unexpected third tempo property value '${De}', expected: 'hide'`,severity:ce.Error,start:s.arguments.arguments[2].start,end:s.arguments.arguments[2].end}),w.NotAppliedSemanticError}else s.arguments.arguments.length>1&&(b=s.arguments.arguments[1].text,b==="hide"&&(S=!1,b=""));const N=new tt;return N.isLinear=!1,N.type=Re.Tempo,N.value=m,N.text=b,N.isVisible=S,t.automations.push(N),t.voice.bar.masterBar.tempoAutomations.push(N),w.Applied;case"volume":const v=new tt;return v.isLinear=!0,v.type=Re.Volume,v.value=s.arguments.arguments[0].value,t.automations.push(v),w.Applied;case"balance":const W=new tt;return W.isLinear=!0,W.type=Re.Balance,W.value=L.clamp(s.arguments.arguments[0].value,0,16),t.automations.push(W),w.Applied;case"tp":const j=new Ts;if(t.tremoloPicking=j,s.arguments&&s.arguments.arguments.length>0){if(s.arguments.arguments.length>0){const De=s.arguments.arguments[0].value;if(De>=Ts.minMarks&&De<=Ts.maxMarks)j.marks=De;else switch(De){case 8:j.marks=1;break;case 16:j.marks=2;break;case 32:j.marks=3;break;default:return e.addSemanticDiagnostic({code:fe.AT209,message:`Unexpected tremolo marks value '${De}, expected: ${Ts.minMarks}-${Ts.maxMarks}, or legacy: 8, 16 or 32`,severity:ce.Error,start:s.arguments.arguments[0].start,end:s.arguments.arguments[0].end}
5),w.NotAppliedSemanticError}}if(s.arguments.arguments.length>1){const De=Z._parseEnumValue(e,s.arguments,"tremolo picking style",V.tremoloPickingStyle,1);if(De===void 0)return w.NotAppliedSemanticError;j.style=De}}return w.Applied;case"spd":return Z._applySustainPedal(e,t,it.Down),w.Applied;case"sph":return Z._applySustainPedal(e,t,it.Hold),w.Applied;case"spu":return Z._applySustainPedal(e,t,it.Up),w.Applied;case"spe":return Z._applySustainPedal(e,t,it.Up,!0),w.Applied;case"slashed":return t.slashed=!0,w.Applied;case"ds":return t.deadSlapped=!0,t.notes.length===1&&t.notes[0].isDead&&t.removeNote(t.notes[0]),w.Applied;case"glpf":return t.golpe=Xt.Finger,w.Applied;case"glpt":return t.golpe=Xt.Thumb,w.Applied;case"waho":return t.wahPedal=ss.Open,w.Applied;case"wahc":return t.wahPedal=ss.Closed,w.Applied;case"barre":if(t.barreFret=s.arguments.arguments[0].value,t.barreShape=xs.Full,s.arguments.arguments.length>1){const De=Z._parseEnumValue(e,s.arguments,"barre shape",V.barreShape,1);if(De===void 0)return w.NotAppliedSemanticError;t.barreShape=De}return w.Applied;case"rasg":const q=Z._parseEnumValue(e,s.arguments,"rasgueado pattern",V.rasgueado);return q===void 0?w.NotAppliedSemanticError:(t.rasgueado=q,w.Applied);case"ot":const F=Z._parseEnumValue(e,s.arguments,"ottava",V.ottavia);return F===void 0?w.NotAppliedSemanticError:(t.ottava=F,w.Applied);case"legatoorigin":return t.isLegatoOrigin=!0,w.Applied;case"instrument":let Q=0;switch(s.arguments.arguments[0].nodeType){case x.Ident:case x.String:Q=Ss.getValue(s.arguments.arguments[0].text);break;case x.Number:Q=s.arguments.arguments[0].value;break}const me=new tt;return me.isLinear=!1,me.type=Re.Instrument,me.value=Q,t.automations.push(me),w.Applied;case"bank":const ge=new tt;return ge.isLinear=!1,ge.type=Re.Bank,ge.value=s.arguments.arguments[0].value,t.automations.push(ge),w.Applied;case"fermata":const re=Z._parseEnumValue(e,s.arguments,"fermata",V.fermataType);if(re===void 0)return w.NotAppliedSemanticError;const Je=new Br;return Je.type=re,s.arguments.arguments.length>1&&(Je.length=s.arguments.arguments[1].value),t.fermata=Je,w.Applied;case"beam":const lt=s.arguments.arguments[0].text;switch(lt.toLowerCase()){case"invert":t.invertBeamDirection=!0;break;case"up":t.preferredBeamDirection=P.Up;break;case"down":t.preferredBeamDirection=P.Down;break;case"auto":t.beamingMode=st.Auto;break;case"split":t.beamingMode=st.ForceSplitToNext;break;case"merge":t.beamingMode=st.ForceMergeWithNext;break;case"splitsecondary":t.beamingMode=st.ForceSplitOnSecondaryToNext;break;default:const De=["invert","up","down","auto","split","merge","splitsecondary"];return e.addSemanticDiagnostic({code:fe.AT209,message:`Unexpected beam value '${lt}', expected: ${De.join(",")}`,severity:ce.Error,start:s.arguments.arguments[0].start,end:s.arguments.arguments[0].end}),w.NotAppliedSemanticError}return w.Applied;case"timer":return t.showTimer=!0,w.Applied}return w.NotAppliedUnrecognizedMarker}static _applySustainPedal(e,t,s,i=!1){const r=new _i;r.pedalType=s,i?r.ratioPosition=1:r.ratioPosition=.001*t.voice.bar.sustainPedals.length,e.state.sustainPedalToBeat.set(r,t),t.voice.bar.sustainPedals.push(r)}static _applyBrush(e,t,s,i){e.brushType=s,t.arguments&&t.arguments.arguments.length>0?e.brushDuration=t.arguments.arguments[0].value:(e.updateDurations(),e.brushDuration=e.playbackDuration*i/e.notes.length)}applyNoteProperty(e,t,s){const i=s.property.text.toLowerCase(),r=this._checkArgumentTypes(e,[Ve.noteProperties],s,i,s.arguments);if(r!==void 0)return r;switch(i){case"b":case"be":let n=0,o=!0,l=!1;for(;o;)switch(s.arguments.arguments[n].nodeType){case x.Ident:case x.String:const m=s.arguments.arguments[n].text.toLowerCase();if(V.bendType.has(m))t.bendType=V.bendType.get(m),l=!0,n++;else if(V.bendStyle.has(m))t.bendStyle=V.bendStyle.get(m),n++;else return l?Z._parseEnumValue(e,s.arguments,"bend style",V.bendStyle,n):Z._parseEnumValue(e,s.arguments,"bend type",V.bendType,n),w.NotAppliedSemanticError;break;default:o=!1;break}const h=this._getBendPoints(e,s,n,i==="be");if(h)for(const m of h)t.addBendPoint(m);return w.Applied;case"nh":return t.harmonicType=te.Natural,t.harmonicValue=L.deltaFretToHarmonicValue(t.fret),w.Applied;case"ah":return t.harmonicType=te.Artificial,t.harmonicValue=Z._harmonicValue(s.arguments,t.harmonicValue),w.Applied;case"th":return t.harmonicType=te.Tap,t.harmonicValue=Z._harmonicValue(s.arguments,t.harmonicValue),w.Applied;case"ph":return t.harmonicType=te.Pinch,t.harmonicValue=Z._harmonicValue(s.arguments,t.harmonicValue),w.Applied;case"sh":return t.harmonicType=te.Semi,t.harmonicValue=Z._harmonicValue(s.arguments,t.harmonicValue),w.Applied;case"fh":return t.harmonicType=te.Feedback,t.harmonicValue=Z._harmonicValue(s.arguments,t.harmonicValue),w.Applied;case"tr":const c=s.arguments.arguments[0].value;let d=y.Sixteenth;if(s.arguments.arguments.length>1){const m=s.arguments.arguments[1].value;switch(m){case 16:d=y.Sixteenth;break;case 32:d=y.ThirtySecond;break;case 64:d=y.SixtyFourth;break;default:return e.addSemanticDiagnostic({code:fe.AT209,message:`Unexpected trill duration value '${m}', expected: 16, 32 or 64`,severity:ce.Error,start:s.arguments.arguments[1].start,end:s.arguments.arguments[1].end}
vendor: 6,900 bytes, line 5
5),w.NotAppliedSemanticError}}return t.trillValue=c+t.stringTuning,t.trillSpeed=d,w.Applied;case"v":return t.vibrato=Be.Slight,w.Applied;case"vw":return t.vibrato=Be.Wide,w.Applied;case"sl":return t.slideOutType=he.Legato,w.Applied;case"ss":return t.slideOutType=he.Shift,w.Applied;case"sib":return t.slideInType=St.IntoFromBelow,w.Applied;case"sia":return t.slideInType=St.IntoFromAbove,w.Applied;case"sou":return t.slideOutType=he.OutUp,w.Applied;case"sod":return t.slideOutType=he.OutDown,w.Applied;case"psd":return t.slideOutType=he.PickSlideDown,w.Applied;case"psu":return t.slideOutType=he.PickSlideUp,w.Applied;case"h":return t.isHammerPullOrigin=!0,w.Applied;case"lht":return t.isLeftHandTapped=!0,w.Applied;case"g":return t.isGhost=!0,w.Applied;case"ac":return t.accentuated=ct.Normal,w.Applied;case"hac":return t.accentuated=ct.Heavy,w.Applied;case"ten":return t.accentuated=ct.Tenuto,w.Applied;case"pm":return t.isPalmMute=!0,w.Applied;case"st":return t.isStaccato=!0,w.Applied;case"lr":return t.isLetRing=!0,w.Applied;case"x":return t.isDead=!0,w.Applied;case"-":case"t":return t.isTieDestination=!0,w.Applied;case"lf":let f=ie.Thumb;if(s.arguments&&s.arguments.arguments.length>0){const m=Z._toFinger(e,s.arguments);if(m===void 0)return w.NotAppliedSemanticError;f=m}return t.leftHandFinger=f,w.Applied;case"rf":let p=ie.Thumb;if(s.arguments&&s.arguments.arguments.length>0){const m=Z._toFinger(e,s.arguments);if(m===void 0)return w.NotAppliedSemanticError;p=m}return t.rightHandFinger=p,w.Applied;case"acc":return t.accidentalMode=L.parseAccidentalMode(s.arguments.arguments[0].text),w.Applied;case"turn":return t.ornament=ot.Turn,w.Applied;case"iturn":return t.ornament=ot.InvertedTurn,w.Applied;case"umordent":return t.ornament=ot.UpperMordent,w.Applied;case"lmordent":return t.ornament=ot.LowerMordent,w.Applied;case"string":return t.showStringNumber=!0,w.Applied;case"hide":return t.isVisible=!1,w.Applied;case"slur":const g=s.arguments.arguments[0].text;if(e.state.slurs.has(g)){const m=e.state.slurs.get(g);m.slurDestination=t,t.slurOrigin=m,t.isSlurDestination=!0}else e.state.slurs.set(g,t);return w.Applied;default:return this.applyBeatProperty(e,t.beat,s)}return w.NotAppliedUnrecognizedMarker}static _toFinger(e,t){const s=t.arguments[0].value;switch(s){case 1:return ie.Thumb;case 2:return ie.IndexFinger;case 3:return ie.MiddleFinger;case 4:return ie.AnnularFinger;case 5:return ie.LittleFinger;default:e.addSemanticDiagnostic({code:fe.AT211,message:`Value is out of valid range. Allowed range: 1-5, Actual Value: ${s}`,start:t.arguments[0].start,end:t.arguments[0].end,severity:ce.Error});return}}static _harmonicValue(e,t){return e&&(t=e.arguments[0].value),t}_getBendPoints(e,t,s,i){let r=t.arguments.arguments,n=r.length-s,o=t.arguments;n>0&&r[s].nodeType===x.Arguments&&(r=r[s].arguments,s=0,n=r.length,o=r[s]);const l=i?2:1;if(n%l!==0){const d=Math.ceil(n/l),f=d*l;e.addSemanticDiagnostic({code:fe.AT214,message:`The '${t.property.text}' effect needs ${l} arguments per item. With ${d} points, ${f} arguments are needed, only ${n} arguments found.`,severity:ce.Error,start:o.end,end:o.end});return}const h=[];let c=s;for(;c<r.length;){let d=0,f=0;i?(d=r[c++].value,f=r[c++].value):(d=0,f=r[c++].value),h.push(new G(d,f))}if(h.length>0){if(h.length>60&&h.splice(60,h.length-60),i)h.sort((d,f)=>d.offset-f.offset);else{const d=h.length,f=G.MaxPosition/(d-1)|0;let p=0;for(;p<d;)h[p].offset=Math.min(G.MaxPosition,p*f),p++}return h}else return}static _parseEnumValue(e,t,s,i,r=0){if(r>=t.arguments.length)return;const n=t.arguments[r].text;if(i.has(n.toLowerCase()))return i.get(n.toLowerCase());e.addSemanticDiagnostic({code:fe.AT209,message:`Unexpected ${s} value '${n}', expected: ${Array.from(i.keys()).join(",")}`,severity:ce.Error,start:t.arguments[r].start,end:t.arguments[r].end})}static _defaultScore=new Ks;static _defaultTrack=new Zs;buildScoreMetaDataNodes(e){const t=[];return Z._buildScoreInfoMeta(t,"album",e,e.album,H.Album),Z._buildScoreInfoMeta(t,"artist",e,e.artist,H.Artist),Z._buildScoreInfoMeta(t,"copyright",e,e.copyright,H.Copyright),Z._buildScoreInfoMeta(t,"copyright2",e,void 0,H.CopyrightSecondLine),Z._buildScoreInfoMeta(t,"wordsandmusic",e,void 0,H.WordsAndMusic,!0),Z._buildScoreInfoMeta(t,"instructions",e,e.instructions,void 0),Z._buildScoreInfoMeta(t,"music",e,e.music,H.Music),Z._buildScoreInfoMeta(t,"notices",e,e.notices,void 0),Z._buildScoreInfoMeta(t,"subtitle",e,e.subTitle,H.SubTitle),Z._buildScoreInfoMeta(t,"title",e,e.title,H.Title),Z._buildScoreInfoMeta(t,"words",e,e.words,H.Words),Z._buildScoreInfoMeta(t,"tab",e,e.tab,H.Transcriber),e.defaultSystemsLayout!==Z._defaultScore.defaultSystemsLayout&&t.push(_.numberMeta("defaultSystemsLayout",e.defaultSystemsLayout)),e.systemsLayout.length>0&&t.push(_.meta("systemsLayout",_.args(e.systemsLayout.map(s=>_.number(s))))),Z._buildStyleSheetMetaData(t,e.stylesheet),t.length>0&&(t[0].leadingComments=[{text:"Score Metadata",multiLine:!1}]),t}static _buildStyleSheetMetaData(e,t){const s=e.length;t.hideDynamics&&e.push(_.meta("hideDynamics")),t.bracketExtendMode!==Z._defaultScore.stylesheet.bracketExtendMode&&e.push(_.identMeta("bracketExtendMode",V.bracketExtendModeReversed.get(t.bracketExtendMode))),t.useSystemSignSeparator&&e.push(_.meta("useSystemSignSeparator")),t.multiTrackMultiBarRest&&e.push(_.meta("multiBarRest")),t.singleTrackTrackNamePolicy!==Z._defaultScore.stylesheet.singleTrackTrackNamePolicy&&e.push(_.identMeta("singleTrackTrackNamePolicy",V.trackNamePolicyReversed.get(t.singleTrackTrackNamePolicy))),t.multiTrackTrackNamePolicy!==Z._defaultScore.stylesheet.multiTrackTrackNamePolicy&&e.push(_.identMeta("multiTrackTrackNamePolicy",V.trackNamePolicyReversed.get(t.multiTrackTrackNamePolicy))),t.firstSystemTrackNameMode!==Z._defaultScore.stylesheet.firstSystemTrackNameMode&&e.push(_.identMeta("firstSystemTrackNameMode",V.trackNameModeReversed.get(t.firstSystemTrackNameMode))),t.otherSystemsTrackNameMode!==Z._defaultScore.stylesheet.otherSystemsTrackNameMode&&e.push(_.identMeta("otherSystemsTrackNameMode",V.trackNameModeReversed.get(t.otherSystemsTrackNameMode))),t.firstSystemTrackNameOrientation!==Z._defaultScore.stylesheet.firstSystemTrackNameOrientation&&e.push(_.identMeta("firstSystemTrackNameOrientation",V.trackNameOrientationReversed.get(t.firstSystemTrackNameOrientation))),t.otherSystemsTrackNameOrientation!==Z._defaultScore.stylesheet.otherSystemsTrackNameOrientation&&e.push(_.identMeta("otherSystemsTrackNameOrientation",V.trackNameOrientationReversed.get(t.otherSystemsTrackNameOrientation))),t.extendBarLines&&e.push(_.meta("extendBarLines")),t.globalDisplayChordDiagramsInScore&&e.push(_.meta("chordDiagramsInScore")),t.hideEmptyStaves&&e.push(_.meta("hideEmptyStaves")),t.hideEmptyStavesInFirstSystem&&e.push(_.meta("hideEmptyStavesInFirstSystem")),t.showSingleStaffBrackets&&e.push(_.meta("showSingleStaffBrackets")),t.barNumberDis
5play!==vt.AllBars&&e.push(_.identMeta("defaultBarNumberDisplay",vt[t.barNumberDisplay])),s<e.length&&(e[s].leadingComments=[{multiLine:!1,text:"Score Stylesheet"}])}static _buildScoreInfoMeta(e,t,s,i,r,n=!1){if(i!==void 0&&i.length===0&&!n)return;const o=[];if(i!==void 0&&o.push(_.string(i)),r!==void 0){const l=s.style&&s.style.headerAndFooter.has(r)?s.style.headerAndFooter.get(r):void 0,h=Mi.defaultHeaderAndFooter.has(r)?Mi.defaultHeaderAndFooter.get(r):void 0;l&&(!h||!hs.equals(h,l))&&(o.push(_.string(l.isVisible===!1?"":l.template)),o.push(_.ident(V.textAlignReversed.get(l.textAlign))))}i===void 0&&o.length===0||i!==void 0&&i.length===0&&o.length===1||e.push(_.meta(t,_.args(o)))}buildSyncPointNodes(e){const t=[],s=e.exportFlatSyncPoints();for(const i of s)t.push(_.meta("sync",_.args([_.number(i.barIndex),_.number(i.barOccurence),_.number(i.millisecondOffset),i.barPosition>0?_.number(i.barPosition):void 0])));return t}buildBarMetaDataNodes(e,t,s,i){const r=[];if(Z._buildStructuralMetaDataNodes(t,e,r,i,s),!t)return r;s===0&&e.index===0&&e.track.index===0&&Z._buildMasterBarMetaDataNodes(r,t.masterBar);const n=r.length;s===0&&t.index===0&&e.index===0&&e.track.index===0&&r.push(_.identMeta("accidentals","auto")),(t.index===0||t.clef!==t.previousBar?.clef)&&r.push(_.identMeta("clef",V.clefReversed.get(t.clef))),(t.index===0&&t.clefOttava!==le.Regular||t.clefOttava!==t.previousBar?.clefOttava)&&r.push(_.identMeta("ottava",V.ottaviaReversed.get(t.clefOttava))),(t.index===0&&t.simileMark!==xt.None||t.simileMark!==t.previousBar?.simileMark)&&r.push(_.identMeta("simile",V.simileMarkReversed.get(t.simileMark))),t.displayScale!==1&&r.push(_.numberMeta("scale",t.displayScale)),t.displayWidth>0&&r.push(_.numberMeta("width",t.displayWidth));for(const o of t.sustainPedals){let l="";switch(o.pedalType){case it.Down:l="spd";break;case it.Hold:l="sph";break;case it.Up:l="spu";break}l&&r.push(_.numberMeta(l,o.ratioPosition))}if(t.barLineLeft!==ye.Automatic&&r.push(_.identMeta("barLineLeft",V.barLineStyleReversed.get(t.barLineLeft))),t.barLineRight!==ye.Automatic&&r.push(_.identMeta("barLineRight",V.barLineStyleReversed.get(t.barLineRight))),t.index===0||t.keySignature!==t.previousBar.keySignature||t.keySignatureType!==t.previousBar.keySignatureType){let o="";t.keySignatureType===as.Minor?o=V.keySignaturesMinorReversed.get(t.keySignature):o=V.keySignaturesMajorReversed.get(t.keySignature),r.push(_.identMeta("ks",o))}return n<r.length&&(r[n].leadingComments=[{multiLine:!1,text:`Bar ${t.index+1} Metadata`}]),t.barNumberDisplay!==void 0&&r.push(_.identMeta("barNumberDisplay",vt[t.barNumberDisplay])),r}static _buildStaffMetaDataNodes(e,t){const s=e.length;if(t.capo!==0&&e.push(_.numberMeta("capo",t.capo)),t.isPercussion)e.push(_.identMeta("articulation","defaults"));else if(t.isStringed){const r=_.meta("tuning",_.args(t.stringTuning.tunings.map(n=>_.ident(I.getTextForTuning(n,!0)))));e.push(r),t.track.score.stylesheet.perTrackDisplayTuning&&t.track.score.stylesheet.perTrackDisplayTuning.has(t.track.index)&&(r.properties=_.props([["hide",void 0]])),t.stringTuning.name.length>0&&(r.properties??=_.props([]),_.prop(r.properties.properties,"label",_.stringValue(t.stringTuning.name)))}t.transpositionPitch!==0&&e.push(_.numberMeta("transpose",-t.transpositionPitch));const i=L.displayTranspositionPitches.has(t.track.playbackInfo.program)?L.displayTranspositionPitches.get(t.track.playbackInfo.program):0;if(t.displayTranspositionPitch!==i&&e.push(_.numberMeta("displaytranspose",-t.displayTranspositionPitch)),t.chords!=null)for(const[r,n]of t.chords)e.push(Z._buildChordNode(n));s<e.length&&(e[s].leadingComments=[{multiLine:!1,text:`Staff ${t.index+1} Metadata`}])}static _buildChordNode(e){const t=_.meta("chord",_.args([_.string(e.name)],!0),_.props([e.firstFret>=0?["firstfret",_.numberValue(e.firstFret)]:void 0,["showdiagram",_.identValue(e.showDiagram?"true":"false")],["showfingering",_.identValue(e.showFingering?"true":"false")],["showname",_.identValue(e.showName?"true":"false")],e.barreFrets.length>0?["barre",_.args(e.barreFrets.map(s=>_.number(s)))]:void 0]));for(let s=0;s<e.staff.tuning.length;s++)s<e.strings.length&&e.strings[s]>
5=0?t.arguments.arguments.push(_.number(e.strings[s])):t.arguments.arguments.push(_.ident("x"));return t}static _buildMasterBarMetaDataNodes(e,t){const s=e.length;if(t.alternateEndings!==0&&e.push(_.meta("ae",_.args(L.getAlternateEndingsList(t.alternateEndings).map(i=>_.number(i+1))))),t.isRepeatStart&&e.push(_.meta("ro")),t.isRepeatEnd&&e.push(_.numberMeta("rc",t.repeatCount)),(t.index===0||t.timeSignatureCommon!==t.previousMasterBar?.timeSignatureCommon||t.timeSignatureNumerator!==t.previousMasterBar.timeSignatureNumerator||t.timeSignatureDenominator!==t.previousMasterBar.timeSignatureDenominator)&&(t.timeSignatureCommon?e.push(_.identMeta("ts","common")):e.push(_.meta("ts",_.args([_.number(t.timeSignatureNumerator),_.number(t.timeSignatureDenominator)])))),t.beamingRules)for(const[i,r]of t.beamingRules.groups){const n=_.args([_.number(i)],!0);for(const o of r)n.arguments.push(_.number(o));e.push(_.meta("beaming",n))}if((t.index>0&&t.tripletFeel!==t.previousMasterBar?.tripletFeel||t.index===0&&t.tripletFeel!==Ce.NoTripletFeel)&&e.push(_.identMeta("tf",V.tripletFeelReversed.get(t.tripletFeel))),t.isFreeTime&&e.push(_.meta("ft")),t.section!=null&&e.push(_.meta("section",_.args([_.string(t.section.marker),_.string(t.section.text)]))),t.isAnacrusis&&e.push(_.meta("ac")),t.displayScale!==1&&e.push(_.numberMeta("scale",t.displayScale)),t.displayWidth>0&&e.push(_.numberMeta("width",t.displayWidth)),t.directions)for(const i of t.directions)e.push(_.identMeta("jump",V.directionReversed.get(i)));for(const i of t.tempoAutomations){const r=_.meta("tempo",_.args([_.number(i.value),i.text?_.string(i.text):void 0,i.ratioPosition>0?_.number(i.ratioPosition):void 0,i.isVisible?void 0:_.ident("hide")]));r.arguments.arguments.length===1&&(r.arguments.openParenthesis=void 0,r.arguments.closeParenthesis=void 0),e.push(r)}s<e.length&&(e[s].leadingComments=[{multiLine:!1,text:`Masterbar ${t.index+1} Metadata`}])}static _buildStructuralMetaDataNodes(e,t,s,i,r){if((e===void 0||e.index===0)&&(r===0&&(t.index===0&&s.push(Z._buildNewTrackNode(t.track)),s.push(Z._buildNewStaffNode(t)),Z._buildStaffMetaDataNodes(s,t)),i)){const n=_.meta("voice");n.trailingComments=[{multiLine:!0,text:`Voice ${r+1}`}],s.push(n)}}static _buildNewStaffNode(e){const t=_.meta("staff",void 0,_.props([e.showStandardNotation?["score",_.args([e.standardNotationLineCount!==Oi.DefaultStandardNotationLineCount?_.number(e.standardNotationLineCount):void 0])]:void 0,e.showTablature?["tabs",void 0]:void 0,e.showSlash?["slash",void 0]:void 0,e.showNumbered?["numbered",void 0]:void 0]));return t.properties&&t.properties.properties.length>0&&(t.properties.properties[0].leadingComments=[{multiLine:!1,text:"Staff Properties"}]),t}static _buildNewTrackNode(e){const t=_.meta("track",_.args([_.string(e.name),e.shortName.length>0?_.string(e.shortName):void 0]),_.props([e.color.rgba!==Z._defaultTrack.color.rgba?["color",_.stringValue(e.color.rgba)]:void 0,e.defaultSystemsLayout!==Z._defaultTrack.defaultSystemsLayout?["defaultSystemsLayout",_.numberValue(e.defaultSystemsLayout)]:void 0,e.systemsLayout.length?["systemsLayout",_.args(e.systemsLayout.map(s=>_.number(s)))]:void 0,["volume",_.numberValue(e.playbackInfo.volume)],["balance",_.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",_.identValue(e.isPercussion?"percussion":Ss.getName(e.playbackInfo.program))],e.playbackInfo.bank>0?["bank",_.numberValue(e.playbackInfo.bank)]:void 0]));return t.properties&&t.properties.properties.length>0&&(t.properties.properties[0].leadingComments=[{multiLine:!1,text:"Track Properties"}]),t}buildNoteEffects(e){const t=[];if(e.hasBend){const i=_.args([_.ident(V.bendTypeReversed.get(e.bendType)),e.bendStyle!==Ke.Default?_.ident(V.bendStyleReversed.get(e.bendStyle)):void 0],!0);for(const r of e.bendPoints)i.arguments.push(_.number(r.offset)),i.arguments.push(_.number(r.value));_.prop(t,"be",i)}let s="";
5switch(e.harmonicType){case te.Natural:_.prop(t,"nh");break;case te.Artificial:s="ah";break;case te.Pinch:s="ph";break;case te.Tap:s="th";break;case te.Semi:s="sh";break;case te.Feedback:s="fh";break}switch(s&&_.prop(t,s,_.numberValue(e.harmonicValue)),e.showStringNumber&&_.prop(t,"string"),e.isTrill&&_.prop(t,"tr",_.args([_.number(e.trillFret),_.number(e.trillSpeed)])),e.vibrato){case Be.Slight:_.prop(t,"v");break;case Be.Wide:_.prop(t,"vw");break}switch(e.slideInType){case St.IntoFromBelow:_.prop(t,"sib");break;case St.IntoFromAbove:_.prop(t,"sia");break}switch(e.slideOutType){case he.Shift:_.prop(t,"ss");break;case he.Legato:_.prop(t,"sl");break;case he.OutUp:_.prop(t,"sou");break;case he.OutDown:_.prop(t,"sod");break;case he.PickSlideDown:_.prop(t,"psd");break;case he.PickSlideUp:_.prop(t,"psu");break}switch(e.isHammerPullOrigin&&_.prop(t,"h"),e.isLeftHandTapped&&_.prop(t,"lht"),e.isGhost&&_.prop(t,"g"),e.accentuated){case ct.Normal:_.prop(t,"ac");break;case ct.Heavy:_.prop(t,"hac");break;case ct.Tenuto:_.prop(t,"ten");break}if(e.isPalmMute&&_.prop(t,"pm"),e.isStaccato&&_.prop(t,"st"),e.isLetRing&&_.prop(t,"lr"),e.isDead&&_.prop(t,"x"),e.isTieDestination&&_.prop(t,"t"),e.leftHandFinger>=ie.Thumb&&_.prop(t,"lf",_.numberValue(e.leftHandFinger+1)),e.rightHandFinger>=ie.Thumb&&_.prop(t,"rf",_.numberValue(e.rightHandFinger+1)),e.isVisible||_.prop(t,"hide"),e.isSlurOrigin){const i=`s${e.id}`;_.prop(t,"slur",_.identValue(i))}if(e.isSlurDestination){const i=`s${e.slurOrigin.id}`;_.prop(t,"slur",_.identValue(i))}
5switch(e.accidentalMode!==oe.Default&&_.prop(t,"acc",_.identValue(L.reverseAccidentalModeMapping.get(e.accidentalMode))),e.ornament){case ot.InvertedTurn:_.prop(t,"iturn");break;case ot.Turn:_.prop(t,"turn");break;case ot.UpperMordent:_.prop(t,"umordent");break;case ot.LowerMordent:_.prop(t,"lmordent");break}return t}buildBeatEffects(e){const t=[];switch(e.fade){case yt.FadeIn:_.prop(t,"f");break;case yt.FadeOut:_.prop(t,"fo");break;case yt.VolumeSwell:_.prop(t,"vs");break}if(e.vibrato===Be.Slight?_.prop(t,"v"):e.vibrato===Be.Wide&&_.prop(t,"vw"),e.slap&&_.prop(t,"s"),e.pop&&_.prop(t,"p"),e.tap&&_.prop(t,"tt"),e.dots>=2?_.prop(t,"dd"):e.dots>0&&_.prop(t,"d"),e.pickStroke===Ct.Up?_.prop(t,"su"):e.pickStroke===Ct.Down&&_.prop(t,"sd"),e.hasTuplet&&_.prop(t,"tu",_.args([_.number(e.tupletNumerator),_.number(e.tupletDenominator)])),e.hasWhammyBar){const n=_.args([_.ident(V.whammyTypeReversed.get(e.whammyBarType)),_.ident(V.bendStyleReversed.get(e.whammyStyle))],!0);for(const o of e.whammyBarPoints)n.arguments.push(_.number(o.offset)),n.arguments.push(_.number(o.value));_.prop(t,"tbe",n)}let s="";switch(e.brushType){case z.BrushUp:s="bu";break;case z.BrushDown:s="bd";break;case z.ArpeggioUp:s="au";break;case z.ArpeggioDown:s="ad";break}if(s&&_.prop(t,s,_.numberValue(e.brushDuration)),e.chord!=null&&_.prop(t,"ch",_.stringValue(e.chord.name)),e.ottava!==le.Regular&&_.prop(t,"ot",_.identValue(V.ottaviaReversed.get(e.ottava))),e.hasRasgueado&&_.prop(t,"rasg",_.identValue(V.rasgueadoReversed.get(e.rasgueado))),e.text!=null&&_.prop(t,"txt",_.stringValue(e.text)),e.lyrics!=null&&e.lyrics.length>0)if(e.lyrics.length>1)for(let n=0;n<e.lyrics.length;n++)_.prop(t,"lyrics",_.args([_.number(n),_.string(e.lyrics[n])]));else _.prop(t,"lyrics",_.stringValue(e.lyrics[0]));if(e.graceType!==K.None&&_.prop(t,"gr",e.graceType===K.BeforeBeat?void 0:_.identValue(V.graceTypeReversed.get(e.graceType))),e.isTremolo){const n=[_.number(e.tremoloPicking.marks)];e.tremoloPicking.style!==wi.Default&&n.push(_.ident(wi[e.tremoloPicking.style])),_.prop(t,"tp",_.args(n))}switch(e.crescendo){case Gt.Crescendo:_.prop(t,"cre");break;case Gt.Decrescendo:_.prop(t,"dec");break}(e.voice.bar.index===0&&e.index===0||e.dynamics!==e.previousBeat?.dynamics)&&_.prop(t,"dy",_.identValue(V.dynamicValueReversed.get(e.dynamics))),e.fermata!=null&&_.prop(t,"fermata",_.args([_.ident(V.fermataTypeReversed.get(e.fermata.type)),_.number(e.fermata.length)])),e.isLegatoOrigin&&_.prop(t,"legatoorigin");for(const n of e.automations)switch(n.type){case Re.Tempo:_.prop(t,"tempo",_.args([_.number(n.value),n.text.length===0?void 0:_.string(n.text)]));break;case Re.Volume:_.prop(t,"volume",_.numberValue(n.value));break;case Re.Instrument:e.voice.bar.staff.isPercussion||_.prop(t,"instrument",_.identValue(Ss.getName(n.value)));break;case Re.Balance:_.prop(t,"balance",_.numberValue(n.value));break}switch(e.wahPedal){case ss.Open:_.prop(t,"waho");break;case ss.Closed:_.prop(t,"wahc");break}switch(e.isBarre&&_.prop(t,"barre",_.args([_.number(e.barreFret),_.ident(V.barreShapeReversed.get(e.barreShape))])),e.slashed&&_.prop(t,"slashed"),e.deadSlapped&&_.prop(t,"ds"),e.golpe){case Xt.Thumb:_.prop(t,"glpt");break;case Xt.Finger:_.prop(t,"glpf");break}e.invertBeamDirection?_.prop(t,"beam",_.identValue("invert")):e.preferredBeamDirection!==null&&_.prop(t,"beam",_.identValue(P[e.preferredBeamDirection]));let r="";switch(e.beamingMode){case st.ForceSplitToNext:r="split";break;case st.ForceMergeWithNext:r="merge";break;case st.ForceSplitOnSecondaryToNext:r="splitsecondary";break}return r&&_.prop(t,"beam",_.identValue(r)),e.showTimer&&_.prop(t,"timer"),t}}class sr{data;settings;init(e,t){this.data=e,this.settings=t,Ks.resetIds()}}class Bt extends Ye{constructor(e=null,t){super(Ge.Format,e??"Unsupported format",t)}}class gt{_buffer;length=0;position=0;get bytesWritten(){return this.position}getBuffer(){return this._buffer}static empty(){return gt.withCapacity(0)}static withCapacity(e){const t=new gt;return t._buffer=new Uint8Array(e),t}static fromBuffer(e){const t=new gt;return t._buffer=e,t.length=e.length,t}static fromString(e){const t=k.stringToBytes(e);return gt.fromBuffer(t)}reset(){this.position=0}skip(e){this.position+=e}readByte(){return this.length-this.position<=0?-1:this._buffer[this.position++]}read(e,t,s){let i=this.length-this.position;return i>s&&(i=s),i<=0?0:(e.set(this._buffer.subarray(this.position,this.position+i),t),this.position+=i,i)}writeByte(e){const t=this.position+1;this._ensureCapacity(t),this._buffer[this.position]=e&255,t>this.length&&(this.length=t),this.position=t}
vendor: 5,260 bytes, lines 5-7
5write(e,t,s){const i=this.position+s;this._ensureCapacity(i);const r=Math.min(s,e.length-t);this._buffer.set(e.subarray(t,t+r),this.position),i>this.length&&(this.length=i),this.position=i}_ensureCapacity(e){if(e>this._buffer.length){let t=e;t<256&&(t=256),t<this._buffer.length*2&&(t=this._buffer.length*2);const s=new Uint8Array(t);this.length>0&&s.set(this._buffer.subarray(0,0+this.length),0),this._buffer=s}}readAll(){return this.toArray()}toArray(){const e=new Uint8Array(this.length);return e.set(this._buffer.subarray(0,0+this.length),0),e}copyTo(e){e.write(this._buffer,0,this.length)}}class Di extends Ye{lexerDiagnostics;parserDiagnostics;semanticDiagnostics;*iterateDiagnostics(){if(this.lexerDiagnostics)for(const e of this.lexerDiagnostics.items)yield e;if(this.parserDiagnostics)for(const e of this.parserDiagnostics.items)yield e;if(this.semanticDiagnostics)for(const e of this.semanticDiagnostics.items)yield e}constructor(e,t,s,i){super(Ge.AlphaTex,e),this.lexerDiagnostics=t,this.parserDiagnostics=s,this.semanticDiagnostics=i}toString(){return[this.message,"lexer diagnostics:",Di._diagnosticsToString(this.lexerDiagnostics,"  "),"parser diagnostics:",Di._diagnosticsToString(this.parserDiagnostics,"  "),"semantic diagnostics:",Di._diagnosticsToString(this.semanticDiagnostics,"  ")].join(`
6`)}static _diagnosticsToString(e,t){return e?e.items.map(s=>`${t}${ce[s.severity]} AT${s.code.toString().padStart(3,"0")}${Di._locationToString(s)}: ${s.message}`).join(`
7`):`${t}none`}static _locationToString(e){let t="";return e.start&&(t+=`(${e.start.line},${e.start.col})`),e.end&&(t.length>0&&(t+="->"),t+=`(${e.end.line},${e.end.col})`),t}}class Qo{trackChannel=0;score;currentTrack;currentStaff;barIndex=0;voiceIndex=0;ignoredInitialVoice=!1;ignoredInitialStaff=!1;ignoredInitialTrack=!1;currentDuration=y.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=se.F;accidentalMode=Kr.Explicit;voiceMode=ri.StaffWise;currentTupletNumerator=-1;currentTupletDenominator=-1;scoreNode}class gn extends sr{_parser;_handler=Z.instance;_state=new Qo;get state(){return this._state}get scoreNode(){return this._state.scoreNode}get name(){return"AlphaTex"}get lexerDiagnostics(){return this._parser.lexerDiagnostics}get parserDiagnostics(){return this._parser.parserDiagnostics}get parser(){return this._parser}get parseMode(){return this._parser.mode}logErrors=!1;semanticDiagnostics=new pn;addSemanticDiagnostic(e){this.semanticDiagnostics.push(e)}initFromString(e,t){this.data=gt.empty(),this._parser=new Zr(e),this.settings=t,Ks.resetIds()}readScore(){this._state=new Qo,this._createDefaultScore(),this.data.length>0&&(this._parser=new Zr(k.toString(this.data.readAll(),this.settings.importer.encoding)));let e;try{e=this._parser.read(),this._state.scoreNode=e}catch(t){throw this.logErrors&&E.error("AlphaTex",`Error while parsing alphaTex: ${t.toString()}`),new Bt("Error parsing alphaTex, check inner error for details",t)}if(this._parser.parserDiagnostics.hasErrors||this._parser.lexer.lexerDiagnostics.hasErrors){const t=new Di("There are errors in the parsed alphaTex, check the diagnostics for details",this.lexerDiagnostics,this.parserDiagnostics,this.semanticDiagnostics);throw this.logErrors&&E.error("AlphaTex",`Error while parsing alphaTex: ${t.toString()}`),new Bt("Error parsing alphaTex, check diagnostics on inner error for details",t)}if(this._bars(e),this.semanticDiagnostics.hasErrors)if(this._state.hasAnyProperData){const t=new Di("There are errors in the parsed alphaTex, check the diagnostics for details",this.lexerDiagnostics,this.parserDiagnostics,this.semanticDiagnostics);throw this.logErrors&&E.error("AlphaTex",`Error while parsing alphaTex: ${t.toString()}`),t}else throw new Bt("No alphaTex data found");L.consolidate(this._state.score),this._state.score.finish(this.settings),L.trimEmptyBarsAtEnd(this._state.score),this._state.score.rebuildRepeatGroups(),this._state.score.applyFlatSyncPoints(this._state.syncPoints);for(const[t,s]of this._state.lyrics)this._state.score.tracks[t].applyLyrics(s);for(const[t,s]of this._state.sustainPedalToBeat)if(t.ratioPosition<1){const i=s.voice.bar.masterBar.calculateDuration();t.ratioPosition=s.playbackStart/i}return this._state.score}_createDefaultScore(){this._state.score=new Ks,this._newTrack()}_newTrack(){this._state.currentTrack=new Zs,this._state.currentTrack.ensureStaveCount(1),this._state.currentTrack.playbackInfo.program=25,this._state.currentTrack.playbackInfo.primaryChannel=this._state.trackChannel++,this._state.currentTrack.playbackInfo.secondaryChannel=this._state.trackChannel++;const e=this._state.currentTrack.staves[0];e.displayTranspositionPitch=0,e.stringTuning=I.getDefaultTuningFor(6),this._state.articulationUniqueIdToIndex.clear(),this._beginStaff(e),this._state.score.addTrack(this._state.currentTrack),this._state.lyrics.set(this._state.currentTrack.index,[]),this._state.currentDynamics=se.F,this._state.currentTupletDe
7nominator=-1,this._state.currentTupletNumerator=-1}_beginStaff(e){this._state.currentStaff&&(this._detectTuningForStaff(this._state.currentStaff),this._handleTransposition(this._state.currentStaff)),this._state.currentStaff=e,this._state.slurs.clear(),this._state.barIndex=0,this._state.voiceIndex=0}_bars(e){if(e.bars.length>0){let t=!1;for(const s of e.bars)switch(this._bar(s,t),this.state.voiceMode){case ri.StaffWise:this._state.barIndex++,t=!0;break;case ri.BarWise:s.pipe&&(this._state.barIndex++,this._state.voiceIndex=0,this._state.ignoredInitialVoice=!1,t=!0);break}}else this._getBar(this._state.currentStaff),this._detectTuningForStaff(this._state.currentStaff),this._handleTransposition(this._state.currentStaff)}_bar(e,t){const s=this._barMeta(e,t);this._detectTuningForStaff(this._state.currentStaff),this._handleTransposition(this._state.currentStaff),s.index===0&&this._state.staffInitialClef.has(this._state.currentStaff)&&(s.clef=this._state.staffInitialClef.get(this._state.currentStaff));const i=s.voices[this._state.voiceIndex];for(const r of e.beats)this._beat(i,r);if(i.beats.length===0){const r=new Dt;r.isEmpty=!0,i.addBeat(r)}}_beat(e,t){if(t.durationChange&&this._beatDuration(t.durationChange),!t.notes&&!t.rest)return;const s=new Dt;if(e.addBeat(s),t.notes)for(const r of t.notes.notes)this._note(s,r);else t.rest;t.durationValue&&(this._state.currentDuration=this._parseDuration(t.durationValue)),s.duration=this._state.currentDuration,s.dynamics=this._state.currentDynamics,this._state.currentTupletNumerator!==-1&&!s.hasTuplet&&(s.tupletNumerator=this._state.currentTupletNumerator,s.tupletDenominator=this._state.currentTupletDenominator);let i=1;t.beatMultiplierValue!==void 0&&(i=t.beatMultiplierValue.value),t.beatEffects&&this._beatEffects(s,t.beatEffects);for(let r=0;r<i-1;r++)e.addBeat(Zn.clone(s))}_beatEffects(e,t){for(const s of t.properties)switch(this._handler.applyBeatProperty(this,e,s)){case w.Applied:case w.NotAp
7pliedSemanticError:this._state.hasAnyProperData=!0;break;case w.NotAppliedUnrecognizedMarker:const r=Array.from(this._handler.knownBeatProperties).join(",");this.addSemanticDiagnostic({code:fe.AT212,message:`Unrecogized property '${s.property.text}', expected one of ${r}`,severity:ce.Error,start:s.start,end:s.end});break}}_beatDuration(e){if(e.value&&(this._state.currentDuration=this._parseDuration(e.value)),this._state.currentTupletNumerator=-1,this._state.currentTupletDenominator=-1,e.properties)for(const t of e.properties.properties)switch(this._handler.applyBeatDurationProperty(this,t)){case w.Applied:case w.NotAppliedSemanticError:this._state.hasAnyProperData=!0;break;case w.NotAppliedUnrecognizedMarker:const i=Array.from(this._handler.knownBeatDurationProperties).join(",");this.addSemanticDiagnostic({code:fe.AT212,message:`Unrecogized property '${t.property.text}', expected one of ${i}`,severity:ce.Error,start:t.start,end:t.end});break}}_parseDuration(e){switch(e.value){case-4:return y.QuadrupleWhole;case-2:return y.DoubleWhole;case 1:return y.Whole;case 2:return y.Half;case 4:return y.Quarter;case 8:return y.Eighth;case 16:return y.Sixteenth;case 32:return y.ThirtySecond;case 64:return y.SixtyFourth;case 128:return y.OneHundredTwentyEighth;case 256:return y.TwoHundredFiftySixth;default:return this.addSemanticDiagnostic({code:fe.AT209,message:`Unexpected duration value '${e.value}', expected: -4, -2, 1, 2, 4, 8, 16, 32, 64, 128 or 256`,severity:ce.Error,start:e.start,end:e.end}),this._state.currentDuration}}_note(e,t){let s=!1,i=!1,r=-1,n="",o=-1,l=-1,h=oe.Default;const c=t.noteValue;let d,f=this._state.staffNoteKind.has(this._state.currentStaff)?this._state.staffNoteKind.get(this._state.currentStaff):void 0;switch(c.nodeType){case x.Number:r=c.value,t.noteString!==void 0?d=Jt.Fretted:d=Jt.Articulation;break;case x.String:case x.Ident:const g=c.text;if(s=g==="x",i=g==="-",i||s)r=0,t.noteStringDot&&t.noteString?d=Jt.Fretted:d=void 0;else{const m=L.parseTuning(g);if(m)d=Jt.Pitched,o=m.octave,l=m.tone.noteValue,this._state.accidentalMode===Kr.Explicit&&(h=m.tone.accidentalMode);else{d=Jt.Articulation;const b=g.toLowerCase(),S=this._state.percussionArticulationNames;if(f===void 0&&S.size===0)for(const[N,v]of Xe.instrumentArticulationNames)Xe.getInstrumentArticulationByUniqueId(v)&&(S.set(N.toLowerCase(),v),S.set(L.toArticulationId(N),v));if(S.has(b))n=S.get(b);else{this.addSemanticDiagnostic({code:fe.AT209,message:`Unexpected percussion articulation value '${b}', expected: oneOf(${Array.from(this._state.percussionArticulationNames.keys()).join(",")}).`,severity:ce.Error,start:c.start,end:c.end}),n=Array.from(Xe.instrumentArticulationNames.values())[0];return}}}break}d!==void 0?f===void 0?(f=d,this.applyStaffNoteKind(this._state.currentStaff,f)):f!==d&&this.addSemanticDiagnostic({code:fe.AT218,message:`Wrong note kind '${Jt[d]}' for staff with note kind ''${Jt[f]}'. Do not mix incompatible staves and notes.`,severity:ce.Error,start:c.start,end:c.end}):f!==void 0&&(d=f);const p=new kt;if(p.isDead=s,(s||i)&&(p.fret=r),p.isTieDestination=i,d!==void 0&&d===f)switch(d){case Jt.Pitched:p.octave=o,p.tone=l,p.accidentalMode=h;break;case Jt.Fretted:if(!t.noteString){this.addSemanticDiagnostic({code:fe.AT207,message:"Missing string for fretted note.",severity:ce.Error,start:c.end,end:c.end});return}const g=t.noteString.value;if(g<1||g>this._state.currentStaff.tuning.length){this.addSemanticDiagnostic({code:fe.AT208,message:`Note string is out of range. Available range: 1-${this._state.currentStaff.tuning.length}`,severity:ce.Error,start:c.end,end:c.end});return}p.string=this._state.currentStaff.tuning.length-(g-1),i||(p.fret=r);break;case Jt.Articulation:let m=0;if(n.length===0&&r>0){const b=Xe.getArticulationById(r);b&&(n=b.uniqueId)}if(this._state.articulationUniqueIdToIndex.has(n))m=this._state.articulationUniqueIdToIndex.get(n);else{m=this._state.currentTrack.percussionArticulations.length;const b=Xe.getInstrumentArticulationByUniqueId(n);if(b===null){this.addSemanticDiagnostic({code:fe.AT209,message:`Unexpected articulation value '${r}', expected: oneOf(${Array.from(Xe.instrumentArticulations.keys()).join(",")}).`,severity:ce.Error,start:c.end,end:c.end});return}this._state.currentTrack.percussionArticulations.push(b),this._state.articulationUniqueIdToIndex.set(n,m)}p.percussionArticulation=m;break}e.addNote(p),this._state.hasAnyProperData=!0,t.noteEffects&&this._noteEffects(p,t.noteEffects)}getStaffNoteKind(e){return this._state.staffNoteKind.has(e)?this._state.staffNoteKind.get(e):void 0}applyStaffNoteKind(e,t){switch(this._state.staffNoteKind.set(e,t),t){case Jt.Pit
vendor: 5,036 bytes, line 7
7ched:e.isPercussion=!1,e.stringTuning.reset(),this._state.staffHasExplicitDisplayTransposition.has(e)||(e.displayTranspositionPitch=0);break;case Jt.Fretted:e.isPercussion=!1,this._detectTuningForStaff(e),this._handleTransposition(e);break;case Jt.Articulation:e.isPercussion=!0,e.stringTuning.reset(),this._state.staffHasExplicitDisplayTransposition.has(e)||(e.displayTranspositionPitch=0);break}}_noteEffects(e,t){for(const s of t.properties){let i=this._handler.applyNoteProperty(this,e,s);switch(i===w.NotAppliedUnrecognizedMarker&&(i=this._handler.applyBeatProperty(this,e.beat,s)),i){case w.Applied:case w.NotAppliedSemanticError:break;case w.NotAppliedUnrecognizedMarker:const r=Array.from(this._handler.knownNoteProperties).concat(Array.from(this._handler.knownBeatProperties)).join(",");this.addSemanticDiagnostic({code:fe.AT212,message:`Unrecogized property '${s.property.text}', expected one of ${r}`,severity:ce.Error,start:s.start,end:s.end});break}}}_handleTransposition(e){if(!this._state.staffDisplayTranspositionApplied.has(e)&&!this._state.staffHasExplicitDisplayTransposition.has(e)){const t=e.track.playbackInfo.program;L.displayTranspositionPitches.has(t)?e.displayTranspositionPitch=L.displayTranspositionPitches.get(t):this._state.currentStaff.displayTranspositionPitch=0,this._state.staffDisplayTranspositionApplied.add(e)}}_detectTuningForStaff(e){const t=e.track.playbackInfo.program;!this._state.staffTuningApplied.has(e)&&!this._state.staffHasExplicitTuning.has(e)&&(e.stringTuning.reset(),t===15||t>=24&&t<=31?e.stringTuning.tunings=I.getDefaultTuningFor(6).tunings:t>=32&&t<=39?(e.stringTuning.tunings=[43,38,33,28],this._state.staffInitialClef.set(e,ve.F4)):t===40||t===44||t===45||t===48||t===49||t===50||t===51?e.stringTuning.tunings=[52,57,50,43]:t===41?e.stringTuning.tunings=[57,50,43,36]:t===42?e.stringTuning.tunings=[45,38,31,24]:t===43?e.stringTuning.tunings=[43,38,33,28]:t===105?e.stringTuning.tunings=[50,47,43,38,55]:t===106?e.stringTuning.tunings=[57,52,45]:t===107?e.stringTuning.tunings=[52,45,38,31]:t===110?e.stringTuning.tunings=[64,57,50,43]:this._state.staffNoteKind.has(e)&&this._state.staffNoteKind.get(e)===Jt.Fretted&&(e.stringTuning=I.getDefaultTuningFor(6)),this._state.staffTuningApplied.add(e))}_barMeta(e,t){let s=this._state.score.masterBars.length>0?void 0:[],i=this._state.currentStaff,r=!1,n=!1,o=!1,l=!1;const h=()=>{s&&(s=void 0,i=this._state.currentStaff,r=!1,n=!1,o=!1,l=!1)},c=new mr(()=>{!o&&!t&&this._state.barIndex++;const d=this._getBar(this._state.currentStaff);if(s){for(const f of s)this._handler.applyBarMetaData(this,d,f);h()}return d});for(const d of e.metaData){const f=d.tag.tag.text.toLowerCase();if(this._handler.knownStructuralMetaDataTags.has(f)){switch(this._state.hasAnyProperData=!0,this._handler.applyStructuralMetaData(this,d)){case Gs.AppliedNewTrack:n||r?l=!0:(r=!0,i=this._state.currentStaff),c.reset();break;case Gs.AppliedNewStaff:n?l=!0:(n=!0,i=this._state.currentStaff),c.reset();break;case Gs.AppliedNewVoice:o=!0;break}if(s&&l)if(i.bars.length===0){const g=new ns;i.addBar(g);const m=new ks;if(g.addVoice(m),i.bars.length>this._state.score.masterBars.length){const b=new Qs;this._state.score.addMasterBar(b)}for(const b of s)this._handler.applyBarMetaData(this,g,b);h()}else throw new Ye(Ge.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.")}else if(this._handler.knownScoreMetaDataTags.has(d.tag.tag.text.toLowerCase()))this._state.hasAnyProperData=!0,this._handler.applyScoreMetaData(this,this._state.score,d);else if(this._handler.knownStaffMetaDataTags.has(d.tag.tag.text.toLowerCase()))this._state.hasAnyProperData=!0,this._handler.applyStaffMetaData(this,this._state.currentStaff,d);else if(this._handler.knownBarMetaDataTags.has(d.tag.tag.text.toLowerCase()))this._state.hasAnyProperData=!0,s?s.push(d):this._handler.applyBarMetaData(this,c.value,d);else{const p=Array.from(this._handler.allKnownMetaDataTags).join(",");this.addSemanticDiagnostic({code:fe.AT204,message:`Unrecognized metadata '${d.tag.tag.text}', expected one of: ${p}`,severity:ce.Error,start:d.tag.start,end:d.tag.end})}}return c.value}_getBar(e){if(this._state.barIndex<e.bars.length)return e.bars[this._state.barIndex];const t=e.bars.length===0?this._state.voiceIndex+1:e.bars[0].voices.length,s=new ns;e.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._state.barIndex=s.index,s.index>0&&(s.clef=s.previousBar.clef);for(let i=0;i<t;i++){const r=new ks;s.addVoice(r)}if(this._state.currentStaff.bars.length>this._state.score.masterBars.length){const i=new Qs;this._state.score.addMasterBar(i),i.index>0&&(i.timeSignatureDenominator=i.previousMasterBar.timeSignatureDenominator,i.timeSignatureNumerator=i.previousMasterBar.timeSignatureNumerator,i.tripletFeel=i.previousMasterBar.tripletFeel)}return s}
7startNewStaff(){if(this._state.ignoredInitialVoice=!1,this._state.ignoredInitialStaff||this._state.currentTrack.staves[0].bars.length>0){const e=this._state.currentStaff.isPercussion;this._state.currentTrack.ensureStaveCount(this._state.currentTrack.staves.length+1);const t=this._state.currentTrack.staves[this._state.currentTrack.staves.length-1];this._beginStaff(t),e&&this.applyPercussionStaff(this._state.currentStaff),this._state.currentDynamics=se.F}else this._state.ignoredInitialStaff=!0;return this._state.currentStaff}applyPercussionStaff(e){e.isPercussion=!0,e.showTablature=!1,e.track.playbackInfo.program=0}startNewTrack(){return this._state.ignoredInitialVoice=!1,this._state.ignoredInitialStaff=!1,this._state.ignoredInitialTrack||this._state.score.masterBars.length>0?this._newTrack():this._state.ignoredInitialTrack=!0,this._state.currentTrack}startNewVoice(){let e=this._state.voiceIndex===0&&!this._state.ignoredInitialVoice;if(e)if(this._state.currentStaff.bars.length===0)e=!0;else switch(this._state.voiceMode){case ri.StaffWise:e=this._state.currentStaff.bars.length===1&&this._state.currentStaff.bars[0].isEmpty;break;case ri.BarWise:this._state.barIndex<this._state.currentStaff.bars.length?e=this._state.currentStaff.bars[this._state.barIndex].voices[0].isEmpty:e=!0;break}if(e){this._state.ignoredInitialVoice=!0;return}switch(this._state.voiceMode){case ri.StaffWise:this._state.voiceIndex++,this._state.barIndex=0,this._state.currentTupletDenominator=-1,this._state.currentTupletNumerator=-1;break;case ri.BarWise:this._state.voiceIndex++,this._state.currentTupletDenominator=-1,this._state.currentTupletNumerator=-1;break}for(const t of this._state.currentStaff.bars)for(;t.voices.length<=this._state.voiceIndex;)t.addVoice(new ks)}}let eo=class{};class ga extends eo{n;constructor(e){super(),this.n=e}}class Vi extends eo{left;right;constructor(e,t){super(),this.left=e,this.right=t}}class Wn extends eo{n;table;constructor(e,t){super(),this.n=e,this.table=t}}class Yt{static make(e,t,s,i){const r=[],n=[];if(i>32)throw new zt("Invalid huffman");for(let h=0;h<i;h++)r.push(0),n.push(0);for(let h=0;h<s;h++){const c=e[h+t];if(c>=i)throw new zt("Invalid huffman");r[c]++}let o=0;for(let h=1;h<i-1;h++)o=o+r[h]<<1,n[h]=o;const l=new Map;for(let h=0;h<s;h++){const c=e[h+t];if(c!==0){const d=n[c-1];n[c-1]=d+1,l.set(d<<5|c,h)}}return Yt._treeCompress(new Vi(Yt._treeMake(l,i,0,1),Yt._treeMake(l,i,1,1)))}static _treeMake(e,t,s,i){if(i>t)throw new zt("Invalid huffman");const r=s<<5|i;return e.has(r)?new ga(e.get(r)):(s=s<<1,i+=1,new Vi(Yt._treeMake(e,t,s,i),Yt._treeMake(e,t,s|1,i)))}static _treeCompress(e){const t=Yt._treeDepth(e);if(t===0)return e;if(t===1){if(e instanceof Vi)return new Vi(Yt._treeCompress(e.left),Yt._treeCompress(e.right));throw new zt("assert")}const s=1<<t,i=[];for(let r=0;r<s;r++)i.push(new ga(-1));return Yt._treeWalk(i,0,0,t,e),new Wn(t,i)}static _treeWalk(e,t,s,i,r){r instanceof Vi&&i>0?(Yt._treeWalk(e,t,s+1,i-1,r.left),Yt._treeWalk(e,t|1<<s,s+1,i-1,r.right)):e[t]=Yt._treeCompress(r)}static _treeDepth(e){if(e instanceof ga)return 0;if(e instanceof Wn)throw new zt("assert");if(e instanceof Vi){const t=Yt._treeDepth(e.left),s=Yt._treeDepth(e.right);return 1+(t<s?t:s)}return 0}}var Et;(function(a){a[a.Head=0]="Head",a[a.Block=1]="Block",a[a.CData=2]="CData",a[a.Flat=3]="Flat",a[a.Crc=4]="Crc",a[a.Dist=5]="Dist",a[a.DistOne=6]="DistOne",a[a.Done=7]="Done"})(Et||(Et={}));class fi{static _size=32768;static _bufferSize=65536;buffer=new Uint8Array(fi._bufferSize);pos=0;slide(){const e=new Uint8Array(fi._bufferSize);this.pos-=fi._size,e.set(this.buffer.subarray(fi._size,fi._size+this.pos),0),this.buffer=e}addBytes(e,t,s){this.pos+s>fi._bufferSize&&this.slide(),this.buffer.set(e.subarray(t,t+s),this.pos),this.pos+=s}addByte(e){this.pos===fi._bufferSize&&this.slide(),this.buffer[this.pos]=e,this.pos++}getLastChar(){return this.buffer[this.pos-1]}available(){return this.pos}}class Vs{static _lenExtraBitsTbl=[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 _lenBaseValTbl=[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 _distExtraBitsTbl=[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 _distBaseValTbl=[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 _codeLengthsPos=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];static _fixedHuffman=Vs._buildFixedHuffman();static _buildFixedHuffman(){const e=[];for(let t=0;t<288;t++)e.push(t<=143?8:t<=255?9:t<=279?7:8);return Yt.make(e,0,288,10)}_nbits=0;_bits=0;_state=Et.Block;_isFinal=!1;_huffman=Vs._fixedHuffman;_huffdist=null;_len=0;_dist=0;_needed=0;_output=null;_outpos=0;_input;_lengths=[];_window=new fi;constructor(e){this._input=e;for(let t=0;t<19;t++)this._lengths.push(-1)}readBytes(e,t,s){if(this._needed=s,this._outpos=t,this._output=e,s>0)for(;this._inflateLoop(););return s-this._needed}_inflateLoop(){switch(this._state){case Et.Head:const e=this._input.readByte();if((e&15)!==8)throw new zt("Invalid data");const s=this._input.readByte(),i=(s&32)!==0;if(((e<<8)+s)%31!==0)throw new zt("Invalid data");if(i)throw new zt("Unsupported dictionary");return this._state=Et.Block,!0;case Et.Crc:return this._state=Et.Done,!0;case Et.Done:return!1;case Et.Block:switch(this._isFinal=this._getBit(),this._getBits(2)){case 0:if(this._len=k.readUInt16LE(this._input),k.readUInt16LE(this._input)!==65535-this._len)throw new zt("Invalid data");this._state=Et.Flat;const c=this._inflateLoop();return this._resetBits(),c;case 1:return this._huffman=Vs._fixedHuffman,this._huffdist=null,this._state=Et.CData,!0;case 2:const d=this._getBits(5)+257,f=this._getBits(5)+1,p=this._getBits(4)+4;for(let m=0;m<p;
7m++)this._lengths[Vs._codeLengthsPos[m]]=this._getBits(3);for(let m=p;m<19;m++)this._lengths[Vs._codeLengthsPos[m]]=0;this._huffman=Yt.make(this._lengths,0,19,8);const g=[];for(let m=0;m<d+f;m++)g.push(0);return this._inflateLengths(g,d+f),this._huffdist=Yt.make(g,d,f,16),this._huffman=Yt.make(g,0,d,16),this._state=Et.CData,!0;default:throw new zt("Invalid data")}case Et.Flat:{const h=this._len<this._needed?this._len:this._needed,c=k.readByteArray(this._input,h);return this._len-=h,this._addBytes(c,0,h),this._len===0&&(this._state=this._isFinal?Et.Crc:Et.Block),this._needed>0}case Et.DistOne:{const h=this._len<this._needed?this._len:this._needed;return this._addDistOne(h),this._len-=h,this._len===0&&(this._state=Et.CData),this._needed>0}case Et.Dist:for(;this._len>0&&this._needed>0;){const h=this._len<this._dist?this._len:this._dist,c=this._needed<h?this._needed:h;this._addDist(this._dist,c),this._len-=c}return this._len===0&&(this._state=Et.CData),this._needed>0;case Et.CData:let r=this._applyHuffman(this._huffman);if(r<256)return this._addByte(r),this._needed>0;if(r===256)return this._state=this._isFinal?Et.Crc:Et.Block,!0;r=r-257&255;let n=Vs._lenExtraBitsTbl[r];if(n===-1)throw new zt("Invalid data");this._len=Vs._lenBaseValTbl[r]+this._getBits(n);const o=this._huffdist,l=o?this._applyHuffman(o):this._getRevBits(5);if(n=Vs._distExtraBitsTbl[l],n===-1)throw new zt("Invalid data");if(this._dist=Vs._distBaseValTbl[l]+this._getBits(n),this._dist>this._window.available())throw new zt("Invalid data");return this._state=this._dist===1?Et.DistOne:Et.Dist,!0}return!1}_addDistOne(e){const t=this._window.getLastChar();for(let s=0;s<e;s++)this._addByte(t)}_addByte(e){this._window.addByte(e),this._output[this._outpos]=e,this._needed--,this._outpos++}_addDist(e,t){this._addBytes(this._window.buffer,this._window.pos-e,t)}_getBit(){this._nbits===0&&(this._nbits=8,this._bits=this._input.readByte());const e=(this._bits&1)===1;return this._nbits--,this._bits=this._bits>>1,e}_getBits(e){for(;this._nbits<e;)this._bits=this._bits|this._input.readByte()<<this._nbits,this._nbits+=8;const t=this._bits&(1<<e)-1;return this._nbits-=e,this._bits=this._bits>>e,t}_getRevBits(e){return e===0?0:this._getBit()?1<<e-1|this._getRevBits(e-1):this._getRevBits(e-1)}_resetBits(){this._bits=0,this._nbits=0}_addBytes(e,t,s){this._window.addBytes(e,t,s),this._output.set(e.subarray(t,t+s),this._outpos),this._needed-=s,this._outpos+=s}_inflateLengths(e,t){let s=0,i=0;for(;s<t;){const r=this._applyHuffman(this._huffman);switch(r){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=r,e[s]=r,s++;break;case 16:const n=s+3+this._getBits(2);if(n>t)throw new zt("Invalid data");for(;s<n;)e[s]=i,s++;break;case 17:if(s+=3+this._getBits(3),s>t)throw new zt("Invalid data");break;case 18:if(s+=11+this._getBits(7),s>t)throw new zt("Invalid data");break;default:throw new zt("Invalid data")}}}_applyHuffman(e){if(e instanceof ga)return e.n;if(e instanceof Vi)return this._applyHuffman(this._getBit()?e.right:e.left);if(e instanceof Wn)return this._applyHuffman(e.table[this._getBits(e.n)]);throw new zt("Invalid data")}}class cs{static OptionalDataDescriptorSignature=134695760;static CompressionMethodDeflate=8;static LocalFileHeaderSignature=67324752;static CentralFileHeaderSignature=33639248;static EndOfCentralDirSignature=101010256;fullName;fileName;data;constructor(e,t){this.fullName=e;const s=e.lastIndexOf("/");this.fileName=s===-1||s===e.length-1?this.fullName:e.substr(s+1),this.data=t}}class to{_readable;constructor(e){this._readable=e}read(){const e=[];for(;;){const t=this._readEntry();if(!t)break;e.push(t)}return e}_readEntry(){const e=this._readable;if(k.readInt32LE(e)!==cs.LocalFileHeaderSignature)return null;k.readUInt16LE(e);const s=k.readUInt16LE(e),i=k.readUInt16LE(e),r=i!==0;if(r&&i!==cs.CompressionMethodDeflate)return null;k.readInt16LE(this._readable),k.readInt16LE(this._readable),k.readInt32LE(e),k.readInt32LE(e);const n=k.readInt32LE(e),o=k.readInt16LE(e),l=k.readInt16LE(e),h=k.toString(k.readByteArray(e,o),"utf-8");e.skip(l);let c;if(r){const d=gt.empty(),f=new Vs(this._readable),p=new Uint8Array(65536);for(;;){const g=f.readBytes(p,0,p.length);if(d.write(p,0,g),g<p.length)break}c=d.toArray()}else c=k.readByteArray(this._readable,n);return(s&8)!==0&&(k.readInt32LE(this._readable)===cs.OptionalDataDescriptorSignature&&k.readInt32LE(this._readable),k.readInt32LE(this._readable),k.readInt32LE(this._readable)),new cs(h,c)}}var ht;(function(a){a[a.None=0]="None",a[a.Element=1]="Element",a[a.Text=2]="Text",a[a.CDATA=3]="CDATA",a[a.Document=4]="Document",a[a.DocumentType=5]="DocumentType",a[a.Comment=6]="Comment"})(ht||(ht={}));class As{nodeType=ht.None;localName=null;value=null;childNodes=[];attributes=new Map;firstChild=null;firstElement=null;*childElements(){for(const e of this.childNodes)e.nodeType===ht.Element&&(yield e)}addChild(e){this.childNodes.push(e),this.firstChild=e,(e.nodeType===ht.Element||e.nodeType===ht.CDATA)&&(this.firstElement=e)}getAttribute(e,t=""){return this.attributes.has(e)?this.attributes.get(e):t}getElementsByTagName(e,t=!1){const s=[];return this._searchElementsByTagName(this.childNodes,s,e,t),s}_searchElementsByTagName(e,t,s,i=!1){for(const r of e)r&&r.nodeType===ht.Element&&r.localName===s&&t.push(r),i&&this._searchElementsByTagName(r.childNodes,t,s,!0)}findChildElement(e){for(const t of this.childNodes)if(t&&t.nodeType===ht.Element&&t.localName===e)return t;return null}addElement(e){const t=new As;return t.nodeType=ht.Element,t.localName=e,this.addChild(t),t}get innerText(){if(this.nodeType===ht.Element||this.nodeType===ht.Document){if(this.firstElement&&this.firstElement.nodeType===ht.CDATA)return this.firstElement.innerText;let e="";for(const s of this.childNodes)e+=s.innerText?.toString();return e.trim()}return this.value??""}set innerText(e){const t=new As;t.nodeType=ht.Text,t.value=e,this.childNodes=[t]}setCData(e){const t=new As;
7t.nodeType=ht.CDATA,t.value=e,this.childNodes=[t]}}class Ns extends Ye{xml;pos=0;constructor(e,t,s){super(Ge.Format,e),this.xml=t,this.pos=s}}var pe;(function(a){a[a.IgnoreSpaces=0]="IgnoreSpaces",a[a.Begin=1]="Begin",a[a.BeginNode=2]="BeginNode",a[a.TagName=3]="TagName",a[a.Body=4]="Body",a[a.AttribName=5]="AttribName",a[a.Equals=6]="Equals",a[a.AttvalBegin=7]="AttvalBegin",a[a.AttribVal=8]="AttribVal",a[a.Childs=9]="Childs",a[a.Close=10]="Close",a[a.WaitEnd=11]="WaitEnd",a[a.WaitEndRet=12]="WaitEndRet",a[a.Pcdata=13]="Pcdata",a[a.Header=14]="Header",a[a.Comment=15]="Comment",a[a.Doctype=16]="Doctype",a[a.Cdata=17]="Cdata",a[a.Escape=18]="Escape"})(pe||(pe={}));class Te{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 _escapes=new Map([["lt","<"],["gt",">"],["amp","&"],["quot",'"'],["apos","'"]]);static parse(e,t,s){let i=e.charCodeAt(t),r=pe.Begin,n=pe.Begin,o=0,l="",h=pe.Begin,c=null,d=null,f=0,p=0;for(;t<e.length;){switch(i=e.charCodeAt(t),r){case pe.IgnoreSpaces:switch(i){case Te.CharCodeLF:case Te.CharCodeCR:case Te.CharCodeTab:case Te.CharCodeSpace:break;default:r=n;continue}break;case pe.Begin:if(i===Te.CharCodeLowerThan)r=pe.IgnoreSpaces,n=pe.BeginNode;else{o=t,r=pe.Pcdata;continue}break;case pe.Pcdata:if(i===Te.CharCodeLowerThan){l+=e.substr(o,t-o);const g=new As;g.nodeType=ht.Text,g.value=l,l="",s.addChild(g),r=pe.IgnoreSpaces,n=pe.BeginNode}else i===Te.CharCodeAmp&&(l+=e.substr(o,t-o),r=pe.Escape,h=pe.Pcdata,o=t+1);break;case pe.Cdata:if(i===Te.CharCodeBrackedClose&&e.charCodeAt(t+1)===Te.CharCodeBrackedClose&&e.charCodeAt(t+2)===Te.CharCodeGreaterThan){const g=new As;g.nodeType=ht.CDATA,g.value=e.substr(o,t-o),s.addChild(g),t+=2,r=pe.Begin}break;case pe.BeginNode:switch(i){case Te.CharCodeExclamation:if(e.charCodeAt(t+1)===Te.CharCodeBrackedOpen){if(t+=2,e.substr(t,6).toUpperCase()!=="CDATA[")throw new Ns("Expected <![CDATA[",e,t);t+=5,r=pe.Cdata,o=t+1}else if(e.charCodeAt(t+1)===Te.CharCodeUpperD||e.charCodeAt(t+1)===Te.CharCodeLowerD){if(e.substr(t+2,6).toUpperCase()!=="OCTYPE")throw new Ns("Expected <!DOCTYPE",e,t);t+=8,r=pe.Doctype,o=t+1}else{if(e.charCodeAt(t+1)!==Te.CharCodeMinus||e.charCodeAt(t+2)!==Te.CharCodeMinus)throw new Ns("Expected <!--",e,t);t+=2,r=pe.Comment,o=t+1}break;case Te.CharCodeQuestion:r=pe.Header,o=t;break;case Te.CharCodeSlash:if(!s)throw new Ns("Expected node name",e,t);o=t+1,r=pe.IgnoreSpaces,n=pe.Close;break;default:r=pe.TagName,o=t;continue}break;case pe.TagName:if(!Te._isValidChar(i)){if(t===o)throw new Ns("Expected node name",e,t);c=new As,c.nodeType=ht.Element,c.localName=e.substr(o,t-o),s.addChild(c),r=pe.IgnoreSpaces,n=pe.Body;continue}break;case pe.Body:switch(i){case Te.CharCodeSlash:r=pe.WaitEnd;break;case Te.CharCodeGreaterThan:r=pe.Childs;break;default:r=pe.AttribName,o=t;continue}break;case pe.AttribName:if(!Te._isValidChar(i)){if(o===t)throw new Ns("Expected attribute name",e,t);if(d=e.substr(o,t-o),c.attributes.has(d))throw new Ns(`Duplicate attribute [${d}]`,e,t);r=pe.IgnoreSpaces,n=pe.Equals;continue}break;case pe.Equals:if(i===Te.CharCodeEquals)r=pe.IgnoreSpaces,n=pe.AttvalBegin;else throw new Ns("Expected =",e,t);break;case pe.AttvalBegin:switch(i){case Te.CharCodeDoubleQuote:case Te.CharCodeSingleQuote:l="",r=pe.AttribVal,o=t+1,p=i;break}break;case pe.AttribVal:switch(i){case Te.CharCodeAmp:l+=e.substr(o,t-o),r=pe.Escape,h=pe.AttribVal,o=t+1;break;default:if(i===p){l+=e.substr(o,t-o);const g=l;l="",c.attributes.set(d,g),r=pe.IgnoreSpaces,n=pe.Body}break}break;case pe.Childs:t=Te.parse(e,t,c),o=t,r=pe.Begin;break;case pe.WaitEnd:if(i===Te.CharCodeGreaterThan)r=pe.Begin;else throw new Ns("Expected >",e,t);break;case pe.WaitEndRet:if(i===Te.CharCodeGreaterThan)return t;throw new Ns("Expected >",e,t);
7case pe.Close:if(!Te._isValidChar(i)){if(o===t)throw new Ns("Expected node name",e,t);if(e.substr(o,t-o)!==s.localName)throw new Ns(`Expected </${s.localName}>`,e,t);r=pe.IgnoreSpaces,n=pe.WaitEndRet;continue}break;case pe.Comment:i===Te.CharCodeMinus&&e.charCodeAt(t+1)===Te.CharCodeMinus&&e.charCodeAt(t+2)===Te.CharCodeGreaterThan&&(t+=2,r=pe.Begin);break;case pe.Doctype:if(i===Te.CharCodeBrackedOpen)f++;else if(i===Te.CharCodeBrackedClose)f--;else if(i===Te.CharCodeGreaterThan&&f===0){const g=new As;g.nodeType=ht.DocumentType,g.value=e.substr(o,t-o),s.addChild(g),r=pe.Begin}break;case pe.Header:i===Te.CharCodeQuestion&&e.charCodeAt(t+1)===Te.CharCodeGreaterThan&&(t++,r=pe.Begin);break;case pe.Escape:if(i===Te.CharCodeSemi){const g=e.substr(o,t-o);if(g.charCodeAt(0)===Te.CharCodeSharp){const m=g.charCodeAt(1)===Te.CharCodeLowerX?Number.parseInt(`0${g.substr(1,g.length-1)}`,10):Number.parseInt(g.substr(1,g.length-1),10);l+=String.fromCharCode(m)}else Te._escapes.has(g)?l+=Te._escapes.get(g):l+=`&${g};`?.toString();o=t+1,r=h}else!Te._isValidChar(i)&&i!==Te.CharCodeSharp&&(l+="&",l+=e.substr(o,t-o),t--,o=t+1,r=h);break}t++}if(r===pe.Begin&&(o=t,r=pe.Pcdata),r===pe.Pcdata){if(t!==o){l+=e.substr(o,t-o);const g=new As;g.nodeType=ht.Text,g.value=l,s.addChild(g)}return t}if(r===pe.Escape&&h===pe.Pcdata){l+="&",l+=e.substr(o,t-o);const g=new As;return g.nodeType=ht.Text,g.value=l,s.addChild(g),t}throw new Ns("Unexpected end",e,t)}static _isValidChar(e){return e>=Te.CharCodeLowerA&&e<=Te.CharCodeLowerZ||e>=Te.CharCodeUpperA&&e<=Te.CharCodeUpperZ||e>=Te.CharCode0&&e<=Te.CharCode9||e===Te.CharCodeColon||e===Te.CharCodeDot||e===Te.CharCodeUnderscore||e===Te.CharCodeMinus}}class so{_result=[];_indention;_xmlHeader;_isStartOfLine;_currentIndention;constructor(e,t){this._indention=e,this._xmlHeader=t,this._currentIndention="",this._isStartOfLine=!0}writeNode(e){switch(e.nodeType){case ht.None:break;case ht.Element:this._result.length>0&&this._writeLine(),this._write(`<${e.localName}`);for(const[t,s]of e.attributes)this._write(` ${t}="`),this._writeAttributeValue(s),this._write('"');if(e.childNodes.length===0)this._write("/>");else{if(this._write(">"),e.childNodes.length===1&&!e.firstElement)this.writeNode(e.childNodes[0]);else{this._indent();for(const t of e.childNodes)(t.nodeType===ht.Element||t.nodeType===ht.Comment)&&this.writeNode(t);this._unindend(),this._writeLine()}this._write(`</${e.localName}>`)}break;case ht.Text:e.value&&this._write(e.value);break;case ht.CDATA:e.value!==null&&this._write(`<![CDATA[${e.value}]]>`);break;case ht.Document:this._xmlHeader&&this._write('<?xml version="1.0" encoding="utf-8"?>');for(const t of e.childNodes)this.writeNode(t);break;case ht.DocumentType:this._write(`<!DOCTYPE ${e.value}>`);break;case ht.Comment:this._write(`<!-- ${e.value} -->`);break}}_unindend(){this._currentIndention=this._currentIndention.substr(0,this._currentIndention.length-this._indention.length)}_indent(){this._currentIndention+=this._indention}_writeAttributeValue(e){for(let t=0;t<e.length;t++){const s=e.charAt(t);switch(s){case"<":this._result.push("&lt;");break;case">":this._result.push("&gt;");break;case"&":this._result.push("&amp;");break;case"'":this._result.push("&apos;");break;case'"':this._result.push("&quot;");break;default:this._result.push(s);break}}}static write(e,t,s){const i=new so(t,s);return i.writeNode(e),i.toString()}_write(e){this._isStartOfLine&&this._result.push(this._currentIndention),this._result.push(e),this._isStartOfLine=!1}_writeLine(e=null){e&&this._write(e),this._indention.length>0&&!this._isStartOfLine&&(this._result.push(`
8`),this._isStartOfLine=!0)}toString(){return this._result.join("").trimRight()}}class jr extends As{constructor(){super(),this.nodeType=ht.Document}parse(e){Te.parse(e,0,this)}toString(){return this.toFormattedString()}toFormattedString(e="",t=!1){return so.write(this,e,t)}}class Ti{noteRange=1;x=0;y=0}var Ui;(function(a){a[a.None=0]="None",a[a.Rectangle=1]="Rectangle",a[a.Ellipse=2]="Ellipse",a[a.Circle=3]="Circle"})(Ui||(Ui={}));class En extends Ti{align=Y.Left;frame=Ui.None;text="";fontFace="";weight=0;height=0}class Ko extends Ti{chord=new Bi}class Zo extends Ti{}class jo extends Ti{}class Ph extends Ti{number=0}class el extends Ti{decrescendo=!1}class vn extends Ti{allNumbers=!1;firstNumber=0;lastNumber=0}class Ch extends Ti{octave=1}class Eh extends Ti{}class vh{defaultClef=ve.G2;description="";percussion=!1;instrument=0;volume=0;transpose=0;index=0}class Dh{from=0;to=0;curly=!1}class Lh{currentBarIndex=-1;currentBarComplete=!0;currentBarDuration=0;currentPosition=0;voiceStemDir=null;repeatCount=0;repeatEnd=null}class _a{score;_trackChannel=0;_beamingMode=st.Auto;_galleryObjects;_voiceCounts;_isFirstSystem=!0;_initialTempo=-1;parseXml(e,t){this._galleryObjects=new Map,this._tieStarts=[],this._tieStartIds=new Map,this._voiceCounts=new Map,this._slurs=new Map,this._crescendo=new Map,this._isFirstSystem=!0;const s=new jr;try{s.parse(e)}catch(i){throw new Bt("Could not parse XML",i)}this._parseDom(s),this._consolidate(),this.score.finish(t)}_consolidate(){L.consolidate(this.score),_a._applyEffectRange(this._slurs,(e,t)=>{t.isLegatoOrigin=!0}),_a._applyEffectRange(this._crescendo,(e,t)=>{t.crescendo=e.decrescendo?Gt.Decrescendo:Gt.Crescendo})}static _applyEffectRange(e,t){for(const[s,i]of e){const r=i.noteRange;let n=s;for(let o=0;o<r;o++)if(t(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)n=n.voice.bar.staff.bars[n.voice.bar.index+1].voices[n.voice.index].beats[0];else break}}_parseDom(e){const t=e.firstElement;if(!t)throw new Bt("No valid XML");if(t.localName==="score"){this.score=new Ks;for(const s of t.childElements())switch(s.localName){case"info":this._parseInfo(s);break;case"layout":this._parseLayout(s);break;case"gallery":this._parseGallery(s);break;case"pageObjects":this._parsePageObjects(s);break;case"systems":this._parseSystems(s);break}}else throw new Bt('Root node of XML was not "score"')}_staffLookup=new Map;_parseLayout(e){for(const r of e.childElements())switch(r.localName){case"staves":this._parseLayoutStaves(r);break;case"brackets":this._parseBrackets(r);break}const t=this._brackets.filter(r=>!!r.curly);t.sort((r,n)=>r.from-n.from);let s=0,i=null;for(let r=0;r<this._staffLayouts.length;r++){const n=this._staffLayouts[r];for(;s<t.length&&r>t[s].to;)s++;i&&s<t.length&&r>t[s].from&&r<=t[s].to?i.ensureStaveCount(i.staves.length+1):(i=new Zs,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._trackChannel++,i.playbackInfo.secondaryChannel=this._trackChannel++),this.score.addTrack(i));const o=i.staves[i.staves.length-1];o.isPercussion=n.percussion,o.transpositionPitch=n.transpose,o.displayTranspositionPitch=0,o.showTablature=!1,this._staffLookup.set(n.index,o)}}_brackets=[];_parseBrackets(e){for(const t of e.childElements())t.localName==="bracket"&&this._parseBracket(t)}_parseBracket(e){const t=new Dh;t.from=Number.parseInt(e.getAttribute("from"),10),t.to=Number.parseInt(e.getAttribute("to"),10),e.attributes.has("curly")&&(t.curly=e.attributes.get("curly")==="true"),this._brackets.push(t)}_parseLayoutStaves(e){for(const t of e.childElements())t.localName==="staffLayout"&&this._parseStaffLayout(t)}_staffLayoutLookup=new Map;_staffLayouts=[];_parseStaffLayout(e){const t=new vh;t.description=e.getAttribute("description");for(const s of e.childElements())switch(s.localName){case"notation":s.attributes.has("defaultClef")&&(t.defaultClef=this._parseClef(s.attributes.get("defaultClef")));break;case"sound":s.attributes.has("percussion")&&(t.percussion=s.attributes.get("percussion")==="true"),s.attributes.has("instr")&&(t.instrument=Number.parseInt(s.attributes.get("instr"),10)),s.attributes.has("volume")&&(t.volume=Number.parseInt(s.attributes.get("volume"),10)),s.attributes.has("transpose")&&(t.transpose=Number.parseInt(s.attributes.get("transpose"),10));break}this._staffLayoutLookup.set(t.description,t),t.index=this._staffLayouts.length,this._staffLayouts.push(t)}_parseClef(e){switch(e){case"treble":return ve.G2;case"bass":return ve.F4;case"alto":return ve.C4;case"tenor":return ve.C4}return ve.G2}_parseClefOttava(e){return e.endsWith("-")?le._8vb:e.endsWith("+")?le._8va:le.Regular}_parseSystems(e){for(const t of e.childElements())t.localName==="system"&&this._parseSystem(t)}_parseSystem(e){e.attributes.has("tempo")&&this.score.masterBars.length===0&&(this._initialTempo=Number.parseInt(e.attributes.get("tempo"),10)),e.getAttribute("beamGrouping")==="0"&&(this._beamingMode=st.ForceSplitToNext);for(const t of e.childElements())t.localName==="staves"&&this._parseStaves(e,t);this._isFirstSystem=!1}_parseStaves(e,t){const s=this.score.masterBars.length;for(const i of t.childElements())i.localName==="staff"&&this._parseStaff(e,s,i)}_timeSignature=new Qs;_currentStaffLayout;_parseStaff(e,t,s){const i=s.getAttribute("layout");this._currentStaffLayout=this._staffLayoutLookup.get(i),this._timeSignature.timeSignatureNumerator=4,this._timeSignature.timeSignatureDenominator=4,this._timeSignature.timeSignatureCommon=!1,this._parseTime(s.getAttribute("defaultTime"));const r=this._staffLookup.get(this._currentStaffLayout.index);for(;r.bars.length<t;
8)this._addNewBar(r);for(const n of s.childElements())n.localName==="voices"&&this._parseVoices(i,r,e,t,n)}_parseTime(e){switch(e){case"allaBreve":case"C":this._timeSignature.timeSignatureNumerator=2,this._timeSignature.timeSignatureDenominator=2,this._timeSignature.timeSignatureCommon=!0;break;case"longAllaBreve":this._timeSignature.timeSignatureNumerator=4,this._timeSignature.timeSignatureDenominator=4,this._timeSignature.timeSignatureCommon=!0;break;default:if(e.indexOf("/")>0){const t=e.split("/");this._timeSignature.timeSignatureNumerator=Number.parseInt(t[0],10),this._timeSignature.timeSignatureDenominator=Number.parseInt(t[1],10),this._timeSignature.timeSignatureCommon=!1}break}}_parseVoices(e,t,s,i,r){let n=0;for(const o of r.childElements())o.localName==="voice"&&(this._parseVoice(e,t,s,n,i,o),n++)}_getOrCreateBar(e,t){return t<e.bars.length?e.bars[t]:this._addNewBar(e)}_addNewBar(e){const t=new ns;if(e.bars.length>0?(t.clef=e.bars[e.bars.length-1].clef,t.clefOttava=e.bars[e.bars.length-1].clefOttava,t.keySignature=e.bars[e.bars.length-1].keySignature,t.keySignatureType=e.bars[e.bars.length-1].keySignatureType):t.clef=this._currentStaffLayout.defaultClef,e.addBar(t),e.bars.length>this.score.masterBars.length){const s=new Qs;this.score.addMasterBar(s),s.index>0?s.tripletFeel=s.previousMasterBar.tripletFeel:this._initialTempo>0&&s.tempoAutomations.push(tt.buildTempoAutomation(!1,0,this._initialTempo,0
vendor: 5,199 bytes, line 8
8)),s.timeSignatureDenominator=this._timeSignature.timeSignatureDenominator,s.timeSignatureNumerator=this._timeSignature.timeSignatureNumerator,s.timeSignatureCommon=this._timeSignature.timeSignatureCommon}return t}_voiceStates=new Map;_currentVoiceState;_currentBar;_currentVoice;_newBar(e,t){this._currentVoiceState.currentBarIndex++,this._currentBar=this._getOrCreateBar(e,this._currentVoiceState.currentBarIndex),this._currentVoiceState.currentBarDuration=this._currentBar.masterBar.calculateDuration(!1),this._currentVoiceState.currentBarComplete=!1,this._currentVoiceState.currentPosition=0,this._ensureVoice(e,t)}_parseVoice(e,t,s,i,r,n){const o=`${e}_${i}`;if(this._currentVoiceState&&!this._currentVoiceState.currentBarComplete&&(this._currentBar.masterBar.isAnacrusis=!0),this._voiceStates.has(o)?(this._currentVoiceState=this._voiceStates.get(o),this._currentBar=this._getOrCreateBar(t,this._currentVoiceState.currentBarIndex),this._ensureVoice(t,i)):(this._currentVoiceState=new Lh,this._currentVoiceState.currentBarIndex=r-1,this._voiceStates.set(o,this._currentVoiceState),this._newBar(t,i)),n.attributes.has("stemDir"))switch(n.attributes.get("stemDir")){case"up":this._currentVoiceState.voiceStemDir=P.Up;break;case"down":this._currentVoiceState.voiceStemDir=P.Down;break;default:this._currentVoiceState.voiceStemDir=null;break}else this._currentVoiceState.voiceStemDir=null;const l=n.findChildElement("noteObjects");if(s.attributes.has("tempo")){const h=new tt;h.isLinear=!0,h.type=Re.Tempo,h.value=Number.parseInt(s.attributes.get("tempo"),10),h.ratioPosition=this._currentVoiceState.currentPosition/this._currentVoiceState.currentBarDuration,this._currentBar.masterBar.tempoAutomations.push(h)}if(l)for(const h of l.childElements())switch(this._currentVoiceState.currentBarComplete&&h.localName!=="barline"&&this._newBar(t,i),h.localName){case"clefSign":this._currentBar.clef=this._parseClef(h.getAttribute("clef")),this._currentBar.clefOttava=this._parseClefOttava(h.getAttribute("clef"));break;case"keySign":this._currentBar.keySignature=Number.parseInt(h.getAttribute("fifths"),10);break;case"timeSign":this._parseTime(h.getAttribute("time")),this._currentBar.masterBar.timeSignatureDenominator=this._timeSignature.timeSignatureDenominator,this._currentBar.masterBar.timeSignatureNumerator=this._timeSignature.timeSignatureNumerator,this._currentBar.masterBar.timeSignatureCommon=this._timeSignature.timeSignatureCommon,this._currentVoiceState.currentPosition=0,this._currentVoiceState.currentBarDuration=this._currentBar.masterBar.calculateDuration(!1);break;case"barline":switch(h.getAttribute("type")){case"double":this._currentBar.barLineRight=ye.LightLight,this._currentVoiceState.currentBarComplete||(this._currentBar.masterBar.isAnacrusis=!0),this._currentVoiceState.currentBarComplete=!0;break;case"end":this._currentVoiceState.currentBarComplete||(this._currentBar.masterBar.isAnacrusis=!0);break;case"repEnd":this._currentVoiceState.repeatEnd=this._currentBar.masterBar,this._currentBar.masterBar.repeatCount<this._currentVoiceState.repeatCount&&(this._currentBar.masterBar.repeatCount=this._currentVoiceState.repeatCount),this._parseBarDrawObject(h),this._currentVoiceState.currentBarComplete||(this._currentBar.masterBar.isAnacrusis=!0),this._currentVoiceState.currentBarComplete=!0;break;case"repBegin":this._newBar(t,i),this._currentBar.masterBar.isRepeatStart=!0,this._currentVoiceState.repeatEnd=null,this._currentVoiceState.repeatCount=0;break;case"repEndBegin":this._currentVoiceState.repeatEnd=this._currentBar.masterBar,this._currentBar.masterBar.repeatCount<this._currentVoiceState.repeatCount&&(this._currentBar.masterBar.repeatCount=this._currentVoiceState.repeatCount),this._parseBarDrawObject(h),this._newBar(t,i),this._currentBar.masterBar.isRepeatStart=!0;break;case"dashed":this._currentVoiceState.currentBarComplete||(this._currentBar.masterBar.isAnacrusis=!0),this._currentVoiceState.currentBarComplete=!0;break;default:this._currentVoiceState.currentBarComplete||(this._currentBar.masterBar.isAnacrusis=!0),this._currentVoiceState.currentBarComplete=!0;break}break;case"chord":const c=new Dt;this._initFromPreviousBeat(c,this._currentVoice),c.beamingMode=this._beamingMode,this._currentVoiceState.voiceStemDir&&(c.preferredBeamDirection=this._currentVoiceState.voiceStemDir),this._parseDuration(c,h.findChildElement("duration")),c.updateDurations(),this._currentVoiceState.currentPosition+=c.playbackDuration,this._currentVoice.addBeat(c),this._parseChord(c,h),this._currentVoiceState.currentPosition>=this._currentVoiceState.currentBarDuration&&(this._currentVoiceState.currentBarComplete=!0);break;case"rest":const d=this._parseRestDurations(h.findChildElement("duration"));d&&(this._initFromPreviousBeat(d,this._currentVoice),d.updateDurations(),this._currentVoiceState.currentPosition+=d.playbackDuration,this._currentVoice.addBeat(d),this._currentVoiceState.currentPosition>=this._currentVoiceState.currentBarDuration&&(this._currentVoiceState.currentBarComplete=!0));break}}_initFromPreviousBeat(e,t){const s=this._getLastBeat(t);s&&(e.dynamics=s.dynamics)}_getLastBeat(e){if(e.beats.length>0)return e.beats[e.beats.length-1];if(e.bar.index>
80){const t=e.bar.staff.bars[e.bar.index-1];if(e.index<t.voices.length){const s=t.voices[e.index];return this._getLastBeat(s)}}return null}_ensureVoice(e,t){for(;this._currentBar.voices.length<t+1;)this._currentBar.addVoice(new ks);(!this._voiceCounts.has(e.track.index)||this._voiceCounts.get(e.track.index)<this._currentBar.voices.length)&&this._voiceCounts.set(e.track.index,this._currentBar.voices.length),this._currentVoice=this._currentBar.voices[t]}_parseChord(e,t){const s=new kt;for(const i of t.childElements())switch(i.localName){case"stem":switch(i.getAttribute("dir")){case"up":e.preferredBeamDirection=P.Up;break;case"down":e.preferredBeamDirection=P.Down;break}break;case"articulation":switch(i.getAttribute("type")){case"staccato":s.isStaccato=!0;break;case"normalAccent":s.accentuated=ct.Normal;break;case"strongAccent":s.accentuated=ct.Heavy;break}break;case"lyric":this._parseLyric(e,i);break;case"drawObjects":this._parseBeatDrawObject(e,i);break;case"heads":this._parseHeads(e,s,i);break;case"beam":switch(i.getAttribute("group")){case"force":e.beamingMode=st.ForceMergeWithNext;break;case"divide":e.beamingMode=st.ForceSplitToNext;break}break}}_parseHeads(e,t,s){for(const i of s.childElements())i.localName==="head"&&this._parseHead(e,t,i)}_tieStarts;_tieStartIds;_slurs;_crescendo;_parseHead(e,t,s){const i=new kt,r=L.parseTuning(s.getAttribute("pitch"));i.octave=r.octave-1,i.tone=r.tone.noteValue,i.isStaccato=t.isStaccato,i.accentuated=t.accentuated,e.addNote(i);for(const n of s.childElements())switch(n.localName){case"alter":n.attributes.has("step")&&(i.tone+=Number.parseInt(n.attributes.get("step"),10));break;case"tie":n.attributes.has("begin")?this._tieStartIds.has(i.id)||(this._tieStartIds.set(i.id,!0),this._tieStarts.push(i)):n.attributes.has("end")&&this._tieStarts.length>0&&!i.isTieDestination&&(i.isTieDestination=!0,i.tieOrigin=this._tieStarts[0],this._tieStarts.splice(0,1),this._tieStartIds.delete(i.id));break}}_parseBeatDrawObject(e,t){for(const s of t.childElements())switch(s.localName){case"drawObj":const i=this._parseDrawObj(s);if(i){if(i instanceof En)i.fontFace.startsWith("capella")?i.text==="u"?(e.fermata=new Br,e.fermata.type=os.Medium):i.text==="f"?e.dynamics=se.F:i.text==="j"&&(e.dynamics=se.MF):this._isFirstSystem&&this.score.title===""&&i.align===Y.Center&&i.height>16&&i.weight>400?this.score.title=i.text:this._isFirstSystem&&this.score.artist===""&&i.align===Y.Center&&i.y<0?this.score.artist=i.text:this._isFirstSystem&&this.score.music===""&&i.align===Y.Right&&i.y<0?this.score.music=i.text:i.text.startsWith("by capella")||(e.text=i.text);else if(!(i instanceof Ko))if(i instanceof jo)e.vibrato=Be.Slight;else if(i instanceof el)e.crescendo=i.decrescendo?Gt.Decrescendo:Gt.Crescendo,i.noteRange++,this._crescendo.set(e,i);else if(i instanceof Zo){const r=i;this._slurs.set(e,r)}else i instanceof vn&&this._applyVolta(i)}break}}_parseBarDrawObject(e){for(const t of e.childElements())if(t.localName==="drawObj"){const s=this._parseDrawObj(t);s&&s instanceof vn&&this._applyVolta(s)}}_applyVolta(e){if(e.lastNumber>0?(this._currentVoiceState.repeatCount=e.lastNumber,this._currentVoiceState.repeatEnd&&this._currentVoiceState.repeatEnd.repeatCount<this._currentVoiceState.repeatCount&&(this._currentVoiceState.repeatEnd.repeatCount=this._currentVoiceState.repeatCount)):e.firstNumber>0&&(this._currentVoiceState.repeatCount=e.firstNumber,this._currentVoiceState.repeatEnd&&this._currentVoiceState.repeatEnd.repeatCount<this._currentVoiceState.repeatCount&&(this._currentVoiceState.repeatEnd.repeatCount=this._currentVoiceState.repeatCount)),e.lastNumber>0&&e.firstNumber>0){let t=0;for(let s=e.firstNumber;s<=e.lastNumber;s++)t=t|1<<s-1;this._currentBar.masterBar.alternateEndings=t}else e.lastNumber>0?this._currentBar.masterBar.alternateEndings=1<<e.lastNumber-1:e.firstNumber>0&&(this._currentBar.masterBar.alternateEndings=1<<e.firstNumber-1)}_parseLyric(e,t){for(const s of t.childElements())if(s.localName==="verse"){e.lyrics||(e.lyrics=[]);let i=s.innerText;s.getAttribute("hyphen")==="true"&&(i+="-"),e.lyrics.push(i)}}_parseRestDurations(e){const t=e.getAttribute("base");if(t.indexOf("/")!==-1){const i=new Dt;return i.beamingMode=this._beamingMode,this._parseDuration(i,e),i}if(Number.parseInt(t,10)===1){const i=new Dt;return i.beamingMode=this._beamingMode,i.duration=y.Whole,i}return E.warning("Importer","Multi-Bar rests are not supported"),null}_parseDurationValue(e){switch(e){case"2/1":return y.DoubleWhole;case"1/1":return y.Whole;case"1/2":return y.Half;case"1/4":return y.Quarter;case"1/8":return y.Eighth;case"1/16":return y.Sixteenth;case"1/32":return y.ThirtySecond;case"1/64":return y.SixtyFourth;case"1/128":return y.OneHundredTwentyEighth;default:return E.warning("Importer","Unsupported duration"),y.Quarter}}_parseDuration(e,t){const s=t.getAttribute("base");e.duration=this._parseDurationValue(s),t.attributes.has("dots")&&(e.dots=Number.parseInt(t.attributes.get("dots"),10));const i=t.findChildElement("tuplet");if(i){e.tupletNumerator=Number.parseInt(i.getAttribute("count"),10);const r=i.getAttribute("tripartite")==="true"?3:1,n=i.getAttribute("prolong")==="true"?0:1;let o=0;for(;r*Math.pow(2,o+n)<e.tupletNumerator;)o++;e.tupletDenominator=r*Math.pow(2,o)}}_parsePageObjects(e){for(const t of e.childElements())switch(t.localName){case"drawObj":const s=this._parseDrawObj(t);if(s&&s instanceof En)switch(s.align){case Y.Center:this.score.title?this.score.subTitle||(this.score.subTitle=t.innerText):this.score.title=t.innerText;break;case Y.Right:this.score.artist||(this.score.artist=t.innerText);break}break}}_parseGallery(e){for(const t of e.childElements())if(t.localName==="drawObj"){const s=this._parseDrawObj(t);s&&this._galleryObjects.set(t.getAttribute("name"),s)}}_parseDrawObj(e){let t=null,s=1;for(const i of e.childElements())switch(i.localName){case"text":t=this._parseText(i);break;case"guitar":t=this._parseGuitar(i);break;case"slur":t=this._parseSlur(i);break;case"wavyLine":t=this._parseWavyLine(i);break;case"bracket":t=this._parseTupletBracket(i);break;case"wedge":t=this._parseWedge(i);break;case"volta":t=this._parseVolta(i);break;case"octaveClef":t=this._parseOctaveClef(i);break;case"trill":t=this._parseTrill(i);break;case"basic":i.attributes.has("noteRange")&&(s=Number.parseInt(i.attributes.get("noteRange"),10));break}return t&&(t.noteRange=s),t}_parseTrill(e){return new Eh}_parseOctaveClef(e){const t=new Ch;return e.attributes.has("octave")&&(t.octave=Number.parseInt(e.attributes.get("octave"),10)),t}_parseVolta(e){const t=new vn;return t.allNumbers=e.attributes.get("allNumbers")==="true",e.attributes.has("firstNumber")&&(t.firstNumber=Number.parseInt(e.attributes.get("firstNumber"),10)),e.attributes.has("lastNumber")&&(t.lastNumber=Number.parseInt(e.attributes.get("lastNumber"),10)),t}_parseWedge(e){const t=new el;return t.decrescendo=e.attributes.get("decrescendo")==="true",t}_parseTupletBracket(e){const t=new Ph;return e.attributes.has("number")&&(t.number=Number.parseInt(e.attributes.get("number"),10)),t}_parseWavyLine(e){return new jo}_parseSlur(e){return new Zo}_parseGuitar(e){const t=new Ko,s=e.innerText.trim();for(let i=0;i<s.length;i++)s.charAt(i)==="/"?t.chord.strings.push(0):t.chord.strings.push(Number.parseInt(s.charAt(i),10));return t}_parseText(e){const t=new En;switch(e.attributes.has("x")&&(t.x=Number.parseFloat(e.attributes.get("x"))),e.attributes.has("x")&&(t.y=Number.parseFloat(e.attributes.get("y"))),e.getAttribute("align")){case"left":t.align=Y.Left;break;case"center":t.align=Y.Center;break;case"right":t.align=Y.Right;break}
vendor: 4,900 bytes, line 8
8switch(e.getAttribute("frame")){case"rectangle":t.frame=Ui.Rectangle;break;case"ellipse":t.frame=Ui.Ellipse;break;case"circle":t.frame=Ui.Circle;break;case"none":t.frame=Ui.None;break}if(e.firstElement)for(const s of e.childElements())switch(s.localName){case"font":t.fontFace=s.getAttribute("face"),s.attributes.has("weight")&&(t.weight=Number.parseInt(s.attributes.get("weight"),10)),s.attributes.has("height")&&(t.height=Number.parseInt(s.attributes.get("height"),10));break;case"content":t.text=s.innerText;break}else t.text=e.innerText;return t}_parseInfo(e){for(const t of e.childElements())switch(t.localName){case"author":this.score.tab=t.firstChild.innerText;break;case"comment":this.score.notices=t.firstChild.innerText;break}}}class Fh extends sr{get name(){return"Capella"}readScore(){E.debug(this.name,"Loading ZIP entries");const e=new to(this.data);let t,s=null;if(t=e.read(),E.debug(this.name,"Zip entries loaded"),t.length>0)for(const i of t)i.fileName==="score.xml"&&(s=k.toString(i.data,this.settings.importer.encoding));else this.data.reset(),s=k.toString(this.data.readAll(),this.settings.importer.encoding);if(!s)throw new Bt("No valid capella file");E.debug(this.name,"Start Parsing score.xml");try{const i=new _a;return i.parseXml(s,this.settings),E.debug(this.name,"score.xml parsed"),i.score}catch(i){throw new Bt("Failed to parse CapXML",i)}}}var U;(function(a){a[a.TargetFine=0]="TargetFine",a[a.TargetSegno=1]="TargetSegno",a[a.TargetSegnoSegno=2]="TargetSegnoSegno",a[a.TargetCoda=3]="TargetCoda",a[a.TargetDoubleCoda=4]="TargetDoubleCoda",a[a.JumpDaCapo=5]="JumpDaCapo",a[a.JumpDaCapoAlCoda=6]="JumpDaCapoAlCoda",a[a.JumpDaCapoAlDoubleCoda=7]="JumpDaCapoAlDoubleCoda",a[a.JumpDaCapoAlFine=8]="JumpDaCapoAlFine",a[a.JumpDalSegno=9]="JumpDalSegno",a[a.JumpDalSegnoAlCoda=10]="JumpDalSegnoAlCoda",a[a.JumpDalSegnoAlDoubleCoda=11]="JumpDalSegnoAlDoubleCoda",a[a.JumpDalSegnoAlFine=12]="JumpDalSegnoAlFine",a[a.JumpDalSegnoSegno=13]="JumpDalSegnoSegno",a[a.JumpDalSegnoSegnoAlCoda=14]="JumpDalSegnoSegnoAlCoda",a[a.JumpDalSegnoSegnoAlDoubleCoda=15]="JumpDalSegnoSegnoAlDoubleCoda",a[a.JumpDalSegnoSegnoAlFine=16]="JumpDalSegnoSegnoAlFine",a[a.JumpDaCoda=17]="JumpDaCoda",a[a.JumpDaDoubleCoda=18]="JumpDaDoubleCoda"})(U||(U={}));class ti extends sr{static _versionString="FICHIER GUITAR PRO ";_versionNumber=0;_score;_globalTripletFeel=Ce.NoTripletFeel;_lyricsTrack=0;_lyrics=[];_barCount=0;_trackCount=0;_playbackInfos=[];_doubleBars=new Set;_clefsPerTrack=new Map;_keySignatures=new Map;_beatTextChunksByTrack=new Map;_directionLookup=new Map;_initialTempo;get name(){return"Guitar Pro 3-5"}readScore(){if(this._directionLookup.clear(),this.readVersion(),this._score=new Ks,this.readScoreInformation(),this._versionNumber<500&&(this._globalTripletFeel=Ae.gpReadBool(this.data)?Ce.Triplet8th:Ce.NoTripletFeel),this._versionNumber>=400&&this.readLyrics(),this._versionNumber>=510&&this.data.skip(19),this._initialTempo=tt.buildTempoAutomation(!1,0,0,0),this._versionNumber>=500&&(this.readPageSetup(),this._initialTempo.text=Ae.gpReadStringIntByte(this.data,this.settings.importer.encoding)),this._initialTempo.value=k.readInt32LE(this.data),this._versionNumber>=510&&Ae.gpReadBool(this.data),k.readInt32LE(this.data),this._versionNumber>=400&&this.data.readByte(),this.readPlaybackInfos(),this._versionNumber>=500&&(this._readDirection(U.TargetCoda),this._readDirection(U.TargetDoubleCoda),this._readDirection(U.TargetSegno),this._readDirection(U.TargetSegnoSegno),this._readDirection(U.TargetFine),this._readDirection(U.JumpDaCapo),this._readDirection(U.JumpDaCapoAlCoda),this._readDirection(U.JumpDaCapoAlDoubleCoda),this._readDirection(U.JumpDaCapoAlFine),this._readDirection(U.JumpDalSegno),this._readDirection(U.JumpDalSegnoAlCoda),this._readDirection(U.JumpDalSegnoAlDoubleCoda),this._readDirection(U.JumpDalSegnoAlFine),this._readDirection(U.JumpDalSegnoSegno),this._readDirection(U.JumpDalSegnoSegnoAlCoda),this._readDirection(U.JumpDalSegnoSegnoAlDoubleCoda),this._readDirection(U.JumpDalSegnoSegnoAlFine),this._readDirection(U.JumpDaCoda),this._readDirection(U.JumpDaDoubleCoda),this.data.skip(4)),this._barCount=k.readInt32LE(this.data),this._trackCount=k.readInt32LE(this.data),this.readMasterBars(),this.readTracks(),this.readBars(),this._score.masterBars.length>0){const e=tt.buildTempoAutomation(!1,0,this._score.tempo,2);e.text=this._score.tempoLabel,this._score.masterBars[0].tempoAutomations.push(e)}return L.consolidate(this._score),this._score.finish(this.settings),this._lyrics&&this._lyricsTrack>=0&&this._score.tracks[this._lyricsTrack].applyLyrics(this._lyrics),this._score}_readDirection(e){let t=k.readInt16LE(this.data);if(t===-1)return;t--;let s;this._directionLookup.has(t)?s=this._directionLookup.get(t):(s=[],this._directionLookup.set(t,s)),s.push(e)}readVersion(){let e=Ae.gpReadStringByteLength(this.data,30,this.settings.importer.encoding);
8if(!e.startsWith(ti._versionString))throw new Bt("Unsupported format");e=e.substr(ti._versionString.length+1);const t=e.indexOf(".");this._versionNumber=100*Number.parseInt(e.substr(0,t),10)+Number.parseInt(e.substr(t+1),10),E.debug(this.name,`Guitar Pro version ${e} detected`)}readScoreInformation(){this._score.title=Ae.gpReadStringIntUnused(this.data,this.settings.importer.encoding),this._score.subTitle=Ae.gpReadStringIntUnused(this.data,this.settings.importer.encoding),this._score.artist=Ae.gpReadStringIntUnused(this.data,this.settings.importer.encoding),this._score.album=Ae.gpReadStringIntUnused(this.data,this.settings.importer.encoding),this._score.words=Ae.gpReadStringIntUnused(this.data,this.settings.importer.encoding),this._score.music=this._versionNumber>=500?Ae.gpReadStringIntUnused(this.data,this.settings.importer.encoding):this._score.words,this._score.copyright=Ae.gpReadStringIntUnused(this.data,this.settings.importer.encoding),this._score.tab=Ae.gpReadStringIntUnused(this.data,this.settings.importer.encoding),this._score.instructions=Ae.gpReadStringIntUnused(this.data,this.settings.importer.encoding);const e=k.readInt32LE(this.data);let t="";for(let s=0;s<e;s++)s>0&&(t+=`\r
9`),t+=Ae.gpReadStringIntUnused(this.data,this.settings.importer.encoding)?.toString();this._score.notices=t}readLyrics(){this._lyrics=[],this._lyricsTrack=k.readInt32LE(this.data)-1;for(let e=0;e<5;e++){const t=new es;t.startBar=k.readInt32LE(this.data)-1,t.text=Ae.gpReadStringInt(this.data,this.settings.importer.encoding),this._lyrics.push(t)}}readPageSetup(){this.data.skip(28);const e=k.readInt16LE(this.data);L.getOrCreateHeaderFooterStyle(this._score,H.Title).isVisible=(e&1)!==0,L.getOrCreateHeaderFooterStyle(this._score,H.Title).template=Ae.gpReadStringIntByte(this.data,this.settings.importer.encoding),L.getOrCreateHeaderFooterStyle(this._score,H.SubTitle).isVisible=(e&2)!==0,L.getOrCreateHeaderFooterStyle(this._score,H.SubTitle).template=Ae.gpReadStringIntByte(this.data,this.settings.importer.encoding),L.getOrCreateHeaderFooterStyle(this._score,H.Artist).isVisible=(e&4)!==0,L.getOrCreateHeaderFooterStyle(this._score,H.Artist).template=Ae.gpReadStringIntByte(this.data,this.settings.importer.encoding),L.getOrCreateHeaderFooterStyle(this._score,H.Album).isVisible=(e&8)!==0,L.getOrCreateHeaderFooterStyle(this._score,H.Album).template=Ae.gpReadStringIntByte(this.data,this.settings.importer.encoding),L.getOrCreateHeaderFooterStyle(this._score,H.Words).isVisible=(e&16)!==0,L.getOrCreateHeaderFooterStyle(this._score,H.Words).template=Ae.gpReadStringIntByte(this.data,this.settings.importer.encoding),L.getOrCreateHeaderFooterStyle(this._score,H.Music).isVisible=(e&32)!==0,L.getOrCreateHeaderFooterStyle(this._score,H.Music).template=Ae.gpReadStringIntByte(this.data,this.settings.importer.encoding),L.getOrCreateHeaderFooterStyle(this._score,H.WordsAndMusic).isVisible=(e&64)!==0,L.getOrCreateHeaderFooterStyle(this._score,H.WordsAndMusic).template=Ae.gpReadStringIntByte(this.data,this.settings.importer.encoding),L.getOrCreateHeaderFooterStyle(this._score,H.Copyright).isVisible=(e&128)!==0,L.getOrCreateHeaderFooterStyle(this._score,H.Copyright).template=Ae.gpReadStringIntByte(this.data,this.settings.importer.encoding),L.getOrCreateHeaderFooterStyle(this._score,H.CopyrightSecondLine).isVisible=(e&128)!==0,L.getOrCreateHeaderFooterStyle(this._score,H.CopyrightSecondLine).template=Ae.gpReadStringIntByte(this.data,this.settings.importer.encoding),Ae.gpReadStringIntByte(this.data,this.settings.importer.encoding)}readPlaybackInfos(){this._playbackInfos=[];let e=0;for(let t=0;t<64;t++){const s=new jn;s.primaryChannel=e++,s.secondaryChannel=e++,s.program=k.readInt32LE(this.data),s.volume=this.data.readByte(),s.balance=this.data.readByte(),this.data.skip(6),this._playbackInfos.push(s)}}readMasterBars(){for(let e=0;e<this._barCount;e++)this.readMasterBar()}readMasterBar(){let e=null;this._score.masterBars.length>0&&(e=this._score.masterBars[this._score.masterBars.length-1]);const t=new Qs;!e&&this._initialTempo.value>0&&t.tempoAutomations.push(this._initialTempo);const s=this.data.readByte();if((s&1)!==0?t.timeSignatureNumerator=this.data.readByte():e&&(t.timeSignatureNumerator=e.timeSignatureNumerator),(s&2)!==0?t.timeSignatureDenominator=this.data.readByte():e&&(t.timeSignatureDenominator=e.timeSignatureDenominator),t.isRepeatStart=(s&4)!==0,(s&8)!==0&&(t.repeatCount=this.data.readByte()+(this._versionNumber>=500?0:1)),(s&16)!==0&&this._versionNumber<500){let n=e,o=0;for(;n&&!(n.isRepeatEnd&&n!==e||n.isRepeatStart);)o=o|n.alternateEndings,n=n.previousMasterBar;let l=0;const h=this.data.readByte();for(let c=0;c<8;c++){const d=1<<c;h>c&&(o&d)===0&&(l=l|d)}t.alternateEndings=l}if((s&32)!==0){const n=new Tr;n.text=Ae.gpReadStringIntByte(this.data,this.settings.importer.encoding),n.marker="",Ae.gpReadColor(this.data,!1),t.section=n}if((s&64)!==0&&this._keySignatures.set(this._score.masterBars.length,[k.readSInt8(this.data),this.data.readByte()]),this._versionNumber>=500&&(s&3)!==0&&this.data.skip(4),this._versionNumber>=500&&(t.alternateEndings=this.data.readByte()),this._versionNumber>=500){switch(this.data.readByte()){case 1:t.tripletFeel=Ce.Triplet8th;break;case 2:t.tripletFeel=Ce.Triplet16th;break}this.data.readByte()}else t.tripletFeel=this._globalTripletFeel;const i=(s&128)!==0;t.isDoubleBar=i;const r=this._score.masterBars.length;if(this._directionLookup.has(r))for(const n of this._directionLookup.get(r))t.addDirection(n);this._score.addMasterBar(t),i&&this._doubleBars.add(t.index)}readTracks(){for(let e=0;e<this._trackCount;e++)this.readTrack()}static _bassClefTuningThreshold=L.parseTuning("B2").realValue;readTrack(){const e=new Zs;e.ensureStaveCount(1),this._score.addTrack(e);const t=e.staves[0],s=this.data.readByte();e.name=Ae.gpReadStringByteLength(this.data,40,this.settings.importer.encoding),(s&1)!==0&&(t.isPercussion=!0),this._versionNumber>=500&&(e.isVisibleOnMultiTrack=(s&8)!==0),this._score.stylesheet.perTrackDisplayTuning===null&&(this._score.stylesheet.perTrackDisplayTuning=new Map),this._score.stylesheet.perTrackDisplayTuning.set(e.index,(s&128)!==0);const i=k.readInt32LE(this.data),r=[];for(let h=0;h<7;h++){const c=k.readInt32LE(this.data);i>h&&r.push(c)}t.stringTuning.tunings=r;const n=k.readInt32LE(this.data),o=k.readInt32LE(this.data)-1,l=k.readInt32LE(this.data)-1;if(this.data.skip(4),o>=0&&o<this._playbackInfos.length){const h=this._playbackInfos[o];h.port=n,h.isSolo=(s&16)!==0,h.isMute=(s&32)!==0,h.secondaryChannel=l,Ss.isGuitar(h.program)&&(t.displayTranspositionPitch=-12),e.playbackInfo=h}if(t.capo=k.readInt32LE(this.data),e.color=Ae.gpReadColor(this.data,!1),this._versionNumber>=500){const h=this.data.readByte();t.showTablature=(h&1)!==0,t.showStandardNotation=(h&2)!==0;const c=(h&100)!==0;this._score.stylesheet.perTrackChordDiagramsOnTop===null&&(this._score.stylesheet.perTrackChordDiagramsOnTop=new Map),this._score.stylesheet.perTrackChordDiagramsOnTop.set(e.index,c),this.data.readByte(),this.data.readByte(),e.playbackInfo.bank=this.data.readByte(),this.data.readByte(),k.readInt32LE(this.data)===12||r[r.length-1]<ti._bassClefTuningThreshold?this._clefsPerTrack.set(e.index,ve.F4):this._clefsPerTrack.set(e.index,ve.G2),k.readInt32LE(this.data),k.readInt32LE(this.data),this.data.skip(10),this.data.readByte(),this.data.readByte(),this._readRseBank(),this._versionNumber>=510&&(this.data.skip(4),Ae.gpReadStringIntByte(this.data,this.settings.importer.encoding),Ae.gpReadStringIntByte(this.data,this.settings.importer.encoding))}else r[r.length-1]<ti._bassClefTuningThreshold?this._clefsPerTrack.set(e.index,ve.F4):this._clefsPerTrack.set(e.index,ve.G2)}readBars(){for(let e=0;e<this._barCount;e++)for(let t=0;t<this._trackCount;t++)this.readBar(this._score.tracks[t])}readBar(e){const t=new ns,s=e.staves[0];if(s.isPercussion?t.clef=ve.Neutral:this._clefsPerTrack.has(e.index)&&(t.clef=this._clefsPerTrack.get(e.index)),s.addBar(t),this._keySignatures.has(t.index)){const r=this._keySignatures.get(t.index);
9t.keySignature=r[0],t.keySignatureType=r[1]}else t.index>0&&(t.keySignature=t.previousBar.keySignature,t.keySignatureType=t.previousBar.keySignatureType);this._doubleBars.has(t.index)&&(t.barLineRight=ye.LightLight);let i=1;this._versionNumber>=500&&(this.data.readByte(),i=2);for(let r=0;r<i;r++)this.readVoice(e,t)}readVoice(e,t){const s=k.readInt32LE(this.data);if(s===0)return;const i=new ks;t.addVoice(i);for(let r=0;r<s;r++)this.readBeat(e,t,i)}readBeat(e,t,s){const i=new Dt,r=this.data.readByte();if((r&1)!==0&&(i.dots=1),(r&64)!==0){const c=this.data.readByte();i.isEmpty=(c&2)===0}switch(s.addBeat(i),k.readSInt8(this.data)){case-2:i.duration=y.Whole;break;case-1:i.duration=y.Half;break;case 0:i.duration=y.Quarter;break;case 1:i.duration=y.Eighth;break;case 2:i.duration=y.Sixteenth;break;case 3:i.duration=y.ThirtySecond;break;case 4:i.duration=y.SixtyFourth;break;default:i.duration=y.Quarter;break}if((r&32)!==0)switch(i.tupletNumerator=k.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;break}(r&2)!==0&&this.readChord(i);const o=this.settings.importer.beatTextAsLyrics&&e.index!==this._lyricsTrack;if((r&4)!==0){const c=Ae.gpReadStringIntUnused(this.data,this.settings.importer.encoding);if(o){const d=new es;d.text=c.trim(),d.finish(!0);const f=[];for(let p=d.chunks.length-1;p>=0;p--)f.push(d.chunks[p]);this._beatTextChunksByTrack.set(e.index,f)}else i.text=c}let l=te.None;(r&8)!==0&&(l=this.readBeatEffects(i)),(r&16)!==0&&this.readMixTableChange(i);const h=this.data.readByte();for(let c=6;c>=0;c--)if((h&1<<c)!==0&&6-c<t.staff.tuning.length){const d=this.readNote(e,t,s,i,6-c);l!==te.None&&(d.harmonicType=l,d.harmonicType===te.Natural&&(d.harmonicValue=L.deltaFretToHarmonicValue(d.fret)))}if(this._versionNumber>=500){const c=k.readInt16LE(this.data);if((c&1)!==0&&i.index>0&&(s.beats[i.index-1].beamingMode=st.ForceSplitToNext),(c&2)!==0&&(i.preferredBeamDirection=P.Down),(c&4)!==0&&i.index>0&&(s.beats[i.index-1].beamingMode=st.ForceMergeWithNext),(c&8)!==0&&(i.preferredBeamDirection=P.Up),(c&16)!==0&&(i.ottava=le._8va),(c&32)!==0&&(i.ottava=le._8vb),(c&64)!==0&&(i.ottava=le._15ma),(c&256)!==0&&(i.ottava=le._15mb),(c&2048)!==0){const d=this.data.readByte()!==0;i.index>0&&d&&(s.beats[i.index-1].beamingMode=st.ForceSplitOnSecondaryToNext)}}o&&!i.isRest&&this._beatTextChunksByTrack.has(e.index)&&this._beatTextChunksByTrack.get(e.index).length>0&&(i.lyrics=[this._beatTextChunksByTrack.get(e.index).pop()])}readChord(e){const t=new Bi,s=L.newGuid();if(this._versionNumber>=500){this.data.skip(17),t.name=Ae.gpReadStringByteLength(this.data,21,this.settings.importer.encoding),this.data.skip(4),t.firstFret=k.readInt32LE(this.data);for(let n=0;n<7;n++){const o=k.readInt32LE(this.data);n<e.voice.bar.staff.tuning.length&&t.strings.push(o)}const i=this.data.readByte(),r=new Uint8Array(5);this.data.read(r,0,r.length);for(let n=0;n<i;n++)t.barreFrets.push(r[n]);this.data.skip(26)}else if(this.data.readByte()!==0)if(this._versionNumber>=400){this.data.skip(16),t.name=Ae.gpReadStringByteLength(this.data,21,this.settings.importer.encoding),this.data.skip(4),t.firstFret=k.readInt32LE(this.data);for(let n=0;n<7;n++){const o=k.readInt32LE(this.data);n<e.voice.bar.staff.tuning.length&&t.strings.push(o)}const i=this.data.readByte(),r=new Uint8Array(5);this.data.read(r,0,r.length);for(let n=0;n<i;n++)t.barreFrets.push(r[n]);this.data.skip(26)}else{this.data.skip(25),t.name=Ae.gpReadStringByteLength(this.data,34,this.settings.importer.encoding),t.firstFret=k.readInt32LE(this.data);for(let i=0;i<6;i++){const r=k.readInt32LE(this.data);i<e.voice.bar.staff.tuning.length&&t.strings.push(r)}this.data.skip(36)}else{const i=this._versionNumber>=406?7:6;if(t.name=Ae.gpReadStringIntByte(this.data,this.settings.importer.encoding),t.firstFret=k.readInt32LE(this.data),t.firstFret>0)for(let r=0;r<i;r++){const n=k.readInt32LE(this.data);r<e.voice.bar.staff.tuning.length&&t.strings.push(n)}}t.name&&(e.chordId=s,e.voice.bar.staff.addChord(e.chordId,t))}readBeatEffects(e){const t=this.data.readByte();let s=0;if(this._versionNumber>=400&&(s=this.data.readByte()),(t&16)!==0&&(e.fade=yt.FadeIn),(this._versionNumber<400&&(t&1)!==0||(t&2)!==0)&&(e.vibrato=Be.Slight),(s&1)!==0&&(e.rasgueado=ne.Ii),(t&32)!==0&&this._versionNumber>=400)switch(k.readSInt8(this.data)){case 1:e.tap=!0;break;case 2:e.slap=!0;break;case 3:e.pop=!0;break}else if((t&32)!==0){switch(k.readSInt8(this.data)){case 1:e.tap=!0;break;case 2:e.slap=!0;break;case 3:e.pop=!0;break}this.data.skip(4)}if((s&4)!==0&&this.readTremoloBarEffect(e),(t&64)!==0){let i=0,r=0;this._versionNumber<500?(r=this.data.readByte(),i=this.data.readByte()):(i=this.data.readByte(),r=this.data.readByte()),i>0?(e.brushType=z.BrushUp,e.brushDuration=ti._toStrokeValue(i)):r>0&&(e.brushType=z.BrushDown,e.brushDuration=ti._toStrokeValue(r))}if((s&2)!==0)switch(k.readSInt8(this.data)){case 0:e.pickStroke=Ct.None;break;case 1:e.pickStroke=Ct.Up;break;case 2:e.pickStroke=Ct.Down;break}
9if(this._versionNumber<400){if((t&4)!==0)return te.Natural;if((t&8)!==0)return te.Artificial}return te.None}readTremoloBarEffect(e){this.data.readByte(),k.readInt32LE(this.data);const t=k.readInt32LE(this.data);if(t>0)for(let s=0;s<t;s++){const i=new G(0,0);i.offset=k.readInt32LE(this.data),i.value=k.readInt32LE(this.data)/ti._bendStep|0,Ae.gpReadBool(this.data),e.addWhammyBarPoint(i)}}static _toStrokeValue(e){switch(e){case 1:return 30;case 2:return 30;case 3:return 60;case 4:return 120;case 5:return 240;case 6:return 480;default:return 0}}_readRseBank(){this.data.skip(4),this.data.skip(4),this.data.skip(4),this.data.skip(4)}readMixTableChange(e){const t=new Mh;t.instrument=k.readSInt8(this.data),this._versionNumber>=500&&this._readRseBank(),t.volume=k.readSInt8(this.data),t.balance=k.readSInt8(this.data);const s=k.readSInt8(this.data),i=k.readSInt8(this.data),r=k.readSInt8(this.data),n=k.readSInt8(this.data);if(this._versionNumber>=500&&(t.tempoName=Ae.gpReadStringIntByte(this.data,this.settings.importer.encoding)),t.tempo=k.readInt32LE(this.data),t.volume>=0&&this.data.readByte(),t.balance>=0&&this.data.readByte(),s>=0&&this.data.readByte(),i>=0&&this.data.readByte(),r>=0&&this.data.readByte(),n>=0&&this.data.readByte(),t.tempo>=0&&(t.duration=k.readSInt8(this.data),this._versionNumber>=510&&this.data.readByte()),this._versionNumber>=400&&this.data.readByte(),this._versionNumber>=500){const o=k.readSInt8(this.data);o>=100?e.wahPedal=ss.Closed:o>=0&&(e.wahPedal=ss.Open)}if(this._versionNumber>=510&&(Ae.gpReadStringIntByte(this.data,this.settings.importer.encoding),Ae.gpReadStringIntByte(this.data,this.settings.importer.encoding)),t.volume>=0){const o=new tt;o.isLinear=!0,o.type=Re.Volume,o.value=t.volume,e.automations.push(o)}if(t.balance>=0){const o=new tt;o.isLinear=!0,o.type=Re.Balance,o.value=t.balance,e.automations.push(o)}if(t.instrument>=0){const o=new tt;o.isLinear=!0,o.type=Re.Instrument,o.value=t.instrument,e.automations.push(o)}if(t.tempo>=0){const o=new tt;o.isLinear=!0,o.type=Re.Tempo,o.value=t.tempo,e.automations.push(o),e.voice.bar.masterBar.tempoAutomations.some(l=>l.ratioPosition===o.ratioPosition&&l.value===o.value)||e.voice.bar.masterBar.tempoAutomations.push(o)}}readNote(e,t,s,i,r){const n=new kt;n.string=t.staff.tuning.length-r;const o=this.data.readByte();if((o&2)!==0?n.accentuated=ct.Heavy:(o&64)!==0&&(n.accentuated=ct.Normal),n.isGhost=(o&4)!==0,(o&32)!==0){const h=this.data.readByte();h===3?n.isDead=!0:h===2&&(n.isTieDestination=!0)}if((o&1)!==0&&this._versionNumber<500&&(this.data.readByte(),this.data.readByte()),(o&16)!==0){const h=k.readSInt8(this.data);n.dynamics=this.toDynamicValue(h),i.dynamics=n.dynamics}(o&32)!==0&&(n.fret=k.readSInt8(this.data)),(o&128)!==0&&(n.leftHandFinger=k.readSInt8(this.data),n.rightHandFinger=k.readSInt8(this.data));let l=!1;if(this._versionNumber>=500&&((o&1)!==0&&(n.durationPercent=k.readFloat64BE(this.data)),l=(this.data.readByte()&2)!==0),i.addNote(n),(o&8)!==0&&this.readNoteEffects(e,s,i,n),t.staff.isPercussion&&(n.percussionArticulation=n.fret,n.string=-1,n.fret=-1),l){const h=L.computeAccidental(t.keySignature,oe.Default,n.realValueWithoutHarmonic,!1);h===ee.Sharp?n.accidentalMode=oe.ForceFlat:h===ee.Flat&&(n.accidentalMode=oe.ForceSharp)}return n}toDynamicValue(e){switch(e){case 1:return se.PPP;case 2:return se.PP;case 3:return se.P;case 4:return se.MP;case 5:return se.MF;case 6:return se.F;case 7:return se.FF;case 8:return se.FFF;default:return se.F}}readNoteEffects(e,t,s,i){const r=this.data.readByte();let n=0;this._versionNumber>=400&&(n=this.data.readByte()),(r&1)!==0&&this.readBend(i),(r&16)!==0&&this.readGrace(t,i),(n&4)!==0&&this.readTremoloPicking(s),(n&8)!==0?this.readSlide(i):this._versionNumber<400&&(r&4)!==0&&(i.slideOutType=he.Shift),(n&16)!==0&&this.readArtificialHarmonic(i),(n&32)!==0&&this.readTrill(i),i.isLetRing=(r&8)!==0,i.isHammerPullOrigin=(r&2)!==0,(n&64)!==0&&(i.vibrato=Be.Slight),i.isPalmMute=(n&2)!==0,i.isStaccato=(n&1)!==0}static _bendStep=25;readBend(e){this.data.readByte(),k.readInt32LE(this.data);const t=k.readInt32LE(this.data);if(t>0)for(let s=0;s<t;s++){const i=new G(0,0);i.offset=k.readInt32LE(this.data),i.value=k.readInt32LE(this.data)/ti._bendStep|0,Ae.gpReadBool(this.data),e.addBendPoint(i)}}readGrace(e,t){const s=new Dt,i=new kt;switch(i.string=t.string,i.fret=k.readSInt8(this.data),s.duration=y.ThirtySecond,s.dynamics=this.toDynamicValue(k.readSInt8(this.data)),k.readSInt8(this.data)){case 0:break;case 1:i.slideOutType=he.Legato,i.slideTarget=t;break;case 2:break;case 3:i.isHammerPullOrigin=!0;break}if(i.dynamics=s.dynamics,this.data.skip(1),this._versionNumber<500)s.graceType=K.BeforeBeat;else{const n=this.data.readByte();i.isDead=(n&1)!==0,s.graceType=(n&2)!==0?K.OnBeat:K.BeforeBeat}e.addGraceBeat(s),s.addNote(i)}readTremoloPicking(e){const t=new Ts;e.tremoloPicking=t,t.marks=this.data.readByte()}readSlide(e){if(this._versionNumber>=500){const t=k.readSInt8(this.data);
9(t&1)!==0?e.slideOutType=he.Shift:(t&2)!==0?e.slideOutType=he.Legato:(t&4)!==0?e.slideOutType=he.OutDown:(t&8)!==0&&(e.slideOutType=he.OutUp),(t&16)!==0?e.slideInType=St.IntoFromBelow:(t&32)!==0&&(e.slideInType=St.IntoFromAbove)}else switch(k.readSInt8(this.data)){case 1:e.slideOutType=he.Shift;break;case 2:e.slideOutType=he.Legato;break;case 3:e.slideOutType=he.OutDown;break;case 4:e.slideOutType=he.OutUp;break;case-1:e.slideInType=St.IntoFromBelow;break;case-2:e.slideInType=St.IntoFromAbove;break}}readArtificialHarmonic(e){const t=this.data.readByte();if(this._versionNumber>=500)switch(t){case 1:e.harmonicType=te.Natural,e.harmonicValue=L.deltaFretToHarmonicValue(e.fret);break;case 2:this.data.readByte(),this.data.readByte(),this.data.readByte(),e.harmonicType=te.Artificial;break;case 3:e.harmonicType=te.Tap,e.harmonicValue=L.deltaFretToHarmonicValue(this.data.readByte());break;case 4:e.harmonicType=te.Pinch,e.harmonicValue=12;break;case 5:e.harmonicType=te.Semi,e.harmonicValue=12;break}else if(this._versionNumber>=400)switch(t){case 1:e.harmonicType=te.Natural;break;case 3:e.harmonicType=te.Tap;break;case 4:e.harmonicType=te.Pinch;break;case 5:e.harmonicType=te.Semi;break;case 15:e.harmonicType=te.Artificial;break;case 17:e.harmonicType=te.Artificial;break;case 22:e.harmonicType=te.Artificial;break}}readTrill(e){switch(e.trillValue=this.data.readByte()+e.stringTuning,this.data.readByte()){case 1:e.trillSpeed=y.Sixteenth;break;case 2:e.trillSpeed=y.ThirtySecond;break;case 3:e.trillSpeed=y.SixtyFourth;break}}}class Ae{static gpReadColor(e,t=!1){const s=e.readByte(),i=e.readByte(),r=e.readByte();let n=255;return t?n=e.readByte():e.skip(1),new Fe(s,i,r,n)}static gpReadBool(e){return e.readByte()!==0}static gpReadStringIntUnused(e,t){return e.skip(4),Ae.gpReadString(e,e.readByte(),t)}static gpReadStringInt(e,t){return Ae.gpReadString(e,k.readInt32LE(e),t)}static gpReadStringIntByte(e,t){const s=k.readInt32LE(e)-1;return e.readByte(),Ae.gpReadString(e,s,t)}static gpReadString(e,t,s){const i=new Uint8Array(t);return e.read(i,0,i.length),k.toString(i,s)}static gpWriteString(e,t){const s=k.stringToBytes(t);e.writeByte(t.length),e.write(s,0,s.length)}static gpReadStringByteLength(e,t,s){const i=e.readByte(),r=Ae.gpReadString(e,i,s);return i<t&&e.skip(t-i),r}}class Mh{volume=-1;balance=-1;instrument=-1;tempoName="";tempo=-1;duration=-1}class bt{x;y;w;h;scaleWith(e){this.x*=e,this.y*=e,this.w*=e,this.h*=e}constructor(e=0,t=0,s=0,i=0){this.x=e,this.y=t,this.h=i,this.w=s}}var Me;(function(a){a[a.Boolean=0]="Boolean",a[a.Integer=1]="Integer",a[a.Float=2]="Float",a[a.String=3]="String",a[a.Point=4]="Point",a[a.Size=5]="Size",a[a.Rectangle=6]="Rectangle",a[a.Color=7]="Color"})(Me||(Me={}));class ys{_types=new Map;raw=new Map;constructor(e){e&&this._read(e)}_read(e){const t=gt.fromBuffer(e),s=k.readInt32BE(t);for(let i=0;i<s;i++){const r=Ae.gpReadString(t,t.readByte(),"utf-8"),n=t.readByte();switch(this._types.set(r,n),n){case Me.Boolean:const o=t.readByte()===1;this.addValue(r,o);break;case Me.Integer:const l=k.readInt32BE(t);this.addValue(r,l);break;case Me.Float:const h=k.readFloat32BE(t);this.addValue(r,h);break;case Me.String:const c=Ae.gpReadString(t,k.readInt16BE(t),"utf-8");this.addValue(r,c);break;case Me.Point:const d=k.readInt32BE(t),f=k.readInt32BE(t);this.addValue(r,new G(d,f));break;case Me.Size:const p=k.readInt32BE(t),g=k.readInt32BE(t);this.addValue(r,new G(p,g));break;case Me.Rectangle:const m=new bt;m.x=k.readInt32BE(t),m.y=k.readInt32BE(t),m.w=k.readInt32BE(t),m.h=k.readInt32BE(t),this.addValue(r,m);break;case Me.Color:const b=Ae.gpReadColor(t,!0);this.addValue(r,b);break}}}apply(e){for(const[t,s]of this.raw)switch(t){case"StandardNotation/hideDynamics":e.stylesheet.hideDynamics=s;break;case"System/bracketExtendMode":e.stylesheet.bracketExtendMode=s;break;case"Global/useSystemSignSeparator":e.stylesheet.useSystemSignSeparator=s;break;case"Global/DisplayTuning":e.stylesheet.globalDisplayTuning=s;break;case"Global/DrawChords":e.stylesheet.globalDisplayChordDiagramsOnTop=s;break;case"System/drawChordInScore":e.stylesheet.globalDisplayChordDiagramsInScore=s;break;case"System/showTrackNameSingle":s||(e.stylesheet.singleTrackTrackNamePolicy=mt.Hidden);break;case"System/showTrackNameMulti":s||(e.stylesheet.multiTrackTrackNamePolicy=mt.Hidden);break;case"System/trackNameModeSingle":if(e.stylesheet.singleTrackTrackNamePolicy!==mt.Hidden)switch(s){case 0:e.stylesheet.singleTrackTrackNamePolicy=mt.FirstSystem;break;case 1:e.stylesheet.singleTrackTrackNamePolicy=mt.FirstSystem;break;case 2:e.stylesheet.singleTrackTrackNamePolicy=mt.AllSystems;break}break;case"System/trackNameModeMulti":if(e.stylesheet.multiTrackTrackNamePolicy!==mt.Hidden)switch(s){case 0:e.stylesheet.multiTrackTrackNamePolicy=mt.FirstSystem;break;case 1:e.stylesheet.multiTrackTrackNamePolicy=mt.FirstSystem;break;case 2:e.stylesheet.multiTrackTrackNamePolicy=mt.AllSystems;break}break;case"System/shortTrackNameOnFirstSystem":s?e.stylesheet.firstSystemTrackNameMode=Qt.ShortName:e.stylesheet.firstSystemTrackNameMode=Qt.FullName;break;case"System/shortTrackNameOnOtherSystems":s?e.stylesheet.otherSystemsTrackNameMode=Qt.ShortName:e.stylesheet.otherSystemsTrackNameMode=Qt.FullName;break;case"System/horizontalTrackNameOnFirstSystem":s?e.stylesheet.firstSystemTrackNameOrientation=Kt.Horizontal:e.stylesheet.firstSystemTrackNameOrientation=Kt.Vertical;break;case"System/horizontalTrackNameOnOtherSystems":s?e.stylesheet.otherSystemsTrackNameOrientation=Kt.Horizontal:e.stylesheet.otherSystemsTrackNameOrientation=Kt.Vertical;break;case"System/ExtendedBarLines":e.stylesheet.extendBarLines=s;break;case"Header/Title":L.getOrCreateHeaderFooterStyle(e,H.Title).template=s;break;case"Header/TitleAlignment":L.getOrCreateHeaderFooterStyle(e,H.Title).textAlign=this._toTextAlign(s);break;case"Header/drawTitle":L.getOrCreateHeaderFooterStyle(e,H.Title).isVisible=s;break;case"Header/Subtitle":L.getOrCreateHeaderFooterStyle(e,H.SubTitle).template=s;break;case"Header/SubtitleAlignment":L.getOrCreateHeaderFooterStyle(e,H.SubTitle).textAlign=this._toTextAlign(s);break;case"Header/drawSubtitle":L.getOrCreateHeaderFooterStyle(e,H.SubTitle).isVisible=s;break;case"Header/Artist":L.getOrCreateHeaderFooterStyle(e,H.Artist).template=s;break;case"Header/ArtistAlignment":L.getOrCreateHeaderFooterStyle(e,H.Artist).textAlign=this._toTextAlign(s);break;case"Header/drawArtist":L.getOrCreateHeaderFooterStyle(e,H.Artist).isVisible=s;break;case"Header/Album":L.getOrCreateHeaderFooterStyle(e,H.Album).template=s;break;case"Header/AlbumAlignment":L.getOrCreateHeaderFooterStyle(e,H.Album).textAlign=this._toTextAlign(s);break;case"Header/drawAlbum":L.getOrCreateHeaderFooterStyle(e,H.Album).isVisible=s;break;case"Header/Words":L.getOrCreateHeaderFooterStyle(e,H.Words).template=s;break;case"Header/WordsAlignment":L.getOrCreateHeaderFooterStyle(e,H.Words).textAlign=this._toTextAlign(s);break;case"Header/drawWords":L.getOrCreateHeaderFooterStyle(e,H.Words).isVisible=s;break;case"Header/Music":L.getOrCreateHeaderFooterStyle(e,H.Music).template=s;break;case"Header/MusicAlignment":L.getOrCreateHeaderFooterStyle(e,H.Music).textAlign=this._toTextAlign(s);break;case"Header/drawMusic":L.getOrCreateHeaderFooterStyle(e,H.Music).isVisible=s;break;case"Header/WordsAndMusic":L.getOrCreateHeaderFooterStyle(e,H.WordsAndMusic).template=s;break;case"Header/WordsAndMusicAlignment":L.getOrCreateHeaderFooterStyle(e,H.WordsAndMusic).textAlign=this._toTextAlign(s);break;case"Header/drawWordsAndMusic":L.getOrCreateHeaderFooterStyle(e,H.WordsAndMusic).isVisible=s;break;case"Header/Tabber":L.getOrCreateHeaderFooterStyle(e,H.Transcriber).template=s;break;case"Header/TabberAlignment":L.getOrCreateHeaderFooterStyle(e,H.Transcriber).textAlign=this._toTextAlign(s);break;case"Header/drawTabber":L.getOrCreateHeaderFooterStyle(e,H.Transcriber).isVisible=s;break;case"Footer/Copyright":L.getOrCreateHeaderFooterStyle(e,H.Copyright).template=s;break;case"Footer/CopyrightAlignment":L.getOrCreateHeaderFooterStyle(e,H.Copyright).textAlign=this._toTextAlign(s);break;case"Footer/drawCopyright":L.getOrCreateHeaderFooterStyle(e,H.Copyright).isVisible=s;break;case"Footer/Copyright2":L.getOrCreateHeaderFooterStyle(e,H.CopyrightSecondLine).template=s;break;case"Footer/Copyright2Alignment":L.getOrCreateHeaderFooterStyle(e,H.CopyrightSecondLine).textAlign=this._toTextAlign(s);break;case"Footer/drawCopyright2":L.getOrCreateHeaderFooterStyle(e,H.CopyrightSecondLine).isVisible=s;break;case"System/barIndexDrawType":switch(s){case 0:e.stylesheet.barNumberDis
9play=vt.AllBars;break;case 1:e.stylesheet.barNumberDisplay=vt.FirstOfSystem;break;case 2:e.stylesheet.barNumberDisplay=vt.Hide;break}break}}_toTextAlign(e){switch(e){case 0:return Y.Left;case 1:return Y.Center;case 2:return Y.Right}return Y.Left}addValue(e,t,s){this.raw.set(e,t),s!==void 0&&this._types.set(e,s)}writeTo(e){k.writeInt32BE(e,this.raw.size);for(const[t,s]of this.raw){const i=this._getDataType(t,s);switch(Ae.gpWriteString(e,t),e.writeByte(i),i){case Me.Boolean:e.writeByte(s?1:0);break;case Me.Integer:k.writeInt32BE(e,s);break;case Me.Float:k.writeFloat32BE(e,s);break;case Me.String:const r=k.stringToBytes(s);k.writeInt16BE(e,r.length),e.write(r,0,r.length);break;case Me.Point:k.writeInt32BE(e,s.offset),k.writeInt32BE(e,s.value);break;case Me.Size:k.writeInt32BE(e,s.offset),k.writeInt32BE(e,s.value);break;case Me.Rectangle:k.writeInt32BE(e,s.x),k.writeInt32BE(e,s.y),k.writeInt32BE(e,s.w),k.writeInt32BE(e,s.h);break;case Me.Color:e.writeByte(s.r),e.writeByte(s.g),e.writeByte(s.b),e.writeByte(s.a);break}}}_getDataType(e,t){if(this._types.has(e))return this._types.get(e);const s=typeof t;switch(typeof t){case"string":return Me.String;case"number":const i=t|0;return t===i?Me.Integer:Me.Float;case"object":if(t instanceof G)return Me.Point;if(t instanceof bt)return Me.Rectangle;if(t instanceof Fe)return Me.Color;break}throw new Ye(Ge.General,`Unknown value type in BinaryStylesheet: ${s}`)}static writeForScore(e){const t=new ys;switch(t.addValue("StandardNotation/hideDynamics",e.stylesheet.hideDynamics,Me.Boolean),t.addValue("System/bracketExtendMode",e.stylesheet.bracketExtendMode,Me.Integer),t.addValue("Global/useSystemSignSeparator",e.stylesheet.useSystemSignSeparator,Me.Boolean),t.addValue("Global/DisplayTuning",e.stylesheet.globalDisplayTuning,Me.Boolean),t.addValue("Global/DrawChords",e.stylesheet.globalDisplayChordDiagramsOnTop,Me.Boolean),t.addValue("System/drawChordInScore",e.stylesheet.globalDisplayChordDiagramsInScore,Me.Boolean),e.stylesheet.singleTrackTrackNamePolicy){case mt.Hidden:t.addValue("System/showTrackNameSingle",!1,Me.Boolean);break;case mt.FirstSystem:t.addValue("System/trackNameModeSingle",0,Me.Integer);break;case mt.AllSystems:t.addValue("System/trackNameModeSingle",2,Me.Integer);break}switch(e.stylesheet.multiTrackTrackNamePolicy){case mt.Hidden:t.addValue("System/showTrackNameMulti",!1,Me.Boolean);break;case mt.FirstSystem:t.addValue("System/trackNameModeMulti",0,Me.Integer);break;case mt.AllSystems:t.addValue("System/trackNameModeMulti",2,Me.Integer);break}switch(e.stylesheet.firstSystemTrackNameMode){case Qt.FullName:t.addValue("System/shortTrackNameOnFirstSystem",!1,Me.Boolean);break;case Qt.ShortName:t.addValue("System/shortTrackNameOnFirstSystem",!0,Me.Boolean);break}switch(e.stylesheet.otherSystemsTrackNameMode){case Qt.FullName:t.addValue("System/shortTrackNameOnOtherSystems",!1,Me.Boolean);break;case Qt.ShortName:t.addValue("System/shortTrackNameOnOtherSystems",!0,Me.Boolean);break}switch(e.stylesheet.firstSystemTrackNameOrientation){case Kt.Horizontal:t.addValue("System/horizontalTrackNameOnFirstSystem",!0,Me.Boolean);break;case Kt.Vertical:t.addValue("System/horizontalTrackNameOnFirstSystem",!1,Me.Boolean);break}switch(e.stylesheet.otherSystemsTrackNameOrientation){case Kt.Horizontal:t.addValue("System/horizontalTrackNameOnOtherSystems",!0,Me.Boolean);break;case Kt.Vertical:t.addValue("System/horizontalTrackNameOnOtherSystems",!1,Me.Boolean);break}t.addValue("System/ExtendedBarLines",e.stylesheet.extendBarLines,Me.Boolean);const s=e.style;if(s)for(const[r,n]of s.headerAndFooter)switch(r){case H.Title:ys._addHeaderAndFooter(t,n,"Header/","Title");break;case H.SubTitle:ys._addHeaderAndFooter(t,n,"Header/","Subtitle");break;case H.Artist:ys._addHeaderAndFooter(t,n,"Header/","Artist");break;case H.Album:ys._addHeaderAndFooter(t,n,"Header/","Album");break;case H.Words:ys._addHeaderAndFooter(t,n,"Header/","Words");break;case H.Music:ys._addHeaderAndFooter(t,n,"Header/","Music");break;case H.WordsAndMusic:ys._addHeaderAndFooter(t,n,"Header/","WordsAndMusic");break;case H.Transcriber:ys._addHeaderAndFooter(t,n,"Header/","Tabber");break;case H.Copyright:ys._addHeaderAndFooter(t,n,"Footer/","Copyright");break;case H.CopyrightSecondLine:ys._addHeaderAndFooter(t,n,"Footer/","Copyright2");break}
9switch(e.stylesheet.barNumberDisplay){case vt.AllBars:t.addValue("System/barIndexDrawType",0,Me.Integer);break;case vt.FirstOfSystem:t.addValue("System/barIndexDrawType",1,Me.Integer);break;case vt.Hide:t.addValue("System/barIndexDrawType",2,Me.Integer);break}const i=gt.withCapacity(128);return t.writeTo(i),i.toArray()}static _addHeaderAndFooter(e,t,s,i){e.addValue(`${s}${i}`,t.template,Me.String),e.addValue(`${s}${i}Alignment`,t.textAlign,Me.Integer),t.isVisible!==void 0&&e.addValue(`${s}draw${i}`,t.isVisible,Me.Boolean)}}class io{rawAudioFile}class Ah{id="";dots=0;tupletDenominator=-1;tupletNumerator=-1;value=y.Quarter}class Ih{name="";path="";role="";get uniqueId(){return`${this.path};${this.name};${this.role}`}program=0;bank=0}class O{static _invalidId="-1";static _bendPointPositionFactor=G.MaxPosition/100;static _bendPointValueFactor=1/25;static _sampleRate=44100;score;_backingTrackAssetId;_masterTrackAutomations;_automationsPerTrackIdAndBarIndex;_sustainPedalsPerTrackIdAndBarIndex;_tracksMapping;_tracksById;_masterBars;_barsOfMasterBar;_barsById;_voicesOfBar;_voiceById;_beatsOfVoice;_rhythmOfBeat;_beatById;_rhythmById;_noteById;_notesOfBeat;_tappedNotes;_lyricsByTrack;_soundsByTrack;_hasAnacrusis=!1;_articulationByName;_skipApplyLyrics=!1;_backingTrackPadding=0;_doubleBars=new Set;_keySignatures=new Map;loadAsset;parseXml(e,t){this._masterTrackAutomations=new Map,this._automationsPerTrackIdAndBarIndex=new Map,this._sustainPedalsPerTrackIdAndBarIndex=new Map,this._tracksMapping=[],this._tracksById=new Map,this._masterBars=[],this._barsOfMasterBar=[],this._voicesOfBar=new Map,this._barsById=new Map,this._voiceById=new Map,this._beatsOfVoice=new Map,this._beatById=new Map,this._rhythmOfBeat=new Map,this._rhythmById=new Map,this._notesOfBeat=new Map,this._noteById=new Map,this._tappedNotes=new Map,this._lyricsByTrack=new Map,this._soundsByTrack=new Map,this._skipApplyLyrics=!1;const s=new jr;try{s.parse(e)}catch(i){throw new Bt("Could not parse XML",i)}if(this._parseDom(s),this._buildModel(),L.consolidate(this.score),this.score.finish(t),!this._skipApplyLyrics&&this._lyricsByTrack.size>0)for(const[i,r]of this._lyricsByTrack)this._tracksById.get(i).applyLyrics(r)}_parseDom(e){const t=e.firstElement;if(t)if(t.localName==="GPIF"){this.score=new Ks;for(const s of t.childElements())switch(s.localName){case"Score":this._parseScoreNode(s);break;case"MasterTrack":this._parseMasterTrackNode(s);break;case"BackingTrack":this._parseBackingTrackNode(s);break;case"Tracks":this._parseTracksNode(s);break;case"MasterBars":this._parseMasterBarsNode(s);break;case"Bars":this._parseBars(s);break;case"Voices":this._parseVoices(s);break;case"Beats":this._parseBeats(s);break;case"Notes":this._parseNotes(s);break;case"Rhythms":this._parseRhythms(s);break;case"Assets":this._parseAssets(s);break}}else throw new Bt("Root node of XML was not GPIF")}_parseAssets(e){for(const t of e.childElements())t.localName==="Asset"&&t.getAttribute("id")===this._backingTrackAssetId&&this._parseBackingTrackAsset(t)}_parseBackingTrackAsset(e){let t="";for(const i of e.childElements())i.localName==="EmbeddedFilePath"&&(t=i.innerText);const s=this.loadAsset;if(s){const i=s(t);i?this.score.backingTrack.rawAudioFile=i:this.score.backingTrack=void 0}}_parseScoreNode(e){for(const t of e.childElements())switch(t.localName){case"Title":this.score.title=t.innerText;break;case"SubTitle":this.score.subTitle=t.innerText;break;case"Artist":this.score.artist=t.innerText;break;case"Album":this.score.album=t.innerText;break;case"Words":this.score.words=t.innerText;break;case"Music":this.score.music=t.innerText;break;case"WordsAndMusic":const s=t.innerText;s!==""&&(s&&!this.score.words&&(this.score.words=s),s&&!this.score.music&&(this.score.music=s));break;case"Copyright":this.score.copyright=t.innerText;break;case"Tabber":this.score.tab=t.innerText;break;case"Instructions":this.score.instructions=t.innerText;break;case"Notices":this.score.notices=t.innerText;break;case"ScoreSystemsDefaultLayout":this.score.defaultSystemsLayout=O._parseIntSafe(t.innerText,4);break;case"ScoreSystemsLayout":this.score.systemsLayout=O._splitSafe(t.innerText).map(i=>O._parseIntSafe(i,4));break}}static _parseIntSafe(e,t){if(!e)return t;const s=Number.parseInt(e,10);return Number.isNaN(s)?t:s}static _parseFloatSafe(e,t){if(!e)return t;const s=Number.parseFloat(e);return Number.isNaN(s)?t:s}static _splitSafe(e,t=" "){return e?e.split(t).map(s=>s.trim()).filter(s=>s.length>0):[]}_parseBackingTrackNode(e){const t=new io;let s=!1,i="",r="";for(const n of e.childElements())switch(n.localName){case"Enabled":s=n.innerText==="true";break;case"Source":i=n.innerText;break;case"AssetId":r=n.innerText;break;case"FramePadding":this._backingTrackPadding=O._parseIntSafe(n.innerText,0)/O._sampleRate*1e3;break}s&&i==="Local"&&(this.score.backingTrack=t,this._backingTrackAssetId=r)}_parseMasterTrackNode(e){for(const t of e.childElements())switch(t.localName){case"Automations":this._parseAutomations(t,this._masterTrackAutomations,null,null);break;case"Tracks":this._tracksMapping=O._splitSafe(t.innerText);break;
9case"Anacrusis":this._hasAnacrusis=!0;break}}_parseAutomations(e,t,s,i){for(const r of e.childElements())r.localName==="Automation"&&this._parseAutomation(r,t,s,i)}_parseAutomation(e,t,s,i){let r=null,n=!1,o=-1,l=0,h=0,c=null,d=0,f=null,p,g=!0;for(const b of e.childElements())switch(b.localName){case"Type":r=b.innerText;break;case"Linear":n=b.innerText.toLowerCase()==="true";break;case"Bar":o=O._parseIntSafe(b.innerText,0);break;case"Position":l=O._parseFloatSafe(b.innerText,0);break;case"Value":if(b.firstElement&&b.firstElement.nodeType===ht.CDATA)c=b.innerText;else if(b.firstElement&&b.firstElement.nodeType===ht.Element&&r==="SyncPoint"){p=new ra;for(const S of b.childElements())switch(S.localName){case"BarIndex":o=O._parseIntSafe(S.innerText,0);break;case"BarOccurrence":p.barOccurence=O._parseIntSafe(S.innerText,0);break;case"FrameOffset":const N=O._parseFloatSafe(S.innerText,0);p.millisecondOffset=N/O._sampleRate*1e3;break}}else{const S=O._splitSafe(b.innerText);S.length===1?(h=O._parseFloatSafe(S[0],0),d=1):(h=O._parseFloatSafe(S[0],0),d=O._parseIntSafe(S[1],0))}break;case"Text":f=b.innerText;break;case"Visible":g=b.innerText.toLowerCase()==="true";break}if(!r)return;const m=[];switch(r){case"Tempo":m.push(tt.buildTempoAutomation(n,l,h,d,g));break;case"SyncPoint":const b=new tt;b.type=Re.SyncPoint,b.isLinear=n,b.ratioPosition=l,b.syncPointValue=p,b.isVisible=g,m.push(b);break;case"Sound":if(c&&s&&s.has(c)){const S=new tt;S.type=Re.Bank,S.ratioPosition=l,S.value=s.get(c).bank,S.isVisible=g,m.push(S);const N=tt.buildInstrumentAutomation(n,l,s.get(c).program);m.push(N)}break;case"SustainPedal":if(i){let S;i.has(o)?S=i.get(o):(S=[],i.set(o,S));const N=new _i;switch(N.ratioPosition=l,d){case 1:N.pedalType=it.Down;break;case 3:N.pedalType=it.Up;break}S.push(N)}break}if(m.length){if(f)for(const b of m)b.text=f;if(o>=0){t.has(o)||t.set(o,[]);for(const b of m)t.get(o).push(b)}}}_parseTracksNode(e){for(const t of e.childElements())t.localName==="Track"&&this._parseTrack(t)}_parseTrack(e){this._articulationByName=new Map;const t=new Zs;t.ensureStaveCount(1);const s=t.staves[0];s.showStandardNotation=!0;const i=e.getAttribute("id");for(const r of e.childElements())switch(r.localName){case"Name":t.name=r.innerText;break;case"Color":const n=O._splitSafe(r.innerText);if(n.length>=3){const h=O._parseIntSafe(n[0],0),c=O._parseIntSafe(n[1],0),d=O._parseIntSafe(n[2],0);t.color=new Fe(h,c,d,255)}break;case"Instrument":const o=r.getAttribute("ref");(o.endsWith("-gs")||o.endsWith("GrandStaff"))&&(t.ensureStaveCount(2),t.staves[1].showStandardNotation=!0);break;case"InstrumentSet":this._parseInstrumentSet(t,r);break;case"NotationPatch":this._parseNotationPatch(t,r);break;case"ShortName":t.shortName=r.innerText;break;case"SystemsDefautLayout":t.defaultSystemsLayout=O._parseIntSafe(r.innerText,4);break;case"SystemsLayout":t.systemsLayout=O._splitSafe(r.innerText).map(h=>O._parseIntSafe(h,4));break;case"Lyrics":this._parseLyrics(i,r);break;case"Properties":this._parseTrackProperties(t,r);break;case"GeneralMidi":case"MidiConnection":case"MIDISettings":this._parseGeneralMidi(t,r);break;case"Sounds":this._parseSounds(i,t,r);break;case"PlaybackState":const l=r.innerText;t.playbackInfo.isSolo=l==="Solo",t.playbackInfo.isMute=l==="Mute";break;case"PartSounding":this._parsePartSounding(i,t,r);break;case"Staves":this._parseStaves(t,r);break;case"Transpose":this._parseTranspose(i,t,r);break;case"RSE":this._parseRSE(t,r);break;case"Automations":this._parseTrackAutomations(i,r);break}this._tracksById.set(i,t)}_parseTrackAutomations(e,t){const s=new Map;this._automationsPerTrackIdAndBarIndex.set(e,s);const i=new Map;this._sustainPedalsPerTrackIdAndBarIndex.set(e,i),this._parseAutomations(t,s,this._soundsByTrack.get(e),i)}_parseNotationPatch(e,t){for(const s of t.childElements())switch(s.localName){case"LineCount":const i=O._parseIntSafe(s.innerText,5);for(const r of e.staves)r.standardNotationLineCount=i;break;case"Elements":this._parseElements(e,s,!1);break}}_parseInstrumentSet(e,t){for(const s of t.childElements())switch(s.localName){case"Type":if(s.innerText==="drumKit")for(const r of e.staves)r.isPercussion=!0;break;case"Elements":this._parseElements(e,s,!0);break;case"LineCount":const i=O._parseIntSafe(s.innerText,5);for(const r of e.staves)r.standardNotationLineCount=i;break}}_parseElements(e,t,s){for(const i of t.childElements())i.localName==="Element"&&this._parseElement(e,i,s)}_parseElement(e,t,s){const i=t.findChildElement("Name")?.innerText??"";for(const r of t.childElements())switch(r.localName){case"Name":case"Articulations":this._parseArticulations(e,r,s,i);break}}_parseArticulations(e,t,s,i){for(const r of t.childElements())r.localName==="Articulation"&&this._parseArticulation(e,r,s,i)}_parseArticulation(e,t,s,i){const r=new X;r.outputMidiNumber=-1,r.elementType=i;let n="";for(const l of t.childElements()){const h=l.innerText;switch(l.localName){case"Name":n=l.innerText;break;case"InputMidiNumbers":r.id=O._parseIntSafe(h.split(" ")[0],0);break;case"OutputMidiNumber":r.outputMidiNumber=O._parseIntSafe(h,0);break;case"TechniqueSymbol":r.techniqueSymbol=O.parseTechniqueSymbol(h);break;case"TechniquePlacement":r.techniqueSymbolPlacement=O.parseTechniqueSymbolPlacement(h);break;case"Noteheads":const c=O._splitSafe(h);c.length>=1&&(r.noteHeadDefault=O.parseNoteHead(c[0])),c.length>=2&&(r.noteHeadHalf=O.parseNoteHead(c[1])),c.length>=3&&(r.noteHeadWhole=O.parseNoteHead(c[2])),r.noteHeadHalf===u.None&&(r.noteHeadHalf=r.noteHeadDefault),r.noteHeadWhole===u.None&&(r.noteHeadWhole=r.noteHeadDefault);break;case"StaffLine":r.staffLine=O._parseIntSafe(h,0);break}}const o=`${i}.${n}`;s?(e.percussionArticulations.push(r),this._articulationByName.set(o,r)):this._articulationByName.has(o)&&(this._articulationByName.get(o).staffLine=r.staffLine)}static parseTechniqueSymbol(e){switch(e){case"pictEdgeOfCymbal":return u.PictEdgeOfCymbal;case"articStaccatoAbove":return u.ArticStaccatoAbove;case"noteheadParenthesis":return u.NoteheadParenthesis;case"stringsUpBow":return u.StringsUpBow;case"stringsDownBow":return u.StringsDownBow;case"guitarGolpe":return u.GuitarGolpe;default:return u.None}}static parseTechniqueSymbolPlacement(e){switch(e){case"outside":return $e.Outside;case"inside":return $e.Inside;case"above":return $e.Above;case"below":return $e.Below;default:return $e.Outside}}static parseNoteHead(e){switch(e){case"noteheadDoubleWholeSquare":return u.NoteheadDoubleWholeSquare;case"noteheadDoubleWhole":return u.NoteheadDoubleWhole;case"noteheadWhole":return u.NoteheadWhole;case"noteheadHalf":return u.NoteheadHalf;case"noteheadBlack":return u.NoteheadBlack;case"noteheadNull":return u.NoteheadNull;case"noteheadXOrnate":return u.NoteheadXOrnate;case"noteheadTriangleUpWhole":return u.NoteheadTriangleUpWhole;case"noteheadTriangleUpHalf":return u.NoteheadTriangleUpHalf;
9case"noteheadTriangleUpBlack":return u.NoteheadTriangleUpBlack;case"noteheadDiamondBlackWide":return u.NoteheadDiamondBlackWide;case"noteheadDiamondWhite":return u.NoteheadDiamondWhite;case"noteheadDiamondWhiteWide":return u.NoteheadDiamondWhiteWide;case"noteheadCircleX":return u.NoteheadCircleX;case"noteheadXWhole":return u.NoteheadXWhole;case"noteheadXHalf":return u.NoteheadXHalf;case"noteheadXBlack":return u.NoteheadXBlack;case"noteheadParenthesis":return u.NoteheadParenthesis;case"noteheadSlashedBlack2":return u.NoteheadSlashedBlack2;case"noteheadCircleSlash":return u.NoteheadCircleSlash;case"noteheadHeavyX":return u.NoteheadHeavyX;case"noteheadHeavyXHat":return u.NoteheadHeavyXHat;default:return E.warning("GPIF","Unknown notehead symbol",e),u.None}}_parseStaves(e,t){let s=0;for(const i of t.childElements())if(i.localName==="Staff"){e.ensureStaveCount(s+1);const r=e.staves[s];this._parseStaff(r,i),s++}}_parseStaff(e,t){for(const s of t.childElements())s.localName==="Properties"&&this._parseStaffProperties(e,s)}_parseStaffProperties(e,t){for(const s of t.childElements())s.localName==="Property"&&this._parseStaffProperty(e,s)}_parseStaffProperty(e,t){switch(t.getAttribute("name")){case"Tuning":for(const r of t.childElements())switch(r.localName){case"Pitches":const n=O._splitSafe(t.findChildElement("Pitches")?.innerText),o=new Array(n.length);for(let l=0;l<o.length;l++)o[o.length-1-l]=O._parseIntSafe(n[l],0);e.stringTuning.tunings=o;break;case"Label":e.stringTuning.name=r.innerText;break}e.isPercussion||(e.showTablature=!0);break;case"DiagramCollection":case"ChordCollection":this._parseDiagramCollectionForStaff(e,t);break;case"CapoFret":const i=O._parseIntSafe(t.findChildElement("Fret")?.innerText,0);e.capo=i;break}}_parseLyrics(e,t){const s=[];for(const i of t.childElements())i.localName==="Line"&&s.push(this._parseLyricsLine(i));this._lyricsByTrack.set(e,s)}_parseLyricsLine(e){const t=new es;for(const s of e.childElements())switch(s.localName){case"Offset":t.startBar=O._parseIntSafe(s.innerText,0);break;case"Text":t.text=s.innerText;break}return t}_parseDiagramCollectionForTrack(e,t){const s=t.findChildElement("Items");if(s)for(const i of s.childElements())i.localName==="Item"&&this._parseDiagramItemForTrack(e,i)}_parseDiagramCollectionForStaff(e,t){const s=t.findChildElement("Items");if(s)for(const i of s.childElements())i.localName==="Item"&&this._parseDiagramItemForStaff(e,i)}_parseDiagramItemForTrack(e,t){const s=new Bi,i=t.getAttribute("id");for(const r of e.staves)r.addChord(i,s);this._parseDiagramItemForChord(s,t)}_parseDiagramItemForStaff(e,t){const s=new Bi,i=t.getAttribute("id");e.addChord(i,s),this._parseDiagramItemForChord(s,t)}_parseDiagramItemForChord(e,t){e.name=t.getAttribute("name");const s=t.findChildElement("Diagram");if(!s){e.showDiagram=!1,e.showFingering=!1;return}const i=O._parseIntSafe(s.getAttribute("stringCount"),6),r=O._parseIntSafe(s.getAttribute("baseFret"),0);e.firstFret=r+1;for(let n=0;n<i;n++)e.strings.push(-1);for(const n of s.childElements())switch(n.localName){case"Fret":const o=O._parseIntSafe(n.getAttribute("string"),0);e.strings[i-o-1]=r+O._parseIntSafe(n.getAttribute("fret"),0);break;case"Fingering":const l=new Map;for(const h of n.childElements())switch(h.localName){case"Position":let c=ie.Unknown;const d=r+O._parseIntSafe(h.getAttribute("fret"),0);switch(h.getAttribute("finger")){case"Index":c=ie.IndexFinger;break;case"Middle":c=ie.MiddleFinger;break;case"Rank":c=ie.AnnularFinger;break;case"Pinky":c=ie.LittleFinger;break;case"Thumb":c=ie.Thumb;break}c!==ie.Unknown&&(l.has(c)?e.barreFrets.push(d):l.set(c,!0));break}break;case"Property":switch(n.getAttribute("name")){case"ShowName":e.showName=n.getAttribute("value")==="true";break;case"ShowDiagram":e.showDiagram=n.getAttribute("value")==="true";break;case"ShowFingering":e.showFingering=n.getAttribute("value")==="true";break}break}}_parseTrackProperties(e,t){for(const s of t.childElements())s.localName==="Property"&&this._parseTrackProperty(e,s)}_parseTrackProperty(e,t){switch(t.getAttribute("name")){case"Tuning":const i=O._splitSafe(t.findChildElement("Pitches")?.innerText),r=new Array(i.length);for(let o=0;o<r.length;o++)r[r.length-1-o]=O._parseIntSafe(i[o],0);
9for(const o of e.staves)o.stringTuning.tunings=r,o.showStandardNotation=!0,o.showTablature=!0;break;case"DiagramCollection":case"ChordCollection":this._parseDiagramCollectionForTrack(e,t);break;case"CapoFret":const n=O._parseIntSafe(t.findChildElement("Fret")?.innerText,0);for(const o of e.staves)o.capo=n;break}}_parseGeneralMidi(e,t){for(const i of t.childElements())switch(i.localName){case"Program":e.playbackInfo.program=O._parseIntSafe(i.innerText,0);break;case"Port":e.playbackInfo.port=O._parseIntSafe(i.innerText,0);break;case"PrimaryChannel":e.playbackInfo.primaryChannel=O._parseIntSafe(i.innerText,0);break;case"SecondaryChannel":e.playbackInfo.secondaryChannel=O._parseIntSafe(i.innerText,0);break}if(t.getAttribute("table")==="Percussion")for(const i of e.staves)i.isPercussion=!0}_parseSounds(e,t,s){for(const i of s.childElements())i.localName==="Sound"&&this._parseSound(e,t,i)}_parseSound(e,t,s){const i=new Ih;for(const r of s.childElements())switch(r.localName){case"Name":i.name=r.innerText;break;case"Path":i.path=r.innerText;break;case"Role":i.role=r.innerText;break;case"MIDI":this._parseSoundMidi(i,r);break}this._soundsByTrack.has(e)||(this._soundsByTrack.set(e,new Map),t.playbackInfo.program=i.program,t.playbackInfo.bank=i.bank),this._soundsByTrack.get(e).set(i.uniqueId,i)}_parseSoundMidi(e,t){let s=0,i=0;for(const r of t.childElements())switch(r.localName){case"Program":e.program=O._parseIntSafe(r.innerText,0);break;case"MSB":s=O._parseIntSafe(r.innerText,0);break;case"LSB":i=O._parseIntSafe(r.innerText,0);break}e.bank=(s&127)<<7|i}_parsePartSounding(e,t,s){for(const i of s.childElements())switch(i.localName){case"TranspositionPitch":for(const n of t.staves)n.displayTranspositionPitch=O._parseIntSafe(i.innerText,0);break;case"NominalKey":const r=Math.max(0,I.noteNames.indexOf(i.innerText));this._transposeKeySignaturePerTrack.set(e,r);break}}_transposeKeySignaturePerTrack=new Map;_parseTranspose(e,t,s){let i=0,r=0;for(const l of s.childElements())switch(l.localName){case"Chromatic":r=O._parseIntSafe(l.innerText,0);break;case"Octave":i=O._parseIntSafe(l.innerText,0);break}const n=i*12+r;for(const l of t.staves)l.displayTranspositionPitch=n;const o=L.flooredDivision(n,12);this._transposeKeySignaturePerTrack.set(e,o)}_parseRSE(e,t){for(const s of t.childElements())s.localName==="ChannelStrip"&&this._parseChannelStrip(e,s)}_parseChannelStrip(e,t){for(const s of t.childElements())s.localName==="Parameters"&&this._parseChannelStripParameters(e,s)}_parseChannelStripParameters(e,t){if(t.firstChild&&t.firstChild.value){const s=O._splitSafe(t.firstChild.value);s.length>=12&&(e.playbackInfo.balance=Math.floor(O._parseFloatSafe(s[11],.5)*16),e.playbackInfo.volume=Math.floor(O._parseFloatSafe(s[12],.9)*16))}}_parseMasterBarsNode(e){for(const t of e.childElements())t.localName==="MasterBar"&&this._parseMasterBar(t)}_parseMasterBar(e){const t=new Qs;this._masterBars.length===0&&this._hasAnacrusis&&(t.isAnacrusis=!0);for(const s of e.childElements())switch(s.localName){case"Time":const i=s.innerText.split("/");t.timeSignatureNumerator=O._parseIntSafe(i[0],4),t.timeSignatureDenominator=O._parseIntSafe(i[1],4);break;case"FreeTime":t.isFreeTime=!0;break;case"DoubleBar":t.isDoubleBar=!0,this._doubleBars.add(t);break;case"Section":t.section=new Tr,t.section.marker=s.findChildElement("Letter")?.innerText??"",t.section.text=s.findChildElement("Text")?.innerText??"";break;case"Repeat":s.getAttribute("start").toLowerCase()==="true"&&(t.isRepeatStart=!0),s.getAttribute("end").toLowerCase()==="true"&&s.getAttribute("count")&&(t.repeatCount=O._parseIntSafe(s.getAttribute("count"),1));break;case"AlternateEndings":const r=O._splitSafe(s.innerText);let n=0;for(let c=0;c<r.length;c++)n=n|1<<-1+O._parseIntSafe(r[c],0);t.alternateEndings=n;break;case"Bars":this._barsOfMasterBar.push(O._splitSafe(s.innerText));break;case"TripletFeel":switch(s.innerText){case"NoTripletFeel":t.tripletFeel=Ce.NoTripletFeel;break;case"Triplet8th":t.tripletFeel=Ce.Triplet8th;break;case"Triplet16th":t.tripletFeel=Ce.Triplet16th;break;case"Dotted8th":t.tripletFeel=Ce.Dotted8th;break;case"Dotted16th":t.tripletFeel=Ce.Dotted16th;break;case"Scottish8th":t.tripletFeel=Ce.Scottish8th;break;case"Scottish16th":t.tripletFeel=Ce.Scottish16th;break}break;case"Key":const o=O._parseIntSafe(s.findChildElement("AccidentalCount")?.innerText,0),l=s.findChildElement("Mode");let h=as.Major;if(l)switch(l.innerText.toLowerCase()){case"major":h=as.Major;break;case"minor":h=as.Minor;break}this._keySignatures.set(this._masterBars.length,[o,h]);break;case"Fermatas":this._parseFermatas(t,s);break;
9case"XProperties":this._parseMasterBarXProperties(t,s);break;case"Directions":this._parseDirections(t,s);break}this._masterBars.push(t)}_parseDirections(e,t){for(const s of t.childElements())switch(s.localName){case"Target":switch(s.innerText){case"Coda":e.addDirection(U.TargetCoda);break;case"DoubleCoda":e.addDirection(U.TargetDoubleCoda);break;case"Segno":e.addDirection(U.TargetSegno);break;case"SegnoSegno":e.addDirection(U.TargetSegnoSegno);break;case"Fine":e.addDirection(U.TargetFine);break}break;case"Jump":switch(s.innerText){case"DaCapo":e.addDirection(U.JumpDaCapo);break;case"DaCapoAlCoda":e.addDirection(U.JumpDaCapoAlCoda);break;case"DaCapoAlDoubleCoda":e.addDirection(U.JumpDaCapoAlDoubleCoda);break;case"DaCapoAlFine":e.addDirection(U.JumpDaCapoAlFine);break;case"DaSegno":e.addDirection(U.JumpDalSegno);break;case"DaSegnoAlCoda":e.addDirection(U.JumpDalSegnoAlCoda);break;case"DaSegnoAlDoubleCoda":e.addDirection(U.JumpDalSegnoAlDoubleCoda);break;case"DaSegnoAlFine":e.addDirection(U.JumpDalSegnoAlFine);break;case"DaSegnoSegno":e.addDirection(U.JumpDalSegnoSegno);break;case"DaSegnoSegnoAlCoda":e.addDirection(U.JumpDalSegnoSegnoAlCoda);break;case"DaSegnoSegnoAlDoubleCoda":e.addDirection(U.JumpDalSegnoSegnoAlDoubleCoda);break;case"DaSegnoSegnoAlFine":e.addDirection(U.JumpDalSegnoSegnoAlFine);break;case"DaCoda":e.addDirection(U.JumpDaCoda);break;case"DaDoubleCoda":e.addDirection(U.JumpDaDoubleCoda);break}break}}_parseFermatas(e,t){for(const s of t.childElements())s.localName==="Fermata"&&this._parseFermata(e,s)}_parseFermata(e,t){let s=0;const i=new Br;for(const r of t.childElements())switch(r.localName){case"Type":switch(r.innerText){case"Short":i.type=os.Short;break;case"Medium":i.type=os.Medium;break;case"Long":i.type=os.Long;break}break;case"Length":i.length=O._parseFloatSafe(r.innerText,0);break;case"Offset":const n=r.innerText.split("/");if(n.length===2){const o=O._parseIntSafe(n[0],4),l=O._parseIntSafe(n[1],4);s=o/l*B.QuarterTime|0}break}e.addFermata(s,i)}_parseBars(e){for(const t of e.childElements())t.localName==="Bar"&&this._parseBar(t)}_parseBar(e){const t=new ns,s=e.getAttribute("id");for(const i of e.childElements())switch(i.localName){case"Voices":this._voicesOfBar.set(s,O._splitSafe(i.innerText));break;case"Clef":switch(i.innerText){case"Neutral":t.clef=ve.Neutral;break;case"G2":t.clef=ve.G2;break;case"F4":t.clef=ve.F4;break;case"C4":t.clef=ve.C4;break;case"C3":t.clef=ve.C3;break}break;case"Ottavia":switch(i.innerText){case"8va":t.clefOttava=le._8va;break;case"15ma":t.clefOttava=le._15ma;break;case"8vb":t.clefOttava=le._8vb;break;case"15mb":t.clefOttava=le._15mb;break}break;case"SimileMark":switch(i.innerText){case"Simple":t.simileMark=xt.Simple;break;case"FirstOfDouble":t.simileMark=xt.FirstOfDouble;break;case"SecondOfDouble":t.simileMark=xt.SecondOfDouble;break}break;
9case"XProperties":this._parseBarXProperties(i,t);break}this._barsById.set(s,t)}_parseVoices(e){for(const t of e.childElements())t.localName==="Voice"&&this._parseVoice(t)}_parseVoice(e){const t=new ks,s=e.getAttribute("id");for(const i of e.childElements())i.localName==="Beats"&&this._beatsOfVoice.set(s,O._splitSafe(i.innerText));this._voiceById.set(s,t)}_parseBeats(e){for(const t of e.childElements())t.localName==="Beat"&&this._parseBeat(t)}_parseBeat(e){const t=new Dt,s=e.getAttribute("id");for(const i of e.childElements())switch(i.localName){case"Notes":this._notesOfBeat.set(s,O._splitSafe(i.innerText));break;case"Rhythm":this._rhythmOfBeat.set(s,i.getAttribute("ref"));break;case"Fadding":switch(i.innerText){case"FadeIn":t.fade=yt.FadeIn;break;case"FadeOut":t.fade=yt.FadeOut;break;case"VolumeSwell":t.fade=yt.VolumeSwell;break}break;case"Tremolo":const r=new Ts;switch(t.tremoloPicking=r,i.innerText){case"1/2":r.marks=1;break;case"1/4":r.marks=2;break;case"1/8":r.marks=3;break}break;case"Chord":t.chordId=i.innerText;break;case"Hairpin":switch(i.innerText){case"Crescendo":t.crescendo=Gt.Crescendo;break;case"Decrescendo":t.crescendo=Gt.Decrescendo;break}break;case"Arpeggio":i.innerText==="Up"?t.brushType=z.ArpeggioUp:t.brushType=z.ArpeggioDown;break;case"Properties":this._parseBeatProperties(i,t);break;
9case"XProperties":this._parseBeatXProperties(i,t);break;case"FreeText":t.text=i.innerText;break;case"TransposedPitchStemOrientation":switch(i.innerText){case"Upward":t.preferredBeamDirection=P.Up;break;case"Downward":t.preferredBeamDirection=P.Down;break}break;case"Dynamic":switch(i.innerText){case"PPP":t.dynamics=se.PPP;break;case"PP":t.dynamics=se.PP;break;case"P":t.dynamics=se.P;break;case"MP":t.dynamics=se.MP;break;case"MF":t.dynamics=se.MF;break;case"F":t.dynamics=se.F;break;case"FF":t.dynamics=se.FF;break;case"FFF":t.dynamics=se.FFF;break}break;case"GraceNotes":switch(i.innerText){case"OnBeat":t.graceType=K.OnBeat;break;case"BeforeBeat":t.graceType=K.BeforeBeat;break}break;case"Legato":i.getAttribute("origin")==="true"&&(t.isLegatoOrigin=!0);break;case"Whammy":const n=new G(0,0);n.value=this._toBendValue(O._parseFloatSafe(i.getAttribute("originValue"),0)),n.offset=this._toBendOffset(O._parseFloatSafe(i.getAttribute("originOffset"),0)),t.addWhammyBarPoint(n);const o=new G(0,0);o.value=this._toBendValue(O._parseFloatSafe(i.getAttribute("middleValue"),0)),o.offset=this._toBendOffset(O._parseFloatSafe(i.getAttribute("middleOffset1"),0)),t.addWhammyBarPoint(o);const l=new G(0,0);l.value=this._toBendValue(O._parseFloatSafe(i.getAttribute("middleValue"),0)),l.offset=this._toBendOffset(O._parseFloatSafe(i.getAttribute("middleOffset2"),0)),t.addWhammyBarPoint(l);const h=new G(0,0);h.value=this._toBendValue(O._parseFloatSafe(i.getAttribute("destinationValue"),0)),h.offset=this._toBendOffset(O._parseFloatSafe(i.getAttribute("destinationOffset"),0)),t.addWhammyBarPoint(h);break;case"Ottavia":switch(i.innerText){case"8va":t.ottava=le._8va;break;case"8vb":t.ottava=le._8vb;break;case"15ma":t.ottava=le._15ma;break;case"15mb":t.ottava=le._15mb;break}break;case"Lyrics":t.lyrics=this._parseBeatLyrics(i),this._skipApplyLyrics=!0;break;case"Slashed":t.slashed=!0;break;case"DeadSlapped":t.deadSlapped=!0;break;case"Golpe":switch(i.innerText){case"Finger":t.golpe=Xt.Finger;break;case"Thumb":t.golpe=Xt.Thumb;break}break;case"Wah":switch(i.innerText){case"Open":t.wahPedal=ss.Open;break;case"Closed":t.wahPedal=ss.Closed;break}break;case"UserTransposedPitchStemOrientation":switch(i.innerText){case"Downward":t.preferredBeamDirection=P.Down;break;case"Upward":t.preferredBeamDirection=P.Up;break}break;case"Timer":t.showTimer=!0,t.timer=O._parseIntSafe(i.innerText,-1),t.timer<0&&(t.timer=null);break}this._beatById.set(s,t)}_parseBeatLyrics(e){const t=[];for(const s of e.childElements())s.localName==="Line"&&t.push(s.innerText);return t}_parseBeatXProperties(e,t){for(const s of e.childElements())switch(s.localName){case"XProperty":const i=s.getAttribute("id");let r=0;switch(i){case"1124204546":switch(r=O._parseIntSafe(s.findChildElement("Int")?.innerText,0),r){case 1:t.beamingMode=st.ForceMergeWithNext;break;case 2:t.beamingMode=st.ForceSplitToNext;break}break;case"1124204552":r=O._parseIntSafe(s.findChildElement("Int")?.innerText,0),r===1&&t.beamingMode!==st.ForceSplitToNext&&(t.beamingMode=st.ForceSplitOnSecondaryToNext);break;case"1124204545":r=O._parseIntSafe(s.findChildElement("Int")?.innerText,0),t.invertBeamDirection=r===1;break;case"687935489":r=O._parseIntSafe(s.findChildElement("Int")?.innerText,0),t.brushDuration=r;break}break}}_parseBarXProperties(e,t){for(const s of e.childElements())switch(s.localName){case"XProperty":if(s.getAttribute("id")==="1124139520"){const r=s.findChildElement("Double")??s.findChildElement("Float");t.displayScale=O._parseFloatSafe(r?.innerText,1)}break}}_parseMasterBarXProperties(e,t){let s=Number.NaN,i;for(const r of t.childElements())switch(r.localName){case"XProperty":const n=r.getAttribute("id");switch(n){case"1124073984":e.displayScale=O._parseFloatSafe(r.findChildElement("Double")?.innerText,1);break;case"1124139010":s=O._parseIntSafe(r.findChildElement("Int")?.innerText,Number.NaN);break;default:const o=O._parseIntSafe(n,0);if(o>=1124139264&&o<=1124139295){const l=o-1124139264,h=O._parseIntSafe(r.findChildElement("Int")?.innerText,Number.NaN);for(i===void 0&&(i=[]);i.length<l+1;)i.push(0);i[l]=h}break}break}if(!Number.isNaN(s)&&i){const r=new nt;r.groups.set(s,i),e.beamingRules=r}}_parseBeatProperties(e,t){let s=!1,i=null,r=null,n=null,o=null,l=null;for(const h of e.childElements())switch(h.localName){case"Property":switch(h.getAttribute("name")){case"Brush":h.findC
9hildElement("Direction")?.innerText==="Up"?t.brushType=z.BrushUp:t.brushType=z.BrushDown;break;case"PickStroke":h.findChildElement("Direction")?.innerText==="Up"?t.pickStroke=Ct.Up:t.pickStroke=Ct.Down;break;case"Slapped":h.findChildElement("Enable")&&(t.slap=!0);break;case"Popped":h.findChildElement("Enable")&&(t.pop=!0);break;case"VibratoWTremBar":switch(h.findChildElement("Strength")?.innerText){case"Wide":t.vibrato=Be.Wide;break;case"Slight":t.vibrato=Be.Slight;break}break;case"WhammyBar":s=!0;break;case"WhammyBarExtend":break;case"WhammyBarOriginValue":i||(i=new G(0,0)),i.value=this._toBendValue(O._parseFloatSafe(h.findChildElement("Float")?.innerText,0));break;case"WhammyBarOriginOffset":i||(i=new G(0,0)),i.offset=this._toBendOffset(O._parseFloatSafe(h.findChildElement("Float")?.innerText,0));break;case"WhammyBarMiddleValue":r=this._toBendValue(O._parseFloatSafe(h.findChildElement("Float")?.innerText,0));break;case"WhammyBarMiddleOffset1":n=this._toBendOffset(O._parseFloatSafe(h.findChildElement("Float")?.innerText,0));break;case"WhammyBarMiddleOffset2":o=this._toBendOffset(O._parseFloatSafe(h.findChildElement("Float")?.innerText,0));break;case"WhammyBarDestinationValue":l||(l=new G(G.MaxPosition,0)),l.value=this._toBendValue(O._parseFloatSafe(h.findChildElement("Float")?.innerText,0));break;case"WhammyBarDestinationOffset":l||(l=new G(0,0)),l.offset=this._toBendOffset(O._parseFloatSafe(h.findChildElement("Float")?.innerText,0));break;case"BarreFret":t.barreFret=O._parseIntSafe(h.findChildElement("Fret")?.innerText,0);break;case"BarreString":switch(h.findChildElement("String")?.innerText){case"0":t.barreShape=xs.Full;break;case"1":t.barreShape=xs.Half;break}break;case"Rasgueado":switch(h.findChildElement("Rasgueado")?.innerText){case"ii_1":t.rasgueado=ne.Ii;break;case"mi_1":t.rasgueado=ne.Mi;break;case"mii_1":t.rasgueado=ne.MiiTriplet;break;case"mii_2":t.rasgueado=ne.MiiAnapaest;break;case"pmp_1":t.rasgueado=ne.PmpTriplet;break;case"pmp_2":t.rasgueado=ne.PmpAnapaest;break;case"pei_1":t.rasgueado=ne.PeiTriplet;break;case"pei_2":t.rasgueado=ne.PeiAnapaest;break;case"pai_1":t.rasgueado=ne.PaiTriplet;break;case"pai_2":t.rasgueado=ne.PaiAnapaest;break;case"ami_1":t.rasgueado=ne.AmiTriplet;break;case"ami_2":t.rasgueado=ne.AmiAnapaest;break;case"ppp_1":t.rasgueado=ne.Ppp;break;case"amii_1":t.rasgueado=ne.Amii;break;case"amip_1":t.rasgueado=ne.Amip;break;case"eami_1":t.rasgueado=ne.Eami;break;case"eamii_1":t.rasgueado=ne.Eamii;break;case"peami_1":t.rasgueado=ne.Peami;break}break}break}s&&(i||(i=new G(0,0)),l||(l=new G(G.MaxPosition,0)),t.addWhammyBarPoint(i),n&&r&&t.addWhammyBarPoint(new G(n,r)),o&&r&&t.addWhammyBarPoint(new G(o,r)),!n&&!o&&r&&t.addWhammyBarPoint(new G(G.MaxPosition/2|0,r)),t.addWhammyBarPoint(l))}_parseNotes(e){for(const t of e.childElements())t.localName==="Note"&&this._parseNote(t)}_parseNote(e){const t=new kt,s=e.getAttribute("id");for(const i of e.childElements())switch(i.localName){case"Properties":this._parseNoteProperties(i,t,s);break;case"AntiAccent":i.innerText.toLowerCase()==="normal"&&(t.isGhost=!0);break;case"LetRing":t.isLetRing=!0;break;case"Trill":t.trillValue=O._parseIntSafe(i.innerText,-1),t.trillSpeed=y.Sixteenth;break;case"Accent":const r=O._parseIntSafe(i.innerText,0);(r&1)!==0&&(t.isStaccato=!0),(r&4)!==0&&(t.accentuated=ct.Heavy),(r&8)!==0&&(t.accentuated=ct.Normal),(r&16)!==0&&(t.accentuated=ct.Tenuto);break;case"Tie":i.getAttribute("destination").toLowerCase()==="true"&&(t.isTieDestination=!0);break;case"Vibrato":switch(i.innerText){case"Slight":t.vibrato=Be.Slight;break;case"Wide":t.vibrato=Be.Wide;break}break;case"LeftFingering":switch(i.innerText){case"P":t.leftHandFinger=ie.Thumb;break;case"I":t.leftHandFinger=ie.IndexFinger;break;case"M":t.leftHandFinger=ie.MiddleFinger;break;case"A":t.leftHandFinger=ie.AnnularFinger;break;case"C":t.leftHandFinger=ie.LittleFinger;break}break;case"RightFingering":switch(i.innerText){case"P":t.rightHandFinger=ie.Thumb;break;case"I":t.rightHandFinger=ie.IndexFinger;break;case"M":t.rightHandFinger=ie.MiddleFinger;break;case"A":t.rightHandFinger=ie.AnnularFinger;break;case"C":t.rightHandFinger=ie.LittleFinger;break}break;case"InstrumentArticulation":t.percussionArticulation=O._parseIntSafe(i.innerText,0);break;case"Ornament":switch(i.innerText){case"Turn":t.ornament=ot.Turn;break;case"InvertedTurn":t.ornament=ot.InvertedTurn;break;case"UpperMordent":t.ornament=ot.UpperMordent;break;case"LowerMordent":t.ornament=ot.LowerMordent;break}break}this._noteById.set(s,t)}_parseNoteProperties(e,t,s){let i=!1,r=null,n=null,o=null,l=null,h=null,c=-1,d=-1,f=!1;for(const p of e.childElements())switch(p.localName){case"Property":switch(p.getAttribute("name")){case"ShowStringNumber":p.findC
vendor: 9,960 bytes, line 9
9hildElement("Enable")&&(t.showStringNumber=!0);break;case"String":t.string=O._parseIntSafe(p.findChildElement("String")?.innerText,0)+1;break;case"Fret":t.fret=O._parseIntSafe(p.findChildElement("Fret")?.innerText,0);break;case"Element":c=O._parseIntSafe(p.findChildElement("Element")?.innerText,0);break;case"Variation":d=O._parseIntSafe(p.findChildElement("Variation")?.innerText,0);break;case"Tapped":this._tappedNotes.set(s,!0);break;case"HarmonicType":const m=p.findChildElement("HType");if(m)switch(m.innerText){case"NoHarmonic":t.harmonicType=te.None;break;case"Natural":t.harmonicType=te.Natural;break;case"Artificial":t.harmonicType=te.Artificial;break;case"Pinch":t.harmonicType=te.Pinch;break;case"Tap":t.harmonicType=te.Tap;break;case"Semi":t.harmonicType=te.Semi;break;case"Feedback":t.harmonicType=te.Feedback;break}break;case"HarmonicFret":const b=p.findChildElement("HFret");b&&(t.harmonicValue=O._parseFloatSafe(b.innerText,0));break;case"Muted":p.findChildElement("Enable")&&(t.isDead=!0);break;case"PalmMuted":p.findChildElement("Enable")&&(t.isPalmMute=!0);break;case"Octave":t.octave=O._parseIntSafe(p.findChildElement("Number")?.innerText,0),t.tone===-1&&(t.tone=0);break;case"Tone":t.tone=O._parseIntSafe(p.findChildElement("Step")?.innerText,0);break;case"ConcertPitch":f||this._parseConcertPitch(p,t);break;case"TransposedPitch":t.accidentalMode=oe.Default,this._parseConcertPitch(p,t),f=!0;break;case"Bended":i=!0;break;case"BendOriginValue":r||(r=new G(0,0)),r.value=this._toBendValue(O._parseFloatSafe(p.findChildElement("Float")?.innerText,0));break;case"BendOriginOffset":r||(r=new G(0,0)),r.offset=this._toBendOffset(O._parseFloatSafe(p.findChildElement("Float")?.innerText,0));break;case"BendMiddleValue":n=this._toBendValue(O._parseFloatSafe(p.findChildElement("Float")?.innerText,0));break;case"BendMiddleOffset1":o=this._toBendOffset(O._parseFloatSafe(p.findChildElement("Float")?.innerText,0));break;case"BendMiddleOffset2":l=this._toBendOffset(O._parseFloatSafe(p.findChildElement("Float")?.innerText,0));break;case"BendDestinationValue":h||(h=new G(G.MaxPosition,0)),h.value=this._toBendValue(O._parseFloatSafe(p.findChildElement("Float")?.innerText,0));break;case"BendDestinationOffset":h||(h=new G(0,0)),h.offset=this._toBendOffset(O._parseFloatSafe(p.findChildElement("Float")?.innerText,0));break;case"HopoOrigin":p.findChildElement("Enable")&&(t.isHammerPullOrigin=!0);break;case"HopoDestination":break;case"LeftHandTapped":t.isLeftHandTapped=!0;break;case"Slide":const S=O._parseIntSafe(p.findChildElement("Flags")?.innerText,0);(S&1)!==0?t.slideOutType=he.Shift:(S&2)!==0?t.slideOutType=he.Legato:(S&4)!==0?t.slideOutType=he.OutDown:(S&8)!==0&&(t.slideOutType=he.OutUp),(S&16)!==0?t.slideInType=St.IntoFromBelow:(S&32)!==0&&(t.slideInType=St.IntoFromAbove),(S&64)!==0?t.slideOutType=he.PickSlideDown:(S&128)!==0&&(t.slideOutType=he.PickSlideUp);break}break}i&&(r||(r=new G(0,0)),h||(h=new G(G.MaxPosition,0)),t.addBendPoint(r),o&&n&&t.addBendPoint(new G(o,n)),l&&n&&t.addBendPoint(new G(l,n)),!o&&!l&&n&&t.addBendPoint(new G(G.MaxPosition/2|0,n)),t.addBendPoint(h)),c!==-1&&d!==-1&&(t.percussionArticulation=Xe.articulationFromElementVariation(c,d))}_parseConcertPitch(e,t){const s=e.findChildElement("Pitch");if(s)for(const i of s.childElements())switch(i.localName){case"Accidental":switch(i.innerText){case"x":t.accidentalMode=oe.ForceDoubleSharp;break;case"#":t.accidentalMode=oe.ForceSharp;break;case"b":t.accidentalMode=oe.ForceFlat;break;case"bb":t.accidentalMode=oe.ForceDoubleFlat;break}break}}_toBendValue(e){return e*O._bendPointValueFactor|0}_toBendOffset(e){return e*O._bendPointPositionFactor}_parseRhythms(e){for(const t of e.childElements())t.localName==="Rhythm"&&this._parseRhythm(t)}_parseRhythm(e){const t=new Ah,s=e.getAttribute("id");t.id=s;for(const i of e.childElements())switch(i.localName){case"NoteValue":switch(i.innerText){case"Long":t.value=y.QuadrupleWhole;break;case"DoubleWhole":t.value=y.DoubleWhole;break;case"Whole":t.value=y.Whole;break;case"Half":t.value=y.Half;break;case"Quarter":t.value=y.Quarter;break;case"Eighth":t.value=y.Eighth;break;case"16th":t.value=y.Sixteenth;break;case"32nd":t.value=y.ThirtySecond;break;case"64th":t.value=y.SixtyFourth;break;case"128th":t.value=y.OneHundredTwentyEighth;break;case"256th":t.value=y.TwoHundredFiftySixth;break}break;case"PrimaryTuplet":t.tupletNumerator=O._parseIntSafe(i.getAttribute("num"),-1),t.tupletDenominator=O._parseIntSafe(i.getAttribute("den"),-1);break;case"AugmentationDot":t.dots=O._parseIntSafe(i.getAttribute("count"),0);break}this._rhythmById.set(s,t)}_buildModel(){for(let i=0,r=this._masterBars.length;i<r;i++){const n=this._masterBars[i];this.score.addMasterBar(n)}const e=this._masterBars[this._masterBars.length-1];this._doubleBars.has(e)&&(this._doubleBars.delete(e),e.isDoubleBar=!1);const t=[];for(const i of this._tracksMapping){if(!i)continue;const r=this._tracksById.get(i);this.score.addTrack(r),t.push(i)}let s;for(const i of this._barsOfMasterBar){let r=0,n=0;s=[qe.C,as.Major],this._transposeKeySignaturePerTrack.has(t[0])&&(s=[L.transposeKey(s[0],this._transposeKeySignaturePerTrack.get(t[0])),s[1]]);for(let o=0;o<i.length&&n<this.score.tracks.length;o++){const l=i[o];if(l!==O._invalidId){const h=this._barsById.get(l),c=this.score.tracks[n],d=c.staves[r];d.addBar(h);const f=d.bars.length-1;if(this._keySignatures.has(f)&&(s=this._keySignatures.get(f),this._transposeKeySignaturePerTrack.has(t[n])&&(s=[L.transposeKey(s[0],this._transposeKeySignaturePerTrack.get(t[n])),s[1]])),h.keySignature=s[0],h.keySignatureType=s[1],this._doubleBars.has(h.masterBar)&&(h.barLineRight=ye.LightLight),this._voicesOfBar.has(l))for(const p of this._voicesOfBar.get(l))if(p!==O._invalidId){const g=this._voiceById.get(p);if(h.addVoice(g),this._beatsOfVoice.has(p)){for(const m of this._beatsOfVoice.get(p))if(m!==O._invalidId){const b=Zn.clone(this._beatById.get(m));g.addBeat(b);const S=this._rhythmOfBeat.get(m),N=this._rhythmById.get(S);if(b.duration=N.value,b.dots=N.dots,b.tupletNumerator=N.tupletNumerator,b.tupletDenominator=N.tupletDenominator,this._notesOfBeat.has(m)){for(const v of this._notesOfBeat.get(m))if(v!==O._invalidId){const W=Xl.clone(this._noteById.get(v));d.isPercussion?(W.fret=-1,W.string=-1):W.percussionArticulation=-1,b.addNote(W),this._tappedNotes.has(v)&&(b.tap=!0)}}}}}else{const g=new ks;h.addVoice(g);const m=new Dt;m.isEmpty=!0,m.duration=y.Quarter,g.addBeat(m)}r===c.staves.length-1?(n++,r=0):r++,s=[qe.C,as.Major],n<t.length&&this._transposeKeySignaturePerTrack.has(t[n])&&(s=[L.transposeKey(s[0],this._transposeKeySignaturePerTrack.get(t[n])),s[1]])}else n++}}for(const i of this._tracksMapping){if(!i)continue;const r=this._tracksById.get(i);let n=!1;for(const o of r.staves)if(o.isPercussion){n=!0;break}if(n||(r.percussionArticulations=[]),this._automationsPerTrackIdAndBarIndex.has(i)){const o=this._automationsPerTrackIdAndBarIndex.get(i);for(const[l,h]of o)if(r.staves.length>0&&l<r.staves[0].bars.length){const c=r.staves[0].bars[l];if(c.voices.length>0&&c.voices[0].beats.length>0){const d=c.voices[0].beats[0];for(const f of h)f.type===Re.Bank&&f.value===0&&c.index===0||d.automations.push(f)}}}if(this._sustainPedalsPerTrackIdAndBarIndex.has(i)){const o=this._sustainPedalsPerTrackIdAndBarIndex.get(i);for(const[l,h]of o)if(r.staves.length>0&&l<r.staves[0].bars.length){const c=r.staves[0].bars[l];c.sustainPedals=h}}}for(const[i,r]of this._masterTrackAutomations){const n=this.score.masterBars[i];for(let o=0,l=r.length;o<l;o++){const h=r[o];switch(h.type){case Re.Tempo:n.tempoAutomations.push(h);break;case Re.SyncPoint:h.syncPointValue.millisecondOffset-=this._backingTrackPadding,n.addSyncPoint(h);break}}}}}class Dn{isMultiRest=!1;trackViewGroups=[]}class tl{showNumbered=!1;showSlash=!1;showStandardNotation=!1;showTablature=!1}class ro{scoreViews=[];apply(e){if(this.scoreViews.length>0){let t=0;e.stylesheet.multiTrackMultiBarRest=this.scoreViews[0].isMultiRest;for(const s of this.scoreViews[0].trackViewGroups){if(t<e.tracks.length){const i=e.tracks[t];for(const r of i.staves)r.isPercussion||(r.showTablature=s.showTablature),r.showStandardNotation=s.showStandardNotation,r.showSlash=s.showSlash,r.showNumbered=s.showNumbered}t++}for(let s=1;s<this.scoreViews.length;s++)this.scoreViews[s].isMultiRest&&(e.stylesheet.perTrackMultiBarRest||(e.stylesheet.perTrackMultiBarRest=new Set),t=s-1,e.stylesheet.perTrackMultiBarRest.add(t))}}constructor(e){const t=gt.fromBuffer(e),s=k.readInt32BE(t);for(let i=0;i<s;i++){const r=new Dn;this.scoreViews.push(r),r.isMultiRest=Ae.gpReadBool(t);const n=k.readInt32BE(t);for(let o=0;o<n;o++){let l=t.readByte();l===0&&(l=1);const h=new tl;h.showStandardNotation=(l&1)!==0,h.showTablature=(l&2)!==0,h.showSlash=(l&4)!==0,h.showNumbered=(l&8)!==0,r.trackViewGroups.push(h)}}}static writeForScore(e){const t=gt.withCapacity(128),s=[new Dn];s[0].isMultiRest=e.stylesheet.multiTrackMultiBarRest;for(const i of e.tracks){const r=new tl;r.showStandardNotation=i.staves[0].showStandardNotation,r.showTablature=i.staves[0].showTablature,r.showSlash=i.staves[0].showSlash,r.showNumbered=i.staves[0].showNumbered,s[0].trackViewGroups.push(r);const n=new Dn;n.isMultiRest=e.stylesheet.perTrackMultiBarRest?.has(i.index)===!0,n.trackViewGroups.push(r),s.push(n)}k.writeInt32BE(t,s.length);for(const i of s){t.writeByte(i.isMultiRest?1:0),k.writeInt32BE(t,i.trackViewGroups.length);for(const r of i.trackViewGroups){let n=0;r.showStandardNotation&&(n=n|1),r.showTablature&&(n=n|2),r.showSlash&&(n=n|4),r.showNumbered&&(n=n|8),t.writeByte(n)}}return k.writeInt32BE(t,1),t.toArray()}}class Rh{trackViewGroups=[]}class Oh{isVisible=!1}var Vn;(function(a){a[a.PageVertical=0]="PageVertical",a[a.PageGrid=1]="PageGrid",a[a.PageParchment=2]="PageParchment",a[a.ScreenVertical=3]="ScreenVertical",a[a.ScreenHorizontal=4]="ScreenHorizontal",a[a.PageHorizontal=5]="PageHorizontal"})(Vn||(Vn={}));class ao{zoomLevel=4;view=Vn.PageVertical;
9muiltiVoiceCursor=!1;scoreViews=[];constructor(e,t){const s=gt.fromBuffer(t);this.zoomLevel=k.readInt32BE(s),this.view=s.readByte(),this.muiltiVoiceCursor=s.readByte()!==0;const i=e.scoreViews.length;for(let r=0;r<i;r++){const n=new Rh;this.scoreViews.push(n);const o=e.scoreViews[r];for(let l=0;l<o.trackViewGroups.length;l++){const h=new Oh;h.isVisible=s.readByte()!==0,n.trackViewGroups.push(h)}}}apply(e){if(this.scoreViews.length>0){let t=0;for(const s of this.scoreViews[0].trackViewGroups){if(t<e.tracks.length){const i=e.tracks[t];i.isVisibleOnMultiTrack=s.isVisible}t++}}}static writeForScore(e){const t=gt.withCapacity(128);k.writeInt32BE(t,4),t.writeByte(0);const s=e.tracks.length>0&&e.tracks[0].staves[0].bars[0].isMultiVoice;t.writeByte(s?255:0);for(const i of e.tracks)t.writeByte(i.isVisibleOnMultiTrack?255:0);for(const i of e.tracks)t.writeByte(255);return t.toArray()}}class Wh extends sr{get name(){return"Guitar Pro 7-8"}readScore(){E.debug(this.name,"Loading ZIP entries");const e=new to(this.data);let t;try{t=e.read()}catch(d){throw new Bt("No Zip archive",d)}E.debug(this.name,"Zip entries loaded");let s=null,i=null,r=null,n=null;const o=new Map;for(const d of t)switch(o.set(d.fullName,d),d.fileName){case"score.gpif":s=k.toString(d.data,this.settings.importer.encoding);break;case"BinaryStylesheet":i=d.data;break;case"PartConfiguration":r=d.data;break;case"LayoutConfiguration":n=d.data;break}if(!s)throw new Bt("No score.gpif found in zip archive");E.debug(this.name,"Start Parsing score.gpif");const l=new O;l.loadAsset=d=>{if(o.has(d))return o.get(d).data},l.parseXml(s,this.settings),E.debug(this.name,"score.gpif parsed");const h=l.score;i&&(E.debug(this.name,"Start Parsing BinaryStylesheet"),new ys(i).apply(h),E.debug(this.name,"BinaryStylesheet parsed"));let c=null;return r&&(E.debug(this.name,"Start Parsing Part Configuration"),c=new ro(r),c.apply(h),E.debug(this.name,"Part Configuration parsed")),n&&c!=null&&(E.debug(this.name,"Start Parsing Layout Configuration"),new ao(c,n).apply(h),E.debug(this.name,"Layout Configuration parsed")),h}}class Hn extends Ye{constructor(){super(Ge.Format,"Unexpected end of data within reader")}}class Sa{static _byteSize=8;_currentByte=0;_position=Sa._byteSize;_source;constructor(e){this._source=e}readByte(){return this.readBits(8)}readBytes(e){const t=new Uint8Array(e);for(let s=0;s<e;s++)t[s]=this.readByte()&255;return t}readBits(e){let t=0,s=e-1;for(;s>=0;)t=t|this.readBit()<<s,s--;return t}readBitsReversed(e){let t=0;for(let s=0;s<e;s++)t=t|this.readBit()<<s;return t}readBit(){if(this._position>=8){if(this._currentByte=this._source.readByte(),this._currentByte===-1)throw new Hn;this._position=0}const e=this._currentByte>>Sa._byteSize-this._position-1&1;return this._position++,e}readAll(){const e=gt.empty();try{for(;;)e.writeByte(this.readByte()&255)}catch(t){if(!(t instanceof Hn))throw t}return e.toArray()}}class Vh{fileName="";fileSize=0;data=null}class Hh{static HeaderBcFs="BCFS";static HeaderBcFz="BCFZ";fileFilter;files=[];constructor(){this.files=[],this.fileFilter=e=>!0}load(e){const t=new Sa(e);this._readBlock(t)}readHeader(e){return this._getString(e.readBytes(4),0,4)}decompress(e,t=!1){const s=gt.empty();let i;const r=this._getInteger(e.readBytes(4),0);try{for(;s.length<r;)if(e.readBits(1)===1){const d=e.readBits(4),f=e.readBitsReversed(d),p=e.readBitsReversed(d),g=s.length-f,m=Math.min(f,p);i=s.getBuffer(),s.write(i,g,m)}else{const d=e.readBitsReversed(2);for(let f=0;f<d;f++)s.writeByte(e.readByte())}}catch(c){if(!(c instanceof Hn))throw c}i=s.getBuffer();const n=t?4:0,o=s.length-n,l=new Uint8Array(o),h=o;return l.set(i.subarray(n,n+h),0),l}_readBlock(e){const t=this.readHeader(e);if(t==="BCFZ")this._readUncompressedBlock(this.decompress(e,!0));else if(t==="BCFS")this._readUncompressedBlock(e.readAll());else throw new Bt("Unsupported format")}_readUncompressedBlock(e){let s=4096;for(;s+3<e.length;){if(this._getInteger(e,s)===2){const r=new Vh;r.fileName=this._getString(e,s+4,127),r.fileSize=this._getInteger(e,s+140);const n=!this.fileFilter||this.fileFilter(r.fileName);n&&this.files.push(r);const o=s+148;let l=0,h=0;const c=n?gt.withCapacity(r.fileSize):null;for(;l=this._getInteger(e,o+4*h++),l!==0;)s=l*4096,n&&c.write(e,s,4096);if(n){r.data=new Uint8Array(Math.min(r.fileSize,c.length));const d=c.toArray();r.data.set(d.subarray(0,0+r.data.length),0)}}s+=4096}}
9_getString(e,t,s){let i="";for(let r=0;r<s;r++){const n=e[t+r]&255;if(n===0)break;i+=String.fromCharCode(n)}return i}_getInteger(e,t){return e[t+3]<<24|e[t+2]<<16|e[t+1]<<8|e[t]}}class Gh extends sr{get name(){return"Guitar Pro 6"}readScore(){E.debug(this.name,"Loading GPX filesystem");const e=new Hh;e.fileFilter=h=>h.endsWith("score.gpif")||h.endsWith("BinaryStylesheet")||h.endsWith("PartConfiguration")||h.endsWith("LayoutConfiguration"),e.load(this.data),E.debug(this.name,"GPX filesystem loaded");let t=null,s=null,i=null,r=null;for(const h of e.files)switch(h.fileName){case"score.gpif":t=k.toString(h.data,this.settings.importer.encoding);break;case"BinaryStylesheet":s=h.data;break;case"PartConfiguration":i=h.data;break;case"LayoutConfiguration":r=h.data;break}if(!t)throw new Bt("No score.gpif found in GPX");E.debug(this.name,"Start Parsing score.gpif");const n=new O;n.parseXml(t,this.settings),E.debug(this.name,"score.gpif parsed");const o=n.score;s&&(E.debug(this.name,"Start Parsing BinaryStylesheet"),new ys(s).apply(o),E.debug(this.name,"BinaryStylesheet parsed"));let l=null;return i&&(E.debug(this.name,"Start Parsing Part Configuration"),l=new ro(i),l.apply(o),E.debug(this.name,"Part Configuration parsed")),r&&l!=null&&(E.debug(this.name,"Start Parsing Layout Configuration"),new ao(l,r).apply(o),E.debug(this.name,"Layout Configuration parsed")),o}}class Uh{maxSteps=-1e3;maxStepsNote=null;minSteps=-1e3;minStepsNote=null}class qt{_bar;_barRenderer;static _stepsPerOctave=7;static _octaveSteps=[38,32,30,26,38];static sharpNoteSteps=[0,0,1,1,2,3,3,4,4,5,5,6];static flatNoteSteps=[0,1,1,2,2,3,4,4,5,5,6,6];_registeredAccidentals=new Map;_appliedScoreSteps=new Map;_appliedScoreStepsByValue=new Map;_notesByValue=new Map;_beatSteps=new Map;maxStepsBeat=null;minStepsBeat=null;maxSteps=-1e3;minSteps=-1e3;constructor(e){this._barRenderer=e,this._bar=e.bar}static getPercussionSteps(e){return Xe.getArticulation(e)?.staffLine??0}static getNoteValue(e){let t=e.displayValue;switch(e.accidentalMode){case oe.ForceDoubleFlat:t+=2;break;case oe.ForceDoubleSharp:t-=2;break;case oe.ForceFlat:t+=1;break;case oe.ForceSharp:t-=1;break}return t}applyAccidental(e){const t=qt.getNoteValue(e),s=e.hasQuarterToneOffset;return this._getAccidental(t,s,e.beat,!1,e)}applyAccidentalForValue(e,t,s,i){return this._getAccidental(t,s,e,i,null)}static computeStepsWithoutAccidentals(e,t){let s=0;const i=qt.getNoteValue(t);return t.isPercussion?s=qt.getPercussionSteps(t):s=qt.calculateNoteSteps(e.keySignature,e.clef,i),s}_getAccidental(e,t,s,i,r=null){let n=0,o=ee.None;if(r!=null?r.isPercussion:!1)n=qt.getPercussionSteps(r);else{const h=r?r.accidentalMode:oe.Default;n=qt.calculateNoteSteps(this._bar.keySignature,this._bar.clef,e);const c=this._registeredAccidentals.has(n)?this._registeredAccidentals.get(n):null;o=L.computeAccidental(this._bar.keySignature,h,e,t,c);let d=!1;switch(o){case ee.NaturalQuarterNoteUp:case ee.SharpQuarterNoteUp:case ee.FlatQuarterNoteUp:break;default:if(r&&r.isTieDestination&&r.beat.index===0){const f=this._barRenderer.scoreRenderer.layout?.getRendererForBar(this._barRenderer.staff.staffId,r.tieOrigin.beat.voice.bar);f&&f.staff===this._barRenderer.staff&&f.accidentalHelper.getNoteSteps(r.tieOrigin)===n&&(d=!0)}d?o=ee.None:o!==ee.None&&this._registeredAccidentals.set(n,o);break}}return r?(this._appliedScoreSteps.set(r.id,n),this._notesByValue.set(e,r)):this._appliedScoreStepsByValue.set(e,n),(this.minSteps===-1e3||this.minSteps<n)&&(this.minSteps=n,this.minStepsBeat=s),(this.maxSteps===-1e3||this.maxSteps>n)&&(this.maxSteps=n,this.maxStepsBeat=s),i||this._registerSteps(s,n,r),o}_registerSteps(e,t,s){let i;this._beatSteps.has(e.id)?i=this._beatSteps.get(e.id):(i=new Uh,this._beatSteps.set(e.id,i)),(i.minSteps===-1e3||t<i.minSteps)&&(i.minSteps=t,i.minStepsNote=s),(i.minSteps===-1e3||t>i.maxSteps)&&(i.maxSteps=t,i.maxStepsNote=s)}getMaxSteps(e){return this._beatSteps.has(e.id)?this._beatSteps.get(e.id).maxSteps:0}getMaxStepsNote(e){return this._beatSteps.has(e.id)?this._beatSteps.get(e.id).maxStepsNote:null}getMinSteps(e){return this._beatSteps.has(e.id)?this._beatSteps.get(e.id).minSteps:0}getMinStepsNote(e){return this._beatSteps.has(e.id)?this._beatSteps.get(e.id).minStepsNote:null}static calculateNoteSteps(e,t,s){const i=s,r=e,n=t,o=i%12,l=(i/12|0)-1;let h=qt._octaveSteps[n];h-=l*qt._stepsPerOctave;
9const c=L.keySignatureIsSharp(r)||L.keySignatureIsNatural(r)?qt.sharpNoteSteps:qt.flatNoteSteps;return h-=c[o],h}getNoteSteps(e){return this._appliedScoreSteps.get(e.id)}getNoteStepsForValue(e,t=!1){return this._appliedScoreStepsByValue.has(e)?this._appliedScoreStepsByValue.get(e):t&&this._notesByValue.has(e)?this.getNoteSteps(this._notesByValue.get(e)):0}}class zh{slurStarts;currentDynamics=se.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}}class Yh extends X{outputMidiChannel=-1;outputMidiProgram=-1;outputMidiBank=-1;outputVolume=-1;outputBalance=-1}class no{track;firstArticulation;instruments=new Map;_instrumentIdToArticulationIndex=new Map;_lyricsLine=0;_lyricsLines=new Map;constructor(e){this.track=e}getLyricLine(e){if(this._lyricsLines.has(e))return this._lyricsLines.get(e);const t=this._lyricsLine;return this._lyricsLines.set(e,t),this._lyricsLine++,t}static _defaultNoteArticulation=X.create(0,"Default",0,0,u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole);getOrCreateArticulation(e,t){const s=t.octave*12+t.tone,i=`${e}_${s}`;if(this._instrumentIdToArticulationIndex.has(i))return this._instrumentIdToArticulationIndex.get(i);let r;this.instruments.has(e)?r=this.instruments.get(e):r=no._defaultNoteArticulation;const n=this.track.percussionArticulations.length,o=t.beat.voice.bar;let l;s===0?l=4:l=qt.calculateNoteSteps(o.keySignature,o.clef,s);const d=9-(t.beat.voice.bar.staff.standardNotationLineCount*2-1),f=l-d,p=X.create(r.id,r.elementType,f,r.outputMidiNumber,r.noteHeadDefault,r.noteHeadHalf,r.noteHeadWhole,r.techniqueSymbol,r.techniqueSymbolPlacement);return this._instrumentIdToArticulationIndex.set(i,n),this.track.percussionArticulations.push(p),n}}class Ze extends sr{_score;_idToTrackInfo=new Map;_indexToTrackInfo=new Map;_staffToContext=new Map;_currentBarNumberDisplayPart;_currentBarNumberDisplayBar;_divisionsPerQuarterNote=1;_currentDynamics=se.F;get name(){return"MusicXML"}readScore(){const e=this._extractMusicXml(),t=new jr;try{t.parse(e)}catch(s){throw new Bt("Unsupported format",s)}return this._score=new Ks,this._score.stylesheet.hideDynamics=!0,this._parseDom(t),L.consolidate(this._score),this._score.finish(this.settings),this._score.rebuildRepeatGroups(),this._score}_extractMusicXml(){const e=new to(this.data);let t;try{t=e.read()}catch{t=[]}if(t.length===0)return this.data.reset(),k.toString(this.data.readAll(),this.settings.importer.encoding);const s=t.find(h=>h.fullName==="META-INF/container.xml");if(!s)throw new Bt("No compressed MusicXML");const i=new jr;try{i.parse(k.toString(s.data,this.settings.importer.encoding))}catch(h){throw new Bt("Malformed container.xml, could not parse as XML",h)}const r=i.firstElement;if(!r||r.localName!=="container")throw new Bt("Malformed container.xml, root element not 'container'");const n=r.findChildElement("rootfiles");if(!n)throw new Bt("Malformed container.xml, 'container/rootfiles' not found");let o="";for(const h of n.childElements())if(h.localName==="rootfile"){o=h.getAttribute("full-path");break}if(!o)throw new Bt("Unsupported compressed MusicXML, missing rootfile");const l=t.find(h=>h.fullName===o);if(!l)throw new Bt(`Malformed container.xml, '${o}' not contained in zip`);return k.toString(l.data,this.settings.importer.encoding)}_parseDom(e){const t=e.firstElement;if(!t)throw new Bt("Unsupported format");switch(t.localName){case"score-partwise":this._parsePartwise(t);break;case"score-timewise":this._parseTimewise(t);break;default:throw new Bt("Unsupported format")}}_parsePartwise(e){for(const t of e.childElements())switch(t.localName){case"credit":this._parseCredit(t);break;case"identification":this._parseIdentification(t);break;case"movement-title":this._parseMovementTitle(t);break;case"part":this._parsePartwisePart(t);break;case"part-list":this._parsePartList(t);break;case"work":this._parseWork(t);break}}_parseTimewise(e){let t=0;for(const s of e.childElements())switch(s.localName){case"credit":this._parseCredit(s);break;case"identification":this._parseIdentification(s);break;case"movement-title":this._parseMovementTitle(s);break;case"part-list":this._parsePartList(s);break;case"work":this._parseWork(s);break;case"measure":this._parseTimewiseMeasure(s,t),t++;break}}_parseCredit(e){if(e.getAttribute("page","1")!=="1")return;const t=[];let s=null,i="";for(const r of e.childElements())switch(r.localName){case"credit-type":t.push(r.innerText);break;case"credit-words":s===null&&(s=r),i+=r.innerText;break}if(t.length>0)for(const r of t)switch(r){case"title":this._score.title=Ze._sanitizeDisplay(i);break;case"subtitle":this._score.subTitle=Ze._sanitizeDisplay(i);break;case"composer":this._score.artist=Ze._sanitizeDisplay(i);break;case"arranger":this._score.artist=Ze._sanitizeDisplay(i);break;case"lyricist":this._score.words=Ze._sanitizeDisplay(i);break;case"rights":this._score.copyright=Ze._sanitizeDisplay(i);break}else if(s){const r=s.getAttribute("font-size","0"),n=s.getAttribute("font-size","top"),o=s.getAttribute("halign","left");if(n==="top"){if(i.includes("copyright")||i.includes("Copyright")||i.includes("©")||i.includes("(c)")||i.includes("(C)")){this._score.copyright=Ze._sanitizeDisplay(i);return}if(o==="center"||r==="center"){if(this._score.title.length===0){this._score.title=Ze._sanitizeDisplay(i);return}if(this._score.subTitle.length===0){this._score.subTitle=Ze._sanitizeDisplay(i);return}if(this._score.album.length===0){this._score.album=Ze._sanitizeDisplay(i);return}}else if((o==="right"||r==="right")&&this._score.music.length===0){this._score.music=Ze._sanitizeDisplay(i);return}if(this._score.artist.length===0){this._score.artist=Ze._sanitizeDisplay(i);return}if(this._score.words.length===0){this._score.words=Ze._sanitizeDisplay(i);return}}}}static _sanitizeDisplay(e){return e.replaceAll("\r","").replaceAll(`
10`," ").replaceAll("	","  ").replaceAll(" "," ")}_parseIdentification(e){for(const t of e.childElements())switch(t.localName){case"creator":if(t.attributes.has("type"))switch(t.attributes.get("type")){case"composer":this._score.artist=Ze._sanitizeDisplay(t.innerText);break;case"lyricist":this._score.words=Ze._sanitizeDisplay(t.innerText);break;case"arranger":this._score.music=Ze._sanitizeDisplay(t.innerText);break}else this._score.artist=Ze._sanitizeDisplay(t.innerText);break;case"rights":this._score.copyright.length>0&&(this._score.copyright+=", "),this._score.copyright+=t.innerText,t.attributes.has("type")&&(this._score.copyright+=` (${t.attributes.get("type")})`);break;case"encoding":this._parseEncoding(t);break}}_parseEncoding(e){for(const t of e.childElements())switch(t.localName){case"encoder":this._score.tab.length>0&&(this._score.tab+=", "),this._score.tab+=t.innerText,t.attributes.has("type")&&(this._score.tab+=` (${t.attributes.get("type")})`);break;case"encoding-description":this._score.notices+=Ze._sanitizeDisplay(t.innerText);break}}_parseMovementTitle(e){this._score.title.length===0?this._score.title=Ze._sanitizeDisplay(e.innerText):this._score.subTitle=Ze._sanitizeDisplay(e.innerText)}_parsePartList(e){for(const t of e.childElements())t.localName==="score-part"&&this._parseScorePart(t)}_parseScorePart(e){const t=new Zs;t.ensureStaveCount(1),this._score.addTrack(t);const s=e.attributes.get("id"),i=new no(t);this._idToTrackInfo.set(s,i),this._indexToTrackInfo.set(t.index,i);for(const r of e.childElements())switch(r.localName){case"part-name":t.name=Ze._sanitizeDisplay(r.innerText);break;case"part-name-display":t.name=this._parsePartDisplayAsText(r);break;case"part-abbreviation":t.shortName=Ze._sanitizeDisplay(r.innerText);break;case"part-abbreviation-display":t.shortName=this._parsePartDisplayAsText(r);break;case"score-instrument":this._parseScoreInstrument(r,i);break;case"midi-device":r.attributes.has("port")&&(t.playbackInfo.port=Number.parseInt(r.attributes.get("port"),10));break;case"midi-instrument":this._parseScorePartMidiInstrument(r,i);break}i.firstArticulation&&(i.firstArticulation.outputMidiProgram>=0&&(t.playbackInfo.program=i.firstArticulation.outputMidiProgram),i.firstArticulation.outputMidiBank>=0&&(t.playbackInfo.bank=i.firstArticulation.outputMidiBank),i.firstArticulation.outputBalance>=0&&(t.playbackInfo.balance=i.firstArticulation.outputBalance),i.firstArticulation.outputVolume>=0&&(t.playbackInfo.volume=i.firstArticulation.outputVolume),i.firstArticulation.outputMidiChannel>=0&&(t.playbackInfo.primaryChannel=i.firstArticulation.outputMidiChannel,t.playbackInfo.secondaryChannel=i.firstArticulation.outputMidiChannel))}_parseScoreInstrument(e,t){const s=new Yh;t.firstArticulation||(t.firstArticulation=s),t.instruments.set(e.getAttribute("id",""),s)}_parseScorePartMidiInstrument(e,t){const s=e.getAttribute("id","");if(!t.instruments.has(s))return;const i=t.instruments.get(s);for(const r of e.childElements())switch(r.localName){case"midi-channel":i.outputMidiChannel=Number.parseInt(r.innerText,10)-1;break;case"midi-bank":i.outputMidiBank=Number.parseInt(r.innerText,10)-1;break;case"midi-program":i.outputMidiProgram=Number.parseInt(r.innerText,10)-1;break;case"midi-unpitched":i.outputMidiNumber=Number.parseInt(r.innerText,10)-1;break;case"volume":i.outputVolume=Ze._interpolatePercent(Number.parseFloat(r.innerText));break;case"pan":i.outputBalance=Ze._interpolatePan(Number.parseFloat(r.innerText));break}i.id=Xe.tryMatchKnownArticulation(i),i.id<0&&(i.id=0)}static _interpolatePercent(e){return Ze._interpolate(0,100,0,16,e)|0}static _interpolatePan(e){return Ze._interpolate(-90,90,0,16,e)|0}static _interpolate(e,t,s,i,r){const n=(r-e)/(t-e);return s+(i-s)*n}_parsePartDisplayAsText(e){let t="";for(const s of e.childElements())switch(s.localName){case"display-text":t+=s.innerText;break;case"accidental-text":switch(s.innerText){case"sharp":t+="♯";break;case"natural":t+="♮";break;case"flat":t+="♭";break;case"double-sharp":t+="𝄪";break;case"sharp-sharp":t+="♯♯";break;case"flat-flat":t+="𝄫";break;case"natural-sharp":t+="♮♯";break;case"natural-flat":t+="♮♭";break;case"sharp-down":t+="𝄱";break;case"sharp-up":t+="𝄰";break;case"natural-down":t+="𝄯";break;
10case"natural-up":t+="𝄮";break;case"flat-down":t+="𝄭";break;case"flat-up":t+="𝄬";break;case"arrow-down":t+="↓";break;case"arrow-up":t+="↑";break;case"triple-sharp":t+="♯𝄪";break;case"triple-flat":t+="𝄬𝄬𝄬";break;case"sharp-1":t+="♯¹";break;case"sharp-2":t+="♯²";break;case"sharp-3":t+="♯³";break;case"sharp-4":t+="♯⁴";break;case"sharp-5":t+="♯⁵";break;case"flat-1":t+="♭¹";break;case"flat-2":t+="♭²";break;case"flat-3":t+="♭³";break;case"flat-4":t+="♭⁴";break;case"flat-5":t+="♭⁵";break}break}return Ze._sanitizeDisplay(t)}_parseWork(e){for(const t of e.childElements())t.localName==="work-title"&&(this._score.title=Ze._sanitizeDisplay(t.innerText))}_parsePartwisePart(e){const t=e.attributes.get("id");if(!t||!this._idToTrackInfo.has(t))return;const s=this._idToTrackInfo.get(t).track;let i=0;for(const r of e.childElements())r.localName==="measure"&&(this._parsePartwiseMeasure(r,s,i),i++);this._currentBarNumberDisplayPart=void 0}_parsePartwiseMeasure(e,t,s){const i=this._getOrCreateMasterBar(e,s),r=e.attributes.get("implicit")==="yes";this._parsePartMeasure(e,i,t,r,!0),this._currentBarNumberDisplayBar=void 0}_parseTimewiseMeasure(e,t){const s=this._getOrCreateMasterBar(e,t),i=e.attributes.get("implicit")==="yes";for(const r of e.childElements())switch(r.localName){case"part":this._parseTimewisePart(r,s,i),this._currentBarNumberDisplayPart=void 0;break;case"print":this._parsePrint(r,s,void 0,!0);break}this._currentBarNumberDisplayBar=void 0}_getOrCreateMasterBar(e,t){const s=e.attributes.get("implicit")==="yes";for(;this._score.masterBars.length<=t;){const r=new Qs;s&&(r.isAnacrusis=!0),this._score.addMasterBar(r),r.index>0&&(r.timeSignatureDenominator=r.previousMasterBar.timeSignatureDenominator,r.timeSignatureNumerator=r.previousMasterBar.timeSignatureNumerator,r.tripletFeel=r.previousMasterBar.tripletFeel)}return this._score.masterBars[t]}_parseTimewisePart(e,t,s){const i=e.attributes.get("id");if(!i||!this._idToTrackInfo.has(i))return;const r=this._idToTrackInfo.get(i).track;this._parsePartMeasure(e,t,r,s,!1)}_musicalPosition=0;_lastBeat=null;_parsePartMeasure(e,t,s,i,r){this._musicalPosition=0,this._lastBeat=null,t.alternateEndings=this._nextMasterBarRepeatEnding;const n=[];for(const h of e.childElements())switch(h.localName){case"note":this._parseNote(h,t,s);break;case"backup":this._parseBackup(h);break;case"forward":this._parseForward(h);break;case"direction":this._parseDirection(h,t,s);break;case"attributes":this._parseAttributes(h,t,s);break;case"harmony":this._parseHarmony(h,s);break;case"print":this._parsePrint(h,t,s,!0);break;case"sound":this._parseSound(h,t,s);break;case"barline":n.push(h);break}for(const h of n)this._parseBarLine(h,t,s);this._applySimileMarks(t,s);const o=this._getOrCreateStaff(s,0),l=this._getOrCreateBar(o,t);i?l.barNumberDisplay=vt.Hide:r?l.barNumberDisplay=this._currentBarNumberDisplayBar??this._currentBarNumberDisplayPart:l.barNumberDisplay=this._currentBarNumberDisplayPart??this._currentBarNumberDisplayBar,this._keyAllStaves=null}_parsePrint(e,t,s,i){s!==void 0&&(e.getAttribute("new-system","no")==="yes"||e.getAttribute("new-page","no")==="yes")&&s.addLineBreaks(t.index);let r;for(const n of e.childElements())switch(n.localName){case"measure-numbering":switch(n.innerText){case"none":r=vt.Hide;break;case"measure":r=vt.AllBars;break;case"system":r=vt.FirstOfSystem;break}break}i?this._currentBarNumberDisplayBar=r:this._currentBarNumberDisplayPart=r}_applySimileMarks(e,t){if(this._simileMarkAllStaves!==null){for(const s of t.staves){const i=this._getOrCreateBar(s,e);i.simileMark=this._simileMarkAllStaves,i.simileMark!==xt.None&&this._clearBar(i)}this._simileMarkAllStaves===xt.FirstOfDouble?this._simileMarkAllStaves=xt.SecondOfDouble:this._simileMarkAllStaves=null}if(this._simileMarkPerStaff!==null){const s=Array.from(this._simileMarkPerStaff.keys());for(const i of s){const r=this._getOrCreateStaff(t,i),n=this._getOrCreateBar(r,e);n.simileMark=this._simileMarkPerStaff.get(i),n.simileMark!==xt.None&&this._clearBar(n),n.simileMark===xt.FirstOfDouble?this._simileMarkPerStaff.set(i,xt.SecondOfDouble):this._simileMarkPerStaff.delete(i)}this._simileMarkPerStaff.size===0&&(this._simileMarkPerStaff=null)}}_clearBar(e){for(const t of e.voices){const s=new Dt;s.isEmpty=!0,t.addBeat(s)}}_parseBarLine(e,t,s){for(const i of e.childElements())switch(i.localName){case"bar-style":this._parseBarStyle(i,t,s,e.getAttribute("location","right"));break;case"ending":this._parseEnding(i,t);break;case"repeat":this._parseRepeat(i,t);break}}_parseRepeat(e,t){const s=e.getAttribute("direction");let i=Number.parseInt(e.getAttribute("times"),10);(i<0||Number.isNaN(i))&&(i=2),s==="backward"?t.repeatCount=i:s==="forward"&&(t.isRepeatStart=!0)}_nextMasterBarRepeatEnding=0;_parseEnding(e,t){const s=e.getAttribute("number").split(",").map(r=>Number.parseInt(r,10));let i=0;for(const r of s)i=i|1<<r-1&255;switch(t.alternateEndings=i,e.getAttribute("type","")){case"start":this._nextMasterBarRepeatEnding=this._nextMasterBarRepeatEnding|i;break;case"stop":case"discontinue":this._nextMasterBarRepeatEnding=this._nextMasterBarRepeatEnding&~i;break}}_parseBarStyle(e,t,s,i){let r=ye.Automatic;switch(e.innerText){case"dashed":r=ye.Dashed;break;case"dotted":r=ye.Dotted;break;case"heavy":r=ye.Heavy;break;case"heavy-heavy":r=ye.HeavyHeavy;break;case"heavy-light":r=ye.HeavyLight;break;case"light-heavy":r=ye.LightHeavy;break;case"light-light":r=ye.LightLight;break;case"none":r=ye.None;break;case"regular":r=ye.Regular;break;case"short":r=ye.Short;break;case"tick":r=ye.Tick;break}for(const n of s.staves){const o=this._getOrCreateBar(n,t);switch(i){case"left":o.barLineLeft=r;break;case"right":o.barLineRight=r;break}}}_parseSound(e,t,s){for(const i of e.childElements())switch(i.localName){case"midi-instrument":this._parseSoundMidiInstrument(i,t);break;case"swing":this._parseSwing(i,t);break}if(e.attributes.has("coda")&&t.addDirection(U.TargetCoda),e.attributes.has("tocoda")&&t.addDirection(U.JumpDaCoda),e.attributes.has("dacapo")&&t.addDirection(U.JumpDaCapo),e.attributes.has("dalsegno")&&t.addDirection(U.JumpDalSegno),e.attributes.has("fine")&&t.addDirection(U.TargetFine),e.attributes.has("segno")&&t.addDirection(U.TargetSegno),e.attributes.has("pan")){this._nextBeatAutomations||(this._nextBeatAutomations=[]);const i=new tt;i.type=Re.Balance,i.value=Ze._interpolatePan(Number.parseFloat(e.attributes.get("pan"))),this._nextBeatAutomations.push(i)}if(e.attributes.has("tempo")){this._nextBeatAutomations||(this._nextBeatAutomations=[]);const i=new tt;i.type=Re.Tempo,i.value=Ze._interpolatePercent(Number.parseFloat(e.attributes.get("tempo"))),this._nextBeatAutomations.push(i)}}_parseSwing(e,t){let s=0,i=0,r=null;for(const n of e.childElements())switch(n.localName){case"straight":t.tripletFeel=Ce.NoTripletFeel;return;case"first":s=Number.parseInt(n.innerText,10);break;case"second":i=Number.parseInt(n.innerText,10);break;case"swing-type":r=this._parseBeatDuration(n);break}r||(r=y.Eighth),r===y.Eighth?s===2&&i===1?t.tripletFeel=Ce.Triplet8th:s===3&&i===1?t.tripletFeel=Ce.Dotted8th:s===1&&i===3&&(t.tripletFeel=Ce.Scottish8th):r===y.Sixteenth&&(s===2&&i===1?t.tripletFeel=Ce.Triplet16th:s===3&&i===1?t.tripletFeel=Ce.Dotted16th:s===1&&i===3&&(t.tripletFeel=Ce.Scottish16th))}_nextBeatAutomations=null;_nextBeatChord=null;_nextBeatCrescendo=null;_nextBeatLetRing=!1;_nextBeatPalmMute=!1;_nextBeatOttavia=null;_nextBeatText=null;_parseSoundMidiInstrument(e,t){let s;for(const i of e.childElements())switch(i.localName){case"midi-bank":this._nextBeatAutomations||(this._nextBeatAutomations=[]),s=new tt,s.type=Re.Bank,s.value=Number.parseInt(i.innerText,10)-1,this._nextBeatAutomations.push(s);break;case"midi-program":this._nextBeatAutomations||(this._nextBeatAutomations=[]),s=new tt,s.type=Re.Instrument,s.value=Number.parseInt(i.innerText,10)-1,this._nextBeatAutomations.push(s);break;case"volume":this._nextBeatAutomations||(this._nextBeatAutomations=[]),s=new tt,s.type=Re.Volume,s.value=Ze._interpolatePercent(Number.parseFloat(i.innerText)),this._nextBeatAutomations.push(s);break;case"pan":this._nextBeatAutomations||(this._nextBeatAutomations=[]),s=new tt,s.type=Re.Balance,s.value=Ze._interpolatePan(Number.parseFloat(i.innerText)),this._nextBeatAutomations.push(s);break}}_parseHarmony(e,t){const s=new Bi;let i=!1,r="";for(const n of e.childElements())switch(n.localName){case"root":s.name=this._parseHarmonyRoot(n);break;case"kind":s.name=s.name+this._parseHarmonyKind(n),n.getAttribute("parentheses-degrees","no")==="yes"&&(i=!0);break;case"frame":this._parseHarmonyFrame(n,s);break;case"degree":r+=this._parseDegree(n);break}r&&(s.name+=i?`(${r})`:r),e.getAttribute("print-frame","no")==="yes"&&(s.showDiagram=!0,this._score.stylesheet.globalDisplayChordDiagramsInScore=!0),e.getAttribute("print-object","yes")==="yes"&&(s.showDiagram=!0),this._nextBeatChord===null&&(this._nextBeatChord=s)}_parseDegree(e){let t="",s="",i="";for(const r of e.childElements())switch(r.localName){case"degree-value":t=r.innerText;break;case"degree-alter":switch(r.innerText){case"-1":s="♭";break;case"1":s="♯";break}break;case"degree-type":i+=r.getAttribute("text","");break}return`${i}${s}${t}`}_parseHarmonyRoot(e){let t="",s="";for(const i of e.childElements())switch(i.localName){case"root-step":t=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="##";break}break}return t+s}_parseHarmonyKind(e){const t=e.getAttribute("text");let s="";if(t)s=t;else{const i=e.innerText;switch(i){case"major":s="";break;case"minor":s="m";break;case"augmented":s="+";break;
10case"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":s="Fr⁺⁶";break;case"German":s="Fr⁺⁶";break;default:s=i;break}}return s}_parseHarmonyFrame(e,t){for(const s of e.childElements())switch(s.localName){case"frame-strings":const i=Number.parseInt(s.innerText,10);t.strings=new Array(i);for(let o=0;o<i;o++)t.strings[o]=-1;break;case"first-fret":t.firstFret=Number.parseInt(s.innerText,10);break;case"frame-note":let r=null,n=null;for(const o of s.childElements())switch(o.localName){case"string":r=Number.parseInt(o.innerText,10);break;case"fret":n=Number.parseInt(o.innerText,10),r&&n>=0&&(t.strings[r-1]=n);break;case"barre":r&&n&&o.getAttribute("type")==="start"&&t.barreFrets.push(n);break}break}}_parseAttributes(e,t,s){let i,r,n;if(this._lastBeat==null)for(const o of e.childElements())switch(o.localName){case"divisions":this._divisionsPerQuarterNote=Number.parseFloat(o.innerText);break;case"key":this._parseKey(o,t,s);break;case"time":this._parseTime(o,t);break;case"staves":s.ensureStaveCount(Number.parseInt(o.innerText,10));break;case"clef":i=Number.parseInt(o.getAttribute("number","1"),10)-1,r=this._getOrCreateStaff(s,i),n=this._getOrCreateBar(r,t),this._parseClef(o,n);break;case"staff-details":i=Number.parseInt(o.getAttribute("number","1"),10)-1,r=this._getOrCreateStaff(s,i),this._parseStaffDetails(o,r);break;case"transpose":this._parseTranspose(o,s);break;case"measure-style":this._parseMeasureStyle(o,s,!1);break}else for(const o of e.childElements())switch(o.localName){case"divisions":this._divisionsPerQuarterNote=Number.parseFloat(o.innerText);break;case"measure-style":this._parseMeasureStyle(o,s,!0);break}}_simileMarkAllStaves=null;_simileMarkPerStaff=null;_isBeatSlash=!1;_parseMeasureStyle(e,t,s){for(const i of e.childElements())switch(i.localName){case"measure-repeat":if(!s){let r=null;switch(i.getAttribute("type")){case"start":switch(Number.parseInt(i.getAttribute("slashes","1"),10)){case 1:r=xt.Simple;break;case 2:r=xt.FirstOfDouble;break}break;case"stop":r=null;break}if(e.attributes.has("number")){this._simileMarkPerStaff=this._simileMarkPerStaff??new Map;const n=Number.parseInt(e.attributes.get("number"),10)-1;r==null?this._simileMarkPerStaff.delete(n):this._simileMarkPerStaff.set(n,r)}else this._simileMarkAllStaves=r}break;case"slash":switch(i.getAttribute("type")){case"start":this._isBeatSlash=!0;break;case"stop":this._isBeatSlash=!1;break}break}}_parseTranspose(e,t){let s=0;for(const i of e.childElements())switch(i.localName){case"chromatic":s+=Number.parseFloat(i.innerText);break;case"octave-change":s+=Number.parseFloat(i.innerText)*12;break}if(e.attributes.has("number")){const i=this._getOrCreateStaff(t,Number.parseInt(e.attributes.get("number"),10)-1);this._getStaffContext(i).transpose=s,i.displayTranspositionPitch=s}else for(const i of t.staves)this._getStaffContext(i).transpose=s,i.displayTranspositionPitch=s}_parseStaffDetails(e,t){for(const s of e.childElements())switch(s.localName){case"staff-lines":t.standardNotationLineCount=Number.parseInt(s.innerText,10);break;case"staff-tuning":this._parseStaffTuning(s,t);break;case"capo":t.capo=Number.parseInt(s.innerText,10);break}}_parseStaffTuning(e,t){t.stringTuning.tunings.length===0&&(t.showTablature=!0,t.showStandardNotation=!1,t.stringTuning.tunings=new Array(t.standardNotationLineCount).fill(0));const s=Number.parseInt(e.getAttribute("line"),10);let i="C",r="",n=0;for(const l of e.childElements())switch(l.localName){case"tuning-step":i=l.innerText;break;case"tuning-alter":n=Number.parseFloat(l.innerText);break;case"tuning-octave":r=l.innerText;break}const o=L.getTuningForText(i+r)+n;t.tuning[t.tuning.length-s]=o}_parseClef(e,t){let s="s",i=0;for(const r of e.childElements())switch(r.localName){case"sign":s=r.innerText.toLowerCase();break;case"line":i=Number.parseInt(r.innerText,10);break;case"clef-octave-change":switch(Number.parseInt(r.innerText,10)){case-2:t.clefOttava=le._15mb;break;case-1:t.clefOttava=le._8vb;break;case 1:t.clefOttava=le._8va;break;case 2:t.clefOttava=le._15mb;break}break}switch(s){case"g":t.clef=ve.G2;break;case"f":t.clef=ve.F4;break;case"c":i===3?t.clef=ve.C3:t.clef=ve.C4;break;case"percussion":t.clef=ve.Neutral,t.staff.isPercussion=!0;break;case"tab":t.clef=ve.G2,t.staff.showTablature=!0;break;default:t.clef=ve.G2;break}}_parseTime(e,t){let s=!1,i=!1;for(const r of e.childElements()){const n=r.innerText;switch(r.localName){case"beats":s||(n.indexOf("+")===-1?t.timeSignatureNumerator=Number.parseInt(n,10):t.timeSignatureNumerator=n.split("+").map(o=>Number.parseInt(o,10)).reduce((o,l)=>l+o,0),s=!0);break;case"beat-type":i||(n.indexOf("+")===-1?t.timeSignatureDenominator=Number.parseInt(n,10):t.timeSignatureDenominator=n.split("+").map(o=>Number.parseInt(o,10)).reduce((o,l)=>l+o,0),i=!0);break}}switch(e.getAttribute("symbol","")){case"common":case"cut":t.timeSignatureCommon=!0;break}}_keyAllStaves=null;_parseKey(e,t,s){let i=-qe.C,r="";for(const l of e.childElements())switch(l.localName){case"fifths":i=Number.parseInt(l.innerText,10);break;case"mode":r=l.innerText;break}let n;-7<=i&&i<=7?n=i:n=qe.C;let o;if(r==="minor"?o=as.Minor:o=as.Major,e.attributes.has("number")){const l=this._getOrCreateStaff(s,Number.parseInt(e.attributes.get("number"),10)-1),h=this._getOrCreateBar(l,t);
10h.keySignature=n,h.keySignatureType=o}else{this._keyAllStaves=[n,o];for(const l of s.staves)l.bars.length>t.index&&(l.bars[t.index].keySignature=n,l.bars[t.index].keySignatureType=o)}}_parseDirection(e,t,s){const i=[];let r=null,n=-1,o=-1;for(const f of e.childElements())switch(f.localName){case"direction-type":const p=f.firstElement;p&&i.push(p);break;case"offset":r=Number.parseFloat(f.innerText);break;case"voice":break;case"staff":n=Number.parseInt(f.innerText,10)-1;break;case"sound":f.attributes.has("tempo")&&(o=Number.parseFloat(f.attributes.get("tempo")));break}let l=null;n>=0?l=this._getOrCreateStaff(s,n):this._lastBeat!==null?l=this._lastBeat.voice.bar.staff:l=this._getOrCreateStaff(s,0);const h=l?this._getOrCreateBar(l,t):null,c=()=>{let f=this._musicalPosition;r!==null&&(f+=r);const p=t.calculateDuration(!1);return f/p};if(o>0){const f=new tt;f.type=Re.Tempo,f.value=o,f.ratioPosition=c(),this._hasSameTempo(t,f)||t.tempoAutomations.push(f)}let d="";for(const f of i)switch(f.localName){case"rehearsal":t.section=new Tr,t.section.marker=f.innerText;break;case"segno":t.addDirection(U.TargetSegno);break;case"coda":t.addDirection(U.TargetCoda);break;case"words":d=f.innerText;break;case"wedge":switch(f.getAttribute("type")){case"crescendo":this._nextBeatCrescendo=Gt.Crescendo;break;case"diminuendo":this._nextBeatCrescendo=Gt.Decrescendo;break;case"stop":this._nextBeatCrescendo=null;break}break;case"dynamics":const p=this._parseDynamics(f);p!==null&&(this._currentDynamics=p,this._score.stylesheet.hideDynamics=!1);break;case"dashes":const g=f.getAttribute("type","start");switch(d){case"LetRing":this._nextBeatLetRing=g==="start"||g==="continue";break;case"P.M.":this._nextBeatPalmMute=g==="start"||g==="continue";break}d="";break;case"pedal":const m=this._parsePedal(f);if(m&&h){m.ratioPosition=c();const b=h.sustainPedals.length>0&&h.sustainPedals[h.sustainPedals.length-1].pedalType!==it.Up;(m.pedalType!==it.Up||b)&&h.sustainPedals.push(m)}break;case"metronome":this._parseMetronome(f,t,c());break;case"octave-shift":this._nextBeatOttavia=this._parseOctaveShift(f);break}d&&(this._nextBeatText=d)}_parseOctaveShift(e){const t=e.getAttribute("type");switch(Number.parseInt(e.getAttribute("size","8"),10)){case 15:switch(t){case"up":return le._15mb;case"down":return le._15ma;case"stop":return le.Regular;case"continue":return this._nextBeatOttavia}break;case 8:switch(t){case"up":return le._8vb;case"down":return le._8va;case"stop":return le.Regular;case"continue":return this._nextBeatOttavia}break}return null}_parseMetronome(e,t,s){let i=null,r=-1;for(const n of e.childElements())switch(n.localName){case"beat-unit":i=this._parseBeatDuration(n);break;case"per-minute":r=Number.parseFloat(n.innerText);break}if(i!==null&&r>0){const n=new tt;n.type=Re.Tempo,n.value=r*(i/4),n.ratioPosition=s,this._hasSameTempo(t,n)||t.tempoAutomations.push(n)}}_hasSameTempo(e,t){for(const s of e.tempoAutomations)if(t.ratioPosition===s.ratioPosition&&t.value===s.value)return!0;return!1}_parsePedal(e){const t=new _i;switch(e.getAttribute("type")){case"start":t.pedalType=it.Down;break;case"stop":t.pedalType=it.Up;break;case"continue":t.pedalType=it.Hold;break;default:return null}return t}_parseDynamics(e){for(const t of e.childElements()){const s=t.localName.toUpperCase();switch(s){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 se[s]}}return null}_parseForward(e){for(const t of e.childElements())t.localName==="duration"&&(this._musicalPosition+=this._musicXmlDivisionsToAlphaTabTicks(Number.parseFloat(t.innerText)))}_parseBackup(e){for(const t of e.childElements())switch(t.localName){case"duration":if(this._lastBeat){let i=this._musicalPosition;i-=this._musicXmlDivisionsToAlphaTabTicks(Number.parseFloat(t.innerText)),i<0&&(i=0),this._musicalPosition=i}break}}_getOrCreateStaff(e,t){for(;e.staves.length<=t;){const s=new Oi;e.addStaff(s),this._score.masterBars.length>0&&this._getOrCreateBar(s,this._score.masterBars[this._score.masterBars.length-1])}return e.staves[t]}_getOrCreateBar(e,t){const s=e.bars.length===0?1:e.bars[0].voices.length;for(;e.bars.length<=t.index;){const i=new ns;e.addBar(i),i.previousBar&&(i.clef=i.previousBar.clef,i.clefOttava=i.previousBar.clefOttava,i.keySignature=i.previousBar.keySignature,i.keySignatureType=i.previousBar.keySignatureType),this._keyAllStaves!=null&&(i.keySignature=this._keyAllStaves[0],i.keySignatureType=this._keyAllStaves[1]);for(let r=0;r<s;r++){const n=new ks;i.addVoice(n)}}return e.bars[t.index]}_getOrCreateVoice(e,t){let s=!1;for(;e.voices.length<=t;)e.addVoice(new ks),s=!0;if(s)for(const i of e.staff.bars)for(;i.voices.length<=t;)i.addVoice(new ks);return e.voices[t]}
10_parseNote(e,t,s){let i=null,r=K.None,n=0,o=null,l=!1,h=0,c=0,d=-1,f=null,p=0,g=-1,m=-1,b=null,S=null,N=!1,v=null;const W=e.getAttribute("print-object","yes")!=="no",j=()=>{if(i!==null)return;l&&!this._lastBeat&&(E.warning("MusicXML","Malformed MusicXML, <chord /> cannot be set on the first note of a measure"),l=!1),l&&!S&&(E.warning("MusicXML","Cannot mix <chord /> and <rest />"),l=!1);const q=this._getOrCreateStaff(s,h);if(l){i=this._lastBeat,i.addNote(S);return}const F=this._getOrCreateBar(q,t),Q=this._getOrCreateVoice(F,c),me=Q.beats.length===0?0:Q.beats[Q.beats.length-1].displayEnd;let ge=this._musicalPosition-me;if(ge>0){if(this._lastBeat&&this._lastBeat.beamingMode===st.ForceMergeWithNext&&this._lastBeat.voice.bar.staff.index!==h&&Q.beats.length>0&&Q.beats[Q.beats.length-1].beamingMode===st.ForceMergeWithNext){const Ht=Q.beats[Q.beats.length-1].duration;for(;ge>0;){const Zt=this._createRestForGap(ge,Ht);if(Zt!==null)this._insertBeatToVoice(Zt,Q),ge-=Zt.playbackDuration;else break}}if(ge>0){const Ht=new Dt;Ht.dynamics=this._currentDynamics,Ht.isEmpty=!0,Ht.duration=y.TwoHundredFiftySixth,Ht.overrideDisplayDuration=ge,Ht.updateDurations(),this._insertBeatToVoice(Ht,Q)}}else ge<0&&E.error("MusicXML","Unsupported forward/backup detected. Cannot fill new beats into already filled area of voice");d<0&&f!==null&&(d=B.toTicks(f),p>0&&(d=B.applyDot(d,p===2)));const re=new Dt;i=re,o===null?re.beamingMode=this._getStaffContext(q).isExplicitlyBeamed?st.ForceSplitToNext:st.Auto:(re.beamingMode=o,this._getStaffContext(q).isExplicitlyBeamed=!0),re.isEmpty=!1,re.dynamics=this._currentDynamics,this._isBeatSlash&&(re.slashed=!0);const Je=this._nextBeatAutomations;if(this._nextBeatAutomations=null,Je!==null)for(const Ht of Je)re.automations.push(Ht);const lt=this._nextBeatChord;this._nextBeatChord=null,lt!==null&&(re.chordId=lt.uniqueId,Q.bar.staff.hasChord(lt.uniqueId)||Q.bar.staff.addChord(re.chordId,lt));const De=this._nextBeatCrescendo;De!==null&&(re.crescendo=De);const vs=this._nextBeatOttavia;if(vs!==null&&(re.ottava=vs),re.isLetRing=this._nextBeatLetRing,re.isPalmMute=this._nextBeatPalmMute,this._nextBeatText&&(re.text=this._nextBeatText,this._nextBeatText=null),S!==null&&re.addNote(S),this._insertBeatToVoice(re,Q),S!==null){S.isVisible=W;const Ht=this._indexToTrackInfo.get(s.index);v!==null?S.percussionArticulation=Ht.getOrCreateArticulation(v,S):N||(S.percussionArticulation=Ht.getOrCreateArticulation("",S))}r!==K.None?(re.graceType=r,this._applyBeatDurationFromTicks(re,n,null,!1)):(re.tupletNumerator=g,re.tupletDenominator=m,re.dots=p,re.preferredBeamDirection=b,this._applyBeatDurationFromTicks(re,d,f,!0)),this._musicalPosition=re.displayEnd,this._lastBeat=re};for(const q of e.childElements())switch(q.localName){case"grace":const F=Number.parseFloat(q.getAttribute("make-time","-1"));F>=0?(n=this._musicXmlDivisionsToAlphaTabTicks(F),r=K.BeforeBeat):r=K.OnBeat,q.getAttribute("slash")==="yes"&&(r=K.BeforeBeat);break;case"chord":l=!0;break;case"cue":return;case"pitch":S=this._parsePitch(q),N=!0;break;case"unpitched":S=this._parseUnpitched(q,s);break;case"rest":S=null,f===null&&(f=y.Whole);break;case"duration":d=this._parseDuration(q);break;case"instrument":v=q.getAttribute("id","");break;case"voice":c=Number.parseInt(q.innerText,10),Number.isNaN(c)?(E.warning("MusicXML","Voices need to be specified as numbers"),c=0):c=c-1;break;case"type":f=this._parseBeatDuration(q);break;case"dot":p++;break;case"accidental":S===null?E.warning("MusicXML","Malformed MusicXML, missing pitch or unpitched for note"):this._parseAccidental(q,S);break;case"time-modification":for(const Q of q.childElements())switch(Q.localName){case"actual-notes":g=Number.parseInt(Q.innerText,10);break;case"normal-notes":m=Number.parseInt(Q.innerText,10);break}break;case"stem":b=this._parseStem(q);break;case"notehead":S===null?E.warning("MusicXML","Malformed MusicXML, missing pitch or unpitched for note"):this._parseNoteHead(q,S,f??y.Quarter,b??this._estimateBeamDirection(S));break;case"staff":h=Number.parseInt(q.innerText,10)-1;break;case"beam":if(q.getAttribute("number","1")==="1")switch(q.innerText){case"begin":o=st.ForceMergeWithNext;break;case"continue":o=st.ForceMergeWithNext;break;case"end":o=st.ForceSplitToNext;break}break;case"notations":j(),this._parseNotations(q,S,i);break;case"lyric":j(),this._parseLyric(q,i,s);break;
10case"play":this._parsePlay(q,S);break}if(N){const q=this._getOrCreateStaff(s,h),F=this._getStaffContext(q).transpose;if(F!==0){const Q=S.octave*12+S.tone+F;S.octave=Q/12|0,S.tone=Q-S.octave*12}}j()}_parsePlay(e,t){for(const s of e.childElements())s.localName==="mute"&&t&&s.innerText==="palm"&&(t.isPalmMute=!0)}static _b4Value=71;_estimateBeamDirection(e){return e.calculateRealValue(!1,!1)<Ze._b4Value?P.Down:P.Up}_parseNoteHead(e,t,s,i){e.getAttribute("parentheses","no")==="yes"&&(t.isGhost=!0);const r=e.getAttribute("filled","");let n;switch(r==="yes"?n=!0:r==="no"&&(n=!1),t.style=new Kn,e.innerText){case"arrow down":t.style.noteHeadCenterOnStem=!0,this._applyNoteHead(t,s,n,u.NoteheadTriangleDownDoubleWhole,u.NoteheadTriangleDownWhole,u.NoteheadTriangleDownHalf,u.NoteheadTriangleDownBlack);break;case"arrow up":t.style.noteHeadCenterOnStem=!0,this._applyNoteHead(t,s,n,u.NoteheadTriangleUpDoubleWhole,u.NoteheadTriangleUpWhole,u.NoteheadTriangleUpHalf,u.NoteheadTriangleUpBlack);break;case"back slashed":this._applyNoteHead(t,s,n,u.NoteheadSlashedDoubleWhole2,u.NoteheadSlashedWhole2,u.NoteheadSlashedHalf2,u.NoteheadSlashedBlack2);break;case"circle dot":t.style.noteHead=u.NoteheadRoundWhiteWithDot;break;case"circle-x":this._applyNoteHead(t,s,n,u.NoteheadCircleXDoubleWhole,u.NoteheadCircleXWhole,u.NoteheadCircleXHalf,u.NoteheadCircleX);break;case"circled":this._applyNoteHead(t,s,n,u.NoteheadCircledDoubleWhole,u.NoteheadCircledWhole,u.NoteheadCircledHalf,u.NoteheadCircledBlack);break;case"cluster":this._applyNoteHead(t,s,n,u.NoteheadClusterDoubleWhole3rd,u.NoteheadClusterWhole3rd,u.NoteheadClusterHalf3rd,u.NoteheadClusterQuarter3rd);break;case"cross":this._applyNoteHead(t,s,n,u.NoteheadPlusDoubleWhole,u.NoteheadPlusWhole,u.NoteheadPlusHalf,u.NoteheadPlusBlack);break;case"diamond":this._applyNoteHead(t,s,n,u.NoteheadDiamondDoubleWhole,u.NoteheadDiamondWhole,u.NoteheadDiamondHalf,u.NoteheadDiamondBlack);break;case"do":this._applyNoteHead(t,s,n,u.NoteShapeTriangleUpWhite,u.NoteShapeTriangleUpWhite,u.NoteShapeTriangleUpWhite,u.NoteShapeTriangleUpBlack);break;case"fa":i===P.Up?this._applyNoteHead(t,s,n,u.NoteShapeTriangleRightWhite,u.NoteShapeTriangleRightWhite,u.NoteShapeTriangleRightWhite,u.NoteShapeTriangleRightBlack):this._applyNoteHead(t,s,n,u.NoteShapeTriangleLeftWhite,u.NoteShapeTriangleLeftWhite,u.NoteShapeTriangleLeftWhite,u.NoteShapeTriangleLeftBlack);break;case"fa up":this._applyNoteHead(t,s,n,u.NoteShapeTriangleLeftWhite,u.NoteShapeTriangleLeftWhite,u.NoteShapeTriangleLeftWhite,u.NoteShapeTriangleLeftBlack);break;case"inverted triangle":this._applyNoteHead(t,s,n,u.NoteheadTriangleDownDoubleWhole,u.NoteheadTriangleDownWhole,u.NoteheadTriangleDownHalf,u.NoteheadTriangleDownBlack);break;case"la":this._applyNoteHead(t,s,n,u.NoteShapeSquareWhite,u.NoteShapeSquareWhite,u.NoteShapeSquareWhite,u.NoteShapeSquareBlack);break;case"left triangle":this._applyNoteHead(t,s,n,u.NoteheadTriangleRightWhite,u.NoteheadTriangleRightWhite,u.NoteheadTriangleRightWhite,u.NoteheadTriangleRightBlack);break;case"mi":this._applyNoteHead(t,s,n,u.NoteShapeDiamondWhite,u.NoteShapeDiamondWhite,u.NoteShapeDiamondWhite,u.NoteShapeDiamondBlack);break;case"none":t.style.noteHead=u.NoteheadNull;break;case"normal":this._applyNoteHead(t,s,n,u.NoteheadDoubleWhole,u.NoteheadWhole,u.NoteheadHalf,u.NoteheadBlack);break;case"re":this._applyNoteHead(t,s,n,u.NoteShapeMoonWhite,u.NoteShapeMoonWhite,u.NoteShapeMoonWhite,u.NoteShapeMoonBlack);break;case"rectangle":this._applyNoteHead(t,s,n,u.NoteheadSquareWhite,u.NoteheadSquareWhite,u.NoteheadSquareWhite,u.NoteheadSquareBlack);break;case"slash":this._applyNoteHead(t,s,n,u.NoteheadSlashWhiteWhole,u.NoteheadSlashWhiteWhole,u.NoteheadSlashWhiteHalf,u.NoteheadSlashHorizontalEnds);break;case"slashed":this._applyNoteHead(t,s,n,u.NoteheadSlashedDoubleWhole1,u.NoteheadSlashedWhole1,u.NoteheadSlashedHalf1,u.NoteheadSlashedBlack1);break;case"so":this._applyNoteHead(t,s,n,u.NoteShapeRoundWhite,u.NoteShapeRoundWhite,u.NoteShapeRoundWhite,u.NoteShapeRoundBlack);break;case"square":this._applyNoteHead(t,s,n,u.NoteShapeSquareWhite,u.NoteShapeSquareWhite,u.NoteShapeSquareWhite,u.NoteShapeSquareBlack);break;case"ti":this._applyNoteHead(t,s,n,u.NoteShapeTriangleRoundWhite,u.NoteShapeTriangleRoundWhite,u.NoteShapeTriangleRoundWhite,u.NoteShapeTriangleRoundBlack);break;case"triangle":this._applyNoteHead(t,s,n,u.NoteheadTriangleUpDoubleWhole,u.NoteheadTriangleUpWhole,u.NoteheadTriangleUpHalf,u.NoteheadTriangleUp
10Black);break;case"x":this._applyNoteHead(t,s,n,u.NoteheadXDoubleWhole,u.NoteheadXWhole,u.NoteheadXHalf,u.NoteheadXBlack);break}}_createRestForGap(e,t){let s=B.toTicks(t);for(;s>e;){if(t===y.TwoHundredFiftySixth)return null;t=t*2,s=B.toTicks(t)}const i=new Dt;return i.dynamics=this._currentDynamics,i.isEmpty=!1,i.duration=t,i.overrideDisplayDuration=s,i.updateDurations(),i}_insertBeatToVoice(e,t){if(t.beats.length>0){const s=t.beats[t.beats.length-1];s.nextBeat=e,e.previousBeat=s;let i=s;for(;i!==null&&i.graceType!==K.None;)i.index>0?i=i.previousBeat:i=null;i!==null&&(e.displayStart=i.displayEnd)}t.addBeat(e)}_musicXmlDivisionsToAlphaTabTicks(e){return e*B.QuarterTime/this._divisionsPerQuarterNote}_parseBeatDuration(e){switch(e.innerText){case"1024th":return y.TwoHundredFiftySixth;case"512th":return y.TwoHundredFiftySixth;case"256th":return y.TwoHundredFiftySixth;case"128th":return y.OneHundredTwentyEighth;case"64th":return y.SixtyFourth;case"32nd":return y.ThirtySecond;case"16th":return y.Sixteenth;case"eighth":return y.Eighth;case"quarter":return y.Quarter;case"half":return y.Half;case"whole":return y.Whole;case"breve":return y.DoubleWhole;case"long":return y.QuadrupleWhole}return null}static _allDurations=[y.TwoHundredFiftySixth,y.OneHundredTwentyEighth,y.SixtyFourth,y.ThirtySecond,y.Sixteenth,y.Eighth,y.Quarter,y.Half,y.Whole,y.DoubleWhole,y.QuadrupleWhole];static _allDurationTicks=Ze._allDurations.map(e=>B.toTicks(e));_applyBeatDurationFromTicks(e,t,s,i){if(!s)for(let r=0;r<Ze._allDurations.length;r++){const n=Ze._allDurationTicks[r];if(t>=n)s=Ze._allDurations[r];else break}e.duration=s??y.Sixteenth,i&&(e.overrideDisplayDuration=t),e.updateDurations()}_parseLyric(e,t,s){const r=this._indexToTrackInfo.get(s.index).getLyricLine(e.getAttribute("number",""));for(t.lyrics===null&&(t.lyrics=[]);t.lyrics.length<=r;)t.lyrics.push("");for(const n of e.childElements())switch(n.localName){case"text":t.lyrics[r]?t.lyrics[r]+=` ${n.innerText}`:t.lyrics[r]=n.innerText;break;case"elision":t.lyrics[r]+=n.innerText;break}}_parseNotations(e,t,s){for(const i of e.childElements())switch(i.localName){case"tied":t&&this._parseTied(i,t,s.voice.bar.staff);break;case"slur":t&&this._parseSlur(i,t);break;case"glissando":t&&this._parseGlissando(i,t);break;case"slide":t&&this._parseSlide(i,t);break;case"ornaments":t&&this._parseOrnaments(i,t);break;case"technical":this._parseTechnical(i,t,s);break;case"articulations":t&&this._parseArticulations(i,t);break;case"dynamics":const r=this._parseDynamics(i);r!==null&&(s.dynamics=r,this._currentDynamics=r);break;case"fermata":this._parseFermata(i,s);break;case"arpeggiate":this._parseArpeggiate(i,s);break}}_getStaffContext(e){if(!this._staffToContext.has(e)){const t=new zh;return this._staffToContext.set(e,t),t}return this._staffToContext.get(e)}_parseGlissando(e,t){const s=e.getAttribute("type"),i=e.getAttribute("number","1"),r=this._getStaffContext(t.beat.voice.bar.staff);switch(s){case"start":r.slideOrigins.set(i,t);break;case"stop":if(r.slideOrigins.has(i)){const n=r.slideOrigins.get(i);n.slideTarget=t,t.slideOrigin=n,n.slideOutType=he.Shift}break}}_parseSlur(e,t){const s=e.getAttribute("number","1"),i=this._getStaffContext(t.beat.voice.bar.staff);switch(e.getAttribute("type")){case"start":i.slurStarts.set(s,t);break;case"stop":if(i.slurStarts.has(s)){t.isSlurDestination=!0;const r=i.slurStarts.get(s);r.slurDestination=t,t.slurOrigin=r,i.slurStarts.delete(s)}break}}_parseArpeggiate(e,t){switch(e.getAttribute("direction","down")){case"down":t.brushType=z.ArpeggioDown;break;case"up":t.brushType=z.ArpeggioUp;break}}_parseFermata(e,t){let s;switch(e.innerText){case"normal":s=os.Medium;break;case"angled":s=os.Short;break;case"square":s=os.Long;break;default:s=os.Medium;break}t.fermata=new Br,t.fermata.type=s}_parseArticulations(e,t){for(const s of e.childElements())switch(s.localName){case"accent":t.accentuated=ct.Normal;break;case"strong-accent":t.accentuated=ct.Heavy;break;case"staccato":t.isStaccato=!0;break;case"tenuto":t.accentuated=ct.Tenuto;break}}_parseTechnical(e,t,s){const i=[];for(const r of e.childElements())switch(r.localName){case"up-bow":s.pickStroke=Ct.Up;break;case"down-bow":s.pickStroke=Ct.Down;break;case"harmonic":break;case"fingering":t&&(t.leftHandFinger=this._parseFingering(r));break;case"pluck":t&&(t.rightHandFinger=this._parseFingering(r));break;case"fret":t&&(t.fret=Number.parseInt(r.innerText,10));break;case"string":t&&(t.string=s.voice.bar.staff.tuning.length-Number.parseInt(r.innerText,10)+1);break;case"hammer-on":case"pull-off":t&&(t.isHammerPullOrigin=!0);break;case"bend":i.push(r);break;case"tap":s.tap=!0;break;case"smear":t&&(t.vibrato=Be.Slight);break;case"golpe":switch(r.getAttribute("placement","above")){case"above":s.golpe=Xt.Finger;break;case"below":s.golpe=Xt.Thumb;break}break}t&&i.length>0&&this._parseBends(i,t)}_parseBends(e,t){const s=G.MaxPosition/e.length;let i=0,r=0,n=!0;for(const o of e){const l=o.findChildElement("bend-alter");if(l){const h=Math.round(Math.abs(Number.parseFloat(l.innerText))*2);o.findChildElement("pre-bend")?n?(i+=h,t.addBendPoint(new G(r,i)),r+=s,t.addBendPoint(new G(r,i)),n=!1):r+=s:o.findC
10hildElement("release")?(n&&(i+=h),t.addBendPoint(new G(r,i)),r+=s,i-=h,t.addBendPoint(new G(r,i)),n=!1):(t.addBendPoint(new G(r,i)),i+=h,r+=s,t.addBendPoint(new G(r,i)),n=!1)}}}_parseFingering(e){switch(e.innerText){case"0":return ie.NoOrDead;case"1":case"p":case"t":return ie.Thumb;case"2":case"i":return ie.IndexFinger;case"3":case"m":return ie.MiddleFinger;case"4":case"a":return ie.AnnularFinger;case"5":case"c":return ie.LittleFinger}return ie.Unknown}_currentTrillStep=-1;_parseOrnaments(e,t){let s=-1;for(const i of e.childElements())switch(i.localName){case"trill-mark":s=Number.parseInt(i.getAttribute("trill-step","2"),10),t.isStringed?t.trillValue=t.stringTuning+s:t.isPercussion||(t.trillValue=t.calculateRealValue(!1,!1)+s);break;case"turn":t.ornament=ot.Turn;break;case"inverted-turn":t.ornament=ot.InvertedTurn;break;case"wavy-line":s>0?i.getAttribute("type")==="start"&&(this._currentTrillStep=s):this._currentTrillStep>0?i.getAttribute("type")==="stop"?this._currentTrillStep=-1:t.isStringed?t.trillValue=t.stringTuning+this._currentTrillStep:t.isPercussion||(t.trillValue=t.calculateRealValue(!1,!1)+this._currentTrillStep):t.vibrato=Be.Slight;break;case"mordent":t.ornament=ot.LowerMordent;break;case"inverted-mordent":t.ornament=ot.UpperMordent;break;case"tremolo":const r=new Ts;t.beat.tremoloPicking=r,r.marks=Number.parseInt(i.innerText,10),(i.getAttribute("type","")==="unmeasured"&&r.marks===0||i.getAttribute("smufl","")==="buzzRoll")&&(r.style=wi.BuzzRoll);break}}_parseSlide(e,t){const s=e.getAttribute("type"),i=e.getAttribute("number","1"),r=this._getStaffContext(t.beat.voice.bar.staff);switch(s){case"start":r.slideOrigins.set(i,t);break;case"stop":if(r.slideOrigins.has(i)){const n=r.slideOrigins.get(i);n.slideTarget=t,t.slideOrigin=n,n.slideOutType=he.Shift}break}}_parseTied(e,t,s){const i=e.getAttribute("type"),r=e.getAttribute("number",""),n=this._getStaffContext(s);if(i==="start"){if(r){if(n.tieStartIds.has(r)){const o=n.tieStartIds.get(r);n.tieStarts.delete(o)}n.tieStartIds.set(r,t)}n.tieStarts.add(t)}else if(i==="stop"&&!t.isTieDestination){let o=null;if(r){if(!n.tieStartIds.has(r))return;o=n.tieStartIds.get(r),n.tieStartIds.delete(r),n.tieStarts.delete(t)}else{const l=this._calculatePitchedNoteValue(t);for(const h of n.tieStarts)if(this._calculatePitchedNoteValue(h)===l){o=h,n.tieStarts.delete(o);break}}if(!o)return;t.isTieDestination=!0,t.tieOrigin=o}}_parseStem(e){switch(e.innerText){case"down":return P.Down;case"up":return P.Up;default:return null}}_parseAccidental(e,t){switch(e.innerText){case"sharp":t.accidentalMode=oe.ForceSharp;break;case"natural":t.accidentalMode=oe.ForceNatural;break;case"flat":t.accidentalMode=oe.ForceFlat;break;case"double-sharp":t.accidentalMode=oe.ForceDoubleSharp;break;case"flat-flat":t.accidentalMode=oe.ForceDoubleFlat;break}}_calculatePitchedNoteValue(e){return e.octave*12+e.tone}_parseDuration(e){return this._musicXmlDivisionsToAlphaTabTicks(Number.parseFloat(e.innerText))}_parseUnpitched(e,t){let s="",i=0;for(const n of e.childElements())switch(n.localName){case"display-step":s=n.innerText;break;case"display-octave":i=Number.parseInt(n.innerText,10)+1;break}const r=new kt;if(s==="")r.octave=0,r.tone=0;else{const n=i*12+(L.getToneForText(s)?.noteValue??0);r.octave=n/12|0,r.tone=n-r.octave*12}return r}_parsePitch(e){let t="",s=0,i=0;for(const o of e.childElements())switch(o.localName){case"step":t=o.innerText;break;case"alter":s=Number.parseFloat(o.innerText),Number.isNaN(s)&&(s=0);break;case"octave":i=Number.parseInt(o.innerText,10)+1;break}s=s|0;const r=i*12+(L.getToneForText(t)?.noteValue??0)+s,n=new kt;return n.octave=r/12|0,n.tone=r-n.octave*12,n}_applyNoteHead(e,t,s,i,r,n,o){if(s===void 0)switch(t){case y.QuadrupleWhole:case y.DoubleWhole:e.style.noteHead=i;break;case y.Whole:e.style.noteHead=r;break;case y.Half:e.style.noteHead=n;break;default:e.style.noteHead=o;break}else if(s===!0)e.style.noteHead=o;else switch(t){case y.QuadrupleWhole:case y.DoubleWhole:e.style.noteHead=i;break;case y.Whole:e.style.noteHead=r;break;case y.Half:e.style.noteHead=n;break;default:e.style.noteHead=n;break}}}var ni;(function(a){a[a.Page=0]="Page",a[a.Horizontal=1]="Horizontal",a[a.Parchment=2]="Parchment"})(ni||(ni={}));class oo{_buffer;_writePosition=0;_readPosition=0;count=0;constructor(e){this._buffer=new Float32Array(e)}clear(){this._readPosition=0,this._writePosition=0,this.count=0,this._buffer=new Float32Array(this._buffer.length)}
vendor: 4,706 bytes, line 10
10write(e,t,s){let i=0;s>this._buffer.length-this.count&&(s=this._buffer.length-this.count);const r=Math.min(this._buffer.length-this._writePosition,s);return this._buffer.set(e.subarray(t,t+r),this._writePosition),this._writePosition+=r,this._writePosition%=this._buffer.length,i+=r,i<s&&(this._buffer.set(e.subarray(t+i,t+i+s-i),this._writePosition),this._writePosition+=s-i,i=s),this.count+=i,i}read(e,t,s){s>this.count&&(s=this.count);let i=0;const r=Math.min(this._buffer.length-this._readPosition,s);return e.set(this._buffer.subarray(this._readPosition,this._readPosition+r),t),i+=r,this._readPosition+=r,this._readPosition%=this._buffer.length,i<s&&(e.set(this._buffer.subarray(this._readPosition,this._readPosition+s-i),t+i),this._readPosition+=s-i,i=s),this.count-=i,i}}class _t{_listeners=[];_fireOnRegister;constructor(e=void 0){this._fireOnRegister=e}on(e){return this._listeners.push(e),this._fireOnRegister?.()&&e(),()=>{this.off(e)}}off(e){this._listeners=this._listeners.filter(t=>t!==e)}trigger(){for(const e of this._listeners)e()}}class Se{_listeners=[];_fireOnRegister;constructor(e=void 0){this._fireOnRegister=e}on(e){if(this._listeners.push(e),this._fireOnRegister){const t=this._fireOnRegister();t!==null&&e(t)}return()=>{this.off(e)}}off(e){this._listeners=this._listeners.filter(t=>t!==e)}trigger(e){for(const t of this._listeners)t(e)}}class It{static CmdOutputPrefix="alphaSynth.output.";static CmdOutputAddSamples=`${It.CmdOutputPrefix}addSamples`;static CmdOutputPlay=`${It.CmdOutputPrefix}play`;static CmdOutputPause=`${It.CmdOutputPrefix}pause`;static CmdOutputResetSamples=`${It.CmdOutputPrefix}resetSamples`;static CmdOutputStop=`${It.CmdOutputPrefix}stop`;static CmdOutputSampleRequest=`${It.CmdOutputPrefix}sampleRequest`;static CmdOutputSamplesPlayed=`${It.CmdOutputPrefix}samplesPlayed`;static preferredSampleRate=0;_worker;get sampleRate(){return It.preferredSampleRate}open(){E.debug("AlphaSynth","Initializing synth worker"),this._worker=M.globalThis,this._worker.addEventListener("message",this._handleMessage.bind(this)),this.ready.trigger()}destroy(){this._worker.postMessage({cmd:"alphaSynth.output.destroy"})}_handleMessage(e){const t=e.data;switch(t.cmd){case It.CmdOutputSampleRequest:this.sampleRequest.trigger();break;case It.CmdOutputSamplesPlayed:this.samplesPlayed.trigger(t.samples);break}}ready=new _t;samplesPlayed=new Se;sampleRequest=new _t;addSamples(e){this._worker.postMessage({cmd:"alphaSynth.output.addSamples",samples:M.prepareForPostMessage(e)})}play(){this._worker.postMessage({cmd:"alphaSynth.output.play"})}pause(){this._worker.postMessage({cmd:"alphaSynth.output.pause"})}resetSamples(){this._worker.postMessage({cmd:"alphaSynth.output.resetSamples"})}activate(){}async enumerateOutputDevices(){return[]}async setOutputDevice(e){}async getOutputDevice(){return null}}class Xh{device;constructor(e){this.device=e}get deviceId(){return this.device.deviceId}get label(){return this.device.label}isDefault=!1}class ds{static _knownDevices=[];static findKnownDevice(e){return ds._knownDevices.find(t=>t.deviceId===e)}static createAudioContext(){if("AudioContext"in M.globalThis)return new AudioContext;if("webkitAudioContext"in M.globalThis)return new webkitAudioContext;throw new Ye(Ge.General,"AudioContext not found")}static async checkSinkIdSupport(){return"setSinkId"in ds.createAudioContext()?!0:(E.warning("WebAudio","Browser does not support changing the output device"),!1)}static async enumerateOutputDevices(){try{if(!await ds.checkSinkIdSupport())return[];try{await navigator.mediaDevices.getUserMedia({audio:!0})}catch(o){E.warning("WebAudio","Output device permission rejected",o)}const e=await navigator.mediaDevices.enumerateDevices();let t="",s="";const i=new Map;for(const o of e)o.kind==="audiooutput"&&(i.set(o.groupId,new Xh(o)),(o.deviceId==="default"||o.deviceId==="")&&(t=o.groupId,s=o.deviceId));const r=Array.from(i.values());let n=r.find(o=>o.deviceId===s);return n||(n=r.find(o=>o.device.groupId===t)),!n&&r.length>0&&(n=r[0]),n&&(n.isDefault=!0),ds._knownDevices=r,r}catch(e){return E.error("WebAudio","Failed to enumerate output devices",e),[]}}}class zs{static BufferSize=4096;static PreferredSampleRate=44100;context=null;buffer=null;source=null;_resumeHandler;get sampleRate(){return this.context?this.context.sampleRate:zs.PreferredSampleRate}activate(e){this.context||(this.context=ds.createAudioContext()),(this.context.state==="suspended"||this.context.state==="interrupted")&&(E.debug("WebAudio","Audio Context is suspended, trying resume"),this.context.resume().then(()=>{E.debug("WebAudio",`Audio Context resume success: state=${this.context?.state}, sampleRate:${this.context?.sampleRate}`),e&&e()},t=>
10{E.warning("WebAudio",`Audio Context resume failed: state=${this.context?.state}, sampleRate:${this.context?.sampleRate}, reason=${t}`)}))}_patchIosSampleRate(){const e=navigator.userAgent;if(e.indexOf("iPhone")!==-1||e.indexOf("iPad")!==-1){const t=ds.createAudioContext(),s=t.createBuffer(1,1,zs.PreferredSampleRate),i=t.createBufferSource();i.buffer=s,i.connect(t.destination),i.start(0),i.disconnect(0),t.close()}}open(e){this._patchIosSampleRate(),this.context=ds.createAudioContext(),this.context.state==="suspended"&&this._registerResumeHandler()}_registerResumeHandler(){this._resumeHandler=(()=>{this.activate(()=>{this._unregisterResumeHandler()})}).bind(this),document.body.addEventListener("touchend",this._resumeHandler,!1),document.body.addEventListener("click",this._resumeHandler,!1)}_unregisterResumeHandler(){const e=this._resumeHandler;e&&(document.body.removeEventListener("touchend",e,!1),document.body.removeEventListener("click",e,!1))}play(){const e=this.context;this.activate(),this.buffer=e.createBuffer(2,zs.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._unregisterResumeHandler()}ready=new _t;samplesPlayed=new Se;sampleRequest=new _t;onSamplesPlayed(e){this.samplesPlayed.trigger(e)}onSampleRequest(){this.sampleRequest.trigger()}onReady(){this.ready.trigger()}enumerateOutputDevices(){return ds.enumerateOutputDevices()}async setOutputDevice(e){await ds.checkSinkIdSupport()&&(e?await this.context.setSinkId(e.deviceId):await this.context.setSinkId(""))}async getOutputDevice(){if(!await ds.checkSinkIdSupport())return null;const e=this.context.sinkId;if(typeof e!="string"||e===""||e==="default")return null;let t=ds.findKnownDevice(e);if(t)return t;const s=await this.enumerateOutputDevices();return t=s.find(i=>i.deviceId===e),t||(E.warning("WebAudio","Could not find output device in device list",e,s),null)}}class ka{static _isRegistered=!1;static init(){ka._isRegistered||(ka._isRegistered=!0,registerProcessor("alphatab",class Er extends AudioWorkletProcessor{static BufferSize=4096;_outputBuffer=new Float32Array(0);_circularBuffer;_bufferCount=0;_requestedBufferCount=0;_isStopped=!1;constructor(t){super(t),E.debug("WebAudio","creating processor"),this._bufferCount=Math.floor(t.processorOptions.bufferTimeInMilliseconds*sampleRate/1e3/Er.BufferSize),this._circularBuffer=new oo(Er.BufferSize*this._bufferCount),this.port.onmessage=this._handleMessage.bind(this)}_handleMessage(t){const s=t.data;switch(s.cmd){case It.CmdOutputAddSamples:const r=s.samples;this._circularBuffer.write(r,0,r.length),this._requestedBufferCount--;break;case It.CmdOutputResetSamples:this._circularBuffer.clear();break;case It.CmdOutputStop:this._isStopped=!0;break}}process(t,s,i){if(s.length!==1&&s[0].length!==2)return!1;const r=s[0][0],n=s[0][1];if(!r||!n)return!0;const o=r.length+n.length;let l=this._outputBuffer;l.length!==o&&(l=new Float32Array(o),this._outputBuffer=l);const h=this._circularBuffer.read(l,0,Math.min(l.length,this._circularBuffer.count));let c=0;const d=Math.min(r.length,h);for(let f=0;f<d;f++)r[f]=l[c++],n[f]=l[c++];if(h<r.length)for(let f=h;f<r.length;f++)r[f]=0,n[f]=0;return this.port.postMessage({cmd:It.CmdOutputSamplesPlayed,samples:h/de.AudioChannels}),this._requestBuffers(),this._circularBuffer.count>0||!this._isStopped}_requestBuffers(){const t=this._bufferCount/2|0,s=t*Er.BufferSize;if(this._circularBuffer.count+this._requestedBufferCount*Er.BufferSize<s){for(let r=0;r<t;r++)this.port.postMessage({cmd:It.CmdOutputSampleRequest});this._requestedBufferCount+=t}}}))}}class Jl extends zs{_worklet=null;_bufferTimeInMilliseconds=0;_settings;constructor(e){super(),this._settings=e}open(e){super.open(e),this._bufferTimeInMilliseconds=e,this.onReady()}play(){super.play();const e=this.context;M.createAudioWorklet(e,this._settings).then(()=>{this._worklet=new AudioWorkletNode(e,"alphatab",{numberOfOutputs:1,outputChannelCount:[2],processorOptions:{bufferTimeInMilliseconds:this._bufferTimeInMilliseconds}}),this._worklet.port.onmessage=this._handleMessage.bind(this),this.source.connect(this._worklet),this.source.start(0),this._worklet.connect(e.destination)},t=>{E.error("WebAudio",`Audio Worklet creation failed: reason=${t}`)})}_handleMessage(e){const t=e.data;switch(t.cmd){case It.CmdOutputSamplesPlayed:this.onSamplesPlayed(t.samples);break;case It.CmdOutputSampleRequest:this.onSampleRequest();break}}pause(){super.pause(),this._worklet&&(this._worklet.port.postMessage({cmd:It.CmdOutputStop}),this._worklet.port.onmessage=null,this._worklet.disconnect()),this._worklet=null}addSamples(e){this._worklet?.port.postMessage({cmd:It.CmdOutputAddSamples,samples:M.prepareForPostMessage(e)})}resetSamples(){this._worklet?.port.postMessage({cmd:It.CmdOutputResetSamples})}}var ji;(function(a){a[a.SingleTrackMultiChannel=0]="SingleTrackMultiChannel",a[a.MultiTrack=1]="MultiTrack"})(ji||(ji={}));class lo{events=[];addEvent(e){if(this.events.length===0||e.tick>=this.events[this.events.length-1].tick)this.events.push(e);else{let t=this.events.length;for(;t>0&&this.events[t-1].tick>e.tick;)t--;this.events.splice(t,0,e)}}writeTo(e){const t=gt.empty();let s=0;for(const n of this.events){const o=n.tick-s;oi.writeVariableInt(t,o),n.writeTo(t),s=n.tick}const i=new Uint8Array([77,84,114,107]);e.write(i,0,i.length);const r=t.toArray();k.writeInt32BE(e,r.length),e.write(r,0,r.length)}}class oi{format=ji.SingleTrackMultiChannel;division=B.QuarterTime;tickShift=0;get events(){if(this.tracks.length===1)return this.tracks[0].events;const e=[];for(const t of this.tracks)this.events.push(...t.events);return e.sort((t,s)=>t.tick-s.tick),e}tracks=[];_ensureTracks(e){for(;this.tracks.length<e;)this.tracks.push(new lo)}addEvent(e){this.format===ji.SingleTrackMultiChannel?(this._ensureTracks(1),this.tracks[0].addEvent(e)):(this._ensureTracks(e.track+1),this.tracks[e.track].addEvent(e))}toBinary(){const e=gt.empty();return this.writeTo(e),e.toArray()}writeTo(e){const t=new Uint8Array([77,84,104,100]);e.write(t,0,t.length),k.writeInt32BE(e,6),k.writeInt16BE(e,this.format),k.writeInt16BE(e,this.tracks.length),k.writeInt16BE(e,this.division);for(const s of this.tracks)s.writeTo(e)}static writeVariableInt(e,t){const s=new Uint8Array(4);let i=0;do s[i++]=t&127,t>>=7;while(t>0);for(;i>0;)i--,i>0?e.writeByte(s[i]|128):e.writeByte(s[i])}}var Ie;(function(a){a[a.TimeSignature=88]="TimeSignature",a[a.NoteOn=128]="NoteOn",a[a.NoteOff=144]="NoteOff",a[a.ControlChange=176]="ControlChange",a[a.ProgramChange=192]="ProgramChange",a[a.TempoChange=81]="TempoChange",a[a.PitchBend=224]="PitchBend",a[a.PerNotePitchBend=96]="PerNotePitchBend",a[a.EndOfTrack=47
vendor: 15,262 bytes, line 10
10]="EndOfTrack",a[a.AlphaTabRest=241]="AlphaTabRest",a[a.AlphaTabMetronome=242]="AlphaTabMetronome",a[a.SystemExclusive=240]="SystemExclusive",a[a.SystemExclusive2=247]="SystemExclusive2",a[a.Meta=255]="Meta"})(Ie||(Ie={}));class ei{track;tick;type;constructor(e,t,s){this.track=e,this.tick=t,this.type=s}get command(){return this.type}get message(){return 0}get data1(){return 0}get data2(){return 0}}class ho extends ei{numerator;denominatorIndex;midiClocksPerMetronomeClick;thirtySecondNodesInQuarter;constructor(e,t,s,i,r,n){super(e,t,Ie.TimeSignature),this.track=e,this.tick=t,this.numerator=s,this.denominatorIndex=i,this.midiClocksPerMetronomeClick=r,this.thirtySecondNodesInQuarter=n}writeTo(e){e.writeByte(255),e.writeByte(88),oi.writeVariableInt(e,4),e.writeByte(this.numerator&255),e.writeByte(this.denominatorIndex&255),e.writeByte(this.midiClocksPerMetronomeClick&255),e.writeByte(this.thirtySecondNodesInQuarter&255)}}class er extends ei{static AlphaTabManufacturerId=125;static MetronomeEventId=0;static RestEventId=1;writeTo(e){e.writeByte(240);const t=gt.withCapacity(16);t.writeByte(er.AlphaTabManufacturerId),this.writeEventData(t),t.writeByte(247),oi.writeVariableInt(e,t.length),t.copyTo(e)}}class co extends er{metronomeNumerator;metronomeDurationInTicks;metronomeDurationInMilliseconds;isMetronome=!0;constructor(e,t,s,i,r){super(e,t,Ie.AlphaTabMetronome),this.metronomeNumerator=s,this.metronomeDurationInMilliseconds=r,this.metronomeDurationInTicks=i}writeEventData(e){e.writeByte(er.MetronomeEventId),e.writeByte(this.metronomeNumerator),k.writeInt32LE(e,this.metronomeDurationInTicks),k.writeInt32LE(e,this.metronomeDurationInMilliseconds)}}class uo extends er{channel;constructor(e,t,s){super(e,t,Ie.AlphaTabRest),this.channel=s}writeEventData(e){e.writeByte(er.RestEventId),e.writeByte(this.channel)}}class fo extends ei{channel;noteKey;noteVelocity;constructor(e,t,s,i,r,n){super(e,t,s),this.channel=i,this.noteKey=r,this.noteVelocity=n}get data1(){return this.noteKey}get data2(){return this.noteVelocity}}class po extends fo{constructor(e,t,s,i,r){super(e,t,Ie.NoteOn,s,i,r)}writeTo(e){e.writeByte(this.channel&15|144),e.writeByte(this.noteKey&255),e.writeByte(this.noteVelocity&255)}}class go extends fo{constructor(e,t,s,i,r){super(e,t,Ie.NoteOff,s,i,r)}writeTo(e){e.writeByte(this.channel&15|128),e.writeByte(this.noteKey&255),e.writeByte(this.noteVelocity&255)}}class mo extends ei{channel;controller;value;constructor(e,t,s,i,r){super(e,t,Ie.ControlChange),this.channel=s,this.controller=i,this.value=r}writeTo(e){e.writeByte(this.channel&15|176),e.writeByte(this.controller&255),e.writeByte(this.value&255)}get data1(){return this.controller}get data2(){return this.value}}class yo extends ei{channel;program;constructor(e,t,s,i){super(e,t,Ie.ProgramChange),this.channel=s,this.program=i}writeTo(e){e.writeByte(this.channel&15|192),e.writeByte(this.program&255)}get data1(){return this.program}}class bo extends ei{get microSecondsPerQuarterNote(){return 6e7/this.beatsPerMinute}set microSecondsPerQuarterNote(e){this.beatsPerMinute=6e7/e}beatsPerMinute=0;constructor(e,t){super(0,e,Ie.TempoChange),this.microSecondsPerQuarterNote=t}writeTo(e){e.writeByte(255),e.writeByte(81),e.writeByte(3),e.writeByte(this.microSecondsPerQuarterNote>>16&255),e.writeByte(this.microSecondsPerQuarterNote>>8&255),e.writeByte(this.microSecondsPerQuarterNote&255)}}class _o extends ei{channel;value;constructor(e,t,s,i){super(e,t,Ie.PitchBend),this.channel=s,this.value=i}writeTo(e){e.writeByte(this.channel&15|224),e.writeByte(this.value&127),e.writeByte(this.value>>7&127)}get data1(){return this.value&127}get data2(){return this.value>>7&127}}class So extends ei{channel;noteKey;value;constructor(e,t,s,i,r){super(e,t,Ie.PerNotePitchBend),this.channel=s,this.noteKey=i,this.value=r}writeTo(e){throw new Ye(Ge.General,"Note Bend (Midi2.0) events cannot be exported to SMF1.0")}}class ko extends ei{constructor(e,t){super(e,t,Ie.EndOfTrack)}writeTo(e){e.writeByte(255),e.writeByte(47),e.writeByte(0)}}class Lr{eventIndex;event;isMetronome;time=0;constructor(e,t){this.eventIndex=e,this.event=t,this.isMetronome=this.event.type===Ie.AlphaTabMetronome}static newMetronomeEvent(e,t,s,i,r){const n=new co(0,t,s,i,r);return new Lr(e,n)}}class lr{masterBarIndex=0;masterBarOccurence=0;synthBpm=0;synthTime=0;synthTick=0;syncTime=0;syncBpm=0;updateSyncBpm(e,t){const s=e-this.synthTime,i=t-this.syncTime,r=s/i*this.synthBpm;this.syncBpm=r}}class sl{bpm;ticks;time;constructor(e,t,s){this.bpm=e,this.ticks=t,this.time=s}}class Ln{tempoChanges=[];tempoChangeIndex=0;syncPoints=[];firstProgramEventPerChannel=new Map;firstTimeSignatureNumerator=0;firstTimeSignatureDenominator=0;synthData=[];division=B.QuarterTime;eventIndex=0;currentTime=0;syncPointIndex=0;playbackRange=null;playbackRangeStartTime=0;playbackRangeEndTime=0;endTick=0;endTime=0;currentTempo=0;syncPointTempo=0}class zi{_synthesizer;_currentState;_mainState;_oneTimeState=null;_countInState=null;get isPlayingMain(){return this._currentState===this._mainState}get isPlayingOneTimeMidi(){return this._currentState===this._oneTimeState}get isPlayingCountIn(){return this._currentState===this._countInState}constructor(e){this._synthesizer=e,this._mainState=new Ln,this._currentState=this._mainState}get mainPlaybackRange(){return this._mainState.playbackRange}set mainPlaybackRange(e){this._mainState.playbackRange=e,e&&(this._mainState.playbackRangeStartTime=this._tickPositionToTimePositionWithSpeed(this._mainState,e.startTick,1),this._mainState.playbackRangeEndTime=this._tickPositionToTimePositionWithSpeed(this._mainState,e.endTick,1))}isLooping=!1;get currentTime(){return this._currentState.currentTime/this.playbackSpeed}get currentEndTick(){return this._currentState.endTick}get currentEndTime(){return this._currentState.endTime/this.playbackSpeed}get currentTempo(){return this._currentState.currentTempo}get modifiedTempo(){return this._currentState.syncPointTempo*this.playbackSpeed}get syncPointTempo(){return this._currentState.syncPointTempo}get currentSyncPoints(){return this._currentState.syncPoints}playbackSpeed=1;mainSeek(e){if(e*=this.playbackSpeed,this.mainPlaybackRange&&(e<this._mainState.playbackRangeStartTime?e=this._mainState.playbackRangeStartTime:e>this._mainState.playbackRangeEndTime&&(e=this._mainState.playbackRangeEndTime)),e>this._mainState.currentTime)this._mainSilentProcess(e-this._mainState.currentTime);else if(e<this._mainState.currentTime){if(this._mainState.currentTime=0,this._mainState.eventIndex=0,this._mainState.syncPointIndex=0,this._mainState.tempoChangeIndex=0,this._mainState.currentTempo=this._mainState.tempoChanges[0].bpm,this._mainState.syncPointTempo=this._mainState.syncPoints.length>0?this._mainState.syncPoints[0].syncBpm:this._mainState.currentTempo,this.isPlayingMain){const t=this._synthesizer.metronomeVolume;this._synthesizer.noteOffAll(!0),this._synthesizer.resetSoft(),this._synthesizer.setupMetronomeChannel(t)}this._mainSilentProcess(e)}}_mainSilentProcess(e){if(e<=0)return;const t=Date.now(),s=this._mainState.currentTime+e;if(this.isPlayingMain)for(;this._mainState.currentTime<s;)this._fillMidiEventQueueLimited(s-this._mainState.currentTime)&&this._synthesizer.synthesizeSilent(de.MicroBufferSize);this._mainState.currentTime=s;const i=Date.now()-t;E.debug("Sequencer",`Silent seek finished in ${i}ms (main)`)}loadOneTimeMidi(e){this._oneTimeState=this.createStateFromFile(e),this._currentState=this._oneTimeState}instrumentPrograms=new Set;percussionKeys=new Set;loadMidi(e){this.instrumentPrograms.clear(),this.percussionKeys.clear(),this._mainState=this.createStateFromFile(e),this._currentState=this._mainState}createStateFromFile(e){const t=new Ln;this.percussionKeys.add(de.MetronomeKey),t.tempoChanges=[],t.division=e.division,t.eventIndex=0,t.currentTime=0,t.synthData=[];let s=120,i=0,r=0,n=0,o=0,l=0,h=e.tickShift,c=0,d=0;for(const f of e.events){const p=new Lr(t.synthData.length,f);t.synthData.push(p);const g=f.tick-d;if(i+=g,r+=g*(6e4/(s*e.division)),p.time=r,d=f.tick,o>0)for(;h<i;){const m=Lr.newMetronomeEvent(t.synthData.length,h,Math.floor(h/o)%n,o,l);t.synthData.push(m),m.time=c,h+=o,c+=l}if(f.type===Ie.TempoChange){const m=f;s=zi._sanitizeBpm(m.beatsPerMinute),t.tempoChanges.push(new sl(s,i,r)),l=o*(6e4/(s*e.division))}else if(f.type===Ie.TimeSignature){const m=f,b=Math.pow(2,m.denominatorIndex);n=m.numerator,o=t.division*(4/b)|0,l=o*(6e4/(s*e.division)),t.firstTimeSignatureDenominator===0&&(t.firstTimeSignatureNumerator=m.numerator,t.firstTimeSignatureDenominator=b)}else if(f.type===Ie.ProgramChange){const m=f,b=m.channel;t.firstProgramEventPerChannel.has(b)||t.firstProgramEventPerChannel.set(b,p),b===de.PercussionChannel||this.instrumentPrograms.add(m.program)}else if(f.type===Ie.NoteOn){const m=f;m.channel===de.PercussionChannel&&this.percussionKeys.add(m.noteKey)}}return t.currentTempo=t.tempoChanges.length>0?t.tempoChanges[0].bpm:s,t.syncPointTempo=t.currentTempo,t.synthData.sort((f,p)=>f.time>p.time?1:f.time<p.time?-1:f.eventIndex-p.eventIndex),t.endTime=r,t.endTick=i,t}fillMidiEventQueue(){return this._fillMidiEventQueueLimited(-1)}fillMidiEventQueueToEndTime(e){for(;this._mainState.currentTime<e;)this._fillMidiEventQueueLimited(e-this._mainState.currentTime)&&this._synthesizer.synthesizeSilent(de.MicroBufferSize);let t=!1;for(this._currentState.currentTime=e;this._currentState.eventIndex<this._currentState.synthData.length&&this._currentState.synthData[this._currentState.eventIndex].time<this._currentState.currentTime;){const s=this._currentState.synthData[this._currentState.eventIndex];this._synthesizer.dispatchEvent(s),this._currentState.eventIndex++,t=!0}return t}_fillMidiEventQueueLimited(e){let t=de.MicroBufferSize/this._synthesizer.outSampleRate*1e3*this.playbackSpeed,s=this._internalEndTime;e>0&&(e<t&&(t=e),s=Math.min(this._internalEndTime,this._currentState.currentTime+e));let i=!1;for(this._currentState.currentTime+=t;this._currentState.eventIndex<this._currentState.synthData.length&&this._currentState.synthData[this._currentState.eventIndex].time<this._currentState.currentTime&&this._currentState.currentTime<s;)this._synthesizer.dispatchEvent(this._currentState.synthData[this._currentState.eventIndex]),this._currentState.eventIndex++,i=!0;return i}mainTickPositionToTimePosition(e){return this._tickPositionToTimePositionWithSpeed(this._mainState,e,this.playbackSpeed)}mainUpdateSyncPoints(e){const t=this._mainState;if(e.sort((s,i)=>s.synthTick-i.synthTick),t.syncPoints=[],e.length>=0){let s=120,i=0,r=0,n=0;for(let o=0;o<e.length;o++){const l=e[o];let h=0,c,d,f;if(o===0)c=s,d=0,f=0;else{const p=e[o-1];c=zi._sanitizeBpm(p.syncBpm),d=p.syncTime,f=p.synthTick}for(;n<t.tempoChanges.length&&t.tempoChanges[n].ticks<=l.synthTick;){if(h=t.tempoChanges[n].ticks-i,h>0){i+=h,r+=h*(6e4/(s*t.division));const p=(l.syncTime-d)/(l.synthTick-f),g=(i-f)*p+d,m=new lr;m.synthTick=i,m.synthBpm=s,m.synthTime=r,m.syncTime=g,m.syncBpm=c}s=zi._sanitizeBpm(t.tempoChanges[n].bpm),n++}h=l.synthTick-i,i+=h,r+=h*(6e4/(s*t.division)),t.syncPoints.push(l)}}t.syncPointIndex=0,t.syncPointTempo=t.syncPoints.length>0?t.syncPoints[0].syncBpm:t.currentTempo}currentTimePositionToTickPosition(e){const t=this._currentState;if(t.tempoChanges.length===0)return 0;e*=this.playbackSpeed,this._updateCurrentTempo(t,e);const s=t.tempoChanges[t.tempoChangeIndex],r=(e-s.time)/(6e4/(zi._sanitizeBpm(s.bpm)*t.division))|0;return s.ticks+r+1}static _sanitizeBpm(e){return Math.max(e,1)}currentUpdateCurrentTempo(e){this._updateCurrentTempo(this._mainState,e*this.playbackSpeed)}_updateCurrentTempo(e,t){let s=e.tempoChangeIndex;for(t<e.tempoChanges[s].time&&(s=0);s+1<e.tempoChanges.length&&e.tempoChanges[s+1].time<=t;)s++;s!==e.tempoChangeIndex&&(e.tempoChangeIndex=s,e.currentTempo=e.tempoChanges[e.tempoChangeIndex].bpm,e.syncPoints.length===0&&(e.syncPointTempo=e.currentTempo))}currentUpdateSyncPoints(e){this._updateSyncPoints(this._mainState,e)}_updateSyncPoints(e,t){const s=e.syncPoints;if(s.length>0){let i=Math.min(e.syncPointIndex,s.length-1);for(t<s[i].syncTime&&(i=0);i+1<s.length&&s[i+1].syncTime<=t;)i++;i!==e.syncPointIndex&&(e.syncPointIndex=i,e.syncPointTempo=s[i].syncBpm)}else e.syncPointTempo=e.currentTempo}mainTimePositionFromBackingTrack(e,t){const s=this._mainState,i=s.syncPoints;if(e<0||i.length===0)return e;this._updateSyncPoints(this._mainState,e);const r=Math.min(s.syncPointIndex,i.length-1),n=i[r],o=e-n.syncTime;let l;if(r+1<i.length){const h=i[r+1],c=o/(h.syncTime-n.syncTime);l=(h.synthTime-n.synthTime)*c}else{const h=o/(t-n.syncTime);l=(s.endTime-n.synthTime)*h}return(n.synthTime+l)/this.playbackSpeed}mainTimePositionToBackingTrack(e,t){const s=this._mainState,i=s.syncPoints;if(e<0||i.length===0)return e;e*=this.playbackSpeed;let r=Math.min(s.syncPointIndex,i.length-1);for(e<i[r].synthTime&&(r=0);r+1<i.length&&i[r+1].synthTime<=e;)r++;const n=i[r],o=e-n.synthTime;let l;if(r+1<i.length){const h=i[r+1],c=o/(h.synthTime-n.synthTime),d=h.syncTime-n.syncTime;l=n.syncTime+d*c}else{const h=o/(s.endTime-n.synthTime),c=t-n.syncTime;l=n.syncTime+c*h}return l}_tickPositionToTimePositionWithSpeed(e,t,s){let i=0,r=120,n=0;for(const o of e.tempoChanges){if(t<o.ticks)break;i=o.time,r=o.bpm,n=o.ticks}return t-=n,i+=t*(6e4/(r*e.division)),i/s}get _internalEndTime(){return this.isPlayingMain?this.mainPlaybackRange?this._currentState.playbackRangeEndTime:this._currentState.endTime:this._currentState.endTime}get isFinished(){return this._currentState.currentTime>=this._internalEndTime}stop(){this.isPlayingMain&&this.mainPlaybackRange?this._currentState.currentTime=this.mainPlaybackRange.startTick:this._currentState.currentTime=0,this._currentState.eventIndex=0}resetOneTimeMidi(){this._oneTimeState=null,this._currentState=this._mainState}resetCountIn(){this._countInState=null,this._currentState=this._mainState}startCountIn(){this.generateCountInMidi(),this._currentState=this._countInState,this.stop(),this._synthesizer.noteOffAll(!0)}generateCountInMidi(){const e=new Ln;e.division=this._mainState.division;let t=120,s=4,i=4;this._mainState.eventIndex===0?(t=this._mainState.tempoChanges[0].bpm,s=this._mainState.firstTimeSignatureNumerator,i=this._mainState.firstTimeSignatureDenominator):(t=this._synthesizer.currentTempo,s=this._synthesizer.timeSignatureNumerator,i=this._synthesizer.timeSignatureDenominator),e.tempoChanges.push(new sl(t,0,0));const r=e.division*(4/i)|0,n=r*(6e4/(t*this._mainState.division));let o=0,l=0;for(let h=0;h<s;h++){const c=Lr.newMetronomeEvent(e.synthData.length,o,h,r,n);e.synthData.push(c),c.time=l,o+=r,l+=n}e.synthData.sort((h,c)=>h.time>c.time?1:h.time<c.time?-1:h.eventIndex-c.eventIndex),e.endTime=l,e.endTick=o,e.currentTempo=t,e.syncPointTempo=t,this._countInState=e}}var Rt;(function(a){a[a.Paused=0]="Paused",a[a.Playing=1]="Playing"})(Rt||(Rt={}));class Yi{state;stopped;constructor(e,t){this.state=e,this.stopped=t}}class Ys{currentTime;endTime;currentTick;endTick;isSeek;originalTempo=0;modifiedTempo=0;constructor(e,t,s,i,r,n,o){this.currentTime=e,this.endTime=t,this.currentTick=s,this.endTick=i,this.isSeek=r,this.originalTempo=n,this.modifiedTempo=o}}class Ms{static HeaderSize=8;id="";size=0;static load(e,t,s){if(e&&Ms.HeaderSize>e.size||s.position+Ms.HeaderSize>
10=s.length||(t.id=k.read8BitStringLength(s,4),t.id.charCodeAt(0)<=32||t.id.charCodeAt(0)>=122)||(t.size=k.readUInt32LE(s),e&&Ms.HeaderSize+t.size>e.size))return!1;e&&(e.size-=Ms.HeaderSize+t.size);const i=t.id==="RIFF",r=t.id==="LIST";return i&&e?!1:!i&&!r?!0:(t.id=k.read8BitStringLength(s,4),t.id.charCodeAt(0)<=32||t.id.charCodeAt(0)>=122?!1:(t.size-=4,!0))}}class $h{packetData;isBeginningOfStream;isEndOfStream;granulePosition;constructor(e,t,s,i){this.packetData=e,this.isBeginningOfStream=t,this.isEndOfStream=s,this.granulePosition=s?i:null}addData(e){const t=this.packetData,s=new Uint8Array(t.length+e.length);s.set(t,0),s.set(e,t.length)}}var Fr;(function(a){a[a.ContinuesPacket=1]="ContinuesPacket",a[a.BeginningOfStream=2]="BeginningOfStream",a[a.EndOfStream=4]="EndOfStream"})(Fr||(Fr={}));class Jh{_readable;constructor(e){this._readable=e}read(){const e=[];for(;this._findAndReadPage(e););return e}_findAndReadPage(e){return this._seekPageHeader()?this._readPage(e):!1}_seekPageHeader(){for(let e=0;e<65536;e++){if(k.readInt32LE(this._readable)===1399285583)return!0;this._readable.position-=3}return!1}_readPage(e){const t=this._readable.readByte();if(t===-1||t!==0)return!1;const s=this._readable.readByte(),i=k.readInt64LE(this._readable);this._readable.skip(4),this._readable.skip(4),this._readable.skip(4);const r=this._readable.readByte();if(r===-1)return!1;const n=[];let o=0;for(let l=0;l<r;l++){const h=this._readable.readByte();o===n.length&&n.push(0),n[o]+=h,h<255&&o++}for(let l=0;l<n.length;l++){const h=new Uint8Array(n[l]);if(this._readable.read(h,0,h.length)!==h.length)return!1;if((s&Fr.ContinuesPacket)!==0){if(e.length===0)throw new Ye(Ge.Format,"OGG: Continuation page without any previous packets");e[e.length-1].addData(h)}else{const d=new $h(h,(s&Fr.BeginningOfStream)!==0&&l===0,(s&Fr.EndOfStream)!==0&&l===n.length-1,i);e.push(d)}}return!0}}class qh{audioChannels=0;audioSampleRate=0;samples=new Float32Array(0);bitrateMaximum=0;bitrateNominal=0;bitrateMinimum=0;blocksize0=0;blocksize1=0}class il{value=0;bitsRead=0}class mn{static _byteSize=8;_source;_bitBucket=0n;_bitCount=0n;_overflowBits=0n;constructor(e){this._source=e}readByte(){return this.readBits(mn._byteSize)}readBit(){return this.readBits(1)===1}readBytes(e){const t=new Uint8Array(e);for(let s=0;s<e;s++)t[s]=this.readByte()&255;return t}readBits(e){if(e===0)return 0;const t=this.tryPeekBits(e);return this.skipBits(e),t.value}tryPeekBits(e){if(e<0||e>32)throw new Ye(Ge.General,"IO: Cannot read more than 32 bits in one go");if(e===0)return new il;const t=new il;for(;this._bitCount<e;){const i=BigInt(this._source.readByte());if(i===-1n)return t.bitsRead=Number(this._bitCount),t.value=Number(this._bitBucket),this._bitBucket=0n,this._bitCount=0n,t;this._bitBucket=(i&0xffn)<<this._bitCount|this._bitBucket,this._bitCount+=8n,this._bitCount>32&&(this._overflowBits=i>>40n-this._bitCount&0xffn)}let s=this._bitBucket;return e<64&&(s=s&(1n<<BigInt(e))-1n),t.value=Number(s),t.bitsRead=e,t}skipBits(e){let t=BigInt(e);if(e!==0)if(this._bitCount>t){if(e>31?this._bitBucket=0n:this._bitBucket=this._bitBucket>>t,this._bitCount>32){const s=this._bitCount-32n;this._bitBucket=this._bitBucket|this._overflowBits<<this._bitCount-t-s,s>e&&(this._overflowBits=this._overflowBits>>t&0xffn)}this._bitCount-=t}else if(this._bitCount===t)this._bitBucket=0n,this._bitCount=0n;else{for(t-=this._bitCount,this._bitCount=0n,this._bitBucket=0n;t>8;){if(this._source.readByte()===-1){t=0n;break}t-=8n}if(t>0){const s=BigInt(this._source.readByte());s===-1n||(this._bitBucket=s>>t,this._bitCount=8n-t)}}}}class Qh{codebooks=[];timeDomainTransforms=[];floors=[];residues=[];mappings=[];modes=[]}class li{static ilog(e){let t=0;for(;e>0;)++t,e>>=1;return t}static bitReverse(e,t=32){let s=BigInt(e);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(t),Number(BigInt.asUintN(32,s))}static convertFromVorbisFloat32(e){const t=BigInt(e);let s=t&BigInt(2097151);const i=t&BigInt(2147483648),r=(t&BigInt(2145386496))>>21n;return i!==0n&&(s=-s),Number(s)*Math.pow(2,Number(r)-788)}}class Kh{_data;constructor(e){this._data=e}get(e){return this._data[e]}}class wo{static instance=new wo;get(e){return e}}class Zh{_lengths;_maxBits=0;_overflowList=null;_prefixList=null;_prefixBitLength=0;_lookupTable;dimensions=0;entries=0;mapType=0;constructor(e,t){if(e.readBits(24)!==5653314)throw new Ye(Ge.Format,"Vorbis: Book header had invalid signature!");this.dimensions=e.readBits(16),this.entries=e.readBits(24),this._lengths=new Int32Array(this.entries),this._initTree(e,t),this._initLookupTable(e)}get(e,t){return this._lookupTable[e*this.dimensions+t]}decodeScalar(e){let t=e.tryPeekBits(this._prefixBitLength);if(t.bitsRead===0)return-1;let s=this._prefixList[t.value];if(s!=null)return e.skipBits(s.length),s.value;if(t=e.tryPeekBits(this._maxBits),this._overflowList!==null)for(let i=0;i<this._overflowList.length;i++){s=this._overflowList[i];const r=t.value&s.mask;if(s.bits===r)return e.skipBits(s.length),s.value}return-1}_initTree(e,t){let s,i=0,r;if(e.readBit()){let n=e.readBits(5)+1;for(let o=0;o<this.entries;){let l=e.readBits(li.ilog(this.entries-o));for(;--l>=0;)this._lengths[o++]=n;++n}i=0,s=!1,r=n}else{r=-1,s=e.readBit();for(let n=0;n<this.entries;n++)!s||e.readBit()?(this._lengths[n]=e.readBits(5)+1,++i):this._lengths[n]=-1,this._lengths[n]>r&&(r=this._lengths[n])}if(this._maxBits=r,r>-1){let n=null;s&&i>=this.entries>>2&&(n=new Int32Array(this.entries),n.set(this._lengths.subarray(0,this.entries),0),s=!1);let o;s?o=i:o=0;let l=null,h=null;if(s?o!==0&&(n=new Int32Array(o),h=new Int32Array(o),l=new Int32Array(o)):h=new Int32Array(this.entries),!this._computeCodewords(s,h,n,this._lengths,this.entries,l))throw new Ye(Ge.Format,"Vorbis: Failed to compute codewords");const c=l==null?wo.instance:new Kh(l);t.generateTable(c,n??this._lengths,h),this._prefixList=t.prefixTree,this._prefixBitLength=t.tableBits,this._overflowList=t.overflowList}}_computeCodewords(e,t,s,i,r,n){const o=new Uint32Array(32);let l=0,h=0;for(l=0;l<r&&!(i[l]>0);++l);if(l===r)return!0;this._addEntry(e,t,s,0,l,h++,i[l],n);for(let c=1;c<=i[l];++c)o[c]=1<<32-c;for(let c=l+1;c<r;++c){let d=i[c];if(d<=0)continue;for(;d>0&&o[d]===0;)--d;if(d===0)return!1;const f=o[d];if(o[d]=0,this._addEntry(e,t,s,li.bitReverse(f),c,h++,i[c],n),d!==i[c])for(let p=i[c];p>d;--p)o[p]=f+(1<<32-p)}return!0}_addEntry(e,t,s,i,r,n,o,l){e?(t[n]=i,s[n]=o,l[n]=r):t[r]=i}_initLookupTable(e){if(this.mapType=e.readBits(4),this.mapType===0)return;const t=li.convertFromVorbisFloat32(e.readBits(32)),s=li.convertFromVorbisFloat32(e.readBits(32)),i=e.readBits(4)+1,r=e.readBit();let n=this.entries*this.dimensions;const o=new Float32Array(n);this.mapType===1&&(n=this._lookup1Values());const l=new Uint32Array(n);for(let h=0;h<n;h++)l[h]=e.readBits(i);if(this.mapType===1)for(let h=0;h<this.entries;h++){let c=0,d=1;for(let f=0;f<this.dimensions;
vendor: 23,696 bytes, line 10
10f++){const p=h/d%n|0,g=l[p]*s+t+c;o[h*this.dimensions+f]=g,r&&(c=g),d*=n}}else for(let h=0;h<this.entries;h++){let c=0,d=h*this.dimensions;for(let f=0;f<this.dimensions;f++){const p=l[d]*s+t+c;o[h*this.dimensions+f]=p,r&&(c=p),++d}}this._lookupTable=o}_lookup1Values(){let e=Math.floor(Math.exp(Math.log(this.entries)/this.dimensions));return Math.floor(Math.pow(e+1,this.dimensions))<=this.entries&&++e,e}}class jh{value=0;length=0;bits=0;mask=0}class wa{static maxTableBits=10;tableBits=0;prefixTree=[];overflowList=null;generateTable(e,t,s){const i=new Array(t.length);let r=0;for(let h=0;h<i.length;h++){const c=new jh;c.value=e.get(h),c.length=t[h]<=0?99999:t[h],c.bits=s[h],c.mask=(1<<t[h])-1,i[h]=c,t[h]>0&&r<t[h]&&(r=t[h])}i.sort((h,c)=>{const d=h.length-c.length;return d===0?h.bits-c.bits:d});const n=r>wa.maxTableBits?wa.maxTableBits:r,o=[];let l=null;for(let h=0;h<i.length&&i[h].length<99999;h++){const c=i[h].length;if(c>n)for(l=[];h<i.length&&i[h].length<99999;h++)l.push(i[h]);else{const d=1<<n-c,f=i[h];for(let p=0;p<d;p++){const g=p<<c|f.bits;for(;o.length<=g;)o.push(null);o[g]=f}}}for(;o.length<1<<n;)o.push(null);this.tableBits=n,this.prefixTree=o,this.overflowList=l}}class ec{constructor(e){e.readBits(16)}}class tc{coeff;amp=0;get executeChannel(){return(this.forceEnergy||this.amp>0)&&!this.forceNoEnergy}forceEnergy=!1;forceNoEnergy=!1;constructor(e){this.coeff=e}}class Ba{_order;_rate;_barkMapSize;_ampBits;_ampOfs;_ampDiv;_books;_bookBits;_wMap;_barkMaps;constructor(e,t,s,i){if(this._order=e.readBits(8),this._rate=e.readBits(16),this._barkMapSize=e.readBits(16),this._ampBits=e.readBits(6),this._ampOfs=e.readBits(8),this._books=new Array(e.readBits(4)+1),this._order<1||this._rate<1||this._barkMapSize<1||this._books.length===0)throw new Ye(Ge.Format,"Vorbis: Invalid Floor0 Data");this._ampDiv=(1<<this._ampBits)-1;for(let r=0;r<this._books.length;r++){const n=e.readBits(8);if(n<0||n>=i.length)throw new Ye(Ge.Format,"Vorbis: Invalid Floor0 Data");const o=i[n];if(o.mapType===0||o.dimensions<1)throw new Ye(Ge.Format,"Vorbis: Invalid Floor0 Data");this._books[r]=o}this._bookBits=li.ilog(this._books.length),this._barkMaps=new Map([[t,this._synthesizeBarkCurve(t/2)],[s,this._synthesizeBarkCurve(s/2)]]),this._wMap=new Map([[t,this._synthesizeWDelMap(t/2)],[s,this._synthesizeWDelMap(s/2)]])}_synthesizeBarkCurve(e){const t=this._barkMapSize/Ba._toBARK(this._rate/2),s=new Int32Array(e+1);for(let i=0;i<e-1;i++)s[i]=Math.min(this._barkMapSize-1,Math.floor(Ba._toBARK(this._rate/2/e*i)*t));return s[e]=-1,s}static _toBARK(e){return 13.1*Math.atan(74e-5*e)+2.24*Math.atan(185e-10*e*e)+1e-4*e}_synthesizeWDelMap(e){const t=Math.PI/this._barkMapSize,s=new Float32Array(e);for(let i=0;i<e;i++)s[i]=2*Math.cos(t*i);return s}unpack(e,t,s){const i=new tc(new Float32Array(this._order+1));if(i.amp=e.readBits(this._ampBits),i.amp>0){i.amp=i.amp/this._ampDiv*this._ampOfs;const r=e.readBits(this._bookBits);if(r>=this._books.length)return i.amp=0,i;const n=this._books[r];for(let l=0;l<this._order;){const h=n.decodeScalar(e);if(h===-1)return i.amp=0,i;for(let c=0;l<this._order&&c<n.dimensions;c++,l++)i.coeff[l]=n.get(h,c)}let o=0;for(let l=0;l<this._order;){for(let h=0;l<this._order&&h<n.dimensions;l++,h++)i.coeff[l]+=o;o=i.coeff[l-1]}}return i}apply(e,t,s){const i=e,r=t/2;if(i.amp>0){const n=this._barkMaps.get(t),o=this._wMap.get(t);let l=0;for(l=0;l<this._order;l++)i.coeff[l]=2*Math.cos(i.coeff[l]);for(l=0;l<r;){let h=0;const c=n[l];let d=.5,f=.5;const p=o[c];for(h=1;h<this._order;h+=2)f*=p-i.coeff[h-1],d*=p-i.coeff[h];for(h===this._order?(f*=p-i.coeff[h-1],d*=d*(4-p*p),f*=f):(d*=d*(2-p),f*=f*(2+p)),f=i.amp/Math.sqrt(d+f)-this._ampOfs,f=Math.exp(f*.11512925),s[l]*=f;n[++l]===c;)s[l]*=f}}else s.fill(0,0,r)}}class sc{posts=new Int32Array(64);postCount=0;get executeChannel(){return(this.forceEnergy||this.postCount>0)&&!this.forceNoEnergy}forceEnergy=!1;forceNoEnergy=!1}class hr{static _rangeLookup=[256,128,86,64];static _yBitsLookup=[8,7,7,6];_partitionClass;_classDimensions;_classSubclasses;_xList;_classMasterBookIndex;_hNeigh;_lNeigh;_sortIdx;_multiplier;_range;_yBits;_classMasterbooks;_subclassBooks;_subclassBookIndex;constructor(e,t){let s=-1;this._partitionClass=new Int32Array(e.readBits(5));for(let n=0;n<this._partitionClass.length;n++)this._partitionClass[n]=e.readBits(4),this._partitionClass[n]>s&&(s=this._partitionClass[n]);++s,this._classDimensions=new Int32Array(s),this._classSubclasses=new Int32Array(s),this._classMasterbooks=new Array(s),this._classMasterBookIndex=new Int32Array(s),this._subclassBooks=new Array(s),this._subclassBookIndex=new Array(s);for(let n=0;n<s;n++){this._classDimensions[n]=e.readBits(3)+1,this._classSubclasses[n]=e.readBits(2),this._classSubclasses[n]>0&&(this._classMasterBookIndex[n]=e.readBits(8),this._classMasterbooks[n]=t[this._classMasterBookIndex[n]]),this._subclassBooks[n]=new Array(1<<this._classSubclasses[n]),this._subclassBookIndex[n]=new Int32Array(this._subclassBooks[n].length);for(let o=0;o<this._subclassBooks[n].length;o++){const l=e.readBits(8)-1;l>=0&&(this._subclassBooks[n][o]=t[l]),this._subclassBookIndex[n][o]=l}}this._multiplier=e.readBits(2),this._range=hr._rangeLookup[this._multiplier],this._yBits=hr._yBitsLookup[this._multiplier],++this._multiplier;const i=e.readBits(4),r=[];r.push(0),r.push(1<<i);for(let n=0;n<this._partitionClass.length;n++){const o=this._partitionClass[n];for(let l=0;l<this._classDimensions[o];l++)r.push(e.readBits(i))}this._xList=new Int32Array(r),this._lNeigh=new Int32Array(r.length),this._hNeigh=new Int32Array(r.length),this._sortIdx=new Int32Array(r.length),this._sortIdx[0]=0,this._sortIdx[1]=1;for(let n=2;n<this._lNeigh.length;n++){this._lNeigh[n]=0,this._hNeigh[n]=1,this._sortIdx[n]=n;for(let o=2;o<n;o++){const l=this._xList[o];l<this._xList[n]?l>this._xList[this._lNeigh[n]]&&(this._lNeigh[n]=o):l<this._xList[this._hNeigh[n]]&&(this._hNeigh[n]=o)}}for(let n=0;n<this._sortIdx.length-1;n++)for(let o=n+1;o<this._sortIdx.length;o++){if(this._xList[n]===this._xList[o])throw new Ye(Ge.Format,"Vorbis: Invalid Floor1 Data");if(this._xList[this._sortIdx[n]]>this._xList[this._sortIdx[o]]){const l=this._sortIdx[n];this._sortIdx[n]=this._sortIdx[o],this._sortIdx[o]=l}}}unpack(e,t,s){const i=new sc;if(e.readBit()){let r=2;i.posts[0]=e.readBits(this._yBits),i.posts[1]=e.readBits(this._yBits);for(let n=0;n<this._partitionClass.length;n++){const o=this._partitionClass[n],l=this._classDimensions[o],h=this._classSubclasses[o],c=(1<<h)-1;let d=0;if(h>0&&(d=this._classMasterbooks[o].decodeScalar(e),d===-1)){r=0;break}for(let f=0;f<l;f++){const p=this._subclassBooks[o][d&c];if(d=d>>h,p!=null&&(i.posts[r]=p.decodeScalar(e),i.posts[r]===-1)){r=0,n=this._partitionClass.length;break}++r}}i.postCount=r}return i}apply(e,t,s){const i=e,r=t/2;if(i.postCount>0){const n=this._unwrapPosts(i);let o=0,l=i.posts[0]*this._multiplier;for(let h=1;h<i.postCount;h++){const c=this._sortIdx[h];if(n[c]){const d=this._xList[c],f=i.posts[c]*this._multiplier;o<r&&this._renderLineMulti(o,l,Math.min(d,r),f,s),o=d,l=f}if(o>=r)break}o<r&&this._renderLineMulti(o,l,r,l,s)}else s.fill(0,0,r)}_unwrapPosts(e){const t=new Array(64);t.fill(!1),t[0]=!0,t[1]=!0;const s=new Int32Array(64);s[0]=e.posts[0],s[1]=e.posts[1];for(let i=2;i<e.postCount;i++){const r=this._lNeigh[i],n=this._hNeigh[i],o=this._renderPoint(this._xList[r],s[r],this._xList[n],s[n],this._xList[i]),l=e.posts[i],h=this._range-o,c=o;let d;h<c?d=h*2:d=c*2,l!==0?(t[r]=!0,t[n]=!0,t[i]=!0,l>=d?h>c?s[i]=l-c+o:s[i]=o-l+h-1:l%2===1?s[i]=o-(l+1)/2:s[i]=o+l/2):(t[i]=!1,s[i]=o)}for(let i=0;i<e.postCount;i++)e.posts[i]=s[i];return t}_renderPoint(e,t,s,i,r){const n=i-t,o=s-e,c=Math.abs(n)*(r-e)/o|0;return n<0?t-c:t+c}_renderLineMulti(e,t,s,i,r){const n=i-t,o=s-e;let l=Math.abs(n);const h=1-(n>>31&1)*2,c=n/o|0;let d=e,f=t,p=-o;for(r[e]*=hr._inverseDbTable[t],l-=Math.abs(c)*o;++d<s;)f+=c,p+=l,p>=0&&(p-=o,f+=h),r[d]*=hr._inverseDbTable[f]}static _inverseDbTable=new Float32Array([10649863e-14,11341951e-14,12079015e-14,12863978e-14,13699951e-14,14590251e-14,15538408e-14,16548181e-14,17623575e-14,18768855e-14,19988561e-14,2128753e-13,22670913e-14,24144197e-14,25713223e-14,27384213e-14,29163793e-14,31059021e-14,33077411e-14,35226968e-14,37516214e-14,39954229e-14,4255068e-13,45315863e-14,48260743e-14,51396998e-14,54737065e-14,58294187e-14,62082472e-14,66116941e-14,70413592e-14,74989464e-14,79862701e-14,8505263e-13,90579828e-14,96466216e-14,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])}class ic{floor;constructor(e,t,s,i){const r=e.readBits(16);switch(r){case 0:this.floor=new Ba(e,t,s,i);break;case 1:this.floor=new hr(e,i);break;default:throw new Ye(Ge.Format,`Vorbis: Invalid Floor type: ${r}`)}}apply(e,t,s){this.floor.apply(e,t,s)}unpack(e,t,s){return this.floor.unpack(e,t,s)}}class na{_channels;_begin;_end;_partitionSize;_classifications;_maxStages;_books;_classBook;_cascade;_decodeMap;constructor(e,t,s){this._begin=e.readBits(24),this._end=e.readBits(24),this._partitionSize=e.readBits(24)+1,this._classifications=e.readBits(6)+1,this._classBook=s[e.readBits(8)],this._cascade=new Int32Array(this._classifications);let i=0;for(let d=0;d<this._classifications;d++){const f=e.readBits(3);e.readBit()?this._cascade[d]=e.readBits(5)<<3|f:this._cascade[d]=f,i+=na._icount(this._cascade[d])}const r=new Int32Array(i);for(let d=0;d<i;d++)if(r[d]=e.readBits(8),s[r[d]].mapType===0)throw new Ye(Ge.Format,"Vorbis: Invalid Residue 0");const n=this._classBook.entries;let o=this._classBook.dimensions,l=1;for(;o>0;){if(l*=this._classifications,l>n)throw new Ye(Ge.Format,"Vorbis: Invalid Residue 0");--o}this._books=new Array(this._classifications),i=0;let h=0,c;for(let d=0;d<this._classifications;d++)if(c=li.ilog(this._cascade[d]),this._books[d]=new Array(c),c>0){h=Math.max(h,c);for(let f=0;f<c;f++)(this._cascade[d]&1<<f)>0&&(this._books[d][f]=s[r[i++]])}this._maxStages=h,this._decodeMap=new Array(l);for(let d=0;d<l;d++){let f=d,p=l/this._classifications|0;this._decodeMap[d]=new Int32Array(this._classBook.dimensions);for(let g=0;g<this._classBook.dimensions;g++){const m=f/p|0;f-=m*p,p=p/this._classifications|0,this._decodeMap[d][g]=m}}this._channels=t}static _icount(e){let t=0;for(;e!==0;)t+=e&1,e>>=1;return t}decode(e,t,s,i){const n=(this._end<s/2?this._end:s/2)-this._begin;if(n>0&&t.indexOf(!1)!==-1){const o=n/this._partitionSize,l=(o+this._classBook.dimensions-1)/this._classBook.dimensions|0,h=[];for(let c=0;c<this._channels;c++)h.push(new Array(l));for(let c=0;c<this._maxStages;c++)for(let d=0,f=0;d<o;f++){if(c===0)for(let p=0;p<this._channels;p++){const g=this._classBook.decodeScalar(e);if(g>=0&&g<this._decodeMap.length)h[p][f]=this._decodeMap[g];else{d=o,c=this._maxStages;break}}for(let p=0;d<o&&p<this._classBook.dimensions;p++,d++){const g=this._begin+d*this._partitionSize;for(let m=0;m<this._channels;m++){const b=h[m][f][p];if((this._cascade[b]&1<<c)!==0){const S=this._books[b][c];if(S&&this.writeVectors(S,e,i,m,g,this._partitionSize)){d=o,c=this._maxStages;break}}}}}}}writeVectors(e,t,s,i,r,n){const o=s[i],l=n/e.dimensions,h=new Int32Array(l);for(let c=0;c<l;c++)if(h[c]=e.decodeScalar(t),h[c]===-1)return!0;for(let c=0;c<e.dimensions;c++)for(let d=0;d<l;d++,r++)o[r]+=e.get(h[d],c);return!1}}class rc extends na{writeVectors(e,t,s,i,r,n){const o=s[i];for(let l=0;l<n;){const h=e.decodeScalar(t);if(h===-1)return!0;for(let c=0;c<e.dimensions;l++,c++)o[r+l]+=e.get(h,c)}return!1}}class ac extends na{_realChannels;constructor(e,t,s){super(e,1,s),this._realChannels=t}decode(e,t,s,i){super.decode(e,t,s*this._realChannels,i)}writeVectors(e,t,s,i,r,n){let o=0;r/=this._realChannels;for(let l=0;l<n;){const h=e.decodeScalar(t);if(h===-1)return!0;for(let c=0;c<e.dimensions;c++,l++)s[o][r]+=e.get(h,c),++o===this._realChannels&&(o=0,r++)}return!1}}class nc{residue;constructor(e,t,s){const i=e.readBits(16);switch(i){case 0:this.residue=new na(e,t,s);break;case 1:this.residue=new rc(e,t,s);break;case 2:this.residue=new ac(e,t,s);break;default:throw new Ye(Ge.Format,`Vorbis: Invalid Residue type: ${i}`)}}decode(e,t,s,i){this.residue.decode(e,t,s,i)}}class oc{_mdct;_couplingAngle;_couplingMangitude;_submapFloor;_submapResidue;_channelFloor;_channelResidue;constructor(e,t,s,i,r){if(e.readBits(16)!==0)throw new Ye(Ge.Format,"Vorbis: Invalid mapping type!");let o=1;e.readBit()&&(o+=e.readBits(4));let l=0;e.readBit()&&(l=e.readBits(8)+1);const h=li.ilog(t-1);this._couplingAngle=new Int32Array(l),this._couplingMangitude=new Int32Array(l);for(let d=0;d<l;d++){const f=e.readBits(h),p=e.readBits(h);if(f===p||f>t-1||p>t-1)throw new Ye(Ge.Format,"Vorbis: Invalid magnitude or angle in mapping header!");this._couplingAngle[d]=p,this._couplingMangitude[d]=f}if(e.readBits(2)!==0)throw new Ye(Ge.Format,"Vorbis: Reserved bits not 0 in mapping header.");const c=new Int32Array(t);if(o>1){for(let d=0;d<t;d++)if(c[d]=e.readBits(4),c[d]>o)throw new Ye(Ge.Format,"Vorbis: Invalid channel mux submap index in mapping header!")}this._submapFloor=new Array(o),this._submapResidue=new Array(o);for(let d=0;d<o;d++){e.skipBits(8);const f=e.readBits(8);if(f>=s.length)throw new Ye(Ge.Format,"Vorbis: Invalid floor number in mapping header!");const p=e.readBits(8);if(p>=i.length)throw new Ye(Ge.Format,"Vorbis: Invalid residue number in mapping header!");this._submapFloor[d]=s[f],this._submapResidue[d]=i[p]}this._channelFloor=new Array(t),this._channelResidue=new Array(t);for(let d=0;d<t;d++)this._channelFloor[d]=this._submapFloor[c[d]],this._channelResidue[d]=this._submapResidue[c[d]];this._mdct=r}decodePacket(e,t,s){const i=t>>1,r=new Array(this._channelFloor.length),n=new Array(this._channelFloor.length);n.fill(!1);for(let o=0;o<this._channelFloor.length;o++)r[o]=this._channelFloor[o].unpack(e,t,o),n[o]=!r[o].executeChannel,s[o].fill(0,0,i);for(let o=0;o<this._couplingAngle.length;o++)(r[this._couplingAngle[o]].executeChannel||r[this._couplingMangitude[o]].executeChannel)&&(r[this._couplingAngle[o]].forceEnergy=!0,r[this._couplingMangitude[o]].forceEnergy=!0);for(let o=0;o<this._submapFloor.length;o++){for(let l=0;l<this._channelFloor.length;l++)(this._submapFloor[o]!==this._channelFloor[l]||this._submapResidue[o]!==this._channelResidue[l])&&(r[l].forceNoEnergy=!0);this._submapResidue[o].decode(e,n,t,s)}for(let o=this._couplingAngle.length-1;o>=0;o--)if(r[this._couplingAngle[o]].executeChannel||r[this._couplingMangitude[o]].executeChannel){const l=s[this._couplingMangitude[o]],h=s[this._couplingAngle[o]];for(let c=0;c<i;c++){let d,f;const p=l[c],g=h[c];p>0?g>0?(d=p,f=p-g):(f=p,d=p+g):g>0?(d=p,f=p+g):(f=p,d=p-g),l[c]=d,h[c]=f}}for(let o=0;o<this._channelFloor.length;o++)r[o].executeChannel?(this._channelFloor[o].apply(r[o],t,s[o]),this._mdct.reverse(s[o],t)):s[o].fill(0,i,i*2)}}class ql{packetStartIndex=0;packetTotalLength=0;packetValidLength=0}class lc{overlapInfo=new ql;windowIndex=0}class hc{samplePosition=null;constructor(e=null){this.samplePosition=e}}class ms{static _piHalf=3.1415926539/2;_channels;_blockFlag;_blockSize;_mapping;_windows;_overlapInfo=null;constructor(e,t,s,i,r){if(this._channels=t,this._blockFlag=e.readBit(),e.readBits(32)!==0)throw new Ye(Ge.Format,"Vorbis: Mode header had invalid window or transform type!");const n=e.readBits(8);if(n>=r.length)throw new Ye(Ge.Format,"Vorbis: Mode header had invalid mapping index!");this._mapping=r[n],this._blockFlag?(this._blockSize=i,this._windows=[ms._calcWindow(s,i,s),ms._calcWindow(i,i,s),ms._calcWindow(s,i,i),ms._calcWindow(i,i,i)],this._overlapInfo=[ms._calcOverlap(s,i,s),ms._calcOverlap(i,i,s),ms._calcOverlap(s,i,i),ms._calcOverlap(i,i,i)]):(this._blockSize=s,this._windows=[ms._calcWindow(s,s,s)])}decode(e,t){const s=this._getPacketInfo(e);this._mapping.decodePacket(e,this._blockSize,t);const i=this._windows[s.windowIndex];for(let r=0;r<this._blockSize;r++)for(let n=0;n<this._channels;n++)t[n][r]*=i[r];return s.overlapInfo}_getPacketInfo(e){const t=new lc;if(this._blockFlag){const s=e.readBit(),i=e.readBit();t.windowIndex=(s?1:0)+(i?2:0);const r=this._overlapInfo[t.windowIndex];t.overlapInfo.packetStartIndex=r.packetStartIndex,t.overlapInfo.packetValidLength=r.packetValidLength,t.overlapInfo.packetTotalLength=r.packetTotalLength}else t.windowIndex=0,t.overlapInfo.packetStartIndex=0,t.overlapInfo.packetValidLength=this._blockSize/2,t.overlapInfo.packetTotalLength=this._blockSize;return t}static _calcWindow(e,t,s){const i=new Float32Array(t),r=e/2,n=t,o=s/2,l=n/4-r/2,h=n-n/4-o/2;for(let c=0;c<r;c++){let d=Math.sin((c+.5)/r*ms._piHalf);d*=d,i[l+c]=Math.sin(d*ms._piHalf)}for(let c=l+r;c<h;c++)i[c]=1;for(let c=0;c<o;c++){let d=Math.sin((o-c-.5)/o*ms._piHalf);d*=d,i[h+c]=Math.sin(d*ms._piHalf)}return i}static _calcOverlap(e,t,s){const i=e/4,r=s/4,n=t/4-i,o=t/4*3+r,l=o-r*2,h=new ql;return h.packetStartIndex=n,h.packetValidLength=l,h.packetTotalLength=o,h}}class Ci{static _pi=3.141592653589793;_n;_n2;_n4;_n8;_ld;_a;_b;_c;_bitrev;constructor(e){this._n=e,this._n2=e>>1,this._n4=this._n2>>1,this._n8=this._n4>>1,this._ld=li.ilog(e)-1,this._a=new Float32Array(this._n2),this._b=new Float32Array(this._n2),this._c=new Float32Array(this._n4);let t=0,s=0;for(;t<this._n4;++t,s+=2)this._a[s]=Math.cos(4*t*Ci._pi/e),this._a[s+1]=-Math.sin(4*t*Ci._pi/e),this._b[s]=Math.cos((s+1)*Ci._pi/e/2)*.5,this._b[s+1]=Math.sin((s+1)*Ci._pi/e/2)*.5;for(t=0,s=0;t<this._n8;++t,s+=2)this._c[s]=Math.cos(2*(s+1)*Ci._pi/e),this._c[s+1]=-Math.sin(2*(s+1)*Ci._pi/e);this._bitrev=new Uint16Array(this._n8);for(let i=0;i<this._n8;++i)this._bitrev[i]=be.int32ToUint16(li.bitReverse(i,this._ld-3)<<2)}calcReverse(e){let t,s;const i=new Float32Array(this._n2);{let n=this._n2-2,o=0,l=0;const h=this._n2;for(;l!==h;)i[n+1]=e[l]*this._a[o]-e[l+2]*this._a[o+1],i[n]=e[l]*this._a[o+1]+e[l+2]*this._a[o],n-=2,o+=2,l+=4;for(l=this._n2-3;n>=0;)i[n+1]=-e[l+2]*this._a[o]- -e[l]*this._a[o+1],i[n]=-e[l+2]*this._a[o+1]+-e[l]*this._a[o],n-=2,o+=2,l-=4}t=e,s=i;{let n=this._n2-8,o=this._n4,l=0,h=this._n4,c=0;for(;n>=0;){let d,f;f=s[o+1]-s[l+1],d=s[o]-s[l],t[h+1]=s[o+1]+s[l+1],t[h]=s[o]+s[l],t[c+1]=f*this._a[n+4]-d*this._a[n+5],t[c]=d*this._a[n+4]+f*this._a[n+5],f=s[o+3]-s[l+3],d=s[o+2]-s[l+2],t[h+3]=s[o+3]+s[l+3],t[h+2]=s[o+2]+s[l+2],t[c+3]=f*this._a[n]-d*this._a[n+1],t[c+2]=d*this._a[n]+f*this._a[n+1],n-=8,h+=4,c+=4,o+=4,l+=4}}this._step3Iter0Loop(this._n>>4,t,this._n2-1-this._n4*0,-this._n8),this._step3Iter0Loop(this._n>>4,t,this._n2-1-this._n4*1,-this._n8),this._step3InnerRLoop(this._n>>5,t,this._n2-1-this._n8*0,-(this._n>>4),16),this._step3InnerRLoop(this._n>>5,t,this._n2-1-this._n8*1,-(this._n>>4),16),this._step3InnerRLoop(this._n>>5,t,this._n2-1-this._n8*2,-(this._n>>4),16),this._step3InnerRLoop(this._n>>5,t,this._n2-1-this._n8*3,-(this._n>>4),16);let r=2;for(;r<this._ld-3>>1;++r){const n=this._n>>r+2,o=n>>1,l=1<<r+1;for(let h=0;h<l;++h)this._step3InnerRLoop(this._n>>r+4,t,this._n2-1-n*h,-o,1<<r+3)}for(;r<this._ld-6;++r){const n=this._n>>r+2,o=1<<r+3,l=n>>1,h=this._n>>r+6,c=1<<r+1;let d=this._n2-1,f=0;for(let p=h;p>0;--p)this._step3InnerSLoop(c,t,d,-l,f,o,n),f+=o*4,d-=8}this._step3InnerSLoopLd654(this._n>>5,t,this._n2-1,this._n);{let n=0,o=this._n4-4,l=this._n2-4;for(;o>=0;){let h;h=this._bitrev[n],s[l+3]=t[h],s[l+2]=t[h+1],s[o+3]=t[h+2],s[o+2]=t[h+3],h=this._bitrev[n+1],s[l+1]=t[h],s[l]=t[h+1],s[o+1]=t[h+2],s[o]=t[h+3],o-=4,l-=4,n+=2}}{let n=0,o=0,l=this._n2-4;for(;o<l;){let h,c,d,f,p,g;h=s[o]-s[l+2],c=s[o+1]+s[l+3],d=this._c[n+1]*h+this._c[n]*c,f=this._c[n+1]*c-this._c[n]*h,p=s[o]+s[l+2],g=s[o+1]-s[l+3],s[o]=p+d,s[o+1]=g+f,s[l+2]=p-d,s[l+3]=f-g,h=s[o+2]-s[l],c=s[o+3]+s[l+1],d=this._c[n+3]*h+this._c[n+2]*c,f=this._c[n+3]*c-this._c[n+2]*h,p=s[o+2]+s[l],g=s[o+3]-s[l+1],s[o+2]=p+d,s[o+3]=g+f,s[l]=p-d,s[l+1]=f-g,n+=4,o+=4,l-=4}}{let n=this._n2-8,o=this._n2-8,l=0,h=this._n2-4,c=this._n2,d=this._n-4;for(;o>=0;){let f,p,g,m;m=i[o+6]*this._b[n+7]-i[o+7]*this._b[n+6],g=-i[o+6]*this._b[n+6]-i[o+7]*this._b[n+7],e[l]=m,e[h+3]=-m,e[c]=g,e[d+3]=g,p=i[o+4]*this._b[n+5]-i[o+5]*this._b[n+4],f=-i[o+4]*this._b[n+4]-i[o+5]*this._b[n+5],e[l+1]=p,e[h+2]=-p,e[c+1]=f,e[d+2]=f,m=i[o+2]*this._b[n+3]-i[o+3]*this._b[n+2],g=-i[o+2]*this._b[n+2]-i[o+3]*this._b[n+3],e[l+2]=m,e[h+1]=-m,e[c+2]=g,e[d+1]=g,p=i[o]*this._b[n+1]-i[o+1]*this._b[n],f=-i[o]*this._b[n]-i[o+1]*this._b[n+1],e[l+3]=p,e[h]=-p,e[c+3]=f,e[d]=f,n-=8,o-=8,l+=4,c+=4,h-=4,d-=4}}}_step3InnerRLoop(e,t,s,i,r){let n,o,l=s,h=l+i,c=0;for(let d=e>>2;d>0;--d)n=t[l]-t[h],o=t[l-1]-t[h-1],t[l]+=t[h],t[l-1]+=t[h-1],t[h]=n*this._a[c]-o*this._a[c+1],t[h-1]=o*this._a[c]+n*this._a[c+1],c+=r,n=t[l-2]-t[h-2],o=t[l-3]-t[h-3],t[l-2]+=t[h-2],t[l-3]+=t[h-3],t[h-2]=n*this._a[c]-o*this._a[c+1],t[h-3]=o*this._a[c]+n*this._a[c+1],c+=r,n=t[l-4]-t[h-4],o=t[l-5]-t[h-5],t[l-4]+=t[h-4],t[l-5]+=t[h-5],t[h-4]=n*this._a[c]-o*this._a[c+1],t[h-5]=o*this._a[c]+n*this._a[c+1],c+=r,n=t[l-6]-t[h-6],o=t[l-7]-t[h-7],t[l-6]+=t[h-6],t[l-7]+=t[h-7],t[h-6]=n*this._a[c]-o*this._a[c+1],t[h-7]=o*this._a[c]+n*this._a[c+1],c+=r,l-=8,h-=8}_step3Iter0Loop(e,t,s,i){let r=s,n=r+i,o=0;for(let l=e>>2;l>0;--l){let h,c;h=t[r]-t[n],c=t[r-1]-t[n-1],t[r]+=t[n],t[r-1]+=t[n-1],t[n]=h*this._a[o]-c*this._a[o+1],t[n-1]=c*this._a[o]+h*this._a[o+1],o+=8,h=t[r-2]-t[n-2],c=t[r-3]-t[n-3],t[r
10-2]+=t[n-2],t[r-3]+=t[n-3],t[n-2]=h*this._a[o]-c*this._a[o+1],t[n-3]=c*this._a[o]+h*this._a[o+1],o+=8,h=t[r-4]-t[n-4],c=t[r-5]-t[n-5],t[r-4]+=t[n-4],t[r-5]+=t[n-5],t[n-4]=h*this._a[o]-c*this._a[o+1],t[n-5]=c*this._a[o]+h*this._a[o+1],o+=8,h=t[r-6]-t[n-6],c=t[r-7]-t[n-7],t[r-6]+=t[n-6],t[r-7]+=t[n-7],t[n-6]=h*this._a[o]-c*this._a[o+1],t[n-7]=c*this._a[o]+h*this._a[o+1],o+=8,r-=8,n-=8}}_step3InnerSLoop(e,t,s,i,r,n,o){const l=this._a[r],h=this._a[r+1],c=this._a[r+n],d=this._a[r+n+1],f=this._a[r+n*2],p=this._a[r+n*2+1],g=this._a[r+n*3],m=this._a[r+n*3+1];let b,S,N=s,v=N+i;for(let W=e;W>0;--W)b=t[N]-t[v],S=t[N-1]-t[v-1],t[N]+=t[v],t[N-1]+=t[v-1],t[v]=b*l-S*h,t[v-1]=S*l+b*h,b=t[N-2]-t[v-2],S=t[N-3]-t[v-3],t[N-2]+=t[v-2],t[N-3]+=t[v-3],t[v-2]=b*c-S*d,t[v-3]=S*c+b*d,b=t[N-4]-t[v-4],S=t[N-5]-t[v-5],t[N-4]+=t[v-4],t[N-5]+=t[v-5],t[v-4]=b*f-S*p,t[v-5]=S*f+b*p,b=t[N-6]-t[v-6],S=t[N-7]-t[v-7],t[N-6]+=t[v-6],t[N-7]+=t[v-7],t[v-6]=b*g-S*m,t[v-7]=S*g+b*m,N-=o,v-=o}_step3InnerSLoopLd654(e,t,s,i){const r=i>>3,n=this._a[r];let o=s;const l=o-16*e;for(;o>l;){let h,c;h=t[o]-t[o-8],c=t[o-1]-t[o-9],t[o]+=t[o-8],t[o-1]+=t[o-9],t[o-8]=h,t[o-9]=c,h=t[o-2]-t[o-10],c=t[o-3]-t[o-11],t[o-2]+=t[o-10],t[o-3]+=t[o-11],t[o-10]=(h+c)*n,t[o-11]=(c-h)*n,h=t[o-12]-t[o-4],c=t[o-5]-t[o-13],t[o-4]+=t[o-12],t[o-5]+=t[o-13],t[o-12]=c,t[o-13]=h,h=t[o-14]-t[o-6],c=t[o-7]-t[o-15],t[o-6]+=t[o-14],t[o-7]+=t[o-15],t[o-14]=(h+c)*n,t[o-15]=(h-c)*n,this._iter54(t,o),this._iter54(t,o-8),o-=16}}_iter54(e,t){const s=e[t]-e[t-4],i=e[t]+e[t-4],r=e[t-2]+e[t-6],n=e[t-2]-e[t-6];e[t]=i+r,e[t-2]=i-r;const o=e[t-3]-e[t-7];e[t-4]=s+o,e[t-6]=s-o;const l=e[t-1]-e[t-5],h=e[t-1]+e[t-5],c=e[t-3]+e[t-7];e[t-1]=h+c,e[t-3]=h-c,e[t-5]=l-n,e[t-7]=l+n}}class cc{_setupCache=new Map;reverse(e,t){let s;this._setupCache.has(t)?s=this._setupCache.get(t):(s=new Ci(t),this._setupCache.set(t,s)),s.calcReverse(e)}}class Bo{_stream;_setup;_packets;_packetIndex=0;_nextPacketBuf;_prevPacketBuf;_prevPacketStart;_prevPacketEnd;_prevPacketStop;_currentPosition;_hasPosition;_eosFound;_modeFieldBits;constructor(e,t,s){this._stream=e,this._setup=t,this._packets=s,this._currentPosition=0,this._prevPacketBuf=null,this._prevPacketStart=0,this._prevPacketEnd=0,this._prevPacketStop=0,this._nextPacketBuf=null,this._eosFound=!1,this._hasPosition=!1,this._modeFieldBits=li.ilog(t.modes.length-1)}decode(){let e=new Float32Array(this._packets[this._packets.length-1].granulePosition*this._stream.audioChannels);const t=new Float32Array(.2*this._stream.audioSampleRate*this._stream.audioChannels);let s=0,i=0;for(;s=this.read(t,0,t.length),s!==0;){if(i+s>=e.length){const r=new Float32Array(e.length+t.length);r.set(e,0),e=r}e.set(t.subarray(0,s),i),i+=s}return e.subarray(0,i)}read(e,t,s){if(s===0)return 0;let i=t;const r=t+s;for(;i<r;){if(this._prevPacketStart===this._prevPacketEnd){if(this._eosFound){this._nextPacketBuf=null,this._prevPacketBuf=null;break}const o=this._readNextPacket((i-t)/this._stream.audioChannels);o===null&&(this._prevPacketEnd=this._prevPacketStop),o!==null&&o.samplePosition!==null&&!this._hasPosition&&(this._hasPosition=!0,this._currentPosition=o.samplePosition-(this._prevPacketEnd-this._prevPacketStart)-(i-t)/this._stream.audioChannels)}const n=Math.min((r-i)/this._stream.audioChannels,this._prevPacketEnd-this._prevPacketStart);n>0&&(i+=this._copyBuffer(e,i,n))}return s=i-t,this._currentPosition+=s/this._stream.audioChannels,s}_copyBuffer(e,t,s){let i=t;for(;s>0;this._prevPacketStart++,s--)for(let r=0;r<this._stream.audioChannels;r++)e[i++]=this._prevPacketBuf[r][this._prevPacketStart];return i-t}_readNextPacket(e){const t=this._decodeNextPacket();if(this._eosFound=this._eosFound||t.isEndOfStream,t.curPacket==null)return null;if(t.samplePosition!==null&&t.isEndOfStream){const s=this._currentPosition+e+t.validLen-t.startIndex,i=t.samplePosition-s;i<0&&(t.validLen+=i,t.validLen<0&&(t.validLen=0))}return this._prevPacketEnd>0?(Bo._overlapBuffers(this._prevPacketBuf,t.curPacket,this._prevPacketStart,this._prevPacketStop,t.startIndex,this._stream.audioChannels),this._prevPacketStart=t.startIndex):this._prevPacketBuf==null&&(this._prevPacketStart=t.validLen),this._nextPacketBuf=this._prevPacketBuf,this._prevPacketEnd=t.validLen,this._prevPacketStop=t.totalLen,this._prevPacketBuf=t.curPacket,new hc(t.samplePosition)}static _overlapBuffers(e,t,s,i,r,n){for(;s<i;s++,r++)for(let o=0;o<n;o++)t[o][r]+=e[o][s]}_decodeNextPacket(){const e=new dc;let t=null;if(this._packetIndex>=this._packets.length)e.isEndOfStream=!0;else{t=this._packets[this._packetIndex++];const s=new mn(gt.fromBuffer(t.packetData));if(e.isEndOfStream=t.isEndOfStream,!s.readBit()){const i=this._setup.modes[s.readBits(this._modeFieldBits)];if(this._nextPacketBuf==null){this._nextPacketBuf=new Array(this._stream.audioChannels);for(let n=0;n<this._stream.audioChannels;n++)this._nextPacketBuf[n]=new Float32Array(this._stream.blocksize1)}const r=i.decode(s,this._nextPacketBuf);return e.startIndex=r.packetStartIndex,e.validLen=r.packetValidLength,e.totalLen=r.packetTotalLength,e.samplePosition=t.granulePosition,e.curPacket=this._nextPacketBuf,e}}return e}}class dc{curPacket=null;startIndex=0;validLen=0;totalLen=0;isEndOfStream=!1;samplePosition=null}var Mr;(function(a){a[a.IdentificationHeader=1]="IdentificationHeader",a[a.Comment=3]="Comment",a[a.SetupHeader=5]="SetupHeader"})(Mr||(Mr={}));class Ei{static vorbisHeaderMarker=new Uint8Array([118,111,114,98,105,115]);_packets;_packetIndex;constructor(e){this._packetIndex=-1,this._packets=e}read(){let e;for(;;){if(e=this._nextPacket(),e==null)return null;if(e.isBeginningOfStream){const t=this._readStream(e);if(t!=null)return t}}}_nextPacket(){return this._packetIndex++,this._packetIndex<this._packets.length?this._packets[this._packetIndex]:null}_readStream(e){const t=new qh;if(!this._readIdentificationHeader(t,e)||!this._readComments(this._nextPacket()))return null;const s=new Qh;if(!this._readSetupHeader(t,s,this._nextPacket()))return null;const i=[];let r;for(;r=this._nextPacket(),!(r==null||(i.push(r),r.isEndOfStream)););const n=new Bo(t,s,i);return t.samples=n.decode(),t}_commonHeaderDecode(e,t){const s=new Uint8Array(7);if(t.read(s,0,s.length),s[0]!==e)return!1;for(let i=0;i<Ei.vorbisHeaderMarker.length;i++)if(s[1+i]!==Ei.vorbisHeaderMarker[i])return!1;return!0}_commonHeaderDecodeBit(e,t){const s=t.readBytes(7);if(s[0]!==e)return!1;for(let i=0;i<Ei.vorbisHeaderMarker.length;i++)if(s[1+i]!==Ei.vorbisHeaderMarker[i])return!1;return!0}_readIdentificationHeader(e,t){const s=gt.fromBuffer(t.packetData);if(!this._commonHeaderDecode(Mr.IdentificationHeader,s)||k.readUInt32LE(s)!==0||(e.audioChannels=s.readByte(),e.audioSampleRate=k.readUInt32LE(s),e.audioChannels<=0||e.audioSampleRate<=0))return!1;e.bitrateMaximum=k.readInt32LE(s),e.bitrateNominal=k.readInt32LE(s),e.bitrateMinimum=k.readInt32LE(s);const r=s.readByte();return e.blocksize0=1<<(r&15),e.blocksize1=1<<(r>>4),!(e.blocksize0>e.blocksize1||!Ei._isAllowedBlockSize(e.blocksize0)||!Ei._isAllowedBlockSize(e.blocksize0)||s.readByte()===0)}static _isAllowedBlockSize(e){switch(e){case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:return!0;default:return!1}}_readComments(e){if(e==null)return!1;const t=gt.fromBuffer(e.packetData);if(!this._commonHeaderDecode(Mr.Comment,t))return!1;const s=k.readUInt32LE(t);t.skip(s);const i=k.readUInt32LE(t);for(let n=0;n<i;n++){const o=k.readUInt32LE(t);t.skip(o)}return t.readByte()!==0}_readSetupHeader(e,t,s){if(s==null)return!1;
10const i=new mn(gt.fromBuffer(s.packetData)),r=new cc,n=new wa;if(!this._commonHeaderDecodeBit(Mr.SetupHeader,i))return!1;let o=i.readByte()+1;for(let l=0;l<o;l++)t.codebooks.push(new Zh(i,n));o=i.readBits(6)+1;for(let l=0;l<o;l++)t.timeDomainTransforms.push(new ec(i));o=i.readBits(6)+1;for(let l=0;l<o;l++)t.floors.push(new ic(i,e.blocksize0,e.blocksize1,t.codebooks));o=i.readBits(6)+1;for(let l=0;l<o;l++)t.residues.push(new nc(i,e.audioChannels,t.codebooks));o=i.readBits(6)+1;for(let l=0;l<o;l++)t.mappings.push(new oc(i,e.audioChannels,t.floors,t.residues,r));o=i.readBits(6)+1;for(let l=0;l<o;l++)t.modes.push(new ms(i,e.audioChannels,e.blocksize0,e.blocksize1,t.mappings));return!!i.readBit()}}class uc{streams=[];constructor(e){const s=new Jh(e).read(),i=new Ei(s);for(;;){const r=i.read();if(r==null)break;this.streams.push(r)}}}class Ql{phdrs=[];pbags=[];pmods=[];pgens=[];insts=[];ibags=[];imods=[];igens=[];sHdrs=[];sampleData=new Uint8Array(0);_sampleCache=new Map;decodeSamples(e,t,s){const i=`${e}_${t}_${s}`;if(!this._sampleCache.has(i)){let r;const n=this.sampleData.slice(e,t);if(s)r=new uc(gt.fromBuffer(n)).streams[0].samples;else{const o=new DataView(n.buffer,n.byteOffset,n.length);r=new Float32Array(n.length/2);for(let l=0;l<r.length;l++)r[l]=o.getInt16(l*2,!0)/32767}return this._sampleCache.set(i,r),r}return this._sampleCache.get(i)}load(e){const t=new Ms,s=new Ms;if(!Ms.load(null,t,e)||t.id!=="sfbk")throw new zt("Soundfont is not a valid Soundfont2 file");for(;Ms.load(t,s,e);){const i=new Ms;if(s.id==="pdta")for(;Ms.load(s,i,e);)switch(i.id){case"phdr":for(let r=0,n=i.size/hl.SizeInFile|0;r<n;r++)this.phdrs.push(new hl(e));break;case"pbag":for(let r=0,n=i.size/ll.SizeInFile|0;r<n;r++)this.pbags.push(new ll(e));break;case"pmod":for(let r=0,n=i.size/cl.SizeInFile|0;r<n;r++)this.pmods.push(new cl(e));break;case"pgen":for(let r=0,n=i.size/pi.SizeInFile|0;r<n;r++)this.pgens.push(new pi(e));break;case"inst":for(let r=0,n=i.size/ol.SizeInFile|0;r<n;r++)this.insts.push(new ol(e));break;case"ibag":for(let r=0,n=i.size/rl.SizeInFile|0;r<n;r++)this.ibags.push(new rl(e));break;case"imod":for(let r=0,n=i.size/al.SizeInFile|0;r<n;r++)this.imods.push(new al(e));break;case"igen":for(let r=0,n=i.size/nl.SizeInFile|0;r<n;r++)this.igens.push(new nl(e));break;case"shdr":for(let r=0,n=i.size/dl.SizeInFile|0;r<n;r++)this.sHdrs.push(new dl(e));break;default:e.position+=i.size;break}else if(s.id==="sdta")for(;Ms.load(s,i,e);)i.id==="smpl"?(this.sampleData=new Uint8Array(i.size),e.read(this.sampleData,0,i.size)):e.position+=i.size;else e.position+=s.size}}}class rl{static SizeInFile=4;instGenNdx;instModNdx;constructor(e){this.instGenNdx=k.readUInt16LE(e),this.instModNdx=k.readUInt16LE(e)}}class al{static SizeInFile=10;modSrcOper;modDestOper;modAmount;modAmtSrcOper;modTransOper;constructor(e){this.modSrcOper=k.readUInt16LE(e),this.modDestOper=k.readUInt16LE(e),this.modAmount=k.readInt16LE(e),this.modAmtSrcOper=k.readUInt16LE(e),this.modTransOper=k.readUInt16LE(e)}}class nl{static SizeInFile=4;genOper;genAmount;constructor(e){this.genOper=k.readUInt16LE(e),this.genAmount=new Kl(e)}}class ol{static SizeInFile=22;instName;instBagNdx;constructor(e){this.instName=k.read8BitStringLength(e,20),this.instBagNdx=k.readUInt16LE(e)}}class ll{static SizeInFile=4;genNdx;modNdx;constructor(e){this.genNdx=k.readUInt16LE(e),this.modNdx=k.readUInt16LE(e)}}class pi{static SizeInFile=4;static GenInstrument=41;static GenKeyRange=43;static GenVelRange=44;static GenSampleId=53;genOper;genAmount;constructor(e){this.genOper=k.readUInt16LE(e),this.genAmount=new Kl(e)}}class hl{static SizeInFile=38;presetName;preset;bank;presetBagNdx;library;genre;morphology;constructor(e){this.presetName=k.read8BitStringLength(e,20),this.preset=k.readUInt16LE(e),this.bank=k.readUInt16LE(e),this.presetBagNdx=k.readUInt16LE(e),this.library=k.readUInt32LE(e),this.genre=k.readUInt32LE(e),this.morphology=k.readUInt32LE(e)}}class cl{static SizeInFile=10;modSrcOper;modDestOper;modAmount;modAmtSrcOper;modTransOper;constructor(e){this.modSrcOper=k.readUInt16LE(e),this.modDestOper=k.readUInt16LE(e),this.modAmount=k.readUInt16LE(e),this.modAmtSrcOper=k.readUInt16LE(e),this.modTransOper=k.readUInt16LE(e)}}class dl{static SizeInFile=46;sampleName;start;end;startLoop;endLoop;sampleRate;originalPitch;pitchCorrection;sampleLink;sampleType;constructor(e){this.sampleName=k.read8BitStringLength(e,20),this.start=k.readUInt32LE(e),this.end=k.readUInt32LE(e),this.startLoop=k.readUInt32LE(e),this.endLoop=k.readUInt32LE(e),this.sampleRate=k.readUInt32LE(e),this.originalPitch=e.readByte(),this.pitchCorrection=k.readSInt8(e),this.sampleLink=k.readUInt16LE(e),this.sampleType=k.readUInt16LE(e)}}class Kl{wordAmount;get shortAmount(){return be.uint16ToInt16(this.wordAmount)}
10get lowByteAmount(){return this.wordAmount&255}get highByteAmount(){return(this.wordAmount&65280)>>8&255}constructor(e){this.wordAmount=k.readUInt16LE(e)}}class fc{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}class pc{activeChannel=0;channelList=[];setupVoice(e,t){const s=this.channelList[this.activeChannel],i=t.region.pan+s.panOffset;t.playingChannel=this.activeChannel,t.mixVolume=s.mixVolume,t.noteGainDb+=s.gainDb,t.updatePitchRatio(s,e.outSampleRate),i<=-.5?(t.panFactorLeft=1,t.panFactorRight=0):i>=.5?(t.panFactorLeft=0,t.panFactorRight=1):(t.panFactorLeft=Math.sqrt(.5-i),t.panFactorRight=Math.sqrt(.5+i))}}var mi;(function(a){a[a.None=0]="None",a[a.Continuous=1]="Continuous",a[a.Sustain=2]="Sustain"})(mi||(mi={}));var Xi;(function(a){a[a.StereoInterleaved=0]="StereoInterleaved",a[a.StereoUnweaved=1]="StereoUnweaved",a[a.Mono=2]="Mono"})(Xi||(Xi={}));class gc{name="";presetNumber=0;bank=0;regions=null}class Wt{static timecents2Secs(e){return Math.pow(2,e/1200)}static decibelsToGain(e){return e>-100?Math.pow(10,e*.05):0}static gainToDecibels(e){return e<=1e-5?-100:20*Math.log10(e)}static cents2Hertz(e){return 8.176*Math.pow(2,e/1200)}}class vr{delay=0;attack=0;hold=0;decay=0;sustain=0;release=0;keynumToHold=0;keynumToDecay=0;constructor(e){e&&(this.delay=e.delay,this.attack=e.attack,this.hold=e.hold,this.decay=e.decay,this.sustain=e.sustain,this.release=e.release,this.keynumToHold=e.keynumToHold,this.keynumToDecay=e.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(e){this.delay=this.delay<-11950?0:Wt.timecents2Secs(this.delay),this.attack=this.attack<-11950?0:Wt.timecents2Secs(this.attack),this.release=this.release<-11950?0:Wt.timecents2Secs(this.release),this.keynumToHold===0&&(this.hold=this.hold<-11950?0:Wt.timecents2Secs(this.hold)),this.keynumToDecay===0&&(this.decay=this.decay<-11950?0:Wt.timecents2Secs(this.decay)),this.sustain<0?this.sustain=0:e?this.sustain=Wt.decibelsToGain(-this.sustain/10):this.sustain=1-this.sustain/1e3}}var Oe;(function(a){a[a.StartAddrsOffset=0]="StartAddrsOffset",a[a.EndAddrsOffset=1]="EndAddrsOffset",a[a.StartloopAddrsOffset=2]="StartloopAddrsOffset",a[a.EndloopAddrsOffset=3]="EndloopAddrsOffset",a[a.StartAddrsCoarseOffset=4]="StartAddrsCoarseOffset",a[a.ModLfoToPitch=5]="ModLfoToPitch",a[a.VibLfoToPitch=6]="VibLfoToPitch",a[a.ModEnvToPitch=7]="ModEnvToPitch",a[a.InitialFilterFc=8]="InitialFilterFc",a[a.InitialFilterQ=9]="InitialFilterQ",a[a.ModLfoToFilterFc=10]="ModLfoToFilterFc",a[a.ModEnvToFilterFc=11]="ModEnvToFilterFc",a[a.EndAddrsCoarseOffset=12]="EndAddrsCoarseOffset",a[a.ModLfoToVolume=13]="ModLfoToVolume",a[a.Unused1=14]="Unused1",a[a.ChorusEffectsSend=15]="ChorusEffectsSend",a[a.ReverbEffectsSend=16]="ReverbEffectsSend",a[a.Pan=17]="Pan",a[a.Unused2=18]="Unused2",a[a.Unused3=19]="Unused3",a[a.Unused4=20]="Unused4",a[a.DelayModLFO=21]="DelayModLFO",a[a.FreqModLFO=22]="FreqModLFO",a[a.DelayVibLFO=23]="DelayVibLFO",a[a.FreqVibLFO=24]="FreqVibLFO",a[a.DelayModEnv=25]="DelayModEnv",a[a.AttackModEnv=26]="AttackModEnv",a[a.HoldModEnv=27]="HoldModEnv",a[a.DecayModEnv=28]="DecayModEnv",a[a.SustainModEnv=29]="SustainModEnv",a[a.ReleaseModEnv=30]="ReleaseModEnv",a[a.KeynumToModEnvHold=31]="KeynumToModEnvHold",a[a.KeynumToModEnvDecay=32]="KeynumToModEnvDecay",a[a.DelayVolEnv=33]="DelayVolEnv",a[a.AttackVolEnv=34]="AttackVolEnv",a[a.HoldVolEnv=35]="HoldVolEnv",a[a.DecayVolEnv=36]="DecayVolEnv",a[a.SustainVolEnv=37]="SustainVolEnv",a[a.ReleaseVolEnv=38]="ReleaseVolEnv",a[a.KeynumToVolEnvHold=39]="KeynumToVolEnvHold",a[a.KeynumToVolEnvDecay=40]="KeynumToVolEnvDecay",a[a.Instrument=41]="Instrument",a[a.Reserved1=42]="Reserved1",a[a.KeyRange=43]="KeyRange",a[a.VelRange=44]="VelRange",a[a.StartloopAddrsCoarseOffset=45]="StartloopAddrsCoarseOffset",a[a.Keynum=46]="Keynum",a[a.Velocity=47]="Velocity",a[a.InitialAttenuation=48]="InitialAttenuation",a[a.Reserved2=49]="Reserved2",a[a.EndloopAddrsCoarseOffset=50]="EndloopAddrsCoarseOffset",a[a.CoarseTune=51]="CoarseTune",a[a.FineTune=52]="FineTune",a[a.SampleID=53]="SampleID",a[a.SampleModes=54]="SampleModes",a[a.Reserved3=55]="Reserved3",a[a.ScaleTuning=56]="ScaleTuning",a[a.ExclusiveClass=57]="ExclusiveClass",a[a.OverridingRootKey=58]="OverridingRootKey",a[a.Unused5=59]="Unu
10sed5",a[a.EndOper=60]="EndOper"})(Oe||(Oe={}));class gi{static _noSamples=new Float32Array(0);loopMode=mi.None;samples=gi._noSamples;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 vr;modEnv=new vr;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(e){e&&(this.loopMode=e.loopMode,this.samples=e.samples,this.sampleRate=e.sampleRate,this.loKey=e.loKey,this.hiKey=e.hiKey,this.loVel=e.loVel,this.hiVel=e.hiVel,this.group=e.group,this.offset=e.offset,this.end=e.end,this.loopStart=e.loopStart,this.loopEnd=e.loopEnd,this.transpose=e.transpose,this.tune=e.tune,this.pitchKeyCenter=e.pitchKeyCenter,this.pitchKeyTrack=e.pitchKeyTrack,this.attenuation=e.attenuation,this.pan=e.pan,this.ampEnv=new vr(e.ampEnv),this.modEnv=new vr(e.modEnv),this.initialFilterQ=e.initialFilterQ,this.initialFilterFc=e.initialFilterFc,this.modEnvToPitch=e.modEnvToPitch,this.modEnvToFilterFc=e.modEnvToFilterFc,this.modLfoToFilterFc=e.modLfoToFilterFc,this.modLfoToVolume=e.modLfoToVolume,this.delayModLFO=e.delayModLFO,this.freqModLFO=e.freqModLFO,this.modLfoToPitch=e.modLfoToPitch,this.delayVibLFO=e.delayVibLFO,this.freqVibLFO=e.freqVibLFO,this.vibLfoToPitch=e.vibLfoToPitch)}clear(e){this.loopMode=mi.None,this.samples=gi._noSamples,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(e,t){switch(e){case Oe.StartAddrsOffset:this.offset+=be.int16ToUint32(t.shortAmount);break;case Oe.EndAddrsOffset:this.end+=be.int16ToUint32(t.shortAmount);break;case Oe.StartloopAddrsOffset:this.loopStart+=be.int16ToUint32(t.shortAmount);break;case Oe.EndloopAddrsOffset:this.loopEnd+=be.int16ToUint32(t.shortAmount);break;case Oe.StartAddrsCoarseOffset:this.offset+=be.int16ToUint32(t.shortAmount)*32768;break;case Oe.ModLfoToPitch:this.modLfoToPitch=t.shortAmount;break;case Oe.VibLfoToPitch:this.vibLfoToPitch=t.shortAmount;break;case Oe.ModEnvToPitch:this.modEnvToPitch=t.shortAmount;break;case Oe.InitialFilterFc:this.initialFilterFc=t.shortAmount;break;case Oe.InitialFilterQ:this.initialFilterQ=t.shortAmount;break;case Oe.ModLfoToFilterFc:this.modLfoToFilterFc=t.shortAmount;break;case Oe.ModEnvToFilterFc:this.modEnvToFilterFc=t.shortAmount;break;case Oe.EndAddrsCoarseOffset:this.end+=be.int16ToUint32(t.shortAmount)*32768;break;case Oe.ModLfoToVolume:this.modLfoToVolume=t.shortAmount;break;case Oe.Pan:this.pan=t.shortAmount/1e3;break;case Oe.DelayModLFO:this.delayModLFO=t.shortAmount;break;case Oe.FreqModLFO:this.freqModLFO=t.shortAmount;break;case Oe.DelayVibLFO:this.delayVibLFO=t.shortAmount;break;case Oe.FreqVibLFO:this.freqVibLFO=t.shortAmount;break;case Oe.DelayModEnv:this.modEnv.delay=t.shortAmount;break;case Oe.AttackModEnv:this.modEnv.attack=t.shortAmount;break;case Oe.HoldModEnv:this.modEnv.hold=t.shortAmount;break;case Oe.DecayModEnv:this.modEnv.decay=t.shortAmount;break;case Oe.SustainModEnv:this.modEnv.sustain=t.shortAmount;break;case Oe.ReleaseModEnv:this.modEnv.release=t.shortAmount;break;case Oe.KeynumToModEnvHold:this.modEnv.keynumToHold=t.shortAmount;break;case Oe.KeynumToModEnvDecay:this.modEnv.keynumToDecay=t.shortAmount;break;case Oe.DelayVolEnv:this.ampEnv.delay=t.shortAmount;break;case Oe.AttackVolEnv:this.ampEnv.attack=t.shortAmount;break;case Oe.HoldVolEnv:this.ampEnv.hold=t.shortAmount;break;case Oe.DecayVolEnv:this.ampEnv.decay=t.shortAmount;break;case Oe.SustainVolEnv:this.ampEnv.sustain=t.shortAmount;break;case Oe.ReleaseVolEnv:this.ampEnv.release=t.shortAmount;break;
10case Oe.KeynumToVolEnvHold:this.ampEnv.keynumToHold=t.shortAmount;break;case Oe.KeynumToVolEnvDecay:this.ampEnv.keynumToDecay=t.shortAmount;break;case Oe.KeyRange:this.loKey=t.lowByteAmount,this.hiKey=t.highByteAmount;break;case Oe.VelRange:this.loVel=t.lowByteAmount,this.hiVel=t.highByteAmount;break;case Oe.StartloopAddrsCoarseOffset:this.loopStart+=be.int16ToUint32(t.shortAmount)*32768;break;case Oe.InitialAttenuation:this.attenuation+=t.shortAmount*.1;break;case Oe.EndloopAddrsCoarseOffset:this.loopEnd+=be.int16ToUint32(t.shortAmount)*32768;break;case Oe.CoarseTune:this.transpose+=t.shortAmount;break;case Oe.FineTune:this.tune+=t.shortAmount;break;case Oe.SampleModes:this.loopMode=(t.wordAmount&3)===3?mi.Sustain:(t.wordAmount&3)===1?mi.Continuous:mi.None;break;case Oe.ScaleTuning:this.pitchKeyTrack=t.shortAmount;break;case Oe.ExclusiveClass:this.group=t.wordAmount;break;case Oe.OverridingRootKey:this.pitchKeyCenter=t.shortAmount;break}}}var at;(function(a){a[a.None=0]="None",a[a.Delay=1]="Delay",a[a.Attack=2]="Attack",a[a.Hold=3]="Hold",a[a.Decay=4]="Decay",a[a.Sustain=5]="Sustain",a[a.Release=6]="Release",a[a.Done=7]="Done"})(at||(at={}));class Ta{static _fastReleaseTime=.01;level=0;slope=0;samplesUntilNextSegment=0;segment=at.None;midiVelocity=0;parameters=null;segmentIsExponential=!1;isAmpEnv=!1;nextSegment(e,t){if(this.parameters)for(;;)switch(e){case at.None:if(this.samplesUntilNextSegment=this.parameters.delay*t|0,this.samplesUntilNextSegment>0){this.segment=at.Delay,this.segmentIsExponential=!1,this.level=0,this.slope=0;return}e=at.Delay;break;case at.Delay:if(this.samplesUntilNextSegment=this.parameters.attack*t|0,this.samplesUntilNextSegment>0){this.isAmpEnv||(this.samplesUntilNextSegment=this.parameters.attack*((145-this.midiVelocity)/144)*t|0),this.segment=at.Attack,this.segmentIsExponential=!1,this.level=0,this.slope=1/this.samplesUntilNextSegment;return}e=at.Attack;break;case at.Attack:if(this.samplesUntilNextSegment=this.parameters.hold*t|0,this.samplesUntilNextSegment>0){this.segment=at.Hold,this.segmentIsExponential=!1,this.level=1,this.slope=0;return}e=at.Hold;break;case at.Hold:if(this.samplesUntilNextSegment=this.parameters.decay*t|0,this.samplesUntilNextSegment>0){if(this.segment=at.Decay,this.level=1,this.isAmpEnv){const s=-9.226/this.samplesUntilNextSegment;this.slope=Math.exp(s),this.segmentIsExponential=!0,this.parameters.sustain>0&&(this.samplesUntilNextSegment=Math.log(this.parameters.sustain)/s|0)}else this.slope=-1/this.samplesUntilNextSegment,this.samplesUntilNextSegment=this.parameters.decay*(1-this.parameters.sustain)*t|0,this.segmentIsExponential=!1;return}e=at.Decay;break;case at.Decay:this.segment=at.Sustain,this.level=this.parameters.sustain,this.slope=0,this.samplesUntilNextSegment=2147483647,this.segmentIsExponential=!1;return;case at.Sustain:if(this.segment=at.Release,this.samplesUntilNextSegment=(this.parameters.release<=0?Ta._fastReleaseTime:this.parameters.release)*t|0,this.isAmpEnv){const s=-9.226/this.samplesUntilNextSegment;this.slope=Math.exp(s),this.segmentIsExponential=!0}else this.slope=-this.level/this.samplesUntilNextSegment,this.segmentIsExponential=!1;return;default:this.segment=at.Done,this.segmentIsExponential=!1,this.level=0,this.slope=0,this.samplesUntilNextSegment=134217727;return}}setup(e,t,s,i,r){this.parameters=new vr(e),this.parameters.keynumToHold>0&&(this.parameters.hold+=this.parameters.keynumToHold*(60-t),this.parameters.hold=this.parameters.hold<-1e4?0:Wt.timecents2Secs(this.parameters.hold)),this.parameters.keynumToDecay>0&&(this.parameters.decay+=this.parameters.keynumToDecay*(60-t),this.parameters.decay=this.parameters.decay<-1e4?0:Wt.timecents2Secs(this.parameters.decay)),this.midiVelocity=s|0,this.isAmpEnv=i,this.nextSegment(at.None,r)}process(e,t){this.slope>0&&(this.segmentIsExponential?this.level*=Math.pow(this.slope,e):this.level+=this.slope*e),this.samplesUntilNextSegment-=e,this.samplesUntilNextSegment<=0&&this.nextSegment(this.segment,t)}}class ul{samplesUntil=0;level=0;delta=0;setup(e,t,s){this.samplesUntil=e*s|0,this.delta=4*Wt.cents2Hertz(t)/s,this.level=0}process(e){if(this.samplesUntil>e){this.samplesUntil-=e;return}this.level+=this.delta*e,this.level>1?(this.delta=-this.delta,this.level=2-this.level):this.level<-1&&(this.delta=-this.delta,this.level=-2-this.level)}}class fl{qInv=0;a0=0;a1=0;b1=0;b2=0;z1=0;z2=0;active=!1;constructor(e){e&&(this.qInv=e.qInv,this.a0=e.a0,this.a1=e.a1,this.b1=e.b1,this.b2=e.b2,this.z1=e.z1,this.z2=e.z2,this.active=e.active)}setup(e){const t=Math.tan(Math.PI*e),s=t*t,i=1/(1+t*this.qInv+s);this.a0=s*i,this.a1=2*this.a0,this.b1=2*(s-1)*i,this.b2=(1-t*this.qInv+s)*i}process(e){const t=e*this.a0+this.z1;return this.z1=e*this.a1+this.z2-this.b1*t,this.z2=e*this.a0-this.b2*t,t}}class xa{static renderEffectSampleBlock=de.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 Ta;modEnv=new Ta;lowPass=new fl;modLfo=new ul;vibLfo=new ul;
10mixVolume=0;mute=!1;updatePitchRatio(e,t){let s=e.pitchWheel;e.perNotePitchWheel.has(this.playingKey)&&(s+=e.perNotePitchWheel.get(this.playingKey)-8192);const i=s===8192?e.tuning:s/16383*e.pitchRange*2-e.pitchRange+e.tuning;this.calcPitchRatio(i,t)}calcPitchRatio(e,t){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);e!==0&&(i+=e),this.pitchInputTimecents=i*100,this.pitchOutputFactor=this.region.sampleRate/(Wt.timecents2Secs(this.region.pitchKeyCenter*100)*t)}end(e){this.region&&(this.ampEnv.nextSegment(at.Sustain,e),this.modEnv.nextSegment(at.Sustain,e),this.region.loopMode===mi.Sustain&&(this.loopEnd=this.loopStart))}endQuick(e){this.ampEnv.parameters.release=0,this.ampEnv.nextSegment(at.Sustain,e),this.modEnv.parameters.release=0,this.modEnv.nextSegment(at.Sustain,e)}render(e,t,s,i,r){if(!this.region)return;const n=this.region,o=n.samples;let l=0,h=e.outputMode===Xi.StereoUnweaved?i:-1;const c=n.modEnvToPitch!==0||n.modEnvToFilterFc!==0,d=this.modLfo.delta>0&&(n.modLfoToPitch!==0||n.modLfoToFilterFc!==0||n.modLfoToVolume!==0),f=this.vibLfo.delta>0&&n.vibLfoToPitch!==0,p=this.loopStart<this.loopEnd,g=this.loopStart,m=this.loopEnd,b=n.end,S=m+1;let N=this.sourceSamplePosition;const v=new fl(this.lowPass),W=n.modLfoToFilterFc!==0||n.modEnvToFilterFc!==0;let j=0,q=0,F=0,Q=0;const me=n.modLfoToPitch!==0||n.modEnvToPitch!==0||n.vibLfoToPitch!==0;let ge=0,re=0,Je=0,lt=0;const De=n.modLfoToVolume!==0;let vs=0,Ht=0;for(W?(j=e.outSampleRate,q=n.initialFilterFc,F=n.modLfoToFilterFc,Q=n.modEnvToFilterFc):(j=0,q=0,F=0,Q=0),me?(ge=0,re=n.modLfoToPitch,Je=n.vibLfoToPitch,lt=n.modEnvToPitch):(ge=Wt.timecents2Secs(this.pitchInputTimecents)*this.pitchOutputFactor,re=0,Je=0,lt=0),De?Ht=n.modLfoToVolume*.1:(vs=Wt.decibelsToGain(this.noteGainDb),Ht=0);i>0;){let Zt,xi,ui=0,Ds=i>xa.renderEffectSampleBlock?xa.renderEffectSampleBlock:i;if(i-=Ds,W){const Ut=q+this.modLfo.level*F+this.modEnv.level*Q;v.active=Ut<=13500,v.active&&v.setup(Wt.cents2Hertz(Ut)/j)}switch(me&&(ge=Wt.timecents2Secs(this.pitchInputTimecents+(this.modLfo.level*re+this.vibLfo.level*Je+this.modEnv.level*lt))*this.pitchOutputFactor),De&&(vs=Wt.decibelsToGain(this.noteGainDb+this.modLfo.level*Ht)),Zt=vs*this.ampEnv.level,r?Zt=0:Zt*=this.mixVolume,this.ampEnv.process(Ds,e.outSampleRate),c&&this.modEnv.process(Ds,e.outSampleRate),d&&this.modLfo.process(Ds),f&&this.vibLfo.process(Ds),e.outputMode){case Xi.StereoInterleaved:for(xi=Zt*this.panFactorLeft,ui=Zt*this.panFactorRight;Ds-- >0&&N<b;){const Ut=N|0,Wi=Ut>=m&&p?g:Ut+1,Os=N-Ut;let ps=o[Ut]*(1-Os)+o[Wi]*Os;v.active&&(ps=v.process(ps)),t[s+l]+=ps*xi,l++,t[s+l]+=ps*ui,l++,N+=ge,N>=S&&p&&(N-=m-g+1)}break;case Xi.StereoUnweaved:for(xi=Zt*this.panFactorLeft,ui=Zt*this.panFactorRight;Ds-- >0&&N<b;){const Ut=N|0,Wi=Ut>=m&&p?g:Ut+1,Os=N-Ut;let ps=o[Ut]*(1-Os)+o[Wi]*Os;v.active&&(ps=v.process(ps)),t[s+l]+=ps*xi,l++,t[s+h]+=ps*ui,h++,N+=ge,N>=S&&p&&(N-=m-g+1)}break;case Xi.Mono:for(;Ds-- >0&&N<b;){const Ut=N|0,Wi=Ut>=m&&p?g:Ut+1,Os=N-Ut;let ps=o[Ut]*(1-Os)+o[Wi]*Os;v.active&&(ps=v.process(ps)),t[s+l]=ps*Zt,l++,N+=ge,N>=S&&p&&(N-=m-g+1)}break}if(N>=b||this.ampEnv.segment===at.Done){this.kill();return}}this.sourceSamplePosition=N,(v.active||W)&&(this.lowPass=v)}kill(){this.playingPreset=-1}}class pl{value;next;constructor(e){this.value=e}}class To{_head;_tail;get isEmpty(){return this._head===void 0}clear(){this._head=void 0,this._tail=void 0}enqueue(e){const t=new pl(e);this._tail?(this._tail.next=t,this._tail=t):(this._head=t,this._tail=t)}enqueueFront(e){const t=new pl(e);t.next=this._head,this._head?this._head=t:(this._head=t,this._tail=t)}peek(){const e=this._head;if(e)return e.value}dequeue(){const e=this._head;if(!e)return;const t=e.next;return this._head=t,t||(this._tail=void 0),e.value}}var et;(function(a){a[a.BankSelectCoarse=0]="BankSelectCoarse",a[a.ModulationCoarse=1]="ModulationCoarse",a[a.DataEntryCoarse=6]="DataEntryCoarse",a[a.VolumeCoarse=7]="VolumeCoarse",a[a.PanCoarse=10]="PanCoarse",a[a.ExpressionControllerCoarse=11]="ExpressionControllerCoarse",a[a.BankSelectFine=32]="BankSelectFine",a[a.ModulationFine=33]="ModulationFine",a[a.DataEntryFine=38]="DataEntryFine",a[a.VolumeFine=39]="VolumeFine",a[a.PanFine=42]="PanFine",a[a.ExpressionControllerFine=43]="ExpressionControllerFine",a[a.HoldPedal=64]="HoldPedal",a[a.LegatoPedal=68]="LegatoPedal",a[a.NonRegisteredParameterFine=98]="NonRegisteredParameterFine",a[a.NonRegisteredParameterCourse=99]="NonRegisteredParameterCourse",a[a.RegisteredParameterFine=100]="RegisteredParameterFine",a[a.RegisteredParameterCourse=101]="RegisteredParameterCourse",a[a.AllSoundOff=120]="AllSoundOff",a[a.ResetControllers=121]="ResetControllers",a[a.AllNotesOff=123]="AllNotesOff"})(et||(et={}));class yn{_midiEventQueue=new To;_mutedChannels=new Map;_soloChannels=new Map;_isAnySolo=!1;_transpositionPitches=new Map;
10_liveTranspositionPitches=new Map;currentTempo=0;timeSignatureNumerator=0;timeSignatureDenominator=0;constructor(e){this.outSampleRate=e}synthesize(e,t,s){return this._fillWorkingBuffer(e,t,s)}synthesizeSilent(e){this._fillWorkingBuffer(null,0,e)}channelGetMixVolume(e){return this._channels&&e<this._channels.channelList.length?this._channels.channelList[e].mixVolume:1}channelSetMixVolume(e,t){const s=this._channelInit(e);for(const i of this._voices)i.playingChannel===e&&i.playingPreset!==-1&&(i.mixVolume=t);s.mixVolume=t}channelSetMute(e,t){t?this._mutedChannels.set(e,!0):this._mutedChannels.delete(e)}channelSetSolo(e,t){t?this._soloChannels.set(e,!0):this._soloChannels.delete(e),this._isAnySolo=this._soloChannels.size>0}resetChannelStates(){this._mutedChannels=new Map,this._soloChannels=new Map,this._liveTranspositionPitches=new Map,this.applyTranspositionPitches(new Map),this._isAnySolo=!1}setChannelTranspositionPitch(e,t){let s=0;this._liveTranspositionPitches.has(e)&&(s=this._liveTranspositionPitches.get(e)),t===0?this._liveTranspositionPitches.delete(e):this._liveTranspositionPitches.set(e,t);for(const i of this._voices)if(i.playingChannel===e&&i.playingChannel!==9){let r=0;r-=s,r+=t,i.playingKey+=r,this._channels&&i.updatePitchRatio(this._channels.channelList[i.playingChannel],this.outSampleRate)}}applyTranspositionPitches(e){const t=this._transpositionPitches;for(const s of this._voices)if(s.playingChannel>=0&&s.playingChannel!==9){let i=0;t.has(s.playingChannel)&&(i-=t.get(s.playingChannel)),e.has(s.playingChannel)&&(i+=e.get(s.playingChannel)),s.playingKey+=i,this._channels&&s.updatePitchRatio(this._channels.channelList[s.playingChannel],this.outSampleRate)}this._transpositionPitches=e}dispatchEvent(e){this._midiEventQueue.enqueue(e)}_fillWorkingBuffer(e,t,s){const i=this._isAnySolo,r=[];for(;!this._midiEventQueue.isEmpty;){const n=this._midiEventQueue.dequeue();n.isMetronome&&this.metronomeVolume>0?(this.channelNoteOff(de.MetronomeChannel,de.MetronomeKey),this.channelNoteOn(de.MetronomeChannel,de.MetronomeKey,95/127)):n.event&&this.processMidiMessage(n.event),r.push(n)}for(const n of this._voices)if(n.playingPreset!==-1){const o=n.playingChannel,l=this._mutedChannels.has(o)||i&&o!==de.MetronomeChannel&&!this._soloChannels.has(o);e?n.render(this,e,t,s,l):n.kill()}return r}processMidiMessage(e){switch(e.type){case Ie.TimeSignature:const s=e;this.timeSignatureNumerator=s.numerator,this.timeSignatureDenominator=Math.pow(2,s.denominatorIndex);break;case Ie.NoteOn:const i=e;this.channelNoteOn(i.channel,i.noteKey,i.noteVelocity/127);break;case Ie.NoteOff:const r=e;this.channelNoteOff(r.channel,r.noteKey);break;case Ie.ControlChange:const n=e;this.channelMidiControl(n.channel,n.controller,n.value);break;case Ie.ProgramChange:const o=e;this.channelSetPresetNumber(o.channel,o.program,o.channel===9);break;case Ie.TempoChange:const l=e;this.currentTempo=l.beatsPerMinute;break;case Ie.PitchBend:const h=e;this.channelSetPitchWheel(h.channel,h.value);break;case Ie.PerNotePitchBend:const c=e;let d=c.value;d=d*de.MaxPitchWheel/de.MaxPitchWheel20,this.channelSetPerNotePitchWheel(c.channel,c.noteKey,d);break}}get metronomeVolume(){return this.channelGetMixVolume(de.MetronomeChannel)}set metronomeVolume(e){this.setupMetronomeChannel(e)}setupMetronomeChannel(e){this.channelSetMixVolume(de.MetronomeChannel,e),e>0&&(this.channelSetVolume(de.MetronomeChannel,1),this.channelSetPresetNumber(de.MetronomeChannel,0,!0))}get masterVolume(){return Wt.decibelsToGain(this.globalGainDb)}set masterVolume(e){const t=Wt.gainToDecibels(e),s=t-this.globalGainDb;if(s!==0){for(const i of this._voices)i.playingPreset!==-1&&(i.noteGainDb+=s);this.globalGainDb=t}}resetSoft(){for(const e of this._voices)e.playingPreset!==-1&&(e.ampEnv.segment<at.Release||e.ampEnv.parameters.release!==0)&&e.endQuick(this.outSampleRate);if(this._channels)for(const e of this._channels.channelList)e.presetIndex=0,e.bank=0,e.pitchWheel=8192,e.midiPan=8192,e.perNotePitchWheel.clear(),e.midiVolume=16383,e.midiExpression=16383,e.midiRpn=65535,e.midiData=0,e.panOffset=0,e.gainDb=0,e.pitchRange=2,e.tuning=0}
10presets=null;_voices=[];_channels=null;_voicePlayIndex=0;get presetCount(){return this.presets?.length??0}outputMode=Xi.StereoInterleaved;outSampleRate=0;globalGainDb=0;reset(){for(const e of this._voices)e.playingPreset!==-1&&(e.ampEnv.segment<at.Release||e.ampEnv.parameters.release!==0)&&e.endQuick(this.outSampleRate);this._channels=null}setOutput(e,t,s){this.outputMode=e,this.outSampleRate=t>=1?t:44100,this.globalGainDb=s}noteOn(e,t,s){if(!this.presets)return;const i=s*127|0;if(e<0||e>=this.presets.length)return;if(s<=0){this.noteOff(e,t);return}const r=this._voicePlayIndex++;for(const n of this.presets[e].regions){if(t<n.loKey||t>n.hiKey||i<n.loVel||i>n.hiVel)continue;let o=null;if(n.group!==0)for(const c of this._voices)c.playingPreset===e&&c.region.group===n.group?c.endQuick(this.outSampleRate):c.playingPreset===-1&&!o&&(o=c);else for(const c of this._voices)c.playingPreset===-1&&(o=c);if(!o){for(let c=0;c<4;c++){const d=new xa;d.playingPreset=-1,this._voices.push(d)}o=this._voices[this._voices.length-4]}o.region=n,o.playingPreset=e,o.playingKey=t,o.playIndex=r,o.noteGainDb=this.globalGainDb-n.attenuation-Wt.gainToDecibels(1/s),this._channels?this._channels.setupVoice(this,o):(o.calcPitchRatio(0,this.outSampleRate),o.panFactorLeft=Math.sqrt(.5-n.pan),o.panFactorRight=Math.sqrt(.5+n.pan)),o.sourceSamplePosition=n.offset;const l=n.loopMode!==mi.None&&n.loopStart<n.loopEnd;o.loopStart=l?n.loopStart:0,o.loopEnd=l?n.loopEnd:0,o.ampEnv.setup(n.ampEnv,t,i,!0,this.outSampleRate),o.modEnv.setup(n.modEnv,t,i,!1,this.outSampleRate);const h=n.initialFilterQ/10;o.lowPass.qInv=1/Math.pow(10,h/20),o.lowPass.z1=0,o.lowPass.z2=0,o.lowPass.active=n.initialFilterFc<=13500,o.lowPass.active&&o.lowPass.setup(Wt.cents2Hertz(n.initialFilterFc)/this.outSampleRate),o.modLfo.setup(n.delayModLFO,n.freqModLFO,this.outSampleRate),o.vibLfo.setup(n.delayVibLFO,n.freqVibLFO,this.outSampleRate)}}bankNoteOn(e,t,s,i){const r=this._getPresetIndex(e,t);return r===-1?!1:(this.noteOn(r,s,i),!0)}noteOff(e,t){let s=null,i=null;const r=[];for(const n of this._voices)n.playingPreset!==e||n.playingKey!==t||n.ampEnv.segment>=at.Release||(!s||n.playIndex<s.playIndex?(s=n,i=n,r.push(n)):n.playIndex===s.playIndex&&(i=n,r.push(n)));if(s)for(const n of r)n!==s&&n!==i&&(n.playIndex!==s.playIndex||n.playingPreset!==e||n.playingKey!==t||n.ampEnv.segment>=at.Release)||n.end(this.outSampleRate)}bankNoteOff(e,t,s){const i=this._getPresetIndex(e,t);return i===-1?!1:(this.noteOff(i,s),!0)}noteOffAll(e){for(const t of this._voices)t.playingPreset!==-1&&(e?t.endQuick(this.outSampleRate):t.ampEnv.segment<at.Release&&t.end(this.outSampleRate))}get activeVoiceCount(){let e=0;for(const t of this._voices)t.playingPreset!==-1&&e++;return e}_channelInit(e){if(this._channels&&e<this._channels.channelList.length)return this._channels.channelList[e];this._channels||(this._channels=new pc);for(let t=this._channels.channelList.length;t<=e;t++){const s=new fc;s.presetIndex=0,s.bank=0,s.pitchWheel=8192,s.midiPan=8192,s.midiVolume=16383,s.midiExpression=16383,s.midiRpn=65535,s.midiData=0,s.panOffset=0,s.gainDb=0,s.pitchRange=2,s.tuning=0,s.mixVolume=1,this._channels.channelList.push(s)}return this._channels.channelList[e]}_getPresetIndex(e,t){if(!this.presets)return-1;for(let s=this.presets.length-1;s>=0;s--){const i=this.presets[s];if(i.presetNumber===t&&i.bank===e)return s}return-1}getPresetName(e){return this.presets?e<0||e>=this.presets.length?null:this.presets[e].name:null}bankGetPresetName(e,t){return this.getPresetName(this._getPresetIndex(e,t))}channelNoteOn(e,t,s){!this._channels||e>this._channels.channelList.length||(this._transpositionPitches.has(e)&&(t+=this._transpositionPitches.get(e)),this._liveTranspositionPitches.has(e)&&(t+=this._liveTranspositionPitches.get(e)),this._channels.activeChannel=e,this.noteOn(this._channels.channelList[e].presetIndex,t,s))}channelNoteOff(e,t){this._transpositionPitches.has(e)&&(t+=this._transpositionPitches.get(e)),this._liveTranspositionPitches.has(e)&&(t+=this._liveTranspositionPitches.get(e));const s=[];let i=null,r=null;for(const o of this._voices)o.playingPreset===-1||o.playingChannel!==e||o.playingKey!==t||o.ampEnv.segment>=at.Release||(!i||o.playIndex<i.playIndex?(i=o,r=o,s.push(o)):o.playIndex===i.playIndex&&(r=o,s.push(o)));if(this._channelInit(e).perNotePitchWheel.delete(t),!!i)for(const o of s)o!==i&&o!==r&&(o.playIndex!==i.playIndex||o.playingPreset===-1||o.playingChannel!==e||o.playingKey!==t||o.ampEnv.segment>=at.Release)||o.end(this.outSampleRate)}channelNoteOffAll(e){this._channelInit(e).perNotePitchWheel.clear();for(const s of this._voices)s.playingPreset!==-1&&s.playingChannel===e&&s.ampEnv.segment<at.Release&&s.end(this.outSampleRate)}channelSoundsOffAll(e){this._channelInit(e).perNotePitchWheel.clear();for(const s of this._voices)s.playingPreset!==-1&&s.playingChannel===e&&(s.ampEnv.segment<at.Release||s.ampEnv.parameters.release===0)&&s.endQuick(this.outSampleRate)}channelSetPresetIndex(e,t){this._channelInit(e).presetIndex=be.int32ToUint16(t)}channelSetPresetNumber(e,t,s=!1){const i=this._channelInit(e);let r=0;return s?(r=this._getPresetIndex(128|i.bank&32767,t),r===-1&&(r=this._getPresetIndex(128,t)),r===-1&&(r=this._getPresetIndex(128,0)),r===-1&&(r=this._getPresetIndex(i.bank&2047,t))):r=this._getPresetIndex(i.bank&2047,t),i.presetIndex=r,r!==-1}channelSetBank(e,t){this._channelInit(e).bank=be.int32ToUint16(t)}channelSetBankPreset(e,t,s){const i=this._channelInit(e),r=this._getPresetIndex(t,s);return r===-1?!1:(i.presetIndex=be.int32ToUint16(r),i.bank=be.int32ToUint16(t),!0)}channelSetPan(e,t){for(const s of this._voices)if(s.playingChannel===e&&s.playingPreset!==-1){const i=s.region.pan+t-.5;i<=-.5?(s.panFactorLeft=1,s.panFactorRight=0):i>=.5?(s.panFactorLeft=0,s.panFactorRight=1):(s.panFactorLeft=Math.sqrt(.5-i),s.panFactorRight=Math.sqrt(.5+i))}this._channelInit(e).panOffset=t-.5}channelSetVolume(e,t){const s=this._channelInit(e),i=Wt.gainToDecibels(t),r=i-s.gainDb;if(r!==0){for(const n of this._voices)n.playingChannel===e&&n.playingPreset!==-1&&(n.noteGainDb+=r);s.gainDb=i}}channelSetPitchWheel(e,t){const s=this._channelInit(e);s.pitchWheel!==t&&(s.pitchWheel=be.int32ToUint16(t),this._channelApplyPitch(e,s))}
10channelSetPerNotePitchWheel(e,t,s){this._transpositionPitches.has(e)&&(t+=this._transpositionPitches.get(e)),this._liveTranspositionPitches.has(e)&&(t+=this._liveTranspositionPitches.get(e));const i=this._channelInit(e);i.perNotePitchWheel.has(t)&&i.perNotePitchWheel.get(t)===s||(i.perNotePitchWheel.set(t,s),this._channelApplyPitch(e,i,t))}_channelApplyPitch(e,t,s=-1){for(const i of this._voices)i.playingChannel===e&&i.playingPreset!==-1&&(s===-1||i.playingKey===s)&&i.updatePitchRatio(t,this.outSampleRate)}channelSetPitchRange(e,t){const s=this._channelInit(e);s.pitchRange!==t&&(s.pitchRange=t,s.pitchWheel!==8192&&this._channelApplyPitch(e,s))}channelSetTuning(e,t){const s=this._channelInit(e);s.tuning!==t&&(s.tuning=t,this._channelApplyPitch(e,s))}channelMidiControl(e,t,s){const i=this._channelInit(e);switch(t){case et.DataEntryFine:i.midiData=be.int32ToUint16(i.midiData&16256|s),i.midiRpn===0?this.channelSetPitchRange(e,(i.midiData>>7)+.01*(i.midiData&127)):i.midiRpn===1?this.channelSetTuning(e,(i.tuning|0)+(i.midiData-8192)/8192):i.midiRpn===2&&this.channelSetTuning(e,s-64+(i.tuning-(i.tuning|0)));return;case et.VolumeCoarse:i.midiVolume=be.int32ToUint16(i.midiVolume&127|s<<7),this.channelSetVolume(e,Math.pow(i.midiVolume/16383*(i.midiExpression/16383),3));return;case et.VolumeFine:i.midiVolume=be.int32ToUint16(i.midiVolume&16256|s),this.channelSetVolume(e,Math.pow(i.midiVolume/16383*(i.midiExpression/16383),3));return;case et.ExpressionControllerCoarse:i.midiExpression=be.int32ToUint16(i.midiExpression&127|s<<7),this.channelSetVolume(e,Math.pow(i.midiVolume/16383*(i.midiExpression/16383),3));return;case et.ExpressionControllerFine:i.midiExpression=be.int32ToUint16(i.midiExpression&16256|s),this.channelSetVolume(e,Math.pow(i.midiVolume/16383*(i.midiExpression/16383),3));return;case et.PanCoarse:i.midiPan=be.int32ToUint16(i.midiPan&127|s<<7),this.channelSetPan(e,i.midiPan/16383);return;case et.PanFine:i.midiPan=be.int32ToUint16(i.midiPan&16256|s),this.channelSetPan(e,i.midiPan/16383);return;case et.DataEntryCoarse:i.midiData=be.int32ToUint16(i.midiData&127|s<<7),i.midiRpn===0?this.channelSetPitchRange(e,(i.midiData>>7)+.01*(i.midiData&127)):i.midiRpn===1?this.channelSetTuning(e,(i.tuning|0)+(i.midiData-8192)/8192):i.midiRpn===2&&t===et.DataEntryCoarse&&this.channelSetTuning(e,s-64+(i.tuning-(i.tuning|0)));return;case et.BankSelectCoarse:i.bank=be.int32ToUint16(32768|s);return;case et.BankSelectFine:i.bank=be.int32ToUint16(((i.bank&32768)!==0?(i.bank&127)<<7:0)|s);return;case et.RegisteredParameterCourse:i.midiRpn=be.int32ToUint16((i.midiRpn===65535?0:i.midiRpn)&127|s<<7);return;case et.RegisteredParameterFine:i.midiRpn=be.int32ToUint16((i.midiRpn===65535?0:i.midiRpn)&16256|s);return;case et.NonRegisteredParameterFine:i.midiRpn=65535;return;case et.NonRegisteredParameterCourse:i.midiRpn=65535;return;case et.AllSoundOff:this.channelSoundsOffAll(e);return;case et.AllNotesOff:this.channelNoteOffAll(e);return;case et.ResetControllers:i.midiVolume=16383,i.midiExpression=16383,i.midiPan=8192,i.bank=0,this.channelSetVolume(e,1),this.channelSetPan(e,.5),this.channelSetPitchRange(e,2);return}}channelGetPresetIndex(e){return this._channels&&e<this._channels.channelList.length?this._channels.channelList[e].presetIndex:0}channelGetPresetBank(e){return this._channels&&e<this._channels.channelList.length?this._channels.channelList[e].bank&32767:0}channelGetPan(e){return this._channels&&e<this._channels.channelList.length?this._channels.channelList[e].panOffset-.5:.5}channelGetVolume(e){return this._channels&&e<this._channels.channelList.length?Wt.decibelsToGain(this._channels.channelList[e].gainDb):1}channelGetPitchWheel(e){return this._channels&&e<this._channels.channelList.length?this._channels.channelList[e].pitchWheel:8192}channelGetPitchRange(e){return this._channels&&e<this._channels.channelList.length?this._channels.channelList[e].pitchRange:2}channelGetTuning(e){return this._channels&&e<this._channels.channelList.length?this._channels.channelList[e].tuning:0}resetPresets(){this.presets=[]}loadPresets(e,t,s,i){const r=[];for(let n=0;n<e.phdrs.length-1;n++){const o=e.phdrs[n];let l=0;const h=new gc;r.push(h),h.name=o.presetName,h.bank=o.bank,h.presetNumber=o.preset;let c=0;for(let f=o.presetBagNdx;f<e.phdrs[n+1].presetBagNdx;f++){const p=e.pbags[f];let g=0,m=127,b=0,S=127;for(let N=p.genNdx;N<e.pbags[f+1].genNdx;N++){const v=e.pgens[N];
10if(v.genOper===pi.GenKeyRange){g=v.genAmount.lowByteAmount,m=v.genAmount.highByteAmount;continue}if(v.genOper===pi.GenVelRange){b=v.genAmount.lowByteAmount,S=v.genAmount.highByteAmount;continue}if(v.genOper!==pi.GenInstrument||v.genAmount.wordAmount>=e.insts.length)continue;const W=e.insts[v.genAmount.wordAmount];for(let j=W.instBagNdx;j<e.insts[v.genAmount.wordAmount+1].instBagNdx;j++){const q=e.ibags[j];let F=0,Q=127,me=0,ge=127;for(let re=q.instGenNdx;re<e.ibags[j+1].instGenNdx;re++){const Je=e.igens[re];if(Je.genOper===pi.GenKeyRange){F=Je.genAmount.lowByteAmount,Q=Je.genAmount.highByteAmount;continue}if(Je.genOper===pi.GenVelRange){me=Je.genAmount.lowByteAmount,ge=Je.genAmount.highByteAmount;continue}Je.genOper===53&&Q>=g&&F<=m&&ge>=b&&me<=S&&c++}}}}h.regions=new Array(c);let d=new gi;d.clear(!0);for(let f=o.presetBagNdx;f<e.phdrs[n+1].presetBagNdx;f++){const p=e.pbags[f],g=new gi(d);let m=!1;for(let b=p.genNdx;b<e.pbags[f+1].genNdx;b++){const S=e.pgens[b];if(S.genOper===pi.GenInstrument){const N=S.genAmount.wordAmount;if(N>=e.insts.length)continue;let v=new gi;v.clear(!1);const W=e.insts[N];for(let j=W.instBagNdx;j<e.insts[N+1].instBagNdx;j++){const q=e.ibags[j],F=new gi(v);let Q=!1;for(let me=q.instGenNdx;me<e.ibags[j+1].instGenNdx;me++){const ge=e.igens[me];if(ge.genOper===pi.GenSampleId){if(F.hiKey<g.loKey||F.loKey>g.hiKey||F.hiVel<g.loVel||F.loVel>g.hiVel)continue;g.loKey>F.loKey&&(F.loKey=g.loKey),g.hiKey<F.hiKey&&(F.hiKey=g.hiKey),g.loVel>F.loVel&&(F.loVel=g.loVel),g.hiVel<F.hiVel&&(F.hiVel=g.hiVel),F.offset+=g.offset,F.end+=g.end,F.loopStart+=g.loopStart,F.loopEnd+=g.loopEnd,F.transpose+=g.transpose,F.tune+=g.tune,F.pitchKeyTrack+=g.pitchKeyTrack,F.attenuation+=g.attenuation,F.pan+=g.pan,F.ampEnv.delay+=g.ampEnv.delay,F.ampEnv.attack+=g.ampEnv.attack,F.ampEnv.hold+=g.ampEnv.hold,F.ampEnv.decay+=g.ampEnv.decay,F.ampEnv.sustain+=g.ampEnv.sustain,F.ampEnv.release+=g.ampEnv.release,F.modEnv.delay+=g.modEnv.delay,F.modEnv.attack+=g.modEnv.attack,F.modEnv.hold+=g.modEnv.hold,F.modEnv.decay+=g.modEnv.decay,F.modEnv.sustain+=g.modEnv.sustain,F.modEnv.release+=g.modEnv.release,F.initialFilterQ+=g.initialFilterQ,F.initialFilterFc+=g.initialFilterFc,F.modEnvToPitch+=g.modEnvToPitch,F.modEnvToFilterFc+=g.modEnvToFilterFc,F.delayModLFO+=g.delayModLFO,F.freqModLFO+=g.freqModLFO,F.modLfoToPitch+=g.modLfoToPitch,F.modLfoToFilterFc+=g.modLfoToFilterFc,F.modLfoToVolume+=g.modLfoToVolume,F.delayVibLFO+=g.delayVibLFO,F.freqVibLFO+=g.freqVibLFO,F.vibLfoToPitch+=g.vibLfoToPitch,F.ampEnv.envToSecs(!0),F.modEnv.envToSecs(!1),F.delayModLFO=F.delayModLFO<-11950?0:Wt.timecents2Secs(F.delayModLFO),F.delayVibLFO=F.delayVibLFO<-11950?0:Wt.timecents2Secs(F.delayVibLFO),F.pan<-.5?F.pan=-.5:F.pan>.5&&(F.pan=.5),(F.initialFilterQ<1500||F.initialFilterQ>13500)&&(F.initialFilterQ=0);const re=e.sHdrs[ge.genAmount.wordAmount];F.offset+=re.start,F.end+=re.end,F.loopStart+=re.startLoop,F.loopEnd+=re.endLoop,re.endLoop>0&&(F.loopEnd-=1),F.pitchKeyCenter===-1&&(F.pitchKeyCenter=re.originalPitch),F.tune+=re.pitchCorrection,F.sampleRate=re.sampleRate;const Je=o.bank===de.PercussionBank;Je&&yn._setContainsRange(s,F.loKey,F.hiKey)||!Je&&t.has(o.preset)?(re.sampleType&1)!==0?(E.debug("AlphaSynth",`Loading of used sample ${re.sampleName} for preset ${o.presetName} (bank ${h.bank} program ${h.presetNumber})`),(re.sampleType&16)!==0?F.samples=e.decodeSamples(re.start,re.end,!0):(F.samples=e.decodeSamples(F.offset*2,F.end*2,!1),F.loopStart>0&&(F.loopStart-=F.offset),F.loopEnd>0&&(F.loopEnd-=F.offset)),F.offset=0,F.end=F.samples.length-1):(E.warning("AlphaSynth",`Skipping load of unsupported sample ${re.sampleName} for preset ${o.presetName}, sample type ${re.sampleType} is not supported (bank ${h.bank} program ${h.presetNumber})`),F.samples=new Float32Array(0)):(E.debug("AlphaSynth",`Skipping load of unused sample ${re.sampleName} for preset ${o.presetName} (bank ${h.bank} program ${h.presetNumber})`),F.samples=new Float32Array(0)),h.regions[l]=new gi(F),l++,Q=!0}else F.operator(ge.genOper,ge.genAmount)}q===e.ibags[W.instBagNdx]&&!Q&&(v=new gi(F))}m=!0}else g.operator(S.genOper,S.genAmount)}p===e.pbags[o.presetBagNdx]&&!m&&(d=g)}}if(!i||!this.presets)this.presets=r;else for(const n of r)this.presets.push(n)}
vendor: 58,043 bytes, line 10
10static _setContainsRange(e,t,s){for(let i=t;i<=s;i++)if(e.has(i))return!0;return!1}hasSamplesForProgram(e){const t=this.presets;if(!t)return!1;for(const s of t)if(s.presetNumber===e){for(const i of s.regions)if(i.samples.length>0)return!0}return!1}hasSamplesForPercussion(e){const t=this.presets;if(!t)return!1;for(const s of t)if(s.bank===de.PercussionBank){for(const i of s.regions)if(i.loKey>=e&&i.hiKey<=e&&i.samples.length>0)return!0}return!1}}class xo{events;constructor(e){this.events=e}}class br{playbackRange;constructor(e){this.playbackRange=e}}class Zl{soundFonts;sampleRate=44100;useSyncPoints=!1;masterVolume=1;metronomeVolume=0;playbackRange;trackVolume=new Map;trackTranspositionPitches=new Map}class jl{samples;currentTime=0;endTime=0;currentTick=0;endTick=0}class No{sequencer;synthesizer;isSoundFontLoaded=!1;_isMidiLoaded=!1;_tickPosition=0;_timePosition=0;_metronomeVolume=0;_countInVolume=0;playedEventsQueue=new To;midiEventsPlayedFilterSet=new Set;_notPlayedSamples=0;_synthStopping=!1;_output;_loadedMidiInfo;_currentPosition=new Ys(0,0,0,0,!1,120,120);get output(){return this._output}isReady=!1;get isReadyForPlayback(){return this.isReady&&this.isSoundFontLoaded&&this._isMidiLoaded}state=Rt.Paused;get logLevel(){return E.logLevel}set logLevel(e){E.logLevel=e}get masterVolume(){return this.synthesizer.masterVolume}set masterVolume(e){e=Math.max(e,de.MinVolume),this.updateMasterVolume(e)}updateMasterVolume(e){this.synthesizer.masterVolume=e}get metronomeVolume(){return this._metronomeVolume}set metronomeVolume(e){e=Math.max(e,de.MinVolume),this._metronomeVolume=e,this.synthesizer.metronomeVolume=e}get countInVolume(){return this._countInVolume}set countInVolume(e){e=Math.max(e,de.MinVolume),this._countInVolume=e}get midiEventsPlayedFilter(){return Array.from(this.midiEventsPlayedFilterSet)}set midiEventsPlayedFilter(e){this.midiEventsPlayedFilterSet=new Set(e)}get playbackSpeed(){return this.sequencer.playbackSpeed}set playbackSpeed(e){e=L.clamp(e,de.MinPlaybackSpeed,de.MaxPlaybackSpeed),this.updatePlaybackSpeed(e)}updatePlaybackSpeed(e){const t=this.sequencer.playbackSpeed;this.sequencer.playbackSpeed=e,this.timePosition=this.timePosition*(t/e)}get loadedMidiInfo(){return this._loadedMidiInfo}get currentPosition(){return this._currentPosition}get tickPosition(){return this._tickPosition}set tickPosition(e){this.timePosition=this.sequencer.mainTickPositionToTimePosition(e)}get timePosition(){return this._timePosition}set timePosition(e){E.debug("AlphaSynth",`Seeking to position ${e}ms (main)`),this.sequencer.mainSeek(e),this.updateTimePosition(e,!0),this.sequencer.isPlayingMain&&(this._notPlayedSamples=0,this.output.resetSamples())}get playbackRange(){return this.sequencer.mainPlaybackRange}set playbackRange(e){this.sequencer.mainPlaybackRange=e,e&&(this.tickPosition=e.startTick),this.playbackRangeChanged.trigger(new br(e))}get isLooping(){return this.sequencer.isLooping}set isLooping(e){this.sequencer.isLooping=e}destroy(){E.debug("AlphaSynth","Destroying player"),this.stop(),this.output.destroy()}constructor(e,t,s){E.debug("AlphaSynth","Initializing player"),this.state=Rt.Paused,this.ready=new _t(()=>this.isReady),this.readyForPlayback=new _t(()=>this.isReadyForPlayback),this.midiLoaded=new Se(()=>this._loadedMidiInfo?this._loadedMidiInfo:null),this.stateChanged=new Se(()=>new Yi(this.state,!1)),this.positionChanged=new Se(()=>this._currentPosition),this.playbackRangeChanged=new Se(()=>this.playbackRange?new br(this.playbackRange):null),E.debug("AlphaSynth","Creating output"),this._output=e,E.debug("AlphaSynth","Creating synthesizer"),this.synthesizer=t,this.sequencer=new zi(this.synthesizer),E.debug("AlphaSynth","Opening output"),this.output.ready.on(()=>{this.isReady=!0,this.ready.trigger(),this._checkReadyForPlayback()}),this.output.sampleRequest.on(()=>{this.onSampleRequest()}),this.output.samplesPlayed.on(this._onSamplesPlayed.bind(this)),this.output.open(s)}onSampleRequest(){if(this.state===Rt.Playing&&(!this.sequencer.isFinished||this.synthesizer.activeVoiceCount>0)){let e=new Float32Array(de.MicroBufferSize*de.MicroBufferCount*de.AudioChannels),t=0;for(let s=0;s<de.MicroBufferCount;s++){this.sequencer.fillMidiEventQueue();const i=this.synthesizer.synthesize(e,t,de.MicroBufferSize);t+=de.MicroBufferSize*de.AudioChannels;for(const r of i)this.midiEventsPlayedFilterSet.has(r.event.type)&&this.playedEventsQueue.enqueue(r);if(this.sequencer.isFinished)break}t<e.length&&(e=e.subarray(0,t)),this._notPlayedSamples+=e.length,this.output.addSamples(e)}else{const e=new Float32Array(0);this.output.addSamples(e)}}play(){return this.state!==Rt.Paused||!this._isMidiLoaded?!1:(this.output.activate(),this._playInternal(),this._countInVolume>0&&(E.debug("AlphaSynth","Starting countin"),this.sequencer.startCountIn(),this.synthesizer.setupMetronomeChannel(this._countInVolume),this.updateTimePosition(0,!0)),this.output.play(),!0)}_playInternal(){this.sequencer.isPlayingOneTimeMidi&&(E.debug("AlphaSynth","Cancelling one time midi"),this._stopOneTimeMidi()),E.debug("AlphaSynth","Starting playback"),this.synthesizer.setupMetronomeChannel(this.metronomeVolume),this._synthStopping=!1,this.state=Rt.Playing,this.stateChanged.trigger(new Yi(this.state,!1))}pause(){this.state===Rt.Paused||!this._isMidiLoaded||(E.debug("AlphaSynth","Pausing playback"),this.state=Rt.Paused,this.stateChanged.trigger(new Yi(this.state,!1)),this.output.pause(),this.synthesizer.noteOffAll(!1))}playPause(){this.state!==Rt.Paused||!this._isMidiLoaded?this.pause():this.play()}stop(){this._isMidiLoaded&&(E.debug("AlphaSynth","Stopping playback"),this.state=Rt.Paused,this.output.pause(),this._notPlayedSamples=0,this.sequencer.stop(),this.synthesizer.noteOffAll(!0),this.tickPosition=this.sequencer.mainPlaybackRange?this.sequencer.mainPlaybackRange.startTick:0,this.stateChanged.trigger(new Yi(this.state,!0)))}playOneTimeMidiFile(e){this.sequencer.isPlayingOneTimeMidi?this._stopOneTimeMidi():this.pause(),this.sequencer.loadOneTimeMidi(e),this.synthesizer.noteOffAll(!0),this.updateTimePosition(0,!0),this._notPlayedSamples=0,this.output.resetSamples(),this.output.play()}resetSoundFonts(){this.stop(),this.synthesizer.resetPresets(),this._loadedSoundFonts=[],this.isSoundFontLoaded=!1,this.soundFontLoaded.trigger()}_loadedSoundFonts=[];loadSoundFont(e,t){this.pause();const s=gt.fromBuffer(e);try{E.debug("AlphaSynth","Loading soundfont from bytes");const i=new Ql;i.load(s),t||(this._loadedSoundFonts=[]),this._loadedSoundFonts.push(i),this.isSoundFontLoaded=!0,this.soundFontLoaded.trigger(),E.debug("AlphaSynth","soundFont successfully loaded"),this._checkReadyForPlayback()}catch(i){E.error("AlphaSynth",`Could not load soundfont from bytes ${i}`),this.soundFontLoadFailed.trigger(i)}}_checkReadyForPlayback(){if(this.isReadyForPlayback){this.synthesizer.setupMetronomeChannel(this.metronomeVolume);const e=this.sequencer.instrumentPrograms,t=this.sequencer.percussionKeys;let s=!1;for(const i of this._loadedSoundFonts)this.synthesizer.loadPresets(i,e,t,s),s=!0;this.readyForPlayback.trigger()}}loadMidiFile(e){this.stop();try{E.debug("AlphaSynth","Loading midi from model"),this.sequencer.loadMidi(e),this._isMidiLoaded=!0,this._loadedMidiInfo=new Ys(0,this.sequencer.currentEndTime,0,this.sequencer.currentEndTick,!1,this.sequencer.currentTempo,this.sequencer.modifiedTempo),this.midiLoaded.trigger(this._loadedMidiInfo),E.debug("AlphaSynth","Midi successfully loaded"),this._checkReadyForPlayback(),this.tickPosition=0}catch(t){E.error("AlphaSynth",`Could not load midi from model ${t}`),this.midiLoadFailed.trigger(t)}}applyTranspositionPitches(e){this.synthesizer.applyTranspositionPitches(e)}setChannelTranspositionPitch(e,t){this.synthesizer.setChannelTranspositionPitch(e,t)}setChannelMute(e,t){this.synthesizer.channelSetMute(e,t)}resetChannelStates(){this.synthesizer.resetChannelStates()}setChannelSolo(e,t){this.synthesizer.channelSetSolo(e,t)}setChannelVolume(e,t){t=Math.max(t,de.MinVolume),this.synthesizer.channelSetMixVolume(e,t)}_onSamplesPlayed(e){if(e===0)return;const t=e/this.synthesizer.outSampleRate*1e3;this._notPlayedSamples-=e*de.AudioChannels,this.updateTimePosition(this._timePosition+t,!1),this.checkForFinish()}checkForFinish(){let e=0,t=0;this.playbackRange&&this.sequencer.isPlayingMain?(e=this.playbackRange.startTick,t=this.playbackRange.endTick):t=this.sequencer.currentEndTick,this._tickPosition>=t&&(this._notPlayedSamples<=0?(this._notPlayedSamples=0,this.sequencer.isPlayingCountIn?(E.debug("AlphaSynth","Finished playback (count-in)"),this.sequencer.resetCountIn(),this.timePosition=this.sequencer.currentTime,this._playInternal(),this.output.resetSamples()):this.sequencer.isPlayingOneTimeMidi?(E.debug("AlphaSynth","Finished playback (one time)"),this.output.resetSamples(),this.state=Rt.Paused,this._stopOneTimeMidi()):this.isLooping?(E.debug("AlphaSynth","Finished playback (main looping)"),this.finished.trigger(),this.tickPosition=e,this._synthStopping=!1):this.synthesizer.activeVoiceCount>0?this._synthStopping||(E.debug("AlphaSynth","Signaling synth to stop all voices (all samples played)"),this.synthesizer.noteOffAll(!0),this._synthStopping=!0):(this._synthStopping=!1,E.debug("AlphaSynth","Finished playback (main)"),this.finished.trigger(),this.stop())):this._synthStopping||(E.debug("AlphaSynth","Signaling synth to stop all voices (not all samples played)"),this.synthesizer.noteOffAll(!0),this._synthStopping=!0))}_stopOneTimeMidi(){this.output.pause(),this.synthesizer.noteOffAll(!0),this.sequencer.resetOneTimeMidi(),this.timePosition=this.sequencer.currentTime}_createPositionChangedEventArgs(e){let t=this._timePosition,s=this.sequencer.currentTimePositionToTickPosition(t);const i=this.sequencer.currentEndTime,r=this.sequencer.currentEndTick;return t>i&&(t=i,s=r),new Ys(t,i,s,r,e,this.sequencer.currentTempo,this.sequencer.modifiedTempo)}updateTimePosition(e,t){this._timePosition=e;const s=this._createPositionChangedEventArgs(t);this._tickPosition=s.currentTick;const i=this.sequencer.isPlayingMain?"main":this.sequencer.isPlayingCountIn?"count-in":"one-time";if(E.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._currentPosition=s,this.positionChanged.trigger(s)),t)this.playedEventsQueue.clear();else{const r=[];for(;!this.playedEventsQueue.isEmpty&&this.playedEventsQueue.peek().time<s.currentTime;){const n=this.playedEventsQueue.dequeue();r.push(n.event)}r.length>0&&(r.reverse(),this.midiEventsPlayed.trigger(new xo(r)))}}ready;readyForPlayback=new _t;finished=new _t;soundFontLoaded=new _t;soundFontLoadFailed=new Se;midiLoaded;midiLoadFailed=new Se;stateChanged;positionChanged;midiEventsPlayed=new Se;playbackRangeChanged;hasSamplesForProgram(e){return this.synthesizer.hasSamplesForProgram(e)}hasSamplesForPercussion(e){return this.synthesizer.hasSamplesForPercussion(e)}loadBackingTrack(e){}updateSyncPoints(e){}}class eh extends No{constructor(e,t){super(e,new yn(e.sampleRate),t)}exportAudio(e,t,s,i){const r=new mc(e);r.loadMidiFile(t),e.useSyncPoints&&r.updateSyncPoints(s),r.applyTranspositionPitches(i);for(const[n,o]of e.trackTranspositionPitches)r.setChannelTranspositionPitch(n,o);for(const[n,o]of e.trackVolume)r.channelSetMixVolume(n,o);if(e.soundFonts)for(const n of e.soundFonts)r.loadSoundFont(n);else r.loadPresets(this.synthesizer.presets);return e.playbackRange&&r.limitExport(e.playbackRange),r.setup(),r}}class mc{_synth;_sequencer;constructor(e){this._synth=new yn(e.sampleRate),this._sequencer=new zi(this._synth),this._synth.masterVolume=Math.max(e.masterVolume,de.MinVolume),this._synth.metronomeVolume=Math.max(e.metronomeVolume,de.MinVolume)}loadSoundFont(e){const t=gt.fromBuffer(e),s=new Ql;s.load(t);const i=this._sequencer.instrumentPrograms,r=this._sequencer.percussionKeys;this._synth.loadPresets(s,i,r,!0)}loadPresets(e){this._synth.presets=e}limitExport(e){this._sequencer.mainPlaybackRange=e,this._sequencer.mainSeek(this._sequencer.mainTickPositionToTimePosition(e.startTick))}setChannelTranspositionPitch(e,t){this._synth.setChannelTranspositionPitch(e,t)}applyTranspositionPitches(e){this._synth.applyTranspositionPitches(e)}loadMidiFile(e){this._sequencer.loadMidi(e)}updateSyncPoints(e){this._sequencer.mainUpdateSyncPoints(e)}channelSetMixVolume(e,t){t=Math.max(t,de.MinVolume),this._synth.channelSetMixVolume(e,t)}_generatedAudioCurrentTime=0;_generatedAudioEndTime=0;setup(){this._synth.setupMetronomeChannel(this._synth.metronomeVolume);const e=this._sequencer.currentSyncPoints,t=this._sequencer.currentEndTime;if(e.length===0)this._generatedAudioEndTime=t;else{const s=e[e.length-1];let i=s.syncTime;const r=this._sequencer.currentEndTick-s.synthTick;r>0&&(i+=B.ticksToMillis(r,s.syncBpm)),this._generatedAudioEndTime=i}}render(e){if(this._sequencer.isFinished)return;const t=de.MicroBufferSize*1e3/this._synth.outSampleRate,s=Math.ceil(e/t);let i=new Float32Array(de.MicroBufferSize*s*de.AudioChannels);const r=this._sequencer.currentSyncPoints;let n=0,o=this._generatedAudioCurrentTime;for(let h=0;h<s;h++){if(r.length>0){this._sequencer.currentUpdateSyncPoints(o),this._sequencer.currentUpdateCurrentTempo(this._sequencer.currentTime);const c=this._sequencer.syncPointTempo/this._sequencer.currentTempo;this._sequencer.playbackSpeed!==c&&(this._sequencer.playbackSpeed=c)}if(this._sequencer.fillMidiEventQueue(),this._synth.synthesize(i,n,de.MicroBufferSize),n+=de.MicroBufferSize*de.AudioChannels,o+=t,this._sequencer.isFinished)break}n<i.length&&(i=i.subarray(0,n));const l=new jl;return l.currentTime=this._generatedAudioCurrentTime,l.endTime=this._generatedAudioEndTime,l.currentTick=this._sequencer.currentTimePositionToTickPosition(this._sequencer.currentTime),l.endTick=this._sequencer.currentEndTick,this._generatedAudioCurrentTime+=e,l.samples=i,this._sequencer.isFinished&&this._synth.noteOffAll(!0),l}}class T{static parseEnum(e,t){switch(typeof e){case"string":const s=Number.parseInt(e,10);return Number.isNaN(s)?t[Object.keys(t).find(i=>i.toLowerCase()===e.toLowerCase())]:s;case"number":return e;case"undefined":case"object":return}throw new Ye(Ge.Format,`Could not parse enum value '${e}'`)}static parseEnumExact(e,t){if(e in t)return t[e]}static forEach(e,t){if(e instanceof Map)e.forEach(t);else if(typeof e=="object")for(const s in e)t(e[s],s)}static getValue(e,t){return e instanceof Map?e.get(t):typeof e=="object"?e[t]:null}}class Na{static fromJson(e,t){t&&T.forEach(t,(s,i)=>Na.setProperty(e,i,s))}static toJson(e){if(!e)return null;const t=new Map;{const s=new Map;t.set("groups",s);for(const[i,r]of e.groups)s.set(i.toString(),r)}return t}static setProperty(e,t,s){return t==="groups"?(e.groups=new Map,T.forEach(s,(i,r)=>{e.groups.set(T.parseEnum(r,y),i)}),!0):!1}}class Pa{static fromJson(e,t){t&&T.forEach(t,(s,i)=>Pa.setProperty(e,i,s))}static toJson(e){if(!e)return null;const t=new Map;return t.set("marker",e.marker),t.set("text",e.text),t}static setProperty(e,t,s){switch(t){case"marker":return e.marker=s,!0;case"text":return e.text=s,!0}return!1}}class Ca{static fromJson(e,t){t&&T.forEach(t,(s,i)=>Ca.setProperty(e,i,s))}static toJson(e){if(!e)return null;const t=new Map;return t.set("baroccurence",e.barOccurence),t.set("millisecondoffset",e.millisecondOffset),t}static setProperty(e,t,s){switch(t){case"baroccurence":return e.barOccurence=s,!0;case"millisecondoffset":return e.millisecondOffset=s,!0}return!1}}class Li{static fromJson(e,t){t&&T.forEach(t,(s,i)=>Li.setProperty(e,i,s))}static toJson(e){if(!e)return null;const t=new Map;return t.set("islinear",e.isLinear),t.set("type",e.type),t.set("value",e.value),e.syncPointValue&&t.set("syncpointvalue",Ca.toJson(e.syncPointValue)),t.set("ratioposition",e.ratioPosition),t.set("text",e.text),t.set("isvisible",e.isVisible),t}static setProperty(e,t,s){switch(t){case"islinear":return e.isLinear=s,!0;case"type":return e.type=T.parseEnum(s,Re),!0;case"value":return e.value=s,!0;case"syncpointvalue":return s?(e.syncPointValue=new ra,Ca.fromJson(e.syncPointValue,s)):e.syncPointValue=void 0,!0;case"ratioposition":return e.ratioPosition=s,!0;case"text":return e.text=s,!0;case"isvisible":return e.isVisible=s,!0}return!1}}class Ea{static fromJson(e,t){t&&T.forEach(t,(s,i)=>Ea.setProperty(e,i,s))}static toJson(e){if(!e)return null;const t=new Map;return t.set("type",e.type),t.set("length",e.length),t}static setProperty(e,t,s){switch(t){case"type":return e.type=T.parseEnum(s,os),!0;case"length":return e.length=s,!0}return!1}}class va{static fromJson(e,t){t&&T.forEach(t,(s,i)=>va.setProperty(e,i,s))}static toJson(e){if(!e)return null;const t=new Map;if(t.set("alternateendings",e.alternateEndings),t.set("isdoublebar",e.isDoubleBar),t.set("isrepeatstart",e.isRepeatStart),t.set("repeatcount",e.repeatCount),t.set("timesignaturenumerator",e.timeSignatureNumerator),t.set("timesignaturedenominator",e.timeSignatureDenominator),t.set("timesignaturecommon",e.timeSignatureCommon),e.beamingRules&&t.set("beamingrules",Na.toJson(e.beamingRules)),t.set("isfreetime",e.isFreeTime),t.set("tripletfeel",e.tripletFeel),e.section&&t.set("section",Pa.toJson(e.section)),t.set("tempoautomations",e.tempoAutomations.map(s=>Li.toJson(s))),e.syncPoints!==void 0&&t.set("syncpoints",e.syncPoints?.map(s=>Li.toJson(s))),e.fermata!==null){const s=new Map;t.set("fermata",s);for(const[i,r]of e.fermata)s.set(i.toString(),Ea.toJson(r))}if(t.set("start",e.start),t.set("isanacrusis",e.isAnacrusis),t.set("displayscale",e.displayScale),t.set("displaywidth",e.displayWidth),e.directions!==null){const s=[];t.set("directions",s);for(const i of e.directions)s.push(i)}return t}static setProperty(e,t,s){switch(t){case"alternateendings":return e.alternateEndings=s,!0;case"isdoublebar":return e.isDoubleBar=s,!0;case"isrepeatstart":return e.isRepeatStart=s,!0;case"repeatcount":return e.repeatCount=s,!0;case"timesignaturenumerator":return e.timeSignatureNumerator=s,!0;case"timesignaturedenominator":return e.timeSignatureDenominator=s,!0;case"timesignaturecommon":return e.timeSignatureCommon=s,!0;case"beamingrules":return s?(e.beamingRules=new nt,Na.fromJson(e.beamingRules,s)):e.beamingRules=void 0,!0;case"isfreetime":return e.isFreeTime=s,!0;case"tripletfeel":return e.tripletFeel=T.parseEnum(s,Ce),!0;case"section":return s?(e.section=new Tr,Pa.fromJson(e.section,s)):e.section=null,!0;case"tempoautomations":e.tempoAutomations=[];for(const i of s){const r=new tt;Li.fromJson(r,i),e.tempoAutomations.push(r)}return!0;case"syncpoints":if(s){e.syncPoints=[];for(const i of s){const r=new tt;Li.fromJson(r,i),e.addSyncPoint(r)}}return!0;case"fermata":return e.fermata=new Map,T.forEach(s,(i,r)=>{const n=new Br;Ea.fromJson(n,i),e.addFermata(Number.parseInt(r),n)}),!0;case"start":return e.start=s,!0;case"isanacrusis":return e.isAnacrusis=s,!0;case"displayscale":return e.displayScale=s,!0;case"displaywidth":return e.displayWidth=s,!0;case"directions":for(const i of s)e.addDirection(T.parseEnum(i,U));return!0}return!1}}class _r{static fromJson(e,t){t&&T.forEach(t,(s,i)=>_r.setProperty(e,i,s))}static toJson(e){if(!e)return null;const t=new Map;return t.set("offset",e.offset),t.set("value",e.value),t}static setProperty(e,t,s){switch(t){case"offset":return e.offset=s,!0;case"value":return e.value=s,!0}return!1}}class Da{static fromJson(e,t){t&&T.forEach(t,(s,i)=>Da.setProperty(e,i,s))}static toJson(e){if(!e)return null;const t=new Map;t.set("notehead",e.noteHead),t.set("noteheadcenteronstem",e.noteHeadCenterOnStem);{const s=new Map;t.set("colors",s);for(const[i,r]of e.colors)s.set(i.toString(),Fe.toJson(r))}return t}static setProperty(e,t,s){switch(t){case"notehead":return e.noteHead=T.parseEnum(s,u),!0;case"noteheadcenteronstem":return e.noteHeadCenterOnStem=s,!0;case"colors":return e.colors=new Map,T.forEach(s,(i,r)=>{e.colors.set(T.parseEnum(r,$t),Fe.fromJson(i))}),!0}return!1}}class La{static fromJson(e,t){t&&T.forEach(t,(s,i)=>La.setProperty(e,i,s))}static toJson(e){if(!e)return null;const t=new Map;return t.set("id",e.id),t.set("accentuated",e.accentuated),t.set("bendtype",e.bendType),t.set("bendstyle",e.bendStyle),t.set("iscontinuedbend",e.isContinuedBend),e.bendPoints!==null&&t.set("bendpoints",e.bendPoints?.map(s=>_r.toJson(s))),t.set("fret",e.fret),t.set("string",e.string),t.set("showstringnumber",e.showStringNumber),t.set("octave",e.octave),t.set("tone",e.tone),t.set("percussionarticulation",e.percussionArticulation),t.set("isvisible",e.isVisible),t.set("islefthandtapped",e.isLeftHandTapped),t.set("ishammerpullorigin",e.isHammerPullOrigin),t.set("isslurdestination",e.isSlurDestination),t.set("harmonictype",e.harmonicType),t.set("harmonicvalue",e.harmonicValue),t.set("isghost",e.isGhost),t.set("isletring",e.isLetRing),t.set("ispalmmute",e.isPalmMute),t.set("isdead",e.isDead),t.set("isstaccato",e.isStaccato),t.set("slideintype",e.slideInType),t.set("slideouttype",e.slideOutType),t.set("vibrato",e.vibrato),t.set("istiedestination",e.isTieDestination),t.set("lefthandfinger",e.leftHandFinger),t.set("righthandfinger",e.rightHandFinger),t.set("trillvalue",e.trillValue),t.set("trillspeed",e.trillSpeed),t.set("durationpercent",e.durationPercent),t.set("accidentalmode",e.accidentalMode),t.set("dynamics",e.dynamics),t.set("ornament",e.ornament),e.style&&t.set("style",Da.toJson(e.style)),e.toJson(t),t}static setProperty(e,t,s){switch(t){case"id":return e.id=s,!0;case"accentuated":return e.accentuated=T.parseEnum(s,ct),!0;case"bendtype":return e.bendType=T.parseEnum(s,$),!0;case"bendstyle":return e.bendStyle=T.parseEnum(s,Ke),!0;case"iscontinuedbend":return e.isContinuedBend=s,!0;case"bendpoints":if(s){e.bendPoints=[];for(const i of s){const r=new G;_r.fromJson(r,i),e.addBendPoint(r)}}return!0;case"fret":return e.fret=s,!0;case"string":return e.string=s,!0;case"showstringnumber":return e.showStringNumber=s,!0;case"octave":return e.octave=s,!0;case"tone":return e.tone=s,!0;case"percussionarticulation":return e.percussionArticulation=s,!0;case"isvisible":return e.isVisible=s,!0;case"islefthandtapped":return e.isLeftHandTapped=s,!0;case"ishammerpullorigin":return e.isHammerPullOrigin=s,!0;case"isslurdestination":return e.isSlurDestination=s,!0;case"harmonictype":return e.harmonicType=T.parseEnum(s,te),!0;case"harmonicvalue":return e.harmonicValue=s,!0;case"isghost":return e.isGhost=s,!0;case"isletring":return e.isLetRing=s,!0;case"ispalmmute":return e.isPalmMute=s,!0;case"isdead":return e.isDead=s,!0;case"isstaccato":return e.isStaccato=s,!0;case"slideintype":return e.slideInType=T.parseEnum(s,St),!0;case"slideouttype":return e.slideOutType=T.parseEnum(s,he),!0;case"vibrato":return e.vibrato=T.parseEnum(s,Be),!0;case"istiedestination":return e.isTieDestination=s,!0;case"lefthandfinger":return e.leftHandFinger=T.parseEnum(s,ie),!0;case"righthandfinger":return e.rightHandFinger=T.parseEnum(s,ie),!0;case"trillvalue":return e.trillValue=s,!0;case"trillspeed":return e.trillSpeed=T.parseEnum(s,y),!0;case"durationpercent":return e.durationPercent=s,!0;case"accidentalmode":return e.accidentalMode=T.parseEnum(s,oe),!0;case"dynamics":return e.dynamics=T.parseEnum(s,se),!0;case"ornament":return e.ornament=T.parseEnum(s,ot),!0;case"style":return s?(e.style=new Kn,Da.fromJson(e.style,s)):e.style=void 0,!0}return e.setProperty(t,s)}}class Fa{static fromJson(e,t){t&&T.forEach(t,(s,i)=>Fa.setProperty(e,i,s))}static toJson(e){if(!e)return null;const t=new Map;return t.set("marks",e.marks),t.set("style",e.style),t}static setProperty(e,t,s){switch(t){case"marks":return e.marks=s,!0;case"style":return e.style=T.parseEnum(s,wi),!0}return!1}}class Ma{static fromJson(e,t){t&&T.forEach(t,(s,i)=>Ma.setProperty(e,i,s))}static toJson(e){if(!e)return null;const t=new Map;{const s=new Map;t.set("colors",s);for(const[i,r]of e.colors)s.set(i.toString(),Fe.toJson(r))}return t}static setProperty(e,t,s){return t==="colors"?(e.colors=new Map,T.forEach(s,(i,r)=>{e.colors.set(T.parseEnum(r,rt),Fe.fromJson(i))}),!0):!1}}class Aa{static fromJson(e,t){t&&T.forEach(t,(s,i)=>Aa.setProperty(e,i,s))}static toJson(e){if(!e)return null;const t=new Map;return t.set("id",e.id),t.set("notes",e.notes.map(s=>La.toJson(s))),t.set("isempty",e.isEmpty),t.set("whammystyle",e.whammyStyle),t.set("ottava",e.ottava),t.set("islegatoorigin",e.isLegatoOrigin),t.set("duration",e.duration),t.set("automations",e.automations.map(s=>Li.toJson(s))),t.set("dots",e.dots),t.set("fade",e.fade),t.set("lyrics",e.lyrics),t.set("pop",e.pop),t.set("slap",e.slap),t.set("tap",e.tap),t.set("text",e.text),t.set("slashed",e.slashed),t.set("deadslapped",e.deadSlapped),t.set("brushtype",e.brushType),t.set("brushduration",e.brushDuration),t.set("tupletdenominator",e.tupletDenominator),t.set("tupletnumerator",e.tupletNumerator),t.set("iscontinuedwhammy",e.isContinuedWhammy),t.set("whammybartype",e.whammyBarType),e.whammyBarPoints!==null&&t.set("whammybarpoints",e.whammyBarPoints?.map(s=>_r.toJson(s))),t.set("vibrato",e.vibrato),t.set("chordid",e.chordId),t.set("gracetype",e.graceType),t.set("pickstroke",e.pickStroke),e.tremoloPicking&&t.set("tremolopicking",Fa.toJson(e.tremoloPicking)),t.set("crescendo",e.crescendo),t.set("displaystart",e.displayStart),t.set("playbackstart",e.playbackStart),t.set("displayduration",e.displayDuration),t.set("playbackduration",e.playbackDuration),t.set("overridedisplayduration",e.overrideDisplayDuration),t.set("golpe",e.golpe),t.set("dynamics",e.dynamics),t.set("invertbeamdirection",e.invertBeamDirection),t.set("preferredbeamdirection",e.preferredBeamDirection),t.set("beamingmode",e.beamingMode),t.set("wahpedal",e.wahPedal),t.set("barrefret",e.barreFret),t.set("barreshape",e.barreShape),t.set("rasgueado",e.rasgueado),t.set("showtimer",e.showTimer),t.set("timer",e.timer),e.style&&t.set("style",Ma.toJson(e.style)),t}static setProperty(e,t,s){switch(t){case"id":return e.id=s,!0;case"notes":e.notes=[];for(const i of s){const r=new kt;La.fromJson(r,i),e.addNote(r)}return!0;case"isempty":return e.isEmpty=s,!0;case"whammystyle":return e.whammyStyle=T.parseEnum(s,Ke),!0;case"ottava":return e.ottava=T.parseEnum(s,le),!0;case"islegatoorigin":return e.isLegatoOrigin=s,!0;case"duration":return e.duration=T.parseEnum(s,y),!0;case"automations":e.automations=[];for(const i of s){const r=new tt;Li.fromJson(r,i),e.automations.push(r)}return!0;case"dots":return e.dots=s,!0;case"fade":return e.fade=T.parseEnum(s,yt),!0;case"lyrics":return e.lyrics=s,!0;case"pop":return e.pop=s,!0;case"slap":return e.slap=s,!0;case"tap":return e.tap=s,!0;case"text":return e.text=s,!0;case"slashed":return e.slashed=s,!0;case"deadslapped":return e.deadSlapped=s,!0;case"brushtype":return e.brushType=T.parseEnum(s,z),!0;case"brushduration":return e.brushDuration=s,!0;case"tupletdenominator":return e.tupletDenominator=s,!0;case"tupletnumerator":return e.tupletNumerator=s,!0;case"iscontinuedwhammy":return e.isContinuedWhammy=s,!0;case"whammybartype":return e.whammyBarType=T.parseEnum(s,Pe),!0;case"whammybarpoints":if(s){e.whammyBarPoints=[];for(const i of s){const r=new G;_r.fromJson(r,i),e.addWhammyBarPoint(r)}}return!0;case"vibrato":return e.vibrato=T.parseEnum(s,Be),!0;case"chordid":return e.chordId=s,!0;case"gracetype":return e.graceType=T.parseEnum(s,K),!0;case"pickstroke":return e.pickStroke=T.parseEnum(s,Ct),!0;case"tremolopicking":return s?(e.tremoloPicking=new Ts,Fa.fromJson(e.tremoloPicking,s)):e.tremoloPicking=void 0,!0;case"crescendo":return e.crescendo=T.parseEnum(s,Gt),!0;case"displaystart":return e.displayStart=s,!0;case"playbackstart":return e.playbackStart=s,!0;case"displayduration":return e.displayDuration=s,!0;case"playbackduration":return e.playbackDuration=s,!0;case"overridedisplayduration":return e.overrideDisplayDuration=s,!0;case"golpe":return e.golpe=T.parseEnum(s,Xt),!0;case"dynamics":return e.dynamics=T.parseEnum(s,se),!0;case"invertbeamdirection":return e.invertBeamDirection=s,!0;case"preferredbeamdirection":return e.preferredBeamDirection=T.parseEnum(s,P)??null,!0;case"beamingmode":return e.beamingMode=T.parseEnum(s,st),!0;case"wahpedal":return e.wahPedal=T.parseEnum(s,ss),!0;case"barrefret":return e.barreFret=s,!0;case"barreshape":return e.barreShape=T.parseEnum(s,xs),!0;case"rasgueado":return e.rasgueado=T.parseEnum(s,ne),!0;case"showtimer":return e.showTimer=s,!0;case"timer":return e.timer=s,!0;case"style":return s?(e.style=new zl,Ma.fromJson(e.style,s)):e.style=void 0,!0}return!1}}class Ia{static fromJson(e,t){t&&T.forEach(t,(s,i)=>Ia.setProperty(e,i,s))}static toJson(e){if(!e)return null;const t=new Map;{const s=new Map;t.set("colors",s);for(const[i,r]of e.colors)s.set(i.toString(),Fe.toJson(r))}return t}static setProperty(e,t,s){return t==="colors"?(e.colors=new Map,T.forEach(s,(i,r)=>{e.colors.set(T.parseEnum(r,yr),Fe.fromJson(i))}),!0):!1}}class Ra{static fromJson(e,t){t&&T.forEach(t,(s,i)=>Ra.setProperty(e,i,s))}static toJson(e){if(!e)return null;const t=new Map;return t.set("id",e.id),t.set("beats",e.beats.map(s=>Aa.toJson(s))),e.style&&t.set("style",Ia.toJson(e.style)),t}static setProperty(e,t,s){switch(t){case"id":return e.id=s,!0;case"beats":e.beats=[];for(const i of s){const r=new Dt;Aa.fromJson(r,i),e.addBeat(r)}return!0;case"style":return s?(e.style=new Gl,Ia.fromJson(e.style,s)):e.style=void 0,!0}return!1}}class Oa{static fromJson(e,t){t&&T.forEach(t,(s,i)=>Oa.setProperty(e,i,s))}static toJson(e){if(!e)return null;const t=new Map;return t.set("ratioposition",e.ratioPosition),t.set("pedaltype",e.pedalType),t}static setProperty(e,t,s){switch(t){case"ratioposition":return e.ratioPosition=s,!0;case"pedaltype":return e.pedalType=T.parseEnum(s,it),!0}return!1}}class Wa{static fromJson(e,t){t&&T.forEach(t,(s,i)=>Wa.setProperty(e,i,s))}static toJson(e){if(!e)return null;const t=new Map;{const s=new Map;t.set("colors",s);for(const[i,r]of e.colors)s.set(i.toString(),Fe.toJson(r))}return t}static setProperty(e,t,s){return t==="colors"?(e.colors=new Map,T.forEach(s,(i,r)=>{e.colors.set(T.parseEnum(r,Le),Fe.fromJson(i))}),!0):!1}}class Va{static fromJson(e,t){t&&T.forEach(t,(s,i)=>Va.setProperty(e,i,s))}static toJson(e){if(!e)return null;const t=new Map;return t.set("id",e.id),t.set("clef",e.clef),t.set("clefottava",e.clefOttava),t.set("voices",e.voices.map(s=>Ra.toJson(s))),t.set("similemark",e.simileMark),t.set("displayscale",e.displayScale),t.set("displaywidth",e.displayWidth),t.set("sustainpedals",e.sustainPedals.map(s=>Oa.toJson(s))),t.set("barlineleft",e.barLineLeft),t.set("barlineright",e.barLineRight),t.set("keysignature",e.keySignature),t.set("keysignaturetype",e.keySignatureType),t.set("barnumberdisplay",e.barNumberDisplay),e.style&&t.set("style",Wa.toJson(e.style)),t}static setProperty(e,t,s){switch(t){case"id":return e.id=s,!0;case"clef":return e.clef=T.parseEnum(s,ve),!0;case"clefottava":return e.clefOttava=T.parseEnum(s,le),!0;case"voices":e.voices=[];for(const i of s){const r=new ks;Ra.fromJson(r,i),e.addVoice(r)}return!0;case"similemark":return e.simileMark=T.parseEnum(s,xt),!0;case"displayscale":return e.displayScale=s,!0;case"displaywidth":return e.displayWidth=s,!0;case"sustainpedals":e.sustainPedals=[];for(const i of s){const r=new _i;Oa.fromJson(r,i),e.sustainPedals.push(r)}return!0;case"barlineleft":return e.barLineLeft=T.parseEnum(s,ye),!0;case"barlineright":return e.barLineRight=T.parseEnum(s,ye),!0;case"keysignature":return e.keySignature=T.parseEnum(s,qe),!0;case"keysignaturetype":return e.keySignatureType=T.parseEnum(s,as),!0;case"barnumberdisplay":return e.barNumberDisplay=T.parseEnum(s,vt),!0;case"style":return s?(e.style=new Vl,Wa.fromJson(e.style,s)):e.style=void 0,!0}return!1}}class Ha{static fromJson(e,t){t&&T.forEach(t,(s,i)=>Ha.setProperty(e,i,s))}static toJson(e){if(!e)return null;const t=new Map;return t.set("name",e.name),t.set("firstfret",e.firstFret),t.set("strings",e.strings),t.set("barrefrets",e.barreFrets),t.set("showname",e.showName),t.set("showdiagram",e.showDiagram),t.set("showfingering",e.showFingering),t}static setProperty(e,t,s){switch(t){case"name":return e.name=s,!0;case"firstfret":return e.firstFret=s,!0;case"strings":return e.strings=s,!0;case"barrefrets":return e.barreFrets=s,!0;case"showname":return e.showName=s,!0;case"showdiagram":return e.showDiagram=s,!0;case"showfingering":return e.showFingering=s,!0}return!1}}class Ga{static fromJson(e,t){t&&T.forEach(t,(s,i)=>Ga.setProperty(e,i,s))}static toJson(e){if(!e)return null;const t=new Map;return t.set("isstandard",e.isStandard),t.set("name",e.name),t.set("tunings",e.tunings),t}static setProperty(e,t,s){switch(t){case"isstandard":return e.isStandard=s,!0;case"name":return e.name=s,!0;case"tunings":return e.tunings=s,!0}return!1}}class Ua{static fromJson(e,t){t&&T.forEach(t,(s,i)=>Ua.setProperty(e,i,s))}static toJson(e){if(!e)return null;const t=new Map;if(t.set("bars",e.bars.map(s=>Va.toJson(s))),e.chords!==null){const s=new Map;t.set("chords",s);for(const[i,r]of e.chords)s.set(i.toString(),Ha.toJson(r))}return t.set("capo",e.capo),t.set("transpositionpitch",e.transpositionPitch),t.set("displaytranspositionpitch",e.displayTranspositionPitch),t.set("stringtuning",Ga.toJson(e.stringTuning)),t.set("showslash",e.showSlash),t.set("shownumbered",e.showNumbered),t.set("showtablature",e.showTablature),t.set("showstandardnotation",e.showStandardNotation),t.set("ispercussion",e.isPercussion),t.set("standardnotationlinecount",e.standardNotationLineCount),t}static setProperty(e,t,s){switch(t){case"bars":e.bars=[];for(const i of s){const r=new ns;Va.fromJson(r,i),e.addBar(r)}return!0;case"chords":return e.chords=new Map,T.forEach(s,(i,r)=>{const n=new Bi;Ha.fromJson(n,i),e.addChord(r,n)}),!0;case"capo":return e.capo=s,!0;case"transpositionpitch":return e.transpositionPitch=s,!0;case"displaytranspositionpitch":return e.displayTranspositionPitch=s,!0;case"stringtuning":return Ga.fromJson(e.stringTuning,s),!0;case"showslash":return e.showSlash=s,!0;case"shownumbered":return e.showNumbered=s,!0;case"showtablature":return e.showTablature=s,!0;case"showstandardnotation":return e.showStandardNotation=s,!0;case"ispercussion":return e.isPercussion=s,!0;case"standardnotationlinecount":return e.standardNotationLineCount=s,!0}return!1}}class za{static fromJson(e,t){t&&T.forEach(t,(s,i)=>za.setProperty(e,i,s))}static toJson(e){if(!e)return null;const t=new Map;return t.set("volume",e.volume),t.set("balance",e.balance),t.set("port",e.port),t.set("program",e.program),t.set("bank",e.bank),t.set("primarychannel",e.primaryChannel),t.set("secondarychannel",e.secondaryChannel),t.set("ismute",e.isMute),t.set("issolo",e.isSolo),t}static setProperty(e,t,s){switch(t){case"volume":return e.volume=s,!0;case"balance":return e.balance=s,!0;case"port":return e.port=s,!0;case"program":return e.program=s,!0;case"bank":return e.bank=s,!0;case"primarychannel":return e.primaryChannel=s,!0;case"secondarychannel":return e.secondaryChannel=s,!0;case"ismute":return e.isMute=s,!0;case"issolo":return e.isSolo=s,!0}return!1}}class Ya{static fromJson(e,t){t&&T.forEach(t,(s,i)=>Ya.setProperty(e,i,s))}static toJson(e){if(!e)return null;const t=new Map;return t.set("id",e.id),t.set("elementtype",e.elementType),t.set("staffline",e.staffLine),t.set("noteheaddefault",e.noteHeadDefault),t.set("noteheadhalf",e.noteHeadHalf),t.set("noteheadwhole",e.noteHeadWhole),t.set("techniquesymbol",e.techniqueSymbol),t.set("techniquesymbolplacement",e.techniqueSymbolPlacement),t.set("outputmidinumber",e.outputMidiNumber),t}static setProperty(e,t,s){switch(t){case"id":return e.id=s,!0;case"elementtype":return e.elementType=s,!0;case"staffline":return e.staffLine=s,!0;case"noteheaddefault":return e.noteHeadDefault=T.parseEnum(s,u),!0;case"noteheadhalf":return e.noteHeadHalf=T.parseEnum(s,u),!0;case"noteheadwhole":return e.noteHeadWhole=T.parseEnum(s,u),!0;case"techniquesymbol":return e.techniqueSymbol=T.parseEnum(s,u),!0;case"techniquesymbolplacement":return e.techniqueSymbolPlacement=T.parseEnum(s,$e),!0;case"outputmidinumber":return e.outputMidiNumber=s,!0}return!1}}class Xa{static fromJson(e,t){t&&T.forEach(t,(s,i)=>Xa.setProperty(e,i,s))}static toJson(e){if(!e)return null;const t=new Map;{const s=new Map;t.set("colors",s);for(const[i,r]of e.colors)s.set(i.toString(),Fe.toJson(r))}return t}static setProperty(e,t,s){return t==="colors"?(e.colors=new Map,T.forEach(s,(i,r)=>{e.colors.set(T.parseEnum(r,$s),Fe.fromJson(i))}),!0):!1}}class $a{static fromJson(e,t){t&&T.forEach(t,(s,i)=>$a.setProperty(e,i,s))}static toJson(e){if(!e)return null;const t=new Map;if(t.set("staves",e.staves.map(s=>Ua.toJson(s))),t.set("playbackinfo",za.toJson(e.playbackInfo)),t.set("color",Fe.toJson(e.color)),t.set("name",e.name),t.set("isvisibleonmultitrack",e.isVisibleOnMultiTrack),t.set("shortname",e.shortName),t.set("defaultsystemslayout",e.defaultSystemsLayout),t.set("systemslayout",e.systemsLayout),e.lineBreaks!==void 0){const s=[];t.set("linebreaks",s);for(const i of e.lineBreaks)s.push(i)}return t.set("percussionarticulations",e.percussionArticulations.map(s=>Ya.toJson(s))),e.style&&t.set("style",Xa.toJson(e.style)),t}static setProperty(e,t,s){switch(t){case"staves":e.staves=[];for(const i of s){const r=new Oi;Ua.fromJson(r,i),e.addStaff(r)}return!0;case"playbackinfo":return za.fromJson(e.playbackInfo,s),!0;case"color":return e.color=Fe.fromJson(s),!0;case"name":return e.name=s,!0;case"isvisibleonmultitrack":return e.isVisibleOnMultiTrack=s,!0;case"shortname":return e.shortName=s,!0;case"defaultsystemslayout":return e.defaultSystemsLayout=s,!0;case"systemslayout":return e.systemsLayout=s,!0;case"linebreaks":for(const i of s)e.addLineBreaks(i);return!0;case"percussionarticulations":e.percussionArticulations=[];for(const i of s){const r=new X;Ya.fromJson(r,i),e.percussionArticulations.push(r)}return!0;case"style":return s?(e.style=new $l,Xa.fromJson(e.style,s)):e.style=void 0,!0}return!1}}class Ja{static fromJson(e,t){t&&T.forEach(t,(s,i)=>Ja.setProperty(e,i,s))}static toJson(e){if(!e)return null;const t=new Map;if(t.set("hidedynamics",e.hideDynamics),t.set("bracketextendmode",e.bracketExtendMode),t.set("usesystemsignseparator",e.useSystemSignSeparator),t.set("globaldisplaytuning",e.globalDisplayTuning),e.perTrackDisplayTuning!==null){const s=new Map;t.set("pertrackdisplaytuning",s);for(const[i,r]of e.perTrackDisplayTuning)s.set(i.toString(),r)}if(t.set("globaldisplaychorddiagramsontop",e.globalDisplayChordDiagramsOnTop),e.perTrackChordDiagramsOnTop!==null){const s=new Map;t.set("pertrackchorddiagramsontop",s);for(const[i,r]of e.perTrackChordDiagramsOnTop)s.set(i.toString(),r)}if(t.set("globaldisplaychorddiagramsinscore",e.globalDisplayChordDiagramsInScore),t.set("singletracktracknamepolicy",e.singleTrackTrackNamePolicy),t.set("multitracktracknamepolicy",e.multiTrackTrackNamePolicy),t.set("firstsystemtracknamemode",e.firstSystemTrackNameMode),t.set("othersystemstracknamemode",e.otherSystemsTrackNameMode),t.set("firstsystemtracknameorientation",e.firstSystemTrackNameOrientation),t.set("othersystemstracknameorientation",e.otherSystemsTrackNameOrientation),t.set("multitrackmultibarrest",e.multiTrackMultiBarRest),e.perTrackMultiBarRest!==null){const s=[];t.set("pertrackmultibarrest",s);for(const i of e.perTrackMultiBarRest)s.push(i)}return t.set("extendbarlines",e.extendBarLines),t.set("hideemptystaves",e.hideEmptyStaves),t.set("hideemptystavesinfirstsystem",e.hideEmptyStavesInFirstSystem),t.set("showsinglestaffbrackets",e.showSingleStaffBrackets),t.set("barnumberdisplay",e.barNumberDisplay),t}static setProperty(e,t,s){switch(t){case"hidedynamics":return e.hideDynamics=s,!0;case"bracketextendmode":return e.bracketExtendMode=T.parseEnum(s,Fi),!0;case"usesystemsignseparator":return e.useSystemSignSeparator=s,!0;case"globaldisplaytuning":return e.globalDisplayTuning=s,!0;case"pertrackdisplaytuning":return e.perTrackDisplayTuning=new Map,T.forEach(s,(i,r)=>{e.perTrackDisplayTuning.set(Number.parseInt(r),i)}),!0;case"globaldisplaychorddiagramsontop":return e.globalDisplayChordDiagramsOnTop=s,!0;case"pertrackchorddiagramsontop":return e.perTrackChordDiagramsOnTop=new Map,T.forEach(s,(i,r)=>{e.perTrackChordDiagramsOnTop.set(Number.parseInt(r),i)}),!0;case"globaldisplaychorddiagramsinscore":return e.globalDisplayChordDiagramsInScore=s,!0;case"singletracktracknamepolicy":return e.singleTrackTrackNamePolicy=T.parseEnum(s,mt),!0;case"multitracktracknamepolicy":return e.multiTrackTrackNamePolicy=T.parseEnum(s,mt),!0;case"firstsystemtracknamemode":return e.firstSystemTrackNameMode=T.parseEnum(s,Qt),!0;case"othersystemstracknamemode":return e.otherSystemsTrackNameMode=T.parseEnum(s,Qt),!0;case"firstsystemtracknameorientation":return e.firstSystemTrackNameOrientation=T.parseEnum(s,Kt),!0;case"othersystemstracknameorientation":return e.otherSystemsTrackNameOrientation=T.parseEnum(s,Kt),!0;case"multitrackmultibarrest":return e.multiTrackMultiBarRest=s,!0;case"pertrackmultibarrest":return e.perTrackMultiBarRest=new Set(s),!0;case"extendbarlines":return e.extendBarLines=s,!0;case"hideemptystaves":return e.hideEmptyStaves=s,!0;case"hideemptystavesinfirstsystem":return e.hideEmptyStavesInFirstSystem=s,!0;case"showsinglestaffbrackets":return e.showSingleStaffBrackets=s,!0;case"barnumberdisplay":return e.barNumberDisplay=T.parseEnum(s,vt),!0}return!1}}class qa{static fromJson(e,t){t&&T.forEach(t,(s,i)=>qa.setProperty(e,i,s))}static toJson(e){return e?new Map:null}static setProperty(e,t,s){return!1}}class Qa{static fromJson(e,t){t&&T.forEach(t,(s,i)=>Qa.setProperty(e,i,s))}static toJson(e){if(!e)return null;const t=new Map;return t.set("template",e.template),t.set("isvisible",e.isVisible),t.set("textalign",e.textAlign),t}static setProperty(e,t,s){switch(t){case"template":return e.template=s,!0;case"isvisible":return e.isVisible=s,!0;case"textalign":return e.textAlign=T.parseEnum(s,Y),!0}return!1}}class Ka{static fromJson(e,t){t&&T.forEach(t,(s,i)=>Ka.setProperty(e,i,s))}static toJson(e){if(!e)return null;const t=new Map;{const s=new Map;t.set("headerandfooter",s);for(const[i,r]of e.headerAndFooter)s.set(i.toString(),Qa.toJson(r))}{const s=new Map;t.set("colors",s);for(const[i,r]of e.colors)s.set(i.toString(),Fe.toJson(r))}return t}static setProperty(e,t,s){switch(t){case"headerandfooter":return e.headerAndFooter=new Map,T.forEach(s,(i,r)=>{const n=new hs;Qa.fromJson(n,i),e.headerAndFooter.set(T.parseEnum(r,H),n)}),!0;case"colors":return e.colors=new Map,T.forEach(s,(i,r)=>{e.colors.set(T.parseEnum(r,H),Fe.fromJson(i))}),!0}return!1}}class Za{static fromJson(e,t){t&&T.forEach(t,(s,i)=>Za.setProperty(e,i,s))}static toJson(e){if(!e)return null;const t=new Map;return t.set("album",e.album),t.set("artist",e.artist),t.set("copyright",e.copyright),t.set("instructions",e.instructions),t.set("music",e.music),t.set("notices",e.notices),t.set("subtitle",e.subTitle),t.set("title",e.title),t.set("words",e.words),t.set("tab",e.tab),t.set("masterbars",e.masterBars.map(s=>va.toJson(s))),t.set("tracks",e.tracks.map(s=>$a.toJson(s))),t.set("defaultsystemslayout",e.defaultSystemsLayout),t.set("systemslayout",e.systemsLayout),t.set("stylesheet",Ja.toJson(e.stylesheet)),e.backingTrack&&t.set("backingtrack",qa.toJson(e.backingTrack)),e.style&&t.set("style",Ka.toJson(e.style)),t}static setProperty(e,t,s){switch(t){case"album":return e.album=s,!0;case"artist":return e.artist=s,!0;case"copyright":return e.copyright=s,!0;case"instructions":return e.instructions=s,!0;case"music":return e.music=s,!0;case"notices":return e.notices=s,!0;case"subtitle":return e.subTitle=s,!0;case"title":return e.title=s,!0;case"words":return e.words=s,!0;case"tab":return e.tab=s,!0;case"masterbars":e.masterBars=[];for(const i of s){const r=new Qs;va.fromJson(r,i),e.addMasterBar(r)}return!0;case"tracks":e.tracks=[];for(const i of s){const r=new Zs;$a.fromJson(r,i),e.addTrack(r)}return!0;case"defaultsystemslayout":return e.defaultSystemsLayout=s,!0;case"systemslayout":return e.systemsLayout=s,!0;case"stylesheet":return Ja.fromJson(e.stylesheet,s),!0;case"backingtrack":return s?(e.backingTrack=new io,qa.fromJson(e.backingTrack,s)):e.backingTrack=void 0,!0;case"style":return s?(e.style=new Mi,Ka.fromJson(e.style,s)):e.style=void 0,!0}return!1}}class Ar{static fromJson(e,t){t&&T.forEach(t,(s,i)=>Ar.setProperty(e,i.toLowerCase(),s))}static toJson(e){if(!e)return null;const t=new Map;if(t.set("scriptfile",e.scriptFile),t.set("fontdirectory",e.fontDirectory),e.smuflFontSources!==null){const s=new Map;t.set("smuflfontsources",s);for(const[i,r]of e.smuflFontSources)s.set(i.toString(),r)}return t.set("file",e.file),t.set("tex",e.tex),t.set("tracks",e.tracks),t.set("enablelazyloading",e.enableLazyLoading),t.set("engine",e.engine),t.set("loglevel",e.logLevel),t.set("useworkers",e.useWorkers),t.set("includenotebounds",e.includeNoteBounds),t}static setProperty(e,t,s){switch(t){case"scriptfile":return e.scriptFile=s,!0;case"fontdirectory":return e.fontDirectory=s,!0;case"smuflfontsources":return e.smuflFontSources=new Map,T.forEach(s,(i,r)=>{e.smuflFontSources.set(T.parseEnum(r,Is),i)}),!0;case"file":return e.file=s,!0;case"tex":return e.tex=s,!0;case"tracks":return e.tracks=s,!0;case"enablelazyloading":return e.enableLazyLoading=s,!0;case"engine":return e.engine=s,!0;case"loglevel":return e.logLevel=T.parseEnum(s,Hs),!0;case"useworkers":return e.useWorkers=s,!0;case"includenotebounds":return e.includeNoteBounds=s,!0}return!1}}class cr{static fromJson(e,t){t&&T.forEach(t,(s,i)=>cr.setProperty(e,i.toLowerCase(),s))}static toJson(e){if(!e)return null;const t=new Map;return t.set("topy",e.topY),t.set("bottomy",e.bottomY),t.set("x",e.x),t}static setProperty(e,t,s){switch(t){case"topy":return e.topY=s,!0;case"bottomy":return e.bottomY=s,!0;case"x":return e.x=s,!0}return!1}}class yc{static clone(e){const t=new We;return t.musicFontSize=e.musicFontSize,t.oneStaffSpace=e.oneStaffSpace,t.tabLineSpacing=e.tabLineSpacing,t.arrowShaftThickness=e.arrowShaftThickness,t.barlineSeparation=e.barlineSeparation,t.beamSpacing=e.beamSpacing,t.beamThickness=e.beamThickness,t.bracketThickness=e.bracketThickness,t.dashedBarlineDashLength=e.dashedBarlineDashLength,t.dashedBarlineGapLength=e.dashedBarlineGapLength,t.dashedBarlineThickness=e.dashedBarlineThickness,t.hairpinThickness=e.hairpinThickness,t.legerLineThickness=e.legerLineThickness,t.legerLineExtension=e.legerLineExtension,t.octaveLineThickness=e.octaveLineThickness,t.pedalLineThickness=e.pedalLineThickness,t.repeatBarlineDotSeparation=e.repeatBarlineDotSeparation,t.repeatEndingLineThickness=e.repeatEndingLineThickness,t.slurMidpointThickness=e.slurMidpointThickness,t.staffLineThickness=e.staffLineThickness,t.stemThickness=e.stemThickness,t.thickBarlineThickness=e.thickBarlineThickness,t.thinBarlineThickness=e.thinBarlineThickness,t.thinThickBarlineSeparation=e.thinThickBarlineSeparation,t.tieMidpointThickness=e.tieMidpointThickness,t.tupletBracketThickness=e.tupletBracketThickness,t.stemUp=new Map(e.stemUp),t.stemDown=new Map(e.stemDown),t.repeatOffsetX=new Map(e.repeatOffsetX),t.standardStemLength=e.standardStemLength,t.stemFlagOffsets=new Map(e.stemFlagOffsets),t.glyphTop=new Map(e.glyphTop),t.glyphBottom=new Map(e.glyphBottom),t.glyphWidths=new Map(e.glyphWidths),t.glyphHeights=new Map(e.glyphHeights),t.numberedBarRendererBarSize=e.numberedBarRendererBarSize,t.numberedBarRendererBarSpacing=e.numberedBarRendererBarSpacing,t.numberedDashGlyphPadding=e.numberedDashGlyphPadding,t.numberedDashGlyphWidth=e.numberedDashGlyphWidth,t.lineRangedGlyphDashGap=e.lineRangedGlyphDashGap,t.lineRangedGlyphDashSize=e.lineRangedGlyphDashSize,t.preNoteEffectPadding=e.preNoteEffectPadding,t.postNoteEffectPadding=e.postNoteEffectPadding,t.onNoteEffectPadding=e.onNoteEffectPadding,t.stringNumberCirclePadding=e.stringNumberCirclePadding,t.rowContainerPadding=e.rowContainerPadding,t.rowContainerGap=e.rowContainerGap,t.alternateEndingsPadding=e.alternateEndingsPadding,t.sustainPedalLinePadding=e.sustainPedalLinePadding,t.tieHeight=e.tieHeight,t.beatTimerPadding=e.beatTimerPadding,t.bendNoteHeadElementPadding=e.bendNoteHeadElementPadding,t.ghostParenthesisWidth=e.ghostParenthesisWidth,t.ghostParenthesisPadding=e.ghostParenthesisPadding,t.brokenBeamWidth=e.brokenBeamWidth,t.tabWhammyTextPadding=e.tabWhammyTextPadding,t.tabWhammyPerHalfHeight=e.tabWhammyPerHalfHeight,t.tabWhammyDashSize=e.tabWhammyDashSize,t.songBookWhammyDipHeight=e.songBookWhammyDipHeight,t.deadSlappedLineWidth=e.deadSlappedLineWidth,t.leftHandTabTieWidth=e.leftHandTabTieWidth,t.tabBendDashSize=e.tabBendDashSize,t.tabBendStaffPadding=e.tabBendStaffPadding,t.tabBendPerValueHeight=e.tabBendPerValueHeight,t.tabBendLabelPadding=e.tabBendLabelPadding,t.simpleSlideWidth=e.simpleSlideWidth,t.simpleSlideHeight=e.simpleSlideHeight,t.chordDiagramPaddingX=e.chordDiagramPaddingX,t.chordDiagramPaddingY=e.chordDiagramPaddingY,t.chordDiagramStringSpacing=e.chordDiagramStringSpacing,t.chordDiagramFretSpacing=e.chordDiagramFretSpacing,t.chordDiagramNutHeight=e.chordDiagramNutHeight,t.chordDiagramFretHeight=e.chordDiagramFretHeight,t.chordDiagramLineWidth=e.chordDiagramLineWidth,t.tripletFeelBracketPadding=e.tripletFeelBracketPadding,t.accidentalPadding=e.accidentalPadding,t.preBeatGlyphSpacing=e.preBeatGlyphSpacing,t.tempoNoteScale=e.tempoNoteScale,t.tuningGlyphCircleNumberScale=e.tuningGlyphCircleNumberScale,t.tuningGlyphStringColumnScale=e.tuningGlyphStringColumnScale,t.tuningGlyphStringRowPadding=e.tuningGlyphStringRowPadding,t.directionsScale=e.directionsScale,t.multiVoiceDisplacedNoteHeadSpacing=e.multiVoiceDisplacedNoteHeadSpacing,t.stemFlagHeight=new Map(e.stemFlagHeight),t}}class ja{topY=0;bottomY=0;x=0}class We{static _bravuraDefaults;static GraceScale=.75;static get bravuraDefaults(){let e=We._bravuraDefaults;return e||(e=new We,e.fillFromSmufl(We.bravuraMetadata),We._bravuraDefaults=e),yc.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(e){return this.glyphWidths.get(e)>0&&this.glyphHeights.get(e)>0}fillFromSmufl(e,t=36){this.musicFontSize=t,this.oneStaffSpace=t/4,this.tabLineSpacing=Math.floor(this.oneStaffSpace*1.5),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,typeof e.engravingDefaults.thinThickBarlineSeparation=="number"?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 s=3*this.oneStaffSpace;this.standardStemLength=s,this.stemFlagOffsets.set(y.QuadrupleWhole,0),this.stemFlagOffsets.set(y.DoubleWhole,0),this.stemFlagOffsets.set(y.Whole,0),this.stemFlagOffsets.set(y.Half,0),this.stemFlagOffsets.set(y.Quarter,0),this.stemFlagOffsets.set(y.Eighth,0),this.stemFlagOffsets.set(y.Sixteenth,0),this.stemFlagOffsets.set(y.ThirtySecond,0),this.stemFlagOffsets.set(y.SixtyFourth,0),this.stemFlagOffsets.set(y.OneHundredTwentyEighth,0),this.stemFlagOffsets.set(y.TwoHundredFiftySixth,0),this.stemFlagHeight.set(y.QuadrupleWhole,0),this.stemFlagHeight.set(y.DoubleWhole,0),this.stemFlagHeight.set(y.Whole,0),this.stemFlagHeight.set(y.Half,0),this.stemFlagHeight.set(y.Quarter,0),this.stemFlagHeight.set(y.Eighth,1*this.oneStaffSpace),this.stemFlagHeight.set(y.Sixteenth,1.5*this.oneStaffSpace),this.stemFlagHeight.set(y.ThirtySecond,2*this.oneStaffSpace),this.stemFlagHeight.set(y.SixtyFourth,3*this.oneStaffSpace),this.stemFlagHeight.set(y.OneHundredTwentyEighth,3.5*this.oneStaffSpace),this.stemFlagHeight.set(y.TwoHundredFiftySixth,4.2*this.oneStaffSpace);for(const[o,l]of Object.entries(e.glyphsWithAnchors)){const h=We._smuflNameToMusicFontSymbol(o);if(h){if(l.stemDownNW){const c=new ja;c.x=l.stemDownNW[0]*this.oneStaffSpace,c.topY=l.stemDownNW[1]*this.oneStaffSpace,l.stemDownSW?c.bottomY=l.stemDownSW[1]*this.oneStaffSpace:c.bottomY=0,this.stemDown.set(h,c)}if(l.stemUpSE){const c=new ja,d=l.stemUpSE[0]*this.oneStaffSpace;c.bottomY=l.stemUpSE[1]*this.oneStaffSpace,l.stemUpNW?(c.x=l.stemUpNW[0]*this.oneStaffSpace,c.topY=l.stemUpNW[1]*this.oneStaffSpace):(c.x=d-this.stemThickness,c.topY=0),this.stemUp.set(h,c)}if(l.repeatOffset&&this.repeatOffsetX.set(h,l.repeatOffset[0]*this.oneStaffSpace),l.stemUpNW){const c=l.stemUpNW[1]*this.oneStaffSpace;switch(h){case u.Flag8thUp:this.stemFlagOffsets.set(y.Eighth,c);break;case u.Flag16thUp:this.stemFlagOffsets.set(y.Sixteenth,c);break;case u.Flag32ndUp:this.stemFlagOffsets.set(y.ThirtySecond,c);break;case u.Flag64thUp:this.stemFlagOffsets.set(y.SixtyFourth,c);break;case u.Flag128thUp:this.stemFlagOffsets.set(y.OneHundredTwentyEighth,c);break;case u.Flag256thUp:this.stemFlagOffsets.set(y.TwoHundredFiftySixth,c);break}}}}const i=new Set,r=e.glyphBBoxes;if(r)for(const[o,l]of Object.entries(r)){const h=We._smuflNameToMusicFontSymbol(o);h&&(i.add(h),this.glyphTop.set(h,l.bBoxNE[1]*this.oneStaffSpace),this.glyphBottom.set(h,l.bBoxSW[1]*this.oneStaffSpace),this.glyphWidths.set(h,(l.bBoxNE[0]-l.bBoxSW[0])*this.oneStaffSpace),this.glyphHeights.set(h,(l.bBoxNE[1]-l.bBoxSW[1])*this.oneStaffSpace))}const n=new Set([u.None,u.Space,u.NoteheadNull]);for(const o of ii.getAllMusicFontSymbols())i.has(o)||(n.has(o)||E.warning("SmuFL",`The provided SmuFL font is missing the glyph ${u[o]} needed by alphaTab, the music notation might not show all details`),this.glyphTop.set(o,0),this.glyphBottom.set(o,0),this.glyphWidths.set(o,0),this.glyphHeights.set(o,0));this.numberedBarRendererBarSize=this.staffLineThickness*2,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.multiVoiceDis
10placedNoteHeadSpacing=.2*this.oneStaffSpace,this.tuningGlyphStringRowPadding=.2*this.oneStaffSpace}static smuflNameToGlyphNameMapping=new Map([["4stringTabClef","FourStringTabClef"],["6stringTabClef","SixStringTabClef"]]);static _smuflNameToMusicFontSymbol(e){const t=We.smuflNameToGlyphNameMapping.has(e)?We.smuflNameToGlyphNameMapping.get(e):e.substring(0,1).toUpperCase()+e.substring(1);return T.parseEnumExact(t,u)}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;
10multiVoiceDisplacedNoteHeadSpacing=0;getStemLength(e,t){return this.standardStemLength+(t?this.stemFlagOffsets.get(e
vendor: 23,101 bytes, line 10
10):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]}}}}class 
vendor: 2,477 bytes, line 10
10en{static fromJson(e,t){t&&T.forEach(t,(s,i)=>en.setProperty(e,i.toLowerCase(),s))}static toJson(e){if(!e)return null;const t=new Map;t.set("musicfontsize",e.musicFontSize),t.set("onestaffspace",e.oneStaffSpace),t.set("tablinespacing",e.tabLineSpacing),t.set("arrowshaftthickness",e.arrowShaftThickness),t.set("barlineseparation",e.barlineSeparation),t.set("beamspacing",e.beamSpacing),t.set("beamthickness",e.beamThickness),t.set("bracketthickness",e.bracketThickness),t.set("dashedbarlinedashlength",e.dashedBarlineDashLength),t.set("dashedbarlinegaplength",e.dashedBarlineGapLength),t.set("dashedbarlinethickness",e.dashedBarlineThickness),t.set("hairpinthickness",e.hairpinThickness),t.set("legerlinethickness",e.legerLineThickness),t.set("legerlineextension",e.legerLineExtension),t.set("octavelinethickness",e.octaveLineThickness),t.set("pedallinethickness",e.pedalLineThickness),t.set("repeatbarlinedotseparation",e.repeatBarlineDotSeparation),t.set("repeatendinglinethickness",e.repeatEndingLineThickness),t.set("slurmidpointthickness",e.slurMidpointThickness),t.set("stafflinethickness",e.staffLineThickness),t.set("stemthickness",e.stemThickness),t.set("thickbarlinethickness",e.thickBarlineThickness),t.set("thinbarlinethickness",e.thinBarlineThickness),t.set("thinthickbarlineseparation",e.thinThickBarlineSeparation),t.set("tiemidpointthickness",e.tieMidpointThickness),t.set("tupletbracketthickness",e.tupletBracketThickness);{const s=new Map;t.set("stemup",s);for(const[i,r]of e.stemUp)s.set(i.toString(),cr.toJson(r))}{const s=new Map;t.set("stemdown",s);for(const[i,r]of e.stemDown)s.set(i.toString(),cr.toJson(r))}{const s=new Map;t.set("repeatoffsetx",s);for(const[i,r]of e.repeatOffsetX)s.set(i.toString(),r)}t.set("standardstemlength",e.standardStemLength);{const s=new Map;t.set("stemflagoffsets",s);for(const[i,r]of e.stemFlagOffsets)s.set(i.toString(),r)}{const s=new Map;t.set("glyphtop",s);for(const[i,r]of e.glyphTop)s.set(i.toString(),r)}{const s=new Map;t.set("glyphbottom",s);for(const[i,r]of e.glyphBottom)s.set(i.toString(),r)}{const s=new Map;t.set("glyphwidths",s);for(const[i,r]of e.glyphWidths)s.set(i.toString(),r)}{const s=new Map;t.set("glyphheights",s);for(const[i,r]of e.glyphHeights)s.set(i.toString(),r)}t.set("numberedbarrendererbarsize",e.numberedBarRendererBarSize),t.set("numberedbarrendererbarspacing",e.numberedBarRendererBarSpacing),t.set("numbereddashglyphpadding",e.numberedDashGlyphPadding),t.set("numbereddashglyphwidth",e.
10numberedDashGlyphWidth),t.set("linerangedglyphdashgap",e.lineRangedGlyphDashGap),t.set("linerangedglyphdashsize",e.lineRangedGlyphDashSize),t.set("prenoteeffectpadding",e.preNoteEffectPadding),t.set("postnoteeffectpadding",e.postNoteEffectPadding),t.set("onnoteeffectpadding",e.onNoteEffectPadding),t.set("stringnumbercirclepadding",e.stringNumberCirclePadding),t.set("rowcontainerpadding",e.rowContainerPadding),t.set("rowcontainergap",e.rowContainerGap),t.set("alternateendingspadding",e.alternateEndingsPadding),t.set("sustainpedallinepadding",e.sustainPedalLinePadding),t.set("tieheight",e.tieHeight),t.set("beattimerpadding",e.beatTimerPadding),t.set("bendnoteheadelementpadding",e.bendNoteHeadElementPadding),t.set("ghostparenthesiswidth",e.ghostParenthesisWidth),t.set("ghostparenthesispadding",e.ghostParenthesisPadding),t.set("brokenbeamwidth",e.brokenBeamWidth),t.set("tabwhammytextpadding",e.tabWhammyTextPadding),t.set("tabwhammyperhalfheight",e.tabWhammyPerHalfHeight),t.set("tabwhammydashsize",e.tabWhammyDashSize),t.set("songbookwhammydipheight",e.songBookWhammyDipHeight),t.set("deadslappedlinewidth",e.deadSlappedLineWidth),t.set("lefthandtabtiewidth",e.leftHandTabTieWidth),t.set("tabbenddashsize",e.tabBendDashSize),t.set("tabbendstaffpadding",e.tabBendStaffPadding),t.set("tabbendpervalueheight",e.tabBendPerValueHeight),t.set("tabbendlabelpadding",e.tabBendLabelPadding),t.set("simpleslidewidth",e.simpleSlideWidth),t.set("simpleslideheight",e.simpleSlideHeight),t.set("chorddiagrampaddingx",e.chordDiagramPaddingX),t.set("chorddiagrampaddingy",e.chordDiagramPaddingY),t.set("chorddiagramstringspacing",e.chordDiagramStringSpacing),t.set("chorddiagramfretspacing",e.chordDiagramFretSpacing),t.set("chorddiagramnutheight",e.chordDiagramNutHeight),t.set("chorddiagramfretheight",e.chordDiagramFretHeight),t.set("chorddiagramlinewidth",e.chordDiagramLineWidth),t.set("tripletfeelbracketpadding",e.tripletFeelBracketPadding),t.set("accidentalpadding",e.accidentalPadding),t.set("prebeatglyphspacing",e.preBeatGlyphSpacing),t.set("temponotescale",e.tempoNoteScale),t.set("tuningglyphcirclenumberscale",e.tuningGlyphCircleNumberScale),t.set("tuningglyphstringcolumnscale",e.tuningGlyphStringColumnScale),t.set("tuningglyphstringrowpadding",e.tuningGlyphStringRowPadding),t.set("directionsscale",e.directionsScale),t.set("multivoicedisplacednoteheadspacing",e.multiVoiceDis
vendor: 4,231 bytes, line 10
10placedNoteHeadSpacing);{const s=new Map;t.set("stemflagheight",s);for(const[i,r]of e.stemFlagHeight)s.set(i.toString(),r)}return t}static setProperty(e,t,s){switch(t){case"musicfontsize":return e.musicFontSize=s,!0;case"onestaffspace":return e.oneStaffSpace=s,!0;case"tablinespacing":return e.tabLineSpacing=s,!0;case"arrowshaftthickness":return e.arrowShaftThickness=s,!0;case"barlineseparation":return e.barlineSeparation=s,!0;case"beamspacing":return e.beamSpacing=s,!0;case"beamthickness":return e.beamThickness=s,!0;case"bracketthickness":return e.bracketThickness=s,!0;case"dashedbarlinedashlength":return e.dashedBarlineDashLength=s,!0;case"dashedbarlinegaplength":return e.dashedBarlineGapLength=s,!0;case"dashedbarlinethickness":return e.dashedBarlineThickness=s,!0;case"hairpinthickness":return e.hairpinThickness=s,!0;case"legerlinethickness":return e.legerLineThickness=s,!0;case"legerlineextension":return e.legerLineExtension=s,!0;case"octavelinethickness":return e.octaveLineThickness=s,!0;case"pedallinethickness":return e.pedalLineThickness=s,!0;case"repeatbarlinedotseparation":return e.repeatBarlineDotSeparation=s,!0;case"repeatendinglinethickness":return e.repeatEndingLineThickness=s,!0;case"slurmidpointthickness":return e.slurMidpointThickness=s,!0;case"stafflinethickness":return e.staffLineThickness=s,!0;case"stemthickness":return e.stemThickness=s,!0;case"thickbarlinethickness":return e.thickBarlineThickness=s,!0;case"thinbarlinethickness":return e.thinBarlineThickness=s,!0;case"thinthickbarlineseparation":return e.thinThickBarlineSeparation=s,!0;case"tiemidpointthickness":return e.tieMidpointThickness=s,!0;case"tupletbracketthickness":return e.tupletBracketThickness=s,!0;case"stemup":return e.stemUp=new Map,T.forEach(s,(i,r)=>{const n=new ja;cr.fromJson(n,i),e.stemUp.set(T.parseEnum(r,u),n)}),!0;case"stemdown":return e.stemDown=new Map,T.forEach(s,(i,r)=>{const n=new ja;cr.fromJson(n,i),e.stemDown.set(T.parseEnum(r,u),n)}),!0;case"repeatoffsetx":return e.repeatOffsetX=new Map,T.forEach(s,(i,r)=>{e.repeatOffsetX.set(T.parseEnum(r,u),i)}),!0;case"standardstemlength":return e.standardStemLength=s,!0;case"stemflagoffsets":return e.stemFlagOffsets=new Map,T.forEach(s,(i,r)=>{e.stemFlagOffsets.set(T.parseEnum(r,y),i)}),!0;case"glyphtop":return e.glyphTop=new Map,T.forEach(s,(i,r)=>{e.glyphTop.set(T.parseEnum(r,u),i)}),!0;case"glyphbottom":return e.glyphBottom=new Map,T.forEach(s,(i,r)=>{e.glyphBottom.set(T.parseEnum(r,u),i)}),!0;case"glyphwidths":return e.glyphWidths=new Map,T.forEach(s,(i,r)=>{e.glyphWidths.set(T.parseEnum(r,u),i)}),!0;case"glyphheights":return e.glyphHeights=new Map,T.forEach(s,(i,r)=>{e.glyphHeights.set(T.parseEnum(r,u),i)}),!0;case"numberedbarrendererbarsize":return e.numberedBarRendererBarSize=s,!0;case"numberedbarrendererbarspacing":return e.numberedBarRendererBarSpacing=s,!0;case"numbereddashglyphpadding":return e.numberedDashGlyphPadding=s,!0;case"numbereddashglyphwidth":return e.numberedDashGlyphWidth=s,!0;case"linerangedglyphdashgap":return e.lineRangedGlyphDashGap=s,!0;case"linerangedglyphdashsize":return e.lineRangedGlyphDashSize=s,!0;case"prenoteeffectpadding":return e.preNoteEffectPadding=s,!0;case"postnoteeffectpadding":return e.postNoteEffectPadding=s,!0;case"onnoteeffectpadding":return e.onNoteEffectPadding=s,!0;case"stringnumbercirclepadding":return e.stringNumberCirclePadding=s,!0;case"rowcontainerpadding":return e.rowContainerPadding=s,!0;case"rowcontainergap":return e.rowContainerGap=s,!0;case"alternateendingspadding":return e.alternateEndingsPadding=s,!0;case"sustainpedallinepadding":return e.sustainPedalLinePadding=s,!0;case"tieheight":return e.tieHeight=s,!0;case"beattimerpadding":return e.beatTimerPadding=s,!0;case"bendnoteheadelementpadding":return e.bendNoteHeadElementPadding=s,!0;case"ghostparenthesiswidth":return e.ghostParenthesisWidth=s,!0;case"ghostparenthesispadding":return e.ghostParenthesisPadding=s,!0;case"brokenbeamwidth":return e.brokenBeamWidth=s,!0;case"tabwhammytextpadding":return e.tabWhammyTextPadding=s,!0;case"tabwhammyperhalfheight":return e.tabWhammyPerHalfHeight=s,!0;case"tabwhammydashsize":return e.tabWhammyDashSize=s,!0;case"songbookwhammydipheight":return e.songBookWhammyDipHeight=s,!0;
10case"deadslappedlinewidth":return e.deadSlappedLineWidth=s,!0;case"lefthandtabtiewidth":return e.leftHandTabTieWidth=s,!0;case"tabbenddashsize":return e.tabBendDashSize=s,!0;case"tabbendstaffpadding":return e.tabBendStaffPadding=s,!0;case"tabbendpervalueheight":return e.tabBendPerValueHeight=s,!0;case"tabbendlabelpadding":return e.tabBendLabelPadding=s,!0;case"simpleslidewidth":return e.simpleSlideWidth=s,!0;case"simpleslideheight":return e.simpleSlideHeight=s,!0;case"chorddiagrampaddingx":return e.chordDiagramPaddingX=s,!0;case"chorddiagrampaddingy":return e.chordDiagramPaddingY=s,!0;case"chorddiagramstringspacing":return e.chordDiagramStringSpacing=s,!0;case"chorddiagramfretspacing":return e.chordDiagramFretSpacing=s,!0;case"chorddiagramnutheight":return e.chordDiagramNutHeight=s,!0;case"chorddiagramfretheight":return e.chordDiagramFretHeight=s,!0;case"chorddiagramlinewidth":return e.chordDiagramLineWidth=s,!0;case"tripletfeelbracketpadding":return e.tripletFeelBracketPadding=s,!0;case"accidentalpadding":return e.accidentalPadding=s,!0;case"prebeatglyphspacing":return e.preBeatGlyphSpacing=s,!0;case"temponotescale":return e.tempoNoteScale=s,!0;case"tuningglyphcirclenumberscale":return e.tuningGlyphCircleNumberScale=s,!0;case"tuningglyphstringcolumnscale":return e.tuningGlyphStringColumnScale=s,!0;case"tuningglyphstringrowpadding":return e.tuningGlyphStringRowPadding=s,!0;case"directionsscale":return e.directionsScale=s,!0;
10case"multivoicedisplacednoteheadspacing":return e.multiVoiceDisplacedNoteHeadSpacing=s,!0;case"stemflagheight":return e.stemFlagHeight=new Map,T.forEach(s,(i,r)=>{e.stemFlagHeight.set(T.parseEnum(r,y),i)}),!0}return!1}}class bc{startPos;endPos;text;constructor(e,t,s){this.text=e,this.startPos=t,this.endPos=s}}class dr{style="normal";variant="normal";weight="normal";stretch="normal";lineHeight="normal";size="1rem";families=[];parseOnlyFamilies=!1;_tokens;_currentTokenIndex=-1;_input="";_currentToken=null;constructor(e){this._input=e,this._tokens=this._splitToTokens(e)}_splitToTokens(e){const t=[];let s=0;for(;s<e.length;){let i=s;for(;i<e.length&&e.charAt(i)!==" ";)i++;i>s&&t.push(new bc(e.substring(s,i),s,i)),s=i+1}return t}parse(){if(this._reset(),this._tokens.length===1)switch(this._currentToken?.text){case"caption":case"icon":case"menu":case"message-box":case"small-caption":case"status-bar":case"inherit":return}this.parseOnlyFamilies||(this._fontStyleVariantWeight(),this._fontSizeLineHeight()),this._fontFamily()}static parseFamilies(e){const t=new dr(e);return t.parseOnlyFamilies=!0,t.parse(),t.families}
10_fontFamily(){if(!this._currentToken){if(this.parseOnlyFamilies)return;throw new Error("Missing font list")}const e=this._input.substr(this._currentToken.startPos).trim();let t=0;for(;t<e.length;){const s=e.charAt(t);if(s===" "||s===",")t++;else if(s==='"'||s==="'"){const i=this._findEndOfQuote(e,t+1,s);this.families.push(e.substring(t+1,i).split(`\\${s}`).join(s)),t=i+1}else{const i=this._findEndOfQuote(e,t+1,",");this.families.push(e.substring(t,i).trim()),t=i+1}}}_findEndOfQuote(e,t,s){let i=!1;for(;t<e.length;){const r=e.charAt(t);if(!i&&r===s)return t;!i&&r==="\\"?i=!0:i=!1,t+=1}return e.length}_fontSizeLineHeight(){if(!this._currentToken)throw new Error("Missing font size");const e=this._currentToken.text.split("/");if(e.length>=3)throw new Error(`Invalid font size '${this._currentToken}' specified`);if(this._nextToken(),e.length>=2)if(e[1]==="/"){if(!this._currentToken)throw new Error("Missing line-height after font size");this.lineHeight=this._currentToken.text,this._nextToken()}else this.size=e[0],this.lineHeight=e[1];else if(e.length>=1){if(this.size=e[0],this._currentToken&&this._currentToken.text.indexOf("/")===0)if(this._currentToken.text==="/"){if(this._nextToken(),!this._currentToken)throw new Error("Missing line-height after font size");this.lineHeight=this._currentToken.text,this._nextToken()}else this.lineHeight=this._currentToken.text.substr(1),this._nextToken()}else throw new Error("Missing font size")}_nextToken(){this._currentTokenIndex++,this._currentTokenIndex<this._tokens.length?this._currentToken=this._tokens[this._currentTokenIndex]:this._currentToken=null}_fontStyleVariantWeight(){let e=!1,t=!1,s=!1,i=3;const r=[];for(;;){if(!this._currentToken)return;const n=this._currentToken.text;switch(n){case"normal":case"inherit":r.push(n),i--,this._nextToken();break;case"italic":case"oblique":this.style=n,e=!0,i--,this._nextToken();break;case"small-caps":this.variant=n,t=!0,i--,this._nextToken();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=n,s=!0,i--,this._nextToken();break;default:return}if(i===0)break}for(;r.length>0;){const n=r.pop();s?t?e||(this.style=n):this.variant=n:this.weight=n}}_reset(){this._currentTokenIndex=-1,this._nextToken()}static quoteFont(e){return e.indexOf(" ")===-1?e:`"${e.replaceAll('"','\\"')}"`}}var je;(function(a){a[a.Plain=0]="Plain",a[a.Italic=1]="Italic"})(je||(je={}));var rs;(function(a){a[a.Regular=0]="Regular",a[a.Bold=1]="Bold"})(rs||(rs={}));class ze{_css;_cssScale=0;_families;_style;_weight;_size;_reset(){this._cssScale=0,this._css=this.toCssString()}get family(){return this._families[0]}set family(e){this.families=dr.parseFamilies(e)}get families(){return this._families}set families(e){this._families=e,this._reset()}get size(){return this._size}set size(e){this._size=e,this._reset()}get style(){return this._style}set style(e){this._style=e,this._reset()}get weight(){return this._weight}set weight(e){this._weight=e,this._reset()}get isBold(){return this.weight===rs.Bold}get isItalic(){return this.style===je.Italic}constructor(e,t,s=je.Plain,i=rs.Regular){this._families=dr.parseFamilies(e),this._size=t,this._style=s,this._weight=i,this._css=this.toCssString()}withSize(e){return ze.withFamilyList(this._families,e,this._style,this._weight)}static withFamilyList(e,t,s=je.Plain,i=rs.Regular){const r=new ze("",t,s,i);return r.families=e,r}toCssString(e=1){if(!this._css||!(Math.abs(e-this._cssScale)<.01)){let t="";this.isBold&&(t+="bold "),this.isItalic&&(t+="italic "),t+=this.size*e,t+="px ",t+=this.families.map(s=>dr.quoteFont(s)).join(", "),this._css=t,this._cssScale=e}return this._css}static fromJson(e){if(e instanceof ze)return e;switch(typeof e){case"undefined":return;case"object":{const t=e,s=t.get("families"),i=t.get("size"),r=T.parseEnum(t.get("style"),je),n=T.parseEnum(t.get("weight"),rs);return ze.withFamilyList(s,i,r,n)}case"string":{const t=new dr(e);t.parse();const s=t.families,i=t.size.toLowerCase();let r=0;switch(i){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{i.endsWith("em")?r=Number.parseFloat(i.substr(0,i.length-2))*16:i.endsWith("pt")?r=Number.parseFloat(i.substr(0,i.length-2))*16/12:i.endsWith("px")?r=Number.parseFloat(i.substr(0,i.length-2)):r=12}catch{r=12}break}let n=je.Plain;t.style==="italic"&&(n=je.Italic);let o=rs.Regular;switch(t.weight.toLowerCase()){case"normal":case"lighter":break;default:o=rs.Bold;break}return ze.withFamilyList(s,r,n,o)}default:return}}static toJson(e){if(!e)return;const t=new Map;return t.set("families",e.families),t.set("size",e.size),t.set("style",e.style),t.set("weight",e.weight),t}}class Ir{static fromJson(e,t){t&&T.forEach(t,(s,i)=>Ir.setProperty(e,i.toLowerCase(),s))}static toJson(e){if(!e)return null;const t=new Map;t.set("smuflfontfamilyname",e.smuflFontFamilyName),t.set("engravingsettings",en.toJson(e.engravingSettings));{const s=new Map;t.set("elementfonts",s);for(const[i,r]of e.elementFonts)s.set(i.toString(),ze.toJson(r))}return t.set("numberednotationfont",ze.toJson(e.numberedNotationFont)),t.set("numberednotationgracefont",ze.toJson(e.numberedNotationGraceFont)),t.set("tablaturefont",ze.toJson(e.tablatureFont)),t.set("gracefont",ze.toJson(e.graceFont)),t.set("stafflinecolor",Fe.toJson(e.staffLineColor)),t.set("barseparatorcolor",Fe.toJson(e.barSeparatorColor)),t.set("barnumbercolor",Fe.toJson(e.barNumberColor)),t.set("mainglyphcolor",Fe.toJson(e.mainGlyphColor)),t.set("secondaryglyphcolor",Fe.toJson(e.secondaryGlyphColor)),t.set("scoreinfocolor",Fe.toJson(e.scoreInfoColor)),t}static setProperty(e,t,s){switch(t){case"smuflfontfamilyname":return e.smuflFontFamilyName=s,!0;case"elementfonts":return T.forEach(s,(i,r)=>{e.elementFonts.set(T.parseEnum(r,C),ze.fromJson(i))}),!0;case"numberednotationfont":return e.numberedNotationFont=ze.fromJson(s),!0;case"numberednotationgracefont":return e.numberedNotationGraceFont=ze.fromJson(s),!0;case"tablaturefont":return e.tablatureFont=ze.fromJson(s),!0;case"gracefont":return e.graceFont=ze.fromJson(s),!0;case"stafflinecolor":return e.staffLineColor=Fe.fromJson(s),!0;case"barseparatorcolor":return e.barSeparatorColor=Fe.fromJson(s),!0;case"barnumbercolor":return e.barNumberColor=Fe.fromJson(s),!0;case"mainglyphcolor":return e.mainGlyphColor=Fe.fromJson(s),!0;case"secondaryglyphcolor":return e.secondaryGlyphColor=Fe.fromJson(s),!0;case"scoreinfocolor":return e.scoreInfoColor=Fe.fromJson(s),!0}return["engravingsettings"].indexOf(t)>=0?(en.fromJson(e.engravingSettings,s),!0):!1}}var yi;(function(a){a[a.Default=0]="Default",a[a.ScoreTab=1]="ScoreTab",a[a.Score=2]="Score",a[a.Tab=3]="Tab",a[a.TabMixed=4]="TabMixed"})(yi||(yi={}));class Ue{static _sansFont="Arial, sans-serif";static _serifFont="Georgia, serif";static _effectFont=new ze(Ue._serifFont,12,je.Italic);static defaultFonts=new Map([[C.ScoreTitle,new ze(Ue._serifFont,32,je.Plain)],[C.ScoreSubTitle,new ze(Ue._serifFont,20,je.Plain)],[C.ScoreArtist,new ze(Ue._serifFont,20,je.Plain)],[C.ScoreAlbum,new ze(Ue._serifFont,20,je.Plain)],[C.ScoreWords,new ze(Ue._serifFont,15,je.Plain)],[C.ScoreMusic,new ze(Ue._serifFont,15,je.Plain)],[C.ScoreWordsAndMusic,new ze(Ue._serifFont,15,je.Plain)],[C.ScoreCopyright,
vendor: 10,404 bytes, line 10
10new ze(Ue._sansFont,12,je.Plain,rs.Bold)],[C.EffectBeatTimer,new ze(Ue._serifFont,12,je.Plain)],[C.EffectDirections,new ze(Ue._serifFont,14,je.Plain)],[C.ChordDiagramFretboardNumbers,new ze(Ue._sansFont,11,je.Plain)],[C.EffectFingering,new ze(Ue._serifFont,14,je.Plain)],[C.EffectMarker,new ze(Ue._serifFont,14,je.Plain,rs.Bold)],[C.EffectCapo,Ue._effectFont],[C.EffectFreeTime,Ue._effectFont],[C.EffectLyrics,Ue._effectFont],[C.EffectTap,Ue._effectFont],[C.ChordDiagrams,Ue._effectFont],[C.EffectChordNames,Ue._effectFont],[C.EffectText,Ue._effectFont],[C.EffectPalmMute,Ue._effectFont],[C.EffectLetRing,Ue._effectFont],[C.EffectBeatBarre,Ue._effectFont],[C.EffectTripletFeel,Ue._effectFont],[C.EffectHarmonics,Ue._effectFont],[C.EffectPickSlide,Ue._effectFont],[C.GuitarTuning,Ue._effectFont],[C.EffectRasgueado,Ue._effectFont],[C.EffectWhammyBar,Ue._effectFont],[C.TrackNames,Ue._effectFont],[C.RepeatCount,new ze(Ue._sansFont,11,je.Plain)],[C.BarNumber,new ze(Ue._sansFont,11,je.Plain)],[C.ScoreBendSlur,new ze(Ue._sansFont,11,je.Plain)],[C.EffectAlternateEndings,new ze(Ue._serifFont,15,je.Plain)]]);smuflFontFamilyName;engravingSettings=We.bravuraDefaults;get copyrightFont(){return this.elementFonts.get(C.ScoreCopyright)}set copyrightFont(e){this.elementFonts.set(C.ScoreCopyright,e)}get titleFont(){return this.elementFonts.get(C.ScoreTitle)}set titleFont(e){this.elementFonts.set(C.ScoreTitle,e)}get subTitleFont(){return this.elementFonts.get(C.ScoreSubTitle)}set subTitleFont(e){this.elementFonts.set(C.ScoreSubTitle,e)}get wordsFont(){return this.elementFonts.get(C.ScoreWords)}set wordsFont(e){this.elementFonts.set(C.ScoreWords,e)}get timerFont(){return this.elementFonts.get(C.EffectBeatTimer)}set timerFont(e){this.elementFonts.set(C.EffectBeatTimer,e)}get directionsFont(){return this.elementFonts.get(C.EffectDirections)}set directionsFont(e){this.elementFonts.set(C.EffectDirections,e)}get fretboardNumberFont(){return this.elementFonts.get(C.ChordDiagramFretboardNumbers)}set fretboardNumberFont(e){this.elementFonts.set(C.ChordDiagramFretboardNumbers,e)}fingeringFont=Ue._effectFont;inlineFingeringFont=Ue._effectFont;get markerFont(){return this.elementFonts.get(C.EffectMarker)}set markerFont(e){this.elementFonts.set(C.EffectMarker,e)}effectFont=Ue._effectFont;get barNumberFont(){return this.elementFonts.get(C.BarNumber)}set barNumberFont(e){this.elementFonts.set(C.BarNumber,e)}elementFonts=new Map;numberedNotationFont=new ze(Ue._sansFont,16,je.Plain);numberedNotationGraceFont=new ze(Ue._sansFont,14,je.Plain);tablatureFont=new ze(Ue._sansFont,14,je.Plain);graceFont=new ze(Ue._sansFont,12,je.Plain);staffLineColor=new Fe(165,165,165,255);barSeparatorColor=new Fe(34,34,17,255);barNumberColor=new Fe(200,0,0,255);mainGlyphColor=new Fe(0,0,0,255);secondaryGlyphColor=new Fe(0,0,0,100);scoreInfoColor=new Fe(0,0,0,255);constructor(){for(const[e,t]of Ue.defaultFonts)this.elementFonts.set(e,t.withSize(t.size))}getFontForElement(e){let t=C.ScoreWords;switch(e){case H.Title:t=C.ScoreTitle;break;case H.SubTitle:t=C.ScoreSubTitle;break;case H.Artist:t=C.ScoreArtist;break;case H.Album:t=C.ScoreAlbum;break;case H.Words:t=C.ScoreWords;break;case H.Music:t=C.ScoreMusic;break;case H.WordsAndMusic:t=C.ScoreWordsAndMusic;break;case H.Copyright:case H.CopyrightSecondLine:t=C.ScoreCopyright;break;default:t=C.ScoreWords;break}return this.elementFonts.has(t)?this.elementFonts.get(t):Ue.defaultFonts.get(C.ScoreWords)}}var Sr;(function(a){a[a.Automatic=0]="Automatic",a[a.UseModelLayout=1]="UseModelLayout"})(Sr||(Sr={}));class _c{scale=1;stretchForce=1;layoutMode=ni.Page;staveProfile=yi.Default;barsPerRow=-1;startBar=1;barCount=-1;barCountPerPartial=10;justifyLastSystem=!1;resources=new Ue;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=Sr.Automatic}class Rr{static fromJson(e,t){t&&T.forEach(t,(s,i)=>Rr.setProperty(e,i.toLowerCase(),s))}static toJson(e){if(!e)return null;const t=new Map;return t.set("scale",e.scale),t.set("stretchforce",e.stretchForce),t.set("layoutmode",e.layoutMode),t.set("staveprofile",e.staveProfile),t.set("barsperrow",e.barsPerRow),t.set("startbar",e.startBar),t.set("barcount",e.barCount),t.set("barcountperpartial",e.barCountPerPartial),t.set("justifylastsystem",e.justifyLastSystem),t.set("resources",Ir.toJson(e.resources)),t.set("padding",e.padding),t.set("firstsystempaddingtop",e.firstSystemPaddingTop),t.set("systempaddingtop",e.systemPaddingTop),t.set("systempaddingbottom",e.systemPaddingBottom),t.set("lastsystempaddingbottom",e.lastSystemPaddingBottom),t.set("systemlabelpaddingleft",e.systemLabelPaddingLeft),t.set("systemlabelpaddingright",e.systemLabelPaddingRight),t.set("accoladebarpaddingright",e.accoladeBarPaddingRight),t.set("firstnotationstaffpaddingtop",e.firstNotationStaffPaddingTop),t.set("lastnotationstaffpaddingbottom",e.lastNotationStaffPaddingBottom),t.set("notationstaffpaddingtop",e.notationStaffPaddingTop),t.set("notationstaffpaddingbottom",e.notationStaffPaddingBottom),t.set("effectstaffpaddingtop",e.effectStaffPaddingTop),t.set("effectstaffpaddingbottom",e.effectStaffPaddingBottom),t.set("firststaffpaddingleft",e.firstStaffPaddingLeft),t.set("staffpaddingleft",e.staffPaddingLeft),t.set("effectbandpaddingbottom",e.effectBandPaddingBottom),t.set("trackstaffpaddingbetween",e.trackStaffPaddingBetween),t.set("lyriclinespaddingbetween",e.lyricLinesPaddingBetween),t.set("systemslayoutmode",e.systemsLayoutMode),t}static setProperty(e,t,s){switch(t){case"scale":return e.scale=s,!0;case"stretchforce":return e.stretchForce=s,!0;case"layoutmode":return e.layoutMode=T.parseEnum(s,ni),!0;case"staveprofile":return e.staveProfile=T.parseEnum(s,yi),!0;case"barsperrow":return e.barsPerRow=s,!0;case"startbar":return e.startBar=s,!0;case"barcount":return e.barCount=s,!0;case"barcountperpartial":return e.barCountPerPartial=s,!0;case"justifylastsystem":return e.justifyLastSystem=s,!0;case"padding":return e.padding=s,!0;case"firstsystempaddingtop":return e.firstSystemPaddingTop=s,!0;case"systempaddingtop":return e.systemPaddingTop=s,!0;case"systempaddingbottom":return e.systemPaddingBottom=s,!0;case"lastsystempaddingbottom":return e.lastSystemPaddingBottom=s,!0;case"systemlabelpaddingleft":return e.systemLabelPaddingLeft=s,!0;case"systemlabelpaddingright":return e.systemLabelPaddingRight=s,!0;case"accoladebarpaddingright":return e.accoladeBarPaddingRight=s,!0;case"firstnotationstaffpaddingtop":return e.firstNotationStaffPaddingTop=s,!0;case"lastnotationstaffpaddingbottom":return e.lastNotationStaffPaddingBottom=s,!0;case"notationstaffpaddingtop":return e.notationStaffPaddingTop=s,!0;case"notationstaffpaddingbottom":return e.notationStaffPaddingBottom=s,!0;case"effectstaffpaddingtop":return e.effectStaffPaddingTop=s,!0;case"effectstaffpaddingbottom":return e.effectStaffPaddingBottom=s,!0;case"firststaffpaddingleft":return e.firstStaffPaddingLeft=s,!0;case"staffpaddingleft":return e.staffPaddingLeft=s,!0;case"effectbandpaddingbottom":return e.effectBandPaddingBottom=s,!0;case"trackstaffpaddingbetween":return e.trackStaffPaddingBetween=s,!0;case"lyriclinespaddingbetween":return e.lyricLinesPaddingBetween=s,!0;case"systemslayoutmode":return e.systemsLayoutMode=T.parseEnum(s,Sr),!0}if(["resources"].indexOf(t)>=0)return Ir.fromJson(e.resources,s),!0;for(const i of["resources"])if(t.indexOf(i)===0&&Ir.setProperty(e.resources,t.substring(i.length),s))return!0;return!1}}class Or{static fromJson(e,t){t&&T.forEach(t,(s,i)=>Or.setProperty(e,i.toLowerCase(),s))}static toJson(e){if(!e)return null;const t=new Map;t.set("notationmode",e.notationMode),t.set("fingeringmode",e.fingeringMode);{const s=new Map;t.set("elements",s);for(const[i,r]of e.elements)s.set(i.toString(),r)}return t.set("rhythmmode",e.rhythmMode),t.set("rhythmheight",e.rhythmHeight),t.set("transpositionpitches",e.transpositionPitches),t.set("displaytranspositionpitches",e.displayTranspositionPitches),t.set("smallgracetabnotes",e.smallGraceTabNotes),t.set("extendbendarrowsontiednotes",e.extendBendArrowsOnTiedNotes),t.set("extendlineeffectstobeatend",e.extendLineEffectsToBeatEnd),t.set("slurheight",e.slurHeight),t}static setProperty(e,t,s){switch(t){case"notationmode":return e.notationMode=T.parseEnum(s,Vt),!0;case"fingeringmode":return e.fingeringMode=T.parseEnum(s,Xs),!0;case"elements":return e.elements=new Map,T.forEach(s,(i,r)=>{e.elements.set(T.parseEnum(r,C),i)}),!0;case"rhythmmode":return e.rhythmMode=T.parseEnum(s,Cs),!0;case"rhythmheight":return e.rhythmHeight=s,!0;case"transpositionpitches":return e.transpositionPitches=s,!0;case"displaytranspositionpitches":return e.displayTranspositionPitches=s,!0;case"smallgracetabnotes":return e.smallGraceTabNotes=s,!0;case"extendbendarrowsontiednotes":return e.extendBendArrowsOnTiedNotes=s,!0;case"extendlineeffectstobeatend":return e.extendLineEffectsToBeatEnd=s,!0;case"slurheight":return e.slurHeight=s,!0}return!1}}class Wr{static fromJson(e,t){t&&T.forEach(t,(s,i)=>Wr.setProperty(e,i.toLowerCase(),s))}static toJson(e){if(!e)return null;const t=new Map;return t.set("encoding",e.encoding),t.set("mergepartgroupsinmusicxml",e.mergePartGroupsInMusicXml),t.set("beattextaslyrics",e.beatTextAsLyrics),t}static setProperty(e,t,s){switch(t){case"encoding":return e.encoding=s,!0;case"mergepartgroupsinmusicxml":return e.mergePartGroupsInMusicXml=s,!0;case"beattextaslyrics":return e.beatTextAsLyrics=s,!0}return!1}}class Vr{static fromJson(e,t){t&&T.forEach(t,(s,i)=>Vr.setProperty(e,i.toLowerCase(),s))}static toJson(e){if(!e)return null;const t=new Map;return t.set("notewidelength",e.noteWideLength),t.set("notewideamplitude",e.noteWideAmplitude),t.set("noteslightlength",e.noteSlightLength),t.set("noteslightamplitude",e.noteSlightAmplitude),t.set("beatwidelength",e.beatWideLength),t.set("beatwideamplitude",e.beatWideAmplitude),t.set("beatslightlength",e.beatSlightLength),t.set("beatslightamplitude",e.beatSlightAmplitude),t}static setProperty(e,t,s){switch(t){case"notewidelength":return e.noteWideLength=s,
10!0;case"notewideamplitude":return e.noteWideAmplitude=s,!0;case"noteslightlength":return e.noteSlightLength=s,!0;case"noteslightamplitude":return e.noteSlightAmplitude=s,!0;case"beatwidelength":return e.beatWideLength=s,!0;case"beatwideamplitude":return e.beatWideAmplitude=s,!0;case"beatslightlength":return e.beatSlightLength=s,!0;case"beatslightamplitude":return e.beatSlightAmplitude=s,!0}return!1}}class Hr{static fromJson(e,t){t&&T.forEach(t,(s,i)=>Hr.setProperty(e,i.toLowerCase(),s))}static toJson(e){if(!e)return null;const t=new Map;return t.set("simpleslidepitchoffset",e.simpleSlidePitchOffset),t.set("simpleslidedurationratio",e.simpleSlideDurationRatio),t.set("shiftslidedurationratio",e.shiftSlideDurationRatio),t}static setProperty(e,t,s){switch(t){case"simpleslidepitchoffset":return e.simpleSlidePitchOffset=s,!0;case"simpleslidedurationratio":return e.simpleSlideDurationRatio=s,!0;case"shiftslidedurationratio":return e.shiftSlideDurationRatio=s,!0}return!1}}var Us;(function(a){a[a.Off=0]="Off",a[a.Continuous=1]="Continuous",a[a.OffScreen=2]="OffScreen",a[a.Smooth=3]="Smooth"})(Us||(Us={}));class Sc{noteWideLength=240;noteWideAmplitude=1;noteSlightLength=360;noteSlightAmplitude=.5;beatWideLength=480;beatWideAmplitude=2;beatSlightLength=480;beatSlightAmplitude=2}class kc{simpleSlidePitchOffset=6;simpleSlideDurationRatio=.25;shiftSlideDurationRatio=.5}var ea;(function(a){a[a.WebAudioAudioWorklets=0]="WebAudioAudioWorklets",a[a.WebAudioScriptProcessor=1]="WebAudioScriptProcessor"})(ea||(ea={}));var ts;(function(a){a[a.Disabled=0]="Disabled",a[a.EnabledAutomatic=1]="EnabledAutomatic",a[a.EnabledSynthesizer=2]="EnabledSynthesizer",a[a.EnabledBackingTrack=3]="EnabledBackingTrack",a[a.EnabledExternalMedia=4]="EnabledExternalMedia"})(ts||(ts={}));class wc{soundFont=null;scrollElement="html,body";outputMode=ea.WebAudioAudioWorklets;enablePlayer=!1;playerMode=ts.Disabled;enableCursor=!0;enableAnimatedBeatCursor=!0;enableElementHighlighting=!0;enableUserInteraction=!0;scrollOffsetX=0;scrollOffsetY=0;scrollMode=Us.Continuous;scrollSpeed=300;nativeBrowserSmoothScroll=!0;songBookBendDuration=75;songBookDipDuration=150;vibrato=new Sc;slide=new kc;playTripletFeel=!0;bufferTimeInMilliseconds=500}class Gr{static fromJson(e,t){t&&T.forEach(t,(s,i)=>Gr.setProperty(e,i.toLowerCase(),s))}static toJson(e){if(!e)return null;const t=new Map;return t.set("soundfont",e.soundFont),t.set("outputmode",e.outputMode),t.set("enableplayer",e.enablePlayer),t.set("playermode",e.playerMode),t.set("enablecursor",e.enableCursor),t.set("enableanimatedbeatcursor",e.enableAnimatedBeatCursor),t.set("enableelementhighlighting",e.enableElementHighlighting),t.set("enableuserinteraction",e.enableUserInteraction),t.set("scrolloffsetx",e.scrollOffsetX),t.set("scrolloffsety",e.scrollOffsetY),t.set("scrollmode",e.scrollMode),t.set("scrollspeed",e.scrollSpeed),t.set("nativebrowsersmoothscroll",e.nativeBrowserSmoothScroll),t.set("songbookbendduration",e.songBookBendDuration),t.set("songbookdipduration",e.songBookDipDuration),t.set("vibrato",Vr.toJson(e.vibrato)),t.set("slide",Hr.toJson(e.slide)),t.set("playtripletfeel",e.playTripletFeel),t.set("buffertimeinmilliseconds",e.bufferTimeInMilliseconds),t}static setProperty(e,t,s){switch(t){case"soundfont":return e.soundFont=s,!0;case"scrollelement":return e.scrollElement=s,!0;case"outputmode":return e.outputMode=T.parseEnum(s,ea),!0;case"enableplayer":return e.enablePlayer=s,!0;case"playermode":return e.playerMode=T.parseEnum(s,ts),!0;case"enablecursor":return e.enableCursor=s,!0;case"enableanimatedbeatcursor":return e.enableAnimatedBeatCursor=s,!0;case"enableelementhighlighting":return e.enableElementHighlighting=s,!0;case"enableuserinteraction":return e.enableUserInteraction=s,!0;case"scrolloffsetx":return e.scrollOffsetX=s,!0;case"scrolloffsety":return e.scrollOffsetY=s,!0;case"scrollmode":return e.scrollMode=T.parseEnum(s,Us),!0;case"scrollspeed":return e.scrollSpeed=s,!0;case"nativebrowsersmoothscroll":return e.nativeBrowserSmoothScroll=s,!0;case"songbookbendduration":return e.songBookBendDuration=s,!0;case"songbookdipduration":return e.songBookDipDuration=s,!0;case"playtripletfeel":return e.playTripletFeel=s,!0;
vendor: 6,249 bytes, line 10
10case"buffertimeinmilliseconds":return e.bufferTimeInMilliseconds=s,!0}if(["vibrato"].indexOf(t)>=0)return Vr.fromJson(e.vibrato,s),!0;for(const i of["vibrato"])if(t.indexOf(i)===0&&Vr.setProperty(e.vibrato,t.substring(i.length),s))return!0;if(["slide"].indexOf(t)>=0)return Hr.fromJson(e.slide,s),!0;for(const i of["slide"])if(t.indexOf(i)===0&&Hr.setProperty(e.slide,t.substring(i.length),s))return!0;return!1}}class Ur{static fromJson(e,t){t&&T.forEach(t,(s,i)=>Ur.setProperty(e,i.toLowerCase(),s))}static toJson(e){if(!e)return null;const t=new Map;return t.set("indent",e.indent),t.set("comments",e.comments),t}static setProperty(e,t,s){switch(t){case"indent":return e.indent=s,!0;case"comments":return e.comments=s,!0}return!1}}class Ii{static fromJson(e,t){t&&T.forEach(t,(s,i)=>Ii.setProperty(e,i.toLowerCase(),s))}static toJson(e){if(!e)return null;const t=new Map;return t.set("core",Ar.toJson(e.core)),t.set("display",Rr.toJson(e.display)),t.set("notation",Or.toJson(e.notation)),t.set("importer",Wr.toJson(e.importer)),t.set("player",Gr.toJson(e.player)),t.set("exporter",Ur.toJson(e.exporter)),t}static setProperty(e,t,s){if(["core",""].indexOf(t)>=0)return Ar.fromJson(e.core,s),!0;for(const i of["core",""])if(t.indexOf(i)===0&&Ar.setProperty(e.core,t.substring(i.length),s))return!0;if(["display",""].indexOf(t)>=0)return Rr.fromJson(e.display,s),!0;for(const i of["display",""])if(t.indexOf(i)===0&&Rr.setProperty(e.display,t.substring(i.length),s))return!0;if(["notation"].indexOf(t)>=0)return Or.fromJson(e.notation,s),!0;for(const i of["notation"])if(t.indexOf(i)===0&&Or.setProperty(e.notation,t.substring(i.length),s))return!0;if(["importer"].indexOf(t)>=0)return Wr.fromJson(e.importer,s),!0;for(const i of["importer"])if(t.indexOf(i)===0&&Wr.setProperty(e.importer,t.substring(i.length),s))return!0;if(["player"].indexOf(t)>=0)return Gr.fromJson(e.player,s),!0;for(const i of["player"])if(t.indexOf(i)===0&&Gr.setProperty(e.player,t.substring(i.length),s))return!0;if(["exporter"].indexOf(t)>=0)return Ur.fromJson(e.exporter,s),!0;for(const i of["exporter"])if(t.indexOf(i)===0&&Ur.setProperty(e.exporter,t.substring(i.length),s))return!0;return!1}}class Bc{encoding="utf-8";mergePartGroupsInMusicXml=!1;beatTextAsLyrics=!1}class Tc{indent=2;comments=!1}class di{core=new bh;display=new _c;notation=new ya;importer=new Bc;player=new wc;exporter=new Tc;setSongBookModeSettings(){this.notation.notationMode=Vt.SongBook,this.notation.smallGraceTabNotes=!1,this.notation.fingeringMode=Xs.SingleNoteEffectBand,this.notation.extendBendArrowsOnTiedNotes=!1,this.notation.elements.set(C.ParenthesisOnTiedBends,!1),this.notation.elements.set(C.TabNotesOnTiedBends,!1),this.notation.elements.set(C.ZerosOnDiveWhammys,!0)}static get songBook(){const e=new di;return e.setSongBookModeSettings(),e}fillFromJson(e){Ii.fromJson(this,e)}handleBackwardsCompatibility(){this.player.playerMode===ts.Disabled&&this.player.enablePlayer&&(this.player.playerMode=ts.EnabledAutomatic)}}class wt{static _jsonReplacer(e,t){if(t instanceof Map){if("fromEntries"in Object)return Object.fromEntries(t);const s={};for(const[i,r]of t)s[i]=r;return s}return ArrayBuffer.isView(t)?Array.apply([],[t]):t}static scoreToJson(e){const t=wt.scoreToJsObject(e);return JSON.stringify(t,wt._jsonReplacer)}static jsonToScore(e,t){return wt.jsObjectToScore(JSON.parse(e),t)}static scoreToJsObject(e){return Za.toJson(e)}static jsObjectToScore(e,t){const s=new Ks;return Za.fromJson(s,e),s.finish(t??new di),s}static settingsToJson(e){const t=wt.settingsToJsObject(e);return JSON.stringify(t,wt._jsonReplacer)}static jsonToSettings(e){return wt.jsObjectToSettings(JSON.parse(e))}static settingsToJsObject(e){return Ii.toJson(e)}static jsObjectToSettings(e){const t=new di;return Ii.fromJson(t,e),t}static jsObjectToMidiFile(e){const t=new oi;return T.forEach(e,(s,i)=>{switch(i){case"tickShift":t.tickShift=s;break;case"division":t.division=s;break;case"tracks":for(const r of s){const n=wt._jsObjectToMidiTrack(r);t.tracks.push(n)}break}}),t}static _jsObjectToMidiTrack(e){const t=new lo;return T.forEach(e,(s,i)=>{switch(i){case"events":for(const r of s){const n=wt.jsObjectToMidiEvent(r);t.events.push(n)}break}}),t}static jsObjectToMidiEvent(e){const t=T.getValue(e,"track"),s=T.getValue(e,"tick"),i=T.getValue(e,"type");switch(i){case Ie.TimeSignature:return new ho(t,s,T.getValue(e,"numerator"),T.getValue(e,"denominatorIndex"),T.getValue(e,"midiClocksPerMetronomeClick"),T.getValue(e,"thirdySecondNodesInQuarter"));case Ie.AlphaTabRest:return new uo(t,s,T.getValue(e,"channel"));case Ie.AlphaTabMetronome:return new co(t,s,T.getValue(e,"metronomeNumerator"),T.getValue(e,"metronomeDurationInTicks"),T.getValue(e,"metronomeDurationInMilliseconds"));case Ie.NoteOn:return new po(t,s,T.getValue(e,"channel"),T.getValue(e,"noteKey"),T.getValue(e,"noteVelocity"));case Ie.NoteOff:return new go(t,s,T.getValue(e,"channel"),T.getValue(e,"noteKey"),T.getValue(e,"noteVelocity"));case Ie.ControlChange:return new mo(t,s,T.getValue(e,"channel"),T.getValue(e,"controller"),T.getValue(e,"value"));case Ie.ProgramChange:return new yo(t,s,T.getValue(e,"channel"),T.getValue(e,"program"));case Ie.TempoChange:const r=new bo(s,0);return r.beatsPerMinute=T.getValue(e,"beatsPerMinute"),r;case Ie.PitchBend:return new _o(t,s,T.getValue(e,"channel"),T.getValue(e,"value"));case Ie.PerNotePitchBend:return new So(t,s,T.getValue(e,"channel"),T.getValue(e,"noteKey"),T.getValue(e,"value"));case Ie.EndOfTrack:return new ko(t,s)}throw new Ye(Ge.Format,`Unknown Midi Event type: ${i}`)}static midiFileToJsObject(e){const t=new Map;t.set("division",e.division),t.set("tickShift",e.tickShift);const s=[];for(const i of e.tracks)s.push(wt._midiTrackToJsObject(i));return t.set("tracks",s),t}static _midiTrackToJsObject(e){const t=new Map,s=[];for(const i of e.events)s.push(wt.midiEventToJsObject(i));return t.set("events",s),t}static midiEventToJsObject(e){const t=new Map;switch(t.set("track",e.track),t.set("tick",e.tick),t.set("type",e.type),e.type){case Ie.TimeSignature:t.set("numerator",e.numerator),t.set("denominatorIndex",e.denominatorIndex),t.set("midiClocksPerMetronomeClick",e.midiClocksPerMetronomeClick),t.set("thirdySecondNodesInQuarter",e.thirtySecondNodesInQuarter);break;
10case Ie.AlphaTabRest:t.set("channel",e.channel);break;case Ie.AlphaTabMetronome:t.set("metronomeNumerator",e.metronomeNumerator),t.set("metronomeDurationInMilliseconds",e.metronomeDurationInMilliseconds),t.set("metronomeDurationInTicks",e.metronomeDurationInTicks);break;case Ie.NoteOn:case Ie.NoteOff:t.set("channel",e.channel),t.set("noteKey",e.noteKey),t.set("noteVelocity",e.noteVelocity);break;case Ie.ControlChange:t.set("channel",e.channel),t.set("controller",e.controller),t.set("value",e.value);break;case Ie.ProgramChange:t.set("channel",e.channel),t.set("program",e.program);break;case Ie.TempoChange:t.set("beatsPerMinute",e.beatsPerMinute);break;case Ie.PitchBend:t.set("channel",e.channel),t.set("value",e.value);break;case Ie.PerNotePitchBend:t.set("channel",e.channel),t.set("noteKey",e.noteKey),t.set("value",e.value);break;case Ie.EndOfTrack:break}return t}}class Po{_player;_main;_exporter=new Map;constructor(e,t){this._main=e,this._main.addEventListener("message",this.handleMessage.bind(this)),this._player=new eh(new It,t),this._player.positionChanged.on(this.onPositionChanged.bind(this)),this._player.stateChanged.on(this.onPlayerStateChanged.bind(this)),this._player.finished.on(this.onFinished.bind(this)),this._player.soundFontLoaded.on(this.onSoundFontLoaded.bind(this)),this._player.soundFontLoadFailed.on(this.onSoundFontLoadFailed.bind(this)),this._player.soundFontLoadFailed.on(this.onSoundFontLoadFailed.bind(this)),this._player.midiLoaded.on(this.onMidiLoaded.bind(this)),this._player.midiLoadFailed.on(this.onMidiLoadFailed.bind(this)),this._player.readyForPlayback.on(this.onReadyForPlayback.bind(this)),this._player.midiEventsPlayed.on(this.onMidiEventsPlayed.bind(this)),this._player.playbackRangeChanged.on(this.onPlaybackRangeChanged.bind(this)),this._main.postMessage({cmd:"alphaSynth.ready"})}static init(){const e=M.globalThis;e.addEventListener("message",t=>{const s=t.data;s.cmd==="alphaSynth.initialize"&&(It.preferredSampleRate=s.sampleRate,E.logLevel=s.logLevel,M.globalThis.alphaSynthWebWorker=new Po(e,s.bufferTimeInMilliseconds))})}handleMessage(e){const t=e.data,s=t.cmd;switch(s){case"alphaSynth.setLogLevel":E.logLevel=t.value;break;case"alphaSynth.setMasterVolume":this._player.masterVolume=t.value;break;case"alphaSynth.setMetronomeVolume":this._player.metronomeVolume=t.value;break;case"alphaSynth.setPlaybackSpeed":this._player.playbackSpeed=t.value;break;case"alphaSynth.setTickPosition":this._player.tickPosition=t.value;break;case"alphaSynth.setTimePosition":this._player.timePosition=t.value;break;case"alphaSynth.setPlaybackRange":this._player.playbackRange=t.value;break;case"alphaSynth.setIsLooping":this._player.isLooping=t.value;break;case"alphaSynth.setCountInVolume":this._player.countInVolume=t.value;break;case"alphaSynth.setMidiEventsPlayedFilter":this._player.midiEventsPlayedFilter=t.value;break;case"alphaSynth.play":this._player.play();break;case"alphaSynth.pause":this._player.pause();break;case"alphaSynth.playPause":this._player.playPause();break;case"alphaSynth.stop":this._player.stop();break;case"alphaSynth.playOneTimeMidiFile":this._player.playOneTimeMidiFile(wt.jsObjectToMidiFile(t.midi));break;case"alphaSynth.loadSoundFontBytes":this._player.loadSoundFont(t.data,t.append);break;case"alphaSynth.resetSoundFonts":this._player.resetSoundFonts();break;case"alphaSynth.loadMidi":this._player.loadMidiFile(wt.jsObjectToMidiFile(t.midi));break;case"alphaSynth.setChannelMute":this._player.setChannelMute(t.channel,t.mute);break;case"alphaSynth.setChannelTranspositionPitch":this._player.setChannelTranspositionPitch(t.channel,t.semitones);break;case"alphaSynth.setChannelSolo":this._player.setChannelSolo(t.channel,t.solo);break;case"alphaSynth.setChannelVolume":this._player.setChannelVolume(t.channel,t.volume);break;case"alphaSynth.resetChannelStates":this._player.resetChannelStates();break;case"alphaSynth.destroy":this._player.destroy(),this._main.postMessage({cmd:"alphaSynth.destroyed"});break;case"alphaSynth.applyTranspositionPitches":this._player.applyTranspositionPitches(new Map(JSON.parse(t.transpositionPitches)));break}s.startsWith("alphaSynth.exporter")&&this._handleExporterMessage(e)}_handleExporterMessage(e){const t=e.data,s=t.cmd;try{switch(s){case"alphaSynth.exporter.initialize":const i=this._player.exportAudio(t.options,wt.jsObjectToMidiFile(t.midi),t.syncPoints,t.transpositionPitches);this._exporter.set(t.exporterId,i),this._main.postMessage({cmd:"alphaSynth.exporter.initialized",exporterId:t.exporterId});break;case"alphaSynth.exporter.render":if(this._exporter.has(t.exporterId)){const n=this._exporter.get(t.exporterId).render(t.milliseconds);this._main.postMessage({cmd:"alphaSynth.exporter.rendered",exporterId:t.exporterId,chunk:n})}else this._main.postMessage({cmd:"alphaSynth.exporter.error",exporterId:t.exporterId,error:new Error("Unknown exporter ID")});break;case"alphaSynth.exporter.destroy":this._exporter.delete(t.exporterId);break}}catch(i){this._main.postMessage({cmd:"alphaSynth.exporter.error",exporterId:t.exporterId,error:i})}}onPositionChanged(e){this._main.postMessage({cmd:"alphaSynth.positionChanged",currentTime:e.currentTime,endTime:e.endTime,currentTick:e.currentTick,endTick:e.endTick,isSeek:e.isSeek,originalTempo:e.originalTempo,modifiedTempo:e.modifiedTempo})}onPlayerStateChanged(e){this._main.postMessage({cmd:"alphaSynth.playerStateChanged",state:e.state,stopped:e.stopped})}onFinished(){this._main.postMessage({cmd:"alphaSynth.finished"})}onSoundFontLoaded(){this._main.postMessage({cmd:"alphaSynth.soundFontLoaded"})}onSoundFontLoadFailed(e){this._main.postMessage({cmd:"alphaSynth.soundFontLoadFailed",error:this._serializeException(M.prepareForPostMessage(e))})}_serializeException(e){const t=JSON.parse(JSON.stringify(e));return e.message&&(t.message=e.message),e.stack&&(t.stack=e.stack),e.constructor&&e.constructor.name&&(t.type=e.constructor.name),t}onMidiLoaded(e){this._main.postMessage({cmd:"alphaSynth.midiLoaded",currentTime:e.currentTime,endTime:e.endTime,currentTick:e.currentTick,endTick:e.endTick,isSeek:e.isSeek,originalTempo:e.originalTempo,modifiedTempo:e.modifiedTempo})}onMidiLoadFailed(e){this._main.postMessage({cmd:"alphaSynth.midiLoaded",error:this._serializeException(M.prepareForPostMessage(e))})}onReadyForPlayback(){this._main.postMessage({cmd:"alphaSynth.readyForPlayback"})}onMidiEventsPlayed(e){this._main.postMessage({cmd:"alphaSynth.midiEventsPlayed",events:e.events.map(wt.midiEventToJsObject)})}onPlaybackRangeChanged(e){this._main.postMessage({cmd:"alphaSynth.playbackRangeChanged",playbackRange:e.playbackRange})}}var us;(function(a){a[a.Browser=0]="Browser",a[a.NodeJs=1]="NodeJs",a[a.BrowserModule=2]="BrowserModule"})(us||(us={}));class Gn{characterWidths;characterHeights;constructor(e,t){this.characterWidths=e,this.characterHeights=t}}class bs{static fontSizeLookupTables=new Map;static ControlChars=32;static generateFontLookup(e){if(!bs.fontSizeLookupTables.has(e))if(!M.isRunningInWorker&&M.webPlatform!==us.NodeJs){const s=document.createElement("canvas").getContext("2d"),i=11;s.font=`${i}px ${e}`;const r=[],n=[];for(let l=bs.ControlChars;l<255;l++){const h=String.fromCharCode(l),c=s.measureText(h);r.push(c.width);const d=c.actualBoundingBoxDescent+c.actualBoundingBoxAscent;n.push(d)}const o=new Gn(new Uint8Array(r),new Uint8Array(n));bs.fontSizeLookupTables.set(e,o)}else{const t=new Gn(new Uint8Array([8]),new Uint8Array([10]));bs.fontSizeLookupTables.set(e,t)}}static measureString(e,t,s,i,r){let n,l=t[0];for(let f=0;f<t.length;f++)if(bs.fontSizeLookupTables.has(t[f])){l=t[f];break}bs.fontSizeLookupTables.has(l)||bs.generateFontLookup(l),n=bs.fontSizeLookupTables.get(l);let h=1;i===je.Italic&&(h*=1.1),r===rs.Bold&&(h*=1.1);let c=0,d=0;for(let f=0;f<e.length;f++){const p=Math.min(n.characterWidths.length-1,e.charCodeAt(f)-bs.ControlChars);p>=0&&(c+=n.characterWidths[p]*s/11,d=Math.max(d,n.characterHeights[p]*s/11))}return h*=1.07,new aa(c*h,d)}}class Si{id=L.newGuid();reuseViewport=!0;x=0;y=0;width=0;height=0;totalWidth=0;totalHeight=0;firstMasterBarIndex=-1;lastMasterBarIndex=-1;renderResult=null}class Co{masterBarBounds;visualBounds;realBounds;bar;beats=[];addBeat(e){e.barBounds=this,this.beats.push(e),this.masterBarBounds.addBeat(e)}findBeatAtPos(e){let t=null;for(const s of this.beats)if(!t||s.realBounds.x<e)t=s;else if(s.realBounds.x>e)break;return t}finish(e=1){this.realBounds.scaleWith(e),this.visualBounds.scaleWith(e),this.beats.sort((t,s)=>t.realBounds.x-s.realBounds.x);for(const t of this.beats)t.finish(e)}}class Eo{barBounds;visualBounds;onNotesX=0;realBounds;beat;notes=null;addNote(e){this.notes||(this.notes=[]),e.beatBounds=this,this.notes.push(e)}findNoteAtPos(e,t){const s=this.notes;if(!s)return null;for(const i of s){const r=i.noteHeadBounds.y+i.noteHeadBounds.h,n=i.noteHeadBounds.x+i.noteHeadBounds.w;if(i.noteHeadBounds.x<=e&&i.noteHeadBounds.y<=t&&e<=n&&t<=r)return i.note}return null}finish(e=1){if(this.realBounds.scaleWith(e),this.visualBounds.scaleWith(e),this.onNotesX*=e,this.notes)for(const t of this.notes)t.finish(e)}}class vo{index=0;
10isFirstOfLine=!1;visualBounds;realBounds;lineAlignedBounds;bars=[];staffSystemBounds=null;get staveGroupBounds(){return this.staffSystemBounds}addBar(e){e.masterBarBounds=this,this.bars.push(e)}findBeatAtPos(e){let t=null;const s=1e7;for(const i of this.bars){const r=i.findBeatAtPos(e);if(r&&(!t||t.realBounds.x<r.realBounds.x)){const n=Math.abs(r.realBounds.x-e);(!t||n<s)&&(t=r)}}return t?t.beat:null}finish(e=1){this.realBounds.scaleWith(e),this.visualBounds.scaleWith(e),this.lineAlignedBounds.scaleWith(e),this.bars.sort((t,s)=>t.realBounds.y<s.realBounds.y?-1:t.realBounds.y>s.realBounds.y?1:t.realBounds.x<s.realBounds.x?-1:t.realBounds.x>s.realBounds.x?1:0);for(const t of this.bars)t.finish(e)}addBeat(e){this.staffSystemBounds.boundsLookup.addBeat(e)}}class xr{beatBounds;noteHeadBounds;note;finish(e=1){this.noteHeadBounds.scaleWith(e)}}class Do{index=0;visualBounds;realBounds;bars=[];boundsLookup;finish(e=1){this.realBounds.scaleWith(e),this.visualBounds.scaleWith(e);for(const t of this.bars)t.finish(e)}addBar(e){this.boundsLookup.addMasterBar(e),e.staffSystemBounds=this,this.bars.push(e)}findBarAtPos(e){let t=null;for(const s of this.bars)if(!t||s.realBounds.x<e)t=s;else if(e>s.realBounds.x+s.realBounds.w)break;return t}}class ls{toJson(){const e={},t=[];e.staffSystems=t;for(const s of this.staffSystems){const i={};i.visualBounds=this._boundsToJson(s.visualBounds),i.realBounds=this._boundsToJson(s.realBounds),i.bars=[];for(const r of s.bars){const n={};n.lineAlignedBounds=this._boundsToJson(r.lineAlignedBounds),n.visualBounds=this._boundsToJson(r.visualBounds),n.realBounds=this._boundsToJson(r.realBounds),n.index=r.index,n.isFirstOfLine=r.isFirstOfLine,n.bars=[];for(const o of r.bars){const l={};l.visualBounds=this._boundsToJson(o.visualBounds),l.realBounds=this._boundsToJson(o.realBounds),l.beats=[];for(const h of o.beats){const c={};c.visualBounds=this._boundsToJson(h.visualBounds),c.realBounds=this._boundsToJson(h.realBounds),c.onNotesX=h.onNotesX;const d=c;if(d.beatIndex=h.beat.index,d.voiceIndex=h.beat.voice.index,d.barIndex=h.beat.voice.bar.index,d.staffIndex=h.beat.voice.bar.staff.index,d.trackIndex=h.beat.voice.bar.staff.track.index,h.notes){const f=[];c.notes=f;for(const p of h.notes){const g={},m=g;m.index=p.note.index,g.noteHeadBounds=this._boundsToJson(p.noteHeadBounds),f.push(g)}}l.beats.push(c)}n.bars.push(l)}i.bars.push(n)}t.push(i)}return e}static fromJson(e,t){const s=new ls,i=e.staffSystems;for(const r of i){const n=new Do;n.visualBounds=ls._boundsFromJson(r.visualBounds),n.realBounds=ls._boundsFromJson(r.realBounds),s.addStaffSystem(n);for(const o of r.bars){const l=new vo;l.index=o.index,l.isFirstOfLine=o.isFirstOfLine,l.lineAlignedBounds=ls._boundsFromJson(o.lineAlignedBounds),l.visualBounds=ls._boundsFromJson(o.visualBounds),l.realBounds=ls._boundsFromJson(o.realBounds),s.addMasterBar(l);for(const h of o.bars){const c=new Co;c.visualBounds=ls._boundsFromJson(h.visualBounds),c.realBounds=ls._boundsFromJson(h.realBounds),l.addBar(c);for(const d of h.beats){const f=new Eo;f.visualBounds=ls._boundsFromJson(d.visualBounds),f.realBounds=ls._boundsFromJson(d.realBounds),f.onNotesX=d.onNotesX;const p=d;if(f.beat=t.tracks[p.trackIndex].staves[p.staffIndex].bars[p.barIndex].voices[p.voiceIndex].beats[p.beatIndex],d.notes){f.notes=[];for(const g of d.notes){const m=new xr,b=g;m.note=f.beat.notes[b.index],m.noteHeadBounds=ls._boundsFromJson(g.noteHeadBounds),f.addNote(m)}}c.addBeat(f)}}}}return s}static _boundsFromJson(e){const t=new bt;return t.x=e.x,t.y=e.y,t.w=e.w,t.h=e.h,t}_boundsToJson(e){const t={};return t.x=e.x,t.y=e.y,t.w=e.w,t.h=e.h,t}_beatLookup=new Map;_masterBarLookup=new Map;_currentStaffSystem=null;staffSystems=[];isFinished=!1;finish(e=1){for(const t of this.staffSystems)t.finish(e);this.isFinished=!0}addStaffSystem(e){e.index=this.staffSystems.length,e.boundsLookup=this,this.staffSystems.push(e),this._currentStaffSystem=e}addMasterBar(e){e.staffSystemBounds?this._masterBarLookup.set(e.index,e):(e.staffSystemBounds=this._currentStaffSystem,this._masterBarLookup.set(e.index,e),this._currentStaffSystem.addBar(e))}addBeat(e){this._beatLookup.has(e.beat.id)||this._beatLookup.set(e.beat.id,[]),this._beatLookup.get(e.beat.id)?.push(e)}findMasterBarByIndex(e){return this._masterBarLookup.has(e)?this._masterBarLookup.get(e):null}findMasterBar(e){const t=e.index;return this._masterBarLookup.has(t)?this._masterBarLookup.get(t):null}findBeat(e){const t=this.findBeats(e);return t?t[0]:null}findBeats(e){const t=e.id;return this._beatLookup.has(t)?this._beatLookup.get(t):null}getBeatAtPos(e,t){let s=0,i=this.staffSystems.length-1,r=-1;for(;s<=i;){const l=(i+s)/2|0,h=this.staffSystems[l];if(t>=h.realBounds.y&&t<=h.realBounds.y+h.realBounds.h){r=l;break}t<h.realBounds.y?i=l-1:s=l+1}if(r===-1)return null;const o=this.staffSystems[r].findBarAtPos(e);return o?o.findBeatAtPos(e):null}getNoteAtPos(e,t,s){const i=this.findBeats(e);if(i)for(const r of i){const n=r.findNoteAtPos(t,s);if(n)return n}return null}}class ur{_currentLayoutMode=ni.Page;_currentRenderEngine=null;_renderedTracks=null;canvas=null;score=null;tracks=null;layout=null;settings;boundsLookup=null;width=0;constructor(e){this.settings=e,this._recreateCanvas(),this._recreateLayout()}destroy(){this.score=null,this.canvas?.destroy(),this.canvas=null,this.layout=null,this.boundsLookup=null,this.tracks=null}
10_recreateCanvas(){return this._currentRenderEngine!==this.settings.core.engine?(this.canvas?.destroy(),this.canvas=M.getRenderEngineFactory(this.settings.core.engine).createCanvas(),this._currentRenderEngine=this.settings.core.engine,!0):!1}_recreateLayout(){return!this.layout||this._currentLayoutMode!==this.settings.display.layoutMode?(this.layout=M.getLayoutEngineFactory(this.settings.display.layoutMode).createLayout(this),this._currentLayoutMode=this.settings.display.layoutMode,!0):!1}renderScore(e,t,s){try{this.score=e;let i=null;if(e!=null&&t!=null){if(!t)i=e.tracks.slice(0);else{i=[];for(const r of t)r>=0&&r<e.tracks.length&&i.push(e.tracks[r])}i.length===0&&e.tracks.length>0&&i.push(e.tracks[0])}this.tracks=i,this.render(s)}catch(i){this.error.trigger(i)}}renderTracks(e){e.length===0?this.score=null:this.score=e[0].score,this.tracks=e,this.render()}updateSettings(e){this.settings=e}renderResult(e){try{const t=this.layout;t?(E.debug("Rendering",`Request render of lazy partial ${e}`),t.renderLazyPartial(e)):E.warning("Rendering",`Request render of lazy partial ${e} ignored, no layout exists`)}catch(t){this.error.trigger(t)}}render(e){if(this.width===0){E.warning("Rendering","AlphaTab skipped rendering because of width=0 (element invisible)",null);return}if(this.boundsLookup=new ls,this._recreateCanvas(),this.canvas.lineWidth=1,this.canvas.settings=this.settings,!this.tracks||this.tracks.length===0||!this.score)E.debug("Rendering","Clearing rendered tracks because no score or tracks are set"),this.preRender.trigger(!1),this._renderedTracks=null,this._onRenderFinished(),this.postRenderFinished.trigger(),E.debug("Rendering","Clearing finished");else{E.debug("Rendering",`Rendering ${this.tracks.length} tracks`);for(let t=0;t<this.tracks.length;t++){const s=this.tracks[t];E.debug("Rendering",`Track ${t}: ${s.name}`)}this.preRender.trigger(!1),this._recreateLayout(),this._layoutAndRender(e),E.debug("Rendering","Rendering finished")}}resizeRender(){this._recreateLayout()||this._recreateCanvas()||this._renderedTracks!==this.tracks||!this.tracks?(E.debug("Rendering","Starting full rerendering due to layout or canvas change",null),this.render()):this.layout.supportsResize?(E.debug("Rendering","Starting optimized rerendering for resize"),this.boundsLookup=new ls,this.preRender.trigger(!0),this.canvas.settings=this.settings,this.layout.resize(),this._onRenderFinished(),this.postRenderFinished.trigger()):E.debug("Rendering","Current layout does not support dynamic resizing, nothing was done",null),E.debug("Rendering","Resize finished")}_layoutAndRender(e){E.debug("Rendering",`Rendering at scale ${this.settings.display.scale} with layout ${this.layout.name}`,null),this.layout.layoutAndRender(e),this._renderedTracks=this.tracks,this._onRenderFinished(),this.postRenderFinished.trigger()}preRender=new Se;renderFinished=new Se;partialRenderFinished=new Se;partialLayoutFinished=new Se;postRenderFinished=new _t;error=new Se;_onRenderFinished(){this.boundsLookup?.finish(this.settings.display.scale);const e=new Si;e.totalHeight=this.layout.height,e.totalWidth=this.layout.width,e.renderResult=this.canvas.onRenderFinished(),this.renderFinished.trigger(e)}}class Lo{_renderer;_main;constructor(e){this._main=e,this._main.addEventListener("message",this._handleMessage.bind(this),!1)}static init(){M.globalThis.alphaTabWebWorker=new Lo(M.globalThis)}_handleMessage(e){const t=e.data;switch(t?t.cmd:""){case"alphaTab.initialize":const i=wt.jsObjectToSettings(t.settings);E.logLevel=i.core.logLevel,this._renderer=new ur(i),this._renderer.partialRenderFinished.on(n=>{this._main.postMessage({cmd:"alphaTab.partialRenderFinished",result:n})}),this._renderer.partialLayoutFinished.on(n=>{this._main.postMessage({cmd:"alphaTab.partialLayoutFinished",result:n})}),this._renderer.renderFinished.on(n=>{this._main.postMessage({cmd:"alphaTab.renderFinished",result:n})}),this._renderer.postRenderFinished.on(()=>{this._main.postMessage({cmd:"alphaTab.postRenderFinished",boundsLookup:this._renderer.boundsLookup?.toJson()??null})}),this._renderer.preRender.on(n=>{this._main.postMessage({cmd:"alphaTab.preRender",resize:n})}),this._renderer.error.on(this._error.bind(this));break;case"alphaTab.render":this._renderer.render(t.renderHints);break;case"alphaTab.resizeRender":this._renderer.resizeRender();break;case"alphaTab.renderResult":this._renderer.renderResult(t.resultId);break;case"alphaTab.setWidth":this._renderer.width=t.width;break;
10case"alphaTab.renderScore":this._updateFontSizes(t.fontSizes);const r=t.score==null?null:wt.jsObjectToScore(t.score,this._renderer.settings);this._renderMultiple(r,t.trackIndexes);break;case"alphaTab.updateSettings":this._updateSettings(t.settings);break}}_updateFontSizes(e){if(!(e instanceof Map)){const t=e;e=new Map;for(const s in t)e.set(s,t[s])}if(e)for(const[t,s]of e)bs.fontSizeLookupTables.set(t,s)}_updateSettings(e){Ii.fromJson(this._renderer.settings,e)}_renderMultiple(e,t,s){try{this._renderer.renderScore(e,t,s)}catch(i){this._error(i)}}_error(e){E.error("Worker","An unexpected error occurred in worker",e),this._main.postMessage({cmd:"alphaTab.error",error:e})}}class xc{_measureCanvas;_measureContext;_canvas=null;_context;_color=new Fe(0,0,0,255);_font=new ze("Arial",10,je.Plain);_musicFont;_lineWidth=0;settings;constructor(){this._measureCanvas=document.createElement("canvas"),this._measureCanvas.width=10,this._measureCanvas.height=10,this._measureCanvas.style.width="10px",this._measureCanvas.style.height="10px",this._measureContext=this._measureCanvas.getContext("2d"),this._measureContext.textBaseline="hanging"}destroy(){}onRenderFinished(){return null}beginRender(e,t){this._musicFont=new ze(this.settings.display.resources.smuflFontFamilyName,this.settings.display.resources.engravingSettings.musicFontSize,je.Plain,rs.Regular);const s=this.settings.display.scale;this._canvas=document.createElement("canvas"),this._canvas.width=e*M.highDpiFactor|0,this._canvas.height=t*M.highDpiFactor|0,this._canvas.style.width=`${e}px`,this._canvas.style.height=`${t}px`,this._context=this._canvas.getContext("2d"),this._context.textBaseline="hanging",this._context.scale(M.highDpiFactor*s,M.highDpiFactor*s),this._context.lineWidth=this._lineWidth}endRender(){const e=this._canvas;return this._canvas=null,e}get color(){return this._color}set color(e){this._color.rgba!==e.rgba&&(this._color=e,this._context.strokeStyle=e.rgba,this._context.fillStyle=e.rgba)}get lineWidth(){return this._lineWidth}set lineWidth(e){this._lineWidth=e,this._context&&(this._context.lineWidth=e)}fillRect(e,t,s,i){s>0&&this._context.fillRect(e,t,s,i)}strokeRect(e,t,s,i){const r=this.lineWidth%2===0?0:.5;this._context.strokeRect(e+r,t+r,s,i)}beginPath(){this._context.beginPath()}closePath(){this._context.closePath()}moveTo(e,t){this._context.moveTo(e,t)}lineTo(e,t){this._context.lineTo(e,t)}quadraticCurveTo(e,t,s,i){this._context.quadraticCurveTo(e,t,s,i)}bezierCurveTo(e,t,s,i,r,n){this._context.bezierCurveTo(e,t,s,i,r,n)}fillCircle(e,t,s){this._context.beginPath(),this._context.arc(e,t,s,0,Math.PI*2,!0),this.fill()}strokeCircle(e,t,s){this._context.beginPath(),this._context.arc(e,t,s,0,Math.PI*2,!0),this.stroke()}fill(){this._context.fill(),this._context.beginPath()}stroke(){this._context.stroke(),this._context.beginPath()}get font(){return this._font}set font(e){this._font=e,this._context&&(this._context.font=e.toCssString(1)),this._measureContext.font=e.toCssString(1)}get textAlign(){switch(this._context.textAlign){case"left":return Y.Left;case"center":return Y.Center;case"right":return Y.Right;default:return Y.Left}}set textAlign(e){switch(e){case Y.Left:this._context.textAlign="left";break;case Y.Center:this._context.textAlign="center";break;case Y.Right:this._context.textAlign="right";break}}get textBaseline(){switch(this._context.textBaseline){case"hanging":return He.Top;case"middle":return He.Middle;case"bottom":return He.Bottom;case"alphabetic":return He.Alphabetic;default:return He.Top}}set textBaseline(e){switch(e){case He.Top:this._context.textBaseline="hanging";break;case He.Middle:this._context.textBaseline="middle";break;case He.Bottom:this._context.textBaseline="bottom";break;case He.Alphabetic:this._context.textBaseline="alphabetic";break}}beginGroup(e){}endGroup(){}fillText(e,t,s){this._context.fillText(e,t,s)}measureText(e){const t=this._measureContext.measureText(e);return new aa(t.width,t.actualBoundingBoxDescent+t.actualBoundingBoxAscent)}fillMusicFontSymbol(e,t,s,i,r=!1){i!==u.None&&this._fillMusicFontSymbolText(e,t,s,String.fromCharCode(i),r)}fillMusicFontSymbols(e,t,s,i,r=!1){let n="";for(const o of i)o!==u.None&&(n+=String.fromCharCode(o));this._fillMusicFontSymbolText(e,t,s,n,r)}_fillMusicFontSymbolText(e,t,s,i,r){const n=this._context.textAlign,o=this._context.textBaseline,l=this._context.font;this._context.font=this._musicFont.toCssString(s),this._context.textBaseline="alphabetic",r?this._context.textAlign="center"
10:this._context.textAlign="left",this._context.fillText(i,e,t),this._context.textBaseline=o,this._context.font=l,this._context.textAlign=n}beginRotate(e,t,s){this._context.save(),this._context.translate(e,t),this._context.rotate(s*Math.PI/180)}endRotate(){this._context.restore()}}class Rs{_midiFile;_smf1Mode;tickShift=0;constructor(e,t=!1){this._midiFile=e,this._smf1Mode=t}addTickShift(e){this._midiFile.tickShift=e,this.tickShift=e}addTimeSignature(e,t,s){e+=this.tickShift;let i=0,r=s;for(;r=r>>1,r>0;)i++;this._midiFile.addEvent(new ho(0,e,t,i,48,8))}addRest(e,t,s){t+=this.tickShift,this._smf1Mode||this._midiFile.addEvent(new uo(e,t,s))}addNote(e,t,s,i,r,n){t+=this.tickShift,this._midiFile.addEvent(new po(e,t,n,Rs._fixValue(i),Rs._fixValue(r))),this._midiFile.addEvent(new go(e,t+s,n,Rs._fixValue(i),Rs._fixValue(r)))}static _fixValue(e){return e>127?127:e<0?0:e}addControlChange(e,t,s,i,r){t+=this.tickShift,this._midiFile.addEvent(new mo(e,t,s,i,Rs._fixValue(r)))}addProgramChange(e,t,s,i){t+=this.tickShift,this._midiFile.addEvent(new yo(e,t,s,i))}addTempo(e,t){e+=this.tickShift;const s=new bo(e,0);s.beatsPerMinute=t,this._midiFile.addEvent(s)}addBend(e,t,s,i){t+=this.tickShift,i>=de.MaxPitchWheel?i=de.MaxPitchWheel:i=Math.floor(i),this._midiFile.addEvent(new _o(e,t,s,i))}addNoteBend(e,t,s,i,r){t+=this.tickShift,this._smf1Mode?this.addBend(e,t,s,r):(r=r*de.MaxPitchWheel20/de.MaxPitchWheel,this._midiFile.addEvent(new So(e,t,s,i,r)))}finishTrack(e,t){t+=this.tickShift,(this._midiFile.format===ji.MultiTrack||e===0)&&this._midiFile.addEvent(new ko(e,t))}}class Nc{group;opening;iterations;closingIndex=0;constructor(e,t){this.group=e,this.opening=t,e.closings=e.closings.sort((s,i)=>s.index-i.index),this.iterations=e.closings.map(s=>0)}}var Ft;(function(a){a[a.PlayingNormally=0]="PlayingNormally",a[a.DirectionJumped=1]="DirectionJumped",a[a.DirectionJumpedAlCoda=2]="DirectionJumpedAlCoda",a[a.DirectionJumpedAlDoubleCoda=3]="DirectionJumpedAlDoubleCoda",a[a.DirectionJumpedAlFine=4]="DirectionJumpedAlFine"})(Ft||(Ft={}));class Pc{_score;_repeatStack=[];_groupsOnStack=new Set;_previousAlternateEndings=0;_state=Ft.PlayingNormally;shouldPlay=!0;index=0;currentTick=0;get finished(){return this.index>=this._score.masterBars.length}constructor(e){this._score=e}processCurrent(){const e=this._score.masterBars[this.index];if(this._state===Ft.PlayingNormally){let t=e.alternateEndings;if(t===0&&(t=this._previousAlternateEndings),e===e.repeatGroup.opening&&e.repeatGroup.isClosed&&!this._groupsOnStack.has(e.repeatGroup)){const s=new Nc(e.repeatGroup,e);this._repeatStack.push(s),this._groupsOnStack.add(e.repeatGroup),this._previousAlternateEndings=0,t=e.alternateEndings}if(this._repeatStack.length===0||t===0)this.shouldPlay=!0;else{const s=this._repeatStack[this._repeatStack.length-1],i=s.iterations[s.closingIndex];this._previousAlternateEndings=t,(t&1<<i)===0?this.shouldPlay=!1:this.shouldPlay=!0}}else this.shouldPlay=!0;this.shouldPlay&&(this.currentTick+=e.calculateDuration())}moveNext(){this._moveNextWithDirections()||this._moveNextWithNormalRepeats()}_resetRepeats(){this._groupsOnStack.clear(),this._previousAlternateEndings=0,this._repeatStack=[]}_handleDaCapo(e,t,s){return e.has(t)?(this.index=0,this._state=s,this._resetRepeats(),!0):!1}_handleDalSegno(e,t,s,i){if(e.has(t)){const r=this._findJumpTarget(i,this.index,!0);return r===-1?!1:(this.index=r,this._state=s,this._resetRepeats(),!0)}return!1}_handleDaCoda(e,t,s){if(e.has(t)){const i=this._findJumpTarget(s,this.index,!1);return i===-1?(this.index++,!0):(this.index=i,this._state=Ft.PlayingNormally,!0)}return!1}_moveNextWithDirections(){const e=this._score.masterBars[this.index],t=e.directions!==null&&e.directions.size>0;if(this._state===Ft.PlayingNormally&&!t)return!1;if(!t)return this.index++,!0;switch(this._state){case Ft.PlayingNormally:return!!(this._handleDaCapo(e.directions,U.JumpDaCapo,Ft.DirectionJumped)||this._handleDaCapo(e.directions,U.JumpDaCapoAlCoda,Ft.DirectionJumpedAlCoda)||this._handleDaCapo(e.directions,U.JumpDaCapoAlDoubleCoda,Ft.DirectionJumpedAlDoubleCoda)||this._handleDaCapo(e.directions,U.JumpDaCapoAlFine,Ft.DirectionJumpedAlFine)||this._handleDalSegno(e.directions,U.JumpDalSegno,Ft.DirectionJumped,U.TargetSegno)||this._handleDalSegno(e.directions,U.JumpDalSegnoAlCoda,Ft.DirectionJumpedAlCoda,U.TargetSegno)||this._handleDalSegno(e.directions,U.JumpDalSegnoAlDoubleCo
vendor: 6,464 bytes, line 10
10da,Ft.DirectionJumpedAlDoubleCoda,U.TargetSegno)||this._handleDalSegno(e.directions,U.JumpDalSegnoAlFine,Ft.DirectionJumpedAlFine,U.TargetSegno)||this._handleDalSegno(e.directions,U.JumpDalSegnoSegno,Ft.DirectionJumped,U.TargetSegnoSegno)||this._handleDalSegno(e.directions,U.JumpDalSegnoSegnoAlCoda,Ft.DirectionJumpedAlCoda,U.TargetSegnoSegno)||this._handleDalSegno(e.directions,U.JumpDalSegnoSegnoAlDoubleCoda,Ft.DirectionJumpedAlDoubleCoda,U.TargetSegnoSegno)||this._handleDalSegno(e.directions,U.JumpDalSegnoSegnoAlFine,Ft.DirectionJumpedAlFine,U.TargetSegnoSegno));case Ft.DirectionJumped:return this.index++,!0;case Ft.DirectionJumpedAlCoda:return this._handleDaCoda(e.directions,U.JumpDaCoda,U.TargetCoda)||this.index++,!0;case Ft.DirectionJumpedAlDoubleCoda:return this._handleDaCoda(e.directions,U.JumpDaDoubleCoda,U.TargetDoubleCoda)||this.index++,!0;case Ft.DirectionJumpedAlFine:return e.directions.has(U.TargetFine)?(this.index=this._score.masterBars.length,!0):(this.index++,!0)}return!0}_findJumpTarget(e,t,s){let i;return s?(i=this._findJumpTargetBackwards(e,t),i===-1&&(i=this._findJumpTargetForwards(e,t)),i):(i=this._findJumpTargetForwards(e,t),i===-1&&(i=this._findJumpTargetBackwards(e,t)),i)}_findJumpTargetForwards(e,t){let s=t;for(;s<this._score.masterBars.length;){const i=this._score.masterBars[s].directions;if(i&&i.has(e))return s;s++}return-1}_findJumpTargetBackwards(e,t){let s=t;for(;s>=0;){const i=this._score.masterBars[s].directions;if(i&&i.has(e))return s;s--}return-1}_moveNextWithNormalRepeats(){const t=this._score.masterBars[this.index].repeatCount-1;if(this._repeatStack.length>0&&t>0){const s=this._repeatStack[this._repeatStack.length-1];if(s.iterations[s.closingIndex]<t){this.index=s.opening.index,s.iterations[s.closingIndex]++;for(let r=0;r<s.closingIndex;r++)s.iterations[r]=0;s.closingIndex=0,this._previousAlternateEndings=0}else s.closingIndex<s.group.closings.length-1?(s.closingIndex++,this.index++):(this._repeatStack.pop(),this._groupsOnStack.delete(s.group),this.index++)}else this.index++}}class th{beat;playbackStart;constructor(e,t){this.beat=e,this.playbackStart=t}}class Ps{_highlightedBeats=new Map;start;end;highlightedBeats=[];nextBeat=null;previousBeat=null;get duration(){return this.end-this.start}constructor(e,t){this.start=e,this.end=t}highlightBeat(e,t){e.isEmpty&&!e.voice.isEmpty||this._highlightedBeats.has(e.id)||(this._highlightedBeats.set(e.id,!0),this.highlightedBeats.push(new th(e,t)))}getVisibleBeatAtStart(e){for(const t of this.highlightedBeats)if(t.playbackStart===this.start&&e.has(t.beat.voice.bar.staff.track.index))return t.beat;return null}getVisibleBeatAtStartWithChecker(e){for(const t of this.highlightedBeats)if(t.playbackStart===this.start&&e.isVisible(t.beat))return t.beat;return null}}class Dr{tick;tempo;constructor(e,t){this.tick=e,this.tempo=t}}class Fo{start=0;end=0;get tempo(){return this.tempoChanges[0].tempo}tempoChanges=[];masterBar;firstBeat=null;lastBeat=null;_insertAfter(e,t){this.firstBeat==null||e==null||this.lastBeat==null?(this.firstBeat=t,this.lastBeat=t):(t.nextBeat=e.nextBeat,t.previousBeat=e,e.nextBeat&&(e.nextBeat.previousBeat=t),e.nextBeat=t,e===this.lastBeat&&(this.lastBeat=t))}_insertBefore(e,t){this.firstBeat==null||e==null||this.lastBeat==null?(this.firstBeat=t,this.lastBeat=t):(t.previousBeat=e.previousBeat,t.nextBeat=e,e.previousBeat&&(e.previousBeat.nextBeat=t),e.previousBeat=t,e===this.firstBeat&&(this.firstBeat=t))}nextMasterBar=null;previousMasterBar=null;addBeat(e,t,s,i){const r=s+i;if(this.firstBeat==null){const n=new Ps(s,r);n.highlightBeat(e,t),this._insertAfter(this.firstBeat,n)}else if(s>=this.lastBeat.end){const n=new Ps(this.lastBeat.end,r);n.highlightBeat(e,t),this._insertAfter(this.lastBeat,n)}else{let n=null;if(s<this.firstBeat.start)n=this.firstBeat;else{let o=this.firstBeat;for(;o!=null;){if(s>=o.start&&s<o.end){n=o;break}o=o.nextBeat}if(n===null)throw new Ye(Ge.General,"Error on building lookup, unknown variant")}if(s<n.start)if(r===n.start){const o=new Ps(s,n.start);o.highlightBeat(e,t),this._insertBefore(this.firstBeat,o)}else if(r<n.end){const o=new Ps(s,n.start);o.highlightBeat(e,t),this._insertBefore(n,o);const l=new Ps(n.start,r);for(const h of n.highlightedBeats)l.highlightBeat(h.beat,h.playbackStart);l.highlightBeat(e,t),this._insertBefore(n,l),n.start=r}else if(r===n.end){const o=new Ps(s,n.start);o.highlightBeat(e,t),n.highlightBeat(e,t),this._insertBefore(n,o)}else{const o=new Ps(s,n.start);o.highlightBeat(e,t),n.highlightBeat(e,t),this._insertBefore(n,o),this.addBeat(e,t,n.end,r-n.end)}else if(s>n.start)if(r===n.end){const o=new Ps(n.start,s);for(const l of n.highlightedBeats)o.highlightBeat(l.beat,l.playbackStart);n.start=s,n.highlightBeat(e,t),this._insertBefore(n,o)}else if(r<n.end){const o=new Ps(n.start,s);this._insertBefore(n,o);const l=new Ps(s,r);this._insertBefore(n,l);for(const h of n.highlightedBeats)o.highlightBeat(h.beat,h.playbackStart),l.highlightBeat(h.beat,h.playbackStart);l.highlightBeat(e,t),n.start=r}else{const o=new Ps(n.start,s);for(const l of n.highlightedBeats)o.highlightBeat(l.beat,l.playbackStart);n.start=s,n.highlightBeat(e,t),this._insertBefore(n,o),this.addBeat(e,t,n.end,r-n.end)}else if(r===n.end)n.highlightBeat(e,t);else if(r<n.end){const o=new Ps(n.start,r);for(const l of n.highlightedBeats)o.highlightBeat(l.beat,l.playbackStart);o.highlightBeat(e,t),n.start=r,this._insertBefore(n,o)}else n.highlightBeat(e,t),this.addBeat(e,t,n.end,r-n.end)}}}var Bs;(function(a){a[a.Unknown=0]="Unknown",a[a.ToNextBext=1]="ToNextBext",a[a.ToEndOfBar=2]="ToEndOfBar"})(Bs||(Bs={}));class sh{beat;masterBar;beatLookup;nextBeat=null;tickDuration=0;duration=0;cursorMode=Bs.Unknown;get start(){return this.masterBar.start+this.beatLookup.start}get end(){return this.start+this.tickDuration}constructor(e){this.masterBar=e}calculateDuration(){if(this.masterBar.tempoChanges.length===1)this.duration=B.ticksToMillis(this.tickDuration,this.masterBar.tempoChanges[0].tempo);else{let e=0,t=this.start,s=this.masterBar.tempoChanges[0].tempo;const i=this.end;for(const r of this.masterBar.tempoChanges)if(r.tick<t)s=r.tempo;else{if(r.tick>i)break;e+=B.ticksToMillis(r.tick-t,s),s=r.tempo,t=r.tick}i>t&&(e+=B.ticksToMillis(i-t,s)),this.duration=e}}}class Cc{_lookup;constructor(e){this._lookup=e}isVisible(e){return this._lookup.has(e.voice.bar.staff.track.index)}}class ih{_currentMasterBar=null;masterBarLookup=new Map;masterBars=[];multiBarRestInfo=null;
10findBeat(e,t,s=null){return this.findBeatWithChecker(new Cc(e),t,s)}findBeatWithChecker(e,t,s=null){let i=null;return s&&(i=this._findBeatFast(e,s,t)),i||(i=this._findBeatSlow(e,s,t,!1)),i}_findBeatFast(e,t,s){if(s>=t.start&&s<t.end)return t;if(t.nextBeat&&s>=t.nextBeat.start&&s<t.nextBeat.end&&(e===void 0||e.isVisible(t.nextBeat.beat))){const i=t.nextBeat;return this._fillNextBeat(i,e),i}return null}_fillNextBeatMultiBarRest(e,t){const s=this.multiBarRestInfo.get(e.masterBar.masterBar.index);let i=e.masterBar;for(let r=0;r<s.length&&i;r++)i=i.nextMasterBar;i?i.nextMasterBar?(e.nextBeat=this._firstBeatInMasterBar(t,i.nextMasterBar,i.nextMasterBar.start,!0),e.nextBeat?(e.tickDuration=e.nextBeat.start-e.start,e.cursorMode=Bs.ToNextBext,e.nextBeat.masterBar.masterBar.index!==i.masterBar.index+1&&(e.nextBeat.masterBar.masterBar.index!==i.masterBar.index||e.nextBeat.beat.playbackStart<=e.beat.playbackStart)&&(e.cursorMode=Bs.ToEndOfBar)):(e.tickDuration=i.nextMasterBar.end-e.start,e.cursorMode=Bs.ToEndOfBar)):(e.tickDuration=i.end-e.start,e.cursorMode=Bs.ToEndOfBar):(E.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)"),e.tickDuration=(e.masterBar.end-e.masterBar.start)*(s.length+1),e.cursorMode=Bs.ToEndOfBar),e.calculateDuration()}_fillNextBeat(e,t){this._isMultiBarRestResult(e)?this._fillNextBeatMultiBarRest(e,t):this._fillNextBeatDefault(e,t)}_fillNextBeatDefault(e,t){e.nextBeat=this._findBeatInMasterBar(e.masterBar,e.beatLookup.nextBeat,e.end,t,!0),e.nextBeat==null&&(e.nextBeat=this._findBeatSlow(t,e,e.end,!0)),e.nextBeat?(e.tickDuration=e.nextBeat.start-e.start,e.cursorMode=Bs.ToNextBext,e.calculateDuration()):(e.tickDuration=e.masterBar.end-e.start,e.cursorMode=Bs.ToEndOfBar,e.calculateDuration()),e.nextBeat&&e.nextBeat.masterBar.masterBar.index!==e.masterBar.masterBar.index+1&&(e.nextBeat.masterBar.masterBar.index!==e.masterBar.masterBar.index||e.nextBeat.beat.playbackStart<=e.beat.playbackStart)&&(e.cursorMode=Bs.ToEndOfBar)}_isMultiBarRestResult(e){return this._internalIsMultiBarRestResult(e.masterBar.masterBar.index,e.beat)}_internalIsMultiBarRestResult(e,t){return this.multiBarRestInfo&&this.multiBarRestInfo.has(e)&&t.isRest&&t.voice.bar.isRestOnly}_findBeatSlow(e,t,s,i){let r=null;return t!=null&&(t.masterBar.start<=s&&t.masterBar.end>s?r=t.masterBar:t.masterBar.nextMasterBar&&t.masterBar.nextMasterBar.start<=s&&t.masterBar.nextMasterBar.end>s&&(r=t.masterBar.nextMasterBar)),r||(r=this._findMasterBar(s)),r?this._firstBeatInMasterBar(e,r,s,i):null}_firstBeatInMasterBar(e,t,s,i){let r=t;for(;r;){if(r.firstBeat){const n=this._findBeatInMasterBar(r,r.firstBeat,s,e,i);if(n)return n}r=r.nextMasterBar}return null}_findBeatInMasterBar(e,t,s,i,r){if(!t)return null;let n=null,o=null;const l=s-e.start;for(;t!=null&&o==null;){if((t.start<=l||r&&l<0)&&l<t.end){if(n=t,o=t.getVisibleBeatAtStartWithChecker(i),!o)if(r){let c=e;for(;c!=null&&o==null;){for(;t!=null;){if(o=t.getVisibleBeatAtStartWithChecker(i),o){n=t,e=c;break}t=t.nextBeat}(!o||!n)&&(c=c.nextMasterBar,t=c?.firstBeat??null)}}else{let c=e;for(;c!=null&&o==null;){for(;t!=null;){if(o=t.getVisibleBeatAtStartWithChecker(i),o){n=t,e=c;break}t=t.previousBeat}(!o||!n)&&(c=c.previousMasterBar,t=c?.firstBeat??null)}}}else if(t.end>l)break;t=t?.nextBeat??null}return o==null?null:this._createResult(e,n,o,r,i)}_createResult(e,t,s,i,r){const n=new sh(e);if(n.beat=s,n.beatLookup=t,n.tickDuration=t.end-t.start,!i)this._fillNextBeat(n,r);else if(this._isMultiBarRestResult(n)){const o=this.multiBarRestInfo.get(e.masterBar.index);let l=e;for(let h=0;h<o.length&&l;h++)l=l.nextMasterBar;l?l.nextMasterBar?n.tickDuration=l.nextMasterBar.start-t.start:n.tickDuration=l.end-t.start:E.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)")}return n.calculateDuration(),n}_findMasterBar(e){if(e<=0&&this.masterBars.length>0)return this.masterBars[0];const t=this.masterBars;let s=0,i=t.length-1;for(;s<=i;){const r=(i+s)/2|0,n=t[r];
vendor: 11,221 bytes, line 10
10if(e>=n.start&&e<n.end)return n;e<n.start?i=r-1:s=r+1}return null}getMasterBar(e){if(!this.masterBarLookup.has(e.index)){const t=new Fo;return t.masterBar=e,t}return this.masterBarLookup.get(e.index)}getMasterBarStart(e){return this.masterBarLookup.has(e.index)?this.masterBarLookup.get(e.index).start:0}getBeatStart(e){return this.masterBarLookup.has(e.voice.bar.index)?this.masterBarLookup.get(e.voice.bar.index).start+e.playbackStart:0}addMasterBar(e){this.masterBars.push(e),this._currentMasterBar&&(e.previousMasterBar=this._currentMasterBar,this._currentMasterBar.nextMasterBar=e),this._currentMasterBar=e,this.masterBarLookup.has(e.masterBar.index)||this.masterBarLookup.set(e.masterBar.index,e)}addBeat(e,t,s){const i=this._currentMasterBar;if(i)if(t<0&&i.previousMasterBar){const r=i.previousMasterBar.end-i.previousMasterBar.start,n=r+t,o=n+s;if(i.previousMasterBar.addBeat(e,n,n,s),o>r){const l=s+t;i.addBeat(e,t,0,l)}}else i.addBeat(e,t,t,s)}}class Ec{noteOnly=0;untilTieOrSlideEnd=0;letRingEnd=0;beatDurationFactor=1}class vc{firstBeatDuration=0;secondBeatStartOffset=0;secondBeatDuration=0}class Dc{durations=[];brushInfos=[]}class Lc{synthTick=0;synthTime=0;currentTempo=0;automationToSyncPoint=new Map;syncPoints;createNewSyncPoints=!1}class Ne{static _defaultDurationDead=30;static _defaultDurationPalmMute=80;_score;_settings;_handler;_programsPerChannel=new Map;_currentTime=0;_calculatedBeatTimers=new Set;tickLookup=new ih;applyTranspositionPitches=!0;syncPoints=[];transpositionPitches=new Map;constructor(e,t,s){this._score=e,this._settings=t||new di,this._handler=s}generate(){this.transpositionPitches.clear(),this._calculatedBeatTimers.clear(),this._currentTime=0;for(const e of this._score.tracks)this._generateTrack(e);E.debug("Midi","Begin midi generation"),this.syncPoints=[],Ne._playThroughSong(this._score,this.syncPoints,!1,(e,t,s,i,r)=>{this._generateMasterBar(e,t,s,i,r),e.index===0&&r===0&&this._detectTickShift()},(e,t,s)=>{for(const i of this._score.tracks)for(const r of i.staves)e<r.bars.length&&this._generateBar(r.bars[e],t,s)},e=>{for(const t of this._score.tracks)this._handler.finishTrack(t.index,e)}),E.debug("Midi","Midi generation done")}_detectTickShift(){let e=0;for(const t of this._score.tracks)for(const s of t.staves)for(const i of s.bars[0].voices)if(!i.isEmpty){const r=i.beats[0];r.playbackStart<e&&(e=r.playbackStart)}e=Math.abs(e),this._handler.addTickShift(e)}_generateTrack(e){this._generateChannel(e,e.playbackInfo.primaryChannel,e.playbackInfo),e.playbackInfo.primaryChannel!==e.playbackInfo.secondaryChannel&&this._generateChannel(e,e.playbackInfo.secondaryChannel,e.playbackInfo)}_addProgramChange(e,t,s,i){(!this._programsPerChannel.has(s)||this._programsPerChannel.get(s)!==i)&&(this._handler.addProgramChange(e.index,t,s,i),this._programsPerChannel.set(s,i))}_addBankChange(e,t,s,i){const r=Ss.bankToLsbMsb(i);this._handler.addControlChange(e.index,t,s,et.BankSelectCoarse,r[1]),this._handler.addControlChange(e.index,t,s,et.BankSelectFine,r[0])}static buildTranspositionPitches(e,t){const s=new Map;for(const i of e.tracks){const r=i.index<t.notation.transpositionPitches.length?t.notation.transpositionPitches[i.index]:-i.staves[0].transpositionPitch;s.set(i.playbackInfo.primaryChannel,r),s.set(i.playbackInfo.secondaryChannel,r)}return s}_generateChannel(e,t,s){const i=e.index<this._settings.notation.transpositionPitches.length?this._settings.notation.transpositionPitches[e.index]:-e.staves[0].transpositionPitch;this.transpositionPitches.set(t,i);const r=Ne._toChannelShort(s.volume),n=Ne._toChannelShort(s.balance);this._handler.addControlChange(e.index,0,t,et.VolumeCoarse,r),this._handler.addControlChange(e.index,0,t,et.PanCoarse,n),this._handler.addControlChange(e.index,0,t,et.ExpressionControllerCoarse,127),this._handler.addControlChange(e.index,0,t,et.RegisteredParameterFine,0),this._handler.addControlChange(e.index,0,t,et.RegisteredParameterCourse,0),this._handler.addControlChange(e.index,0,t,et.DataEntryFine,0),this._handler.addControlChange(e.index,0,t,et.DataEntryCoarse,Ne._pitchBendRangeInSemitones),this._addBankChange(e,0,t,s.bank),this._addProgramChange(e,0,t,s.program)}static generateSyncPoints(e,t=!1){const s=[];return Ne._playThroughSong(e,s,t,(i,r,n,o,l)=>{},(i,r,n)=>{},i=>{}),s}static buildModifiedTempoLookup(e){const t=[];return Ne._playThroughSong(e,t,!1,(i,r,n,o,l)=>{},(i,r,n)=>{},i=>{}).automationToSyncPoint}static _playThroughSong(e,t,s,i,r,n){const o=new Pc(e),l=new Lc;l.currentTempo=e.tempo,l.syncPoints=t,l.createNewSyncPoints=s;let h=null;const c=new Map;for(;!o.finished;){const d=o.index,f=e.masterBars[d],p=o.currentTick;if(o.processCurrent(),o.shouldPlay){let g=c.has(d)?c.get(d):-1;g++,c.set(d,g),i(f,h,p,l.currentTempo,g);const m=f.tempoAutomations.length>0?f.tempoAutomations[0].value:l.currentTempo;r(d,p,m),l.synthTick=p,Ne._processBarTime(f,g,l)}o.moveNext(),h=f}if(t.length>0){const d=t[t.length-1],f=o.currentTick-d.synthTick;if(f>0){const p=new lr;p.masterBarIndex=h.index,p.masterBarOccurence=c.get(h.index)-1,p.synthTick=o.currentTick,p.synthBpm=l.currentTempo,l.createNewSyncPoints?(p.syncBpm=d.synthBpm,p.synthBpm=d.synthBpm):t.length===1?p.syncBpm=d.synthBpm:p.syncBpm=t[t.length-2].syncBpm,p.synthTime=d.synthTime+B.ticksToMillis(f,d.synthBpm),p.syncTime=d.syncTime+B.ticksToMillis(f,p.syncBpm),l.createNewSyncPoints||d.updateSyncBpm(p.synthTime,p.syncTime),t.push(p)}}return n(o.currentTick),l}static _processBarTime(e,t,s){const i=e.calculateDuration(),r=e.syncPoints,n=s.synthTick;s.createNewSyncPoints?Ne._processBarTimeWithNewSyncPoints(e,t,s):r?Ne._processBarTimeWithSyncPoints(e,t,s):Ne._processBarTimeNoSyncPoints(e,s);const o=n+i,l=o-s.synthTick;l>0&&(s.synthTime+=B.ticksToMillis(l,s.currentTempo),s.synthTick=o)}static _processBarTimeWithNewSyncPoints(e,t,s){const i=s.synthTick;if(e.index===0&&t===0){s.currentTempo=e.score.tempo;const n=new lr;n.masterBarIndex=e.index,n.masterBarOccurence=t,n.synthTick=i,n.synthBpm=s.currentTempo,n.synthTime=s.synthTime,n.syncBpm=s.currentTempo,n.syncTime=s.synthTime,s.syncPoints.push(n)}const r=e.calculateDuration();for(const n of e.tempoAutomations){const o=i+n.ratioPosition*r,l=o-s.synthTick;if(l>0&&(s.synthTick=o,s.synthTime+=B.ticksToMillis(l,s.currentTempo)),n.value!==s.currentTempo){s.currentTempo=n.value;const h=new lr;h.masterBarIndex=e.index,h.masterBarOccurence=t,h.synthTick=o,h.synthBpm=s.currentTempo,h.synthTime=s.synthTime,h.syncBpm=s.currentTempo,h.syncTime=s.synthTime,s.syncPoints.push(h)}}}static _processBarTimeWithSyncPoints(e,t,s){const i=s.synthTick,r=e.calculateDuration();let n=0,o;for(const l of e.syncPoints){if(l.syncPointValue.barOccurence!==t)continue;const h=i+l.ratioPosition*r;for(;n<e.tempoAutomations.length&&e.tempoAutomations[n].ratioPosition<=l.ratioPosition;){const d=e.tempoAutomations[n],f=i+d.ratioPosition*r;o=f-s.synthTick,o>0&&(s.synthTick=f,s.synthTime+=B.ticksToMillis(o,s.currentTempo)),s.currentTempo=d.value,n++}o=h-s.synthTick,o>0&&(s.synthTick=h,s.synthTime+=B.ticksToMillis(o,s.currentTempo)),s.syncPoints.length>0&&s.syncPoints[s.syncPoints.length-1].updateSyncBpm(s.synthTime,l.syncPointValue.millisecondOffset);const c=new lr;c.masterBarIndex=e.index,c.masterBarOccurence=t,c.synthTick=h,c.synthBpm=s.currentTempo,c.synthTime=s.synthTime,c.syncTime=l.syncPointValue.millisecondOffset,c.syncBpm=0,s.syncPoints.push(c),s.automationToSyncPoint.set(l,c)}for(;n<e.tempoAutomations.length;){const l=e.tempoAutomations[n],h=i+l.ratioPosition*r;o=h-s.synthTick,o>0&&(s.synthTick=h,s.synthTime+=B.ticksToMillis(o,s.currentTempo)),s.currentTempo=l.value,n++}}static _processBarTimeNoSyncPoints(e,t){const s=t.synthTick,i=e.calculateDuration();for(const r of e.tempoAutomations){const n=s+r.ratioPosition*i,o=n-t.synthTick;o>0&&(t.synthTick=n,t.synthTime+=B.ticksToMillis(o,t.currentTempo)),t.currentTempo=r.value}}static _toChannelShort(e){const t=Math.max(-32768,Math.min(32767,e*8-1));return Math.max(t,-1)+1}_generateMasterBar(e,t,s,i,r){(!t||t.timeSignatureDenominator!==e.timeSignatureDenominator||t.timeSignatureNumerator!==e.timeSignatureNumerator)&&this._handler.addTimeSignature(s,e.timeSignatureNumerator,e.timeSignatureDenominator);const n=e.calculateDuration(),o=new Fo;if(e.tempoAutomations.length>0){e.tempoAutomations[0].ratioPosition>0&&o.tempoChanges.push(new Dr(s,i));for(const l of e.tempoAutomations){const h=s+n*l.ratioPosition;this._handler.addTempo(h,l.value),o.tempoChanges.push(new Dr(h,l.value))}}else t?o.tempoChanges.push(new Dr(s,i)):(this._handler.addTempo(s,e.score.tempo),o.tempoChanges.push(new Dr(s,e.score.tempo)));o.masterBar=e,o.start=s,o.end=o.start+n,this.tickLookup.addMasterBar(o)}_generateBar(e,t,s){const i=this._getPlaybackBar(e),r=this._currentTime;for(const h of i.voices)this._currentTime=r,this._generateVoice(h,t,e,s);const n=i.masterBar,o=n.calculateDuration(),l=n.tempoAutomations.slice();if(l.length===0)this._currentTime=r+B.ticksToMillis(o,s);else{this._currentTime=r;let h=t,c=s;const d=t+o;for(const p of l){const m=o*p.ratioPosition-h;m>0&&(this._currentTime+=B.ticksToMillis(m,c)),c=p.value,h+=m}const f=d-h;f>0&&(this._currentTime+=B.ticksToMillis(f,c))}i.id!==e.id&&this.tickLookup.addBeat(e.voices[0].beats[0],0,o)}_getPlaybackBar(e){switch(e.simileMark){case xt.Simple:e.previousBar&&(e=this._getPlaybackBar(e.previousBar));break;case xt.FirstOfDouble:e.previousBar&&e.previousBar.previousBar&&(e=this._getPlaybackBar(e.previousBar.previousBar));break;case xt.SecondOfDouble:e.previousBar&&e.previousBar.previousBar&&(e=this._getPlaybackBar(e.previousBar.previousBar));break}return e}_generateVoice(e,t,s,i){if(e.isEmpty&&(!e.bar.isEmpty||e.index!==0))return;const r=s.masterBar.tempoAutomations.slice();let n=i;const o=s.masterBar.calculateDuration();for(const l of e.beats){const h=l.playbackStart/o;for(;r.length>0&&r[0].ratioPosition<=h;)n=r.shift().value;this._generateBeat(l,t,s,n)}}_currentTripletFeel=null;_generateBeat(e,t,s,i){let r=e.playbackStart,n=e.playbackDuration;const o=e.voice.bar.masterBar.calculateDuration();e.voice.bar.isEmpty?n=o:e.voice.bar.masterBar.tripletFeel!==Ce.NoTripletFeel&&this._settings.player.playTripletFeel&&(this._currentTripletFeel?(r-=this._currentTripletFeel.secondBeatStartOffset,n=this._currentTripletFeel.secondBeatDuration,this._currentTripletFeel=null):(this._currentTripletFeel=Ne._calculateTripletFeelInfo(r,n,e),this._currentTripletFeel&&(n=this._currentTripletFeel.firstBeatDuration))),e.showTimer&&!this._calculatedBeatTimers.has(e.id)&&(e.timer=this._currentTime,this._calculatedBeatTimers.add(e.id)),this._currentTime+=B.ticksToMillis(n,i),s===e.voice.bar&&this.tickLookup.addBeat(e,r,n);const l=e.voice.bar.staff.track;for(const h of e.automations)this._generateNonTempoAutomation(e,h,t);if(e.isRest)this._handler.addRest(l.index,t+r,l.playbackInfo.primaryChannel);else if(e.deadSlapped)this._generateDeadSlap(e,t+r);else{const h=this._getBrushInfo(e),c=this._getRasgueadoInfo(e,n);for(const d of e.notes)this._generateNote(d,t+r,n,i,h,c)}if(e.fade!==yt.None&&this._generateFade(e,t+r,n),e.vibrato!==Be.None){let h=240,c=3;switch(e.vibrato){case Be.Slight:h=this._settings.player.vibrato.beatSlightLength,c=this._settings.player.vibrato.beatSlightAmplitude;break;
10case Be.Wide:h=this._settings.player.vibrato.beatWideLength,c=this._settings.player.vibrato.beatWideAmplitude;break}this._generateVibratorWithParams(t+r,e.playbackDuration,h,0,c,(d,f)=>{this._handler.addBend(e.voice.bar.staff.track.index,d,l.playbackInfo.secondaryChannel,f)})}}static _calculateTripletFeelInfo(e,t,s){let i;switch(s.voice.bar.masterBar.tripletFeel){case Ce.Triplet8th:case Ce.Dotted8th:case Ce.Scottish8th:i=y.Eighth;break;case Ce.Triplet16th:case Ce.Dotted16th:case Ce.Scottish16th:i=y.Sixteenth;break;default:return null}const r=B.toTicks(i);if(t!==r||e%r!==0||!s.nextBeat||s.nextBeat.voice!==s.voice||s.playbackDuration!==r)return null;const n=new vc;switch(s.voice.bar.masterBar.tripletFeel){case Ce.Triplet8th:n.firstBeatDuration=B.applyTuplet(B.toTicks(y.Quarter),3,2),n.secondBeatDuration=B.applyTuplet(B.toTicks(y.Eighth),3,2);break;case Ce.Dotted8th:n.firstBeatDuration=B.applyDot(B.toTicks(y.Eighth),!1),n.secondBeatDuration=B.toTicks(y.Sixteenth);break;case Ce.Scottish8th:n.firstBeatDuration=B.toTicks(y.Sixteenth),n.secondBeatDuration=B.applyDot(B.toTicks(y.Eighth),!1);break;case Ce.Triplet16th:n.firstBeatDuration=B.applyTuplet(B.toTicks(y.Eighth),3,2),n.secondBeatDuration=B.applyTuplet(B.toTicks(y.Sixteenth),3,2);break;case Ce.Dotted16th:n.firstBeatDuration=B.applyDot(B.toTicks(y.Sixteenth),!1),n.secondBeatDuration=B.toTicks(y.ThirtySecond);break;case Ce.Scottish16th:n.firstBeatDuration=B.toTicks(y.ThirtySecond),n.secondBeatDuration=B.applyDot(B.toTicks(y.Sixteenth),!1);break}return n.secondBeatStartOffset=t-n.firstBeatDuration,n}_generateDeadSlap(e,t){const s=B.toTicks(y.SixtyFourth),i=e.voice.bar.staff;if(i.tuning.length>0)for(const r of i.tuning)this._handler.addNote(i.track.index,t,s,r,B.dynamicToVelocity(se.F),i.track.playbackInfo.primaryChannel)}_needsSecondaryChannel(e){return e.hasBend||e.beat.hasWhammyBar||e.beat.vibrato!==Be.None}_determineChannel(e,t){if(this._needsSecondaryChannel(t))return e.playbackInfo.secondaryChannel;let s=t;for(;s.isTieDestination;)if(s=s.tieOrigin,this._needsSecondaryChannel(s))return e.playbackInfo.secondaryChannel;for(s=t;s.isTieOrigin;)if(s=s.tieDestination,this._needsSecondaryChannel(s))return e.playbackInfo.secondaryChannel;return e.playbackInfo.primaryChannel}_generateNote(e,t,s,i,r,n){const o=e.beat.voice.bar.staff.track,l=e.beat.voice.bar.staff;let h=e.calculateRealValue(this.applyTranspositionPitches,!0);if(e.isPercussion){const S=Xe.getArticulation(e);S&&(h=S.outputMidiNumber)}const c=n==null&&e.isStringed&&e.string<=r.length?r[e.string-1]:0,d=t+c,f=this._getNoteDuration(e,s,i);f.untilTieOrSlideEnd-=c,f.noteOnly-=c,f.letRingEnd-=c;const p=Ne._getNoteVelocity(e),g=this._determineChannel(o,e);let m=0;const b=Math.max(f.untilTieOrSlideEnd,f.letRingEnd);if(e.hasBend?m=Ne.getPitchWheel(e.bendPoints[0].value):e.beat.hasWhammyBar?m=Ne.getPitchWheel(e.beat.whammyBarPoints[0].value):e.isTieDestination||e.slideOrigin&&e.slideOrigin.slideOutType===he.Legato?m=-1:m=Ne.getPitchWheel(0),m>=0&&this._handler.addNoteBend(o.index,d,g,h,m),e.beat.hasRasgueado){this._generateRasgueado(o,e,d,h,p,g,n);return}if(e.ornament!==ot.None){this._generateOrnament(o,e,d,b,h,p,g);return}if(e.isTrill&&!l.isPercussion){this._generateTrill(e,d,f,h,p,g);return}if(e.beat.isTremolo){this._generateTremoloPicking(e,d,f,h,p,g);return}e.hasBend?this._generateBend(e,d,f,h,g,i):e.beat.hasWhammyBar&&e.index===0?this._generateWhammy(e.beat,d,f,g,i):e.slideInType!==St.None||e.slideOutType!==he.None?this._generateSlide(e,d,f,h,g,i):(e.vibrato!==Be.None||e.isTieDestination&&e.tieOrigin.vibrato!==Be.None)&&this._generateVibrato(e,d,f,h,g),!e.isTieDestination&&(!e.slideOrigin||e.slideOrigin.slideOutType!==he.Legato)&&this._handler.addNote(o.index,d,b,h,p,g)}static _ornamentKeysUp=[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];_generateOrnament(e,t,s,i,r,n,o){let l,h;const c=r%12,d=1/3;switch(t.ornament){case ot.Turn:l=[r+Ne._ornamentKeysUp[c],r,r+Ne.ornamentKeysDown[c]],h=[B.toTicks(y.Sixteenth)*d,B.toTicks(y.Sixteenth)*d,B.toTicks(y.Sixteenth)*d];break;case ot.InvertedTurn:l=[r+Ne.ornamentKeysDown[c],r,r+Ne._ornamentKeysUp[c]],h=[B.toTicks(y.Sixteenth)*d,B.toTicks(y.Sixteenth)*d,B.toTicks(y.Sixteenth)*d];break;case ot.UpperMordent:l=[r,r+Ne._ornamentKeysUp[c]],h=[B.toTicks(y.ThirtySecond),B.toTicks(y.ThirtySecond)];break;case ot.LowerMordent:l=[r,r+Ne.ornamentKeysDown[c]],h=[B.toTicks(y.ThirtySecond),B.toTicks(y.ThirtySecond)];break;default:return}let f=1;i<B.QuarterTime&&(f=i/B.QuarterTime),n-=B.VelocityIncrement;let p=0;for(let m=0;m<l.length;m++){const b=h[m]*f;this._handler.addNote(e.index,s,b,l[m],n,o),s+=b,p+=b}const g=i-p;this._handler.addNote(e.index,s,g,r,n,o)}_getNoteDuration(e,t,s){const i=new Ec,r=B.toTicks(e.beat.duration);if(i.beatDurationFactor=t/r,i.noteOnly=t,i.untilTieOrSlideEnd=t,i.letRingEnd=t,e.isDead)return i.noteOnly=this._applyStaticDuration(Ne._defaultDurationDead,t,s),i.untilTieOrSlideEnd=i.noteOnly,i.letRingEnd=i.noteOnly,i;if(e.isPalmMute)return i.noteOnly=this._applyStaticDuration(Ne._defaultDurationPalmMute,t,s),i.untilTieOrSlideEnd=i.noteOnly,i.letRingEnd=i.noteOnly,i;if(e.isStaccato)return i.noteOnly=t/2|0,i.untilTieOrSlideEnd=i.noteOnly,i.letRingEnd=i.noteOnly,i;if(e.isTieOrigin){const n=e.tieDestination;if(n)if(e.isTieDestination){const o=this._getNoteDuration(n,n.beat.playbackDuration,s);i.untilTieOrSlideEnd=t+o.untilTieOrSlideEnd}else{const o=e.beat.absolutePlaybackStart,l=this._getNoteDuration(n,n.beat.playbackDuration,s),h=n.beat.absolutePlaybackStart+l.untilTieOrSlideEnd;i.untilTieOrSlideEnd=h-o}}else if(e.slideOutType===he.Legato){const n=e.slideTarget;if(n){const o=e.beat.absolutePlaybackStart,l=this._getNoteDuration(n,n.beat.playbackDuration,s),h=n.beat.absolutePlaybackStart+l.untilTieOrSlideEnd;i.untilTieOrSlideEnd=h-o}}if(e.isLetRing&&this._settings.notation.notationMode===Vt.GuitarPro){let n=e.beat,o=0;const l=e.beat.voice.bar.masterBar.calculateDuration();for(;n.nextBeat;){const h=n.nextBeat;
vendor: 13,785 bytes, line 10
10if(h.isRest||e.isStringed&&h.hasNoteOnString(e.string))break;if(n=n.nextBeat,o=n.absolutePlaybackStart-e.beat.absolutePlaybackStart+n.playbackDuration,o>l){o=l;break}}n===e.beat?i.letRingEnd=t:i.letRingEnd=o}else i.letRingEnd=i.untilTieOrSlideEnd;return i}_applyStaticDuration(e,t,s){const i=s*e/G.MaxPosition|0;return Math.min(i,t)}static _getNoteVelocity(e){let t=0;switch(!e.beat.voice.bar.staff.isPercussion&&e.hammerPullOrigin&&t--,e.isGhost&&t--,e.accentuated){case ct.Normal:t++;break;case ct.Heavy:t+=2;break}return B.dynamicToVelocity(e.dynamics,t)}_generateFade(e,t,s){const i=e.voice.bar.staff.track;switch(e.fade){case yt.FadeIn:this._generateFadeSteps(i,t,s,0,Ne._toChannelShort(i.playbackInfo.volume));break;case yt.FadeOut:this._generateFadeSteps(i,t,s,Ne._toChannelShort(i.playbackInfo.volume),0);break;case yt.VolumeSwell:const r=s/2|0;this._generateFadeSteps(i,t,r,0,Ne._toChannelShort(i.playbackInfo.volume)),this._generateFadeSteps(i,t+r,r,Ne._toChannelShort(i.playbackInfo.volume),0);break}}_generateFadeSteps(e,t,s,i,r){s=s*.8|0;const o=(r-i)/s,l=s/120+1|0,h=t+s;for(let c=0;c<l;c++){const d=c===l-1,f=d?h:t+c*120,p=d?r:Math.round(i+(f-t)*o);this._handler.addControlChange(e.index,f,e.playbackInfo.primaryChannel,et.VolumeCoarse,p),this._handler.addControlChange(e.index,f,e.playbackInfo.secondaryChannel,et.VolumeCoarse,p)}}_generateVibrato(e,t,s,i,r){let n=0,o=0;switch(e.vibrato!==Be.None?e.vibrato:e.isTieDestination?e.tieOrigin.vibrato:Be.Slight){case Be.Slight:n=this._settings.player.vibrato.noteSlightLength,o=this._settings.player.vibrato.noteSlightAmplitude;break;case Be.Wide:n=this._settings.player.vibrato.noteWideLength,o=this._settings.player.vibrato.noteWideAmplitude;break;default:return}const h=e.beat.voice.bar.staff.track;let c=0;if(e.isTieDestination&&e.tieOrigin.hasBend){const d=e.tieOrigin.bendPoints;c=d[d.length-1].value}this._generateVibratorWithParams(t,s.noteOnly,n,c,o,(d,f)=>{this._handler.addNoteBend(h.index,d,r,i,f)})}vibratoResolution=16;_generateVibratorWithParams(e,t,s,i,r,n){const o=this.vibratoResolution,l=s/2|0,h=e+t;for(;e<h;){let c=0;const d=e+s<h?s:h-e;for(;c<d;){const f=i+r*Math.sin(c*Math.PI/l);n(e+c|0,Ne.getPitchWheel(f)),c+=o}e+=s}n(h|0,Ne.getPitchWheel(i))}static _pitchBendRangeInSemitones=16;static _pitchValuePerSemitone=de.DefaultPitchWheel/Ne._pitchBendRangeInSemitones;static _minBreakpointsPerSemitone=6;static _millisecondsPerBreakpoint=150;static getPitchWheel(e){return de.DefaultPitchWheel+e/2*Ne._pitchValuePerSemitone}_generateSlide(e,t,s,i,r,n){const o=e.slideOutType===he.Legato?s.noteOnly:s.untilTieOrSlideEnd,l=[],h=e.beat.voice.bar.staff.track,c=this._settings.player.slide.simpleSlidePitchOffset,d=Math.floor(G.MaxPosition*this._settings.player.slide.simpleSlideDurationRatio),f=Math.floor(G.MaxPosition*this._settings.player.slide.shiftSlideDurationRatio);switch(e.slideInType){case St.IntoFromAbove:l.push(new G(0,c)),l.push(new G(d,0));break;case St.IntoFromBelow:l.push(new G(0,-c)),l.push(new G(d,0));break}switch(e.slideOutType){case he.Legato:case he.Shift:l.push(new G(f,0));const p=(e.slideTarget.calculateRealValue(this.applyTranspositionPitches,!0)-e.calculateRealValue(this.applyTranspositionPitches,!0))*2;l.push(new G(G.MaxPosition,p));break;case he.OutDown:l.push(new G(G.MaxPosition-d,0)),l.push(new G(G.MaxPosition,-c));break;case he.OutUp:l.push(new G(G.MaxPosition-d,0)),l.push(new G(G.MaxPosition,c));break}this._generateWhammyOrBend(t,o,l,n,(p,g)=>{this._handler.addNoteBend(h.index,p,r,i,g)})}_generateBend(e,t,s,i,r,n){const o=e.bendPoints,l=e.beat.voice.bar.staff.track,h=(g,m)=>{this._handler.addNoteBend(l.index,g,r,i,m)};let c=null,d;if(e.isTieOrigin&&this._settings.notation.extendBendArrowsOnTiedNotes){let g=e;for(;g.isTieOrigin&&!g.tieDestination.hasBend&&g.tieDestination.vibrato===Be.None;)g=g.tieDestination;d=g.beat.absolutePlaybackStart-e.beat.absolutePlaybackStart+this._getNoteDuration(g,g.beat.playbackDuration,n).noteOnly}else if(e.isTieOrigin&&e.beat.graceType!==K.None){switch(e.tieDestination.bendType){case $.Bend:case $.BendRelease:case $.PrebendBend:c=e.tieDestination.bendPoints[1].value;break;case $.Prebend:case $.PrebendRelease:c=e.tieDestination.bendPoints[0].value;break}d=Math.max(s.noteOnly,B.millisToTicks(this._settings.player.songBookBendDuration,n))}else d=s.noteOnly;o[0].value>0&&!e.isContinuedBend&&t>0&&t--;const f=Math.min(d,B.millisToTicks(this._settings.player.songBookBendDuration,n));let p=[];switch(e.bendType){case $.Custom:p=o;break;case $.Bend:case $.Release:switch(e.bendStyle){case Ke.Default:p=o;break;case Ke.Gradual:p.push(new G(0,e.bendPoints[0].value)),(!c||c<e.bendPoints[1].value)&&(c=e.bendPoints[1].value),p.push(new G(G.MaxPosition,c));break;case Ke.Fast:(!c||c<e.bendPoints[1].value)&&(c=e.bendPoints[1].value),e.beat.graceType===K.BendGrace?this._generateSongBookWhammyOrBend(t,d,!0,[e.bendPoints[0].value,c],f,n,h):this._generateSongBookWhammyOrBend(t,d,!1,[e.bendPoints[0].value,c],f,n,h);return}break;case $.BendRelease:switch(e.bendStyle){case Ke.Default:p=o;break;case Ke.Gradual:p.push(new G(0,e.bendPoints[0].value)),p.push(new G(G.MaxPosition/2|0,e.bendPoints[1].value)),p.push(new G(G.MaxPosition,e.bendPoints[2].value));break;case Ke.Fast:this._generateSongBookWhammyOrBend(t,d,!1,[e.bendPoints[0].value,e.bendPoints[1].value,e.bendPoints[2].value],f,n,h);return}break;case $.Hold:p=o;break;case $.Prebend:p=o;break;case $.PrebendBend:switch(e.bendStyle){case Ke.Default:p=o;break;case Ke.Gradual:p.push(new G(0,e.bendPoints[0].value)),p.push(new G(G.MaxPosition,e.bendPoints[1].value));break;case Ke.Fast:const g=Ne.getPitchWheel(e.bendPoints[0].value);h(t,g|0),(!c||c<e.bendPoints[1].value)&&(c=e.bendPoints[1].value),this._generateSongBookWhammyOrBend(t,d,!1,[e.bendPoints[0].value,c],f,n,h);return}break;case $.PrebendRelease:switch(e.bendStyle){case Ke.Default:p=o;break;case Ke.Gradual:p.push(new G(0,e.bendPoints[0].value)),p.push(new G(G.MaxPosition,e.bendPoints[1].value));break;case Ke.Fast:const g=Ne.getPitchWheel(e.bendPoints[0].value);h(t,g|0),this._generateSongBookWhammyOrBend(t,d,!1,[e.bendPoints[0].value,e.bendPoints[1].value],f,n,h);return}break}this._generateWhammyOrBend(t,d,p,n,h)}_generateSongBookWhammyOrBend(e,t,s,i,r,n,o){const l=s?e:e+t-r,h=r/(i.length-1);for(let c=0;c<i.length-1;c++){const d=Ne.getPitchWheel(i[c]),f=Ne.getPitchWheel(i[c+1]),p=l+h*c;this._generateBendValues(p,h,d,f,n,o)}}_generateWhammy(e,t,s,i,r){const n=e.whammyBarPoints,o=e.voice.bar.staff.track,l=s.noteOnly;n[0].value>0&&!e.isContinuedWhammy&&t--;const h=(d,f)=>{this._handler.addBend(o.index,d,i,f)};let c=[];switch(e.whammyBarType){case Pe.Custom:c=n;break;case Pe.Dive:switch(e.whammyStyle){case Ke.Default:c=n;break;case Ke.Gradual:c.push(new G(0,n[0].value)),c.push(new G(G.MaxPosition,n[1].value));break;case Ke.Fast:const d=Math.min(l,B.millisToTicks(this._settings.player.songBookBendDuration,r));this._generateSongBookWhammyOrBend(t,l,!1,[n[0].value,n[1].value],d,r,h);return}break;case Pe.Dip:switch(e.whammyStyle){case Ke.Default:c=n;break;case Ke.Gradual:c.push(new G(0,n[0].value)),c.push(new G(G.MaxPosition/2|0,n[1].value)),c.push(new G(G.MaxPosition,n[2].value));break;case Ke.Fast:const d=Math.min(l,B.millisToTicks(this._settings.player.songBookDipDuration,r));this._generateSongBookWhammyOrBend(t,l,!0,[n[0].value,n[1].value,n[2].value],d,r,h);return}break;case Pe.Hold:c=n;break;case Pe.Predive:c=n;break;case Pe.PrediveDive:switch(e.whammyStyle){case Ke.Default:c=n;break;case Ke.Gradual:c.push(new G(0,n[0].value)),c.push(new G(G.MaxPosition/2|0,n[0].value)),c.push(new G(G.MaxPosition,n[1].value));break;case Ke.Fast:const d=Ne.getPitchWheel(n[0].value);this._handler.addBend(o.index,t,i,d|0);const f=Math.min(l,B.millisToTicks(this._settings.player.songBookBendDuration,r));this._generateSongBookWhammyOrBend(t,l,!1,[n[0].value,n[1].value],f,r,h);return}break}this._generateWhammyOrBend(t,l,c,r,h)}_generateWhammyOrBend(e,t,s,i,r){const n=t/G.MaxPosition;for(let o=0;o<s.length-1;o++){const l=s[o],h=s[o+1],c=Ne.getPitchWheel(l.value),d=Ne.getPitchWheel(h.value),f=n*(h.offset-l.offset),p=e+n*l.offset;this._generateBendValues(p,f,c,d,i,r)}}_generateBendValues(e,t,s,i,r,n){const o=B.ticksToMillis(t,r),l=Math.abs(i-s)/Ne._pitchValuePerSemitone,h=Math.max(Ne._minBreakpointsPerSemitone*l,o/Ne._millisecondsPerBreakpoint),c=t/h,d=(i-s)/h,f=e+t;for(let p=0;p<h;p++)n(e|0,Math.round(s)),s+=d,e+=c;n(f|0,i)}_generateRasgueado(e,t,s,i,r,n,o){let l=s;for(let h=0;h<o.durations.length;h++){const c=o.brushInfos[h],d=t.isStringed&&t.string<=c.length?c[t.string-1]:0,f=o.durations[h];this._handler.addNote(e.index,l+d,f-d,i,r,n),l+=f}}_generateTrill(e,t,s,i,r,n){const o=e.beat.voice.bar.staff.track,l=e.stringTuning+e.trillFret;let h=B.toTicks(e.trillSpeed),c=!0,d=t;const f=t+s.untilTieOrSlideEnd;for(;d+10<f;)d+h>=f&&(h=f-d),this._handler.addNote(o.index,d,h,c?i:l,r,n),c=!c,d+=h}_generateTremoloPicking(e,t,s,i,r,n){const o=e.beat.voice.bar.staff.track;if(e.beat.tremoloPicking.marks===0)return;let h=e.beat.tremoloPicking.getDurationAsTicks(e.beat.duration)*s.beatDurationFactor,c=t;const d=t+s.untilTieOrSlideEnd;for(;c+10<d;)c+h>=d&&(h=d-c),this._handler.addNote(o.index,c,h,i,r,n),c+=h}static _rasgueadoDirections=new Map([[ne.Ii,[z.BrushDown,z.BrushUp]],[ne.Mi,[z.BrushDown,z.BrushDown]],[ne.MiiTriplet,[z.BrushDown,z.BrushDown,z.BrushUp]],[ne.MiiAnapaest,[z.BrushDown,z.BrushDown,z.BrushUp]],[ne.PmpTriplet,[z.BrushUp,z.BrushDown,z.BrushDown]],[ne.PmpAnapaest,[z.BrushUp,z.BrushDown,z.BrushDown]],[ne.PeiTriplet,[z.BrushUp,z.BrushDown,z.BrushDown]],[ne.PeiAnapaest,[z.BrushUp,z.BrushDown,z.BrushDown]],[ne.PaiTriplet,[z.BrushUp,z.BrushDown,z.BrushDown]],[ne.PaiAnapaest,[z.BrushUp,z.BrushDown,z.BrushDown]],[ne.AmiTriplet,[z.BrushDown,z.BrushDown,z.BrushDown]],[ne.AmiAnapaest,[z.BrushDown,z.BrushDown,z.BrushDown]],[ne.Ppp,[z.None,z.BrushDown,z.BrushUp]],[ne.Amii,[z.BrushDown,z.BrushDown,z.BrushDown,z.BrushUp]],[ne.Amip,[z.BrushDown,z.BrushDown,z.BrushDown,z.BrushUp]],[ne.Eami,[z.BrushDown,z.BrushDown,z.BrushDown,z.BrushDown]],[ne.Eamii,[z.BrushDown,z.BrushDown,z.BrushDown,z.BrushDown,z.BrushUp]],[ne.Peami,[z.BrushDown,z.BrushDown,z.BrushDown,z.BrushDown,z.BrushUp]]]);static _rasgueadoDurations=new Map([[ne.Ii,[B.toTicks(y.Eighth),B.toTicks(y.Eighth)]],[ne.Mi,[B.toTicks(y.Eighth),B.toTicks(y.Eighth)]],[ne.MiiTriplet,[B.toTicks(y.Eighth)/3,B.toTicks(y.Eighth)/3,B.toTicks(y.Eighth)/3]],[ne.MiiAnapaest,[B.toTicks(y.Sixteenth),B.toTicks(y.Sixteenth),B.toTicks(y.Eighth)]],[ne.PmpTriplet,[B.toTicks(y.Eighth)/3,B.toTicks(y.Eighth)/3,B.toTicks(y.Eighth)/3]],[ne.PmpAnapaest,[B.toTicks(y.Sixteenth)/3,B.toTicks(y.Sixteenth)/3,B.toTicks(y.Eighth)/3]],[ne.PeiTriplet,[B.toTicks(y.Eighth)/3,B.toTicks(y.Eighth)/3,B.toTicks(y.Eighth)/3]],[ne.PeiAnapaest,[B.toTicks(y.Sixteenth),B.toTicks(y.Sixteenth),B.toTicks(y.Eighth)]],[ne.PaiTriplet,[B.toTicks(y.Eighth)/3,B.toTicks(y.Eighth)/3,B.toTicks(y.Eighth)/3]],[ne.PaiAnapaest,[B.toTicks(y.Sixteenth),B.toTicks(y.Sixteenth),B.toTicks(y.Eighth)]],[ne.AmiTriplet,[B.toTicks(y.Eighth)/3,B.toTicks(y.Eighth)/3,B.toTicks(y.Eighth)/3]],[ne.AmiAnapaest,[B.toTicks(y.Sixteenth)/3,B.toTicks(y.Sixteenth)/3,B.toTicks(y.Eighth)/3]],[ne.Ppp,[B.toTicks(y.Sixteenth)/3,B.toTicks(y.Sixteenth)/3,B.toTicks(y.Eighth)/3]],[ne.Amii,[B.toTicks(y.Sixteenth)/3,B.toTicks(y.Sixteenth)/3,B.toTicks(y.Sixteenth)/3,B.toTicks(y.Eighth)]],[ne.Amip,[B.toTicks(y.Sixteenth)/3,B.toTicks(y.Sixteenth)/3,B.toTicks(y.Sixteenth)/3,B.toTicks(y.Eighth)]],[ne.Eami,[B.toTicks(y.Sixteenth),B.toTicks(y.Sixteenth),B.toTicks(y.Sixteenth),B.toTicks(y.Sixteenth)]],[ne.Eamii,[B.toTicks(y.Sixteenth)/5,B.toTicks(y.Sixteenth)/5,B.toTicks(y.Sixteenth)/5,B.toTicks(y.Sixteenth)/5,B.toTicks(y.Sixteenth)/5]],[ne.Peami,[B.toTicks(y.Sixteenth)/5,B.toTicks(y.Sixteenth)/5,B.toTicks(y.Sixteenth)/5,B.toTicks(y.Sixteenth)/5,B.toTicks(y.Sixteenth)/5]]]);_getRasgueadoInfo(e,t){if(!e.hasRasgueado)return null;const s=new Dc,r=Ne._rasgueadoDurations.get(e.rasgueado).reduce((c,d)=>c+d,0);s.durations=Ne._rasgueadoDurations.get(e.rasgueado).map(c=>t*c/r),s.brushInfos=new Array(s.durations.length);const n=B.toTicks(y.Sixteenth);let o=0,l=0;for(const c of e.notes)c.isTieDestination||(o|=1<<c.string-1,l++);const h=Ne._rasgueadoDirections.get(e.rasgueado);for(let c=0;c<s.durations.length;c++){const d=s.durations[c]*n/B.QuarterTime,f=new Int32Array(e.voice.bar.staff.tuning.length);s.brushInfos[c]=f;const p=h[c];p!==z.None&&this._fillBrushInfo(e,f,p===z.ArpeggioDown||p===z.BrushDown,o,l,d)}return s}_getBrushInfo(e){const t=new Int32Array(e.voice.bar.staff.tuning.length);if(e.brushType){let s=0,i=0;for(const r of e.notes)r.isTieDestination||(s|=1<<r.string-1,i++);this._fillBrushInfo(e,t,e.brushType===z.ArpeggioDown||e.brushType===z.BrushDown,s,i,e.brushDuration)}return t}_fillBrushInfo(e,t,s,i,r,n){if(e.notes.length>0){let o=0;const l=n/(r-1)|0;for(let h=0;h<e.voice.bar.staff.tuning.length;h++){const c=s?h:t.length-1-h;(i&1<<c)!==0&&(t[c]=o,o+=l)}}return t}_generateNonTempoAutomation(e,t,s){switch(t.type){case Re.Instrument:this._addProgramChange(e.voice.bar.staff.track,e.playbackStart+s,e.voice.bar.staff.track.playbackInfo.primaryChannel,(t.value|0)&255),this._addProgramChange(e.voice.bar.staff.track,e.playbackStart+s,e.voice.bar.staff.track.playbackInfo.secondaryChannel,(t.value|0)&255);break;case Re.Bank:this._addBankChange(e.voice.bar.staff.track,e.playbackStart+s,e.voice.bar.staff.track.playbackInfo.primaryChannel,t.value),this._addBankChange(e.voice.bar.staff.track,e.playbackStart+s,e.voice.bar.staff.track.playbackInfo.secondaryChannel,t.value);break;case Re.Balance:const i=Ne._toChannelShort(t.value);this._handler.addControlChange(e.voice.bar.staff.track.index,e.playbackStart+s,e.voice.bar.staff.track.playbackInfo.primaryChannel,et.PanCoarse,i
10),this._handler.addControlChange(e.voice.bar.staff.track.index,e.playbackStart+s,e.voice.bar.staff.track.playbackInfo.secondaryChannel,et.PanCoarse,i);break;case Re.Volume:const r=Ne._toChannelShort(t.value);this._handler.addControlChange(e.voice.bar.staff.track.index,e.playbackStart+s,e.voice.bar.staff.track.playbackInfo.primaryChannel,et.VolumeCoarse,r),this._handler.addControlChange(e.voice.bar.staff.track.index,e.playbackStart+s,e.voice.bar.staff.track.playbackInfo.secondaryChannel,et.VolumeCoarse,r);break}}prepareSingleBeat(e){let t=-1,s=-1,i=e;for(;i&&(t===-1||s===-1);){for(const c of e.automations)switch(c.type){case Re.Instrument:s=c.value;break;case Re.Tempo:t=c.value;break}i=i.previousBeat}const r=e.voice.bar.staff.track,n=e.voice.bar.masterBar;t===-1&&(t=n.score.tempo);const o=e.playbackStart/n.calculateDuration();for(const c of n.tempoAutomations)if(c.ratioPosition<=o)t=c.value;else break;s===-1&&(s=r.playbackInfo.program);const l=r.playbackInfo.volume;this._generateTrack(r),this._handler.addTimeSignature(0,n.timeSignatureNumerator,n.timeSignatureDenominator),this._handler.addTempo(0,t);const h=Ne._toChannelShort(l);return this._handler.addControlChange(0,0,r.playbackInfo.primaryChannel,et.VolumeCoarse,h),this._handler.addControlChange(0,0,r.playbackInfo.secondaryChannel,et.VolumeCoarse,h),t}generateSingleBeat(e){const t=this.prepareSingleBeat(e);this._generateBeat(e,-e.playbackStart,e.voice.bar,t)}generateSingleNote(e){const t=this.prepareSingleBeat(e.beat);this._generateNote(e,0,e.beat.playbackDuration,t,new Int32Array(e.beat.voice.bar.staff.tuning.length),null)}}class gl{oldWidth=0;newWidth=0;settings=null}var ae;(function(a){a[a.PreNotes=0]="PreNotes",a[a.OnNotes=1]="OnNotes",a[a.MiddleNotes=2]="MiddleNotes",a[a.Stem=3]="Stem",a[a.PostNotes=4]="PostNotes",a[a.EndBeat=5]="EndBeat"})(ae||(ae={}));class Nt{x;y;width=0;height=0;renderer;constructor(e,t){this.x=e,this.y=t}getBoundingBoxTop(){return this.y}getBoundingBoxBottom(){return this.getBoundingBoxTop()+this.height}doLayout(){}paint(e,t,s){}}class Mo extends Nt{scaleToWidth(e){this.width=e}}class hi extends Mo{_ties=[];_tieWidth=0;beat;preNotes;onNotes;getLowestNoteY(e){return this.onNotes.getLowestNoteY(e)}getHighestNoteY(e){return this.onNotes.getHighestNoteY(e)}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(e){super(0,0),this.beat=e,this._ties=[]}getNoteY(e,t){return this.onNotes.y+this.onNotes.getNoteY(e,t)}getRestY(e){return this.onNotes.y+this.onNotes.getRestY(e)}getNoteX(e,t){return this.onNotes.x+this.onNotes.getNoteX(e,t)}addTie(e){const t=e;t.renderer=this.renderer,this._ties.push(e),this.renderer.registerTie(e)}getBoundingBoxTop(){let e=L.minBoundingBox(this.preNotes.getBoundingBoxTop(),this.onNotes.getBoundingBoxTop());return Number.isNaN(e)&&(e=this.renderer.middleYPosition),e}getBoundingBoxBottom(){let e=L.maxBoundingBox(this.preNotes.getBoundingBoxBottom(),this.onNotes.getBoundingBoxBottom());return Number.isNaN(e)&&(e=this.renderer.middleYPosition),e}drawBeamHelperAsFlags(e){return e.hasFlag(!1,void 0)}get postBeatStretch(){return this.onNotes.computedWidth+this._tieWidth-this.onNotes.onTimeX}registerLayoutingInfo(e){const t=this.preNotes.computedWidth+this.onNotes.onTimeX;let s=this.postBeatStretch;for(const i of this._ties)s+=i.width;e.addBeatSpring(this,t,s),e.setBeatSizes(this,{preBeatSize:this.preNotes.width,onBeatSize:this.onNotes.width})}applyLayoutingInfo(e){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 e=this.beat.notes.length-1;for(;e>=0;)this.createTies(this.beat.notes[e--])}doMultiVoiceLayout(){}updateWidth(){let e=this.preNotes.width+this.onNotes.width,t=0;
vendor: 29,195 bytes, line 10
10for(const s of this._ties){const i=s;i.width>t&&(t=i.width)}this._tieWidth=t,e+=t,this.width=e}createTies(e){}static getGroupId(e){return`b${e.id}`}paint(e,t,s){if(this.preNotes.isEmpty&&this.onNotes.isEmpty&&this._ties.length===0)return;s.beginGroup(hi.getGroupId(this.beat)),this.preNotes.paint(e+this.x,t+this.y,s),this.onNotes.paint(e+this.x,t+this.y,s);const r=e-this.renderer.beatGlyphsStart-this.renderer.x,n=t-this.renderer.y;for(let o=0,l=this._ties.length;o<l;o++){const h=this._ties[o];h.renderer=this.renderer,h.paint(r,n,s)}s.endGroup()}buildBoundingsLookup(e,t,s){const i=new Eo;if(i.beat=this.beat,this.beat.isEmpty)i.visualBounds=new bt,i.visualBounds.x=t+this.x,i.visualBounds.y=e.visualBounds.y,i.visualBounds.w=this.width,i.visualBounds.h=e.visualBounds.h,i.realBounds=new bt,i.realBounds.x=t+this.x,i.realBounds.y=e.realBounds.y,i.realBounds.w=this.width,i.realBounds.h=e.realBounds.h,i.onNotesX=t+this.x+this.onNotes.x+this.onNotes.onTimeX;else{i.visualBounds=new bt,i.visualBounds.x=t+this.x,this.preNotes.isEmpty?this.onNotes.isEmpty?i.visualBounds.x=t+this.x:i.visualBounds.x=t+this.x+this.onNotes.x:i.visualBounds.x=t+this.x+this.preNotes.x;let r=0;this.onNotes.isEmpty?this.preNotes.isEmpty?r=t+this.x+this.width:r=t+this.x+this.preNotes.x+this.preNotes.width:r=t+this.x+this.onNotes.x+this.onNotes.onTimeX+this.postBeatStretch,i.visualBounds.w=r-i.visualBounds.x,i.visualBounds.y=e.visualBounds.y,i.visualBounds.h=e.visualBounds.h,i.realBounds=new bt,i.realBounds.x=t+this.x,i.realBounds.y=e.realBounds.y,i.realBounds.w=this.width,i.realBounds.h=e.realBounds.h,i.onNotesX=t+this.x+this.onNotes.x+this.onNotes.onTimeX}e.addBeat(i),this.renderer.settings.core.includeNoteBounds&&this.onNotes.buildBoundingsLookup(i,t+this.x,s+this.y)}getBeatX(e,t=!1){switch(e){case ae.PreNotes:return this.preNotes.x;case ae.OnNotes:return this.onNotes.x;case ae.MiddleNotes:return this.onNotes.x+this.onNotes.middleX;case ae.Stem:return this.onNotes.x+this.onNotes.stemX;case ae.PostNotes:const s=t?this.renderer.layoutingInfo.getBeatSizes(this.beat)?.onBeatSize??this.onNotes.width:this.onNotes.width;return this.onNotes.x+s;case ae.EndBeat:return this.width}return this.preNotes.x}}class Fc{_instance;_instanceEventUnregister;_settings;_width=0;_score=null;_trackIndexes=null;get instance(){return this._instance}set instance(e){this._instance=e;const t=this._instanceEventUnregister;if(t)for(const s of t)s();if(e){const s=[];s.push(e.preRender.on(i=>this.preRender.trigger(i))),s.push(e.renderFinished.on(i=>this.renderFinished.trigger(i))),s.push(e.partialRenderFinished.on(i=>this.partialRenderFinished.trigger(i))),s.push(e.partialLayoutFinished.on(i=>this.partialLayoutFinished.trigger(i))),s.push(e.postRenderFinished.on(()=>this.postRenderFinished.trigger())),s.push(e.error.on(i=>this.error.trigger(i))),this._instanceEventUnregister=s,this._settings&&e.updateSettings(this._settings),e.width=this._width,this._score!==null&&e.renderScore(this._score,this._trackIndexes)}else this._instanceEventUnregister=void 0}get boundsLookup(){return this._instance?this._instance.boundsLookup:null}get width(){return this._instance?this._instance.width:0}set width(e){this._width=e,this._instance&&(this._instance.width=e)}render(e){this._instance?.render(e)}resizeRender(){this._instance?.resizeRender()}renderScore(e,t,s){this._score=e,this._trackIndexes=t,this._instance?.renderScore(e,t,s)}renderResult(e){this._instance?.renderResult(e)}updateSettings(e){this._settings=e,this._instance?.updateSettings(e)}destroy(){this._instance?.destroy(),this._instance=void 0}preRender=new Se;renderFinished=new Se;partialRenderFinished=new Se;partialLayoutFinished=new Se;postRenderFinished=new _t;error=new Se}class bn{api;lastScroll=-1;constructor(e){this.api=e}[Symbol.dispose](){}forceScrollTo(e){this._scrollToBeat(e,!0),this.lastScroll=-1}_scrollToBeat(e,t){const s=this.calculateLastScroll(e);s===this.lastScroll&&!t||(this.lastScroll=s,this.doScroll(e))}onBeatCursorUpdating(e,t,s,i,r,n){this._scrollToBeat(e,!1)}}class Mc extends bn{calculateLastScroll(e){return e.barBounds.masterBarBounds.realBounds.y}doScroll(e){const t=this.api.uiFacade,s=this.api.settings,i=t.getScrollContainer(),r=t.getOffset(i,this.api.container),n=e.barBounds.masterBarBounds.realBounds.y+s.player.scrollOffsetY;t.scrollToY(i,r.y+n,this.api.settings.player.scrollSpeed)}}class Ac extends bn{calculateLastScroll(e){return e.barBounds.masterBarBounds.realBounds.y}doScroll(e){const t=this.api.uiFacade,s=this.api.settings,i=t.getScrollContainer(),r=i.scrollTop+t.getOffset(null,i).h,n=e.barBounds.masterBarBounds;if(n.visualBounds.y+n.visualBounds.h>=r||n.visualBounds.y<i.scrollTop){const o=n.realBounds.y+s.player.scrollOffsetY;t.scrollToY(i,o,s.player.scrollSpeed)}}}class Ic{_api;_lastScroll=-1;_scrollContainerResizeUnregister;constructor(e){this._api=e,this._scrollContainerResizeUnregister=e.uiFacade.getScrollContainer().resize.on(()=>{const t=e.uiFacade.getScrollContainer(),s=e.settings.player.scrollOffsetX,r=t.width+s;e.uiFacade.setCanvasOverflow(e.canvasElement,r,!0)})}[Symbol.dispose](){this._api.uiFacade.setCanvasOverflow(this._api.canvasElement,0,!0),this._scrollContainerResizeUnregister()}forceScrollTo(e){const t=this._api.uiFacade,s=this._api.settings,i=t.getScrollContainer(),r=e.barBounds.masterBarBounds.realBounds.y+s.player.scrollOffsetY;t.scrollToY(i,r,0),this._lastScroll=-1}onBeatCursorUpdating(e,t,s,i,r,n){const o=this._api.uiFacade,l=this._api.settings,h=e.barBounds.masterBarBounds,c=h.realBounds.y+l.player.scrollOffsetY;if(c===this._lastScroll&&n>0)return;const d=o.getScrollContainer();if(o.scrollToY(d,c,0),n===0){this._lastScroll=-1;return}this._lastScroll=c;const f=c+h.realBounds.h,p=this._calculateSystemDuration(h);o.scrollToY(d,f,p)}_calculateSystemDuration(e){const t=e.staffSystemBounds.bars,s=this._api.tickCache;let i=0;const r=this._api.score.masterBars;for(const n of t){const o=r[n.index],l=s.getMasterBar(o),h=s.getMasterBar(o).tempoChanges;let c=h[0].tempo,d=h[0].tick;for(let p=1;p<h.length;p++){const g=h[p].tick-d;i+=B.ticksToMillis(g,c),c=h[p].tempo,d=h[p].tick}const f=l.end-d;i+=B.ticksToMillis(f,c)}return i}}class Rc extends bn{calculateLastScroll(e){return e.barBounds.masterBarBounds.visualBounds.x}doScroll(e){const t=this.api.uiFacade,s=this.api.settings,i=t.getScrollContainer(),n=e.barBounds.masterBarBounds.realBounds.x+s.player.scrollOffsetX;t.scrollToX(i,n,s.player.scrollSpeed)}}class Oc extends bn{calculateLastScroll(e){return e.barBounds.masterBarBounds.visualBounds.x}doScroll(e){const t=this.api.uiFacade,s=this.api.settings,i=t.getScrollContainer(),r=i.scrollLeft+t.getOffset(null,i).w,n=e.barBounds.masterBarBounds;if(n.visualBounds.x+n.visualBounds.w>=r||n.visualBounds.x<i.scrollLeft){const o=n.realBounds.x+s.player.scrollOffsetX;t.scrollToX(i,o,s.player.scrollSpeed)}}}class Wc{_api;_lastScroll=-1;_scrollContainerResizeUnregister;constructor(e){this._api=e,this._scrollContainerResizeUnregister=e.uiFacade.getScrollContainer().resize.on(()=>{const t=e.uiFacade.getScrollContainer(),s=e.settings.player.scrollOffsetX,r=t.width+s;e.uiFacade.setCanvasOverflow(e.canvasElement,r,!1)})}[Symbol.dispose](){this._scrollContainerResizeUnregister(),this._api.uiFacade.setCanvasOverflow(this._api.canvasElement,0,!1)}forceScrollTo(e){const t=this._api.uiFacade,s=this._api.settings,i=t.getScrollContainer(),r=e.onNotesX+s.player.scrollOffsetY;t.scrollToY(i,r,0),this._lastScroll=-1}onBeatCursorUpdating(e,t,s,i,r,n){const o=this._api.uiFacade;if(r===this._lastScroll&&n>0)return;const l=this._api.settings,h=o.getScrollContainer();if(o.scrollToX(h,i+l.player.scrollOffsetX,0),n===0){this._lastScroll=-1;return}this._lastScroll=r;const c=r+l.player.scrollOffsetX;o.scrollToX(h,c,n)}}class Un{activeBeats;constructor(e){this.activeBeats=e}}class tn{startTick=0;endTick=0}class Vc{_masterVolume=1;_metronomeVolume=0;_countInVolume=0;_playbackSpeed=1;_isLooping=!1;_midiEventsPlayedFilter=[];_instance;_instanceEventUnregister;midiTickShift=0;constructor(){this.ready=new _t(()=>this.isReady),this.readyForPlayback=new _t(()=>this.isReadyForPlayback),this.midiLoaded=new Se(()=>this._instance?.loadedMidiInfo??null),this.stateChanged=new Se(()=>new Yi(this.state,!1)),this.positionChanged=new Se(()=>this.currentPosition),this.playbackRangeChanged=new Se(()=>{const e=this.playbackRange;return e?new br(e):null})}get instance(){return this._instance}set instance(e){this._instance=e;const t=this._instanceEventUnregister;if(t)for(const s of t)s();if(e){const s=[];s.push(e.ready.on(()=>this.ready.trigger())),s.push(e.readyForPlayback.on(()=>this.readyForPlayback.trigger())),s.push(e.finished.on(()=>this.finished.trigger())),s.push(e.soundFontLoaded.on(()=>this.soundFontLoaded.trigger())),s.push(e.soundFontLoadFailed.on(i=>this.soundFontLoadFailed.trigger(i))),s.push(e.midiLoaded.on(i=>{this.midiLoaded.trigger(this._shiftPositionChangedEventArgsToApi(i))})),s.push(e.midiLoadFailed.on(i=>this.midiLoadFailed.trigger(i))),s.push(e.stateChanged.on(i=>this.stateChanged.trigger(i))),s.push(e.positionChanged.on(i=>{this.positionChanged.trigger(this._shiftPositionChangedEventArgsToApi(i))})),s.push(e.midiEventsPlayed.on(i=>this.midiEventsPlayed.trigger(i))),s.push(e.playbackRangeChanged.on(i=>this.playbackRangeChanged.trigger(this._shiftPlaybackRangeChangedEventArgsToApi(i)))),this._instanceEventUnregister=s,this.isReady?(e.masterVolume=this._masterVolume,e.metronomeVolume=this._metronomeVolume,e.countInVolume=this._countInVolume,e.playbackSpeed=this._playbackSpeed,e.isLooping=this._isLooping,e.midiEventsPlayedFilter=this._midiEventsPlayedFilter,this.ready.trigger()):s.push(e.ready.on(()=>{e.masterVolume=this._masterVolume,e.metronomeVolume=this._metronomeVolume,e.countInVolume=this._countInVolume,e.playbackSpeed=this._playbackSpeed,e.isLooping=this._isLooping,e.midiEventsPlayedFilter=this._midiEventsPlayedFilter}))}else this._instanceEventUnregister=void 0}get output(){return this._instance.output}get isReady(){return this._instance?this._instance.isReady:!1}get isReadyForPlayback(){return this._instance?this._instance.isReadyForPlayback:!1}get state(){return this._instance?this._instance.state:Rt.Paused}get logLevel(){return E.logLevel}set logLevel(e){E.logLevel=e,this._instance&&(this._instance.logLevel=e)}get masterVolume(){return this._masterVolume}set masterVolume(e){e=Math.max(e,de.MinVolume),this._masterVolume=e,this._instance&&(this._instance.masterVolume=e)}get metronomeVolume(){return this._metronomeVolume}set metronomeVolume(e){e=Math.max(e,de.MinVolume),this._metronomeVolume=e,this._instance&&(this._instance.metronomeVolume=e)}get playbackSpeed(){return this._playbackSpeed}set playbackSpeed(e){this._playbackSpeed=e,this._instance&&(this._instance.playbackSpeed=e)}get loadedMidiInfo(){return this._instance?this._shiftPositionChangedEventArgsToApi(this._instance.loadedMidiInfo):void 0}get currentPosition(){return this._instance?this._shiftPositionChangedEventArgsToApi(this._instance.currentPosition):new Ys(0,0,0,0,!1,120,120)}get tickPosition(){return this._instance?this._shiftTickToApi(this._instance.tickPosition):0}set tickPosition(e){this._instance&&(this._instance.tickPosition=this._shiftTickToPlayer(e))}get timePosition(){return this._instance?this._instance.timePosition:0}set timePosition(e){this._instance&&(this._instance.timePosition=e)}get playbackRange(){return this._instance?this._shiftPlaybackRangeToApi(this._instance.playbackRange):null}set playbackRange(e){this._instance&&(this._instance.playbackRange=this._shiftPlaybackRangeToPlayer(e))}get isLooping(){return this._isLooping}set isLooping(e){this._isLooping=e,this._instance&&(this._instance.isLooping=e)}get countInVolume(){return this._countInVolume}set countInVolume(e){this._countInVolume=e,this._instance&&(this._instance.countInVolume=e)}get midiEventsPlayedFilter(){return this._midiEventsPlayedFilter}set midiEventsPlayedFilter(e){this._midiEventsPlayedFilter=e,this._instance&&(this._instance.midiEventsPlayedFilter=e)}destroy(){this._instance&&(this._instance.destroy(),this._instance=void 0)}play(){return this._instance?this._instance.play():!1}pause(){this._instance&&this._instance.pause()}playPause(){this._instance&&this._instance.playPause()}stop(){this._instance&&this._instance.stop()}playOneTimeMidiFile(e){this._instance&&this._instance.playOneTimeMidiFile(e)}loadSoundFont(e,t){this._instance&&this._instance.loadSoundFont(e,t)}resetSoundFonts(){this._instance&&this._instance.resetSoundFonts()}loadMidiFile(e){this._instance&&this._instance.loadMidiFile(e)}loadBackingTrack(e){this._instance&&this._instance.loadBackingTrack(e)}updateSyncPoints(e){this._instance&&this._instance.updateSyncPoints(e)}applyTranspositionPitches(e){this._instance&&this._instance.applyTranspositionPitches(e)}setChannelTranspositionPitch(e,t){this._instance&&this._instance.setChannelTranspositionPitch(e,t)}setChannelMute(e,t){this._instance&&this._instance.setChannelMute(e,t)}resetChannelStates(){this._instance&&this._instance.resetChannelStates()}setChannelSolo(e,t){this._instance&&this._instance.setChannelSolo(e,t)}setChannelVolume(e,t){this._instance&&this._instance.setChannelVolume(e,t)}ready;readyForPlayback;finished=new _t;soundFontLoaded=new _t;soundFontLoadFailed=new Se;midiLoaded;midiLoadFailed=new Se;stateChanged;positionChanged;midiEventsPlayed=new Se;playbackRangeChanged;_shiftPlaybackRangeChangedEventArgsToApi(e){return e.playbackRange==null?e:this.midiTickShift>0?new br(this._shiftPlaybackRangeToApi(e.playbackRange)):e}_shiftPlaybackRangeToApi(e){if(e==null)return e;const t=this.midiTickShift;if(t>0){const s=new tn;return s.startTick=e.startTick-t,s.endTick=e.endTick-t,s}else return e}_shiftPlaybackRangeToPlayer(e){if(e==null)return e;const t=this.midiTickShift;if(t>0){const s=new tn;return s.startTick=e.startTick+t,s.endTick=e.endTick+t,s}else return e}_shiftPositionChangedEventArgsToApi(e){if(!e)return e;const t=this.midiTickShift;return t>0?new Ys(e.currentTime,e.endTime,e.currentTick-t,e.endTick-t,e.isSeek,e.originalTempo,e.modifiedTempo):e}_shiftTickToApi(e){return e-this.midiTickShift}_shiftTickToPlayer(e){return e+this.midiTickShift}}class Hc{_midiEventQueue=new To;masterVolume=1;metronomeVolume=0;outSampleRate=44100;currentTempo=120;timeSignatureNumerator=4;timeSignatureDenominator=4;activeVoiceCount=0;output;noteOffAll(e){}resetSoft(){}resetPresets(){}loadPresets(e,t,s,i){}setupMetronomeChannel(e){}synthesizeSilent(e){this.fakeSynthesize()}_processMidiMessage(e){}dispatchEvent(e){this._midiEventQueue.enqueue(e)}synthesize(e,t,s){return this.fakeSynthesize()}fakeSynthesize(){const e=[];for(;!this._midiEventQueue.isEmpty;){const t=this._midiEventQueue.dequeue();t.isMetronome&&this.metronomeVolume>0||t.event&&this._processMidiMessage(t.event),e.push(t)}return e}applyTranspositionPitches(e){}setChannelTranspositionPitch(e,t){}channelSetMute(e,t){}channelSetSolo(e,t){}resetChannelStates(){}channelSetMixVolume(e,t){}hasSamplesForProgram(e){return!0}hasSamplesForPercussion(e){return!0}}class rh extends No{_backingTrackOutput;constructor(e,t){super(e,new Hc,t),this.synthesizer.output=e,this._backingTrackOutput=e,e.timeUpdate.on(s=>{const i=this.sequencer.mainTimePositionFromBackingTrack(s,e.backingTrackDuration);this.sequencer.fillMidiEventQueueToEndTime(i),this.synthesizer.fakeSynthesize(),this.updateTimePosition(i,!1),this.checkForFinish()})}updateMasterVolume(e){super.updateMasterVolume(e),this._backingTrackOutput.masterVolume=e}updatePlaybackSpeed(e){super.updatePlaybackSpeed(e),this._backingTrackOutput.playbackRate=e}onSampleRequest(){}loadMidiFile(e){this.isSoundFontLoaded||(this.isSoundFontLoaded=!0,this.soundFontLoaded.trigger()),super.loadMidiFile(e)}updateTimePosition(e,t){super.updateTimePosition(e,t),t&&this._backingTrackOutput.seekTo(this.sequencer.mainTimePositionToBackingTrack(e,this._backingTrackOutput.backingTrackDuration))}loadBackingTrack(e){const t=e.backingTrack;t&&(this._backingTrackOutput.loadBackingTrack(t),this.timePosition=0)}updateSyncPoints(e){this.sequencer.mainUpdateSyncPoints(e),this.tickPosition=this.tickPosition}}class Gc{sampleRate=44100;_seekPosition=0;_handler;get handler(){return this._handler}set handler(e){e&&this._seekPosition!==0&&(e.seekTo(this._seekPosition),this._seekPosition=0),this._handler=e}get backingTrackDuration(){return this.handler?.backingTrackDuration??0}get playbackRate(){return this.handler?.playbackRate??1}set playbackRate(e){const t=this.handler;t&&(t.playbackRate=e)}get masterVolume(){return this.handler?.masterVolume??1}set masterVolume(e){const t=this.handler;t&&(t.masterVolume=e)}seekTo(e){const t=this.handler;t?t.seekTo(e):this._seekPosition=e}loadBackingTrack(e){}open(e){this.ready.trigger()}updatePosition(e){this.timeUpdate.trigger(e)}play(){this.handler?.play()}destroy(){}pause(){this.handler?.pause()}addSamples(e){}resetSamples(){}activate(){}ready=new _t;samplesPlayed=new Se;timeUpdate=new Se;sampleRequest=new _t;async enumerateOutputDevices(){return[]}async setOutputDevice(e){}async getOutputDevice(){return null}}class Uc extends rh{get handler(){return this.output.handler}set handler(e){this.output.handler=e}constructor(e){super(new Gc,e)}}class zc{bounds=null;isVisible(e){const t=this.bounds;return t?t.findBeat(e)!==null:!1}}class Yc{_startTime=0;_trackIndexes=null;_trackIndexLookup=null;_beatVisibilityChecker=new zc;_isDestroyed=!1;_score=null;_tracks=[];_actualPlayerMode=ts.Disabled;_player;_renderer;_defaultScrollHandler;get midiTickShift(){return this._player.midiTickShift}get actualPlayerMode(){return this._actualPlayerMode}uiFacade;container;get renderer(){return this._renderer}get score(){return this._score}settings;get tracks(){return this._tracks}canvasElement;constructor(e,t){this.uiFacade=e,this.container=e.rootContainer,this.activeBeatsChanged=new Se(()=>this._player.state===Rt.Playing&&this._currentBeat?new Un(this._currentBeat.beatLookup.highlightedBeats.map(i=>i.beat)):null),this.playedBeatChanged=new Se(()=>this._player.state===Rt.Playing&&this._currentBeat?this._currentBeat.beat:null),this.scoreLoaded=new Se(()=>this._score?this._score:null),this.midiLoaded=new Se(()=>this._player.loadedMidiInfo??null),e.initialize(this,t),E.logLevel=this.settings.core.logLevel,this.settings.handleBackwardsCompatibility(),M.printEnvironmentInfo(!1),this.canvasElement=e.createCanvasElement(),this.container.appendChild(this.canvasElement),this._renderer=new Fc,this.settings.core.useWorkers&&this.uiFacade.areWorkersSupported&&M.getRenderEngineFactory(this.settings.core.engine).supportsWorkers?this._renderer.instance=this.uiFacade.createWorkerRenderer():this._renderer.instance=new ur(this.settings),this.container.resize.on(M.throttle(()=>{this._isDestroyed||this.container.width!==this._renderer.width&&this.triggerResize()},e.resizeThrottle));const s=new gl;s.oldWidth=this._renderer.width,s.newWidth=this.container.width|0,s.settings=this.settings,this._onResize(s),this._renderer.preRender.on(this._onRenderStarted.bind(this)),this._renderer.renderFinished.on(i=>{this._onRenderFinished(i)}),this._renderer.postRenderFinished.on(()=>{const i=Date.now()-this._startTime;E.debug("rendering",`Rendering completed in ${i}ms`),this._onPostRenderFinished()}),this._renderer.preRender.on(i=>{this._startTime=Date.now()}),this._renderer.partialLayoutFinished.on(i=>this._appendRenderResult(i,!1)),this._renderer.partialRenderFinished.on(this._updateRenderResult.bind(this)),this._renderer.renderFinished.on(i=>{this._appendRenderResult(i,!0)}),this._renderer.error.on(this.onError.bind(this)),this._setupPlayerWrapper(),this.settings.player.playerMode!==ts.Disabled&&this._setupOrDestroyPlayer(),this._setupClickHandling(),this.uiFacade.beginInvoke(()=>{this.uiFacade.initialRender()})}_setupPlayerWrapper(){const e=new Vc;this._player=e,e.ready.on(()=>{this.loadMidiForScore()}),e.readyForPlayback.on(()=>{if(this._onPlayerReady(),this.tracks)for(const t of this.tracks){const s=t.playbackInfo.volume/16;e.setChannelVolume(t.playbackInfo.primaryChannel,s),e.setChannelVolume(t.playbackInfo.secondaryChannel,s)}}),e.soundFontLoaded.on(this._onSoundFontLoaded.bind(this)),e.soundFontLoadFailed.on(t=>{this.onError(t)}),e.midiLoaded.on(this._onMidiLoaded.bind(this)),e.midiLoadFailed.on(t=>{this.onError(t)}),e.stateChanged.on(this._onPlayerStateChanged.bind(this)),e.positionChanged.on(this._onPlayerPositionChanged.bind(this)),e.midiEventsPlayed.on(this._onMidiEventsPlayed.bind(this)),e.playbackRangeChanged.on(this._onPlaybackRangeChanged.bind(this)),e.finished.on(this._onPlayerFinished.bind(this))}destroy(){this._isDestroyed=!0,this._player.destroy(),this.uiFacade.destroy(),this._renderer.destroy()}updateSettings(){this.settings.handleBackwardsCompatibility();const e=this.score;e&&L.applyPitchOffsets(this.settings,e),this._updateRenderer(),this._renderer.updateSettings(this.settings),this._setupOrDestroyPlayer(),this._onSettingsUpdated()}_updateRenderer(){const e=this._renderer;this.settings.core.useWorkers&&this.uiFacade.areWorkersSupported&&M.getRenderEngineFactory(this.settings.core.engine).supportsWorkers?e.instance instanceof ur&&(e.destroy(),e.instance=this.uiFacade.createWorkerRenderer()):e.instance instanceof ur||(e.destroy(),e.instance=new ur(this.settings))}load(e,t){try{return this.uiFacade.load(e,s=>{this.renderScore(s,t)},s=>{this.onError(s)})}catch(s){return this.onError(s),!1}}renderScore(e,t,s){const i=[];if(!t)e.tracks.length>0&&i.push(e.tracks[0]);else if(t.length===0)e.tracks.length>0&&i.push(e.tracks[0]);else if(t.length===1&&t[0]===-1)for(const r of e.tracks)i.push(r);else for(const r of t)r>=0&&r<=e.tracks.length&&i.push(e.tracks[r]);this._internalRenderTracks(e,i,s)}renderTracks(e,t){if(e.length>0){const s=e[0].score;for(const i of e)if(i.score!==s){this.onError(new Ye(Ge.General,"All rendered tracks must belong to the same score."));return}this._internalRenderTracks(s,e,t)}}_internalRenderTracks(e,t,s){if(L.applyPitchOffsets(this.settings,e),e!==this.score){this._score=e,this._tracks=t,this._tickCache=null,this._trackIndexes=[];for(const i of t)this._trackIndexes.push(i.index);this._trackIndexLookup=new Set(this._trackIndexes),this._onScoreLoaded(e),this.loadMidiForScore(),this.render(s)}else{this._tracks=t;const i=L.computeFirstDisplayedBarIndex(e,this.settings),r=L.computeLastDisplayedBarIndex(e,this.settings,i);this._tickCache&&(this._tickCache.multiBarRestInfo=L.buildMultiBarRestInfo(this.tracks,i,r)),this._trackIndexes=[];for(const n of t)this._trackIndexes.push(n.index);this._trackIndexLookup=new Set(this._trackIndexes),this.render(s)}}triggerResize(){if(!this.container.isVisible)E.warning("Rendering","AlphaTab container was invisible while autosizing, waiting for element to become visible",null),this.uiFacade.rootContainerBecameVisible.on(()=>{E.debug("Rendering","AlphaTab container became visible, doing autosizing",null),this.triggerResize()});else{const e=new gl;e.oldWidth=this._renderer.width,e.newWidth=this.container.width,e.settings=this.settings,this._onResize(e),this._renderer.updateSettings(this.settings),this._renderer.width=this.container.width,this._renderer.resizeRender()}}_appendRenderResult(e,t){t&&(this.canvasElement.width=e.totalWidth,this.canvasElement.height=e.totalHeight,this._cursorWrapper&&(this._cursorWrapper.width=e.totalWidth,this._cursorWrapper.height=e.totalHeight)),(e.width>0||e.height>0)&&this.uiFacade.beginAppendRenderResults(e),t&&this.uiFacade.beginAppendRenderResults(null)}_updateRenderResult(e){e&&e.renderResult&&this.uiFacade.beginUpdateRenderResults(e)}tex(e,t){try{const s=new gn;s.logErrors=!0,s.initFromString(e,this.settings);const i=s.readScore();this.renderScore(i,t)}catch(s){this.onError(s)}}loadSoundFont(e,t=!1){return this.uiFacade.loadSoundFont(e,t)}resetSoundFonts(){this._player.resetSoundFonts()}render(e){this.uiFacade.canRender?(this._renderer.width=this.container.width,this._renderer.renderScore(this.score,this._trackIndexes,e)):this.uiFacade.canRenderChanged.on(()=>this.render(e))}_tickCache=null;customScrollHandler;get tickCache(){return this._tickCache}get boundsLookup(){return this._renderer.boundsLookup}get player(){return this._player.instance?this._player:null}get isReadyForPlayback(){return this._player.isReadyForPlayback}get playerState(){return this._player.state}get masterVolume(){return this._player.masterVolume}set masterVolume(e){this._player.masterVolume=e}get metronomeVolume(){return this._player.metronomeVolume}set metronomeVolume(e){this._player.metronomeVolume=e}get countInVolume(){return this._player.countInVolume}set countInVolume(e){this._player.countInVolume=e}get midiEventsPlayedFilter(){return this._player.midiEventsPlayedFilter}set midiEventsPlayedFilter(e){this._player.midiEventsPlayedFilter=e}get tickPosition(){return this._player.tickPosition}set tickPosition(e){this._player.tickPosition=e}get timePosition(){return this._player.timePosition}set timePosition(e){this._player.timePosition=e}get endTick(){return this._player.currentPosition.endTick}get endTime(){return this._player.currentPosition.endTime}get playbackRange(){return this._player.playbackRange}set playbackRange(e){this._player.playbackRange=e,this._updateSelectionCursor(e)}get playbackSpeed(){return this._player.playbackSpeed}set playbackSpeed(e){this._player.playbackSpeed=e}get isLooping(){return this._player.isLooping}set isLooping(e){this._player.isLooping=e}_destroyPlayer(){this._player.destroy(),this._previousTick=0,this._destroyCursors()}_setupOrDestroyPlayer(){let e=this.settings.player.playerMode;if(e===ts.EnabledAutomatic){const s=this.score;if(!s)return!1;s?.backingTrack?.rawAudioFile?e=ts.EnabledBackingTrack:e=ts.EnabledSynthesizer}let t=null;if(e!==this._actualPlayerMode)switch(this._destroyPlayer(),this._updateCursors(),e){case ts.Disabled:t=null;break;case ts.EnabledSynthesizer:t=this.uiFacade.createWorkerPlayer();break;case ts.EnabledBackingTrack:t=this.uiFacade.createBackingTrackPlayer();break;case ts.EnabledExternalMedia:t=new Uc(this.settings.player.bufferTimeInMilliseconds);break}else return this._updateCursors(),!1;return this._actualPlayerMode=e,t&&(this._player.instance=t),!1}loadMidiForScore(){if(!this.score)return;const e=this.score;E.debug("AlphaTab","Generating Midi");const t=new oi,s=new Rs(t),i=new Ne(e,this.settings,s),r=L.computeFirstDisplayedBarIndex(e,this.settings),n=L.computeLastDisplayedBarIndex(e,this.settings,r);i.tickLookup.multiBarRestInfo=L.buildMultiBarRestInfo(this.tracks,r,n),i.applyTranspositionPitches=!1,i.generate(),this._tickCache=i.tickLookup,this._onMidiLoad(t);const o=this._player;o.midiTickShift=s.tickShift,o.loadMidiFile(t),o.loadBackingTrack(e),o.updateSyncPoints(i.syncPoints),o.applyTranspositionPitches(i.transpositionPitches)}updateSyncPoints(){if(!this.score)return;const e=this.score;this._player.updateSyncPoints(Ne.generateSyncPoints(e))}changeTrackVolume(e,t){for(const s of e)this._player.setChannelVolume(s.playbackInfo.primaryChannel,t),this._player.setChannelVolume(s.playbackInfo.secondaryChannel,t)}changeTrackSolo(e,t){for(const s of e)this._player.setChannelSolo(s.playbackInfo.primaryChannel,t),this._player.setChannelSolo(s.playbackInfo.secondaryChannel,t)}changeTrackMute(e,t){for(const s of e)this._player.setChannelMute(s.playbackInfo.primaryChannel,t),this._player.setChannelMute(s.playbackInfo.secondaryChannel,t)}changeTrackTranspositionPitch(e,t){for(const s of e)this._player.setChannelTranspositionPitch(s.playbackInfo.primaryChannel,t),this._player.setChannelTranspositionPitch(s.playbackInfo.secondaryChannel,t)}play(){return this._player.play()}pause(){this._player.pause()}playPause(){this._player.playPause()}stop(){this._player.stop()}playBeat(e){const t=new oi,s=new Rs(t);new Ne(e.voice.bar.staff.track.score,this.settings,s).generateSingleBeat(e),this._player.playOneTimeMidiFile(t)}playNote(e){const t=new oi,s=new Rs(t);new Ne(e.beat.voice.bar.staff.track.score,this.settings,s).generateSingleNote(e),this._player.playOneTimeMidiFile(t)}_cursorWrapper=null;_barCursor=null;_beatCursor=null;_selectionWrapper=null;_previousTick=0;_currentBeat=null;_currentBeatBounds=null;_isInitialBeatCursorUpdate=!0;_previousStateForCursor=Rt.Paused;_previousCursorCache=null;_destroyCursors(){this._cursorWrapper&&(this.uiFacade.destroyCursors(),this._cursorWrapper=null,this._barCursor=null,this._beatCursor=null,this._selectionWrapper=null)}_createCursors(){if(this._cursorWrapper)return;const e=this.uiFacade.createCursors();e&&(this._cursorWrapper=e.cursorWrapper,this._barCursor=e.barCursor,this._beatCursor=e.beatCursor,this._selectionWrapper=e.selectionWrapper,this._isInitialBeatCursorUpdate=!0),this._currentBeat!==null&&this._cursorUpdateBeat(this._currentBeat,!1,this._previousTick>10,1,!0)}_updateCursors(){this._updateScrollHandler();const e=this._hasCursor;e?this._createCursors():!e&&this._cursorWrapper&&this._destroyCursors()}_scrollHandlerMode=Us.Off;_scrollHandlerVertical=!0;_updateScrollHandler(){const e=this._defaultScrollHandler,t=this.settings.player.scrollMode,s=M.getLayoutEngineFactory(this.settings.display.layoutMode).vertical;if(!(this._scrollHandlerMode===t&&this._scrollHandlerVertical===s)){if(e){e[Symbol.dispose]();
10const i=this.uiFacade.getScrollContainer();this.uiFacade.stopScrolling(i)}switch(t){case Us.Off:this._defaultScrollHandler=void 0;break;case Us.Continuous:s?this._defaultScrollHandler=new Mc(this):this._defaultScrollHandler=new Rc(this);break;case Us.OffScreen:s?this._defaultScrollHandler=new Ac(this):this._defaultScrollHandler=new Oc(this);break;case Us.Smooth:s?this._defaultScrollHandler=new Ic(this):this._defaultScrollHandler=new Wc(this);break}}}_cursorUpdateTick(e,t,s,i=!1,r=!1){this._previousTick=e;const n=this._tickCache;if(n){const o=n.findBeatWithChecker(this._beatVisibilityChecker,e,this._currentBeat);o&&this._cursorUpdateBeat(o,t,i,s,r||this.playerState===Rt.Paused)}}_cursorUpdateBeat(e,t,s,i,r=!1){const n=e.beat,o=e.nextBeat?.beat??null,l=e.duration,h=e.beatLookup.highlightedBeats;if(!n)return;const c=this._renderer.boundsLookup;if(!c)return;const d=this._currentBeat,f=this._previousCursorCache,p=this._previousStateForCursor;if(!r&&n===d?.beat&&c===f&&p===this._player.state&&d?.start===e.start)return;const g=c.findBeat(n);g&&(this._currentBeat=e,this._previousCursorCache=c,this._previousStateForCursor=this._player.state,this.uiFacade.beginInvoke(()=>{this._internalCursorUpdateBeat(n,o,l,t,h,c,g,s,e.cursorMode,i)}))}scrollToCursor(){const e=this._currentBeatBounds;if(e){const t=this.customScrollHandler??this._defaultScrollHandler;t&&t.forceScrollTo(e)}}_internalCursorUpdateBeat(e,t,s,i,r,n,o,l,h,c){const d=this._barCursor,f=this._beatCursor,p=o.barBounds.masterBarBounds,g=p.visualBounds,m=this._currentBeatBounds;this._currentBeatBounds=o,d&&d.setBounds(g.x,g.y,g.w,g.h);const b=this._player.state===Rt.Playing&&!i;let S=p.visualBounds.x+p.visualBounds.w,N=null;t&&h===Bs.ToNextBext&&(N=n.findBeat(t),N&&N.barBounds.masterBarBounds.staffSystemBounds===p.staffSystemBounds&&(S=N.onNotesX));let v=o.onNotesX;if(f){if(this.settings.player.enableAnimatedBeatCursor){const j=S-o.onNotesX,q=this._previousTick-this._currentBeat.start,F=this._currentBeat.tickDuration>0?q/this._currentBeat.tickDuration:0;if(v=o.onNotesX+j*F,s-=s*F,b){(!m||this._isInitialBeatCursorUpdate||g.y!==m.barBounds.masterBarBounds.visualBounds.y||v<m.onNotesX||p.index>m.barBounds.masterBarBounds.index+1)&&(f.transitionToX(0,v),f.setBounds(v,g.y,1,g.h));const me=h===Bs.ToNextBext?2:1;S=v+(S-v)*me,s=s/c*me,this.uiFacade.beginInvoke(()=>{f.transitionToX(s,S)})}else s=0,f.transitionToX(s,S),f.setBounds(v,g.y,1,g.h)}else s=0,S=v,f.transitionToX(s,S),f.setBounds(v,g.y,1,g.h);this._isInitialBeatCursorUpdate=!1}else this._isInitialBeatCursorUpdate=!0;this.uiFacade.removeHighlights();let W=!1;if(b){if(this.settings.player.enableElementHighlighting)for(const j of r){const q=hi.getGroupId(j.beat);this.uiFacade.highlightElements(q,e.voice.bar.index)}l=!i,W=!0}if(l&&!this._isBeatMouseDown&&this.settings.player.scrollMode!==Us.Off){const j=this.customScrollHandler??this._defaultScrollHandler;j&&j.onBeatCursorUpdating(o,N===null?void 0:N,h,v,S,s)}W&&(this._onPlayedBeatChanged(e),this._onActiveBeatsChanged(new Un(r.map(j=>j.beat))))}playedBeatChanged;_onPlayedBeatChanged(e){this._isDestroyed||(this.playedBeatChanged.trigger(e),this.uiFacade.triggerEvent(this.container,"playedBeatChanged",e))}activeBeatsChanged;_onActiveBeatsChanged(e){this._isDestroyed||(this.activeBeatsChanged.trigger(e),this.uiFacade.triggerEvent(this.container,"activeBeatsChanged",e))}_isBeatMouseDown=!1;_isNoteMouseDown=!1;_selectionStart;_selectionEnd;beatMouseDown=new Se;beatMouseMove=new Se;beatMouseUp=new Se;noteMouseDown=new Se;noteMouseMove=new Se;noteMouseUp=new Se;get _hasCursor(){return this.settings.player.playerMode!==ts.Disabled&&this.settings.player.enableCursor}_onBeatMouseDown(e,t){this._isDestroyed||(this._hasCursor&&this.settings.player.enableUserInteraction&&(this._selectionStart={beat:t},this._selectionEnd=void 0),this._isBeatMouseDown=!0,this.beatMouseDown.trigger(t),this.uiFacade.triggerEvent(this.container,"beatMouseDown",t,e))}_onNoteMouseDown(e,t){this._isDestroyed||(this._isNoteMouseDown=!0,this.noteMouseDown.trigger(t),this.uiFacade.triggerEvent(this.container,"noteMouseDown",t,e))}_onBeatMouseMove(e,t){this._isDestroyed||(this.settings.player.enableUserInteraction&&(!this._selectionEnd||this._selectionEnd.beat!==t)&&(this._selectionEnd={beat:t},this._cursorSelectRange(this._selectionStart,this._selectionEnd)),this.beatMouseMove.trigger(t),this.uiFacade.triggerEvent(this.container,"beatMouseMove",t,e))}_onNoteMouseMove(e,t){this._isDestroyed||(this.noteMouseMove.trigger(t),this.uiFacade.triggerEvent(this.container,"noteMouseMove",t,e))}_onBeatMouseUp(e,t){this._isDestroyed||(this._hasCursor&&this.settings.player.enableUserInteraction&&this.applyPlaybackRangeFromHighlight(),this.beatMouseUp.trigger(t),this.uiFacade.triggerEvent(this.container,"beatMouseUp",t,e),this._isBeatMouseDown=!1)}_onNoteMouseUp(e,t){this._isDestroyed||(this.noteMouseUp.trigger(t),this.uiFacade.triggerEvent(this.container,"noteMouseUp",t,e),this._isNoteMouseDown=!1)}_updateSelectionCursor(e){if(this._tickCache)if(e){const t=this._tickCache.findBeat(this._trackIndexLookup,e.startTick),s=this._tickCache.findBeat(this._trackIndexLookup,e.endTick);if(t&&s){const i={beat:t.beat},r={beat:s.beat};this._cursorSelectRange(i,r)}}else this._cursorSelectRange(void 0,void 0)}_setupClickHandling(){this.canvasElement.mouseDown.on(e=>{if(!e.isLeftMouseButton)return;this.settings.player.enableUserInteraction&&e.preventDefault();const t=e.getX(this.canvasElement),s=e.getY(this.canvasElement),i=this._renderer.boundsLookup?.getBeatAtPos(t,s)??null;if(i&&(this._onBeatMouseDown(e,i),this.settings.core.includeNoteBounds)){const r=this._renderer.boundsLookup?.getNoteAtPos(i,t,s);r&&this._onNoteMouseDown(e,r)}}),this.canvasElement.mouseMove.on(e=>{if(!this._isBeatMouseDown)return;const t=e.getX(this.canvasElement),s=e.getY(this.canvasElement),i=this._renderer.boundsLookup?.getBeatAtPos(t,s)??null;if(i&&(this._onBeatMouseMove(e,i),this._isNoteMouseDown)){const r=this._renderer.boundsLookup?.getNoteAtPos(i,t,s);r&&this._onNoteMouseMove(e,r)}}),this.canvasElement.mouseUp.on(e=>{if(!this._isBeatMouseDown)return;this.settings.player.enableUserInteraction&&e.preventDefault();const t=e.getX(this.canvasElement),s=e.getY(this.canvasElement),i=this._renderer.boundsLookup?.getBeatAtPos(t,s)??null;if(this._onBeatMouseUp(e,i),this._isNoteMouseDown)if(i){const r=this._renderer.boundsLookup?.getNoteAtPos(i,t,s)??null;this._onNoteMouseUp(e,r)}else this._onNoteMouseUp(e,null)}
10),this._renderer.postRenderFinished.on(()=>{!this._selectionStart||!this._hasCursor||!this.settings.player.enableUserInteraction||this._cursorSelectRange(this._selectionStart,this._selectionEnd)})}highlightPlaybackRange(e,t){this._selectionStart={beat:e},this._selectionEnd={beat:t},this._cursorSelectRange(this._selectionStart,this._selectionEnd)}applyPlaybackRangeFromHighlight(){if(this._selectionEnd){const e=this._tickCache?.getBeatStart(this._selectionStart.beat)??this._selectionStart.beat.absolutePlaybackStart;if((this._tickCache?.getBeatStart(this._selectionEnd.beat)??this._selectionEnd.beat.absolutePlaybackStart)<e){const s=this._selectionStart;this._selectionStart=this._selectionEnd,this._selectionEnd=s}}if(this._selectionStart&&this._tickCache){const e=this._tickCache,t=e.getMasterBarStart(this._selectionStart.beat.voice.bar.masterBar);if(this._currentBeat=null,this._player.state===Rt.Paused&&this._cursorUpdateTick(this._tickCache.getBeatStart(this._selectionStart.beat),!1,1),this.tickPosition=t+this._selectionStart.beat.playbackStart,this._selectionEnd&&this._selectionStart.beat!==this._selectionEnd.beat){const s=e.getMasterBarStart(this._selectionEnd.beat.voice.bar.masterBar),i=new tn;i.startTick=t+this._selectionStart.beat.playbackStart,i.endTick=s+this._selectionEnd.beat.playbackStart+this._selectionEnd.beat.playbackDuration-50,this.playbackRange=i}else this._selectionStart=void 0,this.playbackRange=null,this._cursorSelectRange(this._selectionStart,this._selectionEnd)}}clearPlaybackRangeHighlight(){this._cursorSelectRange(void 0,void 0)}playbackRangeHighlightChanged=new Se;_cursorSelectRange(e,t){const s=this._renderer.boundsLookup;if(!s){this.playbackRangeHighlightChanged.trigger({});return}const i=this._selectionWrapper;if(!i){this.playbackRangeHighlightChanged.trigger({});return}if(i.clear(),!e||!t||e.beat===t.beat){this.playbackRangeHighlightChanged.trigger({});return}e.bounds||(e.bounds=s.findBeat(e.beat)??void 0),t.bounds||(t.bounds=s.findBeat(t.beat)??void 0);const r=this._tickCache?.getBeatStart(e.beat)??e.beat.absolutePlaybackStart;if((this._tickCache?.getBeatStart(t.beat)??t.beat.absolutePlaybackStart)<r){const c=e;e=t,t=c}const o={startBeat:e.beat,startBeatBounds:e.bounds,endBeat:t.beat,endBeatBounds:t.bounds,highlightBlocks:[]};let l=e.bounds.realBounds.x;e.beat.index===0&&(l=e.bounds.barBounds.masterBarBounds.realBounds.x);let h=t.bounds.realBounds.x+t.bounds.realBounds.w;if(t.beat.index===t.beat.voice.beats.length-1&&(h=t.bounds.barBounds.masterBarBounds.realBounds.x+t.bounds.barBounds.masterBarBounds.realBounds.w),e.bounds.barBounds.masterBarBounds.staffSystemBounds!==t.bounds.barBounds.masterBarBounds.staffSystemBounds){const c=e.bounds.barBounds.masterBarBounds.staffSystemBounds.visualBounds.x,d=e.bounds.barBounds.masterBarBounds.staffSystemBounds.visualBounds.x+e.bounds.barBounds.masterBarBounds.staffSystemBounds.visualBounds.w,f=this.uiFacade.createSelectionElement(),p=new bt(l,e.bounds.barBounds.masterBarBounds.visualBounds.y,d-l,e.bounds.barBounds.masterBarBounds.visualBounds.h);f.setBounds(p.x,p.y,p.w,p.h),o.highlightBlocks.push(p),i.appendChild(f);const g=e.bounds.barBounds.masterBarBounds.staffSystemBounds.index+1,m=t.bounds.barBounds.masterBarBounds.staffSystemBounds.index;for(let N=g;N<m;N++){const v=s.staffSystems[N],W=this.uiFacade.createSelectionElement(),j=new bt(c,v.visualBounds.y,d-c,v.visualBounds.h);o.highlightBlocks.push(j),W.setBounds(j.x,j.y,j.w,j.h),i.appendChild(W)}const b=this.uiFacade.createSelectionElement(),S=new bt(c,t.bounds.barBounds.masterBarBounds.visualBounds.y,h-c,t.bounds.barBounds.masterBarBounds.visualBounds.h);o.highlightBlocks.push(S),b.setBounds(S.x,S.y,S.w,S.h),i.appendChild(b)}else{const c=this.uiFacade.createSelectionElement(),d=new bt(l,e.bounds.barBounds.masterBarBounds.visualBounds.y,h-l,e.bounds.barBounds.masterBarBounds.visualBounds.h);c.setBounds(d.x,d.y,d.w,d.h),o.highlightBlocks.push(d),i.appendChild(c)}this.playbackRangeHighlightChanged.trigger(o)}scoreLoaded;_onScoreLoaded(e){this._isDestroyed||(this.scoreLoaded.trigger(e),this.uiFacade.triggerEvent(this.container,"scoreLoaded",e),this._setupOrDestroyPlayer()||this.loadMidiForScore())}resize=new Se;_onResize(e){this._isDestroyed||(this.resize.trigger(e),this.uiFacade.triggerEvent(this.container,"resize",e))}renderStarted=new Se;_onRenderStarted(e){this._isDestroyed||(this.renderStarted.trigger(e),this.uiFacade.triggerEvent(this.container,"render
10Started",e))}renderFinished=new Se;_onRenderFinished(e){this._isDestroyed||(this.renderFinished.trigger(e),this.uiFacade.triggerEvent(this.container,"renderFinished",e))}postRenderFinished=new _t;_onPostRenderFinished(){this._isDestroyed||(this._beatVisibilityChecker.bounds=this.boundsLookup,this._currentBeat=null,this._cursorUpdateTick(this._previousTick,!1,1,!0,!0),this.postRenderFinished.trigger(),this.uiFacade.triggerEvent(this.container,"postRenderFinished",null))}error=new Se;onError(e){this._isDestroyed||(E.error("API","An unexpected error occurred",e),this.error.trigger(e),this.uiFacade.triggerEvent(this.container,"error",e))}get playerReady(){return this._player.readyForPlayback}_onPlayerReady(){this._isDestroyed||this.uiFacade.triggerEvent(this.container,"playerReady",null)}get playerFinished(){return this._player.finished}_onPlayerFinished(){this._isDestroyed||this.uiFacade.triggerEvent(this.container,"playerFinished",null)}get soundFontLoaded(){return this._player.soundFontLoaded}_onSoundFontLoaded(){this._isDestroyed||this.uiFacade.triggerEvent(this.container,"soundFontLoaded",null)}midiLoad=new Se;_onMidiLoad(e){this._isDestroyed||(this.midiLoad.trigger(e),this.uiFacade.triggerEvent(this.container,"midiLoad",e))}midiLoaded;_onMidiLoaded(e){this._isDestroyed||(this.midiLoaded.trigger(e),this.uiFacade.triggerEvent(this.container,"midiFileLoaded",e))}get playerStateChanged(){return this._player.stateChanged}_onPlayerStateChanged(e){if(!this._isDestroyed){if(!e.stopped&&e.state===Rt.Paused){const t=this._currentBeat,s=this._tickCache;t&&s&&(this._player.tickPosition=s.getBeatStart(t.beat),this.scrollToCursor())}this.uiFacade.triggerEvent(this.container,"playerStateChanged",e)}}get playerPositionChanged(){return this._player.positionChanged}_onPlayerPositionChanged(e){if(this._isDestroyed)return;const t=e.currentTick;this._previousTick=t,this.uiFacade.beginInvoke(()=>{const s=e.modifiedTempo/e.originalTempo;this._cursorUpdateTick(t,!1,s,!1,e.isSeek)}),this.uiFacade.triggerEvent(this.container,"playerPositionChanged",e)}get midiEventsPlayed(){return this._player.midiEventsPlayed}_onMidiEventsPlayed(e){this._isDestroyed||this.uiFacade.triggerEvent(this.container,"midiEventsPlayed",e)}get playbackRangeChanged(){return this._player.playbackRangeChanged}_onPlaybackRangeChanged(e){this._isDestroyed||this.uiFacade.triggerEvent(this.container,"playbackRangeChanged",e)}settingsUpdated=new _t;_onSettingsUpdated(){this._isDestroyed||(this.settingsUpdated.trigger(),this.uiFacade.triggerEvent(this.container,"settingsUpdated",null))}async enumerateOutputDevices(){return await this._player.output.enumerateOutputDevices()}async setOutputDevice(e){await this._player.output.setOutputDevice(e)}async getOutputDevice(){return await this._player.output.getOutputDevice()}async exportAudio(e){if(!this.score)throw new Ye(Ge.General,"No song loaded");let t;this._actualPlayerMode===ts.EnabledSynthesizer?t=this.uiFacade.createWorkerAudioExporter(this._player.instance):t=this.uiFacade.createWorkerAudioExporter(null);const s=this.score,i=new oi,r=new Rs(i),n=new Ne(s,this.settings,r);n.applyTranspositionPitches=!1,n.generate();const o=new Zl;o.soundFonts=e.soundFonts,o.sampleRate=e.sampleRate,o.useSyncPoints=e.useSyncPoints,o.masterVolume=e.masterVolume,o.metronomeVolume=e.metronomeVolume,o.playbackRange=e.playbackRange;for(const[l,h]of e.trackVolume)if(l<this.score.tracks.length){const c=this.score.tracks[l];o.trackVolume.set(c.playbackInfo.primaryChannel,h),o.trackVolume.set(c.playbackInfo.secondaryChannel,h)}for(const[l,h]of e.trackTranspositionPitches)if(l<this.score.tracks.length){const c=this.score.tracks[l];o.trackTranspositionPitches.set(c.playbackInfo.primaryChannel,h),o.trackTranspositionPitches.set(c.playbackInfo.secondaryChannel,h)}return await t.initialize(o,i,n.syncPoints,n.transpositionPitches),t}}class Hi extends Ye{xhr;constructor(e,t){super(Ge.General,e),this.xhr=t}}class $i{static loadAlphaTex(e,t){const s=new gn;return s.logErrors=!0,s.initFromString(e,t??new di),s.readScore()}static loadScoreAsync(e,t,s,i){const r=new XMLHttpRequest;r.open("GET",e,!0,null,null),r.responseType="arraybuffer",r.onreadystatechange=()=>{if(r.readyState===XMLHttpRequest.DONE){const n=r.response;if(r.status===200||r.status===0&&n)try{const o=r.response,l=new Uint8Array(o),h=$i.loadScoreFromBytes(l,i);t(h)}catch(o){s(o)}else r.status===0?s(new Hi(`You are offline!!
11 Please Check Your Network.`,r)):r.status===404?s(new Hi("Requested URL not found.",r)):r.status===500?s(new Hi("Internel Server Error.",r)):r.statusText==="parsererror"?s(new Hi(`
11Error.
12Parsing JSON Request failed.`,r)):r.statusText==="timeout"?s(new Hi("Request Time out.",r)):s(new Hi(`Unknow Error: ${r.responseText}`,r))}},r.send()}static loadScoreFromBytes(e,t){t||(t=new di);const s=M.buildImporters();E.debug("ScoreLoader",`Loading score from ${e.length} bytes using ${s.length} importers`);let i=null;const r=gt.fromBuffer(e);for(const n of s){r.reset();try{E.debug("ScoreLoader",`Importing using importer ${n.name}`),n.init(r,t),i=n.readScore(),E.debug("ScoreLoader",`Score imported using ${n.name}`);break}catch(o){if(o instanceof Bt)E.debug("ScoreLoader",`${n.name} does not support the file`);else throw E.error("ScoreLoader","Score import failed due to unexpected error: ",o),o}}if(i)return i;throw new Bt("No compatible importer found for file")}}class Fn{mouseEvent;get isLeftMouseButton(){return this.mouseEvent.button===0}getX(e){const t=e.element,i=t.getBoundingClientRect().left+t.ownerDocument.defaultView.pageXOffset;return this.mouseEvent.pageX-i}getY(e){const t=e.element,i=t.getBoundingClientRect().top+t.ownerDocument.defaultView.pageYOffset;return this.mouseEvent.pageY-i}preventDefault(){this.mouseEvent.preventDefault()}constructor(e){this.mouseEvent=e}}class bi{static _resizeObserver=new mr(()=>new ResizeObserver(e=>{for(const t of e){const s=new CustomEvent("resize",{detail:t});t.target.dispatchEvent(s)}}));_resizeListeners=0;get width(){return this.element.offsetWidth}set width(e){this.element.style.width=`${e}px`}get scrollLeft(){return this.element.scrollLeft}set scrollLeft(e){this.element.scrollLeft=e}get scrollTop(){return this.element.scrollTop}set scrollTop(e){this.element.scrollTop=e}get height(){return this.element.offsetHeight}set height(e){e>=0?this.element.style.height=`${e}px`:this.element.style.height="100%"}get isVisible(){return!!this.element.offsetWidth||!!this.element.offsetHeight||!!this.element.getClientRects().length}element;constructor(e){this.element=e,this.mouseDown={on:s=>{const i=r=>{s(new Fn(r))};return this.element.addEventListener("mousedown",i,!0),()=>{this.element.removeEventListener("mousedown",i,!0)}},off:s=>{}},this.mouseUp={on:s=>{const i=r=>{s(new Fn(r))};return this.element.addEventListener("mouseup",i,!0),()=>{this.element.removeEventListener("mouseup",i,!0)}},off:s=>{}},this.mouseMove={on:s=>{const i=r=>{s(new Fn(r))};return this.element.addEventListener("mousemove",i,!0),()=>{this.element.removeEventListener("mousemove",i,!0)}},off:s=>{}};const t=this;this.resize={on:function(s){return t._resizeListeners===0&&bi._resizeObserver.value.observe(t.element),t.element.addEventListener("resize",s,!0),t._resizeListeners++,()=>this.off(s)},off:s=>{this.element.removeEventListener("resize",s,!0),this._resizeListeners--,this._resizeListeners<=0&&(this._resizeListeners=0,bi._resizeObserver.value.unobserve(this.element))}}}stopAnimation(){this.element.style.transition="none"}transitionToX(e,t){this.element.style.transition=`transform ${e}ms linear`,this.setBounds(t,Number.NaN,Number.NaN,Number.NaN)}lastBounds=new bt;setBounds(e,t,s,i){Number.isNaN(e)&&(e=this.lastBounds.x),Number.isNaN(t)&&(t=this.lastBounds.y),Number.isNaN(s)&&(s=this.lastBounds.w),Number.isNaN(i)&&(i=this.lastBounds.h),this.element.style.transform=`translate(${e}px, ${t}px) scale(${s}, ${i})`,this.element.style.transformOrigin="top left",this.lastBounds.x=e,this.lastBounds.y=t,this.lastBounds.w=s,this.lastBounds.h=i}resize;mouseDown;mouseMove;mouseUp;appendChild(e){this.element.appendChild(e.element)}clear(){this.element.innerText=""}}class ml{_originalFamilies;_families;_isStarted=!1;isFontLoaded=!1;fontLoaded=new Se;constructor(e){this._originalFamilies=e,this._families=e}checkForFontAvailability(){if(M.isRunningInWorker){this.isFontLoaded=!1;return}if(this._isStarted)return;this._isStarted=!0;let e=0;const t=window.setInterval(()=>{E.warning("Rendering",`Could not load font '${this._families[0]}' within ${(e+1)*5} seconds`,null),this._families.length>1?(this._families.shift(),e=0):e++},5e3);E.debug("Font",`Start checking for font availablility: ${this._families.join(", ")}`);const s=n=>{this._families.length>1?(E.debug("Font",`[${this._families[0]}] Loading Failed, switching to ${this._families[1]}`,n),this._families.shift(),window.setTimeout(()=>{r()}
vendor: 11,534 bytes, line 12
12,0)):(E.error("Font",`[${this._originalFamilies.join(",")}] Loading Failed, rendering cannot start`,n),window.clearInterval(t))},i=n=>{E.debug("Font",`[${n}] Font API signaled available`),this.isFontLoaded=!0,window.clearInterval(t),this.fontLoaded.trigger(this._families[0])},r=async()=>{for(const n of this._families)if(await this._isFontAvailable(n,!1)){i(n);return}try{await document.fonts.load(`1em ${this._families[0]}`)}catch(n){s(n)}return E.debug("Font",`[${this._families[0]}] Font API signaled loaded`),await this._isFontAvailable(this._families[0],!0)?i(this._families[0]):s("Font not available"),!0};document.fonts.ready.then(()=>{r()})}_isFontAvailable(e,t){return new Promise(s=>{const i=`1em ${e}`;if(document.fonts.check(i))s(!0);else if(t){E.debug("Font",`Font ${e} not available, creating test element to trigger load`);const r=document.createElement("div");r.style.font=i,r.style.opacity="0",r.style.position="absolute",r.style.top="0",r.style.left="0",r.innerText=`Trigger ${e} load`,document.body.appendChild(r),setTimeout(()=>{document.body.removeChild(r),document.fonts.check(i)?s(!0):s(!1)},200)}else s(!1)})}}class ah extends zs{_audioNode=null;_circularBuffer;_bufferCount=0;_requestedBufferCount=0;open(e){super.open(e),this._bufferCount=Math.floor(e*this.sampleRate/1e3/zs.BufferSize),this._circularBuffer=new oo(zs.BufferSize*this._bufferCount),this.onReady()}play(){super.play();const e=this.context;this._audioNode=e.createScriptProcessor(4096,0,2),this._audioNode.onaudioprocess=this._generateSound.bind(this),this._circularBuffer.clear(),this._requestBuffers(),this.source=e.createBufferSource(),this.source.buffer=this.buffer,this.source.loop=!0,this.source.connect(this._audioNode,0,0),this.source.start(0),this._audioNode.connect(e.destination,0,0)}pause(){super.pause(),this._audioNode&&this._audioNode.disconnect(0),this._audioNode=null}addSamples(e){this._circularBuffer.write(e,0,e.length),this._requestedBufferCount--}resetSamples(){this._circularBuffer.clear()}_requestBuffers(){const e=this._bufferCount/2|0,t=e*zs.BufferSize;if(this._circularBuffer.count+this._requestedBufferCount*zs.BufferSize<t){for(let i=0;i<e;i++)this.onSampleRequest();this._requestedBufferCount+=e}}_outputBuffer=new Float32Array(0);_generateSound(e){const t=e.outputBuffer.getChannelData(0),s=e.outputBuffer.getChannelData(1),i=t.length+s.length;let r=this._outputBuffer;r.length!==i&&(r=new Float32Array(i),this._outputBuffer=r);const n=this._circularBuffer.read(r,0,Math.min(r.length,this._circularBuffer.count));let o=0;const l=Math.min(t.length,n);for(let h=0;h<l;h++)t[h]=r[o++],s[h]=r[o++];if(n<t.length)for(let h=n;h<t.length;h++)t[h]=0,s[h]=0;this.onSamplesPlayed(n/de.AudioChannels),this._requestBuffers()}}class ma{_synth;_output;_workerIsReadyForPlayback=!1;_workerIsReady=!1;_outputIsReady=!1;_state=Rt.Paused;_masterVolume=0;_metronomeVolume=0;_countInVolume=0;_playbackSpeed=0;_isLooping=!1;_playbackRange=null;_midiEventsPlayedFilter=[];_loadedMidiInfo;_currentPosition=new Ys(0,0,0,0,!1,120,120);get output(){return this._output}get isReady(){return this._workerIsReady&&this._outputIsReady}get isReadyForPlayback(){return this._workerIsReadyForPlayback}get state(){return this._state}get logLevel(){return E.logLevel}get worker(){return this._synth}set logLevel(e){E.logLevel=e,this._synth.postMessage({cmd:"alphaSynth.setLogLevel",value:e})}get masterVolume(){return this._masterVolume}set masterVolume(e){e=Math.max(e,de.MinVolume),this._masterVolume=e,this._synth.postMessage({cmd:"alphaSynth.setMasterVolume",value:e})}get metronomeVolume(){return this._metronomeVolume}set metronomeVolume(e){e=Math.max(e,de.MinVolume),this._metronomeVolume=e,this._synth.postMessage({cmd:"alphaSynth.setMetronomeVolume",value:e})}get countInVolume(){return this._countInVolume}set countInVolume(e){e=Math.max(e,de.MinVolume),this._countInVolume=e,this._synth.postMessage({cmd:"alphaSynth.setCountInVolume",value:e})}get midiEventsPlayedFilter(){return this._midiEventsPlayedFilter}set midiEventsPlayedFilter(e){this._midiEventsPlayedFilter=e,this._synth.postMessage({cmd:"alphaSynth.setMidiEventsPlayedFilter",value:M.prepareForPostMessage(e)})}get playbackSpeed(){return this._playbackSpeed}set playbackSpeed(e){e=L.clamp(e,de.MinPlaybackSpeed,de.MaxPlaybackSpeed),this._playbackSpeed=e,this._synth.postMessage({cmd:"alphaSynth.setPlaybackSpeed",value:e})}get loadedMidiInfo(){return this.loadedMidiInfo}get currentPosition(){return this._currentPosition}get tickPosition(){return this._currentPosition.currentTick}set tickPosition(e){e<0&&(e=0),this._currentPosition=new Ys(this._currentPosition.currentTime,this._currentPosition.endTime,e,this._currentPosition.endTick,!0,this._currentPosition.originalTempo,this._currentPosition.modifiedTempo),this._synth.postMessage({cmd:"alphaSynth.setTickPosition",value:e})}get timePosition(){return this._currentPosition.currentTime}set timePosition(e){e<0&&(e=0),this._currentPosition=new Ys(e,this._currentPosition.endTime,this._currentPosition.currentTick,this._currentPosition.endTick,!0,this._currentPosition.originalTempo,this._currentPosition.modifiedTempo),this._synth.postMessage({cmd:"alphaSynth.setTimePosition",value:e})}get isLooping(){return this._isLooping}set isLooping(e){this._isLooping=e,this._synth.postMessage({cmd:"alphaSynth.setIsLooping",value:e})}get playbackRange(){return this._playbackRange}set playbackRange(e){e&&(e.startTick<0&&(e.startTick=0),e.endTick<0&&(e.endTick=0)),this._playbackRange=e,this._synth.postMessage({cmd:"alphaSynth.setPlaybackRange",value:M.prepareForPostMessage(e)})}constructor(e,t){this._workerIsReadyForPlayback=!1,this._workerIsReady=!1,this._outputIsReady=!1,this._state=Rt.Paused,this._masterVolume=0,this._metronomeVolume=0,this._playbackSpeed=0,this._isLooping=!1,this._playbackRange=null,this._output=e,this._output.ready.on(this._onOutputReady.bind(this)),this._output.samplesPlayed.on(this.onOutputSamplesPlayed.bind(this)),this._output.sampleRequest.on(this.onOutputSampleRequest.bind(this)),this._output.open(t.player.bufferTimeInMilliseconds);try{this._synth=M.createWebWorker(t)}catch(s){E.error("AlphaSynth",`Failed to create WebWorker: ${s}`)}this._synth.addEventListener("message",this.handleWorkerMessage.bind(this),!1),this._synth.postMessage({cmd:"alphaSynth.initialize",sampleRate:this._output.sampleRate,logLevel:t.core.logLevel,bufferTimeInMilliseconds:t.player.bufferTimeInMilliseconds}),this.masterVolume=1,this.playbackSpeed=1,this.metronomeVolume=0}destroy(){this._synth.postMessage({cmd:"alphaSynth.destroy"})}play(){return this._output.activate(),this._synth.postMessage({cmd:"alphaSynth.play"}),!0}pause(){this._synth.postMessage({cmd:"alphaSynth.pause"})}playPause(){this._output.activate(),this._synth.postMessage({cmd:"alphaSynth.playPause"})}stop(){this._synth.postMessage({cmd:"alphaSynth.stop"})}playOneTimeMidiFile(e){this._synth.postMessage({cmd:"alphaSynth.playOneTimeMidiFile",midi:wt.midiFileToJsObject(M.prepareForPostMessage(e))})}loadSoundFont(e,t){this._synth.postMessage({cmd:"alphaSynth.loadSoundFontBytes",data:M.prepareForPostMessage(e),append:t})}resetSoundFonts(){this._synth.postMessage({cmd:"alphaSynth.resetSoundFonts"})}loadMidiFile(e){this._synth.postMessage({cmd:"alphaSynth.loadMidi",midi:wt.midiFileToJsObject(M.prepareForPostMessage(e))})}applyTranspositionPitches(e){this._synth.postMessage({cmd:"alphaSynth.applyTranspositionPitches",transpositionPitches:JSON.stringify(Array.from(M.prepareForPostMessage(e).entries()))})}setChannelTranspositionPitch(e,t){this._synth.postMessage({cmd:"alphaSynth.setChannelTranspositionPitch",channel:e,semitones:t})}setChannelMute(e,t){this._synth.postMessage({cmd:"alphaSynth.setChannelMute",channel:e,mute:t})}resetChannelStates(){this._synth.postMessage({cmd:"alphaSynth.resetChannelStates"})}setChannelSolo(e,t){this._synth.postMessage({cmd:"alphaSynth.setChannelSolo",channel:e,solo:t})}setChannelVolume(e,t){t=Math.max(t,de.MinVolume),this._synth.postMessage({cmd:"alphaSynth.setChannelVolume",channel:e,volume:t})}handleWorkerMessage(e){const t=e.data;switch(t.cmd){case"alphaSynth.ready":this._workerIsReady=!0,this._checkReady();break;case"alphaSynth.destroyed":this._synth.terminate();break;case"alphaSynth.readyForPlayback":this._workerIsReadyForPlayback=!0,this._checkReadyForPlayback();break;case"alphaSynth.positionChanged":this._currentPosition=new Ys(t.currentTime,t.endTime,t.currentTick,t.endTick,t.isSeek,t.originalTempo,t.modifiedTempo),this.positionChanged.trigger(this._currentPosition);break;case"alphaSynth.midiEventsPlayed":this.midiEventsPlayed.trigger(new xo(t.events.map(wt.jsObjectToMidiEvent)));break;case"alphaSynth.playerStateChanged":this._state=t.state,this.stateChanged.trigger(new Yi(t.state,t.stopped));break;case"alphaSynth.playbackRangeChanged":this._playbackRange=t.playbackRange,this.playbackRangeChanged.trigger(new br(this._playbackRange));break;case"alphaSynth.finished":this.finished.trigger();break;case"alphaSynth.soundFontLoaded":this.soundFontLoaded.trigger();break;case"alphaSynth.soundFontLoadFailed":this.soundFontLoadFailed.trigger(t.error);break;case"alphaSynth.midiLoaded":this._checkReadyForPlayback(),this._loadedMidiInfo=new Ys(t.currentTime,t.endTime,t.currentTick,t.endTick,t.isSeek,t.originalTempo,t.modifiedTempo),this.midiLoaded.trigger(this._loadedMidiInfo);break;case"alphaSynth.midiLoadFailed":this._checkReadyForPlayback(),this.midiLoadFailed.trigger(t.error);break;case"alphaSynth.output.addSamples":this._output.addSamples(t.samples);break;case"alphaSynth.output.play":this._output.play();break;case"alphaSynth.output.pause":this._output.pause();break;case"alphaSynth.output.destroy":this._output.destroy();break;case"alphaSynth.output.resetSamples":this._output.resetSamples();break}}_checkReady(){this.isReady&&this.ready.trigger()}_checkReadyForPlayback(){this.isReadyForPlayback&&this.readyForPlayback.trigger()}ready=new _t;readyForPlayback=new _t;finished=new _t;soundFontLoaded=new _t;soundFontLoadFailed=new Se;midiLoaded=new Se;midiLoadFailed=new Se;stateChanged=new Se;positionChanged=new Se;midiEventsPlayed=new Se;playbackRangeChanged=new Se;onOutputSampleRequest(){this._synth.postMessage({cmd:"alphaSynth.output.sampleRequest"})}onOutputSamplesPlayed(e){this._synth.postMessage({cmd:"alphaSynth.output.samplesPlayed",samples:e})}_onOutputReady(){this._outputIsReady=!0,this._checkReady()}loadBackingTrack(e){}updateSyncPoints(e){}}class Xc{_api;_worker;_width=0;boundsLookup=null;constructor(e,t){this._api=e;try{this._worker=M.createWebWorker(t)}catch(s){E.error("Rendering",`Failed to create WebWorker: ${s}`);return}this._worker.postMessage({cmd:"alphaTab.initialize",settings:this._serializeSettingsForWorker(t)}),this._worker.addEventListener("message",this._handleWorkerMessage.bind(this))}destroy(){this._worker.terminate()}updateSettings(e){this._worker.postMessage({cmd:"alphaTab.updateSettings",settings:this._serializeSettingsForWorker(e)})}_serializeSettingsForWorker(e){const t=wt.settingsToJsObject(M.prepareForPostMessage(e));return t.delete("player"),t}render(e){this._worker.postMessage({cmd:"alphaTab.render",renderHints:e})}resizeRender(){this._worker.postMessage({cmd:"alphaTab.resizeRender"})}renderResult(e){this._worker.postMessage({cmd:"alphaTab.renderResult",resultId:e})}get width(){return this._width}set width(e){this._width=e,this._worker.postMessage({cmd:"alphaTab.setWidth",width:e})}_handleWorkerMessage(e){const t=e.data;switch(t.cmd){case"alphaTab.preRender":this.preRender.trigger(t.resize);break;
12case"alphaTab.partialRenderFinished":this.partialRenderFinished.trigger(t.result);break;case"alphaTab.partialLayoutFinished":this.partialLayoutFinished.trigger(t.result);break;case"alphaTab.renderFinished":this.renderFinished.trigger(t.result);break;case"alphaTab.postRenderFinished":this.boundsLookup=ls.fromJson(t.boundsLookup,this._api.score),this.boundsLookup.finish(),this.postRenderFinished.trigger();break;case"alphaTab.error":this.error.trigger(t.error);break}}renderScore(e,t,s){const i=e==null?null:wt.scoreToJsObject(M.prepareForPostMessage(e));this._worker.postMessage({cmd:"alphaTab.renderScore",score:i,trackIndexes:M.prepareForPostMessage(t),fontSizes:bs.fontSizeLookupTables,renderHints:s})}preRender=new Se;partialRenderFinished=new Se;partialLayoutFinished=new Se;renderFinished=new Se;postRenderFinished=new _t;error=new Se}class nh{cursorWrapper;barCursor;beatCursor;selectionWrapper;constructor(e,t,s,i){this.cursorWrapper=e,this.barCursor=t,this.beatCursor=s,this.selectionWrapper=i}}class $c extends bi{_xscale;_yscale;centerAtPosition=!1;constructor(e,t,s){super(e),this._xscale=t,this._yscale=s}get width(){return this.element.offsetWidth/this._xscale}set width(e){this.element.style.width=`${e*this._xscale}px`}get height(){return this.element.offsetHeight/this._yscale}set height(e){e>=0?this.element.style.height=`${e*this._yscale}px`:this.element.style.height="100%"}setBounds(e,t,s,i){Number.isNaN(e)&&(e=this.lastBounds.x),Number.isNaN(t)&&(t=this.lastBounds.y),Number.isNaN(s)?s=this.lastBounds.w:s=s/this._xscale,Number.isNaN(i)?i=this.lastBounds.h:i=i/this._yscale;let r=`translate(${e}px, ${t}px) scale(${s}, ${i})`;this.centerAtPosition&&(r+=" translateX(-50%)"),this.element.style.transform=r,this.element.style.transformOrigin="top left",this.lastBounds.x=e,this.lastBounds.y=t,this.lastBounds.w=s,this.lastBounds.h=i}}class Jc{sampleRate=44100;audioElement;_updateInterval=0;get backingTrackDuration(){const e=this.audioElement.duration??0;return Number.isFinite(e)?e*1e3:0}get playbackRate(){return this.audioElement.playbackRate}set playbackRate(e){this.audioElement.playbackRate=e}get masterVolume(){return this.audioElement.volume}set masterVolume(e){this.audioElement.volume=e}seekTo(e){this.audioElement.currentTime=e/1e3}loadBackingTrack(e){this.audioElement?.src&&URL.revokeObjectURL(this.audioElement.src);const t=new Blob([e.rawAudioFile]),s=this.audioElement.playbackRate;this.audioElement.src=URL.createObjectURL(t),this.audioElement.playbackRate=s}open(e){const t=document.createElement("audio");t.style.display="none",document.body.appendChild(t),t.addEventListener("seeked",()=>{this._updatePosition()}),t.addEventListener("timeupdate",()=>{this._updatePosition()}),this.audioElement=t,this.ready.trigger()}_updatePosition(){const e=this.audioElement.currentTime*1e3;this.timeUpdate.trigger(e)}play(){this.audioElement.play(),this._updateInterval=window.setInterval(()=>{this._updatePosition()},50)}destroy(){const e=this.audioElement;e&&document.body.removeChild(e)}pause(){this.audioElement.pause(),window.clearInterval(this._updateInterval)}addSamples(e){}resetSamples(){}activate(){}ready=new _t;samplesPlayed=new Se;timeUpdate=new Se;sampleRequest=new _t;async enumerateOutputDevices(){return ds.enumerateOutputDevices()}async setOutputDevice(e){await ds.checkSinkIdSupport()&&(e?await this.audioElement.setSinkId(e.deviceId):await this.audioElement.setSinkId(""))}async getOutputDevice(){if(!await ds.checkSinkIdSupport())return null;const e=this.audioElement.sinkId;if(typeof e!="string"||e===""||e==="default")return null;let t=ds.findKnownDevice(e);if(t)return t;const s=await this.enumerateOutputDevices();return t=s.find(i=>i.deviceId===e),t||(E.warning("WebAudio","Could not find output device in device list",e,s),null)}}class Ao{static _nextExporterId=1;_worker;_unsubscribe;_exporterId;_ownsWorker;_promise=null;constructor(e,t){this._exporterId=Ao._nextExporterId++,this._worker=e,this._ownsWorker=t}async initialize(e,t,s,i){const r=this.handleWorkerMessage.bind(this);this._worker.worker.addEventListener("message",r,!1),this._unsubscribe=()=>{this._worker.worker.removeEventListener("message",r,!1)},this._promise=Promise.withResolvers(),this._worker.worker.postMessage({cmd:"alphaSynth.exporter.initialize",exporterId:this._exporterId,options:M.prepareForPostMessage(e),midi:wt.midiFileToJsObject(M.prepareForPostMessage(t)),syncPoints:M.prepareForPostMessage(s),transpositionPitches:M.prepareForPostMessage(i)}),await this._promise.promise}handleWorkerMessage(e){const t=e.data;if(t.exporterId!==this._exporterId)return;switch(t.cmd){case"alphaSynth.exporter.initialized":this._promise?.resolve(null),this._promise=null;break;case"alphaSynth.exporter.error":this._promise?.reject(t.error),this._promise=null;break;case"alphaSynth.exporter.rendered":this._promise?.resolve(t.chunk),this._promise=null;break;case"alphaSynth.destroyed":this._promise?.reject(new Ye(Ge.General,"Worker was destroyed")),this._promise=null;break}}async render(e){if(this._promise)throw new Ye(Ge.General,"There is already an ongoing operation, wait for initialize to complete before requesting render");return this._promise=Promise.withResolvers(),this._worker.worker.postMessage({cmd:"alphaSynth.exporter.render",exporterId:this._exporterId,milliseconds:e}),await this._promise.promise}destroy(){this._worker.worker.postMessage({cmd:"alphaSynth.exporter.destroy",exporterId:this._exporterId}),this._unsubscribe(),this._ownsWorker&&this._worker.destroy()}[Symbol.dispose](){this.destroy()}}var si;(function(a){a[a.LayoutDone=0]="LayoutDone",a[a.RenderRequested=1]="RenderRequested",a[a.RenderDone=2]="RenderDone",a[a.Detached=3]="Detached"})(si||(si={}));class Gi{_fontCheckers=new Map;_api;_contents=null;_file=null;_totalResultCount=0;_initialTrackIndexes=null;_intersectionObserver;_barToElementLookup=new Map;_resultIdToElementLookup=new Map;_webFont;rootContainerBecameVisible=new _t;canRenderChanged=new _t;get resizeThrottle(){return 10}rootContainer;areWorkersSupported;get canRender(){return this._areAllFontsLoaded()}_areAllFontsLoaded(){let e=!1;for(const t of this._fontCheckers.values())t.isFontLoaded||(e=!0);return e?!1:(E.debug("Font",`All fonts loaded: ${this._fontCheckers.size}
12`),!0)}_onFontLoaded(e){bs.generateFontLookup(e),this._areAllFontsLoaded()&&this.canRenderChanged.trigger()}constructor(e){if(M.webPlatform!==us.Browser&&M.webPlatform!==us.BrowserModule)throw new Ye(Ge.General,"Usage of AlphaTabApi is only possible in browser environments. For usage in node use the Low Level APIs");e.classList.add("alphaTab"),this.rootContainer=new bi(e),this.areWorkersSupported="Worker"in window,this._intersectionObserver=new IntersectionObserver(this._onElementVisibilityChanged.bind(this),{threshold:[0,.01,1]}),this._intersectionObserver.observe(e)}_onElementVisibilityChanged(e){for(const t of e){const s=t.target;if(s===this.rootContainer.element)t.isIntersecting&&(this.rootContainerBecameVisible.trigger(),this._intersectionObserver.unobserve(this.rootContainer.element));else if("layoutResultId"in s&&this._api.settings.core.enableLazyLoading){const i=s;t.isIntersecting?i.renderedResultId!==i.layoutResultId?this._resultIdToElementLookup.has(i.layoutResultId)?i.resultState!==si.RenderRequested&&(i.resultState=si.RenderRequested,this._api.renderer.renderResult(i.layoutResultId)):s.replaceChildren():i.resultState===si.Detached&&(s.replaceChildren(...i.renderedResult),i.resultState=si.RenderDone):i.resultState===si.RenderDone&&(i.resultState=si.Detached,i.replaceChildren())}}}createWorkerRenderer(){return new Xc(this._api,this._api.settings)}initialize(e,t){this._api=e;let s;t instanceof di?s=t:s=wt.jsObjectToSettings(t);const i=this._getDataAttributes();Ii.fromJson(s,i),s.notation.notationMode===Vt.SongBook&&s.setSongBookModeSettings(),e.settings=s,this._setupFontCheckers(s),this._initialTrackIndexes=this.parseTracks(s.core.tracks),this._contents="";const r=e.container;s.core.tex&&(this._contents=r.element.textContent,r.element.innerText=""),this._createStyleElements(s),this._file=s.core.file}_setupFontCheckers(e){for(const t of e.display.resources.elementFonts.values())this._registerFontChecker(t);this._registerFontChecker(e.display.resources.graceFont),this._registerFontChecker(e.display.resources.tablatureFont),this._registerFontChecker(e.display.resources.numberedNotationFont),this._registerFontChecker(e.display.resources.numberedNotationGraceFont)}_registerFontChecker(e){if(!this._fontCheckers.has(e.families.join(", "))){const t=new ml(e.families);this._fontCheckers.set(e.families.join(", "),t),t.fontLoaded.on(this._onFontLoaded.bind(this)),t.checkForFontAvailability()}}destroy(){const e=this.rootContainer.element;e.innerHTML="";const t=this._webFont,s=t.elements.get(e.ownerDocument);s&&(s.usages--,s.usages<=0&&(s.element.remove(),t.elements.delete(e.ownerDocument))),t.elements.size===0&&Gi._registeredWebFonts.delete(t.hash)}createCanvasElement(){const e=document.createElement("div");return e.classList.add("at-surface",`at${this._webFont.fontSuffix}`),e.style.fontSize="0",e.style.overflow="hidden",e.style.lineHeight="0",e.style.position="relative",new bi(e)}setCanvasOverflow(e,t,s){const i=e.element;t===0?(i.style.boxSizing="",i.style.paddingRight="",i.style.paddingBottom=""):s?(i.style.boxSizing="content-box",i.style.paddingBottom=`${t}px`):(i.style.boxSizing="content-box",i.style.paddingRight=`${t}px`)}triggerEvent(e,t,s=null,i){const r=e.element;t=`alphaTab.${t}`;const n=document.createEvent("CustomEvent"),o=i?i.mouseEvent:null;if(n.initCustomEvent(t,!1,!1,s),o&&(n.originalEvent=o),r.dispatchEvent(n),window&&"jQuery"in window){const l=window.jQuery,h=[];h.push(s),o&&h.push(o),l(r).trigger(t,h)}}load(e,t,s){if(e instanceof Ks)return t(e),!0;if(e instanceof ArrayBuffer){const i=new Uint8Array(e);return t($i.loadScoreFromBytes(i,this._api.settings)),!0}return e instanceof Uint8Array?(t($i.loadScoreFromBytes(e,this._api.settings)),!0):typeof e=="string"?($i.loadScoreAsync(e,t,s,this._api.settings),!0):!1}loadSoundFont(e,t){return this._api.player?e instanceof ArrayBuffer?(this._api.player.loadSoundFont(new Uint8Array(e),t),!0):e instanceof Uint8Array?(this._api.player.loadSoundFont(e,t),!0):typeof e=="string"?(this._api.loadSoundFontFromUrl(e,t),!0):!1:!1}initialRender(){this._api.renderer.preRender.on(t=>{this._totalResultCount=0,this._resultIdToElementLookup.clear(),this._barToElementLookup.clear()});const e=()=>{this._api.renderer.width=this.rootContainer.width|0,this._api.renderer.updateSettings(this._api.settings),this._contents?(this._api.tex(this._contents,this._initialTrackIndexes??void 0),this._initialTrackIndexes=null):this._file&&$i.loadScoreAsync(this._file,t=>{this._api.renderScore(t,this._initialTrackIndexes??void 0),this._initialTrackIndexes=null},t=>{this._api.onError(t)},this._api.settings)};this.rootContainer.isVisible?e():this.rootContainerBecameVisible.on(e)}_createStyleElements(e){const t=this._api.container.element.ownerDocument;Gi.createSharedStyleElement(t);const s=e.core.smuflFontSources??bh.buildDefaultSmuflFontSources(e.core.fontDirectory),i=Gi._cyrb53(s.values()),r=Gi._registeredWebFonts;if(r.has(i)){const f=r.get(i);f.checker.fontLoaded.on(this._onFontLoaded.bind(this)),this._createStyleElement(f,t),this._webFont=f;return}const n=r.size===0?"":String(r.size),o=`alphaTab${n}`,l=Array.from(s.entries()).map(f=>`url(${JSON.stringify(f[1])}) format('${Gi._cssFormat(f[0])}')`).join(","),h=`
13            @font-face {
14                font-display: block;
15                font-family: '${o}';
16                src: ${l};
17                font-weight: normal;
18                font-style: normal;
19            }
20            .at-surface.at${n} .at {
21                font-family: '${o}';
22                speak: none;
23                font-style: normal;
24                font-weight: normal;
25                font-variant: normal;
26                text-transform: none;
27                line-height: 1;
28                line-height: 1;
29                -webkit-font-smoothing: antialiased;
30                -moz-osx-font-smoothing: grayscale;
31                font-size: ${e.display.resources.engravingSettings.musicFontSize}px;
32                overflow: visible !important;
33            }`,c=new ml([o]);
33c.fontLoaded.on(this._onFontLoaded.bind(this)),this._fontCheckers.set(o,c),c.checkForFontAvailability(),e.display.resources.smuflFontFamilyName=o;const d={hash:i,elements:new Map,fontSuffix:n,checker:c,cssSource:h};this._createStyleElement(d,t),r.set(i,d),this._webFont=d}_createStyleElement(e,t){if(e.elements.has(t)){e.elements.get(t).usages++;return}const s=t.createElement("style");s.id=`alphaTabStyle${e.fontSuffix}`,s.innerHTML=e.cssSource,t.getElementsByTagName("head").item(0).appendChild(s),e.elements.set(t,{element:s,usages:1})}static _cssFormat(e){switch(e){case Is.EmbeddedOpenType:return"embedded-opentype";case Is.Woff:return"woff";case Is.Woff2:return"woff2";case Is.OpenType:return"opentype";case Is.TrueType:return"truetype";case Is.Svg:return"svg"}}static _registeredWebFonts=new Map;static _cyrb53(e,t=0){let s=3735928559^t,i=1103547991^t;for(const r of e)for(let n=0;n<r.length;n++){const o=r.charCodeAt(n);s=Math.imul(s^o,2654435761),i=Math.imul(i^o,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(e){let t=e.getElementById("alphaTabStyle");if(!t){t=document.createElement("style"),t.id="alphaTabStyleShared";const s=`
34                .at-surface * {
35                    cursor: default;
36                    vertical-align: top;
37                    overflow: visible;
38                }
39                .at-surface-svg text {
40                    dominant-baseline: alphabetic;
41                    white-space:pre;
42                }`;t.innerHTML=s,document.getElementsByTagName("head").item(0).appendChild(t)}}parseTracks(e){if(!e)return[];const t=[];if(typeof e=="string")try{if(e==="all")return[-1];e=JSON.parse(e)}catch{e=[0]}if(typeof e=="number")t.push(e);else if("length"in e){const s=e.length,i=e;for(let r=0;r<s;r++){const n=i[r];let o=0;typeof n=="number"?o=n:"index"in n?o=n.index:o=Number.parseInt(n.toString(),10),(o>=0||o===-1)&&t.push(o)}}else"index"in e&&t.push(e.index);return t}_getDataAttributes(){const e=new Map,t=this._api.container.element;if(t.dataset)for(const s of Object.keys(t.dataset)){let i=t.dataset[s];try{i=JSON.parse(i)}catch{i===""&&(i=null)}e.set(s,i)}else for(let s=0;s<t.attributes.length;s++){const i=t.attributes.item(s),r=i.nodeName;if(r.startsWith("data-")){const n=r.substr(5).split("-");let o=n[0];for(let h=1;h<n.length;h++)o+=n[h].substr(0,1).toUpperCase()+n[h].substr(1);let l=i.nodeValue;try{l=JSON.parse(l)}catch{l===""&&(l=null)}e.set(o,l)}}return e}beginUpdateRenderResults(e){if(!this._resultIdToElementLookup.has(e.id))return;const t=this._resultIdToElementLookup.get(e.id),s=e.renderResult;typeof s=="string"?t.innerHTML=s:"nodeType"in s&&t.replaceChildren(s),t.resultState=si.RenderDone,t.renderedResultId=e.id,t.renderedResult=Array.from(t.children)}beginAppendRenderResults(e){const t=this._api.canvasElement.element;if(e){let s;this._totalResultCount<t.childElementCount?s=t.childNodes.item(this._totalResultCount):(s=document.createElement("div"),t.appendChild(s)),s.style.zIndex="1",s.style.position="absolute",s.style.left=`${e.x}px`,s.style.top=`${e.y}px`,s.style.width=`${e.width}px`,s.style.height=`${e.height}px`,s.style.display="inline-block",s.layoutResultId=e.id,s.resultState=si.LayoutDone,s.renderedResultId=void 0,s.renderedResult=void 0,e.reuseViewport||(s.textContent=""),this._resultIdToElementLookup.set(e.id,s);for(let i=e.firstMasterBarIndex;i<=e.lastMasterBarIndex;i++)i>=0&&this._barToElementLookup.set(i,s);this._api.settings.core.enableLazyLoading&&(this._intersectionObserver.unobserve(s),this._intersectionObserver.observe(s)),this._totalResultCount++}else for(;t.childElementCount>this._totalResultCount;)this._api.settings.core.enableLazyLoading&&this._intersectionObserver.unobserve(t.lastChild),t.removeChild(t.lastElementChild)}createWorkerPlayer(){let e=null;const t="ScriptProcessorNode"in window;return window.isSecureContext&&"AudioWorkletNode"in window&&this._api.settings.player.outputMode===ea.WebAudioAudioWorklets?(E.debug("Player","Will use webworkers for synthesizing and web audio api with worklets for playback"),e=new ma(new Jl(this._api.settings),this._api.settings)):t&&(E.debug("Player","Will use webworkers for synthesizing and web audio api with ScriptProcessor for playback"),e=new ma(new ah,this._api.settings)),e?e.ready.on(()=>{this._api.settings.player.soundFont&&this._api.loadSoundFontFromUrl(this._api.settings.player.soundFont,!1)}):E.error("Player","Player requires webworkers and web audio api, browser unsupported",null),e}createWorkerAudioExporter(e){const t=e===null||!(e instanceof ma);return t&&(e=this.createWorkerPlayer()),new Ao(e,t)}beginInvoke(e){window.requestAnimationFrame(()=>{e()})}_highlightedElements=[];highlightElements(e,t){const s=this._barToElementLookup.get(t);if(s){const i=s.getElementsByClassName(e);for(let r=0;r<i.length;r++)i.item(r).classList.add("at-highlight"),this._highlightedElements.push(i.item(r))}}removeHighlights(){const e=this._highlightedElements;if(e){for(const t of e)t.classList.remove("at-highlight");this._highlightedElements=[]}}destroyCursors(){const e=this._api.container.element,t=e.querySelector(".at-cursors");e.removeChild(t)}createCursors(){const e=this._api.container.element,t=document.createElement("div");t.classList.add("at-cursors");const s=document.createElement("div");s.classList.add("at-selection");const i=this.createScalingElement(),r=this.createScalingElement(),n=i.element;n.classList.add("at-cursor-bar");const o=r.element;return o.classList.add("at-cursor-beat"),e.style.position="relative",e.style.textAlign="left",t.style.position="absolute",t.style.zIndex="1000",t.style.display="inline",t.style.pointerEvents="none",s.style.position="absolute",n.style.position="absolute",n.style.left="0",n.style.top="0",n.style.willChange="transform",i.width=1,i.height=1,i.setBounds(0,0,1,1),o.style.position="absolute",o.style.transition="all 0s linear",o.style.left="0",o.style.top="0",o.style.willChange="transform",r.width=3,r.height=1,r.centerAtPosition=!0,r.setBounds(0,0,1,1),e.insertBefore(t,e.firstChild),t.appendChild(s),t.appendChild(n),t.appendChild(o),new nh(new bi(t),i,r,new bi(s))}getOffset(e,t){const s=t.element,i=s.getBoundingClientRect();let r=i.top+s.ownerDocument.defaultView.pageYOffset,n=i.left+s.ownerDocument.defaultView.pageXOffset;
42if(e){const l=e.element,h=l.nodeName.toLowerCase();if(h!=="html"&&h!=="body"){const c=this.getOffset(null,e);r=r+l.scrollTop-c.y,n=n+l.scrollLeft-c.x}}const o=new bt;return o.x=n,o.y=r,o.w=i.width,o.h=i.height,o}_scrollContainer=null;getScrollContainer(){if(this._scrollContainer)return this._scrollContainer;let e=typeof this._api.settings.player.scrollElement=="string"?document.querySelector(this._api.settings.player.scrollElement):this._api.settings.player.scrollElement;const t=e.nodeName.toLowerCase();return(t==="html"||t==="body")&&("scrollingElement"in document?e=document.scrollingElement:navigator.userAgent.indexOf("WebKit")!==-1?e=document.body:e=document.documentElement),this._scrollContainer=new bi(e),this._scrollContainer}createSelectionElement(){return this.createScalingElement()}createScalingElement(){const e=document.createElement("div");e.style.position="absolute";const t=new $c(e,100,100);return t.width=1,t.height=1,t.setBounds(0,0,1,1),t}scrollToY(e,t,s){this._internalScrollToY(e.element,t,s)}scrollToX(e,t,s){this._internalScrollToX(e.element,t,s)}stopScrolling(e){const t=this._scrollAnimationLookup.get(e.element);t!==void 0&&this._activeScrollAnimations.delete(t)}get _nativeBrowserSmoothScroll(){const e=this._api.settings.player;return e.nativeBrowserSmoothScroll&&e.scrollMode!==Us.Smooth}_scrollAnimationId=0;_activeScrollAnimations=new Set;_scrollAnimationLookup=new Map;_internalScrollToY(e,t,s){this._nativeBrowserSmoothScroll?e.scrollTo({top:t,behavior:"smooth"}):this._internalScrollTo(e,e.scrollTop,t,s,i=>{e.scrollTop=i})}_internalScrollTo(e,t,s,i,r){const n=this._scrollAnimationLookup.get(e);if(n!==void 0&&this._activeScrollAnimations.delete(n),i===0){r(s);return}const o=this._scrollAnimationId++;this._scrollAnimationLookup.set(e,o),this._activeScrollAnimations.add(o);const l=s-t;let h=0;const c=d=>{if(!this._activeScrollAnimations.has(o))return;h===0&&(h=d);const f=d-h,p=Math.min(f/i,1);r(t+l*p|0),f<i?window.requestAnimationFrame(c):this._activeScrollAnimations.delete(o)};window.requestAnimationFrame(c)}_internalScrollToX(e,t,s){this._nativeBrowserSmoothScroll?e.scrollTo({left:t,behavior:"smooth"}):this._internalScrollTo(e,e.scrollLeft,t,s,i=>{e.scrollLeft=i})}createBackingTrackPlayer(){return new rh(new Jc,this._api.settings.player.bufferTimeInMilliseconds)}}class qc{loaded;total;constructor(e,t){this.loaded=e,this.total=t}}class Io extends Yc{constructor(e,t){super(new Gi(e),t)}tex(e,t){const s=this.uiFacade;super.tex(e,s.parseTracks(t))}print(e,t=null){const s=window.open("","","width=0,height=0"),i=s.document.createElement("div");e?i.style.width=e:this.settings.display.layoutMode===ni.Horizontal?i.style.width="297mm":i.style.width="210mm",s.document.write(`
43        <!DOCTYPE html>
44        <html>
45          <head>
46            <style>
47            .at-surface {
48                width: auto !important;
49                height: auto !important;
50            }
51            .at-surface > div {
52                position: relative!important;
53                left: auto !important;
54                top: auto !important;
55                break-inside: avoid;
56            }
57            </style>
58          </head>
59          <body></body>
60        </html>
61        `);const r=this.score;r&&(r.artist&&r.title?s.document.title=`${r.title} - ${r.artist}`:r.title&&(s.document.title=`${r.title}`)),s.document.body.appendChild(i);const n=typeof window.screenLeft<"u"?window.screenLeft:window.left,o=typeof window.screenTop<"u"?window.screenTop:window.top,l="innerWidth"in window?window.innerWidth:"clientWidth"in document.documentElement?document.documentElement.clientWidth:window.screen.width,h="innerHeight"in window?window.innerHeight:"clientHeight"in document.documentElement?document.documentElement.clientHeight:window.screen.height,c=i.offsetWidth+50,d=window.innerHeight,f=(l/2|0)-(c/2|0)+n,p=(h/2|0)-(d/2|0)+o;s.resizeTo(c,d),s.moveTo(f,p),s.focus();const g=wt.jsObjectToSettings(wt.settingsToJsObject(this.settings));g.core.enableLazyLoading=!1,g.core.useWorkers=!0,g.core.file=null,g.core.tracks=null,g.player.enableCursor=!1,g.player.playerMode=ts.Disabled,g.player.enableElementHighlighting=!1,g.player.enableUserInteraction=!1,g.player.soundFont=null,g.display.scale=.8,g.display.stretchForce=.8,Ii.fromJson(g,t);const m=new Io(i,g);s.onunload=()=>{m.destroy()}
vendor: 2,939 bytes, line 61
61,m.renderer.postRenderFinished.on(()=>{s.print()}),m.renderTracks(this.tracks)}downloadMidi(e=ji.SingleTrackMultiChannel){if(!this.score)return;const t=new oi;t.format=e;const s=new Rs(t,!0);new Ne(this.score,this.settings,s).generate();const r=t.toBinary(),n=this.score.title?`${this.score.title}.mid`:"File.mid",o=document.createElement("a");o.download=n;const l=new Blob([r],{type:"audio/midi"}),h=URL.createObjectURL(l);o.href=h,o.style.display="none",document.body.appendChild(o),o.click(),document.body.removeChild(o)}changeTrackMute(e,t){const s=this._trackIndexesToTracks(this.uiFacade.parseTracks(e));super.changeTrackMute(s,t)}changeTrackSolo(e,t){const s=this._trackIndexesToTracks(this.uiFacade.parseTracks(e));super.changeTrackSolo(s,t)}changeTrackVolume(e,t){const s=this._trackIndexesToTracks(this.uiFacade.parseTracks(e));super.changeTrackVolume(s,t)}_trackIndexesToTracks(e){if(!this.score)return[];const t=[];if(e.length===1&&e[0]===-1)for(const s of this.score.tracks)t.push(s);else for(const s of e)s>=0&&s<this.score.tracks.length&&t.push(this.score.tracks[s]);return t}soundFontLoad=new Se;loadSoundFontFromUrl(e,t){const s=this.player;if(!s)return;E.debug("AlphaSynth",`Start loading Soundfont from url ${e}`);const i=new XMLHttpRequest;i.open("GET",e,!0,null,null),i.responseType="arraybuffer",i.onload=r=>{const n=new Uint8Array(i.response);this.loadSoundFont(n,t)},i.onerror=r=>{E.error("AlphaSynth",`Loading failed: ${r.message}`),s.soundFontLoadFailed.trigger(new Hi(r.message,i))},i.onprogress=r=>{E.debug("AlphaSynth",`Soundfont downloading: ${r.loaded}/${r.total} bytes`);const n=new qc(r.loaded,r.total);this.soundFontLoad.trigger(n),this.uiFacade.triggerEvent(this.container,"soundFontLoad",n)},i.send()}}class yl{exec(e,t,s){if(typeof t!="string"&&(s=[t],t="init"),t.charCodeAt(0)===95||t==="exec")return null;const i=new jQuery(e),r=i.data("alphaTab");if(t==="destroy"&&!r)return null;if(t!=="init"&&!r)throw new Error("alphaTab not initialized");const n=this[t];if(n){const o=[i,r].concat(s);return n.apply(this,o)}return E.error("Api",`Method '${t}' does not exist on jQuery.alphaTab`),null}init(e,t,s){if(!t){t=new Io(e[0],s),e.data("alphaTab",t);for(const i of this._initListeners)i(e,t,s)}}destroy(e,t){e.removeData("alphaTab"),t.destroy()}print(e,t,s,i){t.print(s,i)}load(e,t,s,i){return t.load(s,i)}render(e,t){t.render()}renderScore(e,t,s,i){t.renderScore(s,i)}renderTracks(e,t,s){t.renderTracks(s)}invalidate(e,t){t.render()}tex(e,t,s,i){t.tex(s,i)}muteTrack(e,t,s,i){t.changeTrackMute(s,i)}soloTrack(e,t,s,i){t.changeTrackSolo(s,i)}trackVolume(e,t,s,i){t.changeTrackVolume(s,i)}loadSoundFont(e,t,s,i){t.loadSoundFont(s,i)}resetSoundFonts(e,t){t.resetSoundFonts()}pause(e,t){t.pause()}play(e,t){return t.play()}playPause(e,t){t.playPause()}stop(e,t){t.stop()}api(e,t){return t}player(e,t){return t.player}isReadyForPlayback(e,t){return t.isReadyForPlayback}playerState(e,t){return t.playerState}
61masterVolume(e,t,s){return typeof s=="number"&&(t.masterVolume=s),t.masterVolume}metronomeVolume(e,t,s){return typeof s=="number"&&(t.metronomeVolume=s),t.metronomeVolume}countInVolume(e,t,s){return typeof s=="number"&&(t.countInVolume=s),t.countInVolume}midiEventsPlayedFilter(e,t,s){return Array.isArray(s)&&(t.midiEventsPlayedFilter=s),t.midiEventsPlayedFilter}playbackSpeed(e,t,s){return typeof s=="number"&&(t.playbackSpeed=s),t.playbackSpeed}tickPosition(e,t,s){return typeof s=="number"&&(t.tickPosition=s),t.tickPosition}timePosition(e,t,s){return typeof s=="number"&&(t.timePosition=s),t.timePosition}loop(e,t,s){return typeof s=="boolean"&&(t.isLooping=s),t.isLooping}renderer(e,t){return t.renderer}score(e,t){return t.score}settings(e,t){return t.settings}tracks(e,t){return t.tracks}_initListeners=[];_oninit(e){this._initListeners.push(e)}static restore(e){new jQuery(e).empty().removeData("alphaTab")}}function Qc(a,e,t){if(e!=null){if(typeof e!="object"&&typeof e!="function")throw new TypeError("Object expected.");var s,i;if(s===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");s=e[Symbol.dispose]}if(typeof s!="function")throw new TypeError("Object not disposable.");i&&(s=function(){try{i.call(this)}catch(r){return Promise.reject(r)}}),a.stack.push({value:e,dispose:s,async:t})}return e}var Kc=typeof SuppressedError=="function"?SuppressedError:function(a,e,t){var s=new Error(t);return s.name="SuppressedError",s.error=a,s.suppressed=e,s};function Zc(a){function e(r){a.error=a.hasError?new Kc(r,a.error,"An error was suppressed during disposal."):r,a.hasError=!0}var t,s=0;function i(){for(;t=a.stack.pop();)try{if(!t.async&&s===1)return s=0,a.stack.push(t),Promise.resolve().then(i);if(t.dispose){var r=t.dispose.call(t.value);if(t.async)return s|=2,Promise.resolve(r).then(i,function(n){return e(n),i()})}else s|=1}catch(n){e(n)}if(s===1)return a.hasError?Promise.reject(a.error):Promise.resolve();if(a.hasError)throw a.error}return i()}class ut{static _alphaSkia;static _defaultMusicTextStyle=null;static enable(e,t){ut._alphaSkia=t,ut.initializeMusicFont(ut._alphaSkia.AlphaSkiaTypeface.register(e))}static initializeMusicFont(e){ut._defaultMusicTextStyle=new ut._alphaSkia.AlphaSkiaTextStyle([e.familyName],e.weight,e.isItalic)}static registerFont(e,t){const s=ut._alphaSkia.AlphaSkiaTypeface.register(e.buffer);return t||(t=ze.withFamilyList([s.familyName],12,s.isItalic?je.Italic:je.Plain,s.weight>400?rs.Bold:rs.Regular)),t}_canvas;_color=new Fe(0,0,0,0);_lineWidth=0;_textStyle=null;_scale=1;_textStyles=new Map;_font=new ze("Arial",10,je.Plain);_musicTextStyle=null;settings;get font(){return this._font}set font(e){if(this._font===e)return;this._font=e;const t=this._textStyleKey(e);if(this._textStyles.has(t))this._textStyle=this._textStyles.get(t);else{const s=new ut._alphaSkia.AlphaSkiaTextStyle(e.families,e.weight===rs.Bold?700:400,e.isItalic);this._textStyles.set(t,s),this._textStyle=s}}_textStyleKey(e){return[...e.families,e.weight.toString(),e.isItalic?"italic":"upright"].join("_")}constructor(){this._canvas=new ut._alphaSkia.AlphaSkiaCanvas,this.color=new Fe(0,0,0,255)}destroy(){this._canvas[Symbol.dispose]();for(const e of this._textStyles.values())e[Symbol.dispose]()}onRenderFinished(){return null}beginRender(e,t){this._scale=this.settings.display.scale,this._canvas.beginRender(e,t,M.highDpiFactor);const s=this.settings.display.resources.smuflFontFamilyName;s&&s!==ut._defaultMusicTextStyle.familyNames[0]?this._textStyles.has(s)?this._musicTextStyle=this._textStyles.get(s):(this._musicTextStyle=new ut._alphaSkia.AlphaSkiaTextStyle([s],ut._defaultMusicTextStyle.weight,ut._defaultMusicTextStyle.isItalic),this._textStyles.set(s,this._musicTextStyle)):this._musicTextStyle=ut._defaultMusicTextStyle}endRender(){return this._canvas.endRender()}get color(){return this._color}set color(e){this._color.rgba!==e.rgba&&(this._color=e,this._canvas.color=ut._alphaSkia.AlphaSkiaCanvas.rgbaToColor(e.r,e.g,e.b,e.a))}get lineWidth(){return this._lineWidth}set lineWidth(e){this._lineWidth=e,this._canvas.lineWidth=e}fillRect(e,t,s,i){s>0&&this._canvas.fillRect(e*this._scale,t*this._scale,s*this._scale,i*this._scale)}
61strokeRect(e,t,s,i){const r=this.lineWidth%2===0?0:.5;this._canvas.strokeRect(e*this._scale+r,t*this._scale+r,s*this._scale,i*this._scale)}beginPath(){this._canvas.beginPath()}closePath(){this._canvas.closePath()}moveTo(e,t){this._canvas.moveTo(e*this._scale,t*this._scale)}lineTo(e,t){this._canvas.lineTo(e*this._scale,t*this._scale)}quadraticCurveTo(e,t,s,i){this._canvas.quadraticCurveTo(e*this._scale,t*this._scale,s*this._scale,i*this._scale)}bezierCurveTo(e,t,s,i,r,n){this._canvas.bezierCurveTo(e*this._scale,t*this._scale,s*this._scale,i*this._scale,r*this._scale,n*this._scale)}fillCircle(e,t,s){this._canvas.fillCircle(e*this._scale,t*this._scale,s*this._scale)}strokeCircle(e,t,s){this._canvas.strokeCircle(e*this._scale,t*this._scale,s*this._scale)}fill(){this._canvas.fill()}stroke(){this._canvas.stroke()}textAlign=Y.Left;textBaseline=He.Top;beginGroup(e){}endGroup(){}fillText(e,t,s){if(e.length===0)return;let i=ut._alphaSkia.AlphaSkiaTextAlign.Left;switch(this.textAlign){case Y.Left:i=ut._alphaSkia.AlphaSkiaTextAlign.Left;break;case Y.Center:i=ut._alphaSkia.AlphaSkiaTextAlign.Center;break;case Y.Right:i=ut._alphaSkia.AlphaSkiaTextAlign.Right;break}let r=ut._alphaSkia.AlphaSkiaTextBaseline.Top;switch(this.textBaseline){case He.Top:r=ut._alphaSkia.AlphaSkiaTextBaseline.Top;break;case He.Middle:r=ut._alphaSkia.AlphaSkiaTextBaseline.Middle;break;case He.Bottom:r=ut._alphaSkia.AlphaSkiaTextBaseline.Bottom;break;case He.Alphabetic:r=ut._alphaSkia.AlphaSkiaTextBaseline.Alphabetic;break}this._canvas.fillText(e,this._textStyle,this._font.size*this._scale,t*this._scale,s*this._scale,i,r)}measureText(e){const t={stack:[],error:void 0,hasError:!1};try{const s=Qc(t,this._canvas.measureText(e,this._textStyle,this._font.size,ut._alphaSkia.AlphaSkiaTextAlign.Left,ut._alphaSkia.AlphaSkiaTextBaseline.Alphabetic),!1),[i,r]=this._getTextWidthAndHeight(s,e);return new aa(i,r)}catch(s){t.error=s,t.hasError=!0}finally{Zc(t)}}_getTextWidthAndHeight(e,t){let s=e.width;if(t.length>0&&s<1)for(let r=0;r<5&&(s=e.width,!(s>1));r++);const i=e.actualBoundingBoxAscent+e.actualBoundingBoxDescent;return[s,i]}fillMusicFontSymbol(e,t,s,i,r){i!==u.None&&this._fillMusicFontSymbolText(e,t,s,String.fromCharCode(i),r)}fillMusicFontSymbols(e,t,s,i,r){let n="";for(const o of i)o!==u.None&&(n+=String.fromCharCode(o));this._fillMusicFontSymbolText(e,t,s,n,r)}_fillMusicFontSymbolText(e,t,s,i,r){this._canvas.fillText(i,this._musicTextStyle,this.settings.display.resources.engravingSettings.musicFontSize*this._scale*s,e*this._scale,t*this._scale,r?ut._alphaSkia.AlphaSkiaTextAlign.Center:ut._alphaSkia.AlphaSkiaTextAlign.Left,ut._alphaSkia.AlphaSkiaTextBaseline.Alphabetic)}beginRotate(e,t,s){this._canvas.beginRotate(e*this._scale,t*this._scale,s)}endRotate(){this._canvas.endRotate()}}class _n{buffer="";_currentPath="";_currentPathIsEmpty=!0;scale=1;color=new Fe(255,255,255,255);lineWidth=1;font=new ze("Arial",10,je.Plain);textAlign=Y.Left;textBaseline=He.Top;settings;destroy(){}beginRender(e,t){this.scale=this.settings.display.scale,this.buffer=`<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="${e|0}px" height="${t|0}px" class="at-surface-svg">
62`,this._currentPath="",this._currentPathIsEmpty=!0,this.textBaseline=He.Top}beginGroup(e){this.buffer+=`<g class="${e}">`}endGroup(){this.buffer+="</g>"}endRender(){return this.buffer+="</svg>",this.buffer}fillRect(e,t,s,i){s>0&&(this.buffer+=`<rect x="${e*this.scale}" y="${t*this.scale}" width="${s*this.scale}" height="${i*this.scale}" fill="${this.color.rgba}" />
63`)}strokeRect(e,t,s,i){const r=this.lineWidth*this.scale%2===0?0:.5;this.buffer+=`<rect x="${e*this.scale+r}" y="${t*this.scale+r}" width="${s*this.scale}" height="${i*this.scale}" stroke="${this.color.rgba}"`,this.lineWidth!==1&&(this.buffer+=` stroke-width="${this.lineWidth*this.scale}"`),this.buffer+=` fill="transparent" />
64`}beginPath(){}closePath(){this._currentPath+=" z"}moveTo(e,t){this._currentPath+=` M${e*this.scale},${t*this.scale}`}lineTo(e,t){this._currentPathIsEmpty=!1,this._currentPath+=` L${e*this.scale},${t*this.scale}`}quadraticCurveTo(e,t,s,i){this._currentPathIsEmpty=!1,this._currentPath+=` Q${e*this.scale},${t*this.scale},${s*this.scale},${i*this.scale}`}bezierCurveTo(e,t,s,i,r,n){this._currentPathIsEmpty=!1,this._currentPath+=` C${e*this.scale},${t*this.scale},${s*this.scale},${i*this.scale},${r*this.scale},${n*this.scale}`}fillCircle(e,t,s){this._currentPathIsEmpty=!1,e*=this.scale,t*=this.scale,s*=this.scale,this._currentPath+=` M${e-s},${t} A1,1 0 0,0 ${e+s},${t} A1,1 0 0,0 ${e-s},${t} z`,this.fill()}strokeCircle(e,t,s){this._currentPathIsEmpty=!1,e*=this.scale,t*=this.scale,s*=this.scale,this._currentPath+=` M${e-s},${t} A1,1 0 0,0 ${e+s},${t} A1,1 0 0,0 ${e-s},${t} z`,this.stroke()}fill(){this._currentPathIsEmpty||(this.buffer+=`<path d="${this._currentPath}"`,this.color.rgba!=="#000000"&&(this.buffer+=` fill="${this.color.rgba}"`),this.buffer+=' style="stroke: none"/>'),this._currentPath="",this._currentPathIsEmpty=!0}stroke(){if(!this._currentPathIsEmpty){let e=`<path d="${this._currentPath}" stroke="${this.color.rgba}"`;(this.lineWidth!==1||this.scale!==1)&&(e+=` stroke-width="${this.lineWidth*this.scale}"`),e+=' style="fill: none" />',this.buffer+=e}this._currentPath="",this._currentPathIsEmpty=!0}
64fillText(e,t,s){if(e==="")return;let i=`<text x="${t*this.scale}" y="${s*this.scale}" style='stroke: none; font:${this.font.toCssString(this.settings.display.scale)}; ${this.getSvgBaseLine()}'`;this.color.rgba!=="#000000"&&(i+=` fill="${this.color.rgba}"`),this.textAlign!==Y.Left&&(i+=` text-anchor="${this.getSvgTextAlignment(this.textAlign)}"`),i+=`>${_n._escapeText(e)}</text>`,this.buffer+=i}static _escapeText(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}getSvgTextAlignment(e){switch(e){case Y.Left:return"start";case Y.Center:return"middle";case Y.Right:return"end"}return""}getSvgBaseLine(){switch(this.textBaseline){case He.Top:return"dominant-baseline: hanging";case He.Bottom:return"dominant-baseline: ideographic";case He.Alphabetic:return"";case He.Middle:return"dominant-baseline: middle";default:return""}}measureText(e){return e?bs.measureString(e,this.font.families,this.font.size,this.font.style,this.font.weight):new aa(0,0)}onRenderFinished(){return null}beginRotate(e,t,s){this.buffer+=`<g transform="translate(${e*this.scale} ,${t*this.scale}) rotate( ${s})">`}endRotate(){this.buffer+="</g>"}}class oh extends _n{fillMusicFontSymbol(e,t,s,i,r){i!==u.None&&this._fillMusicFontSymbolText(e,t,s,`&#${i};`,r)}fillMusicFontSymbols(e,t,s,i,r){let n="";for(const o of i)o!==u.None&&(n+=`&#${o};`);this._fillMusicFontSymbolText(e,t,s,n,r)}_fillMusicFontSymbolText(e,t,s,i,r){e*=this.scale,t*=this.scale,this.buffer+=`<g transform="translate(${e} ${t})" class="at" ><text`;const n=this.scale*s;n!==1?this.buffer+=` style="font-size: ${n*100}%; stroke:none"`:this.buffer+=' style="stroke:none"',this.color.rgba!=="#000000"&&(this.buffer+=` fill="${this.color.rgba}"`),r&&(this.buffer+=` text-anchor="${this.getSvgTextAlignment(Y.Center)}"`),this.buffer+=`>${i}</text></g>`}}var ue;(function(a){a[a.OwnedTop=0]="OwnedTop",a[a.OwnedBottom=1]="OwnedBottom",a[a.SharedTop=2]="SharedTop",a[a.SharedBottom=3]="SharedBottom"})(ue||(ue={}));class Sn{hideOnMultiTrack=!1;hideOnPercussionTrack=!1;effectBands;constructor(e){this.effectBands=e}canCreate(e,t){return!this.hideOnPercussionTrack||!t.isPercussion}}var ke;(function(a){a[a.SinglePreBeat=0]="SinglePreBeat",a[a.SingleOnBeat=1]="SingleOnBeat",a[a.SingleOnBeatToEnd=2]="SingleOnBeatToEnd",a[a.GroupedOnBeat=3]="GroupedOnBeat",a[a.GroupedOnBeatToEnd=4]="GroupedOnBeatToEnd",a[a.FullBar=5]="FullBar"})(ke||(ke={}));class fs extends Nt{beat=null;nextGlyph=null;previousGlyph=null;constructor(e=0,t=0){super(e,t)}}class jc extends fs{_endings;_endingsString="";_openLine;_closeLine;_indent;constructor(e,t,s,i,r,n){super(e,t),this._endings=L.getAlternateEndingsList(s),this._openLine=i,this._closeLine=r,this._indent=n}doLayout(){super.doLayout(),this.height=this.renderer.resources.elementFonts.get(C.EffectAlternateEndings).size+this.renderer.smuflMetrics.alternateEndingsPadding*2;let e="";for(let t=0,s=this._endings.length;t<s;t++)e+=this._endings[t]+1,e+=". ";this._endingsString=e}paint(e,t,s){let i=this._closeLine?this.width-s.lineWidth:this.width;if(this.renderer.bar.getActualBarLineRight()===ye.LightHeavy&&(i-=this.renderer.smuflMetrics.thickBarlineThickness+this.renderer.smuflMetrics.barlineSeparation),e=(e|0)+s.lineWidth/2,t=(t|0)+s.lineWidth/2,this._indent&&(e+=this.renderer.smuflMetrics.alternateEndingsPadding,i-=this.renderer.smuflMetrics.alternateEndingsPadding),this._openLine?(s.moveTo(e+this.x,t+this.y+this.height),s.lineTo(e+this.x,t+this.y)):s.moveTo(e+this.x,t+this.y),s.lineTo(e+this.x+i,t+this.y),this._closeLine&&s.lineTo(e+this.x+i,t+this.y+this.height),s.stroke(),this._openLine){const n=s.textBaseline;s.textBaseline=He.Top;const o=this.renderer.resources;s.font=o.elementFonts.get(C.EffectAlternateEndings),s.fillText(this._endingsString,e+this.x+this.renderer.smuflMetrics.alternateEndingsPadding,t+this.y+this.renderer.smuflMetrics.alternateEndingsPadding),s.textBaseline=n}}}class dt{get effectId(){return this.notationElement.toString()}finalizeBand(e){}onAlignGlyphs(e){}}class ed extends dt{get notationElement(){return C.EffectAlternateEndings}get hideOnMultiTrack(){return!0}get canShareBand(){return!1}get sizingMode(){return ke.FullBar}shouldCreateGlyph(e,t){return t.voice.index===0&&t.index===0&&t.voice.bar.masterBar.alternateEndings!==0}createNewGlyph(e,t){const s=t.voice.bar.masterBar,i=s.previousMasterBar===null||s.alternateEndings!==s.previousMasterBar.alternateEndings;let r=s.isRepeatEnd||s.nextMasterBar===null||s.alternateEndings!==s.nextMasterBar.alternateEndings;s.repeatGroup.closings.some(o=>o.index>=s.index)||(r=!1);const n=s.previousMasterBar!==null&&s.alternateEndings!==s.previousMasterBar.alternateEndings&&s.previousMasterBar.alternateEndings>0;return new jc(0,0,s.alternateEndings,i,r,n)}canExpand(e,t){return!0}}class oa extends fs{endPosition;forceGroupedRendering=!1;
vendor: 17,003 bytes, lines 64-65
64endOnBarLine=!1;constructor(e){super(),this.endPosition=e}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(e,t,s){if(this.isLinkedWithPrevious)return;if(!this.isLinkedWithNext&&!this.forceGroupedRendering){this.paintNonGrouped(e,t,s);return}let i;if(!this.isLinkedWithNext&&this.forceGroupedRendering)i=this;else for(i=this.nextGlyph;i.isLinkedWithNext;)i=i.nextGlyph;const r=i.renderer,n=i.beat,o=this.endPosition,l=e-this.renderer.x,h=this.calculateEndX(r,n,l,o);this.paintGrouped(e,t,h,s)}calculateEndX(e,t,s,i){return t?s+e.x+e.getBeatX(t,i):s+e.x+this.x+this.width}paintNonGrouped(e,t,s){const i=e-this.renderer.x,r=this.calculateEndX(this.renderer,this.beat,i,this.endPosition);this.paintGrouped(e,t,r,s)}}class ir extends oa{_label;_dashed;_labelWidth=0;_fontElement;constructor(e,t,s=!0){super(ae.OnNotes),this._label=e,this._dashed=s,this._fontElement=t}doLayout(){this.renderer.settings.notation.extendLineEffectsToBeatEnd&&(this.endPosition=ae.EndBeat,this.forceGroupedRendering=!0),super.doLayout(),this.renderer.scoreRenderer.canvas.font=this.renderer.resources.elementFonts.get(this._fontElement);const e=this.renderer.scoreRenderer.canvas.measureText(this._label);this.height=e.height,this._labelWidth=e.width}paintNonGrouped(e,t,s){const i=this.renderer.resources;s.font=i.elementFonts.get(this._fontElement);const r=s.textBaseline;s.textBaseline=He.Middle,s.fillText(this._label,e+this.x-this._labelWidth/2,t+this.y+this.height/2),s.textBaseline=r}paintGrouped(e,t,s,i){this.paintNonGrouped(e,t,i);const r=this.renderer.smuflMetrics.lineRangedGlyphDashGap,n=this.renderer.smuflMetrics.lineRangedGlyphDashSize,o=this.renderer.smuflMetrics.pedalLineThickness,l=e+this.x+this._labelWidth/2+r/2,h=t+this.y+this.height/2-o/2;if(this._dashed){if(s>l){let c=l;for(;c<s;){const d=Math.min(c+n,s);i.fillRect(c,h,d-c,o),c+=n+r}i.fillRect(s,h-n/2+o/2,o,n)}}else i.fillRect(l,h,s-l,o),i.fillRect(s-o,h,o,n/2)}}class sn extends dt{get notationElement(){return C.EffectLetRing}get canShareBand(){return!1}get hideOnMultiTrack(){return!1}shouldCreateGlyph(e,t){return t.isBarre}get sizingMode(){return ke.GroupedOnBeat}createNewGlyph(e,t){let s="";switch(t.barreShape){case xs.None:case xs.Full:break;case xs.Half:s+="1/2";break}return s+=`B ${sn.toRoman(t.barreFret)}`,new ir(s,C.EffectBeatBarre,!1)}static _romanLetters=new Map([["L",50],["XL",40],["X",10],["IX",9],["V",5],["IV",4],["I",1]]);static toRoman(e){let t="";if(e>0)for(const[s,i]of sn._romanLetters){const r=Math.floor(e/i);e-=r*i,t+=s.repeat(r)}return t}canExpand(e,t){return e.barreFret===t.barreFret&&e.barreShape===t.barreShape}}class td extends fs{_timer;_text="";_textWidth=0;_textHeight=0;constructor(e){super(0,0),this._timer=e}doLayout(){const e=this._timer/6e4|0,t=(this._timer-e*6e4)/1e3|0;this._text=`${e}:${t.toString().padStart(2,"0")}`;const s=this.renderer.scoreRenderer.canvas;s.font=this.renderer.resources.elementFonts.get(C.EffectBeatTimer);const i=s.measureText(this._text);this._textHeight=s.font.size+this.renderer.smuflMetrics.beatTimerPadding*2,this._textWidth=i.width+this.renderer.smuflMetrics.beatTimerPadding*2,this.height=this._textHeight+this.renderer.smuflMetrics.beatTimerPadding*2}paint(e,t,s){const i=this._textWidth/2|0;s.strokeRect(e+this.x-i,t+this.y+this.renderer.smuflMetrics.beatTimerPadding,this._textWidth,this._textHeight);const r=s.font,n=s.textBaseline,o=s.textAlign;s.font=this.renderer.resources.elementFonts.get(C.EffectBeatTimer),s.textBaseline=He.Middle,s.textAlign=Y.Center,s.fillText(this._text,e+this.x,t+this.y+this.height/2),s.font=r,s.textBaseline=n,s.textAlign=o}}class sd extends dt{get notationElement(){return C.EffectBeatTimer}get hideOnMultiTrack(){return!0}get canShareBand(){return!0}get sizingMode(){return ke.SingleOnBeat}shouldCreateGlyph(e,t){return t.showTimer}createNewGlyph(e,t){return new td(t.timer??0)}canExpand(e,t){return!0}}class Es extends fs{_lines;_lineHeights=null;font;textAlign;textBaseline;colorOverride;constructor(e,t,s,i,r=Y.Left,n=null,o){super(e,t),this._lines=s.split(`
65`),this.font=i,this.textAlign=r,this.textBaseline=n,this.colorOverride=o}doLayout(){super.doLayout(),this._lineHeights=[];const e=this.renderer.scoreRenderer.canvas;for(const t of this._lines){e.font=this.font;const s=e.measureText(t),i=s.height;this._lineHeights.push(i),this.height+=i,this.width=Math.max(this.width,s.width)}}paint(e,t,s){const i=s.color;s.color=this.colorOverride??i,s.font=this.font;const r=s.textAlign,n=s.textBaseline;s.textAlign=this.textAlign,this.textBaseline!==null&&(s.textBaseline=this.textBaseline);let o=t+this.y;for(let l=0;l<this._lines.length;l++)s.fillText(this._lines[l],e+this.x,o),o+=this._lineHeights[l];s.textAlign=r,s.textBaseline=n,s.color=i}}class id extends dt{get notationElement(){return C.EffectCapo}get hideOnMultiTrack(){return!1}get canShareBand(){return!1}get sizingMode(){return ke.SingleOnBeat}shouldCreateGlyph(e,t){return t.index===0&&t.voice.bar.index===0&&t.voice.bar.staff.capo!==0}createNewGlyph(e,t){return new Es(0,0,`Capo. fret ${t.voice.bar.staff.capo}`,e.resources.elementFonts.get(C.EffectCapo),Y.Left)}canExpand(e,t){return!1}}class pr extends fs{static _frets=5;_chord;_textRow=0;_fretRow=0;_firstFretSpacing=0;_center;_fontElement;constructor(e,t,s,i,r=!1){super(e,t),this._chord=s,this._center=r,this._fontElement=i}doLayout(){super.doLayout();const t=this.renderer.resources.elementFonts.get(this._fontElement);if(this._textRow=t.size*1.5,this._fretRow=t.size*1.5,this.height=this._textRow,this.width=2*this.renderer.smuflMetrics.chordDiagramPaddingX,this.renderer.settings.notation.isNotationElementVisible(C.ChordDiagramFretboardNumbers))this._chord.firstFret>1?this._firstFretSpacing=this.renderer.smuflMetrics.chordDiagramFretSpacing:this._firstFretSpacing=0,this.height+=this._fretRow+pr._frets*this.renderer.smuflMetrics.chordDiagramFretSpacing+2*this.renderer.smuflMetrics.chordDiagramPaddingY,this.width+=this._firstFretSpacing+(this._chord.strings.length-1)*this.renderer.smuflMetrics.chordDiagramStringSpacing;else if(this._chord.showName){const s=this.renderer.scoreRenderer.canvas;s.font=t,this.width+=s.measureText(this._chord.name).width}}paint(e,t,s){e+=this.x+this.renderer.smuflMetrics.chordDiagramPaddingX+this._firstFretSpacing,t+=this.y,this._center&&(e-=this.width/2);const i=this.renderer.resources,r=i.engravingSettings.chordDiagramLineWidth,n=this.width-2*this.renderer.smuflMetrics.chordDiagramPaddingX-this._firstFretSpacing+r,o=s.textAlign,l=s.textBaseline,h=i.elementFonts.get(this._fontElement);s.font=h,s.textAlign=Y.Center,s.textBaseline=He.Top,this._chord.showName&&s.fillText(this._chord.name,e+n/2,t+h.size/2),this.renderer.settings.notation.isNotationElementVisible(C.ChordDiagramFretboardNumbers)&&this._paintFretboard(e,t,s,n),s.textAlign=o,s.textBaseline=l}_paintFretboard(e,t,s,i){t+=this._textRow;const r=this.renderer.resources,n=this.renderer.smuflMetrics.chordDiagramStringSpacing,o=this.renderer.smuflMetrics.chordDiagramFretSpacing,l=r.engravingSettings.glyphHeights.get(u.FretboardFilledCircle),h=r.engravingSettings.glyphTop.get(u.FretboardFilledCircle),c=r.engravingSettings.glyphHeights.get(u.FretboardX)/2,d=r.engravingSettings.glyphHeights.get(u.FretboardO)/2,f=r.engravingSettings.chordDiagramLineWidth;s.font=r.elementFonts.get(C.ChordDiagramFretboardNumbers),s.textBaseline=He.Middle;for(let g=0;g<this._chord.strings.length;g++){const m=e+g*n,b=t+this._fretRow/2;let S=this._chord.strings[this._chord.strings.length-g-1];S<0?pt.fillMusicFontSymbolSafe(s,m,b+c,1,u.FretboardX,!0):S===0?pt.fillMusicFontSymbolSafe(s,m,b+d,1,u.FretboardO,!0):(S-=this._chord.firstFret-1,s.fillText(S.toString(),m,b))}t+=this._fretRow;for(let g=0;g<this._chord.strings.length;g++){const m=e+g*n;s.fillRect(m,t,f,o*pr._frets+1)}this._chord.firstFret>1?(s.textAlign=Y.Left,s.fillText(this._chord.firstFret.toString(),e-this._firstFretSpacing,t+o/2),s.fillRect(e,t,i,f)):s.fillRect(e,t-this.renderer.smuflMetrics.chordDiagramNutHeight/2,i,this.renderer.smuflMetrics.chordDiagramNutHeight);for(let g=0;g<=pr._frets;g++){const m=t+g*o;s.fillRect(e,m,i,this.renderer.smuflMetrics.chordDiagramFretHeight)}const p=new Map;for(const g of this._chord.barreFrets){const m=[-1,-1];p.set(g-this._chord.firstFret,m)}for(let g=0;g<this._chord.strings.length;g++){let m=this._chord.strings[g];if(m>0){if(m-=this._chord.firstFret,p.has(m)){const N=p.get(m);(N[0]===-1||g<N[0])&&(N[0]=g),(N[1]===-1||g>N[1])&&(N[1]=g)}const b=t+m*o+o/2+.5,S=e+(this._chord.strings.length-g-1)*n+f/2;pt.fillMusicFontSymbolSafe(s,S,b+h-l/2,1,u.FretboardFilledCircle,!0)}}for(const[g,m]of p){const b=t+g*o+o/2+.5,S=e+(this._chord.strings.length-m[1]-1)*n,N=e+(this._chord.strings.length-m[0]-1)*n;s.fillRect(S,b-l/2,N-S,l)}}}class rd extends dt{get notationElement(){return C.EffectChordNames}get hideOnMultiTrack(){return!1}get canShareBand(){return!0}get sizingMode(){return ke.SingleOnBeat}shouldCreateGlyph(e,t){return t.hasChord}createNewGlyph(e,t){return t.voice.bar.staff.track.score.stylesheet.globalDisplayChordDiagramsInScore?new pr(0,0,t.chord,C.EffectChordNames,!0):new Es(0,0,t.chord.name,e.resources.elementFonts.get(C.EffectChordNames),Y.Center)}canExpand(e,t){return!1}}class ad extends oa{_crescendo;constructor(e,t,s){super(ae.EndBeat),this._crescendo=Gt.None,this._crescendo=s,this.x=e,this.y=t}doLayout(){super.doLayout(),this.height=this.renderer.smuflMetrics.glyphHeights.get(u.DynamicCrescendoHairpin)}paintGrouped(e,t,s,i){const r=e+this.x,n=this.height,o=this.renderer.smuflMetrics.glyphWidths.get(u.NoteheadBlack)/2;i.beginPath(),this._crescendo===Gt.Crescendo?(s-=o,i.moveTo(s,t+this.y),i.lineTo(r,t+this.y+n/2),i.lineTo(s,t+this.y+n)):(s-=o,i.moveTo(r,t+this.y),i.lineTo(s,t+this.y+n/2),i.lineTo(r,t+this.y+n));const l=i.lineWidth;i.lineWidth=this.renderer.smuflMetrics.hairpinThickness,i.stroke(),i.lineWidth=l}}class nd extends dt{get notationElement(){return C.EffectCrescendo}get hideOnMultiTrack(){return!1}get canShareBand(){return!0}get sizingMode(){return ke.GroupedOnBeatToEnd}shouldCreateGlyph(e,t){return t.crescendo!==Gt.None}createNewGlyph(e,t){return new ad(0,0,t.crescendo)}canExpand(e,t){return e.crescendo===t.crescendo}}class ua extends Nt{_symbols;_scale=1;constructor(e){super(0,0),this._symbols=e}doLayout(){this.height=0;const e=this.renderer.smuflMetrics.directionsScale;this._scale=e;for(const t of this._symbols){const s=this.renderer.smuflMetrics.glyphHeights.get(t)*e;s>this.height&&(this.height=s)}}paint(e,t,s){s.fillMusicFontSymbols(e+this.x,t+this.y+this.height,this._scale,this._symbols,!0)}}class gs extends Nt{_text;constructor(e){super(0,0),this._text=e}doLayout(){const e=this.renderer.scoreRenderer.canvas;e.font=this.renderer.resources.elementFonts.get(C.EffectDirections),this.height=e.measureText(this._text).height}paint(e,t,s){const i=s.font,r=s.textBaseline,n=s.textAlign;s.font=this.renderer.resources.elementFonts.get(C.EffectDirections),s.textBaseline=He.Middle,s.textAlign=Y.Right,s.fillText(this._text,e+this.x,t+this.y+this.height/2),s.font=i,s.textBaseline=r,s.textAlign=n}}class od extends fs{_directions;_barBeginGlyphs=[];_barEndGlyphs=[];constructor(e,t,s){super(e,t),this._directions=s}doLayout(){const e=this._directions;e.has(U.TargetSegnoSegno)&&this._barBeginGlyphs.push(new ua([u.Segno,u.Segno])),e.has(U.TargetSegno)&&this._barBeginGlyphs.push(new ua([u.Segno])),e.has(U.TargetDoubleCoda)&&this._barBeginGlyphs.push(new ua([u.Coda,u.Coda])),e.has(U.TargetCoda)&&this._barBeginGlyphs.push(new ua([u.Coda])),e.has(U.TargetFine)&&this._barEndGlyphs.push(new gs("Fine")),e.has(U.JumpDaDoubleCoda)&&this._barEndGlyphs.push(new gs("To Double Coda")),e.has(U.JumpDaCoda)&&this._barEndGlyphs.push(new gs("To Coda")),e.has(U.JumpDalSegnoSegno)&&this._barEndGlyphs.push(new gs("D.S.S.")),e.has(U.JumpDalSegnoSegnoAlCoda)&&this._barEndGlyphs.push(new gs("D.S.S. al Coda")),e.has(U.JumpDalSegnoSegnoAlDoubleCoda)&&this._barEndGlyphs.push(new gs("D.S.S. al Double Coda")),e.has(U.JumpDalSegnoSegnoAlFine)&&this._barEndGlyphs.push(new gs("D.S.S. al Fine")),e.has(U.JumpDalSegno)&&this._barEndGlyphs.push(new gs("D.S.")),e.has(U.JumpDalSegnoAlCoda)&&this._barEndGlyphs.push(new gs("D.S. al Coda")),e.has(U.JumpDalSegnoAlDoubleCoda)&&this._barEndGlyphs.push(new gs("D.S. al Double Coda")),e.has(U.JumpDalSegnoAlFine)&&this._barEndGlyphs.push(new gs("D.S. al Fine")),e.has(U.JumpDaCapo)&&this._barEndGlyphs.push(new gs("D.C.")),e.has(U.JumpDaCapoAlCoda)&&this._barEndGlyphs.push(new gs("D.C. al Coda")),e.has(U.JumpDaCapoAlDoubleCoda)&&this._barEndGlyphs.push(new gs("D.C. al Double Coda")),e.has(U.JumpDaCapoAlFine)&&this._barEndGlyphs.push(new gs("D.C. al Fine"));const t=this._doSideLayout(this._barBeginGlyphs),s=this._doSideLayout(this._barEndGlyphs);this.height=Math.max(t,s)}_doSideLayout(e){let t=0;const s=this.renderer.settings.display.effectBandPaddingBottom;for(const i of e)i.y=t,i.renderer=this.renderer,i.doLayout(),t+=i.height+s;return t}paint(e,t,s){for(const i of this._barBeginGlyphs)i.paint(e+this.x,t+this.y,s);for(const i of this._barEndGlyphs)i.paint(e+this.x+this.width,t+this.y,s)}}class ld extends dt{get notationElement(){return C.EffectDirections}get hideOnMultiTrack(){return!0}get canShareBand(){return!1}get sizingMode(){return ke.FullBar}shouldCreateGlyph(e,t){return t.voice.index===0&&t.index===0&&t.voice.bar.masterBar.directions!==null&&t.voice.bar.masterBar.directions.size>0}createNewGlyph(e,t){return new od(0,0,t.voice.bar.masterBar.directions)}canExpand(e,t){return!0}}class Lt extends fs{glyphScale=0;symbol;center=!1;colorOverride;offsetX=0;offsetY=0;constructor(e,t,s,i){super(e,t),this.glyphScale=s,this.symbol=i}getBoundingBoxTop(){const e=this.renderer.smuflMetrics.glyphTop.get(this.symbol);return this.y-this.offsetY-e}doLayout(){this.width=this.renderer.smuflMetrics.glyphWidths.get(this.symbol)*this.glyphScale,this.height=this.renderer.smuflMetrics.glyphHeights.get(this.symbol)*this.glyphScale}paint(e,t,s){if(this.width===0&&this.height===0)return;const i=s.color;this.colorOverride&&(s.color=this.colorOverride),s.fillMusicFontSymbol(e+this.x+this.offsetX,t+this.y+this.offsetY,this.glyphScale,this.symbol,this.center),s.color=i}}class hd extends fs{glyphScale=0;symbols;center=!1;colorOverride;offsetX=0;offsetY=0;constructor(e,t,s,i){super(e,t),this.glyphScale=s,this.symbols=i}getBoundingBoxTop(){let e=0;for(let t=0;t<this.symbols.length;t++){const s=this.renderer.smuflMetrics.glyphTop.get(this.symbols[t]);(t===0||s<e)&&(e=s)}return this.y-this.offsetY-e}doLayout(){this.width=0,this.height=0;for(let e=0;e<this.symbols.length;e++){const t=this.renderer.smuflMetrics.glyphWidths.get(this.symbols[e])*this.glyphScale,s=this.renderer.smuflMetrics.glyphHeights.get(this.symbols[e])*this.glyphScale;(e===0||t>this.width)&&(this.width=t),(e===0||s>this.height)&&(this.height=s)}}paint(e,t,s){if(this.width===0&&this.height===0)return;const i=s.color;this.colorOverride&&(s.color=this.colorOverride),s.fillMusicFontSymbols(e+this.x+this.offsetX,t+this.y+this.offsetY,this.glyphScale,this.symbols,this.center),s.color=i}}class Ro extends Lt{constructor(e,t,s){super(e,t,1,Ro._getSymbol(s))}doLayout(){super.doLayout(),this.center=!0,this.height=this.renderer.smuflMetrics.glyphHeights.get(u.DynamicForte);const e=this.renderer.smuflMetrics.glyphTop.get(u.DynamicForte);this.offsetY=e}static _getSymbol(e){switch(e){case se.PPP:return u.DynamicPPP;case se.PP:return u.DynamicPP;case se.P:return u.DynamicPiano;case se.MP:return u.DynamicMP;case se.MF:return u.DynamicMF;case se.F:return u.DynamicForte;case se.FF:return u.DynamicFF;case se.FFF:return u.DynamicFFF;case se.PPPP:return u.DynamicPPPP;case se.PPPPP:return u.DynamicPPPPP;case se.PPPPPP:return u.DynamicPPPPP;case se.FFFF:return u.DynamicFFFF;case se.FFFFF:return u.DynamicFFFFF;case se.FFFFFF:return u.DynamicFFFFFF;case se.SF:return u.DynamicSforzando1;case se.SFP:return u.DynamicSforzandoPiano;case se.SFPP:return u.DynamicSforzandoPianissimo;case se.FP:return u.DynamicFortePiano;case se.RF:return u.DynamicRinforzando1;case se.RFZ:return u.DynamicRinforzando2;case se.SFZ:return u.DynamicSforzato;case se.SFFZ:return u.DynamicSforzatoFF;case se.FZ:return u.DynamicForzando;case se.N:return u.DynamicNiente;case se.PF:return u.DynamicPF;case se.SFZP:return u.DynamicSforzatoPiano;default:return u.None}}}class cd extends dt{get notationElement(){return C.EffectDynamics}get hideOnMultiTrack(){return!1}get canShareBand(){return!1}get sizingMode(){return ke.SingleOnBeat}shouldCreateGlyph(e,t){return this._internalShouldCreateGlyph(t)}_internalShouldCreateGlyph(e){if(e.voice.bar.staff.track.score.stylesheet.hideDynamics||e.isEmpty||e.voice.isEmpty||e.isRest)return!1;const t=this._getPreviousDynamicsBeat(e);let s=e.voice.index===0&&!t||e.dynamics!==t?.dynamics;if(s&&e.voice.index>
650){for(const i of e.voice.bar.voices)if(i.index<e.voice.index){const r=i.getBeatAtPlaybackStart(e.playbackStart);r&&e.dynamics===r.dynamics&&this._internalShouldCreateGlyph(r)&&(s=!1)}}return s}_getPreviousDynamicsBeat(e){let t=e.previousBeat;for(;t!=null;){if(!t.isRest)return t;t=t.previousBeat}return null}createNewGlyph(e,t){return new Ro(0,0,t.dynamics)}canExpand(e,t){return!0}}class Oo extends Lt{constructor(e){super(0,0,1,Oo._getSymbol(e)),this.center=!0}static _getSymbol(e){switch(e){case yt.FadeIn:return u.GuitarFadeIn;case yt.FadeOut:return u.GuitarFadeOut;case yt.VolumeSwell:return u.GuitarVolumeSwell}return u.None}paint(e,t,s){super.paint(e,t+this.height,s)}}class bl extends dt{get notationElement(){return C.EffectFadeIn}get hideOnMultiTrack(){return!1}get canShareBand(){return!0}get sizingMode(){return ke.SingleOnBeat}shouldCreateGlyph(e,t){return t.fade!==yt.None}createNewGlyph(e,t){return new Oo(t.fade)}canExpand(e,t){return!0}}class Wo extends Lt{constructor(e,t,s){super(e,t,1,Wo._getSymbol(s))}static _getSymbol(e){switch(e){case os.Short:return u.FermataShortAbove;case os.Medium:return u.FermataAbove;case os.Long:return u.FermataLongAbove;default:return u.None}}paint(e,t,s){super.paint(e-this.width/2,t+this.height,s)}}class dd extends dt{get notationElement(){return C.EffectFermata}get hideOnMultiTrack(){return!1}get canShareBand(){return!1}get sizingMode(){return ke.SingleOnBeat}shouldCreateGlyph(e,t){return t.voice.index===0&&!!t.fermata}createNewGlyph(e,t){return new Wo(0,0,t.fermata.type)}canExpand(e,t){return!0}}class js extends Nt{glyphs=null;get isEmpty(){return!this.glyphs||this.glyphs.length===0}getBoundingBoxTop(){let e=Number.NaN;const t=this.glyphs;if(t)for(const s of t)e=L.minBoundingBox(e,s.getBoundingBoxTop());return e}getBoundingBoxBottom(){let e=Number.NaN;const t=this.glyphs;if(t)for(const s of t)e=L.maxBoundingBox(e,s.getBoundingBoxBottom());return e}doLayout(){if(!this.glyphs||this.glyphs.length===0){this.width=0;return}let e=0,t=0;for(let s=0,i=this.glyphs.length;s<i;s++){const r=this.glyphs[s];r.renderer=this.renderer,r.doLayout(),e=Math.max(e,r.width),t=Math.max(t,r.y+r.height)}this.width=e,this.height=t}addGlyph(e){this.glyphs||(this.glyphs=[]),this.renderer&&(e.renderer=this.renderer),this.glyphs.push(e)}paint(e,t,s){const i=this.glyphs;if(!(!i||i.length===0))for(const r of i)r.paint(e+this.x,t+this.y,s)}}class xe{static score(e,t,s,i=!1){if(!s.style&&!i)return;const r=xe._scoreDefaultColor(e.settings.display.resources,t);return new nr(e,t,s.style,r)}static scoreColor(e,t,s){const i=xe._scoreDefaultColor(e,t);if(s.style&&s.style.colors.has(t))return s.style.colors.get(t)??i}static _scoreDefaultColor(e,t){return e.mainGlyphColor}static bar(e,t,s,i=!1){if(!s.style&&!i)return;let r=e.settings.display.resources.mainGlyphColor;switch(t){case Le.StandardNotationRepeats:case Le.GuitarTabsRepeats:case Le.SlashRepeats:case Le.NumberedRepeats:case Le.StandardNotationClef:case Le.GuitarTabsClef:case Le.StandardNotationKeySignature:case Le.NumberedKeySignature:case Le.StandardNotationTimeSignature:case Le.GuitarTabsTimeSignature:case Le.SlashTimeSignature:case Le.NumberedTimeSignature:break;case Le.StandardNotationBarLines:case Le.GuitarTabsBarLines:case Le.SlashBarLines:case Le.NumberedBarLines:r=e.settings.display.resources.barSeparatorColor;break;case Le.StandardNotationBarNumber:case Le.SlashBarNumber:case Le.NumberedBarNumber:case Le.GuitarTabsBarNumber:r=e.settings.display.resources.barNumberColor;break;case Le.StandardNotationStaffLine:case Le.GuitarTabsStaffLine:case Le.SlashStaffLine:case Le.NumberedStaffLine:r=e.settings.display.resources.staffLineColor;break}return new nr(e,t,s.style,r)}static voice(e,t,s,i=!1){if(!s.style&&!i)return;const r=s.index===0?e.settings.display.resources.mainGlyphColor:e.settings.display.resources.secondaryGlyphColor;return new nr(e,t,s.style,r)}static trackColor(e,t,s){const i=xe._trackDefaultColor(e,t);if(s.style&&s.style.colors.has(t))return s.style.colors.get(t)??i}static _trackDefaultColor(e,t){let s=e.mainGlyphColor;switch(t){case $s.TrackName:case $s.SystemSeparator:case $s.StringTuning:break;case $s.BracesAndBrackets:s=e.barSeparatorColor;break}return s}static track(e,t,s,i=!1){if(!s.style&&!i)return;const r=xe._trackDefaultColor(e.settings.display.resources,t);return new nr(e,t,s.style,r)}static beatColor(e,t,s){const i=xe._beatDefaultColor(e,t,s);if(s.style&&s.style.colors.has(t))return s.style.colors.get(t)??i}static _beatDefaultColor(e,t,s){return s.voice.index===0?e.mainGlyphColor:e.secondaryGlyphColor}static beat(e,t,s,i=!1){if(!s.style&&!i)return;const r=xe._beatDefaultColor(e.settings.display.resources,t,s);return new nr(e,t,s.style,r)}static noteColor(e,t,s){const i=xe._noteDefaultColor(e,t,s);if(s.style&&s.style.colors.has(t))return s.style.colors.get(t)??i}static _noteDefaultColor(e,t,s){return s.beat.voice.index===0?e.mainGlyphColor:e.secondaryGlyphColor}static note(e,t,s,i=!1){if(!s.style&&!i)return;
vendor: 19,083 bytes, line 65
65const r=s.beat.voice.index===0?e.settings.display.resources.mainGlyphColor:e.settings.display.resources.secondaryGlyphColor;return new nr(e,t,s.style,r)}}class nr{_canvas;_previousColor;constructor(e,t,s,i){this._canvas=e,s&&s.colors.has(t)?(this._previousColor=e.color,e.color=s.colors.get(t)??i):s||(this._previousColor=e.color,e.color=i)}[Symbol.dispose](){this._previousColor&&(this._canvas.color=this._previousColor)}}class ud{line=0;symbols;color;constructor(e,t){this.line=e,this.symbols=t}}class ta extends js{_infos=new Map;constructor(){super(0,0)}get isEmpty(){return this._infos.size===0}addFingers(e){const t=this.renderer.settings;if(t.notation.fingeringMode!==Xs.ScoreDefault&&t.notation.fingeringMode!==Xs.ScoreForcePiano)return;const s=ta.fingerToMusicFontSymbol(this.renderer.settings,e.beat,e.leftHandFinger,!0);s!==u.None&&this._addFinger(e,s);const i=ta.fingerToMusicFontSymbol(this.renderer.settings,e.beat,e.rightHandFinger,!1);i!==u.None&&this._addFinger(e,i)}static fingerToMusicFontSymbol(e,t,s,i){if(e.notation.fingeringMode===Xs.ScoreForcePiano||e.notation.fingeringMode===Xs.SingleNoteEffectBandForcePiano||Ss.isPiano(t.voice.bar.staff.track.playbackInfo.program))switch(s){case ie.Unknown:case ie.NoOrDead:return u.None;case ie.Thumb:return u.Fingering1;case ie.IndexFinger:return u.Fingering2;case ie.MiddleFinger:return u.Fingering3;case ie.AnnularFinger:return u.Fingering4;case ie.LittleFinger:return u.Fingering5;default:return u.None}if(i)switch(s){case ie.Unknown:return u.None;case ie.NoOrDead:return u.Fingering0;case ie.Thumb:return u.FingeringTLower;case ie.IndexFinger:return u.Fingering1;case ie.MiddleFinger:return u.Fingering2;case ie.AnnularFinger:return u.Fingering3;case ie.LittleFinger:return u.Fingering4;default:return u.None}switch(s){case ie.Unknown:case ie.NoOrDead:return u.None;case ie.Thumb:return u.FingeringPLower;case ie.IndexFinger:return u.FingeringILower;case ie.MiddleFinger:return u.FingeringMLower;case ie.AnnularFinger:return u.FingeringALower;case ie.LittleFinger:return u.FingeringCLower;default:return u.None}}_addFinger(e,t){const s=this.renderer,i=s.getNoteSteps(e);if(this._infos.has(i))this._infos.get(i).symbols.push(t);else{const r=new ud(i,[t]);r.color=xe.noteColor(s.resources,$t.StandardNotationEffects,e),this._infos.set(i,r)}}doLayout(){const e=this.renderer;for(const[t,s]of this._infos){const i=new hd(0,0,1,s.symbols);i.colorOverride=s.color,i.renderer=e,i.y=e.getScoreY(s.line),i.doLayout(),i.offsetY=i.height/2,this.addGlyph(i),this.width=Math.max(this.width,i.width)}for(const t of this.glyphs){const s=t;s.x=this.width/2,s.center=!0}}}class fd extends dt{get notationElement(){return C.EffectFingering}get hideOnMultiTrack(){return!1}get canShareBand(){return!0}get sizingMode(){return ke.SingleOnBeat}shouldCreateGlyph(e,t){return t.voice.index!==0||t.isRest||e.notation.fingeringMode!==Xs.SingleNoteEffectBand&&e.notation.fingeringMode!==Xs.SingleNoteEffectBandForcePiano||t.notes.length!==1?!1:t.notes[0].isFingering}createNewGlyph(e,t){let s=ie.Unknown,i=!1;const r=t.notes[0];r.leftHandFinger!==ie.Unknown?(s=r.leftHandFinger,i=!0):r.rightHandFinger!==ie.Unknown&&(s=r.rightHandFinger);const n=ta.fingerToMusicFontSymbol(e.settings,t,s,i),o=new Lt(0,0,1,n);return o.center=!0,o.renderer=e,o.doLayout(),o.offsetY=e.smuflMetrics.glyphTop.get(o.symbol),o}canExpand(e,t){return!0}}class pd extends dt{get notationElement(){return C.EffectText}get hideOnMultiTrack(){return!1}get canShareBand(){return!0}get sizingMode(){return ke.SinglePreBeat}shouldCreateGlyph(e,t){const s=t.voice.bar.masterBar;return t.voice.bar.staff.index===0&&t.voice.index===0&&t.index===0&&s.isFreeTime&&(s.index===0||s.isFreeTime!==s.previousMasterBar.isFreeTime)}createNewGlyph(e,t){return new Es(0,0,"Free time",e.resources.elementFonts.get(C.EffectFreeTime),Y.Left)}canExpand(e,t){return!0}}class lh extends Lt{constructor(e,t,s=!1){super(e,t,We.GraceScale,u.GuitarGolpe),this.center=s}doLayout(){super.doLayout(),this.offsetY=this.height}}class fa extends dt{_type;constructor(e){super(),this._type=e}get notationElement(){return C.EffectGolpe}get effectId(){return`${super.effectId}.${Xt[this._type]}`}get hideOnMultiTrack(){return!1}get canShareBand(){return!0}get sizingMode(){return ke.SingleOnBeat}shouldCreateGlyph(e,t){return t.golpe===this._type}createNewGlyph(e,t){return new lh(0,0,!0)}canExpand(e,t){return!1}}class rr extends dt{lastCreateInfo=null;shouldCreateGlyph(e,t){this.lastCreateInfo=[];for(let s=0,i=t.notes.length;s<i;s++){const r=t.notes[s];this.shouldCreateGlyphForNote(r)&&this.lastCreateInfo.push(r)}return this.lastCreateInfo.length>0}get hideOnMultiTrack(){return!1}get canShareBand(){return!0}canExpand(e,t){return!0}}class vi extends rr{_harmonicType;_beat=null;_effectId;get effectId(){return this._effectId}get notationElement(){return C.EffectHarmonics}constructor(e){switch(super(),this._harmonicType=e,e){case te.None:this._effectId="harmonics-none";break;case te.Natural:this._effectId="harmonics-natural";break;case te.Artificial:this._effectId="harmonics-artificial";break;case te.Pinch:this._effectId="harmonics-pinch";break;case te.Tap:this._effectId="harmonics-tap";break;case te.Semi:this._effectId="harmonics-semi";break;case te.Feedback:this._effectId="harmonics-feedback";break;default:this._effectId="";break}}shouldCreateGlyphForNote(e){return!e.isHarmonic||e.harmonicType!==this._harmonicType?!1:(e.beat!==this._beat&&(this._beat=e.beat),!0)}get sizingMode(){return ke.GroupedOnBeat}createNewGlyph(e,t){return new ir(vi.harmonicToString(this._harmonicType),C.EffectHarmonics)}static harmonicToString(e){switch(e){case te.Natural:return"N.H.";case te.Artificial:return"A.H.";case te.Pinch:return"P.H.";case te.Tap:return"T.H.";case te.Semi:return"S.H.";case te.Feedback:return"Fdbk."}return""}}class gd extends Lt{constructor(){super(0,0,1,u.GuitarLeftHandTapping),this.center=!0}doLayout(){super.doLayout(),this.offsetY=this.renderer.smuflMetrics.glyphTop.get(this.symbol)}}class _l extends rr{get notationElement(){return C.EffectTap}get sizingMode(){return ke.SingleOnBeat}shouldCreateGlyphForNote(e){return e.isLeftHandTapped}createNewGlyph(e,t){return new gd}}class Sl extends dt{get notationElement(){return C.EffectLetRing}get canShareBand(){return!1}get hideOnMultiTrack(){return!1}shouldCreateGlyph(e,t){return t.isLetRing}get sizingMode(){return ke.GroupedOnBeat}createNewGlyph(e,t){return new ir("LetRing",C.EffectLetRing)}canExpand(e,t){return!0}}class md extends fs{_lines;_linePositions=[];font;textAlign;constructor(e,t,s,i,r=Y.Center){super(e,t),this._lines=s,this.font=i,this.textAlign=r}doLayout(){super.doLayout();const e=this.renderer.settings.display.lyricLinesPaddingBetween,t=this.renderer.scoreRenderer.canvas;t.font=this.font;let s=0;for(const i of this._lines){this._linePositions.push(s);const r=t.measureText(i.length>0?i:" ");s+=r.height+e}s-=e,this.height=s}paint(e,t,s){s.font=this.font;const i=s.textAlign;s.textAlign=this.textAlign;for(let r=0;r<this._lines.length;r++)this._lines[r]&&s.fillText(this._lines[r],e+this.x,t+this.y+this._linePositions[r]);s.textAlign=i}}class yd extends dt{get notationElement(){return C.EffectLyrics}get hideOnMultiTrack(){return!1}get canShareBand(){return!1}get sizingMode(){return ke.SingleOnBeat}shouldCreateGlyph(e,t){return!!t.lyrics}createNewGlyph(e,t){return new md(0,0,t.lyrics,e.resources.elementFonts.get(C.EffectLyrics),Y.Center)}canExpand(e,t){return!0}}class bd extends dt{get notationElement(){return C.EffectMarker}get hideOnMultiTrack(){return!0}get canShareBand(){return!0}get sizingMode(){return ke.SinglePreBeat}shouldCreateGlyph(e,t){return t.voice.bar.staff.index===0&&t.voice.index===0&&t.index===0&&t.voice.bar.masterBar.isSectionStart}createNewGlyph(e,t){return new Es(0,0,t.voice.bar.masterBar.section.marker?`[${t.voice.bar.masterBar.section.marker}] ${t.voice.bar.masterBar.section.text}`:t.voice.bar.masterBar.section.text,e.resources.elementFonts.get(C.EffectMarker),Y.Left)}canExpand(e,t){return!0}}class Vo extends Lt{constructor(e){super(0,0,1,Vo._getSymbol(e)),this.center=!0}static _getSymbol(e){switch(e){case ot.InvertedTurn:return u.OrnamentTurnInverted;case ot.Turn:return u.OrnamentTurn;case ot.UpperMordent:return u.OrnamentShortTrill;case ot.LowerMordent:return u.OrnamentMordent}return u.None}doLayout(){super.doLayout(),this.height=this.renderer.smuflMetrics.glyphHeights.get(u.OrnamentMordent),this.offsetY=this.renderer.smuflMetrics.glyphTop.get(u.OrnamentMordent)}}class _d extends dt{get notationElement(){return C.EffectNoteOrnament}get hideOnMultiTrack(){return!1}get canShareBand(){return!0}get sizingMode(){return ke.SingleOnBeat}shouldCreateGlyph(e,t){return t.notes.some(s=>s.ornament!==ot.None)}createNewGlyph(e,t){return new Vo(t.notes.find(s=>s.ornament!==ot.None).ornament)}canExpand(e,t){return!1}}class ci extends Lt{constructor(e,t,s,i){super(e,t,i,ci.getMusicSymbol(s))}static getMusicSymbol(e){switch(e){case ee.Natural:return u.AccidentalNatural;case ee.Sharp:return u.AccidentalSharp;case ee.Flat:return u.AccidentalFlat;case ee.NaturalQuarterNoteUp:return u.AccidentalQuarterToneSharpNaturalArrowUp;case ee.SharpQuarterNoteUp:return u.AccidentalThreeQuarterTonesSharpArrowUp;case ee.FlatQuarterNoteUp:return u.AccidentalQuarterToneFlatArrowUp;case ee.DoubleSharp:return u.AccidentalDoubleSharp;case ee.DoubleFlat:return u.AccidentalDoubleFlat}return u.None}}class Sd extends fs{_keySignature;_keySignatureType;_text="";_accidental=ee.None;_accidentalOffset=0;_padding=0;constructor(e,t,s,i){super(e,t),this._keySignature=s,this._keySignatureType=i}doLayout(){super.doLayout();const e="1 = ";let t="",s=ee.None;switch(this._keySignatureType){case as.Major:switch(this._keySignature){case qe.Cb:t="  C",s=ee.Flat;break;case qe.Gb:t="  G",s=ee.Flat;break;case qe.Db:t="  D",s=ee.Flat;break;case qe.Ab:t="  A",s=ee.Flat;break;case qe.Eb:t="  E",s=ee.Flat;break;case qe.Bb:t="  B",s=ee.Flat;break;case qe.F:t="F";break;case qe.C:t="C",s=ee.None;break;case qe.G:t="G",s=ee.None;break;case qe.D:t="D",s=ee.None;break;case qe.A:t="A",s=ee.None;break;case qe.E:t="E",s=ee.None;break;case qe.B:t="B",s=ee.None;break;case qe.FSharp:t="  F",s=ee.Sharp;break;case qe.CSharp:t="  C",s=ee.Sharp;break}break;case as.Minor:switch(this._keySignature){case qe.Cb:t="  a",s=ee.Flat;break;case qe.Gb:t="  e",s=ee.Flat;break;case qe.Db:t="  b",s=ee.Flat;break;case qe.Ab:t="f",s=ee.None;break;case qe.Eb:t="c",s=ee.None;break;case qe.Bb:t="g",s=ee.None;break;case qe.F:t="d";break;case qe.C:t="a",s=ee.None;break;case qe.G:t="e",s=ee.None;break;case qe.D:t="b",s=ee.None;break;case qe.A:t="  f",s=ee.Sharp;break;case qe.E:t="  c",s=ee.Sharp;break;case qe.B:t="  g",s=ee.Sharp;break;case qe.FSharp:t="  d",s=ee.Sharp;break;case qe.CSharp:t="  a",s=ee.Sharp;break}break}this._text=e+t,this._accidental=s;const i=this.renderer.scoreRenderer.canvas,r=this.renderer.settings,n=r.display.resources;i.font=n.numberedNotationFont,this._accidentalOffset=i.measureText(e).width;const o=i.measureText(e+t);this._padding=this.renderer.index===0?r.display.firstStaffPaddingLeft:r.display.staffPaddingLeft,this.width=this._padding+o.width,this.height=o.height}paint(e,t,s){const i=xe.bar(s,Le.NumberedKeySignature,this.renderer.bar);try{const r=this.renderer.resources;s.font=r.numberedNotationFont,s.textBaseline=He.Alphabetic,s.fillText(this._text,e+this.x+this._padding,t+this.y+this.height),this._accidental!==ee.None&&pt.fillMusicFontSymbolSafe(s,e+this.x+this._padding+this._accidentalOffset,t+this.y+this.height,1,ci.getMusicSymbol(this._accidental),!1)}finally{i?.[Symbol.dispose]?.()}}}class kd extends dt{get notationElement(){return C.EffectNumberedNotationKeySignature}get hideOnMultiTrack(){return!1}get canShareBand(){return!1}get sizingMode(){return ke.FullBar}shouldCreateGlyph(e,t){const s=t.voice.bar;return t.index===0&&t.voice.index===0&&(!s.previousBar||s.keySignature!==s.previousBar.keySignature)}createNewGlyph(e,t){return new Sd(0,0,e.bar.keySignature,e.bar.keySignatureType)}canExpand(e,t){return!1}}class wd extends oa{_ottava;_aboveStaff;constructor(e,t){super(ae.PostNotes),this._ottava=e,this._aboveStaff=t}doLayout(){super.doLayout(),this.height=this.renderer.smuflMetrics.glyphHeights.get(u.QuindicesimaAlta)}paintNonGrouped(e,t,s){this._paintOttava(e,t,s)}_paintOttava(e,t,s){let i=0;switch(this._ottava){case le._15ma:i=this.renderer.smuflMetrics.glyphWidths.get(u.QuindicesimaAlta),pt.fillMusicFontSymbolSafe(s,e+this.x-i/2,t+this.y+this.height,1,u.QuindicesimaAlta,!1);break;case le._8va:i=this.renderer.smuflMetrics.glyphWidths.get(u.OttavaAlta),pt.fillMusicFontSymbolSafe(s,e+this.x-i/2,t+this.y+this.height,1,u.OttavaAlta,!1);break;case le._8vb:i=this.renderer.smuflMetrics.glyphWidths.get(u.OttavaBassaVb),pt.fillMusicFontSymbolSafe(s,e+this.x-i/2,t+this.y+this.height,1,u.OttavaBassaVb,!1);break;case le._15mb:i=(this.renderer.smuflMetrics.glyphWidths.get(u.Quindicesima)+this.renderer.smuflMetrics.glyphWidths.get(u.OctaveBaselineM)+this.renderer.smuflMetrics.glyphWidths.get(u.OctaveBaselineB))*1,pt.fillMusicFontSymbolsSafe(s,e+this.x-i/2,t+this.y+this.height,1,[u.Quindicesima,u.OctaveBaselineM,u.OctaveBaselineB],!1);break}return i/2}paintGrouped(e,t,s,i){const r=this._paintOttava(e,t,i),n=this.renderer.smuflMetrics.lineRangedGlyphDashGap,o=e+this.x+r+n;let l=t+this.y;const h=this.height*.5;l+=this._aboveStaff?0:this.height;const c=this.renderer.smuflMetrics.lineRangedGlyphDashSize,d=i.lineWidth;if(i.lineWidth=this.renderer.smuflMetrics.octaveLineThickness,s>o){let f=o;for(;f<s;)i.beginPath(),i.moveTo(f,l|0),i.lineTo(Math.min(f+c,s),l|0),f+=c+n,i.stroke();i.beginPath(),this._aboveStaff?(i.moveTo(s,l),i.lineTo(s,l+h)):(i.moveTo(s,l),i.lineTo(s,l-h)),i.stroke()}i.lineWidth=d}}class Bd extends dt{_aboveStaff;get effectId(){return`ottavia-${this._aboveStaff?"above":"below"}`}get notationElement(){return C.EffectOttavia}get hideOnMultiTrack(){return!1}get canShareBand(){return!0}get sizingMode(){return ke.GroupedOnBeat}constructor(e){super(),this._aboveStaff=e}shouldCreateGlyph(e,t){switch(t.ottava){case le._15ma:return this._aboveStaff;case le._8va:return this._aboveStaff;case le._8vb:return!this._aboveStaff;case le._15mb:return!this._aboveStaff}return!1}createNewGlyph(e,t){return new wd(t.ottava,this._aboveStaff)}canExpand(e,t){return e.ottava===t.ottava}}class Td extends rr{get notationElement(){return C.EffectPalmMute}shouldCreateGlyphForNote(e){return e.isPalmMute}get sizingMode(){return ke.GroupedOnBeat}createNewGlyph(e,t){return new ir("P.M.",C.EffectPalmMute)}}class kl extends rr{get notationElement(){return C.EffectPickSlide}shouldCreateGlyphForNote(e){return e.slideOutType===he.PickSlideDown||e.slideOutType===he.PickSlideUp}get sizingMode(){return ke.GroupedOnBeat}createNewGlyph(e,t){return new ir("P.S.",C.EffectPickSlide)}}class sa extends Lt{constructor(e,t,s){super(e,t,We.GraceScale,sa._getSymbol(s)),this.center=!0}doLayout(){super.doLayout(),this.offsetY=this.height}static _getSymbol(e){switch(e){case Ct.Up:return u.StringsUpBow;case Ct.Down:return u.StringsDownBow;default:return u.None}}}class wl extends dt{get notationElement(){return C.EffectPickStroke}get hideOnMultiTrack(){return!1}get canShareBand(){return!0}get sizingMode(){return ke.SingleOnBeat}shouldCreateGlyph(e,t){return t.pickStroke!==Ct.None}createNewGlyph(e,t){return new sa(0,0,t.pickStroke)}canExpand(e,t){return!0}}class xd extends dt{get notationElement(){return C.EffectRasgueado}get canShareBand(){return!1}get hideOnMultiTrack(){return!1}shouldCreateGlyph(e,t){return t.hasRasgueado}get sizingMode(){return ke.GroupedOnBeat}createNewGlyph(e,t){return new ir("rasg.",C.EffectRasgueado)}canExpand(e,t){return!0}}class rn extends Nt{_uniqueEffectGlyphs=[];_effectGlyphs=[];_container;isEmpty=!0;previousBand=null;isLinkedToPrevious=!1;firstBeat=null;lastBeat=null;height=0;originalHeight=0;voice;info;slot=null;constructor(e,t,s){super(0,0),this.voice=e,this.info=t,this._container=s}*iterateAllGlyphs(){for(const e of this._effectGlyphs)for(const t of e.values())yield t}finalizeBand(){this.info.finalizeBand(this)}doLayout(){super.doLayout();for(let e=0;e<this.renderer.bar.voices.length;e++)this._effectGlyphs.push(new Map),this._uniqueEffectGlyphs.push([])}static shouldCreateGlyph(e,t,s){return t.shouldCreateGlyph(s.settings,e)&&(!t.hideOnMultiTrack||s.staff.trackIndex===0)}createGlyph(e){if(e.voice===this.voice&&rn.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 ke.SingleOnBeatToEnd:case ke.GroupedOnBeatToEnd:this.lastBeat.nextBeat&&(this.lastBeat=this.lastBeat.nextBeat);break}const t=this._createOrResizeGlyph(this.info.sizingMode,e);t.height>this.height&&(this.height=t.height,this.originalHeight=t.height)}}resetHeight(){this.height=this.originalHeight}_createOrResizeGlyph(e,t){let s;switch(e){case ke.FullBar:return s=this.info.createNewGlyph(this.renderer,t),s.renderer=this.renderer,s.beat=t,s.doLayout(),this._effectGlyphs[t.voice.index].set(t.index,s),this._uniqueEffectGlyphs[t.voice.index].push(s),s;case ke.SinglePreBeat:case ke.SingleOnBeat:case ke.SingleOnBeatToEnd:return s=this.info.createNewGlyph(this.renderer,t),s.renderer=this.renderer,s.beat=t,s.doLayout(),this._effectGlyphs[t.voice.index].set(t.index,s),this._uniqueEffectGlyphs[t.voice.index].push(s),s;case ke.GroupedOnBeat:case ke.GroupedOnBeatToEnd:const i=e===ke.GroupedOnBeat?ke.SingleOnBeat:ke.SingleOnBeatToEnd;if(t.index>0||this.renderer.index>0){const r=t.previousBeat;if(this.info.shouldCreateGlyph(this.renderer.settings,r)){let n=null;if(t.index>0&&this._effectGlyphs[t.voice.index].has(r.index))n=this._effectGlyphs[t.voice.index].get(r.index);else if(this.renderer.index>0){const h=this._container.previousContainer.getBand(r.voice,this.info.effectId);if(h){const c=h._effectGlyphs[r.voice.index];c.has(r.index)&&(n=c.get(r.index))}}const o=this._createOrResizeGlyph(i,t);return n&&this.info.canExpand(r,t)&&(n.nextGlyph=o,o.previousGlyph=n,this.isLinkedToPrevious=!0),o}return this._createOrResizeGlyph(i,t)}return this._createOrResizeGlyph(i,t);default:return this._createOrResizeGlyph(ke.SingleOnBeat,t)}}paint(e,t,s){super.paint(e,t,s);for(let i=0,r=this._uniqueEffectGlyphs.length;i<r;i++){const n=this._uniqueEffectGlyphs[i];for(let o=0,l=n.length;o<l;o++){const h=n[o],c=xe.beat(s,rt.Effects,h.beat,!1);try{h.paint(e+this.x,t+this.y,s)}finally{c?.[Symbol.dispose]?.()}}}}alignGlyphs(){for(let e=0;e<this._effectGlyphs.length;e++)for(const t of this._effectGlyphs[e].keys()){const s=this.renderer.bar.voices[e].beats[t];this._alignGlyph(this.info.sizingMode,s)}this.info.onAlignGlyphs(this)}_alignGlyph(e,t){const s=this._effectGlyphs[t.voice.index].get(t.index),i=this.renderer.getBeatContainer(t);switch(e){case ke.SinglePreBeat:const r=this.renderer.layoutingInfo.getPreBeatSize(t);s.x=this.renderer.beatGlyphsStart+i.x+i.onTimeX-r;break;case ke.SingleOnBeat:case ke.GroupedOnBeat:s.x=this.renderer.beatGlyphsStart+i.x+i.onT
65imeX;break;case ke.SingleOnBeatToEnd:case ke.GroupedOnBeatToEnd:if(s.x=this.renderer.beatGlyphsStart+i.x+i.onTimeX,i.isLastOfVoice)s.width=this.renderer.width-s.x;else{const n=this.renderer.layoutingInfo.getPostBeatSize(t);s.width=n}break;case ke.FullBar:s.width=this.renderer.width;break}}}class Nd{uniqueEffectId=null;y=0;height=0;firstBeat=null;lastBeat=null}class Pd{bands;shared;constructor(){this.bands=[],this.shared=new Nd}update(e){e.info.canShareBand||(this.shared.uniqueEffectId=e.info.effectId),e.slot=this,this.bands.push(e),e.height>this.shared.height&&(this.shared.height=e.height),(!this.shared.firstBeat||e.firstBeat.isBefore(this.shared.firstBeat))&&(this.shared.firstBeat=e.firstBeat),(!this.shared.lastBeat||e.lastBeat.isAfter(this.shared.lastBeat))&&(this.shared.lastBeat=e.lastBeat)}canBeUsed(e){return!this.shared.uniqueEffectId&&e.info.canShareBand||e.info.effectId===this.shared.uniqueEffectId?!!(!this.shared.firstBeat||this.shared.lastBeat===e.firstBeat||this.shared.lastBeat.isBefore(e.firstBeat)||this.shared.lastBeat.isBefore(this.shared.firstBeat)):!1}}class Cd{_effectSlot;_assignedSlots;slots;owner;constructor(e){this.slots=[],this._effectSlot=new Map,this._assignedSlots=new Map,this.owner=e}reset(){this._effectSlot.clear(),this._assignedSlots.clear(),this.slots=[]}getOrCreateSlot(e){if(this._assignedSlots.has(e))return this._assignedSlots.get(e);if(this._effectSlot.has(e.info.effectId)){const s=this._effectSlot.get(e.info.effectId);if(s.canBeUsed(e))return this._assignedSlots.set(e,s),s}for(const s of this.slots)if(s.canBeUsed(e))return this._assignedSlots.set(e,s),s;const t=new Pd;return this.slots.push(t),this._assignedSlots.set(e,t),t}register(e){const t=this.getOrCreateSlot(e);t.update(e),this._effectSlot.set(e.info.effectId,t)}sortSlots(e){for(const t of this.slots)t.bands.sort((s,i)=>{const r=e.get(s.info),n=e.get(i.info);return r-n});this.slots.sort((t,s)=>{const i=e.get(t.bands[0].info),r=e.get(s.bands[0].info);return i-r})}}class Bl{_bands=[];_bandLookup=new Map;_effectBandSizingInfo=null;_effectInfosSortOrder=new Map;height=0;infos;_renderer;_isTopContainer;alignGlyphs(){for(const e of this._bands)e.alignGlyphs()}get previousContainer(){return this._renderer.index===0?void 0:this._isTopContainer?this._renderer.previousRenderer.topEffects:this._renderer.previousRenderer.bottomEffects}get isLinkedToPreviousRenderer(){return this._bands.some(e=>e.isLinkedToPrevious)}constructor(e,t){this._renderer=e,this._isTopContainer=t}reLayout(){this.resetEffectBandSizingInfo(),this.sizeAndAlignEffectBands()}afterStaffBarReverted(){this.resetEffectBandSizingInfo(),this.sizeAndAlignEffectBands()}createVoiceGlyphs(e){let t=0;const s=this._renderer,i=s.settings.notation;for(const r of this.infos){if(!i.isNotationElementVisible(r.effect.notationElement))continue;let n;this._effectInfosSortOrder.set(r.effect,r.order??t);for(const o of e.beats)!n&&rn.shouldCreateGlyph(o,r.effect,s)&&(n=new rn(e,r.effect,this),n.renderer=this._renderer,n.doLayout(),this._bands.push(n),this._bandLookup.set(`${e.index}.${r.effect.effectId}`,n)),n!==void 0&&n.createGlyph(o);t++}}doLayout(){this._effectInfosSortOrder.clear(),this._bands=[],this._bandLookup=new Map,this.resetEffectBandSizingInfo()}resetEffectBandSizingInfo(){this._renderer.index>0?this._effectBandSizingInfo=this.previousContainer._effectBandSizingInfo:this._effectBandSizingInfo&&this._effectBandSizingInfo.owner===this?this._effectBandSizingInfo.reset():this._effectBandSizingInfo=new Cd(this)}finalizeEffects(){return this._updateEffectBandHeights(!0)}updateEffectBandHeights(){return this._updateEffectBandHeights(!1)}_updateEffectBandHeights(e){if(!this._effectBandSizingInfo)return!1;let t=0;const s=0,i=this._renderer.settings.display.effectBandPaddingBottom;for(const r of this._effectBandSizingInfo.slots){r.shared.y=t;for(const n of r.bands)t+=s,n.y=t,e&&n.finalizeBand(),n.height=r.shared.height;t+=r.shared.height+i}return t=Math.ceil(t),t!==this.height?(this.height=t,!0):!1}sizeAndAlignEffectBands(e=!0){for(const t of this._bands)t.resetHeight(),t.alignGlyphs(),e&&!t.isEmpty&&this._effectBandSizingInfo.register(t);e&&this._effectBandSizingInfo.sortSlots(this._effectInfosSortOrder)}
vendor: 4,186 bytes, line 65
65paint(e,t,s){const i=this._renderer.resources;for(const r of this._bands)s.color=r.voice.index===0?i.mainGlyphColor:i.secondaryGlyphColor,r.isEmpty||r.paint(e,t,s)}getBand(e,t){const s=`${e.index}.${t}`;return this._bandLookup.has(s)?this._bandLookup.get(s):null}}class zr extends js{gap=0;constructor(){super(0,0),this.glyphs=[]}doLayout(){}addGlyph(e){e.x=this.width,e.renderer=this.renderer,e.doLayout(),this.width=e.x+e.width+this.gap,super.addGlyph(e)}}class Ed extends Nt{static KeySizeBeat="Beat";voiceDrawOrder;_beatGlyphLookup=new Map;beatGlyphs=new Map;tupletGroups=new Map;constructor(){super(0,0)}getBoundingBoxTop(){let e=Number.NaN;for(const t of this.beatGlyphs.values())for(const s of t)e=L.minBoundingBox(e,s.getBoundingBoxTop());return e}getBoundingBoxBottom(){let e=Number.NaN;for(const t of this.beatGlyphs.values())for(const s of t)e=L.maxBoundingBox(e,s.getBoundingBoxBottom());return e}scaleToWidth(e){const t=this.renderer.layoutingInfo.spaceToForce(e);this._scaleToForce(t)}_scaleToForce(e){this.width=this.renderer.layoutingInfo.calculateVoiceWidth(e);const t=this.renderer.layoutingInfo.buildOnTimePositions(e);for(const s of this.beatGlyphs.values())for(let i=0,r=s.length;i<r;i++){const n=s[i];switch(n.graceType){case K.None:n.x=t.get(n.absoluteDisplayStart)-n.onTimeX;break;default:const o=n.graceGroup.beats[0].absoluteDisplayStart,l=n.graceGroup.id;if(n.graceGroup.isComplete&&t.has(o)){n.x=t.get(o)-n.onTimeX;const h=this.renderer.layoutingInfo.allGraceRods.get(l),c=n.graceGroup.beats[n.graceGroup.beats.length-1].nextBeat,d=c?this.renderer.layoutingInfo.getPreBeatSize(c):0;n.x-=d,n.x-=h[n.graceIndex].postSpringWidth,n.x+=h[n.graceIndex].graceBeatWidth;const f=h[n.graceGroup.beats.length-1];n.x-=f.graceBeatWidth}else{const h=this.renderer.layoutingInfo.incompleteGraceRods.get(l),c=h[n.graceIndex].postSpringWidth-h[n.graceIndex].preSpringWidth;i>0?n.graceIndex===0?n.x=s[i-1].x+s[i-1].width:n.x=s[i-1].x+h[n.graceIndex-1].postSpringWidth-h[n.graceIndex-1].preSpringWidth-c:n.x=-c}break}if(i>0){const o=n.x-s[i-1].x;s[i-1].scaleToWidth(o)}if(i===r-1){const o=this.width-s[s.length-1].x;n.scaleToWidth(o)}}}registerLayoutingInfo(e){for(const t of this.beatGlyphs.values())for(const s of t)s.registerLayoutingInfo(e)}applyLayoutingInfo(e){for(const t of this.beatGlyphs.values()){for(const s of t)s.applyLayoutingInfo(e);this._scaleToForce(Math.max(this.renderer.settings.display.stretchForce,e.minStretchForce))}}addGlyph(e){let t;this.beatGlyphs.has(e.voiceIndex)?t=this.beatGlyphs.get(e.voiceIndex):(t=[],this.beatGlyphs.set(e.voiceIndex,t)),e.x=t.length===0?0:t[t.length-1].x+t[t.length-1].width,e.renderer=this.renderer,t.push(e);const s=e.beatId;s>=0&&this._beatGlyphLookup.set(s,e);const i=e.x+e.width;if(i>this.width&&(this.width=i),e.isFirstOfTupletGroup){let r;this.tupletGroups.has(e.voiceIndex)?r=this.tupletGroups.get(e.voiceIndex):(r=[],this.tupletGroups.set(e.voiceIndex,r)),r.push(e.tupletGroup)}}getBeatX(e,t=ae.PreNotes,s=!1){const i=this.getBeatContainer(e);return i?i.x+i.getBeatX(t,s):0}getLowestNoteY(e,t){const s=this.getBeatContainer(e);return s?s.y+s.getLowestNoteY(t):0}getHighestNoteY(e,t){const s=this.getBeatContainer(e);return s?s.y+s.getHighestNoteY(t):0}getNoteX(e,t){const s=this.getBeatContainer(e.beat);return s?s.x+s.getNoteX(e,t):0}getNoteY(e,t){const s=this.getBeatContainer(e.beat);return s?s.y+s.getNoteY(e,t):0}getRestY(e,t){const s=this.getBeatContainer(e);return s?s.y+s.getRestY(t):0}getBeatContainer(e){if(this._beatGlyphLookup.has(e.id))return this._beatGlyphLookup.get(e.id)}buildBoundingsLookup(e,t,s){for(const[i,r]of this.beatGlyphs){const n=this.renderer.bar.voices[i];if(i===0||!n.isEmpty)for(const o of r)o.buildBoundingsLookup(e,t+this.x,s+this.y)}}doLayout(){for(const e of this.beatGlyphs.values()){let t=0;for(const s of e)s.x=t,s.doLayout(),t+=s.width;t>this.width&&(this.width=t)}this.renderer.bar.isMultiVoice&&this._doMultiVoiceLayout(),this.voiceDrawOrder=Array.from(this.beatGlyphs.keys()),M.sortDescending(this.voiceDrawOrder)}_doMultiVoiceLayout(){for(const e of this.beatGlyphs.values()){let t=0;for(const s of e)s.x=t,s.doMultiVoiceLayout(),t+=s.width;t>this.width&&(this.width=t)}}
65paint(e,t,s){for(const i of this.voiceDrawOrder){const r=this.beatGlyphs.get(i),n=this.renderer.bar.voices[i],o=xe.voice(s,yr.Glyphs,n,!0);try{for(let l=0,h=r.length;l<h;l++)r[l].paint(e+this.x,t+this.y,s)}finally{o?.[Symbol.dispose]?.()}}}}class Ot extends Nt{tieDirection=P.Up;slurEffectId;isForEnd;constructor(e,t){super(0,0),this.slurEffectId=e,this.isForEnd=t}_startX=0;_startY=0;_endX=0;_endY=0;_tieHeight=0;_boundingBox;_shouldPaint=!1;get checkForOverflow(){return this._shouldPaint&&this._boundingBox!==void 0}getBoundingBoxTop(){return this._boundingBox?this._boundingBox.y:this._startY}getBoundingBoxBottom(){return this._boundingBox?this._boundingBox.y+this._boundingBox.h:this._startY}doLayout(){this.width=0;const e=this.lookupStartBeatRenderer(),t=this.lookupEndBeatRenderer();this._startX=0,this._endX=0,this._startY=0,this._endY=0,this.height=0,this.tieDirection=this.calculateTieDirection();const s=this.isForEnd;if(this._shouldPaint=!1,s){if(e.staff!==t.staff){const r=e.staff.barRenderers[0];this._startX=r.x,this._endX=this.calculateEndX();const n=e.scoreRenderer.layout.slurRegistry.completeMultiSystemSlur(this);n?this._startY=n.calculateMultiSystemSlurY(t):this._startY=this.caclculateEndY(),this._endY=this.caclculateEndY(),this._shouldPaint=e.staff!==t.staff}}else{if(e!==t)if(this._startX=this.calculateStartX(),this._startY=this.calculateStartY(),!t||e.staff!==t.staff){const r=e.staff.barRenderers[e.staff.barRenderers.length-1];this._endX=r.x+r.width,this._endY=this._startY,e.scoreRenderer.layout.slurRegistry.startMultiSystemSlur(this)}else this._endX=this.calculateEndX(),this._endY=this.caclculateEndY();else this._shouldPaint=!0,this._startX=this.calculateStartX(),this._endX=this.calculateEndX(),this._startY=this.calculateStartY(),this._endY=this.caclculateEndY();this._shouldPaint=!0}this._boundingBox=void 0,this.y=Math.min(this._startY,this._endY);let i;if(this.shouldDrawBendSlur()?(this._tieHeight=0,i=Ot.calculateBendSlurHeight(this._startX,this._startY,this._endX,this._endY,this.tieDirection===P.Down,this.renderer.smuflMetrics.tieHeight)):(this._tieHeight=this.getTieHeight(this._startX,this._startY,this._endX,this._endY),i=Ot.calculateActualTieHeight(1,this._startX,this._startY,this._endX,this._endY,this.tieDirection===P.Down,this._tieHeight,this.renderer.smuflMetrics.tieMidpointThickness)),this._boundingBox=i,this.height=i.h,this.tieDirection===P.Up){const r=this.y-i.y;r>0&&(this.y-=r)}}paint(e,t,s){this._shouldPaint&&(this.shouldDrawBendSlur()?Ot.drawBendSlur(s,e+this._startX,t+this._startY,e+this._endX,t+this._endY,this.tieDirection===P.Down,this.renderer.smuflMetrics.tieHeight):Ot.paintTie(s,1,e+this._startX,t+this._startY,e+this._endX,t+this._endY,this.tieDirection===P.Down,this._tieHeight,this.renderer.smuflMetrics.tieMidpointThickness))}getTieHeight(e,t,s,i){return this.renderer.smuflMetrics.tieHeight}calculateMultiSystemSlurY(e){const t=this.lookupStartBeatRenderer(),i=this.calculateStartY()-t.y;return e.y+i}shouldCreateMultiSystemSlur(e){const t=this.lookupEndBeatRenderer()?.staff;return t?e.staff.system.index<t.system.index:!0}static calculateActualTieHeight(e,t,s,i,r,n,o,l){const h=Ot._computeBezierControlPoints(e,t,s,i,r,n,o,l);if(h.length===0)return new bt(t,s,i-t,r-s);const c=h[0],d=h[1],f=h[2],p=h[3],g=h[4],m=h[5],b=h[6],S=h[7],N=.125*c+.375*f+.375*g+.125*b,v=.125*d+.375*p+.375*m+.125*S,W=Math.min(c,b,N),j=Math.max(c,b,N);let q=Math.min(d,S,v),F=Math.max(d,S,v);n?F+=l:q-=l;const Q=new bt;return Q.x=W,Q.y=q,Q.w=j-W,Q.h=F-q,Q}static _computeBezierControlPoints(e,t,s,i,r,n,o,l){if(t===i&&s===r)return[];if(i<t){let j=t;t=i,i=j,j=s,s=r,r=j}o*=e,l*=e,n&&(o*=-1,l*=-1),e>=1&&(l*=1.2);const h=r-s,c=i-t,d=Math.sqrt(c*c+h*h);let f=t+d*.25,p=s-o,g=t+d*.75,m=s-o,b=t+d*.75,S=s-o-l,N=t+d*.25,v=s-o-l;const W=Math.atan2(h,c);return[f,p]=Ot._rotate(f,p,t,s,W),[g,m]=Ot._rotate(g,m,t,s,W),[b,S]=Ot._rotate(b,S,t,s,W),[N,v]=Ot._rotate(N,v,t,s,W),[t,s,f,p,g,m,i,r,b,S,N,v,t,s]}static _rotate(e,t,s,i,r){const n=e-s,o=t-i,l=n*Math.cos(r)-o*Math.sin(r),h=n*Math.sin(r)+o*Math.cos(r);return[s+l,i+h]}static paintTie(e,t,s,i,r,n,o,l,h){const c=Ot._computeBezierControlPoints(t,s,i,r,n,o,l,h);e.beginPath(),e.moveTo(c[0],c[1]),e.bezierCurveTo(c[2],c[3],c[4],c[5],c[6],c[7]),e.bezierCurveTo(c[8],c[9],c[10],c[11],c[12],c[13]),e.closePath(),e.fill()}static calculateBendSlurTopY(e,t,s,i,r,n,o){let l=i-t,h=s-e;const c=Math.sqrt(l*l+h*h);r?l*=-1:h*=-1,l/=c,h/=c;let d=o*n;return s-e<20&&(d/=2),(i+t)/2+d*h}static calculateBendSlurHeight(e,t,s,i,r,n){let o=i-t,l=s-e;const h=Math.sqrt(o*o+l*l);r?o*=-1:l*=-1,o/=h,l/=h;const c=(i+t)/2;let d=n;s-e<20&&(d/=2);const f=c+d*l,p=Math.min(t,i,f),g=Math.max(t,i,f);return new bt(e,Math.min(t,i,f),s-e,g-p)}static drawBendSlur(e,t,s,i,r,n,o,l){let h=r-s,c=i-t;const d=Math.sqrt(h*h+c*c);n?h*=-1:c*=-1,h/=d,c/=d;const f=(i+t)/2,p=(r+s)/2;let g=o;i-t<20&&(g/=2);const m=f+g*h,b=p+g*c;if(e.beginPath(),e.moveTo(t,s),e.lineTo(m,b),e.lineTo(i,r),e.stroke(),l){const S=e.measureText(l).width,N=n?0:-e.font.size;e.fillText(l,m-S/2,b+N)}}}class kn extends Ot{startNote;endNote;startNoteRenderer=null;endNoteRenderer=null;constructor(e,t,s,i){super(e,i),this.startNote=t,this.endNote=s}get isLeftHandTap(){return this.startNote===this.endNote}getTieHeight(e,t,s,i){return this.isLeftHandTap?this.renderer.smuflMetrics.tieHeight:super.getTieHeight(e,t,s,i)}calculateTieDirection(){return this.lookupStartBeatRenderer().getBeatDirection(this.startNote.beat)===P.Up?P.Down:P.Up}calculateStartX(){const e=this.lookupStartBeatRenderer();return this.isLeftHandTap?this.calculateEndX()-e.smuflMetrics.leftHandTabTieWidth:e.x+e.getNoteX(this.startNote,this.get
vendor: 4,831 bytes, line 65
65StartNotePosition())}getStartNotePosition(){return Qe.Center}calculateStartY(){const e=this.lookupStartBeatRenderer();return this.isLeftHandTap?e.y+e.getNoteY(this.startNote,D.Center):this.tieDirection===P.Up?e.y+e.getNoteY(this.startNote,D.Top):e.y+e.getNoteY(this.startNote,D.Bottom)}calculateEndX(){const e=this.lookupEndBeatRenderer();return e?this.isLeftHandTap?e.x+e.getNoteX(this.endNote,Qe.Left):e.x+e.getNoteX(this.endNote,Qe.Center):this.calculateStartY()+this.renderer.smuflMetrics.leftHandTabTieWidth}getEndNotePosition(){return Qe.Center}caclculateEndY(){const e=this.lookupEndBeatRenderer();return e?this.isLeftHandTap?e.y+e.getNoteY(this.endNote,D.Center):this.tieDirection===P.Up?e.y+e.getNoteY(this.endNote,D.Top):e.y+e.getNoteY(this.endNote,D.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}}class vd extends Ot{_startTie;constructor(e){super(e.slurEffectId,!1),this._startTie=e}lookupStartBeatRenderer(){return this.renderer}lookupEndBeatRenderer(){return this.renderer}shouldDrawBendSlur(){return!1}calculateTieDirection(){return this._startTie.tieDirection}calculateStartY(){return this._startTie.calculateMultiSystemSlurY(this.renderer)}caclculateEndY(){return this.calculateStartY()}calculateStartX(){return this.renderer.staff.barRenderers[0].x}calculateEndX(){const e=this.renderer.staff.barRenderers[this.renderer.staff.barRenderers.length-1];return e.x+e.width}}class kr extends Nt{_scale=0;_baseline;_symbols=[];constructor(e,t,s,i,r=1){super(e,t),this._symbols=kr.getSymbols(s),this._scale=r,this._baseline=i}static getSymbols(e){const t=[];for(;e>0;){const s=e%10;t.unshift(kr.getSymbol(s)),e=e/10|0}return t}static getSymbol(e){switch(e){case 0:return u.TimeSig0;case 1:return u.TimeSig1;case 2:return u.TimeSig2;case 3:return u.TimeSig3;case 4:return u.TimeSig4;case 5:return u.TimeSig5;case 6:return u.TimeSig6;case 7:return u.TimeSig7;case 8:return u.TimeSig8;case 9:return u.TimeSig9;default:return u.None}}doLayout(){let e=0;for(const t of this._symbols)e+=this.renderer.smuflMetrics.glyphWidths.get(t);this.width=e}paint(e,t,s){switch(this._baseline){case He.Top:t+=this.renderer.smuflMetrics.glyphBottom.get(this._symbols[0]);break;case He.Bottom:t+=this.renderer.smuflMetrics.glyphTop.get(this._symbols[0]);break}s.fillMusicFontSymbols(e+this.x,t+this.y,this._scale,this._symbols)}}class an extends Nt{static _restSymbols=[u.RestHBarLeft,u.RestHBarMiddle,u.RestHBarMiddle,u.RestHBarMiddle,u.RestHBarRight];_numberGlyph=[];_numberTop=0;constructor(){super(0,0)}doLayout(){const e=this.renderer.smuflMetrics;this.width=an._restSymbols.reduce((i,r)=>i+e.glyphWidths.get(r),0);const t=this.renderer.additionalMultiRestBars.length+1;this._numberGlyph=kr.getSymbols(t),this._numberTop=this.renderer.getLineY(-1.5);const s=e.glyphTop.get(this._numberGlyph[0]);this.renderer.registerOverflowTop(Math.abs(this._numberTop)+s)}paint(e,t,s){s.fillMusicFontSymbols(e+this.x,t+this.y+this.renderer.height/2,1,an._restSymbols);const i=this.renderer.getLineY(-1.5);s.fillMusicFontSymbols(e+this.x+this.width/2,t+this.y+i|0,1,this._numberGlyph,!0)}}class Dd extends Mo{_glyph;constructor(){super(0,0)}get absoluteDisplayStart(){return this.renderer.bar.masterBar.start}get beatId(){return-1}get onTimeX(){return 0}get graceType(){return K.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(e){const t=this._glyph;if(t)switch(e){case D.Top:return t.y;case D.TopWithStem:return t.y-this.renderer.smuflMetrics.getStemLength(y.Quarter,!0);case D.Center:case D.StemUp:case D.StemDown:return t.y+t.height/2;case D.Bottom:return t.y+t.height;case D.BottomWithStem:return t.y+t.height+this.renderer.smuflMetrics.getStemLength(y.Quarter,!0)}return 0}getNoteY(e,t){return this.getRestY(t)}getHighestNoteY(e){return this.getRestY(e)}getLowestNoteY(e){return this.getRestY(e)}getNoteX(e,t){const s=this._glyph;if(s)switch(t){case Qe.Left:return s.x;case Qe.Center:return s.x+s.width/2;case Qe.Right:return s.x+s.width}return 0}getBeatX(e,t){const s=this._glyph;if(s)switch(e){case ae.PreNotes:return s.x;case ae.OnNotes:case ae.MiddleNotes:case ae.Stem:case ae.PostNotes:return s.x+s.width;case ae.EndBeat:return this.width}return 0}registerLayoutingInfo(e){const t=this._glyph?.width??0;e.addBeatSpring(this,0,t)}
65applyLayoutingInfo(e){}buildBoundingsLookup(e,t,s){}doLayout(){this.renderer.showMultiBarRest&&(this._glyph=new an,this._glyph.renderer=this.renderer,this._glyph.doLayout(),this.width=this._glyph.width)}doMultiVoiceLayout(){}getBoundingBoxTop(){return this._glyph?.getBoundingBoxTop()??Number.NaN}getBoundingBoxBottom(){return this._glyph?.getBoundingBoxBottom()??Number.NaN}paint(e,t,s){this._glyph?.paint(e+this.x,t+this.y,s)}}class Ld{startBeat=null;startX=0;startY=0;endBeat=null;endX=0;endY=0;calcY(e){return this.startX===this.endX?this.startY:(this.endY-this.startY)/(this.endX-this.startX)*(e-this.startX)+this.startY}}class _s{_staff;_renderer;_beamingRuleLookup;voice=null;beats=[];shortestDuration=y.QuadrupleWhole;hasTuplet=!1;slashBeats=[];restBeats=[];lowestNoteInHelper=null;_lowestNoteCompareValueInHelper=-1;highestNoteInHelper=null;_highestNoteCompareValueInHelper=-1;invertBeamDirection=!1;preferredBeamDirection=null;graceType=K.None;get isRestBeamHelper(){return this.beats.length===1&&this.beats[0].isRest}hasStem(e,t){return e&&_s.beatHasStem(t)||!e&&_s.beatHasStem(t)}static beatHasStem(e){return e.duration>y.Whole}hasFlag(e,t){return e&&_s.beatHasFlag(t)||!e&&this.beats.length===1&&_s.beatHasFlag(this.beats[0])}static beatHasFlag(e){return!e.deadSlapped&&!e.isRest&&(e.duration>y.Quarter||e.graceType!==K.None)}constructor(e,t,s){this._staff=e,this._renderer=t,this.beats=[],this._beamingRuleLookup=s}alignWithBeats(){for(const e of this.drawingInfos.values())e.startX=this._renderer.getBeatX(e.startBeat,ae.Stem),e.endX=this._renderer.getBeatX(e.endBeat,ae.Stem),this.drawingInfos.clear()}finish(){this._renderer.completeBeamingHelper(this)}static computeLineHeightsForRest(e){switch(e){case y.QuadrupleWhole:return[2,2];case y.DoubleWhole:return[2,2];case y.Whole:return[0,1];case y.Half:return[1,0];case y.Quarter:return[3,3];case y.Eighth:return[2,2];case y.Sixteenth:return[2,4];case y.ThirtySecond:return[4,4];case y.SixtyFourth:return[4,6];case y.OneHundredTwentyEighth:return[6,6];case y.TwoHundredFiftySixth:return[6,8]}return[0,0]}checkBeat(e){e.invertBeamDirection&&(this.invertBeamDirection=!0),this.voice||(this.voice=e.voice);let t=!1;if(this.beats.length===0)t=!0;else switch(this.beats[this.beats.length-1].beamingMode){case st.Auto:case st.ForceSplitOnSecondaryToNext:t=this._canJoin(this.beats[this.beats.length-1],e);break;case st.ForceSplitToNext:t=!1;break;case st.ForceMergeWithNext:t=!0;break}return t&&(this.preferredBeamDirection==null&&e.preferredBeamDirection!==null&&(this.preferredBeamDirection=e.preferredBeamDirection),e.hasTuplet&&(this.hasTuplet=!0),e.graceType!==K.None&&(this.graceType=e.graceType),e.isRest?this.beats.length===0?this.beats.push(e):this.restBeats.push(e):(this.isRestBeamHelper&&(this.beats=[]),this.beats.push(e),this._checkNote(e.minNote),this._checkNote(e.maxNote),this.shortestDuration<e.duration&&(this.shortestDuration=e.duration)),e.slashed&&this.slashBeats.push(e)),t}_checkNote(e){if(!e)return;let t,s;this.voice&&e.isPercussion?(t=-qt.getPercussionSteps(e),s=t):(t=qt.getNoteValue(e),s=t,e.harmonicType!==te.None&&e.harmonicType!==te.Natural&&(s=e.realValue-this._staff.displayTranspositionPitch)),(!this.lowestNoteInHelper||t<this._lowestNoteCompareValueInHelper)&&(this.lowestNoteInHelper=e,this._lowestNoteCompareValueInHelper=t),(!this.highestNoteInHelper||s>this._highestNoteCompareValueInHelper)&&(this.highestNoteInHelper=e,this._highestNoteCompareValueInHelper=s)}_canJoin(e,t){if(!e||!t||e.graceType!==t.graceType||e.graceType===K.BendGrace||t.graceType===K.BendGrace||e.deadSlapped||t.deadSlapped)return!1;if(e.graceType!==K.None&&t.graceType!==K.None)return!0;const s=e.voice.bar,i=t.voice.bar;if(s!==i)return!1;const r=e.playbackStart,n=t.playbackStart;if(!_s._canJoinDuration(e.duration)||!_s._canJoinDuration(t.duration))return r===n;if(e.tupletGroup!==t.tupletGroup)return!1;if(e.hasTuplet&&t.hasTuplet&&e.tupletGroup===t.tupletGroup&&e.tupletGroup.isFull)return!0;const o=this._beamingRuleLookup.calculateGroupIndex(r),l=this._beamingRuleLookup.calculateGroupIndex(n);return o===l}static _canJoinDuration(e){switch(e){case y.Whole:case y.Half:case y.Quarter:return!1;default:return!0}}static isFullBarJoin(e,t,s){return L.getIndex(e.duration)-2-s>0&&L.getIndex(t.duration)-2-s>0}
65get beatOfLowestNote(){return this.lowestNoteInHelper.beat}get beatOfHighestNote(){return this.highestNoteInHelper.beat}drawingInfos=new Map}class Fd{topY=0;bottomY=0;constructor(e,t){this.topY=e,this.bottomY=t}}class Md{beat;topY=-1e3;bottomY=-1e3;slots=[];constructor(e){this.beat=e}addSlot(e,t){if(this.slots.push(new Fd(e,t)),this.topY===-1e3)this.topY=e,this.bottomY=t;else{const s=Math.min(e,t),i=Math.max(e,t);s<this.topY&&(this.topY=s),i>this.bottomY&&(this.bottomY=i)}}}class Ad{reservedLayoutAreasByDisplayTime=new Map;restDurationsByDisplayTime=new Map;getBeatMinMaxY(){let e=-1e3,t=-1e3;for(const s of this.reservedLayoutAreasByDisplayTime.values())e===-1e3?(e=s.topY,t=s.bottomY):(e>s.topY&&(e=s.topY),t<s.bottomY&&(t=s.bottomY));return e===-1e3?[0,0]:[e,t]}reserveBeatSlot(e,t,s){t!==s&&(this.reservedLayoutAreasByDisplayTime.has(e.displayStart)||this.reservedLayoutAreasByDisplayTime.set(e.displayStart,new Md(e)),this.reservedLayoutAreasByDisplayTime.get(e.displayStart).addSlot(t,s),e.isRest&&this.registerRest(e))}registerRest(e){this.restDurationsByDisplayTime.has(e.displayStart)||this.restDurationsByDisplayTime.set(e.displayStart,new Map),this.restDurationsByDisplayTime.get(e.displayStart).has(e.playbackDuration)||this.restDurationsByDisplayTime.get(e.displayStart).set(e.playbackDuration,e.id)}applyRestCollisionOffset(e,t,s){if(e.voice.index>
650&&this.reservedLayoutAreasByDisplayTime.has(e.playbackStart)){const i=_s.computeLineHeightsForRest(e.duration).map(c=>c*s),r=t-i[0],n=t+i[1];let o=r;const l=this.reservedLayoutAreasByDisplayTime.get(e.playbackStart);let h=!1;for(const c of l.slots)if(r>=c.topY&&r<=c.bottomY||n>=c.topY&&n<=c.bottomY){h=!0;break}if(h){e.voice.index===1?o=l.topY-i[1]-i[0]:o=l.bottomY;const c=o+i[0]+i[1],d=s*2,f=Math.ceil(Math.abs(o-r)/d);return l.addSlot(o,c),o<r?f*-d:f*d}}return 0}}class nn{_division=0;_slots=[];_barDuration;constructor(e,t,s){this._division=t,this._slots=s,this._barDuration=e}calculateGroupIndex(e){if(this._slots.length===0)return e;e=e%this._barDuration;const t=Math.floor(e/this._division);return this._slots[t]}static build(e,t,s){const i=e.calculateDuration(!1),r=B.toTicks(t),n=i/r;if(n<0||s.length===0)return new nn(0,0,[]);let o=0,l=s[o];const h=[];for(let c=0;c<n;c++)o<s.length?(h.push(o),l--,l<=0&&(o++,o<s.length&&(l=s[o]))):(h.push(o),o++);return new nn(i,r,h)}}class Yr{_renderer;_beamHelperLookup=new Map;beamHelpers=[];collisionHelper;preferredBeamDirection=null;constructor(e){this._renderer=e,this.collisionHelper=new Ad}initialize(){const e=this._renderer,t=this._renderer.bar,s=t.masterBar,i=s.actualBeamingRules??Yr._findOrBuildDefaultBeamingRules(s),r=i.findRule(t.shortestDuration),n=`beaming_${i.uniqueId}_${r[0]}`;let o=this._renderer.scoreRenderer.layout.beamingRuleLookups.has(n)?this._renderer.scoreRenderer.layout.beamingRuleLookups.get(n):void 0;o||(o=nn.build(s,r[0],r[1]),this._renderer.scoreRenderer.layout.beamingRuleLookups.set(n,o));let l=null,h=null;for(let c=0,d=t.voices.length;c<d;c++){const f=t.voices[c];this.beamHelpers.push([]);for(let p=0,g=f.beats.length;p<g;p++){const m=f.beats[p];let b;m.graceType!==K.None?b=h:(b=l,h&&h.finish(),h=null),(!b||!b.checkBeat(m))&&(b&&b.finish(),b=new _s(t.staff,e,o),b.preferredBeamDirection=this.preferredBeamDirection,b.checkBeat(m),m.graceType!==K.None?h=b:l=b,this.beamHelpers[f.index].push(b)),this._beamHelperLookup.set(m.id,b)}l&&l.finish(),h&&h.finish(),l=null,h=null}}static _defaultBeamingRules;static _findOrBuildDefaultBeamingRules(e){let t=Yr._defaultBeamingRules;t||(t=new Map([nt.createSimple(2,16,y.Sixteenth,[1,1]),nt.createSimple(1,8,y.Eighth,[1]),nt.createSimple(1,4,y.Quarter,[1]),nt.createSimple(3,16,y.Sixteenth,[3]),nt.createSimple(4,16,y.Sixteenth,[2,2]),nt.createSimple(2,8,y.Eighth,[1,1]),nt.createSimple(5,16,y.Sixteenth,[3,2]),nt.createSimple(6,16,y.Sixteenth,[3,3]),nt.createSimple(3,8,y.Eighth,[3]),nt.createSimple(4,8,y.Eighth,[2,2]),nt.createSimple(2,4,y.Quarter,[1,1]),nt.createSimple(9,16,y.Sixteenth,[3,3,3]),nt.createSimple(5,8,y.Eighth,[3,2]),nt.createSimple(12,16,y.Sixteenth,[3,3,3,3]),nt.createSimple(6,8,y.Eighth,[3,3,3]),nt.createSimple(3,4,y.Quarter,[1,1,1]),nt.createSimple(7,8,y.Eighth,[4,3]),nt.createSimple(8,8,y.Eighth,[3,3,2]),nt.createSimple(4,4,y.Quarter,[1,1,1,1]),nt.createSimple(9,8,y.Eighth,[3,3,3]),nt.createSimple(10,8,y.Eighth,[4,3,3]),nt.createSimple(5,4,y.Quarter,[1,1,1,1,1]),nt.createSimple(12,8,y.Eighth,[3,3,3,3]),nt.createSimple(6,4,y.Quarter,[1,1,1,1,1,1]),nt.createSimple(15,8,y.Eighth,[3,3,3,3,3,3]),nt.createSimple(8,4,y.Quarter,[1,1,1,1,1,1,1,1]),nt.createSimple(18,8,y.Eighth,[3,3,3,3,3,3])].map(h=>[`${h.timeSignatureNumerator}_${h.timeSignatureDenominator}`,h])),Yr._defaultBeamingRules=t);const s=`${e.timeSignatureNumerator}_${e.timeSignatureDenominator}`;if(t.has(s))return t.get(s);let i=B.QuarterTime;e.timeSignatureDenominator===8&&e.timeSignatureNumerator%3===0&&(i+=B.QuarterTime/2|0);const r=Math.ceil(e.calculateDuration(!1)/i),n=i/B.QuarterTime*2,o=new nt,l=[];for(let h=0;h<r;h++)l.push(n);return o.groups.set(y.Eighth,l),o.timeSignatureNumerator=e.timeSignatureNumerator,o.timeSignatureDenominator=e.timeSignatureDenominator,o.finish(),t.set(s,o),o}getBeamingHelperForBeat(e){return this._beamHelperLookup.has(e.id)?this._beamHelperLookup.get(e.id):void 0}}var D;(function(a){a[a.TopWithStem=0]="TopWithStem",a[a.Top=1]="Top",a[a.Center=2]="Center",a[a.Bottom=3]="Bottom",a[a.BottomWithStem=4]="BottomWithStem",a[a.StemUp=5]="StemUp",a[a.StemDown=6]="StemDown"})(D||(D={}));var Qe;(function(a){a[a.Left=0]="Left",a[a.Center=1]="Center",a[a.Right=2]="Right"})(Qe||(Qe={}));class zn{_preBeatGlyphs=new zr;voiceContainer=new Ed;_postBeatGlyphs=new zr;_ties=[];_multiSystemSlurs;topEffects;
vendor: 20,916 bytes, line 65
65bottomEffects;get nextRenderer(){return!this.bar||!this.bar.nextBar?null:this.scoreRenderer.layout.getRendererForBar(this.staff.staffId,this.bar.nextBar)}get previousRenderer(){return!this.bar||!this.bar.previousBar?null:this.scoreRenderer.layout.getRendererForBar(this.staff.staffId,this.bar.previousBar)}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;_contentTopOverflow=0;_contentBottomOverflow=0;beatEffectsMinY=Number.NaN;beatEffectsMaxY=Number.NaN;get topOverflow(){return this._contentTopOverflow+this.topEffects.height}get bottomOverflow(){return this._contentBottomOverflow+this.bottomEffects.height}helpers;get collisionHelper(){return this.helpers.collisionHelper}isLinkedToPrevious=!1;canWrap=!0;get showMultiBarRest(){return!0}constructor(e,t){this.scoreRenderer=e,this.bar=t,this.helpers=new Yr(this),this.topEffects=new Bl(this,!0),this.bottomEffects=new Bl(this,!1)}registerTie(e){this._ties.push(e)}get middleYPosition(){return 0}registerBeatEffectOverflows(e,t){const s=this.beatEffectsMinY;(Number.isNaN(s)||e<s)&&(this.beatEffectsMinY=e);const i=this.beatEffectsMaxY;(Number.isNaN(i)||t>i)&&(this.beatEffectsMaxY=t)}registerOverflowTop(e){return e=Math.ceil(e),e>this._contentTopOverflow?(this._contentTopOverflow=e,!0):!1}registerOverflowBottom(e){return e=Math.ceil(e),e>this._contentBottomOverflow?(this._contentBottomOverflow=e,!0):!1}scaleToWidth(e){const t=e-this._preBeatGlyphs.width-this._postBeatGlyphs.width;this.voiceContainer.scaleToWidth(t);for(const s of this.helpers.beamHelpers)for(const i of s)i.alignWithBeats();this._postBeatGlyphs.x=this._preBeatGlyphs.x+this._preBeatGlyphs.width+t,this.width=e,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 this.index===0}get isLastOfStaff(){return this.index===this.staff.barRenderers.length-1}get isLast(){return!this.bar||this.bar.index===this.scoreRenderer.layout.lastBarIndex}_registerLayoutingInfo(){const e=this.layoutingInfo,t=this._preBeatGlyphs.width;e.preBeatSize<t&&(e.preBeatSize=t),this.voiceContainer.registerLayoutingInfo(e);const i=this._postBeatGlyphs.width;e.postBeatSize<i&&(e.postBeatSize=i)}_appliedLayoutingInfo=0;afterReverted(){this.staff=void 0,this.registerMultiSystemSlurs(void 0),this.isFinalized=!1}afterStaffBarReverted(){this.topEffects.afterStaffBarReverted(),this.bottomEffects.afterStaffBarReverted(),this._registerStaffOverflow()}applyLayoutingInfo(){if(this._appliedLayoutingInfo>=this.layoutingInfo.version)return!1;this.topEffects.resetEffectBandSizingInfo(),this.bottomEffects.resetEffectBandSizingInfo(),this._appliedLayoutingInfo=this.layoutingInfo.version,this._preBeatGlyphs.width=this.layoutingInfo.preBeatSize;const e=this.voiceContainer;return e.x=this._preBeatGlyphs.x+this._preBeatGlyphs.width,e.applyLayoutingInfo(this.layoutingInfo),this._postBeatGlyphs.x=Math.floor(e.x+e.width),this._postBeatGlyphs.width=this.layoutingInfo.postBeatSize,this.width=Math.ceil(this._postBeatGlyphs.x+this._postBeatGlyphs.width),this.computedWidth=this.width,this.topEffects.sizeAndAlignEffectBands(),this.bottomEffects.sizeAndAlignEffectBands(),this._registerStaffOverflow(),!0}isFinalized=!1;registerMultiSystemSlurs(e){if(!e){this._multiSystemSlurs=void 0;return}let t;for(const s of e){const i=new vd(s);i.renderer=this,i.tieDirection=s.tieDirection,t||(t=[]),t.push(i)}this._multiSystemSlurs=t}_finalizeTies(e,t,s){let i=!1;for(const r of e){const n=r;if(n.doLayout(),r.checkForOverflow){const o=n.getBoundingBoxTop(),h=n.getBoundingBoxBottom()-s;h>0&&this.registerOverflowBottom(h)&&(i=!0);const c=o-t;c<0&&this.registerOverflowTop(c*-1)&&(i=!0)}}return i}finalizeRenderer(){this.isFinalized=!0;let e=!1;const t=this.y,s=this.y+this.height;this._finalizeTies(this._ties,t,s)&&(e=!0);const i=this._multiSystemSlurs;i&&this._finalizeTies(i,t,s)&&(e=!0);const r=this.topEffects.finalizeEffects(),n=this.bottomEffects.finalizeEffects();return(r||n)&&(e=!0),e&&(this.updateSizes(),this._registerStaffOverflow()),e}_registerStaffOverflow(){this.staff.registerOverflowTop(this.topOverflow),this.staff.registerOverflowBottom(this.bottomOverflow)}doLayout(){if(this.bar){this.helpers.initialize(),this._ties=[],this._preBeatGlyphs.renderer=this,this.voiceContainer.renderer=this,this._postBeatGlyphs.renderer=this,this.topEffects.doLayout(),this.bottomEffects.doLayout(),this.bar.simileMark===xt.SecondOfDouble&&(this.canWrap=!1),this.createPreBeatGlyphs(),this.createBeatGlyphs(),this.createPostBeatGlyphs(),this._registerLayoutingInfo(),this.topEffects.sizeAndAlignEffectBands(!1),this.bottomEffects.sizeAndAlignEffectBands(!1),this.updateSizes();for(const e of this.helpers.beamHelpers)for(const t of e)t.finish();this.computedWidth=this.width,this.calculateOverflows(0,this.height)}}calculateOverflows(e,t){const s=this._preBeatGlyphs.glyphs;if(s)for(const c of s){const d=c.getBoundingBoxTop();d<0&&this.registerOverflowTop(d*-1);const f=c.getBoundingBoxBottom();f>t&&this.registerOverflowBottom(f-t)}const i=this._postBeatGlyphs.glyphs;if(i)for(const c of i){const d=c.getBoundingBoxTop();d<0&&this.registerOverflowTop(d*-1);const f=c.getBoundingBoxBottom();f>t&&this.registerOverflowBottom(f-t)}const r=this.voiceContainer,n=r.getBoundingBoxTop();n<0&&this.registerOverflowTop(n*-1);const o=r.getBoundingBoxBottom();o>t&&this.registerOverflowBottom(o-t);const l=this.beatEffectsMinY;!Number.isNaN(l)&&l<0&&this.registerOverflowTop(l*-1);const h=this.beatEffectsMaxY;!Number.isNaN(h)&&h>t&&this.registerOverflowBottom(h-t)}updateSizes(){this.staff.registerStaffTop(0),this.voiceContainer.x=this._preBeatGlyphs.x+this._preBeatGlyphs.width,this._postBeatGlyphs.x=Math.floor(this.voiceContainer.x+this.voiceContainer.width),this.width=Math.ceil(this._postBeatGlyphs.x+this._postBeatGlyphs.width);const e=this.topEffects.updateEffectBandHeights(),t=this.bottomEffects.updateEffectBandHeights();(e||t)&&this._registerStaffOverflow(),this.height+=this.layoutingInfo.height,this.height=Math.ceil(this.height),this.staff.registerStaffBottom(this.height)}addPreBeatGlyph(e){e.renderer=this,this._preBeatGlyphs.addGlyph(e)}addBeatGlyph(e){e.renderer=this,this.voiceContainer.addGlyph(e)}getBeatContainer(e){return this.voiceContainer.getBeatContainer(e)}paint(e,t,s){this.paintContent(e,t,s);const i=t+this.y-this.staff.topOverflow;this.topEffects.paint(e+this.x,i,s);const r=t+this.y+this.height+this.staff.bottomOverflow-this.bottomEffects.height;this.bottomEffects.paint(e+this.x,r,s)}paintContent(e,t,s){this.paintBackground(e,t,s),s.color=this.resources.mainGlyphColor,this._preBeatGlyphs.paint(e+this.x,t+this.y,s),this.voiceContainer.paint(e+this.x,t+this.y,s),s.color=this.resources.mainGlyphColor,this._postBeatGlyphs.paint(e+this.x,t+this.y,s),this._paintMultiSystemSlurs(e,t,s)}_paintMultiSystemSlurs(e,t,s){const i=this._multiSystemSlurs;if(i)for(const r of i)r.paint(e,t,s)}paintBackground(e,t,s){this.layoutingInfo.paint(e+this.x+this._preBeatGlyphs.x+this._preBeatGlyphs.width,t+this.y+this.height,s)}buildBoundingsLookup(e,t,s){const i=new Co;i.bar=this.bar,i.visualBounds=new bt,i.visualBounds.x=t+this.x,i.visualBounds.y=s+this.y,i.visualBounds.w=this.width,i.visualBounds.h=this.height,i.realBounds=new bt,i.realBounds.x=t+this.x,i.realBounds.y=s+this.y,i.realBounds.w=this.width,i.realBounds.h=this.height,e.addBar(i),this.voiceContainer.buildBoundingsLookup(i,t+this.x,s+this.y)}addPostBeatGlyph(e){this._postBeatGlyphs.addGlyph(e)}createPreBeatGlyphs(){this.wasFirstOfStaff=this.isFirstOfStaff}createBeatGlyphs(){if(this.additionalMultiRestBars){const e=new Dd;this.addBeatGlyph(e)}else for(const e of this.bar.filledVoices)this.createVoiceGlyphs(this.bar.voices[e]);this.voiceContainer.doLayout(),(this.topEffects.isLinkedToPreviousRenderer||this.bottomEffects.isLinkedToPreviousRenderer)&&(this.isLinkedToPrevious=!0)}createVoiceGlyphs(e){this.topEffects.createVoiceGlyphs(e),this.bottomEffects.createVoiceGlyphs(e)}createPostBeatGlyphs(){}get beatGlyphsStart(){return this.voiceContainer.x}get postBeatGlyphsStart(){return this._postBeatGlyphs.x}getBeatX(e,t=ae.PreNotes,s=!1){return this.beatGlyphsStart+this.voiceContainer.getBeatX(e,t,s)}getRatioPositionX(e){const t=this.bar.isEmpty?this.beatGlyphsStart:this.getBeatX(this.bar.voices[0].beats[0],ae.MiddleNotes),s=t,i=this.postBeatGlyphsStart-t;return s+i*e}getNoteX(e,t){return this.beatGlyphsStart+this.voiceContainer.getNoteX(e,t)}getNoteY(e,t){return this.voiceContainer.y+ +this.voiceContainer.getNoteY(e,t)}getRestY(e,t){return this.voiceContainer.y+ +this.voiceContainer.getRestY(e,t)}reLayout(){this.topEffects.reLayout(),this.bottomEffects.reLayout(),this.updateSizes(),(this.wasFirstOfStaff&&!this.isFirstOfStaff||!this.wasFirstOfStaff&&this.isFirstOfStaff)&&(this.recreatePreBeatGlyphs(),this._postBeatGlyphs.doLayout()),this._registerLayoutingInfo(),this.calculateOverflows(0,this.height)}recreatePreBeatGlyphs(){this._preBeatGlyphs=new zr,this._preBeatGlyphs.renderer=this,this.createPreBeatGlyphs()}paintSimileMark(e,t,s){const i=xe.voice(s,yr.Glyphs,this.bar.voices[0],!0);try{switch(this.bar.simileMark){case xt.Simple:s.beginGroup(hi.getGroupId(this.bar.voices[0].beats[0])),pt.fillMusicFontSymbolSafe(s,e+this.x+this.width/2,t+this.y+this.height/2,1,u.Repeat1Bar,!0),s.endGroup();break;case xt.SecondOfDouble:s.beginGroup(hi.getGroupId(this.bar.voices[0].beats[0])),s.beginGroup(hi.getGroupId(this.bar.previousBar.voices[0].beats[0])),pt.fillMusicFontSymbolSafe(s,e+this.x,t+this.y+this.height/2,1,u.Repeat2Bars,!0),s.endGroup(),s.endGroup();break}}finally{i?.[Symbol.dispose]?.()}}completeBeamingHelper(e){}}class hh extends oa{_type;_symbol=u.None;_repeatOffsetX=0;_symbolOffsetY=0;_partialWaves;constructor(e,t,s,i=!1){super(ae.EndBeat),this._type=s,this.x=e,this.y=t,this._partialWaves=i}doLayout(){switch(super.doLayout(),this._type){case Be.Slight:this._symbol=this.slightVibratoGlyph;break;case Be.Wide:this._symbol=this.wideVibratoGlyph;break}this._repeatOffsetX=this.renderer.smuflMetrics.repeatOffsetX.get(this._symbol),this._symbolOffsetY=this.renderer.smuflMetrics.glyphTop.get(this._symbol),this.height=this.renderer.smuflMetrics.glyphHeights.get(this._symbol)}paintGrouped(e,t,s,i){const r=e+this.x,n=s-r,o=this._repeatOffsetX;let l=n/o;this._partialWaves||(l=Math.floor(l)),l<1&&(l=1);const h=[];for(let c=0;c<l;c++)h.push(this._symbol);i.fillMusicFontSymbols(e+this.x,t+this.y+this._symbolOffsetY,1,h,!1)}}class Ri extends hh{get slightVibratoGlyph(){return u.GuitarVibratoStroke}get wideVibratoGlyph(){return u.GuitarWideVibratoStroke}}class Pi extends G{lineValue=0;constructor(e=0,t=0){super(e,t),this.lineValue=t}}class wn extends Nt{_notes=[];_renderPoints=new Map;_preBendMinValue=-1;_bendMiddleMinValue=-1;_bendEndMinValue=-1;_bendEndContinuedMinValue=-1;_releaseMinValue=-1;_releaseContinuedMinValue=-1;_maxBendValue=-1;checkForOverflow=!1;constructor(){super(0,0)}addBends(e){this._notes.push(e);const t=this._createRenderingPoints(e);this._renderPoints.set(e.id,t),(this._maxBendValue===-1||this._maxBendValue<e.maxBendPoint.value)&&(this._maxBendValue=e.maxBendPoint.value);let s=0;switch(e.bendType){case $.Bend:s=t[1].value,e.isTieOrigin?(this._bendEndContinuedMinValue===-1||s<this._bendEndContinuedMinValue)&&(this._bendEndContinuedMinValue=s):(this._bendEndMinValue===-1||s<this._bendEndMinValue)&&(this._bendEndMinValue=s);break;case $.Release:s=t[1].value,e.isTieOrigin?(this._releaseContinuedMinValue===-1||s<this._releaseContinuedMinValue)&&(this._releaseContinuedMinValue=s):s>0&&(this._releaseMinValue===-1||s<this._releaseMinValue)&&(this._releaseMinValue=s);break;case $.BendRelease:s=t[1].value,(this._bendMiddleMinValue===-1||s<this._bendMiddleMinValue)&&(this._bendMiddleMinValue=s),s=t[2].value,e.isTieOrigin?(this._releaseContinuedMinValue===-1||s<this._releaseContinuedMinValue)&&(this._releaseContinuedMinValue=s):s>0&&(this._releaseMinValue===-1||s<this._releaseMinValue)&&(this._releaseMinValue=s);break;case $.Prebend:s=t[0].value,(this._preBendMinValue===-1||s<this._preBendMinValue)&&(this._preBendMinValue=s);break;case $.PrebendBend:s=t[0].value,(this._preBendMinValue===-1||s<this._preBendMinValue)&&(this._preBendMinValue=s),s=t[1].value,e.isTieOrigin?(this._bendEndContinuedMinValue===-1||s<this._bendEndContinuedMinValue)&&(this._bendEndContinuedMinValue=s):(this._bendEndMinValue===-1||s<this._bendEndMinValue)&&(this._bendEndMinValue=s);break;case $.PrebendRelease:s=t[0].value,(this._preBendMinValue===-1||s<this._preBendMinValue)&&(this._preBendMinValue=s),s=t[1].value,e.isTieOrigin?(this._releaseContinuedMinValue===-1||s<this._releaseContinuedMinValue)&&(this._releaseContinuedMinValue=s):s>0&&(this._releaseMinValue===-1||s<this._releaseMinValue)&&(this._releaseMinValue=s);break}}doLayout(){super.doLayout(),this._calculateAndRegisterOverflow();let e=0;for(const t of this._notes){const s=this._renderPoints.get(t.id);switch(t.bendType){case $.Bend:s[1].lineValue=t.isTieOrigin?this._bendEndContinuedMinValue:this._bendEndMinValue;break;case $.Release:e=t.isTieOrigin?this._releaseContinuedMinValue:this._releaseMinValue,e>=0&&(s[1].lineValue=e);break;case $.BendRelease:s[1].lineValue=this._bendMiddleMinValue,e=t.isTieOrigin?this._releaseContinuedMinValue:this._releaseMinValue,e>=0&&(s[2].lineValue=e);break;case $.Prebend:s[0].lineValue=this._preBendMinValue;break;case $.PrebendBend:s[0].lineValue=this._preBendMinValue,s[1].lineValue=t.isTieOrigin?this._bendEndContinuedMinValue:this._bendEndMinValue;break;case $.PrebendRelease:s[0].lineValue=this._preBendMinValue,e=t.isTieOrigin?this._releaseContinuedMinValue:this._releaseMinValue,e>=0&&(s[1].lineValue=e);break}}this.width=0,this._notes.sort((t,s)=>t.isStringed?t.string-s.string:t.realValue-s.realValue)}_calculateAndRegisterOverflow(){const e=this.renderer.resources,t=this.renderer.smuflMetrics;let s=this._maxBendValue*t.tabBendPerValueHeight;s+=t.tabBendStaffPadding;const i=this.renderer.scoreRenderer.canvas;i.font=e.tablatureFont;const r=i.measureText("full");s+=r.height+e.engravingSettings.tabBendLabelPadding,this.renderer.registerOverflowTop(s)}_createRenderingPoints(e){const t=[];switch(e.bendType){case $.Custom:for(const s of e.bendPoints)t.push(new Pi(s.offset,s.value));break;case $.BendRelease:t.push(new Pi(0,e.bendPoints[0].value)),t.push(new Pi(G.MaxPosition/2|0,e.bendPoints[1].value)),t.push(new Pi(G.MaxPosition,e.bendPoints[3].value));break;case $.Bend:case $.Hold:case $.Prebend:case $.PrebendBend:case $.PrebendRelease:case $.Release:t.push(new Pi(0,e.bendPoints[0].value)),t.push(new Pi(G.MaxPosition,e.bendPoints[1].value));break}return t}paint(e,t,s){const i=s.color;this._notes.length>1&&(s.color=this.renderer.resources.secondaryGlyphColor);for(const r of this._notes){const n=this.renderer;let o=r,l=!1,h=null,c=!1,d=null;for(;o.isTieOrigin;){const N=o.tieDestination;if(h=this.renderer.scoreRenderer.layout.getRendererForBar(this.renderer.staff.staffId,N.beat.voice.bar),!h||n.staff!==h.staff)break;if(o=N,l=!0,o.hasBend||!this.renderer.settings.notation.extendBendArrowsOnTiedNotes||o.vibrato!==Be.None){c=!0;break}}d=o.beat,h=this.renderer.scoreRenderer.layout.getRendererForBar(this.renderer.staff.staffId,d.voice.bar),d.isLastOfVoice&&!o.hasBend&&this.renderer.settings.notation.extendBendArrowsOnTiedNotes&&(d=null);const f=n.smuflMetrics,p=f.glyphWidths.get(u.ArrowheadBlackDown),g=t+n.y-f.tabBendStaffPadding;let m=e+n.x;const b=this._renderPoints.get(r.id);b[0].value>0||r.isContinuedBend?m+=n.getBeatX(r.beat,ae.MiddleNotes):m+=n.getNoteX(r,Qe.Right);let S=0;!d||d.isLastOfVoice&&!c?(S=e+h.x+h.postBeatGlyphsStart,S-=this.renderer.smuflMetrics.postNoteEffectPadding):c||!d.nextBeat?S=e+h.x+h.getBeatX(d,ae.MiddleNotes):r.bendType===$.Hold?S=e+h.x+h.getBeatX(d.nextBeat,ae.OnNotes):(S=e+h.x+h.getBeatX(d.nextBeat,ae.PreNotes),S-=this.renderer.smuflMetrics.postNoteEffectPadding),l||(S-=p/2),this._paintBendLines(s,m,g,S,n,r,b),this._paintBendVibrato(s,e,S+p/2,g-f.tabBendPerValueHeight*b[b.length-1].lineValue,h,o),s.color=i}}_paintBendVibrato(e,t,s,i,r,n){if(n.isTieDestination&&n.vibrato!==Be.None&&!n.hasBend){const o=t+r.x,l=s-o,h=new Ri(l,0,n.vibrato);h.beat=n.beat,h.renderer=r,h.doLayout(),h.paint(o,i,e)}}_paintBendLines(e,t,s,i,r,n,o){const l=e.lineWidth,h=this.renderer.resources,c=e.textBaseline;e.textBaseline=He.Alphabetic,e.lineWidth=h.engravingSettings.arrowShaftThickness;const f=(i-t)/G.MaxPosition;for(let p=0,g=o.length-1;p<g;p++){const m=o[p];let b=o[p+1];p===0&&m.value!==0&&!n.isTieDestination&&this._paintBend(e,t,s,f,r,n,new Pi(0,0),m),n.bendType!==$.Prebend?(p===0&&(t+=this.renderer.smuflMetrics.postNoteEffectPadding),this._paintBend(e,t,s,f,r,n,m,b)):n.isTieOrigin&&n.tieDestination.hasBend&&(b=new Pi(G.MaxPosition,m.value),b.lineValue=m.lineValue,this._paintBend(e,t,s,f,r,n,m,b))}e.lineWidth=l,e.textBaseline=c}_paintBendLine(e,t,s,i,r,n,o){if(n.value===o.value){if(n.lineValue>0){let l=i;const h=this.renderer.smuflMetrics.tabBendDashSize,c=t+h;if((l-t)/(h*2)<1)e.moveTo(l,s),e.lineTo(t,s);else for(;l>c;)e.moveTo(l,s),e.lineTo(l-h,s),l-=h*2;e.stroke()}}else if(i>t){const h=o.value>n.value?3:-3;e.moveTo(t,s),e.bezierCurveTo((t+i)/2,s,i,s,i,r+h),e.stroke()}else e.moveTo(t,s),e.lineTo(i,r),e.stroke()}_paintBend(e,t,s,i,r,n,o,l){const h=r.lineOffset/2,c=r.resources,d=c.engravingSettings,f=t+i*o.offset;let p;o.value===0?(p=s+d.tabBendStaffPadding,l.offset===o.offset?p+=r.getNoteY(n.beat.maxStringNote,D.Top)-h:p+=r.getNoteY(n,D.Center)):p=s-d.tabBendPerValueHeight*o.lineValue;const g=t+i*l.offset;let m;l.lineValue===0?m=s+d.tabBendStaffPadding+r.getNoteY(n.beat.maxStringNote,D.Center):m=s-d.tabBendPerValueHeight*l.lineValue,this._paintBendLine(e,f,p,g,m,o,l);const b=d.glyphWidths.get(u.ArrowheadBlackDown);if(o.value!==l.value){const S=l.value>o.value;this._paintBendLineArrow(e,g,m,p,b,S),this._paintBendLineSlurText(e,f,p,g,m,n,c.graceFont),this._paintBendLineValueText(e,p,g,m-d.tabBendLabelPadding,o,l,c.tablatureFont)}}_paintBendLineSlurText(e,t,s,i,r,n,o){if(n.bendStyle===Ke.Gradual){const l="grad.",h=e.measureText(l);e.font=o;let c=0,d=0;if(s>r){const f=Math.abs(s-r);c=f>h.height?s-f/2:s,d=(t+i-h.width)/2}else c=s,d=i-h.width;e.fillText(l,d,c)}}_paintBendLineValueText(e,t,s,i,r,n,o){if(n.value!==0){const l=n.value>r.value;let h=n.value,c="";if(h===4)c="full",h-=4;else if(h>=4||h<=-4){const d=h/4|0;c+=d,h-=d*4}if(h>0&&(c+=wn.getFractionSign(h)),c!==""){const d=l?i:t+Math.abs(i-t)*1/3;e.font=o;const f=e.measureText(c),p=s-f.width/2;e.fillText(c,p,d)}}}_paintBendLineArrow(e,t,s,i,r,n){n?(s+r>i&&(s=i-r),e.beginPath(),e.moveTo(t,s),e.lineTo(t-r*.5,s+r),e.lineTo(t+r*.5,s+r),e.closePath(),e.fill()):(s<i&&(s=i+r),e.beginPath(),e.moveTo(t,s),e.lineTo(t-r*.5,s-r),e.lineTo(t+r*.5,s-r),e.closePath(),e.fill())}static getFractionSign(e){switch(e){case 1:return"¼";case 2:return"½";case 3:return"¾";default:return`${e}/ 4`}}}class ch extends fs{_beat;_renderPoints;_isSimpleDip=!1;originalTopOffset=0;originalBottomOffset=0;topOffset=0;bottomOffset=0;constructor(e){super(0,0),this._beat=e,this._renderPoints=this._createRenderingPoints(e)}_createRenderingPoints(e){if(e.whammyBarType===Pe.Custom)return e.whammyBarPoints;const t=[];switch(e.whammyBarType){case Pe.Dive:case Pe.Hold:case Pe.PrediveDive:case Pe.Predive:t.push(new G(0,e.whammyBarPoints[0].value)),t.push(new G(G.MaxPosition,e.whammyBarPoints[1].value));break;case Pe.Dip:t.push(new G(0,e.whammyBarPoints[0].value)),t.push(new G(G.MaxPosition/2|0,e.whammyBarPoints[1].value)),t.push(new G(G.MaxPosition,e.whammyBarPoints[e.whammyBarPoints.length-1].value));break}return t}doLayout(){if(super.doLayout(),this._beat.whammyBarType===Pe.Custom)return;this._isSimpleDip=this.renderer.settings.notation.notationMode===Vt.SongBook&&this._beat.whammyBarType===Pe.Dip;const e=this._beat.minWhammyPoint,t=this._beat.maxWhammyPoint;let s=t.value>0?-this._getOffset(t.value):0,i=e.value<0?-this._getOffset(e.value):0;const r=this.renderer.scoreRenderer.canvas;r.font=this.renderer.resources.tablatureFont;const o=r.measureText("-1").height+this.renderer.smuflMetrics.tabWhammyTextPadding;if((s!==0||this._beat.whammyBarPoints[0].value!==0||this.renderer.settings.notation.isNotationElementVisible(C.ZerosOnDiveWhammys))&&(s-=o),i!==0)if(this._isSimpleDip)s-=o;else{const l=i-o;l<s&&(s=l)}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}_getOffset(e){if(e===0)return 0;let t=this.renderer.smuflMetrics.tabWhammyPerHalfHeight+Math.log2(Math.abs(e)/2)*this.renderer.smuflMetrics.tabWhammyPerHalfHeight;return e<0&&(t=-t),t}
65paint(e,t,s){const i=xe.beat(s,rt.StandardNotationEffects,this._beat);try{const r=this.renderer;let n=this._beat.nextBeat,o=null,l=ae.PreNotes;n&&(o=this.renderer.scoreRenderer.layout.getRendererForBar(this.renderer.staff.staffId,n.voice.bar),!o||o.staff!==r.staff||o!==r&&!n.hasWhammyBar?(n=null,o=null):l=n.hasWhammyBar&&(r.settings.notation.notationMode!==Vt.SongBook||n.whammyBarType!==Pe.Dip)?ae.MiddleNotes:ae.PreNotes);let h=0,c=0;this._isSimpleDip?(h=e+r.getBeatX(this._beat,ae.OnNotes,!0),c=e+r.getBeatX(this._beat,ae.PostNotes,!0)):(h=e+r.getBeatX(this._beat,ae.MiddleNotes,!0),o?c=e-r.x+o.x+o.getBeatX(n,l,!0):c=e+r.getBeatX(this._beat,ae.EndBeat)-r.smuflMetrics.postNoteEffectPadding);const d=s.textAlign,f=s.textBaseline;if(s.textAlign=Y.Center,s.textBaseline=He.Alphabetic,s.font=this.renderer.resources.tablatureFont,this._renderPoints.length>=2){const p=(c-h)/G.MaxPosition;s.beginPath();const g=t+this.topOffset;let m=this._beat.whammyStyle===Ke.Gradual?"grad.":"";for(let b=0,S=this._renderPoints.length-1;b<S;b++){const N=this._renderPoints[b],v=this._renderPoints[b+1];let W=b===0;b===0&&N.value!==0&&!this._beat.isContinuedWhammy&&(this._paintWhammy(!1,new G(0,0),N,h,g,p,s),W=!1),this._paintWhammy(W,N,v,h,g,p,s,m),m=""}s.stroke()}s.textAlign=d,s.textBaseline=f}finally{i?.[Symbol.dispose]?.()}}_paintWhammy(e,t,s,i,r,n,o,l){const h=i+n*t.offset,c=i+n*s.offset,d=r-this._getOffset(t.value),f=r-this._getOffset(s.value);if(t.offset===s.offset){const m=this.renderer.smuflMetrics.tabWhammyDashSize;if(Math.abs(f-d)/(m*2)<1)o.moveTo(h,d),o.lineTo(c,f);else{const S=Math.max(d,f);let N=Math.min(d,f);for(;S>N;)o.moveTo(h,N),o.lineTo(h,N+m),N+=m*2}o.stroke()}else if(t.value===s.value){const m=this.renderer.smuflMetrics.tabWhammyDashSize;if(Math.abs(c-h)/(m*2)<1)o.moveTo(h,d),o.lineTo(c,f);else{let S=Math.max(h,c);const N=Math.min(h,c);for(;S>N;)o.moveTo(S,d),o.lineTo(S-m,d),S-=m*2}o.stroke()}else o.moveTo(h,d),o.lineTo(c,f);const p=this.renderer.smuflMetrics.tabWhammyTextPadding;e&&!this._beat.isContinuedWhammy&&!this._isSimpleDip&&(this.renderer.settings.notation.isNotationElementVisible(C.ZerosOnDiveWhammys)&&o.fillText("0",h,d-p),l&&o.fillText(l,h,d-p));let g=Math.abs(s.value);if((g!==0||this.renderer.settings.notation.isNotationElementVisible(C.ZerosOnDiveWhammys)&&!this._isSimpleDip)&&t.value!==s.value){let m="";if(s.value<0&&(m+="-"),g>=4){const N=g/4|0;m+=N,g-=N*4}else g===0&&(m+="0");g>0&&(m+=wn.getFractionSign(g));let b=0;this._isSimpleDip?b=Math.min(d,f):b=t.offset===s.offset?Math.min(d,f):f;const S=c;o.fillText(m,S,b-p)}}}class Id extends dt{get notationElement(){return C.EffectWhammyBar}get effectId(){return`${super.effectId}.simpledip`}get hideOnMultiTrack(){return!1}get canShareBand(){return!1}get sizingMode(){return ke.SingleOnBeat}shouldCreateGlyph(e,t){return e.notation.notationMode===Vt.SongBook&&t.hasWhammyBar&&t.whammyBarType===Pe.Dip}createNewGlyph(e,t){return new ch(t)}canExpand(e,t){return!0}}class dh extends hh{get slightVibratoGlyph(){return u.WiggleSawtoothNarrow}get wideVibratoGlyph(){return u.WiggleSawtooth}}class Tl extends dt{get notationElement(){return C.EffectSlightBeatVibrato}get hideOnMultiTrack(){return!1}get canShareBand(){return!0}get sizingMode(){return ke.GroupedOnBeatToEnd}shouldCreateGlyph(e,t){return t.vibrato===Be.Slight}createNewGlyph(e,t){return new dh(0,0,Be.Slight)}canExpand(e,t){return!0}}class xl extends rr{_hideOnTiedBend;get notationElement(){return C.EffectSlightNoteVibrato}shouldCreateGlyphForNote(e){let t=e.vibrato===Be.Slight||e.isTieDestination&&e.tieOrigin.vibrato===Be.Slight;return this._hideOnTiedBend&&t&&e.isTieDestination&&e.tieOrigin.hasBend&&(t=!1),t}get sizingMode(){return ke.GroupedOnBeatToEnd}createNewGlyph(e,t){return new Ri(0,0,Be.Slight)}constructor(e){super(),this._hideOnTiedBend=e}}class Rd extends fs{constructor(){super(0,0)}doLayout(){super.doLayout(),this.height=this.renderer.smuflMetrics.glyphHeights.get(u.KeyboardPedalPed)}paint(e,t,s){const i=this.renderer,r=t+this.y,n=this.height,o=i.bar.sustainPedals,l=this.renderer.smuflMetrics.glyphWidths.get(u.KeyboardPedalPed),h=this.renderer.smuflMetrics.glyphWidths.get(u.KeyboardPedalUp);let c=0;for(;c<o.length;){let d=o[c];for(;d!=null;){const f=e+this.renderer.getRatioPositionX(d.ratioPosition);let p=0;if(d.pedalType===it.Down?(pt.fillMusicFontSymbolSafe(s,f,r+n,1,u.KeyboardPedalPed,!0),p=l/2+this.renderer.smuflMetrics.sustainPedalLinePadding):d.pedalType===it.Up&&(pt.fillMusicFontSymbolSafe(s,f,r+n,1,u.KeyboardPedalUp,!0),p=h
vendor: 5,949 bytes, line 65
65/2+this.renderer.smuflMetrics.sustainPedalLinePadding),d.nextPedalMarker)if(d.nextPedalMarker.bar===d.bar){let g=e+this.renderer.getRatioPositionX(d.nextPedalMarker.ratioPosition);switch(d.nextPedalMarker.pedalType){case it.Down:g-=l/2;break;case it.Hold:break;case it.Up:g-=h/2;break}const m=f+p;g>m&&s.fillRect(m,r+n-this.renderer.smuflMetrics.pedalLineThickness,g-m,this.renderer.smuflMetrics.pedalLineThickness)}else{const g=e+this.x+this.width,m=f+p;s.fillRect(m,r+n-this.renderer.smuflMetrics.pedalLineThickness,g-m,this.renderer.smuflMetrics.pedalLineThickness)}if(c===0&&d.previousPedalMarker){const g=e+this.x,m=f-p;s.fillRect(g,r+n-this.renderer.smuflMetrics.pedalLineThickness,m-g,this.renderer.smuflMetrics.pedalLineThickness)}c++,d.nextPedalMarker!=null&&d.nextPedalMarker.bar!==d.bar?(d=null,c=o.length):d=d.nextPedalMarker}}}}class Od extends dt{get notationElement(){return C.EffectSustainPedal}get hideOnMultiTrack(){return!1}get canShareBand(){return!1}get sizingMode(){return ke.FullBar}shouldCreateGlyph(e,t){return t.voice.index===0&&t.index===0&&t.voice.bar.sustainPedals.length>0}createNewGlyph(e,t){return new Rd}canExpand(e,t){return!0}}class Xr extends dt{get notationElement(){return C.EffectWhammyBarLine}get hideOnMultiTrack(){return!1}get canShareBand(){return!1}get sizingMode(){return ke.GroupedOnBeatToEnd}shouldCreateGlyph(e,t){return t.hasWhammyBar}createNewGlyph(e,t){return new ch(t)}canExpand(e,t){return t.hasWhammyBar}static offsetSharedDataKey="tab.whammy.offset";onAlignGlyphs(e){const t=e.renderer.staff.getSharedLayoutData(Xr.offsetSharedDataKey,[0,0]);e.renderer.staff.setSharedLayoutData(Xr.offsetSharedDataKey,t);for(const s of e.iterateAllGlyphs()){const i=s;i.originalTopOffset>t[0]&&(t[0]=i.originalTopOffset),i.originalBottomOffset>t[1]&&(t[1]=i.originalBottomOffset)}}finalizeBand(e){const t=e.renderer.staff.getSharedLayoutData(Xr.offsetSharedDataKey,[0,0]),s=t[0],i=t[1];for(const r of e.iterateAllGlyphs()){const n=r;n.topOffset=s,n.bottomOffset=i,n.height=s+i}e.slot.shared.height=s+i,e.height=s+i}}class Nl extends dt{get notationElement(){return C.EffectTap}get hideOnMultiTrack(){return!1}get canShareBand(){return!0}get sizingMode(){return ke.SingleOnBeat}shouldCreateGlyph(e,t){return t.slap||t.pop||t.tap}createNewGlyph(e,t){const s=e.resources;return t.slap?new Es(0,0,"S",s.elementFonts.get(C.EffectTap),Y.Center):t.pop?new Es(0,0,"P",s.elementFonts.get(C.EffectTap),Y.Center):new Es(0,0,"T",s.elementFonts.get(C.EffectTap),Y.Center)}canExpand(e,t){return!0}}class Wd extends fs{_tempoAutomations;constructor(e){super(0,0),this._tempoAutomations=e}doLayout(){super.doLayout();const e=this.renderer.resources;this.height=this.renderer.smuflMetrics.glyphHeights.get(u.MetNoteQuarterUp)*e.engravingSettings.tempoNoteScale}paint(e,t,s){for(const i of this._tempoAutomations){let r=e+this.renderer.getRatioPositionX(i.ratioPosition);const n=this.renderer.resources;s.font=n.elementFonts.get(C.EffectMarker);const o=t+this.y+this.height+this.renderer.smuflMetrics.glyphBottom.get(u.MetNoteQuarterUp)*n.engravingSettings.tempoNoteScale,l=s.textBaseline;if(s.textBaseline=He.Alphabetic,i.text){const h=`${i.text} `,c=s.measureText(h);s.fillText(h,r,o),r+=c.width}else r-=n.engravingSettings.glyphWidths.get(u.MetNoteQuarterUp)/2;pt.fillMusicFontSymbolSafe(s,r,o,n.engravingSettings.tempoNoteScale,u.MetNoteQuarterUp),r+=this.renderer.smuflMetrics.glyphWidths.get(u.MetNoteQuarterUp)*n.engravingSettings.tempoNoteScale,s.fillText(` = ${i.value.toString()}`,r,o),s.textBaseline=l,r+=s.measureText(` = ${i.value.toString()}`).width}}}class Vd extends dt{get notationElement(){return C.EffectTempo}get hideOnMultiTrack(){return!0}get canShareBand(){return!1}get sizingMode(){return ke.SinglePreBeat}shouldCreateGlyph(e,t){return t.voice.bar.staff.index===0&&t.voice.index===0&&t.index===0&&t.voice.bar.masterBar.tempoAutomations.some(s=>s.isVisible)}createNewGlyph(e,t){return new Wd(t.voice.bar.masterBar.tempoAutomations.filter(s=>s.isVisible))}canExpand(e,t){return!0}}class Hd extends dt{get notationElement(){return C.EffectText}get hideOnMultiTrack(){return!1}get canShareBand(){return!1}get sizingMode(){return ke.SingleOnBeat}shouldCreateGlyph(e,t){return!!t.text}createNewGlyph(e,t){return new Es(0,0,t.text,e.resources.elementFonts.get(C.EffectText),Y.Left)}canExpand(e,t){return!0}}class Gd extends oa{constructor(e,t){super(ae.EndBeat),this.x=e,this.y=t}doLayout(){super.doLayout(),this.height=this.renderer.smuflMetrics.glyphHeights.get(u.OrnamentTrill)}paintGrouped(e,t,s,i){const r=this.renderer.smuflMetrics.glyphWidths.get(u.OrnamentTrill),o=e+this.x+r,l=this.renderer.smuflMetrics.repeatOffsetX.get(u.WiggleTrill),h=Math.ceil((s-o)/l),c=[u.OrnamentTrill];for(let d=0;d<h;d++)c.push(u.WiggleTrill);i.fillMusicFontSymbols(e+this.x-r/2,t+this.y+this.height,1,c,!1)}}class Pl extends rr{get notationElement(){return C.EffectTrill}shouldCreateGlyphForNote(e){return e.isTrill}get sizingMode(){return ke.GroupedOnBeatToEnd}createNewGlyph(e,t){return new Gd(0,0)}}var Tt;(function(a){a[a.EighthEighth=0]="EighthEighth",a[a.SixteenthSixteenth=1]="SixteenthSixteenth",a[a.QuarterTripletEighthTriplet=2]="QuarterTripletEighthTriplet",a[a.EighthSixteenthTriplet=3]="EighthSixteenthTriplet",a[a.EighthDottedSixteenth=4]="EighthDottedSixteenth",a[a.SixteenthDottedThirtySecond=5]="SixteenthDottedThirtySecond",a[a.SixteenthEighthDotted=6]="SixteenthEighthDotted",a[a.ThirtySecondSixteenthDotted=7]="ThirtySecondSixteenthDotted"})(Tt||(Tt={}));class Ud extends fs{_tripletFeel;_tupletHeight=0;_tupletPadding=0;constructor(e){super(0,0),this._tripletFeel=e}doLayout(){super.doLayout();const e=this.renderer.smuflMetrics.tempoNoteScale;this.height=this.renderer.smuflMetrics.glyphHeights.get(u.MetNoteQuarterUp)*e,this._tupletHeight=this.renderer.smuflMetrics.glyphHeights.get(u.Tuplet3)*e,this._tupletPadding=this.renderer.smuflMetrics.tripletFeelBracketPadding,this.height+=this._tupletHeight}
65paint(e,t,s){e+=this.x,t+=this.y;let i=Tt.EighthEighth,r=Tt.EighthEighth;switch(this._tripletFeel){case Ce.NoTripletFeel:i=Tt.EighthEighth,r=Tt.EighthEighth;break;case Ce.Triplet8th:i=Tt.EighthEighth,r=Tt.QuarterTripletEighthTriplet;break;case Ce.Triplet16th:i=Tt.SixteenthSixteenth,r=Tt.EighthSixteenthTriplet;break;case Ce.Dotted8th:i=Tt.EighthEighth,r=Tt.EighthDottedSixteenth;break;case Ce.Dotted16th:i=Tt.SixteenthSixteenth,r=Tt.SixteenthDottedThirtySecond;break;case Ce.Scottish8th:i=Tt.EighthEighth,r=Tt.SixteenthEighthDotted;break;case Ce.Scottish16th:i=Tt.SixteenthSixteenth,r=Tt.ThirtySecondSixteenthDotted;break}const n=this.renderer.smuflMetrics.tempoNoteScale,o=t+this.renderer.smuflMetrics.glyphTop.get(u.MetNoteQuarterUp)*n,l=t+this.height,h=s.textBaseline;s.textBaseline=He.Bottom,s.font=this.renderer.resources.elementFonts.get(C.EffectTripletFeel),s.fillText("(",e,l),e+=s.measureText("( ").width,e=this._drawGroup(e,o+this._tupletHeight,s,i),s.fillText(" = ",e,l),e+=s.measureText(" = ").width,e=this._drawGroup(e,o+this._tupletHeight,s,r),s.fillText(" )",e,l),s.textBaseline=h}_drawGroup(e,t,s,i){const r=this.renderer.smuflMetrics.tempoNoteScale;let n=[],o=[];const l=[];let h=u.None;switch(i){case Tt.EighthEighth:l.push(Y.Center),n=[u.MetNoteQuarterUp],o=[u.MetNoteQuarterUp];break;case Tt.SixteenthSixteenth:l.push(Y.Center),l.push(Y.Center),n=[u.MetNoteQuarterUp],o=[u.MetNoteQuarterUp];break;case Tt.QuarterTripletEighthTriplet:n=[u.MetNoteQuarterUp],o=[u.MetNote8thUp],h=u.Tuplet3;break;case Tt.EighthSixteenthTriplet:l.push(Y.Center),l.push(Y.Right),n=[u.MetNoteQuarterUp],o=[u.MetNoteQuarterUp],h=u.Tuplet3;break;case Tt.EighthDottedSixteenth:l.push(Y.Center),l.push(Y.Right),n=[u.MetNoteQuarterUp,u.Space,u.MetAugmentationDot],o=[u.MetNoteQuarterUp];break;case Tt.SixteenthDottedThirtySecond:l.push(Y.Center),l.push(Y.Center),l.push(Y.Right),n=[u.MetNoteQuarterUp,u.Space,u.MetAugmentationDot],o=[u.MetNoteQuarterUp];break;case Tt.SixteenthEighthDotted:l.push(Y.Center),l.push(Y.Left),n=[u.MetNoteQuarterUp],o=[u.MetNoteQuarterUp,u.Space,u.MetAugmentationDot];break;case Tt.ThirtySecondSixteenthDotted:l.push(Y.Center),l.push(Y.Center),l.push(Y.Left),n=[u.MetNoteQuarterUp],o=[u.MetNoteQuarterUp,u.Space,u.MetAugmentationDot];break}const c=this.renderer.smuflMetrics.glyphWidths.get(u.MetNoteQuarterUp)*r,d=e+c-this.renderer.smuflMetrics.stemThickness*r,f=d+c*2+this.renderer.smuflMetrics.stemThickness*r,p=this.renderer.smuflMetrics.tempoNoteScale*this.renderer.smuflMetrics.beamThickness,g=this.renderer.smuflMetrics.tempoNoteScale*this.renderer.smuflMetrics.beamSpacing,m=this.renderer.smuflMetrics.brokenBeamWidth*r;let b=t-this.renderer.smuflMetrics.glyphHeights.get(u.MetNoteQuarterUp)*r+p;if(h!==u.None){const v=(e+f)/2,W=b-this._tupletHeight-this._tupletPadding,j=this.renderer.smuflMetrics.glyphTop.get(h)*r,q=this.renderer.smuflMetrics.glyphWidths.get(h)*r;pt.fillMusicFontSymbolSafe(s,v,W+j,r,h,!0);const F=v-q/2-this._tupletPadding,Q=v+q/2+this._tupletPadding,me=this._tupletHeight/2,ge=s.lineWidth;s.beginPath(),s.moveTo(e,W+me+me),s.lineTo(e,W+me),s.lineTo(F,W+me),s.moveTo(Q,W+me),s.lineTo(f,W+me),s.lineTo(f,W+me+me),s.lineWidth=this.renderer.smuflMetrics.tupletBracketThickness*r,s.stroke(),s.lineWidth=ge}s.fillMusicFontSymbols(e,t,r,n,!1),e+=c,e+=c,s.fillMusicFontSymbols(e,t,r,o,!1),e+=c,(o[o.length-1]===u.MetAugmentationDot||o[0]===u.MetNote8thUp)&&(e+=c);for(const S of l){switch(S){case Y.Left:s.fillRect(d,b,m,p);break;case Y.Center:s.fillRect(d,b,f-d,p);break;case Y.Right:s.fillRect(f-m,b,m,p);break}b+=p+g}return e}}class zd extends dt{get notationElement(){return C.EffectTripletFeel}get hideOnMultiTrack(){return!0}get canShareBand(){return!1}get sizingMode(){return ke.SinglePreBeat}shouldCreateGlyph(e,t){return t.index===0&&(t.voice.bar.masterBar.index===0&&t.voice.bar.masterBar.tripletFeel!==Ce.NoTripletFeel||t.voice.bar.masterBar.index>0&&t.voice.bar.masterBar.tripletFeel!==t.voice.bar.masterBar.previousMasterBar.tripletFeel)}createNewGlyph(e,t){return new Ud(t.voice.bar.masterBar.tripletFeel)}canExpand(e,t){return!0}}class Ho extends Lt{constructor(e){super(0,0,1,Ho._getSymbol(e)),this.center=!0}static _getSymbol(e){switch(e){case ss.Open:return u.GuitarOpenPedal;case ss.Closed:return u.GuitarClosePedal}return u.None}
vendor: 13,598 bytes, line 65
65paint(e,t,s){super.paint(e,t+this.height,s)}}class Yd extends dt{get notationElement(){return C.EffectWahPedal}get hideOnMultiTrack(){return!1}get canShareBand(){return!0}get sizingMode(){return ke.SingleOnBeat}shouldCreateGlyph(e,t){return t.wahPedal!==ss.None}createNewGlyph(e,t){return new Ho(t.wahPedal)}canExpand(e,t){return!1}}class Xd extends dt{get notationElement(){return C.EffectWhammyBar}get hideOnMultiTrack(){return!1}get canShareBand(){return!1}get sizingMode(){return ke.GroupedOnBeat}shouldCreateGlyph(e,t){return t.hasWhammyBar}createNewGlyph(e,t){return new ir("w/bar",C.EffectWhammyBar)}canExpand(e,t){return!0}}class Cl extends dt{get notationElement(){return C.EffectWideBeatVibrato}get hideOnMultiTrack(){return!1}get canShareBand(){return!0}get sizingMode(){return ke.GroupedOnBeatToEnd}shouldCreateGlyph(e,t){return t.vibrato===Be.Wide}createNewGlyph(e,t){return new dh(0,0,Be.Wide)}canExpand(e,t){return!0}}class El extends rr{get notationElement(){return C.EffectWideNoteVibrato}shouldCreateGlyphForNote(e){return e.vibrato===Be.Wide||e.isTieDestination&&e.tieOrigin.vibrato===Be.Wide}get sizingMode(){return ke.GroupedOnBeatToEnd}createNewGlyph(e,t){return new Ri(0,0,Be.Wide)}}class vl extends js{_glyphWidth=0;_align;constructor(e,t,s=Y.Center){super(e,t),this.glyphs=[],this._align=s}doLayout(){const e=this.renderer.smuflMetrics.rowContainerGap,t=this._glyphWidth-e;let s=0;switch(this._align){case Y.Left:s=0;break;case Y.Center:s=(this.width-t)/2;break;case Y.Right:s=this.width-t;break}for(const i of this.glyphs)i.x=s,s+=i.width+e}addGlyphToRow(e){this.glyphs.push(e),this._glyphWidth+=e.width+this.renderer.smuflMetrics.rowContainerGap,e.height>this.height&&(this.height=e.height)}}class uh extends js{_rows=[];_align;constructor(e,t,s=Y.Center){super(e,t),this.height=0,this.glyphs=[],this._align=s}doLayout(){let e=0,t=0;const s=this.renderer.smuflMetrics.rowContainerGap;this._rows=[];let i=new vl(e,t,this._align);i.renderer=this.renderer,i.width=this.width;for(const r of this.glyphs){const n=e+r.width+s;n<this.width?(i.addGlyphToRow(r),e=Math.ceil(n)):(i.isEmpty||(i.doLayout(),this._rows.push(i),t+=i.height+s),e=0,i=new vl(e,t,this._align),i.renderer=this.renderer,i.width=this.width,i.addGlyphToRow(r),e+=Math.ceil(r.width+s))}i.isEmpty||(i.doLayout(),this._rows.push(i),t+=Math.ceil(i.height+this.renderer.smuflMetrics.rowContainerPadding)),this.height=t}paint(e,t,s){for(const i of this._rows)i.paint(e+this.x,t+this.y,s)}}class $d extends uh{addChord(e){if(e.strings.length>0){const t=new pr(0,0,e,C.ChordDiagrams);t.renderer=this.renderer,t.doLayout(),this.glyphs.push(t)}}paint(e,t,s){if(this.glyphs.length>0){const i=xe.score(s,H.ChordDiagramList,this.renderer.scoreRenderer.score);try{super.paint(e,t,s)}finally{i?.[Symbol.dispose]?.()}}}}class Jd extends uh{constructor(e,t){super(e,t,Y.Left)}}class qd extends js{_tuning;_trackLabel;colorOverride;constructor(e,t,s,i){super(e,t),this._tuning=s,this._trackLabel=i,this.glyphs=[]}doLayout(){if(!(this.glyphs.length>0)){this._createGlyphs(this._tuning);for(const e of this.glyphs)e.renderer=this.renderer,e.doLayout()}}paint(e,t,s){const i=s.color;this.colorOverride&&(s.color=this.colorOverride),super.paint(e,t,s),s.color=i}_createGlyphs(e){const t=this.renderer.resources;if(this.height=0,this._trackLabel.length>0){const n=new Es(0,this.height,this._trackLabel,t.elementFonts.get(C.GuitarTuning),Y.Left);n.renderer=this.renderer,n.doLayout(),this.height+=n.height,this.addGlyph(n)}if(e.name.length>0){const n=new Es(0,this.height,e.name,t.elementFonts.get(C.GuitarTuning),Y.Left);n.renderer=this.renderer,n.doLayout(),this.height+=n.height,this.addGlyph(n)}const s=this.renderer.smuflMetrics.tuningGlyphCircleNumberScale,i=this.renderer.smuflMetrics.glyphHeights.get(u.GuitarString0)*s;this.renderer.scoreRenderer.canvas.font=t.elementFonts.get(C.GuitarTuning);const r=(i+this.renderer.scoreRenderer.canvas.measureText(" = Gb").width)*t.engravingSettings.tuningGlyphStringColumnScale;if(this.width=Math.max(this.renderer.scoreRenderer.canvas.measureText(this._trackLabel).width,Math.max(this.renderer.scoreRenderer.canvas.measureText(e.name).width,2*r)),!e.isStandard){const n=Math.ceil(e.tunings.length/2)|0;let o=0;const l=this.height+this.renderer.smuflMetrics.tuningGlyphStringRowPadding;let h=l;for(let c=0,d=e.tunings.length;c<d;c++){const f=u.GuitarString0+(c+1);this.addGlyph(new Lt(o,h+i,s,f));const p=` = ${I.getTextForTuning(e.tunings[c],!1)}`;this.addGlyph(new Es(o+i,h+i/2,p,t.elementFonts.get(C.GuitarTuning),Y.Left,He.Middle)),h+=i+this.renderer.smuflMetrics.tuningGlyphStringRowPadding;const g=h;this.height<g&&(this.height=g),c===n-1&&(h=l,o+=r)}}}}class $r{_staffLookup=new Map;clear(){this._staffLookup.clear()}startMultiSystemSlur(e){const t=$r._staffId(e.renderer.staff);let s;this._staffLookup.has(t)?s=this._staffLookup.get(t):(s={startedSlurs:new Map},this._staffLookup.set(t,s)),s.startedSlurs.set(e.slurEffectId,{startGlyph:e})}static _staffId(e){return`${e.modelStaff.index}.${e.modelStaff.track.index}.${e.staffId}`}completeMultiSystemSlur(e){const t=$r._staffId(e.renderer.staff);if(!this._staffLookup.has(t))return;const s=this._staffLookup.get(t);if(s.startedSlurs.has(e.slurEffectId)){const i=s.startedSlurs.get(e.slurEffectId);return i.endGlyph=e,i.startGlyph}}*getAllContinuations(e){const t=$r._staffId(e.staff);if(!this._staffLookup.has(t)||e.index>0)return;const s=this._staffLookup.get(t);for(const i of s.startedSlurs.values())i.startGlyph.shouldCreateMultiSystemSlur(e)&&(yield i.startGlyph)}}class Qd{_factory;_sharedLayoutData=new Map;staffTrackGroup;system;barRenderers=[];x=0;y=0;height=0;index=0;staffIndex=0;isVisible=!1;_emptyBarCount=0;get isFirstInSystem(){return this.system.firstVisibleStaff===this}topEffectInfos=[];bottomEffectInfos=[];trackIndex=0;modelStaff;get staffId(){return this._factory.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(e,t,s,i){this._factory=i,this.trackIndex=t,this.modelStaff=s,this.system=e;for(const r of i.effectBands)if(!(r.shouldCreate&&!r.shouldCreate(s)))switch(r.mode){case ue.OwnedTop:case ue.SharedTop:this.topEffectInfos.push(r);break;case ue.OwnedBottom:case ue.SharedBottom:this.bottomEffectInfos.push(r);break}this._updateVisibility()}getSharedLayoutData(e,t){return this._sharedLayoutData.has(e)?this._sharedLayoutData.get(e):t}setSharedLayoutData(e,t){this._sharedLayoutData.set(e,t)}registerStaffTop(e){e>this.staffTop&&(this.staffTop=e)}registerStaffBottom(e){e>this.staffBottom&&(this.staffBottom=e)}addBarRenderer(e){e.staff=this,e.index=this.barRenderers.length,e.reLayout(),this.barRenderers.push(e),this.system.layout.registerBarRenderer(this.staffId,e),(e.bar.isEmpty||e.bar.isRestOnly)&&this._emptyBarCount++,this._updateVisibility()}_updateVisibility(){const e=this.modelStaff.track.score.stylesheet;e.hideEmptyStaves&&(e.hideEmptyStavesInFirstSystem||this.system.index>0)?this.isVisible=this._emptyBarCount<this.barRenderers.length:this.isVisible=!0}addBar(e,t,s){const i=this._factory.create(this.system.layout.renderer,e);i.topEffects.infos=this.topEffectInfos,i.bottomEffects.infos=this.bottomEffectInfos,i.additionalMultiRestBars=s,i.staff=this,i.index=this.barRenderers.length,i.layoutingInfo=t,i.doLayout(),this.barRenderers.push(i),this.system.layout.registerBarRenderer(this.staffId,i),(e.isEmpty||e.isRestOnly)&&this._emptyBarCount++,this._updateVisibility()}revertLastBar(){this.resetSharedLayoutData();const e=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(e.bar.isEmpty||e.bar.isRestOnly)&&this._emptyBarCount--,this._updateVisibility(),e}resetSharedLayoutData(){this._sharedLayoutData.clear()}topOverflow=0;registerOverflowTop(e){e>this.topOverflow&&(this.topOverflow=e)}bottomOverflow=0;registerOverflowBottom(e){e>this.bottomOverflow&&(this.bottomOverflow=e)}calculateHeightForAccolade(){this._applyStaffPaddings(),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))}_applyStaffPaddings(){const e=this.index===0,t=this.index===this.system.staves.length-1,s=this.system.layout.renderer.settings.display;this.topPadding=e?s.firstNotationStaffPaddingTop:s.notationStaffPaddingTop,this.bottomPadding=t?s.lastNotationStaffPaddingBottom:s.notationStaffPaddingBottom}finalizeStaff(){this._applyStaffPaddings(),this.height=0;let e=!1,t=this.topOverflow;for(const s of this.barRenderers)s.registerMultiSystemSlurs(this.system.layout.slurRegistry.getAllContinuations(s)),s.finalizeRenderer()&&(e=!0),this.height=Math.max(this.height,s.height);if(e){t=this.topOverflow;for(const s of this.barRenderers)s.y=this.topPadding+t;for(const s of this.barRenderers)s.finalizeRenderer()}this.height>0&&(this.height+=this.topPadding+t+this.bottomOverflow+this.bottomPadding),this.height=Math.ceil(this.height),this._updateVisibility()}paint(e,t,s,i,r){if(!(this.height===0||r===0))for(let n=i,o=Math.min(i+r,this.barRenderers.length);n<o;n++)this.barRenderers[n].paint(e+this.x,t+this.y,s)}}class Dl{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}class on{static _defaultMinDuration=30;static _defaultMinDurationWidth=7;_timeSortedSprings=[];_minTime=-1;_onTimePositionsForce=0;_onTimePositions=new Map;_incompleteGraceRodsWidth=0;_beatSizes=new Map;_minDuration=on._defaultMinDuration;version=0;preBeatSize=0;postBeatSize=0;minStretchForce=0;totalSpringConstant=0;_updateMinStretchForce(e){this.minStretchForce<e&&(this.minStretchForce=e)}getBeatSizes(e){const t=e.absoluteDisplayStart;if(this._beatSizes.has(t))return this._beatSizes.get(t)}setBeatSizes(e,t){const s=e.absoluteDisplayStart;if(this._beatSizes.has(s)){const i=this._beatSizes.get(s);i.onBeatSize<t.onBeatSize&&(i.onBeatSize=t.onBeatSize),i.preBeatSize<t.preBeatSize&&(i.preBeatSize=t.preBeatSize)}else this._beatSizes.set(s,t)}getPreBeatSize(e){if(e.graceType!==K.None){const s=e.graceGroup.id;return this.allGraceRods.get(s)[e.graceIndex].preBeatWidth}const t=e.absoluteDisplayStart;return this.springs.has(t)?this.springs.get(t).preBeatWidth:0}getPostBeatSize(e){if(e.graceType!==K.None){const s=e.graceGroup.id;return this.allGraceRods.get(s)[e.graceIndex].postSpringWidth}const t=e.absoluteDisplayStart;return this.springs.has(t)?this.springs.get(t).postSpringWidth:0}incompleteGraceRods=new Map;allGraceRods=new Map;springs=new Map;addSpring(e,t,s,i,r){this.version++;let n;if(this.springs.has(e))n=this.springs.get(e),n.postSpringWidth<r&&(n.postSpringWidth=r),n.graceBeatWidth<s&&(n.graceBeatWidth=s),n.preBeatWidth<i&&(n.preBeatWidth=i),t<n.smallestDuration&&(n.smallestDuration=t),t>n.longestDuration&&(n.longestDuration=t),n.allDurations.add(t);else{if(n=new Dl,n.timePosition=e,n.allDurations.add(t),this._timeSortedSprings.length>0){const h=this._timeSortedSprings[this._timeSortedSprings.length-1];for(const c of h.allDurations)h.timePosition+c;t<this._minDuration&&(this._minDuration=t)}n.longestDuration=t,n.postSpringWidth=r,n.graceBeatWidth=s,n.preBeatWidth=i,this.springs.set(e,n);const o=this._timeSortedSprings;let l=o.length-1;for(;l>0&&o[l].timePosition>e;)l--;this._timeSortedSprings.splice(l+1,0,n)}return(this._minTime===-1||this._minTime>e)&&(this._minTime=e),n}addBeatSpring(e,t,s){const i=e.absoluteDisplayStart;if(e.graceType!==K.None){const r=e.graceGroup.id;this.allGraceRods.has(r)||this.allGraceRods.set(r,new Array(e.graceGroup.beats.length)),!e.graceGroup.isComplete&&!this.incompleteGraceRods.has(r)&&this.incompleteGraceRods.set(r,new Array(e.graceGroup.beats.length));const n=this.allGraceRods.get(r)[e.graceIndex];if(n)n.postSpringWidth<s&&(n.postSpringWidth=s),n.preBeatWidth<t&&(n.preBeatWidth=t);else{const o=new Dl;o.timePosition=i,o.postSpringWidth=s,o.preBeatWidth=t,e.graceGroup.isComplete||(this.incompleteGraceRods.get(r)[e.graceIndex]=o),this.allGraceRods.get(r)[e.graceIndex]=o}}else{let r=0;if(e.graceGroup&&this.allGraceRods.has(e.graceGroup.id))for(const n of this.allGraceRods.get(e.graceGroup.id))r+=n.springWidth;this.addSpring(i,e.displayDuration,r,t,s)}}finish(){for(const[e,t]of this.allGraceRods){let s=0;for(const i of t)s+=i.preBeatWidth,i.graceBeatWidth=s,s+=i.postSpringWidth}this._incompleteGraceRodsWidth=0;for(const e of this.incompleteGraceRods.values())for(const t of e)this._incompleteGraceRodsWidth+=t.preBeatWidth+t.postSpringWidth;this._calculateSpringConstants(),this.version++}_calculateSpringConstants(){let e=0;const t=this._timeSortedSprings;if(t.length===0){this.totalSpringConstant=-1,this.minStretchForce=-1;return}for(let s=0;s<t.length;s++){const i=t[s];let r=0;if(s===t.length-1)r=i.longestDuration;else{const n=t[s+1];r=Math.abs(n.timePosition-i.timePosition)}i.springConstant=this._calculateSpringConstant(i,r),e+=1/i.springConstant}this.totalSpringConstant=1/e,this.minStretchForce=0;for(let s=0;s<t.length;s++){const i=t[s];let r=0;if(s===t.length-1)r=i.postSpringWidth;else{const o=t[s+1];r=i.postSpringWidth+o.preSpringWidth}s===0&&(r+=i.preSpringWidth);const n=r*i.springConstant;this._updateMinStretchForce(n)}}height=0;
65paint(e,t,s){}_calculateSpringConstant(e,t){t<=0&&(t=B.toTicks(y.TwoHundredFiftySixth)),e.smallestDuration===0&&(e.smallestDuration=t);const s=e.smallestDuration,i=this._minDuration,r=on._defaultMinDurationWidth,n=1+.85*Math.log2(t/i);return s/t*(1/(n*r))}spaceToForce(e){return this.totalSpringConstant!==-1?(this._timeSortedSprings.length>0&&(e-=this._timeSortedSprings[0].preSpringWidth),e-=this._incompleteGraceRodsWidth,Math.max(e,0)*this.totalSpringConstant):-1}calculateVoiceWidth(e){let t=0;return this.totalSpringConstant!==-1&&(t=this._calculateWidth(e,this.totalSpringConstant)),this._timeSortedSprings.length>0&&(t+=this._timeSortedSprings[0].preSpringWidth),t+=this._incompleteGraceRodsWidth,t}_calculateWidth(e,t){return e/t}buildOnTimePositions(e){if(this.totalSpringConstant===-1)return new Map;if(L.isAlmostEqualTo(this._onTimePositionsForce,e)&&this._onTimePositions)return this._onTimePositions;this._onTimePositionsForce=e;const t=new Map;this._onTimePositions=t;const s=this._timeSortedSprings;if(s.length===0)return t;let i=s[0].preSpringWidth;for(let r=0;r<s.length;r++)t.set(s[r].timePosition,i),i+=this._calculateWidth(e,s[r].springConstant);return t}}class Kd{width=0;isLinkedToPrevious=!1;canWrap=!0;masterBar;additionalMultiBarRestIndexes=null;get lastMasterBarIndex(){return this.additionalMultiBarRestIndexes?this.additionalMultiBarRestIndexes[this.additionalMultiBarRestIndexes.length-1]:this.masterBar.index}renderers=[];layoutingInfo}class Zd{track;staffSystem;staves=[];firstVisibleStaff;lastVisibleStaff;bracket=null;constructor(e,t){this.staffSystem=e,this.track=t}addStaff(e){this.staves.push(e)}}class jd{_system;firstStaffInBracket;lastStaffInBracket;firstVisibleStaffInBracket;lastVisibleStaffInBracket;drawAsBrace=!1;braceScale=1;width=0;index=0;canPaint=!1;constructor(e){this._system=e}updateCanPaint(){let e,t;for(let i=this.firstStaffInBracket.index;i<=this.lastStaffInBracket.index;i++){const r=this._system.allStaves[i];r.isVisible&&(e||(e=r),t=r)}if(this.firstVisibleStaffInBracket=e,this.lastVisibleStaffInBracket=t,!e||!t){this.canPaint=!1;return}if(!this._system.layout.renderer.score.stylesheet.showSingleStaffBrackets&&e===t){this.canPaint=!1;return}this.canPaint=!0}finalizeBracket(e){if(!this.canPaint){this.width=0;return}const t=e.glyphHeights.get(u.Brace),s=e.glyphWidths.get(u.Brace);if(this.drawAsBrace?this.width=s:this.width=e.bracketThickness,!this.drawAsBrace)return;const i=this.firstVisibleStaffInBracket.contentTop,o=(this.lastVisibleStaffInBracket.contentBottom-i)/t;this.braceScale=o,this.width=s*this.braceScale}}class Bn extends jd{track;constructor(e,t){super(e),this.track=t,this.drawAsBrace=Bn.isTrackDrawAsBrace(t)}includesStaff(e){return e.modelStaff.track===this.track}static isTrackDrawAsBrace(e){return e.staves.filter(t=>t.showStandardNotation).length>1}}class eu extends Bn{includesStaff(e){return e.modelStaff.track===this.track?!0:this.drawAsBrace?!1:this.track.playbackInfo.program===e.modelStaff.track.playbackInfo.program}}class tu{_accoladeSpacingCalculated=!1;_brackets=[];_staffToBracket=new Map;_contentHeight=0;_hasSystemSeparator=!1;x=0;y=0;index=0;accoladeWidth=0;isFull=!1;width=0;computedWidth=0;totalBarDisplayScale=0;isLast=!1;masterBarsRenderers=[];staves=[];layout;topPadding;bottomPadding;allStaves=[];firstVisibleStaff;constructor(e){this.layout=e,this.topPadding=e.renderer.settings.display.systemPaddingTop,this.bottomPadding=e.renderer.settings.display.systemPaddingBottom}get firstBarIndex(){return this.masterBarsRenderers[0].masterBar.index}get lastBarIndex(){return this.masterBarsRenderers[this.masterBarsRenderers.length-1].lastMasterBarIndex}addMasterBarRenderers(e,t){if(e.length===0)return null;this.masterBarsRenderers.push(t),t.layoutingInfo.preBeatSize=0;let s=0,i,r=!1;for(const n of this.staves){let o,l;for(const h of n.staves){const c=t.renderers[s++];h.addBarRenderer(c),h.isVisible&&(r=!0,o||(o=h),i||(i=h),l=h)}n.firstVisibleStaff=o,n.lastVisibleStaff=l,i||(i=o)}if(!r){const n=this.staves[0],o=n.staves[0];o.isVisible=!0,n.firstVisibleStaff=o,n.lastVisibleStaff=o,i=o}
65return this.firstVisibleStaff=i,this._calculateAccoladeSpacing(e),this._applyLayoutAndUpdateWidth(),t}addBars(e,t,s){const i=new Kd;i.additionalMultiBarRestIndexes=s,i.layoutingInfo=new on,i.masterBar=e[0].score.masterBars[t],this.masterBarsRenderers.push(i);let r,n=!1;const o=i.layoutingInfo;for(const l of this.staves){let h,c;for(const d of l.staves){const f=l.track.staves[d.modelStaff.index].bars[t],p=s==null?null:s.map(m=>l.track.staves[d.modelStaff.index].bars[m]);d.addBar(f,o,p),d.isVisible&&(n=!0,h||(h=d),c=d);const g=d.barRenderers[d.barRenderers.length-1];i.renderers.push(g),g.isLinkedToPrevious&&(i.isLinkedToPrevious=!0),g.canWrap||(i.canWrap=!1)}l.firstVisibleStaff=h,l.lastVisibleStaff=c,r||(r=h)}if(!n){const l=this.staves[0],h=l.staves[0];h.isVisible=!0,l.firstVisibleStaff=h,l.lastVisibleStaff=h,r=h}return this.firstVisibleStaff=r,this._calculateAccoladeSpacing(e),o.finish(),i.width=this._applyLayoutAndUpdateWidth(),i}getBarDisplayScale(e){return this.staves.length>1?e.bar.masterBar.displayScale:e.bar.displayScale}revertLastBar(){if(this.masterBarsRenderers.length>1){const e=this.masterBarsRenderers[this.masterBarsRenderers.length-1];this.masterBarsRenderers.splice(this.masterBarsRenderers.length-1,1);let t=0,s=0,i;for(const r of this.staves){let n,o;for(const l of r.staves){const h=l.revertLastBar(),c=h.computedWidth;c>t&&(t=c),h.afterReverted(),s=this.getBarDisplayScale(h),l.isVisible&&(n||(n=l),o=l)}r.firstVisibleStaff=n,r.lastVisibleStaff=o,i||(i=n)}return this.firstVisibleStaff=i,this.width-=t,this.computedWidth-=t,this.totalBarDisplayScale-=s,e}return null}_applyLayoutAndUpdateWidth(){let e=0,t=0;for(const s of this.allStaves){const i=s.barRenderers[s.barRenderers.length-1];i.applyLayoutingInfo(),t=this.getBarDisplayScale(i),i.computedWidth>e&&(e=i.computedWidth)}return this.totalBarDisplayScale+=t,this.width+=e,this.computedWidth+=e,e}_calculateAccoladeSpacing(e){const t=this.layout.renderer.settings;if(this._accoladeSpacingCalculated)for(const s of this._brackets)s.updateCanPaint(),s.finalizeBracket(t.display.resources.engravingSettings);else{this._accoladeSpacingCalculated=!0,this.accoladeWidth=0;const s=this.layout.renderer.score.stylesheet;if(this.layout.renderer.settings.notation.isNotationElementVisible(C.TrackNames)){const o=this.layout.renderer.tracks.length===1?s.singleTrackTrackNamePolicy:s.multiTrackTrackNamePolicy,l=this.index===0?s.firstSystemTrackNameMode:s.otherSystemsTrackNameMode,h=this.index===0?s.firstSystemTrackNameOrientation:s.otherSystemsTrackNameOrientation;let c=!1;switch(o){case mt.Hidden:break;case mt.FirstSystem:c=this.index===0;break;case mt.AllSystems:c=!0;break}let d=!1;if(c){const f=this.layout.renderer.canvas,p=t.display.resources.elementFonts.get(C.TrackNames);f.font=p;for(const g of e){let m="";switch(l){case Qt.FullName:m=g.name;break;case Qt.ShortName:m=g.shortName;break}if(m.length>0){d=!0;const b=f.measureText(m);switch(h){case Kt.Horizontal:this.accoladeWidth=Math.ceil(Math.max(this.accoladeWidth,b.width));break;case Kt.Vertical:this.accoladeWidth=Math.ceil(Math.max(this.accoladeWidth,b.height));break}}}this.accoladeWidth+=t.display.systemLabelPaddingLeft,d&&(this.accoladeWidth+=t.display.systemLabelPaddingRight)}}let r=0;for(const o of this.allStaves)o.y=r,o.calculateHeightForAccolade(),r+=o.height;let n=0;for(const o of this._brackets)o.updateCanPaint(),o.finalizeBracket(t.display.resources.engravingSettings),n=Math.max(n,o.width);this.accoladeWidth+=n,this.width+=this.accoladeWidth,this.computedWidth+=this.accoladeWidth}}_getStaffTrackGroup(e){for(let t=0,s=this.staves.length;t<s;t++){const i=this.staves[t];if(i.track===e)return i}return null}addStaff(e){const t=e.modelStaff.track;let s=this._getStaffTrackGroup(t);s||(s=new Zd(this,t),this.staves.push(s)),e.staffTrackGroup=s,e.system=this,e.index=this.allStaves.length,this.allStaves.push(e),s.addStaff(e);let i=this._brackets.find(r=>r.includesStaff(e));if(!i)switch(t.score.stylesheet.bracketExtendMode){case Fi.NoBrackets:break;case Fi.GroupStaves:i=new Bn(this,t),i.index=this._brackets.length,this._brackets.push(i);break;case Fi.GroupSimilarInstruments:i=new eu(this,t),i.index=this._brackets.length,this._brackets.push(i);break}i&&(i.firstStaffInBracket||(i.firstStaffInBracket=e),i.lastStaffInBracket=e,s.bracket=i,this._staffToBracket.set(e,i))}get height(){return Math.ceil(this._contentHeight+this.topPadding+this.bottomPadding)}
65paint(e,t,s){if(this.paintPartial(e+this.x,t+this.y+this.topPadding,s,0,this.masterBarsRenderers.length),this._hasSystemSeparator){const i=xe.track(s,$s.SystemSeparator,this.allStaves[0].modelStaff.track);try{const r=this.layout.renderer.settings.display.resources.engravingSettings,n=Math.min(0,r.glyphBottom.get(u.SystemDivider)??0);pt.fillMusicFontSymbolSafe(s,e+this.x,t+this.y+this.height+n,1,u.SystemDivider,!1),pt.fillMusicFontSymbolSafe(s,e+this.x+this.width-r.glyphWidths.get(u.SystemDivider),t+this.y+this.height+n,1,u.SystemDivider,!1)}finally{i?.[Symbol.dispose]?.()}}}paintPartial(e,t,s,i,r){for(const o of this.allStaves)o.isVisible&&o.paint(e,t,s,i,r);const n=this.layout.renderer.settings.display.resources;if(this.staves.length>0&&i===0){s.color=n.barSeparatorColor;const o=this.layout.renderer.settings,l=this.layout.renderer.settings.notation.isNotationElementVisible(C.TrackNames);if(s.font=n.elementFonts.get(C.TrackNames),l){const c=this.layout.renderer.score.stylesheet,d=this.layout.renderer.tracks.length===1?c.singleTrackTrackNamePolicy:c.multiTrackTrackNamePolicy,f=this.index===0?c.firstSystemTrackNameMode:c.otherSystemsTrackNameMode,p=this.index===0?c.firstSystemTrackNameOrientation:c.otherSystemsTrackNameOrientation;let g=!1;switch(d){case mt.Hidden:break;case mt.FirstSystem:g=this.index===0;break;case mt.AllSystems:g=!0;break}if(g){const m=s.textBaseline,b=s.textAlign;for(const S of this.staves)if(S.firstVisibleStaff){const N=t+S.firstVisibleStaff.contentTop,v=t+S.lastVisibleStaff.contentBottom;let W="";switch(f){case Qt.FullName:W=S.track.name;break;case Qt.ShortName:W=S.track.shortName;break}const j=xe.track(s,$s.TrackName,S.track);try{if(W.length>0){const q=e+S.staves[0].x-o.display.accoladeBarPaddingRight-(S.bracket?.width??0)-o.display.systemLabelPaddingRight;switch(p){case Kt.Horizontal:s.textBaseline=He.Middle,s.textAlign=Y.Right,s.fillText(W,q,(N+v)/2);break;case Kt.Vertical:s.textBaseline=He.Bottom,s.textAlign=Y.Center,s.beginRotate(q,(N+v)/2,-90-.1),s.fillText(W,0,0),s.endRotate();break}}}finally{j?.[Symbol.dispose]?.()}}s.textBaseline=m,s.textAlign=b}}const h=!this.layout.renderer.score.stylesheet.extendBarLines;if(this.allStaves.length>0&&h){let c=null;for(const d of this.allStaves)if(d.isVisible){if(c!==null){const f=c.contentBottom,p=d.contentTop,g=e+c.x,m=c.barRenderers[0],b=xe.bar(s,m.staffLineBarSubElement,m.bar);try{const S=Math.ceil(p-f);s.fillRect(g,t+f,n.engravingSettings.thinBarlineThickness,S)}finally{b?.[Symbol.dispose]?.()}}c=d}}this._paintBrackets(e,t,s)}}_paintBrackets(e,t,s){const i=this.layout.renderer.settings;for(const r of this._brackets)if(r.canPaint){const n=e+r.firstVisibleStaffInBracket.x,o=r.width,l=i.display.accoladeBarPaddingRight,h=t+r.firstVisibleStaffInBracket.contentTop,c=t+r.lastVisibleStaffInBracket.contentBottom;let d=h,f=c;if(r.drawAsBrace)pt.fillMusicFontSymbolSafe(s,n-l-o,f,r.braceScale,u.Brace);else if(r.firstVisibleStaffInBracket!==r.lastVisibleStaffInBracket){const g=i.display.resources.engravingSettings.oneStaffSpace*.25;d-=g,f+=g;const m=3;s.fillRect(n-l-o,d-m,o,Math.ceil(f-d+m*2));const b=n-l-o;pt.fillMusicFontSymbolSafe(s,b,d,1,u.BracketTop),pt.fillMusicFontSymbolSafe(s,b,Math.floor(f),1,u.BracketBottom)}}}finalizeSystem(){const e=this.layout.renderer.settings;if(this.index===0&&(this.topPadding=e.display.firstSystemPaddingTop),this.isLast)this.bottomPadding=e.display.lastSystemPaddingBottom;else if(this.layout.renderer.score.stylesheet.useSystemSignSeparator&&this.layout.renderer.tracks.length>1){const s=e.display.resources.engravingSettings.glyphHeights.get(u.SystemDivider);this.bottomPadding=Math.max(this.bottomPadding,s),this._hasSystemSeparator=!0}if(!this._finalizeTrackGroups()){const i=this.staves[0].staves[0];i.isVisible=!0,this._finalizeTrackGroups(!0)}for(const s of this._brackets)s.finalizeBracket(e.display.resources.engravingSettings)}_finalizeTrackGroups(e=!1){let t=0;const s=this.layout.renderer.settings,i=s.display.resources.engravingSettings,r=i.glyphHeights.get(u.BracketTop),n=i.glyphHeights.get(u.BracketBottom);let o,l=0,h=!1;for(const c of this.staves){let d,f;for(const p of c.staves){o!==void 0&&o.trackIndex!==p.trackIndex&&(t+=s.display.trackStaffPaddingBetween);const g=this._staffToBracket.has(p)?this._staffToBracket.get(p):void 0,m=g&&!g.drawAsBrace&&g.canPaint;if(m&&g.firstStaffInBracket===p){const b=r-p.topOverflow;b>0&&(t+=b)}if(p.x=this.accoladeWidth,p.y=t,e||p.finalizeStaff(),p.isVisible&&(t+=p.height,h=!0,o=p,d||(d=p),f=p),l=0,m&&g.lastStaffInBracket===p){const b=n-p.bottomOverflow;b>0&&(p.isVisible?t+=b:l=b)}}
65if(c.firstVisibleStaff=d,c.lastVisibleStaff=f,this.firstVisibleStaff||(this.firstVisibleStaff=d),e)break}return l&&(t+=l),this._contentHeight=t,h}buildBoundingsLookup(e,t){if(this.layout.renderer.boundsLookup.isFinished)return;const s=this.allStaves[0],i=this.allStaves[this.allStaves.length-1];t+=this.topPadding;const r=t+this.y+s.y,o=t+this.y+i.y+i.height-r,l=t+this.y,c=t+this.y+this.height-l,d=t+this.y+s.y+s.topPadding+s.topOverflow,p=t+this.y+i.y+i.height-i.bottomPadding-i.bottomOverflow-d,g=this.x+s.x,m=new Do;m.visualBounds=new bt,m.visualBounds.x=e+this.x,m.visualBounds.y=t+this.y,m.visualBounds.w=this.width,m.visualBounds.h=this.height-this.topPadding-this.bottomPadding,m.realBounds=new bt,m.realBounds.x=e+this.x,m.realBounds.y=t+this.y,m.realBounds.w=this.width,m.realBounds.h=this.height,this.layout.renderer.boundsLookup.addStaffSystem(m);const b=new Map;for(let S=0;S<this.staves.length;S++)for(const N of this.staves[S].staves)if(N.isVisible)for(const v of N.barRenderers){let W;b.has(v.bar.masterBar.index)?W=b.get(v.bar.masterBar.index):(W=new vo,W.index=v.bar.masterBar.index,W.isFirstOfLine=v.isFirstOfStaff,W.realBounds=new bt,W.realBounds.x=g+v.x,W.realBounds.y=l,W.realBounds.w=v.width,W.realBounds.h=c,W.visualBounds=new bt,W.visualBounds.x=g+v.x,W.visualBounds.y=r,W.visualBounds.w=v.width,W.visualBounds.h=o,W.lineAlignedBounds=new bt,W.lineAlignedBounds.x=g+v.x,W.lineAlignedBounds.y=d,W.lineAlignedBounds.w=v.width,W.lineAlignedBounds.h=p,this.layout.renderer.boundsLookup.addMasterBar(W),b.set(W.index,W)),v.buildBoundingsLookup(W,g,t+this.y+N.y)}}getBarX(e){if(this.allStaves.length===0||this.layout.renderer.tracks.length===0)return 0;const t=this.layout.renderer.tracks[0].staves[0].bars[e];return this.layout.getRendererForBar(this.allStaves[0].staffId,t).x}}class su{args;renderCallback;constructor(e,t){this.args=e,this.renderCallback=t}}class Qi{_barRendererLookup=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(e){this.renderer=e}slurRegistry=new $r;beamingRuleLookups=new Map;resize(){this._lazyPartials.clear(),this.slurRegistry.clear(),this.doResize()}layoutAndRender(e){this._lazyPartials.clear(),this.slurRegistry.clear(),this.beamingRuleLookups.clear(),this._barRendererLookup.clear(),this.profile=M.staveProfiles.get(this.renderer.settings.display.staveProfile);const t=this.renderer.score;this.firstBarIndex=L.computeFirstDisplayedBarIndex(t,this.renderer.settings),this.lastBarIndex=L.computeLastDisplayedBarIndex(t,this.renderer.settings,this.firstBarIndex),this.multiBarRestInfo=L.buildMultiBarRestInfo(this.renderer.tracks,this.firstBarIndex,this.lastBarIndex),this.pagePadding=this.renderer.settings.display.padding.map(s=>s/this.renderer.settings.display.scale),this.pagePadding||(this.pagePadding=[0,0,0,0]),this.pagePadding.length===1?this.pagePadding=[this.pagePadding[0],this.pagePadding[0],this.pagePadding[0],this.pagePadding[0]]:this.pagePadding.length===2&&(this.pagePadding=[this.pagePadding[0],this.pagePadding[1],this.pagePadding[0],this.pagePadding[1]]),this._createScoreInfoGlyphs(),this.doLayoutAndRender(e)}_lazyPartials=new Map;registerPartial(e,t){if(e.height===0)return;const s=this.renderer.settings.display.scale;e.x*=s,e.y*=s,e.width*=s,e.height*=s,e.totalWidth*=s,e.totalHeight*=s,this.renderer.settings.core.enableLazyLoading?(this._lazyPartials.set(e.id,new su(e,t)),this.renderer.partialLayoutFinished.trigger(e)):(this.renderer.partialLayoutFinished.trigger(e),this._internalRenderLazyPartial(e,t))}_internalRenderLazyPartial(e,t){const s=this.renderer.canvas;s.beginRender(e.width,e.height),t(s),e.renderResult=s.endRender(),this.renderer.partialRenderFinished.trigger(e)}renderLazyPartial(e){if(this._lazyPartials.has(e)){const t=this._lazyPartials.get(e);this._internalRenderLazyPartial(t.args,t.renderCallback)}}static headerElements=new mr(()=>new Map([[H.Title,C.ScoreTitle],[H.SubTitle,C.ScoreSubTitle],[H.Artist,C.ScoreArtist],[H.Album,C.ScoreAlbum],[H.Words,C.ScoreWords],[H.Music,C.ScoreMusic],[H.WordsAndMusic,C.ScoreWordsAndMusic],[H.Transcriber,void 0]]));static footerElements=new mr(()=>new Map([[H.Copyright,C.ScoreCopyright],[H.CopyrightSecondLine,void 0]]));_createHeaderFooterGlyph(e,t,s,i){switch(s){case H.WordsAndMusic:if(t.words!==t.music)return;break;case H.Words:case H.Music:if(t.words===t.music)return;break;case H.CopyrightSecondLine:if(!this.footerGlyphs.has(H.Copyright))return;break}const r=e.display.resources,n=e.notation,l=t.style&&t.style.headerAndFooter.has(s)?t.style.headerAndFooter.get(s):Mi.defaultHeaderAndFooter.get(s);let h=l.isVisible!==void 0?l.isVisible:!0;if(i!==void 0&&(h=n.isNotationElementVisible(i)),!h)return;const c=l.buildText(t);if(c)return new Es(0,0,c,r.getFontForElement(s),l.textAlign,void 0,xe.scoreColor(r,s,t))}_createScoreInfoGlyphs(){E.debug("ScoreLayout","Creating score info glyphs");const e=this.renderer.settings,t=this.renderer.score;this.headerGlyphs=new Map,this.footerGlyphs=new Map;const s=new zn(this.renderer,this.renderer.tracks[0].staves[0].bars[0]);for(const[n,o]of Qi.headerElements.value){const l=this._createHeaderFooterGlyph(e,t,n,o);l&&(l.renderer=s,l.doLayout(),this.headerGlyphs.set(n,l))}for(const[n,o]of Qi.footerElements.value){const l=this._createHeaderFooterGlyph(e,t,n,o);l&&(l.renderer=s,l.doLayout(),this.footerGlyphs.set(n,l))}const i=e.notation,r=e.display.resources;if(i.isNotationElementVisible(C.GuitarTuning)){const n=[];for(const o of this.renderer.tracks)for(const l of o.staves){let h=!l.isPercussion&&l.isStringed&&l.tuning.length>0&&l.showTablature;if(t.stylesheet.perTrackDisplayTuning&&t.stylesheet.perTrackDisplayTuning.has(o.index)&&t.stylesheet.perTrackDisplayTuning.get(o.index)===!1&&(h=!1),h){n.push(l);break}}if(n.length>0&&t.stylesheet.globalDisplayTuning){this.tuningGlyph=new Jd(0,0),this.tuningGlyph.renderer=s;
vendor: 25,957 bytes, line 65
65for(const o of n)if(o.stringTuning.tunings.length>0){const l=n.length>1?o.track.name:"",h=new qd(0,0,o.stringTuning,l);h.colorOverride=xe.trackColor(r,$s.StringTuning,o.track),h.renderer=s,h.doLayout(),this.tuningGlyph.addGlyph(h)}}else this.tuningGlyph=null}if(i.isNotationElementVisible(C.ChordDiagrams)){this.chordDiagrams=new $d(0,0),this.chordDiagrams.renderer=s;const n=new Set;for(const o of this.renderer.tracks)if(t.stylesheet.globalDisplayChordDiagramsOnTop&&(t.stylesheet.perTrackChordDiagramsOnTop==null||!t.stylesheet.perTrackChordDiagramsOnTop.has(o.index)||t.stylesheet.perTrackChordDiagramsOnTop.get(o.index)))for(const h of o.staves){const c=h.chords;if(c)for(const[,d]of c)n.has(d.uniqueId)||d.showDiagram&&(n.add(d.uniqueId),this.chordDiagrams.addChord(d))}this.chordDiagrams.isEmpty&&(this.chordDiagrams=null)}else this.chordDiagrams=null}firstBarIndex=0;lastBarIndex=0;createEmptyStaffSystem(e){const t=new tu(this);t.index=e;const s=M.defaultRenderers,i=[];for(let r=0;r<this.renderer.tracks.length;r++){const n=this.renderer.tracks[r];for(let o=0;o<n.staves.length;o++){const l=n.staves[o];let h=[],c=[],d;for(const f of s)if(this.profile.has(f.staffId)&&f.canCreate(n,l)){const p=new Qd(t,r,l,f);p.topEffectInfos.splice(0,0,...h),p.bottomEffectInfos.push(...c),d=p,i.push(p),h=[],c=[]}else for(const p of f.effectBands)switch(p.mode){case ue.SharedTop:h.push(p);break;case ue.SharedBottom:c.push(p);break}d&&(h.length>0&&d.bottomEffectInfos.push(...h),c.length>0&&d.bottomEffectInfos.push(...c))}}for(const r of i)t.addStaff(r);return t}registerBarRenderer(e,t){if(this._barRendererLookup.has(e)||this._barRendererLookup.set(e,new Map),this._barRendererLookup.get(e).set(t.bar.id,t),t.additionalMultiRestBars)for(const s of t.additionalMultiRestBars)this._barRendererLookup.get(e).set(s.id,t)}getRendererForBar(e,t){const s=t.id;return this._barRendererLookup.has(e)&&this._barRendererLookup.get(e).has(s)?this._barRendererLookup.get(e).get(s):null}layoutAndRenderBottomScoreInfo(e){e=Math.round(e);const t=new Si;t.x=0,t.y=e;let s=0;const i=this.renderer.settings.display.resources,r=[];let n=0;for(const[o,l]of Qi.footerElements.value)if(this.footerGlyphs.has(o)){const h=this.footerGlyphs.get(o);h.y=s,this.alignScoreInfoGlyph(h),s+=h.height,r.push(h),n=Math.max(n,Math.round(h.x+h.width))}return s=Math.round(s),r.length>0&&(t.width=n,t.height=s,t.totalWidth=this.scaledWidth,t.totalHeight=e+t.height,this.registerPartial(t,o=>{o.color=i.scoreInfoColor,o.textAlign=Y.Left,o.textBaseline=He.Top;for(const l of r)l.paint(0,0,o)})),e+s}alignScoreInfoGlyph(e){if(M.getLayoutEngineFactory(this.renderer.settings.display.layoutMode).vertical)switch(e.textAlign){case Y.Left:e.x=this.pagePadding[0];break;case Y.Center:e.x=this.scaledWidth/2;break;case Y.Right:e.x=this.scaledWidth-this.pagePadding[2];break}else e.x=this.firstBarX,e.textAlign=Y.Left}layoutAndRenderAnnotation(e){const t="rendered by alphaTab",s=this.renderer.settings.display.resources,i=12,r=s.elementFonts.has(C.ScoreCopyright)?s.elementFonts.get(C.ScoreCopyright).families:s.tablatureFont.families,n=ze.withFamilyList(r,i,je.Plain,rs.Bold),o=new zn(this.renderer,this.renderer.tracks[0].staves[0].bars[0]),l=new Es(0,0,t,n,Y.Center,void 0,s.mainGlyphColor);l.renderer=o,l.doLayout(),this.alignScoreInfoGlyph(l);const h=new Si;return h.width=l.x+l.width,h.x=0,h.height=i,h.y=e,h.totalWidth=this.scaledWidth,h.totalHeight=e+i,h.firstMasterBarIndex=-1,h.lastMasterBarIndex=-1,this.registerPartial(h,c=>{c.color=s.mainGlyphColor,c.font=n,c.textAlign=Y.Left,c.textBaseline=He.Top,l.paint(0,0,c)}),e+i}}class Ll{x=0;width=0;masterBars=[];results=[]}class iu extends Qi{_system=null;get name(){return"HorizontalScreen"}get supportsResize(){return!1}get firstBarX(){let e=this.pagePadding[0];return this._system&&(e+=this._system.accoladeWidth),e}doResize(){}doLayoutAndRender(e){const t=this.renderer.score;let s=this.renderer.settings.display.startBar;s--,s=Math.min(t.masterBars.length-1,Math.max(0,s));let i=s,r=this.renderer.settings.display.barCount;r<=0&&(r=t.masterBars.length),r=s+r-1,r=Math.min(t.masterBars.length-1,Math.max(0,r)),this._system=this.createEmptyStaffSystem(0),this._system.isLast=!0,this._system.x=this.pagePadding[0],this._system.y=this.pagePadding[1];const n=this.renderer.settings.display.barCountPerPartial,o=[];let l=new Ll;for(;i<=r;){const c=this.multiBarRestInfo,d=c!==null&&c.has(i)?c.get(i):null,f=this._system.addBars(this.renderer.tracks,i,d);l.masterBars.length>=n&&!f.isLinkedToPrevious&&(l=this._completePartial(o,l)),this._scaleBars(f),l.results.push(f),l.masterBars.push(t.masterBars[i]),l.width+=f.width,i++}l.masterBars.length>0&&this._completePartial(o,l),this._finalizeStaffSystem(),this.height=Math.floor(this._system.y+this._system.height),this.width=this._system.x+this._system.width+this.pagePadding[2],i=0;let h=0;for(let c=0;c<o.length;c++){const d=o[c],f=new Si;f.reuseViewport=e?.reuseViewport??!1,f.x=h,f.y=0,f.totalWidth=this.width,f.totalHeight=this.height,f.width=d.width,f.height=this.height,f.firstMasterBarIndex=d.masterBars[0].index,f.lastMasterBarIndex=d.masterBars[d.masterBars.length-1].index,h+=d.width;const p=i,g=c;this._system.buildBoundingsLookup(0,0),this.registerPartial(f,m=>{let b=this._system.getBarX(d.masterBars[0].index)+this._system.accoladeWidth;g===0&&(b-=this._system.x+this._system.accoladeWidth),m.color=this.renderer.settings.display.resources.mainGlyphColor,m.textAlign=Y.Left,E.debug(this.name,`Rendering partial from bar ${d.masterBars[0].index} to ${d.masterBars[d.masterBars.length-1].index}`,null),this._system.paintPartial(-b,this._system.y,m,p,d.masterBars.length)}),i+=d.masterBars.length}this.height=this.layoutAndRenderBottomScoreInfo(this.height),this.height=this.layoutAndRenderAnnotation(this.height),this.height+=this.pagePadding[3],this.height*=this.renderer.settings.display.scale}_scaleBars(e){e.width=0,this._system.width-=e.width;for(const t of e.renderers){const s=t.staff.system.staves.length>1?t.bar.masterBar.displayWidth:t.bar.displayWidth;s>0&&t.scaleToWidth(s);const i=t.x+t.width;i>e.width&&(e.width=i)}this._system.width+=e.width}_completePartial(e,t){e.length===0&&(t.width+=this._system.accoladeWidth+this.pagePadding[0]),e.push(t),E.debug(this.name,`Finished partial from bar ${t.masterBars[0].index} to ${t.masterBars[t.masterBars.length-1].index}`,null);const s=new Ll;return s.x=t.x+t.width,s}_finalizeStaffSystem(){this._alignRenderers(),this._system.finalizeSystem()}_alignRenderers(){this.width=0;const e=this._system;for(const t of e.allStaves){t.resetSharedLayoutData();let s=0;for(const i of t.barRenderers)i.x=s,i.y=t.topPadding+t.topOverflow,i.scaleToWidth(i.width),s+=i.width;s>this.width&&(e.width=s)}e.width+=e.accoladeWidth}}class fh extends Qi{_systems=[];_allMasterBarRenderers=[];_barsFromPreviousSystem=[];_reuseViewPort=!1;doLayoutAndRender(e){let t=this.pagePadding[1];this.width=this.renderer.width,this._allMasterBarRenderers=[],this._reuseViewPort=e?.reuseViewport??!1,t=this._layoutAndRenderScoreInfo(t,-1),t=this._layoutAndRenderTunings(t,-1),t=this._layoutAndRenderChordDiagrams(t,-1),t=this._layoutAndRenderScore(t),t=this.layoutAndRenderBottomScoreInfo(t),t=this.layoutAndRenderAnnotation(t),this.height=(t+this.pagePadding[3])*this.renderer.settings.display.scale}registerPartial(e,t){e.reuseViewport=this._reuseViewPort,super.registerPartial(e,t)}get supportsResize(){return!0}get firstBarX(){let e=this.pagePadding[0];return this._systems.length>0&&(e+=this._systems[0].accoladeWidth),e}doResize(){let e=this.pagePadding[1];this.width=this.renderer.width;const t=this.height;this._reuseViewPort=!0,e=this._layoutAndRenderScoreInfo(e,t),e=this._layoutAndRenderTunings(e,t),e=this._layoutAndRenderChordDiagrams(e,t),e=this._resizeAndRenderScore(e,t),e=this.layoutAndRenderBottomScoreInfo(e),e=this.layoutAndRenderAnnotation(e),this.height=(e+this.pagePadding[3])*this.renderer.settings.display.scale}_layoutAndRenderTunings(e,t=-1){if(!this.tuningGlyph)return e;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),r=new Si;return r.x=0,r.y=e,r.width=this.scaledWidth,r.height=i,r.totalWidth=this.scaledWidth,r.totalHeight=t<0?e+r.height:t,this.registerPartial(r,n=>{n.color=s.scoreInfoColor,n.textAlign=Y.Center,this.tuningGlyph.paint(0,0,n)}),e+i}_layoutAndRenderChordDiagrams(e,t=-1){if(!this.chordDiagrams)return e;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),r=new Si;return r.x=0,r.y=e,r.width=this.scaledWidth,r.height=i,r.totalWidth=this.scaledWidth,r.totalHeight=t<0?e+i:t,this.registerPartial(r,n=>{n.color=s.scoreInfoColor,n.textAlign=Y.Center,this.chordDiagrams.paint(0,0,n)}),e+i}_layoutAndRenderScoreInfo(e,t=-1){E.debug(this.name,"Layouting score info");const s=new Si;s.x=0,s.y=e;let i=0;const r=this.renderer.settings.display.resources,n=[];for(const[o,l]of Qi.headerElements.value)if(this.headerGlyphs.has(o)){const h=this.headerGlyphs.get(o);h.y=i,this.alignScoreInfoGlyph(h);let c=h.font.size;o===H.Words&&this.headerGlyphs.has(H.Music)&&this.headerGlyphs.get(H.Music).textAlign!==h.textAlign&&(c=0),i+=c,n.push(h)}return n.length>0&&(i=Math.floor(i+17),s.width=this.scaledWidth,s.height=i,s.totalWidth=this.scaledWidth,s.totalHeight=t<0?e+s.height:t,this.registerPartial(s,o=>{o.color=r.scoreInfoColor,o.textAlign=Y.Center;for(const l of n)l.paint(0,0,o)})),e+i}_resizeAndRenderScore(e,t){if(this.getBarsPerSystem(0)>0)for(let i=0;i<this._systems.length;i++){const r=this._systems[i];r.width=r.computedWidth,this._fitSystem(r),e+=this._paintSystem(r,t)}else{for(const o of this._allMasterBarRenderers)for(const l of o.renderers)l.afterReverted();this._systems=[];let i=0;const r=this._maxWidth;let n=this.createEmptyStaffSystem(this._systems.length);for(n.x=this.pagePadding[0],n.y=e;i<this._allMasterBarRenderers.length;){let o=this._allMasterBarRenderers[i];if(n.width+o.width<=r||n.masterBarsRenderers.length===0)n.addMasterBarRenderers(this.renderer.tracks,o),i++,this._needsLineBreak(i)&&(n.isFull=!0);else{for(;o&&!o.canWrap&&n.masterBarsRenderers.length>1;)o=n.revertLastBar(),i--;n.isFull=!0}n.isFull&&(n.isLast=this.lastBarIndex===n.lastBarIndex,this._systems.push(n),this._fitSystem(n),e+=this._paintSystem(n,t),n=this.createEmptyStaffSystem(this._systems.length),n.x=this.pagePadding[0],n.y=e)}n.isLast=this.lastBarIndex===n.lastBarIndex,this._fitSystem(n),e+=this._paintSystem(n,t)}return e}_layoutAndRenderScore(e){let s=this.firstBarIndex;const i=this.lastBarIndex;for(this._systems=[];s<=i;){const r=this._createStaffSystem(s,i);this._systems.push(r),r.x=this.pagePadding[0],r.y=e,s=r.lastBarIndex+1,this._fitSystem(r),E.debug(this.name,`Rendering partial from bar ${r.firstBarIndex} to ${r.lastBarIndex}`,null),e+=this._paintSystem(r,e)}return e}_paintSystem(e,t){const s=Math.floor(e.height),i=new Si;return i.x=0,i.y=e.y,i.totalWidth=this.scaledWidth,i.totalHeight=t,i.width=this.scaledWidth,i.height=s,i.firstMasterBarIndex=e.firstBarIndex,i.lastMasterBarIndex=e.lastBarIndex,e.buildBoundingsLookup(0,0),this.registerPartial(i,r=>{this.renderer.canvas.color=this.renderer.settings.display.resources.mainGlyphColor,this.renderer.canvas.textAlign=Y.Left,e.paint(0,-(i.y/this.renderer.settings.display.scale),r)}),s}_fitSystem(e){e.isFull||e.width>this._maxWidth||this.renderer.settings.display.justifyLastSystem?this._scaleToWidth(e,this._maxWidth):this._scaleToWidth(e,e.width),e.finalizeSystem()}_scaleToWidth(e,t){const s=t-e.accoladeWidth,i=this.shouldApplyBarScale,r=e.totalBarDisplayScale,o=(t-e.computedWidth)/e.masterBarsRenderers.length;for(const l of e.allStaves){l.resetSharedLayoutData();let h=0;for(const c of l.barRenderers){c.x=h,c.y=l.topPadding+l.topOverflow;let d;i?d=e.getBarDisplayScale(c)*s/r:d=c.computedWidth+o,c.scaleToWidth(d),h+=c.width}}e.width=t}_createStaffSystem(e,t){const s=this.createEmptyStaffSystem(this._systems.length),i=this.getBarsPerSystem(s.index),r=this._maxWidth,n=t+1;let o=e;for(;o<n;){if(this._barsFromPreviousSystem.length>0)for(const h of this._barsFromPreviousSystem)s.addMasterBarRenderers(this.renderer.tracks,h),o=h.lastMasterBarIndex;else{const h=this.multiBarRestInfo,c=h!==null&&h.has(o)?h.get(o):null,d=s.addBars(this.renderer.tracks,o,c);this._allMasterBarRenderers.push(d),o=d.lastMasterBarIndex}this._barsFromPreviousSystem=[];let l=!1;if((i===-1&&s.width>=r&&s.masterBarsRenderers.length!==0||s.masterBarsRenderers.length===i+1)&&(l=!0),l){let h=s.revertLastBar();if(h)for(this._barsFromPreviousSystem.push(h);h&&!h.canWrap&&s.masterBarsRenderers.length>1;)h=s.revertLastBar(),h&&this._barsFromPreviousSystem.push(h);return s.isFull=!0,s.isLast=!1,this._barsFromPreviousSystem.reverse(),s}if(this._needsLineBreak(o))return s.isFull=!0,s.isLast=!1,s;s.x=0,o++}return s.isLast=t===s.lastBarIndex,s}_needsLineBreak(e){let t=!1,s=!0;for(const i of this.renderer.tracks)i.lineBreaks&&i.lineBreaks.has(e+1)?t=!0:s=!1;return t&&s}get _maxWidth(){return this.scaledWidth-this.pagePadding[0]-this.pagePadding[2]}}class ru extends fh{get name(){return"PageView"}getBarsPerSystem(e){let t=this.renderer.settings.display.barsPerRow;return this.renderer.settings.display.systemsLayoutMode===Sr.UseModelLayout&&(t=L.getSystemLayout(this.renderer.score,e,this.renderer.tracks)),t}get shouldApplyBarScale(){return this.renderer.settings.display.systemsLayoutMode===Sr.UseModelLayout}}class au extends fh{get name(){return"Parchment"}getBarsPerSystem(e){return L.getSystemLayout(this.renderer.score,e,this.renderer.tracks)}get shouldApplyBarScale(){return!0}}class ar extends Nt{doLayout(){this.width=this.renderer.smuflMetrics.thinBarlineThickness}paint(e,t,s){this.paintExtended(e,t,s,this.height)}}class Pr extends ar{_isRepeat;constructor(e,t,s){super(e,t),this._isRepeat=s}doLayout(){this.width=this._isRepeat?this.renderer.smuflMetrics.repeatEndingLineThickness:this.renderer.smuflMetrics.thinBarlineThickness}paintExtended(e,t,s,i){s.fillRect(e+this.x,t+this.y,this.renderer.smuflMetrics.thinBarlineThickness,i)}}class nu extends ar{paintExtended(e,t,s,i){const r=this.renderer.smuflMetrics.thinBarlineThickness/2,n=this.renderer.getLineHeight(1);let o=t+this.y+n*.5+r;const l=t+this.y+i;for(;o<l;)s.fillCircle(e+this.x,o,r),o+=n}}class ou extends ar{paintExtended(e,t,s,i){const r=this.renderer.smuflMetrics.dashedBarlineDashLength,n=e+this.x-this.width/2,o=Math.ceil(i/2/r),l=t+this.y+i,h=this.renderer.smuflMetrics.dashedBarlineGapLength,c=s.lineWidth;if(s.lineWidth=this.renderer.smuflMetrics.dashedBarlineThickness,s.beginPath(),o<1)s.moveTo(n,t+this.y),s.lineTo(n,l);else{let d=t+this.y;for(;d<l;){s.moveTo(n,d);const f=Math.min(l-d,r);s.lineTo(n,d+f),d+=r+h}}s.stroke(),s.lineWidth=c}}class Cr extends ar{doLayout(){this.width=this.renderer.smuflMetrics.thickBarlineThickness}paintExtended(e,t,s,i){s.fillRect(e+this.x,t+this.y,this.width,i)}}class Fl extends ar{doLayout(){this.width=this.renderer.smuflMetrics.glyphWidths.get(u.RepeatDot)}paintExtended(e,t,s,i){const r=this.renderer,n=r.heightLineCount%2===0?1:.5,o=t+this.y+this.height/2,l=r.getLineHeight(n),h=r.smuflMetrics.glyphTop.get(u.RepeatDot),c=r.smuflMetrics.glyphHeights.get(u.RepeatDot),d=h-c/2;pt.fillMusicFontSymbolSafe(s,e+this.x,o+d-l,1,u.RepeatDot),pt.fillMusicFontSymbolSafe(s,e+this.x,o+d+l,1,u.RepeatDot)}}class lu extends ar{paintExtended(e,t,s,i){const r=this.renderer;if(r.drawnLineCount-1<=2)return;const l=r.smuflMetrics.staffLineThickness/2,h=(r.drawnLineCount-1)/2,c=r.getLineY(h-1)-l,d=r.getLineY(h+1)+l;s.fillRect(e+this.x,t+c,r.smuflMetrics.thinBarlineThickness,d-c)}}class hu extends ar{paintExtended(e,t,s,i){const n=this.renderer.getLineHeight(1),o=-(n/2)+1;s.fillRect(e+this.x,t+this.y+o,1,n)}}class Yn extends zr{_isRight;_extendToNextStaff;constructor(e,t){super(),this._isRight=e,this._extendToNextStaff=t}doLayout(){const e=this.renderer.bar,t=e.masterBar,s=this._isRight?e.getActualBarLineRight():e.getActualBarLineLeft(this.renderer.index===0),i=this._isRight&&t.isRepeatEnd||!this._isRight&&t.isRepeatStart;let r=ye.Automatic;if(!this._isRight){const f=this.renderer.previousRenderer;if(f&&f.staff===this.renderer.staff&&(r=f.bar.getActualBarLineRight(),s===r))return}switch(this._isRight&&t.isRepeatEnd&&(this.addGlyph(new Fl(0,0)),this.width+=this.renderer.smuflMetrics.repeatBarlineDotSeparation),s){case ye.Dashed:this.addGlyph(new ou(0,0));break;case ye.Dotted:this.addGlyph(new nu(0,0));break;case ye.Heavy:r!==ye.LightHeavy&&r!==ye.HeavyHeavy&&this.addGlyph(new Cr(0,0));break;case ye.HeavyHeavy:r!==ye.LightHeavy&&r!==ye.Heavy&&this.addGlyph(new Cr(0,0)),this.width+=this.renderer.smuflMetrics.barlineSeparation,this.addGlyph(new Cr(0,0));break;case ye.HeavyLight:r!==ye.LightHeavy&&r!==ye.Heavy&&r!==ye.HeavyHeavy&&this.addGlyph(new Cr(0,0)),this.width+=this.renderer.smuflMetrics.thinThickBarlineSeparation,this.addGlyph(new Pr(0,0,i));break;case ye.LightHeavy:r!==ye.HeavyLight&&r!==ye.Regular&&r!==ye.LightLight&&this.addGlyph(new Pr(0,0,i)),this.width+=this.renderer.smuflMetrics.thinThickBarlineSeparation,this.addGlyph(new Cr(0,0));break;case ye.LightLight:r!==ye.HeavyLight&&r!==ye.Regular&&this.addGlyph(new Pr(0,0,i)),this.width+=this.renderer.smuflMetrics.barlineSeparation,this.addGlyph(new Pr(0,0,i));break;case ye.None:break;case ye.Regular:r!==ye.HeavyLight&&r!==ye.LightLight&&this.addGlyph(new Pr(0,0,i));break;case ye.Short:this.addGlyph(new lu(0,0));break;case ye.Tick:this.addGlyph(new hu(0,0));break}this._isRight||t.isRepeatStart&&(this.width+=this.renderer.smuflMetrics.repeatBarlineDotSeparation,this.addGlyph(new Fl(0,0)));const n=this.renderer,o=n.smuflMetrics.staffLineThickness;let l=this.y,h=this.y;n.drawnLineCount<2||!this._isRight&&n.isFirstOfStaff||this._isRight&&n.isLastOfStaff?(l-=o,h+=n.height):(l+=n.getLineY(0)-o/2,h+=n.getLineY(n.drawnLineCount-1)+o/2);const c=h-l;let d=0;if(this._extendToNextStaff&&this._isRight){const f=Math.ceil(this.width);d=f-this.width,this.width=f}for(const f of this.glyphs)f.y=l,f.x+=d,f.height=c}paint(e,t,s){const i=this.glyphs;if(!i)return;const r=this.renderer,n=xe.bar(s,r.barLineBarSubElement,this.renderer.bar,!0);try{let o=this.height;const l=r.staff,h=l.system.allStaves;let c=!1;if(this._extendToNextStaff&&l.index<h.length-1){const d=h[l.index+1],f=l.y+r.y;o=d.y+d.topOverflow+r.smuflMetrics.staffLineThickness-f,c=!0}for(const d of i)c?d.paintExtended(e,t,s,o):d.paint(e,t,s)}finally{n?.[Symbol.dispose]?.()}}}class ph extends Nt{_number;constructor(e,t,s){super(e,t),this._number=`${s}  `}doLayout(){this.renderer.scoreRenderer.canvas.font=this.renderer.resources.elementFonts.get(C.BarNumber);const e=this.renderer.scoreRenderer.canvas.measureText(this._number);this.width=e.width,this.height=e.height,this.y-=this.height}paint(e,t,s){if(!this.renderer.staff.isFirstInSystem)return;const i=xe.bar(s,this.renderer.barNumberBarSubElement,this.renderer.bar,!0);try{const r=this.renderer.resources,n=s.textBaseline;s.font=r.elementFonts.get(C.BarNumber),s.textBaseline=He.Top,s.fillText(this._number,e+this.x,t+this.y),s.textBaseline=n}finally{i?.[Symbol.dispose]?.()}}}class Mn extends kn{shouldDrawBendSlur(){return this.renderer.settings.notation.extendBendArrowsOnTiedNotes&&!!this.startNote.bendOrigin&&this.startNote.isTieOrigin}calculateTieDirection(){return P.Up}}class Ml{x=0;y=-3e3;width=0}class Go extends js{constructor(){super(0,0)}doLayout(){if(!this.glyphs||this.glyphs.length===0){this.width=0;return}this.glyphs.sort((s,i)=>s.y<i.y?-1:s.y>i.y?1:0);const e=[];e.push(new Ml);for(let s=0,i=this.glyphs.length;s<i;s++){const r=this.glyphs[s];r.renderer=this.renderer,r.doLayout();let n=0;for(;e[n].y>r.y;)n++,n===e.length&&e.push(new Ml);r.x=n,e[n].y=r.y+r.height,e[n].width<r.width&&(e[n].width=r.width)}this.width=0;const t=this.renderer.smuflMetrics.accidentalPadding;for(const s of e)this.width+=s.width+t,s.x=this.width;for(let s=0,i=this.glyphs.length;s<i;s++){const r=this.glyphs[s],n=e[r.x];r.x=this.width-n.x}}}class ia extends Lt{constructor(e,t){super(e,t,1,u.AugmentationDot)}doLayout(){super.doLayout(),this.offsetX=this.width/2,this.width*=1.5}}class la extends js{_effectGlyphs=[];_normalGlyphs=[];container;computedWidth=0;constructor(){super(0,0)}doLayout(){let e=0;if(this.glyphs)for(let t=0,s=this.glyphs.length;t<s;t++){const i=this.glyphs[t];i.x=e,i.renderer=this.renderer,i.doLayout(),e+=i.width}this.width=e,this.computedWidth=e}noteLoop(e){for(let t=this.container.beat.notes.length-1;t>=0;t--)e(this.container.beat.notes[t])}addEffect(e){super.addGlyph(e),this._effectGlyphs.push(e)}addNormal(e){super.addGlyph(e),this._normalGlyphs.push(e)}get effectElement(){}paint(e,t,s){this._paintEffects(e,t,s),this._paintNormal(e,t,s)}_paintNormal(e,t,s){for(const i of this._normalGlyphs)i.paint(e+this.x,t+this.y,s)}_paintEffects(e,t,s){const i=this.effectElement?xe.beat(s,this.effectElement,this.container.beat):void 0;try{for(const r of this._effectGlyphs)r.paint(e+this.x,t+this.y,s)}finally{i?.[Symbol.dispose]?.()}}}class Tn extends la{onTimeX=0;middleX=0;stemX=0}class xn extends Nt{_topY=0;constructor(){super(0,0)}getBoundingBoxTop(){return this._topY}getBoundingBoxBottom(){return this._topY+this.height}doLayout(){this.width=this.renderer.smuflMetrics.glyphWidths.get(u.NoteheadSlashWhiteHalf);const e=this.renderer,t=e.getLineHeight(e.heightLineCount-1),s=e.getLineY(0),i=e.drawnLineCount>0?e.getLineHeight(e.drawnLineCount-1):0,r=s+i/2-t/2;this.height=t,this._topY=r}paint(e,t,s){const i=this.height,r=this._topY,n=s.lineWidth;s.lineWidth=this.renderer.smuflMetrics.deadSlappedLineWidth,s.moveTo(e+this.x,t+r),s.lineTo(e+this.x+this.width,t+r+i),s.moveTo(e+this.x,t+r+i),s.lineTo(e+this.x+this.width,t+r),s.stroke(),s.lineWidth=n}}class cu extends Nt{_isGrace;_beat;_number;_octaveDots;_octaveDotsY=0;_octaveDotHeight=0;constructor(e,t,s,i,r,n){super(e,t),this._isGrace=i,this._number=s,this._beat=r,this._octaveDots=n}getBoundingBoxTop(){let e=-this.height/2;return this._octaveDots>0&&this._octaveDotsY<e&&(e=this._octaveDotsY),this.y+e}getBoundingBoxBottom(){let e=this.height/2;const t=this._octaveDotsY+Math.abs(this._octaveDots)*this._octaveDotHeight*2;return this._octaveDots<0&&e<t&&(e=t),this.y+e}paint(e,t,s){const i=this._beat.isRest?xe.beat(s,rt.NumberedRests,this._beat):this._beat.notes.length>0?xe.note(s,$t.NumberedNumber,this._beat.notes[0]):void 0;try{const r=this.renderer.resources;s.font=this._isGrace?r.numberedNotationGraceFont:r.numberedNotationFont;const n=s.textBaseline;s.textBaseline=He.Middle,s.textAlign=Y.Left,s.fillText(this._number.toString(),e+this.x,t+this.y),s.textBaseline=n;const o=Math.abs(this._octaveDots);let l=this._octaveDotsY+r.engravingSettings.glyphTop.get(u.AugmentationDot);for(let h=0;h<o;h++)pt.fillMusicFontSymbolSafe(s,e+this.x+this.width/2,t+this.y+l,1,u.AugmentationDot,!0),l+=this._octaveDotHeight*2}finally{i?.[Symbol.dispose]?.()}}doLayout(){const e=this.renderer.resources,t=this._isGrace?e.numberedNotationGraceFont:e.numberedNotationFont,s=this.renderer.scoreRenderer.canvas;s.font=t;const i=s.measureText(`${this._number}`);this.height=i.height,this.width=i.width;const r=this._octaveDots,n=e.engravingSettings.glyphHeights.get(u.AugmentationDot),o=Math.abs(r)*n*2;r>0?this._octaveDotsY=-(this.height/2)-o-e.engravingSettings.glyphTop.get(u.AugmentationDot):r<0&&(this._octaveDotsY=this.height/2+n+e.engravingSettings.glyphTop.get(u.AugmentationDot)),this._octaveDotHeight=n}}class is extends Nt{constructor(e,t,s){super(e,t),this.width=s}getBoundingBoxTop(){return Number.NaN}getBoundingBoxBottom(){return Number.NaN}}class du extends la{isNaturalizeAccidental=!1;accidental=ee.None;skipLayout=!1;get effectElement(){return rt.NumberedEffects}doLayout(){if(!this.skipLayout){if(!this.container.beat.isRest&&!this.container.beat.isEmpty){const e=new Go;if(e.renderer=this.renderer,this.container.beat.notes.length>0){const t=this.container.beat.notes[0],s=t?t.accidentalMode:oe.Default,i=qt.getNoteValue(t);let r=L.computeAccidental(this.renderer.bar.keySignature,s,i,t.hasQuarterToneOffset);if(r===ee.Natural&&(r=this.renderer.bar.keySignature+7<7?ee.Sharp:ee.Flat,this.isNaturalizeAccidental=!0),r!==ee.None){this.accidental=r;const n=this.renderer,o=xe.noteColor(n.resources,$t.NumberedAccidentals,t),l=new ci(0,n.getLineY(0),r,t.beat.graceType!==K.None?We.GraceScale*We.GraceScale:We.GraceScale);l.colorOverride=o,l.renderer=this.renderer,e.addGlyph(l),this.addNormal(e),this.addNormal(new is(0,0,this.renderer.smuflMetrics.preNoteEffectPadding))}}}super.doLayout()}}}class ln extends Tn{noteHeads=null;deadSlapped=null;get effectElement(){return rt.NumberedEffects}getNoteX(e,t){let s=null;if(this.noteHeads?s=this.noteHeads:this.deadSlapped&&(s=this.deadSlapped),s){let i=s.x;switch(t){case Qe.Left:break;case Qe.Center:i+=s.width/2;break;case Qe.Right:i+=s.width;break}return i}return 0}buildBoundingsLookup(e,t,s){if(this.noteHeads&&this.container.beat.notes.length>0){const i=new xr;i.note=this.container.beat.notes[0],i.noteHeadBounds=new bt,i.noteHeadBounds.x=t+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,e.addNote(i)}}getLowestNoteY(e){return this._internalGetNoteY(e)}getHighestNoteY(e){return this._internalGetNoteY(e)}getNoteY(e,t){return this._internalGetNoteY(t)}getRestY(e){return this._internalGetNoteY(e)}_internalGetNoteY(e){let t=null;if(this.noteHeads?t=this.noteHeads:this.deadSlapped&&(t=this.deadSlapped),t){let s=this.y+t.y;switch(e){case D.Top:case D.TopWithStem:s-=t.height/2;break;case D.Center:break;case D.Bottom:case D.BottomWithStem:s+=t.height/2;break;case D.StemUp:case D.StemDown:break}return s}return 0}
65static majorKeySignatureOneValues=[59,66,61,68,63,58,65,60,67,62,69,64,71,66,61];static minorKeySignatureOneValues=[71,66,73,68,63,70,65,72,67,74,69,64,71,66,73];doLayout(){const e=this.renderer;e.shortestDuration<this.container.beat.duration&&(e.shortestDuration=this.container.beat.duration);let t=0;if(!this.container.beat.isEmpty){const s=e.getLineY(0);let i="0";if(this.container.beat.notes.length>0){const r=this.container.beat.notes[0],n=this.renderer.bar.keySignatureType,o=this.renderer.bar.keySignature,l=o+7,c=(n===as.Minor?ln.minorKeySignatureOneValues:ln.majorKeySignatureOneValues)[l];if(r.isDead)i="X";else{const d=r.displayValue-c,f=d<0?(d%12+12)%12:d%12;t=d<0?(Math.abs(d)+12)/12|0:d/12|0,d<0&&(t*=-1);let g=(L.keySignatureIsSharp(o)||L.keySignatureIsNatural(o)?qt.flatNoteSteps:qt.sharpNoteSteps)[f]+1;L.accidentalNotes[f]&&!this.container.preNotes.isNaturalizeAccidental&&(l<7?g++:g--),i=g.toString()}}if(this.container.beat.deadSlapped){const r=new xn;r.renderer=this.renderer,r.doLayout(),this.deadSlapped=r,this.addEffect(r)}else{const r=this.container.beat.graceType!==K.None,n=new cu(0,s,i,r,this.container.beat,t);this.noteHeads=n,this.addNormal(n)}if(this.container.beat.dots>0&&this.container.beat.duration>=y.Quarter)for(let r=0;r<this.container.beat.dots;r++){const n=new ia(0,s);n.renderer=this.renderer,this.addEffect(n)}}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}}class Ki extends kn{calculateTieDirection(){return this.isLeftHandTap?P.Up:Ki.getBeamDirectionForNote(this.startNote)}static getBeamDirectionForNote(e){return e.string>3?P.Up:P.Down}}class Xn extends Ki{_forSlide;constructor(e,t,s,i,r){super(e,t,s,r),this._forSlide=i}getTieHeight(e,t,s,i){return Math.log(s-e+1)*this.renderer.settings.notation.slurHeight/2}tryExpand(e,t,s,i){if(this._forSlide!==s||this.startNote.beat.id!==e.beat.id||this.endNote.beat.id!==t.beat.id||this.renderer===this.lookupEndBeatRenderer()!==i||this.tieDirection!==Ki.getBeamDirectionForNote(e))return!1;switch(this.tieDirection){case P.Up:e.realValue>this.startNote.realValue&&(this.startNote=e),t.realValue>this.endNote.realValue&&(this.endNote=t);break;case P.Down:e.realValue<this.startNote.realValue&&(this.startNote=e),t.realValue<this.endNote.realValue&&(this.endNote=t);break}return!0}}class Al extends Xn{calculateTieDirection(){return P.Up}}class gh extends hi{_slurs=new Map;_effectSlurs=[];_dashes;hasAdditionalNumbers=!1;*iterateAdditionalNumbers(){const e=this._dashes;if(e)for(const t of e)t instanceof Nn&&(yield t)}constructor(e){super(e),this.preNotes=new du,this.onNotes=new ln}addDash(e){let t=this._dashes;t||(t=[],this._dashes=t),t.push(e)}addNotes(e){let t=this._dashes;t||(t=[],this._dashes=t),t.push(e),this.hasAdditionalNumbers=!0}doLayout(){this._slurs.clear(),this._effectSlurs=[],super.doLayout()}buildBoundingsLookup(e,t,s){super.buildBoundingsLookup(e,t,s);const i=this._dashes;if(i){const r=e.beats[e.beats.length-1],n=i[i.length-1],o=n.x+n.contentWidth;r.visualBounds.w=o-r.visualBounds.x;const l=n.x+n.width;r.realBounds.w=l-r.realBounds.x}}createTies(e){if(e.isVisible){if(e.isTieOrigin&&e.tieDestination.isVisible&&!this._slurs.has("numbered.tie")){const t=new Mn(`numbered.tie.${e.beat.id}`,e,e.tieDestination,!1);this.addTie(t),this._slurs.set(t.slurEffectId,t)}if(e.isTieDestination){const t=new Mn(`numbered.tie.${e.tieOrigin.beat.id}`,e.tieOrigin,e,!0);this.addTie(t)}if(e.isLeftHandTapped&&!e.isHammerPullDestination&&!this._slurs.has(`numbered.tie.leftHandTap.${e.beat.id}`)){const t=new Mn(`numbered.tie.leftHandTap.${e.beat.id}`,e,e,!1);this.addTie(t),this._slurs.set(t.slurEffectId,t)}if(e.isEffectSlurOrigin&&e.effectSlurDestination){let t=!1;for(const s of this._effectSlurs)if(s.tryExpand(e,e.effectSlurDestination,!1,!1)){t=!0;break}if(!t){const s=new Al("numbered.slur.effect",e,e.effectSlurDestination,!1,!1);this._effectSlurs.push(s),this.addTie(s),this._slurs.set(s.slurEffectId,s),this._slurs.set("numbered.slur.effect",s)}}if(e.isEffectSlurDestination&&e.effectSlurOrigin){let t=!1;for(const s of this._effectSlurs)if(s.tryExpand(e.effectSlurOrigin,e,!1,!0)){t=!0;break}if(!t){const s=new Al("numbered.slur.effect",e.effectSlurOrigin,e,!1,!0);this._effectSlurs.push(s),this.addTie(s),this._slurs.set(s.slurEffectId,s),this._slurs.set("numbered.slur.effect",s)}}}}}class Nn extends gh{_absoluteDisplayStart;_displayDuration;constructor(e,t,s){super(e),this._absoluteDisplayStart=t,this._displayDuration=s,this.preNotes.skipLayout=!0,this.barCount=Nn._ticksToBarCount(s)}static _ticksToBarCount(e){return e>=B.toTicks(y.Eighth)?1:e>=B.toTicks(y.Sixteenth)?2:e>=B.toTicks(y.ThirtySecond)?3:e>=B.toTicks(y.SixtyFourth)?4:e>=B.toTicks(y.OneHundredTwentyEighth)?5:e>=B.toTicks(y.TwoHundredFiftySixth)?6:0}
vendor: 6,232 bytes, line 65
65barCount;get beatId(){return-1}get contentWidth(){return this.onNotes.width}get absoluteDisplayStart(){return this._absoluteDisplayStart}get displayDuration(){return this._displayDuration}get graceType(){return K.None}get graceIndex(){return 0}get graceGroup(){return null}get isFirstOfTupletGroup(){return!1}get tupletGroup(){return null}get isLastOfVoice(){return!1}buildBoundingsLookup(e,t,s){}}class uu extends Mo{_absoluteDisplayStart;_voiceIndex;constructor(e,t){super(0,0),this._absoluteDisplayStart=t,this._voiceIndex=e}get beatId(){return-1}get contentWidth(){return this.renderer.smuflMetrics.numberedDashGlyphWidth}get absoluteDisplayStart(){return this._absoluteDisplayStart}get displayDuration(){return B.QuarterTime}get onTimeX(){return this.renderer.smuflMetrics.numberedDashGlyphWidth/2}get graceType(){return K.None}get graceIndex(){return 0}get graceGroup(){return null}get voiceIndex(){return this._voiceIndex}get isFirstOfTupletGroup(){return!1}get tupletGroup(){return null}get isLastOfVoice(){return!1}getLowestNoteY(e){return 0}getHighestNoteY(e){return 0}getNoteY(e,t){return 0}doMultiVoiceLayout(){}getRestY(e){return 0}getNoteX(e,t){return 0}getBeatX(e,t){return 0}registerLayoutingInfo(e){const t=this.renderer.smuflMetrics.numberedDashGlyphWidth;e.addBeatSpring(this,t/2,t/2)}applyLayoutingInfo(e){}buildBoundingsLookup(e,t,s){}paint(e,t,s){const i=this.renderer,r=i.smuflMetrics.numberedDashGlyphWidth,n=i.smuflMetrics.numberedBarRendererBarSize,o=Math.ceil(t+i.getLineY(0)-n);s.fillRect(e+this.x,o,r,n)}}class $n extends Nt{_isOpen;colorOverride;constructor(e){super(0,0),this._isOpen=e}doLayout(){super.doLayout(),this.width=this.renderer.smuflMetrics.ghostParenthesisWidth+this.renderer.smuflMetrics.ghostParenthesisPadding}paint(e,t,s){const i=s.color;this.colorOverride&&(s.color=this.colorOverride),this._isOpen?Ot.paintTie(s,1,e+this.x+this.renderer.smuflMetrics.ghostParenthesisWidth,t+this.y+this.height,e+this.x+this.renderer.smuflMetrics.ghostParenthesisWidth,t+this.y,!1,this.renderer.smuflMetrics.ghostParenthesisWidth/2,this.renderer.smuflMetrics.tieMidpointThickness):Ot.paintTie(s,1,e+this.x+this.renderer.smuflMetrics.ghostParenthesisPadding,t+this.y,e+this.x+this.renderer.smuflMetrics.ghostParenthesisPadding,t+this.y+this.height,!1,this.renderer.smuflMetrics.ghostParenthesisWidth/2,this.renderer.smuflMetrics.tieMidpointThickness),s.color=i}}class mh extends js{_numerator=0;_denominator=0;_isCommon;_isFreeTime;barSubElement=Le.StandardNotationTimeSignature;constructor(e,t,s,i,r,n){super(e,t),this._numerator=s,this._denominator=i,this._isCommon=r,this._isFreeTime=n}paint(e,t,s){const i=xe.bar(s,this.barSubElement,this.renderer.bar);try{super.paint(e,t,s)}finally{i?.[Symbol.dispose]?.()}}doLayout(){if(this._isCommon&&this._numerator===2&&this._denominator===2){const e=new Lt(0,0,this.commonScale,u.TimeSigCutCommon);this.addGlyph(e),super.doLayout()}else if(this._isCommon&&this._numerator===4&&this._denominator===4){const e=new Lt(0,0,this.commonScale,u.TimeSigCommon);this.addGlyph(e),super.doLayout()}else{const e=new kr(0,0,this._numerator,He.Top,this.numberScale),t=new kr(0,0,this._denominator,He.Bottom,this.numberScale);this.addGlyph(e),this.addGlyph(t),super.doLayout();const s=this.width;e.x=(s-e.width)/2,t.x=(s-t.width)/2,this.width=Math.max(e.x+e.width,t.x+t.width)}if(this._isFreeTime){const e=this.renderer.smuflMetrics.oneStaffSpace*2,t=new $n(!0);t.renderer=this.renderer,t.y=-e,t.height=e*2,t.doLayout();for(const i of this.glyphs)i.x+=t.width;this.width+=t.width,this.addGlyph(t);const s=new $n(!1);s.renderer=this.renderer,s.x=this.width,s.y=-e,s.height=e*2,s.doLayout(),this.addGlyph(s),this.width+=s.width}}}class Uo extends mh{get commonScale(){return 1}get numberScale(){return 1}}class ha extends Lt{constructor(e,t,s,i,r){super(e,t,r?We.GraceScale:1,ha.getSymbol(s,i,r))}paint(e,t,s){const i=s.color;super.paint(e,t,s),s.color=i}static getSymbol(e,t,s){if(s&&(e=y.Eighth),t===P.Up)switch(e){case y.Eighth:return u.Flag8thUp;case y.Sixteenth:return u.Flag16thUp;case y.ThirtySecond:return u.Flag32ndUp;case y.SixtyFourth:return u.Flag64thUp;case y.OneHundredTwentyEighth:return u.Flag128thUp;case y.TwoHundredFiftySixth:return u.Flag256thUp;default:return u.Flag8thUp}switch(e){case y.Eighth:return u.Flag8thDown;case y.Sixteenth:return u.Flag16thDown;case y.ThirtySecond:return u.Flag32ndDown;case y.SixtyFourth:return u.Flag64thDown;case y.OneHundredTwentyEighth:return u.Flag128thDown;case y.TwoHundredFiftySixth:return u.Flag128thDown;default:return u.Flag8thDown}}}class fu extends Nt{_count=0;constructor(e,t,s){super(e,t),this._count=0,this._count=s}doLayout(){this.renderer.scoreRenderer.canvas.font=this.renderer.resources.elementFonts.get(C.RepeatCount);const e=this.renderer.scoreRenderer.canvas.measureText(`x${this._count}`);this.width=0,this.height=e.height,this.y-=e.height}paint(e,t,s){const i=xe.bar(s,this.renderer.repeatsBarSubElement,this.renderer.bar);try{const r=this.renderer.resources,n=s.textAlign;s.font=r.elementFonts.get(C.RepeatCount),s.textAlign=Y.Right;const o=`x${this._count}`,l=s.measureText(o).width/1.5;s.fillText(o,e+this.x-l,t+this.y),s.textAlign=n}finally{i?.[Symbol.dispose]?.()}}}class Js extends zn{firstLineY=0;_startSpacing=!1;tupletSize=0;get lineOffset(){return this.lineSpacing}get tupletOffset(){return this.smuflMetrics.oneStaffSpace*.5}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 e=this.lineOffset*(this.heightLineCount-1),t=this.drawnLineCount===0?0:(this.drawnLineCount-1)*this.lineOffset,s=this.smuflMetrics.staffLineThickness/2;this.firstLineY=((e-t)/2|0)-s}doLayout(){this.initLineBasedSizes(),this.updateFirstLineY(),this.tupletSize=this.smuflMetrics.glyphHeights.get(u.Tuplet0),super.doLayout()}getLineY(e){return this.firstLineY+this.getLineHeight(e)}getLineHeight(e){return this.lineOffset*e}paintContent(e,t,s){super.paintContent(e,t,s),this.paintBeams(e,t,s,this.flagsSubElement,this.beamsSubElement),this.paintTuplets(e,t,s,this.tupletSubElement)}
65paintBackground(e,t,s){super.paintBackground(e,t,s),this.paintStaffLines(e,t,s),this.paintSimileMark(e,t,s)}paintStaffLines(e,t,s){const i=xe.bar(s,this.staffLineBarSubElement,this.bar,!0);try{const r=[];for(let l=0,h=this.drawnLineCount;l<h;l++)r.push([]);this.additionalMultiRestBars||this.collectSpaces(r);for(const l of r)l.sort((h,c)=>h[0]>c[0]?1:h[0]<c[0]?-1:0);const n=this.width,o=this.smuflMetrics.staffLineThickness/2;for(let l=0;l<this.drawnLineCount;l++){const h=this.getLineY(l)-o;let c=0;for(const d of r[l])s.fillRect(e+this.x+c,t+this.y+h,d[0]-c,this.smuflMetrics.staffLineThickness),c=d[0]+d[1];s.fillRect(e+this.x+c,t+this.y+h,n-c,this.smuflMetrics.staffLineThickness)}}finally{i?.[Symbol.dispose]?.()}}collectSpaces(e){}createStartSpacing(){if(this._startSpacing)return!1;const e=this.index===0?this.settings.display.firstStaffPaddingLeft:this.settings.display.staffPaddingLeft;return this.addPreBeatGlyph(new is(0,0,e)),this._startSpacing=!0,!0}paintTuplets(e,t,s,i,r=!1){for(const n of this.voiceContainer.voiceDrawOrder)if(this.voiceContainer.tupletGroups.has(n)){const o=this.voiceContainer.tupletGroups.get(n);for(const l of o)this._paintTupletHelper(e,t,s,l,i,r)}}getBeatDirection(e){const t=this.helpers.getBeamingHelperForBeat(e);return t?this.getBeamDirection(t):P.Up}getTupletBeamDirection(e){return this.getBeamDirection(e)}calculateBeamYWithDirection(e,t,s){return this.ensureBeamDrawingInfo(e,s),e.drawingInfos.get(s).calcY(t)}_paintTupletHelper(e,t,s,i,r,n){const o=this.resources,l=s.textAlign,h=s.textBaseline;s.color=i.voice.index===0?this.resources.mainGlyphColor:this.resources.secondaryGlyphColor,s.textAlign=Y.Center,s.textBaseline=He.Middle;let c;const d=i.beats[0].tupletNumerator,f=i.beats[0].tupletDenominator;if(d===2&&f===3)c=[u.Tuplet2];else if(d===3&&f===2)c=[u.Tuplet3];else if(d===4&&f===6)c=[u.Tuplet4];else if(d===5&&f===4)c=[u.Tuplet5];else if(d===6&&f===4)c=[u.Tuplet6];else if(d===7&&f===4)c=[u.Tuplet7];else if(d===9&&f===8)c=[u.Tuplet9];else if(d===10&&f===8)c=[u.Tuplet1,u.Tuplet0];else if(d===11&&f===8)c=[u.Tuplet1,u.Tuplet1];else if(d===12&&f===8)c=[u.Tuplet1,u.Tuplet2];else if(d===13&&f===8)c=[u.Tuplet1,u.Tuplet3];else{c=[];const S=u.Tuplet0;d>10?(c.push(S+Math.floor(d/10)),c.push(S+(d-10))):c.push(S+d),c.push(u.TupletColon),f>10?(c.push(S+Math.floor(f/10)),c.push(S+(f-10))):c.push(S+f)}const p=this.tupletOffset,g=this.tupletSize,m=p+g*.5,b=xe.beat(s,r,i.beats[0]);try{const S=s.lineWidth;if(s.lineWidth=this.smuflMetrics.tupletBracketThickness,i.beats.length===1||!i.isFull)for(const N of i.beats){const v=this.helpers.getBeamingHelperForBeat(N);if(!v)continue;const W=this.getTupletBeamDirection(v),j=this.getBeatX(N,ae.Stem);let q=this.calculateBeamYWithDirection(v,j,W);W===P.Down?q+=m:q-=m,s.fillMusicFontSymbols(e+this.x+j,t+this.y+q+g*.5,1,c,!0)}else{const N=i.beats[0],v=i.beats[i.beats.length-1];let W=null,j=null;for(let Ws=0;Ws<i.beats.length;Ws++)if(!i.beats[Ws].isRest){W=i.beats[Ws];break}for(let Ws=i.beats.length-1;Ws>=0;Ws--)if(!i.beats[Ws].isRest){j=i.beats[Ws];break}let q=!1;W||(W=N,q=!0),j||(j=v);const F=this.getBeatX(N,ae.OnNotes),Q=this.getBeatX(v,ae.PostNotes),me=this.helpers.getBeamingHelperForBeat(W),ge=this.helpers.getBeamingHelperForBeat(j),re=this.getTupletBeamDirection(me);let Je=this.calculateBeamYWithDirection(me,F,re),lt=this.calculateBeamYWithDirection(ge,Q,re);q&&(Je=Math.max(Je,lt),lt=Je),re===P.Down?(Je+=m,lt+=m):(Je-=m,lt-=m);const De=c.reduce((Ws,Sh)=>Ws+o.engravingSettings.glyphWidths.get(Sh),0),vs=o.engravingSettings.oneStaffSpace*.5,Ht=(F+Q)/2,Zt=Ht-De/2-vs,xi=Ht+De/2+vs,ui=(lt-Je)/(Q-F),Ds=Je-ui*F,Ut=ui*Zt+Ds,Wi=ui*Ht+Ds,Os=ui*xi+Ds,ps=re===P.Down?Je-g*.5:Je+g*.5,Jo=re===P.Down?lt-g*.5:lt+g*.5,qo=s.lineWidth%2===0?0:.5;e+=qo,t+=qo,Zt>F&&(s.beginPath(),s.moveTo(e+this.x+F,t+this.y+ps),n?s.quadraticCurveTo(e+this.x+(Zt+F)/2,t+this.y+Ut,e+this.x+Zt,t+this.y+Ut):(s.lineTo(e+this.x+F,t+this.y+Je),s.lineTo(e+this.x+Zt,t+this.y+Ut)),s.moveTo(e+this.x+xi,t+this.y+Os),n?s.quadraticCurveTo(e+this.x+(Q+xi)/2,t+this.y+Os,e+this.x+Q,t+this.y+Jo):(s.lineTo(e+this.x+Q,t+this.y+lt),s.lineTo(e+this.x+Q,t+this.y+Jo)),s.stroke()),s.fillMusicFontSymbols(e+this.x+Ht,t+this.y+Wi+g*.5,1,c,!0)}s.textAlign=l,s.textBaseline=h,s.lineWidth=S}finally{b?.[Symbol.dispose]?.()}}paintBeams(e,t,s,i,r){for(const n of this.voiceContainer.voiceDrawOrder)for(const o of this.helpers.beamHelpers[n])this.paintBeamHelper(e,t,s,o,i,r)}drawBeamHelperAsFlags(e){return e.beats.length===1}hasFlag(e){if(e.isRest)return!1;const t=this.helpers.getBeamingHelperForBeat(e);return t?t.hasFlag(this.drawBeamHelperAsFlags(t),e):_s.beatHasFlag(e)}hasStem(e){if(e.isRest)return!1;const t=this.helpers.getBeamingHelperForBeat(e);return t?t.hasStem(this.drawBeamHelperAsFlags(t),e):_s.beatHasStem(e)}paintBeamHelper(e,t,s,i,r,n){s.color=i.voice.index===0?this.resources.mainGlyphColor:this.resources.secondaryGlyphColor,this.shouldPaintBeamingHelper(i)&&(this.drawBeamHelperAsFlags(i)?this.paintFlag(e,t,s,i,r):this.paintBar(e,t,s,i,n))}
vendor: 16,674 bytes, line 65
65shouldPaintBeamingHelper(e){return!e.isRestBeamHelper}shouldPaintFlag(e){return!(e.graceType===K.BendGrace||e.deadSlapped||e.graceType!==K.None&&this.settings.notation.notationMode===Vt.SongBook||e.duration===y.Whole||e.duration===y.DoubleWhole||e.duration===y.QuadrupleWhole)}paintFlag(e,t,s,i,r){for(const n of i.beats){if(!this.shouldPaintFlag(n))continue;const o=n.graceType!==K.None,l=this.getBeatX(n,ae.Stem),h=this.getBeamDirection(i),c=t+this.y+this.getFlagTopY(n,h),d=t+this.y+this.getFlagBottomY(n,h);let f=0;if(h===P.Down?f=d:f=c,!i.hasStem(!0,n))continue;this.paintBeamingStem(n,t+this.y,e+this.x+l,c,d,s);const p=xe.beat(s,r,n);try{let g=0;if(i.hasFlag(!0,n)){const m=new ha(e+this.x+l,f,n.duration,h,o);m.renderer=this,m.doLayout(),m.paint(0,0,s),g=m.width/2}n.graceType===K.BeforeBeat&&(h===P.Down?pt.fillMusicFontSymbolSafe(s,e+this.x+l+g/2,(c+d-this.smuflMetrics.glyphHeights.get(u.GraceNoteSlashStemDown))/2,We.GraceScale,u.GraceNoteSlashStemDown,!0):pt.fillMusicFontSymbolSafe(s,e+this.x+l+g/2,(c+d+this.smuflMetrics.glyphHeights.get(u.GraceNoteSlashStemUp))/2,We.GraceScale,u.GraceNoteSlashStemUp,!0))}finally{p?.[Symbol.dispose]?.()}}}recreatePreBeatGlyphs(){this._startSpacing=!1,super.recreatePreBeatGlyphs()}calculateBeamY(e,t){return this.calculateBeamYWithDirection(e,t,this.getBeamDirection(e))}createPreBeatGlyphs(){super.createPreBeatGlyphs(),this.addPreBeatGlyph(new Yn(!1,this.bar.staff.track.score.stylesheet.extendBarLines)),this.createLinePreBeatGlyphs();let e=!1;this.index===0&&(e=this.createStartSpacing()),this.shouldCreateBarNumber()?this.addPreBeatGlyph(new ph(0,this.getLineHeight(-.5),this.bar.index+1)):e||this.addPreBeatGlyph(new is(0,0,this.smuflMetrics.oneStaffSpace))}shouldCreateBarNumber(){let e=vt.AllBars;switch(this.settings.notation.isNotationElementVisible(C.BarNumber)?this.bar.barNumberDisplay!==void 0?e=this.bar.barNumberDisplay:e=this.bar.staff.track.score.stylesheet.barNumberDisplay:e=vt.Hide,e){case vt.AllBars:return!0;case vt.FirstOfSystem:return this.isFirstOfStaff;case vt.Hide:return!1}return!0}createPostBeatGlyphs(){super.createPostBeatGlyphs();const e=this.lastBar;this.addPostBeatGlyph(new Yn(!0,this.bar.staff.track.score.stylesheet.extendBarLines)),e.masterBar.isRepeatEnd&&e.masterBar.repeatCount>2&&this.settings.notation.isNotationElementVisible(C.RepeatCount)&&this.addPostBeatGlyph(new fu(0,this.getLineHeight(-.5),this.bar.masterBar.repeatCount))}paintBar(e,t,s,i,r){const n=this.getBeamDirection(i),l=i.graceType!==K.None?We.GraceScale:1;let h=(this.beamSpacing+this.beamThickness)*l,c=this.beamThickness*l;n===P.Down&&(h=-h,c=-c);for(let d=0,f=i.beats.length;d<f;d++){const p=i.beats[d];if(p.deadSlapped)continue;const g=this.getBeatX(p,ae.Stem);let m=t+this.y;n===P.Up?m+=this.getFlagBottomY(p,n):m+=this.getFlagTopY(p,n);const b=t+this.y+this.calculateBeamY(i,g);let S,N;m<b?(S=m,N=b):(S=b,N=m),this.paintBeamingStem(p,t+this.y,e+this.x+g,S,N,s);const v=xe.beat(s,r,p);try{const W=this.smuflMetrics.brokenBeamWidth*l,j=L.getIndex(p.duration)-2,q=t+this.y,F=this.smuflMetrics.stemThickness;for(let Q=0;Q<j;Q++){let me=Math.floor(g+F),ge=0,re=0,Je=0;const lt=q+Q*h;if(d<i.beats.length-1){const De=_s.isFullBarJoin(p,i.beats[d+1],Q);if(Q===j-1&&De&&p.beamingMode===st.ForceSplitOnSecondaryToNext)ge=Math.ceil(me+W),re=lt+this.calculateBeamY(i,me),Je=lt+this.calculateBeamY(i,ge),Js.paintSingleBar(s,e+this.x+me,re,e+this.x+ge,Je,c),ge=Math.floor(this.getBeatX(i.beats[d+1],ae.Stem)),me=Math.floor(ge-W),re=lt+this.calculateBeamY(i,me),Je=lt+this.calculateBeamY(i,ge),Js.paintSingleBar(s,e+this.x+me,re,e+this.x+ge,Je,c);else{if(De)ge=Math.ceil(this.getBeatX(i.beats[d+1],ae.Stem));else if(d===0||!_s.isFullBarJoin(i.beats[d-1],p,Q))ge=Math.ceil(me+W);else continue;re=lt+this.calculateBeamY(i,me),Je=lt+this.calculateBeamY(i,ge),Js.paintSingleBar(s,e+this.x+me,re,e+this.x+ge,Je,c)}}else d>0&&!_s.isFullBarJoin(p,i.beats[d-1],Q)&&(ge=Math.ceil(g),me=Math.floor(g-W),re=lt+this.calculateBeamY(i,me),Je=lt+this.calculateBeamY(i,ge),Js.paintSingleBar(s,e+this.x+me,re,e+this.x+ge,Je,c))}}finally{v?.[Symbol.dispose]?.()}}if(i.graceType===K.BeforeBeat){const d=this.getBeatX(i.beats[0],ae.Stem),f=this.smuflMetrics.glyphWidths.get(u.Flag8thUp)*We.GraceScale;let p=t+this.y+this.calculateBeamY(i,d)|0;p+=c+h,n===P.Down?pt.fillMusicFontSymbolSafe(s,e+this.x+d+f/2,p,We.GraceScale,u.GraceNoteSlashStemDown,!0):pt.fillMusicFontSymbolSafe(s,e+this.x+d+f/2,p,We.GraceScale,u.GraceNoteSlashStemUp,!0)}}static paintSingleBar(e,t,s,i,r,n){e.beginPath(),e.moveTo(t,s),e.lineTo(i,r),e.lineTo(i,r+n),e.lineTo(t,s+n),e.closePath(),e.fill()}calculateBeamingOverflows(e,t){let s=0,i=0;for(const r of this.helpers.beamHelpers)for(const n of r)if(this.shouldPaintBeamingHelper(n))if(n.beats.length===1&&n.beats[0].duration>=y.Half){const o=this.getTupletBeamDirection(n),l=this.getBeamDirection(n),h=this.smuflMetrics.stemFlagOffsets.get(n.beats[0].duration);if(l===P.Up){let c=this.getFlagTopY(n.beats[0],l)-h;if(n.hasTuplet&&o===l&&(c-=this.tupletSize+this.tupletOffset),c<s&&(s=c),n.hasTuplet&&o!==l){let d=this.getFlagBottomY(n.beats[0],o);d+=this.tupletSize+this.tupletOffset,d>i&&(i=d)}}else{let c=this.getFlagBottomY(n.beats[0],l)+h;if(n.hasTuplet&&o===l&&(c+=this.tupletSize+this.tupletOffset),c>i&&(i=c),n.hasTuplet&&o!==l){let d=this.getFlagTopY(n.beats[0],o);d-=this.tupletSize+this.tupletOffset,d<s&&(s=d)}}}else{const o=this.getBeamDirection(n);this.ensureBeamDrawingInfo(n,o);const l=n.drawingInfos.get(o),h=this.getTupletBeamDirection(n);if(o===P.Up){let c=Math.min(l.startY,l.endY);n.hasTuplet&&h===o&&(c-=this.tupletSize+this.tupletOffset),c<s&&(s=c);let d=this.voiceContainer.getLowestNoteY(n.beatOfLowestNote,D.Bottom);n.hasTuplet&&h!==o&&(d+=this.tupletSize+this.tupletOffset),d>i&&(i=d)}else{let c=Math.max(l.startY,l.endY);n.hasTuplet&&h===o&&(c+=this.tupletSize+this.tupletOffset),c>i&&(i=c);let d=this.voiceContainer.getHighestNoteY(n.beatOfHighestNote,D.Top);n.hasTuplet&&h!==o&&(d-=this.tupletSize+this.tupletOffset),d<s&&(s=d)}}s<e&&this.registerOverflowTop(Math.abs(s)),i>t&&this.registerOverflowBottom(Math.abs(i)-t)}initializeBeamDrawingInfo(e,t){const s=new Ld,i=e.beats[0],r=e.beats[e.beats.length-1];s.startBeat=i,s.startX=this.getBeatX(i,ae.Stem),s.startY=t===P.Up?this.getFlagTopY(i,t):this.getFlagBottomY(i,t),s.endBeat=r,s.endX=this.getBeatX(r,ae.Stem),s.endY=t===P.Up?this.getFlagTopY(r,t):this.getFlagBottomY(r,t);const n=this.smuflMetrics.oneStaffSpace;return t===P.Down&&s.startY>s.endY&&s.startY-s.endY>n&&(s.endY=s.startY-n),t===P.Down&&s.endY>s.startY&&s.endY-s.startY>n&&(s.startY=s.endY-n),t===P.Up&&s.startY<s.endY&&s.endY-s.startY>n&&(s.endY=s.startY+n),t===P.Up&&s.endY<s.startY&&s.startY-s.endY>n&&(s.startY=s.endY+n),s}get beamSpacing(){return this.smuflMetrics.beamSpacing}get beamThickness(){return this.smuflMetrics.beamThickness}ensureBeamDrawingInfo(e,t){if(e.drawingInfos.has(t))return;const s=this.initializeBeamDrawingInfo(e,t);e.drawingInfos.set(t,s);const i=L.getIndex(e.shortestDuration)-2,r=this.applyBarShift(e,t,s,i);if(e.beats.length>1){if(t===P.Up){const o=r+this.getFlagTopY(e.beatOfHighestNote,t),h=s.calcY(this.getBeatX(e.beatOfHighestNote,ae.Stem))-o;h>0&&(s.startY-=h,s.endY-=h)}else{const o=r+this.getFlagBottomY(e.beatOfLowestNote,t),l=s.calcY(this.getBeatX(e.beatOfLowestNote,ae.Stem)),h=o-l;h>0&&(s.startY+=h,s.endY+=h)}let n=0;if(e.restBeats.length>0){const o=e.graceType!==K.None?We.GraceScale:1;n=i*(this.beamSpacing+this.beamThickness)*o}for(const o of e.restBeats)if(o.isRest&&o.index<e.beats[e.beats.length-1].index){if(t===P.Up){const l=this.getBeatContainer(o).getBoundingBoxTop()-n,c=s.calcY(this.getBeatX(o,ae.Stem))-l;c>0&&(s.startY-=c,s.endY-=c)}else if(t===P.Down){const l=this.getBeatContainer(o).getBoundingBoxBottom()+n,h=s.calcY(this.getBeatX(o,ae.Stem)),c=l-h;c>0&&(s.startY+=c,s.endY+=c)}}if(e.slashBeats.length>0)for(const o of e.slashBeats){const l=s.calcY(this.getBeatX(o,ae.Stem)),c=(t===P.Up?this.getFlagTopY(o,t):this.getFlagBottomY(o,t))-l;c>0&&(s.startY+=c,s.endY+=c)}}P.Up,s.startY=Math.round(s.startY),s.endY=Math.round(s.endY)}applyBarShift(e,t,s,i){let r=0;const n=e.isRestBeamHelper,o=e.graceType!==K.None?We.GraceScale:1;if(i>2&&!n){const l=this.beamSpacing*o,h=this.beamThickness*o,c=i*h+(i-1)*l;if(t===P.Up){const f=s.startY+2*h+l-c,p=s.startY-f;p>0&&(r=p*-1,s.startY-=p,s.endY-=p)}else{const p=s.startY-2*h+l+c-s.startY;p>0&&(r=p,s.startY+=p,s.endY+=p)}}return r}getMinLineOfBeat(e){return 0}getMaxLineOfBeat(e){return 0}}class hn extends Js{static StaffId="numbered";simpleWhammyOverflow=0;_isOnlyNumbered;shortestDuration=y.QuadrupleWhole;get dotSpacing(){return this.smuflMetrics.glyphHeights.get(u.AugmentationDot)*2}get repeatsBarSubElement(){return Le.NumberedRepeats}get barNumberBarSubElement(){return Le.NumberedBarNumber}get barLineBarSubElement(){return Le.NumberedBarLines}get staffLineBarSubElement(){return Le.NumberedStaffLine}constructor(e,t){super(e,t),this._isOnlyNumbered=!t.staff.showSlash&&!t.staff.showTablature&&!t.staff.showStandardNotation}get lineSpacing(){return this.smuflMetrics.oneStaffSpace}get heightLineCount(){return 5}get drawnLineCount(){return 0}get bottomGlyphOverflow(){return 0}get flagsSubElement(){return rt.NumberedDuration}get beamsSubElement(){return rt.NumberedDuration}get tupletSubElement(){return rt.NumberedTuplet}shouldPaintBeamingHelper(e){return!0}paintFlag(e,t,s,i,r){this.paintBar(e,t,s,i,r)}paintBar(e,t,s,i,r){if(!(i.beats.length===0||i.graceType!==K.None))for(let n=0,o=i.beats.length;n<o;n++){const l=i.beats[n],h=xe.beat(s,r,l);try{const c=this.getBeamDirection(i),f=i.graceType!==K.None?We.GraceScale:1;let p=(this.beamSpacing+this.beamThickness)*f,g=this.beamThickness*f;c===P.Down&&(p=-p,g=-g);let m=L.getIndex(l.duration)-2,b=this.getBeatX(l,ae.PreNotes),S=0,N=0;n===i.beats.length-1?(S=b,N=this.getBeatX(l,ae.PostNotes)):(S=b,N=this.getBeatX(i.beats[n+1],ae.PreNotes));const v=t+this.y+this.calculateBeamY(i,b);for(let j=0;j<m;j++){const q=v+j*p;Js.paintSingleBar(s,e+this.x+S,q,e+this.x+N,q,g)}const W=this.voiceContainer.getBeatContainer(l);if(W&&W.hasAdditionalNumbers)for(const j of W.iterateAdditionalNumbers()){m=j.barCount,b=this.beatGlyphsStart+j.x+j.getBeatX(ae.PreNotes,!1);for(let q=0;q<m;q++){const F=v+q*p,Q=this.beatGlyphsStart+j.x+j.getBeatX(ae.PostNotes,!1);Js.paintSingleBar(s,e+this.x+b,F,e+this.x+Q,F,g)}}}finally{h?.[Symbol.dispose]?.()}}}calculateOverflows(e,t){super.calculateOverflows(e,t),!this.bar.isEmpty&&this.calculateBeamingOverflows(e,t)}getNoteLine(e){return 0}_calculateBarHeight(e){const t=L.getIndex(e.duration)-2;let s=0;if(t>0){const i=this.smuflMetrics;s=i.numberedBarRendererBarSpacing+t*(i.numberedBarRendererBarSpacing+i.numberedBarRendererBarSize)}return s}getFlagTopY(e,t){const s=this._calculateBarHeight(e),i=this.voiceContainer.getBeatContainer(e);return i?t===P.Up?i.getBoundingBoxTop()-s:i.getBoundingBoxBottom():t===P.Up?this.voiceContainer.getBoundingBoxTop()-s:this.voiceContainer.getBoundingBoxBottom()}getFlagBottomY(e,t){const s=this._calculateBarHeight(e),i=this.voiceContainer.getBeatContainer(e);return i?t===P.Down?i.getBoundingBoxBottom()+s:this.getLineY(0):t===P.Down?this.voiceContainer.getBoundingBoxBottom()+s:this.getLineY(0)}getBeamDirection(e){return P.Down}getTupletBeamDirection(e){return P.Up}createPreBeatGlyphs(){this.wasFirstOfStaff=this.isFirstOfStaff,(this.index===0||this.bar.masterBar.isRepeatStart&&this._isOnlyNumbered)&&this.addPreBeatGlyph(new Yn(!1,this.bar.staff.track.score.stylesheet.extendBarLines)),this.createLinePreBeatGlyphs();const e=this.createStartSpacing();this.shouldCreateBarNumber()?this.addPreBeatGlyph(new ph(0,this.getLineHeight(-.5),this.bar.index+1)):e||this.addPreBeatGlyph(new is(0,0,this.smuflMetrics.oneStaffSpace))}createLinePreBeatGlyphs(){this._isOnlyNumbered&&(!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._createTimeSignatureGlyphs())}_createTimeSignatureGlyphs(){const e=this.bar.masterBar,t=new Uo(0,this.getLineY(0),e.timeSignatureNumerator,e.timeSignatureDenominator,e.timeSignatureCommon,e.isFreeTime&&(e.previousMasterBar==null||e.isFreeTime!==e.previousMasterBar.isFreeTime));t.barSubElement=Le.NumberedTimeSignature,this.addPreBeatGlyph(t)}createPostBeatGlyphs(){this._isOnlyNumbered&&super.createPostBeatGlyphs()}createVoiceGlyphs(e){if(e.index>0)return;super.createVoiceGlyphs(e);const t=this.bar.masterBar.start;for(const s of e.beats){const i=new gh(s);if(this.addBeatGlyph(i),s.duration<y.Quarter){const r=s.displayStart+s.displayDuration;let n=s.displayStart+B.QuarterTime;for(;n<r;){if(r-n>=B.QuarterTime){const l=new uu(e.index,t+n);this.addBeatGlyph(l),i.addDash(l)}else if(s.duration===y.Half&&s.dots>1){const l=new Nn(s,t+n,r-n);this.addBeatGlyph(l),i.addNotes(l)}n+=B.QuarterTime}}}}paintBeamingStem(e,t,s,i,r,n){}get beamSpacing(){return this.smuflMetrics.numberedBarRendererBarSpacing}get beamThickness(){return this.smuflMetrics.numberedBarRendererBarSize}paintBeamHelper(e,t,s,i,r,n){i.voice?.index===0&&super.paintBeamHelper(e,t,s,i,r,n)}applyBarShift(e,t,s,i){return 0}calculateBeamYWithDirection(e,t,s){this.ensureBeamDrawingInfo(e,s);const i=e.drawingInfos.get(s);return s===P.Up?Math.min(i.startY,i.endY):Math.max(i.startY,i.endY)}paintTuplets(e,t,s,i,r=!1){super.paintTuplets(e,t,s,i,!0)}}class pu extends Sn{get staffId(){return hn.StaffId}create(e,t){return new hn(e,t)}canCreate(e,t){return super.canCreate(e,t)&&t.showNumbered}}class zo extends Lt{_clef;_clefOttava;_ottavaGlyph;constructor(e,t,s,i){super(e,t,1,zo._getSymbol(s,i)),this._clef=s,this._clefOttava=i}getBoundingBoxTop(){let e=super.getBoundingBoxTop();const t=this._ottavaGlyph;if(t){const s=this.y+t.getBoundingBoxTop();e=L.minBoundingBox(e,s)}return e}getBoundingBoxBottom(){let e=super.getBoundingBoxBottom();const t=this._ottavaGlyph;if(t){const s=this.y+t.getBoundingBoxBottom();e=L.maxBoundingBox(e,s)}return e}doLayout(){switch(this.center=!0,super.doLayout(),this.width=this.renderer.smuflMetrics.glyphWidths.get(u.GClef),this.offsetX=this.width/2,this._ottavaGlyph=void 0,this._clef){case ve.C3:case ve.C4:if(this._clefOttava===le._8vb)return;break;case ve.F4:case ve.G2:return}let e,t=!1;switch(this._clefOttava){case le._15ma:e=u.Clef15,t=!0;break;case le._8va:e=u.Clef8,t=!0;break;case le._8vb:e=u.Clef8;break;case le._15mb:e=u.Clef15;break;default:return}const s=this.width/2,i=t?this.renderer.smuflMetrics.glyphTop.get(this.symbol):this.renderer.smuflMetrics.glyphBottom.get(this.symbol)-this.renderer.smuflMetrics.glyphHeights.get(e);this._ottavaGlyph=new Lt(s,-i,1,e),this._ottavaGlyph.center=!0,this._ottavaGlyph.renderer=this.renderer,this._ottavaGlyph.doLayout()}static _getSymbol(e,t){switch(e){case ve.Neutral:return u.UnpitchedPercussionClef1;case ve.C3:case ve.C4:return t===le._8vb?u.CClef8vb:u.CClef;case ve.F4:switch(t){case le._15ma:return u.FClef15ma;case le._8va:return u.FClef8va;case le._8vb:return u.FClef8vb;case le._15mb:return u.FClef15mb;default:return u.FClef}case ve.G2:switch(t){case le._15ma:return u.GClef15ma;case le._8va:return u.GClef8va;case le._8vb:return u.GClef8vb;case le._15mb:return u.GClef15mb;default:return u.GClef}default:return u.None}}paint(e,t,s){const i=xe.bar(s,Le.StandardNotationClef,this.renderer.bar);try{super.paint(e,t,s);const r=this._ottavaGlyph;r&&r.paint(e+this.x,t+this.y,s)}finally{i?.[Symbol.dispose]?.()}}}class gu extends zr{paint(e,t,s){const i=xe.bar(s,Le.StandardNotationKeySignature,this.renderer.bar);try{super.paint(e,t,s)}finally{i?.[Symbol.dispose]?.()}}}class Jr extends fs{_note;constructor(e,t,s){super(e,t),this._note=s}static _getSymbol(e,t){switch(e){case ct.None:return u.None;case ct.Normal:return t?u.ArticAccentAbove:u.ArticAccentBelow;case ct.Heavy:return t?u.ArticMarcatoAbove:u.ArticMarcatoBelow;case ct.Tenuto:return t?u.ArticTenutoAbove:u.ArticTenutoBelow;default:return u.None}}doLayout(){this.width=this.renderer.smuflMetrics.glyphWidths.get(u.ArticAccentAbove),this.height=this.renderer.smuflMetrics.glyphHeights.get(u.ArticAccentAbove)}paint(e,t,s){const i=this.renderer.getBeatDirection(this._note.beat),r=Jr._getSymbol(this._note.accentuated,i===P.Down),n=i===P.Up?t+this.y:t+this.y+this.height;pt.fillMusicFontSymbolSafe(s,e+this.x,n,1,r,!0)}}class Il extends Lt{constructor(e,t){super(e,t,We.GraceScale,u.ArticStaccatoAbove),this.center=!0}
65doLayout(){super.doLayout(),this.offsetY=this.height}}class ca extends Lt{centerOnStem=!1;constructor(e,t,s,i){super(e,t,s?We.GraceScale:1,i)}paint(e,t,s){this.centerOnStem&&(this.center=!0),super.paint(e,t,s)}}class gr extends ca{constructor(e,t,s,i){super(e,t,i,gr.getSymbol(s))}static getSymbol(e){switch(e){case y.QuadrupleWhole:return u.NoteheadDoubleWholeSquare;case y.DoubleWhole:return u.NoteheadDoubleWhole;case y.Whole:return u.NoteheadWhole;case y.Half:return u.NoteheadHalf;default:return u.NoteheadBlack}}}class mu extends ca{constructor(e,t,s){super(e,t,s,u.NoteheadXOrnate)}}class cn extends ca{constructor(e,t,s,i){super(e,t,i,cn._getSymbol(s))}static _getSymbol(e){switch(e){case y.QuadrupleWhole:case y.DoubleWhole:case y.Whole:case y.Half:return u.NoteheadDiamondWhiteWide;default:return u.NoteheadDiamondBlackWide}}}class Rl{steps=0;isGhost;color;constructor(e,t,s){this.steps=e,this.isGhost=t,this.color=s}}class dn extends Nt{_isOpen;_infos=[];_glyphs=[];isEmpty=!0;constructor(e){super(0,0),this._isOpen=e}addParenthesis(e){const t=this.renderer,s=t.getNoteSteps(e),i=e.isGhost||this._isTiedBend(e)&&t.settings.notation.isNotationElementVisible(C.ParenthesisOnTiedBends),r=xe.noteColor(t.resources,$t.Effects,e);this._add(new Rl(s,i,r))}addParenthesisOnSteps(e,t){const s=new Rl(e,t,void 0);this._add(s)}_add(e){this._infos.push(e),e.isGhost&&(this.isEmpty=!1)}_isTiedBend(e){return e.isTieDestination?e.tieOrigin.hasBend?!0:this._isTiedBend(e.tieOrigin):!1}doLayout(){const e=this.renderer;this._infos.sort((i,r)=>i.steps-r.steps);let t=null;const s=e.getScoreHeight(1);for(let i=0,r=this._infos.length;i<r;i++){let n;if(!this._infos[i].isGhost)t=null;else if(!t)n=new $n(this._isOpen),n.colorOverride=this._infos[i].color,n.renderer=this.renderer,n.y=e.getScoreY(this._infos[i].steps)-s,n.height=s*2,n.doLayout(),this._glyphs.push(n),t=n;else{const o=e.getScoreY(this._infos[i].steps)+s;t.height=o-t.y}}this.width=this._glyphs.length>0?this._glyphs[0].width:0}paint(e,t,s){super.paint(e,t,s);for(const i of this._glyphs)i.paint(e+this.x,t+this.y,s)}}class yu extends ca{_isGrace;_articulation;constructor(e,t,s,i,r){super(e,t,r,s.getSymbol(i)),this._isGrace=r,this._articulation=s}paint(e,t,s){const i=s.color;this.colorOverride&&(s.color=this.colorOverride);const r=this._isGrace?1:0;pt.fillMusicFontSymbolSafe(s,e+this.x,t+this.y+r,this.glyphScale,this.symbol,!1),this._articulation.techniqueSymbol!==u.None&&this._articulation.techniqueSymbolPlacement===$e.Inside&&pt.fillMusicFontSymbolSafe(s,e+this.x,t+this.y+r,this.glyphScale,this._articulation.techniqueSymbol,!1),s.color=i}doLayout(){super.doLayout(),this.width===0&&(this.height=this.renderer.smuflMetrics.glyphWidths.get(u.NoteheadBlack)),this.height===0&&(this.height=this.renderer.smuflMetrics.glyphHeights.get(u.NoteheadBlack))}}class bu extends Lt{constructor(e,t){super(e,t,.5,u.PictEdgeOfCymbal),this.center=!0}doLayout(){super.doLayout(),this.offsetY=this.height}}var Ls;(function(a){a[a.NoIntersection=0]="NoIntersection",a[a.EndsTouchingOuter=1]="EndsTouchingOuter",a[a.EndsTouchingInner=2]="EndsTouchingInner",a[a.ExactMatch=3]="ExactMatch",a[a.FullIntersection=4]="FullIntersection"})(Ls||(Ls={}));class Ai{mainVoiceDirection=P.Up;groups=new Map;minX=0;maxX=0;_isFinished=!1;constructor(e){this.mainVoiceDirection=e}update(){let e=0,t=0;for(const s of this.groups.values()){const i=s.minX+s.multiVoiceShiftX,r=s.maxX+s.multiVoiceShiftX;i<e&&(e=i),t<r&&(t=r)}this.minX=e,this.maxX=t}finish(e){if(!this._isFinished){this._isFinished=!0;for(const t of this.groups.values())this._checkForGroupDisplacement(t,e);this.update()}}_checkForGroupDisplacement(e,t){if(this.mainVoiceDirection===e.direction)return;const s=this.groups.get(this.mainVoiceDirection),i=Ai._checkIntersection(s,e),r=t.multiVoiceDis
65placedNoteHeadSpacing;switch(i){case Ls.NoIntersection:return;case Ls.ExactMatch:Ai._canShareNoteHead(s,e)||(s.direction===P.Up?e.displacedNotes?e.multiVoiceShiftX=e.stemX+e.correctNotes.width+r:e.multiVoiceShiftX=e.correctNotes.width+r:s.multiVoiceShiftX=e.stemX+r);break;case Ls.EndsTouchingOuter:if(s.direction===P.Up)if(s.displacedNotes)e.multiVoiceShiftX=s.stemX;else{const n=s.stemX-e.stemX;e.multiVoiceShiftX=n}else if(s.displacedNotes)e.multiVoiceShiftX=-e.stemX;else{const n=e.stemX-s.stemX;s.multiVoiceShiftX=n}break;case Ls.EndsTouchingInner:s.direction===P.Up?(s.multiVoiceShiftX=s.stemX,e.hasFlag&&(s.multiVoiceShiftX+=r)):(e.multiVoiceShiftX=e.stemX,s.hasFlag&&(e.multiVoiceShiftX+=r));break;case Ls.FullIntersection:!s.hasStem&&!e.hasStem||(s.direction===P.Up?(s.multiVoiceShiftX=s.stemX,e.hasFlag?s.multiVoiceShiftX+=r:s.multiVoiceShiftX-=r):(e.multiVoiceShiftX=e.stemX,s.hasFlag?e.multiVoiceShiftX+=r:e.multiVoiceShiftX-=r));break}}static _canShareNoteHead(e,t){const s=e.direction===P.Up?e.maxStep:e.minStep,i=t.direction===P.Up?t.maxStep:t.minStep,r=e.correctNotes.notes.get(s);if(r.length>1)return!1;const n=t.correctNotes.notes.get(i);return n.length>1?!1:Ai._canShareNoteHeadGlyph(r[0].glyph,n[0].glyph)}static _canShareNoteHeadGlyph(e,t){return e.glyphScale===t.glyphScale&&e.centerOnStem===t.centerOnStem&&ii.isBlackNoteHead(e.symbol)&&ii.isBlackNoteHead(t.symbol)}static _checkIntersection(e,t){let s=0;if(e.direction===P.Up){const i=e.maxStep;s=t.minStep-i}else{const i=e.minStep,r=t.maxStep;s=i-r}return s===0?Ls.ExactMatch:s===1?Ls.EndsTouchingOuter:s===-1?Ls.EndsTouchingInner:s<0?Ls.FullIntersection:Ls.NoIntersection}}class Pn extends Nt{_infos=[];_noteHeadInfo;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(e,t){const s={glyph:e,steps:t};this._infos.push(s),(!this.minStepsNote||this.minStepsNote.steps>s.steps)&&(this.minStepsNote=s),(!this.maxStepsNote||this.maxStepsNote.steps<s.steps)&&(this.maxStepsNote=s)}_prepareForLayout(e){const t=this.direction;e.groups||(e.mainVoiceDirection=t),t===P.Up?this._infos.sort((n,o)=>o.steps-n.steps):this._infos.sort((n,o)=>n.steps-o.steps);let s;const i=this.hasFlag,r=this.hasStem;return e.groups.has(t)?(s=e.groups.get(t),i&&(s.hasFlag=i),r&&(s.hasStem=r)):(s={correctNotes:{notes:new Map,width:0,minX:Number.NaN},direction:t,stemX:0,maxX:Number.NaN,minX:Number.NaN,minStep:Number.NaN,maxStep:Number.NaN,multiVoiceShiftX:0,hasFlag:i,hasStem:r},e.groups.set(t,s)),s}doLayout(){const e=this.getScoreChordNoteHeadInfo(),t=this._prepareForLayout(e);this.noteGroup=t,this._noteHeadInfo=e,this._collectNoteDisplacements(t),this._alignNoteHeadsGroup(t),e.update(),this._updateSizes()}_updateSizes(){const e=this.noteGroup;this.onTimeX=e.correctNotes.minX+e.correctNotes.width/2,this.width=this.noteStartX+e.multiVoiceShiftX+e.maxX-e.minX}doMultiVoiceLayout(){this._noteHeadInfo.finish(this.renderer.smuflMetrics),this._updateSizes()}_alignNoteHeadsGroup(e){e.direction===P.Up?(this._alignNoteHeads(e,e.correctNotes,!0),e.displacedNotes&&this._alignNoteHeads(e,e.displacedNotes,!1)):(this._alignNoteHeads(e,e.correctNotes,!1),e.displacedNotes&&this._alignNoteHeads(e,e.displacedNotes,!0))}_alignNoteHeads(e,t,s){const i=this.scale,r=this.renderer.smuflMetrics;for(const n of t.notes.values())for(const o of n){o.glyph.x=e.stemX,o.glyph.centerOnStem||(s?r.stemUp.has(o.glyph.symbol)?o.glyph.x-=r.stemUp.get(o.glyph.symbol).x*i:o.glyph.x-=r.glyphWidths.get(o.glyph.symbol)*i:r.stemDown.has(o.glyph.symbol)&&(o.glyph.x+=r.stemDown.get(o.glyph.symbol).x*i)),t.width=Math.max(t.width,o.glyph.width),(Number.isNaN(t.minX)||o.glyph.x<t.minX)&&(t.minX=o.glyph.x),(Number.isNaN(e.minX)||o.glyph.x<e.minX)&&(e.minX=o.glyph.x);const l=o.glyph.x+o.glyph.width;(Number.isNaN(e.maxX)||l>e.maxX)&&(e.maxX=l)}}static _hasCollision(e,t){return e.notes.has(t.steps)||e.notes.has(t.steps+1)||e.notes.has(t.steps-1)}_collectNoteDisplacements(e){for(const t of this._infos){t.glyph.renderer=this.renderer,t.glyph.doLayout();const s=Pn._hasCollision(e.correctNotes,t);let i;s?(e.displacedNotes||(e.displacedNotes={notes:new Map,width:0,minX:0}),i=e.displacedNotes):i=e.correctNotes;let r;i.notes.has(t.steps)?r=i.notes.get(t.steps):(r=[],i.notes.set(t.steps,r)),r.push(t),(Number.isNaN(e.minStep)||t.steps<e.minStep)&&(e.minStep=t.steps),(Number.isNaN(e.maxStep)||t.steps>e.maxStep)&&(e.maxStep=t.steps),this._updateGroupStemXPosition(t,e)}}_updateGroupStemXPosition(e,t){const s=this.renderer.smuflMetrics,i=this.scale;let r;t.direction===P.Up||t.displacedNotes?s.stemUp.has(e.glyph.symbol)?r=s.stemUp.get(e.glyph.symbol).x*i:r=s.glyphWidths.get(e.glyph.symbol)*i:s.stemDown.has(e.glyph.symbol)?r=s.stemDown.get(e.glyph.symbol).x*i:r=0,r+=this.noteStartX,r>t.stemX&&(t.stemX=r)}
vendor: 45,495 bytes, line 65
65paint(e,t,s){e+=this.x,t+=this.y,this._paintLedgerLines(e,t,s);const i=this.noteGroup;e+=i.multiVoiceShiftX;const r=this._infos;for(const n of r)n.glyph.renderer=this.renderer,n.glyph.paint(e,t,s)}_paintLedgerLines(e,t,s){if(!this.minStepsNote)return;const i=this.renderer,r=xe.bar(s,Le.StandardNotationStaffLine,i.bar,!0);try{const n=this.scale,o=this.renderer.smuflMetrics.legerLineExtension*n,l=this.width+o*2-this.noteStartX,h=i.getLineHeight(1),c=i.getLineY(-1),d=i.getLineY(i.drawnLineCount),f=i.getLineY(this.minStepsNote.steps/2),p=i.getLineY(this.maxStepsNote.steps/2),g=this.renderer.smuflMetrics.legerLineThickness*n/2;let m=c;for(;m>=f;)s.fillRect(e-o+this.noteStartX,t+m-g,l,this.renderer.smuflMetrics.legerLineThickness*n),m-=h;for(m=d;m<=p;)s.fillRect(e-o+this.noteStartX,t+m-g,l,this.renderer.smuflMetrics.legerLineThickness*n),m+=h}finally{r?.[Symbol.dispose]?.()}}}class Nr extends Lt{constructor(e,t,s){super(e,t,1,Nr._getSymbol(s))}static _getSymbol(e){if(e.style===wi.BuzzRoll)return u.BuzzRoll;switch(e.marks){case 1:return u.Tremolo1;case 2:return u.Tremolo2;case 3:return u.Tremolo3;case 4:return u.Tremolo4;case 5:return u.Tremolo5;default:return u.None}}stemExtensionHeight=0;alignTremoloPickingGlyph(e,t,s,i){const r=this.renderer,n=r.smuflMetrics;let o=0;const l=n.glyphHeights.get(u.Tremolo1)/2,h=this.height/2,c=this.symbol===u.Tremolo1,d=r.lineSpacing,f=c?d:d/2;if(e===P.Up){let p=t;p+=n.stemFlagHeight.get(i),p-=n.stemFlagOffsets.get(i),o=f*Math.ceil(p/f);const g=o+h,m=s-d;m<g&&(o=m-h),p+=l;const b=o-h;p>b?this.stemExtensionHeight=p-b:this.stemExtensionHeight=0}else{let p=t;p-=n.stemFlagHeight.get(i),p+=n.stemFlagOffsets.get(i),o=f*Math.floor(p/f);const g=o-h,m=s+d;m>g&&(o=m+h),p-=l;const b=o+h;p<b?this.stemExtensionHeight=b-p:this.stemExtensionHeight=0}this.y=o}}class _u extends Pn{_noteGlyphLookup=new Map;_notes=[];_deadSlapped=null;_tremoloPicking=null;_stemLengthExtension=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!==K.None?We.GraceScale:1}getScoreChordNoteHeadInfo(){if(this.beat.graceType!==K.None)return new Ai(this.direction);const e=this.beat.voice.bar.staff,t=`score.noteheads.${e.track.index}.${e.index}.${this.beat.voice.bar.index}.${this.beat.absoluteDisplayStart}`;let s=this.renderer.staff.getSharedLayoutData(t,void 0);return s||(s=new Ai(this.direction),this.renderer.staff.setSharedLayoutData(t,s)),s}getNoteX(e,t){if(this._noteGlyphLookup.has(e.id)){const s=this._noteGlyphLookup.get(e.id);let i=this.x+s.x;switch(t){case Qe.Left:break;case Qe.Center:i+=s.width/2;break;case Qe.Right:i+=s.width;break}return i}return 0}getNoteY(e,t){if(this._noteGlyphLookup.has(e.id)){const s=this._noteGlyphLookup.get(e.id);return this._internalGetNoteY(s,t)}return 0}getLowestNoteY(e){return this.maxStepsNote?this._internalGetNoteY(this.maxStepsNote.glyph,e):0}getHighestNoteY(e){return this.minStepsNote?this._internalGetNoteY(this.minStepsNote.glyph,e):0}_internalGetNoteY(e,t){let s=this.y+e.y;const i=this.renderer,r=this.beat.graceType!==K.None?We.GraceScale:1;switch(t){case D.TopWithStem:s-=(i.smuflMetrics.stemUp.has(e.symbol)?i.smuflMetrics.stemUp.get(e.symbol).bottomY:0)*r,s-=i.smuflMetrics.getStemLength(this.beat.duration,i.hasFlag(this.beat))*r,s-=this._stemLengthExtension;let n=i.centerStaffStemY(this.direction);return n-=this._stemLengthExtension,Math.min(n,s);case D.Top:s-=e.height/2;break;case D.Center:break;case D.Bottom:s+=e.height/2;break;case D.BottomWithStem:s-=(this.renderer.smuflMetrics.stemDown.has(e.symbol)?this.renderer.smuflMetrics.stemDown.get(e.symbol).topY:-this.renderer.smuflMetrics.glyphHeights.get(e.symbol)/2)*r,s+=i.smuflMetrics.getStemLength(this.beat.duration,i.hasFlag(this.beat))*r,s+=this._stemLengthExtension;let o=i.centerStaffStemY(this.direction);return o+=this._stemLengthExtension,Math.max(o,s);case D.StemUp:s-=(i.smuflMetrics.stemUp.has(e.symbol)?i.smuflMetrics.stemUp.get(e.symbol).bottomY:0)*r;break;case D.StemDown:s-=(i.smuflMetrics.stemDown.has(e.symbol)?i.smuflMetrics.stemDown.get(e.symbol).topY:-i.smuflMetrics.glyphHeights.get(e.symbol)/2)*r;break}return s}addMainNoteGlyph(e,t,s){super.add(e,s),this._noteGlyphLookup.set(t.id,e),this._notes.push(t)}addEffectNoteGlyph(e,t){super.add(e,t)}doLayout(){super.doLayout();const e=this.renderer;this.beat.deadSlapped&&(this._deadSlapped=new xn,this._deadSlapped.renderer=this.renderer,this._deadSlapped.doLayout(),this.width=this._deadSlapped.width,this.onTimeX=this.width/2);let t=0,s=0;const i=this.renderer.smuflMetrics.onNoteEffectPadding;this.beat.deadSlapped?(s=e.getScoreY(0),t=e.getScoreY(e.heightLineCount)):this.direction===P.Up?(s=this._internalGetNoteY(this.maxStepsNote.glyph,D.Bottom)+i,t=this._internalGetNoteY(this.minStepsNote.glyph,D.TopWithStem)-i):(s=this._internalGetNoteY(this.maxStepsNote.glyph,D.BottomWithStem)+i,t=this._internalGetNoteY(this.minStepsNote.glyph,D.Top)-i);let r=null,n=null;for(const o of this.aboveBeatEffects.values())o.renderer=this.renderer,o.doLayout(),t-=o.height,o.y=t,(r===null||r>t)&&(r=t),(n===null||n<t)&&(n=t),t-=i;for(const o of this.belowBeatEffects.values())o.renderer=this.renderer,o.doLayout(),o.y=s,(r===null||r>s)&&(r=s),(n===null||n<s)&&(n=s),s+=o.height+i;r!==null&&e.registerBeatEffectOverflows(r,n??0),this.beat.isTremolo&&!this.beat.deadSlapped&&(this._tremoloPicking=new Nr(0,0,this.beat.tremoloPicking),this._tremoloPicking.renderer=this.renderer,this._tremoloPicking.doLayout(),this._alignTremoloPickingGlyph())}_alignTremoloPickingGlyph(){const e=this._tremoloPicking,t=this.direction;t===P.Up?e.alignTremoloPickingGlyph(t,this.getHighestNoteY(D.TopWithStem),this.getHighestNoteY(D.Center),this.beat.duration):e.alignTremoloPickingGlyph(t,this.getLowestNoteY(D.BottomWithStem),this.getLowestNoteY(D.Center),this.beat.duration),this._stemLengthExtension=e.stemExtensionHeight;let s=this.stemX;this.beat.duration<y.Half&&(s=this.width/2),e.x=s}buildBoundingsLookup(e,t,s){for(const i of this._notes)if(this._noteGlyphLookup.has(i.id)){const r=this._noteGlyphLookup.get(i.id),n=new xr;n.note=i,n.noteHeadBounds=new bt,n.noteHeadBounds.x=t+this.x+r.x,n.noteHeadBounds.y=s+this.y+r.y-r.height/2,n.noteHeadBounds.w=r.width,n.noteHeadBounds.h=r.height,e.addNote(n)}}paint(e,t,s){this._paintEffects(e,t,s),super.paint(e,t,s)}_paintEffects(e,t,s){const i=xe.beat(s,rt.StandardNotationEffects,this.beat);try{for(const r of this.aboveBeatEffects.values())r.paint(e+this.x+this.width/2,t+this.y,s);for(const r of this.belowBeatEffects.values())r.paint(e+this.x+this.width/2,t+this.y,s);this._tremoloPicking&&this._tremoloPicking.paint(e,t,s),this._deadSlapped&&this._deadSlapped.paint(e,t,s)}finally{i?.[Symbol.dispose]?.()}}}class da extends Lt{constructor(e,t,s){super(e,t,1,da.getSymbol(s))}static getSymbol(e){switch(e){case y.QuadrupleWhole:return u.RestLonga;case y.DoubleWhole:return u.RestDoubleWhole;case y.Whole:return u.RestWhole;case y.Half:return u.RestHalf;case y.Quarter:return u.RestQuarter;case y.Eighth:return u.Rest8th;case y.Sixteenth:return u.Rest16th;case y.ThirtySecond:return u.Rest32nd;case y.SixtyFourth:return u.Rest64th;case y.OneHundredTwentyEighth:return u.Rest128th;case y.TwoHundredFiftySixth:return u.Rest256th;default:return u.None}}paint(e,t,s){this.internalPaint(e,t,s,rt.StandardNotationRests)}internalPaint(e,t,s,i){const r=xe.beat(s,i,this.beat);try{super.paint(e,t,s)}finally{r?.[Symbol.dispose]?.()}}}class ki extends Pn{_beat;_showParenthesis=!1;_noteValueLookup=new Map;_accidentals=new Go;_preNoteParenthesis=null;_postNoteParenthesis=null;isEmpty=!0;_groupId;get scale(){return We.GraceScale}get hasFlag(){return!1}get hasStem(){return!1}get direction(){return P.Up}constructor(e,t,s=!1){super(),this._beat=t,this._groupId=e,this._showParenthesis=s,s&&(this._preNoteParenthesis=new dn(!0),this._postNoteParenthesis=new dn(!1))}getScoreChordNoteHeadInfo(){const e=this._beat.voice.bar.staff,t=`score.noteheads.${this._groupId}.${e.track.index}.${e.index}.${this._beat.absoluteDisplayStart}`;let s=this.renderer.staff.getSharedLayoutData(t,void 0);return s||(s=new Ai(this.direction),this.renderer.staff.setSharedLayoutData(t,s)),new Ai(this.direction)}containsNoteValue(e){return this._noteValueLookup.has(e)}getNoteValueY(e){return this._noteValueLookup.has(e)?this.y+this._noteValueLookup.get(e).y:0}addGlyph(e,t,s){const i=this.renderer,r=new gr(0,0,y.Quarter,!0),n=i.accidentalHelper.applyAccidentalForValue(this._beat,e,t,!0),o=i.accidentalHelper.getNoteStepsForValue(e,!1);if(r.y=i.getScoreY(o),this._showParenthesis&&(this._preNoteParenthesis.renderer=this.renderer,this._postNoteParenthesis.renderer=this.renderer,this._preNoteParenthesis.addParenthesisOnSteps(o,!0),this._postNoteParenthesis.addParenthesisOnSteps(o,!0)),n!==ee.None){const l=new ci(0,r.y,n,We.GraceScale);l.renderer=this.renderer,this._accidentals.renderer=this.renderer,this._accidentals.addGlyph(l)}this._noteValueLookup.set(e,r),this.add(r,o),this.isEmpty=!1}doLayout(){let e=0;this._showParenthesis&&(this._preNoteParenthesis.x=e,this._preNoteParenthesis.renderer=this.renderer,this._preNoteParenthesis.doLayout(),e+=this._preNoteParenthesis.width+this.renderer.smuflMetrics.bendNoteHeadElementPadding),this._accidentals.isEmpty||(e+=this._accidentals.width+this.renderer.smuflMetrics.bendNoteHeadElementPadding,this._accidentals.x=e,this._accidentals.renderer=this.renderer,this._accidentals.doLayout(),e+=this._accidentals.width+this.renderer.smuflMetrics.bendNoteHeadElementPadding),this.noteStartX=e,super.doLayout(),this._showParenthesis&&(this._postNoteParenthesis.x=this.width+this.renderer.smuflMetrics.bendNoteHeadElementPadding,this._postNoteParenthesis.renderer=this.renderer,this._postNoteParenthesis.doLayout(),this.width+=this._postNoteParenthesis.width+this.renderer.smuflMetrics.bendNoteHeadElementPadding)}paint(e,t,s){this._accidentals.isEmpty||this._accidentals.paint(e+this.x,t+this.y,s),this._showParenthesis&&(this._preNoteParenthesis.paint(e+this.x,t+this.y,s),this._postNoteParenthesis.paint(e+this.x,t+this.y,s)),super.paint(e,t,s)}}class yh extends js{drawBendSlur(e,t,s,i,r,n,o){Ot.drawBendSlur(e,t,s,i,r,n,this.renderer.smuflMetrics.tieHeight,o)}doLayout(){if(this.glyphs){this.width=0;for(const e of this.glyphs)e.doLayout(),this.width+=e.width}}getTieDirection(e,t){return t.getBeatDirection(e)===P.Up?P.Down:P.Up}}class Su extends yh{_container;_beat;_endGlyph=null;checkForOverflow=!1;constructor(e){super(0,0),this._container=e,this._beat=e.beat}get hasBoundingBox(){const e=this._endGlyph;return e?!!e.minStepsNote&&!!e.maxStepsNote:!1}getBoundingBoxTop(){return this._endGlyph?.minStepsNote?this._endGlyph.minStepsNote.glyph.getBoundingBoxTop():super.getBoundingBoxTop()}getBoundingBoxBottom(){return this._endGlyph?.maxStepsNote?this._endGlyph.maxStepsNote.glyph.getBoundingBoxBottom():super.getBoundingBoxBottom()}doMultiVoiceLayout(){this._endGlyph?.doMultiVoiceLayout()}doLayout(){const e=this.renderer,t=e.settings.notation.notationMode;switch(this._beat.whammyBarType){case Pe.None:case Pe.Custom:case Pe.Hold:return;case Pe.Dive:case Pe.PrediveDive:{const s=new ki("postwhammy",this._beat,!1);this._endGlyph=s,s.renderer=e;const i=this._beat.whammyBarPoints[this._beat.whammyBarPoints.length-1];for(const r of this._beat.notes)r.isTieOrigin||s.addGlyph(this._getBendNoteValue(r,i),i.value%2!==0,void 0);s.doLayout(),this.addGlyph(s)}break;case Pe.Dip:{if(t===Vt.SongBook)return;{const s=new ki("middlewhammy",this._beat,!1);if(s.renderer=e,e.settings.notation.notationMode===Vt.GuitarPro){const r=this._beat.whammyBarPoints[1];for(const n of this._beat.notes)s.addGlyph(this._getBendNoteValue(n,this._beat.whammyBarPoints[1]),r.value%2!==0,void 0)}s.doLayout(),this.addGlyph(s);const i=new ki("postwhammy",this._beat,!1);if(i.renderer=e,this._endGlyph=i,e.settings.notation.notationMode===Vt.GuitarPro){const r=this._beat.whammyBarPoints[this._beat.whammyBarPoints.length-1];for(const n of this._beat.notes)i.addGlyph(this._getBendNoteValue(n,r),r.value%2!==0,void 0)}i.doLayout(),this.addGlyph(i)}}break;case Pe.Predive:break}super.doLayout(),this.width=this.width/2}paint(e,t,s){const i=this._beat;switch(i.whammyBarType){case Pe.None:case Pe.Custom:return}const r=this.renderer.settings.notation.notationMode,n=this.renderer.scoreRenderer.layout.getRendererForBar(this.renderer.staff.staffId,i.voice.bar),o=xe.beat(s,rt.StandardNotationEffects,i);try{const l=e+n.x+n.getBeatX(i,ae.MiddleNotes),h=this.getTieDirection(i,n);let c=this._beat.notes.length===1?h:P.Up;const d=s.textAlign,f=this.renderer.smuflMetrics.glyphHeights.get(u.NoteheadBlack);for(let p=0;p<i.notes.length;p++){const g=i.notes[p],m=xe.note(s,$t.StandardNotationEffects,g);try{let b=t+n.y;p>0&&p>=(this._beat.notes.length/2|0)&&(c=P.Down),c===P.Down?b+=n.getNoteY(g,D.Bottom):b+=n.getNoteY(g,D.Top);let S=e+n.x+n.getBeatX(i,ae.EndBeat);if(S-=this.renderer.smuflMetrics.postNoteEffectPadding,this._endGlyph){const Q=this._endGlyph.width-this._endGlyph.onTimeX;S-=Q}const N=i.whammyStyle===Ke.Gradual&&p===0?"grad.":"";let v=null;g.isTieOrigin&&(v=this.renderer.scoreRenderer.layout.getRendererForBar(this.renderer.staff.staffId,g.tieDestination.beat.voice.bar),v&&v.staff===n.staff?S=e+v.x+v.getBeatX(g.tieDestination.beat,ae.MiddleNotes):v=null);let W=f*We.GraceScale*.5;c===P.Up&&(W=-W);const j=i.whammyBarPoints.length>0?this._getBendNoteValue(g,i.whammyBarPoints[i.whammyBarPoints.length-1]):0;let q=0,F=!1;switch(this.glyphs&&this.glyphs[0].containsNoteValue(j)?(q=this.glyphs[0].getNoteValueY(j)+W,F=!0):v&&(g.isTieOrigin&&g.tieDestination.beat.hasWhammyBar||g.beat.isContinuedWhammy)?(q=t+v.y+v.getNoteY(g.tieDestination,D.Top),F=!0,c===P.Down&&(q+=f)):g.isTieOrigin&&(v?q=t+v.y+v.getNoteY(g.tieDestination,D.Top):q=b,c===P.Down&&(q+=f)),i.whammyBarType){case Pe.Hold:g.isTieOrigin&&Ot.paintTie(s,1,l,b,S,q,h===P.Down,this.renderer.smuflMetrics.tieHeight,this.renderer.smuflMetrics.slurMidpointThickness);break;case Pe.Dive:if(p===0){const ge=this.glyphs[0];ge.x=S-ge.onTimeX;const re=this.glyphs[0].y;ge.y=t+n.y,ge.paint(0,0,s),ge.containsNoteValue(j)&&(q-=re,q+=ge.y)}F?this.drawBendSlur(s,l,b,S,q,c===P.Down,N):g.isTieOrigin&&Ot.paintTie(s,1,l,b,S,q,h===P.Down,this.renderer.smuflMetrics.tieHeight,this.renderer.smuflMetrics.slurMidpointThickness);break;case Pe.Dip:if(r===Vt.SongBook)g.isTieOrigin&&Ot.paintTie(s,1,l,b,S,q,h===P.Down,this.renderer.smuflMetrics.tieHeight,this.renderer.smuflMetrics.slurMidpointThickness);else{const ge=(l+S)/2,re=this.glyphs[0];re.x=ge-re.onTimeX,re.y=t+n.y,re.paint(0,0,s);const Je=this._getBendNoteValue(g,i.whammyBarPoints[1]),lt=re.getNoteValueY(Je)+W;this.drawBendSlur(s,l,b,ge,lt,c===P.Down,N);const De=this.glyphs[1];De.x=S-De.onTimeX,De.y=t+n.y,De.paint(0,0,s),q=De.getNoteValueY(j)+W,this.drawBendSlur(s,ge,lt,S,q,c===P.Down,N)}break;case Pe.PrediveDive:case Pe.Predive:let Q=e+n.x+n.getBeatX(g.beat,ae.PreNotes);Q+=this._container.prebendNoteHeadOffset;const me=t+n.y+n.getScoreY(n.accidentalHelper.getNoteStepsForValue(g.displayValue-(g.beat.whammyBarPoints[0].value/2|0),!1))+W;if(this.drawBendSlur(s,Q,me,l,b,c===P.Down,N),this.glyphs){const ge=this.glyphs[0];ge.x=S-ge.onTimeX,ge.y=t+n.y,ge.paint(0,0,s),this.drawBendSlur(s,l,b,S,q,c===P.Down,N)}break}}finally{m?.[Symbol.dispose]?.()}}s.textAlign=d}finally{o?.[Symbol.dispose]?.()}}_getBendNoteValue(e,t){return e.displayValueWithoutBend+(t.value/2|0)}}class wr extends ca{beatEffects=new Map;noteHeadElement=$t.SlashNoteHead;effectElement=rt.SlashEffects;stemX=0;constructor(e,t,s){super(e,t,s.graceType!==K.None,wr.getSymbol(s.duration)),this.beat=s}paint(e,t,s){const i=this.beat.notes.length===0?void 0:xe.note(s,this.noteHeadElement,this.beat.notes[0]);try{super.paint(e,t,s),this._paintEffects(e,t,s)}finally{i?.[Symbol.dispose]?.()}}_paintEffects(e,t,s){const i=xe.beat(s,this.effectElement,this.beat);try{for(const r of this.beatEffects.values())r.paint(e+this.x,t+this.y,s)}finally{i?.[Symbol.dispose]?.()}}doLayout(){super.doLayout();const e=this.renderer,t=e.smuflMetrics.onNoteEffectPadding;let s=e.smuflMetrics.glyphHeights.get(this.symbol),i=Number.NaN,r=Number.NaN;for(const l of this.beatEffects.values())l.y+=s,l.x+=this.width/2,l.renderer=e,s+=l.height+t,l.doLayout(),(Number.isNaN(i)||i>s)&&(i=s),(Number.isNaN(r)||r<s)&&(r=s);Number.isNaN(i)||e.registerBeatEffectOverflows(i,r);const n=e.getBeatDirection(this.beat),o=this.symbol;if(n===P.Up){const l=e.smuflMetrics.stemUp.has(o)?e.smuflMetrics.stemUp.get(o).x:0;this.stemX=l}else{const l=e.smuflMetrics.stemDown.has(o)?e.smuflMetrics.stemDown.get(o).x:0;this.stemX=l}}static getSymbol(e){switch(e){case y.QuadrupleWhole:case y.DoubleWhole:case y.Whole:return u.NoteheadSlashWhiteWhole;case y.Half:return u.NoteheadSlashWhiteHalf;default:return u.NoteheadSlashHorizontalEnds}}}class ku extends fs{_strings=new Set;addString(e){this._strings.add(e)}doLayout(){const e=this.renderer.smuflMetrics.glyphWidths.get(u.GuitarString0)*this.renderer.smuflMetrics.tuningGlyphCircleNumberScale;this.height=(e+this.renderer.smuflMetrics.stringNumberCirclePadding)*this._strings.size,this.width=e}paint(e,t,s){const i=this.renderer.bar.staff.tuning.length;let r=0;const n=this.renderer.smuflMetrics.glyphWidths.get(u.GuitarString0)*this.renderer.smuflMetrics.tuningGlyphCircleNumberScale;for(const o of this._strings){const l=i-o,h=u.GuitarString1+l;pt.fillMusicFontSymbolSafe(s,e+this.x,t+this.y+n+r,this.renderer.smuflMetrics.tuningGlyphCircleNumberScale,h,!0),r+=n+this.renderer.smuflMetrics.stringNumberCirclePadding}}}class wu extends Tn{_collisionOffset=Number.NaN;_skipPaint=!1;_whammy;noteHeads=null;restGlyph=null;get effectElement(){return rt.StandardNotationEffects}buildBoundingsLookup(e,t,s){this.noteHeads&&this.noteHeads.buildBoundingsLookup(e,t+this.x,s+this.y)}getBoundingBoxTop(){let e=this.y;return this.noteHeads?e=this.noteHeads.getBoundingBoxTop():this.restGlyph&&(e=this.restGlyph.getBoundingBoxTop()),this._whammy?.hasBoundingBox&&(e=Math.min(e,this._whammy.getBoundingBoxTop())),e}getBoundingBoxBottom(){let e=this.y+this.height;return this.noteHeads?e=this.noteHeads.getBoundingBoxBottom():this.restGlyph&&(e=this.restGlyph.getBoundingBoxBottom()),this._whammy?.hasBoundingBox&&(e=Math.max(e,this._whammy.getBoundingBoxBottom())),e}getLowestNoteY(e){return this.noteHeads?this.noteHeads.getLowestNoteY(e):0}getHighestNoteY(e){return this.noteHeads?this.noteHeads.getHighestNoteY(e):0}getNoteY(e,t){return e.beat.slashed&&(e=e.beat.notes[0]),this.noteHeads?this.noteHeads.getNoteY(e,t):0}getNoteX(e,t){return e.beat.slashed&&(e=e.beat.notes[0]),this.noteHeads?this.noteHeads.getNoteX(e,t):0}getRestY(e){const t=this.restGlyph;if(t)switch(e){case D.TopWithStem:return t.getBoundingBoxTop()-this.renderer.smuflMetrics.getStemLength(y.Quarter,!0);case D.Top:return t.getBoundingBoxTop();case D.Center:case D.StemUp:case D.StemDown:return t.getBoundingBoxTop()+t.height/2;case D.Bottom:return t.getBoundingBoxBottom();case D.BottomWithStem:return t.getBoundingBoxBottom()+this.renderer.smuflMetrics.getStemLength(y.Quarter,!0)}return 0}applyRestCollisionOffset(){if(this.restGlyph&&Number.isNaN(this._collisionOffset)){this._collisionOffset=this.renderer.collisionHelper.applyRestCollisionOffset(this.container.beat,this.restGlyph.y,this.renderer.getScoreHeight(1)),this.y+=this._collisionOffset;const e=this.renderer.collisionHelper.restDurationsByDisplayTime;e.has(this.container.beat.playbackStart)&&e.get(this.container.beat.playbackStart).has(this.container.beat.playbackDuration)&&e.get(this.container.beat.playbackStart).get(this.container.beat.playbackDuration)!==this.container.beat.id&&(this._skipPaint=!0)}}paint(e,t,s){this._skipPaint||super.paint(e,t,s)}doMultiVoiceLayout(){this.applyRestCollisionOffset(),this.noteHeads?.doMultiVoiceLayout(),this._whammy?.doMultiVoiceLayout();let e=0;if(this.glyphs)for(const t of this.glyphs)t.x=e,e+=t.width;this.width=e,this.computedWidth=e,this._updatePositions()}doLayout(){this._createGlyphs(),super.doLayout(),this._updatePositions()}_updatePositions(){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)}_createGlyphs(){this.container.beat.isEmpty||(this.container.beat.isRest?this._createRestGlyphs():this._createNoteGlyphs())}_createNoteGlyphs(){const e=this.renderer,t=new _u;this.noteHeads=t,t.beat=this.container.beat;const s=new dn(!1);if(s.renderer=this.renderer,this.container.beat.slashed){const i=e.heightLineCount-1,r=new wr(0,e.getScoreY(i),this.container.beat);r.colorOverride=xe.noteColor(e.resources,$t.StandardNotationNoteHead,this.container.beat.notes[0]),this.noteHeads.addMainNoteGlyph(r,this.container.beat.notes[0],i)}else for(const i of this.container.beat.notes)i.isVisible&&(this._createNoteGlyph(i),s.addParenthesis(i));if(this.addNormal(t),s.isEmpty||this.addEffect(s),this.container.beat.hasWhammyBar){const i=new Su(this.container);this._whammy=i,i.renderer=this.renderer,i.doLayout(),this.container.addTie(i)}if(this.container.beat.dots>0)for(let i=0;i<this.container.beat.dots;i++){const r=new js(0,0);r.renderer=this.renderer;for(const n of this.container.beat.notes){const o=this._createBeatDot(e.getNoteSteps(n),r);o.colorOverride=xe.noteColor(e.resources,$t.StandardNotationEffects,n)}this.addEffect(r)}if(this.renderer.bar.isMultiVoice){let i=0,r=0;const n=e.getBeatDirection(this.container.beat);let o=0;this.container.beat.hasTuplet&&(o+=e.tupletOffset+e.tupletSize),n===P.Up?(i=this.getHighestNoteY(D.TopWithStem)-o,r=this.getLowestNoteY(D.Bottom)):(i=this.getHighestNoteY(D.Top),r=this.getLowestNoteY(D.BottomWithStem)+o),this.renderer.collisionHelper.reserveBeatSlot(this.container.beat,i,r)}}_createRestGlyphs(){const e=this.renderer;let t=Math.ceil((this.renderer.bar.staff.standardNotationLineCount-1)/2)*2;this.container.beat.duration===y.Whole&&this.renderer.bar.staff.standardNotationLineCount!==1&&this.renderer.bar.staff.standardNotationLineCount!==3&&(t-=2);const s=new da(0,e.getScoreY(t),this.container.beat.duration);if(this.restGlyph=s,s.beat=this.container.beat,this.addNormal(s),this.renderer.bar.isMultiVoice)if(this.container.beat.voice.index===0){const i=_s.computeLineHeightsForRest(this.container.beat.duration),r=s.y-e.getScoreHeight(i[0]),n=s.y+e.getScoreHeight(i[1]);this.renderer.collisionHelper.reserveBeatSlot(this.container.beat,r,n)}else this.renderer.collisionHelper.registerRest(this.container.beat);if(this.container.beat.dots>0)for(let i=0;i<this.container.beat.dots;i++){const r=new js(0,0);r.renderer=this.renderer,this._createBeatDot(t,r),this.addEffect(r)}}_createBeatDot(e,t){const s=this.renderer,i=new ia(0,s.getScoreY(e));return t.addGlyph(i),i}_createNoteHeadGlyph(e){const t=this.container.beat.graceType!==K.None,s=e.style;if(s?.noteHead!==void 0){const i=new gr(0,0,e.beat.duration,t);return i.symbol=s.noteHead,s.noteHeadCenterOnStem&&(i.centerOnStem=!0),i}if(e.beat.voice.bar.staff.isPercussion){const i=Xe.getArticulation(e);if(i)return new yu(0,0,i,e.beat.duration,t);E.warning("Rendering",`No articulation found for percussion instrument ${e.percussionArticulation}`)}return e.isDead?new mu(0,0,t):e.beat.graceType===K.BendGrace?new gr(0,0,y.Quarter,!0):e.harmonicType===te.Natural?new cn(0,0,e.beat.duration,t):new gr(0,0,e.beat.duration,t)}_createNoteGlyph(e){if(e.beat.graceType===K.BendGrace&&!e.hasBend)return;const t=this.renderer,s=this._createNoteHeadGlyph(e);s.colorOverride=xe.noteColor(t.resources,$t.StandardNotationNoteHead,e);let i=t.getNoteSteps(e);if(s.y=t.getScoreY(i),this.noteHeads.addMainNoteGlyph(s,e,i),!e.beat.slashed&&e.harmonicType!==te.None&&e.harmonicType!==te.Natural){const l=e.displayValue+e.harmonicPitch,h=new cn(0,0,e.beat.duration,this.container.beat.graceType!==K.None);h.colorOverride=s.colorOverride,i=t.accidentalHelper.getNoteStepsForValue(l,!1),h.y=t.getScoreY(i),this.noteHeads.addEffectNoteGlyph(h,i)}const r=this.noteHeads.belowBeatEffects,n=this.noteHeads.aboveBeatEffects,o=t.getBeatDirection(this.container.beat)===P.Up?this.noteHeads.belowBeatEffects:this.noteHeads.aboveBeatEffects;if(e.isStaccato&&!r.has("Staccato")&&o.set("Staccato",new Il(0,0)),e.accentuated===ct.Normal&&!r.has("Accent")&&o.set("Accent",new Jr(0,0,e)),e.accentuated===ct.Heavy&&!r.has("HAccent")&&o.set("HAccent",new Jr(0,0,e)),e.accentuated===ct.Tenuto&&!r.has("Tenuto")&&o.set("Tenuto",new Jr(0,0,e)),e.showStringNumber&&e.isStringed){let l;n.has("StringNumber")?l=n.get("StringNumber"):(l=new ku(0,0),n.set("StringNumber",l)),l.addString(e.string)}if(e.isPercussion){const l=Xe.getArticulation(e);if(l&&l.techniqueSymbolPlacement!==$e.Inside){let h;switch(l.techniqueSymbolPlacement){case $e.Above:h=this.noteHeads.aboveBeatEffects;break;case $e.Below:h=this.noteHeads.belowBeatEffects;break;case $e.Outside:h=o;break;default:return}switch(l.techniqueSymbol){case u.PictEdgeOfCymbal:h.set("PictEdgeOfCymbal",new bu(0,0));break;case u.ArticStaccatoAbove:h.set("ArticStaccatoAbove",new Il(0,0));break;case u.StringsUpBow:h.set("StringsUpBow",new sa(0,0,Ct.Up));break;case u.StringsDownBow:h.set("StringsDownBow",new sa(0,0,Ct.Down));break;case u.GuitarGolpe:h.set("GuitarGolpe",new lh(0,0,!0));break}}}}}class Bu extends Nt{_beat;_noteVibratoGlyph;constructor(e){super(0,0),this._beat=e}doLayout(){if(this._beat.brushType===z.ArpeggioUp||this._beat.brushType===z.ArpeggioDown){const e=new Ri(0,0,Be.Slight,!0);e.renderer=this.renderer,e.doLayout(),this._noteVibratoGlyph=e,this.width=e.height}else this.width=0}paint(e,t,s){if(this._beat.brushType===z.ArpeggioUp||this._beat.brushType===z.ArpeggioDown){const i=this.renderer,r=i.lineOffset,n=t+this.y+(i.getNoteY(this._beat.maxNote,D.Bottom)-r),o=t+this.y+i.getNoteY(this._beat.minNote,D.Top)+r,l=e+this.x+this.width/2,h=this.renderer.smuflMetrics.glyphWidths.get(u.ArrowheadBlackDown),c=this._noteVibratoGlyph;if(this._beat.brushType===z.ArpeggioUp){const d=n+h,f=o-h;c.width=Math.abs(f-d),s.beginRotate(e+this.x,f,-90),c.paint(0,0,s),s.endRotate(),s.beginPath(),s.moveTo(l,o),s.lineTo(l+h/2,o-h),s.lineTo(l-h/2,o-h),s.closePath(),s.fill()}else if(this._beat.brushType===z.ArpeggioDown){const d=n+h,f=o;c.width=Math.abs(f-d),s.beginRotate(e+this.x,d,90),c.paint(0,-c.height,s),s.endRotate(),s.beginPath(),s.moveTo(l,n),s.lineTo(l+h/2,n+h),s.lineTo(l-h/2,n+h),s.closePath(),s.fill()}}}}class Tu extends la{_prebends=null;get prebendNoteHeadOffset(){return this._prebends?this._prebends.x+this._prebends.onTimeX:0}get effectElement(){return rt.StandardNotationEffects}accidentals=null;doMultiVoiceLayout(){this._prebends?.doMultiVoiceLayout()}doLayout(){this.container.beat.isRest||this._createGlyphs(),super.doLayout()}_createGlyphs(){const e=new Go;e.renderer=this.renderer;const t=new ta;t.renderer=this.renderer;const s=new dn(!0);s.renderer=this.renderer;let i=null,r=!1;for(const n of this.container.beat.notes){const o=xe.noteColor(this.renderer.resources,$t.StandardNotationEffects,n);if(n.isVisible){if(n.hasBend)switch(n.bendType){case $.PrebendBend:case $.Prebend:case $.PrebendRelease:i||(i=new ki("prebend",this.container.beat,!0),i.renderer=this.renderer),i.addGlyph(n.displayValue-(n.bendPoints[0].value/2|0),!1,o);break}else if(n.beat.hasWhammyBar)switch(n.beat.whammyBarType){case Pe.PrediveDive:case Pe.Predive:i||(i=new ki("prebend",this.container.beat,!0),i.renderer=this.renderer),i.addGlyph(n.displayValue-(n.beat.whammyBarPoints[0].value/2|0),!1,o);break}switch(this._createAccidentalGlyph(n,e),s.addParenthesis(n),t.addFingers(n),n.slideInType){case St.IntoFromBelow:case St.IntoFromAbove:r=!0;break}}}r&&this.addNormal(new is(0,0,this.renderer.smuflMetrics.simpleSlideWidth*(this.container.beat.graceType!==K.None?We.GraceScale:1))),this._prebends=i,i&&(this.addEffect(i),this.addNormal(new is(0,0,this.renderer.smuflMetrics.preNoteEffectPadding*(this.container.beat.graceType!==K.None?We.GraceScale:1)))),this.container.beat.brushType!==z.None&&(this.addEffect(new Bu(this.container.beat)),this.addNormal(new is(0,0,this.renderer.smuflMetrics.preNoteEffectPadding*(this.container.beat.graceType!==K.None?We.GraceScale:1)))),t.isEmpty||(this.isEmpty||this.addNormal(new is(0,0,this.renderer.smuflMetrics.preNoteEffectPadding*(this.container.beat.graceType!==K.None?We.GraceScale:1))),this.addEffect(t),this.addNormal(new is(0,0,this.renderer.smuflMetrics.preNoteEffectPadding*(this.container.beat.graceType!==K.None?We.GraceScale:1)))),s.isEmpty||this.addEffect(s),e.isEmpty||(this.accidentals=e,this.isEmpty||this.addNormal(new is(0,0,this.renderer.smuflMetrics.preNoteEffectPadding*(this.container.beat.graceType!==K.None?We.GraceScale:1))),this.addNormal(e),this.addNormal(new is(0,0,this.renderer.smuflMetrics.preNoteEffectPadding*(this.container.beat.graceType!==K.None?We.GraceScale:1))))}_createAccidentalGlyph(e,t){const s=this.renderer;let i=s.accidentalHelper.applyAccidental(e),r=s.getNoteSteps(e);const n=this.container.beat.graceType!==K.None,o=xe.noteColor(s.resources,$t.StandardNotationAccidentals,e),l=n?We.GraceScale:1;if(i!==ee.None){const h=new ci(0,s.getScoreY(r),i,l);h.colorOverride=o,h.renderer=this.renderer,t.addGlyph(h)}if(e.harmonicType!==te.None&&e.harmonicType!==te.Natural){const h=e.displayValue+e.harmonicPitch;i=s.accidentalHelper.applyAccidentalForValue(e.beat,h,n,!1),r=s.accidentalHelper.getNoteStepsForValue(h,!1);const c=new ci(0,s.getScoreY(r),i,l);c.colorOverride=o,c.renderer=this.renderer,t.addGlyph(c)}}}class xu extends yh{_beat;_notes=[];_endNoteGlyph=null;_middleNoteGlyph=null;_container;checkForOverflow=!1;constructor(e){super(0,0),this._beat=e.beat,this._container=e}doLayout(){super.doLayout(),this.width=0}getBoundingBoxTop(){return super.getBoundingBoxTop()-this._calculateMaxSlurHeight(P.Up)}getBoundingBoxBottom(){return super.getBoundingBoxBottom()+this._calculateMaxSlurHeight(P.Down)}doMultiVoiceLayout(){this._middleNoteGlyph?.doMultiVoiceLayout(),this._endNoteGlyph?.doMultiVoiceLayout()}_calculateMaxSlurHeight(e){const t=this.getTieDirection(this._beat,this.renderer);if(t!==e)return 0;let s=0;for(const i of this._notes){if(i.isTieOrigin)continue;switch(i.bendType){case $.Custom:case $.Prebend:case $.Hold:continue}const n=this.renderer.getBeatContainer(this._beat).width*2;let o=0,l=0;switch(i.bendType){case $.Bend:case $.PrebendBend:o=this._endNoteGlyph.minStepsNote.glyph.getBoundingBoxTop(),l=n;break;case $.BendRelease:o=this._middleNoteGlyph.minStepsNote.glyph.getBoundingBoxTop(),l=n/2;break;case $.Release:case $.PrebendRelease:o=this._endNoteGlyph.maxStepsNote.glyph.getBoundingBoxTop(),l=n;break}const h=this.renderer.getNoteY(i,D.Top);let c=Math.abs(Ot.calculateBendSlurTopY(0,h,l,o,t===P.Down,1,this.renderer.smuflMetrics.tieHeight)-o);if(i.bendStyle===Ke.Gradual){const d=this.renderer.resources,f=this.renderer.scoreRenderer.canvas;f.font=d.elementFonts.get(C.ScoreBendSlur),c+=f.measureText("grad.").height}c>s&&(s=c)}return s}addBends(e){if(this._notes.push(e),e.isTieOrigin)return;const t=xe.noteColor(this.renderer.resources,$t.StandardNotationEffects,e);switch(e.bendType){case $.Bend:case $.PrebendRelease:case $.PrebendBend:{let s=this._endNoteGlyph;s||(s=new ki("postbend",e.beat,!1),s.renderer=this.renderer,this._endNoteGlyph=s,this.addGlyph(s));const i=e.bendPoints[e.bendPoints.length-1];s.addGlyph(this._getBendNoteValue(e,i),i.value%2!==0,t)}break;case $.Release:if(!e.isTieOrigin){let s=this._endNoteGlyph;s||(s=new ki("postbend",e.beat,!1),s.renderer=this.renderer,this._endNoteGlyph=s,this.addGlyph(s));const i=e.bendPoints[e.bendPoints.length-1];s.addGlyph(this._getBendNoteValue(e,i),i.value%2!==0,t)}break;case $.BendRelease:{let s=this._middleNoteGlyph;s||(s=new ki("middlebend",e.beat,!1),this._middleNoteGlyph=s,s.renderer=this.renderer,this.addGlyph(s));const i=e.bendPoints[1];s.addGlyph(this._getBendNoteValue(e,e.bendPoints[1]),i.value%2!==0,t);let r=this._endNoteGlyph;r||(r=new ki("postbend",e.beat,!1),r.renderer=this.renderer,this._endNoteGlyph=r,this.addGlyph(r));const n=e.bendPoints[e.bendPoints.length-1];r.addGlyph(this._getBendNoteValue(e,n),n.value%2!==0,t)}break}}paint(e,t,s){const i=this.renderer.scoreRenderer.layout.getRendererForBar(this.renderer.staff.staffId,this._beat.voice.bar),r=e+i.x+i.getBeatX(this._beat,ae.MiddleNotes);let n=e+i.x;if(this._beat.isLastOfVoice?n+=i.getBeatX(this._beat,ae.EndBeat):n+=i.getBeatX(this._beat.nextBeat,ae.PreNotes),n-=this.renderer.smuflMetrics.postNoteEffectPadding,this._endNoteGlyph){const l=this._endNoteGlyph.width-this._endNoteGlyph.onTimeX;n-=l}const o=(r+n)/2;this._middleNoteGlyph&&(this._middleNoteGlyph.x=o-this._middleNoteGlyph.onTimeX,this._middleNoteGlyph.y=t+i.y,this._middleNoteGlyph.paint(0,0,s)),this._endNoteGlyph&&(this._endNoteGlyph.x=n-this._endNoteGlyph.onTimeX,this._endNoteGlyph.y=t+i.y,this._endNoteGlyph.paint(0,0,s)),this._notes.sort((l,h)=>h.displayValue-l.displayValue),this.renderer.settings.notation.isNotationElementVisible(C.ScoreBendSlur)&&this._paintSlurs(e,t,s,i,r,o,n)}_paintSlurs(e,t,s,i,r,n,o){const l=this._beat.graceType===K.BendGrace?this._beat.nextBeat:this._beat;let h=this._notes.length===1?this.getTieDirection(l,i):P.Up;const c=this.renderer.smuflMetrics.glyphHeights.get(u.NoteheadBlack);s.font=this.renderer.resources.elementFonts.get(C.ScoreBendSlur);for(let d=0;d<this._notes.length;d++){const f=this._notes[d],p=xe.note(s,$t.StandardNotationEffects,f);try{d>0&&d>=(this._notes.length/2|0)&&(h=P.Down);let g=t+i.y+i.getNoteY(f,D.Top),m=c*We.GraceScale*.5;h===P.Down&&(g+=c);const b=f.bendStyle===Ke.Gradual?"grad.":"";if(f.isTieOrigin){const S=f.tieDestination,N=S?this.renderer.scoreRenderer.layout.getRendererForBar(this.renderer.staff.staffId,S.beat.voice.bar):null;if(!N||N.staff!==i.staff){const v=e+i.x+i.width,W=f.tieDestination.displayValue;i.accidentalHelper.applyAccidentalForValue(f.beat,W,!1,!0);const j=t+i.y+i.getScoreY(i.accidentalHelper.getNoteStepsForValue(W,!1));f.bendType===$.Hold||f.bendType===$.Prebend?Ot.paintTie(s,1,r,g,v,j,h===P.Down,this.renderer.smuflMetrics.tieHeight,this.renderer.smuflMetrics.slurMidpointThickness):this.drawBendSlur(s,r,g,v,j,h===P.Down,b)}else{const v=e+N.x+N.getBeatX(S.beat,ae.MiddleNotes);let W=t+N.y+N.getNoteY(S,D.Top);h===P.Down&&(W+=c),f.bendType===$.Hold||f.bendType===$.Prebend?Ot.paintTie(s,1,r,g,v,W,h===P.Down,this.renderer.smuflMetrics.tieHeight,this.renderer.smuflMetrics.slurMidpointThickness):this.drawBendSlur(s,r,g,v,W,h===P.Down,b)}switch(f.bendType){case $.Prebend:case $.PrebendBend:case $.PrebendRelease:let v=e+i.x+i.getBeatX(f.beat,ae.PreNotes);v+=this._container.prebendNoteHeadOffset;const W=t+i.y+i.getScoreY(i.accidentalHelper.getNoteStepsForValue(f.displayValue-(f.bendPoints[0].value/2|0),!1))+m;this.drawBendSlur(s,v,W,r,g,h===P.Down);break}}else{h===P.Up&&(m=-m);let S=0,N=0;switch(f.bendType){case $.Bend:S=this._getBendNoteValue(f,f.bendPoints[f.bendPoints.length-1]),N=this._endNoteGlyph.getNoteValueY(S)+m,this.drawBendSlur(s,r,g,o,N,h===P.Down,b);break;case $.BendRelease:const v=this._getBendNoteValue(f,f.bendPoints[1]),W=this._middleNoteGlyph.getNoteValueY(v)+m;this.drawBendSlur(s,r,g,n,W,h===P.Down,b),S=this._getBendNoteValue(f,f.bendPoints[f.bendPoints.length-1]),N=this._endNoteGlyph.getNoteValueY(S)+m,this.drawBendSlur(s,n,W,o,N,h===P.Down,b);break;case $.Release:this.glyphs&&(S=this._getBendNoteValue(f,f.bendPoints[f.bendPoints.length-1]),N=this.glyphs[0].getNoteValueY(S)+m,this.drawBendSlur(s,r,g,o,N,h===P.Down,b));break;case $.Prebend:case $.PrebendBend:case $.PrebendRelease:let j=e+i.x+i.getBeatX(f.beat,ae.PreNotes);j+=this._container.prebendNoteHeadOffset;const q=t+i.y+i.getScoreY(i.accidentalHelper.getNoteStepsForValue(f.displayValue-(f.bendPoints[0].value/2|0),!1))+m;this.drawBendSlur(s,j,q,r,g,h===P.Down),this.glyphs&&(S=this._getBendNoteValue(f,f.bendPoints[f.bendPoints.length-1]),N=this.glyphs[0].getNoteValueY(S)+m,this.drawBendSlur(s,r,g,o,N,h===P.Down,b));break}}}finally{p?.[Symbol.dispose]?.()}}}_getBendNoteValue(e,t){return e.displayValueWithoutBend+(t.value/2|0)}}class Ol extends Ot{startBeat;endBeat;startBeatRenderer=null;endBeatRenderer=null;constructor(e,t,s,i){super(e,i),this.startBeat=t,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?P.Up:this.lookupStartBeatRenderer().getBeatDirection(this.startBeat)===P.Up?P.Down:P.Up}calculateStartX(){const e=this.lookupStartBeatRenderer();return e.x+e.getBeatX(this.startBeat,ae.MiddleNotes)}calculateStartY(){const e=this.lookupStartBeatRenderer();return this.startBeat.isRest?this.tieDirection===P.Up?e.y+e.getRestY(this.startBeat,D.Top):e.y+e.getRestY(this.startBeat,D.Bottom):this.tieDirection===P.Up?e.y+e.getNoteY(this.startBeat.maxNote,D.Top):e.y+e.getNoteY(this.startBeat.minNote,D.Bottom)}calculateEndX(){const e=this.lookupEndBeatRenderer();if(!e)return this.calculateStartX()+this.renderer.smuflMetrics.leftHandTabTieWidth;const t=e.getBeatDirection(this.endBeat);return e.x+e.getBeatX(this.endBeat,this.endBeat.duration>y.Whole&&t===this.tieDirection?ae.Stem:ae.MiddleNotes)}caclculateEndY(){const e=this.lookupEndBeatRenderer();if(!e)return this.calculateStartY();if(this.endBeat.isRest)return this.tieDirection===P.Up?e.y+e.getRestY(this.endBeat,D.Top):e.y+e.getRestY(this.endBeat,D.Bottom);const t=this.lookupStartBeatRenderer().getBeatDirection(this.startBeat),s=e.getBeatDirection(this.endBeat);return t!==s&&this.startBeat.graceType===K.None?s===this.tieDirection?this.tieDirection===P.Up?e.y+e.getNoteY(this.endBeat.maxNote,D.TopWithStem):e.y+e.getNoteY(this.endBeat.minNote,D.BottomWithStem):this.tieDirection===P.Up?e.y+e.getNoteY(this.endBeat.maxNote,D.BottomWithStem):e.y+e.getNoteY(this.endBeat.minNote,D.TopWithStem):this.tieDirection===P.Up?e.y+e.getNoteY(this.endBeat.maxNote,D.Top):e.y+e.getNoteY(this.endBeat.minNote,D.Bottom)}}class Nu extends Nt{_outType;_inType;_startNote;_parent;checkForOverflow=!1;constructor(e,t,s,i){super(0,0),this._outType=t,this._inType=e,this._startNote=s,this._parent=i}doLayout(){this.width=0}paint(e,t,s){this._paintSlideIn(e,t,s),this._drawSlideOut(e,t,s)}_paintSlideIn(e,t,s){const i=this.renderer,r=i.smuflMetrics.simpleSlideWidth;let n=e+i.x+i.getNoteX(this._startNote,Qe.Left)-i.smuflMetrics.preNoteEffectPadding;const o=t+i.y+i.getNoteY(this._startNote,D.Center);let l=n-r,h=t+i.y;switch(this._inType){case St.IntoFromBelow:h+=i.getNoteY(this._startNote,D.Bottom);break;case St.IntoFromAbove:h+=i.getNoteY(this._startNote,D.Top);break;default:return}const c=this._getAccidentalsWidth(i,this._startNote.beat);l-=c,n-=c,this._paintSlideLine(s,!1,l,n,h,o)}_getAccidentalsWidth(e,t){return e.getBeatContainer(t).accidentalsWidth}_drawSlideOut(e,t,s){const i=this.renderer,r=i.smuflMetrics.simpleSlideWidth,n=i.smuflMetrics.postNoteEffectPadding;let o=0,l=0,h=0,c=0,d=!1;switch(this._outType){case he.Shift:case he.Legato:if(o=e+i.x+i.getBeatX(this._startNote.beat,ae.PostNotes)+n,l=t+i.y+i.getNoteY(this._startNote,D.Center),this._startNote.slideTarget){const f=this.renderer.scoreRenderer.layout.getRendererForBar(this.renderer.staff.staffId,this._startNote.slideTarget.beat.voice.bar);!f||f.staff!==i.staff?(h=e+i.x+i.width,this._startNote.slideTarget.realValue>this._startNote.realValue?c=t+i.y+i.getNoteY(this._startNote,D.Top):c=t+i.y+i.getNoteY(this._startNote,D.Bottom)):(h=e+f.x+f.getBeatX(this._startNote.slideTarget.beat,ae.PreNotes)-n,c=t+f.y+f.getNoteY(this._startNote.slideTarget,D.Center))}else h=e+i.x+this._parent.x,c=l;break;case he.OutUp:o=e+i.x+i.getNoteX(this._startNote,Qe.Right)+n,l=t+i.y+i.getNoteY(this._startNote,D.Center),h=o+r,c=t+i.y+i.getNoteY(this._startNote,D.Top);break;case he.OutDown:o=e+i.x+i.getNoteX(this._startNote,Qe.Right)+n,l=t+i.y+i.getNoteY(this._startNote,D.Center),h=o+r,c=t+i.y+i.getNoteY(this._startNote,D.Bottom);break;case he.PickSlideUp:o=e+i.x+i.getNoteX(this._startNote,Qe.Right)+n*2,l=t+i.y+i.getNoteY(this._startNote,D.Center),c=t+i.y+i.getNoteY(this._startNote,D.Top),h=e+i.x+i.width,this._startNote.beat.nextBeat&&this._startNote.beat.nextBeat.voice===this._startNote.beat.voice&&(h=e+i.x+i.getBeatX(this._startNote.beat.nextBeat,ae.PreNotes)),d=!0;break;case he.PickSlideDown:o=e+i.x+i.getNoteX(this._startNote,Qe.Right)+n*2,l=t+i.y+i.getNoteY(this._startNote,D.Center),c=t+i.y+i.getNoteY(this._startNote,D.Bottom),h=e+i.x+i.width,this._startNote.beat.nextBeat&&this._startNote.beat.nextBeat.voice===this._startNote.beat.voice&&(h=e+i.x+i.getBeatX(this._startNote.beat.nextBeat,ae.PreNotes)),d=!0;break;default:return}this._paintSlideLine(s,d,o,h,l,c)}_paintSlideLine(e,t,s,i,r,n){if(t){const o=new Ri(0,0,Be.Slight);o.renderer=this.renderer,o.doLayout(),r-=o.height/2,n-=o.height/2;const l=i-s,h=n-r,c=Math.sqrt(Math.pow(h,2)+Math.pow(l,2));o.width=l;const d=Math.asin(h/c)*(180/Math.PI);e.beginRotate(s,r,d),o.paint(0,0,e),e.endRotate()}else e.beginPath(),e.moveTo(s,r),e.lineTo(i,n),e.stroke()}}class Jn extends kn{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,ae.PostNotes)}calculateEndX(){const e=this.lookupEndBeatRenderer();return e?this.isLeftHandTap?e.x+e.getNoteX(this.endNote,Qe.Left):e.x+e.getBeatX(this.endNote.beat,ae.PreNotes):this.calculateStartX()+this.renderer.smuflMetrics.leftHandTabTieWidth}}class pa extends Jn{getTieHeight(e,t,s,i){return Math.log2(s-e+1)*this.renderer.settings.notation.slurHeight/2}calculateStartX(){return this.renderer.x+(this._isStartCentered()?this.renderer.getBeatX(this.startNote.beat,ae.MiddleNotes):this.renderer.getNoteX(this.startNote,Qe.Right))}calculateStartY(){return this._isStartCentered()?this.tieDirection===P.Up?this.renderer.y+this.renderer.getNoteY(this.startNote,D.Top):this.renderer.y+this.renderer.getNoteY(this.startNote,D.Bottom):this.renderer.y+this.renderer.getNoteY(this.startNote,D.Center)}calculateEndX(){const e=this.lookupEndBeatRenderer();return e?this._isEndCentered()?this._isEndOnStem()?e.x+e.getBeatX(this.endNote.beat,ae.Stem):e.x+e.getNoteX(this.endNote,Qe.Center):e.x+e.getBeatX(this.endNote.beat,ae.PreNotes):this.calculateStartX()+this.renderer.smuflMetrics.leftHandTabTieWidth}caclculateEndY(){const e=this.lookupEndBeatRenderer();return e?this._isEndCentered()?this._isEndOnStem()?this.tieDirection===P.Up?e.y+e.getNoteY(this.endNote,D.TopWithStem):e.y+e.getNoteY(this.endNote,D.BottomWithStem):this.tieDirection===P.Up?e.y+e.getNoteY(this.endNote,D.Top):e.y+e.getNoteY(this.endNote,D.Bottom):e.y+e.getNoteY(this.endNote,D.Center):this.calculateStartY()}_isStartCentered(){return this.startNote===this.startNote.beat.maxNote&&this.tieDirection===P.Up||this.startNote===this.startNote.beat.minNote&&this.tieDirection===P.Down}_isEndCentered(){return this.startNote.beat.graceType===K.None&&(this.endNote===this.endNote.beat.maxNote&&this.tieDirection===P.Up||this.endNote===this.endNote.beat.minNote&&this.tieDirection===P.Down)}_isEndOnStem(){const e=this.lookupStartBeatRenderer().getBeatDirection(this.startNote.beat),t=this.lookupEndBeatRenderer(),s=t?t.getBeatDirection(this.endNote.beat):e;return e!==s&&this.startNote.beat.graceType===K.None}}class Pu extends hi{_bend=null;_effectSlur=null;_effectEndSlur=null;constructor(e){super(e),this.preNotes=new Tu,this.onNotes=new wu}get prebendNoteHeadOffset(){return this.preNotes.prebendNoteHeadOffset}get accidentalsWidth(){const e=this.preNotes;return e&&e.accidentals?e.accidentals.width:0}doMultiVoiceLayout(){this.preNotes.x=0,this.preNotes.doMultiVoiceLayout(),this.onNotes.x=this.preNotes.x+this.preNotes.width,this.onNotes.doMultiVoiceLayout(),this._bend?.doMultiVoiceLayout()}doLayout(){this._effectSlur=null,this._effectEndSlur=null;const e=this.renderer,t=this.beat,s=t.graceType!==K.None;if(e.hasFlag(t)){const i=e.getBeatDirection(t),r=s?We.GraceScale:1,n=ha.getSymbol(t.duration,i,s),o=e.smuflMetrics.glyphWidths.get(n)*r;this._flagStretch=o}else if(s){const i=e.smuflMetrics.glyphWidths.get(u.Flag8thUp)*We.GraceScale;this._flagStretch=i}super.doLayout(),this._bend&&(this._bend.renderer=this.renderer,this._bend.doLayout(),this.updateWidth())}getBoundingBoxTop(){return this._bend!==null?L.minBoundingBox(this._bend.getBoundingBoxTop(),super.getBoundingBoxTop()):super.getBoundingBoxTop()}getBoundingBoxBottom(){return this._bend!==null?L.maxBoundingBox(this._bend.getBoundingBoxBottom(),super.getBoundingBoxTop()):super.getBoundingBoxBottom()}createTies(e){if(e.isVisible){if(e.isTieOrigin&&!e.hasBend&&!e.beat.hasWhammyBar&&e.beat.graceType!==K.BendGrace&&e.tieDestination&&e.tieDestination.isVisible){const t=new Jn(`
65score.tie.${e.id}`,e,e.tieDestination,!1);this.addTie(t)}if(e.isTieDestination&&!e.tieOrigin.hasBend&&!e.beat.hasWhammyBar){const t=new Jn(`score.tie.${e.tieOrigin.id}`,e.tieOrigin,e,!0);this.addTie(t)}if(e.slideInType!==St.None||e.slideOutType!==he.None){const t=new Nu(e.slideInType,e.slideOutType,e,this);this.addTie(t)}if(e.isSlurOrigin&&e.slurDestination&&e.slurDestination.isVisible){const t=new pa(`score.slur.${e.id}`,e,e.slurDestination,!1);this.addTie(t)}if(e.isSlurDestination){const t=new pa(`score.slur.${e.slurOrigin.id}`,e.slurOrigin,e,!0);this.addTie(t)}if(!this._effectSlur&&e.isEffectSlurOrigin&&e.effectSlurDestination){const t=new pa(`score.slur.effect.${e.beat.id}`,e,e.effectSlurDestination,!1);this._effectSlur=t,this.addTie(t)}if(!this._effectEndSlur&&e.beat.isEffectSlurDestination&&e.beat.effectSlurOrigin){const t=this.renderer.getBeatDirection(e.beat),s=t===P.Up?e.beat.effectSlurOrigin.minNote:e.beat.effectSlurOrigin.maxNote,i=t===P.Up?e.beat.minNote:e.beat.maxNote,r=new pa(`score.slur.effect.${s.beat.id}`,s,i,!0);this._effectEndSlur=r,this.addTie(r)}if(e.hasBend){if(!this._bend){const t=new xu(this);this._bend=t,t.renderer=this.renderer,this.addTie(t)}this._bend.addBends(e)}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 Ol(`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 Ol(`score.legato.${t.id}`,t,this.beat,!0))}}}_flagStretch=0;get postBeatStretch(){return super.postBeatStretch+this._flagStretch}updateWidth(){super.updateWidth(),this.width+=this._flagStretch}}class qs extends Js{static StaffId="score";static _sharpKsSteps=[-1,2,-2,1,4,0,3];static _flatKsSteps=[3,0,4,1,5,2,6];accidentalHelper;constructor(e,t){super(e,t),this.accidentalHelper=new qt(this)}get repeatsBarSubElement(){return Le.StandardNotationRepeats}get barNumberBarSubElement(){return Le.StandardNotationBarNumber}get barLineBarSubElement(){return Le.StandardNotationBarLines}get staffLineBarSubElement(){return Le.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(e){return super.getLineY(e/2)}getScoreHeight(e){return super.getLineHeight(e/2)}calculateOverflows(e,t){super.calculateOverflows(e,t),!this.bar.isEmpty&&this.calculateBeamingOverflows(e,t)}get flagsSubElement(){return rt.StandardNotationFlags}get beamsSubElement(){return rt.StandardNotationBeams}get tupletSubElement(){return rt.StandardNotationTuplet}getFlagTopY(e,t){const s=t===P.Up?D.TopWithStem:D.StemDown;return e.isRest?this.getRestY(e,s):this.voiceContainer.getHighestNoteY(e,s)}getFlagBottomY(e,t){const s=t===P.Up?D.StemUp:D.BottomWithStem;return e.isRest?this.getRestY(e,s):this.voiceContainer.getLowestNoteY(e,s)}getBeamDirection(e){return this._beamDirections.has(e)?this._beamDirections.get(e):P.Up}centerStaffStemY(e){return this.bar.staff.standardNotationLineCount===Oi.DefaultStandardNotationLineCount?this.getScoreY(this.bar.staff.standardNotationLineCount-1):e===P.Up?this.getScoreY(this.bar.staff.standardNotationLineCount*2):this.getScoreY(0)}get middleYPosition(){return this.getScoreY(this.bar.staff.standardNotationLineCount-1)}applyLayoutingInfo(){const e=super.applyLayoutingInfo();if(e&&this.bar.isMultiVoice){const t=this.getScoreY(-2),s=this.getScoreY(this.heightLineCount*2),i=this.helpers.collisionHelper.getBeatMinMaxY();i[0]<t&&this.registerOverflowTop(Math.abs(i[0])),i[1]>s&&this.registerOverflowBottom(Math.abs(i[1])-s)}return e}getMinLineOfBeat(e){return this.accidentalHelper.getMinSteps(e)/2}getMaxLineOfBeat(e){return this.accidentalHelper.getMaxSteps(e)/2}createLinePreBeatGlyphs(){let e=!1;if(this.isFirstOfStaff||this.bar.clef!==this.bar.previousBar.clef||this.bar.clefOttava!==this.bar.previousBar.clefOttava){let t=0;switch(this.bar.clef){case ve.Neutral:t=this.bar.staff.standardNotationLineCount-1;break;case ve.F4:t=2;break;case ve.C3:t=4;break;case ve.C4:t=2;break;case ve.G2:t=6;break}this.createStartSpacing(),this.addPreBeatGlyph(new zo(0,this.get
vendor: 39,694 bytes, line 65
65ScoreY(t),this.bar.clef,this.bar.clefOttava)),this.addPreBeatGlyph(new is(0,0,this.smuflMetrics.preBeatGlyphSpacing)),e=!0}(e||this.index===0&&this.bar.keySignature!==qe.C||this.bar.previousBar&&this.bar.keySignature!==this.bar.previousBar.keySignature)&&(this.createStartSpacing(),this._createKeySignatureGlyphs()),(!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._createTimeSignatureGlyphs())}_createKeySignatureGlyphs(){let e=0;const t=this.bar.keySignature,s=this.bar.previousBar?this.bar.previousBar.keySignature:0;switch(this.bar.clef){case ve.Neutral:e=0;break;case ve.G2:e=1;break;case ve.F4:e=3;break;case ve.C3:e=2;break;case ve.C4:e=0;break}const i=new gu;i.gap=this.smuflMetrics.accidentalPadding,i.renderer=this;const r=new Map,n=[];if(L.keySignatureIsSharp(t))for(let o=0;o<Math.abs(t);o++){const l=qs._sharpKsSteps[o]+e;n.push(new ci(0,this.getScoreY(l),ee.Sharp,1)),r.set(l,!0)}else for(let o=0;o<Math.abs(t);o++){const l=qs._flatKsSteps[o]+e;n.push(new ci(0,this.getScoreY(l),ee.Flat,1)),r.set(l,!0)}if(this.bar.keySignature===qe.C){const o=Math.abs(s),l=L.keySignatureIsSharp(s)?qs._sharpKsSteps:qs._flatKsSteps;for(let h=0;h<o;h++){const c=l[h]+e;r.has(c)||i.addGlyph(new ci(0,this.getScoreY(l[h]+e),ee.Natural,1))}}for(const o of n)i.addGlyph(o);this.addPreBeatGlyph(i),i.isEmpty||this.addPreBeatGlyph(new is(0,0,this.smuflMetrics.preBeatGlyphSpacing))}_createTimeSignatureGlyphs(){const e=this.bar.staff.standardNotationLineCount-1;this.addPreBeatGlyph(new Uo(0,this.getScoreY(e),this.bar.masterBar.timeSignatureNumerator,this.bar.masterBar.timeSignatureDenominator,this.bar.masterBar.timeSignatureCommon,this.bar.masterBar.isFreeTime)),this.addPreBeatGlyph(new is(0,0,this.smuflMetrics.preBeatGlyphSpacing))}createVoiceGlyphs(e){super.createVoiceGlyphs(e);for(const t of e.beats)this.addBeatGlyph(new Pu(t))}getNoteLine(e){return this.accidentalHelper.getNoteSteps(e)/2}getNoteSteps(e){return this.accidentalHelper.getNoteSteps(e)}_beamDirections=new Map;completeBeamingHelper(e){const t=this._calculateBeamDirection(e);this._beamDirections.set(e,t)}_calculateBeamDirection(e){if(!e.voice)return P.Up;if(e.preferredBeamDirection!==null)return e.preferredBeamDirection;if(e.voice.index>0)return this._invertBeamDirection(e,P.Down);if(e.voice.bar.isMultiVoice)return this._invertBeamDirection(e,P.Up);if(e.beats[0].graceType!==K.None)return this._invertBeamDirection(e,P.Up);if(e.beats.length===1&&e.beats[0].slashed)return this._invertBeamDirection(e,P.Down);if(e.highestNoteInHelper&&e.lowestNoteInHelper){const t=this._getNoteCenterYBeforeLayouting(e.highestNoteInHelper),s=this._getNoteCenterYBeforeLayouting(e.lowestNoteInHelper),i=(t+s)/2;return this._invertBeamDirection(e,this.middleYPosition<i?P.Up:P.Down)}return this._invertBeamDirection(e,P.Up)}_getNoteCenterYBeforeLayouting(e){const t=qt.computeStepsWithoutAccidentals(this.bar,e);return this.getScoreY(t)}_invertBeamDirection(e,t){return e.invertBeamDirection?t===P.Down?P.Up:P.Down:t}paintBeamingStem(e,t,s,i,r,n){const o=xe.beat(n,rt.StandardNotationStem,e);try{n.fillRect(s,i,this.smuflMetrics.stemThickness,r-i)}finally{o?.[Symbol.dispose]?.()}}}class Cu extends Sn{get staffId(){return qs.StaffId}create(e,t){return new qs(e,t)}canCreate(e,t){return super.canCreate(e,t)&&t.showStandardNotation}}class Eu extends da{paint(e,t,s){super.internalPaint(e,t,s,rt.SlashRests)}}class vu extends Tn{_tremoloPicking;_stemLengthExtension=0;noteHeads=null;deadSlapped=null;restGlyph=null;get effectElement(){return rt.SlashEffects}getNoteX(e,t){let s=null;if(this.noteHeads?s=this.noteHeads:this.deadSlapped&&(s=this.deadSlapped),s){let i=s.x;switch(t){case Qe.Left:break;case Qe.Center:i+=s.width/2;break;case Qe.Right:i+=s.width;break}return i}return 0}buildBoundingsLookup(e,t,s){if(this.noteHeads&&this.container.beat.notes.length>0){const i=new xr;i.note=this.container.beat.notes[0],i.noteHeadBounds=new bt,i.noteHeadBounds.x=t+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,e.addNote(i)}}getLowestNoteY(e){return this._internalGetNoteY(e)}getHighestNoteY(e){return this._internalGetNoteY(e)}getRestY(e){const t=this.restGlyph;if(t)switch(e){case D.TopWithStem:return t.getBoundingBoxTop()-this.renderer.smuflMetrics.getStemLength(y.Quarter,!0);case D.Top:return t.getBoundingBoxTop();case D.Center:case D.StemUp:case D.StemDown:return t.getBoundingBoxTop()+t.height/2;case D.Bottom:return t.getBoundingBoxBottom();case D.BottomWithStem:return t.getBoundingBoxBottom()+this.renderer.smuflMetrics.getStemLength(y.Quarter,!0)}return 0}getNoteY(e,t){return this._internalGetNoteY(t)}_internalGetNoteY(e){let t=null,s=u.None,i=!1;if(this.noteHeads?(t=this.noteHeads,s=wr.getSymbol(this.container.beat.duration),i=!0):this.deadSlapped&&(t=this.deadSlapped),t){let r=this.y+t.y;const n=this.renderer,o=this.container.beat,l=o.graceType!==K.None?We.GraceScale:1;switch(e){case D.TopWithStem:return i?(r-=(n.smuflMetrics.stemUp.has(s)?n.smuflMetrics.stemUp.get(s).bottomY:0)*l,r-=n.smuflMetrics.getStemLength(o.duration,n.hasFlag(o))*l,r-=this._stemLengthExtension):r-=t.height/2,r;case D.Top:r-=t.height/2;break;case D.Center:break;case D.Bottom:r+=t.height/2;break;case D.BottomWithStem:return i?(r-=(n.smuflMetrics.stemDown.has(s)?n.smuflMetrics.stemDown.get(s).topY:-n.smuflMetrics.glyphHeights.get(s)/2)*l,r+=n.smuflMetrics.getStemLength(o.duration,n.hasFlag(o))*l,r+=this._stemLengthExtension):r+=t.height/2,r;case D.StemUp:r-=this.renderer.smuflMetrics.stemUp.has(s)?this.renderer.smuflMetrics.stemUp.get(s).bottomY:0;break;case D.StemDown:r-=this.renderer.smuflMetrics.stemDown.has(s)?this.renderer.smuflMetrics.stemDown.get(s).topY:0;break}return r}return 0}doLayout(){const e=this.renderer,t=e.getLineY(0);if(this.container.beat.deadSlapped){const i=new xn;i.renderer=this.renderer,i.doLayout(),this.deadSlapped=i,this.addEffect(i)}else if(!this.container.beat.isEmpty)if(this.container.beat.isRest){const i=new Eu(0,t,this.container.beat.duration);this.restGlyph=i,i.beat=this.container.beat,this.addNormal(i)}else{const i=new wr(0,t,this.container.beat);this.noteHeads=i,i.beat=this.container.beat,this.addNormal(i),this.container.beat.isTremolo&&(this._tremoloPicking=new Nr(0,0,this.container.beat.tremoloPicking),this._tremoloPicking.renderer=this.renderer,this._tremoloPicking.doLayout(),this._alignTremoloPickingGlyph())}if(this.container.beat.dots>0)for(let i=0;i<this.container.beat.dots;i++)this.addEffect(new ia(0,t-e.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._tremoloPicking;s&&(s.x=this.container.beat.duration<y.Half?this.width/2:this.stemX)}_alignTremoloPickingGlyph(){const e=this._tremoloPicking;e.alignTremoloPickingGlyph(P.Up,this._internalGetNoteY(D.TopWithStem),this._internalGetNoteY(D.Center),this.container.beat.duration),this._stemLengthExtension=e.stemExtensionHeight;let t=this.stemX;this.container.beat.duration<y.Half&&(t=this.width/2),e.x=t}paint(e,t,s){super.paint(e,t,s);const i=this._tremoloPicking;i&&i.paint(e+this.x,t+this.y,s)}}class Wl extends kn{calculateTieDirection(){return P.Down}getStartNotePosition(){return Qe.Right}getEndNotePosition(){return Qe.Left}}class Du extends hi{_tiedNoteTie=null;constructor(e){super(e),this.preNotes=new la,this.onNotes=new vu}doLayout(){const e=this.renderer,t=this.beat,s=t.graceType!==K.None;if(e.hasFlag(t)){const i=e.getBeatDirection(t),r=s?We.GraceScale:1,n=ha.getSymbol(t.duration,i,s),o=e.smuflMetrics.glyphWidths.get(n)*r;this._flagStretch=o}else if(s){const i=e.smuflMetrics.glyphWidths.get(u.Flag8thUp)*We.GraceScale;this._flagStretch=i}super.doLayout()}createTies(e){if(e.isVisible){if(!this._tiedNoteTie&&e.isTieOrigin&&e.tieDestination.isVisible){const t=new Wl("slash.tie",e,e.tieDestination,!1);this._tiedNoteTie=t,this.addTie(t)}if(!this._tiedNoteTie&&e.isTieDestination){const t=new Wl("slash.tie",e.tieOrigin,e,!0);this._tiedNoteTie=t,this.addTie(t)}}}_flagStretch=0;get postBeatStretch(){return super.postBeatStretch+this._flagStretch}updateWidth(){super.updateWidth(),this.width+=this._flagStretch}}class un extends Js{static StaffId="slash";simpleWhammyOverflow=0;_isOnlySlash;constructor(e,t){super(e,t),this._isOnlySlash=!t.staff.showTablature&&!t.staff.showStandardNotation,this.helpers.preferredBeamDirection=P.Up}get repeatsBarSubElement(){return Le.SlashRepeats}get barNumberBarSubElement(){return Le.SlashBarNumber}get barLineBarSubElement(){return Le.SlashBarLines}get staffLineBarSubElement(){return Le.SlashStaffLine}get lineSpacing(){return this.smuflMetrics.oneStaffSpace}get heightLineCount(){return 5}get drawnLineCount(){return 1}get bottomGlyphOverflow(){return 0}get flagsSubElement(){return rt.SlashFlags}get beamsSubElement(){return rt.SlashBeams}get tupletSubElement(){return rt.SlashTuplet}doLayout(){super.doLayout(),this.voiceContainer.tupletGroups.size>0&&this.registerOverflowTop(this.tupletSize)}getNoteLine(e){return 0}getFlagTopY(e,t){const s=t===P.Up?D.TopWithStem:D.StemDown;return e.notes.length>0?this.getNoteY(e.notes[0],s):this.getRestY(e,s)}getFlagBottomY(e,t){const s=t===P.Up?D.StemUp:D.BottomWithStem;return e.notes.length>0?this.getNoteY(e.notes[0],s):this.getRestY(e,s)}getBeamDirection(e){return P.Up}createLinePreBeatGlyphs(){this._isOnlySlash&&(!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._createTimeSignatureGlyphs())}_createTimeSignatureGlyphs(){this.addPreBeatGlyph(new is(0,0,this.smuflMetrics.oneStaffSpace));const e=this.bar.masterBar,t=new Uo(0,this.getLineY(0),e.timeSignatureNumerator,e.timeSignatureDenominator,e.timeSignatureCommon,e.isFreeTime&&(e.previousMasterBar==null||e.isFreeTime!==e.previousMasterBar.isFreeTime));t.barSubElement=Le.SlashTimeSignature,this.addPreBeatGlyph(t)}createVoiceGlyphs(e){if(!(e.index>0)){super.createVoiceGlyphs(e);for(const t of e.beats)this.addBeatGlyph(new Du(t))}}calculateOverflows(e,t){super.calculateOverflows(e,t),!this.bar.isEmpty&&this.calculateBeamingOverflows(e,t)}shouldPaintBeamingHelper(e){return super.shouldPaintBeamingHelper(e)&&e.voice.index===0}paintBeamingStem(e,t,s,i,r,n){const o=xe.beat(n,rt.SlashStem,e);try{n.fillRect(s,i,this.smuflMetrics.stemThickness,r-i)}finally{o?.[Symbol.dispose]?.()}}paintBeamHelper(e,t,s,i,r,n){i.voice?.index===0&&super.paintBeamHelper(e,t,s,i,r,n)}}class Lu extends Sn{get staffId(){return un.StaffId}create(e,t){return new un(e,t)}canCreate(e,t){return super.canCreate(e,t)&&t.showSlash}}class Fu extends Nt{_note;_noteString=null;_trillNoteString=null;_trillNoteStringWidth=0;isEmpty=!1;noteStringWidth=0;constructor(e,t,s){super(e,t),this._note=s}get _padding(){return this.renderer.lineSpacing*.25}getBoundingBoxTop(){return this.y-this.height/2-this._padding}getBoundingBoxBottom(){return this.y+this.height/2}doLayout(){const e=this._note;let t=e.fret-e.beat.voice.bar.staff.transpositionPitch;if(e.harmonicType===te.Natural&&e.harmonicValue!==0&&(t=e.harmonicValue-e.beat.voice.bar.staff.transpositionPitch),e.isTieDestination)e.beat.index===0&&this.renderer.settings.notation.notationMode===Vt.GuitarPro||(e.bendType===$.Bend||e.bendType===$.BendRelease)&&this.renderer.settings.notation.isNotationElementVisible(C.TabNotesOnTiedBends)?this._noteString=`(${(e.tieOrigin.fret-e.beat.voice.bar.staff.transpositionPitch).toString()})`:this._noteString="";else if(this._noteString=e.isDead?"x":t.toString(),e.isGhost)this._noteString=`(${this._noteString})`;else if(e.harmonicType===te.Natural){const s=this._noteString.indexOf(".");s>=0&&(this._noteString=this._noteString.substr(0,s+2)),this._noteString=`<${this._noteString}>`}if(e.isTrill)this._trillNoteString=`(${(e.trillFret-e.beat.voice.bar.staff.transpositionPitch).toString()})`;else if(L.isAlmostEqualTo(e.harmonicValue,0))this._trillNoteString="";else switch(e.harmonicType){case te.Artificial:case te.Pinch:case te.Tap:case te.Semi:case te.Feedback:let s=(t+e.harmonicValue).toString();const i=s.indexOf(".");i>=0&&(s=s.substr(0,i+2)),this._trillNoteString=`<${s}>`;break;default:this._trillNoteString="";break}if(this.isEmpty=!this._noteString,!this.isEmpty){this.renderer.scoreRenderer.canvas.font=this.renderer.resources.tablatureFont;const s=!!this._trillNoteString;this.noteStringWidth=this.renderer.scoreRenderer.canvas.measureText(this._noteString+(s?" ":"")).width,this.width=this.noteStringWidth,this.height=this.renderer.scoreRenderer.canvas.font.size,s&&(this.renderer.scoreRenderer.canvas.font=this.renderer.resources.graceFont,this._trillNoteStringWidth=3+this.renderer.scoreRenderer.canvas.measureText(this._trillNoteString).width,this.width+=this._trillNoteStringWidth)}}paint(e,t,s){if(this.isEmpty)return;const i=this.noteStringWidth+this._trillNoteStringWidth,r=e+this.x+(this.width-i)/2,n=t+this.y;this.paintTrill(r,n,s);const o=xe.note(s,$t.GuitarTabFretNumber,this._note);try{s.fillText(this._noteString,r,n)}finally{o?.[Symbol.dispose]?.()}}paintTrill(e,t,s){const i=xe.note(s,$t.GuitarTabFretNumber,this._note);try{const r=this.renderer.scoreRenderer.canvas.font;this.renderer.scoreRenderer.canvas.font=this.renderer.resources.graceFont,s.fillText(this._trillNoteString,e+this.noteStringWidth,t),this.renderer.scoreRenderer.canvas.font=r}finally{i?.[Symbol.dispose]?.()}}buildBoundingsLookup(e,t,s){const i=new xr;i.note=this._note,i.noteHeadBounds=new bt,i.noteHeadBounds.x=t+this.x,i.noteHeadBounds.y=s+this.y-this.height/2,i.noteHeadBounds.w=this.width,i.noteHeadBounds.h=this.height,e.addNote(i)}}class Mu extends Nt{_notes=[];_deadSlapped=null;_isGrace;beat;maxStringNote=null;minStringNote=null;beatEffects=new Map;notesPerString=new Map;noteStringWidth=0;constructor(e,t,s){super(e,t),this._isGrace=s}buildBoundingsLookup(e,t,s){for(const i of this._notes)i.buildBoundingsLookup(e,t+this.x,s+this.y)}getNoteX(e,t){if(this.notesPerString.has(e.string)){const s=this.notesPerString.get(e.string);let i=this.x+s.x;switch(t){case Qe.Left:break;case Qe.Center:i+=s.noteStringWidth/2;break;case Qe.Right:i+=s.width;break}return i}return 0}getLowestNoteY(e){return this.maxStringNote?this.getNoteY(this.maxStringNote,e):0}getHighestNoteY(e){return this.minStringNote?this.getNoteY(this.minStringNote,e):0}getNoteY(e,t){if(this.notesPerString.has(e.string)){const s=this.notesPerString.get(e.string);let i=this.y+s.y;switch(t){case D.Top:i-=s.height/2;break;case D.StemUp:i=this.y+s.getBoundingBoxTop();break;case D.Center:break;case D.Bottom:i+=s.height/2;break;case D.StemDown:i=this.y+s.getBoundingBoxBottom();break;case D.TopWithStem:i=-this.renderer.settings.notation.rhythmHeight,i-=this.calculateTremoloHeightForStem();break;case D.BottomWithStem:i=this.renderer.height+this.renderer.settings.notation.rhythmHeight,i+=this.calculateTremoloHeightForStem();break}return i}return 0}calculateTremoloHeightForStem(){const e=this.beat;if(!e.isTremolo||e.duration<=y.Quarter)return 0;const t=Nr._getSymbol(e.tremoloPicking),s=this.renderer.smuflMetrics;return s.glyphHeights.has(t)?s.glyphHeights.get(t):0}doLayout(){let e=0;if(this.beat.deadSlapped)this._deadSlapped=new xn,this._deadSlapped.renderer=this.renderer,this._deadSlapped.doLayout(),e=this._deadSlapped.width,this.noteStringWidth=e;else{let t=0;for(let l=0,h=this._notes.length;l<h;l++){const c=this._notes[l];c.renderer=this.renderer,c.doLayout(),c.width>e&&(e=c.width),c.noteStringWidth>t&&(t=c.noteStringWidth)}this.noteStringWidth=t;const s=this.renderer.resources.tablatureFont.size;let i=Number.NaN,r=Number.NaN,n=this.getNoteY(this.minStringNote,D.Center)+s/2;const o=this.renderer.smuflMetrics.onNoteEffectPadding;for(const l of this.beatEffects.values())l.y+=n,l.x+=this.width/2,l.renderer=this.renderer,l.doLayout(),n+=l.height+o,(Number.isNaN(i)||i>n)&&(i=n),(Number.isNaN(r)||r<n)&&(r=n);Number.isNaN(i)||this.renderer.registerBeatEffectOverflows(i,r)}this.width=e}addNoteGlyph(e,t){this._notes.push(e),this.notesPerString.set(t.string,e),(!this.minStringNote||t.string<this.minStringNote.string)&&(this.minStringNote=t),(!this.maxStringNote||t.string>this.maxStringNote.string)&&(this.maxStringNote=t)}paint(e,t,s){if(e+=this.x,t+=this.y,this.beat.deadSlapped)this._deadSlapped?.paint(e,t,s);else{const i=this.renderer.resources,r=s.textBaseline;s.textBaseline=He.Middle,s.font=this._isGrace?i.graceFont:i.tablatureFont;const n=this._notes,o=this.width;for(const h of n)h.renderer=this.renderer,h.width=o,h.paint(e,t,s);s.textBaseline=r;const l=xe.beat(s,rt.GuitarTabEffects,this.beat);try{for(const h of this.beatEffects.values())h.paint(e,t,s)}finally{l?.[Symbol.dispose]?.()}}}}class Au extends Lt{_isVisibleRest;constructor(e,t,s,i){super(e,t,1,da.getSymbol(i)),this._isVisibleRest=s}doLayout(){super.doLayout()}paint(e,t,s){if(this._isVisibleRest){const i=xe.beat(s,rt.GuitarTabRests,this.beat);try{super.paint(e,t,s)}finally{i?.[Symbol.dispose]?.()}}}}class Iu extends Tn{slash=null;noteNumbers=null;restGlyph=null;get effectElement(){return rt.GuitarTabEffects}getNoteX(e,t){if(this.slash){let s=this.slash.x;switch(t){case Qe.Left:break;case Qe.Center:s+=this.slash.width/2;break;case Qe.Right:s+=this.slash.width;break}return s}return this.noteNumbers?this.noteNumbers.getNoteX(e,t):0}getNoteY(e,t){return this.noteNumbers?this.noteNumbers.getNoteY(e,t):0}getRestY(e){const t=this.restGlyph;if(t)switch(e){case D.TopWithStem:return t.getBoundingBoxTop()-this.renderer.smuflMetrics.getStemLength(y.Quarter,!0);case D.Top:return t.getBoundingBoxTop();case D.Center:case D.StemUp:case D.StemDown:return t.getBoundingBoxTop()+t.height/2;case D.Bottom:return t.getBoundingBoxTop();case D.BottomWithStem:return t.getBoundingBoxBottom()+this.renderer.smuflMetrics.getStemLength(y.Quarter,!0)}return 0}getLowestNoteY(e){return this.noteNumbers?this.noteNumbers.getLowestNoteY(e):0}getHighestNoteY(e){return this.noteNumbers?this.noteNumbers.getHighestNoteY(e):0}buildBoundingsLookup(e,t,s){this.noteNumbers&&this.noteNumbers.buildBoundingsLookup(e,t+this.x,s+this.y)}doLayout(){const e=this.renderer,t=[];if(this.container.beat.isRest){const i=Math.floor((this.renderer.bar.staff.tuning.length-1)/2),r=e.getLineY(i),n=new Au(0,r,e.showRests,this.container.beat.duration);if(this.restGlyph=n,n.beat=this.container.beat,this.addNormal(n),this.container.beat.dots>0&&e.showRests)for(let o=0;o<this.container.beat.dots;o++)this.addEffect(new ia(0,r))}else{const i=this.renderer.settings.notation.smallGraceTabNotes&&this.container.beat.graceType!==K.None;let r;if(this.container.beat.slashed&&!this.container.beat.notes.some(n=>n.isTieDestination)){const n=Math.floor((this.renderer.bar.staff.tuning.length-1)/2),o=e.getLineY(n),l=new wr(0,o,this.container.beat);l.noteHeadElement=$t.GuitarTabFretNumber,l.effectElement=rt.GuitarTabEffects,this.slash=l,l.beat=this.container.beat,this.addNormal(l),r=l.beatEffects}else{const n=new Mu(0,0,i);this.noteNumbers=n,n.beat=this.container.beat;for(const o of this.container.beat.notes)o.isVisible&&this._createNoteGlyph(o);this.addNormal(n),r=n.beatEffects}if(this.container.beat.isTremolo&&!r.has("tremolo")){const n=new Nr(0,0,this.container.beat.tremoloPicking);n.offsetY=this.renderer.smuflMetrics.glyphTop.get(n.symbol),r.set("tremolo",n),t.push(n)}if(this.container.beat.dots>0&&e.rhythmMode!==Cs.Hidden){const n=this.getNoteY(this.container.beat.maxNote,D.BottomWithStem);for(let o=0;o<this.container.beat.dots;o++)this.addEffect(new ia(0,n))}}if(this.isEmpty)return;let s=0;for(let i=0,r=this.glyphs.length;i<r;i++){const n=this.glyphs[i];n.x=s,n.renderer=this.renderer,n.doLayout(),s+=n.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 i of t)i.x=this.onTimeX}_createNoteGlyph(e){const t=this.renderer,s=new Fu(0,0,e),i=t.getNoteLine(e);s.y=t.getLineY(i),s.renderer=this.renderer,s.doLayout(),this.noteNumbers.addNoteGlyph(s,e);const r=s.getBoundingBoxTop(),n=s.getBoundingBoxBottom();this.renderer.collisionHelper.reserveBeatSlot(this.container.beat,r,n);const o=t.minString,l=t.maxString;(Number.isNaN(o)||o<e.string)&&(t.minString=i),(Number.isNaN(l)||l>e.string)&&(t.maxString=i)}}class Ru extends Nt{_beat;_noteVibratoGlyph;constructor(e){super(0,0),this._beat=e}doLayout(){if(this.width=this.renderer.smuflMetrics.glyphWidths.get(u.ArrowheadBlackDown),this._beat.brushType===z.ArpeggioUp){const e=new Ri(0,0,Be.Slight,!0);e.renderer=this.renderer,e.doLayout(),this._noteVibratoGlyph=e}else if(this._beat.brushType===z.ArpeggioDown){const e=new Ri(0,0,Be.Slight,!0);e.renderer=this.renderer,e.doLayout(),this._noteVibratoGlyph=e}}paint(e,t,s){const i=this.renderer,r=t+this.x+i.getNoteY(this._beat.maxStringNote,D.Top),n=t+this.y+i.getNoteY(this._beat.minStringNote,D.Bottom),o=e+this.x+this.width/2,l=this.renderer.smuflMetrics.glyphWidths.get(u.ArrowheadBlackDown);if(this._beat.brushType!==z.None){if(this._beat.brushType===z.BrushUp||this._beat.brushType===z.BrushDown)s.beginPath(),s.moveTo(o,r),s.lineTo(o,n),s.stroke();else if(this._beat.brushType===z.ArpeggioUp){const h=this._noteVibratoGlyph,c=r,d=n-l;h.width=Math.abs(d-c),s.beginRotate(e+this.x,d,-90),h.paint(0,(this.width-h.height)/2,s),s.endRotate()}else if(this._beat.brushType===z.ArpeggioDown){const h=this._noteVibratoGlyph,c=r+l,d=n;h.width=Math.abs(d-c),s.beginRotate(e+this.x,c,90),h.paint(0,-(this.width-h.height/2),s),s.endRotate()}this._beat.brushType===z.BrushUp||this._beat.brushType===z.ArpeggioUp?(s.beginPath(),s.moveTo(o,n),s.lineTo(o+l/2,n-l),s.lineTo(o-l/2,n-l),s.closePath(),s.fill()):(s.beginPath(),s.moveTo(o,r),s.lineTo(o+l/2,r+l),s.lineTo(o-l/2,r+l),s.closePath(),s.fill())}}}class Ou extends la{doLayout(){this.container.beat.brushType!==z.None&&!this.container.beat.isRest&&(this.addEffect(new Ru(this.container.beat)),this.addNormal(new is(0,0,this.renderer.smuflMetrics.preNoteEffectPadding))),super.doLayout()}get effectElement(){return rt.GuitarTabEffects}}class Wu extends Nt{_inType;_outType;_startNote;_parent;checkForOverflow=!1;constructor(e,t,s,i){super(0,0),this._inType=e,this._outType=t,this._startNote=s,this._parent=i}doLayout(){this.width=0}paint(e,t,s){this._paintSlideIn(e,t,s),this._paintSlideOut(e,t,s)}_paintSlideIn(e,t,s){const i=this.renderer,r=this.renderer.smuflMetrics.simpleSlideWidth,n=this.renderer.smuflMetrics.simpleSlideHeight;let o=0,l=0,h=0,c=0;const d=this.renderer.smuflMetrics.preNoteEffectPadding;switch(this._inType){case St.IntoFromBelow:h=e+i.x+i.getNoteX(this._startNote,Qe.Left)-d,c=t+i.y+i.getNoteY(this._startNote,D.Center)-n,o=h-r,l=t+i.y+i.getNoteY(this._startNote,D.Center)+n;break;case St.IntoFromAbove:h=e+i.x+i.getNoteX(this._startNote,Qe.Left)-d,c=t+i.y+i.getNoteY(this._startNote,D.Center)+n,o=h-r,l=t+i.y+i.getNoteY(this._startNote,D.Center)-n;break;default:return}this._paintSlideLine(s,!1,o,h,l,c)}_paintSlideOut(e,t,s){const i=this.renderer,r=this.renderer.smuflMetrics.simpleSlideWidth,n=this.renderer.smuflMetrics.simpleSlideHeight;let o=0,l=0,h=0,c=0,d=!1;const f=this.renderer.smuflMetrics.postNoteEffectPadding;switch(this._outType){case he.Shift:case he.Legato:if(o=e+i.x+i.getBeatX(this._startNote.beat,ae.PostNotes)+f,l=t+i.y+i.getNoteY(this._startNote,D.Center),this._startNote.slideTarget){const p=this.renderer.scoreRenderer.layout.getRendererForBar(this.renderer.staff.staffId,this._startNote.slideTarget.beat.voice.bar);!p||p.staff!==i.staff?(h=e+i.x+i.width,c=l):(h=e+p.x+p.getBeatX(this._startNote.slideTarget.beat,ae.OnNotes)-f,c=t+p.y+p.getNoteY(this._startNote.slideTarget,D.Center)),this._startNote.slideTarget.fret>this._startNote.fret?(l+=n,c-=n):(l-=n,c+=n)}else h=e+i.x+this._parent.x,c=l;break;case he.OutUp:o=e+i.x+i.getNoteX(this._startNote,Qe.Right)+f,l=t+i.y+i.getNoteY(this._startNote,D.Center)+n,h=o+r,c=t+i.y+i.getNoteY(this._startNote,D.Center)-n;break;case he.OutDown:o=e+i.x+i.getNoteX(this._startNote,Qe.Right)+f,l=t+i.y+i.getNoteY(this._startNote,D.Center)-n,h=o+r,c=t+i.y+i.getNoteY(this._startNote,D.Center)+n;break;case he.PickSlideDown:o=e+i.x+i.getNoteX(this._startNote,Qe.Right)+f*2,l=t+i.y+i.getNoteY(this._startNote,D.Center),h=e+i.x+i.width,c=l+n*3,this._startNote.beat.nextBeat&&this._startNote.beat.nextBeat.voice===this._startNote.beat.voice&&(h=e+i.x+i.getBeatX(this._startNote.beat.nextBeat,ae.PreNotes)),d=!0;break;case he.PickSlideUp:o=e+i.x+i.getNoteX(this._startNote,Qe.Right)+f*2,l=t+i.y+i.getNoteY(this._startNote,D.Center),h=e+i.x+i.width,c=l-n*3,this._startNote.beat.nextBeat&&this._startNote.beat.nextBeat.voice===this._startNote.beat.voice&&(h=e+i.x+i.getBeatX(this._startNote.beat.nextBeat,ae.PreNotes)),d=!0;break;default:return}this._paintSlideLine(s,d,o,h,l,c)}_paintSlideLine(e,t,s,i,r,n){if(t){const o=new Ri(0,0,Be.Slight);o.renderer=this.renderer,o.doLayout(),r-=o.height/2,n-=o.height/2;const l=i-s,h=n-r,c=Math.sqrt(Math.pow(h,2)+Math.pow(l,2));o.width=l;const d=Math.asin(h/c)*(180/Math.PI);e.beginRotate(s,r,d),o.paint(0,0,e),e.endRotate()}else e.beginPath(),e.moveTo(s,r),e.lineTo(i,n),e.stroke()}}class Vu extends hi{_bend=null;_effectSlurs=[];constructor(e){super(e),this.preNotes=new Ou,this.onNotes=new Iu}drawBeamHelperAsFlags(e){return e.hasFlag(this.renderer.drawBeamHelperAsFlags(e),this.beat)}doLayout(){this._effectSlurs=[],super.doLayout(),this._bend&&(this._bend.renderer=this.renderer,this._bend.doLayout(),this.updateWidth())}createTies(e){if(!e.isVisible)return;const t=this.renderer;if(e.isTieOrigin&&t.showTiedNotes&&e.tieDestination.isVisible){const s=new Ki(`tab.tie.${e.id}`,e,e.tieDestination,!1);this.addTie(s)}if(e.isTieDestination&&t.showTiedNotes){const s=new Ki(`tab.tie.${e.tieOrigin.id}`,e.tieOrigin,e,!0);this.addTie(s)}if(e.isLeftHandTapped&&!e.isHammerPullDestination){const s=new Ki(`tab.tie.leftHandTap.${e.id}`,e,e,!1);this.addTie(s)}if(e.isEffectSlurOrigin&&e.effectSlurDestination){let s=!1;for(const i of this._effectSlurs)if(i.tryExpand(e,e.effectSlurDestination,!1,!1)){s=!0;break}if(!s){const i=new Xn(`tab.slur.effect.${e.id}`,e,e.effectSlurDestination,!1,!1);this._effectSlurs.push(i),this.addTie(i)}}if(e.isEffectSlurDestination&&e.effectSlurOrigin){let s=!1;for(const i of this._effectSlurs)if(i.tryExpand(e.effectSlurOrigin,e,!1,!0)){s=!0;break}if(!s){const i=new Xn(`tab.slur.effect.${e.effectSlurOrigin.id}`,e.effectSlurOrigin,e,!1,!0);this._effectSlurs.push(i),this.addTie(i)}}if(e.slideInType!==St.None||e.slideOutType!==he.None){const s=new Wu(e.slideInType,e.slideOutType,e,this);this.addTie(s)}if(e.hasBend){if(!this._bend){const s=new wn;this._bend=s,s.renderer=this.renderer,this.addTie(s)}this._bend.addBends(e)}}}class Hu extends Lt{constructor(e,t){super(e,t,1,u.SixStringTabClef)}doLayout(){this.symbol=this.renderer.bar.staff.tuning.length<=4?u.FourStringTabClef:u.SixStringTabClef,this.center=!0,super.doLayout(),this.width=this.renderer.smuflMetrics.glyphWidths.get(u.GClef),this.offsetX=this.width/2}}class Gu extends mh{doLayout(){this.barSubElement=Le.GuitarTabsTimeSignature,super.doLayout()}get commonScale(){return 1}get numberScale(){return this.renderer.bar.staff.tuning.length<=4?We.GraceScale:1}}class fr extends Js{static StaffId="tab";_hasTuplets=!1;showTimeSignature=!1;showRests=!1;showTiedNotes=!1;_showMultiBarRest=!1;get showMultiBarRest(){return this._showMultiBarRest}get repeatsBarSubElement(){return Le.GuitarTabsRepeats}get barNumberBarSubElement(){return Le.GuitarTabsBarNumber}get barLineBarSubElement(){return Le.GuitarTabsBarLines}get staffLineBarSubElement(){return Le.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 e=this.settings.notation.rhythmMode;return e===Cs.Automatic&&(e=this.bar.staff.showStandardNotation?Cs.Hidden:Cs.ShowWithBars),e}getNoteLine(e){return this.bar.staff.tuning.length-e.string}minString=Number.NaN;maxString=Number.NaN;collectSpaces(e){if(this.additionalMultiRestBars)return;const t=this.smuflMetrics.staffLineThickness,s=this.bar.staff.tuning;for(const i of this.voiceContainer.beatGlyphs.values())for(const r of i){const n=r.onNotes,o=n.noteNumbers;if(o)for(const[l,h]of o.notesPerString)h.isEmpty||e[s.length-l].push(new Float32Array([this.beatGlyphsStart+r.x+n.x+o.x-t,o.width+t*2]))}}doLayout(){this.bar.staff.showStandardNotation&&this.scoreRenderer.layout.profile.has(qs.StaffId)||(this.showTimeSignature=!0,this.showRests=!0,this.showTiedNotes=!0,this._showMultiBarRest=!0),super.doLayout(),this.minString===0&&this.registerOverflowTop(this.lineSpacing/2),this.maxString===this.bar.staff.tuning.length-1&&this.registerOverflowBottom(this.lineSpacing/2),this.rhythmMode!==Cs.Hidden&&(this._hasTuplets=this.voiceContainer.tupletGroups.size>0,this._hasTuplets&&this.registerOverflowBottom(this.settings.notation.rhythmHeight+this.tupletSize))}createLinePreBeatGlyphs(){if(this.isFirstOfStaff){const e=(this.bar.staff.tuning.length-1)/2;this.createStartSpacing(),this.addPreBeatGlyph(new Hu(0,this.getLineY(e)))}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._createTimeSignatureGlyphs())}_createTimeSignatureGlyphs(){this.addPreBeatGlyph(new is(0,0,this.smuflMetrics.oneStaffSpace));const e=(this.bar.staff.tuning.length+1)/2-1;this.addPreBeatGlyph(new Gu(0,this.getLineY(e),this.bar.masterBar.timeSignatureNumerator,this.bar.masterBar.timeSignatureDenominator,this.bar.masterBar.timeSignatureCommon,this.bar.masterBar.isFreeTime))}createVoiceGlyphs(e){super.createVoiceGlyphs(e);for(const t of e.beats)this.addBeatGlyph(new Vu(t))}get flagsSubElement(){return rt.GuitarTabFlags}get beamsSubElement(){return rt.GuitarTabBeams}get tupletSubElement(){return rt.GuitarTabTuplet}paintBeams(e,t,s,i,r){this.rhythmMode!==Cs.Hidden&&super.paintBeams(e,t,s,i,r)}paintTuplets(e,t,s,i,r=!1){this.rhythmMode!==Cs.Hidden&&super.paintTuplets(e,t,s,i,r)}drawBeamHelperAsFlags(e){return super.drawBeamHelperAsFlags(e)||this.rhythmMode===Cs.ShowWithBeams}getFlagTopY(e,t){const s=e.maxStringNote,i=t===P.Up?D.TopWithStem:D.StemDown;return s?this.getNoteY(s,i):this.getRestY(e,i)}getFlagBottomY(e,t){const s=e.minStringNote,i=t===P.Up?D.StemUp:D.BottomWithStem;return s?this.getNoteY(s,i):this.getRestY(e,i)}getBeamDirection(e){return P.Down}shouldPaintFlag(e){return!(!super.shouldPaintFlag(e)||e.graceType!==K.None)}paintBeamingStem(e,t,s,i,r,n){if(r<i){const l=r;r=i,i=l}const o=xe.beat(n,rt.GuitarTabStem,e);try{let l=[];if(this.helpers.collisionHelper.reservedLayoutAreasByDisplayTime.has(e.displayStart)&&(l=this.helpers.collisionHelper.reservedLayoutAreasByDisplayTime.get(e.displayStart).slots.slice(),l.sort((d,f)=>d.topY-f.topY)),l.length===1){n.fillRect(s,i,this.smuflMetrics.stemThickness,r-i);return}const h=r-t,c=l[l.length-1];n.fillRect(s,t+c.bottomY,this.smuflMetrics.stemThickness,h-c.bottomY);for(let d=l.length-1;d>0;d--){const f=l[d].topY,p=l[d-1].bottomY;p<f&&n.fillRect(s,t+p,this.smuflMetrics.stemThickness,f-p)}}finally{o?.[Symbol.dispose]?.()}}calculateOverflows(e,t){super.calculateOverflows(e,t),!this.bar.isEmpty&&this.rhythmMode!==Cs.Hidden&&this.calculateBeamingOverflows(e,t)}}class Uu extends Sn{get staffId(){return fr.StaffId}constructor(e){super(e),this.hideOnPercussionTrack=!0}canCreate(e,t){return t.showTablature&&t.tuning.length>0&&super.canCreate(e,t)}create(e,t){return new fr(e,t)}}class An{vertical;createLayout;constructor(e,t){this.vertical=e,this.createLayout=t}}class In{supportsWorkers;createCanvas;constructor(e,t){this.supportsWorkers=e,this.createCanvas=t}}class M{static highDpiFactor=1;static _globalThis=void 0;static get globalThis(){if(M._globalThis===void 0){try{M._globalThis=globalThis}catch{}typeof M._globalThis>"u"&&(M._globalThis=self),typeof M._globalThis>"u"&&(M._globalThis=global),typeof M._globalThis>"u"&&(M._globalThis=window),typeof M._globalThis>"u"&&(M._globalThis=Function("return this")())}return M._globalThis}static webPlatform=M._detectWebPlatform();static isWebPackBundled=M._detectWebPack();static isViteBundled=M._detectVite();static scriptFile=M._detectScriptFile();static fontDirectory=M._detectFontDirectory();static get isRunningInWorker(){return"WorkerGlobalScope"in M.globalThis}static get isRunningInAudioWorklet(){return"AudioWorkletGlobalScope"in M.globalThis}static createWebWorker;static createAudioWorklet;static throttle(e,t){let s=0;return()=>{M.globalThis.clearTimeout(s),s=M.globalThis.setTimeout(e,t)}}static _detectScriptFile(){if(!M.isRunningInWorker&&M.globalThis.ALPHATAB_ROOT){let e=M.globalThis.ALPHATAB_ROOT;return e=M.ensureFullUrl(e),e=M._appendScriptName(e),e}try{const e=import.meta.url;if(e&&e.indexOf("file://")===-1)return e}catch{}return"document"in M.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 t="";const s=M.globalThis.location;if(t+=s.protocol?.toString(),t+="//",s.hostname&&(t+=s.hostname?.toString()),s.port&&(t+=":",t+=s.port?.toString()),!e.startsWith("/")){const i=s.pathname.split("/").slice(0,-1).join("/");i.length>0&&(i.startsWith("/")||(t+="/"),t+=i?.toString())}return e.startsWith("/")||(t+="/"),t+=e?.toString(),t}return e}static _appendScriptName(e){return e&&!e.endsWith(".js")&&(e.endsWith("/")||(e+="/"),e+="alphaTab.js"),e}static _detectFontDirectory(){if(!M.isRunningInWorker&&M.globalThis.ALPHATAB_FONT)return M.ensureFullUrl(M.globalThis.ALPHATAB_FONT);const e=M.scriptFile;if(e){const t=e.lastIndexOf("/");if(t>=0)return`${e.substr(0,t)}/font/`}return null}static _registerJQueryPlugin(){if(!M.isRunningInWorker&&M.globalThis&&"jQuery"in M.globalThis){const e=M.globalThis.jQuery,t=new yl;e.fn.alphaTab=function(s){const i=Array.prototype.slice.call(arguments,1);return this.length===1?t.exec(this[0],s,i):this.each((r,n)=>{t.exec(n,s,i)})},e.alphaTab={restore:yl.restore},e.fn.alphaTab.fn=t}}static renderEngines=M._createDefaultRenderEngines();static layoutEngines=M._createDefaultLayoutEngines();static staveProfiles=M._createDefaultStaveProfiles();static getRenderEngineFactory(e){return!e||!M.renderEngines.has(e)?M.renderEngines.get("default"):M.renderEngines.get(e)}static getLayoutEngineFactory(e){return!e||!M.layoutEngines.has(e)?M.layoutEngines.get(ni.Page):M.layoutEngines.get(e)}static buildImporters(){return[new ti,new Gh,new Wh,new Ze,new Fh,new gn]}static _createDefaultRenderEngines(){const e=new Map;return e.set("svg",new In(!0,()=>new oh)),e.set("default",e.get("svg")),e.set("skia",new In(!1,()=>new ut)),M._createPlatformSpecificRenderEngines(e),e}static enableAlphaSkia(e,t){ut.enable(e,t)}static registerAlphaSkiaCustomFont(e){return ut.registerFont(e)}static _createPlatformSpecificRenderEngines(e){e.set("html5",new In(!1,()=>new xc))}static defaultRenderers=[new Lu([{effect:new Vd,mode:ue.SharedTop},{effect:new zd,mode:ue.SharedTop},{effect:new bd,mode:ue.SharedTop},{effect:new ld,mode:ue.SharedTop},{effect:new pd,mode:ue.SharedTop},{effect:new Hd,mode:ue.SharedTop},{effect:new sd,mode:ue.SharedTop},{effect:new rd,mode:ue.SharedTop},{effect:new ed,mode:ue.SharedTop,order:1e3}]),new Cu([{effect:new id,mode:ue.SharedTop},{effect:new dd,mode:ue.SharedTop},{effect:new sn,mode:ue.SharedTop},{effect:new _d,mode:ue.SharedTop},{effect:new xd,mode:ue.SharedTop},{effect:new Yd,mode:ue.SharedTop},{effect:new Xd,mode:ue.OwnedTop},{effect:new Id,mode:ue.OwnedTop},{effect:new Pl,mode:ue.OwnedTop},{effect:new Bd(!0),mode:ue.OwnedTop},{effect:new _l,mode:ue.OwnedTop},{effect:new Nl,mode:ue.OwnedTop},{effect:new Cl,mode:ue.OwnedTop},{effect:new Tl,mode:ue.OwnedTop},{effect:new El,mode:ue.OwnedTop},{effect:new xl(!1),mode:ue.OwnedTop},{effect:new bl,mode:ue.OwnedTop,shouldCreate:e=>!e.showTablature},{effect:new Sl,mode:ue.OwnedTop,shouldCreate:e=>!e.showTablature},{effect:new wl,mode:ue.OwnedTop,shouldCreate:e=>!e.showTablature},{effect:new kl,mode:ue.OwnedTop,shouldCreate:e=>!e.showTablature},{effect:new fa(Xt.Finger),mode:ue.OwnedTop},{effect:new fa(Xt.Thumb),mode:ue.OwnedBottom},{effect:new nd,mode:ue.SharedBottom},{effect:new cd,mode:ue.SharedBottom},{effect:new Od,mode:ue.SharedBottom}]),new pu([{effect:new kd,mode:ue.OwnedTop,order:1e3}]),new Uu([{effect:new yd,mode:ue.SharedTop},{effect:new Xr,mode:ue.OwnedTop},{effect:new Pl,mode:ue.OwnedTop},{effect:new Cl,mode:ue.OwnedTop},{effect:new Tl,mode:ue.OwnedTop},{effect:new El,mode:ue.OwnedTop},{effect:new xl(!0),mode:ue.OwnedTop},{effect:new Nl,mode:ue.OwnedTop},{effect:new bl,mode:ue.OwnedTop},{effect:new vi(te.Natural),mode:ue.OwnedTop},{effect:new vi(te.Artificial),mode:ue.OwnedTop},{effect:new vi(te.Pinch),mode:ue.OwnedTop},{effect:new vi(te.Tap),mode:ue.OwnedTop},{effect:new vi(te.Semi),mode:ue.OwnedTop},{effect:new vi(te.Feedback),mode:ue.OwnedTop},{effect:new Sl,mode:ue.OwnedTop},{effect:new fd,mode:ue.OwnedTop},{effect:new Td,mode:ue.OwnedTop},{effect:new wl,mode:ue.OwnedTop},{effect:new kl,mode:ue.OwnedTop},{effect:new _l,mode:ue.OwnedTop},{effect:new fa(Xt.Finger),mode:ue.OwnedTop,shouldCreate:e=>!e.showStandardNotation},{effect:new fa(Xt.Thumb),mode:ue.OwnedBottom,shouldCreate:e=>!e.showStandardNotation}])];static _createDefaultStaveProfiles(){const e=new Map;return e.set(yi.Default,new Set([un.StaffId,qs.StaffId,hn.StaffId,fr.StaffId])),e.set(yi.ScoreTab,new Set([un.StaffId,qs.StaffId,hn.StaffId,fr.StaffId])),e.set(yi.Score,new Set([qs.StaffId])),e.set(yi.Tab,new Set([fr.StaffId])),e.set(yi.TabMixed,new Set([fr.StaffId])),e}static _createDefaultLayoutEngines(){const e=new Map;return e.set(ni.Page,new An(!0,t=>new ru(t))),e.set(ni.Horizontal,new An(!1,t=>new iu(t))),e.set(ni.Parchment,new An(!0,t=>new au(t))),e}static initializeMain(e,t){M.isRunningInWorker||M.isRunningInAudioWorklet||((M.webPlatform===us.Browser||M.webPlatform===us.BrowserModule)&&(M._registerJQueryPlugin(),M.highDpiFactor=window.devicePixelRatio),M.createWebWorker=e,M.createAudioWorklet=t)}static get alphaTabWorker(){return M.globalThis.Worker}static get alphaTabUrl(){return M.globalThis.URL}
65static initializeWorker(){if(!M.isRunningInWorker)throw new Ye(Ge.General,"Not running in worker, cannot run worker initialization");Lo.init(),Po.init(),M.createWebWorker=e=>{throw new Ye(Ge.General,"Nested workers are not supported")}}static initializeAudioWorklet(){if(!M.isRunningInAudioWorklet)throw new Ye(Ge.General,"Not running in audio worklet, cannot run worklet initialization");ka.init()}static _detectWebPack(){try{if(typeof __webpack_require__=="function")return typeof __ALPHATAB_WEBPACK__!="boolean"&&E.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 _detectVite(){try{if(typeof __BASE__=="string")return!0}catch{}return!1}static _detectWebPlatform(){if(!(typeof M.globalThis.Window<"u"&&M.globalThis instanceof M.globalThis.Window))try{if(Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]")return us.NodeJs}catch{}try{const t=import.meta.url;if(t&&typeof t=="string"&&!t.startsWith("file://"))return us.BrowserModule}catch{}return us.Browser}static printEnvironmentInfo(e=!0){const t=e?s=>{E.log.debug("VersionInfo",s)}:s=>{E.debug("VersionInfo",s)};qi.print(t),t(`High DPI: ${M.highDpiFactor}`),M._printPlatformInfo(t)}static _printPlatformInfo(e){e(`Platform: ${us[M.webPlatform]}`),e(`WebPack: ${M.isWebPackBundled}`),e(`Vite: ${M.isViteBundled}`),M.webPlatform!==us.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(typeof e=="object"){const t=e.__v_raw;if(t)return M.prepareForPostMessage(t)}return e}static quoteJsonString(e){return JSON.stringify(e)}static sortDescending(e){e.sort((t,s)=>s-t)}}var Is;(function(a){a[a.EmbeddedOpenType=0]="EmbeddedOpenType",a[a.Woff=1]="Woff",a[a.Woff2=2]="Woff2",a[a.OpenType=3]="OpenType",a[a.TrueType=4]="TrueType",a[a.Svg=5]="Svg"})(Is||(Is={}));class bh{scriptFile=null;fontDirectory=null;smuflFontSources=null;static buildDefaultSmuflFontSources(e){const t=new Map,s=e??"";return t.set(Is.Woff2,`${s}Bravura.woff2`),t.set(Is.Woff,`${s}Bravura.woff`),t.set(Is.OpenType,`${s}Bravura.otf`),t}file=null;tex=!1;tracks=null;enableLazyLoading=!0;engine="default";logLevel=Hs.Info;useWorkers=!0;includeNoteBounds=!1;constructor(){this.scriptFile=M.scriptFile,this.fontDirectory=M.fontDirectory}}const zu=Object.freeze(Object.defineProperty({__proto__:null,get AlphaTexAccidentalMode(){return Kr},AlphaTexDiagnosticBag:pn,get AlphaTexDiagnosticCode(){return fe},get AlphaTexDiagnosticsSeverity(){return ce},AlphaTexLexer:ft,get AlphaTexNodeType(){return x},get AlphaTexParseMode(){return Zi},AlphaTexParser:Zr,get AlphaTexStaffNoteKind(){return Jt},get AlphaTexVoiceMode(){return ri},get ArgumentListParseTypesMode(){return Pt}},Symbol.toStringTag,{value:"Module"})),rf=Object.freeze(Object.defineProperty({__proto__:null,AlphaTexErrorWithDiagnostics:Di,AlphaTexImporter:gn,ScoreImporter:sr,ScoreLoader:$i,UnsupportedFormatError:Bt,alphaTex:zu},Symbol.toStringTag,{value:"Module"})),af=Object.freeze(Object.defineProperty({__proto__:null,ByteBuffer:gt,IOHelper:k},Symbol.toStringTag,{value:"Module"}));class Yo{data;settings;init(e,t){this.data=e,this.settings=t}export(e,t=null){const s=gt.withCapacity(1024);return this.init(s,t??new di),this.writeScore(e),s.toArray()}}class Yu{tex="";isStartOfLine=!0;indentString="";currentIndent=0;indent(){this.indentString.length>0&&this.currentIndent++}outdent(){this.indentString.length>0&&this.currentIndent--}_preWrite(){if(this.isStartOfLine&&this.indentString.length>0)for(let e=0;e<this.currentIndent;e++)this.tex+=this.indentString;this.isStartOfLine=!1}write(e){this._preWrite(),this.tex+=e,this.isStartOfLine=!1}writeString(e){this._preWrite(),this.tex+=M.quoteJsonString(e)}writeLine(e){this._preWrite(),e!==void 0&&(this.tex+=e),this.indentString.length>0?this.tex+=`
66`:this.tex.endsWith(" ")||(this.tex+=" "),this.isStartOfLine=!0}}class Xu{_writer;_comments=!1;get tex(){return this._writer.tex}constructor(e){const t=new Yu;
vendor: 7,344 bytes, line 66
66this._comments=e.exporter.comments,t.indentString=e.exporter.indent>0?" ".repeat(e.exporter.indent):"",this._writer=t}writeScoreNode(e){this._writeComments(e.leadingComments);for(const t of e.bars)this._writeBar(t);this._writeComments(e.trailingComments)}_writeBar(e){this._writeComments(e.leadingComments),this._writeMetaDataList(e.metaData),this._writer.indent();for(const t of e.beats)this._writeBeat(t);this._writer.outdent(),this._writeComments(e.trailingComments),this._writeToken(e.pipe,!0)}_writeBeat(e){this._writeComments(e.leadingComments),e.durationChange&&this._writeDurationChange(e.durationChange),e.rest?this._writeValue(e.rest):e.notes&&this._writeNotes(e.notes),this._writeToken(e.durationDot,!1),this._writeValue(e.durationValue),this._writeToken(e.beatMultiplier,!1),this._writeValue(e.beatMultiplierValue),e.beatEffects&&this._writeProperties(e.beatEffects,!1),this._writeComments(e.trailingComments),this._writer.writeLine()}_writeNotes(e){this._writeComments(e.leadingComments),this._writeToken(e.openParenthesis,!1);let t=!0;for(const s of e.notes)t||this._writer.write(" "),this._writeNote(s),t=!1;this._writeToken(e.closeParenthesis,!1),this._writeComments(e.trailingComments)}_writeNote(e){this._writeComments(e.leadingComments),this._writeValue(e.noteValue),this._writeToken(e.noteStringDot,!1),this._writeValue(e.noteString),e.noteEffects&&this._writeProperties(e.noteEffects,!1),this._writeComments(e.trailingComments)}_writeDurationChange(e){this._writeComments(e.leadingComments),this._writeToken(e.colon,!1),this._writeValue(e.value),e.properties&&(this._writer.write(" "),this._writeProperties(e.properties,!1)),this._writeComments(e.trailingComments),this._writer.write(" ")}_writeMetaDataList(e){for(const t of e)this._writeMetaData(t)}_trackIndex=0;_staffIndex=0;_voiceIndex=0;_writeMetaData(e){switch(e.tag.tag.text){case"track":this._staffIndex>0&&this._writer.outdent(),this._trackIndex>0&&this._writer.outdent();break;case"staff":this._staffIndex>0&&this._writer.outdent();break;case"voice":this._voiceIndex>0&&this._writer.outdent();break}this._writeComments(e.leadingComments),this._writeToken(e.tag.prefix,!1),this._writeValue(e.tag.tag);let t=!0;switch(e.propertiesBeforeArguments?(e.properties&&(this._writer.write(" "),this._writeProperties(e.properties,!1)),e.arguments&&(this._writer.write(" "),this._writeValues(e.arguments))):(e.arguments&&(this._writer.write(" "),this._writeValues(e.arguments)),e.properties&&(this._writer.write(" "),this._writeProperties(e.properties,!0),t=!1)),e.trailingComments&&(this._writer.write(" "),this._writeComments(e.trailingComments)),e.tag.tag.text){case"track":this._trackIndex++,this._staffIndex=0,this._voiceIndex=0,this._writer.indent();break;case"staff":this._staffIndex++,this._voiceIndex=0,this._writer.indent();break;case"voice":this._voiceIndex++,this._writer.indent();break}t&&this._writer.writeLine()}_writeProperties(e,t){this._writeComments(e.leadingComments),this._writeToken(e.openBrace,t),t&&this._writer.indent();let s=!0;for(const i of e.properties)!s&&!t&&this._writer.write(" "),this._writeProperty(i),s=!1,t&&this._writer.writeLine();t&&this._writer.outdent(),this._writeToken(e.closeBrace,t),this._writeComments(e.trailingComments)}_writeProperty(e){this._writeComments(e.leadingComments),this._writeValue(e.property),e.arguments&&(this._writer.write(" "),this._writeValues(e.arguments)),this._writeComments(e.trailingComments)}_writeValues(e){this._writeComments(e.leadingComments),this._writeToken(e.openParenthesis,!1);let t=!0;for(const s of e.arguments)t||this._writer.write(" "),this._writeValue(s),t=!1;this._writeToken(e.closeParenthesis,!1),this._writeComments(e.trailingComments)}_writeValue(e){if(e){switch(this._writeComments(e.leadingComments),e.nodeType){case x.Ident:this._writer.write(e.text);break;case x.Arguments:this._writeValues(e);break;case x.Number:this._writer.write(e.value.toString());break;case x.String:this._writer.writeString(e.text);break}this._writeComments(e.trailingComments)}}_writeToken(e,t){if(e){switch(this._writeComments(e.leadingComments),e.nodeType){case x.Dot:this._writer.write(".");break;case x.Backslash:this._writer.write("\\");break;case x.DoubleBackslash:this._writer.write("\\\\");break;case x.Pipe:this._writer.write("|");break;case x.LBrace:this._writer.write("{");break;case x.RBrace:this._writer.write("}");break;case x.LParen:this._writer.write("(");break;case x.RParen:this._writer.write(")");break;case x.Colon:this._writer.write(":");break;case x.Asterisk:this._writer.write("*");break}this._writeComments(e.trailingComments),t&&this._writer.writeLine()}}_writeComments(e){if(!(!this._comments||!e))for(const t of e){let s=t.text;s.startsWith(" ")||(s=` ${s}`),t.multiLine?(s.endsWith(" ")||(s+=" "),this._writer.write(`/*${s}*/`)):this._writer.writeLine(`//${s}`)}}}class $u extends Yo{_handler=Z.instance;get name(){return"alphaTex"}exportToString(e,t=null){return this.settings=t??new di,this.scoreToAlphaTexString(e)}writeScore(e){const t=k.stringToBytes(this.scoreToAlphaTexString(e));this.data.write(t,0,t.length)}scoreToAlphaTexString(e){const t=new Xu(this.settings);return t.writeScoreNode(this._score(e)),t.tex}_score(e){const t={nodeType:x.Score,bars:[]};for(const s of e.tracks)this._track(t,s);return t.bars.length===0?t.bars.push({nodeType:x.Bar,metaData:this._handler.buildScoreMetaDataNodes(e),beats:[]}):t.bars[0].metaData=this._handler.buildScoreMetaDataNodes(e).concat(t.bars[0].metaData),t.bars.push({nodeType:x.Bar,metaData:this._handler.buildSyncPointNodes(e),beats:[]}),t}_track(e,t){for(const s of t.staves)this._staff(e,s)}_staff(e,t){const s=Math.max(...t.filledVoices)+1;if(t.bars.length===0){const i={nodeType:x.Bar,metaData:this._handler.buildBarMetaDataNodes(t,void 0,0,!1),beats:[],pipe:void 0};e.bars.push(i)}else for(let i=0;i<s;i++)this._voice(e,i,t,s>1)}_voice(e,t,s,i){for(const r of s.bars)this._bar(e,r,t,i)}_bar(e,t,s,i){const r={nodeType:x.Bar,metaData:this._handler.buildBarMetaDataNodes(t.staff,t,s,i),beats:[],pipe:void 0};if(t.isEmpty)r.trailingComments=[{multiLine:!1,text:`Bar ${t.index+1} / Voice ${s+1} no contents`}];else{const n=t.voices[s];if(n.isEmpty)r.trailingComments=[{multiLine:!1,text:`Bar ${t.index+1} / Voice ${s+1} no contents`}];else{for(const o of n.beats)r.beats.push(this._beat(o));r.beats.length>0&&(r.beats[0].leadingComments??=[],r.beats[0].leadingComments.unshift({multiLine:!1,text:`Bar ${t.index+1} / Voice ${s+1} contents`}))}}t.index<t.staff.bars.length-1&&(r.pipe={nodeType:x.Pipe}),e.bars.push(r)}_beat(e){const t={nodeType:x.Beat,durationChange:void 0,notes:void 0,rest:void 0,beatEffects:void 0};return e.isRest?t.rest={nodeType:x.Ident,text:"r"}:t.notes=this._notes(e.notes),t.durationDot={nodeType:x.Dot},t.durationValue={nodeType:x.Number,value:e.duration},t.beatEffects=this._beatEffects(e),t}_beatEffects(e){const t=this._handler.buildBeatEffects(e);return t.length>0?{nodeType:x.Props,openBrace:{nodeType:x.LBrace},properties:t,closeBrace:{nodeType:x.RBrace}}:void 0}_notes(e){const t={nodeType:x.NoteList,openParenthesis:void 0,notes:[],closeParenthesis:void 0};(e.length===0||e.length>1)&&(t.openParenthesis={nodeType:x.LParen},t.closeParenthesis={nodeType:x.RParen});for(const s of e)t.notes.push(this._note(s));return t}_note(e){const t={nodeType:x.Note,noteValue:{nodeType:x.Ident,text:""}}
66;if(e.isPercussion)t.noteValue={nodeType:x.String,text:Xe.getArticulationName(e)};else if(e.isPiano)t.noteValue={nodeType:x.Ident,text:I.getTextForTuning(e.realValueWithoutHarmonic,!0)};else if(e.isStringed){t.noteValue={nodeType:x.Number,value:e.fret},t.noteStringDot={nodeType:x.Dot};const s=e.beat.voice.bar.staff.tuning.length-e.string+1;t.noteString={nodeType:x.Number,value:s}}else throw new Error("What kind of note");return t.noteEffects=this._noteEffects(e),t}_noteEffects(e){const t=this._handler.buildNoteEffects(e);return t.length>0?{nodeType:x.Props,openBrace:{nodeType:x.LBrace},properties:t,closeBrace:{nodeType:x.RBrace}}:void 0}}class R{icon=A.Piano;instrumentSetName;instrumentSetType;constructor(e,t,s=null){if(this.icon=e,this.instrumentSetName=t,s)this.instrumentSetType=s;else{const i=t.split(" ");i[0]=i[0].substr(0,1).toLowerCase()+i[0].substr(1),this.instrumentSetType=i.join("")}}}var A;(function(a){a[a.SteelGuitar=1]="SteelGuitar",a[a.AcousticGuitar=2]="AcousticGuitar",a[a.TwelveStringGuitar=3]="TwelveStringGuitar",a[a.ElectricGuitar=4]="ElectricGuitar",a[a.Bass=5]="Bass",a[a.ClassicalGuitar=23]="ClassicalGuitar",a[a.UprightBass=6]="UprightBass",a[a.Ukulele=7]="Ukulele",a[a.Banjo=8]="Banjo",a[a.Mandolin=9]="Mandolin",a[a.Piano=10]="Piano",a[a.Synth=12]="Synth",a[a.Strings=11]="Strings",a[a.Brass=13]="Brass",a[a.Reed=14]="Reed",a[a.Woodwind=15]="Woodwind",a[a.Vocal=16]="Vocal",a[a.PitchedIdiophone=17]="PitchedIdiophone",a[a.Fx=21]="Fx",a[a.PercussionKit=18]="PercussionKit",a[a.Idiophone=19]="Idiophone",a[a.Membraphone=20]="Membraphone"})(A||(A={}));class qr{lineCount=0;name="";type="";elements=[];static create(e,t,s,i){const r=new qr;return r.name=e,r.type=t,r.lineCount=s,r.elements=i,r}}class we{name;type;soundbankName;articulations;constructor(e,t,s,i){this.name=e,this.type=t,this.soundbankName=s,this.articulations=i}}class J{name;staffLine;noteHeads;techniqueSymbol;techniqueSymbolPlacement;inputMidiNumbers;outputMidiNumber;outputRSESound;constructor(e,t,s,i,r,n,o,l){this.name=e,this.staffLine=t,this.noteHeads=s,this.techniqueSymbol=i,this.techniqueSymbolPlacement=r,this.inputMidiNumbers=n,this.outputMidiNumber=o,this.outputRSESound=l}static template(e,t,s){return new J(e,0,[],u.None,$e.Outside,t,0,s)}}class Mt{static _midiProgramInfoLookup=new Map([[0,new R(A.Piano,"Acoustic Piano")],[1,new R(A.Piano,"Acoustic Piano")],[2,new R(A.Piano,"Electric Piano")],[3,new R(A.Piano,"Acoustic Piano")],[4,new R(A.Piano,"Electric Piano")],[5,new R(A.Piano,"Electric Piano")],[6,new R(A.Piano,"Harpsichord")],[7,new R(A.Piano,"Harpsichord")],[8,new R(A.PitchedIdiophone,"Celesta")],[9,new R(A.PitchedIdiophone,"Vibraphone")],[10,new R(A.PitchedIdiophone,"Vibraphone")],[11,new R(A.PitchedIdiophone,"Vibraphone")],[12,new R(A.PitchedIdiophone,"Xylophone")],[13,new R(A.PitchedIdiophone,"Xylophone")],[14,new R(A.PitchedIdiophone,"Vibraphone")],[15,new R(A.Banjo,"Banjo")],[16,new R(A.Piano,"Electric Organ")],[17,new R(A.Piano,"Electric Organ")],[18,new R(A.Piano,"Electric Organ")],[19,new R(A.Piano,"Electric Organ")],[20,new R(A.Piano,"Electric Organ")],[21,new R(A.Piano,"Electric Organ")],[22,new R(A.Woodwind,"Recorder")],[23,new R(A.Piano,"Electric Organ")],[24,new R(A.ClassicalGuitar,"Nylon Guitar")],[25,new R(A.SteelGuitar,"Steel Guitar")],[26,new R(A.SteelGuitar,"Electric Guitar")],[27,new R(A.ElectricGuitar,"Electric Guitar")],[28,new R(A.ElectricGuitar,"Electric Guitar")],[29,new R(A.ElectricGuitar,"Electric Guitar")],[30,new R(A.SteelGuitar,"Electric Guitar")],[31,new R(A.SteelGuitar,"Electric Guitar")],[32,new R(A.Bass,"Acoustic Bass")],[33,new R(A.Bass,"Electric Bass")],[34,new R(A.Bass,"Electric Bass")],[35,new R(A.Bass,"Acoustic Bass")],[36,new R(A.Bass,"Electric Bass")],[37,new R(A.Bass,"Electric Bass")],[38,new R(A.Synth,"Synth Bass")],[39,new R(A.Synth,"Synth Bass")],[40,new R(A.Strings,"Violin")],[41,new R(A.Strings,"Viola")],[42,new R(A.Strings,"Cello")],[43,new R(A.Strings,"Contrabass")],[44,new R(A.Strings,"Violin")],[45,new R(A.Strings,"Violin")],[46,new R(A.Piano,"Harp")],[47,new R(A.Membraphone,"Timpani")],[48,new R(A.Strings,"Violin")],[49,new R(A.Strings,"Violin")],[50,new R(A.Strings,"Violin")],[51,new R(A.Strings,"Violin")],[52,new R(A.Vocal,"Voice")],[53,new R(A.Vocal,"Voice")],[54,new R(A.Vocal,"Voice")],[55,new R(A.Synth,"Pad Synthesizer")],[56,new R(A.Brass,"Trumpet")],[57,new R(A.Brass,"Trombone")],[58,new R(A.Brass,"Tuba")],[59,new R(A.Brass,"Trumpet")],[60,new R(A.Brass,"French Horn")],[61,new R(A.Brass,"Trumpet")],[62,new R(A.Brass,"Trumpet")],[63,new R(A.Brass,"Trumpet")],[64,new R(A.Reed,"Saxophone")],[65,new R(A.Reed,"Saxophone")],[66,new R(A.Reed,"Saxophone")],[67,new R(A.Reed,"Saxophone")],[68,new R(A.Reed,"Oboe")],[69,new R(A.Reed,"English Horn")],[70,new R(A.Reed,"Bassoon")],[71,new R(A.Reed,"Clarinet")],[72,new R(A.Reed,"Piccolo")],[73,new R(A.Woodwind,"Flute")],[74,new R(A.Woodwind,"Recorder")],[75,new R(A.Woodwind,"Flute")],[76,new R(A.Woodwind,"Recorder")],[77,new R(A.Woodwind,"Flute")],[78,new R(A.Woodwind,"Recorder")],[79,new R(A.Woodwind,"Flute")],[80,new R(A.Synth,"Lead Synthesizer")],[81,new R(A.Synth,"Lead Synthesizer")],[82,new R(A.Synth,"Lead Synthesizer")],[83,new R(A.Synth,"Lead Synthesizer")],[84,new R(A.Synth,"Lead Synthesizer")],[85,new R(A.Synth,"Lead Synthesizer")],[86,new R(A.Synth,"Lead Synthesizer")],[87,new R(A.Synth,"Lead Synthesizer")],[88,new R(A.Synth,"Pad Synthesizer")],[89,new R(A.Synth,"Pad Synthesizer")],[90,new R(A.Synth,"Pad Synthesizer")],[91,new R(A.Synth,"Pad Synthesizer")],[92,new R(A.Synth,"Pad Synthesizer")],[93,new R(A.Synth,"Pad Synthesizer")],[94,new R(A.Synth,"Pad Synthesizer")],[95,new R(A.Synth,"Pad Synthesizer")],[96,new R(A.Fx,"Pad Synthesizer")],[97,new R(A.Fx,"Pad Synthesizer")],[98,new R(A.Fx,"Pad Synthesizer")],[99,new R(A.Fx,"Pad Synthesizer")],[100,new R(A.Fx,"Lead Synthesizer")],[101,new R(A.Fx,"Lead Synthesizer")],[102,new R(A.Fx,"Lead Synthesizer")],[103,new R(A.Fx,"Trumpet")],[104,new R(A.ElectricGuitar,"Banjo")],[105,new R(A.Banjo,"Banjo")],[106,new R(A.Ukulele,"Ukulele")],[107,new R(A.Banjo,"Banjo")],[108,new R(A.PitchedIdiophone,"Xylophone")],[109,new R(A.Reed,"Bassoon")],[110,new R(A.Strings,"Violin")],[111,new R(A.Woodwind,"Flute")],[112,new R(A.PitchedIdiophone,"Xylophone")],[113,new R(A.Idiophone,"Celesta")],[114,new R(A.PitchedIdiophone,"Vibraphone")],[115,new R(A.Idiophone,"Xylophone")],[116,new R(A.Membraphone,"Xylophone")],[117,new R(A.Membraphone,"Xylophone")],[118,new R(A.Membraphone,"Xylophone")],[119,new R(A.Idiophone,"Celesta")],[120,new R(A.Fx,"Steel Guitar")],[121,new R(A.Fx,"Recorder")],[122,new R(A.Fx,"Recorder")],[123,new R(A.Fx,"Recorder")],[124,new R(A.Fx,"Recorder")],[125,new R(A.Fx,"Recorder")],[126,new R(A.Fx,"Recorder")],[127,new R(A.Fx,"Timpani")]]);static _drumInstrumentSet=qr.create("Drums","drumKit",5,[new we("Snare","snare","Master-Snare",[J.template("Snare (hit)",[38],"stick.hit.hit"),J.template("Snare (side stick)",[37],"stick.hit.sidestick"),J.template("Snare (rim shot)",[91],"stick.hit.rimshot")]),new we("Charley","hiHat","Master-Hihat",[J.template("Hi-Hat (closed)",[42],"stick.hit.closed"),J.template("Hi-Hat (half)",[92],"stick.hit.half"),J.template("Hi-Hat (open)",[46],"stick.hit.open"),J.template("Pedal Hi-Hat (hit)",[44],"pedal.hit.pedal")]),new we("Acoustic Kick Drum","kickDrum","AcousticKick-Percu",[J.template("Kick (hit)",[35],"pedal.hit.hit")]),new we("Kick Drum","kickDrum","Master-Kick",[J.template("Kick (hit)",[36],"pedal.hit.hit")]),new we("Tom Very High","tom","Master-Tom05",[J.template("High Floor Tom 
66(hit)",[50],"stick.hit.hit")]),new we("Tom High","tom","Master-Tom04",[J.template("High Tom (hit)",[48],"stick.hit.hit")]),new we("Tom Medium","tom","Master-Tom03",[J.template("Mid Tom (hit)",[47],"stick.hit.hit")]),new we("Tom Low","tom","Master-Tom02",[J.template("Low Tom (hit)",[45],"stick.hit.hit")]),new we("Tom Very Low","tom","Master-Tom01",[J.template("Very Low Tom (hit)",[43],"stick.hit.hit")]),new we("Ride","ride","Master-Ride",[J.template("Ride (edge)",[93],"stick.hit.edge"),J.template("Ride (middle)",[51],"stick.hit.mid"),J.template("Ride (bell)",[53],"stick.hit.bell"),J.template("Ride (choke)",[94],"stick.hit.choke")]),new we("Splash","splash","Master-Splash",[J.template("Splash (hit)",[55],"stick.hit.hit"),J.template("Splash (choke)",[95],"stick.hit.choke")]),new we("China","china","Master-China",[J.template("China (hit)",[52],"stick.hit.hit"),J.template("China (choke)",[96],"stick.hit.choke")]),new we("Crash High","crash","Master-Crash02",[J.template("Crash high (hit)",[49],"stick.hit.hit"),J.template("Crash high (choke)",[97],"stick.hit.choke")]),new we("Crash Medium","crash","Master-Crash01",[J.template("Crash medium (hit)",[57],"stick.hit.hit"),J.template("Crash medium (choke)",[98],"stick.hit.choke")]),new we("Cowbell Low","cowbell","CowbellBig-Percu",[J.template("Cowbell low (hit)",[99],"stick.hit.hit"),J.template("Cowbell low (tip)",[100],"stick.hit.tip")]),new we("Cowbell Medium","cowbell","CowbellMid-Percu",[J.template("Cowbell medium (hit)",[56],"stick.hit.hit"),J.template("Cowbell medium (tip)",[101],"stick.hit.tip")]),new we("Cowbell High","cowbell","CowbellSmall-Percu",[J.template("Cowbell high (hit)",[102],"stick.hit.hit"),J.template("Cowbell high (tip)",[103],"stick.hit.tip")]),new we("Woodblock Low","woodblock","WoodblockLow-Percu",[J.template("Woodblock low (hit)",[77],"stick.hit.hit")]),new we("Woodblock High","woodblock","WoodblockHigh-Percu",[J.template("Woodblock high (hit)",[76],"stick.hit.hit")]),new we("Bongo High","bongo","BongoHigh-Percu",[J.template("Bongo High (hit)",[60],"hand.hit.hit"),J.template("Bongo High (mute)",[104],"hand.hit.mute"),J.template("Bongo High (slap)",[105],"hand.hit.slap")]),new we("Bongo Low","bongo","BongoLow-Percu",[J.template("Bongo Low (hit)",[61],"hand.hit.hit"),J.template("Bongo Low (mute)",[106],"hand.hit.mute"),J.template("Bongo Low (slap)",[107],"hand.hit.slap")]),new we("Timbale Low","timbale","TimbaleLow-Percu",[J.template("Timbale low (hit)",[66],"stick.hit.hit")]),new we("Timbale High","timbale","TimbaleHigh-Percu",[J.template("Timbale high (hit)",[65],"stick.hit.hit")]),new we("Agogo Low","agogo","AgogoLow-Percu",[J.template("Agogo low (hit)",[68],"stick.hit.hit")]),new we("Agogo High","agogo","AgogoHigh-Percu",[J.template("Agogo high (hit)",[67],"stick.hit.hit")]),new we("Conga Low","conga","CongaLow-Percu",[J.template("Conga low (hit)",[64],"hand.hit.hit"),J.template("Conga low (slap)",[108],"hand.hit.slap"),J.template("Conga low (mute)",[109],"hand.hit.mute")]),new we("Conga High","conga","CongaHigh-Percu",[J.template("Conga high (hit)",[63],"hand.hit.hit"),J.template("Conga high (slap)",[110],"hand.hit.slap"),J.template("Conga high (mute)",[62],"hand.hit.mute")]),new we("Whistle Low","whistle","WhistleLow-Percu",[J.template("Whistle low (hit)",[72],"blow.hit.hit")]),new we("Whistle High","whistle","WhistleHigh-Percu",[J.template("Whistle high (hit)",[71],"blow.hit.hit")]),new we("Guiro","guiro","Guiro-Percu",[J.template("Guiro (hit)",[73],"stick.hit.hit"),J.template("Guiro (scrap-return)",[74],"stick.scrape.return")]),new we("Surdo","surdo","Surdo-Percu",[J.template("Surdo (hit)",[86],"brush.hit.hit"),J.template("Surdo (mute)",[87],"brush.hit.mute")]),new we("Tambourine","tambourine","Tambourine-Percu",[J.template("Tambourine (hit)",[54],"hand.hit.hit"),J.template("Tambourine (return)",[111],"hand.hit.return"),J.template("Tambourine (roll)",[112],"hand.hit.roll"),J.template("Tambourine (hand)",[113],"hand.hit.handhit")]),new we("Cuica","cuica","Cuica-Percu",[J.template("Cuica (open)",[79],"hand.hit.hit"),J.template("Cuica (mute)",[78],"hand.hit.mute")]),new we("Vibraslap","vibraslap","Vibraslap-Percu",[J.template("Vibraslap (hit)",[58],"hand.hit.hit")]),new we("Triangle","triangle","Triangle-Percu",[J.template("Triangle (hit)",[81],"stick.hit.hit"),J.template("Triangle (mute)",[80],"stick.hit.mute")]),new we("Grancassa","grancassa","Grancassa-Percu",[J.template("Grancassa (hit)",[114],"mallet.hit.hit")]),new we("Piatti","piatti","Piatti-Percu",[J.template("Piatti (hit)",[115],"hand.hit.hit"),J.template("Piatti (hand)",[116],"hand.hit.hit")]),new we("Cabasa","cabasa","Cabasa-Percu",[J.template("Cabasa (hit)",[69],"hand.hit.hit"),J.template("Cabasa (return)",[117],"hand.hit.return")]),new we("Castanets","castanets","Castanets-Percu",[J.template("Castanets (hit)",[85],"hand.hit.hit")]),new we("Claves","claves","Claves-Percu",[J.template("Claves (hit)",[75],"stick.hit.hit")]),new we("Left Maraca","maraca","Maracas-Percu",[J.template("Left Maraca (hit)",[70],"hand.hit.hit"),J.template("Left Maraca (return)",[118],"hand.hit.return")]),new we("Right Maraca","maraca","Maracas-Percu",[J.template("Right Maraca (hit)",[119],"hand.hit.hit"),J.template("Right Maraca (return)",[120],"hand.hit.return")]),new we("Shaker","shaker","ShakerStudio-Percu",[J.template("Shaker (hit)",[82],"hand.hit.hit"),J.template("Shaker (return)",[122],"hand.hit.return")]),new we("Bell Tree","bellTree","BellTree-Percu",[J.template("Bell Tree (hit)",[84],"stick.hit.hit"),J.template("Bell Tree (return)",[123],"stick.hit.return")]),new we("Jingle Bell","jingleBell","JingleBell-Percu",[J.template("Jingle Bell (hit)",[83],"stick.hit.hit")]),new we("Tinkle Bell","jingleBell","JingleBell-Percu",[J.template("Tinkle Bell (hit)",[83],"stick.hit.hit")]),new we("Golpe","unpitched","Golpe-Percu",[J.template("Golpe (thumb)",[124],"thumb.hit.body"),J.template("Golpe (finger)",[125],"finger4.hit.body")]),new we("Hand Clap","handClap","GroupHandClap-Percu",[J.template("Hand Clap (hit)",[39],"hand.hit.hit")]),new we("Electric Snare","snare","ElectricSnare-Percu",[J.template("Electric Snare (hit)",[40],"stick.hit.hit")]),new we("Sticks","snare","Stick-Percu",[J.template("Snare (side stick)",[31],"stick.hit.sidestick")]),new we("Very Low Floor Tom","tom","LowFloorTom-Percu",[J.template("Low Floor Tom 
66(hit)",[41],"stick.hit.hit")]),new we("Ride Cymbal 2","ride","Ride-Percu",[J.template("Ride (edge)",[59],"stick.hit.edge"),J.template("Ride (middle)",[126],"stick.hit.mid"),J.template("Ride (bell)",[127],"stick.hit.bell"),J.template("Ride (choke)",[29],"stick.hit.choke")]),new we("Reverse Cymbal","crash","Reverse-Cymbal",[J.template("Reverse Cymbal (hit)",[30],"stick.hit.hit")]),new we("Metronome","snare","Metronome-Percu",[J.template("Metronome (hit)",[33],"stick.hit.sidestick"),J.template("Metronome (bell)",[34],"stick.hit.hit")])]);static _elementByArticulation=void 0;static _articulationsById=void 0;static _initLookups(){const e=Mt._drumInstrumentSet,t=new Map,s=new Map;for(const i of e.elements)for(const r of i.articulations)for(const n of r.inputMidiNumbers){const o=`${i.name}.${n}`;t.set(o,i),s.set(o,r)}return Mt._elementByArticulation=t,Mt._articulationsById=s,t}static getIconId(e){return e.primaryChannel===9?A.PercussionKit:Mt._midiProgramInfoLookup.has(e.program)?Mt._midiProgramInfoLookup.get(e.program).icon:A.SteelGuitar}static buildInstrumentSet(e){return e.percussionArticulations.length>0||e.isPercussion?Mt._buildPercussionInstrumentSet(e):Mt._buildPitchedInstrumentSet(e)}static _pitchedElement=new we("Pitched","pitched","",[new J("",0,[u.NoteheadBlack,u.NoteheadHalf,u.NoteheadWhole],u.None,$e.Outside,[],0,"")]);static _buildPitchedInstrumentSet(e){const t=new qr;t.lineCount=e.staves[0].standardNotationLineCount;const s=Mt._midiProgramInfoLookup.has(e.playbackInfo.program)?Mt._midiProgramInfoLookup.get(e.playbackInfo.program):Mt._midiProgramInfoLookup.get(0);t.name=s.instrumentSetName,t.type=s.instrumentSetType;const i=new we(Mt._pitchedElement.name,Mt._pitchedElement.type,Mt._pitchedElement.soundbankName,[Mt._pitchedElement.articulations[0]]);return t.elements.push(i),t}static _buildPercussionInstrumentSet(e){Mt._elementByArticulation||Mt._initLookups();const t=new qr;t.lineCount=e.staves[0].standardNotationLineCount,t.name="Drums",t.type="drumKit";const s=e.percussionArticulations.length>0?e.percussionArticulations:Array.from(Xe.instrumentArticulations.values());let i;for(const r of s){const n=new J(r.elementType,r.staffLine,[r.noteHeadDefault,r.noteHeadHalf,r.noteHeadWhole],r.techniqueSymbol,r.techniqueSymbolPlacement,[r.id],r.outputMidiNumber,""),o=r.uniqueId;if(Mt._articulationsById.has(o)){const l=Mt._articulationsById.get(o);n.inputMidiNumbers=l.inputMidiNumbers,n.name=l.name,n.outputRSESound=l.outputRSESound}if(Mt._elementByArticulation.has(o)){const l=Mt._elementByArticulation.get(o);(!i||i.name!==r.elementType)&&(i=new we(l.name,l.type,l.soundbankName,[]),t.elements.push(i))}else(!i||i.name!==r.elementType)&&(i=new we(r.elementType,r.elementType,"",[]),t.elements.push(i));i.articulations.push(n)}return t}}class Qr{static _sampleRate=44100;_rhythmIdLookup=new Map;writeXml(e){const t=new jr;return this._rhythmIdLookup=new Map,this._writeDom(t,e),t.toFormattedString("",!0)}_writeDom(e,t){const s=e.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 r=s.addElement("Encoding");r.addElement("EncodingDescription").innerText="GP8";const n=new As;n.nodeType=ht.Comment,n.value=`Written by alphaTab ${qi.version} (${qi.commit})`,r.addChild(n),this._writeScoreNode(s,t),this._writeMasterTrackNode(s,t),this._writeBackingTrackNode(s,t),this._writeAudioTracksNode(s,t),this._writeTracksNode(s,t),this._writeMasterBarsNode(s,t),this._writeAssets(s,t);const o=s.addElement("Bars"),l=s.addElement("Voices"),h=s.addElement("Beats"),c=s.addElement("Notes"),d=s.addElement("Rhythms");for(const f of t.tracks)for(const p of f.staves)for(const g of p.bars){this._writeBarNode(o,g);for(const m of g.voices){this._writeVoiceNode(l,m);for(const b of m.beats){this._writeBeatNode(h,b,d);for(const S of b.notes)this._writeNoteNode(c,S)}}}}_writeAssets(e,t){if(!t.backingTrack?.rawAudioFile)return;const i=e.addElement("Assets").addElement("Asset");i.attributes.set("id",this._backingTrackAssetId),this.backingTrackAssetFileName="Content/Assets/backing-track",i.addElement("EmbeddedFilePath").setCData(this.backingTrackAssetFileName)}_backingTrackAssetId;_backingTrackFramePadding;backingTrackAssetFileName;_writeBackingTrackNode(e,t){if(!t.backingTrack?.rawAudioFile)return;const s=e.addElement("BackingTrack"),i="0";this._backingTrackAssetId=i,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=i;const r=s.addElement("ChannelStrip");r.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",r.addElement("YouTubeVideoUrl").innerText="",r.addElement("Filter").innerText="6",r.addElement("FramesPerPixel").innerText="400";const n=this._backingTrackFramePadding!==void 0?this._backingTrackFramePadding:0;s.addElement("FramePadding").innerText=`${n}`,s.addElement("Semitones").innerText="0",s.addElement("Cents").innerText="0"}_writeNoteNode(e,t){const s=e.addElement("Note");s.attributes.set("id",t.id.toString()),this._writeNoteProperties(s,t),t.isGhost&&(s.addElement("AntiAccent").innerText="normal"),t.isLetRing&&s.addElement("LetRing"),t.isTrill&&(s.addElement("Trill").innerText=t.trillValue.toString());let i=0;switch(t.isStaccato&&(i|=1),t.accentuated){case ct.Normal:i|=8;break;case ct.Heavy:i|=4;break;case ct.Tenuto:i|=16;break}if(i>0&&(s.addElement("Accent").innerText=i.toString()),t.isTieOrigin||t.isTieDestination){const r=s.addElement("Tie");r.attributes.set("origin",t.isTieOrigin?"true":"false"),r.attributes.set("destination",t.isTieDestination?"true":"false")}switch(t.vibrato){case Be.Slight:s.addElement("Vibrato").innerText="Slight";break;case Be.Wide:s.addElement("Vibrato").innerText="Wide";break}if(t.isFingering){switch(t.leftHandFinger){case ie.Thumb:s.addElement("LeftFingering").innerText="P";break;case ie.IndexFinger:s.addElement("LeftFingering").innerText="I";break;case ie.MiddleFinger:s.addElement("LeftFingering").innerText="M";break;case ie.AnnularFinger:s.addElement("LeftFingering").innerText="A";break;case ie.LittleFinger:s.addElement("LeftFingering").innerText="C";break}switch(t.rightHandFinger){case ie.Thumb:s.addElement("RightFingering").innerText="P";break;case ie.IndexFinger:s.addElement("RightFingering").innerText="I";break;case ie.MiddleFinger:s.addElement("RightFingering").innerText="M";break;case ie.AnnularFinger:s.addElement("RightFingering").innerText="A";break;case ie.LittleFinger:s.addElement("RightFingering").innerText="C";break}}t.percussionArticulation>=0?s.addElement("InstrumentArticulation").innerText=t.percussionArticulation.toString():s.addElement("InstrumentArticulation").innerText="0",t.ornament!==ot.None&&(s.addElement("Ornament").innerText=ot[t.ornament])}_writeNoteProperties(e,t){const s=e.addElement("Properties");if(this._writeConcertPitch(s,t),this._writeTransposedPitch(s,t),t.isStringed&&(this._writeSimplePropertyNode(s,"String","String",(t.string-1).toString()),this._writeSimplePropertyNode(s,"Fret","Fret",t.fret.toString()),this._writeSimplePropertyNode(s,"Midi","Number",t.realValue.toString()),t.showStringNumber&&this._writeSimplePropertyNode(s,"ShowStringNumber","Enable",null)),t.isPiano&&(this._writeSimplePropertyNode(s,"Octave","Number",t.octave.toString()),this._writeSimplePropertyNode(s,"Tone","Step",t.tone.toString()),this._writeSimplePropertyNode(s,"Midi","Number",t.realValue.toString())),t.beat.tap&&this._writeSimplePropertyNode(s,"Tapped","Enable",null),t.harmonicType!==te.None){switch(t.harmonicType){case te.Natural
vendor: 7,211 bytes, line 66
66:this._writeSimplePropertyNode(s,"HarmonicType","HType","Natural");break;case te.Artificial:this._writeSimplePropertyNode(s,"HarmonicType","HType","Artificial");break;case te.Pinch:this._writeSimplePropertyNode(s,"HarmonicType","HType","Pinch");break;case te.Tap:this._writeSimplePropertyNode(s,"HarmonicType","HType","Tap");break;case te.Semi:this._writeSimplePropertyNode(s,"HarmonicType","HType","Semi");break;case te.Feedback:this._writeSimplePropertyNode(s,"HarmonicType","HType","Feedback");break}t.harmonicValue!==0&&this._writeSimplePropertyNode(s,"HarmonicFret","HFret",t.harmonicValue.toString())}t.isDead&&this._writeSimplePropertyNode(s,"Muted","Enable",null),t.isPalmMute&&this._writeSimplePropertyNode(s,"PalmMuted","Enable",null),t.hasBend&&this._writeBend(s,t),t.isHammerPullOrigin&&this._writeSimplePropertyNode(s,"HopoOrigin","Enable",null),t.isHammerPullDestination&&this._writeSimplePropertyNode(s,"HopoDestination","Enable",null),t.isLeftHandTapped&&this._writeSimplePropertyNode(s,"LeftHandTapped","Enable",null);let i=0;switch(t.slideInType){case St.IntoFromAbove:i|=32;break;case St.IntoFromBelow:i|=16;break}switch(t.slideOutType){case he.Shift:i|=1;break;case he.Legato:i|=2;break;case he.OutDown:i|=4;break;case he.OutUp:i|=8;break;case he.PickSlideDown:i|=64;break;case he.PickSlideUp:i|=128;break}i>0&&this._writeSimplePropertyNode(s,"Slide","Flags",i.toString())}_writeTransposedPitch(e,t){t.isPercussion?this._writePitch(e,"ConcertPitch","C","-1",""):this._writePitchForValue(e,"TransposedPitch",t.displayValueWithoutBend,t.accidentalMode,t.beat.voice.bar.keySignature)}_writeConcertPitch(e,t){t.isPercussion?this._writePitch(e,"ConcertPitch","C","-1",""):this._writePitchForValue(e,"ConcertPitch",t.realValueWithoutHarmonic,t.accidentalMode,t.beat.voice.bar.keySignature)}static _defaultSteps=["C","C","D","D","E","F","F","G","G","A","A","B"];_writePitchForValue(e,t,s,i,r){let n=0,o=0,l="",h="";const c=()=>{switch(n=s%12,o=s/12|0,l=Qr._defaultSteps[n],L.computeAccidental(r,oe.Default,s,!1)){case ee.None:case ee.Natural:h="";break;case ee.Sharp:h="#";break;case ee.Flat:h="b";break;case ee.DoubleSharp:h="x";break;case ee.DoubleFlat:h="bb";break}};switch(c(),i){case oe.Default:break;case oe.ForceNone:h="";break;case oe.ForceNatural:h="";break;case oe.ForceSharp:h="#";break;case oe.ForceDoubleSharp:h==="#"&&(s-=2,c()),h="x";break;case oe.ForceFlat:h==="#"&&(s+=1,c()),h="b";break;case oe.ForceDoubleFlat:h==="#"&&(s+=2,c()),h="bb";break}this._writePitch(e,t,l,o.toString(),h)}_writePitch(e,t,s,i,r){const n=e.addElement("Property");n.attributes.set("name",t);const o=n.addElement("Pitch");o.addElement("Step").innerText=s,o.addElement("Accidental").innerText=r,o.addElement("Octave").innerText=i}_writeBend(e,t){t.hasBend&&t.bendPoints.length<=4&&this._writeStandardBend(e,t.bendPoints)}_writeStandardBend(e,t){this._writeSimplePropertyNode(e,"Bended","Enable",null);const s=t[0],i=t[t.length-1];let r,n;switch(t.length){case 4:r=t[1],n=t[2];break;case 3:r=t[1],n=t[1];break;default:r=new G((s.offset+i.offset)/2,(s.value+i.value)/2),n=r;break}this._writeSimplePropertyNode(e,"BendDestinationOffset","Float",this._toBendOffset(i.offset).toString()),this._writeSimplePropertyNode(e,"BendDestinationValue","Float",this._toBendValue(i.value).toString()),this._writeSimplePropertyNode(e,"BendMiddleOffset1","Float",this._toBendOffset(r.offset).toString()),this._writeSimplePropertyNode(e,"BendMiddleOffset2","Float",this._toBendOffset(n.offset).toString()),this._writeSimplePropertyNode(e,"BendMiddleValue","Float",this._toBendValue(r.value).toString()),this._writeSimplePropertyNode(e,"BendOriginOffset","Float",this._toBendOffset(s.offset).toString()),this._writeSimplePropertyNode(e,"BendOriginValue","Float",this._toBendValue(s.value).toString())}_toBendValue(e){return e*25}_toBendOffset(e){return e/G.MaxPosition*100}_writeBeatNode(e,t,s){const i=e.addElement("Beat");if(i.attributes.set("id",t.id.toString()),i.addElement("Dynamic").innerText=se[t.dynamics],t.fade!==yt.None&&(i.addElement("Fadding").innerText=yt[t.fade]),t.isTremolo)switch(t.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";break}switch(t.hasChord&&i.addElement("Chord").setCData(t.chordId),t.crescendo!==Gt.None&&(i.addElement("Hairpin").innerText=Gt[t.crescendo]),t.brushType){case z.ArpeggioUp:i.addElement("Arpeggio").innerText="Up";break;case z.ArpeggioDown:i.addElement("Arpeggio").innerText="Down";break}switch(t.text&&i.addElement("FreeText").setCData(t.text),t.graceType){case K.OnBeat:case K.BeforeBeat:i.addElement("GraceNotes").innerText=K[t.graceType];break}if(t.ottava!==le.Regular&&(i.addElement("Ottavia").innerText=le[t.ottava].substr(1)),t.hasWhammyBar&&this._writeWhammyNode(i,t),t.isLegatoOrigin||t.isLegatoDestination){const r=i.addElement("Legato");r.attributes.set("origin",t.isLegatoOrigin?"true":"false"),r.attributes.set("destination",t.isLegatoDestination?"true":"false")}if(this._writeRhythm(i,t,s),t.preferredBeamDirection!==null)switch(t.preferredBeamDirection){case P.Up:i.addElement("TransposedPitchStemOrientation").innerText="Upward",i.addElement("UserTransposedPitchStemOrientation").innerText="Upward";break;case P.Down:i.addElement("TransposedPitchStemOrientation").innerText="Downward",i.addElement("UserTransposedPitchStemOrientation").innerText="Downward";break}i.addElement("ConcertPitchStemOrientation").innerText="Undefined",t.slashed&&i.addElement("Slashed"),t.deadSlapped&&i.addElement("DeadSlapped"),t.notes.length>0&&(i.addElement("Notes").innerText=t.notes.map(r=>r.id).join(" ")),t.golpe!==Xt.None&&(i.addElement("Golpe").innerText=Xt[t.golpe]),t.wahPedal!==ss.None&&(i.addElement("Wah").innerText=ss[t.wahPedal]),t.showTimer&&(i.addElement("Timer").innerText=(t.timer??0).toString()),this._writeBeatProperties(i,t),this._writeBeatXProperties(i,t),t.lyrics&&t.lyrics.length>0&&this._writeBeatLyrics(i,t.lyrics)}_writeBeatLyrics(e,t){const s=e.addElement("Lyrics");for(const i of t)s.addElement("Line").setCData(i)}_writeBeatXProperties(e,t){const s=e.addElement("XProperties");switch(t.brushDuration>0&&this._writeSimpleXPropertyNode(s,"687935489","Int",t.brushDuration.toString()),t.beamingMode){case st.ForceSplitToNext:this._writeSimpleXPropertyNode(s,"1124204546","Int","2");break;case st.ForceMergeWithNext:this._writeSimpleXPropertyNode(s,"1124204546","Int","1");break;case st.ForceSplitOnSecondaryToNext:this._writeSimpleXPropertyNode(s,"1124204552","Int","1");break}}_writeBeatProperties(e,t){const s=e.addElement("Properties");switch(t.brushType){case z.BrushUp:this._writeSimplePropertyNode(s,"Brush","Direction","Up");break;case z.BrushDown:this._writeSimplePropertyNode(s,"Brush","Direction","Down");break}switch(t.pickStroke){case Ct.Up:this._writeSimplePropertyNode(s,"PickStroke","Direction","Up");break;case Ct.Down:this._writeSimplePropertyNode(s,"PickStroke","Direction","Down");break}switch(t.slap&&this._writeSimplePropertyNode(s,"Slapped","Enable",null),t.pop&&this._writeSimplePropertyNode(s,"Popped","Enable",null),t.vibrato){case Be.Wide:this._writeSimplePropertyNode(s,"VibratoWTremBar","Strength","Wi
66de");break;case Be.Slight:this._writeSimplePropertyNode(s,"VibratoWTremBar","Strength","Slight");break}if(t.isBarre)switch(this._writeSimplePropertyNode(s,"BarreFret","Fret",t.barreFret.toString()),t.barreShape){case xs.Full:this._writeSimplePropertyNode(s,"BarreString","String","0");break;case xs.Half:this._writeSimplePropertyNode(s,"BarreString","String","1");break}if(t.rasgueado!==ne.None){let i="";switch(t.rasgueado){case ne.Ii:i="ii_1";break;case ne.Mi:i="mi_1";break;case ne.MiiTriplet:i="mii_1";break;case ne.MiiAnapaest:i="mii_2";break;case ne.PmpTriplet:i="pmp_1";break;case ne.PmpAnapaest:i="pmp_2";break;case ne.PeiTriplet:i="pei_1";break;case ne.PeiAnapaest:i="pei_2";break;case ne.PaiTriplet:i="pai_1";break;case ne.PaiAnapaest:i="pai_2";break;case ne.AmiTriplet:i="ami_1";break;case ne.AmiAnapaest:i="ami_2";break;case ne.Ppp:i="ppp_1";break;case ne.Amii:i="amii_1";break;case ne.Amip:i="amip_1";break;case ne.Eami:i="eami_1";break;case ne.Eamii:i="eamii_1";break;case ne.Peami:i="peami_1";break}this._writeSimplePropertyNode(s,"Rasgueado","Rasgueado",i)}}_writeRhythm(e,t,s){const i=`${t.duration}_${t.dots}_${t.tupletNumerator}_${t.tupletDenominator}';`;let r;if(this._rhythmIdLookup.has(i))r=this._rhythmIdLookup.get(i);else{r=this._rhythmIdLookup.size.toString(),this._rhythmIdLookup.set(i,r);const n=s.addElement("Rhythm");if(n.attributes.set("id",r),t.hasTuplet){const l=n.addElement("PrimaryTuplet");l.attributes.set("num",t.tupletNumerator.toString()),l.attributes.set("den",t.tupletDenominator.toString())}t.dots>0&&n.addElement("AugmentationDot").attributes.set("count",t.dots.toString());let o="Quarter";switch(t.duration){case y.QuadrupleWhole:o="Long";break;case y.DoubleWhole:o="DoubleWhole";break;case y.Whole:o="Whole";break;case y.Half:o="Half";break;case y.Quarter:o="Quarter";break;case y.Eighth:o="Eighth";break;case y.Sixteenth:o="16th";break;case y.ThirtySecond:o="32nd";break;case y.SixtyFourth:o="64th";break;case y.OneHundredTwentyEighth:o="128th";break;case y.TwoHundredFiftySixth:o="256th";break}n.addElement("NoteValue").innerText=o}e.addElement("Rhythm").attributes.set("ref",r)}_writeWhammyNode(e,t){t.hasWhammyBar&&t.whammyBarPoints.length<=4&&this._writeStandardWhammy(e,t.whammyBarPoints)}_writeStandardWhammy(e,t){const s=e.addElement("Whammy"),i=t[0],r=t[t.length-1];let n,o;switch(t.length){case 4:n=t[1],o=t[2];break;case 3:n=t[1],o=t[1];break;default:n=new G((i.offset+r.offset)/2,(i.value+r.value)/2),o=n;break}s.attributes.set("destinationOffset",this._toBendOffset(r.offset).toString()),s.attributes.set("destinationValue",this._toBendValue(r.value).toString()),s.attributes.set("middleOffset1",this._toBendOffset(n.offset).toString()),s.attributes.set("middleOffset2",this._toBendOffset(o.offset).toString()),s.attributes.set("middleValue",this._toBendValue(n.value).toString()),s.attributes.set("originOffset",this._toBendOffset(i.offset).toString()),s.attributes.set("originValue",this._toBendValue(i.value).toString())}_writeScoreNode(e,t){const s=e.addElement("Score");s.addElement("Title").setCData(t.title),s.addElement("SubTitle").setCData(t.subTitle),s.addElement("Artist").setCData(t.artist),s.addElement("Album").setCData(t.album),s.addElement("Words").setCData(t.words),s.addElement("Music").setCData(t.music),s.addElement("WordsAndMusic").setCData(t.words===t.music?t.words:""),s.addElement("Copyright").setCData(t.copyright),s.addElement("Tabber").setCData(t.tab),s.addElement("Instructions").setCData(t.instructions),s.addElement("Notices").setCData(t.notices),s.addElement("FirstPageHeader").setCData(""),s.addElement("FirstPageFooter").setCData(""),s.addElement("PageHeader").setCData(""),s.addElement("PageFooter").setCData(""),s.addElement("ScoreSystemsDefaultLayout").setCData(t.defaultSystemsLayout.toString()),s.addElement("ScoreSystemsLayout").setCData(t.systemsLayout.join(" ")),s.addElement("ScoreZoomPolicy").innerText="Value",s.addElement("ScoreZoom").innerText="1",s.addElement("MultiVoice").innerText="1>"}_writeMasterTrackNode(e,t){const s=e.addElement("MasterTrack");s.addElement("Tracks").innerText=t.tracks.map(l=>l.index).join(" ");const i=s.addElement("Automations");
vendor: 19,331 bytes, line 66
66if(t.masterBars.length>0&&t.masterBars[0].isAnacrusis&&s.addElement("Anacrusis"),t.masterBars[0].tempoAutomations.length===0){const l=i.addElement("Automation");l.addElement("Type").innerText="Tempo",l.addElement("Linear").innerText="false",l.addElement("Bar").innerText="0",l.addElement("Position").innerText="0",l.addElement("Visible").innerText="true",l.addElement("Value").innerText=`${t.tempo} 2`,t.tempoLabel&&(l.addElement("Text").innerText=t.tempoLabel)}const r=t.masterBars[0].syncPoints?t.masterBars[0].syncPoints.find(l=>l.ratioPosition===0&&l.syncPointValue.barOccurence===0):void 0,n=r?r.syncPointValue.millisecondOffset:0;this._backingTrackFramePadding=-1*(n/1e3*Qr._sampleRate)|0;const o=new mr(()=>Ne.buildModifiedTempoLookup(t));for(const l of t.masterBars){for(const h of l.tempoAutomations){const c=i.addElement("Automation");c.addElement("Type").innerText="Tempo",c.addElement("Linear").innerText=h.isLinear?"true":"false",c.addElement("Bar").innerText=l.index.toString(),c.addElement("Position").innerText=h.ratioPosition.toString(),c.addElement("Visible").innerText=h.isVisible?"true":"false",c.addElement("Value").innerText=`${h.value} 2`,h.text&&(c.addElement("Text").innerText=h.text)}if(l.syncPoints)for(const h of l.syncPoints){const c=i.addElement("Automation");c.addElement("Type").innerText="SyncPoint",c.addElement("Linear").innerText="false",c.addElement("Bar").innerText=l.index.toString(),c.addElement("Position").innerText=h.ratioPosition.toString(),c.addElement("Visible").innerText=h.isVisible?"true":"false";const d=c.addElement("Value");d.addElement("BarIndex").innerText=l.index.toString(),d.addElement("BarOccurrence").innerText=h.syncPointValue.barOccurence.toString(),d.addElement("ModifiedTempo").innerText=o.value.get(h).syncBpm.toString(),d.addElement("OriginalTempo").innerText=t.tempo.toString();let f=(h.syncPointValue.millisecondOffset-n)/1e3*Qr._sampleRate;f=Math.floor(f+.5),d.addElement("FrameOffset").innerText=f.toString()}}}_writeAudioTracksNode(e,t){e.addElement("AudioTracks")}_writeTracksNode(e,t){const s=e.addElement("Tracks");for(const i of t.tracks)this._writeTrackNode(s,i)}_writeTrackNode(e,t){const s=e.addElement("Track");s.attributes.set("id",t.index.toString()),s.addElement("Name").setCData(t.name),s.addElement("ShortName").setCData(t.shortName),s.addElement("Color").innerText=`${t.color.r} ${t.color.g} ${t.color.b}`,s.addElement("SystemsDefautLayout").innerText=t.defaultSystemsLayout.toString(),s.addElement("SystemsLayout").innerText=t.systemsLayout.join(" "),s.addElement("AutoBrush"),s.addElement("PalmMute").innerText="0",s.addElement("PlayingStyle").innerText=Ss.isGuitar(t.playbackInfo.program)?"StringedPick":"Default",s.addElement("UseOneChannelPerString"),s.addElement("IconId").innerText=Mt.getIconId(t.playbackInfo).toString(),this._writeInstrumentSetNode(s,t),this._writeTransposeNode(s,t),this._writeRseNode(s,t),s.addElement("ForcedSound").innerText="-1",this._writeMidiConnectionNode(s,t),t.playbackInfo.isSolo?s.addElement("PlaybackState").innerText="Solo":t.playbackInfo.isMute?s.addElement("PlaybackState").innerText="Mute":s.addElement("PlaybackState").innerText="Default",s.addElement("AudioEngineState").innerText="MIDI",this._writeLyricsNode(s,t),this._writeStavesNode(s,t),this._writeSoundsAndAutomations(s,t)}_writeSoundAndAutomation(e,t,s,i,r,n,o,l,h=0){const c=e.addElement("Sound");c.addElement("Name").setCData(s),c.addElement("Label").setCData(s),c.addElement("Path").setCData(i),c.addElement("Role").setCData(r);const d=c.addElement("MIDI"),f=Ss.bankToLsbMsb(l);d.addElement("LSB").innerText=f[0].toString(),d.addElement("MSB").innerText=f[1].toString(),d.addElement("Program").innerText=o.toString();const p=t.addElement("Automation");p.addElement("Type").innerText="Sound",p.addElement("Linear").innerText="false",p.addElement("Bar").innerText=n.toString(),p.addElement("Position").innerText=h.toString(),p.addElement("Visible").innerText="true",p.addElement("Value").setCData(`${i};${s};${r}`)}_writeSoundsAndAutomations(e,t){const s=e.addElement("Sounds"),i=e.addElement("Automations");if(t.staves.length>0&&t.staves[0].bars.length>0){const r=`Track_${t.index}_Initial`,n=`Midi/${t.playbackInfo.program}`,o="Factory";let l=!1,h=t.playbackInfo.bank;for(const c of t.staves)for(const d of c.bars)for(const f of d.voices)for(const p of f.beats){const g=p.getAutomation(Re.Instrument),m=d.index===0&&p.index===0,b=p.getAutomation(Re.Bank);if(b&&(h=b.value),g){const S=m?r:`ProgramChange_${p.id}`,N=m?n:`Midi/${g.value}`,v=m?o:"User";!m&&!l&&(this._writeSoundAndAutomation(s,i,r,n,o,t.staves[0].bars[0].index,t.playbackInfo.program,t.playbackInfo.bank),l=!0),this._writeSoundAndAutomation(s,i,S,N,v,d.index,g.value,h,g.ratioPosition),m&&(l=!0)}}}for(const r of t.staves)for(const n of r.bars)for(const o of n.sustainPedals)if(o.pedalType!==it.Hold){const l=i.addElement("Automation");switch(l.addElement("Type").innerText="SustainPedal",l.addElement("Linear").innerText="false",l.addElement("Bar").innerText=n.index.toString(),l.addElement("Position").innerText=o.ratioPosition.toString(),l.addElement("Visible").innerText="true",o.pedalType){case it.Down:l.addElement("Value").innerText="0 1";break;case it.Up:l.addElement("Value").innerText="0 3";break}}}_writeMidiConnectionNode(e,t){const s=e.addElement("MidiConnection");s.addElement("Port").innerText=t.playbackInfo.port.toString(),s.addElement("PrimaryChannel").innerText=t.playbackInfo.primaryChannel.toString(),s.addElement("SecondaryChannel").innerText=t.playbackInfo.secondaryChannel.toString(),s.addElement("ForeOneChannelPerString").innerText="false"}_writeRseNode(e,t){const i=e.addElement("RSE").addElement("ChannelStrip");i.attributes.set("version","E56");const r=i.addElement("Parameters");r.innerText=`0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 1 0.5 ${t.playbackInfo.balance/16} ${t.playbackInfo.volume/16} 0.5 0.5 0.5`}_writeStavesNode(e,t){const s=e.addElement("Staves");for(const i of t.staves)this._writeStaffNode(s,i)}_writeStaffNode(e,t){const i=e.addElement("Staff").addElement("Properties");if(this._writeSimplePropertyNode(i,"CapoFret","Fret",t.capo.toString()),this._writeSimplePropertyNode(i,"FretCount","Fret","24"),t.tuning.length>0){const r=i.addElement("Property");switch(r.attributes.set("name","Tuning"),r.addElement("Pitches").innerText=t.tuning.slice().reverse().join(" "),r.addElement("Label").setCData(t.tuningName),r.addElement("LabelVisible").innerText=t.tuningName?"true":"false",r.addElement("Flat"),t.tuning.length){case 3:r.addElement("Instrument").innerText="Shamisen";break;case 4:t.track.playbackInfo.program===105?r.addElement("Instrument").innerText="Banjo":t.track.playbackInfo.program===42?r.addElement("Instrument").innerText="Cello":t.track.playbackInfo.program===43?r.addElement("Instrument").innerText="Contrabass":t.track.playbackInfo.program===40?r.addElement("Instrument").innerText="Violin":t.track.playbackInfo.program===41?r.addElement("Instrument").innerText="Viola":r.addElement("Instrument").innerText="Bass";break;case 5:t.track.playbackInfo.program===105?r.addElement("Instrument").innerText="Banjo":r.addElement("Instrument").innerText="Bass";break;case 6:t.track.playbackInfo.program===105?r.addElement("Instrument").innerText="Banjo":t.track.playbackInfo.program<=39?r.addElement("Instrument").innerText="Bass":r.addElement("Instrument").innerText="Guitar";break;case 7:t.track.playbackInfo.program<=39?r.addElement("Instrument").innerText="Bass":r.addElement("Instrument").innerText="Guitar";break;default:r.addElement("Instrument").innerText="Guitar";break}}this._writeSimplePropertyNode(i,"PartialCapoFret","Fret","0"),this._writeSimplePropertyNode(i,"PartialCapoStringFlags","Bitset",t.tuning.map(r=>"0").join("")),this._writeSimplePropertyNode(i,"TuningFlat","Enable",null),this._writeDiagramCollection(i,t,"DiagramCollection"),this._writeDiagramCollection(i,t,"DiagramWorkingSet")}_writeDiagramCollection(e,t,s){const i=e.addElement("Property");i.attributes.set("name",s);const r=i.addElement("Items"),n=t.chords;if(n)for(const[o,l]of n){const h=r.addElement("Item");h.attributes.set("id",o),h.attributes.set("name",l.name);const c=h.addElement("Diagram");c.attributes.set("stringCount",l.strings.length.toString()),c.attributes.set("fretCount","5"),c.attributes.set("baseFret",(l.firstFret-1).toString()),c.attributes.set("barStates",l.strings.map(q=>"1").join(" "));const d=[],f=new Map;for(let q=0;q<l.strings.length;q++){const F=l.strings[q];if(F!==-1){const Q=c.addElement("Fret"),me=l.strings.length-1-q;Q.attributes.set("string",me.toString()),Q.attributes.set("fret",(F-l.firstFret+1).toString()),f.has(F)||(f.set(F,[]),d.push(F)),f.get(F).push(me)}}d.sort();const p=c.addElement("Fingering");if(l.barreFrets.length>0){const q=[ie.LittleFinger,ie.AnnularFinger,ie.MiddleFinger,ie.IndexFinger];for(const F of d){const Q=f.get(F);if(Q.length>1&&l.barreFrets.indexOf(F)>=0){const me=q.length>0?q.pop():ie.IndexFinger;for(const ge of Q){const re=p.addElement("Position");switch(me){case ie.LittleFinger:re.attributes.set("finger","Pinky");break;case ie.AnnularFinger:re.attributes.set("finger","Ring");break;case ie.MiddleFinger:re.attributes.set("finger","Middle");break;case ie.IndexFinger:re.attributes.set("finger","Index");break}re.attributes.set("fret",(F-l.firstFret+1).toString()),re.attributes.set("string",ge.toString())}}}}const g=c.addElement("Property");g.attributes.set("name","ShowName"),g.attributes.set("type","bool"),g.attributes.set("value",l.showName?"true":"false");const m=c.addElement("Property");m.attributes.set("name","ShowDiagram"),m.attributes.set("type","bool"),m.attributes.set("value",l.showDiagram?"true":"false");const b=c.addElement("Property");b.attributes.set("name","ShowFingering"),b.attributes.set("type","bool"),b.attributes.set("value",l.showFingering?"true":"false");const S=c.addElement("Chord"),N=S.addElement("KeyNote");N.attributes.set("step","C"),N.attributes.set("accidental","Natural");const v=S.addElement("BassNote");v.attributes.set("step","C"),v.attributes.set("accidental","Natural");const W=S.addElement("Degree");W.attributes.set("interval","Third"),W.attributes.set("alteration","Major"),W.attributes.set("omitted","false");const j=S.addElement("Degree");j.attributes.set("interval","Fifth"),j.attributes.set("alteration","Perfect"),j.attributes.set("omitted","false")}}_writeSimplePropertyNode(e,t,s,i){const r=e.addElement("Property");r.attributes.set("name",t);const n=r.addElement(s);return i!==null&&(n.innerText=i),r}_writeSimpleXPropertyNode(e,t,s,i){const r=e.addElement("XProperty");r.attributes.set("id",t);const n=r.addElement(s);return i!==null&&(n.innerText=i),r}_writeLyricsNode(e,t){const s=e.addElement("Lyrics");s.attributes.set("dispatched","true");const i=[];for(const r of t.staves[0].bars)for(const n of r.voices)if(!n.isEmpty){for(const o of n.beats)if(o.lyrics)for(let l=0;l<o.lyrics.length;l++){for(;l>=i.length;){const c=new es;c.startBar=r.index,c.text="[Empty]",i.push(c)}const h=i[l];h.text=h.text==="[Empty]"?o.lyrics[l]:`${h.text} ${o.lyrics[l].split(" ").join("+")}`}}for(let r=0;r<i.length;r++){const n=s.addElement("Line");n.addElement("Text").setCData(i[r].text),n.addElement("Offset").innerText=i[r].startBar.toString()}}_writeTransposeNode(e,t){const s=e.addElement("Transpose"),i=Math.floor(t.staves[0].displayTranspositionPitch/12),r=t.staves[0].displayTranspositionPitch-i*12;s.addElement("Chromatic").innerText=r.toString(),s.addElement("Octave").innerText=i.toString()}_writeInstrumentSetNode(e,t){const s=Mt.buildInstrumentSet(t),i=e.addElement("InstrumentSet");i.addElement("Name").innerText=s.name,i.addElement("Type").innerText=s.type,i.addElement("LineCount").innerText=s.lineCount.toString();const r=i.addElement("Elements");for(const n of s.elements){const o=r.addElement("Element");o.addElement("Name").innerText=n.name,o.addElement("Type").innerText=n.type,o.addElement("SoundbankName").innerText=n.soundbankName;const l=o.addElement("Articulations");for(const h of n.articulations){const c=l.addElement("Articulation");switch(c.addElement("Name").innerText=h.name,c.addElement("StaffLine").innerText=h.staffLine.toString(),c.addElement("Noteheads").innerText=[this._mapMusicSymbol(h.noteHeads[0]),this._mapMusicSymbol(h.noteHeads[1]),this._mapMusicSymbol(h.noteHeads[2])].join(" "),h.techniqueSymbolPlacement){case $e.Below:c.addElement("TechniquePlacement").innerText="below";break;case $e.Outside:c.addElement("TechniquePlacement").innerText="outside";break;case $e.Inside:c.addElement("TechniquePlacement").innerText="inside";break;case $e.Above:c.addElement("TechniquePlacement").innerText="above";break}c.addElement("TechniqueSymbol").innerText=this._mapMusicSymbol(h.techniqueSymbol),c.addElement("InputMidiNumbers").innerText=h.inputMidiNumbers.map(d=>d.toString()).join(" "),c.addElement("OutputRSESound").innerText=h.outputRSESound,c.addElement("OutputMidiNumber").innerText=h.outputMidiNumber.toString()}}}_mapMusicSymbol(e){if(e===u.None)return"";const t=u[e];return t.substring(0,1).toLowerCase()+t.substring(1)}_writeMasterBarsNode(e,t){const s=e.addElement("MasterBars");for(const i of t.masterBars)this._writeMasterBarNode(s,i)}_writeMasterBarNode(e,t){const s=e.addElement("MasterBar"),i=s.addElement("Key");let r=t.score.tracks[0].staves[0].bars[t.index].keySignature;const n=t.score.tracks[0].staves[0].bars[t.index].keySignatureType,o=L.flooredDivision(t.score.tracks[0].staves[0].displayTranspositionPitch,12);r=L.transposeKey(r,-o),i.addElement("AccidentalCount").innerText=r.toString(),i.addElement("Mode").innerText=as[n],i.addElement("Sharps").innerText="Sharps",s.addElement("Time").innerText=`${t.timeSignatureNumerator}/${t.timeSignatureDenominator}`,t.actualBeamingRules&&this._writeBarXProperties(s,t),t.isFreeTime&&s.addElement("FreeTime");const l=[];for(const h of t.score.tracks)for(const c of h.staves)l.push(c.bars[t.index].id.toString());if(s.addElement("Bars").innerText=l.join(" "),t.isDoubleBar&&s.addElement("DoubleBar"),t.isSectionStart){const h=s.addElement("Section");h.addElement("Letter").setCData(t.section.marker),h.addElement("Text").setCData(t.section.text)}if(t.isRepeatStart||t.isRepeatEnd){const h=s.addElement("Repeat");h.attributes.set("start",t.isRepeatStart?"true":"false"),h.attributes.set("end",t.isRepeatEnd?"true":"false"),t.isRepeatEnd&&h.attributes.set("count",t.repeatCount.toString())}if(t.alternateEndings>0){let h=t.alternateEndings;const c=[];let d=0;for(;h>0;)(h>>d&1)===1&&(c.push(d+1),h&=~(1<<d)),d++;s.addElement("AlternateEndings").innerText=c.join(" ")}if(t.tripletFeel!==Ce.NoTripletFeel&&(s.addElement("TripletFeel").innerText=Ce[t.tripletFeel]),t.directions&&t.directions.size>0){const h=s.addElement("Directions");for(const c of t.directions)switch(c){case U.TargetFine:h.addElement("Target").innerText="Fine";break;case U.TargetSegno:h.addElement("Target").innerText="Segno";break;case U.TargetSegnoSegno:h.addElement("Target").innerText="SegnoSegno";break;case U.TargetCoda:h.addElement("Target").innerText="Coda";break;case U.TargetDoubleCoda:h.addElement("Target").innerText="DoubleCoda";break;case U.JumpDaCapo:h.addElement("Jump").innerText="DaCapo";break;case U.JumpDaCapoAlCoda:h.addElement("Jump").innerText="DaCapoAlCoda";break;case U.JumpDaCapoAlDoubleCoda:h.addElement("Jump").innerText="DaCapoAlDoubleCoda";break;case U.JumpDaCapoAlFine:h.addElement("Jump").innerText="DaCapoAlFine";break;case U.JumpDalSegno:h.addElement("Jump").innerText="DaSegno";break;case U.JumpDalSegnoAlCoda:h.addElement("Jump").innerText="DaSegnoAlCoda";break;case U.JumpDalSegnoAlDoubleCoda:h.addElement("Jump").innerText="DaSegnoAlDoubleCoda";break;case U.JumpDalSegnoAlFine:h.addElement("Jump").innerText="DaSegnoAlFine";break;case U.JumpDalSegnoSegno:h.addElement("Jump").innerText="DaSegnoSegno";break;case U.JumpDalSegnoSegnoAlCoda:h.addElement("Jump").innerText="DaSegnoSegnoAlCoda";break;case U.JumpDalSegnoSegnoAlDoubleCoda:h.addElement("Jump").innerText="DaSegnoSegnoAlDoubleCoda";break;case U.JumpDalSegnoSegnoAlFine:h.addElement("Jump").innerText="DaSegnoSegnoAlFine";break;case U.JumpDaCoda:h.addElement("Jump").innerText="DaCoda";break;case U.JumpDaDoubleCoda:h.addElement("Jump").innerText="DaDoubleCoda";break}}this._writeFermatas(s,t)}_writeBarXProperties(e,t){const s=e.addElement("XProperties"),i=t.actualBeamingRules;if(i){const r=i.findRule(y.Eighth);let n=r[0],o=1;r[0]===y.Quarter&&(n=8,o=2),this._writeSimpleXPropertyNode(s,"1124139010","Int",n.toString());const l=1124139264;let h=0;for(;h<r[1].length;)this._writeSimpleXPropertyNode(s,(l+h).toString(),"Int",(r[1][h]*o).toString()),h++}}_writeFermatas(e,t){const s=t.fermata?.size??0;if(s!==0&&s>0){const i=e.addElement("Fermatas");for(const[r,n]of t.fermata)this._writeFermata(i,r,n)}}_writeFermata(e,t,s){let i=-1,r=1;if(t>0)for(;r<10&&(i=t/B.QuarterTime*r,i!==Math.floor(i));)i=-1,r++;else i=0,r=1;if(i===-1)return;const n=e.addElement("Fermata");n.addElement("Type").innerText=os[s.type],n.addElement("Length").innerText=s.length.toString(),n.addElement("Offset").innerText=`${i}/${r}`}_writeBarNode(e,t){const s=e.addElement("Bar");s.attributes.set("id",t.id.toString()),s.addElement("Voices").innerText=t.voices.map(i=>i.isEmpty?"-1":i.id.toString()).join(" "),s.addElement("Clef").innerText=ve[t.clef],t.clefOttava!==le.Regular&&(s.addElement("Ottavia").innerText=le[t.clefOttava].substr(1)),t.simileMark!==xt.None&&(s.addElement("SimileMark").innerText=xt[t.simileMark])}_writeVoiceNode(e,t){if(t.isEmpty)return;const s=e.addElement("Voice");s.attributes.set("id",t.id.toString()),s.addElement("Beats").innerText=t.beats.map(i=>i.id).join(" ")}}class Ji{static _crc32Lookup=Ji._buildCrc32Lookup();static _buildCrc32Lookup(){const t=new Uint32Array(256);for(let s=0;s<t.length;s++){let i=s;for(let r=0;r<8;r++)i=(i&1)===1?i>>>1^3988292384:i>>>1;t[s]=i}return t}static _crcInit=4294967295;_checkValue=Ji._crcInit;get value(){return~this._checkValue}constructor(){this.reset()}update(e,t,s){for(let i=0;i<s;i++)this._checkValue=Ji._crc32Lookup[(this._checkValue^e[t+i])&255]^this._checkValue>>>8}reset(){this._checkValue=Ji._crcInit}}class _e{static maxWbits=15;static wsize=1<<_e.maxWbits;static wmask=_e.wsize-1;static minMatch=3;static maxMatch=258;static defaultMemLevel=8;static pendingBufSize=1<<_e.defaultMemLevel+8;static hashBits=_e.defaultMemLevel+7;static hashSize=1<<_e.hashBits;static hashShift=(_e.hashBits+_e.minMatch-1)/_e.minMatch;static hashMask=_e.hashSize-1;static minLookahead=_e.maxMatch+_e.minMatch+1;static maxDist=_e.wsize-_e.minLookahead}class ai{static _repeat3To6=16;static _repeat3To10=17;static _repeat11To138=18;freqs;length=null;minNumCodes;numCodes=0;_codes=null;_bitLengthCounts;_maxLength;_huffman;constructor(e,t,s,i){this._huffman=e,this.minNumCodes=s,this._maxLength=i,this.freqs=new Int16Array(t),this._bitLengthCounts=new Int32Array(i)}reset(){for(let e=0;e<this.freqs.length;e++)this.freqs[e]=0;this._codes=null,this.length=null}buildTree(){const e=this.freqs.length,t=new Int32Array(e);let s=0,i=0;for(let h=0;h<e;h++){const c=this.freqs[h];if(c!==0){let d=s++;for(;d>0;){const f=Math.floor((d-1)/2);if(this.freqs[t[f]]>c)t[d]=t[f],d=f;else break}t[d]=h,i=h}}for(;s<2;){const h=i<2?++i:0;t[s++]=h}this.numCodes=Math.max(i+1,this.minNumCodes);const r=s,n=new Int32Array(4*s-2),o=new Int32Array(2*s-1);let l=r;
66for(let h=0;h<s;h++){const c=t[h];n[2*h]=c,n[2*h+1]=-1,o[h]=this.freqs[c]<<8,t[h]=h}do{const h=t[0];let c=t[--s],d=0,f=1;for(;f<s;)f+1<s&&o[t[f]]>o[t[f+1]]&&f++,t[d]=t[f],d=f,f=f*2+1;let p=o[c];for(;f=d,d>0;)if(d=Math.floor((f-1)/2),o[t[d]]>p)t[f]=t[d];else break;t[f]=c;const g=t[0];c=l++,n[2*c]=h,n[2*c+1]=g;const m=Math.min(o[h]&255,o[g]&255);for(p=o[h]+o[g]-m+1,o[c]=p,d=0,f=1;f<s;)f+1<s&&o[t[f]]>o[t[f+1]]&&f++,t[d]=t[f],d=f,f=d*2+1;for(;f=d,f>0;)if(d=Math.floor((f-1)/2),o[t[d]]>p)t[f]=t[d];else break;t[f]=c}while(s>1);this._buildLength(n)}_buildLength(e){this.length=new Uint8Array(this.freqs.length);const t=Math.floor(e.length/2),s=Math.floor((t+1)/2);let i=0;for(let l=0;l<this._maxLength;l++)this._bitLengthCounts[l]=0;const r=new Int32Array(t);r[t-1]=0;for(let l=t-1;l>=0;l--)if(e[2*l+1]!==-1){let h=r[l]+1;h>this._maxLength&&(h=this._maxLength,i++),r[e[2*l]]=h,r[e[2*l+1]]=h}else{const h=r[l];this._bitLengthCounts[h-1]++,this.length[e[2*l]]=r[l]}if(i===0)return;let n=this._maxLength-1;do{for(;this._bitLengthCounts[--n]===0;);do this._bitLengthCounts[n]--,this._bitLengthCounts[++n]++,i-=1<<this._maxLength-1-n;while(i>0&&n<this._maxLength-1)}while(i>0);this._bitLengthCounts[this._maxLength-1]+=i,this._bitLengthCounts[this._maxLength-2]-=i;let o=2*s;for(let l=this._maxLength;l!==0;l--){let h=this._bitLengthCounts[l-1];for(;h>0;){const c=2*e[o++];e[c+1]===-1&&(this.length[e[c]]=l,h--)}}}getEncodedLength(){let e=0;for(let t=0;t<this.freqs.length;t++)e+=this.freqs[t]*this.length[t];return e}calcBLFreq(e){let t,s,i,r=-1,n=0;for(;n<this.numCodes;){i=1;const o=this.length[n];for(o===0?(t=138,s=3):(t=6,s=3,r!==o&&(e.freqs[o]++,i=0)),r=o,n++;n<this.numCodes&&r===this.length[n]&&(n++,!(++i>=t)););i<s?e.freqs[r]+=i:r!==0?e.freqs[ai._repeat3To6]++:i<=10?e.freqs[ai._repeat3To10]++:e.freqs[ai._repeat11To138]++}}setStaticCodes(e,t){this._codes=e,this.length=t}buildCodes(){const e=new Int32Array(this._maxLength);let t=0;this._codes=new Int16Array(this.freqs.length);for(let s=0;s<this._maxLength;s++)e[s]=t,t+=this._bitLengthCounts[s]<<15-s;for(let s=0;s<this.numCodes;s++){const i=this.length[s];i>0&&(this._codes[s]=Ee.bitReverse(e[i-1]),e[i-1]+=1<<16-i)}}writeTree(e){let t,s,i,r=-1,n=0;for(;n<this.numCodes;){i=1;const o=this.length[n];for(o===0?(t=138,s=3):(t=6,s=3,r!==o&&(e.writeSymbol(o),i=0)),r=o,n++;n<this.numCodes&&r===this.length[n]&&(n++,!(++i>=t)););if(i<s)for(;i-- >0;)e.writeSymbol(r);else r!==0?(e.writeSymbol(ai._repeat3To6),this._huffman.pending.writeBits(i-3,2)):i<=10?(e.writeSymbol(ai._repeat3To10),this._huffman.pending.writeBits(i-3,3)):(e.writeSymbol(ai._repeat11To138),this._huffman.pending.writeBits(i-11,7))}}writeSymbol(e){this._huffman.pending.writeBits(this._codes[e]&65535,this.length[e])}}class Ee{static _bufSize=1<<_e.defaultMemLevel+6;static _literalNum=286;static storedBlock=0;static staticTrees=1;static dynTrees=2;static _distNum=30;static _staticLCodes=new Int16Array(Ee._literalNum);static _staticLLength=new Uint8Array(Ee._literalNum);static _staticDCodes=new Int16Array(Ee._distNum);static _staticDLength=new Uint8Array(Ee._distNum);static staticInit(){let e=0;for(;e<144;)Ee._staticLCodes[e]=Ee.bitReverse(48+e<<8),Ee._staticLLength[e++]=8;for(;e<256;)Ee._staticLCodes[e]=Ee.bitReverse(256+e<<7),Ee._staticLLength[e++]=9;for(;e<280;)Ee._staticLCodes[e]=Ee.bitReverse(-256+e<<9),Ee._staticLLength[e++]=7;for(;e<Ee._literalNum;)Ee._staticLCodes[e]=Ee.bitReverse(-88+e<<8),Ee._staticLLength[e++]=8;for(e=0;e<Ee._distNum;e++)Ee._staticDCodes[e]=Ee.bitReverse(e<<11),Ee._staticDLength[e]=5}static _blOrder=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];static _bit4Reverse=new Uint8Array([0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15]);static bitReverse(e){return Ee._bit4Reverse[e&15]<<12|Ee._bit4Reverse[e>>4&15]<<8|Ee._bit4Reverse[e>>8&15]<<4|Ee._bit4Reverse[e>>12]}static _bitLenNum=19;static _eofSymbol=256;pending;_literalTree;_distTree;_blTree;_dBuf;_lBuf;_lastLit=0;_extraBits=0;constructor(e){this.pending=e,this._literalTree=new ai(this,Ee._literalNum,257,15),this._distTree=new ai(this,Ee._distNum,1,15),this._blTree=new ai(this,Ee._bitLenNum,4,7),this._dBuf=new Int16Array(Ee._bufSize),this._lBuf=new 
vendor: 7,083 bytes, line 66
66Uint8Array(Ee._bufSize)}isFull(){return this._lastLit>=Ee._bufSize}reset(){this._lastLit=0,this._extraBits=0,this._literalTree.reset(),this._distTree.reset(),this._blTree.reset()}flushStoredBlock(e,t,s,i){this.pending.writeBits((Ee.storedBlock<<1)+(i?1:0),3),this.pending.alignToByte(),this.pending.writeShort(s),this.pending.writeShort(~s),this.pending.writeBlock(e,t,s),this.reset()}flushBlock(e,t,s,i){this._literalTree.freqs[Ee._eofSymbol]++,this._literalTree.buildTree(),this._distTree.buildTree(),this._literalTree.calcBLFreq(this._blTree),this._distTree.calcBLFreq(this._blTree),this._blTree.buildTree();let r=4;for(let l=18;l>r;l--)this._blTree.length[Ee._blOrder[l]]>0&&(r=l+1);let n=14+r*3+this._blTree.getEncodedLength()+this._literalTree.getEncodedLength()+this._distTree.getEncodedLength()+this._extraBits,o=this._extraBits;for(let l=0;l<Ee._literalNum;l++)o+=this._literalTree.freqs[l]*Ee._staticLLength[l];for(let l=0;l<Ee._distNum;l++)o+=this._distTree.freqs[l]*Ee._staticDLength[l];n>=o&&(n=o),t>=0&&s+4<n>>3?this.flushStoredBlock(e,t,s,i):n===o?(this.pending.writeBits((Ee.staticTrees<<1)+(i?1:0),3),this._literalTree.setStaticCodes(Ee._staticLCodes,Ee._staticLLength),this._distTree.setStaticCodes(Ee._staticDCodes,Ee._staticDLength),this.compressBlock(),this.reset()):(this.pending.writeBits((Ee.dynTrees<<1)+(i?1:0),3),this.sendAllTrees(r),this.compressBlock(),this.reset())}sendAllTrees(e){this._blTree.buildCodes(),this._literalTree.buildCodes(),this._distTree.buildCodes(),this.pending.writeBits(this._literalTree.numCodes-257,5),this.pending.writeBits(this._distTree.numCodes-1,5),this.pending.writeBits(e-4,4);for(let t=0;t<e;t++)this.pending.writeBits(this._blTree.length[Ee._blOrder[t]],3);this._literalTree.writeTree(this._blTree),this._distTree.writeTree(this._blTree)}compressBlock(){for(let e=0;e<this._lastLit;e++){const t=this._lBuf[e]&255;let s=this._dBuf[e];if(s--!==0){const i=Ee._lCode(t);this._literalTree.writeSymbol(i);let r=Math.floor((i-261)/4);r>0&&r<=5&&this.pending.writeBits(t&(1<<r)-1,r);const n=Ee._dCode(s);this._distTree.writeSymbol(n),r=Math.floor(n/2)-1,r>0&&this.pending.writeBits(s&(1<<r)-1,r)}else this._literalTree.writeSymbol(t)}this._literalTree.writeSymbol(Ee._eofSymbol)}tallyDist(e,t){this._dBuf[this._lastLit]=e,this._lBuf[this._lastLit++]=t-3;const s=Ee._lCode(t-3);this._literalTree.freqs[s]++,s>=265&&s<285&&(this._extraBits+=Math.floor((s-261)/4));const i=Ee._dCode(e-1);return this._distTree.freqs[i]++,i>=4&&(this._extraBits+=Math.floor(i/2)-1),this.isFull()}tallyLit(e){return this._dBuf[this._lastLit]=0,this._lBuf[this._lastLit++]=e,this._literalTree.freqs[e]++,this.isFull()}static _lCode(e){if(e===255)return 285;let t=257;for(;e>=8;)t+=4,e=e>>1;return t+e}static _dCode(e){let t=0;for(;e>=4;)t+=2,e=e>>1;return t+e}}Ee.staticInit();class Xo{static _tooFar=4096;_blockStart;_maxChain=128;_niceLength=128;_goodLength=8;_insertHashIndex=0;_strstart;_window;_head;_prev;_lookahead=0;_inputBuf=null;_inputOff=0;_inputEnd=0;_prevAvailable=!1;_matchStart=0;_matchLen=0;_pending;_huffman;inputCrc;constructor(e){this._pending=e,this._huffman=new Ee(e),this.inputCrc=new Ji,this._window=new Uint8Array(2*_e.wsize),this._head=new Int16Array(_e.hashSize),this._prev=new Int16Array(_e.wsize),this._blockStart=1,this._strstart=1}reset(){this._huffman.reset(),this.inputCrc.reset(),this._blockStart=1,this._strstart=1,this._lookahead=0,this._prevAvailable=!1,this._matchLen=_e.minMatch-1;for(let e=0;e<_e.hashSize;e++)this._head[e]=0;for(let e=0;e<_e.wsize;e++)this._prev[e]=0}_updateHash(){this._insertHashIndex=this._window[this._strstart]<<_e.hashShift^this._window[this._strstart+1]}needsInput(){return this._inputEnd===this._inputOff}setInput(e,t,s){const i=t+s;this._inputBuf=e,this._inputOff=t,this._inputEnd=i}deflate(e,t){let s;do{this.fillWindow();const i=e&&this._inputOff===this._inputEnd;s=this._deflateSlow(i,t)}while(this._pending.isFlushed&&s);return s}_deflateSlow(e,t){if(this._lookahead<_e.minLookahead&&!e)return!1;for(;this._lookahead>=_e.minLookahead||e;){if(this._lookahead===0)return this._prevAvailable&&this._huffman.tallyLit(this._window[this._strstart-1]&255),this._prevAvailable=!1,this._huffman.flushBlock(this._window,this._blockStart,this._strstart-this._blockStart,t),this._blockStart=this._strstart,!1;this._strstart>=2*_e.wsize-_e.minLookahead&&this._slideWindow();const s=this._matchStart;let i=this._matchLen;if(this._lookahead>=_e.minMatch){const r=this._insertString();r!==0&&this._strstart-r<=_e.maxDist&&this._findLongestMatch(r)&&this._matchLen===_e.minMatch&&this._strstart-this._matchStart>Xo._tooFar&&(this._matchLen=_e.minMatch-1)}if(i>=_e.minMatch&&this._matchLen<=i){this._huffman.tallyDist(this._strstart-1-s,i),i-=2;do this._strstart++,this._lookahead--,this._lookahead>=_e.minMatch&&this._insertString();while(--i>0);this._strstart++,this._lookahead--,this._prevAvailable=!1,this._matchLen=_e.minMatch-1}else this._prevAvailable&&this._huffman.tallyLit(this._window[this._strstart-1]&255),this._prevAvailable=!0,this._strstart++,this._lookahead--;if(this._huffman.isFull()){let r=this._strstart-this._blockStart;this._prevAvailable&&r--;const n=t&&this._lookahead===0&&!this._prevAvailable;return this._huffman.flushBlock(this._window,this._blockStart,r,n),this._blockStart+=r,!n}}return!0}_findLongestMatch(e){let t,s=this._strstart;const i=s+Math.min(_e.maxMatch,this._lookahead)-1,r=Math.max(s-_e.maxDist,0),n=this._window,o=this._prev;let l=this._maxChain;const h=Math.min(this._niceLength,this._lookahead);if(this._matchLen=Math.max(this._matchLen,_e.minMatch-1),s+this._matchLen>i)return!1;let c=n[s+this._matchLen-1],d=n[s+this._matchLen];this._matchLen>=this._goodLength&&(l>>=2);do if(t=e,s=this._strstart,!(n[t+this._matchLen]!==d||n[t+this._matchLen-1]!==c||n[t]!==n[s]||n[++t]!==n[++s])){switch((i-s)%8){case 1:if(n[++s]===n[++t])break;break;case 2:if(n[++s]===n[++t]&&n[++s]===n[++t])break;break;case 3:if(n[++s]===n[++t]&&n[++s]===n[++t]&&n[++s]===n[++t])break;break;case 4:if(n[++s]===n[++t]&&n[++s]===n[++t]&&n[++s]===n[++t]&&n[++s]===n[++t])break;break;case 5:if(n[++s]===n[++t]&&n[++s]===n[++t]&&n[++s]===n[++t]&&n[++s]===n[++t]&&n[++s]===n[++t])break;break;case 6:if(n[++s]===n[++t]&&n[++s]===n[++t]&&n[++s]===n[++t]&&n[++s]===n[++t]&&n[++s]===n[++t]&&n[++s]===n[++t])break;break;case 7:if(n[++s]===n[++t]&&n[++s]===n[++t]&&n[++s]===n[++t]&&n[++s]===n[++t]&&n[++s]===n[++t]&&n[++s]===n[++t]&&n[++s]===n[++t])break;break}if(n[s]===n[t])do if(s===i){++s,++t;break}while(n[++s]===n[++t]&&n[++s]===n[++t]&&n[++s]===n[++t]&&n[++s]===n[++t]&&n[++s]===n[++t]&&n[++s]===n[++t]&&n[++s]===n[++t]&&n[++s]===n[++t]);if(s-this._strstart>this._matchLen){if(this._matchStart=e,this._matchLen=s-this._strstart,this._matchLen>=h)break;c=n[s-1],d=n[s]}e=o[e&_e.wmask]&65535}while(e>r&&--l!==0);return this._matchLen>=_e.minMatch}_insertString(){const e=(this._insertHashIndex<<_e.hashShift^this._window[this._strstart+(_e.minMatch-1)])&_e.hashMask,t=this._head[e];return this._prev[this._strstart&_e.wmask]=t,this._head[e]=this._strstart,this._insertHashIndex=e,t&65535}
66fillWindow(){if(this._strstart>=_e.wsize+_e.maxDist&&this._slideWindow(),this._lookahead<_e.minLookahead&&this._inputOff<this._inputEnd){let e=2*_e.wsize-this._lookahead-this._strstart;e>this._inputEnd-this._inputOff&&(e=this._inputEnd-this._inputOff),this._window.set(this._inputBuf.subarray(this._inputOff,this._inputOff+e),this._strstart+this._lookahead),this.inputCrc.update(this._inputBuf,this._inputOff,e),this._inputOff+=e,this._lookahead+=e}this._lookahead>=_e.minMatch&&this._updateHash()}_slideWindow(){this._window.set(this._window.subarray(_e.wsize,_e.wsize+_e.wsize),0),this._matchStart-=_e.wsize,this._strstart-=_e.wsize,this._blockStart-=_e.wsize;for(let e=0;e<_e.hashSize;++e){const t=this._head[e]&65535;this._head[e]=t>=_e.wsize?t-_e.wsize:0}for(let e=0;e<_e.wsize;e++){const t=this._prev[e]&65535;this._prev[e]=t>=_e.wsize?t-_e.wsize:0}}}class Ju{_buffer;_start=0;_end=0;_bits=0;bitCount=0;get isFlushed(){return this._end===0}constructor(e){this._buffer=new Uint8Array(e)}reset(){this._start=0,this._end=0,this.bitCount=0}writeShortMSB(e){this._buffer[this._end++]=e>>8&255,this._buffer[this._end++]=e&255}writeShort(e){this._buffer[this._end++]=e,this._buffer[this._end++]=e>>8}writeBlock(e,t,s){this._buffer.set(e.subarray(t,t+s),this._end),this._end+=s}flush(e,t,s){return this.bitCount>=8&&(this._buffer[this._end++]=this._bits&255,this._bits>>=8,this.bitCount-=8),s>this._end-this._start?(s=this._end-this._start,e.set(this._buffer.subarray(this._start,this._start+s),t),this._start=0,this._end=0):(e.set(this._buffer.subarray(this._start,this._start+s),t),this._start+=s),s}writeBits(e,t){this._bits|=e<<this.bitCount,this.bitCount+=t,this.bitCount>=16&&(this._buffer[this._end++]=this._bits&255,this._buffer[this._end++]=this._bits>>8&255,this._bits>>=16,this.bitCount-=16)}alignToByte(){this.bitCount>0&&(this._buffer[this._end++]=this._bits&255,this.bitCount>8&&(this._buffer[this._end++]=this._bits>>8&255)),this._bits=0,this.bitCount=0}}class ws{static _isFlushing=4;static isFinishing=8;static _busyState=16;static _flushingState=20;static _finishingState=28;static _finishedState=30;_state=0;_pending;_engine;get inputCrc(){return this._engine.inputCrc.value}constructor(){this._pending=new Ju(_e.pendingBufSize),this._engine=new Xo(this._pending),this.reset()}get isNeedingInput(){return this._engine.needsInput()}get isFinished(){return this._state===ws._finishedState&&this._pending.isFlushed}reset(){this._state=ws._busyState,this._pending.reset(),this._engine.reset()}setInput(e,t,s){this._engine.setInput(e,t,s)}deflate(e,t,s){const i=s;for(;;){const r=this._pending.flush(e,t,s);if(t+=r,s-=r,s===0||this._state===ws._finishedState)break;if(!this._engine.deflate((this._state&ws._isFlushing)!==0,(this._state&ws.isFinishing)!==0))switch(this._state){case ws._busyState:return i-s;case ws._flushingState:let n=8+(-this._pending.bitCount&7);for(;n>0;)this._pending.writeBits(2,10),n-=10;this._state=ws._busyState;break;
vendor: 4,345 bytes, line 66
66case ws._finishingState:this._pending.alignToByte(),this._state=ws._finishedState;break}}return i-s}finish(){this._state|=ws._isFlushing|ws.isFinishing}}class qu{entry;localHeaderOffset;compressedSize;crc32;compressionMode;constructor(e,t,s,i,r){this.entry=e,this.crc32=t,this.localHeaderOffset=s,this.compressionMode=i,this.compressedSize=r}}class Qu{_data;_centralDirectoryHeaders=[];_deflater=new ws;constructor(e){this._data=e}writeEntry(e){const t=cs.CompressionMethodDeflate,s=gt.empty(),i=this._compress(s,e.data,t),r=s.toArray(),n=new qu(e,i,this._data.bytesWritten,t,s.length);this._centralDirectoryHeaders.push(n),k.writeInt32LE(this._data,cs.LocalFileHeaderSignature),k.writeUInt16LE(this._data,10),k.writeUInt16LE(this._data,2048),k.writeUInt16LE(this._data,t),k.writeInt16LE(this._data,0),k.writeInt16LE(this._data,0),k.writeInt32LE(this._data,i),k.writeInt32LE(this._data,r.length),k.writeInt32LE(this._data,e.data.length),k.writeInt16LE(this._data,e.fullName.length),k.writeInt16LE(this._data,0);const o=k.stringToBytes(e.fullName);this._data.write(o,0,o.length),this._data.write(r,0,r.length)}_compress(e,t,s){if(s!==cs.CompressionMethodDeflate){const r=new Ji;return r.update(t,0,t.length),e.write(t,0,t.length),r.value}const i=new Uint8Array(512);for(this._deflater.reset(),this._deflater.setInput(t,0,t.length);!this._deflater.isNeedingInput;){const r=this._deflater.deflate(i,0,i.length);if(r<=0)break;e.write(i,0,r)}for(this._deflater.finish();!this._deflater.isFinished;){const r=this._deflater.deflate(i,0,i.length);if(r<=0)break;e.write(i,0,r)}return this._deflater.inputCrc}end(){const e=this._data.bytesWritten;for(const s of this._centralDirectoryHeaders)this._writeCentralDirectoryHeader(s);const t=this._data.bytesWritten;this._writeEndOfCentralDirectoryRecord(e,t)}_writeEndOfCentralDirectoryRecord(e,t){k.writeInt32LE(this._data,cs.EndOfCentralDirSignature),k.writeInt16LE(this._data,0),k.writeInt16LE(this._data,0),k.writeInt16LE(this._data,this._centralDirectoryHeaders.length),k.writeInt16LE(this._data,this._centralDirectoryHeaders.length),k.writeInt32LE(this._data,t-e),k.writeInt32LE(this._data,e),k.writeInt16LE(this._data,0)}_writeCentralDirectoryHeader(e){k.writeInt32LE(this._data,cs.CentralFileHeaderSignature),k.writeUInt16LE(this._data,10),k.writeUInt16LE(this._data,10),k.writeUInt16LE(this._data,2048),k.writeUInt16LE(this._data,e.compressionMode),k.writeInt16LE(this._data,0),k.writeInt16LE(this._data,0),k.writeInt32LE(this._data,e.crc32),k.writeInt32LE(this._data,e.compressedSize),k.writeInt32LE(this._data,e.entry.data.length),k.writeInt16LE(this._data,e.entry.fullName.length),k.writeInt16LE(this._data,0),k.writeInt16LE(this._data,0),k.writeInt16LE(this._data,0),k.writeInt16LE(this._data,0),k.writeInt32LE(this._data,0),k.writeInt32LE(this._data,e.localHeaderOffset);const t=k.stringToBytes(e.entry.fullName);this._data.write(t,0,t.length)}}class Ku extends Yo{get name(){return"Guitar Pro 7-8"}writeScore(e){E.debug(this.name,"Writing data entries");const t=new Qr,s=t.writeXml(e),i=ys.writeForScore(e),r=ro.writeForScore(e),n=ao.writeForScore(e);E.debug(this.name,"Writing ZIP entries");const o=new Qu(this.data);o.writeEntry(new cs("VERSION",k.stringToBytes("7.0"))),o.writeEntry(new cs("Content/",new Uint8Array(0))),o.writeEntry(new cs("Content/BinaryStylesheet",i)),o.writeEntry(new cs("Content/PartConfiguration",r)),o.writeEntry(new cs("Content/LayoutConfiguration",n)),o.writeEntry(new cs("Content/score.gpif",k.stringToBytes(s))),t.backingTrackAssetFileName&&o.writeEntry(new cs(t.backingTrackAssetFileName,e.backingTrack.rawAudioFile)),o.end()}}const nf=Object.freeze(Object.defineProperty({__proto__:null,AlphaTexExporter:$u,Gp7Exporter:Ku,ScoreExporter:Yo},Symbol.toStringTag,{value:"Module"}));class Cn extends ei{constructor(){super(0,0,Ie.EndOfTrack)}writeTo(e){throw new Ye(Ge.General,"Deprecated event, serialization not supported")}}var fn;(function(a){a[a.SequenceNumber=0]="SequenceNumber",a[a.TextEvent=1]="TextEvent",a[a.CopyrightNotice=2]="CopyrightNotice",a[a.SequenceOrTrackName=3]="SequenceOrTrackName",a[a.InstrumentName=4]="InstrumentName",a[a.LyricText=5]="LyricText",a[a.MarkerText=6]="MarkerText",a[a.CuePoint=7]="CuePoint",a[a.PatchName=8]="PatchName",a[a.PortName=9]="PortName",a[a.MidiChannel=32]="MidiChannel",a[a.MidiPort=33]="MidiPort",a[a.EndOfTrack=47
66]="EndOfTrack",a[a.Tempo=81]="Tempo",a[a.SmpteOffset=84]="SmpteOffset",a[a.TimeSignature=88]="TimeSignature",a[a.KeySignature=89]="KeySignature",a[a.SequencerSpecific=127]="SequencerSpecific"})(fn||(fn={}));class $o extends Cn{get metaStatus(){return fn.EndOfTrack}}class Zu extends $o{data=new Uint8Array}class ju extends $o{value=0}class ef extends Cn{noteKey=0;pitch=0}var qn;(function(a){a[a.SystemExclusive=240]="SystemExclusive",a[a.MtcQuarterFrame=241]="MtcQuarterFrame",a[a.SongPosition=242]="SongPosition",a[a.SongSelect=243]="SongSelect",a[a.TuneRequest=246]="TuneRequest",a[a.SystemExclusive2=247]="SystemExclusive2"})(qn||(qn={}));class _h extends Cn{}var Qn;(function(a){a[a.MetronomeTick=0]="MetronomeTick",a[a.Rest=1]="Rest"})(Qn||(Qn={}));class tf extends _h{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}}const of=Object.freeze(Object.defineProperty({__proto__:null,AlphaSynthMidiFileHandler:Rs,AlphaTabMetronomeEvent:co,AlphaTabRestEvent:uo,AlphaTabSysExEvent:er,get AlphaTabSystemExclusiveEvents(){return Qn},BeatTickLookup:Ps,BeatTickLookupItem:th,ControlChangeEvent:mo,get ControllerType(){return et},DeprecatedMidiEvent:Cn,EndOfTrackEvent:ko,MasterBarTickLookup:Fo,MasterBarTickLookupTempoChange:Dr,MetaDataEvent:Zu,MetaEvent:$o,get MetaEventType(){return fn},MetaNumberEvent:ju,Midi20PerNotePitchBendEvent:ef,MidiEvent:ei,get MidiEventType(){return Ie},MidiFile:oi,get MidiFileFormat(){return ji},MidiFileGenerator:Ne,MidiTickLookup:ih,MidiTickLookupFindBeatResult:sh,get MidiTickLookupFindBeatResultCursorMode(){return Bs},MidiTrack:lo,NoteBendEvent:So,NoteEvent:fo,NoteOffEvent:go,NoteOnEvent:po,PitchBendEvent:_o,ProgramChangeEvent:yo,SystemCommonEvent:_h,get SystemCommonType(){return qn},SystemExclusiveEvent:tf,TempoChangeEvent:bo,TimeSignatureEvent:ho},Symbol.toStringTag,{value:"Module"})),lf=Object.freeze(Object.defineProperty({__proto__:null,get AccentuationType(){return ct},get AccidentalType(){return ee},Automation:tt,get AutomationType(){return Re},BackingTrack:io,Bar:ns,get BarLineStyle(){return ye},get BarNumberDisplay(){return vt},BarStyle:Vl,get BarSubElement(){return Le},get BarreShape(){return xs},BeamingRules:nt,Beat:Dt,get BeatBeamingMode(){return st},BeatStyle:zl,get BeatSubElement(){return rt},BendPoint:G,get BendStyle(){return Ke},get BendType(){return $},get BracketExtendMode(){return Fi},get BrushType(){return z},Chord:Bi,get Clef(){return ve},Color:Fe,get CrescendoType(){return Gt},get Direction(){return U},get Duration(){return y},get DynamicValue(){return se},ElementStyle:tr,get FadeType(){return yt},Fermata:Br,get FermataType(){return os},get Fingers(){return ie},Font:ze,get FontStyle(){return je},get FontWeight(){return rs},get GolpeType(){return Xt},GraceGroup:ba,get GraceType(){return K},get HarmonicType(){return te},HeaderFooterStyle:hs,InstrumentArticulation:X,JsonConverter:wt,get KeySignature(){return qe},get KeySignatureType(){return as},Lyrics:es,MasterBar:Qs,get MusicFontSymbol(){return u},Note:kt,get NoteAccidentalMode(){return oe},get NoteOrnament(){return ot},NoteStyle:Kn,get NoteSubElement(){return $t},get Ottavia(){return le},get PickStroke(){return Ct},PlaybackInformation:jn,get Rasgueado(){return ne},RenderStylesheet:Hl,RepeatGroup:Rn,Score:Ks,ScoreStyle:Mi,get ScoreSubElement(){return H},Section:Tr,get SimileMark(){return xt},get SlideInType(){return St},get SlideOutType(){return he},Staff:Oi,SustainPedalMarker:_i,get SustainPedalMarkerType(){return it},SyncPointData:ra,get TechniqueSymbolPlacement(){return $e},Track:Zs,get TrackNameMode(){return Qt},get TrackNameOrientation(){return Kt},get TrackNamePolicy(){return mt},TrackStyle:$l,get TrackSubElement(){return $s},TremoloPickingEffect:Ts,get TremoloPickingStyle(){return wi},get TripletFeel(){return Ce},Tuning:I,TupletGroup:Fs,get VibratoType(){return Be},Voice:ks,VoiceStyle:Gl,get VoiceSubElement(){return yr},get WahPedal(){return ss},get WhammyType(){return Pe}},Symbol.toStringTag,{value:"Module"})),hf=Object.freeze(Object.defineProperty({__proto__:null,BarBounds:Co,get BeamDirection(){return P},BeatBounds:Eo,Bounds:bt,BoundsLookup:ls,MasterBarBounds:vo,NoteBounds:xr,RenderFinis
66hedEventArgs:Si,ScoreRenderer:ur,StaffSystemBounds:Do},Symbol.toStringTag,{value:"Module"})),cf=Object.freeze(Object.defineProperty({__proto__:null,CssFontSvgCanvas:oh,Cursors:nh,FontSizeDefinition:Gn,FontSizes:bs,MeasuredText:aa,SvgCanvas:_n,get TextAlign(){return Y},get TextBaseline(){return He}},Symbol.toStringTag,{value:"Module"})),df=Object.freeze(Object.defineProperty({__proto__:null,ActiveBeatsChangedEventArgs:Un,AlphaSynth:eh,AlphaSynthAudioWorkletOutput:Jl,AlphaSynthBase:No,AlphaSynthScriptProcessorOutput:ah,AlphaSynthWebAudioOutputBase:zs,AlphaSynthWebWorkerApi:ma,AudioExportChunk:jl,AudioExportOptions:Zl,BackingTrackSyncPoint:lr,CircularSampleBuffer:oo,MidiEventsPlayedEventArgs:xo,PlaybackRange:tn,PlaybackRangeChangedEventArgs:br,get PlayerState(){return Rt},PlayerStateChangedEventArgs:Yi,PositionChangedEventArgs:Ys},Symbol.toStringTag,{value:"Module"})),uf=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));M.isRunningInWorker?M.initializeWorker():M.isRunningInAudioWorklet?M.initializeAudioWorklet():M.initializeMain(a=>{if(M.webPlatform===us.NodeJs)throw new Ye(Ge.General,"Workers not yet supported in Node.js");if(M.webPlatform===us.BrowserModule||M.isWebPackBundled||M.isViteBundled){E.debug("AlphaTab","Creating webworker");try{return new M.alphaTabWorker(new M.alphaTabUrl(new URL("/assets/alphaTab.worker-ApzHrsCW.js",import.meta.url),import.meta.url),{type:"module"})}catch(t){E.debug("AlphaTab","ESM webworker construction with direct URL failed",t)}let e="";try{e=new M.alphaTabUrl("./alphaTab.worker.mjs",import.meta.url);const t=`import ${JSON.stringify(e)}`,s=new Blob([t],{type:"application/javascript"});return new Worker(URL.createObjectURL(s),{type:"module"})}catch(t){E.debug("AlphaTab","ESM webworker construction with blob import failed",e,t)}try{if(!a.core.scriptFile)throw new Error("Could not detect alphaTab script file");e=a.core.scriptFile;const t=`import ${JSON.stringify(a.core.scriptFile)}`,s=new Blob([t],{type:"application/javascript"});return new Worker(URL.createObjectURL(s),{type:"module"})}catch(t){E.debug("AlphaTab","ESM webworker construction with blob import failed",a.core.scriptFile,t)}}if(!a.core.scriptFile)throw new Ye(Ge.General,"Could not detect alphaTab script file, cannot initialize renderer");try{E.debug("AlphaTab","Creating Blob worker");const e=`importScripts('${a.core.scriptFile}')`,t=new Blob([e],{type:"application/javascript"});return new Worker(URL.createObjectURL(t))}catch{return E.warning("Rendering","Could not create inline worker, fallback to normal worker"),new Worker(a.core.scriptFile)}},(a,e)=>{if(M.webPlatform===us.NodeJs)throw new Ye(Ge.General,"Audio Worklets not yet supported in Node.js");return M.webPlatform===us.BrowserModule||M.isWebPackBundled||M.isViteBundled?(E.debug("AlphaTab","Creating Module worklet"),a.audioWorklet.addModule(new M.alphaTabUrl(new URL("/assets/alphaTab.worklet-BHoTlOwM.js",import.meta.url),import.meta.url))):(E.debug("AlphaTab","Creating Script worklet"),a.audioWorklet.addModule(e.core.scriptFile))});export{Io as AlphaTabApi,Yc as AlphaTabApiBase,Ye as AlphaTabError,Ge as AlphaTabErrorType,or as ConsoleLogger,bh as CoreSettings,_c as DisplaySettings,We as EngravingSettings,ja as EngravingStemInfo,M as Environment,Tc as ExporterSettings,Hi as FileLoadError,Xs as FingeringMode,Is as FontFileFormat,zt as FormatError,Bc as ImporterSettings,ni as LayoutMode,Hs as LogLevel,E as Logger,C as NotationElement,Vt as NotationMode,ya as NotationSettings,ts as PlayerMode,ea as PlayerOutputMode,wc as PlayerSettings,qc as ProgressEventArgs,In as RenderEngineFactory,Ue as RenderingResources,gl as ResizeEventArgs,Us as ScrollMode,di as Settings,kc as SlidePlaybackSettings,yi as StaveProfile,Sr as SystemsLayoutMode,Cs as TabRhythmMode,Sc as VibratoPlaybackSettings,us as WebPlatform,nf as exporter,rf as importer,af as io,uf as json,qi as meta,of as midi,lf as model,cf as platform,hf as rendering,df as synth};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.