vextab 7.0.0 → 7.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/runtime/auto.mjs +1 -1
- package/dist/runtime/browser.mjs +1 -1
- package/dist/runtime/parse.mjs +1 -1
- package/dist/runtime/resolve.mjs +1 -0
- package/dist/runtime/shared/J2THHOG5.mjs +1 -0
- package/dist/runtime/shared/LFV5PYP4.mjs +352 -0
- package/dist/runtime/shared/SGMFW7I5.mjs +2 -0
- package/dist/runtime/shared/TH2FBVEP.mjs +20 -0
- package/dist/runtime/types/browser.d.ts +3 -0
- package/dist/runtime/types/playback/animation.d.ts +2 -7
- package/dist/runtime/types/playback/decorations.d.ts +1 -1
- package/dist/runtime/types/playback/ink.d.ts +18 -0
- package/dist/runtime/types/playback/written-overlay.d.ts +14 -0
- package/dist/runtime/types/score/commands.d.ts +1 -1
- package/dist/runtime/types/score/drums.d.ts +1 -1
- package/dist/runtime/types/score/layout-map.d.ts +63 -0
- package/dist/runtime/types/score/layout.d.ts +9 -0
- package/dist/runtime/types/score/model.d.ts +2 -0
- package/dist/runtime/types/score/music.d.ts +1 -1
- package/dist/runtime/types/score/resolve.d.ts +7 -0
- package/dist/runtime/vextab.js +9 -9
- package/package.json +5 -1
- package/dist/runtime/shared/PRHM4TS2.mjs +0 -21
- package/dist/runtime/shared/TVARZYJR.mjs +0 -352
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
import{a as se,b as Te,c as Lt}from"./SGMFW7I5.mjs";import{a as un}from"./3EDRGUJG.mjs";import{b as sn}from"./WEGSFFPO.mjs";import{a as xt,b as an,c as _e,d as cn,e as ie,f as ln,g as vt}from"./J2THHOG5.mjs";import{a as Pt,b as rt,c as te,d as J,e as mt,f as Ke,g as Ze,h as ee,i as Qe,j as tn,k as ne,l as yt,m as Ft,n as re,p as en,q as nn,t as nt,u as rn,v as oe,w as on}from"./TH2FBVEP.mjs";import{a as Je,b as ir}from"./7VX7ANVZ.mjs";var Nn=Je((_n,An)=>{(function(a,t){typeof define=="function"&&define.amd?define(function(){return t(a)}):t(a)})(_n,function(){var a=(function(){var t,e,n,r,o=[],s=o.concat,i=o.filter,c=o.slice,l=window.document,d={},m={},f={"column-count":1,columns:1,"font-weight":1,"line-height":1,opacity:1,"z-index":1,zoom:1},h=/^\s*<(\w+|!)[^>]*>/,g=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,y=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,b=/^(?:body|html)$/i,S=/([A-Z])/g,T=["val","css","html","text","data","width","height","offset"],A=["after","prepend","before","append"],k=l.createElement("table"),p=l.createElement("tr"),_={tr:l.createElement("tbody"),tbody:k,thead:k,tfoot:k,td:p,th:p,"*":l.createElement("div")},L=/complete|loaded|interactive/,B=/^[\w-]*$/,H={},P=H.toString,x={},C,v,E=l.createElement("div"),R={tabindex:"tabIndex",readonly:"readOnly",for:"htmlFor",class:"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},I=Array.isArray||function(u){return u instanceof Array};x.matches=function(u,w){if(!w||!u||u.nodeType!==1)return!1;var M=u.matches||u.webkitMatchesSelector||u.mozMatchesSelector||u.oMatchesSelector||u.matchesSelector;if(M)return M.call(u,w);var F,X=u.parentNode,Y=!X;return Y&&(X=E).appendChild(u),F=~x.qsa(X,w).indexOf(u),Y&&E.removeChild(u),F};function D(u){return u==null?String(u):H[P.call(u)]||"object"}function G(u){return D(u)=="function"}function $(u){return u!=null&&u==u.window}function j(u){return u!=null&&u.nodeType==u.DOCUMENT_NODE}function Q(u){return D(u)=="object"}function K(u){return Q(u)&&!$(u)&&Object.getPrototypeOf(u)==Object.prototype}function z(u){var w=!!u&&"length"in u&&u.length,M=n.type(u);return M!="function"&&!$(u)&&(M=="array"||w===0||typeof w=="number"&&w>0&&w-1 in u)}function V(u){return i.call(u,function(w){return w!=null})}function O(u){return u.length>0?n.fn.concat.apply([],u):u}C=function(u){return u.replace(/-+(.)?/g,function(w,M){return M?M.toUpperCase():""})};function q(u){return u.replace(/::/g,"/").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/_/g,"-").toLowerCase()}v=function(u){return i.call(u,function(w,M){return u.indexOf(w)==M})};function U(u){return u in m?m[u]:m[u]=new RegExp("(^|\\s)"+u+"(\\s|$)")}function W(u,w){return typeof w=="number"&&!f[q(u)]?w+"px":w}function Z(u){var w,M;return d[u]||(w=l.createElement(u),l.body.appendChild(w),M=getComputedStyle(w,"").getPropertyValue("display"),w.parentNode.removeChild(w),M=="none"&&(M="block"),d[u]=M),d[u]}function tt(u){return"children"in u?c.call(u.children):n.map(u.childNodes,function(w){if(w.nodeType==1)return w})}function et(u,w){var M,F=u?u.length:0;for(M=0;M<F;M++)this[M]=u[M];this.length=F,this.selector=w||""}x.fragment=function(u,w,M){var F,X,Y;return g.test(u)&&(F=n(l.createElement(RegExp.$1))),F||(u.replace&&(u=u.replace(y,"<$1></$2>")),w===t&&(w=h.test(u)&&RegExp.$1),w in _||(w="*"),Y=_[w],Y.innerHTML=""+u,F=n.each(c.call(Y.childNodes),function(){Y.removeChild(this)})),K(M)&&(X=n(F),n.each(M,function(ht,pt){T.indexOf(ht)>-1?X[ht](pt):X.attr(ht,pt)})),F},x.Z=function(u,w){return new et(u,w)},x.isZ=function(u){return u instanceof x.Z},x.init=function(u,w){var M;if(u)if(typeof u=="string")if(u=u.trim(),u[0]=="<"&&h.test(u))M=x.fragment(u,RegExp.$1,w),u=null;else{if(w!==t)return n(w).find(u);M=x.qsa(l,u)}else{if(G(u))return n(l).ready(u);if(x.isZ(u))return u;if(I(u))M=V(u);else if(Q(u))M=[u],u=null;else if(h.test(u))M=x.fragment(u.trim(),RegExp.$1,w),u=null;else{if(w!==t)return n(w).find(u);M=x.qsa(l,u)}}else return x.Z();return x.Z(M,u)},n=function(u,w){return x.init(u,w)};function st(u,w,M){for(e in w)M&&(K(w[e])||I(w[e]))?(K(w[e])&&!K(u[e])&&(u[e]={}),I(w[e])&&!I(u[e])&&(u[e]=[]),st(u[e],w[e],M)):w[e]!==t&&(u[e]=w[e])}n.extend=function(u){var w,M=c.call(arguments,1);return typeof u=="boolean"&&(w=u,u=M.shift()),M.forEach(function(F){st(u,F,w)}),u},x.qsa=function(u,w){var M,F=w[0]=="#",X=!F&&w[0]==".",Y=F||X?w.slice(1):w,ht=B.test(Y);return u.getElementById&&ht&&F?(M=u.getElementById(Y))?[M]:[]:u.nodeType!==1&&u.nodeType!==9&&u.nodeType!==11?[]:c.call(ht&&!F&&u.getElementsByClassName?X?u.getElementsByClassName(Y):u.getElementsByTagName(w):u.querySelectorAll(w))};function ot(u,w){return w==null?n(u):n(u).filter(w)}n.contains=l.documentElement.contains?function(u,w){return u!==w&&u.contains(w)}:function(u,w){for(;w&&(w=w.parentNode);)if(w===u)return!0;return!1};function at(u,w,M,F){return G(w)?w.call(u,M,F):w}function ut(u,w,M){M==null?u.removeAttribute(w):u.setAttribute(w,M)}function dt(u,w){var M=u.className||"",F=M&&M.baseVal!==t;if(w===t)return F?M.baseVal:M;F?M.baseVal=w:u.className=w}function Ye(u){try{return u&&(u=="true"||(u=="false"?!1:u=="null"?null:+u+""==u?+u:/^[\[\{]/.test(u)?n.parseJSON(u):u))}catch{return u}}n.type=D,n.isFunction=G,n.isWindow=$,n.isArray=I,n.isPlainObject=K,n.isEmptyObject=function(u){var w;for(w in u)return!1;return!0},n.isNumeric=function(u){var w=Number(u),M=typeof u;return u!=null&&M!="boolean"&&(M!="string"||u.length)&&!isNaN(w)&&isFinite(w)||!1},n.inArray=function(u,w,M){return o.indexOf.call(w,u,M)},n.camelCase=C,n.trim=function(u){return u==null?"":String.prototype.trim.call(u)},n.uuid=0,n.support={},n.expr={},n.noop=function(){},n.map=function(u,w){var M,F=[],X,Y;if(z(u))for(X=0;X<u.length;X++)M=w(u[X],X),M!=null&&F.push(M);else for(Y in u)M=w(u[Y],Y),M!=null&&F.push(M);return O(F)},n.each=function(u,w){var M,F;if(z(u)){for(M=0;M<u.length;M++)if(w.call(u[M],M,u[M])===!1)return u}else for(F in u)if(w.call(u[F],F,u[F])===!1)return u;return u},n.grep=function(u,w){return i.call(u,w)},window.JSON&&(n.parseJSON=JSON.parse),n.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(u,w){H["[object "+w+"]"]=w.toLowerCase()}),n.fn={constructor:x.Z,length:0,forEach:o.forEach,reduce:o.reduce,push:o.push,sort:o.sort,splice:o.splice,indexOf:o.indexOf,concat:function(){var u,w,M=[];for(u=0;u<arguments.length;u++)w=arguments[u],M[u]=x.isZ(w)?w.toArray():w;return s.apply(x.isZ(this)?this.toArray():this,M)},map:function(u){return n(n.map(this,function(w,M){return u.call(w,M,w)}))},slice:function(){return n(c.apply(this,arguments))},ready:function(u){return L.test(l.readyState)&&l.body?u(n):l.addEventListener("DOMContentLoaded",function(){u(n)},!1),this},get:function(u){return u===t?c.call(this):this[u>=0?u:u+this.length]},toArray:function(){return this.get()},size:function(){return this.length},remove:function(){return this.each(function(){this.parentNode!=null&&this.parentNode.removeChild(this)})},each:function(u){return o.every.call(this,function(w,M){return u.call(w,M,w)!==!1}),this},filter:function(u){return G(u)?this.not(this.not(u)):n(i.call(this,function(w){return x.matches(w,u)}))},add:function(u,w){return n(v(this.concat(n(u,w))))},is:function(u){return this.length>0&&x.matches(this[0],u)},not:function(u){var w=[];if(G(u)&&u.call!==t)this.each(function(F){u.call(this,F)||w.push(this)});else{var M=typeof u=="string"?this.filter(u):z(u)&&G(u.item)?c.call(u):n(u);this.forEach(function(F){M.indexOf(F)<0&&w.push(F)})}return n(w)},has:function(u){return this.filter(function(){return Q(u)?n.contains(this,u):n(this).find(u).size()})},eq:function(u){return u===-1?this.slice(u):this.slice(u,+u+1)},first:function(){var u=this[0];return u&&!Q(u)?u:n(u)},last:function(){var u=this[this.length-1];return u&&!Q(u)?u:n(u)},find:function(u){var w,M=this;return u?typeof u=="object"?w=n(u).filter(function(){var F=this;return o.some.call(M,function(X){return n.contains(X,F)})}):this.length==1?w=n(x.qsa(this[0],u)):w=this.map(function(){return x.qsa(this,u)}):w=n(),w},closest:function(u,w){var M=[],F=typeof u=="object"&&n(u);return this.each(function(X,Y){for(;Y&&!(F?F.indexOf(Y)>=0:x.matches(Y,u));)Y=Y!==w&&!j(Y)&&Y.parentNode;Y&&M.indexOf(Y)<0&&M.push(Y)}),n(M)},parents:function(u){for(var w=[],M=this;M.length>0;)M=n.map(M,function(F){if((F=F.parentNode)&&!j(F)&&w.indexOf(F)<0)return w.push(F),F});return ot(w,u)},parent:function(u){return ot(v(this.pluck("parentNode")),u)},children:function(u){return ot(this.map(function(){return tt(this)}),u)},contents:function(){return this.map(function(){return this.contentDocument||c.call(this.childNodes)})},siblings:function(u){return ot(this.map(function(w,M){return i.call(tt(M.parentNode),function(F){return F!==M})}),u)},empty:function(){return this.each(function(){this.innerHTML=""})},pluck:function(u){return n.map(this,function(w){return w[u]})},show:function(){return this.each(function(){this.style.display=="none"&&(this.style.display=""),getComputedStyle(this,"").getPropertyValue("display")=="none"&&(this.style.display=Z(this.nodeName))})},replaceWith:function(u){return this.before(u).remove()},wrap:function(u){var w=G(u);if(this[0]&&!w)var M=n(u).get(0),F=M.parentNode||this.length>1;return this.each(function(X){n(this).wrapAll(w?u.call(this,X):F?M.cloneNode(!0):M)})},wrapAll:function(u){if(this[0]){n(this[0]).before(u=n(u));for(var w;(w=u.children()).length;)u=w.first();n(u).append(this)}return this},wrapInner:function(u){var w=G(u);return this.each(function(M){var F=n(this),X=F.contents(),Y=w?u.call(this,M):u;X.length?X.wrapAll(Y):F.append(Y)})},unwrap:function(){return this.parent().each(function(){n(this).replaceWith(n(this).children())}),this},clone:function(){return this.map(function(){return this.cloneNode(!0)})},hide:function(){return this.css("display","none")},toggle:function(u){return this.each(function(){var w=n(this);(u===t?w.css("display")=="none":u)?w.show():w.hide()})},prev:function(u){return n(this.pluck("previousElementSibling")).filter(u||"*")},next:function(u){return n(this.pluck("nextElementSibling")).filter(u||"*")},html:function(u){return 0 in arguments?this.each(function(w){var M=this.innerHTML;n(this).empty().append(at(this,u,w,M))}):0 in this?this[0].innerHTML:null},text:function(u){return 0 in arguments?this.each(function(w){var M=at(this,u,w,this.textContent);this.textContent=M==null?"":""+M}):0 in this?this.pluck("textContent").join(""):null},attr:function(u,w){var M;return typeof u=="string"&&!(1 in arguments)?0 in this&&this[0].nodeType==1&&(M=this[0].getAttribute(u))!=null?M:t:this.each(function(F){if(this.nodeType===1)if(Q(u))for(e in u)ut(this,e,u[e]);else ut(this,u,at(this,w,F,this.getAttribute(u)))})},removeAttr:function(u){return this.each(function(){this.nodeType===1&&u.split(" ").forEach(function(w){ut(this,w)},this)})},prop:function(u,w){return u=R[u]||u,1 in arguments?this.each(function(M){this[u]=at(this,w,M,this[u])}):this[0]&&this[0][u]},removeProp:function(u){return u=R[u]||u,this.each(function(){delete this[u]})},data:function(u,w){var M="data-"+u.replace(S,"-$1").toLowerCase(),F=1 in arguments?this.attr(M,w):this.attr(M);return F!==null?Ye(F):t},val:function(u){return 0 in arguments?(u==null&&(u=""),this.each(function(w){this.value=at(this,u,w,this.value)})):this[0]&&(this[0].multiple?n(this[0]).find("option").filter(function(){return this.selected}).pluck("value"):this[0].value)},offset:function(u){if(u)return this.each(function(M){var F=n(this),X=at(this,u,M,F.offset()),Y=F.offsetParent().offset(),ht={top:X.top-Y.top,left:X.left-Y.left};F.css("position")=="static"&&(ht.position="relative"),F.css(ht)});if(!this.length)return null;if(l.documentElement!==this[0]&&!n.contains(l.documentElement,this[0]))return{top:0,left:0};var w=this[0].getBoundingClientRect();return{left:w.left+window.pageXOffset,top:w.top+window.pageYOffset,width:Math.round(w.width),height:Math.round(w.height)}},css:function(u,w){if(arguments.length<2){var M=this[0];if(typeof u=="string")return M?M.style[C(u)]||getComputedStyle(M,"").getPropertyValue(u):void 0;if(I(u)){if(!M)return;var F={},X=getComputedStyle(M,"");return n.each(u,function(ht,pt){F[pt]=M.style[C(pt)]||X.getPropertyValue(pt)}),F}}var Y="";if(D(u)=="string")!w&&w!==0?this.each(function(){this.style.removeProperty(q(u))}):Y=q(u)+":"+W(u,w);else for(e in u)!u[e]&&u[e]!==0?this.each(function(){this.style.removeProperty(q(e))}):Y+=q(e)+":"+W(e,u[e])+";";return this.each(function(){this.style.cssText+=";"+Y})},index:function(u){return u?this.indexOf(n(u)[0]):this.parent().children().indexOf(this[0])},hasClass:function(u){return u?o.some.call(this,function(w){return this.test(dt(w))},U(u)):!1},addClass:function(u){return u?this.each(function(w){if("className"in this){r=[];var M=dt(this),F=at(this,u,w,M);F.split(/\s+/g).forEach(function(X){n(this).hasClass(X)||r.push(X)},this),r.length&&dt(this,M+(M?" ":"")+r.join(" "))}}):this},removeClass:function(u){return this.each(function(w){if("className"in this){if(u===t)return dt(this,"");r=dt(this),at(this,u,w,r).split(/\s+/g).forEach(function(M){r=r.replace(U(M)," ")}),dt(this,r.trim())}})},toggleClass:function(u,w){return u?this.each(function(M){var F=n(this),X=at(this,u,M,dt(this));X.split(/\s+/g).forEach(function(Y){(w===t?!F.hasClass(Y):w)?F.addClass(Y):F.removeClass(Y)})}):this},scrollTop:function(u){if(this.length){var w="scrollTop"in this[0];return u===t?w?this[0].scrollTop:this[0].pageYOffset:this.each(w?function(){this.scrollTop=u}:function(){this.scrollTo(this.scrollX,u)})}},scrollLeft:function(u){if(this.length){var w="scrollLeft"in this[0];return u===t?w?this[0].scrollLeft:this[0].pageXOffset:this.each(w?function(){this.scrollLeft=u}:function(){this.scrollTo(u,this.scrollY)})}},position:function(){if(this.length){var u=this[0],w=this.offsetParent(),M=this.offset(),F=b.test(w[0].nodeName)?{top:0,left:0}:w.offset();return M.top-=parseFloat(n(u).css("margin-top"))||0,M.left-=parseFloat(n(u).css("margin-left"))||0,F.top+=parseFloat(n(w[0]).css("border-top-width"))||0,F.left+=parseFloat(n(w[0]).css("border-left-width"))||0,{top:M.top-F.top,left:M.left-F.left}}},offsetParent:function(){return this.map(function(){for(var u=this.offsetParent||l.body;u&&!b.test(u.nodeName)&&n(u).css("position")=="static";)u=u.offsetParent;return u})}},n.fn.detach=n.fn.remove,["width","height"].forEach(function(u){var w=u.replace(/./,function(M){return M[0].toUpperCase()});n.fn[u]=function(M){var F,X=this[0];return M===t?$(X)?X["inner"+w]:j(X)?X.documentElement["scroll"+w]:(F=this.offset())&&F[u]:this.each(function(Y){X=n(this),X.css(u,at(this,M,Y,X[u]()))})}});function Xe(u,w){w(u);for(var M=0,F=u.childNodes.length;M<F;M++)Xe(u.childNodes[M],w)}return A.forEach(function(u,w){var M=w%2;n.fn[u]=function(){var F,X=n.map(arguments,function(pt){var ft=[];return F=D(pt),F=="array"?(pt.forEach(function(_t){if(_t.nodeType!==t)return ft.push(_t);if(n.zepto.isZ(_t))return ft=ft.concat(_t.get());ft=ft.concat(x.fragment(_t))}),ft):F=="object"||pt==null?pt:x.fragment(pt)}),Y,ht=this.length>1;return X.length<1?this:this.each(function(pt,ft){Y=M?ft:ft.parentNode,ft=w==0?ft.nextSibling:w==1?ft.firstChild:w==2?ft:null;var _t=n.contains(l.documentElement,Y);X.forEach(function(Ut){if(ht)Ut=Ut.cloneNode(!0);else if(!Y)return n(Ut).remove();Y.insertBefore(Ut,ft),_t&&Xe(Ut,function(Et){if(Et.nodeName!=null&&Et.nodeName.toUpperCase()==="SCRIPT"&&(!Et.type||Et.type==="text/javascript")&&!Et.src){var $e=Et.ownerDocument?Et.ownerDocument.defaultView:window;$e.eval.call($e,Et.innerHTML)}})})})},n.fn[M?u+"To":"insert"+(w?"Before":"After")]=function(F){return n(F)[u](this),this}}),x.Z.prototype=et.prototype=n.fn,x.uniq=v,x.deserializeValue=Ye,n.zepto=x,n})();return window.Zepto=a,window.$===void 0&&(window.$=a),An.exports=a,(function(t){var e=1,n,r=Array.prototype.slice,o=t.isFunction,s=function(P){return typeof P=="string"},i={},c={},l="onfocusin"in window,d={focus:"focusin",blur:"focusout"},m={mouseenter:"mouseover",mouseleave:"mouseout"};c.click=c.mousedown=c.mouseup=c.mousemove="MouseEvents";function f(P){return P._zid||(P._zid=e++)}function h(P,x,C,v){if(x=g(x),x.ns)var E=y(x.ns);return(i[f(P)]||[]).filter(function(R){return R&&(!x.e||R.e==x.e)&&(!x.ns||E.test(R.ns))&&(!C||f(R.fn)===f(C))&&(!v||R.sel==v)})}function g(P){var x=(""+P).split(".");return{e:x[0],ns:x.slice(1).sort().join(" ")}}function y(P){return new RegExp("(?:^| )"+P.replace(" "," .* ?")+"(?: |$)")}function b(P,x){return P.del&&!l&&P.e in d||!!x}function S(P){return m[P]||l&&d[P]||P}function T(P,x,C,v,E,R,I){var D=f(P),G=i[D]||(i[D]=[]);x.split(/\s/).forEach(function($){if($=="ready")return t(document).ready(C);var j=g($);j.fn=C,j.sel=E,j.e in m&&(C=function(K){var z=K.relatedTarget;if(!z||z!==this&&!t.contains(this,z))return j.fn.apply(this,arguments)}),j.del=R;var Q=R||C;j.proxy=function(K){if(K=B(K),!K.isImmediatePropagationStopped()){K.data=v;var z=Q.apply(P,K._args==n?[K]:[K].concat(K._args));return z===!1&&(K.preventDefault(),K.stopPropagation()),z}},j.i=G.length,G.push(j),"addEventListener"in P&&P.addEventListener(S(j.e),j.proxy,b(j,I))})}function A(P,x,C,v,E){var R=f(P);(x||"").split(/\s/).forEach(function(I){h(P,I,C,v).forEach(function(D){delete i[R][D.i],"removeEventListener"in P&&P.removeEventListener(S(D.e),D.proxy,b(D,E))})})}t.event={add:T,remove:A},t.proxy=function(P,x){var C=2 in arguments&&r.call(arguments,2);if(o(P)){var v=function(){return P.apply(x,C?C.concat(r.call(arguments)):arguments)};return v._zid=f(P),v}else{if(s(x))return C?(C.unshift(P[x],P),t.proxy.apply(null,C)):t.proxy(P[x],P);throw new TypeError("expected function")}},t.fn.bind=function(P,x,C){return this.on(P,x,C)},t.fn.unbind=function(P,x){return this.off(P,x)},t.fn.one=function(P,x,C,v){return this.on(P,x,C,v,1)};var k=function(){return!0},p=function(){return!1},_=/^([A-Z]|returnValue$|layer[XY]$|webkitMovement[XY]$)/,L={preventDefault:"isDefaultPrevented",stopImmediatePropagation:"isImmediatePropagationStopped",stopPropagation:"isPropagationStopped"};function B(P,x){return(x||!P.isDefaultPrevented)&&(x||(x=P),t.each(L,function(C,v){var E=x[C];P[C]=function(){return this[v]=k,E&&E.apply(x,arguments)},P[v]=p}),P.timeStamp||(P.timeStamp=Date.now()),(x.defaultPrevented!==n?x.defaultPrevented:"returnValue"in x?x.returnValue===!1:x.getPreventDefault&&x.getPreventDefault())&&(P.isDefaultPrevented=k)),P}function H(P){var x,C={originalEvent:P};for(x in P)!_.test(x)&&P[x]!==n&&(C[x]=P[x]);return B(C,P)}t.fn.delegate=function(P,x,C){return this.on(x,P,C)},t.fn.undelegate=function(P,x,C){return this.off(x,P,C)},t.fn.live=function(P,x){return t(document.body).delegate(this.selector,P,x),this},t.fn.die=function(P,x){return t(document.body).undelegate(this.selector,P,x),this},t.fn.on=function(P,x,C,v,E){var R,I,D=this;return P&&!s(P)?(t.each(P,function(G,$){D.on(G,x,C,$,E)}),D):(!s(x)&&!o(v)&&v!==!1&&(v=C,C=x,x=n),(v===n||C===!1)&&(v=C,C=n),v===!1&&(v=p),D.each(function(G,$){E&&(R=function(j){return A($,j.type,v),v.apply(this,arguments)}),x&&(I=function(j){var Q,K=t(j.target).closest(x,$).get(0);if(K&&K!==$)return Q=t.extend(H(j),{currentTarget:K,liveFired:$}),(R||v).apply(K,[Q].concat(r.call(arguments,1)))}),T($,P,v,C,x,I||R)}))},t.fn.off=function(P,x,C){var v=this;return P&&!s(P)?(t.each(P,function(E,R){v.off(E,x,R)}),v):(!s(x)&&!o(C)&&C!==!1&&(C=x,x=n),C===!1&&(C=p),v.each(function(){A(this,P,C,x)}))},t.fn.trigger=function(P,x){return P=s(P)||t.isPlainObject(P)?t.Event(P):B(P),P._args=x,this.each(function(){P.type in d&&typeof this[P.type]=="function"?this[P.type]():"dispatchEvent"in this?this.dispatchEvent(P):t(this).triggerHandler(P,x)})},t.fn.triggerHandler=function(P,x){var C,v;return this.each(function(E,R){C=H(s(P)?t.Event(P):P),C._args=x,C.target=R,t.each(h(R,P.type||P),function(I,D){if(v=D.proxy(C),C.isImmediatePropagationStopped())return!1})}),v},"focusin focusout focus blur load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select keydown keypress keyup error".split(" ").forEach(function(P){t.fn[P]=function(x){return 0 in arguments?this.bind(P,x):this.trigger(P)}}),t.Event=function(P,x){s(P)||(x=P,P=x.type);var C=document.createEvent(c[P]||"Events"),v=!0;if(x)for(var E in x)E=="bubbles"?v=!!x[E]:C[E]=x[E];return C.initEvent(P,v,!0),B(C)}})(a),(function(t){var e=+new Date,n=window.document,r,o,s=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,i=/^(?:text|application)\/javascript/i,c=/^(?:text|application)\/xml/i,l="application/json",d="text/html",m=/^\s*$/,f=n.createElement("a");f.href=window.location.href;function h(v,E,R){var I=t.Event(E);return t(v).trigger(I,R),!I.isDefaultPrevented()}function g(v,E,R,I){if(v.global)return h(E||n,R,I)}t.active=0;function y(v){v.global&&t.active++===0&&g(v,null,"ajaxStart")}function b(v){v.global&&!--t.active&&g(v,null,"ajaxStop")}function S(v,E){var R=E.context;if(E.beforeSend.call(R,v,E)===!1||g(E,R,"ajaxBeforeSend",[v,E])===!1)return!1;g(E,R,"ajaxSend",[v,E])}function T(v,E,R,I){var D=R.context,G="success";R.success.call(D,v,G,E),I&&I.resolveWith(D,[v,G,E]),g(R,D,"ajaxSuccess",[E,R,v]),k(G,E,R)}function A(v,E,R,I,D){var G=I.context;I.error.call(G,R,E,v),D&&D.rejectWith(G,[R,E,v]),g(I,G,"ajaxError",[R,I,v||E]),k(E,R,I)}function k(v,E,R){var I=R.context;R.complete.call(I,E,v),g(R,I,"ajaxComplete",[E,R]),b(R)}function p(v,E,R){if(R.dataFilter==_)return v;var I=R.context;return R.dataFilter.call(I,v,E)}function _(){}t.ajaxJSONP=function(v,E){if(!("type"in v))return t.ajax(v);var R=v.jsonpCallback,I=(t.isFunction(R)?R():R)||"Zepto"+e++,D=n.createElement("script"),G=window[I],$,j=function(z){t(D).triggerHandler("error",z||"abort")},Q={abort:j},K;return E&&E.promise(Q),t(D).on("load error",function(z,V){clearTimeout(K),t(D).off().remove(),z.type=="error"||!$?A(null,V||"error",Q,v,E):T($[0],Q,v,E),window[I]=G,$&&t.isFunction(G)&&G($[0]),G=$=void 0}),S(Q,v)===!1?(j("abort"),Q):(window[I]=function(){$=arguments},D.src=v.url.replace(/\?(.+)=\?/,"?$1="+I),n.head.appendChild(D),v.timeout>0&&(K=setTimeout(function(){j("timeout")},v.timeout)),Q)},t.ajaxSettings={type:"GET",beforeSend:_,success:_,error:_,complete:_,context:null,global:!0,xhr:function(){return new window.XMLHttpRequest},accepts:{script:"text/javascript, application/javascript, application/x-javascript",json:l,xml:"application/xml, text/xml",html:d,text:"text/plain"},crossDomain:!1,timeout:0,processData:!0,cache:!0,dataFilter:_};function L(v){return v&&(v=v.split(";",2)[0]),v&&(v==d?"html":v==l?"json":i.test(v)?"script":c.test(v)&&"xml")||"text"}function B(v,E){return E==""?v:(v+"&"+E).replace(/[&?]{1,2}/,"?")}function H(v){v.processData&&v.data&&t.type(v.data)!="string"&&(v.data=t.param(v.data,v.traditional)),v.data&&(!v.type||v.type.toUpperCase()=="GET"||v.dataType=="jsonp")&&(v.url=B(v.url,v.data),v.data=void 0)}t.ajax=function(v){var E=t.extend({},v||{}),R=t.Deferred&&t.Deferred(),I,D;for(r in t.ajaxSettings)E[r]===void 0&&(E[r]=t.ajaxSettings[r]);y(E),E.crossDomain||(I=n.createElement("a"),I.href=E.url,I.href=I.href,E.crossDomain=f.protocol+"//"+f.host!=I.protocol+"//"+I.host),E.url||(E.url=window.location.toString()),(D=E.url.indexOf("#"))>-1&&(E.url=E.url.slice(0,D)),H(E);var G=E.dataType,$=/\?.+=\?/.test(E.url);if($&&(G="jsonp"),(E.cache===!1||(!v||v.cache!==!0)&&(G=="script"||G=="jsonp"))&&(E.url=B(E.url,"_="+Date.now())),G=="jsonp")return $||(E.url=B(E.url,E.jsonp?E.jsonp+"=?":E.jsonp===!1?"":"callback=?")),t.ajaxJSONP(E,R);var j=E.accepts[G],Q={},K=function(W,Z){Q[W.toLowerCase()]=[W,Z]},z=/^([\w-]+:)\/\//.test(E.url)?RegExp.$1:window.location.protocol,V=E.xhr(),O=V.setRequestHeader,q;if(R&&R.promise(V),E.crossDomain||K("X-Requested-With","XMLHttpRequest"),K("Accept",j||"*/*"),(j=E.mimeType||j)&&(j.indexOf(",")>-1&&(j=j.split(",",2)[0]),V.overrideMimeType&&V.overrideMimeType(j)),(E.contentType||E.contentType!==!1&&E.data&&E.type.toUpperCase()!="GET")&&K("Content-Type",E.contentType||"application/x-www-form-urlencoded"),E.headers)for(o in E.headers)K(o,E.headers[o]);if(V.setRequestHeader=K,V.onreadystatechange=function(){if(V.readyState==4){V.onreadystatechange=_,clearTimeout(q);var W,Z=!1;if(V.status>=200&&V.status<300||V.status==304||V.status==0&&z=="file:"){if(G=G||L(E.mimeType||V.getResponseHeader("content-type")),V.responseType=="arraybuffer"||V.responseType=="blob")W=V.response;else{W=V.responseText;try{W=p(W,G,E),G=="script"?(0,eval)(W):G=="xml"?W=V.responseXML:G=="json"&&(W=m.test(W)?null:t.parseJSON(W))}catch(tt){Z=tt}if(Z)return A(Z,"parsererror",V,E,R)}T(W,V,E,R)}else A(V.statusText||null,V.status?"error":"abort",V,E,R)}},S(V,E)===!1)return V.abort(),A(null,"abort",V,E,R),V;var U="async"in E?E.async:!0;if(V.open(E.type,E.url,U,E.username,E.password),E.xhrFields)for(o in E.xhrFields)V[o]=E.xhrFields[o];for(o in Q)O.apply(V,Q[o]);return E.timeout>0&&(q=setTimeout(function(){V.onreadystatechange=_,V.abort(),A(null,"timeout",V,E,R)},E.timeout)),V.send(E.data?E.data:null),V};function P(v,E,R,I){return t.isFunction(E)&&(I=R,R=E,E=void 0),t.isFunction(R)||(I=R,R=void 0),{url:v,data:E,success:R,dataType:I}}t.get=function(){return t.ajax(P.apply(null,arguments))},t.post=function(){var v=P.apply(null,arguments);return v.type="POST",t.ajax(v)},t.getJSON=function(){var v=P.apply(null,arguments);return v.dataType="json",t.ajax(v)},t.fn.load=function(v,E,R){if(!this.length)return this;var I=this,D=v.split(/\s/),G,$=P(v,E,R),j=$.success;return D.length>1&&($.url=D[0],G=D[1]),$.success=function(Q){I.html(G?t("<div>").html(Q.replace(s,"")).find(G):Q),j&&j.apply(I,arguments)},t.ajax($),this};var x=encodeURIComponent;function C(v,E,R,I){var D,G=t.isArray(E),$=t.isPlainObject(E);t.each(E,function(j,Q){D=t.type(Q),I&&(j=R?I:I+"["+($||D=="object"||D=="array"?j:"")+"]"),!I&&G?v.add(Q.name,Q.value):D=="array"||!R&&D=="object"?C(v,Q,R,j):v.add(j,Q)})}t.param=function(v,E){var R=[];return R.add=function(I,D){t.isFunction(D)&&(D=D()),D==null&&(D=""),this.push(x(I)+"="+x(D))},C(R,v,E),R.join("&").replace(/%20/g,"+")}})(a),(function(t){t.fn.serializeArray=function(){var e,n,r=[],o=function(s){if(s.forEach)return s.forEach(o);r.push({name:e,value:s})};return this[0]&&t.each(this[0].elements,function(s,i){n=i.type,e=i.name,e&&i.nodeName.toLowerCase()!="fieldset"&&!i.disabled&&n!="submit"&&n!="reset"&&n!="button"&&n!="file"&&(n!="radio"&&n!="checkbox"||i.checked)&&o(t(i).val())}),r},t.fn.serialize=function(){var e=[];return this.serializeArray().forEach(function(n){e.push(encodeURIComponent(n.name)+"="+encodeURIComponent(n.value))}),e.join("&")},t.fn.submit=function(e){if(0 in arguments)this.bind("submit",e);else if(this.length){var n=t.Event("submit");this.eq(0).trigger(n),n.isDefaultPrevented()||this.get(0).submit()}return this}})(a),(function(){try{getComputedStyle(void 0)}catch{var t=getComputedStyle;window.getComputedStyle=function(n,r){try{return t(n,r)}catch{return null}}}})(),a})});var sr=Je(()=>{var or=document.createElement("style");or.textContent=`/* Score and editor styles for the browser embed. */
|
|
2
|
+
div.vextab-auto {
|
|
3
|
+
font-family: Academico, Georgia, serif;
|
|
4
|
+
font-size: 18px;
|
|
5
|
+
color: #554;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
div.vextab-auto .editor {
|
|
9
|
+
background: #dfd;
|
|
10
|
+
border: 0 solid #afa;
|
|
11
|
+
border-left: 6px solid #afa;
|
|
12
|
+
font-family: Consolas, "Andale Mono WT", "Andale Mono", "Lucida Console", "Lucida Sans Typewriter", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Liberation Mono", "Nimbus Mono L", Monaco, "Courier New", Courier, monospace;
|
|
13
|
+
font-size: 14px;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
div.vextab-auto .editor-error, .vex-tabdiv .editor-error {
|
|
17
|
+
font: 14px/1.4 monospace;
|
|
18
|
+
color: #9b241e;
|
|
19
|
+
white-space: pre-wrap;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
div.vextab-auto .title {
|
|
23
|
+
font-family: Academico, Georgia, serif;
|
|
24
|
+
font-size: 18px;
|
|
25
|
+
padding: 10px;
|
|
26
|
+
color: #554;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.vex-canvas[data-preview-stale="true"] {
|
|
30
|
+
opacity: 0.65;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/* An indivisible bar can scroll inside a narrow flow embed. */
|
|
34
|
+
.vextab-flow > .vex-canvas { max-width: 100%; overflow-x: auto; }
|
|
35
|
+
.vextab-flow textarea.editor { max-width: 100%; box-sizing: border-box; }
|
|
36
|
+
|
|
37
|
+
/* The sheet takes its size from the score. Only the controls intercept pointer events. */
|
|
38
|
+
.vextab-sheet {
|
|
39
|
+
position: relative;
|
|
40
|
+
width: fit-content;
|
|
41
|
+
max-width: 100%;
|
|
42
|
+
isolation: isolate;
|
|
43
|
+
display: grid;
|
|
44
|
+
}
|
|
45
|
+
.vextab-sheet > :is(svg, canvas, .vextab-playback-page, .vextab-transport) { grid-area: 1 / 1; }
|
|
46
|
+
.vextab-sheet > :is(svg, canvas) { display: block; }
|
|
47
|
+
.vextab-transport { position: relative; min-width: 0; pointer-events: none; container-type: inline-size; }
|
|
48
|
+
.vextab-canvas-ink, .vextab-sheet-controls {
|
|
49
|
+
position: absolute;
|
|
50
|
+
inset: 0;
|
|
51
|
+
pointer-events: none;
|
|
52
|
+
}
|
|
53
|
+
.vextab-transport > .vextab-canvas-ink { width: 100%; height: 100%; }
|
|
54
|
+
.vextab-sheet-controls {
|
|
55
|
+
--control-events: none;
|
|
56
|
+
--ink: #244f43;
|
|
57
|
+
--edge: #aaa697;
|
|
58
|
+
--control-size: 32px;
|
|
59
|
+
--panel-height: var(--control-size);
|
|
60
|
+
--control-gap: 6px;
|
|
61
|
+
--control-paper: #faf9f5;
|
|
62
|
+
--control-hover: #f0ede3;
|
|
63
|
+
--shadow: 0 1px 2px rgb(57 49 31 / 10%), 0 2px 6px rgb(57 49 31 / 9%);
|
|
64
|
+
display: flex;
|
|
65
|
+
justify-content: center;
|
|
66
|
+
align-items: end;
|
|
67
|
+
box-sizing: border-box;
|
|
68
|
+
clip-path: inset(0);
|
|
69
|
+
padding: var(--control-inset);
|
|
70
|
+
opacity: 0;
|
|
71
|
+
transition: opacity 220ms ease;
|
|
72
|
+
font: 500 13px/1.2 system-ui, sans-serif;
|
|
73
|
+
}
|
|
74
|
+
.vextab-sheet-controls[data-position^="top"] { align-items: start; }
|
|
75
|
+
.vextab-sheet-controls[data-position$="-left"] { justify-content: start; }
|
|
76
|
+
.vextab-sheet-controls[data-position$="-right"] { justify-content: end; }
|
|
77
|
+
.vextab-sheet-controls[data-visibility="always"],
|
|
78
|
+
.vextab-sheet-controls[data-visible],
|
|
79
|
+
.vextab-sheet-controls:has(:focus-visible),
|
|
80
|
+
.vextab-sheet-controls:has([aria-expanded="true"]),
|
|
81
|
+
.vextab-sheet-controls:has([role=status]:not(:empty)) { opacity: 1; --control-events: auto; }
|
|
82
|
+
.vextab-sheet-controls { container-type: size; }
|
|
83
|
+
/* The two mini buttons stay in place when the tempo stepper opens. */
|
|
84
|
+
.vextab-control-panel {
|
|
85
|
+
display: grid;
|
|
86
|
+
grid-template-columns: repeat(2, var(--control-size));
|
|
87
|
+
align-items: center;
|
|
88
|
+
gap: var(--control-gap);
|
|
89
|
+
flex: none;
|
|
90
|
+
}
|
|
91
|
+
.vextab-sheet-controls button {
|
|
92
|
+
display: inline-grid;
|
|
93
|
+
place-items: center;
|
|
94
|
+
box-sizing: border-box;
|
|
95
|
+
height: var(--control-size);
|
|
96
|
+
width: var(--control-size);
|
|
97
|
+
margin: 0;
|
|
98
|
+
padding: 0;
|
|
99
|
+
border: 1px solid var(--edge);
|
|
100
|
+
border-radius: 50%;
|
|
101
|
+
color: var(--ink);
|
|
102
|
+
background: var(--control-paper);
|
|
103
|
+
font: inherit;
|
|
104
|
+
cursor: pointer;
|
|
105
|
+
touch-action: manipulation;
|
|
106
|
+
pointer-events: var(--control-events);
|
|
107
|
+
}
|
|
108
|
+
.vextab-sheet-controls button:focus-visible { outline: 2px solid #126854; outline-offset: 2px; }
|
|
109
|
+
.vextab-sheet-controls :is(.vextab-play, .vextab-stop) {
|
|
110
|
+
box-shadow: var(--shadow);
|
|
111
|
+
}
|
|
112
|
+
.vextab-sheet-controls :is(.vextab-play, .vextab-stop):hover { background: var(--control-hover); }
|
|
113
|
+
.vextab-sheet-controls .vextab-play::before {
|
|
114
|
+
content: '';
|
|
115
|
+
border: solid transparent;
|
|
116
|
+
border-width: 7px 0 7px 11px;
|
|
117
|
+
border-left-color: currentColor;
|
|
118
|
+
margin-left: 2px;
|
|
119
|
+
}
|
|
120
|
+
.vextab-sheet-controls .vextab-stop::before {
|
|
121
|
+
content: '';
|
|
122
|
+
width: 10px;
|
|
123
|
+
height: 10px;
|
|
124
|
+
border-radius: 2px;
|
|
125
|
+
background: currentColor;
|
|
126
|
+
}
|
|
127
|
+
.vextab-tempo {
|
|
128
|
+
pointer-events: var(--control-events);
|
|
129
|
+
display: flex;
|
|
130
|
+
justify-self: start;
|
|
131
|
+
width: max-content;
|
|
132
|
+
align-items: center;
|
|
133
|
+
border-radius: 18px;
|
|
134
|
+
background: var(--control-paper);
|
|
135
|
+
box-shadow: inset 0 0 0 1px var(--edge), var(--shadow);
|
|
136
|
+
}
|
|
137
|
+
.vextab-sheet-controls .vextab-metronome,
|
|
138
|
+
.vextab-sheet-controls .vextab-step { border: none; background: transparent; }
|
|
139
|
+
.vextab-sheet-controls .vextab-auto-scroll { display: none; }
|
|
140
|
+
.vextab-metronome::before {
|
|
141
|
+
content: '';
|
|
142
|
+
width: 21px;
|
|
143
|
+
height: 21px;
|
|
144
|
+
background: currentColor;
|
|
145
|
+
mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 20 9.4 3h4L18 20ZM7 16.8h9M11.5 14.6l7-9'/%3E%3Cpath d='m15.9 7.3 2.1 1.6 2-2.7-2.1-1.6z' fill='black'/%3E%3C/svg%3E") center / contain no-repeat;
|
|
146
|
+
}
|
|
147
|
+
.vextab-tempo-stepper[inert] { display: none; }
|
|
148
|
+
.vextab-tempo-stepper:not([inert]) {
|
|
149
|
+
display: flex;
|
|
150
|
+
align-items: center;
|
|
151
|
+
margin-right: 3px;
|
|
152
|
+
}
|
|
153
|
+
.vextab-sheet-controls .vextab-step { height: 26px; width: 26px; font-size: 18px; }
|
|
154
|
+
.vextab-sheet-controls .vextab-metronome:hover { background: var(--control-hover); }
|
|
155
|
+
/* Paint a 20px highlight inside the full 26px button target. */
|
|
156
|
+
.vextab-sheet-controls .vextab-step:enabled:hover {
|
|
157
|
+
background: radial-gradient(circle, var(--control-hover) 9.5px, transparent 10.5px);
|
|
158
|
+
}
|
|
159
|
+
.vextab-bpm { color: var(--ink); font-size: 11px; font-weight: 400; font-variant-numeric: tabular-nums; white-space: nowrap; }
|
|
160
|
+
.vextab-sheet-controls [role=status] { position: absolute; }
|
|
161
|
+
.vextab-sheet-controls [role=status]:not(:empty) {
|
|
162
|
+
bottom: calc(var(--control-y-inset, var(--control-inset)) + var(--panel-height) + 5px);
|
|
163
|
+
left: 50%;
|
|
164
|
+
transform: translateX(-50%);
|
|
165
|
+
width: max-content;
|
|
166
|
+
box-sizing: border-box;
|
|
167
|
+
max-width: calc(100% - 16px);
|
|
168
|
+
padding: 4px 8px;
|
|
169
|
+
border-radius: 4px;
|
|
170
|
+
background: white;
|
|
171
|
+
color: var(--ink);
|
|
172
|
+
box-shadow: var(--shadow);
|
|
173
|
+
}
|
|
174
|
+
/* On narrow sheets and at the right edge, open toward the sheet instead of past its margin. */
|
|
175
|
+
.vextab-sheet-controls[data-position$="-right"] .vextab-tempo,
|
|
176
|
+
.vextab-sheet-controls[data-position$="-left"] .vextab-tempo { position: relative; }
|
|
177
|
+
.vextab-sheet-controls[data-position$="-right"] .vextab-tempo-stepper:not([inert]) {
|
|
178
|
+
position: absolute; bottom: 100%; right: 0;
|
|
179
|
+
}
|
|
180
|
+
@container (max-width: 340px) {
|
|
181
|
+
.vextab-tempo { position: relative; }
|
|
182
|
+
.vextab-tempo-stepper:not([inert]) {
|
|
183
|
+
position: absolute;
|
|
184
|
+
bottom: 100%;
|
|
185
|
+
right: 0;
|
|
186
|
+
}
|
|
187
|
+
.vextab-sheet-controls[data-position$="-left"] .vextab-tempo-stepper { left: calc(0px - var(--control-size) - var(--control-gap)); right: auto; }
|
|
188
|
+
}
|
|
189
|
+
.vextab-tempo-stepper:not([inert]) { background: var(--control-paper); border-radius: 16px; }
|
|
190
|
+
.vextab-sheet-controls[data-position^="top"] .vextab-tempo-stepper:not([inert]) { top: 100%; bottom: auto; }
|
|
191
|
+
/* A single translucent surface holds the primary action and current tempo on larger scores. */
|
|
192
|
+
.vextab-sheet-controls[data-size="large"] {
|
|
193
|
+
--control-size: 44px;
|
|
194
|
+
--control-gap: 4px;
|
|
195
|
+
--panel-height: calc(var(--control-size) + 10px);
|
|
196
|
+
--panel-fill: rgb(36 79 67 / 92%);
|
|
197
|
+
}
|
|
198
|
+
.vextab-sheet-controls[data-size="large"] .vextab-control-panel {
|
|
199
|
+
grid-template-columns: var(--control-size) auto var(--control-size);
|
|
200
|
+
padding: 4px 8px;
|
|
201
|
+
border: 1px solid rgb(21 54 45 / 65%);
|
|
202
|
+
border-radius: 9px;
|
|
203
|
+
background: var(--panel-fill);
|
|
204
|
+
box-shadow: 0 2px 7px rgb(18 43 35 / 19%);
|
|
205
|
+
pointer-events: var(--control-events);
|
|
206
|
+
}
|
|
207
|
+
.vextab-sheet-controls[data-size="large"] :is(.vextab-play, .vextab-stop) {
|
|
208
|
+
background: radial-gradient(circle, var(--control-paper) 16px, transparent 17px);
|
|
209
|
+
border: 0;
|
|
210
|
+
box-shadow: none;
|
|
211
|
+
}
|
|
212
|
+
.vextab-sheet-controls[data-size="large"] :is(.vextab-play, .vextab-stop):is(:hover, :focus-visible) {
|
|
213
|
+
color: #19382e;
|
|
214
|
+
background: radial-gradient(circle, #d6dfd8 16px, transparent 17px);
|
|
215
|
+
}
|
|
216
|
+
.vextab-sheet-controls[data-size="large"] .vextab-tempo {
|
|
217
|
+
position: relative;
|
|
218
|
+
border-radius: 0;
|
|
219
|
+
background: transparent;
|
|
220
|
+
box-shadow: none;
|
|
221
|
+
}
|
|
222
|
+
.vextab-sheet-controls[data-size="large"] .vextab-metronome {
|
|
223
|
+
display: flex;
|
|
224
|
+
align-items: center;
|
|
225
|
+
justify-content: center;
|
|
226
|
+
gap: 5px;
|
|
227
|
+
width: auto;
|
|
228
|
+
padding: 0 6px;
|
|
229
|
+
color: var(--control-paper);
|
|
230
|
+
border-radius: 5px;
|
|
231
|
+
}
|
|
232
|
+
.vextab-sheet-controls[data-size="large"] .vextab-metronome::after {
|
|
233
|
+
content: attr(aria-description);
|
|
234
|
+
font-variant-numeric: tabular-nums;
|
|
235
|
+
white-space: nowrap;
|
|
236
|
+
}
|
|
237
|
+
.vextab-sheet-controls[data-size="large"] .vextab-metronome:hover,
|
|
238
|
+
.vextab-sheet-controls[data-size="large"] .vextab-metronome[aria-expanded="true"] { background: rgb(255 255 255 / 12%); }
|
|
239
|
+
.vextab-sheet-controls[data-size="large"] .vextab-auto-scroll {
|
|
240
|
+
display: inline-grid;
|
|
241
|
+
color: var(--control-paper);
|
|
242
|
+
background: transparent;
|
|
243
|
+
border: 0;
|
|
244
|
+
border-radius: 6px;
|
|
245
|
+
}
|
|
246
|
+
.vextab-auto-scroll::before {
|
|
247
|
+
content: '';
|
|
248
|
+
width: 22px;
|
|
249
|
+
height: 22px;
|
|
250
|
+
background: currentColor;
|
|
251
|
+
mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 3 7 4 7-4m-14 7 7 4 7-4m-14 7 7 4 7-4'/%3E%3C/svg%3E") center / contain no-repeat;
|
|
252
|
+
}
|
|
253
|
+
.vextab-auto-scroll[aria-pressed="true"]::before {
|
|
254
|
+
mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='black' stroke-width='3.4' stroke-linecap='round'%3E%3Cpath d='M5 5h14M5 12h14M5 19h14'/%3E%3C/svg%3E");
|
|
255
|
+
}
|
|
256
|
+
.vextab-sheet-controls[data-size="large"] .vextab-auto-scroll:hover { background: rgb(255 255 255 / 18%); }
|
|
257
|
+
.vextab-sheet-controls[data-size="large"] button:focus-visible { outline-color: #ffdc7b; }
|
|
258
|
+
/* Slide the two adjustments into the panel above the BPM, leaving the metronome in place. */
|
|
259
|
+
.vextab-sheet-controls[data-size="large"] .vextab-metronome::after { transition: transform 150ms ease; }
|
|
260
|
+
.vextab-sheet-controls[data-size="large"] .vextab-metronome[aria-expanded="true"]::after { transform: translateY(9px); }
|
|
261
|
+
.vextab-sheet-controls[data-size="large"] .vextab-tempo .vextab-tempo-stepper {
|
|
262
|
+
position: absolute;
|
|
263
|
+
display: flex;
|
|
264
|
+
align-items: center;
|
|
265
|
+
justify-content: center;
|
|
266
|
+
top: -3px;
|
|
267
|
+
right: 3px;
|
|
268
|
+
bottom: auto;
|
|
269
|
+
left: auto;
|
|
270
|
+
width: 52px;
|
|
271
|
+
height: 24px;
|
|
272
|
+
margin: 0;
|
|
273
|
+
border-radius: 4px;
|
|
274
|
+
background: transparent;
|
|
275
|
+
transition: opacity 150ms ease, translate 150ms ease, visibility 0s;
|
|
276
|
+
}
|
|
277
|
+
.vextab-sheet-controls[data-size="large"] .vextab-tempo-stepper[inert] {
|
|
278
|
+
visibility: hidden;
|
|
279
|
+
opacity: 0;
|
|
280
|
+
translate: 0 6px;
|
|
281
|
+
transition-delay: 0s, 0s, 150ms;
|
|
282
|
+
}
|
|
283
|
+
.vextab-sheet-controls[data-size="large"] .vextab-step {
|
|
284
|
+
width: 26px;
|
|
285
|
+
height: 24px;
|
|
286
|
+
font: 500 15px/1 system-ui, sans-serif;
|
|
287
|
+
color: #d2e2d8;
|
|
288
|
+
background: transparent;
|
|
289
|
+
}
|
|
290
|
+
.vextab-sheet-controls[data-size="large"] .vextab-step:enabled:hover {
|
|
291
|
+
color: white;
|
|
292
|
+
background: radial-gradient(circle, rgb(225 242 233 / 14%) 9px, transparent 10px);
|
|
293
|
+
}
|
|
294
|
+
/* The tempo is printed on the large metronome button. Keep its live announcement when adjusting it. */
|
|
295
|
+
.vextab-sheet-controls[data-size="large"] .vextab-bpm {
|
|
296
|
+
position: absolute;
|
|
297
|
+
width: 1px;
|
|
298
|
+
height: 1px;
|
|
299
|
+
overflow: hidden;
|
|
300
|
+
clip-path: inset(50%);
|
|
301
|
+
}
|
|
302
|
+
/* In a narrow embed the tempo value moves into the stepper to make room for Auto-scroll. */
|
|
303
|
+
@container (max-width: 220px) {
|
|
304
|
+
.vextab-sheet-controls[data-size="large"] .vextab-metronome::after { display: none; }
|
|
305
|
+
.vextab-sheet-controls[data-size="large"] .vextab-tempo .vextab-tempo-stepper {
|
|
306
|
+
top: auto;
|
|
307
|
+
bottom: 100%;
|
|
308
|
+
background: var(--panel-fill);
|
|
309
|
+
width: 110px;
|
|
310
|
+
right: 50%;
|
|
311
|
+
transform: translateX(50%);
|
|
312
|
+
}
|
|
313
|
+
.vextab-sheet-controls[data-size="large"][data-position^="top"] .vextab-tempo .vextab-tempo-stepper { top: 100%; bottom: auto; }
|
|
314
|
+
.vextab-sheet-controls[data-size="large"] .vextab-bpm {
|
|
315
|
+
position: static;
|
|
316
|
+
width: auto;
|
|
317
|
+
height: auto;
|
|
318
|
+
clip-path: none;
|
|
319
|
+
color: var(--control-paper);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
.vextab-sheet-controls[data-position^="top"] [role=status]:not(:empty) { bottom: auto; }
|
|
323
|
+
.vextab-sheet-controls[data-position^="top"] [role=status]:not(:empty) { top: calc(var(--control-y-inset, var(--control-inset)) + var(--panel-height) + 5px); }
|
|
324
|
+
@media (prefers-reduced-motion: reduce) {
|
|
325
|
+
.vextab-sheet-controls,
|
|
326
|
+
.vextab-sheet-controls[data-size="large"] .vextab-metronome::after,
|
|
327
|
+
.vextab-sheet-controls[data-size="large"] .vextab-tempo .vextab-tempo-stepper { transition: none; }
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/* Tint sounding notes and custom position markers. */
|
|
331
|
+
.vextab-playback-ink {
|
|
332
|
+
color: var(--vextab-playback-tint, #fff600);
|
|
333
|
+
}
|
|
334
|
+
.vextab-playback-marker {
|
|
335
|
+
color: var(--vextab-playback-tint, #6baed6);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/* Stack preview ink in the same grid cell as the page, at its intrinsic or responsive size. */
|
|
339
|
+
.vextab-playback-page { display: grid; grid-template-columns: minmax(0, 1fr); }
|
|
340
|
+
.vextab-playback-page > svg { grid-area: 1 / 1; }
|
|
341
|
+
|
|
342
|
+
/* Host-mounted controls stay above the music, including in legacy documentation. */
|
|
343
|
+
.vextab-playback-controls { display: inline-flex; align-items: center; gap: .65em; }
|
|
344
|
+
.vextab-playback-controls button { cursor: pointer; font: inherit; }
|
|
345
|
+
.vextab-playback-controls button::before { content: '\u25B6'; margin-right: .45em; font-size: .8em; }
|
|
346
|
+
.vextab-playback-controls .vextab-stop::before { content: '\u25A0'; }
|
|
347
|
+
@media print {
|
|
348
|
+
.vextab-playback-controls, .vextab-transport, .vextab-playback-ink, .vextab-playback-paper { display: none !important; }
|
|
349
|
+
}
|
|
350
|
+
`;document.head.append(or)});import wt from"vexflow";wt.Flow||(wt.Flow=wt);!wt.RERR&&wt.RuntimeError&&(wt.RERR=wt.RuntimeError);wt.BM||(wt.BM=(a,t)=>t());var N=wt;import Mt from"vexflow";var Ae="Academico",gt=()=>Mt.getTextFonts()[0],At=()=>Mt.getFonts()[0],Ot=()=>gt()==="Petaluma Script"?"normal":"bold";function Nt(a,t){if(!a)return t();let e=Mt.getFonts(),n=Mt.getTextFonts();try{return a==="Petaluma"?Mt.setFonts("Petaluma","Petaluma Script"):Mt.setFonts("Bravura",Ae),t()}finally{Mt.setFonts(...e),Mt.setTextFonts(...n)}}import{Annotation as dn,Beam as fn,Formatter as ar,Fraction as pn,TextNote as cr,Voice as ae}from"vexflow";var ce=class{constructor(t){this.artist=t}prepareStave(t,e){if(!t)return[];let n=N.Flow.Barline.type,r=n.SINGLE,o=e.map(s=>{let i=J(s);return i instanceof N.Flow.BarNote&&i.getType()!==n.REPEAT_BEGIN?(r=i.getType(),s.slice(0,-1)):s});return t.setEndBarType(r),o}makeBeams(t,e,n,r,o){let s=e.options;if(o&&s["tab-stems"]!=="true")return[];let i;e.direction==="top"?i=1:e.direction==="bottom"?i=-1:n.voiceSettings.length>1?i=r===0?1:-1:o&&(i=s["tab-stem-direction"]==="down"?-1:1);for(let c of t)i&&c.setStemDirection&&c.setStemDirection(i);return s.beams==="off"?[]:s.beams==="explicit"?e.groups.map(([c,l])=>{let d=new fn(t.slice(c,l),i===void 0);return d.renderOptions.showStemlets=s["beam-stemlets"]==="true",d}):fn.generateBeams(t,{groups:n.beam_groups,stemDirection:i,beamRests:s["beam-rests"]==="true",showStemlets:s["beam-stemlets"]==="true",beamMiddleOnly:s["beam-middle-only"]==="true"})}alignTopAnnotations(t,e){let n=[];for(let o of t.getTickables())o.getModifiers().filter(i=>i instanceof dn&&i.getVerticalJustification()===dn.VerticalJustify.TOP).forEach((i,c)=>{i.setLayoutBaseline(void 0),(n[c]??=[]).push(i)});let r=e.getYForLine(-1);for(let o of n){for(let s of o)r=Math.min(r,s.computeY().y);for(let s of o)s.setLayoutBaseline(r);r-=Math.max(...o.map(s=>s.computeY().textHeight))}}alignTextBars(t,e){let n=[],r=new pn(0,1);for(let i of e)i.shouldIgnoreTicks()?n.push(r.clone()):r.add(i.getTicks());if(!n.length)return t;let o=[];r=new pn(0,1);let s=0;for(let i of t){for(;s<n.length&&!n[s].greaterThan(r)&&!(n[s++].equals(r)&&i.shouldIgnoreTicks());)o.push(new cr({text:"",duration:"b",ignoreTicks:!0}));o.push(i),i.shouldIgnoreTicks()||r.add(i.getTicks())}return o}formatAndRender(t,e,n,r){let o=[],s=(S,T,A)=>S.flatMap((k,p)=>{if(!k.length)return[];k.forEach(L=>L.setStave(T));let _=new ae(e.meter).setMode(ae.Mode.SOFT).addTickables(k);return o.push(...this.makeBeams(k,e.voiceSettings[p],e,p,A)),[_]}),i=e.tab,c=e.note,l=s(n,i,!0),d=s(r,c,!1),m=c||i,f=m,g=e.text_voices.filter(S=>S.length).map(S=>{let T=this.alignTextBars(S,r[0]??n[0]??[]);return T.forEach(A=>A.setStave(f)),new ae(e.meter).setMode(ae.Mode.SOFT).addTickables(T)}),y=new ar,b=[...l,...d,...g];for(let S of[l,d,g])S.length&&y.joinVoices(S);b.length&&y.formatToStave(b,m,{alignRests:d.length>1});for(let S of l)this.alignTopAnnotations(S,i),S.draw(t,i);for(let S of d)S.draw(t,c);for(let S of o)S.setContext(t).draw();for(let S of g)S.draw(t,f);return i&&c&&new N.Flow.StaveConnector(c,i).setType(N.Flow.StaveConnector.type.BRACKET).setContext(t).draw(),c?d:l}render(t){let e=this.artist;e.log("Render: ",e.options),e.closeBends(),t.resize(Number(e.customizations.width)*Number(e.customizations.scale),(e.last_y+e.options.bottom_spacing)*Number(e.customizations.scale));let n=t.getContext();n.setViewBox?n.setViewBox(0,0,Number(e.customizations.width),e.last_y+e.options.bottom_spacing):n.scale(Number(e.customizations.scale),Number(e.customizations.scale)),n.clear(),n.setFont(e.options.font_face,e.options.font_size,""),e.renderer_context=n,e.player_voices=[];let r=o=>{o.note&&e.notes.applyAccidentals(o);let s=this.prepareStave(o.tab,o.tab_voices),i=this.prepareStave(o.note,o.note_voices);if(o.tab&&o.note){let l=Math.max(o.tab.getNoteStartX(),o.note.getNoteStartX());o.tab.setNoteStartX(l),o.note.setNoteStartX(l)}o.tab&&o.tab.setContext(n).draw(),o.note&&o.note.setContext(n).draw();let c=this.formatAndRender(n,o,s,i);e.player_voices.push(c)};for(let o of e.staves){if(!o.color){r(o);continue}let s=n.getDefaultStyle();n.save();try{n.setDefaultStyle(rt(o.color)).setStrokeStyle(o.color).setFillStyle(o.color),r(o)}finally{n.setDefaultStyle(s),n.restore()}}e.log("Rendering tab articulations."),e.tab_articulations.forEach(o=>o.setContext(n).drawWithStyle()),e.log("Rendering note articulations."),e.stave_articulations.forEach(o=>o.setContext(n).drawWithStyle()),e.player&&(e.customizations.player==="true"?(e.player.setTempo(parseInt(String(e.customizations.tempo),10)),e.player.setInstrument(String(e.customizations.instrument)),e.player.render()):e.player.removeControls()),e.rendered=!0}};import{Annotation as Ne,Articulation as lr,FretHandFinger as ur,Modifier as Ht,StringNumber as dr}from"vexflow";var fr={left:Ht.Position.LEFT,right:Ht.Position.RIGHT,above:Ht.Position.ABOVE,below:Ht.Position.BELOW};function Re(a,t,e=!1,n=!1){let r=!n&&(t===Ht.Position.LEFT||t===Ht.Position.RIGHT),o=e?new dr(a):new ur(a,{headPlacement:r}).setDrawCircle(n&&/^\d$/.test(a));return o.setPosition(t),o}function Vt(a,t,e,n,r=!1,o=!1){for(let s of e){let i=fr[s.position];if(s.finger!==void 0){if(n&&!r)continue;if((o||/^[pimac]$/.test(s.finger))&&(s.position==="above"||s.position==="below")){let c=s.position==="above"?Ne.VerticalJustify.TOP:Ne.VerticalJustify.BOTTOM;a.addModifier(new Ne(s.finger).setFont(gt(),11).setVerticalJustification(c),t);continue}a.addModifier(Re(s.finger,i,s.stringNumber,n),t)}else a.addModifier(new lr(s.articulation??"a>").setPosition(i),t)}}function Ce(a,t){return a?.find(e=>!e.finger||!/^\d$/.test(e.finger)||e.stringNumber?!1:e.position==="left"||e.position==="right"?!0:t.some(n=>n.marks?.some(r=>r!==e&&r.position===e.position&&/^\d$/.test(r.finger??"")&&!r.stringNumber)))}function Be(a,t){let e=a.measures.map(l=>l.number);if(!t)return e;let n=[...a.repeats??[]];for(let l of n){if(l.count!==void 0&&(!Number.isInteger(l.count)||l.count<2||l.count>32||l.endings.length))throw new nt("measure","Invalid counted repeat",a.measures[0].range);let d=l.bodyEnd;if(!Number.isInteger(l.first)||!Number.isInteger(d)||l.first<1||d<l.first||d>e.length)throw new nt("measure","Invalid repeat body",a.measures[0].range);for(let m of l.endings){if(m.first!==d+1||!Number.isInteger(m.last)||m.last<m.first||m.last>e.length)throw new nt("measure","Invalid repeat ending",a.measures[l.first-1].range);d=m.last}}let r=[],o=new Set(n.flatMap(l=>l.count?[l.bodyEnd]:l.endings.slice(0,-1).map(d=>d.last)));for(let l of a.measures){let d=l.voices[0];if(["repeat-begin","repeat-both"].includes(d.opening?.type)&&!n.some(m=>m.first===l.number)&&r.push(l.number),["repeat-end","repeat-both"].includes(d.closing?.type)&&!o.has(l.number)){let m=r.pop()??1;n.push({first:m,bodyEnd:l.number,endings:[],range:[l.range.start,l.range.end]})}}let s=l=>l.endings[l.endings.length-1]?.last??l.bodyEnd;n.sort((l,d)=>l.first-d.first||s(d)-s(l));let i=[];function c(l,d,m){for(let f=l;f<=d;f++){let h=m.find(y=>y.first===f&&s(y)<=d);if(!h){if(i.length>=16384)throw new nt("measure","Performed repeat exceeds 16384 bar visits",a.measures[f-1].range);i.push(f);continue}let g=m.filter(y=>y!==h);for(let y=0;y<(h.count??Math.max(2,h.endings.length));y++){c(f,h.bodyEnd,g);let b=h.endings[y];b&&c(b.first,b.last,g)}f=s(h)}}return c(1,e.length,n),i}function mn(a,t){let e=new Map,n=new Map;for(let r of a){let o=Be(r,t);if(e.set(r,o),o.length===r.measures.length)continue;let s=r.measures.map(c=>c.span).join(","),i=n.get(s);if(i&&(i.length!==o.length||i.some((c,l)=>c!==o[l])))throw new nt("measure","Parts disagree about the performed repeat order",r.measures[0].range);n.set(s,o)}if(n.size)for(let r of a){let o=n.get(r.measures.map(s=>s.span).join(","));o&&e.set(r,o)}return e}function hn(a,t,e,n){let r="cdefgab",[o,s]=a.split("/"),i=r.indexOf(o[0])+e,c=n.getAccidental(r[(i+7)%7]).note,l=yt(c+"/"+(Number(s)+Math.floor(i/7)));return l===void 0?t:Math.max(0,Math.min(127,l+t-yt(a)))}function gn(a,t,e,n=.25){if(!a.notes.length)return[a];let r=a.notes[0],o=t.heads.find(d=>d.sounding&&yt(d.sounding)===r.pitch);if(!o)return[a];let s=[],i=a.time,c=a.duration;function l(d,m,f){let h=f/d.length;d.forEach((g,y)=>s.push({...a,time:m+y*h,duration:h,notes:(Array.isArray(g)?g:[g]).map(b=>({pitch:b,duration:h,velocity:r.velocity,...r.fixedVelocity&&{fixedVelocity:!0},program:r.program}))}))}if(t.grace){let d=r.pitch-yt(o.written),m=t.grace.pitches.map(f=>(Array.isArray(f)?f:[f]).map(h=>yt(h)+d).filter(h=>h>=0&&h<=127)).filter(f=>f.length);if(m.length){let f=t.grace.side==="before",g=(f&&!t.grace.steal?Math.min(c,...a.notes.map(b=>b.duration)):c)*n,y=f?i:i+c-g;l(m,y,g),c-=g,f&&(i+=g);for(let b of a.notes)f?b.duration=Math.max(0,b.duration-g):b.duration-=Math.min(g,Math.max(0,b.duration-(y-a.time)))}}if(t.ornament){let d=hn(o.written,r.pitch,1,e),m=hn(o.written,r.pitch,-1,e),f=r.pitch,g={tr:[f,d,f,d],mordent:[f,d],mordent_inverted:[f,m],turn:[d,f,m],turn_inverted:[m,f,d]}[t.ornament],y=Math.min(c,r.duration)/2;l(g,i,y),a.notes.length>1&&s.push({...a,time:i,duration:c,notes:a.notes.slice(1)}),r.duration=Math.max(0,r.duration-y),s.push({...a,time:i+y,duration:c-y,notes:[r]})}else s.push({...a,time:i,duration:c});return s}import pr,{KeyManager as mr}from"vexflow/core";function bn(a,t,e){let n=yt(a);if(n===void 0)return;let r={pitch:n,duration:t,velocity:100};return e&&(r.bend=[{time:t,semitones:-e}]),r}function it(a,t){let[e,n]=a.split("/").map(Number);return e/n*t}function hr(a,t,e){if(t.midi!==void 0&&!a.silent)return{pitch:t.midi,duration:e,velocity:100};if(!t.sounding||a.silent)return;let n=bn(t.sounding,e,t.prebend?.release&&t.prebend.semitones),r=t.bend??a.bend?.spec;if(!n||!r||r.string!==t.position?.str)return n;let o=i=>e*i[0]/i[1],s=[{time:o(r.rise),semitones:r.semitones}];return r.hold&&s.push({time:o(r.hold),semitones:r.semitones}),r.release&&s.push({time:o(r.release),semitones:0}),n.bend=s,n}var Fe=class{constructor(){this.from=100;this.target=100;this.start=0;this.hasSounded=!1}at(t){let e=(t-this.start)*4,n=Math.max(0,1-e);return this.target+(this.from-this.target)*n*n}attack(t,e,n,r){if(e!==void 0&&(e!==this.target||!r)){let o=this.at(t);this.from=this.hasSounded&&r?(o+e)/2:e,this.target=e,this.start=t}return n&&(this.hasSounded=!0),Math.round(this.at(t))}};function gr(a,t,e){let n=[],r=new Map;for(let g of a.playback?.tempoChanges??[]){let y=r.get(g.bar)??[];y.push({at:it(g.at,1),bpm:g.bpm*t/(a.playback.tempo??120)}),r.set(g.bar,y)}let o=new Map,s=new Map,i=[],c={ppp:28,pp:40,p:52,mp:66,mf:82,f:98,ff:112,fff:124},l=new Set(e&&a.measures[0]?.state.piano?a.measures.flatMap(g=>g.voices.filter(y=>y.hand&&y.events.some(b=>b.dynamic)).map(y=>y.hand)):[]),d=new Map,m=new Set((a.spans??[]).flatMap(g=>g.kind==="crescendo"||g.kind==="diminuendo"?[g.from,g.to]:[])),f=t,h=0;for(let g of a.measures){let y=a.playback?.tempos?.[g.number];y&&(f=y*t/(a.playback.tempo??120)),n.push(f);let b=r.get(g.number);b&&(f=b[b.length-1].bpm);let S=g.voices.flatMap((T,A)=>T.events.map(k=>({attack:k,voice:A,onset:it(k.onset,1)}))).sort((T,A)=>T.onset-A.onset||+!!A.attack.dynamic-+!!T.attack.dynamic);for(let{attack:T,voice:A,onset:k}of S){let p=l.size===2?g.voices[A].hand??"":"";d.has(p)||d.set(p,new Fe);let _=d.get(p);o.set(T.id,_.attack(h+k,c[T.dynamic],!T.silent&&T.heads.length>0,e&&!m.has(T.id)));let L=i[A]??=[],B={id:T.id,time:h+k,voice:A,explicit:!!T.dynamic,index:L.length};s.set(T.id,B),L.push(B)}h+=it(g.span,1)}for(let g of a.spans??[]){if(g.kind!=="crescendo"&&g.kind!=="diminuendo")continue;let y=s.get(g.from),b=s.get(g.to);if(!y||!b||b.time<=y.time)continue;let S=g.kind==="crescendo",T=S&&g.niente?1:o.get(g.from),A=!S&&g.niente?1:b.explicit?o.get(g.to):Math.min(127,Math.max(1,T+(S?24:-24)));for(let k=y.index;k<=b.index;k++){let p=i[y.voice][k];o.set(p.id,Math.round(T+(A-T)*(p.time-y.time)/(b.time-y.time)))}}return{tempi:n,tempoChanges:r,velocities:o}}function br(a,t,e){if(!t.length)return;t.sort((o,s)=>o.start-s.start);let n=[];for(let o of t){let s=n[n.length-1];s&&o.start<s.end?s.end=Math.max(s.end,o.end):n.push(o)}let r=new Map;for(let o=a.length-1;o>=0;o--){let s=a[o];for(let i of s.notes){let c=s.time+i.duration,l=0,d=n.length;for(;l<d;){let f=l+d>>>1;n[f].end<=c?l=f+1:d=f}let m=n[l];if(e&&(m?.start<c||n[l-1]?.end===c)&&(i.holdRelease=!0),m&&m.start<c){let f=Math.min(m.end,r.get(i.pitch)??1/0);i.duration=Math.max(i.duration,f-s.time)}r.set(i.pitch,s.time)}}}function yr(a,t,e,n,r){let o=n(it(a.span,1)),s=t/4,[i,c]=a.state.meter.split("/").map(Number),l=Math.max(0,i/c-it(a.span,1))*4,d=Math.abs(l-Math.round(l))>1e-8?l%1*s:0,m=[];if(r!==void 0){let g=it(a.span,1),y=0,b=(1-d/s)/4;for(;y<g-1e-12;){let S=Math.min(y+b,g);m.push({end:n(S),...S-y>=.25-1e-12&&{eighth:n(y+.125)}}),y=S,b=.25}}let f=[],h=!1;for(let g of a.voices)for(let y of g.events){let b=n(it(y.onset,1)+it(y.duration,1));y.heads.some(S=>S.marks?.some(T=>T.articulation?.startsWith("a@")))&&f.push(b),b>=o-1e-8&&e.has(y.id)&&(h=!0)}return{duration:o,quarter:s,beatOffset:d,...r!==void 0&&{beats:m,endingQuarter:r},swingable:c===2||c===4,fermatas:f,phraseEnd:h||!!f.length}}function yn(a){let t=a[0]??[];for(let e of a.slice(1)){let n=0,r=0,o=0;for(let s of e){let i=n,c=r,l=o+s.duration;for(;i<t.length&&c<l-1e-9;){let d=t[i],m=c+d.duration;s.swingable===!1&&(d.swingable=!1),s.phraseEnd&&Math.abs(l-m)<1e-8&&(d.phraseEnd=!0);for(let f of s.fermatas??[]){let h=o+f;h>c+1e-9&&h<=m+1e-9&&(d.fermatas=[...d.fermatas??[],h-c])}if(m>l+1e-9)break;c=m,i++}n=i,r=c,o=l}}return t}function vn(a,t,e,n=Be(a,!1),r,o){let s=[],i=new Map(a.ties.map(v=>[v.to+":"+v.toHead,v])),c=new Map,l=!!r&&!r.literal,d=!1,{tempi:m,tempoChanges:f,velocities:h}=gr(a,t,l),g=new Set((a.spans??[]).filter(v=>v.kind==="slur").map(v=>v.to)),y=new Map((a.spans??[]).filter(v=>v.kind==="tremolo").map(v=>[v.from,v])),b=new Map((a.spans??[]).flatMap(v=>v.kind==="glissando"?[[v.to+":"+v.toHead,v]]:[])),S=new Map,T=new Map,A=(a.spans??[]).filter(v=>v.kind==="pedal"),k=new Map(A.map(v=>[v.from,v.to])),p=new Set(A.filter(v=>v.onset).map(v=>v.to)),_=new Map,L=[];function B(v){for(let E of _.values())L.push({start:E,end:v});_.clear()}let H=new Map((a.repeats??[]).flatMap(v=>v.endings.slice(1).map(E=>[E.first,v.bodyEnd]))),P=0,x=0;for(let v of n){let E=a.measures[v-1];if(v!==P+1){if(H.get(v)===P)for(let[z,V]of c)(V.barNumber!==P||Math.abs(V.writtenEnd-x)>1e-8)&&c.delete(z);else c.clear();B(x)}else if(H.has(v)){let z=H.get(v);for(let[V,O]of c)O.barNumber===z&&c.delete(V)}P=v;let R=240/m[v-1],I=0,D=0,G=R,$=[{start:I,timeAtStart:D,rate:G}];for(let z of f.get(v)??[])D+=(z.at-I)*G,I=z.at,G=240/z.bpm,$.push({start:I,timeAtStart:D,rate:G});let j=z=>{let V=0,O=$.length;for(;V+1<O;){let U=V+O>>>1;$[U].start<=z?V=U:O=U}let q=$[V];return q.timeAtStart+(z-q.start)*q.rate},Q=E.voices.flatMap(z=>z.events).map(z=>({attack:z,time:x+j(it(z.onset,1))}));Q.sort((z,V)=>z.time-V.time),o&&it(E.span,R)>0&&o.push(yr(E,R,g,j,$.length>1?G/4:void 0));let K=new Map;for(let{attack:z,time:V}of Q){let O=j(it(z.onset,1)+it(z.duration,1))-j(it(z.onset,1));k.has(z.id)&&_.set(k.get(z.id),V),_.has(z.id)&&(L.push({start:_.get(z.id),end:p.has(z.id)?V:V+O}),_.delete(z.id));let q=[];if(z.grace||z.ornament){let U=z.activeKey??E.state.key??"C";T.has(U)||T.set(U,new mr(U));let W;if(z.grace?.steal){let Z=it(z.onset,1),tt=it(z.duration,1),et=tt*it(z.grace.steal,1),st=z.grace.side==="before"?Z:Z+tt-et;W=(j(st+et)-j(st))/O}S.set(z.id,{attack:z,key:T.get(U),graceShare:W})}z.heads.forEach((U,W)=>{let Z=U.sustain?j(it(z.onset,1)+it(U.sustain,1))-j(it(z.onset,1)):O,tt=z.id+":"+W,et=i.get(tt),st=et&&c.get(et.from+":"+et.fromHead);if(st){if(l&&(st.note.holdRelease=!0),st.note.duration=Math.max(st.note.duration,V+Z-st.start),et.bend){let{semitones:ot,hold:at,release:ut}=et.bend;st.note.bend=[...st.note.bend??[],{time:V-st.start+Z*at[0]/at[1],semitones:ot},{time:V-st.start+Z*ut[0]/ut[1],semitones:0}]}c.set(tt,{...st,barNumber:v,writtenEnd:V+Z})}else{let ot=hr(z,U,Z);if(ot){let at=b.get(tt),ut=at&&c.get(at.from+":"+at.fromHead);ut&&(ut.note.bend=[...ut.note.bend??[],{time:V-ut.start,semitones:ot.pitch-ut.note.pitch}]),ot.velocity=h.get(z.id),l&&U.marks&&(U.marks.some(dt=>dt.articulation==="a>"||!dt.articulation&&!dt.finger&&!dt.stringNumber)&&(ot.velocity=Math.min(127,ot.velocity+10)),!ot.bend&&!z.grace&&!z.ornament&&U.marks.some(dt=>dt.articulation==="a.")&&(ot.duration*=.58)),U.velocity!==void 0&&(ot.velocity=U.velocity,ot.fixedVelocity=!0,U.velocity===0&&(d=!0)),a.program!==void 0&&(ot.program=a.program),q.push(ot),c.set(tt,{note:ot,start:V,barNumber:v,writtenEnd:V+Z})}}}),K.set(z.id,{time:V,duration:O,source:z.id,notes:q,mark:e&&(()=>e(z.id))})}for(let[z,V]of K){let O=y.get(z);if(O?.kind!=="tremolo"){s.push(V);continue}let q=K.get(O.to),U=V.duration+q.duration,W=R/2**(2+O.strokes);for(let Z=0;Z*W<U-1e-9;Z++){let tt=Z%2?q:V,et=Math.min(W,U-Z*W);s.push({...tt,time:V.time+Z*W,duration:et,notes:tt.notes.map(st=>({...st,duration:et}))})}K.delete(O.to)}x+=j(it(E.span,1))}let C=S.size?s.flatMap(v=>{let E=S.get(String(v.source));if(!E)return[v];let R=E.attack.grace,I=E.graceShare??(R&&r?.graceFraction(v.time,v.duration,R.pitches.length,R.slash));return gn(v,E.attack,E.key,I)}):s;if(d)for(let v of C)v.notes=v.notes.filter(E=>E.velocity!==0);return C.sort((v,E)=>v.time-E.time),B(x),br(C,L,l),{events:C,duration:x}}function wn(a,t){let e=[],n=240/(t*pr.RESOLUTION),r=new Map,o=0;for(let s of a.getPlayerData().voices){let i=0;for(let c of s){let l=0;for(let d of c.getTickables()){if(d.shouldIgnoreTicks())continue;let m=d.getTicks().value(),f=m*n,h=[];if(!d.isRest()){let g=St.get(d)??(d.getPlayNote?.()??[]).map(b=>({key:b})),y=new Map;g.forEach((b,S)=>{let T=bn(b.key,f,b.release);if(!T)return;let A=le.get(d)?.get(S),k=A&&r.get(A.glyph)?.get(A.index);k&&k.pitch===T.pitch?(k.duration+=f,y.set(S,k)):(h.push(T),y.set(S,T))}),r.set(d,y)}e.push({time:(o+l)*n,duration:f,source:d,notes:h}),l+=m}i=Math.max(i,l)}o+=i}return{events:e.sort((s,i)=>s.time-i.time),duration:o*n}}var St=new WeakMap,le=new WeakMap;function xn(a,t){let e=le.get(a)?.get(t);return e&&St.get(e.glyph)?.[e.index]}function Le(a,t,e,n){if(!a||!t)return;let r=le.get(t)??new Map;n.forEach((o,s)=>r.set(o,{glyph:a,index:e[s]})),le.set(t,r)}var ue=class{constructor(t){this.artist=t}makeBend(t,e){let n=N.Flow.Bend.UP,r="";if(parseInt(t,10)>parseInt(e,10))n=N.Flow.Bend.DOWN;else switch(Math.abs(parseInt(e,10)-parseInt(t,10))){case 1:r="1/2";break;case 2:r="Full";break;case 3:r="1 1/2";break;default:r=`Bend to ${e}`;break}return{type:n,text:r}}openBends(t,e,n,r){this.artist.log("openBends",t,e,n,r);let o=J(this.artist.staves).tab_notes,s=t,i=n;mt(this.artist.current_bends)?(this.artist.bend_start_index=o.indexOf(t),this.artist.bend_start_strings=n):(s=o[this.artist.bend_start_index],i=this.artist.bend_start_strings);let c=s.getPositions(),l=e.getPositions();i.forEach((d,m)=>{let f=r[m],h=c[d],g=l[f];this.artist.current_bends[d]||(this.artist.current_bends[d]=[]),this.artist.current_bends[d].push(this.makeBend(h.fret,g.fret))})}closeBends(t=1){if(this.artist.bend_start_index==null)return;this.artist.log(`closeBends(${t})`);let e=J(this.artist.staves).tab_notes;Ke(this.artist.current_bends,(n,r)=>{let o=[];n.forEach(c=>o.push(c));let s=N.Flow.Bend.length<=1?new N.Flow.Bend(o):new N.Flow.Bend(null,null,o),i=parseInt(String(r),10);e[this.artist.bend_start_index].addModifier(s,i)}),e.slice(this.artist.bend_start_index+1,e.length-2+t+1).forEach(n=>n.setGhost(!0)),this.artist.current_bends={},this.artist.bend_start_index=null}makeTuplets(t,e){this.artist.log("makeTuplets",t,e);let n=Number(e??t),r=Number(t),o=J(this.artist.staves);if(!Number.isSafeInteger(n)||n<1||!Number.isSafeInteger(r)||r<1)throw new N.RERR("ArtistError","Tuplet counts must be positive integers");let s=nn(r,o.meter),i=(c,l,d)=>{let m=c.slice(-n);if(m.length!==n||m.some(h=>h instanceof N.Flow.BarNote))throw new N.RERR("ArtistError","Not enough notes for tuplet in this bar and voice");let f=new N.Flow.Tuplet(m,{numNotes:r,notesOccupied:s});l&&d.push(f)};o.note&&i(o.note_notes,!0,this.artist.stave_articulations),i(o.tab_notes,!!o.tab&&this.artist.customizations["tab-stems"]==="true",this.artist.tab_articulations)}getFingering(t){return t.match(/^\.fingering\/([^.]+)\./)}makeFingering(t){let e=this.getFingering(t),n=N.Flow.Modifier.Position,r=[],o=[];if(e)e[1].split(/-/).forEach(i=>r.push(i.trim()));else return null;let s=()=>new N.RERR("ArtistError",`Bad fingering: ${e[1]}`);return r.forEach(i=>{let c=i.match(/(\d+):([ablr]):([fs]):([^-.]+)/);if(!c)throw s();let l=parseInt(c[1],10)-1,d=n.RIGHT;switch(c[2]){case"l":d=n.LEFT;break;case"r":d=n.RIGHT;break;case"a":d=n.ABOVE;break;case"b":d=n.BELOW;break;default:break}let m=Re(c[4],d,c[3]==="s");o.push({num:l,modifier:m})}),o}getStrokeParts(t){return t.match(/^\.stroke\/([^.]+)\./)}makeStroke(t){let e=this.getStrokeParts(t),n=N.Flow.Stroke.Type;if(!e)return null;switch(e[1]){case"bu":return new N.Flow.Stroke(n.BRUSH_UP);case"bd":return new N.Flow.Stroke(n.BRUSH_DOWN);case"ru":return new N.Flow.Stroke(n.ROLL_UP);case"rd":return new N.Flow.Stroke(n.ROLL_DOWN);case"qu":return new N.Flow.Stroke(n.RASQUEDO_UP);case"qd":return new N.Flow.Stroke(n.RASQUEDO_DOWN);default:throw new N.RERR("ArtistError",`Invalid stroke type: ${e[1]}`)}}getScoreArticulationParts(t){return t.match(/^\.(a[^/]*)\/(t|b)[^.]*\./)}makeScoreArticulation(t){let e=this.getScoreArticulationParts(t);if(!e)return null;let n=e[1],r=e[2],o=N.Flow.Modifier.Position,s=r==="t"?o.ABOVE:o.BELOW;return new N.Flow.Articulation(n).setPosition(s)}makeAnnotation(t){let e=this.artist.customizations["font-face"],n=this.artist.customizations["font-size"],r=this.artist.customizations["font-style"],o=this.artist.customizations["annotation-position"],s=N.Flow.Annotation.VerticalJustify,i=o==="top"?s.TOP:s.BOTTOM,c=(d,m=i)=>new N.Flow.Annotation(d).setFont(e,n,r).setVerticalJustification(m),l=t.match(/^\.([^-]*)-([^-]*)-([^.-]*)(?:-([^.]*))?\.(.*)/);if(l){e=l[1],n=l[2],r=l[3];let[,,,,d,m]=l;if(d!==void 0&&!Pt(d))throw new N.RERR("ArtistError",`Invalid annotation color '${d}'`);if(!m)return null;let f=c(m);return d?f.setStyle(rt(d)):f}if(l=t.match(/^\.([^.]*)\.(.*)/),l){let d=i,m=l[1],f=l[2];switch(m){case"big":r="bold",n="14";break;case"italic":case"italics":r="italic";break;case"medium":n="12";break;case"top":d=s.TOP,this.artist.customizations["annotation-position"]="top";break;case"bottom":d=s.BOTTOM,this.artist.customizations["annotation-position"]="bottom";break;default:break}return f?c(f,d):null}return c(t)}formatOverrideFretText(t){if(!t)return null;let e=N.Flow?.unicode??{},n=e.sharp??"#",r=e.flat??"b",o=e.natural??"n",s=t.match(/^([A-G])([#@n]{1,2})?(~?)(\d+)?(?:_(\d+)\/(\d+))?$/);if(s&&(s[4]||s[6])){let c=s[1],l=s[2]??"",d=s[4]??"",m=s[6],f=(()=>{switch(l){case"##":return`${n}${n}`;case"#":return n;case"@@":return`${r}${r}`;case"@":return r;case"n":return o;default:return""}})();return{text:`${c}${f}${d}`,string:m}}let i=t.match(/^(\d+)\/(\d+)$/);return i?{text:i[1],string:i[2]}:null}applyFretOverride(t,e){if(!t||!e||!t.fretElement||!t.positions)return;let n=0;if(e.string){let l=parseInt(e.string,10);if(!Number.isNaN(l)){let d=-1;t.positions.forEach((m,f)=>{parseInt(m.str,10)===l&&d<0&&(d=f)}),n=d>=0?d:0}}let r=t.fretElement[n];if(!r)return;r.setText(e.text);let o=this.artist.customizations["font-face"],s=this.artist.customizations["font-size"],i=this.artist.customizations["font-style"];o&&r.setFont(o,s,i);let c=0;t.fretElement.forEach(l=>{c=Math.max(c,l.getWidth())}),t.setWidth(c)}addAnnotations(t){let e=J(this.artist.staves),n=e.note_notes,r=e.tab_notes;if(t.length>r.length)throw new N.RERR("ArtistError","More annotations than note elements");e.tab?r.slice(r.length-t.length).forEach((o,s)=>{if(this.getScoreArticulationParts(t[s])){let i=this.makeScoreArticulation(t[s]);o.addModifier(i,0)}else if(this.getStrokeParts(t[s])){let i=this.makeStroke(t[s]);o.addModifier(i,0)}else{let i=t[s],c=this.formatOverrideFretText(i);if(c)this.applyFretOverride(o,c);else{let l=this.makeAnnotation(i);l&&o.addModifier(l,0)}}}):n.slice(n.length-t.length).forEach((o,s)=>{if(!this.getScoreArticulationParts(t[s])){let i=this.makeAnnotation(t[s]);i&&(typeof o.addAnnotation=="function"?o.addAnnotation(0,i):typeof o.addModifier=="function"&&o.addModifier(i,0))}}),e.note&&n.slice(n.length-t.length).forEach((o,s)=>{let i=this.makeScoreArticulation(t[s]);i&&(typeof o.addArticulation=="function"?o.addArticulation(0,i):typeof o.addModifier=="function"&&o.addModifier(i,0));let c=this.makeStroke(t[s]);c&&o.addStroke(0,c);let l=this.makeFingering(t[s]);if(l)try{l.forEach(d=>o.addModifier(d.modifier,d.num))}catch{throw new N.RERR("ArtistError",`Bad note number in fingering: ${t[s]}`)}})}addTabArticulation(t,e,n,r,o){if(this.artist.log("addTabArticulations: ",t,e,n,r,o),t==="T"&&Le(e,n,r,o),t==="t"&&n.addModifier(new N.Flow.Annotation("T").setVerticalJustification(N.Flow.Annotation.VerticalJustify.BOTTOM)),mt(r)&&mt(o))return;let s=null,i={first_note:e,last_note:n,first_indices:r,last_indices:o,firstNote:e,lastNote:n,firstIndexes:r,lastIndexes:o};if(t==="s"&&(s=new N.Flow.TabSlide(i)),(t==="h"||t==="p")&&(s=new N.Flow.TabTie(i,t.toUpperCase())),(t==="T"||t==="t")&&(s=new N.Flow.TabTie(i," ")),t==="b"&&this.openBends(e,n,r,o),s){let c=J(this.artist.staves)?.color;c&&s.setStyle(rt(c)),this.artist.tab_articulations.push(s)}}addStaveArticulation(t,e,n,r,o){this.artist.log("addStaveArticulations: ",t,e,n,r,o);let s=null;if(t==="T"&&Le(e,n,r,o),["b","s","h","p","t","T"].includes(t)&&(s=new N.Flow.StaveTie({first_note:e,last_note:n,first_indices:r,last_indices:o,firstNote:e,lastNote:n,firstIndexes:r,lastIndexes:o})),s){let i=J(this.artist.staves)?.color;i&&s.setStyle(rt(i)),this.artist.stave_articulations.push(s)}}getPreviousNoteIndex(){let t=J(this.artist.staves).tab_notes,e=2;for(;e<=t.length;){let n=t[t.length-e];if(n instanceof N.Flow.TabNote)return t.length-e;if(!(n instanceof N.Flow.BarNote))break;e+=1}return-1}addDecorator(t){if(this.artist.log("addDecorator: ",t),!t)return;let e=J(this.artist.staves),n=e.tab_notes,r=e.note_notes,o=null,s=null;t==="v"&&(o=new N.Flow.Vibrato),t==="V"&&(o=new N.Flow.Vibrato,typeof o.setHarsh=="function"&&o.setHarsh(!0)),t==="u"&&(o=new N.Flow.Articulation("a|").setPosition(N.Flow.Modifier.Position.BELOW),s=new N.Flow.Articulation("a|").setPosition(N.Flow.Modifier.Position.BELOW)),t==="d"&&(o=new N.Flow.Articulation("am").setPosition(N.Flow.Modifier.Position.BELOW),s=new N.Flow.Articulation("am").setPosition(N.Flow.Modifier.Position.BELOW));let i=J(n);if(i&&o&&i.addModifier(o,0),s){let c=J(r);c&&(typeof c.addArticulation=="function"?c.addArticulation(0,s):typeof c.addModifier=="function"&&c.addModifier(s,0))}}addArticulations(t){this.artist.log("addArticulations: ",t);let e=J(this.artist.staves),n=e.tab_notes,r=e.note_notes;if(mt(n)||mt(t)){this.closeBends(0);return}let o=J(n),s=!1;["b","s","h","p","t","T","v","V"].forEach(i=>{let c=t.map((h,g)=>h&&h===i?g:-1).filter(h=>h>=0);if(mt(c))return;i==="b"&&(s=!0);let l=this.getPreviousNoteIndex(),d=null,m=null,f=[];if(l===-1)d=null,m=null;else{d=n[l];let h=d.getPositions();m=[];for(let g of c){let y=o.getPositions()[g];if(!y)continue;let b=y.fret==="X"&&i==="T",S=h.findIndex((T,A)=>{if(m.includes(A))return!1;if(b){let k=e.note?r[l].getKeys():d.getPlayNote(),p=e.note?J(r).getKeys():o.getPlayNote();return T.fret==="X"&&k[A]===p[g]}return T.str===y.str});S>=0&&(m.push(S),f.push(g))}}e.tab&&this.addTabArticulation(i,d,o,m||[],f),e.note&&f.length&&this.addStaveArticulation(i,r[l],J(r),m||[],f)}),s||this.closeBends(0)}};import{Accidental as wr,Fraction as xr,Music as Sr,StaveNote as kn,WrittenAccidentalState as kr}from"vexflow";import{Modifier as Oe}from"vexflow";var de=10,Sn=5;function zt(a,t){let e=a.side==="above"?"higher":"lower";return"Slide "+(a.edge==="in"?"in from "+a.side:"out toward a "+e+" fret")+" on string "+t}function vr(a,t,e){return{x:a+(e.edge==="in"?-de:de),y:t+(e.side==="above"?-Sn:Sn)}}var fe=class extends Oe{constructor(e){super();this.slide=e;this.setPosition(e.edge==="in"?Oe.Position.LEFT:Oe.Position.RIGHT)}static get CATEGORY(){return"OpenSlide"}draw(){let e=this.checkContext(),n=this.checkAttachedNote().getModifierStartXY(this.getPosition(),this.checkIndex()),r=vr(n.x,n.y,this.slide);e.openGroup("open-slide",this.getAttribute("id")),e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(r.x,r.y),e.stroke(),e.closeGroup(),this.setRendered()}};function pe(a,t,e){let n=new fe(e);a.getModifiers().some(o=>o instanceof fe&&o.getPosition()===n.getPosition())||(e.edge==="in"?a.setLeftDisplacedHeadPx(a.getLeftDisplacedHeadPx()+de+2):a.setRightDisplacedHeadPx(a.getRightDisplacedHeadPx()+de+2)),a.addModifier(n,t)}var me=class{constructor(t){this.signs=new WeakMap;this.artist=t}getNoteForFret(t,e){return en(this.artist.tuning,this.artist.key_manager,this.artist.music_api,t,e)}getNoteForABC(t,e){let n=t.key,r=e,o=t.accidental;return t.accidental_type&&(o=`${o||"n"}_${t.accidental_type}`),[n,r,o]}addStaveNote(t){let e={is_rest:!1,play_note:null,...t},n=J(this.artist.staves).note_notes,r=new N.Flow.StaveNote({keys:e.spec,duration:this.artist.current_duration,type:this.artist.current_head,clef:this.artist.current_clef,autoStem:!0});this.signs.set(r,e.signs),this.attachDots(r),e.play_note&&r.setPlayNote(e.play_note),n.push(r)}applyAccidentals(t){let e={};for(let[s,i]of Object.entries(new Sr().createScaleMap(t.key)))e[s]=i.slice(1)||"n";let n=new kr(e),r=new Map;for(let s of t.note_voices){let i=new xr(0,1);for(let c of s){let l=i.clone().simplify().toString(),d=r.get(l);d||(d={at:i.clone(),bar:!1,notes:[]},r.set(l,d)),c instanceof N.Flow.BarNote?d.bar=!0:(this.signs.has(c)&&d.notes.push(c),i.add(c.getTicks()))}}let o=new Map;for(let s of[...r.values()].sort((i,c)=>i.at.value()-c.at.value())){s.bar&&(n.reset(),o.clear());let i=new Map;for(let c of s.notes)St.get(c)?.forEach((l,d)=>{if(!l.inherit)return;let m=l.inherit.written[0],f=o.get(l.inherit.written)??e[m],h=xn(c,d);if(l.key=h?.key??m+(f==="n"?"":f)+l.key.slice(l.key.indexOf("/")),yt(l.key)===void 0)throw new nt("syntax","Transposed note is outside the playable MIDI range",l.inherit.range)}),this.signs.get(c).forEach((l,d)=>{if(!l)return;let m=i.get(l.key)??[];m.push({head:l,note:c,index:d}),i.set(l.key,m)});for(let[c,l]of i){let d=l[0].head.sign,m=l.some(h=>h.head.sign!==d);o.set(c,d);let f=n.sign(c,m?"ambiguous":d)!==void 0;for(let{head:h,note:g,index:y}of l)this.updateSign(g,y,h,f||m)}}}updateSign(t,e,n,r){let o=n.cautionary&&(n.literal||!r),s=n.literal||r||o;if(n.mark&&(!s||n.mark.isCautionary()!==o)){let i=t.getModifiers(),c=i.indexOf(n.mark);c>=0&&i.splice(c,1),delete n.mark}s&&!n.mark&&(n.mark=new wr(n.sign),o&&n.mark.setAsCautionary(),t.addModifier(n.mark,e))}addTabNote(t,e=null){let n=J(this.artist.staves).tab_notes;this.artist.stavesBuilder.reserveTabRhythmSpace();let r=new N.Flow.TabNote({positions:t.map(({str:o,fret:s})=>({str:o,fret:s})),duration:this.artist.current_duration},this.artist.customizations["tab-stems"]==="true");e&&r.setPlayNote(e),t.forEach(({prebend:o,openSlide:s},i)=>{s&&pe(r,i,s),o&&r.addModifier(re(o),i)}),n.push(r),this.attachDots(r)}attachDots(t){for(let e=0;e<this.artist.current_dots;e++)N.Flow.Dot.buildAndAttach([t],t instanceof N.Flow.TabNote?{index:0}:{all:!0})}setDuration(t,e=!1){let n=/^(\d+|[whq])(s?)(d*)$/i.exec(t.trim());if(!n)throw new N.RERR("ArtistError",`Invalid duration '${t}'`);let r=Number(e)||n[3].length;this.artist.current_dots=r,this.artist.current_head=n[2]?"s":"n",this.artist.current_duration=n[1]+"d".repeat(r)}addDrums(t){let e=J(this.artist.staves),n=this.artist.current_duration,r=new kn(oe.note(t,n));this.attachDots(r),e.note_notes.push(r),e.tab_notes.push(new N.Flow.GhostNote(n)),St.set(r,[])}addRest(t){this.artist.closeBends();let e=J(this.artist.staves);this.artist.stavesBuilder.reserveTabRhythmSpace();let n=t.explicit||Number(t.position)!==0,r=o=>{let s=new kn({keys:["r/4"],duration:this.artist.current_duration,type:"r"});if(s.setStave(o),n){let i=Number(t.position),c=o.getNumLines(),l=6-c,d=2*c-1,m=l+(i-1)/2;i<=0&&(m=l-1+i/2),i>=d&&(m=6+(i-d)/2),s.setRestLine(m)}return this.attachDots(s),s};e.note&&e.note_notes.push(r(e.note)),e.tab_notes.push(e.tab&&this.artist.customizations["tab-stems"]==="true"?r(e.tab):new N.Flow.GhostNote(this.artist.current_duration))}addChord(t,e,n){if(mt(t))return;this.artist.log("addChord: ",t);let r=J(this.artist.staves),o=[],s=[],i=[],c=[],l=[],d=[],m=[],f=[],h=0,g=t[0].string,y=0;if(t.forEach(b=>{h+=1,(b.abc||b.string!==g)&&(y=0,g=b.string),o[y]||(o[y]=[],s[y]=[],i[y]=[],c[y]=[],m[y]=[],l[y]=[],d[y]=null);let S=null,T=null,A=null,k=null,p,_,L;if(b.abc){let v=b.octave?b.octave:b.string;[S,T,A]=this.getNoteForABC(b.abc,v);let E=A?A.split("_")[0]:"";if(k=`${S}${E}`,b.abc.transposed&&!A&&!b.fret&&(L={written:S.toLowerCase()+"/"+T,range:b.abc.transposed},k=this.artist.music_api.createScaleMap(r.key)[S.toLowerCase()].replace(/n$/,"")),b.fret&&b.abc.transposed){let[R,I]=this.artist.tuning.getNoteForFret(Number(b.fret)+r.capo,b.string).split("/");_=R+"/"+(Number(I)-1+this.artist.current_octave_shift)}b.fret||(b.fret="X")}else if(b.fret){let v=String(Number(b.fret)+r.capo+(b.prebend?.semitones??0));[S,T,A]=this.getNoteForFret(v,b.string);let[E,R]=this.artist.tuning.getNoteForFret(v,b.string).split("/");k=E,p=Number(R)-1}else throw new N.RERR("ArtistError","No note specified");let B=parseInt(String(T),10)+this.artist.current_octave_shift,H=b.time?{time:b.time,dot:b.dot}:null,P=A?.split("_")[0],x=b.abc&&P&&P!=="n"?S+P:S;o[y].push(`${x}/${T}`);let C=(p??Number(T))+this.artist.current_octave_shift;s[y].push(`${k}/${B}`),i[y].push(_??`${k}/${C}`),c[y].push(P&&/^[a-g]/i.test(S)?{key:`${S[0].toLowerCase()}/${T}`,sign:P,literal:!!b.abc,cautionary:b.abc?b.abc.accidental_type==="c":this.artist.customizations.accidentals==="cautionary"&&P!=="n"}:null),m[y].push({fret:b.fret,str:b.string,prebend:b.prebend,openSlide:b.openSlide,marks:b.marks,inherit:L}),b.articulation?l[y].push(b.articulation):l[y].push(null),f[y]=H,b.decorator&&(d[y]=b.decorator),y+=1}),o.forEach((b,S)=>{if(f[S]&&this.setDuration(f[S].time,f[S].dot),this.addTabNote(m[S],s[S]),r.note&&(this.addStaveNote({spec:b,signs:c[S],play_note:s[S]}),!r.tab)){let A=m[S].filter(k=>k.prebend).map(k=>Ft(k.prebend,k.str));for(let k of m[S])k.openSlide&&A.push(zt(k.openSlide,k.str));if(A.length){let k=new N.Flow.Annotation(A.join(" \xB7 "));k.setVerticalJustification(N.Flow.Annotation.VerticalJustify.TOP),J(r.note_notes).addModifier(k,0)}}m[S].forEach((A,k)=>{A.marks&&(r.tab&&Vt(J(r.tab_notes),k,A.marks,!0),r.note&&Vt(J(r.note_notes),k,A.marks,!1))});let T=i[S].map((A,k)=>{let p=m[S][k].prebend;return{key:A,release:p?.release?p.semitones:0,inherit:m[S][k].inherit}});St.set(J(r.tab_notes),T),r.note&&St.set(J(r.note_notes),T),this.artist.addArticulations(l[S]),d[S]&&this.artist.addDecorator(d[S])}),e){let b=[];for(let S=0;S<h;S+=1)b.push(e);this.artist.addArticulations(b)}n&&this.artist.addDecorator(n)}addNote(t){this.addChord([t],null,null)}};import{Beam as Er,Fraction as Pr,Voice as Mr}from"vexflow";function Ie(a){let t=a;t==="C"&&(t="4/4"),t==="C|"&&(t="2/2");let e=/^(?:\((\d+(?:\+\d+)+)\)|(\d+(?:\+\d+)+))\/(\d+)$/.exec(t),n;if(e){let r=(e[1]||e[2]).split("+").map(Number),o=Number(e[3]);if(r.includes(0))throw new Error("Empty beat group");n=r.map(s=>new Pr(s,o)),t=r.reduce((s,i)=>s+i,0)+"/"+o}return new Mr(t),{meter:t,groups:n??Er.getDefaultBeamGroups(t)}}var he=class{constructor(t){this.artist=t}addBar(t){this.artist.log("addBar: ",t),this.artist.closeBends(),this.artist.key_manager.reset();let e=J(this.artist.staves),n=N.Flow.Barline.type,r=n.SINGLE;switch(t){case"single":r=n.SINGLE;break;case"double":r=n.DOUBLE;break;case"end":r=n.END;break;case"repeat-begin":r=n.REPEAT_BEGIN;break;case"repeat-end":r=n.REPEAT_END;break;case"repeat-both":r=n.REPEAT_BOTH;break;default:r=n.SINGLE;break}let o=new N.Flow.BarNote().setType(r);e.tab_notes.push(o),e.note&&e.note_notes.push(new N.Flow.BarNote().setType(r))}reserveTabRhythmSpace(){let t=J(this.artist.staves);!t.tab||t.tabRhythmSpace||this.artist.customizations["tab-stems"]!=="true"||(t.tabRhythmSpace=(t.note?3:2)*t.tab.getSpacingBetweenLines(),t.tab.setY(t.tab.getY()+t.tabRhythmSpace),this.artist.last_y+=t.tabRhythmSpace)}addVoice(t={}){this.artist.closeBends();let e=J(this.artist.staves);if(!e){this.addStave("stave",t);return}e.tab_notes.length?(e.tab_notes=[],e.note_notes=[],e.tab_voices.push(e.tab_notes),e.note_voices.push(e.note_notes),e.voiceSettings.push({options:{...this.artist.customizations},direction:t.voice,groups:[]})):Object.assign(J(e.voiceSettings),{direction:t.voice,options:{...this.artist.customizations}})}addStave(t,e){let n={tuning:"standard",clef:"treble",key:"C",notation:t==="tabstave"?"false":"true",tablature:t==="stave"?"false":"true",strings:6};ee(n,e),this.artist.log("addStave: ",t,n);let r=null,o=null,s=this.artist.x+Number(this.artist.customizations["connector-space"]),i=40;n.notation==="true"&&(o=new N.Flow.Stave(s,this.artist.last_y,Number(this.artist.customizations.width)-20,{leftBar:!1}),n.color&&o.setDefaultLedgerLineStyle(rt(n.color)),n.clef!=="none"&&o.addClef(n.clef),o.addKeySignature(n.key),n.time&&n["show-time"]!=="false"&&o.addTimeSignature(n.time),this.artist.last_y+=o.getHeight()+this.artist.options.note_stave_lower_spacing+parseInt(String(this.artist.customizations["stave-distance"]),10),i=o.getNoteStartX(),this.artist.current_clef=n.clef==="none"?"treble":n.clef),n.tablature==="true"&&(r=new N.Flow.TabStave(s,this.artist.last_y,Number(this.artist.customizations.width)-20,{leftBar:!1}).setNumLines(n.strings),n.clef!=="none"&&r.addTabGlyph(),r.setNoteStartX(i),this.artist.last_y+=r.getHeight()+this.artist.options.tab_stave_lower_spacing),this.artist.closeBends();let{meter:c,groups:l}=Ie(n.time||"4/4"),d=[],m=[];this.artist.staves.push({tab:r,note:o,tab_voices:[d],note_voices:[m],tab_notes:d,note_notes:m,meter:c,key:n.key,capo:Number(n.capo??0),color:n.color,tabRhythmSpace:0,voiceSettings:[{options:{...this.artist.customizations},direction:n.voice,groups:[]}],text_voices:[],beam_groups:l}),this.artist.tuning.setTuning(n.tuning),this.artist.key_manager.setKey(n.key)}};var ge=class{constructor(t){this.artist=t}addTextVoice(){this.color=void 0,J(this.artist.staves).text_voices.push([])}setTextFont(t){if(!t)return;let e=t.match(/^([^-]*)-([^-]*)-([^-]*)(?:-(.*))?$/);if(e){if(e[4]!==void 0&&!Pt(e[4]))throw new N.RERR("ArtistError",`Invalid text color '${e[4]}'`);this.color=e[4],this.artist.customizations["font-face"]=e[1],this.artist.customizations["font-size"]=parseInt(e[2],10),this.artist.customizations["font-style"]=e[3]}}addTextNote(t,e=0,n="center",r=!0,o=!1){let s=J(this.artist.staves).text_voices;if(mt(s))throw new N.RERR("ArtistError","Can't add text note without text voice");let i=this.artist.customizations["font-face"],c=this.artist.customizations["font-size"],l=this.artist.customizations["font-style"],d=N.Flow.TextNote.Justification.CENTER;switch(n){case"center":d=N.Flow.TextNote.Justification.CENTER;break;case"left":d=N.Flow.TextNote.Justification.LEFT;break;case"right":d=N.Flow.TextNote.Justification.RIGHT;break;default:d=N.Flow.TextNote.Justification.CENTER;break}let m=o?"b":this.artist.current_duration,f={text:t,duration:m,smooth:r,ignoreTicks:o,font:{family:i,size:c,weight:l}};t.startsWith("#")&&(f.glyph=t.slice(1),f.text="",f.font=null);let h=new N.Flow.TextNote(f).setLine(e).setJustification(d);this.color&&h.setStyle(rt(this.color)),J(s).push(h)}};var Rt=class a{constructor(t,e,n,r){this.customizations={};this.staves=[];this.tab_articulations=[];this.stave_articulations=[];this.player_voices=[];this.last_y=0;this.current_duration="q";this.current_dots=0;this.current_head="n";this.current_clef="treble";this.current_bends={};this.current_octave_shift=0;this.bend_start_index=null;this.bend_start_strings=null;this.rendered=!1;this.renderer_context=null;this.player=null;this.x=t,this.y=e,this.width=n,this.options={font_face:Ae,font_size:10,font_style:null,bottom_spacing:30,tab_stave_lower_spacing:10,note_stave_lower_spacing:0,scale:1},r&&ee(this.options,r),this.renderer=new ce(this),this.articulations=new ue(this),this.notes=new me(this),this.stavesBuilder=new he(this),this.text=new ge(this),this.reset()}static{this.DEBUG=!1}static{this.NOLOGO=!0}log(...t){a.DEBUG&&console&&console.log("(Vex.Flow.Artist)",...t)}reset(){this.tuning=new N.Flow.Tuning,this.key_manager=new N.Flow.KeyManager("C"),this.music_api=new N.Flow.Music,this.customizations={"font-size":this.options.font_size,"font-face":this.options.font_face,"font-style":this.options.font_style,"annotation-position":"bottom",scale:this.options.scale,width:this.width,"stave-distance":0,space:0,player:"false",tempo:120,instrument:"acoustic_grand_piano",accidentals:"standard","tab-stems":"false","tab-stem-direction":"up",beams:"auto","beam-rests":"true","beam-stemlets":"true","beam-middle-only":"false","connector-space":5},this.staves=[],this.tab_articulations=[],this.stave_articulations=[],this.player_voices=[],this.last_y=this.y,this.current_duration="q",this.current_dots=0,this.current_head="n",this.current_clef="treble",this.current_bends={},this.current_octave_shift=0,this.bend_start_index=null,this.bend_start_strings=null,this.rendered=!1,this.renderer_context=null}attachPlayer(t){this.player=t}setOptions(t,e=(n,r)=>new N.RERR("ArtistError",r)){this.log("setOptions: ",t);let n=Qe(this.customizations);if(Object.entries(t).forEach(([r,o])=>{if(!n.includes(r))throw e(r,`Invalid option '${r}'`);if(["width","scale","font-size","tempo","space","stave-distance","connector-space"].includes(r)){let s=Number(o),i=["width","scale","font-size","tempo"].includes(r);if(!Number.isFinite(s)||String(o).trim()===""||i&&s<=0)throw e(r,`Invalid numeric value for '${r}': ${o}`)}if(r==="accidentals"&&!["standard","cautionary"].includes(o))throw e(r,"accidentals must be standard or cautionary");if(r==="beams"&&!["auto","off","explicit"].includes(o))throw e(r,"beams must be auto, explicit or off")}),Object.assign(this.customizations,t),this.rendered&&t.width!==void 0)for(let r of this.staves)r.note?.setWidth(Number(t.width)-20),r.tab?.setWidth(Number(t.width)-20);this.last_y+=Number(t.space??0),t.player==="true"&&(this.last_y+=15)}getPlayerData(){return{voices:this.player_voices,context:this.renderer_context,scale:Number(this.customizations.scale)}}render(t){this.renderer.render(t)}draw(t){this.render(t)}isRendered(){return this.rendered}isLogoHidden(){return!0}setDuration(t,e=!1){this.notes.setDuration(t,e)}addBar(t){this.stavesBuilder.addBar(t)}makeTuplets(t,e){this.articulations.makeTuplets(t,e)}addAnnotations(t){this.articulations.addAnnotations(t)}addArticulations(t){this.articulations.addArticulations(t)}addDecorator(t){this.articulations.addDecorator(t||null)}addRest(t){this.notes.addRest(t)}addChord(t,e,n){this.notes.addChord(t,e||null,n||null)}addNote(t){this.notes.addNote(t)}addTextVoice(){this.text.addTextVoice()}setTextFont(t){this.text.setTextFont(t)}addTextNote(t,e=0,n="center",r=!0,o=!1){this.text.addTextNote(t,e,n,r,o)}addVoice(t){this.stavesBuilder.addVoice(t||{})}addStave(t,e){this.stavesBuilder.addStave(t,e)}openBends(t,e,n,r){this.articulations.openBends(t,e,n,r)}closeBends(t=1){this.articulations.closeBends(t)}runCommand(t,e=0,n=0){this.log("runCommand: ",t);let r=t.split(/\s+/);switch(r[0]){case"color":{if(r.length!==2||!Pt(r[1]))throw new N.RERR("ArtistError",`Expected a CSS color name or hex value at line ${e} column ${n}`);let o=J(this.staves),s=o&&J(o.note_notes),i=o&&J(o.tab_notes);if(!s&&!i||(s||i)instanceof N.Flow.BarNote)throw new N.RERR("ArtistError",`Put !color! after a note or rest at line ${e} column ${n}`);s?.setStyle(rt(r[1])),s?.setLedgerLineStyle?.(rt(r[1])),i?.setStyle(rt(r[1]));break}case"octave-shift":if(r.length!==2||!/^[+-]?\d+$/.test(r[1])||!Number.isSafeInteger(Number(r[1])))throw new N.RERR("ArtistError",`Invalid octave shift at line ${e} column ${n}`);this.current_octave_shift=Number(r[1]),this.log("Octave shift: ",this.current_octave_shift);break;default:throw new N.RERR("ArtistError",`Invalid command '${r[0]}' at line ${e} column ${n}`)}}};var be=class{constructor(t){this.artist=t}newError(t,e){return new N.RERR("ParseError",`${e} in line ${t._l} column ${t._c}`)}parseStaveOptions(t,e="voice"){let n={};if(!t)return n;let r=null;t.forEach(i=>{let c=l=>this.newError(i,l);switch(n[i.key]=i.value,i.key){case"fingering":case"accents":break;case"notation":case"tablature":if(r=i,!["true","false"].includes(i.value))throw c(`'${i.key}' must be 'true' or 'false'`);break;case"color":if(e==="voice"||!Pt(i.value))throw c("Expected a stave color as a CSS name or hex value");break;case"pickup":if(!/^([1-9]\d*)\/([1-9]\d*)$/.test(i.value))throw c("Expected a pickup span such as 1/4");break;case"fragment":if(!["true","false"].includes(i.value))throw c("fragment must be true or false");break;case"show-time":if(!["true","false"].includes(i.value))throw c("show-time must be true or false");break;case"key":{if(!(N.Flow?.hasKeySignature?N.Flow.hasKeySignature(i.value):tn(N.Flow?.keySignature?.keySpecs,i.value)))throw c(`Invalid key signature '${i.value}'`);break}case"clef":{let l=["treble","bass","tenor","alto","percussion","none"];if(!l.includes(i.value))throw c(`'clef' must be one of ${l.join(", ")}`);break}case"voice":{let l=["top","bottom","new"];if(!l.includes(i.value))throw c(`'voice' must be one of ${l.join(", ")}`);break}case"time":try{Ie(i.value)}catch{throw c(`Invalid time signature: '${i.value}'`)}break;case"tuning":try{new N.Flow.Tuning(i.value)}catch{throw c(`Invalid tuning: '${i.value}'`)}break;case"capo":if(!/^\d+$/.test(i.value)||!Number.isSafeInteger(Number(i.value)))throw c("Expected a nonnegative capo fret");break;case"strings":{let l=Number(i.value);if(!Number.isInteger(l)||l<4||l>8)throw c(`Invalid number of strings: ${l}`);break}default:throw c(`Invalid option '${i.key}'`)}});let o=n.notation??(e==="tabstave"?"false":"true"),s=n.tablature??(e==="stave"?"false":"true");if(o==="false"&&s==="false")throw this.newError(r,"Both 'notation' and 'tablature' can't be invisible");return n}parseCommand(t){t.command==="bar"&&this.artist.addBar(t.type),t.command==="tuplet"&&this.artist.makeTuplets(t.params.tuplet,t.params.notes),t.command==="annotations"&&this.artist.addAnnotations(t.params),t.command==="rest"&&this.artist.addRest(t.params),t.command==="command"&&this.artist.runCommand(t.params,t._l,t._c)}parseChord(t){this.artist.log("parseChord:",t),this.artist.addChord(Ze(t.chord,e=>ne(e,"time","dot","fret","prebend","openSlide","marks","abc","octave","string","articulation","decorator")),t.articulation,t.decorator)}parseFret(t){this.artist.addNote(ne(t,"time","dot","fret","prebend","openSlide","marks","string","articulation","decorator"))}parseABC(t){this.artist.addNote(ne(t,"time","dot","fret","prebend","openSlide","marks","abc","octave","string","articulation","decorator"))}parseStaveElements(t){this.artist.log("parseStaveElements:",t);let e=J(this.artist.staves),n=J(e.voiceSettings),r;if(t.forEach(o=>{if(n.options.beams==="explicit"){if(o.command==="open_beam"){if(r)throw this.newError(o,"Nested beam group");r={index:e.tab_notes.length,token:o}}if(o.command==="close_beam"){if(!r)throw this.newError(o,"Missing opening beam bracket");let s=e.tab_notes.slice(r.index);if(s.length<2||s.some(i=>i.getIntrinsicTicks()>=N.Flow.RESOLUTION/4))throw this.newError(o,"Beams need at least two eighth notes or shorter values");n.groups.push([r.index,e.tab_notes.length]),r=void 0}if(r&&o.command==="bar")throw this.newError(o,"Beam crosses a barline")}if(o.time&&this.artist.setDuration(o.time,o.dot),o.command&&this.parseCommand(o),o.drums){let s=o.drums.map(c=>c.id),i=on(this.artist.current_clef,!!e.tab,s,this.artist.current_head==="s");if(i)throw this.newError(o,i);this.artist.notes.addDrums(s)}o.chord&&this.parseChord(o),o.abc?this.parseABC(o):o.fret&&this.parseFret(o)}),r)throw this.newError(r.token,"Missing closing beam bracket")}parseStaveText(t){mt(t)||this.artist.addTextVoice();let e=0,n="center",r=!0,o=null,s=()=>this.artist.addTextNote("",0,n,!1,!0),i=(c,l)=>{let d=!1,m=c;m[0]==="|"&&(d=!0,m=m.slice(1));try{this.artist.addTextNote(m,e,n,r,d)}catch(f){throw this.newError(l,`Bad text or duration. Did you forget a comma?${f}`)}};t.forEach(c=>{let l=c.text.trim();if(l.match(/\.font=.*/))o=l.slice(6),this.artist.setTextFont(o);else if(l[0]===":")this.artist.setDuration(l.slice(1));else if(l[0]==="."){let d=l.slice(1);switch(d){case"center":case"left":case"right":n=d;break;case"strict":r=!1;break;case"smooth":r=!0;break;case"bar":case"|":s();break;default:if(!/^[+-]?\d+$/.test(d))throw this.newError(c,`Invalid text position '${d}'`);e=Number(d);break}}else l==="|"?s():l.slice(0,2)==="++"?this.artist.addTextVoice():i(l,c)})}generate(t){t.forEach(e=>{switch(e.element){case"piano":throw this.newError(e,'Use layout="flow" or parseScore for a piano grand staff');case"stave":case"tabstave":this.artist.addStave(e.element,this.parseStaveOptions(e.options,e.element)),e.notes&&this.parseStaveElements(e.notes),e.text&&this.parseStaveText(e.text);break;case"voice":this.artist.addVoice(this.parseStaveOptions(e.options,e.element)),e.notes&&this.parseStaveElements(e.notes),e.text&&this.parseStaveText(e.text);break;case"options":{let n={};e.params.forEach(r=>{r.key!=="transpose"&&(n[r.key]=r.value)}),this.artist.setOptions(n,(r,o)=>this.newError(e.params.find(s=>s.key===r),o));break}default:throw this.newError(e,`Invalid keyword '${e.element}'`)}})}};function Tr(a){return typeof a?.addStave=="function"}var Ct=class a{constructor(t,e){this.valid=!1;if(Tr(t)){if(e?.language!==1)throw new TypeError("Use new VexTab(artist, { language: 1 }) for fixed engraving, or new VexTab() and renderScore() for language 2.");this.artist=t,this.compiler=new be(t)}else{if(e||t?.language===1)throw new TypeError("Language 1 fixed engraving requires new VexTab(artist, { language: 1 }).");if(t?.language!==void 0&&t.language!==2)throw new RangeError("Expected VexTab language 1 or 2");this.capacity=t?.capacity}}static{this.DEBUG=!1}reset(){this.valid=!1}isValid(){return this.valid}getArtist(){return this.artist}parse(t=""){this.reset(),a.DEBUG&&console.log(`(Vex.Flow.VexTab) Parsing:
|
|
351
|
+
`+t);let e=this.compiler?this.parseFixed(t):Lt(t,{language:2,capacity:this.capacity});return this.valid=!!e,e}parseFixed(t){let e;try{e=rn(t)}catch(n){throw n instanceof nt?Object.assign(new N.RERR("ParseError",n.message),{range:n.range}):n}return e&&this.compiler.generate(e),e}};function Dt(a){if(typeof a=="number")return a;if(!/^\d+\/[1-9]\d*$/.test(a))return NaN;let[t,e]=a.split("/").map(Number);return Number.isSafeInteger(t)&&Number.isSafeInteger(e)?t/e:NaN}function En(a){let t=a.getSpacingBetweenLines()/2;return{left:a.getX(),right:a.getX()+a.getWidth(),top:a.getYForLine(0)-t,bottom:a.getYForLine(a.getNumLines()-1)+t}}function _r(a,t,e,n){let r=new Map,o=new Map;for(let c of a){let{partIndex:l,score:d,local:m,view:f}=c,h=d.measures[t-1],g=m.staves[t-1];g.forEach((y,b)=>r.set(y,{partIndex:l,staffIndex:b,bounds:En(y)}));for(let[y,b]of f.staves.entries())for(let S of h.voices)if(!(S.hand&&S.hand!==b))for(let T of S.events){let A=Dt(T.onset),k=m.getNote(f.eventId(b,T.id)),p=o.get(A);if(!p){let B=k.getAbsoluteX()-(k.isCenterAligned()?k.getCenterXShift():0);p={time:A,x:B,events:new Map},o.set(A,p)}let _=r.get(k.getStave())??r.get(g[y]),L=p.events.get(_);L?L.push(T.id):p.events.set(_,[T.id])}}let s=[...o.values()].sort((c,l)=>c.time-l.time),i=[...r.values()];return s.push({time:Dt(a[0].score.measures[t-1].span),x:i[0].bounds.right,events:new Map}),{measure:t,system:e,systemBounds:n,anchors:s,staves:i}}function Pn(a,t,e){let n=0,r=a.length;for(;n<r;){let o=Math.floor((n+r)/2);a[o][e]<t?n=o+1:r=o}return n}function Mn(a,t,e,n,r){return n+(a-t)/(e-t)*(r-n)}function Yt(a,t,e,n,r){let{partIndex:o,staffIndex:s,bounds:i}=t;return{partIndex:o,staffIndex:s,measure:a.measure,offset:e,system:a.system,x:n,staffBounds:i,staffCenterY:(i.top+i.bottom)/2,systemBounds:a.systemBounds,eventIds:r?.events.get(t)??[]}}var Xt=.5;function Ar(a,t,e){let n=a.anchors;if(t<n[0].x-Xt||t>n[n.length-1].x+Xt)return;let r=a.staves.find(l=>e>=l.bounds.top&&e<=l.bounds.bottom);if(!r)return;let o=Math.min(n.length-1,Pn(n,t,"x")),s=n[o],i=n[o-1],c=i&&t-i.x<s.x-t?i:s;return Math.abs(c.x-t)<=Xt?Yt(a,r,c.time,c.x,c):Yt(a,r,Mn(t,i.x,s.x,i.time,s.time),t)}function ye(a){if(a instanceof SVGSVGElement)return({clientX:n,clientY:r})=>{let o=a.getScreenCTM();if(!o)return;let{x:s,y:i}=new DOMPoint(n,r).matrixTransform(o.inverse());if(Number.isFinite(s)&&Number.isFinite(i))return{x:s,y:i}};let t=parseFloat(a.style.width),e=parseFloat(a.style.height);return({clientX:n,clientY:r})=>{let o=a.getBoundingClientRect();if(o.width&&o.height)return{x:(n-o.left)*t/o.width,y:(r-o.top)*e/o.height}}}function Tn(a,t,e,n,r){let o=a.sheet.getContinuousLayout().rows,s=[],i=o.map(c=>{let l=c.measures.flatMap(d=>a.staves[d-1].map(En));return{left:Math.min(...l.map(d=>d.left)),right:Math.max(...l.map(d=>d.right)),top:Math.min(...l.map(d=>d.top)),bottom:Math.max(...l.map(d=>d.bottom))}});return o.forEach((c,l)=>{for(let d of c.measures)s[d-1]=_r(t,d,l+1,i[l])}),{clientPoint:r,positionAt({partIndex:c,staffIndex:l=0,measure:d,offset:m}){if(!Number.isInteger(d))return;let f=s[d-1],h=f?.staves.find(T=>T.partIndex===c&&T.staffIndex===l),g=Dt(m);if(!h||!Number.isFinite(g)||g<0)return;let y=Pn(f.anchors,g,"time"),b=f.anchors[y];if(!b)return;if(b.time===g)return Yt(f,h,g,b.x,b);let S=f.anchors[y-1];if(S)return Yt(f,h,g,Mn(g,S.time,b.time,S.x,b.x))},hitTest({x:c,y:l}){if(!Number.isFinite(c)||!Number.isFinite(l))return;let d=i.findIndex(y=>l>=y.top&&l<=y.bottom&&c>=y.left-Xt&&c<=y.right+Xt);if(d>=0)for(let y of o[d].measures){let b=Ar(s[y-1],c,l);if(b)return b}let m=e.hitTest(c,l);if(!m||m.reference||m.role==="mark")return;let f=s[m.measure-1],h=f.staves[n.findIndex(y=>y.id===m.staff)],g=f.anchors.find(y=>y.events.get(h)?.includes(m.sourceEvent));if(g)return Yt(f,h,g.time,g.x,g)}}}var lt=ir(Nn());var Nr="http://www.w3.org/2000/svg";var Rr=0;function bt(a,t={}){let e=document.createElementNS(Nr,a);for(let[n,r]of Object.entries(t))e.setAttribute(n,String(r));return e}function ve(a,t,e){let n=e-t;if(n<=0)return 0;let r=Math.min(.075,n/2),o=Math.min(.14,n/2);return Math.max(0,Math.min(1,(a-t+r)/r,(e-a)/o))}var Gt=class{constructor(){this.layer=bt("g",{class:"vextab-playback-ink",color:"var(--vextab-playback-tint, #fff600)","pointer-events":"none","aria-hidden":"true"});this.bar=bt("line",{stroke:"#a8a8a8","stroke-opacity":.55,"stroke-width":3.5,"stroke-linecap":"round"});this.gradient="vextab-glow-"+ ++Rr;this.dots=[];let t=bt("radialGradient",{id:this.gradient});for(let[n,r]of[[0,.5],[.32,.72],[.52,.6],[.76,.22],[1,0]])t.append(bt("stop",{offset:n,"stop-color":"currentColor","stop-opacity":r}));let e=bt("defs");e.append(t),this.layer.append(e,this.bar)}drawDot(t,e,n,r){let o=this.dots[t];o||(o={node:bt("ellipse",{rx:17,ry:13,fill:"url(#"+this.gradient+")",stroke:"none"})},this.dots.push(o)),o.point!==e&&(o.node.parentNode!==r&&r.append(o.node),o.node.setAttribute("cx",String(e.x)),o.node.setAttribute("cy",String(e.y)),o.point=e),o.opacity!==n&&o.node.setAttribute("opacity",String(n)),o.opacity=n}hideUnused(t){for(let e=t;e<this.dots.length;e++){let n=this.dots[e];n.opacity!==0&&n.node.setAttribute("opacity","0"),n.opacity=0}}};var $t=class{constructor(t,e,n,r){this.surface=t;this.music=e;this.follow=r;this.ink=new Gt;this.anchors=[];this.pulses=[];this.active=[];this.anchor=0;this.pulse=0;this.frame=0;this.pages=new Map;this.printedRows=new Map;for(let o of e.events){let s=n.get(o.source);if(!s)continue;let{x:i,row:c,heads:l}=s,d=this.anchors[this.anchors.length-1];(!d||Math.abs(d.time-o.time)>1e-6)&&this.anchors.push({time:o.time,x:i,row:c,slope:0,speed:0}),l.length&&this.pulses.push({time:o.time,end:o.time+o.duration,heads:l,row:c})}this.anchors.forEach((o,s)=>{let i=this.anchors[s+1],c=(i?.row===o.row?i.x:o.row.right)-o.x,l=(i?.time??e.duration)-o.time;o.slope=l>0?c/l:0;let d=this.anchors[s-1];o.speed=o.slope,d?.row===o.row&&(o.speed=d.slope*o.slope>0?2/(1/d.slope+1/o.slope):0)})}rowLayer(t){let e=t.printedPage;if(!e)return this.ink.layer.parentNode||this.surface?.append(this.ink.layer),this.ink.layer;let n=this.printedRows.get(t);if(n)return n;let r=this.pages.get(e);if(!r){let s=document.createElement("div");s.className="vextab-playback-page",e.before(s),r=bt("svg",{"aria-hidden":"true",class:"vextab-playback-paper"});for(let i of["viewBox","width","height","preserveAspectRatio"])e.hasAttribute(i)&&r.setAttribute(i,e.getAttribute(i));r.style.cssText="pointer-events:none;background:transparent;border-color:transparent",s.append(e,r),this.pages.set(e,r),this.ink.layer.parentNode||r.append(this.ink.layer)}let o=bt("g",{transform:"scale("+t.scale+")",class:"vextab-playback-ink","pointer-events":"none"});return r.append(o),this.printedRows.set(t,o),o}moveToRow(t){this.rowLayer(t).prepend(this.ink.bar),this.ink.bar.setAttribute("y1",String(t.top)),this.ink.bar.setAttribute("y2",String(t.bottom)),this.row=t}start(t){if(!this.anchors.length)return;let e=()=>{let n=t();for(;this.anchor+1<this.anchors.length&&this.anchors[this.anchor+1].time<=n;)this.anchor++;let r=this.anchors[this.anchor],o=r.row!==this.row;o&&this.moveToRow(r.row),this.drawBar(n,r,this.anchors[this.anchor+1]),this.follow?.(this.ink.bar,o),this.drawHeads(n),this.frame=requestAnimationFrame(e)};e()}drawBar(t,e,n){let r=n?.row===e.row,o=(r?n.x:e.row.right)-e.x,s=(n?.time??this.music.duration)-e.time,i=s>0?Math.max(0,Math.min(1,(t-e.time)/s)):0,c=r?n.speed:e.slope,l=(1-i)*(e.speed*s-o)+i*(o-c*s),d=e.x+i*o+i*(1-i)*l;this.ink.bar.setAttribute("transform","translate("+d+" 0)")}drawHeads(t){for(;this.pulse<this.pulses.length&&this.pulses[this.pulse].time<=t+.075;)this.active.push(this.pulses[this.pulse++]);let e=0,n=0;for(let r of this.active){if(r.end<=t)continue;this.active[e++]=r;let o=ve(t,r.time,r.end);if(o>0)for(let s of r.heads)this.ink.drawDot(n++,s,o,this.rowLayer(r.row))}this.active.length=e,this.ink.hideUnused(n)}stop(){cancelAnimationFrame(this.frame),this.ink.layer.remove();for(let[t,e]of this.pages)e.parentElement?.replaceWith(t)}};var Wt=new WeakMap;function we(a){return{top:Math.min(...a.map(t=>t.getYForLine(0)))-7,bottom:Math.max(...a.map(t=>t.getYForLine(t.getNumLines()-1)))+7,right:Math.max(...a.map(t=>t.getNoteEndX()))}}function Cr(a,t,e){let n=[],r=t[0].getAbsoluteX();for(let o of t){if(o.isRest()||!e.some(Boolean))continue;let s=o.getYs(),i="getHeadInk"in o?o.getHeadInk():[];for(let c=0;c<s.length;c++){let l=i[c]?i[c].x+i[c].w/2:o.getAbsoluteX();c===0&&o===t[0]&&(r=l),e[c]&&n.push({x:l,y:s[c]})}}return{row:a,x:r,heads:n}}function Rn(a){let t=new Map;for(let e of a.staves){let n=[e.note,e.tab].filter(Boolean);if(!n.length)continue;let r=we(n);(e.note?e.note_voices:e.tab_voices).forEach((s,i)=>s.forEach((c,l)=>{if(c.shouldIgnoreTicks())return;let d=e.note&&e.tab&&e.tab_voices[i]?.[l],m=d&&!d.shouldIgnoreTicks()?[c,d]:[c],f=(St.get(c)??[]).map(h=>/^[a-g]/i.test(h.key));t.set(c,Cr(r,m,f))}))}return t}function Cn(a,t,e,n){let r=new Map,o=new Map;for(let s of e){let{measure:i}=s[1];o.has(i)||o.set(i,[]),o.get(i).push(s)}for(let s of a.pages){for(let i of s.systems){let c=s.svg.querySelector('[data-system="'+i.measures[0]+'"] > g:last-child'),l=i.y/n+(c?.transform.baseVal[0]?.matrix.f??0),d=i.x/n,m;for(let f of i.measures)for(let[h,g]of o.get(f)??[])m??={top:l+g.row.top,bottom:l+g.row.bottom,right:d+g.row.right,printedPage:s.svg,scale:n},r.set(h,{row:m,x:d+g.x,heads:[]})}for(let i of s.heads.occurrences){if(i.reference||i.role==="mark")continue;let c=t.get(i.sourceEvent),l=r.get(i.sourceEvent);if(!c||!l||typeof i.sourceHead!="number")continue;let d=c.heads[i.sourceHead];if(c.silent||!d||!d.sounding&&d.midi===void 0)continue;let m=i.bounds,f={x:(m.x+m.w/2)/n,y:(m.y+m.h/2)/n};l.heads.length||(l.x=f.x),l.heads.push(f)}}return r}function Br(a){let t=[];for(let e=a.parentElement;e&&e!==document.scrollingElement;e=e.parentElement){if(!(e instanceof HTMLElement))continue;let n=getComputedStyle(e),r=/^(auto|scroll|overlay)$/.test(n.overflowX),o=/^(auto|scroll|overlay)$/.test(n.overflowY);(r||o)&&t.push({element:e,x:r,y:o})}return t.push({element:document.scrollingElement,x:!0,y:!0}),t}function Bn(a,t,e,n){return t-a>=n-e||a<e?a-e:Math.max(0,t-n)}var xe=class{constructor(){this.ports=[];this.reducedMotion=matchMedia("(prefers-reduced-motion: reduce)");this.lastFrame=0;this.nextCheck=0}update(t,e){let n=performance.now();if(!e&&n<this.nextCheck)return;(e||!this.ports.length)&&(this.ports=Br(t));let r=Math.min(40,this.lastFrame?n-this.lastFrame:16),o=this.reducedMotion.matches?1:1-Math.exp(-r/65);this.lastFrame=n;let s=t.getBoundingClientRect(),{left:i,right:c,top:l,bottom:d}=s,m=!1;for(let{element:f,x:h,y:g}of this.ports){let y=f===document.scrollingElement,b=y?void 0:f.getBoundingClientRect(),S=b?b.width/(f.offsetWidth||1):1,T=b?b.height/(f.offsetHeight||1):1;if(!S||!T)continue;let A=window.visualViewport,k=b?b.left+f.clientLeft*S:A?.offsetLeft??0,p=b?b.top+f.clientTop*T:A?.offsetTop??0,_=y?A?.width??f.clientWidth:f.clientWidth*S,L=y?A?.height??f.clientHeight:f.clientHeight*T,B=h?Bn(i,c,k+12,k+_-12)/S:0,H=Math.min(68,L*.12),P=g?Bn(l,d,p+H,p+L-H)/T:0,x=Math.max(0,Math.min(f.scrollWidth-f.clientWidth,f.scrollLeft+B)),C=Math.max(0,Math.min(f.scrollHeight-f.clientHeight,f.scrollTop+P)),v=x-f.scrollLeft,E=C-f.scrollTop;if(Math.abs(v)>=1||Math.abs(E)>=1){m=!0;let R=I=>Math.sign(I)*Math.min(Math.abs(I),Math.max(1,Math.abs(I)*o));f.scrollBy({left:R(v),top:R(E),behavior:"instant"})}i-=v*S,c-=v*S,l-=E*T,d-=E*T}this.nextCheck=m?n:n+120}};function Fr(a){let t=[];for(let e=a.parentElement;e&&e!==document.documentElement;e=e.parentElement){let n=getComputedStyle(e),r=n.overflowX!=="visible",o=n.overflowY!=="visible";(r||o)&&t.push({element:e,x:r,y:o})}return t}function Fn(a,t,e,n,{size:r,inset:o}){let s=Fr(a),i=n.querySelector(".vextab-control-panel"),c=window.visualViewport,l=0,d,m=!1;function f(){l=0;let S=t.getBoundingClientRect(),T=e.getBoundingClientRect();if(m&&(!d||S.left!==d.left||S.top!==d.top||S.right!==d.right||S.bottom!==d.bottom)&&h(),d=S,!T.width||!T.height)return;let A=e.offsetWidth/T.width,k=e.offsetHeight/T.height,p=c?.offsetLeft??0,_=c?.offsetTop??0,L=Math.max(S.left,p),B=Math.max(S.top,_),H=c?.width??document.documentElement.clientWidth,P=c?.height??document.documentElement.clientHeight,x=Math.min(S.right,p+H),C=Math.min(S.bottom,_+P),v=S.height>=P*.8||S.width>H+1;for(let{element:D,x:G,y:$}of s){let j=D.getBoundingClientRect(),Q=j.width/(D.offsetWidth||1),K=j.height/(D.offsetHeight||1),z=j.left+D.clientLeft*Q,V=j.top+D.clientTop*K;(G&&S.width>D.clientWidth*Q+1||$&&S.height>D.clientHeight*K+1)&&(v=!0),G&&(L=Math.max(L,z),x=Math.min(x,z+D.clientWidth*Q)),$&&(B=Math.max(B,V),C=Math.min(C,V+D.clientHeight*K))}if(x<=L||C<=B){n.style.inset="0";return}let E=r==="auto"?v?"large":"mini":r;n.dataset.size!==E&&(n.dataset.size=E);let R=Math.min(o,Math.max(0,((x-L)*A-i.offsetWidth)/2)),I=Math.min(o,Math.max(0,((C-B)*k-i.offsetHeight)/2));n.style.padding=I+"px "+R+"px",n.style.setProperty("--control-y-inset",I+"px"),n.style.inset=[(B-T.top)*k,(T.right-x)*A,(T.bottom-C)*k,(L-T.left)*A].map(D=>D+"px").join(" ")}function h(){l||(l=requestAnimationFrame(f))}let g,y=new IntersectionObserver(S=>{if(m=S[S.length-1].isIntersecting,m){if(d=void 0,!g){g=new AbortController;let T={signal:g.signal,passive:!0};document.addEventListener("scroll",h,{...T,capture:!0}),window.addEventListener("resize",h,T),c?.addEventListener("scroll",h,T),c?.addEventListener("resize",h,T)}h()}else g?.abort(),g=void 0,n.style.inset="0"},{threshold:[0,.25,.5,.75,1]}),b=new ResizeObserver(h);for(let S of[a,...s.map(T=>T.element)])b.observe(S);return y.observe(t),f(),()=>{g?.abort(),y.disconnect(),b.disconnect(),cancelAnimationFrame(l)}}var Ln="http://www.w3.org/2000/svg",On=3e3;function Jt(a,t,e){let n=document.createElement("button");return n.type="button",n.className=t,n.setAttribute("aria-label",a),n.title=a,n.onclick=e,n}var Se=class{constructor(t,e,n,r,o,s,i,c,l){this.root=document.createElement("div");this.status=document.createElement("span");this.listeners=new AbortController;this.hideAt=0;if(this.root.className=`vextab-transport ${e}`,this.controls=document.createElement(l?"span":"div"),this.controls.className=l?"vextab-playback-controls":"vextab-sheet-controls",this.status.setAttribute("role","status"),n)if(this.toggle=Jt("Play","vextab-play",()=>this.toggle.classList.contains("vextab-stop")?o():r()),this.setButton(!1),l)this.controls.append(this.toggle);else{let d=document.createElement("div");d.className="vextab-control-panel",d.setAttribute("role","group"),d.setAttribute("aria-label","Playback"),this.scrollButton=Jt("Auto-scroll","vextab-auto-scroll",()=>this.setFollowing(!this.follower)),this.setFollowing(c.size!=="mini"),d.append(this.toggle,this.addTempo(i),this.scrollButton),this.controls.append(d),this.controls.dataset.position=c.position,this.controls.dataset.visibility=c.visibility,this.controls.style.setProperty("--control-inset",c.inset+"px")}this.setTempo(s),this.controls.append(this.status),(l??this.root).append(n||l?this.controls:this.status),t instanceof SVGSVGElement&&(this.surface=t),t&&(!l||t instanceof HTMLCanvasElement)&&this.mountSheet(t,n&&!l,c)}setFollowing(t){this.follower=t?new xe:void 0,this.scrollButton.setAttribute("aria-pressed",String(t))}followSystem(t,e){this.controls.dataset.size==="large"&&this.follower?.update(t,e)}mountSheet(t,e,n){let r=this.sheet=document.createElement("div");if(r.className="vextab-sheet",t.before(r),r.append(t,this.root),t instanceof HTMLCanvasElement){let o=document.createElementNS(Ln,"svg");o.setAttribute("viewBox",`0 0 ${t.width} ${t.height}`),o.setAttribute("preserveAspectRatio","none"),o.setAttribute("aria-hidden","true"),o.classList.add("vextab-canvas-ink"),this.surface=document.createElementNS(Ln,"g"),this.surface.setAttribute("transform",t.getContext("2d").getTransform().toString()),o.append(this.surface),this.root.prepend(o)}if(e){if(this.controls.addEventListener("click",o=>o.stopPropagation(),{signal:this.listeners.signal}),this.controls.dataset.visibility==="hover"){let o=()=>this.reveal();o();for(let s of["pointerenter","pointermove","pointerdown"])r.addEventListener(s,o,{passive:!0,signal:this.listeners.signal})}this.untrack=Fn(r,t,this.root,this.controls,n)}}reveal(){if(this.hideAt=performance.now()+On,this.revealTimer!==void 0)return;this.controls.setAttribute("data-visible","");let t=()=>{let e=this.hideAt-performance.now();if(e>0){this.revealTimer=window.setTimeout(t,e);return}this.revealTimer=void 0,this.dismissHoverTempo?.(),this.controls.removeAttribute("data-visible")};this.revealTimer=window.setTimeout(t,On)}addTempo(t){let e=document.createElement("div");e.className="vextab-tempo";let n=document.createElement("div");n.className="vextab-tempo-stepper";let r=i=>{e.contains(i.target)||o(!1)},o=(i,c=!1)=>{this.dismissHoverTempo=i&&c?()=>{e.querySelector(":focus-visible")||o(!1)}:void 0,i?document.addEventListener("pointerdown",r,{signal:this.listeners.signal}):document.removeEventListener("pointerdown",r),n.inert=!i,this.metronome.setAttribute("aria-expanded",String(i))};this.metronome=Jt("Adjust tempo","vextab-metronome",()=>o(n.inert)),this.decrease=Jt("Decrease tempo","vextab-step",()=>t(Math.max(1,this.tempo-5))),this.decrease.textContent="\u2212";let s=Jt("Increase tempo","vextab-step",()=>t(this.tempo+5));return s.textContent="+",this.readout=document.createElement("span"),this.readout.className="vextab-bpm",this.readout.setAttribute("aria-live","polite"),n.append(this.decrease,this.readout,s),e.append(this.metronome,n),o(!1),e.onpointerenter=i=>{i.pointerType==="mouse"&&n.inert&&o(!0,!0)},e.onpointerleave=i=>{i.pointerType==="mouse"&&!e.querySelector(":focus-visible")&&o(!1)},e.addEventListener("focusout",i=>{e.contains(i.relatedTarget)||o(!1)}),e.onkeydown=i=>{i.key==="Escape"&&(this.metronome.focus(),o(!1))},e}setTempo(t){this.tempo=t,this.readout&&(this.readout.textContent=t+" BPM",this.metronome.setAttribute("aria-description",this.readout.textContent),this.decrease.disabled=t<=1)}setStatus(t){this.status.textContent=t}setPlaying(t){this.root.toggleAttribute("data-playing",t),this.setButton(t),t||(this.marker?.remove(),this.marker=void 0)}setButton(t){if(!this.toggle)return;let e=t?"Stop":"Play";this.controls.classList.contains("vextab-playback-controls")&&(this.toggle.textContent=e),this.toggle.title=e,this.toggle.setAttribute("aria-label",e),this.toggle.className=t?"vextab-stop":"vextab-play"}moveCursor(t,e){this.surface&&(this.marker||(this.marker=document.createElementNS("http://www.w3.org/2000/svg","circle"),this.marker.setAttribute("r","6"),this.marker.classList.add("vextab-playback-marker"),this.marker.setAttribute("fill","currentColor"),this.marker.setAttribute("opacity",".45"),this.marker.setAttribute("pointer-events","none"),this.surface.append(this.marker)),this.marker.setAttribute("cx",String(t)),this.marker.setAttribute("cy",String(e)))}remove(){this.untrack?.(),this.listeners.abort(),window.clearTimeout(this.revealTimer),this.marker?.remove(),this.controls.remove(),this.root.remove(),this.sheet&&this.sheet.replaceWith(...this.sheet.childNodes)}};function In(a,t){return{async open(e,n){let r=new Map,o=!1;function s(){o=!0,r.forEach(i=>i.stop()),r.clear()}n.addEventListener("abort",s,{once:!0});try{return await Promise.all([...new Set(t)].map(async i=>{let c=await a.open(i,n);o||n.aborted?c.stop():r.set(i,c)})),{get currentTime(){return r.values().next().value?.currentTime},playNote(i){r.get(i.program??e)?.playNote(i)},stop:s}}catch(i){throw s(),i}}}}function Lr(a){if(!a.some(e=>e.notes.some(n=>n.onsetOffset)))return a;let t=[];for(let e of a){let n=[];t.push({time:e.time,notes:n,mark:e.mark});for(let r of e.notes){if(!r.onsetOffset){n.push(r);continue}let{onsetOffset:o,...s}=r;t.push({time:e.time+o,notes:[s]})}}return t.sort((e,n)=>e.time-n.time)}var ke=class{constructor(){this.rate=1}setRate(t){this.retime?this.retime(t):this.rate=t}get active(){return!!this.request}play(t,e,n,r,o=0){this.stop();let s=this.request=new AbortController;return globalThis.addEventListener?.("pagehide",()=>this.stop(),{capture:!0,signal:s.signal}),new Promise((i,c)=>{s.signal.addEventListener("abort",()=>i(),{once:!0});let l=m=>{s.signal.aborted||(c(m),this.stop())},d=m=>{if(s.signal.aborted){m.stop();return}this.session=m;let f=()=>m.currentTime??performance.now()/1e3,h=Lr(n.events),g=f(),y=-o,b=()=>y+(f()-g)*this.rate,S=0,T=()=>{if(!s.signal.aborted)try{let A=b();for(;S<h.length&&h[S].time<=A;){let p=h[S++];p.mark?.();for(let _ of p.notes)p.time+_.duration>A&&m.playNote(Or(_,this.rate))}if(S===h.length&&A>=n.duration){this.stop();return}let k=h[S]?.time??n.duration;this.timer=window.setTimeout(T,Math.max(1,(k-b())/this.rate*1e3))}catch(A){l(A)}};this.retime=A=>{y=b(),g=f(),this.rate=A,window.clearTimeout(this.timer),T()},r(b),T()};try{let m=t.open(e,s.signal);"playNote"in m?d(m):m.then(d).catch(l)}catch(m){l(m)}})}stop(){this.retime=void 0,this.rate=1,this.request?.abort(),this.request=void 0,window.clearTimeout(this.timer),this.timer=void 0;let t=this.session;this.session=void 0,t?.stop()}};function Or(a,t){return t===1?a:{...a,duration:a.duration/t,bend:a.bend?.map(e=>({...e,time:e.time/t}))}}function Kt(a){async function t(e,n){let r=a??new AudioContext,o=new Set,s=!1;function i(){if(!s){s=!0;for(let l of o)l.stop();!a&&r instanceof AudioContext&&r.state!=="closed"&&r.close(),n.removeEventListener("abort",i)}}n.addEventListener("abort",i,{once:!0});try{r instanceof AudioContext&&r.state!=="running"&&await r.resume(),n.throwIfAborted()}catch(l){throw i(),l}function c(l){let d=r.currentTime,m=d+l.duration,f=r.createOscillator(),h=r.createGain();f.type=e>=72&&e<=79?"sine":"triangle",f.frequency.value=440*2**((l.pitch-69)/12),f.detune.setValueAtTime(0,d);for(let g of l.bend??[])f.detune.linearRampToValueAtTime(g.semitones*100,d+g.time);h.gain.setValueAtTime(0,d),h.gain.linearRampToValueAtTime(l.velocity/127*.12,d+Math.min(.006,l.duration/3)),h.gain.exponentialRampToValueAtTime(.001,m),f.connect(h).connect(r.destination),o.add(f),f.onended=()=>{o.delete(f),f.disconnect(),h.disconnect()},f.start(d),f.stop(m)}return{playNote:c,stop:i,get currentTime(){return r.currentTime}}}return{open:t}}function Hn(a,t,e,n=!0){return{open(r,o){function s(){return o.throwIfAborted(),MIDI.programChange(0,r),{playNote(i){MIDI.noteOn(0,i.pitch,n&&!i.fixedVelocity?127:i.velocity,0),MIDI.noteOff(0,i.pitch,i.duration)},stop(){}}}return e[a]?s():new Promise((i,c)=>{MIDI.loadPlugin({instruments:[a],soundfontUrl:t,onerror:c,callback(){e[a]=!0;try{i(s())}catch(l){c(l)}}})})}}}var Ir={acoustic_grand_piano:0,acoustic_guitar_nylon:24,acoustic_guitar_steel:25,electric_guitar_jazz:26,distortion_guitar:30,electric_bass_finger:33,electric_bass_pick:34,trumpet:56,brass_section:61,soprano_sax:64,alto_sax:65,tenor_sax:66,baritone_sax:67,flute:73,synth_drum:118};function Vn(a){let t=/^\d+$/.test(String(a))?Number(a):Ir[a];if(!Number.isInteger(t)||t<0||t>127)throw new RangeError("Invalid instrument: "+a);return t}var Tt=class a{constructor(t,e={}){this.transport=new ke;this.generation=0;this.performanceTempo=120;this.sharedSurface=!1;this.companions=[];this.animations=[];if(this.options={instrument:"acoustic_grand_piano",tempo:120,show_controls:!0,soundfont_url:"/soundfont/",overlay_class:"vextab-player",...e},"parts"in t){let n=t;e.partId===void 0&&e.partIndex===void 0&&n.parts.length>1&&(this.ensemble=n.parts.map((r,o)=>vt(n,o))),t=vt(n,xt(n,e))}"measures"in t?(this.score=t,this.options.tempo=e.tempo??t.playback?.tempo??120,this.options.instrument=e.instrument??t.playback?.instrument??"acoustic_grand_piano"):this.artist=t,this.setTempo(this.options.tempo),this.setInstrument(this.options.instrument),this.reset()}static{this.DEBUG=!1}static{this.INSTRUMENTS_LOADED={}}setArtist(t){this.dispose(),this.score=void 0,this.ensemble=void 0,this.artist=t,this.reset()}setTempo(t){if(!Number.isFinite(t)||t<=0)throw new RangeError("Tempo must be positive");this.options.tempo=t,this.overlay?.setTempo(t),this.transport.active&&this.transport.setRate(t/this.performanceTempo)}setInstrument(t){Vn(t),this.options.instrument=t,this.stop()}reset(){this.artist?.attachPlayer(this),this.stop()}removeControls(){this.stop(),this.overlay?.remove(),this.overlay=void 0;for(let t of this.companions)t.overlay.remove();this.companions=[]}dispose(){this.removeControls(),this.mark=void 0,this.geometry=void 0,this.artist?.player===this&&this.artist.attachPlayer(null)}render(t,e,n=[]){this.removeControls(),this.mark=e;let r=t&&Wt.get(t);this.sharedSurface=!!this.ensemble&&!!r?.ensemble&&this.ensemble.every((g,y)=>r.ensemble[y]===g),this.geometry=r&&r.score===this.score?r.read:void 0;let o=this.artist?.getPlayerData().context,s=t??o?.canvas??o?.svg,i=this.options.controls,c=i instanceof HTMLElement?i:void 0;if(!s&&!c)throw new Error("Render the score before mounting playback controls");let l=this.score?.playback?.controls,d=typeof i=="object"&&!(i instanceof HTMLElement)?i:void 0,m=se({...l,...d});(i===!0||c)&&m.visibility==="off"&&(m.visibility="hover");let f=(g,y,b)=>new Se(g,this.options.overlay_class,y,()=>{this.play().catch(()=>{})},()=>this.stop(),this.options.tempo,S=>this.setTempo(S),m,b);this.overlay=f(s,this.options.show_controls&&i!==!1&&m.visibility!=="off",c);let h=new Set(this.ensemble);for(let g of n){let y=Wt.get(g);y&&h.has(y.score)&&this.companions.push({...y,overlay:f(g,!1)})}}moveCursor(t,e){this.overlay?.moveCursor(t,e)}async play(){if(this.transport.active)return;let t=++this.generation,{tempo:e,instrument:n,playback:r,soundfont_url:o}=this.options;this.performanceTempo=e;let s=this.ensemble??(this.score?[this.score]:[]),i=mn(s,this.options.order==="performed"),c=un(this.options.performer??this.score?.playback?.performer,this.options.seed,this.options.swing??this.score?.playback?.swing),l=s.map(()=>[]),d=s.length?s.map((b,S)=>vn(b,e,this.mark,i.get(b),c,c.needsBeatGrid?l[S]:void 0)):[wn(this.artist,e)],m=c.perform(d,yn(l),e),f=m[0],h=new Map(s.map((b,S)=>[b,m[S]])),g=m.length===1?f:{events:m.flatMap(b=>b.events).sort((b,S)=>b.time-S.time),duration:Math.max(...m.map(b=>b.duration))},y=r??(!this.artist||typeof MIDI>"u"?Kt():Hn(String(n),o,a.INSTRUMENTS_LOADED,c.literal));if(this.overlay&&!g.events.some(b=>b.notes.length)){this.overlay?.setStatus("This example has no pitched notes to play.");return}this.overlay?.setPlaying(!0),this.overlay?.setStatus("Loading instruments...");try{let b=this.geometry?.()??(this.artist&&this.overlay?Rn(this.artist):void 0);b?.size&&this.animations.push(new $t(this.overlay?.surface,this.sharedSurface?g:f,b,(k,p)=>this.overlay?.followSystem(k,p)));for(let k of this.companions){let p=h.get(k.score);p&&this.animations.push(new $t(k.overlay.surface,p,k.read()))}let S=Vn(n),T=[...new Set(g.events.flatMap(k=>k.notes.map(p=>p.program??S)))],A=T.some(k=>k!==S)?In(y,T):y;await this.transport.play(A,S,g,k=>{for(let p of this.animations)p.start(k);this.overlay?.setStatus(""),this.overlay?.setPlaying(!0)},this.animations.length?.075:0)}catch(b){throw t===this.generation&&(this.overlay?.setPlaying(!1),this.overlay?.setStatus(b instanceof Error?b.message:String(b))),b}finally{t===this.generation&&(this.stopAnimations(),this.overlay?.setPlaying(!1))}}stopAnimations(){for(let t of this.animations)t.stop();this.animations=[]}stop(){this.generation++,this.transport.stop(),this.stopAnimations(),this.overlay?.setStatus(""),this.overlay?.setPlaying(!1)}};N.Flow.Player||(N.Flow.Player=Tt);function Hr(a,t){let e=0,n=a.length;for(;e<n;){let r=Math.floor((e+n)/2);a[r].end<=t?e=r+1:n=r}return e}function Vr(a,t){let e=a[0].measures.map(()=>[]);for(let n of a)for(let r of n.measures)for(let o of r.voices){let s=[];for(let i of o.events){let c=t.get(i.id)?.heads;if(!c?.length)continue;let l=Dt(i.onset);s.push({start:l,end:l+Dt(i.duration),heads:c})}s.length&&e[r.number-1].push(s)}return e}function zr(a,t){let e=parseFloat(a.style.width),n=parseFloat(a.style.height),r=bt("svg",{viewBox:`0 0 ${e} ${n}`,preserveAspectRatio:"none","aria-hidden":"true"});r.style.cssText="position:absolute;pointer-events:none;background:transparent;",t.append(r);let o="";return{paper:r,align(){let s=a.getBoundingClientRect(),i=t.getBoundingClientRect();if(!i.width||!i.height)return;let c=[100*(s.left-i.left)/i.width,100*(s.top-i.top)/i.height,100*s.width/i.width,100*s.height/i.height],l=c.join(",");l!==o&&(o=l,[r.style.left,r.style.top,r.style.width,r.style.height]=c.map(d=>d+"%"))}}}function zn(a,t,e,n,r){let o=new Gt,s=Vr(n,r),i=t instanceof HTMLCanvasElement?zr(t,a):void 0,c=i?.paper??t,l=n[0].playback?.tempo??120,d=!1;return{setPosition(m,f=l){if(d)return;if(!Number.isFinite(f)||f<=0)throw new RangeError("Tempo must be positive");let h=e.positionAt(m);if(!h){o.layer.remove();return}i?.align(),o.layer.parentNode||c.append(o.layer),o.bar.setAttribute("transform","translate("+h.x+" 0)"),o.bar.setAttribute("y1",String(h.systemBounds.top)),o.bar.setAttribute("y2",String(h.systemBounds.bottom));let g=240/f,y=.075/g,b=0;for(let S of s[h.measure-1])for(let T=Hr(S,h.offset);T<S.length;T++){let A=S[T];if(A.start>h.offset+y)break;let k=ve((h.offset-A.start)*g,0,(A.end-A.start)*g);if(k>0)for(let p of A.heads)o.drawDot(b++,p,k,o.layer)}o.hideUnused(b)},clear(){o.layer.remove()},dispose(){d=!0,o.layer.remove(),i?.paper.remove()}}}function Dn(a,t,e){let n=(a.editions??[]).filter(c=>!c.conductor&&!c.part),r=a.editions?.find(c=>t==="conductor"?c.conductor:c.part&&c.part===a.parts[t].id);r&&n.push(r);let o={},s=[];for(let c of n)Object.assign(o,c.settings),s.push(...c.anchors);for(let c of["systemBreaks","pageBreaks","preferredTurns","forbiddenTurns"])o[c]=s.filter(l=>l.field===c).map(l=>l.measure);let i={...o.margins,...e.margins};return{settings:{...o,...e,margins:i},cues:r?.cues??[],anchors:s,range:(r??n[0])?.range}}import{TextNote as Bt}from"vexflow";function jn(a,t,e){return a.flatMap(n=>{let r=!1,o=n.map(s=>{let i=(d=0)=>d-3>e+4,c=s.text&&i(s.style.line)===t?s.text:"",l=s.boundaries?.filter(d=>i(d.style.line)===t).map(d=>t?{...d,style:{...d.style,line:d.style.line-e}}:d);return(c||l?.length)&&(r=!0),{...s,text:c,boundaries:l,belowBassStaff:t,style:c&&t?{...s.style,line:s.style.line-e}:s.style}});return r?[o]:[]})}function Gn(a){return a.boundaries?.some(t=>t.edge==="start"&&t.style.line===a.style.line)}var Ee=class{constructor(){this.regions=new Map;this.cells=new Map;this.smoothMeasures=new Map;this.smoothNotes=new Map}voices(t,e,n){let o=[{notes:t.map(i=>{let c=n(i.id,i.range);return i.text&&i.style.smooth&&!i.boundaries?.length&&this.smoothMeasures.set(c,e),this.anchor(i,c)})}],s=Math.max(0,...t.map(i=>i.boundaries?.length??0));for(let i=0;i<s;i++)o.push({notes:t.map(c=>{let l=c.boundaries?.[i];if(!l)return{skip:{duration:c.base,dots:c.dots}};let d=c.id+"-at-"+l.range.start;return this.anchor({...c,...l,id:d},n(d,l.range),l.edge)})});return o}anchor(t,e,n="beat"){let r={duration:t.base,dots:t.dots};if(!t.text)return{id:e,skip:r};if(this.cells.set(e,t),t.style.smooth&&n==="beat"&&!t.boundaries?.length)return"B4/"+t.base+"/r"+".".repeat(t.dots)+'[clef="treble",id="'+e+'"]';let{family:o,size:s,style:i,align:c,line:l}=t.style,d=t.glyph?Bt.GLYPHS[t.text]??t.text:t.text,m={...o&&{family:o},...s&&{size:s},...i==="italic"&&{style:i},...i==="bold"&&{weight:i},...t.glyph&&{family:At(),style:"normal",weight:"normal"}},h=n==="beat"&&Gn(t)?"right":c??"center";return{id:e,direction:{...r,text:d,anchor:n,line:l,align:h,font:m}}}prepare(t,e){let n=this.smoothMeasures.get(t);if(n===void 0||e instanceof Bt)return;e.renderOptions.draw=!1;let r=this.smoothNotes.get(n);r||this.smoothNotes.set(n,r=new Map),r.set(t,e)}smoothLabel(t,e,n){let{family:r,size:o,style:s,align:i,line:c}=e.style,l=new Bt({duration:e.base,...e.glyph?{glyph:e.text}:{text:e.text},line:c}).setDirectionAnchor("beat").setAttribute("id",n);return e.glyph?o&&l.setFontSize(o):l.setFont(r??l.fontInfo.family,o??l.fontInfo.size,s==="bold"?"bold":void 0,s==="italic"?"italic":void 0),l.setJustification(i==="right"?Bt.Justification.RIGHT:i==="left"?Bt.Justification.LEFT:Bt.Justification.CENTER),l.setStave(t.checkStave()).setTickContext(t.checkTickContext()),l.preFormat(),l}inkBounds(t,e){let n=[];for(let[r,o]of this.smoothNotes.get(e)??[]){if(o.getStave()!==t)continue;let s=this.cells.get(r),i=this.smoothLabel(o,s,r);this.positionLabel(i,t,s.glyph),n.push(i.getBoundingBox())}return n}positionLabel(t,e,n){if(t.getLine()-3<e.getNumLines())return;t.setYShift(0);let r=n?-t.getTextInk(0,0).y:t.getTextMetrics().fontBoundingBoxAscent;t.setYShift(e.getSpacingBetweenLines()+r)}place(t,e,n){let r=t.getAttribute("id"),o=this.cells.get(r);if(!o)return;let s;if(t instanceof Bt){if(s=t,s.getDirectionAnchor()==="beat"&&Gn(o)){let l=s.getTextMetrics().width;s.setXShift(o.style.align==="right"?0:o.style.align==="left"?l:l/2)}}else{if(!o.style.smooth)return;s=this.smoothLabel(t,o,r)}o.style.ink&&s.setStyle(rt(o.style.ink));let i=t.checkStave();if(this.positionLabel(s,i,o.glyph),o.belowBassStaff){let l=s.getBoundingBox(),d=l.y;for(let m of n.notes.flat(3)){let f=m,h=f.getBeam?.();if(!(!h||h.getNotes()[0]!==f||f.getStave()?.getY()!==i.getY()))for(let g of h.getStripBounds())g.x<l.x+l.w&&g.x+g.w>l.x&&(d=Math.max(d,g.y+g.h+i.space(.4)))}s.setYShift(s.getYShift()+d-l.y)}let c=s.getBoundingBox();this.regions.set(r,{id:r,source:o.id,kind:"event",x:c.x,y:c.y,w:c.w,h:c.h}),s!==t&&e({source:t,bounds:c,draw:l=>s.setContext(l).drawWithStyle()})}};import Wn,{KeyManager as Dr,Ornament as Gr}from"vexflow";function qn(a,t,e,n,r){a.save(),a.openGroup("score-heading");let o=t.align==="center",s=Math.min(1,o?Math.max(.75,n/620):n/620),i=0;function c(l,d,m,f,h=0){if(!l)return;let g=l.split(/(\^\{[^{}]+\}|♩|𝅗𝅥)/u).filter(Boolean).map(k=>{let p=k.startsWith("^{")&&k.endsWith("}"),_=p?k.slice(2,-1):k,L=k==="\u2669"?Wn.Glyphs.metNoteQuarterUp:k==="\u{1D15E}"?Wn.Glyphs.metNoteHalfUp:void 0,B=L?At():gt(),H=L?"normal":Ot(),P=L??_.trim(),x=f*s*(p?.62:1);a.setFont(B,x,H,"normal");let C=L?0:a.measureText("a a").width-a.measureText("aa").width,v=(_.length-_.trimStart().length)*C,E=(_.length-P.length)*C+a.measureText(P).width;return{label:P,family:B,weight:H,fontSize:x,raised:p,leading:v,advance:E}}),y=g.reduce((k,p)=>k+p.advance,0),b=o&&y>n?n/y:1,S=f*s*b,T=e+d*n-y*b*h,A=o?r+i+S*1.3:r-m*s;for(let k of g)a.setFont(k.family,k.fontSize*b,k.weight,"normal"),a.fillText(k.label,T+k.leading*b,A-(k.raised?S*.5:0)),T+=k.advance*b;o&&(i+=S*1.85)}return o?(c(t.title,.5,0,32,.5),c(t.dedication,.5,0,16,.5),c(t.composer,.5,0,16,.5),c(t.tempo,.5,0,16,.5)):(c(t.title,.5,112,34,.5),c(t.dedication,.045,74,18),c(t.tempo,.17,39,23),c(t.composer,.985,32,19,1)),a.closeGroup(),a.restore(),i}function Un(a,t){let e=new Dr(t),n=new Map;return a.notes.map(r=>{let[o,s]=r.key.split("/"),i=o[0],c=o.slice(1)||"n",l=i+s,d=n.get(l)??e.getAccidental(i).accidental??"n";n.set(l,c);let m=r.ornament&&new Gr(r.ornament.replace("_inverted","Inverted")).getText(),f=m?'[stem="down",articulations="'+m+'.above"]':'[stem="down"]';return i+(d===c?"":c)+s+"/"+a.duration+f}).join(", ")}import $n,{AlternatingTremolo as Qn,GraceNoteGroup as Jn,GraceTabNote as qr,Ornament as Ur,TextDynamics as Yr,Clef as Xr,FretDiagram as $r,Registry as Pe,Fraction as Zt,Annotation as kt,Stroke as Kn,Vibrato as Jr,Articulation as Kr,Modifier as ze,TabSlide as He,Barline as Zn,StaveNote as Qt,TabNote as Me,TabTie as Ve,Factory as Zr,FrettedInstrument as Qr,Publication as to,ScoreNavigation as eo,SVGContext as no,CanvasContext as ro}from"vexflow";import{Fraction as jr}from"vexflow";function Yn(a,t,e,n,r=!1,o=!1,s=new Map){let i=[],c=[];for(let l of a.voices){let d=new Map;for(let[m,f]of l.events.entries()){let h=e(f.id),g=f.chord?[f.chord.text]:[];if(n)for(let y of f.heads)(y.connection||y.hammer)&&t==="tab"&&g.push(y.connection==="pull"?"P":y.connection==="slide"?"Slide":"H"),y.openSlide&&t==="notation"&&g.push(zt(y.openSlide,y.position.str)),y.prebend&&g.push(Ft(y.prebend,y.position.str));if(r)for(let y of f.gestures??[])"direction"in y?!a.state.piano&&!o&&g.push(y.kind+" "+y.direction):g.push(y.kind==="tap"?"T":y.wide?"Wide vibrato":"Vibrato");f.harmony&&g.length===1?i.push({note:h,harmony:f.harmony}):g.length&&i.push({note:h,text:g.join(" \xB7 ")});for(let y of ie(f)){let{text:b,hyphen:S,extend:T,range:A,verse:k,elideWith:p,crossConnector:_}=y;if(t==="tab")throw new nt("fixed-layout","This lyric needs a notation staff",A);let L=k??"";d.has(L)||d.set(L,[]),d.get(L).push({note:h,text:b,elideWith:p,hyphenAfter:S,extendTo:T?e(_?s.get(A.start):l.events[m+T].id):void 0})}}for(let m of[...d.keys()].sort())c.push({id:m,syllables:d.get(m)})}return{chords:i,verses:c}}function Wr(a){return a.voices.flatMap(t=>t.events.filter(e=>e.frame)).map(t=>({event:t,beat:new jr().parse(t.onset).value()})).sort((t,e)=>t.beat-e.beat)}function Xn(a,t){return a.measures.flatMap(e=>Wr(e).map(({event:n})=>{let{spec:r,range:o}=n.frame,s="frame"+o.start;return{id:t(s,o,n.id),source:s,diagram:{...r,label:n.chord.text}}}))}var oo=0;function so(a,t){let e=a.measures[0].state,r=(e.piano?["right","left"]:["notation","tab"].filter(o=>e[o])).filter(o=>t==="score"||t===o||e.piano&&t==="notation");if(!r.length)throw new nt("fixed-layout",`No ${t} staff in this score`,e.declaration);for(let o of a.measures)if(o.state.piano!==e.piano||["notation","tab"].some(s=>(t==="score"||t===s)&&o.state[s]!==e[s])||r.includes("tab")&&o.state.strings!==e.strings)throw new nt("fixed-layout","A flow score must keep its staff configuration",o.state.declaration);return r}function qt(a,t){return a.state.piano?a.voices.filter(e=>e.hand===t):a.voices}var De=class{constructor(t){this.revision=t;this.ids=Object.create(null);this.ranges=new Map;this.prefix="vt"+ ++oo+"-";this.id=(t,e)=>this.prefix+t+"-"+e;this.rangeFor=(t,e)=>e===this.revision?this.ranges.get(this.ids[t]??t):void 0;this.sourceFor=t=>this.ids[t]}project(t,e,n,r){let o=this.id(t,r?e+"-"+r:e);return this.ids[o]=e,this.ranges.set(e,n),o}};function io(a,t){let e=a.heads.flatMap((r,o)=>r.position?[{...r.position,displayKey:r.written,index:o}]:[]),n=[];if(a.bend){let r=e.map(s=>({str:s.str,fret:Number(s.fret)}));n.push(...t.attack(e,a.base).note.notation);let o=a.heads.some(s=>s.bend)?a.heads.flatMap(s=>s.bend&&!s.tiedBendStart?[s.bend]:[]):[a.bend.spec];for(let s of o)n.push(...t.bentAttack(r,a.base,s).note.notation.filter(i=>i.bend))}else if(e.length)for(let r of t.attack(e,a.base).note.notation)n.push({...r,index:e[r.index].index});return a.heads.forEach((r,o)=>{r.openSlide&&n.push({kind:"technique",id:"open-slide",index:o,label:zt(r.openSlide,r.position.str)}),r.prebend&&n.push({kind:"technique",id:"pre-bend",index:o,label:Ft(r.prebend,r.position.str)}),!r.position&&r.sounding===null&&n.push({kind:"unpitched",id:"slash",label:"Rhythm slash",index:o})}),n}function ao(a){let t=new Map;if(!a.hand)return t;for(let e of a.beamGroups??[]){let n=a.events.slice(e.start,e.end+1),r=n.map(o=>o.displayHand??a.hand);r.some(o=>o!==r[0])&&n.forEach((o,s)=>t.set(o,r[s]==="right"?-1:1))}return t}function co(a,t,e,n){let r=a.stem,o=r?r==="up"?1:-1:e==="tab"?a.tabDirection:void 0,s=new Qr(t.state.tuning,t.state.capo),i=e==="left"?"bass":t.state.clef,c=ao(a),l,d=a.events.map(h=>{let g=n.project(e,h.id,h.range);h.heads.forEach((B,H)=>n.project(e,h.id+"-head-"+H,B.range));let y=t.state.piano?h.displayHand:void 0,b=c.get(h),S=h.stem==="up"?1:h.stem==="down"?-1:void 0,T={duration:h.base,dots:h.dots,stemDirection:S??b??o,headSource:{event:h.id}};if(h.silent)return{id:g,skip:T};if(!h.heads.length){let B=e==="tab"?5-t.state.strings:0,H=h.restLine===void 0?void 0:h.restLine+B;return{id:g,...y&&{stave:y},note:{...T,keys:["r/4"],clef:"treble",type:"r",restLine:H}}}if(h.heads[0].drum){let B=(t.state.kit??oe).note(h.heads.map(H=>H.drum),h.base,h.stem??r);return{id:g,note:{...B,dots:h.dots,headSource:T.headSource}}}let A=io(h,s),k=h.heads.map(B=>B.position?.fret==="X"?B.written+"/X":B.written);if(e==="tab")return{id:g,tab:{...T,keys:k,notation:A,positions:h.heads.map(B=>({...B.position}))},drawStem:a.tabStems&&!["w","1"].includes(h.base)};let p=h.writtenClef??i;if(y&&y!==a.hand){let B=t.staffState?.[y];p=B?.clef??(y==="left"?"bass":"treble");for(let H of B?.changes??[]){if(new Zt().parse(H.at).greaterThan(new Zt().parse(h.onset)))break;p=H.clef??p}}let _=h.heads.map((B,H)=>{let P=Ce(B.marks,h.heads);return{key:k[H],...P&&{fingering:{finger:P.finger,position:P.position}},...B.accidental&&{accidental:B.cautionary?"cautionary":"force"}}}),L={...T,heads:_,notation:A,clef:p,type:h.slash?"s":"n",autoStem:T.stemDirection===void 0};return h.tremolo&&(l===void 0?(l=T.stemDirection??new Qt({...L,autoStem:!0}).getStemDirection(),L.stemDirection=l):(L.stemDirection=l,l=void 0),L.autoStem=!1),{id:g,...y&&{stave:y},note:h.tremolo?Qn.endpoint(L,h.tremolo):L,...h.grace&&{grace:{side:h.grace.side,slur:!0,beam:h.grace.pitches.length>1,notes:h.grace.pitches.map(B=>({keys:Array.isArray(B)?B:[B],duration:h.grace.slash?"8":"16",slash:h.grace.slash,clef:p}))}}}}),m=new Map;if(e!=="tab")for(let h of t.staffState?.[e]?.changes??[])!h.clef&&!h.key||m.set(h.at,{...m.get(h.at),...h.clef&&{clef:h.clef},...h.key&&{key:h.key}});return{notes:m.size?d.flatMap((h,g)=>{let y=m.get(a.events[g].onset);return y?[{change:y},h]:[h]}):d,stem:r??"auto",autoBeam:!a.events.some(h=>h.tremolo)&&a.beams&&(e!=="tab"||a.tabStems)&&{groups:a.beatGroups?.map(h=>new Zt(h,Number(t.state.meter.split("/")[1]))),stemDirection:a.events.some(h=>h.stem)?void 0:o,flatBeams:a.flatBeams,beamRests:a.beamRests,showStemlets:a.stemlets,beamMiddleOnly:a.middleRests},beams:e==="tab"&&!a.tabStems?[]:a.beamGroups?.map(h=>({start:h.start,count:h.end-h.start+1,flatBeams:a.flatBeams,feathered:h.feather,showStemlets:a.stemlets})),tuplets:a.tuplets.map(h=>({start:h.start,count:h.count,options:{numNotes:h.numNotes,notesOccupied:h.notesOccupied}}))}}function lo(a){let t=a.voices[0].closing?.type;if(t==="end")return Zn.type.END;if(t==="double")return Zn.type.DOUBLE}function tr(a,t,e,n=!1){let r=so(a,t);if(!r.includes("tab"))for(let p of a.measures)for(let _ of p.voices){let L=_.events.find(B=>B.bend)?.bend;if(L)throw new nt("fixed-layout","A timed bend contour needs a tab staff",L.range)}let o=new De(a.source),s=o.id,i=a.layout?.heading,c=i&&(i.align==="center"||Object.keys(i).length===1)&&!Object.values(i).some(p=>/\^\{/.test(p)),l=Xn(a,(p,_,L)=>o.project(r[0],p,_,L)),d=[];if(c)for(let p of["title","dedication","composer","tempo"])i[p]&&d.push({kind:"text",runs:i[p].split(/([♩𝅗𝅥])/u).filter(Boolean).map(_=>_==="\u2669"||_==="\u{1D15E}"?{text:_==="\u2669"?$n.Glyphs.metNoteQuarterUp:$n.Glyphs.metNoteHalfUp,font:{family:At(),weight:"normal"}}:_),align:i.align??(p==="title"?"center":p==="composer"?"right":"left"),font:{family:gt(),weight:Ot(),size:p==="title"?32:16}});l.length&&d.push({kind:"diagrams",align:i?.align??"left",diagrams:l.map(p=>p.diagram),font:{family:gt(),size:12}}),a.playback?.swing==="eighths"&&d.push({kind:"text",font:{family:gt(),size:12,weight:Ot()},runs:["Swing ",{notes:["8","8"],beam:!0}," = ",{notes:["q","8"],tuplet:[3,2]}]});let m=new Ee,f=new Map(a.spans.filter(p=>p.kind==="lyric").map(p=>[p.range.start,p.to])),h=a.measures[0].state.tab&&a.measures.some(p=>p.voices.length>1),g=[],y=new Set(a.measures.flatMap(p=>p.voices.flatMap(_=>_.events.filter(L=>!L.heads.length).map(L=>L.id)))),b=new Map,S=[],T={stemPolicy:a.layout?.stemPolicy==="pitch"?void 0:"active-voices",accidentals:"key-aware",graceAccidentals:"ordered",sheet:{width:e,x:10,y:a.layout?.top??14,rowGap:a.layout?.rowGap??36,...a.layout?.spacing&&{measurePadding:18,measureGap:0}},system:{...a.layout?.spacing&&{details:{spacing:{mode:a.layout.spacing}}},spaceBetweenStaves:a.layout?.staffDistance??9},staves:r.map(p=>({id:p,kind:p==="tab"?"tab":"stave",...p==="right"&&{name:"R.H.",shortName:"R.H."},...p==="left"&&{name:"L.H.",shortName:"L.H."},...an(a,p,p===r[0]),options:p==="tab"?{numLines:a.measures[0].state.strings}:{},measures:a.measures.map(_=>{let L=qt(_,p);if(p!=="tab"&&a.ties.length&&L.filter(x=>x.events.some(C=>C.heads.length)).length>1){for(let x of L)if(x.stem)for(let C of x.events)b.set(C.id,x.stem==="up"?"above":"below")}let B=p===r[0]||_.state.piano,H=p==="tab"?void 0:_.staffState?.[p];return{clef:H?.clef??(p==="tab"?"tab":p==="left"?"bass":_.state.clef),key:H?.key??_.state.key,time:_.state.meterSign??_.state.meter,span:_.span==="0/1"?"1/1":_.span,showTimeSignature:_.state.showTime&&!(p==="tab"&&r.includes("notation")),endBarline:lo(_),...B&&Yn({..._,voices:L},p==="tab"?"tab":"notation",x=>s(p,x),n||!r.includes("tab"),n,h,f),voices:[...L.map((x,C)=>x.events.length?co(x,_,p,o):{notes:[{id:s(p,"blank-"+_.number+"-"+C),skip:"w"}]}),...(_.state.piano&&r.length===2?jn(_.text??[],p==="left",a.layout?.staffDistance??9):p===r[0]?_.text??[]:[]).flatMap(x=>m.voices(x,_.number,(C,v)=>o.project(p,C,v)))]}})})),continuous:{inkBounds:(p,_)=>m.inkBounds(p,_),verticalSpacing:a.measures[0].state.piano||r.length>1?"profile":"envelope",textLanes:"system",opening:{indent:a.layout?.firstSystemIndent,blocks:d},courtesy:!1,measureNumbers:a.measureNumbers,spans:g,groups:r.length===2?[{first:r[0],last:r[1],type:a.measures[0].state.piano?"brace":"bracket",barlines:!!a.measures[0].state.piano}]:[],boundaries:a.measures.map(p=>({measure:p.number,rehearsal:p.voices[0].rehearsal,breakBefore:p.newRow&&p.number>1?"force":void 0,repeatStart:["repeat-begin","repeat-both"].includes(p.voices[0].opening?.type),repeatEnd:["repeat-end","repeat-both"].includes(p.voices[0].closing?.type)}))}};for(let p of a.ties)for(let _ of r){let L=s(_,p.from);o.ids[L]&&g.push({kind:"tie",id:o.project(_,p.id,p.range),from:L,to:s(_,p.to),side:_==="tab"?void 0:p.side??b.get(p.from)??b.get(p.to),..._==="tab"&&p.bend&&{bend:p.bend,string:p.string},fromHead:p.fromHead,toHead:p.toHead})}for(let p of a.spans??[]){if(p.kind==="pedal"){for(let H of r){let P=s(H,p.from),x=s(H,p.to);H!=="tab"&&o.ids[P]&&o.ids[x]&&g.push({kind:"pedal",pedalStyle:"text",id:o.project(H,p.id,p.range),from:P,to:x})}continue}if(p.kind==="lyric"||p.kind==="hyphen"||p.kind==="tremolo")continue;if(p.kind==="continuousBeam"||p.kind==="crescendo"||p.kind==="diminuendo"){for(let H of r){let P=s(H,p.from),x=s(H,p.to);!o.ids[P]||!o.ids[x]||H==="tab"||g.push({kind:p.kind==="continuousBeam"?"beam":p.kind,from:P,to:x,..."niente"in p&&{niente:p.niente},...p.side&&{side:p.side},id:o.project(H,p.id,p.range)})}continue}if("fromHead"in p){for(let H of r){if(H==="tab")continue;let P=s(H,p.from);o.ids[P]&&g.push({kind:p.kind==="glissando"?"glissando":"tie",id:o.project(H,p.id,p.range),from:P,to:s(H,p.to),fromHead:p.fromHead,toHead:p.toHead})}continue}if(p.kind==="slur"){for(let H of r){let P=s(H,p.from);H==="tab"&&(y.has(p.from)||y.has(p.to))||o.ids[P]&&g.push({kind:"slur",side:p.side??(H==="tab"?"below":void 0),id:o.project(H,p.id,p.range),from:P,to:s(H,p.to)})}continue}if(p.kind==="palmMute"&&!r.includes("tab"))throw new nt("fixed-layout","A string-specific palm mute needs a tab staff",p.range);if(p.kind!=="palmMute"&&p.kind!=="volta")continue;let _=p.kind==="palmMute"?"tab":r[0],B={id:o.project(_,p.id,p.range),from:s(_,p.from),to:s(_,p.to)};if(p.kind==="palmMute")g.push({...B,kind:p.kind,strings:p.strings});else if(_==="tab"&&y.has(p.from)!==y.has(p.to)){let H=a.measures[p.firstBar-1].voices.flatMap(v=>v.events),x=a.measures[p.lastBar-1].voices.flatMap(v=>v.events).find(v=>y.has(v.id)===y.has(p.from)),C=H.find(v=>y.has(v.id)===y.has(p.to));x||C?g.push({...B,kind:"volta",text:p.label,from:x?B.from:s(_,C.id),to:x?s(_,x.id):B.to}):S.push(p)}else g.push({...B,kind:p.kind,text:p.label})}let A=[];for(let p of a.measures)for(let _ of r)if(_!=="tab")for(let L of qt(p,_))for(let B of L.events){let H=B.ossia;H&&A.push({id:s(_,B.id+"-ossia"),at:s(_,B.id),label:"Ossia.",notes:Un(H,p.state.key??"C"),beam:H.notes.length>1&&H.duration!=="q",scale:.63})}if(T.continuous.ossias=A,r.includes("left")&&r.includes("right")){let p=[];for(let _ of a.measures){let L=new Map;for(let B of _.voices)for(let H of B.events)if(H.sharedStem){let P=H.sharedStem+":"+H.onset,x=L.get(P)??{},C=B.hand==="right"?"upper":"lower";if(x[C])throw new nt("measure","Duplicate shared stem endpoint",H.range);x[C]=s(B.hand,H.id),L.set(P,x)}for(let B of L.values()){if(!B.upper||!B.lower)throw new nt("measure","Shared stems need simultaneous notes on both staves",_.range);p.push({id:B.upper+"-shared",upper:B.upper,lower:B.lower})}}T.continuous.splitChords=p}let k={spec:T,nativeHeading:c,frames:l,staves:r,sources:o,eventId:s,mixedEndings:S,textLanes:m,printAnchors:n?new Map:void 0,endingRegions:[]};return T.engraving=go(a,k),k}function uo(a,t,e){for(let n of t.labels??[]){let r=new kt(n.text).setVerticalJustification(n.position==="below"?kt.VerticalJustify.BOTTOM:kt.VerticalJustify.TOP);r.setFont(n.family??gt(),n.size??12,n.style==="bold"?"bold":void 0,n.style==="italic"?"italic":void 0),n.ink&&r.setStyle(rt(n.ink)),a.addModifier(r,0)}for(let n of t.gestures??[])if(n.kind==="tap")e&&a.addModifier(new kt("T"),0);else if(n.kind==="vibrato")e&&a.addModifier(new Jr().setVibratoWidth(n.wide?28:18),0);else if(n.kind==="stroke")a.addModifier(new Kr(n.direction==="up"?"a|":"am").setPosition(ze.Position.BELOW),0);else if("direction"in n){let r=(n.kind==="rasgueado"?"RASGUEADO":n.kind.toUpperCase())+"_"+n.direction.toUpperCase();a.addModifier(new Kn(Kn.Type[r]),0)}}function fo(a,t,e,n,r){if(t.grace?.positions&&a instanceof Me){let o=t.grace.positions.map(i=>new qr({positions:i,duration:"16"})),s=new Jn(o).setPosition(t.grace.side==="before"?ze.Position.LEFT:ze.Position.RIGHT);a.addModifier(s,0)}if(t.grace?.fingerings){let o=a.getModifiers().find(s=>s instanceof Jn);for(let{attack:s,head:i,finger:c,position:l}of t.grace.fingerings)o&&Vt(o.getGraceNotes()[s],i,[{finger:c,position:l}],e==="tab",!0,!0)}if(t.ornament&&e!=="tab"&&a.addModifier(new Ur(t.ornament.replace("_inverted","Inverted")),0),t.dynamic&&(n.hand||r)){let o=[...t.dynamic].map(i=>Yr.GLYPHS[i]).join(""),s=n.hand==="right"&&t.displayHand==="left"?kt.VerticalJustify.TOP:kt.VerticalJustify.BOTTOM;a.addModifier(new kt(o).setFont(At(),15).setVerticalJustification(s),0)}uo(a,t,e==="tab"),t.color&&(a.setStyle(rt(t.color)),a instanceof Qt&&a.setLedgerLineStyle(rt(t.color))),t.silent&&(a.renderOptions.draw=!1),t.heads.forEach((o,s)=>{if(!o.marks)return;let i=a instanceof Qt&&!o.drum?Ce(o.marks,t.heads):void 0;Vt(a,s,o.marks.filter(c=>c!==i),e==="tab",!0)}),a instanceof Me&&t.heads.forEach((o,s)=>{o.openSlide&&pe(a,s,o.openSlide),o.prebend&&a.addModifier(re(o.prebend),s)}),e==="tab"&&!n.tabStems&&!t.heads.length&&(a.renderOptions.draw=!1)}function po(a,t,e,n){let r=ie(t).sort((s,i)=>(s.verse??"").localeCompare(i.verse??"")),o=0;for(let s of a.getModifiers()){if(!(s instanceof kt))continue;let i=t.chord&&s.getText().split(" \xB7 ")[0]===t.chord.text,c=s.phraseManaged&&s.getVerticalJustification()===kt.VerticalJustify.BOTTOM&&r[o++],l=i?t.chord.range:c&&c.range;if(!l)continue;i&&t.chord.color&&s.setStyle(rt(t.chord.color));let d=(i?"chord":"lyric")+l.start;e.sources.project(n,d,l,t.id),e.sources.ids[s.getAttribute("id")]=d}}function mo(a,t,e,n,r){t.endingRegions.length=0;for(let o of t.mixedEndings){if(o.kind!=="volta")continue;let s=t.eventId("tab",o.id),i=c=>n.get(t.eventId("tab",a.measures[c-1].voices[0].events[0]?.id));for(let[c,l]of e.sheet.getContinuousLayout().rows.entries()){let d=l.measures.filter(k=>k>=o.firstBar&&k<=o.lastBar);if(!d.length)continue;let m=d[0],f=d[d.length-1],h=i(m),g=i(f);if(!h||!g)continue;let y=h.checkStave(),b=y.getX()+1,S=g.checkStave().getNoteEndX(),T=l.y+y.getY()-e.staves[m-1][0].getY()-15,A={x:b,y:T,w:S-b,h:14};t.endingRegions.push({id:s,kind:"span",source:o.id,row:c,...A}),r({source:h,bounds:A,draw(k){k.openGroup("tab-ending",s+"-"+c),k.fillRect(b,T,S-b,1),m===o.firstBar&&(k.fillRect(b,T,1,12),k.setFont(gt(),11).fillText(o.label,b+4,T+12)),f===o.lastBar&&k.fillRect(S-1,T,1,12),k.closeGroup()}})}}}function ho(a,t,e,n){for(let r of a.spans)for(let o of t.staves){let s=e.get(t.eventId(o,r.from)),i=e.get(t.eventId(o,r.to));if(!s||!i)continue;if(r.kind==="tremolo"&&s instanceof Qt&&i instanceof Qt){let d=new Qn(s,i,r.strokes);n({source:s,bounds:s.getBoundingBox().clone().mergeWith(i.getBoundingBox()),draw:m=>d.setContext(m).draw()})}if(!("fromHead"in r)||!(s instanceof Me)||!(i instanceof Me))continue;let c=Number(i.getPositions()[r.toHead].fret)>Number(s.getPositions()[r.fromHead].fret),l=(d,m)=>{let f={firstNote:d,lastNote:m,firstIndexes:[r.fromHead],lastIndexes:[r.toHead]},h=r.kind==="slide"||r.kind==="glissando"?new He(f,c?He.SLIDE_UP:He.SLIDE_DOWN):d?r.kind==="pull"?Ve.createPulloff(f):Ve.createHammeron(f):new Ve(f);d&&(r.kind==="hammer"||r.kind==="pull")&&h.setFont({...h.fontInfo,family:gt(),weight:Ot()}),n({source:d??m,head:d?r.fromHead:r.toHead,bounds:h.getRibbonBounds(),draw:y=>h.setContext(y).draw()})};s.getStave().getY()===i.getStave().getY()?l(s,i):(l(s),l(void 0,i))}}function go(a,t){let e=new Map;for(let n of a.measures)for(let r of t.staves)for(let o of qt(n,r))for(let s of o.events)e.set(t.eventId(r,s.id),{event:s,staff:r,voice:o,measure:n});return{prepareNote(n,r){let o=e.get(n.id);o?fo(r,o.event,o.staff,o.voice,o.staff===t.staves[0]):t.textLanes.prepare(n.id,r)},place(n,r){let o=new Map,s=new Map;if(t.printAnchors)for(let d of n.sheet.getContinuousLayout().rows){let m=we(d.measures.flatMap(f=>n.staves[f-1]));for(let f of d.measures)s.set(f,m)}for(let d of n.notes)for(let m of d)for(let f of m)for(let h of f){let g=h.getAttribute("id"),y=e.get(g),b=h;if(!y){t.textLanes.place(b,r,n);continue}let{measure:S,voice:T,staff:A,event:k}=y;o.set(g,b),t.printAnchors&&b.preFormatted&&s.has(S.number)&&(!t.printAnchors.has(k.id)||A===t.staves[0])&&t.printAnchors.set(k.id,{measure:S.number,x:b.getAbsoluteX(),row:s.get(S.number)}),k.silent&&(b.renderOptions.draw=!1);let p=b.checkStave();if(S.state.hideClef)for(let _ of p.getModifiers(void 0,Xr.CATEGORY))_.setText("");if(S.state.color){let _=rt(S.state.color);p.setStyle(_),b.getVoice().setStyle(_),b.getBeam()?.setStyle(_)}if(A==="tab"&&!T.tabStems)for(let _ of b.getTupletStack())_.setRendered();po(b,k,t,A)}ho(a,t,o,r),t.mixedEndings.length&&mo(a,t,n,o,r);let i=o.get(t.eventId(t.staves[0],qt(a.measures[0],t.staves[0])[0]?.events[0]?.id));if(!i)return;let c=n.sheet.getRows()[0],l=!t.nativeHeading&&a.layout?.heading;if(l){let d=i.checkStave().getYForLine(0);r({source:i,bounds:{x:c.x,y:d-150,w:c.width,h:145},draw:m=>{qn(m,l,c.x,c.width,l.align==="center"?d-150:d)}})}}}}function bo(a,t){let e=new Set(a.measures.flatMap(n=>n.voices.filter(r=>!r.tabStems).flatMap(r=>r.events.filter(o=>!o.heads.length).map(o=>t.eventId("tab",o.id)))));for(let n of a.measures)for(let r of n.voices)for(let o of r.events)if(o.silent)for(let s of t.staves)e.add(t.eventId(s,o.id));return e}var Ge=class extends eo{constructor(t,e,n,r){super(t,e,n);let o=[],s=0;for(let{score:c,view:l}of r)for(let d of l.staves){let m=e[s++];for(let f of c.measures)for(let[h,g]of qt(f,d).entries())for(let y of g.events)y.silent&&o.push({id:l.eventId(d,y.id),source:y.id,staff:m.id,measure:f.number,voice:h+1,onset:y.onset,duration:y.duration,label:["Measure "+f.number,m.name||m.id,"voice "+(h+1),y.duration+" rest"].join(", ")})}let i=new Map(e.map((c,l)=>[c.id,l]));o.length&&(this.events=[...this.events,...o].sort((c,l)=>c.measure-l.measure||new Zt().parse(c.onset).value()-new Zt().parse(l.onset).value()||i.get(c.staff)-i.get(l.staff)||c.voice-l.voice))}};function yo(a,t,e){let n=new Map;for(let r of a.sheet.getContinuousLayout().rows){let o=we(r.measures.flatMap(s=>a.staves[s-1]));for(let{score:s,view:i}of t)for(let c of r.measures)for(let l of s.measures[c-1].voices)for(let d of l.events){let m=l.hand?[l.hand]:i.staves,f=e.heads.get(d.id).flatMap(g=>{if(g.role==="mark"||g.reference||typeof g.sourceHead!="number")return[];let y=d.heads[g.sourceHead];if(d.silent||!y||!y.sounding&&y.midi===void 0)return[];let b=g.bounds;return[{x:b.x+b.w/2,y:b.y+b.h/2}]}),h=f[0]?.x??a.getNote(i.eventId(m[0],d.id)).getAbsoluteX();n.set(d.id,{row:o,x:h,heads:f})}}return n}function je(a,t,e={}){let n=e.part??"score",r="parts"in t?xt(t,e):0,o="parts"in t?vt(t,r):t;return Nt(o.layout?.font,()=>er(a,[qe(o,n)],n,e,!1,r))}function We(a,t,e={}){return Nt(t.layout?.font,()=>er(a,t.parts.map((n,r)=>vt(t,r)),"score",e,!0))}function er(a,t,e,n,r=!1,o=0){let s=t[0],i=n.width??s.layout?.width??(a.clientWidth||640);if(!Number.isFinite(i)||i<=20)throw new RangeError("Score width must exceed 20 pixels");let c=t.map(O=>tr(O,e,i-20)),l=c.map(O=>O.spec),d=r?_e(t,l):l[0],m=document.createElement("div"),f=n.renderer==="canvas"?m.appendChild(document.createElement("canvas")):void 0,h=f?new ro(f.getContext("2d")):new no(m);f?m.style.position="relative":te(h,a),s.layout?.heading&&!c[0].nativeHeading&&(d.sheet.y+=125),c.some(O=>O.mixedEndings.length)&&(d.sheet.y+=20);let g=new Zr({renderer:{elementId:null,width:i,height:1}}).setContext(h),y=g.EasyScore();if(f){let O=d.engraving.place;d.engraving={...d.engraving,place(q,U){let W=0;for(let Z of q.sheet.getContinuousLayout().detailMarks)W=Math.max(W,Z.bounds.y+Z.bounds.h);O(q,Z=>{W=Math.max(W,Z.bounds.y+Z.bounds.h),U(Z)}),A(q.sheet,W)}}}let b=y.compose(d),S=0,T=c.map((O,q)=>{let U=c.length===1?b:cn(b,S,O.staves.length);S+=O.staves.length;let W=t[q];return{partIndex:o+q,score:W,view:O,local:U}});function A(O,q=0){let U=Math.max(i,...O.getRows().map(W=>W.x+W.width+10));h.resize(U,Math.ceil(Math.max(O.getHeight(),q)+20))}let k=[],p=c.flatMap(O=>O.frames.map(q=>({frame:q,sources:O.sources})));if(p.length){let O=Pe.getDefaultRegistry(),q=O??new Pe;O||Pe.enableDefaultRegistry(q);try{g.draw(),q.getElementsByType($r.CATEGORY).filter(W=>W.isRendered()&&W.getContext()===h).forEach((W,Z)=>{let{frame:tt,sources:et}=p[Z],{x:st,y:ot,w:at,h:ut}=W.getBoundingBox();et.ids[W.getAttribute("id")]=tt.source,k.push({id:tt.id,source:tt.source,kind:"event",x:st,y:ot,w:at,h:ut})})}finally{O||Pe.disableDefaultRegistry()}}else g.draw();let _=c.flatMap(O=>[...O.textLanes.regions.values()]),L=[..._,...k,...c.flatMap(O=>O.endingRegions)],B=Object.assign(Object.create(null),...c.map(O=>O.sources.ids)),H=T.flatMap(({score:O,view:q},U)=>q.staves.map(W=>{let Z=O.measures[0].state,tt=O.instrument?.name??(Z.piano?"Piano":Z.tab?"Guitar":"Part "+(U+1)),et={right:"right hand",left:"left hand",tab:"tablature",notation:"notation"}[W];return tt+", "+et})),P=r?d.staves.map((O,q)=>({...O,name:H[q]})):d.staves,x=new Ge(b,P,B,T),C=new Map(T.flatMap(({score:O,view:q})=>O.ties.map(U=>[q.eventId("tab",U.id),[]])));for(let O of x.regions)C.get(O.id)?.push(O);let v=[...C.values()].flat(),E=new Set(T.flatMap(({score:O,view:q})=>[...bo(O,q)]));function R(O,q){let U=et=>O>=et.x&&O<=et.x+et.w&&q>=et.y&&q<=et.y+et.h,W=_.find(U);if(W)return W;let Z=x.heads.hitTest(O,q);if(Z&&typeof Z.sourceHead=="number"&&Z.role!=="mark")return{id:Z.sourceEvent+"-head-"+Z.sourceHead,source:Z.sourceEvent,kind:"event",...Z.bounds};let tt=x.hitTest(O,q);return tt&&!E.has(tt.id)?tt:L.find(U)}f?(f.setAttribute("role","img"),f.setAttribute("aria-label",x.events.map(O=>O.label).join(". "))):A(b.sheet);let I=s.layout?.scale??1;if(I!==1){let O=f??h.svg;O.style.zoom=String(I),f||(m.style.width=parseFloat(O.style.width)*I+"px")}a.replaceChildren(m);function D(O,q,U){return G(O+"-head-"+q,U)}function G(O,q){for(let U of c){let W=U.sources.rangeFor(O,q);if(W)return W}}let $=b.sheet.getContinuousLayout().diagnostics.map(O=>({...O,range:O.source&&G(O.source,s.source)||s.measures[O.measures[0]-1]?.range}));for(let O of s.measures)if(t.some(q=>q.measures[O.number-1].voices.some(U=>U.events.some(W=>W.chord||W.lyric))))for(let q of b.systems[O.number-1].getPhraseLayout().diagnostics){let U=q.sources.find(W=>G(W,s.source));$.push({code:q.code,measures:[O.number],source:U,range:G(U,s.source)??O.range})}let j=f??h.svg,Q=ye(j),K,z=()=>Nt(s.layout?.font,()=>yo(b,T,x));function V(){return K??=Nt(s.layout?.font,()=>Tn(b,T,x.heads,P,Q))}return Wt.set(j,{score:s,ensemble:r?t:void 0,read:z}),{score:s,parts:t,composition:b,navigation:x,hitTest:R,tabRegions:v,extraRegions:L,diagnostics:$,rangeFor:G,headRangeFor:D,get layoutMap(){return V()},createPlaybackOverlay(){return zn(m,j,V(),t,z())},sourceFor:O=>B[O]}}function qe(a,t,e){let n=t==="right"||t==="left"?t:void 0;if(!n&&e===void 0)return a;if(n&&!a.measures[0].state.piano)throw new nt("measure","A hand part needs a piano score",a.measures[0].range);if(!n&&a.measures[0].state.piano&&e!==void 0)throw new nt("measure","Choose a hand before selecting its voice",a.measures[0].range);let r=new Set,o=a.measures.map(c=>{let l=n?qt(c,n):c.voices;if(e!==void 0){let d=l[e-1];if(!Number.isInteger(e)||!d)throw new nt("measure","Missing voice "+e+" in bar "+c.number,c.range);l=[{...d,stem:void 0}]}for(let d of l)for(let m of d.events)r.add(m.id);return{...c,voices:l.map((d,m)=>({...d,rehearsal:m?d.rehearsal:c.voices[0].rehearsal,events:n?d.events.map(f=>f.displayHand?{...f,displayHand:void 0}:f):d.events}))}}),s=a.ties.filter(c=>r.has(c.from)&&r.has(c.to)),i=(a.spans??[]).filter(c=>c.kind==="volta"||r.has(c.from)).map(c=>{if(c.kind!=="volta")return c;let l=o[c.lastBar-1].voices[0].events;return{...c,from:o[c.firstBar-1].voices[0].events[0].id,to:l[l.length-1].id}});return{...a,measures:o,ties:s,spans:i}}function vo(a,t,e,n={}){let{voice:r,partId:o,partIndex:s,...i}=n;return Nt(t.layout?.font,()=>"parts"in t?nr(a,t,xt(t,{partId:o,partIndex:s}),i,e,r):rr(a,[qe(t,e,r)],[e],i))}function wo(a,t,e="conductor",n={}){return Nt(t.layout?.font,()=>nr(a,t,e==="conductor"?e:xt(t,e),n,"score"))}function nr(a,t,e,n,r,o){let s=e==="conductor",i=Dn(t,e,n),c=n.regions===void 0?i.cues.map(f=>xt(t,{partId:f.part})):[],l=s?t.parts.map((f,h)=>h):[...new Set([e,...c])],d=l.map((f,h)=>{let g=vt(t,f);return h===0&&!s?qe(g,r,o):g}),m=d.map((f,h)=>h===0?r:"score");return rr(a,d,m,i.settings,{conductor:s,donors:c.map(f=>l.indexOf(f)),edition:i,document:t})}function rr(a,t,e,n,r){let o=t[0],s=t.map((k,p)=>tr(k,e[p],600,!0)),i=s.length>1?_e(t,s.map(k=>k.spec)):s[0].spec;r?.conductor||(i.continuous.boundaries=s[0].spec.continuous.boundaries),r?.conductor||(i.continuous.opening=s[0].spec.continuous.opening);let{compressRests:c,...l}=n;if(c){let k=new Set([...l.preferredTurns??[],...l.forbiddenTurns??[]].map(p=>p+1));i.continuous.compressRests=!0,i.continuous.boundaries=i.continuous.boundaries.flatMap(p=>k.has(p.measure)||o.measures[p.measure-1].state.fragment?[{...p,keepRest:!0}]:p.rehearsal||p.breakBefore||p.repeatStart||p.repeatEnd?[p]:[])}let{noteHooks:d,...m}=l;if(d?.length){for(let p of i.staves)for(let _ of p.measures)for(let L of _.voices)typeof L.notes!="string"&&(L.notes=L.notes.map(B=>typeof B!="object"||!("skip"in B)||typeof B.skip=="string"?B:"B4/"+B.skip.duration+"/g"+".".repeat(B.skip.dots??0)+'[id="'+B.id+'"]'));let k=i.engraving.prepareNote;i.engraving={...i.engraving,prepareNote(p,_,L){k(p,_,L);for(let B of d)B(p,_,L)}}}r&&!r.conductor&&(m.staves=i.staves.slice(0,s[0].staves.length).map(k=>k.id)),r?.donors.length&&(m.regions=r.edition.cues.map((k,p)=>{let _=s.slice(0,r.donors[p]).reduce((L,B)=>L+B.staves.length,0);return{kind:"cue",staff:i.staves[_].id,label:k.label,measure:k.measure}}));let f=ln(o.source),h;try{h=new to(i).render(a,m)}catch(k){throw r?.edition.range&&k.code==="BadPublication"?new nt("fixed-layout",k.message,f(r.edition.range)):k}let g=(r?.conductor?s:s.slice(0,1)).flatMap(k=>k.frames.map(p=>({frame:p,sources:k.sources})));g.length&&h.pages.flatMap(p=>[...p.svg.querySelectorAll(".vf-score-opening .vf-fret-diagram")]).forEach((p,_)=>{let L=p.getAttribute("data-vf-id")?.replace(/^vf-/,"");L&&g[_]&&(g[_].sources.ids[L]=g[_].frame.source)});let y=(k,p)=>s.map(_=>_.sources.rangeFor(k,p)).find(Boolean),b=h.diagnostics.map(k=>{let p=k.measures[0],_=k.code==="ForbiddenTurn"&&r?.edition.anchors.find(x=>x.field==="forbiddenTurns"&&x.measure===p),L=k.detail.startsWith("cue exceeds")&&r?.edition.cues.find(x=>x.measure===p),B=_||L,H=k.code==="ExcludedAnchor"?k.detail:k.detail.split(" ")[1],P=B?f(B.range):y(H,o.source)||k.code==="TextOverflow"&&r?.edition.range&&f(r.edition.range)||o.measures[p-1]?.range;return{...k,range:P}}),S=new Map,T=r?.conductor?t:[o];for(let k of T)for(let p of k.measures)for(let _ of p.voices)for(let L of _.events)S.set(L.id,L);let A=new Map((r?.conductor?s:s.slice(0,1)).flatMap(k=>[...k.printAnchors]));for(let k of h.pages)Wt.set(k.svg,{score:o,ensemble:r?.conductor?t:void 0,read:()=>Cn(h,S,A,(m.staffSize??7)/40)});return{publication:h,diagnostics:b,score:o,rangeFor:y,headRangeFor:(k,p,_)=>y(k+"-head-"+p,_),sourceFor:k=>s.map(p=>p.sources.sourceFor(k)).find(Boolean)}}sr();function ct(a,t,e){return a.getAttribute(`data-${t}`)||(e?a.getAttribute(`data-${e}`):null)||a.getAttribute(t)}function xo(a){let t=ct(a,"playback-controls"),e=ct(a,"playback-position"),n=ct(a,"playback-inset"),r=ct(a,"playback-size");if(t===null&&e===null&&n===null&&r===null)return;if(t==="off"||t==="false")return!1;let o={};return t&&t!=="on"&&t!=="true"&&(o.visibility=t),r&&(o.size=r),e&&(o.position=e),n!==null&&(o.inset=Number(n)),se(o),(t==="on"||t==="true")&&!o.visibility&&(o.visibility="hover"),o}function So(a,t){let e=ct(a,"layout");return e==="flow"||!e&&/^[ \t]*piano(?:\s|$)/m.test(t)}var Ue=class{constructor(t,e={}){this.part="score";this.disposed=!1;this.composing=!1;this.surface=null;this.text_area=null;this.editor_error=null;this.timeoutID=null;if(this.order=e.order,this.playback=e.playback??Kt(),this.sel=t,!this.sel)throw new Error(`VexTab.Div: invalid selector: ${t}`);this.code=(0,lt.default)(t).text(),(0,lt.default)(t).empty(),(0,lt.default)(t).css("position")==="static"&&(0,lt.default)(t).css("position","relative");let n=(0,lt.default)(t)[0];this.playbackControls=e.playbackControls??xo(n),this.enablePlayer=e.player??(this.playbackControls===void 0?void 0:!!this.playbackControls);let r=ct(n,"performer");if(e.performer!==void 0)this.performer=e.performer;else if(r){if(!sn(r))throw new RangeError("Unknown performer: "+r);this.performer=r}this.seed=e.seed;let o=ct(n,"width");this.width=parseInt(o,10)||400,this.scale=parseFloat(ct(n,"scale"))||1,this.rendererBackend=ct(n,"renderer")||"svg";let s=e.language??Number(ct(n,"language")??2);if(s!==1&&s!==2)throw new RangeError("Expected VexTab language 1 or 2");this.grammar2=s===2;let i=e.capacity??ct(n,"capacity")??"default";if(i!=="default"&&i!=="large")throw new RangeError("Expected score capacity default or large");if(this.capacity=i,this.partIndex=e.partIndex,this.partId=e.partId??ct(n,"part-id")??void 0,this.conductor=(e.view??ct(n,"view"))==="conductor",this.conductor&&(!this.grammar2||this.partIndex!==void 0||this.partId!==void 0))throw new Error("The conductor view requires a complete v2 score");this.flow=this.grammar2||So(n,this.code),n.classList.toggle("vextab-flow",this.flow),this.editor=ct(n,"editor")||"",this.show_errors=ct(n,"show-errors")||"",this.editor_width=parseInt(ct(n,"editor-width","editor_width"),10)||this.width,this.editor_height=parseInt(ct(n,"editor-height","editor_height"),10)||200,this.editor==="true"?(this.text_area=(0,lt.default)('<textarea aria-label="VexTab source"></textarea>').addClass("editor").val(this.code),this.code=this.text_area.val(),this.editor_error=(0,lt.default)('<div role="status"></div>').addClass("editor-error"),(0,lt.default)(t).append((0,lt.default)("<p/>")).append(this.editor_error),(0,lt.default)(t).append((0,lt.default)("<p/>")).append(this.text_area),this.text_area.width(this.editor_width),this.text_area.height(this.editor_height),this.text_area.on("compositionstart.vextab",()=>{this.composing=!0,window.clearTimeout(this.timeoutID)}),this.text_area.on("compositionend.vextab",()=>{this.composing=!1,this.scheduleEdit()}),this.text_area.on("input.vextab",()=>this.scheduleEdit()),this.text_area.on("keydown.vextab",c=>{!this.composing&&(c.ctrlKey||c.metaKey)&&c.key==="Enter"&&(c.preventDefault(),this.run())})):this.show_errors==="true"&&(this.editor_error=(0,lt.default)('<div role="status"></div>').addClass("editor-error"),(0,lt.default)(t).append((0,lt.default)("<p/>")).append(this.editor_error)),this.flow||(this.artist=new Rt(10,0,this.width,{scale:this.scale}),this.parser=new Ct(this.artist,{language:1})),this.autoWidth=this.flow&&ct(n,"layout")!=="fixed"&&(o===null||o==="auto"),this.autoWidth&&n.clientWidth>20&&(this.width=n.clientWidth),this.redraw(),document.fonts.status==="loading"&&document.fonts.ready.then(()=>{this.disposed||this.redraw()}),this.autoWidth&&(this.observer=new ResizeObserver(([c])=>{let l=Math.floor(c.contentRect.width);cancelAnimationFrame(this.resizeFrame),l>20&&l!==this.width&&(this.resizeFrame=requestAnimationFrame(()=>{this.width=l,this.draw()}))}),this.observer.observe(n))}dispose(){this.disposed=!0,this.player?.dispose(),this.observer?.disconnect(),cancelAnimationFrame(this.resizeFrame),window.clearTimeout(this.timeoutID),this.text_area?.off(".vextab")}scheduleEdit(){window.clearTimeout(this.timeoutID),this.player?.removeControls(),this.composing||(this.timeoutID=window.setTimeout(()=>this.run(),250))}run(){return window.clearTimeout(this.timeoutID),this.disposed||this.composing?this:(this.code=this.text_area?.val()??this.code,this.redraw())}getReadingEvents(){return this.getScore()?this.current.layouts.flatMap(t=>t.navigation.events):[]}getDiagnosticRange(){return!this.disposed&&this.code===(this.text_area?.val()??this.code)?this.diagnostic:void 0}selectError(){let t=this.getDiagnosticRange();return!t||!this.text_area?!1:(this.text_area[0].focus(),this.text_area[0].setSelectionRange(t.start,t.end),!0)}getScoreDocument(){return!this.disposed&&this.document?.source===(this.text_area?.val()??this.code)?this.document:void 0}setInstrumentView(t,e="score"){if(!this.grammar2)throw new Error("Instrument selection requires a v2 score");return this.conductor=t==="conductor",this.partIndex=t==="conductor"?void 0:t.partIndex,this.partId=t==="conductor"?void 0:t.partId,this.part=t==="conductor"?"score":e,this.run()}setPart(t){if(!this.flow)throw new Error('setPart requires layout="flow"');return this.part=t,this.draw()}redraw(){return N.BM("Total render time: ",()=>{this.parse(),this.draw()}),this}reportError(t){this.player?.removeControls(),this.diagnostic=t instanceof Te?{start:t.range[0],end:t.range[1],line:t.line,column:t.column-1}:t.range,this.surface?.setAttribute("data-preview-stale","true");let e=this.surface?"Showing the last valid score. ":"";this.editor_error?.text(e+t.message),(0,lt.default)(this.sel)[0].dispatchEvent(new Event("vextab-render"))}getScore(){if(!this.disposed&&this.current&&this.current.score===this.candidate&&!this.surface?.hasAttribute("data-preview-stale")&&this.current.score.source===(this.text_area?.val()??this.code))return this.current.score}setWidth(t){if(!this.flow)throw new Error('setWidth requires layout="flow"');return this.observer?.disconnect(),cancelAnimationFrame(this.resizeFrame),this.autoWidth=!1,this.width=t,this.draw()}selectSource(t,e){let n=this.getScore(),r=n&&n===e&&this.current.layouts.map(s=>s.rangeFor(t,n.source)).find(Boolean);if(!r||!this.text_area)return!1;let o=this.text_area[0];return o.focus(),o.setSelectionRange(r.start,r.end),!0}drawView(t,e,n){let r=this.rendererBackend.toLowerCase()==="canvas"?"canvas":"svg",o=Math.max(21,this.width/(e.layout?.scale??1)),s=this.autoWidth?e.layout?.width??o:this.width,i="parts"in e?We(t,e,{width:s,renderer:r}):je(t,e,{width:s,part:this.part,renderer:r}),c=t.querySelector("svg, canvas"),l=ye(c);return this.text_area&&c.addEventListener("click",d=>{let m=l(d);if(!m)return;let f=i.hitTest(m.x,m.y);f&&this.selectSource(f.id,n)}),{layout:i,surface:c}}drawFlow(t){if(!this.grammar2&&(this.rendererBackend.toLowerCase()!=="svg"||this.scale!==1))throw new Error("Flow layout requires SVG at scale 1. Use width to reflow.");let e=this.candidate,n=this.document,r=n&&this.part==="score"&&this.partId===void 0&&this.partIndex===void 0&&n.parts.length>1,s=this.conductor&&this.part==="score"?[this.drawView(t,n,e)]:r?n.parts.map((i,c)=>{let l=t.appendChild(document.createElement("div"));return this.drawView(l,vt(n,c),e)}):[this.drawView(t,e,e)];this.grammar2&&this.scale!==1&&(t.style.zoom=String(this.scale)),this.player?.dispose(),this.player=void 0,(this.enablePlayer??e.playback?.enabled)&&(this.player=new Tt(r?n:s[0].layout.score,{playback:this.playback,controls:this.playbackControls,performer:this.performer,seed:this.seed,order:this.order})).render(s[0].surface,void 0,s.slice(1).map(c=>c.surface)),this.current={score:e,layouts:s.map(i=>i.layout)}}drawInternal(){if(this.flow?!this.candidate:!this.parser.isValid())return this;let t=this.rendererBackend.toLowerCase()==="canvas",e=document.createElement(t&&!this.flow?"canvas":"div");e.className="vex-canvas";let n=(0,lt.default)(this.sel)[0];n.insertBefore(e,n.firstChild);try{if(this.flow)this.drawFlow(e);else{let o=t?N.Flow.Renderer.Backends.CANVAS:N.Flow.Renderer.Backends.SVG,s=new N.Flow.Renderer(e,o);if(t||te(s.getContext(),e),this.enablePlayer!==void 0&&(this.artist.customizations.player=String(this.enablePlayer)),!this.player&&this.artist.customizations.player==="true"&&(this.player=new Tt(this.artist,{playback:this.playback,controls:this.playbackControls,performer:this.performer,seed:this.seed})),this.artist.draw(s),t){let i=this.artist.staves.map((c,l)=>{let m=(c.tab?c.tab_voices:c.note_voices).map((f,h)=>"Voice "+(h+1)+". "+f.filter(g=>!g.shouldIgnoreTicks()).map(g=>{let y=g.getPositions?.(),b=c.note?.getClef()==="percussion"?g.notation?.filter(A=>A.kind==="unpitched").map(A=>A.label):void 0,S=b?.length?b:y?.map(A=>"string "+A.str+" fret "+A.fret);return(g.isRest()?"rest":(S??g.getKeys()).join(", "))+" ("+g.getDuration()+")"}).join(". "));return"Stave "+(l+1)+", meter "+c.meter+". "+m.join(". ")}).join(". ");e.setAttribute("role","img"),e.setAttribute("aria-label",i),e.textContent=i}}this.surface?.remove(),this.surface=e;let r=this.flow?this.current.layouts.flatMap(o=>o.diagnostics):[];this.diagnostic=r[0]?.range,this.editor_error?.text(r.map(o=>{let s=o.range?" (line "+o.range.line+", column "+o.range.column+")":"";return(o.code==="RowOverflow"?"Bar "+o.measures.join(", ")+" exceeds this width":o.code)+s}).join(`
|
|
352
|
+
`)),n.dispatchEvent(new Event("vextab-render"))}catch(r){e.remove(),this.reportError(r)}return this}parseInternal(){try{this.flow?(this.candidate=void 0,this.document=this.grammar2?Lt(this.code,{capacity:this.capacity}):void 0,this.candidate=this.document?vt(this.document,xt(this.document,{partId:this.partId,partIndex:this.partIndex})):Lt(this.code,{language:1})):(this.artist.reset(),this.parser.parse(this.code))}catch(t){this.reportError(t)}return this}parse(){return N.BM("Parse time: ",()=>{this.parseInternal()}),this}draw(){return N.BM("Draw time: ",()=>{this.drawInternal()}),this}},ko=Ue;function Eo(a,t){let e={time:0,semitones:0};for(let n of a){if(t<n.time)return e.semitones+(n.semitones-e.semitones)*(t-e.time)/(n.time-e.time);e=n}return e.semitones}function Po(a,t=[0,1,2,3,4,5,6,7,8,10,11,12,13,14,15]){let e=[...new Set(t)];if(!e.length||e.some(o=>!Number.isInteger(o)||o<0||o>15))throw new RangeError("Supply MIDI channels from 0 to 15");let n=new Set;async function r(o,s){let i=a.context,c="resume"in i?i.resume():Promise.resolve();await Promise.all([c,a.isReady]),s.throwIfAborted();let l=new Set,d=new Set,m;function f(g){a.noteOff(g.channel,g.note.pitch),g.range&&a.pitchWheel(g.channel,8192),l.delete(g)}function h(){window.clearTimeout(m);let g=1/0;for(let y of l){let b=i.currentTime-y.start;if(b>=y.note.duration){f(y);continue}if(y.range){let S=Eo(y.note.bend,b)/y.range;a.pitchWheel(y.channel,Math.max(0,Math.min(16383,Math.round(8192+S*8192)))),g=Math.min(g,.012)}g=Math.min(g,y.note.duration-b)}l.size&&(m=window.setTimeout(h,Math.max(1,g*1e3)))}return{get currentTime(){return i.currentTime},playNote(g){h();let y=Math.ceil(Math.max(0,...(g.bend??[]).map(S=>Math.abs(S.semitones)))),b=e.find(S=>(!n.has(S)||d.has(S))&&![...l].some(T=>T.channel===S&&(y||T.range||T.note.pitch===g.pitch)));if(b===void 0)throw new Error("Insufficient reserved SpessaSynth channels for this chord");d.has(b)||(a.programChange(b,o),d.add(b),n.add(b)),y&&a.pitchWheelRange(b,y),a.noteOn(b,g.pitch,g.velocity),l.add({channel:b,note:g,start:i.currentTime,range:y}),h()},stop(){window.clearTimeout(m);for(let g of l)f(g);for(let g of d)n.delete(g);d.clear()}}}return{open:r}}export{Nn as a,N as b,Rt as c,Ct as d,Kt as e,Tt as f,je as g,We as h,vo as i,wo as j,ko as k,Po as l};
|