System.register(["./node_modules-legacy-bf1d9d7f.js"],(function(e,t){"use strict";var i,s,n,r,o,a,l;return{setters:[e=>{i=e.D,s=e.l,n=e.V,r=e.N,o=e._,a=e.p,l=e.j}],execute:function(){e({a:Lt,b:function(e){return bt.includes(e)},i:Tt});class t{static ajax(e,t=9e3){let i;const s=e.indexOf(".mxl")>-1?"text/plain; charset=x-user-defined":"application/xml";if(XMLHttpRequest)i=new XMLHttpRequest;else{if(!ActiveXObject)return Promise.reject(new Error("XMLHttp not supported."));i=new ActiveXObject("Microsoft.XMLHTTP")}return i.timeout=t,new Promise(((t,n)=>{i.onreadystatechange=()=>{i.readyState===XMLHttpRequest.DONE&&(200===i.status||0===i.status&&i.responseText?t(i.responseText):n(new Error("Could not retrieve requested URL "+i.status)))},i.ontimeout=e=>{n(new Error("Server request Timeout"))},i.overrideMimeType(s),i.open("GET",e,!0),i.send()}))}}const h=class{constructor(e=0,t=1,i=0,s=!0){this.numerator=0,this.denominator=1,this.wholeValue=0,this.numerator=e,this.denominator=t,this.wholeValue=i,s&&this.simplify(),this.setRealValue()}static max(e,t){return e.RealValue>t.RealValue?e:t}static Equal(e,t){return e.wholeValue===t.wholeValue&&e.Denominator===t.Denominator&&e.Numerator===t.Numerator}static createFromFraction(e){return new h(e.numerator,e.denominator,e.wholeValue,!1)}static plus(e,t){const i=e.clone();return i.Add(t),i}static minus(e,t){const i=e.clone();return i.Sub(t),i}static multiply(e,t){return new h((e.wholeValue*e.denominator+e.numerator)*(t.wholeValue*t.denominator+t.numerator),e.denominator*t.denominator)}static greatestCommonDenominator(e,t){if(0===e)return t;if(1===t)return 1;for(;Math.abs(t)>=1&&Math.abs(e)>=1;)e>t?e-=t:t-=e;const i=Math.round(e);return Math.max(i,1)}toString(){let e=this.numerator+"/"+this.denominator;return 0!==this.wholeValue&&(e=this.wholeValue+" "+e),e}clone(){return new h(this.numerator,this.denominator,this.wholeValue,!1)}get Numerator(){return this.numerator}set Numerator(e){this.numerator!==e&&(this.numerator=e,this.simplify(),this.setRealValue())}get Denominator(){return this.denominator}set Denominator(e){this.denominator!==e&&(this.denominator=e,0!==this.numerator&&this.simplify(),this.setRealValue())}get WholeValue(){return this.wholeValue}set WholeValue(e){this.wholeValue!==e&&(this.wholeValue=e,this.setRealValue())}GetExpandedNumerator(){return this.wholeValue*this.denominator+this.numerator}calculateNumberOfNeededDots(){let e=1,t=2;const i=this.GetExpandedNumerator();for(;te;)t.Numerator++;if(this.numerator>this.denominator){const i=new h(this.numerator-1,this.denominator,this.wholeValue);for(;i.Denominator>e;)i.Numerator--;if(i.Denominatorh.maximumAllowedNumber){const e=this.denominator/h.maximumAllowedNumber;this.numerator=Math.round(this.numerator/e),this.denominator=Math.round(this.denominator/e)}if(this.numerator>h.maximumAllowedNumber){const e=this.numerator/h.maximumAllowedNumber;this.numerator=Math.round(this.numerator/e),this.denominator=Math.round(this.denominator/e)}}isOnBeat(e){const t=this.distanceFromBeat(e);return Math.abs(t)(e[e.Above=0]="Above",e[e.Below=1]="Below",e[e.Left=2]="Left",e[e.Right=3]="Right",e[e.NotYetDefined=4]="NotYetDefined",e[e.AboveOrBelow=5]="AboveOrBelow",e))(d||{});const f=class extends c{constructor(e,t,i,s,n,r,o=""){super(t),super.parentMeasure=s,this.NumberXml=r,this.dynamicType=e,this.label=o,this.staffNumber=i,this.activeInstantaneousDynamic=n,this.startVolume=1,this.endVolume=1,this.setStartAndEndVolume(),""!==o&&this.setType()}setStartAndEndVolume(){this.activeInstantaneousDynamic&&(0===this.dynamicType&&(this.startVolume=this.activeInstantaneousDynamic.Volume,this.endVolume=1.2*this.activeInstantaneousDynamic.Volume),1===this.dynamicType&&(this.startVolume=this.activeInstantaneousDynamic.Volume,this.endVolume=.8*this.activeInstantaneousDynamic.Volume))}get DynamicType(){return this.dynamicType}set DynamicType(e){this.dynamicType=e}get StartMultiExpression(){return this.startMultiExpression}set StartMultiExpression(e){this.startMultiExpression=e}get EndMultiExpression(){return this.endMultiExpression}set EndMultiExpression(e){this.endMultiExpression=e}get Placement(){return this.placement}set Placement(e){this.placement=e}get StartVolume(){return this.startVolume}set StartVolume(e){this.startVolume=e}get EndVolume(){return this.endVolume}set EndVolume(e){this.endVolume=e}get StaffNumber(){return this.staffNumber}set StaffNumber(e){this.staffNumber=e}get Label(){return this.label}set Label(e){this.label=e,this.setType()}static isInputStringContinuousDynamic(e){return!!e&&(f.isStringInStringList(f.listContinuousDynamicIncreasing,e)||f.isStringInStringList(f.listContinuousDynamicDecreasing,e))}getInterpolatedDynamic(e){const t=this.StartMultiExpression.AbsoluteTimestamp;let i;if(i=this.EndMultiExpression?this.EndMultiExpression.AbsoluteTimestamp:u.plus(this.startMultiExpression.SourceMeasureParent.AbsoluteTimestamp,this.startMultiExpression.SourceMeasureParent.Duration),e.lt(t))return-1;if(i.lt(e))return-2;const s=u.minus(e,t).RealValue/u.minus(i,t).RealValue;return Math.max(0,Math.min(99.9,this.startVolume+(this.endVolume-this.startVolume)*s))}isWedge(){return!this.label}setType(){f.isStringInStringList(f.listContinuousDynamicIncreasing,this.label)?this.dynamicType=0:f.isStringInStringList(f.listContinuousDynamicDecreasing,this.label)&&(this.dynamicType=1)}};let m=f;m.listContinuousDynamicIncreasing=["crescendo","cresc","cresc.","cres."],m.listContinuousDynamicDecreasing=["decrescendo","decresc","decr.","diminuendo","dim.","dim"];var p=(e=>(e[e.crescendo=0]="crescendo",e[e.diminuendo=1]="diminuendo",e))(p||{}),g=(e=>(e[e.p=0]="p",e[e.f=1]="f",e[e.s=2]="s",e[e.z=3]="z",e[e.m=4]="m",e[e.r=5]="r",e))(g||{});class S{constructor(e,t){this.message=e,t&&(this.message+=" "+t.toString())}}class y{constructor(e){this.message=e}}class b{constructor(e){this.message=e}}const M=class extends c{constructor(e,t,i,s,n){super(i),super.parentMeasure=n,this.dynamicEnum=P[e.toLowerCase()],this.soundDynamic=t,this.staffNumber=s}static staticConstructor(){M.dynamicToRelativeVolumeDict.setValue(13,1),M.dynamicToRelativeVolumeDict.setValue(12,126/127),M.dynamicToRelativeVolumeDict.setValue(11,125/127),M.dynamicToRelativeVolumeDict.setValue(10,124/127),M.dynamicToRelativeVolumeDict.setValue(9,122/127),M.dynamicToRelativeVolumeDict.setValue(8,108/127),M.dynamicToRelativeVolumeDict.setValue(7,76/127),M.dynamicToRelativeVolumeDict.setValue(14,.5),M.dynamicToRelativeVolumeDict.setValue(16,.5),M.dynamicToRelativeVolumeDict.setValue(17,.5),M.dynamicToRelativeVolumeDict.setValue(18,.5),M.dynamicToRelativeVolumeDict.setValue(19,.5),M.dynamicToRelativeVolumeDict.setValue(20,.5),M.dynamicToRelativeVolumeDict.setValue(21,.5),M.dynamicToRelativeVolumeDict.setValue(22,.5),M.dynamicToRelativeVolumeDict.setValue(23,.5),M.dynamicToRelativeVolumeDict.setValue(6,60/127),M.dynamicToRelativeVolumeDict.setValue(5,28/127),M.dynamicToRelativeVolumeDict.setValue(4,12/127),M.dynamicToRelativeVolumeDict.setValue(3,10/127),M.dynamicToRelativeVolumeDict.setValue(2,7/127),M.dynamicToRelativeVolumeDict.setValue(1,5/127),M.dynamicToRelativeVolumeDict.setValue(0,4/127)}get ParentMultiExpression(){return this.multiExpression}set ParentMultiExpression(e){this.multiExpression=e}get DynEnum(){return this.dynamicEnum}set DynEnum(e){this.dynamicEnum=e}get SoundDynamic(){return this.soundDynamic}set SoundDynamic(e){this.soundDynamic=e}get Placement(){return this.placement}set Placement(e){this.placement=e}get StaffNumber(){return this.staffNumber}set StaffNumber(e){this.staffNumber=e}get Length(){return Math.abs(this.length)<1e-4&&(this.length=this.calculateLength()),this.length}get MidiVolume(){return 127*this.Volume}get Volume(){return M.dynamicToRelativeVolumeDict.getValue(this.dynamicEnum)}static isInputStringInstantaneousDynamic(e){return!!e&&M.isStringInStringList(M.listInstantaneousDynamics,e)}getDynamicExpressionSymbol(e){switch(e){case"p":return g.p;case"f":return g.f;case"s":return g.s;case"z":return g.z;case"m":return g.m;case"r":return g.r;default:throw new b("unknown DynamicExpressionSymbolEnum: "+e)}}calculateLength(){return s.debug("[Andrea] instantaneousDynamicExpression: not implemented: calculateLength!"),0}};let v=M;v.dynamicToRelativeVolumeDict=new i,v.listInstantaneousDynamics=["pppppp","ppppp","pppp","ppp","pp","p","ffffff","fffff","ffff","fff","ff","f","mf","mp","sf","sff","sp","spp","fp","rf","rfz","sfz","sffz","fz"];var P=(e=>(e[e.pppppp=0]="pppppp",e[e.ppppp=1]="ppppp",e[e.pppp=2]="pppp",e[e.ppp=3]="ppp",e[e.pp=4]="pp",e[e.p=5]="p",e[e.mp=6]="mp",e[e.mf=7]="mf",e[e.f=8]="f",e[e.ff=9]="ff",e[e.fff=10]="fff",e[e.ffff=11]="ffff",e[e.fffff=12]="fffff",e[e.ffffff=13]="ffffff",e[e.sf=14]="sf",e[e.sff=15]="sff",e[e.sfp=16]="sfp",e[e.sfpp=17]="sfpp",e[e.fp=18]="fp",e[e.rf=19]="rf",e[e.rfz=20]="rfz",e[e.sfz=21]="sfz",e[e.sffz=22]="sffz",e[e.fz=23]="fz",e[e.other=24]="other",e))(P||{});v.staticConstructor();class E{constructor(e,t){e instanceof m?this.continuousDynamicExpression=e:e instanceof v&&(this.instantaneousDynamicExpression=e),this.staffNumber=t}static Compare(e,t){return e.parMultiExpression().AbsoluteTimestamp.CompareTo(t.parMultiExpression().AbsoluteTimestamp)}parMultiExpression(){return this.continuousDynamicExpression?this.continuousDynamicExpression.StartMultiExpression:this.instantaneousDynamicExpression?this.instantaneousDynamicExpression.ParentMultiExpression:void 0}}class L{constructor(e){this.printObject=!0,this.parent=e}get Parent(){return this.parent}set Parent(e){this.parent=e}get PrintObject(){return this.printObject}set PrintObject(e){this.printObject=e}}class x extends L{constructor(e,t){super(void 0),this.rhythm=e,this.numerator=e.Numerator,this.denominator=e.Denominator,this.symbolEnum=t}get Rhythm(){return this.rhythm}set Rhythm(e){this.rhythm=e}get SymbolEnum(){return this.symbolEnum}set SymbolEnum(e){this.symbolEnum=e}clone(){return new x(this.rhythm.clone(),this.symbolEnum)}OperatorEquals(e){const t=this;return t===e||!(!t||!e)&&t.numerator===e.numerator&&t.denominator===e.denominator}OperatorNotEqual(e){return!(this===e)}ToString(){return"Rhythm: "+this.rhythm.toString()}}var T=(e=>(e[e.NONE=0]="NONE",e[e.COMMON=1]="COMMON",e[e.CUT=2]="CUT",e))(T||{});class w{constructor(e,t,i){this.currentMeasureIndex=0,this.currentPartIndex=0,this.currentVoiceEntryIndex=-1,this.currentDynamicEntryIndex=0,this.currentTempoEntryIndex=0,this.currentDynamicChangingExpressions=[],this.repetitionIterationCountDictKeys=[],this.repetitionIterationCountDictValues=[],this.currentRepetition=void 0,this.endReached=!1,this.frontReached=!1,this.currentTimeStamp=new u(0,1),this.currentEnrolledMeasureTimestamp=new u(0,1),this.currentRelativeInMeasureTimestamp=new u(0,1),this.currentVerticalContainerInMeasureTimestamp=new u(0,1),this.jumpResponsibleRepetition=void 0,this.activeDynamicExpressions=[],this.maxRepeatNum=1,this.dcResetDone=!1,this.SkipInvisibleNotes=!0,this.testNoteIdx=0;try{this.frontReached=!0,this.musicSheet=e,this.currentBpm=e.userStartTempoInBPM,this.currentVoiceEntries=void 0,this.frontReached=!1;for(const e of this.musicSheet.Repetitions)this.setRepetitionIterationCount(e,1);for(let t=0;t=this.JumpResponsibleRepetition.StartIndex&&t.EndIndex<=this.JumpResponsibleRepetition.EndIndex&&this.resetRepetitionIterationCount(t)}for(let o=0,a=this.repetitionIterationCountDictKeys.length;o=this.JumpResponsibleRepetition.StartIndex&&a.EndIndex<=this.JumpResponsibleRepetition.EndIndex&&(4!==(null===(e=this.JumpResponsibleRepetition)||void 0===e||null===(t=e.BackwardJumpInstructions)||void 0===t||null===(i=t[0])||void 0===i?void 0:i.type)&&5!==(null===(s=this.JumpResponsibleRepetition)||void 0===s||null===(n=s.BackwardJumpInstructions)||void 0===n||null===(r=n[0])||void 0===r?void 0:r.type)||this.dcResetDone||(this.resetRepetitionIterationCount(a),this.dcResetDone=!0))}}handleRepetitionsAtMeasureEnd(){for(let s=0,n=this.currentMeasure.LastRepetitionInstructions.length;s-1&&this.getRepetitionIterationCount(r)=this.JumpResponsibleRepetition.StartIndex&&r.EndIndex<=this.JumpResponsibleRepetition.EndIndex&&4===(null===(e=this.JumpResponsibleRepetition)||void 0===e||null===(t=e.BackwardJumpInstructions)||void 0===t||null===(i=t[0])||void 0===i?void 0:i.type)&&this.resetRepetitionIterationCount(r),this.repetitionIterationCountDictKeys.contains(r))){const e=r.getForwardJumpTargetForIteration(this.getRepetitionIterationCount(r));if(e>=0)return this.currentMeasureIndex=e,this.currentMeasure=this.musicSheet.SourceMeasures[this.currentMeasureIndex],this.currentVoiceEntryIndex=-1,this.jumpResponsibleRepetition=r,void(this.forwardJumpOccurred=!0);-2===e&&(this.endReached=!0)}}}this.currentMeasureIndex++,void 0!==this.JumpResponsibleRepetition&&this.currentMeasureIndex>this.JumpResponsibleRepetition.EndIndex&&(this.jumpResponsibleRepetition=void 0)}doBackJump(e){this.currentMeasureIndex=e.getBackwardJumpTarget(),this.currentMeasure=this.musicSheet.SourceMeasures[this.currentMeasureIndex],this.currentVoiceEntryIndex=-1,this.incrementRepetitionIterationCount(e),this.jumpResponsibleRepetition=e,this.backJumpOccurred=!0}activateCurrentRhythmInstructions(){if(void 0!==this.currentMeasure&&this.currentMeasure.FirstInstructionsStaffEntries.length>0&&void 0!==this.currentMeasure.FirstInstructionsStaffEntries[0]){const e=this.currentMeasure.FirstInstructionsStaffEntries[0].Instructions;for(let t=0,i=e.length;t0&&(this.currentDynamicEntryIndex>=e.length||e[this.currentDynamicEntryIndex].parMultiExpression().AbsoluteTimestamp.gte(this.CurrentSourceTimestamp));)this.currentDynamicEntryIndex--;for(;this.currentDynamicEntryIndex0&&(this.currentTempoEntryIndex>=t.length||t[this.currentTempoEntryIndex].AbsoluteTimestamp.gte(this.CurrentSourceTimestamp));)this.currentTempoEntryIndex--;for(;this.currentTempoEntryIndex0){this.currentVoiceEntryIndex--;const e=this.currentMeasure.VerticalSourceStaffEntryContainers[this.currentVoiceEntryIndex];this.currentVoiceEntries=this.getVoiceEntries(e),this.currentVerticalContainerInMeasureTimestamp=e.Timestamp,this.currentRelativeInMeasureTimestamp=this.currentVerticalContainerInMeasureTimestamp,this.currentTimeStamp=u.plus(this.currentMeasure.AbsoluteTimestamp,this.currentVerticalContainerInMeasureTimestamp),this.activateCurrentDynamicOrTempoInstructions();const t=this.musicSheet.SelectionEnd;return t&&this.currentTimeStamp.lt(t)&&(this.endReached=!1),void(this.currentMeasureIndex=this.musicSheet.SourceMeasures.indexOf(this.CurrentMeasure))}if(0!==this.currentVoiceEntryIndex||0===this.currentMeasureIndex)this.frontReached=!0,this.currentTimeStamp=new u(-1,1);else{const e=this.musicSheet.SourceMeasures[this.currentMeasureIndex-1];this.currentMeasureIndex--,this.currentMeasure=this.musicSheet.SourceMeasures[this.currentMeasureIndex];const t=e.VerticalSourceStaffEntryContainers[e.VerticalSourceStaffEntryContainers.length-1];this.currentVoiceEntries=this.getVoiceEntries(t),this.currentVerticalContainerInMeasureTimestamp=t.Timestamp,this.currentVoiceEntryIndex=e.VerticalSourceStaffEntryContainers.length-1,this.currentTimeStamp=u.plus(this.currentMeasure.AbsoluteTimestamp,t.Timestamp),this.activateCurrentDynamicOrTempoInstructions();const i=this.musicSheet.SelectionEnd;i&&this.currentTimeStamp.lt(i)&&(this.endReached=!1)}}recursiveMove(){if(this.currentVoiceEntryIndex++,0===this.currentVoiceEntryIndex&&(this.handleRepetitionsAtMeasureBegin(),this.activateCurrentRhythmInstructions()),this.currentVoiceEntryIndex>=0&&this.currentVoiceEntryIndex=0&&this.currentMeasureIndex0){if(!e)return!0;for(let e=0,i=t.length;ei){const e=this.openSheetMusicDisplay.Sheet.SourceMeasures[i];this.openSheetMusicDisplay.Sheet.SelectionEnd=u.plus(e.AbsoluteTimestamp,e.Duration)}this.iterator=this.manager.getIterator(),this.iterator.SkipInvisibleNotes=this.skipInvisibleNotes}getStaffEntryFromVoiceEntry(e){const t=e.ParentSourceStaffEntry.VerticalContainerParent.ParentMeasure.measureListIndex,i=e.ParentSourceStaffEntry.ParentStaff.idInMusicSheet;return this.graphic.findGraphicalStaffEntryFromMeasureList(i,t,e.ParentSourceStaffEntry)}updateWithTimestamp(e){const t=this.manager.absoluteEnrolledToSheetTimestamp(e),i=this.graphic.calculateXPositionFromTimestamp(t),s=i[0],n=i[1];this.updateCurrentPageFromSystem(n);const r=i[2];if(!r)return;const o=Math.max(r.parentMeasure.MeasureNumber,1);let a;for(const c of this.graphic.MeasureList[o-1])if(c){a=c;break}const l=this.graphic.calculateCursorPoints(s,n),h=l[0].y,u=l[1].y-h;if(a){if(this.updateWidthAndStyle(a.PositionAndShape,s,h,u),this.openSheetMusicDisplay.FollowCursor){const e=this.cursorElement.getBoundingClientRect().top;this.cursorElement.scrollIntoView({behavior:e<1e3?"smooth":"auto",block:this.ScrollPosition})}this.cursorElement.style.display=""}}update(){var e;if(this.hidden||void 0===this.hidden||null===this.hidden)return;this.updateCurrentPage();const t=this.Iterator;let i,s=t.CurrentVisibleVoiceEntries(),n=t.CurrentMeasureIndex,r=0,o=0,a=0;if(0!==s.length||t.FrontReached||t.EndReached||(t.moveToPrevious(),s=t.CurrentVisibleVoiceEntries(),t.moveToNext()),t.FrontReached&&0===s.length){t.moveToNext(),s=t.CurrentVisibleVoiceEntries();const e=this.findVisibleGraphicalMeasure(t.CurrentMeasureIndex);r=e.PositionAndShape.AbsolutePosition.x,i=e.ParentMusicSystem,t.moveToPrevious()}else if(t.EndReached||!t.CurrentVoiceEntries||0===s.length){t.moveToPrevious(),s=t.CurrentVisibleVoiceEntries(),n=t.CurrentMeasureIndex;const e=this.findVisibleGraphicalMeasure(t.CurrentMeasureIndex);r=e.PositionAndShape.AbsolutePosition.x+e.PositionAndShape.Size.width,i=e.ParentMusicSystem,t.moveToNext()}else if(t.CurrentMeasure.isReducedToMultiRest){const e=this.findVisibleGraphicalMeasure(t.CurrentMeasureIndex),s=e.parentSourceMeasure.multipleRestMeasures,n=t.CurrentMeasure.multipleRestMeasureNumber/(s+1),o=e.PositionAndShape.Size.width-e.beginInstructionsWidth;r=e.PositionAndShape.AbsolutePosition.x+e.beginInstructionsWidth+n*o,i=e.ParentMusicSystem}else{const e=s.map((e=>this.getStaffEntryFromVoiceEntry(e)));let t=e.sort(((e,t)=>{var i,s,n,r;return(null==e||null===(i=e.PositionAndShape)||void 0===i||null===(s=i.AbsolutePosition)||void 0===s?void 0:s.x)<=(null==t||null===(n=t.PositionAndShape)||void 0===n||null===(r=n.AbsolutePosition)||void 0===r?void 0:r.x)?-1:1}))[0];window.DYFirstTrackName&&(t=e.find((e=>e.sourceStaffEntry.ParentStaff.ParentInstrument.Name===window.DYFirstTrackName))),t&&(r=t.PositionAndShape.AbsolutePosition.x,i=t.parentMeasure.ParentMusicSystem)}if(null===(e=i)||void 0===e||!e.StaffLines[0])return;o=i.PositionAndShape.AbsolutePosition.y+i.StaffLines[0].PositionAndShape.RelativePosition.y;let l=i.PositionAndShape.AbsolutePosition.y;const h=i.StaffLines[i.StaffLines.length-1];h&&(l+=h.PositionAndShape.RelativePosition.y+h.StaffHeight),a=l-o;const u=this.findVisibleGraphicalMeasure(n);if(!u)return;const c=u.PositionAndShape;if(!this.activeMeasureNum||u.MeasureNumber===this.activeMeasureNum){if(this.updateWidthAndStyle(c,r,o,a),this.openSheetMusicDisplay.FollowCursor&&this.cursorOptions.follow)if(this.openSheetMusicDisplay.EngravingRules.RenderSingleHorizontalStaffline)this.cursorElement.scrollIntoView({behavior:"smooth",inline:"center"});else{const e=this.cursorElement.getBoundingClientRect().top;this.cursorElement.scrollIntoView({behavior:e<1e3?"smooth":"auto",block:"center"})}this.cursorElement.style.display=""}}findVisibleGraphicalMeasure(e){for(let t=0;t{i.push.apply(i,e.Notes)})),i}GNotesUnderCursor(e){const t=this.VoicesUnderCursor(e),i=[];return t.forEach((e=>{i.push(...e.Notes.map((e=>this.rules.GNote(e))))})),i}updateCurrentPage(){let e=this.iterator.currentTimeStamp;e.RealValue<0&&(e=new u(0,0));for(const t of this.graphic.MusicPages)if(t.MusicSystems.last().GetSystemsLastTimeStamp().gt(e)){const e=t.PageNumber;return e!==this.currentPageNumber&&(this.container.removeChild(this.cursorElement),this.container=document.getElementById(this.rules.DYContainerId+e),this.container.appendChild(this.cursorElement)),this.currentPageNumber=e}return 1}get SkipInvisibleNotes(){return this.skipInvisibleNotes}set SkipInvisibleNotes(e){this.skipInvisibleNotes=e,this.iterator.SkipInvisibleNotes=e}get CursorOptions(){return this.cursorOptions}set CursorOptions(e){this.cursorOptions=e}updateCurrentPageFromSystem(e){if(null!=e&&e.Parent){const t=e.Parent.PageNumber;return t!==this.currentPageNumber&&(this.container.removeChild(this.cursorElement),this.container=document.getElementById(this.rules.DYContainerId+t),this.container.appendChild(this.cursorElement)),this.currentPageNumber=t}return 1}Dispose(){this.hide(),this.container.removeChild(this.cursorElement),this.rules=void 0,this.openSheetMusicDisplay=void 0,this.cursorOptions=void 0}}var A=(e=>(e.allon="allon",e.compact="compact",e.compacttight="compacttight",e.default="default",e.leadsheet="leadsheet",e.preview="preview",e.thumbnail="thumbnail",e))(A||{}),R=(e=>(e[e.Standard=0]="Standard",e[e.ThinLeft=1]="ThinLeft",e[e.ShortThinTopLeft=2]="ShortThinTopLeft",e[e.CurrentArea=3]="CurrentArea",e[e.CurrentAreaLeft=4]="CurrentAreaLeft",e))(R||{}),N=(e=>(e[e.Never=0]="Never",e[e.Always=1]="Always",e[e.Auto=2]="Auto",e))(N||{}),C=(e=>(e[e.No=0]="No",e[e.YesVisible=1]="YesVisible",e[e.YesInvisible=2]="YesInvisible",e))(C||{}),B=(e=>(e[e.SVG=0]="SVG",e[e.Canvas=1]="Canvas",e))(B||{}),D=(e=>(e[e.Plain=0]="Plain",e[e.WebGL=1]="WebGL",e))(D||{});class V{static OSMDOptionsStandard(){return{autoResize:!0,backend:"svg",drawingParameters:A.default}}static BackendTypeFromString(e){return e&&"canvas"===e.toLowerCase()?1:0}}class k{constructor(e){if(this.hasAttributes=!1,!e)throw new Error("IXmlElement: expected Element, got undefined");this.elem=e,this.name=e.nodeName.toLowerCase(),e.hasAttributes()&&(this.hasAttributes=!0,this.firstAttribute=e.attributes[0]),this.hasElements=e.hasChildNodes(),1===e.childNodes.length&&e.childNodes[0].nodeType===Node.TEXT_NODE?this.value=e.childNodes[0].nodeValue:this.value=""}attribute(e){return this.elem.attributes.getNamedItem(e)}attributes(){if(!this.attrs){const e=this.elem.attributes,t=[];for(let i=0;i0){let i;for(let s=0,n=t.length;ss?1:0}getFirstNonNullStaffEntry(){for(let e=0,t=this.staffEntries.length;e(e[e.BaseWritingColor=0]="BaseWritingColor",e[e.FollowingCursor=1]="FollowingCursor",e[e.AlternativeFollowingCursor=2]="AlternativeFollowingCursor",e[e.PlaybackCursor=3]="PlaybackCursor",e[e.Highlighted=4]="Highlighted",e[e.ErrorUnderlay=5]="ErrorUnderlay",e[e.Selected=6]="Selected",e[e.SelectionSymbol=7]="SelectionSymbol",e[e.DebugColor1=8]="DebugColor1",e[e.DebugColor2=9]="DebugColor2",e[e.DebugColor3=10]="DebugColor3",e[e.SplitScreenDivision=11]="SplitScreenDivision",e[e.GreyTransparentOverlay=12]="GreyTransparentOverlay",e[e.MarkedArea1=13]="MarkedArea1",e[e.MarkedArea2=14]="MarkedArea2",e[e.MarkedArea3=15]="MarkedArea3",e[e.MarkedArea4=16]="MarkedArea4",e[e.MarkedArea5=17]="MarkedArea5",e[e.MarkedArea6=18]="MarkedArea6",e[e.MarkedArea7=19]="MarkedArea7",e[e.MarkedArea8=20]="MarkedArea8",e[e.MarkedArea9=21]="MarkedArea9",e[e.MarkedArea10=22]="MarkedArea10",e[e.Comment1=23]="Comment1",e[e.Comment2=24]="Comment2",e[e.Comment3=25]="Comment3",e[e.Comment4=26]="Comment4",e[e.Comment5=27]="Comment5",e[e.Comment6=28]="Comment6",e[e.Comment7=29]="Comment7",e[e.Comment8=30]="Comment8",e[e.Comment9=31]="Comment9",e[e.Comment10=32]="Comment10",e))(O||{});const _=new i;_.setValue(0,"Thistle"),_.setValue(1,"Aqua"),_.setValue(2,"Azure"),_.setValue(3,"Bisque"),_.setValue(4,"CadetBlue"),_.setValue(5,"DarkBlue"),_.setValue(6,"DarkGoldenRod"),_.setValue(7,"BlanchedAlmond"),_.setValue(8,"Chartreuse"),_.setValue(9,"DarkGreen"),_.setValue(10,"DarkOrange"),_.setValue(11,"FireBrick"),_.setValue(12,"DarkSalmon"),_.setValue(13,"DarkSeaGreen"),_.setValue(14,"DarkOrchid"),_.setValue(15,"Aquamarine"),_.setValue(16,"DarkKhaki"),_.setValue(17,"ForestGreen"),_.setValue(18,"AliceBlue"),_.setValue(19,"DeepPink"),_.setValue(20,"Coral"),_.setValue(21,"DarkOliveGreen"),_.setValue(22,"Chocolate"),_.setValue(23,"DodgerBlue"),_.setValue(24,"Blue"),_.setValue(25,"Beige"),_.setValue(26,"Crimson"),_.setValue(27,"Fuchsia"),_.setValue(28,"Brown"),_.setValue(29,"BlanchedAlmond"),_.setValue(30,"CornflowerBlue"),_.setValue(31,"Cornsilk"),_.setValue(32,"DarkGrey");var G=(e=>(e[e.Background=0]="Background",e[e.Highlight=1]="Highlight",e[e.MeasureError=2]="MeasureError",e[e.SelectionSymbol=3]="SelectionSymbol",e[e.Cursor=4]="Cursor",e[e.PSI_Debug=5]="PSI_Debug",e[e.Notes=6]="Notes",e[e.Comment=7]="Comment",e[e.Debug_above=8]="Debug_above",e))(G||{}),W=(e=>(e[e.Normal=0]="Normal",e[e.Selected=1]="Selected",e[e.Follow_Confirmed=2]="Follow_Confirmed",e[e.QFeedback_NotFound=3]="QFeedback_NotFound",e[e.QFeedback_OK=4]="QFeedback_OK",e[e.QFeedback_Perfect=5]="QFeedback_Perfect",e[e.Debug1=6]="Debug1",e[e.Debug2=7]="Debug2",e[e.Debug3=8]="Debug3",e))(W||{}),U=(e=>(e.C="#d82c6b",e.D="#F89D15",e.E="#FFE21A",e.F="#4dbd5c",e.G="#009D96",e.A="#43469d",e.B="#76429c",e.Rest="#000000",e))(U||{});class X{constructor(e,t,i=0,s=O.BaseWritingColor,n=void 0){this.start=e,this.end=t,this.width=i,this.styleId=s,this.colorHex=n}get Start(){return this.start}set Start(e){this.start=e}get End(){return this.end}set End(e){this.end=e}get Width(){return this.width}set Width(e){this.width=e}}class z{constructor(e=0,t=0){this.x=0,this.y=0,this.x=e,this.y=t}static get Empty(){return new z}static pointsAreEqual(e,t){return e.x===t.x&&e.y===t.y}ToString(){return"["+this.x+", "+this.y+"]"}}var H=(e=>(e[e.C=0]="C",e[e.D=2]="D",e[e.E=4]="E",e[e.F=5]="F",e[e.G=7]="G",e[e.A=9]="A",e[e.B=11]="B",e))(H||{}),Y=(e=>(e[e.SHARP=0]="SHARP",e[e.FLAT=1]="FLAT",e[e.NONE=2]="NONE",e[e.NATURAL=3]="NATURAL",e[e.DOUBLESHARP=4]="DOUBLESHARP",e[e.DOUBLEFLAT=5]="DOUBLEFLAT",e[e.TRIPLESHARP=6]="TRIPLESHARP",e[e.TRIPLEFLAT=7]="TRIPLEFLAT",e[e.QUARTERTONESHARP=8]="QUARTERTONESHARP",e[e.QUARTERTONEFLAT=9]="QUARTERTONEFLAT",e[e.SLASHFLAT=10]="SLASHFLAT",e[e.THREEQUARTERSSHARP=11]="THREEQUARTERSSHARP",e[e.THREEQUARTERSFLAT=12]="THREEQUARTERSFLAT",e[e.SLASHQUARTERSHARP=13]="SLASHQUARTERSHARP",e[e.SLASHSHARP=14]="SLASHSHARP",e[e.DOUBLESLASHFLAT=15]="DOUBLESLASHFLAT",e[e.SORI=16]="SORI",e[e.KORON=17]="KORON",e))(Y||{});const j=class{constructor(e,t,i,s=void 0,n=!1){this.accidental=2,this.fundamentalNote=e,this.octave=t,this.accidental=i,this.accidentalXml=s,this.halfTone=e+12*(t+j.octXmlDiff)+j.HalfTonesFromAccidental(i),n||(this.frequency=j.calcFrequency(this),this.nextFrequency=j.calcFrequency(this,"next"),this.prevFrequency=j.calcFrequency(this,"prev"))}static getNoteEnumString(e){switch(e){case 0:return"C";case 2:return"D";case 4:return"E";case 5:return"F";case 7:return"G";case 9:return"A";case 11:return"B";default:return""}}static lineShiftFromNoteEnum(e,t){if(0===t)return[e,0];const i=j.pitchEnumValues,s=i.indexOf(e);let n=0,r=(s+t)%i.length;return s+t>i.length-1&&(n=1),r<0&&(r=i.length+r,n=-1),[i[r],n]}static CalculateTransposedHalfTone(e,t){const i=e.fundamentalNote+e.AccidentalHalfTones+t;return j.WrapAroundCheck(i,12)}static WrapAroundCheck(e,t){let i=0;for(;e<0;)e+=t,i--;for(;e>=t;)e-=t,i++;return{overflow:i,halftone:e}}static calcFrequency(e,t){const i="musicScore"===window.DYProjectName?{"-2":[11,3],"-7":[12],"-9":[5],12:[33,34,35,37,38,2],24:[39]}:{"-2":[4,12,23],"-7":[13],"-9":[6],12:[5,116,55]};let s,n=0;if(e instanceof j){const t=e;n=t.octave-1,s=t.fundamentalNote-9+t.AccidentalHalfTones}else"number"==typeof e&&(s=e-57);const r=window.DYSubjectId;let o=0;if("COLEXIU"===window.DYEnvironment&&(i[12]=[120]),window.xmlNeedAdjustVoice)for(const l in i)if(Object.prototype.hasOwnProperty.call(i,l)&&i[l].includes(r)){o=parseFloat(l);break}let a=s+o;return"next"===t&&a++,"prev"===t&&a--,442*Math.pow(2,n)*Math.pow(2,a/12)}static calcFractionalKey(e){return Math.log(e/440)/Math.LN10*j.halftoneFactor+57}static fromFrequency(e){const t=j.calcFractionalKey(e)+.5,i=Math.floor(t/12)-j.octXmlDiff,s=Math.floor(t)%12;let n=s,r=2;return-1===this.pitchEnumValues.indexOf(n)&&(n=s-1,r=0),new j(n,i,r)}static fromHalftone(e){const t=Math.floor(e/12)-j.octXmlDiff,i=e%12;let s=i,n=2;return-1===this.pitchEnumValues.indexOf(s)&&(s=i-1,n=0),new j(s,t,n)}static ceiling(e){let t=e%=12;return-1===this.pitchEnumValues.indexOf(t)&&(t=e+1),t}static floor(e){let t=e%=12;return-1===this.pitchEnumValues.indexOf(t)&&(t=e-1),t}static HalfTonesFromAccidental(e){switch(e){case 2:case 3:return 0;case 0:return 1;case 1:return-1;case 4:return 2;case 5:return-2;case 6:return 3;case 7:return-3;case 8:return.5;case 9:return-.5;case 10:return-.51;case 11:return 1.5;case 12:return-1.5;case 13:return.0013;case 14:return.0014;case 15:return-.0015;case 16:return.0016;case 17:return.0017;default:throw new Error("Unhandled AccidentalEnum value")}}static AccidentalFromHalfTones(e){switch(e){case 0:return 2;case 1:return 0;case-1:return 1;case 2:return 4;case-2:return 5;case 3:return 6;case-3:return 7;case.5:return 8;case-.5:return 9;case 1.5:return 11;case-1.5:return 12;default:return e>0&&e<1?8:e<0&&e>-1?9:8}}static accidentalVexflow(e){let t;switch(e){case 3:t="n";break;case 1:t="b";break;case 0:t="#";break;case 4:t="##";break;case 6:t="###";break;case 5:t="bb";break;case 7:t="bbs";break;case 8:t="+";break;case 9:t="d";break;case 10:t="bs";break;case 11:t="++";break;case 12:t="db";break;case 13:t="+-";break;case 14:t="++-";break;case 15:t="bss";break;case 16:t="o";break;case 17:t="k"}return t}get AccidentalHalfTones(){return j.HalfTonesFromAccidental(this.accidental)}get Octave(){return this.octave}get FundamentalNote(){return this.fundamentalNote}get Accidental(){return this.accidental}get AccidentalXml(){return this.accidentalXml}get Frequency(){return this.frequency}static get OctaveXmlDifference(){return j.octXmlDiff}getHalfTone(){return this.halfTone}getTransposedPitch(e){if(e>12)throw new Error("rewrite this method to handle bigger octave changes or don't use is with bigger octave changes!");return e>0?this.getHigherPitchByTransposeFactor(e):e<0?this.getLowerPitchByTransposeFactor(-e):this}DoEnharmonicChange(){switch(this.accidental){case 1:case 5:this.fundamentalNote=this.getPreviousFundamentalNote(this.fundamentalNote),this.accidental=j.AccidentalFromHalfTones(this.halfTone-(this.fundamentalNote+12*(this.octave+j.octXmlDiff)));break;case 0:case 4:this.fundamentalNote=this.getNextFundamentalNote(this.fundamentalNote),this.accidental=j.AccidentalFromHalfTones(this.halfTone-(this.fundamentalNote+12*(this.octave+j.octXmlDiff)));break;default:return}}ToString(){let e=j.accidentalVexflow(this.accidental);return e||(e=""),"Key: "+j.getNoteEnumString(this.fundamentalNote)+e+", Note: "+this.fundamentalNote+", octave: "+this.octave.toString()}ToStringShort(e=0){let t=j.accidentalVexflow(this.accidental);t||(t="");const i=this.octave+e;return j.getNoteEnumString(this.fundamentalNote)+t+i}get ToStringShortGet(){return this.ToStringShort(0)}OperatorEquals(e){const t=this;return!(!t||!e)&&t.FundamentalNote===e.FundamentalNote&&t.Octave===e.Octave&&t.Accidental===e.Accidental}OperatorNotEqual(e){return!(this===e)}OperatorFundamentalGreaterThan(e){const t=this;return t.Octave===e.Octave?t.FundamentalNote>e.FundamentalNote:t.Octave>e.Octave}OperatorFundamentalLessThan(e){const t=this;return t.Octave===e.Octave?t.FundamentalNotej.pitchEnumValues.length-1?(i=j.pitchEnumValues[t+e-j.pitchEnumValues.length],s++):i=j.pitchEnumValues[t+e],new j(i,s,2)}getLowerPitchByTransposeFactor(e){const t=j.pitchEnumValues.indexOf(this.fundamentalNote);let i,s=this.octave;return t-e<0?(i=j.pitchEnumValues[j.pitchEnumValues.length+t-e],s--):i=j.pitchEnumValues[t-e],new j(i,s,2)}getNextFundamentalNote(e){let t=j.pitchEnumValues.indexOf(e);return t=(t+1)%j.pitchEnumValues.length,j.pitchEnumValues[t]}getPreviousFundamentalNote(e){const t=j.pitchEnumValues.indexOf(e);return t>0?j.pitchEnumValues[t-1]:j.pitchEnumValues[j.pitchEnumValues.length-1]}};let K=j;K.pitchEnumValues=[0,2,4,5,7,9,11],K.halftoneFactor=12/(Math.LN2/Math.LN10),K.octXmlDiff=3;class J extends L{constructor(e=0,t=0,i=2){super(void 0),this.clefType=0,this.line=2,this.octaveOffset=0,this.line=i,this.clefType=e,this.octaveOffset=t,this.calcParameters()}static getDefaultClefFromMidiInstrument(e){switch(e){case 0:case 33:case 34:case 35:case 36:case 37:case 38:case 39:case 43:return new J(1,0,4);default:return new J(0,0,2)}}static getAllPossibleClefs(){const e=[];for(let t=0;t<=2;t++){const i=new J(0,t,2);e.push(i)}for(let t=-2;t<=0;t++){const i=new J(1,t,4);e.push(i)}return e}static isSupportedClef(e){switch(e){case 0:case 1:case 2:case 3:case 4:return!0;default:return!1}}get ClefType(){return this.clefType}set ClefType(e){this.clefType=e}get Line(){return this.line}set Line(e){this.line=e}get OctaveOffset(){return this.octaveOffset}set OctaveOffset(e){this.octaveOffset=e}get ClefPitch(){return this.clefPitch}set ClefPitch(e){this.clefPitch=e}get ReferenceCyPosition(){return this.referenceCyPosition}set ReferenceCyPosition(e){this.referenceCyPosition=e}Equals(e){return this===e||!(!this||!e)&&this.clefPitch===e.clefPitch&&this.Line===e.Line}NotEqual(e){return!this.Equals(e)}ToString(){return"ClefType: "+this.clefType}calcParameters(){switch(this.clefType){case 0:this.clefPitch=new K(H.G,1+this.octaveOffset,Y.NONE),this.referenceCyPosition=5-this.line+2;break;case 1:this.clefPitch=new K(H.F,0+this.octaveOffset,Y.NONE),this.referenceCyPosition=5-this.line+1.5;break;case 2:this.clefPitch=new K(H.C,1+this.octaveOffset,Y.NONE),this.referenceCyPosition=5-this.line;break;case 3:this.clefPitch=new K(H.C,2,Y.NONE),this.referenceCyPosition=2;break;case 4:this.clefPitch=new K(H.G,0,Y.NONE),this.referenceCyPosition=0;break;default:throw new y("clefType")}}}var q=(e=>(e[e.G=0]="G",e[e.F=1]="F",e[e.C=2]="C",e[e.percussion=3]="percussion",e[e.TAB=4]="TAB",e))(q||{}),$=(e=>(e[e.None=-1]="None",e[e.Acoustic_Grand_Piano=0]="Acoustic_Grand_Piano",e[e.Bright_Acoustic_Piano=1]="Bright_Acoustic_Piano",e[e.Electric_Grand_Piano=2]="Electric_Grand_Piano",e[e.Honky_tonk_Piano=3]="Honky_tonk_Piano",e[e.Electric_Piano_1=4]="Electric_Piano_1",e[e.Electric_Piano_2=5]="Electric_Piano_2",e[e.Harpsichord=6]="Harpsichord",e[e.Clavinet=7]="Clavinet",e[e.Celesta=8]="Celesta",e[e.Glockenspiel=9]="Glockenspiel",e[e.Music_Box=10]="Music_Box",e[e.Vibraphone=11]="Vibraphone",e[e.Marimba=12]="Marimba",e[e.Xylophone=13]="Xylophone",e[e.Tubular_Bells=14]="Tubular_Bells",e[e.Dulcimer=15]="Dulcimer",e[e.Drawbar_Organ=16]="Drawbar_Organ",e[e.Percussive_Organ=17]="Percussive_Organ",e[e.Rock_Organ=18]="Rock_Organ",e[e.Church_Organ=19]="Church_Organ",e[e.Reed_Organ=20]="Reed_Organ",e[e.Accordion=21]="Accordion",e[e.Harmonica=22]="Harmonica",e[e.Tango_Accordion=23]="Tango_Accordion",e[e.Acoustic_Guitar_nylon=24]="Acoustic_Guitar_nylon",e[e.Acoustic_Guitar_steel=25]="Acoustic_Guitar_steel",e[e.Electric_Guitar_jazz=26]="Electric_Guitar_jazz",e[e.Electric_Guitar_clean=27]="Electric_Guitar_clean",e[e.Electric_Guitar_muted=28]="Electric_Guitar_muted",e[e.Overdriven_Guitar=29]="Overdriven_Guitar",e[e.Distortion_Guitar=30]="Distortion_Guitar",e[e.Guitar_harmonics=31]="Guitar_harmonics",e[e.Acoustic_Bass=32]="Acoustic_Bass",e[e.Electric_Bass_finger=33]="Electric_Bass_finger",e[e.Electric_Bass_pick=34]="Electric_Bass_pick",e[e.Fretless_Bass=35]="Fretless_Bass",e[e.Slap_Bass_1=36]="Slap_Bass_1",e[e.Slap_Bass_2=37]="Slap_Bass_2",e[e.Synth_Bass_1=38]="Synth_Bass_1",e[e.Synth_Bass_2=39]="Synth_Bass_2",e[e.Violin=40]="Violin",e[e.Viola=41]="Viola",e[e.Cello=42]="Cello",e[e.Contrabass=43]="Contrabass",e[e.Tremolo_Strings=44]="Tremolo_Strings",e[e.Pizzicato_Strings=45]="Pizzicato_Strings",e[e.Orchestral_Harp=46]="Orchestral_Harp",e[e.Timpani=47]="Timpani",e[e.String_Ensemble_1=48]="String_Ensemble_1",e[e.String_Ensemble_2=49]="String_Ensemble_2",e[e.Synth_Strings_1=50]="Synth_Strings_1",e[e.Synth_Strings_2=51]="Synth_Strings_2",e[e.Choir_Aahs=52]="Choir_Aahs",e[e.Voice_Oohs=53]="Voice_Oohs",e[e.Synth_Voice=54]="Synth_Voice",e[e.Orchestra_Hit=55]="Orchestra_Hit",e[e.Trumpet=56]="Trumpet",e[e.Trombone=57]="Trombone",e[e.Tuba=58]="Tuba",e[e.Muted_Trumpet=59]="Muted_Trumpet",e[e.French_Horn=60]="French_Horn",e[e.Brass_Section=61]="Brass_Section",e[e.Synth_Brass_1=62]="Synth_Brass_1",e[e.Synth_Brass_2=63]="Synth_Brass_2",e[e.Soprano_Sax=64]="Soprano_Sax",e[e.Alto_Sax=65]="Alto_Sax",e[e.Tenor_Sax=66]="Tenor_Sax",e[e.Baritone_Sax=67]="Baritone_Sax",e[e.Oboe=68]="Oboe",e[e.English_Horn=69]="English_Horn",e[e.Bassoon=70]="Bassoon",e[e.Clarinet=71]="Clarinet",e[e.Piccolo=72]="Piccolo",e[e.Flute=73]="Flute",e[e.Recorder=74]="Recorder",e[e.Pan_Flute=75]="Pan_Flute",e[e.Blown_Bottle=76]="Blown_Bottle",e[e.Shakuhachi=77]="Shakuhachi",e[e.Whistle=78]="Whistle",e[e.Ocarina=79]="Ocarina",e[e.Lead_1_square=80]="Lead_1_square",e[e.Lead_2_sawtooth=81]="Lead_2_sawtooth",e[e.Lead_3_calliope=82]="Lead_3_calliope",e[e.Lead_4_chiff=83]="Lead_4_chiff",e[e.Lead_5_charang=84]="Lead_5_charang",e[e.Lead_6_voice=85]="Lead_6_voice",e[e.Lead_7_fifths=86]="Lead_7_fifths",e[e.Lead_8_bass_lead=87]="Lead_8_bass_lead",e[e.Pad_1_new_age=88]="Pad_1_new_age",e[e.Pad_2_warm=89]="Pad_2_warm",e[e.Pad_3_polysynth=90]="Pad_3_polysynth",e[e.Pad_4_choir=91]="Pad_4_choir",e[e.Pad_5_bowed=92]="Pad_5_bowed",e[e.Pad_6_metallic=93]="Pad_6_metallic",e[e.Pad_7_halo=94]="Pad_7_halo",e[e.Pad_8_sweep=95]="Pad_8_sweep",e[e.FX_1_rain=96]="FX_1_rain",e[e.FX_2_soundtrack=97]="FX_2_soundtrack",e[e.FX_3_crystal=98]="FX_3_crystal",e[e.FX_4_atmosphere=99]="FX_4_atmosphere",e[e.FX_5_brightness=100]="FX_5_brightness",e[e.FX_6_goblins=101]="FX_6_goblins",e[e.FX_7_echoes=102]="FX_7_echoes",e[e.FX_8_scifi=103]="FX_8_scifi",e[e.Sitar=104]="Sitar",e[e.Banjo=105]="Banjo",e[e.Shamisen=106]="Shamisen",e[e.Koto=107]="Koto",e[e.Kalimba=108]="Kalimba",e[e.Bag_pipe=109]="Bag_pipe",e[e.Fiddle=110]="Fiddle",e[e.Shanai=111]="Shanai",e[e.Tinkle_Bell=112]="Tinkle_Bell",e[e.Agogo=113]="Agogo",e[e.Steel_Drums=114]="Steel_Drums",e[e.Woodblock=115]="Woodblock",e[e.Taiko_Drum=116]="Taiko_Drum",e[e.Melodic_Tom=117]="Melodic_Tom",e[e.Synth_Drum=118]="Synth_Drum",e[e.Reverse_Cymbal=119]="Reverse_Cymbal",e[e.Guitar_Fret_Noise=120]="Guitar_Fret_Noise",e[e.Breath_Noise=121]="Breath_Noise",e[e.Seashore=122]="Seashore",e[e.Bird_Tweet=123]="Bird_Tweet",e[e.Telephone_Ring=124]="Telephone_Ring",e[e.Helicopter=125]="Helicopter",e[e.Applause=126]="Applause",e[e.Gunshot=127]="Gunshot",e[e.Percussion=128]="Percussion",e))($||{});const Q=class extends L{constructor(e=void 0,t=0,i=0){super(e),this.isTransposedBy=0,this.Key=t,this.keyTypeOriginal=t,this.mode=i,this.alteratedNotes=this.calcAlteratedNotes()}static copy(e){const t=new Q(e.parent,e.Key,e.Mode);return t.keyTypeOriginal=e.keyTypeOriginal,t}static getAllPossibleMajorKeyInstructions(){const e=[];for(let t=-7;t<7;t++){const i=new Q(void 0,t,0);e.push(i)}return e}get Key(){return this.keyType}set Key(e){this.keyType=e,this.alteratedNotes=this.calcAlteratedNotes()}get Mode(){return this.mode}set Mode(e){this.mode=e}get AlteratedNotes(){return this.alteratedNotes}calcAlteratedNotes(){const e=[];if(this.keyType>0)for(let t=0;t=0}getAlterationForPitch(e){return this.keyType>0&&this.alteratedNotes.indexOf(e.FundamentalNote)<=this.keyType?Y.SHARP:this.keyType<0&&this.alteratedNotes.indexOf(e.FundamentalNote)<=Math.abs(this.keyType)?Y.FLAT:Y.NONE}ToString(){return"Key: "+this.keyType+this.mode}OperatorEquals(e){const t=this;return t===e||!(!t||!e)&&t.Key===e.Key&&t.Mode===e.Mode}OperatorNotEqual(e){return!this.OperatorEquals(e)}};let Z=Q;Z.sharpPositionList=[H.F,H.C,H.G,H.D,H.A,H.E,H.B],Z.flatPositionList=[H.B,H.E,H.A,H.D,H.G,H.C,H.F];var ee=(e=>(e[e.major=0]="major",e[e.minor=1]="minor",e[e.none=2]="none",e[e.dorian=3]="dorian",e[e.phrygian=4]="phrygian",e[e.lydian=5]="lydian",e[e.mixolydian=6]="mixolydian",e[e.aeolian=7]="aeolian",e[e.ionian=8]="ionian",e[e.locrian=9]="locrian",e))(ee||{});class te{constructor(e=0,t=0){this.width=e,this.height=t}}class ie{constructor(e,t,i,s){this.x=0,this.y=0,this.width=0,this.height=0,this.x=e,this.y=t,this.width=i,this.height=s}static createFromLocationAndSize(e,t){return new ie(e.x,e.y,t.width,t.height)}get Location(){return new z(this.x,this.y)}get Size(){return new te(this.width,this.height)}}class se{isInstanceOfClass(e){let t=this.constructor.prototype;for(;t;){if(e===t.constructor.name)return!0;t=t.__proto__}return!1}}class ne extends se{get PositionAndShape(){return this.boundingBox}set PositionAndShape(e){this.boundingBox=e}}class re extends ne{}class oe{constructor(e=void 0,t=void 0,i=!1){this.isSymbol=!1,this.relativePositionHasBeenSet=!1,this.xBordersHaveBeenSet=!1,this.yBordersHaveBeenSet=!1,this.absolutePosition=new z,this.relativePosition=new z,this.size=new te,this.marginSize=new te,this.upperLeftCorner=new z,this.upperLeftMarginCorner=new z,this.borderLeft=0,this.borderRight=0,this.borderTop=0,this.borderBottom=0,this.borderMarginLeft=0,this.borderMarginRight=0,this.borderMarginTop=0,this.borderMarginBottom=0,this.childElements=[],this.parent=t,this.dataObject=e,this.isSymbol=i,this.xBordersHaveBeenSet=!1,this.yBordersHaveBeenSet=!1,t&&(this.Parent=t)}get RelativePositionHasBeenSet(){return this.relativePositionHasBeenSet}get XBordersHaveBeenSet(){return this.xBordersHaveBeenSet}set XBordersHaveBeenSet(e){this.xBordersHaveBeenSet=e}get YBordersHaveBeenSet(){return this.yBordersHaveBeenSet}set YBordersHaveBeenSet(e){this.yBordersHaveBeenSet=e}get AbsolutePosition(){return this.absolutePosition}set AbsolutePosition(e){this.absolutePosition=e}get RelativePosition(){return this.relativePosition}set RelativePosition(e){this.relativePosition=e,this.relativePositionHasBeenSet=!0}get Size(){return this.size}set Size(e){this.size=e}get MarginSize(){return this.marginSize}get UpperLeftCorner(){return this.upperLeftCorner}get UpperLeftMarginCorner(){return this.upperLeftMarginCorner}get BorderLeft(){return this.borderLeft}set BorderLeft(e){this.borderLeft=e,this.calculateRectangle()}get BorderRight(){return this.borderRight}set BorderRight(e){this.borderRight=e,this.calculateRectangle()}get BorderTop(){return this.borderTop}set BorderTop(e){this.borderTop=e,this.calculateRectangle()}get BorderBottom(){return this.borderBottom}set BorderBottom(e){this.borderBottom=e,this.calculateRectangle()}get BorderMarginLeft(){return this.borderMarginLeft>this.borderLeft?this.borderLeft:this.borderMarginLeft}set BorderMarginLeft(e){this.borderMarginLeft=e,this.calculateMarginRectangle()}get BorderMarginRight(){return this.borderMarginRightthis.borderTop?this.borderTop:this.borderMarginTop}set BorderMarginTop(e){this.borderMarginTop=e,this.calculateMarginRectangle()}get BorderMarginBottom(){return this.borderMarginBottom-1&&this.parent.ChildElements.splice(e,1)}this.parent=e,(null===(t=this.parent)||void 0===t||null===(i=t.ChildElements)||void 0===i?void 0:i.indexOf(this))>-1?s.error("BoundingBox of "+this.dataObject.constructor.name+" already in children list of "+this.parent.dataObject.constructor.name+"'s BoundingBox"):null===(n=this.parent)||void 0===n||null===(r=n.ChildElements)||void 0===r||r.push(this)}get DataObject(){return this.dataObject}get Center(){return new z(this.RelativePosition.x+(this.BorderMarginRight+this.BorderMarginLeft),this.RelativePosition.y+(this.BorderMarginBottom+this.BorderMarginTop))}setAbsolutePositionFromParent(){this.parent?(this.absolutePosition.x=this.parent.AbsolutePosition.x+this.relativePosition.x,this.absolutePosition.y=this.parent.AbsolutePosition.y+this.relativePosition.y):this.absolutePosition=this.relativePosition}calculateAbsolutePosition(){this.absolutePosition.x=this.relativePosition.x,this.absolutePosition.y=this.relativePosition.y;let e=this.parent;for(;e;)this.absolutePosition.x+=e.relativePosition.x,this.absolutePosition.y+=e.relativePosition.y,e=e.parent}calculateAbsolutePositionsRecursiveWithoutTopelement(){this.absolutePosition.x=0,this.absolutePosition.y=0;for(let e=0,t=this.ChildElements.length;e.001;break;case 2:case 3:s=this.relativePosition.y,e.calculateMarginPositionAlongDirection(this,t),n=Math.abs(s-this.relativePosition.y)>.001;break;default:throw new y("direction")}}while(n)}collisionDetection(e){const t=Math.min(this.AbsolutePosition.x+this.borderRight,e.absolutePosition.x+e.borderRight)-Math.max(this.AbsolutePosition.x+this.borderLeft,e.absolutePosition.x+e.borderLeft),i=Math.min(this.AbsolutePosition.y+this.borderBottom,e.absolutePosition.y+e.borderBottom)-Math.max(this.AbsolutePosition.y+this.borderTop,e.absolutePosition.y+e.borderTop);return t>0&&i>0}liesInsideBorders(e){const t=this.AbsolutePosition.x+this.borderLeft<=e.absolutePosition.x+e.borderLeft&&e.absolutePosition.x+e.borderLeft<=this.AbsolutePosition.x+this.borderRight,i=this.AbsolutePosition.x+this.borderLeft<=e.absolutePosition.x+e.borderRight&&e.absolutePosition.x+e.borderRight<=this.AbsolutePosition.x+this.borderRight;if(t&&i){const t=this.AbsolutePosition.y+this.borderTop<=e.absolutePosition.y+e.borderTop&&e.absolutePosition.y+e.borderTop<=this.AbsolutePosition.y+this.borderBottom,i=this.AbsolutePosition.y+this.borderTop<=e.absolutePosition.y+e.borderBottom&&e.absolutePosition.y+e.borderBottom<=this.AbsolutePosition.y+this.borderBottom;if(t&&i)return!0}return!1}pointLiesInsideBorders(e){return this.AbsolutePosition.x+this.borderLeft<=e.x&&e.x<=this.AbsolutePosition.x+this.borderRight&&this.AbsolutePosition.y+this.borderTop<=e.y&&e.y<=this.AbsolutePosition.y+this.borderBottom}marginCollisionDetection(e){const t=Math.min(this.AbsolutePosition.x+this.borderMarginRight,e.absolutePosition.x+e.borderMarginRight)-Math.max(this.AbsolutePosition.x+this.borderMarginLeft,e.absolutePosition.x+e.borderMarginLeft),i=Math.min(this.AbsolutePosition.y+this.borderMarginBottom,e.absolutePosition.y+e.borderMarginBottom)-Math.max(this.AbsolutePosition.y+this.borderMarginTop,e.absolutePosition.y+e.borderMarginTop);return t>0&&i>0}liesInsideMargins(e){const t=this.AbsolutePosition.x+this.borderMarginLeft<=e.absolutePosition.x+e.borderMarginLeft&&e.absolutePosition.x+e.borderMarginLeft<=this.AbsolutePosition.x+this.borderMarginRight,i=this.AbsolutePosition.x+this.borderMarginLeft<=e.absolutePosition.x+e.borderMarginRight&&e.absolutePosition.x+e.borderMarginRight<=this.AbsolutePosition.x+this.borderMarginRight;if(t&&i){const t=this.AbsolutePosition.y+this.borderMarginTop<=e.absolutePosition.y+e.borderMarginTop&&e.absolutePosition.y+e.borderMarginTop<=this.AbsolutePosition.y+this.borderMarginBottom,i=this.AbsolutePosition.y+this.borderMarginTop<=e.absolutePosition.y+e.borderMarginBottom&&e.absolutePosition.y+e.borderMarginBottom<=this.AbsolutePosition.y+this.borderMarginBottom;if(t&&i)return!0}return!1}pointLiesInsideMargins(e){return this.AbsolutePosition.x+this.borderMarginLeft<=e.x&&e.x<=this.AbsolutePosition.x+this.borderMarginRight&&this.AbsolutePosition.y+this.borderMarginTop<=e.y&&e.y<=this.AbsolutePosition.y+this.borderMarginBottom}computeNonOverlappingPosition(e,t,i){this.RelativePosition=new z(i.x,i.y),this.setAbsolutePositionFromParent();let s=0,n=!1;do{switch(t){case 0:case 1:s=this.relativePosition.x,e.calculatePositionAlongDirection(this,t),n=Math.abs(s-this.relativePosition.x)>1e-4;break;case 2:case 3:s=this.relativePosition.y,e.calculatePositionAlongDirection(this,t),n=Math.abs(s-this.relativePosition.y)>1e-4;break;default:throw new y("direction")}}while(n)}getClickedObjectOfType(e){const t=this.dataObject;if(this.pointLiesInsideBorders(e)&&t)return t;for(let i=0,s=this.childElements.length;i(e[e.Left=0]="Left",e[e.Right=1]="Right",e[e.Up=2]="Up",e[e.Down=3]="Down",e[e.NotYetDefined=4]="NotYetDefined",e))(ae||{});Array.prototype.last||Object.defineProperty(Array.prototype,"last",{enumerable:!1,writable:!0,value:function(){return this[this.length-1]}}),Array.prototype.clear||Object.defineProperty(Array.prototype,"clear",{enumerable:!1,writable:!0,value:function(){this.length=0}}),Array.prototype.contains||Object.defineProperty(Array.prototype,"contains",{enumerable:!1,writable:!0,value:function(e){return-1!==this.indexOf(e)}});class le{static contains2(e,t){for(let i=0;i(e[e.Down=0]="Down",e[e.Right=1]="Right",e[e.RightDown=2]="RightDown",e))(ue||{}),ce=(e=>(e[e.LeftTop=0]="LeftTop",e[e.LeftCenter=1]="LeftCenter",e[e.LeftBottom=2]="LeftBottom",e[e.CenterTop=3]="CenterTop",e[e.CenterCenter=4]="CenterCenter",e[e.CenterBottom=5]="CenterBottom",e[e.RightTop=6]="RightTop",e[e.RightCenter=7]="RightCenter",e[e.RightBottom=8]="RightBottom",e))(ce||{});class de{static IsLeft(e){return 0===e||1===e||2===e}static IsCenterAligned(e){return 3===e||4===e||5===e}static IsRight(e){return 6===e||7===e||8===e}}var fe=(e=>(e[e.XML=0]="XML",e[e.AutoColoring=1]="AutoColoring",e[e.CustomColorSet=2]="CustomColorSet",e))(fe||{}),me=(e=>(e[e.Regular=0]="Regular",e[e.Bold=1]="Bold",e[e.Italic=2]="Italic",e[e.BoldItalic=3]="BoldItalic",e[e.Underlined=4]="Underlined",e))(me||{}),pe=(e=>(e[e.TimesNewRoman=0]="TimesNewRoman",e[e.Kokila=1]="Kokila",e[e.Gonville=2]="Gonville",e))(pe||{});const ge={0:"Times New Roman",1:"Kokila",2:"Gonville"};var Se=(e=>(e.SIMPLE="",e.HAMMERON="H",e.PULLOFF="P",e.SLIDE="S",e.TAPPING="T",e))(Se||{});class ye{constructor(e,t,i,s,n){this.rootPitch=e,this.chordKind=t,this.bassPitch=i,this.degrees=s,this.rules=n}get RootPitch(){return this.rootPitch}get ChordKind(){return this.chordKind}get BassPitch(){return this.bassPitch}get ChordDegrees(){return this.degrees}static calculateChordText(e,t,i){let s=e.RootPitch;if(yi.transposeCalculator&&(s=yi.transposeCalculator.transposePitch(e.RootPitch,i,t)),31===e.ChordKind)return e.getTextFromChordKindEnum(e.ChordKind);let n=K.getNoteEnumString(s.FundamentalNote);s.Accidental!==Y.NONE&&(n+=e.getTextForAccidental(s.Accidental));const r={adds:[],alts:[],subs:[]};for(const h of e.ChordDegrees)if(h){let t="";switch(h.alteration!==Y.NONE&&(t+=e.getTextForAccidental(h.alteration)),t+=h.value,h.text){case 0:r.adds.push(t);break;case 1:r.alts.push(t);break;case 2:r.subs.push(t)}}let o=e.getTextFromChordKindEnum(e.ChordKind);const a=["adds","alts","subs"],l=e.rules.CustomChords;for(const h of l){if(h.chordKind!==e.chordKind)continue;let t=!0;for(const e of a){for(const i of h.degrees[e]||[])if(r[e].indexOf(i)<0){t=!1;break}if(!t)break}if(t){for(const e of a)for(const t of h.degrees[e]||[])r[e].splice(r[e].indexOf(t),1);o=h.alternateName}}if(n+=o,r.adds.length>0&&(n+="("+r.adds.join(",")+")"),r.alts.length>0&&(n+="(alt "+r.alts.join(",")+")"),r.subs.length>0&&(n+="(omit "+r.subs.join(",")+")"),e.BassPitch){let s=e.BassPitch;yi.transposeCalculator&&(s=yi.transposeCalculator.transposePitch(e.BassPitch,i,t)),n+="/",n+=K.getNoteEnumString(s.FundamentalNote),n+=e.getTextForAccidental(s.Accidental)}return n}getTextForAccidental(e){const t=this.rules.ChordAccidentalTexts.getValue(e);return void 0!==t?t:""}getTextFromChordKindEnum(e){var t;return null!==(t=this.rules.ChordSymbolLabelTexts.getValue(e))&&void 0!==t?t:""}}class be{constructor(e,t,i){this.value=e,this.alteration=t,this.text=i}}class Me{constructor(e,t,i){this.alternateName=e,this.chordKind=t,this.degrees=i}static createCustomChord(e,t,i){return new Me(e,t,i)}static renameCustomChord(e,t,i){for(const s of i)s.alternateName===e&&(s.alternateName=t)}}var ve=(e=>(e[e.add=0]="add",e[e.alter=1]="alter",e[e.subtract=2]="subtract",e))(ve||{}),Pe=(e=>(e[e.major=0]="major",e[e.minor=1]="minor",e[e.augmented=2]="augmented",e[e.diminished=3]="diminished",e[e.dominant=4]="dominant",e[e.majorseventh=5]="majorseventh",e[e.minorseventh=6]="minorseventh",e[e.diminishedseventh=7]="diminishedseventh",e[e.augmentedseventh=8]="augmentedseventh",e[e.halfdiminished=9]="halfdiminished",e[e.majorminor=10]="majorminor",e[e.majorsixth=11]="majorsixth",e[e.minorsixth=12]="minorsixth",e[e.dominantninth=13]="dominantninth",e[e.majorninth=14]="majorninth",e[e.minorninth=15]="minorninth",e[e.dominant11th=16]="dominant11th",e[e.major11th=17]="major11th",e[e.minor11th=18]="minor11th",e[e.dominant13th=19]="dominant13th",e[e.major13th=20]="major13th",e[e.minor13th=21]="minor13th",e[e.suspendedsecond=22]="suspendedsecond",e[e.suspendedfourth=23]="suspendedfourth",e[e.Neapolitan=24]="Neapolitan",e[e.Italian=25]="Italian",e[e.French=26]="French",e[e.German=27]="German",e[e.pedal=28]="pedal",e[e.power=29]="power",e[e.Tristan=30]="Tristan",e[e.none=31]="none",e))(Pe||{});class Ee extends ne{constructor(e,t,i,s=void 0){super(),this.DrawnAccidental=Y.NONE,this.lineShift=0,this.sourceNote=e,this.parentVoiceEntry=t,this.PositionAndShape=new oe(this,t.PositionAndShape),this.graphicalNoteLength=s||e.Length,this.numberOfDots=this.calculateNumberOfNeededDots(this.graphicalNoteLength),this.rules=i,this.rules.addGraphicalNoteToNoteMap(e,this)}Transpose(e,t,i,s){let n=this.sourceNote.Pitch;return yi.transposeCalculator&&(n=yi.transposeCalculator.transposePitch(this.sourceNote.Pitch,e,i)),n}calculateNumberOfNeededDots(e){return this.sourceNote&&this.sourceNote.NoteTuplet?0:e.calculateNumberOfNeededDots()}get ParentMusicPage(){return this.parentVoiceEntry.parentStaffEntry.parentMeasure.ParentMusicSystem.Parent}static FromNote(e,t){return t.NoteToGraphicalNoteMap.getValue(e.NoteToGraphicalNoteObjectId)}ToStringShort(e=0){var t;return null===(t=this.sourceNote)||void 0===t?void 0:t.ToStringShort(e)}get ToStringShortGet(){return this.ToStringShort(0)}}const Le=class{constructor(){this.DYSlursStartingAtSameStaffEntryYOffset=0,this.DYMinNoteWidth=0,this.DYWorkId=0,this.DYWorkSpecial=!1,this.DYContainerId="osmdCanvasPage",this.DYSVGContainerId="osmdSvgPage",this.DYMusicScoreType="staff",this.DYMusicScoreId="",this.DYCustomRepeatCount=0,this.DYIsSingleLine=!1,this.DYMusicClientType="",this.NoteDistances=[1,1,1.3,1.6,2,2.5,3,4],this.NoteDistancesScalingFactors=[1,2,4,8,16,32,64,128],this.DurationDistanceDict={},this.DurationScalingDistanceDict={},this.NoteToGraphicalNoteMapObjectCount=0,this.RenderCount=0,this.PlayAlreadyStartedNotesFromCursorPosition=!1,this.PlaybackSkipNotesSafetyInterval=.02,this.UseDefaultVoiceInteractionListener=!0,this.LimitCursorPositionToCurrentMeasure=!0,this.loadDefaultValues()}loadDefaultValues(){this.SamplingUnit=3*Le.unit,this.MpatMode=!0,this.SheetTitleHeight=4,this.SheetSubtitleHeight=2,this.SheetMinimumDistanceBetweenTitleAndSubtitle=1,this.SheetComposerHeight=2,this.SheetAuthorHeight=2,this.SheetCopyrightHeight=1.5,this.SheetCopyrightMargin=2,this.SheetComposerSubtitleUseLegacyParsing=!1,this.CompactMode=!1,this.PagePlacementEnum=ue.Down,this.PageHeight=100001,this.PageTopMargin=5,this.PageTopMarginNarrow=0,this.PageBottomMargin=5,this.PageLeftMargin=5,this.PageRightMargin=5,this.TitleTopDistance=5,this.TitleBottomDistance=1,this.StaffDistance=7,this.BetweenStaffDistance=5,this.MinimumStaffLineDistance=4,this.MinSkyBottomDistBetweenStaves=1,this.StaffHeight=4,this.TabStaffInterlineHeight=1.1111,this.BetweenStaffLinesDistance=Le.unit,this.SystemLeftMargin=0,this.SystemRightMargin=0,this.SystemLabelsRightMargin=2,this.SystemComposerDistance=2,this.SystemLyricistDistance=2,this.InstrumentLabelTextHeight=2,this.MinimumDistanceBetweenSystems=7,this.MinSkyBottomDistBetweenSystems=5,this.LastSystemMaxScalingFactor=1.4,this.AutoBeamNotes=!1,this.AutoBeamOptions={beam_middle_rests_only:!1,beam_rests:!1,maintain_stem_directions:!1},this.AutoBeamTabs=!1,this.BeamWidth=Le.unit/2,this.BeamSpaceWidth=Le.unit/3,this.BeamForwardLength=1.25*Le.unit,this.FlatBeams=!1,this.FlatBeamOffset=20,this.FlatBeamOffsetPerBeam=10,this.ClefLeftMargin=.5,this.ClefRightMargin=.75,this.PercussionOneLineCutoff=3,this.PercussionForceVoicesOneLineCutoff=1,this.PercussionUseXMLDisplayStep=!0,this.PercussionXMLDisplayStepNoteValueShift=0,this.PercussionOneLineXMLDisplayStepOctaveOffset=0,this.PercussionUseCajon2NoteSystem=!1,this.BetweenKeySymbolsDistance=.2,this.KeyRightMargin=.75,this.RhythmRightMargin=1.25,this.ShowRhythmAgainAfterPartEndOrFinalBarline=!0,this.NewPartAndSystemAfterFinalBarline=!1,this.InStaffClefScalingFactor=.8,this.DistanceBetweenNaturalAndSymbolWhenCancelling=.4,this.NoteHelperLinesOffset=.25,this.MeasureLeftMargin=.7,this.MeasureRightMargin=0,this.DistanceBetweenLastInstructionAndRepetitionBarline=1,this.ArpeggioDistance=.6,this.StaccatoShorteningFactor=2,this.IdealStemLength=3,this.StemNoteHeadBorderYOffset=.2,this.StemMargin=.2,this.StemMinLength=2.5,this.StemMaxLength=4.5,this.BeamSlopeMaxAngle=10,this.StemMinAllowedDistanceBetweenNoteHeadAndBeamLine=1,this.SetWantedStemDirectionByXml=!0,this.GraceNoteScalingFactor=.6,this.GraceNoteXOffset=.2,this.GraceNoteGroupXMargin=0,this.WedgeOpeningLength=1.2,this.WedgeMeasureEndOpeningLength=.75,this.WedgeMeasureBeginOpeningLength=.75,this.WedgePlacementAboveY=-1.5,this.WedgePlacementBelowY=1.5,this.WedgeHorizontalMargin=.6,this.WedgeVerticalMargin=.5,this.DistanceOffsetBetweenTwoHorizontallyCrossedWedges=.3,this.WedgeMinLength=2,this.WedgeEndDistanceBetweenTimestampsFactor=1.75,this.SoftAccentWedgePadding=.4,this.SoftAccentSizeFactor=.6,this.DistanceBetweenAdjacentDynamics=.75,this.TempoChangeMeasureValidity=4,this.TempoContinousFactor=.7,this.StaccatoScalingFactor=.8,this.BetweenDotsDistance=.8,this.OrnamentAccidentalScalingFactor=.65,this.ChordSymbolTextHeight=2,this.ChordSymbolTextAlignment=ce.LeftBottom,this.ChordSymbolRelativeXOffset=-1,this.ChordSymbolExtraXShiftForShortChordSymbols=.3,this.ChordSymbolExtraXShiftWidthThreshold=2,this.ChordSymbolXSpacing=1,this.ChordOverlapAllowedIntoNextMeasure=0,this.ChordSymbolYOffset=.1,this.ChordSymbolYPadding=0,this.ChordSymbolYAlignment=!0,this.ChordSymbolYAlignmentScope="staffline",this.ChordSymbolWholeMeasureRestXOffset=0,this.ChordSymbolWholeMeasureRestXOffsetMeasure1=-2,this.ChordAccidentalTexts=new i,this.resetChordAccidentalTexts(this.ChordAccidentalTexts,!1),this.ChordSymbolLabelTexts=new i,this.resetChordSymbolLabelTexts(this.ChordSymbolLabelTexts),this.CustomChords=[],this.resetChordNames(),this.RepetitionSymbolsYOffset=0,this.RepetitionEndInstructionXShiftAsPercentOfStaveWidth=.4,this.RehearsalMarkXOffsetDefault=10,this.RehearsalMarkXOffset=0,this.RehearsalMarkXOffsetSystemStartMeasure=-20,this.RehearsalMarkYOffsetDefault=-15,this.RehearsalMarkYOffset=0,this.RehearsalMarkFontSize=10,this.MeasureNumberLabelHeight=1.5*Le.unit,this.MeasureNumberLabelOffset=2,this.MeasureNumberLabelXOffset=-.5,this.TupletsRatioed=!1,this.TupletsBracketed=!1,this.TripletsBracketed=!1,this.TupletsBracketedUseXMLValue=!0,this.TupletNumberLabelHeight=1.5*Le.unit,this.TupletNumberYOffset=.5,this.TupletNumberLimitConsecutiveRepetitions=!0,this.TupletNumberMaxConsecutiveRepetitions=2,this.TupletNumberAlwaysDisableAfterFirstMax=!0,this.TupletNumberUseShowNoneXMLValue=!0,this.LabelMarginBorderFactor=.1,this.TupletVerticalLineLength=.5,this.TupletNumbersInTabs=!0,this.TabTupletYOffsetBottom=1,this.TabTupletYOffsetTop=-3.5,this.TabTupletYOffsetEffects=1.5,this.TabTupletsBracketed=!0,this.TabBeamsRendered=!0,this.TabKeySignatureRendered=!1,this.TabKeySignatureSpacingAdded=!0,this.TabTimeSignatureRendered=!1,this.TabTimeSignatureSpacingAdded=!0,this.TabFingeringsRendered=!1,this.SlurPlacementFromXML=!0,this.SlurPlacementAtStems=!1,this.SlurPlacementUseSkyBottomLine=!1,this.BezierCurveStepSize=1e3,this.calculateCurveParametersArrays(),this.TieGhostObjectWidth=.75,this.TieYPositionOffsetFactor=.3,this.MinimumNeededXspaceForTieGhostObject=1,this.TieHeightMinimum=.28,this.TieHeightMaximum=1.2,this.TieHeightInterpolationK=.0288,this.TieHeightInterpolationD=.136,this.SlurNoteHeadYOffset=.5,this.SlurEndArticulationYOffset=.8,this.SlurStartArticulationYOffsetOfArticulation=.5,this.SlurStemXOffset=.3,this.SlurSlopeMaxAngle=15,this.SlurTangentMinAngle=30,this.SlurTangentMaxAngle=80,this.SlurHeightFactor=1,this.SlurHeightFlattenLongSlursFactorByWidth=.24,this.SlurHeightFlattenLongSlursFactorByAngle=.36,this.SlurHeightFlattenLongSlursCutoffAngle=47,this.SlurHeightFlattenLongSlursCutoffWidth=16,this.SlursStartingAtSameStaffEntryYOffset=.8,this.SlurMaximumYControlPointDistance=void 0,this.GlissandoNoteOffset=.5,this.GlissandoStafflineStartMinimumWidth=1,this.GlissandoStafflineStartYDistanceToNote=.8,this.GlissandoStafflineEndOffset=1,this.GlissandoDefaultWidth=.1,this.RepetitionAllowFirstMeasureBeginningRepeatBarline=!1,this.RepetitionEndingLabelHeight=2,this.RepetitionEndingLabelXOffset=.5,this.RepetitionEndingLabelYOffset=.3,this.RepetitionEndingLineYLowerOffset=.5,this.RepetitionEndingLineYUpperOffset=.3,this.VoltaOffset=2.5,this.LyricsAlignmentStandard=ce.LeftBottom,this.LyricsHeight=2,this.LyricsYOffsetToStaffHeight=0,this.LyricsYMarginToBottomLine=.2,this.LyricsExtraXShiftForShortLyrics=.5,this.LyricsExtraXShiftForShortLyricsWidthThreshold=1.4,this.LyricsUseXPaddingForLongLyrics=!0,this.LyricsXPaddingFactorForLongLyrics=1,this.LyricsXPaddingWidthThreshold=1.7,this.LyricsXPaddingReductionForLongNotes=.7,this.LyricsXPaddingReductionForLastNoteInMeasure=1.2,this.LyricsXPaddingForLastNoteInMeasure=!0,this.VerticalBetweenLyricsDistance=2,this.HorizontalBetweenLyricsDistance=5,this.BetweenSyllableMaximumDistance=10,this.BetweenSyllableMinimumDistance=.5,this.LyricOverlapAllowedIntoNextMeasure=3.4,this.MinimumDistanceBetweenDashes=10,this.MaximumLyricsElongationFactor=2.5,this.TempoYSpacing=.5,this.InstantaneousTempoTextHeight=2.3,this.ContinuousDynamicTextHeight=2.3,this.UseEndOffsetForExpressions=!0,this.MoodTextHeight=2.3,this.UnknownTextHeight=2,this.ContinuousTempoTextHeight=2.3,this.DynamicExpressionMaxDistance=2,this.DynamicExpressionSpacer=.5,this.IgnoreRepeatedDynamics=!1,this.ExpressionsUseXMLColor=!0,this.VexFlowDefaultNotationFontScale=39,this.VexFlowDefaultTabFontScale=39,this.TremoloStrokeScale=1,this.TremoloYSpacingScale=1,this.TremoloBuzzRollThickness=.25,this.StemWidth=.15,this.StaffLineWidth=.1,this.StaffLineColor=void 0,this.LedgerLineWidth=1,this.LedgerLineStrokeStyle=void 0,this.LedgerLineColorDefault="#000000",this.WedgeLineWidth=.12,this.TupletLineWidth=.12,this.LyricUnderscoreLineWidth=.12,this.SystemThinLineWidth=.12,this.SystemBoldLineWidth=Le.unit/2,this.SystemRepetitionEndingLineWidth=.12,this.SystemDotWidth=Le.unit/2,this.DistanceBetweenVerticalSystemLines=.35,this.DistanceBetweenDotAndLine=.7,this.RepeatEndStartPadding=2,this.OctaveShiftLineWidth=.12,this.OctaveShiftVerticalLineLength=Le.unit,this.OctaveShiftOnWholeMeasureNoteUntilEndOfMeasure=!1,this.GraceLineWidth=this.StaffLineWidth*this.GraceNoteScalingFactor,this.MultipleRestMeasureDefaultWidth=4,this.MultipleRestMeasureAddKeySignature=!0,this.FixedMeasureWidth=!1,this.FixedMeasureWidthFixedValue=void 0,this.FixedMeasureWidthUseForPickupMeasures=!1,this.MinimumCrossedBeamDifferenceMargin=1e-4,this.SheetMaximumWidth=32767,this.VoiceSpacingMultiplierVexflow=1,this.VoiceSpacingAddendVexflow=5,this.PickupMeasureWidthMultiplier=1,this.PickupMeasureRepetitionSpacing=.8,this.PickupMeasureSpacingSingleNoteAddend=1.6,this.DisplacedNoteMargin=.1,this.MinNoteDistance=2,this.SubMeasureXSpacingThreshold=35,this.MeasureDynamicsMaxScalingFactor=2.5,this.WholeRestXShiftVexflow=-1.5,this.MetronomeMarksDrawn=!0,this.MetronomeMarkXShift=-6,this.MetronomeMarkYShift=-1,this.SoftmaxFactorVexFlow=15,this.StaggerSameWholeNotes=!0,this.AlignRests=N.Never,this.RestCollisionYPadding=0,this.FillEmptyMeasuresWithWholeRest=C.No,this.ArpeggiosGoAcrossVoices=!1,this.RenderArpeggios=!0,this.RenderSlurs=!0,this.RenderGlissandi=!0,this.ColoringMode=fe.XML,this.ColoringEnabled=!0,this.ColorStemsLikeNoteheads=!1,this.ColorBeams=!0,this.ColorFlags=!0,this.applyDefaultColorMusic("#000000"),this.DefaultColorCursor="#33e02f",this.DefaultFontFamily="Times New Roman",this.DefaultFontStyle=me.Regular,this.DefaultVexFlowNoteFont="gonville",this.MaxMeasureToDrawIndex=Number.MAX_VALUE,this.MaxMeasureToDrawNumber=Number.MAX_VALUE,this.MinMeasureToDrawIndex=0,this.MinMeasureToDrawNumber=0,this.MaxSystemToDrawNumber=Number.MAX_VALUE,this.MaxPageToDrawNumber=Number.MAX_VALUE,this.RenderComposer=!0,this.RenderTitle=!0,this.RenderSubtitle=!0,this.RenderLyricist=!0,this.RenderCopyright=!1,this.RenderPartNames=!0,this.RenderPartAbbreviations=!0,this.RenderSystemLabelsAfterFirstPage=!0,this.RenderFingerings=!0,this.RenderMeasureNumbers=!0,this.RenderMeasureNumbersOnlyAtSystemStart=!1,this.UseXMLMeasureNumbers=!0,this.RenderLyrics=!0,this.RenderChordSymbols=!0,this.RenderMultipleRestMeasures=!0,this.AutoGenerateMultipleRestMeasuresFromRestMeasures=!0,this.RenderRehearsalMarks=!0,this.RenderClefsAtBeginningOfStaffline=!0,this.RenderKeySignatures=!0,this.RenderTimeSignatures=!0,this.RenderPedals=!0,this.RenderWavyLines=!0,this.ArticulationPlacementFromXML=!0,this.BreathMarkDistance=.8,this.FingeringPosition=d.AboveOrBelow,this.FingeringPositionFromXML=!0,this.FingeringPositionGrace=d.Left,this.FingeringInsideStafflines=!1,this.FingeringLabelFontHeight=1.7,this.FingeringOffsetX=0,this.FingeringOffsetY=0,this.FingeringPaddingY=-.2,this.FingeringTextSize=1.5,this.RenderStringNumbersClassical=!0,this.StringNumberOffsetY=0,this.NewSystemAtXMLNewSystemAttribute=!1,this.NewPageAtXMLNewPageAttribute=!1,this.NewSystemAtXMLNewPageAttribute=!1,this.RestoreCursorAfterRerender=!0,this.StretchLastSystemLine=!1,this.IgnoreBracketsWords=!0,this.PlaceWordsInsideStafflineFromXml=!1,this.PlaceWordsInsideStafflineYOffset=.9,this.UseJustifiedBuilder=!0,this.PageFormat=Te.UndefinedPageFormat,this.PageBackgroundColor=void 0,this.UsePageBackgroundColorForTabNotes=!0,this.PerformanceMode=!1,this.RenderSingleHorizontalStaffline=!1,this.SpacingBetweenTextLines=0,this.NoteToGraphicalNoteMap=new i,this.NoteToGraphicalNoteMapObjectCount=0,this.SkyBottomLineBatchMinMeasures=5,this.SkyBottomLineWebGLMinMeasures=80,this.AlwaysSetPreferredSkyBottomLineBackendAutomatically=!0,this.DisableWebGLInFirefox=!0,this.DisableWebGLInSafariAndIOS=!0,this.setPreferredSkyBottomLineBackendAutomatically();try{this.MaxInstructionsConstValue=this.ClefLeftMargin+this.ClefRightMargin+this.KeyRightMargin+this.RhythmRightMargin+11}catch(e){s.info("EngravingRules()",e)}this.MpatMode&&(this.NewPartAndSystemAfterFinalBarline=!0)}setPreferredSkyBottomLineBackendAutomatically(e=-1){let t="",i="";var s,n,r,o;"object"==typeof globalThis&&(t=null!==(s=null===(n=globalThis.navigator)||void 0===n?void 0:n.vendor)&&void 0!==s?s:"",i=null!==(r=null===(o=globalThis.navigator)||void 0===o?void 0:o.userAgent)&&void 0!==r?r:"");let a=!1;(this.DisableWebGLInSafariAndIOS&&/apple/i.test(t)||this.DisableWebGLInFirefox&&i.includes("Firefox"))&&(a=!0),this.PreferredSkyBottomLineBatchCalculatorBackend=D.Plain,a||e>=this.SkyBottomLineWebGLMinMeasures&&(this.PreferredSkyBottomLineBatchCalculatorBackend=D.WebGL)}applyDefaultColorMusic(e){this.DefaultColorMusic=e,this.DefaultColorNotehead=e,this.DefaultColorRest=e,this.DefaultColorStem=e,this.DefaultColorLabel=e,this.DefaultColorLyrics=e,this.DefaultColorTitle=e,this.LedgerLineColorDefault=e}addGraphicalNoteToNoteMap(e,t){e.NoteToGraphicalNoteObjectId=this.NoteToGraphicalNoteMapObjectCount,this.NoteToGraphicalNoteMap.setValue(e.NoteToGraphicalNoteObjectId,t),this.NoteToGraphicalNoteMapObjectCount++}GNote(e){return Ee.FromNote(e,this)}clearMusicSheetObjects(){this.NoteToGraphicalNoteMap=new i,this.NoteToGraphicalNoteMapObjectCount=0}resetChordAccidentalTexts(e,t){e.setValue(Y.SHARP,t?"♯":"#"),e.setValue(Y.FLAT,t?"♭":"b"),e.setValue(Y.DOUBLEFLAT,t?"𝄫":"bb"),e.setValue(Y.DOUBLESHARP,t?"𝄪":"x")}setChordSymbolLabelText(e,t){this.ChordSymbolLabelTexts.setValue(e,t)}resetChordSymbolLabelTexts(e){return e.setValue(Pe.minor,"m"),e.setValue(Pe.augmented,"aug"),e.setValue(Pe.diminished,"dim"),e.setValue(Pe.dominant,"7"),e.setValue(Pe.majorseventh,"maj7"),e.setValue(Pe.minorseventh,"m7"),e.setValue(Pe.diminishedseventh,"dim7"),e.setValue(Pe.augmentedseventh,"aug7"),e.setValue(Pe.halfdiminished,`m7${this.ChordAccidentalTexts.getValue(Y.FLAT)}5`),e.setValue(Pe.majorminor,"m(maj7)"),e.setValue(Pe.majorsixth,"maj6"),e.setValue(Pe.minorsixth,"m6"),e.setValue(Pe.dominantninth,"9"),e.setValue(Pe.majorninth,"maj9"),e.setValue(Pe.minorninth,"m9"),e.setValue(Pe.dominant11th,"11"),e.setValue(Pe.major11th,"maj11"),e.setValue(Pe.minor11th,"m11"),e.setValue(Pe.dominant13th,"13"),e.setValue(Pe.major13th,"maj13"),e.setValue(Pe.minor13th,"m13"),e.setValue(Pe.suspendedsecond,"sus2"),e.setValue(Pe.suspendedfourth,"sus4"),e.setValue(Pe.power,"5"),e.setValue(Pe.none,"N.C."),e}addChordName(e,t,i,s,n){if(void 0!==Pe[t]){const r={adds:i,alts:s,subs:n};this.CustomChords.push(Me.createCustomChord(e,Pe[t],r))}}renameChord(e,t){Me.renameCustomChord(e,t,this.CustomChords)}resetChordNames(){const e=this.ChordAccidentalTexts.getValue(Y.SHARP),t=this.ChordAccidentalTexts.getValue(Y.FLAT);this.addChordName("alt","major",[`${e}5`,`${t}9`,`${e}9`],[`${t}5`],[]),this.addChordName("7alt","dominant",[`${e}5`,`${t}9`,`${e}9`],[`${t}5`],[]),this.addChordName("7sus4","dominant",["4"],[],["3"]),this.addChordName("7sus4","suspendedfourth",["7"],[],[]),this.addChordName("9sus4","dominantninth",["4"],[],["3"]),this.addChordName("9sus4","suspendedfourth",["9"],[],[]),this.addChordName("11sus4","dominant11th",["4"],[],["3"]),this.addChordName("11sus4","suspendedfourth",["11"],[],[]),this.addChordName("13sus4","dominant13th",["4"],[],["3"]),this.addChordName("13sus4","suspendedfourth",["13"],[],[]),this.addChordName("7sus2","dominant",["2"],[],["3"]),this.addChordName("7sus2","suspendedsecond",["7"],[],[]),this.addChordName(`m7${t}5`,"minorseventh",[],[`${t}5`],[]),this.addChordName("9sus2","dominantninth",["2"],[],["3"]),this.addChordName("9sus2","suspendedsecond",["9"],[],[]),this.addChordName("11sus2","dominant11th",["2"],[],["3"]),this.addChordName("11sus2","suspendedsecond",["11"],[],[]),this.addChordName("13sus2","dominant13th",["2"],[],["3"]),this.addChordName("13sus2","suspendedsecond",["13"],[],[]),this.addChordName("m(maj9)","majorminor",["9"],[],[]),this.addChordName("m(maj11)","majorminor",["11"],[],[]),this.addChordName("m(maj13)","majorminor",["13"],[],[]),this.addChordName("69","majorsixth",["9"],[],[]),this.addChordName("mi69","minorsixth",["9"],[],[])}calculateCurveParametersArrays(){this.TPower3=new Array(this.BezierCurveStepSize),this.OneMinusTPower3=new Array(this.BezierCurveStepSize),this.FactorOne=new Array(this.BezierCurveStepSize),this.FactorTwo=new Array(this.BezierCurveStepSize);for(let e=0;e{var i,s,n,r;return(null!==(i=null===(s=t.sourceNote.Pitch)||void 0===s?void 0:s.getHalfTone())&&void 0!==i?i:0)-(null!==(n=null===(r=e.sourceNote.Pitch)||void 0===r?void 0:r.getHalfTone())&&void 0!==n?n:0)})),this.notes}sortForVexflow(){return this.notes.sort(((e,t)=>{var i,s,n;return(null!==(i=null===(s=e.sourceNote.Pitch)||void 0===s?void 0:s.getHalfTone())&&void 0!==i?i:0)-(null!==(n=t.sourceNote.Pitch.getHalfTone())&&void 0!==n?n:0)})),this.notes}color(){}}class Ie{constructor(e,t){this.musicPages=[],this.measureList=[],this.verticalGraphicalStaffEntryContainers=[],this.cursors=[],this.leadSheet=!1,this.musicSheet=e,this.numberOfStaves=this.musicSheet.Staves.length,this.calculator=t,this.calculator.initialize(this)}get ParentMusicSheet(){return this.musicSheet}get GetCalculator(){return this.calculator}get JianpuKeySignature(){return this.jianpuKeySignature}set JianpuKeySignature(e){this.jianpuKeySignature=e}get MusicPages(){return this.musicPages}set MusicPages(e){this.musicPages=e}get MeasureList(){return this.measureList}set MeasureList(e){this.measureList=e}get VerticalGraphicalStaffEntryContainers(){return this.verticalGraphicalStaffEntryContainers}set VerticalGraphicalStaffEntryContainers(e){this.verticalGraphicalStaffEntryContainers=e}get Title(){return this.title}set Title(e){this.title=e}get Subtitle(){return this.subtitle}set Subtitle(e){this.subtitle=e}get Composer(){return this.composer}set Composer(e){this.composer=e}get Lyricist(){return this.lyricist}set Lyricist(e){this.lyricist=e}get Copyright(){return this.copyright}set Copyright(e){this.copyright=e}get Cursors(){return this.cursors}get SelectionStartSymbol(){return this.selectionStartSymbol}get SelectionEndSymbol(){return this.selectionEndSymbol}get MinAllowedSystemWidth(){return this.minAllowedSystemWidth}set MinAllowedSystemWidth(e){this.minAllowedSystemWidth=e}get NumberOfStaves(){return this.numberOfStaves}get LeadSheet(){return this.leadSheet}set LeadSheet(e){this.leadSheet=e}static transformRelativeToAbsolutePosition(e){for(let t=0;t=0;s--){var i;const e=null===(i=this.measureList[s])||void 0===i?void 0:i[t];if(e)return e}}findGraphicalMeasureByMeasureNumber(e,t){for(let i=e;i>=0;i--)if(this.MeasureList[i]){const s=this.MeasureList[i][t];if((null==s?void 0:s.MeasureNumber)===e)return s}}findGraphicalStaffEntryFromMeasureList(e,t,i){for(let s=t;s0)return i.staffEntries[0]}}getFirstVisibleMeasuresListFromIndices(e,t){const i=[],s=this.measureList[0].length;for(let n=e;n<=t;n++)for(let e=0;e=0;t--){if(this.verticalGraphicalStaffEntryContainers[t].AbsoluteTimestamp.lt(e)){const i=new F(this.numberOfStaves,e);return this.verticalGraphicalStaffEntryContainers.splice(t+1,0,i),i}if(this.verticalGraphicalStaffEntryContainers[t].AbsoluteTimestamp.Equals(e))return this.verticalGraphicalStaffEntryContainers[t]}}GetVerticalContainerFromTimestamp(e,t=0){const i=le.binarySearch(this.verticalGraphicalStaffEntryContainers,new F(0,e),F.compareByTimestamp,t);if(i>=0)return this.verticalGraphicalStaffEntryContainers[i]}GetInterpolatedIndexInVerticalContainers(e){const t=this.verticalGraphicalStaffEntryContainers;if(1===t.length)return 0;let i,s,n=0,r=t.length-1;if(e.lte(t[t.length-1].AbsoluteTimestamp)){for(;r-n>1;){const i=Math.floor((r+n)/2);if(t[n].AbsoluteTimestamp.Equals(e)){r=n;break}if(t[r].AbsoluteTimestamp.Equals(e)){n=r;break}if(t[i].AbsoluteTimestamp.Equals(e))return this.verticalGraphicalStaffEntryContainers.indexOf(t[i]);e.lt(t[i].AbsoluteTimestamp)?r=i:n=i}if(n===r)return this.verticalGraphicalStaffEntryContainers.indexOf(t[n]);i=t[n].AbsoluteTimestamp,s=t[r].AbsoluteTimestamp}else i=t[t.length-1].AbsoluteTimestamp,s=u.plus(this.getLongestStaffEntryDuration(t.length-1),i),r=t.length;const o=s.RealValue-i.RealValue,a=r-(s.RealValue-e.RealValue)/o;return Math.min(a,this.verticalGraphicalStaffEntryContainers.length-1)}getVisibleStavesIndicesFromSourceMeasure(e){const t=[],i=[];for(let s=0,n=e.length;s=0;)s=this.measureList[--i][e];return this.measureList[i][e]}getMeasureIndex(e,t,i){for(t=0;t{var t;return void 0!==(null===(t=e.parentStaffEntry)||void 0===t?void 0:t.relInMeasureTimestamp)}))}GetNearestNote(e,t){const i=this.GetNearestVoiceEntry(e);if(!i)return;let s,n=Number.MAX_SAFE_INTEGER;for(const r of i.notes){const t=r.PositionAndShape.AbsolutePosition.y,i=Math.abs(r.PositionAndShape.AbsolutePosition.x-e.x),o=Math.abs(t-e.y);i+os.PositionAndShape.RelativePosition.x&&(i=s):i=s)}}catch(n){s.info("GraphicalMusicSheet.getStaffEntry",n)}return i}GetPreviousVisibleContainerIndex(e){for(let t=e-1;t>=0;t--){const e=this.verticalGraphicalStaffEntryContainers[t].StaffEntries;for(let i=0,s=e.length;i=0;n--)if(i=this.getStaffEntry(n),i){if(!t)return i;if(i.sourceStaffEntry.ParentStaff.ParentInstrument.Visible)return i}}findClosestRightStaffEntry(e,t){let i;for(let s=Math.max(0,Math.ceil(e));s1}isVisible(){return this.ParentStaff.ParentInstrument.Visible}getGraphicalMeasureDurationFromStaffEntries(){let e=new u(0,1);const t=[];for(let i=0,s=this.staffEntries.length;i0&&n.Add(t.notes[0].graphicalNoteLength);e.lt(n)&&(e=u.createFromFraction(n))}return e}addGraphicalStaffEntry(e){this.staffEntries.push(e)}addGraphicalStaffEntryAtTimestamp(e){if(e)if(0===this.staffEntries.length||this.staffEntries[this.staffEntries.length-1].relInMeasureTimestamp.lt(e.relInMeasureTimestamp))this.staffEntries.push(e);else for(let t=this.staffEntries.length-1;t>=0;t--){if(this.staffEntries[t].relInMeasureTimestamp.lt(e.relInMeasureTimestamp)){this.staffEntries.splice(t+1,0,e);break}0===t&&this.staffEntries.splice(t,0,e)}}isPianoRightHand(){return this.isUpperStaffOfInstrument()}isPianoLeftHand(){return this.isLowerStaffOfInstrument()}isUpperStaffOfInstrument(){return 1===this.parentStaff.ParentInstrument.Staves.length||this.ParentStaff===this.parentStaff.ParentInstrument.Staves[0]}isLowerStaffOfInstrument(){return 1!==this.parentStaff.ParentInstrument.Staves.length&&this.ParentStaff===this.ParentStaff.ParentInstrument.Staves.last()}beginsWithLineRepetition(){const e=this.parentSourceMeasure;return!!e&&e.beginsWithLineRepetition()}endsWithLineRepetition(){const e=this.parentSourceMeasure;return!!e&&e.endsWithLineRepetition()}beginsWithWordRepetition(){const e=this.parentSourceMeasure;return!!e&&e.beginsWithWordRepetition()}endsWithWordRepetition(){const e=this.parentSourceMeasure;return!!e&&e.endsWithWordRepetition()}getTransposedHalftones(){return this.parentStaff.ParentInstrument.GetMusicSheet.Transpose+this.parentStaff.ParentInstrument.Transpose}}var Ne=(e=>(e[e.SingleThin=0]="SingleThin",e[e.DoubleThin=1]="DoubleThin",e[e.ThinBold=2]="ThinBold",e[e.BoldThinDots=3]="BoldThinDots",e[e.DotsThinBold=4]="DotsThinBold",e[e.DotsBoldBoldDots=5]="DotsBoldBoldDots",e[e.None=6]="None",e[e.Dotted=7]="Dotted",e[e.Dashed=8]="Dashed",e[e.Bold=9]="Bold",e[e.BoldThin=10]="BoldThin",e[e.DoubleBold=11]="DoubleBold",e[e.Tick=12]="Tick",e[e.Short=13]="Short",e))(Ne||{});class Ce{static xmlBarlineStyleToSystemLinesEnum(e){return"regular"===e?0:"dotted"===e?7:"dashed"===e?8:"heavy"===e?9:"light-light"===e?1:"light-heavy"===e?2:"heavy-light"===e?10:"heavy-heavy"===e?11:"tick"===e?12:"short"===e?13:"none"===e?6:0}}class Be{constructor(){this.matrix=[];for(let e=0;e<2;e++){this.matrix[e]=[];for(let t=0;t<2;t++)this.matrix[e][t]=0}}static getRotationMatrix(e){const t=new Be,i=Math.cos(e),s=Math.sin(e);return t.matrix[0][0]=i,t.matrix[0][1]=-s,t.matrix[1][0]=s,t.matrix[1][1]=i,t}scalarMultiplication(e){for(let t=0;t<2;t++)for(let i=0;i<2;i++)this.matrix[t][i]*=e}getTransposeMatrix(){const e=new Be;for(let t=0;t<2;t++)for(let i=0;i<2;i++)e.matrix[t][i]=this.matrix[i][t];return e}vectorMultiplication(e){const t=new z;return t.x=e.x*this.matrix[0][0]+e.y*this.matrix[0][1],t.y=e.x*this.matrix[1][0]+e.y*this.matrix[1][1],t}}class De{constructor(){this.measureErrors={},this.errors=[],this.tempErrors=[]}finalizeMeasure(e){let t=this.measureErrors[e];t||(t=[]),this.measureErrors[e]=t.concat(this.tempErrors),this.tempErrors=[]}pushMeasureError(e){this.tempErrors.push(e)}push(e){this.errors.push(e)}}class Ve{constructor(e,t=7){this.parentVoiceEntry=e,this.type=t,this.notes=[]}addNote(e){this.notes.push(e),e.Arpeggio=this}}var ke=(e=>(e[e.BRUSH_DOWN=1]="BRUSH_DOWN",e[e.BRUSH_UP=2]="BRUSH_UP",e[e.ROLL_DOWN=3]="ROLL_DOWN",e[e.ROLL_UP=4]="ROLL_UP",e[e.RASQUEDO_DOWN=5]="RASQUEDO_DOWN",e[e.RASQUEDO_UP=6]="RASQUEDO_UP",e[e.ARPEGGIO_DIRECTIONLESS=7]="ARPEGGIO_DIRECTIONLESS",e))(ke||{});class Fe{constructor(e=1,t=0){this.notes=[],this.extendedNoteList=[],this.BeamNumberOffsetToXML=0,this.AutoGenerated=!1,this.BeamNumber=e,this.BeamNumberOffsetToXML=t}get Notes(){return this.notes}set Notes(e){this.notes=e}get ExtendedNoteList(){return this.extendedNoteList}set ExtendedNoteList(e){this.extendedNoteList=e}addNoteToBeam(e){e&&(e.NoteBeam=this,this.notes.push(e),this.extendedNoteList.push(e))}}class Oe{constructor(e){this.notes=[],this.XMLNumber=1,this.AddNote(e),this.StartNote=e,this.Direction=ae.NotYetDefined}get Notes(){return this.notes}get Duration(){const e=new u;for(const t of this.notes)e.Add(t.Length);return e}get Pitch(){return this.StartNote.Pitch}AddNote(e){this.notes.push(e),e.NoteGlissando=this,2===this.notes.length&&(this.notes[0].Pitch.getHalfTone()2:(s.warn("notehead: sourceNote and filledXmlAttribute undefined."),i=!0)),this.filled=i}get SourceNote(){return this.sourceNote}get Shape(){return this.shape}get Filled(){return this.filled}static ShapeTypeXmlToShape(e){switch(e.toLowerCase()){case"normal":return 2;case"x":return 8;case"slash":return 4;case"diamond":return 1;case"square":case"la":return 5;case"do":case"triangle":return 6;case"inverted triangle":return 7;case"rectangle":return 3;case"circle-x":return 0;default:return s.info("unsupported/unhandled xml notehead '"+e+"'. Using normal notehead."),2}}}var Ue=(e=>(e[e.CIRCLEX=0]="CIRCLEX",e[e.DIAMOND=1]="DIAMOND",e[e.NORMAL=2]="NORMAL",e[e.RECTANGLE=3]="RECTANGLE",e[e.SLASH=4]="SLASH",e[e.SQUARE=5]="SQUARE",e[e.TRIANGLE=6]="TRIANGLE",e[e.TRIANGLE_INVERTED=7]="TRIANGLE_INVERTED",e[e.X=8]="X",e))(Ue||{});class Xe{static translateText(e,t){if(!this.defaultTextTranslation)return t}}var ze=(e=>(e[e.UNDEFINED=0]="UNDEFINED",e[e._1024th=1]="_1024th",e[e._512th=2]="_512th",e[e._256th=3]="_256th",e[e._128th=4]="_128th",e[e._64th=5]="_64th",e[e._32nd=6]="_32nd",e[e._16th=7]="_16th",e[e.EIGTH=8]="EIGTH",e[e.QUARTER=9]="QUARTER",e[e.HALF=10]="HALF",e[e.WHOLE=11]="WHOLE",e[e.BREVE=12]="BREVE",e[e.LONG=13]="LONG",e[e.MAXIMA=14]="MAXIMA",e))(ze||{});class He{static NoteTypeToString(e){return this.NoteTypeXmlValues[e]}static StringToNoteType(e){const t=this.NoteTypeXmlValues.indexOf(e);return-1!==t?t:0}static getNoteDurationFromType(e){switch(e){case"1024th":return new u(1,1024);case"512th":return new u(1,512);case"256th":return new u(1,256);case"128th":return new u(1,128);case"64th":return new u(1,64);case"32th":case"32nd":return new u(1,32);case"16th":return new u(1,16);case"eighth":return new u(1,8);case"quarter":return new u(1,4);case"half":return new u(1,2);case"whole":return new u(1,1);case"breve":return new u(2,1);case"long":return new u(4,1);case"maxima":return new u(8,1);default:{const e=Xe.translateText("ReaderErrorMessages/NoteDurationError","Invalid note duration.");throw new S(e)}}}}He.NoteTypeXmlValues=["","1024th","512th","256th","128th","64th","32nd","16th","eigth","quarter","half","whole","breve","long","maxima"];class Ye{constructor(e){this.placement=d.Above,this.accidentalAbove=Y.NONE,this.accidentalBelow=Y.NONE,this.ornament=e}get GetOrnament(){return this.ornament}get AccidentalAbove(){return this.accidentalAbove}set AccidentalAbove(e){this.accidentalAbove=e}get AccidentalBelow(){return this.accidentalBelow}set AccidentalBelow(e){this.accidentalBelow=e}}var je=(e=>(e[e.Trill=0]="Trill",e[e.Turn=1]="Turn",e[e.InvertedTurn=2]="InvertedTurn",e[e.DelayedTurn=3]="DelayedTurn",e[e.DelayedInvertedTurn=4]="DelayedInvertedTurn",e[e.Mordent=5]="Mordent",e[e.InvertedMordent=6]="InvertedMordent",e))(je||{});class Ke{constructor(e,t,i){this.staffEntries=[],this.comments=[],this.timestamp=t,this.staffEntries=new Array(i),this.parentMeasure=e}$get$(e){return this.staffEntries[e]}$set$(e,t){this.staffEntries[e]=t}get Timestamp(){return this.timestamp}set Timestamp(e){this.timestamp=e}get StaffEntries(){return this.staffEntries}set StaffEntries(e){this.staffEntries=e}get Comments(){return this.comments}set Comments(e){this.comments=e}get ParentMeasure(){return this.parentMeasure}set ParentMeasure(e){this.parentMeasure=e}getAbsoluteTimestamp(){return u.plus(this.timestamp,this.parentMeasure.AbsoluteTimestamp)}}class Je{constructor(e,t){this.voiceEntries=[],this.instructions=[],this.chordSymbolContainers=[],this.verticalContainerParent=e,this.parentStaff=t}get ParentStaff(){return this.parentStaff}get VerticalContainerParent(){return this.verticalContainerParent}get Timestamp(){if(this.VerticalContainerParent)return this.VerticalContainerParent.Timestamp}get AbsoluteTimestamp(){if(this.VerticalContainerParent)return u.plus(this.VerticalContainerParent.ParentMeasure.AbsoluteTimestamp,this.VerticalContainerParent.Timestamp)}get VoiceEntries(){return this.voiceEntries}set VoiceEntries(e){this.voiceEntries=e}get Link(){return this.staffEntryLink}set Link(e){this.staffEntryLink=e}get Instructions(){return this.instructions}set Instructions(e){this.instructions=e}get ChordContainers(){return this.chordSymbolContainers}set ChordContainers(e){this.chordSymbolContainers=e}removeAllInstructionsOfTypeClefInstruction(){let e=0,t=0;for(;e0)return!0;return!1}hasTie(){for(let e=0,t=this.VoiceEntries.length;et.parentRepetition.StartIndex)return-1}if(0===e.alignment&&0===t.alignment){if(e.parentRepetition.EndIndext.parentRepetition.EndIndex)return-1}}return 0}}class $e{constructor(e,t,i=1,s=void 0,n=void 0,r){this.endingIndices=void 0,this.measureIndex=e,n&&(this.endingIndices=n.slice()),this.type=t,r&&(this.originalVal=r),this.alignment=i,this.parentRepetition=s}CompareTo(e){const t=e;if(this.measureIndex>t.measureIndex)return 1;if(this.measureIndex(e[e.StartLine=0]="StartLine",e[e.ForwardJump=1]="ForwardJump",e[e.BackJumpLine=2]="BackJumpLine",e[e.Ending=3]="Ending",e[e.DaCapo=4]="DaCapo",e[e.DalSegno=5]="DalSegno",e[e.Fine=6]="Fine",e[e.ToCoda=7]="ToCoda",e[e.DalSegnoAlFine=8]="DalSegnoAlFine",e[e.DaCapoAlFine=9]="DaCapoAlFine",e[e.DalSegnoAlCoda=10]="DalSegnoAlCoda",e[e.DaCapoAlCoda=11]="DaCapoAlCoda",e[e.Coda=12]="Coda",e[e.Segno=13]="Segno",e[e.None=14]="None",e))(Qe||{}),Ze=(e=>(e[e.Begin=0]="Begin",e[e.End=1]="End",e))(Ze||{});let et=null;class tt{constructor(e,t){this.printNewSystemXml=!1,this.printNewPageXml=!1,this.IsSystemStartMeasure=!1,this.WidthFactor=1,this.hasLyrics=!1,this.hasMoodExpressions=!1,this.CompoundTempo="",this.allRests=!1,this.isReducedToMultiRest=!1,this.multipleRestMeasureNumber=0,this.staffLinkedExpressions=[],this.tempoExpressions=[],this.verticalSourceStaffEntryContainers=[],this.graphicalMeasureErrors=[],this.firstRepetitionInstructions=[],this.lastRepetitionInstructions=[],this.metronomeNoteIndex=0,this.WasRendered=!1,this.completeNumberOfStaves=e,this.implicitMeasure=!1,this.hasEndLine=!1,this.endingBarStyleXml="",this.endingBarStyleEnum=Ne.SingleThin,this.firstInstructionsStaffEntries=new Array(e),this.lastInstructionsStaffEntries=new Array(e),this.rules=t,this.TempoInBPM=0;for(let i=0;i1)return e[this.measureListIndex-1]}get Rules(){return this.rules}get VerticalMeasureList(){return this.verticalMeasureList}set VerticalMeasureList(e){this.verticalMeasureList=e}get TempoInBPM(){return this.tempoInBPM}set TempoInBPM(e){this.tempoInBPM=e}findOrCreateStaffEntry(e,t,i){let s,n;for(const o of this.verticalSourceStaffEntryContainers)if(o.Timestamp.Equals(e)){n=o;break}if(n)return n.StaffEntries[t]?s=n.StaffEntries[t]:(s=new Je(n,i),n.StaffEntries[t]=s),{createdNewContainer:!1,staffEntry:s};const r=this.verticalSourceStaffEntryContainers[this.verticalSourceStaffEntryContainers.length-1];if(0===this.verticalSourceStaffEntryContainers.length||r.Timestamp.lt(e)){const n=new Ke(this,e.clone(),this.completeNumberOfStaves);this.verticalSourceStaffEntryContainers.push(n),s=new Je(n,i),n.StaffEntries[t]=s}else for(let o=this.verticalSourceStaffEntryContainers.length-1;o>=0;o--){if(this.verticalSourceStaffEntryContainers[o].Timestamp.lt(e)){const n=new Ke(this,e.clone(),this.completeNumberOfStaves);this.verticalSourceStaffEntryContainers.splice(o+1,0,n),s=new Je(n,i),n.StaffEntries[t]=s;break}if(0===o){const n=new Ke(this,e.clone(),this.completeNumberOfStaves);this.verticalSourceStaffEntryContainers.splice(o,0,n),s=new Je(n,i),n.StaffEntries[t]=s;break}}return{createdNewContainer:!0,staffEntry:s}}findOrCreateVoiceEntry(e,t){let i,s=!1;for(const n of e.VoiceEntries)if(n.ParentVoice===t){i=n;break}return i||(i=new ut(e.Timestamp,t,e),s=!0),{createdVoiceEntry:s,voiceEntry:i}}getPreviousSourceStaffEntryFromIndex(e,t){for(let i=t-1;i>=0;i--)if(this.verticalSourceStaffEntryContainers[i][e])return this.verticalSourceStaffEntryContainers[i][e]}getVerticalContainerIndexByTimestamp(e){for(let t=0,i=this.VerticalSourceStaffEntryContainers.length;t=0;n--){const e=this.verticalSourceStaffEntryContainers[n][i+s];if(void 0!==e&&e.hasTie()&&t.lt(u.plus(e.Timestamp,e.calculateMaxNoteLength()))){t=u.plus(e.Timestamp,e.calculateMaxNoteLength());break}}}s.push(t)}for(let n=0,r=s.length;n0)return!0}return!1}beginsWithLineRepetition(){for(let e=0,t=this.FirstRepetitionInstructions.length;e=0;s--)if(i=this.verticalSourceStaffEntryContainers[s].StaffEntries[e],i&&(!t||i.VoiceEntries.length>0))return i}canBeReducedToMultiRest(){var e,t,i,s,n,r,o,a;if(this.firstRepetitionInstructions.length>0||this.lastRepetitionInstructions.length>0)return!1;let l=!0,h=!1;for(const u of this.verticalSourceStaffEntryContainers)if(u)for(const e of u.StaffEntries)if(e&&e.ParentStaff.ParentInstrument.Visible){if(e.ChordContainers.length>0)return!1;e.ParentStaff.hasLyrics&&(h=!0);for(const t of e.VoiceEntries){for(const e of t.Notes)if(!e.isRest()){l=!1;break}if(!l)break}}if(!l||h||this.hasMoodExpressions||this.tempoExpressions.length>0)return!1;for(const u of this.staffLinkedExpressions)if(u.length>0)return!1;for(const u of this.lastInstructionsStaffEntries)for(let e=0,t=null==u?void 0:u.Instructions.length;e=0;t--)for(let i=0;i(e[e.Fingering=0]="Fingering",e[e.String=1]="String",e))(ot||{});class at{}class lt{constructor(e,t){if(this.parentEntry=e,this.parentNote=t,this.ParentNote.PlaybackNote=this,this.Length=this.ParentNote.Length,void 0!==t.Pitch){const e=this.ParentNote.ParentStaff.ParentInstrument.MidiInstrumentId===$.Percussion;this.MidiKey=e?lt.noteToMidiDrumKey(t):t.Pitch.getHalfTone()+12}else this.MidiKey=0}setLength(){void 0!==this.ParentNote.NoteTie&&this.ParentNote.NoteTie.StartNote===this.ParentNote&&(this.Length=this.ParentNote.NoteTie.Duration)}get ParentEntry(){return this.parentEntry}get ParentNote(){return this.parentNote}static noteToMidiDrumKey(e){var t;const i=e.Pitch.getHalfTone()-12,s=null===(t=e.Notehead)||void 0===t?void 0:t.Shape;switch(e.Pitch.Octave){case 1:switch(e.Pitch.FundamentalNote){case H.D:return 44;case H.E:return 35;case H.F:return 36;case H.G:return 41;case H.A:return 43;case H.B:return s===Ue.TRIANGLE?54:47;default:return i}case 2:switch(e.Pitch.FundamentalNote){case H.C:return s===Ue.X?37:38;case H.D:return s===Ue.X?59:48;case H.E:switch(s){case Ue.X:return 42;case Ue.CIRCLEX:return 46;case Ue.TRIANGLE:return 56;default:return 50}case H.F:return s===Ue.DIAMOND?53:51;case H.G:switch(s){case Ue.CIRCLEX:case Ue.DIAMOND:return 46;default:return 42}case H.A:return 49;case H.B:return 57;default:return i}case 3:return e.Pitch.FundamentalNote===H.C?s===Ue.CIRCLEX?52:55:i;default:return i}}}class ht{constructor(e){this.notes=[],this.TimestampShift=new u,this.parentVoiceEntry=e;for(const t of e.Notes)this.Notes.push(new lt(this,t))}get ParentVoiceEntry(){return this.parentVoiceEntry}get Notes(){return this.notes}get Length(){if(this.Notes.length>0)return this.Notes[0].Length}set Length(e){for(const t of this.Notes)t.Length=e}get HasNotes(){return this.Notes.length>0}}class ut{constructor(e,t,s,n=!0,r=!1,o=!1,a=!1){if(this.notes=[],this.graceVoiceEntriesBefore=[],this.graceVoiceEntriesAfter=[],this.articulations=[],this.playbackEntries=[],this.technicalInstructions=[],this.lyricsEntries=new i,this.wantedStemDirection=-1,this.stemDirectionXml=-1,this.stemDirection=-1,this.timestamp=e,this.parentVoice=t,this.parentSourceStaffEntry=s,this.isGrace=r,this.graceAfterMainNote=!1,this.graceNoteSlash=o,this.graceSlur=a,r||t.VoiceEntries.push(this),n&&void 0!==s){const e=s.VoiceEntries;-1===e.indexOf(this)&&e.push(this)}this.mainPlaybackEntry=new ht(this),this.PlaybackEntries.push(this.mainPlaybackEntry)}get ParentSourceStaffEntry(){return this.parentSourceStaffEntry}get ParentVoice(){return this.parentVoice}get Timestamp(){return this.timestamp}set Timestamp(e){this.timestamp=e}get Notes(){return this.notes}addNote(e){this.notes.push(e),e.isRest()||void 0!==e.NoteTie&&e.NoteTie.StartNote!==e||this.MainPlaybackEntry.Notes.push(new lt(this.MainPlaybackEntry,e))}get GraceVoiceEntriesBefore(){return this.graceVoiceEntriesBefore}set GraceVoiceEntriesBefore(e){this.graceVoiceEntriesBefore=e;for(const t of this.graceVoiceEntriesBefore)t.parentSourceStaffEntry=this.ParentSourceStaffEntry}get GraceVoiceEntriesAfter(){return this.graceVoiceEntriesAfter}set GraceVoiceEntriesAfter(e){this.graceVoiceEntriesAfter=e;for(const t of this.graceVoiceEntriesAfter)t.parentSourceStaffEntry=this.ParentSourceStaffEntry}get IsGrace(){return this.isGrace}set IsGrace(e){this.isGrace=e}get GraceAfterMainNote(){return this.graceAfterMainNote}set GraceAfterMainNote(e){this.graceAfterMainNote=e}get GraceNoteSlash(){return this.graceNoteSlash}set GraceNoteSlash(e){this.graceNoteSlash=e}get GraceSlur(){return this.graceSlur}set GraceSlur(e){this.graceSlur=e}get Articulations(){return this.articulations}get PlaybackEntries(){return this.playbackEntries}get Fermata(){return this.fermata}get MainPlaybackEntry(){return this.mainPlaybackEntry}set MainPlaybackEntry(e){this.mainPlaybackEntry=e}removeMainPlaybackEntry(){void 0!==this.mainPlaybackEntry&&this.removePlaybackEntry(this.mainPlaybackEntry)}removePlaybackEntry(e){this.mainPlaybackEntry===e&&(this.mainPlaybackEntry=void 0);const t=this.playbackEntries.indexOf(e);t>-1&&this.playbackEntries.splice(t,1)}set Articulations(e){this.articulations=e}get TechnicalInstructions(){return this.technicalInstructions}get LyricsEntries(){return this.lyricsEntries}get Arpeggio(){return this.arpeggio}set Arpeggio(e){this.arpeggio=e}get OrnamentContainer(){return this.ornamentContainer}set OrnamentContainer(e){this.ornamentContainer=e}set WantedStemDirection(e){this.wantedStemDirection=e}get WantedStemDirection(){return this.wantedStemDirection}set StemDirectionXml(e){this.stemDirectionXml=e}get StemDirectionXml(){return this.stemDirectionXml}set StemDirection(e){this.stemDirection=e}get StemDirection(){return this.stemDirection}get StemColorXml(){return this.stemColorXml}set StemColorXml(e){this.stemColorXml=e}get StemColor(){return this.stemColor}set StemColor(e){this.stemColor=e}get VolumeModifier(){return this.volumeModifier}set VolumeModifier(e){this.volumeModifier=e}get DurationModifier(){return this.durationModifier}set DurationModifier(e){this.durationModifier=e}hasArticulation(e){for(const t of this.articulations)if(t.Equals(e))return!0;return!1}static isSupportedArticulation(e){switch(e){case 0:case 1:case 2:case 5:case 6:case 7:case 8:case 9:case 10:case 11:case 12:case 13:case 14:case 15:case 16:case 17:case 18:case 27:return!0;default:return!1}}hasTie(){for(let e=0,t=this.Notes.length;e0)return!0;return!1}isStaccato(){for(const e of this.Articulations)if(6===e.articulationEnum)return!0;return!1}isAccent(){for(const e of this.Articulations)if(0===e.articulationEnum||1===e.articulationEnum)return!0;return!1}getVerseNumberForLyricEntry(e){let t="1";return this.lyricsEntries.forEach(((i,s)=>{e===s&&(t=i)})),t}}var ct=(e=>(e[e.accent=0]="accent",e[e.strongaccent=1]="strongaccent",e[e.softaccent=2]="softaccent",e[e.marcatoup=3]="marcatoup",e[e.marcatodown=4]="marcatodown",e[e.invertedstrongaccent=5]="invertedstrongaccent",e[e.staccato=6]="staccato",e[e.staccatissimo=7]="staccatissimo",e[e.spiccato=8]="spiccato",e[e.tenuto=9]="tenuto",e[e.fermata=10]="fermata",e[e.invertedfermata=11]="invertedfermata",e[e.breathmark=12]="breathmark",e[e.caesura=13]="caesura",e[e.lefthandpizzicato=14]="lefthandpizzicato",e[e.naturalharmonic=15]="naturalharmonic",e[e.snappizzicato=16]="snappizzicato",e[e.upbow=17]="upbow",e[e.downbow=18]="downbow",e[e.scoop=19]="scoop",e[e.plop=20]="plop",e[e.doit=21]="doit",e[e.falloff=22]="falloff",e[e.stress=23]="stress",e[e.unstress=24]="unstress",e[e.detachedlegato=25]="detachedlegato",e[e.otherarticulation=26]="otherarticulation",e[e.bend=27]="bend",e))(ct||{}),dt=(e=>(e[e.Undefined=-1]="Undefined",e[e.Up=0]="Up",e[e.Down=1]="Down",e[e.None=2]="None",e[e.Double=3]="Double",e))(dt||{}),ft=(e=>(e[e.MeasureBegin=0]="MeasureBegin",e[e.MeasureEnd=1]="MeasureEnd",e))(ft||{});class mt extends re{constructor(e,t,i,s,n=void 0){super(),this.CenteringXShift=0,this.label=e,this.boundingBox=new oe(this,n),this.label.fontHeight=t,this.label.textAlignment=i,this.rules=s,this.rules.MpatMode&&"TRIO"===this.label.text&&(this.label.fontFamily="Arial")}get Label(){return this.label}toString(){return`${this.label.text} (${this.boundingBox.RelativePosition.x},${this.boundingBox.RelativePosition.y})`}setLabelPositionAndShapeBorders(){var e,t;if(""===this.Label.text.trim())return;this.TextLines=[];const i=null!==(e=null===(t=this.rules)||void 0===t?void 0:t.LabelMarginBorderFactor)&&void 0!==e?e:.1,s=this.Label.text.split(/[\n\r]+/g),n=s.length;let r=0;for(let l=0;l0&&this.TextLines.length>1&&(o+=this.rules.SpacingBetweenTextLines*n/10);const a=this.PositionAndShape;switch(this.Label.textAlignment){case ce.CenterBottom:a.BorderTop=-o,a.BorderLeft=-r/2,a.BorderBottom=0,a.BorderRight=r/2;break;case ce.CenterCenter:a.BorderTop=-o/2,a.BorderLeft=-r/2,a.BorderBottom=o/2,a.BorderRight=r/2;break;case ce.CenterTop:a.BorderTop=0,a.BorderLeft=-r/2,a.BorderBottom=o,a.BorderRight=r/2;break;case ce.LeftBottom:a.BorderTop=-o,a.BorderLeft=0,a.BorderBottom=0,a.BorderRight=r;break;case ce.LeftCenter:a.BorderTop=-o/2,a.BorderLeft=0,a.BorderBottom=o/2,a.BorderRight=r;break;case ce.LeftTop:a.BorderTop=0,a.BorderLeft=0,a.BorderBottom=o,a.BorderRight=r;break;case ce.RightBottom:a.BorderTop=-o,a.BorderLeft=-r,a.BorderBottom=0,a.BorderRight=0;break;case ce.RightCenter:a.BorderTop=-o/2,a.BorderLeft=-r,a.BorderBottom=o/2,a.BorderRight=0;break;case ce.RightTop:a.BorderTop=0,a.BorderLeft=-r,a.BorderBottom=o,a.BorderRight=0}a.BorderMarginTop=a.BorderTop-o*i,a.BorderMarginLeft=a.BorderLeft-o*i,a.BorderMarginBottom=a.BorderBottom+o*i,a.BorderMarginRight=a.BorderRight+o*i}}class pt{constructor(e="",t=ce.CenterBottom,i=void 0,s=!0){this.IsCreditLabel=!1,this.isLyricText=!1,this.isNotRender=!1,this.text=e,this.print=s,this.textAlignment=t,this.font=i,this.fontFamily=void 0}set font(e){this.fontEnumValue=e,this.fontFamily=ge[e]}get font(){return this.fontEnumValue}ToString(){return this.text}}const gt={Grava:40,Largo:46,Lento:52,Adagio:56,Larghetto:60,Andante:66,Anderato:69,Andantino:69,Moderato:88,Allegretto:108,"Allegro Moderato":108,Allegro:132,Vivace:152,Vivo:160,Vivacissimo:168,Presto:184,Prestissimo:208},St=["纯律","纯律结束"],yt=["跳过下一个","b","#","§","º","X"],bt=["poco rit.","rall.","rit.","accel.","molto rit.","molto rall","lentando","poco accel.","calando","molto allargando","allargando","stringendo","poco a poco rit.","rit. poco a poco","Ritardando","Ritenuto","accelerate","poco a poco accel."],Mt="结束范围速度",vt=(e("G","a tempo"),[Mt]),Pt="速度 ",Et="仅文本速度 ";function Lt(e){return 0===e.indexOf(Pt)}function xt(e){return 0===e.indexOf(Et)}function Tt(e){return[...Object.keys(gt),...St,...vt,...yt].map((e=>e.trim().toLocaleUpperCase())).includes(e.toLocaleUpperCase().trim())}function wt(e){return[ce.CenterTop,ce.RightTop].includes(e)}var It=(e=>(e[e.Unused_first_Symbol=0]="Unused_first_Symbol",e[e.BLACK_HEAD=1]="BLACK_HEAD",e[e.UPWARDS_TAIL=2]="UPWARDS_TAIL",e[e.DOWNWARDS_TAIL=3]="DOWNWARDS_TAIL",e[e.UPWARDS_DOUBLE_TAIL=4]="UPWARDS_DOUBLE_TAIL",e[e.DOWNWARDS_DOUBLE_TAIL=5]="DOWNWARDS_DOUBLE_TAIL",e[e.UPWARDS_TRIPLE_TAIL=6]="UPWARDS_TRIPLE_TAIL",e[e.DOWNWARDS_TRIPLE_TAIL=7]="DOWNWARDS_TRIPLE_TAIL",e[e.UPWARDS_QUAD_TAIL=8]="UPWARDS_QUAD_TAIL",e[e.DOWNWARDS_QUAD_TAIL=9]="DOWNWARDS_QUAD_TAIL",e[e.ROUND_HEAD=10]="ROUND_HEAD",e[e.WHITE_HEAD=11]="WHITE_HEAD",e[e.G_CLEF=12]="G_CLEF",e[e.F_CLEF=13]="F_CLEF",e[e.C_CLEF=14]="C_CLEF",e[e.BREVE=15]="BREVE",e[e.BREVE_REST=16]="BREVE_REST",e[e.COMMON_TIME=17]="COMMON_TIME",e[e.CUT_TIME=18]="CUT_TIME",e[e.WHOLE_REST=19]="WHOLE_REST",e[e.HALF_REST=20]="HALF_REST",e[e.QUARTER_REST=21]="QUARTER_REST",e[e.EIGHTH_REST=22]="EIGHTH_REST",e[e.SIXTEENTH_REST=23]="SIXTEENTH_REST",e[e.THIRTYSECOND_REST=24]="THIRTYSECOND_REST",e[e.SIXTYFOURTH_REST=25]="SIXTYFOURTH_REST",e[e.FLAT=26]="FLAT",e[e.SHARP=27]="SHARP",e[e.NATURAL=28]="NATURAL",e[e.DOUBLE_FLAT=29]="DOUBLE_FLAT",e[e.DOUBLE_SHARP=30]="DOUBLE_SHARP",e[e.ZERO=31]="ZERO",e[e.ONE=32]="ONE",e[e.TWO=33]="TWO",e[e.THREE=34]="THREE",e[e.FOUR=35]="FOUR",e[e.FIVE=36]="FIVE",e[e.SIX=37]="SIX",e[e.SEVEN=38]="SEVEN",e[e.EIGHT=39]="EIGHT",e[e.NINE=40]="NINE",e[e.DOT=41]="DOT",e[e.FERMATA=42]="FERMATA",e[e.INVERTED_FERMATA=43]="INVERTED_FERMATA",e[e.SPICCATO=44]="SPICCATO",e[e.TENUTO=45]="TENUTO",e[e.MARCATO=46]="MARCATO",e[e.MARCATISSIMO=47]="MARCATISSIMO",e[e.INVERTED_MARCATISSIMO=48]="INVERTED_MARCATISSIMO",e[e.P=49]="P",e[e.F=50]="F",e[e.S=51]="S",e[e.Z=52]="Z",e[e.M=53]="M",e[e.R=54]="R",e[e.SEGNO=55]="SEGNO",e[e.CODA=56]="CODA",e[e.DRUM_CLEF=57]="DRUM_CLEF",e[e.G_CLEF_SUB8=58]="G_CLEF_SUB8",e[e.G_CLEF_SUPER8=59]="G_CLEF_SUPER8",e[e.G_CLEF_SUB15=60]="G_CLEF_SUB15",e[e.G_CLEF_SUPER15=61]="G_CLEF_SUPER15",e[e.F_CLEF_SUB8=62]="F_CLEF_SUB8",e[e.F_CLEF_SUPER8=63]="F_CLEF_SUPER8",e[e.F_CLEF_SUB15=64]="F_CLEF_SUB15",e[e.F_CLEF_SUPER15=65]="F_CLEF_SUPER15",e[e.DOWN_BOW=66]="DOWN_BOW",e[e.MORDENT=67]="MORDENT",e[e.INVERTED_MORDENT=68]="INVERTED_MORDENT",e[e.TURN=69]="TURN",e[e.INVERTED_TURN=70]="INVERTED_TURN",e[e.LEFTHAND_PIZZICATO=71]="LEFTHAND_PIZZICATO",e[e.RELEASE_PED=72]="RELEASE_PED",e[e.ENGAGE_PED=73]="ENGAGE_PED",e[e.VA8=74]="VA8",e[e.VB8=75]="VB8",e[e.TRILL=76]="TRILL",e[e.MA15=77]="MA15",e[e.MB15=78]="MB15",e[e.HIGH=79]="HIGH",e[e.PLAY=80]="PLAY",e[e.MIC=81]="MIC",e[e.SNAP_PIZZICATO=82]="SNAP_PIZZICATO",e[e.NATURAL_HARMONIC=83]="NATURAL_HARMONIC",e[e.EditPen=84]="EditPen",e[e.PEDAL_BRACKET=85]="PEDAL_BRACKET",e[e.PEDAL_MIXED=86]="PEDAL_MIXED",e[e.PEDAL_SYMBOL=87]="PEDAL_SYMBOL",e))(It||{}),At=(e=>(e[e.Normal=0]="Normal",e[e.Disabled=1]="Disabled",e[e.Selected=2]="Selected",e[e.Clickable=3]="Clickable",e[e.PlaybackSymbols=4]="PlaybackSymbols",e[e.FollowSymbols=5]="FollowSymbols",e[e.QFeedbackNotFound=6]="QFeedbackNotFound",e[e.QFeedbackOk=7]="QFeedbackOk",e[e.QFeedbackPerfect=8]="QFeedbackPerfect",e[e.Debug1=9]="Debug1",e[e.Debug2=10]="Debug2",e[e.Debug3=11]="Debug3",e))(At||{}),Rt=(e=>(e[e.Following=0]="Following",e[e.Midi=1]="Midi",e[e.Manual=2]="Manual",e))(Rt||{});class Nt{}class Ct{constructor(e,t){this.drawableBoundingBoxElement="None",this.skyLineVisible=!1,this.bottomLineVisible=!1,this.needSpecialArrTs=[],this.phonicScoreMode=Rt.Manual,this.textMeasurer=e,this.splitScreenLineColor=-1,this.drawingParameters=t,this.rules=t.Rules}set Mode(e){this.phonicScoreMode=e}drawSheet(e){if(this.graphicalMusicSheet=e,this.rules=e.ParentMusicSheet.Rules,this.drawSplitScreenLine(),this.drawingParameters.drawCursors)for(const i of e.Cursors){if(!i)continue;const e=new oe(i);e.AbsolutePosition=i.Start,e.BorderBottom=i.End.y-i.Start.y,e.BorderRight=i.Width/2,e.BorderLeft=-i.Width/2,this.isVisible(e)&&this.drawLineAsVerticalRectangle(i,G.Cursor)}this.drawingParameters.drawScrollIndicator&&this.drawScrollIndicator();const t=Math.min(this.graphicalMusicSheet.MusicPages.length,this.rules.MaxPageToDrawNumber);for(let i=0;ie[0])).filter(Boolean))||[],i=[];let n=!1;for(let r=0;re.x-t.x)))||void 0===m||null===(p=m[0])||void 0===p?void 0:p.measure;break}}}catch(w){}let n=0;var b,M;if(s)n=(null===(b=s.stave)||void 0===b?void 0:b.end_x)||0;else n=(null===(M=o.sourceNote.SourceMeasure.VerticalMeasureList[0])||void 0===M?void 0:M.getVFStave()).end_x;const r=0;l.ScreenPosition.x=n,l.ScreenPosition.y=0===t?10*(e.PositionAndShape.Parent.AbsolutePosition.y-3-r):10*t}const v=["C","G","D","A","E","B","F#","C#","G#","F","Bb","Eb","Ab","Db","Gb","Cb","Fb","D#","A#","E#"];v.includes(a.text)&&(l.ScreenPosition.y=10*(e.PositionAndShape.Parent.AbsolutePosition.y+e.PositionAndShape.Parent.BorderTop+e.PositionAndShape.Parent.BorderMarginTop)),["play","listen"].includes(a.text.toLocaleLowerCase())&&a.textAlignment===ce.LeftBottom&&(l.ScreenPosition.y=10*(e.PositionAndShape.Parent.AbsolutePosition.y-1+e.PositionAndShape.Parent.BorderBottom));const P=["ffp","p-f","sfzp","szf","sffzp"];for(let I=0;I0&&(wt(e.Label.textAlignment)||[ce.CenterBottom].includes(e.Label.textAlignment))){let t=-1,i=!1;for(const s of(null==u?void 0:u.AbstractExpressions)||[]){var L,x;if(s.Label===e?t=null==s||null===(x=s.parentMeasure)||void 0===x?void 0:x.measureListIndex:null!==(L=s.expression)&&void 0!==L&&L.TempoInBpm&&(i=s.expression.TempoInBpm>0),i&&t>-1){l.ScreenPosition.y-=40;break}}}const T=!/^\d+$/.test(e.Label.text);(!i&&!e.Label.isNotRender||T)&&this.renderLabel(e,t,l)}calculateLabel(e){const t=new Nt,i=e.Label;t.ScreenPosition=this.applyScreenTransformation(e.PositionAndShape.AbsolutePosition),t.FontHeightInPixel=this.calculatePixelDistance(i.fontHeight);const s=this.calculatePixelDistance(e.PositionAndShape.Size.width);switch(t.BitmapWidth=Math.ceil(s),t.BitmapHeight=e.TextLines?Math.ceil(t.FontHeightInPixel*(.2+e.TextLines.length)):10,i.textAlignment){case ce.LeftTop:break;case ce.LeftCenter:t.ScreenPosition.y-=t.BitmapHeight/2;break;case ce.LeftBottom:t.ScreenPosition.y-=t.BitmapHeight;break;case ce.CenterTop:t.ScreenPosition.x-=t.BitmapWidth/2;break;case ce.CenterCenter:t.ScreenPosition.x-=t.BitmapWidth/2,t.ScreenPosition.y-=t.BitmapHeight/2;break;case ce.CenterBottom:t.ScreenPosition.x-=t.BitmapWidth/2,t.ScreenPosition.y-=t.BitmapHeight,"筒音作5"===i.text&&"jianpu"===this.rules.DYMusicScoreType&&(t.ScreenPosition.x=80);break;case ce.RightTop:t.ScreenPosition.x-=t.BitmapWidth;break;case ce.RightCenter:t.ScreenPosition.x-=t.BitmapWidth,t.ScreenPosition.y-=t.BitmapHeight/2;break;case ce.RightBottom:t.ScreenPosition.x-=t.BitmapWidth,t.ScreenPosition.y-=t.BitmapHeight;break;default:throw new y("")}const n=e.PositionAndShape.Parent.DataObject,r=[1,3,7,9,15,20,22,24,28,30,36,41];var o,a;this.rules.DYMusicScoreId&&"1722157850347765762"===this.rules.DYMusicScoreId&&("."===i.text&&(t.ScreenPosition.x=142,t.ScreenPosition.y=134),"T"===i.text&&(this.needSpecialArrTs.push(t),1===(null==n||null===(o=n.measures)||void 0===o||null===(a=o[0])||void 0===a?void 0:a.MeasureNumber)?t.ScreenPosition.y+=20:t.ScreenPosition.y-=20));for(let l in this.needSpecialArrTs)r.includes(Number(l))&&(this.needSpecialArrTs[l].ScreenPosition.x-=20);return t}applyScreenTransformations(e){const t=[];for(const i of e)t.push(this.applyScreenTransformation(i));return t}drawSplitScreenLine(){}renderRectangle(e,t,i,s=void 0,n=1){throw new Error("not implemented")}drawScrollIndicator(){}drawSelectionStartSymbol(e){}drawSelectionEndSymbol(e){}renderLabel(e,t,i){throw new Error("not implemented")}renderSystemToScreen(e,t,i){}drawSkyLine(e){}drawBottomLine(e){}drawInstrumentBrace(e,t){}drawGroupBracket(e,t){}isVisible(e){return!0}drawMusicSystem(e){const t=this.getSystemAbsBoundingRect(e),i=this.getSytemBoundingBoxInPixels(t);this.drawMusicSystemComponents(e,i,t)}getSytemBoundingBoxInPixels(e){const t=this.applyScreenTransformationForRect(e);return t.x=Math.round(t.x),t.y=Math.round(t.y),t}getSystemAbsBoundingRect(e){const t=e.PositionAndShape.BoundingRectangle;return new ie(e.PositionAndShape.AbsolutePosition.x+e.PositionAndShape.BorderLeft-1,e.PositionAndShape.AbsolutePosition.y+e.PositionAndShape.BorderTop-1,t.width+6,t.height+2)}drawMusicSystemComponents(e,t,i){const s=this.graphicalMusicSheet.SelectionStartSymbol,n=this.graphicalMusicSheet.SelectionEndSymbol;this.drawingParameters.drawSelectionStartSymbol&&void 0!==s&&this.isVisible(s.PositionAndShape)&&this.drawSelectionStartSymbol(s),this.drawingParameters.drawSelectionEndSymbol&&void 0!==n&&this.isVisible(n.PositionAndShape)&&this.drawSelectionEndSymbol(n);for(const a of e.StaffLines)this.drawStaffLine(a),this.rules.RenderLyrics&&(a.LyricsDashes.length>0&&this.drawDashes(a.LyricsDashes),a.LyricLines.length>0&&this.drawLyricLines(a.LyricLines,a));for(const a of e.SystemLines)this.drawSystemLineObject(a);if(this.rules.RenderSystemLabelsAfterFirstPage||e.Parent===e.Parent.Parent.MusicPages[0])for(const a of e.Labels)a.SVGNode=this.drawLabel(a,G.Notes);const r=this.graphicalMusicSheet.ParentMusicSheet.Instruments,o=r.filter((e=>e.Visible)).length;for(const a of e.InstrumentBrackets)this.drawInstrumentBrace(a,e);if(r.length>0)if(o>1)for(const a of e.GroupBrackets)this.drawGroupBracket(a,e);else for(const a of e.GroupBrackets)a.Visible=!1;if(!this.leadSheet)for(const a of e.MeasureNumberLabels)a.SVGNode=this.drawLabel(a,G.Notes);for(const a of e.StaffLines)this.drawStaffLineSymbols(a);this.drawingParameters.drawMarkedAreas&&this.drawMarkedAreas(e)}activateSystemRendering(e,t,i,s){return!0}drawSystemLineObject(e){}drawStaffLine(e){for(const t of e.Measures)this.drawMeasure(t),t.parentSourceMeasure&&(t.parentSourceMeasure.WasRendered=!0);this.rules.RenderLyrics&&e.LyricsDashes.length>0&&this.drawDashes(e.LyricsDashes),this.drawOctaveShifts(e),this.drawPedals(e),this.drawWavyLines(e),this.drawExpressions(e),this.skyLineVisible&&this.drawSkyLine(e),this.bottomLineVisible&&this.drawBottomLine(e)}drawLyricLines(e,t){t.LyricLines.forEach((e=>{e.Start.y+=t.PositionAndShape.AbsolutePosition.y,e.End.y+=t.PositionAndShape.AbsolutePosition.y,e.Start.x+=t.PositionAndShape.AbsolutePosition.x,e.End.x+=t.PositionAndShape.AbsolutePosition.x,this.drawGraphicalLine(e,this.rules.LyricUnderscoreLineWidth,e.colorHex)}))}drawExpressions(e){}drawGraphicalLine(e,t,i="black"){return this.drawLine(e.Start,e.End,i,t)}drawLine(e,t,i="#FF0000FF",s){}drawDashes(e){e.forEach((e=>{var t;e.SVGNode=this.drawLabel(e,G.Notes),null===(t=e.SVGNode)||void 0===t||t.classList.add("dash")}))}drawOctaveShifts(e){}drawStaffLines(e){if(e.StaffLines){const t=e.PositionAndShape.AbsolutePosition;for(let i=0;i<5;i++)this.drawLineAsHorizontalRectangleWithOffset(e.StaffLines[i],t,G.Notes)}}drawSymbol(e,t,i,s=1,n=G.Notes){}get leadSheet(){return this.graphicalMusicSheet.LeadSheet}set leadSheet(e){this.graphicalMusicSheet.LeadSheet=e}drawPage(e){if(this.isVisible(e.PositionAndShape)){for(const t of e.MusicSystems)this.isVisible(t.PositionAndShape)&&this.drawMusicSystem(t);if(e===e.Parent.MusicPages[0])for(const t of e.Labels)t.SVGNode=this.drawLabel(t,G.Notes);this.drawableBoundingBoxElement&&this.drawBoundingBoxes(e.PositionAndShape,0,this.drawableBoundingBoxElement)}}drawBoundingBoxes(e,t=0,i="all"){const s=e.DataObject.constructor.name;let n=!1;"all"===i&&(n=!0),(n||s===i)&&this.drawBoundingBox(e,void 0,!0,s,t),t++,e.ChildElements.forEach((e=>this.drawBoundingBoxes(e,t,i)))}drawBoundingBox(e,t=void 0,i=!1,s=void 0,n=0){let r=new ie(e.AbsolutePosition.x+e.BorderMarginLeft,e.AbsolutePosition.y+e.BorderMarginTop,e.BorderMarginRight-e.BorderMarginLeft,e.BorderMarginBottom-e.BorderMarginTop);i&&(this.drawLineAsHorizontalRectangle(new X(new z(e.AbsolutePosition.x-1,e.AbsolutePosition.y),new z(e.AbsolutePosition.x+1,e.AbsolutePosition.y),.1,O.BaseWritingColor,t),n-1),this.drawLineAsVerticalRectangle(new X(new z(e.AbsolutePosition.x,e.AbsolutePosition.y-1),new z(e.AbsolutePosition.x,e.AbsolutePosition.y+1),.1,O.BaseWritingColor,t),n-1)),r=this.applyScreenTransformationForRect(r);const o=this.renderRectangle(r,G.Background,n,t,.5);if(s){const e=new pt(s),t=new Nt;t.BitmapWidth=r.width,t.BitmapHeight=r.height,t.FontHeightInPixel=r.height,t.ScreenPosition=new z(r.x,r.y+12),this.renderLabel(new mt(e,.8,ce.CenterCenter,this.rules),n,t)}return o}drawMarkedAreas(e){for(const t of e.GraphicalMarkedAreas)t&&(t.systemRectangle&&this.drawRectangle(t.systemRectangle,G.Background),t.settings&&(t.settings.SVGNode=this.drawLabel(t.settings,G.Comment)),t.labelRectangle&&this.drawRectangle(t.labelRectangle,G.Background),t.label&&(t.label.SVGNode=this.drawLabel(t.label,G.Comment)))}drawStaffLineSymbols(e){const t=e.ParentStaff.ParentInstrument,i=e.PositionAndShape.AbsolutePosition.x,s=e.PositionAndShape.AbsolutePosition.y+2,n=e.PositionAndShape.BorderRight;t.highlight&&this.drawingParameters.drawHighlights&&this.drawLineAsHorizontalRectangle(new X(new z(i,s),new z(i+n,s),4,O.Highlighted),G.Highlight);let r=At.Disabled,o=It.PLAY,a=this.drawingParameters.drawActivitySymbols;switch(this.phonicScoreMode){case Rt.Midi:o=It.PLAY,this.midiPlaybackAvailable&&e.ParentStaff.audible&&(r=At.PlaybackSymbols);break;case Rt.Following:o=It.MIC,e.ParentStaff.following&&(r=At.FollowSymbols);break;default:a=!1}if(a){const e=new z(i+n+2,s);this.drawSymbol(o,r,e)}if(this.drawingParameters.drawErrors)for(const l of e.Measures){const e=l.PositionAndShape,t=e.AbsolutePosition.x,i=e.AbsolutePosition.y+2;l.hasError&&this.graphicalMusicSheet.ParentMusicSheet.DrawErroneousMeasures&&this.drawLineAsHorizontalRectangle(new X(new z(t,i),new z(t+e.BorderRight,i),4,O.ErrorUnderlay),G.MeasureError)}}}class Bt{constructor(e){this.fontSize=20,this.fontSizeStandard=this.fontSize;const t=document.createElement("canvas");this.context=t.getContext("2d"),this.rules=e}computeTextWidthToHeightRatio(e,t,i,s=void 0,n=this.fontSize){return this.context.font=Jt.font(n,i,t,this.rules,s),this.context.measureText(e).width/n}setFontSize(e=this.fontSizeStandard){return this.fontSize=e,e}}class Dt extends ne{constructor(e,t,i){super(),this.expression=t,this.parentMeasure=i,this.boundingBox=new oe(this,e.PositionAndShape),this.parentStaffLine=e,this.parentStaffLine.AbstractExpressions.push(this),this.rules=e.ParentMusicSystem.rules}get Label(){return this.label}get ParentStaffLine(){return this.parentStaffLine}get SourceExpression(){return this.expression}get Placement(){return this.expression.Placement}}class Vt extends Dt{constructor(e,t){super(t.PositionAndShape.Parent.DataObject,e,e.parentMeasure),this.label=t}get GraphicalLabel(){return this.label}updateSkyBottomLine(){}}class kt extends Dt{constructor(e,t,i){super(t,e,i.parentSourceMeasure),this.mInstantaneousDynamicExpression=e,this.mMeasure=i}updateSkyBottomLine(){const e=this.parentStaffLine.SkyBottomLineCalculator,t=this.PositionAndShape.RelativePosition.x+this.PositionAndShape.BorderMarginLeft,i=this.PositionAndShape.RelativePosition.x+this.PositionAndShape.BorderMarginRight;let n=0;switch(this.Placement){case d.Above:n=this.PositionAndShape.RelativePosition.y+this.PositionAndShape.BorderMarginTop,e.updateSkyLineInRange(t,i,n);break;case d.Below:n=this.PositionAndShape.RelativePosition.y+this.PositionAndShape.BorderMarginBottom,e.updateBottomLineInRange(t,i,n);break;default:s.error("Placement for GraphicalInstantaneousDynamicExpression is unknown")}}}class Ft extends Dt{constructor(e,t,i){super(t,e,i),this.lines=[],this.isSplittedPart=!1,this.notToBeRemoved=!1}get StartMeasure(){return this.startMeasure}set StartMeasure(e){this.startMeasure=e}get EndMeasure(){return this.endMeasure}set EndMeasure(e){this.endMeasure=e}get EndStaffLine(){return this.endMeasure?this.endMeasure.ParentStaffLine:void 0}get IsSplittedPart(){return this.isSplittedPart}set IsSplittedPart(e){this.isSplittedPart=e}get IsVerbal(){return this.ContinuousDynamic.Label&&this.ContinuousDynamic.Label.length>0}get NotToBeRemoved(){return this.notToBeRemoved}set NotToBeRemoved(e){this.notToBeRemoved=e}get Lines(){return this.lines}get ContinuousDynamic(){return this.SourceExpression}updateSkyBottomLine(){const e=this.parentStaffLine.SkyBottomLineCalculator,t=this.IsVerbal?this.label.PositionAndShape.RelativePosition.x+this.label.PositionAndShape.BorderMarginLeft:0,i=this.IsVerbal?this.label.PositionAndShape.RelativePosition.x+this.label.PositionAndShape.BorderMarginRight:0;var n;switch(!this.IsSoftAccent&&!this.IsVerbal&&this.lines.length<2&&s.warn("Not enough lines for SkyBottomLine calculation"),this.IsVerbal||this.ContinuousDynamic.DynamicType!==p.crescendo&&this.ContinuousDynamic.DynamicType!==p.diminuendo&&s.warn("GraphicalContinuousDynamicExpression.updateSkyBottomLine(): unhandled continuous dynamic type. start measure: "+(null===(n=this.startMeasure)||void 0===n?void 0:n.MeasureNumber)),this.Placement){case d.Above:if(this.IsSoftAccent)e.updateSkyLineWithWedge(this.lines[0].Start,this.lines[0].End),e.updateSkyLineWithWedge(this.lines[2].End,this.lines[2].Start),e.updateSkyLineWithLine(this.lines[0].End,this.lines[2].End,this.lines[0].End.y);else if(this.IsVerbal){const s=this.label.PositionAndShape.BorderMarginTop+this.label.PositionAndShape.RelativePosition.y;e.updateSkyLineInRange(t,i,s)}else this.ContinuousDynamic.DynamicType===p.crescendo?e.updateSkyLineWithWedge(this.lines[0].Start,this.lines[0].End):this.ContinuousDynamic.DynamicType===p.diminuendo&&e.updateSkyLineWithWedge(this.lines[0].End,this.lines[0].Start);break;case d.Below:if(this.IsVerbal){const s=this.label.PositionAndShape.BorderMarginBottom+this.label.PositionAndShape.RelativePosition.y;e.updateBottomLineInRange(t,i,s)}else this.ContinuousDynamic.DynamicType===p.crescendo?e.updateBottomLineWithWedge(this.lines[1].Start,this.lines[1].End):this.ContinuousDynamic.DynamicType===p.diminuendo&&e.updateBottomLineWithWedge(this.lines[1].End,this.lines[1].Start);break;default:s.error("Placement for GraphicalContinuousDynamicExpression is unknown")}}createCrescendoLines(e,t,i,s=this.rules.WedgeOpeningLength,n=this.rules.WedgeLineWidth){const r=new z(e,i),o=new z(t,i-s/2),a=new z(t,i+s/2);this.addWedgeLines(r,o,a,n)}createFirstHalfCrescendoLines(e,t,i,s=this.rules.WedgeMeasureEndOpeningLength,n=this.rules.WedgeLineWidth){const r=new z(e,i),o=new z(t,i-s/2),a=new z(t,i+s/2);this.addWedgeLines(r,o,a,n)}createSecondHalfCrescendoLines(e,t,i,s=this.rules.WedgeMeasureBeginOpeningLength,n=this.rules.WedgeOpeningLength,r=this.rules.WedgeLineWidth){const o=new z(e,i-s/2),a=new z(e,i+s/2),l=new z(t,i-n/2),h=new z(t,i+n/2);this.addDoubleLines(o,l,a,h,r)}recalculateCrescendoLines(e,t,i){const s=Math.abs(this.lines[0].Start.y-this.lines[1].Start.y)>1e-4;this.lines.clear(),s?this.createSecondHalfCrescendoLines(e,t,i):this.isSplittedPart?this.createFirstHalfCrescendoLines(e,t,i):this.createCrescendoLines(e,t,i)}createDiminuendoLines(e,t,i,s=this.rules.WedgeOpeningLength,n=this.rules.WedgeLineWidth){const r=new z(e,i-s/2),o=new z(e,i+s/2),a=new z(t,i);this.addWedgeLines(a,r,o,n)}createFirstHalfDiminuendoLines(e,t,i,s=this.rules.WedgeOpeningLength,n=this.rules.WedgeMeasureEndOpeningLength,r=this.rules.WedgeLineWidth){const o=new z(e,i-s/2),a=new z(e,i+s/2),l=new z(t,i-n/2),h=new z(t,i+n/2);this.addDoubleLines(o,l,a,h,r)}createSecondHalfDiminuendoLines(e,t,i,s=this.rules.WedgeMeasureBeginOpeningLength,n=this.rules.WedgeLineWidth){const r=new z(e,i-s/2),o=new z(e,i+s/2),a=new z(t,i);this.addWedgeLines(a,r,o,n)}recalculateDiminuendoLines(e,t,i){const s=Math.abs(this.lines[0].End.y-this.lines[1].End.y)>1e-4;this.lines.clear(),s?this.createFirstHalfDiminuendoLines(e,t,i):this.isSplittedPart?this.createSecondHalfDiminuendoLines(e,t,i):this.createDiminuendoLines(e,t,i)}createFirstHalfLines(e,t,i,s=this.rules.WedgeOpeningLength,n=this.rules.WedgeMeasureEndOpeningLength,r=this.rules.WedgeLineWidth){this.ContinuousDynamic.DynamicType===p.crescendo?this.createFirstHalfCrescendoLines(e,t,i,n,r):this.ContinuousDynamic.DynamicType===p.diminuendo&&this.createFirstHalfDiminuendoLines(e,t,i,s,n,r)}createSecondHalfLines(e,t,i,s=this.rules.WedgeMeasureBeginOpeningLength,n=this.rules.WedgeOpeningLength,r=this.rules.WedgeLineWidth){this.ContinuousDynamic.DynamicType===p.crescendo?this.createSecondHalfCrescendoLines(e,t,i,s,n,r):this.ContinuousDynamic.DynamicType===p.diminuendo&&this.createSecondHalfDiminuendoLines(e,t,i,s,r)}createLines(e,t,i,s=this.rules.WedgeOpeningLength,n=this.rules.WedgeLineWidth){this.ContinuousDynamic.DynamicType===p.crescendo?this.createCrescendoLines(e,t,i,s,n):this.ContinuousDynamic.DynamicType===p.diminuendo&&this.createDiminuendoLines(e,t,i,s,n)}calcPsi(){this.IsVerbal?this.PositionAndShape.calculateBoundingBox():(this.PositionAndShape.RelativePosition=this.lines[0].Start,this.PositionAndShape.BorderMarginTop=this.lines[0].End.y-this.lines[0].Start.y,this.PositionAndShape.BorderMarginBottom=this.lines[1].End.y-this.lines[1].Start.y,this.PositionAndShape.Center.y=(this.PositionAndShape.BorderMarginTop+this.PositionAndShape.BorderMarginBottom)/2,this.IsSoftAccent?(this.PositionAndShape.BorderMarginLeft=0,this.PositionAndShape.BorderMarginRight=this.lines[3].Start.x-this.lines[0].Start.x):this.ContinuousDynamic.DynamicType===p.crescendo?(this.PositionAndShape.BorderMarginLeft=0,this.PositionAndShape.BorderMarginRight=this.lines[0].End.x-this.lines[0].Start.x):(this.PositionAndShape.BorderMarginLeft=this.lines[0].End.x-this.lines[0].Start.x,this.PositionAndShape.BorderMarginRight=0))}cleanUp(){this.lines.clear()}shiftYPosition(e){this.IsVerbal?(this.PositionAndShape.RelativePosition.y+=e,this.PositionAndShape.calculateBoundingBox()):(this.lines[0].Start.y+=e,this.lines[0].End.y+=e,this.lines[1].End.y+=e)}squeeze(e){this.IsVerbal||Math.abs(this.lines[0].End.x-this.lines[0].Start.x)0?this.lines[0].Start.x+=e:(this.lines[0].End.x+=e,this.lines[1].End.x+=e):e<0?this.lines[0].Start.x+=e:(this.lines[0].End.x+=e,this.lines[1].End.x+=e),this.calcPsi())}addWedgeLines(e,t,i,s){const n=new X(e,t,s),r=new X(e,i,s);this.rules.DefaultColorMusic&&(n.colorHex=this.rules.DefaultColorMusic,r.colorHex=this.rules.DefaultColorMusic),this.lines.push(n),this.lines.push(r)}addDoubleLines(e,t,i,s,n){const r=new X(e,t,n),o=new X(i,s,n);this.rules.DefaultColorMusic&&(r.colorHex=this.rules.DefaultColorMusic,o.colorHex=this.rules.DefaultColorMusic),this.lines.push(r),this.lines.push(o)}}class Ot{constructor(e=A.default,t){this.drawCursors=!0,this.drawTitle=!0,this.drawSubtitle=!0,this.drawLyricist=!0,this.drawComposer=!0,this.drawCopyright=!1,this.drawCredits=!0,this.drawPartNames=!0,this.fingeringPosition=d.Left,this.drawHiddenNotes=!1,this.rules=t,this.rules||(this.rules=new xe),this.DrawingParametersEnum=e}set DrawingParametersEnum(e){switch(this.drawingParametersEnum=e,e){case A.allon:this.setForAllOn();break;case A.thumbnail:this.setForThumbnail();break;case A.leadsheet:this.setForLeadsheet();break;case A.compact:this.setForCompactMode();break;case A.compacttight:this.setForCompactTightMode();break;case A.default:default:this.setForDefault()}}get DrawingParametersEnum(){return this.drawingParametersEnum}setForAllOn(){this.drawHighlights=!0,this.drawErrors=!0,this.drawSelectionStartSymbol=!0,this.drawSelectionEndSymbol=!0,this.drawCursors=!0,this.drawActivitySymbols=!0,this.drawScrollIndicator=!0,this.drawAnnotations=!0,this.drawComments=!0,this.drawMarkedAreas=!0,this.DrawTitle=!0,this.DrawSubtitle=!0,this.DrawComposer=!0,this.DrawLyricist=!0,this.drawCredits=!0,this.DrawPartNames=!0,this.drawHiddenNotes=!0,this.rules.CompactMode=!1}setForDefault(){this.rules.loadDefaultValues(),this.setForAllOn(),this.drawHiddenNotes=!1}setForThumbnail(){this.drawHighlights=!1,this.drawErrors=!1,this.drawSelectionStartSymbol=!1,this.drawSelectionStartSymbol=!1,this.drawCursors=!1,this.drawActivitySymbols=!1,this.drawScrollIndicator=!1,this.drawAnnotations=!0,this.drawComments=!0,this.drawMarkedAreas=!0,this.drawHiddenNotes=!1}setForCompactMode(){this.rules.CompactMode=!0,this.DrawCredits=!1,this.drawHiddenNotes=!1}setForCompactTightMode(){this.setForCompactMode(),this.DrawPartNames=!1,this.rules.VoiceSpacingMultiplierVexflow=.65,this.rules.VoiceSpacingAddendVexflow=2,this.rules.MinSkyBottomDistBetweenStaves=1,this.rules.MinSkyBottomDistBetweenSystems=1,this.rules.BetweenStaffDistance=2.5,this.rules.StaffDistance=3.5,this.rules.MinimumDistanceBetweenSystems=1,this.rules.PageBottomMargin=0,this.rules.PageLeftMargin=2,this.rules.PageRightMargin=2}setForLeadsheet(){this.drawHighlights=!1,this.drawErrors=!1,this.drawSelectionStartSymbol=!0,this.drawSelectionEndSymbol=!0,this.drawCursors=!0,this.drawActivitySymbols=!1,this.drawScrollIndicator=!0,this.drawAnnotations=!0,this.drawComments=!0,this.drawMarkedAreas=!0}get DrawCredits(){return this.drawCredits}set DrawCredits(e){this.drawCredits=e,this.DrawComposer=e,this.DrawTitle=e,this.DrawSubtitle=e,this.DrawLyricist=e,this.DrawCopyright=e}get DrawTitle(){return this.drawTitle}set DrawTitle(e){this.drawTitle=e,this.rules.RenderTitle=e,e||(this.DrawSubtitle=!1)}get DrawSubtitle(){return this.drawSubtitle}set DrawSubtitle(e){this.drawSubtitle=e,this.rules.RenderSubtitle=e,e&&(this.DrawTitle=!0)}get DrawComposer(){return this.drawComposer}set DrawComposer(e){this.drawComposer=e,this.rules.RenderComposer=e}get DrawLyricist(){return this.drawLyricist}set DrawLyricist(e){this.drawLyricist=e,this.rules.RenderLyricist=e}get DrawCopyright(){return this.drawCopyright}set DrawCopyright(e){this.drawCopyright=e,this.rules.RenderCopyright=e}get DrawPartNames(){return this.drawPartNames}set DrawPartNames(e){this.drawPartNames=e,this.rules.RenderPartNames=e,this.rules.RenderPartNames||(this.rules.RenderPartAbbreviations=!1)}get FingeringPosition(){return this.fingeringPosition}set FingeringPosition(e){this.fingeringPosition=e,this.rules.FingeringPosition=e}get Rules(){return this.rules}set Rules(e){this.rules=e}}class _t extends Dt{constructor(e,t,i,s,n=void 0){super(e,new c(i),s),this.label=t,this.sourceMultiExpression=n}updateSkyBottomLine(){const e=this.parentStaffLine.SkyBottomLineCalculator,t=this.label.PositionAndShape.RelativePosition.x+this.label.PositionAndShape.BorderMarginLeft,i=this.label.PositionAndShape.RelativePosition.x+this.label.PositionAndShape.BorderMarginRight;switch(this.Placement){case d.Above:const n=this.label.PositionAndShape.BorderMarginTop+this.label.PositionAndShape.RelativePosition.y;e.updateSkyLineInRange(t,i,n);break;case d.Below:const r=this.label.PositionAndShape.BorderMarginBottom+this.label.PositionAndShape.RelativePosition.y;e.updateBottomLineInRange(t,i,r);break;default:s.error("Placement for GraphicalUnknownExpression is unknown")}}}const Gt=n.Flow;class Wt{getInnerElement(){return this.inner}getCanvas(){return this.canvas}getRenderElement(){let e=this.canvas;return this.getVexflowBackendType()===Gt.Renderer.Backends.CANVAS&&(e=this.inner),e}getRenderer(){return this.renderer}removeAllChildrenFromContainer(e){for(;0!==e.children.length;)e.removeChild(e.children.item(0))}removeFromContainer(e){const t=this.getRenderElement();for(let i=0;ie.y))),i=Math.min(...e.map((e=>e.y)));if(t-i>100){const i=t-100;e.forEach((e=>{t-e.y>100&&(e.y=i)}))}}const t=this.ctx.openGroup("curve");return this.ctx.beginPath(),this.ctx.moveTo(e[0].x,e[0].y),this.ctx.bezierCurveTo(e[1].x,e[1].y,e[2].x,e[2].y,e[3].x,e[3].y),this.ctx.lineTo(e[7].x,e[7].y),this.ctx.bezierCurveTo(e[6].x,e[6].y,e[5].x,e[5].y,e[4].x,e[4].y),this.ctx.lineTo(e[0].x,e[0].y),this.ctx.closePath(),this.ctx.fill(),this.ctx.closeGroup(),t}renderPath(e,t=!0,i){const s=this.ctx.openGroup("path",i);let n;this.ctx.beginPath();for(const r of e)n?this.ctx.lineTo(r.x,r.y):(this.ctx.moveTo(r.x,r.y),n=r);return this.ctx.closePath(),t?this.ctx.fill():this.ctx.stroke(),this.ctx.stroke(),this.ctx.closeGroup(),s}export(){const e=this.ctx.svg.cloneNode(!0),t=document.implementation.createDocumentType("svg","-//W3C//DTD SVG 1.1//EN","http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"),i=document.implementation.createDocument("http://www.w3.org/2000/svg","svg",t);i.replaceChild(e,i.documentElement);const s=(new XMLSerializer).serializeToString(i),n=document.createElement("a");n.href="data:image/svg+xml; charset=utf8, "+encodeURIComponent(s.replace(/>\n\r<")),n.download="opensheetmusicdisplay_download.svg",n.innerHTML=window.location.href+"/download",document.body.appendChild(n)}}const zt=10;class Ht extends Ct{constructor(e=new Ot){super(new Bt(e.Rules),e),this.backends=[],this.zoom=1,this.pageIdx=0,this.getDotId=(e,t)=>t?String(e.Label.PositionAndShape.RelativePosition[t]):String(e.Label.PositionAndShape.RelativePosition.x)+String(e.Label.PositionAndShape.RelativePosition.y),this.hasDot=(e,t,i,s)=>{const n=t||Object.values(s);for(const r of n){if(i)return e.x===r.x&&e.y===r.y;if(e.x===r.x)return!0}return!1}}get Zoom(){return this.zoom}get Backends(){return this.backends}initializeBackendForPage(e){this.backend=this.backends[e.PageNumber-1]}drawSheet(e){var t,i,s;"gonville"===this.rules.DefaultVexFlowNoteFont&&(n.Flow.DEFAULT_FONT_STACK=[null===(t=n.Flow.Fonts)||void 0===t?void 0:t.Gonville,null===(i=n.Flow.Fonts)||void 0===i?void 0:i.Bravura,null===(s=n.Flow.Fonts)||void 0===s?void 0:s.Custom]),n.Flow.STAVE_LINE_THICKNESS=this.rules.StaffLineWidth*zt,n.Flow.STEM_WIDTH=this.rules.StemWidth*zt,n.Flow.DEFAULT_NOTATION_FONT_SCALE=this.rules.VexFlowDefaultNotationFontScale,n.Flow.DEFAULT_TAB_FONT_SCALE=this.rules.VexFlowDefaultTabFontScale,this.pageIdx=0;for(const n of e.MusicPages){if(n.PageNumber>this.rules.MaxPageToDrawNumber)break;const e=this.backends[this.pageIdx];e.graphicalMusicPage=n,e.scale(this.zoom),this.pageIdx+=1}this.pageIdx=0,this.backend=this.backends[0],super.drawSheet(e)}drawPage(e){e&&(this.backend=this.backends[e.PageNumber-1],super.drawPage(e),this.pageIdx+=1)}clear(){for(const e of this.backends)e.clear()}setZoom(e){this.zoom=e}calculatePixelDistance(e){return e*zt}drawStaffLine(e){const t=this.backend.getContext().openGroup();t&&t.classList.add("staffline"),super.drawStaffLine(e);const i=e.PositionAndShape.AbsolutePosition;this.rules.RenderSlurs&&this.drawSlurs(e,i),this.backend.getContext().closeGroup(),this.rules.RenderGlissandi&&this.drawGlissandi(e,i)}drawSlurs(e,t){var i;const s=null===(i=window.GYM)||void 0===i?void 0:i.vfcurveItem;for(let l=0;l(!e.index||e.index===l)&&e.MeasureNumberXML==i.staffEntries[i.staffEntries.length-1].parentMeasure.MeasureNumber));var n,r,o;e&&(i.bezierEndControlPt.y+=null!=e&&null!==(n=e.bezierEndControlPt)&&void 0!==n&&n.y?e.bezierEndControlPt.y:0,i.bezierEndPt.y+=null!=e&&null!==(r=e.bezierEndPt)&&void 0!==r&&r.y?e.bezierEndPt.y:0,i.bezierStartControlPt.y+=null!=e&&null!==(o=e.bezierStartControlPt)&&void 0!==o&&o.y?e.bezierStartControlPt.y:0)}catch(a){}this.drawSlur(i,t)}}}drawGlissandi(e,t){for(const i of e.GraphicalGlissandi)this.drawGlissando(i,t)}drawGlissando(e,t){if(e.StaffLine.ParentStaff.isTab||e.calculateLine(this.rules),e.Line){const i=new z(e.Line.Start.x+t.x,e.Line.Start.y),s=new z(e.Line.End.x+t.x,e.Line.End.y);e.Line.SVGElement=this.drawLine(i,s,e.Color,e.Width)}else{const t=e.vfTie;if(t){const e=this.backend.getContext();t.setContext(e),t.draw()}}}drawSlur(e,t){const i=[];let s,n,r,o;"jianpu"===this.rules.DYMusicScoreType?((e.placement>0||e.bezierStartPt.y>0)&&(e.bezierStartPt.y=-.8,e.bezierStartControlPt.y=-2.5),s=new z(e.bezierStartPt.x+t.x,e.bezierStartPt.y+t.y),n=new z(e.bezierStartControlPt.x+t.x,e.bezierStartControlPt.y+t.y),r=new z(e.bezierEndControlPt.x+t.x,e.bezierStartControlPt.y+t.y),o=new z(e.bezierEndPt.x+t.x,e.bezierStartPt.y+t.y)):(s=new z(e.bezierStartPt.x+t.x,e.bezierStartPt.y+t.y),n=new z(e.bezierStartControlPt.x+t.x,e.bezierStartControlPt.y+t.y),r=new z(e.bezierEndControlPt.x+t.x,e.bezierEndControlPt.y+t.y),o=new z(e.bezierEndPt.x+t.x,e.bezierEndPt.y+t.y)),i.push(this.applyScreenTransformation(s)),i.push(this.applyScreenTransformation(n)),i.push(this.applyScreenTransformation(r)),i.push(this.applyScreenTransformation(o)),e.placement===d.Above?(s.y-=.05,n.y-=.3,r.y-=.3,o.y-=.05):(s.y+=.05,n.y+=.3,r.y+=.3,o.y+=.05),i.push(this.applyScreenTransformation(s)),i.push(this.applyScreenTransformation(n)),i.push(this.applyScreenTransformation(r)),i.push(this.applyScreenTransformation(o)),e.SVGElement=this.backend.renderCurve(i)}drawMeasure(e){e.setAbsoluteCoordinates(e.PositionAndShape.AbsolutePosition.x*zt,e.PositionAndShape.AbsolutePosition.y*zt);const t=this.backend.getContext();try{e.draw(t)}catch(n){s.warn("VexFlowMusicSheetDrawer.drawMeasure",n)}let i=0;for(const s of e.staffEntries)this.drawStaffEntry(s),i=this.drawBuzzRolls(s,i)}drawBuzzRolls(e,t){for(const n of e.graphicalVoiceEntries)for(const e of n.notes){var i;if(null!==(i=e.sourceNote.TremoloInfo)&&void 0!==i&&i.tremoloUnmeasured){var s;const i=this.rules.TremoloBuzzRollThickness,n=.9,r=.5,o=e;let a,l;const h=o.vfnote[0].getStemDirection();let u;if(this.backend instanceof Xt&&(u=o.getStemSVG()),void 0!==(null===(s=u)||void 0===s?void 0:s.getBbox)){const e=u.getBBox();a=new z(e.x/10,e.y/10),l=e.height/10}else l=o.vfnote[0].getStemLength()/10,a=new z(o.vfnote[0].getStem().x_begin/10,o.vfnote[0].getStem().y_top/10),1===h&&(a.y-=l);let c=a.y+l/3;o.vfnote[0].getBeamCount()>1&&(c=a.y+l/2,-1===h&&(c-=r+.2));const d=a.x-.5,f=c,m=[],p=[new z(0,-i),new z(n-i,0),new z(-n+i,-r),new z(0,-i),new z(n,0),new z(0,i),new z(-n+i,0),new z(n-i,r),new z(0,i),new z(-n,0)];let g=new z(d,f);m.push(g);for(const e of p)g=m.last(),m.push(new z(g.x+e.x,g.y-e.y));this.DrawPath(m,o.ParentMusicPage,!0,`buzzRoll${t}`),t++}}return t}drawLine(e,t,i="#000000FF",s=.2){return e=this.applyScreenTransformation(e),t=this.applyScreenTransformation(t),this.backend.renderLine(e,t,i,s*zt)}DrawOverlayLine(e,t,i,s="#FF0000FF",n=.2,r){if(!i.PageNumber||i.PageNumber>this.backends.length||i.PageNumber<1)return;const o=i.PageNumber-1,a=this.backends[o];return e=this.applyScreenTransformation(e),t=this.applyScreenTransformation(t),r||(r=`overlayLine ${e.x}/${e.y}`),a.renderLine(e,t,s,n*zt,r)}DrawPath(e,t,i=!0,s){const n=t.PageNumber-1,r=this.backends[n],o=[];for(const a of e)o.push(this.applyScreenTransformation(a));return r.renderPath(o,i,s)}drawSkyLine(e){const t=e.PositionAndShape.AbsolutePosition,i=e.PositionAndShape.Size.width;this.drawSampledLine(e.SkyLine,t,i)}drawBottomLine(e){const t=new z(e.PositionAndShape.AbsolutePosition.x,e.PositionAndShape.AbsolutePosition.y),i=e.PositionAndShape.Size.width;this.drawSampledLine(e.BottomLine,t,i,"#0000FFFF")}drawSampledLine(e,t,i,s="#FF0000FF"){const n=[];let r=0;for(let a=0;a0){const t=this.rules.SamplingUnit;let r,a,l=new z(o.x,o.y),h=new z(n[0]/t+o.x,o.y);this.drawLine(l,h,s),e[0]>=0&&(r=new z(n[0]/t+o.x,o.y),a=new z(n[0]/t+o.x,o.y+e[n[0]]),this.drawLine(r,a,s));for(let i=1;i0)for(const t of e.FingeringEntries)t.SVGNode=this.drawLabel(t,G.Notes);if(void 0!==e.graphicalChordContainers&&e.graphicalChordContainers.length>0)for(const t of e.graphicalChordContainers){const e=t.GraphicalLabel;e.SVGNode=this.drawLabel(e,G.Notes)}this.rules.RenderLyrics&&e.LyricsEntries.length>0&&this.drawLyrics(e.LyricsEntries,G.Notes)}drawLyrics(e,t){e.forEach((e=>{var i;const s=e.GraphicalLabel;s.Label.colorDefault=this.rules.DefaultColorLyrics,s.SVGNode=this.drawLabel(s,t),null===(i=s.SVGNode)||void 0===i||i.classList.add("lyrics")}))}drawInstrumentBrace(e,t){e.draw(this.backend.getContext())}drawGroupBracket(e,t){e.draw(this.backend.getContext())}drawOctaveShifts(e){for(const i of e.OctaveShifts)if(i){const e=i,n=this.backend.getContext(),r=e.getTextBracket();this.rules.DefaultColorMusic&&(r.render_options.color=this.rules.DefaultColorMusic),r.setContext(n);try{r.draw()}catch(t){s.warn(t)}}}drawPedals(e){for(const t of e.Pedals)if(t){const e=t,i=this.backend.getContext(),s=e.getPedalMarking();s.render_options.color=this.rules.DefaultColorMusic,s.setContext(i),s.draw()}}drawWavyLines(e){for(const t of e.WavyLines)if(t){const e=t,i=this.backend.getContext(),s=e.getVibratoBracket();s.setContext(i),s.draw()}}getMaxExpressionsYAndDots(e){const t=[];let i=0;for(const h of e.measures)t.push(h.measureNumber);const s={},n={},r={};for(const h of e.AbstractExpressions)if(h instanceof _t&&t.includes(h.parentMeasure.MeasureNumber)){const e=this.getDotId(h),t=this.getDotId(h,"x");n[e]||(n[e]=[]),r[t]||(r[t]=[]),this.hasDot(h.Label.PositionAndShape.RelativePosition,n[e],!0)||(n[e].push(h.Label.PositionAndShape.RelativePosition),r[t].push(h.Label.PositionAndShape.RelativePosition)),s[e]=h.Label.PositionAndShape.RelativePosition}let o=0;for(const h of e.AbstractExpressions){var a;const e=null===(a=h.parentMeasure)||void 0===a?void 0:a.MeasureNumber;if(h instanceof _t&&t.includes(e)){var l;const t=null===(l=h.parentMeasure.verticalMeasureList[0])||void 0===l?void 0:l.stave,s=(null==t?void 0:t.end_x)-(null==t?void 0:t.x),n=this.getDotId(h,"x");if(1===(r[n]||[]).length&&o!==e){const e=h.Label.PositionAndShape.AbsolutePosition.y;i=0===i?e:Math.min(i,e)}1!==(r[n]||[]).length&&s/10{var t;return"StaveSection"===(null==e||null===(t=e.attrs)||void 0===t?void 0:t.type)&&(null==e?void 0:e.section)>0&&isFinite(null==e?void 0:e.section)})))||!1,r=e.Label;r.SVGNode=this.drawLabel(r,G.Notes,n)}drawContinuousDynamic(e){if(e.IsVerbal){const t=e.Label;t.SVGNode=this.drawLabel(t,G.Notes)}else{var t;try{if(2===e.Lines.length&&Math.abs(e.Lines[0].Start.x-e.Lines[1].Start.x)>Number.EPSILON){let t=Math.min(...e.Lines.map((e=>e.Start.x))),i=Math.min(...e.Lines.map((e=>e.Start.y)));e.Lines[0].Start.x=t,e.Lines[1].Start.x=t,e.Lines[0].Start.y=i+this.rules.WedgeOpeningLength/2,e.Lines[1].Start.y=i+2*this.rules.WedgeOpeningLength,e.Lines[0].End.y+=this.rules.WedgeOpeningLength/2,e.Lines[1].End.y+=this.rules.WedgeOpeningLength}}catch(s){}const n=this.backend.getContext(),r=n.openGroup("lineGroup");null!=e&&null!==(t=e.parentMeasure)&&void 0!==t&&t.MeasureNumberXML&&(null==r||r.setAttribute("data-mnum",String(e.parentMeasure.MeasureNumberXML)));for(const t of e.Lines){var i;const s=new z(e.ParentStaffLine.PositionAndShape.AbsolutePosition.x+t.Start.x,e.ParentStaffLine.PositionAndShape.AbsolutePosition.y+t.Start.y),n=new z(e.ParentStaffLine.PositionAndShape.AbsolutePosition.x+t.End.x,e.ParentStaffLine.PositionAndShape.AbsolutePosition.y+t.End.y);t.SVGElement=this.drawLine(s,n,null!==(i=t.colorHex)&&void 0!==i?i:"#000000",t.Width)}n.closeGroup()}}renderLabel(e,t,i){return this._renderLabel(e,i)}_renderLabel(e,t){if(!e.Label.print)return;const i=e.Label.fontHeight*zt,{font:s}=e.Label;let n;this.rules.ColoringEnabled&&(n=e.Label.colorDefault,e.ColorXML&&(n=e.ColorXML),e.Label.color&&(n=e.Label.color.toString()),n||(n=this.rules.DefaultColorLabel));let r,{fontStyle:o,fontFamily:a}=e.Label;o||(o=this.rules.DefaultFontStyle),a||(a=this.rules.DefaultFontFamily);for(let c=0;c<(null===(l=e.TextLines)||void 0===l?void 0:l.length);c++){var l,h,u;const a=e.TextLines[c],d=this.calculatePixelDistance(a.xOffset),f=new z(t.ScreenPosition.x+d,t.ScreenPosition.y),m=this.backend.renderText(i,o,s,a.text,t.FontHeightInPixel,f,n,e.Label.fontFamily,null===(h=e.Label)||void 0===h?void 0:h.lyricExtendNoteId,null===(u=e.Label)||void 0===u?void 0:u.lyricVerseNumber);void 0!==a.trackIndex&&m.setAttribute("data-trackIdx",a.trackIndex),r?r.appendChild(m):r=m,t.ScreenPosition.y=t.ScreenPosition.y+t.FontHeightInPixel,e.TextLines.length>1&&(t.ScreenPosition.y+=this.rules.SpacingBetweenTextLines)}return r}renderRectangle(e,t,i,s,n){return this.backend.renderRectangle(e,i,s,n)}applyScreenTransformation(e){return new z(e.x*zt,e.y*zt)}applyScreenTransformationForRect(e){return new ie(e.x*zt,e.y*zt,e.width*zt,e.height*zt)}}class Yt extends Ae{constructor(e,t,i,s,n,r,o,a){super(e,t,i,s,n),this.stringNumberTab=r,this.fretNumber=o,this.bendArray=a}get StringNumberTab(){return this.stringNumberTab}get FretNumber(){return this.fretNumber}get BendArray(){return this.bendArray}hasTabEffects(){var e;return(null===(e=this.bendArray)||void 0===e?void 0:e.length)>0}}const jt=n.Flow,Kt=class{static durations(e,t){const i=[],s=e.clone();for(;s.RealValue>1e-4;){const e=s.RealValue;if(e>=2)i.push("1/2"),s.Sub(new u(2,1));else if(e>=1)i.push("w"),s.Sub(new u(1,1));else if(e<1&&e>=.5){if(t&&e>.5)return["w"];i.push("h"),s.Sub(new u(1,2))}else if(e<.5&&e>=.25){if(t&&e>.25)return["h"];i.push("q"),s.Sub(new u(1,4))}else if(e<.25&&e>=.125){if(t&&e>.125)return["q"];i.push("8"),s.Sub(new u(1,8))}else if(e<.125&&e>=.0625){if(t&&e>.0625)return["8"];i.push("16"),s.Sub(new u(1,16))}else if(e<.0625&&e>=.03125){if(t&&e>.03125)return["16"];i.push("32"),s.Sub(new u(1,32))}else if(e<.03125&&e>=.015625){if(t&&e>.015625)return["32"];i.push("64"),s.Sub(new u(1,64))}else{if(t)return["64"];i.push("128"),s.Sub(new u(1,128))}}return i}static pitch(e,t,i,s=void 0,n=void 0){let r=n;void 0===n&&(r=3),t&&void 0===n&&(r=0,i.ClefType===q.F&&(r=2),i.ClefType===q.C&&(r=2));const o=H[e.FundamentalNote].toLowerCase(),a=K.accidentalVexflow(e.Accidental),l=e.Octave-i.OctaveOffset+r;let h="";return s&&(h=this.NoteHeadCode(s)),[o+"n/"+l+h,a,i]}static restToNotePitch(e,t){let i=e.Octave;switch(t){case q.C:case q.F:i+=2;case q.G:}return new K(e.FundamentalNote,i,Y.NONE)}static NoteHeadCode(e){const t=e.Filled?"2":"1";switch(e.Shape){case Ue.NORMAL:return"";case Ue.DIAMOND:return"/D"+t;case Ue.TRIANGLE:return"/T"+t;case Ue.TRIANGLE_INVERTED:return"/TI";case Ue.X:return"/X"+t;case Ue.CIRCLEX:return"/X3";case Ue.RECTANGLE:return"/R"+t;case Ue.SQUARE:return"/S"+t;case Ue.SLASH:default:return""}}static GhostNotes(e){const t=[],i=Kt.durations(e,!1);for(const s of i)t.push(new jt.GhostNote({duration:s}));return t}static StaveNote(e){var t,i,s;e.sortForVexflow();const n=e.notes,o=e.parentStaffEntry.parentMeasure.parentSourceMeasure.Rules,a=n[0];let l,h=[];const c=[],d=a.graphicalNoteLength,f=void 0!==a.sourceNote.NoteTuplet;let m,p=Kt.durations(d,f)[0];Kt.idx+=1,void 0!==a.sourceNote.TypeLength&&a.sourceNote.TypeLength!==d&&0!==a.sourceNote.TypeLength.RealValue&&(p=Kt.durations(a.sourceNote.TypeLength,f)[0],a.numberOfDots=a.sourceNote.DotsXml);let g,S,y=a.numberOfDots,b=!1,M=0,v=!1;for(const r of n){var P,E;if(y=1&&t.length-1>=n+1&&(i=null===(w=t[n-1])||void 0===w||null===(I=w.graphicalVoiceEntries[0])||void 0===I?void 0:I.parentVoiceEntry,s=null===(A=t[n+1])||void 0===A||null===(R=A.graphicalVoiceEntries[0])||void 0===R?void 0:R.parentVoiceEntry,i&&s)){var N;const e=i.Notes[0],t=s.Notes[0];if(null!==(N=e.NoteBeam)&&void 0!==N&&N.Notes.includes(t)&&1!==t.ParentStaffEntry.ParentStaff.StafflineCount){const e=i.Notes.last().Pitch,t=r.Clef(),s=Kt.pitch(Kt.restToNotePitch(e.getTransposedPitch(-2),t.ClefType),!1,t);4===e.FundamentalNote&&(h=[s[0]])}}}}if((r.sourceNote.IsWholeMeasureRest||d.RealValue===r.sourceNote.SourceMeasure.ActiveTimeSignature.RealValue)&&(h="staff"===o.DYMusicScoreType?["d/5"]:["R/5"],p="w",y=0,b=!0,M=o.WholeRestXShiftVexflow*zt),[...r.sourceNote.ParentStaff.Voices].filter((e=>1!=(null==e?void 0:e.VoiceId))).length){const e=r.parentVoiceEntry.parentStaffEntry.graphicalVoiceEntries,t=r.parentVoiceEntry.parentVoiceEntry.ParentVoice.VoiceId;let i,s;for(const n of e)for(const e of n.notes){if(e===r||e.sourceNote.isRest()||!e.sourceNote.PrintObject){r.lineShift=-2;continue}const n=e.parentVoiceEntry.parentVoiceEntry.WantedStemDirection,a=1===t||5===t,l=a?1:-1,h=e.sourceNote.Pitch.getHalfTone();(!i||1===l&&h>i||-1===l&&h0){let e=3;const t=r.Clef();switch(t.ClefType){case q.F:e=5;break;case q.C:e=4}g=K.fromHalftone(i),h=[Kt.pitch(g,!0,t,void 0,e)[0]]}}break}r.sourceNote.Notehead&&(r.sourceNote.Notehead.Shape,Ue.SLASH);const e=r.vfpitch;if(null!==(P=e[2])&&void 0!==P&&null!==(E=P.Parent)&&void 0!==E&&E.Instructions)for(let t=0,i=e[2].Parent.Instructions.length;t0&&o.RenderLyrics&&o.LyricsUseXPaddingForLongLyrics){const t=e.parentStaffEntry.parentMeasure,n=[];for(let i=t.staffEntries.indexOf(e.parentStaffEntry)+1;i.25){i=!1;break}if(a.LyricsEntries.length>0)break;s+=32*u.minus(t,o).RealValue,o=t}}if(o.RenderLyrics&&o.LyricsUseXPaddingForLongLyrics&&t.length>0&&i){let i=!1,r=0;for(const e of n)if(e.sourceNote.Length.RealValue<=.125){i=!0;break}let a=!1;for(const n of t){const t=o.LyricsXPaddingWidthThreshold;let l=n.GraphicalLabel.PositionAndShape.Size.width;if(n.hasDashFromLyricWord()&&(l+=.5),l>t){r+=l-t;const n=e.parentStaffEntry,h=n.parentMeasure.staffEntries,u=h.indexOf(n)===h.length-1;u&&(s+=o.LyricsXPaddingReductionForLastNoteInMeasure),i||(s+=o.LyricsXPaddingReductionForLongNotes),!o.LyricsXPaddingForLastNoteInMeasure&&u||l>t+s&&(a=!0,r-=s);break}}a&&(S.paddingRight=10*o.LyricsXPaddingFactorForLongLyrics*r)}}const D=e.notes[0].lineShift;if(0!==D&&(S.getKeyProps()[0].line+=D),n.length>1)for(let r=0;r1&&1==e.notes[0].sourceNote.ParentVoiceEntry.ParentVoice.VoiceId&&(S.getKeyProps()[0].line=4.5);const O=null===(s=window.GYM)||void 0===s?void 0:s.customBassDrum;if(O&&S.isRest()&&("q"===S.getDuration()&&(S.getKeyProps()[0].line=O),"h"===S.getDuration()&&(S.getKeyProps()[0].line=O-1)),S.getKeyProps().forEach((({line:t},i)=>e.notes[i].staffLine=t)),(o.LedgerLineWidth||o.LedgerLineStrokeStyle)&&(S.ledgerLineStyle||(S.ledgerLineStyle={}),o.LedgerLineWidth&&(S.ledgerLineStyle.lineWidth=o.LedgerLineWidth),o.LedgerLineStrokeStyle&&(S.ledgerLineStyle.strokeStyle=o.LedgerLineStrokeStyle)),o.ColoringEnabled){const t=o.DefaultColorStem;let i=e.parentVoiceEntry.StemColor;!i&&t&&(i=t);const s={fillStyle:i,strokeStyle:i};i&&(S.setStemStyle(s),S.flag&&o.ColorFlags&&S.setFlagStyle(s))}if(S.x_shift=M,e.parentVoiceEntry.IsGrace&&e.notes[0].sourceNote.NoteBeam&&(e.parentVoiceEntry.WantedStemDirection=e.notes[0].sourceNote.NoteBeam.Notes[0].ParentVoiceEntry.WantedStemDirection),e.parentVoiceEntry){var _;let t=e.parentVoiceEntry.WantedStemDirection;const i=(null===(_=window.GYM)||void 0===_?void 0:_.stemDirectionNote)||[],s=null==i?void 0:i.find((t=>t.id===e.notes[0].sourceNote.NoteToGraphicalNoteObjectId));switch(s&&"number"==typeof(null==s?void 0:s.direction)&&(t=s.direction),t){case dt.Up:S.setStemDirection(jt.Stem.UP),e.parentVoiceEntry.StemDirection=dt.Up;break;case dt.Down:S.setStemDirection(jt.Stem.DOWN),e.parentVoiceEntry.StemDirection=dt.Down}}for(let r=0,u=n.length;r0&&"single"===t){const t=new jt.Tremolo(e);t.extra_stroke_scale=o.TremoloStrokeScale,t.y_spacing_scale=o.TremoloYSpacingScale,S&&"w"===S.duration&&S.stem.setExtension(-9),S.addModifier(r,t)}if(e>0&&"start"===t&&this.noteTremoloList.push(S),e>0&&"stop"===t){if(this.noteTremoloList.push(S),this.noteTremoloList.filter((e=>"w"===e.duration)).length===this.noteTremoloList.length)try{var G;if(this.noteTremoloList[0].keyProps&&this.noteTremoloList[1].keyProps)null===(G=(this.noteTremoloList[0].keyProps[0].line>this.noteTremoloList[1].keyProps[0].line?this.noteTremoloList[1]:this.noteTremoloList[0]).stem)||void 0===G||G.setResetHeight(30)}catch(U){console.error("设置都是全音符,stem的高度失败")}const t=new jt.Tremolo(e,[...this.noteTremoloList]);t.extra_stroke_scale=1.2,t.y_spacing_scale=1.2,t.x_shift=-30,S.addModifier(r,t),this.noteTremoloList=[]}this.glissandoList.length&&(S.setVibrato(this.glissandoList[0].vfnote[0]),this.glissandoList=[]),"start"===n[r].sourceNote.glissandoType&&this.glissandoList.push(n[r])}if(this.slideNote){try{S.setSlideNote(this.slideNote)}catch(U){console.error(U)}this.slideNote=null}if("start"===e.notes[0].sourceNote.slideType&&(this.slideNote=S),.25===B.Length.RealValue&&B.Notehead&&!1===B.Notehead.Filled){const e=S.getKeyProps();for(let t=0;t1){var W;let e=S.getKeyProps().filter((e=>!e.code&&e.line>3));(null===(W=window.GYM)||void 0===W?void 0:W.stemDirectionNote)||e.length!==h.length||S.setStemDirection(-1)}"jianpu"===o.DYMusicScoreType&&window&&window.sett&&window.sett.keySignature&&S.addAccidental(0,new jt.Accidental("#"));try{const e=["b","#","§","º","X"],t={b:"b","#":"#","§":"n","º":"bb",X:"##"};for(const i of n){const s=i.sourceNote.voiceEntry.Timestamp;for(const n of i.sourceNote.SourceMeasure.StaffLinkedExpressions)for(const i of n){const n=u.Equal(s,i.Timestamp),r=i.EntriesList.map((e=>e.label)).filter((t=>e.includes(t))).map((e=>t[e]));if(n){for(const e of r)e&&S.addAnnotation(0,new jt.Annotation(e));break}}}}catch(U){}return S}static generateArticulations(e,t,i){if(e&&"GhostNote"!==e.getAttribute("type"))for(const h of t.sourceNote.ParentVoiceEntry.Articulations){let u,c=jt.Modifier.Position.ABOVE;e.getStemDirection()===jt.Stem.UP&&(c=jt.Modifier.Position.BELOW);const f=h.articulationEnum;switch(i.ArticulationPlacementFromXML&&(h.placement===d.Above?c=jt.Modifier.Position.ABOVE:h.placement===d.Below&&(c=jt.Modifier.Position.BELOW)),f){case ct.accent:{u=new jt.Articulation("a>");const e=t.sourceNote.NoteSlurs;for(const s of e)s.StartNote===t.sourceNote&&(s.PlacementXml===d.Above?u.setYShift(10*-i.SlurStartArticulationYOffsetOfArticulation):s.PlacementXml===d.Below&&u.setYShift(10*i.SlurStartArticulationYOffsetOfArticulation));break}case ct.breathmark:u=new jt.Articulation("abr"),h.placement===d.Above&&(c=jt.Modifier.Position.ABOVE),u.breathMarkDistance=i.BreathMarkDistance;break;case ct.downbow:u=new jt.Articulation("am"),void 0===h.placement&&(c=jt.Modifier.Position.ABOVE,h.placement=d.Above);break;case ct.fermata:u=new jt.Articulation("a@a"),c=jt.Modifier.Position.ABOVE,h.placement=d.Above;break;case ct.marcatodown:u=new jt.Articulation("a|");break;case ct.marcatoup:u=new jt.Articulation("a^"),c=jt.Modifier.Position.ABOVE;break;case ct.invertedfermata:{const e=t.sourceNote.ParentVoiceEntry;if(e!==t.sourceNote.ParentVoiceEntry.ParentSourceStaffEntry.VoiceEntries.last()){e.Articulations=e.Articulations.slice(e.Articulations.indexOf(h)),e.ParentSourceStaffEntry.VoiceEntries.last().Articulations.push(h);continue}u=new jt.Articulation("a@u"),c=jt.Modifier.Position.BELOW,h.placement=d.Below;break}case ct.lefthandpizzicato:u=new jt.Articulation("a+");break;case ct.naturalharmonic:u=new jt.Articulation("ah");break;case ct.snappizzicato:u=new jt.Articulation("ao");break;case ct.staccatissimo:u=new jt.Articulation("av");break;case ct.staccato:u=new jt.Articulation("a.");break;case ct.tenuto:u=new jt.Articulation("a-");break;case ct.upbow:u=new jt.Articulation("a|"),void 0===h.placement&&(c=jt.Modifier.Position.ABOVE,h.placement=d.Above);break;case ct.strongaccent:u=new jt.Articulation("a^")}if(u){var s,n,r,o,a,l;if(!e.hasStem()&&!e.isRest()&&f==ct.accent&&e.getLineNumber()>=3&&(c=jt.Modifier.Position.ABOVE,null!=e&&null!==(r=e.modifiers)&&void 0!==r&&null!==(o=r.filter((e=>["TREMOLO"].includes(e.getCategory().toLocaleUpperCase()))))&&void 0!==o&&o.length&&u.setYShift(-16)),f===ct.strongaccent)c=jt.Modifier.Position.ABOVE,(null===(a=window.GYM)||void 0===a?void 0:a.customArtPosition)&&(1===e.getStemDirection()?c=jt.Modifier.Position.ABOVE:(c=jt.Modifier.Position.BELOW,u=new jt.Articulation("a|")));if((null===(s=window.GYM)||void 0===s?void 0:s.customAccentItem)&&f===ct.accent&&(c=jt.Modifier.Position.ABOVE),!(null===(n=window.GYM)||void 0===n?void 0:n.customLefthandpizzicatoItem)||f!==ct.lefthandpizzicato&&f!==ct.naturalharmonic||(c=jt.Modifier.Position.ABOVE),f===ct.tenuto&&"w"===e.getDuration())(null===(l=window.GYM)||void 0===l?void 0:l.customTenutoItem)&&(c=jt.Modifier.Position.ABOVE);f===ct.tenuto&&"jianpu"===i.DYMusicScoreType&&(c=jt.Modifier.Position.ABOVE,u.setYShift(-15),u.setXShift(3)),f===ct.staccatissimo&&"jianpu"===i.DYMusicScoreType&&(c=jt.Modifier.Position.ABOVE),u.setPosition(c),e.addModifier(0,u)}}}static generateOrnaments(e,t){let i,n=jt.Modifier.Position.ABOVE;switch(t.placement===d.Below&&(n=jt.Modifier.Position.BELOW),t.GetOrnament){case je.DelayedInvertedTurn:i=new jt.Ornament("turn_inverted"),i.setDelayed(!0);break;case je.DelayedTurn:i=new jt.Ornament("turn"),i.setDelayed(!0);break;case je.InvertedMordent:i=new jt.Ornament("mordent"),i.setDelayed(!1);break;case je.InvertedTurn:i=new jt.Ornament("turn_inverted"),i.setDelayed(!1);break;case je.Mordent:i=new jt.Ornament("mordent_inverted"),i.setDelayed(!1);break;case je.Trill:i=new jt.Ornament("tr"),i.setDelayed(!1);break;case je.Turn:i=new jt.Ornament("turn"),i.setDelayed(!1);break;default:return void s.warn("unhandled OrnamentEnum type: "+t.GetOrnament)}i&&(t.AccidentalBelow!==Y.NONE&&i.setLowerAccidental(K.accidentalVexflow(t.AccidentalBelow)),t.AccidentalAbove!==Y.NONE&&i.setUpperAccidental(K.accidentalVexflow(t.AccidentalAbove)),i.setPosition(n),e.addModifier(0,i))}static StrokeTypeFromArpeggioType(e){switch(e){case ke.ARPEGGIO_DIRECTIONLESS:return jt.Stroke.Type.ARPEGGIO_DIRECTIONLESS;case ke.BRUSH_DOWN:return jt.Stroke.Type.BRUSH_UP;case ke.BRUSH_UP:return jt.Stroke.Type.BRUSH_DOWN;case ke.RASQUEDO_DOWN:return jt.Stroke.Type.RASQUEDO_UP;case ke.RASQUEDO_UP:return jt.Stroke.Type.RASQUEDO_DOWN;case ke.ROLL_DOWN:return jt.Stroke.Type.ROLL_UP;case ke.ROLL_UP:return jt.Stroke.Type.ROLL_DOWN;default:return jt.Stroke.Type.ARPEGGIO_DIRECTIONLESS}}static CreateTabNote(e){const t=[],i=e.notes.reverse(),n=[],r=e.notes[0].graphicalNoteLength,o=void 0!==e.notes[0].sourceNote.NoteTuplet;let a=Kt.durations(r,o)[0],l=0;for(const c of e.notes){const i=c.sourceNote;let r={str:i.StringNumberTab,fret:i.FretNumber};c.sourceNote instanceof Yt||(s.info(`invalid tab note: ${c.sourceNote.Pitch.ToString()} in measure ${e.parentStaffEntry.parentMeasure.MeasureNumber}, likely missing XML string+fret number.`),r={str:1,fret:0}),t.push(r),i.BendArray&&i.BendArray.forEach((function(e){let t;const i=e.bendalter-r.fret;t=i>1?"Full":1===i?"1/2":"1/4","up"===e.direction?n.push({type:jt.Bend.UP,text:t,width:10}):n.push({type:jt.Bend.DOWN,text:t,width:10})})),l(e[e.VA8=0]="VA8",e[e.VB8=1]="VB8",e[e.MA15=2]="MA15",e[e.MB15=3]="MB15",e[e.NONE=4]="NONE",e))($t||{});class Qt extends c{constructor(e,t,i,s){super(t),this.label=e,this.staffNumber=i,this.parentMultiTempoExpression=s}get Label(){return this.label}set Label(e){this.label=e}get Placement(){return this.placement}set Placement(e){this.placement=e}get StaffNumber(){return this.staffNumber}set StaffNumber(e){this.staffNumber=e}get ParentMultiTempoExpression(){return this.parentMultiTempoExpression}static isStringInStringList(e,t){for(const i of e)if(Qt.stringContainsSeparatedWord(t.toLowerCase().trim(),i.toLowerCase().trim()))return!0;return!1}static stringContainsSeparatedWord(e,t){return e===t||-1!==e.indexOf(" "+t)||-1!==e.indexOf(t+" ")}}const Zt=class extends Qt{constructor(e,t,i,s,n,r=!1){super(e,t,i,n),this.isMetronomeMark=r,this.setTempoAndTempoType(s)}static getDefaultValueForTempoType(e){switch(e){case 1:return 20;case 2:return 30;case 3:return 48;case 4:return 52;case 5:return 63;case 6:return 70;case 7:return 75;case 8:return 88;case 9:return 92;case 10:return 96;case 11:return 106;case 12:return 112;case 13:return 118;case 14:return 130;case 15:return 140;case 16:return 155;case 17:return 170;case 18:return 184;case 19:return 200;default:throw new y("tempoEnum")}}static isInputStringInstantaneousTempo(e){return!!e&&(Zt.isStringInStringList(Zt.listInstantaneousTempoLarghissimo,e)||Zt.isStringInStringList(Zt.listInstantaneousTempoGrave,e)||Zt.isStringInStringList(Zt.listInstantaneousTempoLento,e)||Zt.isStringInStringList(Zt.listInstantaneousTempoLargo,e)||Zt.isStringInStringList(Zt.listInstantaneousTempoLarghetto,e)||Zt.isStringInStringList(Zt.listInstantaneousTempoAdagio,e)||Zt.isStringInStringList(Zt.listInstantaneousTempoAdagietto,e)||Zt.isStringInStringList(Zt.listInstantaneousTempoAndanteModerato,e)||Zt.isStringInStringList(Zt.listInstantaneousTempoAndante,e)||Zt.isStringInStringList(Zt.listInstantaneousTempoAndantino,e)||Zt.isStringInStringList(Zt.listInstantaneousTempoModerato,e)||Zt.isStringInStringList(Zt.listInstantaneousTempoAllegretto,e)||Zt.isStringInStringList(Zt.listInstantaneousTempoAllegroModerato,e)||Zt.isStringInStringList(Zt.listInstantaneousTempoAllegro,e)||Zt.isStringInStringList(Zt.listInstantaneousTempoVivace,e)||Zt.isStringInStringList(Zt.listInstantaneousTempoVivacissimo,e)||Zt.isStringInStringList(Zt.listInstantaneousTempoAllegrissimo,e)||Zt.isStringInStringList(Zt.listInstantaneousTempoPresto,e)||Zt.isStringInStringList(Zt.listInstantaneousTempoPrestissimo,e)||Zt.isStringInStringList(Zt.listInstantaneousTempoChangesGeneral,e))}get Label(){return this.label}set Label(e){this.label=e}get Placement(){return this.placement}set Placement(e){this.placement=e}get StaffNumber(){return this.staffNumber}set StaffNumber(e){this.staffNumber=e}get Enum(){return this.tempoEnum}get TempoInBpm(){return this.tempoInBpm}set TempoInBpm(e){this.tempoInBpm=e}get ParentMultiTempoExpression(){return this.parentMultiTempoExpression}getAbsoluteTimestamp(){return u.plus(this.ParentMultiTempoExpression.SourceMeasureParent.AbsoluteTimestamp,this.ParentMultiTempoExpression.Timestamp)}getAbsoluteFloatTimestamp(){return u.plus(this.ParentMultiTempoExpression.SourceMeasureParent.AbsoluteTimestamp,this.ParentMultiTempoExpression.Timestamp).RealValue}setTempoAndTempoType(e){return this.label?Zt.isStringInStringList(Zt.listInstantaneousTempoLarghissimo,this.label)?(0===e&&(e=Zt.getDefaultValueForTempoType(1)),this.tempoInBpm=e,void(this.tempoEnum=1)):Zt.isStringInStringList(Zt.listInstantaneousTempoGrave,this.label)?(0===e&&(e=Zt.getDefaultValueForTempoType(2)),this.tempoInBpm=e,void(this.tempoEnum=2)):Zt.isStringInStringList(Zt.listInstantaneousTempoLento,this.label)?(0===e&&(e=Zt.getDefaultValueForTempoType(3)),this.tempoInBpm=e,void(this.tempoEnum=3)):Zt.isStringInStringList(Zt.listInstantaneousTempoLargo,this.label)?(0===e&&(e=Zt.getDefaultValueForTempoType(4)),this.tempoInBpm=e,void(this.tempoEnum=4)):Zt.isStringInStringList(Zt.listInstantaneousTempoLarghetto,this.label)?(0===e&&(e=Zt.getDefaultValueForTempoType(5)),this.tempoInBpm=e,void(this.tempoEnum=5)):Zt.isStringInStringList(Zt.listInstantaneousTempoAdagio,this.label)?(0===e&&(e=Zt.getDefaultValueForTempoType(6)),this.tempoInBpm=e,void(this.tempoEnum=6)):Zt.isStringInStringList(Zt.listInstantaneousTempoAdagietto,this.label)?(0===e&&(e=Zt.getDefaultValueForTempoType(7)),this.tempoInBpm=e,void(this.tempoEnum=7)):Zt.isStringInStringList(Zt.listInstantaneousTempoAndanteModerato,this.label)?(0===e&&(e=Zt.getDefaultValueForTempoType(8)),this.tempoInBpm=e,void(this.tempoEnum=8)):Zt.isStringInStringList(Zt.listInstantaneousTempoAndante,this.label)?(0===e&&(e=Zt.getDefaultValueForTempoType(9)),this.tempoInBpm=e,void(this.tempoEnum=9)):Zt.isStringInStringList(Zt.listInstantaneousTempoAndantino,this.label)?(0===e&&(e=Zt.getDefaultValueForTempoType(10)),this.tempoInBpm=e,void(this.tempoEnum=10)):Zt.isStringInStringList(Zt.listInstantaneousTempoModerato,this.label)?(0===e&&(e=Zt.getDefaultValueForTempoType(11)),this.tempoInBpm=e,void(this.tempoEnum=11)):Zt.isStringInStringList(Zt.listInstantaneousTempoAllegretto,this.label)?(0===e&&(e=Zt.getDefaultValueForTempoType(12)),this.tempoInBpm=e,void(this.tempoEnum=12)):Zt.isStringInStringList(Zt.listInstantaneousTempoAllegroModerato,this.label)?(0===e&&(e=Zt.getDefaultValueForTempoType(13)),this.tempoInBpm=e,void(this.tempoEnum=13)):Zt.isStringInStringList(Zt.listInstantaneousTempoAllegro,this.label)?(0===e&&(e=Zt.getDefaultValueForTempoType(14)),this.tempoInBpm=e,void(this.tempoEnum=14)):Zt.isStringInStringList(Zt.listInstantaneousTempoVivace,this.label)?(0===e&&(e=Zt.getDefaultValueForTempoType(15)),this.tempoInBpm=e,void(this.tempoEnum=15)):Zt.isStringInStringList(Zt.listInstantaneousTempoVivacissimo,this.label)?(0===e&&(e=Zt.getDefaultValueForTempoType(16)),this.tempoInBpm=e,void(this.tempoEnum=16)):Zt.isStringInStringList(Zt.listInstantaneousTempoAllegrissimo,this.label)?(0===e&&(e=Zt.getDefaultValueForTempoType(17)),this.tempoInBpm=e,void(this.tempoEnum=17)):Zt.isStringInStringList(Zt.listInstantaneousTempoPresto,this.label)?(0===e&&(e=Zt.getDefaultValueForTempoType(18)),this.tempoInBpm=e,void(this.tempoEnum=18)):Zt.isStringInStringList(Zt.listInstantaneousTempoPrestissimo,this.label)?(0===e&&(e=Zt.getDefaultValueForTempoType(19)),this.tempoInBpm=e,void(this.tempoEnum=19)):Zt.isStringInStringList(Zt.listInstantaneousTempoAddons,this.label)?(this.tempoInBpm=0,void(this.tempoEnum=21)):Zt.isStringInStringList(Zt.listInstantaneousTempoChangesGeneral,this.label)?(this.tempoInBpm=0,void(this.tempoEnum=22)):void 0:(this.tempoInBpm=e,void(this.tempoEnum=23))}};let ei=Zt;ei.listInstantaneousTempoLarghissimo=["Larghissimo","Sehr breit","very, very slow"],ei.listInstantaneousTempoGrave=["Grave","Schwer","slow and solemn"],ei.listInstantaneousTempoLento=["Lento","Lent","Langsam","slowly"],ei.listInstantaneousTempoLargo=["Largo","Breit","broadly"],ei.listInstantaneousTempoLarghetto=["Larghetto","Etwas breit","rather broadly"],ei.listInstantaneousTempoAdagio=["Adagio","Langsam","Ruhig","slow and stately"],ei.listInstantaneousTempoAdagietto=["Adagietto","Ziemlich ruhig","Ziemlich langsam","rather slow"],ei.listInstantaneousTempoAndanteModerato=["Andante moderato"],ei.listInstantaneousTempoAndante=["Andante","Gehend","Schreitend","at a walking pace"],ei.listInstantaneousTempoAndantino=["Andantino","Maestoso"],ei.listInstantaneousTempoModerato=["Moderato","Mäßig","Modéré","moderately"],ei.listInstantaneousTempoAllegretto=["Allegretto","Animato","fast"],ei.listInstantaneousTempoAllegroModerato=["Allegro moderato"],ei.listInstantaneousTempoAllegro=["Allegro","Rapide","Vite","Rasch","Schnell","Fröhlich"],ei.listInstantaneousTempoVivace=["Vivace","Allegro Assai","Lebhaft","Lebendig","lively and fast"],ei.listInstantaneousTempoVivacissimo=["Vivacissimo","Sehr lebhaft","Sehr lebendig"],ei.listInstantaneousTempoAllegrissimo=["Allegrissimo","very fast"],ei.listInstantaneousTempoPresto=["Presto","Sehr schnell","Geschwind"],ei.listInstantaneousTempoPrestissimo=["Prestissimo","äußerst schnell"],ei.listInstantaneousTempoChangesGeneral=["tempo primo","a tempo","tempo i","rubato","doppio movimento","rallentando","ritardando","ritard.","rit.","ritard","rall...","accelerando","accel","molto allargando","allargando","stringendo","poco a poco rit.","rit. poco a poco","Ritardando","Ritenuto","accelerate","poco a poco accel."],ei.listInstantaneousTempoAddons=["assai","amoroso","cantabile","con brio","con dolore","con espressione","con fuoco","con moto","con spirito","spiritoso","espressivo","giocoso","giusto","grazioso","lesto","lugubre","maestoso","ma non troppo","marcato","molto","morendo","mosso","non tanto","piu","un poco","poco","quasi","risoluto","scherzando","sostenuto","teneramente","tempo giusto","tranquillo","sehr","lieblich","liebevoll","mit Leidenschaft","mit Liebe","amourös","gesanglich","mit Schwung","mit Feuer","mit Schmerz","mit Ausdruck","mit Bewegung","geistvoll","ausdrucksvoll","freudig","verspielt","angemessen","graziös","mit Grazie","flink","behände","traurig","klagend","majestätisch","aber nicht zu sehr","markant","gemäßigt","viel","sehr","ersterbend","bewegt","nicht zu sehr","mehr","ein wenig","gleichsam","entschlossen","zupackend","heiter","nachdrücklich","getragen","gewichtig","zart","zärtlich","im angemessenen Zeitmaß","ruhig","ein wenig","alla marcia","ad libitum","alla breve"];var ti=(e=>(e[e.none=0]="none",e[e.larghissimo=1]="larghissimo",e[e.grave=2]="grave",e[e.lento=3]="lento",e[e.largo=4]="largo",e[e.larghetto=5]="larghetto",e[e.adagio=6]="adagio",e[e.adagietto=7]="adagietto",e[e.andanteModerato=8]="andanteModerato",e[e.andante=9]="andante",e[e.andantino=10]="andantino",e[e.moderato=11]="moderato",e[e.allegretto=12]="allegretto",e[e.allegroModerato=13]="allegroModerato",e[e.allegro=14]="allegro",e[e.vivace=15]="vivace",e[e.vivacissimo=16]="vivacissimo",e[e.allegrissimo=17]="allegrissimo",e[e.presto=18]="presto",e[e.prestissimo=19]="prestissimo",e[e.lastRealTempo=20]="lastRealTempo",e[e.addon=21]="addon",e[e.changes=22]="changes",e[e.metronomeMark=23]="metronomeMark",e))(ti||{});const ii=class extends c{constructor(e,t,i){super(t),this.label=e,this.staffNumber=i,this.setMoodType()}static isInputStringMood(e){return!!e&&(ii.isStringInStringList(ii.listMoodAffettuoso,e)||ii.isStringInStringList(ii.listMoodAgitato,e)||ii.isStringInStringList(ii.listMoodAnimato,e)||ii.isStringInStringList(ii.listMoodAppassionato,e)||ii.isStringInStringList(ii.listMoodBrillante,e)||ii.isStringInStringList(ii.listMoodCantabile,e)||ii.isStringInStringList(ii.listMoodDolce,e)||ii.isStringInStringList(ii.listMoodEnergico,e)||ii.isStringInStringList(ii.listMoodEroico,e)||ii.isStringInStringList(ii.listMoodEspressivo,e)||ii.isStringInStringList(ii.listMoodFurioso,e)||ii.isStringInStringList(ii.listMoodGiocoso,e)||ii.isStringInStringList(ii.listMoodGioioso,e)||ii.isStringInStringList(ii.listMoodGrandioso,e)||ii.isStringInStringList(ii.listMoodGrazioso,e)||ii.isStringInStringList(ii.listMoodLacrimoso,e)||ii.isStringInStringList(ii.listMoodLeggiero,e)||ii.isStringInStringList(ii.listMoodMaestoso,e)||ii.isStringInStringList(ii.listMoodMalinconico,e)||ii.isStringInStringList(ii.listMoodMarcato,e)||ii.isStringInStringList(ii.listMoodMarziale,e)||ii.isStringInStringList(ii.listMoodMesto,e)||ii.isStringInStringList(ii.listMoodMorendo,e)||ii.isStringInStringList(ii.listMoodNobilmente,e)||ii.isStringInStringList(ii.listMoodPatetico,e)||ii.isStringInStringList(ii.listMoodPesante,e)||ii.isStringInStringList(ii.listMoodSaltando,e)||ii.isStringInStringList(ii.listMoodSautille,e)||ii.isStringInStringList(ii.listMoodScherzando,e)||ii.isStringInStringList(ii.listMoodSostenuto,e)||ii.isStringInStringList(ii.listMoodSpiccato,e)||ii.isStringInStringList(ii.listMoodTenerezza,e)||ii.isStringInStringList(ii.listMoodTranquillamente,e)||ii.isStringInStringList(ii.listMoodTrionfante,e))}get Label(){return this.label}set Label(e){this.label=e}get Mood(){return this.moodType}set Mood(e){this.moodType=e}get StaffNumber(){return this.staffNumber}set StaffNumber(e){this.staffNumber=e}get Placement(){return this.placement}set Placement(e){this.placement=e}setMoodType(){ii.isStringInStringList(ii.listMoodAffettuoso,this.label)?this.moodType=0:ii.isStringInStringList(ii.listMoodAgitato,this.label)?this.moodType=1:ii.isStringInStringList(ii.listMoodAnimato,this.label)?this.moodType=3:ii.isStringInStringList(ii.listMoodAppassionato,this.label)?this.moodType=2:ii.isStringInStringList(ii.listMoodBrillante,this.label)?this.moodType=4:ii.isStringInStringList(ii.listMoodCantabile,this.label)?this.moodType=5:ii.isStringInStringList(ii.listMoodDolce,this.label)?this.moodType=6:ii.isStringInStringList(ii.listMoodEnergico,this.label)?this.moodType=7:ii.isStringInStringList(ii.listMoodEroico,this.label)?this.moodType=8:ii.isStringInStringList(ii.listMoodEspressivo,this.label)?this.moodType=9:ii.isStringInStringList(ii.listMoodFurioso,this.label)?this.moodType=10:ii.isStringInStringList(ii.listMoodGiocoso,this.label)?this.moodType=11:ii.isStringInStringList(ii.listMoodGioioso,this.label)?this.moodType=12:ii.isStringInStringList(ii.listMoodGrandioso,this.label)?this.moodType=14:ii.isStringInStringList(ii.listMoodGrazioso,this.label)?this.moodType=15:ii.isStringInStringList(ii.listMoodLacrimoso,this.label)?this.moodType=13:ii.isStringInStringList(ii.listMoodLeggiero,this.label)?this.moodType=16:ii.isStringInStringList(ii.listMoodMaestoso,this.label)?this.moodType=17:ii.isStringInStringList(ii.listMoodMalinconico,this.label)?this.moodType=18:ii.isStringInStringList(ii.listMoodMarcato,this.label)?this.moodType=19:ii.isStringInStringList(ii.listMoodMarziale,this.label)?this.moodType=20:ii.isStringInStringList(ii.listMoodMesto,this.label)?this.moodType=21:ii.isStringInStringList(ii.listMoodMorendo,this.label)?this.moodType=22:ii.isStringInStringList(ii.listMoodNobilmente,this.label)?this.moodType=23:ii.isStringInStringList(ii.listMoodPatetico,this.label)?this.moodType=24:ii.isStringInStringList(ii.listMoodPesante,this.label)?this.moodType=25:ii.isStringInStringList(ii.listMoodSaltando,this.label)?this.moodType=27:ii.isStringInStringList(ii.listMoodSautille,this.label)?this.moodType=26:ii.isStringInStringList(ii.listMoodScherzando,this.label)?this.moodType=28:ii.isStringInStringList(ii.listMoodSostenuto,this.label)?this.moodType=29:ii.isStringInStringList(ii.listMoodSpiccato,this.label)?this.moodType=30:ii.isStringInStringList(ii.listMoodTenerezza,this.label)?this.moodType=31:ii.isStringInStringList(ii.listMoodTranquillamente,this.label)?this.moodType=32:ii.isStringInStringList(ii.listMoodTrionfante,this.label)&&(this.moodType=33)}};let si=ii;si.listMoodAffettuoso=["affettuoso"],si.listMoodAgitato=["agitato"],si.listMoodAppassionato=["appassionato"],si.listMoodAnimato=["animato","lively"],si.listMoodBrillante=["brillante"],si.listMoodCantabile=["cantabile"],si.listMoodDolce=["dolce"],si.listMoodEnergico=["energico"],si.listMoodEroico=["eroico"],si.listMoodEspressivo=["espressivo"],si.listMoodFurioso=["furioso"],si.listMoodGiocoso=["giocoso"],si.listMoodGioioso=["gioioso"],si.listMoodLacrimoso=["lacrimoso"],si.listMoodGrandioso=["grandioso"],si.listMoodGrazioso=["grazioso"],si.listMoodLeggiero=["leggiero"],si.listMoodMaestoso=["maestoso"],si.listMoodMalinconico=["malinconico"],si.listMoodMarcato=["marcato"],si.listMoodMarziale=["marziale"],si.listMoodMesto=["mesto"],si.listMoodMorendo=["morendo"],si.listMoodNobilmente=["nobilmente"],si.listMoodPatetico=["patetico"],si.listMoodPesante=["pesante"],si.listMoodSautille=["sautille"],si.listMoodSaltando=["saltando"],si.listMoodScherzando=["scherzando"],si.listMoodSostenuto=["sostenuto"],si.listMoodSpiccato=["spiccato"],si.listMoodTenerezza=["tenerezza"],si.listMoodTranquillamente=["tranquillamente"],si.listMoodTrionfante=["trionfante"];class ni extends c{constructor(e,t,i,s){super(t),this.label=e,this.staffNumber=s,void 0===i&&(i=ce.LeftBottom),this.textAlignment=i}get Label(){return this.label}get Placement(){return this.placement}set Placement(e){this.placement=e}get StaffNumber(){return this.staffNumber}set StaffNumber(e){this.staffNumber=e}get TextAlignment(){return this.textAlignment}}class ri{constructor(e,t){this.unknownList=[],this.moodList=[],this.expressions=[],this.sourceMeasure=e,this.timestamp=t}get SourceMeasureParent(){return this.sourceMeasure}set SourceMeasureParent(e){this.sourceMeasure=e}get StaffNumber(){return this.staffNumber}set StaffNumber(e){this.staffNumber=e}get Timestamp(){return this.timestamp}set Timestamp(e){this.timestamp=e}get AbsoluteTimestamp(){return u.plus(this.timestamp,this.sourceMeasure.AbsoluteTimestamp)}get InstantaneousDynamic(){return this.instantaneousDynamic}set InstantaneousDynamic(e){this.instantaneousDynamic=e}get EndingContinuousDynamic(){return this.endingContinuousDynamic}set EndingContinuousDynamic(e){this.endingContinuousDynamic=e}get StartingContinuousDynamic(){return this.startingContinuousDynamic}set StartingContinuousDynamic(e){this.startingContinuousDynamic=e}get MoodList(){return this.moodList}get UnknownList(){return this.unknownList}get EntriesList(){return this.expressions}get OctaveShiftStart(){return this.octaveShiftStart}set OctaveShiftStart(e){this.octaveShiftStart=e}get OctaveShiftEnd(){return this.octaveShiftEnd}set OctaveShiftEnd(e){this.octaveShiftEnd=e}get CombinedExpressionsText(){return this.combinedExpressionsText}set CombinedExpressionsText(e){this.combinedExpressionsText=e}getPlacementOfFirstEntry(){let e=d.Above;return this.expressions.length>0&&(this.expressions[0].expression instanceof v||this.expressions[0].expression instanceof m||this.expressions[0].expression instanceof si||this.expressions[0].expression instanceof ni)&&(e=this.expressions[0].expression.Placement),e}getFontstyleOfFirstEntry(){let e=me.Regular;if(this.expressions.length>0)if(this.expressions[0].expression instanceof m)e=me.Italic;else if(this.expressions[0].expression instanceof si)e=me.Italic;else if(this.expressions[0].expression instanceof ni){var t;e=null!==(t=this.expressions[0].expression.fontStyle)&&void 0!==t?t:me.Regular}return e}addExpression(e,t){e instanceof v?(this.instantaneousDynamic&&this.removeExpressionFromEntryList(this.InstantaneousDynamic),this.instantaneousDynamic=e,this.instantaneousDynamic.ParentMultiExpression=this):e instanceof m?this.startingContinuousDynamic=e:e instanceof si?this.moodList.push(e):e instanceof ni&&this.unknownList.push(e),this.addExpressionToEntryList(e,t)}CompareTo(e){return this.Timestamp.RealValue>e.Timestamp.RealValue?1:this.Timestamp.RealValue=5&&e<=12}get TempoType(){return this.tempoType}set TempoType(e){this.tempoType=e}get StartTempo(){return this.startTempo}set StartTempo(e){this.startTempo=e}get EndTempo(){return this.endTempo}set EndTempo(e){this.endTempo=e}get AbsoluteEndTimestamp(){return this.absoluteEndTimestamp}set AbsoluteEndTimestamp(e){this.absoluteEndTimestamp=e}get AbsoluteTimestamp(){return this.ParentMultiTempoExpression.AbsoluteTimestamp}getAbsoluteFloatTimestamp(){return this.ParentMultiTempoExpression.AbsoluteTimestamp.RealValue}getInterpolatedTempo(e){const t=u.plus(this.parentMultiTempoExpression.SourceMeasureParent.AbsoluteTimestamp,this.parentMultiTempoExpression.Timestamp);if(e.lt(t))return-1;if(this.absoluteEndTimestamp.lt(e))return-2;const i=u.minus(e,t).RealValue/u.minus(this.absoluteEndTimestamp,t).RealValue;return Math.max(0,Math.min(250,this.startTempo+(this.endTempo-this.startTempo)*i))}setTempoType(){ai.isStringInStringList(ai.listContinuousTempoFaster,this.label)?this.tempoType=0:ai.isStringInStringList(ai.listContinuousTempoSlower,this.label)&&(this.tempoType=9)}};let li=ai;li.listContinuousTempoFaster=["accelerando","piu mosso","poco piu","stretto","stringendo","accelerate","poco a poco accel."],li.listContinuousTempoSlower=["poco meno","meno mosso","piu lento","calando","allargando","molto allargando","rallentando","ritardando","ritenuto","ritard.","ritard","rit.","rit","riten.","riten","poco a poco rit.","rit. poco a poco","Ritardando","Ritenuto"];class hi{constructor(e,t){this.expressions=[],this.sourceMeasure=e,this.timestamp=t}get Timestamp(){return this.timestamp}get AbsoluteTimestamp(){return u.plus(this.sourceMeasure.AbsoluteTimestamp,this.timestamp)}get SourceMeasureParent(){return this.sourceMeasure}set SourceMeasureParent(e){this.sourceMeasure=e}get InstantaneousTempo(){return this.instantaneousTempo}get ContinuousTempo(){return this.continuousTempo}get EntriesList(){return this.expressions}get CombinedExpressionsText(){return this.combinedExpressionsText}set CombinedExpressionsText(e){this.combinedExpressionsText=e}getPlacementOfFirstEntry(){let e=d.Above;return this.expressions.length>0&&(this.expressions[0].Expression instanceof ei||this.expressions[0].Expression instanceof li)&&(e=this.expressions[0].Expression.Placement),e}getFontstyleOfFirstEntry(){let e=me.Regular;return this.expressions[0].Expression instanceof ei?e=me.Bold:this.expressions[0].Expression instanceof li&&(e=me.Italic),e}addExpression(e,t){if(this.checkIfAlreadyExists(e))return;e instanceof ei?this.instantaneousTempo=e:e instanceof li&&(this.continuousTempo=e);const i=new ui;i.prefix=t,i.Expression=e,i.label=e.Label,this.expressions.push(i)}CompareTo(e){return this.Timestamp.RealValue>e.Timestamp.RealValue?1:this.Timestamp.RealValue0){if(this.rules.MaxSystemToDrawNumber===this.musicSystems.length)return this.finalizeCurrentSystem(this.measureList[this.measureList.length-1],!this.rules.StretchLastSystemLine,!1),this.musicSystems;this.finalizeCurrentAndCreateNewSystem(this.measureList[this.measureList.length-1],!this.rules.StretchLastSystemLine,!1)}return this.musicSystems}calculateSystemYLayout(){for(const e of this.musicSystems)this.optimizeDistanceBetweenStaffLines(e);this.calculateMusicSystemsRelativePositions()}setMeasureWidth(e,t,i,s){for(let n=0,r=e.length;n0&&(r.beginInstructionsWidth=i),s>0&&(r.endInstructionsWidth=s)}}finalizeCurrentAndCreateNewSystem(e,t=!1,i=!0,s=!1){this.finalizeCurrentSystem(e,t,i,s),this.currentSystemParams=new fi,void 0!==e&&this.measureListIndex=1){const t=this.currentSystemParams.currentSystem.GraphicalMeasures[this.currentSystemParams.currentSystem.GraphicalMeasures.length-1];let i=0;const s=e[e.length-1];s.endLine===Ne.DotsBoldBoldDots&&(s.endLine=Ne.DotsThinBold,i=t[0].getLineWidth(Ne.DotsBoldBoldDots)/2-t[0].getLineWidth(Ne.DotsThinBold)),this.currentSystemParams.currentSystemFixWidth-=i;for(let e=0,n=t.length;e1){r=!0;break}let o=0;for(let a=0;a=0&&this.measureList[s]){var b;const t=null===(b=this.measureList[s][0])||void 0===b?void 0:b.parentSourceMeasure;null!=t&&t.ImplicitMeasure&&null!=t&&t.RhythmPrinted&&(e=!1)}e&&(t.addRhythmAtBegin(h,i),t.parentSourceMeasure.RhythmPrinted=h,p=!0)}return(f||m||p)&&(u+=t.beginInstructionsWidth,p&&(u+=this.rules.RhythmRightMargin)),u}addInstructionsAtMeasureEnd(e,t,i){if(!e||!e.Instructions||0===e.Instructions.length)return 0;for(let s=0,n=e.Instructions.length;s0&&(this.currentSystemParams.systemMeasures.push({beginLine:Ne.None,endLine:Ne.None}),this.currentSystemParams.currentWidth+=s,this.currentSystemParams.currentSystemFixWidth+=s)}addExtraInstructionMeasure(e,t,i){const s=this.currentSystemParams.currentSystem,n=yi.symbolFactory.createExtraGraphicalMeasure(s.StaffLines[e]);t&&n.addKeyAtBegin(t,this.activeKeys[e],this.activeClefs[e]),void 0!==i&&i.PrintObject&&n.addRhythmAtBegin(i),n.PositionAndShape.BorderLeft=0,n.PositionAndShape.BorderTop=0,n.PositionAndShape.BorderBottom=this.rules.StaffHeight;const r=this.rules.MeasureLeftMargin+n.beginInstructionsWidth+this.rules.MeasureRightMargin;return n.PositionAndShape.BorderRight=r,s.StaffLines[e].Measures.push(n),r}addStaveMeasuresToSystem(e){if(e[0]){const t=[];for(let s=0;s1){const t=Math.min(this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.length-1,e.measureListIndex+e.multipleRestMeasures-1);e=this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures[t]}}finally{}const t=this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures,i=t[this.measureListIndex];let s=!1;var n,r;return i.allRests&&(s=null===(n=t[this.measureListIndex+i.multipleRestMeasures-1])||void 0===n||null===(r=n.endsWithLineRepetition)||void 0===r?void 0:r.call(n)),this.nextMeasureBeginsLineRepetition()&&this.thisMeasureEndsLineRepetition()?Ne.DotsBoldBoldDots:this.thisMeasureEndsLineRepetition()||s?Ne.DotsThinBold:this.nextMeasureHasKeyInstructionChange()||this.thisMeasureEndsWordRepetition()||this.nextMeasureBeginsWordRepetition()?Ne.DoubleThin:e&&void 0!==e.endingBarStyleEnum?e.endingBarStyleEnum:Ne.SingleThin}getLineWidth(e,t,i){let s=e.getLineWidth(t);return t===Ne.DotsBoldBoldDots&&(s/=2),i&&t===Ne.BoldThinDots&&(s+=this.rules.DistanceBetweenLastInstructionAndRepetitionBarline),s}previousMeasureEndsLineRepetition(){if(0===this.measureListIndex)return!1;for(let e=0,t=this.measureList[this.measureListIndex-1].length;e=this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.length||!this.measureList[e])return!1;for(let t=0,i=this.measureList[e].length;t=n))break;t=s,n=s.multipleRestMeasureNumber}return t.endsWithLineRepetition()}}return!1}nextMeasureBeginsWordRepetition(){const e=this.measureListIndex+1;if(e>=this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.length||e>this.measureList.length-1)return!1;for(let t=0,i=this.measureList[e].length;t1)for(let a=1;an&&(n=i)}for(let a=0;athis.rules.PageHeight-this.rules.PageBottomMargin&&(s++,s<=4&&(e.PageNumber,i.GraphicalMeasures[0][0].MeasureNumber))}else{var r,o;const s=this.musicSystems[a-1],l=s.StaffLines[s.StaffLines.length-1],h=l.PositionAndShape;let u=this.findRequiredDistanceWithSkyBottomLine(s,i);u=Math.max(n,u),u+=this.rules.MinSkyBottomDistBetweenSystems,"GYM"===(null===(r=window)||void 0===r||null===(o=r.appName)||void 0===o?void 0:o.toLocaleUpperCase())&&(u=u<16?16:u);const c=this.hasExpressionCounts(i);c.TempoCount>0&&this.rules.MetronomeMarksDrawn&&(u+=2),c.OtherCount>0&&this.rules.MetronomeMarksDrawn&&(u+=2),u=Math.max(u,this.rules.MinimumDistanceBetweenSystems+l.StaffHeight);const d=t+h.RelativePosition.y+u,f=d+i.PositionAndShape.BorderMarginBottom;if(this.rules.NewPageAtXMLNewPageAttribute&&s.breaksPage||!(f0&&e.PageNumber}findRequiredDistanceWithSkyBottomLine(e,t){const i=e.StaffLines[e.StaffLines.length-1],s=t.StaffLines[0],n=i.BottomLine,r=s.SkyLine,o=i.PositionAndShape,a=s.PositionAndShape,l=1/this.rules.SamplingUnit;let h=0;for(let u=0;u=r.length)break;const i=Math.max(0,t-6),s=Math.min(r.length-1,t+6);let c=0;for(let n=i;n<=s;n++)c=Math.min(c,r[n]);const d=e-c;h=Math.max(d,h)}return 0===h&&(h=o.BorderBottom-a.BorderTop),h}}class fi{constructor(){this.systemMeasures=[],this.systemMeasureIndex=0,this.currentWidth=0,this.currentSystemFixWidth=0,this.currentSystemVarWidth=0,this.maxLabelLength=0}IsSystemStartMeasure(){return 0===this.systemMeasureIndex}}class mi{constructor(e,t,i){this.getOpenOctaveShift=e,this.getAbsoluteStartTimestamp=t,this.getAbsoluteEndTimestamp=i}}class pi{constructor(){this.keySignatureNoteAlterationsDict=new i,this.currentAlterationsComparedToKeyInstructionList=[],this.currentInMeasureNoteAlterationsDict=new i}get ActiveKeyInstruction(){return this.activeKeyInstruction}set ActiveKeyInstruction(e){this.activeKeyInstruction=e,this.reactOnKeyInstructionChange()}doCalculationsAtEndOfMeasure(){this.currentInMeasureNoteAlterationsDict.clear(),this.currentAlterationsComparedToKeyInstructionList.clear();for(const e of this.keySignatureNoteAlterationsDict.keys())this.currentInMeasureNoteAlterationsDict.setValue(e,this.keySignatureNoteAlterationsDict.getValue(e))}checkAccidental(e,t){if(!t)return;const i=t.FundamentalNote+12*t.Octave,s=this.currentAlterationsComparedToKeyInstructionList.indexOf(i)>=0;if(this.currentInMeasureNoteAlterationsDict.containsKey(i)){if(s&&this.currentAlterationsComparedToKeyInstructionList.splice(this.currentAlterationsComparedToKeyInstructionList.indexOf(i),1),this.currentInMeasureNoteAlterationsDict.getValue(i)!==t.AccidentalHalfTones){this.keySignatureNoteAlterationsDict.containsKey(i)&&this.keySignatureNoteAlterationsDict.getValue(i)!==t.AccidentalHalfTones?(this.currentAlterationsComparedToKeyInstructionList.push(i),this.currentInMeasureNoteAlterationsDict.setValue(i,t.AccidentalHalfTones)):t.Accidental!==Y.NONE&&this.currentInMeasureNoteAlterationsDict.remove(i);const s=this.currentInMeasureNoteAlterationsDict.getValue(i);if(t.Accidental===Y.NONE&&(t=.5===Math.abs(s)?new K(t.FundamentalNote,t.Octave,Y.NONE):new K(t.FundamentalNote,t.Octave,Y.NATURAL)),this.isAlterAmbiguousAccidental(t.Accidental)&&!t.AccidentalXml)return;yi.symbolFactory.addGraphicalAccidental(e,t)}}else if(t.Accidental!==Y.NONE){if(s||this.currentAlterationsComparedToKeyInstructionList.push(i),this.currentInMeasureNoteAlterationsDict.setValue(i,t.AccidentalHalfTones),this.isAlterAmbiguousAccidental(t.Accidental)&&!t.AccidentalXml)return;yi.symbolFactory.addGraphicalAccidental(e,t)}else s&&(t=new K(t.FundamentalNote,t.Octave,Y.NATURAL),this.currentAlterationsComparedToKeyInstructionList.splice(this.currentAlterationsComparedToKeyInstructionList.indexOf(i),1),yi.symbolFactory.addGraphicalAccidental(e,t))}isAlterAmbiguousAccidental(e){return e===Y.SLASHFLAT||e===Y.QUARTERTONEFLAT}reactOnKeyInstructionChange(){const e=this.activeKeyInstruction.AlteratedNotes;let t;t=this.activeKeyInstruction.Key>0?Y.SHARP:Y.FLAT,this.keySignatureNoteAlterationsDict.clear(),this.currentAlterationsComparedToKeyInstructionList.length=0;for(let i=-9;i<9;i++)for(let s=0;s0?(i=u-1,e.push({startIndex:t,endIndex:i}),t=u):n.HasEndLine&&this.rules.NewPartAndSystemAfterFinalBarline&&(i=u,e.push({startIndex:t,endIndex:i}),t=u+1)}t0?Number(e):6,p===e||m+u>i&&p%2==0?(n.push(p),m=t,p=1):p++}else m>i?(n.push(p),m=t,p=1):p++;S=t>i?g+1:Math.ceil(S),d===S?f+=1:(s.push(f),d=S,f=1)}s.push(f),n.push(p),n=n.filter(Boolean)}return n.length>1&&1===n[n.length-1]&&(n[n.length-2]=n[n.length-2]-1,n[n.length-1]=n[n.length-1]+1),this.buildPreparedMusicSystems(n)}buildPreparedMusicSystems(e){let t=!1;this.currentSystemParams=new fi,this.currentSystemParams.currentSystem=this.initMusicSystem();for(let i=0,s=this.measureList.length;i0&&this.rules.RenderMultipleRestMeasures){r.isReducedToMultiRest=!0,r.multipleRestMeasureNumber=1;const i=r.multipleRestMeasures-1;l+=i;for(let s=1;s<=i;s++){const i=e.SourceMeasures.indexOf(r)+s;if(i>=e.SourceMeasures.length)break;const n=e.SourceMeasures[i];n.multipleRestMeasureNumber=s+1,n.isReducedToMultiRest=!0,t.push([void 0])}}}if(this.rules.AutoGenerateMultipleRestMeasuresFromRestMeasures&&this.rules.RenderMultipleRestMeasures){let r,a=0;for(let l=0,h=e.SourceMeasures.length;l0){r.isReducedToMultiRest=!0,r.multipleRestMeasureNumber=1,a++,h.multipleRestMeasureNumber=a,h.isReducedToMultiRest=!0;for(let e=0;e1){r.multipleRestMeasures=a;const e=this.createGraphicalMeasuresForSourceMeasure(r,i,n,o,s);t[r.measureListIndex]=e,a=0,r=void 0}else a=0,r=void 0}if(a>1){r.multipleRestMeasures=a,r.isReducedToMultiRest=!0;const e=this.createGraphicalMeasuresForSourceMeasure(r,i,n,o,s);t[r.measureListIndex]=e,a=0,r=void 0}}const a=s.map((e=>e.ClefType===q.percussion));this.handleStaffEntries(a),this.calculateVerticalContainersList(),this.setIndicesToVerticalGraphicalContainers()}calculate(){this.musicSystems=[],this.clearSystemsAndMeasures(),this.clearRecreatedObjects(),this.createGraphicalTies(),this.calculateSheetLabelBoundingBoxes(),this.calculateXLayout(this.graphicalMusicSheet,this.maxInstrNameLabelLength()),this.graphicalMusicSheet.MusicPages.length=0,this.calculateMusicSystems(),Ie.transformRelativeToAbsolutePosition(this.graphicalMusicSheet)}calculateXLayout(e,t){if(this.graphicalMusicSheet.MeasureList.length>0){let e,t=0,s=1;for(let i=0;it&&(t=n);const r=this.graphicalMusicSheet.ParentMusicSheet.MeasureWidthFactor;for(const t of e)if(null!=t&&t.parentSourceMeasure.WidthFactor){s=t.parentSourceMeasure.WidthFactor;break}n*=r*s,yi.setMeasuresMinStaffEntriesWidth(e,n)}if(this.rules.FixedMeasureWidth){let s=t;this.rules.FixedMeasureWidthFixedValue&&(s=this.rules.FixedMeasureWidthFixedValue);for(let t=0;t1;if(1===s&&t.Measures[0].parentSourceMeasure.ImplicitMeasure&&(o=!1),o)return;0!==r.MeasureNumber&&1!==r.MeasureNumber||(i=r.MeasureNumber),n=r!==t.Measures[0]&&this.rules.MeasureNumberLabelXOffset?this.rules.MeasureNumberLabelXOffset:0;const a=this.rules.UseXMLMeasureNumbers&&1===r.MeasureNumber&&1!==r.parentSourceMeasure.getPrintedMeasureNumber();((r.MeasureNumber===i||r.MeasureNumber>=i+this.rules.MeasureNumberLabelOffset)&&!r.parentSourceMeasure.ImplicitMeasure||a)&&((1!==r.MeasureNumber||1===r.MeasureNumber&&r!==t.Measures[0]||a)&&this.calculateSingleMeasureNumberPlacement(r,t,e,n),i=r.MeasureNumber)}}calculateSingleMeasureNumberPlacement(e,t,i,s=0){var n,r,o,a;const l=/^\d+$/.test((null==e||null===(n=e.parentSourceMeasure)||void 0===n||null===(r=n.rehearsalExpression)||void 0===r?void 0:r.label)||"")||(null==e||null===(o=e.stave)||void 0===o||null===(a=o.modifiers)||void 0===a?void 0:a.some((e=>{var t;return"StaveSection"===(null==e||null===(t=e.attrs)||void 0===t?void 0:t.type)&&(null==e?void 0:e.section)>0&&isFinite(null==e?void 0:e.section)})))||!1,h=e.parentSourceMeasure.getPrintedMeasureNumber().toString(),u=new pt(h);u.isNotRender=l;const c=new mt(u,this.rules.MeasureNumberLabelHeight,ce.LeftBottom,this.rules),d=t.SkyBottomLineCalculator;c.setLabelPositionAndShapeBorders(),c.PositionAndShape.Parent=i.PositionAndShape;const f=t.PositionAndShape.RelativePosition.x+e.PositionAndShape.RelativePosition.x-c.PositionAndShape.BorderMarginLeft+s;let m,p=f,g=f-c.PositionAndShape.BorderLeft+c.PositionAndShape.BorderRight;p-=t.PositionAndShape.RelativePosition.x,g-=t.PositionAndShape.RelativePosition.x;const S=p+.5,y=g-.5,b=d.getSkyLineMinInRange(S,y);if(e===t.Measures[0]){let t=0;if(i.GroupBrackets.length>0)for(const e of i.GroupBrackets)t=Math.min(t,e.PositionAndShape.BorderTop);else e.ParentStaff.ParentInstrument.Parent&&(t=-1);m=Math.min(b,t)}else m=b;m=Math.min(0,m),c.PositionAndShape.RelativePosition=new z(f,m),i.MeasureNumberLabels.push(c)}calculateMeasureNumberSkyline(e){const t=e.StaffLines[0];for(const i of e.MeasureNumberLabels){let e=i.PositionAndShape.RelativePosition.x,s=e-i.PositionAndShape.BorderLeft+i.PositionAndShape.BorderRight;e-=t.PositionAndShape.RelativePosition.x,s-=t.PositionAndShape.RelativePosition.x,t.SkyBottomLineCalculator.updateSkyLineInRange(e,s,i.PositionAndShape.RelativePosition.y+i.PositionAndShape.BorderMarginTop)}}layoutGraphicalTie(e,t,i){throw new Error(this.abstractNotImplementedErrorMessage)}calculateSingleStaffLineLyricsPosition(e,t){let i=0,s=this.rules.StaffHeight;const n=new Map,r=[],o=e.SkyBottomLineCalculator;let a=e.Measures.length;for(let h=0;h0){r.push(l),i=Math.max(i,l.LyricsEntries.length);const e=l.PositionAndShape.RelativePosition.x+a.x;let t=Number.MAX_VALUE,n=Number.MIN_VALUE;for(let i=0;i0){const t=e.PositionAndShape.Size.width;let i=r[0].PositionAndShape.RelativePosition.x+r[0].PositionAndShape.BorderMarginLeft+r[0].parentMeasure.PositionAndShape.RelativePosition.x;i=i>t?t:i,o.updateBottomLineInRange(i,t,l)}return r}calculateLyricsExtendsAndDashes(e){for(let t=0,i=e.length;t0||e.UnknownList.length>0){var h;let t="";for(let i=0,s=e.EntriesList.length;i-50){let e=l/10;e+=this.rules.PlaceWordsInsideStafflineYOffset,d.PositionAndShape.RelativePosition.y=e}new _t(n,d,c,null===(h=o[i])||void 0===h?void 0:h.parentSourceMeasure,e)}}clearRecreatedObjects(){for(let e=0,t=this.staffEntriesWithGraphicalTies.length;ee.length-1&&(s.debug("minimum measure to draw index out of range. resetting min measure index to limit."),this.rules.MinMeasureToDrawIndex=e.length-1);const t=[];for(let s=this.rules.MinMeasureToDrawIndex,o=e.length;s0){let e=0;0===r.staffEntries[0].relInMeasureTimestamp.RealValue&&(e=r.staffEntries[0].PositionAndShape.RelativePosition.x,1===r.MeasureNumber&&(e+=this.rules.ChordSymbolWholeMeasureRestXOffsetMeasure1));let i=e+(r.PositionAndShape.Size.width-r.endInstructionsWidth-e)*(t.relInMeasureTimestamp.RealValue/r.parentSourceMeasure.Duration.RealValue)+l.PositionAndShape.BorderMarginLeft;o&&(i=Math.max(i,o.PositionAndShape.RelativePosition.x+o.GraphicalLabel.PositionAndShape.Size.width+this.rules.ChordSymbolXSpacing)),l.PositionAndShape.RelativePosition.x=i,l.PositionAndShape.Parent=r.staffEntries[0].PositionAndShape.Parent}const h=l.PositionAndShape,u=h.Parent;if(u.DataObject instanceof Re&&0===t.relInMeasureTimestamp.RealValue&&(h.RelativePosition.x=Math.max(r.beginInstructionsWidth,h.RelativePosition.x),1===r.MeasureNumber&&h.RelativePosition.x>3&&(h.RelativePosition.x+=this.rules.ChordSymbolWholeMeasureRestXOffsetMeasure1)),0===t.PositionAndShape.RelativePosition.x){const i=e.GraphicalMeasures[n];for(const e of i){let i=!1;for(const s of e.staffEntries)if(s.relInMeasureTimestamp===t.relInMeasureTimestamp&&0!==s.PositionAndShape.RelativePosition.x){h.RelativePosition.x=s.PositionAndShape.RelativePosition.x,i=!0;break}if(i)break}}const c=h.BorderMarginLeft+u.AbsolutePosition.x+h.RelativePosition.x,d=h.BorderMarginRight+u.AbsolutePosition.x+h.RelativePosition.x;(!this.rules.ChordSymbolYAlignment||s>0)&&(s=i.getSkyLineMinInRange(c,d));let f=0;0===a?(f+=this.rules.ChordSymbolYOffset,f+=.1):f+=this.rules.ChordSymbolYPadding,f*=-1;const m=l.GraphicalLabel;m.PositionAndShape.RelativePosition.y=s+f,m.setLabelPositionAndShapeBorders(),m.PositionAndShape.calculateBoundingBox(),i.updateSkyLineInRange(c,d,s+m.PositionAndShape.BorderMarginTop),o=l}}}}calculateAlignedChordSymbolsOffset(e,t){let i=Number.MAX_SAFE_INTEGER;for(const s of e)for(const e of s.graphicalChordContainers){const s=e.PositionAndShape,n=s.Parent;let r=s.BorderMarginLeft+n.AbsolutePosition.x,o=s.BorderMarginRight+n.AbsolutePosition.x;n.DataObject instanceof Re&&(r+=n.DataObject.beginInstructionsWidth,o+=n.DataObject.beginInstructionsWidth),i=Math.min(i,t.getSkyLineMinInRange(r,o))}return i}layoutMeasureWithWholeRest(e,t,i){}layoutBeams(e){}layoutArticulationMarks(e,t,i){}layoutOrnament(e,t,i){}calculateRestNotePlacementWithinGraphicalBeam(e,t,i,s,n){}calculateTupletNumbers(){if(!this.rules.TupletNumberLimitConsecutiveRepetitions)return;let e,t,i,n=-1,r=0;const o={};for(const a of this.graphicalMusicSheet.ParentMusicSheet.Instruments)for(const l of a.Voices){r=0,o[l.VoiceId]={};for(const a of l.VoiceEntries)if(a.Notes.length>0){const h=a.Notes[0];if(!h.NoteTuplet||h.NoteTuplet.shouldBeBracketed(this.rules.TupletsBracketedUseXMLValue,this.rules.TupletsBracketed,this.rules.TripletsBracketed)){n=-1,r=0,t=void 0,e=void 0;continue}if(h.NoteTuplet===i)continue;let u=h.TypeLength;if(u||(s.warn("note missing TypeLength"),u=h.NoteTuplet.Fractions[0]),h.NoteTuplet!==t&&o[l.VoiceId][h.NoteTuplet.TupletLabelNumber]&&o[l.VoiceId][h.NoteTuplet.TupletLabelNumber][u.RealValue]){h.NoteTuplet.RenderTupletNumber=!1,i=h.NoteTuplet;continue}h.NoteTuplet.TupletLabelNumber===n&&u.Equals(e)&&!h.NoteTuplet.Bracket||(n=h.NoteTuplet.TupletLabelNumber,e=u,r=0),t=h.NoteTuplet,r++,r<=this.rules.TupletNumberMaxConsecutiveRepetitions&&(h.NoteTuplet.RenderTupletNumber=!0),r>this.rules.TupletNumberMaxConsecutiveRepetitions&&(h.NoteTuplet.RenderTupletNumber=!1,this.rules.TupletNumberAlwaysDisableAfterFirstMax&&(o[l.VoiceId][n]||(o[l.VoiceId][n]={}),o[l.VoiceId][n][u.RealValue]=!0)),i=t}}}calculateSlurs(){}calculateGlissandi(){}calculateDynamicExpressionsForMultiExpression(e,t,i){}calculateGraphicalVerbalContinuousDynamic(e,t){const i=e.Label,s=t.x+i.PositionAndShape.BorderMarginLeft,n=t.x+i.PositionAndShape.BorderMarginRight,r=e.ContinuousDynamic.Placement,o=e.ParentStaffLine.SkyBottomLineCalculator;let a;r===d.Below?(a=o.getBottomLineMaxInRange(s,n),i.PositionAndShape.RelativePosition=new z(t.x,a-i.PositionAndShape.BorderMarginTop)):(a=o.getSkyLineMinInRange(s,n),i.PositionAndShape.RelativePosition=new z(t.x,a-i.PositionAndShape.BorderMarginBottom))}calculateGraphicalContinuousDynamic(e,t){const i=e.IsSoftAccent,n=e.ParentStaffLine.ParentStaff.idInMusicSheet,r=this.graphicalMusicSheet.getGraphicalMeasureFromSourceMeasureAndIndex(e.ContinuousDynamic.EndMultiExpression.SourceMeasureParent,n);if(!r)return void s.warn("MusicSheetCalculator.calculateGraphicalContinuousDynamic: No endMeasure found");e.EndMeasure=r;const o=e.ParentStaffLine,a=r.ParentStaffLine,l=a&&o===a;let h=!1;a?h=null==a?void 0:a.isPartOfMultiStaffInstrument():o&&(h=null==o?void 0:o.isPartOfMultiStaffInstrument());const c=u.createFromFraction(e.ContinuousDynamic.EndMultiExpression.AbsoluteTimestamp),f=this.graphicalMusicSheet.GetVerticalContainerFromTimestamp(c),m=f.getFirstNonNullStaffEntry().parentMeasure,g=m.PositionAndShape.AbsolutePosition.x+m.PositionAndShape.BorderRight;let S=new u(0,0,0);for(const s of f.StaffEntries){var y;const e=null==s||null===(y=s.sourceStaffEntry)||void 0===y?void 0:y.calculateMaxNoteLength(!1);null!=e&&e.gt(S)&&(S=e)}const b=!i&&e.ContinuousDynamic.DynamicType===p.diminuendo,M=this.getRelativePositionInStaffLineFromTimestamp(c,n,a,h,0,b),v=u.plus(c,S).clone();e.ContinuousDynamic.EndMultiExpression.EndOffsetFraction&&this.rules.UseEndOffsetForExpressions&&v.Add(e.ContinuousDynamic.EndMultiExpression.EndOffsetFraction);const P=this.getRelativePositionInStaffLineFromTimestamp(v,n,a,h,0,e.ContinuousDynamic.DynamicType===p.diminuendo),E=this.rules.SoftAccentWedgePadding,L=f.getFirstNonNullStaffEntry().PositionAndShape.Size.width,x=this.rules.SoftAccentSizeFactor;i?(t.x-=L/2*x+E,M.x=t.x+L/2*x):P.x>M.x&&P.xI){const t=w.StaffLines[e].PositionAndShape.RelativePosition.y-o.PositionAndShape.RelativePosition.y-this.rules.StaffHeight;O=this.rules.StaffHeight+t/2}else O=this.rules.WedgePlacementBelowY;O-=this.rules.WedgeOpeningLength/2,l||(_=O);let t=A.getBottomLineMaxInRange(B,V);if(t>O&&(O=t),I_&&(_=t),_+=this.rules.WedgeOpeningLength/2,_+=this.rules.WedgeVerticalMargin),O+=this.rules.WedgeOpeningLength/2,O+=this.rules.WedgeVerticalMargin}else if(R===d.Above){if(1===o.ParentStaff.ParentInstrument.Staves.length)O=this.rules.WedgePlacementAboveY;else{let e=0;I>0&&(e=I-1);const t=w.StaffLines[e];O=-(o.PositionAndShape.RelativePosition.y-t.PositionAndShape.RelativePosition.y-this.rules.StaffHeight)/2}O+=this.rules.WedgeOpeningLength/2,l||(_=O);let e=A.getSkyLineMinInRange(B,V);if(e1&&I>0){const e=o.findClosestStaffEntry(B),t=o.findClosestStaffEntry(V);e&&t&&e.parentVerticalContainer}l||(e=a.SkyBottomLineCalculator.getSkyLineMinInRange(D,k),e<_&&(_=e),_-=this.rules.WedgeOpeningLength/2),O-=this.rules.WedgeOpeningLength/2,O-=this.rules.WedgeVerticalMargin,l||(_-=this.rules.WedgeVerticalMargin)}if(e.Lines.clear(),i)e.createFirstHalfCrescendoLines(B,V,O),e.createSecondHalfDiminuendoLines(D,k,O),e.calcPsi();else if(l&&!i)e.createLines(B,V,O),e.calcPsi();else{e.createFirstHalfLines(B,V,O),e.calcPsi();for(let t=0;tn&&(n=e),n+=this.rules.WedgeOpeningLength/2,n+=this.rules.WedgeVerticalMargin}else if(R===d.Above){const e=s.SkyBottomLineCalculator.getSkyLineMinInRange(D,k);e<_&&(n=e),n-=this.rules.WedgeOpeningLength/2}e.ContinuousDynamic.DynamicType===p.crescendo?i.createSecondHalfCrescendoLines(0,s.PositionAndShape.Size.width,n):i.createFirstHalfDiminuendoLines(0,s.PositionAndShape.Size.width,n),i.calcPsi()}C.createSecondHalfLines(D,k,_),C.calcPsi()}this.dynamicExpressionMap.set(c.RealValue,e.PositionAndShape)}calculateGraphicalInstantaneousDynamicExpression(e,t,i){const s=e.ParentStaffLine;if(!s)return;const n=t.x+e.PositionAndShape.BorderMarginLeft,r=t.x+e.PositionAndShape.BorderMarginRight,o=s.SkyBottomLineCalculator;let a=0;if(e.Placement===d.Above){const i=o.getSkyLineMinInRange(n,r);if(s.isPartOfMultiStaffInstrument()&&s.ParentStaff!==s.ParentStaff.ParentInstrument.Staves[0]){const t=s.ParentMusicSystem.StaffLines[s.ParentMusicSystem.StaffLines.indexOf(s)-1],n=s.PositionAndShape.RelativePosition.y-t.PositionAndShape.RelativePosition.y-this.rules.StaffHeight;a=i>-n/2?-n/2:i-e.PositionAndShape.BorderMarginBottom}else a=i-e.PositionAndShape.BorderMarginBottom;e.PositionAndShape.RelativePosition=new z(t.x,a)}else if(e.Placement===d.Below){const i=o.getBottomLineMaxInRange(n,r),l=s.ParentStaff.ParentInstrument.Staves[s.ParentStaff.ParentInstrument.Staves.length-1];if(s.isPartOfMultiStaffInstrument()&&s.ParentStaff!==l){const t=s.ParentMusicSystem.StaffLines[s.ParentMusicSystem.StaffLines.indexOf(s)+1].PositionAndShape.RelativePosition.y-s.PositionAndShape.RelativePosition.y-this.rules.StaffHeight;a=i+e.PositionAndShape.BorderMarginBottome.PositionAndShape.Size.width&&(m=e.PositionAndShape.Size.width-this.rules.MeasureRightMargin,f=m-h.PositionAndShape.MarginSize.width,t.x=f-h.PositionAndShape.BorderMarginLeft);const p=e.SkyBottomLineCalculator;return c=n===d.Below?p.getBottomLineMaxInRange(f,m)+a:p.getSkyLineMinInRange(f,m)-a,h.PositionAndShape.RelativePosition=new z(t.x,c),n===d.Below?p.updateBottomLineInRange(f,m,h.PositionAndShape.BorderMarginBottom+c):p.updateSkyLineInRange(f,m,h.PositionAndShape.BorderMarginTop+c),h}calculateTempoExpressionsForMultiTempoExpression(e,t,i,n){Si={};const r=u.plus(e.AbsoluteTimestamp,t.Timestamp),o=this.graphicalMusicSheet.MeasureList[i];let a=new z;if(t.ContinuousTempo||t.InstantaneousTempo){if(this.rules.MinMeasureToDrawIndex>0)return;if(!o[0])return;let l=o[0].ParentStaffLine,h=o[0].PositionAndShape.RelativePosition.x,u=0;for(let e=0;e0){l=o[e].ParentStaffLine,h=o[e].PositionAndShape.RelativePosition.x,u=e;break}if(a=this.getRelativePositionInStaffLineFromTimestamp(r,u,l,l.isPartOfMultiStaffInstrument(),h),t.EntriesList.length>0&&t.EntriesList[0].Expression instanceof ei&&(t.EntriesList[0].Expression.Placement=d.Above,l.Measures[0].staffEntries.length>0&&0===Math.abs(a.x-l.Measures[0].staffEntries[0].PositionAndShape.RelativePosition.x)&&l.ParentMusicSystem===this.musicSystems[0])){const e=l.Measures[0].FirstInstructionStaffEntry;if(e){const t=e.GraphicalInstructions.last();a.x=t.PositionAndShape.RelativePosition.x}this.rules.CompactMode&&(a.x=l.PositionAndShape.RelativePosition.x+l.Measures[0].PositionAndShape.RelativePosition.x)}for(const r of t.EntriesList){let o=ce.CenterBottom;this.rules.CompactMode&&(o=ce.LeftBottom);const h=this.calculateLabel(l,a,r.label,t.getFontstyleOfFirstEntry(),r.Expression.Placement,this.rules.UnknownTextHeight,o,this.rules.TempoYSpacing);if(r.Expression.ColorXML&&this.rules.ExpressionsUseXMLColor&&(h.ColorXML=r.Expression.ColorXML),r.Expression instanceof ei){for(const e of l.AbstractExpressions)e instanceof Vt&&(e.SourceExpression.Label,r.Expression.Label);new Vt(r.Expression,h).ParentStaffLine||s.warn("Adding staffline didn't work"),r.Expression.Enum===ti.metronomeMark&&(Si[i]=r.Expression)}else r.Expression;if(n===e.TempoExpressions.length-1)for(const e of Object.values(Si))this.createMetronomeMark(e,i);else if(r.Expression instanceof li){for(const e of l.AbstractExpressions)e instanceof Vt&&(e.SourceExpression.Label,r.Expression.Label);l.AbstractExpressions.push(new Vt(r.Expression,h))}}}}createMetronomeMark(e,t){throw new Error(this.abstractNotImplementedErrorMessage)}graphicalMeasureCreatedCalculations(e){}clearSystemsAndMeasures(){for(let e=0,t=this.graphicalMusicSheet.MusicPages.length;e-1&&i.PositionAndShape.ChildElements.splice(e,1),i.FirstInstructionStaffEntry=void 0,i.beginInstructionsWidth=0}if(i.LastInstructionStaffEntry){const e=i.PositionAndShape.ChildElements.indexOf(i.LastInstructionStaffEntry.PositionAndShape);e>-1&&i.PositionAndShape.ChildElements.splice(e,1),i.LastInstructionStaffEntry=void 0,i.endInstructionsWidth=0}}t.Measures=[],t.PositionAndShape.ChildElements=[]}i.StaffLines.length=0,i.PositionAndShape.ChildElements=[]}t.MusicSystems=[],t.PositionAndShape.ChildElements=[]}this.graphicalMusicSheet.MusicPages=[]}handleVoiceEntry(e,t,i,s,n,r,o,a,l,h=void 0,u=void 0){e.StemDirectionXml!==dt.Undefined&&this.rules.SetWantedStemDirectionByXml&&void 0!==e.StemDirectionXml?e.WantedStemDirection=e.StemDirectionXml:this.calculateStemDirectionFromVoices(e);const c=t.findOrCreateGraphicalVoiceEntry(e);c.octaveShiftValue=a;const d=t.tabStaffEntry;let f;d&&(f=d.findOrCreateGraphicalVoiceEntry(e));for(let m=0,p=e.Notes.length;m-1)continue;let l;if(e.IsGrace?l=yi.symbolFactory.createGraceNote(s,c,n,this.rules,a):(l=yi.symbolFactory.createNote(s,c,n,a,this.rules,void 0),yi.stafflineNoteCalculator.trackNote(l)),s.Pitch&&this.checkNoteForAccidental(l,i,n,a),this.resetYPositionForLeadSheet(l.PositionAndShape),t.addGraphicalNoteToListAtCorrectYPosition(c,l),l.PositionAndShape.calculateBoundingBox(),this.leadSheet||(void 0!==s.NoteBeam&&s.PrintObject&&(s instanceof Yt&&!this.rules.TabBeamsRendered||this.handleBeam(l,s.NoteBeam,o)),void 0!==s.NoteTuplet&&s.PrintObject&&this.handleTuplet(l,s.NoteTuplet,r)),f){const e=yi.symbolFactory.createNote(s,f,n,a,this.rules,void 0);d.addGraphicalNoteToListAtCorrectYPosition(f,e),e.PositionAndShape.calculateBoundingBox(),this.leadSheet||s.NoteTuplet&&this.handleTuplet(e,s.NoteTuplet,r)}}return e.Articulations.length>0&&this.handleVoiceEntryArticulations(e.Articulations,e,t),e.TechnicalInstructions.length>0&&this.handleVoiceEntryTechnicalInstructions(e.TechnicalInstructions,e,t),e.LyricsEntries.size()>0&&this.handleVoiceEntryLyrics(e,t,s),e.OrnamentContainer&&this.handleVoiceEntryOrnaments(e.OrnamentContainer,e,t),a}resetYPositionForLeadSheet(e){this.leadSheet&&(e.RelativePosition=new z(e.RelativePosition.x,0))}layoutVoiceEntries(e,t){if(e.PositionAndShape.RelativePosition=new z(0,0),!this.leadSheet)for(const i of e.graphicalVoiceEntries){const t=i.notes;if(0===t.length)continue;const s=t[0].sourceNote.ParentVoiceEntry,n=void 0!==t[0].sourceNote.Pitch;this.layoutVoiceEntry(s,t,e,n)}}maxInstrNameLabelLength(){let e=0;for(const i of this.graphicalMusicSheet.ParentMusicSheet.Instruments){var t;if(null!==(t=i.NameLabel)&&void 0!==t&&t.print&&i.Voices.length>0&&i.Voices[0].Visible){let t=i.NameLabel;this.rules.RenderPartNames||(t=new pt("",t.textAlignment,t.font));const s=new mt(t,this.rules.InstrumentLabelTextHeight,ce.LeftCenter,this.rules);s.setLabelPositionAndShapeBorders(),e=Math.max(e,s.PositionAndShape.MarginSize.width)}}return this.rules.RenderPartNames?e:0}calculateSheetLabelBoundingBoxes(){var e;const t=this.graphicalMusicSheet.ParentMusicSheet,i=this.rules.DefaultColorTitle;if(void 0!==t.Title&&this.rules.RenderTitle){const e=new mt(t.Title,this.rules.SheetTitleHeight,ce.CenterBottom,this.rules);e.Label.IsCreditLabel=!0,e.Label.colorDefault=i,this.graphicalMusicSheet.Title=e,e.setLabelPositionAndShapeBorders()}else this.rules.RenderTitle||(this.graphicalMusicSheet.Title=void 0);if(void 0!==t.Subtitle&&this.rules.RenderSubtitle){const e=new mt(t.Subtitle,this.rules.SheetSubtitleHeight,ce.CenterCenter,this.rules);e.Label.IsCreditLabel=!0,e.Label.colorDefault=i,this.graphicalMusicSheet.Subtitle=e,e.setLabelPositionAndShapeBorders()}else this.rules.RenderSubtitle||(this.graphicalMusicSheet.Subtitle=void 0);if(void 0!==t.Composer&&this.rules.RenderComposer){const e=new mt(t.Composer,this.rules.SheetComposerHeight,ce.RightCenter,this.rules);e.Label.IsCreditLabel=!0,e.Label.colorDefault=i,this.graphicalMusicSheet.Composer=e,e.setLabelPositionAndShapeBorders()}else this.rules.RenderComposer||(this.graphicalMusicSheet.Composer=void 0);if(void 0!==t.Lyricist&&this.rules.RenderLyricist){const e=new mt(t.Lyricist,this.rules.SheetAuthorHeight,ce.RightCenter,this.rules);e.Label.IsCreditLabel=!0,e.Label.colorDefault=i,this.graphicalMusicSheet.Lyricist=e,e.setLabelPositionAndShapeBorders()}else this.rules.RenderLyricist||(this.graphicalMusicSheet.Lyricist=void 0);if(void 0!==t.Copyright&&this.rules.RenderCopyright){const e=new mt(t.Copyright,this.rules.SheetCopyrightHeight,ce.CenterBottom,this.rules);e.Label.IsCreditLabel=!0,e.Label.colorDefault=i,this.graphicalMusicSheet.Copyright=e,e.setLabelPositionAndShapeBorders()}else this.rules.RenderCopyright||(this.graphicalMusicSheet.Copyright=void 0);const s=null===(e=this.graphicalMusicSheet.musicSheet.sourceMeasures)||void 0===e?void 0:e[0];if(s&&s.FirstInstructionsStaffEntries.length>0){const e=s.FirstInstructionsStaffEntries[0];let n,r;for(let t=0,i=e.Instructions.length;t0&&1===e.graphicalVoiceEntries[0].notes.length){const i=e.graphicalVoiceEntries[0].notes[0];!i.sourceNote.Pitch&&new u(1,2).lt(i.sourceNote.Length)&&this.layoutMeasureWithWholeRest(i,e,t)}}}}}}optimizeRestNotePlacement(e,t){if(0===e.graphicalVoiceEntries.length)return;const i=e.graphicalVoiceEntries[0].notes;if(0===i.length)return;const s=i[0],n=s.sourceNote.isRest();if(2===e.graphicalVoiceEntries.length){let t=!1;const i=e.graphicalVoiceEntries[1].notes;i.length>0&&(t=i[0].sourceNote.isRest()),n&&t?this.calculateTwoRestNotesPlacementWithCollisionDetection(e):(n||t)&&this.calculateRestNotePlacementWithCollisionDetectionFromGraphicalNote(e)}else if(n&&e!==t.staffEntries[0]&&e!==t.staffEntries[t.staffEntries.length-1]){const i=t.staffEntries.indexOf(e),n=t.staffEntries[i-1],r=t.staffEntries[i+1];if(1===n.graphicalVoiceEntries.length){const t=n.graphicalVoiceEntries[0].notes[0];if(void 0!==t.sourceNote.NoteBeam&&1===r.graphicalVoiceEntries.length){const i=r.graphicalVoiceEntries[0].notes[0];void 0!==i.sourceNote.NoteBeam&&t.sourceNote.NoteBeam===i.sourceNote.NoteBeam&&(this.calculateRestNotePlacementWithinGraphicalBeam(e,s,t,r,i),e.PositionAndShape.calculateBoundingBox())}}}}getRelativePositionInStaffLineFromTimestamp(e,t,i,s,n=0,r=!1){let o,a,l=new z;const h=this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers.length,c=this.graphicalMusicSheet.GetInterpolatedIndexInVerticalContainers(e),d=Math.min(Math.floor(c),h-1),f=Math.min(Math.ceil(c),h-1);if(d<0||t<0)return l;if(o=this.getFirstLeftNotNullStaffEntryFromContainer(d,t,s),a=this.getFirstRightNotNullStaffEntryFromContainer(f,t,s),o&&a){let t=o.parentMeasure.PositionAndShape.RelativePosition.x;n>0&&(t=n);let s=o.PositionAndShape.RelativePosition.x+t,h=a.PositionAndShape.RelativePosition.x+a.parentMeasure.PositionAndShape.RelativePosition.x;const c=e.RealValue>a.getAbsoluteTimestamp().RealValue;n>0?h=a.PositionAndShape.RelativePosition.x+t:r&&(o.getAbsoluteTimestamp().RealValue===e.RealValue||c)&&(s=o.PositionAndShape.RelativePosition.x+o.PositionAndShape.BorderLeft+t,h=s);let d=0;if(o!==a){const t=o.getAbsoluteTimestamp(),i=a.getAbsoluteTimestamp();d=u.minus(e,t).RealValue/u.minus(i,t).RealValue}o.parentMeasure.ParentStaffLine!==a.parentMeasure.ParentStaffLine&&(o.parentMeasure.ParentStaffLine===i?h=i.PositionAndShape.Size.width:s=i.PositionAndShape.RelativePosition.x),l=new z(s+(h-s)*d,0)}return l}getRelativeXPositionFromTimestamp(e){const t=this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers.length,i=this.graphicalMusicSheet.GetInterpolatedIndexInVerticalContainers(e),s=Math.max(0,Math.min(Math.round(i),t-1)),n=this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers[s].getFirstNonNullStaffEntry();return n.PositionAndShape.RelativePosition.x+n.parentMeasure.PositionAndShape.RelativePosition.x}calculatePageLabels(e){this.rules.RenderSingleHorizontalStaffline&&(e.PositionAndShape.BorderRight=e.PositionAndShape.Size.width,e.PositionAndShape.calculateBoundingBox(),this.graphicalMusicSheet.ParentMusicSheet.pageWidth=e.PositionAndShape.Size.width);let t=10,i=-1;if(e.MusicSystems.length>0){const s=e.MusicSystems[0];t=s.PositionAndShape.RelativePosition.y+s.PositionAndShape.BorderTop;const n=e.MusicSystems[e.MusicSystems.length-1];i=n.PositionAndShape.RelativePosition.y+n.PositionAndShape.BorderBottom}const s=this.graphicalMusicSheet.Title;if(s&&this.rules.RenderTitle){s.PositionAndShape.Parent=e.PositionAndShape;const t=new z;t.x=this.graphicalMusicSheet.ParentMusicSheet.pageWidth/2,this.rules.RenderSingleHorizontalStaffline&&(t.x=e.PositionAndShape.BorderMarginLeft+s.PositionAndShape.Size.width),t.y=this.rules.TitleTopDistance+this.rules.SheetTitleHeight,s.PositionAndShape.RelativePosition=t,e.Labels.push(s)}if(this.graphicalMusicSheet.Subtitle&&this.rules.RenderTitle&&this.rules.RenderSubtitle){var n;const t=this.graphicalMusicSheet.Subtitle;t.PositionAndShape.Parent=e.PositionAndShape;const i=new z;i.x=this.graphicalMusicSheet.ParentMusicSheet.pageWidth/2,this.rules.RenderSingleHorizontalStaffline&&(i.x=e.PositionAndShape.BorderMarginLeft+s.PositionAndShape.Size.width+t.PositionAndShape.Size.width/2),i.y=this.rules.TitleTopDistance+this.rules.SheetTitleHeight+this.rules.SheetMinimumDistanceBetweenTitleAndSubtitle;const r=null===(n=t.TextLines)||void 0===n?void 0:n.length;r>1&&(i.y+=t.PositionAndShape.BorderBottom*(r-1)/r),t.PositionAndShape.RelativePosition=i,e.Labels.push(t)}const r=this.graphicalMusicSheet.Composer;let o;const a=this.graphicalMusicSheet.Composer&&this.rules.RenderComposer&&this.graphicalMusicSheet.Lyricist&&this.rules.RenderLyricist?2:0;if(r&&this.rules.RenderComposer){var l;r.PositionAndShape.Parent=e.PositionAndShape,r.setLabelPositionAndShapeBorders();const i=new z;i.x=this.graphicalMusicSheet.ParentMusicSheet.pageWidth-this.rules.PageRightMargin,this.rules.RenderSingleHorizontalStaffline&&(i.x=e.PositionAndShape.BorderMarginLeft+2*s.PositionAndShape.Size.width),i.y=t,i.y-=this.rules.SystemComposerDistance;const n=null===(l=r.TextLines)||void 0===l?void 0:l.length;n>1&&(i.y-=r.PositionAndShape.BorderBottom*(n-1)/n),o=i.y,i.y-=a,r.PositionAndShape.RelativePosition=i,e.Labels.push(r)}const h=this.graphicalMusicSheet.Lyricist;if(h&&this.rules.RenderLyricist){var u;h.PositionAndShape.Parent=e.PositionAndShape,h.setLabelPositionAndShapeBorders();const i=new z;i.x=this.graphicalMusicSheet.ParentMusicSheet.pageWidth-this.rules.PageRightMargin,i.y=t,i.y-=this.rules.SystemLyricistDistance,i.y+=h.PositionAndShape.BorderBottom,i.y=Math.min(i.y,null!==(u=o)&&void 0!==u?u:Number.MAX_SAFE_INTEGER),i.y+=a,h.PositionAndShape.RelativePosition=i,e.Labels.push(h)}const c=this.graphicalMusicSheet.Copyright;if(c&&this.rules.RenderCopyright){c.PositionAndShape.Parent=e.PositionAndShape,c.setLabelPositionAndShapeBorders();const t=new z;t.x=e.PositionAndShape.Size.width/2,t.y=i+this.rules.SheetCopyrightMargin,t.y-=c.PositionAndShape.BorderTop,c.PositionAndShape.RelativePosition=t,e.Labels.push(c)}}createGraphicalTies(){for(let e=0;e=0&&this.staffEntriesWithGraphicalTies.push(a)}a=r}}setTieDirections(e){if(!e)return;const t=e.ties;if(1===t.length){const e=t[0];if(e.TieDirection===d.NotYetDefined){const t=e.Notes[0].ParentVoiceEntry.ParentVoice.VoiceId;2!==t&&6!==t||(e.TieDirection=d.Below)}}if(t.length>1){let e;for(const i of t){const t=i.Notes[0];(!e||t.Pitch.getHalfTone()>e.Pitch.getHalfTone())&&(e=t)}for(const i of t)i.TieDirection===d.NotYetDefined&&(i.Notes[0]===e?i.TieDirection=d.Above:i.TieDirection=d.Below)}}createAccidentalCalculators(){const e=[],t=this.graphicalMusicSheet.ParentMusicSheet.getFirstSourceMeasure();if(t)for(let i=0;i1)return;c=yi.symbolFactory.createGraphicalMeasure(e,h)}if(c.hasError=e.getErrorInMeasure(a),e.FirstInstructionsStaffEntries[a])for(let u=0,y=e.FirstInstructionsStaffEntries[a].Instructions.length;u0){const t=h.Instructions[0];yi.symbolFactory.createInStaffClef(e,t)}this.rules.RenderChordSymbols&&(null===(m=h.ChordContainers)||void 0===m?void 0:m.length)>0&&(h.ParentStaff.ParentInstrument.HasChordSymbols=!0,yi.symbolFactory.createChordSymbols(h,e,s.ActiveKeyInstruction,this.graphicalMusicSheet.ParentMusicSheet.Transpose))}}if(s.doCalculationsAtEndOfMeasure(),e.LastInstructionsStaffEntries[a]){const t=e.LastInstructionsStaffEntries[a];for(let e=0,i=t.Instructions.length;e=1&&0===c.staffEntries.length){const t=new Je(new Ke(c.parentSourceMeasure,c.parentSourceMeasure.AbsoluteTimestamp,c.parentSourceMeasure.CompleteNumberOfStaves),h);if(0===h.Voices.length){const e=new _e(c.ParentStaff.ParentInstrument,-1);h.Voices.push(e)}const i=new ut(new u(0,1),h.Voices[0],t);let s=e.Duration;0===s.RealValue&&(s=e.ActiveTimeSignature.clone());const n=new Ae(i,t,s,void 0,e,!0);n.IsWholeMeasureRest=!0,n.PrintObject=this.rules.FillEmptyMeasuresWithWholeRest===C.YesVisible,i.addNote(n);const r=yi.symbolFactory.createStaffEntry(t,c);c.addGraphicalStaffEntry(r),r.relInMeasureTimestamp=i.Timestamp;const o=yi.symbolFactory.createVoiceEntry(i,r);r.graphicalVoiceEntries.push(o);const a=yi.symbolFactory.createNote(n,o,new J,$t.NONE,this.rules);yi.stafflineNoteCalculator.trackNote(a),o.notes.push(a)}c.hasOnlyRests=!0;for(const u of c.staffEntries)if(c.hasOnlyRests=u.hasOnlyRests(),!c.hasOnlyRests)break;return c}checkNoteForAccidental(e,t,i,s){let n=e.sourceNote.Pitch;const r=e.parentVoiceEntry.parentStaffEntry.parentMeasure.getTransposedHalftones();0!==r&&e.sourceNote.ParentStaffEntry.ParentStaff.ParentInstrument.MidiInstrumentId!==$.Percussion&&(n=e.Transpose(t.ActiveKeyInstruction,i,r,s),e.sourceNote.TransposedPitch=n),e.sourceNote.halfTone=n.getHalfTone(),t.checkAccidental(e,n)}handleStaffEntries(e){for(let t=0,i=this.graphicalMusicSheet.MeasureList.length;t0&&!this.rules.PercussionUseCajon2NoteSystem&&e[t]&&(-1===this.rules.PercussionOneLineCutoff||yi.stafflineNoteCalculator.getStafflineUniquePositionCount(t)0&&e.graphicalVoiceEntries[0].notes.length>0&&(this.layoutVoiceEntries(e,t),this.layoutStaffEntry(e));this.graphicalMeasureCreatedCalculations(s)}}}}calculateSkyBottomLines(){for(const e of this.musicSystems)for(const t of e.StaffLines)t.SkyBottomLineCalculator.calculateLines()}calculateExpressionAlignements(){}calculateStaffEntryArticulationMarks(){for(let e=0,t=this.musicSystems.length;e0&&this.layoutArticulationMarks(t.Articulations,t,i)}}}}}}calculateOrnaments(){for(let e=0,t=this.musicSystems.length;e0&&e.LyricVersesNumbers.sort()}for(let t=0,i=this.musicSystems.length;t=0&&(s=t.GraphicalLyricsEntries[i+1]),!s)return;const n=e.StaffEntryParent.parentMeasure.ParentStaffLine,r=s.StaffEntryParent.parentMeasure.ParentStaffLine,o=e.StaffEntryParent,a=s.StaffEntryParent;if(e.StaffEntryParent.parentMeasure.ParentStaffLine===s.StaffEntryParent.parentMeasure.ParentStaffLine){const t=o.parentMeasure.PositionAndShape.RelativePosition.x+o.PositionAndShape.RelativePosition.x+e.GraphicalLabel.PositionAndShape.RelativePosition.x+e.GraphicalLabel.PositionAndShape.BorderMarginRight-e.GraphicalLabel.CenteringXShift,i=a.parentMeasure.PositionAndShape.RelativePosition.x+a.PositionAndShape.RelativePosition.x+e.GraphicalLabel.PositionAndShape.RelativePosition.x+s.GraphicalLabel.PositionAndShape.BorderMarginLeft,r=e.GraphicalLabel.PositionAndShape.RelativePosition.y;let l=1;i-t>3*this.rules.MinimumDistanceBetweenDashes&&(l=Math.floor((i-t)/this.rules.MinimumDistanceBetweenDashes)-1),1===l?this.calculateSingleDashForLyricWord(n,t,i,r):this.calculateDashes(n,t,i,r)}else{const t=o.parentMeasure.PositionAndShape.RelativePosition.x+o.PositionAndShape.RelativePosition.x+e.GraphicalLabel.PositionAndShape.BorderMarginRight,i=n.Measures[n.Measures.length-1],l=i.PositionAndShape.RelativePosition.x+i.PositionAndShape.Size.width;let h=e.GraphicalLabel.PositionAndShape.RelativePosition.y;if(this.calculateDashes(n,t,l,h),r&&r.Measures[0]&&a.parentMeasure.ParentStaffLine&&(a!==a.parentMeasure.staffEntries[0]||a.parentMeasure!==a.parentMeasure.ParentStaffLine.Measures[0])){const e=r.Measures[0].staffEntries[0].PositionAndShape.RelativePosition.x,t=a.parentMeasure.PositionAndShape.RelativePosition.x+a.PositionAndShape.RelativePosition.x+s.GraphicalLabel.PositionAndShape.BorderMarginLeft;h=s.GraphicalLabel.PositionAndShape.RelativePosition.y,this.calculateDashes(r,e,t,h)}}}calculateDashes(e,t,i,s){let n=i-t;if(n<3*this.rules.MinimumDistanceBetweenDashes)this.calculateSingleDashForLyricWord(e,t,i,s);else{const r=Math.floor(n/this.rules.MinimumDistanceBetweenDashes)-1,o=n/(r+1);let a=0;for(t+=o,i-=o;a<=Math.floor(r/2)&&i>t;)n=this.calculateRightAndLeftDashesForLyricWord(e,t,i,s),t+=o,i-=o,a++;n>2*o&&this.calculateSingleDashForLyricWord(e,t,i,s)}}calculateSingleDashForLyricWord(e,t,i,s){const n=new pt("-");n.colorDefault=this.rules.DefaultColorLyrics;let r=this.rules.LyricsHeight;i-t<.8&&(r*=.8,s-=.1*r);const o=new mt(n,r,ce.CenterBottom,this.rules);o.setLabelPositionAndShapeBorders(),e.LyricsDashes.push(o),-1===this.staffLinesWithLyricWords.indexOf(e)&&this.staffLinesWithLyricWords.push(e),o.PositionAndShape.Parent=e.PositionAndShape;const a=new z(t+(i-t)/2,s);o.PositionAndShape.RelativePosition=a}calculateLyricExtend(e){let t=e.GraphicalLabel.PositionAndShape.RelativePosition.y;const i=e.StaffEntryParent,s=i.parentMeasure.ParentStaffLine;let n,r;const o=i.parentMeasure.ParentStaff.idInMusicSheet;for(let a=i.parentVerticalContainer.Index+1;a0)break;n=e,r=n.parentMeasure.ParentStaffLine,r||(r=i.parentMeasure.ParentStaffLine)}}if(n&&r)if(s===r&&n.parentMeasure.ParentStaffLine){const r=i.parentMeasure.PositionAndShape.RelativePosition.x+i.PositionAndShape.RelativePosition.x+e.GraphicalLabel.PositionAndShape.BorderMarginRight,o=n.parentMeasure.PositionAndShape.RelativePosition.x+n.PositionAndShape.RelativePosition.x+n.PositionAndShape.BorderMarginRight;t-=e.GraphicalLabel.PositionAndShape.Size.height/4,this.calculateSingleLyricWordWithUnderscore(s,r,o,t)}else{const o=s.Measures[s.Measures.length-1].PositionAndShape,a=i.parentMeasure.PositionAndShape.RelativePosition.x+i.PositionAndShape.RelativePosition.x+e.GraphicalLabel.PositionAndShape.BorderMarginRight,l=o.RelativePosition.x+o.Size.width;if(t-=e.GraphicalLabel.PositionAndShape.Size.height/4,this.calculateSingleLyricWordWithUnderscore(s,a,l,t),!n)return;if(n.parentMeasure.ParentStaffLine&&n.parentMeasure.staffEntries&&(n!==n.parentMeasure.staffEntries[0]||n.parentMeasure!==n.parentMeasure.ParentStaffLine.Measures[0])){const e=r.Measures[0].staffEntries[0].PositionAndShape.RelativePosition.x,i=n.parentMeasure.PositionAndShape.RelativePosition.x+n.PositionAndShape.RelativePosition.x+n.PositionAndShape.BorderMarginRight;this.calculateSingleLyricWordWithUnderscore(r,e,i,t)}}}calculateSingleLyricWordWithUnderscore(e,t,i,s){const n=new z(t,s),r=new z(i,s),o=new X(n,r,this.rules.LyricUnderscoreLineWidth);o.colorHex=this.rules.DefaultColorLyrics,e.LyricLines.push(o),-1===this.staffLinesWithLyricWords.indexOf(e)&&this.staffLinesWithLyricWords.push(e)}calculateRightAndLeftDashesForLyricWord(e,t,i,s){const n=new pt("-");n.colorDefault=this.rules.DefaultColorLyrics;const r=new mt(n,this.rules.LyricsHeight,ce.CenterBottom,this.rules);r.setLabelPositionAndShapeBorders(),e.LyricsDashes.push(r),-1===this.staffLinesWithLyricWords.indexOf(e)&&this.staffLinesWithLyricWords.push(e),r.PositionAndShape.Parent=e.PositionAndShape;const o=new z(t,s);r.PositionAndShape.RelativePosition=o;const a=new pt("-"),l=new mt(a,this.rules.LyricsHeight,ce.CenterBottom,this.rules);l.setLabelPositionAndShapeBorders(),e.LyricsDashes.push(l),l.PositionAndShape.Parent=e.PositionAndShape;const h=new z(i,s);return l.PositionAndShape.RelativePosition=h,l.PositionAndShape.RelativePosition.x-r.PositionAndShape.RelativePosition.x}calculateDynamicExpressions(){const e=Math.min(this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.length-1,this.rules.MaxMeasureToDrawIndex);for(let t=Math.min(this.rules.MinMeasureToDrawIndex,this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.length);t<=e;t++){const e=this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures[t];this.dynamicExpressionMap.clear();for(let i=0;i=0;r--){var n;if(null!==(n=this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers[r])&&void 0!==n&&n.StaffEntries[t])return this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers[r].StaffEntries[t]}}getFirstRightNotNullStaffEntryFromContainer(e,t,i){var s;if(null!==(s=this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers[e])&&void 0!==s&&s.StaffEntries[t])return this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers[e].StaffEntries[t];for(let r=e+1;r0||t.StaffLinkedExpressions[i][s].UnknownList.length>0)&&this.calculateMoodAndUnknownExpression(t.StaffLinkedExpressions[i][s],e,i)}}calculateStemDirectionFromVoices(e){if(void 0!==e.ParentSourceStaffEntry.Link)return e===e.ParentSourceStaffEntry.VoiceEntries[0]?void(e.WantedStemDirection=dt.Up):void(e.WantedStemDirection=dt.Down);e.ParentVoice instanceof Ge?e.WantedStemDirection=dt.Down:e.ParentSourceStaffEntry.VoiceEntries.length>1&&(e.WantedStemDirection=dt.Up)}setBeamNotesWantedStemDirections(e){if(!(e.Notes.length>0))return;const t=e.Notes[0].NoteBeam;if(t)for(const i of t.Notes)if(i.ParentVoiceEntry.WantedStemDirection!==dt.Undefined&&i.ParentVoiceEntry.ParentSourceStaffEntry.ParentStaff.Id===e.ParentSourceStaffEntry.ParentStaff.Id){e.WantedStemDirection=i.ParentVoiceEntry.WantedStemDirection;break}}}class bi{constructor(e,t,i){this.instrumentalGroups=[],this.name=e,this.musicSheet=t,this.parent=i}get InstrumentalGroups(){return this.instrumentalGroups}get Parent(){return this.parent}get Name(){return this.name}set Name(e){this.name=e}get GetMusicSheet(){return this.musicSheet}}class Mi extends bi{constructor(e,t,i,s){super(void 0,i,s),this.Transpose=0,this.voices=[],this.staves=[],this.hasLyrics=!1,this.hasChordSymbols=!1,this.playbackTranspose=0,this.lyricVersesNumbers=[],this.subInstruments=[],this.id=e,this.idString=t,this.nameLabel=new pt(t)}get Voices(){return this.voices}get Staves(){return this.staves}get NameLabel(){return this.nameLabel}get HasLyrics(){return this.hasLyrics}set HasLyrics(e){this.hasLyrics=e}get HasChordSymbols(){return this.hasChordSymbols}set HasChordSymbols(e){this.hasChordSymbols=e}get LyricVersesNumbers(){return this.lyricVersesNumbers}set LyricVersesNumbers(e){this.lyricVersesNumbers=e}get Name(){return this.nameLabel.text}set Name(e){this.nameLabel.text=e}get IdString(){return this.idString}get Id(){return this.id}get MidiInstrumentId(){return this.subInstruments[0].midiInstrumentID}set MidiInstrumentId(e){this.subInstruments[0].midiInstrumentID=e}get Volume(){return this.subInstruments[0].volume}set Volume(e){for(let t=0,i=this.subInstruments.length;t0&&this.Voices[0].Visible}set Visible(e){for(let t=0,i=this.Voices.length;t-1&&this.parent.MusicSystems.splice(e,1)}this.parent=e,this.boundingBox.Parent=e.PositionAndShape}get NextSystem(){const e=this.Parent.MusicSystems.indexOf(this);return e!==this.Parent.MusicSystems.length?this.Parent.MusicSystems[e+1]:void 0}get StaffLines(){return this.staffLines}get GraphicalMeasures(){return this.graphicalMeasures}get MeasureNumberLabels(){return this.measureNumberLabels}get Labels(){return this.labels.values()}get ObjectsToRedraw(){return this.objectsToRedraw}get InstrumentBrackets(){return this.instrumentBrackets}get GroupBrackets(){return this.groupBrackets}get GraphicalMarkedAreas(){return this.graphicalMarkedAreas}get SystemLines(){return this.systemLines}get Id(){return this.id}createSystemLeftLine(e,t,i){let s=-e/2;i&&(s=this.maxLabelLength+t-e/2);const n=this.staffLines[0].Measures[0];let r;this.staffLines.length>1&&(r=this.staffLines[this.staffLines.length-1].Measures[0]);const o=this.createSystemLine(s,e,Ne.SingleThin,ft.MeasureBegin,this,n,r);this.SystemLines.push(o),o.PositionAndShape.RelativePosition=new z(s,0),o.PositionAndShape.BorderLeft=0,o.PositionAndShape.BorderRight=e,o.PositionAndShape.BorderTop=o.PositionAndShape.Parent.BorderTop,o.PositionAndShape.BorderBottom=o.PositionAndShape.Parent.BorderBottom,this.createLinesForSystemLine(o)}createVerticalLineForMeasure(e,t,i,s,n,r){const o=r.ParentStaffLine,a=new z(o.PositionAndShape.RelativePosition.x,o.PositionAndShape.RelativePosition.y),l=o.ParentStaff.ParentInstrument.Staves;if(o.ParentStaff===l[0]){let h;l.length>1&&(h=this.getBottomStaffLine(o).Measures[n]);const u=this.createSystemLine(e,t,i,s,this,r,h),c=a.x+e;u.PositionAndShape.RelativePosition=new z(c,0),u.PositionAndShape.BorderLeft=0,u.PositionAndShape.BorderRight=t,this.SystemLines.push(u)}}setYPositionsToVerticalLineObjectsAndCreateLines(e){}calculateBorders(e){}alignBeginInstructions(){}GetLeftBorderAbsoluteXPosition(){return this.StaffLines[0].PositionAndShape.AbsolutePosition.x+this.StaffLines[0].Measures[0].beginInstructionsWidth}GetRightBorderAbsoluteXPosition(){return this.StaffLines[0].PositionAndShape.AbsolutePosition.x+this.StaffLines[0].StaffLines[0].End.x}AddGraphicalMeasures(e){for(let t=0,i=e.length;t1){let e,i;for(let s=0,n=this.staffLines.length;sthis.maxLabelLength&&(this.maxLabelLength=e.PositionAndShape.Size.width,t=n)}this.updateMusicSystemStaffLineXPosition(t)}setMusicSystemLabelsYPosition(){this.labels.forEach(((e,t)=>{let i=0,s=0;for(let n=0;n0&&(t.PositionAndShape.RelativePosition=new z(0,i/s+2))}))}checkStaffEntriesForStaffEntryLink(){let e=!1,t=!1;for(let i=0;i=0;i--){if(t=e.InstrumentalGroups[i],!(t instanceof Mi))return this.findLastVisibleInstrumentInInstrumentalGroup(t);if(!0===t.Visible)return t}}updateMusicSystemStaffLineXPosition(e){for(let t=0,i=this.StaffLines.length;t0){var i;const e=null===(i=window.GYM)||void 0===i?void 0:i.multitrack;e&&e>1&&(Ni=!0)}else Ni=!1;const s=Jt.TimeSignature(e);Ni||this.stave.addModifier(s,Ai.StaveModifier.Position.BEGIN,{numerator:e.Rhythm.Numerator,denominator:e.Rhythm.Denominator}),(!this.ShowTimeSignature||this.isTabMeasure&&!this.rules.TabTimeSignatureRendered)&&(s.setStyle({fillStyle:"#00000000"}),s.hidden=!0),this.updateInstructionWidth()}addClefAtEnd(e,t=!0){const i=Jt.Clef(e,"small");if(t||!this.stave.endClef){this.stave.setEndClef(i.type,i.size,i.annotation);for(const e of this.stave.getModifiers())if(t){const t=e.originalStrokeStyle,i=e.originalFillStyle;e.getStyle()&&(t&&i?(e.getStyle().strokeStyle=t,e.getStyle().fillStyle=i):(e.getStyle().strokeStyle=null,e.getStyle().fillStyle=null))}else if("clefs"===e.getCategory()&&e.getPosition()===Ai.StaveModifier.Position.END&&e.type===i.type){const t="#12345600",i=e.getStyle();i&&(e.originalStrokeStyle=i.strokeStyle,e.originalFillStyle=i.fillStyle),e.setStyle({strokeStyle:t,fillStyle:t})}return this.parentSourceMeasure.hasEndClef=!0,this.updateInstructionWidth()}}addMeasureLine(e,t,i=!0){switch(t){case ft.MeasureBegin:e===Ne.BoldThinDots&&(i||(this.stave.modifiers[0].draw=function(e){switch(e.checkContext(),this.setRendered(),this.type){case Ai.Barline.type.SINGLE:this.drawVerticalBar(e,this.x,!1);break;case Ai.Barline.type.DOUBLE:this.drawVerticalBar(e,this.x,!0);break;case Ai.Barline.type.END:this.drawVerticalEndBar(e,this.x);break;case Ai.Barline.type.REPEAT_BEGIN:this.drawRepeatBar(e,this.x,!0);break;case Ai.Barline.type.REPEAT_END:this.drawRepeatBar(e,this.x,!1);break;case Ai.Barline.type.REPEAT_BOTH:this.drawRepeatBar(e,this.x,!1),this.drawRepeatBar(e,this.x,!0)}}),this.stave.setBegBarType(Ai.Barline.type.REPEAT_BEGIN));break;case ft.MeasureEnd:switch(e){case Ne.DotsBoldBoldDots:this.stave.setEndBarType(Ai.Barline.type.REPEAT_BOTH);break;case Ne.DotsThinBold:this.stave.setEndBarType(Ai.Barline.type.REPEAT_END);break;case Ne.DoubleThin:this.stave.setEndBarType(Ai.Barline.type.DOUBLE);break;case Ne.ThinBold:this.stave.setEndBarType(Ai.Barline.type.END);break;case Ne.None:this.stave.setEndBarType(Ai.Barline.type.NONE)}}}addMeasureNumber(){const e=this.MeasureNumber.toString();this.stave.setText(e,3,{justification:1,shift_x:0,shift_y:0})}addWordRepetition(e){let t,i=Ai.StaveModifier.Position.END;const s=this.beginInstructionsWidth;switch(e.type){case Qe.Segno:t=Ai.Repetition.type.SEGNO_LEFT,i=Ai.StaveModifier.Position.LEFT;break;case Qe.Coda:t=Ai.Repetition.type.CODA_LEFT,i=Ai.StaveModifier.Position.LEFT;break;case Qe.DaCapo:t=Ai.Repetition.type.DC;break;case Qe.DalSegno:t=Ai.Repetition.type.DS;break;case Qe.Fine:t=Ai.Repetition.type.FINE;break;case Qe.ToCoda:t=Ai.Repetition.type.TO_CODA;break;case Qe.DaCapoAlFine:t=Ai.Repetition.type.DC_AL_FINE;break;case Qe.DaCapoAlCoda:t=Ai.Repetition.type.DC_AL_CODA;break;case Qe.DalSegnoAlFine:t=Ai.Repetition.type.DS_AL_FINE;break;case Qe.DalSegnoAlCoda:t=Ai.Repetition.type.DS_AL_CODA}if(t){if(this.stave.getModifiers().find((e=>e.symbol_type===t)))return;const e=new Ai.Repetition(t,s,-this.rules.RepetitionSymbolsYOffset);return e.xShiftAsPercentOfStaveWidth=this.rules.RepetitionEndInstructionXShiftAsPercentOfStaveWidth,void this.stave.addModifier(e,i)}this.addVolta(e)}addVolta(e){let t=Ai.Volta.type.BEGIN;if(e.type===Qe.Ending){switch(e.alignment){case Ze.Begin:t=this.parentSourceMeasure.endsRepetitionEnding()?Ai.Volta.type.BEGIN_END:Ai.Volta.type.BEGIN;break;case Ze.End:if(this.parentSourceMeasure.beginsRepetitionEnding())return;t=Ai.Volta.type.END}const s=this.ParentStaffLine.SkyBottomLineCalculator,n=this.PositionAndShape.AbsolutePosition.x+this.PositionAndShape.BorderMarginLeft+.4,r=Math.max(this.PositionAndShape.AbsolutePosition.x+this.PositionAndShape.BorderMarginRight,n+.4),o=s.getSkyLineMinInRange(n,r)-2;let a,l=-6.1+this.rules.VoltaOffset,h=this.rules.VoltaOffset;o0){s.trace(`Ghost Found in between (measure ${this.MeasureNumber})`);const t=this.createGhostGves(e);i.splice(o,0,...t),o+=t.length}}else{const e=u.minus(n,this.parentSourceMeasure.AbsoluteTimestamp);if(e.RealValue>0){s.trace(`Ghost Found at start (measure ${this.MeasureNumber})`);const t=this.createGhostGves(e);i.splice(0,0,...t),o+=t.length}}t=r}const n=u.plus(this.parentSourceMeasure.AbsoluteTimestamp,this.parentSourceMeasure.Duration),r=u.minus(n,t);if(r.RealValue>0){s.trace(`Ghost Found at end (measure ${this.MeasureNumber})`);const e=this.createGhostGves(r);i=i.concat(e)}return i}createGhostGves(e){const t=Jt.GhostNotes(e),i=[];for(const s of t){const e=new Ii(void 0,void 0,this.rules);e.vfStaveNote=s,i.push(e)}return i}handleBeam(e,t){const i=e.sourceNote.ParentVoiceEntry.ParentVoice.VoiceId;let s,n=this.beams[i];n||(n=this.beams[i]=[]);for(const o of n)o[0]===t&&(s=o);s||(s=[t,[]],n.push(s));const r=e.parentVoiceEntry;s[1].indexOf(r)<0&&s[1].push(r)}handleTuplet(e,t){const i=e.sourceNote.ParentVoiceEntry.ParentVoice.VoiceId;t=e.sourceNote.NoteTuplet;let s,n=this.tuplets[i];n||(n=this.tuplets[i]=[]);for(const o of n)o[0]===t&&(s=o);s||(s=[t,[]],n.push(s));const r=e.parentVoiceEntry;s[1].indexOf(r)<0&&s[1].push(r)}finalizeBeams(){if(this.vfbeams={},this.isTabMeasure&&!this.rules.TabBeamsRendered)return;const e=[];for(const t in this.beams)if(this.beams.hasOwnProperty(t)){let i=this.vfbeams[t];i||(i=this.vfbeams[t]=[]);for(const n of this.beams[t]){let t=!1;for(const e of n[0].Notes)if(e.Length.RealValue>=new u(1,4).RealValue&&(!e.TypeLength||e.TypeLength.RealValue>.125)){t=!0;break}if(t){s.debug("Beam between note >= quarter, likely tremolo, currently unsupported. continuing.");continue}const r=[],o=n[0],a=n[1];let l=!0;for(const e of a)e.parentVoiceEntry.ParentVoice===o.Notes[0].ParentVoiceEntry.ParentVoice&&(l=e.parentVoiceEntry.WantedStemDirection===dt.Undefined);let h,c=!1;const d=[];for(const i of a){const t=i.vfStaveNote;t&&(r.push(t),e.push(t)),i.parentVoiceEntry.IsGrace&&(c=!0),i.parentVoiceEntry.StemColor&&this.rules.ColoringEnabled&&d.push(i.parentVoiceEntry.StemColor)}if(r.length>1){const e=new Ai.Beam(r,l);if(c&&(e.render_options.beam_width=3,e.render_options.partial_beam_length=4),d.length>=2&&this.rules.ColorBeams){h=d[0];for(const e of d)if(e!==h){h=void 0;break}e.setStyle({fillStyle:h,strokeStyle:h})}this.rules.FlatBeams&&(e.render_options.flat_beams=!0,e.render_options.flat_beam_offset=this.rules.FlatBeamOffset,e.render_options.flat_beam_offset_per_beam=this.rules.FlatBeamOffsetPerBeam),i.push(e)}else s.debug("Warning! Beam with no notes!")}}this.rules.AutoBeamNotes&&this.autoBeamNotes(e)}autoBeamNotes(e){if(!this.rules.AutoBeamTabs&&this.isTabMeasure)return;let t,i=60,s=[],n=[],r=[];this.autoTupletVfBeams=[];const o=[];this.autoVfBeams=[];let a=this.parentSourceMeasure.ActiveTimeSignature;a||(a=this.parentSourceMeasure.Duration);for(const c of this.staffEntries)for(const l of c.graphicalVoiceEntries){const h=l.vfStaveNote,d=l.notes[0],f={vfStaveNote:h,sourceNote:d.sourceNote},m=c.relInMeasureTimestamp.isOnBeat(a),p=n.length>=2,g=d.sourceNote.Length.RealValue-new u(1,4).RealValue>-u.FloatInaccuracyTolerance,S=l.parentVoiceEntry.IsGrace||g||e.contains(h);if(S||m){if(p){for(const e of n)s.push(e);o.push(s.slice()),s=[]}if(n=[],S)continue}const y=l.notes[0].sourceNote.NoteTuplet;if(y){let e=!1;for(const t of y.Notes){for(const i of t)if(i.NoteTypeXml>=ze.QUARTER||i.ParentVoiceEntry.IsGrace||i.isRest()&&!this.rules.AutoBeamOptions.beam_rests){e=!0;break}if(e)break}if(t){if(t!==y){if(r.length>1){const e=[];for(const i of r)e.push(i.vfStaveNote);const t=new Ai.Beam(e,!0);this.rules.FlatBeams&&(t.render_options.flat_beams=!0,t.render_options.flat_beam_offset=this.rules.FlatBeamOffset,t.render_options.flat_beam_offset_per_beam=this.rules.FlatBeamOffsetPerBeam),this.autoTupletVfBeams.push(t);const s=new Fe(i++);s.AutoGenerated=!0;for(const i of r)s.addNoteToBeam(i.sourceNote)}r=[],t=y}}else t=y;e||r.push(f)}else t=void 0,n.push(f)}if(r.length>=2){const e=[];for(const i of r)e.push(i.vfStaveNote);const t=new Ai.Beam(e,!0);this.rules.FlatBeams&&(t.render_options.flat_beams=!0,t.render_options.flat_beam_offset=this.rules.FlatBeamOffset,t.render_options.flat_beam_offset_per_beam=this.rules.FlatBeamOffsetPerBeam),this.autoTupletVfBeams.push(t);const s=new Fe(i++);s.AutoGenerated=!0;for(const i of r)s.addNoteToBeam(i.sourceNote)}if(n.length>=2){for(const e of n)s.push(e);o.push(s)}const l=this.rules.AutoBeamOptions,h={beam_middle_only:l.beam_middle_rests_only,beam_rests:l.beam_rests,maintain_stem_directions:l.maintain_stem_directions};if(l.groups&&l.groups.length){const e=[];for(const t of l.groups)e.push(new Ai.Fraction(t[0],t[1]));h.groups=e}for(const u of o){const e=[];for(const i of u)e.push(i.vfStaveNote);const t=Ai.Beam.generateBeams(e,h);for(const i of t)this.rules.FlatBeams&&(i.render_options.flat_beams=!0,i.render_options.flat_beam_offset=this.rules.FlatBeamOffset,i.render_options.flat_beam_offset_per_beam=this.rules.FlatBeamOffsetPerBeam),this.autoVfBeams.push(i)}}finalizeTuplets(){this.vftuplets={};for(const e in this.tuplets)if(this.tuplets.hasOwnProperty(e)){let t=this.vftuplets[e];t||(t=this.vftuplets[e]=[]);for(const i of this.tuplets[e]){const e=[],n=i[1];for(const t of n)e.push(t.vfStaveNote);if(e.length>1){const s=i[0],n=s.Notes[0][0].NormalNotes,r=s.shouldBeBracketed(this.rules.TupletsBracketedUseXMLValue,this.rules.TupletsBracketed,this.rules.TripletsBracketed,this.isTabMeasure,this.rules.TabTupletsBracketed);let o=Ai.Tuplet.LOCATION_TOP;s.tupletLabelNumberPlacement===d.Below&&(o=Ai.Tuplet.LOCATION_BOTTOM);let a=0;if(this.isTabMeasure&&(a=10*this.rules.TabTupletYOffsetBottom,o===Ai.Tuplet.LOCATION_TOP)){a=-10*this.rules.TabTupletYOffsetTop;const e=s.Notes[0][0];null!=e&&e.hasTabEffects()&&(a-=10*this.rules.TabTupletYOffsetEffects)}const l=new Ai.Tuplet(e,{bracketed:r,location:o,notes_occupied:n,num_notes:s.TupletLabelNumber,ratioed:this.rules.TupletsRatioed,y_offset:a});t.push(l)}else s.debug("Warning! Tuplet with no notes! Trying to ignore, but this is a serious problem.")}}}layoutStaffEntry(e){}graphicalMeasureCreatedCalculations(){let e,t=[];const i=[];for(const n of this.staffEntries){e=!1,t=[];for(const s of n.graphicalVoiceEntries)if(s.parentVoiceEntry.IsGrace)t.push(s),i.push(s),e||(e=s.parentVoiceEntry.GraceSlur);else if(s.vfStaveNote=Jt.StaveNote(s),t.length>0){const i=[];for(let e=0;e0&&(s.GraceSlash=!1);const n=Jt.StaveNote(s);s.vfStaveNote=n,i.push(n)}const n=new Ai.GraceNoteGroup(i,e);n.spacing=10*this.rules.GraceNoteGroupXMargin,s.vfStaveNote.addModifier(0,n),t=[]}}if(t.length>0)for(const n of t)n.vfStaveNote=Jt.StaveNote(n),n.parentVoiceEntry.GraceAfterMainNote=!0;this.finalizeBeams(),this.finalizeTuplets();const s=this.getVoicesWithinMeasure();if(this.rules.RenderFingerings)for(const n of this.staffEntries)n.setModifierXOffsets();for(const n of s){if(!n)continue;this.vfVoices[n.VoiceId]=new Ai.Voice({beat_value:this.parentSourceMeasure.ActiveTimeSignature.Denominator,num_beats:this.parentSourceMeasure.ActiveTimeSignature.Numerator,resolution:Ai.RESOLUTION}).setMode(Ai.Voice.Mode.SOFT);const e=this.getRestFilledVexFlowStaveNotesPerVoice(n);for(const t of e){if(t.parentVoiceEntry&&t.parentVoiceEntry.IsGrace&&!t.parentVoiceEntry.GraceAfterMainNote)continue;const e=t;if(0===e.vfStaveNote.getTicks().denominator&&(e.vfStaveNote.getTicks().denominator=1),0===t.notes.length||!t.notes[0]||!t.notes[0].sourceNote.PrintObject){this.vfVoices[n.VoiceId].addTickable(e.vfStaveNote);continue}const i=e.parentStaffEntry;if(i&&i.vfClefBefore){const t=new Ri([i.vfClefBefore]);e.vfStaveNote.getCategory&&"stavenotes"===e.vfStaveNote.getCategory()&&e.vfStaveNote.addModifier(0,t)}t.parentVoiceEntry&&this.rules.RenderFingerings&&(this.rules.FingeringPosition!==d.Left&&this.rules.FingeringPosition!==d.Right||this.createFingerings(t),this.createStringNumber(t)),this.createArpeggio(t),this.vfVoices[n.VoiceId].addTickable(e.vfStaveNote)}}this.setStemDirectionFromVexFlow();for(const n of i)this.createFingerings(n),this.createStringNumber(n),this.createArpeggio(n);this.createArticulations(),this.createOrnaments()}createArpeggio(e){if(e.parentVoiceEntry&&e.parentVoiceEntry.Arpeggio){const t=e.parentVoiceEntry.Arpeggio;if(e.notes&&e.notes.length>1){const i=Jt.StrokeTypeFromArpeggioType(t.type),s=new Ai.Stroke(i,{all_voices:this.rules.ArpeggiosGoAcrossVoices});this.rules.RenderArpeggios&&e.vfStaveNote.addStroke(0,s)}else s.debug(`[OSMD] arpeggio in measure ${this.MeasureNumber} could not be drawn.\n voice entry had less than two notes, arpeggio is likely between voice entries, not currently supported in Vexflow.`)}}setStemDirectionFromVexFlow(){for(const e of this.staffEntries)for(const t of e.graphicalVoiceEntries)for(const e of t.notes){const i=e.vfnote;if(i&&i[0])switch(i[0].getStemDirection()){case Ai.Stem.UP:t.parentVoiceEntry.StemDirection=dt.Up;break;case Ai.Stem.DOWN:t.parentVoiceEntry.StemDirection=dt.Down}}}createArticulations(){for(let e=0,t=this.staffEntries.length;ei){let t=0;for(const n of e.notes)if(n.sourceNote.Fingering)t++;else{if(n.sourceNote.Fingering=s.pop(),i++,t>s.length-1)break;n.sourceNote.Fingering=s[t],t++}}let n=-1;for(const r of e.notes){const s=r.sourceNote.Fingering;if(!s){n++;continue}n++;let o=this.rules.FingeringPosition;this.rules.FingeringPositionGrace===d.AboveOrBelow&&(this.isUpperStaffOfInstrument()?o=d.Above:this.isLowerStaffOfInstrument()&&(o=d.Below)),s.placement!==d.NotYetDefined&&(o=s.placement);let a,l=this.rules.FingeringOffsetX;switch(o){default:case d.Left:a=Ai.StaveModifier.Position.LEFT,l-=r.baseFingeringXOffset*zt;break;case d.Right:a=Ai.StaveModifier.Position.RIGHT,l+=r.baseFingeringXOffset*zt;break;case d.Above:a=Ai.StaveModifier.Position.ABOVE;break;case d.Below:a=Ai.StaveModifier.Position.BELOW;break;case d.NotYetDefined:const t=e.parentStaffEntry.sourceStaffEntry.ParentStaff;e.notes.length>1||e.parentStaffEntry.graphicalVoiceEntries.length>1?a=Ai.StaveModifier.Position.LEFT:0===t.idInMusicSheet?(a=Ai.StaveModifier.Position.ABOVE,o=d.Above):(a=Ai.StaveModifier.Position.BELOW,o=d.Below)}const h=new Ai.FretHandFinger(s.value);if(h.setPosition(a),h.setOffsetX(l),o===d.Above||o===d.Below){const e=o===d.Above?-1:1,r=o===d.Above?n:i-1-n;if(this.rules.FingeringInsideStafflines&&i>1){const t=h.getWidth()/2,s=2.5*i;h.setOffsetY(e*(r+s)*t)}else if(!this.rules.FingeringInsideStafflines){const i=new Ai.StringNumber(s.value);i.radius=0,i.setPosition(a),i.setOffsetY(e*r*i.getWidth()*2/3),t.vfStaveNote.addModifier(n,i);continue}}t.vfStaveNote.addModifier(n,h)}}createStringNumber(e){if(!this.rules.RenderStringNumbersClassical)return;const t=e;e.notes.forEach(((i,s)=>{const n=i.sourceNote.StringInstruction;if(n){let r=n.value;switch(r){case"1":r="I";break;case"2":r="II";break;case"3":r="III";break;case"4":r="IV";break;case"5":r="V";break;case"6":r="VI"}const o=new Ai.StringNumber(r);o.radius=0;const a=-this.rules.StringNumberOffsetY;e.notes.length>1||e.parentStaffEntry.graphicalVoiceEntries.length>1?(o.setOffsetX(13*i.baseStringNumberXOffset),o.setPosition(Ai.Modifier.Position.RIGHT)):o.setPosition(Ai.Modifier.Position.ABOVE),o.setOffsetY(a),t.vfStaveNote.addModifier(s,o)}}))}lineTo(e,t){const i=new Ai.StaveConnector(e.getVFStave(),this.stave);i.setType(t),this.connectors.push(i)}getVFStave(){return this.stave}updateInstructionWidth(){var e,t;let i=0,s=0;const n=this.stave.getModifiers();for(const r of n)5===r.getPosition()?i+=r.getWidth()+r.getPadding(void 0):6===r.getPosition()&&(s+=r.getWidth()+r.getPadding(void 0));this.beginInstructionsWidth=(null!==(e=i)&&void 0!==e?e:0)/zt,this.endInstructionsWidth=(null!==(t=s)&&void 0!==t?t:0)/zt}addStaveTie(e,t){this.vfTies.push(e),t.vfTie=e,t.Tie.TieDirection===d.Below&&e.setDirection(1)}}class Bi extends ne{constructor(e,t=void 0,i=void 0){super(),this.graphicalChordContainers=[],this.tabStaffEntry=void 0,this.MaxAccidentals=0,this.graphicalInstructions=[],this.ties=[],this.graphicalTies=[],this.lyricsEntries=[],this.parentMeasure=e,this.graphicalVoiceEntries=[],this.sourceStaffEntry=t,i?(this.staffEntryParent=i,this.parentVerticalContainer=i.parentVerticalContainer,this.PositionAndShape=new oe(this,i.PositionAndShape)):this.PositionAndShape=new oe(this,e.PositionAndShape),t&&(this.relInMeasureTimestamp=t.Timestamp),this.FingeringEntries=[]}get GraphicalInstructions(){return this.graphicalInstructions}get GraphicalTies(){return this.graphicalTies}get LyricsEntries(){return this.lyricsEntries}set LyricsEntries(e){this.lyricsEntries=e}getAbsoluteTimestamp(){const e=this.parentMeasure.parentSourceMeasure.AbsoluteTimestamp.clone();return this.relInMeasureTimestamp&&e.Add(this.relInMeasureTimestamp),e}findTieGraphicalNoteFromNote(e){var t;const i=(null===(t=window.GYM)||void 0===t?void 0:t.graceCustom)||!1;for(const s of this.graphicalVoiceEntries)for(const t of s.notes){const s=t.sourceNote;if(i){if(e.NoteToGraphicalNoteObjectId==s.NoteToGraphicalNoteObjectId)return t}else if(!s.isRest()&&s.Pitch.FundamentalNote===e.Pitch.FundamentalNote&&s.Pitch.Octave===e.Pitch.Octave&&s.getAbsoluteTimestamp().Equals(e.getAbsoluteTimestamp()))return t}}findEndTieGraphicalNoteFromNoteWithStartingSlur(e,t){if(e)for(const i of this.graphicalVoiceEntries)if(i.parentVoiceEntry===e.ParentVoiceEntry)for(const e of i.notes){const i=e.sourceNote;if(i.NoteTie&&-1!==i.NoteSlurs.indexOf(t))return e}}findGraphicalNoteFromGraceNote(e){if(e)for(const t of this.graphicalVoiceEntries)if(t.parentVoiceEntry===e.ParentVoiceEntry)for(const i of t.notes)if(i.sourceNote===e)return i}findGraphicalNoteFromNote(e){if(e)for(const t of this.graphicalVoiceEntries)if(t.parentVoiceEntry===e.ParentVoiceEntry)for(const i of t.notes)if(i.sourceNote===e&&this.getAbsoluteTimestamp().Equals(e.getAbsoluteTimestamp()))return i}getGraphicalNoteDurationFromVoice(e){for(const t of this.graphicalVoiceEntries)if(t.parentVoiceEntry.ParentVoice===e)return t.notes[0].graphicalNoteLength;return new u(0,1)}findVoiceEntryGraphicalNotes(e){for(const t of this.graphicalVoiceEntries)if(t.parentVoiceEntry===e)return t.notes}isVoiceEntryPartOfLinkedVoiceEntry(e){if(this.sourceStaffEntry.Link)for(let t=0,i=this.sourceStaffEntry.Link.LinkStaffEntries.length;t0&&(e=t)}return e}findStaffEntryMaxNoteLength(){let e=new u(0,1);for(const t of this.graphicalVoiceEntries)for(const i of t.notes){const t=i.graphicalNoteLength;e.lt(t)&&t.GetExpandedNumerator()>0&&(e=t)}return e}findOrCreateGraphicalVoiceEntry(e){for(const i of this.graphicalVoiceEntries)if(i.parentVoiceEntry===e)return i;const t=yi.symbolFactory.createVoiceEntry(e,this);return this.graphicalVoiceEntries.push(t),t}findOrCreateGraphicalVoiceEntryFromGraphicalNote(e){for(const i of this.graphicalVoiceEntries)if(i===e.parentVoiceEntry)return i;const t=yi.symbolFactory.createVoiceEntry(e.sourceNote.ParentVoiceEntry,this);return this.graphicalVoiceEntries.push(t),t}addGraphicalNoteToListAtCorrectYPosition(e,t){const i=e.notes;if(0===i.length||t.PositionAndShape.RelativePosition.y=0;s--){if(i[s].PositionAndShape.RelativePosition.y>t.PositionAndShape.RelativePosition.y){i.splice(s+1,0,t);break}if(0===s){i.splice(0,0,t);break}}}hasOnlyRests(){return this.sourceStaffEntry.hasOnlyRests}getSkylineMin(){var e;const t=null===(e=this.parentMeasure)||void 0===e?void 0:e.ParentStaffLine.SkyBottomLineCalculator;if(!t)return;const[i,s]=this.getAbsoluteStartAndEnd();return t.getSkyLineMinInRange(i,s)}getHighestYAtEntry(){return this.parentMeasure.ParentStaffLine.PositionAndShape.AbsolutePosition.y+this.getSkylineMin()}getLowestYAtEntry(){return this.parentMeasure.ParentStaffLine.PositionAndShape.AbsolutePosition.y+this.getBottomlineMax()}getBottomlineMax(){var e;const t=null===(e=this.parentMeasure)||void 0===e?void 0:e.ParentStaffLine.SkyBottomLineCalculator;if(!t)return;const[i,s]=this.getAbsoluteStartAndEnd();return t.getBottomLineMaxInRange(i,s)}getAbsoluteStartAndEnd(){let e=this.PositionAndShape.AbsolutePosition.x;return e-=this.parentMeasure.ParentStaffLine.PositionAndShape.AbsolutePosition.x,[e,e+this.PositionAndShape.Size.width]}}class Di extends Bi{constructor(e,t,i){super(e,t,i)}calculateXPosition(){const e=this.parentMeasure.getVFStave();let t=0;for(const i of this.graphicalVoiceEntries)if(i.vfStaveNote){if(i.vfStaveNote.setStave(e),!i.vfStaveNote.preFormatted)continue;i.applyBordersFromVexflow();let s=!1,n=this.PositionAndShape;i.notes[0].sourceNote.isWholeRest()&&!this.hasOnlyRests()&&(s=!0,n=i.PositionAndShape),this.parentMeasure.ParentStaff.isTab?n.RelativePosition.x=(i.vfStaveNote.getAbsoluteX()+i.vfStaveNote.glyph.getWidth())/zt:(n.RelativePosition.x=i.vfStaveNote.getBoundingBox().getX()/zt,s&&(n.RelativePosition.x-=e.getNoteStartX()/zt,n.RelativePosition.x-=1.3));const r=i.notes[0].sourceNote;r.isRest()&&r.Length.RealValue===this.parentMeasure.parentSourceMeasure.ActiveTimeSignature.RealValue&&(n.RelativePosition.x+=this.parentMeasure.parentSourceMeasure.Rules.WholeRestXShiftVexflow-.1,i.PositionAndShape.BorderLeft=-.7,i.PositionAndShape.BorderRight=.7),i.PositionAndShape.BorderLefte.staffLine)),i=this.calculateModifierXOffsets(t,1),s=this.calculateModifierXOffsets(t,.5);e.forEach(((e,t)=>{e.baseFingeringXOffset=s[t],e.baseStringNumberXOffset=i[t]}))}calculateModifierXOffsets(e,t){const i=[];for(let s=0;s=0;o--){if(Math.abs(e[s]-e[o])<=t&&n===i[o]){n++,r=!0;break}r=!1}i.push(n)}return i}}class Vi extends Ee{constructor(e,t,i,s=$t.NONE,n,r=void 0){if(super(e,t,n,r),this.clef=i,this.octaveShift=s,e.Pitch){const t=e.isRest()?e.Pitch:qt.getPitchFromOctaveShift(e.Pitch,s);this.vfpitch=Jt.pitch(t,e.isRest(),this.clef,this.sourceNote.Notehead),this.vfpitch[1]=void 0}}setAccidental(e){const t=this.drawPitch(e);this.vfpitch=Jt.pitch(t,this.sourceNote.isRest(),this.clef,this.sourceNote.Notehead),this.DrawnAccidental=t.Accidental}drawPitch(e){return qt.getPitchFromOctaveShift(e,this.octaveShift)}Transpose(e,t,i,s){const n=super.Transpose(e,t,i,s),r=qt.getPitchFromOctaveShift(n,this.octaveShift);return this.vfpitch=Jt.pitch(r,this.sourceNote.isRest(),this.clef,this.sourceNote.Notehead),this.vfpitch[1]=void 0,r}setIndex(e,t){this.vfnote=[e,t],this.vfnoteIndex=t}notehead(e=void 0){let t=e;t||(t=this.vfnote[0]);const i=t.note_heads;return i&&i.length>this.vfnoteIndex&&i[this.vfnoteIndex]?t.note_heads[this.vfnoteIndex]:{line:0}}Clef(){return this.clef}getSVGId(){if(this.vfnote)return this.vfnote[0].getAttribute("id")}getSVGGElement(){if(this.vfnote)return this.vfnote[0].getAttribute("el")}getStemSVG(){return document.getElementById("vf-"+this.getSVGId()+"-stem")}getBeamSVGs(){const e=[];for(let t=0;;t++){const i=document.getElementById(`vf-${this.getSVGId()}-beam${t}`);if(!i)break;e.push(i)}return e}}class ki extends ne{constructor(e,t,i,s,n,r){super(),this.chordSymbolContainer=e,this.boundingBox=new oe(this,t),this.rules=r,this.calculateLabel(i,n,s)}get GetChordSymbolContainer(){return this.chordSymbolContainer}get GraphicalLabel(){return this.graphicalLabel}calculateLabel(e,t,i){const s=ye.calculateChordText(this.chordSymbolContainer,t,i);this.graphicalLabel=new mt(new pt(s),e,this.rules.ChordSymbolTextAlignment,this.rules,this.boundingBox),this.graphicalLabel.PositionAndShape.RelativePosition=new z(this.rules.ChordSymbolRelativeXOffset,0),this.graphicalLabel.Label.colorDefault=this.rules.DefaultColorChordSymbol}}const Fi=n.Flow;class Oi extends Ci{constructor(e,t=void 0,i=void 0){super(e,t,i),this.isTabMeasure=!0}resetLayout(){var e;const t=null!==(e=this.ParentStaff.StafflineCount)&&void 0!==e?e:6;this.stave=new Fi.TabStave(0,0,0,{space_above_staff_ln:0,space_below_staff_ln:0,num_lines:t}),this.updateInstructionWidth()}graphicalMeasureCreatedCalculations(){for(let t=0,i=this.staffEntries.length;t1){const i=Jt.StrokeTypeFromArpeggioType(t.type),s=new Fi.Stroke(i,{all_voices:this.rules.ArpeggiosGoAcrossVoices});this.rules.RenderArpeggios&&e.vfStaveNote.addStroke(0,s)}else s.debug(`[OSMD] arpeggio in measure ${this.MeasureNumber} could not be drawn.\n voice entry had less than two notes, arpeggio is likely between voice entries, not currently supported in Vexflow.`)}if(e.vfGhostNotes)for(const i of e.vfGhostNotes)this.vfVoices[t.VoiceId].addTickable(i);else this.vfVoices[t.VoiceId].addTickable(e.vfStaveNote)}else if(e.vfGhostNotes)for(const i of e.vfGhostNotes)this.vfVoices[t.VoiceId].addTickable(i);else this.vfVoices[t.VoiceId].addTickable(e.vfStaveNote)}}}}class _i extends ne{constructor(e){super(),this.parentStaffLine=e;const t=e.PositionAndShape;this.boundingBox=new oe(this,t),this.boundingBox.BorderRight=6,this.boundingBox.BorderBottom=4.5,this.boundingBox.BorderLeft=-1.5,this.boundingBox.BorderTop=-1.5}}class Gi extends ne{constructor(e,t){super(),this.measures=[],this.staffLines=new Array(5),this.octaveShifts=[],this.lyricLines=[],this.lyricsDashes=[],this.abstractExpressions=[],this.graphicalSlurs=[],this.graphicalGlissandi=[],this.Pedals=[],this.WavyLines=[],this.parentMusicSystem=e,this.parentStaff=t,this.boundingBox=new oe(this,e.PositionAndShape),this.skyBottomLine=yi.symbolFactory.createSkyBottomLineCalculator(this),this.staffHeight=this.parentMusicSystem.rules.StaffHeight,this.topLineOffset=0,this.bottomLineOffset=4,this.calculateStaffLineOffsets()}calculateStaffLineOffsets(){if(this.ParentStaff.isTab)5===this.ParentStaff.StafflineCount?this.staffHeight=this.bottomLineOffset=6*this.ParentStaff.ParentInstrument.GetMusicSheet.Rules.TabStaffInterlineHeight:this.staffHeight=this.bottomLineOffset=this.ParentStaff.ParentInstrument.GetMusicSheet.Rules.TabStaffInterlineHeight*this.ParentStaff.StafflineCount;else switch(this.ParentStaff.StafflineCount){case 4:this.bottomLineOffset=1;break;case 3:this.topLineOffset=1,this.bottomLineOffset=1;break;case 2:this.topLineOffset=2,this.bottomLineOffset=1;break;case 1:this.topLineOffset=2,this.bottomLineOffset=2}}get Measures(){return this.measures}set Measures(e){this.measures=e}get StaffLines(){return this.staffLines}set StaffLines(e){this.staffLines=e}get Index(){return this.parentMusicSystem.StaffLines.indexOf(this)}get NextStaffLine(){const e=this.Index;return e!==this.parentMusicSystem.StaffLines.length?this.parentMusicSystem.StaffLines[e+1]:void 0}get LyricLines(){return this.lyricLines}get AbstractExpressions(){return this.abstractExpressions}set AbstractExpressions(e){this.abstractExpressions=e}set LyricLines(e){this.lyricLines=e}get LyricsDashes(){return this.lyricsDashes}set LyricsDashes(e){this.lyricsDashes=e}get ParentMusicSystem(){return this.parentMusicSystem}set ParentMusicSystem(e){this.parentMusicSystem=e}get ParentStaff(){return this.parentStaff}set ParentStaff(e){this.parentStaff=e}get SkyBottomLineCalculator(){return this.skyBottomLine}get SkyLine(){return this.skyBottomLine.SkyLine}get BottomLine(){return this.skyBottomLine.BottomLine}get OctaveShifts(){return this.octaveShifts}set OctaveShifts(e){this.octaveShifts=e}get StaffHeight(){return this.staffHeight}get TopLineOffset(){return this.topLineOffset}get BottomLineOffset(){return this.bottomLineOffset}get GraphicalSlurs(){return this.graphicalSlurs}get GraphicalGlissandi(){return this.graphicalGlissandi}addSlurToStaffline(e){this.graphicalSlurs.push(e)}addGlissandoToStaffline(e){this.graphicalGlissandi.push(e),e.StaffLine=this}addActivitySymbolClickArea(){const e=new _i(this),t=this.PositionAndShape;e.PositionAndShape.RelativePosition=new z(t.RelativePosition.x+t.BorderRight+.5,t.RelativePosition.y+.5),e.PositionAndShape.Parent=this.parentMusicSystem.PositionAndShape}isPartOfMultiStaffInstrument(){return this.parentStaff.ParentInstrument.Staves.length>1}findClosestStaffEntry(e){let t;for(let i=0,s=this.Measures.length;i0){var n,r;const e=o.map((e=>e.PositionAndShape.Center.y)),t=Math.max(...e),i=(null===(n=window.GYM)||void 0===n?void 0:n.noNeedContinuousDynamic)||!1,s=(null===(r=window.GYM)||void 0===r?void 0:r.noNeedGraphicalContinuousDynamic)||!1;for(let n=0;n0?o[n-1]:void 0;if(e){const t=this.getOverlap(r.PositionAndShape,e.PositionAndShape);r.squeeze(-(t.x+this.rules.DynamicExpressionSpacer))}if(t){const e=this.getOverlap(t.PositionAndShape,r.PositionAndShape);r.squeeze(e.x+this.rules.DynamicExpressionSpacer)}}}}}getDistance(e,t){const i=e.RelativePosition.x+e.BorderMarginRight,s=t.RelativePosition.x+t.BorderMarginLeft,n=e.RelativePosition.y+e.BorderMarginBottom,r=t.RelativePosition.y+t.BorderMarginTop;return new z(s-i,r-n)}getOverlap(e,t){return new z(e.RelativePosition.x+e.BorderMarginRight-(t.RelativePosition.x+t.BorderMarginLeft),e.RelativePosition.y+e.BorderMarginBottom-(t.RelativePosition.y+t.BorderMarginTop))}}class Xi extends Gi{constructor(e,t){super(e,t),this.slursInVFStaffLine=[],this.alignmentManager=new Ui(this)}get SlursInVFStaffLine(){return this.slursInVFStaffLine}addVFSlurToVFStaffline(e){this.slursInVFStaffLine.push(e)}get AlignmentManager(){return this.alignmentManager}}const zi=n.Flow;class Hi extends Ci{constructor(e,t=void 0,i=void 0){super(e,t,i),this.minimumStaffEntriesWidth=-1,i?this.rules=i.ParentMusicSystem.rules:t&&(this.rules=t.Rules),this.resetLayout(),this.multiRestElement=new zi.MultiMeasureRest(t.multipleRestMeasures,{})}draw(e){var t,i,s,n,r,o;const a=e.openGroup();null==a||null===(t=a.classList)||void 0===t||t.add("vf-measure"),null==a||a.setAttribute("data-num",String(null==this||null===(i=this.parentSourceMeasure)||void 0===i?void 0:i.MeasureNumberXML));const l=e.openGroup();null==l||null===(s=l.classList)||void 0===s||s.add("vf-stave"),null==l||l.setAttribute("id",null===(n=this.stave)||void 0===n||null===(r=n.attrs)||void 0===r?void 0:r.id),this.stave.setContext(e).draw(),e.closeGroup();const h=e.openGroup();null==h||null===(o=h.classList)||void 0===o||o.add("vf-voices"),this.multiRestElement.setStave(this.stave),this.multiRestElement.setContext(e),this.multiRestElement.draw(),e.closeGroup();for(const u of this.connectors)u.setContext(e).draw();return e.closeGroup(),a}format(){for(const i of this.staffEntries){var e,t;const s=this.PositionAndShape.Size.width-this.beginInstructionsWidth;i.PositionAndShape.RelativePosition.x=this.PositionAndShape.Size.width/2+this.beginInstructionsWidth/3,i.PositionAndShape.RelativePosition.y=0;const n=null===(e=i.graphicalVoiceEntries[0])||void 0===e||null===(t=e.notes[0])||void 0===t?void 0:t.PositionAndShape;n.BorderLeft=-s/3,n.BorderRight=s/3,n.BorderTop=2,n.BorderBottom=4,i.PositionAndShape.calculateBoundingBox()}}getVoicesWithinMeasure(){return[]}getGraphicalVoiceEntriesPerVoice(e){return[]}getRestFilledVexFlowStaveNotesPerVoice(e){return[]}handleBeam(e,t){}handleTuplet(e,t){}finalizeBeams(){}finalizeTuplets(){}layoutStaffEntry(e){}graphicalMeasureCreatedCalculations(){}createArticulations(){}createOrnaments(){}createFingerings(e){}getVFStave(){return this.stave}}class Yi{constructor(e,t){this.skyLine=e,this.bottomLine=t}}const ji=n.Flow;class Ki extends Wt{constructor(e){super(),this.rules=e}getVexflowBackendType(){return ji.Renderer.Backends.CANVAS}getOSMDBackendType(){return B.Canvas}getCanvasSize(){var e;return null===(e=document.getElementById("osmdCanvasPage"+this.graphicalMusicPage.PageNumber))||void 0===e?void 0:e.offsetHeight}initialize(e,t){this.zoom=t,this.canvas=document.createElement("canvas"),this.graphicalMusicPage||(this.graphicalMusicPage=new he(void 0),this.graphicalMusicPage.PageNumber=1),this.canvas.id="osmdCanvasVexFlowBackendCanvas"+this.graphicalMusicPage.PageNumber,this.inner=document.createElement("div"),this.inner.id="osmdCanvasPage"+this.graphicalMusicPage.PageNumber,this.inner.style.position="relative",this.canvas.style.zIndex="0",this.inner.appendChild(this.canvas),e.appendChild(this.inner),this.renderer=new ji.Renderer(this.canvas,this.getVexflowBackendType()),this.ctx=this.renderer.getContext()}initializeHeadless(e=300,t=300){this.graphicalMusicPage||(this.graphicalMusicPage=new he(void 0),this.graphicalMusicPage.PageNumber=1),this.canvas=document.createElement("canvas"),this.canvas.width=e,this.canvas.height=t,this.renderer=new ji.Renderer(this.canvas,this.getVexflowBackendType()),this.ctx=this.renderer.getContext()}getContext(){return this.ctx}free(){this.canvas&&(this.canvas.width=0,this.canvas.height=0,this.canvas.remove(),delete this.canvas,this.canvas=null)}clear(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.rules.PageBackgroundColor&&(this.ctx.save(),this.ctx.setFillStyle(this.rules.PageBackgroundColor),this.zoom=1,this.ctx.fillRect(0,0,this.canvas.width/this.zoom,this.canvas.height/this.zoom),this.ctx.restore())}scale(e){this.ctx.scale(e,e)}translate(e,t){this.CanvasRenderingCtx.translate(e,t)}renderText(e,t,i,s,n,r,o=void 0,a=void 0){const l=this.CanvasRenderingCtx.font;this.CanvasRenderingCtx.save(),this.CanvasRenderingCtx.font=Jt.font(e,t,i,this.rules,a),this.CanvasRenderingCtx.fillStyle=o,this.CanvasRenderingCtx.strokeStyle=o,this.CanvasRenderingCtx.fillText(s,r.x,r.y+n),this.CanvasRenderingCtx.restore(),this.CanvasRenderingCtx.font=l}renderRectangle(e,t,i,s=1){const n=this.CanvasRenderingCtx.fillStyle;this.CanvasRenderingCtx.fillStyle=i||Jt.style(t),this.CanvasRenderingCtx.globalAlpha=s,this.ctx.fillRect(e.x,e.y,e.width,e.height),this.CanvasRenderingCtx.fillStyle=n,this.CanvasRenderingCtx.globalAlpha=1}renderLine(e,t,i="#FF0000FF",s=2,n){const r=this.CanvasRenderingCtx.strokeStyle;this.CanvasRenderingCtx.strokeStyle=i,this.CanvasRenderingCtx.beginPath(),this.CanvasRenderingCtx.moveTo(e.x,e.y),this.CanvasRenderingCtx.lineTo(t.x,t.y),this.CanvasRenderingCtx.stroke(),this.CanvasRenderingCtx.strokeStyle=r}renderCurve(e){this.ctx.beginPath(),this.ctx.moveTo(e[0].x,e[0].y),this.ctx.bezierCurveTo(e[1].x,e[1].y,e[2].x,e[2].y,e[3].x,e[3].y),this.ctx.lineTo(e[7].x,e[7].y),this.ctx.bezierCurveTo(e[6].x,e[6].y,e[5].x,e[5].y,e[4].x,e[4].y),this.ctx.lineTo(e[0].x,e[0].y),this.ctx.closePath(),this.ctx.fill()}renderPath(e,t=!0,i){let s;this.ctx.beginPath();for(const n of e)s?this.ctx.lineTo(n.x,n.y):(this.ctx.moveTo(n.x,n.y),s=n);this.ctx.closePath(),t?this.ctx.fill():this.ctx.stroke()}get CanvasRenderingCtx(){return this.ctx.vexFlowCanvasContext}}class Ji{constructor(e){this.mStaffLineParent=e,this.mRules=e.ParentMusicSystem.rules}updateLines(e){const t=this.StaffLineParent.Measures;if(e.length!==t.length)if(s.warn("SkyBottomLineCalculator: lengths of calculation result array and measure array do not match"),e.length(e-a)/zt+this.StaffLineParent.TopLineOffset));const l=Math.min(...this.mBottomLine);this.mBottomLine=this.mBottomLine.map((e=>(e-l)/zt+this.StaffLineParent.BottomLineOffset))}calculateLines(){const e=Math.max(Math.ceil(this.StaffLineParent.PositionAndShape.Size.width*this.SamplingUnit),1);this.mSkyLine=[],this.mBottomLine=[];const t=new Ki(this.StaffLineParent.ParentMusicSystem.rules);for(const a of this.StaffLineParent.Measures){a.PositionAndShape.calculateAbsolutePositionsRecursive(0,0);const e=a.getVFStave();let i=e.getWidth();if(i>0||a.IsExtraGraphicalMeasure||(s.warn("SkyBottomLineCalculator: width not > 0 in measure "+a.MeasureNumber),i=50),!(i>=50)&&a.IsExtraGraphicalMeasure)continue;t.initializeHeadless(i);const n=t.getContext(),r=t.getCanvas();i=r.width;const l=r.height;"jianpu"===this.mRules.DYMusicScoreType||e.setY(e.y+100);const h=e.getWidth();e.setWidth(i),a.format(),e.setWidth(h);try{a.draw(n)}catch(o){s.warn("SkyBottomLineCalculator.calculateLines.draw",o)}const u=n.getImageData(0,0,i,l),c=4,d=Math.max(Math.ceil(a.PositionAndShape.Size.width*this.mRules.SamplingUnit),1),f=new Array(d),m=new Array(d);for(let t=0;t0){f[t]=e;break}}for(let e=l;e>0;e--){const s=e*i*c+t*c;if(u.data[s+3]>0){m[t]=e;break}}}for(let t=0;t(e-Math.max(...this.mSkyLine))/zt+this.StaffLineParent.TopLineOffset)),this.mBottomLine=this.mBottomLine.map((e=>(e-Math.min(...this.mBottomLine))/zt+this.StaffLineParent.BottomLineOffset))}updateSkyLineWithLine(e,t,i){const s=Math.floor(e.x*this.SamplingUnit),n=Math.ceil(t.x*this.SamplingUnit);for(let r=s+1;r=this.BottomLine.length&&(i=this.BottomLine.length-1),s<0&&(s=0),s>=this.BottomLine.length&&(s=this.BottomLine.length),this.SkyLine[i]=e.y;for(let r=i+1;r=this.BottomLine.length&&(i=this.BottomLine.length-1),s<0&&(s=0),s>=this.BottomLine.length&&(s=this.BottomLine.length),this.BottomLine[i]=e.y;for(let r=i+1;re))}setBottomLineWithValue(e){this.BottomLine.forEach((t=>e))}getLeftIndexForPointX(e,t){const i=Math.floor(e*this.SamplingUnit);return i<0?0:i>=t?t-1:i}getRightIndexForPointX(e,t){const i=Math.ceil(e*this.SamplingUnit);return i<0?0:i>=t?t-1:i}updateStaffLineBorders(){this.mStaffLineParent.PositionAndShape.BorderTop=this.getSkyLineMin(),this.mStaffLineParent.PositionAndShape.BorderMarginTop=this.getSkyLineMin(),this.mStaffLineParent.PositionAndShape.BorderBottom=this.getBottomLineMax(),this.mStaffLineParent.PositionAndShape.BorderMarginBottom=this.getBottomLineMax()}getSkyLineMin(){return Math.min(...this.SkyLine.filter((e=>!isNaN(e))))}getSkyLineMinAtPoint(e){const t=Math.round(e*this.SamplingUnit);return this.mSkyLine[t]}getSkyLineMinInRange(e,t){return this.getMinInRange(this.SkyLine,e,t)}getBottomLineMax(){return Math.max(...this.BottomLine.filter((e=>!isNaN(e))))}getBottomLineMaxAtPoint(e){const t=Math.round(e*this.SamplingUnit);return this.mBottomLine[t]}getBottomLineMaxInRange(e,t){return this.getMaxInRange(this.BottomLine,e,t)}getBottomLineMaxInBoundingBox(e){const t=Math.floor(e.AbsolutePosition.x+e.BorderLeft),i=Math.ceil(e.AbsolutePosition.x+e.BorderRight);return this.getMaxInRange(this.mBottomLine,t,i)}updateWithBoundingBoxRecursively(e){if(e.ChildElements&&e.ChildElements.length>0)for(const t of e.ChildElements)this.updateWithBoundingBoxRecursively(t);else{const t=e.BorderTop+e.AbsolutePosition.y,i=e.BorderBottom+e.AbsolutePosition.y;if(t<0){const i=Math.floor(e.AbsolutePosition.x+e.BorderLeft),s=Math.ceil(e.AbsolutePosition.x+e.BorderRight);this.updateInRange(this.mSkyLine,i,s,t)}else if(i>this.StaffLineParent.StaffHeight){const t=Math.floor(e.AbsolutePosition.x+e.BorderLeft),s=Math.ceil(e.AbsolutePosition.x+e.BorderRight);this.updateInRange(this.mBottomLine,t,s,i)}}}findPreviousValidNumber(e,t){for(let i=e;i>=0;i--)if(!isNaN(t[i]))return t[i];return 0}findNextValidNumber(e,t){if(e>=t.length)return t[e-1];for(let i=e;ie.length&&(i=e.length);for(let n=t;nMath.abs(e[n])?s:e[n]}setInRange(e,t=0,i=e.length,s=0){if(t=Math.floor(t*this.SamplingUnit),(i=Math.ceil(i*this.SamplingUnit))e.length&&(i=e.length);for(let n=t;n=e.length&&(t=e.length-1),i<0&&(i=0),i>=e.length&&(i=e.length),t>=0&&i<=e.length?Math.min(...e.slice(t,i+1)):void 0):Number.MAX_VALUE}getMaxInRange(e,t,i){return t=Math.floor(t*this.SamplingUnit),i=Math.ceil(i*this.SamplingUnit),e?(t<0&&(t=0),t>=e.length&&(t=e.length-1),i<0&&(i=0),i>=e.length&&(i=e.length),t>=0&&i<=e.length?Math.max(...e.slice(t,i+1)):void 0):Number.MIN_VALUE}get SamplingUnit(){return this.mRules.SamplingUnit}get StaffLineParent(){return this.mStaffLineParent}get SkyLine(){return this.mSkyLine}get BottomLine(){return this.mBottomLine}}class qi extends Ji{recursiveUpdate(e,t,i,s){const n=e.getBBox(),r=n.y/zt,o=n.height/zt+r,[l,h]=s;if(rt.bottom)switch(e.tagName.toLowerCase()){case"g":for(const n of e.children)this.recursiveUpdate(n,t,i,s);break;case"circle":case"rect":case"line":case"path":let u=Math.floor((n.x-i.x)/zt*this.mRules.SamplingUnit);const c=u+Math.ceil(n.width/zt*this.mRules.SamplingUnit);if(e.parentElement.classList.contains("vf-beams")&&e.hasAttribute("d")){const t=a(e.getAttribute("d"));if(5===t.length){const e=t[0],i=t[3],s=(i.end.y-e.end.y)/(i.end.x-e.end.x);let n=e.end.y/zt;for(;u<=c;u++)nh[u]&&(h[u]=n),n+=s/this.mRules.SamplingUnit}}else for(;u<=c;u++)rh[u]&&(h[u]=o)}}calculateLinesForMeasure(e,t){var i,s;const n=t.getBBox(),r=Math.max(Math.round(e.PositionAndShape.Size.width*this.mRules.SamplingUnit),1),o=n.height/zt,a=t.getElementsByClassName("vf-stave")[0].getBBox();let l=(null==a?void 0:a.height)/zt,h=(null==a?void 0:a.y)/zt;const u=e.getVFStave();let c=(null!==(i=u.options)&&void 0!==i&&i.num_lines?u.options.num_lines:5)-1,d=-1,f=0;const m=[c];for(const P of null===(p=u.options)||void 0===p?void 0:p.line_config){var p;P.visible?(-1===d&&(d=f),m.push(f)):c--,f++}-1===d&&(d=0),c=m.pop()-d;const g=null===(s=u.options)||void 0===s?void 0:s.spacing_between_lines_px,S=c*g/zt;l-S>.2&&(l=S,h=d*g/zt);const y=h+l,b=new Array(r).fill(h),M=new Array(r).fill(y),v=[b,M];if(o>l)for(const P of t.children)this.recursiveUpdate(P,{top:h,bottom:y},n,[b,M]);return v}calculateLines(){this.mSkyLine=[],this.mBottomLine=[];const e=document.createElement("div");document.body.append(e);const t=new Xt(this.mRules);t.initialize(e,1,"0");const i=t.getContext(),s=i.openGroup();s.classList.add("staffline");for(const n of this.StaffLineParent.Measures){n.PositionAndShape.calculateAbsolutePositionsRecursive(0,0),n.setAbsoluteCoordinates(n.PositionAndShape.AbsolutePosition.x*zt,n.PositionAndShape.AbsolutePosition.y*zt);const e=n.draw(i),[t,s]=this.calculateLinesForMeasure(n,e);this.mSkyLine.push(...t),this.mBottomLine.push(...s)}i.closeGroup();for(const n of s.getElementsByClassName("vf-ties"))for(const e of n.childNodes)if("path"===e.nodeName.toLowerCase()){const t=e.getBBox();let i=Math.floor(t.x/zt*this.mRules.SamplingUnit);const s=i+Math.ceil(t.width/zt*this.mRules.SamplingUnit),n=t.y/zt,r=t.height/zt+n;for(;i<=s;i++)nthis.mBottomLine[i]&&(this.mBottomLine[i]=r)}t.clear(),e.remove()}}const $i=n.Flow;class Qi{constructor(){this.hasBBox=!1,void 0!==document.createElementNS("http://www.w3.org/2000/svg","g").getBBox&&(this.hasBBox=!0)}createMusicSystem(e,t){return new wi(e,t)}createStaffLine(e,t){return new Xi(e,t)}createSkyBottomLineCalculator(e){return e.ParentMusicSystem.rules.PerformanceMode&&this.hasBBox?new qi(e):new Ji(e)}createGraphicalMeasure(e,t,i=!1){return new Ci(t,e,void 0)}createMultiRestMeasure(e,t,i){return new Hi(t,e,i)}createTabStaffMeasure(e,t){return new Oi(t,e)}createExtraGraphicalMeasure(e){const t=new Ci(e.ParentStaff,void 0,e);return t.IsExtraGraphicalMeasure=!0,t.ExtraGraphicalMeasurePreviousMeasure=e.Measures.last(),t}createStaffEntry(e,t){return new Di(t,e,void 0)}createVoiceEntry(e,t){return new Ii(e,t)}createNote(e,t,i,s=$t.NONE,n,r=void 0){return new Vi(e,t,i,s,n,r)}createGraceNote(e,t,i,s,n=$t.NONE){return new Vi(e,t,i,n,s)}addGraphicalAccidental(e,t){e.setAccidental(t)}addFermataAtTiedEndNote(e,t){}createInStaffClef(e,t){const i=e,s=Jt.Clef(t,"small");i.vfClefBefore=new $i.ClefNote(s.type,s.size,s.annotation)}createChordSymbols(e,t,i,s){const n=t.parentMeasure.parentSourceMeasure.Rules;let r=0;const o=n.ChordSymbolXSpacing;for(const a of e.ChordContainers){let e=t.PositionAndShape;1===t.graphicalVoiceEntries.length&&1===t.graphicalVoiceEntries[0].notes.length&&t.graphicalVoiceEntries[0].notes[0].sourceNote.isWholeRest()&&(e=t.parentMeasure.PositionAndShape,r+=t.parentMeasure.beginInstructionsWidth,r+=n.ChordSymbolWholeMeasureRestXOffset);const l=new ki(a,e,n.ChordSymbolTextHeight,i,s,t.parentMeasure.parentSourceMeasure.Rules),h=l.GraphicalLabel;h.PositionAndShape.RelativePosition.y-=n.ChordSymbolYOffset,h.setLabelPositionAndShapeBorders();let u=0;h.PositionAndShape.Size.width=4&&e.Parent.Notes[0].Length.Denominator>4&&ce.LeftBottom;const a=new pt(e.Text);a.isLyricText=!0,a.lyricExtendNoteId=null==e||null===(n=e.Parent)||void 0===n||null===(r=n.Notes[0])||void 0===r?void 0:r.NoteToGraphicalNoteObjectId,a.lyricVerseNumber=null==e?void 0:e.verseNumber;const l=this.graphicalStaffEntry.parentMeasure.parentSourceMeasure.Rules;this.graphicalLabel=new mt(a,i,o,l,t.PositionAndShape),this.graphicalLabel.Label.colorDefault=l.DefaultColorLyrics,this.graphicalLabel.PositionAndShape.RelativePosition=new z(0,s),this.graphicalLabel.setLabelPositionAndShapeBorders(),this.graphicalLabel.PositionAndShape.Size.width1&&e10*(i.endMeasure.PositionAndShape.AbsolutePosition.x+i.endMeasure.PositionAndShape.Size.width),getGlyph:()=>({getWidth:()=>0})}),e&&(t=e);const s=new ss.TextBracket({position:this.position,start:this.startNote,stop:t,superscript:this.supscript,text:this.text});return this.endsOnDifferentStaffLine&&(s.render_options.show_bracket=!1),s}}class rs extends kt{constructor(e,t,i){super(e,t,i);const s=new pt(this.Expression);this.label=new mt(s,this.rules.ContinuousDynamicTextHeight,ce.CenterCenter,this.rules,this.PositionAndShape),this.label.Label.fontStyle=me.BoldItalic,this.label.setLabelPositionAndShapeBorders(),this.PositionAndShape.calculateBoundingBox()}get InstantaneousDynamic(){return this.mInstantaneousDynamicExpression}get Expression(){return P[this.mInstantaneousDynamicExpression.DynEnum]}}const os=class{constructor(){os.tPow3=new Array(os.bezierCurveStepSize),os.oneMinusTPow3=new Array(os.bezierCurveStepSize),os.bezierFactorOne=new Array(os.bezierCurveStepSize),os.bezierFactorTwo=new Array(os.bezierCurveStepSize);for(let e=0;e=os.bezierCurveStepSize?new z:new z(os.oneMinusTPow3[t]*this.bezierStartPt.x+os.bezierFactorOne[t]*this.bezierStartControlPt.x+os.bezierFactorTwo[t]*this.bezierEndControlPt.x+os.tPow3[t]*this.bezierEndPt.x,os.oneMinusTPow3[t]*this.bezierStartPt.y+os.bezierFactorOne[t]*this.bezierStartControlPt.y+os.bezierFactorTwo[t]*this.bezierEndControlPt.y+os.tPow3[t]*this.bezierEndPt.y)}};let as=os;as.bezierCurveStepSize=1e3;const ls=n.Flow,hs=class extends as{constructor(e,t){super(),this.staffEntries=[],this.slur=e,this.rules=t}static Compare(e,t){if(e.staffEntries.length<1)return-1;if(t.staffEntries.length<1)return 1;const i=u.minus(e.staffEntries[e.staffEntries.length-1].getAbsoluteTimestamp(),e.staffEntries[0].getAbsoluteTimestamp()),s=u.minus(t.staffEntries[t.staffEntries.length-1].getAbsoluteTimestamp(),t.staffEntries[0].getAbsoluteTimestamp());return i.RealValue>s.RealValue?1:s.RealValue>i.RealValue?-1:0}calculateCurve(e){const t=this.staffEntries[0],i=this.staffEntries[this.staffEntries.length-1];let s=t.findGraphicalNoteFromNote(this.slur.StartNote);!s&&this.graceStart&&(s=t.findGraphicalNoteFromGraceNote(this.slur.StartNote)),s||(s=t.findEndTieGraphicalNoteFromNoteWithStartingSlur(this.slur.StartNote,this.slur));let n=i.findGraphicalNoteFromNote(this.slur.EndNote);!n&&this.graceEnd&&(n=i.findGraphicalNoteFromGraceNote(this.slur.EndNote));const r=t.parentMeasure.ParentStaffLine,o=r.SkyBottomLineCalculator;this.calculatePlacement(o,r);const a=this.calculateStartAndEnd(s,n,r,e,o),l=a.startX,h=a.endX;let u=a.startY,c=a.endY;const f=e.SlurTangentMinAngle,m=e.SlurTangentMaxAngle;let p;if(this.placement===d.Above){u-=e.SlurNoteHeadYOffset,c-=e.SlurNoteHeadYOffset;const t=new z(this.staffEntries[0].parentMeasure.PositionAndShape.RelativePosition.x+this.staffEntries[0].PositionAndShape.RelativePosition.x,u);s?t.x+=this.staffEntries[0].PositionAndShape.BorderRight:t.x=this.staffEntries[0].parentMeasure.beginInstructionsWidth,this.graceStart&&(t.x+=i.PositionAndShape.RelativePosition.x);const a=new z(this.staffEntries[this.staffEntries.length-1].parentMeasure.PositionAndShape.RelativePosition.x+this.staffEntries[this.staffEntries.length-1].PositionAndShape.RelativePosition.x,c);if(n?a.x+=this.staffEntries[this.staffEntries.length-1].PositionAndShape.BorderLeft:a.x=this.staffEntries[this.staffEntries.length-1].parentMeasure.PositionAndShape.RelativePosition.x+this.staffEntries[this.staffEntries.length-1].parentMeasure.PositionAndShape.Size.width,this.graceEnd&&(a.x+=i.staffEntryParent.PositionAndShape.RelativePosition.x),p=this.calculateTopPoints(t,a,r,o),0===p.length){const e=new z((a.x-t.x)/2+t.x,(a.y-t.y)/2+t.y);p.push(e)}const d=Math.atan((c-u)/(h-l)),g=new z(0,0);let S=new z(h-l,-(c-u));const y=Be.getRotationMatrix(d),b=y.getTransposeMatrix();S=y.vectorMultiplication(S);const M=this.calculateTranslatedAndRotatedPointListAbove(p,l,u,y),v=this.calculateMaxLeftSlope(M,g,S),P=this.calculateMaxRightSlope(M,g,S),E=g.y-g.x*v,L=S.y-S.x*P,x=new z;let T=!1;Math.abs(Math.abs(v)-Math.abs(P))<1e-4?(x.x=S.x/2,x.y=0,T=!0):(x.x=(L-E)/(v-P),x.y=v*x.x+E);const w=this.calculateHeightWidthRatio(S.x,M),I=0,A=0;let R=f,N=-f;if(!T){const e=this.calculateAngles(f,v,P,m);R=e.startAngle,N=e.endAngle}const C=this.calculateControlPoints(S.x,R,N,M,w,u,c);let B=C.startControlPoint,D=C.endControlPoint;B=b.vectorMultiplication(B),B.x+=l,B.y=-B.y+u,D=b.vectorMultiplication(D),D.x+=l,D.y=-D.y+u,this.bezierStartPt=new z(l,u-I),this.bezierStartControlPt=new z(B.x,B.y-I),this.bezierEndControlPt=new z(D.x,D.y-A),this.bezierEndPt=new z(h,c-A);const V=r.SkyLine.length,k=o.getLeftIndexForPointX(this.bezierStartPt.x,V),F=o.getLeftIndexForPointX(this.bezierEndPt.x,V),O=this.bezierEndPt.x-this.bezierStartPt.x,_=o.SamplingUnit;for(let e=k;e=k&&(r.SkyLine[s]=Math.min(r.SkyLine[s],i.y)),s++,s=k&&(r.BottomLine[s]=Math.max(r.BottomLine[s],i.y)),s++,s0)return void(this.placement=d.Above);const i=this.staffEntries[0],s=this.staffEntries[this.staffEntries.length-1],n=i.graphicalVoiceEntries[0].parentVoiceEntry.StemDirection;if(n===s.graphicalVoiceEntries[0].parentVoiceEntry.StemDirection)this.placement=n===dt.Up?d.Below:d.Above,this.rules.SlurPlacementAtStems&&(this.placement=n===dt.Up?d.Above:d.Below);else{let n=i.PositionAndShape.BorderLeft+i.PositionAndShape.RelativePosition.x+i.parentMeasure.PositionAndShape.RelativePosition.x,r=s.PositionAndShape.BorderRight+s.PositionAndShape.RelativePosition.x+s.parentMeasure.PositionAndShape.RelativePosition.x;this.graceStart&&(n+=s.PositionAndShape.RelativePosition.x),this.graceEnd&&(r+=s.staffEntryParent.PositionAndShape.RelativePosition.x);const o=-1*e.getSkyLineMinInRange(n,r),a=e.getBottomLineMaxInRange(n,r)-t.StaffHeight;this.placement=a>o?d.Above:d.Below}}calculateTopPoints(e,t,i,s){const n=[];let r=s.getRightIndexForPointX(e.x,i.SkyLine.length),o=s.getLeftIndexForPointX(t.x,i.SkyLine.length);r<0&&(r=0),o>=i.SkyLine.length&&(o=i.SkyLine.length-1);for(let a=r;a=i.BottomLine.length&&(o=i.BottomLine.length-1);for(let a=r;ah&&e>u&&(l+=e/70*this.rules.SlurHeightFlattenLongSlursFactorByWidth,l*=1+t/30*this.rules.SlurHeightFlattenLongSlursFactorByAngle,a/=l);const c=Math.min(.5,Math.max(.1,1.7*t/80*a*Math.pow(Math.max(n,.05),.4))),d=Math.min(.5,Math.max(.1,1.7*-i/80*a*Math.pow(Math.max(n,.05),.4))),f=new z;f.x=e*c*Math.cos(t*hs.degreesToRadiansFactor),f.y=e*c*Math.sin(t*hs.degreesToRadiansFactor);const m=new z;m.x=e-e*d*Math.cos(i*hs.degreesToRadiansFactor),m.y=-e*d*Math.sin(i*hs.degreesToRadiansFactor);let p=f.y-m.y;for(;this.rules.SlurMaximumYControlPointDistance&&Math.abs(p)>this.rules.SlurMaximumYControlPointDistance;)p<0?(f.y+=1,m.y-=1):(f.y-=1,m.y+=1),p=f.y-m.y;return{startControlPoint:f,endControlPoint:m}}calculateAngles(e,t,i,s){let n=Math.atan(t)/hs.degreesToRadiansFactor;t>0?n+=20:n-=20;let r=Math.atan(i)/hs.degreesToRadiansFactor;return i<0?r-=20:r+=20,{startAngle:Math.min(Math.max(e,n),s),endAngle:Math.max(Math.min(-e,r),-s)}}};let us=hs;us.degreesToRadiansFactor=Math.PI/180;class cs{constructor(e){this.staffPitchListMapping=new i,this.baseLineNote=H.B,this.baseLineOctave=1,this.rules=e}trackNote(e){if(!(e instanceof Vi)||e.Clef().ClefType!==q.percussion||e.sourceNote.isRest()||0===this.rules.PercussionOneLineCutoff||-1===this.rules.PercussionForceVoicesOneLineCutoff)return;const t=e.parentVoiceEntry.parentStaffEntry.sourceStaffEntry.ParentStaff.idInMusicSheet;let i;this.staffPitchListMapping.containsKey(t)||this.staffPitchListMapping.setValue(t,new Array),i=this.staffPitchListMapping.getValue(t);const s=e.sourceNote.Pitch;cs.findOrInsert(i,s)}static PitchIndexOf(e,t,i=0){if(i>e.length-1)return-1;for(let s=i;sthis.rules.PercussionOneLineCutoff&&!s&&!this.rules.PercussionUseCajon2NoteSystem)return e;const n=e,r=e.sourceNote.Pitch;let o=this.baseLineNote,a=this.baseLineOctave;if(this.rules.PercussionUseCajon2NoteSystem?r.FundamentalNote===H.C&&(o=H.G,a=1):this.rules.PercussionUseXMLDisplayStep&&void 0!==e.sourceNote.displayStepUnpitched&&(o=e.sourceNote.displayStepUnpitched,a=e.sourceNote.displayOctaveUnpitched+this.rules.PercussionOneLineXMLDisplayStepOctaveOffset),i.length<=this.rules.PercussionForceVoicesOneLineCutoff)n.setAccidental(new K(o,a,r.Accidental));else{const e=cs.PitchIndexOf(i,r);if(e>-1){const t=Math.ceil(i.length/2);if(!this.rules.PercussionUseXMLDisplayStep)if(e>=t)switch(a=2,(e-t)%5){case 1:o=H.E;break;case 2:o=H.G;break;case 3:o=H.B;break;case 4:o=H.D,a=3;break;default:o=H.C}else switch(e%5){case 1:o=H.F;break;case 2:o=H.D;break;case 3:o=H.B,a=0;break;case 4:o=H.G,a=0;break;default:o=H.A}const s=new K(o,a,r.Accidental);n.setAccidental(s);const l=n.parentVoiceEntry.parentVoiceEntry;!this.rules.SetWantedStemDirectionByXml&&l.Notes.length<2&&(s.Octave>this.baseLineOctave||s.FundamentalNote===this.baseLineNote&&s.Octave===this.baseLineOctave?n.parentVoiceEntry.parentVoiceEntry.WantedStemDirection=dt.Up:n.parentVoiceEntry.parentVoiceEntry.WantedStemDirection=dt.Down)}}return n}getStafflineUniquePositionCount(e){return this.staffPitchListMapping.containsKey(e)?this.staffPitchListMapping.getValue(e).length:0}}class ds extends ne{constructor(e,t){super(),this.getPedal=e,this.setSymbol(),this.PositionAndShape=new oe(this,t)}setSymbol(){!this.getPedal.IsLine&&this.getPedal.IsSign?this.pedalSymbol=It.PEDAL_SYMBOL:this.getPedal.IsLine&&this.getPedal.IsSign?this.pedalSymbol=It.PEDAL_MIXED:this.pedalSymbol=It.PEDAL_BRACKET}}class fs extends ds{constructor(e,t,i=!1,s=!1){switch(super(e,t),this.vfStyle=n.Flow.PedalMarking.Styles.BRACKET,this.ChangeBegin=!1,this.ChangeEnd=!1,this.line=-3,this.EndSymbolPositionAndShape=void 0,this.ChangeBegin=e.ChangeBegin,this.ChangeEnd=e.ChangeEnd,this.pedalSymbol){case It.PEDAL_SYMBOL:this.vfStyle=n.Flow.PedalMarking.Styles.TEXT,this.EndSymbolPositionAndShape=new oe(this,t);break;case It.PEDAL_MIXED:this.vfStyle=i&&s?n.Flow.PedalMarking.Styles.BRACKET_OPEN_BOTH:i?n.Flow.PedalMarking.Styles.BRACKET_OPEN_BEGIN:s?n.Flow.PedalMarking.Styles.MIXED_OPEN_END:n.Flow.PedalMarking.Styles.MIXED;break;case It.PEDAL_BRACKET:default:this.vfStyle=i&&s?n.Flow.PedalMarking.Styles.BRACKET_OPEN_BOTH:i?n.Flow.PedalMarking.Styles.BRACKET_OPEN_BEGIN:s?n.Flow.PedalMarking.Styles.BRACKET_OPEN_END:n.Flow.PedalMarking.Styles.BRACKET}}setStartNote(e){if(!e)return!1;for(const t of e.graphicalVoiceEntries){const e=t;if(null!=e&&e.vfStaveNote)return this.startNote=e.vfStaveNote,this.startVfVoiceEntry=e,!0}return!1}setEndNote(e){if(!e)return!1;for(const t of e.graphicalVoiceEntries){const e=t;if(null!=e&&e.vfStaveNote)return this.endNote=e.vfStaveNote,this.endVfVoiceEntry=e,!0}return!1}setEndMeasure(e){this.endMeasure=e}CalculateBoundingBox(){}setLine(e){this.line=e}getPedalMarking(){const e=new n.Flow.PedalMarking([this.startNote,this.endNote]);return this.endMeasure&&e.setEndStave(this.endMeasure.getVFStave()),e.setStyle(this.vfStyle),e.setLine(this.line),e.setCustomText(this.DepressText,this.ReleaseText),this.endVfVoiceEntry&&!this.getPedal.EndsStave||(e.EndsStave=!0),this.getPedal.BeginsStave&&(e.BeginsStave=!0),e.ChangeBegin=this.ChangeBegin,e.ChangeEnd=this.ChangeEnd,e}setEndsStave(e,t){null!=t&&t.gte(e.parentSourceMeasure.Duration)&&(this.getPedal.EndsStave=!0)}setBeginsStave(e,t){e&&0===t.RealValue&&(this.getPedal.BeginsStave=!0)}}class ms{constructor(e){this.Glissando=e,this.staffEntries=[]}calculateLine(e){const t=this.staffEntries[0],i=this.staffEntries[this.staffEntries.length-1],s=t.findGraphicalNoteFromNote(this.Glissando.StartNote),n=i.findGraphicalNoteFromNote(this.Glissando.EndNote);if(!s&&!n)return;const r=t.parentMeasure.ParentStaffLine;let o,a,l,h;if(s&&t.parentMeasure.ParentStaffLine===this.StaffLine)o=s.PositionAndShape.RelativePosition.x+s.parentVoiceEntry.parentStaffEntry.PositionAndShape.RelativePosition.x+s.parentVoiceEntry.parentStaffEntry.parentMeasure.PositionAndShape.RelativePosition.x+e.GlissandoNoteOffset,l=s.PositionAndShape.AbsolutePosition.y;else{o=i.parentMeasure.beginInstructionsWidth-.4;const t=this.Glissando.Direction===ae.Down?-1:1;l=n.PositionAndShape.AbsolutePosition.y+t*e.GlissandoStafflineStartYDistanceToNote}if(n&&i.parentMeasure.ParentStaffLine===this.StaffLine)a=n.PositionAndShape.RelativePosition.x+n.parentVoiceEntry.parentStaffEntry.PositionAndShape.RelativePosition.x+n.parentVoiceEntry.parentStaffEntry.parentMeasure.PositionAndShape.RelativePosition.x-.5-e.GlissandoNoteOffset,o>a&&(o=a-e.GlissandoStafflineStartMinimumWidth),h=n.PositionAndShape.AbsolutePosition.y;else{if(r.Measures.last().parentSourceMeasure.HasEndLine)return;a=r.PositionAndShape.Size.width,a-o>e.GlissandoStafflineEndOffset&&(o=a-e.GlissandoStafflineEndOffset);const t=this.Glissando.Direction===ae.Down?1:-1;h=s.PositionAndShape.AbsolutePosition.y+t*e.GlissandoStafflineStartYDistanceToNote}const u=new z(o,l),c=new z(a,h);void 0===this.Width&&(this.Width=e.GlissandoDefaultWidth),this.Line=new X(u,c,this.Width)}}class ps extends ms{}class gs extends ne{constructor(e,t){super(),this.getWavyLine=e,this.PositionAndShape=new oe(this,t)}}class Ss extends gs{constructor(e,t,i=!1){super(e,t),this.line=1,this.isVibrato=!1,this.toEndOfStopStave=!1,this.isVibrato=i}get ToEndOfStopStave(){return this.toEndOfStopStave}setStartNote(e){for(const t of e.graphicalVoiceEntries){const e=t;if(null!=e&&e.vfStaveNote)return this.startNote=e.vfStaveNote,this.startVfVoiceEntry=e,!0}return!1}setEndNote(e){for(const t of e.graphicalVoiceEntries){const e=t;if(null!=e&&e.vfStaveNote){this.endNote=e.vfStaveNote,this.endVfVoiceEntry=e;const t=this.endVfVoiceEntry.parentStaffEntry.parentMeasure.staffEntries,i=t[t.length-1];return this.toEndOfStopStave=i===this.endVfVoiceEntry.parentStaffEntry,!0}}return!1}CalculateBoundingBox(){const e=this.getVibratoBracket();this.boundingBox.Size.height=.2*e.render_options.wave_height}getVibratoBracket(){const e=new n.Flow.VibratoBracket({start:this.startNote,stop:this.endNote,toEndOfStopStave:this.toEndOfStopStave});return e.setLine(this.line),this.isVibrato?e.render_options.vibrato_width=20:e.render_options.wave_girth=4,e}}const ys=n.Flow;class bs extends yi{constructor(e){var t,i,s,r,o;if(super(),this.beamsNeedUpdate=!1,this.rules=e,yi.symbolFactory=new Qi,yi.TextMeasurer=new Bt(this.rules),yi.stafflineNoteCalculator=new cs(this.rules),"gonville"===(null===(t=this.rules.DefaultVexFlowNoteFont)||void 0===t?void 0:t.toLowerCase()))n.Flow.DEFAULT_FONT_STACK=[null===(s=n.Flow.Fonts)||void 0===s?void 0:s.Gonville,null===(r=n.Flow.Fonts)||void 0===r?void 0:r.Bravura,null===(o=n.Flow.Fonts)||void 0===o?void 0:o.Custom];else if("petaluma"===(null===(i=this.rules.DefaultVexFlowNoteFont)||void 0===i?void 0:i.toLowerCase())){var a,l,h;n.Flow.DEFAULT_FONT_STACK=[null===(a=n.Flow.Fonts)||void 0===a?void 0:a.Petaluma,null===(l=n.Flow.Fonts)||void 0===l?void 0:l.Gonville,null===(h=n.Flow.Fonts)||void 0===h?void 0:h.Bravura]}}clearRecreatedObjects(){super.clearRecreatedObjects(),yi.stafflineNoteCalculator=new cs(this.rules);for(const e of this.graphicalMusicSheet.MeasureList)for(const t of e)null==t||t.clean()}formatMeasures(){for(const e of this.graphicalMusicSheet.MeasureList)if(e&&e[0]){e.find((e=>null==e?void 0:e.isVisible())).format();for(const t of e){for(const e of t.staffEntries)e.calculateXPosition();t.finalizeBeams()}}this.beamsNeedUpdate=!1}calculateMeasureXLayout(e){const t=[];for(const s of e)null!=s&&s.isVisible()&&t.push(s);if(0===t.length)return 0;e=t;const i=[],n=new ys.Formatter({softmaxFactor:this.rules.SoftmaxFactorVexFlow});let r=e[0].staffEntries.length,o=1;for(const h of e){if(!h)continue;let e=0;for(const i of h.staffEntries)e+=i.setMaxAccidentals();h.parentSourceMeasure.ImplicitMeasure&&(r=Math.max(h.staffEntries.length,r),o=Math.max(h.staffEntries.length+e,o));const t=h.vfVoices,a=[];for(const s in t)if(t.hasOwnProperty(s)){const e=t[s];h.hasOnlyRests&&!e.ticksUsed.equals(e.totalTicks)&&(e.ticksUsed=e.totalTicks),a.push(e),i.push(e)}0!==a.length?n.joinVoices(a):s.debug("Found a measure with no voices. Continuing anyway.",t)}let a=12;const l=e[0].parentSourceMeasure;if(i.length>0){if(a=n.preCalculateMinTotalWidth(i)/zt*this.rules.VoiceSpacingMultiplierVexflow+this.rules.VoiceSpacingAddendVexflow+.3*r,null!=l&&l.ImplicitMeasure){a=l.Duration.RealValue/l.ActiveTimeSignature.RealValue*a;let e=0;const t=l.measureListIndex;if(t>1)for(const i of this.graphicalMusicSheet.MeasureList[t-1]){const t=null==i?void 0:i.parentSourceMeasure.endingBarStyleEnum;if(t===Ne.ThinBold||t===Ne.DotsThinBold){e=this.rules.PickupMeasureRepetitionSpacing;break}}a+=e,r>1?a+=.3*o*1.5:t>1&&1===r&&(a+=this.rules.PickupMeasureSpacingSingleNoteAddend),a*=this.rules.PickupMeasureWidthMultiplier}yi.setMeasuresMinStaffEntriesWidth(e,a);const t=(e,t)=>{n.formatToStave(i,t.getVFStave())},s=(e,t)=>{n.formatToStave(i,t.getVFStave(),{align_rests:!0,context:void 0})};for(const i of e){if(this.rules.AlignRests===N.Never)i.formatVoices=t;else if(this.rules.AlignRests===N.Always)i.formatVoices=s;else if(this.rules.AlignRests===N.Auto){let e=!1;for(const t of i.staffEntries){let i=0,s=0;for(const n of t.graphicalVoiceEntries)if(n.parentVoiceEntry.IsGrace||n&&n.notes&&n.notes[0]&&n.notes[0].sourceNote&&n.notes[0].sourceNote.PrintObject&&i++,n&&n.notes&&n.notes[0]&&n.notes[0].sourceNote&&n.notes[0].sourceNote.isRest()&&n.notes[0].sourceNote.PrintObject&&s++,i>1&&s>=1){e=!0;break}if(e)break}i.formatVoices=e?s:t}if(i===e[0]){const e=i;e.formatVoices(a*zt,e)}}}for(const s of e)if(s)for(const e of s.staffEntries)e.calculateXPosition();for(const h of e){if(!h)continue;const e=h.vfVoices,t=[];for(const i in e)e.hasOwnProperty(i)&&t.push(e[i]);0!==t.length?n.joinVoices(t):s.debug("Found a measure with no voices. Continuing anyway.",e)}return a}calculateElongationFactor(e,t,i,s,n,r,o,a){let l=n,h=0;for(const u of e){const e=u.GraphicalLabel.Label.textAlignment;let c=o,d=a;if(u instanceof es&&u.ParentLyricWord){u.LyricsEntry.SyllableIndex>0&&(c=this.rules.BetweenSyllableMinimumDistance,de.IsCenterAligned(e)&&(c+=1));const t=u.ParentLyricWord.GetLyricWord.Syllables;t.length>1&&u.LyricsEntry.SyllableIndex4&&(E*=1.1)):i[h]&&(E=p/g),v=Math.max(P,E),l=Math.max(l,v);let L=Math.max(p-g||0,0);i[h]&&(L+=i[h].cumulativeOverlap),i[h]={cumulativeOverlap:L,extend:u instanceof es&&u.LyricsEntry.extend,labelWidth:m,measureNumber:r,sourceNoteDuration:u instanceof es&&u.LyricsEntry&&u.LyricsEntry.Parent.Notes[0].Length,text:u instanceof es?u.LyricsEntry.Text:u.GraphicalLabel.Label.text,xPosition:b},h++}return l}calculateElongationFactorFromStaffEntries(e,t,i,s){let n=i;const r={},o={};for(const a of e)a.LyricsEntries.length>0&&this.rules.RenderLyrics&&(n=this.calculateElongationFactor(a.LyricsEntries,a,r,t,n,s,this.rules.HorizontalBetweenLyricsDistance,this.rules.LyricOverlapAllowedIntoNextMeasure)),a.graphicalChordContainers.length>0&&this.rules.RenderChordSymbols&&(n=this.calculateElongationFactor(a.graphicalChordContainers,a,o,t,n,s,this.rules.ChordSymbolXSpacing,this.rules.ChordOverlapAllowedIntoNextMeasure));return n}calculateMeasureWidthFromStaffEntries(e,t){var i;let s=1;if(!(null===(i=window.GYM)||void 0===i?void 0:i.multitrack))for(const n of e)n&&0!==n.staffEntries.length&&(s=this.calculateElongationFactorFromStaffEntries(n.staffEntries,t,s,n.MeasureNumber),s=1);return s=Math.min(s,this.rules.MaximumLyricsElongationFactor),t*s}createGraphicalTie(e,t,i,s,n){return new Zi(e,s,n)}updateStaffLineBorders(e){e.SkyBottomLineCalculator.updateStaffLineBorders()}graphicalMeasureCreatedCalculations(e){e.rules=this.rules,e.graphicalMeasureCreatedCalculations()}layoutVoiceEntry(e,t,i,s){for(let n=0;n=2&&(r=s.vfnote[0],a=s.vfnote[1]);let l=0;if(n&&n.vfnote&&n.vfnote.length>=2&&(o=n.vfnote[0],l=n.vfnote[1]),t){if(r){const t=new ys.StaveTie({first_indices:[a],first_note:r}),i=s.parentVoiceEntry.parentStaffEntry.parentMeasure;if(o){var h,u,c;"w"===o.getDuration()&&(null===(h=o.keyProps)||void 0===h||null===(u=h[0])||void 0===u?void 0:u.line)>=3&&o.setStemDirection(-1);let e=(null===(c=window.GYM)||void 0===c?void 0:c.tieDirection)||0;var f,m;1===Math.abs(e)&&((null===(f=o.keyProps)||void 0===f||null===(m=f[0])||void 0===m?void 0:m.line)>=3?o.setStemDirection(-e):o.setStemDirection(e)),null==t||t.setDirection(o.getStemDirection())}if(i.vfTies.length>0){const e=i.vfTies[0].direction;null==t||t.setDirection(e?-e:1)}i.addStaveTie(t,e)}if(o){const t=new ys.StaveTie({last_indices:[l],last_note:o}),i=n.parentVoiceEntry.parentStaffEntry.parentMeasure;if(i.vfTies.length>0){const e=i.vfTies[0].direction;null==t||t.setDirection(e?-e:1)}i.addStaveTie(t,e)}}else if(r||o){var p;let t;if(i)if("S"===e.Tie.Type){const i=e.StartNote.sourceNote,s=e.EndNote.sourceNote;let n=1;i.FretNumber>s.FretNumber&&(n=-1),t=new ys.TabSlide({first_indices:[a],first_note:r,last_indices:[l],last_note:o},n)}else t=new ys.TabTie({first_indices:[a],first_note:r,last_indices:[l],last_note:o},e.Tie.Type);else{t=new ys.StaveTie({first_indices:[a],first_note:r,last_indices:[l],last_note:o});const i=e.Tie.getTieDirection(s.sourceNote);i===d.Below?t.setDirection(1):i===d.Above&&t.setDirection(-1)}const h=n.parentVoiceEntry.parentStaffEntry.parentMeasure,u=(null===(p=window.GYM)||void 0===p?void 0:p.graceCustom)||!1;u&&t.setDirection(u.direction),h.addStaveTie(t,e)}}calculateDynamicExpressionsForMultiExpression(e,t,i){if(tthis.rules.MaxMeasureToDrawIndex)return;const n=e.AbsoluteTimestamp,r=this.graphicalMusicSheet.MeasureList[t],o=r[i].ParentStaffLine,a=r[i];if(!o)return;const l=e.StartingContinuousDynamic,h=void 0!==l&&!l.IsStartOfSoftAccent,u=this.getRelativePositionInStaffLineFromTimestamp(n,i,o,null==o?void 0:o.isPartOfMultiStaffInstrument(),void 0,h);if(u.x<=0&&(u.x=a.beginInstructionsWidth+this.rules.RhythmRightMargin),e.InstantaneousDynamic){const t=new rs(e.InstantaneousDynamic,o,a);this.calculateGraphicalInstantaneousDynamicExpression(t,u,n),this.dynamicExpressionMap.set(n.RealValue,t.PositionAndShape)}if(l){const t=new Wi(l,o,a.parentSourceMeasure);if(t.StartMeasure=a,t.IsSoftAccent=e.StartingContinuousDynamic.IsStartOfSoftAccent,!t.IsVerbal&&l.EndMultiExpression)try{this.calculateGraphicalContinuousDynamic(t,u),t.updateSkyBottomLine()}catch(c){}else t.IsVerbal?this.calculateGraphicalVerbalContinuousDynamic(t,u):s.warn("This continuous dynamic is not covered. measure"+e.SourceMeasureParent.MeasureNumber)}}createMetronomeMark(e,t){var i,s,n,r,o;const a=Math.max(e.ParentMultiTempoExpression.SourceMeasureParent.MeasureNumber-1,0),l=t||a,h=Math.max(e.StaffNumber-1,0),u=this.graphicalMusicSheet.MeasureList[l][h].getVFStave();let c="q";if(e.beatUnit){const t=He.getNoteDurationFromType(e.beatUnit);c=Jt.durations(t,!1)[0]}let f=this.rules.MetronomeMarkYShift,m=!1;const p=[];if(e.parentMeasure){for(const t of e.parentMeasure.StaffLinkedExpressions)for(const e of t)e&&e instanceof ni&&p.push(e);for(const t of e.parentMeasure.TempoExpressions){var g;const i=(null===(g=t.InstantaneousTempo)||void 0===g?void 0:g.Enum)===ti.metronomeMark;if(!e.beatUnit&&t.InstantaneousTempo.beatUnit){const t=He.getNoteDurationFromType(e.beatUnit);c=Jt.durations(t,!1)[0]}if(t.getPlacementOfFirstEntry()===d.Above&&!i){m=!0;break}}}m&&(f-=1.4);const S=null===(i=this.graphicalMusicSheet.MeasureList[0][0].ParentStaffLine)||void 0===i?void 0:i.SkyLine;let y=e.TempoInBpm,b="",M="",v="";for(const d of this.graphicalMusicSheet.MeasureList[l][h].parentSourceMeasure.TempoExpressions){if(M=d.CombinedExpressionsText,Tt(d.CombinedExpressionsText)){b=d.CombinedExpressionsText;break}if(Lt(d.CombinedExpressionsText)||xt(d.CombinedExpressionsText)){b=d.CombinedExpressionsText.replace(Et,"").replace(Pt,""),y=d.sourceMeasure.TempoInBPM,Lt(d.CombinedExpressionsText)&&(v=c);break}}const P={bpm:e.TempoInBpm,dots:e.dotted,duration:c,name:b};b&&(P.bpm=y/1,Lt(M)?P.duration=v:y!==gt[b]&>[b]||(P.duration=""));const E=(null===(s=this.graphicalMusicSheet.MeasureList[l][h])||void 0===s||null===(n=s.vfVoices)||void 0===n||null===(r=n[1])||void 0===r||null===(o=r.boundingBox)||void 0===o?void 0:o.y)||0;if(this.rules.MetronomeMarksDrawn){if(S){var L,x;const e=(null===(L=this.graphicalMusicSheet.MeasureList[0])||void 0===L||null===(x=L[h])||void 0===x?void 0:x.ParentStaffLine).Measures.map((e=>e.MeasureNumber-1));if(E&&e.includes(l)&&(Lt(M)||xt(M))){const e=S.slice(0,9);let t=Math.min(...e);t=t<0?t-1:t,f+=t}e.includes(l)&&p.length?S[0]=Math.min(S[0],-4.5+f-4):S[0]=Math.min(S[0],-4.5+f)}u.options.line_config.reduce(((e,t)=>(t.visible&&e++,e)),0)<5&&(f-=2),u.setTempo(P,f*zt);let e=-3;u.getModifiers()[u.getModifiers().length-1].setShiftX(e)}}calculateRehearsalMark(e){var t,i,s,n,r,o;const a=e.rehearsalExpression;if(!a)return;const l=null===(t=e.VerticalMeasureList)||void 0===t||null===(i=t[0])||void 0===i||null===(s=i.getVFStave)||void 0===s?void 0:s.call(i);if(!l)return;const h=-this.rules.RehearsalMarkYOffsetDefault-this.rules.RehearsalMarkYOffset;let u=this.rules.RehearsalMarkXOffsetDefault+this.rules.RehearsalMarkXOffset;e.IsSystemStartMeasure&&(u+=this.rules.RehearsalMarkXOffsetSystemStartMeasure);const c=this.rules.RehearsalMarkFontSize,d=l.getModifiers(),f=d.find((e=>"repetitions"===e.getCategory().toLocaleLowerCase()));if(f&&f.setShiftY(f.y_shift-10),l.setSection(a.label,h,u,c),null!==(n=e.VerticalMeasureList)&&void 0!==n&&null!==(r=n[0])&&void 0!==r&&null!==(o=r.ParentStaffLine)&&void 0!==o&&o.AbstractExpressions){const t=d.find((e=>"stavesection"===e.getCategory().toLocaleLowerCase()));for(let i of(null==e||null===(m=e.VerticalMeasureList)||void 0===m||null===(p=m[0])||void 0===p||null===(g=p.ParentStaffLine)||void 0===g?void 0:g.AbstractExpressions)||[]){var m,p,g;i instanceof _t&&(t&&(i.Label.PositionAndShape.RelativePosition.y-=.5),f&&(i.Label.PositionAndShape.RelativePosition.y-=1.7))}}}calculateSingleOctaveShift(e,t,i,n){var r;const o=t.OctaveShiftStart,a=o.ParentStartMultiExpression.Timestamp,l=null===(r=o.ParentEndMultiExpression)||void 0===r?void 0:r.Timestamp,h=this.rules.MinMeasureToDrawIndex,u=this.rules.MaxMeasureToDrawIndex;let c,d,f=this.graphicalMusicSheet.MeasureList[i][n].ParentStaffLine;if(f||(f=this.graphicalMusicSheet.MeasureList[h][n].ParentStaffLine),c=o.ParentEndMultiExpression?this.graphicalMusicSheet.getGraphicalMeasureFromSourceMeasureAndIndex(o.ParentEndMultiExpression.SourceMeasureParent,n):this.graphicalMusicSheet.getLastGraphicalMeasureFromIndex(n,!0),c.MeasureNumber>u+1&&(c=this.graphicalMusicSheet.getLastGraphicalMeasureFromIndex(n,!0)),d=o.ParentEndMultiExpression?this.graphicalMusicSheet.getGraphicalMeasureFromSourceMeasureAndIndex(o.ParentStartMultiExpression.SourceMeasureParent,n):this.graphicalMusicSheet.MeasureList[h][n],d.MeasureNumberu||c.parentSourceMeasure.measureListIndexu)return;let m=c.ParentStaffLine;if(m||(m=f),c&&f&&m){const e=new ns(o,f.PositionAndShape);if(!e.startNote){let t;for(const e of d.staffEntries)if(e){t=e;break}if(!t)return;if(e.setStartNote(t),!e.startNote)return}if(!e.endNote){let t;for(let e=c.staffEntries.length-1;e>=0;e++)if(c.staffEntries[e]){t=c.staffEntries[e];break}if(!t)return void(e.graphicalEndAtMeasureEnd=!0);if(e.setEndNote(t),!e.endNote)return}let t=d.findGraphicalStaffEntryFromTimestamp(a);t||(t=d.staffEntries[0]);let i=c.findGraphicalStaffEntryFromTimestamp(l);if(i||(i=c.staffEntries[c.staffEntries.length-1]),e.setStartNote(t),m!==f){e.endsOnDifferentStaffLine=!0;let r=this.findLastStafflineMeasure(f);void 0===r&&(r=c);const a=r.staffEntries[r.staffEntries.length-1];e.setEndNote(a),e.graphicalEndAtMeasureEnd=!0,e.endMeasure=r;const l=m.ParentMusicSystem.Id-f.ParentMusicSystem.Id;if(l>0)for(let e=f.ParentMusicSystem.Id;e=0;t--){const i=e.Measures[t];if(i.staffEntries.length>0)return i}}calculateSinglePedal(e,t,i,n){var r;const o=t.PedalStart,a=o.ParentStartMultiExpression.Timestamp,l=null===(r=o.ParentEndMultiExpression)||void 0===r?void 0:r.Timestamp,h=this.rules.MinMeasureToDrawIndex,u=this.rules.MaxMeasureToDrawIndex;let c,d,f=this.graphicalMusicSheet.MeasureList[i][n].ParentStaffLine;if(f||(f=this.graphicalMusicSheet.MeasureList[h][n].ParentStaffLine),c=o.ParentEndMultiExpression?this.graphicalMusicSheet.getGraphicalMeasureFromSourceMeasureAndIndex(o.ParentEndMultiExpression.SourceMeasureParent,n):this.graphicalMusicSheet.getLastGraphicalMeasureFromIndex(n,!0),c||(c=o.ParentStartMultiExpression.SourceMeasureParent.VerticalMeasureList[n]),c.MeasureNumber>u+1&&(c=this.graphicalMusicSheet.getLastGraphicalMeasureFromIndex(n,!0)),o.ParentEndMultiExpression?d=this.graphicalMusicSheet.getGraphicalMeasureFromSourceMeasureAndIndex(o.ParentStartMultiExpression.SourceMeasureParent,n):(d=this.graphicalMusicSheet.getGraphicalMeasureFromSourceMeasureAndIndex(o.ParentStartMultiExpression.SourceMeasureParent,n),d||(d=this.graphicalMusicSheet.MeasureList[h][n])),d.MeasureNumberu||c.parentSourceMeasure.measureListIndexu)return;let m=c.ParentStaffLine;if(m||(m=f),c&&f&&m){let e=!1;f!==m&&(e=!0);const t=new fs(o,f.PositionAndShape,!1,e);t.setEndsStave(c,l);let i=d.findGraphicalStaffEntryFromTimestamp(a);i||(i=d.staffEntries[0]);let s=c.findGraphicalStaffEntryFromTimestamp(l);if(s||(s=c.staffEntries[c.staffEntries.length-1]),!t.setStartNote(i))return;if(t.setBeginsStave(t.startNote.isRest(),a),m!==f)if(t.pedalSymbol===It.PEDAL_SYMBOL){t.setEndNote(s),t.setEndMeasure(c),t.ReleaseText=" ",t.CalculateBoundingBox(),this.calculatePedalSkyBottomLine(t.startVfVoiceEntry,t.endVfVoiceEntry,t,f);const e=m.Measures[0],i=new fs(o,e.PositionAndShape);t.setEndsStave(c,l);const n=e.staffEntries[0];if(!i.setStartNote(n))return;i.setEndNote(s),i.setEndMeasure(c),t.setEndMeasure(c),m.Pedals.push(i),i.CalculateBoundingBox(),i.DepressText=" ",this.calculatePedalSkyBottomLine(i.startVfVoiceEntry,i.endVfVoiceEntry,i,m)}else{let e=this.findLastStafflineMeasure(f);void 0===e&&(e=c);const i=e.staffEntries[e.staffEntries.length-1];t.setEndNote(i),t.setEndMeasure(c),t.ChangeEnd=!1;const r=m.ParentMusicSystem.Id-f.ParentMusicSystem.Id;if(r>0){let e=1;for(let i=f.ParentMusicSystem.Id;iu+1&&(c=this.graphicalMusicSheet.getLastGraphicalMeasureFromIndex(n,!0)),d=o.ParentEndMultiExpression?this.graphicalMusicSheet.getGraphicalMeasureFromSourceMeasureAndIndex(o.ParentStartMultiExpression.SourceMeasureParent,n):this.graphicalMusicSheet.MeasureList[h][n],d.MeasureNumberu||c.parentSourceMeasure.measureListIndexu)return;let m=c.ParentStaffLine;if(m||(m=f),c&&f&&m){const e=new Ss(o,f.PositionAndShape,d.ParentStaff.isTab);let t=d.findGraphicalStaffEntryFromTimestamp(a);t||(t=d.staffEntries[0]);let i=c.findGraphicalStaffEntryFromTimestamp(l);if(i||(i=c.staffEntries[c.staffEntries.length-1]),e.setStartNote(t),m!==f){let t=f.Measures[f.Measures.length-1];void 0===t&&(t=c);const s=t.staffEntries[t.staffEntries.length-1];if(e.setEndNote(s),m.ParentMusicSystem.Id-f.ParentMusicSystem.Id>0)for(let e=f.ParentMusicSystem.Id;eu){const e=u;u=c,c=e}s.SkyBottomLineCalculator.updateBottomLineInRange(c,u,d+e)}for(const n of s.Pedals){const e=n,t=e.getPedalMarking();if(d>t.line+3+(s.StaffLines.length-1)){var m;const i=t.render_options.text_margin_right/10;let n,r=e.startVfVoiceEntry.PositionAndShape.AbsolutePosition.x-i;e.setLine(d-3-(s.StaffLines.length-1));let l=null===(m=e.endVfVoiceEntry)||void 0===m?void 0:m.PositionAndShape;if(l||(l=e.endMeasure.PositionAndShape),e.EndSymbolPositionAndShape){const e=a.render_options.glyph_point_size/20;n=r+3.4;const t=l.AbsolutePosition.x-i,o=t+1.5;s.SkyBottomLineCalculator.updateBottomLineInRange(r,n,d+e),s.SkyBottomLineCalculator.updateBottomLineInRange(t,o,d+e)}else{var p,g;const h=t.render_options.bracket_height/10;if(t.EndsStave)n=l.AbsolutePosition.x+l.Size.width-i;else switch(a.style){case o.BRACKET_OPEN_END:case o.BRACKET_OPEN_BOTH:case o.MIXED_OPEN_END:n=l.AbsolutePosition.x+l.BorderRight-i;break;default:n=l.AbsolutePosition.x+l.BorderLeft-i}const u=null===(p=e.endVfVoiceEntry)||void 0===p||null===(g=p.parentStaffEntry)||void 0===g?void 0:g.vfClefBefore;if(u&&(n+=u.getWidth()/10),r>n){const e=r;r=n,n=e}s.SkyBottomLineCalculator.updateBottomLineInRange(r,n,d+h)}}}}calculateOctaveShiftSkyBottomLine(e,t,i,n){if(!t)return void s.warn("octaveshift: no endStaffEntry");let r=t.PositionAndShape;i.graphicalEndAtMeasureEnd&&(r=t.parentMeasure.PositionAndShape);let o=e.PositionAndShape.Size.width,a=r.Size.width;e.hasOnlyRests()?o=-o:o/=2,i.graphicalEndAtMeasureEnd||(t.hasOnlyRests()?a*=2:a/=2,e===t&&(a*=2));let l=e.PositionAndShape.AbsolutePosition.x-o,h=r.AbsolutePosition.x+a;if(l>h){const e=l;l=h,h=e}i.PositionAndShape.Size.width=h-l;const u=i.getTextBracket(),c=u.font.size/10;if(u.position===ys.TextBracket.Positions.TOP){const e=Math.ceil(n.SkyBottomLineCalculator.getSkyLineMinInRange(l,h));if(e===1/0)return;u.start.getStave().options.top_text_position=Math.abs(e),n.SkyBottomLineCalculator.updateSkyLineInRange(l,h,e-2*c)}else{const i=n.SkyBottomLineCalculator.getBottomLineMaxInRange(l,h);if(i===1/0)return;u.start.getStave().options.bottom_text_position=i,e.parentMeasure!==t.parentMeasure&&(u.stop.getStave().options.bottom_text_position=i),n.SkyBottomLineCalculator.updateBottomLineInRange(l,h,i+1.5*c)}}calculateWordRepetitionInstruction(e,t){let i;const s=this.graphicalMusicSheet.MeasureList[t];for(let n=0,r=s.length;ne.StaffLines)));let t=0;for(const i of e)for(const e of i.Measures)e&&t++;this.rules.AlwaysSetPreferredSkyBottomLineBackendAutomatically&&this.rules.setPreferredSkyBottomLineBackendAutomatically(t);for(const i of e)i.SkyBottomLineCalculator.calculateLines()}calculateExpressionAlignements(){for(const t of this.musicSystems)for(const i of t.StaffLines)try{i.AlignmentManager.alignDynamicExpressions(),i.AbstractExpressions.forEach((e=>{e.updateSkyBottomLine()}))}catch(e){}}handleTiedGraphicalNote(e,t,i,s,n,r,o,a){}handleBeam(e,t,i){e.parentVoiceEntry.parentStaffEntry.parentMeasure.handleBeam(e,t)}handleVoiceEntryLyrics(e,t,i){e.LyricsEntries.forEach(((e,s)=>{const n=new es(s,t,this.rules.LyricsHeight,this.rules.StaffHeight);if(t.LyricsEntries.push(n),n.GraphicalLabel.setLabelPositionAndShapeBorders(),s.Word){const e=s.Word.Syllables.indexOf(s);let t=i.indexOf(s.Word);if(-1===t&&(i.push(s.Word),t=i.indexOf(s.Word)),0===this.graphicalLyricWords.length||t>this.graphicalLyricWords.length-1){const t=new ts(s.Word);n.ParentLyricWord=t,t.GraphicalLyricsEntries[e]=n,this.graphicalLyricWords.push(t)}else{const s=this.graphicalLyricWords[t];n.ParentLyricWord=s,s.GraphicalLyricsEntries[e]=n,s.isFilled()&&(i.splice(t,1),this.graphicalLyricWords.splice(this.graphicalLyricWords.indexOf(s),1))}}}))}handleVoiceEntryOrnaments(e,t,i){}handleVoiceEntryArticulations(e,t,i){}handleVoiceEntryTechnicalInstructions(e,t,i){}handleTuplet(e,t,i){e.parentVoiceEntry.parentStaffEntry.parentMeasure.handleTuplet(e,t)}findIndexGraphicalSlurFromSlur(e,t){for(let i=0;i=0){const e=t[i];-1===e.staffEntries.indexOf(s)&&e.staffEntries.push(s),t.splice(i,1)}}}for(const e of t)-1===e.staffEntries.indexOf(s)&&e.staffEntries.push(s)}}for(const t of this.musicSystems)for(const e of t.StaffLines){const t=e.GraphicalSlurs.sort(us.Compare);for(const e of t)e.slur.isCrossed()||e.calculateCurve(this.rules)}}calculateGlissandi(){const e={};for(const t of this.graphicalMusicSheet.MeasureList[0])e[t.ParentStaff.idInMusicSheet]=[];for(const t of this.musicSystems)for(const i of t.StaffLines){const t=e[i.ParentStaff.idInMusicSheet];for(let e=0;e=0){const e=t[i];-1===e.staffEntries.indexOf(s)&&e.staffEntries.push(s),t.splice(i,1)}}}}for(const e of t)-1===e.staffEntries.indexOf(s)&&e.staffEntries.push(s)}}for(const t of this.musicSystems)for(const e of t.StaffLines)for(const t of e.GraphicalGlissandi)if(e.ParentStaff.isTab){const e=t.Glissando.StartNote,i=t.Glissando.EndNote,s=t.staffEntries[0].findGraphicalNoteFromNote(e),n=t.staffEntries.last().findGraphicalNoteFromNote(i);if(!s&&!n)return;let r,o,a,l,h=1;e.FretNumber>i.FretNumber&&(h=-1),s&&s.vfnote&&s.vfnote.length>=2&&(a=s.vfnote[0],r=[0]),n&&n.vfnote&&n.vfnote.length>=2&&(l=n.vfnote[0],o=[0]);const u=new ys.TabSlide({first_indices:r,first_note:a,last_indices:o,last_note:l},h),c=null==s?void 0:s.parentVoiceEntry.parentStaffEntry.parentMeasure;c&&(c.vfTies.push(u),t.vfTie=u);const d=null==n?void 0:n.parentVoiceEntry.parentStaffEntry.parentMeasure;d&&(d.vfTies.push(u),t.vfTie=u)}}}class Ms{constructor(e){this.musicSheet=e}reInit(){this.init()}init(){this.parts=this.musicSheet.Repetitions.slice(),this.sheetStart=this.musicSheet.SelectionStart=new u(0,1),this.sheetEnd=this.musicSheet.SelectionEnd=this.musicSheet.SheetEndTimestamp,this.calcMapping()}getCurrentRepetitionTimestampTransform(e){let t;for(let i=this.timestamps.length-1;i>=0;i--)if(t=this.timestamps[i],e.gte(t.from))return t;return this.timestamps[0]}absoluteEnrolledToSheetTimestamp(e){if(0===this.timestamps.length)return e;const t=this.getCurrentRepetitionTimestampTransform(e);return u.plus(e,u.minus(t.to,t.from))}get Parts(){return this.parts}get MusicSheet(){return this.musicSheet}getIterator(e){return e?new w(this.musicSheet,e,void 0):new w(this.musicSheet,this.musicSheet.SelectionStart,this.musicSheet.SelectionEnd)}setSelectionStart(e){this.musicSheet.SelectionStart=e,this.musicSheet.SelectionEnd=void 0}setSelectionRange(e,t){this.musicSheet.SelectionStart=null!=e?e:this.sheetStart,this.musicSheet.SelectionEnd=null!=t?t:this.sheetEnd}calcMapping(){this.timestamps=[];const e=this.getIterator();let t=e.CurrentRepetition,i=new vs(e.CurrentEnrolledTimestamp.clone(),e.CurrentSourceTimestamp.clone(),void 0,0);for(this.timestamps.push(i);!e.EndReached;){if(e.JumpOccurred||t!==e.CurrentRepetition){if(t=e.CurrentRepetition,e.backJumpOccurred){const t=e.JumpResponsibleRepetition;i.nextBackJump=e.CurrentEnrolledTimestamp,i.curRepetition=t,i.curRepetitionIteration=e.CurrentJumpResponsibleRepetitionIterationBeforeJump;for(let e=this.timestamps.length-2;e>=0&&!t.AbsoluteTimestamp.gt(this.timestamps[e].to)&&!this.timestamps[e].curRepetition;e--)this.timestamps[e].nextBackJump=i.nextBackJump,this.timestamps[e].curRepetition=t,this.timestamps[e].curRepetitionIteration=i.curRepetitionIteration}i=new vs(e.CurrentEnrolledTimestamp.clone(),e.CurrentSourceTimestamp.clone(),void 0,0),this.timestamps.push(i)}e.moveToNext()}}}class vs{constructor(e,t,i,s){this.from=e,this.to=t,this.curRepetition=i,this.curRepetitionIteration=s,this.nextBackJump=void 0,this.nextForwardJump=void 0}}class Ps{constructor(e){this.enrolledTimestamps=[],this.visible=!0,this.musicSheet=e}get Visible(){return this.visible}set Visible(e){this.visible=e}getFirstSourceMeasure(){return this.musicSheet.SourceMeasures[this.startIndex]}getLastSourceMeasure(){return this.musicSheet.SourceMeasures[this.endIndex]}}class Es extends Ps{constructor(e,t,i){super(e),this.musicSheet=e,this.startIndex=t,this.endIndex=i}get MeasuresCount(){return this.endIndex-this.startIndex+1}get StartIndex(){return this.startIndex}get EndIndex(){return this.endIndex}get ParentRepetition(){return this.parentRepetition}set ParentRepetition(e){this.parentRepetition=e}get AbsoluteTimestamp(){return u.createFromFraction(this.musicSheet.SourceMeasures[this.startIndex].AbsoluteTimestamp)}setStartIndex(e){this.startIndex=e}setEndIndex(e){this.endIndex=e}}class Ls extends Ps{constructor(e,t=!1){super(e),this.backwardJumpInstructions=[],this.endingParts=[],this.endingIndexDict={},this.userNumberOfRepetitions=0,this.visibles=[],this.fromWords=!1,this.repetitonIterationOrder=[],this.numberOfEndings=1,this.musicSheet2=e,this.virtualOverallRepetition=t}get BackwardJumpInstructions(){return this.backwardJumpInstructions}get EndingIndexDict(){return this.endingIndexDict}get EndingParts(){return this.endingParts}get Visibles(){return this.visibles}set Visibles(e){this.visibles=e}get DefaultNumberOfRepetitions(){let e=2;return this.virtualOverallRepetition&&(e=1),Math.max(e,Object.keys(this.endingIndexDict).length,this.checkRepetitionForMultipleLyricVerses())}get UserNumberOfRepetitions(){return this.userNumberOfRepetitions}set UserNumberOfRepetitions(e){this.userNumberOfRepetitions=e,this.repetitonIterationOrder=[];const t=this.userNumberOfRepetitions-this.NumberOfEndings;for(let i=1;i<=this.userNumberOfRepetitions;i++)i<=t?this.repetitonIterationOrder.push(1):this.repetitonIterationOrder.push(i-t)}getForwardJumpTargetForIteration(e){const t=this.repetitonIterationOrder[e-1];return this.endingIndexDict[t]?this.endingIndexDict[t].part.StartIndex:-1}getBackwardJumpTarget(){return this.startMarker.measureIndex}setEndingsStartIndex(e,t){const i=new xs(new Es(this.musicSheet2,t,t));this.endingParts.push(i);for(const r of e)try{this.endingIndexDict[r]=i,i.endingIndices.push(r),this.numberOfEndings0&&(s=1),n.Add(new u(s,t)),n}}class ws{constructor(){this.idString="uninitialized",this.sourceMeasures=[],this.repetitions=[],this.dynListStaves=[],this.timestampSortedDynamicExpressionsList=[],this.timestampSortedTempoExpressionsList=[],this.instrumentalGroups=[],this.instruments=[],this.musicPartManager=void 0,this.musicSheetErrors=new De,this.staves=[],this.playbackDataDict=new i,this.transpose=0,this.defaultStartTempoInBpm=0,this.drawErroneousMeasures=!1,this.hasBeenOpenedForTheFirstTime=!1,this.currentEnrolledPosition=new u(0,1),this.MeasureWidthFactor=1,this.soundTempos=new Map,this.userStartTempoInBPM=100,this.playbackSettings=new Ts(new u(4,4,0,!1),this.userStartTempoInBPM),this.pageWidth=120,this.MusicPartManager=new Ms(this),this.hasBPMInfo=!1}get SoundTempos(){return this.soundTempos}set SoundTempos(e){this.soundTempos=e}static getIndexFromStaff(e){return e.idInMusicSheet}get CurrentKeyInstruction(){return this.currentKeyInstruction}set CurrentKeyInstruction(e){this.currentKeyInstruction=e}get SourceMeasures(){return this.sourceMeasures}set SourceMeasures(e){this.sourceMeasures=e}get Repetitions(){return this.repetitions}set Repetitions(e){this.repetitions=e}get DynListStaves(){return this.dynListStaves}get TimestampSortedTempoExpressionsList(){return this.timestampSortedTempoExpressionsList}get TimestampSortedDynamicExpressionsList(){return this.timestampSortedDynamicExpressionsList}get InstrumentalGroups(){return this.instrumentalGroups}get Parts(){return this.instruments}get Instruments(){return this.instruments}get SheetPlaybackSetting(){return this.playbackSettings}set SheetPlaybackSetting(e){this.playbackSettings=e}get DrawErroneousMeasures(){return this.drawErroneousMeasures}set DrawErroneousMeasures(e){this.drawErroneousMeasures=e}get HasBeenOpenedForTheFirstTime(){return this.hasBeenOpenedForTheFirstTime}set HasBeenOpenedForTheFirstTime(e){this.hasBeenOpenedForTheFirstTime=e}InitializeStartTempoInBPM(e){this.playbackSettings.BeatsPerMinute=e,this.userStartTempoInBPM=e}get DefaultStartTempoInBpm(){return this.defaultStartTempoInBpm}set DefaultStartTempoInBpm(e){this.defaultStartTempoInBpm=e,this.InitializeStartTempoInBPM(e)}get Path(){return this.path}set Path(e){this.path=e}get Staves(){return this.staves}get TitleString(){return this.title?this.title.text:""}set TitleString(e){this.Title=new pt(e)}get SubtitleString(){return this.subtitle?this.subtitle.text:""}set SubtitleString(e){this.Subtitle=new pt(e)}get ComposerString(){return this.composer?this.composer.text:""}set ComposerString(e){this.Composer=new pt(e)}get LyricistString(){return this.lyricist?this.lyricist.text:""}set LyricistString(e){this.Lyricist=new pt(e)}get CopyrightString(){return this.copyright?this.copyright.text:""}set CopyrightString(e){this.Copyright=new pt(e,ce.CenterBottom,void 0,!0)}get Title(){return this.title}set Title(e){this.title=e}get Subtitle(){return this.subtitle}set Subtitle(e){this.subtitle=e}get Composer(){return this.composer}set Composer(e){this.composer=e}get Lyricist(){return this.lyricist}set Lyricist(e){this.lyricist=e}get Copyright(){return this.copyright}set Copyright(e){this.copyright=e}get Rules(){return this.rules||(s.debug("warning: sheet.Rules was undefined. Creating new EngravingRules."),this.rules=new xe),this.rules}set Rules(e){this.rules=e}get SheetErrors(){return this.musicSheetErrors}get PlaybackDataDict(){return this.playbackDataDict}get SelectionStart(){return this.selectionStart}set SelectionStart(e){this.selectionStart=e.clone(),this.currentEnrolledPosition=e.clone()}get SelectionEnd(){return this.selectionEnd}set SelectionEnd(e){this.selectionEnd=e}set HasBPMInfo(e){this.hasBPMInfo=e}get HasBPMInfo(){return this.hasBPMInfo}addMeasure(e){this.sourceMeasures.push(e),e.measureListIndex=this.sourceMeasures.length-1}checkForInstrumentWithNoVoice(){for(let e=0,t=this.instruments.length;e0){const e=this.TimestampSortedTempoExpressionsList[0];if(e.InstantaneousTempo)return e.InstantaneousTempo.TempoInBpm;if(e.ContinuousTempo)return e.ContinuousTempo.StartTempo}return this.userStartTempoInBPM}get Errors(){return this.musicSheetErrors.measureErrors}get FirstMeasureNumber(){try{return this.getFirstSourceMeasure().MeasureNumber}catch(e){return s.info("MusicSheet.FirstMeasureNumber: ",e),0}}get LastMeasureNumber(){try{return this.getLastSourceMeasure().MeasureNumber}catch(e){return s.info("MusicSheet.LastMeasureNumber: ",e),0}}get CurrentEnrolledPosition(){return this.currentEnrolledPosition.clone()}set CurrentEnrolledPosition(e){this.currentEnrolledPosition=e.clone()}get Transpose(){return this.transpose}set Transpose(e){this.transpose=e}get FullNameString(){return this.ComposerString+" "+this.TitleString}get IdString(){return this.idString}set IdString(e){this.idString=e}getEnrolledSelectionStartTimeStampWorkaround(){const e=this.MusicPartManager.getIterator(this.SelectionStart);return u.createFromFraction(e.CurrentEnrolledTimestamp)}get SheetEndTimestamp(){const e=this.getLastSourceMeasure();return u.plus(e.AbsoluteTimestamp,e.Duration)}getSourceMeasureFromTimeStamp(e){for(let t=0,i=this.sourceMeasures.length;t0&&i.Voices[0].Visible&&e.push(i)}return e}}ws.defaultTitle="defaultTitle";class Is{constructor(){this.syllables=[]}get Syllables(){return this.syllables}containsVoiceEntry(e){for(let t=0,i=this.Syllables.length;t=0&&(this.syllableIndex=n)}get Text(){return this.text}set Text(e){this.text=e}get Word(){return this.word}get Parent(){return this.parent}set Parent(e){this.parent=e}get VerseNumber(){return this.verseNumber}get SyllableIndex(){return this.syllableIndex}get IsTranslation(){return this.VerseNumber.endsWith("translation")}get IsChorus(){return this.VerseNumber.startsWith("chorus")}get FontStyle(){return this.IsChorus||this.IsTranslation?me.Italic:me.Regular}}class Rs{constructor(e){this.openLyricWords={},this.musicSheet=e}addLyricEntry(e,t){if(e){const r=e;for(let e=0,o=r.length;e0)for(let e=r;e0){const o=e.elements();for(let e=0,a=o.length;e0&&t.Articulations[0].articulationEnum!==ct.staccato&&t.Articulations.splice(0,0,o);else if("breathmark"===l)s===d.NotYetDefined&&(o.placement=d.Above);else if("strongaccent"===l){var n;const e=null==a||null===(n=a.attribute("type"))||void 0===n?void 0:n.value;"up"===e?o.articulationEnum=ct.marcatoup:"down"===e&&(o.articulationEnum=ct.marcatodown)}else if(e===ct.softaccent){const e=t.ParentSourceStaffEntry.ParentStaff.Id-1;s===d.NotYetDefined&&(s=d.Above,e>0&&(s=d.Below));const i=t.ParentSourceStaffEntry.VerticalContainerParent.ParentMeasure,n=new ri(i,t.Timestamp);n.StartingContinuousDynamic=new m(p.crescendo,s,e,i,null,-1),n.StartingContinuousDynamic.IsStartOfSoftAccent=!0,n.StartingContinuousDynamic.StartMultiExpression=n,n.StartingContinuousDynamic.EndMultiExpression=n,n.EndingContinuousDynamic=new m(p.diminuendo,s,e,i,null,-1),n.EndingContinuousDynamic.StartMultiExpression=n,n.EndingContinuousDynamic.EndMultiExpression=n,i.StaffLinkedExpressions[e].push(n)}if(!t.hasArticulation(o))switch(t.Articulations.push(o),o.articulationEnum){case ct.staccato:case ct.staccatissimo:t.DurationModifier=o;break;case ct.accent:case ct.strongaccent:t.VolumeModifier=o}}}catch(r){const e="Invalid note articulation.";return void s.debug("addArticulationExpression",e,r)}}}}addFermata(e,t){var i;let s=ct.fermata;e.attributes().length>0&&e.attribute("type")&&"inverted"===e.attribute("type").value&&(s=ct.invertedfermata);let n=d.Above;"below"===(null===(i=e.attribute("placement"))||void 0===i?void 0:i.value)&&(n=d.Below),t.Articulations.push(new Ns(s,n))}addTechnicalArticulations(e,t,i){const s={bend:ct.bend,"down-bow":ct.downbow,"open-string":ct.naturalharmonic,"snap-pizzicato":ct.snappizzicato,stopped:ct.lefthandpizzicato,"up-bow":ct.upbow,harmonic:ct.naturalharmonic};for(const l in s){if(!s.hasOwnProperty(l))continue;const i=s[l],o=e.element(l);if(o){var n,r;let e;"above"===(null===(n=o.attribute("placement"))||void 0===n?void 0:n.value)&&(e=d.Above),"below"===(null===(r=o.attribute("placement"))||void 0===r?void 0:r.value)&&(e=d.Below);const s=new Ns(i,e);t.hasArticulation(s)||t.Articulations.push(s)}}const o=e.elements("fingering");for(const l of o){const e=this.createTechnicalInstruction(l,i);e.type=ot.Fingering,i.Fingering||(i.Fingering=e),t.TechnicalInstructions.push(e)}const a=e.element("string");if(a){const e=this.createTechnicalInstruction(a,i);e.type=ot.String,i.StringInstruction=e,t.TechnicalInstructions.push(e)}}createTechnicalInstruction(e,t){const i=new at;i.sourceNote=t,i.value=e.value;const s=e.attribute("placement");return this.rules.FingeringPositionFromXML&&(i.placement=this.getPlacement(s)),i}getPlacement(e,t=d.NotYetDefined){if(t!==d.NotYetDefined)return t;if(!e)return d.NotYetDefined;switch(e.value){case"above":return d.Above;case"below":return d.Below;case"left":return d.Left;case"right":return d.Right;default:return d.NotYetDefined}}addOrnament(e,t){if(e){let i;const s={"delayed-inverted-turn":je.DelayedInvertedTurn,"delayed-turn":je.DelayedTurn,"inverted-mordent":je.InvertedMordent,"inverted-turn":je.InvertedTurn,mordent:je.Mordent,"trill-mark":je.Trill,turn:je.Turn};for(const t in s){if(!s.hasOwnProperty(t))continue;const n=e.element(t);if(n){i=new Ye(s[t]);const e=n.attribute("placement");e&&"below"===e.value&&(i.placement=d.Below)}}if(i){const s=e.elements("accidental-mark");if(s){let e=d.Below,t=Y.NONE;const n=s;for(let s=0,r=n.length;s0&&(this.currentVoiceEntry.GraceVoiceEntriesBefore=this.graceVoiceEntriesTempList,this.graceVoiceEntriesTempList=[]))}finalizeReadingMeasure(){this.graceVoiceEntriesTempList.length>0&&void 0!==this.currentNormalVoiceEntry&&this.currentNormalVoiceEntry.GraceVoiceEntriesAfter.concat(this.graceVoiceEntriesTempList),this.graceVoiceEntriesTempList=[],this.pluginManager.processVoiceMeasureReadPlugins(this.currMeasureVoiceEntries,this.activeKey,this.activeRhythm),this.currMeasureVoiceEntries.length=0,this.openBeams.length>1&&this.handleOpenBeam()}read(e,t,i,n,r,o,a,l,h,u,c,d,f,m,p,g,S,y,b,M,v,P,E){this.currentStaffEntry=a,this.currentMeasure=l;try{this.currentNote=o?this.addRestNote(e.element("rest"),t,n,i,r,f,m,b,e):this.addSingleNote(e,t,n,i,r,c,d,f,m,p,g,S,y,b,v,P,E),this.currentNote.DotsXml=M;const s=e.elements("lyric");void 0!==this.lyricsReader&&s&&(this.lyricsReader.addLyricEntry(s,this.currentVoiceEntry),this.voice.Parent.HasLyrics=!0);let a=!1;const l=e.element("notations");if(l){this.articulationReader&&this.readArticulations(l,this.currentVoiceEntry,this.currentNote);const t=l.elements("slur"),i=l.elements("slide"),s=l.elements("glissando");void 0!==this.slurReader&&(t.length>0||i.length>0)&&!this.currentNote.ParentVoiceEntry.IsGrace&&(this.slurReader.addSlur(t,this.currentNote),i.length>0&&this.slurReader.addSlur(i,this.currentNote),s.length>0&&this.slurReader.addSlur(s,this.currentNote));const n=l.elements("tuplet");n.length>0&&(this.openTupletNumber=this.addTuplet(e,n),a=!0);const r=l.element("arpeggiate");if(void 0!==r){let e;if(this.currentVoiceEntry.Arpeggio)e=this.currentVoiceEntry.Arpeggio;else{let t=!1;for(const i of this.currentStaffEntry.VoiceEntries)if(i.Arpeggio){t=!0,e=i.Arpeggio;break}if(!t){let t=ke.ARPEGGIO_DIRECTIONLESS;const i=r.attribute("direction");if(i)switch(i.value){case"up":t=ke.ROLL_UP;break;case"down":t=ke.ROLL_DOWN;break;default:t=ke.ARPEGGIO_DIRECTIONLESS}e=new Ve(this.currentVoiceEntry,t),this.currentVoiceEntry.Arpeggio=e}}e.addNote(this.currentNote)}const o=l.elements("tied");o.length>0&&this.addTie(o,h,u,Se.SIMPLE);const c=l.element("technical");if(c){const e=c.elements("hammer-on");e.length>0&&this.addTie(e,h,u,Se.HAMMERON);const t=c.elements("pull-off");t.length>0&&this.addTie(t,h,u,Se.PULLOFF)}}void 0===e.element("time-modification")||a||this.handleTimeModificationNode(e)}catch(L){s.warn(L);const e=Xe.translateText("ReaderErrorMessages/NoteError","Ignored erroneous Note.");this.musicSheet.SheetErrors.pushMeasureError(e),this.musicSheet.SheetErrors.pushMeasureError(L)}return this.currentNote}checkForStaffEntryLink(e,t,i,s){const n=new st(this.currentVoiceEntry);n.LinkStaffEntries.push(i),i.Link=n;const r=this.currentVoiceEntry.Timestamp.clone(),o=s.getVerticalContainerByTimestamp(r);return(i=o.StaffEntries[e])||(i=new Je(o,t),o.StaffEntries[e]=i),i.VoiceEntries.push(this.currentVoiceEntry),n.LinkStaffEntries.push(i),i.Link=n,i}checkForOpenBeam(){this.openBeams.length>0&&this.currentNote&&this.handleOpenBeam()}checkOpenTies(){const e=this.openTieDict;for(const t in e)if(e.hasOwnProperty(t)){const i=e[t];u.plus(i.StartNote.ParentStaffEntry.Timestamp,i.Duration).lt(i.StartNote.SourceMeasure.Duration)&&delete e[t]}}hasVoiceEntry(){return void 0!==this.currentVoiceEntry}readArticulations(e,t,i){const s=e.element("articulations");s&&this.articulationReader.addArticulationExpression(s,t);const n=e.element("fermata");n&&this.articulationReader.addFermata(n,t);const r=e.element("technical");r&&this.articulationReader.addTechnicalArticulations(r,t,i);const o=e.element("ornaments");o&&this.articulationReader.addOrnament(o,t)}addSingleNote(e,t,i,n,r,o,a,l,h,c,d,f,m,p,g,y,b){var M;let v,P,E,L,x=0,T=Y.NONE,w=H.C,I=H.C,A=0,R=0;const N=e.elements();for(let u=0,X=N.length;u{const t=e.getAttribute("begin"),i=e.getAttribute("end");_.push({begin:t?t/1e3:0,end:i?i/1e3:0})})),this.addNoteInfo(D,i,l,h,r,I,R,p,p,_),D.TypeLength=n,D.IsGraceNote=c,D.StemDirectionXml=d,D.TremoloInfo=f,D.PlaybackInstrumentId=P,(void 0!==E&&"normal"!==E||void 0!==L)&&(D.Notehead=new We(D,E,L)),D.NoteheadColorXml=p,D.NoteheadColor=p,D.PlaybackInstrumentId=P,D.TremoloType=g,D.glissandoType=y,D.slideType=b,this.currentVoiceEntry.addNote(D),d===dt.None&&(m="#00000000"),this.currentVoiceEntry.StemDirectionXml=d,m&&(this.currentVoiceEntry.StemColorXml=m,this.currentVoiceEntry.StemColor=m,D.StemColorXml=m),e.elements("beam")&&!o&&this.createBeam(e,D),D.IsChordNote=o,D}addRestNote(e,t,i,s,n,r,o,a,l){var h;const c=u.createFromFraction(t),d=e.element("display-step"),f=e.element("display-octave");let m,p,g;d&&f&&(m=H[d.value.toUpperCase()],p=parseInt(f.value,10),g=new K(m,p,Y.NONE,void 0,!0));const S=new Ae(this.currentVoiceEntry,this.currentStaffEntry,c,g,this.currentMeasure,!0);let y=[];const b=e.element("times")||l.element("times"),M=null==b||null===(h=b.elem)||void 0===h?void 0:h.getElementsByTagName("time");return M&&M.length&&Array.from(M).forEach((e=>{const t=e.getAttribute("begin"),i=e.getAttribute("end");y.push({begin:t?t/1e3:0,end:i?i/1e3:0})})),this.addNoteInfo(S,i,r,o,n,m,p,a,a,y),S.TypeLength=s,this.currentVoiceEntry.Notes.push(S),this.openBeams.length>0&&this.openBeams.last().ExtendedNoteList.push(S),S}addNoteInfo(e,t,i,s,n,r,o,a,l,h){e.NoteTypeXml=t,e.PrintObject=i,e.IsCueNote=s,e.NormalNotes=n,e.displayStepUnpitched=r,e.displayOctaveUnpitched=o,e.NoteheadColorXml=a,e.NoteheadColor=a,e.noteTimeInfo=h}createBeam(e,t){try{const n=e.element("beam");let r;if(void 0!==n&&n.hasAttributes&&(r=n.attribute("number")),r){let n=parseInt(r.value,10);const o=e.elements("beam"),a=o[0].value;var i;o&&("begin"===a?(n===(null===(i=this.openBeams.last())||void 0===i?void 0:i.BeamNumber)?(this.beamNumberOffset++,n+=this.beamNumberOffset):this.openBeams.last()&&this.handleOpenBeam(),this.openBeams.push(new Fe(n,this.beamNumberOffset))):n+=this.beamNumberOffset);let l=!1;if(!(n>0&&n<=this.openBeams.length&&this.openBeams[n-1]))return void s.debug("[OSMD] invalid beamnumber");for(let e=0,t=this.openBeams[n-1].Notes.length;e1){let n=e.element("time-modification");n&&(n=n.element("actual-notes"));const r=t;for(let t=0,o=r.length;t1&&this.openTupletNumber--),this.tupletDict[t]=l;const u=[];u.push(this.currentNote),l.Notes.push(u),l.Fractions.push(this.getTupletNoteDurationFromType(e)),this.currentNote.NoteTuplet=l,this.openTupletNumber=t}else if("stop"===a.value){let t=1;o.attribute("number")&&(t=parseInt(o.attribute("number").value,10));const i=this.tupletDict[t];if(i){const s=o.attribute("placement");s&&("below"===s.value?i.tupletLabelNumberPlacement=d.Below:i.tupletLabelNumberPlacement=d.Above,i.PlacementFromXml=!0);const n=[];if(n.push(this.currentNote),i.Notes.push(n),!i.PlacementFromXml){let e=!1;for(const t of i.Notes){for(const s of t)if(!s.isRest()){s.StemDirectionXml===dt.Down?i.tupletLabelNumberPlacement=d.Below:i.tupletLabelNumberPlacement=d.Above,e=!0;break}if(e)break}}i.Fractions.push(this.getTupletNoteDurationFromType(e)),this.currentNote.NoteTuplet=i,delete this.tupletDict[t],0===Object.keys(this.tupletDict).length?this.openTupletNumber=0:Object.keys(this.tupletDict).length>1&&this.openTupletNumber--}}}}}else if(t[0]){const n=t[0];if(n.hasAttributes){const t=n.attribute("type").value;let r=1;n.attribute("number")&&(r=parseInt(n.attribute("number").value,10));const o=isNaN(r),a=this.readShowNumberNoneGiven(n),l=n.attribute("bracket");if(l&&"yes"===l.value?(s=!0,i=!0):l&&"no"===l.value&&(i=!1),"start"===t){let t=0,l=e.element("time-modification");if(l&&(l=l.element("actual-notes")),l&&(t=parseInt(l.value,10),isNaN(t))){const e=Xe.translateText("ReaderErrorMessages/TupletNoteDurationError","Invalid tuplet note duration.");throw this.musicSheet.SheetErrors.pushMeasureError(e),new S(e)}o&&(this.openTupletNumber++,r=this.openTupletNumber);let h=this.tupletDict[r];h||(h=this.tupletDict[r]=new rt(t,s),h.BracketedXmlValue=i,h.ShowNumberNoneGivenInXml=a,h.tupletLabelNumberPlacement=d.Above);const u=n.attribute("placement");u&&("below"===u.value?h.tupletLabelNumberPlacement=d.Below:h.tupletLabelNumberPlacement=d.Above,h.PlacementFromXml=!0);const c=[];c.push(this.currentNote),h.Notes.push(c),h.Fractions.push(this.getTupletNoteDurationFromType(e)),this.currentNote.NoteTuplet=h,this.openTupletNumber=r}else if("stop"===t){o&&(r=this.openTupletNumber);const t=this.tupletDict[this.openTupletNumber];if(t){const i=n.attribute("placement");i&&("below"===i.value?t.tupletLabelNumberPlacement=d.Below:t.tupletLabelNumberPlacement=d.Above,t.PlacementFromXml=!0);const s=[];if(s.push(this.currentNote),t.Notes.push(s),!t.PlacementFromXml){let e=!1;for(const i of t.Notes){for(const s of i)if(!s.isRest()){s.StemDirectionXml===dt.Down?t.tupletLabelNumberPlacement=d.Below:t.tupletLabelNumberPlacement=d.Above,e=!0;break}if(e)break}}t.Fractions.push(this.getTupletNoteDurationFromType(e)),this.currentNote.NoteTuplet=t,0===Object.keys(this.tupletDict).length?this.openTupletNumber=0:Object.keys(this.tupletDict).length>1&&this.openTupletNumber--,delete this.tupletDict[r]}}}}return this.openTupletNumber}readShowNumberNoneGiven(e){const t=e.attribute("show-number");return!(null==t||!t.value||"none"!==t.value)}handleTimeModificationNode(e){if(this.tupletDict[this.openTupletNumber])try{const t=this.tupletDict[this.openTupletNumber],i=le.last(t.Notes);let s;i[0].ParentVoiceEntry.Timestamp.Equals(this.currentVoiceEntry.Timestamp)?s=i:(s=[],t.Notes.push(s),t.Fractions.push(this.getTupletNoteDurationFromType(e))),s.push(this.currentNote),this.currentNote.NoteTuplet=t}catch(t){const e=Xe.translateText("ReaderErrorMessages/TupletNumberError","Invalid tuplet number.");throw this.musicSheet.SheetErrors.pushMeasureError(e),t}else if(this.currentVoiceEntry.Notes.length>0){const e=this.currentVoiceEntry.Notes[0];if(e.NoteTuplet){const t=e.NoteTuplet;le.last(t.Notes).push(this.currentNote),this.currentNote.NoteTuplet=t}}}addTie(e,t,i,s){if(e)if(1===e.length){const t=e[0];if(void 0!==t&&t.attributes()){const e=this.getTieDirection(t),i=t.attribute("type").value;try{if("start"===i){const t=this.findCurrentNoteInTieDict(this.currentNote);t<0&&delete this.openTieDict[t];const i=this.getNextAvailableNumberForTie(),n=new nt(this.currentNote,s);this.openTieDict[i]=n,n.TieNumber=i,n.TieDirection=e}else if("stop"===i){const e=this.findCurrentNoteInTieDict(this.currentNote),t=this.openTieDict[e];t&&(t.AddNote(this.currentNote),delete this.openTieDict[e])}}catch(n){const e=Xe.translateText("ReaderErrorMessages/TieError","Error while reading tie.");this.musicSheet.SheetErrors.pushMeasureError(e)}}}else if(2===e.length){const t=this.findCurrentNoteInTieDict(this.currentNote);if(t>=0){const i=this.openTieDict[t];i.AddNote(this.currentNote);for(const t of e)if("start"===t.attribute("type").value){const e=this.getTieDirection(t);i.NoteIndexToTieDirection[i.Notes.length-1]=e}}}}getTieDirection(e){let t=d.NotYetDefined;const i=e.attribute("placement");i&&("above"===i.value?t=d.Above:"below"===i.value&&(t=d.Below));const s=e.attribute("orientation");return s&&("over"===s.value?t=d.Above:"under"===s.value&&(t=d.Below)),t}getNextAvailableNumberForTie(){const e=Object.keys(this.openTieDict);if(0===e.length)return 1;e.sort(((e,t)=>+e-+t));for(let t=0;t0?n.RealValue>0?(c=u.multiply(u.minus(n,r),c),this.directionTimestamp=u.plus(c,n)):this.directionTimestamp=u.createFromFraction(c):this.offsetDivisions<0&&(n.RealValue>0?(c=u.multiply(u.minus(n,r),c),this.directionTimestamp=u.minus(n,c)):this.directionTimestamp=u.createFromFraction(c));const f=e.element("direction-type");let m;if(f&&(m=f.element("wedge"),m)){const e=m.attribute("default-y");e&&(h=this.readPosition(e))}this.WedgeYPosXml=h;const p=e.attribute("placement");if(p)try{const e=p.value;"below"===e?this.placement=d.Below:"above"===e&&(this.placement=d.Above)}catch(g){const e=Xe.translateText("ReaderErrorMessages/ExpressionPlacementError","Invalid expression placement -> set to default.");s.debug("ExpressionReader.readExpressionParameters",e,g),this.musicSheet.SheetErrors.pushMeasureError(e),this.placement=d.Below}if(this.placement===d.NotYetDefined)try{if(f){const e=f.element("dynamics");if(e){const t=e.attribute("default-y");t&&this.readExpressionPlacement(t,"read dynamics y pos")}if(m){const e=m.attribute("default-y");e&&this.readExpressionPlacement(e,"read wedge y pos")}const t=f.element("words");if(t){const e=t.attribute("default-y");e&&this.readExpressionPlacement(e,"read words y pos")}const i=f.element("rehearsal");if(i){const e=i.attribute("default-y");e&&this.readExpressionPlacement(e,"read rehearsal pos")}}}catch(g){const e=Xe.translateText("ReaderErrorMessages/ExpressionPlacementError","Invalid expression placement. Set to default.");s.debug("ExpressionReader.readExpressionParameters",e,g),this.musicSheet.SheetErrors.pushMeasureError(e),this.placement=d.Below}this.placement===d.NotYetDefined&&(t.Staves.length>1?this.placement=d.Below:t.HasLyrics?this.placement=d.Above:this.placement=d.Below)}read(e,t,i,n=void 0,r=0,o){let a=!1,l=!1;const h=e.element("sound");if(h){const e=h.attribute("tempo"),i=h.attribute("dynamics");if(e){const i=e.value.match(/^(\d+)(\.\d+)?$/);(null==i?void 0:i.length)>0?this.soundTempo=Math.round(Number.parseFloat(e.value)):(s.info("invalid xml tempo: "+e.value),this.soundTempo=100),t.TempoInBPM=this.soundTempo,0===this.musicSheet.DefaultStartTempoInBpm&&(this.musicSheet.DefaultStartTempoInBpm=this.soundTempo),this.musicSheet.HasBPMInfo=!0,a=!0}if(i){const e=i.value.match(/\d+/);this.soundDynamic=void 0!==e?parseInt(e[0],10):100,l=!0}}const c=e.element("direction-type");if(!c)return;let d=c.element("metronome");if(d){t.metronomeNoteIndex=r;const e=d.element("beat-unit"),s=void 0!==d.element("beat-unit-dot"),n=d.element("per-minute");if(void 0!==e&&n){d.hasAttributes&&void 0!==d.attribute("default-x")&&(this.directionTimestamp=u.createFromFraction(i));const r=parseFloat(n.value);!o&&this.createNewTempoExpressionIfNeeded(t);const a=new ei(void 0,this.placement,this.staffNumber,r,this.currentMultiTempoExpression,!0);a.parentMeasure=t,this.soundTempo=r,t.TempoInBPM=1*this.soundTempo,0===this.musicSheet.DefaultStartTempoInBpm&&(this.musicSheet.DefaultStartTempoInBpm=this.soundTempo),1===t.MeasureNumberXML&&0===this.musicSheet.SourceMeasures.length&&(this.musicSheet.DefaultStartTempoInBpm=this.soundTempo),this.musicSheet.HasBPMInfo=!0,a.dotted=s,a.beatUnit=e.value,this.currentMultiTempoExpression.addExpression(a,""),this.currentMultiTempoExpression.CombinedExpressionsText="test"}}else if(d=c.element("dynamics"),d){const s=void 0!==e.element("notations");this.interpretInstantaneousDynamics(d,t,i,s)}else if(d=c.element("words"),d){const e=c.elements("words");let s="";for(const t of e)s+=t.value;if(d.value=s,d.value&&d.value.toLocaleLowerCase().includes("compound_tempo")&&(d.value=""),a||Lt(d.value)||xt(d.value)){this.createNewTempoExpressionIfNeeded(t),this.currentMultiTempoExpression.CombinedExpressionsText=d.value,(Lt(d.value)||xt(d.value))&&(d.value=void 0);const e=new ei(d.value,this.placement,this.staffNumber,this.soundTempo,this.currentMultiTempoExpression);this.currentMultiTempoExpression.addExpression(e,"")}else l||this.interpretWords(d,t,i)}else d=c.element("wedge"),d?this.interpretWedge(e,d,t,n,t.MeasureNumber):(d=c.element("rehearsal"),d&&this.interpretRehearsalMark(d,t,i,t.MeasureNumber))}closeOpenExpressions(e,t){for(const i of this.openContinuousDynamicExpressions)this.createNewMultiExpressionIfNeeded(e,i.NumberXml,t),this.closeOpenContinuousDynamic(i,e,t);this.openContinuousTempoExpression&&this.closeOpenContinuousTempo(u.plus(e.AbsoluteTimestamp,t))}addOctaveShift(e,t,i){let n=1;const r=e.element("staff");if(r)try{n=parseInt(r.value,10)}catch(l){const e=Xe.translateText("ReaderErrorMessages/OctaveShiftStaffError","Invalid octave shift staff number. Set to default");this.musicSheet.SheetErrors.pushMeasureError(e),n=1,s.debug("ExpressionReader.addOctaveShift",e,l)}const o=e.element("direction-type");if(o){const r=o.element("octave-shift"),h=this.readPlacement(e);if(void 0!==r&&r.hasAttributes)try{const e=this.readNumber(r);if(r.attribute("size")){var a;const o=parseInt(r.attribute("size").value,10);let l=0;8===o?l=1:15===o&&(l=2);let u=null===(a=r.attribute("type"))||void 0===a?void 0:a.value;if(u||(h===d.Above?u="down":h===d.Below&&(u="up")),"up"===u||"down"===u){const i=new qt(u,l);i.StaffNumber=n,this.getMultiExpression=this.createNewMultiExpressionIfNeeded(t,e),this.getMultiExpression.OctaveShiftStart=i,i.ParentStartMultiExpression=this.getMultiExpression,this.openOctaveShift=i}else"stop"===u?this.openOctaveShift&&(this.getMultiExpression=this.createNewMultiExpressionIfNeeded(t,this.openOctaveShift.numberXml,i),this.getMultiExpression.OctaveShiftEnd=this.openOctaveShift,this.openOctaveShift.ParentEndMultiExpression=this.getMultiExpression,this.openOctaveShift=void 0):u||s.debug("octave-shift missing type in xml")}}catch(l){const e=Xe.translateText("ReaderErrorMessages/OctaveShiftError","Error while reading octave shift.");this.musicSheet.SheetErrors.pushMeasureError(e),s.debug("ExpressionReader.addOctaveShift",e,l)}}}addPedalMarking(e,t,i){const n=e.element("direction-type");if(n){const e=n.element("pedal");if(void 0!==e&&e.hasAttributes){let n=!1,h=!1;try{var r,o,a;switch("yes"===(null===(r=e.attribute("line"))||void 0===r?void 0:r.value)?h=!0:"no"===(null===(o=e.attribute("line"))||void 0===o?void 0:o.value)?(h=!1,n=!0):"yes"===(null===(a=e.attribute("sign"))||void 0===a?void 0:a.value)?n=!0:(n=!1,h=!0),e.attribute("type").value){case"start":this.openPedal&&this.openPedal.IsLine&&this.endOpenPedal(t),this.createNewMultiExpressionIfNeeded(t,-1),this.openPedal=new ks(h,n),this.getMultiExpression.PedalStart=this.openPedal,this.openPedal.ParentStartMultiExpression=this.getMultiExpression;break;case"stop":this.openPedal&&this.endOpenPedal(t,i);break;case"change":this.openPedal&&this.openPedal.IsLine&&(this.openPedal.ChangeEnd=!0,this.createNewMultiExpressionIfNeeded(t,-1),this.getMultiExpression.PedalEnd=this.openPedal,this.openPedal.ParentEndMultiExpression=this.getMultiExpression,this.createNewMultiExpressionIfNeeded(t,-1),this.openPedal=new ks(h,n),this.openPedal.ChangeBegin=!0,this.getMultiExpression.PedalStart=this.openPedal,this.openPedal.ParentStartMultiExpression=this.getMultiExpression)}}catch(l){const e=Xe.translateText("ReaderErrorMessages/PedalError","Error while reading pedal.");this.musicSheet.SheetErrors.pushMeasureError(e),s.debug("ExpressionReader.addPedalMarking",e,l)}}}}endOpenPedal(e,t){this.createNewMultiExpressionIfNeeded(e,-1,t),this.getMultiExpression.PedalEnd=this.openPedal,this.openPedal.ParentEndMultiExpression=this.getMultiExpression,this.openPedal=void 0}addWavyLine(e,t,i,n){if(e&&e.hasAttributes)try{switch(e.attribute("type").value){case"start":this.createNewMultiExpressionIfNeeded(t,-1),this.openWavyLine=new Fs(this.placement),this.getMultiExpression.WavyLineStart=this.openWavyLine,this.openWavyLine.ParentStartMultiExpression=this.getMultiExpression;break;case"stop":this.openWavyLine&&(this.createNewMultiExpressionIfNeeded(t,-1,i),this.getMultiExpression.WavyLineEnd=this.openWavyLine,this.openWavyLine.ParentEndMultiExpression=this.getMultiExpression,this.openWavyLine=void 0)}}catch(r){const e=Xe.translateText("ReaderErrorMessages/WavyLineError","Error while reading wavy-line.");this.musicSheet.SheetErrors.pushMeasureError(e),s.debug("ExpressionReader.addWavyLine",e,r)}}initialize(){this.placement=d.NotYetDefined,this.soundTempo=0,this.soundDynamic=0,this.offsetDivisions=0}readPlacement(e){var t;const i=null===(t=e.attribute("placement"))||void 0===t?void 0:t.value;return"above"===i?d.Above:"below"===i?d.Below:d.NotYetDefined}readExpressionPlacement(e,t){try{const t=this.readPosition(e);t<0?this.placement=d.Below:t>0&&(this.placement=d.Above)}catch(i){s.debug("ExpressionReader.readExpressionParameters",t,i)}}readPosition(e){try{const t=parseInt(e.value,10);return t<0?this.placement=d.Below:t>0&&(this.placement=d.Above),t}catch(t){s.debug("ExpressionReader.readExpressionParameters",t)}}interpretInstantaneousDynamics(e,t,i,s){if(e.hasElements){var n;e.hasAttributes&&e.attribute("default-x")&&(this.directionTimestamp=u.createFromFraction(i));const l=this.readNumber(e);let h=null===(n=e.elements()[0])||void 0===n?void 0:n.name;if("other-dynamics"===h&&(h=e.elements()[0].value),h){var r;if(null!==(r=t.Rules)&&void 0!==r&&r.IgnoreRepeatedDynamics){var o;let e;try{e=P[h]}catch(a){const e=Xe.translateText("ReaderErrorMessages/DynamicError","Error while reading dynamic.");return void this.musicSheet.SheetErrors.pushMeasureError(e)}if((null===(o=this.activeInstantaneousDynamic)||void 0===o?void 0:o.DynEnum)===e)return}s?this.createNewMultiExpressionIfNeeded(t,l,u.createFromFraction(i)):this.createNewMultiExpressionIfNeeded(t,l);const e=new v(h,this.soundDynamic,this.placement,this.staffNumber,t);e.InMeasureTimestamp=i.clone(),this.getMultiExpression.addExpression(e,""),this.initialize(),this.activeInstantaneousDynamic?this.activeInstantaneousDynamic.DynEnum=e.DynEnum:this.activeInstantaneousDynamic=new v(h,0,d.NotYetDefined,1,t)}}}interpretWords(e,t,i){const s=e.value;if(t.Rules.IgnoreBracketsWords&&(/^\(\s*\)$/.test(s)||/^\[\s*\]$/.test(s)))return;let n;const r=e.attribute("font-style");let o,a,l;r&&(o=r.value,"italic"===o&&(n=me.Italic));const h=e.attribute("font-weight");h&&(a=h.value,"bold"===a&&(n=me.Bold,"italic"===o&&(n=me.BoldItalic)));const c=e.attribute("color");let d;if(c&&(l=c.value),t.Rules.PlaceWordsInsideStafflineFromXml){var f;const t=null===(f=e.attribute("default-y"))||void 0===f?void 0:f.value;(null==t?void 0:t.length)>0&&(d=Number.parseInt(t,10))}if(s.length>0){if(e.hasAttributes&&e.attribute("default-x")&&(this.directionTimestamp=u.createFromFraction(i)),this.checkIfWordsNodeIsRepetitionInstruction(s))return;this.fillMultiOrTempoExpression(s,t,i,n,l,d),this.initialize()}}readNumber(e){var t;let i=1;const s=null===(t=e.attribute("number"))||void 0===t?void 0:t.value;return s&&(i=Number.parseInt(s,10)),i}interpretWedge(e,t,i,s,n){var r,o;void 0!==t&&t.hasAttributes&&t.attribute("default-x")&&(this.directionTimestamp=u.createFromFraction(s));const a=this.readNumber(t),l=null===(r=t.attribute("type"))||void 0===r||null===(o=r.value)||void 0===o?void 0:o.toLowerCase();this.lastWedge&&this.lastWedge.parentMeasure.MeasureNumberXML===i.MeasureNumberXML&&this.lastWedge.StaffNumber===this.staffNumber&&this.placement===this.lastWedge.Placement&&void 0!==this.WedgeYPosXml&&this.lastWedge.YPosXml===this.WedgeYPosXml&&this.lastWedge.StartMultiExpression.Timestamp.Equals(this.directionTimestamp)&&this.lastWedge.DynamicType===p[l]||("stop"===l?(this.createNewMultiExpressionIfNeeded(i,a,s),this.getMultiExpression.EndOffsetFraction=new u(this.offsetDivisions,4*this.divisions)):this.createNewMultiExpressionIfNeeded(i,a),this.addWedge(t,i,s),this.initialize())}interpretRehearsalMark(e,t,i,s){t.rehearsalExpression=new ci(e.value,this.placement)}createNewMultiExpressionIfNeeded(e,t,i=void 0){i||(i=this.directionTimestamp);let s=this.getMultiExpression;return(!s||s&&(s.SourceMeasureParent!==e||s.numberXml!==t||s.SourceMeasureParent===e&&!s.Timestamp.Equals(i)))&&(this.getMultiExpression=s=new ri(e,u.createFromFraction(i)),this.getMultiExpression.numberXml=t,e.StaffLinkedExpressions[this.globalStaffIndex].push(s)),s}createNewTempoExpressionIfNeeded(e){this.currentMultiTempoExpression&&this.currentMultiTempoExpression.SourceMeasureParent===e&&this.currentMultiTempoExpression.Timestamp===this.directionTimestamp||(this.currentMultiTempoExpression=new hi(e,u.createFromFraction(this.directionTimestamp)),e.TempoExpressions.push(this.currentMultiTempoExpression))}addWedge(e,t,i){if(void 0!==e&&e.hasAttributes){const r=this.readNumber(e),o=e.attribute("type").value.toLowerCase();try{if("crescendo"===o||"diminuendo"===o){const e=new m(p[o],this.placement,this.staffNumber,t,this.activeInstantaneousDynamic,r);this.lastWedge=e,this.lastWedge.YPosXml=this.WedgeYPosXml,this.openContinuousDynamicExpressions.push(e);let i=this.getMultiExpression;i||(i=this.createNewMultiExpressionIfNeeded(t,r)),i.StartingContinuousDynamic=e,e.StartMultiExpression=i,void 0!==this.activeInstantaneousDynamic&&this.activeInstantaneousDynamic.StaffNumber===e.StaffNumber&&(this.activeInstantaneousDynamic=void 0)}else if("stop"===o)for(const e of this.openContinuousDynamicExpressions)e.NumberXml===r&&this.closeOpenContinuousDynamic(e,t,i)}catch(n){const e="ReaderErrorMessages/WedgeError, Error while reading Crescendo / Diminuendo.";this.musicSheet.SheetErrors.pushMeasureError(e),s.debug("ExpressionReader.addWedge",e,n)}}}fillMultiOrTempoExpression(e,t,i,s,n,r=void 0){if(!e)return;const o=e.trim();this.createExpressionFromString("",o,t,i,e,s,n,r)}createExpressionFromString(e,t,i,s,n,r,o,a=void 0){if(ei.isInputStringInstantaneousTempo(t)||li.isInputStringContinuousTempo(t)){if(i.TempoExpressions.length>0)for(let e=0,s=i.TempoExpressions.length;e0)for(let c=0,d=i.TempoExpressions.length;c0&&!this.hasDigit(t)&&this.globalStaffIndex>0){if(e.EntriesList[0].label.indexOf(t)>=0)return!1;break}}let h=ce.CenterBottom;this.musicSheet.Rules.CompactMode&&(h=ce.LeftBottom);const u=new ni(t,this.placement,h,this.staffNumber);return u.fontStyle=r,u.ColorXML=o,u.defaultYXml=a,l.addExpression(u,e),!1}closeOpenContinuousDynamic(e,t,i){if(!e)return;const s=e.NumberXml;e.EndMultiExpression=this.createNewMultiExpressionIfNeeded(t,s,i),e.StartMultiExpression.EndingContinuousDynamic=e,this.openContinuousDynamicExpressions=this.openContinuousDynamicExpressions.filter((t=>t!==e))}closeOpenContinuousTempo(e){this.openContinuousTempoExpression.AbsoluteEndTimestamp=e,this.openContinuousTempoExpression=void 0}checkIfWordsNodeIsRepetitionInstruction(e){return"coda"===(e=e.trim().toLowerCase())||"tocoda"===e||"to coda"===e||"fine"===e||"d.c."===e||"dacapo"===e||"da capo"===e||"d.s."===e||"dalsegno"===e||"dal segno"===e||"d.c. al fine"===e||"d.s. al fine"===e||"d.c. al coda"===e||"d.s. al coda"===e}hasDigit(e){return/\d/.test(e)}}class _s{constructor(e){this.openSlurDict={},this.musicSheet=e}addSlur(e,t,i){try{if(e)for(const r of e)if(r.attributes().length>0){const e=r.attribute("type").value;let o=1;try{r.attribute("number")&&(o=parseInt(r.attribute("number").value,10))}catch(n){s.debug("VoiceGenerator.addSlur number: ",n)}let a=d.NotYetDefined;const l=r.attribute("placement");l&&l.value&&("above"===l.value?a=d.Above:"below"===l.value&&(a=d.Below));const h=r.attribute("orientation");if(h&&h.value&&("over"===h.value?a=d.Above:"under"===h.value&&(a=d.Below)),"start"===e){let e=new Cs;this.openSlurDict[o]=e,e.StartNote=t,e.idx=i,e.PlacementXml=a}else if("stop"===e){const e=this.openSlurDict[o];if(e){const s=r.name;if("slide"===s||"glissando"===s){const i=e.StartNote,s=new Oe(i);s.AddNote(t),s.EndNote=t,t.NoteGlissando=s,delete this.openSlurDict[o]}else e.idx=i,e.EndNote=t,t.isDuplicateSlur(e)||(t.NoteSlurs.push(e),e.StartNote.NoteSlurs.push(e)),delete this.openSlurDict[o]}}}}catch(r){const e=Xe.translateText("ReaderErrorMessages/SlurError","Error while reading slur.");this.musicSheet.SheetErrors.pushMeasureError(e)}}}class Gs{constructor(e,t,i,s){this.voiceGeneratorsDict={},this.staffMainVoiceGeneratorDict={},this.divisions=0,this.currentClefNumber=1,this.currentXmlMeasureIndex=0,this.activeKeyHasBeenInitialized=!1,this.abstractInstructions=[],this.soundTempos=new Map,this.xmlNotes=[],this.preCompoundTempo="",this.repetitionInstructionReader=t,this.xmlMeasureList=i,this.musicSheet=s.GetMusicSheet,this.instrument=s,this.activeClefs=new Array(s.Staves.length),this.activeClefsHaveBeenInitialized=new Array(s.Staves.length);for(let n=0;n=this.xmlMeasureList.length)return!1;this.currentMeasure=e,this.followingMultirestMeasures=Math.max(this.followingMultirestMeasures-1,0),this.inSourceMeasureInstrumentIndex=this.musicSheet.getGlobalStaffIndexOfFirstStaff(this.instrument),this.repetitionInstructionReader&&this.repetitionInstructionReader.prepareReadingMeasure(e,this.currentXmlMeasureIndex);let n=new u(0,1),r=new u(0,1),o=!1;this.maxTieNoteFraction=new u(0,1);let a=!1;const l=[];let h=!1;try{const T=this.xmlMeasureList[this.currentXmlMeasureIndex],w=T.attribute("osmdWidthFactor");w&&(e.WidthFactor=Number.parseFloat(w.value));const I=T.elements();if(e.Rules.UseXMLMeasureNumbers&&!Number.isInteger(e.MeasureNumberXML)){var c;const t=parseInt(null===(c=T.attribute("number"))||void 0===c?void 0:c.value,10);Number.isInteger(t)&&(e.MeasureNumberXML=t)}let A;for(let c=0;c0&&(A=I[c-1]),"print"===T.name){const t=T.attribute("new-system");"yes"===(null==t?void 0:t.value)&&(e.printNewSystemXml=!0);const i=T.attribute("new-page");"yes"===(null==i?void 0:i.value)&&(e.printNewPageXml=!0)}else if("attributes"===T.name){const t=T.element("divisions");if(t&&(this.divisions=parseInt(t.value,10),isNaN(this.divisions))){const e=Xe.translateText("ReaderErrorMessages/DivisionError","Invalid divisions value at Instrument: ");if(s.debug("InstrumentReader.readNextXmlMeasure",e),this.divisions=this.readDivisionsFromNotes(),!(this.divisions>0))throw o=!0,new S(e+this.instrument.Name);this.musicSheet.SheetErrors.push(e+this.instrument.Name)}if(!T.element("divisions")&&0===this.divisions&&0===this.currentXmlMeasureIndex){const e=Xe.translateText("ReaderErrorMessages/DivisionError","Invalid divisions value at Instrument: ");if(this.divisions=this.readDivisionsFromNotes(),!(this.divisions>0))throw o=!0,new S(e+this.instrument.Name);this.musicSheet.SheetErrors.push(e+this.instrument.Name)}this.addAbstractInstruction(T,i,A,n.clone()),n.Equals(new u(0,1))&&this.isAttributesNodeAtBeginOfMeasure(this.xmlMeasureList[this.currentXmlMeasureIndex],T)&&this.saveAbstractInstructionList(this.instrument.Staves.length,!0),this.isAttributesNodeAtEndOfMeasure(this.xmlMeasureList[this.currentXmlMeasureIndex],T,n)&&this.saveClefInstructionAtEndOfMeasure();const r=T.elements("staff-details");for(const e of r){const t=e.element("staff-lines");if(t){let i=1;const s=e.attribute("number");s&&(i=parseInt(s.value,10)),this.instrument.Staves[i-1].StafflineCount=parseInt(t.value,10)}}const a=T.element("measure-style");if(a){const t=a.element("multiple-rest");if(t){const i=t.value;let s=0;try{s=Number.parseInt(i,10),void 0!==e.multipleRestMeasures&&s!==e.multipleRestMeasures?e.multipleRestMeasures=0:(e.multipleRestMeasures=s,this.currentMultirestStartMeasure=e,this.followingMultirestMeasures=s+1)}catch(x){}}}}else if("note"===T.name){var d;let e=!0;"no"===(null===(d=T.attribute("print-object"))||void 0===d?void 0:d.value)&&(e=!1);const o=this.getNoteStaff(T);this.currentStaff=this.instrument.Staves[o-1];const h=void 0!==T.element("chord");if(T.element("voice")){const e=parseInt(T.element("voice").value,10);this.currentVoiceGenerator=this.getOrCreateVoiceGenerator(e,o-1)}else h&&this.currentVoiceGenerator||(this.currentVoiceGenerator=this.getOrCreateVoiceGenerator(1,o-1));let c,f=0,m=new u(0,1),p=2;if(T.element("duration")){if(f=parseInt(T.element("duration").value,10),isNaN(f)){const e=Xe.translateText("ReaderErrorMessages/NoteDurationError","Invalid Note Duration.");this.musicSheet.SheetErrors.pushMeasureError(e),s.debug("InstrumentReader.readNextXmlMeasure",e);continue}if(m=new u(f,4*this.divisions),0===f?m=this.getNoteDurationFromTypeNode(T):c=this.getNoteDurationFromTypeNode(T),T.element("time-modification")){m=this.getNoteDurationForTuplet(T);const e=T.element("time-modification");null!=e&&e.element("normal-notes")&&(p=parseInt(e.element("normal-notes").value,10))}}const g=void 0!==T.element("rest"),S=T.combinedElement("notations"),y=void 0!==T.element("grace")||0===f||h&&a;let b=!1,M=!1;if(y){const e=T.element("duration"),t=T.element("grace");t&&t.attributes()&&t.attribute("slash")&&"yes"===t.attribute("slash").value&&(b=!0),e||(m=this.getNoteDurationFromTypeNode(T)),S&&S.element("slur")&&(M=!0)}const[v,P]=this.getCueNoteAndNoteTypeXml(T),[E,L,x]=this.getStemDirectionAndColors(T);let w,I=0,A="",R="",N="";if(S){const e=S.element("ornaments");if(e){w=this.getTremoloInfo(e),this.getWavyLines(e,T,n,r);const t=e.element("tremolo");if(t){const e=t.attribute("type");if(A=e.value,e){const i=parseInt(t.value,10);i>0&&(I=i),"start"!==e.value&&"stop"!==e.value||(m=new u(parseInt(T.element("duration").value,10),4*this.divisions))}}const i=e.elements("wavy-line");if(void 0!==i)for(const e of i){const t=this.expressionReaders[this.readExpressionStaffNumber(T)-1];t&&(t.readExpressionParameters(e,this.instrument,this.divisions,n,r,this.currentMeasure.MeasureNumber,!1),t.addWavyLine(e,this.currentMeasure,n,r))}}const t=S.elements("glissando");t.find((e=>"start"===e.attribute("type").value))&&(R="start");const i=S.elements("slide");i.find((e=>"start"===e.attribute("type").value))&&(N="start")}const C=h?r.clone():n.clone();this.currentStaffEntry=this.currentMeasure.findOrCreateStaffEntry(C,this.inSourceMeasureInstrumentIndex+o-1,this.currentStaff).staffEntry,(!this.currentVoiceGenerator.hasVoiceEntry()||!h&&!y&&!a||y&&!a||y&&!h||!y&&a)&&this.currentVoiceGenerator.createVoiceEntry(C,this.currentStaffEntry,this.activeKey,this.ActiveRhythm,y,b,M),y||h||(r=n.clone(),n.Add(m)),h&&void 0!==this.currentStaffEntry&&this.currentStaffEntry.ParentStaff!==this.currentStaff&&(this.currentStaffEntry=this.currentVoiceGenerator.checkForStaffEntryLink(this.inSourceMeasureInstrumentIndex+o-1,this.currentStaff,this.currentStaffEntry,this.currentMeasure));const B=void 0!==this.currentStaffEntry&&void 0!==this.currentStaffEntry.Timestamp&&this.currentStaffEntry.Timestamp.Equals(new u(0,1))&&!this.currentStaffEntry.hasNotes();this.saveAbstractInstructionList(this.instrument.Staves.length,B),this.activeRhythm;const D=T.elements("dot").length;if(this.currentVoiceGenerator.read(T,m,c,P,p,g,this.currentStaffEntry,this.currentMeasure,t,this.maxTieNoteFraction,h,i,e,v,y,E,w,L,x,D,A,R,N),void 0!==S&&S.element("dynamics")){const e=this.expressionReaders[this.readExpressionStaffNumber(T)-1];e&&(e.readExpressionParameters(T,this.instrument,this.divisions,n,r,this.currentMeasure.MeasureNumber,!1),e.read(T,this.currentMeasure,r,void 0,l.length))}a=y}else if("forward"===T.name){const e=parseInt(T.element("duration").value,10);n.Add(new u(e,4*this.divisions))}else if("backup"===T.name){const e=parseInt(T.element("duration").value,10);n.Sub(new u(e,4*this.divisions)),n.IsNegative()&&(n=new u(0,1)),r.Sub(new u(e,4*this.divisions)),r.IsNegative()&&(r=new u(0,1))}else if("direction"===T.name){const t=T.elements("direction-type"),i=T.element("direction-type");let s=Math.min(1,n.RealValue);void 0!==this.activeRhythm&&this.activeRhythm.Rhythm&&(s/=this.activeRhythm.Rhythm.RealValue);let o=!1;if(this.repetitionInstructionReader&&(o=this.repetitionInstructionReader.handleRepetitionInstructionsFromWordsOrSymbols(i,s)),!o){let s=this.expressionReaders[0];const o=this.readExpressionStaffNumber(T)-1;if(onull==e?void 0:e.toLocaleLowerCase())).includes(null===(m=o.value)||void 0===m?void 0:m.toLocaleLowerCase())&&(this.currentGradualChangeMeasure=this.currentMeasure,this.currentMeasure.speedInfo={startWord:null===(b=o.value)||void 0===b?void 0:b.toLocaleLowerCase(),startXmlNoteIndex:l.length,endXmlNoteIndex:0,resetXmlNoteIndex:0,startMeasureListIndex:this.currentXmlMeasureIndex,endMeasureListIndex:0,resetMeasureListIndex:0},this.xmlNotes=[]),o.value.startsWith(Mt)&&null!==(p=this.currentGradualChangeMeasure)&&void 0!==p&&p.speedInfo&&(this.currentGradualChangeMeasure.speedInfo={...this.currentGradualChangeMeasure.speedInfo,endXmlNoteIndex:this.xmlNotes.length,endMeasureListIndex:this.currentXmlMeasureIndex}),(null===(g=o.value)||void 0===g?void 0:g.toLocaleLowerCase())==="a tempo".toLocaleLowerCase()&&null!==(y=this.currentGradualChangeMeasure)&&void 0!==y&&y.speedInfo){const{endXmlNoteIndex:e,resetXmlNoteIndex:t,endMeasureListIndex:i}=this.currentGradualChangeMeasure.speedInfo;0===t&&(this.currentGradualChangeMeasure.speedInfo={...this.currentGradualChangeMeasure.speedInfo,endXmlNoteIndex:e||this.xmlNotes.length,endMeasureListIndex:i||this.currentXmlMeasureIndex,resetXmlNoteIndex:this.xmlNotes.length,resetMeasureListIndex:this.currentXmlMeasureIndex}),this.xmlNotes=[]}h=!(!o.value||"hiddenspeed"!==o.value.toLocaleLowerCase()),o.value&&o.value.toLocaleLowerCase().includes("compound_tempo")&&(e.CompoundTempo=(null===(M=o.value.split("("))||void 0===M||null===(v=M[1])||void 0===v||null===(P=v.split(")"))||void 0===P?void 0:P[0])||"",this.preCompoundTempo=e.CompoundTempo)}if(t.find((e=>e.element("metronome")))&&null!==(f=this.currentGradualChangeMeasure)&&void 0!==f&&f.speedInfo){const{endXmlNoteIndex:e,resetXmlNoteIndex:t,endMeasureListIndex:i}=this.currentGradualChangeMeasure.speedInfo;0===t&&(this.currentGradualChangeMeasure.speedInfo={...this.currentGradualChangeMeasure.speedInfo,endXmlNoteIndex:e||this.xmlNotes.length,endMeasureListIndex:i||this.currentXmlMeasureIndex,resetXmlNoteIndex:this.xmlNotes.length,resetMeasureListIndex:this.currentXmlMeasureIndex}),this.xmlNotes=[]}s.readExpressionParameters(T,this.instrument,this.divisions,n,r,this.currentMeasure.MeasureNumber,!1),s.read(T,this.currentMeasure,n,r.clone(),l.length,h)}}}else if("barline"===T.name){var E;this.repetitionInstructionReader&&this.repetitionInstructionReader.handleLineRepetitionInstructions(T)&&(this.currentMeasure.HasEndLine=!0);const e=T.attribute("location"),t=null!==(E=null==e?void 0:e.value)&&void 0!==E?E:"right";if(c===I.length-1||"right"===t){var L;const e=null===(L=T.element("bar-style"))||void 0===L?void 0:L.value;e&&(this.currentMeasure.endingBarStyleXml=e,this.currentMeasure.endingBarStyleEnum=Ce.xmlBarlineStyleToSystemLinesEnum(e))}}else if("sound"===T.name)try{if(T.attribute("tempo")){const e=parseFloat(T.attribute("tempo").value);T.element("offset")&&(this.soundTempos.has(this.currentXmlMeasureIndex)||this.soundTempos.set(this.currentXmlMeasureIndex,[]),this.soundTempos.get(this.currentXmlMeasureIndex).push(e)),0===this.currentXmlMeasureIndex&&(this.musicSheet.DefaultStartTempoInBpm=e,this.musicSheet.HasBPMInfo=!0)}}catch(x){s.debug("InstrumentReader.readTempoInstruction",x)}else if("harmony"===T.name){const e=this.getNoteStaff(T);this.currentStaff=this.instrument.Staves[e-1];const t=n.clone();this.currentStaffEntry=this.currentMeasure.findOrCreateStaffEntry(t,this.inSourceMeasureInstrumentIndex+e-1,this.currentStaff).staffEntry,this.currentStaffEntry.ChordContainers.push(Vs.readChordSymbol(T,this.musicSheet,this.activeKey))}}e.CompoundTempo||(e.CompoundTempo=this.preCompoundTempo);for(const e in this.voiceGeneratorsDict)this.voiceGeneratorsDict.hasOwnProperty(e)&&this.voiceGeneratorsDict[e].checkForOpenBeam();if(this.currentXmlMeasureIndex===this.xmlMeasureList.length-1){for(let e=0;e{this.voiceGeneratorsDict[e].finalizeReadingMeasure()})),this.musicSheet.HasBPMInfo?0===e.TempoInBPM&&this.previousMeasure&&(this.currentMeasure.TempoInBPM=this.previousMeasure.TempoInBPM||this.musicSheet.DefaultStartTempoInBpm):this.currentMeasure.TempoInBPM=window.baseMeasureSpeed||120}catch(x){if(o)throw new S(x.Message);const e=Xe.translateText("ReaderErrorMessages/MeasureError","Error while reading Measure.");this.musicSheet.SheetErrors.pushMeasureError(e),s.debug("InstrumentReader.readNextXmlMeasure",e,x)}return this.previousMeasure=this.currentMeasure,this.currentXmlMeasureIndex+=1,!0}getStemDirectionAndColors(e){let t,i=dt.Undefined;const s=e.element("stem");if(s){i=this.getStemDirectionType(s);const e=s.attribute("color");e&&(t=this.parseXmlColor(e.value))}let n=this.getNoteHeadColorXml(e);const r=this.getNoteColorXml(e);return r&&!n&&(n=r),r&&!t&&(t=r),[i,t,n]}parseXmlColor(e){if(e)return 7===e.length?e:9===e.length?"#"+e.substr(3):void 0}doCalculationsAfterDurationHasBeenSet(){for(const e in this.voiceGeneratorsDict)this.voiceGeneratorsDict.hasOwnProperty(e)&&this.voiceGeneratorsDict[e].checkOpenTies()}getOrCreateVoiceGenerator(e,t){const i=this.instrument.Staves[t];let s=this.voiceGeneratorsDict[e];if(s)-1===i.Voices.indexOf(s.GetVoice)&&i.Voices.push(s.GetVoice);else{const n=this.staffMainVoiceGeneratorDict[t];n?(s=new Ds(this.pluginManager,i,e,this.slurReader,n.GetVoice),i.Voices.push(s.GetVoice),this.voiceGeneratorsDict[e]=s):(s=new Ds(this.pluginManager,i,e,this.slurReader),i.Voices.push(s.GetVoice),this.voiceGeneratorsDict[e]=s,this.staffMainVoiceGeneratorDict[t]=s)}return s}createExpressionGenerators(e){this.expressionReaders=new Array(e);for(let t=0;t0?this.musicSheet.SourceMeasures[0]:this.currentMeasure;const i=new J(q.G,0,2);let s;t.FirstInstructionsStaffEntries[e]?(s=t.FirstInstructionsStaffEntries[e],s.removeFirstInstructionOfTypeClefInstruction()):(s=new Je(void 0,void 0),t.FirstInstructionsStaffEntries[e]=s),i.Parent=s,s.Instructions.splice(0,0,i)}createDefaultKeyInstruction(){let e;e=this.musicSheet.SourceMeasures.length>0?this.musicSheet.SourceMeasures[0]:this.currentMeasure;const t=new Z(void 0,0,ee.major);for(let i=this.inSourceMeasureInstrumentIndex;i0&&"backup"===i[s-1].name)return!0;let n=-1;for(let r=0;r0||n<0}isAttributesNodeAtEndOfMeasure(e,t,i){var s;if(i.Equals(null===(s=this.ActiveRhythm)||void 0===s?void 0:s.Rhythm))return!0;const n=e.elements().slice();let r=0;for(let a=0;ao}getNoteDurationFromTypeNode(e){const t=e.element("type");if(t){const e=t.value;return He.getNoteDurationFromType(e)}return new u(0,4*this.divisions)}addAbstractInstruction(e,t,i,n){if(e.element("divisions")&&1===e.elements().length)return;const r=e.element("transpose");if(r){const e=r.element("chromatic");e&&(this.instrument.PlaybackTranspose=parseInt(e.value,10))}const o=e.elements("clef");let a;if(o.length>0)for(let u=0,d=o.length;uthis.currentClefNumber&&(r=this.currentClefNumber),this.currentClefNumber=r+1}catch(c){a=Xe.translateText("ReaderErrorMessages/ClefError","Invalid clef. Using default."),this.musicSheet.SheetErrors.pushMeasureError(a),r=1,this.currentClefNumber=r+1}const g=new J(t,d,i);this.abstractInstructions.push([r,g,n])}if(void 0!==e.element("key")&&this.instrument.MidiInstrumentId!==$.Percussion){let t=0;const i=e.element("key").element("fifths");if(i)try{t=parseInt(i.value,10)}catch(l){a=Xe.translateText("ReaderErrorMessages/KeyError","Invalid key. Set to default."),this.musicSheet.SheetErrors.pushMeasureError(a),t=0,s.debug("InstrumentReader.addAbstractInstruction",a,l)}let r=ee.none,o=e.element("key");if(o&&(o=o.element("mode")),o)try{r=ee[o.value]}catch(l){a=Xe.translateText("ReaderErrorMessages/KeyError","Invalid key/mode. Set to default."),this.musicSheet.SheetErrors.pushMeasureError(a),r=ee.major,s.debug("InstrumentReader.addAbstractInstruction",a,l)}const h=new Z(void 0,t,r);this.abstractInstructions.push([1,h,n])}if(e.element("time")){const t=e.element("time");let i=T.NONE,r=!0;if(void 0!==t&&t.hasAttributes){const e=t.attribute("symbol");e&&("common"===e.value?i=T.COMMON:"cut"===e.value&&(i=T.CUT));const s=t.attribute("print-object");s&&"no"===s.value&&(r=!1)}let o=0,h=0;const c=t&&void 0!==t.element("senza-misura"),d=e.elements("time"),f=[],m=[];for(let e=0,s=d.length;e0&&void 0!==m&&f.length===m.length){const e=f.length,t=new Array(e);let i=0;for(let s=0;s=0;i--){const s=this.abstractInstructions[i],n=s[0],r=s[1],o=s[2];if(r instanceof J){const e=r;if(0===this.currentXmlMeasureIndex||n<=this.activeClefs.length&&e!==this.activeClefs[n-1])if(t||void 0===this.currentStaffEntry||this.currentStaffEntry.hasNotes()||n-1!==this.instrument.Staves.indexOf(this.currentStaffEntry.ParentStaff))if(t){if(0!==o.RealValue)continue;let t;if(this.currentMeasure){const s=e,r=this.inSourceMeasureInstrumentIndex+n-1,o=this.currentMeasure.FirstInstructionsStaffEntries[r];if(0===this.currentXmlMeasureIndex)if(o)if(void 0===this.currentMeasure.FirstInstructionsStaffEntries[r]||o.Instructions[0]instanceof J){const e=new Je(void 0,void 0);this.currentMeasure.LastInstructionsStaffEntries[r]=e,s.Parent=e,e.Instructions.push(s)}else t=o,s.Parent=t,t.removeFirstInstructionOfTypeClefInstruction(),t.Instructions.splice(0,0,s),this.activeClefsHaveBeenInitialized[n-1]=!0;else t=new Je(void 0,void 0),this.currentMeasure.FirstInstructionsStaffEntries[r]=t,s.Parent=t,t.Instructions.push(s),this.activeClefsHaveBeenInitialized[n-1]=!0;else if(this.activeClefsHaveBeenInitialized[n-1]){let e=this.previousMeasure;this.followingMultirestMeasures>0&&this.currentMeasure.Rules.RenderMultipleRestMeasures&&(e=this.currentMultirestStartMeasure);const t=new Je(void 0,void 0);e.LastInstructionsStaffEntries[r]=t,s.Parent=t,t.Instructions.push(s)}else{const e=this.musicSheet.SourceMeasures[0];e.FirstInstructionsStaffEntries[r]?(t=e.FirstInstructionsStaffEntries[r],t.removeFirstInstructionOfTypeClefInstruction()):t=new Je(void 0,void 0),s.Parent=t,t.Instructions.splice(0,0,s),this.activeClefsHaveBeenInitialized[n-1]=!0}this.activeClefs[n-1]=e,this.abstractInstructions.splice(i,1)}}else{let t;const s=this.activeRhythm.Rhythm;s.RealValue>0&&o.RealValue/s.RealValue>.9&&s.RealValue!==o.RealValue&&(this.currentMeasure.LastInstructionsStaffEntries[n-1]||(this.currentMeasure.LastInstructionsStaffEntries[n-1]=new Je(void 0,this.instrument.Staves[n-1])),t=this.currentMeasure.LastInstructionsStaffEntries[n-1]),t&&(e.Parent=t,t.Instructions.push(e),this.activeClefs[n-1]=e,this.abstractInstructions.splice(i,1))}else{const t=e,s=this.currentStaffEntry;if(o&&Math.abs(o.RealValue-s.Timestamp.RealValue)>.01)continue;t.Parent=s,s.removeFirstInstructionOfTypeClefInstruction(),s.Instructions.push(t),this.activeClefs[n-1]=e,this.abstractInstructions.splice(i,1)}else n<=this.activeClefs.length&&e===this.activeClefs[n-1]&&this.abstractInstructions.splice(i,1)}if(r instanceof Z){const t=r;if(this.activeKey&&this.activeKey.Key===t.Key)this.abstractInstructions.splice(i,1);else{let s;if(this.activeKey=t,this.abstractInstructions.splice(i,1),this.activeKeyHasBeenInitialized?s=this.currentMeasure:(this.activeKeyHasBeenInitialized=!0,s=this.currentXmlMeasureIndex>0?this.musicSheet.SourceMeasures[0]:this.currentMeasure),s)for(let i=this.inSourceMeasureInstrumentIndex;i=0;e--){const t=this.abstractInstructions[e][0],i=this.abstractInstructions[e][1];if(i instanceof J){const s=i;if(!this.activeClefs[t-1]||s.ClefType!==this.activeClefs[t-1].ClefType||s.ClefType===this.activeClefs[t-1].ClefType&&s.Line!==this.activeClefs[t-1].Line){const i=new Je(void 0,void 0);this.currentMeasure.LastInstructionsStaffEntries[this.inSourceMeasureInstrumentIndex+t-1]=i;const n=s;n.Parent=i,i.Instructions.push(n),this.activeClefs[t-1]=s,this.abstractInstructions.splice(e,1)}}}}getNoteDurationForTuplet(e){const t=e.element("duration"),i=Number.parseInt(t.value,10);return new u(i,4*this.divisions)}readExpressionStaffNumber(e){let t=1;if(e.element("staff")){const n=e.element("staff");if(n)try{t=parseInt(n.value,10)}catch(i){const e=Xe.translateText("ReaderErrorMessages/ExpressionStaffError","Invalid Expression staff number. Set to default.");this.musicSheet.SheetErrors.pushMeasureError(e),t=1,s.debug("InstrumentReader.readExpressionStaffNumber",e,i)}}return t}readDivisionsFromNotes(){let e=0,t=this.currentXmlMeasureIndex,i=!1;for(;!i;){const r=this.xmlMeasureList[t].elements();for(let t=0,o=r.length;t0){i=!0;break}}if(0===e&&(t++,t===this.xmlMeasureList.length)){const e=Xe.translateText("ReaderErrorMEssages/DivisionsError","Invalid divisions value at Instrument: ");throw new S(e+this.instrument.Name)}}return e}getCueNoteAndNoteTypeXml(e){let t=!1;e.element("cue")&&(t=!0);const i=e.element("type");let s=ze.UNDEFINED;if(i){const e=i.attribute("size");"cue"===(null==e?void 0:e.value)&&(t=!0),s=He.StringToNoteType(i.value)}return[t,s]}getStemDirectionType(e){switch(e.value){case"down":return dt.Down;case"up":return dt.Up;case"double":return dt.Double;case"none":return dt.None;default:return dt.Undefined}}getNoteHeadColorXml(e){const t=e.element("notehead");if(t){const e=t.attribute("color");if(e)return this.parseXmlColor(e.value)}return null}getNoteColorXml(e){const t=e.attribute("color");return t?this.parseXmlColor(t.value):null}getTremoloInfo(e){let t,i;const s=e.element("tremolo");if(s){const e=s.attribute("type");if(e){if("single"===e.value){const e=parseInt(s.value,10);e>0&&(t=e)}else t=0;"unmeasured"===e.value&&(i=!0)}}return{tremoloStrokes:t,tremoloUnmeasured:i}}getWavyLines(e,t,i,s){const n=e.elements("wavy-line");if(n)for(const r of n){const e=this.expressionReaders[this.readExpressionStaffNumber(t)-1];e&&(e.readExpressionParameters(r,this.instrument,this.divisions,i,s,this.currentMeasure.MeasureNumber,!1),e.addWavyLine(r,this.currentMeasure,i,s))}}getNoteStaff(e){let t=1;return this.instrument.Staves.length>1&&e.element("staff")&&(t=parseInt(e.element("staff").value,10),isNaN(t)&&(s.debug("InstrumentReader.readNextXmlMeasure.get staff number"),t=1)),t}}class Ws{}Ws.MidiInstrument={banjo:$.Banjo,blockfloete:$.Recorder,brass:$.Trombone,bratsche:$.Viola,cello:$.Cello,clarinet:$.Clarinet,contrabass:$.Contrabass,"steel drum":$.Steel_Drums,drums:$.Percussion,flute:$.Flute,floete:$.Flute,frenchhorn:$.French_Horn,gitarre:$.Acoustic_Guitar_nylon,guitar:$.Acoustic_Guitar_nylon,harfe:$.Orchestral_Harp,harp:$.Orchestral_Harp,klarinette:$.Clarinet,klavier:$.Acoustic_Grand_Piano,kontrabass:$.Contrabass,oboe:$.Oboe,organ:$.Church_Organ,orgel:$.Church_Organ,orgue:$.Church_Organ,percussion:$.Percussion,piano:$.Acoustic_Grand_Piano,piccolo:$.Piccolo,posaune:$.Trombone,recorder:$.Recorder,sax:$.Tenor_Sax,schlagwerk:$.Percussion,schlagzeug:$.Percussion,steeldrum:$.Steel_Drums,streicher:$.String_Ensemble_1,strings:$.String_Ensemble_1,tpt:$.Trumpet,trombone:$.Trombone,trompete:$.Trumpet,trumpet:$.Trumpet,tuba:$.Tuba,unnamed:$.Acoustic_Grand_Piano,viola:$.Viola,violin:$.Violin,"violon-c":$.Cello,"violon.":$.Violin,voice:$.Synth_Voice,woodblock:$.Woodblock,alt:$.Synth_Voice,alto:$.Synth_Voice,bariton:$.Synth_Voice,baritone:$.Synth_Voice,bass:$.Synth_Voice,sopran:$.Synth_Voice,tenor:$.Synth_Voice},Ws.MidiInstrumentSounds={"brass.alphorn":$.French_Horn,"brass.alto-horn":$.French_Horn,"brass.baritone-horn":$.French_Horn,"brass.bugle":$.Trumpet,"brass.bugle.alto":$.Trumpet,"brass.bugle.baritone":$.Trombone,"brass.bugle.contrabass":$.Trombone,"brass.bugle.euphonium-bugle":$.French_Horn,"brass.bugle.mellophone-bugle":$.French_Horn,"brass.bugle.soprano":$.Trumpet,"brass.cimbasso":$.Trombone,"brass.conch-shell":$.Flute,"brass.cornet":$.Trumpet,"brass.cornet.soprano":$.Trumpet,"brass.cornett":$.Trumpet,"brass.cornett.tenor":$.Trumpet,"brass.cornettino":$.Trumpet,"brass.didgeridoo":$.Flute,"brass.euphonium":$.French_Horn,"brass.fiscorn":$.French_Horn,"brass.flugelhorn":$.French_Horn,"brass.french-horn":$.French_Horn,"brass.group":$.Brass_Section,"brass.group.synth":$.Synth_Brass_1,"brass.helicon":$.French_Horn,"brass.horagai":$.Trumpet,"brass.kuhlohorn":$.French_Horn,"brass.mellophone":$.French_Horn,"brass.natural-horn":$.French_Horn,"brass.ophicleide":$.French_Horn,"brass.posthorn":$.French_Horn,"brass.saxhorn":$.French_Horn,"brass.sousaphone":$.Tuba,"brass.trombone":$.Trombone,"brass.trombone.alto":$.Trombone,"brass.trombone.bass":$.Trombone,"brass.trombone.contrabass":$.Trombone,"brass.trombone.tenor":$.Trombone,"brass.trumpet":$.Trumpet,"brass.trumpet.baroque":$.Trumpet,"brass.trumpet.bass":$.Trombone,"brass.trumpet.bflat":$.Trumpet,"brass.trumpet.c":$.Trumpet,"brass.trumpet.d":$.Trumpet,"brass.trumpet.piccolo":$.Trumpet,"brass.trumpet.pocket":$.Trumpet,"brass.trumpet.slide":$.Trumpet,"brass.trumpet.tenor":$.Trumpet,"brass.tuba":$.Tuba,"brass.tuba.bass":$.Tuba,"brass.tuba.subcontrabass":$.Tuba,"brass.vienna-horn":$.French_Horn,"brass.wagner-tuba":$.French_Horn,"drum.ashiko":$.Shakuhachi,"drum.bass-drum":$.Percussion,"drum.bongo":$.Percussion,"drum.bougarabou":$.Percussion,"drum.buffalo-drum":$.Percussion,"drum.cajon":$.Percussion,"drum.chenda":$.Percussion,"drum.chu-daiko":$.Percussion,"drum.conga":$.Percussion,"drum.cuica":$.Percussion,"drum.dabakan":$.Percussion,"drum.daff":$.Percussion,"drum.dafli":$.Percussion,"drum.daibyosi":$.Percussion,"drum.damroo":$.Percussion,"drum.darabuka":$.Percussion,"drum.def":$.Percussion,"drum.dhol":$.Percussion,"drum.dholak":$.Percussion,"drum.djembe":$.Percussion,"drum.doira":$.Percussion,"drum.dondo":$.Percussion,"drum.doun-doun-ba":$.Percussion,"drum.duff":$.Percussion,"drum.dumbek":$.Percussion,"drum.fontomfrom":$.Percussion,"drum.frame-drum":$.Percussion,"drum.frame-drum.arabian":$.Percussion,"drum.geduk":$.Percussion,"drum.ghatam":$.Percussion,"drum.gome":$.Percussion,"drum.group":$.Percussion,"drum.group.chinese":$.Percussion,"drum.group.ewe":$.Percussion,"drum.group.indian":$.Percussion,"drum.group.set":$.Percussion,"drum.hand-drum":$.Percussion,"drum.hira-daiko":$.Percussion,"drum.ibo":$.Percussion,"drum.igihumurizo":$.Percussion,"drum.inyahura":$.Percussion,"drum.ishakwe":$.Percussion,"drum.jang-gu":$.Percussion,"drum.kagan":$.Percussion,"drum.kakko":$.Percussion,"drum.kanjira":$.Percussion,"drum.kendhang":$.Percussion,"drum.kendhang.ageng":$.Percussion,"drum.kendhang.ciblon":$.Percussion,"drum.kenkeni":$.Percussion,"drum.khol":$.Percussion,"drum.kick-drum":$.Percussion,"drum.kidi":$.Percussion,"drum.ko-daiko":$.Percussion,"drum.kpanlogo":$.Percussion,"drum.kudum":$.Percussion,"drum.lambeg":$.Percussion,"drum.lion-drum":$.Percussion,"drum.log-drum":$.Percussion,"drum.log-drum.african":$.Percussion,"drum.log-drum.native":$.Percussion,"drum.log-drum.nigerian":$.Percussion,"drum.madal":$.Percussion,"drum.maddale":$.Percussion,"drum.mridangam":$.Percussion,"drum.naal":$.Percussion,"drum.nagado-daiko":$.Percussion,"drum.nagara":$.Percussion,"drum.naqara":$.Percussion,"drum.o-daiko":$.Percussion,"drum.okawa":$.Percussion,"drum.okedo-daiko":$.Percussion,"drum.pahu-hula":$.Percussion,"drum.pakhawaj":$.Percussion,"drum.pandeiro":$.Percussion,"drum.pandero":$.Percussion,"drum.powwow":$.Percussion,"drum.pueblo":$.Percussion,"drum.repinique":$.Percussion,"drum.riq":$.Percussion,"drum.rototom":$.Percussion,"drum.sabar":$.Percussion,"drum.sakara":$.Percussion,"drum.sampho":$.Percussion,"drum.sangban":$.Percussion,"drum.shime-daiko":$.Percussion,"drum.slit-drum":$.Percussion,"drum.slit-drum.krin":$.Percussion,"drum.snare-drum":$.Percussion,"drum.snare-drum.electric":$.Synth_Drum,"drum.sogo":$.Percussion,"drum.surdo":$.Percussion,"drum.tabla":$.Percussion,"drum.tabla.bayan":$.Percussion,"drum.tabla.dayan":$.Percussion,"drum.tabor":$.Percussion,"drum.taiko":$.Taiko_Drum,"drum.talking":$.Percussion,"drum.tama":$.Percussion,"drum.tamborim":$.Percussion,"drum.tamborita":$.Percussion,"drum.tambourine":$.Percussion,"drum.tamte":$.Percussion,"drum.tangku":$.Percussion,"drum.tan-tan":$.Percussion,"drum.taphon":$.Percussion,"drum.tar":$.Percussion,"drum.tasha":$.Percussion,"drum.tenor-drum":$.Percussion,"drum.teponaxtli":$.Percussion,"drum.thavil":$.Percussion,"drum.the-box":$.Percussion,"drum.timbale":$.Percussion,"drum.timpani":$.Timpani,"drum.tinaja":$.Percussion,"drum.toere":$.Percussion,"drum.tombak":$.Percussion,"drum.tom-tom":$.Melodic_Tom,"drum.tom-tom.synth":$.Melodic_Tom,"drum.tsuzumi":$.Percussion,"drum.tumbak":$.Percussion,"drum.uchiwa-daiko":$.Percussion,"drum.udaku":$.Percussion,"drum.udu":$.Percussion,"drum.zarb":$.Percussion,"effect.applause":$.Applause,"effect.gunshot":$.Gunshot,"effect.helicopter":$.Helicopter,"effect.telephone-ring":$.Telephone_Ring,"keyboard.accordion":$.Accordion,"keyboard.bandoneon":$.Accordion,"keyboard.celesta":$.Celesta,"keyboard.clavichord":$.Harpsichord,"keyboard.clavichord.synth":$.Harpsichord,"keyboard.concertina":$.Accordion,"keyboard.fortepiano":$.Acoustic_Grand_Piano,"keyboard.harmonium":$.Drawbar_Organ,"keyboard.harpsichord":$.Harpsichord,"keyboard.ondes-martenot":$.Pad_3_polysynth,"keyboard.organ":$.Church_Organ,"keyboard.organ.drawbar":$.Percussive_Organ,"keyboard.organ.percussive":$.Rock_Organ,"keyboard.organ.pipe":$.Church_Organ,"keyboard.organ.reed":$.Church_Organ,"keyboard.organ.rotary":$.Rock_Organ,"keyboard.piano":$.Acoustic_Grand_Piano,"keyboard.piano.electric":$.Electric_Grand_Piano,"keyboard.piano.grand":$.Acoustic_Grand_Piano,"keyboard.piano.honky-tonk":$.Honky_tonk_Piano,"keyboard.piano.prepared":$.Acoustic_Grand_Piano,"keyboard.piano.toy":$.Honky_tonk_Piano,"keyboard.piano.upright":$.Acoustic_Grand_Piano,"keyboard.virginal":$.Acoustic_Grand_Piano,"metal.adodo":$.Xylophone,"metal.anvil":$.Xylophone,"metal.babendil":$.Xylophone,"metal.bells.agogo":$.Agogo,"metal.bells.almglocken":$.Tubular_Bells,"metal.bells.bell-plate":$.Tubular_Bells,"metal.bells.bell-tree":$.Tubular_Bells,"metal.bells.carillon":$.Tubular_Bells,"metal.bells.chimes":$.Tinkle_Bell,"metal.bells.chimta":$.Tubular_Bells,"metal.bells.chippli":$.Tubular_Bells,"metal.bells.church":$.Tubular_Bells,"metal.bells.cowbell":$.Percussion,"metal.bells.dawuro":$.Percussion,"metal.bells.gankokwe":$.Percussion,"metal.bells.ghungroo":$.Percussion,"metal.bells.hatheli":$.Percussion,"metal.bells.jingle-bell":$.Percussion,"metal.bells.khartal":$.Percussion,"metal.bells.mark-tree":$.Percussion,"metal.bells.sistrum":$.Percussion,"metal.bells.sleigh-bells":$.Percussion,"metal.bells.temple":$.Percussion,"metal.bells.tibetan":$.Percussion,"metal.bells.tinklebell":$.Percussion,"metal.bells.trychel":$.Percussion,"metal.bells.wind-chimes":$.Percussion,"metal.bells.zills":$.Percussion,"metal.berimbau":$.Flute,"metal.brake-drums":$.Percussion,"metal.crotales":$.Percussion,"metal.cymbal.bo":$.Percussion,"metal.cymbal.ceng-ceng":$.Percussion,"metal.cymbal.chabara":$.Percussion,"metal.cymbal.chinese":$.Percussion,"metal.cymbal.ching":$.Percussion,"metal.cymbal.clash":$.Percussion,"metal.cymbal.crash":$.Percussion,"metal.cymbal.finger":$.Percussion,"metal.cymbal.hand":$.Percussion,"metal.cymbal.kesi":$.Percussion,"metal.cymbal.manjeera":$.Percussion,"metal.cymbal.reverse":$.Percussion,"metal.cymbal.ride":$.Percussion,"metal.cymbal.sizzle":$.Percussion,"metal.cymbal.splash":$.Percussion,"metal.cymbal.suspended":$.Percussion,"metal.cymbal.tebyoshi":$.Percussion,"metal.cymbal.tibetan":$.Percussion,"metal.cymbal.tingsha":$.Percussion,"metal.flexatone":$.Percussion,"metal.gong":$.Percussion,"metal.gong.ageng":$.Percussion,"metal.gong.agung":$.Percussion,"metal.gong.chanchiki":$.Percussion,"metal.gong.chinese":$.Percussion,"metal.gong.gandingan":$.Percussion,"metal.gong.kempul":$.Percussion,"metal.gong.kempyang":$.Percussion,"metal.gong.ketuk":$.Percussion,"metal.gong.kkwenggwari":$.Percussion,"metal.gong.luo":$.Percussion,"metal.gong.singing":$.Percussion,"metal.gong.thai":$.Percussion,"metal.guira":$.Percussion,"metal.hang":$.Percussion,"metal.hi-hat":$.Percussion,"metal.jaw-harp":$.Percussion,"metal.kengong":$.Percussion,"metal.murchang":$.Percussion,"metal.musical-saw":$.Percussion,"metal.singing-bowl":$.Percussion,"metal.spoons":$.Percussion,"metal.steel-drums":$.Percussion,"metal.tamtam":$.Percussion,"metal.thundersheet":$.Percussion,"metal.triangle":$.Percussion,"metal.washboard":$.Percussion,"pitched-percussion.angklung":$.Xylophone,"pitched-percussion.balafon":$.Xylophone,"pitched-percussion.bell-lyre":$.Xylophone,"pitched-percussion.bells":$.Tubular_Bells,"pitched-percussion.bianqing":$.Xylophone,"pitched-percussion.bianzhong":$.Xylophone,"pitched-percussion.bonang":$.Xylophone,"pitched-percussion.cimbalom":$.Xylophone,"pitched-percussion.crystal-glasses":$.Xylophone,"pitched-percussion.dan-tam-thap-luc":$.Xylophone,"pitched-percussion.fangxiang":$.Xylophone,"pitched-percussion.gandingan-a-kayo":$.Xylophone,"pitched-percussion.gangsa":$.Xylophone,"pitched-percussion.gender":$.Xylophone,"pitched-percussion.giying":$.Xylophone,"pitched-percussion.glass-harmonica":$.Xylophone,"pitched-percussion.glockenspiel":$.Glockenspiel,"pitched-percussion.glockenspiel.alto":$.Glockenspiel,"pitched-percussion.glockenspiel.soprano":$.Glockenspiel,"pitched-percussion.gyil":$.Xylophone,"pitched-percussion.hammer-dulcimer":$.Dulcimer,"pitched-percussion.handbells":$.Tubular_Bells,"pitched-percussion.handchimes":$.Tubular_Bells,"pitched-percussion.kalimba":$.Kalimba,"pitched-percussion.kantil":$.Xylophone,"pitched-percussion.khim":$.Xylophone,"pitched-percussion.kulintang":$.Xylophone,"pitched-percussion.kulintang-a-kayo":$.Xylophone,"pitched-percussion.kulintang-a-tiniok":$.Xylophone,"pitched-percussion.likembe":$.Xylophone,"pitched-percussion.luntang":$.Xylophone,"pitched-percussion.marimba":$.Marimba,"pitched-percussion.marimba.bass":$.Marimba,"pitched-percussion.mbira":$.Marimba,"pitched-percussion.mbira.array":$.Marimba,"pitched-percussion.metallophone":$.Xylophone,"pitched-percussion.metallophone.alto":$.Xylophone,"pitched-percussion.metallophone.bass":$.Xylophone,"pitched-percussion.metallophone.soprano":$.Xylophone,"pitched-percussion.music-box":$.Glockenspiel,"pitched-percussion.pelog-panerus":$.Xylophone,"pitched-percussion.pemade":$.Xylophone,"pitched-percussion.penyacah":$.Xylophone,"pitched-percussion.ranat.ek":$.Xylophone,"pitched-percussion.ranat.ek-lek":$.Xylophone,"pitched-percussion.ranat.thum":$.Xylophone,"pitched-percussion.ranat.thum-lek":$.Xylophone,"pitched-percussion.reyong":$.Xylophone,"pitched-percussion.sanza":$.Xylophone,"pitched-percussion.saron-barung":$.Xylophone,"pitched-percussion.saron-demong":$.Xylophone,"pitched-percussion.saron-panerus":$.Xylophone,"pitched-percussion.slendro-panerus":$.Xylophone,"pitched-percussion.slentem":$.Xylophone,"pitched-percussion.tsymbaly":$.Xylophone,"pitched-percussion.tubes":$.Tubular_Bells,"pitched-percussion.tubular-bells":$.Tubular_Bells,"pitched-percussion.vibraphone":$.Vibraphone,"pitched-percussion.xylophone":$.Xylophone,"pitched-percussion.xylophone.alto":$.Xylophone,"pitched-percussion.xylophone.bass":$.Xylophone,"pitched-percussion.xylophone.soprano":$.Xylophone,"pitched-percussion.xylorimba":$.Xylophone,"pitched-percussion.yangqin":$.Xylophone,"pluck.archlute":$.Acoustic_Guitar_nylon,"pluck.autoharp":$.Orchestral_Harp,"pluck.baglama":$.Orchestral_Harp,"pluck.bajo":$.Acoustic_Guitar_steel,"pluck.balalaika":$.Acoustic_Guitar_steel,"pluck.balalaika.alto":$.Acoustic_Guitar_steel,"pluck.balalaika.bass":$.Acoustic_Guitar_steel,"pluck.balalaika.contrabass":$.Acoustic_Guitar_steel,"pluck.balalaika.piccolo":$.Acoustic_Guitar_steel,"pluck.balalaika.prima":$.Acoustic_Guitar_steel,"pluck.balalaika.secunda":$.Acoustic_Guitar_steel,"pluck.bandola":$.Acoustic_Guitar_steel,"pluck.bandura":$.Acoustic_Guitar_steel,"pluck.bandurria":$.Acoustic_Guitar_steel,"pluck.banjo":$.Banjo,"pluck.banjo.tenor":$.Banjo,"pluck.banjolele":$.Banjo,"pluck.barbat":$.Acoustic_Guitar_steel,"pluck.bass":$.Electric_Bass_finger,"pluck.bass.acoustic":$.Acoustic_Bass,"pluck.bass.bolon":$.Electric_Bass_finger,"pluck.bass.electric":$.Electric_Bass_finger,"pluck.bass.fretless":$.Fretless_Bass,"pluck.bass.guitarron":$.Acoustic_Bass,"pluck.bass.synth":$.Synth_Bass_1,"pluck.bass.synth.lead":$.Synth_Bass_2,"pluck.celtic-harp":$.Orchestral_Harp,"pluck.charango":$.Acoustic_Guitar_nylon,"pluck.chitarra-battente":$.Acoustic_Guitar_nylon,"pluck.cithara":$.Acoustic_Guitar_nylon,"pluck.cittern":$.Acoustic_Guitar_nylon,"pluck.cuatro":$.Acoustic_Guitar_nylon,"pluck.dulcimer":$.Dulcimer,"pluck.dutar":$.Acoustic_Grand_Piano,"pluck.duxianqin":$.Dulcimer,"pluck.ektara":$.Acoustic_Guitar_nylon,"pluck.guitar":$.Acoustic_Guitar_nylon,"pluck.guitar.acoustic":$.Acoustic_Guitar_nylon,"pluck.guitar.electric":$.Electric_Guitar_clean,"pluck.guitar.nylon-string":$.Electric_Guitar_clean,"pluck.guitar.pedal-steel":$.Electric_Guitar_clean,"pluck.guitar.portuguese":$.Acoustic_Guitar_nylon,"pluck.guitar.requinto":$.Acoustic_Guitar_nylon,"pluck.guitar.resonator":$.Acoustic_Guitar_nylon,"pluck.guitar.steel-string":$.Acoustic_Guitar_steel,"pluck.harp":$.Orchestral_Harp,"pluck.harp-guitar":$.Orchestral_Harp,"pluck.huapanguera":$.Orchestral_Harp,"pluck.lute":$.Acoustic_Grand_Piano,"pluck.lyre":$.Orchestral_Harp,"pluck.mandobass":$.Acoustic_Guitar_nylon,"pluck.mandocello":$.Acoustic_Guitar_nylon,"pluck.mandola":$.Acoustic_Guitar_nylon,"pluck.mandolin":$.Acoustic_Guitar_nylon,"pluck.mandolin.octave":$.Acoustic_Guitar_nylon,"pluck.setar":$.Acoustic_Guitar_nylon,"pluck.shamisen":$.Shamisen,"pluck.sitar":$.Sitar,"pluck.synth":$.Electric_Bass_pick,"pluck.synth.charang":$.Electric_Bass_pick,"pluck.synth.chiff":$.Electric_Bass_pick,"pluck.synth.stick":$.Electric_Bass_pick,"pluck.tambura":$.Acoustic_Grand_Piano,"pluck.ukulele":$.Banjo,"pluck.ukulele.tenor":$.Banjo,"strings.arpeggione":$.Cello,"strings.cello":$.Cello,"strings.cello.piccolo":$.Cello,"strings.contrabass":$.Contrabass,"strings.fiddle":$.Fiddle,"strings.fiddle.hardanger":$.Fiddle,"strings.group":$.String_Ensemble_1,"strings.group.synth":$.Synth_Strings_1,"strings.octobass":$.Contrabass,"strings.tromba-marina":$.Contrabass,"strings.vielle":$.Violin,"strings.viol":$.Violin,"strings.viol.alto":$.Violin,"strings.viol.bass":$.Violin,"strings.viol.tenor":$.Violin,"strings.viol.treble":$.Violin,"strings.viol.violone":$.Violin,"strings.viola":$.Viola,"strings.viola-damore":$.Viola,"strings.violin":$.Violin,"strings.violono.piccolo":$.Violin,"strings.violotta":$.Viola,"synth.group":$.Pad_3_polysynth,"synth.group.fifths":$.Pad_3_polysynth,"synth.group.orchestra":$.Orchestra_Hit,"synth.pad":$.Pad_1_new_age,"synth.pad.bowed":$.Pad_1_new_age,"synth.pad.choir":$.Pad_4_choir,"synth.pad.halo":$.Acoustic_Grand_Piano,"synth.pad.polysynth":$.Pad_3_polysynth,"voice.alto":$.Voice_Oohs,"voice.baritone":$.Voice_Oohs,"voice.bass":$.Voice_Oohs,"voice.female":$.Synth_Voice,"voice.kazoo":$.Flute,"voice.male":$.Voice_Oohs,"voice.mezzo-soprano":$.Voice_Oohs,"voice.soprano":$.Voice_Oohs,"voice.synth":$.Synth_Voice,"voice.tenor":$.Voice_Oohs,"voice.vocals":$.Choir_Aahs,"wind.flutes.flute":$.Flute,"wind.flutes.flute.alto":$.Flute,"wind.flutes.flute.bass":$.Flute,"wind.flutes.flute.contra-alto":$.Flute,"wind.flutes.flute.contrabass":$.Flute,"wind.flutes.flute.double-contrabass":$.Flute,"wind.flutes.flute.irish":$.Flute,"wind.flutes.flute.piccolo":$.Piccolo,"wind.flutes.flute.subcontrabass":$.Flute,"wind.flutes.ocarina":$.Ocarina,"wind.flutes.panpipes":$.Pan_Flute,"wind.flutes.recorder":$.Acoustic_Grand_Piano,"wind.flutes.recorder.alto":$.Recorder,"wind.flutes.recorder.bass":$.Recorder,"wind.flutes.recorder.contrabass":$.Recorder,"wind.flutes.recorder.descant":$.Recorder,"wind.flutes.recorder.garklein":$.Recorder,"wind.flutes.recorder.great-bass":$.Recorder,"wind.flutes.recorder.sopranino":$.Recorder,"wind.flutes.recorder.soprano":$.Recorder,"wind.flutes.recorder.tenor":$.Recorder,"wind.flutes.shakuhachi":$.Shakuhachi,"wind.flutes.whistle":$.Whistle,"wind.flutes.whistle.alto":$.Whistle,"wind.flutes.whistle.low-irish":$.Whistle,"wind.flutes.whistle.shiva":$.Whistle,"wind.flutes.whistle.slide":$.Whistle,"wind.flutes.whistle.tin":$.Whistle,"wind.flutes.whistle.tin.bflat":$.Whistle,"wind.flutes.whistle.tin.c":$.Whistle,"wind.flutes.whistle.tin.d":$.Whistle,"wind.group":$.Flute,"wind.pipes.bagpipes":$.Bag_pipe,"wind.reed.basset-horn":$.Bassoon,"wind.reed.bassoon":$.Bassoon,"wind.reed.bombarde":$.Bassoon,"wind.reed.clarinet":$.Clarinet,"wind.reed.clarinet.a":$.Clarinet,"wind.reed.clarinet.alto":$.Clarinet,"wind.reed.clarinet.bass":$.Clarinet,"wind.reed.clarinet.basset":$.Clarinet,"wind.reed.clarinet.bflat":$.Clarinet,"wind.reed.clarinet.contra-alto":$.Clarinet,"wind.reed.clarinet.contrabass":$.Clarinet,"wind.reed.clarinet.d":$.Clarinet,"wind.reed.clarinet.eflat":$.Clarinet,"wind.reed.clarinet.g":$.Clarinet,"wind.reed.clarinet.piccolo":$.Clarinet,"wind.reed.clarinet.piccolo.aflat":$.Clarinet,"wind.reed.clarinette-damour":$.Clarinet,"wind.reed.contrabass":$.Clarinet,"wind.reed.contrabassoon":$.Clarinet,"wind.reed.cornamuse":$.Bag_pipe,"wind.reed.english-horn":$.English_Horn,"wind.reed.harmonica":$.Harmonica,"wind.reed.harmonica.bass":$.Harmonica,"wind.reed.oboe":$.Oboe,"wind.reed.oboe.bass":$.Oboe,"wind.reed.oboe.piccolo":$.Oboe,"wind.reed.oboe-da-caccia":$.Oboe,"wind.reed.oboe-damore":$.Oboe,"wind.reed.saxonette":$.Soprano_Sax,"wind.reed.saxophone":$.Alto_Sax,"wind.reed.saxophone.alto":$.Alto_Sax,"wind.reed.saxophone.aulochrome":$.Alto_Sax,"wind.reed.saxophone.baritone":$.Baritone_Sax,"wind.reed.saxophone.bass":$.Baritone_Sax,"wind.reed.saxophone.contrabass":$.Baritone_Sax,"wind.reed.saxophone.melody":$.Baritone_Sax,"wind.reed.saxophone.mezzo-soprano":$.Alto_Sax,"wind.reed.saxophone.sopranino":$.Soprano_Sax,"wind.reed.saxophone.sopranissimo":$.Soprano_Sax,"wind.reed.saxophone.soprano":$.Soprano_Sax,"wind.reed.saxophone.subcontrabass":$.Baritone_Sax,"wind.reed.saxophone.tenor":$.Tenor_Sax,"wood.bones":$.Woodblock,"wood.castanets":$.Woodblock,"wood.claves":$.Woodblock,"wood.drum-sticks":$.Woodblock,"wood.gourd":$.Woodblock,"wood.granite-block":$.Woodblock,"wood.guban":$.Woodblock,"wood.guiro":$.Woodblock,"wood.hyoushigi":$.Woodblock,"wood.ipu":$.Woodblock,"wood.jam-block":$.Woodblock,"wood.kaekeeke":$.Woodblock,"wood.kagul":$.Woodblock,"wood.kalaau":$.Woodblock,"wood.kashiklar":$.Woodblock,"wood.kubing":$.Woodblock,"wood.pan-clappers":$.Woodblock,"wood.sand-block":$.Woodblock,"wood.slapstick":$.Woodblock,"wood.stir-drum":$.Woodblock,"wood.temple-block":$.Woodblock,"wood.tic-toc-block":$.Woodblock,"wood.tonetang":$.Woodblock,"wood.wood-block":$.Woodblock};class Us{constructor(e){this.parentInstrument=e,this.fixedKey=-1,this.name=this.parseMidiInstrument(this.parentInstrument.Name),this.midiInstrumentID=Ws.MidiInstrument[this.name],this.volume=1}get ParentInstrument(){return this.parentInstrument}static isPianoInstrument(e){return e===$.Acoustic_Grand_Piano||e===$.Bright_Acoustic_Piano||e===$.Electric_Grand_Piano||e===$.Electric_Piano_1||e===$.Electric_Piano_2}setMidiInstrumentSound(e){this.midiInstrumentID=Ws.MidiInstrumentSounds[e]}setMidiInstrument(e){this.midiInstrumentID=Ws.MidiInstrument[this.parseMidiInstrument(e)]}parseMidiInstrument(e){try{if(e){const t=e.toLowerCase().trim();for(const e in Ws.MidiInstrument)if(-1!==t.indexOf(e))return e}if(this.parentInstrument.Name){const e=this.parentInstrument.Name.toLowerCase().trim();for(const t in Ws.MidiInstrument)if(-1!==e.indexOf(t))return t}}catch(t){s.error("Error parsing MIDI Instrument. Default to Grand Piano.")}return"unnamed"}}class Xs{static StringContainsSeparatedWord(e,t,i=!1){return new RegExp("( |^)"+t+"([ .]|$)",i?"i":void 0).test(e)}}e("S",Xs);class zs{set MusicSheet(e){this.musicSheet=e,this.xmlMeasureList=new Array(this.musicSheet.Instruments.length),this.repetitionInstructions=[]}prepareReadingMeasure(e,t){this.currentMeasureIndex=t}handleLineRepetitionInstructions(e){let t=!1;if(e.elements().length>0){let s="",n=!1,r="",o="",a="";const l=[];let h="";const u=e.element("bar-style");u&&(a=u.value),s=e.attributes().length>0&&e.attribute("location")?e.attribute("location").value:"right";const c=e.elements();for(let e=0,t=c.length;e2&&(h=e);const s=e.split("[,+]");for(let t=0,i=s.length;t0)if("left"===s){if("start"===o){const e=new $e(this.currentMeasureIndex,Qe.Ending,Ze.Begin,void 0,l,h);this.addInstruction(this.repetitionInstructions,e)}if("forward"===r){const e=new $e(this.currentMeasureIndex,Qe.StartLine);this.addInstruction(this.repetitionInstructions,e)}}else{if("stop"===o){const e=new $e(this.currentMeasureIndex,Qe.Ending,Ze.End,void 0,l,h);this.addInstruction(this.repetitionInstructions,e)}if("backward"===r){const e=new $e(this.currentMeasureIndex,Qe.BackJumpLine);this.addInstruction(this.repetitionInstructions,e)}}}return t}handleRepetitionInstructionsFromWordsOrSymbols(e,t){const i=e.element("words"),s=this.currentMeasureIndex;if(i){const e="d\\s?\\.s\\.",t=i.value.trim().toLowerCase();if(Xs.StringContainsSeparatedWord(t,e+" al fine",!0)){const e=new $e(s,Qe.DalSegnoAlFine);return this.addInstruction(this.repetitionInstructions,e),!0}if(Xs.StringContainsSeparatedWord(t,e+" al coda",!0)){const e=new $e(s,Qe.DalSegnoAlCoda);return this.addInstruction(this.repetitionInstructions,e),!0}const n="d\\.\\s?c\\.";if(Xs.StringContainsSeparatedWord(t,n+" al fine",!0)){const e=new $e(s,Qe.DaCapoAlFine);return this.addInstruction(this.repetitionInstructions,e),!0}if(Xs.StringContainsSeparatedWord(t,n+" al coda",!0)){const e=new $e(s,Qe.DaCapoAlCoda);return this.addInstruction(this.repetitionInstructions,e),!0}if(Xs.StringContainsSeparatedWord(t,n)||Xs.StringContainsSeparatedWord(t,"da\\s?capo",!0)){const e=new $e(s,Qe.DaCapo);return this.addInstruction(this.repetitionInstructions,e),!0}if(Xs.StringContainsSeparatedWord(t,e,!0)||Xs.StringContainsSeparatedWord(t,"dal\\s?segno",!0)){let e;return e=Xs.StringContainsSeparatedWord(t,"al\\s?coda",!0)?new $e(s,Qe.DalSegnoAlCoda):new $e(s,Qe.DalSegno),this.addInstruction(this.repetitionInstructions,e),!0}if(Xs.StringContainsSeparatedWord(t,"to\\s?coda",!0)||Xs.StringContainsSeparatedWord(t,"a (la )?coda",!0)){const e=new $e(s,Qe.ToCoda);return this.addInstruction(this.repetitionInstructions,e),!0}if(Xs.StringContainsSeparatedWord(t,"fine",!0)){const e=new $e(s,Qe.Fine);return this.addInstruction(this.repetitionInstructions,e),!0}if(Xs.StringContainsSeparatedWord(t,"coda",!0)){const e=new $e(s,Qe.Coda);return this.addInstruction(this.repetitionInstructions,e),!0}if(Xs.StringContainsSeparatedWord(t,"segno",!0)){const e=new $e(s,Qe.Segno);return this.addInstruction(this.repetitionInstructions,e),!0}}else{if(e.element("segno")){const e=new $e(s,Qe.Segno);return this.addInstruction(this.repetitionInstructions,e),!0}if(e.element("coda")){const e=new $e(s,Qe.Coda);return this.addInstruction(this.repetitionInstructions,e),!0}}return!1}removeRedundantInstructions(){let e=0,t=0,i=0,s=0;for(let n=0;n0&&this.findInstructionInPreviousMeasure(n,r.measureIndex,Qe.ToCoda)&&(r.type=Qe.None),0===t&&0===i&&(r.type=Qe.ToCoda,r.alignment=Ze.End,r.measureIndex--);break;case Qe.Segno:if(e-s>0){let e=!1;for(let s=0,n=this.repetitionInstructions.length;s0?Qe.DalSegnoAlCoda:Qe.DalSegno,r.type=Qe.None,e=!0;break;case Qe.DalSegno:case Qe.DalSegnoAlFine:case Qe.DalSegnoAlCoda:r.type=Qe.None,e=!0}if(e)break}if(e)break;r.type=i-t>0?Qe.DalSegnoAlCoda:Qe.DalSegno,r.alignment=Ze.End,r.measureIndex--}}if(this.backwardSearchForPreviousIdenticalInstruction(n,r)||r.type===Qe.None)this.repetitionInstructions.splice(n,1),n--;else switch(r.type){case Qe.Fine:break;case Qe.ToCoda:i++;break;case Qe.Coda:t++;break;case Qe.Segno:e++;break;case Qe.DalSegnoAlFine:case Qe.DalSegnoAlCoda:s++}}this.repetitionInstructions.sort(qe.Compare)}findInstructionInPreviousMeasure(e,t,i){for(let s=e-1;s>=0;s--){const e=this.repetitionInstructions[s];if(t-e.measureIndex==1&&e.type===i)return!0}return!1}backwardSearchForPreviousIdenticalInstruction(e,t){for(let i=e-1;i>=0;i--)if(this.repetitionInstructions[i].equals(t))return!0;return!1}addInstruction(e,t){let i=!0;for(let s=0,n=e.length;s0;)try{const e=this.openRepetitions.last();if(e.RepetitonUnderConstruction.FromWords){if(e.WaitingForCoda){let t=e.RepetitonUnderConstruction.BackwardJumpInstructions.last().measureIndex+1;t>=this.musicSheet.SourceMeasures.length&&(t=-1),e.RepetitonUnderConstruction.setEndingStartIndex(2,t)}else if(0===e.RepetitonUnderConstruction.BackwardJumpInstructions.length){this.openRepetitions.splice(this.openRepetitions.length-1,1);continue}}else if(0===e.RepetitonUnderConstruction.BackwardJumpInstructions.length){const t=n.length-1,i=new $e(t,Qe.BackJumpLine,Ze.End,e.RepetitonUnderConstruction);e.RepetitonUnderConstruction.BackwardJumpInstructions.push(i),n[t].LastRepetitionInstructions.push(i)}this.finalizeRepetition(this.openRepetitions.last())}catch(l){try{const e=this.openRepetitions.last().RepetitonUnderConstruction;for(const t of this.repetitionInstructions)t.parentRepetition===e&&(t.parentRepetition=void 0);this.openRepetitions.splice(this.openRepetitions.length-1,1)}catch(a){s.error("RepetitionCalculator: calculateRepetitions2",a)}}let r=!1;const o=this.musicSheet.SourceMeasures.length-1;for(const s of this.musicSheet.Repetitions)if(0===s.StartIndex&&s.EndIndex===o){r=!0;break}if(!r){const e=new Ls(this.musicSheet,!0);e.FromWords=!0,e.startMarker=new $e(0,Qe.StartLine),e.startMarker.parentRepetition=e,this.musicSheet.SourceMeasures[0].FirstRepetitionInstructions.push(e.startMarker),e.endMarker=new $e(o,Qe.BackJumpLine),e.endMarker.parentRepetition=e,e.BackwardJumpInstructions.push(e.endMarker),e.UserNumberOfRepetitions=e.DefaultNumberOfRepetitions,this.musicSheet.Repetitions.push(e)}for(let s=0,h=this.musicSheet.SourceMeasures.length;s1&&e.FirstRepetitionInstructions.sort(qe.Compare),e.LastRepetitionInstructions.length>1&&e.LastRepetitionInstructions.sort(qe.Compare)}}handleRepetitionInstructions(e){var t,i,s,n,r;let o;switch(e.type){case Qe.StartLine:o=this.createNewRepetition(this.currentMeasureIndex),e.parentRepetition=o.RepetitonUnderConstruction,o.RepetitonUnderConstruction.FromWords=!1,o.RepetitonUnderConstruction.startMarker=e,null===(t=this.currentMeasure)||void 0===t||t.FirstRepetitionInstructions.push(e);break;case Qe.BackJumpLine:o=this.getOrCreateCurrentRepetition2(!1),e.parentRepetition=o.RepetitonUnderConstruction,o.RepetitonUnderConstruction.BackwardJumpInstructions.push(e),null===(i=this.currentMeasure)||void 0===i||i.LastRepetitionInstructions.push(e),0===o.RepetitonUnderConstruction.EndingParts.length&&this.finalizeRepetition(o);break;case Qe.Ending:if(o=this.getOrCreateCurrentRepetition(),e.parentRepetition=o.RepetitonUnderConstruction,e.endingIndices.contains(1)&&e.alignment===Ze.Begin){if(o.RepetitonUnderConstruction.BackwardJumpInstructions.length>0||o.RepetitonUnderConstruction.EndingIndexDict.hasOwnProperty(1)){o=void 0;for(let e=this.openRepetitions.length-1;e>=0;e--){const t=this.openRepetitions[e];if(0===t.RepetitonUnderConstruction.BackwardJumpInstructions.length)for(o=t;this.openRepetitions.length-1>e;){const e=this.openRepetitions.last();this.finalizeRepetition(e)}}void 0===o&&(o=this.createNewRepetition(0),o.RepetitonUnderConstruction.startMarker=new $e(0,Qe.None))}void 0===o.RepetitonUnderConstruction.forwardJumpInstruction&&(o.RepetitonUnderConstruction.forwardJumpInstruction=new $e(this.currentMeasureIndex-1,Qe.ForwardJump,Ze.End,o.RepetitonUnderConstruction),this.musicSheet.SourceMeasures[this.currentMeasureIndex-1].LastRepetitionInstructions.push(o.RepetitonUnderConstruction.forwardJumpInstruction))}var a;if(e.alignment===Ze.Begin)o.RepetitonUnderConstruction.setEndingsStartIndex(e.endingIndices,this.currentMeasureIndex),null===(a=this.currentMeasure)||void 0===a||a.FirstRepetitionInstructions.push(e);else for(let t=0,i=e.endingIndices.length;t0&&Math.abs(o.RepetitonUnderConstruction.BackwardJumpInstructions.last().measureIndex-this.currentMeasureIndex)<=1)break;if(this.openRepetitions.length&&(null===(s=this.openRepetitions)||void 0===s||null===(n=s.find((e=>e.RepetitonUnderConstruction.startMarker.type===Qe.StartLine)))||void 0===n||null===(r=n.RepetitonUnderConstruction)||void 0===r?void 0:r.StartIndex)===this.currentMeasureIndex)break;o=this.createNewRepetition(this.currentMeasureIndex),e.parentRepetition=o.RepetitonUnderConstruction,o.RepetitonUnderConstruction.FromWords=!0,o.SegnoFound=!0,o.RepetitonUnderConstruction.startMarker=e,this.currentMeasure.FirstRepetitionInstructions.push(e);break;case Qe.Fine:if(0===this.openRepetitions.length)break;if(o=this.getCurrentRepetition(!0),void 0===o)break;e.parentRepetition=o.RepetitonUnderConstruction,o.RepetitonUnderConstruction.FromWords=!0,void 0===o.RepetitonUnderConstruction.forwardJumpInstruction?(o.FineFound=!0,o.RepetitonUnderConstruction.forwardJumpInstruction=e,o.RepetitonUnderConstruction.setEndingStartIndex(2,-2),this.currentMeasure.LastRepetitionInstructions.push(e)):this.currentMeasure.LastRepetitionInstructions.push(new $e(this.currentMeasureIndex,Qe.Fine,Ze.End,void 0));break;case Qe.ToCoda:if(0===this.openRepetitions.length)break;if(o=this.getCurrentRepetition(!0),void 0===o)break;void 0===o.RepetitonUnderConstruction.forwardJumpInstruction&&(e.parentRepetition=o.RepetitonUnderConstruction,o.RepetitonUnderConstruction.FromWords=!0,o.ToCodaFound=!0,o.RepetitonUnderConstruction.forwardJumpInstruction=e,this.currentMeasure.LastRepetitionInstructions.push(e));break;case Qe.Coda:if(0===this.openRepetitions.length)break;o=this.getOrCreateCurrentRepetition2(!0),e.parentRepetition=o.RepetitonUnderConstruction,o.WaitingForCoda?(o.CodaFound=!0,o.RepetitonUnderConstruction.setEndingStartIndex(2,this.currentMeasureIndex),this.currentMeasure.LastRepetitionInstructions.push(e),this.finalizeRepetition(o),this.currentMeasureIndex>0&&(this.musicSheet.SourceMeasures[this.currentMeasureIndex-1].printNewSystemXml=!0)):o.ToCodaFound||(0===o.RepetitonUnderConstruction.BackwardJumpInstructions.length?(o.ToCodaFound=!0,o.RepetitonUnderConstruction.forwardJumpInstruction=new $e(this.currentMeasureIndex,Qe.ToCoda,Ze.End,o.RepetitonUnderConstruction),this.currentMeasure.LastRepetitionInstructions.push(o.RepetitonUnderConstruction.forwardJumpInstruction)):this.currentMeasure.LastRepetitionInstructions.push(new $e(this.currentMeasureIndex,Qe.Coda,Ze.Begin,void 0)));break;case Qe.DaCapo:o=this.getOrCreateCurrentRepetition(),o.RepetitonUnderConstruction.BackwardJumpInstructions.length>0&&this.finalizeRepetition(o),0!==o.RepetitonUnderConstruction.StartIndex&&(o=this.createNewRepetition(0)),e.parentRepetition=o.RepetitonUnderConstruction,o.RepetitonUnderConstruction.FromWords=!0,o.RepetitonUnderConstruction.startMarker=new $e(0,Qe.None,Ze.Begin,o.RepetitonUnderConstruction),o.RepetitonUnderConstruction.BackwardJumpInstructions.push(e),this.currentMeasure.LastRepetitionInstructions.push(e),0===o.RepetitonUnderConstruction.EndingParts.length&&this.finalizeRepetition(o);break;case Qe.DalSegno:if(o=this.getOrCreateCurrentRepetition2(!0),o.RepetitonUnderConstruction.BackwardJumpInstructions.length>0&&(this.finalizeRepetition(o),o=this.createNewRepetition(0),o.RepetitonUnderConstruction.FromWords=!0,o.RepetitonUnderConstruction.startMarker=new $e(0,Qe.None,Ze.Begin,o.RepetitonUnderConstruction)),e.parentRepetition=o.RepetitonUnderConstruction,!o.SegnoFound){const t=this.findInstructionInMainListBackwards(Qe.Segno,e.measureIndex);t>=0&&(o.SegnoFound=!0,o.RepetitonUnderConstruction.startMarker=new $e(t,Qe.Segno,Ze.Begin,o.RepetitonUnderConstruction),this.musicSheet.SourceMeasures[t].FirstRepetitionInstructions.splice(0,0,o.RepetitonUnderConstruction.startMarker))}o.RepetitonUnderConstruction.EndingIndexDict.hasOwnProperty(1)&&o.RepetitonUnderConstruction.setEndingEndIndex(1,this.currentMeasureIndex),o.RepetitonUnderConstruction.BackwardJumpInstructions.push(e),this.currentMeasure.LastRepetitionInstructions.push(e);break;case Qe.DalSegnoAlFine:if(0===this.openRepetitions.length)break;if(o=this.getOrCreateCurrentRepetition2(!0),e.parentRepetition=o.RepetitonUnderConstruction,!o.SegnoFound){const t=this.findInstructionInMainListBackwards(Qe.Segno,e.measureIndex);t>=0&&(o.SegnoFound=!0,o.RepetitonUnderConstruction.startMarker=new $e(t,Qe.Segno,Ze.Begin,o.RepetitonUnderConstruction),this.musicSheet.SourceMeasures[t].FirstRepetitionInstructions.splice(0,0,o.RepetitonUnderConstruction.startMarker))}if(!o.FineFound){const t=this.findInstructionInMainListBackwards(Qe.Fine,e.measureIndex);t>=0&&(o.FineFound=!0,o.RepetitonUnderConstruction.forwardJumpInstruction=new $e(t,Qe.Fine,Ze.Begin,o.RepetitonUnderConstruction),o.RepetitonUnderConstruction.setEndingStartIndex(2,-2),this.musicSheet.SourceMeasures[t].LastRepetitionInstructions.splice(0,0,o.RepetitonUnderConstruction.forwardJumpInstruction))}o.RepetitonUnderConstruction.EndingIndexDict.hasOwnProperty(1)||o.RepetitonUnderConstruction.setEndingEndIndex(1,this.currentMeasureIndex),o.RepetitonUnderConstruction.BackwardJumpInstructions.push(e),this.currentMeasure.LastRepetitionInstructions.push(e);break;case Qe.DaCapoAlFine:if(o=this.getOrCreateCurrentRepetition(),o.RepetitonUnderConstruction.BackwardJumpInstructions.length>0&&(this.finalizeRepetition(o),o=this.createNewRepetition(0)),void 0!==o.RepetitonUnderConstruction.startMarker&&0!==o.RepetitonUnderConstruction.StartIndex&&(o=this.createNewRepetition(0)),o.RepetitonUnderConstruction.startMarker=new $e(0,Qe.None,Ze.Begin,o.RepetitonUnderConstruction),o.RepetitonUnderConstruction.FromWords=!0,e.parentRepetition=o.RepetitonUnderConstruction,!o.FineFound){const t=this.findInstructionInMainListBackwards(Qe.Fine,e.measureIndex);t>=0&&(o.FineFound=!0,o.RepetitonUnderConstruction.forwardJumpInstruction=new $e(t,Qe.Fine,Ze.Begin,o.RepetitonUnderConstruction),o.RepetitonUnderConstruction.setEndingStartIndex(2,-2),this.musicSheet.SourceMeasures[t].LastRepetitionInstructions.splice(0,0,o.RepetitonUnderConstruction.forwardJumpInstruction))}o.RepetitonUnderConstruction.EndingIndexDict.hasOwnProperty(1)||o.RepetitonUnderConstruction.setEndingEndIndex(1,this.currentMeasureIndex),o.RepetitonUnderConstruction.BackwardJumpInstructions.push(e),this.currentMeasure.LastRepetitionInstructions.push(e);break;case Qe.DalSegnoAlCoda:if(0===this.openRepetitions.length)break;if(o=this.getOrCreateCurrentRepetition2(!0),e.parentRepetition=o.RepetitonUnderConstruction,!o.SegnoFound){const t=this.findInstructionInMainListBackwards(Qe.Segno,e.measureIndex);t>=0&&(o.SegnoFound=!0,o.RepetitonUnderConstruction.startMarker=new $e(t,Qe.Segno,Ze.Begin,o.RepetitonUnderConstruction),this.musicSheet.SourceMeasures[t].FirstRepetitionInstructions.splice(0,0,o.RepetitonUnderConstruction.startMarker))}if(!o.ToCodaFound){const t=this.findInstructionInMainListBackwards(Qe.ToCoda,e.measureIndex);if(t>=0)o.RepetitonUnderConstruction.forwardJumpInstruction=new $e(t,Qe.ToCoda,Ze.Begin,o.RepetitonUnderConstruction),this.musicSheet.SourceMeasures[t].LastRepetitionInstructions.splice(0,0,o.RepetitonUnderConstruction.forwardJumpInstruction),o.ToCodaFound=!0;else{const t=this.findInstructionInMainListBackwards(Qe.Coda,e.measureIndex);t>=0&&(o.RepetitonUnderConstruction.forwardJumpInstruction=new $e(t,Qe.ToCoda,Ze.Begin,o.RepetitonUnderConstruction),this.musicSheet.SourceMeasures[t].LastRepetitionInstructions.splice(0,0,o.RepetitonUnderConstruction.forwardJumpInstruction),o.ToCodaFound=!0)}}o.ToCodaFound&&(o.WaitingForCoda=!0),o.RepetitonUnderConstruction.EndingIndexDict.hasOwnProperty(1)||o.RepetitonUnderConstruction.setEndingEndIndex(1,this.currentMeasureIndex),o.RepetitonUnderConstruction.BackwardJumpInstructions.push(e),this.currentMeasure.LastRepetitionInstructions.push(e);break;case Qe.DaCapoAlCoda:if(o=this.getOrCreateCurrentRepetition(),(o.RepetitonUnderConstruction.BackwardJumpInstructions.length>0||0===o.RepetitonUnderConstruction.EndingParts.length)&&(this.finalizeRepetition(o),o=this.createNewRepetition(0)),void 0!==o.RepetitonUnderConstruction.startMarker&&0!==o.RepetitonUnderConstruction.StartIndex&&(o=this.createNewRepetition(0)),o.RepetitonUnderConstruction.startMarker=new $e(0,Qe.None,Ze.Begin,o.RepetitonUnderConstruction),o.RepetitonUnderConstruction.FromWords=!0,e.parentRepetition=o.RepetitonUnderConstruction,!o.ToCodaFound){const t=this.findInstructionInMainListBackwards(Qe.ToCoda,e.measureIndex);if(t>=0)o.RepetitonUnderConstruction.forwardJumpInstruction=new $e(t,Qe.ToCoda,Ze.Begin,o.RepetitonUnderConstruction),this.musicSheet.SourceMeasures[t].LastRepetitionInstructions.splice(0,0,o.RepetitonUnderConstruction.forwardJumpInstruction),o.ToCodaFound=!0;else{const t=this.findInstructionInMainListBackwards(Qe.Coda,e.measureIndex);t>=0&&(o.RepetitonUnderConstruction.forwardJumpInstruction=new $e(t,Qe.ToCoda,Ze.Begin,o.RepetitonUnderConstruction),this.musicSheet.SourceMeasures[t].LastRepetitionInstructions.splice(0,0,o.RepetitonUnderConstruction.forwardJumpInstruction),o.ToCodaFound=!0)}}o.ToCodaFound&&(o.WaitingForCoda=!0),o.RepetitonUnderConstruction.EndingIndexDict.hasOwnProperty(1)||o.RepetitonUnderConstruction.setEndingEndIndex(1,this.currentMeasureIndex),o.RepetitonUnderConstruction.BackwardJumpInstructions.push(e),this.currentMeasure.LastRepetitionInstructions.push(e);break;case Qe.None:break;default:throw new y("currentRepetitionInstruction")}return!0}findInstructionInMainListBackwards(e,t){for(let i=this.repetitionInstructions.length-1;i>=0;i--){const s=this.repetitionInstructions[i];if(s.measureIndex<=t&&s.type===e)return s.measureIndex}return-1}finalizeRepetition(e){var t,i,s;const n=e.RepetitonUnderConstruction,r=!!(null===(t=n.BackwardJumpInstructions)||void 0===t?void 0:t.some((e=>{var t;return e.measureIndex===(null===(t=this.currentMeasure)||void 0===t?void 0:t.measureListIndex)})))&&"结束句"===(null===(i=this.repetitionInstructions)||void 0===i||null===(s=i.find((e=>{var t;return(null==e?void 0:e.measureIndex)===(null===(t=this.currentMeasure)||void 0===t?void 0:t.measureListIndex)})))||void 0===s?void 0:s.originalVal);if(n.BackwardJumpInstructions.length>0){let e=!0;const t=this.getLastFinalizedRepetition();if(void 0!==t&&n.coversIdenticalMeasures(t)){if(n.NumberOfEndings>t.NumberOfEndings){const e=this.musicSheet.Repetitions.indexOf(t,0);e>-1&&this.musicSheet.Repetitions.splice(e,1),t.removeFromRepetitionInstructions(),this.musicSheet.Repetitions.push(n)}e=!1,n.removeFromRepetitionInstructions()}else r?e=!1:this.musicSheet.Repetitions.push(n);if(e){var o,a;n.startMarker.type===Qe.None&&this.musicSheet.SourceMeasures[n.StartIndex].FirstRepetitionInstructions.push(n.startMarker);let e=(null===(o=window)||void 0===o?void 0:o.DYCustomRepeatCount)>n.DefaultNumberOfRepetitions?null===(a=window)||void 0===a?void 0:a.DYCustomRepeatCount:n.DefaultNumberOfRepetitions;var l,h;!this.hasNextRepeat&&this.currentMeasureIndex(null==e?void 0:e.measureIndex)>=(null==n?void 0:n.EndIndex))))||void 0===h?void 0:h.some((e=>2==(null==e?void 0:e.type)||4==(null==e?void 0:e.type)))),this.hasNextRepeat&&(e=n.DefaultNumberOfRepetitions),n.UserNumberOfRepetitions=e||n.DefaultNumberOfRepetitions}}this.openRepetitions.splice(this.openRepetitions.length-1,1)}getCurrentRepetition(e){let t;for(let i=this.openRepetitions.length-1;i>=0;i--)if(this.openRepetitions[i].RepetitonUnderConstruction.FromWords===e){for(t=this.openRepetitions[i];i0)return this.openRepetitions.last();const e=this.createNewRepetition(0);return e.RepetitonUnderConstruction.startMarker=new $e(0,Qe.None,Ze.Begin,e.RepetitonUnderConstruction),e}getOrCreateCurrentRepetition2(e){let t;if(this.openRepetitions.length&&this.openRepetitions.last().RepetitonUnderConstruction.EndingParts.length<2)for(let i=this.openRepetitions.length-1;i>=0;i--)if(t=this.openRepetitions[i],t.RepetitonUnderConstruction.FromWords===e){for(;i0){const e=this.openRepetitions.last(),t=e.RepetitonUnderConstruction;if(t.BackwardJumpInstructions.length>0){const i=Object.keys(t.EndingIndexDict);(0===i.length||t.EndingIndexDict[i[i.length-1]].part.EndIndex>=0)&&this.finalizeRepetition(e)}}const t=new Ys(this.musicSheet);return this.lastRepetitionCommonPartStartIndex=e,this.openRepetitions.push(t),t}getLastFinalizedRepetition(){if(this.musicSheet.Repetitions.length>0)return this.musicSheet.Repetitions.last()}}class Ys{constructor(e){this.RepetitonUnderConstruction=new Ls(e)}}class js{static createRepetitionInstructionReader(){return new zs}static createRepetitionCalculator(){return new Hs}}class Ks{constructor(){this.voiceMeasureReadPlugins=[]}addVoiceMeasureReadPlugin(e){this.voiceMeasureReadPlugins.push(e)}processVoiceMeasureReadPlugins(e,t,i){for(const r of this.voiceMeasureReadPlugins)try{r.measureReadCalculations(e,t,i)}catch(n){s.info("VoiceGenerator.addSingleNote: ",n)}}}class Js{constructor(e=void 0,t=new xe){this.completeNumberOfStaves=0,this.pluginManager=new Ks,this.afterSheetReadingModules=e||[],this.repetitionInstructionReader=js.createRepetitionInstructionReader(),this.repetitionCalculator=js.createRepetitionCalculator(),this.rules=t}get PluginManager(){return this.pluginManager}get CompleteNumberOfStaves(){return this.completeNumberOfStaves}static doCalculationsAfterDurationHasBeenSet(e){for(const t of e)t.doCalculationsAfterDurationHasBeenSet()}createMusicSheet(e,t){try{return this._createMusicSheet(e,t)}catch(i){return void s.error("MusicSheetReader.CreateMusicSheet",i)}}_removeFromArray(e,t){const i=e.indexOf(t);-1!==i&&e.splice(i,1)}trimString(e){return e.replace(/^\s+|\s+$/g,"")}_lastElement(e){return e[e.length-1]}_createMusicSheet(e,t){const i=[];let s=0;this.musicSheet=new ws,this.musicSheet.Path=t,this.musicSheet.Rules=this.rules;const n=e.attribute("osmdMeasureWidthFactor");if(n){const e=Number.parseFloat(n.value);"number"==typeof e&&(this.musicSheet.MeasureWidthFactor=e)}if(!e)throw new S("Undefined root element");this.pushSheetLabels(e,t);const r=e.element("part-list");if(!r)throw new S("Undefined partListNode");const o=e.elements("part"),a=r.elements();this.initializeReading(a,o,i);let l=!0;this.currentFraction=new u(0,1);let h=!1,c=e.element("identification");for(c&&(c=c.element("encoding")),c&&(c=c.element("software")),void 0!==c&&"Guitar Pro 5"===c.value&&(h=!0);l;){void 0!==this.currentMeasure&&this.currentMeasure.HasEndLine&&this.rules.NewPartAndSystemAfterFinalBarline&&(s=0),this.currentMeasure=new tt(this.completeNumberOfStaves,this.musicSheet.Rules);for(const e of i)try{l=l&&e.readNextXmlMeasure(this.currentMeasure,this.currentFraction,h)}catch(d){const e=Xe.translateText("ReaderErrorMessages/InstrumentError","Error while reading instruments.");throw new S(e,d)}l&&(this.musicSheet.addMeasure(this.currentMeasure),this.checkIfRhythmInstructionsAreSetAndEqual(i),this.checkSourceMeasureForNullEntries(),s=this.setSourceMeasureDuration(i,s),Js.doCalculationsAfterDurationHasBeenSet(i),this.currentMeasure.AbsoluteTimestamp=this.currentFraction.clone(),this.musicSheet.SheetErrors.finalizeMeasure(this.currentMeasure.MeasureNumber),this.currentFraction.Add(this.currentMeasure.Duration),this.previousMeasure=this.currentMeasure)}this.repetitionInstructionReader&&(this.repetitionInstructionReader.removeRedundantInstructions(),this.repetitionCalculator&&this.repetitionCalculator.calculateRepetitions(this.musicSheet,this.repetitionInstructionReader.repetitionInstructions)),0===this.musicSheet.DefaultStartTempoInBpm&&(this.musicSheet.DefaultStartTempoInBpm=100),this.musicSheet.checkForInstrumentWithNoVoice(),this.musicSheet.fillStaffList();for(let u=0,f=this.afterSheetReadingModules.length;ui){if(this.areRhythmInstructionsMixed(t)&&e.SymbolEnum!==T.NONE)continue;i=e.Rhythm.RealValue,s=t.indexOf(e)}}if(t.length>0&&t.length0)&&t++,this.currentMeasure.Duration=r,this.currentMeasure.ActiveTimeSignature=i,this.currentMeasure.MeasureNumber=t;for(let o=0;oe.Denominator){const i=t.Denominator/e.Denominator;e.expand(i)}}checkIfMeasureIsImplicit(e,t){return!(this.previousMeasure||!e.lt(t))||!!this.previousMeasure&&u.plus(this.previousMeasure.Duration,e).Equals(t)}allInstrumentsHaveSameDuration(e,t){let i=0;for(let s=0,n=e.length;s=0;e--)for(let t=this.currentMeasure.VerticalSourceStaffEntryContainers[e].StaffEntries.length-1;t>=0;t--){const i=this.currentMeasure.VerticalSourceStaffEntryContainers[e].StaffEntries[t];if(i)for(let e=i.VoiceEntries.length-1;e>=0;e--){const t=i.VoiceEntries[e];0===t.Notes.length&&(this._removeFromArray(t.ParentVoice.VoiceEntries,t),this._removeFromArray(i.VoiceEntries,t))}void 0!==i&&0===i.VoiceEntries.length&&0===i.ChordContainers.length&&(this.currentMeasure.VerticalSourceStaffEntryContainers[e].StaffEntries[t]=void 0)}for(let e=this.currentMeasure.VerticalSourceStaffEntryContainers.length-1;e>=0;e--){let t=0;for(let i=0,s=this.currentMeasure.VerticalSourceStaffEntryContainers[e].StaffEntries.length;i0){const e=t[0].elements("rights");if(e.length>0)for(let t=0,i=e.length;tt||d)if(i||d){if(u||"right"===c)n?n+="\n"+r:n=r;else if(h||"right"!==c&&"left"!==c)s?s+="\n"+r:s=r;else if("left"===c){this.musicSheet.Lyricist||(this.musicSheet.Lyricist=new pt(r));break}}else i=r}}}}if(!this.musicSheet.Title&&i&&(this.musicSheet.Title=new pt(this.trimString(i))),!this.musicSheet.Subtitle&&s&&(this.musicSheet.Subtitle=new pt(this.trimString(s))),n){let e=!1;var h,u;if(this.musicSheet.Composer)(null!==(h=n.match("\n"))&&void 0!==h?h:[]).length+1>=(null!==(u=this.musicSheet.Composer.text.match("\n"))&&void 0!==u?u:[]).length+1&&(e=!0);else e=!0;e&&(this.musicSheet.Composer=new pt(this.trimString(n)))}}readTitleAndComposerFromCreditsLegacy(e){const t=this.computeSystemYCoordinates(e);if(0===t)return;let i,s,n,r=1,o=0;const a=e.elements("credit");for(let c=0,d=a.length;ct||p){if(!this.musicSheet.Title&&!p){var u;const e=null===(u=a.attribute("font-size"))||void 0===u?void 0:u.value;if(e){const t=parseFloat(e);r0&&o.MidiInstrumentId!==$.Percussion&&(t.midiInstrumentID=Math.max(0,parseInt(n.value,10)-1));else if("midi-unpitched"===n.name)t.fixedKey=Math.max(0,parseInt(n.value,10));else if("volume"===n.name)try{const e=parseFloat(n.value);t.volume=e/127}catch(r){s.debug("ExpressionReader.readExpressionParameters","read volume",r)}else if("pan"===n.name)try{const e=parseFloat(n.value);t.pan=e/64}catch(r){s.debug("ExpressionReader.readExpressionParameters","read pan",r)}}catch(r){s.info("MusicSheetReader.createInstrumentGroups midi settings: ",r)}}}}catch(r){s.info("MusicSheetReader.createInstrumentGroups: ",r)}}if(0===o.SubInstruments.length){const e=new Us(o);o.SubInstruments.push(e)}i[e]=o,n?(n.InstrumentalGroups.push(o),this.musicSheet.Instruments.push(o)):(this.musicSheet.InstrumentalGroups.push(o),this.musicSheet.Instruments.push(o))}else if("part-group"===a.name&&"start"===a.attribute("type").value){const e=new bi("group",this.musicSheet,n);n?n.InstrumentalGroups.push(e):this.musicSheet.InstrumentalGroups.push(e),n=e}else if("part-group"===a.name&&"stop"===a.attribute("type").value&&n){if(1===n.InstrumentalGroups.length){const e=n.InstrumentalGroups[0];n.Parent?(n.Parent.InstrumentalGroups.push(e),this._removeFromArray(n.Parent.InstrumentalGroups,n)):(this.musicSheet.InstrumentalGroups.push(e),this._removeFromArray(this.musicSheet.InstrumentalGroups,n))}n=n.Parent}}}catch(o){const e=Xe.translateText("ReaderErrorMessages/InstrumentError","Error while reading Instruments");throw new S(e,o)}for(let s=0,a=this.musicSheet.Instruments.length;s0){const i=e[0];if(i){let e=i.element("attributes");e&&(e=e.element("staves")),e?t+=parseInt(e.value,10):t++}}}if(isNaN(t)||t<=0){const e=Xe.translateText("ReaderErrorMessages/StaffError","Invalid number of staves.");throw new S(e)}return t}getInstrumentNumberOfStavesFromXml(e){let t=0;const i=e.element("measure");if(i){const e=i.element("attributes");let s;e&&(s=e.element("staves")),t=e&&s?parseInt(s.value,10):1}if(isNaN(t)||t<=0){const e=Xe.translateText("ReaderErrorMessages/StaffError","Invalid number of Staves.");throw new S(e)}return t}}class qs{static MXLtoIXmlElement(e){const t=new l;return t.loadAsync(e).then((e=>t.file("META-INF/container.xml").async("text")),(e=>{throw e})).then((e=>{const i=(new DOMParser).parseFromString(e,"text/xml").getElementsByTagName("rootfile")[0].getAttribute("full-path");return t.file(i).async("text")}),(e=>{throw e})).then((e=>{const t=(new DOMParser).parseFromString(e,"text/xml"),i=new k(t.documentElement);return Promise.resolve(i)}),(e=>{throw e})).then((e=>e),(e=>{throw new Error("extractSheetFromMxl: "+e.message)}))}static MXLtoXMLstring(e){const t=new l;return t.loadAsync(e).then((e=>t.file("META-INF/container.xml").async("text")),(e=>{throw s.error(e),e})).then((e=>{const i=(new DOMParser).parseFromString(e,"text/xml").getElementsByTagName("rootfile")[0].getAttribute("full-path");return t.file(i).async("text")}),(e=>{throw e}))}}class $s{calculate(e){const t=new w(e);for(;!t.EndReached;){const i=t.CurrentEnrolledTimestamp,s=t.CurrentAudibleVoiceEntries();for(const t of s)this.handleVoiceEntry(e,t,i);t.moveToNext()}}handleVoiceEntry(e,t,i){if(t.IsGrace)return;const s=t.ParentVoice;let n;e.PlaybackDataDict.containsKey(s)?n=e.PlaybackDataDict.getValue(s):(n=[],e.PlaybackDataDict.setValue(s,n));for(const r of t.PlaybackEntries)if(r.HasNotes){for(const t of r.Notes)t.setLength();const e=u.plus(i,r.TimestampShift);$s.addEntrySorted(n,r,e)}}static addEntrySorted(e,t,i){if(0===e.length)e.push({enrolledTimestamp:i,playbackEntry:t});else for(let s=e.length-1;s>=0;s--){const n=e[s];if(i.RealValue>n.enrolledTimestamp.RealValue){if(s===e.length-1){e.push({enrolledTimestamp:i,playbackEntry:t});break}e.splice(s+1,0,{enrolledTimestamp:i,playbackEntry:t});break}}}}class Qs{constructor(e,t,i,s){this.psi=new oe(void 0),this.displaySizeInPixel=e,this.RelativeDisplaySize=t,this.RelativeDisplayPosition=i,this.WidthInUnits=s}static createWithRelativeDefaults(e,t){return new Qs(e,new te(1,1),new z(0,0),t)}static createWithDefaults(){return new Qs(new te(1,1),new te(1,1),new z(0,0),1)}get UpperLeftPositionInUnits(){return this.psi.AbsolutePosition}set UpperLeftPositionInUnits(e){this.psi.AbsolutePosition=e}get DisplaySizeInPixel(){return this.displaySizeInPixel}set DisplaySizeInPixel(e){this.displaySizeInPixel=e,this.regionSizeInPixel=new te(this.displaySizeInPixel.width*this.relativeRegionSize.width,this.displaySizeInPixel.height*this.relativeRegionSize.height),this.recalculateDependentVariables()}get RelativeDisplaySize(){return this.relativeRegionSize}set RelativeDisplaySize(e){this.relativeRegionSize=e,this.regionSizeInPixel=new te(this.displaySizeInPixel.width*this.relativeRegionSize.width,this.displaySizeInPixel.height*this.relativeRegionSize.height),this.recalculateDependentVariables()}get RegionSizeInPixel(){return this.regionSizeInPixel}get WidthInUnits(){return this.psi.BorderRight}set WidthInUnits(e){this.psi.BorderRight=e,this.recalculateDependentVariables()}get ViewRegionInUnits(){return new te(this.psi.BorderRight,this.psi.BorderBottom)}isVisible(e,t){const i=this.psi.collisionDetection(e);return this.psi.liesInsideBorders(e),i}isInsideDisplayArea(e,t){return this.RelativeDisplayPosition.x<=e&&e<=this.RelativeDisplayPosition.x+this.RelativeDisplaySize.width&&this.RelativeDisplayPosition.y<=t&&t<=this.RelativeDisplayPosition.y+this.RelativeDisplaySize.height}transformToUnitCoordinates(e){return new z(this.UpperLeftPositionInUnits.x+this.ViewRegionInUnits.width*((e.x-this.RelativeDisplayPosition.x)/this.RelativeDisplaySize.width),this.UpperLeftPositionInUnits.y+this.ViewRegionInUnits.height*((e.y-this.RelativeDisplayPosition.y)/this.RelativeDisplaySize.height))}transformLengthXToUnitCoordinates(e){return e/this.horizontalUnitToPixelRatio}transformLengthYToUnitCoordinates(e){return e/this.verticalUnitToPixelRatio}recalculateDependentVariables(){const e=this.regionSizeInPixel.width/this.regionSizeInPixel.height;this.psi.BorderBottom=this.psi.BorderRight/e,this.horizontalUnitToPixelRatio=this.regionSizeInPixel.width/this.ViewRegionInUnits.width,this.verticalUnitToPixelRatio=this.regionSizeInPixel.height/this.ViewRegionInUnits.height}}class Zs{constructor(e){this.aspectRatio=1,this.zoomViews=[],this.mouseZoomMode=!1,this.autoScrollY=!0,this.displayInteractionManager=e,this.displayInteractionManager.addListener(this),this.offsetXMin=Number.MIN_VALUE,this.offsetYMin=Number.MIN_VALUE,this.rangeXMin=1,this.rangeYMin=1,this.offsetXMax=Number.MAX_VALUE,this.offsetYMax=Number.MAX_VALUE,this.rangeXMax=1e9,this.rangeYMax=1e9,this.XScrollingEnabled=!1,this.YScrollingEnabled=!0}positionTouched(e,t){if(!this.convertToUnitsReady())return;const i=this.getPositionInUnits(e,t);this.unitPosTouched(i,e,t)}get TouchActive(){return this.displayInteractionManager.TouchActive}get TouchMoving(){return this.displayInteractionManager.TouchMoving}positionDoubleTouched(e,t){if(!this.convertToUnitsReady())return;const i=this.getPositionInUnits(e,t);this.unitPosDoubleTouched(i,e,t)}get UsesManuallyControlledZoomMode(){return this.usesManuallyControlledZoomMode}set UsesManuallyControlledZoomMode(e){this.usesManuallyControlledZoomMode=e}mouseDown(e,t,i=!1){if(!this.convertToUnitsReady())return;this.selectScrollControllerY(!1),this.lastRangeX=Math.max(1,this.RangeX),this.lastRangeY=Math.max(1,this.RangeY),this.lastOffsetX=this.OffsetX,this.lastOffsetY=this.OffsetY;const s=this.getPositionInUnits(e,t);this.unitPosTouchDown(s,e,t),this.usesManuallyControlledZoomMode||(this.mouseZoomMode=!!i)}mouseUp(e,t){const i=this.getPositionInUnits(e,t);this.unitPosTouchUp(i,e,t)}mouseMove(e,t,i,s){this.mouseZoomMode?(Math.abs(i-0)>1e-8&&(this.RangeX=Math.abs(this.lastRangeX/(1+i))),!this.lockRanges&&Math.abs(s-0)>1e-8&&(this.RangeY=Math.abs(this.lastRangeY/(1-s)))):(Math.abs(i-0)>1e-8&&(this.OffsetX=this.lastOffsetX-i*this.RangeX),Math.abs(s-0)>1e-8&&(this.OffsetY=this.lastOffsetY-s*this.RangeY));const n=this.getPositionInUnits(e,t);this.unitPosMove(n,e,t)}zoom(e){this.RangeX=Math.abs(this.lastRangeX/e)}addZoomView(e){this.zoomViews.push(e)}get OffsetX(){return this.offsetX}set OffsetX(e){this.offsetX=Math.min(this.offsetXMax,Math.max(this.offsetXMin,e));for(const t of this.zoomViews)t.viewportXChanged(this.offsetX,this.RangeX)}get OffsetY(){return this.offsetY}set OffsetY(e){this.offsetY=e,this.offsetY>this.offsetYMax?this.offsetY=this.offsetYMax:this.offsetY(e[e.SingleTouch=0]="SingleTouch",e[e.DoubleTouch=1]="DoubleTouch",e[e.TouchUp=2]="TouchUp",e[e.TouchDown=3]="TouchDown",e[e.Move=4]="Move",e))(en||{});class tn{constructor(e){this.renderingManager=e}userDisplayInteraction(e,t,i){switch(i){case en.TouchDown:case en.SingleTouch:case en.DoubleTouch:{const e=this.renderingManager.GraphicalMusicSheet.GetNearestVoiceEntry(t);if(e&&void 0!==e.parentStaffEntry.parentVerticalContainer){var s;const t=e.parentStaffEntry.parentVerticalContainer.AbsoluteTimestamp;var n;this.renderingManager.setStartPosition(t),void 0!==(null===(s=e.notes[0])||void 0===s?void 0:s.sourceNote.Pitch)&&(null===(n=this.renderingManager.PlaybackManager)||void 0===n||n.playVoiceEntry(e.parentVoiceEntry))}break}}}}class sn extends Zs{constructor(e,t){super(e),this.mainViewingRegion=Qs.createWithDefaults(),this.tryAgainToRenderCount=0,this.yOffsetMouseDown=Number.MIN_VALUE,this.unlockCursorDistancePixel=50,this.relativeTopPosition=.06,this.internalPreviewImageScale=3,this.listeners=[],this.LockDisplayToCursor=!0,this.ZoomActive=!1,this.rules=t,this.addZoomView(this),this.lockRanges=!0,this.TopBarHeightInPixel=70,this.BottomBarHeightInPixel=0,this.rules.UseDefaultVoiceInteractionListener&&this.listeners.push(new tn(this))}addListener(e){this.listeners.push(e)}get Listeners(){return this.listeners}convertToUnitsReady(){return void 0!==this.graphicalMusicSheet}unitPosTouched(e,t,i){if(!this.SingleTouchDisabled){const s=new z(t,i);this.handleUserDisplayInteraction(s,e,en.SingleTouch)}}unitPosDoubleTouched(e,t,i){if(!this.DoubleTouchDisabled){const s=new z(t,i);this.handleUserDisplayInteraction(s,e,en.DoubleTouch)}}unitPosTouchDown(e,t,i){const s=new z(t,i);this.handleUserDisplayInteraction(s,e,en.TouchDown),this.yOffsetMouseDown=e.y}unitPosTouchUp(e,t,i){const s=new z(t,i);this.handleUserDisplayInteraction(s,e,en.TouchUp),!1===this.displayInteractionManager.WasZoomGestureActive&&this.unlockFromCursorIfNecessary(e),this.yOffsetMouseDown=Number.MIN_VALUE}unitPosMove(e,t,i){const s=new z(t,i);this.handleUserDisplayInteraction(s,e,en.Move),this.unlockFromCursorIfNecessary(e)}get MainViewingRegion(){return this.mainViewingRegion}setMusicSheet(e){this.graphicalMusicSheet=e,this.adaptDisplayLimitsToSheet(),this.setYOffset(0,!0)}viewportXChanged(e,t){void 0!==this.graphicalMusicSheet&&this.horizontalViewportChanged(e,t)}viewportYChanged(e,t){void 0!==this.graphicalMusicSheet&&(this.yOffsetMouseDown<=Number.MIN_VALUE+.5&&(this.yOffsetMouseDown=e),this.verticalViewportChanged(e,t))}displaySizeChanged(e,t){super.viewSizeChanged(e,t),Math.abs(e-0)<1e-7||Math.abs(t-0)<1e-7||(void 0!==this.graphicalMusicSheet&&this.graphicalMusicSheet.EnforceRedrawOfMusicSystems(),this.mainViewingRegion.DisplaySizeInPixel=new te(e,t),this.adaptDisplayLimitsToSheet())}calcDisplayYPosition(e){return e.PositionAndShape.AbsolutePosition.y+e.PositionAndShape.BorderMarginTop-this.topBarHeightInUnits()-this.relativeTopPosition*this.heightWithoutTopBottomBarsInUnits()}yPositionForLastSystem(e){return e.PositionAndShape.AbsolutePosition.y+e.PositionAndShape.BorderMarginBottom-this.topBarHeightInUnits()-(1-this.relativeTopPosition)*this.heightWithoutTopBottomBarsInUnits()}scorePositionChanged(e,t,i,s,n,r){const o=this.calcDisplayYPosition(s);this.setYPosition(o,r)}setXPosition(e,t){this.LockDisplayToCursor&&this.setXOffset(e,t)}setYPosition(e,t){this.LockDisplayToCursor&&this.setYOffset(e,t)}get DrawingParameters(){return this.musicSheetDrawer.drawingParameters}topBarHeightInUnits(){return this.mainViewingRegion.transformLengthYToUnitCoordinates(this.TopBarHeightInPixel)}bottomBarHeightInUnits(){return this.mainViewingRegion.transformLengthYToUnitCoordinates(this.BottomBarHeightInPixel)}heightWithoutTopBottomBarsInUnits(){return this.mainViewingRegion.ViewRegionInUnits.height-this.topBarHeightInUnits()-this.bottomBarHeightInUnits()}activePositionToBottomBarHeight(){return(this.mainViewingRegion.ViewRegionInUnits.height-this.topBarHeightInUnits()-this.bottomBarHeightInUnits())*(1-2*this.relativeTopPosition)}getClickPosition(e,t){return this.mainViewingRegion.transformToUnitCoordinates(new z(e,t))}graphicalObjectIsVisible(e){return this.mainViewingRegion.isVisible(e,!1)}adaptDisplayLimitsToSheet(){if(void 0===this.graphicalMusicSheet||0===this.graphicalMusicSheet.MusicPages.length||0===this.graphicalMusicSheet.MusicPages[0].MusicSystems.length)return;this.offsetXMin=0,this.rangeXMin=this.graphicalMusicSheet.MinAllowedSystemWidth,this.rangeXMax=300,this.offsetYMin=-.3*this.RangeY;const e=this.graphicalMusicSheet.MusicPages.last().PositionAndShape;this.offsetYMax=Math.max(0,e.BorderMarginBottom-.7*this.RangeY),this.OffsetY>this.offsetYMax&&this.setYOffset(this.offsetYMax,!0)}horizontalViewportChanged(e,t){this.mainViewingRegion.WidthInUnits!==t&&(this.mainViewingRegion.WidthInUnits=t)}verticalViewportChanged(e,t){this.mainViewingRegion.UpperLeftPositionInUnits=new z(this.mainViewingRegion.UpperLeftPositionInUnits.x,e)}unlockFromCursorIfNecessary(e){!1===this.LockDisplayToCursor||this.ZoomActive||this.displayInteractionManager.ZoomGestureActive||this.displayInteractionManager.WasZoomGestureActive||Math.abs((e.y-this.yOffsetMouseDown)*this.mainViewingRegion.RegionSizeInPixel.height/this.mainViewingRegion.ViewRegionInUnits.height)>this.unlockCursorDistancePixel&&(this.LockDisplayToCursor=!1)}getPositionInUnits(e,t){return this.mainViewingRegion.transformToUnitCoordinates(new z(e,t))}handleUserDisplayInteraction(e,t,i){switch(i){case en.TouchDown:case en.SingleTouch:case en.DoubleTouch:case en.TouchUp:case en.TouchDown:case en.Move:for(const s of this.listeners)s.userDisplayInteraction(e,t,i);break;default:throw new Error("type")}}setStartPosition(e){var t;void 0!==this.graphicalMusicSheet&&(this.graphicalMusicSheet.ParentMusicSheet.SelectionStart=e,null===(t=this.PlaybackManager)||void 0===t||t.reset())}get GraphicalMusicSheet(){return this.graphicalMusicSheet}}class nn extends sn{mouseMove(e,t,i,s){const n=this.getPositionInUnits(e,t);this.unitPosMove(n,e,t)}}class rn{constructor(){this.listeners=[],this.zoomGestureActive=!1,this.touchCount=0,this.touchActive=!1,this.touchMoving=!1,this.displayWidth=1,this.displayHeight=1,this.displayDpi=96,this.maxNumerOfFingers=2,this.movementThreshInch=.075,this.interactionWasZoomGesture=!1}addListener(e){this.listeners.push(e)}get ZoomGestureActive(){return this.zoomGestureActive}get WasZoomGestureActive(){return this.interactionWasZoomGesture}displaySizeChanged(e,t){this.displayWidth=e,this.displayHeight=t;for(const i of this.listeners)i.displaySizeChanged(this.displayWidth,this.displayHeight)}Dispose(){this.dispose()}Initialize(){this.initialize()}get DisplayDpi(){return this.displayDpi}get TouchActive(){return this.touchActive}get TouchMoving(){return this.touchMoving}touchDown(e,t,i){this.interactionWasZoomGesture=!1;const s=e/this.displayWidth,n=t/this.displayHeight;this.lastRelPosX=s,this.lastRelPosY=n,this.lastPixelX=e,this.lastPixelY=t,this.touchActive=!0,this.touchMoving=!1,this.touchCount=Math.min(this.touchCount+1,this.maxNumerOfFingers);for(const r of this.listeners)r.mouseDown(s,n,!i)}move(e,t){if(this.touchActive&&!this.zoomGestureActive){const i=e/this.displayWidth,s=t/this.displayHeight,n=i-this.lastRelPosX,r=s-this.lastRelPosY;this.touchMoving=!0;for(const e of this.listeners)e.mouseMove(i,s,n,r)}}zoomGestureStarted(){this.zoomGestureActive=!0}zoomGestureCompleted(){this.zoomGestureActive=!1,this.interactionWasZoomGesture=!0}zoomGestureMove(e){this.zoomGestureActive&&this.listeners.forEach((function(t){t.zoom(e)}))}touchUp(e,t){this.touchActive=!1,this.touchMoving=!1,this.touchCount=Math.max(0,this.touchCount-1);const i=e/this.displayWidth,s=t/this.displayHeight;for(const n of this.listeners)n.mouseUp(i,s)}click(e,t){if(!this.mouseDidMove(this.lastPixelX,e,this.lastPixelY,t)&&!this.ZoomGestureActive){const i=e/this.displayWidth,s=t/this.displayHeight;for(const e of this.listeners)e.positionTouched(i,s)}}doubleClick(e,t){if(!this.mouseDidMove(this.lastPixelX,e,this.lastPixelY,t)&&!this.ZoomGestureActive){const i=e/this.displayWidth,s=t/this.displayHeight;for(const e of this.listeners)e.positionDoubleTouched(i,s)}}mouseDidMove(e,t,i,s){const n=Math.abs(e-t)/this.displayDpi,r=Math.abs(i-s)/this.displayDpi;return n>this.movementThreshInch||r>this.movementThreshInch}}class on extends rn{constructor(e){super(),this.fullOffsetLeft=0,this.fullOffsetTop=0,this.fullScrollTop=0,this.fullScrollLeft=0,this.parentScrollMap=new Map,this.scrollCallbackMap=new Map,this.timeout=void 0,this.resizeObserver=void 0,this.EventCallbackMap=new i,this.DOUBLE_CLICK_WINDOW=200,this.lastClick=0,this.osmdSheetMusicContainer=e,this.listenForInteractions()}get FullOffsetTop(){return this.fullOffsetTop}get FullScrollTop(){return this.fullScrollTop}get FullOffsetLeft(){return this.fullOffsetLeft}get FullScrollLeft(){return this.fullScrollLeft}static resizeCallback(e,t){clearTimeout(t.timeout),t.timeout=setTimeout((()=>{t.fullOffsetLeft=0,t.fullOffsetTop=0;let e=t.osmdSheetMusicContainer;for(;e;)t.fullOffsetLeft+=e.offsetLeft,t.fullOffsetTop+=e.offsetTop,e=e.offsetParent;t.resizeEventListener(),t.deregisterScrollOffsets(),t.registerScrollOffsets()}),500)}registerScrollOffsets(){let e=this.osmdSheetMusicContainer;this.fullScrollTop=0,this.fullScrollLeft=0;const t=this;for(;e&&e!==document.documentElement;){if(this.parentScrollMap.set(e,[e.scrollTop,e.scrollLeft]),this.fullScrollLeft+=e.scrollLeft,this.fullScrollTop+=e.scrollTop,e.scrollHeight>e.clientHeight){const i=function(e){const i=t.parentScrollMap.get(this),s=i[0],n=i[1];t.fullScrollTop=t.fullScrollTop-s+this.scrollTop,t.fullScrollLeft=t.fullScrollLeft-n+this.scrollLeft,t.parentScrollMap.set(this,[this.scrollTop,this.scrollLeft])};this.scrollCallbackMap.set(e,i),e.addEventListener("scroll",i)}e=e.parentElement}}deregisterScrollOffsets(){for(const e of this.scrollCallbackMap.keys())e.removeEventListener("scroll",this.scrollCallbackMap.get(e));this.scrollCallbackMap.clear()}initialize(){this.fullOffsetLeft=0,this.fullOffsetTop=0;let e=this.osmdSheetMusicContainer;const t=[],i=this;for(window.ResizeObserver&&(this.resizeObserver=new ResizeObserver((e=>{on.resizeCallback(e,i)})));e;)this.fullOffsetLeft+=e.offsetLeft,this.fullOffsetTop+=e.offsetTop,this.resizeObserver?this.resizeObserver.observe(e):t.push(e),e=e.offsetParent;if(this.resizeObserver)this.disposeResizeListener=()=>{i.resizeObserver.disconnect(),i.resizeObserver=void 0};else{let e=()=>{on.resizeCallback(t,i)};window.addEventListener("resize",e),this.disposeResizeListener=()=>{window.removeEventListener("resize",e),e=void 0}}i.registerScrollOffsets()}dispose(){this.disposeResizeListener();for(const e of this.EventCallbackMap.keys()){const t=this.EventCallbackMap.getValue(e);t[0].removeEventListener(e,t[1])}this.EventCallbackMap.clear(),this.deregisterScrollOffsets(),this.scrollCallbackMap.clear(),this.parentScrollMap.clear()}isTouch(){if("ontouchstart"in window||window.DocumentTouch)return!0;if(!window.matchMedia)return!1;const e=["(",["-webkit-","-moz-","-o-","-ms-"].join("touch-enabled),("),"heartz",")"].join("");return window.matchMedia(e).matches}get downEventName(){return this.isTouch()?"touchstart":"mousedown"}get moveEventName(){return this.isTouch()?"touchmove":"mousemove"}listenForInteractions(){const e=this.downEventListener.bind(this),t=this.touchEndEventListener.bind(this),i=this.moveEventListener.bind(this);this.osmdSheetMusicContainer.addEventListener("mousedown",e),this.osmdSheetMusicContainer.addEventListener("touchend",t),document.addEventListener(this.moveEventName,i),this.EventCallbackMap.setValue("mousedown",[this.osmdSheetMusicContainer,e]),this.EventCallbackMap.setValue("touchend",[this.osmdSheetMusicContainer,t]),this.EventCallbackMap.setValue(this.moveEventName,[document,i])}downEventListener(e){const t=(new Date).getTime(),i=t-this.lastClick;clearTimeout(this.clickTimeout);let s=0,n=0;this.isTouch()&&e instanceof TouchEvent?(s=e.touches[0].pageX,n=e.touches[0].pageY):e instanceof MouseEvent&&(s=e.pageX,n=e.pageY);const r=this.getOffsetCoordinates(s,n);if(i0)this.doubleClick(r.x,r.y);else{const e=this;this.clickTimeout=setTimeout((function(){clearTimeout(this.clickTimeout),e.isTouch()?e.touchDown(r.x,r.y,void 0):e.click(r.x,r.y)}),this.DOUBLE_CLICK_WINDOW)}this.lastClick=t}moveEventListener(e){let t=0,i=0;if(this.isTouch()&&e instanceof TouchEvent){var s,n;let r;e.touches&&e.touches.length>0?r=e.touches[0]:e.changedTouches&&e.changedTouches.length>0&&(r=e.changedTouches[0]),t=null===(s=r)||void 0===s?void 0:s.clientX,i=null===(n=r)||void 0===n?void 0:n.clientY}else e instanceof MouseEvent&&(t=e.clientX,i=e.clientY);const r=this.getOffsetCoordinates(t,i);this.move(r.x,r.y)}touchEndEventListener(e){var t,i;let s;e.touches&&e.touches.length>0?s=e.touches[0]:e.changedTouches&&e.changedTouches.length>0&&(s=e.changedTouches[0]);const n=this.getOffsetCoordinates(null===(t=s)||void 0===t?void 0:t.pageX,null===(i=s)||void 0===i?void 0:i.pageY);this.touchUp(n.x,n.y)}resizeEventListener(){this.displaySizeChanged(this.osmdSheetMusicContainer.clientWidth,this.osmdSheetMusicContainer.clientHeight)}getOffsetCoordinates(e,t){const i=e-this.fullOffsetLeft+this.fullScrollLeft,s=t-this.fullOffsetTop+this.fullScrollTop;return new z(i,s)}}class an{static fillDynamicsList(e,t,i){for(let s=0;s=0&&i[t].push(new E(r.InstantaneousDynamic,t))}if(void 0!==r.StartingContinuousDynamic){i[s].push(new E(r.StartingContinuousDynamic,r.StaffNumber));const t=this.getOtherStaffIndexIfLinkedStavesAreDetected(e,s,r.StartingContinuousDynamic.Placement);t>=0&&i[t].push(new E(r.StartingContinuousDynamic,t))}}}}static getOtherStaffIndexIfLinkedStavesAreDetected(e,t,i){const s=e.getStaffFromIndex(t),n=s.ParentInstrument.Staves.indexOf(s),r=s.ParentInstrument.Staves.length;return r>1&&0===n&&i===d.Below?t+1:r>1&&1===n&&i===d.Above?t-1:-1}static fillDynamicExpressions(e){const t=e.DynListStaves,i=e.getCompleteNumberOfStaves(),s=e.TimestampSortedDynamicExpressionsList;for(let n=0;n{t(this.processStringXml(e))}),(e=>{s.error(new Error("[OSMD] Invalid MXL file: "+e)),i(new Error("[OSMD] Invalid MXL file: "+e))}))}processStringXml(e){const t=new DOMParser;if(""===e.substr(0,3))return s.debug("[OSMD] UTF with BOM detected, truncate first three bytes and pass along: "+e),t.parseFromString(e.substr(3),"application/xml");if(e.substr(0,6).includes("{n.isMxl(e)?n.processMxl(e,i,r):i(n.processStringXml(e))}),(e=>{throw r(e),e}));else{const e=new Error("[OSMD] osmd.load(string): Could not process string. Did not find {e.init(this.sheet.MusicPartManager,this.graphic)})),this.drawingParameters.DrawingParametersEnum===A.leadsheet&&(this.graphic.LeadSheet=!0),this.renderingManager.setMusicSheet(this.graphic),this.interactionManager.Initialize()}render(){var e;if(!this.graphic)throw new Error("OpenSheetMusicDisplay: Before rendering a music sheet, please load a MusicXML file");null===(e=this.drawer)||void 0===e||e.clear(),this.Sheet.SourceMeasures[0].ImplicitMeasure&&(this.rules.MinMeasureToDrawNumber>1&&(this.rules.MinMeasureToDrawIndex=this.rules.MinMeasureToDrawNumber),this.rules.MaxMeasureToDrawNumber>0&&(this.rules.MaxMeasureToDrawIndex=this.rules.MaxMeasureToDrawNumber));let t=this.container.offsetWidth;this.rules.RenderSingleHorizontalStaffline&&(t=this.rules.SheetMaximumWidth),this.sheet.pageWidth=t/this.zoom/10,this.renderingManager.MainViewingRegion.WidthInUnits=this.sheet.pageWidth,this.rules.PageFormat&&!this.rules.PageFormat.IsUndefined?(this.rules.PageHeight=this.sheet.pageWidth/this.rules.PageFormat.aspectRatio,s.debug("[OSMD] PageHeight: "+this.rules.PageHeight)):(s.debug("[OSMD] endless/undefined pageformat, id: "+this.rules.PageFormat.idString),this.rules.PageHeight=100001),this.graphic.reCalculate(),this.drawingParameters.drawCursors&&(this.graphic.Cursors.length=0),this.createOrRefreshRenderBackend(),this.needBackendUpdate=!1,this.drawer.setZoom(this.zoom);for(const i of this.sheet.SourceMeasures)i.WasRendered=!1;this.drawer.drawSheet(this.graphic),this.enableOrDisableCursors(this.drawingParameters.drawCursors),this.drawingParameters.drawCursors&&this.cursors.forEach((e=>{e.update()})),this.zoomUpdated=!1,this.interactionManager.displaySizeChanged(this.container.clientWidth,this.container.clientHeight),this.rules.RenderCount++}createOrRefreshRenderBackend(){if(this.drawer&&this.drawer.Backends){this.drawer.Backends[0]&&this.drawer.Backends[0].removeAllChildrenFromContainer(this.container);for(const e of this.drawer.Backends)e.free();this.drawer.Backends.clear()}this.drawingParameters.Rules=this.rules,this.drawer=new Ht(this.drawingParameters),this.drawer.drawableBoundingBoxElement=this.DrawBoundingBox,this.drawer.bottomLineVisible=this.drawBottomLine,this.drawer.skyLineVisible=this.drawSkyLine;let e,t=this.container.offsetWidth;this.rules.RenderSingleHorizontalStaffline&&(t=10*(this.EngravingRules.PageLeftMargin+this.graphic.MusicPages[0].PositionAndShape.Size.width+this.EngravingRules.PageRightMargin)*this.zoom);const i=32767;for(const n of this.graphic.MusicPages){if(n.PageNumber>this.rules.MaxPageToDrawNumber)break;const r=this.createBackend(this.backendType,n),o=" exceeds CanvasBackend limit of 32767. Cutting off score.";r.getOSMDBackendType()===B.Canvas&&t>i&&(s.warn("[OSMD] Warning: width of "+t+o),t=i),this.rules.PageFormat&&!this.rules.PageFormat.IsUndefined?e=t/this.rules.PageFormat.aspectRatio:(e=n.PositionAndShape.Size.height,e+=this.rules.PageBottomMargin,r.getOSMDBackendType()===B.Canvas&&(e+=.1),e+=n.PositionAndShape.BorderTop,this.rules.RenderTitle&&(e+=this.rules.TitleTopDistance),e*=10*this.zoom),r.getOSMDBackendType()===B.Canvas&&e>i&&(s.warn("[OSMD] Warning: height of "+e+o),e=Math.min(e,i)),r.resize(t,e),r.clear(),r.getContext().setFillStyle(this.rules.DefaultColorMusic),r.getContext().setStrokeStyle(this.rules.DefaultColorMusic),this.drawer.Backends.push(r),this.graphic.drawer=this.drawer}}exportSVG(){for(const t of null===(e=this.drawer)||void 0===e?void 0:e.Backends){var e;t instanceof Xt&&t.export()}}IsReadyToRender(){return void 0!==this.graphic}clear(){var e;null===(e=this.drawer)||void 0===e||e.clear(),this.reset()}dispose(){this.disposeResizeListener&&this.disposeResizeListener(),this.InteractionManager&&this.InteractionManager.Dispose()}setOptions(e){if(this.rules||(this.rules=new xe),this.drawingParameters||e.drawingParameters?e.drawingParameters&&(this.drawingParameters?this.drawingParameters.DrawingParametersEnum=A[e.drawingParameters.toLowerCase()]:this.drawingParameters=new Ot(A[e.drawingParameters],this.rules)):this.drawingParameters=new Ot(A.default,this.rules),null==e)return void s.warn("warning: osmd.setOptions() called without an options parameter, has no effect.\nexample usage: osmd.setOptions({drawCredits: false, drawPartNames: false})");this.OnXMLRead=function(e){return e},e.onXMLRead&&(this.OnXMLRead=e.onXMLRead);let t=!this.drawer||!this.drawer.Backends||this.drawer.Backends.length<1;if(void 0!==e.backend){const i=V.BackendTypeFromString(e.backend);t=t||this.backendType!==i,this.backendType=i}this.needBackendUpdate=t,void 0!==e.autoBeam&&(this.rules.AutoBeamNotes=e.autoBeam);const i=e.autoBeamOptions;if(i&&(void 0===i.maintain_stem_directions&&(i.maintain_stem_directions=!1),this.rules.AutoBeamOptions=i,i.groups&&i.groups.length))for(const s of i.groups)if(2!==s.length)throw new Error("Each fraction in autoBeamOptions.groups must be of length 2, e.g. [3,4] for beaming three fourths");void 0!==e.percussionOneLineCutoff&&(this.rules.PercussionOneLineCutoff=e.percussionOneLineCutoff),0!==this.rules.PercussionOneLineCutoff&&void 0!==e.percussionForceVoicesOneLineCutoff&&(this.rules.PercussionForceVoicesOneLineCutoff=e.percussionForceVoicesOneLineCutoff),void 0!==e.alignRests&&(this.rules.AlignRests=e.alignRests),void 0!==e.coloringMode&&this.setColoringMode(e),void 0!==e.coloringEnabled&&(this.rules.ColoringEnabled=e.coloringEnabled),void 0!==e.colorStemsLikeNoteheads&&(this.rules.ColorStemsLikeNoteheads=e.colorStemsLikeNoteheads),e.disableCursor&&(this.drawingParameters.drawCursors=!1),e.drawHiddenNotes&&(this.drawingParameters.drawHiddenNotes=!0),void 0!==e.drawCredits&&(this.drawingParameters.DrawCredits=e.drawCredits),void 0!==e.drawComposer&&(this.drawingParameters.DrawComposer=e.drawComposer),void 0!==e.drawTitle&&(this.drawingParameters.DrawTitle=e.drawTitle),void 0!==e.drawSubtitle&&(this.drawingParameters.DrawSubtitle=e.drawSubtitle),void 0!==e.drawLyricist&&(this.drawingParameters.DrawLyricist=e.drawLyricist),void 0!==e.drawMetronomeMarks&&(this.rules.MetronomeMarksDrawn=e.drawMetronomeMarks),void 0!==e.drawPartNames&&(this.drawingParameters.DrawPartNames=e.drawPartNames,e.drawPartAbbreviations||(this.rules.RenderPartAbbreviations=e.drawPartNames)),void 0!==e.drawPartAbbreviations&&(this.rules.RenderPartAbbreviations=e.drawPartAbbreviations),!1===e.drawFingerings&&(this.rules.RenderFingerings=!1),void 0!==e.drawMeasureNumbers&&(this.rules.RenderMeasureNumbers=e.drawMeasureNumbers),e.drawMeasureNumbersOnlyAtSystemStart&&(this.rules.RenderMeasureNumbersOnlyAtSystemStart=e.drawMeasureNumbersOnlyAtSystemStart),void 0!==e.drawLyrics&&(this.rules.RenderLyrics=e.drawLyrics),void 0!==e.drawTimeSignatures&&(this.rules.RenderTimeSignatures=e.drawTimeSignatures),void 0!==e.drawSlurs&&(this.rules.RenderSlurs=e.drawSlurs),void 0!==e.measureNumberInterval&&(this.rules.MeasureNumberLabelOffset=e.measureNumberInterval),void 0!==e.useXMLMeasureNumbers&&(this.rules.UseXMLMeasureNumbers=e.useXMLMeasureNumbers),void 0!==e.fingeringPosition&&(this.rules.FingeringPosition=c.PlacementEnumFromString(e.fingeringPosition)),void 0!==e.fingeringInsideStafflines&&(this.rules.FingeringInsideStafflines=e.fingeringInsideStafflines),void 0!==e.newSystemFromXML&&(this.rules.NewSystemAtXMLNewSystemAttribute=e.newSystemFromXML),void 0!==e.newSystemFromNewPageInXML&&(this.rules.NewSystemAtXMLNewPageAttribute=e.newSystemFromNewPageInXML),void 0!==e.newPageFromXML&&(this.rules.NewPageAtXMLNewPageAttribute=e.newPageFromXML),void 0!==e.fillEmptyMeasuresWithWholeRest&&(this.rules.FillEmptyMeasuresWithWholeRest=e.fillEmptyMeasuresWithWholeRest),void 0!==e.followCursor&&(this.FollowCursor=e.followCursor),void 0!==e.setWantedStemDirectionByXml&&(this.rules.SetWantedStemDirectionByXml=e.setWantedStemDirectionByXml),e.darkMode?(this.rules.applyDefaultColorMusic("#FFFFFF"),this.rules.PageBackgroundColor="#000000"):!1===e.darkMode&&(this.rules.applyDefaultColorMusic("#000000"),this.rules.PageBackgroundColor=void 0),e.defaultColorMusic&&this.rules.applyDefaultColorMusic(e.defaultColorMusic),e.defaultColorNotehead&&(this.rules.DefaultColorNotehead=e.defaultColorNotehead),e.defaultColorRest&&(this.rules.DefaultColorRest=e.defaultColorRest),e.defaultColorStem&&(this.rules.DefaultColorStem=e.defaultColorStem),e.defaultColorLabel&&(this.rules.DefaultColorLabel=e.defaultColorLabel),e.defaultColorTitle&&(this.rules.DefaultColorTitle=e.defaultColorTitle),e.defaultFontFamily&&(this.rules.DefaultFontFamily=e.defaultFontFamily),e.defaultFontStyle&&(this.rules.DefaultFontStyle=e.defaultFontStyle),e.drawUpToMeasureNumber>=0&&(this.rules.MaxMeasureToDrawIndex=Math.max(e.drawUpToMeasureNumber-1,0),this.rules.MaxMeasureToDrawNumber=e.drawUpToMeasureNumber),e.drawFromMeasureNumber>=0&&(this.rules.MinMeasureToDrawIndex=Math.max(e.drawFromMeasureNumber-1,0),this.rules.MinMeasureToDrawNumber=e.drawFromMeasureNumber),e.drawUpToPageNumber&&(this.rules.MaxPageToDrawNumber=e.drawUpToPageNumber),e.drawUpToSystemNumber&&(this.rules.MaxSystemToDrawNumber=e.drawUpToSystemNumber),e.tupletsRatioed&&(this.rules.TupletsRatioed=!0),e.tupletsBracketed&&(this.rules.TupletsBracketed=!0),e.tripletsBracketed&&(this.rules.TripletsBracketed=!0),e.autoResize?(this.resizeHandlerAttached||this.autoResize(),this.autoResizeEnabled=!0):!1===e.autoResize&&(this.autoResizeEnabled=!1),void 0!==e.pageFormat&&this.setPageFormat(e.pageFormat),void 0!==e.pageBackgroundColor&&(this.rules.PageBackgroundColor=e.pageBackgroundColor),void 0!==e.performanceMode&&(this.rules.PerformanceMode=e.performanceMode),void 0!==e.renderSingleHorizontalStaffline&&(this.rules.RenderSingleHorizontalStaffline=e.renderSingleHorizontalStaffline),void 0!==e.spacingFactorSoftmax&&(this.rules.SoftmaxFactorVexFlow=e.spacingFactorSoftmax),void 0!==e.spacingBetweenTextLines&&(this.rules.SpacingBetweenTextLines=e.spacingBetweenTextLines),void 0!==e.stretchLastSystemLine&&(this.rules.StretchLastSystemLine=e.stretchLastSystemLine),void 0!==e.autoGenerateMultipleRestMeasuresFromRestMeasures&&(this.rules.AutoGenerateMultipleRestMeasuresFromRestMeasures=e.autoGenerateMultipleRestMeasuresFromRestMeasures),void 0!==e.cursorsOptions?this.cursorsOptions=e.cursorsOptions:this.cursorsOptions=[{type:R.Standard,color:this.EngravingRules.DefaultColorCursor,alpha:.5,follow:!0}],void 0!==e.preferredSkyBottomLineBatchCalculatorBackend&&(this.rules.PreferredSkyBottomLineBatchCalculatorBackend=e.preferredSkyBottomLineBatchCalculatorBackend),void 0!==e.skyBottomLineBatchMinMeasures&&(this.rules.SkyBottomLineBatchMinMeasures=e.skyBottomLineBatchMinMeasures)}setColoringMode(e){if(e.coloringMode===fe.XML)return void(this.rules.ColoringMode=fe.XML);const t=[H.C,H.D,H.E,H.F,H.G,H.A,H.B];let s;if(e.coloringMode===fe.CustomColorSet){if(!e.coloringSetCustom||8!==e.coloringSetCustom.length)throw new Error("Invalid amount of colors: With coloringModes.customColorSet, you have to provide a coloringSetCustom parameter (array) with 8 strings (C to B, rest note).");for(const t of e.coloringSetCustom)if(!/^\#[0-9a-fA-F]{6}$/.test(t))throw new Error("One of the color strings in options.coloringSetCustom was not a valid HTML Hex color:\n"+t);s=e.coloringSetCustom}else if(e.coloringMode===fe.AutoColoring){s=[];const e=Object.keys(U);for(let t=0;t{e.hide()})),this.sheet=void 0,this.graphic=void 0,this.zoom=1,this.rules.RenderCount=0}autoResize(){const e=this;this.handleResize((()=>{}),(()=>{var t;(null===(t=this.graphic)||void 0===t?void 0:t.GetCalculator)instanceof bs&&(this.graphic.GetCalculator.beamsNeedUpdate=!0),e.IsReadyToRender()&&e.render()}))}handleResize(e,t){let i,s;const n=this;function r(){n.AutoResizeEnabled&&(i=(new Date).getTime(),s||(e(),i=(new Date).getTime(),s=window.setTimeout(o,200)))}function o(){s=void 0,window.clearTimeout(s),(new Date).getTime()-i<200?s=window.setTimeout(o,200):t()}window.attachEvent?window.attachEvent("onresize",r):window.addEventListener("resize",r),this.disposeResizeListener=()=>{window.detachEvent?window.detachEvent("onresize",r):window.removeEventListener("resize",r),this.resizeHandlerAttached=!1},this.resizeHandlerAttached=!0,window.setTimeout(e,0),window.setTimeout(t,1)}enableOrDisableCursors(e){if(this.drawingParameters.drawCursors=e,e){var t;for(let e=0;e{e.hide()}))}createBackend(e,t){let i;return i=void 0===e||e===B.SVG?new Xt(this.rules):new Ki(this.rules),i.graphicalMusicPage=t,i.initialize(this.container,this.zoom),i}static StringToPageFormat(e){let t=Te.UndefinedPageFormat;if(e.match("^[0-9]+x[0-9]+$")){const i=e.split("x"),s=Number.parseInt(i[0],10),n=Number.parseInt(i[1],10);s>0&&s<32768&&n>0&&n<32768&&(t=new Te(s,n,`customPageFormat${e}`))}return e=(e=(e=e.replace(" ","_")).replace("Landscape","L")).replace("Portrait","P"),ln.PageFormatStandards.hasOwnProperty(e)?(t=ln.PageFormatStandards[e],t):t}setPageFormat(e){const t=ln.StringToPageFormat(e);this.needBackendUpdate=!t.Equals(this.rules.PageFormat),this.rules.PageFormat=t}setCustomPageFormat(e,t){if(e>0&&t>0){const i=new Te(e,t);this.rules.PageFormat=i}}set DrawSkyLine(e){this.drawSkyLine=e,this.drawer&&(this.drawer.skyLineVisible=e)}get DrawSkyLine(){return this.drawer.skyLineVisible}set DrawBottomLine(e){this.drawBottomLine=e,this.drawer&&(this.drawer.bottomLineVisible=e)}get DrawBottomLine(){return this.drawer.bottomLineVisible}set DrawBoundingBox(e){this.setDrawBoundingBox(e,!0)}get DrawBoundingBox(){return this.drawBoundingBox}setDrawBoundingBox(e,t=!1){this.drawBoundingBox=e,this.drawer&&(this.drawer.drawableBoundingBoxElement=e),t&&this.render()}get AutoResizeEnabled(){return this.autoResizeEnabled}set AutoResizeEnabled(e){this.autoResizeEnabled=e}get Zoom(){return this.zoom}set Zoom(e){var t;this.zoom=e,this.zoomUpdated=!0,(null===(t=this.graphic)||void 0===t?void 0:t.GetCalculator)instanceof bs&&(this.graphic.GetCalculator.beamsNeedUpdate=this.zoomUpdated)}set FollowCursor(e){this.followCursor=e}get FollowCursor(){return this.followCursor}set TransposeCalculator(e){yi.transposeCalculator=e}get TransposeCalculator(){return yi.transposeCalculator}get Sheet(){return this.sheet}get Drawer(){return this.drawer}get GraphicSheet(){return this.graphic}get DrawingParameters(){return this.drawingParameters}get EngravingRules(){return this.rules}get InteractionManager(){return this.interactionManager}get Version(){return this.version}};e("O",ln).PageFormatStandards={A3_L:new Te(420,297,"A3_L"),A3_P:new Te(297,420,"A3_P"),A4_L:new Te(297,210,"A4_L"),A4_P:new Te(210,297,"A4_P"),A5_L:new Te(210,148,"A5_L"),A5_P:new Te(148,210,"A5_P"),A6_L:new Te(148,105,"A6_L"),A6_P:new Te(105,148,"A6_P"),Endless:Te.UndefinedPageFormat,Letter_L:new Te(279.4,215.9,"Letter_L"),Letter_P:new Te(215.9,279.4,"Letter_P")},H.C,H.D,H.E,H.F,H.G,H.A,H.B}}}));