!function(){function e(){return(e="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,i){var n=S(e,t);if(n){var r=Object.getOwnPropertyDescriptor(n,t);return r.get?r.get.call(arguments.length<3?e:i):r.value}}).apply(this,arguments)}function t(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==i)return;var n,r,s=[],a=!0,o=!1;try{for(i=i.call(e);!(a=(n=i.next()).done)&&(s.push(n.value),!t||s.length!==t);a=!0);}catch(u){o=!0,r=u}finally{try{a||null==i.return||i.return()}finally{if(o)throw r}}return s}(e,t)||u(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function n(e){for(var t=1;t=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,a=!0,o=!1;return{s:function(){i=i.call(e)},n:function(){var e=i.next();return a=e.done,e},e:function(e){o=!0,s=e},f:function(){try{a||null==i.return||i.return()}finally{if(o)throw s}}}}function u(e,t){if(e){if("string"==typeof e)return l(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?l(e,t):void 0}}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i1&&void 0!==arguments[1]?arguments[1]:9e3,n=e.indexOf(".mxl")>-1?"text/plain; charset=x-user-defined":"application/xml";if(XMLHttpRequest)t=new XMLHttpRequest;else{if(!ActiveXObject)return Promise.reject(new Error("XMLHttp not supported."));t=new ActiveXObject("Microsoft.XMLHTTP")}return t.timeout=i,new Promise((function(i,r){t.onreadystatechange=function(){t.readyState===XMLHttpRequest.DONE&&(200===t.status||0===t.status&&t.responseText?i(t.responseText):r(new Error("Could not retrieve requested URL "+t.status)))},t.ontimeout=function(e){r(new Error("Server request Timeout"))},t.overrideMimeType(n),t.open("GET",e,!0),t.send()}))}}]),e}(),f=i("F",function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];k(this,e),this.numerator=0,this.denominator=1,this.wholeValue=0,this.numerator=t,this.denominator=i,this.wholeValue=n,r&&this.simplify(),this.setRealValue()}return E(e,[{key:"toString",value:function(){var e=this.numerator+"/"+this.denominator;return 0!==this.wholeValue&&(e=this.wholeValue+" "+e),e}},{key:"clone",value:function(){return new e(this.numerator,this.denominator,this.wholeValue,!1)}},{key:"Numerator",get:function(){return this.numerator},set:function(e){this.numerator!==e&&(this.numerator=e,this.simplify(),this.setRealValue())}},{key:"Denominator",get:function(){return this.denominator},set:function(e){this.denominator!==e&&(this.denominator=e,0!==this.numerator&&this.simplify(),this.setRealValue())}},{key:"WholeValue",get:function(){return this.wholeValue},set:function(e){this.wholeValue!==e&&(this.wholeValue=e,this.setRealValue())}},{key:"GetExpandedNumerator",value:function(){return this.wholeValue*this.denominator+this.numerator}},{key:"calculateNumberOfNeededDots",value:function(){for(var e=1,t=2,i=this.GetExpandedNumerator();tt;)i.Numerator++;if(this.numerator>this.denominator){for(var n=new e(this.numerator-1,this.denominator,this.wholeValue);n.Denominator>t;)n.Numerator--;if(n.Denominatore.maximumAllowedNumber){var n=this.denominator/e.maximumAllowedNumber;this.numerator=Math.round(this.numerator/n),this.denominator=Math.round(this.denominator/n)}if(this.numerator>e.maximumAllowedNumber){var r=this.numerator/e.maximumAllowedNumber;this.numerator=Math.round(this.numerator/r),this.denominator=Math.round(this.denominator/r)}}else this.denominator=1}},{key:"isOnBeat",value:function(t){var i=this.distanceFromBeat(t);return Math.abs(i)t.RealValue?e:t}},{key:"Equal",value:function(e,t){return e.wholeValue===t.wholeValue&&e.Denominator===t.Denominator&&e.Numerator===t.Numerator}},{key:"createFromFraction",value:function(t){return new e(t.numerator,t.denominator,t.wholeValue,!1)}},{key:"plus",value:function(e,t){var i=e.clone();return i.Add(t),i}},{key:"minus",value:function(e,t){var i=e.clone();return i.Sub(t),i}},{key:"multiply",value:function(t,i){return new e((t.wholeValue*t.denominator+t.numerator)*(i.wholeValue*i.denominator+i.numerator),t.denominator*i.denominator)}},{key:"greatestCommonDenominator",value:function(e,t){if(0===e)return t;if(1===t)return 1;for(;Math.abs(t)>1e-8;)e>t?e-=t:t-=e;return Math.round(e)}}]),e}());f.maximumAllowedNumber=46340,f.FloatInaccuracyTolerance=1e-4;var m=function(){function e(t){k(this,e),this.placement=t}return E(e,[{key:"Placement",get:function(){return this.placement}}],[{key:"isStringInStringList",value:function(e,t){for(var i=0,n=e.length;i6&&void 0!==arguments[6]?arguments[6]:"";return k(this,i),y((u=v(l=t.call(this,n)),x(i.prototype)),"parentMeasure",s,u,!0),l.NumberXml=o,l.dynamicType=e,l.label=h,l.staffNumber=r,l.activeInstantaneousDynamic=a,l.startVolume=1,l.endVolume=1,l.setStartAndEndVolume(),""!==h&&l.setType(),l}return E(i,[{key:"setStartAndEndVolume",value:function(){this.activeInstantaneousDynamic&&(this.dynamicType===_.crescendo&&(this.startVolume=this.activeInstantaneousDynamic.Volume,this.endVolume=1.2*this.activeInstantaneousDynamic.Volume),this.dynamicType===_.diminuendo&&(this.startVolume=this.activeInstantaneousDynamic.Volume,this.endVolume=.8*this.activeInstantaneousDynamic.Volume))}},{key:"DynamicType",get:function(){return this.dynamicType},set:function(e){this.dynamicType=e}},{key:"StartMultiExpression",get:function(){return this.startMultiExpression},set:function(e){this.startMultiExpression=e}},{key:"EndMultiExpression",get:function(){return this.endMultiExpression},set:function(e){this.endMultiExpression=e}},{key:"Placement",get:function(){return this.placement},set:function(e){this.placement=e}},{key:"StartVolume",get:function(){return this.startVolume},set:function(e){this.startVolume=e}},{key:"EndVolume",get:function(){return this.endVolume},set:function(e){this.endVolume=e}},{key:"StaffNumber",get:function(){return this.staffNumber},set:function(e){this.staffNumber=e}},{key:"Label",get:function(){return this.label},set:function(e){this.label=e,this.setType()}},{key:"getInterpolatedDynamic",value:function(e){var t,i=this.StartMultiExpression.AbsoluteTimestamp;if(t=this.EndMultiExpression?this.EndMultiExpression.AbsoluteTimestamp:f.plus(this.startMultiExpression.SourceMeasureParent.AbsoluteTimestamp,this.startMultiExpression.SourceMeasureParent.Duration),e.lt(i))return-1;if(t.lt(e))return-2;var n=f.minus(e,i).RealValue/f.minus(t,i).RealValue;return Math.max(0,Math.min(99.9,this.startVolume+(this.endVolume-this.startVolume)*n))}},{key:"isWedge",value:function(){return!this.label}},{key:"setType",value:function(){i.isStringInStringList(i.listContinuousDynamicIncreasing,this.label)?this.dynamicType=_.crescendo:i.isStringInStringList(i.listContinuousDynamicDecreasing,this.label)&&(this.dynamicType=_.diminuendo)}}],[{key:"isInputStringContinuousDynamic",value:function(e){return!!e&&(i.isStringInStringList(i.listContinuousDynamicIncreasing,e)||i.isStringInStringList(i.listContinuousDynamicDecreasing,e))}}]),i}(m);S.listContinuousDynamicIncreasing=["crescendo","cresc","cresc.","cres."],S.listContinuousDynamicDecreasing=["decrescendo","decresc","decr.","diminuendo","dim.","dim"];var _=function(e){return e[e.crescendo=0]="crescendo",e[e.diminuendo=1]="diminuendo",e}(_||{}),w=function(e){return 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}(w||{}),M=E((function e(t,i){k(this,e),this.message=t,i&&(this.message+=" "+i.toString())})),T=E((function e(t){k(this,e),this.message=t})),P=E((function e(t){k(this,e),this.message=t})),L={};!function(e){var t,i;t=u,i=function(){var e=function(){},t="undefined",i=("undefined"==typeof window?"undefined":h(window))!==t&&h(window.navigator)!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),n=["trace","debug","info","warn","error"];function r(e,t){var i=e[t];if("function"==typeof i.bind)return i.bind(e);try{return Function.prototype.bind.call(i,e)}catch(n){return function(){return Function.prototype.apply.apply(i,[e,arguments])}}}function s(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function a(n){return"debug"===n&&(n="log"),("undefined"==typeof console?"undefined":h(console))!==t&&("trace"===n&&i?s:void 0!==console[n]?r(console,n):void 0!==console.log?r(console,"log"):e)}function o(t,i){for(var r=0;r=0&&i<=a.levels.SILENT))throw"log.setLevel() called with invalid level: "+i;if(s=i,!1!==r&&function(e){var i=(n[e]||"silent").toUpperCase();if(("undefined"==typeof window?"undefined":h(window))!==t&&u){try{return void(window.localStorage[u]=i)}catch(r){}try{window.document.cookie=encodeURIComponent(u)+"="+i+";"}catch(r){}}}(i),o.call(a,i,e),("undefined"==typeof console?"undefined":h(console))===t&&i=0;r--)if(n(e[r],t))return r;return-1},A.contains=function(e,t,i){return N(e,t,i)>=0},A.remove=function(e,t,i){var n=N(e,t,i);return!(n<0)&&(e.splice(n,1),!0)},A.frequency=function(e,t,i){for(var n=i||I.defaultEquals,r=e.length,s=0,a=0;a=e.length||i<0||i>=e.length)return!1;var n=e[t];return e[t]=e[i],e[i]=n,!0},A.toString=function(e){return"["+e.toString()+"]"},A.forEach=function(e,t){for(var i=0,n=e;ie.size())return!1;var t=!0;return this.forEach((function(i){return!!e.contains(i)||(t=!1,!1)})),t},e.prototype.remove=function(e){return!!this.contains(e)&&(this.dictionary.remove(e),!0)},e.prototype.forEach=function(e){this.dictionary.forEach((function(t,i){return e(i)}))},e.prototype.toArray=function(){return this.dictionary.values()},e.prototype.isEmpty=function(){return this.dictionary.isEmpty()},e.prototype.size=function(){return this.dictionary.size()},e.prototype.clear=function(){this.dictionary.clear()},e.prototype.toString=function(){return U.toString(this.toArray())},e}();G.default=H,Object.defineProperty(B,"__esModule",{value:!0});var X=R,Y=D,j=G,K=function(){function e(e){this.toStrF=e||X.defaultToString,this.dictionary=new Y.default(this.toStrF),this.nElements=0}return e.prototype.add=function(e,t){if(void 0===t&&(t=1),X.isUndefined(e)||t<=0)return!1;if(this.contains(e))this.dictionary.getValue(e).copies+=t;else{var i={value:e,copies:t};this.dictionary.setValue(e,i)}return this.nElements+=t,!0},e.prototype.count=function(e){return this.contains(e)?this.dictionary.getValue(e).copies:0},e.prototype.contains=function(e){return this.dictionary.containsKey(e)},e.prototype.remove=function(e,t){if(void 0===t&&(t=1),X.isUndefined(e)||t<=0)return!1;if(this.contains(e)){var i=this.dictionary.getValue(e);return t>i.copies?this.nElements-=i.copies:this.nElements-=t,i.copies-=t,i.copies<=0&&this.dictionary.remove(e),!0}return!1},e.prototype.toArray=function(){for(var e=[],t=0,i=this.dictionary.values();tthis.nElements||Q.isUndefined(e))return!1;var i=this.createNode(e);if(0===this.nElements||null===this.lastNode)this.firstNode=i,this.lastNode=i;else if(t===this.nElements)this.lastNode.next=i,this.lastNode=i;else if(0===t)i.next=this.firstNode,this.firstNode=i;else{var n=this.nodeAtIndex(t-1);if(null===n)return!1;i.next=n.next,n.next=i}return this.nElements++,!0},e.prototype.first=function(){if(null!==this.firstNode)return this.firstNode.element},e.prototype.last=function(){if(null!==this.lastNode)return this.lastNode.element},e.prototype.elementAtIndex=function(e){var t=this.nodeAtIndex(e);if(null!==t)return t.element},e.prototype.indexOf=function(e,t){var i=t||Q.defaultEquals;if(Q.isUndefined(e))return-1;for(var n=this.firstNode,r=0;null!==n;){if(i(n.element,e))return r;r++,n=n.next}return-1},e.prototype.contains=function(e,t){return this.indexOf(e,t)>=0},e.prototype.remove=function(e,t){var i=t||Q.defaultEquals;if(this.nElements<1||Q.isUndefined(e))return!1;for(var n=null,r=this.firstNode;null!==r;){if(i(r.element,e))return null===n?(this.firstNode=r.next,r===this.lastNode&&(this.lastNode=null)):r===this.lastNode?(this.lastNode=n,n.next=r.next,r.next=null):(n.next=r.next,r.next=null),this.nElements--,!0;n=r,r=r.next}return!1},e.prototype.clear=function(){this.firstNode=null,this.lastNode=null,this.nElements=0},e.prototype.equals=function(t,i){var n=i||Q.defaultEquals;return t instanceof e&&(this.size()===t.size()&&this.equalsAux(this.firstNode,t.firstNode,n))},e.prototype.equalsAux=function(e,t,i){for(;null!==e&&null!==t;){if(!i(e.element,t.element))return!1;e=e.next,t=t.next}return!0},e.prototype.removeElementAtIndex=function(e){if(!(e<0||e>=this.nElements||null===this.firstNode||null===this.lastNode)){var t;if(1===this.nElements)t=this.firstNode.element,this.firstNode=null,this.lastNode=null;else{var i=this.nodeAtIndex(e-1);null===i?(t=this.firstNode.element,this.firstNode=this.firstNode.next):i.next===this.lastNode&&(t=this.lastNode.element,this.lastNode=i),null!==i&&null!==i.next&&(t=i.next.element,i.next=i.next.next)}return this.nElements--,t}},e.prototype.forEach=function(e){for(var t=this.firstNode;null!==t&&!1!==e(t.element);)t=t.next},e.prototype.reverse=function(){for(var e=null,t=this.firstNode,i=null;null!==t;)i=t.next,t.next=e,e=t,t=i;i=this.firstNode,this.firstNode=this.lastNode,this.lastNode=i},e.prototype.toArray=function(){for(var e=[],t=this.firstNode;null!==t;)e.push(t.element),t=t.next;return e},e.prototype.size=function(){return this.nElements},e.prototype.isEmpty=function(){return this.nElements<=0},e.prototype.toString=function(){return ee.toString(this.toArray())},e.prototype.nodeAtIndex=function(e){if(e<0||e>=this.nElements)return null;if(e===this.nElements-1)return this.lastNode;for(var t=this.firstNode,i=0;i0&&(e=e.rightCh);return e},e.prototype.transplant=function(e,t){null===e.parent?this.root=t:e===e.parent.leftCh?e.parent.leftCh=t:e.parent.rightCh=t,null!==t&&(t.parent=e.parent)},e.prototype.removeNode=function(e){if(null===e.leftCh)this.transplant(e,e.rightCh);else if(null===e.rightCh)this.transplant(e,e.leftCh);else{var t=this.minimumAux(e.rightCh);t.parent!==e&&(this.transplant(t,t.rightCh),t.rightCh=e.rightCh,t.rightCh.parent=t),this.transplant(e,t),t.leftCh=e.leftCh,t.leftCh.parent=t}},e.prototype.inorderTraversalAux=function(e,t,i){null===e||i.stop||(this.inorderTraversalAux(e.leftCh,t,i),i.stop||(i.stop=!1===t(e.element),i.stop||this.inorderTraversalAux(e.rightCh,t,i)))},e.prototype.levelTraversalAux=function(e,t){var i=new se.default;for(null!==e&&i.enqueue(e),e=i.dequeue()||null;null!=e;){if(!1===t(e.element))return;null!==e.leftCh&&i.enqueue(e.leftCh),null!==e.rightCh&&i.enqueue(e.rightCh),e=i.dequeue()||null}},e.prototype.preorderTraversalAux=function(e,t,i){null===e||i.stop||(i.stop=!1===t(e.element),i.stop||(this.preorderTraversalAux(e.leftCh,t,i),i.stop||this.preorderTraversalAux(e.rightCh,t,i)))},e.prototype.postorderTraversalAux=function(e,t,i){null===e||i.stop||(this.postorderTraversalAux(e.leftCh,t,i),i.stop||(this.postorderTraversalAux(e.rightCh,t,i),i.stop||(i.stop=!1===t(e.element))))},e.prototype.minimumAux=function(e){for(;null!=e&&null!==e.leftCh;)e=e.leftCh;return e},e.prototype.maximumAux=function(e){for(;null!=e&&null!==e.rightCh;)e=e.rightCh;return e},e.prototype.heightAux=function(e){return null===e?-1:Math.max(this.heightAux(e.leftCh),this.heightAux(e.rightCh))+1},e.prototype.insertNode=function(e){for(var t=null,i=this.root;null!==i;){var n=this.compare(e.element,i.element);if(0===n)return null;n<0?(t=i,i=i.leftCh):(t=i,i=i.rightCh)}return e.parent=t,null===t?this.root=e:this.compare(e.element,t.element)<0?t.leftCh=e:t.rightCh=e,e},e.prototype.createNode=function(e){return{element:e,leftCh:null,rightCh:null,parent:null}},e}();J.default=ae;var oe,ue=u&&u.__extends||(oe=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])},function(e,t){function i(){this.constructor=e}oe(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)});Object.defineProperty(q,"__esModule",{value:!0});var le=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return ue(t,e),t}(J.default);q.default=le;var he={};Object.defineProperty(he,"__esModule",{value:!0});var ce=R,fe=A,de=function(){function e(e){this.data=[],this.compare=e||ce.defaultCompare}return e.prototype.leftChildIndex=function(e){return 2*e+1},e.prototype.rightChildIndex=function(e){return 2*e+2},e.prototype.parentIndex=function(e){return Math.floor((e-1)/2)},e.prototype.minIndex=function(e,t){return t>=this.data.length?e>=this.data.length?-1:e:this.compare(this.data[e],this.data[t])<=0?e:t},e.prototype.siftUp=function(e){for(var t=this.parentIndex(e);e>0&&this.compare(this.data[t],this.data[e])>0;)fe.swap(this.data,t,e),e=t,t=this.parentIndex(e)},e.prototype.siftDown=function(e){for(var t=this.minIndex(this.leftChildIndex(e),this.rightChildIndex(e));t>=0&&this.compare(this.data[e],this.data[t])>0;)fe.swap(this.data,t,e),e=t,t=this.minIndex(this.leftChildIndex(e),this.rightChildIndex(e))},e.prototype.peek=function(){return this.data.length>0?this.data[0]:void 0},e.prototype.add=function(e){return!ce.isUndefined(e)&&(this.data.push(e),this.siftUp(this.data.length-1),!0)},e.prototype.removeRoot=function(){if(this.data.length>0){var e=this.data[0];return this.data[0]=this.data[this.data.length-1],this.data.splice(this.data.length-1,1),this.data.length>0&&this.siftDown(0),e}},e.prototype.contains=function(e){var t=ce.compareToEquals(this.compare);return fe.contains(this.data,e,t)},e.prototype.size=function(){return this.data.length},e.prototype.isEmpty=function(){return this.data.length<=0},e.prototype.clear=function(){this.data.length=0},e.prototype.forEach=function(e){fe.forEach(this.data,e)},e}();he.default=de;var pe={},ve=u&&u.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])};return function(t,i){function n(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}}();Object.defineProperty(pe,"__esModule",{value:!0});var me=D,ge=R,ye=function(){function e(e,t){this.key=e,this.value=t}return e.prototype.unlink=function(){this.prev.next=this.next,this.next.prev=this.prev},e}(),be=function(){function e(){this.key=null,this.value=null}return e.prototype.unlink=function(){this.prev.next=this.next,this.next.prev=this.prev},e}();var Se=function(e){function t(t){var i=e.call(this,t)||this;return i.head=new be,i.tail=new be,i.head.next=i.tail,i.tail.prev=i.head,i}return ve(t,e),t.prototype.appendToTail=function(e){var t=this.tail.prev;t.next=e,e.prev=t,e.next=this.tail,this.tail.prev=e},t.prototype.getLinkedDictionaryPair=function(e){if(!ge.isUndefined(e)){var t="$"+this.toStr(e);return this.table[t]}},t.prototype.getValue=function(e){var t=this.getLinkedDictionaryPair(e);if(!ge.isUndefined(t))return t.value},t.prototype.remove=function(t){var i=this.getLinkedDictionaryPair(t);if(!ge.isUndefined(i))return e.prototype.remove.call(this,t),i.unlink(),i.value},t.prototype.clear=function(){e.prototype.clear.call(this),this.head.next=this.tail,this.tail.prev=this.head},t.prototype.replace=function(e,t){var i="$"+this.toStr(t.key);t.next=e.next,t.prev=e.prev,this.remove(e.key),t.prev.next=t,t.next.prev=t,this.table[i]=t,++this.nElements},t.prototype.setValue=function(e,t){if(!ge.isUndefined(e)&&!ge.isUndefined(t)){var i=this.getLinkedDictionaryPair(e),n=new ye(e,t),r="$"+this.toStr(e);return ge.isUndefined(i)?(this.appendToTail(n),this.table[r]=n,void++this.nElements):(this.replace(i,n),i.value)}},t.prototype.keys=function(){var e=[];return this.forEach((function(t,i){e.push(t)})),e},t.prototype.values=function(){var e=[];return this.forEach((function(t,i){e.push(i)})),e},t.prototype.forEach=function(e){for(var t=this.head.next;t.next;){if(!1===e(t.key,t.value))return;t=t.next}},t}(me.default);pe.default=Se;var xe={};Object.defineProperty(xe,"__esModule",{value:!0});var ke=R,_e=D,Ee=A,we=function(){function e(e,t,i){void 0===i&&(i=!1),this.dict=new _e.default(e),this.equalsF=t||ke.defaultEquals,this.allowDuplicate=i}return e.prototype.getValue=function(e){var t=this.dict.getValue(e);return ke.isUndefined(t)?[]:Ee.copy(t)},e.prototype.setValue=function(e,t){if(ke.isUndefined(e)||ke.isUndefined(t))return!1;var i=this.dict.getValue(e);return ke.isUndefined(i)?(this.dict.setValue(e,[t]),!0):!(!this.allowDuplicate&&Ee.contains(i,t,this.equalsF))&&(i.push(t),!0)},e.prototype.remove=function(e,t){if(ke.isUndefined(t)){var i=this.dict.remove(e);return!ke.isUndefined(i)}var n=this.dict.getValue(e);return!(ke.isUndefined(n)||!Ee.remove(n,t,this.equalsF))&&(0===n.length&&this.dict.remove(e),!0)},e.prototype.keys=function(){return this.dict.keys()},e.prototype.values=function(){for(var e=[],t=0,i=this.dict.values();t-1&&this.insertIdIntoRoot(t,i),this.nodes)if(this.nodes.hasOwnProperty(n)){var r=this.findNodeId(n,e);r>-1&&this.insertIdIntoNode(n,t,r)}},e.prototype.insertIdAfterId=function(e,t){var i=this.findRootId(e);for(var n in i>-1&&this.insertIdIntoRoot(t,i+1),this.nodes)if(this.nodes.hasOwnProperty(n)){var r=this.findNodeId(n,e);r>-1&&this.insertIdIntoNode(n,t,r+1)}},e.prototype.insertIdIntoId=function(e,t){this.nodeInsertAtEnd(e,t),this.nodes[t]=[]},e.prototype.insertIdIntoRoot=function(e,t){if(void 0===t)this.rootInsertAtEnd(e);else if(t<0){var i=this.rootIds.length;this.rootIds.splice(t+i+1,0,e)}else this.rootIds.splice(t,0,e);this.nodes[e]=this.nodes[e]||[]},e.prototype.insertIdIntoNode=function(e,t,i){if(this.nodes[e]=this.nodes[e]||[],this.nodes[t]=this.nodes[t]||[],void 0===i)this.nodeInsertAtEnd(e,t);else if(i<0){var n=this.nodes[e].length;this.nodes[e].splice(i+n+1,0,t)}else this.nodes[e].splice(i,0,t)},e.prototype.moveId=function(e,t,i){var n=e,r=this.findRootId(n);for(var s in this.nodes[t],this.nodes)if(this.nodes.hasOwnProperty(s)){this.findNodeId(s,t);break}var a=t,o=this.findRootId(a);for(var s in this.nodes[t],this.nodes)if(this.nodes.hasOwnProperty(s)){this.findNodeId(s,t);break}if(r>-1)if(o>-1)switch(this.rootDelete(r),o>r&&o--,i){case Oe.BEFORE:this.insertIdIntoRoot(n,o);break;case Oe.AFTER:this.insertIdIntoRoot(n,o+1);break;case Oe.INSIDE_AT_START:this.nodeInsertAtStart(a,n);break;case Oe.INSIDE_AT_END:this.nodeInsertAtEnd(a,n)}else for(var s in this.rootDelete(r),this.nodes){if(this.nodes.hasOwnProperty(s))if((u=this.findNodeId(s,a))>-1){switch(i){case Oe.BEFORE:this.insertIdIntoNode(s,n,u);break;case Oe.AFTER:this.insertIdIntoNode(s,n,u+1);break;case Oe.INSIDE_AT_START:this.nodeInsertAtStart(a,n);break;case Oe.INSIDE_AT_END:this.nodeInsertAtEnd(a,n)}break}}else if(o>-1){for(var s in this.nodes){if(this.nodes.hasOwnProperty(s))if((u=this.findNodeId(s,n))>-1){this.nodeDeleteAtIndex(s,u);break}}switch(i){case Oe.BEFORE:this.insertIdIntoRoot(n,o);break;case Oe.AFTER:this.insertIdIntoRoot(n,o+1);break;case Oe.INSIDE_AT_START:this.nodeInsertAtStart(a,n);break;case Oe.INSIDE_AT_END:this.nodeInsertAtEnd(a,n)}}else{for(var s in this.nodes){if(this.nodes.hasOwnProperty(s))if((u=this.findNodeId(s,n))>-1){this.nodeDeleteAtIndex(s,u);break}}for(var s in this.nodes){var u;if(this.nodes.hasOwnProperty(s))if((u=this.findNodeId(s,a))>-1){switch(i){case Oe.BEFORE:this.insertIdIntoNode(s,n,u);break;case Oe.AFTER:this.insertIdIntoNode(s,n,u+1);break;case Oe.INSIDE_AT_START:this.nodeInsertAtStart(a,n);break;case Oe.INSIDE_AT_END:this.nodeInsertAtEnd(a,n)}break}}}},e.prototype.swapArrayElements=function(e,t,i){var n=e[t];return e[t]=e[i],e[i]=n,e},e.prototype.rootDeleteId=function(e){var t=this.findRootId(e);t>-1&&this.rootDelete(t)},e.prototype.nodeAndSubNodesDelete=function(e){for(var t=[],i=0;i0&&void 0!==arguments[0]?arguments[0]:void 0,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,n=new e(this.musicSheet,null!=t?t:this.currentTimeStamp,i);return n.currentVoiceEntryIndex=this.currentVoiceEntryIndex,n.currentMappingPart=this.currentMappingPart,n.currentPartIndex=this.currentPartIndex,n.currentVoiceEntries=this.currentVoiceEntries,n.endReached=this.endReached,n.frontReached=this.frontReached,n}},{key:"CurrentVisibleVoiceEntries",value:function(e){var t=[];if(!this.currentVoiceEntries)return t;if(e){var i,n=o(this.currentVoiceEntries);try{for(n.s();!(i=n.n()).done;){var r=i.value;if(r.ParentVoice.Parent.IdString===e.IdString)return this.getVisibleEntries(r,t),t}}catch(l){n.e(l)}finally{n.f()}}else{var s,a=o(this.currentVoiceEntries);try{for(a.s();!(s=a.n()).done;){var u=s.value;this.getVisibleEntries(u,t)}}catch(l){a.e(l)}finally{a.f()}}return t}},{key:"CurrentAudibleVoiceEntries",value:function(e){var t=[];if(this.currentVoiceEntries)if(e){var i,n=o(this.currentVoiceEntries);try{for(n.s();!(i=n.n()).done;){var r=i.value;if(r.ParentVoice.Parent.IdString===e.IdString)return this.getAudibleEntries(r,t),t}}catch(l){n.e(l)}finally{n.f()}}else{var s,a=o(this.currentVoiceEntries);try{for(a.s();!(s=a.n()).done;){var u=s.value;this.getAudibleEntries(u,t)}}catch(l){a.e(l)}finally{a.f()}}return t}},{key:"getCurrentDynamicChangingExpressions",value:function(){return this.currentDynamicChangingExpressions}},{key:"CurrentScoreFollowingVoiceEntries",value:function(e){var t=[];if(!this.currentVoiceEntries)return t;if(e){var i,n=o(this.currentVoiceEntries);try{for(n.s();!(i=n.n()).done;){var r=i.value;if(r.ParentVoice.Parent.IdString===e.IdString)return this.getScoreFollowingEntries(r,t),t}}catch(l){n.e(l)}finally{n.f()}}else{var s,a=o(this.currentVoiceEntries);try{for(a.s();!(s=a.n()).done;){var u=s.value;this.getScoreFollowingEntries(u,t)}}catch(l){a.e(l)}finally{a.f()}}return t}},{key:"currentPlaybackSettings",value:function(){return this.musicSheet.SheetPlaybackSetting}},{key:"moveToNext",value:function(){this.forwardJumpOccurred=this.backJumpOccurred=!1,this.endReached||(this.currentVoiceEntries&&(this.currentVoiceEntries.length=0),this.recursiveMove(),this.currentMeasure||(this.currentTimeStamp=new f(99999,1)),void 0!==this.CurrentTempoChangingExpression&&(void 0!==this.CurrentTempoChangingExpression.ContinuousTempo?this.currentBpm=this.CurrentTempoChangingExpression.ContinuousTempo.getInterpolatedTempo(this.CurrentSourceTimestamp):this.currentBpm=this.CurrentTempoChangingExpression.InstantaneousTempo.TempoInBpm))}},{key:"moveToNextVisibleVoiceEntry",value:function(e){for(;!this.endReached;)if(this.moveToNext(),this.checkEntries(e))return}},{key:"resetRepetitionIterationCount",value:function(e){return 1}},{key:"incrementRepetitionIterationCount",value:function(e){return-1===this.repetitionIterationCountDictKeys.indexOf(e)?this.setRepetitionIterationCount(e,1):this.setRepetitionIterationCount(e,this.getRepetitionIterationCount(e)+1)}},{key:"setRepetitionIterationCount",value:function(e,t){var i=this.repetitionIterationCountDictKeys.indexOf(e);return-1===i?(this.repetitionIterationCountDictKeys.push(e),this.repetitionIterationCountDictValues.push(t)):this.repetitionIterationCountDictValues[i]=t,t}},{key:"getRepetitionIterationCount",value:function(e){var t=this.repetitionIterationCountDictKeys.indexOf(e);if(-1!==t)return this.repetitionIterationCountDictValues[t]}},{key:"handleRepetitionsAtMeasureBegin",value:function(){for(var e=0,t=this.currentMeasure.FirstRepetitionInstructions.length;e=this.JumpResponsibleRepetition.StartIndex&&n.EndIndex<=this.JumpResponsibleRepetition.EndIndex&&this.resetRepetitionIterationCount(n)}}}},{key:"handleRepetitionsAtMeasureEnd",value:function(){for(var e=0,t=this.currentMeasure.LastRepetitionInstructions.length;e-1&&this.getRepetitionIterationCount(n)=this.JumpResponsibleRepetition.StartIndex&&n.EndIndex<=this.JumpResponsibleRepetition.EndIndex&&this.resetRepetitionIterationCount(n),this.repetitionIterationCountDictKeys.contains(n))){var r=n.getForwardJumpTargetForIteration(this.getRepetitionIterationCount(n));if(r>=0)return this.currentMeasureIndex=r,this.currentMeasure=this.musicSheet.SourceMeasures[this.currentMeasureIndex],this.currentVoiceEntryIndex=-1,this.jumpResponsibleRepetition=n,void(this.forwardJumpOccurred=!0);-2===r&&(this.endReached=!0)}}}this.currentMeasureIndex++,void 0!==this.JumpResponsibleRepetition&&this.currentMeasureIndex>this.JumpResponsibleRepetition.EndIndex&&(this.jumpResponsibleRepetition=void 0)}},{key:"doBackJump",value:function(e){this.currentMeasureIndex=e.getBackwardJumpTarget(),this.currentMeasure=this.musicSheet.SourceMeasures[this.currentMeasureIndex],this.currentVoiceEntryIndex=-1,this.incrementRepetitionIterationCount(e),this.jumpResponsibleRepetition=e,this.backJumpOccurred=!0}},{key:"activateCurrentRhythmInstructions",value:function(){if(void 0!==this.currentMeasure&&this.currentMeasure.FirstInstructionsStaffEntries.length>0&&void 0!==this.currentMeasure.FirstInstructionsStaffEntries[0])for(var e=this.currentMeasure.FirstInstructionsStaffEntries[0].Instructions,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>=u.length||u[this.currentTempoEntryIndex].AbsoluteTimestamp.gte(this.CurrentSourceTimestamp));)this.currentTempoEntryIndex--;for(;this.currentTempoEntryIndex=0&&this.currentVoiceEntryIndex=0&&this.currentMeasureIndex0){if(!e)return!0;for(var i=0,n=t.length;it&&(this.openSheetMusicDisplay.Sheet.SelectionStart=this.openSheetMusicDisplay.Sheet.SourceMeasures[t].AbsoluteTimestamp),this.openSheetMusicDisplay.Sheet&&this.openSheetMusicDisplay.Sheet.SourceMeasures.length>i){var n=this.openSheetMusicDisplay.Sheet.SourceMeasures[i];this.openSheetMusicDisplay.Sheet.SelectionEnd=f.plus(n.AbsoluteTimestamp,n.Duration)}this.iterator=this.manager.getIterator()}else console.log("OSMD.Cursor.resetIterator(): sheet or measures were null/undefined.")}},{key:"getStaffEntryFromVoiceEntry",value:function(e){var t=e.ParentSourceStaffEntry.VerticalContainerParent.ParentMeasure.measureListIndex,i=e.ParentSourceStaffEntry.ParentStaff.idInMusicSheet;return this.graphic.findGraphicalStaffEntryFromMeasureList(i,t,e.ParentSourceStaffEntry)}},{key:"updateWithTimestamp",value:function(e){var t=this.manager.absoluteEnrolledToSheetTimestamp(e),i=this.graphic.calculateXPositionFromTimestamp(t),n=i[0],r=i[1];this.updateCurrentPageFromSystem(r);var s=i[2];if(s){var a,u,l=Math.max(s.parentMeasure.MeasureNumber,1),h=o(this.graphic.MeasureList[l-1]);try{for(h.s();!(u=h.n()).done;){var c=u.value;if(c){a=c;break}}}catch(m){h.e(m)}finally{h.f()}var f=this.graphic.calculateCursorPoints(n,r),d=f[0].y,p=f[1].y-d;if(a){if(this.updateWidthAndStyle(a.PositionAndShape,n,d,p),this.openSheetMusicDisplay.FollowCursor){var v=this.cursorElement.getBoundingClientRect().top;this.cursorElement.scrollIntoView({behavior:v<1e3?"smooth":"auto",block:"center"})}this.cursorElement.style.display=""}}}},{key:"update",value:function(){var e=this;if(!this.hidden&&void 0!==this.hidden&&null!==this.hidden){this.updateCurrentPage();var t=this.Iterator,i=t.CurrentVisibleVoiceEntries();if(!t.EndReached&&t.CurrentVoiceEntries&&0!==i.length){var n,r,s,a=0;if(t.CurrentMeasure.isReducedToMultiRest){var o=this.graphic.findGraphicalMeasure(t.CurrentMeasureIndex,0),u=o.parentSourceMeasure.multipleRestMeasures,l=t.CurrentMeasure.multipleRestMeasureNumber/(u+1),h=o.PositionAndShape.Size.width-o.beginInstructionsWidth;a=o.PositionAndShape.AbsolutePosition.x+o.beginInstructionsWidth+l*h,s=o.ParentMusicSystem}else{var c=i.map((function(t){return e.getStaffEntryFromVoiceEntry(t)})).sort((function(e,t){var i,n,r,s;return(null==e||null===(i=e.PositionAndShape)||void 0===i||null===(n=i.AbsolutePosition)||void 0===n?void 0:n.x)<=(null==t||null===(r=t.PositionAndShape)||void 0===r||null===(s=r.AbsolutePosition)||void 0===s?void 0:s.x)?-1:1}))[0];c&&(a=c.PositionAndShape.AbsolutePosition.x,s=c.parentMeasure.ParentMusicSystem)}if(s){n=s.PositionAndShape.AbsolutePosition.y+s.StaffLines[0].PositionAndShape.RelativePosition.y;var f=s.StaffLines[s.StaffLines.length-1];r=s.PositionAndShape.AbsolutePosition.y+f.PositionAndShape.RelativePosition.y+f.StaffHeight-n;var d=this.graphic.findGraphicalMeasure(t.CurrentMeasureIndex,0).PositionAndShape;if(this.updateWidthAndStyle(d,a,n,r),this.openSheetMusicDisplay.FollowCursor&&this.cursorOptions.follow)if(this.openSheetMusicDisplay.EngravingRules.RenderSingleHorizontalStaffline)this.cursorElement.scrollIntoView({behavior:"smooth",inline:"center"});else{var p=this.cursorElement.getBoundingClientRect().top;this.cursorElement.scrollIntoView({behavior:p<1e3?"smooth":"auto",block:"center"})}this.cursorElement.style.display=""}}}}},{key:"updateWidthAndStyle",value:function(e,t,i,n){var r=this.cursorElement,s=0,a=n;switch(this.cursorOptions.type){case 1:r.style.top=10*i*this.openSheetMusicDisplay.zoom+"px",r.style.left=10*(t-1.5)*this.openSheetMusicDisplay.zoom+"px",a=10*n*this.openSheetMusicDisplay.zoom,r.height=a,r.style.height=a+"px",s=5*this.openSheetMusicDisplay.zoom;break;case 2:r.style.top=10*(i-2.5)*this.openSheetMusicDisplay.zoom+"px",r.style.left=10*t*this.openSheetMusicDisplay.zoom+"px",a=15*this.openSheetMusicDisplay.zoom,r.height=a,r.style.height=a+"px",s=5*this.openSheetMusicDisplay.zoom;break;case 3:r.style.top=10*e.AbsolutePosition.y*this.openSheetMusicDisplay.zoom+"px",r.style.left=10*e.AbsolutePosition.x*this.openSheetMusicDisplay.zoom+"px",a=10*n*this.openSheetMusicDisplay.zoom,r.height=a,r.style.height=a+"px",s=10*e.Size.width*this.openSheetMusicDisplay.zoom;break;case 4:r.style.top=10*e.AbsolutePosition.y*this.openSheetMusicDisplay.zoom+"px",r.style.left=10*e.AbsolutePosition.x*this.openSheetMusicDisplay.zoom+"px",a=10*n*this.openSheetMusicDisplay.zoom,r.height=a,r.style.height=a+"px",s=10*(t-e.AbsolutePosition.x)*this.openSheetMusicDisplay.zoom;break;default:r.style.top=10*i*this.openSheetMusicDisplay.zoom+"px",r.style.left=10*(t-1.5)*this.openSheetMusicDisplay.zoom+"px",a=10*n*this.openSheetMusicDisplay.zoom,r.height=a,r.style.height=a+"px",s=30*this.openSheetMusicDisplay.zoom}s!==r.width&&(r.width=s,this.updateStyle(s,this.cursorOptions))}},{key:"hide",value:function(){this.cursorElement.style.display="none",this.hidden=!0}},{key:"next",value:function(){this.Iterator.moveToNextVisibleVoiceEntry(!1),this.update()}},{key:"reset",value:function(){this.resetIterator();var e=this.manager.getIterator(this.graphic.ParentMusicSheet.SelectionStart);this.updateWithTimestamp(e.CurrentEnrolledTimestamp)}},{key:"updateStyle",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;void 0!==t&&(this.cursorOptions=t);var i=document.createElement("canvas");i.width=this.cursorElement.width,i.height=1;var n=i.getContext("2d");n.globalAlpha=this.cursorOptions.alpha;var r=n.createLinearGradient(0,0,this.cursorElement.width,0);switch(this.cursorOptions.type){case 1:case 2:case 3:case 4:r.addColorStop(1,this.cursorOptions.color);break;default:r.addColorStop(0,"white"),r.addColorStop(.2,this.cursorOptions.color),r.addColorStop(.8,this.cursorOptions.color),r.addColorStop(1,"white")}n.fillStyle=r,n.fillRect(0,0,e,1),this.cursorElement.src=i.toDataURL("image/png")}},{key:"Iterator",get:function(){return this.iterator}},{key:"Hidden",get:function(){return this.hidden}},{key:"VoicesUnderCursor",value:function(e){return this.Iterator.CurrentVisibleVoiceEntries(e)}},{key:"NotesUnderCursor",value:function(e){var t=this.VoicesUnderCursor(e),i=[];return t.forEach((function(e){i.push.apply(i,e.Notes)})),i}},{key:"GNotesUnderCursor",value:function(e){var t=this,i=this.VoicesUnderCursor(e),n=[];return i.forEach((function(e){n.push.apply(n,a(e.Notes.map((function(e){return t.rules.GNote(e)}))))})),n}},{key:"updateCurrentPage",value:function(){var e,t=this.Iterator.currentTimeStamp,i=o(this.graphic.MusicPages);try{for(i.s();!(e=i.n()).done;){var n=e.value;if(n.MusicSystems.last().GetSystemsLastTimeStamp().gt(t)){var r=n.PageNumber;return r!==this.currentPageNumber&&(this.container.removeChild(this.cursorElement),this.container=document.getElementById(this.rules.DYContainerId+r),this.container.appendChild(this.cursorElement)),this.currentPageNumber=r}}}catch(s){i.e(s)}finally{i.f()}return 1}},{key:"updateCurrentPageFromSystem",value:function(e){if(null!=e&&e.Parent){var 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}}]),e}(),ft=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;k(this,e),this.x=0,this.y=0,this.x=t,this.y=i}return E(e,[{key:"ToString",value:function(){return"["+this.x+", "+this.y+"]"}}],[{key:"Empty",get:function(){return new e}},{key:"pointsAreEqual",value:function(e,t){return e.x===t.x&&e.y===t.y}}]),e}(),dt=E((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;k(this,e),this.width=t,this.height=i})),pt=function(){function e(t,i,n,r){k(this,e),this.x=0,this.y=0,this.width=0,this.height=0,this.x=t,this.y=i,this.width=n,this.height=r}return E(e,[{key:"Location",get:function(){return new ft(this.x,this.y)}},{key:"Size",get:function(){return new dt(this.width,this.height)}}],[{key:"createFromLocationAndSize",value:function(t,i){return new e(t.x,t.y,i.width,i.height)}}]),e}(),vt=function(e){c(i,e);var t=d(i);function i(){return k(this,i),t.apply(this,arguments)}return E(i,[{key:"PositionAndShape",get:function(){return this.boundingBox},set:function(e){this.boundingBox=e}}]),i}(function(){function e(){k(this,e)}return E(e,[{key:"isInstanceOfClass",value:function(e){for(var t=this.constructor.prototype;t;){if(e===t.constructor.name)return!0;t=t.__proto__}return!1}}]),e}()),mt=function(e){c(i,e);var t=d(i);function i(e){var n;k(this,i),(n=t.call(this)).parentStaffLine=e;var r=e.PositionAndShape;return n.boundingBox=new yt(v(n),r),n.boundingBox.BorderRight=6,n.boundingBox.BorderBottom=4.5,n.boundingBox.BorderLeft=-1.5,n.boundingBox.BorderTop=-1.5,n}return E(i)}(vt),gt=function(e){c(i,e);var t=d(i);function i(){return k(this,i),t.apply(this,arguments)}return E(i)}(vt),yt=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];k(this,e),this.isSymbol=!1,this.relativePositionHasBeenSet=!1,this.xBordersHaveBeenSet=!1,this.yBordersHaveBeenSet=!1,this.absolutePosition=new ft,this.relativePosition=new ft,this.size=new dt,this.marginSize=new dt,this.upperLeftCorner=new ft,this.upperLeftMarginCorner=new ft,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=i,this.dataObject=t,this.isSymbol=n,this.xBordersHaveBeenSet=!1,this.yBordersHaveBeenSet=!1,i&&(this.Parent=i)}return E(e,[{key:"RelativePositionHasBeenSet",get:function(){return this.relativePositionHasBeenSet}},{key:"XBordersHaveBeenSet",get:function(){return this.xBordersHaveBeenSet},set:function(e){this.xBordersHaveBeenSet=e}},{key:"YBordersHaveBeenSet",get:function(){return this.yBordersHaveBeenSet},set:function(e){this.yBordersHaveBeenSet=e}},{key:"AbsolutePosition",get:function(){return this.absolutePosition},set:function(e){this.absolutePosition=e}},{key:"RelativePosition",get:function(){return this.relativePosition},set:function(e){this.relativePosition=e,this.relativePositionHasBeenSet=!0}},{key:"Size",get:function(){return this.size},set:function(e){this.size=e}},{key:"MarginSize",get:function(){return this.marginSize}},{key:"UpperLeftCorner",get:function(){return this.upperLeftCorner}},{key:"UpperLeftMarginCorner",get:function(){return this.upperLeftMarginCorner}},{key:"BorderLeft",get:function(){return this.borderLeft},set:function(e){this.borderLeft=e,this.calculateRectangle()}},{key:"BorderRight",get:function(){return this.borderRight},set:function(e){this.borderRight=e,this.calculateRectangle()}},{key:"BorderTop",get:function(){return this.borderTop},set:function(e){this.borderTop=e,this.calculateRectangle()}},{key:"BorderBottom",get:function(){return this.borderBottom},set:function(e){this.borderBottom=e,this.calculateRectangle()}},{key:"BorderMarginLeft",get:function(){return this.borderMarginLeft>this.borderLeft?this.borderLeft:this.borderMarginLeft},set:function(e){this.borderMarginLeft=e,this.calculateMarginRectangle()}},{key:"BorderMarginRight",get:function(){return this.borderMarginRightthis.borderTop?this.borderTop:this.borderMarginTop},set:function(e){this.borderMarginTop=e,this.calculateMarginRectangle()}},{key:"BorderMarginBottom",get:function(){return this.borderMarginBottom-1&&this.parent.ChildElements.splice(s,1)}(this.parent=e,(null===(t=this.parent)||void 0===t||null===(i=t.ChildElements)||void 0===i?void 0:i.indexOf(this))>-1)?L.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)}},{key:"DataObject",get:function(){return this.dataObject}},{key:"Center",get:function(){return new ft(this.RelativePosition.x+(this.BorderMarginRight+this.BorderMarginLeft),this.RelativePosition.y+(this.BorderMarginBottom+this.BorderMarginTop))}},{key:"setAbsolutePositionFromParent",value:function(){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}},{key:"calculateAbsolutePosition",value:function(){this.absolutePosition.x=this.relativePosition.x,this.absolutePosition.y=this.relativePosition.y;for(var e=this.parent;e;)this.absolutePosition.x+=e.relativePosition.x,this.absolutePosition.y+=e.relativePosition.y,e=e.parent}},{key:"calculateAbsolutePositionsRecursiveWithoutTopelement",value:function(){this.absolutePosition.x=0,this.absolutePosition.y=0;for(var e=0,t=this.ChildElements.length;e.001;break;case bt.Up:case bt.Down:n=this.relativePosition.y,e.calculateMarginPositionAlongDirection(this,t),r=Math.abs(n-this.relativePosition.y)>.001;break;default:throw new T("direction")}}while(r)}},{key:"collisionDetection",value:function(e){var 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}},{key:"liesInsideBorders",value:function(e){var 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){var n=this.AbsolutePosition.y+this.borderTop<=e.absolutePosition.y+e.borderTop&&e.absolutePosition.y+e.borderTop<=this.AbsolutePosition.y+this.borderBottom,r=this.AbsolutePosition.y+this.borderTop<=e.absolutePosition.y+e.borderBottom&&e.absolutePosition.y+e.borderBottom<=this.AbsolutePosition.y+this.borderBottom;if(n&&r)return!0}return!1}},{key:"pointLiesInsideBorders",value:function(e){if(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))return!0;return!1}},{key:"marginCollisionDetection",value:function(e){var 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}},{key:"liesInsideMargins",value:function(e){var 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){var n=this.AbsolutePosition.y+this.borderMarginTop<=e.absolutePosition.y+e.borderMarginTop&&e.absolutePosition.y+e.borderMarginTop<=this.AbsolutePosition.y+this.borderMarginBottom,r=this.AbsolutePosition.y+this.borderMarginTop<=e.absolutePosition.y+e.borderMarginBottom&&e.absolutePosition.y+e.borderMarginBottom<=this.AbsolutePosition.y+this.borderMarginBottom;if(n&&r)return!0}return!1}},{key:"pointLiesInsideMargins",value:function(e){if(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))return!0;return!1}},{key:"computeNonOverlappingPosition",value:function(e,t,i){this.RelativePosition=new ft(i.x,i.y),this.setAbsolutePositionFromParent();var n=0,r=!1;do{switch(t){case bt.Left:case bt.Right:n=this.relativePosition.x,e.calculatePositionAlongDirection(this,t),r=Math.abs(n-this.relativePosition.x)>1e-4;break;case bt.Up:case bt.Down:n=this.relativePosition.y,e.calculatePositionAlongDirection(this,t),r=Math.abs(n-this.relativePosition.y)>1e-4;break;default:throw new T("direction")}}while(r)}},{key:"getClickedObjectOfType",value:function(e){var t=this.dataObject;if(this.pointLiesInsideBorders(e)&&t)return t;for(var i=0,n=this.childElements.length;i1&&void 0!==arguments[1])||arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:vt.name,r=[],s=o(this.childElements);try{for(s.s();!(t=s.n()).done;){var a=t.value;r=r.concat(a.getObjectsInRegion(e,i,n))}}catch(u){s.e(u)}finally{s.f()}return this.dataObject&&this.dataObject.isInstanceOfClass(n)&&(i?e.liesInsideBorders(this)&&r.push(this.dataObject):e.collisionDetection(this)&&r.push(this.dataObject)),r}},{key:"calculateRectangle",value:function(){this.upperLeftCorner=new ft(this.BorderLeft,this.BorderTop),this.size=new dt(this.BorderRight-this.BorderLeft,this.BorderBottom-this.BorderTop),this.boundingRectangle=pt.createFromLocationAndSize(this.upperLeftCorner,this.size)}},{key:"calculateMarginRectangle",value:function(){this.upperLeftMarginCorner=new ft(this.BorderMarginLeft,this.BorderMarginTop),this.marginSize=new dt(this.BorderMarginRight-this.BorderMarginLeft,this.BorderMarginBottom-this.BorderMarginTop),this.boundingMarginRectangle=pt.createFromLocationAndSize(this.upperLeftMarginCorner,this.marginSize)}},{key:"calculateMarginPositionAlongDirection",value:function(e,t){if(this!==e){if(this.isSymbol&&this.marginCollisionDetection(e)){var i=0;switch(t){case bt.Left:return i=this.absolutePosition.x+this.borderMarginLeft-(e.absolutePosition.x+e.borderMarginRight),e.relativePosition.x+=i,void(e.absolutePosition.x+=i);case bt.Right:return i=this.absolutePosition.x+this.borderMarginRight-(e.absolutePosition.x+e.borderMarginLeft),e.relativePosition.x+=i,void(e.absolutePosition.x+=i);case bt.Up:return i=this.absolutePosition.y+this.borderMarginTop-(e.absolutePosition.y+e.borderMarginBottom),e.relativePosition.y+=i,void(e.absolutePosition.y+=i);case bt.Down:return i=this.absolutePosition.y+this.borderMarginBottom-(e.absolutePosition.y+e.borderMarginTop),e.relativePosition.y+=i,void(e.absolutePosition.y+=i);default:throw new T("direction")}}for(var n=0,r=this.ChildElements.length;n3&&void 0!==arguments[3]?arguments[3]:void 0;k(this,e),this.accidental=2,this.fundamentalNote=t,this.octave=i,this.accidental=n,this.accidentalXml=r,this.halfTone=t+12*(i+e.octXmlDiff)+e.HalfTonesFromAccidental(n),this.frequency=e.calcFrequency(this),this.nextFrequency=e.calcFrequency(this,"next"),this.prevFrequency=e.calcFrequency(this,"prev")}return E(e,[{key:"AccidentalHalfTones",get:function(){return e.HalfTonesFromAccidental(this.accidental)}},{key:"Octave",get:function(){return this.octave}},{key:"FundamentalNote",get:function(){return this.fundamentalNote}},{key:"Accidental",get:function(){return this.accidental}},{key:"AccidentalXml",get:function(){return this.accidentalXml}},{key:"Frequency",get:function(){return this.frequency}},{key:"getHalfTone",value:function(){return this.halfTone}},{key:"getTransposedPitch",value:function(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}},{key:"DoEnharmonicChange",value:function(){switch(this.accidental){case 1:case 5:this.fundamentalNote=this.getPreviousFundamentalNote(this.fundamentalNote),this.accidental=e.AccidentalFromHalfTones(this.halfTone-(this.fundamentalNote+12*(this.octave+e.octXmlDiff)));break;case 0:case 4:this.fundamentalNote=this.getNextFundamentalNote(this.fundamentalNote),this.accidental=e.AccidentalFromHalfTones(this.halfTone-(this.fundamentalNote+12*(this.octave+e.octXmlDiff)));break;default:return}}},{key:"ToString",value:function(){var t=e.accidentalVexflow(this.accidental);return t||(t=""),"Key: "+e.getNoteEnumString(this.fundamentalNote)+t+", Note: "+this.fundamentalNote+", octave: "+this.octave.toString()}},{key:"OperatorEquals",value:function(e){var t=this;return!(!t||!e)&&(t.FundamentalNote===e.FundamentalNote&&t.Octave===e.Octave&&t.Accidental===e.Accidental)}},{key:"OperatorNotEqual",value:function(e){return!(this===e)}},{key:"OperatorFundamentalGreaterThan",value:function(e){var t=this;return t.Octave===e.Octave?t.FundamentalNote>e.FundamentalNote:t.Octave>e.Octave}},{key:"OperatorFundamentalLessThan",value:function(e){var t=this;return t.Octave===e.Octave?t.FundamentalNotee.pitchEnumValues.length-1?(i=e.pitchEnumValues[n+t-e.pitchEnumValues.length],r++):i=e.pitchEnumValues[n+t],new e(i,r,2)}},{key:"getLowerPitchByTransposeFactor",value:function(t){var i,n=e.pitchEnumValues.indexOf(this.fundamentalNote),r=this.octave;return n-t<0?(i=e.pitchEnumValues[e.pitchEnumValues.length+n-t],r--):i=e.pitchEnumValues[n-t],new e(i,r,2)}},{key:"getNextFundamentalNote",value:function(t){var i=e.pitchEnumValues.indexOf(t);return i=(i+1)%e.pitchEnumValues.length,e.pitchEnumValues[i]}},{key:"getPreviousFundamentalNote",value:function(t){var i=e.pitchEnumValues.indexOf(t);return i>0?e.pitchEnumValues[i-1]:e.pitchEnumValues[e.pitchEnumValues.length-1]}}],[{key:"getNoteEnumString",value:function(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""}}},{key:"lineShiftFromNoteEnum",value:function(t,i){if(0===i)return[t,0];var n=e.pitchEnumValues,r=n.indexOf(t),s=0,a=(r+i)%n.length;return r+i>n.length-1&&(s=1),a<0&&(a=n.length+a,s=-1),[n[a],s]}},{key:"CalculateTransposedHalfTone",value:function(t,i){var n=t.fundamentalNote+t.AccidentalHalfTones+i;return e.WrapAroundCheck(n,12)}},{key:"WrapAroundCheck",value:function(e,t){for(var i=0;e<0;)e+=t,i--;for(;e>=t;)e-=t,i++;return{overflow:i,halftone:e}}},{key:"calcFrequency",value:function(t,i){var n,r=0;if(t instanceof e){var s=t;r=s.octave-1,n=s.fundamentalNote-9+s.AccidentalHalfTones}else if("number"==typeof t){n=t-57}var a=window.DYSubjectId,o=0;for(var u in"COLEXIU"===window.DYEnvironment&&(Pt[12]=[120]),Pt){if(Object.prototype.hasOwnProperty.call(Pt,u))if(Pt[u].includes(a)){o=parseFloat(u);break}}var l=n+o;return"next"===i&&l++,"prev"===i&&l--,442*Math.pow(2,r)*Math.pow(2,l/12)}},{key:"calcFractionalKey",value:function(t){return Math.log(t/440)/Math.LN10*e.halftoneFactor+57}},{key:"fromFrequency",value:function(t){var i=e.calcFractionalKey(t)+.5,n=Math.floor(i/12)-e.octXmlDiff,r=Math.floor(i)%12,s=r,a=2;return-1===this.pitchEnumValues.indexOf(s)&&(s=r-1,a=0),new e(s,n,a)}},{key:"fromHalftone",value:function(t){var i=Math.floor(t/12)-e.octXmlDiff,n=t%12,r=n,s=2;return-1===this.pitchEnumValues.indexOf(r)&&(r=n-1,s=0),new e(r,i,s)}},{key:"ceiling",value:function(e){var t=e%=12;return-1===this.pitchEnumValues.indexOf(t)&&(t=e+1),t}},{key:"floor",value:function(e){var t=e%=12;return-1===this.pitchEnumValues.indexOf(t)&&(t=e-1),t}},{key:"HalfTonesFromAccidental",value:function(e){switch(e){case 2:return 0;case 0:return 1;case 1:return-1;case 3:return 0;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")}}},{key:"AccidentalFromHalfTones",value:function(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}}},{key:"accidentalVexflow",value:function(e){var 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}},{key:"OctaveXmlDifference",get:function(){return e.octXmlDiff}}]),e}();At.pitchEnumValues=[0,2,4,5,7,9,11],At.halftoneFactor=12/(Math.LN2/Math.LN10),At.octXmlDiff=3;var Rt=function(){function e(t,i){k(this,e),this.staffEntries=[],this.absoluteTimestamp=i,this.staffEntries=new Array(t)}return E(e,[{key:"Index",get:function(){return this.index},set:function(e){this.index=e}},{key:"AbsoluteTimestamp",get:function(){return this.absoluteTimestamp}},{key:"StaffEntries",get:function(){return this.staffEntries},set:function(e){this.staffEntries=e}},{key:"getFirstNonNullStaffEntry",value:function(){for(var e=0,t=this.staffEntries.length;en?1:0}}]),e}(),It=function(e){return 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}(It||{}),Nt=new Xe;Nt.setValue(0,"Thistle"),Nt.setValue(1,"Aqua"),Nt.setValue(2,"Azure"),Nt.setValue(3,"Bisque"),Nt.setValue(4,"CadetBlue"),Nt.setValue(5,"DarkBlue"),Nt.setValue(6,"DarkGoldenRod"),Nt.setValue(7,"BlanchedAlmond"),Nt.setValue(8,"Chartreuse"),Nt.setValue(9,"DarkGreen"),Nt.setValue(10,"DarkOrange"),Nt.setValue(11,"FireBrick"),Nt.setValue(12,"DarkSalmon"),Nt.setValue(13,"DarkSeaGreen"),Nt.setValue(14,"DarkOrchid"),Nt.setValue(15,"Aquamarine"),Nt.setValue(16,"DarkKhaki"),Nt.setValue(17,"ForestGreen"),Nt.setValue(18,"AliceBlue"),Nt.setValue(19,"DeepPink"),Nt.setValue(20,"Coral"),Nt.setValue(21,"DarkOliveGreen"),Nt.setValue(22,"Chocolate"),Nt.setValue(23,"DodgerBlue"),Nt.setValue(24,"Blue"),Nt.setValue(25,"Beige"),Nt.setValue(26,"Crimson"),Nt.setValue(27,"Fuchsia"),Nt.setValue(28,"Brown"),Nt.setValue(29,"BlanchedAlmond"),Nt.setValue(30,"CornflowerBlue"),Nt.setValue(31,"Cornsilk"),Nt.setValue(32,"DarkGrey");var Bt=function(e){return 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}(Bt||{}),Dt=function(e){return 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}(Dt||{}),Ot=function(e){return 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}(Ot||{}),Ft=function(){function e(t,i){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:It.BaseWritingColor,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:void 0;k(this,e),this.start=t,this.end=i,this.width=n,this.styleId=r,this.colorHex=s}return E(e,[{key:"Start",get:function(){return this.start},set:function(e){this.start=e}},{key:"End",get:function(){return this.end},set:function(e){this.end=e}},{key:"Width",get:function(){return this.width},set:function(e){this.width=e}}]),e}(),Vt=function(e){c(i,e);var t=d(i);function i(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Gt.G,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2;return k(this,i),(e=t.call(this,void 0)).clefType=Gt.G,e.line=2,e.octaveOffset=0,e.line=s,e.clefType=n,e.octaveOffset=r,e.calcParameters(),e}return E(i,[{key:"ClefType",get:function(){return this.clefType},set:function(e){this.clefType=e}},{key:"Line",get:function(){return this.line},set:function(e){this.line=e}},{key:"OctaveOffset",get:function(){return this.octaveOffset},set:function(e){this.octaveOffset=e}},{key:"ClefPitch",get:function(){return this.clefPitch},set:function(e){this.clefPitch=e}},{key:"ReferenceCyPosition",get:function(){return this.referenceCyPosition},set:function(e){this.referenceCyPosition=e}},{key:"Equals",value:function(e){return this===e||!(!this||!e)&&(this.clefPitch===e.clefPitch&&this.Line===e.Line)}},{key:"NotEqual",value:function(e){return!this.Equals(e)}},{key:"ToString",value:function(){return"ClefType: "+this.clefType}},{key:"calcParameters",value:function(){switch(this.clefType){case Gt.G:this.clefPitch=new At(Lt.G,1+this.octaveOffset,Ct.NONE),this.referenceCyPosition=5-this.line+2;break;case Gt.F:this.clefPitch=new At(Lt.F,0+this.octaveOffset,Ct.NONE),this.referenceCyPosition=5-this.line+1.5;break;case Gt.C:this.clefPitch=new At(Lt.C,1+this.octaveOffset,Ct.NONE),this.referenceCyPosition=5-this.line;break;case Gt.percussion:this.clefPitch=new At(Lt.C,2,Ct.NONE),this.referenceCyPosition=2;break;case Gt.TAB:this.clefPitch=new At(Lt.G,0,Ct.NONE),this.referenceCyPosition=0;break;default:throw new T("clefType")}}}],[{key:"getDefaultClefFromMidiInstrument",value:function(e){switch(e){case Wt.Acoustic_Grand_Piano:case Wt.Electric_Bass_finger:case Wt.Electric_Bass_pick:case Wt.Fretless_Bass:case Wt.Slap_Bass_1:case Wt.Slap_Bass_2:case Wt.Synth_Bass_1:case Wt.Synth_Bass_2:case Wt.Contrabass:return new i(Gt.F,0,4);default:return new i(Gt.G,0,2)}}},{key:"getAllPossibleClefs",value:function(){for(var e=[],t=0;t<=2;t++){var n=new i(Gt.G,t,2);e.push(n)}for(var r=-2;r<=0;r++){var s=new i(Gt.F,r,4);e.push(s)}return e}},{key:"isSupportedClef",value:function(e){switch(e){case Gt.G:case Gt.F:case Gt.C:case Gt.percussion:case Gt.TAB:return!0;default:return!1}}}]),i}(ot),Gt=function(e){return 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}(Gt||{}),Wt=function(e){return 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.euphonium=128]="euphonium",e[e.AltoClarinetInEb=200]="AltoClarinetInEb",e[e.TrumpetInBb=201]="TrumpetInBb",e[e.BaritoneSaxophone=202]="BaritoneSaxophone",e[e.TenorSaxophone=203]="TenorSaxophone",e[e.ClarinetInEb=204]="ClarinetInEb",e[e.Euphonium=205]="Euphonium",e[e.Alto_Clarinet=206]="Alto_Clarinet",e[e.Bass_Clarinet=207]="Bass_Clarinet",e[e.Bass_Trombone=208]="Bass_Trombone",e[e.clarinet_in_bb=209]="clarinet_in_bb",e[e.clarinet_in_eb=210]="clarinet_in_eb",e[e.Percussion=135]="Percussion",e}(Wt||{}),Ut=function(e){c(i,e);var t=d(i);function i(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:zt.major;return k(this,i),(e=t.call(this,n)).isTransposedBy=0,e.Key=r,e.keyTypeOriginal=r,e.mode=s,e.alteratedNotes=e.calcAlteratedNotes(),e}return E(i,[{key:"Key",get:function(){return this.keyType},set:function(e){this.keyType=e,this.alteratedNotes=this.calcAlteratedNotes()}},{key:"Mode",get:function(){return this.mode},set:function(e){this.mode=e}},{key:"AlteratedNotes",get:function(){return this.alteratedNotes}},{key:"calcAlteratedNotes",value:function(){var e=[];if(this.keyType>0)for(var t=0;t=0}},{key:"getAlterationForPitch",value:function(e){return this.keyType>0&&this.alteratedNotes.indexOf(e.FundamentalNote)<=this.keyType?Ct.SHARP:this.keyType<0&&this.alteratedNotes.indexOf(e.FundamentalNote)<=Math.abs(this.keyType)?Ct.FLAT:Ct.NONE}},{key:"ToString",value:function(){return"Key: "+this.keyType+this.mode}},{key:"OperatorEquals",value:function(e){var t=this;return t===e||!(!t||!e)&&(t.Key===e.Key&&t.Mode===e.Mode)}},{key:"OperatorNotEqual",value:function(e){return!this.OperatorEquals(e)}}],[{key:"copy",value:function(e){var t=new i(e.parent,e.Key,e.Mode);return t.keyTypeOriginal=e.keyTypeOriginal,t}},{key:"getAllPossibleMajorKeyInstructions",value:function(){for(var e=[],t=-7;t<7;t++){var n=new i(void 0,t,zt.major);e.push(n)}return e}}]),i}(ot);Ut.sharpPositionList=[Lt.F,Lt.C,Lt.G,Lt.D,Lt.A,Lt.E,Lt.B],Ut.flatPositionList=[Lt.B,Lt.E,Lt.A,Lt.D,Lt.G,Lt.C,Lt.F];var zt=function(e){return 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}(zt||{});Array.prototype.last||Object.defineProperty(Array.prototype,"last",{enumerable:!1,value:function(){return this[this.length-1]}}),Array.prototype.clear||Object.defineProperty(Array.prototype,"clear",{enumerable:!1,value:function(){this.length=0}}),Array.prototype.contains||Object.defineProperty(Array.prototype,"contains",{enumerable:!1,value:function(e){return-1!==this.indexOf(e)}});var Ht=function(){function e(){k(this,e)}return E(e,null,[{key:"contains2",value:function(e,t){for(var i=0;i3&&void 0!==arguments[3]?arguments[3]:0,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.length-1,s=1;n<=r;){var a=i(e[s=Math.floor((n+r)/2)],t);if(0===a)return s;a<0&&(n=s+1),0=0;i--){var n=this.measureList[i][t];if(n)return n}}},{key:"findGraphicalStaffEntryFromMeasureList",value:function(e,t,i){for(var n=t;n0)return s.staffEntries[0]}}},{key:"getFirstVisibleMeasuresListFromIndices",value:function(e,t){for(var i=[],n=this.measureList[0].length,r=e;r<=t;r++)for(var s=0;s=0;i--){if(this.verticalGraphicalStaffEntryContainers[i].AbsoluteTimestamp.lt(e)){var n=new Rt(this.numberOfStaves,e);return this.verticalGraphicalStaffEntryContainers.splice(i+1,0,n),n}if(this.verticalGraphicalStaffEntryContainers[i].AbsoluteTimestamp.Equals(e))return this.verticalGraphicalStaffEntryContainers[i]}}},{key:"GetVerticalContainerFromTimestamp",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=Ht.binarySearch(this.verticalGraphicalStaffEntryContainers,new Rt(0,e),Rt.compareByTimestamp,t);if(i>=0)return this.verticalGraphicalStaffEntryContainers[i]}},{key:"GetInterpolatedIndexInVerticalContainers",value:function(e){var t=this.verticalGraphicalStaffEntryContainers,i=0,n=t.length-1,r=void 0,s=void 0;if(e.lte(t[t.length-1].AbsoluteTimestamp)){for(;n-i>1;){var a=Math.floor((n+i)/2);if(t[i].AbsoluteTimestamp.Equals(e)){n=i;break}if(t[n].AbsoluteTimestamp.Equals(e)){i=n;break}if(t[a].AbsoluteTimestamp.Equals(e))return this.verticalGraphicalStaffEntryContainers.indexOf(t[a]);e.lt(t[a].AbsoluteTimestamp)?n=a:i=a}if(i===n)return this.verticalGraphicalStaffEntryContainers.indexOf(t[i]);r=t[i].AbsoluteTimestamp,s=t[n].AbsoluteTimestamp}else r=t[t.length-1].AbsoluteTimestamp,s=f.plus(this.getLongestStaffEntryDuration(t.length-1),r),n=t.length;var o=s.RealValue-r.RealValue,u=n-(s.RealValue-e.RealValue)/o;return Math.min(u,this.verticalGraphicalStaffEntryContainers.length)}},{key:"getVisibleStavesIndicesFromSourceMeasure",value:function(e){for(var t=[],i=[],n=0,r=e.length;n1&&void 0!==arguments[1])||arguments[1],i=this.measureList.length-1;return t&&(i=Math.min(i,this.musicSheet.Rules.MaxMeasureToDrawIndex)),this.measureList[i][e]}},{key:"getMeasureIndex",value:function(e,t,i){for(t=0;t1&&void 0!==arguments[1]?arguments[1]:vt.name,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:20,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:5,s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:void 0,a=[];0===a.length&&i<=n;){var o=new yt(void 0);o.BorderLeft=e.x-i,o.BorderTop=e.y-i,o.BorderRight=e.x+i,o.BorderBottom=e.y+i,o.AbsolutePosition=new ft(e.x,e.y),o.calculateAbsolutePosition();for(var u=0,l=this.MusicPages.length;us.PositionAndShape.RelativePosition.x&&(i=s):i=s)}}catch(a){L.info("GraphicalMusicSheet.getStaffEntry",a)}return i}},{key:"GetPreviousVisibleContainerIndex",value:function(e){for(var t=e-1;t>=0;t--)for(var i=this.verticalGraphicalStaffEntryContainers[t].StaffEntries,n=0,r=i.length;n=0;r--)if(i=this.getStaffEntry(r)){if(!t)return i;if(i.sourceStaffEntry.ParentStaff.ParentInstrument.Visible)return i}}},{key:"findClosestRightStaffEntry",value:function(e,t){for(var i=void 0,n=Math.max(0,Math.ceil(e));n=t/2?parseInt(e/t,10)*t+t:parseInt(e/t,10)*t},Kt.MidLine=function(e,t){var i=t+(e-t)/2;return i%2>0&&(i=Kt.RoundN(10*i,5)/10),i},Kt.SortAndUnique=function(e,t,i){if(e.length>1){var n,r=[];e.sort(t);for(var s=0;s3&&void 0!==arguments[3]?arguments[3]:"#55";e.save(),e.setFillStyle(n),e.beginPath(),e.arc(t,i,3,0,2*Math.PI,!0),e.closePath(),e.fill(),e.restore()},Kt.BM=function(e,t){var i=(new Date).getTime();t();var n=(new Date).getTime()-i;Kt.L(e+n+"ms")},Kt.StackTrace=function(){return(new Error).stack},Kt.W=function(){for(var e=arguments.length,t=new Array(e),i=0;i0}},{key:"greaterThanEquals",value:function(t){var i=e.__compareB.copy(this);return i.subtract(t),i.numerator>=0}},{key:"lessThan",value:function(e){return!this.greaterThanEquals(e)}},{key:"lessThanEquals",value:function(e){return!this.greaterThan(e)}},{key:"clone",value:function(){return new e(this.numerator,this.denominator)}},{key:"copy",value:function(e){return"number"==typeof e?this.set(e||0,1):this.set(e.numerator,e.denominator)}},{key:"quotient",value:function(){return Math.floor(this.numerator/this.denominator)}},{key:"fraction",value:function(){return this.numerator%this.denominator}},{key:"abs",value:function(){return this.denominator=Math.abs(this.denominator),this.numerator=Math.abs(this.numerator),this}},{key:"toString",value:function(){return this.numerator+"/"+this.denominator}},{key:"toSimplifiedString",value:function(){return e.__tmp.copy(this).simplify().toString()}},{key:"toMixedString",value:function(){var t="",i=this.quotient(),n=e.__tmp.copy(this);return i<0?n.abs().fraction():n.fraction(),0!==i?(t+=i,0!==n.numerator&&(t+=" "+n.toSimplifiedString())):t=0===n.numerator?"0":n.toSimplifiedString(),t}},{key:"parse",value:function(e){var t=e.split("/"),i=parseInt(t[0],10),n=t[1]?parseInt(t[1],10):1;return this.set(i,n)}}],[{key:"GCD",value:function(e,t){if("number"!=typeof e||"number"!=typeof t)throw new Kt.RERR("BadArgument","Invalid numbers: ".concat(e,", ").concat(t));for(var i;0!==t;)i=t,t=e%t,e=i;return e}},{key:"LCM",value:function(t,i){return t*i/e.GCD(t,i)}},{key:"LCMM",value:function(t){if(0===t.length)return 0;if(1===t.length)return t[0];if(2===t.length)return e.LCM(t[0],t[1]);var i=t[0];return t.shift(),e.LCM(i,e.LCMM(t))}}]),e}();Jt.__compareA=new Jt,Jt.__compareB=new Jt,Jt.__tmp=new Jt;var Zt=Kt.MakeException("RegistryError");function $t(e,t,i,n,r){e[t][i]||(e[t][i]={}),e[t][i][n]=r}var Qt=function(){function e(){k(this,e),this.clear()}return E(e,[{key:"clear",value:function(){return this.index={id:{},type:{},class:{}},this}},{key:"updateIndex",value:function(e){var t=e.id,i=e.name,n=e.value,r=e.oldValue,s=this.getElementById(t);null!==r&&this.index[i][r]&&delete this.index[i][r][t],null!==n&&$t(this.index,i,n,s.getAttribute("id"),s)}},{key:"register",value:function(t,i){var n=this;if(!(i=i||t.getAttribute("id")))throw new Zt("Can't add element without `id` attribute to registry",t);return t.setAttribute("id",i),$t(this.index,"id",i,i,t),e.INDEXES.forEach((function(e){n.updateIndex({id:i,name:e,value:t.getAttribute(e),oldValue:null})})),t.onRegister(this),this}},{key:"getElementById",value:function(e){return this.index.id[e]?this.index.id[e][e]:null}},{key:"getElementsByAttribute",value:function(e,t){var i=this.index[e];return i&&i[t]?Object.keys(i[t]).map((function(e){return i[t][e]})):[]}},{key:"getElementsByType",value:function(e){return this.getElementsByAttribute("type",e)}},{key:"getElementsByClass",value:function(e){return this.getElementsByAttribute("class",e)}},{key:"onUpdate",value:function(t){var i=t.id,n=t.name,r=t.value,s=t.oldValue;return function(e,t){return e.filter((function(e){return e===t})).length>0}(e.INDEXES.concat(["id","class"]),n)?(this.updateIndex({id:i,name:n,value:r,oldValue:s}),this):this}}],[{key:"INDEXES",get:function(){return["type"]}},{key:"enableDefaultRegistry",value:function(t){e.defaultRegistry=t}},{key:"getDefaultRegistry",value:function(){return e.defaultRegistry}},{key:"disableDefaultRegistry",value:function(){e.defaultRegistry=null}}]),e}();Qt.defaultRegistry=null;var ei=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=t.type;k(this,e),this.attrs={id:e.newID(),el:null,type:i||"Base",classes:{}},this.boundingBox=null,this.context=null,this.rendered=!1,Qt.getDefaultRegistry()&&Qt.getDefaultRegistry().register(this)}return E(e,[{key:"setStyle",value:function(e){return this.style=e,this}},{key:"getStyle",value:function(){return this.style}},{key:"applyStyle",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.context,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.getStyle();return t?(e.save(),t.shadowColor&&e.setShadowColor(t.shadowColor),t.shadowBlur&&e.setShadowBlur(t.shadowBlur),t.fillStyle&&e.setFillStyle(t.fillStyle),t.strokeStyle&&e.setStrokeStyle(t.strokeStyle),t.lineWidth&&e.setLineWidth(t.lineWidth),this):this}},{key:"restoreStyle",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.context,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.getStyle();return t?(e.restore(),this):this}},{key:"drawWithStyle",value:function(){this.checkContext(),this.applyStyle(),this.draw(),this.restoreStyle()}},{key:"hasClass",value:function(e){return!0===this.attrs.classes[e]}},{key:"addClass",value:function(e){return this.attrs.classes[e]=!0,this.registry&&this.registry.onUpdate({id:this.getAttribute("id"),name:"class",value:e,oldValue:null}),this}},{key:"removeClass",value:function(e){return delete this.attrs.classes[e],this.registry&&this.registry.onUpdate({id:this.getAttribute("id"),name:"class",value:null,oldValue:e}),this}},{key:"onRegister",value:function(e){return this.registry=e,this}},{key:"isRendered",value:function(){return this.rendered}},{key:"setRendered",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.rendered=e,this}},{key:"getAttributes",value:function(){return this.attrs}},{key:"getAttribute",value:function(e){return this.attrs[e]}},{key:"setAttribute",value:function(e,t){var i=this.attrs.id,n=this.attrs[e];return this.attrs[e]=t,this.registry&&this.registry.onUpdate({id:i,name:e,value:t,oldValue:n}),this}},{key:"getContext",value:function(){return this.context}},{key:"setContext",value:function(e){return this.context=e,this}},{key:"getBoundingBox",value:function(){return this.boundingBox}},{key:"checkContext",value:function(){if(!this.context)throw new Kt.RERR("NoContext","No rendering context attached to instance");return this.context}}],[{key:"newID",value:function(){return"auto"+e.ID++}}]),e}();ei.ID=1e3;var ti=function(){function e(t,i,n,r){k(this,e),this.x1=Number.NaN,this.y1=Number.NaN,this.x2=Number.NaN,this.y2=Number.NaN,this.addPoint(t,i),this.addPoint(n,r)}return E(e,[{key:"width",value:function(){return this.x2-this.x1}},{key:"height",value:function(){return this.y2-this.y1}},{key:"addPoint",value:function(e,t){null!=e&&((isNaN(this.x1)||isNaN(this.x2))&&(this.x1=e,this.x2=e),ethis.x2&&(this.x2=e)),null!=t&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=t,this.y2=t),tthis.y2&&(this.y2=t))}},{key:"addX",value:function(e){this.addPoint(e,null)}},{key:"addY",value:function(e){this.addPoint(null,e)}},{key:"addQuadraticCurve",value:function(e,t,i,n,r,s){var a=e+2/3*(i-e),o=t+2/3*(n-t),u=a+1/3*(r-e),l=o+1/3*(s-t);this.addBezierCurve(e,t,a,o,u,l,r,s)}},{key:"addBezierCurve",value:function(e,t,i,n,r,s,a,o){var u,l=[e,t],h=[i,n],c=[r,s],f=[a,o];this.addPoint(l[0],l[1]),this.addPoint(f[0],f[1]);var d=function(e,t){return Math.pow(1-e,3)*l[t]+3*Math.pow(1-e,2)*e*h[t]+3*(1-e)*Math.pow(e,2)*c[t]+Math.pow(e,3)*f[t]};for(u=0;u<=1;u++){var p=6*l[u]-12*h[u]+6*c[u],v=-3*l[u]+9*h[u]-9*c[u]+3*f[u],m=3*h[u]-3*l[u];if(0!==v){var g=Math.pow(p,2)-4*m*v;if(!(g<0)){var y=(-p+Math.sqrt(g))/(2*v);0=6&&2*l%2==0&&(c=-1);var f=void 0!==o.int_val?12*u+o.int_val:null,d=o.code,p=o.shift_right,v={};if(s.length>2&&s[2]){var m=s[2].toUpperCase();v=ai.keyProperties.customNoteHeads[m]||{}}return n({key:a,octave:u,line:l,int_value:f,accidental:o.accidental,code:d,stroke:c,shift_right:p,displaced:!1},v)},ai.keyProperties.note_values={C:{index:0,int_val:0,accidental:null},CN:{index:0,int_val:0,accidental:"n"},"C#":{index:0,int_val:1,accidental:"#"},"C##":{index:0,int_val:2,accidental:"##"},CB:{index:0,int_val:-1,accidental:"b"},CBB:{index:0,int_val:-2,accidental:"bb"},D:{index:1,int_val:2,accidental:null},DN:{index:1,int_val:2,accidental:"n"},"D#":{index:1,int_val:3,accidental:"#"},"D##":{index:1,int_val:4,accidental:"##"},DB:{index:1,int_val:1,accidental:"b"},DBB:{index:1,int_val:0,accidental:"bb"},E:{index:2,int_val:4,accidental:null},EN:{index:2,int_val:4,accidental:"n"},"E#":{index:2,int_val:5,accidental:"#"},"E##":{index:2,int_val:6,accidental:"##"},EB:{index:2,int_val:3,accidental:"b"},EBB:{index:2,int_val:2,accidental:"bb"},F:{index:3,int_val:5,accidental:null},FN:{index:3,int_val:5,accidental:"n"},"F#":{index:3,int_val:6,accidental:"#"},"F##":{index:3,int_val:7,accidental:"##"},FB:{index:3,int_val:4,accidental:"b"},FBB:{index:3,int_val:3,accidental:"bb"},G:{index:4,int_val:7,accidental:null},GN:{index:4,int_val:7,accidental:"n"},"G#":{index:4,int_val:8,accidental:"#"},"G##":{index:4,int_val:9,accidental:"##"},GB:{index:4,int_val:6,accidental:"b"},GBB:{index:4,int_val:5,accidental:"bb"},A:{index:5,int_val:9,accidental:null},AN:{index:5,int_val:9,accidental:"n"},"A#":{index:5,int_val:10,accidental:"#"},"A##":{index:5,int_val:11,accidental:"##"},AB:{index:5,int_val:8,accidental:"b"},ABB:{index:5,int_val:7,accidental:"bb"},B:{index:6,int_val:11,accidental:null},BN:{index:6,int_val:11,accidental:"n"},"B#":{index:6,int_val:12,accidental:"#"},"B##":{index:6,int_val:13,accidental:"##"},BB:{index:6,int_val:10,accidental:"b"},BBB:{index:6,int_val:9,accidental:"bb"},R:{index:6,int_val:9,rest:!0},X:{index:6,accidental:"",octave:4,code:"v3e",shift_right:5.5}},ai.keyProperties.customNoteHeads={D0:{code:"v27",shift_right:0,stem_up_x_offset:0,stem_down_x_offset:0,stem_up_y_offset:-1,stem_down_y_offset:0},D1:{code:"v2d",shift_right:-.5},D2:{code:"v22",shift_right:-.5},D3:{code:"v70",shift_right:-.5},T0:{code:"v49",shift_right:-2,stem_up_y_offset:-4,stem_down_y_offset:4},T1:{code:"v93",shift_right:.5,stem_up_y_offset:-4,stem_down_y_offset:4},T2:{code:"v40",shift_right:.5,stem_up_y_offset:-4,stem_down_y_offset:4},T3:{code:"v7d",shift_right:.5,stem_up_y_offset:-4,stem_down_y_offset:4},X0:{code:"v92",stem_up_x_offset:-2,stem_down_x_offset:0,stem_up_y_offset:4,stem_down_y_offset:4},X1:{code:"v95",shift_right:-.5,stem_up_y_offset:4,stem_down_y_offset:4},X2:{code:"v3e",shift_right:.5,stem_up_y_offset:4,stem_down_y_offset:4},X3:{code:"v3b",shift_right:0,stem_up_x_offset:-1.2,stem_down_x_offset:0,stem_up_y_offset:-1,stem_down_y_offset:2},S1:{code:"vd3",shift_right:0},S2:{code:"vd2",shift_right:0},R1:{code:"vd5",shift_right:0},R2:{code:"vd4",shift_right:0}},ai.integerToNote=function(e){if(void 0===e)throw new Kt.RERR("BadArguments","Undefined integer for integerToNote");if(e<-2)throw new Kt.RERR("BadArguments","integerToNote requires integer > -2: ".concat(e));var t=ai.integerToNote.table[e];if(!t)throw new Kt.RERR("BadArguments","Unknown note value for integer: ".concat(e));return t},ai.integerToNote.table={0:"C",1:"C#",2:"D",3:"D#",4:"E",5:"F",6:"F#",7:"G",8:"G#",9:"A",10:"A#",11:"B"},ai.tabToGlyph=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,i=null,n=0,r=0;if("X"===e.toString().toUpperCase()){var s=new si("v7f",ai.DEFAULT_TABLATURE_FONT_SCALE).getMetrics();i="v7f",n=s.width,r=-s.height/2}else n=ai.textWidth(e.toString());return{text:e,code:i,getWidth:function(){return n*t},shift_y:r}},ai.textWidth=function(e){return 7*e.toString().length},ai.articulationCodes=function(e){return ai.articulationCodes.articulations[e]},ai.articulationCodes.articulations={"a.":{code:"v23",between_lines:!0},av:{code:"v28",between_lines:!0},"a>":{code:"v42",between_lines:!0},"a-":{code:"v25",between_lines:!0},"a^":{code:"va",between_lines:!1},"a+":{code:"v8b",between_lines:!1},ao:{code:"v94",between_lines:!1},ah:{code:"vb9",between_lines:!1},"a@a":{code:"v43",between_lines:!1},"a@u":{code:"v5b",between_lines:!1},"a|":{code:"v75",between_lines:!1},am:{code:"v97",between_lines:!1},"a,":{code:"vb3",between_lines:!1}},ai.accidentalCodes=function(e){return ai.accidentalCodes.accidentals[e]},ai.accidentalCodes.accidentals={"#":{code:"v18",parenRightPaddingAdjustment:-1},"##":{code:"v7f",parenRightPaddingAdjustment:-1},b:{code:"v44",parenRightPaddingAdjustment:-2},bb:{code:"v26",parenRightPaddingAdjustment:-2},n:{code:"v4e",parenRightPaddingAdjustment:-1},"{":{code:"v9c",parenRightPaddingAdjustment:-1},"}":{code:"v84",parenRightPaddingAdjustment:-1},db:{code:"v9e",parenRightPaddingAdjustment:-1},d:{code:"vab",parenRightPaddingAdjustment:0},bbs:{code:"v90",parenRightPaddingAdjustment:-1},"++":{code:"v51",parenRightPaddingAdjustment:-1},"+":{code:"v78",parenRightPaddingAdjustment:-1},"+-":{code:"v8d",parenRightPaddingAdjustment:-1},"++-":{code:"v7a",parenRightPaddingAdjustment:-1},bs:{code:"vb7",parenRightPaddingAdjustment:-1},bss:{code:"v39",parenRightPaddingAdjustment:-1},o:{code:"vd0",parenRightPaddingAdjustment:-1},k:{code:"vd1",parenRightPaddingAdjustment:-1},ashs:{code:"vd6",parenRightPaddingAdjustment:-1},afhf:{code:"vd7",parenRightPaddingAdjustment:-1}},ai.accidentalColumnsTable={1:{a:[1],b:[1]},2:{a:[1,2]},3:{a:[1,3,2],b:[1,2,1],second_on_bottom:[1,2,3]},4:{a:[1,3,4,2],b:[1,2,3,1],spaced_out_tetrachord:[1,2,1,2]},5:{a:[1,3,5,4,2],b:[1,2,4,3,1],spaced_out_pentachord:[1,2,3,2,1],very_spaced_out_pentachord:[1,2,1,2,1]},6:{a:[1,3,5,6,4,2],b:[1,2,4,5,3,1],spaced_out_hexachord:[1,3,2,1,3,2],very_spaced_out_hexachord:[1,2,1,2,1,2]}},ai.ornamentCodes=function(e){return ai.ornamentCodes.ornaments[e]},ai.ornamentCodes.ornaments={mordent:{code:"v1e"},mordent_inverted:{code:"v45"},turn:{code:"v72"},turn_inverted:{code:"v33"},tr:{code:"v1f"},upprall:{code:"v60"},downprall:{code:"vb4"},prallup:{code:"v6d"},pralldown:{code:"v2c"},upmordent:{code:"v29"},downmordent:{code:"v68"},lineprall:{code:"v20"},prallprall:{code:"v86"}},ai.keySignature=function(e){var t=ai.keySignature.keySpecs[e];if(!t)throw new Kt.RERR("BadKeySignature","Bad key signature spec: '".concat(e,"'"));if(!t.acc)return[];for(var i=ai.keySignature.accidentalList(t.acc),n=[],r=0;r0&&void 0!==arguments[0]?arguments[0]:ai.DEFAULT_NOTATION_FONT_SCALE;return new si(this.code_head||"v53",e).getMetrics().width},stem:!1,stem_offset:0,flag:!1,stem_up_extension:-ai.STEM_HEIGHT,stem_down_extension:-ai.STEM_HEIGHT,tabnote_stem_up_extension:-ai.STEM_HEIGHT,tabnote_stem_down_extension:-ai.STEM_HEIGHT,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"v53"},h:{code_head:"v59"},m:{code_head:"vf",stem_offset:0},r:{code_head:"v31",rest:!0,position:"B/5",dot_shiftY:.5},s:{getWidth:function(){return ai.SLASH_NOTEHEAD_WIDTH},position:"B/4"}}},1:{common:{getWidth:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ai.DEFAULT_NOTATION_FONT_SCALE;return new si(this.code_head||"v1d",e).getMetrics().width},stem:!1,stem_offset:0,flag:!1,stem_up_extension:-ai.STEM_HEIGHT,stem_down_extension:-ai.STEM_HEIGHT,tabnote_stem_up_extension:-ai.STEM_HEIGHT,tabnote_stem_down_extension:-ai.STEM_HEIGHT,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"v1d"},h:{code_head:"v46"},m:{code_head:"v92",stem_offset:-3},r:{code_head:"v5c",rest:!0,position:"D/5",dot_shiftY:.5},s:{getWidth:function(){return ai.SLASH_NOTEHEAD_WIDTH},position:"B/4"}}},2:{common:{getWidth:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ai.DEFAULT_NOTATION_FONT_SCALE;return new si(this.code_head||"v81",e).getMetrics().width},stem:!0,stem_offset:0,flag:!1,stem_up_extension:0,stem_down_extension:0,tabnote_stem_up_extension:0,tabnote_stem_down_extension:0,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"v81"},h:{code_head:"v2d"},m:{code_head:"v95",stem_offset:-3},r:{code_head:"vc",stem:!1,rest:!0,position:"B/4",dot_shiftY:-.5},s:{getWidth:function(){return ai.SLASH_NOTEHEAD_WIDTH},position:"B/4"}}},4:{common:{getWidth:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ai.DEFAULT_NOTATION_FONT_SCALE;return new si(this.code_head||"vb",e).getMetrics().width},stem:!0,stem_offset:0,flag:!1,stem_up_extension:0,stem_down_extension:0,tabnote_stem_up_extension:0,tabnote_stem_down_extension:0,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"vb"},h:{code_head:"v22"},m:{code_head:"v3e",stem_offset:-3},r:{code_head:"v7c",stem:!1,rest:!0,position:"B/4",dot_shiftY:-.5,line_above:1.5,line_below:1.5},s:{getWidth:function(){return ai.SLASH_NOTEHEAD_WIDTH},position:"B/4"}}},8:{common:{getWidth:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ai.DEFAULT_NOTATION_FONT_SCALE;return new si(this.code_head||"vb",e).getMetrics().width},stem:!0,stem_offset:0,flag:!0,beam_count:1,code_flag_upstem:"v54",code_flag_downstem:"v9a",stem_up_extension:0,stem_down_extension:0,tabnote_stem_up_extension:0,tabnote_stem_down_extension:0,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"vb"},h:{code_head:"v22"},m:{code_head:"v3e"},r:{code_head:"va5",stem:!1,flag:!1,rest:!0,position:"B/4",dot_shiftY:-.5,line_above:1,line_below:1},s:{getWidth:function(){return ai.SLASH_NOTEHEAD_WIDTH},position:"B/4"}}},16:{common:{beam_count:2,getWidth:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ai.DEFAULT_NOTATION_FONT_SCALE;return new si(this.code_head||"vb",e).getMetrics().width},stem:!0,stem_offset:0,flag:!0,code_flag_upstem:"v3f",code_flag_downstem:"v8f",stem_up_extension:0,stem_down_extension:0,tabnote_stem_up_extension:0,tabnote_stem_down_extension:0,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"vb"},h:{code_head:"v22"},m:{code_head:"v3e"},r:{code_head:"v3c",stem:!1,flag:!1,rest:!0,position:"B/4",dot_shiftY:-.5,line_above:1,line_below:2},s:{getWidth:function(){return ai.SLASH_NOTEHEAD_WIDTH},position:"B/4"}}},32:{common:{beam_count:3,getWidth:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ai.DEFAULT_NOTATION_FONT_SCALE;return new si(this.code_head||"vb",e).getMetrics().width},stem:!0,stem_offset:0,flag:!0,code_flag_upstem:"v47",code_flag_downstem:"v2a",stem_up_extension:9,stem_down_extension:9,tabnote_stem_up_extension:8,tabnote_stem_down_extension:5,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"vb"},h:{code_head:"v22"},m:{code_head:"v3e"},r:{code_head:"v55",stem:!1,flag:!1,rest:!0,position:"B/4",dot_shiftY:-1.5,line_above:2,line_below:2},s:{getWidth:function(){return ai.SLASH_NOTEHEAD_WIDTH},position:"B/4"}}},64:{common:{beam_count:4,getWidth:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ai.DEFAULT_NOTATION_FONT_SCALE;return new si(this.code_head||"vb",e).getMetrics().width},stem:!0,stem_offset:0,flag:!0,code_flag_upstem:"va9",code_flag_downstem:"v58",stem_up_extension:13,stem_down_extension:13,tabnote_stem_up_extension:12,tabnote_stem_down_extension:9,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"vb"},h:{code_head:"v22"},m:{code_head:"v3e"},r:{code_head:"v38",stem:!1,flag:!1,rest:!0,position:"B/4",dot_shiftY:-1.5,line_above:2,line_below:3},s:{getWidth:function(){return ai.SLASH_NOTEHEAD_WIDTH},position:"B/4"}}},128:{common:{beam_count:5,getWidth:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ai.DEFAULT_NOTATION_FONT_SCALE;return new si(this.code_head||"vb",e).getMetrics().width},stem:!0,stem_offset:0,flag:!0,code_flag_upstem:"v9b",code_flag_downstem:"v30",stem_up_extension:22,stem_down_extension:22,tabnote_stem_up_extension:21,tabnote_stem_down_extension:18,dot_shiftY:0,line_above:0,line_below:0},type:{n:{code_head:"vb"},h:{code_head:"v22"},m:{code_head:"v3e"},r:{code_head:"vaa",stem:!1,flag:!1,rest:!0,position:"B/4",dot_shiftY:1.5,line_above:3,line_below:3},s:{getWidth:function(){return ai.SLASH_NOTEHEAD_WIDTH},position:"B/4"}}}},ai.smufl={},ai.smufl.to_code_points={bracketTop:"v1b",bracketBottom:"v10",barlineTick:"v6f",segno:"v8c",coda:"v4d",gClef:"v83",cClef:"vad",fClef:"v79",unpitchedPercussionClef1:"v59","6stringTabClef":"v2f",timeSig0:"v0",timeSig1:"v1",timeSig2:"v2",timeSig3:"v3",timeSig4:"v4",timeSig5:"v5",timeSig6:"v6",timeSig7:"v7",timeSig8:"v8",timeSig9:"v9",timeSigCommon:"v41",timeSigCutCommon:"vb6",noteheadDoubleWhole:"v53",noteheadWhole:"v1d",noteheadHalf:"v81",noteheadBlack:"vb",noteheadXWhole:"v92",noteheadXHalf:"v95",noteheadXBlack:"v3e",noteheadCircleX:"v3b",noteheadTriangleUpWhole:"v49",noteheadTriangleUpHalf:"v93",noteheadTriangleUpBlack:"v40",noteheadDiamondWhole:"v46",noteheadDiamondHalf:"v2d",noteheadDiamondBlack:"v22",augmentationDot:"v23",tremolo1:"v74",flag8thUp:"v54",flag8thDown:"v9a",flag16thUp:"v3f",flag16thDown:"v8f",flag32ndUp:"v47",flag32ndDown:"v2a",flag64thUp:"va9",flag64thDown:"v58",flag128thUp:"v9b",flag128thDown:"v30",accidentalFlat:"v44",accidentalNatural:"v4e",accidentalSharp:"v18",accidentalDoubleSharp:"v7f",accidentalDoubleFlat:"v26",accidentalParensLeft:"v9c",accidentalParensRight:"v84",accidentalQuarterToneFlatStein:"vab",accidentalThreeQuarterTonesFlatZimmermann:"v9e",accidentalQuarterToneSharpStein:"v78",accidentalThreeQuarterTonesSharpStein:"v51",accidentalBuyukMucennebFlat:"v39",accidentalBakiyeFlat:"vb7",accidentalKomaSharp:"v51",accidentalKucukMucennebSharp:"v8d",accidentalKoron:"vd1",accidentalSori:"vd0",articAccentAbove:"v42",articAccentBelow:"v42",articTenutoAbove:"v25",articTenutoBelow:"v25",articStaccatoAbove:"v23",articStaccatoBelow:"v23",articStaccatissimoAbove:"v28",articMarcatoAbove:"va",fermataAbove:"v43",fermataBelow:"v5b",breathMarkComma:"v6c",breathMarkUpbow:"v8a",caesura:"v34",caesuraCurved:"v4b",restMaxima:"v59",restDoubleWhole:"v31",restWhole:"v5c",restHalf:"vc",restQuarter:"v7c",rest8th:"va5",rest16th:"v3c",rest32nd:"v55",rest64th:"v38",rest128th:"vaa",dynamicPiano:"vbf",dynamicMezzo:"v62",dynamicForte:"vba",dynamicRinforzando:"vba",dynamicSforzando:"v4a",dynamicZ:"v80",ornamentTrill:"v1f",ornamentTurn:"v72",ornamentTurnSlash:"v33",ornamentMordent:"v45",ornamentMordentInverted:"v1e",ornamentTremblement:"v86",ornamentPrecompAppoggTrill:"v20",ornamentPrecompSlideTrillDAnglebert:"v60",ornamentPrecompSlideTrillBach:"v29",ornamentPrecompTrillSuffixDandrieu:"v6d",ornamentPrecompDoubleCadenceUpperPrefix:"vb4",ornamentPrecompDoubleCadenceUpperPrefixTurn:"v68",ornamentPrecompTrillLowerSuffix:"v2c",stringsDownBow:"v94",stringsUpBow:"v75",stringsHarmonic:"vb9",pluckedSnapPizzicatoAbove:"v94",pluckedLeftHandPizzicato:"v8b",keyboardPedalPed:"v36",keyboardPedalUp:"v5d",pictChokeCymbal:"vb3",wiggleArpeggiatoUp:"va3",arrowheadBlackUp:"vc3",arrowheadBlackDown:"v52"},ai.TIME4_4={num_beats:4,beat_value:4,resolution:ai.RESOLUTION};var oi=function(){function e(t){k(this,e),this.vexFlowCanvasContext=t,t.canvas?this.canvas=t.canvas:this.canvas={width:e.WIDTH,height:e.HEIGHT}}return E(e,[{key:"clear",value:function(){this.vexFlowCanvasContext.clearRect(0,0,this.canvas.width,this.canvas.height)}},{key:"openGroup",value:function(){}},{key:"closeGroup",value:function(){}},{key:"add",value:function(){}},{key:"setFont",value:function(e,t,i){return this.vexFlowCanvasContext.font=(i||"")+" "+t+"pt "+e,this}},{key:"setRawFont",value:function(e){return this.vexFlowCanvasContext.font=e,this}},{key:"setFillStyle",value:function(e){return this.vexFlowCanvasContext.fillStyle=e,this}},{key:"setBackgroundFillStyle",value:function(e){return this.background_fillStyle=e,this}},{key:"setStrokeStyle",value:function(e){return this.vexFlowCanvasContext.strokeStyle=e,this}},{key:"setShadowColor",value:function(e){return this.vexFlowCanvasContext.shadowColor=e,this}},{key:"setShadowBlur",value:function(e){return this.vexFlowCanvasContext.shadowBlur=e,this}},{key:"setLineWidth",value:function(e){return this.vexFlowCanvasContext.lineWidth=e,this}},{key:"setLineCap",value:function(e){return this.vexFlowCanvasContext.lineCap=e,this}},{key:"setLineDash",value:function(e){return this.vexFlowCanvasContext.lineDash=e,this}},{key:"scale",value:function(e,t){return this.vexFlowCanvasContext.scale(parseFloat(e),parseFloat(t))}},{key:"resize",value:function(e,i){var n=t(this.SanitizeCanvasDims(parseInt(e,10),parseInt(i,10)),2);return e=n[0],i=n[1],this.vexFlowCanvasContext.resize(e,i)}},{key:"rect",value:function(e,t,i,n){return this.vexFlowCanvasContext.rect(e,t,i,n)}},{key:"fillRect",value:function(e,t,i,n){return this.vexFlowCanvasContext.fillRect(e,t,i,n)}},{key:"clearRect",value:function(e,t,i,n){return this.vexFlowCanvasContext.clearRect(e,t,i,n)}},{key:"beginPath",value:function(){return this.vexFlowCanvasContext.beginPath()}},{key:"moveTo",value:function(e,t){return this.vexFlowCanvasContext.moveTo(e,t)}},{key:"lineTo",value:function(e,t){return this.vexFlowCanvasContext.lineTo(e,t)}},{key:"bezierCurveTo",value:function(e,t,i,n,r,s){return this.vexFlowCanvasContext.bezierCurveTo(e,t,i,n,r,s)}},{key:"quadraticCurveTo",value:function(e,t,i,n){return this.vexFlowCanvasContext.quadraticCurveTo(e,t,i,n)}},{key:"arc",value:function(e,t,i,n,r,s){return this.vexFlowCanvasContext.arc(e,t,i,n,r,s)}},{key:"glow",value:function(){return this.vexFlowCanvasContext.glow()}},{key:"fill",value:function(){return this.vexFlowCanvasContext.fill()}},{key:"stroke",value:function(){return this.vexFlowCanvasContext.stroke()}},{key:"closePath",value:function(){return this.vexFlowCanvasContext.closePath()}},{key:"measureText",value:function(e){return this.vexFlowCanvasContext.measureText(e)}},{key:"fillText",value:function(e,t,i){return this.vexFlowCanvasContext.fillText(e,t,i)}},{key:"save",value:function(){return this.vexFlowCanvasContext.save()}},{key:"restore",value:function(){return this.vexFlowCanvasContext.restore()}}],[{key:"WIDTH",get:function(){return 600}},{key:"HEIGHT",get:function(){return 400}},{key:"CANVAS_BROWSER_SIZE_LIMIT",get:function(){return 32767}},{key:"SanitizeCanvasDims",value:function(e,t){return Math.max(e,t)>this.CANVAS_BROWSER_SIZE_LIMIT&&(Kt.W("Canvas dimensions exceed browser limit. Cropping to "+this.CANVAS_BROWSER_SIZE_LIMIT),e>this.CANVAS_BROWSER_SIZE_LIMIT&&(e=this.CANVAS_BROWSER_SIZE_LIMIT),t>this.CANVAS_BROWSER_SIZE_LIMIT&&(t=this.CANVAS_BROWSER_SIZE_LIMIT)),[e,t]}}]),e}(),ui=function(){function e(t){k(this,e),this.element=t,this.paper=Raphael(t),this.path="",this.pen={x:0,y:0},this.lineWidth=1,this.state={scale:{x:1,y:1},font_family:"Arial",font_size:8,font_weight:800},this.attributes={"stroke-width":.3,fill:"black",stroke:"black",font:"10pt Arial"},this.background_attributes={"stroke-width":0,fill:"white",stroke:"white",font:"10pt Arial"},this.shadow_attributes={width:0,color:"black"},this.state_stack=[]}return E(e,[{key:"openGroup",value:function(){}},{key:"closeGroup",value:function(){}},{key:"add",value:function(){}},{key:"setFont",value:function(e,t,i){return this.state.font_family=e,this.state.font_size=t,this.state.font_weight=i,this.attributes.font=(this.state.font_weight||"")+" "+this.state.font_size*this.state.scale.x+"pt "+this.state.font_family,this}},{key:"setRawFont",value:function(e){return this.attributes.font=e,this}},{key:"setFillStyle",value:function(e){return this.attributes.fill=e,this}},{key:"setBackgroundFillStyle",value:function(e){return this.background_attributes.fill=e,this.background_attributes.stroke=e,this}},{key:"setStrokeStyle",value:function(e){return this.attributes.stroke=e,this}},{key:"setShadowColor",value:function(e){return this.shadow_attributes.color=e,this}},{key:"setShadowBlur",value:function(e){return this.shadow_attributes.width=e,this}},{key:"setLineWidth",value:function(e){this.attributes["stroke-width"]=e,this.lineWidth=e}},{key:"setLineDash",value:function(){return this}},{key:"setLineCap",value:function(){return this}},{key:"scale",value:function(e,t){return this.state.scale={x:e,y:t},this.attributes.transform="S"+e+","+t+",0,0",this.attributes.scale=e+","+t+",0,0",this.attributes.font=this.state.font_size*this.state.scale.x+"pt "+this.state.font_family,this.background_attributes.transform="S"+e+","+t+",0,0",this.background_attributes.font=this.state.font_size*this.state.scale.x+"pt "+this.state.font_family,this}},{key:"clear",value:function(){this.paper.clear()}},{key:"resize",value:function(e,t){return this.element.style.width=e,this.paper.setSize(e,t),this}},{key:"setViewBox",value:function(e){this.paper.canvas.setAttribute("viewBox",e)}},{key:"rect",value:function(e,t,i,n){return n<0&&(t+=n,n=-n),this.paper.rect(e,t,i-.5,n-.5).attr(this.attributes).attr("fill","none").attr("stroke-width",this.lineWidth),this}},{key:"fillRect",value:function(e,t,i,n){return n<0&&(t+=n,n=-n),this.paper.rect(e,t,i-.5,n-.5).attr(this.attributes),this}},{key:"clearRect",value:function(e,t,i,n){return n<0&&(t+=n,n=-n),this.paper.rect(e,t,i-.5,n-.5).attr(this.background_attributes),this}},{key:"beginPath",value:function(){return this.path="",this.pen.x=0,this.pen.y=0,this}},{key:"moveTo",value:function(e,t){return this.path+="M"+e+","+t,this.pen.x=e,this.pen.y=t,this}},{key:"lineTo",value:function(e,t){return this.path+="L"+e+","+t,this.pen.x=e,this.pen.y=t,this}},{key:"bezierCurveTo",value:function(e,t,i,n,r,s){return this.path+="C"+e+","+t+","+i+","+n+","+r+","+s,this.pen.x=r,this.pen.y=s,this}},{key:"quadraticCurveTo",value:function(e,t,i,n){return this.path+="Q"+e+","+t+","+i+","+n,this.pen.x=i,this.pen.y=n,this}},{key:"arc",value:function(e,t,i,n,r,s){function a(e){for(;e<0;)e+=2*Math.PI;for(;e>2*Math.PI;)e-=2*Math.PI;return e}if((n=a(n))>(r=a(r))){var o=n;n=r,r=o,s=!s}var u=r-n;return u>Math.PI?(this.arcHelper(e,t,i,n,n+u/2,s),this.arcHelper(e,t,i,n+u/2,r,s)):this.arcHelper(e,t,i,n,r,s),this}},{key:"arcHelper",value:function(e,t,i,n,r,s){var a=e+i*Math.cos(n),o=t+i*Math.sin(n),u=e+i*Math.cos(r),l=t+i*Math.sin(r),h=0,c=0;s?(c=1,r-nMath.PI&&(h=1),this.path+="M"+a+","+o+",A"+i+","+i+",0,"+h+","+c+","+u+","+l+"M"+this.pen.x+","+this.pen.y}},{key:"glow",value:function(){var e=this.paper.set();if(this.shadow_attributes.width>0)for(var t=this.shadow_attributes,i=t.width/2,n=1;n<=i;n++)e.push(this.paper.path(this.path).attr({stroke:t.color,"stroke-linejoin":"round","stroke-linecap":"round","stroke-width":+(t.width/i*n).toFixed(3),opacity:+((t.opacity||.3)/i).toFixed(3),transform:this.attributes.transform,scale:this.attributes.scale}));return e}},{key:"fill",value:function(){var e=this.paper.path(this.path).attr(this.attributes).attr("stroke-width",0);return this.glow(e),this}},{key:"stroke",value:function(){var e=this.lineWidth*(this.state.scale.x+this.state.scale.y)/2,t=this.paper.path(this.path).attr(this.attributes).attr("fill","none").attr("stroke-width",e);return this.glow(t),this}},{key:"closePath",value:function(){return this.path+="Z",this}},{key:"measureText",value:function(e){var t=this.paper.text(0,0,e).attr(this.attributes).attr("fill","none").attr("stroke","none"),i=t.getBBox();return t.remove(),{width:i.width,height:i.height}}},{key:"fillText",value:function(e,t,i){return this.paper.text(t+this.measureText(e).width/2,i-this.state.font_size/(2.25*this.state.scale.y),e).attr(this.attributes),this}},{key:"save",value:function(){return this.state_stack.push({state:{font_family:this.state.font_family},attributes:{font:this.attributes.font,fill:this.attributes.fill,stroke:this.attributes.stroke,"stroke-width":this.attributes["stroke-width"]},shadow_attributes:{width:this.shadow_attributes.width,color:this.shadow_attributes.color}}),this}},{key:"restore",value:function(){var e=this.state_stack.pop();return this.state.font_family=e.state.font_family,this.attributes.font=e.attributes.font,this.attributes.fill=e.attributes.fill,this.attributes.stroke=e.attributes.stroke,this.attributes["stroke-width"]=e.attributes["stroke-width"],this.shadow_attributes.width=e.shadow_attributes.width,this.shadow_attributes.color=e.shadow_attributes.color,this}}]),e}(),li={path:{x:!0,y:!0,width:!0,height:!0},rect:{},text:{width:!0,height:!0}},hi={"font-family":!0,"font-weight":!0,"font-style":!0,"font-size":!0};Kt.Merge(li.rect,hi),Kt.Merge(li.path,hi);var ci=function(){function e(t){k(this,e),this.element=t,this.svgNS="http://www.w3.org/2000/svg";var i=this.create("svg");this.element.appendChild(i),this.svg=i,this.groups=[this.svg],this.parent=this.svg,this.path="",this.pen={x:NaN,y:NaN},this.lineWidth=1,this.state={scale:{x:1,y:1},"font-family":"Arial","font-size":"8pt","font-weight":"normal"},this.attributes={"stroke-width":.3,fill:"black",stroke:"black","stroke-dasharray":"none","font-family":"Arial","font-size":"10pt","font-weight":"normal","font-style":"normal"},this.background_attributes={"stroke-width":0,fill:"white",stroke:"white","stroke-dasharray":"none","font-family":"Arial","font-size":"10pt","font-weight":"normal","font-style":"normal"},this.shadow_attributes={width:0,color:"black"},this.state_stack=[],this.iePolyfill()}return E(e,[{key:"create",value:function(e){return document.createElementNS(this.svgNS,e)}},{key:"openGroup",value:function(e,t,i){var n=this.create("g");return this.groups.push(n),this.parent.appendChild(n),this.parent=n,e&&n.setAttribute("class",Kt.Prefix(e)),t&&n.setAttribute("id",Kt.Prefix(t)),i&&i.pointerBBox&&n.setAttribute("pointer-events","bounding-box"),n}},{key:"closeGroup",value:function(){this.groups.pop(),this.parent=this.groups[this.groups.length-1]}},{key:"add",value:function(e){this.parent.appendChild(e)}},{key:"iePolyfill",value:function(){"undefined"!=typeof navigator&&(this.ie=/MSIE 9/i.test(navigator.userAgent)||/MSIE 10/i.test(navigator.userAgent)||/rv:11\.0/i.test(navigator.userAgent)||/Trident/i.test(navigator.userAgent))}},{key:"setFont",value:function(e,t,i){var n=!1,r=!1,s="normal";"string"==typeof i&&(-1!==i.indexOf("italic")&&(i=i.replace(/italic/g,""),r=!0),-1!==i.indexOf("bold")&&(i=i.replace(/bold/g,""),n=!0),i=i.replace(/ /g,""));var a={"font-family":e,"font-size":t+"pt","font-weight":i=void 0===(i=n?"bold":i)||""===i?"normal":i,"font-style":s=r?"italic":s};return this.fontSize=Number(t),Kt.Merge(this.attributes,a),Kt.Merge(this.state,a),this}},{key:"setRawFont",value:function(e){var t=(e=e.trim()).split(" ");return this.attributes["font-family"]=t[1],this.state["font-family"]=t[1],this.attributes["font-size"]=t[0],this.state["font-size"]=t[0],this.fontSize=Number(t[0].match(/\d+/)),this}},{key:"setFillStyle",value:function(e){return this.attributes.fill=e,this}},{key:"setBackgroundFillStyle",value:function(e){return this.background_attributes.fill=e,this.background_attributes.stroke=e,this}},{key:"setStrokeStyle",value:function(e){return this.attributes.stroke=e,this}},{key:"setShadowColor",value:function(e){return this.shadow_attributes.color=e,this}},{key:"setShadowBlur",value:function(e){return this.shadow_attributes.width=e,this}},{key:"setLineWidth",value:function(e){this.attributes["stroke-width"]=e,this.lineWidth=e}},{key:"setLineDash",value:function(e){if("[object Array]"===Object.prototype.toString.call(e))return e=e.join(", "),this.attributes["stroke-dasharray"]=e,this;throw new Kt.RERR("ArgumentError","lineDash must be an array of integers.")}},{key:"setLineCap",value:function(e){return this.attributes["stroke-linecap"]=e,this}},{key:"resize",value:function(e,t){this.width=e,this.height=t,this.element.style.width=e;var i={width:e,height:t};return this.applyAttributes(this.svg,i),this.scale(this.state.scale.x,this.state.scale.y),this}},{key:"scale",value:function(e,t){this.state.scale={x:e,y:t};var i=this.width/e,n=this.height/t;return this.setViewBox(0,0,i,n),this}},{key:"setViewBox",value:function(){for(var e=arguments.length,t=new Array(e),i=0;i-1||e.setAttributeNS(null,n,t[n])})),e}},{key:"clear",value:function(){for(;this.svg.lastChild;)this.svg.removeChild(this.svg.lastChild);this.scale(this.state.scale.x,this.state.scale.y)}},{key:"rect",value:function(e,t,i,n,r){n<0&&(t+=n,n*=-1);var s=this.create("rect");return void 0===r&&(r={fill:"none","stroke-width":this.lineWidth,stroke:"black"}),Kt.Merge(r,{x:e,y:t,width:i,height:n}),this.applyAttributes(s,r),this.add(s),this}},{key:"fillRect",value:function(e,t,i,n){return n<0&&(t+=n,n*=-1),this.rect(e,t,i,n,this.attributes),this}},{key:"clearRect",value:function(e,t,i,n){return this.rect(e,t,i,n,this.background_attributes),this}},{key:"beginPath",value:function(){return this.path="",this.pen.x=NaN,this.pen.y=NaN,this}},{key:"moveTo",value:function(e,t){return this.path+="M"+e+" "+t,this.pen.x=e,this.pen.y=t,this}},{key:"lineTo",value:function(e,t){return this.path+="L"+e+" "+t,this.pen.x=e,this.pen.y=t,this}},{key:"bezierCurveTo",value:function(e,t,i,n,r,s){return this.path+="C"+e+" "+t+","+i+" "+n+","+r+" "+s,this.pen.x=r,this.pen.y=s,this}},{key:"quadraticCurveTo",value:function(e,t,i,n){return this.path+="Q"+e+" "+t+","+i+" "+n,this.pen.x=i,this.pen.y=n,this}},{key:"arc",value:function(e,t,i,n,r,s){function a(e){for(;e<0;)e+=2*Math.PI;for(;e>2*Math.PI;)e-=2*Math.PI;return e}if((n=a(n))>(r=a(r))){var o=n;n=r,r=o,s=!s}var u=r-n;return u>Math.PI?(this.arcHelper(e,t,i,n,n+u/2,s),this.arcHelper(e,t,i,n+u/2,r,s)):this.arcHelper(e,t,i,n,r,s),this}},{key:"arcHelper",value:function(e,t,i,n,r,s){var a=e+i*Math.cos(n),o=t+i*Math.sin(n),u=e+i*Math.cos(r),l=t+i*Math.sin(r),h=0,c=0;s?(c=1,r-nMath.PI&&(h=1),this.path+="M"+a+" "+o+" A"+i+" "+i+" 0 "+h+" "+c+" "+u+" "+l,isNaN(this.pen.x)||isNaN(this.pen.y)||(this.peth+="M"+this.pen.x+" "+this.pen.y)}},{key:"closePath",value:function(){return this.path+="Z",this}},{key:"glow",value:function(){if(this.shadow_attributes.width>0)for(var e=this.shadow_attributes,t=e.width/2,i=1;i<=t;i++){var n={stroke:e.color,"stroke-linejoin":"round","stroke-linecap":"round","stroke-width":+(.4*e.width/t*i).toFixed(3),opacity:+((e.opacity||.3)/t).toFixed(3)},r=this.create("path");n.d=this.path,this.applyAttributes(r,n),this.add(r)}return this}},{key:"fill",value:function(e){this.glow();var t=this.create("path"),i=e;return void 0===e?(e={},Kt.Merge(e,this.attributes),e.stroke="none",i=e):(i=e,Kt.Merge(i,this.attributes),e.class&&(i.class=e.class),e.id&&(i.id=e.id)),e.d=this.path,this.applyAttributes(t,e),this.add(t),this}},{key:"stroke",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0;this.glow();var t=this.create("path"),i={};return Kt.Merge(i,this.attributes),e&&Kt.Merge(i,e),i.fill="none",i["stroke-width"]=this.lineWidth,i.d=this.path,this.applyAttributes(t,i),this.add(t),this}},{key:"measureText",value:function(e){var t=this.create("text");if("function"!=typeof t.getBBox)return{x:0,y:0,width:0,height:0};t.textContent=e,this.applyAttributes(t,this.attributes),this.svg.appendChild(t);var i=t.getBBox();return this.ie&&""!==e&&"italic"===this.attributes["font-style"]&&(i=this.ieMeasureTextFix(i,e)),this.svg.removeChild(t),i}},{key:"ieMeasureTextFix",value:function(e){var t=1.196*Number(this.fontSize)+1.9598,i=e.width-t,n=e.height-1.5;return{x:e.x,y:e.y,width:i,height:n}}},{key:"fillText",value:function(e,t,i){if(e&&!(e.length<=0)){var n={};Kt.Merge(n,this.attributes),n.stroke="none",n.x=t,n.y=i;var r=this.create("text");r.textContent=e,this.applyAttributes(r,n),this.add(r)}}},{key:"save",value:function(){return this.state_stack.push({state:{"font-family":this.state["font-family"],"font-weight":this.state["font-weight"],"font-style":this.state["font-style"],"font-size":this.state["font-size"],scale:this.state.scale},attributes:{"font-family":this.attributes["font-family"],"font-weight":this.attributes["font-weight"],"font-style":this.attributes["font-style"],"font-size":this.attributes["font-size"],fill:this.attributes.fill,stroke:this.attributes.stroke,"stroke-width":this.attributes["stroke-width"],"stroke-dasharray":this.attributes["stroke-dasharray"]},shadow_attributes:{width:this.shadow_attributes.width,color:this.shadow_attributes.color},lineWidth:this.lineWidth}),this}},{key:"restore",value:function(){var e=this.state_stack.pop();return this.state["font-family"]=e.state["font-family"],this.state["font-weight"]=e.state["font-weight"],this.state["font-style"]=e.state["font-style"],this.state["font-size"]=e.state["font-size"],this.state.scale=e.state.scale,this.attributes["font-family"]=e.attributes["font-family"],this.attributes["font-weight"]=e.attributes["font-weight"],this.attributes["font-style"]=e.attributes["font-style"],this.attributes["font-size"]=e.attributes["font-size"],this.attributes.fill=e.attributes.fill,this.attributes.stroke=e.attributes.stroke,this.attributes["stroke-width"]=e.attributes["stroke-width"],this.attributes["stroke-dasharray"]=e.attributes["stroke-dasharray"],this.shadow_attributes.width=e.shadow_attributes.width,this.shadow_attributes.color=e.shadow_attributes.color,this.lineWidth=e.lineWidth,this}}]),e}(),fi=null,di=function(){function e(t,i){if(k(this,e),this.elementId=t,!this.elementId)throw new Kt.RERR("BadArgument","Invalid id for renderer.");if(this.element=document.getElementById(t),this.element||(this.element=t),this.ctx=null,this.paper=null,this.backend=i,this.backend===e.Backends.CANVAS){if(!this.element.getContext)throw new Kt.RERR("BadElement","Can't get canvas context from element: ".concat(t));this.ctx=e.bolsterCanvasContext(this.element.getContext("2d"))}else if(this.backend===e.Backends.RAPHAEL)this.ctx=new ui(this.element);else{if(this.backend!==e.Backends.SVG)throw new Kt.RERR("InvalidBackend","No support for backend: ".concat(this.backend));this.ctx=new ci(this.element)}}return E(e,[{key:"resize",value:function(i,n){if(this.backend===e.Backends.CANVAS){if(!this.element.getContext)throw new Kt.RERR("BadElement","Can't get canvas context from element: ".concat(this.elementId));var r=t(oi.SanitizeCanvasDims(i,n),2);i=r[0],n=r[1];var s=window.devicePixelRatio||1;this.element.width=i*s,this.element.height=n*s,this.element.style.width=i+"px",this.element.style.height=n+"px",this.ctx=e.bolsterCanvasContext(this.element.getContext("2d")),this.ctx.scale(s,s)}else this.ctx.resize(i,n);return this}},{key:"getContext",value:function(){return this.ctx}}],[{key:"Backends",get:function(){return{CANVAS:1,RAPHAEL:2,SVG:3,VML:4}}},{key:"LineEndType",get:function(){return{NONE:1,UP:2,DOWN:3}}},{key:"USE_CANVAS_PROXY",get:function(){return!1}},{key:"lastContext",get:function(){return fi},set:function(e){fi=e}},{key:"buildContext",value:function(t,i,n,r,s){var a=new e(t,i);n&&r&&a.resize(n,r),s||(s="#FFF");var o=a.getContext();return o.setBackgroundFillStyle(s),e.lastContext=o,o}},{key:"getCanvasContext",value:function(t,i,n,r){return e.buildContext(t,e.Backends.CANVAS,i,n,r)}},{key:"getRaphaelContext",value:function(t,i,n,r){return e.buildContext(t,e.Backends.RAPHAEL,i,n,r)}},{key:"getSVGContext",value:function(t,i,n,r){return e.buildContext(t,e.Backends.SVG,i,n,r)}},{key:"bolsterCanvasContext",value:function(t){if(e.USE_CANVAS_PROXY)return new oi(t);return t.vexFlowCanvasContext=t,["clear","setFont","setRawFont","setFillStyle","setBackgroundFillStyle","setStrokeStyle","setShadowColor","setShadowBlur","setLineWidth","setLineCap","setLineDash","openGroup","closeGroup","getGroup"].forEach((function(e){t[e]=t[e]||oi.prototype[e]})),t}},{key:"drawDashedLine",value:function(e,t,i,n,r,s){e.beginPath();var a=n-t,o=r-i,u=Math.atan2(o,a),l=t,h=i;e.moveTo(t,i);for(var c=0,f=!0;!(a<0?l<=n:l>=n)||!(o<0?h<=r:h>=r);){var d=s[c++%s.length],p=l+Math.cos(u)*d;l=a<0?Math.max(n,p):Math.min(n,p);var v=h+Math.sin(u)*d;h=o<0?Math.max(r,v):Math.min(r,v),f?e.lineTo(l,h):e.moveTo(l,h),f=!f}e.closePath(),e.stroke()}}]),e}();function pi(){for(var e=arguments.length,t=new Array(e),i=0;i0&&void 0!==arguments[0]?arguments[0]:{};return k(this,i),(e=t.call(this)).setAttribute("type","Stem"),e.x_begin=n.x_begin||0,e.x_end=n.x_end||0,e.y_top=n.y_top||0,e.y_bottom=n.y_bottom||0,e.stem_extension=n.stem_extension||0,e.stem_direction=n.stem_direction||0,e.hide=n.hide||!1,e.isStemlet=n.isStemlet||!1,e.stemletHeight=n.stemletHeight||0,e.resetHeight=0,e.renderHeightAdjustment=0,e.setOptions(n),e}return E(i,[{key:"setResetHeight",value:function(e){this.resetHeight=e}},{key:"setOptions",value:function(e){this.stem_up_y_offset=e.stem_up_y_offset||0,this.stem_down_y_offset=e.stem_down_y_offset||0}},{key:"setNoteHeadXBounds",value:function(e,t){return this.x_begin=e,this.x_end=t,this}},{key:"setDirection",value:function(e){this.stem_direction=e}},{key:"setExtension",value:function(e){this.stem_extension=e}},{key:"getExtension",value:function(){return this.stem_extension}},{key:"setYBounds",value:function(e,t){this.y_top=e,this.y_bottom=t}},{key:"getCategory",value:function(){return i.CATEGORY}},{key:"getHeight",value:function(){var e=this.stem_direction===i.UP?this.stem_up_y_offset:this.stem_down_y_offset;return(this.y_bottom-this.y_top)*this.stem_direction+(i.HEIGHT-e+this.stem_extension)*this.stem_direction}},{key:"getBoundingBox",value:function(){throw new Kt.RERR("NotImplemented","getBoundingBox() not implemented.")}},{key:"getExtents",value:function(){var e=this.stem_direction===i.UP,t=[this.y_top,this.y_bottom],n=i.HEIGHT+this.stem_extension,r=(e?Math.min:Math.max).apply(void 0,t),s=(e?Math.max:Math.min).apply(void 0,t);return{topY:r+n*-this.stem_direction+this.resetHeight*-this.stem_direction,baseY:s}}},{key:"setVisibility",value:function(e){return this.hide=!e,this}},{key:"setStemlet",value:function(e,t){return this.isStemlet=e,this.stemletHeight=t,this}},{key:"draw",value:function(){if(this.setRendered(),!this.hide){var e,t,n=this.checkContext(),r=this.stem_direction;r===i.DOWN?(e=this.x_begin,t=this.y_top+this.stem_down_y_offset):(e=this.x_end,t=this.y_bottom-this.stem_up_y_offset);var s=this.getHeight();pi("Rendering stem - ","Top Y: ",this.y_top,"Bottom Y: ",this.y_bottom);var a=this.isStemlet?s-this.stemletHeight*this.stem_direction:0;if(n.save(),this.applyStyle(n),n.beginPath(),n.setLineWidth(i.WIDTH),n.moveTo(e,t-a),n.lineTo(e,t-s-this.renderHeightAdjustment*r-this.resetHeight*r),n.svg){var o={class:Kt.Prefix("stem")};this.id&&(o.id=this.id),n.stroke(o)}else n.stroke();this.restoreStyle(n),n.restore()}}}],[{key:"CATEGORY",get:function(){return"stem"}},{key:"UP",get:function(){return 1}},{key:"DOWN",get:function(){return-1}},{key:"WIDTH",get:function(){return ai.STEM_WIDTH}},{key:"HEIGHT",get:function(){return ai.STEM_HEIGHT}}]),i}(ei),mi=function(e){c(i,e);var t=d(i);function i(e,n){var r;if(k(this,i),(r=t.call(this)).setAttribute("type","Tuplet"),!e||!e.length)throw new Kt.RuntimeError("BadArguments","No notes provided for tuplet.");return r.options=Kt.Merge({},n),r.notes=e,r.num_notes="num_notes"in r.options?r.options.num_notes:e.length,r.options.beats_occupied&&r.beatsOccupiedDeprecationWarning(),r.notes_occupied=r.options.notes_occupied||r.options.beats_occupied||2,"bracketed"in r.options?r.bracketed=r.options.bracketed:r.bracketed=e.some((function(e){return null===e.beam})),r.ratioed="ratioed"in r.options?r.options.ratioed:Math.abs(r.notes_occupied-r.num_notes)>1,r.point=28,r.y_pos=16,r.x_pos=100,r.width=200,r.location=r.options.location||mi.LOCATION_TOP,cn.AlignRestsToNotes(e,!0,!0),r.resolveGlyphs(),r.attach(),r}return E(i,[{key:"attach",value:function(){for(var e=0;e=1;)this.numerator_glyphs.unshift(new si("v"+e%10,this.point)),e=parseInt(e/10,10);for(this.denom_glyphs=[],e=this.notes_occupied;e>=1;)this.denom_glyphs.unshift(new si("v"+e%10,this.point)),e=parseInt(e/10,10)}},{key:"getNestedTupletCount",value:function(){var e=this.location,t=this.notes[0],i=r(t,e),n=r(t,e);function r(e,t){return e.tupletStack.filter((function(e){return e.location===t})).length}return this.notes.forEach((function(t){var s=r(t,e);i=s>i?s:i,n=se&&(e=o)}}return e+t+i}},{key:"draw",value:function(){var e=this;this.checkContext(),this.setRendered();var t=this.notes[0],i=this.notes[this.notes.length-1];this.bracketed?(this.x_pos=t.getTieLeftX()-5,this.width=i.getTieRightX()-this.x_pos+5):(this.x_pos=t.getStemX(),this.width=i.getStemX()-this.x_pos),this.y_pos=this.getYPosition();var n=function(e,t){return e+t.getMetrics().width},r=this.numerator_glyphs.reduce(n,0);this.ratioed&&(r=this.denom_glyphs.reduce(n,r),r+=.32*this.point);var s=this.x_pos+this.width/2-r/2;if(this.bracketed){var a=this.width/2-r/2-5;a>0&&(this.context.fillRect(this.x_pos,this.y_pos,a,1),this.context.fillRect(this.x_pos+this.width/2+r/2+5,this.y_pos,a,1),this.context.fillRect(this.x_pos,this.y_pos+(this.location===mi.LOCATION_BOTTOM),1,10*this.location),this.context.fillRect(this.x_pos+this.width,this.y_pos+(this.location===mi.LOCATION_BOTTOM),1,10*this.location))}var o=0;if(this.numerator_glyphs.forEach((function(t){t.render(e.context,s+o,e.y_pos+e.point/3-2),o+=t.getMetrics().width})),this.ratioed){var u=s+o+.16*this.point,l=.06*this.point;this.context.beginPath(),this.context.arc(u,this.y_pos-.08*this.point,l,0,2*Math.PI,!0),this.context.closePath(),this.context.fill(),this.context.beginPath(),this.context.arc(u,this.y_pos+.12*this.point,l,0,2*Math.PI,!0),this.context.closePath(),this.context.fill(),o+=.32*this.point,this.denom_glyphs.forEach((function(t){t.render(e.context,s+o,e.y_pos+e.point/3-2),o+=t.getMetrics().width}))}}}],[{key:"LOCATION_TOP",get:function(){return 1}},{key:"LOCATION_BOTTOM",get:function(){return-1}},{key:"NESTING_OFFSET",get:function(){return 15}}]),i}(ei);function gi(e){var t=0;return e.forEach((function(e){e.keyProps&&e.keyProps.forEach((function(e){t+=e.line-3}))})),t>=0?vi.DOWN:vi.UP}var yi="L",bi="B",Si=function(e){c(i,e);var t=d(i);function i(e,n){var r,s,a;if(k(this,i),(r=t.call(this)).setAttribute("type","Beam"),!e||e===[])throw new Kt.RuntimeError("BadArguments","No notes provided for beam.");if(1===e.length)throw new Kt.RuntimeError("BadArguments","Too few notes for beam.");if(r.ticks=e[0].getIntrinsicTicks(),r.ticks>=ai.durationToTicks("4"))throw new Kt.RuntimeError("BadArguments","Beams can only be applied to notes shorter than a quarter note.");for(r.stem_direction=vi.UP,s=0;s-1?vi.UP:vi.DOWN}for(s=0;se?t:e}))}},{key:"breakSecondaryAt",value:function(e){return this.break_on_indices=e,this}},{key:"getSlopeY",value:function(e,t,i,n){return i+(e-t)*n}},{key:"calculateSlope",value:function(){for(var e=this.notes,t=this.stem_direction,i=this.render_options,n=i.max_slope,r=i.min_slope,s=i.slope_iterations,a=i.slope_cost,o=e[0],u=function(e,t){var i=e.getStemExtents().topY,n=e.getStemX();return(t.getStemExtents().topY-i)/(t.getStemX()-n)}(o,e[e.length-1]),l=(n-r)/s,h=Number.MAX_VALUE,c=0,f=0,d=r;d<=n;d+=l){for(var p=0,v=0,m=1;md)&&(h=d,u=Math.min.apply(Math,a(f.getYs())),l=f.getBeamCount())}var p=o/e.length,v=r+l*(1.5*n),m=u+v*-t;t===vi.DOWN&&pm&&(p=u-v),s+this.render_options.flat_beam_offset_per_beam>0?(t===vi.DOWN&&p>s&&!this.render_options.flat_beams||t===vi.UP&&p0){var t=this.render_options.flat_beam_offset;this.render_options.flat_beam_offset_per_beam&&(t+=this.render_options.flat_beam_offset_per_beam*this.getBeamCount());var i,n=this.notes[0].note_heads[0].y,r=this.stem_direction>0?Math.min:Math.max,s=o(this.notes);try{for(s.s();!(i=s.n()).done;){var a,u=o(i.value.note_heads);try{for(u.s();!(a=u.n()).done;){n=r(n,a.value.y)}}catch(l){u.e(l)}finally{u.f()}}}catch(l){s.e(l)}finally{s.f()}e=n+t*-this.stem_direction}return e}},{key:"applyStemExtensions",value:function(){for(var e=this.notes,t=this.slope,i=this.y_shift,n=this.stem_direction,r=this.beam_count,s=this.render_options,a=s.show_stemlets,o=s.stemlet_extension,u=s.beam_width,l=e[0],h=this.getBeamYToDraw(),c=l.getStemX(),f=0;f=8&&(h=-1!==this.break_on_indices.indexOf(u),this.render_options.secondary_break_ticks&&o>=this.render_options.secondary_break_ticks&&(o=0,h=!0));var c=l.getIntrinsicTicks()4?[new Jt(2,n)]:n<=4?[new Jt(1,n)]:[new Jt(1,4)]}},{key:"applyAndGetBeams",value:function(e,t,i){return Si.generateBeams(e.getTickables(),{groups:i,stem_direction:t})}},{key:"generateBeams",value:function(e,t){t||(t={}),t.groups&&t.groups.length||(t.groups=[new Jt(2,8)]);var i,n,r=t.groups.map((function(e){if(!e.multiply)throw new Kt.RuntimeError("InvalidBeamGroups","The beam groups must be an array of Vex.Flow.Fractions");return e.clone().multiply(ai.RESOLUTION,1)})),s=0,a=[],o=[];function u(){r.length-1>s?s+=1:s=0}i=[],e.forEach((function(e){if(i=[],e.shouldIgnoreTicks())return a.push(o),void(o=i);o.push(e);var t=r[s].clone(),n=o.reduce((function(e,t){return t.getTicks().clone().add(e)}),new Jt(0,1)),l=ai.durationToNumber(e.duration)<8;l&&e.tuplet&&(t.numerator*=2),n.greaterThan(t)?(l||i.push(o.pop()),a.push(o),o=i,u()):n.equals(t)&&(a.push(o),o=i,u())})),o.length>0&&a.push(o),n=[],a.forEach((function(e){var i=[];e.forEach((function(e,r,s){var a=0===r||r===s.length-1,o=s[r-1],u=!t.beam_rests&&e.isRest(),l=t.beam_rests&&t.beam_middle_only&&e.isRest()&&a,h=!1;if(t.maintain_stem_directions&&o&&!e.isRest()&&!o.isRest()){var c=o.getStemDirection();h=e.getStemDirection()!==c}var f=parseInt(e.duration,10)<8;u||l||h||f?(i.length>0&&n.push(i),i=h?[e]:[]):i.push(e)})),i.length>0&&n.push(i)})),(a=n).forEach((function(e){var i;if(t.maintain_stem_directions){var n=function(e){for(var t=0;t1){var t=!0;return e.forEach((function(e){e.getIntrinsicTicks()>=ai.durationToTicks("4")&&(t=!1)})),t}return!1})),c=(l=[],a.forEach((function(e){var t=null;e.forEach((function(e){e.tuplet&&t!==e.tuplet&&(t=e.tuplet,l.push(t))}))})),l),f=[];return h.forEach((function(e){var i=new Si(e);t.show_stemlets&&(i.render_options.show_stemlets=!0),t.secondary_breaks&&(i.render_options.secondary_break_ticks=ai.durationToTicks(t.secondary_breaks)),!0===t.flat_beams&&(i.render_options.flat_beams=!0,i.render_options.flat_beam_offset=t.flat_beam_offset),f.push(i)})),c.forEach((function(e){var t=e.notes[0].stem_direction===vi.DOWN?mi.LOCATION_BOTTOM:mi.LOCATION_TOP;e.setTupletLocation(t);for(var i=!1,n=0;n0&&void 0!==arguments[0]?arguments[0]:this.context,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.stave;this.setRendered();for(var i=null,n=0;n0&&i){var s=r.getBoundingBox();s&&i.mergeWith(s)}r.setContext(e),r.drawWithStyle()}this.boundingBox=i}}],[{key:"Mode",get:function(){return{STRICT:1,SOFT:2,FULL:3}}}]),i}(ei);function ki(e,t,i,n,r){if(t!==_i.type.BOLD_DOUBLE_LEFT&&t!==_i.type.BOLD_DOUBLE_RIGHT)throw new Kt.RERR("InvalidConnector","A REPEAT_BEGIN or REPEAT_END type must be provided.");var s=3,a=3.5;t===_i.type.BOLD_DOUBLE_RIGHT&&(s=-5,a=3),e.fillRect(i+s,n,1,r-n),e.fillRect(i-2,n,a,r-n)}var _i=function(e){c(i,e);var t=d(i);function i(e,n){var r;return k(this,i),(r=t.call(this)).setAttribute("type","StaveConnector"),r.thickness=ai.STAVE_LINE_THICKNESS,r.width=3,r.top_stave=e,r.bottom_stave=n,r.type=i.type.DOUBLE,r.font={family:"times",size:16,weight:"normal"},r.x_shift=0,r.texts=[],r}return E(i,[{key:"setType",value:function(e){return(e="string"==typeof e?i.typeString[e]:e)>=i.type.SINGLE_RIGHT&&e<=i.type.NONE&&(this.type=e),this}},{key:"setText",value:function(e,t){return this.texts.push({content:e,options:Kt.Merge({shift_x:0,shift_y:0},t)}),this}},{key:"setFont",value:function(e){Kt.Merge(this.font,e)}},{key:"setXShift",value:function(e){if("number"!=typeof e)throw Kt.RERR("InvalidType","x_shift must be a Number");return this.x_shift=e,this}},{key:"draw",value:function(){var e=this.checkContext();this.setRendered();var t=this.top_stave.getYForLine(0),n=this.bottom_stave.getYForLine(this.bottom_stave.getNumLines()-1)+this.thickness,r=this.width,s=this.top_stave.getX();(this.type===i.type.SINGLE_RIGHT||this.type===i.type.BOLD_DOUBLE_RIGHT||this.type===i.type.THIN_DOUBLE)&&(s=this.top_stave.getX()+this.top_stave.width);var a=n-t;switch(this.type){case i.type.SINGLE:case i.type.SINGLE_LEFT:case i.type.SINGLE_RIGHT:r=1;break;case i.type.DOUBLE:s-=this.width+2;break;case i.type.BRACE:r=12;var o=this.top_stave.getX()-2+this.x_shift,u=t,l=o,h=n,c=o-r,f=u+a/2,d=c-.9*r,p=u+.2*a,v=o+1.1*r,m=f-.135*a,g=v,y=f+.135*a,b=d,S=h-.2*a,x=c-r,k=S,_=o+.4*r,E=f+.135*a,w=_,M=f-.135*a,T=x,P=p;e.beginPath(),e.moveTo(o,u),e.bezierCurveTo(d,p,v,m,c,f),e.bezierCurveTo(g,y,b,S,l,h),e.bezierCurveTo(x,k,_,E,c,f),e.bezierCurveTo(w,M,T,P,o,u),e.fill(),e.stroke();break;case i.type.BRACKET:a=(n+=4)-(t-=4),si.renderGlyph(e,s-5,t-3,40,"v1b",!0),si.renderGlyph(e,s-5,n+3,40,"v10",!0),s-=this.width+2;break;case i.type.BOLD_DOUBLE_LEFT:ki(e,this.type,s+this.x_shift,t,n);break;case i.type.BOLD_DOUBLE_RIGHT:ki(e,this.type,s,t,n);break;case i.type.THIN_DOUBLE:r=1;break;case i.type.NONE:break;default:throw new Kt.RERR("InvalidType","The provided StaveConnector.type (".concat(this.type,") is invalid"))}this.type!==i.type.BRACE&&this.type!==i.type.BOLD_DOUBLE_LEFT&&this.type!==i.type.BOLD_DOUBLE_RIGHT&&this.type!==i.type.NONE&&e.fillRect(s,t,r,a),this.type===i.type.THIN_DOUBLE&&e.fillRect(s-3,t,r,a),e.save(),e.lineWidth=2,e.setFont(this.font.family,this.font.size,this.font.weight);for(var L=0;L0}},{key:"hasStem",value:function(){return!1}},{key:"getDots",value:function(){return this.dots}},{key:"getNoteType",value:function(){return this.noteType}},{key:"setBeam",value:function(){return this}},{key:"setModifierContext",value:function(e){return this.modifierContext=e,this}},{key:"addModifier",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e.setNote(this),e.setIndex(t),this.modifiers.push(e),this.setPreFormatted(!1),this}},{key:"getModifierStartXY",value:function(){if(!this.preFormatted)throw new Kt.RERR("UnformattedNote","Can't call GetModifierStartXY on an unformatted note");return{x:this.getAbsoluteX(),y:this.ys[0]}}},{key:"getMetrics",value:function(){if(!this.preFormatted)throw new Kt.RERR("UnformattedNote","Can't call getMetrics on an unformatted note.");var e=0,t=0;null!=this.modifierContext&&(e=this.modifierContext.state.left_shift,t=this.modifierContext.state.right_shift);var i=this.getWidth();return{width:i,noteWidth:i-e-t-this.extraLeftPx-this.extraRightPx,left_shift:this.x_shift,modLeftPx:e,modRightPx:t,extraLeftPx:this.extraLeftPx,extraRightPx:this.extraRightPx}}},{key:"setWidth",value:function(e){this.width=e}},{key:"getWidth",value:function(){if(!this.preFormatted)throw new Kt.RERR("UnformattedNote","Can't call GetWidth on an unformatted note.");return this.width+(this.modifierContext?this.modifierContext.getWidth():0)}},{key:"setXShift",value:function(e){return this.x_shift=e,this}},{key:"getXShift",value:function(){return this.x_shift}},{key:"getX",value:function(){if(!this.tickContext)throw new Kt.RERR("NoTickContext","Note needs a TickContext assigned for an X-Value");return this.tickContext.getX()+this.x_shift}},{key:"getAbsoluteX",value:function(){if(!this.tickContext)throw new Kt.RERR("NoTickContext","Note needs a TickContext assigned for an X-Value");var e=this.tickContext.getX();return this.stave&&(e+=this.stave.getNoteStartX()+this.render_options.stave_padding),this.isCenterAligned()&&("jianpu"===this.DYMusicScoreType||(e+=this.getCenterXShift())),e}},{key:"setPreFormatted",value:function(e){if(this.preFormatted=e,this.preFormatted){var t=this.tickContext.getExtraPx();this.left_modPx=Math.max(this.left_modPx,t.left),this.right_modPx=Math.max(this.right_modPx,t.right)}}}],[{key:"CATEGORY",get:function(){return"note"}},{key:"STAVEPADDING",get:function(){return 12}},{key:"plotMetrics",value:function(e,t,i){var n=t.getMetrics(),r=t.getAbsoluteX()-n.modLeftPx-n.extraLeftPx,s=t.getAbsoluteX()-n.extraLeftPx,a=t.getAbsoluteX(),o=t.getAbsoluteX()+n.noteWidth,u=t.getAbsoluteX()+n.noteWidth+n.extraRightPx,l=t.getAbsoluteX()+n.noteWidth+n.extraRightPx+n.modRightPx,h=l+t.getFormatterMetrics().freedom.right,c=l-r;e.save(),e.setFont("Arial",8,""),e.fillText(Math.round(c)+"px",r+t.getXShift(),i);var f=i+7;function d(i,n,r){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:f;e.beginPath(),e.setStrokeStyle(r),e.setFillStyle(r),e.setLineWidth(3),e.moveTo(i+t.getXShift(),s),e.lineTo(n+t.getXShift(),s),e.stroke()}d(r,s,"red"),d(s,a,"#999"),d(a,o,"green"),d(o,u,"#999"),d(u,l,"red"),d(l,h,"#DD0"),d(r-t.getXShift(),r,"#BBB"),Kt.drawDot(e,a+t.getXShift(),f,"blue");var p=t.getFormatterMetrics();if(p.iterations>0){var v=p.space.deviation,m=v>=0?"+":"";e.setFillStyle("red"),e.fillText(m+Math.round(v),a+t.getXShift(),i-10)}e.restore()}}]),i}(Ei);function Mi(){for(var e=arguments.length,t=new Array(e),i=0;i2&&(o=!0),o||(i-=ai.STEM_WIDTH/2*r),e.beginPath(),e.moveTo(i,n+s),e.lineTo(i,n+1),e.lineTo(i+a,n-s),e.lineTo(i+a,n),e.lineTo(i,n+s),e.closePath(),o?e.fill():e.stroke(),ai.durationToFraction(t).equals(.5))for(var u=[-3,-1,a+1,a+3],l=0;lf?c:f,d=k,p=S}return t.right_shift+=f,!0}}]),i}(Li);function Ai(e,t,i){var n=(t.isrest?0:1)*i;e.line+=n,e.maxLine+=n,e.minLine+=n,e.note.setKeyLine(0,e.note.getKeyLine(0)+n)}var Ri=function(t){c(r,t);var i=d(r);function r(e){var t;if(k(this,r),(t=i.call(this,e)).setAttribute("type","StaveNote"),t.keys=e.keys,t.clef=e.clef,t.octave_shift=e.octave_shift,t.beam=null,t.vibrato=null,t.glyph=ai.getGlyphProps(t.duration,t.noteType),!t.glyph)throw new Kt.RuntimeError("BadArguments","Invalid note initialization data (No glyph found): ".concat(JSON.stringify(e)));return t.displaced=!1,t.dot_shiftY=0,t.addDotsCount=0,t.keyProps=[],t.use_default_head_x=!1,t.note_heads=[],t.modifiers=[],Kt.Merge(t.render_options,{glyph_font_scale:e.glyph_font_scale||ai.DEFAULT_NOTATION_FONT_SCALE,stroke_px:e.stroke_px||r.DEFAULT_LEDGER_LINE_OFFSET}),t.calculateKeyProps(),t.buildStem(),e.auto_stem?t.autoStem():t.setStemDirection(e.stem_direction),t.reset(),t.buildFlag(),t}return E(r,[{key:"reset",value:function(){var t=this;e(x(r.prototype),"reset",this).call(this);var i=this.note_heads.map((function(e){return e.getStyle()}));this.buildNoteHeads(),this.note_heads.forEach((function(e,t){return e.setStyle(i[t])})),this.stave&&this.note_heads.forEach((function(e){return e.setStave(t.stave)})),this.calcExtraPx()}},{key:"setBeam",value:function(e){return this.beam=e,this.calcExtraPx(),this}},{key:"setVibrato",value:function(e){this.vibrato=e}},{key:"getCategory",value:function(){return r.CATEGORY}},{key:"buildStem",value:function(){this.setStem(new vi({hide:!!this.isRest()})),this.stem.id=Kt.Prefix("".concat(this.getAttribute("id"),"-stem"))}},{key:"buildNoteHeads",value:function(){this.note_heads=[];var e,t,i,n=this.getStemDirection(),r=this.getKeys(),s=null,a=null,o=!1;n===vi.UP?(e=0,t=r.length,i=1):n===vi.DOWN&&(e=r.length-1,t=-1,i=-1);for(var u=e;u!==t;u+=i){var l=this.keyProps[u],h=l.line;null===s?s=h:0===(a=Math.abs(s-h))||.5===a?o=!o:(o=!1,this.use_default_head_x=!0),s=h;var c=new Ti({duration:this.duration,note_type:this.noteType,displaced:o,stem_direction:n,custom_glyph_code:l.code,glyph_font_scale:this.render_options.glyph_font_scale,x_shift:l.shift_right,stem_up_x_offset:l.stem_up_x_offset,stem_down_x_offset:l.stem_down_x_offset,line:l.line});this.note_heads[u]=c}}},{key:"autoStem",value:function(){this.minLine=this.keyProps[0].line,this.maxLine=this.keyProps[this.keyProps.length-1].line;var e=(this.minLine+this.maxLine)/2<3?vi.UP:vi.DOWN;this.setStemDirection(e)}},{key:"calculateKeyProps",value:function(){for(var e=null,t=0;t0&&(this.keyProps[t-1].displaced=!0)),e=s,this.keyProps.push(r)}e=-1/0,this.keyProps.forEach((function(t){t.linet&&(t=n):n1}},{key:"hasStem",value:function(){return this.glyph.stem}},{key:"hasFlag",value:function(){return e(x(r.prototype),"hasFlag",this).call(this)&&!this.isRest()&&this.renderFlag}},{key:"getStemX",value:function(){return"r"===this.noteType?this.getCenterGlyphX():e(x(r.prototype),"getStemX",this).call(this)+function(e){return vi.WIDTH/(2*-e.getStemDirection())}(this)}},{key:"getYForTopText",value:function(e){var t=this.getStemExtents();return Math.min(this.stave.getYForTopText(e),t.topY-this.render_options.annotation_spacing*(e+1))}},{key:"getYForBottomText",value:function(e){var t=this.getStemExtents();return Math.max(this.stave.getYForTopText(e),t.baseY+this.render_options.annotation_spacing*e)}},{key:"setStave",value:function(t){e(x(r.prototype),"setStave",this).call(this,t);var i=this.note_heads.map((function(e){return e.setStave(t),e.getY()}));if(this.setYs(i),this.stem){var n=this.getNoteHeadBounds(),s=n.y_top,a=n.y_bottom;this.stem.setYBounds(s,a)}return this}},{key:"getKeys",value:function(){return this.keys}},{key:"getKeyProps",value:function(){return this.keyProps}},{key:"isDisplaced",value:function(){return this.displaced}},{key:"setNoteDisplaced",value:function(e){return this.displaced=e,this}},{key:"getTieRightX",value:function(){var e=this.getAbsoluteX();return e+=this.getGlyphWidth()+this.x_shift+this.extraRightPx,this.modifierContext&&(e+=this.modifierContext.getExtraRightPx()),e}},{key:"getTieLeftX",value:function(){var e=this.getAbsoluteX();return e+=this.x_shift-this.extraLeftPx}},{key:"getLineForRest",value:function(){var e=this.keyProps[0].line;if(this.keyProps.length>1){var t=this.keyProps[this.keyProps.length-1].line,i=Math.max(e,t),n=Math.min(e,t);e=Kt.MidLine(i,n)}return e}},{key:"getModifierStartXY",value:function(e,t,i){if(i=i||{},!this.preFormatted)throw new Kt.RERR("UnformattedNote","Can't call GetModifierStartXY on an unformatted note");if(0===this.ys.length)throw new Kt.RERR("NoYValues","No Y-Values calculated for this note.");var n=Li.Position,r=n.ABOVE,s=n.BELOW,a=n.LEFT,o=n.RIGHT,u=0;return e===a?u=-2:e===o?(u=this.getGlyphWidth()+this.x_shift+2,this.stem_direction===vi.UP&&this.hasFlag()&&(i.forceFlagRight||function(e,t){return t===(e.getStemDirection()===vi.UP?e.keyProps.length-1:0)}(this,t))&&(u+=this.flag.getMetrics().width)):e!==s&&e!==r||(u=this.getGlyphWidth()/2),{x:this.getAbsoluteX()+u,y:this.ys[t]}}},{key:"setStyle",value:function(t){e(x(r.prototype),"setStyle",this).call(this,t),this.note_heads.forEach((function(e){return e.setStyle(t)})),this.stem&&this.stem.setStyle(t)}},{key:"setStemStyle",value:function(e){this.stem&&this.getStem().setStyle(e)}},{key:"getStemStyle",value:function(){return this.stem.getStyle()}},{key:"setLedgerLineStyle",value:function(e){this.ledgerLineStyle=e}},{key:"getLedgerLineStyle",value:function(){return this.ledgerLineStyle}},{key:"setFlagStyle",value:function(e){this.flagStyle=e}},{key:"getFlagStyle",value:function(){return this.flagStyle}},{key:"setKeyStyle",value:function(e,t){return this.note_heads[e].setStyle(t),this}},{key:"setKeyLine",value:function(e,t){return"va5"!=this.glyph.code_head&&"v3c"!=this.glyph.code_head||(t=3),this.keyProps[e].line=t,this.reset(),this}},{key:"getKeyLine",value:function(e){return this.keyProps[e].line}},{key:"addToModifierContext",value:function(e){this.setModifierContext(e);for(var t=0;tt)&&(t=f),null===n&&h.isDisplaced()&&(n=h.getAbsoluteX()),null!==i||h.isDisplaced()||(i=h.getAbsoluteX()),r=c>r?c:r,s=c=l;--k){var _=null!==v&&k>=d,E=null!==p&&k>=f;g(e.getYForNote(k),_,E)}this.restoreStyle(r,y)}}},{key:"drawVibrato",value:function(){if(this.vibrato){var e=this.context;e.openGroup("vibrato");var t=this.vibrato.getNoteHeadEndX()+2,i=this.vibrato.getNoteHeadBounds().y_top,n=this.getNoteHeadBounds().y_bottom,s=Math.abs(this.getNoteHeadBeginX()-t)-10;this.vibrato.stave.y!==this.stave.y&&(s=30,n=i+10),r.renderVibrato(this.context,t,i,{harsh:!0,vibrato_width:s,wave_height:6,wave_width:4,wave_girth:2},n),e.closeGroup()}}},{key:"drawModifiers",value:function(){if(!this.context)throw new Kt.RERR("NoCanvasContext","Can't draw without a canvas context.");var e=this.context;e.openGroup("modifiers");for(var t=0;t6.5||h<-.5)&&(l+=h>6.5?10*(h-6.5):10*(h+.5))}i.openGroup("flag",null,{pointerBBox:!0}),this.applyStyle(i,this.getFlagStyle()||!1),this.flag.render(i,u,l),this.restoreStyle(i,this.getFlagStyle()||!1),i.closeGroup()}}},{key:"drawNoteHeads",value:function(){var e=this;this.note_heads.forEach((function(t){e.context.openGroup("notehead",null,{pointerBBox:!0});try{if(e.isRest()&&"w"===e.duration){var i=e.stave.options.line_config.filter((function(e){return e.visible})).length;4===e.keyProps[0].line&&i<5&&t.setY(t.getY()+10),1===i&&t.setLine(3)}}catch(n){}t.setContext(e.context).draw(),e.context.closeGroup()}))}},{key:"drawStem",value:function(e){if(!this.context)throw new Kt.RERR("NoCanvasContext","Can't draw without a canvas context.");e&&this.setStem(new vi(e)),this.stem.id=Kt.Prefix("".concat(this.getAttribute("id"),"-stem")),this.stem&&(this.context.openGroup("stem",null,{pointerBBox:!0}),this.stem.setContext(this.context).draw(),this.context.closeGroup())}},{key:"draw",value:function(){if(!this.context)throw new Kt.RERR("NoCanvasContext","Can't draw without a canvas context.");if(!this.stave)throw new Kt.RERR("NoStave","Can't draw without a stave.");if(0===this.ys.length)throw new Kt.RERR("NoYValues","Can't draw note without Y values.");var e=this.stave.getLines();if(2===e||3===e||4===e)for(var t=0;t6.5||o<-.5)&&(this.beam||(this.stem.renderHeightAdjustment=o>6.5?10*(o-6.5):10*Math.abs(o+.5))),this.stem.setNoteHeadXBounds(a,a)}!function(){for(var e=arguments.length,t=new Array(e),i=0;i2?i[1]:null,m=d>2?i[2]:i[1];2===d&&-1===p.stemDirection&&1===m.stemDirection&&(p=i[1],m=i[0]);var g,y=Math.max(p.voice_shift,m.voice_shift),b=0;if(2===d){var S=p.stemDirection===m.stemDirection?0:.5;if(p.stemDirection===m.stemDirection&&p.minLine<=m.maxLine&&(p.isrest||(g=Math.abs(p.line-(m.maxLine+.5)),g=Math.max(g,p.stemMin),p.minLine=p.line-g,p.note.setStemLength(10*g))),p.minLine<=m.maxLine+S)if(p.isrest)Ai(p,m,1);else if(m.isrest)Ai(m,p,-1);else{b=y;var x=Math.abs(p.line-m.line),k=0,_=0;"h"===p.note.duration?k++:"w"===p.note.duration&&_++,"h"===m.note.duration?k++:"w"===m.note.duration&&_++;var E=1===k||1===_||p.note.dots!==m.note.dots;if(n&&(E=E||2===_),0===x&&E){if(m.note.setXShift(b),p.note.dots>0){var w,M=0,T=o(p.note.modifiers);try{for(T.s();!(w=T.n()).done;){var P=w.value;if(P instanceof Ci&&(M++,P.setYShift(-10*(m.maxLine-p.line+1)),M===p.note.dots))break}}catch(L){T.e(L)}finally{T.f()}}}else x<1&&x>0?m.note.setXShift(b):p.note.voice!==m.note.voice&&p.stemDirection===m.stemDirection&&(p.line>m.line?1===p.stemDirection?m.note.renderFlag=!1:p.note.renderFlag=!1:m.line>p.line?1===m.stemDirection?p.note.renderFlag=!1:m.note.renderFlag=!1:1===m.stemDirection&&(m.stemDirection=-1,m.note.setStemDirection(-1)))}return!0}if((null!==v&&v.minLineg?k:g):w===Li.Position.RIGHT&&(M.setXShift(m),y=(k=o+C)>y?k:y),b=T,S=E}return t.left_shift+=g,t.right_shift+=y,!0}}]),i}(Li),Ni=function(){function e(){k(this,e)}return E(e,[{key:"isValidNoteValue",value:function(t){return!(null==t||t<0||t>=e.NUM_TONES)}},{key:"isValidIntervalValue",value:function(e){return this.isValidNoteValue(e)}},{key:"getNoteParts",value:function(e){if(!e||e.length<1)throw new Kt.RERR("BadArguments","Invalid note name: "+e);if(e.length>3)throw new Kt.RERR("BadArguments","Invalid note name: "+e);var t=e.toLowerCase(),i=/^([cdefgab])(b|bb|n|#|##)?$/.exec(t);if(null!=i)return{root:i[1],accidental:i[2]};throw new Kt.RERR("BadArguments","Invalid note name: "+e)}},{key:"getKeyParts",value:function(e){if(!e||e.length<1)throw new Kt.RERR("BadArguments","Invalid key: "+e);var t=e.toLowerCase(),i=/^([cdefgab])(b|#)?(mel|harm|m|M)?$/.exec(t);if(null!=i){var n=i[1],r=i[2],s=i[3];return s||(s="M"),{root:n,accidental:r,type:s}}throw new Kt.RERR("BadArguments","Invalid key: ".concat(e))}},{key:"getNoteValue",value:function(t){var i=e.noteValues[t];if(null==i)throw new Kt.RERR("BadArguments","Invalid note name: ".concat(t));return i.int_val}},{key:"getIntervalValue",value:function(t){var i=e.intervals[t];if(null==i)throw new Kt.RERR("BadArguments","Invalid interval name: ".concat(t));return i}},{key:"getCanonicalNoteName",value:function(t){if(!this.isValidNoteValue(t))throw new Kt.RERR("BadArguments","Invalid note value: ".concat(t));return e.canonical_notes[t]}},{key:"getCanonicalIntervalName",value:function(t){if(!this.isValidIntervalValue(t))throw new Kt.RERR("BadArguments","Invalid interval value: ".concat(t));return e.diatonic_intervals[t]}},{key:"getRelativeNoteValue",value:function(t,i,n){if(null==n&&(n=1),1!==n&&-1!==n)throw new Kt.RERR("BadArguments","Invalid direction: ".concat(n));var r=(t+n*i)%e.NUM_TONES;return r<0&&(r+=e.NUM_TONES),r}},{key:"getRelativeNoteName",value:function(t,i){var n=this.getNoteParts(t),r=this.getNoteValue(n.root),s=i-r;if(Math.abs(s)>e.NUM_TONES-3){var a=1;s>0&&(a=-1);var o=(i+1+(r+1))%e.NUM_TONES*a;if(Math.abs(o)>2)throw new Kt.RERR("BadArguments","Notes not related: ".concat(t,", ").concat(i,")"));s=o}if(Math.abs(s)>2)throw new Kt.RERR("BadArguments","Notes not related: ".concat(t,", ").concat(i,")"));var u=n.root;if(s>0)for(var l=1;l<=s;++l)u+="#";else if(s<0)for(var h=-1;h>=s;--h)u+="b";return u}},{key:"getScaleTones",value:function(e,t){for(var i=[e],n=e,r=0;r0&&void 0!==arguments[0]?arguments[0]:null;if(k(this,n),(e=i.call(this)).setAttribute("type","Accidental"),Bi("New accidental: ",t),e.note=null,e.index=null,e.type=t,e.position=Li.Position.LEFT,e.render_options={font_scale:38,stroke_px:3,parenLeftPadding:2,parenRightPadding:2},e.accidental=ai.accidentalCodes(e.type),!e.accidental)throw new Kt.RERR("ArgumentError","Unknown accidental type: ".concat(t));return e.cautionary=!1,e.parenLeft=null,e.parenRight=null,e.reset(),e}return E(n,[{key:"reset",value:function(){var e=this.render_options.font_scale;this.glyph=new si(this.accidental.code,e),this.glyph.setOriginX(1),this.cautionary&&(this.parenLeft=new si(ai.accidentalCodes("{").code,e),this.parenRight=new si(ai.accidentalCodes("}").code,e),this.parenLeft.setOriginX(1),this.parenRight.setOriginX(1))}},{key:"getCategory",value:function(){return n.CATEGORY}},{key:"getWidth",value:function(){var e=this.cautionary?Di(this.parenLeft)+Di(this.parenRight)+this.render_options.parenLeftPadding+this.render_options.parenRightPadding:0;return Di(this.glyph)+e}},{key:"setNote",value:function(e){if(!e)throw new Kt.RERR("ArgumentError","Bad note value: ".concat(e));this.note=e,"gracenotes"===this.note.getCategory()&&(this.render_options.font_scale=25,this.reset())}},{key:"setAsCautionary",value:function(){return this.cautionary=!0,this.render_options.font_scale=28,this.reset(),this}},{key:"draw",value:function(){var e=this.context,t=this.type,i=this.position,n=this.note,r=this.index,s=this.cautionary,a=this.x_shift,o=this.y_shift,u=this.glyph,l=this.parenLeft,h=this.parenRight,c=this.render_options,f=c.parenLeftPadding,d=c.parenRightPadding;if(this.checkContext(),!n||null==r)throw new Kt.RERR("NoAttachedNote","Can't draw accidental without a note and index.");var p=n.getModifierStartXY(i,r),v=p.x+a,m=p.y+o;Bi("Rendering: ",t,v,m),s?(h.render(e,v,m),v-=Di(h),v-=d,v-=this.accidental.parenRightPaddingAdjustment,u.render(e,v,m),v-=Di(u),v-=f,l.render(e,v,m)):u.render(e,v,m),this.setRendered()}}],[{key:"CATEGORY",get:function(){return"accidentals"}},{key:"format",value:function(e,i){var n=this,r=i.left_shift+1;if(e&&0!==e.length){for(var s=[],o=null,u=0,l=0;lb?k.shift:b,S=k.line}for(var _=0,E=function(e){for(var i=!1,r=e,s=e;s+1=7){for(var v=2,m=!0;!0===m;){m=!1;for(var g=0;g+vp?_:p}else for(d=e;d<=s;d++)p=ai.accidentalColumnsTable[c][f][d-e],y[d].column=p,_=_>p?_:p;w=e=s},w=0;wM[e.column]&&(M[e.column]=e.width)}));for(var L=1;L0?(n=t.flatLine||t.dblSharpLine?2.5:3,e.dblSharpLine&&(i-=.5)):(n=e.flatLine||e.dblSharpLine?2.5:3,t.dblSharpLine&&(i-=.5));var r=Math.abs(i)-1;if(!h||h&&c){a[o.root]=l;var f=new n(u);t.addAccidental(r,f),i.push(l)}})),t.getModifiers().forEach((function(t){"gracenotegroups"===t.getCategory()&&t.getGraceNotes().forEach(e)})))}))}))}}]),n}(Li),Fi=function(e){c(i,e);var t=d(i);function i(e){var n;return k(this,i),(n=t.call(this)).setAttribute("type","NoteSubGroup"),n.note=null,n.index=null,n.position=Li.Position.LEFT,n.subNotes=e,n.subNotes.forEach((function(e){e.ignore_ticks=!1})),n.width=0,n.preFormatted=!1,n.formatter=new cn,n.voice=new xi({num_beats:4,beat_value:4,resolution:ai.RESOLUTION}).setStrict(!1),n.voice.addTickables(n.subNotes),p(n,v(n))}return E(i,[{key:"getCategory",value:function(){return Fi.CATEGORY}},{key:"preFormat",value:function(){this.preFormatted||(this.formatter.joinVoices([this.voice]).format([this.voice],0),this.setWidth(this.formatter.getMinTotalWidth()),this.preFormatted=!0)}},{key:"setNote",value:function(e){this.note=e}},{key:"setWidth",value:function(e){this.width=e}},{key:"getWidth",value:function(){return this.width}},{key:"draw",value:function(){var e=this;this.checkContext();var t=this.getNote();if(!t||null===this.index)throw new Kt.RuntimeError("NoAttachedNote","Can't draw notes without a parent note and parent note index.");this.setRendered(),this.alignSubNotesWithNote(this.subNotes,t),this.subNotes.forEach((function(t){return t.setContext(e.context).drawWithStyle()}))}}],[{key:"CATEGORY",get:function(){return"notesubgroup"}},{key:"format",value:function(e,t){if(!e||0===e.length)return!1;for(var i=0,n=0;nc&&Math.abs(l-c)<10?-6:0;if(this.first_note&&"jianpu"===this.first_note.DYMusicScoreType){if("TabTie"===this.getAttribute("type"))continue;l1){var t=new Si(e);t.render_options.beam_width=3,t.render_options.partial_beam_length=4,this.beams.push(t)}return this}},{key:"setNote",value:function(e){this.note=e}},{key:"setWidth",value:function(e){this.width=e}},{key:"getWidth",value:function(){return this.width}},{key:"getGraceNotes",value:function(){return this.grace_notes}},{key:"draw",value:function(){var e=this;this.checkContext();var t=this.getNote();if(function(){for(var e=arguments.length,t=new Array(e),i=0;i=di.LineEndType.NONE&&e<=di.LineEndType.DOWN&&(this.leg=e),this}},{key:"setStringNumber",value:function(e){return this.string_number=e,this}},{key:"setOffsetX",value:function(e){return this.x_offset=e,this}},{key:"setOffsetY",value:function(e){return this.y_offset=e,this}},{key:"setLastNote",value:function(e){return this.last_note=e,this}},{key:"setDashed",value:function(e){return this.dashed=e,this}},{key:"draw",value:function(){var e=this.checkContext();if(!this.note||null==this.index)throw new Kt.RERR("NoAttachedNote","Can't draw string number without a note and index.");this.setRendered();var t=this.note.stave.options.spacing_between_lines_px,i=this.note.getModifierStartXY(this.position,this.index),n=i.x+this.x_shift+this.x_offset,r=i.y+this.y_shift+this.y_offset;switch(this.position){case Li.Position.ABOVE:case Li.Position.BELOW:var s=this.note.getStemExtents(),a=s.topY,o=s.baseY+2;this.note.stem_direction===Ri.STEM_DOWN&&(a=s.baseY,o=s.topY-2),r=this.position===Li.Position.ABOVE?this.note.hasStem()?a-1.75*t:i.y-1.75*t:this.note.hasStem()?o+1.5*t:i.y+1.75*t,r+=this.y_shift+this.y_offset;break;case Li.Position.LEFT:n-=this.radius/2+5;break;case Li.Position.RIGHT:n+=this.radius/2+6;break;default:throw new Kt.RERR("InvalidPosition","The position ".concat(this.position," is invalid"))}e.save(),e.beginPath(),e.arc(n,r,this.radius,0,2*Math.PI,!1),e.lineWidth=1.5,e.stroke(),e.setFont(this.font.family,this.font.size,this.font.weight);var u=n-e.measureText(this.string_number).width/2;if(e.fillText(""+this.string_number,u,r+4.5),null!=this.last_note){var l,h,c=this.last_note.getStemX()-this.note.getX()+5;switch(e.strokeStyle="#000000",e.lineCap="round",e.lineWidth=.6,this.dashed?di.drawDashedLine(e,n+10,r,n+c,r,[3,3]):di.drawDashedLine(e,n+10,r,n+c,r,[3,0]),this.leg){case di.LineEndType.UP:l=-10,h=this.dashed?[3,3]:[3,0],di.drawDashedLine(e,n+c,r,n+c,r+l,h);break;case di.LineEndType.DOWN:l=10,h=this.dashed?[3,3]:[3,0],di.drawDashedLine(e,n+c,r,n+c,r+l,h)}}e.restore()}}],[{key:"CATEGORY",get:function(){return"stringnumber"}},{key:"format",value:function(e,t){var i=t.left_shift,n=t.right_shift;if(!e||0===e.length)return this;var r,s,a,o,u,l=[],h=null,c=0,f=0;for(r=0;rm?S:m):o===Li.Position.RIGHT&&(s.setXShift(v),g=(S+=_)>g?S:g),y=x,b=a}return t.left_shift+=m,t.right_shift+=g,!0}}]),i}(Li);var Hi=Li.Position,Xi=Hi.ABOVE,Yi=Hi.BELOW,ji=function(e,t){return.5*e(t/.5)},Ki=function(e,t){return t===Xi?e<=5:e>=1},qi=function(e,t){return Ki(e,t)?t===Xi?Math.ceil:Math.floor:Math.round},Ji=function(e){var t=e.getCategory();return"stavenotes"===t||"gracenotes"===t},Zi=function(e){var t=e.getCategory();return"tabnotes"===t||"numberednotes"===t},$i=function(e){c(n,e);var i=d(n);function n(e){var t;if(k(this,n),(t=i.call(this)).setAttribute("type","Articulation"),t.note=null,t.index=null,t.type=e,t.position=Yi,t.render_options={font_scale:38},t.articulation=ai.articulationCodes(t.type),!t.articulation)throw new Kt.RERR("ArgumentError","Articulation not found: ".concat(t.type));return t.glyph=new si(t.articulation.code,t.render_options.font_scale),t.setWidth(t.glyph.getMetrics().width),t}return E(n,[{key:"getCategory",value:function(){return $i.CATEGORY}},{key:"draw",value:function(){var e,t=this,i=this.note,n=this.index,r=this.position,s=this.glyph,o=this.articulation.between_lines,u=this.text_line,l=this.context;if(this.checkContext(),!i||null==n)throw new Kt.RERR("NoAttachedNote","Can't draw Articulation without a note and index.");this.setRendered();var h=i.getStave(),c=h.getSpacingBetweenLines(),f="tabnotes"===i.getCategory(),d=i.getModifierStartXY(r,n).x,p=!o||f,v=function(e,t){var i=t===Xi&&e.getStemDirection()===vi.UP||t===Yi&&e.getStemDirection()===vi.DOWN;return Ji(e)?e.hasStem()&&i?.5:1:e.hasStem()&&i?1:0}(i,r),m=(e={},b(e,Xi,(function(){s.setOrigin(.5,1);var e=function(e,t){var i=e.getStave(),n=e.getStemDirection(),r=e.getStemExtents(),s=r.topY,o=r.baseY;if(Ji(e))return e.hasStem()?n===vi.UP?s:o:Math.min.apply(Math,a(e.getYs()));if(Zi(e))return e.hasStem()&&n===vi.UP?s:i.getYForTopText(t);throw new Kt.RERR("UnknownCategory","Only can get the top and bottom ys of stavenotes and tabnotes")}(i,u)-(u+v)*c+(t.y_shift||0);return p?Math.min(h.getYForTopText($i.INITIAL_OFFSET),e):e})),b(e,Yi,(function(){s.setOrigin(.5,0);var e=function(e,t){var i=e.getStave(),n=e.getStemDirection(),r=e.getStemExtents(),s=r.topY,o=r.baseY;if(Ji(e))return e.hasStem()?n===vi.UP?o:s:Math.max.apply(Math,a(e.getYs()));if(Zi(e))return e.hasStem()?n===vi.UP?i.getYForBottomText(t):s:i.getYForBottomText(t);throw new Kt.RERR("UnknownCategory","Only can get the top and bottom ys of stavenotes and tabnotes")}(i,u)+(u+v)*c;return p?Math.max(h.getYForBottomText($i.INITIAL_OFFSET),e):e})),e)[r]();if(!f){var g=r===Xi?-1:1,y=f?i.positions[n].str:i.getKeyProps()[n].line,S=(i.getYs()[n]-m)/c+y,x=function(e,t,i,n){var r=ji(qi(t,i),t);if(e&&Ki(r,i)&&r%1==0)return r+.5*-n;return r}(o,S,r,g);Ki(x,r)&&s.setOrigin(.5,.5),m+=Math.abs(x-S)*c*g}!function(){for(var e=arguments.length,t=new Array(e),i=0;i0&&n--;for(var o=0;o4&&void 0!==arguments[4]?arguments[4]:0,s=t;for(i+=1;i4.5||s<1.5)){var h=e[i].stem;if(h)if(h.stem_direction>0){var c=s<1.5?Math.abs(s-1.5)*r:0;h.setResetHeight(c)}else{var f=s>4.5?Math.abs(s-4.5)*r:0;h.setResetHeight(f)}}}return s}function hn(e,t,i){if(!e||!e.length)throw new Kt.RERR("BadArgument","No voices to format");var n=e[0].getTotalTicks(),r=e.reduce((function(e,t){if(!t.getTotalTicks().equals(n))throw new Kt.RERR("TickMismatch","Voices should have same total note duration in ticks.");if(t.getMode()===xi.Mode.STRICT&&!t.isComplete())throw new Kt.RERR("IncompleteVoice","Voice does not have enough notes.");return Math.max(e,Jt.LCM(e,t.getResolutionMultiplier()))}),1),s={},a=[],o=[];return e.forEach((function(e){var n=new Jt(0,r);e.getTickables().forEach((function(e){var r=n.numerator;if(!s[r]){var u=new t;o.push(u),s[r]=u}i(e,s[r]),a.push(r),n.add(e.getTicks())}))})),{map:s,array:o,list:Kt.SortAndUnique(a,(function(e,t){return e-t}),(function(e,t){return e===t})),resolutionMultiplier:r}}var cn=function(){function e(){k(this,e),this.minTotalWidth=0,this.hasMinTotalWidth=!1,this.totalTicks=new Jt(0,1),this.tickContexts=null,this.modiferContexts=null,this.contextGaps={total:0,gaps:[]},this.voices=[]}return E(e,[{key:"alignRests",value:function(t,i){if(!t||!t.length)throw new Kt.RERR("BadArgument","No voices to format rests");t.forEach((function(t){return e.AlignRestsToNotes(t.getTickables(),i)}))}},{key:"preCalculateMinTotalWidth",value:function(e){if(this.hasMinTotalWidth)return this.minTotalWidth;if(!this.tickContexts){if(!e)throw new Kt.RERR("BadArgument","'voices' required to run preCalculateMinTotalWidth");this.createTickContexts(e)}var t=this.tickContexts,i=t.list,n=t.map;return this.minTotalWidth=i.map((function(e){var t=n[e];return t.preFormat(),t.getWidth()})).reduce((function(e,t){return e+t}),0),this.hasMinTotalWidth=!0,this.minTotalWidth}},{key:"getMinTotalWidth",value:function(){if(!this.hasMinTotalWidth)throw new Kt.RERR("NoMinTotalWidth","Call 'preCalculateMinTotalWidth' or 'preFormat' before calling 'getMinTotalWidth'");return this.minTotalWidth}},{key:"createModifierContexts",value:function(e){var t=hn(e,on,(function(e,t){return e.addToModifierContext(t)}));return this.modiferContexts=t,t}},{key:"createTickContexts",value:function(e){var t=hn(e,Qi,(function(e,t){return t.addTickable(e)}));return t.array.forEach((function(e){e.tContexts=t.array})),this.totalTicks=e[0].getTicksUsed().clone(),this.tickContexts=t,t}},{key:"preFormat",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,i=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0,r=arguments.length>3?arguments[3]:void 0,s=this.tickContexts,a=s.list,o=s.map,u=s.resolutionMultiplier;n&&r&&n.forEach((function(e){return e.setStave(r).preFormat()}));var l=0,h=0,c=t/2;if(this.minTotalWidth=0,a.forEach((function(t){var n=o[t];i&&n.setContext(i),n.preFormat();var r=n.getWidth();e.minTotalWidth+=r;var s=n.getMetrics();l=l+h+s.extraLeftPx,n.setX(l),h=r-s.extraLeftPx})),this.minTotalWidth=l+h,this.hasMinTotalWidth=!0,!(t<=0)){var f=t-this.minTotalWidth,d=f/(this.totalTicks.value()*u),p=0;a.forEach((function(e,t){var i=a[t-1]||0,n=o[e];p+=(e-i)*d,n.setX(n.getX()+p),n.getCenterAlignedTickables().forEach((function(e){e.center_x_shift=c-n.getX()}))})),1!==a.length&&(this.justifyWidth=t,this.lossHistory=[],this.evaluate())}}},{key:"evaluate",value:function(){var e=this,t=this.justifyWidth;this.contextGaps={total:0,gaps:[]},this.tickContexts.list.forEach((function(t,i){if(0!==i){var n=e.tickContexts.list[i-1],r=e.tickContexts.map[n],s=e.tickContexts.map[t],a=r.getMetrics(),o=r.getX()+a.width,u=s.getX(),l=u-o;e.contextGaps.total+=l,e.contextGaps.gaps.push({x1:o,x2:u}),s.getFormatterMetrics().freedom.left=l,r.getFormatterMetrics().freedom.right=l}}));var i=this.durationStats={};this.voices.forEach((function(e){e.getTickables().forEach((function(e,n,r){var s=e.getTicks().clone().simplify().toString(),a=e.getMetrics(),o=e.getFormatterMetrics(),u=e.getX()+a.noteWidth+a.modRightPx+a.extraRightPx,l=0;if(n0?e.tickContexts.map[r[n-1]]:null,o=n0?t=-Math.min(s.getFormatterMetrics().freedom.right,Math.abs(u)):u<0&&(t=o?Math.min(o.getFormatterMetrics().freedom.right,Math.abs(u)):0);var l=Math.min(5,Math.abs(t));t=t>0?l:-l})),this.evaluate()}},{key:"postFormat",value:function(){var e=function(e){return e.list.forEach((function(t){return e.map[t].postFormat()}))};return e(this.modiferContexts),e(this.tickContexts),this}},{key:"joinVoices",value:function(e){return this.createModifierContexts(e),this.hasMinTotalWidth=!1,this}},{key:"format",value:function(e,t,i){var n={align_rests:!1,context:null,stave:null};return Kt.Merge(n,i),this.voices=e,this.alignRests(e,n.align_rests),this.createTickContexts(e),this.preFormat(t,n.context,e,n.stave),n.stave&&this.postFormat(),this}},{key:"formatToStave",value:function(e,t,i){var n=t.getNoteEndX()-t.getNoteStartX()-10;!function(){for(var e=arguments.length,t=new Array(e),i=0;i1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=i.paddingBetween,r=void 0===n?10:n;e.reduce((function(e,t){t.addToModifierContext(new on);var i=(new Qi).addTickable(t).preFormat(),n=i.getExtraPx();return i.setX(e+n.left),e+i.getWidth()+n.right+r}),t)}},{key:"plotDebugging",value:function(e,t,i,n,r){var s=i+wi.STAVEPADDING,a=t.contextGaps;e.save(),e.setFont("Arial",8,""),a.gaps.forEach((function(t){var i,a,o;i=s+t.x1,a=s+t.x2,o="#aaa",e.beginPath(),e.setStrokeStyle(o),e.setFillStyle(o),e.setLineWidth(1),e.fillRect(i,n,a-i,r-n),e.fillText(Math.round(t.x2-t.x1),s+t.x1,r+12)})),e.fillText(Math.round(a.total)+"px",s-20,r+12),e.setFillStyle("red"),e.fillText("Loss: "+t.lossHistory.map((function(e){return Math.round(e)})),s-20,r+22),e.restore()}},{key:"FormatAndDraw",value:function(t,i,n,r){var s={auto_beam:!1,align_rests:!1};"object"===h(r)?Kt.Merge(s,r):"boolean"==typeof r&&(s.auto_beam=r);var a=new xi(ai.TIME4_4).setMode(xi.Mode.SOFT).addTickables(n),o=s.auto_beam?Si.applyAndGetBeams(a):[];return(new e).joinVoices([a],{align_rests:s.align_rests}).formatToStave([a],i,{align_rests:s.align_rests,stave:i}),a.setStave(i).draw(t,i),o.forEach((function(e){return e.setContext(t).draw()})),a.getBoundingBox()}},{key:"FormatAndDrawTab",value:function(t,i,n,r,s,a,o){var u={auto_beam:a,align_rests:!1};"object"===h(o)?Kt.Merge(u,o):"boolean"==typeof o&&(u.auto_beam=o);var l=new xi(ai.TIME4_4).setMode(xi.Mode.SOFT).addTickables(s),c=new xi(ai.TIME4_4).setMode(xi.Mode.SOFT).addTickables(r),f=u.auto_beam?Si.applyAndGetBeams(l):[];(new e).joinVoices([l],{align_rests:u.align_rests}).joinVoices([c]).formatToStave([l,c],n,{align_rests:u.align_rests}),l.draw(t,n),c.draw(t,i),f.forEach((function(e){return e.setContext(t).draw()})),new _i(n,i).setContext(t).draw()}},{key:"AlignRestsToNotes",value:function(e,t,i){return e.forEach((function(n,r){if(n instanceof Ri&&n.isRest()){if(n.tuplet&&!i)return;if(n.getGlyph().position.toUpperCase(),"va5"===n.glyph.code_head||"v3c"===n.glyph.code_head){var s="va5"===n.glyph.code_head?10:20,a=e[r-1],o=un(e,r),u=!1;if(a&&o&&a.beam&&o.beam&&(u=a.beam.notes.includes(o)),t||null!=n.beam||u){var l=n.getKeyProps()[0];if(0===r)l.line=ln(e,l.line,r,!1,s),n.setKeyLine(0,l.line);else if(r>0&&r=e.line?a.above:a.below}this.placeGlyphOnLine(r,this.stave,e.line),this.glyphs.push(r);var o=this.xPositions[this.xPositions.length-1],u=r.getMetrics().width+s;this.xPositions.push(o+u),this.width+=u}},{key:"cancelKey",value:function(e){return this.formatted=!1,this.cancelKeySpec=e,this}},{key:"convertToCancelAccList",value:function(e){var t=ai.keySignature(e),i=this.accList.length>0&&t.length>0&&t[0].type!==this.accList[0].type,n=i?t.length:t.length-this.accList.length;if(!(n<1)){for(var r=[],s=0;s2&&void 0!==arguments[2]?arguments[2]:this.accList,s=0;switch(e){case"soprano":"#"===t?i=[2.5,.5,2,0,1.5,-.5,1]:s=-1;break;case"mezzo-soprano":"b"===t?i=[0,2,.5,2.5,1,3,1.5]:s=1.5;break;case"alto":s=.5;break;case"tenor":"#"===t?i=[3,1,2.5,.5,2,0,1.5]:s=-.5;break;case"baritone-f":case"baritone-c":"b"===t?i=[.5,2.5,1,3,1.5,3.5,2]:s=2;break;case"bass":case"french":s=1}if(void 0!==i)for(n=0;n0?t[0].type:null;if(this.cancelKeySpec&&(e=this.convertToCancelAccList(this.cancelKeySpec)),this.alterKeySpec&&this.convertToAlterAccList(this.alterKeySpec),this.accList.length>0){var n=(this.position===fn.Position.END?this.stave.endClef:this.stave.clef)||this.stave.clef;e&&this.convertAccLines(n,e.type,e.accList),this.convertAccLines(n,i,t);for(var r=0;r0){this.stave.context.openGroup("keysignature");for(var e=0;e0&&void 0!==arguments[0]?arguments[0]:null,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:15,s=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(k(this,n),(e=i.call(this)).setAttribute("type","TimeSignature"),e.validate_args=s,null===t)return p(e);var a=r;return e.point=40,e.topLine=2,e.bottomLine=4,e.setPosition(fn.Position.BEGIN),e.setTimeSig(t),e.setWidth(e.timeSig.glyph.getMetrics().width),e.setPadding(a),e}return E(n,[{key:"getCategory",value:function(){return n.CATEGORY}},{key:"parseTimeSpec",value:function(e){if("C"===e||"C|"===e){var i=n.glyphs[e],r=i.line,s=i.code,a=i.point;return{line:r,num:!1,glyph:new si(s,a)}}this.validate_args&&function(e){var t=e.split("/").filter((function(e){return""!==e}));if(2!==t.length)throw new Kt.RERR("BadTimeSignature","Invalid time spec: ".concat(e,'. Must be in the form "/"'));t.forEach((function(t){if(isNaN(Number(t)))throw new Kt.RERR("BadTimeSignature","Invalid time spec: ".concat(e,". Must contain two valid numbers."))}))}(e);var o=t(e.split("/").map((function(e){return e.split("")})),2),u=o[0],l=o[1];return{num:!0,glyph:this.makeTimeSignatureGlyph(u,l)}}},{key:"makeTimeSignatureGlyph",value:function(e,t){var i=new si("v0",this.point);i.topGlyphs=[],i.botGlyphs=[];for(var n=0,r=0;ro?n:o,f=i.getMetrics().x_min;i.getMetrics=function(){return{x_min:f,x_max:f+c,width:c}};var d=(c-n)/2,p=(c-o)/2,v=this;return i.renderToStave=function(e){for(var t=e+d,i=0;i0&&void 0!==arguments[0]?arguments[0]:0;if("number"!=typeof e)throw new Kt.RERR("InvalidIndex","Must be of number type");if(this.formatted||this.format(),1===this.getModifiers(fn.Position.BEGIN).length)return 0;var t=this.start_x-this.x,i=this.modifiers[0];return i.getType()===dn.type.REPEAT_BEGIN&&t>i.getWidth()&&(t-=i.getWidth()),t}},{key:"setRepetitionTypeLeft",value:function(e,t){return this.modifiers.push(new pn(e,this.x,t)),this}},{key:"setRepetitionTypeRight",value:function(e,t){return this.modifiers.push(new pn(e,this.x,t)),this}},{key:"setVoltaType",value:function(e,t,i){if(2===e)2===wn.type&&wn.stave.modifiers.push(new _n(wn.type,wn.number_t,wn.x,wn.y)),wn={stave:this,type:e,number_t:t,MeasureNumber:this.MeasureNumber,y:i,x:this.x};else if(4===e){for(var n=this.MeasureNumber-wn.MeasureNumber,r=Math.max(wn.y,i),s=0;s<=n;s++)Mn[wn.MeasureNumber+s]={type:0===s?2:s===n?4:0,number_t:t,y:r};wn={}}else this.modifiers.push(new _n(e,t,this.x,i));return this}},{key:"drawVolta",value:function(){var e=Mn[this.MeasureNumber];e&&(this.modifiers.push(new _n(e.type,e.number_t,this.x,e.y)),delete Mn[this.MeasureNumber]),wn.type&&wn.MeasureNumber==this.MeasureNumber&&(this.modifiers.push(new _n(wn.type,wn.number_t,this.x,wn.y)),wn={})}},{key:"setSection",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:12,r=new vn(e,this.x+i,t);return r.font.size=n,this.modifiers.push(r),this}},{key:"setTempo",value:function(e,t){return this.modifiers.push(new mn(e,this.x,t)),this}},{key:"setText",value:function(e,t,i){var n=new yn(e,t,i);return n.setFont({family:"Arial",size:14,weight:"normal"}),this.modifiers.push(n),this}},{key:"getHeight",value:function(){return this.height}},{key:"getSpacingBetweenLines",value:function(){return this.options.spacing_between_lines_px}},{key:"getBoundingBox",value:function(){return new ii(this.x,this.y,this.width,this.getBottomY()-this.y)}},{key:"getBottomY",value:function(){var e=this.options,t=e.spacing_between_lines_px;return this.getYForLine(e.num_lines)+e.space_below_staff_ln*t}},{key:"getBottomLineY",value:function(){return this.getYForLine(this.options.num_lines)}},{key:"getYForLine",value:function(e){var t=this.options,i=t.spacing_between_lines_px,n=t.space_above_staff_ln;return this.y+e*i+n*i}},{key:"getLineForY",value:function(e){var t=this.options,i=t.spacing_between_lines_px,n=t.space_above_staff_ln;return(e-this.y)/i-n}},{key:"getYForTopText",value:function(e){var t=e||0;return this.getYForLine(-t-this.options.top_text_position)}},{key:"getYForBottomText",value:function(e){var t=e||0;return this.getYForLine(this.options.bottom_text_position+t)}},{key:"getYForNote",value:function(e){var t=this.options,i=t.spacing_between_lines_px,n=t.space_above_staff_ln;return this.y+n*i+5*i-e*i}},{key:"getYForGlyphs",value:function(){return this.getYForLine(3)}},{key:"addModifier",value:function(e,t,i){return void 0!==t&&e.setPosition(t),i&&(this.timeSignature.numerator=i.numerator,this.timeSignature.denominator=i.denominator),e.setStave(this),this.formatted=!1,this.modifiers.push(e),this}},{key:"addEndModifier",value:function(e){return this.addModifier(e,fn.Position.END),this}},{key:"setBegBarType",value:function(e){var t=dn.type,i=t.SINGLE,n=t.REPEAT_BEGIN,r=t.NONE;return e!==i&&e!==n&&e!==r||(this.modifiers[0].setType(e),this.formatted=!1),this}},{key:"setEndBarType",value:function(e){return e!==dn.type.REPEAT_BEGIN&&(this.modifiers[1].setType(e),this.formatted=!1),this}},{key:"setClef",value:function(e,t,i,n){void 0===n&&(n=fn.Position.BEGIN),n===fn.Position.END?this.endClef=e:this.clef=e;var r=this.getModifiers(n,Sn.CATEGORY);return 0===r.length?this.addClef(e,t,i,n):r[0].setType(e,t,i),this}},{key:"setEndClef",value:function(e,t,i){return this.setClef(e,t,i,fn.Position.END),this}},{key:"setKeySignature",value:function(e,t,i){this.options.keySignature=e,void 0===i&&(i=fn.Position.BEGIN);var n=this.getModifiers(i,xn.CATEGORY);return 0===n.length?"jianpu"!==this.options.DYMusicScoreType&&this.addKeySignature(e,t,i):n[0].setKeySig(e,t),this}},{key:"setEndKeySignature",value:function(e,t){return this.setKeySignature(e,t,fn.Position.END),this}},{key:"setTimeSignature",value:function(e,t,i){void 0===i&&(i=fn.Position.BEGIN);var n=this.getModifiers(i,kn.CATEGORY);return 0===n.length?this.addTimeSignature(e,t,i):n[0].setTimeSig(e),this}},{key:"setEndTimeSignature",value:function(e,t){return this.setTimeSignature(e,t,fn.Position.END),this}},{key:"addKeySignature",value:function(e,t,i){return void 0===i&&(i=fn.Position.BEGIN),this.addModifier(new xn(e,t).setPosition(i),i),this}},{key:"addClef",value:function(e,t,i,n){return void 0===n||n===fn.Position.BEGIN?this.clef=e:n===fn.Position.END&&(this.endClef=e),this.addModifier(new Sn(e,t,i),n),this}},{key:"addEndClef",value:function(e,t,i){return this.addClef(e,t,i,fn.Position.END),this}},{key:"addTimeSignature",value:function(e,t,i){return this.addModifier(new kn(e,t),i),this}},{key:"addEndTimeSignature",value:function(e,t){return this.addTimeSignature(e,t,fn.Position.END),this}},{key:"addTrebleGlyph",value:function(){return this.addClef("treble"),this}},{key:"getModifiers",value:function(e,t){return void 0===e&&void 0===t?this.modifiers:this.modifiers.filter((function(i){return!(void 0!==e&&e!==i.getPosition()||void 0!==t&&t!==i.getCategory())}))}},{key:"sortByCategory",value:function(e,t){for(var i=e.length-1;i>=0;i--)for(var n=0;nt[e[n+1].getCategory()]){var r=e[n];e[n]=e[n+1],e[n+1]=r}}},{key:"format",value:function(){var e,t,i,n=this.modifiers[0],r=this.modifiers[1],s=this.getModifiers(fn.Position.BEGIN),a=this.getModifiers(fn.Position.END);this.sortByCategory(s,{barlines:0,clefs:1,keysignatures:2,timesignatures:3}),this.sortByCategory(a,{timesignatures:0,keysignatures:1,barlines:2,clefs:3}),s.length>1&&n.getType()===dn.type.REPEAT_BEGIN&&(s.push(s.splice(0,1)[0]),s.splice(0,0,new dn(dn.type.SINGLE))),a.indexOf(r)>0&&a.splice(0,0,new dn(dn.type.NONE));for(var o=0,u=this.x,l=0;l0){this.context.save(),this.context.setFont(this.font.family,this.font.size,this.font.weight);var c=this.context.measureText(""+this.measure).width;t=this.getYForTopText(0)+3,this.context.fillText(""+this.measure,this.x-c/2,t),this.context.restore()}return this}},{key:"drawStaveTempo",value:function(){if(this.staveTempos.length){var e=document.querySelector("#".concat(this.attrs.id));if(e){var t=e.parentElement.getBBox(),i=this.getYForLine(0),n=e.parentElement.parentElement.querySelectorAll(".vf-curve");if(n.length){var r=this.x+this.staveTempos[0].shift_x+this.getModifierXShift(0),s=this.getYForTopText(1)+t.y-i+5;n.forEach((function(e){var i=e.getBBox();i.x-10r&&i.y-10s&&(t.y=i.y+5)}))}for(var a=0;a=0&&this.timeSignature.numerator){var t=40,n=0;this.MeasureNumber<2&&(t=70,n=-72),this.setText("".concat(this.timeSignature.numerator),1,{justification:1,shift_x:t,shift_y:n-13}),this.setText("ᅳ",1,{justification:1,shift_x:t+3,shift_y:n-2}),this.setText("".concat(this.timeSignature.denominator),1,{justification:1,shift_x:t,shift_y:n+8})}}},{key:"drawVertical",value:function(e,t){this.drawVerticalFixed(this.x+e,t)}},{key:"drawVerticalFixed",value:function(e,t){this.checkContext();var i=this.getYForLine(0),n=this.getYForLine(this.options.num_lines-1);t&&this.context.fillRect(e-3,i,1,n-i+1),this.context.fillRect(e,i,1,n-i+1)}},{key:"drawVerticalBar",value:function(e){this.drawVerticalBarFixed(this.x+e,!1)}},{key:"drawVerticalBarFixed",value:function(e){this.checkContext();var t=this.getYForLine(0),i=this.getYForLine(this.options.num_lines-1);this.context.fillRect(e,t,1,i-t+1)}},{key:"getConfigForLines",value:function(){return this.options.line_config}},{key:"setConfigForLine",value:function(e,t){if(e>=this.options.num_lines||e<0)throw new Kt.RERR("StaveConfigError","The line number must be within the range of the number of lines in the Stave.");if(void 0===t.visible)throw new Kt.RERR("StaveConfigError","The line configuration object is missing the 'visible' property.");if("boolean"!=typeof t.visible)throw new Kt.RERR("StaveConfigError","The line configuration objects 'visible' property must be true or false.");return this.options.line_config[e]=t,this}},{key:"setConfigForLines",value:function(e){if(e.length!==this.options.num_lines)throw new Kt.RERR("StaveConfigError","The length of the lines configuration array must match the number of lines in the Stave");for(var t in e)e[t]||(e[t]=this.options.line_config[t]),Kt.Merge(this.options.line_config[t],e[t]);return this.options.line_config=e,this}}],[{key:"saxophoneMap",value:function(e){var t={C:"bE","#C":"E","C#":"E",Db:"E",D:"F",Eb:"bG",E:"G",F:"bA","#F":"A","F#":"A",Gb:"A",G:"bB",Ab:"B",A:"C",Bb:"bD",B:"D"};return t[e]?t[e]:e}}]),i}(ei),Pn=function(e){c(i,e);var t=d(i);function i(e,n,r,s){var a;k(this,i);var o={spacing_between_lines_px:13,num_lines:6,top_text_position:1};return Kt.Merge(o,s),(a=t.call(this,e,n,r,o)).setAttribute("type","TabStave"),a}return E(i,[{key:"getYForGlyphs",value:function(){return this.getYForLine(2.5)}},{key:"addTabGlyph",value:function(){return this.addClef("tab"),this}}]),i}(Tn);var Ln=function(t){c(n,t);var i=d(n);function n(e,t){var r;if(k(this,n),(r=i.call(this,e)).setAttribute("type","TabNote"),r.ghost=!1,r.positions=e.positions,Kt.Merge(r.render_options,{glyph_font_scale:ai.DEFAULT_TABLATURE_FONT_SCALE,draw_stem:t,draw_dots:t,draw_stem_through_stave:!1,y_shift:0,scale:1,font:"10pt Arial"}),r.glyph=ai.getGlyphProps(r.duration,r.noteType),!r.glyph)throw new Kt.RuntimeError("BadArguments","Invalid note initialization data (No glyph found): ".concat(JSON.stringify(e)));return r.buildStem(),e.stem_direction?r.setStemDirection(e.stem_direction):r.setStemDirection(vi.UP),r.ghost=!1,r.updateWidth(),r}return E(n,[{key:"reset",value:function(){this.stave&&this.setStave(this.stave)}},{key:"getCategory",value:function(){return Ln.CATEGORY}},{key:"setGhost",value:function(e){return this.ghost=e,this.updateWidth(),this}},{key:"hasStem",value:function(){return this.render_options.draw_stem}},{key:"getStemExtension",value:function(){var e=this.getGlyph();return null!=this.stem_extension_override?this.stem_extension_override:e?1===this.getStemDirection()?e.tabnote_stem_up_extension:e.tabnote_stem_down_extension:0}},{key:"addDot",value:function(){var e=new Ci;return this.dots+=1,this.addModifier(e,0)}},{key:"updateWidth",value:function(){var e=this;this.glyphs=[],this.width=0;for(var t=0;t-1,h=t.indexOf(1)>-1;if(!(r&&h||s&&l)){1===t.length&&t.push(t[0]);var c=[];t.forEach((function(t,r,s){var u=1===t,l=t===o,h=i.getYForLine(t-1);0!==r||u?r!==s.length-1||l||(h+=a/2-1):h-=a/2-1,c.push(h),1===n&&u?c.push(e-2):-1===n&&l&&c.push(e+2)})),u.push(c.sort((function(e,t){return e-t})))}})),u}(t,function(e,t){for(var i=[],n=[],r=1;r<=e;r++)t.indexOf(r)>-1?(i.push(n),n=[]):n.push(r);return n.length>0&&i.push(n),i}(this.stave.getNumLines(),this.positions.map((function(e){return e.str}))),this.getStave(),this.getStemDirection());i.save(),i.setLineWidth(vi.WIDTH),r.forEach((function(t){0!==t.length&&(i.beginPath(),i.moveTo(e,t[0]),i.lineTo(e,t[t.length-1]),i.stroke(),i.closePath())})),i.restore()}}},{key:"drawPositions",value:function(){for(var e=this.context,t=this.getAbsoluteX(),i=this.ys,n=0;nparseInt(a,10)?i.SLIDE_DOWN:i.SLIDE_UP}return r.slide_direction=n,r.render_options.cp1=11,r.render_options.cp2=14,r.render_options.y_shift=.5,r.setFont({font:"Times",size:10,style:"bold italic"}),r.setNotes(e),r}return E(i,[{key:"renderTie",value:function(e){if(0===e.first_ys.length||0===e.last_ys.length)throw new Kt.RERR("BadArguments","No Y-values to render");var t=this.context,n=e.first_x_px,r=e.first_ys,s=e.last_x_px,a=this.slide_direction;if(a!==i.SLIDE_UP&&a!==i.SLIDE_DOWN)throw new Kt.RERR("BadSlide","Invalid slide direction");for(var o=0;o0&&void 0!==arguments[0]?arguments[0]:"E/5,B/4,G/4,D/4,A/3,E/3,B/2,E/2";k(this,e),this.setTuning(t)}return E(e,[{key:"noteToInteger",value:function(e){return ai.keyProperties(e).int_value}},{key:"setTuning",value:function(t){e.names[t]&&(t=e.names[t]),this.tuningString=t,this.tuningValues=[],this.numStrings=0;var i=t.split(/\s*,\s*/);if(0===i.length)throw new Kt.RERR("BadArguments","Invalid tuning string: "+t);this.numStrings=i.length;for(var n=0;nthis.numStrings)throw new Kt.RERR("BadArguments","String number must be between 1 and ".concat(this.numStrings,":").concat(e));return this.tuningValues[t-1]}},{key:"getValueForFret",value:function(e,t){var i=this.getValueForString(t),n=parseInt(e,10);if(n<0)throw new Kt.RERR("BadArguments","Fret number must be 0 or higher: "+e);return i+n}},{key:"getNoteForFret",value:function(e,t){var i=this.getValueForFret(e,t),n=Math.floor(i/12),r=i%12;return ai.integerToNote(r)+"/"+n}}],[{key:"names",get:function(){return{standard:"E/5,B/4,G/4,D/4,A/3,E/3",dagdad:"D/5,A/4,G/4,D/4,A/3,D/3",dropd:"E/5,B/4,G/4,D/4,A/3,D/3",eb:"Eb/5,Bb/4,Gb/4,Db/4,Ab/3,Db/3",standardBanjo:"D/5,B/4,G/4,D/4,G/5"}}}]),e}(),Wn=function(){function e(t){k(this,e),this.music=new Ni,this.setKey(t)}return E(e,[{key:"setKey",value:function(e){return this.key=e,this.reset(),this}},{key:"getKey",value:function(){return this.key}},{key:"reset",value:function(){if(this.keyParts=this.music.getKeyParts(this.key),this.keyString=this.keyParts.root,this.keyParts.accidental&&(this.keyString+=this.keyParts.accidental),!Ni.scaleTypes[this.keyParts.type])throw new Kt.RERR("BadArguments","Unsupported key type: ".concat(this.key));this.scale=this.music.getScaleTones(this.music.getNoteValue(this.keyString),Ni.scaleTypes[this.keyParts.type]),this.scaleMap={},this.scaleMapByValue={},this.originalScaleMapByValue={};for(var e=Ni.root_indices[this.keyParts.root],t=0;tr.y;n.x+=s.getMetrics().modRightPx+o.padding_left,r.x-=a.getMetrics().modLeftPx+o.padding_right;var c=s.getGlyph().getWidth();s.getKeyProps()[i].displaced&&1===s.getStemDirection()&&(n.x+=c+o.padding_left),a.getKeyProps()[l].displaced&&-1===a.getStemDirection()&&(r.x-=c+o.padding_right),n.y+=h?-3:1,r.y+=h?2:0,function(e,t,i,n){var r,s,a,o,u=n.draw_start_arrow&&n.draw_end_arrow,l=t.x,h=t.y,c=i.x,f=i.y,d=Math.sqrt((c-l)*(c-l)+(f-h)*(f-h)),p=(d-n.arrowhead_length/3)/d;n.draw_end_arrow||u?(r=Math.round(l+(c-l)*p),s=Math.round(h+(f-h)*p)):(r=c,s=f),n.draw_start_arrow||u?(a=l+(c-l)*(1-p),o=h+(f-h)*(1-p)):(a=l,o=h),n.color&&(e.setStrokeStyle(n.color),e.setFillStyle(n.color)),e.beginPath(),e.moveTo(a,o),e.lineTo(r,s),e.stroke(),e.closePath();var v,m,g,y,b=Math.atan2(f-h,c-l),S=Math.abs(n.arrowhead_length/Math.cos(n.arrowhead_angle));(n.draw_end_arrow||u)&&(v=b+Math.PI+n.arrowhead_angle,g=c+Math.cos(v)*S,y=f+Math.sin(v)*S,m=b+Math.PI-n.arrowhead_angle,Yn(e,g,y,c,f,c+Math.cos(m)*S,f+Math.sin(m)*S)),(n.draw_start_arrow||u)&&(v=b+n.arrowhead_angle,g=l+Math.cos(v)*S,y=h+Math.sin(v)*S,m=b-n.arrowhead_angle,Yn(e,g,y,l,h,l+Math.cos(m)*S,h+Math.sin(m)*S))}(t,n,r,e.render_options)})),t.restore();var u,l=t.measureText(this.text).width,h=o.text_justification,c=0;if(h===i.TextJustification.LEFT)c=n.x;else if(h===i.TextJustification.CENTER){c=(r.x-n.x)/2+n.x-l/2}else h===i.TextJustification.RIGHT&&(c=r.x-l);var f=o.text_position_vertical;return f===i.TextVerticalPosition.TOP?u=s.getStave().getYForTopText():f===i.TextVerticalPosition.BOTTOM&&(u=s.getStave().getYForBottomText(ai.TEXT_HEIGHT_OFFSET_HACK)),t.save(),this.applyFontStyle(),t.fillText(this.text,c,u),t.restore(),this}}],[{key:"TextVerticalPosition",get:function(){return{TOP:1,BOTTOM:2}}},{key:"TextJustification",get:function(){return{LEFT:1,CENTER:2,RIGHT:3}}}]),i}(ei);function Kn(e,t,i,n,r){var s=qn.GLYPHS[e];new si(s.code,r).render(t,i+s.x_shift,n+s.y_shift)}var qn=function(e){c(i,e);var t=d(i);function i(e){var n;return k(this,i),(n=t.call(this)).setAttribute("type","PedalMarking"),n.EndsStave=!1,n.ChangeBegin=!1,n.ChangeEnd=!1,n.notes=e,n.style=i.TEXT,n.line=0,n.custom_depress_text="",n.custom_release_text="",n.font={family:"Times New Roman",size:12,weight:"italic bold"},n.render_options={bracket_height:10,text_margin_right:6,bracket_line_width:1,glyph_point_size:40,color:"black"},n}return E(i,[{key:"setEndStave",value:function(e){if(this.endStave=e,this.endStaveAddedWidth=0,this.startMargin=0,this.endMargin=0,Array.isArray(this.endStave.modifiers))for(var t=0;t3)throw new Kt.RERR("InvalidParameter","The style must be one found in PedalMarking.Styles");return this.style=e,this}},{key:"setLine",value:function(e){return this.line=e,this}},{key:"drawBracketed",value:function(){var e,t,n=this,r=this.context,s=!1,a=this;this.notes.forEach((function(o,u,l){s=!s;var h=0;if(h=o?o.getNoteHeadBeginX():n.endStave.end_x+n.endStaveAddedWidth,n.EndsStave)s?n.ChangeBegin&&(h=o.getAbsoluteX()):(h=o?n.ChangeEnd?o.getAbsoluteX():o.getStave().end_x+n.endStaveAddedWidth-a.render_options.text_margin_right:n.endStave.end_x+n.endStaveAddedWidth-a.render_options.text_margin_right,n.endMargin=-a.render_options.text_margin_right);else if(o)if(s)n.ChangeBegin&&(h=o.getAbsoluteX());else switch(a.style){case i.Styles.BRACKET_OPEN_END:case i.Styles.BRACKET_OPEN_BOTH:case i.Styles.MIXED_OPEN_END:h=o.getNoteHeadEndX();break;default:n.ChangeEnd?h=o.getAbsoluteX():(h=o.getNoteHeadBeginX()-a.render_options.text_margin_right,n.startMargin=-a.render_options.text_margin_right)}var c=n.endStave;o&&(c=o.getStave());var f=c.getYForBottomText(a.line+3);t&&t>f&&(f=t);var d=l[u+1]===o,p=l[u-1]===o,v=0;if(s)if(v=p?5:0,a.style!==i.Styles.MIXED&&a.style!==i.Styles.MIXED_OPEN_END||p)r.beginPath(),a.style===i.Styles.BRACKET_OPEN_BEGIN||a.style===i.Styles.BRACKET_OPEN_BOTH?r.moveTo(h+v,f):(n.ChangeBegin&&(h+=5),r.moveTo(h,f-a.render_options.bracket_height),n.ChangeBegin&&(h+=5),r.lineTo(h+v,f)),r.stroke(),r.closePath();else if(a.custom_depress_text){var m=r.measureText(a.custom_depress_text).width;r.fillText(a.custom_depress_text,h-m/2,f),v=m/2+a.render_options.text_margin_right}else Kn("pedal_depress",r,h,f,a.render_options.glyph_point_size),v=20+a.render_options.text_margin_right;else v=d&&!n.EndsStave?-5:0,r.beginPath(),r.moveTo(e,t),r.lineTo(h+v,f),a.style!==i.Styles.BRACKET_OPEN_END&&a.style!==i.Styles.MIXED_OPEN_END&&a.style!==i.Styles.BRACKET_OPEN_BOTH&&(n.ChangeEnd&&(h+=5),r.lineTo(h,f-a.render_options.bracket_height)),r.stroke(),r.closePath();e=h+v,t=f}))}},{key:"drawText",value:function(){var e=this.context,t=!1,i=this,n=i.render_options.glyph_point_size;this.notes.forEach((function(r){t=!t;var s=r.getStave(),a=r.getAbsoluteX(),o=s.getYForBottomText(i.line+3),u=0;t?i.custom_depress_text?(u=e.measureText(i.custom_depress_text).width,e.fillText(i.custom_depress_text,a-u/2,o)):Kn("pedal_depress",e,a,o,n):i.custom_release_text?(u=e.measureText(i.custom_release_text).width,e.fillText(i.custom_release_text,a-u/2,o)):Kn("pedal_release",e,a,o,n)}))}},{key:"draw",value:function(){var e=this.checkContext();this.setRendered(),e.save(),e.setStrokeStyle(this.render_options.color),e.setFillStyle(this.render_options.color),e.setFont(this.font.family,this.font.size,this.font.weight),function(){for(var e=arguments.length,t=new Array(e),i=0;i0&&void 0!==arguments[0]?arguments[0]:dn.type.SINGLE;k(this,n),(t=i.call(this,{duration:"b"})).setAttribute("type","BarNote"),t.metrics={widths:{}};var s=dn.type;return t.metrics.widths=(b(e={},s.SINGLE,8),b(e,s.DOUBLE,12),b(e,s.END,15),b(e,s.REPEAT_BEGIN,14),b(e,s.REPEAT_END,14),b(e,s.REPEAT_BOTH,18),b(e,s.NONE,0),e),t.ignore_ticks=!0,t.setType(r),t}return E(n,[{key:"getType",value:function(){return this.type}},{key:"setType",value:function(e){return this.type="string"==typeof e?dn.typeString[e]:e,this.setWidth(this.metrics.widths[this.type]),this}},{key:"getBoundingBox",value:function(){return e(x(n.prototype),"getBoundingBox",this).call(this)}},{key:"addToModifierContext",value:function(){return this}},{key:"preFormat",value:function(){return this.setPreFormatted(!0),this}},{key:"draw",value:function(){if(this.checkContext(),!this.stave)throw new Kt.RERR("NoStave","Can't draw without a stave.");!function(){for(var e=arguments.length,t=new Array(e),i=0;i1&&void 0!==arguments[1]&&arguments[1],i=t?new RegExp("^(("+e+"))"):new RegExp("^(("+e+")\\s*)"),n=this.line.slice(this.pos),r=n.match(i);return null!==r?{success:!0,matchedString:r[2],incrementPos:r[1].length,pos:this.pos}:{success:!1,pos:this.pos}}},{key:"expectOne",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=[],n=this.pos,r=!0,s=!1;t=!0===t||!0===e.maybe;for(var a=0;a1&&void 0!==arguments[1]&&arguments[1],i=[],n=this.pos,r=0,s=!0;do{var a=this.expectOne(e);a.success?(r++,i.push(a.results)):s=!1}while(s);var o=r>0||!0===t;return!t||r>0||(this.pos=n),o?this.matchSuccess():this.matchFail(n),{success:o,results:i,numMatches:r}}},{key:"expectZeroOrMore",value:function(e){return this.expectOneOrMore(e,!0)}},{key:"expect",value:function(e){var t;if(ir("Evaluating rules:",e),!e)throw new nr("Invalid Rule: "+e,e);var i=e.bind(this.grammar)();if(i.token)(t=this.matchToken(i.token,!0===i.noSpace)).success&&(this.pos+=t.incrementPos);else{if(!i.expect)throw new nr("Bad grammar! No `token` or `expect` property",i);t=i.oneOrMore?this.expectOneOrMore(i):i.zeroOrMore?this.expectZeroOrMore(i):this.expectOne(i)}return t.matches=[],t.results&&t.results.forEach((function(e){return t.matches.push(rr(e))})),i.run&&t.success&&i.run(t),t}}]),e}();function ar(){for(var e=arguments.length,t=new Array(e),i=0;i0&&void 0!==arguments[0]?arguments[0]:{};this.options={stem:"auto",clef:"treble"},this.elements={notes:[],accidentals:[]},this.rollingDuration="8",this.resetPiece(),Object.assign(this.options,e)}},{key:"getFactory",value:function(){return this.factory}},{key:"getElements",value:function(){return this.elements}},{key:"addCommitHook",value:function(e){this.commitHooks.push(e)}},{key:"resetPiece",value:function(){ar("resetPiece"),this.piece={chord:[],duration:this.rollingDuration,dots:0,type:void 0,options:{}}}},{key:"setNoteDots",value:function(e){ar("setNoteDots:",e),e&&(this.piece.dots=e.length)}},{key:"setNoteDuration",value:function(e){ar("setNoteDuration:",e),this.rollingDuration=this.piece.duration=e||this.rollingDuration}},{key:"setNoteType",value:function(e){ar("setNoteType:",e),e&&(this.piece.type=e)}},{key:"addNoteOption",value:function(e,t){ar("addNoteOption: key:",e,"value:",t),this.piece.options[e]=t}},{key:"addNote",value:function(e,t,i){ar("addNote:",e,t,i),this.piece.chord.push({key:e,accid:t,octave:i})}},{key:"addSingleNote",value:function(e,t,i){ar("addSingleNote:",e,t,i),this.addNote(e,t,i)}},{key:"addChord",value:function(e){var t=this;ar("startChord"),"object"!==h(e[0])?this.addSingleNote(e[0]):e.forEach((function(e){e&&t.addNote.apply(t,a(e))})),ar("endChord")}},{key:"commitPiece",value:function(){var e=this;ar("commitPiece");var t=this.factory;if(t){var i=n(n({},this.options),this.piece.options),r=i.stem,s=i.clef,a="auto"===r.toLowerCase(),o=a||"up"!==r.toLowerCase()?Ri.STEM_DOWN:Ri.STEM_UP,u=this.piece,l=u.chord,h=u.duration,c=u.dots,f=u.type,d=l.map((function(e){return e.key+"/"+e.octave})),p=t.StaveNote({keys:d,duration:h,dots:c,type:f,clef:s,auto_stem:a});a||p.setStemDirection(o);var v=l.map((function(e){return e.accid||null}));v.forEach((function(e,i){e&&p.addAccidental(i,t.Accidental({type:e}))}));for(var m=0;m0&&void 0!==arguments[0]?arguments[0]:{};k(this,e),this.setOptions(t),this.defaults={clef:"treble",time:"4/4",stem:"auto"}}return E(e,[{key:"set",value:function(e){return Object.assign(this.defaults,e),this}},{key:"setOptions",value:function(e){var t=this;return this.options=n({factory:null,builder:null,commitHooks:[hr,cr,$i.easyScoreHook],throwOnError:!1},e),this.factory=this.options.factory,this.builder=this.options.builder||new lr(this.factory),this.grammar=new ur(this.builder),this.parser=new sr(this.grammar),this.options.commitHooks.forEach((function(e){return t.addCommitHook(e)})),this}},{key:"setContext",value:function(e){return this.factory&&this.factory.setContext(e),this}},{key:"parse",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.builder.reset(t);var i=this.parser.parse(e);if(!i.success&&this.options.throwOnError)throw new or("Error parsing line: "+e,i);return i}},{key:"beam",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.factory.Beam({notes:e,options:t}),e}},{key:"tuplet",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.factory.Tuplet({notes:e,options:t}),e}},{key:"notes",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return t=n({clef:this.defaults.clef,stem:this.defaults.stem},t),this.parse(e,t),this.builder.getElements().notes}},{key:"voice",value:function(e,t){return t=n({time:this.defaults.time},t),this.factory.Voice(t).addTickables(e)}},{key:"addCommitHook",value:function(e){return this.builder.addCommitHook(e)}}]),e}();var dr=null,pr="C",vr={notes:[],finish:!1,total:0,staveId:""},mr="",gr="",yr="",br=function(t){c(n,t);var i=d(n);function n(e){var t;k(this,n),(t=i.call(this,e)).setAttribute("type","NumberedNote"),pr=e.keyString,t.ornament=!!e.ornament,t.line=0,t.keys=e.keys||[],t.fontSize=20,t.offset_x=0,t.offset_y=0,t.note_tones=[],t.duration_lines=0,t.long_duration_lines=0,t.note_size=e.note_size||16;var r=ai.sanitizeDuration(t.duration),s=n.numberedDurationLine[r.toString()];if(s&&(t.duration_lines=s),(s=n.longDurationLine[r.toString()])&&(t.long_duration_lines=s),!dr){var a="__$text_wraper$$__",o=document.createElement("canvas");o.id=a,document.body.append(o);var u=document.getElementById(a),l=u.getContext("2d");l.font="Arial 22px";var h=l.measureText("5");dr=h.width+2,document.body.removeChild(u)}return t}return E(n,[{key:"getCategory",value:function(){return n.CATEGORY}},{key:"setKeySignature",value:function(e){this.keySignature=e}},{key:"preFormat",value:function(){this.preFormatted||(this.modifierContext&&this.modifierContext.preFormat(),this.setWidth(this.full_width),this.setPreFormatted(!0))}},{key:"filterNote",value:function(){if(!(window&&window.sett&&window.sett.keySignature)&&this.keys&&this.keys.length){var e=n.accidentalMap(pr);if(e){var t=n.noteLift;if(t){var i=this.keys[0].split("/")[0];"b"===i&&(i="R"),(i=(i=i.replaceAll("#","")).replaceAll("n","")).length>1&&(i=i.replaceAll("b",""));var r=Sr.numberedNotationMapping[i.toUpperCase()];if(t.includes(r))for(var s=0;s=gr&&(this.long_duration_lines=gr-1),8==mr)if(this.long_duration_lines=0,3==gr&&this.draw_dot(this.context,this.bottom_x+25,this.bottom_y-30,this.dot_width),6==gr)this.draw_dot(this.context,this.bottom_x+25,this.bottom_y-30,this.dot_width),new si("v0",40).render(this.context,this.bottom_x+40,this.top_y),this.draw_dot(this.context,this.bottom_x+65,this.bottom_y-30,this.dot_width);return vr={notes:[],finish:!1,total:0,staveId:""}}var r={lines:this.duration_lines,duration:i,id:this.attrs.id,x:this.x-this.duration_line_space/2-this.left_width,y:this.y,width:this.full_width};i>2*e&&(this.long_duration_lines=parseInt(i/e)-1,this.handleDeleteDot()),yr&&(r.x+=this.note_width),vr.notes.push(r);var s=vr.notes.reduce((function(e,t){return e+t.duration}),0);if((s=parseInt(s))>e&&(s-=e),s>e-10&&sn)r.push(o),s++;else{if(r.length>1){var u=r.length-1;i=r[0].y+this.duration_line_space,e.rect(r[0].x,i+3*n,r[u].x-r[0].x+r[u].width,.5)}r=[],s=a+1}}if(r.length>1){var l=r.length-1;i=r[0].y+this.duration_line_space,e.rect(r[0].x,i+3*n,r[l].x-r[0].x+r[l].width,.5)}}}},{key:"draw_dot",value:function(e,t,i,n){e.openGroup("numbered-note-dot"),e.beginPath(),e.arc(t,i,n,0,2*Math.PI),e.closePath(),e.fill(),e.closeGroup()}},{key:"drawDurationLine",value:function(e,t){var i,n,r=this.attrs.id+"-lines";if(e.openGroup("numbered_note_lines",r),this.duration_lines>0){var s=this.duration_line_space,a=this.full_width;if(t&&t.width&&(a=t.width),a<0&&(a=this.note_width),i=t&&void 0!==t.startX?t.startX:this.x-s/2-this.left_width,n=t&&void 0!==t.startY?t.startY:this.y+this.duration_line_space,vr.finish&&(this.drawDurationLoneLine(e,n),vr={notes:[],finish:!1,total:0,staveId:""}),this.ornament?(i+=12,n-=22,a=15,yr&&(i-=10,a+=10)):yr&&(i+=this.note_width,a-=this.note_width),a>0){for(var o=0;o-1?this.modifiers[s].accidental.code="#"===r?"v18":"v44":this.modifiers.splice(s,1)}}catch(a){console.log("🚀 ~ error",a)}}this.setYs(e)}},{key:"getFullWidth",value:function(){return this.full_width}},{key:"getFullHeight",value:function(){return this.full_height}},{key:"getLine",value:function(){return this.keyProps[0].line}},{key:"full_width",get:function(){return this.note_width+this.left_width+this.right_width+this.long_duration_line_width}},{key:"long_duration_line_width",get:function(){return(this.long_duration_width+this.long_duration_space)*this.long_duration_lines}},{key:"full_height",get:function(){return this.bottom_y-this.top_y}},{key:"note_width",get:function(){return this.note_size||0}},{key:"note_dot_width",get:function(){return 6}},{key:"note_height",get:function(){return this.unit_height}},{key:"unit_height",get:function(){return this.note_size||0}},{key:"note_x",get:function(){return this.x||0}},{key:"top_x",get:function(){return this.x||0}},{key:"top_y",get:function(){var e=this;return(this.y||0)-(e.note_tones.map((function(t){return(t.td+t.bd)*(e.dot_space+e.dot_width)})).reduce((function(e,t){return e+t}),0)+this.note_height*this.note_tones.length-this.unit_height-this.note_tones[0].bd*(e.dot_space+e.dot_width)+(this.note_tones.length-1)*this.head_space)}},{key:"bottom_x",get:function(){return this.x||0}},{key:"bottom_y",get:function(){return(this.y||0)+this.unit_height+this.duration_lines*(this.duration_line_height+this.duration_line_space)+this.note_tones[0].meta.bd*(this.dot_width+this.dot_space)}},{key:"left_width",get:function(){return this.modifiers_width}},{key:"right_width",get:function(){return this.full_duration_dot_width}},{key:"duration_dot_width",get:function(){return 6}},{key:"full_duration_dot_width",get:function(){return this.duration_dot_width*this.getModifiersByCategory(Ci.CATEGORY).length}},{key:"getModifiersByCategory",value:function(e){var t=[];return this.modifiers.forEach((function(i){i.getCategory()===e&&t.push(i)})),t}},{key:"head_space",get:function(){return 6}},{key:"duration_line_height",get:function(){return 2}},{key:"duration_line_space",get:function(){return 4}},{key:"dot_width",get:function(){return 2}},{key:"dot_space",get:function(){return 2}},{key:"long_duration_space",get:function(){return 10}},{key:"long_duration_width",get:function(){return 20}},{key:"getWidth",value:function(){return this.full_width}},{key:"modifiers_width",get:function(){var e=0;return this.modifiers.forEach((function(t){e+=t.getWidth()})),e}}],[{key:"CATEGORY",get:function(){return"numberednotes"}},{key:"accidentalAndKey",value:function(e){switch(e){case"G":return{4:"#"};case"D":return{1:"#",4:"#"};case"A":return{1:"#",4:"#",5:"#"};case"E":return{1:"#",2:"#",4:"#",5:"#"};case"B":return{1:"#",2:"#",4:"#",5:"#",6:"#"};case"F#":return{1:"#",2:"#",3:"#",4:"#",5:"#",6:"#"};case"C#":return{1:"#",2:"#",3:"#",4:"#",5:"#",6:"#",7:"#"};case"F":return{7:"b"};case"Bb":return{7:"b",3:"b"};case"Eb":return{7:"b",3:"b",6:"b"};case"Ab":return{7:"b",2:"b",3:"b",6:"b"};case"Db":return{7:"b",2:"b",3:"b",5:"b",6:"b"};case"Gb":return{7:"b",1:"b",2:"b",3:"b",5:"b",6:"b"};case"Cb":return{7:"b",1:"b",2:"b",3:"b",4:"b",5:"b",6:"b"};default:return{}}}},{key:"accidentalMap",value:function(e){switch(e){case"C":return"";case"F":case"Bb":case"Eb":case"Ab":case"Db":case"Gb":case"Cb":return{bb:"b",b:"",n:"#","#":"##"};default:return{b:"bb",n:"b","#":"","##":"#"}}}},{key:"noteLift",get:function(){switch(pr){case"G":return["7"];case"D":return["7","3"];case"A":return["7","3","6"];case"E":return["2","6","3","7"];case"B":return["5","2","6","3","7"];case"F#":return["1","5","2","6","3","7"];case"C#":return["4","1","5","2","6","3","7"];case"F":return["4"];case"Bb":return["1","4"];case"Eb":return["5","1","4"];case"Ab":return["2","5","1","4"];case"Db":return["6","2","5","1","4"];case"Gb":return["3","6","2","5","1","4"];case"Cb":return["7","3","6","2","5","1","4"]}}},{key:"longDurationLine",get:function(){return{1:3,2:1,6:2}}},{key:"numberedDurationLine",get:function(){return{8:1,16:2,32:3,64:4,128:5}}},{key:"durationTime",get:function(){return{8:6144,4:4096}}}]),n}(Ri),Sr=function(){function e(t){k(this,e),this.key=t.key,this.x=t.x||0,this.y=t.y||0,this.idx=t.idx||0,this.note=t.note||0,this.meta=this.tone_to_numbered_key(),this.noteSize=t.noteSize||16,this.td=this.meta.td,this.bd=this.meta.bd}return E(e,[{key:"tone_to_numbered_key",value:function(){var t=this.key.split("/")[0];"b"===t&&(t="R"),(t=(t=t.replaceAll("#","")).replaceAll("n","")).length>1&&(t=t.replaceAll("b",""));var i=0,n=0;this.note.stave&&this.note.stave.options&&this.note.stave.options.keySignature&&(pr=this.note.stave.options.keySignature);var r=this.note.getLine();return re.numberedNotationMapping.max&&(n=Math.ceil((r-e.numberedNotationMapping.max)/3.5)),"R"===t.toUpperCase()&&(i=0,n=0),{key:e.numberedNotationMapping[t.toUpperCase()],td:n,bd:i}}},{key:"draw",value:function(e){var t=this.y;e.openGroup("numbered-note-head");for(var i=this.x+(this.note.ornament?-2:0),n=t-this.note.unit_height-this.note.dot_space-(this.note.ornament?-4:2),r=0;r1&&(a-=this.note.duration_line_space),t+=a}this.draw_dot(e,i+dr,t,this.note.dot_width),t+=this.note.dot_width+this.note.dot_space}e.closeGroup()}},{key:"height",get:function(){return this.note.note_height+(this.meta.bd+this.meta.td)*(this.note.dot_width+this.note.dot_space)}},{key:"draw_dot",value:function(e,t,i,n){e.openGroup("numbered-note-dot"),e.beginPath(),e.arc(t,i,n,0,2*Math.PI),e.closePath(),e.fill(),e.closeGroup()}}],[{key:"numberedNotationMapping",get:function(){var e=pr;switch(window&&window.sett&&window.sett.keySignature&&(e="C"),e){case"A":return{C:"3",D:"4",E:"5",F:"6",G:"7",A:"1",B:"2",R:"0",min:2.5,max:5.5};case"B":return{C:"2",D:"3",E:"4",F:"5",G:"6",A:"7",B:"1",R:"0",min:-.5,max:2.5};case"D":return{C:"7",D:"1",E:"2",F:"3",G:"4",A:"5",B:"6",R:"0",min:.5,max:3.5};case"E":return{C:"6",D:"7",E:"1",F:"2",G:"3",A:"4",B:"5",R:"0",min:1,max:4};case"F":return{C:"5",D:"6",E:"7",F:"1",G:"2",A:"3",B:"4",R:"0",min:1.5,max:4.5};case"G":case"Gb":return{C:"4",D:"5",E:"6",F:"7",G:"1",A:"2",B:"3",R:"0",min:2,max:5};case"Eb":return{C:"6",D:"7",E:"1",F:"2",G:"3",A:"4",B:"5",R:"0",min:1,max:4};case"D#":case"Db":return{C:"7",D:"1",E:"2",F:"3",G:"4",A:"5",B:"6",R:"0",min:.5,max:3.5};case"F#":return{C:"5",D:"6",E:"7",F:"1",G:"2",A:"3",B:"4",R:"0",min:1.5,max:4.5};case"Ab":case"G#":return{C:"3",D:"4",E:"5",F:"6",G:"7",A:"1",B:"2",R:"0",min:-1,max:2};case"Bb":case"A#":return{C:"2",D:"3",E:"4",F:"5",G:"6",A:"7",B:"1",R:"0",min:-.5,max:2.5};case"C#":case"Cb":default:return{C:"1",D:"2",E:"3",F:"4",G:"5",A:"6",B:"7",R:"0",min:0,max:3}}}}]),e}();function xr(){for(var e=arguments.length,t=new Array(e),i=0;i0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0,i=t.options;return(e=Object.assign(t,e)).options=Object.assign(i,e.options),e}var Er=function(){function e(t){k(this,e),xr("New factory: ",t);var i={stave:{space:10},renderer:{context:null,elementId:"",backend:di.Backends.SVG,width:500,height:200,background:"#FFF"},font:{face:"Arial",point:10,style:""}};this.options=i,this.setOptions(t)}return E(e,[{key:"reset",value:function(){this.renderQ=[],this.systems=[],this.staves=[],this.voices=[],this.stave=null}},{key:"getOptions",value:function(){return this.options}},{key:"setOptions",value:function(e){for(var t=0,i=["stave","renderer","font"];t0&&void 0!==arguments[0]?arguments[0]:{};e.factory=this;var t=new Mr(e).setContext(this.context);return this.systems.push(t),t}))},{key:"EasyScore",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return e.factory=this,new fr(e)}},{key:"PedalMarking",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e=_r(e,{notes:[],options:{style:"mixed"}});var t=new qn(e.notes);return t.setStyle(qn.StylesString[e.options.style]),t.setContext(this.context),this.renderQ.push(t),t}},{key:"NoteSubGroup",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e=_r(e,{notes:[],options:{}});var t=new Fi(e.notes);return t.setContext(this.context),t}},{key:"draw",value:function(){var e=this;this.systems.forEach((function(t){return t.setContext(e.context).format()})),this.staves.forEach((function(t){return t.setContext(e.context).draw()})),this.voices.forEach((function(t){return t.setContext(e.context).draw()})),this.renderQ.forEach((function(t){t.isRendered()||t.setContext(e.context).draw()})),this.systems.forEach((function(t){return t.setContext(e.context).draw()})),this.reset()}}],[{key:"newFromElementId",value:function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:200;return new e({renderer:{elementId:t,width:i,height:n}})}}]),e}();function wr(e,t){var i=t.options;return(e=Object.assign(t,e)).options=Object.assign(i,e.options),e}var Mr=function(t){c(n,t);var i=d(n);function n(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return k(this,n),(e=i.call(this)).setAttribute("type","System"),e.setOptions(t),e.parts=[],e}return E(n,[{key:"setOptions",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.options=wr(e,{x:10,y:10,width:500,connector:null,spaceBetweenStaves:12,factory:null,debugFormatter:!1,formatIterations:0,options:{}}),this.factory=this.options.factory||new Er({renderer:{el:null}})}},{key:"setContext",value:function(t){return e(x(n.prototype),"setContext",this).call(this,t),this.factory.setContext(t),this}},{key:"addConnector",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"double";return this.connector=this.factory.StaveConnector({top_stave:this.parts[0].stave,bottom_stave:this.parts[this.parts.length-1].stave,type:e}),this.connector}},{key:"addStave",value:function(e){var t=this;return(e=wr(e,{stave:null,voices:[],spaceAbove:0,spaceBelow:0,debugNoteMetrics:!1,options:{left_bar:!1}})).stave||(e.stave=this.factory.Stave({x:this.options.x,y:this.options.y,width:this.options.width,options:e.options})),e.voices.forEach((function(i){return i.setContext(t.context).setStave(e.stave).getTickables().forEach((function(t){return t.setStave(e.stave)}))})),this.parts.push(e),e.stave}},{key:"format",value:function(){var e=this,t=new cn;this.formatter=t;var i=this.options.y,n=0,r=[],s=[];this.parts.forEach((function(a){i+=a.stave.space(a.spaceAbove),a.stave.setY(i),t.joinVoices(a.voices),i+=a.stave.space(a.spaceBelow),i+=a.stave.space(e.options.spaceBetweenStaves),a.debugNoteMetrics&&(s.push({y:i,voice:a.voices[0]}),i+=15),r=r.concat(a.voices),n=Math.max(n,a.stave.getNoteStartX())})),this.parts.forEach((function(e){return e.stave.setNoteStartX(n)}));var a=this.options.width-(n-this.options.x)-wi.STAVEPADDING;t.format(r,a);for(var o=0;o1&&void 0!==arguments[1]?arguments[1]:Rr.ARPEGGIO_DIRECTIONLESS;k(this,e),this.parentVoiceEntry=t,this.type=i,this.notes=[]}return E(e,[{key:"addNote",value:function(e){this.notes.push(e),e.Arpeggio=this}}]),e}(),Rr=function(e){return 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}(Rr||{}),Ir=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;k(this,e),this.notes=[],this.extendedNoteList=[],this.BeamNumberOffsetToXML=0,this.BeamNumber=t,this.BeamNumberOffsetToXML=i}return E(e,[{key:"Notes",get:function(){return this.notes},set:function(e){this.notes=e}},{key:"ExtendedNoteList",get:function(){return this.extendedNoteList},set:function(e){this.extendedNoteList=e}},{key:"addNoteToBeam",value:function(e){e&&(e.NoteBeam=this,this.notes.push(e),this.extendedNoteList.push(e))}}]),e}(),Nr=function(){function e(t,i){k(this,e),this.voiceEntries=[],this.volume=1,this.parent=t,this.visible=!0,this.audible=!0,this.following=!0,this.voiceId=i,this.uniqueVoiceId="I:"+this.parent.Id+" V: "+this.voiceId}return E(e,[{key:"VoiceEntries",get:function(){return this.voiceEntries}},{key:"Parent",get:function(){return this.parent}},{key:"Visible",get:function(){return this.visible},set:function(e){this.visible=e}},{key:"Audible",get:function(){return this.audible},set:function(e){this.audible=e}},{key:"Following",get:function(){return this.following},set:function(e){this.following=e}},{key:"Solo",get:function(){return this.solo},set:function(e){this.solo=e}},{key:"VoiceId",get:function(){return this.voiceId}},{key:"Volume",get:function(){return this.volume},set:function(e){this.volume=e}},{key:"toString",value:function(){return this.uniqueVoiceId}}]),e}(),Br=function(e){c(i,e);var t=d(i);function i(e,n,r){var s;return k(this,i),(s=t.call(this,e,n)).master=r,s}return E(i,[{key:"Master",get:function(){return this.master}}]),i}(Nr),Dr=function(){function e(t,i){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;k(this,e),this.sourceNote=t,this.setShapeFromXml(i,n)}return E(e,[{key:"setShapeFromXml",value:function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;this.shape=e.ShapeTypeXmlToShape(t);var n=i;void 0===n&&(this.sourceNote?n=this.sourceNote.Length.Denominator>2:(L.warn("notehead: sourceNote and filledXmlAttribute undefined."),n=!0)),this.filled=n}},{key:"SourceNote",get:function(){return this.sourceNote}},{key:"Shape",get:function(){return this.shape}},{key:"Filled",get:function(){return this.filled}}],[{key:"ShapeTypeXmlToShape",value:function(e){switch(e.toLowerCase()){case"normal":return Or.NORMAL;case"x":return Or.X;case"slash":return Or.SLASH;case"diamond":return Or.DIAMOND;case"square":case"la":return Or.SQUARE;case"do":case"triangle":return Or.TRIANGLE;case"rectangle":return Or.RECTANGLE;case"circle-x":return Or.CIRCLEX;default:return L.info("unsupported/unhandled xml notehead '"+e+"'. Using normal notehead."),Or.NORMAL}}}]),e}(),Or=function(e){return 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.X=7]="X",e}(Or||{}),Fr=function(){function e(){k(this,e)}return E(e,null,[{key:"translateText",value:function(e,t){if(!this.defaultTextTranslation)return t}}]),e}(),Vr=function(e){return 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}(Vr||{}),Gr=function(){function e(){k(this,e)}return E(e,null,[{key:"NoteTypeToString",value:function(e){return this.NoteTypeXmlValues[e]}},{key:"StringToNoteType",value:function(e){var t=this.NoteTypeXmlValues.indexOf(e);return-1!==t?t:0}},{key:"getNoteDurationFromType",value:function(e){switch(e){case"1024th":return new f(1,1024);case"512th":return new f(1,512);case"256th":return new f(1,256);case"128th":return new f(1,128);case"64th":return new f(1,64);case"32th":case"32nd":return new f(1,32);case"16th":return new f(1,16);case"eighth":return new f(1,8);case"quarter":return new f(1,4);case"half":return new f(1,2);case"whole":return new f(1,1);case"breve":return new f(2,1);case"long":return new f(4,1);case"maxima":return new f(8,1);default:var t=Fr.translateText("ReaderErrorMessages/NoteDurationError","Invalid note duration.");throw new M(t)}}}]),e}();Gr.NoteTypeXmlValues=["","1024th","512th","256th","128th","64th","32nd","16th","eigth","quarter","half","whole","breve","long","maxima"];var Wr=function(){function e(t){k(this,e),this.placement=g.Above,this.accidentalAbove=Ct.NONE,this.accidentalBelow=Ct.NONE,this.ornament=t}return E(e,[{key:"GetOrnament",get:function(){return this.ornament}},{key:"AccidentalAbove",get:function(){return this.accidentalAbove},set:function(e){this.accidentalAbove=e}},{key:"AccidentalBelow",get:function(){return this.accidentalBelow},set:function(e){this.accidentalBelow=e}}]),e}(),Ur=function(e){return 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}(Ur||{}),zr=function(){function e(t,i,n){k(this,e),this.staffEntries=[],this.comments=[],this.timestamp=i,this.staffEntries=new Array(n),this.parentMeasure=t}return E(e,[{key:"$get$",value:function(e){return this.staffEntries[e]}},{key:"$set$",value:function(e,t){this.staffEntries[e]=t}},{key:"Timestamp",get:function(){return this.timestamp},set:function(e){this.timestamp=e}},{key:"StaffEntries",get:function(){return this.staffEntries},set:function(e){this.staffEntries=e}},{key:"Comments",get:function(){return this.comments},set:function(e){this.comments=e}},{key:"ParentMeasure",get:function(){return this.parentMeasure},set:function(e){this.parentMeasure=e}},{key:"getAbsoluteTimestamp",value:function(){return f.plus(this.timestamp,this.parentMeasure.AbsoluteTimestamp)}}]),e}(),Hr=function(){function e(t,i){k(this,e),this.voiceEntries=[],this.instructions=[],this.chordSymbolContainers=[],this.verticalContainerParent=t,this.parentStaff=i}return E(e,[{key:"ParentStaff",get:function(){return this.parentStaff}},{key:"VerticalContainerParent",get:function(){return this.verticalContainerParent}},{key:"Timestamp",get:function(){if(this.VerticalContainerParent)return this.VerticalContainerParent.Timestamp}},{key:"AbsoluteTimestamp",get:function(){if(this.VerticalContainerParent)return f.plus(this.VerticalContainerParent.ParentMeasure.AbsoluteTimestamp,this.VerticalContainerParent.Timestamp)}},{key:"VoiceEntries",get:function(){return this.voiceEntries},set:function(e){this.voiceEntries=e}},{key:"Link",get:function(){return this.staffEntryLink},set:function(e){this.staffEntryLink=e}},{key:"Instructions",get:function(){return this.instructions},set:function(e){this.instructions=e}},{key:"ChordContainers",get:function(){return this.chordSymbolContainers},set:function(e){this.chordSymbolContainers=e}},{key:"removeAllInstructionsOfTypeClefInstruction",value:function(){for(var e=0,t=0;e0)return!0}return!1}},{key:"hasTie",value:function(){for(var e=0,t=this.VoiceEntries.length;et.parentRepetition.StartIndex)return-1}if(e.alignment===Kr.Begin&&t.alignment===Kr.Begin){if(e.parentRepetition.EndIndext.parentRepetition.EndIndex)return-1}}return 0}}]),e}(),Yr=function(){function e(t,i){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Kr.End,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:void 0,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:void 0;k(this,e),this.endingIndices=void 0,this.measureIndex=t,s&&(this.endingIndices=s.slice()),this.type=i,this.alignment=n,this.parentRepetition=r}return E(e,[{key:"CompareTo",value:function(e){var t=e;if(this.measureIndex>t.measureIndex)return 1;if(this.measureIndex1)return e[this.measureListIndex-1]}},{key:"Rules",get:function(){return this.rules}},{key:"VerticalMeasureList",get:function(){return this.verticalMeasureList},set:function(e){this.verticalMeasureList=e}},{key:"TempoInBPM",get:function(){return this.tempoInBPM},set:function(e){this.tempoInBPM=e}},{key:"findOrCreateStaffEntry",value:function(e,t,i){var n,r,s=void 0,a=o(this.verticalSourceStaffEntryContainers);try{for(a.s();!(r=a.n()).done;){var u=r.value;if(u.Timestamp.Equals(e)){n=u;break}}}catch(p){a.e(p)}finally{a.f()}if(n)return n.StaffEntries[t]?s=n.StaffEntries[t]:(s=new Hr(n,i),n.StaffEntries[t]=s),{createdNewContainer:!1,staffEntry:s};var l=this.verticalSourceStaffEntryContainers[this.verticalSourceStaffEntryContainers.length-1];if(0===this.verticalSourceStaffEntryContainers.length||l.Timestamp.lt(e)){var h=new zr(this,e.clone(),this.completeNumberOfStaves);this.verticalSourceStaffEntryContainers.push(h),s=new Hr(h,i),h.StaffEntries[t]=s}else for(var c=this.verticalSourceStaffEntryContainers.length-1;c>=0;c--){if(this.verticalSourceStaffEntryContainers[c].Timestamp.lt(e)){var f=new zr(this,e.clone(),this.completeNumberOfStaves);this.verticalSourceStaffEntryContainers.splice(c+1,0,f),s=new Hr(f,i),f.StaffEntries[t]=s;break}if(0===c){var d=new zr(this,e.clone(),this.completeNumberOfStaves);this.verticalSourceStaffEntryContainers.splice(c,0,d),s=new Hr(d,i),d.StaffEntries[t]=s;break}}return{createdNewContainer:!0,staffEntry:s}}},{key:"findOrCreateVoiceEntry",value:function(e,t){var i,n=void 0,r=!1,s=o(e.VoiceEntries);try{for(s.s();!(i=s.n()).done;){var a=i.value;if(a.ParentVoice===t){n=a;break}}}catch(u){s.e(u)}finally{s.f()}return n||(n=new ss(e.Timestamp,t,e),r=!0),{createdVoiceEntry:r,voiceEntry:n}}},{key:"getPreviousSourceStaffEntryFromIndex",value:function(e,t){for(var i=t-1;i>=0;i--)if(this.verticalSourceStaffEntryContainers[i][e])return this.verticalSourceStaffEntryContainers[i][e]}},{key:"getVerticalContainerIndexByTimestamp",value:function(e){for(var t=0,i=this.VerticalSourceStaffEntryContainers.length;t=0;l--){var h=this.verticalSourceStaffEntryContainers[l][a+o];if(void 0!==h&&h.hasTie()&&s.lt(f.plus(h.Timestamp,h.calculateMaxNoteLength()))){s=f.plus(h.Timestamp,h.calculateMaxNoteLength());break}}}n.push(s)}for(var c=0,d=n.length;c0)return!0}return!1}},{key:"beginsWithLineRepetition",value:function(){for(var e=0,t=this.FirstRepetitionInstructions.length;e=0&&!(t=this.verticalSourceStaffEntryContainers[i].StaffEntries[e]);i--);return t}},{key:"canBeReducedToMultiRest",value:function(){var e,t,i,n,r,s,a,u,l,h=!0,c=!1,f=o(this.verticalSourceStaffEntryContainers);try{for(f.s();!(l=f.n()).done;){var d=l.value;if(d){var p,v=o(d.StaffEntries);try{for(v.s();!(p=v.n()).done;){var m=p.value;if(m&&m.ParentStaff.ParentInstrument.Visible){if(m.ChordContainers.length>0)return!1;if(m.ParentStaff.hasLyrics&&(c=!0),this.firstRepetitionInstructions.length>0||this.lastRepetitionInstructions.length>0)return!1;var g,y=o(m.VoiceEntries);try{for(y.s();!(g=y.n()).done;){var b,S=o(g.value.Notes);try{for(S.s();!(b=S.n()).done;){if(!b.value.isRest()){h=!1;break}}}catch(P){S.e(P)}finally{S.f()}if(!h)break}}catch(P){y.e(P)}finally{y.f()}}}}catch(P){v.e(P)}finally{v.f()}}}}catch(P){f.e(P)}finally{f.f()}if(!h||c||this.hasMoodExpressions||this.tempoExpressions.length>0)return!1;var x,k=o(this.staffLinkedExpressions);try{for(k.s();!(x=k.n()).done;){if(x.value.length>0)return!1}}catch(P){k.e(P)}finally{k.f()}var _,E=o(this.lastInstructionsStaffEntries);try{for(E.s();!(_=E.n()).done;)for(var w=_.value,M=0,T=null==w?void 0:w.Instructions.length;M1&&void 0!==arguments[1]&&arguments[1];k(this,e),this.PlacementFromXml=!1,this.notes=[],this.fractions=[],this.tupletLabelNumber=t,this.bracket=i}return E(e,[{key:"TupletLabelNumber",get:function(){return this.tupletLabelNumber},set:function(e){this.tupletLabelNumber=e}},{key:"Notes",get:function(){return this.notes},set:function(e){this.notes=e}},{key:"Fractions",get:function(){return this.fractions},set:function(e){this.fractions=e}},{key:"Bracket",get:function(){return this.bracket},set:function(e){this.bracket=e}},{key:"getNoteIndex",value:function(e){for(var t=this.notes.length-1;t>=0;t--)for(var i=0;i0)return this.Notes[0].Length},set:function(e){var t,i=o(this.Notes);try{for(i.s();!(t=i.n()).done;){t.value.Length=e}}catch(n){i.e(n)}finally{i.f()}}},{key:"HasNotes",get:function(){return this.Notes.length>0}}]),e}(),ss=function(){function e(t,i,n){var r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],s=arguments.length>4&&void 0!==arguments[4]&&arguments[4],a=arguments.length>5&&void 0!==arguments[5]&&arguments[5],o=arguments.length>6&&void 0!==arguments[6]&&arguments[6];if(k(this,e),this.notes=[],this.graceVoiceEntriesBefore=[],this.graceVoiceEntriesAfter=[],this.articulations=[],this.playbackEntries=[],this.technicalInstructions=[],this.lyricsEntries=new Xe,this.wantedStemDirection=os.Undefined,this.stemDirectionXml=os.Undefined,this.stemDirection=os.Undefined,this.timestamp=t,this.parentVoice=i,this.parentSourceStaffEntry=n,this.isGrace=s,this.graceAfterMainNote=!1,this.graceNoteSlash=a,this.graceSlur=o,s||i.VoiceEntries.push(this),r&&void 0!==n){var u=n.VoiceEntries;-1===u.indexOf(this)&&u.push(this)}this.mainPlaybackEntry=new rs(this),this.PlaybackEntries.push(this.mainPlaybackEntry)}return E(e,[{key:"ParentSourceStaffEntry",get:function(){return this.parentSourceStaffEntry}},{key:"ParentVoice",get:function(){return this.parentVoice}},{key:"Timestamp",get:function(){return this.timestamp},set:function(e){this.timestamp=e}},{key:"Notes",get:function(){return this.notes}},{key:"addNote",value:function(e){this.notes.push(e),e.isRest()||void 0!==e.NoteTie&&e.NoteTie.StartNote!==e||this.MainPlaybackEntry.Notes.push(new ns(this.MainPlaybackEntry,e))}},{key:"GraceVoiceEntriesBefore",get:function(){return this.graceVoiceEntriesBefore},set:function(e){this.graceVoiceEntriesBefore=e;var t,i=o(this.graceVoiceEntriesBefore);try{for(i.s();!(t=i.n()).done;){t.value.parentSourceStaffEntry=this.ParentSourceStaffEntry}}catch(n){i.e(n)}finally{i.f()}}},{key:"GraceVoiceEntriesAfter",get:function(){return this.graceVoiceEntriesAfter},set:function(e){this.graceVoiceEntriesAfter=e;var t,i=o(this.graceVoiceEntriesAfter);try{for(i.s();!(t=i.n()).done;){t.value.parentSourceStaffEntry=this.ParentSourceStaffEntry}}catch(n){i.e(n)}finally{i.f()}}},{key:"IsGrace",get:function(){return this.isGrace},set:function(e){this.isGrace=e}},{key:"GraceAfterMainNote",get:function(){return this.graceAfterMainNote},set:function(e){this.graceAfterMainNote=e}},{key:"GraceNoteSlash",get:function(){return this.graceNoteSlash},set:function(e){this.graceNoteSlash=e}},{key:"GraceSlur",get:function(){return this.graceSlur},set:function(e){this.graceSlur=e}},{key:"Articulations",get:function(){return this.articulations}},{key:"PlaybackEntries",get:function(){return this.playbackEntries}},{key:"Fermata",get:function(){return this.fermata}},{key:"MainPlaybackEntry",get:function(){return this.mainPlaybackEntry},set:function(e){this.mainPlaybackEntry=e}},{key:"removeMainPlaybackEntry",value:function(){void 0!==this.mainPlaybackEntry&&this.removePlaybackEntry(this.mainPlaybackEntry)}},{key:"removePlaybackEntry",value:function(e){this.mainPlaybackEntry===e&&(this.mainPlaybackEntry=void 0);var t=this.playbackEntries.indexOf(e);t>-1&&this.playbackEntries.splice(t,1)}},{key:"TechnicalInstructions",get:function(){return this.technicalInstructions}},{key:"LyricsEntries",get:function(){return this.lyricsEntries}},{key:"Arpeggio",get:function(){return this.arpeggio},set:function(e){this.arpeggio=e}},{key:"OrnamentContainer",get:function(){return this.ornamentContainer},set:function(e){this.ornamentContainer=e}},{key:"WantedStemDirection",get:function(){return this.wantedStemDirection},set:function(e){this.wantedStemDirection=e}},{key:"StemDirectionXml",get:function(){return this.stemDirectionXml},set:function(e){this.stemDirectionXml=e}},{key:"StemDirection",get:function(){return this.stemDirection},set:function(e){this.stemDirection=e}},{key:"StemColorXml",get:function(){return this.stemColorXml},set:function(e){this.stemColorXml=e}},{key:"StemColor",get:function(){return this.stemColor},set:function(e){this.stemColor=e}},{key:"VolumeModifier",get:function(){return this.volumeModifier},set:function(e){this.volumeModifier=e}},{key:"DurationModifier",get:function(){return this.durationModifier},set:function(e){this.durationModifier=e}},{key:"hasArticulation",value:function(e){var t,i=o(this.articulations);try{for(i.s();!(t=i.n()).done;){if(t.value.Equals(e))return!0}}catch(n){i.e(n)}finally{i.f()}return!1}},{key:"hasTie",value:function(){for(var e=0,t=this.Notes.length;e0)return!0}return!1}},{key:"isStaccato",value:function(){var e,t=o(this.Articulations);try{for(t.s();!(e=t.n()).done;){if(e.value.articulationEnum===as.staccato)return!0}}catch(i){t.e(i)}finally{t.f()}return!1}},{key:"isAccent",value:function(){var e,t=o(this.Articulations);try{for(t.s();!(e=t.n()).done;){var i=e.value;if(i.articulationEnum===as.accent||i.articulationEnum===as.strongaccent)return!0}}catch(n){t.e(n)}finally{t.f()}return!1}},{key:"getVerseNumberForLyricEntry",value:function(e){var t=1;return this.lyricsEntries.forEach((function(i,n){e===n&&(t=i)})),t}}],[{key:"isSupportedArticulation",value:function(e){switch(e){case as.accent:case as.strongaccent:case as.invertedstrongaccent:case as.staccato:case as.staccatissimo:case as.spiccato:case as.tenuto:case as.fermata:case as.invertedfermata:case as.breathmark:case as.caesura:case as.lefthandpizzicato:case as.naturalharmonic:case as.snappizzicato:case as.upbow:case as.downbow:case as.bend:case as.detachedlegato:return!0;default:return!1}}}]),e}(),as=function(e){return e[e.accent=0]="accent",e[e.strongaccent=1]="strongaccent",e[e.marcatoup=2]="marcatoup",e[e.marcatodown=3]="marcatodown",e[e.invertedstrongaccent=4]="invertedstrongaccent",e[e.staccato=5]="staccato",e[e.staccatissimo=6]="staccatissimo",e[e.spiccato=7]="spiccato",e[e.tenuto=8]="tenuto",e[e.fermata=9]="fermata",e[e.invertedfermata=10]="invertedfermata",e[e.breathmark=11]="breathmark",e[e.caesura=12]="caesura",e[e.lefthandpizzicato=13]="lefthandpizzicato",e[e.naturalharmonic=14]="naturalharmonic",e[e.snappizzicato=15]="snappizzicato",e[e.upbow=16]="upbow",e[e.downbow=17]="downbow",e[e.scoop=18]="scoop",e[e.plop=19]="plop",e[e.doit=20]="doit",e[e.falloff=21]="falloff",e[e.stress=22]="stress",e[e.unstress=23]="unstress",e[e.detachedlegato=24]="detachedlegato",e[e.otherarticulation=25]="otherarticulation",e[e.bend=26]="bend",e}(as||{}),os=function(e){return 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}(os||{}),us=function(e){return e[e.MeasureBegin=0]="MeasureBegin",e[e.MeasureEnd=1]="MeasureEnd",e}(us||{}),ls=function(e){c(i,e);var t=d(i);function i(e,n,r,s){var a,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:void 0;return k(this,i),(a=t.call(this)).label=e,a.boundingBox=new yt(v(a),o),a.label.fontHeight=n,a.label.textAlignment=r,a.rules=s,a.rules.MpatMode&&"TRIO"===a.label.text&&(a.label.fontFamily="Arial"),a}return E(i,[{key:"Label",get:function(){return this.label}},{key:"toString",value:function(){return"".concat(this.label.text," (").concat(this.boundingBox.RelativePosition.x,",").concat(this.boundingBox.RelativePosition.y,")")}},{key:"setLabelPositionAndShapeBorders",value:function(){var e,t;if(""!==this.Label.text.trim()){this.TextLines=[];for(var i=null!==(e=null===(t=this.rules)||void 0===t?void 0:t.LabelMarginBorderFactor)&&void 0!==e?e:.1,n=this.Label.text.split(/[\n\r]+/g),r=n.length,s=0,a=0;a0&&this.TextLines.length>1&&(v+=this.rules.SpacingBetweenTextLines*r/10);var m=this.PositionAndShape;switch(this.Label.textAlignment){case kt.CenterBottom:m.BorderTop=-v,m.BorderLeft=-s/2,m.BorderBottom=0,m.BorderRight=s/2;break;case kt.CenterCenter:m.BorderTop=-v/2,m.BorderLeft=-s/2,m.BorderBottom=v/2,m.BorderRight=s/2;break;case kt.CenterTop:m.BorderTop=0,m.BorderLeft=-s/2,m.BorderBottom=v,m.BorderRight=s/2;break;case kt.LeftBottom:m.BorderTop=-v,m.BorderLeft=0,m.BorderBottom=0,m.BorderRight=s;break;case kt.LeftCenter:m.BorderTop=-v/2,m.BorderLeft=0,m.BorderBottom=v/2,m.BorderRight=s;break;case kt.LeftTop:m.BorderTop=0,m.BorderLeft=0,m.BorderBottom=v,m.BorderRight=s;break;case kt.RightBottom:m.BorderTop=-v,m.BorderLeft=-s,m.BorderBottom=0,m.BorderRight=0;break;case kt.RightCenter:m.BorderTop=-v/2,m.BorderLeft=-s,m.BorderBottom=v/2,m.BorderRight=0;break;case kt.RightTop:m.BorderTop=0,m.BorderLeft=-s,m.BorderBottom=v,m.BorderRight=0}m.BorderMarginTop=m.BorderTop-v*i,m.BorderMarginLeft=m.BorderLeft-v*i,m.BorderMarginBottom=m.BorderBottom+v*i,m.BorderMarginRight=m.BorderRight+v*i}}}]),i}(gt),hs=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:kt.CenterBottom,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];k(this,e),this.IsCreditLabel=!1,this.text=t,this.print=r,this.textAlignment=i,this.font=n,this.fontFamily=void 0}return E(e,[{key:"font",get:function(){return this.fontEnumValue},set:function(e){this.fontEnumValue=e,this.fontFamily=Mt[e]}},{key:"ToString",value:function(){return this.text}}]),e}(),cs={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},fs=["纯律","纯律结束"],ds=["跳过下一个","b","#","§","º","X"],ps=["poco rit.","rall.","rit.","accel.","molto rit.","molto rall","lentando","poco accel.","calando"],vs="结束范围速度",ms=(i("G","a tempo"),[vs]),gs="仅文本速度 ";function ys(e){return 0===e.indexOf("速度 ")}function bs(e){return 0===e.indexOf(gs)}function Ss(e){return[].concat(a(Object.keys(cs)),fs,ms,ds).map((function(e){return e.trim().toLocaleUpperCase()})).includes(e.toLocaleUpperCase().trim())}function xs(e){return[kt.CenterTop,kt.RightTop].includes(e)}var ks=function(e){return 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}(ks||{}),_s=function(e){return 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}(_s||{}),Es=function(e){return e[e.Following=0]="Following",e[e.Midi=1]="Midi",e[e.Manual=2]="Manual",e}(Es||{}),ws=E((function e(){k(this,e)})),Ms=function(){function e(t,i){k(this,e),this.drawableBoundingBoxElement="None",this.skyLineVisible=!1,this.bottomLineVisible=!1,this.phonicScoreMode=Es.Manual,this.textMeasurer=t,this.splitScreenLineColor=-1,this.drawingParameters=i,this.rules=i.Rules}return E(e,[{key:"Mode",set:function(e){this.phonicScoreMode=e}},{key:"drawSheet",value:function(e){if(this.graphicalMusicSheet=e,this.rules=e.ParentMusicSheet.Rules,this.drawSplitScreenLine(),this.drawingParameters.drawCursors){var t,i=o(e.Cursors);try{for(i.s();!(t=i.n()).done;){var n=t.value;if(n){var r=new yt(n);r.AbsolutePosition=n.Start,r.BorderBottom=n.End.y-n.Start.y,r.BorderRight=n.Width/2,r.BorderLeft=-n.Width/2,this.isVisible(r)&&this.drawLineAsVerticalRectangle(n,Bt.Cursor)}}}catch(l){i.e(l)}finally{i.f()}}this.drawingParameters.drawScrollIndicator&&this.drawScrollIndicator();for(var s=Math.min(this.graphicalMusicSheet.MusicPages.length,this.rules.MaxPageToDrawNumber),a=0;a0&&(xs(e.Label.textAlignment)||[kt.CenterBottom].includes(e.Label.textAlignment))){var p,v=-1,m=!1,g=o((null==h?void 0:h.AbstractExpressions)||[]);try{for(g.s();!(p=g.n()).done;){var y,b,S=p.value;if(S.Label===e)v=null==S||null===(b=S.parentMeasure)||void 0===b?void 0:b.measureListIndex;else null!==(y=S.expression)&&void 0!==y&&y.TempoInBpm&&(m=S.expression.TempoInBpm>0);if(m&&v>-1){u.ScreenPosition.y-=40;break}}}catch(x){g.e(x)}finally{g.f()}}"jianpu"===this.rules.DYMusicScoreType?isNaN(parseInt(e.Label.text,10))&&this.renderLabel(e,t,u):this.renderLabel(e,t,u)}}}},{key:"calculateLabel",value:function(e){var t=new ws,i=e.Label,n=new yt(this);n.AbsolutePosition.x=e.PositionAndShape.AbsolutePosition.x,n.AbsolutePosition.y=e.PositionAndShape.AbsolutePosition.y||e.PositionAndShape.Parent.AbsolutePosition.y,t.ScreenPosition=this.applyScreenTransformation(n.AbsolutePosition),t.FontHeightInPixel=this.calculatePixelDistance(i.fontHeight);var r=this.calculatePixelDistance(e.PositionAndShape.Size.width);switch(t.BitmapWidth=Math.ceil(r),t.BitmapHeight=e.TextLines?Math.ceil(t.FontHeightInPixel*(.2+e.TextLines.length)):10,i.textAlignment){case kt.LeftTop:t.ScreenPosition.x-=t.BitmapWidth/2,t.ScreenPosition.y+=1.5*t.BitmapHeight;break;case kt.LeftCenter:t.ScreenPosition.y-=t.BitmapHeight/2;break;case kt.LeftBottom:t.ScreenPosition.y-=t.BitmapHeight;break;case kt.CenterTop:t.ScreenPosition.x-=t.BitmapWidth/2;break;case kt.CenterCenter:t.ScreenPosition.x-=t.BitmapWidth/2,t.ScreenPosition.y-=t.BitmapHeight/2;break;case kt.CenterBottom:t.ScreenPosition.x-=t.BitmapWidth/2,t.ScreenPosition.y-=t.BitmapHeight;break;case kt.RightTop:t.ScreenPosition.x-=t.BitmapWidth;break;case kt.RightCenter:t.ScreenPosition.x-=t.BitmapWidth,t.ScreenPosition.y-=t.BitmapHeight/2;break;case kt.RightBottom:t.ScreenPosition.x-=t.BitmapWidth,t.ScreenPosition.y-=t.BitmapHeight;break;default:throw new T("")}return t}},{key:"applyScreenTransformations",value:function(e){var t,i=[],n=o(e);try{for(n.s();!(t=n.n()).done;){var r=t.value;i.push(this.applyScreenTransformation(r))}}catch(s){n.e(s)}finally{n.f()}return i}},{key:"drawSplitScreenLine",value:function(){}},{key:"renderRectangle",value:function(e,t,i){throw new Error("not implemented")}},{key:"drawScrollIndicator",value:function(){}},{key:"drawSelectionStartSymbol",value:function(e){}},{key:"drawSelectionEndSymbol",value:function(e){}},{key:"renderLabel",value:function(e,t,i){throw new Error("not implemented")}},{key:"renderSystemToScreen",value:function(e,t,i){}},{key:"drawSkyLine",value:function(e){}},{key:"drawBottomLine",value:function(e){}},{key:"drawInstrumentBrace",value:function(e,t){}},{key:"drawGroupBracket",value:function(e,t){}},{key:"isVisible",value:function(e){return!0}},{key:"drawMusicSystem",value:function(e){var t=this.getSystemAbsBoundingRect(e),i=this.getSytemBoundingBoxInPixels(t);this.drawMusicSystemComponents(e,i,t)}},{key:"getSytemBoundingBoxInPixels",value:function(e){var t=this.applyScreenTransformationForRect(e);return t.x=Math.round(t.x),t.y=Math.round(t.y),t}},{key:"getSystemAbsBoundingRect",value:function(e){var t=e.PositionAndShape.BoundingRectangle;return new pt(e.PositionAndShape.AbsolutePosition.x+e.PositionAndShape.BorderLeft-1,e.PositionAndShape.AbsolutePosition.y+e.PositionAndShape.BorderTop-1,t.width+6,t.height+2)}},{key:"drawMusicSystemComponents",value:function(e,t,i){var n=this.graphicalMusicSheet.SelectionStartSymbol,r=this.graphicalMusicSheet.SelectionEndSymbol;this.drawingParameters.drawSelectionStartSymbol&&void 0!==n&&this.isVisible(n.PositionAndShape)&&this.drawSelectionStartSymbol(n),this.drawingParameters.drawSelectionEndSymbol&&void 0!==r&&this.isVisible(r.PositionAndShape)&&this.drawSelectionEndSymbol(r);var s,a=o(e.StaffLines);try{for(a.s();!(s=a.n()).done;){var u=s.value;this.drawStaffLine(u),this.rules.RenderLyrics&&(u.LyricsDashes.length>0&&this.drawDashes(u.LyricsDashes),u.LyricLines.length>0&&this.drawLyricLines(u.LyricLines,u))}}catch(A){a.e(A)}finally{a.f()}var l,h=o(e.SystemLines);try{for(h.s();!(l=h.n()).done;){var c=l.value;this.drawSystemLineObject(c)}}catch(A){h.e(A)}finally{h.f()}if(e.Parent===e.Parent.Parent.MusicPages[0]){var f,d=o(e.Labels);try{for(d.s();!(f=d.n()).done;){var p=f.value;p.SVGNode=this.drawLabel(p,Bt.Notes)}}catch(A){d.e(A)}finally{d.f()}}var v,m=this.graphicalMusicSheet.ParentMusicSheet.Instruments,g=m.filter((function(e){return e.Visible})).length,y=o(e.InstrumentBrackets);try{for(y.s();!(v=y.n()).done;){var b=v.value;this.drawInstrumentBrace(b,e)}}catch(A){y.e(A)}finally{y.f()}if(m.length>0)if(g>1){var S,x=o(e.GroupBrackets);try{for(x.s();!(S=x.n()).done;){var k=S.value;this.drawGroupBracket(k,e)}}catch(A){x.e(A)}finally{x.f()}}else{var _,E=o(e.GroupBrackets);try{for(E.s();!(_=E.n()).done;){_.value.Visible=!1}}catch(A){E.e(A)}finally{E.f()}}if(!this.leadSheet){var w,M=o(e.MeasureNumberLabels);try{for(M.s();!(w=M.n()).done;){var T=w.value;T.SVGNode=this.drawLabel(T,Bt.Notes)}}catch(A){M.e(A)}finally{M.f()}}var P,L=o(e.StaffLines);try{for(L.s();!(P=L.n()).done;){var C=P.value;this.drawStaffLineSymbols(C)}}catch(A){L.e(A)}finally{L.f()}this.drawingParameters.drawMarkedAreas&&this.drawMarkedAreas(e)}},{key:"activateSystemRendering",value:function(e,t,i,n){return!0}},{key:"drawSystemLineObject",value:function(e){}},{key:"drawStaffLine",value:function(e){var t,i=o(e.Measures);try{for(i.s();!(t=i.n()).done;){var n=t.value;this.drawMeasure(n)}}catch(r){i.e(r)}finally{i.f()}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)}},{key:"drawLyricLines",value:function(e,t){var i=this;t.LyricLines.forEach((function(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,i.drawGraphicalLine(e,i.rules.LyricUnderscoreLineWidth)}))}},{key:"drawExpressions",value:function(e){}},{key:"drawGraphicalLine",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"black";return this.drawLine(e.Start,e.End,i,t)}},{key:"drawLine",value:function(e,t){}},{key:"drawDashes",value:function(e){var t=this;e.forEach((function(e){return e.SVGNode=t.drawLabel(e,Bt.Notes)}))}},{key:"drawOctaveShifts",value:function(e){}},{key:"drawStaffLines",value:function(e){if(e.StaffLines)for(var t=e.PositionAndShape.AbsolutePosition,i=0;i<5;i++)this.drawLineAsHorizontalRectangleWithOffset(e.StaffLines[i],t,Bt.Notes)}},{key:"drawSymbol",value:function(e,t,i){arguments.length>4&&void 0!==arguments[4]||Bt.Notes}},{key:"leadSheet",get:function(){return this.graphicalMusicSheet.LeadSheet},set:function(e){this.graphicalMusicSheet.LeadSheet=e}},{key:"drawPage",value:function(e){if(this.isVisible(e.PositionAndShape)){var t,i=o(e.MusicSystems);try{for(i.s();!(t=i.n()).done;){var n=t.value;this.isVisible(n.PositionAndShape)&&this.drawMusicSystem(n)}}catch(u){i.e(u)}finally{i.f()}if(e===e.Parent.MusicPages[0]){var r,s=o(e.Labels);try{for(s.s();!(r=s.n()).done;){var a=r.value;a.SVGNode=this.drawLabel(a,Bt.Notes)}}catch(u){s.e(u)}finally{s.f()}}this.drawableBoundingBoxElement&&this.drawBoundingBoxes(e.PositionAndShape,0,this.drawableBoundingBoxElement)}}},{key:"drawBoundingBoxes",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"all",r=e.DataObject.constructor.name,s=!1;"all"===n&&(s=!0),(s||r===n)&&this.drawBoundingBox(e,void 0,!0,r,i),i++,e.ChildElements.forEach((function(e){return t.drawBoundingBoxes(e,i,n)}))}},{key:"drawBoundingBox",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:void 0,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,s=new pt(e.AbsolutePosition.x+e.BorderMarginLeft,e.AbsolutePosition.y+e.BorderMarginTop,e.BorderMarginRight-e.BorderMarginLeft,e.BorderMarginBottom-e.BorderMarginTop);i&&(this.drawLineAsHorizontalRectangle(new Ft(new ft(e.AbsolutePosition.x-1,e.AbsolutePosition.y),new ft(e.AbsolutePosition.x+1,e.AbsolutePosition.y),.1,It.BaseWritingColor,t),r-1),this.drawLineAsVerticalRectangle(new Ft(new ft(e.AbsolutePosition.x,e.AbsolutePosition.y-1),new ft(e.AbsolutePosition.x,e.AbsolutePosition.y+1),.1,It.BaseWritingColor,t),r-1)),s=this.applyScreenTransformationForRect(s);var a=this.renderRectangle(s,Bt.Background,r,t,.5);if(n){var o=new hs(n),u=new ws;u.BitmapWidth=s.width,u.BitmapHeight=s.height,u.FontHeightInPixel=s.height,u.ScreenPosition=new ft(s.x,s.y+12),this.renderLabel(new ls(o,.8,kt.CenterCenter,this.rules),r,u)}return a}},{key:"drawMarkedAreas",value:function(e){var t,i=o(e.GraphicalMarkedAreas);try{for(i.s();!(t=i.n()).done;){var n=t.value;n&&(n.systemRectangle&&this.drawRectangle(n.systemRectangle,Bt.Background),n.settings&&(n.settings.SVGNode=this.drawLabel(n.settings,Bt.Comment)),n.labelRectangle&&this.drawRectangle(n.labelRectangle,Bt.Background),n.label&&(n.label.SVGNode=this.drawLabel(n.label,Bt.Comment)))}}catch(r){i.e(r)}finally{i.f()}}},{key:"drawStaffLineSymbols",value:function(e){var t=e.ParentStaff.ParentInstrument,i=e.PositionAndShape.AbsolutePosition.x,n=e.PositionAndShape.AbsolutePosition.y+2,r=e.PositionAndShape.BorderRight;t.highlight&&this.drawingParameters.drawHighlights&&this.drawLineAsHorizontalRectangle(new Ft(new ft(i,n),new ft(i+r,n),4,It.Highlighted),Bt.Highlight);var s=_s.Disabled,a=ks.PLAY,u=this.drawingParameters.drawActivitySymbols;switch(this.phonicScoreMode){case Es.Midi:a=ks.PLAY,this.midiPlaybackAvailable&&e.ParentStaff.audible&&(s=_s.PlaybackSymbols);break;case Es.Following:a=ks.MIC,e.ParentStaff.following&&(s=_s.FollowSymbols);break;default:u=!1}if(u){var l=new ft(i+r+2,n);this.drawSymbol(a,s,l)}if(this.drawingParameters.drawErrors){var h,c=o(e.Measures);try{for(c.s();!(h=c.n()).done;){var f=h.value,d=f.PositionAndShape,p=d.AbsolutePosition.x,v=d.AbsolutePosition.y+2;f.hasError&&this.graphicalMusicSheet.ParentMusicSheet.DrawErroneousMeasures&&this.drawLineAsHorizontalRectangle(new Ft(new ft(p,v),new ft(p+d.BorderRight,v),4,It.ErrorUnderlay),Bt.MeasureError)}}catch(m){c.e(m)}finally{c.f()}}}}]),e}(),Ts=function(){function e(t){k(this,e),this.fontSize=20,this.fontSizeStandard=this.fontSize;var i=document.createElement("canvas");this.context=i.getContext("2d"),this.rules=t}return E(e,[{key:"computeTextWidthToHeightRatio",value:function(e,t,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:void 0,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:this.fontSize;return this.context.font=Ds.font(r,i,t,this.rules,n),this.context.measureText(e).width/r}},{key:"setFontSize",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.fontSizeStandard;return this.fontSize=e,e}}]),e}(),Ps=function(e){c(i,e);var t=d(i);function i(e,n,r){var s;return k(this,i),(s=t.call(this)).expression=n,s.parentMeasure=r,s.boundingBox=new yt(v(s),e.PositionAndShape),s.parentStaffLine=e,s.parentStaffLine.AbstractExpressions.push(v(s)),s.rules=e.ParentMusicSystem.rules,s}return E(i,[{key:"Label",get:function(){return this.label}},{key:"ParentStaffLine",get:function(){return this.parentStaffLine}},{key:"SourceExpression",get:function(){return this.expression}},{key:"Placement",get:function(){return this.expression.Placement}}]),i}(vt),Ls=function(e){c(i,e);var t=d(i);function i(e,n){var r;return k(this,i),(r=t.call(this,n.PositionAndShape.Parent.DataObject,e,e.parentMeasure)).label=n,r}return E(i,[{key:"GraphicalLabel",get:function(){return this.label}},{key:"updateSkyBottomLine",value:function(){}}]),i}(Ps),Cs=function(e){c(i,e);var t=d(i);function i(e,n,r){var s;return k(this,i),(s=t.call(this,n,e,r.parentSourceMeasure)).mInstantaneousDynamicExpression=e,s.mMeasure=r,s}return E(i,[{key:"updateSkyBottomLine",value:function(){var e=this.parentStaffLine.SkyBottomLineCalculator,t=this.PositionAndShape.RelativePosition.x+this.PositionAndShape.BorderMarginLeft,i=this.PositionAndShape.RelativePosition.x+this.PositionAndShape.BorderMarginRight,n=0;switch(this.Placement){case g.Above:n=this.PositionAndShape.RelativePosition.y+this.PositionAndShape.BorderMarginTop,e.updateSkyLineInRange(t,i,n);break;case g.Below:n=this.PositionAndShape.RelativePosition.y+this.PositionAndShape.BorderMarginBottom,e.updateBottomLineInRange(t,i,n);break;default:L.error("Placement for GraphicalInstantaneousDynamicExpression is unknown")}}}]),i}(Ps),As=function(e){c(i,e);var t=d(i);function i(e,n,r){var s;return k(this,i),(s=t.call(this,n,e,r)).lines=[],s.isSplittedPart=!1,s.notToBeRemoved=!1,s}return E(i,[{key:"StartMeasure",get:function(){return this.startMeasure},set:function(e){this.startMeasure=e}},{key:"EndMeasure",get:function(){return this.endMeasure},set:function(e){this.endMeasure=e}},{key:"EndStaffLine",get:function(){return this.endMeasure?this.endMeasure.ParentStaffLine:void 0}},{key:"IsSplittedPart",get:function(){return this.isSplittedPart},set:function(e){this.isSplittedPart=e}},{key:"IsVerbal",get:function(){return this.ContinuousDynamic.Label&&this.ContinuousDynamic.Label.length>0}},{key:"NotToBeRemoved",get:function(){return this.notToBeRemoved},set:function(e){this.notToBeRemoved=e}},{key:"Lines",get:function(){return this.lines}},{key:"ContinuousDynamic",get:function(){return this.SourceExpression}},{key:"updateSkyBottomLine",value:function(){var e,t=this.parentStaffLine.SkyBottomLineCalculator,i=this.IsVerbal?this.label.PositionAndShape.RelativePosition.x+this.label.PositionAndShape.BorderMarginLeft:0,n=this.IsVerbal?this.label.PositionAndShape.RelativePosition.x+this.label.PositionAndShape.BorderMarginRight:0;(!this.IsVerbal&&this.lines.length<2&&L.warn("Not enough lines for SkyBottomLine calculation"),this.IsVerbal)||this.ContinuousDynamic.DynamicType!==_.crescendo&&this.ContinuousDynamic.DynamicType!==_.diminuendo&&L.warn("GraphicalContinuousDynamicExpression.updateSkyBottomLine(): unhandled continuous dynamic type. start measure: "+(null===(e=this.startMeasure)||void 0===e?void 0:e.MeasureNumber));switch(this.Placement){case g.Above:if(this.IsVerbal){var r=this.label.PositionAndShape.BorderMarginTop+this.label.PositionAndShape.RelativePosition.y;t.updateSkyLineInRange(i,n,r)}else this.ContinuousDynamic.DynamicType===_.crescendo?t.updateSkyLineWithWedge(this.lines[0].Start,this.lines[0].End):this.ContinuousDynamic.DynamicType===_.diminuendo&&t.updateSkyLineWithWedge(this.lines[0].End,this.lines[0].Start);break;case g.Below:if(this.IsVerbal){var s=this.label.PositionAndShape.BorderMarginBottom+this.label.PositionAndShape.RelativePosition.y;t.updateBottomLineInRange(i,n,s)}else this.ContinuousDynamic.DynamicType===_.crescendo?t.updateBottomLineWithWedge(this.lines[1].Start,this.lines[1].End):this.ContinuousDynamic.DynamicType===_.diminuendo&&t.updateBottomLineWithWedge(this.lines[1].End,this.lines[1].Start);break;default:L.error("Placement for GraphicalContinuousDynamicExpression is unknown")}}},{key:"createCrescendoLines",value:function(e,t,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:this.rules.WedgeOpeningLength,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:this.rules.WedgeLineWidth,s=new ft(e,i),a=new ft(t,i-n/2),o=new ft(t,i+n/2);this.addWedgeLines(s,a,o,r)}},{key:"createFirstHalfCrescendoLines",value:function(e,t,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:this.rules.WedgeMeasureEndOpeningLength,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:this.rules.WedgeLineWidth,s=new ft(e,i),a=new ft(t,i-n/2),o=new ft(t,i+n/2);this.addWedgeLines(s,a,o,r)}},{key:"createSecondHalfCrescendoLines",value:function(e,t,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:this.rules.WedgeMeasureBeginOpeningLength,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:this.rules.WedgeOpeningLength,s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:this.rules.WedgeLineWidth,a=new ft(e,i-n/2),o=new ft(e,i+n/2),u=new ft(t,i-r/2),l=new ft(t,i+r/2);this.addDoubleLines(a,u,o,l,s)}},{key:"recalculateCrescendoLines",value:function(e,t,i){var n=Math.abs(this.lines[0].Start.y-this.lines[1].Start.y)>1e-4;this.lines.clear(),n?this.createSecondHalfCrescendoLines(e,t,i):this.isSplittedPart?this.createFirstHalfCrescendoLines(e,t,i):this.createCrescendoLines(e,t,i)}},{key:"createDiminuendoLines",value:function(e,t,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:this.rules.WedgeOpeningLength,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:this.rules.WedgeLineWidth,s=new ft(e,i-n/2),a=new ft(e,i+n/2),o=new ft(t,i);this.addWedgeLines(o,s,a,r)}},{key:"createFirstHalfDiminuendoLines",value:function(e,t,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:this.rules.WedgeOpeningLength,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:this.rules.WedgeMeasureEndOpeningLength,s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:this.rules.WedgeLineWidth,a=new ft(e,i-n/2),o=new ft(e,i+n/2),u=new ft(t,i-r/2),l=new ft(t,i+r/2);this.addDoubleLines(a,u,o,l,s)}},{key:"createSecondHalfDiminuendoLines",value:function(e,t,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:this.rules.WedgeMeasureBeginOpeningLength,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:this.rules.WedgeLineWidth,s=new ft(e,i-n/2),a=new ft(e,i+n/2),o=new ft(t,i);this.addWedgeLines(o,s,a,r)}},{key:"recalculateDiminuendoLines",value:function(e,t,i){var n=Math.abs(this.lines[0].End.y-this.lines[1].End.y)>1e-4;this.lines.clear(),n?this.createFirstHalfDiminuendoLines(e,t,i):this.isSplittedPart?this.createSecondHalfDiminuendoLines(e,t,i):this.createDiminuendoLines(e,t,i)}},{key:"calcPsi",value:function(){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.ContinuousDynamic.DynamicType===_.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))}},{key:"cleanUp",value:function(){this.lines.clear()}},{key:"shiftYPosition",value:function(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)}},{key:"squeeze",value:function(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()))}},{key:"addWedgeLines",value:function(e,t,i,n){var r=new Ft(e,t,n),s=new Ft(e,i,n);this.lines.push(r),this.lines.push(s)}},{key:"addDoubleLines",value:function(e,t,i,n,r){var s=new Ft(e,t,r),a=new Ft(i,n,r);this.lines.push(s),this.lines.push(a)}}]),i}(Ps),Rs=function(e){c(i,e);var t=d(i);function i(e,n,r,s){var a,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:void 0;return k(this,i),(a=t.call(this,e,new m(r),s)).label=n,a.sourceMultiExpression=o,a}return E(i,[{key:"updateSkyBottomLine",value:function(){var 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 g.Above:var n=this.label.PositionAndShape.BorderMarginTop+this.label.PositionAndShape.RelativePosition.y;e.updateSkyLineInRange(t,i,n);break;case g.Below:var r=this.label.PositionAndShape.BorderMarginBottom+this.label.PositionAndShape.RelativePosition.y;e.updateBottomLineInRange(t,i,r);break;default:L.error("Placement for GraphicalUnknownExpression is unknown")}}}]),i}(Ps);Kt.Flow;var Is=10,Ns=function(t){c(n,t);var i=d(n);function n(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new va;return k(this,n),(e=i.call(this,new Ts(t.Rules),t)).backends=[],e.zoom=1,e.pageIdx=0,e.getDotId=function(e,t){return t?String(e.Label.PositionAndShape.RelativePosition[t]):String(e.Label.PositionAndShape.RelativePosition.x)+String(e.Label.PositionAndShape.RelativePosition.y)},e.hasDot=function(e,t,i,n){var r,s=o(t||Object.values(n));try{for(s.s();!(r=s.n()).done;){var a=r.value;if(i)return e.x===a.x&&e.y===a.y;if(e.x===a.x)return!0}}catch(u){s.e(u)}finally{s.f()}return!1},e}return E(n,[{key:"Zoom",get:function(){return this.zoom}},{key:"Backends",get:function(){return this.backends}},{key:"initializeBackendForPage",value:function(e){this.backend=this.backends[e.PageNumber-1]}},{key:"drawSheet",value:function(t){var i,r,s;"gonville"===this.rules.DefaultVexFlowNoteFont&&(Kt.Flow.DEFAULT_FONT_STACK=[null===(i=Kt.Flow.Fonts)||void 0===i?void 0:i.Gonville,null===(r=Kt.Flow.Fonts)||void 0===r?void 0:r.Bravura,null===(s=Kt.Flow.Fonts)||void 0===s?void 0:s.Custom]);Kt.Flow.STAVE_LINE_THICKNESS=this.rules.StaffLineWidth*Is,Kt.Flow.STEM_WIDTH=this.rules.StemWidth*Is,Kt.Flow.DEFAULT_NOTATION_FONT_SCALE=this.rules.VexFlowDefaultNotationFontScale,Kt.Flow.DEFAULT_TAB_FONT_SCALE=this.rules.VexFlowDefaultTabFontScale,this.pageIdx=0;var a,u=o(t.MusicPages);try{for(u.s();!(a=u.n()).done;){var l=a.value;if(l.PageNumber>this.rules.MaxPageToDrawNumber)break;var h=this.backends[this.pageIdx];h.graphicalMusicPage=l,h.scale(this.zoom),this.pageIdx+=1}}catch(c){u.e(c)}finally{u.f()}this.pageIdx=0,this.backend=this.backends[0],e(x(n.prototype),"drawSheet",this).call(this,t)}},{key:"drawPage",value:function(t){t&&(this.backend=this.backends[t.PageNumber-1],e(x(n.prototype),"drawPage",this).call(this,t),this.pageIdx+=1)}},{key:"clear",value:function(){var e,t=o(this.backends);try{for(t.s();!(e=t.n()).done;){e.value.clear()}}catch(i){t.e(i)}finally{t.f()}}},{key:"setZoom",value:function(e){this.zoom=e}},{key:"calculatePixelDistance",value:function(e){return e*Is}},{key:"drawStaffLine",value:function(t){var i=this.backend.getContext().openGroup();i&&i.classList.add("staffline"),e(x(n.prototype),"drawStaffLine",this).call(this,t);var r=t.PositionAndShape.AbsolutePosition;this.rules.RenderSlurs&&this.drawSlurs(t,r),this.backend.getContext().closeGroup()}},{key:"drawSlurs",value:function(e,t){var i,n=o(e.GraphicalSlurs);try{for(n.s();!(i=n.n()).done;){var r=i.value;r.slur.isCrossed()||this.drawSlur(r,t)}}catch(s){n.e(s)}finally{n.f()}}},{key:"drawSlur",value:function(e,t){var i,n,r,s,a=[];"jianpu"===this.rules.DYMusicScoreType?((e.placement>0||e.bezierStartPt.y>0)&&(e.bezierStartPt.y=-.8,e.bezierStartControlPt.y=-2.5),i=new ft(e.bezierStartPt.x+t.x,e.bezierStartPt.y+t.y),n=new ft(e.bezierStartControlPt.x+t.x,e.bezierStartControlPt.y+t.y),r=new ft(e.bezierEndControlPt.x+t.x,e.bezierStartControlPt.y+t.y),s=new ft(e.bezierEndPt.x+t.x,e.bezierStartPt.y+t.y)):(i=new ft(e.bezierStartPt.x+t.x,e.bezierStartPt.y+t.y),n=new ft(e.bezierStartControlPt.x+t.x,e.bezierStartControlPt.y+t.y),r=new ft(e.bezierEndControlPt.x+t.x,e.bezierEndControlPt.y+t.y),s=new ft(e.bezierEndPt.x+t.x,e.bezierEndPt.y+t.y)),a.push(this.applyScreenTransformation(i)),a.push(this.applyScreenTransformation(n)),a.push(this.applyScreenTransformation(r)),a.push(this.applyScreenTransformation(s)),e.placement===g.Above?(i.y-=.05,n.y-=.3,r.y-=.3,s.y-=.05):(i.y+=.05,n.y+=.3,r.y+=.3,s.y+=.05),a.push(this.applyScreenTransformation(i)),a.push(this.applyScreenTransformation(n)),a.push(this.applyScreenTransformation(r)),a.push(this.applyScreenTransformation(s)),e.SVGElement=this.backend.renderCurve(a)}},{key:"drawMeasure",value:function(e){e.setAbsoluteCoordinates(e.PositionAndShape.AbsolutePosition.x*Is,e.PositionAndShape.AbsolutePosition.y*Is);var t=this.backend.getContext();try{e.draw(t)}catch(s){L.warn("VexFlowMusicSheetDrawer.drawMeasure",s)}var i,n=o(e.staffEntries);try{for(n.s();!(i=n.n()).done;){var r=i.value;this.drawStaffEntry(r)}}catch(a){n.e(a)}finally{n.f()}}},{key:"drawLine",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"#FF0000FF",n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.2;return e=this.applyScreenTransformation(e),t=this.applyScreenTransformation(t),this.backend.renderLine(e,t,i,n*Is)}},{key:"DrawOverlayLine",value:function(e,t,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"#FF0000FF",r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:.2;if(!(!i.PageNumber||i.PageNumber>this.backends.length||i.PageNumber<1)){var s=i.PageNumber-1,a=this.backends[s];return e=this.applyScreenTransformation(e),t=this.applyScreenTransformation(t),a.renderLine(e,t,n,r*Is)}console.log("VexFlowMusicSheetDrawer.drawOverlayLine: invalid page number / music page number doesn't correspond to an existing backend.")}},{key:"drawSkyLine",value:function(e){var t=e.PositionAndShape.AbsolutePosition,i=e.PositionAndShape.Size.width;this.drawSampledLine(e.SkyLine,t,i)}},{key:"drawBottomLine",value:function(e){var t=new ft(e.PositionAndShape.AbsolutePosition.x,e.PositionAndShape.AbsolutePosition.y),i=e.PositionAndShape.Size.width;this.drawSampledLine(e.BottomLine,t,i,"#0000FFFF")}},{key:"drawSampledLine",value:function(e,t,i){for(var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"#FF0000FF",r=[],s=0,a=0;a0){var u,l,h=this.rules.SamplingUnit,c=new ft(o.x,o.y),f=new ft(r[0]/h+o.x,o.y);this.drawLine(c,f,n),e[0]>=0&&(u=new ft(r[0]/h+o.x,o.y),l=new ft(r[0]/h+o.x,o.y+e[r[0]]),this.drawLine(u,l,n));for(var d=1;d0){var t,i=o(e.FingeringEntries);try{for(i.s();!(t=i.n()).done;){var n=t.value;n.SVGNode=this.drawLabel(n,Bt.Notes)}}catch(u){i.e(u)}finally{i.f()}}if(void 0!==e.graphicalChordContainers&&e.graphicalChordContainers.length>0){var r,s=o(e.graphicalChordContainers);try{for(s.s();!(r=s.n()).done;){var a=r.value.GraphicalLabel;a.SVGNode=this.drawLabel(a,Bt.Notes)}}catch(u){s.e(u)}finally{s.f()}}this.rules.RenderLyrics&&e.LyricsEntries.length>0&&this.drawLyrics(e.LyricsEntries,Bt.Notes)}},{key:"drawLyrics",value:function(e,t){var i=this;e.forEach((function(e){var n=e.GraphicalLabel;n.SVGNode=i.drawLabel(n,t)}))}},{key:"drawInstrumentBrace",value:function(e,t){e.draw(this.backend.getContext())}},{key:"drawGroupBracket",value:function(e,t){e.draw(this.backend.getContext())}},{key:"drawOctaveShifts",value:function(e){var t,i=o(e.OctaveShifts);try{for(i.s();!(t=i.n()).done;){var n=t.value;if(n){var r=n,s=this.backend.getContext(),a=r.getTextBracket();a.setContext(s);try{a.draw()}catch(u){L.warn(u)}}}}catch(l){i.e(l)}finally{i.f()}}},{key:"drawPedals",value:function(e){var t,i=o(e.Pedals);try{for(i.s();!(t=i.n()).done;){var n=t.value;if(n){var r=n,s=this.backend.getContext(),a=r.getPedalMarking();a.setContext(s),a.draw()}}}catch(u){i.e(u)}finally{i.f()}}},{key:"drawWavyLines",value:function(e){var t,i=o(e.WavyLines);try{for(i.s();!(t=i.n()).done;){var n=t.value;if(n){var r=n,s=this.backend.getContext(),a=r.getVibratoBracket();a.setContext(s),a.draw()}}}catch(u){i.e(u)}finally{i.f()}}},{key:"getMaxExpressionsYAndDots",value:function(e){var t,i=[],n=0,r=o(e.measures);try{for(r.s();!(t=r.n()).done;){var s=t.value;i.push(s.measureNumber)}}catch(M){r.e(M)}finally{r.f()}var a,u={},l={},h={},c=o(e.AbstractExpressions);try{for(c.s();!(a=c.n()).done;){var f=a.value;if(f instanceof Rs&&i.includes(f.parentMeasure.MeasureNumber)){var d=this.getDotId(f),p=this.getDotId(f,"x");l[d]||(l[d]=[]),h[p]||(h[p]=[]),this.hasDot(f.Label.PositionAndShape.RelativePosition,l[d],!0)||(l[d].push(f.Label.PositionAndShape.RelativePosition),h[p].push(f.Label.PositionAndShape.RelativePosition)),u[d]=f.Label.PositionAndShape.RelativePosition}}}catch(M){c.e(M)}finally{c.f()}var v,m=0,g=o(e.AbstractExpressions);try{for(g.s();!(v=g.n()).done;){var y,b=v.value,S=null===(y=b.parentMeasure)||void 0===y?void 0:y.MeasureNumber;if(b instanceof Rs&&i.includes(S)){var x,k=null===(x=b.parentMeasure.verticalMeasureList[0])||void 0===x?void 0:x.stave,_=(null==k?void 0:k.end_x)-(null==k?void 0:k.x),E=this.getDotId(b,"x");if(1===(h[E]||[]).length&&m!==S){var w=b.Label.PositionAndShape.AbsolutePosition.y;n=0===n?w:Math.min(n,w)}1!==(h[E]||[]).length&&_/101){var i=Math.min.apply(Math,a(e.Lines.map((function(e){return e.Start.x}))));e.Lines[0].Start.x=i,e.Lines[1].Start.x=i;var n=[e.Lines[1].Start.y,e.Lines[0].Start.y];e.Lines[0].Start.y=n[0],e.Lines[1].Start.y=n[1],e.Lines[0].End.y+=this.rules.WedgeOpeningLength/2,e.Lines[1].End.y+=this.rules.WedgeOpeningLength}}catch(f){}var r=this.backend.getContext();r.openGroup("lineGroup");var s,u=o(e.Lines);try{for(u.s();!(s=u.n()).done;){var l=s.value,h=new ft(e.ParentStaffLine.PositionAndShape.AbsolutePosition.x+l.Start.x,e.ParentStaffLine.PositionAndShape.AbsolutePosition.y+l.Start.y),c=new ft(e.ParentStaffLine.PositionAndShape.AbsolutePosition.x+l.End.x,e.ParentStaffLine.PositionAndShape.AbsolutePosition.y+l.End.y);this.drawLine(h,c,"black",l.Width)}}catch(d){u.e(d)}finally{u.f()}r.closeGroup()}}},{key:"renderLabel",value:function(e,t,i){return this._renderLabel(e,i)}},{key:"_renderLabel",value:function(e,t){if(e.Label.print){var i,n=e.Label.fontHeight*Is,r=e.Label.font;this.rules.ColoringEnabled&&(i=e.Label.colorDefault,e.Label.color&&(i=e.Label.color.toString()),i||(i=this.rules.DefaultColorLabel));var s,a=e.Label,o=a.fontStyle,u=a.fontFamily;o||(o=this.rules.DefaultFontStyle),u||(u=this.rules.DefaultFontFamily);for(var l=0;l<(null===(h=e.TextLines)||void 0===h?void 0:h.length);l++){var h,c=e.TextLines[l],f=this.calculatePixelDistance(c.xOffset),d=new ft(t.ScreenPosition.x+f,t.ScreenPosition.y),p=this.backend.renderText(n,o,r,c.text,t.FontHeightInPixel,d,i,e.Label.fontFamily);s?s.appendChild(p):s=p,t.ScreenPosition.y=t.ScreenPosition.y+t.FontHeightInPixel,e.TextLines.length>1&&(t.ScreenPosition.y+=this.rules.SpacingBetweenTextLines)}return s}}},{key:"renderRectangle",value:function(e,t,i,n,r){return this.backend.renderRectangle(e,i,n,r)}},{key:"applyScreenTransformation",value:function(e){return new ft(e.x*Is,e.y*Is)}},{key:"applyScreenTransformationForRect",value:function(e){return new pt(e.x*Is,e.y*Is,e.width*Is,e.height*Is)}}]),n}(Ms),Bs=Kt.Flow,Ds=function(){function e(){k(this,e)}return E(e,null,[{key:"durations",value:function(e,t){for(var i=[],n=e.clone();n.RealValue>0;){var r=n.RealValue;if(r>=2)i.push("1/2"),n.Sub(new f(2,1));else if(r>=1)i.push("w"),n.Sub(new f(1,1));else if(r<1&&r>=.5){if(t&&r>.5)return["w"];i.push("h"),n.Sub(new f(1,2))}else if(r<.5&&r>=.25){if(t&&r>.25)return["h"];i.push("q"),n.Sub(new f(1,4))}else if(r<.25&&r>=.125){if(t&&r>.125)return["q"];i.push("8"),n.Sub(new f(1,8))}else if(r<.125&&r>=.0625){if(t&&r>.0625)return["8"];i.push("16"),n.Sub(new f(1,16))}else if(r<.0625&&r>=.03125){if(t&&r>.03125)return["16"];i.push("32"),n.Sub(new f(1,32))}else if(r<.03125&&r>=.015625){if(t&&r>.015625)return["32"];i.push("64"),n.Sub(new f(1,64))}else{if(t)return["64"];i.push("128"),n.Sub(new f(1,128))}}return i}},{key:"pitch",value:function(e,t,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:void 0,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:void 0,s=r;void 0===r&&(s=3),t&&void 0===r&&(s=0,i.ClefType===Gt.F&&(s=2),i.ClefType===Gt.C&&(s=2));var a=Lt[e.FundamentalNote].toLowerCase(),o=At.accidentalVexflow(e.Accidental),u=e.Octave-i.OctaveOffset+s,l="";return n&&(l=this.NoteHeadCode(n)),[a+"n/"+u+l,o,i]}},{key:"restToNotePitch",value:function(e,t){var i=e.Octave;switch(t){case Gt.C:case Gt.F:i+=2;break;case Gt.G:}return new At(e.FundamentalNote,i,Ct.NONE)}},{key:"NoteHeadCode",value:function(e){var t=e.Filled?"2":"1";switch(e.Shape){case Or.NORMAL:return"";case Or.DIAMOND:return"/D"+t;case Or.TRIANGLE:return"/T"+t;case Or.X:return"/X"+t;case Or.CIRCLEX:return"/X3";case Or.RECTANGLE:return"/R"+t;case Or.SQUARE:return"/S"+t;case Or.SLASH:default:return""}}},{key:"GhostNotes",value:function(t){var i,n=[],r=o(e.durations(t,!1));try{for(r.s();!(i=r.n()).done;){var s=i.value;n.push(new Bs.GhostNote({duration:s}))}}catch(a){r.e(a)}finally{r.f()}return n}},{key:"StaveNote",value:function(t){t.sortForVexflow();var i,n=t.notes,r=t.parentStaffEntry.parentMeasure.parentSourceMeasure.Rules,s=n[0],u=[],l=[],h=s.graphicalNoteLength,c=void 0!==s.sourceNote.NoteTuplet,d=e.durations(h,c)[0];void 0!==s.sourceNote.TypeLength&&s.sourceNote.TypeLength!==h&&0!==s.sourceNote.TypeLength.RealValue&&(d=e.durations(s.sourceNote.TypeLength,c)[0],s.numberOfDots=s.sourceNote.DotsXml);var p,v,m,g=void 0,y=s.numberOfDots,b=!1,S=0,x=!1,k=!1,_=o(n);try{for(_.s();!(v=_.n()).done;){var E,w,M=v.value;if(y=1&&N.length-1>=O+1)if(B=null===(C=N[O-1])||void 0===C||null===(A=C.graphicalVoiceEntries[0])||void 0===A?void 0:A.parentVoiceEntry,D=null===(R=N[O+1])||void 0===R||null===(I=R.graphicalVoiceEntries[0])||void 0===I?void 0:I.parentVoiceEntry,B&&D){var G,W=B.Notes[0],U=D.Notes[0];if(null!==(G=W.NoteBeam)&&void 0!==G&&G.Notes.includes(U)&&1!==U.ParentStaffEntry.ParentStaff.StafflineCount){var z=B.Notes.last().Pitch,H=M.Clef(),X=e.pitch(e.restToNotePitch(z.getTransposedPitch(-2),H.ClefType),!1,H);4===z.FundamentalNote&&(u=[X[0]])}}}if(h.RealValue===M.sourceNote.SourceMeasure.ActiveTimeSignature.RealValue&&(u="staff"===r.DYMusicScoreType?["d/5"]:["R/5"],d="w",y=0,b=!0,S=r.WholeRestXShiftVexflow*Is),a(M.sourceNote.ParentStaff.Voices).filter((function(e){return 1!=(null==e?void 0:e.VoiceId)})).length){var Y,j=M.parentVoiceEntry.parentStaffEntry.graphicalVoiceEntries,K=M.parentVoiceEntry.parentVoiceEntry.ParentVoice.VoiceId,q=void 0,J=void 0,Z=o(j);try{for(Z.s();!(Y=Z.n()).done;){var $,Q=o(Y.value.notes);try{for(Q.s();!($=Q.n()).done;){var ee=$.value;if(ee!==M&&!ee.sourceNote.isRest()&&ee.sourceNote.PrintObject){var te=ee.parentVoiceEntry.parentVoiceEntry.WantedStemDirection,ie=1===K||5===K,ne=ie?1:-1,re=ee.sourceNote.Pitch.getHalfTone();(!q||1===ne&&re>q||-1===ne&&re0){var se=3,ae=M.Clef();switch(ae.ClefType){case Gt.F:se=5;break;case Gt.C:se=4}p=At.fromHalftone(q),u=[e.pitch(p,!0,ae,void 0,se)[0]]}}break}M.sourceNote.Notehead&&M.sourceNote.Notehead.Shape===Or.SLASH&&(x=!0);var oe=M.vfpitch;if(null!==(E=oe[2])&&void 0!==E&&null!==(w=E.Parent)&&void 0!==w&&w.Instructions)for(var ue=0,le=oe[2].Parent.Instructions.length;ue0&&"single"===Le){var Ce=new Bs.Tremolo(Pe);Ce.extra_stroke_scale=r.TremoloStrokeScale,Ce.y_spacing_scale=r.TremoloYSpacingScale,m&&"w"===m.duration&&m.stem.setExtension(-9),m.addModifier(Se,Ce)}if(Pe>0&&"start"===Le&&this.noteTremoloList.push(m),Pe>0&&"stop"===Le){this.noteTremoloList.push(m);var Ae=new Bs.Tremolo(Pe,a(this.noteTremoloList));Ae.extra_stroke_scale=1.2,Ae.y_spacing_scale=1.2,Ae.x_shift=-30,m.addModifier(Se,Ae),this.noteTremoloList=[]}if(this.glissandoList.length)m.setVibrato(this.glissandoList[0].vfnote[0]),null===(ke=this.glissandoList[0])||void 0===ke||null===(_e=ke.sourceNote)||void 0===_e||null===(Ee=_e.SourceMeasure)||void 0===Ee||Ee.MeasureNumberXML,null===(we=n[Se])||void 0===we||null===(Me=we.sourceNote)||void 0===Me||null===(Te=Me.SourceMeasure)||void 0===Te||Te.MeasureNumberXML,this.glissandoList=[];"start"===n[Se].sourceNote.glissandoType&&this.glissandoList.push(n[Se])}if(.25===ve.Length.RealValue&&ve.Notehead&&!1===ve.Notehead.Filled)for(var Re=m.getKeyProps(),Ie=0;Ie1&&(m.getKeyProps().filter((function(e){return!e.code&&e.line>3})).length===u.length&&m.setStemDirection(-1));"jianpu"===r.DYMusicScoreType&&window&&window.sett&&window.sett.keySignature&&m.addAccidental(0,new Bs.Accidental("#"));try{!function(){var e,t=["b","#","§","º","X"],i={b:"b","#":"#","§":"n","º":"bb",X:"##"},r=o(n);try{for(r.s();!(e=r.n()).done;){var s,a=e.value,u=a.sourceNote.voiceEntry.Timestamp,l=o(a.sourceNote.SourceMeasure.StaffLinkedExpressions);try{for(l.s();!(s=l.n()).done;){var h,c=o(s.value);try{for(c.s();!(h=c.n()).done;){var d=h.value,p=f.Equal(u,d.Timestamp),v=d.EntriesList.map((function(e){return e.label})).filter((function(e){return t.includes(e)})).map((function(e){return i[e]}));if(p){var g,y=o(v);try{for(y.s();!(g=y.n()).done;){var b=g.value;b&&m.addAnnotation(0,new Bs.Annotation(b))}}catch(De){y.e(De)}finally{y.f()}break}}}catch(De){c.e(De)}finally{c.f()}}}catch(De){l.e(De)}finally{l.f()}}}catch(De){r.e(De)}finally{r.f()}}()}catch(Oe){}return m}},{key:"generateArticulations",value:function(e,t,i){if(e&&"GhostNote"!==e.getAttribute("type")){var n,r=o(t);try{for(r.s();!(n=r.n()).done;){var s=n.value,a=Bs.Modifier.Position.ABOVE;e.getStemDirection()===Bs.Stem.UP&&(a=Bs.Modifier.Position.BELOW);var u=void 0,l=s.articulationEnum;switch(i.ArticulationPlacementFromXML&&(s.placement===g.Above?a=Bs.Modifier.Position.ABOVE:s.placement===g.Below&&(a=Bs.Modifier.Position.BELOW)),l){case as.accent:u=new Bs.Articulation("a>");break;case as.downbow:u=new Bs.Articulation("am"),void 0===s.placement&&(a=Bs.Modifier.Position.ABOVE);break;case as.fermata:u=new Bs.Articulation("a@a"),a=Bs.Modifier.Position.ABOVE;break;case as.marcatodown:u=new Bs.Articulation("a|");break;case as.marcatoup:u=new Bs.Articulation("a^");break;case as.invertedfermata:u=new Bs.Articulation("a@u"),a=Bs.Modifier.Position.BELOW;break;case as.lefthandpizzicato:u=new Bs.Articulation("a+");break;case as.naturalharmonic:u=new Bs.Articulation("ah");break;case as.snappizzicato:u=new Bs.Articulation("ao");break;case as.staccatissimo:u=new Bs.Articulation("av");break;case as.staccato:u=new Bs.Articulation("a.");break;case as.tenuto:u=new Bs.Articulation("a-");break;case as.upbow:u=new Bs.Articulation("a|"),void 0===s.placement&&(a=Bs.Modifier.Position.ABOVE);break;case as.strongaccent:u=new Bs.Articulation("a^")}if(u){var h,c;if(!e.hasStem()&&!e.isRest()&&l==as.accent&&e.getLineNumber()>=3)a=Bs.Modifier.Position.ABOVE,null!=e&&null!==(h=e.modifiers)&&void 0!==h&&null!==(c=h.filter((function(e){return["TREMOLO"].includes(e.getCategory().toLocaleUpperCase())})))&&void 0!==c&&c.length&&u.setYShift(-16);l===as.strongaccent&&(a=Bs.Modifier.Position.ABOVE),u.setPosition(a),e.addModifier(0,u)}}}catch(f){r.e(f)}finally{r.f()}}}},{key:"generateOrnaments",value:function(e,t){var i=Bs.Modifier.Position.ABOVE;t.placement===g.Below&&(i=Bs.Modifier.Position.BELOW);var n=void 0;switch(t.GetOrnament){case Ur.DelayedInvertedTurn:(n=new Bs.Ornament("turn_inverted")).setDelayed(!0);break;case Ur.DelayedTurn:(n=new Bs.Ornament("turn")).setDelayed(!0);break;case Ur.InvertedMordent:(n=new Bs.Ornament("mordent")).setDelayed(!1);break;case Ur.InvertedTurn:(n=new Bs.Ornament("turn_inverted")).setDelayed(!1);break;case Ur.Mordent:(n=new Bs.Ornament("mordent_inverted")).setDelayed(!1);break;case Ur.Trill:(n=new Bs.Ornament("tr")).setDelayed(!1);break;case Ur.Turn:(n=new Bs.Ornament("turn")).setDelayed(!1);break;default:return void L.warn("unhandled OrnamentEnum type: "+t.GetOrnament)}n&&(t.AccidentalBelow!==Ct.NONE&&n.setLowerAccidental(At.accidentalVexflow(t.AccidentalBelow)),t.AccidentalAbove!==Ct.NONE&&n.setUpperAccidental(At.accidentalVexflow(t.AccidentalAbove)),n.setPosition(i),e.addModifier(0,n))}},{key:"StrokeTypeFromArpeggioType",value:function(e){switch(e){case Rr.ARPEGGIO_DIRECTIONLESS:return Bs.Stroke.Type.ARPEGGIO_DIRECTIONLESS;case Rr.BRUSH_DOWN:return Bs.Stroke.Type.BRUSH_UP;case Rr.BRUSH_UP:return Bs.Stroke.Type.BRUSH_DOWN;case Rr.RASQUEDO_DOWN:return Bs.Stroke.Type.RASQUEDO_UP;case Rr.RASQUEDO_UP:return Bs.Stroke.Type.RASQUEDO_DOWN;case Rr.ROLL_DOWN:return Bs.Stroke.Type.ROLL_UP;case Rr.ROLL_UP:return Bs.Stroke.Type.ROLL_DOWN;default:return Bs.Stroke.Type.ARPEGGIO_DIRECTIONLESS}}},{key:"CreateTabNote",value:function(t){var i,n=[],r=t.notes.reverse(),s=[],a=t.notes[0].graphicalNoteLength,u=void 0!==t.notes[0].sourceNote.NoteTuplet,l=e.durations(a,u)[0],h=0,c=o(t.notes);try{var f=function(){var e=i.value,t=e.sourceNote,r={str:t.StringNumberTab,fret:t.FretNumber};n.push(r),t.BendArray&&t.BendArray.forEach((function(e){var t,i=e.bendalter-r.fret;t=i>1?"Full":1===i?"1/2":"1/4","up"===e.direction?s.push({type:Bs.Bend.UP,text:t,width:10}):s.push({type:Bs.Bend.DOWN,text:t,width:10})})),h1&&void 0!==arguments[1]?arguments[1]:"default";switch("default"!==n&&"small"!==n&&(L.warn('Invalid VexFlow clef size "'.concat(n,'" specified. Using "default".')),n="default"),e.ClefType){case Gt.G:switch(e.Line){case 1:t="french";break;case 2:t="treble";break;default:t="treble",L.error("Clef ".concat(Gt[e.ClefType]," on line ").concat(e.Line,' not supported by VexFlow. Using default value "').concat(t,'".'))}break;case Gt.F:switch(e.Line){case 4:t="bass";break;case 3:t="baritone-f";break;case 5:t="subbass";break;default:t="bass",L.error("Clef ".concat(Gt[e.ClefType]," on line ").concat(e.Line,' not supported by VexFlow. Using default value "').concat(t,'".'))}break;case Gt.C:switch(e.Line){case 3:t="alto";break;case 4:t="tenor";break;case 1:t="soprano";break;case 2:t="mezzo-soprano";break;default:t="alto",L.error("Clef ".concat(Gt[e.ClefType]," on line ").concat(e.Line,' not supported by VexFlow. Using default value "').concat(t,'".'))}break;case Gt.percussion:t="percussion";break;case Gt.TAB:t="treble";break;default:L.info("bad clef type: "+e.ClefType),t="treble"}return 1===e.OctaveOffset&&"bass"!==t?i="8va":-1===e.OctaveOffset&&(i="8vb"),{type:t,size:n,annotation:i}}},{key:"TimeSignature",value:function(e){var t;switch(e.SymbolEnum){case lt.NONE:t=e.Rhythm.Numerator+"/"+e.Rhythm.Denominator;break;case lt.COMMON:t="C";break;case lt.CUT:t="C|"}return new Bs.TimeSignature(t)}},{key:"keySignature",value:function(t){if(t){var i;switch(t.Mode){case zt.minor:i=e.minorMap[t.Key]+"m";break;case zt.major:case zt.none:i=e.majorMap[t.Key];break;default:i="C"}return i}}},{key:"line",value:function(e,t){switch(e){case Tr.SingleThin:return t===us.MeasureBegin?Bs.StaveConnector.type.SINGLE:Bs.StaveConnector.type.SINGLE_RIGHT;case Tr.DoubleThin:return Bs.StaveConnector.type.THIN_DOUBLE;case Tr.ThinBold:return Bs.StaveConnector.type.BOLD_DOUBLE_RIGHT;case Tr.BoldThinDots:return Bs.StaveConnector.type.BOLD_DOUBLE_LEFT;case Tr.DotsThinBold:case Tr.DotsBoldBoldDots:return Bs.StaveConnector.type.BOLD_DOUBLE_RIGHT;case Tr.None:return Bs.StaveConnector.type.NONE}}},{key:"font",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Et.Regular,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:wt.TimesNewRoman,n=arguments.length>3?arguments[3]:void 0,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:void 0,s="normal",a="normal",o="'".concat(n.DefaultFontFamily,"'");switch(t){case Et.Bold:a="bold";break;case Et.Italic:s="italic";break;case Et.BoldItalic:s="italic",a="bold";break;case Et.Underlined:}switch(i){case wt.Kokila:}return r&&"default"!==r&&(o="'".concat(r,"'")),s+" "+a+" "+Math.floor(e)+"px "+o}},{key:"fontStyle",value:function(e){switch(e){case Et.Bold:return"bold";case Et.Italic:return"italic";case Et.BoldItalic:return"italic bold";default:return"normal"}}},{key:"style",value:function(e){return Nt.getValue(e)}}]),e}();Ds.majorMap={"-1":"F","-2":"Bb","-3":"Eb","-4":"Ab","-5":"Db","-6":"Gb","-7":"Cb","-8":"Fb",0:"C",1:"G",2:"D",3:"A",4:"E",5:"B",6:"F#",7:"C#",8:"G#"},Ds.minorMap={"-1":"D","-2":"G","-3":"C","-4":"F","-5":"Bb","-6":"Eb","-7":"Ab","-8":"Db",0:"A",1:"E",2:"B",3:"F#",4:"C#",5:"G#",6:"D#",7:"A#",8:"E#"},Ds.noteTremoloList=[],Ds.glissandoList=[];var Os=function(){function e(t,i){k(this,e),this.numberXml=1,this.setOctaveShiftValue(t,i)}return E(e,[{key:"Type",get:function(){return this.octaveValue},set:function(e){this.octaveValue=e}},{key:"StaffNumber",get:function(){return this.staffNumber},set:function(e){this.staffNumber=e}},{key:"ParentStartMultiExpression",get:function(){return this.startMultiExpression},set:function(e){this.startMultiExpression=e}},{key:"ParentEndMultiExpression",get:function(){return this.endMultiExpression},set:function(e){this.endMultiExpression=e}},{key:"setOctaveShiftValue",value:function(e,t){this.octaveValue=1===t&&"down"===e?Fs.VA8:1===t&&"up"===e?Fs.VB8:2===t&&"down"===e?Fs.MA15:2===t&&"up"===e?Fs.MB15:Fs.NONE}}],[{key:"getPitchFromOctaveShift",value:function(e,t){if(e){var i=e.Octave;switch(t){case Fs.VA8:i-=1;break;case Fs.VB8:i+=1;break;case Fs.MA15:i-=2;break;case Fs.MB15:i+=2;break;case Fs.NONE:default:i+=0}return new At(e.FundamentalNote,i,e.Accidental)}}}]),e}(),Fs=function(e){return 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}(Fs||{}),Vs=function(e){c(i,e);var t=d(i);function i(e,n,r,s){var a;return k(this,i),(a=t.call(this,n)).label=e,a.staffNumber=r,a.parentMultiTempoExpression=s,a}return E(i,[{key:"Label",get:function(){return this.label},set:function(e){this.label=e}},{key:"Placement",get:function(){return this.placement},set:function(e){this.placement=e}},{key:"StaffNumber",get:function(){return this.staffNumber},set:function(e){this.staffNumber=e}},{key:"ParentMultiTempoExpression",get:function(){return this.parentMultiTempoExpression}}],[{key:"isStringInStringList",value:function(e,t){var n,r=o(e);try{for(r.s();!(n=r.n()).done;){var s=n.value;if(i.stringContainsSeparatedWord(t.toLowerCase().trim(),s.toLowerCase().trim()))return!0}}catch(a){r.e(a)}finally{r.f()}return!1}},{key:"stringContainsSeparatedWord",value:function(e,t){return e===t||-1!==e.indexOf(" "+t)||-1!==e.indexOf(t+" ")}}]),i}(m),Gs=function(e){c(i,e);var t=d(i);function i(e,n,r,s,a){var o;return k(this,i),(o=t.call(this,e,n,r,a)).setTempoAndTempoType(s),o}return E(i,[{key:"Label",get:function(){return this.label},set:function(e){this.label=e}},{key:"Placement",get:function(){return this.placement},set:function(e){this.placement=e}},{key:"StaffNumber",get:function(){return this.staffNumber},set:function(e){this.staffNumber=e}},{key:"Enum",get:function(){return this.tempoEnum}},{key:"TempoInBpm",get:function(){return this.tempoInBpm},set:function(e){this.tempoInBpm=e}},{key:"ParentMultiTempoExpression",get:function(){return this.parentMultiTempoExpression}},{key:"getAbsoluteTimestamp",value:function(){return f.plus(this.ParentMultiTempoExpression.SourceMeasureParent.AbsoluteTimestamp,this.ParentMultiTempoExpression.Timestamp)}},{key:"getAbsoluteFloatTimestamp",value:function(){return f.plus(this.ParentMultiTempoExpression.SourceMeasureParent.AbsoluteTimestamp,this.ParentMultiTempoExpression.Timestamp).RealValue}},{key:"setTempoAndTempoType",value:function(e){return this.label?i.isStringInStringList(i.listInstantaneousTempoLarghissimo,this.label)?(0===e&&(e=i.getDefaultValueForTempoType(Ws.larghissimo)),this.tempoInBpm=e,void(this.tempoEnum=Ws.larghissimo)):i.isStringInStringList(i.listInstantaneousTempoGrave,this.label)?(0===e&&(e=i.getDefaultValueForTempoType(Ws.grave)),this.tempoInBpm=e,void(this.tempoEnum=Ws.grave)):i.isStringInStringList(i.listInstantaneousTempoLento,this.label)?(0===e&&(e=i.getDefaultValueForTempoType(Ws.lento)),this.tempoInBpm=e,void(this.tempoEnum=Ws.lento)):i.isStringInStringList(i.listInstantaneousTempoLargo,this.label)?(0===e&&(e=i.getDefaultValueForTempoType(Ws.largo)),this.tempoInBpm=e,void(this.tempoEnum=Ws.largo)):i.isStringInStringList(i.listInstantaneousTempoLarghetto,this.label)?(0===e&&(e=i.getDefaultValueForTempoType(Ws.larghetto)),this.tempoInBpm=e,void(this.tempoEnum=Ws.larghetto)):i.isStringInStringList(i.listInstantaneousTempoAdagio,this.label)?(0===e&&(e=i.getDefaultValueForTempoType(Ws.adagio)),this.tempoInBpm=e,void(this.tempoEnum=Ws.adagio)):i.isStringInStringList(i.listInstantaneousTempoAdagietto,this.label)?(0===e&&(e=i.getDefaultValueForTempoType(Ws.adagietto)),this.tempoInBpm=e,void(this.tempoEnum=Ws.adagietto)):i.isStringInStringList(i.listInstantaneousTempoAndanteModerato,this.label)?(0===e&&(e=i.getDefaultValueForTempoType(Ws.andanteModerato)),this.tempoInBpm=e,void(this.tempoEnum=Ws.andanteModerato)):i.isStringInStringList(i.listInstantaneousTempoAndante,this.label)?(0===e&&(e=i.getDefaultValueForTempoType(Ws.andante)),this.tempoInBpm=e,void(this.tempoEnum=Ws.andante)):i.isStringInStringList(i.listInstantaneousTempoAndantino,this.label)?(0===e&&(e=i.getDefaultValueForTempoType(Ws.andantino)),this.tempoInBpm=e,void(this.tempoEnum=Ws.andantino)):i.isStringInStringList(i.listInstantaneousTempoModerato,this.label)?(0===e&&(e=i.getDefaultValueForTempoType(Ws.moderato)),this.tempoInBpm=e,void(this.tempoEnum=Ws.moderato)):i.isStringInStringList(i.listInstantaneousTempoAllegretto,this.label)?(0===e&&(e=i.getDefaultValueForTempoType(Ws.allegretto)),this.tempoInBpm=e,void(this.tempoEnum=Ws.allegretto)):i.isStringInStringList(i.listInstantaneousTempoAllegroModerato,this.label)?(0===e&&(e=i.getDefaultValueForTempoType(Ws.allegroModerato)),this.tempoInBpm=e,void(this.tempoEnum=Ws.allegroModerato)):i.isStringInStringList(i.listInstantaneousTempoAllegro,this.label)?(0===e&&(e=i.getDefaultValueForTempoType(Ws.allegro)),this.tempoInBpm=e,void(this.tempoEnum=Ws.allegro)):i.isStringInStringList(i.listInstantaneousTempoVivace,this.label)?(0===e&&(e=i.getDefaultValueForTempoType(Ws.vivace)),this.tempoInBpm=e,void(this.tempoEnum=Ws.vivace)):i.isStringInStringList(i.listInstantaneousTempoVivacissimo,this.label)?(0===e&&(e=i.getDefaultValueForTempoType(Ws.vivacissimo)),this.tempoInBpm=e,void(this.tempoEnum=Ws.vivacissimo)):i.isStringInStringList(i.listInstantaneousTempoAllegrissimo,this.label)?(0===e&&(e=i.getDefaultValueForTempoType(Ws.allegrissimo)),this.tempoInBpm=e,void(this.tempoEnum=Ws.allegrissimo)):i.isStringInStringList(i.listInstantaneousTempoPresto,this.label)?(0===e&&(e=i.getDefaultValueForTempoType(Ws.presto)),this.tempoInBpm=e,void(this.tempoEnum=Ws.presto)):i.isStringInStringList(i.listInstantaneousTempoPrestissimo,this.label)?(0===e&&(e=i.getDefaultValueForTempoType(Ws.prestissimo)),this.tempoInBpm=e,void(this.tempoEnum=Ws.prestissimo)):i.isStringInStringList(i.listInstantaneousTempoAddons,this.label)?(this.tempoInBpm=0,void(this.tempoEnum=Ws.addon)):i.isStringInStringList(i.listInstantaneousTempoChangesGeneral,this.label)?(this.tempoInBpm=0,void(this.tempoEnum=Ws.changes)):void 0:(this.tempoInBpm=e,void(this.tempoEnum=Ws.metronomeMark))}}],[{key:"getDefaultValueForTempoType",value:function(e){switch(e){case Ws.larghissimo:return 20;case Ws.grave:return 30;case Ws.lento:return 48;case Ws.largo:return 52;case Ws.larghetto:return 63;case Ws.adagio:return 70;case Ws.adagietto:return 75;case Ws.andanteModerato:return 88;case Ws.andante:return 92;case Ws.andantino:return 96;case Ws.moderato:return 106;case Ws.allegretto:return 112;case Ws.allegroModerato:return 118;case Ws.allegro:return 130;case Ws.vivace:return 140;case Ws.vivacissimo:return 155;case Ws.allegrissimo:return 170;case Ws.presto:return 184;case Ws.prestissimo:return 200;default:throw new T("tempoEnum")}}},{key:"isInputStringInstantaneousTempo",value:function(e){return!!e&&(i.isStringInStringList(i.listInstantaneousTempoLarghissimo,e)||i.isStringInStringList(i.listInstantaneousTempoGrave,e)||i.isStringInStringList(i.listInstantaneousTempoLento,e)||i.isStringInStringList(i.listInstantaneousTempoLargo,e)||i.isStringInStringList(i.listInstantaneousTempoLarghetto,e)||i.isStringInStringList(i.listInstantaneousTempoAdagio,e)||i.isStringInStringList(i.listInstantaneousTempoAdagietto,e)||i.isStringInStringList(i.listInstantaneousTempoAndanteModerato,e)||i.isStringInStringList(i.listInstantaneousTempoAndante,e)||i.isStringInStringList(i.listInstantaneousTempoAndantino,e)||i.isStringInStringList(i.listInstantaneousTempoModerato,e)||i.isStringInStringList(i.listInstantaneousTempoAllegretto,e)||i.isStringInStringList(i.listInstantaneousTempoAllegroModerato,e)||i.isStringInStringList(i.listInstantaneousTempoAllegro,e)||i.isStringInStringList(i.listInstantaneousTempoVivace,e)||i.isStringInStringList(i.listInstantaneousTempoVivacissimo,e)||i.isStringInStringList(i.listInstantaneousTempoAllegrissimo,e)||i.isStringInStringList(i.listInstantaneousTempoPresto,e)||i.isStringInStringList(i.listInstantaneousTempoPrestissimo,e)||i.isStringInStringList(i.listInstantaneousTempoChangesGeneral,e))}}]),i}(Vs);Gs.listInstantaneousTempoLarghissimo=["Larghissimo","Sehr breit","very, very slow"],Gs.listInstantaneousTempoGrave=["Grave","Schwer","slow and solemn"],Gs.listInstantaneousTempoLento=["Lento","Lent","Langsam","slowly"],Gs.listInstantaneousTempoLargo=["Largo","Breit","broadly"],Gs.listInstantaneousTempoLarghetto=["Larghetto","Etwas breit","rather broadly"],Gs.listInstantaneousTempoAdagio=["Adagio","Langsam","Ruhig","slow and stately"],Gs.listInstantaneousTempoAdagietto=["Adagietto","Ziemlich ruhig","Ziemlich langsam","rather slow"],Gs.listInstantaneousTempoAndanteModerato=["Andante moderato"],Gs.listInstantaneousTempoAndante=["Andante","Gehend","Schreitend","at a walking pace"],Gs.listInstantaneousTempoAndantino=["Andantino"],Gs.listInstantaneousTempoModerato=["Moderato","Mäßig","Mod�r�","moderately"],Gs.listInstantaneousTempoAllegretto=["Allegretto","fast"],Gs.listInstantaneousTempoAllegroModerato=["Allegro moderato"],Gs.listInstantaneousTempoAllegro=["Allegro","Rapide","Vite","Rasch","Schnell","Fr�hlich"],Gs.listInstantaneousTempoVivace=["Vivace","Lebhaft","Lebendig","lively and fast"],Gs.listInstantaneousTempoVivacissimo=["Vivacissimo","Sehr lebhaft","Sehr lebendig"],Gs.listInstantaneousTempoAllegrissimo=["Allegrissimo","very fast"],Gs.listInstantaneousTempoPresto=["Presto","Sehr schnell","Geschwind"],Gs.listInstantaneousTempoPrestissimo=["Prestissimo","äußerst schnell"],Gs.listInstantaneousTempoChangesGeneral=["tempo primo","a tempo","tempo i","rubato","doppio movimento"],Gs.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 Ws=function(e){return 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}(Ws||{}),Us=function(e){c(i,e);var t=d(i);function i(e,n,r){var s;return k(this,i),(s=t.call(this,n)).label=e,s.staffNumber=r,s.setMoodType(),s}return E(i,[{key:"Label",get:function(){return this.label},set:function(e){this.label=e}},{key:"Mood",get:function(){return this.moodType},set:function(e){this.moodType=e}},{key:"StaffNumber",get:function(){return this.staffNumber},set:function(e){this.staffNumber=e}},{key:"Placement",get:function(){return this.placement},set:function(e){this.placement=e}},{key:"setMoodType",value:function(){i.isStringInStringList(i.listMoodAffettuoso,this.label)?this.moodType=zs.Affettuoso:i.isStringInStringList(i.listMoodAgitato,this.label)?this.moodType=zs.Agitato:i.isStringInStringList(i.listMoodAnimato,this.label)?this.moodType=zs.Animato:i.isStringInStringList(i.listMoodAppassionato,this.label)?this.moodType=zs.Appassionato:i.isStringInStringList(i.listMoodBrillante,this.label)?this.moodType=zs.Brillante:i.isStringInStringList(i.listMoodCantabile,this.label)?this.moodType=zs.Cantabile:i.isStringInStringList(i.listMoodDolce,this.label)?this.moodType=zs.Dolce:i.isStringInStringList(i.listMoodEnergico,this.label)?this.moodType=zs.Energico:i.isStringInStringList(i.listMoodEroico,this.label)?this.moodType=zs.Eroico:i.isStringInStringList(i.listMoodEspressivo,this.label)?this.moodType=zs.Espressivo:i.isStringInStringList(i.listMoodFurioso,this.label)?this.moodType=zs.Furioso:i.isStringInStringList(i.listMoodGiocoso,this.label)?this.moodType=zs.Giocoso:i.isStringInStringList(i.listMoodGioioso,this.label)?this.moodType=zs.Gioioso:i.isStringInStringList(i.listMoodGrandioso,this.label)?this.moodType=zs.Grandioso:i.isStringInStringList(i.listMoodGrazioso,this.label)?this.moodType=zs.Grazioso:i.isStringInStringList(i.listMoodLacrimoso,this.label)?this.moodType=zs.Lacrimoso:i.isStringInStringList(i.listMoodLeggiero,this.label)?this.moodType=zs.Leggiero:i.isStringInStringList(i.listMoodMaestoso,this.label)?this.moodType=zs.Maestoso:i.isStringInStringList(i.listMoodMalinconico,this.label)?this.moodType=zs.Malinconico:i.isStringInStringList(i.listMoodMarcato,this.label)?this.moodType=zs.Marcato:i.isStringInStringList(i.listMoodMarziale,this.label)?this.moodType=zs.Marziale:i.isStringInStringList(i.listMoodMesto,this.label)?this.moodType=zs.Mesto:i.isStringInStringList(i.listMoodMorendo,this.label)?this.moodType=zs.Morendo:i.isStringInStringList(i.listMoodNobilmente,this.label)?this.moodType=zs.Nobilmente:i.isStringInStringList(i.listMoodPatetico,this.label)?this.moodType=zs.Patetico:i.isStringInStringList(i.listMoodPesante,this.label)?this.moodType=zs.Pesante:i.isStringInStringList(i.listMoodSaltando,this.label)?this.moodType=zs.Saltando:i.isStringInStringList(i.listMoodSautille,this.label)?this.moodType=zs.Sautille:i.isStringInStringList(i.listMoodScherzando,this.label)?this.moodType=zs.Scherzando:i.isStringInStringList(i.listMoodSostenuto,this.label)?this.moodType=zs.Sostenuto:i.isStringInStringList(i.listMoodSpiccato,this.label)?this.moodType=zs.Spiccato:i.isStringInStringList(i.listMoodTenerezza,this.label)?this.moodType=zs.Tenerezza:i.isStringInStringList(i.listMoodTranquillamente,this.label)?this.moodType=zs.Tranquillamente:i.isStringInStringList(i.listMoodTrionfante,this.label)&&(this.moodType=zs.Trionfante)}}],[{key:"isInputStringMood",value:function(e){return!!e&&(i.isStringInStringList(i.listMoodAffettuoso,e)||i.isStringInStringList(i.listMoodAgitato,e)||i.isStringInStringList(i.listMoodAnimato,e)||i.isStringInStringList(i.listMoodAppassionato,e)||i.isStringInStringList(i.listMoodBrillante,e)||i.isStringInStringList(i.listMoodCantabile,e)||i.isStringInStringList(i.listMoodDolce,e)||i.isStringInStringList(i.listMoodEnergico,e)||i.isStringInStringList(i.listMoodEroico,e)||i.isStringInStringList(i.listMoodEspressivo,e)||i.isStringInStringList(i.listMoodFurioso,e)||i.isStringInStringList(i.listMoodGiocoso,e)||i.isStringInStringList(i.listMoodGioioso,e)||i.isStringInStringList(i.listMoodGrandioso,e)||i.isStringInStringList(i.listMoodGrazioso,e)||i.isStringInStringList(i.listMoodLacrimoso,e)||i.isStringInStringList(i.listMoodLeggiero,e)||i.isStringInStringList(i.listMoodMaestoso,e)||i.isStringInStringList(i.listMoodMalinconico,e)||i.isStringInStringList(i.listMoodMarcato,e)||i.isStringInStringList(i.listMoodMarziale,e)||i.isStringInStringList(i.listMoodMesto,e)||i.isStringInStringList(i.listMoodMorendo,e)||i.isStringInStringList(i.listMoodNobilmente,e)||i.isStringInStringList(i.listMoodPatetico,e)||i.isStringInStringList(i.listMoodPesante,e)||i.isStringInStringList(i.listMoodSaltando,e)||i.isStringInStringList(i.listMoodSautille,e)||i.isStringInStringList(i.listMoodScherzando,e)||i.isStringInStringList(i.listMoodSostenuto,e)||i.isStringInStringList(i.listMoodSpiccato,e)||i.isStringInStringList(i.listMoodTenerezza,e)||i.isStringInStringList(i.listMoodTranquillamente,e)||i.isStringInStringList(i.listMoodTrionfante,e))}}]),i}(m);Us.listMoodAffettuoso=["affettuoso"],Us.listMoodAgitato=["agitato"],Us.listMoodAppassionato=["appassionato"],Us.listMoodAnimato=["animato","lively"],Us.listMoodBrillante=["brillante"],Us.listMoodCantabile=["cantabile"],Us.listMoodDolce=["dolce"],Us.listMoodEnergico=["energico"],Us.listMoodEroico=["eroico"],Us.listMoodEspressivo=["espressivo"],Us.listMoodFurioso=["furioso"],Us.listMoodGiocoso=["giocoso"],Us.listMoodGioioso=["gioioso"],Us.listMoodLacrimoso=["lacrimoso"],Us.listMoodGrandioso=["grandioso"],Us.listMoodGrazioso=["grazioso"],Us.listMoodLeggiero=["leggiero"],Us.listMoodMaestoso=["maestoso"],Us.listMoodMalinconico=["malinconico"],Us.listMoodMarcato=["marcato"],Us.listMoodMarziale=["marziale"],Us.listMoodMesto=["mesto"],Us.listMoodMorendo=["morendo"],Us.listMoodNobilmente=["nobilmente"],Us.listMoodPatetico=["patetico"],Us.listMoodPesante=["pesante"],Us.listMoodSautille=["sautille"],Us.listMoodSaltando=["saltando"],Us.listMoodScherzando=["scherzando"],Us.listMoodSostenuto=["sostenuto"],Us.listMoodSpiccato=["spiccato"],Us.listMoodTenerezza=["tenerezza"],Us.listMoodTranquillamente=["tranquillamente"],Us.listMoodTrionfante=["trionfante"];var zs=function(e){return e[e.Affettuoso=0]="Affettuoso",e[e.Agitato=1]="Agitato",e[e.Appassionato=2]="Appassionato",e[e.Animato=3]="Animato",e[e.Brillante=4]="Brillante",e[e.Cantabile=5]="Cantabile",e[e.Dolce=6]="Dolce",e[e.Energico=7]="Energico",e[e.Eroico=8]="Eroico",e[e.Espressivo=9]="Espressivo",e[e.Furioso=10]="Furioso",e[e.Giocoso=11]="Giocoso",e[e.Gioioso=12]="Gioioso",e[e.Lacrimoso=13]="Lacrimoso",e[e.Grandioso=14]="Grandioso",e[e.Grazioso=15]="Grazioso",e[e.Leggiero=16]="Leggiero",e[e.Maestoso=17]="Maestoso",e[e.Malinconico=18]="Malinconico",e[e.Marcato=19]="Marcato",e[e.Marziale=20]="Marziale",e[e.Mesto=21]="Mesto",e[e.Morendo=22]="Morendo",e[e.Nobilmente=23]="Nobilmente",e[e.Patetico=24]="Patetico",e[e.Pesante=25]="Pesante",e[e.Sautille=26]="Sautille",e[e.Saltando=27]="Saltando",e[e.Scherzando=28]="Scherzando",e[e.Sostenuto=29]="Sostenuto",e[e.Spiccato=30]="Spiccato",e[e.Tenerezza=31]="Tenerezza",e[e.Tranquillamente=32]="Tranquillamente",e[e.Trionfante=33]="Trionfante",e[e.Vivace=34]="Vivace",e}(zs||{}),Hs=function(e){c(i,e);var t=d(i);function i(e,n,r,s){var a;return k(this,i),(a=t.call(this,n)).label=e,a.staffNumber=s,void 0===r&&(r=kt.LeftBottom),a.textAlignment=r,a}return E(i,[{key:"Label",get:function(){return this.label}},{key:"Placement",get:function(){return this.placement},set:function(e){this.placement=e}},{key:"StaffNumber",get:function(){return this.staffNumber},set:function(e){this.staffNumber=e}},{key:"TextAlignment",get:function(){return this.textAlignment}}]),i}(m),Xs=function(){function e(t,i){k(this,e),this.unknownList=[],this.moodList=[],this.expressions=[],this.sourceMeasure=t,this.timestamp=i}return E(e,[{key:"SourceMeasureParent",get:function(){return this.sourceMeasure},set:function(e){this.sourceMeasure=e}},{key:"StaffNumber",get:function(){return this.staffNumber},set:function(e){this.staffNumber=e}},{key:"Timestamp",get:function(){return this.timestamp},set:function(e){this.timestamp=e}},{key:"AbsoluteTimestamp",get:function(){return f.plus(this.timestamp,this.sourceMeasure.AbsoluteTimestamp)}},{key:"InstantaneousDynamic",get:function(){return this.instantaneousDynamic},set:function(e){this.instantaneousDynamic=e}},{key:"EndingContinuousDynamic",get:function(){return this.endingContinuousDynamic},set:function(e){this.endingContinuousDynamic=e}},{key:"StartingContinuousDynamic",get:function(){return this.startingContinuousDynamic},set:function(e){this.startingContinuousDynamic=e}},{key:"MoodList",get:function(){return this.moodList}},{key:"UnknownList",get:function(){return this.unknownList}},{key:"EntriesList",get:function(){return this.expressions}},{key:"OctaveShiftStart",get:function(){return this.octaveShiftStart},set:function(e){this.octaveShiftStart=e}},{key:"OctaveShiftEnd",get:function(){return this.octaveShiftEnd},set:function(e){this.octaveShiftEnd=e}},{key:"CombinedExpressionsText",get:function(){return this.combinedExpressionsText},set:function(e){this.combinedExpressionsText=e}},{key:"getPlacementOfFirstEntry",value:function(){var e=g.Above;return this.expressions.length>0&&(this.expressions[0].expression instanceof rt||this.expressions[0].expression instanceof S||this.expressions[0].expression instanceof Us||this.expressions[0].expression instanceof Hs)&&(e=this.expressions[0].expression.Placement),e}},{key:"getFontstyleOfFirstEntry",value:function(){var e=Et.Regular;if(this.expressions.length>0)if(this.expressions[0].expression instanceof S)e=Et.Italic;else if(this.expressions[0].expression instanceof Us)e=Et.Italic;else if(this.expressions[0].expression instanceof Hs){var t;e=null!==(t=this.expressions[0].expression.fontStyle)&&void 0!==t?t:Et.Regular}return e}},{key:"addExpression",value:function(e,t){e instanceof rt?(this.instantaneousDynamic&&this.removeExpressionFromEntryList(this.InstantaneousDynamic),this.instantaneousDynamic=e,this.instantaneousDynamic.ParentMultiExpression=this):e instanceof S?this.startingContinuousDynamic=e:e instanceof Us?this.moodList.push(e):e instanceof Hs&&this.unknownList.push(e),this.addExpressionToEntryList(e,t)}},{key:"CompareTo",value:function(e){return this.Timestamp.RealValue>e.Timestamp.RealValue?1:this.Timestamp.RealValue=Ks.allargando&&e<=Ks.ritenuto}}]),i}(Vs);js.listContinuousTempoFaster=["accelerando","piu mosso","poco piu","stretto"],js.listContinuousTempoSlower=["poco meno","meno mosso","piu lento","rallentando","ritardando","ritenuto","ritard.","ritard","riten.","riten"];var Ks=function(e){return e[e.accelerando=0]="accelerando",e[e.stretto=1]="stretto",e[e.stringendo=2]="stringendo",e[e.mosso=3]="mosso",e[e.piuMosso=4]="piuMosso",e[e.allargando=5]="allargando",e[e.calando=6]="calando",e[e.menoMosso=7]="menoMosso",e[e.rallentando=8]="rallentando",e[e.ritardando=9]="ritardando",e[e.ritard=10]="ritard",e[e.rit=11]="rit",e[e.ritenuto=12]="ritenuto",e[e.rubato=13]="rubato",e[e.precipitando=14]="precipitando",e}(Ks||{}),qs=function(){function e(t,i){k(this,e),this.expressions=[],this.sourceMeasure=t,this.timestamp=i}return E(e,[{key:"Timestamp",get:function(){return this.timestamp}},{key:"AbsoluteTimestamp",get:function(){return f.plus(this.sourceMeasure.AbsoluteTimestamp,this.timestamp)}},{key:"SourceMeasureParent",get:function(){return this.sourceMeasure},set:function(e){this.sourceMeasure=e}},{key:"InstantaneousTempo",get:function(){return this.instantaneousTempo}},{key:"ContinuousTempo",get:function(){return this.continuousTempo}},{key:"EntriesList",get:function(){return this.expressions}},{key:"CombinedExpressionsText",get:function(){return this.combinedExpressionsText},set:function(e){this.combinedExpressionsText=e}},{key:"getPlacementOfFirstEntry",value:function(){var e=g.Above;return this.expressions.length>0&&(this.expressions[0].Expression instanceof Gs||this.expressions[0].Expression instanceof js)&&(e=this.expressions[0].Expression.Placement),e}},{key:"getFontstyleOfFirstEntry",value:function(){var e=Et.Regular;return this.expressions[0].Expression instanceof Gs?e=Et.Bold:this.expressions[0].Expression instanceof js&&(e=Et.Italic),e}},{key:"addExpression",value:function(e,t){if(!this.checkIfAlreadyExists(e)){e instanceof Gs?this.instantaneousTempo=e:e instanceof js&&(this.continuousTempo=e);var i=new Js;i.prefix=t,i.Expression=e,i.label=e.Label,this.expressions.push(i)}}},{key:"CompareTo",value:function(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}},{key:"calculateSystemYLayout",value:function(){var e,t=o(this.musicSystems);try{for(t.s();!(e=t.n()).done;){var i=e.value;this.optimizeDistanceBetweenStaffLines(i)}}catch(n){t.e(n)}finally{t.f()}this.calculateMusicSystemsRelativePositions()}},{key:"setMeasureWidth",value:function(e,t,i,n){for(var r=0,s=e.length;r0&&(a.beginInstructionsWidth=i),n>0&&(a.endInstructionsWidth=n)}}},{key:"finalizeCurrentAndCreateNewSystem",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];this.finalizeCurrentSystem(e,t,i,n),this.currentSystemParams=new Qs,void 0!==e&&this.measureListIndex1&&void 0!==arguments[1]&&arguments[1],i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];this.currentSystemParams.currentSystem.breaksPage=n,this.adaptRepetitionLineWithIfNeeded(),void 0!==e&&i&&this.checkAndCreateExtraInstructionMeasure(e),this.stretchMusicSystem(t)}},{key:"adaptRepetitionLineWithIfNeeded",value:function(){var e=this.currentSystemParams.systemMeasures;if(e.length>=1){var t=this.currentSystemParams.currentSystem.GraphicalMeasures[this.currentSystemParams.currentSystem.GraphicalMeasures.length-1],i=0,n=e[e.length-1];n.endLine===Tr.DotsBoldBoldDots&&(n.endLine=Tr.DotsThinBold,i=t[0].getLineWidth(Tr.DotsBoldBoldDots)/2-t[0].getLineWidth(Tr.DotsThinBold)),this.currentSystemParams.currentSystemFixWidth-=i;for(var r=0,s=t.length;r1){c=!0;break}}for(var p=0,v=0;v=0&&this.measureList[g]){var y,b=null===(y=this.measureList[g][0])||void 0===y?void 0:y.parentSourceMeasure;null!=b&&b.ImplicitMeasure&&null!=b&&b.RhythmPrinted&&(m=!1)}m&&(t.addRhythmAtBegin(u),t.parentSourceMeasure.RhythmPrinted=u,p=!0)}return(f||d||p)&&(s+=t.beginInstructionsWidth,p&&(s+=this.rules.RhythmRightMargin)),s}},{key:"addInstructionsAtMeasureEnd",value:function(e,t,i){if(!e||!e.Instructions||0===e.Instructions.length)return 0;for(var n=0,r=e.Instructions.length;n0&&(this.currentSystemParams.systemMeasures.push({beginLine:Tr.None,endLine:Tr.None}),this.currentSystemParams.currentWidth+=a,this.currentSystemParams.currentSystemFixWidth+=a)}},{key:"addExtraInstructionMeasure",value:function(e,t,i){var n=this.currentSystemParams.currentSystem,r=ra.symbolFactory.createExtraGraphicalMeasure(n.StaffLines[e]);t&&r.addKeyAtBegin(t,this.activeKeys[e],this.activeClefs[e]),void 0!==i&&i.PrintObject&&r.addRhythmAtBegin(i),r.PositionAndShape.BorderLeft=0,r.PositionAndShape.BorderTop=0,r.PositionAndShape.BorderBottom=this.rules.StaffHeight;var s=this.rules.MeasureLeftMargin+r.beginInstructionsWidth+this.rules.MeasureRightMargin;return r.PositionAndShape.BorderRight=s,n.StaffLines[e].Measures.push(r),s}},{key:"addStaveMeasuresToSystem",value:function(e){if(e[0]){for(var t=[],i=0;i1){var t=Math.min(this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.length-1,e.measureListIndex+e.multipleRestMeasures-1);e=this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures[t]}}finally{}var i,n,r=this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures,s=r[this.measureListIndex],a=!1;s.allRests&&(a=null===(i=r[this.measureListIndex+s.multipleRestMeasures-1])||void 0===i||null===(n=i.endsWithLineRepetition)||void 0===n?void 0:n.call(i));return this.nextMeasureBeginsLineRepetition()&&this.thisMeasureEndsLineRepetition()?Tr.DotsBoldBoldDots:this.thisMeasureEndsLineRepetition()||a?Tr.DotsThinBold:this.nextMeasureHasKeyInstructionChange()||this.thisMeasureEndsWordRepetition()||this.nextMeasureBeginsWordRepetition()?Tr.DoubleThin:e&&void 0!==e.endingBarStyleEnum?e.endingBarStyleEnum:Tr.SingleThin}},{key:"getLineWidth",value:function(e,t,i){var n=e.getLineWidth(t);return t===Tr.DotsBoldBoldDots&&(n/=2),i&&t===Tr.BoldThinDots&&(n+=this.rules.DistanceBetweenLastInstructionAndRepetitionBarline),n}},{key:"previousMeasureEndsLineRepetition",value:function(){if(0===this.measureListIndex)return!1;for(var e=0,t=this.measureList[this.measureListIndex-1].length;e=this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.length||!this.measureList[e])return!1;for(var t=0,i=this.measureList[e].length;t=this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.length||e>this.measureList.length-1)return!1;for(var t=0,i=this.measureList[e].length;t1)for(var s=1;sr&&(r=u)}for(var l=0;lthis.rules.PageHeight-this.rules.PageBottomMargin&&++n<=4&&console.log("warning: could not fit a single system on page ".concat(e.PageNumber," and measure number ").concat(i.GraphicalMeasures[0][0].MeasureNumber,'.\n The PageFormat may be too small for this sheet."\n Will not give further warnings for all pages, only total.'))}else{var c,f,d=this.musicSystems[l-1],p=d.StaffLines[d.StaffLines.length-1],v=p.PositionAndShape,m=this.findRequiredDistanceWithSkyBottomLine(d,i);m=Math.max(r,m),m+=this.rules.MinSkyBottomDistBetweenSystems,"GYM"===(null===(c=window)||void 0===c||null===(f=c.appName)||void 0===f?void 0:f.toLocaleUpperCase())&&(m=m<16?16:m);var g=this.hasExpressionCounts(i);g.TempoCount>0&&this.rules.MetronomeMarksDrawn&&(m+=2),g.OtherCount>0&&this.rules.MetronomeMarksDrawn&&(m+=2),m=Math.max(m,this.rules.MinimumDistanceBetweenSystems+p.StaffHeight);var y=t+v.RelativePosition.y+m,b=y+i.PositionAndShape.BorderMarginBottom;if(this.rules.NewPageAtXMLNewPageAttribute&&d.breaksPage||!(b0&&console.log("total amount of pages that couldn't fit a single music system: ".concat(n," of ").concat(e.PageNumber))}},{key:"findRequiredDistanceWithSkyBottomLine",value:function(e,t){for(var i=e.StaffLines[e.StaffLines.length-1],n=t.StaffLines[0],r=i.BottomLine,s=n.SkyLine,a=i.PositionAndShape,o=n.PositionAndShape,u=1/this.rules.SamplingUnit,l=0,h=0;h=s.length)break;for(var d=Math.max(0,f-6),p=Math.min(s.length-1,f+6),v=0,m=d;m<=p;m++)v=Math.min(v,s[m]);var g=c-v;l=Math.max(g,l)}}return 0===l&&(l=a.BorderBottom-o.BorderTop),l}}]),e}(),Qs=function(){function e(){k(this,e),this.systemMeasures=[],this.systemMeasureIndex=0,this.currentWidth=0,this.currentSystemFixWidth=0,this.currentSystemVarWidth=0,this.maxLabelLength=0}return E(e,[{key:"IsSystemStartMeasure",value:function(){return 0===this.systemMeasureIndex}}]),e}(),ea=E((function e(t,i,n){k(this,e),this.getOpenOctaveShift=t,this.getAbsoluteStartTimestamp=i,this.getAbsoluteEndTimestamp=n})),ta=function(){function e(){k(this,e),this.keySignatureNoteAlterationsDict=new Xe,this.currentAlterationsComparedToKeyInstructionList=[],this.currentInMeasureNoteAlterationsDict=new Xe}return E(e,[{key:"ActiveKeyInstruction",get:function(){return this.activeKeyInstruction},set:function(e){this.activeKeyInstruction=e,this.reactOnKeyInstructionChange()}},{key:"doCalculationsAtEndOfMeasure",value:function(){this.currentInMeasureNoteAlterationsDict.clear(),this.currentAlterationsComparedToKeyInstructionList.clear();var e,t=o(this.keySignatureNoteAlterationsDict.keys());try{for(t.s();!(e=t.n()).done;){var i=e.value;this.currentInMeasureNoteAlterationsDict.setValue(i,this.keySignatureNoteAlterationsDict.getValue(i))}}catch(n){t.e(n)}finally{t.f()}}},{key:"checkAccidental",value:function(e,t){if(t){var i=t.FundamentalNote+12*t.Octave,n=this.currentAlterationsComparedToKeyInstructionList.indexOf(i)>=0;if(this.currentInMeasureNoteAlterationsDict.containsKey(i)){if(n&&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!==Ct.NONE&&this.currentInMeasureNoteAlterationsDict.remove(i);var r=this.currentInMeasureNoteAlterationsDict.getValue(i);if(t.Accidental===Ct.NONE&&(t=.5===Math.abs(r)?new At(t.FundamentalNote,t.Octave,Ct.NONE):new At(t.FundamentalNote,t.Octave,Ct.NATURAL)),this.isAlterAmbiguousAccidental(t.Accidental)&&!t.AccidentalXml)return;ra.symbolFactory.addGraphicalAccidental(e,t)}}else if(t.Accidental!==Ct.NONE){if(n||this.currentAlterationsComparedToKeyInstructionList.push(i),this.currentInMeasureNoteAlterationsDict.setValue(i,t.AccidentalHalfTones),this.isAlterAmbiguousAccidental(t.Accidental)&&!t.AccidentalXml)return;ra.symbolFactory.addGraphicalAccidental(e,t)}else n&&(t=new At(t.FundamentalNote,t.Octave,Ct.NATURAL),this.currentAlterationsComparedToKeyInstructionList.splice(this.currentAlterationsComparedToKeyInstructionList.indexOf(i),1),ra.symbolFactory.addGraphicalAccidental(e,t))}}},{key:"isAlterAmbiguousAccidental",value:function(e){return e===Ct.SLASHFLAT||e===Ct.QUARTERTONEFLAT}},{key:"reactOnKeyInstructionChange",value:function(){var e,t=this.activeKeyInstruction.AlteratedNotes;e=this.activeKeyInstruction.Key>0?Ct.SHARP:Ct.FLAT,this.keySignatureNoteAlterationsDict.clear(),this.currentAlterationsComparedToKeyInstructionList.length=0;for(var i=-9;i<9;i++)for(var n=0;n0)i=n-1,e.push({startIndex:t,endIndex:i}),t=n;else u.HasEndLine&&this.rules.NewPartAndSystemAfterFinalBarline&&(i=n,e.push({startIndex:t,endIndex:i}),t=n+1)}}tI&&F%2==0?(c.push(F),O=U,F=1):F++:O>I?(c.push(F),O=U,F=1):F++,B===(H=U>I?V+1:Math.ceil(H))?D+=1:(h.push(D),B=H,D=1)}}h.push(D),c.push(F),c=c.filter(Boolean),console.log(c,h)}return this.buildPreparedMusicSystems(c)}},{key:"buildPreparedMusicSystems",value:function(e){var t=!1;this.currentSystemParams=new Qs,this.currentSystemParams.currentSystem=this.initMusicSystem();for(var i=0,n=this.measureList.length;i0&&this.rules.RenderMultipleRestMeasures){h.isReducedToMultiRest=!0,h.multipleRestMeasureNumber=1;var f=h.multipleRestMeasures-1;u+=f;for(var d=1;d<=f;d++){var p=e.SourceMeasures[h.MeasureNumber-1+d];p.multipleRestMeasureNumber=d+1,p.isReducedToMultiRest=!0,t.push([void 0])}}}if(this.rules.AutoGenerateMutipleRestMeasuresFromRestMeasures&&this.rules.RenderMultipleRestMeasures){for(var v=void 0,m=0,g=0,y=e.SourceMeasures.length;g0){v.isReducedToMultiRest=!0,v.multipleRestMeasureNumber=1,m++,b.multipleRestMeasureNumber=m,b.isReducedToMultiRest=!0;for(var S=0;S1){v.multipleRestMeasures=m;var x=this.createGraphicalMeasuresForSourceMeasure(v,i,r,a,n);t[v.measureListIndex]=x,m=0,v=void 0}else m=0,v=void 0}if(m>1){v.multipleRestMeasures=m,v.isReducedToMultiRest=!0;var k=this.createGraphicalMeasuresForSourceMeasure(v,i,r,a,n);t[v.measureListIndex]=k,m=0,v=void 0}}var _=n.map((function(e){return e.ClefType===Gt.percussion}));this.handleStaffEntries(_),this.calculateVerticalContainersList(),this.setIndicesToVerticalGraphicalContainers()}},{key:"calculate",value:function(){this.musicSystems=[],this.clearSystemsAndMeasures(),this.clearRecreatedObjects(),this.createGraphicalTies(),this.calculateSheetLabelBoundingBoxes(),this.calculateXLayout(this.graphicalMusicSheet,this.maxInstrNameLabelLength()),this.graphicalMusicSheet.MusicPages.length=0,this.calculateMusicSystems(),Yt.transformRelativeToAbsolutePosition(this.graphicalMusicSheet)}},{key:"calculateXLayout",value:function(t,i){var n=0,r=this.rules.MaxInstructionsConstValue;if(this.graphicalMusicSheet.MeasureList.length>0){var s=this.graphicalMusicSheet.MeasureList[0],a=this.calculateMeasureXLayout(s);a=this.calculateMeasureWidthFromStaffEntries(s,a),e.setMeasuresMinStaffEntriesWidth(s,a),n=1.2*a+i+r;for(var o=1;o0)return;var s=t.Measures[r];0!==s.MeasureNumber&&1!==s.MeasureNumber||(i=s.MeasureNumber),n=s!==t.Measures[0]&&this.rules.MeasureNumberLabelXOffset?this.rules.MeasureNumberLabelXOffset:0;var a=this.rules.UseXMLMeasureNumbers&&1===s.MeasureNumber&&1!==s.parentSourceMeasure.getPrintedMeasureNumber();((s.MeasureNumber===i||s.MeasureNumber>=i+this.rules.MeasureNumberLabelOffset)&&!s.parentSourceMeasure.ImplicitMeasure||a)&&((1!==s.MeasureNumber||1===s.MeasureNumber&&s!==t.Measures[0]||a)&&this.calculateSingleMeasureNumberPlacement(s,t,e,n),i=s.MeasureNumber)}else L.warn("calculateMeasureNumberPlacement: measure undefined for system.Id "+e.Id)}},{key:"calculateSingleMeasureNumberPlacement",value:function(e,t,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,r=e.parentSourceMeasure.getPrintedMeasureNumber().toString(),s=new hs(r),a=new ls(s,this.rules.MeasureNumberLabelHeight,kt.LeftBottom,this.rules),u=t.SkyBottomLineCalculator;a.setLabelPositionAndShapeBorders(),a.PositionAndShape.Parent=i.PositionAndShape;var l,h=t.PositionAndShape.RelativePosition.x+e.PositionAndShape.RelativePosition.x-a.PositionAndShape.BorderMarginLeft+n,c=h,f=h-a.PositionAndShape.BorderLeft+a.PositionAndShape.BorderRight,d=(c-=t.PositionAndShape.RelativePosition.x)+.5,p=(f-=t.PositionAndShape.RelativePosition.x)-.5,v=u.getSkyLineMinInRange(d,p);if(e===t.Measures[0]){var m=0;if(i.GroupBrackets.length>0){var g,y=o(i.GroupBrackets);try{for(y.s();!(g=y.n()).done;){var b=g.value;m=Math.min(m,b.PositionAndShape.BorderTop)}}catch(S){y.e(S)}finally{y.f()}}l=Math.min(v,m)}else l=v;l=Math.min(0,l),a.PositionAndShape.RelativePosition=new ft(h,l),i.MeasureNumberLabels.push(a)}},{key:"calculateMeasureNumberSkyline",value:function(e){var t,i=e.StaffLines[0],n=o(e.MeasureNumberLabels);try{for(n.s();!(t=n.n()).done;){var r=t.value,s=r.PositionAndShape.RelativePosition.x,a=s-r.PositionAndShape.BorderLeft+r.PositionAndShape.BorderRight;s-=i.PositionAndShape.RelativePosition.x,a-=i.PositionAndShape.RelativePosition.x,i.SkyBottomLineCalculator.updateSkyLineInRange(s,a,r.PositionAndShape.RelativePosition.y+r.PositionAndShape.BorderMarginTop)}}catch(u){n.e(u)}finally{n.f()}}},{key:"layoutGraphicalTie",value:function(e,t,i){throw new Error(this.abstractNotImplementedErrorMessage)}},{key:"calculateSingleStaffLineLyricsPosition",value:function(e,t){for(var i=0,n=this.rules.StaffHeight,r=[],s=e.SkyBottomLineCalculator,a=e.Measures.length,o=0;o0){r.push(f),i=Math.max(i,f.LyricsEntries.length);for(var d=f.PositionAndShape.RelativePosition.x+l.x,p=Number.MAX_VALUE,v=Number.MIN_VALUE,m=0;m0){var C=e.PositionAndShape.Size.width,A=r[0].PositionAndShape.RelativePosition.x+r[0].PositionAndShape.BorderMarginLeft+r[0].parentMeasure.PositionAndShape.RelativePosition.x;A=A>C?C:A,s.updateBottomLineInRange(A,C,b)}return r}},{key:"calculateLyricsExtendsAndDashes",value:function(e){for(var t=0,i=e.length;t0||e.UnknownList.length>0){for(var a,o="",u=0,l=e.EntriesList.length;ue.length-1&&(L.debug("minimum measure to draw index out of range. resetting min measure index to limit."),this.rules.MinMeasureToDrawIndex=e.length-1);for(var t=[],i=this.rules.MinMeasureToDrawIndex,n=e.length;i0)&&(u=s.getSkyLineMinInRange(_,E));var w=0;0===b?(w+=this.rules.ChordSymbolYOffset,w+=.1):w+=this.rules.ChordSymbolYPadding,w*=-1;var M=S.GraphicalLabel;M.PositionAndShape.RelativePosition.y=u+w,M.setLabelPositionAndShapeBorders(),M.PositionAndShape.calculateBoundingBox(),s.updateSkyLineInRange(_,E,u+M.PositionAndShape.BorderMarginTop)}}}catch(T){g.e(T)}finally{g.f()}}}catch(T){p.e(T)}finally{p.f()}}}catch(T){n.e(T)}finally{n.f()}}}catch(T){t.e(T)}finally{t.f()}}},{key:"calculateAlignedChordSymbolsOffset",value:function(e,t){var i,n=Number.MAX_SAFE_INTEGER,r=o(e);try{for(r.s();!(i=r.n()).done;){var s,a=i.value,u=o(a.graphicalChordContainers);try{for(u.s();!(s=u.n()).done;){var l=s.value,h=a.PositionAndShape,c=l.PositionAndShape,f=c.BorderMarginLeft+h.AbsolutePosition.x,d=c.BorderMarginRight+h.AbsolutePosition.x;n=Math.min(n,t.getSkyLineMinInRange(f,d))}}catch(p){u.e(p)}finally{u.f()}}}catch(p){r.e(p)}finally{r.f()}return n}},{key:"layoutMeasureWithWholeRest",value:function(e,t,i){}},{key:"layoutBeams",value:function(e){}},{key:"layoutArticulationMarks",value:function(e,t,i){}},{key:"layoutOrnament",value:function(e,t,i){}},{key:"calculateRestNotePlacementWithinGraphicalBeam",value:function(e,t,i,n,r){}},{key:"calculateTupletNumbers",value:function(){}},{key:"calculateSlurs",value:function(){}},{key:"calculateDynamicExpressionsForMultiExpression",value:function(e,t,i){}},{key:"calculateGraphicalVerbalContinuousDynamic",value:function(e,t){var i,n=e.Label,r=t.x+n.PositionAndShape.BorderMarginLeft,s=t.x+n.PositionAndShape.BorderMarginRight,a=e.ContinuousDynamic.Placement,o=e.ParentStaffLine.SkyBottomLineCalculator;a===g.Below?(i=o.getBottomLineMaxInRange(r,s),n.PositionAndShape.RelativePosition=new ft(t.x,i-n.PositionAndShape.BorderMarginTop)):(i=o.getSkyLineMinInRange(r,s),n.PositionAndShape.RelativePosition=new ft(t.x,i-n.PositionAndShape.BorderMarginBottom))}},{key:"calculateGraphicalContinuousDynamic",value:function(e,t){var i,n,r=e.ParentStaffLine.ParentStaff.idInMusicSheet,s=this.graphicalMusicSheet.getGraphicalMeasureFromSourceMeasureAndIndex(e.ContinuousDynamic.EndMultiExpression.SourceMeasureParent,r);if(s){e.EndMeasure=s;var a=e.ParentStaffLine,u=s.ParentStaffLine,l=u&&a===u,h=!1;u?h=null==u?void 0:u.isPartOfMultiStaffInstrument():a&&(h=null==a?void 0:a.isPartOfMultiStaffInstrument());var c,d=f.createFromFraction(e.ContinuousDynamic.EndMultiExpression.AbsoluteTimestamp),p=this.graphicalMusicSheet.GetVerticalContainerFromTimestamp(d),v=p.getFirstNonNullStaffEntry().parentMeasure,m=v.PositionAndShape.AbsolutePosition.x+v.PositionAndShape.BorderRight,y=new f(0,0,0),b=o(p.StaffEntries);try{for(b.s();!(c=b.n()).done;){var S,x=c.value,k=null==x||null===(S=x.sourceStaffEntry)||void 0===S?void 0:S.calculateMaxNoteLength();null!=k&&k.gt(y)&&(y=k)}}catch(Z){b.e(Z)}finally{b.f()}var E=this.getRelativePositionInStaffLineFromTimestamp(d,r,u,h,0),w=f.plus(d,y),M=this.getRelativePositionInStaffLineFromTimestamp(w,r,u,h,0);M.x>E.x&&M.xC){var U=P.StaffLines[W].PositionAndShape.RelativePosition.y-a.PositionAndShape.RelativePosition.y-this.rules.StaffHeight;V=this.rules.StaffHeight+U/2}else V=this.rules.WedgePlacementBelowY;V-=this.rules.WedgeOpeningLength/2,l||(G=V);var z=A.getBottomLineMaxInRange(B,O);if(z>V&&(V=z),CG&&(G=z),G+=this.rules.WedgeOpeningLength/2,G+=this.rules.WedgeVerticalMargin),V+=this.rules.WedgeOpeningLength/2,V+=this.rules.WedgeVerticalMargin}else if(R===g.Above){if(1===a.ParentStaff.ParentInstrument.Staves.length)V=this.rules.WedgePlacementAboveY;else{var Y=0;C>0&&(Y=C-1);var j=P.StaffLines[Y];V=-(a.PositionAndShape.RelativePosition.y-j.PositionAndShape.RelativePosition.y-this.rules.StaffHeight)/2}V+=this.rules.WedgeOpeningLength/2,l||(G=V);var K=A.getSkyLineMinInRange(B,O);if(K1&&C>0){var q=a.findClosestStaffEntry(B),J=a.findClosestStaffEntry(O);q&&J&&q.parentVerticalContainer}l||((K=u.SkyBottomLineCalculator.getSkyLineMinInRange(D,F))-h/2?-h/2:u-e.PositionAndShape.BorderMarginBottom}else o=u-e.PositionAndShape.BorderMarginBottom;e.PositionAndShape.RelativePosition=new ft(t.x,o)}else if(e.Placement===g.Below){var c=a.getBottomLineMaxInRange(r,s),f=n.ParentStaff.ParentInstrument.Staves[n.ParentStaff.ParentInstrument.Staves.length-1];if(n.isPartOfMultiStaffInstrument()&&n.ParentStaff!==f){var d=n.ParentMusicSystem.StaffLines[n.ParentMusicSystem.StaffLines.indexOf(n)+1].PositionAndShape.RelativePosition.y-n.PositionAndShape.RelativePosition.y-this.rules.StaffHeight;o=c+e.PositionAndShape.BorderMarginBottom6&&void 0!==arguments[6]?arguments[6]:kt.CenterBottom,o=new hs(i,a);o.fontStyle=n,o.fontHeight=s;var u=new ls(o,s,o.textAlignment,this.rules,e.PositionAndShape),l=1.1;r===g.Below&&(u.Label.textAlignment=kt.LeftTop),u.setLabelPositionAndShapeBorders(),u.PositionAndShape.BorderMarginBottom*=l,u.PositionAndShape.BorderMarginTop*=l,u.PositionAndShape.BorderMarginLeft*=l,u.PositionAndShape.BorderMarginRight*=l;var h,c=t.x+u.PositionAndShape.BorderMarginLeft,f=t.x+u.PositionAndShape.BorderMarginRight;f>e.PositionAndShape.Size.width&&(c=(f=e.PositionAndShape.Size.width-this.rules.MeasureRightMargin)-u.PositionAndShape.MarginSize.width,t.x=c-u.PositionAndShape.BorderMarginLeft);var d=e.SkyBottomLineCalculator;return h=r===g.Below?d.getBottomLineMaxInRange(c,f):d.getSkyLineMinInRange(c,f),u.PositionAndShape.RelativePosition=new ft(t.x,h),r===g.Below?d.updateBottomLineInRange(c,f,u.PositionAndShape.BorderMarginBottom+h):d.updateSkyLineInRange(c,f,u.PositionAndShape.BorderMarginTop+h),u}},{key:"calculateTempoExpressionsForMultiTempoExpression",value:function(e,t,i,n){na={};var r=f.plus(e.AbsoluteTimestamp,t.Timestamp),s=this.graphicalMusicSheet.MeasureList[i],a=new ft;if(t.ContinuousTempo||t.InstantaneousTempo){if(this.rules.MinMeasureToDrawIndex>0)return;if(!s[0])return;for(var u=s[0].ParentStaffLine,l=s[0].PositionAndShape.RelativePosition.x,h=0,c=0;c0){u=s[c].ParentStaffLine,l=s[c].PositionAndShape.RelativePosition.x,h=c;break}if(a=this.getRelativePositionInStaffLineFromTimestamp(r,h,u,u.isPartOfMultiStaffInstrument(),l),t.EntriesList.length>0&&t.EntriesList[0].Expression instanceof Gs)if(t.EntriesList[0].Expression.Placement=g.Above,u.Measures[0].staffEntries.length>0&&0===Math.abs(a.x-u.Measures[0].staffEntries[0].PositionAndShape.RelativePosition.x)&&u.ParentMusicSystem===this.musicSystems[0]){var d=u.Measures[0].FirstInstructionStaffEntry;if(d){var p=d.GraphicalInstructions.last();a.x=p.PositionAndShape.RelativePosition.x}this.rules.CompactMode&&(a.x=u.PositionAndShape.RelativePosition.x+u.Measures[0].PositionAndShape.RelativePosition.x)}var v,m=o(t.EntriesList);try{for(m.s();!(v=m.n()).done;){var y=v.value,b=kt.CenterBottom;this.rules.CompactMode&&(b=kt.LeftBottom);var S=this.calculateLabel(u,a,y.label,t.getFontstyleOfFirstEntry(),y.Expression.Placement,this.rules.UnknownTextHeight,b);if(y.Expression instanceof Gs){var x,k=o(u.AbstractExpressions);try{for(k.s();!(x=k.n()).done;){var _=x.value;_ instanceof Ls&&(_.SourceExpression.Label,y.Expression.Label)}}catch(T){k.e(T)}finally{k.f()}new Ls(y.Expression,S).ParentStaffLine||L.warn("Adding staffline didn't work"),y.Expression.Enum===Ws.metronomeMark&&(na[i]=y.Expression)}else y.Expression;if(n===e.TempoExpressions.length-1)for(var E=0,w=Object.values(na);E-1&&c.PositionAndShape.ChildElements.splice(f,1),c.FirstInstructionStaffEntry=void 0,c.beginInstructionsWidth=0}if(c.LastInstructionStaffEntry){var d=c.PositionAndShape.ChildElements.indexOf(c.LastInstructionStaffEntry.PositionAndShape);d>-1&&c.PositionAndShape.ChildElements.splice(d,1),c.LastInstructionStaffEntry=void 0,c.endInstructionsWidth=0}}u.Measures=[],u.PositionAndShape.ChildElements=[]}s.StaffLines.length=0,s.PositionAndShape.ChildElements=[]}i.MusicSystems=[],i.PositionAndShape.ChildElements=[]}this.graphicalMusicSheet.MusicPages=[]}},{key:"handleVoiceEntry",value:function(t,i,n,r,s,a,o,u,l){var h=arguments.length>9&&void 0!==arguments[9]?arguments[9]:void 0,c=arguments.length>10&&void 0!==arguments[10]?arguments[10]:void 0;t.StemDirectionXml!==os.Undefined&&this.rules.SetWantedStemDirectionByXml&&void 0!==t.StemDirectionXml?t.WantedStemDirection=t.StemDirectionXml:this.calculateStemDirectionFromVoices(t);var f=i.findOrCreateGraphicalVoiceEntry(t);f.octaveShiftValue=u;var d,p=i.tabStaffEntry;p&&(d=p.findOrCreateGraphicalVoiceEntry(t));for(var v=0,m=t.Notes.length;v-1)){var y=void 0;if(t.IsGrace?y=e.symbolFactory.createGraceNote(g,f,s,this.rules,u):(y=e.symbolFactory.createNote(g,f,s,u,this.rules,void 0),e.stafflineNoteCalculator.trackNote(y)),g.Pitch&&this.checkNoteForAccidental(y,n,s,u),this.resetYPositionForLeadSheet(y.PositionAndShape),i.addGraphicalNoteToListAtCorrectYPosition(f,y),y.PositionAndShape.calculateBoundingBox(),this.leadSheet||(void 0!==g.NoteBeam&&g.PrintObject&&this.handleBeam(y,g.NoteBeam,o),void 0!==g.NoteTuplet&&g.PrintObject&&this.handleTuplet(y,g.NoteTuplet,a)),d){var b=e.symbolFactory.createNote(g,d,s,u,this.rules,void 0);p.addGraphicalNoteToListAtCorrectYPosition(d,b),b.PositionAndShape.calculateBoundingBox(),this.leadSheet||g.NoteTuplet&&this.handleTuplet(b,g.NoteTuplet,a)}}}return t.Articulations.length>0&&this.handleVoiceEntryArticulations(t.Articulations,t,i),t.TechnicalInstructions.length>0&&this.handleVoiceEntryTechnicalInstructions(t.TechnicalInstructions,t,i),t.LyricsEntries.size()>0&&this.handleVoiceEntryLyrics(t,i,r),t.OrnamentContainer&&this.handleVoiceEntryOrnaments(t.OrnamentContainer,t,i),u}},{key:"resetYPositionForLeadSheet",value:function(e){this.leadSheet&&(e.RelativePosition=new ft(e.RelativePosition.x,0))}},{key:"layoutVoiceEntries",value:function(e,t){if(e.PositionAndShape.RelativePosition=new ft(0,0),!this.leadSheet){var i,n=o(e.graphicalVoiceEntries);try{for(n.s();!(i=n.n()).done;){var r=i.value.notes;if(0!==r.length){var s=r[0].sourceNote.ParentVoiceEntry,a=void 0!==r[0].sourceNote.Pitch;this.layoutVoiceEntry(s,r,e,a)}}}catch(u){n.e(u)}finally{n.f()}}}},{key:"maxInstrNameLabelLength",value:function(){var e,t=0,i=o(this.graphicalMusicSheet.ParentMusicSheet.Instruments);try{for(i.s();!(e=i.n()).done;){var n,r=e.value;if(null!==(n=r.NameLabel)&&void 0!==n&&n.print&&r.Voices.length>0&&r.Voices[0].Visible){var s=r.NameLabel;this.rules.RenderPartNames||(s=new hs("",s.textAlignment,s.font));var a=new ls(s,this.rules.InstrumentLabelTextHeight,kt.LeftCenter,this.rules);a.setLabelPositionAndShapeBorders(),t=Math.max(t,a.PositionAndShape.MarginSize.width)}}}catch(u){i.e(u)}finally{i.f()}return this.rules.RenderPartNames?t:0}},{key:"calculateSheetLabelBoundingBoxes",value:function(){var e,t=this.graphicalMusicSheet.ParentMusicSheet,i=this.rules.DefaultColorTitle;if(void 0!==t.Title&&this.rules.RenderTitle){var n=new ls(t.Title,this.rules.SheetTitleHeight,kt.CenterBottom,this.rules);n.Label.IsCreditLabel=!0,n.Label.colorDefault=i,this.graphicalMusicSheet.Title=n,n.setLabelPositionAndShapeBorders()}else this.rules.RenderTitle||(this.graphicalMusicSheet.Title=void 0);if(void 0!==t.Subtitle&&this.rules.RenderSubtitle){var r=new ls(t.Subtitle,this.rules.SheetSubtitleHeight,kt.CenterCenter,this.rules);r.Label.IsCreditLabel=!0,r.Label.colorDefault=i,this.graphicalMusicSheet.Subtitle=r,r.setLabelPositionAndShapeBorders()}else this.rules.RenderSubtitle||(this.graphicalMusicSheet.Subtitle=void 0);if(void 0!==t.Composer&&this.rules.RenderComposer){var s=new ls(t.Composer,this.rules.SheetComposerHeight,kt.RightCenter,this.rules);s.Label.IsCreditLabel=!0,s.Label.colorDefault=i,this.graphicalMusicSheet.Composer=s,s.setLabelPositionAndShapeBorders()}else this.rules.RenderComposer||(this.graphicalMusicSheet.Composer=void 0);if(void 0!==t.Lyricist&&this.rules.RenderLyricist){var a=new ls(t.Lyricist,this.rules.SheetAuthorHeight,kt.LeftCenter,this.rules);a.Label.IsCreditLabel=!0,a.Label.colorDefault=i,this.graphicalMusicSheet.Lyricist=a,a.setLabelPositionAndShapeBorders()}else this.rules.RenderLyricist||(this.graphicalMusicSheet.Lyricist=void 0);var o=null===(e=this.graphicalMusicSheet.musicSheet.sourceMeasures)||void 0===e?void 0:e[0];if(o&&o.FirstInstructionsStaffEntries.length>0){for(var u,l,h=o.FirstInstructionsStaffEntries[0],c=0,f=h.Instructions.length;c0&&1===l.graphicalVoiceEntries[0].notes.length){var h=l.graphicalVoiceEntries[0].notes[0];!h.sourceNote.Pitch&&new f(1,2).lt(h.sourceNote.Length)&&this.layoutMeasureWithWholeRest(h,l,u)}}}}},{key:"optimizeRestNotePlacement",value:function(e,t){if(0!==e.graphicalVoiceEntries.length){var i=e.graphicalVoiceEntries[0].notes;if(0!==i.length){var n=i[0],r=n.sourceNote.isRest();if(2===e.graphicalVoiceEntries.length){var s=!1,a=e.graphicalVoiceEntries[1].notes;if(a.length>0)s=a[0].sourceNote.isRest();r&&s?this.calculateTwoRestNotesPlacementWithCollisionDetection(e):(r||s)&&this.calculateRestNotePlacementWithCollisionDetectionFromGraphicalNote(e)}else if(r&&e!==t.staffEntries[0]&&e!==t.staffEntries[t.staffEntries.length-1]){var o=t.staffEntries.indexOf(e),u=t.staffEntries[o-1],l=t.staffEntries[o+1];if(1===u.graphicalVoiceEntries.length){var h=u.graphicalVoiceEntries[0].notes[0];if(void 0!==h.sourceNote.NoteBeam&&1===l.graphicalVoiceEntries.length){var c=l.graphicalVoiceEntries[0].notes[0];void 0!==c.sourceNote.NoteBeam&&h.sourceNote.NoteBeam===c.sourceNote.NoteBeam&&(this.calculateRestNotePlacementWithinGraphicalBeam(e,n,h,l,c),e.PositionAndShape.calculateBoundingBox())}}}}}}},{key:"getRelativePositionInStaffLineFromTimestamp",value:function(e,t,i,n){var r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,s=new ft,a=void 0,o=void 0,u=this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers.length,l=this.graphicalMusicSheet.GetInterpolatedIndexInVerticalContainers(e),h=Math.min(Math.floor(l),u-1),c=Math.min(Math.ceil(l),u-1);if(h<0||t<0)return s;if(a=this.getFirstLeftNotNullStaffEntryFromContainer(h,t,n),o=this.getFirstRightNotNullStaffEntryFromContainer(c,t,n),a&&o){var d=a.parentMeasure.PositionAndShape.RelativePosition.x;r>0&&(d=r);var p=a.PositionAndShape.RelativePosition.x+d,v=o.PositionAndShape.RelativePosition.x+o.parentMeasure.PositionAndShape.RelativePosition.x;r>0&&(v=o.PositionAndShape.RelativePosition.x+d);var m=0;if(a!==o){var g=a.getAbsoluteTimestamp(),y=o.getAbsoluteTimestamp(),b=f.minus(e,g);m=b.RealValue/f.minus(y,g).RealValue}a.parentMeasure.ParentStaffLine!==o.parentMeasure.ParentStaffLine&&(a.parentMeasure.ParentStaffLine===i?v=i.PositionAndShape.Size.width:p=i.PositionAndShape.RelativePosition.x),s=new ft(p+(v-p)*m,0)}return s}},{key:"getRelativeXPositionFromTimestamp",value:function(e){var t=this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers.length,i=this.graphicalMusicSheet.GetInterpolatedIndexInVerticalContainers(e),n=Math.max(0,Math.min(Math.round(i),t-1)),r=this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers[n].getFirstNonNullStaffEntry();return r.PositionAndShape.RelativePosition.x+r.parentMeasure.PositionAndShape.RelativePosition.x}},{key:"calculatePageLabels",value:function(e){this.rules.RenderSingleHorizontalStaffline&&(e.PositionAndShape.BorderRight=e.PositionAndShape.Size.width,e.PositionAndShape.calculateBoundingBox(),this.graphicalMusicSheet.ParentMusicSheet.pageWidth=e.PositionAndShape.Size.width);var t=10;if(e.MusicSystems.length>0){var i=e.MusicSystems[0];t=i.PositionAndShape.RelativePosition.y+i.PositionAndShape.BorderTop}if(this.graphicalMusicSheet.Title){var n=this.graphicalMusicSheet.Title;n.PositionAndShape.Parent=e.PositionAndShape;var r=new ft;r.x=this.graphicalMusicSheet.ParentMusicSheet.pageWidth/2,r.y=this.rules.TitleTopDistance+this.rules.SheetTitleHeight,n.PositionAndShape.RelativePosition=r,e.Labels.push(n)}if(this.graphicalMusicSheet.Subtitle){var s=this.graphicalMusicSheet.Subtitle;s.PositionAndShape.Parent=e.PositionAndShape;var a=new ft;a.x=this.graphicalMusicSheet.ParentMusicSheet.pageWidth/2,a.y=this.rules.TitleTopDistance+this.rules.SheetTitleHeight+this.rules.SheetMinimumDistanceBetweenTitleAndSubtitle,s.PositionAndShape.RelativePosition=a,e.Labels.push(s)}var o,u=this.graphicalMusicSheet.Composer;if(u){var l;u.PositionAndShape.Parent=e.PositionAndShape,u.setLabelPositionAndShapeBorders();var h=new ft;h.x=this.graphicalMusicSheet.ParentMusicSheet.pageWidth-this.rules.PageRightMargin,h.y=t,h.y-=this.rules.SystemComposerDistance;var c=null===(l=u.TextLines)||void 0===l?void 0:l.length;c>1&&(h.y-=u.PositionAndShape.BorderBottom*(c-1)/c),o=h.y,u.PositionAndShape.RelativePosition=h,e.Labels.push(u)}var f=this.graphicalMusicSheet.Lyricist;if(f){var d;f.PositionAndShape.Parent=e.PositionAndShape,f.setLabelPositionAndShapeBorders();var p=new ft;p.x=this.rules.PageLeftMargin,p.y=t,p.y+=f.PositionAndShape.BorderBottom,p.y=Math.min(p.y,null!==(d=o)&&void 0!==d?d:Number.MAX_SAFE_INTEGER),f.PositionAndShape.RelativePosition=p,e.Labels.push(f)}}},{key:"createGraphicalTies",value:function(){for(var e=0;e=0&&this.staffEntriesWithGraphicalTies.push(r)}r=a}}}},{key:"setTieDirections",value:function(e){if(e){var t=e.ties;if(t.length>1){var i,n=void 0,r=o(t);try{for(r.s();!(i=r.n()).done;){var s=i.value.Notes[0];(!n||s.Pitch.getHalfTone()>n.Pitch.getHalfTone())&&(n=s)}}catch(h){r.e(h)}finally{r.f()}var a,u=o(t);try{for(u.s();!(a=u.n()).done;){var l=a.value;l.TieDirection===g.NotYetDefined&&(l.Notes[0]===n?l.TieDirection=g.Above:l.TieDirection=g.Below)}}catch(h){u.e(h)}finally{u.f()}}}}},{key:"createAccidentalCalculators",value:function(){var e=[],t=this.graphicalMusicSheet.ParentMusicSheet.getFirstSourceMeasure();if(t)for(var i=0;i1)return;d=e.symbolFactory.createGraphicalMeasure(t,c)}if(d.hasError=t.getErrorInMeasure(l),t.FirstInstructionsStaffEntries[l])for(var p=0,v=t.FirstInstructionsStaffEntries[l].Instructions.length;p0){var X=T.Instructions[0];e.symbolFactory.createInStaffClef(R,X)}this.rules.RenderChordSymbols&&(null===(P=T.ChordContainers)||void 0===P?void 0:P.length)>0&&(T.ParentStaff.ParentInstrument.HasChordSymbols=!0,e.symbolFactory.createChordSymbols(T,R,r.ActiveKeyInstruction,this.graphicalMusicSheet.ParentMusicSheet.Transpose))}}if(r.doCalculationsAtEndOfMeasure(),t.LastInstructionsStaffEntries[l])for(var Y=t.LastInstructionsStaffEntries[l],j=0,K=Y.Instructions.length;j=1&&0===d.staffEntries.length){var re=new Hr(new zr(d.parentSourceMeasure,d.parentSourceMeasure.AbsoluteTimestamp,d.parentSourceMeasure.CompleteNumberOfStaves),c),se=new ss(new f(0,1),c.Voices[0],re),ae=new jt(se,re,f.createFromFraction(t.Duration),void 0,t);ae.PrintObject=this.rules.FillEmptyMeasuresWithWholeRest===ga.YesVisible,se.addNote(ae);var oe=e.symbolFactory.createStaffEntry(re,d);d.addGraphicalStaffEntry(oe),oe.relInMeasureTimestamp=se.Timestamp;var ue=e.symbolFactory.createVoiceEntry(se,oe);oe.graphicalVoiceEntries.push(ue);var le=e.symbolFactory.createNote(ae,ue,new Vt,Fs.NONE,void 0);e.stafflineNoteCalculator.trackNote(le),ue.notes.push(le)}d.hasOnlyRests=!0;var he,ce=o(d.staffEntries);try{for(ce.s();!(he=ce.n()).done;){var fe=he.value;if(d.hasOnlyRests=fe.hasOnlyRests(),!d.hasOnlyRests)break}}catch(de){ce.e(de)}finally{ce.f()}return d}},{key:"checkNoteForAccidental",value:function(e,t,i,n){var r=e.sourceNote.Pitch,s=e.parentVoiceEntry.parentStaffEntry.parentMeasure.getTransposedHalftones();0!==s&&e.sourceNote.ParentStaffEntry.ParentStaff.ParentInstrument.MidiInstrumentId!==Wt.Percussion&&(r=e.Transpose(t.ActiveKeyInstruction,i,s,n),e.sourceNote.TransposedPitch=r),e.sourceNote.halfTone=r.getHalfTone(),t.checkAccidental(e,r)}},{key:"handleStaffEntries",value:function(t){for(var i=0,n=this.graphicalMusicSheet.MeasureList.length;i0&&c.graphicalVoiceEntries[0].notes.length>0&&(this.layoutVoiceEntries(c,s),this.layoutStaffEntry(c))}}catch(f){h.e(f)}finally{h.f()}this.graphicalMeasureCreatedCalculations(u)}}}},{key:"calculateSkyBottomLines",value:function(){var e,t=o(this.musicSystems);try{for(t.s();!(e=t.n()).done;){var i,n=o(e.value.StaffLines);try{for(n.s();!(i=n.n()).done;){i.value.SkyBottomLineCalculator.calculateLines()}}catch(r){n.e(r)}finally{n.f()}}}catch(r){t.e(r)}finally{t.f()}}},{key:"calculateExpressionAlignements",value:function(){}},{key:"calculateStaffEntryArticulationMarks",value:function(){for(var e=0,t=this.musicSystems.length;e0&&this.layoutArticulationMarks(p.Articulations,p,c)}}},{key:"calculateOrnaments",value:function(){for(var e=0,t=this.musicSystems.length;e0&&n.LyricVersesNumbers.sort()}for(var r=0,s=this.musicSystems.length;r=0&&(n=t.GraphicalLyricsEntries[i+1]),n){var r=e.StaffEntryParent.parentMeasure.ParentStaffLine,s=n.StaffEntryParent.parentMeasure.ParentStaffLine,a=e.StaffEntryParent,o=n.StaffEntryParent;if(e.StaffEntryParent.parentMeasure.ParentStaffLine===n.StaffEntryParent.parentMeasure.ParentStaffLine){var u=a.parentMeasure.PositionAndShape.RelativePosition.x+a.PositionAndShape.RelativePosition.x+e.GraphicalLabel.PositionAndShape.RelativePosition.x+e.GraphicalLabel.PositionAndShape.BorderMarginRight,l=o.parentMeasure.PositionAndShape.RelativePosition.x+o.PositionAndShape.RelativePosition.x+e.GraphicalLabel.PositionAndShape.RelativePosition.x+n.GraphicalLabel.PositionAndShape.BorderMarginLeft,h=e.GraphicalLabel.PositionAndShape.RelativePosition.y,c=1;l-u>3*this.rules.MinimumDistanceBetweenDashes&&(c=Math.floor((l-u)/this.rules.MinimumDistanceBetweenDashes)-1),1===c?this.calculateSingleDashForLyricWord(r,u,l,h):this.calculateDashes(r,u,l,h)}else{var f=a.parentMeasure.PositionAndShape.RelativePosition.x+a.PositionAndShape.RelativePosition.x+e.GraphicalLabel.PositionAndShape.BorderMarginRight,d=r.Measures[r.Measures.length-1],p=d.PositionAndShape.RelativePosition.x+d.PositionAndShape.Size.width,v=e.GraphicalLabel.PositionAndShape.RelativePosition.y;if(this.calculateDashes(r,f,p,v),s&&s.Measures[0]&&o.parentMeasure.ParentStaffLine&&(o!==o.parentMeasure.staffEntries[0]||o.parentMeasure!==o.parentMeasure.ParentStaffLine.Measures[0])){var m=s.Measures[0].staffEntries[0].PositionAndShape.RelativePosition.x,g=o.parentMeasure.PositionAndShape.RelativePosition.x+o.PositionAndShape.RelativePosition.x+n.GraphicalLabel.PositionAndShape.BorderMarginLeft;v=n.GraphicalLabel.PositionAndShape.RelativePosition.y,this.calculateDashes(s,m,g,v)}}}}},{key:"calculateDashes",value:function(e,t,i,n){var r=i-t;if(r<3*this.rules.MinimumDistanceBetweenDashes)this.calculateSingleDashForLyricWord(e,t,i,n);else{var s=Math.floor(r/this.rules.MinimumDistanceBetweenDashes)-1,a=r/(s+1),o=0;for(t+=a,i-=a;o<=Math.floor(s/2)&&i>t;)r=this.calculateRightAndLeftDashesForLyricWord(e,t,i,n),t+=a,i-=a,o++;r>2*a&&this.calculateSingleDashForLyricWord(e,t,i,n)}}},{key:"calculateSingleDashForLyricWord",value:function(e,t,i,n){var r=new hs("-"),s=new ls(r,this.rules.LyricsHeight,kt.CenterBottom,this.rules);s.setLabelPositionAndShapeBorders(),e.LyricsDashes.push(s),-1===this.staffLinesWithLyricWords.indexOf(e)&&this.staffLinesWithLyricWords.push(e),s.PositionAndShape.Parent=e.PositionAndShape;var a=new ft(t+(i-t)/2,n);s.PositionAndShape.RelativePosition=a}},{key:"calculateLyricExtend",value:function(e){for(var t=e.GraphicalLabel.PositionAndShape.RelativePosition.y,i=e.StaffEntryParent,n=i.parentMeasure.ParentStaffLine,r=void 0,s=void 0,a=i.parentMeasure.ParentStaff.idInMusicSheet,o=i.parentVerticalContainer.Index+1;o0)break;(s=(r=u).parentMeasure.ParentStaffLine)||(s=i.parentMeasure.ParentStaffLine)}}if(r&&s)if(n===s&&r.parentMeasure.ParentStaffLine){var l=i.parentMeasure.PositionAndShape.RelativePosition.x+i.PositionAndShape.RelativePosition.x+e.GraphicalLabel.PositionAndShape.BorderMarginRight,h=r.parentMeasure.PositionAndShape.RelativePosition.x+r.PositionAndShape.RelativePosition.x+r.PositionAndShape.BorderMarginRight;t-=e.GraphicalLabel.PositionAndShape.Size.height/4,this.calculateSingleLyricWordWithUnderscore(n,l,h,t)}else{var c=n.Measures[n.Measures.length-1].PositionAndShape,f=i.parentMeasure.PositionAndShape.RelativePosition.x+i.PositionAndShape.RelativePosition.x+e.GraphicalLabel.PositionAndShape.BorderMarginRight,d=c.RelativePosition.x+c.Size.width;if(t-=e.GraphicalLabel.PositionAndShape.Size.height/4,this.calculateSingleLyricWordWithUnderscore(n,f,d,t),!r)return;if(r.parentMeasure.ParentStaffLine&&r.parentMeasure.staffEntries&&(r!==r.parentMeasure.staffEntries[0]||r.parentMeasure!==r.parentMeasure.ParentStaffLine.Measures[0])){var p=s.Measures[0].staffEntries[0].PositionAndShape.RelativePosition.x,v=r.parentMeasure.PositionAndShape.RelativePosition.x+r.PositionAndShape.RelativePosition.x+r.PositionAndShape.BorderMarginRight;this.calculateSingleLyricWordWithUnderscore(s,p,v,t)}}}},{key:"calculateSingleLyricWordWithUnderscore",value:function(e,t,i,n){var r=new ft(t,n),s=new ft(i,n),a=new Ft(r,s,this.rules.LyricUnderscoreLineWidth);e.LyricLines.push(a),-1===this.staffLinesWithLyricWords.indexOf(e)&&this.staffLinesWithLyricWords.push(e)}},{key:"calculateRightAndLeftDashesForLyricWord",value:function(e,t,i,n){var r=new hs("-"),s=new ls(r,this.rules.LyricsHeight,kt.CenterBottom,this.rules);s.setLabelPositionAndShapeBorders(),e.LyricsDashes.push(s),-1===this.staffLinesWithLyricWords.indexOf(e)&&this.staffLinesWithLyricWords.push(e),s.PositionAndShape.Parent=e.PositionAndShape;var a=new ft(t,n);s.PositionAndShape.RelativePosition=a;var o=new hs("-"),u=new ls(o,this.rules.LyricsHeight,kt.CenterBottom,this.rules);u.setLabelPositionAndShapeBorders(),e.LyricsDashes.push(u),u.PositionAndShape.Parent=e.PositionAndShape;var l=new ft(i,n);return u.PositionAndShape.RelativePosition=l,u.PositionAndShape.RelativePosition.x-s.PositionAndShape.RelativePosition.x}},{key:"calculateDynamicExpressions",value:function(){for(var e=Math.min(this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.length-1,this.rules.MaxMeasureToDrawIndex),t=Math.min(this.rules.MinMeasureToDrawIndex,this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.length);t<=e;t++){var i=this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures[t];this.dynamicExpressionMap.clear();for(var n=0;n=0;r--){var s;if(null!==(s=this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers[r])&&void 0!==s&&s.StaffEntries[t])return this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers[r].StaffEntries[t]}}},{key:"getFirstRightNotNullStaffEntryFromContainer",value:function(e,t,i){var n;if(null!==(n=this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers[e])&&void 0!==n&&n.StaffEntries[t])return this.graphicalMusicSheet.VerticalGraphicalStaffEntryContainers[e].StaffEntries[t];for(var r=e+1;r0||t.StaffLinkedExpressions[i][n].UnknownList.length>0)&&this.calculateMoodAndUnknownExpression(t.StaffLinkedExpressions[i][n],e,i)}},{key:"calculateStemDirectionFromVoices",value:function(e){if(void 0!==e.ParentSourceStaffEntry.Link)return e===e.ParentSourceStaffEntry.VoiceEntries[0]?void(e.WantedStemDirection=os.Up):void(e.WantedStemDirection=os.Down);e.ParentVoice instanceof Br?e.WantedStemDirection=os.Down:e.ParentSourceStaffEntry.VoiceEntries.length>1&&(e.WantedStemDirection=os.Up)}},{key:"setBeamNotesWantedStemDirections",value:function(e){if(e.Notes.length>0){var t=e.Notes[0].NoteBeam;if(t){var i,n=o(t.Notes);try{for(n.s();!(i=n.n()).done;){var r=i.value;if(r.ParentVoiceEntry.WantedStemDirection!==os.Undefined&&r.ParentVoiceEntry.ParentSourceStaffEntry.ParentStaff.Id===e.ParentSourceStaffEntry.ParentStaff.Id){e.WantedStemDirection=r.ParentVoiceEntry.WantedStemDirection;break}}}catch(s){n.e(s)}finally{n.f()}}}}}],[{key:"TextMeasurer",get:function(){return e.textMeasurer},set:function(t){e.textMeasurer=t}},{key:"setMeasuresMinStaffEntriesWidth",value:function(e,t){for(var i=0,n=e.length;i0&&(r+="("+a.adds.join(",")+")"),a.alts.length>0&&(r+="(alt "+a.alts.join(",")+")"),a.subs.length>0&&(r+="(omit "+a.subs.join(",")+")"),e.BassPitch){var L=e.BassPitch;ra.transposeCalculator&&(L=ra.transposeCalculator.transposePitch(e.BassPitch,i,t)),r+="/",r+=At.getNoteEnumString(L.FundamentalNote),r+=this.getTextForAccidental(L.Accidental)}return r}},{key:"getTextForAccidental",value:function(e){var t="";switch(e){case Ct.DOUBLEFLAT:t+="bb";break;case Ct.FLAT:t+="b";break;case Ct.SHARP:t+="#";break;case Ct.DOUBLESHARP:t+="x"}return t}}]),e}(),aa=E((function e(t,i,n){k(this,e),this.value=t,this.alteration=i,this.text=n})),oa=function(){function e(t,i,n){k(this,e),this.alternateName=t,this.chordKind=i,this.degrees=n}return E(e,null,[{key:"createCustomChord",value:function(t,i,n){return new e(t,i,n)}},{key:"renameCustomChord",value:function(e,t,i){var n,r=o(i);try{for(r.s();!(n=r.n()).done;){var s=n.value;s.alternateName===e&&(s.alternateName=t)}}catch(a){r.e(a)}finally{r.f()}}}]),e}(),ua=function(e){return e[e.add=0]="add",e[e.alter=1]="alter",e[e.subtract=2]="subtract",e}(ua||{}),la=function(e){return 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}(la||{}),ha=function(e){c(i,e);var t=d(i);function i(e,n,r){var s,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:void 0;return k(this,i),(s=t.call(this)).DrawnAccidental=Ct.NONE,s.lineShift=0,s.sourceNote=e,s.parentVoiceEntry=n,s.PositionAndShape=new yt(v(s),n.PositionAndShape),s.graphicalNoteLength=a||e.Length,s.numberOfDots=s.calculateNumberOfNeededDots(s.graphicalNoteLength),s.rules=r,s.rules.addGraphicalNoteToNoteMap(e,v(s)),s}return E(i,[{key:"Transpose",value:function(e,t,i,n){var r=this.sourceNote.Pitch;return ra.transposeCalculator&&(r=ra.transposeCalculator.transposePitch(this.sourceNote.Pitch,e,i)),r}},{key:"calculateNumberOfNeededDots",value:function(e){return this.sourceNote&&this.sourceNote.NoteTuplet?0:e.calculateNumberOfNeededDots()}},{key:"ParentMusicPage",get:function(){return this.parentVoiceEntry.parentStaffEntry.parentMeasure.ParentMusicSystem.Parent}}],[{key:"FromNote",value:function(e,t){return t.NoteToGraphicalNoteMap.getValue(e.NoteToGraphicalNoteObjectId)}}]),i}(vt),ca=i("E",function(){function e(){k(this,e),this.DYSlursStartingAtSameStaffEntryYOffset=0,this.DYMinNoteWidth=0,this.DYWorkId=0,this.DYWorkSpecial=!1,this.DYContainerId="osmdCanvasPage",this.DYSVGContainerId="osmdSvgPage",this.DYMusicScoreType="staff",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.PlayAlreadyStartedNotesFromCursorPosition=!1,this.PlaybackSkipNotesSafetyInterval=.02,this.UseDefaultVoiceInteractionListener=!0,this.loadDefaultValues()}return E(e,[{key:"loadDefaultValues",value:function(){this.SamplingUnit=3*e.unit,this.MpatMode=!0,this.SheetTitleHeight=4,this.SheetSubtitleHeight=2,this.SheetMinimumDistanceBetweenTitleAndSubtitle=1,this.SheetComposerHeight=2,this.SheetAuthorHeight=2,this.CompactMode=!1,this.PagePlacementEnum=xt.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=e.unit,this.SystemLeftMargin=0,this.SystemRightMargin=0,this.SystemLabelsRightMargin=2,this.SystemComposerDistance=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=e.unit/2,this.BeamSpaceWidth=e.unit/3,this.BeamForwardLength=1.25*e.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.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.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.DistanceBetweenAdjacentDynamics=.75,this.TempoChangeMeasureValidity=4,this.TempoContinousFactor=.7,this.StaccatoScalingFactor=.8,this.BetweenDotsDistance=.8,this.OrnamentAccidentalScalingFactor=.65,this.ChordSymbolTextHeight=2,this.ChordSymbolTextAlignment=kt.LeftBottom,this.ChordSymbolRelativeXOffset=-1,this.ChordSymbolXSpacing=1,this.ChordOverlapAllowedIntoNextMeasure=0,this.ChordSymbolYOffset=.1,this.ChordSymbolYPadding=0,this.ChordSymbolYAlignment=!0,this.ChordSymbolYAlignmentScope="staffline",this.ChordSymbolLabelTexts=new Xe,this.resetChordSymbolLabelTexts(this.ChordSymbolLabelTexts),this.CustomChords=[],this.resetChordNames(),this.RepetitionSymbolsYOffset=0,this.RehearsalMarkXOffsetDefault=10,this.RehearsalMarkXOffset=0,this.RehearsalMarkXOffsetSystemStartMeasure=-20,this.RehearsalMarkYOffsetDefault=-15,this.RehearsalMarkYOffset=0,this.RehearsalMarkFontSize=10,this.MeasureNumberLabelHeight=1.5*e.unit,this.MeasureNumberLabelOffset=2,this.MeasureNumberLabelXOffset=-.5,this.TupletsRatioed=!1,this.TupletsBracketed=!1,this.TripletsBracketed=!1,this.TupletNumberLabelHeight=1.5*e.unit,this.TupletNumberYOffset=.5,this.LabelMarginBorderFactor=.1,this.TupletVerticalLineLength=.5,this.TupletNumbersInTabs=!1,this.SlurPlacementFromXML=!0,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.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.RepetitionEndingLabelHeight=2,this.RepetitionEndingLabelXOffset=.5,this.RepetitionEndingLabelYOffset=.3,this.RepetitionEndingLineYLowerOffset=.5,this.RepetitionEndingLineYUpperOffset=.3,this.VoltaOffset=2.5,this.LyricsAlignmentStandard=kt.LeftBottom,this.LyricsHeight=2,this.LyricsYOffsetToStaffHeight=0,this.VerticalBetweenLyricsDistance=.5,this.HorizontalBetweenLyricsDistance=.2,this.BetweenSyllableMaximumDistance=10,this.BetweenSyllableMinimumDistance=.5,this.LyricOverlapAllowedIntoNextMeasure=3.4,this.MinimumDistanceBetweenDashes=10,this.MaximumLyricsElongationFactor=2.5,this.InstantaneousTempoTextHeight=2.3,this.ContinuousDynamicTextHeight=2.3,this.MoodTextHeight=2.3,this.UnknownTextHeight=2,this.ContinuousTempoTextHeight=2.3,this.DynamicExpressionMaxDistance=2,this.DynamicExpressionSpacer=.5,this.VexFlowDefaultNotationFontScale=39,this.VexFlowDefaultTabFontScale=39,this.TremoloStrokeScale=1,this.TremoloYSpacingScale=1,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=e.unit/2,this.SystemRepetitionEndingLineWidth=.12,this.SystemDotWidth=e.unit/2,this.DistanceBetweenVerticalSystemLines=.35,this.DistanceBetweenDotAndLine=.7,this.RepeatEndStartPadding=2,this.OctaveShiftLineWidth=.12,this.OctaveShiftVerticalLineLength=e.unit,this.GraceLineWidth=this.StaffLineWidth*this.GraceNoteScalingFactor,this.MultipleRestMeasureDefaultWidth=4,this.MinimumCrossedBeamDifferenceMargin=1e-4,this.SheetMaximumWidth=32767,this.VoiceSpacingMultiplierVexflow=.85,this.VoiceSpacingAddendVexflow=3,this.PickupMeasureWidthMultiplier=1,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=-.5,this.SoftmaxFactorVexFlow=15,this.StaggerSameWholeNotes=!0,this.AlignRests=ma.Never,this.RestCollisionYPadding=0,this.FillEmptyMeasuresWithWholeRest=ga.No,this.ArpeggiosGoAcrossVoices=!1,this.RenderArpeggios=!0,this.RenderSlurs=!0,this.ColoringMode=da.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=Et.Regular,this.DefaultVexFlowNoteFont="gonville",this.MaxMeasureToDrawIndex=Number.MAX_VALUE,this.MinMeasureToDrawIndex=0,this.MaxSystemToDrawNumber=Number.MAX_VALUE,this.MaxPageToDrawNumber=Number.MAX_VALUE,this.RenderComposer=!0,this.RenderTitle=!0,this.RenderSubtitle=!0,this.RenderLyricist=!0,this.RenderPartNames=!0,this.RenderPartAbbreviations=!0,this.RenderFingerings=!0,this.RenderMeasureNumbers=!0,this.RenderMeasureNumbersOnlyAtSystemStart=!1,this.UseXMLMeasureNumbers=!0,this.RenderLyrics=!0,this.RenderChordSymbols=!0,this.RenderMultipleRestMeasures=!0,this.AutoGenerateMutipleRestMeasuresFromRestMeasures=!0,this.RenderRehearsalMarks=!0,this.RenderClefsAtBeginningOfStaffline=!0,this.RenderKeySignatures=!0,this.RenderTimeSignatures=!0,this.ArticulationPlacementFromXML=!0,this.FingeringPosition=g.AboveOrBelow,this.FingeringPositionFromXML=!0,this.FingeringPositionGrace=g.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.RestoreCursorAfterRerender=!0,this.StretchLastSystemLine=!1,e.FixStafflineBoundingBox=!1,this.PageFormat=fa.UndefinedPageFormat,this.PageBackgroundColor=void 0,this.PerformanceMode=!1,this.RenderSingleHorizontalStaffline=!1,this.SpacingBetweenTextLines=0,this.NoteToGraphicalNoteMap=new Xe,this.NoteToGraphicalNoteMapObjectCount=0;try{this.MaxInstructionsConstValue=this.ClefLeftMargin+this.ClefRightMargin+this.KeyRightMargin+this.RhythmRightMargin+11}catch(t){L.info("EngravingRules()",t)}this.MpatMode&&(this.NewPartAndSystemAfterFinalBarline=!0)}},{key:"applyDefaultColorMusic",value:function(e){this.DefaultColorMusic=e,this.DefaultColorNotehead=this.DefaultColorMusic,this.DefaultColorRest=this.DefaultColorNotehead,this.DefaultColorStem=this.DefaultColorNotehead,this.DefaultColorLabel=this.DefaultColorNotehead,this.DefaultColorTitle=this.DefaultColorNotehead,this.LedgerLineColorDefault=this.DefaultColorNotehead}},{key:"addGraphicalNoteToNoteMap",value:function(e,t){e.NoteToGraphicalNoteObjectId=this.NoteToGraphicalNoteMapObjectCount,this.NoteToGraphicalNoteMap.setValue(e.NoteToGraphicalNoteObjectId,t),this.NoteToGraphicalNoteMapObjectCount++}},{key:"GNote",value:function(e){return ha.FromNote(e,this)}},{key:"clearMusicSheetObjects",value:function(){this.NoteToGraphicalNoteMap=new Xe,this.NoteToGraphicalNoteMapObjectCount=0}},{key:"setChordSymbolLabelText",value:function(e,t){this.ChordSymbolLabelTexts.setValue(e,t)}},{key:"resetChordSymbolLabelTexts",value:function(e){return e.setValue(la.minor,"m"),e.setValue(la.augmented,"aug"),e.setValue(la.diminished,"dim"),e.setValue(la.dominant,"7"),e.setValue(la.majorseventh,"maj7"),e.setValue(la.minorseventh,"m7"),e.setValue(la.diminishedseventh,"dim7"),e.setValue(la.augmentedseventh,"aug7"),e.setValue(la.halfdiminished,"m7b5"),e.setValue(la.majorminor,"m(maj7)"),e.setValue(la.majorsixth,"maj6"),e.setValue(la.minorsixth,"m6"),e.setValue(la.dominantninth,"9"),e.setValue(la.majorninth,"maj9"),e.setValue(la.minorninth,"m9"),e.setValue(la.dominant11th,"11"),e.setValue(la.major11th,"maj11"),e.setValue(la.minor11th,"m11"),e.setValue(la.dominant13th,"13"),e.setValue(la.major13th,"maj13"),e.setValue(la.minor13th,"m13"),e.setValue(la.suspendedsecond,"sus2"),e.setValue(la.suspendedfourth,"sus4"),e.setValue(la.power,"5"),e.setValue(la.none,"N.C."),e}},{key:"addChordName",value:function(e,t,i,n,r){if(void 0!==la[t]){var s={adds:i,alts:n,subs:r};this.CustomChords.push(oa.createCustomChord(e,la[t],s))}}},{key:"renameChord",value:function(e,t){oa.renameCustomChord(e,t,this.CustomChords)}},{key:"resetChordNames",value:function(){this.addChordName("alt","major",["#5","b9","#9"],["b5"],[]),this.addChordName("7alt","dominant",["#5","b9","#9"],["b5"],[]),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("m7b5","minorseventh",[],["b5"],[]),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"],[],[])}},{key:"calculateCurveParametersArrays",value:function(){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(var e=0;e2&&void 0!==arguments[2]?arguments[2]:"noIdStringGiven";k(this,e),this.width=t,this.height=i,this.idString=n}return E(e,[{key:"aspectRatio",get:function(){return this.IsUndefined?0:this.width/this.height}},{key:"IsUndefined",get:function(){return void 0===this.width||void 0===this.height||0===this.height||0===this.width}},{key:"Equals",value:function(e){return!!e&&(e.width===this.width&&e.height===this.height)}}],[{key:"UndefinedPageFormat",get:function(){return new e(0,0)}}]),e}();i("P",fa);var da=function(e){return e[e.XML=0]="XML",e[e.AutoColoring=1]="AutoColoring",e[e.CustomColorSet=2]="CustomColorSet",e}(da||{}),pa=function(e){return e.allon="allon",e.compact="compact",e.compacttight="compacttight",e.default="default",e.leadsheet="leadsheet",e.preview="preview",e.thumbnail="thumbnail",e}(pa||{}),va=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default";k(this,e),this.rules=new ca,this.drawCursors=!0,this.drawTitle=!0,this.drawSubtitle=!0,this.drawLyricist=!0,this.drawComposer=!0,this.drawCredits=!0,this.drawPartNames=!0,this.fingeringPosition=g.Left,this.drawHiddenNotes=!1,this.DrawingParametersEnum=t}return E(e,[{key:"DrawingParametersEnum",get:function(){return this.drawingParametersEnum},set:function(e){switch(this.drawingParametersEnum=e,e){case"allon":this.setForAllOn();break;case"thumbnail":this.setForThumbnail();break;case"leadsheet":this.setForLeadsheet();break;case"compact":this.setForCompactMode();break;case"compacttight":this.setForCompactTightMode();break;case"default":default:this.setForDefault()}}},{key:"setForAllOn",value:function(){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}},{key:"setForDefault",value:function(){this.rules.loadDefaultValues(),this.setForAllOn(),this.drawHiddenNotes=!1}},{key:"setForThumbnail",value:function(){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}},{key:"setForCompactMode",value:function(){this.rules.CompactMode=!0,this.DrawCredits=!1,this.drawHiddenNotes=!1}},{key:"setForCompactTightMode",value:function(){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}},{key:"setForLeadsheet",value:function(){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}},{key:"DrawCredits",get:function(){return this.drawCredits},set:function(e){this.drawCredits=e,this.DrawComposer=e,this.DrawTitle=e,this.DrawSubtitle=e,this.DrawLyricist=e}},{key:"DrawTitle",get:function(){return this.drawTitle},set:function(e){this.drawTitle=e,this.rules.RenderTitle=e,e||(this.DrawSubtitle=!1)}},{key:"DrawSubtitle",get:function(){return this.drawSubtitle},set:function(e){this.drawSubtitle=e,this.rules.RenderSubtitle=e,e&&(this.DrawTitle=!0)}},{key:"DrawComposer",get:function(){return this.drawComposer},set:function(e){this.drawComposer=e,this.rules.RenderComposer=e}},{key:"DrawLyricist",get:function(){return this.drawLyricist},set:function(e){this.drawLyricist=e,this.rules.RenderLyricist=e}},{key:"DrawPartNames",get:function(){return this.drawPartNames},set:function(e){this.drawPartNames=e,this.rules.RenderPartNames=e,this.rules.RenderPartNames||(this.rules.RenderPartAbbreviations=!1)}},{key:"FingeringPosition",get:function(){return this.fingeringPosition},set:function(e){this.fingeringPosition=e,this.rules.FingeringPosition=e}},{key:"Rules",get:function(){return this.rules},set:function(e){this.rules=e}}]),e}(),ma=function(e){return e[e.Never=0]="Never",e[e.Always=1]="Always",e[e.Auto=2]="Auto",e}(ma||{}),ga=function(e){return e[e.No=0]="No",e[e.YesVisible=1]="YesVisible",e[e.YesInvisible=2]="YesInvisible",e}(ga||{}),ya=function(e){return e[e.SVG=0]="SVG",e[e.Canvas=1]="Canvas",e}(ya||{}),ba=function(){function e(){k(this,e)}return E(e,null,[{key:"OSMDOptionsStandard",value:function(){return{autoResize:!0,backend:"svg",drawingParameters:pa.default}}},{key:"BackendTypeFromString",value:function(e){return e&&"canvas"===e.toLowerCase()?1:0}}]),e}(),Sa=function(){function e(t){if(k(this,e),this.hasAttributes=!1,!t)throw new Error("IXmlElement: expected Element, got undefined");this.elem=t,this.name=t.nodeName.toLowerCase(),t.hasAttributes()&&(this.hasAttributes=!0,this.firstAttribute=t.attributes[0]),this.hasElements=t.hasChildNodes(),1===t.childNodes.length&&t.childNodes[0].nodeType===Node.TEXT_NODE?this.value=t.childNodes[0].nodeValue:this.value=""}return E(e,[{key:"attribute",value:function(e){return this.elem.attributes.getNamedItem(e)}},{key:"attributes",value:function(){if(!this.attrs){for(var e=this.elem.attributes,t=[],i=0;i0&&this.Voices[0].Visible},set:function(e){for(var t=0,i=this.Voices.length;t-1&&this.parent.MusicSystems.splice(t,1)}this.parent=e,this.boundingBox.Parent=e.PositionAndShape}},{key:"NextSystem",get:function(){var e=this.Parent.MusicSystems.indexOf(this);return e!==this.Parent.MusicSystems.length?this.Parent.MusicSystems[e+1]:void 0}},{key:"StaffLines",get:function(){return this.staffLines}},{key:"GraphicalMeasures",get:function(){return this.graphicalMeasures}},{key:"MeasureNumberLabels",get:function(){return this.measureNumberLabels}},{key:"Labels",get:function(){return this.labels.values()}},{key:"ObjectsToRedraw",get:function(){return this.objectsToRedraw}},{key:"InstrumentBrackets",get:function(){return this.instrumentBrackets}},{key:"GroupBrackets",get:function(){return this.groupBrackets}},{key:"GraphicalMarkedAreas",get:function(){return this.graphicalMarkedAreas}},{key:"SystemLines",get:function(){return this.systemLines}},{key:"Id",get:function(){return this.id}},{key:"createSystemLeftLine",value:function(e,t,i){var n=-e/2;i&&(n=this.maxLabelLength+t-e/2);var r=this.staffLines[0].Measures[0],s=void 0;this.staffLines.length>1&&(s=this.staffLines[this.staffLines.length-1].Measures[0]);var a=this.createSystemLine(n,e,Tr.SingleThin,us.MeasureBegin,this,r,s);this.SystemLines.push(a),a.PositionAndShape.RelativePosition=new ft(n,0),a.PositionAndShape.BorderLeft=0,a.PositionAndShape.BorderRight=e,a.PositionAndShape.BorderTop=0,a.PositionAndShape.BorderBottom=this.boundingBox.Size.height,this.createLinesForSystemLine(a)}},{key:"createVerticalLineForMeasure",value:function(e,t,i,n,r,s){var a=s.ParentStaffLine,o=new ft(a.PositionAndShape.RelativePosition.x,a.PositionAndShape.RelativePosition.y),u=a.ParentStaff.ParentInstrument.Staves;if(a.ParentStaff===u[0]){var l=void 0;u.length>1&&(l=this.getBottomStaffLine(a).Measures[r]);var h=this.createSystemLine(e,t,i,n,this,s,l),c=o.x+e;h.PositionAndShape.RelativePosition=new ft(c,0),h.PositionAndShape.BorderLeft=0,h.PositionAndShape.BorderRight=t,this.SystemLines.push(h)}}},{key:"setYPositionsToVerticalLineObjectsAndCreateLines",value:function(e){}},{key:"calculateBorders",value:function(e){}},{key:"alignBeginInstructions",value:function(){}},{key:"GetLeftBorderAbsoluteXPosition",value:function(){return this.StaffLines[0].PositionAndShape.AbsolutePosition.x+this.StaffLines[0].Measures[0].beginInstructionsWidth}},{key:"GetRightBorderAbsoluteXPosition",value:function(){return this.StaffLines[0].PositionAndShape.AbsolutePosition.x+this.StaffLines[0].StaffLines[0].End.x}},{key:"AddGraphicalMeasures",value:function(e){for(var t=0,i=e.length;t1){for(var s=void 0,a=void 0,o=0,u=this.staffLines.length;o3&&void 0!==arguments[3]&&arguments[3],r=t,s=0,a=this.staffLines.length;sthis.maxLabelLength&&(this.maxLabelLength=m.PositionAndShape.Size.width,t=r))}this.updateMusicSystemStaffLineXPosition(t)}},{key:"setMusicSystemLabelsYPosition",value:function(){var e=this;this.labels.forEach((function(t,i){for(var n=0,r=0,s=0;s0&&(i.PositionAndShape.RelativePosition=new ft(0,n/r+2))}))}},{key:"checkStaffEntriesForStaffEntryLink",value:function(){for(var e=!1,t=!1,i=0;i=0;i--){if(!((t=e.InstrumentalGroups[i])instanceof ka))return this.findLastVisibleInstrumentInInstrumentalGroup(t);if(!0===t.Visible)return t}}},{key:"updateMusicSystemStaffLineXPosition",value:function(e){for(var t=0,i=this.StaffLines.length;t4&&void 0!==arguments[4]?arguments[4]:void 0;return k(this,i),(a=t.call(this)).lineType=e,a.linePosition=n,a.parentMusicSystem=r,a.topMeasure=s,a.bottomMeasure=o,a.parentTopStaffLine=null==s?void 0:s.ParentStaffLine,a.boundingBox=new yt(v(a),r.PositionAndShape),a}return E(i,null,[{key:"getObjectWidthForLineType",value:function(e,t){switch(t){case Tr.SingleThin:return e.SystemThinLineWidth;case Tr.DoubleThin:return 2*e.SystemThinLineWidth+e.DistanceBetweenVerticalSystemLines;case Tr.ThinBold:return e.SystemThinLineWidth+e.SystemBoldLineWidth+e.DistanceBetweenVerticalSystemLines;case Tr.BoldThinDots:case Tr.DotsThinBold:return e.SystemThinLineWidth+e.SystemBoldLineWidth+e.DistanceBetweenVerticalSystemLines+e.SystemDotWidth+e.DistanceBetweenDotAndLine;case Tr.DotsBoldBoldDots:return 2*e.SystemBoldLineWidth+2*e.SystemDotWidth+2*e.DistanceBetweenDotAndLine+e.DistanceBetweenVerticalSystemLines;default:return 0}}}]),i}(vt),wa=Kt.Flow,Ma=function(e){c(i,e);var t=d(i);function i(e,n){var r,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;k(this,i),(r=t.call(this)).Visible=!0,r.PositionAndShape=new yt(v(r),e.ParentMusicSystem.PositionAndShape);var a=e.Measures[0],o=n.Measures[0];return r.addConnector(a.getVFStave(),o.getVFStave(),wa.StaveConnector.type.BRACKET,s),r}return E(i,[{key:"draw",value:function(e){this.Visible&&this.vexflowConnector.setContext(e).draw();var t=this.vexflowConnector,i=t.top_stave.getYForLine(0),n=t.bottom_stave.getYForLine(t.bottom_stave.getNumLines()-1)+t.thickness;this.PositionAndShape.AbsolutePosition.x=(t.top_stave.getX()-2+t.x_shift)/Is,this.PositionAndShape.AbsolutePosition.y=i/Is,this.PositionAndShape.Size.height=(n-i)/Is,this.PositionAndShape.Size.width=1.2}},{key:"addConnector",value:function(e,t,i,n){this.vexflowConnector=new wa.StaveConnector(e,t).setType(i).setXShift(-5*n)}}]),i}(vt),Ta=Kt.Flow,Pa=function(e){c(i,e);var t=d(i);function i(e,n){var r,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return k(this,i),(r=t.call(this,e,n,s)).vexflowConnector.setType(Ta.StaveConnector.type.BRACE),r}return E(i)}(Ma),La=function(e){c(i,e);var t=d(i);function i(e,n){var r;return k(this,i),(r=t.call(this,e)).rules=n,r}return E(i,[{key:"calculateBorders",value:function(e){if(0!==this.staffLines.length){var t=this.calcBracketsWidth();this.boundingBox.BorderLeft=-t,this.boundingBox.BorderMarginLeft=-t,this.boundingBox.XBordersHaveBeenSet=!0;var i=this.staffLines[0].SkyBottomLineCalculator.getSkyLineMin();this.boundingBox.BorderTop=i,this.boundingBox.BorderMarginTop=i;var n=this.staffLines[this.staffLines.length-1],r=n.SkyBottomLineCalculator.getBottomLineMax()+n.PositionAndShape.RelativePosition.y;this.boundingBox.BorderBottom=r,this.boundingBox.BorderMarginBottom=r,this.boundingBox.XBordersHaveBeenSet=!0,this.boundingBox.YBordersHaveBeenSet=!0}}},{key:"createSystemLine",value:function(e,t,i,n,r,s){var a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:void 0,o=s,u=!1;if(a&&(u=!0,a.lineTo(s,Ds.line(i,n)),a.addMeasureLine(i,n),i===Tr.DotsBoldBoldDots)){var l=a.ParentStaffLine.Measures.indexOf(a)+1,h=a.ParentStaffLine.Measures[l],c=s.ParentStaffLine.Measures[l];h&&c&&(h.lineTo(c,Ds.line(Tr.BoldThinDots,n)),h.addMeasureLine(Tr.BoldThinDots,n))}return o&&o.addMeasureLine(i,n,u),new Ea(i,n,this,s,a)}},{key:"createInstrumentBracket",value:function(e,t){var i=new Pa(e,t);this.InstrumentBrackets.push(i)}},{key:"createGroupBracket",value:function(e,t,i){var n=e,r=t;if(0===i){var s=new Ma(n,r,i);this.GroupBrackets.push(s)}else{var a=new Pa(n,r,i);this.GroupBrackets.push(a)}}}]),i}(_a),Ca=function(e){c(i,e);var t=d(i);function i(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;return k(this,i),(e=t.call(this)).hasOnlyRests=!1,e.measureNumber=-1,e.ShowTimeSignature=!0,e.parentStaff=n,e.parentSourceMeasure=r,e.parentStaffLine=s,s?(e.parentStaff=s.ParentStaff,e.PositionAndShape=new yt(v(e),s.PositionAndShape)):e.PositionAndShape=new yt(v(e)),e.PositionAndShape.BorderBottom=4,e.parentSourceMeasure&&(e.measureNumber=e.parentSourceMeasure.MeasureNumber),e.staffEntries=[],e}return E(i,[{key:"ParentStaff",get:function(){return this.parentStaff}},{key:"ParentMusicSystem",get:function(){return this.parentMusicSystem},set:function(e){this.parentMusicSystem=e}},{key:"MeasureNumber",get:function(){return this.measureNumber}},{key:"FirstInstructionStaffEntry",get:function(){return this.firstInstructionStaffEntry},set:function(e){this.firstInstructionStaffEntry=e}},{key:"LastInstructionStaffEntry",get:function(){return this.lastInstructionStaffEntry},set:function(e){this.lastInstructionStaffEntry=e}},{key:"ParentStaffLine",get:function(){return this.parentStaffLine},set:function(e){this.parentStaffLine=e,this.parentStaffLine&&(this.PositionAndShape.Parent=this.parentStaffLine.PositionAndShape)}},{key:"resetLayout",value:function(){throw new Error("not implemented")}},{key:"getLineWidth",value:function(e){throw new Error("not implemented")}},{key:"addClefAtBegin",value:function(e){throw new Error("not implemented")}},{key:"addKeyAtBegin",value:function(e,t,i){throw new Error("not implemented")}},{key:"addRhythmAtBegin",value:function(e){throw new Error("not implemented")}},{key:"addClefAtEnd",value:function(e){throw new Error("not implemented")}},{key:"setPositionInStaffline",value:function(e){this.PositionAndShape.RelativePosition=new ft(e,0)}},{key:"setWidth",value:function(e){this.PositionAndShape.BorderRight=e}},{key:"layoutSymbols",value:function(){throw new Error("not implemented")}},{key:"findGraphicalStaffEntryFromTimestamp",value:function(e){for(var t=0,i=this.staffEntries.length;t1}},{key:"isVisible",value:function(){return this.ParentStaff.ParentInstrument.Visible}},{key:"getGraphicalMeasureDurationFromStaffEntries",value:function(){for(var e=new f(0,1),t=[],i=0,n=this.staffEntries.length;i0&&p.Add(y.notes[0].graphicalNoteLength)}}catch(b){g.e(b)}finally{g.f()}}}catch(b){v.e(b)}finally{v.f()}e.lt(p)&&(e=f.createFromFraction(p))}return e}},{key:"addGraphicalStaffEntry",value:function(e){this.staffEntries.push(e)}},{key:"addGraphicalStaffEntryAtTimestamp",value:function(e){if(e)if(0===this.staffEntries.length||this.staffEntries[this.staffEntries.length-1].relInMeasureTimestamp.lt(e.relInMeasureTimestamp))this.staffEntries.push(e);else for(var 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)}}},{key:"isPianoRightHand",value:function(){return this.isUpperStaffOfInstrument()}},{key:"isPianoLeftHand",value:function(){return this.isLowerStaffOfInstrument()}},{key:"isUpperStaffOfInstrument",value:function(){return 1===this.parentStaff.ParentInstrument.Staves.length||this.ParentStaff===this.parentStaff.ParentInstrument.Staves[0]}},{key:"isLowerStaffOfInstrument",value:function(){return 1!==this.parentStaff.ParentInstrument.Staves.length&&this.ParentStaff===this.ParentStaff.ParentInstrument.Staves.last()}},{key:"beginsWithLineRepetition",value:function(){var e=this.parentSourceMeasure;return!!e&&e.beginsWithLineRepetition()}},{key:"endsWithLineRepetition",value:function(){var e=this.parentSourceMeasure;return!!e&&e.endsWithLineRepetition()}},{key:"beginsWithWordRepetition",value:function(){var e=this.parentSourceMeasure;return!!e&&e.beginsWithWordRepetition()}},{key:"endsWithWordRepetition",value:function(){var e=this.parentSourceMeasure;return!!e&&e.endsWithWordRepetition()}},{key:"getTransposedHalftones",value:function(){return this.parentStaff.ParentInstrument.GetMusicSheet.Transpose+this.parentStaff.ParentInstrument.Transpose}}]),i}(vt);Kt.Flow;var Aa=function(e){c(i,e);var t=d(i);function i(e,n){return k(this,i),t.call(this,e,n)}return E(i,[{key:"applyBordersFromVexflow",value:function(){var e=this.vfStaveNote;if(e.getNoteHeadBeginX){var t=e.getBoundingBox(),i=e.getNoteHeadBeginX()-t.x;this.PositionAndShape.RelativePosition.y=t.y/Is,this.PositionAndShape.BorderTop=0,this.PositionAndShape.BorderBottom=t.h/Is,this.PositionAndShape.BorderLeft=-(i+e.width/2)/Is,this.PositionAndShape.BorderRight=(t.w-i)/Is}}},{key:"vfStaveNote",get:function(){return this.mVexFlowStaveNote},set:function(e){this.mVexFlowStaveNote=e}},{key:"color",value:function(){for(var e,t,i=this.rules.DefaultColorNotehead,n=this.rules.DefaultColorRest,r=this.rules.DefaultColorStem,s="#00000000",a=this.vfStaveNote,u=0;u1&&void 0!==arguments[1]?arguments[1]:void 0,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;return k(this,n),(t=i.call(this,e,r,s)).isTabMeasure=!1,t.octaveOffset=3,t.vfVoices={},t.vfTies=[],t.vfRepetitionWords=[],t.connectors=[],t.beams={},t.tuplets={},t.vftuplets={},t.minimumStaffEntriesWidth=-1,s?t.rules=s.ParentMusicSystem.rules:r&&(t.rules=r.Rules),t.resetLayout(),t}return E(n,[{key:"setAbsoluteCoordinates",value:function(e,t){this.stave.setX(e).setY(t)}},{key:"resetLayout",value:function(){this.stave=new Ra.Stave(0,0,0,{fill_style:this.rules.StaffLineColor,space_above_staff_ln:0,space_below_staff_ln:0,DYMusicScoreType:this.rules.DYMusicScoreType}),this.stave.MeasureNumber=this.MeasureNumber,this.ParentStaff&&this.setLineNumber(this.ParentStaff.StafflineCount),this.stave.setBegBarType(Ra.Barline.type.NONE),this.parentSourceMeasure&&this.parentSourceMeasure.endingBarStyleEnum===Tr.None&&this.stave.setEndBarType(Ra.Barline.type.NONE),this.updateInstructionWidth()}},{key:"clean",value:function(){this.vfTies.length=0,this.connectors=[],this.resetLayout()}},{key:"getLineWidth",value:function(e){switch(e){case Tr.SingleThin:case Tr.DoubleThin:case Tr.ThinBold:return.5;case Tr.BoldThinDots:case Tr.DotsThinBold:return 1;case Tr.DotsBoldBoldDots:return 1+this.rules.RepeatEndStartPadding;default:return 0}}},{key:"addClefAtBegin",value:function(e){if(this.rules.RenderClefsAtBeginningOfStaffline){if(this.octaveOffset=e.OctaveOffset,"jianpu"!==this.rules.DYMusicScoreType)if(e.ClefType===Gt.TAB)this.stave.addClef("tab",void 0,void 0,void 0);else{var t=Ds.Clef(e,"default");this.stave.addClef(t.type,t.size,t.annotation,Ra.StaveModifier.Position.BEGIN)}this.updateInstructionWidth()}}},{key:"setLineNumber",value:function(e){5!==e&&(0===e?(this.stave.setNumLines(0),this.stave.getBottomLineY=function(){return this.getYForLine(this.options.num_lines)}):1===e?(this.stave.options.line_config=[{visible:!1},{visible:!1},{visible:!0},{visible:!1},{visible:!1}],this.stave.getBottomLineY=function(){return this.getYForLine(2)}):2===e?(this.stave.options.line_config=[{visible:!1},{visible:!1},{visible:!0},{visible:!0},{visible:!1}],this.stave.getBottomLineY=function(){return this.getYForLine(3)}):3===e?(this.stave.options.line_config=[{visible:!1},{visible:!0},{visible:!0},{visible:!0},{visible:!1}],this.stave.getBottomLineY=function(){return this.getYForLine(2)}):(this.stave.setNumLines(e),this.stave.getBottomLineY=function(){return this.getYForLine(this.options.num_lines)}))}},{key:"addKeyAtBegin",value:function(e,t,i){this.rules.RenderKeySignatures&&(this.stave.setKeySignature(Ds.keySignature(e),Ds.keySignature(t),void 0),this.updateInstructionWidth())}},{key:"addRhythmAtBegin",value:function(e){var t=Ds.TimeSignature(e);this.stave.addModifier(t,Ra.StaveModifier.Position.BEGIN,{numerator:e.Rhythm.Numerator,denominator:e.Rhythm.Denominator}),this.ShowTimeSignature||t.setStyle({fillStyle:"#00000000"}),this.updateInstructionWidth()}},{key:"addClefAtEnd",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=Ds.Clef(e,"small");if(t||!this.stave.endClef){this.stave.setEndClef(i.type,i.size,i.annotation);var n,r=o(this.stave.getModifiers());try{for(r.s();!(n=r.n()).done;){var s=n.value;if(t){var a=s.originalStrokeStyle,u=s.originalFillStyle;s.getStyle()&&(a&&u?(s.getStyle().strokeStyle=a,s.getStyle().fillStyle=u):(s.getStyle().strokeStyle=null,s.getStyle().fillStyle=null))}else if("clefs"===s.getCategory()&&s.getPosition()===Ra.StaveModifier.Position.END&&s.type===i.type){var l="#12345600",h=s.getStyle();h&&(s.originalStrokeStyle=h.strokeStyle,s.originalFillStyle=h.fillStyle),s.setStyle({strokeStyle:l,fillStyle:l})}}}catch(c){r.e(c)}finally{r.f()}return this.parentSourceMeasure.hasEndClef=!0,this.updateInstructionWidth()}}},{key:"addMeasureLine",value:function(e,t){var i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];switch(t){case us.MeasureBegin:switch(e){case Tr.BoldThinDots:i||(this.stave.modifiers[0].draw=function(e){switch(e.checkContext(),this.setRendered(),this.type){case Ra.Barline.type.SINGLE:this.drawVerticalBar(e,this.x,!1);break;case Ra.Barline.type.DOUBLE:this.drawVerticalBar(e,this.x,!0);break;case Ra.Barline.type.END:this.drawVerticalEndBar(e,this.x);break;case Ra.Barline.type.REPEAT_BEGIN:this.drawRepeatBar(e,this.x,!0);break;case Ra.Barline.type.REPEAT_END:this.drawRepeatBar(e,this.x,!1);break;case Ra.Barline.type.REPEAT_BOTH:this.drawRepeatBar(e,this.x,!1),this.drawRepeatBar(e,this.x,!0)}}),this.stave.setBegBarType(Ra.Barline.type.REPEAT_BEGIN)}break;case us.MeasureEnd:switch(e){case Tr.DotsBoldBoldDots:this.stave.setEndBarType(Ra.Barline.type.REPEAT_BOTH);break;case Tr.DotsThinBold:this.stave.setEndBarType(Ra.Barline.type.REPEAT_END);break;case Tr.DoubleThin:this.stave.setEndBarType(Ra.Barline.type.DOUBLE);break;case Tr.ThinBold:this.stave.setEndBarType(Ra.Barline.type.END);break;case Tr.None:this.stave.setEndBarType(Ra.Barline.type.NONE)}}}},{key:"addMeasureNumber",value:function(){var e=this.MeasureNumber.toString(),t=Ba.ABOVE;this.stave.setText(e,t,{justification:1,shift_x:0,shift_y:0})}},{key:"addWordRepetition",value:function(e){var t=void 0,i=Ra.StaveModifier.Position.END,n=this.beginInstructionsWidth;switch(e.type){case jr.Segno:t=Ra.Repetition.type.SEGNO_LEFT,i=Ra.StaveModifier.Position.LEFT;break;case jr.Coda:t=Ra.Repetition.type.CODA_LEFT,i=Ra.StaveModifier.Position.LEFT;break;case jr.DaCapo:t=Ra.Repetition.type.DC;break;case jr.DalSegno:t=Ra.Repetition.type.DS;break;case jr.Fine:t=Ra.Repetition.type.FINE;break;case jr.ToCoda:t=Ra.Repetition.type.TO_CODA;break;case jr.DaCapoAlFine:t=Ra.Repetition.type.DC_AL_FINE;break;case jr.DaCapoAlCoda:t=Ra.Repetition.type.DC_AL_CODA;break;case jr.DalSegnoAlFine:t=Ra.Repetition.type.DS_AL_FINE;break;case jr.DalSegnoAlCoda:t=Ra.Repetition.type.DS_AL_CODA}if(t){if(this.stave.getModifiers().find((function(e){return e.symbol_type===t})))return;var r=new Ra.Repetition(t,n,-this.rules.RepetitionSymbolsYOffset);this.stave.addModifier(r,i)}else this.addVolta(e)}},{key:"addVolta",value:function(e){var t=Ra.Volta.type.BEGIN;if(e.type===jr.Ending){switch(e.alignment){case Kr.Begin:t=this.parentSourceMeasure.endsRepetitionEnding()?Ra.Volta.type.BEGIN_END:Ra.Volta.type.BEGIN;break;case Kr.End:if(this.parentSourceMeasure.beginsRepetitionEnding())return;t=Ra.Volta.type.END}var i=this.ParentStaffLine.SkyBottomLineCalculator,r=this.PositionAndShape.AbsolutePosition.x+this.PositionAndShape.BorderMarginLeft+.4,s=Math.max(this.PositionAndShape.AbsolutePosition.x+this.PositionAndShape.BorderMarginRight,r+.4),a=i.getSkyLineMinInRange(r,s)-2,o=-6.1+this.rules.VoltaOffset,u=this.rules.VoltaOffset;if(a0){var v;L.trace("Ghost Found in between (measure ".concat(this.MeasureNumber,")"));var m=this.createGhostGves(p);(v=i).splice.apply(v,[n,0].concat(a(m))),n+=m.length}}else{var g=f.minus(u,this.parentSourceMeasure.AbsoluteTimestamp);if(g.RealValue>0){var y;L.trace("Ghost Found at start (measure ".concat(this.MeasureNumber,")"));var b=this.createGhostGves(g);(y=i).splice.apply(y,[0,0].concat(a(b))),n+=b.length}}t=l}var S=f.plus(this.parentSourceMeasure.AbsoluteTimestamp,this.parentSourceMeasure.Duration),x=f.minus(S,t);if(x.RealValue>0){L.trace("Ghost Found at end (measure ".concat(this.MeasureNumber,")"));var k=this.createGhostGves(x);i=i.concat(k)}return i}},{key:"createGhostGves",value:function(e){var t,i=[],n=o(Ds.GhostNotes(e));try{for(n.s();!(t=n.n()).done;){var r=t.value,s=new Aa(void 0,void 0);s.vfStaveNote=r,i.push(s)}}catch(a){n.e(a)}finally{n.f()}return i}},{key:"handleBeam",value:function(e,t){var i,n=e.sourceNote.ParentVoiceEntry.ParentVoice.VoiceId,r=this.beams[n];r||(r=this.beams[n]=[]);var s,a=o(r);try{for(a.s();!(s=a.n()).done;){var u=s.value;u[0]===t&&(i=u)}}catch(h){a.e(h)}finally{a.f()}i||(i=[t,[]],r.push(i));var l=e.parentVoiceEntry;i[1].indexOf(l)<0&&i[1].push(l)}},{key:"handleTuplet",value:function(e,t){var i=e.sourceNote.ParentVoiceEntry.ParentVoice.VoiceId;t=e.sourceNote.NoteTuplet;var n,r=this.tuplets[i];r||(r=this.tuplets[i]=[]);var s,a=o(r);try{for(a.s();!(s=a.n()).done;){var u=s.value;u[0]===t&&(n=u)}}catch(h){a.e(h)}finally{a.f()}n||(n=[t,[]],r.push(n));var l=e.parentVoiceEntry;n[1].indexOf(l)<0&&n[1].push(l)}},{key:"finalizeBeams",value:function(){this.vfbeams={};var e=[];for(var t in this.beams)if(this.beams.hasOwnProperty(t)){var i=this.vfbeams[t];i||(i=this.vfbeams[t]=[]);var n,r=o(this.beams[t]);try{for(r.s();!(n=r.n()).done;){var s,a=n.value,u=!1,l=o(a[0].Notes);try{for(l.s();!(s=l.n()).done;){var h=s.value;if(h.Length.RealValue>=new f(1,4).RealValue&&(!h.TypeLength||h.TypeLength.RealValue>.125)){u=!0;break}}}catch(C){l.e(C)}finally{l.f()}if(u)L.debug("Beam between note >= quarter, likely tremolo, currently unsupported. continuing.");else{var c,d=[],p=a[0],v=a[1],m=!0,g=o(v);try{for(g.s();!(c=g.n()).done;){var y=c.value;y.parentVoiceEntry.ParentVoice===p.Notes[0].ParentVoiceEntry.ParentVoice&&(m=y.parentVoiceEntry.WantedStemDirection===os.Undefined)}}catch(C){g.e(C)}finally{g.f()}var b,S=!1,x=void 0,k=[],_=o(v);try{for(_.s();!(b=_.n()).done;){var E=b.value,w=E.vfStaveNote;w&&(d.push(w),e.push(w)),E.parentVoiceEntry.IsGrace&&(S=!0),E.parentVoiceEntry.StemColor&&this.rules.ColoringEnabled&&k.push(E.parentVoiceEntry.StemColor)}}catch(C){_.e(C)}finally{_.f()}if(d.length>1){var M=new Ra.Beam(d,m);if(S&&(M.render_options.beam_width=3,M.render_options.partial_beam_length=4),k.length>=2&&this.rules.ColorBeams){x=k[0];var T,P=o(k);try{for(P.s();!(T=P.n()).done;){if(T.value!==x){x=void 0;break}}}catch(C){P.e(C)}finally{P.f()}M.setStyle({fillStyle:x,strokeStyle:x})}this.rules.FlatBeams&&(M.render_options.flat_beams=!0,M.render_options.flat_beam_offset=this.rules.FlatBeamOffset,M.render_options.flat_beam_offset_per_beam=this.rules.FlatBeamOffsetPerBeam),i.push(M)}else L.debug("Warning! Beam with no notes!")}}}catch(C){r.e(C)}finally{r.f()}}this.rules.AutoBeamNotes&&this.autoBeamNotes(e)}},{key:"autoBeamNotes",value:function(e){if(this.rules.AutoBeamTabs||!this.isTabMeasure){var t,i=[],n=[],r=[];this.autoTupletVfBeams=[];var s=[];this.autoVfBeams=[];var a=this.parentSourceMeasure.ActiveTimeSignature;a||(a=this.parentSourceMeasure.Duration);var u,l=o(this.staffEntries);try{for(l.s();!(u=l.n()).done;){var h,c=u.value,d=o(c.graphicalVoiceEntries);try{for(d.s();!(h=d.n()).done;){var p=h.value,v=p.vfStaveNote,m=p.notes[0],g=c.relInMeasureTimestamp.isOnBeat(a),y=n.length>=2,b=m.sourceNote.Length.RealValue-new f(1,4).RealValue>-f.FloatInaccuracyTolerance,S=p.parentVoiceEntry.IsGrace||b||e.contains(v);if(S||g){if(y){var x,k=o(n);try{for(k.s();!(x=k.n()).done;){var _=x.value;i.push(_)}}catch(K){k.e(K)}finally{k.f()}s.push(i.slice()),i=[]}if(n=[],S)continue}var E=p.notes[0].sourceNote.NoteTuplet;if(E){var w,M=!1,T=o(E.Notes);try{for(T.s();!(w=T.n()).done;){var P,L=o(w.value);try{for(L.s();!(P=L.n()).done;){var C=P.value;if(C.NoteTypeXml>=Vr.QUARTER||C.ParentVoiceEntry.IsGrace||C.isRest()&&!this.rules.AutoBeamOptions.beam_rests){M=!0;break}}}catch(K){L.e(K)}finally{L.f()}if(M)break}}catch(K){T.e(K)}finally{T.f()}if(t){if(t!==E){if(r.length>1){var A=new Ra.Beam(r,!0);this.rules.FlatBeams&&(A.render_options.flat_beams=!0,A.render_options.flat_beam_offset=this.rules.FlatBeamOffset,A.render_options.flat_beam_offset_per_beam=this.rules.FlatBeamOffsetPerBeam),this.autoTupletVfBeams.push(A)}r=[],t=E}}else t=E;M||r.push(v)}else t=void 0,n.push(v)}}catch(K){d.e(K)}finally{d.f()}}}catch(K){l.e(K)}finally{l.f()}if(r.length>=2){var R=new Ra.Beam(r,!0);this.rules.FlatBeams&&(R.render_options.flat_beams=!0,R.render_options.flat_beam_offset=this.rules.FlatBeamOffset,R.render_options.flat_beam_offset_per_beam=this.rules.FlatBeamOffsetPerBeam),this.autoTupletVfBeams.push(R)}if(n.length>=2){var I,N=o(n);try{for(N.s();!(I=N.n()).done;){var B=I.value;i.push(B)}}catch(K){N.e(K)}finally{N.f()}s.push(i)}var D=this.rules.AutoBeamOptions,O={beam_middle_only:D.beam_middle_rests_only,beam_rests:D.beam_rests,maintain_stem_directions:D.maintain_stem_directions};if(D.groups&&D.groups.length){var F,V=[],G=o(D.groups);try{for(G.s();!(F=G.n()).done;){var W=F.value;V.push(new Ra.Fraction(W[0],W[1]))}}catch(K){G.e(K)}finally{G.f()}O.groups=V}for(var U=0,z=s;U1){var h=s[0],c=h.Notes[0][0].NormalNotes,f=h.Bracket||3===h.TupletLabelNumber&&this.rules.TripletsBracketed||3!==h.TupletLabelNumber&&this.rules.TupletsBracketed,d=Ra.Tuplet.LOCATION_TOP;h.tupletLabelNumberPlacement===g.Below&&(d=Ra.Tuplet.LOCATION_BOTTOM),t.push(new Ra.Tuplet(a,{bracketed:f,location:d,notes_occupied:c,num_notes:h.TupletLabelNumber,ratioed:this.rules.TupletsRatioed}))}else L.debug("Warning! Tuplet with no notes! Trying to ignore, but this is a serious problem.")}}catch(p){n.e(p)}finally{n.f()}}}},{key:"layoutStaffEntry",value:function(e){}},{key:"graphicalMeasureCreatedCalculations",value:function(){var e,t,i=[],n=[],r=o(this.staffEntries);try{for(r.s();!(t=r.n()).done;){var s=t.value;e=!1,i=[];var a,u=o(s.graphicalVoiceEntries);try{for(u.s();!(a=u.n()).done;){var l=a.value;if(l.parentVoiceEntry.IsGrace)i.push(l),n.push(l),e||(e=l.parentVoiceEntry.GraceSlur);else if(l.vfStaveNote=Ds.StaveNote(l),i.length>0){for(var h=[],c=0;c0&&(f.GraceSlash=!1);var d=Ds.StaveNote(f);f.vfStaveNote=d,h.push(d)}var p=new Ra.GraceNoteGroup(h,e);l.vfStaveNote.addModifier(0,p),i=[]}}}catch(N){u.e(N)}finally{u.f()}}}catch(N){r.e(N)}finally{r.f()}if(i.length>0){var v,m=o(i);try{for(m.s();!(v=m.n()).done;){var y=v.value;y.vfStaveNote=Ds.StaveNote(y),y.parentVoiceEntry.GraceAfterMainNote=!0}}catch(N){m.e(N)}finally{m.f()}}this.finalizeBeams(),this.finalizeTuplets();var b=this.getVoicesWithinMeasure();if(this.rules.RenderFingerings){var S,x=o(this.staffEntries);try{for(x.s();!(S=x.n()).done;){S.value.setModifierXOffsets()}}catch(N){x.e(N)}finally{x.f()}}var k,_=o(b);try{for(_.s();!(k=_.n()).done;){var E=k.value;if(E){this.vfVoices[E.VoiceId]=new Ra.Voice({beat_value:this.parentSourceMeasure.Duration.Denominator,num_beats:this.parentSourceMeasure.Duration.Numerator,resolution:Ra.RESOLUTION}).setMode(Ra.Voice.Mode.SOFT);var w,M=o(this.getRestFilledVexFlowStaveNotesPerVoice(E));try{for(M.s();!(w=M.n()).done;){var T=w.value;if(!T.parentVoiceEntry||!T.parentVoiceEntry.IsGrace||T.parentVoiceEntry.GraceAfterMainNote){var P=T;if(0!==P.vfStaveNote.ticks.denominator)if(0!==T.notes.length&&T.notes[0]&&T.notes[0].sourceNote.PrintObject){var L=P.parentStaffEntry;if(L&&L.vfClefBefore){var C=new Ia([L.vfClefBefore]);P.vfStaveNote.getCategory&&"stavenotes"===P.vfStaveNote.getCategory()&&P.vfStaveNote.addModifier(0,C)}T.parentVoiceEntry&&this.rules.RenderFingerings&&(this.rules.FingeringPosition!==g.Left&&this.rules.FingeringPosition!==g.Right||this.createFingerings(T),this.createStringNumber(T)),this.createArpeggio(T),this.vfVoices[E.VoiceId].addTickable(P.vfStaveNote)}else this.vfVoices[E.VoiceId].addTickable(P.vfStaveNote)}}}catch(N){M.e(N)}finally{M.f()}}}}catch(N){_.e(N)}finally{_.f()}this.setStemDirectionFromVexFlow();for(var A=0,R=n;A1){var i=Ds.StrokeTypeFromArpeggioType(t.type),n=new Ra.Stroke(i,{all_voices:this.rules.ArpeggiosGoAcrossVoices});this.rules.RenderArpeggios&&e.vfStaveNote.addStroke(0,n)}else L.debug("[OSMD] arpeggio in measure ".concat(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."))}}},{key:"setStemDirectionFromVexFlow",value:function(){var e,t=o(this.staffEntries);try{for(t.s();!(e=t.n()).done;){var i,n=o(e.value.graphicalVoiceEntries);try{for(n.s();!(i=n.n()).done;){var r,s=i.value,a=o(s.notes);try{for(a.s();!(r=a.n()).done;){var u=r.value.vfnote;if(u&&u[0])switch(u[0].getStemDirection()){case Ra.Stem.UP:s.parentVoiceEntry.StemDirection=os.Up;break;case Ra.Stem.DOWN:s.parentVoiceEntry.StemDirection=os.Down}}}catch(l){a.e(l)}finally{a.f()}}}catch(l){n.e(l)}finally{n.f()}}}catch(l){t.e(l)}finally{t.f()}}},{key:"createArticulations",value:function(){for(var e=0,t=this.staffEntries.length;e1||e.parentStaffEntry.graphicalVoiceEntries.length>1?d=Ra.StaveModifier.Position.LEFT:0===p.idInMusicSheet?(d=Ra.StaveModifier.Position.ABOVE,c=g.Above):(d=Ra.StaveModifier.Position.BELOW,c=g.Below)}var v=new Ra.FretHandFinger(h.value);if(v.setPosition(d),v.setOffsetX(f),c===g.Above||c===g.Below){var m=c===g.Above?-1:1,y=c===g.Above?a:n-1-a;if(this.rules.FingeringInsideStafflines&&n>1){var b=v.getWidth()/2,S=2.5*n;v.setOffsetY(m*(y+S)*b)}else if(!this.rules.FingeringInsideStafflines){var x=new Ra.StringNumber(h.value);x.radius=0,x.setPosition(d),x.setOffsetY(m*y*x.getWidth()*2/3),i.vfStaveNote.addModifier(a,x);continue}}i.vfStaveNote.addModifier(a,v)}else a++}}catch(k){u.e(k)}finally{u.f()}}},{key:"createStringNumber",value:function(e){var t=this;if(this.rules.RenderStringNumbersClassical){var i=e;e.notes.forEach((function(n,r){var s=n.sourceNote.StringInstruction;if(s){var a=s.value;switch(a){case"1":a="I";break;case"2":a="II";break;case"3":a="III";break;case"4":a="IV";break;case"5":a="V";break;case"6":a="VI"}var o=new Ra.StringNumber(a);o.radius=0;var u=-t.rules.StringNumberOffsetY;e.notes.length>1||e.parentStaffEntry.graphicalVoiceEntries.length>1?(o.setOffsetX(13*n.baseStringNumberXOffset),o.setPosition(Ra.Modifier.Position.RIGHT)):o.setPosition(Ra.Modifier.Position.ABOVE),o.setOffsetY(u),i.vfStaveNote.addModifier(r,o)}}))}}},{key:"lineTo",value:function(e,t){var i=new Ra.StaveConnector(e.getVFStave(),this.stave);i.setType(t),this.connectors.push(i)}},{key:"getVFStave",value:function(){return this.stave}},{key:"updateInstructionWidth",value:function(){var e,t,i,n=0,r=0,s=o(this.stave.getModifiers());try{for(s.s();!(i=s.n()).done;){var a=i.value;a.getPosition()===Ba.BEGIN?n+=a.getWidth()+a.getPadding(void 0):a.getPosition()===Ba.END&&(r+=a.getWidth()+a.getPadding(void 0))}}catch(u){s.e(u)}finally{s.f()}this.beginInstructionsWidth=(null!==(e=n)&&void 0!==e?e:0)/Is,this.endInstructionsWidth=(null!==(t=r)&&void 0!==t?t:0)/Is}},{key:"addStaveTie",value:function(e,t){this.vfTies.push(e),t.vfTie=e}}]),n}(Ca),Ba=function(e){return e[e.LEFT=1]="LEFT",e[e.RIGHT=2]="RIGHT",e[e.ABOVE=3]="ABOVE",e[e.BELOW=4]="BELOW",e[e.BEGIN=5]="BEGIN",e[e.END=6]="END",e}(Ba||{}),Da=function(e){c(n,e);var i=d(n);function n(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;return k(this,n),(t=i.call(this)).graphicalChordContainers=[],t.tabStaffEntry=void 0,t.MaxAccidentals=0,t.graphicalInstructions=[],t.ties=[],t.graphicalTies=[],t.lyricsEntries=[],t.parentMeasure=e,t.graphicalVoiceEntries=[],t.sourceStaffEntry=r,s?(t.staffEntryParent=s,t.parentVerticalContainer=s.parentVerticalContainer,t.PositionAndShape=new yt(v(t),s.PositionAndShape)):t.PositionAndShape=new yt(v(t),e.PositionAndShape),r&&(t.relInMeasureTimestamp=r.Timestamp),t.FingeringEntries=[],t}return E(n,[{key:"GraphicalInstructions",get:function(){return this.graphicalInstructions}},{key:"GraphicalTies",get:function(){return this.graphicalTies}},{key:"LyricsEntries",get:function(){return this.lyricsEntries},set:function(e){this.lyricsEntries=e}},{key:"getAbsoluteTimestamp",value:function(){var e=this.parentMeasure.parentSourceMeasure.AbsoluteTimestamp.clone();return this.relInMeasureTimestamp&&e.Add(this.relInMeasureTimestamp),e}},{key:"findTieGraphicalNoteFromNote",value:function(e){var t,i=o(this.graphicalVoiceEntries);try{for(i.s();!(t=i.n()).done;){var n,r=o(t.value.notes);try{for(r.s();!(n=r.n()).done;){var s=n.value,a=s.sourceNote;if(!a.isRest()&&a.Pitch.FundamentalNote===e.Pitch.FundamentalNote&&a.Pitch.Octave===e.Pitch.Octave&&a.getAbsoluteTimestamp().Equals(e.getAbsoluteTimestamp()))return s}}catch(u){r.e(u)}finally{r.f()}}}catch(u){i.e(u)}finally{i.f()}}},{key:"findEndTieGraphicalNoteFromNoteWithStartingSlur",value:function(e,t){if(e){var i,n=o(this.graphicalVoiceEntries);try{for(n.s();!(i=n.n()).done;){var r=i.value;if(r.parentVoiceEntry===e.ParentVoiceEntry){var s,a=o(r.notes);try{for(a.s();!(s=a.n()).done;){var u=s.value,l=u.sourceNote;if(l.NoteTie&&-1!==l.NoteSlurs.indexOf(t))return u}}catch(h){a.e(h)}finally{a.f()}}}}catch(h){n.e(h)}finally{n.f()}}}},{key:"findGraphicalNoteFromGraceNote",value:function(e){if(e){var t,i=o(this.graphicalVoiceEntries);try{for(i.s();!(t=i.n()).done;){var n=t.value;if(n.parentVoiceEntry===e.ParentVoiceEntry){var r,s=o(n.notes);try{for(s.s();!(r=s.n()).done;){var a=r.value;if(a.sourceNote===e)return a}}catch(u){s.e(u)}finally{s.f()}}}}catch(u){i.e(u)}finally{i.f()}}}},{key:"findGraphicalNoteFromNote",value:function(e){if(e){var t,i=o(this.graphicalVoiceEntries);try{for(i.s();!(t=i.n()).done;){var n=t.value;if(n.parentVoiceEntry===e.ParentVoiceEntry){var r,s=o(n.notes);try{for(s.s();!(r=s.n()).done;){var a=r.value;if(a.sourceNote===e&&this.getAbsoluteTimestamp().Equals(e.getAbsoluteTimestamp()))return a}}catch(u){s.e(u)}finally{s.f()}}}}catch(u){i.e(u)}finally{i.f()}}}},{key:"getGraphicalNoteDurationFromVoice",value:function(e){var t,i=o(this.graphicalVoiceEntries);try{for(i.s();!(t=i.n()).done;){var n=t.value;if(n.parentVoiceEntry.ParentVoice===e)return n.notes[0].graphicalNoteLength}}catch(r){i.e(r)}finally{i.f()}return new f(0,1)}},{key:"findVoiceEntryGraphicalNotes",value:function(e){var t,i=o(this.graphicalVoiceEntries);try{for(i.s();!(t=i.n()).done;){var n=t.value;if(n.parentVoiceEntry===e)return n.notes}}catch(r){i.e(r)}finally{i.f()}}},{key:"isVoiceEntryPartOfLinkedVoiceEntry",value:function(e){if(this.sourceStaffEntry.Link)for(var t=0,i=this.sourceStaffEntry.Link.LinkStaffEntries.length;t0&&(t=s)}}catch(a){r.e(a)}finally{r.f()}}}catch(a){i.e(a)}finally{i.f()}return t}},{key:"findStaffEntryMaxNoteLength",value:function(){var e,t=new f(0,1),i=o(this.graphicalVoiceEntries);try{for(i.s();!(e=i.n()).done;){var n,r=o(e.value.notes);try{for(r.s();!(n=r.n()).done;){var s=n.value.graphicalNoteLength;t.lt(s)&&s.GetExpandedNumerator()>0&&(t=s)}}catch(a){r.e(a)}finally{r.f()}}}catch(a){i.e(a)}finally{i.f()}return t}},{key:"findOrCreateGraphicalVoiceEntry",value:function(e){var t,i=o(this.graphicalVoiceEntries);try{for(i.s();!(t=i.n()).done;){var n=t.value;if(n.parentVoiceEntry===e)return n}}catch(s){i.e(s)}finally{i.f()}var r=ra.symbolFactory.createVoiceEntry(e,this);return this.graphicalVoiceEntries.push(r),r}},{key:"findOrCreateGraphicalVoiceEntryFromGraphicalNote",value:function(e){var t,i=o(this.graphicalVoiceEntries);try{for(i.s();!(t=i.n()).done;){var n=t.value;if(n===e.parentVoiceEntry)return n}}catch(s){i.e(s)}finally{i.f()}var r=ra.symbolFactory.createVoiceEntry(e.sourceNote.ParentVoiceEntry,this);return this.graphicalVoiceEntries.push(r),r}},{key:"addGraphicalNoteToListAtCorrectYPosition",value:function(e,t){var i=e.notes;if(0===i.length||t.PositionAndShape.RelativePosition.y=0;n--){if(i[n].PositionAndShape.RelativePosition.y>t.PositionAndShape.RelativePosition.y){i.splice(n+1,0,t);break}if(0===n){i.splice(0,0,t);break}}}},{key:"hasOnlyRests",value:function(){var e,t=o(this.graphicalVoiceEntries);try{for(t.s();!(e=t.n()).done;){var i,n=o(e.value.notes);try{for(n.s();!(i=n.n()).done;){if(!i.value.sourceNote.isRest())return!1}}catch(r){n.e(r)}finally{n.f()}}}catch(r){t.e(r)}finally{t.f()}return!0}},{key:"getSkylineMin",value:function(){var e,i=null===(e=this.parentMeasure)||void 0===e?void 0:e.ParentStaffLine.SkyBottomLineCalculator;if(i){var n=t(this.getAbsoluteStartAndEnd(),2),r=n[0],s=n[1];return i.getSkyLineMinInRange(r,s)}}},{key:"getHighestYAtEntry",value:function(){return this.parentMeasure.ParentStaffLine.PositionAndShape.AbsolutePosition.y+this.getSkylineMin()}},{key:"getLowestYAtEntry",value:function(){return this.parentMeasure.ParentStaffLine.PositionAndShape.AbsolutePosition.y+this.getBottomlineMax()}},{key:"getBottomlineMax",value:function(){var e,i=null===(e=this.parentMeasure)||void 0===e?void 0:e.ParentStaffLine.SkyBottomLineCalculator;if(i){var n=t(this.getAbsoluteStartAndEnd(),2),r=n[0],s=n[1];return i.getBottomLineMaxInRange(r,s)}}},{key:"getAbsoluteStartAndEnd",value:function(){var e=this.PositionAndShape.AbsolutePosition.x;return[e-=this.parentMeasure.ParentStaffLine.PositionAndShape.AbsolutePosition.x,e+this.PositionAndShape.Size.width]}}]),n}(vt),Oa=Kt.Flow,Fa=function(e){c(i,e);var t=d(i);function i(e,n,r){return k(this,i),t.call(this,e,n,r)}return E(i,[{key:"calculateXPosition",value:function(){var e,t=this.parentMeasure.getVFStave(),i=0,n=o(this.graphicalVoiceEntries);try{for(n.s();!(e=n.n()).done;){var r=e.value;if(r.vfStaveNote){if(r.vfStaveNote.setStave(t),t&&t.getLines&&1===t.getLines()&&r.vfStaveNote.getStemDirection()<0&&(r.vfStaveNote.setStemDirection(Oa.Stem.UP),r.parentVoiceEntry.StemDirection=os.Up),!r.vfStaveNote.preFormatted)continue;r.applyBordersFromVexflow(),this.parentMeasure.ParentStaff.isTab?this.PositionAndShape.RelativePosition.x=(r.vfStaveNote.getAbsoluteX()+r.vfStaveNote.glyph.getWidth())/Is:this.PositionAndShape.RelativePosition.x=r.vfStaveNote.getBoundingBox().getX()/Is;var s=r.notes[0].sourceNote;s.isRest()&&s.Length.RealValue===this.parentMeasure.parentSourceMeasure.ActiveTimeSignature.RealValue&&(this.PositionAndShape.RelativePosition.x+=this.parentMeasure.parentSourceMeasure.Rules.WholeRestXShiftVexflow-.1,r.PositionAndShape.BorderLeft=-.7,r.PositionAndShape.BorderRight=.7),r.PositionAndShape.BorderLeft=0;a--){if(Math.abs(e[n]-e[a])<=t&&r===i[a]){r++,s=!0;break}s=!1}i.push(r)}return i}}]),i}(Da);Kt.Flow;var Va=function(t){c(n,t);var i=d(n);function n(e,t,r){var s,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Fs.NONE,o=arguments.length>4?arguments[4]:void 0,u=arguments.length>5&&void 0!==arguments[5]?arguments[5]:void 0;if(k(this,n),(s=i.call(this,e,t,o,u)).clef=r,s.octaveShift=a,e.Pitch){var l=e.isRest()?e.Pitch:Os.getPitchFromOctaveShift(e.Pitch,a);s.vfpitch=Ds.pitch(l,e.isRest(),s.clef,s.sourceNote.Notehead),s.vfpitch[1]=void 0}return s}return E(n,[{key:"setAccidental",value:function(e){var t=this.drawPitch(e);this.vfpitch=Ds.pitch(t,this.sourceNote.isRest(),this.clef,this.sourceNote.Notehead),this.DrawnAccidental=t.Accidental}},{key:"drawPitch",value:function(e){return Os.getPitchFromOctaveShift(e,this.octaveShift)}},{key:"Transpose",value:function(t,i,r,s){var a=e(x(n.prototype),"Transpose",this).call(this,t,i,r,s),o=Os.getPitchFromOctaveShift(a,this.octaveShift);return this.vfpitch=Ds.pitch(o,this.sourceNote.isRest(),this.clef,this.sourceNote.Notehead),this.vfpitch[1]=void 0,o}},{key:"setIndex",value:function(e,t){this.vfnote=[e,t],this.vfnoteIndex=t}},{key:"notehead",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0,t=e;t||(t=this.vfnote[0]);var i=t.note_heads;return i&&i.length>this.vfnoteIndex&&i[this.vfnoteIndex]?t.note_heads[this.vfnoteIndex]:{line:0}}},{key:"Clef",value:function(){return this.clef}},{key:"getSVGId",value:function(){if(this.vfnote)return this.vfnote[0].getAttribute("id")}},{key:"getSVGGElement",value:function(){if(this.vfnote)return this.vfnote[0].getAttribute("el")}},{key:"getStemSVG",value:function(){return document.getElementById("vf-"+this.getSVGId()+"-stem")}},{key:"getBeamSVGs",value:function(){for(var e=[],t=0;;t++){var i=document.getElementById("vf-".concat(this.getSVGId(),"-beam").concat(t));if(!i)break;e.push(i)}return e}}]),n}(ha),Ga=function(e){c(i,e);var t=d(i);function i(e,n,r,s,a,o){var u;return k(this,i),(u=t.call(this)).chordSymbolContainer=e,u.boundingBox=new yt(v(u),n),u.rules=o,u.calculateLabel(r,a,s),u}return E(i,[{key:"GetChordSymbolContainer",get:function(){return this.chordSymbolContainer}},{key:"GraphicalLabel",get:function(){return this.graphicalLabel}},{key:"calculateLabel",value:function(e,t,i){var n=sa.calculateChordText(this.chordSymbolContainer,t,i);this.graphicalLabel=new ls(new hs(n),e,this.rules.ChordSymbolTextAlignment,this.rules,this.boundingBox),this.graphicalLabel.PositionAndShape.RelativePosition=new ft(this.rules.ChordSymbolRelativeXOffset,0),this.graphicalLabel.Label.colorDefault=this.rules.DefaultColorChordSymbol}}]),i}(vt),Wa=Kt.Flow,Ua=function(e){c(i,e);var t=d(i);function i(e){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;return k(this,i),(n=t.call(this,e,r,s)).isTabMeasure=!0,n}return E(i,[{key:"resetLayout",value:function(){var e,t=null!==(e=this.ParentStaff.StafflineCount)&&void 0!==e?e:6;this.stave=new Wa.TabStave(0,0,0,{space_above_staff_ln:0,space_below_staff_ln:0,num_lines:t}),this.updateInstructionWidth()}},{key:"graphicalMeasureCreatedCalculations",value:function(){for(var e=0,t=this.staffEntries.length;e1){var p=Ds.StrokeTypeFromArpeggioType(d.type),v=new Wa.Stroke(p,{all_voices:this.rules.ArpeggiosGoAcrossVoices});this.rules.RenderArpeggios&&f.vfStaveNote.addStroke(0,v)}else L.debug("[OSMD] arpeggio in measure ".concat(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."))}this.vfVoices[u.VoiceId].addTickable(f.vfStaveNote)}else this.vfVoices[u.VoiceId].addTickable(f.vfStaveNote)}}}catch(m){h.e(m)}finally{h.f()}}}}catch(m){a.e(m)}finally{a.f()}}}]),i}(Na),za=function(e){c(i,e);var t=d(i);function i(e,n){var r;return k(this,i),(r=t.call(this)).measures=[],r.staffLines=new Array(5),r.octaveShifts=[],r.lyricLines=[],r.lyricsDashes=[],r.abstractExpressions=[],r.graphicalSlurs=[],r.Pedals=[],r.WavyLines=[],r.parentMusicSystem=e,r.parentStaff=n,r.boundingBox=new yt(v(r),e.PositionAndShape),r.skyBottomLine=ra.symbolFactory.createSkyBottomLineCalculator(v(r)),r.staffHeight=r.parentMusicSystem.rules.StaffHeight,r.topLineOffset=0,r.bottomLineOffset=4,r.calculateStaffLineOffsets(),r}return E(i,[{key:"calculateStaffLineOffsets",value:function(){if(this.ParentStaff.isTab)switch(this.ParentStaff.StafflineCount){case 5:this.staffHeight=this.bottomLineOffset=6*this.ParentStaff.ParentInstrument.GetMusicSheet.Rules.TabStaffInterlineHeight;break;default: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}}},{key:"Measures",get:function(){return this.measures},set:function(e){this.measures=e}},{key:"StaffLines",get:function(){return this.staffLines},set:function(e){this.staffLines=e}},{key:"Index",get:function(){return this.parentMusicSystem.StaffLines.indexOf(this)}},{key:"NextStaffLine",get:function(){var e=this.Index;return e!==this.parentMusicSystem.StaffLines.length?this.parentMusicSystem.StaffLines[e+1]:void 0}},{key:"LyricLines",get:function(){return this.lyricLines},set:function(e){this.lyricLines=e}},{key:"AbstractExpressions",get:function(){return this.abstractExpressions},set:function(e){this.abstractExpressions=e}},{key:"LyricsDashes",get:function(){return this.lyricsDashes},set:function(e){this.lyricsDashes=e}},{key:"ParentMusicSystem",get:function(){return this.parentMusicSystem},set:function(e){this.parentMusicSystem=e}},{key:"ParentStaff",get:function(){return this.parentStaff},set:function(e){this.parentStaff=e}},{key:"SkyBottomLineCalculator",get:function(){return this.skyBottomLine}},{key:"SkyLine",get:function(){return this.skyBottomLine.SkyLine}},{key:"BottomLine",get:function(){return this.skyBottomLine.BottomLine}},{key:"OctaveShifts",get:function(){return this.octaveShifts},set:function(e){this.octaveShifts=e}},{key:"StaffHeight",get:function(){return this.staffHeight}},{key:"TopLineOffset",get:function(){return this.topLineOffset}},{key:"BottomLineOffset",get:function(){return this.bottomLineOffset}},{key:"GraphicalSlurs",get:function(){return this.graphicalSlurs}},{key:"addSlurToStaffline",value:function(e){this.graphicalSlurs.push(e)}},{key:"addActivitySymbolClickArea",value:function(){var e=new mt(this),t=this.PositionAndShape;e.PositionAndShape.RelativePosition=new ft(t.RelativePosition.x+t.BorderRight+.5,t.RelativePosition.y+.5),e.PositionAndShape.Parent=this.parentMusicSystem.PositionAndShape}},{key:"isPartOfMultiStaffInstrument",value:function(){return this.parentStaff.ParentInstrument.Staves.length>1}},{key:"findClosestStaffEntry",value:function(e){for(var t=void 0,i=0,n=this.Measures.length;i0)for(var f=c.map((function(e){return e.PositionAndShape.Center.y})),d=Math.max.apply(Math,a(f)),p=0;p0?c[p-1]:void 0;if(g){var b=this.getOverlap(v.PositionAndShape,g.PositionAndShape);v.squeeze(-(b.x+this.rules.DynamicExpressionSpacer))}if(y){var S=this.getOverlap(y.PositionAndShape,v.PositionAndShape);v.squeeze(S.x+this.rules.DynamicExpressionSpacer)}}}}}},{key:"getDistance",value:function(e,t){var i=e.RelativePosition.x+e.BorderMarginRight,n=t.RelativePosition.x+t.BorderMarginLeft,r=e.RelativePosition.y+e.BorderMarginBottom,s=t.RelativePosition.y+t.BorderMarginTop;return new ft(n-i,s-r)}},{key:"getOverlap",value:function(e,t){return new ft(e.RelativePosition.x+e.BorderMarginRight-(t.RelativePosition.x+t.BorderMarginLeft),e.RelativePosition.y+e.BorderMarginBottom-(t.RelativePosition.y+t.BorderMarginTop))}}]),e}(),Ya=function(e){c(i,e);var t=d(i);function i(e,n){var r;return k(this,i),(r=t.call(this,e,n)).slursInVFStaffLine=[],r.alignmentManager=new Xa(v(r)),r}return E(i,[{key:"SlursInVFStaffLine",get:function(){return this.slursInVFStaffLine}},{key:"addVFSlurToVFStaffline",value:function(e){this.slursInVFStaffLine.push(e)}},{key:"AlignmentManager",get:function(){return this.alignmentManager}}]),i}(za),ja=Kt.Flow,Ka=function(e){c(i,e);var t=d(i);function i(e){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;return k(this,i),(n=t.call(this,e,r,s)).minimumStaffEntriesWidth=-1,s?n.rules=s.ParentMusicSystem.rules:r&&(n.rules=r.Rules),n.resetLayout(),n.multiRestElement=new ja.MultiMeasureRest(r.multipleRestMeasures,{}),n}return E(i,[{key:"draw",value:function(e){var t,i,n,r,s,a=e.openGroup();null==a||null===(t=a.classList)||void 0===t||t.add("vf-measure");var u=e.openGroup();null==u||null===(i=u.classList)||void 0===i||i.add("vf-stave"),null==u||u.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();var l=e.openGroup();null==l||null===(s=l.classList)||void 0===s||s.add("vf-voices"),this.multiRestElement.setStave(this.stave),this.multiRestElement.setContext(e),this.multiRestElement.draw(),e.closeGroup();var h,c=o(this.connectors);try{for(c.s();!(h=c.n()).done;){h.value.setContext(e).draw()}}catch(f){c.e(f)}finally{c.f()}return e.closeGroup(),a}},{key:"format",value:function(){}},{key:"getVoicesWithinMeasure",value:function(){return[]}},{key:"getGraphicalVoiceEntriesPerVoice",value:function(e){return[]}},{key:"getRestFilledVexFlowStaveNotesPerVoice",value:function(e){return[]}},{key:"handleBeam",value:function(e,t){}},{key:"handleTuplet",value:function(e,t){}},{key:"finalizeBeams",value:function(){}},{key:"finalizeTuplets",value:function(){}},{key:"layoutStaffEntry",value:function(e){}},{key:"graphicalMeasureCreatedCalculations",value:function(){}},{key:"createArticulations",value:function(){}},{key:"createOrnaments",value:function(){}},{key:"createFingerings",value:function(e){}},{key:"getVFStave",value:function(){return this.stave}}]),i}(Na),qa=Kt.Flow,Ja=function(){function e(){k(this,e)}return E(e,[{key:"getInnerElement",value:function(){return this.inner}},{key:"getCanvas",value:function(){return this.canvas}},{key:"getRenderElement",value:function(){var e=this.canvas;return this.getVexflowBackendType()===qa.Renderer.Backends.CANVAS&&(e=this.inner),e}},{key:"getRenderer",value:function(){return this.renderer}},{key:"removeAllChildrenFromContainer",value:function(e){for(;0!==e.children.length;)e.removeChild(e.children.item(0))}},{key:"removeFromContainer",value:function(e){for(var t=this.getRenderElement(),i=0;i0&&void 0!==arguments[0]?arguments[0]:300,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:300;this.graphicalMusicPage||(this.graphicalMusicPage=new St(void 0),this.graphicalMusicPage.PageNumber=1),this.canvas=document.createElement("canvas"),this.canvas.width=e,this.canvas.height=t,this.renderer=new Za.Renderer(this.canvas,this.getVexflowBackendType()),this.ctx=this.renderer.getContext()}},{key:"getContext",value:function(){return this.ctx}},{key:"clear",value:function(){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())}},{key:"scale",value:function(e){this.ctx.scale(e,e)}},{key:"translate",value:function(e,t){this.CanvasRenderingCtx.translate(e,t)}},{key:"renderText",value:function(e,t,i,n,r,s){var a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:void 0,o=arguments.length>7&&void 0!==arguments[7]?arguments[7]:void 0,u=this.CanvasRenderingCtx.font;this.CanvasRenderingCtx.save(),this.CanvasRenderingCtx.font=Ds.font(e,t,i,this.rules,o),this.CanvasRenderingCtx.fillStyle=a,this.CanvasRenderingCtx.strokeStyle=a,this.CanvasRenderingCtx.fillText(n,s.x,s.y+r),this.CanvasRenderingCtx.restore(),this.CanvasRenderingCtx.font=u}},{key:"renderRectangle",value:function(e,t,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,r=this.CanvasRenderingCtx.fillStyle;this.CanvasRenderingCtx.fillStyle=i||Ds.style(t),this.CanvasRenderingCtx.globalAlpha=n,this.ctx.fillRect(e.x,e.y,e.width,e.height),this.CanvasRenderingCtx.fillStyle=r,this.CanvasRenderingCtx.globalAlpha=1}},{key:"renderLine",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"#FF0000FF",n=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=n}},{key:"renderCurve",value:function(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()}},{key:"CanvasRenderingCtx",get:function(){return this.ctx.vexFlowCanvasContext}}]),i}(Ja),Qa=Kt.Flow,eo=function(e){c(i,e);var t=d(i);function i(e){var n;return k(this,i),(n=t.call(this)).rules=e,n}return E(i,[{key:"getVexflowBackendType",value:function(){return Qa.Renderer.Backends.SVG}},{key:"getOSMDBackendType",value:function(){return ya.SVG}},{key:"getCanvasSize",value:function(){var e;return null===(e=document.getElementById(this.rules.DYContainerId+this.graphicalMusicPage.PageNumber))||void 0===e?void 0:e.offsetHeight}},{key:"initialize",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;this.zoom=t,this.canvas=document.createElement("div"),i||(i=this.graphicalMusicPage?this.graphicalMusicPage.PageNumber.toString():"1"),this.canvas.id=this.rules.DYContainerId+i,this.inner=this.canvas,this.inner.style.position="relative",this.canvas.style.zIndex="0",e.appendChild(this.inner),this.renderer=new Kt.Flow.Renderer(this.canvas,this.getVexflowBackendType()),this.ctx=this.renderer.getContext(),this.ctx.svg.id=this.rules.DYSVGContainerId+i}},{key:"getContext",value:function(){return this.ctx}},{key:"getSvgElement",value:function(){return this.ctx.svg}},{key:"removeNode",value:function(e){var t,i=null===(t=this.ctx)||void 0===t?void 0:t.svg;if(!i)return!1;try{i.removeChild(e)}catch(n){return L.error(n),!1}return!0}},{key:"clear",value:function(){if(this.ctx){for(var e=this.ctx.svg;e.lastChild;)e.removeChild(e.lastChild);this.rules.PageBackgroundColor&&(this.ctx.svg.style["background-color"]=this.rules.PageBackgroundColor)}}},{key:"scale",value:function(e){this.ctx.scale(e,e)}},{key:"translate",value:function(e,t){}},{key:"renderText",value:function(e,t,i,n,r,s){var a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:void 0,o=arguments.length>7&&void 0!==arguments[7]?arguments[7]:void 0;this.ctx.save();var u=this.ctx.openGroup("text");a&&(this.ctx.attributes.fill=a,this.ctx.attributes.stroke=a);var l=o;o&&"default"!==o||(l=this.rules.DefaultFontFamily),this.ctx.setFont(l,e,Ds.fontStyle(t)),this.ctx.attributes["font-size"]="".concat(e,"px"),this.ctx.state["font-size"]="".concat(e,"px");var h="normal",c="normal";switch(t){case Et.Bold:h="bold";break;case Et.Italic:c="italic";break;case Et.BoldItalic:h="bold",c="italic";break;default:h="normal"}return this.ctx.attributes["font-weight"]=h,this.ctx.state["font-weight"]=h,this.ctx.attributes["font-style"]=c,this.ctx.state["font-style"]=c,this.ctx.fillText(n,s.x,s.y+r),this.ctx.closeGroup(),this.ctx.restore(),u}},{key:"renderRectangle",value:function(e,t,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;this.ctx.save();var r=this.ctx.openGroup("rect");return this.ctx.attributes.fill=i||Ds.style(t),this.ctx.attributes["fill-opacity"]=n,this.ctx.fillRect(e.x,e.y,e.width,e.height),this.ctx.restore(),this.ctx.attributes["fill-opacity"]=1,this.ctx.closeGroup(),r}},{key:"renderLine",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"#FF0000FF",n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:2;this.ctx.save();var r=this.ctx.openGroup("line");return this.ctx.beginPath(),this.ctx.moveTo(e.x,e.y),this.ctx.lineTo(t.x,t.y),this.ctx.attributes.stroke=i,this.ctx.lineWidth=n,this.ctx.stroke(),this.ctx.closeGroup(),this.ctx.restore(),r}},{key:"renderCurve",value:function(e){var 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}},{key:"export",value:function(){var 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);var n=(new XMLSerializer).serializeToString(i),r=document.createElement("a");r.href="data:image/svg+xml; charset=utf8, "+encodeURIComponent(n.replace(/>\n\r<")),r.download="opensheetmusicdisplay_download.svg",r.innerHTML=window.location.href+"/download",document.body.appendChild(r)}}]),i}(Ja),to=function(e){c(i,e);var t=d(i);function i(e,n,r){var s;k(this,i),s=t.call(this,e,n,r);var a=new hs(s.Expression);return s.label=new ls(a,s.rules.ContinuousDynamicTextHeight,kt.CenterCenter,s.rules,s.PositionAndShape),s.label.Label.fontStyle=Et.BoldItalic,s.label.setLabelPositionAndShapeBorders(),s.PositionAndShape.calculateBoundingBox(),s}return E(i,[{key:"InstantaneousDynamic",get:function(){return this.mInstantaneousDynamicExpression}},{key:"Expression",get:function(){return st[this.mInstantaneousDynamicExpression.DynEnum]}}]),i}(Cs),io=function(e){c(i,e);var t=d(i);function i(e,n){var r;return k(this,i),(r=t.call(this)).getOctaveShift=e,r.setSymbol(),r.PositionAndShape=new yt(v(r),n),r}return E(i,[{key:"setSymbol",value:function(){switch(this.getOctaveShift.Type){case Fs.VA8:this.octaveSymbol=ks.VA8;break;case Fs.VB8:this.octaveSymbol=ks.VB8;break;case Fs.MA15:this.octaveSymbol=ks.MA15;break;case Fs.MB15:this.octaveSymbol=ks.MB15;break;default:throw new T("")}}}]),i}(vt),no=Kt.Flow,ro=function(e){c(i,e);var t=d(i);function i(e,n){var r;switch(k(this,i),r=t.call(this,e,n),e.Type){case Fs.VA8:r.position=no.TextBracket.Positions.TOP,r.supscript="va",r.text="8";break;case Fs.MA15:r.position=no.TextBracket.Positions.TOP,r.supscript="ma",r.text="15";break;case Fs.VB8:r.position=no.TextBracket.Positions.BOTTOM,r.supscript="vb",r.text="8";break;case Fs.MB15:r.position=no.TextBracket.Positions.BOTTOM,r.supscript="mb",r.text="15";break;default:L.error("Unknown or NONE octaveshift. This should not be called!")}return r}return E(i,[{key:"setStartNote",value:function(e){var t,i=o(e.graphicalVoiceEntries);try{for(i.s();!(t=i.n()).done;){var n=t.value;if(null!=n&&n.vfStaveNote)return this.startNote=n.vfStaveNote,!0}}catch(r){i.e(r)}finally{i.f()}return!1}},{key:"setEndNote",value:function(e){var t,i=o(e.graphicalVoiceEntries);try{for(i.s();!(t=i.n()).done;){var n=t.value;if(null!=n&&n.vfStaveNote)return this.endNote=n.vfStaveNote,!0}}catch(r){i.e(r)}finally{i.f()}return!1}},{key:"getTextBracket",value:function(){return new no.TextBracket({position:this.position,start:this.startNote,stop:this.endNote,superscript:this.supscript,text:this.text})}}]),i}(io);Kt.Flow;var so=function(){function e(t){k(this,e),this.staffPitchListMapping=new Xe,this.baseLineNote=Lt.B,this.baseLineOctave=1,this.rules=t}return E(e,[{key:"trackNote",value:function(t){if(t instanceof Va&&t.Clef().ClefType===Gt.percussion&&!t.sourceNote.isRest()&&0!==this.rules.PercussionOneLineCutoff&&-1!==this.rules.PercussionForceVoicesOneLineCutoff){var i,n=t.parentVoiceEntry.parentStaffEntry.sourceStaffEntry.ParentStaff.idInMusicSheet;this.staffPitchListMapping.containsKey(n)||this.staffPitchListMapping.setValue(n,new Array),i=this.staffPitchListMapping.getValue(n);var r=t.sourceNote.Pitch;e.findOrInsert(i,r)}}},{key:"positionNote",value:function(t){var i=t.parentVoiceEntry.parentStaffEntry.sourceStaffEntry.ParentStaff.idInMusicSheet;if(!(t instanceof Va)||t.sourceNote.isRest()||!this.staffPitchListMapping.containsKey(i))return t;var n=this.staffPitchListMapping.getValue(i),r=this.rules.PercussionUseXMLDisplayStep&&void 0!==t.sourceNote.displayStepUnpitched;if(n.length>this.rules.PercussionOneLineCutoff&&!r)return t;var s=t,a=t.sourceNote.Pitch,o=this.baseLineNote,u=this.baseLineOctave;if(this.rules.PercussionUseXMLDisplayStep&&void 0!==t.sourceNote.displayStepUnpitched&&(o=t.sourceNote.displayStepUnpitched,u=t.sourceNote.displayOctaveUnpitched+this.rules.PercussionOneLineXMLDisplayStepOctaveOffset),n.length<=this.rules.PercussionForceVoicesOneLineCutoff)s.setAccidental(new At(o,u,a.Accidental));else{var l=e.PitchIndexOf(n,a);if(l>-1){var h=Math.ceil(n.length/2);if(!this.rules.PercussionUseXMLDisplayStep)if(l>=h)switch(u=2,(l-h)%5){case 1:o=Lt.E;break;case 2:o=Lt.G;break;case 3:o=Lt.B;break;case 4:o=Lt.D,u=3;break;default:o=Lt.C}else switch(l%5){case 1:o=Lt.F;break;case 2:o=Lt.D;break;case 3:o=Lt.B,u=0;break;case 4:o=Lt.G,u=0;break;default:o=Lt.A}var c=new At(o,u,a.Accidental);s.setAccidental(c);var f=s.parentVoiceEntry.parentVoiceEntry;!this.rules.SetWantedStemDirectionByXml&&f.Notes.length<2&&(c.Octave>this.baseLineOctave||c.FundamentalNote===this.baseLineNote&&c.Octave===this.baseLineOctave?s.parentVoiceEntry.parentVoiceEntry.WantedStemDirection=os.Up:s.parentVoiceEntry.parentVoiceEntry.WantedStemDirection=os.Down)}}return s}},{key:"getStafflineUniquePositionCount",value:function(e){return this.staffPitchListMapping.containsKey(e)?this.staffPitchListMapping.getValue(e).length:0}}],[{key:"PitchIndexOf",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(i>e.length-1)return-1;for(var n=i;n0||l.IsExtraGraphicalMeasure||(L.warn("SkyBottomLineCalculator: width not > 0 in measure "+l.MeasureNumber),c=50),c>=50||!l.IsExtraGraphicalMeasure){n.initializeHeadless(c);var f=n.getContext(),d=n.getCanvas();c=d.width;var p=d.height;"jianpu"===this.mRules.DYMusicScoreType?h.setY(h.y-50):h.setY(h.y+100);var v=h.getWidth();h.setWidth(c),l.format(),h.setWidth(v);try{l.draw(f)}catch(N){L.warn("SkyBottomLineCalculator.calculateLines.draw",N)}for(var m=f.getImageData(0,0,c,p),g=Math.max(Math.ceil(l.PositionAndShape.Size.width*this.mRules.SamplingUnit),1),y=new Array(g),b=new Array(g),S=0;S0){y[S]=x;break}}for(var _=p;_>0;_--){var E=_*c*4+4*S;if(m.data[E+3]>0){b[S]=_;break}}}for(var w=0;w=0;i--)if(!isNaN(t[i]))return t[i];return 0}},{key:"findNextValidNumber",value:function(e,t){if(e>=t.length)return t[e-1];for(var i=e;i2&&void 0!==arguments[2]?arguments[2]:"#FF0000FF",n=t.getContext(),r=n.fillStyle;n.fillStyle=i,n.fillRect(e.x,e.y,2,2),n.fillStyle=r}},{key:"updateSkyLineWithWedge",value:function(e,t){var i=Math.floor(e.x*this.SamplingUnit),n=Math.ceil(t.x*this.SamplingUnit),r=(t.y-e.y)/(t.x-e.x);n-i<=1&&(n++,r=0),i<0&&(i=0),i>=this.BottomLine.length&&(i=this.BottomLine.length-1),n<0&&(n=0),n>=this.BottomLine.length&&(n=this.BottomLine.length),this.SkyLine[i]=e.y;for(var s=i+1;s=this.BottomLine.length&&(i=this.BottomLine.length-1),n<0&&(n=0),n>=this.BottomLine.length&&(n=this.BottomLine.length),this.BottomLine[i]=e.y;for(var s=i+1;s=t?t-1:i}},{key:"getRightIndexForPointX",value:function(e,t){var i=Math.ceil(e*this.SamplingUnit);return i<0?0:i>=t?t-1:i}},{key:"updateStaffLineBorders",value:function(){this.mStaffLineParent.PositionAndShape.BorderTop=this.getSkyLineMin(),this.mStaffLineParent.PositionAndShape.BorderMarginTop=this.getSkyLineMin(),this.mStaffLineParent.PositionAndShape.BorderBottom=this.getBottomLineMax(),this.mStaffLineParent.PositionAndShape.BorderMarginBottom=this.getBottomLineMax()}},{key:"getSkyLineMin",value:function(){return Math.min.apply(Math,a(this.SkyLine.filter((function(e){return!isNaN(e)}))))}},{key:"getSkyLineMinAtPoint",value:function(e){var t=Math.round(e*this.SamplingUnit);return this.mSkyLine[t]}},{key:"getSkyLineMinInRange",value:function(e,t){return this.getMinInRange(this.SkyLine,e,t)}},{key:"getBottomLineMax",value:function(){return Math.max.apply(Math,a(this.BottomLine.filter((function(e){return!isNaN(e)}))))}},{key:"getBottomLineMaxAtPoint",value:function(e){var t=Math.round(e*this.SamplingUnit);return this.mBottomLine[t]}},{key:"getBottomLineMaxInRange",value:function(e,t){return this.getMaxInRange(this.BottomLine,e,t)}},{key:"getBottomLineMaxInBoundingBox",value:function(e){var t=Math.floor(e.AbsolutePosition.x+e.BorderLeft),i=Math.ceil(e.AbsolutePosition.x+e.BorderRight);return this.getMaxInRange(this.mBottomLine,t,i)}},{key:"updateWithBoundingBoxRecursively",value:function(e){if(e.ChildElements&&e.ChildElements.length>0){var t,i=o(e.ChildElements);try{for(i.s();!(t=i.n()).done;){var n=t.value;this.updateWithBoundingBoxRecursively(n)}}catch(c){i.e(c)}finally{i.f()}}else{var r=e.BorderTop+e.AbsolutePosition.y,s=e.BorderBottom+e.AbsolutePosition.y;if(r<0){var a=Math.floor(e.AbsolutePosition.x+e.BorderLeft),u=Math.ceil(e.AbsolutePosition.x+e.BorderRight);this.updateInRange(this.mSkyLine,a,u,r)}else if(s>this.StaffLineParent.StaffHeight){var l=Math.floor(e.AbsolutePosition.x+e.BorderLeft),h=Math.ceil(e.AbsolutePosition.x+e.BorderRight);this.updateInRange(this.mBottomLine,l,h,s)}}}},{key:"updateInRange",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;if(t=Math.floor(t*this.SamplingUnit),(i=Math.ceil(i*this.SamplingUnit))e.length&&(i=e.length);for(var r=t;rMath.abs(e[r])?n:e[r]}},{key:"setInRange",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;if(t=Math.floor(t*this.SamplingUnit),(i=Math.ceil(i*this.SamplingUnit))e.length&&(i=e.length);for(var r=t;r=e.length&&(t=e.length-1),i<0&&(i=0),i>=e.length&&(i=e.length),t>=0&&i<=e.length?Math.min.apply(Math,a(e.slice(t,i+1))):void 0):Number.MAX_VALUE}},{key:"getMaxInRange",value:function(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.apply(Math,a(e.slice(t,i+1))):void 0):Number.MIN_VALUE}},{key:"SamplingUnit",get:function(){return this.mRules.SamplingUnit}},{key:"StaffLineParent",get:function(){return this.mStaffLineParent}},{key:"SkyLine",get:function(){return this.mSkyLine}},{key:"BottomLine",get:function(){return this.mBottomLine}}]),e}(),oo={}; /*! * d-path-parser - v1.0.0 * by Massimo Artizzu (MaxArt2501) * * https://github.com/MaxArt2501/d-path-parser * * Licensed under the MIT License * See LICENSE for details */ !function(e,t){e.exports=function(e){for(var t={command:/\s*([achlmqstvz])/gi,number:/\s*([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/gi,comma:/\s*(?:(,)|\s)/g,flag:/\s*([01])/g},i={number:function(e){return+h("number",e)},"coordinate pair":function(e){var t=h("number",e);return null!==t||e?(h("comma"),{x:+t,y:+h("number",!0)}):null},"arc definition":function(e){var t=i["coordinate pair"](e);if(!t&&!e)return null;h("comma");var n=+h("number",!0);h("comma",!0);var r=!!+h("flag",!0);h("comma");var s=!!+h("flag",!0);return h("comma"),{radii:t,rotation:n,large:r,clockwise:s,end:i["coordinate pair"](!0)}}},n=0,r=[];ni.bottom)switch(e.tagName.toLowerCase()){case"g":var f,d=o(e.children);try{for(d.s();!(f=d.n()).done;){var p=f.value;this.recursiveUpdate(p,i,n,r)}}catch(k){d.e(k)}finally{d.f()}break;case"circle":case"rect":case"line":case"path":var v=Math.floor((s.x-n.x)/Is*this.mRules.SamplingUnit),m=v+Math.ceil(s.width/Is*this.mRules.SamplingUnit);if(e.parentElement.classList.contains("vf-beams")&&e.hasAttribute("d")){var g=oo(e.getAttribute("d"));if(5===g.length)for(var y=g[0],b=g[3],S=(b.end.y-y.end.y)/(b.end.x-y.end.x),x=y.end.y/Is;v<=m;v++)xc[v]&&(c[v]=x),x+=S/this.mRules.SamplingUnit}else for(;v<=m;v++)ac[v]&&(c[v]=u)}}},{key:"calculateLinesForMeasure",value:function(e,t){var i,n,r,s,a=t.getBBox(),u=Math.max(Math.round(e.PositionAndShape.Size.width*this.mRules.SamplingUnit),1),l=a.height/Is,h=t.getElementsByClassName("vf-stave")[0].getBBox(),c=(null==h?void 0:h.height)/Is,f=(null==h?void 0:h.y)/Is,d=e.getVFStave(),p=(null!==(i=d.options)&&void 0!==i&&i.num_lines?d.options.num_lines:5)-1,v=-1,m=0,g=[p],y=o(null===(r=d.options)||void 0===r?void 0:r.line_config);try{for(y.s();!(s=y.n()).done;){s.value.visible?(-1===v&&(v=m),g.push(m)):p--,m++}}catch(P){y.e(P)}finally{y.f()}-1===v&&(v=0),p=g.pop()-v;var b=null===(n=d.options)||void 0===n?void 0:n.spacing_between_lines_px,S=p*b/Is;c-S>.2&&(c=S,f=v*b/Is);var x=f+c,k=new Array(u).fill(f),_=new Array(u).fill(x),E=[k,_];if(l>c){var w,M=o(t.children);try{for(M.s();!(w=M.n()).done;){var T=w.value;this.recursiveUpdate(T,{top:f,bottom:x},a,[k,_])}}catch(P){M.e(P)}finally{M.f()}}return E}},{key:"calculateLines",value:function(){this.mSkyLine=[],this.mBottomLine=[];var e=document.createElement("div");document.body.append(e);var i=new eo(this.mRules);i.initialize(e,1,"0");var n=i.getContext(),r=n.openGroup();r.classList.add("staffline");var s,u=o(this.StaffLineParent.Measures);try{for(u.s();!(s=u.n()).done;){var l,h,c=s.value;c.PositionAndShape.calculateAbsolutePositionsRecursive(0,0),c.setAbsoluteCoordinates(c.PositionAndShape.AbsolutePosition.x*Is,c.PositionAndShape.AbsolutePosition.y*Is);var f=c.draw(n),d=t(this.calculateLinesForMeasure(c,f),2),p=d[0],v=d[1];(l=this.mSkyLine).push.apply(l,a(p)),(h=this.mBottomLine).push.apply(h,a(v))}}catch(M){u.e(M)}finally{u.f()}n.closeGroup();var m,g=o(r.getElementsByClassName("vf-ties"));try{for(g.s();!(m=g.n()).done;){var y,b=o(m.value.childNodes);try{for(b.s();!(y=b.n()).done;){var S=y.value;if("path"===S.nodeName.toLowerCase())for(var x=S.getBBox(),k=Math.floor(x.x/Is*this.mRules.SamplingUnit),_=k+Math.ceil(x.width/Is*this.mRules.SamplingUnit),E=x.y/Is,w=x.height/Is+E;k<=_;k++)Ethis.mBottomLine[k]&&(this.mBottomLine[k]=w)}}catch(M){b.e(M)}finally{b.f()}}}catch(M){g.e(M)}finally{g.f()}i.clear(),e.remove()}}]),n}(ao),lo=Kt.Flow,ho=function(){function e(){k(this,e),this.hasBBox=!1,void 0!==document.createElementNS("http://www.w3.org/2000/svg","g").getBBox&&(this.hasBBox=!0)}return E(e,[{key:"createMusicSystem",value:function(e,t){return new La(e,t)}},{key:"createStaffLine",value:function(e,t){return new Ya(e,t)}},{key:"createSkyBottomLineCalculator",value:function(e){return e.ParentMusicSystem.rules.PerformanceMode&&this.hasBBox?new uo(e):new ao(e)}},{key:"createGraphicalMeasure",value:function(e,t){return new Na(t,e,void 0)}},{key:"createMultiRestMeasure",value:function(e,t,i){return new Ka(t,e,i)}},{key:"createTabStaffMeasure",value:function(e,t){return new Ua(t,e)}},{key:"createExtraGraphicalMeasure",value:function(e){var t=new Na(e.ParentStaff,void 0,e);return t.IsExtraGraphicalMeasure=!0,t.ExtraGraphicalMeasurePreviousMeasure=e.Measures.last(),t}},{key:"createStaffEntry",value:function(e,t){return new Fa(t,e,void 0)}},{key:"createVoiceEntry",value:function(e,t){return new Aa(e,t)}},{key:"createNote",value:function(e,t,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Fs.NONE,r=arguments.length>4?arguments[4]:void 0,s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:void 0;return new Va(e,t,i,n,r,s)}},{key:"createGraceNote",value:function(e,t,i,n){var r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:Fs.NONE;return new Va(e,t,i,r,n)}},{key:"addGraphicalAccidental",value:function(e,t){e.setAccidental(t)}},{key:"addFermataAtTiedEndNote",value:function(e,t){}},{key:"createInStaffClef",value:function(e,t){var i=e,n=Ds.Clef(t,"small");i.vfClefBefore=new lo.ClefNote(n.type,n.size,n.annotation)}},{key:"createChordSymbols",value:function(e,t,i,n){var r,s=t.parentMeasure.parentSourceMeasure.Rules,a=0,u=s.ChordSymbolXSpacing,l=o(e.ChordContainers);try{for(l.s();!(r=l.n()).done;){var h=r.value,c=new Ga(h,t.PositionAndShape,s.ChordSymbolTextHeight,i,n,t.parentMeasure.parentSourceMeasure.Rules),f=c.GraphicalLabel;f.PositionAndShape.RelativePosition.y-=s.ChordSymbolYOffset,f.PositionAndShape.RelativePosition.x+=a,f.setLabelPositionAndShapeBorders(),c.PositionAndShape.calculateBoundingBox(),t.graphicalChordContainers.push(c),a+=f.PositionAndShape.Size.width+u}}catch(d){l.e(d)}finally{l.f()}}},{key:"createGraphicalTechnicalInstruction",value:function(e,t){}}]),e}();Kt.Flow;var co=function(){function e(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;k(this,e),this.tie=t,this.startNote=i,this.endNote=n}return E(e,[{key:"SVGElement",get:function(){return this.vfTie.getAttribute("el")}},{key:"GetTie",get:function(){return this.tie}},{key:"StartNote",get:function(){return this.startNote},set:function(e){this.startNote=e}},{key:"Tie",get:function(){return this.tie}},{key:"EndNote",get:function(){return this.endNote},set:function(e){this.endNote=e}}]),e}(),fo=function(){function e(t,i,n,r){k(this,e),this.lyricsEntry=t,this.graphicalStaffEntry=i;var s=i.parentMeasure.parentSourceMeasure.Rules.LyricsAlignmentStandard;t.Text.length>=4&&t.Parent.Notes[0].Length.Denominator>4&&kt.LeftBottom;var a=new hs(t.Text);this.graphicalLabel=new ls(a,n,s,this.graphicalStaffEntry.parentMeasure.parentSourceMeasure.Rules,i.PositionAndShape),this.graphicalLabel.PositionAndShape.RelativePosition=new ft(0,r),s===kt.LeftBottom&&(this.graphicalLabel.PositionAndShape.RelativePosition.x-=1)}return E(e,[{key:"LyricsEntry",get:function(){return this.lyricsEntry}},{key:"ParentLyricWord",get:function(){return this.graphicalLyricWord},set:function(e){this.graphicalLyricWord=e}},{key:"GraphicalLabel",get:function(){return this.graphicalLabel},set:function(e){this.graphicalLabel=e}},{key:"StaffEntryParent",get:function(){return this.graphicalStaffEntry},set:function(e){this.graphicalStaffEntry=e}}]),e}(),po=function(){function e(t){k(this,e),this.graphicalLyricsEntries=[],this.lyricWord=t,this.initialize()}return E(e,[{key:"GetLyricWord",get:function(){return this.lyricWord}},{key:"GraphicalLyricsEntries",get:function(){return this.graphicalLyricsEntries},set:function(e){this.graphicalLyricsEntries=e}},{key:"isFilled",value:function(){for(var e=0;e=e.bezierCurveStepSize?new ft:new ft(e.oneMinusTPow3[i]*this.bezierStartPt.x+e.bezierFactorOne[i]*this.bezierStartControlPt.x+e.bezierFactorTwo[i]*this.bezierEndControlPt.x+e.tPow3[i]*this.bezierEndPt.x,e.oneMinusTPow3[i]*this.bezierStartPt.y+e.bezierFactorOne[i]*this.bezierStartControlPt.y+e.bezierFactorTwo[i]*this.bezierEndControlPt.y+e.tPow3[i]*this.bezierEndPt.y)}}]),e}();vo.bezierCurveStepSize=1e3;var mo=function(e){c(i,e);var t=d(i);function i(e,n){var r;return k(this,i),(r=t.call(this)).staffEntries=[],r.slur=e,r.rules=n,r}return E(i,[{key:"calculateCurve",value:function(e){var t=this.staffEntries[0],i=this.staffEntries[this.staffEntries.length-1],n=t.findGraphicalNoteFromNote(this.slur.StartNote);!n&&this.graceStart&&(n=t.findGraphicalNoteFromGraceNote(this.slur.StartNote)),n||(n=t.findEndTieGraphicalNoteFromNoteWithStartingSlur(this.slur.StartNote,this.slur));var r=i.findGraphicalNoteFromNote(this.slur.EndNote);!r&&this.graceEnd&&(r=i.findGraphicalNoteFromGraceNote(this.slur.EndNote));var s=t.parentMeasure.ParentStaffLine,a=s.SkyBottomLineCalculator;this.calculatePlacement(a,s);var o,u=this.calculateStartAndEnd(n,r,s,e,a),l=u.startX,h=u.endX,c=u.startY,f=u.endY,d=e.SlurTangentMinAngle,p=e.SlurTangentMaxAngle;if(this.placement===g.Above){c-=e.SlurNoteHeadYOffset,f-=e.SlurNoteHeadYOffset;var v=new ft(this.staffEntries[0].parentMeasure.PositionAndShape.RelativePosition.x+this.staffEntries[0].PositionAndShape.RelativePosition.x,c);n?v.x+=this.staffEntries[0].PositionAndShape.BorderRight:v.x=this.staffEntries[0].parentMeasure.beginInstructionsWidth,this.graceStart&&(v.x+=i.PositionAndShape.RelativePosition.x);var m=new ft(this.staffEntries[this.staffEntries.length-1].parentMeasure.PositionAndShape.RelativePosition.x+this.staffEntries[this.staffEntries.length-1].PositionAndShape.RelativePosition.x,f);if(r?m.x+=this.staffEntries[this.staffEntries.length-1].PositionAndShape.BorderLeft:m.x=this.staffEntries[this.staffEntries.length-1].parentMeasure.PositionAndShape.RelativePosition.x+this.staffEntries[this.staffEntries.length-1].parentMeasure.PositionAndShape.Size.width,this.graceEnd&&(m.x+=i.staffEntryParent.PositionAndShape.RelativePosition.x),0===(o=this.calculateTopPoints(v,m,s,a)).length){var y=new ft((m.x-v.x)/2+v.x,(m.y-v.y)/2+v.y);o.push(y)}var b=Math.atan((f-c)/(h-l)),S=new ft(0,0),x=new ft(h-l,-(f-c)),k=Lr.getRotationMatrix(b),_=k.getTransposeMatrix();x=k.vectorMultiplication(x);var E=this.calculateTranslatedAndRotatedPointListAbove(o,l,c,k),w=this.calculateMaxLeftSlope(E,S,x),M=this.calculateMaxRightSlope(E,S,x),T=S.y-S.x*w,P=x.y-x.x*M,L=new ft,C=!1;Math.abs(Math.abs(w)-Math.abs(M))<1e-4?(L.x=x.x/2,L.y=0,C=!0):(L.x=(P-T)/(w-M),L.y=w*L.x+T);var A=this.calculateHeightWidthRatio(x.x,E),R=0,I=0;if(Math.abs(A)>.001){var N=Math.abs(w/(2*A)),B=Math.abs(w);w-=R=Math.max(0,B*(Math.min(10,N-1)/10));var D=Math.abs(M/(2*A)),O=Math.abs(M);M+=I=Math.max(0,O*(Math.min(10,D-1)/10))}var F=d,V=-d;if(!C){var G=this.calculateAngles(d,w,M,p);F=G.startAngle,V=G.endAngle}var W=this.calculateControlPoints(x.x,F,V,E,A,c,f),U=W.startControlPoint,z=W.endControlPoint;(U=_.vectorMultiplication(U)).x+=l,U.y=-U.y+c,(z=_.vectorMultiplication(z)).x+=l,z.y=-z.y+c,this.bezierStartPt=new ft(l,c-R),this.bezierStartControlPt=new ft(U.x,U.y-R),this.bezierEndControlPt=new ft(z.x,z.y-I),this.bezierEndPt=new ft(h,f-I);for(var H=s.SkyLine.length,X=a.getLeftIndexForPointX(this.bezierStartPt.x,H),Y=a.getLeftIndexForPointX(this.bezierEndPt.x,H),j=this.bezierEndPt.x-this.bezierStartPt.x,K=a.SamplingUnit,q=X;q=X&&(s.SkyLine[$]=Math.min(s.SkyLine[$],Z.y)),++$.001){var ge=Math.abs(ue/(2*pe)),ye=Math.abs(ue);ue-=ve=Math.max(0,ye*(Math.min(10,ge-1)/10));var be=Math.abs(le/(2*pe)),Se=Math.abs(le);le+=me=Math.max(0,Se*(Math.min(10,be-1)/10))}var xe=d,ke=-d;if(!de){var _e=this.calculateAngles(d,ue,le,p);xe=_e.startAngle,ke=_e.endAngle}var Ee=this.calculateControlPoints(re.x,xe,ke,oe,pe,c,f),we=Ee.startControlPoint,Me=Ee.endControlPoint;(we=ae.vectorMultiplication(we)).x+=l,we.y+=c,(Me=ae.vectorMultiplication(Me)).x+=l,Me.y+=c,this.bezierStartPt=new ft(l,c+ve),this.bezierStartControlPt=new ft(we.x,we.y+ve),this.bezierEndControlPt=new ft(Me.x,Me.y+me),this.bezierEndPt=new ft(h,f+me);for(var Te=s.BottomLine.length,Pe=a.getLeftIndexForPointX(this.bezierStartPt.x,Te),Le=a.getLeftIndexForPointX(this.bezierEndPt.x,Te),Ce=this.bezierEndPt.x-this.bezierStartPt.x,Ae=a.SamplingUnit,Re=Pe;Re=Pe&&(s.BottomLine[Be]=Math.max(s.BottomLine[Be],Ne.y)),++Be0)return void(this.placement=g.Above)}var a=this.staffEntries[0],o=this.staffEntries[this.staffEntries.length-1],u=a.graphicalVoiceEntries[0].parentVoiceEntry.StemDirection;if(u===o.graphicalVoiceEntries[0].parentVoiceEntry.StemDirection)this.placement=u===os.Up?g.Below:g.Above;else{var l=a.PositionAndShape.BorderLeft+a.PositionAndShape.RelativePosition.x+a.parentMeasure.PositionAndShape.RelativePosition.x,h=o.PositionAndShape.BorderRight+o.PositionAndShape.RelativePosition.x+o.parentMeasure.PositionAndShape.RelativePosition.x;this.graceStart&&(l+=o.PositionAndShape.RelativePosition.x),this.graceEnd&&(h+=o.staffEntryParent.PositionAndShape.RelativePosition.x);var c=-1*e.getSkyLineMinInRange(l,h),f=e.getBottomLineMaxInRange(l,h)-t.StaffHeight;this.placement=f>c?g.Above:g.Below}}}},{key:"calculateTopPoints",value:function(e,t,i,n){var r=[],s=n.getRightIndexForPointX(e.x,i.SkyLine.length),a=n.getLeftIndexForPointX(t.x,i.SkyLine.length);s<0&&(s=0),a>=i.SkyLine.length&&(a=i.SkyLine.length-1);for(var o=s;o=i.BottomLine.length&&(a=i.BottomLine.length-1);for(var o=s;oh&&e>c&&(l+=e/70*this.rules.SlurHeightFlattenLongSlursFactorByWidth,u/=l*=1+t/30*this.rules.SlurHeightFlattenLongSlursFactorByAngle);var f=Math.min(.5,Math.max(.1,1.7*t/80*u*Math.pow(Math.max(s,.05),.4))),d=Math.min(.5,Math.max(.1,1.7*-n/80*u*Math.pow(Math.max(s,.05),.4))),p=new ft;p.x=e*f*Math.cos(t*i.degreesToRadiansFactor),p.y=e*f*Math.sin(t*i.degreesToRadiansFactor);var v=new ft;v.x=e-e*d*Math.cos(n*i.degreesToRadiansFactor),v.y=-e*d*Math.sin(n*i.degreesToRadiansFactor);for(var m=p.y-v.y;this.rules.SlurMaximumYControlPointDistance&&Math.abs(m)>this.rules.SlurMaximumYControlPointDistance;)m<0?(p.y+=1,v.y-=1):(p.y-=1,v.y+=1),m=p.y-v.y;return{startControlPoint:p,endControlPoint:v}}},{key:"calculateAngles",value:function(e,t,n,r){var s=Math.atan(t)/i.degreesToRadiansFactor;t>0?s+=20:s-=20;var a=Math.atan(n)/i.degreesToRadiansFactor;return n<0?a-=20:a+=20,{startAngle:Math.min(Math.max(e,s),r),endAngle:Math.max(Math.min(-e,a),-r)}}}],[{key:"Compare",value:function(e,t){if(e.staffEntries.length<1)return-1;if(t.staffEntries.length<1)return 1;var i=f.minus(e.staffEntries[e.staffEntries.length-1].getAbsoluteTimestamp(),e.staffEntries[0].getAbsoluteTimestamp()),n=f.minus(t.staffEntries[t.staffEntries.length-1].getAbsoluteTimestamp(),t.staffEntries[0].getAbsoluteTimestamp());return i.RealValue>n.RealValue?1:n.RealValue>i.RealValue?-1:0}}]),i}(vo);mo.degreesToRadiansFactor=Math.PI/180;var go=function(e){c(i,e);var t=d(i);function i(e,n){var r,s=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];switch(k(this,i),(r=t.call(this,e,n)).vfStyle=Kt.Flow.PedalMarking.Styles.BRACKET,r.ChangeBegin=!1,r.ChangeEnd=!1,r.line=-3,r.EndSymbolPositionAndShape=void 0,r.ChangeBegin=e.ChangeBegin,r.ChangeEnd=e.ChangeEnd,r.pedalSymbol){case ks.PEDAL_SYMBOL:r.vfStyle=Kt.Flow.PedalMarking.Styles.TEXT,r.EndSymbolPositionAndShape=new yt(v(r),n);break;case ks.PEDAL_MIXED:r.vfStyle=s&&a?Kt.Flow.PedalMarking.Styles.BRACKET_OPEN_BOTH:s?Kt.Flow.PedalMarking.Styles.BRACKET_OPEN_BEGIN:a?Kt.Flow.PedalMarking.Styles.MIXED_OPEN_END:Kt.Flow.PedalMarking.Styles.MIXED;break;case ks.PEDAL_BRACKET:default:r.vfStyle=s&&a?Kt.Flow.PedalMarking.Styles.BRACKET_OPEN_BOTH:s?Kt.Flow.PedalMarking.Styles.BRACKET_OPEN_BEGIN:a?Kt.Flow.PedalMarking.Styles.BRACKET_OPEN_END:Kt.Flow.PedalMarking.Styles.BRACKET}return r}return E(i,[{key:"setStartNote",value:function(e){if(!e)return!1;var t,i=o(e.graphicalVoiceEntries);try{for(i.s();!(t=i.n()).done;){var n=t.value;if(null!=n&&n.vfStaveNote)return this.startNote=n.vfStaveNote,this.startVfVoiceEntry=n,!0}}catch(r){i.e(r)}finally{i.f()}return!1}},{key:"setEndNote",value:function(e){if(!e)return!1;var t,i=o(e.graphicalVoiceEntries);try{for(i.s();!(t=i.n()).done;){var n=t.value;if(null!=n&&n.vfStaveNote)return this.endNote=n.vfStaveNote,this.endVfVoiceEntry=n,!0}}catch(r){i.e(r)}finally{i.f()}return!1}},{key:"setEndMeasure",value:function(e){this.endMeasure=e}},{key:"CalculateBoundingBox",value:function(){}},{key:"setLine",value:function(e){this.line=e}},{key:"getPedalMarking",value:function(){var e,t,i,n,r=new Kt.Flow.PedalMarking([this.startNote,this.endNote]);return this.endMeasure&&r.setEndStave(this.endMeasure.getVFStave()),r.setStyle(this.vfStyle),r.setLine(this.line),r.setCustomText(this.DepressText,this.ReleaseText),(null===(e=this.endVfVoiceEntry)||void 0===e?void 0:e.parentStaffEntry)!==(null===(t=this.endVfVoiceEntry)||void 0===t||null===(i=t.parentStaffEntry)||void 0===i||null===(n=i.parentMeasure)||void 0===n?void 0:n.staffEntries.last())&&this.endVfVoiceEntry||(r.EndsStave=!0),r.ChangeBegin=this.ChangeBegin,r.ChangeEnd=this.ChangeEnd,r}}]),i}(function(e){c(i,e);var t=d(i);function i(e,n){var r;return k(this,i),(r=t.call(this)).getPedal=e,r.setSymbol(),r.PositionAndShape=new yt(v(r),n),r}return E(i,[{key:"setSymbol",value:function(){!this.getPedal.IsLine&&this.getPedal.IsSign?this.pedalSymbol=ks.PEDAL_SYMBOL:this.getPedal.IsLine&&this.getPedal.IsSign?this.pedalSymbol=ks.PEDAL_MIXED:this.pedalSymbol=ks.PEDAL_BRACKET}}]),i}(vt)),yo=function(e){c(i,e);var t=d(i);function i(e,n){var r,s=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return k(this,i),(r=t.call(this,e,n)).line=1,r.isVibrato=!1,r.toEndOfStopStave=!1,r.isVibrato=s,r}return E(i,[{key:"ToEndOfStopStave",get:function(){return this.toEndOfStopStave}},{key:"setStartNote",value:function(e){var t,i=o(e.graphicalVoiceEntries);try{for(i.s();!(t=i.n()).done;){var n=t.value;if(null!=n&&n.vfStaveNote)return this.startNote=n.vfStaveNote,this.startVfVoiceEntry=n,!0}}catch(r){i.e(r)}finally{i.f()}return!1}},{key:"setEndNote",value:function(e){var t,i=o(e.graphicalVoiceEntries);try{for(i.s();!(t=i.n()).done;){var n=t.value;if(null!=n&&n.vfStaveNote){this.endNote=n.vfStaveNote,this.endVfVoiceEntry=n;var r=this.endVfVoiceEntry.parentStaffEntry.parentMeasure.staffEntries,s=r[r.length-1];return this.toEndOfStopStave=s===this.endVfVoiceEntry.parentStaffEntry,!0}}}catch(a){i.e(a)}finally{i.f()}return!1}},{key:"CalculateBoundingBox",value:function(){var e=this.getVibratoBracket();this.boundingBox.Size.height=.2*e.render_options.wave_height}},{key:"getVibratoBracket",value:function(){var e=new Kt.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}}]),i}(function(e){c(i,e);var t=d(i);function i(e,n){var r;return k(this,i),(r=t.call(this)).getWavyLine=e,r.PositionAndShape=new yt(v(r),n),r}return E(i)}(vt)),bo=Kt.Flow,So=function(t){c(n,t);var i=d(n);function n(e){var t,r,s,a,o,u;if(k(this,n),(s=i.call(this)).beamsNeedUpdate=!1,s.rules=e,ra.symbolFactory=new ho,ra.TextMeasurer=new Ts(s.rules),ra.stafflineNoteCalculator=new so(s.rules),"gonville"===(null===(t=s.rules.DefaultVexFlowNoteFont)||void 0===t?void 0:t.toLowerCase()))Kt.Flow.DEFAULT_FONT_STACK=[null===(a=Kt.Flow.Fonts)||void 0===a?void 0:a.Gonville,null===(o=Kt.Flow.Fonts)||void 0===o?void 0:o.Bravura,null===(u=Kt.Flow.Fonts)||void 0===u?void 0:u.Custom];else if("petaluma"===(null===(r=s.rules.DefaultVexFlowNoteFont)||void 0===r?void 0:r.toLowerCase())){var l,h,c;Kt.Flow.DEFAULT_FONT_STACK=[null===(l=Kt.Flow.Fonts)||void 0===l?void 0:l.Petaluma,null===(h=Kt.Flow.Fonts)||void 0===h?void 0:h.Gonville,null===(c=Kt.Flow.Fonts)||void 0===c?void 0:c.Bravura]}return s}return E(n,[{key:"clearRecreatedObjects",value:function(){e(x(n.prototype),"clearRecreatedObjects",this).call(this),ra.stafflineNoteCalculator=new so(this.rules);var t,i=o(this.graphicalMusicSheet.MeasureList);try{for(i.s();!(t=i.n()).done;){var r,s=o(t.value);try{for(s.s();!(r=s.n()).done;){var a=r.value;null==a||a.clean()}}catch(u){s.e(u)}finally{s.f()}}}catch(u){i.e(u)}finally{i.f()}}},{key:"formatMeasures",value:function(){var e,t=o(this.graphicalMusicSheet.MeasureList);try{for(t.s();!(e=t.n()).done;){var i=e.value;if(i&&i[0]){i[0].format();var n,r=o(i);try{for(r.s();!(n=r.n()).done;){var s,a=n.value,u=o(a.staffEntries);try{for(u.s();!(s=u.n()).done;){s.value.calculateXPosition()}}catch(l){u.e(l)}finally{u.f()}a.finalizeBeams()}}catch(l){r.e(l)}finally{r.f()}}}}catch(l){t.e(l)}finally{t.f()}this.beamsNeedUpdate=!1}},{key:"calculateMeasureXLayout",value:function(e){var t,i=[],n=o(e);try{for(n.s();!(t=n.n()).done;){var r=t.value;r&&i.push(r)}}catch(K){n.e(K)}finally{n.f()}if(0===i.length)return 0;e=i;var s,a=[],u=new bo.Formatter({softmaxFactor:this.rules.SoftmaxFactorVexFlow}),l=e[0].staffEntries.length,h=1,c=o(e);try{for(c.s();!(s=c.n()).done;){var f=s.value;if(f){var d,p=0,v=o(f.staffEntries);try{for(v.s();!(d=v.n()).done;){p+=d.value.setMaxAccidentals()}}catch(K){v.e(K)}finally{v.f()}f.parentSourceMeasure.ImplicitMeasure&&(l=Math.max(f.staffEntries.length,l),h=Math.max(f.staffEntries.length+p,h));var m=f.vfVoices,g=[];for(var y in m)m.hasOwnProperty(y)&&(g.push(m[y]),a.push(m[y]));0!==g.length?u.joinVoices(g):L.debug("Found a measure with no voices. Continuing anyway.",m)}}}catch(K){c.e(K)}finally{c.f()}var b=12,S=e[0].parentSourceMeasure;if(a.length>0){b=u.preCalculateMinTotalWidth(a)/Is*this.rules.VoiceSpacingMultiplierVexflow+this.rules.VoiceSpacingAddendVexflow+.3*l,null!=S&&S.ImplicitMeasure&&(b=S.Duration.RealValue/S.ActiveTimeSignature.RealValue*b,l>1&&(b+=.3*h*1.5),b*=this.rules.PickupMeasureWidthMultiplier),ra.setMeasuresMinStaffEntriesWidth(e,b);var x,k=function(e,t){u.formatToStave(a,t.getVFStave())},_=function(e,t){u.formatToStave(a,t.getVFStave(),{align_rests:!0,context:void 0})},E=o(e);try{for(E.s();!(x=E.n()).done;){var w=x.value;if(this.rules.AlignRests===ma.Never)w.formatVoices=k;else if(this.rules.AlignRests===ma.Always)w.formatVoices=_;else if(this.rules.AlignRests===ma.Auto){var M,T=!1,P=o(w.staffEntries);try{for(P.s();!(M=P.n()).done;){var C,A=M.value,R=0,I=0,N=o(A.graphicalVoiceEntries);try{for(N.s();!(C=N.n()).done;){var B=C.value;if(B.parentVoiceEntry.IsGrace||B&&B.notes&&B.notes[0]&&B.notes[0].sourceNote&&B.notes[0].sourceNote.PrintObject&&R++,B&&B.notes&&B.notes[0]&&B.notes[0].sourceNote&&B.notes[0].sourceNote.isRest()&&B.notes[0].sourceNote.PrintObject&&I++,R>1&&I>=1){T=!0;break}}}catch(K){N.e(K)}finally{N.f()}if(T)break}}catch(K){P.e(K)}finally{P.f()}w.formatVoices=T?_:k}if(w===e[0]){var D=w;D.formatVoices(b*Is,D)}}}catch(K){E.e(K)}finally{E.f()}}var O,F=o(e);try{for(F.s();!(O=F.n()).done;){var V=O.value;if(V){var G,W=o(V.staffEntries);try{for(W.s();!(G=W.n()).done;){G.value.calculateXPosition()}}catch(K){W.e(K)}finally{W.f()}}}}catch(K){F.e(K)}finally{F.f()}var U,z=o(e);try{for(z.s();!(U=z.n()).done;){var H=U.value;if(H){var X=H.vfVoices,Y=[];for(var j in X)X.hasOwnProperty(j)&&Y.push(X[j]);0!==Y.length?u.joinVoices(Y):L.debug("Found a measure with no voices. Continuing anyway.",X)}}}catch(K){z.e(K)}finally{z.f()}return b}},{key:"calculateElongationFactor",value:function(e,t,i,n,r,s,a,u){var l,h=r,c=0,f=o(e);try{for(f.s();!(l=f.n()).done;){var d=l.value,p=d.GraphicalLabel.Label.textAlignment,v=a,m=u;if(d instanceof fo&&d.ParentLyricWord){d.LyricsEntry.SyllableIndex>0&&(v=this.rules.BetweenSyllableMinimumDistance,_t.IsCenterAligned(p)&&(v+=1));var g=d.ParentLyricWord.GetLyricWord.Syllables;g.length>1&&d.LyricsEntry.SyllableIndex4&&(P*=1.1)}}else i[c]&&(P=x/k);M=Math.max(T,P),h=Math.max(h,M);var C=Math.max(x-k||0,0);i[c]&&(C+=i[c].cumulativeOverlap),i[c]={cumulativeOverlap:C,extend:d instanceof fo&&d.LyricsEntry.extend,labelWidth:b,measureNumber:s,sourceNoteDuration:d instanceof fo&&(d.LyricsEntry&&d.LyricsEntry.Parent.Notes[0].Length),text:d instanceof fo?d.LyricsEntry.Text:d.GraphicalLabel.Label.text,xPosition:S},c++}}catch(A){f.e(A)}finally{f.f()}return h}},{key:"calculateElongationFactorFromStaffEntries",value:function(e,t,i,n){var r,s=i,a={},u={},l=o(e);try{for(l.s();!(r=l.n()).done;){var h=r.value;h.LyricsEntries.length>0&&(s=this.calculateElongationFactor(h.LyricsEntries,h,a,t,s,n,this.rules.HorizontalBetweenLyricsDistance,this.rules.LyricOverlapAllowedIntoNextMeasure)),h.graphicalChordContainers.length>0&&(s=this.calculateElongationFactor(h.graphicalChordContainers,h,u,t,s,n,this.rules.ChordSymbolXSpacing,this.rules.ChordOverlapAllowedIntoNextMeasure))}}catch(c){l.e(c)}finally{l.f()}return s}},{key:"calculateMeasureWidthFromStaffEntries",value:function(e,t){var i,n=1,r=o(e);try{for(r.s();!(i=r.n()).done;){var s=i.value;s&&0!==s.staffEntries.length&&(n=this.calculateElongationFactorFromStaffEntries(s.staffEntries,t,n,s.MeasureNumber))}}catch(a){r.e(a)}finally{r.f()}return t*(n=Math.min(n,this.rules.MaximumLyricsElongationFactor))}},{key:"createGraphicalTie",value:function(e,t,i,n,r){return new co(e,n,r)}},{key:"updateStaffLineBorders",value:function(e){e.SkyBottomLineCalculator.updateStaffLineBorders()}},{key:"graphicalMeasureCreatedCalculations",value:function(e){e.rules=this.rules,e.graphicalMeasureCreatedCalculations()}},{key:"layoutVoiceEntry",value:function(e,t,i,n){for(var r=0;r=2&&(s=n.vfnote[0],a=n.vfnote[1]);var o=void 0,u=0;if(r&&r.vfnote&&r.vfnote.length>=2&&(o=r.vfnote[0],u=r.vfnote[1]),t){if(s){var l=new bo.StaveTie({first_indices:[a],first_note:s});n.parentVoiceEntry.parentStaffEntry.parentMeasure.addStaveTie(l,e)}if(o){var h=new bo.StaveTie({last_indices:[u],last_note:o});r.parentVoiceEntry.parentStaffEntry.parentMeasure.addStaveTie(h,e)}}else if(s||o){var c;if(i)if("S"===e.Tie.Type){var f=e.StartNote.sourceNote,d=e.EndNote.sourceNote,p=1;f.FretNumber>d.FretNumber&&(p=-1),c=new bo.TabSlide({first_indices:[a],first_note:s,last_indices:[u],last_note:o},p)}else c=new bo.TabTie({first_indices:[a],first_note:s,last_indices:[u],last_note:o},e.Tie.Type);else{c=new bo.StaveTie({first_indices:[a],first_note:s,last_indices:[u],last_note:o});var v=e.Tie.getTieDirection(n.sourceNote);v===g.Below?c.setDirection(1):v===g.Above&&c.setDirection(-1);try{var m,y;Math.abs((null===(m=s)||void 0===m?void 0:m.getTieRightX())-(null===(y=o)||void 0===y?void 0:y.getTieLeftX()))<10&&(c.render_options.first_x_shift=-3,c.render_options.last_x_shift=3)}catch(b){console.log(b)}}r.parentVoiceEntry.parentStaffEntry.parentMeasure.addStaveTie(c,e)}}},{key:"calculateDynamicExpressionsForMultiExpression",value:function(e,t,i){if(!(tthis.rules.MaxMeasureToDrawIndex)){var n=e.AbsoluteTimestamp,r=this.graphicalMusicSheet.MeasureList[t],s=r[i].ParentStaffLine,a=r[i];if(s){var o=this.getRelativePositionInStaffLineFromTimestamp(n,i,s,null==s?void 0:s.isPartOfMultiStaffInstrument());if(o.x<=0&&(o.x=a.beginInstructionsWidth+this.rules.RhythmRightMargin),e.InstantaneousDynamic){var u=new to(e.InstantaneousDynamic,s,a);this.calculateGraphicalInstantaneousDynamicExpression(u,o,n),this.dynamicExpressionMap.set(n.RealValue,u.PositionAndShape)}if(e.StartingContinuousDynamic){var l=e.StartingContinuousDynamic,h=new Ha(e.StartingContinuousDynamic,s,a.parentSourceMeasure);if(h.StartMeasure=a,!h.IsVerbal&&l.EndMultiExpression)try{this.calculateGraphicalContinuousDynamic(h,o),h.updateSkyBottomLine()}catch(c){}else h.IsVerbal?this.calculateGraphicalVerbalContinuousDynamic(h,o):L.warn("This continuous dynamic is not covered. measure"+e.SourceMeasureParent.MeasureNumber)}}}}},{key:"createMetronomeMark",value:function(e,t){var i,n,r,s=Math.max(e.ParentMultiTempoExpression.SourceMeasureParent.MeasureNumber-1,0),u=t||s,l=Math.max(e.StaffNumber-1,0),h=this.graphicalMusicSheet.MeasureList[u][l].getVFStave(),c="q";if(e.beatUnit){var f=Gr.getNoteDurationFromType(e.beatUnit);c=Ds.durations(f,!1)[0]}var d=this.rules.MetronomeMarkYShift,p=!1,v=[];if(e.parentMeasure){var m,y=o(e.parentMeasure.StaffLinkedExpressions);try{for(y.s();!(m=y.n()).done;){var b,S=o(m.value);try{for(S.s();!(b=S.n()).done;){var x=b.value;x&&x instanceof Hs&&v.push(x)}}catch(j){S.e(j)}finally{S.f()}}}catch(j){y.e(j)}finally{y.f()}var k,_=o(e.parentMeasure.TempoExpressions);try{for(_.s();!(k=_.n()).done;){var E,w=k.value,M=(null===(E=w.InstantaneousTempo)||void 0===E?void 0:E.Enum)===Ws.metronomeMark;if(!e.beatUnit&&w.InstantaneousTempo.beatUnit){var T=Gr.getNoteDurationFromType(e.beatUnit);c=Ds.durations(T,!1)[0]}if(w.getPlacementOfFirstEntry()===g.Above&&!M){p=!0;break}}}catch(j){_.e(j)}finally{_.f()}}p&&(d-=1.4);var P,L=null===(i=this.graphicalMusicSheet.MeasureList[0][0].ParentStaffLine)||void 0===i?void 0:i.SkyLine,C=e.TempoInBpm,A="",R="",I="",N=o(this.graphicalMusicSheet.MeasureList[u][l].parentSourceMeasure.TempoExpressions);try{for(N.s();!(P=N.n()).done;){var B=P.value;if(R=B.CombinedExpressionsText,Ss(B.CombinedExpressionsText)){A=B.CombinedExpressionsText;break}if(ys(B.CombinedExpressionsText)||bs(B.CombinedExpressionsText)){A=B.CombinedExpressionsText.replace(gs,"").replace("速度 ",""),C=B.sourceMeasure.TempoInBPM,ys(B.CombinedExpressionsText)&&(I=c);break}}}catch(j){N.e(j)}finally{N.f()}var D={bpm:e.TempoInBpm,dots:e.dotted,duration:c,name:A};A&&(D.bpm=C/(D.dots?1.5:1),ys(R)?D.duration=I:C!==cs[A]&&cs[A]||(D.duration=""));var O=(null===(n=this.graphicalMusicSheet.MeasureList[u][l].vfVoices)||void 0===n||null===(r=n[1])||void 0===r?void 0:r.boundingBox.y)||0;if(this.rules.MetronomeMarksDrawn){if(L){var F,V,G=(null===(F=this.graphicalMusicSheet.MeasureList[0])||void 0===F||null===(V=F[l])||void 0===V?void 0:V.ParentStaffLine).Measures.map((function(e){return e.MeasureNumber-1}));if(O&&G.includes(u)&&(ys(R)||bs(R))){var W=L.slice(0,9),U=Math.min.apply(Math,a(W));d+=U=U<0?U-1:U}G.includes(u)&&v.length?L[0]=Math.min(L[0],-4.5+d-4):L[0]=Math.min(L[0],-4.5+d)}h.options.line_config.reduce((function(e,t){return t.visible&&e++,e}),0)<5&&(d-=2),h.setTempo(D,d*Is);var z=0;try{var H,X,Y;z+=(null===(H=this.graphicalMusicSheet.MeasureList[u][l])||void 0===H||null===(X=H.vfVoices)||void 0===X||null===(Y=X[1])||void 0===Y?void 0:Y.getTickables())[e.parentMeasure.metronomeNoteIndex].getBoundingBox().getX()-h.getNoteStartX()}catch(K){}h.getModifiers()[h.getModifiers().length-1].setShiftX(z)}}},{key:"calculateRehearsalMark",value:function(e){var t,i,n=e.rehearsalExpression;if(n){var r=this.graphicalMusicSheet.MeasureList[0][0].MeasureNumber,s=Math.max(e.measureListIndex+1-r,0),a=null===(t=this.graphicalMusicSheet.MeasureList[s][0])||void 0===t?void 0:t.getVFStave();if(a){var u=-this.rules.RehearsalMarkYOffsetDefault-this.rules.RehearsalMarkYOffset,l=this.rules.RehearsalMarkXOffsetDefault+this.rules.RehearsalMarkXOffset;e.IsSystemStartMeasure&&(l+=this.rules.RehearsalMarkXOffsetSystemStartMeasure);var h=this.rules.RehearsalMarkFontSize,c=a.getModifiers(),f=c.find((function(e){return"repetitions"===e.getCategory().toLocaleLowerCase()}));if(f&&f.setShiftY(f.y_shift-10),a.setSection(n.label,u,l,h),null!==(i=this.graphicalMusicSheet.MeasureList[s][0])&&void 0!==i&&i.ParentStaffLine.AbstractExpressions){var d,p,v,m,g=c.find((function(e){return"stavesection"===e.getCategory().toLocaleLowerCase()})),y=o((null==e||null===(d=e.VerticalMeasureList)||void 0===d||null===(p=d[0])||void 0===p||null===(v=p.ParentStaffLine)||void 0===v?void 0:v.AbstractExpressions)||[]);try{for(y.s();!(m=y.n()).done;){var b=m.value;b instanceof Rs&&(g&&(b.Label.PositionAndShape.RelativePosition.y-=.5),f&&(b.Label.PositionAndShape.RelativePosition.y-=1.7))}}catch(S){y.e(S)}finally{y.f()}}}}}},{key:"calculateSingleOctaveShift",value:function(e,t,i,n){var r,s=t.OctaveShiftStart,a=s.ParentStartMultiExpression.Timestamp,u=null===(r=s.ParentEndMultiExpression)||void 0===r?void 0:r.Timestamp,l=this.rules.MinMeasureToDrawIndex,h=this.rules.MaxMeasureToDrawIndex,c=this.graphicalMusicSheet.MeasureList[i][n].ParentStaffLine;c||(c=this.graphicalMusicSheet.MeasureList[l][n].ParentStaffLine);var f=void 0;(f=s.ParentEndMultiExpression?this.graphicalMusicSheet.getGraphicalMeasureFromSourceMeasureAndIndex(s.ParentEndMultiExpression.SourceMeasureParent,n):this.graphicalMusicSheet.getLastGraphicalMeasureFromIndex(n,!0)).MeasureNumber>h+1&&(f=this.graphicalMusicSheet.getLastGraphicalMeasureFromIndex(n,!0));var d=void 0;if((d=s.ParentEndMultiExpression?this.graphicalMusicSheet.getGraphicalMeasureFromSourceMeasureAndIndex(s.ParentStartMultiExpression.SourceMeasureParent,n):this.graphicalMusicSheet.MeasureList[l][n]).MeasureNumberh||f.parentSourceMeasure.measureListIndexh)){var p=f.ParentStaffLine;if(p||(p=c),f&&c&&p){var v=new ro(s,c.PositionAndShape);if(!v.startNote){var m,g,y=o(d.staffEntries);try{for(y.s();!(g=y.n()).done;){var b=g.value;if(b){m=b;break}}}catch(O){y.e(O)}finally{y.f()}if(!m)return;if(v.setStartNote(m),!v.startNote)return}if(!v.endNote){for(var S,x=f.staffEntries.length-1;x>=0;x++)if(f.staffEntries[x]){S=f.staffEntries[x];break}if(v.setEndNote(S),!v.endNote)return}var k=d.findGraphicalStaffEntryFromTimestamp(a);k||(k=d.staffEntries[0]);var _=f.findGraphicalStaffEntryFromTimestamp(u);if(_||(_=f.staffEntries[f.staffEntries.length-1]),v.setStartNote(k),p!==c){v.endsOnDifferentStaffLine=!0;var E=c.Measures[c.Measures.length-1];void 0===E&&(E=f);var w=E.staffEntries[E.staffEntries.length-1];v.setEndNote(w);var M=p.ParentMusicSystem.Id-c.ParentMusicSystem.Id;if(M>0)for(var T=c.ParentMusicSystem.Id;Tl+1&&(c=this.graphicalMusicSheet.getLastGraphicalMeasureFromIndex(n,!0));var f=void 0;if(s.ParentEndMultiExpression?f=this.graphicalMusicSheet.getGraphicalMeasureFromSourceMeasureAndIndex(s.ParentStartMultiExpression.SourceMeasureParent,n):(f=this.graphicalMusicSheet.getGraphicalMeasureFromSourceMeasureAndIndex(s.ParentStartMultiExpression.SourceMeasureParent,n))||(f=this.graphicalMusicSheet.MeasureList[u][n]),f.MeasureNumberl||c.parentSourceMeasure.measureListIndexl)){var d=c.ParentStaffLine;if(d||(d=h),c&&h&&d){var p=!1;h!==d&&(p=!0);var v=new go(s,h.PositionAndShape,!1,p),m=f.findGraphicalStaffEntryFromTimestamp(a);m||(m=f.staffEntries[0]);var g=c.findGraphicalStaffEntryFromTimestamp(o);if(g||(g=c.staffEntries[c.staffEntries.length-1]),!v.setStartNote(m))return;if(d!==h)if(v.pedalSymbol===ks.PEDAL_SYMBOL){v.setEndNote(g),v.setEndMeasure(c),v.ReleaseText=" ",v.CalculateBoundingBox(),this.calculatePedalSkyBottomLine(v.startVfVoiceEntry,v.endVfVoiceEntry,v,h);var y=d.Measures[0],b=new go(s,y.PositionAndShape),S=y.staffEntries[0];if(!b.setStartNote(S))return;b.setEndNote(g),v.setEndMeasure(c),d.Pedals.push(b),b.CalculateBoundingBox(),b.DepressText=" ",this.calculatePedalSkyBottomLine(b.startVfVoiceEntry,b.endVfVoiceEntry,b,d)}else{var x=h.Measures[h.Measures.length-1];void 0===x&&(x=c);var k=x.staffEntries[x.staffEntries.length-1];v.setEndNote(k),v.setEndMeasure(c),v.ChangeEnd=!1;var _=d.ParentMusicSystem.Id-h.ParentMusicSystem.Id;if(_>0)for(var E=1,w=h.ParentMusicSystem.Id;wl+1&&(c=this.graphicalMusicSheet.getLastGraphicalMeasureFromIndex(n,!0));var f=void 0;if((f=s.ParentEndMultiExpression?this.graphicalMusicSheet.getGraphicalMeasureFromSourceMeasureAndIndex(s.ParentStartMultiExpression.SourceMeasureParent,n):this.graphicalMusicSheet.MeasureList[u][n]).MeasureNumberl||c.parentSourceMeasure.measureListIndexl)){var d=c.ParentStaffLine;if(d||(d=h),c&&h&&d){var p=new yo(s,h.PositionAndShape,f.ParentStaff.isTab),v=f.findGraphicalStaffEntryFromTimestamp(a);v||(v=f.staffEntries[0]);var m=c.findGraphicalStaffEntryFromTimestamp(o);if(m||(m=c.staffEntries[c.staffEntries.length-1]),p.setStartNote(v),d!==h){var g=h.Measures[h.Measures.length-1];void 0===g&&(g=c);var y=g.staffEntries[g.staffEntries.length-1];if(p.setEndNote(y),d.ParentMusicSystem.Id-h.ParentMusicSystem.Id>0)for(var b=h.ParentMusicSystem.Id;bf){var _=f;f=h,h=_}n.SkyBottomLineCalculator.updateBottomLineInRange(h,f,d+x)}var E,w=o(n.Pedals);try{for(w.s();!(E=w.n()).done;){var M=E.value,T=M.getPedalMarking();if(d>T.line+3+(n.StaffLines.length-1)){var P,L=T.render_options.text_margin_right/10,C=M.startVfVoiceEntry.PositionAndShape.AbsolutePosition.x-L,A=void 0;M.setLine(d-3-(n.StaffLines.length-1));var R=null===(P=M.endVfVoiceEntry)||void 0===P?void 0:P.PositionAndShape;if(R||(R=M.endMeasure.PositionAndShape),M.EndSymbolPositionAndShape){var I=a.render_options.glyph_point_size/20;A=C+3.4;var N=R.AbsolutePosition.x-L,B=N+1.5;n.SkyBottomLineCalculator.updateBottomLineInRange(C,A,d+I),n.SkyBottomLineCalculator.updateBottomLineInRange(N,B,d+I)}else{var D,O,F=T.render_options.bracket_height/10;if(T.EndsStave)A=R.AbsolutePosition.x+R.Size.width-L;else switch(a.style){case s.BRACKET_OPEN_END:case s.BRACKET_OPEN_BOTH:case s.MIXED_OPEN_END:A=R.AbsolutePosition.x+R.BorderRight-L;break;default:A=R.AbsolutePosition.x+R.BorderLeft-L}var V=null===(D=M.endVfVoiceEntry)||void 0===D||null===(O=D.parentStaffEntry)||void 0===O?void 0:O.vfClefBefore;if(V)A+=V.getWidth()/10;if(C>A){var G=C;C=A,A=G}n.SkyBottomLineCalculator.updateBottomLineInRange(C,A,d+F)}}}}catch(W){w.e(W)}finally{w.f()}}},{key:"calculateOctaveShiftSkyBottomLine",value:function(e,t,i,n){if(t){var r=e.PositionAndShape.Size.width,s=t.PositionAndShape.Size.width;e.hasOnlyRests()?r=-r:r/=2,t.hasOnlyRests()?s*=2:s/=2,e===t&&(s*=2);var a=e.PositionAndShape.AbsolutePosition.x-r,o=t.PositionAndShape.AbsolutePosition.x+s;i.PositionAndShape.Size.width=a-o;var u=i.getTextBracket(),l=u.font.size/10;if(u.position===bo.TextBracket.Positions.TOP){var h=Math.ceil(n.SkyBottomLineCalculator.getSkyLineMinInRange(a,o));if(h===1/0)return;u.start.getStave().options.top_text_position=Math.abs(h),n.SkyBottomLineCalculator.updateSkyLineInRange(a,o,h-2*l)}else{var c=n.SkyBottomLineCalculator.getBottomLineMaxInRange(a,o);if(c===1/0)return;u.start.getStave().options.bottom_text_position=c,e.parentMeasure!==t.parentMeasure&&(u.stop.getStave().options.bottom_text_position=c),n.SkyBottomLineCalculator.updateBottomLineInRange(a,o,c+1.5*l)}}else L.warn("octaveshift: no endStaffEntry")}},{key:"calculateWordRepetitionInstruction",value:function(e,t){for(var i=void 0,n=this.graphicalMusicSheet.MeasureList[t],r=0,s=n.length;rn.graphicalLyricWords.length-1){var u=new po(r.Word);s.ParentLyricWord=u,u.GraphicalLyricsEntries[a]=s,n.graphicalLyricWords.push(u)}else{var l=n.graphicalLyricWords[o];s.ParentLyricWord=l,l.GraphicalLyricsEntries[a]=s,l.isFilled()&&(i.splice(o,1),n.graphicalLyricWords.splice(n.graphicalLyricWords.indexOf(l),1))}}}))}},{key:"handleVoiceEntryOrnaments",value:function(e,t,i){}},{key:"handleVoiceEntryArticulations",value:function(e,t,i){}},{key:"handleVoiceEntryTechnicalInstructions",value:function(e,t,i){}},{key:"handleTuplet",value:function(e,t,i){e.parentVoiceEntry.parentStaffEntry.parentMeasure.handleTuplet(e,t)}},{key:"findIndexGraphicalSlurFromSlur",value:function(e,t){for(var i=0;i=0){var P=l[T];-1===P.staffEntries.indexOf(y)&&P.staffEntries.push(y),l.splice(T,1)}}}}}catch(V){E.e(V)}finally{E.f()}}}catch(V){x.e(V)}finally{x.f()}}}catch(V){b.e(V)}finally{b.f()}var L,C=o(l);try{for(C.s();!(L=C.n()).done;){var A=L.value;-1===A.staffEntries.indexOf(y)&&A.staffEntries.push(y)}}catch(V){C.e(V)}finally{C.f()}}}catch(V){m.e(V)}finally{m.f()}}}catch(V){p.e(V)}finally{p.f()}}}catch(V){a.e(V)}finally{a.f()}}}catch(V){r.e(V)}finally{r.f()}var R,I=o(this.musicSystems);try{for(I.s();!(R=I.n()).done;){var N,B=o(R.value.StaffLines);try{for(B.s();!(N=B.n()).done;){var D,O=o(N.value.GraphicalSlurs.sort(mo.Compare));try{for(O.s();!(D=O.n()).done;){var F=D.value;F.slur.isCrossed()||F.calculateCurve(this.rules)}}catch(V){O.e(V)}finally{O.f()}}}catch(V){B.e(V)}finally{B.f()}}}catch(V){I.e(V)}finally{I.f()}}}]),n}(ra),xo=function(){function e(t){k(this,e),this.musicSheet=t}return E(e,[{key:"reInit",value:function(){this.init()}},{key:"init",value:function(){this.parts=this.musicSheet.Repetitions.slice(),this.sheetStart=this.musicSheet.SelectionStart=new f(0,1),this.sheetEnd=this.musicSheet.SelectionEnd=this.musicSheet.SheetEndTimestamp,this.calcMapping()}},{key:"getCurrentRepetitionTimestampTransform",value:function(e){for(var t=void 0,i=this.timestamps.length-1;i>=0;i--)if(t=this.timestamps[i],e.gte(t.from))return t;return this.timestamps[0]}},{key:"absoluteEnrolledToSheetTimestamp",value:function(e){if(0===this.timestamps.length)return e;var t=this.getCurrentRepetitionTimestampTransform(e);return f.plus(e,f.minus(t.to,t.from))}},{key:"Parts",get:function(){return this.parts}},{key:"MusicSheet",get:function(){return this.musicSheet}},{key:"getIterator",value:function(e){return e?new ht(this.musicSheet,e,void 0):new ht(this.musicSheet,this.musicSheet.SelectionStart,this.musicSheet.SelectionEnd)}},{key:"setSelectionStart",value:function(e){this.musicSheet.SelectionStart=e,this.musicSheet.SelectionEnd=void 0}},{key:"setSelectionRange",value:function(e,t){this.musicSheet.SelectionStart=null!=e?e:this.sheetStart,this.musicSheet.SelectionEnd=null!=t?t:this.sheetEnd}},{key:"calcMapping",value:function(){this.timestamps=[];var e=this.getIterator(),t=e.CurrentRepetition,i=new ko(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){var n=e.JumpResponsibleRepetition;i.nextBackJump=e.CurrentEnrolledTimestamp,i.curRepetition=n,i.curRepetitionIteration=e.CurrentJumpResponsibleRepetitionIterationBeforeJump;for(var r=this.timestamps.length-2;r>=0&&(!n.AbsoluteTimestamp.gt(this.timestamps[r].to)&&!this.timestamps[r].curRepetition);r--)this.timestamps[r].nextBackJump=i.nextBackJump,this.timestamps[r].curRepetition=n,this.timestamps[r].curRepetitionIteration=i.curRepetitionIteration}i=new ko(e.CurrentEnrolledTimestamp.clone(),e.CurrentSourceTimestamp.clone(),void 0,0),this.timestamps.push(i)}e.moveToNext()}}}]),e}(),ko=E((function e(t,i,n,r){k(this,e),this.from=t,this.to=i,this.curRepetition=n,this.curRepetitionIteration=r,this.nextBackJump=void 0,this.nextForwardJump=void 0})),_o=function(){function e(t){k(this,e),this.enrolledTimestamps=[],this.visible=!0,this.musicSheet=t}return E(e,[{key:"Visible",get:function(){return this.visible},set:function(e){this.visible=e}},{key:"getFirstSourceMeasure",value:function(){return this.musicSheet.SourceMeasures[this.startIndex]}},{key:"getLastSourceMeasure",value:function(){return this.musicSheet.SourceMeasures[this.endIndex]}}]),e}(),Eo=function(e){c(i,e);var t=d(i);function i(e,n,r){var s;return k(this,i),(s=t.call(this,e)).musicSheet=e,s.startIndex=n,s.endIndex=r,s}return E(i,[{key:"MeasuresCount",get:function(){return this.endIndex-this.startIndex+1}},{key:"StartIndex",get:function(){return this.startIndex}},{key:"EndIndex",get:function(){return this.endIndex}},{key:"ParentRepetition",get:function(){return this.parentRepetition},set:function(e){this.parentRepetition=e}},{key:"AbsoluteTimestamp",get:function(){return f.createFromFraction(this.musicSheet.SourceMeasures[this.startIndex].AbsoluteTimestamp)}},{key:"setStartIndex",value:function(e){this.startIndex=e}},{key:"setEndIndex",value:function(e){this.endIndex=e}}]),i}(_o),wo=function(e){c(i,e);var t=d(i);function i(e){var n,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return k(this,i),(n=t.call(this,e)).backwardJumpInstructions=[],n.endingParts=[],n.endingIndexDict={},n.userNumberOfRepetitions=0,n.visibles=[],n.fromWords=!1,n.repetitonIterationOrder=[],n.numberOfEndings=1,n.musicSheet2=e,n.virtualOverallRepetition=r,n}return E(i,[{key:"BackwardJumpInstructions",get:function(){return this.backwardJumpInstructions}},{key:"EndingIndexDict",get:function(){return this.endingIndexDict}},{key:"EndingParts",get:function(){return this.endingParts}},{key:"Visibles",get:function(){return this.visibles},set:function(e){this.visibles=e}},{key:"DefaultNumberOfRepetitions",get:function(){var e=2;return this.virtualOverallRepetition&&(e=1),Math.max(e,Object.keys(this.endingIndexDict).length,this.checkRepetitionForMultipleLyricVerses())}},{key:"UserNumberOfRepetitions",get:function(){return this.userNumberOfRepetitions},set:function(e){this.userNumberOfRepetitions=e,this.repetitonIterationOrder=[];for(var t=this.userNumberOfRepetitions-this.NumberOfEndings,i=1;i<=this.userNumberOfRepetitions;i++)i<=t?this.repetitonIterationOrder.push(1):this.repetitonIterationOrder.push(i-t)}},{key:"getForwardJumpTargetForIteration",value:function(e){var t=this.repetitonIterationOrder[e-1];return this.endingIndexDict[t]?this.endingIndexDict[t].part.StartIndex:-1}},{key:"getBackwardJumpTarget",value:function(){return this.startMarker.measureIndex}},{key:"setEndingsStartIndex",value:function(e,t){var i=new Mo(new Eo(this.musicSheet2,t,t));this.endingParts.push(i);var n,r=o(e);try{for(r.s();!(n=r.n()).done;){var s=n.value;try{this.endingIndexDict[s]=i,i.endingIndices.push(s),this.numberOfEndings0&&void 0!==arguments[0]?arguments[0]:new f,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;k(this,e),this.rhythm=t,this.beatsPerMinute=i,this.beatLengthInMilliseconds=6e4/i,this.beatRealValue=1/4}return E(e,[{key:"BeatsPerMinute",get:function(){return this.beatsPerMinute},set:function(e){this.beatsPerMinute=e,this.beatLengthInMilliseconds=6e4/this.beatsPerMinute}},{key:"Rhythm",get:function(){return this.rhythm},set:function(e){this.rhythm=e}},{key:"BeatRealValue",get:function(){return this.beatRealValue}},{key:"BeatLengthInMilliseconds",get:function(){return this.beatLengthInMilliseconds}},{key:"getDurationInMilliseconds",value:function(e){return("number"==typeof e?e:e.RealValue)*this.BeatLengthInMilliseconds/this.beatRealValue}},{key:"getDurationAsNoteDuration",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1024,i=e/this.BeatLengthInMilliseconds,n=Math.floor(i),r=new f(n,4),s=i-n;return 0===(n=Math.round(s/(1/t)/4))&&e>0&&(n=1),r.Add(new f(n,t)),r}}],[{key:"createFrom",value:function(t){return new e(t.Rhythm,t.BeatsPerMinute)}}]),e}(),Po=function(){function e(){k(this,e),this.idString="random idString, not initialized",this.sourceMeasures=[],this.repetitions=[],this.dynListStaves=[],this.timestampSortedDynamicExpressionsList=[],this.timestampSortedTempoExpressionsList=[],this.instrumentalGroups=[],this.instruments=[],this.musicPartManager=void 0,this.musicSheetErrors=new Cr,this.staves=[],this.playbackDataDict=new Xe,this.transpose=0,this.defaultStartTempoInBpm=0,this.drawErroneousMeasures=!1,this.hasBeenOpenedForTheFirstTime=!1,this.currentEnrolledPosition=new f(0,1),this.soundTempos=new Map,this.playbackSettings=new To,this.playbackSettings.rhythm=new f(4,4,0,!1),this.userStartTempoInBPM=100,this.pageWidth=120,this.MusicPartManager=new xo(this),this.hasBPMInfo=!1}return E(e,[{key:"SoundTempos",get:function(){return this.soundTempos},set:function(e){this.soundTempos=e}},{key:"CurrentKeyInstruction",get:function(){return this.currentKeyInstruction},set:function(e){this.currentKeyInstruction=e}},{key:"SourceMeasures",get:function(){return this.sourceMeasures},set:function(e){this.sourceMeasures=e}},{key:"Repetitions",get:function(){return this.repetitions},set:function(e){this.repetitions=e}},{key:"DynListStaves",get:function(){return this.dynListStaves}},{key:"TimestampSortedTempoExpressionsList",get:function(){return this.timestampSortedTempoExpressionsList}},{key:"TimestampSortedDynamicExpressionsList",get:function(){return this.timestampSortedDynamicExpressionsList}},{key:"InstrumentalGroups",get:function(){return this.instrumentalGroups}},{key:"Parts",get:function(){return this.instruments}},{key:"Instruments",get:function(){return this.instruments}},{key:"SheetPlaybackSetting",get:function(){return this.playbackSettings},set:function(e){this.playbackSettings=e}},{key:"DrawErroneousMeasures",get:function(){return this.drawErroneousMeasures},set:function(e){this.drawErroneousMeasures=e}},{key:"HasBeenOpenedForTheFirstTime",get:function(){return this.hasBeenOpenedForTheFirstTime},set:function(e){this.hasBeenOpenedForTheFirstTime=e}},{key:"InitializeStartTempoInBPM",value:function(e){this.playbackSettings.BeatsPerMinute=e,this.userStartTempoInBPM=e}},{key:"DefaultStartTempoInBpm",get:function(){return this.defaultStartTempoInBpm},set:function(e){this.defaultStartTempoInBpm=e,this.InitializeStartTempoInBPM(e)}},{key:"Path",get:function(){return this.path},set:function(e){this.path=e}},{key:"Staves",get:function(){return this.staves}},{key:"TitleString",get:function(){return this.title?this.title.text:""},set:function(e){this.Title=new hs(e)}},{key:"SubtitleString",get:function(){return this.subtitle?this.subtitle.text:""},set:function(e){this.Subtitle=new hs(e)}},{key:"ComposerString",get:function(){return this.composer?this.composer.text:""},set:function(e){this.Composer=new hs(e)}},{key:"LyricistString",get:function(){return this.lyricist?this.lyricist.text:""},set:function(e){this.Lyricist=new hs(e)}},{key:"Title",get:function(){return this.title},set:function(e){this.title=e}},{key:"Subtitle",get:function(){return this.subtitle},set:function(e){this.subtitle=e}},{key:"Composer",get:function(){return this.composer},set:function(e){this.composer=e}},{key:"Lyricist",get:function(){return this.lyricist},set:function(e){this.lyricist=e}},{key:"Rules",get:function(){return this.rules||(L.debug("warning: sheet.Rules was undefined. Creating new EngravingRules."),this.rules=new ca),this.rules},set:function(e){this.rules=e}},{key:"SheetErrors",get:function(){return this.musicSheetErrors}},{key:"PlaybackDataDict",get:function(){return this.playbackDataDict}},{key:"SelectionStart",get:function(){return this.selectionStart},set:function(e){this.selectionStart=e.clone(),this.currentEnrolledPosition=e.clone()}},{key:"SelectionEnd",get:function(){return this.selectionEnd},set:function(e){this.selectionEnd=e}},{key:"HasBPMInfo",get:function(){return this.hasBPMInfo},set:function(e){this.hasBPMInfo=e}},{key:"addMeasure",value:function(e){this.sourceMeasures.push(e),e.measureListIndex=this.sourceMeasures.length-1}},{key:"checkForInstrumentWithNoVoice",value:function(){for(var e=0,t=this.instruments.length;e0){var e=this.TimestampSortedTempoExpressionsList[0];if(e.InstantaneousTempo)return e.InstantaneousTempo.TempoInBpm;if(e.ContinuousTempo)return e.ContinuousTempo.StartTempo}return this.userStartTempoInBPM}},{key:"Errors",get:function(){return this.musicSheetErrors.measureErrors}},{key:"FirstMeasureNumber",get:function(){try{return this.getFirstSourceMeasure().MeasureNumber}catch(e){return L.info("MusicSheet.FirstMeasureNumber: ",e),0}}},{key:"LastMeasureNumber",get:function(){try{return this.getLastSourceMeasure().MeasureNumber}catch(e){return L.info("MusicSheet.LastMeasureNumber: ",e),0}}},{key:"CurrentEnrolledPosition",get:function(){return this.currentEnrolledPosition.clone()},set:function(e){this.currentEnrolledPosition=e.clone()}},{key:"Transpose",get:function(){return this.transpose},set:function(e){this.transpose=e}},{key:"FullNameString",get:function(){return this.ComposerString+" "+this.TitleString}},{key:"IdString",get:function(){return this.idString},set:function(e){this.idString=e}},{key:"getEnrolledSelectionStartTimeStampWorkaround",value:function(){var e=this.MusicPartManager.getIterator(this.SelectionStart);return f.createFromFraction(e.CurrentEnrolledTimestamp)}},{key:"SheetEndTimestamp",get:function(){var e=this.getLastSourceMeasure();return f.plus(e.AbsoluteTimestamp,e.Duration)}},{key:"getSourceMeasureFromTimeStamp",value:function(e){for(var t=0,i=this.sourceMeasures.length;t0&&n.Voices[0].Visible&&e.push(n)}return e}}],[{key:"getIndexFromStaff",value:function(e){return e.idInMusicSheet}}]),e}();Po.defaultTitle="[no title given]";var Lo=function(){function e(){k(this,e),this.syllables=[]}return E(e,[{key:"Syllables",get:function(){return this.syllables}},{key:"containsVoiceEntry",value:function(e){for(var t=0,i=this.Syllables.length;t4&&void 0!==arguments[4]?arguments[4]:-1;k(this,e),this.text=t,this.word=n,this.parent=r,this.verseNumber=i,s>=0&&(this.syllableIndex=s)}return E(e,[{key:"Text",get:function(){return this.text},set:function(e){this.text=e}},{key:"Word",get:function(){return this.word}},{key:"Parent",get:function(){return this.parent},set:function(e){this.parent=e}},{key:"VerseNumber",get:function(){return this.verseNumber}},{key:"SyllableIndex",get:function(){return this.syllableIndex}}]),e}(),Ao=function(){function e(t){k(this,e),this.openLyricWords={},this.musicSheet=t}return E(e,[{key:"addLyricEntry",value:function(e,t){if(e){for(var i=e,n=0,r=i.length;n0)for(var y=p;y1&&(S=parseInt(k[1],10))}catch(C){var _=Fr.translateText("ReaderErrorMessages/LyricVerseNumberError","Invalid lyric verse number");this.musicSheet.SheetErrors.pushMeasureError(_);continue}}var E=void 0;if("single"===a||"end"===a){if(this.openLyricWords[S]){this.currentLyricWord=this.openLyricWords[S];var w=this.currentLyricWord.Syllables.length;E=new Co(h,S,this.currentLyricWord,t,w),this.currentLyricWord.Syllables.push(E),delete this.openLyricWords[S],this.currentLyricWord=void 0}else E=new Co(h,S,void 0,t);E.extend=void 0!==s.element("extend")}else if("begin"===a)this.openLyricWords[S]&&(delete this.openLyricWords[S],this.currentLyricWord=void 0),this.currentLyricWord=new Lo,this.openLyricWords[S]=this.currentLyricWord,E=new Co(h,S,this.currentLyricWord,t,0),this.currentLyricWord.Syllables.push(E);else if("middle"===a)if(this.openLyricWords[S]){this.currentLyricWord=this.openLyricWords[S];var M=this.currentLyricWord.Syllables.length;E=new Co(h,S,this.currentLyricWord,t,M),this.currentLyricWord.Syllables.push(E)}else E=new Co(h,S,void 0,t);if(E){var T,P;if(!t.LyricsEntries[S])t.LyricsEntries.setValue(S,E),null!==(T=t.ParentSourceStaffEntry)&&void 0!==T&&null!==(P=T.VerticalContainerParent)&&void 0!==P&&P.ParentMeasure&&(t.ParentSourceStaffEntry.VerticalContainerParent.ParentMeasure.hasLyrics=!0);t.ParentVoice.Parent.LyricVersesNumbers[S]||t.ParentVoice.Parent.LyricVersesNumbers.push(S)}}}}catch(C){var L=Fr.translateText("ReaderErrorMessages/LyricError","Error while reading lyric entry.");this.musicSheet.SheetErrors.pushMeasureError(L);continue}}t.ParentVoice.Parent.LyricVersesNumbers=t.ParentVoice.Parent.LyricVersesNumbers.filter((function(e,t,i){return i.indexOf(e)===t}))}}}]),e}(),Ro=function(){function e(t,i){k(this,e),this.articulationEnum=t,this.placement=i}return E(e,[{key:"Equals",value:function(e){return e.articulationEnum===this.articulationEnum&&e.placement===this.placement}}]),e}(),Io=function(){function e(t){k(this,e),this.rules=t}return E(e,[{key:"getAccEnumFromString",value:function(e){switch(e){case"sharp":return Ct.SHARP;case"flat":return Ct.FLAT;case"natural":return Ct.NATURAL;case"double-sharp":case"sharp-sharp":return Ct.DOUBLESHARP;case"double-flat":case"flat-flat":return Ct.DOUBLEFLAT;case"triple-sharp":return Ct.TRIPLESHARP;case"triple-flat":return Ct.TRIPLEFLAT;case"quarter-sharp":return Ct.QUARTERTONESHARP;case"quarter-flat":return Ct.QUARTERTONEFLAT;case"three-quarters-sharp":return Ct.THREEQUARTERSSHARP;case"three-quarters-flat":return Ct.THREEQUARTERSFLAT;case"slash-quarter-sharp":return Ct.SLASHQUARTERSHARP;case"slash-sharp":return Ct.SLASHSHARP;case"double-slash-flat":return Ct.DOUBLESLASHFLAT;case"sori":return Ct.SORI;case"koron":return Ct.KORON;default:return Ct.NONE}}},{key:"addArticulationExpression",value:function(e,t){if(void 0!==e&&e.elements().length>0)for(var i=e.elements(),n=0,r=i.length;n0&&t.Articulations[0].articulationEnum!==as.staccato&&t.Articulations.splice(0,0,c),"strongaccent"===a){var f,d=null==s||null===(f=s.attribute("type"))||void 0===f?void 0:f.value;"up"===d?c.articulationEnum=as.marcatoup:"down"===d&&(c.articulationEnum=as.marcatodown)}if("detachedlegato"===a){var p,v=new Ro(as.staccato,l),m=new Ro(as.tenuto,l);(p=t.Articulations).push.apply(p,[v,m])}if(!t.hasArticulation(c))switch(t.Articulations.push(c),c.articulationEnum){case as.staccato:case as.staccatissimo:t.DurationModifier=c;break;case as.accent:case as.strongaccent:t.VolumeModifier=c}}}catch(y){return void L.debug("addArticulationExpression","Invalid note articulation.",y)}}}},{key:"addFermata",value:function(e,t){var i,n=as.fermata;e.attributes().length>0&&e.attribute("type")&&"inverted"===e.attribute("type").value&&(n=as.invertedfermata);var r=g.Above;"below"===(null===(i=e.attribute("placement"))||void 0===i?void 0:i.value)&&(r=g.Below),t.Articulations.push(new Ro(n,r))}},{key:"addTechnicalArticulations",value:function(e,t,i){var n={bend:as.bend,"down-bow":as.downbow,"open-string":as.naturalharmonic,"snap-pizzicato":as.snappizzicato,stopped:as.lefthandpizzicato,"up-bow":as.upbow};for(var r in n)if(n.hasOwnProperty(r)){var s=n[r],a=e.element(r);if(a){var o,u,l=void 0;"above"===(null===(o=a.attribute("placement"))||void 0===o?void 0:o.value)&&(l=g.Above),"below"===(null===(u=a.attribute("placement"))||void 0===u?void 0:u.value)&&(l=g.Below);var h=new Ro(s,l);t.hasArticulation(h)||t.Articulations.push(h)}}var c=e.element("fingering");if(c){var f=this.createTechnicalInstruction(c,i);f.type=ts.Fingering,i.Fingering=f,t.TechnicalInstructions.push(f)}var d=e.element("string");if(d){var p=this.createTechnicalInstruction(d,i);p.type=ts.String,i.StringInstruction=p,t.TechnicalInstructions.push(p)}}},{key:"createTechnicalInstruction",value:function(e,t){var i=new is;i.sourceNote=t,i.value=e.value;var n=e.attribute("placement");return this.rules.FingeringPositionFromXML&&(i.placement=this.getPlacement(n)),i}},{key:"getPlacement",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:g.NotYetDefined;if(t!==g.NotYetDefined)return t;if(!e)return g.NotYetDefined;switch(e.value){case"above":return g.Above;case"below":return g.Below;case"left":return g.Left;case"right":return g.Right;default:return g.NotYetDefined}}},{key:"addOrnament",value:function(e,t){if(e){var i=void 0,n={"delayed-inverted-turn":Ur.DelayedInvertedTurn,"delayed-turn":Ur.DelayedTurn,"inverted-mordent":Ur.InvertedMordent,"inverted-turn":Ur.InvertedTurn,mordent:Ur.Mordent,"trill-mark":Ur.Trill,turn:Ur.Turn};for(var r in n)if(n.hasOwnProperty(r)){var s=e.element(r);if(s){i=new Wr(n[r]);var a=s.attribute("placement");if(a)"below"===a.value&&(i.placement=g.Below)}}if(i){var o=e.elements("accidental-mark");if(o)for(var u=g.Below,l=Ct.NONE,h=o,c=0,f=h.length;c4&&void 0!==arguments[4]?arguments[4]:void 0;k(this,e),this.openBeams=[],this.beamNumberOffset=0,this.currentOctaveShift=0,this.tupletDict={},this.openTupletNumber=0,this.currMeasureVoiceEntries=[],this.graceVoiceEntriesTempList=[],this.staff=i,this.instrument=i.ParentInstrument,this.musicSheet=this.instrument.GetMusicSheet,this.slurReader=r,this.pluginManager=t,this.voice=s?new Br(this.instrument,n,s):new Nr(this.instrument,n),this.instrument.Voices.push(this.voice),this.staff.Voices.push(this.voice),this.lyricsReader=new Ao(this.musicSheet),this.articulationReader=new Io(this.musicSheet.Rules)}return E(e,[{key:"openTieDict",get:function(){return this.staff.openTieDict}},{key:"GetVoice",get:function(){return this.voice}},{key:"OctaveShift",get:function(){return this.currentOctaveShift},set:function(e){this.currentOctaveShift=e}},{key:"createVoiceEntry",value:function(e,t,i,n){var r=arguments.length>4&&void 0!==arguments[4]&&arguments[4],s=arguments.length>5&&void 0!==arguments[5]&&arguments[5],a=arguments.length>6&&void 0!==arguments[6]&&arguments[6];this.activeKey=i,this.activeRhythm=n,this.currentVoiceEntry=new ss(f.createFromFraction(e),this.voice,t,!0,r,s,a),r?this.graceVoiceEntriesTempList.push(this.currentVoiceEntry):(this.currentNormalVoiceEntry=this.currentVoiceEntry,this.currMeasureVoiceEntries.push(this.currentNormalVoiceEntry),this.graceVoiceEntriesTempList.length>0&&(this.currentVoiceEntry.GraceVoiceEntriesBefore=this.graceVoiceEntriesTempList,this.graceVoiceEntriesTempList=[]))}},{key:"finalizeReadingMeasure",value:function(){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()}},{key:"read",value:function(e,t,i,n,r,s,a,u,l,h,c,f,d,p,v,m,g,y,b,S,x,k){this.currentStaffEntry=a,this.currentMeasure=u;try{this.currentNote=s?this.addRestNote(e.element("rest"),t,n,r,d,p,b):this.addSingleNote(e,t,n,i,r,c,f,d,p,v,m,g,y,b,x,k),this.currentNote.DotsXml=S;var _=e.elements("lyric");void 0!==this.lyricsReader&&_&&(this.lyricsReader.addLyricEntry(_,this.currentVoiceEntry),this.voice.Parent.HasLyrics=!0);var E=!1,w=e.element("notations");if(w){this.articulationReader&&this.readArticulations(w,this.currentVoiceEntry,this.currentNote);var M=w.elements("slur");void 0!==this.slurReader&&M.length>0&&!this.currentNote.ParentVoiceEntry.IsGrace&&this.slurReader.addSlur(M,this.currentNote);var T=w.elements("tuplet");T.length>0&&(this.openTupletNumber=this.addTuplet(e,T),E=!0);var P=w.element("arpeggiate");if(void 0!==P){var C;if(this.currentVoiceEntry.Arpeggio)C=this.currentVoiceEntry.Arpeggio;else{var A,R=!1,I=o(this.currentStaffEntry.VoiceEntries);try{for(I.s();!(A=I.n()).done;){var N=A.value;if(N.Arpeggio){R=!0,C=N.Arpeggio;break}}}catch(z){I.e(z)}finally{I.f()}if(!R){var B=Rr.ARPEGGIO_DIRECTIONLESS,D=P.attribute("direction");if(D)switch(D.value){case"up":B=Rr.ROLL_UP;break;case"down":B=Rr.ROLL_DOWN;break;default:B=Rr.ARPEGGIO_DIRECTIONLESS}C=new Ar(this.currentVoiceEntry,B),this.currentVoiceEntry.Arpeggio=C}}C.addNote(this.currentNote)}var O=w.elements("tied");O.length>0&&this.addTie(O,l,h,Tt.SIMPLE);var F=w.elements("slide");F.length>0&&this.addTie(F,l,h,Tt.SLIDE);var V=w.element("technical");if(V){var G=V.elements("hammer-on");G.length>0&&this.addTie(G,l,h,Tt.HAMMERON);var W=V.elements("pull-off");W.length>0&&this.addTie(W,l,h,Tt.PULLOFF)}}void 0===e.element("time-modification")||E||this.handleTimeModificationNode(e)}catch(z){L.warn(z);var U=Fr.translateText("ReaderErrorMessages/NoteError","Ignored erroneous Note.");this.musicSheet.SheetErrors.pushMeasureError(U),this.musicSheet.SheetErrors.pushMeasureError(z)}return this.currentNote}},{key:"checkForStaffEntryLink",value:function(e,t,i,n){var r=new $r(this.currentVoiceEntry);r.LinkStaffEntries.push(i),i.Link=r;var s=this.currentVoiceEntry.Timestamp.clone(),a=n.getVerticalContainerByTimestamp(s);return(i=a.StaffEntries[e])||(i=new Hr(a,t),a.StaffEntries[e]=i),i.VoiceEntries.push(this.currentVoiceEntry),r.LinkStaffEntries.push(i),i.Link=r,i}},{key:"checkForOpenBeam",value:function(){this.openBeams.length>0&&this.currentNote&&this.handleOpenBeam()}},{key:"checkOpenTies",value:function(){var e=this.openTieDict;for(var t in e)if(e.hasOwnProperty(t)){var i=e[t];f.plus(i.StartNote.ParentStaffEntry.Timestamp,i.Duration).lt(i.StartNote.SourceMeasure.Duration)&&delete e[t]}}},{key:"hasVoiceEntry",value:function(){return void 0!==this.currentVoiceEntry}},{key:"readArticulations",value:function(e,t,i){var n=e.element("articulations");n&&this.articulationReader.addArticulationExpression(n,t);var r=e.element("fermata");r&&this.articulationReader.addFermata(r,t);var s=e.element("technical");s&&this.articulationReader.addTechnicalArticulations(s,t,i);var a=e.element("ornaments");a&&this.articulationReader.addOrnament(a,t)}},{key:"addSingleNote",value:function(e,i,n,r,s,a,o,u,l,h,c,d,p,v,m,g){for(var y,b=0,S=Ct.NONE,x=Lt.C,k=Lt.C,_=0,E=0,w=void 0,T=void 0,P=void 0,C=e.elements(),A=0,R=C.length;A0&&this.openBeams.last().ExtendedNoteList.push(p),p}},{key:"addNoteInfo",value:function(e,t,i,n,r,s,a,o,u){e.NoteTypeXml=t,e.PrintObject=i,e.IsCueNote=n,e.NormalNotes=r,e.displayStepUnpitched=s,e.displayOctaveUnpitched=a,e.NoteheadColorXml=o,e.NoteheadColor=o}},{key:"createBeam",value:function(e,t){try{var i=e.element("beam"),n=void 0;if(void 0!==i&&i.hasAttributes&&(n=i.attribute("number")),n){var r,s=parseInt(n.value,10),a=e.elements("beam"),o=a[0].value;if(a)if("begin"===o)s===(null===(r=this.openBeams.last())||void 0===r?void 0:r.BeamNumber)?(this.beamNumberOffset++,s+=this.beamNumberOffset):this.openBeams.last()&&this.handleOpenBeam(),this.openBeams.push(new Ir(s,this.beamNumberOffset));else s+=this.beamNumberOffset;var u=!1;if(!(s>0&&s<=this.openBeams.length&&this.openBeams[s-1]))return void L.debug("[OSMD] invalid beamnumber");for(var l=0,h=this.openBeams[s-1].Notes.length;l1){var n=e.element("time-modification");n&&(n=n.element("actual-notes"));for(var r=t,s=0,a=r.length;s1&&this.openTupletNumber--),this.tupletDict[c]=p;var m=[];m.push(this.currentNote),p.Notes.push(m),p.Fractions.push(this.getTupletNoteDurationFromType(e)),this.currentNote.NoteTuplet=p,this.openTupletNumber=c}else if("stop"===h.value){var y=1;u.attribute("number")&&(y=parseInt(u.attribute("number").value,10));var b=this.tupletDict[y];if(b){var S=u.attribute("placement");S&&("below"===S.value?b.tupletLabelNumberPlacement=g.Below:b.tupletLabelNumberPlacement=g.Above,b.PlacementFromXml=!0);var x=[];if(x.push(this.currentNote),b.Notes.push(x),!b.PlacementFromXml){var k,_=!1,E=o(b.Notes);try{for(E.s();!(k=E.n()).done;){var w,T=o(k.value);try{for(T.s();!(w=T.n()).done;){var P=w.value;if(!P.isRest()){P.StemDirectionXml===os.Down?b.tupletLabelNumberPlacement=g.Below:b.tupletLabelNumberPlacement=g.Above,_=!0;break}}}catch(q){T.e(q)}finally{T.f()}if(_)break}}catch(q){E.e(q)}finally{E.f()}}b.Fractions.push(this.getTupletNoteDurationFromType(e)),this.currentNote.NoteTuplet=b,delete this.tupletDict[y],0===Object.keys(this.tupletDict).length?this.openTupletNumber=0:Object.keys(this.tupletDict).length>1&&this.openTupletNumber--}}}}}else if(t[0]){var L=t[0];if(L.hasAttributes){var C=L.attribute("type").value,A=1;L.attribute("number")&&(A=parseInt(L.attribute("number").value,10));var R=isNaN(A),I=L.attribute("bracket");if(I&&"yes"===I.value&&(i=!0),"start"===C){var N=0,B=e.element("time-modification");if(B&&(B=B.element("actual-notes")),B&&(N=parseInt(B.value,10),isNaN(N))){var D=Fr.translateText("ReaderErrorMessages/TupletNoteDurationError","Invalid tuplet note duration.");throw this.musicSheet.SheetErrors.pushMeasureError(D),new M(D)}R&&(this.openTupletNumber++,A=this.openTupletNumber);var O=this.tupletDict[A];O||((O=this.tupletDict[A]=new es(N,i)).tupletLabelNumberPlacement=g.Above);var F=L.attribute("placement");F&&("below"===F.value?O.tupletLabelNumberPlacement=g.Below:O.tupletLabelNumberPlacement=g.Above,O.PlacementFromXml=!0);var V=[];V.push(this.currentNote),O.Notes.push(V),O.Fractions.push(this.getTupletNoteDurationFromType(e)),this.currentNote.NoteTuplet=O,this.openTupletNumber=A}else if("stop"===C){R&&(A=this.openTupletNumber);var G=this.tupletDict[this.openTupletNumber];if(G){var W=L.attribute("placement");W&&("below"===W.value?G.tupletLabelNumberPlacement=g.Below:G.tupletLabelNumberPlacement=g.Above,G.PlacementFromXml=!0);var U=[];if(U.push(this.currentNote),G.Notes.push(U),!G.PlacementFromXml){var z,H=!1,X=o(G.Notes);try{for(X.s();!(z=X.n()).done;){var Y,j=o(z.value);try{for(j.s();!(Y=j.n()).done;){var K=Y.value;if(!K.isRest()){K.StemDirectionXml===os.Down?G.tupletLabelNumberPlacement=g.Below:G.tupletLabelNumberPlacement=g.Above,H=!0;break}}}catch(q){j.e(q)}finally{j.f()}if(H)break}}catch(q){X.e(q)}finally{X.f()}}G.Fractions.push(this.getTupletNoteDurationFromType(e)),this.currentNote.NoteTuplet=G,0===Object.keys(this.tupletDict).length?this.openTupletNumber=0:Object.keys(this.tupletDict).length>1&&this.openTupletNumber--,delete this.tupletDict[A]}}}}return this.openTupletNumber}},{key:"handleTimeModificationNode",value:function(e){if(this.tupletDict[this.openTupletNumber])try{var t,i=this.tupletDict[this.openTupletNumber],n=Ht.last(i.Notes);n[0].ParentVoiceEntry.Timestamp.Equals(this.currentVoiceEntry.Timestamp)?t=n:(t=[],i.Notes.push(t),i.Fractions.push(this.getTupletNoteDurationFromType(e))),t.push(this.currentNote),this.currentNote.NoteTuplet=i}catch(o){var r=Fr.translateText("ReaderErrorMessages/TupletNumberError","Invalid tuplet number.");throw this.musicSheet.SheetErrors.pushMeasureError(r),o}else if(this.currentVoiceEntry.Notes.length>0){var s=this.currentVoiceEntry.Notes[0];if(s.NoteTuplet){var a=s.NoteTuplet;Ht.last(a.Notes).push(this.currentNote),this.currentNote.NoteTuplet=a}}}},{key:"addTie",value:function(e,t,i,n){if(e)if(1===e.length){var r=e[0];if(void 0!==r&&r.attributes()){var s=this.getTieDirection(r),a=r.attribute("type").value;try{if("start"===a){var u=this.findCurrentNoteInTieDict(this.currentNote);u<0&&delete this.openTieDict[u];var l=this.getNextAvailableNumberForTie(),h=new Qr(this.currentNote,n);this.openTieDict[l]=h,h.TieNumber=l,h.TieDirection=s}else if("stop"===a){var c=this.findCurrentNoteInTieDict(this.currentNote),f=this.openTieDict[c];f&&(f.AddNote(this.currentNote),delete this.openTieDict[c])}}catch(S){var d=Fr.translateText("ReaderErrorMessages/TieError","Error while reading tie.");this.musicSheet.SheetErrors.pushMeasureError(d)}}}else if(2===e.length){var p=this.findCurrentNoteInTieDict(this.currentNote);if(p>=0){var v=this.openTieDict[p];v.AddNote(this.currentNote);var m,g=o(e);try{for(g.s();!(m=g.n()).done;){var y=m.value;if("start"===y.attribute("type").value){var b=this.getTieDirection(y);v.NoteIndexToTieDirection[v.Notes.length-1]=b}}}catch(S){g.e(S)}finally{g.f()}}}}},{key:"getTieDirection",value:function(e){var t=g.NotYetDefined,i=e.attribute("placement");i&&("above"===i.value?t=g.Above:"below"===i.value&&(t=g.Below));var n=e.attribute("orientation");return n&&("over"===n.value?t=g.Above:"under"===n.value&&(t=g.Below)),t}},{key:"getNextAvailableNumberForTie",value:function(){var e=Object.keys(this.openTieDict);if(0===e.length)return 1;e.sort((function(e,t){return+e-+t}));for(var t=0;t0&&void 0!==arguments[0]&&arguments[0],i=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];k(this,e),this.ChangeEnd=!1,this.ChangeBegin=!1,this.line=t,this.sign=i}return E(e,[{key:"IsLine",get:function(){return this.line}},{key:"IsSign",get:function(){return this.sign}}]),e}(),Fo=function(e){c(i,e);var t=d(i);function i(e){return k(this,i),t.call(this,e)}return E(i)}(m),Vo=function(){function e(t,i,n){k(this,e),this.openContinuousDynamicExpressions=[],this.musicSheet=t,this.staffNumber=n,this.globalStaffIndex=t.getGlobalStaffIndexOfFirstStaff(i)+(n-1),this.initialize()}return E(e,[{key:"readExpressionParameters",value:function(e,t,i,n,r,s,a){this.initialize();var o=e.element("offset");if(void 0!==o&&!a)try{this.offsetDivisions=parseInt(o.value,10)}catch(w){var u="ReaderErrorMessages/ExpressionOffsetError, Invalid expression offset -> set to default.";L.debug("ExpressionReader.readExpressionParameters",u,w),this.musicSheet.SheetErrors.pushMeasureError(u),this.offsetDivisions=0}this.directionTimestamp=f.createFromFraction(n);var l=new f(Math.abs(this.offsetDivisions),4*i);this.offsetDivisions>0?n.RealValue>0?(l=f.multiply(f.minus(n,r),l),this.directionTimestamp=f.plus(l,n)):this.directionTimestamp=f.createFromFraction(l):this.offsetDivisions<0&&(n.RealValue>0?(l=f.multiply(f.minus(n,r),l),this.directionTimestamp=f.minus(n,l)):this.directionTimestamp=f.createFromFraction(l));var h=e.attribute("placement");if(h)try{var c=h.value;"below"===c?this.placement=g.Below:"above"===c&&(this.placement=g.Above)}catch(w){var d=Fr.translateText("ReaderErrorMessages/ExpressionPlacementError","Invalid expression placement -> set to default.");L.debug("ExpressionReader.readExpressionParameters",d,w),this.musicSheet.SheetErrors.pushMeasureError(d),this.placement=g.Below}if(this.placement===g.NotYetDefined)try{var p=e.element("direction-type");if(p){var v=p.element("dynamics");if(v){var m=v.attribute("default-y");m&&this.readExpressionPlacement(m,"read dynamics y pos")}var y=p.element("wedge");if(y){var b=y.attribute("default-y");b&&this.readExpressionPlacement(b,"read wedge y pos")}var S=p.element("words");if(S){var x=S.attribute("default-y");x&&this.readExpressionPlacement(x,"read words y pos")}var k=p.element("rehearsal");if(k){var _=k.attribute("default-y");_&&this.readExpressionPlacement(_,"read rehearsal pos")}}}catch(w){var E=Fr.translateText("ReaderErrorMessages/ExpressionPlacementError","Invalid expression placement -> set to default.");L.debug("ExpressionReader.readExpressionParameters",E,w),this.musicSheet.SheetErrors.pushMeasureError(E),this.placement=g.Below}this.placement===g.NotYetDefined&&(t.Staves.length>1?this.placement=g.Below:t.HasLyrics?this.placement=g.Above:this.placement=g.Below)}},{key:"read",value:function(e,t,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:void 0,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,s=!1,a=!1,u=e.element("sound");if(u){var l=u.attribute("tempo"),h=u.attribute("dynamics");if(l){var c=l.value.match(/^(\d+)(\.\d+)?$/);(null==c?void 0:c.length)>0?this.soundTempo=Math.round(Number.parseFloat(l.value)):(L.info("invalid xml tempo: "+l.value),this.soundTempo=100),t.TempoInBPM=this.soundTempo,0===this.musicSheet.DefaultStartTempoInBpm&&(this.musicSheet.DefaultStartTempoInBpm=this.soundTempo),this.musicSheet.HasBPMInfo=!0,s=!0}if(h){var d=h.value.match(/\d+/);this.soundDynamic=void 0!==d?parseInt(d[0],10):100,a=!0}}var p=e.element("direction-type");if(p){var v=p.element("metronome");if(v){t.metronomeNoteIndex=r;var m=v.element("beat-unit"),g=void 0!==v.element("beat-unit-dot"),y=v.element("per-minute");if(void 0!==m&&y){var b=v.hasAttributes&&void 0!==v.attribute("default-x");b&&(this.directionTimestamp=f.createFromFraction(i));var S=parseFloat(y.value);this.createNewTempoExpressionIfNeeded(t);var x=new Gs(void 0,this.placement,this.staffNumber,S,this.currentMultiTempoExpression,!0);x.parentMeasure=t,this.soundTempo=S,t.TempoInBPM=this.soundTempo*(g?1.5:1),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,x.dotted=g,x.beatUnit=m.value,this.currentMultiTempoExpression.addExpression(x,""),this.currentMultiTempoExpression.CombinedExpressionsText="test"}}else if(v=p.element("dynamics")){var k=void 0!==e.element("notations");this.interpretInstantaneousDynamics(v,t,i,k)}else if(v=p.element("words")){var _,E=p.elements("words"),w="",M=o(E);try{for(M.s();!(_=M.n()).done;){var T=_.value;w+=T.value}}catch(C){M.e(C)}finally{M.f()}if(v.value=w,s||ys(v.value)||bs(v.value)){this.createNewTempoExpressionIfNeeded(t),this.currentMultiTempoExpression.CombinedExpressionsText=v.value,(ys(v.value)||bs(v.value))&&(v.value=void 0);var P=new Gs(v.value,this.placement,this.staffNumber,this.soundTempo,this.currentMultiTempoExpression);this.currentMultiTempoExpression.addExpression(P,"")}else a||this.interpretWords(v,t,i)}else(v=p.element("wedge"))?this.interpretWedge(v,t,n,t.MeasureNumber):(v=p.element("rehearsal"))&&this.interpretRehearsalMark(v,t,i,t.MeasureNumber)}}},{key:"closeOpenExpressions",value:function(e,t){var i,n=o(this.openContinuousDynamicExpressions);try{for(n.s();!(i=n.n()).done;){var r=i.value;this.createNewMultiExpressionIfNeeded(e,r.NumberXml,t),this.closeOpenContinuousDynamic(r,e,t)}}catch(s){n.e(s)}finally{n.f()}this.openContinuousTempoExpression&&this.closeOpenContinuousTempo(f.plus(e.AbsoluteTimestamp,t))}},{key:"addOctaveShift",value:function(e,t,i){var n=1,r=e.element("staff");if(r)try{n=parseInt(r.value,10)}catch(m){var s=Fr.translateText("ReaderErrorMessages/OctaveShiftStaffError","Invalid octave shift staff number -> set to default");this.musicSheet.SheetErrors.pushMeasureError(s),n=1,L.debug("ExpressionReader.addOctaveShift",s,m)}var a=e.element("direction-type");if(a){var o=a.element("octave-shift"),u=this.readPlacement(e);if(void 0!==o&&o.hasAttributes)try{var l=this.readNumber(o);if(o.attribute("size")){var h,c=parseInt(o.attribute("size").value,10),f=0;8===c?f=1:15===c&&(f=2);var d=null===(h=o.attribute("type"))||void 0===h?void 0:h.value;if(d||(u===g.Above?d="down":u===g.Below&&(d="up")),"up"===d||"down"===d){var p=new Os(d,f);p.StaffNumber=n,this.getMultiExpression=this.createNewMultiExpressionIfNeeded(t,l),this.getMultiExpression.OctaveShiftStart=p,p.ParentStartMultiExpression=this.getMultiExpression,this.openOctaveShift=p}else if("stop"===d){if(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}else d||L.debug("octave-shift missing type in xml")}}catch(m){var v=Fr.translateText("ReaderErrorMessages/OctaveShiftError","Error while reading octave shift.");this.musicSheet.SheetErrors.pushMeasureError(v),L.debug("ExpressionReader.addOctaveShift",v,m)}}}},{key:"addPedalMarking",value:function(e,t,i){var n=e.element("direction-type");if(n){var r=n.element("pedal");if(void 0!==r&&r.hasAttributes){var s=!1,a=!1;try{var o,u,l,h;switch("yes"===(null===(o=r.attribute("line"))||void 0===o?void 0:o.value)?a=!0:"no"===(null===(u=r.attribute("line"))||void 0===u?void 0:u.value)&&(a=!1,s=!0),"yes"===(null===(l=r.attribute("sign"))||void 0===l?void 0:l.value)?s=!0:"no"===(null===(h=r.attribute("sign"))||void 0===h?void 0:h.value)&&(s=!1,a=!0),r.attribute("type").value){case"start":this.openPedal&&this.openPedal.IsLine&&this.endOpenPedal(t),this.createNewMultiExpressionIfNeeded(t,-1),this.openPedal=new Oo(a,s),this.getMultiExpression.PedalStart=this.openPedal,this.openPedal.ParentStartMultiExpression=this.getMultiExpression;break;case"stop":this.openPedal&&this.endOpenPedal(t);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 Oo(a,s),this.openPedal.ChangeBegin=!0,this.getMultiExpression.PedalStart=this.openPedal,this.openPedal.ParentStartMultiExpression=this.getMultiExpression)}}catch(f){var c=Fr.translateText("ReaderErrorMessages/PedalError","Error while reading pedal.");this.musicSheet.SheetErrors.pushMeasureError(c),L.debug("ExpressionReader.addPedalMarking",c,f)}}}}},{key:"endOpenPedal",value:function(e){this.createNewMultiExpressionIfNeeded(e,-1),this.getMultiExpression.PedalEnd=this.openPedal,this.openPedal.ParentEndMultiExpression=this.getMultiExpression,this.openPedal=void 0}},{key:"addWavyLine",value:function(e,t,i,n){if(e&&e.hasAttributes)try{switch(e.attribute("type").value){case"start":this.createNewMultiExpressionIfNeeded(t,-1),this.openWavyLine=new Fo(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(s){var r=Fr.translateText("ReaderErrorMessages/WavyLineError","Error while reading wavy-line.");this.musicSheet.SheetErrors.pushMeasureError(r),L.debug("ExpressionReader.addWavyLine",r,s)}}},{key:"initialize",value:function(){this.placement=g.NotYetDefined,this.soundTempo=0,this.soundDynamic=0,this.offsetDivisions=0}},{key:"readPlacement",value:function(e){var t,i=null===(t=e.attribute("placement"))||void 0===t?void 0:t.value;return"above"===i?g.Above:"below"===i?g.Below:g.NotYetDefined}},{key:"readExpressionPlacement",value:function(e,t){try{var i=parseInt(e.value,10);i<0?this.placement=g.Below:i>0&&(this.placement=g.Above)}catch(n){L.debug("ExpressionReader.readExpressionParameters",t,n)}}},{key:"interpretInstantaneousDynamics",value:function(e,t,i,n){if(e.hasElements){e.hasAttributes&&e.attribute("default-x")&&(this.directionTimestamp=f.createFromFraction(i));var r=this.readNumber(e),s=e.elements()[0].name;if("other-dynamics"===s&&(s=e.elements()[0].value),s){n?this.createNewMultiExpressionIfNeeded(t,r,f.createFromFraction(i)):this.createNewMultiExpressionIfNeeded(t,r);var a=new rt(s,this.soundDynamic,this.placement,this.staffNumber,t);a.InMeasureTimestamp=i.clone(),this.getMultiExpression.addExpression(a,""),this.initialize(),this.activeInstantaneousDynamic?this.activeInstantaneousDynamic.DynEnum=a.DynEnum:this.activeInstantaneousDynamic=new rt(s,0,g.NotYetDefined,1,t)}}}},{key:"interpretWords",value:function(e,t,i){var n,r=e.value,s=e.attribute("font-style");s&&("italic"===s.value&&(n=Et.Italic));if(r.length>0){if(e.hasAttributes&&e.attribute("default-x")&&(this.directionTimestamp=f.createFromFraction(i)),this.checkIfWordsNodeIsRepetitionInstruction(r))return;this.fillMultiOrTempoExpression(r,t,i,n),this.initialize()}}},{key:"readNumber",value:function(e){var t,i=1,n=null===(t=e.attribute("number"))||void 0===t?void 0:t.value;return n&&(i=Number.parseInt(n,10)),i}},{key:"interpretWedge",value:function(e,t,i,n){var r,s;void 0!==e&&e.hasAttributes&&e.attribute("default-x")&&(this.directionTimestamp=f.createFromFraction(i));var a=this.readNumber(e);"stop"===(null===(r=e.attribute("type"))||void 0===r||null===(s=r.value)||void 0===s?void 0:s.toLowerCase())?this.createNewMultiExpressionIfNeeded(t,a,i):this.createNewMultiExpressionIfNeeded(t,a),this.addWedge(e,t,i),this.initialize()}},{key:"interpretRehearsalMark",value:function(e,t,i,n){t.rehearsalExpression=new Zs(e.value,this.placement)}},{key:"createNewMultiExpressionIfNeeded",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;i||(i=this.directionTimestamp);var n=this.getMultiExpression;return(!n||n&&(n.SourceMeasureParent!==e||n.numberXml!==t||n.SourceMeasureParent===e&&n.Timestamp!==i))&&(this.getMultiExpression=n=new Xs(e,f.createFromFraction(i)),e.StaffLinkedExpressions[this.globalStaffIndex].push(n)),n}},{key:"createNewTempoExpressionIfNeeded",value:function(e){this.currentMultiTempoExpression&&this.currentMultiTempoExpression.SourceMeasureParent===e&&this.currentMultiTempoExpression.Timestamp===this.directionTimestamp||(this.currentMultiTempoExpression=new qs(e,f.createFromFraction(this.directionTimestamp)),e.TempoExpressions.push(this.currentMultiTempoExpression))}},{key:"addWedge",value:function(e,t,i){if(void 0!==e&&e.hasAttributes){var n=this.readNumber(e),r=e.attribute("type").value.toLowerCase();try{if("crescendo"===r||"diminuendo"===r){var s=new S(_[r],this.placement,this.staffNumber,t,this.activeInstantaneousDynamic,n);this.openContinuousDynamicExpressions.push(s);var a=this.getMultiExpression;a||(a=this.createNewMultiExpressionIfNeeded(t,n)),a.StartingContinuousDynamic=s,s.StartMultiExpression=a,void 0!==this.activeInstantaneousDynamic&&this.activeInstantaneousDynamic.StaffNumber===s.StaffNumber&&(this.activeInstantaneousDynamic=void 0)}else if("stop"===r){var u,l=o(this.openContinuousDynamicExpressions);try{for(l.s();!(u=l.n()).done;){var h=u.value;h.NumberXml===n&&h.NumberXml===n&&this.closeOpenContinuousDynamic(h,t,i)}}catch(f){l.e(f)}finally{l.f()}}}catch(d){var c="ReaderErrorMessages/WedgeError, Error while reading Crescendo / Diminuendo.";this.musicSheet.SheetErrors.pushMeasureError(c),L.debug("ExpressionReader.addWedge",c,d)}}}},{key:"fillMultiOrTempoExpression",value:function(e,t,i,n){if(e){var r=e.trim();this.createExpressionFromString("",r,t,i,e,n)}}},{key:"createExpressionFromString",value:function(e,t,i,n,r,s){if(Gs.isInputStringInstantaneousTempo(t)||js.isInputStringContinuousTempo(t)){if(i.TempoExpressions.length>0)for(var a=0,o=i.TempoExpressions.length;a0)for(var m=0,g=i.TempoExpressions.length;m0&&!this.hasDigit(t)&&this.globalStaffIndex>0){if(y.EntriesList[0].label.indexOf(t)>=0)return!1;break}}var b=kt.CenterBottom;this.musicSheet.Rules.CompactMode&&(b=kt.LeftBottom);var x=new Hs(t,this.placement,b,this.staffNumber);return x.fontStyle=s,v.addExpression(x,e),!1}},{key:"closeOpenContinuousDynamic",value:function(e,t,i){if(e){var n=e.NumberXml;e.EndMultiExpression=this.createNewMultiExpressionIfNeeded(t,n,i),e.StartMultiExpression.EndingContinuousDynamic=e,this.openContinuousDynamicExpressions=this.openContinuousDynamicExpressions.filter((function(t){return t!==e}))}}},{key:"closeOpenContinuousTempo",value:function(e){this.openContinuousTempoExpression.AbsoluteEndTimestamp=e,this.openContinuousTempoExpression=void 0}},{key:"checkIfWordsNodeIsRepetitionInstruction",value:function(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}},{key:"hasDigit",value:function(e){return/\d/.test(e)}}]),e}(),Go=function(){function e(){k(this,e)}return E(e,[{key:"StartNote",get:function(){return this.startNote},set:function(e){this.startNote=e}},{key:"EndNote",get:function(){return this.endNote},set:function(e){this.endNote=e}},{key:"startNoteHasMoreStartingSlurs",value:function(){if(!this.startNote)return!1;for(var e=0,t=this.startNote.NoteSlurs.length;e0){var s=r.attribute("type").value,a=1;try{r.attribute("number")&&(a=parseInt(r.attribute("number").value,10))}catch(p){L.debug("VoiceGenerator.addSlur number: ",p)}var u=g.NotYetDefined,l=r.attribute("placement");l&&l.value&&("above"===l.value?u=g.Above:"below"===l.value&&(u=g.Below));var h=r.attribute("orientation");if(h&&h.value&&("over"===h.value?u=g.Above:"under"===h.value&&(u=g.Below)),"start"===s){var c=this.openSlurDict[a];c||(c=new Go,this.openSlurDict[a]=c),c.StartNote=t,c.PlacementXml=u}else if("stop"===s){var f=this.openSlurDict[a];if(f){if(f.EndNote=t,!t.checkForDoubleSlur(f))t.NoteSlurs.push(f),f.StartNote.NoteSlurs.push(f);delete this.openSlurDict[a]}}}}}catch(v){n.e(v)}finally{n.f()}}}catch(v){var d=Fr.translateText("ReaderErrorMessages/SlurError","Error while reading slur.");this.musicSheet.SheetErrors.pushMeasureError(d)}}}]),e}(),Uo=function(){function e(t,i,n,r){k(this,e),this.voiceGeneratorsDict={},this.staffMainVoiceGeneratorDict={},this.divisions=0,this.currentClefNumber=1,this.currentXmlMeasureIndex=0,this.activeKeyHasBeenInitialized=!1,this.abstractInstructions=[],this.openChordSymbolContainers=[],this.soundTempos=new Map,this.xmlNotes=[],this.repetitionInstructionReader=i,this.xmlMeasureList=n,this.musicSheet=r.GetMusicSheet,this.instrument=r,this.activeClefs=new Array(r.Staves.length),this.activeClefsHaveBeenInitialized=new Array(r.Staves.length);for(var s=0;s=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);var s=new f(0,1),a=new f(0,1),u=!1;this.maxTieNoteFraction=new f(0,1);var l=!1,h=[];try{var c,d=this.xmlMeasureList[this.currentXmlMeasureIndex],p=d.elements();if(e.Rules.UseXMLMeasureNumbers&&!Number.isInteger(e.MeasureNumberXML)){var v,m=parseInt(null===(v=d.attribute("number"))||void 0===v?void 0:v.value,10);Number.isInteger(m)&&(e.MeasureNumberXML=m)}for(var g=0;g0&&(c=p[g-1]),"print"===y.name){var b=y.attribute("new-system");"yes"===(null==b?void 0:b.value)&&(e.printNewSystemXml=!0);var S=y.attribute("new-page");"yes"===(null==S?void 0:S.value)&&(e.printNewPageXml=!0)}else if("note"===y.name){var x;y.element("grace")||(this.xmlNotes.push(y),h.push(y));var k=!0;"no"===(null===(x=y.attribute("print-object"))||void 0===x?void 0:x.value)&&(k=!1);var _=1;this.instrument.Staves.length>1&&y.element("staff")&&(_=parseInt(y.element("staff").value,10),isNaN(_)&&(L.debug("InstrumentReader.readNextXmlMeasure.get staff number"),_=1)),this.currentStaff=this.instrument.Staves[_-1];var E=void 0!==y.element("chord");if(y.element("voice")){var w=parseInt(y.element("voice").value,10);this.currentVoiceGenerator=this.getOrCreateVoiceGenerator(w,_-1)}else E&&this.currentVoiceGenerator||(this.currentVoiceGenerator=this.getOrCreateVoiceGenerator(1,_-1));var T=0,P=new f(0,1),C=2,A=void 0,R=!1;if(y.element("duration")){if(T=parseInt(y.element("duration").value,10),isNaN(T)){var I=Fr.translateText("ReaderErrorMessages/NoteDurationError","Invalid Note Duration.");this.musicSheet.SheetErrors.pushMeasureError(I),L.debug("InstrumentReader.readNextXmlMeasure",I);continue}if(P=new f(T,4*this.divisions),0===T?P=this.getNoteDurationFromTypeNode(y):A=this.getNoteDurationFromTypeNode(y),y.element("time-modification")){P=this.getNoteDurationForTuplet(y);var N=y.element("time-modification");null!=N&&N.element("normal-notes")&&(C=parseInt(N.element("normal-notes").value,10)),R=!0}}var B=void 0!==y.element("rest"),D=y.element("notations"),O=void 0!==y.element("grace")||0===T||E&&l,F=!1,V=!1;if(O){var G=y.element("duration"),W=y.element("grace");if(W&&W.attributes())if(W.attribute("slash"))"yes"===W.attribute("slash").value&&(F=!0);G||(P=this.getNoteDurationFromTypeNode(y));var U=y.element("notations");U&&U.element("slur")&&(V=!0)}var z=!1;y.element("cue")&&(z=!0);var H=y.element("type"),X=Vr.UNDEFINED;if(H){var Y=H.attribute("size");"cue"===(null==Y?void 0:Y.value)&&(z=!0),X=Gr.StringToNoteType(H.value)}var j=os.Undefined,K=void 0,q=y.element("stem");if(q){switch(q.value){case"down":j=os.Down;break;case"up":j=os.Up;break;case"double":j=os.Double;break;case"none":j=os.None;break;default:j=os.Undefined}var J=q.attribute("color");J&&(K=this.parseXmlColor(J.value))}var Z=0,$="",Q="";if(D){var ee=D.element("ornaments");if(ee){var te=ee.element("tremolo");if(te){var ie=te.attribute("type");if($=ie.value,ie){var ne=parseInt(te.value,10);ne>0&&(Z=ne),"start"!==ie.value&&"stop"!==ie.value||(P=new f(parseInt(y.element("duration").value,10),4*this.divisions))}}var re=ee.elements("wavy-line");if(void 0!==re){var se,ae=o(re);try{for(ae.s();!(se=ae.n()).done;){var oe=se.value,ue=this.expressionReaders[this.readExpressionStaffNumber(y)-1];ue&&(ue.readExpressionParameters(oe,this.instrument,this.divisions,s,a,this.currentMeasure.MeasureNumber,!1),ue.addWavyLine(oe,this.currentMeasure,s,a))}}catch(vt){ae.e(vt)}finally{ae.f()}}}var le=D.element("glissando");if(le)"start"===le.attribute("type").value&&(Q="start")}var he=void 0,ce=y.element("notehead");if(ce){var fe=ce.attribute("color");fe&&(he=this.parseXmlColor(fe.value))}var de=void 0,pe=y.attribute("color");pe&&(de=this.parseXmlColor(pe.value),he||(he=de),K||(K=de));var ve=s.clone();E&&(ve=a.clone()),this.currentStaffEntry=this.currentMeasure.findOrCreateStaffEntry(ve,this.inSourceMeasureInstrumentIndex+_-1,this.currentStaff).staffEntry,(!this.currentVoiceGenerator.hasVoiceEntry()||!E&&!O&&!l||O&&!l||O&&!E||!O&&l)&&this.currentVoiceGenerator.createVoiceEntry(ve,this.currentStaffEntry,this.activeKey,this.ActiveRhythm,O,F,V),O||E||(a=s.clone(),s.Add(P)),E&&void 0!==this.currentStaffEntry&&this.currentStaffEntry.ParentStaff!==this.currentStaff&&(this.currentStaffEntry=this.currentVoiceGenerator.checkForStaffEntryLink(this.inSourceMeasureInstrumentIndex+_-1,this.currentStaff,this.currentStaffEntry,this.currentMeasure));var me=void 0!==this.currentStaffEntry&&void 0!==this.currentStaffEntry.Timestamp&&this.currentStaffEntry.Timestamp.Equals(new f(0,1))&&!this.currentStaffEntry.hasNotes();this.saveAbstractInstructionList(this.instrument.Staves.length,me),0!==this.openChordSymbolContainers.length&&(this.currentStaffEntry.ChordContainers=this.openChordSymbolContainers,this.openChordSymbolContainers=[]),this.activeRhythm,R||O||(P=new f(T,4*this.divisions));var ge=y.elements("dot").length;if(this.currentVoiceGenerator.read(y,P,A,X,C,B,this.currentStaffEntry,this.currentMeasure,t,this.maxTieNoteFraction,E,i,k,z,O,j,Z,K,he,ge,$,Q),void 0!==D&&D.element("dynamics")){var ye=this.expressionReaders[this.readExpressionStaffNumber(y)-1];ye&&(ye.readExpressionParameters(y,this.instrument,this.divisions,s,a,this.currentMeasure.MeasureNumber,!1),ye.read(y,this.currentMeasure,a,void 0,h.length))}l=O}else if("attributes"===y.name){var be=y.element("divisions");if(be&&(this.divisions=parseInt(be.value,10),isNaN(this.divisions))){var Se=Fr.translateText("ReaderErrorMessages/DivisionError","Invalid divisions value at Instrument: ");if(L.debug("InstrumentReader.readNextXmlMeasure",Se),this.divisions=this.readDivisionsFromNotes(),!(this.divisions>0))throw u=!0,new M(Se+this.instrument.Name);this.musicSheet.SheetErrors.push(Se+this.instrument.Name)}if(!y.element("divisions")&&0===this.divisions&&0===this.currentXmlMeasureIndex){var xe=Fr.translateText("ReaderErrorMessages/DivisionError","Invalid divisions value at Instrument: ");if(this.divisions=this.readDivisionsFromNotes(),!(this.divisions>0))throw u=!0,new M(xe+this.instrument.Name);this.musicSheet.SheetErrors.push(xe+this.instrument.Name)}this.addAbstractInstruction(y,i,c,s.clone()),s.Equals(new f(0,1))&&this.isAttributesNodeAtBeginOfMeasure(this.xmlMeasureList[this.currentXmlMeasureIndex],y)&&this.saveAbstractInstructionList(this.instrument.Staves.length,!0),this.isAttributesNodeAtEndOfMeasure(this.xmlMeasureList[this.currentXmlMeasureIndex],y)&&this.saveClefInstructionAtEndOfMeasure();var ke,_e=o(y.elements("staff-details"));try{for(_e.s();!(ke=_e.n()).done;){var Ee=ke.value,we=Ee.element("staff-lines");if(we){var Me=1,Te=Ee.attribute("number");Te&&(Me=parseInt(Te.value,10)),this.instrument.Staves[Me-1].StafflineCount=parseInt(we.value,10)}}}catch(vt){_e.e(vt)}finally{_e.f()}var Pe=y.element("measure-style");if(Pe){var Le=Pe.element("multiple-rest");if(Le){var Ce=Le.value,Ae=0;try{Ae=Number.parseInt(Ce,10),void 0!==e.multipleRestMeasures&&Ae!==e.multipleRestMeasures?e.multipleRestMeasures=0:(e.multipleRestMeasures=Ae,this.currentMultirestStartMeasure=e,this.followingMultirestMeasures=Ae+1)}catch(mt){console.log("multirest parse error: "+mt)}}}}else if("forward"===y.name){var Re=parseInt(y.element("duration").value,10);s.Add(new f(Re,4*this.divisions))}else if("backup"===y.name){var Ie=parseInt(y.element("duration").value,10);s.Sub(new f(Ie,4*this.divisions)),s.IsNegative()&&(s=new f(0,1)),a.Sub(new f(Ie,4*this.divisions)),a.IsNegative()&&(a=new f(0,1))}else if("direction"===y.name){var Ne=y.elements("direction-type"),Be=y.element("direction-type"),De=Math.min(1,s.RealValue);void 0!==this.activeRhythm&&this.activeRhythm.Rhythm&&(De/=this.activeRhythm.Rhythm.RealValue);var Oe=!1;if(this.repetitionInstructionReader&&(Oe=this.repetitionInstructionReader.handleRepetitionInstructionsFromWordsOrSymbols(Be,De)),!Oe){var Fe=this.expressionReaders[0],Ve=this.readExpressionStaffNumber(y)-1;if(Ve0?this.musicSheet.SourceMeasures[0]:this.currentMeasure;var i,n=new Vt(Gt.G,0,2);t.FirstInstructionsStaffEntries[e]?(i=t.FirstInstructionsStaffEntries[e]).removeFirstInstructionOfTypeClefInstruction():(i=new Hr(void 0,void 0),t.FirstInstructionsStaffEntries[e]=i),n.Parent=i,i.Instructions.splice(0,0,n)}},{key:"createDefaultKeyInstruction",value:function(){var e;e=this.musicSheet.SourceMeasures.length>0?this.musicSheet.SourceMeasures[0]:this.currentMeasure;for(var t=new Ut(void 0,0,zt.major),i=this.inSourceMeasureInstrumentIndex;i0&&"backup"===i[n-1].name)return!0;for(var r=-1,s=0;s0||r<0}},{key:"isAttributesNodeAtEndOfMeasure",value:function(e,t){for(var i=e.elements().slice(),n=0,r=0;rs}},{key:"getNoteDurationFromTypeNode",value:function(e){var t=e.element("type");if(t){var i=t.value;return Gr.getNoteDurationFromType(i)}return new f(0,4*this.divisions)}},{key:"addAbstractInstruction",value:function(e,t,i,n){if(!e.element("divisions")||1!==e.elements().length){var r=e.element("transpose");if(r){var s=r.element("chromatic");s&&(this.instrument.PlaybackTranspose=parseInt(s.value,10))}var a,o=e.elements("clef");if(o.length>0)for(var u=0,l=o.length;u using default clef line."),this.musicSheet.SheetErrors.pushMeasureError(a),d=2,L.debug("InstrumentReader.addAbstractInstruction",a,$)}var g=h.element("sign");if(g)try{c=Gt[g.value],Vt.isSupportedClef(c)||(a=Fr.translateText("ReaderErrorMessages/ClefError","Unsupported clef found -> using default clef."),this.musicSheet.SheetErrors.pushMeasureError(a),c=Gt.G,d=2),c===Gt.TAB&&(v=-1)}catch(Q){a=Fr.translateText("ReaderErrorMessages/ClefError","Invalid clef found -> using default clef."),this.musicSheet.SheetErrors.pushMeasureError(a),c=Gt.G,d=2,L.debug("InstrumentReader.addAbstractInstruction",a,Q)}var y=h.element("clef-octave-change");if(y)try{v=parseInt(y.value,10)}catch(Q){a=Fr.translateText("ReaderErrorMessages/ClefOctaveError","Invalid clef octave found -> using default clef octave."),this.musicSheet.SheetErrors.pushMeasureError(a),v=0}if(h.hasAttributes&&h.attribute("number"))try{(p=parseInt(h.attribute("number").value,10))>this.currentClefNumber&&(p=this.currentClefNumber),this.currentClefNumber=p+1}catch(ee){a=Fr.translateText("ReaderErrorMessages/ClefError","Invalid clef found -> using default clef."),this.musicSheet.SheetErrors.pushMeasureError(a),p=1,this.currentClefNumber=p+1}var b=new Vt(c,v,d);this.abstractInstructions.push([p,b,n])}if(void 0!==e.element("key")&&this.instrument.MidiInstrumentId!==Wt.Percussion){var S=0,x=e.element("key").element("fifths");if(x)try{S=parseInt(x.value,10)}catch($){a=Fr.translateText("ReaderErrorMessages/KeyError","Invalid key found -> set to default."),this.musicSheet.SheetErrors.pushMeasureError(a),S=0,L.debug("InstrumentReader.addAbstractInstruction",a,$)}var k=zt.none,_=e.element("key");if(_&&(_=_.element("mode")),_)try{k=zt[_.value]}catch($){a=Fr.translateText("ReaderErrorMessages/KeyError","Invalid key found -> set to default."),this.musicSheet.SheetErrors.pushMeasureError(a),k=zt.major,L.debug("InstrumentReader.addAbstractInstruction",a,$)}var E=new Ut(void 0,S,k);this.abstractInstructions.push([1,E,n])}if(e.element("time")){var w=e.element("time"),M=lt.NONE,T=!0;if(void 0!==w&&w.hasAttributes){var P=w.attribute("symbol");P&&("common"===P.value?M=lt.COMMON:"cut"===P.value&&(M=lt.CUT));var C=w.attribute("print-object");C&&"no"===C.value&&(T=!1)}for(var A=0,R=0,I=w&&void 0!==w.element("senza-misura"),N=e.elements("time"),B=[],D=[],O=0,F=N.length;O0&&void 0!==D&&B.length===D.length){for(var G=B.length,W=new Array(G),U=0,z=0;z set to default."),this.musicSheet.SheetErrors.pushMeasureError(a),A=4,R=4,L.debug("InstrumentReader.addAbstractInstruction",a,$)}var Z=new ut(new f(A,R,0,!1),M);Z.PrintObject=T,this.abstractInstructions.push([1,Z,n])}}}}},{key:"saveAbstractInstructionList",value:function(e,t){for(var i=this.abstractInstructions.length-1;i>=0;i--){var n=this.abstractInstructions[i],r=n[0],s=n[1],a=n[2];if(s instanceof Vt){var o=s;if(0===this.currentXmlMeasureIndex||r<=this.activeClefs.length&&o!==this.activeClefs[r-1])if(t||void 0===this.currentStaffEntry||this.currentStaffEntry.hasNotes()||r-1!==this.instrument.Staves.indexOf(this.currentStaffEntry.ParentStaff))if(t){if(0!==a.RealValue)continue;var u=void 0;if(this.currentMeasure){var l=o,h=this.inSourceMeasureInstrumentIndex+r-1,c=this.currentMeasure.FirstInstructionsStaffEntries[h];if(0===this.currentXmlMeasureIndex)if(c)if(void 0===this.currentMeasure.FirstInstructionsStaffEntries[h]||c.Instructions[0]instanceof Vt){var f=new Hr(void 0,void 0);this.currentMeasure.LastInstructionsStaffEntries[h]=f,l.Parent=f,f.Instructions.push(l)}else u=c,l.Parent=u,u.removeFirstInstructionOfTypeClefInstruction(),u.Instructions.splice(0,0,l),this.activeClefsHaveBeenInitialized[r-1]=!0;else u=new Hr(void 0,void 0),this.currentMeasure.FirstInstructionsStaffEntries[h]=u,l.Parent=u,u.Instructions.push(l),this.activeClefsHaveBeenInitialized[r-1]=!0;else if(this.activeClefsHaveBeenInitialized[r-1]){var d=this.previousMeasure;this.followingMultirestMeasures>0&&this.currentMeasure.Rules.RenderMultipleRestMeasures&&(d=this.currentMultirestStartMeasure);var p=new Hr(void 0,void 0);d.LastInstructionsStaffEntries[h]=p,l.Parent=p,p.Instructions.push(l)}else{var v=this.musicSheet.SourceMeasures[0];v.FirstInstructionsStaffEntries[h]?(u=v.FirstInstructionsStaffEntries[h]).removeFirstInstructionOfTypeClefInstruction():u=new Hr(void 0,void 0),l.Parent=u,u.Instructions.splice(0,0,l),this.activeClefsHaveBeenInitialized[r-1]=!0}this.activeClefs[r-1]=o,this.abstractInstructions.splice(i,1)}}else{var m=void 0,g=this.activeRhythm.Rhythm;g.RealValue>0&&a.RealValue/g.RealValue>.9&&(this.currentMeasure.LastInstructionsStaffEntries[r-1]||(this.currentMeasure.LastInstructionsStaffEntries[r-1]=new Hr(void 0,this.instrument.Staves[r-1])),m=this.currentMeasure.LastInstructionsStaffEntries[r-1]),m&&(o.Parent=m,m.Instructions.push(o),this.activeClefs[r-1]=o,this.abstractInstructions.splice(i,1))}else{var y=o,b=this.currentStaffEntry;if(a&&Math.abs(a.RealValue-b.Timestamp.RealValue)>.01)continue;y.Parent=b,b.removeFirstInstructionOfTypeClefInstruction(),b.Instructions.push(y),this.activeClefs[r-1]=o,this.abstractInstructions.splice(i,1)}else r<=this.activeClefs.length&&o===this.activeClefs[r-1]&&this.abstractInstructions.splice(i,1)}if(s instanceof Ut){var S=s;if(this.activeKey&&this.activeKey.Key===S.Key)this.abstractInstructions.splice(i,1);else{this.activeKey=S,this.abstractInstructions.splice(i,1);var x=void 0;if(this.activeKeyHasBeenInitialized?x=this.currentMeasure:(this.activeKeyHasBeenInitialized=!0,x=this.currentXmlMeasureIndex>0?this.musicSheet.SourceMeasures[0]:this.currentMeasure),x)for(var k=this.inSourceMeasureInstrumentIndex;k=0;e--){var t=this.abstractInstructions[e][0],i=this.abstractInstructions[e][1];if(i instanceof Vt){var n=i;if(!this.activeClefs[t-1]||n.ClefType!==this.activeClefs[t-1].ClefType||n.ClefType===this.activeClefs[t-1].ClefType&&n.Line!==this.activeClefs[t-1].Line){var r=new Hr(void 0,void 0);this.currentMeasure.LastInstructionsStaffEntries[this.inSourceMeasureInstrumentIndex+t-1]=r;var s=n;s.Parent=r,r.Instructions.push(s),this.activeClefs[t-1]=n,this.abstractInstructions.splice(e,1)}}}}},{key:"getNoteDurationForTuplet",value:function(e){var t=new f(0,1),i=this.getNoteDurationFromTypeNode(e);if(e.element("time-modification")){var n=e.element("time-modification");if(n&&void 0!==n.element("actual-notes")&&n.element("normal-notes")){var r=n.element("actual-notes"),s=n.element("normal-notes");if(void 0!==r&&s){var a=parseInt(r.value,10),o=parseInt(s.value,10);t=new f(o*i.Numerator,a*i.Denominator)}}}return t}},{key:"readExpressionStaffNumber",value:function(e){var t=1;if(e.element("staff")){var i=e.element("staff");if(i)try{t=parseInt(i.value,10)}catch(r){var n=Fr.translateText("ReaderErrorMessages/ExpressionStaffError","Invalid Expression staff number -> set to default.");this.musicSheet.SheetErrors.pushMeasureError(n),t=1,L.debug("InstrumentReader.readExpressionStaffNumber",n,r)}}return t}},{key:"readDivisionsFromNotes",value:function(){for(var e=0,t=this.currentXmlMeasureIndex,i=!1;!i;){for(var n=this.xmlMeasureList[t].elements(),r=0,s=n.length;r0){i=!0;break}}if(0===e&&++t===this.xmlMeasureList.length){var c=Fr.translateText("ReaderErrorMEssages/DivisionsError","Invalid divisions value at Instrument: ");throw new M(c+this.instrument.Name)}}return e}}]),e}(),zo=function(){function e(t){k(this,e),this.parentInstrument=t,this.fixedKey=-1,this.name=this.parseMidiInstrument(this.parentInstrument.Name),this.midiInstrumentID=e.midiInstrument[this.name],this.volume=1}return E(e,[{key:"ParentInstrument",get:function(){return this.parentInstrument}},{key:"setMidiInstrument",value:function(t){this.midiInstrumentID=e.midiInstrument[this.parseMidiInstrument(t)]}},{key:"parseMidiInstrument",value:function(t){try{if(t){var i=t.toLowerCase().trim();for(var n in i=i.replace(/\s+/g,"_"),e.midiInstrument)if(-1!==i.indexOf(n))return n}if(this.parentInstrument.Name){var r=this.parentInstrument.Name.toLowerCase().trim();for(var s in r=r.replace(/\s+/g,"_"),e.midiInstrument)if(-1!==r.indexOf(s))return s}}catch(a){L.error("Error parsing MIDI Instrument. Default to Grand Piano.")}return"unnamed"}}],[{key:"isPianoInstrument",value:function(e){return e===Wt.Acoustic_Grand_Piano||e===Wt.Bright_Acoustic_Piano||e===Wt.Electric_Grand_Piano||e===Wt.Electric_Piano_1||e===Wt.Electric_Piano_2}}]),e}();zo.midiInstrument={alto_saxophone:Wt.Alto_Sax,baritone_saxophone:Wt.Baritone_Sax,horn_in_f:Wt.French_Horn,english_horn:Wt.English_Horn,euphonium:Wt.Euphonium,clarinet_in_bb:Wt.clarinet_in_bb,clarinet_in_eb:Wt.clarinet_in_eb,clarinet:Wt.Clarinet,alto_clarinet:Wt.Alto_Clarinet,bass_clarinet:Wt.Bass_Clarinet,bassoon:Wt.Bassoon,bass_trombone:Wt.Bass_Trombone,alt:Wt.Synth_Voice,alto:Wt.Synth_Voice,banjo:Wt.Banjo,bariton:Wt.Synth_Voice,baritone:Wt.Synth_Voice,bass:Wt.Synth_Voice,"blockflöte":Wt.Recorder,brass:Wt.Trombone,bratsche:Wt.Viola,cello:Wt.Cello,contrabass:Wt.Contrabass,drums:Wt.Percussion,flute:Wt.Flute,"flöte":Wt.Flute,frenchhorn:Wt.French_Horn,gitarre:Wt.Acoustic_Guitar_nylon,guitar:Wt.Acoustic_Guitar_nylon,harfe:Wt.Orchestral_Harp,harp:Wt.Orchestral_Harp,klarinette:Wt.Clarinet,klavier:Wt.Acoustic_Grand_Piano,kontrabass:Wt.Contrabass,oboe:Wt.Oboe,organ:Wt.Church_Organ,orgel:Wt.Church_Organ,orgue:Wt.Church_Organ,percussion:Wt.Synth_Drum,"小军鼓":Wt.Synth_Drum,snare_drum:Wt.Synth_Drum,bass_drum:Wt.Synth_Drum,side_drum:Wt.Synth_Drum,piano:Wt.Acoustic_Grand_Piano,piccolo:Wt.Piccolo,posaune:Wt.Trombone,recorder:Wt.Recorder,sax:Wt.Tenor_Sax,schlagwerk:Wt.Percussion,schlagzeug:Wt.Percussion,sopran:Wt.Synth_Voice,steeldrum:Wt.Steel_Drums,streicher:Wt.String_Ensemble_1,strings:Wt.String_Ensemble_1,tenor:Wt.Synth_Voice,tpt:Wt.Trumpet,trombone:Wt.Trombone,trompete:Wt.Trumpet,trumpet:Wt.Trumpet,tuba:Wt.Tuba,unnamed:Wt.Acoustic_Grand_Piano,viola:Wt.Viola,violin:Wt.Violin,"violon-c":Wt.Cello,"violon.":Wt.Violin,voice:Wt.Synth_Voice,woodblock:Wt.Woodblock,alto_clarinet_in_eb:Wt.AltoClarinetInEb,trumpet_in_bb:Wt.TrumpetInBb,tenor_saxophone:Wt.TenorSaxophone};var Ho=function(){function e(){k(this,e)}return E(e,null,[{key:"StringContainsSeparatedWord",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=new RegExp("( |^)"+t+"([ .]|$)",i?"i":void 0);return n.test(e)}}]),e}();i("S",Ho);var Xo=function(){function e(){k(this,e)}return E(e,[{key:"MusicSheet",set:function(e){this.musicSheet=e,this.xmlMeasureList=new Array(this.musicSheet.Instruments.length),this.repetitionInstructions=[]}},{key:"prepareReadingMeasure",value:function(e,t){this.currentMeasureIndex=t}},{key:"handleLineRepetitionInstructions",value:function(e){var t=!1;if(e.elements().length>0){var i="",n=!1,r="",s="",a="",o=[],u=e.element("bar-style");u&&(a=u.value),i=e.attributes().length>0&&e.attribute("location")?e.attribute("location").value:"right";for(var l=e.elements(),h=0,c=l.length;h0)if("left"===i){if("start"===s){var E=new Yr(this.currentMeasureIndex,jr.Ending,Kr.Begin,void 0,o);this.addInstruction(this.repetitionInstructions,E)}if("forward"===r){var w=new Yr(this.currentMeasureIndex,jr.StartLine);this.addInstruction(this.repetitionInstructions,w)}}else{if("stop"===s){var M=new Yr(this.currentMeasureIndex,jr.Ending,Kr.End,void 0,o);this.addInstruction(this.repetitionInstructions,M)}if("backward"===r){var T=new Yr(this.currentMeasureIndex,jr.BackJumpLine);this.addInstruction(this.repetitionInstructions,T)}}}return t}},{key:"handleRepetitionInstructionsFromWordsOrSymbols",value:function(e,t){var i=e.element("words"),n=this.currentMeasureIndex;if(i){var r="d\\s?\\.s\\.",s=i.value.trim().toLowerCase();if(Ho.StringContainsSeparatedWord(s,r+" al fine",!0)){var a=new Yr(n,jr.DalSegnoAlFine);return this.addInstruction(this.repetitionInstructions,a),!0}if(Ho.StringContainsSeparatedWord(s,r+" al coda",!0)){var o=new Yr(n,jr.DalSegnoAlCoda);return this.addInstruction(this.repetitionInstructions,o),!0}var u,l="d\\.\\s?c\\.";if(Ho.StringContainsSeparatedWord(s,l+" al fine",!0)){var h=new Yr(n,jr.DaCapoAlFine);return this.addInstruction(this.repetitionInstructions,h),!0}if(Ho.StringContainsSeparatedWord(s,l+" al coda",!0)){var c=new Yr(n,jr.DaCapoAlCoda);return this.addInstruction(this.repetitionInstructions,c),!0}if(Ho.StringContainsSeparatedWord(s,l)||Ho.StringContainsSeparatedWord(s,"da\\s?capo",!0)){var f=new Yr(n,jr.DaCapo);return this.addInstruction(this.repetitionInstructions,f),!0}if(Ho.StringContainsSeparatedWord(s,r,!0)||Ho.StringContainsSeparatedWord(s,"dal\\s?segno",!0))return u=Ho.StringContainsSeparatedWord(s,"al\\s?coda",!0)?new Yr(n,jr.DalSegnoAlCoda):new Yr(n,jr.DalSegno),this.addInstruction(this.repetitionInstructions,u),!0;if(Ho.StringContainsSeparatedWord(s,"to\\s?coda",!0)||Ho.StringContainsSeparatedWord(s,"a (la )?coda",!0)){var d=new Yr(n,jr.ToCoda);return this.addInstruction(this.repetitionInstructions,d),!0}if(Ho.StringContainsSeparatedWord(s,"fine",!0)){var p=new Yr(n,jr.Fine);return this.addInstruction(this.repetitionInstructions,p),!0}if(Ho.StringContainsSeparatedWord(s,"coda",!0)){var v=new Yr(n,jr.Coda);return this.addInstruction(this.repetitionInstructions,v),!0}if(Ho.StringContainsSeparatedWord(s,"segno",!0)){var m=new Yr(n,jr.Segno);return this.addInstruction(this.repetitionInstructions,m),!0}}else{if(e.element("segno")){var g=new Yr(n,jr.Segno);return this.addInstruction(this.repetitionInstructions,g),!0}if(e.element("coda")){var y=new Yr(n,jr.Coda);return this.addInstruction(this.repetitionInstructions,y),!0}}return!1}},{key:"removeRedundantInstructions",value:function(){for(var e=0,t=0,i=0,n=0,r=0;r0&&this.findInstructionInPreviousMeasure(r,s.measureIndex,jr.ToCoda)&&(s.type=jr.None),0===t&&0===i&&(s.type=jr.ToCoda,s.alignment=Kr.End,s.measureIndex--);break;case jr.Segno:if(e-n>0){for(var a=!1,o=0,u=this.repetitionInstructions.length;o0?jr.DalSegnoAlCoda:jr.DalSegno,s.type=jr.None,a=!0;break;case jr.DalSegno:case jr.DalSegnoAlFine:case jr.DalSegnoAlCoda:s.type=jr.None,a=!0}if(a)break}if(a)break;s.type=i-t>0?jr.DalSegnoAlCoda:jr.DalSegno,s.alignment=Kr.End,s.measureIndex--}}if(this.backwardSearchForPreviousIdenticalInstruction(r,s)||s.type===jr.None)this.repetitionInstructions.splice(r,1),r--;else switch(s.type){case jr.Fine:break;case jr.ToCoda:i++;break;case jr.Coda:t++;break;case jr.Segno:e++;break;case jr.DalSegnoAlFine:case jr.DalSegnoAlCoda:n++}}this.repetitionInstructions.sort(Xr.Compare)}},{key:"findInstructionInPreviousMeasure",value:function(e,t,i){for(var n=e-1;n>=0;n--){var r=this.repetitionInstructions[n];if(t-r.measureIndex==1&&r.type===i)return!0}return!1}},{key:"backwardSearchForPreviousIdenticalInstruction",value:function(e,t){for(var i=e-1;i>=0;i--){if(this.repetitionInstructions[i].equals(t))return!0}return!1}},{key:"addInstruction",value:function(e,t){for(var i=!0,n=0,r=e.length;n0;)try{var a=this.openRepetitions.last();if(a.RepetitonUnderConstruction.FromWords){if(a.WaitingForCoda){var u=a.RepetitonUnderConstruction.BackwardJumpInstructions.last().measureIndex+1;u>=this.musicSheet.SourceMeasures.length&&(u=-1),a.RepetitonUnderConstruction.setEndingStartIndex(2,u)}else if(0===a.RepetitonUnderConstruction.BackwardJumpInstructions.length){this.openRepetitions.splice(this.openRepetitions.length-1,1);continue}}else if(0===a.RepetitonUnderConstruction.BackwardJumpInstructions.length){var l=n.length-1,h=new Yr(l,jr.BackJumpLine,Kr.End,a.RepetitonUnderConstruction);a.RepetitonUnderConstruction.BackwardJumpInstructions.push(h),n[l].LastRepetitionInstructions.push(h)}this.finalizeRepetition(this.openRepetitions.last())}catch(w){try{var c,f=this.openRepetitions.last().RepetitonUnderConstruction,d=o(this.repetitionInstructions);try{for(d.s();!(c=d.n()).done;){var p=c.value;p.parentRepetition===f&&(p.parentRepetition=void 0)}}catch(w){d.e(w)}finally{d.f()}this.openRepetitions.splice(this.openRepetitions.length-1,1)}catch(E){L.error("RepetitionCalculator: calculateRepetitions2",E)}}var v,m=!1,g=this.musicSheet.SourceMeasures.length-1,y=o(this.musicSheet.Repetitions);try{for(y.s();!(v=y.n()).done;){var b=v.value;if(0===b.StartIndex&&b.EndIndex===g){m=!0;break}}}catch(w){y.e(w)}finally{y.f()}if(!m){var S=new wo(this.musicSheet,!0);S.FromWords=!0,S.startMarker=new Yr(0,jr.StartLine),S.startMarker.parentRepetition=S,this.musicSheet.SourceMeasures[0].FirstRepetitionInstructions.push(S.startMarker),S.endMarker=new Yr(g,jr.BackJumpLine),S.endMarker.parentRepetition=S,S.BackwardJumpInstructions.push(S.endMarker),S.UserNumberOfRepetitions=S.DefaultNumberOfRepetitions,this.musicSheet.Repetitions.push(S)}for(var x=0,k=this.musicSheet.SourceMeasures.length;x1&&_.FirstRepetitionInstructions.sort(Xr.Compare),_.LastRepetitionInstructions.length>1&&_.LastRepetitionInstructions.sort(Xr.Compare)}}},{key:"handleRepetitionInstructions",value:function(e){var t;switch(e.type){case jr.StartLine:t=this.createNewRepetition(this.currentMeasureIndex),e.parentRepetition=t.RepetitonUnderConstruction,t.RepetitonUnderConstruction.FromWords=!1,t.RepetitonUnderConstruction.startMarker=e,this.currentMeasure.FirstRepetitionInstructions.push(e);break;case jr.BackJumpLine:t=this.getOrCreateCurrentRepetition2(!1),e.parentRepetition=t.RepetitonUnderConstruction,t.RepetitonUnderConstruction.BackwardJumpInstructions.push(e),this.currentMeasure.LastRepetitionInstructions.push(e),0===t.RepetitonUnderConstruction.EndingParts.length&&this.finalizeRepetition(t);break;case jr.Ending:if(t=this.getOrCreateCurrentRepetition(),e.parentRepetition=t.RepetitonUnderConstruction,e.endingIndices.contains(1)&&e.alignment===Kr.Begin){if(t.RepetitonUnderConstruction.BackwardJumpInstructions.length>0||t.RepetitonUnderConstruction.EndingIndexDict.hasOwnProperty(1)){t=void 0;for(var i=this.openRepetitions.length-1;i>=0;i--){var n=this.openRepetitions[i];if(0===n.RepetitonUnderConstruction.BackwardJumpInstructions.length)for(t=n;this.openRepetitions.length-1>i;){var r=this.openRepetitions.last();this.finalizeRepetition(r)}}void 0===t&&((t=this.createNewRepetition(0)).RepetitonUnderConstruction.startMarker=new Yr(0,jr.None))}void 0===t.RepetitonUnderConstruction.forwardJumpInstruction&&(t.RepetitonUnderConstruction.forwardJumpInstruction=new Yr(this.currentMeasureIndex-1,jr.ForwardJump,Kr.End,t.RepetitonUnderConstruction),this.musicSheet.SourceMeasures[this.currentMeasureIndex-1].LastRepetitionInstructions.push(t.RepetitonUnderConstruction.forwardJumpInstruction))}if(e.alignment===Kr.Begin)t.RepetitonUnderConstruction.setEndingsStartIndex(e.endingIndices,this.currentMeasureIndex),this.currentMeasure.FirstRepetitionInstructions.push(e);else for(var s=0,a=e.endingIndices.length;s0&&Math.abs(t.RepetitonUnderConstruction.BackwardJumpInstructions.last().measureIndex-this.currentMeasureIndex)<=1)break;if(this.openRepetitions.length&&this.openRepetitions.find((function(e){return e.RepetitonUnderConstruction.startMarker.type===jr.StartLine})).RepetitonUnderConstruction.StartIndex===this.currentMeasureIndex)break;t=this.createNewRepetition(this.currentMeasureIndex),e.parentRepetition=t.RepetitonUnderConstruction,t.RepetitonUnderConstruction.FromWords=!0,t.SegnoFound=!0,t.RepetitonUnderConstruction.startMarker=e,this.currentMeasure.FirstRepetitionInstructions.push(e);break;case jr.Fine:if(0===this.openRepetitions.length)break;if(void 0===(t=this.getCurrentRepetition(!0)))break;e.parentRepetition=t.RepetitonUnderConstruction,t.RepetitonUnderConstruction.FromWords=!0,void 0===t.RepetitonUnderConstruction.forwardJumpInstruction?(t.FineFound=!0,t.RepetitonUnderConstruction.forwardJumpInstruction=e,t.RepetitonUnderConstruction.setEndingStartIndex(2,-2),this.currentMeasure.LastRepetitionInstructions.push(e)):this.currentMeasure.LastRepetitionInstructions.push(new Yr(this.currentMeasureIndex,jr.Fine,Kr.End,void 0));break;case jr.ToCoda:if(0===this.openRepetitions.length)break;if(void 0===(t=this.getCurrentRepetition(!0)))break;void 0===t.RepetitonUnderConstruction.forwardJumpInstruction&&(e.parentRepetition=t.RepetitonUnderConstruction,t.RepetitonUnderConstruction.FromWords=!0,t.ToCodaFound=!0,t.RepetitonUnderConstruction.forwardJumpInstruction=e,this.currentMeasure.LastRepetitionInstructions.push(e));break;case jr.Coda:if(0===this.openRepetitions.length)break;t=this.getOrCreateCurrentRepetition2(!0),e.parentRepetition=t.RepetitonUnderConstruction,t.WaitingForCoda?(t.CodaFound=!0,t.RepetitonUnderConstruction.setEndingStartIndex(2,this.currentMeasureIndex),this.currentMeasure.LastRepetitionInstructions.push(e),this.finalizeRepetition(t),this.currentMeasureIndex>0&&(this.musicSheet.SourceMeasures[this.currentMeasureIndex-1].printNewSystemXml=!0)):t.ToCodaFound||(0===t.RepetitonUnderConstruction.BackwardJumpInstructions.length?(t.ToCodaFound=!0,t.RepetitonUnderConstruction.forwardJumpInstruction=new Yr(this.currentMeasureIndex,jr.ToCoda,Kr.End,t.RepetitonUnderConstruction),this.currentMeasure.LastRepetitionInstructions.push(t.RepetitonUnderConstruction.forwardJumpInstruction)):this.currentMeasure.LastRepetitionInstructions.push(new Yr(this.currentMeasureIndex,jr.Coda,Kr.Begin,void 0)));break;case jr.DaCapo:(t=this.getOrCreateCurrentRepetition()).RepetitonUnderConstruction.BackwardJumpInstructions.length>0&&this.finalizeRepetition(t),0!==t.RepetitonUnderConstruction.StartIndex&&(t=this.createNewRepetition(0)),e.parentRepetition=t.RepetitonUnderConstruction,t.RepetitonUnderConstruction.FromWords=!0,t.RepetitonUnderConstruction.startMarker=new Yr(0,jr.None,Kr.Begin,t.RepetitonUnderConstruction),t.RepetitonUnderConstruction.BackwardJumpInstructions.push(e),this.currentMeasure.LastRepetitionInstructions.push(e),0===t.RepetitonUnderConstruction.EndingParts.length&&this.finalizeRepetition(t);break;case jr.DalSegno:if((t=this.getOrCreateCurrentRepetition2(!0)).RepetitonUnderConstruction.BackwardJumpInstructions.length>0&&(this.finalizeRepetition(t),(t=this.createNewRepetition(0)).RepetitonUnderConstruction.FromWords=!0,t.RepetitonUnderConstruction.startMarker=new Yr(0,jr.None,Kr.Begin,t.RepetitonUnderConstruction)),e.parentRepetition=t.RepetitonUnderConstruction,!t.SegnoFound){var u=this.findInstructionInMainListBackwards(jr.Segno,e.measureIndex);u>=0&&(t.SegnoFound=!0,t.RepetitonUnderConstruction.startMarker=new Yr(u,jr.Segno,Kr.Begin,t.RepetitonUnderConstruction),this.musicSheet.SourceMeasures[u].FirstRepetitionInstructions.splice(0,0,t.RepetitonUnderConstruction.startMarker))}t.RepetitonUnderConstruction.EndingIndexDict.hasOwnProperty(1)&&t.RepetitonUnderConstruction.setEndingEndIndex(1,this.currentMeasureIndex),t.RepetitonUnderConstruction.BackwardJumpInstructions.push(e),this.currentMeasure.LastRepetitionInstructions.push(e);break;case jr.DalSegnoAlFine:if(0===this.openRepetitions.length)break;if(t=this.getOrCreateCurrentRepetition2(!0),e.parentRepetition=t.RepetitonUnderConstruction,!t.SegnoFound){var l=this.findInstructionInMainListBackwards(jr.Segno,e.measureIndex);l>=0&&(t.SegnoFound=!0,t.RepetitonUnderConstruction.startMarker=new Yr(l,jr.Segno,Kr.Begin,t.RepetitonUnderConstruction),this.musicSheet.SourceMeasures[l].FirstRepetitionInstructions.splice(0,0,t.RepetitonUnderConstruction.startMarker))}if(!t.FineFound){var h=this.findInstructionInMainListBackwards(jr.Fine,e.measureIndex);h>=0&&(t.FineFound=!0,t.RepetitonUnderConstruction.forwardJumpInstruction=new Yr(h,jr.Fine,Kr.Begin,t.RepetitonUnderConstruction),t.RepetitonUnderConstruction.setEndingStartIndex(2,-2),this.musicSheet.SourceMeasures[h].LastRepetitionInstructions.splice(0,0,t.RepetitonUnderConstruction.forwardJumpInstruction))}t.RepetitonUnderConstruction.EndingIndexDict.hasOwnProperty(1)||t.RepetitonUnderConstruction.setEndingEndIndex(1,this.currentMeasureIndex),t.RepetitonUnderConstruction.BackwardJumpInstructions.push(e),this.currentMeasure.LastRepetitionInstructions.push(e);break;case jr.DaCapoAlFine:if((t=this.getOrCreateCurrentRepetition()).RepetitonUnderConstruction.BackwardJumpInstructions.length>0&&(this.finalizeRepetition(t),t=this.createNewRepetition(0)),void 0!==t.RepetitonUnderConstruction.startMarker&&0!==t.RepetitonUnderConstruction.StartIndex&&(t=this.createNewRepetition(0)),t.RepetitonUnderConstruction.startMarker=new Yr(0,jr.None,Kr.Begin,t.RepetitonUnderConstruction),t.RepetitonUnderConstruction.FromWords=!0,e.parentRepetition=t.RepetitonUnderConstruction,!t.FineFound){var c=this.findInstructionInMainListBackwards(jr.Fine,e.measureIndex);c>=0&&(t.FineFound=!0,t.RepetitonUnderConstruction.forwardJumpInstruction=new Yr(c,jr.Fine,Kr.Begin,t.RepetitonUnderConstruction),t.RepetitonUnderConstruction.setEndingStartIndex(2,-2),this.musicSheet.SourceMeasures[c].LastRepetitionInstructions.splice(0,0,t.RepetitonUnderConstruction.forwardJumpInstruction))}t.RepetitonUnderConstruction.EndingIndexDict.hasOwnProperty(1)||t.RepetitonUnderConstruction.setEndingEndIndex(1,this.currentMeasureIndex),t.RepetitonUnderConstruction.BackwardJumpInstructions.push(e),this.currentMeasure.LastRepetitionInstructions.push(e);break;case jr.DalSegnoAlCoda:if(0===this.openRepetitions.length)break;if(t=this.getOrCreateCurrentRepetition2(!0),e.parentRepetition=t.RepetitonUnderConstruction,!t.SegnoFound){var f=this.findInstructionInMainListBackwards(jr.Segno,e.measureIndex);f>=0&&(t.SegnoFound=!0,t.RepetitonUnderConstruction.startMarker=new Yr(f,jr.Segno,Kr.Begin,t.RepetitonUnderConstruction),this.musicSheet.SourceMeasures[f].FirstRepetitionInstructions.splice(0,0,t.RepetitonUnderConstruction.startMarker))}if(!t.ToCodaFound){var d=this.findInstructionInMainListBackwards(jr.ToCoda,e.measureIndex);if(d>=0)t.RepetitonUnderConstruction.forwardJumpInstruction=new Yr(d,jr.ToCoda,Kr.Begin,t.RepetitonUnderConstruction),this.musicSheet.SourceMeasures[d].LastRepetitionInstructions.splice(0,0,t.RepetitonUnderConstruction.forwardJumpInstruction),t.ToCodaFound=!0;else{var p=this.findInstructionInMainListBackwards(jr.Coda,e.measureIndex);p>=0&&(t.RepetitonUnderConstruction.forwardJumpInstruction=new Yr(p,jr.ToCoda,Kr.Begin,t.RepetitonUnderConstruction),this.musicSheet.SourceMeasures[p].LastRepetitionInstructions.splice(0,0,t.RepetitonUnderConstruction.forwardJumpInstruction),t.ToCodaFound=!0)}}t.ToCodaFound&&(t.WaitingForCoda=!0),t.RepetitonUnderConstruction.EndingIndexDict.hasOwnProperty(1)||t.RepetitonUnderConstruction.setEndingEndIndex(1,this.currentMeasureIndex),t.RepetitonUnderConstruction.BackwardJumpInstructions.push(e),this.currentMeasure.LastRepetitionInstructions.push(e);break;case jr.DaCapoAlCoda:if(((t=this.getOrCreateCurrentRepetition()).RepetitonUnderConstruction.BackwardJumpInstructions.length>0||0===t.RepetitonUnderConstruction.EndingParts.length)&&(this.finalizeRepetition(t),t=this.createNewRepetition(0)),void 0!==t.RepetitonUnderConstruction.startMarker&&0!==t.RepetitonUnderConstruction.StartIndex&&(t=this.createNewRepetition(0)),t.RepetitonUnderConstruction.startMarker=new Yr(0,jr.None,Kr.Begin,t.RepetitonUnderConstruction),t.RepetitonUnderConstruction.FromWords=!0,e.parentRepetition=t.RepetitonUnderConstruction,!t.ToCodaFound){var v=this.findInstructionInMainListBackwards(jr.ToCoda,e.measureIndex);if(v>=0)t.RepetitonUnderConstruction.forwardJumpInstruction=new Yr(v,jr.ToCoda,Kr.Begin,t.RepetitonUnderConstruction),this.musicSheet.SourceMeasures[v].LastRepetitionInstructions.splice(0,0,t.RepetitonUnderConstruction.forwardJumpInstruction),t.ToCodaFound=!0;else{var m=this.findInstructionInMainListBackwards(jr.Coda,e.measureIndex);m>=0&&(t.RepetitonUnderConstruction.forwardJumpInstruction=new Yr(m,jr.ToCoda,Kr.Begin,t.RepetitonUnderConstruction),this.musicSheet.SourceMeasures[m].LastRepetitionInstructions.splice(0,0,t.RepetitonUnderConstruction.forwardJumpInstruction),t.ToCodaFound=!0)}}t.ToCodaFound&&(t.WaitingForCoda=!0),t.RepetitonUnderConstruction.EndingIndexDict.hasOwnProperty(1)||t.RepetitonUnderConstruction.setEndingEndIndex(1,this.currentMeasureIndex),t.RepetitonUnderConstruction.BackwardJumpInstructions.push(e),this.currentMeasure.LastRepetitionInstructions.push(e);break;case jr.None:break;default:throw new T("currentRepetitionInstruction")}return!0}},{key:"findInstructionInMainListBackwards",value:function(e,t){for(var i=this.repetitionInstructions.length-1;i>=0;i--){var n=this.repetitionInstructions[i];if(n.measureIndex<=t&&n.type===e)return n.measureIndex}return-1}},{key:"finalizeRepetition",value:function(e){var t=e.RepetitonUnderConstruction;if(t.BackwardJumpInstructions.length>0){var i=!0,n=this.getLastFinalizedRepetition();if(void 0!==n&&t.coversIdenticalMeasures(n)){if(t.NumberOfEndings>n.NumberOfEndings){var r=this.musicSheet.Repetitions.indexOf(n,0);r>-1&&this.musicSheet.Repetitions.splice(r,1),n.removeFromRepetitionInstructions(),this.musicSheet.Repetitions.push(t)}i=!1,t.removeFromRepetitionInstructions()}else this.musicSheet.Repetitions.push(t);i&&(t.startMarker.type===jr.None&&this.musicSheet.SourceMeasures[t.StartIndex].FirstRepetitionInstructions.push(t.startMarker),t.UserNumberOfRepetitions=t.DefaultNumberOfRepetitions)}this.openRepetitions.splice(this.openRepetitions.length-1,1)}},{key:"getCurrentRepetition",value:function(e){for(var t=void 0,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();var e=this.createNewRepetition(0);return e.RepetitonUnderConstruction.startMarker=new Yr(0,jr.None,Kr.Begin,e.RepetitonUnderConstruction),e}},{key:"getOrCreateCurrentRepetition2",value:function(e){var t=void 0;if(this.openRepetitions.length&&this.openRepetitions.last().RepetitonUnderConstruction.EndingParts.length<2)for(var i=this.openRepetitions.length-1;i>=0;i--)if((t=this.openRepetitions[i]).RepetitonUnderConstruction.FromWords===e){for(;i0){var t=this.openRepetitions.last(),i=t.RepetitonUnderConstruction;if(i.BackwardJumpInstructions.length>0){var n=Object.keys(i.EndingIndexDict);(0===n.length||i.EndingIndexDict[n[n.length-1]].part.EndIndex>=0)&&this.finalizeRepetition(t)}}var r=new jo(this.musicSheet);return this.lastRepetitionCommonPartStartIndex=e,this.openRepetitions.push(r),r}},{key:"getLastFinalizedRepetition",value:function(){if(this.musicSheet.Repetitions.length>0)return this.musicSheet.Repetitions.last()}}]),e}(),jo=E((function e(t){k(this,e),this.RepetitonUnderConstruction=new wo(t)})),Ko=function(){function e(){k(this,e)}return E(e,null,[{key:"createRepetitionInstructionReader",value:function(){return new Xo}},{key:"createRepetitionCalculator",value:function(){return new Yo}}]),e}(),qo=function(){function e(){k(this,e),this.voiceMeasureReadPlugins=[]}return E(e,[{key:"addVoiceMeasureReadPlugin",value:function(e){this.voiceMeasureReadPlugins.push(e)}},{key:"processVoiceMeasureReadPlugins",value:function(e,t,i){var n,r=o(this.voiceMeasureReadPlugins);try{for(r.s();!(n=r.n()).done;){var s=n.value;try{s.measureReadCalculations(e,t,i)}catch(a){L.info("VoiceGenerator.addSingleNote: ",a)}}}catch(u){r.e(u)}finally{r.f()}}}]),e}(),Jo=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new ca;k(this,e),this.completeNumberOfStaves=0,this.pluginManager=new qo,this.afterSheetReadingModules=t||[],this.repetitionInstructionReader=Ko.createRepetitionInstructionReader(),this.repetitionCalculator=Ko.createRepetitionCalculator(),this.rules=i}return E(e,[{key:"PluginManager",get:function(){return this.pluginManager}},{key:"CompleteNumberOfStaves",get:function(){return this.completeNumberOfStaves}},{key:"createMusicSheet",value:function(e,t){try{return this._createMusicSheet(e,t)}catch(i){return void L.error("MusicSheetReader.CreateMusicSheet",i)}}},{key:"_removeFromArray",value:function(e,t){var i=e.indexOf(t);-1!==i&&e.splice(i,1)}},{key:"trimString",value:function(e){return e.replace(/^\s+|\s+$/g,"")}},{key:"_lastElement",value:function(e){return e[e.length-1]}},{key:"_createMusicSheet",value:function(t,i){var n=[],r=0;if(this.musicSheet=new Po,this.musicSheet.Path=i,this.musicSheet.Rules=this.rules,!t)throw new M("Undefined root element");this.pushSheetLabels(t,i);var s=t.element("part-list");if(!s)throw new M("Undefined partListNode");var a=t.elements("part"),u=s.elements();this.initializeReading(u,a,n);var l=!0;this.currentFraction=new f(0,1);var h=!1,c=t.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&&(r=0),this.currentMeasure=new Jr(this.completeNumberOfStaves,this.musicSheet.Rules);var d,p,v=o(n);try{for(v.s();!(d=v.n()).done;){var m=d.value;try{l=l&&m.readNextXmlMeasure(this.currentMeasure,this.currentFraction,h)}catch(S){var g=Fr.translateText("ReaderErrorMessages/InstrumentError","Error while reading instruments.");throw new M(g,S)}}}catch(x){v.e(x)}finally{v.f()}if(l)this.musicSheet.addMeasure(this.currentMeasure),this.checkIfRhythmInstructionsAreSetAndEqual(n),this.checkSourceMeasureForNullEntries(),r=this.setSourceMeasureDuration(n,r),e.doCalculationsAfterDurationHasBeenSet(n),this.currentMeasure.AbsoluteTimestamp=this.currentFraction.clone(),this.musicSheet.SheetErrors.finalizeMeasure(this.currentMeasure.MeasureNumber),this.currentFraction.Add(this.currentMeasure.Duration),this.previousMeasure=this.currentMeasure,this.musicSheet.SoundTempos=null===(p=n[0])||void 0===p?void 0:p.SoundTempos}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(var y=0,b=this.afterSheetReadingModules.length;yr){if(this.areRhythmInstructionsMixed(t)&&u.SymbolEnum!==lt.NONE)continue;r=u.Rhythm.RealValue,s=t.indexOf(u)}}if(t.length>0&&t.lengthe.Denominator){var i=t.Denominator/e.Denominator;e.expand(i)}}},{key:"checkIfMeasureIsImplicit",value:function(e,t){return!(this.previousMeasure||!e.lt(t))||!!this.previousMeasure&&f.plus(this.previousMeasure.Duration,e).Equals(t)}},{key:"allInstrumentsHaveSameDuration",value:function(e,t){for(var i=0,n=0,r=e.length;n=0;e--)for(var t=this.currentMeasure.VerticalSourceStaffEntryContainers[e].StaffEntries.length-1;t>=0;t--){var i=this.currentMeasure.VerticalSourceStaffEntryContainers[e].StaffEntries[t];if(i)for(var n=i.VoiceEntries.length-1;n>=0;n--){var r=i.VoiceEntries[n];0===r.Notes.length&&(this._removeFromArray(r.ParentVoice.VoiceEntries,r),this._removeFromArray(i.VoiceEntries,r))}void 0!==i&&0===i.VoiceEntries.length&&(this.currentMeasure.VerticalSourceStaffEntryContainers[e].StaffEntries[t]=void 0)}for(var s=this.currentMeasure.VerticalSourceStaffEntryContainers.length-1;s>=0;s--){for(var a=0,o=0,u=this.currentMeasure.VerticalSourceStaffEntryContainers[s].StaffEntries.length;ot){if(!this.musicSheet.Title){var y=c.attribute("font-size").value,b=parseFloat(y);i0&&l.MidiInstrumentId!==Wt.Percussion&&(m.midiInstrumentID=Math.max(0,parseInt(_.value,10)-1));else if("midi-unpitched"===_.name)m.fixedKey=Math.max(0,parseInt(_.value,10));else if("volume"===_.name)try{var E=parseFloat(_.value);m.volume=E/127}catch(B){L.debug("ExpressionReader.readExpressionParameters","read volume",B)}else if("pan"===_.name)try{var w=parseFloat(_.value);m.pan=w/64}catch(B){L.debug("ExpressionReader.readExpressionParameters","read pan",B)}}catch(B){L.info("MusicSheetReader.createInstrumentGroups midi settings: ",B)}}}}catch(B){L.info("MusicSheetReader.createInstrumentGroups: ",B)}}if(0===l.SubInstruments.length){var T=new zo(l);l.SubInstruments.push(T)}n[u]=l,t?(t.InstrumentalGroups.push(l),this.musicSheet.Instruments.push(l)):(this.musicSheet.InstrumentalGroups.push(l),this.musicSheet.Instruments.push(l))}else if("part-group"===o.name&&"start"===o.attribute("type").value){var P=new xa("group",this.musicSheet,t);t?t.InstrumentalGroups.push(P):this.musicSheet.InstrumentalGroups.push(P),t=P}else if("part-group"===o.name&&"stop"===o.attribute("type").value&&t){if(1===t.InstrumentalGroups.length){var C=t.InstrumentalGroups[0];t.Parent?(t.Parent.InstrumentalGroups.push(C),this._removeFromArray(t.Parent.InstrumentalGroups,t)):(this.musicSheet.InstrumentalGroups.push(C),this._removeFromArray(this.musicSheet.InstrumentalGroups,t))}t=t.Parent}}}catch(D){var A=Fr.translateText("ReaderErrorMessages/InstrumentError","Error while reading Instruments");throw new M(A,D)}for(var R=0,I=this.musicSheet.Instruments.length;R0){var s=r[0];if(s){var a=s.element("attributes");a&&(a=a.element("staves")),a?i+=parseInt(a.value,10):i++}}}}catch(l){n.e(l)}finally{n.f()}if(isNaN(i)||i<=0){var u=Fr.translateText("ReaderErrorMessages/StaffError","Invalid number of staves.");throw new M(u)}return i}},{key:"getInstrumentNumberOfStavesFromXml",value:function(e){var t=0,i=e.element("measure");if(i){var n=i.element("attributes"),r=void 0;n&&(r=n.element("staves")),t=n&&r?parseInt(r.value,10):1}if(isNaN(t)||t<=0){var s=Fr.translateText("ReaderErrorMessages/StaffError","Invalid number of Staves.");throw new M(s)}return t}}],[{key:"doCalculationsAfterDurationHasBeenSet",value:function(e){var t,i=o(e);try{for(i.s();!(t=i.n()).done;){t.value.doCalculationsAfterDurationHasBeenSet()}}catch(n){i.e(n)}finally{i.f()}}}]),e}();function Zo(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var $o={}; /*! JSZip v3.7.1 - A JavaScript class for generating and reading zip files (c) 2009-2016 Stuart Knightley Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/master/LICENSE.markdown. JSZip uses the library pako released under the MIT license : https://github.com/nodeca/pako/blob/master/LICENSE */ !function(e,t){e.exports=function e(t,i,n){function r(a,o){if(!i[a]){if(!t[a]){if(!o&&Zo)return Zo(a);if(s)return s(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var l=i[a]={exports:{}};t[a][0].call(l.exports,(function(e){return r(t[a][1][e]||e)}),l,l.exports,e,t,i,n)}return i[a].exports}for(var s=Zo,a=0;a>2,o=(3&t)<<4|i>>4,u=1>6:64,l=2>4,i=(15&a)<<4|(o=s.indexOf(e.charAt(l++)))>>2,n=(3&o)<<6|(u=s.indexOf(e.charAt(l++))),f[h++]=t,64!==o&&(f[h++]=i),64!==u&&(f[h++]=n);return f}},{"./support":30,"./utils":32}],2:[function(e,t,i){var n=e("./external"),r=e("./stream/DataWorker"),s=e("./stream/Crc32Probe"),a=e("./stream/DataLengthProbe");function o(e,t,i,n,r){this.compressedSize=e,this.uncompressedSize=t,this.crc32=i,this.compression=n,this.compressedContent=r}o.prototype={getContentWorker:function(){var e=new r(n.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new a("data_length")),t=this;return e.on("end",(function(){if(this.streamInfo.data_length!==t.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")})),e},getCompressedWorker:function(){return new r(n.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},o.createWorkerFrom=function(e,t,i){return e.pipe(new s).pipe(new a("uncompressedSize")).pipe(t.compressWorker(i)).pipe(new a("compressedSize")).withStreamInfo("compression",t)},t.exports=o},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,t,i){var n=e("./stream/GenericWorker");i.STORE={magic:"\0\0",compressWorker:function(e){return new n("STORE compression")},uncompressWorker:function(){return new n("STORE decompression")}},i.DEFLATE=e("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,t,i){var n=e("./utils"),r=function(){for(var e,t=[],i=0;i<256;i++){e=i;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[i]=e}return t}();t.exports=function(e,t){return void 0!==e&&e.length?"string"!==n.getTypeOf(e)?function(e,t,i,n){var s=r,a=n+i;e^=-1;for(var o=n;o>>8^s[255&(e^t[o])];return-1^e}(0|t,e,e.length,0):function(e,t,i,n){var s=r,a=n+i;e^=-1;for(var o=n;o>>8^s[255&(e^t.charCodeAt(o))];return-1^e}(0|t,e,e.length,0):0}},{"./utils":32}],5:[function(e,t,i){i.base64=!1,i.binary=!1,i.dir=!1,i.createFolders=!0,i.date=null,i.compression=null,i.compressionOptions=null,i.comment=null,i.unixPermissions=null,i.dosPermissions=null},{}],6:[function(e,t,i){var n=null;n="undefined"!=typeof Promise?Promise:e("lie"),t.exports={Promise:n}},{lie:37}],7:[function(e,t,i){var n="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,r=e("pako"),s=e("./utils"),a=e("./stream/GenericWorker"),o=n?"uint8array":"array";function u(e,t){a.call(this,"FlateWorker/"+e),this._pako=null,this._pakoAction=e,this._pakoOptions=t,this.meta={}}i.magic="\b\0",s.inherits(u,a),u.prototype.processChunk=function(e){this.meta=e.meta,null===this._pako&&this._createPako(),this._pako.push(s.transformTo(o,e.data),!1)},u.prototype.flush=function(){a.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},u.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this._pako=null},u.prototype._createPako=function(){this._pako=new r[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var e=this;this._pako.onData=function(t){e.push({data:t,meta:e.meta})}},i.compressWorker=function(e){return new u("Deflate",e)},i.uncompressWorker=function(){return new u("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,t,i){function n(e,t){var i,n="";for(i=0;i>>=8;return n}function r(e,t,i,r,a,h){var c,f,d=e.file,p=e.compression,v=h!==o.utf8encode,m=s.transformTo("string",h(d.name)),g=s.transformTo("string",o.utf8encode(d.name)),y=d.comment,b=s.transformTo("string",h(y)),S=s.transformTo("string",o.utf8encode(y)),x=g.length!==d.name.length,k=S.length!==y.length,_="",E="",w="",M=d.dir,T=d.date,P={crc32:0,compressedSize:0,uncompressedSize:0};t&&!i||(P.crc32=e.crc32,P.compressedSize=e.compressedSize,P.uncompressedSize=e.uncompressedSize);var L=0;t&&(L|=8),v||!x&&!k||(L|=2048);var C=0,A=0;M&&(C|=16),"UNIX"===a?(A=798,C|=function(e,t){var i=e;return e||(i=t?16893:33204),(65535&i)<<16}(d.unixPermissions,M)):(A=20,C|=function(e){return 63&(e||0)}(d.dosPermissions)),c=T.getUTCHours(),c<<=6,c|=T.getUTCMinutes(),c<<=5,c|=T.getUTCSeconds()/2,f=T.getUTCFullYear()-1980,f<<=4,f|=T.getUTCMonth()+1,f<<=5,f|=T.getUTCDate(),x&&(E=n(1,1)+n(u(m),4)+g,_+="up"+n(E.length,2)+E),k&&(w=n(1,1)+n(u(b),4)+S,_+="uc"+n(w.length,2)+w);var R="";return R+="\n\0",R+=n(L,2),R+=p.magic,R+=n(c,2),R+=n(f,2),R+=n(P.crc32,4),R+=n(P.compressedSize,4),R+=n(P.uncompressedSize,4),R+=n(m.length,2),R+=n(_.length,2),{fileRecord:l.LOCAL_FILE_HEADER+R+m+_,dirRecord:l.CENTRAL_FILE_HEADER+n(A,2)+R+n(b.length,2)+"\0\0\0\0"+n(C,4)+n(r,4)+m+_+b}}var s=e("../utils"),a=e("../stream/GenericWorker"),o=e("../utf8"),u=e("../crc32"),l=e("../signature");function h(e,t,i,n){a.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=t,this.zipPlatform=i,this.encodeFileName=n,this.streamFiles=e,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}s.inherits(h,a),h.prototype.push=function(e){var t=e.meta.percent||0,i=this.entriesCount,n=this._sources.length;this.accumulate?this.contentBuffer.push(e):(this.bytesWritten+=e.data.length,a.prototype.push.call(this,{data:e.data,meta:{currentFile:this.currentFile,percent:i?(t+100*(i-n-1))/i:100}}))},h.prototype.openedSource=function(e){this.currentSourceOffset=this.bytesWritten,this.currentFile=e.file.name;var t=this.streamFiles&&!e.file.dir;if(t){var i=r(e,t,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:i.fileRecord,meta:{percent:0}})}else this.accumulate=!0},h.prototype.closedSource=function(e){this.accumulate=!1;var t=this.streamFiles&&!e.file.dir,i=r(e,t,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(i.dirRecord),t)this.push({data:function(e){return l.DATA_DESCRIPTOR+n(e.crc32,4)+n(e.compressedSize,4)+n(e.uncompressedSize,4)}(e),meta:{percent:100}});else for(this.push({data:i.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},h.prototype.flush=function(){for(var e=this.bytesWritten,t=0;t=this.index;t--)i=(i<<8)+this.byteAt(t);return this.index+=e,i},readString:function(e){return n.transformTo("string",this.readData(e))},readData:function(e){},lastIndexOfSignature:function(e){},readAndCheckSignature:function(e){},readDate:function(){var e=this.readInt(4);return new Date(Date.UTC(1980+(e>>25&127),(e>>21&15)-1,e>>16&31,e>>11&31,e>>5&63,(31&e)<<1))}},t.exports=r},{"../utils":32}],19:[function(e,t,i){var n=e("./Uint8ArrayReader");function r(e){n.call(this,e)}e("../utils").inherits(r,n),r.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=r},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(e,t,i){var n=e("./DataReader");function r(e){n.call(this,e)}e("../utils").inherits(r,n),r.prototype.byteAt=function(e){return this.data.charCodeAt(this.zero+e)},r.prototype.lastIndexOfSignature=function(e){return this.data.lastIndexOf(e)-this.zero},r.prototype.readAndCheckSignature=function(e){return e===this.readData(4)},r.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=r},{"../utils":32,"./DataReader":18}],21:[function(e,t,i){var n=e("./ArrayReader");function r(e){n.call(this,e)}e("../utils").inherits(r,n),r.prototype.readData=function(e){if(this.checkOffset(e),0===e)return new Uint8Array(0);var t=this.data.subarray(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=r},{"../utils":32,"./ArrayReader":17}],22:[function(e,t,i){var n=e("../utils"),r=e("../support"),s=e("./ArrayReader"),a=e("./StringReader"),o=e("./NodeBufferReader"),u=e("./Uint8ArrayReader");t.exports=function(e){var t=n.getTypeOf(e);return n.checkSupport(t),"string"!==t||r.uint8array?"nodebuffer"===t?new o(e):r.uint8array?new u(n.transformTo("uint8array",e)):new s(n.transformTo("array",e)):new a(e)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(e,t,i){i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\b"},{}],24:[function(e,t,i){var n=e("./GenericWorker"),r=e("../utils");function s(e){n.call(this,"ConvertWorker to "+e),this.destType=e}r.inherits(s,n),s.prototype.processChunk=function(e){this.push({data:r.transformTo(this.destType,e.data),meta:e.meta})},t.exports=s},{"../utils":32,"./GenericWorker":28}],25:[function(e,t,i){var n=e("./GenericWorker"),r=e("../crc32");function s(){n.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}e("../utils").inherits(s,n),s.prototype.processChunk=function(e){this.streamInfo.crc32=r(e.data,this.streamInfo.crc32||0),this.push(e)},t.exports=s},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(e,t,i){var n=e("../utils"),r=e("./GenericWorker");function s(e){r.call(this,"DataLengthProbe for "+e),this.propName=e,this.withStreamInfo(e,0)}n.inherits(s,r),s.prototype.processChunk=function(e){if(e){var t=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=t+e.data.length}r.prototype.processChunk.call(this,e)},t.exports=s},{"../utils":32,"./GenericWorker":28}],27:[function(e,t,i){var n=e("../utils"),r=e("./GenericWorker");function s(e){r.call(this,"DataWorker");var t=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,e.then((function(e){t.dataIsReady=!0,t.data=e,t.max=e&&e.length||0,t.type=n.getTypeOf(e),t.isPaused||t._tickAndRepeat()}),(function(e){t.error(e)}))}n.inherits(s,r),s.prototype.cleanUp=function(){r.prototype.cleanUp.call(this),this.data=null},s.prototype.resume=function(){return!!r.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,n.delay(this._tickAndRepeat,[],this)),!0)},s.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(n.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},s.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var e=null,t=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":e=this.data.substring(this.index,t);break;case"uint8array":e=this.data.subarray(this.index,t);break;case"array":case"nodebuffer":e=this.data.slice(this.index,t)}return this.index=t,this.push({data:e,meta:{percent:this.max?this.index/this.max*100:0}})},t.exports=s},{"../utils":32,"./GenericWorker":28}],28:[function(e,t,i){function n(e){this.name=e||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}n.prototype={push:function(e){this.emit("data",e)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(e){this.emit("error",e)}return!0},error:function(e){return!this.isFinished&&(this.isPaused?this.generatedError=e:(this.isFinished=!0,this.emit("error",e),this.previous&&this.previous.error(e),this.cleanUp()),!0)},on:function(e,t){return this._listeners[e].push(t),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(e,t){if(this._listeners[e])for(var i=0;i "+e:e}},t.exports=n},{}],29:[function(e,t,i){var n=e("../utils"),r=e("./ConvertWorker"),s=e("./GenericWorker"),a=e("../base64"),o=e("../support"),u=e("../external"),l=null;if(o.nodestream)try{l=e("../nodejs/NodejsStreamOutputAdapter")}catch(e){}function h(e,t){return new u.Promise((function(i,r){var s=[],o=e._internalType,u=e._outputType,l=e._mimeType;e.on("data",(function(e,i){s.push(e),t&&t(i)})).on("error",(function(e){s=[],r(e)})).on("end",(function(){try{var e=function(e,t,i){switch(e){case"blob":return n.newBlob(n.transformTo("arraybuffer",t),i);case"base64":return a.encode(t);default:return n.transformTo(e,t)}}(u,function(e,t){var i,n=0,r=null,s=0;for(i=0;i>>6:(i<65536?t[a++]=224|i>>>12:(t[a++]=240|i>>>18,t[a++]=128|i>>>12&63),t[a++]=128|i>>>6&63),t[a++]=128|63&i);return t}(e)},i.utf8decode=function(e){return r.nodebuffer?n.transformTo("nodebuffer",e).toString("utf-8"):function(e){var t,i,r,s,a=e.length,u=new Array(2*a);for(t=i=0;t>10&1023,u[i++]=56320|1023&r)}return u.length!==i&&(u.subarray?u=u.subarray(0,i):u.length=i),n.applyFromCharCode(u)}(e=n.transformTo(r.uint8array?"uint8array":"array",e))},n.inherits(l,a),l.prototype.processChunk=function(e){var t=n.transformTo(r.uint8array?"uint8array":"array",e.data);if(this.leftOver&&this.leftOver.length){if(r.uint8array){var s=t;(t=new Uint8Array(s.length+this.leftOver.length)).set(this.leftOver,0),t.set(s,this.leftOver.length)}else t=this.leftOver.concat(t);this.leftOver=null}var a=function(e,t){var i;for((t=t||e.length)>e.length&&(t=e.length),i=t-1;0<=i&&128==(192&e[i]);)i--;return i<0||0===i?t:i+o[e[i]]>t?i:t}(t),u=t;a!==t.length&&(r.uint8array?(u=t.subarray(0,a),this.leftOver=t.subarray(a,t.length)):(u=t.slice(0,a),this.leftOver=t.slice(a,t.length))),this.push({data:i.utf8decode(u),meta:e.meta})},l.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=l,n.inherits(h,a),h.prototype.processChunk=function(e){this.push({data:i.utf8encode(e.data),meta:e.meta})},i.Utf8EncodeWorker=h},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(e,t,i){var n=e("./support"),r=e("./base64"),s=e("./nodejsUtils"),a=e("set-immediate-shim"),o=e("./external");function u(e){return e}function l(e,t){for(var i=0;i>8;this.dir=!!(16&this.externalFileAttributes),0==e&&(this.dosPermissions=63&this.externalFileAttributes),3==e&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileNameStr.slice(-1)||(this.dir=!0)},parseZIP64ExtraField:function(e){if(this.extraFields[1]){var t=n(this.extraFields[1].value);this.uncompressedSize===r.MAX_VALUE_32BITS&&(this.uncompressedSize=t.readInt(8)),this.compressedSize===r.MAX_VALUE_32BITS&&(this.compressedSize=t.readInt(8)),this.localHeaderOffset===r.MAX_VALUE_32BITS&&(this.localHeaderOffset=t.readInt(8)),this.diskNumberStart===r.MAX_VALUE_32BITS&&(this.diskNumberStart=t.readInt(4))}},readExtraFields:function(e){var t,i,n,r=e.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});e.index+4>>6:(i<65536?t[a++]=224|i>>>12:(t[a++]=240|i>>>18,t[a++]=128|i>>>12&63),t[a++]=128|i>>>6&63),t[a++]=128|63&i);return t},i.buf2binstring=function(e){return u(e,e.length)},i.binstring2buf=function(e){for(var t=new n.Buf8(e.length),i=0,r=t.length;i>10&1023,l[n++]=56320|1023&r)}return u(l,n)},i.utf8border=function(e,t){var i;for((t=t||e.length)>e.length&&(t=e.length),i=t-1;0<=i&&128==(192&e[i]);)i--;return i<0||0===i?t:i+a[e[i]]>t?i:t}},{"./common":41}],43:[function(e,t,i){t.exports=function(e,t,i,n){for(var r=65535&e|0,s=e>>>16&65535|0,a=0;0!==i;){for(i-=a=2e3>>1:e>>>1;t[i]=e}return t}();t.exports=function(e,t,i,r){var s=n,a=r+i;e^=-1;for(var o=r;o>>8^s[255&(e^t[o])];return-1^e}},{}],46:[function(e,t,i){var n,r=e("../utils/common"),s=e("./trees"),a=e("./adler32"),o=e("./crc32"),u=e("./messages"),l=0,h=4,c=0,f=-2,d=-1,p=4,v=2,m=8,g=9,y=286,b=30,S=19,x=2*y+1,k=15,_=3,E=258,w=E+_+1,M=42,T=113,P=1,L=2,C=3,A=4;function R(e,t){return e.msg=u[t],t}function I(e){return(e<<1)-(4e.avail_out&&(i=e.avail_out),0!==i&&(r.arraySet(e.output,t.pending_buf,t.pending_out,i,e.next_out),e.next_out+=i,t.pending_out+=i,e.total_out+=i,e.avail_out-=i,t.pending-=i,0===t.pending&&(t.pending_out=0))}function D(e,t){s._tr_flush_block(e,0<=e.block_start?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,B(e.strm)}function O(e,t){e.pending_buf[e.pending++]=t}function F(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function V(e,t){var i,n,r=e.max_chain_length,s=e.strstart,a=e.prev_length,o=e.nice_match,u=e.strstart>e.w_size-w?e.strstart-(e.w_size-w):0,l=e.window,h=e.w_mask,c=e.prev,f=e.strstart+E,d=l[s+a-1],p=l[s+a];e.prev_length>=e.good_match&&(r>>=2),o>e.lookahead&&(o=e.lookahead);do{if(l[(i=t)+a]===p&&l[i+a-1]===d&&l[i]===l[s]&&l[++i]===l[s+1]){s+=2,i++;do{}while(l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&su&&0!=--r);return a<=e.lookahead?a:e.lookahead}function G(e){var t,i,n,s,u,l,h,c,f,d,p=e.w_size;do{if(s=e.window_size-e.lookahead-e.strstart,e.strstart>=p+(p-w)){for(r.arraySet(e.window,e.window,p,p,0),e.match_start-=p,e.strstart-=p,e.block_start-=p,t=i=e.hash_size;n=e.head[--t],e.head[t]=p<=n?n-p:0,--i;);for(t=i=p;n=e.prev[--t],e.prev[t]=p<=n?n-p:0,--i;);s+=p}if(0===e.strm.avail_in)break;if(l=e.strm,h=e.window,c=e.strstart+e.lookahead,d=void 0,(f=s)<(d=l.avail_in)&&(d=f),i=0===d?0:(l.avail_in-=d,r.arraySet(h,l.input,l.next_in,d,c),1===l.state.wrap?l.adler=a(l.adler,h,d,c):2===l.state.wrap&&(l.adler=o(l.adler,h,d,c)),l.next_in+=d,l.total_in+=d,d),e.lookahead+=i,e.lookahead+e.insert>=_)for(u=e.strstart-e.insert,e.ins_h=e.window[u],e.ins_h=(e.ins_h<=_&&(e.ins_h=(e.ins_h<=_)if(n=s._tr_tally(e,e.strstart-e.match_start,e.match_length-_),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=_){for(e.match_length--;e.strstart++,e.ins_h=(e.ins_h<=_&&(e.ins_h=(e.ins_h<=_&&e.match_length<=e.prev_length){for(r=e.strstart+e.lookahead-_,n=s._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-_),e.lookahead-=e.prev_length-1,e.prev_length-=2;++e.strstart<=r&&(e.ins_h=(e.ins_h<e.pending_buf_size-5&&(i=e.pending_buf_size-5);;){if(e.lookahead<=1){if(G(e),0===e.lookahead&&t===l)return P;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var n=e.block_start+i;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,D(e,!1),0===e.strm.avail_out))return P;if(e.strstart-e.block_start>=e.w_size-w&&(D(e,!1),0===e.strm.avail_out))return P}return e.insert=0,t===h?(D(e,!0),0===e.strm.avail_out?C:A):(e.strstart>e.block_start&&(D(e,!1),e.strm.avail_out),P)})),new z(4,4,8,4,W),new z(4,5,16,8,W),new z(4,6,32,32,W),new z(4,4,16,16,U),new z(8,16,32,32,U),new z(8,16,128,128,U),new z(8,32,128,256,U),new z(32,128,258,1024,U),new z(32,258,258,4096,U)],i.deflateInit=function(e,t){return j(e,t,m,15,8,0)},i.deflateInit2=j,i.deflateReset=Y,i.deflateResetKeep=X,i.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?f:(e.state.gzhead=t,c):f},i.deflate=function(e,t){var i,r,a,u;if(!e||!e.state||5>8&255),O(r,r.gzhead.time>>16&255),O(r,r.gzhead.time>>24&255),O(r,9===r.level?2:2<=r.strategy||r.level<2?4:0),O(r,255&r.gzhead.os),r.gzhead.extra&&r.gzhead.extra.length&&(O(r,255&r.gzhead.extra.length),O(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(e.adler=o(e.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=69):(O(r,0),O(r,0),O(r,0),O(r,0),O(r,0),O(r,9===r.level?2:2<=r.strategy||r.level<2?4:0),O(r,3),r.status=T);else{var d=m+(r.w_bits-8<<4)<<8;d|=(2<=r.strategy||r.level<2?0:r.level<6?1:6===r.level?2:3)<<6,0!==r.strstart&&(d|=32),d+=31-d%31,r.status=T,F(r,d),0!==r.strstart&&(F(r,e.adler>>>16),F(r,65535&e.adler)),e.adler=1}if(69===r.status)if(r.gzhead.extra){for(a=r.pending;r.gzindex<(65535&r.gzhead.extra.length)&&(r.pending!==r.pending_buf_size||(r.gzhead.hcrc&&r.pending>a&&(e.adler=o(e.adler,r.pending_buf,r.pending-a,a)),B(e),a=r.pending,r.pending!==r.pending_buf_size));)O(r,255&r.gzhead.extra[r.gzindex]),r.gzindex++;r.gzhead.hcrc&&r.pending>a&&(e.adler=o(e.adler,r.pending_buf,r.pending-a,a)),r.gzindex===r.gzhead.extra.length&&(r.gzindex=0,r.status=73)}else r.status=73;if(73===r.status)if(r.gzhead.name){a=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>a&&(e.adler=o(e.adler,r.pending_buf,r.pending-a,a)),B(e),a=r.pending,r.pending===r.pending_buf_size)){u=1;break}u=r.gzindexa&&(e.adler=o(e.adler,r.pending_buf,r.pending-a,a)),0===u&&(r.gzindex=0,r.status=91)}else r.status=91;if(91===r.status)if(r.gzhead.comment){a=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>a&&(e.adler=o(e.adler,r.pending_buf,r.pending-a,a)),B(e),a=r.pending,r.pending===r.pending_buf_size)){u=1;break}u=r.gzindexa&&(e.adler=o(e.adler,r.pending_buf,r.pending-a,a)),0===u&&(r.status=103)}else r.status=103;if(103===r.status&&(r.gzhead.hcrc?(r.pending+2>r.pending_buf_size&&B(e),r.pending+2<=r.pending_buf_size&&(O(r,255&e.adler),O(r,e.adler>>8&255),e.adler=0,r.status=T)):r.status=T),0!==r.pending){if(B(e),0===e.avail_out)return r.last_flush=-1,c}else if(0===e.avail_in&&I(t)<=I(i)&&t!==h)return R(e,-5);if(666===r.status&&0!==e.avail_in)return R(e,-5);if(0!==e.avail_in||0!==r.lookahead||t!==l&&666!==r.status){var p=2===r.strategy?function(e,t){for(var i;;){if(0===e.lookahead&&(G(e),0===e.lookahead)){if(t===l)return P;break}if(e.match_length=0,i=s._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,i&&(D(e,!1),0===e.strm.avail_out))return P}return e.insert=0,t===h?(D(e,!0),0===e.strm.avail_out?C:A):e.last_lit&&(D(e,!1),0===e.strm.avail_out)?P:L}(r,t):3===r.strategy?function(e,t){for(var i,n,r,a,o=e.window;;){if(e.lookahead<=E){if(G(e),e.lookahead<=E&&t===l)return P;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=_&&0e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=_?(i=s._tr_tally(e,1,e.match_length-_),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(i=s._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),i&&(D(e,!1),0===e.strm.avail_out))return P}return e.insert=0,t===h?(D(e,!0),0===e.strm.avail_out?C:A):e.last_lit&&(D(e,!1),0===e.strm.avail_out)?P:L}(r,t):n[r.level].func(r,t);if(p!==C&&p!==A||(r.status=666),p===P||p===C)return 0===e.avail_out&&(r.last_flush=-1),c;if(p===L&&(1===t?s._tr_align(r):5!==t&&(s._tr_stored_block(r,0,0,!1),3===t&&(N(r.head),0===r.lookahead&&(r.strstart=0,r.block_start=0,r.insert=0))),B(e),0===e.avail_out))return r.last_flush=-1,c}return t!==h?c:r.wrap<=0?1:(2===r.wrap?(O(r,255&e.adler),O(r,e.adler>>8&255),O(r,e.adler>>16&255),O(r,e.adler>>24&255),O(r,255&e.total_in),O(r,e.total_in>>8&255),O(r,e.total_in>>16&255),O(r,e.total_in>>24&255)):(F(r,e.adler>>>16),F(r,65535&e.adler)),B(e),0=i.w_size&&(0===o&&(N(i.head),i.strstart=0,i.block_start=0,i.insert=0),d=new r.Buf8(i.w_size),r.arraySet(d,t,p-i.w_size,i.w_size,0),t=d,p=i.w_size),u=e.avail_in,l=e.next_in,h=e.input,e.avail_in=p,e.next_in=0,e.input=t,G(i);i.lookahead>=_;){for(n=i.strstart,s=i.lookahead-(_-1);i.ins_h=(i.ins_h<>>=S=b>>>24,p-=S,0==(S=b>>>16&255))M[s++]=65535&b;else{if(!(16&S)){if(0==(64&S)){b=v[(65535&b)+(d&(1<>>=S,p-=S),p<15&&(d+=w[n++]<>>=S=b>>>24,p-=S,!(16&(S=b>>>16&255))){if(0==(64&S)){b=m[(65535&b)+(d&(1<>>=S,p-=S,(S=s-a)>3,d&=(1<<(p-=x<<3))-1,e.next_in=n,e.next_out=s,e.avail_in=n>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function m(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new n.Buf16(320),this.work=new n.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function g(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=f,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new n.Buf32(d),t.distcode=t.distdyn=new n.Buf32(p),t.sane=1,t.back=-1,h):c}function y(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,g(e)):c}function b(e,t){var i,n;return e&&e.state?(n=e.state,t<0?(i=0,t=-t):(i=1+(t>>4),t<48&&(t&=15)),t&&(t<8||15=a.wsize?(n.arraySet(a.window,t,i-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):(r<(s=a.wsize-a.wnext)&&(s=r),n.arraySet(a.window,t,i-r,s,a.wnext),(r-=s)?(n.arraySet(a.window,t,i-r,r,0),a.wnext=r,a.whave=a.wsize):(a.wnext+=s,a.wnext===a.wsize&&(a.wnext=0),a.whave>>8&255,i.check=s(i.check,G,2,0),x=S=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&S)<<8)+(S>>8))%31){e.msg="incorrect header check",i.mode=30;break}if(8!=(15&S)){e.msg="unknown compression method",i.mode=30;break}if(x-=4,B=8+(15&(S>>>=4)),0===i.wbits)i.wbits=B;else if(B>i.wbits){e.msg="invalid window size",i.mode=30;break}i.dmax=1<>8&1),512&i.flags&&(G[0]=255&S,G[1]=S>>>8&255,i.check=s(i.check,G,2,0)),x=S=0,i.mode=3;case 3:for(;x<32;){if(0===y)break e;y--,S+=d[m++]<>>8&255,G[2]=S>>>16&255,G[3]=S>>>24&255,i.check=s(i.check,G,4,0)),x=S=0,i.mode=4;case 4:for(;x<16;){if(0===y)break e;y--,S+=d[m++]<>8),512&i.flags&&(G[0]=255&S,G[1]=S>>>8&255,i.check=s(i.check,G,2,0)),x=S=0,i.mode=5;case 5:if(1024&i.flags){for(;x<16;){if(0===y)break e;y--,S+=d[m++]<>>8&255,i.check=s(i.check,G,2,0)),x=S=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&(y<(M=i.length)&&(M=y),M&&(i.head&&(B=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Array(i.head.extra_len)),n.arraySet(i.head.extra,d,m,M,B)),512&i.flags&&(i.check=s(i.check,d,M,m)),y-=M,m+=M,i.length-=M),i.length))break e;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===y)break e;for(M=0;B=d[m+M++],i.head&&B&&i.length<65536&&(i.head.name+=String.fromCharCode(B)),B&&M>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=12;break;case 10:for(;x<32;){if(0===y)break e;y--,S+=d[m++]<>>=7&x,x-=7&x,i.mode=27;break}for(;x<3;){if(0===y)break e;y--,S+=d[m++]<>>=1)){case 0:i.mode=14;break;case 1:if(E(i),i.mode=20,6!==t)break;S>>>=2,x-=2;break e;case 2:i.mode=17;break;case 3:e.msg="invalid block type",i.mode=30}S>>>=2,x-=2;break;case 14:for(S>>>=7&x,x-=7&x;x<32;){if(0===y)break e;y--,S+=d[m++]<>>16^65535)){e.msg="invalid stored block lengths",i.mode=30;break}if(i.length=65535&S,x=S=0,i.mode=15,6===t)break e;case 15:i.mode=16;case 16:if(M=i.length){if(y>>=5,x-=5,i.ndist=1+(31&S),S>>>=5,x-=5,i.ncode=4+(15&S),S>>>=4,x-=4,286>>=3,x-=3}for(;i.have<19;)i.lens[W[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,O={bits:i.lenbits},D=o(0,i.lens,0,19,i.lencode,0,i.work,O),i.lenbits=O.bits,D){e.msg="invalid code lengths set",i.mode=30;break}i.have=0,i.mode=19;case 19:for(;i.have>>16&255,A=65535&V,!((L=V>>>24)<=x);){if(0===y)break e;y--,S+=d[m++]<>>=L,x-=L,i.lens[i.have++]=A;else{if(16===A){for(F=L+2;x>>=L,x-=L,0===i.have){e.msg="invalid bit length repeat",i.mode=30;break}B=i.lens[i.have-1],M=3+(3&S),S>>>=2,x-=2}else if(17===A){for(F=L+3;x>>=L)),S>>>=3,x-=3}else{for(F=L+7;x>>=L)),S>>>=7,x-=7}if(i.have+M>i.nlen+i.ndist){e.msg="invalid bit length repeat",i.mode=30;break}for(;M--;)i.lens[i.have++]=B}}if(30===i.mode)break;if(0===i.lens[256]){e.msg="invalid code -- missing end-of-block",i.mode=30;break}if(i.lenbits=9,O={bits:i.lenbits},D=o(u,i.lens,0,i.nlen,i.lencode,0,i.work,O),i.lenbits=O.bits,D){e.msg="invalid literal/lengths set",i.mode=30;break}if(i.distbits=6,i.distcode=i.distdyn,O={bits:i.distbits},D=o(l,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,O),i.distbits=O.bits,D){e.msg="invalid distances set",i.mode=30;break}if(i.mode=20,6===t)break e;case 20:i.mode=21;case 21:if(6<=y&&258<=b){e.next_out=g,e.avail_out=b,e.next_in=m,e.avail_in=y,i.hold=S,i.bits=x,a(e,_),g=e.next_out,p=e.output,b=e.avail_out,m=e.next_in,d=e.input,y=e.avail_in,S=i.hold,x=i.bits,12===i.mode&&(i.back=-1);break}for(i.back=0;C=(V=i.lencode[S&(1<>>16&255,A=65535&V,!((L=V>>>24)<=x);){if(0===y)break e;y--,S+=d[m++]<>R)])>>>16&255,A=65535&V,!(R+(L=V>>>24)<=x);){if(0===y)break e;y--,S+=d[m++]<>>=R,x-=R,i.back+=R}if(S>>>=L,x-=L,i.back+=L,i.length=A,0===C){i.mode=26;break}if(32&C){i.back=-1,i.mode=12;break}if(64&C){e.msg="invalid literal/length code",i.mode=30;break}i.extra=15&C,i.mode=22;case 22:if(i.extra){for(F=i.extra;x>>=i.extra,x-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;C=(V=i.distcode[S&(1<>>16&255,A=65535&V,!((L=V>>>24)<=x);){if(0===y)break e;y--,S+=d[m++]<>R)])>>>16&255,A=65535&V,!(R+(L=V>>>24)<=x);){if(0===y)break e;y--,S+=d[m++]<>>=R,x-=R,i.back+=R}if(S>>>=L,x-=L,i.back+=L,64&C){e.msg="invalid distance code",i.mode=30;break}i.offset=A,i.extra=15&C,i.mode=24;case 24:if(i.extra){for(F=i.extra;x>>=i.extra,x-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg="invalid distance too far back",i.mode=30;break}i.mode=25;case 25:if(0===b)break e;if(M=_-b,i.offset>M){if((M=i.offset-M)>i.whave&&i.sane){e.msg="invalid distance too far back",i.mode=30;break}T=M>i.wnext?(M-=i.wnext,i.wsize-M):i.wnext-M,M>i.length&&(M=i.length),P=i.window}else P=p,T=g-i.offset,M=i.length;for(by?(S=O[F+c[E]],I[N+c[E]]):(S=96,0),d=1<<_-L,w=p=1<>L)+(p-=d)]=b<<24|S<<16|x|0,0!==p;);for(d=1<<_-1;R&d;)d>>=1;if(0!==d?(R&=d-1,R+=d):R=0,E++,0==--B[_]){if(_===M)break;_=t[i+c[E]]}if(T<_&&(R&m)!==v){for(0===L&&(L=T),g+=w,C=1<<(P=_-L);P+L>>7)]}function O(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function F(e,t,i){e.bi_valid>v-i?(e.bi_buf|=t<>v-e.bi_valid,e.bi_valid+=i-v):(e.bi_buf|=t<>>=1,i<<=1,0<--t;);return i>>>1}function W(e,t,i){var n,r,s=new Array(p+1),a=0;for(n=1;n<=p;n++)s[n]=a=a+i[n-1]<<1;for(r=0;r<=t;r++){var o=e[2*r+1];0!==o&&(e[2*r]=G(s[o]++,o))}}function U(e){var t;for(t=0;t>1;1<=i;i--)X(e,s,i);for(r=u;i=e.heap[1],e.heap[1]=e.heap[e.heap_len--],X(e,s,1),n=e.heap[1],e.heap[--e.heap_max]=i,e.heap[--e.heap_max]=n,s[2*r]=s[2*i]+s[2*n],e.depth[r]=(e.depth[i]>=e.depth[n]?e.depth[i]:e.depth[n])+1,s[2*i+1]=s[2*n+1]=r,e.heap[1]=r++,X(e,s,1),2<=e.heap_len;);e.heap[--e.heap_max]=e.heap[1],function(e,t){var i,n,r,s,a,o,u=t.dyn_tree,l=t.max_code,h=t.stat_desc.static_tree,c=t.stat_desc.has_stree,f=t.stat_desc.extra_bits,v=t.stat_desc.extra_base,m=t.stat_desc.max_length,g=0;for(s=0;s<=p;s++)e.bl_count[s]=0;for(u[2*e.heap[e.heap_max]+1]=0,i=e.heap_max+1;i>=7;n>>=1)if(1&i&&0!==e.dyn_ltree[2*t])return r;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return s;for(t=32;t>>3,(o=e.static_len+3+7>>>3)<=a&&(a=o)):a=o=i+5,i+4<=a&&-1!==t?Z(e,t,i,n):4===e.strategy||o===a?(F(e,2+(n?1:0),3),Y(e,w,M)):(F(e,4+(n?1:0),3),function(e,t,i,n){var r;for(F(e,t-257,5),F(e,i-1,5),F(e,n-4,4),r=0;r>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&i,e.last_lit++,0===t?e.dyn_ltree[2*i]++:(e.matches++,t--,e.dyn_ltree[2*(P[i]+l+1)]++,e.dyn_dtree[2*D(t)]++),e.last_lit===e.lit_bufsize-1},i._tr_align=function(e){F(e,2,3),V(e,g,w),function(e){16===e.bi_valid?(O(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):8<=e.bi_valid&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)}},{"../utils/common":41}],53:[function(e,t,i){t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(e,t,i){t.exports="function"==typeof setImmediate?setImmediate:function(){var e=[].slice.apply(arguments);e.splice(1,0,0),setTimeout.apply(null,e)}},{}]},{},[10])(10)}({get exports(){return $o},set exports(e){$o=e}});var Qo=function(){function e(){k(this,e)}return E(e,null,[{key:"MXLtoIXmlElement",value:function(e){var t=new $o;return t.loadAsync(e).then((function(e){return t.file("META-INF/container.xml").async("text")}),(function(e){throw e})).then((function(e){var i=(new DOMParser).parseFromString(e,"text/xml").getElementsByTagName("rootfile")[0].getAttribute("full-path");return t.file(i).async("text")}),(function(e){throw e})).then((function(e){var t=(new DOMParser).parseFromString(e,"text/xml"),i=new Sa(t.documentElement);return Promise.resolve(i)}),(function(e){throw e})).then((function(e){return e}),(function(e){throw new Error("extractSheetFromMxl: "+e.message)}))}},{key:"MXLtoXMLstring",value:function(e){var t=new $o;return t.loadAsync(e).then((function(e){return t.file("META-INF/container.xml").async("text")}),(function(e){throw L.error(e),e})).then((function(e){var i=(new DOMParser).parseFromString(e,"text/xml").getElementsByTagName("rootfile")[0].getAttribute("full-path");return t.file(i).async("text")}),(function(e){throw e}))}}]),e}(),eu=function(){function e(){k(this,e)}return E(e,[{key:"calculate",value:function(e){for(var t=new ht(e);!t.EndReached;){var i,n=t.CurrentEnrolledTimestamp,r=o(t.CurrentAudibleVoiceEntries());try{for(r.s();!(i=r.n()).done;){var s=i.value;this.handleVoiceEntry(e,s,n)}}catch(a){r.e(a)}finally{r.f()}t.moveToNext()}}},{key:"handleVoiceEntry",value:function(t,i,n){if(!i.IsGrace){var r,s=i.ParentVoice;t.PlaybackDataDict.containsKey(s)?r=t.PlaybackDataDict.getValue(s):(r=[],t.PlaybackDataDict.setValue(s,r));var a,u=o(i.PlaybackEntries);try{for(u.s();!(a=u.n()).done;){var l=a.value;if(l.HasNotes){var h,c=o(l.Notes);try{for(c.s();!(h=c.n()).done;){h.value.setLength()}}catch(p){c.e(p)}finally{c.f()}var d=f.plus(n,l.TimestampShift);e.addEntrySorted(r,l,d)}}}catch(p){u.e(p)}finally{u.f()}}}}],[{key:"addEntrySorted",value:function(e,t,i){if(0===e.length)e.push({enrolledTimestamp:i,playbackEntry:t});else for(var n=e.length-1;n>=0;n--){var r=e[n];if(i.RealValue>r.enrolledTimestamp.RealValue){if(n===e.length-1){e.push({enrolledTimestamp:i,playbackEntry:t});break}e.splice(n+1,0,{enrolledTimestamp:i,playbackEntry:t});break}}}}]),e}(),tu=function(){function e(t,i,n,r){k(this,e),this.psi=new yt(void 0),this.displaySizeInPixel=t,this.RelativeDisplaySize=i,this.RelativeDisplayPosition=n,this.WidthInUnits=r}return E(e,[{key:"UpperLeftPositionInUnits",get:function(){return this.psi.AbsolutePosition},set:function(e){this.psi.AbsolutePosition=e}},{key:"DisplaySizeInPixel",get:function(){return this.displaySizeInPixel},set:function(e){this.displaySizeInPixel=e,this.regionSizeInPixel=new dt(this.displaySizeInPixel.width*this.relativeRegionSize.width,this.displaySizeInPixel.height*this.relativeRegionSize.height),this.recalculateDependentVariables()}},{key:"RelativeDisplaySize",get:function(){return this.relativeRegionSize},set:function(e){this.relativeRegionSize=e,this.regionSizeInPixel=new dt(this.displaySizeInPixel.width*this.relativeRegionSize.width,this.displaySizeInPixel.height*this.relativeRegionSize.height),this.recalculateDependentVariables()}},{key:"RegionSizeInPixel",get:function(){return this.regionSizeInPixel}},{key:"WidthInUnits",get:function(){return this.psi.BorderRight},set:function(e){this.psi.BorderRight=e,this.recalculateDependentVariables()}},{key:"ViewRegionInUnits",get:function(){return new dt(this.psi.BorderRight,this.psi.BorderBottom)}},{key:"isVisible",value:function(e,t){var i=this.psi.collisionDetection(e);return this.psi.liesInsideBorders(e),i}},{key:"isInsideDisplayArea",value:function(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}},{key:"transformToUnitCoordinates",value:function(e){return new ft(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))}},{key:"transformLengthXToUnitCoordinates",value:function(e){return e/this.horizontalUnitToPixelRatio}},{key:"transformLengthYToUnitCoordinates",value:function(e){return e/this.verticalUnitToPixelRatio}},{key:"recalculateDependentVariables",value:function(){var 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}}],[{key:"createWithRelativeDefaults",value:function(t,i){return new e(t,new dt(1,1),new ft(0,0),i)}},{key:"createWithDefaults",value:function(){return new e(new dt(1,1),new dt(1,1),new ft(0,0),1)}}]),e}(),iu=function(){function e(t){k(this,e),this.aspectRatio=1,this.zoomViews=[],this.mouseZoomMode=!1,this.autoScrollY=!0,this.displayInteractionManager=t,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}return E(e,[{key:"positionTouched",value:function(e,t){if(this.convertToUnitsReady()){var i=this.getPositionInUnits(e,t);this.unitPosTouched(i,e,t)}}},{key:"TouchActive",get:function(){return this.displayInteractionManager.TouchActive}},{key:"TouchMoving",get:function(){return this.displayInteractionManager.TouchMoving}},{key:"positionDoubleTouched",value:function(e,t){if(this.convertToUnitsReady()){var i=this.getPositionInUnits(e,t);this.unitPosDoubleTouched(i,e,t)}}},{key:"UsesManuallyControlledZoomMode",get:function(){return this.usesManuallyControlledZoomMode},set:function(e){this.usesManuallyControlledZoomMode=e}},{key:"mouseDown",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(this.convertToUnitsReady()){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;var n=this.getPositionInUnits(e,t);this.unitPosTouchDown(n,e,t),this.usesManuallyControlledZoomMode||(this.mouseZoomMode=!!i)}}},{key:"mouseUp",value:function(e,t){var i=this.getPositionInUnits(e,t);this.unitPosTouchUp(i,e,t)}},{key:"mouseMove",value:function(e,t,i,n){this.mouseZoomMode?(Math.abs(i-0)>1e-8&&(this.RangeX=Math.abs(this.lastRangeX/(1+i))),!this.lockRanges&&Math.abs(n-0)>1e-8&&(this.RangeY=Math.abs(this.lastRangeY/(1-n)))):(Math.abs(i-0)>1e-8&&(this.OffsetX=this.lastOffsetX-i*this.RangeX),Math.abs(n-0)>1e-8&&(this.OffsetY=this.lastOffsetY-n*this.RangeY));var r=this.getPositionInUnits(e,t);this.unitPosMove(r,e,t)}},{key:"zoom",value:function(e){this.RangeX=Math.abs(this.lastRangeX/e)}},{key:"addZoomView",value:function(e){this.zoomViews.push(e)}},{key:"OffsetX",get:function(){return this.offsetX},set:function(e){this.offsetX=Math.min(this.offsetXMax,Math.max(this.offsetXMin,e));var t,i=o(this.zoomViews);try{for(i.s();!(t=i.n()).done;){t.value.viewportXChanged(this.offsetX,this.RangeX)}}catch(n){i.e(n)}finally{i.f()}}},{key:"OffsetY",get:function(){return this.offsetY},set:function(e){this.offsetY=e,this.offsetY>this.offsetYMax?this.offsetY=this.offsetYMax:this.offsetYthis.offsetYMax&&this.setYOffset(this.offsetYMax,!0)}}},{key:"horizontalViewportChanged",value:function(e,t){this.mainViewingRegion.WidthInUnits!==t&&(this.mainViewingRegion.WidthInUnits=t)}},{key:"verticalViewportChanged",value:function(e,t){this.mainViewingRegion.UpperLeftPositionInUnits=new ft(this.mainViewingRegion.UpperLeftPositionInUnits.x,e)}},{key:"unlockFromCursorIfNecessary",value:function(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))}},{key:"getPositionInUnits",value:function(e,t){return this.mainViewingRegion.transformToUnitCoordinates(new ft(e,t))}},{key:"handleUserDisplayInteraction",value:function(e,t,i){var r=this;switch(i){case nu.TouchDown:case nu.SingleTouch:case nu.DoubleTouch:var s=this.graphicalMusicSheet.GetNearestVoiceEntry(t);if(s){var a=new CustomEvent("note-click",{detail:n(n({},s),{},{setAvtivePlay:function(){if(void 0!==s.parentStaffEntry.parentVerticalContainer){var e,t,i=s.parentStaffEntry.parentVerticalContainer.AbsoluteTimestamp;if(r.setStartPosition(i),void 0!==(null===(e=s.notes[0])||void 0===e?void 0:e.sourceNote.Pitch))console.log("playback clicked note",s.parentVoiceEntry),null===(t=r.PlaybackManager)||void 0===t||t.playVoiceEntry(s.parentVoiceEntry)}}})});window.dispatchEvent(a)}case nu.TouchUp:case nu.TouchDown:case nu.Move:var u,l=o(this.listeners);try{for(l.s();!(u=l.n()).done;){u.value.userDisplayInteraction(e,t,i)}}catch(h){l.e(h)}finally{l.f()}break;default:throw new Error("type")}}},{key:"setStartPosition",value:function(e){var t;void 0!==this.graphicalMusicSheet&&(this.graphicalMusicSheet.ParentMusicSheet.SelectionStart=e,null===(t=this.PlaybackManager)||void 0===t||t.reset())}},{key:"GraphicalMusicSheet",get:function(){return this.graphicalMusicSheet}}]),r}(iu)),au=function(e){c(i,e);var t=d(i);function i(e){var n;return k(this,i),(n=t.call(this)).fullOffsetLeft=0,n.fullOffsetTop=0,n.fullScrollTop=0,n.fullScrollLeft=0,n.parentScrollMap=new Map,n.scrollCallbackMap=new Map,n.timeout=void 0,n.resizeObserver=void 0,n.EventCallbackMap=new Xe,n.DOUBLE_CLICK_WINDOW=200,n.lastClick=0,n.osmdSheetMusicContainer=e,n.listenForInteractions(),n}return E(i,[{key:"FullOffsetTop",get:function(){return this.fullOffsetTop}},{key:"FullScrollTop",get:function(){return this.fullScrollTop}},{key:"FullOffsetLeft",get:function(){return this.fullOffsetLeft}},{key:"FullScrollLeft",get:function(){return this.fullScrollLeft}},{key:"registerScrollOffsets",value:function(){var e=this.osmdSheetMusicContainer;this.fullScrollTop=0,this.fullScrollLeft=0;for(var t=this;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){var i=function(e){var i=t.parentScrollMap.get(this),n=i[0],r=i[1];t.fullScrollTop=t.fullScrollTop-n+this.scrollTop,t.fullScrollLeft=t.fullScrollLeft-r+this.scrollLeft,t.parentScrollMap.set(this,[this.scrollTop,this.scrollLeft])};this.scrollCallbackMap.set(e,i),e.addEventListener("scroll",i)}e=e.parentElement}}},{key:"deregisterScrollOffsets",value:function(){var e,t=o(this.scrollCallbackMap.keys());try{for(t.s();!(e=t.n()).done;){var i=e.value;i.removeEventListener("scroll",this.scrollCallbackMap.get(i))}}catch(n){t.e(n)}finally{t.f()}this.scrollCallbackMap.clear()}},{key:"initialize",value:function(){this.fullOffsetLeft=0,this.fullOffsetTop=0;var e=this.osmdSheetMusicContainer,t=[],n=this;for(window.ResizeObserver&&(this.resizeObserver=new ResizeObserver((function(e){i.resizeCallback(e,n)})));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=function(){n.resizeObserver.disconnect(),n.resizeObserver=void 0};else{var r=function(){i.resizeCallback(t,n)};window.addEventListener("resize",r),this.disposeResizeListener=function(){window.removeEventListener("resize",r),r=void 0}}n.registerScrollOffsets()}},{key:"dispose",value:function(){this.disposeResizeListener();var e,t=o(this.EventCallbackMap.keys());try{for(t.s();!(e=t.n()).done;){var i=e.value,n=this.EventCallbackMap.getValue(i);n[0].removeEventListener(i,n[1])}}catch(r){t.e(r)}finally{t.f()}this.EventCallbackMap.clear(),this.deregisterScrollOffsets(),this.scrollCallbackMap.clear(),this.parentScrollMap.clear()}},{key:"isTouch",value:function(){if("ontouchstart"in window||window.DocumentTouch)return!0;if(!window.matchMedia)return!1;var e=["(",["-webkit-","-moz-","-o-","-ms-"].join("touch-enabled),("),"heartz",")"].join("");return window.matchMedia(e).matches}},{key:"downEventName",get:function(){return this.isTouch()?"touchstart":"mousedown"}},{key:"moveEventName",get:function(){return this.isTouch()?"touchmove":"mousemove"}},{key:"listenForInteractions",value:function(){var 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])}},{key:"downEventListener",value:function(e){var t=(new Date).getTime(),i=t-this.lastClick;clearTimeout(this.clickTimeout);var n=0,r=0;this.isTouch()&&e instanceof TouchEvent?(n=e.touches[0].pageX,r=e.touches[0].pageY):e instanceof MouseEvent&&(n=e.pageX,r=e.pageY);var s=this.getOffsetCoordinates(n,r);if(i0)this.doubleClick(s.x,s.y);else{var a=this;this.clickTimeout=setTimeout((function(){clearTimeout(this.clickTimeout),a.isTouch()?a.touchDown(s.x,s.y,void 0):a.click(s.x,s.y)}),this.DOUBLE_CLICK_WINDOW)}this.lastClick=t}},{key:"moveEventListener",value:function(e){var t=0,i=0;if(this.isTouch()&&e instanceof TouchEvent){var n,r,s=void 0;e.touches&&e.touches.length>0?s=e.touches[0]:e.changedTouches&&e.changedTouches.length>0&&(s=e.changedTouches[0]),t=null===(n=s)||void 0===n?void 0:n.clientX,i=null===(r=s)||void 0===r?void 0:r.clientY}else e instanceof MouseEvent&&(t=e.clientX,i=e.clientY);var a=this.getOffsetCoordinates(t,i);this.move(a.x,a.y)}},{key:"touchEndEventListener",value:function(e){var t,i,n=void 0;e.touches&&e.touches.length>0?n=e.touches[0]:e.changedTouches&&e.changedTouches.length>0&&(n=e.changedTouches[0]);var r=this.getOffsetCoordinates(null===(t=n)||void 0===t?void 0:t.pageX,null===(i=n)||void 0===i?void 0:i.pageY);this.touchUp(r.x,r.y)}},{key:"resizeEventListener",value:function(){this.displaySizeChanged(this.osmdSheetMusicContainer.clientWidth,this.osmdSheetMusicContainer.clientHeight)}},{key:"getOffsetCoordinates",value:function(e,t){var i=e-this.fullOffsetLeft+this.fullScrollLeft,n=t-this.fullOffsetTop+this.fullScrollTop;return new ft(i,n)}}],[{key:"resizeCallback",value:function(e,t){clearTimeout(t.timeout),t.timeout=setTimeout((function(){t.fullOffsetLeft=0,t.fullOffsetTop=0;for(var e=t.osmdSheetMusicContainer;e;)t.fullOffsetLeft+=e.offsetLeft,t.fullOffsetTop+=e.offsetTop,e=e.offsetParent;t.resizeEventListener(),t.deregisterScrollOffsets(),t.registerScrollOffsets()}),500)}}]),i}(function(){function e(){k(this,e),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}return E(e,[{key:"addListener",value:function(e){this.listeners.push(e)}},{key:"ZoomGestureActive",get:function(){return this.zoomGestureActive}},{key:"WasZoomGestureActive",get:function(){return this.interactionWasZoomGesture}},{key:"displaySizeChanged",value:function(e,t){this.displayWidth=e,this.displayHeight=t;var i,n=o(this.listeners);try{for(n.s();!(i=n.n()).done;){i.value.displaySizeChanged(this.displayWidth,this.displayHeight)}}catch(r){n.e(r)}finally{n.f()}}},{key:"Dispose",value:function(){this.dispose()}},{key:"Initialize",value:function(){this.initialize()}},{key:"DisplayDpi",get:function(){return this.displayDpi}},{key:"TouchActive",get:function(){return this.touchActive}},{key:"TouchMoving",get:function(){return this.touchMoving}},{key:"touchDown",value:function(e,t,i){this.interactionWasZoomGesture=!1;var n=e/this.displayWidth,r=t/this.displayHeight;this.lastRelPosX=n,this.lastRelPosY=r,this.lastPixelX=e,this.lastPixelY=t,this.touchActive=!0,this.touchMoving=!1,this.touchCount=Math.min(this.touchCount+1,this.maxNumerOfFingers);var s,a=o(this.listeners);try{for(a.s();!(s=a.n()).done;){s.value.mouseDown(n,r,!i)}}catch(u){a.e(u)}finally{a.f()}}},{key:"move",value:function(e,t){if(this.touchActive&&!this.zoomGestureActive){var i=e/this.displayWidth,n=t/this.displayHeight,r=i-this.lastRelPosX,s=n-this.lastRelPosY;this.touchMoving=!0;var a,u=o(this.listeners);try{for(u.s();!(a=u.n()).done;){a.value.mouseMove(i,n,r,s)}}catch(l){u.e(l)}finally{u.f()}}}},{key:"zoomGestureStarted",value:function(){this.zoomGestureActive=!0}},{key:"zoomGestureCompleted",value:function(){this.zoomGestureActive=!1,this.interactionWasZoomGesture=!0}},{key:"zoomGestureMove",value:function(e){this.zoomGestureActive&&this.listeners.forEach((function(t){t.zoom(e)}))}},{key:"touchUp",value:function(e,t){this.touchActive=!1,this.touchMoving=!1,this.touchCount=Math.max(0,this.touchCount-1);var i,n=e/this.displayWidth,r=t/this.displayHeight,s=o(this.listeners);try{for(s.s();!(i=s.n()).done;){i.value.mouseUp(n,r)}}catch(a){s.e(a)}finally{s.f()}}},{key:"click",value:function(e,t){if(!this.mouseDidMove(this.lastPixelX,e,this.lastPixelY,t)&&!this.ZoomGestureActive){var i,n=e/this.displayWidth,r=t/this.displayHeight,s=o(this.listeners);try{for(s.s();!(i=s.n()).done;){i.value.positionTouched(n,r)}}catch(a){s.e(a)}finally{s.f()}}}},{key:"doubleClick",value:function(e,t){if(!this.mouseDidMove(this.lastPixelX,e,this.lastPixelY,t)&&!this.ZoomGestureActive){var i,n=e/this.displayWidth,r=t/this.displayHeight,s=o(this.listeners);try{for(s.s();!(i=s.n()).done;){i.value.positionDoubleTouched(n,r)}}catch(a){s.e(a)}finally{s.f()}}}},{key:"mouseDidMove",value:function(e,t,i,n){var r=Math.abs(e-t)/this.displayDpi,s=Math.abs(i-n)/this.displayDpi;return r>this.movementThreshInch||s>this.movementThreshInch}}]),e}()),ou=function(){function e(){k(this,e)}return E(e,[{key:"calculate",value:function(t){e.fillDynamicExpressions(t)}}],[{key:"fillDynamicsList",value:function(e,t,i){for(var n=0;n=0&&i[l].push(new at(a.InstantaneousDynamic,l))}if(void 0!==a.StartingContinuousDynamic){i[n].push(new at(a.StartingContinuousDynamic,a.StaffNumber));var h=this.getOtherStaffIndexIfLinkedStavesAreDetected(e,n,a.StartingContinuousDynamic.Placement);h>=0&&i[h].push(new at(a.StartingContinuousDynamic,h))}}}}},{key:"getOtherStaffIndexIfLinkedStavesAreDetected",value:function(e,t,i){var n=e.getStaffFromIndex(t),r=n.ParentInstrument.Staves.indexOf(n),s=n.ParentInstrument.Staves.length;return s>1&&0===r&&i===g.Below?t+1:s>1&&1===r&&i===g.Above?t-1:-1}},{key:"fillDynamicExpressions",value:function(t){for(var i=t.DynListStaves,n=t.getCompleteNumberOfStaves(),r=t.TimestampSortedDynamicExpressionsList,s=0;s1&&void 0!==arguments[1]?arguments[1]:ba.OSMDOptionsStandard(),n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new ca;if(k(this,e),this.version="1.4.5-audio-extended",this.cursorsOptions=[],this.cursors=[],this.zoom=1,this.zoomUpdated=!1,this.loadUrlTimeout=5e3,this.rules=n,"string"==typeof t?this.container=document.getElementById(t):t&&"appendChild"in t&&(this.container=t),!this.container)throw new Error("Please pass a valid div container to OpenSheetMusicDisplay");void 0===i.autoResize&&(i.autoResize=!0),this.backendType=ya.SVG,this.setOptions(i),this.interactionManager=new au(this.container),this.renderingManager=new su(this.interactionManager,this.rules)}return E(e,[{key:"cursor",get:function(){return this.cursors[0]}},{key:"RenderingManager",get:function(){return this.renderingManager}},{key:"PlaybackManager",get:function(){var e;return null===(e=this.renderingManager)||void 0===e?void 0:e.PlaybackManager},set:function(e){this.renderingManager&&(this.renderingManager.PlaybackManager=e)}},{key:"isUrl",value:function(e){return e.length<2083}},{key:"isMxl",value:function(e){return"PK"===e.substr(0,4)}},{key:"processMxl",value:function(e,t,i){var n=this;Qo.MXLtoXMLstring(e).then((function(e){t(n.processStringXml(e))}),(function(e){L.error(new Error("[OSMD] Invalid MXL file: "+e)),i(new Error("[OSMD] Invalid MXL file: "+e))}))}},{key:"processStringXml",value:function(e){var t=new DOMParser;if(""===e.substr(0,3))return L.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("this.rules.MaxPageToDrawNumber)break;var a=this.createBackend(this.backendType,s),u=" exceeds CanvasBackend limit of 32767. Cutting off score.";a.getOSMDBackendType()===ya.Canvas&&t>n&&(L.warn("[OSMD] Warning: width of "+t+u),t=n),this.rules.PageFormat&&!this.rules.PageFormat.IsUndefined?e=t/this.rules.PageFormat.aspectRatio:(e=s.PositionAndShape.Size.height,e+=this.rules.PageBottomMargin,e+=this.rules.CompactMode?this.rules.PageTopMarginNarrow:this.rules.PageTopMargin,this.rules.RenderTitle&&(e+=this.rules.TitleTopDistance),e*=10*this.zoom),a.getOSMDBackendType()===ya.Canvas&&e>n&&(L.warn("[OSMD] Warning: height of "+e+u),e=Math.min(e,n)),a.resize(t,e),a.clear(),this.drawer.Backends.push(a),this.graphic.drawer=this.drawer}}catch(l){r.e(l)}finally{r.f()}}},{key:"exportSVG",value:function(){var e,t,i=o(null===(e=this.drawer)||void 0===e?void 0:e.Backends);try{for(i.s();!(t=i.n()).done;){var n=t.value;n instanceof eo&&n.export()}}catch(r){i.e(r)}finally{i.f()}}},{key:"IsReadyToRender",value:function(){return void 0!==this.graphic}},{key:"clear",value:function(){var e;null===(e=this.drawer)||void 0===e||e.clear(),this.reset()}},{key:"dispose",value:function(){this.disposeResizeListener&&this.disposeResizeListener(),this.InteractionManager&&this.InteractionManager.Dispose()}},{key:"setOptions",value:function(e){if(this.rules||(this.rules=new ca),this.drawingParameters||(this.drawingParameters=new va,this.drawingParameters.Rules=this.rules),null!=e){this.OnXMLRead=function(e){return e},e.onXMLRead&&(this.OnXMLRead=e.onXMLRead),e.drawingParameters&&(this.drawingParameters.DrawingParametersEnum=pa[e.drawingParameters.toLowerCase()]);var t=!this.drawer||!this.drawer.Backends||this.drawer.Backends.length<1;if(void 0!==e.backend){var i=ba.BackendTypeFromString(e.backend);t=t||this.backendType!==i,this.backendType=i}this.needBackendUpdate=t,void 0!==e.autoBeam&&(this.rules.AutoBeamNotes=e.autoBeam);var n=e.autoBeamOptions;if(n&&(void 0===n.maintain_stem_directions&&(n.maintain_stem_directions=!1),this.rules.AutoBeamOptions=n,n.groups&&n.groups.length)){var r,s=o(n.groups);try{for(s.s();!(r=s.n()).done;){if(2!==r.value.length)throw new Error("Each fraction in autoBeamOptions.groups must be of length 2, e.g. [3,4] for beaming three fourths")}}catch(a){s.e(a)}finally{s.f()}}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=m.PlacementEnumFromString(e.fingeringPosition)),void 0!==e.fingeringInsideStafflines&&(this.rules.FingeringInsideStafflines=e.fingeringInsideStafflines),void 0!==e.newSystemFromXML&&(this.rules.NewSystemAtXMLNewSystemAttribute=e.newSystemFromXML),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&&(this.rules.MaxMeasureToDrawIndex=e.drawUpToMeasureNumber-1),e.drawFromMeasureNumber&&(this.rules.MinMeasureToDrawIndex=e.drawFromMeasureNumber-1),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.autoGenerateMutipleRestMeasuresFromRestMeasures&&(this.rules.AutoGenerateMutipleRestMeasuresFromRestMeasures=e.autoGenerateMutipleRestMeasuresFromRestMeasures),void 0!==e.cursorsOptions?this.cursorsOptions=e.cursorsOptions:this.cursorsOptions=[{type:0,color:this.EngravingRules.DefaultColorCursor,alpha:.5,follow:!0}]}else L.warn("warning: osmd.setOptions() called without an options parameter, has no effect.\nexample usage: osmd.setOptions({drawCredits: false, drawPartNames: false})")}},{key:"setColoringMode",value:function(e){if(e.coloringMode!==da.XML){var t,i=[Lt.C,Lt.D,Lt.E,Lt.F,Lt.G,Lt.A,Lt.B,-1];if(e.coloringMode===da.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 with 8 strings (C to B, rest note).");var n,r=o(e.coloringSetCustom);try{for(r.s();!(n=r.n()).done;){var s=n.value;if(!/^\#[0-9a-fA-F]{6}$/.test(s))throw new Error("One of the color strings in options.coloringSetCustom was not a valid HTML Hex color:\n"+s)}}catch(c){r.e(c)}finally{r.f()}t=e.coloringSetCustom}else if(e.coloringMode===da.AutoColoring){t=[];for(var a=Object.keys(Ot),u=0;u0&&t>0){var i=new fa(e,t);this.rules.PageFormat=i}}},{key:"DrawSkyLine",get:function(){return this.drawer.skyLineVisible},set:function(e){this.drawSkyLine=e,this.drawer&&(this.drawer.skyLineVisible=e)}},{key:"DrawBottomLine",get:function(){return this.drawer.bottomLineVisible},set:function(e){this.drawBottomLine=e,this.drawer&&(this.drawer.bottomLineVisible=e)}},{key:"DrawBoundingBox",get:function(){return this.drawBoundingBox},set:function(e){this.setDrawBoundingBox(e,!0)}},{key:"setDrawBoundingBox",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.drawBoundingBox=e,this.drawer&&(this.drawer.drawableBoundingBoxElement=e),t&&this.render()}},{key:"AutoResizeEnabled",get:function(){return this.autoResizeEnabled},set:function(e){this.autoResizeEnabled=e}},{key:"Zoom",get:function(){return this.zoom},set:function(e){var t;this.zoom=e,this.zoomUpdated=!0,(null===(t=this.graphic)||void 0===t?void 0:t.GetCalculator)instanceof So&&(this.graphic.GetCalculator.beamsNeedUpdate=this.zoomUpdated)}},{key:"FollowCursor",get:function(){return this.followCursor},set:function(e){this.followCursor=e}},{key:"TransposeCalculator",get:function(){return ra.transposeCalculator},set:function(e){ra.transposeCalculator=e}},{key:"Sheet",get:function(){return this.sheet}},{key:"Drawer",get:function(){return this.drawer}},{key:"GraphicSheet",get:function(){return this.graphic}},{key:"DrawingParameters",get:function(){return this.drawingParameters}},{key:"EngravingRules",get:function(){return this.rules}},{key:"InteractionManager",get:function(){return this.interactionManager}},{key:"Version",get:function(){return this.version}}],[{key:"StringToPageFormat",value:function(t){var i=fa.UndefinedPageFormat;if(t.match("^[0-9]+x[0-9]+$")){var n=t.split("x"),r=Number.parseInt(n[0],10),s=Number.parseInt(n[1],10);r>0&&r<32768&&s>0&&s<32768&&(i=new fa(r,s,"customPageFormat".concat(t)))}return t=(t=(t=t.replace(" ","_")).replace("Landscape","L")).replace("Portrait","P"),e.PageFormatStandards.hasOwnProperty(t)?i=e.PageFormatStandards[t]:i}}]),e}()).PageFormatStandards={A3_L:new fa(420,297,"A3_L"),A3_P:new fa(297,420,"A3_P"),A4_L:new fa(297,210,"A4_L"),A4_P:new fa(210,297,"A4_P"),A5_L:new fa(210,148,"A5_L"),A5_P:new fa(148,210,"A5_P"),A6_L:new fa(148,105,"A6_L"),A6_P:new fa(105,148,"A6_P"),Endless:fa.UndefinedPageFormat,Letter_L:new fa(279.4,215.9,"Letter_L"),Letter_P:new fa(215.9,279.4,"Letter_P")};var uu={},lu={get exports(){return uu},set exports(e){uu=e}},hu={},cu={get exports(){return hu},set exports(e){hu=e}},fu={},du={__esModule:!0};du.extend=yu,du.indexOf=function(e,t){for(var i=0,n=e.length;i":">",'"':""","'":"'","`":"`","=":"="},vu=/[&<>"'`=]/g,mu=/[&<>"'`=]/;function gu(e){return pu[e]}function yu(e){for(var t=1;t0?(n.ids&&(n.ids=[n.name]),e.helpers.each(t,n)):r(this);if(n.data&&n.ids){var a=i.createFrame(n.data);a.contextPath=i.appendContextPath(n.data.contextPath,n.name),n={data:a}}return s(t,n)}))},e.exports=t.default}({get exports(){return Eu},set exports(e){Eu=e}},Eu);var wu={};!function(e,t){t.__esModule=!0;var i,n=du,r=(i=ku)&&i.__esModule?i:{default:i};t.default=function(e){e.registerHelper("each",(function(e,t){if(!t)throw new r.default("Must pass iterator to #each");var i,s=t.fn,a=t.inverse,o=0,l="",c=void 0,f=void 0;function d(t,i,r){c&&(c.key=t,c.index=i,c.first=0===i,c.last=!!r,f&&(c.contextPath=f+t)),l+=s(e[t],{data:c,blockParams:n.blockParams([e[t],t],[f+t,null])})}if(t.data&&t.ids&&(f=n.appendContextPath(t.data.contextPath,t.ids[0])+"."),n.isFunction(e)&&(e=e.call(this)),t.data&&(c=n.createFrame(t.data)),e&&"object"===h(e))if(n.isArray(e))for(var p=e.length;o=0?t:parseInt(e,10)}return e},log:function(e){if(e=n.lookupLevel(e),"undefined"!=typeof console&&n.lookupLevel(n.level)<=e){var t=n.methodMap[e];console[t]||(t="log");for(var i=arguments.length,r=Array(i>1?i-1:0),s=1;s= 2.0.0-beta.1",7:">= 4.0.0 <4.3.0",8:">= 4.3.0"};var rl="[object Object]";function sl(e,t,i){this.helpers=e||{},this.partials=t||{},this.decorators=i||{},el.registerDefaultHelpers(this),tl.registerDefaultDecorators(this)}sl.prototype={constructor:sl,logger:il.default,log:il.default.log,registerHelper:function(e,t){if($u.toString.call(e)===rl){if(t)throw new Qu.default("Arg not supported with multiple helpers");$u.extend(this.helpers,e)}else this.helpers[e]=t},unregisterHelper:function(e){delete this.helpers[e]},registerPartial:function(e,t){if($u.toString.call(e)===rl)$u.extend(this.partials,e);else{if(void 0===t)throw new Qu.default('Attempting to register a partial called "'+e+'" as undefined');this.partials[e]=t}},unregisterPartial:function(e){delete this.partials[e]},registerDecorator:function(e,t){if($u.toString.call(e)===rl){if(t)throw new Qu.default("Arg not supported with multiple decorators");$u.extend(this.decorators,e)}else this.decorators[e]=t},unregisterDecorator:function(e){delete this.decorators[e]},resetLoggedPropertyAccesses:function(){nl.resetLoggedProperties()}};var al=il.default.log;fu.log=al,fu.createFrame=$u.createFrame,fu.logger=il.default;var ol={};!function(e,t){function i(e){this.string=e}t.__esModule=!0,i.prototype.toString=i.prototype.toHTML=function(){return""+this.string},t.default=i,e.exports=t.default}({get exports(){return ol},set exports(e){ol=e}},ol);var ul={},ll={};ll.__esModule=!0,ll.wrapHelper=function(e,t){if("function"!=typeof e)return e;return function(){var i=arguments[arguments.length-1];return arguments[arguments.length-1]=t(i),e.apply(this,arguments)}},ul.__esModule=!0,ul.checkRevision=function(e){var t=e&&e[0]||1,i=fl.COMPILER_REVISION;if(t>=fl.LAST_COMPATIBLE_COMPILER_REVISION&&t<=fl.COMPILER_REVISION)return;if(t2&&y.push("'"+this.terminals_[v]+"'");x=this.lexer.showPosition?"Parse error on line "+(o+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+y.join(", ")+", got '"+(this.terminals_[c]||c)+"'":"Parse error on line "+(o+1)+": Unexpected "+(1==c?"end of input":"'"+(this.terminals_[c]||c)+"'"),this.parseError(x,{text:this.lexer.match,token:this.terminals_[c]||c,line:this.lexer.yylineno,loc:l,expected:y})}if(d[0]instanceof Array&&d.length>1)throw new Error("Parse Error: multiple actions possible at state: "+f+", token: "+c);switch(d[0]){case 1:i.push(c),n.push(this.lexer.yytext),r.push(this.lexer.yylloc),i.push(d[1]),c=null,u=this.lexer.yyleng,a=this.lexer.yytext,o=this.lexer.yylineno,l=this.lexer.yylloc;break;case 2:if(m=this.productions_[d[1]][1],S.$=n[n.length-m],S._$={first_line:r[r.length-(m||1)].first_line,last_line:r[r.length-1].last_line,first_column:r[r.length-(m||1)].first_column,last_column:r[r.length-1].last_column},h&&(S._$.range=[r[r.length-(m||1)].range[0],r[r.length-1].range[1]]),void 0!==(p=this.performAction.call(S,a,u,o,this.yy,d[1],n,r)))return p;m&&(i=i.slice(0,-1*m*2),n=n.slice(0,-1*m),r=r.slice(0,-1*m)),i.push(this.productions_[d[1]][0]),n.push(S.$),r.push(S._$),g=s[i[i.length-2]][i[i.length-1]],i.push(g);break;case 3:return!0}}return!0}},t=function(){var e={EOF:1,parseError:function(e,t){if(!this.yy.parser)throw new Error(e);this.yy.parser.parseError(e,t)},setInput:function(e){return this._input=e,this._more=this._less=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var e=this._input[0];return this.yytext+=e,this.yyleng++,this.offset++,this.match+=e,this.matched+=e,e.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),e},unput:function(e){var t=e.length,i=e.split(/(?:\r\n?|\n)/g);this._input=e+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-t-1),this.offset-=t;var n=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),i.length-1&&(this.yylineno-=i.length-1);var r=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:i?(i.length===n.length?this.yylloc.first_column:0)+n[n.length-i.length].length-i[0].length:this.yylloc.first_column-t},this.options.ranges&&(this.yylloc.range=[r[0],r[0]+this.yyleng-t]),this},more:function(){return this._more=!0,this},less:function(e){this.unput(this.match.slice(e))},pastInput:function(){var e=this.matched.substr(0,this.matched.length-this.match.length);return(e.length>20?"...":"")+e.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var e=this.match;return e.length<20&&(e+=this._input.substr(0,20-e.length)),(e.substr(0,20)+(e.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var e=this.pastInput(),t=new Array(e.length+1).join("-");return e+this.upcomingInput()+"\n"+t+"^"},next:function(){if(this.done)return this.EOF;var e,t,i,n,r;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var s=this._currentRules(),a=0;at[0].length)||(t=i,n=a,this.options.flex));a++);return t?((r=t[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=r.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:r?r[r.length-1].length-r[r.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],e=this.performAction.call(this,this.yy,this,s[n],this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),e||void 0):""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var e=this.next();return void 0!==e?e:this.lex()},begin:function(e){this.conditionStack.push(e)},popState:function(){return this.conditionStack.pop()},_currentRules:function(){return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules},topState:function(){return this.conditionStack[this.conditionStack.length-2]},pushState:function(e){this.begin(e)},options:{},performAction:function(e,t,i,n){function r(e,i){return t.yytext=t.yytext.substring(e,t.yyleng-i+e)}switch(i){case 0:if("\\\\"===t.yytext.slice(-2)?(r(0,1),this.begin("mu")):"\\"===t.yytext.slice(-1)?(r(0,1),this.begin("emu")):this.begin("mu"),t.yytext)return 15;break;case 1:return 15;case 2:return this.popState(),15;case 3:return this.begin("raw"),15;case 4:return this.popState(),"raw"===this.conditionStack[this.conditionStack.length-1]?15:(r(5,9),"END_RAW_BLOCK");case 5:return 15;case 6:return this.popState(),14;case 7:return 65;case 8:return 68;case 9:return 19;case 10:return this.popState(),this.begin("raw"),23;case 11:return 55;case 12:return 60;case 13:return 29;case 14:return 47;case 15:case 16:return this.popState(),44;case 17:return 34;case 18:return 39;case 19:return 51;case 20:return 48;case 21:this.unput(t.yytext),this.popState(),this.begin("com");break;case 22:return this.popState(),14;case 23:return 48;case 24:return 73;case 25:case 26:return 72;case 27:return 87;case 28:break;case 29:return this.popState(),54;case 30:return this.popState(),33;case 31:return t.yytext=r(1,2).replace(/\\"/g,'"'),80;case 32:return t.yytext=r(1,2).replace(/\\'/g,"'"),80;case 33:return 85;case 34:case 35:return 82;case 36:return 83;case 37:return 84;case 38:return 81;case 39:return 75;case 40:return 77;case 41:return 72;case 42:return t.yytext=t.yytext.replace(/\\([\\\]])/g,"$1"),72;case 43:return"INVALID";case 44:return 5}},rules:[/^(?:[^\x00]*?(?=(\{\{)))/,/^(?:[^\x00]+)/,/^(?:[^\x00]{2,}?(?=(\{\{|\\\{\{|\\\\\{\{|$)))/,/^(?:\{\{\{\{(?=[^\/]))/,/^(?:\{\{\{\{\/[^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=[=}\s\/.])\}\}\}\})/,/^(?:[^\x00]+?(?=(\{\{\{\{)))/,/^(?:[\s\S]*?--(~)?\}\})/,/^(?:\()/,/^(?:\))/,/^(?:\{\{\{\{)/,/^(?:\}\}\}\})/,/^(?:\{\{(~)?>)/,/^(?:\{\{(~)?#>)/,/^(?:\{\{(~)?#\*?)/,/^(?:\{\{(~)?\/)/,/^(?:\{\{(~)?\^\s*(~)?\}\})/,/^(?:\{\{(~)?\s*else\s*(~)?\}\})/,/^(?:\{\{(~)?\^)/,/^(?:\{\{(~)?\s*else\b)/,/^(?:\{\{(~)?\{)/,/^(?:\{\{(~)?&)/,/^(?:\{\{(~)?!--)/,/^(?:\{\{(~)?![\s\S]*?\}\})/,/^(?:\{\{(~)?\*?)/,/^(?:=)/,/^(?:\.\.)/,/^(?:\.(?=([=~}\s\/.)|])))/,/^(?:[\/.])/,/^(?:\s+)/,/^(?:\}(~)?\}\})/,/^(?:(~)?\}\})/,/^(?:"(\\["]|[^"])*")/,/^(?:'(\\[']|[^'])*')/,/^(?:@)/,/^(?:true(?=([~}\s)])))/,/^(?:false(?=([~}\s)])))/,/^(?:undefined(?=([~}\s)])))/,/^(?:null(?=([~}\s)])))/,/^(?:-?[0-9]+(?:\.[0-9]+)?(?=([~}\s)])))/,/^(?:as\s+\|)/,/^(?:\|)/,/^(?:([^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=([=~}\s\/.)|]))))/,/^(?:\[(\\\]|[^\]])*\])/,/^(?:.)/,/^(?:$)/],conditions:{mu:{rules:[7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44],inclusive:!1},emu:{rules:[2],inclusive:!1},com:{rules:[6],inclusive:!1},raw:{rules:[3,4,5],inclusive:!1},INITIAL:{rules:[0,1,44],inclusive:!0}}};return e}();function i(){this.yy={}}return e.lexer=t,i.prototype=e,e.Parser=i,new i}();t.default=i,e.exports=t.default}({get exports(){return _l},set exports(e){_l=e}},_l);var El={},wl={get exports(){return El},set exports(e){El=e}},Ml={};!function(e,t){t.__esModule=!0;var i=function(e){return e&&e.__esModule?e:{default:e}}(ku);function n(){this.parents=[]}function r(e){this.acceptRequired(e,"path"),this.acceptArray(e.params),this.acceptKey(e,"hash")}function s(e){r.call(this,e),this.acceptKey(e,"program"),this.acceptKey(e,"inverse")}function a(e){this.acceptRequired(e,"name"),this.acceptArray(e.params),this.acceptKey(e,"hash")}n.prototype={constructor:n,mutating:!1,acceptKey:function(e,t){var r=this.accept(e[t]);if(this.mutating){if(r&&!n.prototype[r.type])throw new i.default('Unexpected node type "'+r.type+'" found when accepting '+t+" on "+e.type);e[t]=r}},acceptRequired:function(e,t){if(this.acceptKey(e,t),!e[t])throw new i.default(e.type+" requires "+t)},acceptArray:function(e){for(var t=0,i=e.length;t0)throw new Pl.default("Invalid path: "+n,{loc:i});".."===u&&s++}}return{type:"PathExpression",data:e,depth:s,parts:r,original:n,loc:i}},Tl.prepareMustache=function(e,t,i,n,r,s){var a=n.charAt(3)||n.charAt(2),o="{"!==a&&"&"!==a;return{type:/\*/.test(n)?"Decorator":"MustacheStatement",path:e,params:t,hash:i,escaped:o,strip:r,loc:this.locInfo(s)}},Tl.prepareRawBlock=function(e,t,i,n){Ll(e,i),n=this.locInfo(n);var r={type:"Program",body:t,strip:{},loc:n};return{type:"BlockStatement",path:e.path,params:e.params,hash:e.hash,program:r,openStrip:{},inverseStrip:{},closeStrip:{},loc:n}},Tl.prepareBlock=function(e,t,i,n,r,s){n&&n.path&&Ll(e,n);var a=/\*/.test(e.open);t.blockParams=e.blockParams;var o=void 0,u=void 0;if(i){if(a)throw new Pl.default("Unexpected inverse block on decorator",i);i.chain&&(i.program.body[0].closeStrip=n.strip),u=i.strip,o=i.program}r&&(r=o,o=t,t=r);return{type:a?"DecoratorBlock":"BlockStatement",path:e.path,params:e.params,hash:e.hash,program:t,inverse:o,openStrip:e.strip,inverseStrip:u,closeStrip:n&&n.strip,loc:this.locInfo(s)}},Tl.prepareProgram=function(e,t){if(!t&&e.length){var i=e[0].loc,n=e[e.length-1].loc;i&&n&&(t={source:i.source,start:{line:i.start.line,column:i.start.column},end:{line:n.end.line,column:n.end.column}})}return{type:"Program",body:e,strip:{},loc:t}},Tl.preparePartialBlock=function(e,t,i,n){return Ll(e,i),{type:"PartialBlockStatement",name:e.path,params:e.params,hash:e.hash,program:t,openStrip:e.strip,closeStrip:i&&i.strip,loc:this.locInfo(n)}};var Pl=function(e){return e&&e.__esModule?e:{default:e}}(ku);function Ll(e,t){if(t=t.path?t.path.original:t,e.path.original!==t){var i={loc:e.path.loc};throw new Pl.default(e.path.original+" doesn't match "+t,i)}}function Cl(e){return e&&e.__esModule?e:{default:e}}kl.__esModule=!0,kl.parseWithoutProcessing=Dl,kl.parse=function(e,t){var i=Dl(e,t);return new Rl.default(t).accept(i)};var Al=Cl(_l),Rl=Cl(El),Il=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t.default=e,t}(Tl),Nl=du;kl.parser=Al.default;var Bl={};function Dl(e,t){return"Program"===e.type?e:(Al.default.yy=Bl,Bl.locInfo=function(e){return new Bl.SourceLocation(t&&t.srcName,e)},Al.default.parse(e))}Nl.extend(Bl,Il);var Ol={};function Fl(e){return e&&e.__esModule?e:{default:e}}Ol.__esModule=!0,Ol.Compiler=zl,Ol.precompile=function(e,t,i){if(null==e||"string"!=typeof e&&"Program"!==e.type)throw new Vl.default("You must pass a string or Handlebars AST to Handlebars.precompile. You passed "+e);"data"in(t=t||{})||(t.data=!0);t.compat&&(t.useDepths=!0);var n=i.parse(e,t),r=(new i.Compiler).compile(n,t);return(new i.JavaScriptCompiler).compile(r,t)},Ol.compile=function(e,t,i){void 0===t&&(t={});if(null==e||"string"!=typeof e&&"Program"!==e.type)throw new Vl.default("You must pass a string or Handlebars AST to Handlebars.compile. You passed "+e);"data"in(t=Gl.extend({},t))||(t.data=!0);t.compat&&(t.useDepths=!0);var n=void 0;function r(){var n=i.parse(e,t),r=(new i.Compiler).compile(n,t),s=(new i.JavaScriptCompiler).compile(r,t,void 0,!0);return i.template(s)}function s(e,t){return n||(n=r()),n.call(this,e,t)}return s._setup=function(e){return n||(n=r()),n._setup(e)},s._child=function(e,t,i,s){return n||(n=r()),n._child(e,t,i,s)},s};var Vl=Fl(ku),Gl=du,Wl=Fl(xl),Ul=[].slice;function zl(){}function Hl(e,t){if(e===t)return!0;if(Gl.isArray(e)&&Gl.isArray(t)&&e.length===t.length){for(var i=0;i1)throw new Vl.default("Unsupported number of partial arguments: "+i.length,e);i.length||(this.options.explicitPartialContext?this.opcode("pushLiteral","undefined"):i.push({type:"PathExpression",parts:[],depth:0}));var n=e.name.original,r="SubExpression"===e.name.type;r&&this.accept(e.name),this.setupFullMustacheParams(e,t,void 0,!0);var s=e.indent||"";this.options.preventIndent&&s&&(this.opcode("appendContent",s),s=""),this.opcode("invokePartial",r,n,s),this.opcode("append")},PartialBlockStatement:function(e){this.PartialStatement(e)},MustacheStatement:function(e){this.SubExpression(e),e.escaped&&!this.options.noEscape?this.opcode("appendEscaped"):this.opcode("append")},Decorator:function(e){this.DecoratorBlock(e)},ContentStatement:function(e){e.value&&this.opcode("appendContent",e.value)},CommentStatement:function(){},SubExpression:function(e){Xl(e);var t=this.classifySexpr(e);"simple"===t?this.simpleSexpr(e):"helper"===t?this.helperSexpr(e):this.ambiguousSexpr(e)},ambiguousSexpr:function(e,t,i){var n=e.path,r=n.parts[0],s=null!=t||null!=i;this.opcode("getContext",n.depth),this.opcode("pushProgram",t),this.opcode("pushProgram",i),n.strict=!0,this.accept(n),this.opcode("invokeAmbiguous",r,s)},simpleSexpr:function(e){var t=e.path;t.strict=!0,this.accept(t),this.opcode("resolvePossibleLambda")},helperSexpr:function(e,t,i){var n=this.setupFullMustacheParams(e,t,i),r=e.path,s=r.parts[0];if(this.options.knownHelpers[s])this.opcode("invokeKnownHelper",n.length,s);else{if(this.options.knownHelpersOnly)throw new Vl.default("You specified knownHelpersOnly, but used the unknown helper "+s,e);r.strict=!0,r.falsy=!0,this.accept(r),this.opcode("invokeHelper",n.length,r.original,Wl.default.helpers.simpleId(r))}},PathExpression:function(e){this.addDepth(e.depth),this.opcode("getContext",e.depth);var t=e.parts[0],i=Wl.default.helpers.scopedId(e),n=!e.depth&&!i&&this.blockParamIndex(t);n?this.opcode("lookupBlockParam",n,e.parts):t?e.data?(this.options.data=!0,this.opcode("lookupData",e.depth,e.parts,e.strict)):this.opcode("lookupOnContext",e.parts,e.falsy,e.strict,i):this.opcode("pushContext")},StringLiteral:function(e){this.opcode("pushString",e.value)},NumberLiteral:function(e){this.opcode("pushLiteral",e.value)},BooleanLiteral:function(e){this.opcode("pushLiteral",e.value)},UndefinedLiteral:function(){this.opcode("pushLiteral","undefined")},NullLiteral:function(){this.opcode("pushLiteral","null")},Hash:function(e){var t=e.pairs,i=0,n=t.length;for(this.opcode("pushHash");i=0)return[t,r]}}};var Yl,jl,Kl={},ql={get exports(){return Kl},set exports(e){Kl=e}},Jl={},Zl={},$l={},Ql={},eh={};function th(){if(jl)return Ql;jl=1;var e=function(){if(Yl)return eh;Yl=1;var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");return eh.encode=function(t){if(0<=t&&t>>=5)>0&&(i|=32),n+=e.encode(i)}while(r>0);return n},Ql.decode=function(t,i,n){var r,s,a,o,u=t.length,l=0,h=0;do{if(i>=u)throw new Error("Expected more digits in base 64 VLQ value.");if(-1===(s=e.decode(t.charCodeAt(i++))))throw new Error("Invalid base64 digit: "+t.charAt(i-1));r=!!(32&s),l+=(s&=31)<>1,1==(1&a)?-o:o),n.rest=i},Ql}var ih,nh={};function rh(){return ih||(ih=1,function(e){e.getArg=function(e,t,i){if(t in e)return e[t];if(3===arguments.length)return i;throw new Error('"'+t+'" is a required argument.')};var t=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,i=/^data:.+\,.+$/;function n(e){var i=e.match(t);return i?{scheme:i[1],auth:i[2],host:i[3],port:i[4],path:i[5]}:null}function r(e){var t="";return e.scheme&&(t+=e.scheme+":"),t+="//",e.auth&&(t+=e.auth+"@"),e.host&&(t+=e.host),e.port&&(t+=":"+e.port),e.path&&(t+=e.path),t}function s(t){var i=t,s=n(t);if(s){if(!s.path)return t;i=s.path}for(var a,o=e.isAbsolute(i),u=i.split(/\/+/),l=0,h=u.length-1;h>=0;h--)"."===(a=u[h])?u.splice(h,1):".."===a?l++:l>0&&(""===a?(u.splice(h+1,l),l=0):(u.splice(h,2),l--));return""===(i=u.join("/"))&&(i=o?"/":"."),s?(s.path=i,r(s)):i}function a(e,t){""===e&&(e="."),""===t&&(t=".");var a=n(t),o=n(e);if(o&&(e=o.path||"/"),a&&!a.scheme)return o&&(a.scheme=o.scheme),r(a);if(a||t.match(i))return t;if(o&&!o.host&&!o.path)return o.host=t,r(o);var u="/"===t.charAt(0)?t:s(e.replace(/\/+$/,"")+"/"+t);return o?(o.path=u,r(o)):u}e.urlParse=n,e.urlGenerate=r,e.normalize=s,e.join=a,e.isAbsolute=function(e){return"/"===e.charAt(0)||t.test(e)},e.relative=function(e,t){""===e&&(e="."),e=e.replace(/\/$/,"");for(var i=0;0!==t.indexOf(e+"/");){var n=e.lastIndexOf("/");if(n<0)return t;if((e=e.slice(0,n)).match(/^([^\/]+:\/)?\/*$/))return t;++i}return Array(i+1).join("../")+t.substr(e.length+1)};var o=!("__proto__"in Object.create(null));function u(e){return e}function l(e){if(!e)return!1;var t=e.length;if(t<9)return!1;if(95!==e.charCodeAt(t-1)||95!==e.charCodeAt(t-2)||111!==e.charCodeAt(t-3)||116!==e.charCodeAt(t-4)||111!==e.charCodeAt(t-5)||114!==e.charCodeAt(t-6)||112!==e.charCodeAt(t-7)||95!==e.charCodeAt(t-8)||95!==e.charCodeAt(t-9))return!1;for(var i=t-10;i>=0;i--)if(36!==e.charCodeAt(i))return!1;return!0}function h(e,t){return e===t?0:null===e?1:null===t?-1:e>t?1:-1}e.toSetString=o?u:function(e){return l(e)?"$"+e:e},e.fromSetString=o?u:function(e){return l(e)?e.slice(1):e},e.compareByOriginalPositions=function(e,t,i){var n=h(e.source,t.source);return 0!==n||0!==(n=e.originalLine-t.originalLine)||0!==(n=e.originalColumn-t.originalColumn)||i||0!==(n=e.generatedColumn-t.generatedColumn)||0!==(n=e.generatedLine-t.generatedLine)?n:h(e.name,t.name)},e.compareByGeneratedPositionsDeflated=function(e,t,i){var n=e.generatedLine-t.generatedLine;return 0!==n||0!==(n=e.generatedColumn-t.generatedColumn)||i||0!==(n=h(e.source,t.source))||0!==(n=e.originalLine-t.originalLine)||0!==(n=e.originalColumn-t.originalColumn)?n:h(e.name,t.name)},e.compareByGeneratedPositionsInflated=function(e,t){var i=e.generatedLine-t.generatedLine;return 0!==i||0!==(i=e.generatedColumn-t.generatedColumn)||0!==(i=h(e.source,t.source))||0!==(i=e.originalLine-t.originalLine)||0!==(i=e.originalColumn-t.originalColumn)?i:h(e.name,t.name)},e.parseSourceMapInput=function(e){return JSON.parse(e.replace(/^\)]}'[^\n]*\n/,""))},e.computeSourceURL=function(e,t,i){if(t=t||"",e&&("/"!==e[e.length-1]&&"/"!==t[0]&&(e+="/"),t=e+t),i){var o=n(i);if(!o)throw new Error("sourceMapURL could not be parsed");if(o.path){var u=o.path.lastIndexOf("/");u>=0&&(o.path=o.path.substring(0,u+1))}t=a(r(o),t)}return s(t)}}(nh)),nh}var sh,ah={};function oh(){if(sh)return ah;sh=1;var e=rh(),t=Object.prototype.hasOwnProperty,i="undefined"!=typeof Map;function n(){this._array=[],this._set=i?new Map:Object.create(null)}return n.fromArray=function(e,t){for(var i=new n,r=0,s=e.length;r=0)return r}else{var s=e.toSetString(n);if(t.call(this._set,s))return this._set[s]}throw new Error('"'+n+'" is not in the set.')},n.prototype.at=function(e){if(e>=0&&er||s==r&&o>=a||e.compareByGeneratedPositionsInflated(i,n)<=0?(this._last=t,this._array.push(t)):(this._sorted=!1,this._array.push(t))},t.prototype.toArray=function(){return this._sorted||(this._array.sort(e.compareByGeneratedPositionsInflated),this._sorted=!0),this._array},hh.MappingList=t,hh}function fh(){if(lh)return $l;lh=1;var e=th(),t=rh(),i=oh().ArraySet,n=ch().MappingList;function r(e){e||(e={}),this._file=t.getArg(e,"file",null),this._sourceRoot=t.getArg(e,"sourceRoot",null),this._skipValidation=t.getArg(e,"skipValidation",!1),this._sources=new i,this._names=new i,this._mappings=new n,this._sourcesContents=null}return r.prototype._version=3,r.fromSourceMap=function(e){var i=e.sourceRoot,n=new r({file:e.file,sourceRoot:i});return e.eachMapping((function(e){var r={generated:{line:e.generatedLine,column:e.generatedColumn}};null!=e.source&&(r.source=e.source,null!=i&&(r.source=t.relative(i,r.source)),r.original={line:e.originalLine,column:e.originalColumn},null!=e.name&&(r.name=e.name)),n.addMapping(r)})),e.sources.forEach((function(r){var s=r;null!==i&&(s=t.relative(i,r)),n._sources.has(s)||n._sources.add(s);var a=e.sourceContentFor(r);null!=a&&n.setSourceContent(r,a)})),n},r.prototype.addMapping=function(e){var i=t.getArg(e,"generated"),n=t.getArg(e,"original",null),r=t.getArg(e,"source",null),s=t.getArg(e,"name",null);this._skipValidation||this._validateMapping(i,n,r,s),null!=r&&(r=String(r),this._sources.has(r)||this._sources.add(r)),null!=s&&(s=String(s),this._names.has(s)||this._names.add(s)),this._mappings.add({generatedLine:i.line,generatedColumn:i.column,originalLine:null!=n&&n.line,originalColumn:null!=n&&n.column,source:r,name:s})},r.prototype.setSourceContent=function(e,i){var n=e;null!=this._sourceRoot&&(n=t.relative(this._sourceRoot,n)),null!=i?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[t.toSetString(n)]=i):this._sourcesContents&&(delete this._sourcesContents[t.toSetString(n)],0===Object.keys(this._sourcesContents).length&&(this._sourcesContents=null))},r.prototype.applySourceMap=function(e,n,r){var s=n;if(null==n){if(null==e.file)throw new Error('SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map\'s "file" property. Both were omitted.');s=e.file}var a=this._sourceRoot;null!=a&&(s=t.relative(a,s));var o=new i,u=new i;this._mappings.unsortedForEach((function(i){if(i.source===s&&null!=i.originalLine){var n=e.originalPositionFor({line:i.originalLine,column:i.originalColumn});null!=n.source&&(i.source=n.source,null!=r&&(i.source=t.join(r,i.source)),null!=a&&(i.source=t.relative(a,i.source)),i.originalLine=n.line,i.originalColumn=n.column,null!=n.name&&(i.name=n.name))}var l=i.source;null==l||o.has(l)||o.add(l);var h=i.name;null==h||u.has(h)||u.add(h)}),this),this._sources=o,this._names=u,e.sources.forEach((function(i){var n=e.sourceContentFor(i);null!=n&&(null!=r&&(i=t.join(r,i)),null!=a&&(i=t.relative(a,i)),this.setSourceContent(i,n))}),this)},r.prototype._validateMapping=function(e,t,i,n){if(t&&"number"!=typeof t.line&&"number"!=typeof t.column)throw new Error("original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.");if((!(e&&"line"in e&&"column"in e&&e.line>0&&e.column>=0)||t||i||n)&&!(e&&"line"in e&&"column"in e&&t&&"line"in t&&"column"in t&&e.line>0&&e.column>=0&&t.line>0&&t.column>=0&&i))throw new Error("Invalid mapping: "+JSON.stringify({generated:e,source:i,original:t,name:n}))},r.prototype._serializeMappings=function(){for(var i,n,r,s,a=0,o=1,u=0,l=0,h=0,c=0,f="",d=this._mappings.toArray(),p=0,v=d.length;p0){if(!t.compareByGeneratedPositionsInflated(n,d[p-1]))continue;i+=","}i+=e.encode(n.generatedColumn-a),a=n.generatedColumn,null!=n.source&&(s=this._sources.indexOf(n.source),i+=e.encode(s-c),c=s,i+=e.encode(n.originalLine-1-l),l=n.originalLine-1,i+=e.encode(n.originalColumn-u),u=n.originalColumn,null!=n.name&&(r=this._names.indexOf(n.name),i+=e.encode(r-h),h=r)),f+=i}return f},r.prototype._generateSourcesContent=function(e,i){return e.map((function(e){if(!this._sourcesContents)return null;null!=i&&(e=t.relative(i,e));var n=t.toSetString(e);return Object.prototype.hasOwnProperty.call(this._sourcesContents,n)?this._sourcesContents[n]:null}),this)},r.prototype.toJSON=function(){var e={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};return null!=this._file&&(e.file=this._file),null!=this._sourceRoot&&(e.sourceRoot=this._sourceRoot),this._sourcesContents&&(e.sourcesContent=this._generateSourcesContent(e.sources,e.sourceRoot)),e},r.prototype.toString=function(){return JSON.stringify(this.toJSON())},$l.SourceMapGenerator=r,$l}var dh,ph={},vh={};function mh(){return dh||(dh=1,function(e){function t(i,n,r,s,a,o){var u=Math.floor((n-i)/2)+i,l=a(r,s[u],!0);return 0===l?u:l>0?n-u>1?t(u,n,r,s,a,o):o==e.LEAST_UPPER_BOUND?n1?t(i,u,r,s,a,o):o==e.LEAST_UPPER_BOUND?u:i<0?-1:i}e.GREATEST_LOWER_BOUND=1,e.LEAST_UPPER_BOUND=2,e.search=function(i,n,r,s){if(0===n.length)return-1;var a=t(-1,n.length,i,n,r,s||e.GREATEST_LOWER_BOUND);if(a<0)return-1;for(;a-1>=0&&0===r(n[a],n[a-1],!0);)--a;return a}}(vh)),vh}var gh,yh,bh={};function Sh(){if(gh)return bh;function e(e,t,i){var n=e[t];e[t]=e[i],e[i]=n}function t(i,n,r,s){if(r=0){var o=this._originalMappings[a];if(void 0===i.column)for(var u=o.originalLine;o&&o.originalLine===u;)s.push({line:e.getArg(o,"generatedLine",null),column:e.getArg(o,"generatedColumn",null),lastColumn:e.getArg(o,"lastGeneratedColumn",null)}),o=this._originalMappings[++a];else for(var l=o.originalColumn;o&&o.originalLine===n&&o.originalColumn==l;)s.push({line:e.getArg(o,"generatedLine",null),column:e.getArg(o,"generatedColumn",null),lastColumn:e.getArg(o,"lastGeneratedColumn",null)}),o=this._originalMappings[++a]}return s},ph.SourceMapConsumer=s,a.prototype=Object.create(s.prototype),a.prototype.consumer=s,a.prototype._findSourceIndex=function(t){var i,n=t;if(null!=this.sourceRoot&&(n=e.relative(this.sourceRoot,n)),this._sources.has(n))return this._sources.indexOf(n);for(i=0;i1&&(s.source=v+u[1],v+=u[1],s.originalLine=d+u[2],d=s.originalLine,s.originalLine+=1,s.originalColumn=p+u[3],p=s.originalColumn,u.length>4&&(s.name=m+u[4],m+=u[4])),k.push(s),"number"==typeof s.originalLine&&x.push(s)}r(k,e.compareByGeneratedPositionsDeflated),this.__generatedMappings=k,r(x,e.compareByOriginalPositions),this.__originalMappings=x},a.prototype._findMapping=function(e,i,n,r,s,a){if(e[n]<=0)throw new TypeError("Line must be greater than or equal to 1, got "+e[n]);if(e[r]<0)throw new TypeError("Column must be greater than or equal to 0, got "+e[r]);return t.search(e,i,s,a)},a.prototype.computeColumnSpans=function(){for(var e=0;e=0){var r=this._generatedMappings[n];if(r.generatedLine===i.generatedLine){var a=e.getArg(r,"source",null);null!==a&&(a=this._sources.at(a),a=e.computeSourceURL(this.sourceRoot,a,this._sourceMapURL));var o=e.getArg(r,"name",null);return null!==o&&(o=this._names.at(o)),{source:a,line:e.getArg(r,"originalLine",null),column:e.getArg(r,"originalColumn",null),name:o}}}return{source:null,line:null,column:null,name:null}},a.prototype.hasContentsOfAllSources=function(){return!!this.sourcesContent&&this.sourcesContent.length>=this._sources.size()&&!this.sourcesContent.some((function(e){return null==e}))},a.prototype.sourceContentFor=function(t,i){if(!this.sourcesContent)return null;var n=this._findSourceIndex(t);if(n>=0)return this.sourcesContent[n];var r,s=t;if(null!=this.sourceRoot&&(s=e.relative(this.sourceRoot,s)),null!=this.sourceRoot&&(r=e.urlParse(this.sourceRoot))){var a=s.replace(/^file:\/\//,"");if("file"==r.scheme&&this._sources.has(a))return this.sourcesContent[this._sources.indexOf(a)];if((!r.path||"/"==r.path)&&this._sources.has("/"+s))return this.sourcesContent[this._sources.indexOf("/"+s)]}if(i)return null;throw new Error('"'+s+'" is not in the SourceMap.')},a.prototype.generatedPositionFor=function(t){var i=e.getArg(t,"source");if((i=this._findSourceIndex(i))<0)return{line:null,column:null,lastColumn:null};var n={source:i,originalLine:e.getArg(t,"line"),originalColumn:e.getArg(t,"column")},r=this._findMapping(n,this._originalMappings,"originalLine","originalColumn",e.compareByOriginalPositions,e.getArg(t,"bias",s.GREATEST_LOWER_BOUND));if(r>=0){var a=this._originalMappings[r];if(a.source===n.source)return{line:e.getArg(a,"generatedLine",null),column:e.getArg(a,"generatedColumn",null),lastColumn:e.getArg(a,"lastGeneratedColumn",null)}}return{line:null,column:null,lastColumn:null}},ph.BasicSourceMapConsumer=a,u.prototype=Object.create(s.prototype),u.prototype.constructor=s,u.prototype._version=3,Object.defineProperty(u.prototype,"sources",{get:function(){for(var e=[],t=0;t=0;t--)this.prepend(e[t]);else{if(!e[n]&&"string"!=typeof e)throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+e);this.children.unshift(e)}return this},r.prototype.walk=function(e){for(var t,i=0,r=this.children.length;i0){for(t=[],i=0;i0&&(i+=", "+n.join(", "));var r=0;Object.keys(this.aliases).forEach((function(e){var n=t.aliases[e];n.children&&n.referenceCount>1&&(i+=", alias"+ ++r+"="+e,n.children[0]="alias"+r)})),this.lookupPropertyFunctionIsUsed&&(i+=", "+this.lookupPropertyFunctionVarDeclaration());var s=["container","depth0","helpers","partials","data"];(this.useBlockParams||this.useDepths)&&s.push("blockParams"),this.useDepths&&s.push("depths");var a=this.mergeSource(i);return e?(s.push(a),Function.apply(this,s)):this.source.wrap(["function(",s.join(","),") {\n ",a,"}"])},mergeSource:function(e){var t=this.environment.isSimple,i=!this.forceBuffer,n=void 0,r=void 0,s=void 0,a=void 0;return this.source.each((function(e){e.appendToBuffer?(s?e.prepend(" + "):s=e,a=e):(s&&(r?s.prepend("buffer += "):n=!0,a.add(";"),s=a=void 0),r=!0,t||(i=!1))})),i?s?(s.prepend("return "),a.add(";")):r||this.source.push('return "";'):(e+=", buffer = "+(n?"":this.initializeBuffer()),s?(s.prepend("return buffer + "),a.add(";")):this.source.push("return buffer;")),e&&this.source.prepend("var "+e.substring(2)+(n?"":";\n")),this.source.merge()},lookupPropertyFunctionVarDeclaration:function(){return"\n lookupProperty = container.lookupProperty || function(parent, propertyName) {\n if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {\n return parent[propertyName];\n }\n return undefined\n }\n ".trim()},blockValue:function(e){var t=this.aliasable("container.hooks.blockHelperMissing"),i=[this.contextName(0)];this.setupHelperArgs(e,0,i);var n=this.popStack();i.splice(1,0,n),this.push(this.source.functionCall(t,"call",i))},ambiguousBlockValue:function(){var e=this.aliasable("container.hooks.blockHelperMissing"),t=[this.contextName(0)];this.setupHelperArgs("",0,t,!0),this.flushInline();var i=this.topStack();t.splice(1,0,i),this.pushSource(["if (!",this.lastHelper,") { ",i," = ",this.source.functionCall(e,"call",t),"}"])},appendContent:function(e){this.pendingContent?e=this.pendingContent+e:this.pendingLocation=this.source.currentLocation,this.pendingContent=e},append:function(){if(this.isInline())this.replaceStack((function(e){return[" != null ? ",e,' : ""']})),this.pushSource(this.appendToBuffer(this.popStack()));else{var e=this.popStack();this.pushSource(["if (",e," != null) { ",this.appendToBuffer(e,void 0,!0)," }"]),this.environment.isSimple&&this.pushSource(["else { ",this.appendToBuffer("''",void 0,!0)," }"])}},appendEscaped:function(){this.pushSource(this.appendToBuffer([this.aliasable("container.escapeExpression"),"(",this.popStack(),")"]))},getContext:function(e){this.lastContext=e},pushContext:function(){this.pushStackLiteral(this.contextName(this.lastContext))},lookupOnContext:function(e,t,i,n){var r=0;n||!this.options.compat||this.lastContext?this.pushContext():this.push(this.depthedLookup(e[r++])),this.resolvePath("context",e,r,t,i)},lookupBlockParam:function(e,t){this.useBlockParams=!0,this.push(["blockParams[",e[0],"][",e[1],"]"]),this.resolvePath("context",t,1)},lookupData:function(e,t,i){e?this.pushStackLiteral("container.data(data, "+e+")"):this.pushStackLiteral("data"),this.resolvePath("data",t,0,!0,i)},resolvePath:function(e,t,i,n,r){var s=this;if(this.options.strict||this.options.assumeObjects)this.push(function(e,t,i,n){var r=t.popStack(),s=0,a=i.length;e&&a--;for(;sthis.stackVars.length&&this.stackVars.push("stack"+this.stackSlot),this.topStackName()},topStackName:function(){return"stack"+this.stackSlot},flushInline:function(){var e=this.inlineStack;this.inlineStack=[];for(var t=0,i=e.length;t>2)/t)*t:3*a+1>>2,u=new Uint8Array(o),l=0,h=0,c=0;c64&&r<91?r-65:r>96&&r<123?r-71:r>47&&r<58?r+4:43===r?62:47===r?63:0)<<18-6*n,3===n||a-c==1){for(i=0;i<3&&h>>(16>>>i&24)&255;l=0}return u}},Ch=function(e,t){return new Promise((function(i,n){var r=new XMLHttpRequest;t&&(r.responseType=t),r.open("GET",e),r.onload=function(){200===r.status?i(r.response):n(Error(r.statusText))},r.onerror=function(){n(Error("Network Error"))},r.send()}))};!function(e){var t=Lh,i=Ch;function n(e){return function(t){return"string"==typeof t&&e.test(t)}}function r(e,t){return"string"==typeof e?e+t:"function"==typeof e?e(t):t}function s(e,t,i,n){var r=t instanceof ArrayBuffer?a:o(t)?u:function(e){return e&&"function"==typeof e.then}(t)?l:c(t)?f:function(e){return e&&"object"===h(e)}(t)?d:p(t)?v:m(t)?g:y(t)?b:null;return r?r(e,t,i||{}):n?Promise.resolve(n):Promise.reject("Source not valid ("+t+")")}function a(e,t,i){return new Promise((function(i,n){e.decodeAudioData(t,(function(e){i(e)}),(function(){n("Can't decode audio data ("+t.slice(0,30)+"...)")}))}))}s.fetch=i;var o=n(/\.(mp3|wav|ogg)(\?.*)?$/i);function u(e,t,i){var n=r(i.from,t);return s(e,s.fetch(n,"arraybuffer"),i)}function l(e,t,i){return t.then((function(t){return s(e,t,i)}))}var c=Array.isArray;function f(e,t,i){return Promise.all(t.map((function(t){return s(e,t,i,t)})))}function d(e,t,i){var n={},r=Object.keys(t).map((function(r){if(i.only&&-1===i.only.indexOf(r))return null;var a=t[r];return s(e,a,i,a).then((function(e){n[r]=e}))}));return Promise.all(r).then((function(){return n}))}var p=n(/\.json(\?.*)?$/i);function v(e,t,i){var n=r(i.from,t);return s(e,s.fetch(n,"text").then(JSON.parse),i)}var m=n(/^data:audio/);function g(e,i,n){var r=i.indexOf(",");return s(e,t.decode(i.slice(r+1)).buffer,n)}var y=n(/\.js(\?.*)?$/i);function b(e,t,i){var n=r(i.from,t);return s(e,s.fetch(n,"text").then(S),i)}function S(e){var t=e.indexOf("MIDI.Soundfont.");if(t<0)throw Error("Invalid MIDI.js Soundfont format");t=e.indexOf("=",t)+2;var i=e.lastIndexOf(",");return JSON.parse(e.slice(t,i)+"}")}e.exports&&(e.exports=s),"undefined"!=typeof window&&(window.loadAudio=s)}({get exports(){return Ph},set exports(e){Ph=e}});var Ah={},Rh={get exports(){return Ah},set exports(e){Ah=e}},Ih=function(e){var t=e.createGain(),i=t._voltage=function(e){var t=e.createBufferSource(),i=e.createBuffer(1,2,e.sampleRate);return i.getChannelData(0).set(Bh),t.buffer=i,t.loop=!0,t}(e),n=Dh(i),r=Dh(i),s=Dh(i);return t._startAmount=Dh(r),t._endAmount=Dh(s),t._multiplier=Dh(n),t._multiplier.connect(t),t._startAmount.connect(t),t._endAmount.connect(t),t.value=n.gain,t.startValue=r.gain,t.endValue=s.gain,t.startValue.value=0,t.endValue.value=0,Object.defineProperties(t,Nh),t};var Nh={attack:{value:0,writable:!0},decay:{value:0,writable:!0},sustain:{value:1,writable:!0},release:{value:0,writable:!0},getReleaseDuration:{value:function(){return this.release}},start:{value:function(e){var t=this._multiplier.gain,i=this._startAmount.gain,n=this._endAmount.gain;this._voltage.start(e),this._decayFrom=this._decayFrom=e+this.attack,this._startedAt=e;var r=this.sustain;t.cancelScheduledValues(e),i.cancelScheduledValues(e),n.cancelScheduledValues(e),n.setValueAtTime(0,e),this.attack?(t.setValueAtTime(0,e),t.linearRampToValueAtTime(1,e+this.attack),i.setValueAtTime(1,e),i.linearRampToValueAtTime(0,e+this.attack)):(t.setValueAtTime(1,e),i.setValueAtTime(0,e)),this.decay&&t.setTargetAtTime(r,this._decayFrom,Oh(this.decay))}},stop:{value:function(e,t){t&&(e-=this.release);var i=e+this.release;if(this.release){var n=this._multiplier.gain,r=this._startAmount.gain,s=this._endAmount.gain;n.cancelScheduledValues(e),r.cancelScheduledValues(e),s.cancelScheduledValues(e);var a=Oh(this.release);if(this.attack&&e=t&&(s=t);return s}(0,1,this._startedAt,this._decayFrom,e);n.linearRampToValueAtTime(o,e),r.linearRampToValueAtTime(1-o,e),r.setTargetAtTime(0,e,a)}s.setTargetAtTime(1,e,a),n.setTargetAtTime(0,e,a)}return this._voltage.stop(i),i}},onended:{get:function(){return this._voltage.onended},set:function(e){this._voltage.onended=e}}},Bh=new Float32Array([1,1]);function Dh(e){var t=e.context.createGain();return e.connect(t),t}function Oh(e){return Math.log(e+1)/Math.log(100)}var Fh=Ih,Vh={},Gh={gain:1,attack:.01,decay:.1,sustain:.9,release:.3,loop:!1,cents:0,loopStart:0,loopEnd:0};function Wh(e){return"number"==typeof e}var Uh=["attack","decay","sustain","release"];var zh=function(e,t,i){var n=!1,r=0,s={},a=e.createGain();a.gain.value=1;var o=Object.assign({},Gh,i),u={context:e,out:a,opts:o};return t instanceof AudioBuffer?u.buffer=t:u.buffers=t,u.start=function(t,i,a){if(u.buffer&&null!==t)return u.start(null,t,i);var o=t?u.buffers[t]:u.buffer;if(o){if(n){var h=a||Vh;i=Math.max(e.currentTime,i||0),u.emit("start",i,t,h);var c=l(t,o,h);return c.id=function(t,i){return i.id=r++,s[i.id]=i,i.source.onended=function(){var t=e.currentTime;i.source.disconnect(),i.env.disconnect(),i.disconnect(),u.emit("ended",t,i.id,i)},i.id}(0,c),c.env.start(i),c.source.start(i),u.emit("started",i,c.id,c),h.duration&&c.stop(i+h.duration),c}console.warn("SamplePlayer not connected to any node.")}else console.warn("Buffer "+t+" not found.")},u.play=function(e,t,i){return u.start(e,t,i)},u.stop=function(e,t){var i;return(t=t||Object.keys(s)).map((function(t){return(i=s[t])?(i.stop(e),i.id):null}))},u.connect=function(e){return n=!0,a.connect(e),u},u.emit=function(e,t,i,n){u.onevent&&u.onevent(e,t,i,n);var r=u["on"+e];r&&r(t,i,n)},u;function l(t,i,n){var r,s=e.createGain();return s.gain.value=0,s.connect(a),s.env=function(e,t,i){var n=Fh(e),r=t.adsr||i.adsr;return Uh.forEach((function(e,s){n[e]=r?r[s]:t[e]||i[e]})),n.value.value=Wh(t.gain)?t.gain:Wh(i.gain)?i.gain:1,n}(e,n,o),s.env.connect(s.gain),s.source=e.createBufferSource(),s.source.buffer=i,s.source.connect(s),s.source.loop=n.loop||o.loop,s.source.playbackRate.value=(r=n.cents||o.cents)?Math.pow(2,r/1200):1,s.source.loopStart=n.loopStart||o.loopStart,s.source.loopEnd=n.loopEnd||o.loopEnd,s.stop=function(i){var n=i||e.currentTime;u.emit("stop",n,t);var r=s.env.stop(n);s.source.stop(r)},s}},Hh=function(e){return e.on=function(t,i){if(1===arguments.length&&"function"==typeof t)return e.on("event",t);var n="on"+t,r=e[n];return e[n]=r?Xh(r,i):i,e},e};function Xh(e,t){return function(i,n,r,s){e(i,n,r,s),t(i,n,r,s)}}var Yh=/^([a-gA-G])(#{1,}|b{1,}|x{1,}|)(-?\d*)\s*(.*)\s*$/;var jh=[0,2,4,5,7,9,11];function Kh(e,t,i){if("string"!=typeof e)return null;var n=Yh.exec(e);if(!n||!t&&n[4])return null;var r={letter:n[1].toUpperCase(),acc:n[2].replace(/x/g,"##")};return r.pc=r.letter+r.acc,r.step=(r.letter.charCodeAt(0)+3)%7,r.alt="b"===r.acc[0]?-r.acc.length:r.acc.length,r.chroma=jh[r.step]+r.alt,n[3]&&(r.oct=+n[3],r.midi=r.chroma+12*(r.oct+1),r.freq=qh(r.midi,i)),t&&(r.tonicOf=n[4]),r}function qh(e,t){return Math.pow(2,(e-69)/12)*(t||440)}var Jh={parse:Kh,regex:function(){return Yh},midiToFreq:qh};["letter","acc","pc","step","alt","chroma","oct","midi","freq"].forEach((function(e){Jh[e]=function(t){var i=Kh(t);return i&&void 0!==i[e]?i[e]:null}}));var Zh=Jh,$h=function(e){return function(e){return null!==e&&e!==[]&&e>=0&&e<129}(e)?+e:Zh.midi(e)},Qh=function(e){if(e.buffers){var t=e.opts.map,i="function"==typeof t?t:$h,n=function(e){return e?i(e)||e:null};e.buffers=function(e,t){return Object.keys(e).reduce((function(i,n){return i[t(n)]=e[n],i}),{})}(e.buffers,n);var r=e.start;e.start=function(e,t,i){var s=n(e),a=s%1;return a&&(s=Math.floor(s),i=Object.assign(i||{},{cents:Math.floor(100*a)})),r(s,t,i)}}return e};var ec=Array.isArray,tc={},ic=function(e){return e.schedule=function(t,i){var n,r,s,a,o=e.context.currentTime,u=t=0&&e<128)return+e;var t=cc(e);return t&&function(e){return void 0!==e}(t.midi)?t.midi:null}var dc,pc,vc=Object.freeze(Object.defineProperty({__proto__:null,acc:function(e){return(cc(e)||{}).acc},alt:function(e){return(cc(e)||{}).alt},build:function e(t,i,n){return null==t?null:t.step?e(t.step,t.alt,t.oct):t<0||t>6?null:"CDEFGAB".charAt(t)+(oc(r=i)?r<0?ac("b",-r):ac("#",r):"")+function(e){return oc(e)?""+e:""}(n);var r},chroma:function(e){return(cc(e)||{}).chroma},freq:function(e,t){var i=fc(e);return null===i?null:uc(i,t)},letter:function(e){return(cc(e)||{}).letter},midi:fc,oct:function(e){return(cc(e)||{}).oct},parse:cc,pc:function(e){return(cc(e)||{}).pc},regex:function(){return lc},step:function(e){return(cc(e)||{}).step}},Symbol.toStringTag,{value:"Module"})),mc=l(vc);!function(e){var t=Ph,i=Ah;function n(e){return/\.js(\?.*)?$/i.test(e)}function r(e,t,i){return"https://gleitz.github.io/midi-js-soundfonts/"+(t="FluidR3_GM"===t?t:"MusyngKite")+"/"+e+"-"+(i="ogg"===i?i:"mp3")+".js"}var s=function(){if(pc)return dc;pc=1;var e=mc;function t(e,i){if(console.warn("new Soundfont() is deprected"),console.log("Please use Soundfont.instrument() instead of new Soundfont().instrument()"),!(this instanceof t))return new t(e);this.nameToUrl=i||t.nameToUrl,this.ctx=e,this.instruments={},this.promises=[]}function i(t,i){return i=i||{},function(n,r,s,a){console.warn("The oscillator player is deprecated."),console.log("Starting with version 0.9.0 you will have to wait until the soundfont is loaded to play sounds.");var o=n>0&&n<129?+n:e.midi(n),u=o?e.midiToFreq(o,440):null;if(u){s=s||.2;var l=(a=a||{}).destination||i.destination||t.destination,h=a.vcoType||i.vcoType||"sine",c=a.gain||i.gain||.4,f=t.createOscillator();f.type=h,f.frequency.value=u;var d=t.createGain();return d.gain.value=c,f.connect(d),d.connect(l),f.start(r),s>0&&f.stop(r+s),f}}}return t.prototype.onready=function(e){console.warn("deprecated API"),console.log("Please use Promise.all(Soundfont.instrument(), Soundfont.instrument()).then() instead of new Soundfont().onready()"),Promise.all(this.promises).then(e)},t.prototype.instrument=function(e,n){console.warn("new Soundfont().instrument() is deprecated."),console.log("Please use Soundfont.instrument() instead.");var r=this.ctx;if((e=e||"default")in this.instruments)return this.instruments[e];var s={name:e,play:i(r,n)};if(this.instruments[e]=s,"default"!==e){var a=t.instrument(r,e,n).then((function(e){return s.play=e.play,s}));this.promises.push(a),s.onready=function(e){console.warn("onready is deprecated. Use Soundfont.instrument().then()"),a.then(e)}}else s.onready=function(e){console.warn("onready is deprecated. Use Soundfont.instrument().then()"),e()};return s},t.loadBuffers=function(e,i,n){return console.warn("Soundfont.loadBuffers is deprecate."),console.log("Use Soundfont.instrument(..) and get buffers properties from the result."),t.instrument(e,i,n).then((function(e){return e.buffers}))},t.noteToMidi=e.midi,dc=t}();s.instrument=function e(s,a,o){if(1===arguments.length)return function(t,i){return e(s,t,i)};var u=o||{},l=u.isSoundfontURL||n,h=u.nameToUrl||r,c=l(a)?a:h(a,u.soundfont,u.format);return t(s,c,{only:u.only||u.notes}).then((function(e){var t=i(s,e,u).connect(u.destination?u.destination:s.destination);return t.url=c,t.name=a,t}))},s.nameToUrl=r,e.exports&&(e.exports=s),"undefined"!=typeof window&&(window.Soundfont=s)}(Th),Lt.C,Lt.D,Lt.E,Lt.F,Lt.G,Lt.A,Lt.B}}}))}();