From 10090edc2018a2cf5b61b278c963c01c72b47f96 Mon Sep 17 00:00:00 2001 From: Bubobubobubobubo Date: Mon, 9 Oct 2023 19:17:13 +0000 Subject: [PATCH] deploy: 5de6bee171e265ba7e8be700e77a2c6622c0bbea --- assets/{index-9e2dd42b.js => index-bd28b959.js} | 2 +- index.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename assets/{index-9e2dd42b.js => index-bd28b959.js} (95%) diff --git a/assets/index-9e2dd42b.js b/assets/index-bd28b959.js similarity index 95% rename from assets/index-9e2dd42b.js rename to assets/index-bd28b959.js index f61a46c..badf01e 100644 --- a/assets/index-9e2dd42b.js +++ b/assets/index-bd28b959.js @@ -2564,7 +2564,7 @@ I won't teach you how to play with Hydra. You can find some great resources on t `+c.line+" | "+_+` `+m+" | "+t("",l.column-1," ")+t("",I,"^")}else s+=` at `+u}return s},e.buildMessage=function(i,s){var a={literal:function(_){return'"'+l(_.text)+'"'},class:function(_){var T=_.parts.map(function(I){return Array.isArray(I)?c(I[0])+"-"+c(I[1]):c(I)});return"["+(_.inverted?"^":"")+T.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(_){return _.description}};function o(_){return _.charCodeAt(0).toString(16).toUpperCase()}function l(_){return _.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(T){return"\\x0"+o(T)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(T){return"\\x"+o(T)})}function c(_){return _.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(T){return"\\x0"+o(T)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(T){return"\\x"+o(T)})}function u(_){return a[_.type](_)}function p(_){var T=_.map(u),I,R;if(T.sort(),T.length>0){for(I=1,R=1;I",R="@",L=":",$="/",K="(",f=")",E="[:",S="]",N="[",k="{",x="}",M="+",G="*",te="%",ne="^",re="&",ee=">>",B="<<",Q="_",j="?",Z="!",ue="r",le="#",Ee="b",De="iii",xe="ii",be="iv",Re="i",ce="vii",ke="vi",Ze="v",Le=/^[0-9]/,tt=/^[ \n\r\t]/,nt=/^[a-z]/,ze=/^[a-z_]/,St=/^[a-z_0-9]/,mt=/^[mklpdcwyhnqaefsxtgujzo]/,At=/^[a-zA-Z0-9]/,Rt=/^[a-zA-Z0-9\-*+]/,at=/^[A-G]/,$e=/^[bs]/,hr=lt("-",!1),rt=Zr([["0","9"]],!1,!1),He=lt(".",!1),Br=zs("whitespace"),cr=Zr([" ",` -`,"\r"," "],!1,!1),vr=lt(",",!1),W=lt("|",!1),_e=Zr([["a","z"]],!1,!1),we=Zr([["a","z"],"_"],!1,!1),Ne=Zr([["a","z"],"_",["0","9"]],!1,!1),Je=lt("<",!1),ye=lt(">",!1),Ht=lt("@",!1),ut=lt(":",!1),It=Zr(["m","k","l","p","d","c","w","y","h","n","q","a","e","f","s","x","t","g","u","j","z","o"],!1,!1),Vr=lt("/",!1),ht=lt("(",!1),Zt=lt(")",!1),Ct=lt("[:",!1),Be=lt("]",!1),Ur=lt("[",!1),Fn=lt("{",!1),dt=lt("}",!1),zr=lt("+",!1),Ir=lt("*",!1),Ii=lt("%",!1),Rr=lt("^",!1),Wt=lt("&",!1),yn=lt(">>",!1),ea=lt("<<",!1),li=lt("_",!1),ta=lt("?",!1),cn=lt("!",!1),ci=lt("r",!1),An=Zr([["a","z"],["A","Z"],["0","9"]],!1,!1),Kt=lt("#",!1),ui=lt("b",!1),di=Zr([["a","z"],["A","Z"],["0","9"],"-","*","+"],!1,!1),q=Zr([["A","G"]],!1,!1),ie=Zr(["b","s"],!1,!1),de=lt("iii",!1),ge=lt("ii",!1),Ae=lt("iv",!1),Qe=lt("i",!1),Me=lt("vii",!1),yt=lt("vi",!1),Nr=lt("v",!1),Hr=function(v){return v.filter(w=>w)},Da=function(){return parseFloat(Yr())},ra=function(){return parseInt(Yr())},Ds=function(){return parseInt(Yr())},Wr=function(){},xs=function(v){return Ut(XP,{sound:v})},xa=function(){return Yr()},ka=function(v){return Ut(Io,{items:v})},ks=function(v){return v},La=function(v,w){return Ut(ZP,{item:v,sound:w})},Ls=function(v,w){return Ut(KP,{item:v,soundIndex:w})},Ma=function(v){return v},Fr=function(){return UP[Yr()]},Ms=function(v,w){return v/w},Ps=function(v){return v.filter(w=>w)},Pa=function(v){return Ut(Io,{items:v})},Ba=function(v,w){return w?Ut(mE,{item:v,times:w}):Ut(gE,{items:v})},Bs=function(v){return v},Ua=function(v,w,P){return Ut(r3,{left:v,operation:w,right:P})},Us=function(v,w){return Ut(t3,{items:v,times:w})},Fa=function(v){return Ut(vI,{items:v})},Fs=function(v){return v.map(w=>typeof w=="number"?w:void 0)},Ys=function(){return Math.ceil(EI(Yr()))},un=function(v){var w=v.filter(P=>P).map(P=>Ut(ti,{pitch:P[0]},P.toString()));return Ut(gE,{items:w})},bt=function(v){return v},$s=function(v){return v},Ri=function(){},Gs=function(v){return Ut(Io,{items:v})},pi=function(v){return Ut(JP,{octave:v})},Qs=function(){return Yr().split("").reduce((v,w)=>v+(w==="^"?1:-1),0)},Ni=function(){return Ut(Mc,{seededRandom:s.seededRandom})},Ya=function(v,w){return Ut(Mc,{min:v,max:w,seededRandom:s.seededRandom})},$a=function(v,w){return Ut(mE,{item:v,times:w})},qs=function(v){return Ut(e3,{duration:v})},wi=function(v){return v},Ga=function(v){return Ut($m,{duration:v})},Di=function(v,w,P,X){const oe=v?s.nodeOptions.octave+v:s.nodeOptions.octave;return Ut(ti,{duration:w,pitch:X,pitchOctave:oe,add:P})},xi=function(v){return v.reduce((w,P)=>w+(P==="#"?1:-1),0)},Qa=function(v,w,P){return Ut(Ra,{pitches:[v].concat(w),inversion:P})},na=function(){return Yr()},hi=function(v){return v},fr=function(){return Yr()},qa=function(v,w,P,X,oe){const ve=s.nodeOptions.scaleName?s.nodeOptions.scaleName:"MAJOR",gt=s.nodeOptions.key?s.nodeOptions.key:"C",hn=d3(X,P,ve,v,w),Zs=w||s.nodeOptions.duration,mR=v?s.nodeOptions.octave+v:s.nodeOptions.octave;return Ut(Ra,{duration:Zs,chordOctave:mR,pitches:hn,chordName:X,inversion:oe,scaleName:ve,key:gt})},Xr=function(v,w,P){const X=s.nodeOptions.scaleName?s.nodeOptions.scaleName:"MAJOR",oe=s.nodeOptions.key?s.nodeOptions.key:"C";return Ut(jP,{roman:v,chordName:w,inversion:P,scaleName:X,key:oe})},ia=function(v){const w=s.nodeOptions.scaleName?s.nodeOptions.scaleName:"MAJOR",P=s.nodeOptions.key?s.nodeOptions.key:"C",X=O3(v,P,w);return Ut(ti,{pitch:X.pc,add:X.add,scaleName:w,key:P})},A=0,We=0,Va=[{line:1,column:1}],dn=0,Vs=[],Oe=0,me={},aa;if("startRule"in s){if(!(s.startRule in l))throw new Error(`Can't start parsing from rule "`+s.startRule+'".');c=l[s.startRule]}function Yr(){return i.substring(We,A)}function ul(){return d(We,A)}function lt(v,w){return{type:"literal",text:v,ignoreCase:w}}function Zr(v,w,P){return{type:"class",parts:v,inverted:w,ignoreCase:P}}function dl(){return{type:"end"}}function zs(v){return{type:"other",description:v}}function pl(v){var w=Va[v],P;if(w)return w;for(P=v-1;!Va[P];)P--;for(w=Va[P],w={line:w.line,column:w.column};Pdn&&(dn=A,Vs=[]),Vs.push(v))}function g(v,w,P){return new e(e.buildMessage(v,w),v,w,P)}function O(){var v,w,P=A*56+0,X=me[P];return X?(A=X.nextPos,X.result):(v=A,w=Xt(),w!==a&&(We=v,w=Hr(w)),v=w,me[P]={nextPos:A,result:v},v)}function C(){var v,w,P,X,oe,ve,gt,hn=A*56+1,Zs=me[hn];if(Zs)return A=Zs.nextPos,Zs.result;for(v=A,w=A,i.charCodeAt(A)===45?(P=u,A++):(P=a,Oe===0&&h(hr)),P===a&&(P=null),X=[],Le.test(i.charAt(A))?(oe=i.charAt(A),A++):(oe=a,Oe===0&&h(rt));oe!==a;)X.push(oe),Le.test(i.charAt(A))?(oe=i.charAt(A),A++):(oe=a,Oe===0&&h(rt));if(i.charCodeAt(A)===46?(oe=p,A++):(oe=a,Oe===0&&h(He)),oe!==a){if(ve=[],Le.test(i.charAt(A))?(gt=i.charAt(A),A++):(gt=a,Oe===0&&h(rt)),gt!==a)for(;gt!==a;)ve.push(gt),Le.test(i.charAt(A))?(gt=i.charAt(A),A++):(gt=a,Oe===0&&h(rt));else ve=a;ve!==a?(P=[P,X,oe,ve],w=P):(A=w,w=a)}else A=w,w=a;if(w===a)if(w=A,i.charCodeAt(A)===46?(P=p,A++):(P=a,Oe===0&&h(He)),P!==a){if(X=[],Le.test(i.charAt(A))?(oe=i.charAt(A),A++):(oe=a,Oe===0&&h(rt)),oe!==a)for(;oe!==a;)X.push(oe),Le.test(i.charAt(A))?(oe=i.charAt(A),A++):(oe=a,Oe===0&&h(rt));else X=a;X!==a?(P=[P,X],w=P):(A=w,w=a)}else A=w,w=a;return w!==a&&(We=v,w=Da()),v=w,me[hn]={nextPos:A,result:v},v}function y(){var v,w,P=A*56+2,X=me[P];return X?(A=X.nextPos,X.result):(v=A,i.charCodeAt(A)===45?A++:Oe===0&&h(hr),Le.test(i.charAt(A))?(w=i.charAt(A),A++):(w=a,Oe===0&&h(rt)),w!==a?(We=v,v=ra()):(A=v,v=a),me[P]={nextPos:A,result:v},v)}function D(){var v,w,P,X=A*56+3,oe=me[X];if(oe)return A=oe.nextPos,oe.result;if(v=A,i.charCodeAt(A)===45?A++:Oe===0&&h(hr),w=[],Le.test(i.charAt(A))?(P=i.charAt(A),A++):(P=a,Oe===0&&h(rt)),P!==a)for(;P!==a;)w.push(P),Le.test(i.charAt(A))?(P=i.charAt(A),A++):(P=a,Oe===0&&h(rt));else w=a;return w!==a?(We=v,v=Ds()):(A=v,v=a),me[X]={nextPos:A,result:v},v}function F(){var v,w,P=A*56+4,X=me[P];return X?(A=X.nextPos,X.result):(Oe++,v=A,tt.test(i.charAt(A))?(w=i.charAt(A),A++):(w=a,Oe===0&&h(cr)),w!==a&&(We=v,w=Wr()),v=w,Oe--,v===a&&(w=a,Oe===0&&h(Br)),me[P]={nextPos:A,result:v},v)}function U(){var v,w,P=A*56+8,X=me[P];return X?(A=X.nextPos,X.result):(v=A,w=H(),w!==a&&(We=v,w=xs(w)),v=w,me[P]={nextPos:A,result:v},v)}function H(){var v,w,P,X,oe,ve=A*56+10,gt=me[ve];if(gt)return A=gt.nextPos,gt.result;if(v=A,nt.test(i.charAt(A))?(w=i.charAt(A),A++):(w=a,Oe===0&&h(_e)),w!==a){if(P=[],ze.test(i.charAt(A))?(X=i.charAt(A),A++):(X=a,Oe===0&&h(we)),X!==a)for(;X!==a;)P.push(X),ze.test(i.charAt(A))?(X=i.charAt(A),A++):(X=a,Oe===0&&h(we));else P=a;if(P!==a){for(X=[],St.test(i.charAt(A))?(oe=i.charAt(A),A++):(oe=a,Oe===0&&h(Ne));oe!==a;)X.push(oe),St.test(i.charAt(A))?(oe=i.charAt(A),A++):(oe=a,Oe===0&&h(Ne));We=v,v=xa()}else A=v,v=a}else A=v,v=a;return me[ve]={nextPos:A,result:v},v}function z(){var v,w=A*56+11,P=me[w];return P?(A=P.nextPos,P.result):(v=pe(),v===a&&(v=he()),me[w]={nextPos:A,result:v},v)}function pe(){var v,w,P,X,oe=A*56+12,ve=me[oe];if(ve)return A=ve.nextPos,ve.result;if(v=A,i.charCodeAt(A)===60?(w=T,A++):(w=a,Oe===0&&h(Je)),w!==a){if(P=[],X=z(),X!==a)for(;X!==a;)P.push(X),X=z();else P=a;P!==a?(i.charCodeAt(A)===62?(X=I,A++):(X=a,Oe===0&&h(ye)),X!==a?(We=v,v=ka(P)):(A=v,v=a)):(A=v,v=a)}else A=v,v=a;return me[oe]={nextPos:A,result:v},v}function he(){var v,w=A*56+13,P=me[w];return P?(A=P.nextPos,P.result):(v=H(),v===a&&(v=pe(),v===a&&(v=F())),me[w]={nextPos:A,result:v},v)}function se(){var v,w,P,X=A*56+14,oe=me[X];return oe?(A=oe.nextPos,oe.result):(v=A,i.charCodeAt(A)===64?(w=R,A++):(w=a,Oe===0&&h(Ht)),w!==a?(P=z(),P!==a?(We=v,v=ks(P)):(A=v,v=a)):(A=v,v=a),me[X]={nextPos:A,result:v},v)}function ae(){var v,w=A*56+15,P=me[w];return P?(A=P.nextPos,P.result):(v=rr(),v===a&&(v=st(),v===a&&(v=qt(),v===a&&(v=ou(),v===a&&(v=Qt())))),me[w]={nextPos:A,result:v},v)}function Ce(){var v,w,P,X=A*56+16,oe=me[X];return oe?(A=oe.nextPos,oe.result):(v=A,w=ae(),w===a&&(w=Xs()),w!==a?(P=se(),P!==a?(We=v,v=La(w,P)):(A=v,v=a)):(A=v,v=a),me[X]={nextPos:A,result:v},v)}function Se(){var v,w,P,X=A*56+17,oe=me[X];return oe?(A=oe.nextPos,oe.result):(v=A,w=Ce(),w===a&&(w=ae(),w===a&&(w=Xs())),w!==a?(P=qe(),P!==a?(We=v,v=Ls(w,P)):(A=v,v=a)):(A=v,v=a),me[X]={nextPos:A,result:v},v)}function qe(){var v,w,P,X=A*56+18,oe=me[X];return oe?(A=oe.nextPos,oe.result):(v=A,i.charCodeAt(A)===58?(w=L,A++):(w=a,Oe===0&&h(ut)),w!==a?(P=Dt(),P!==a?(We=v,v=Ma(P)):(A=v,v=a)):(A=v,v=a),me[X]={nextPos:A,result:v},v)}function je(){var v,w,P=A*56+19,X=me[P];return X?(A=X.nextPos,X.result):(v=A,mt.test(i.charAt(A))?(w=i.charAt(A),A++):(w=a,Oe===0&&h(It)),w!==a&&(We=v,w=Fr()),v=w,me[P]={nextPos:A,result:v},v)}function Ue(){var v,w=A*56+20,P=me[w];return P?(A=P.nextPos,P.result):(v=Nt(),v===a&&(v=C(),v===a&&(v=je())),me[w]={nextPos:A,result:v},v)}function Nt(){var v,w,P,X,oe=A*56+21,ve=me[oe];return ve?(A=ve.nextPos,ve.result):(v=A,w=D(),w!==a?(i.charCodeAt(A)===47?(P=$,A++):(P=a,Oe===0&&h(Vr)),P!==a?(X=D(),X!==a?(We=v,v=Ms(w,X)):(A=v,v=a)):(A=v,v=a)):(A=v,v=a),me[oe]={nextPos:A,result:v},v)}function Xt(){var v,w,P,X=A*56+22,oe=me[X];if(oe)return A=oe.nextPos,oe.result;if(v=A,w=[],P=E_(),P===a&&(P=Se(),P===a&&(P=Ce(),P===a&&(P=rr(),P===a&&(P=qt(),P===a&&(P=st(),P===a&&(P=Qt(),P===a&&(P=Xs(),P===a&&(P=ou())))))))),P!==a)for(;P!==a;)w.push(P),P=E_(),P===a&&(P=Se(),P===a&&(P=Ce(),P===a&&(P=rr(),P===a&&(P=qt(),P===a&&(P=st(),P===a&&(P=Qt(),P===a&&(P=Xs(),P===a&&(P=ou()))))))));else w=a;return w!==a&&(We=v,w=Ps(w)),v=w,me[X]={nextPos:A,result:v},v}function Dt(){var v,w=A*56+23,P=me[w];return P?(A=P.nextPos,P.result):(v=F(),v===a&&(v=D(),v===a&&(v=O_(),v===a&&(v=cu(),v===a&&(v=er(),v===a&&(v=__()))))),me[w]={nextPos:A,result:v},v)}function er(){var v,w,P,X,oe=A*56+24,ve=me[oe];if(ve)return A=ve.nextPos,ve.result;if(v=A,i.charCodeAt(A)===60?(w=T,A++):(w=a,Oe===0&&h(Je)),w!==a){if(P=[],X=Dt(),X!==a)for(;X!==a;)P.push(X),X=Dt();else P=a;P!==a?(i.charCodeAt(A)===62?(X=I,A++):(X=a,Oe===0&&h(ye)),X!==a?(We=v,v=Pa(P)):(A=v,v=a)):(A=v,v=a)}else A=v,v=a;return me[oe]={nextPos:A,result:v},v}function st(){var v,w,P,X,oe,ve=A*56+25,gt=me[ve];return gt?(A=gt.nextPos,gt.result):(v=A,i.charCodeAt(A)===40?(w=K,A++):(w=a,Oe===0&&h(ht)),w!==a?(i.charCodeAt(A)===58?A++:Oe===0&&h(ut),P=Xt(),P!==a?(X=ft(),X===a&&(X=null),i.charCodeAt(A)===41?(oe=f,A++):(oe=a,Oe===0&&h(Zt)),oe!==a?(We=v,v=Ba(P,X)):(A=v,v=a)):(A=v,v=a)):(A=v,v=a),me[ve]={nextPos:A,result:v},v)}function ft(){var v,w,P,X=A*56+26,oe=me[X];return oe?(A=oe.nextPos,oe.result):(v=A,i.charCodeAt(A)===58?(w=L,A++):(w=a,Oe===0&&h(ut)),w!==a?(P=D(),P!==a?(We=v,v=Bs(P)):(A=v,v=a)):(A=v,v=a),me[X]={nextPos:A,result:v},v)}function rr(){var v,w,P,X,oe=A*56+27,ve=me[oe];return ve?(A=ve.nextPos,ve.result):(v=A,w=st(),w!==a?(P=S_(),P!==a?(X=st(),X!==a?(We=v,v=Ua(w,P,X)):(A=v,v=a)):(A=v,v=a)):(A=v,v=a),me[oe]={nextPos:A,result:v},v)}function Qt(){var v,w,P,X,oe,ve=A*56+28,gt=me[ve];return gt?(A=gt.nextPos,gt.result):(v=A,i.substr(A,2)===E?(w=E,A+=2):(w=a,Oe===0&&h(Ct)),w!==a?(P=Xt(),P!==a?(X=ft(),X===a&&(X=null),i.charCodeAt(A)===93?(oe=S,A++):(oe=a,Oe===0&&h(Be)),oe!==a?(We=v,v=Us(P,X)):(A=v,v=a)):(A=v,v=a)):(A=v,v=a),me[ve]={nextPos:A,result:v},v)}function qt(){var v,w,P,X,oe=A*56+29,ve=me[oe];return ve?(A=ve.nextPos,ve.result):(v=A,i.charCodeAt(A)===91?(w=N,A++):(w=a,Oe===0&&h(Ur)),w!==a?(P=Xt(),P!==a?(i.charCodeAt(A)===93?(X=S,A++):(X=a,Oe===0&&h(Be)),X!==a?(We=v,v=Fa(P)):(A=v,v=a)):(A=v,v=a)):(A=v,v=a),me[oe]={nextPos:A,result:v},v)}function pn(){var v,w=A*56+30,P=me[w];return P?(A=P.nextPos,P.result):(v=D(),v===a&&(v=y()),me[w]={nextPos:A,result:v},v)}function Hs(){var v,w,P,X=A*56+31,oe=me[X];if(oe)return A=oe.nextPos,oe.result;if(v=A,w=[],P=hl(),P===a&&(P=pn()),P!==a)for(;P!==a;)w.push(P),P=hl(),P===a&&(P=pn());else w=a;return w!==a&&(We=v,w=Fs(w)),v=w,me[X]={nextPos:A,result:v},v}function hl(){var v,w,P,X,oe=A*56+32,ve=me[oe];return ve?(A=ve.nextPos,ve.result):(v=A,i.charCodeAt(A)===40?A++:Oe===0&&h(ht),w=pn(),w!==a?(P=S_(),P!==a?(X=Hs(),X!==a?(i.charCodeAt(A)===41?A++:Oe===0&&h(Zt),We=v,v=Ys()):(A=v,v=a)):(A=v,v=a)):(A=v,v=a),me[oe]={nextPos:A,result:v},v)}function Ws(){var v,w,P,X,oe=A*56+33,ve=me[oe];if(ve)return A=ve.nextPos,ve.result;if(v=A,i.charCodeAt(A)===123?(w=k,A++):(w=a,Oe===0&&h(Fn)),w!==a){if(P=[],X=Hs(),X===a&&(X=F()),X!==a)for(;X!==a;)P.push(X),X=Hs(),X===a&&(X=F());else P=a;P!==a?(i.charCodeAt(A)===125?(X=x,A++):(X=a,Oe===0&&h(dt)),X!==a?(We=v,v=un(P)):(A=v,v=a)):(A=v,v=a)}else A=v,v=a;return me[oe]={nextPos:A,result:v},v}function __(){var v,w,P,X,oe=A*56+34,ve=me[oe];return ve?(A=ve.nextPos,ve.result):(v=A,i.charCodeAt(A)===123?(w=k,A++):(w=a,Oe===0&&h(Fn)),w!==a?(P=D(),P===a&&(P=cu()),P!==a?(i.charCodeAt(A)===125?(X=x,A++):(X=a,Oe===0&&h(dt)),X!==a?(We=v,v=bt(P)):(A=v,v=a)):(A=v,v=a)):(A=v,v=a),me[oe]={nextPos:A,result:v},v)}function S_(){var v,w=A*56+35,P=me[w];return P?(A=P.nextPos,P.result):(i.charCodeAt(A)===43?(v=M,A++):(v=a,Oe===0&&h(zr)),v===a&&(i.charCodeAt(A)===45?(v=u,A++):(v=a,Oe===0&&h(hr)),v===a&&(i.charCodeAt(A)===42?(v=G,A++):(v=a,Oe===0&&h(Ir)),v===a&&(i.charCodeAt(A)===47?(v=$,A++):(v=a,Oe===0&&h(Vr)),v===a&&(i.charCodeAt(A)===37?(v=te,A++):(v=a,Oe===0&&h(Ii)),v===a&&(i.charCodeAt(A)===94?(v=ne,A++):(v=a,Oe===0&&h(Rr)),v===a&&(i.charCodeAt(A)===124?(v=_,A++):(v=a,Oe===0&&h(W)),v===a&&(i.charCodeAt(A)===38?(v=re,A++):(v=a,Oe===0&&h(Wt)),v===a&&(i.substr(A,2)===ee?(v=ee,A+=2):(v=a,Oe===0&&h(yn)),v===a&&(i.substr(A,2)===B?(v=B,A+=2):(v=a,Oe===0&&h(ea))))))))))),me[w]={nextPos:A,result:v},v)}function Xs(){var v,w,P=A*56+36,X=me[P];return X?(A=X.nextPos,X.result):(v=A,w=cR(),w===a&&(w=hR(),w===a&&(w=pR(),w===a&&(w=fR(),w===a&&(w=U(),w===a&&(w=dR(),w===a&&(w=fl(),w===a&&(w=sR(),w===a&&(w=F(),w===a&&(w=oR(),w===a&&(w=st(),w===a&&(w=Ws(),w===a&&(w=aR())))))))))))),w!==a&&(We=v,w=$s(w)),v=w,me[P]={nextPos:A,result:v},v)}function aR(){var v,w,P=A*56+37,X=me[P];return X?(A=X.nextPos,X.result):(v=A,i.charCodeAt(A)===124?(w=_,A++):(w=a,Oe===0&&h(W)),w!==a&&(We=v,w=Ri()),v=w,me[P]={nextPos:A,result:v},v)}function ou(){var v,w,P,X,oe=A*56+38,ve=me[oe];return ve?(A=ve.nextPos,ve.result):(v=A,i.charCodeAt(A)===60?(w=T,A++):(w=a,Oe===0&&h(Je)),w!==a?(P=Xt(),P!==a?(i.charCodeAt(A)===62?(X=I,A++):(X=a,Oe===0&&h(ye)),X!==a?(We=v,v=Gs(P)):(A=v,v=a)):(A=v,v=a)):(A=v,v=a),me[oe]={nextPos:A,result:v},v)}function sR(){var v,w,P=A*56+39,X=me[P];return X?(A=X.nextPos,X.result):(v=A,w=lu(),w!==a&&(We=v,w=pi(w)),v=w,me[P]={nextPos:A,result:v},v)}function lu(){var v,w,P,X=A*56+40,oe=me[X];if(oe)return A=oe.nextPos,oe.result;if(v=A,w=[],i.charCodeAt(A)===94?(P=ne,A++):(P=a,Oe===0&&h(Rr)),P===a&&(i.charCodeAt(A)===95?(P=Q,A++):(P=a,Oe===0&&h(li))),P!==a)for(;P!==a;)w.push(P),i.charCodeAt(A)===94?(P=ne,A++):(P=a,Oe===0&&h(Rr)),P===a&&(i.charCodeAt(A)===95?(P=Q,A++):(P=a,Oe===0&&h(li)));else w=a;return w!==a&&(We=v,w=Qs()),v=w,me[X]={nextPos:A,result:v},v}function O_(){var v,w,P=A*56+41,X=me[P];return X?(A=X.nextPos,X.result):(v=A,i.charCodeAt(A)===63?(w=j,A++):(w=a,Oe===0&&h(ta)),w!==a&&(We=v,w=Ni()),v=w,me[P]={nextPos:A,result:v},v)}function cu(){var v,w,P,X,oe,ve,gt=A*56+42,hn=me[gt];return hn?(A=hn.nextPos,hn.result):(v=A,i.charCodeAt(A)===40?(w=K,A++):(w=a,Oe===0&&h(ht)),w!==a?(P=D(),P!==a?(i.charCodeAt(A)===44?(X=m,A++):(X=a,Oe===0&&h(vr)),X!==a?(oe=D(),oe!==a?(i.charCodeAt(A)===41?(ve=f,A++):(ve=a,Oe===0&&h(Zt)),ve!==a?(We=v,v=Ya(P,oe)):(A=v,v=a)):(A=v,v=a)):(A=v,v=a)):(A=v,v=a)):(A=v,v=a),me[gt]={nextPos:A,result:v},v)}function E_(){var v,w,P,X,oe=A*56+43,ve=me[oe];return ve?(A=ve.nextPos,ve.result):(v=A,w=Se(),w===a&&(w=Ce(),w===a&&(w=ae(),w===a&&(w=Xs()))),w!==a?(i.charCodeAt(A)===33?(P=Z,A++):(P=a,Oe===0&&h(cn)),P!==a?(X=D(),X!==a?(We=v,v=$a(w,X)):(A=v,v=a)):(A=v,v=a)):(A=v,v=a),me[oe]={nextPos:A,result:v},v)}function oR(){var v,w,P=A*56+44,X=me[P];return X?(A=X.nextPos,X.result):(v=A,w=Ue(),w!==a&&(We=v,w=qs(w)),v=w,me[P]={nextPos:A,result:v},v)}function lR(){var v,w,P,X=A*56+45,oe=me[X];return oe?(A=oe.nextPos,oe.result):(v=A,w=Ue(),w!==a?(i.charCodeAt(A)===94?(P=ne,A++):(P=a,Oe===0&&h(Rr)),P!==a?(We=v,v=wi(w)):(A=v,v=a)):(A=v,v=a),me[X]={nextPos:A,result:v},v)}function cR(){var v,w,P,X,oe,ve=A*56+46,gt=me[ve];return gt?(A=gt.nextPos,gt.result):(v=A,w=lR(),w===a&&(w=null),i.charCodeAt(A)===114?(P=ue,A++):(P=a,Oe===0&&h(ci)),P!==a?(X=A,Oe++,At.test(i.charAt(A))?(oe=i.charAt(A),A++):(oe=a,Oe===0&&h(An)),Oe--,oe===a?X=void 0:(A=X,X=a),X!==a?(We=v,v=Ga(w)):(A=v,v=a)):(A=v,v=a),me[ve]={nextPos:A,result:v},v)}function fl(){var v,w,P,X,oe,ve=A*56+47,gt=me[ve];return gt?(A=gt.nextPos,gt.result):(v=A,w=lu(),w===a&&(w=null),P=Ue(),P===a&&(P=null),X=uR(),X===a&&(X=null),oe=y(),oe===a&&(oe=O_(),oe===a&&(oe=cu(),oe===a&&(oe=__()))),oe!==a?(We=v,v=Di(w,P,X,oe)):(A=v,v=a),me[ve]={nextPos:A,result:v},v)}function uR(){var v,w,P,X=A*56+48,oe=me[X];if(oe)return A=oe.nextPos,oe.result;if(v=A,w=[],i.charCodeAt(A)===35?(P=le,A++):(P=a,Oe===0&&h(Kt)),P===a&&(i.charCodeAt(A)===98?(P=Ee,A++):(P=a,Oe===0&&h(ui))),P!==a)for(;P!==a;)w.push(P),i.charCodeAt(A)===35?(P=le,A++):(P=a,Oe===0&&h(Kt)),P===a&&(i.charCodeAt(A)===98?(P=Ee,A++):(P=a,Oe===0&&h(ui)));else w=a;return w!==a&&(We=v,w=xi(w)),v=w,me[X]={nextPos:A,result:v},v}function dR(){var v,w,P,X,oe=A*56+49,ve=me[oe];if(ve)return A=ve.nextPos,ve.result;if(v=A,w=fl(),w!==a){if(P=[],X=fl(),X!==a)for(;X!==a;)P.push(X),X=fl();else P=a;P!==a?(X=uu(),X===a&&(X=null),We=v,v=Qa(w,P,X)):(A=v,v=a)}else A=v,v=a;return me[oe]={nextPos:A,result:v},v}function b_(){var v,w,P,X=A*56+50,oe=me[X];if(oe)return A=oe.nextPos,oe.result;if(v=A,w=[],Rt.test(i.charAt(A))?(P=i.charAt(A),A++):(P=a,Oe===0&&h(di)),P!==a)for(;P!==a;)w.push(P),Rt.test(i.charAt(A))?(P=i.charAt(A),A++):(P=a,Oe===0&&h(di));else w=a;return w!==a&&(We=v,w=na()),v=w,me[X]={nextPos:A,result:v},v}function uu(){var v,w,P,X=A*56+51,oe=me[X];return oe?(A=oe.nextPos,oe.result):(v=A,i.charCodeAt(A)===37?(w=te,A++):(w=a,Oe===0&&h(Ii)),w!==a?(P=D(),P!==a?(We=v,v=hi(P)):(A=v,v=a)):(A=v,v=a),me[X]={nextPos:A,result:v},v)}function v_(){var v,w,P=A*56+52,X=me[P];return X?(A=X.nextPos,X.result):(v=A,at.test(i.charAt(A))?(w=i.charAt(A),A++):(w=a,Oe===0&&h(q)),w!==a?($e.test(i.charAt(A))?(i.charAt(A),A++):Oe===0&&h(ie),We=v,v=fr()):(A=v,v=a),me[P]={nextPos:A,result:v},v)}function pR(){var v,w,P,X,oe,ve,gt=A*56+53,hn=me[gt];return hn?(A=hn.nextPos,hn.result):(v=A,w=lu(),w===a&&(w=null),P=Ue(),P===a&&(P=null),X=v_(),X!==a?(i.charCodeAt(A)===94?A++:Oe===0&&h(Rr),oe=b_(),oe!==a?(ve=uu(),ve===a&&(ve=null),We=v,v=qa(w,P,X,oe,ve)):(A=v,v=a)):(A=v,v=a),me[gt]={nextPos:A,result:v},v)}function hR(){var v,w,P,X,oe=A*56+54,ve=me[oe];return ve?(A=ve.nextPos,ve.result):(v=A,i.substr(A,3)===De?(w=De,A+=3):(w=a,Oe===0&&h(de)),w===a&&(i.substr(A,2)===xe?(w=xe,A+=2):(w=a,Oe===0&&h(ge)),w===a&&(i.substr(A,2)===be?(w=be,A+=2):(w=a,Oe===0&&h(Ae)),w===a&&(i.charCodeAt(A)===105?(w=Re,A++):(w=a,Oe===0&&h(Qe)),w===a&&(i.substr(A,3)===ce?(w=ce,A+=3):(w=a,Oe===0&&h(Me)),w===a&&(i.substr(A,2)===ke?(w=ke,A+=2):(w=a,Oe===0&&h(yt)),w===a&&(i.charCodeAt(A)===118?(w=Ze,A++):(w=a,Oe===0&&h(Nr)))))))),w!==a?(i.charCodeAt(A)===94?A++:Oe===0&&h(Rr),P=b_(),P===a&&(P=null),X=uu(),X===a&&(X=null),We=v,v=Xr(w,P,X)):(A=v,v=a),me[oe]={nextPos:A,result:v},v)}function fR(){var v,w,P=A*56+55,X=me[P];return X?(A=X.nextPos,X.result):(v=A,w=v_(),w!==a&&(We=v,w=ia(w)),v=w,me[P]={nextPos:A,result:v},v)}var T_=s.nodeOptions||{};function Ut(v,w,P=void 0){w.text=P||Yr(),w.location=ul();for(var X in T_)(w[X]===void 0||w[X]===null)&&(w[X]=T_[X]);return new v(w)}if(aa=c(),aa!==a&&A===i.length)return aa;throw aa!==a&&Ae.collect("pitch"))}notes(){return this.evaluated.map(e=>e.collect("note"))}sounds(){return this.evaluated.map(e=>e.collect("sound"))}indices(){return this.evaluated.map(e=>e.collect("soundIndex"))}freqs(){return this.evaluated.map(e=>e.collect("freq"))}durations(){return this.evaluated.map(e=>e.collect("duration"))}octaves(){return this.evaluated.map(e=>e.collect("octave"))}retrograde(){return this.evaluated=this.evaluated.reverse(),this}scale(e){return this.applyOptions({scale:e}),this}key(e){return this.applyOptions({key:e}),this}octave(e){return this.applyOptions({octave:e}),this}invert(e){return this.applyOptions({inversion:e}),this}isInOptions(e,t){return this.options.nodeOptions&&this.options.nodeOptions[e]===t}atLast(){return this.index+1>=this.evaluated.length*this.redo}clone(){return ei(this)}notStarted(){return this.index<0}peek(){return this.evaluated[this.index-1||0]}hasStarted(){return this.index>=0}next(){this.index<0&&(this.index=0);const e=this.evaluated[this.index%this.evaluated.length];return this.index++,this.counter++,this.redo>0&&this.index>=this.evaluated.length*this.redo&&(this.index=0,this.evaluated=this.evaluate(this.values)),e}applyOptions(e={}){this.evaluated=this.evaluate(this.evaluated,e),this.applyTransformations()}applyTransformations(){var e;(e=this.globalOptions)!=null&&e.retrograde&&(this.evaluated=this.evaluated.reverse())}update(){return this.evaluated=this.evaluate(this.values),this.applyTransformations(),this}evaluate(e,t={}){let r=e.map(i=>i.evaluate(t)).flat(1/0).filter(i=>i!==void 0);return t.subdivisions&&(r=NI(r)),r}totalDuration(){return this.evaluated.reduce((t,r)=>t+r.collect("duration"),0)}lead(){let e=this.evaluated.findIndex(t=>t instanceof Ra);if(e>=0){for(let t=e+1;t<=this.evaluated.length;t++)if(this.evaluated[t]instanceof Ra){const r=this.evaluated[e],i=this.evaluated[t],s=b3(r.notes(),i.notes()),a=ei(i);a.voiceLeadFromNotes(s,this.options.nodeOptions),this.evaluated[t]=a,e=t}}return this}}const NI=(n,e=void 0)=>n.map(r=>{if(r instanceof vI){const i=r.evaluated.length,s=(e||r.duration)/i;return NI(r.evaluated,s)}else return r.duration=e||r.duration,r}).flat(1/0),C3=n=>{let e={};return WP.forEach(t=>{if(n[t]!==void 0){const r=n[t];e[t]=r,delete n[t]}}),e};class y3{constructor(e,t){b(this,"api");b(this,"settings");b(this,"midiAccess",null);b(this,"midiOutputs",[]);b(this,"currentOutputIndex",0);b(this,"scheduledNotes",{});b(this,"midiInputs",[]);b(this,"currentInputIndex");b(this,"bufferLength",512);b(this,"noteInputBuffer",[]);b(this,"ccInputBuffer",[]);b(this,"activeNotes",[]);b(this,"stickyNotes",[]);b(this,"lastNote");b(this,"lastCC",{});b(this,"lastNoteInChannel",{});b(this,"lastCCInChannel",{});b(this,"midiClockInputIndex");b(this,"midiClockInput");b(this,"lastTimestamp",0);b(this,"midiClockDelta",0);b(this,"lastBPM");b(this,"roundedBPM",0);b(this,"clockBuffer",[]);b(this,"clockBufferLength",24);b(this,"clockTicks",0);b(this,"clockErrorCount",0);b(this,"skipOnError",0);this.api=e,this.settings=t,this.lastBPM=e.bpm(),this.roundedBPM=this.lastBPM,this.initializeMidiAccess()}async initializeMidiAccess(){try{this.midiAccess=await navigator.requestMIDIAccess(),this.midiOutputs=Array.from(this.midiAccess.outputs.values()),this.midiOutputs.length===0&&(console.warn("No MIDI outputs available."),this.currentOutputIndex=-1),this.midiInputs=Array.from(this.midiAccess.inputs.values()),this.midiInputs.length===0?console.warn("No MIDI inputs available."):this.updateInputSelects()}catch(e){console.error("Failed to initialize MIDI:",e)}}getCurrentMidiPort(){return this.midiOutputs.length>0&&this.currentOutputIndex>=0&&this.currentOutputIndex0&&this.currentOutputIndex>=0&&this.currentOutputIndex0){const e=document.getElementById("midi-clock-input"),t=document.getElementById("default-midi-input");e.innerHTML="",t.innerHTML="";const r=document.createElement("option");r.value="-1",r.text="Internal",e.appendChild(r);const i=document.createElement("option");if(i.value="-1",i.text="None",t.appendChild(i),this.midiInputs.forEach((s,a)=>{const o=document.createElement("option");o.value=a.toString(),o.text=s.name||a.toString(),e.appendChild(o),t.appendChild(o.cloneNode(!0))}),this.settings.midi_clock_input){const s=this.getMidiInputIndex(this.settings.midi_clock_input);e.value=s.toString(),s>0&&(this.midiClockInput=this.midiInputs[s],this.registerMidiInputListener(s))}else e.value="-1";if(this.settings.default_midi_input){const s=this.getMidiInputIndex(this.settings.default_midi_input);t.value=s.toString(),s>0&&(this.currentInputIndex=s,this.registerMidiInputListener(s))}else t.value="-1";e.addEventListener("change",s=>{const a=s.target.value;if(a==="-1")this.midiClockInput&&this.midiClockInputIndex!=this.currentInputIndex&&(this.midiClockInput.onmidimessage=null),this.midiClockInput=void 0,this.settings.midi_clock_input=void 0;else{const o=parseInt(a);this.midiClockInputIndex=o,this.midiClockInput&&this.midiClockInputIndex!=this.currentInputIndex&&(this.midiClockInput.onmidimessage=null),this.midiClockInput=this.midiInputs[o],this.registerMidiInputListener(o),this.settings.midi_clock_input=this.midiClockInput.name||void 0}}),t.addEventListener("change",s=>{const a=s.target.value;a==="-1"?(this.currentInputIndex&&this.currentInputIndex!=this.midiClockInputIndex&&this.unregisterMidiInputListener(this.currentInputIndex),this.currentInputIndex=void 0,this.settings.default_midi_input=void 0):(this.currentInputIndex&&this.currentInputIndex!=this.midiClockInputIndex&&this.unregisterMidiInputListener(this.currentInputIndex),this.currentInputIndex=parseInt(a),this.registerMidiInputListener(this.currentInputIndex),this.settings.default_midi_input=this.midiInputs[this.currentInputIndex].name||void 0)})}}registerMidiInputListener(e){if(e!==void 0){const t=this.midiInputs[e];t&&!t.onmidimessage&&(t.onmidimessage=r=>{const i=r;if(t.name===this.settings.midi_clock_input&&(i.data[0]===248?this.skipOnError>0?this.skipOnError-=1:this.onMidiClock(r.timeStamp):i.data[0]===250?(console.log("MIDI start received"),this.api.stop(),this.api.play()):i.data[0]===252?(console.log("MIDI stop received"),this.api.pause()):i.data[0]===251?(console.log("MIDI continue received"),this.api.play()):i.data[0]===254&&console.log("MIDI active sensing received")),t.name===this.settings.default_midi_input){if(i.data[0]>=144&&i.data[0]<=159){const s=i.data[0]-144+1,a=i.data[1],o=i.data[2];this.lastNote={note:a,velocity:o,channel:s,timestamp:r.timeStamp},this.lastNoteInChannel[s]={note:a,velocity:o,channel:s,timestamp:r.timeStamp},this.settings.midi_channels_scripts&&this.api.script(s),this.pushToMidiInputBuffer({note:a,velocity:o,channel:s,timestamp:r.timeStamp}),this.activeNotes.push({note:a,velocity:o,channel:s,timestamp:r.timeStamp}),this.removeFromStickyNotes(a,s)||this.stickyNotes.push({note:a,velocity:o,channel:s,timestamp:r.timeStamp})}if(i.data[0]>=128&&i.data[0]<=143){const s=i.data[0]-128+1,a=i.data[1];this.removeFromActiveNotes(a,s)}if(i.data[0]>=176&&i.data[0]<=191){const s=i.data[0]-176+1,a=i.data[1],o=i.data[2];this.lastCC[a]=o,this.lastCCInChannel[s]?this.lastCCInChannel[s][a]=o:(this.lastCCInChannel[s]={},this.lastCCInChannel[s][a]=o),this.pushToMidiCCBuffer({control:a,value:o,channel:s,timestamp:r.timeStamp})}}})}}removeFromActiveNotes(e,t){const r=this.activeNotes.findIndex(i=>i.note===e&&i.channel===t);r>=0&&this.activeNotes.splice(r,1)}removeFromStickyNotes(e,t){const r=this.stickyNotes.findIndex(i=>i.note===e&&i.channel===t);return r>=0?(this.stickyNotes.splice(r,1),!0):!1}stickyNotesFromChannel(e){return this.stickyNotes.filter(t=>t.channel===e)}activeNotesFromChannel(e){return this.activeNotes.filter(t=>t.channel===e)}killActiveNotes(){this.activeNotes=[]}killActiveNotesFromChannel(e){this.activeNotes=this.activeNotes.filter(t=>t.channel!==e)}pushToMidiInputBuffer(e){this.noteInputBuffer.push(e),this.noteInputBuffer.length>this.bufferLength&&this.noteInputBuffer.shift()}pushToMidiCCBuffer(e){this.ccInputBuffer.push(e),this.ccInputBuffer.length>this.bufferLength&&this.ccInputBuffer.shift()}findNoteFromBufferInChannel(e){const t=this.noteInputBuffer.findIndex(r=>r.channel===e);if(t>=0){const r=this.noteInputBuffer[t];return this.noteInputBuffer.splice(t,1),r}else return}findCCFromBufferInChannel(e){const t=this.ccInputBuffer.findIndex(r=>r.channel===e);if(t>=0){const r=this.ccInputBuffer[t];return this.ccInputBuffer.splice(t,1),r}else return}unregisterMidiInputListener(e){if(e!==void 0){const t=this.midiInputs[e];t&&(t.onmidimessage=null)}}onMidiClock(e){if(this.clockTicks+=1,this.lastTimestamp>0)if(this.lastTimestamp===e)this.clockErrorCount+=1;else if(this.clockErrorCount>0)console.log("Timestamp error count: ",this.clockErrorCount),console.log("Current timestamp: ",e),console.log("Last timestamp: ",this.lastTimestamp),console.log("Last delta: ",this.midiClockDelta),console.log("Current delta: ",e-this.lastTimestamp),console.log("BPMs",this.clockBuffer),this.clockErrorCount=0,this.skipOnError=this.settings.midi_clock_ppqn/4,e=0;else{this.midiClockDelta=e-this.lastTimestamp,this.lastBPM=60*(1e3/this.midiClockDelta/this.settings.midi_clock_ppqn),this.clockBuffer.push(this.lastBPM),this.clockBuffer.length>this.clockBufferLength&&this.clockBuffer.shift();const t=this.estimatedBPM();t!==this.roundedBPM&&(console.log("Estimated BPM: ",t),this.api.bpm(t),this.roundedBPM=t)}this.lastTimestamp=e}estimatedBPM(){const e=this.clockBuffer.reduce((t,r)=>t+r);return Math.round(e/this.clockBuffer.length)}sendMidiClock(){if(!this.midiClockInput){const e=this.midiOutputs[this.currentOutputIndex];e&&e.send([248])}}switchMidiOutput(e){const t=this.getMidiOutputIndex(e);return t!==-1?(this.currentOutputIndex=t,!0):!1}getMidiOutputIndex(e){if(typeof e=="number")return e<0||e>=this.midiOutputs.length?(console.error(`Invalid MIDI output index. Index must be in the range 0-${this.midiOutputs.length-1}.`),this.currentOutputIndex):e;{const t=this.midiOutputs.findIndex(r=>r.name===e);return t!==-1?t:(console.error(`MIDI output "${e}" not found.`),this.currentOutputIndex)}}getMidiInputIndex(e){if(typeof e=="number")return e<0||e>=this.midiInputs.length?(console.error(`Invalid MIDI input index. Index must be in the range 0-${this.midiInputs.length-1}.`),-1):e;{const t=this.midiInputs.findIndex(r=>r.name===e);return t!==-1?t:(console.error(`MIDI input "${e}" not found.`),-1)}}listMidiOutputs(){let e="Available MIDI Outputs: ";return this.midiOutputs.forEach((t,r)=>{e+=`(${r+1}) ${t.name} `}),e}sendMidiNote(e,t,r,i,s=this.currentOutputIndex,a=void 0){typeof s=="string"&&(s=this.getMidiOutputIndex(s));const o=this.midiOutputs[s];if(e=Math.min(Math.max(e,0),127),o){const l=[144+t,e,r],c=[128+t,e,0];o.send(l),a&&this.sendPitchBend(a,t,s);const u=setTimeout(()=>{o.send(c),a&&this.sendPitchBend(8192,t,s),delete this.scheduledNotes[e]},(i-.02)*1e3);this.scheduledNotes[e]=u}else console.error("MIDI output not available.")}sendSysExMessage(e){const t=this.midiOutputs[this.currentOutputIndex];t?t.send(e):console.error("MIDI output not available.")}sendPitchBend(e,t,r=this.currentOutputIndex){(e<0||e>16383)&&console.error("Invalid pitch bend value. Value must be in the range 0-16383."),(t<0||t>15)&&console.error("Invalid MIDI channel. Channel must be in the range 0-15."),typeof r=="string"&&(r=this.getMidiOutputIndex(r));const i=this.midiOutputs[r];if(i){const s=e&127,a=e>>7&127;i.send([224|t,s,a])}else console.error("MIDI output not available.")}sendProgramChange(e,t){const r=this.midiOutputs[this.currentOutputIndex];r?r.send([192+t,e]):console.error("MIDI output not available.")}sendMidiControlChange(e,t,r){const i=this.midiOutputs[this.currentOutputIndex];i?i.send([176+r,e,t]):console.error("MIDI output not available.")}panic(){const e=this.midiOutputs[this.currentOutputIndex];if(e){for(const t in this.scheduledNotes){const r=this.scheduledNotes[t];clearTimeout(r),e.send([128,parseInt(t),0])}this.scheduledNotes={}}else console.error("MIDI output not available.")}}class A3{constructor(e,t,r){b(this,"min");b(this,"max");b(this,"wrap");b(this,"position");this.min=e,this.max=t,this.wrap=r,this.position=0}step(){const e=Math.floor(Math.random()*3)-1;this.position+=e,this.wrap?this.position>this.max?this.position=this.min:this.positionthis.max&&(this.position=this.max)}getPosition(){return this.position}toggleWrap(e){this.wrap=e}}class i_{constructor(e){b(this,"seedValue");b(this,"randomGen",Math.random);b(this,"app");b(this,"values",{});b(this,"evenbar",e=>this.app.clock.time_position.bar%2===0?this.modify(e):this);b(this,"even",e=>this.app.clock.time_position.beat%2===0?this.modify(e):this);b(this,"odd",e=>this.app.clock.time_position.beat%2!==0?this.modify(e):this);b(this,"odds",(e,t)=>this.randomGen()this);b(this,"almostNever",e=>this.odds(.025,e));b(this,"rarely",e=>this.odds(.1,e));b(this,"scarcely",e=>this.odds(.25,e));b(this,"sometimes",e=>this.odds(.5,e));b(this,"often",e=>this.odds(.75,e));b(this,"frequently",e=>this.odds(.9,e));b(this,"almostAlways",e=>this.odds(.985,e));b(this,"always",e=>this.modify(e));b(this,"modify",e=>e(this));b(this,"seed",e=>(this.seedValue=e.toString(),this.randomGen=this.app.api.localSeededRandom(this.seedValue),this));b(this,"clear",()=>(this.app.api.clearLocalSeed(this.seedValue),this));b(this,"apply",e=>this.modify(e));b(this,"length",e=>(this.values.length=e,this));this.app=e,this.app.api.currentSeed&&(this.randomGen=this.app.api.randomGen)}}class wI extends i_{constructor(t){super(t);b(this,"octave",t=>(this.values.octave=t,this.update(),this));b(this,"key",t=>(this.values.key=t,this.update(),this));b(this,"scale",t=>(e_(t)?(this.values.scaleName=t,this.values.parsedScale=vi(t)):this.values.parsedScale=t_(t),this.update(),this));b(this,"freq",t=>{this.values.freq=t;const r=n3(t);return r%1!==0?(this.values.note=Math.floor(r),this.values.bend=TI(r)[1]):this.values.note=r,this});b(this,"update",()=>{})}}let Dr=[],I3=(n,e)=>{let t,r=[],i={lc:0,l:e||0,value:n,set(s){i.value=s,i.notify()},get(){return i.lc||i.listen(()=>{})(),i.value},notify(s){t=r;let a=!Dr.length;for(let o=0;o{r===t&&(r=r.slice());let o=r.indexOf(s);~o&&(r.splice(o,2),i.lc--,i.lc||i.off())}},subscribe(s,a){let o=i.listen(s,a);return s(i.value),o},off(){}};return i},R3=(n={})=>{let e=I3(n);return e.setKey=function(t,r){typeof r>"u"?t in e.value&&(e.value={...e.value},delete e.value[t],e.notify(t)):e.value[t]!==r&&(e.value={...e.value,[t]:r},e.notify(t))},e};if(typeof DelayNode<"u"){class n extends DelayNode{constructor(t,r,i,s){super(t),r=Math.abs(r),this.delayTime.value=i;const a=t.createGain();a.gain.value=Math.min(Math.abs(s),.995),this.feedback=a.gain;const o=t.createGain();return o.gain.value=r,this.delayGain=o,this.connect(a),this.connect(o),a.connect(this),this.connect=l=>o.connect(l),this}start(t){this.delayGain.gain.setValueAtTime(this.delayGain.gain.value,t+this.delayTime.value)}}AudioContext.prototype.createFeedbackDelay=function(e,t,r){return new n(this,e,t,r)}}typeof AudioContext<"u"&&(AudioContext.prototype.impulseResponse=function(n,e=1){const t=this.sampleRate*n,r=this.createBuffer(e,t,this.sampleRate),i=r.getChannelData(0);for(let s=0;s(e.buffer=this.impulseResponse(t),e.duration=n,e),e.setDuration(n),e});var _E={a:{freqs:[660,1120,2750,3e3,3350],gains:[1,.5012,.0708,.0631,.0126],qs:[80,90,120,130,140]},e:{freqs:[440,1800,2700,3e3,3300],gains:[1,.1995,.1259,.1,.1],qs:[70,80,100,120,120]},i:{freqs:[270,1850,2900,3350,3590],gains:[1,.0631,.0631,.0158,.0158],qs:[40,90,100,120,120]},o:{freqs:[430,820,2700,3e3,3300],gains:[1,.3162,.0501,.0794,.01995],qs:[40,80,100,120,120]},u:{freqs:[370,630,2750,3e3,3400],gains:[1,.1,.0708,.0316,.01995],qs:[40,60,100,120,120]}};if(typeof GainNode<"u"){class n extends GainNode{constructor(t,r){if(super(t),!_E[r])throw new Error("vowel: unknown vowel "+r);const{gains:i,qs:s,freqs:a}=_E[r],o=t.createGain();for(let l=0;l<5;l++){const c=t.createGain();c.gain.value=i[l];const u=t.createBiquadFilter();u.type="bandpass",u.Q.value=s[l],u.frequency.value=a[l],this.connect(u),u.connect(c),c.connect(o)}return o.gain.value=8,this.connect=l=>o.connect(l),this}}AudioContext.prototype.createVowelFilter=function(e){return new n(this,e)}}const N3=n=>{var i;if(typeof n!="string")return[];const[e,t="",r]=((i=n.match(/^([a-gA-G])([#bsf]*)([0-9]*)$/))==null?void 0:i.slice(1))||[];return e?[e,t,r?Number(r):void 0]:[]},w3={c:0,d:2,e:4,f:5,g:7,a:9,b:11},D3={"#":1,b:-1,s:1,f:-1},nu=(n,e=3)=>{const[t,r,i=e]=N3(n);if(!t)throw new Error('not a note: "'+n+'"');const s=w3[t.toLowerCase()],a=(r==null?void 0:r.split("").reduce((o,l)=>o+D3[l],0))||0;return(Number(i)+1)*12+s+a},DI=n=>Math.pow(2,(n-69)/12)*440,Qm=(n,e,t)=>Math.min(Math.max(n,e),t),x3=n=>12*Math.log(n/440)/Math.LN2+69,k3=(n,e)=>{if(typeof n!="object")throw new Error("valueToMidi: expected object value");let{freq:t,note:r}=n;if(typeof t=="number")return x3(t);if(typeof r=="string")return nu(r);if(typeof r=="number")return r;if(!e)throw new Error("valueToMidi: expected freq or note to be set");return e},L3="data:application/javascript;base64,Ly8gTElDRU5TRSBHTlUgR2VuZXJhbCBQdWJsaWMgTGljZW5zZSB2My4wIHNlZSBodHRwczovL2dpdGh1Yi5jb20vZGt0cjAvV2ViRGlydC9ibG9iL21haW4vTElDRU5TRQovLyBhbGwgdGhlIGNyZWRpdCBnb2VzIHRvIGRrdHIwJ3Mgd2ViZGlydDogaHR0cHM6Ly9naXRodWIuY29tL2RrdHIwL1dlYkRpcnQvYmxvYi81Y2UzZDY5ODM2MmM1NGQ2ZTFiNjhhY2M0N2ViMjk1NWFjNjJjNzkzL2Rpc3QvQXVkaW9Xb3JrbGV0cy5qcwovLyA8MwoKY2xhc3MgQ29hcnNlUHJvY2Vzc29yIGV4dGVuZHMgQXVkaW9Xb3JrbGV0UHJvY2Vzc29yIHsKICBzdGF0aWMgZ2V0IHBhcmFtZXRlckRlc2NyaXB0b3JzKCkgewogICAgcmV0dXJuIFt7IG5hbWU6ICdjb2Fyc2UnLCBkZWZhdWx0VmFsdWU6IDEgfV07CiAgfQoKICBjb25zdHJ1Y3RvcigpIHsKICAgIHN1cGVyKCk7CiAgICB0aGlzLm5vdFN0YXJ0ZWQgPSB0cnVlOwogIH0KCiAgcHJvY2VzcyhpbnB1dHMsIG91dHB1dHMsIHBhcmFtZXRlcnMpIHsKICAgIGNvbnN0IGlucHV0ID0gaW5wdXRzWzBdOwogICAgY29uc3Qgb3V0cHV0ID0gb3V0cHV0c1swXTsKICAgIGNvbnN0IGNvYXJzZSA9IHBhcmFtZXRlcnMuY29hcnNlOwogICAgY29uc3QgYmxvY2tTaXplID0gMTI4OwogICAgY29uc3QgaGFzSW5wdXQgPSAhKGlucHV0WzBdID09PSB1bmRlZmluZWQpOwogICAgaWYgKGhhc0lucHV0KSB7CiAgICAgIHRoaXMubm90U3RhcnRlZCA9IGZhbHNlOwogICAgICBvdXRwdXRbMF1bMF0gPSBpbnB1dFswXVswXTsKICAgICAgZm9yIChsZXQgbiA9IDE7IG4gPCBibG9ja1NpemU7IG4rKykgewogICAgICAgIGZvciAobGV0IG8gPSAwOyBvIDwgb3V0cHV0Lmxlbmd0aDsgbysrKSB7CiAgICAgICAgICBvdXRwdXRbb11bbl0gPSBuICUgY29hcnNlID09IDAgPyBpbnB1dFswXVtuXSA6IG91dHB1dFtvXVtuIC0gMV07CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICByZXR1cm4gdGhpcy5ub3RTdGFydGVkIHx8IGhhc0lucHV0OwogIH0KfQoKcmVnaXN0ZXJQcm9jZXNzb3IoJ2NvYXJzZS1wcm9jZXNzb3InLCBDb2Fyc2VQcm9jZXNzb3IpOwoKY2xhc3MgQ3J1c2hQcm9jZXNzb3IgZXh0ZW5kcyBBdWRpb1dvcmtsZXRQcm9jZXNzb3IgewogIHN0YXRpYyBnZXQgcGFyYW1ldGVyRGVzY3JpcHRvcnMoKSB7CiAgICByZXR1cm4gW3sgbmFtZTogJ2NydXNoJywgZGVmYXVsdFZhbHVlOiAwIH1dOwogIH0KCiAgY29uc3RydWN0b3IoKSB7CiAgICBzdXBlcigpOwogICAgdGhpcy5ub3RTdGFydGVkID0gdHJ1ZTsKICB9CgogIHByb2Nlc3MoaW5wdXRzLCBvdXRwdXRzLCBwYXJhbWV0ZXJzKSB7CiAgICBjb25zdCBpbnB1dCA9IGlucHV0c1swXTsKICAgIGNvbnN0IG91dHB1dCA9IG91dHB1dHNbMF07CiAgICBjb25zdCBjcnVzaCA9IHBhcmFtZXRlcnMuY3J1c2g7CiAgICBjb25zdCBibG9ja1NpemUgPSAxMjg7CiAgICBjb25zdCBoYXNJbnB1dCA9ICEoaW5wdXRbMF0gPT09IHVuZGVmaW5lZCk7CiAgICBpZiAoaGFzSW5wdXQpIHsKICAgICAgdGhpcy5ub3RTdGFydGVkID0gZmFsc2U7CiAgICAgIGlmIChjcnVzaC5sZW5ndGggPT09IDEpIHsKICAgICAgICBjb25zdCB4ID0gTWF0aC5wb3coMiwgY3J1c2hbMF0gLSAxKTsKICAgICAgICBmb3IgKGxldCBuID0gMDsgbiA8IGJsb2NrU2l6ZTsgbisrKSB7CiAgICAgICAgICBjb25zdCB2YWx1ZSA9IE1hdGgucm91bmQoaW5wdXRbMF1bbl0gKiB4KSAvIHg7CiAgICAgICAgICBmb3IgKGxldCBvID0gMDsgbyA8IG91dHB1dC5sZW5ndGg7IG8rKykgewogICAgICAgICAgICBvdXRwdXRbb11bbl0gPSB2YWx1ZTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgZm9yIChsZXQgbiA9IDA7IG4gPCBibG9ja1NpemU7IG4rKykgewogICAgICAgICAgbGV0IHggPSBNYXRoLnBvdygyLCBjcnVzaFtuXSAtIDEpOwogICAgICAgICAgY29uc3QgdmFsdWUgPSBNYXRoLnJvdW5kKGlucHV0WzBdW25dICogeCkgLyB4OwogICAgICAgICAgZm9yIChsZXQgbyA9IDA7IG8gPCBvdXRwdXQubGVuZ3RoOyBvKyspIHsKICAgICAgICAgICAgb3V0cHV0W29dW25dID0gdmFsdWU7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICByZXR1cm4gdGhpcy5ub3RTdGFydGVkIHx8IGhhc0lucHV0OwogIH0KfQpyZWdpc3RlclByb2Nlc3NvcignY3J1c2gtcHJvY2Vzc29yJywgQ3J1c2hQcm9jZXNzb3IpOwoKY2xhc3MgU2hhcGVQcm9jZXNzb3IgZXh0ZW5kcyBBdWRpb1dvcmtsZXRQcm9jZXNzb3IgewogIHN0YXRpYyBnZXQgcGFyYW1ldGVyRGVzY3JpcHRvcnMoKSB7CiAgICByZXR1cm4gW3sgbmFtZTogJ3NoYXBlJywgZGVmYXVsdFZhbHVlOiAwIH1dOwogIH0KCiAgY29uc3RydWN0b3IoKSB7CiAgICBzdXBlcigpOwogICAgdGhpcy5ub3RTdGFydGVkID0gdHJ1ZTsKICB9CgogIHByb2Nlc3MoaW5wdXRzLCBvdXRwdXRzLCBwYXJhbWV0ZXJzKSB7CiAgICBjb25zdCBpbnB1dCA9IGlucHV0c1swXTsKICAgIGNvbnN0IG91dHB1dCA9IG91dHB1dHNbMF07CiAgICBjb25zdCBzaGFwZTAgPSBwYXJhbWV0ZXJzLnNoYXBlWzBdOwogICAgY29uc3Qgc2hhcGUxID0gc2hhcGUwIDwgMSA/IHNoYXBlMCA6IDEuMCAtIDRlLTEwOwogICAgY29uc3Qgc2hhcGUgPSAoMi4wICogc2hhcGUxKSAvICgxLjAgLSBzaGFwZTEpOwogICAgY29uc3QgYmxvY2tTaXplID0gMTI4OwogICAgY29uc3QgaGFzSW5wdXQgPSAhKGlucHV0WzBdID09PSB1bmRlZmluZWQpOwogICAgaWYgKGhhc0lucHV0KSB7CiAgICAgIHRoaXMubm90U3RhcnRlZCA9IGZhbHNlOwogICAgICBmb3IgKGxldCBuID0gMDsgbiA8IGJsb2NrU2l6ZTsgbisrKSB7CiAgICAgICAgY29uc3QgdmFsdWUgPSAoKDEgKyBzaGFwZSkgKiBpbnB1dFswXVtuXSkgLyAoMSArIHNoYXBlICogTWF0aC5hYnMoaW5wdXRbMF1bbl0pKTsKICAgICAgICBmb3IgKGxldCBvID0gMDsgbyA8IG91dHB1dC5sZW5ndGg7IG8rKykgewogICAgICAgICAgb3V0cHV0W29dW25dID0gdmFsdWU7CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICByZXR1cm4gdGhpcy5ub3RTdGFydGVkIHx8IGhhc0lucHV0OwogIH0KfQoKcmVnaXN0ZXJQcm9jZXNzb3IoJ3NoYXBlLXByb2Nlc3NvcicsIFNoYXBlUHJvY2Vzc29yKTsK";function Pc(n){const e=Jt().createGain();return e.gain.value=n,e}const qm=(n,e,t,r,i,s)=>{const a=Jt().createGain();return a.gain.setValueAtTime(0,s),a.gain.linearRampToValueAtTime(i,s+n),a.gain.linearRampToValueAtTime(t*i,s+n+e),{node:a,stop:o=>{a.gain.setValueAtTime(t*i,o),a.gain.linearRampToValueAtTime(0,o+r)}}},M3=(n,e,t,r,i,s)=>{t=Math.max(.001,t),i=Math.max(.001,i);const a=Jt().createGain();return a.gain.setValueAtTime(1e-4,s),a.gain.exponentialRampToValueAtTime(i,s+n),a.gain.exponentialRampToValueAtTime(t*i,s+n+e),{node:a,stop:o=>{a.gain.exponentialRampToValueAtTime(1e-4,o+r)}}},P3=(n,e,t,r,i,s,a,o,l)=>{const c=a-s,u=s+c,p=s+r*c;n.setValueAtTime(s,o),n.linearRampToValueAtTime(u,o+e),n.linearRampToValueAtTime(p,o+e+t),n.setValueAtTime(p,l),n.linearRampToValueAtTime(s,l+Math.max(i,.1))};function Zu(n,e,t,r,i,s,a,o,l,c,u,p=.5){const m=n.createBiquadFilter();if(m.type=e,m.Q.value=r,m.frequency.value=t,!isNaN(l)&&l!==0){const _=l*p,T=Qm(2**-_*t,0,2e4),I=Qm(2**(l-_)*t,0,2e4);return P3(m.frequency,i,s,a,o,T,I,c,u),m}return m}let B3=n=>console.log(n);const ys=(...n)=>B3(...n),a_=R3();function s_(n,e,t={}){a_.setKey(n,{onTrigger:e,data:t})}function SE(n){return a_.get()[n]}let Ku;const Jt=()=>(Ku||(Ku=new AudioContext),Ku);let Ul;const o_=()=>{const n=Jt();return Ul||(Ul=n.createGain(),Ul.connect(n.destination)),Ul};let ju;function U3(){return ju||(ju=Jt().audioWorklet.addModule(L3),ju)}function Ju(n,e,t){const r=new AudioWorkletNode(n,e);return Object.entries(t).forEach(([i,s])=>{r.parameters.get(i).value=s}),r}async function F3(n={}){const{disableWorklets:e=!1}=n;typeof window<"u"&&(await Jt().resume(),e?console.log("disableWorklets: AudioWorklet effects coarse, crush and shape are skipped!"):await U3().catch(t=>{console.warn("could not load AudioWorklet effects coarse, crush and shape",t)}))}async function Y3(n){return new Promise(e=>{document.addEventListener("click",async function t(){await F3(n),e(),document.removeEventListener("click",t)})})}let la={};function $3(n,e,t,r){var i;if(t=Qm(t,0,.98),!la[n]){const s=Jt().createFeedbackDelay(1,e,t);(i=s.start)==null||i.call(s,r),s.connect(o_()),la[n]=s}return la[n].delayTime.value!==e&&la[n].delayTime.setValueAtTime(e,r),la[n].feedback.value!==t&&la[n].feedback.setValueAtTime(t,r),la[n]}let ca={};function G3(n,e=2){if(!ca[n]){const t=Jt().createReverb(e);t.connect(o_()),ca[n]=t}return ca[n].duration!==e&&(ca[n]=ca[n].setDuration(e),ca[n].duration=e),ca[n]}let ua;function Q3(n=2048){if(!ua){const e=Jt().createAnalyser();e.fftSize=n,ua=e,new Float32Array(ua.frequencyBinCount)}return ua.fftSize!==n&&(ua.fftSize=n,new Float32Array(ua.frequencyBinCount)),ua}function ed(n,e,t){const r=Pc(t);return n.connect(r),r.connect(e),r}const OE=async(n,e,t)=>{const r=Jt();if(typeof n!="object")throw new Error(`expected hap.value to be an object, but got "${n}". Hint: append .note() or .s() to the end`,"error");n.duration=t;let i=r.currentTime+e,{s="triangle",bank:a,source:o,gain:l=.8,ftype:c="12db",fanchor:u=.5,cutoff:p,lpenv:m,lpattack:_=.01,lpdecay:T=.01,lpsustain:I=1,lprelease:R=.01,resonance:L=1,hpenv:$,hcutoff:K,hpattack:f=.01,hpdecay:E=.01,hpsustain:S=1,hprelease:N=.01,hresonance:k=1,bpenv:x,bandf:M,bpattack:G=.01,bpdecay:te=.01,bpsustain:ne=1,bprelease:re=.01,bandq:ee=1,coarse:B,crush:Q,shape:j,pan:Z,vowel:ue,delay:le=0,delayfeedback:Ee=.5,delaytime:De=.25,orbit:xe=1,room:be,size:Re=2,velocity:ce=1,analyze:ke,fft:Ze=8}=n;l*=ce;let Le=[];const tt=()=>{Le.forEach(at=>at==null?void 0:at.disconnect())};a&&s&&(s=`${a}_${s}`);let nt;if(o)nt=o(i,n,t);else if(SE(s)){const{onTrigger:at}=SE(s),$e=await at(i,n,tt);$e&&(nt=$e.node,$e.stop(i+t))}else throw new Error(`sound ${s} not found! Is it loaded?`);if(!nt)return;if(r.currentTime>i){ys("[webaudio] skip hap: still loading",r.currentTime-i);return}const ze=[];if(ze.push(nt),ze.push(Pc(l)),p!==void 0){let at=()=>Zu(r,"lowpass",p,L,_,T,I,R,m,i,i+t,u);ze.push(at()),c==="24db"&&ze.push(at())}if(K!==void 0){let at=()=>Zu(r,"highpass",K,k,f,E,S,N,$,i,i+t,u);ze.push(at()),c==="24db"&&ze.push(at())}if(M!==void 0){let at=()=>Zu(r,"bandpass",M,ee,G,te,ne,re,x,i,i+t,u);ze.push(at()),c==="24db"&&ze.push(at())}if(ue!==void 0){const at=r.createVowelFilter(ue);ze.push(at)}if(B!==void 0&&ze.push(Ju(r,"coarse-processor",{coarse:B})),Q!==void 0&&ze.push(Ju(r,"crush-processor",{crush:Q})),j!==void 0&&ze.push(Ju(r,"shape-processor",{shape:j})),Z!==void 0){const at=r.createStereoPanner();at.pan.value=2*Z-1,ze.push(at)}const St=Pc(1);ze.push(St),St.connect(o_());let mt;if(le>0&&De>0&&Ee>0){const at=$3(xe,De,Ee,i);mt=ed(St,at,le)}let At;if(be>0&&Re>0){const at=G3(xe,Re);At=ed(St,at,be)}let Rt;if(ke){const at=Q3(2**(Ze+5));Rt=ed(St,at,ke)}ze.slice(1).reduce((at,$e)=>at.connect($e),ze[0]),Le=ze.concat([mt,At,Rt])},td={};function q3(n,e){var t=e?1e3:1024;if(n=t);return n.toFixed(1)+" "+r[i]}const V3=async(n,e,t,r,i,s,a)=>{let o=0;i!==void 0&&t!==void 0&&ys("[sampler] hap has note and freq. ignoring note","warning");let l=k3({freq:i,note:t},36);o=l-36;const c=Jt();let u;if(Array.isArray(s))u=s[e%s.length];else{const T=R=>nu(R)-l,I=Object.keys(s).filter(R=>!R.startsWith("_")).reduce((R,L,$)=>!R||Math.abs(T(L)){const i=t?`sound "${t}:${r}"`:"sample";if(!td[n]){ys(`[sampler] load ${i}..`,"load-sample",{url:n});const s=Date.now();td[n]=fetch(n).then(a=>a.arrayBuffer()).then(async a=>{const o=Date.now()-s,l=q3(a.byteLength);return ys(`[sampler] load ${i}... done! loaded ${l} in ${o}ms`,"loaded-sample",{url:n}),await e.decodeAudioData(a)})}return td[n]};function H3(n){const e=Jt(),t=e.createBuffer(n.numberOfChannels,n.length,e.sampleRate);for(let r=0;rObject.entries(n).forEach(([r,i])=>{if(typeof i=="string"&&(i=[i]),typeof i!="object")throw new Error("wrong sample map format for "+r);t=i._base||t;const s=a=>(t+a).replace("github:","https://raw.githubusercontent.com/");Array.isArray(i)?i=i.map(s):i=Object.fromEntries(Object.entries(i).map(([a,o])=>[a,(typeof o=="string"?[o]:o).map(s)])),e(r,i)});let X3={};function Z3(n){const e=Object.entries(X3).find(([t])=>n.startsWith(t));if(e)return e[1]}const $i=async(n,e=n._base||"",t={})=>{if(typeof n=="string"){const s=Z3(n);if(s)return s(n);if(n.startsWith("github:")){let[o,l]=n.split("github:");l=l.endsWith("/")?l.slice(0,-1):l,n=`https://raw.githubusercontent.com/${l}/strudel.json`}if(typeof fetch!="function")return;const a=n.split("/").slice(0,-1).join("/");return typeof fetch>"u"?void 0:fetch(n).then(o=>o.json()).then(o=>$i(o,e||o._base||a,t)).catch(o=>{throw console.error(o),new Error(`error loading "${n}"`)})}const{prebake:r,tag:i}=t;W3(n,(s,a)=>s_(s,(o,l,c)=>K3(o,l,c,a),{type:"sample",samples:a,baseUrl:e,prebake:r,tag:i}),e)},EE=[];async function K3(n,e,t,r,i){let{s,freq:a,unit:o,nudge:l=0,cut:c,loop:u,clip:p=void 0,n:m=0,note:_,speed:T=1,loopBegin:I=0,begin:R=0,loopEnd:L=1,end:$=1}=e;if(T===0)return;u=s.startsWith("wt_")?1:e.loop;const K=Jt(),{attack:f=.001,decay:E=.001,sustain:S=1,release:N=.001}=e,k=n+l,x=await V3(s,m,_,T,a,r,i);if(K.currentTime>n){ys(`[sampler] still loading sound "${s}:${m}"`,"highlight");return}if(!x){ys(`[sampler] could not load "${s}:${m}"`,"error");return}x.playbackRate.value=Math.abs(T)*x.playbackRate.value,o==="c"&&(x.playbackRate.value=x.playbackRate.value*x.buffer.duration*1);const M=R*x.buffer.duration;u&&(x.loop=!0,x.loopStart=I*x.buffer.duration-M,x.loopEnd=L*x.buffer.duration-M),x.start(k,M);const{node:G,stop:te}=qm(f,E,S,N,1,n);x.connect(G);const ne=K.createGain();G.connect(ne),x.onended=function(){x.disconnect(),G.disconnect(),ne.disconnect(),t()};const re={node:ne,bufferSource:x,stop:(ee,B=p===void 0&&u===void 0)=>{let Q=ee;if(B){const j=x.buffer.duration/x.playbackRate.value;Q=n+($-R)*j}x.stop(Q+N),te(Q)}};if(c!==void 0){const ee=EE[c];ee&&(ee.node.gain.setValueAtTime(1,k),ee.node.gain.linearRampToValueAtTime(0,k+.01)),EE[c]=re}return re}const j3=(n,e=1,t="sine")=>{const r=Jt(),i=r.createOscillator();i.type=t,i.frequency.value=n,i.start();const s=new GainNode(r,{gain:e});return i.connect(s),{node:s,stop:a=>i.stop(a)}},J3=(n,e,t,r="sine")=>{const i=n.frequency.value*e,s=i*t;return j3(i,s,r)};function eB(){["sine","square","triangle","sawtooth"].forEach(n=>{s_(n,(e,t,r)=>{let{attack:i=.001,decay:s=.05,sustain:a=.6,release:o=.01,fmh:l=1,fmi:c,fmenv:u="lin",fmattack:p,fmdecay:m,fmsustain:_,fmrelease:T,fmvelocity:I,fmwave:R="sine",vib:L=0,vibmod:$=.5}=t,{n:K,note:f,freq:E}=t;f=f||36,typeof f=="string"&&(f=nu(f)),!E&&typeof f=="number"&&(E=DI(f));const{node:S,stop:N}=rB({t:e,s:n,freq:E,vib:L,vibmod:$,partials:K});let k,x;if(c){const{node:ne,stop:re}=J3(S,l,c,R);[p,m,_,T,I].find(ee=>ee!==void 0)?(p=p??.001,m=m??.001,_=_??1,T=T??.001,I=I??1,x=qm(p,m,_,T,I,e),u==="exp"&&(x=M3(p,m,_,T,I,e),x.node.maxValue=c*2,x.node.minValue=1e-5),ne.connect(x.node),x.node.connect(S.frequency)):ne.connect(S.frequency),k=re}const M=Pc(.3),{node:G,stop:te}=qm(i,s,a,o,1,e);return S.onended=()=>{S.disconnect(),M.disconnect(),r()},{node:S.connect(M).connect(G),stop:ne=>{te(ne),x==null||x.stop(ne);let re=ne+o;N(re),k==null||k(re)}}},{type:"synth",prebake:!0})})}function tB(n,e){const t=new Float32Array(n+1),r=new Float32Array(n+1),i=Jt(),s=i.createOscillator(),a={sawtooth:c=>1/c,square:c=>c%2===0?0:1/c,triangle:c=>c%2===0?0:1/(c*c)};if(!a[e])throw new Error(`unknown wave type ${e}`);t[0]=0,r[0]=0;let o=1;for(;o<=n;)t[o]=a[e](o),r[o]=0,o++;const l=i.createPeriodicWave(t,r);return s.setPeriodicWave(l),s}function rB({s:n,freq:e,t,vib:r,vibmod:i,partials:s}){let a;!s||n==="sine"?(a=Jt().createOscillator(),a.type=n||"triangle"):a=tB(s,n),a.frequency.value=Number(e),a.start(t);let o;if(r>0){o=Jt().createOscillator(),o.frequency.value=r;const l=Jt().createGain();l.gain.value=i*100,o.connect(l),l.connect(a.detune),o.start(t)}return{node:a,stop:l=>{o==null||o.stop(l),a.stop(l)}}}function nB(n=1,e=.05,t=220,r=0,i=0,s=.1,a=0,o=1,l=0,c=0,u=0,p=0,m=0,_=0,T=0,I=0,R=0,L=1,$=0,K=0){let f=Math.PI*2,E=Jt().sampleRate,S=Z=>Z>0?1:-1,N=l*=500*f/E/E,k=t*=(1+e*2*Math.random()-e)*f/E,x=[],M=0,G=0,te=0,ne=1,re=0,ee=0,B=0,Q,j;for(r=r*E+9,$*=E,i*=E,s*=E,R*=E,c*=500*f/E**3,T*=f/E,u*=f/E,p*=E,m=m*E|0,j=r+$+i+s+R|0;te1?a>2?a>3?Math.sin((M%f)**3):Math.max(Math.min(Math.tan(M),1),-1):1-(2*M/f%2+2)%2:1-4*Math.abs(Math.round(M/f)-M/f):Math.sin(M),B=(m?1-K+K*Math.sin(f*te/m):1)*S(B)*Math.abs(B)**o*n*1*(tete?0:(tep&&(t+=u,k+=u,ne=0),m&&!(++re%m)&&(t=k,l=N,ne||(ne=1));return x}const iB=(n,e)=>{let{s:t,note:r=36,freq:i,zrand:s=0,attack:a=0,decay:o=0,sustain:l=.8,release:c=.1,curve:u=1,slide:p=0,deltaSlide:m=0,pitchJump:_=0,pitchJumpTime:T=0,lfo:I=0,noise:R=0,zmod:L=0,zcrush:$=0,zdelay:K=0,tremolo:f=0,duration:E=.2,zzfx:S}=n;const N=Math.max(E-a-o,0);typeof r=="string"&&(r=nu(r)),!i&&typeof r=="number"&&(i=DI(r)),t=t.replace("z_","");const k=["sine","triangle","sawtooth","tan","noise"].indexOf(t)||0;u=t==="square"?0:u;const x=nB(...S||[.25,s,i,a,N,c,k,u,p,m,_,T,I,R,L,$,K,l,o,f]),M=Jt(),G=M.createBuffer(1,x.length,M.sampleRate);G.getChannelData(0).set(x);const te=Jt().createBufferSource();return te.buffer=G,te.start(e),{node:te}};function aB(){["zzfx","z_sine","z_sawtooth","z_triangle","z_square","z_tan","z_noise"].forEach(n=>{s_(n,(e,t,r)=>{const{node:i}=iB({s:n,...t},e);return i.onended=()=>{i.disconnect(),r()},{node:i,stop:()=>{}}},{type:"synth",prebake:!0})})}class Vm extends wI{constructor(t,r){super(r);b(this,"nudge");b(this,"volume",t=>this.updateValue("volume",t));b(this,"vol",this.volume);b(this,"zrand",t=>this.updateValue("zrand",t));b(this,"curve",t=>this.updateValue("curve",t));b(this,"slide",t=>this.updateValue("slide",t));b(this,"sld",this.slide);b(this,"deltaSlide",t=>this.updateValue("deltaSlide",t));b(this,"dslide",this.deltaSlide);b(this,"pitchJump",t=>this.updateValue("pitchJump",t));b(this,"pj",this.pitchJump);b(this,"pitchJumpTime",t=>this.updateValue("pitchJumpTime",t));b(this,"pjt",this.pitchJumpTime);b(this,"lfo",t=>this.updateValue("lfo",t));b(this,"noise",t=>this.updateValue("noise",t));b(this,"zmod",t=>this.updateValue("zmod",t));b(this,"zcrush",t=>this.updateValue("zcrush",t));b(this,"zdelay",t=>this.updateValue("zdelay",t));b(this,"sustainVolume",t=>this.updateValue("sustainVolume",t));b(this,"tremolo",t=>this.updateValue("tremolo",t));b(this,"dur",t=>this.updateValue("dur",t));b(this,"zzfx",t=>this.updateValue("zzfx",t));b(this,"fmi",t=>this.updateValue("fmi",t));b(this,"fmh",t=>this.updateValue("fmh",t));b(this,"fmenv",t=>this.updateValue("fmenv",t));b(this,"fmattack",t=>this.updateValue("fmattack",t));b(this,"fmatk",this.fmattack);b(this,"fmdecay",t=>this.updateValue("fmdecay",t));b(this,"fmdec",this.fmdecay);b(this,"fmsustain",t=>this.updateValue("fmsustain",t));b(this,"fmsus",this.fmsustain);b(this,"fmrelease",t=>this.updateValue("fmrelease",t));b(this,"fmrel",this.fmrelease);b(this,"fmvelocity",t=>this.updateValue("fmvelocity",t));b(this,"fmvel",this.fmvelocity);b(this,"fmwave",t=>this.updateValue("fmwave",t));b(this,"fmw",this.fmwave);b(this,"ftype",t=>this.updateValue("ftype",t));b(this,"fanchor",t=>this.updateValue("fanchor",t));b(this,"attack",t=>this.updateValue("attack",t));b(this,"atk",this.attack);b(this,"decay",t=>this.updateValue("decay",t));b(this,"dec",this.decay);b(this,"sustain",t=>this.updateValue("sustain",t));b(this,"sus",this.sustain);b(this,"release",t=>this.updateValue("release",t));b(this,"rel",this.release);b(this,"adsr",(t,r,i,s)=>(this.attack(t),this.decay(r),this.sustain(i),this.release(s),this));b(this,"lpenv",t=>this.updateValue("lpenv",t));b(this,"lpe",t=>this.updateValue("lpenv",t));b(this,"lpattack",t=>this.updateValue("lpattack",t));b(this,"lpa",this.lpattack);b(this,"lpdecay",t=>this.updateValue("lpdecay",t));b(this,"lpd",this.lpdecay);b(this,"lpsustain",t=>this.updateValue("lpsustain",t));b(this,"lps",this.lpsustain);b(this,"lprelease",t=>this.updateValue("lprelease",t));b(this,"lpr",this.lprelease);b(this,"cutoff",t=>this.updateValue("cutoff",t));b(this,"lpf",this.cutoff);b(this,"resonance",t=>this.updateValue("resonance",Math.min(Math.max(t,0),50)));b(this,"lpq",this.resonance);b(this,"lpadsr",(t,r,i,s,a)=>(this.lpenv(t),this.lpattack(r),this.lpdecay(i),this.lpsustain(s),this.lprelease(a),this));b(this,"hpenv",t=>this.updateValue("hpenv",t));b(this,"hpe",t=>this.updateValue("hpe",t));b(this,"hpattack",t=>this.updateValue("hpattack",t));b(this,"hpa",this.hpattack);b(this,"hpdecay",t=>this.updateValue("hpdecay",t));b(this,"hpd",this.hpdecay);b(this,"hpsustain",t=>this.updateValue("hpsustain",t));b(this,"hpsus",this.hpsustain);b(this,"hprelease",t=>this.updateValue("hprelease",t));b(this,"hpr",this.hprelease);b(this,"hcutoff",t=>this.updateValue("hcutoff",t));b(this,"hpf",this.hcutoff);b(this,"hresonance",t=>this.updateValue("hresonance",t));b(this,"hpq",this.hresonance);b(this,"hpadsr",(t,r,i,s,a)=>(this.hpenv(t),this.hpattack(r),this.hpdecay(i),this.hpsustain(s),this.hprelease(a),this));b(this,"bpenv",t=>this.updateValue("bpenv",t));b(this,"bpe",t=>this.updateValue("bpe",t));b(this,"bpattack",t=>this.updateValue("bpattack",t));b(this,"bpa",this.bpattack);b(this,"bpdecay",t=>this.updateValue("bpdecay",t));b(this,"bpd",this.bpdecay);b(this,"bpsustain",t=>this.updateValue("bpsustain",t));b(this,"bps",this.bpsustain);b(this,"bprelease",t=>this.updateValue("bprelease",t));b(this,"bpr",this.bprelease);b(this,"bandf",t=>this.updateValue("bandf",t));b(this,"bpf",this.bandf);b(this,"bandq",t=>this.updateValue("bandq",t));b(this,"bpq",this.bandq);b(this,"bpadsr",(t,r,i,s,a)=>(this.bpenv(t),this.bpattack(r),this.bpdecay(i),this.bpsustain(s),this.bprelease(a),this));b(this,"freq",t=>this.updateValue("freq",t));b(this,"f",this.freq);b(this,"vib",t=>this.updateValue("vib",t));b(this,"vibmod",t=>this.updateValue("vibmod",t));b(this,"fm",t=>{if(typeof t=="number")this.values.fmi=t;else{let r=t.split(":");this.values.fmi=parseFloat(r[0]),r.length>1&&(this.values.fmh=parseFloat(r[1]))}return this});b(this,"loop",t=>this.updateValue("loop",t));b(this,"loopBegin",t=>this.updateValue("loopBegin",t));b(this,"loopEnd",t=>this.updateValue("loopEnd",t));b(this,"begin",t=>this.updateValue("begin",t));b(this,"end",t=>this.updateValue("end",t));b(this,"gain",t=>this.updateValue("gain",t));b(this,"dbgain",t=>this.updateValue("gain",Math.min(Math.pow(10,t/20),10)));b(this,"db",this.dbgain);b(this,"velocity",t=>this.updateValue("velocity",t));b(this,"vel",this.velocity);b(this,"pan",t=>this.updateValue("pan",t));b(this,"sound",t=>this.updateValue("s",t));b(this,"chord",(t,...r)=>(typeof t=="string"?t=f3(t).map(s=>({note:s,freq:Zn(s)})):t instanceof Array&&typeof t[0]=="number"?t=t.map(i=>({note:i,freq:Zn(i)})):typeof t=="number"&&r.length>0&&(t=[t,...r].map(i=>({note:i,freq:Zn(i)}))),this.updateValue("chord",t)));b(this,"invert",(t=0)=>{if(this.values.chord){let r=this.values.chord.map(s=>s.note);r=t<0?[...r].reverse():r;for(let s=0;s({note:s,freq:Zn(s)}));return this.updateValue("chord",i)}else return this});b(this,"snd",this.sound);b(this,"cut",t=>this.updateValue("cut",t));b(this,"clip",t=>this.updateValue("clip",t));b(this,"n",t=>this.updateValue("n",t));b(this,"note",t=>typeof t=="string"?this.updateValue("note",oi(t)):this.updateValue("note",t));b(this,"speed",t=>this.updateValue("speed",t));b(this,"spd",this.speed);b(this,"coarse",t=>this.updateValue("coarse",t));b(this,"crush",t=>this.updateValue("crush",t));b(this,"shape",t=>this.updateValue("shape",t));b(this,"vowel",t=>this.updateValue("vowel",t));b(this,"vow",this.vowel);b(this,"delay",t=>this.updateValue("delay",t));b(this,"del",this.delay);b(this,"delayfeedback",t=>this.updateValue("delayfeedback",t));b(this,"delayfb",this.delayfeedback);b(this,"delaytime",t=>this.updateValue("delaytime",t));b(this,"delayt",this.delaytime);b(this,"orbit",t=>this.updateValue("orbit",t));b(this,"o",this.orbit);b(this,"room",t=>this.updateValue("room",t));b(this,"rm",this.room);b(this,"size",t=>this.updateValue("size",t));b(this,"sz",this.size);b(this,"stretch",t=>(this.updateValue("unit","c"),this.updateValue("speed",1/t),this.updateValue("cut",t),this));b(this,"modify",t=>{const r=t(this);return r instanceof Object?r:(t(this.values),this.update(),this)});b(this,"update",()=>{const[t,r]=r_(this.values.key||"C4",this.values.pitch||0,this.values.parsedScale||"MAJOR",this.values.octave||0);this.values.freq=Zn(t)});b(this,"out",()=>{this.values.chord?this.values.chord.forEach(t=>{const r={...this.values};r.freq=t.freq,OE(r,this.nudge,this.values.dur)}):OE(this.values,this.nudge,this.values.dur)});this.app=r,this.nudge=r.dough_nudge/100,typeof t=="string"?t.includes(":")?this.values={s:t.split(":")[0],n:t.split(":")[1],dur:r.clock.convertPulseToSecond(r.clock.ppqn)}:this.values={s:t,dur:.5}:this.values=t}updateValue(t,r){return this.values[t]=r,this}}class zm extends wI{constructor(t,r){super(r);b(this,"midiConnection");b(this,"chord",t=>(this.values.chord=t,this));b(this,"note",t=>(this.values.note=t,this));b(this,"sustain",t=>(this.values.sustain=t,this));b(this,"channel",t=>(this.values.channel=t,this));b(this,"port",t=>(this.values.port=this.midiConnection.getMidiOutputIndex(t),this));b(this,"add",t=>(this.values.note+=t,this));b(this,"modify",t=>{const r=t(this);return r instanceof Object?r:(t(this.values),this.update(),this)});b(this,"bend",t=>(this.values.bend=t,this));b(this,"random",(t=0,r=127)=>(t=Math.min(Math.max(t,0),127),r=Math.min(Math.max(r,0),127),this.values.note=Math.floor(this.randomGen()*(r-t+1))+t,this));b(this,"update",()=>{const[t,r]=r_(this.values.key||"C4",this.values.pitch||0,this.values.parsedScale||"MAJOR",this.values.octave||0);this.values.note=t,this.values.freq=Zn(t),r&&(this.values.bend=r)});b(this,"out",()=>{function t(r,i){const s=i&&i.channel?i.channel:0,a=r.values.channel?r.values.channel:s,o=r.values.velocity?r.values.velocity:100,l=i&&i.note?i.note:60,c=r.values.note?r.values.note:l,u=r.values.sustain?r.values.sustain*r.app.clock.pulse_duration*r.app.api.ppqn():r.app.clock.pulse_duration*r.app.api.ppqn(),p=r.values.bend?r.values.bend:void 0,m=r.values.port?r.midiConnection.getMidiOutputIndex(r.values.port):r.midiConnection.getCurrentMidiPortIndex();r.midiConnection.sendMidiNote(c,a,o,u,m,p)}this.values.chord?this.values.chord.forEach(r=>{t(this,r)}):t(this)});this.app=r,typeof t=="number"?this.values.note=t:this.values=t,this.midiConnection=r.api.MidiConnection}}const lo=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,xI=new Set,Hm=typeof process=="object"&&process?process:{},kI=(n,e,t,r)=>{typeof Hm.emitWarning=="function"?Hm.emitWarning(n,e,t,r):console.error(`[${t}] ${e}: ${n}`)};let Bc=globalThis.AbortController,bE=globalThis.AbortSignal;var dT;if(typeof Bc>"u"){bE=class{constructor(){b(this,"onabort");b(this,"_onabort",[]);b(this,"reason");b(this,"aborted",!1)}addEventListener(r,i){this._onabort.push(i)}},Bc=class{constructor(){b(this,"signal",new bE);e()}abort(r){var i,s;if(!this.signal.aborted){this.signal.reason=r,this.signal.aborted=!0;for(const a of this.signal._onabort)a(r);(s=(i=this.signal).onabort)==null||s.call(i,r)}}};let n=((dT=Hm.env)==null?void 0:dT.LRU_CACHE_IGNORE_AC_WARNING)!=="1";const e=()=>{n&&(n=!1,kI("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e))}}const sB=n=>!xI.has(n),Pi=n=>n&&n===Math.floor(n)&&n>0&&isFinite(n),LI=n=>Pi(n)?n<=Math.pow(2,8)?Uint8Array:n<=Math.pow(2,16)?Uint16Array:n<=Math.pow(2,32)?Uint32Array:n<=Number.MAX_SAFE_INTEGER?ec:null:null;class ec extends Array{constructor(e){super(e),this.fill(0)}}var cs;const ha=class ha{constructor(e,t){b(this,"heap");b(this,"length");if(!V(ha,cs))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0}static create(e){const t=LI(e);if(!t)return[];Xe(ha,cs,!0);const r=new ha(e,t);return Xe(ha,cs,!1),r}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}};cs=new WeakMap,ot(ha,cs,!1);let Wm=ha;var Nn,Jr,wn,Dn,us,nr,xn,ir,Mt,it,xr,en,Tr,dr,kn,pr,gi,_i,Ln,Mn,Qi,kr,Zo,Zm,Oa,Si,Ko,tn,Gc,MI,Ea,ds,jo,qn,Bi,Vn,Ui,Jo,Km,ps,tc,hs,rc,xt,Ft,el,jm,ba,Oo;const g_=class g_{constructor(e){ot(this,Zo);ot(this,Gc);ot(this,qn);ot(this,Vn);ot(this,Jo);ot(this,ps);ot(this,hs);ot(this,xt);ot(this,el);ot(this,ba);ot(this,Nn,void 0);ot(this,Jr,void 0);ot(this,wn,void 0);ot(this,Dn,void 0);ot(this,us,void 0);b(this,"ttl");b(this,"ttlResolution");b(this,"ttlAutopurge");b(this,"updateAgeOnGet");b(this,"updateAgeOnHas");b(this,"allowStale");b(this,"noDisposeOnSet");b(this,"noUpdateTTL");b(this,"maxEntrySize");b(this,"sizeCalculation");b(this,"noDeleteOnFetchRejection");b(this,"noDeleteOnStaleGet");b(this,"allowStaleOnFetchAbort");b(this,"allowStaleOnFetchRejection");b(this,"ignoreFetchAbort");ot(this,nr,void 0);ot(this,xn,void 0);ot(this,ir,void 0);ot(this,Mt,void 0);ot(this,it,void 0);ot(this,xr,void 0);ot(this,en,void 0);ot(this,Tr,void 0);ot(this,dr,void 0);ot(this,kn,void 0);ot(this,pr,void 0);ot(this,gi,void 0);ot(this,_i,void 0);ot(this,Ln,void 0);ot(this,Mn,void 0);ot(this,Qi,void 0);ot(this,kr,void 0);ot(this,Oa,()=>{});ot(this,Si,()=>{});ot(this,Ko,()=>{});ot(this,tn,()=>!1);ot(this,Ea,e=>{});ot(this,ds,(e,t,r)=>{});ot(this,jo,(e,t,r,i)=>{if(r||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});const{max:t=0,ttl:r,ttlResolution:i=1,ttlAutopurge:s,updateAgeOnGet:a,updateAgeOnHas:o,allowStale:l,dispose:c,disposeAfter:u,noDisposeOnSet:p,noUpdateTTL:m,maxSize:_=0,maxEntrySize:T=0,sizeCalculation:I,fetchMethod:R,noDeleteOnFetchRejection:L,noDeleteOnStaleGet:$,allowStaleOnFetchRejection:K,allowStaleOnFetchAbort:f,ignoreFetchAbort:E}=e;if(t!==0&&!Pi(t))throw new TypeError("max option must be a nonnegative integer");const S=t?LI(t):Array;if(!S)throw new Error("invalid max value: "+t);if(Xe(this,Nn,t),Xe(this,Jr,_),this.maxEntrySize=T||V(this,Jr),this.sizeCalculation=I,this.sizeCalculation){if(!V(this,Jr)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(R!==void 0&&typeof R!="function")throw new TypeError("fetchMethod must be a function if specified");if(Xe(this,us,R),Xe(this,Qi,!!R),Xe(this,ir,new Map),Xe(this,Mt,new Array(t).fill(void 0)),Xe(this,it,new Array(t).fill(void 0)),Xe(this,xr,new S(t)),Xe(this,en,new S(t)),Xe(this,Tr,0),Xe(this,dr,0),Xe(this,kn,Wm.create(t)),Xe(this,nr,0),Xe(this,xn,0),typeof c=="function"&&Xe(this,wn,c),typeof u=="function"?(Xe(this,Dn,u),Xe(this,pr,[])):(Xe(this,Dn,void 0),Xe(this,pr,void 0)),Xe(this,Mn,!!V(this,wn)),Xe(this,kr,!!V(this,Dn)),this.noDisposeOnSet=!!p,this.noUpdateTTL=!!m,this.noDeleteOnFetchRejection=!!L,this.allowStaleOnFetchRejection=!!K,this.allowStaleOnFetchAbort=!!f,this.ignoreFetchAbort=!!E,this.maxEntrySize!==0){if(V(this,Jr)!==0&&!Pi(V(this,Jr)))throw new TypeError("maxSize must be a positive integer if specified");if(!Pi(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");Ve(this,Gc,MI).call(this)}if(this.allowStale=!!l,this.noDeleteOnStaleGet=!!$,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!o,this.ttlResolution=Pi(i)||i===0?i:1,this.ttlAutopurge=!!s,this.ttl=r||0,this.ttl){if(!Pi(this.ttl))throw new TypeError("ttl must be a positive integer if specified");Ve(this,Zo,Zm).call(this)}if(V(this,Nn)===0&&this.ttl===0&&V(this,Jr)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!V(this,Nn)&&!V(this,Jr)){const N="LRU_CACHE_UNBOUNDED";sB(N)&&(xI.add(N),kI("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",N,g_))}}static unsafeExposeInternals(e){return{starts:V(e,_i),ttls:V(e,Ln),sizes:V(e,gi),keyMap:V(e,ir),keyList:V(e,Mt),valList:V(e,it),next:V(e,xr),prev:V(e,en),get head(){return V(e,Tr)},get tail(){return V(e,dr)},free:V(e,kn),isBackgroundFetch:t=>{var r;return Ve(r=e,xt,Ft).call(r,t)},backgroundFetch:(t,r,i,s)=>{var a;return Ve(a=e,hs,rc).call(a,t,r,i,s)},moveToTail:t=>{var r;return Ve(r=e,ba,Oo).call(r,t)},indexes:t=>{var r;return Ve(r=e,qn,Bi).call(r,t)},rindexes:t=>{var r;return Ve(r=e,Vn,Ui).call(r,t)},isStale:t=>{var r;return V(r=e,tn).call(r,t)}}}get max(){return V(this,Nn)}get maxSize(){return V(this,Jr)}get calculatedSize(){return V(this,xn)}get size(){return V(this,nr)}get fetchMethod(){return V(this,us)}get dispose(){return V(this,wn)}get disposeAfter(){return V(this,Dn)}getRemainingTTL(e){return V(this,ir).has(e)?1/0:0}*entries(){for(const e of Ve(this,qn,Bi).call(this))V(this,it)[e]!==void 0&&V(this,Mt)[e]!==void 0&&!Ve(this,xt,Ft).call(this,V(this,it)[e])&&(yield[V(this,Mt)[e],V(this,it)[e]])}*rentries(){for(const e of Ve(this,Vn,Ui).call(this))V(this,it)[e]!==void 0&&V(this,Mt)[e]!==void 0&&!Ve(this,xt,Ft).call(this,V(this,it)[e])&&(yield[V(this,Mt)[e],V(this,it)[e]])}*keys(){for(const e of Ve(this,qn,Bi).call(this)){const t=V(this,Mt)[e];t!==void 0&&!Ve(this,xt,Ft).call(this,V(this,it)[e])&&(yield t)}}*rkeys(){for(const e of Ve(this,Vn,Ui).call(this)){const t=V(this,Mt)[e];t!==void 0&&!Ve(this,xt,Ft).call(this,V(this,it)[e])&&(yield t)}}*values(){for(const e of Ve(this,qn,Bi).call(this))V(this,it)[e]!==void 0&&!Ve(this,xt,Ft).call(this,V(this,it)[e])&&(yield V(this,it)[e])}*rvalues(){for(const e of Ve(this,Vn,Ui).call(this))V(this,it)[e]!==void 0&&!Ve(this,xt,Ft).call(this,V(this,it)[e])&&(yield V(this,it)[e])}[Symbol.iterator](){return this.entries()}find(e,t={}){for(const r of Ve(this,qn,Bi).call(this)){const i=V(this,it)[r],s=Ve(this,xt,Ft).call(this,i)?i.__staleWhileFetching:i;if(s!==void 0&&e(s,V(this,Mt)[r],this))return this.get(V(this,Mt)[r],t)}}forEach(e,t=this){for(const r of Ve(this,qn,Bi).call(this)){const i=V(this,it)[r],s=Ve(this,xt,Ft).call(this,i)?i.__staleWhileFetching:i;s!==void 0&&e.call(t,s,V(this,Mt)[r],this)}}rforEach(e,t=this){for(const r of Ve(this,Vn,Ui).call(this)){const i=V(this,it)[r],s=Ve(this,xt,Ft).call(this,i)?i.__staleWhileFetching:i;s!==void 0&&e.call(t,s,V(this,Mt)[r],this)}}purgeStale(){let e=!1;for(const t of Ve(this,Vn,Ui).call(this,{allowStale:!0}))V(this,tn).call(this,t)&&(this.delete(V(this,Mt)[t]),e=!0);return e}dump(){const e=[];for(const t of Ve(this,qn,Bi).call(this,{allowStale:!0})){const r=V(this,Mt)[t],i=V(this,it)[t],s=Ve(this,xt,Ft).call(this,i)?i.__staleWhileFetching:i;if(s===void 0||r===void 0)continue;const a={value:s};if(V(this,Ln)&&V(this,_i)){a.ttl=V(this,Ln)[t];const o=lo.now()-V(this,_i)[t];a.start=Math.floor(Date.now()-o)}V(this,gi)&&(a.size=V(this,gi)[t]),e.unshift([r,a])}return e}load(e){this.clear();for(const[t,r]of e){if(r.start){const i=Date.now()-r.start;r.start=lo.now()-i}this.set(t,r.value,r)}}set(e,t,r={}){var m,_,T,I,R;if(t===void 0)return this.delete(e),this;const{ttl:i=this.ttl,start:s,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:o=this.sizeCalculation,status:l}=r;let{noUpdateTTL:c=this.noUpdateTTL}=r;const u=V(this,jo).call(this,e,t,r.size||0,o);if(this.maxEntrySize&&u>this.maxEntrySize)return l&&(l.set="miss",l.maxEntrySizeExceeded=!0),this.delete(e),this;let p=V(this,nr)===0?void 0:V(this,ir).get(e);if(p===void 0)p=V(this,nr)===0?V(this,dr):V(this,kn).length!==0?V(this,kn).pop():V(this,nr)===V(this,Nn)?Ve(this,ps,tc).call(this,!1):V(this,nr),V(this,Mt)[p]=e,V(this,it)[p]=t,V(this,ir).set(e,p),V(this,xr)[V(this,dr)]=p,V(this,en)[p]=V(this,dr),Xe(this,dr,p),ml(this,nr)._++,V(this,ds).call(this,p,u,l),l&&(l.set="add"),c=!1;else{Ve(this,ba,Oo).call(this,p);const L=V(this,it)[p];if(t!==L){if(V(this,Qi)&&Ve(this,xt,Ft).call(this,L)){L.__abortController.abort(new Error("replaced"));const{__staleWhileFetching:$}=L;$!==void 0&&!a&&(V(this,Mn)&&((m=V(this,wn))==null||m.call(this,$,e,"set")),V(this,kr)&&((_=V(this,pr))==null||_.push([$,e,"set"])))}else a||(V(this,Mn)&&((T=V(this,wn))==null||T.call(this,L,e,"set")),V(this,kr)&&((I=V(this,pr))==null||I.push([L,e,"set"])));if(V(this,Ea).call(this,p),V(this,ds).call(this,p,u,l),V(this,it)[p]=t,l){l.set="replace";const $=L&&Ve(this,xt,Ft).call(this,L)?L.__staleWhileFetching:L;$!==void 0&&(l.oldValue=$)}}else l&&(l.set="update")}if(i!==0&&!V(this,Ln)&&Ve(this,Zo,Zm).call(this),V(this,Ln)&&(c||V(this,Ko).call(this,p,i,s),l&&V(this,Si).call(this,l,p)),!a&&V(this,kr)&&V(this,pr)){const L=V(this,pr);let $;for(;$=L==null?void 0:L.shift();)(R=V(this,Dn))==null||R.call(this,...$)}return this}pop(){var e;try{for(;V(this,nr);){const t=V(this,it)[V(this,Tr)];if(Ve(this,ps,tc).call(this,!0),Ve(this,xt,Ft).call(this,t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(V(this,kr)&&V(this,pr)){const t=V(this,pr);let r;for(;r=t==null?void 0:t.shift();)(e=V(this,Dn))==null||e.call(this,...r)}}}has(e,t={}){const{updateAgeOnHas:r=this.updateAgeOnHas,status:i}=t,s=V(this,ir).get(e);if(s!==void 0){const a=V(this,it)[s];if(Ve(this,xt,Ft).call(this,a)&&a.__staleWhileFetching===void 0)return!1;if(V(this,tn).call(this,s))i&&(i.has="stale",V(this,Si).call(this,i,s));else return r&&V(this,Oa).call(this,s),i&&(i.has="hit",V(this,Si).call(this,i,s)),!0}else i&&(i.has="miss");return!1}peek(e,t={}){const{allowStale:r=this.allowStale}=t,i=V(this,ir).get(e);if(i!==void 0&&(r||!V(this,tn).call(this,i))){const s=V(this,it)[i];return Ve(this,xt,Ft).call(this,s)?s.__staleWhileFetching:s}}async fetch(e,t={}){const{allowStale:r=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:o=this.noDisposeOnSet,size:l=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:u=this.noUpdateTTL,noDeleteOnFetchRejection:p=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:m=this.allowStaleOnFetchRejection,ignoreFetchAbort:_=this.ignoreFetchAbort,allowStaleOnFetchAbort:T=this.allowStaleOnFetchAbort,context:I,forceRefresh:R=!1,status:L,signal:$}=t;if(!V(this,Qi))return L&&(L.fetch="get"),this.get(e,{allowStale:r,updateAgeOnGet:i,noDeleteOnStaleGet:s,status:L});const K={allowStale:r,updateAgeOnGet:i,noDeleteOnStaleGet:s,ttl:a,noDisposeOnSet:o,size:l,sizeCalculation:c,noUpdateTTL:u,noDeleteOnFetchRejection:p,allowStaleOnFetchRejection:m,allowStaleOnFetchAbort:T,ignoreFetchAbort:_,status:L,signal:$};let f=V(this,ir).get(e);if(f===void 0){L&&(L.fetch="miss");const E=Ve(this,hs,rc).call(this,e,f,K,I);return E.__returned=E}else{const E=V(this,it)[f];if(Ve(this,xt,Ft).call(this,E)){const M=r&&E.__staleWhileFetching!==void 0;return L&&(L.fetch="inflight",M&&(L.returnedStale=!0)),M?E.__staleWhileFetching:E.__returned=E}const S=V(this,tn).call(this,f);if(!R&&!S)return L&&(L.fetch="hit"),Ve(this,ba,Oo).call(this,f),i&&V(this,Oa).call(this,f),L&&V(this,Si).call(this,L,f),E;const N=Ve(this,hs,rc).call(this,e,f,K,I),x=N.__staleWhileFetching!==void 0&&r;return L&&(L.fetch=S?"stale":"refresh",x&&S&&(L.returnedStale=!0)),x?N.__staleWhileFetching:N.__returned=N}}get(e,t={}){const{allowStale:r=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,status:a}=t,o=V(this,ir).get(e);if(o!==void 0){const l=V(this,it)[o],c=Ve(this,xt,Ft).call(this,l);return a&&V(this,Si).call(this,a,o),V(this,tn).call(this,o)?(a&&(a.get="stale"),c?(a&&r&&l.__staleWhileFetching!==void 0&&(a.returnedStale=!0),r?l.__staleWhileFetching:void 0):(s||this.delete(e),a&&r&&(a.returnedStale=!0),r?l:void 0)):(a&&(a.get="hit"),c?l.__staleWhileFetching:(Ve(this,ba,Oo).call(this,o),i&&V(this,Oa).call(this,o),l))}else a&&(a.get="miss")}delete(e){var r,i,s,a;let t=!1;if(V(this,nr)!==0){const o=V(this,ir).get(e);if(o!==void 0)if(t=!0,V(this,nr)===1)this.clear();else{V(this,Ea).call(this,o);const l=V(this,it)[o];Ve(this,xt,Ft).call(this,l)?l.__abortController.abort(new Error("deleted")):(V(this,Mn)||V(this,kr))&&(V(this,Mn)&&((r=V(this,wn))==null||r.call(this,l,e,"delete")),V(this,kr)&&((i=V(this,pr))==null||i.push([l,e,"delete"]))),V(this,ir).delete(e),V(this,Mt)[o]=void 0,V(this,it)[o]=void 0,o===V(this,dr)?Xe(this,dr,V(this,en)[o]):o===V(this,Tr)?Xe(this,Tr,V(this,xr)[o]):(V(this,xr)[V(this,en)[o]]=V(this,xr)[o],V(this,en)[V(this,xr)[o]]=V(this,en)[o]),ml(this,nr)._--,V(this,kn).push(o)}}if(V(this,kr)&&((s=V(this,pr))!=null&&s.length)){const o=V(this,pr);let l;for(;l=o==null?void 0:o.shift();)(a=V(this,Dn))==null||a.call(this,...l)}return t}clear(){var e,t,r;for(const i of Ve(this,Vn,Ui).call(this,{allowStale:!0})){const s=V(this,it)[i];if(Ve(this,xt,Ft).call(this,s))s.__abortController.abort(new Error("deleted"));else{const a=V(this,Mt)[i];V(this,Mn)&&((e=V(this,wn))==null||e.call(this,s,a,"delete")),V(this,kr)&&((t=V(this,pr))==null||t.push([s,a,"delete"]))}}if(V(this,ir).clear(),V(this,it).fill(void 0),V(this,Mt).fill(void 0),V(this,Ln)&&V(this,_i)&&(V(this,Ln).fill(0),V(this,_i).fill(0)),V(this,gi)&&V(this,gi).fill(0),Xe(this,Tr,0),Xe(this,dr,0),V(this,kn).length=0,Xe(this,xn,0),Xe(this,nr,0),V(this,kr)&&V(this,pr)){const i=V(this,pr);let s;for(;s=i==null?void 0:i.shift();)(r=V(this,Dn))==null||r.call(this,...s)}}};Nn=new WeakMap,Jr=new WeakMap,wn=new WeakMap,Dn=new WeakMap,us=new WeakMap,nr=new WeakMap,xn=new WeakMap,ir=new WeakMap,Mt=new WeakMap,it=new WeakMap,xr=new WeakMap,en=new WeakMap,Tr=new WeakMap,dr=new WeakMap,kn=new WeakMap,pr=new WeakMap,gi=new WeakMap,_i=new WeakMap,Ln=new WeakMap,Mn=new WeakMap,Qi=new WeakMap,kr=new WeakMap,Zo=new WeakSet,Zm=function(){const e=new ec(V(this,Nn)),t=new ec(V(this,Nn));Xe(this,Ln,e),Xe(this,_i,t),Xe(this,Ko,(s,a,o=lo.now())=>{if(t[s]=a!==0?o:0,e[s]=a,a!==0&&this.ttlAutopurge){const l=setTimeout(()=>{V(this,tn).call(this,s)&&this.delete(V(this,Mt)[s])},a+1);l.unref&&l.unref()}}),Xe(this,Oa,s=>{t[s]=e[s]!==0?lo.now():0}),Xe(this,Si,(s,a)=>{if(e[a]){const o=e[a],l=t[a];s.ttl=o,s.start=l,s.now=r||i();const c=s.now-l;s.remainingTTL=o-c}});let r=0;const i=()=>{const s=lo.now();if(this.ttlResolution>0){r=s;const a=setTimeout(()=>r=0,this.ttlResolution);a.unref&&a.unref()}return s};this.getRemainingTTL=s=>{const a=V(this,ir).get(s);if(a===void 0)return 0;const o=e[a],l=t[a];if(o===0||l===0)return 1/0;const c=(r||i())-l;return o-c},Xe(this,tn,s=>e[s]!==0&&t[s]!==0&&(r||i())-t[s]>e[s])},Oa=new WeakMap,Si=new WeakMap,Ko=new WeakMap,tn=new WeakMap,Gc=new WeakSet,MI=function(){const e=new ec(V(this,Nn));Xe(this,xn,0),Xe(this,gi,e),Xe(this,Ea,t=>{Xe(this,xn,V(this,xn)-e[t]),e[t]=0}),Xe(this,jo,(t,r,i,s)=>{if(Ve(this,xt,Ft).call(this,r))return 0;if(!Pi(i))if(s){if(typeof s!="function")throw new TypeError("sizeCalculation must be a function");if(i=s(r,t),!Pi(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return i}),Xe(this,ds,(t,r,i)=>{if(e[t]=r,V(this,Jr)){const s=V(this,Jr)-e[t];for(;V(this,xn)>s;)Ve(this,ps,tc).call(this,!0)}Xe(this,xn,V(this,xn)+e[t]),i&&(i.entrySize=r,i.totalCalculatedSize=V(this,xn))})},Ea=new WeakMap,ds=new WeakMap,jo=new WeakMap,qn=new WeakSet,Bi=function*({allowStale:e=this.allowStale}={}){if(V(this,nr))for(let t=V(this,dr);!(!Ve(this,Jo,Km).call(this,t)||((e||!V(this,tn).call(this,t))&&(yield t),t===V(this,Tr)));)t=V(this,en)[t]},Vn=new WeakSet,Ui=function*({allowStale:e=this.allowStale}={}){if(V(this,nr))for(let t=V(this,Tr);!(!Ve(this,Jo,Km).call(this,t)||((e||!V(this,tn).call(this,t))&&(yield t),t===V(this,dr)));)t=V(this,xr)[t]},Jo=new WeakSet,Km=function(e){return e!==void 0&&V(this,ir).get(V(this,Mt)[e])===e},ps=new WeakSet,tc=function(e){var s,a;const t=V(this,Tr),r=V(this,Mt)[t],i=V(this,it)[t];return V(this,Qi)&&Ve(this,xt,Ft).call(this,i)?i.__abortController.abort(new Error("evicted")):(V(this,Mn)||V(this,kr))&&(V(this,Mn)&&((s=V(this,wn))==null||s.call(this,i,r,"evict")),V(this,kr)&&((a=V(this,pr))==null||a.push([i,r,"evict"]))),V(this,Ea).call(this,t),e&&(V(this,Mt)[t]=void 0,V(this,it)[t]=void 0,V(this,kn).push(t)),V(this,nr)===1?(Xe(this,Tr,Xe(this,dr,0)),V(this,kn).length=0):Xe(this,Tr,V(this,xr)[t]),V(this,ir).delete(r),ml(this,nr)._--,t},hs=new WeakSet,rc=function(e,t,r,i){const s=t===void 0?void 0:V(this,it)[t];if(Ve(this,xt,Ft).call(this,s))return s;const a=new Bc,{signal:o}=r;o==null||o.addEventListener("abort",()=>a.abort(o.reason),{signal:a.signal});const l={signal:a.signal,options:r,context:i},c=(I,R=!1)=>{const{aborted:L}=a.signal,$=r.ignoreFetchAbort&&I!==void 0;if(r.status&&(L&&!R?(r.status.fetchAborted=!0,r.status.fetchError=a.signal.reason,$&&(r.status.fetchAbortIgnored=!0)):r.status.fetchResolved=!0),L&&!$&&!R)return p(a.signal.reason);const K=_;return V(this,it)[t]===_&&(I===void 0?K.__staleWhileFetching?V(this,it)[t]=K.__staleWhileFetching:this.delete(e):(r.status&&(r.status.fetchUpdated=!0),this.set(e,I,l.options))),I},u=I=>(r.status&&(r.status.fetchRejected=!0,r.status.fetchError=I),p(I)),p=I=>{const{aborted:R}=a.signal,L=R&&r.allowStaleOnFetchAbort,$=L||r.allowStaleOnFetchRejection,K=$||r.noDeleteOnFetchRejection,f=_;if(V(this,it)[t]===_&&(!K||f.__staleWhileFetching===void 0?this.delete(e):L||(V(this,it)[t]=f.__staleWhileFetching)),$)return r.status&&f.__staleWhileFetching!==void 0&&(r.status.returnedStale=!0),f.__staleWhileFetching;if(f.__returned===f)throw I},m=(I,R)=>{var $;const L=($=V(this,us))==null?void 0:$.call(this,e,s,l);L&&L instanceof Promise&&L.then(K=>I(K===void 0?void 0:K),R),a.signal.addEventListener("abort",()=>{(!r.ignoreFetchAbort||r.allowStaleOnFetchAbort)&&(I(void 0),r.allowStaleOnFetchAbort&&(I=K=>c(K,!0)))})};r.status&&(r.status.fetchDispatched=!0);const _=new Promise(m).then(c,u),T=Object.assign(_,{__abortController:a,__staleWhileFetching:s,__returned:void 0});return t===void 0?(this.set(e,T,{...l.options,status:void 0}),t=V(this,ir).get(e)):V(this,it)[t]=T,T},xt=new WeakSet,Ft=function(e){if(!V(this,Qi))return!1;const t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof Bc},el=new WeakSet,jm=function(e,t){V(this,en)[t]=e,V(this,xr)[e]=t},ba=new WeakSet,Oo=function(e){e!==V(this,dr)&&(e===V(this,Tr)?Xe(this,Tr,V(this,xr)[e]):Ve(this,el,jm).call(this,V(this,en)[e],V(this,xr)[e]),Ve(this,el,jm).call(this,V(this,dr),e),Xe(this,dr,e))};let Xm=g_;const Ro=class Ro{constructor(){b(this,"_fallbackMethod",()=>Ro.createSkipProxy());b(this,"out",()=>{})}};b(Ro,"createSkipProxy",()=>{const e=new Ro;return new Proxy(e,{get(t,r,i){return typeof t[r]>"u"?t._fallbackMethod:t[r]},set(t,r,i,s){return!1}})});let Uc=Ro;const No=class No extends i_{constructor(t,r){super(r);b(this,"_fallbackMethod",()=>No.createRestProxy(this.values.length,this.app));b(this,"out",()=>{});this.values.length=t}};b(No,"createRestProxy",(t,r)=>{const i=new No(t,r);return new Proxy(i,{get(s,a,o){return typeof s[a]>"u"?s._fallbackMethod:s[a]},set(s,a,o,l){return!1}})});let Fc=No;class oB extends i_{constructor(t,r,i){super(i);b(this,"input");b(this,"ziffers");b(this,"initCallTime",0);b(this,"startCallTime",0);b(this,"lastCallTime",0);b(this,"waitTime",0);b(this,"startBeat",0);b(this,"played",!1);b(this,"current");b(this,"retro",!1);b(this,"index",-1);b(this,"zid","");b(this,"options",{});b(this,"skipIndex",0);b(this,"endTime",0);b(this,"next",()=>(this.current=this.ziffers.next(),this.played=!0,this.current));b(this,"pulseToSecond",t=>this.app.clock.convertPulseToSecond(t));b(this,"firstRun",()=>this.notStarted());b(this,"atTheBeginning",()=>this.skipIndex===0&&this.ziffers.index<=0);b(this,"origin",()=>this.app.clock.pulses_since_origin+1);b(this,"pulse",()=>this.app.clock.time_position.pulse);b(this,"beat",()=>this.app.clock.time_position.beat);b(this,"nextBeat",()=>this.app.clock.next_beat_in_ticks);b(this,"nextBeatInTicks",()=>this.app.clock.next_beat_in_ticks);b(this,"areWeThereYet",()=>{this.app.clock.pulses_since_origin=this.nextBeatInTicks())&&this.origin()>=this.waitTime,r=this.current&&this.pulseToSecond(this.origin())>=this.pulseToSecond(this.lastCallTime)+this.pulseToSecond(this.current.duration*4*this.app.clock.ppqn)&&this.origin()>=this.waitTime,i=t||r;return this.skipIndex=i?0:this.skipIndex+1,this.index=i?this.index+1:this.index,i&&this.notStarted()&&(this.initCallTime=this.app.clock.pulses_since_origin),this.atTheBeginning()&&(this.startCallTime=this.app.clock.pulses_since_origin),i});b(this,"lead",()=>this.voiceleading());b(this,"invert",t=>(this.atTheBeginning()&&this.ziffers.invert(t),this));b(this,"out",()=>{});this.app=i,this.input=t,this.options=r,this.ziffers=new T3(t,r)}get ticks(){return this.ziffers.duration*4*this.app.clock.ppqn}nextEndTime(){return this.startCallTime+this.ticks}updateLastCallTime(){(this.notStarted()||this.played)&&(this.lastCallTime=this.app.clock.pulses_since_origin,this.played=!1)}notStarted(){return this.ziffers.notStarted()}sound(t){if(this.areWeThereYet()){const r=this.next(),i=this.app.clock.convertPulseToSecond(r.duration*4*this.app.clock.ppqn);if(r instanceof ti){const s=r.getExisting("freq","pitch","key","scale","octave","parsedScale");return r.sound&&(t=r.sound),r.soundIndex&&(s.n=r.soundIndex),s.dur=i,new Vm(s,this.app).sound(t||"sine")}else if(r instanceof Ra){const s=r.pitches.map(o=>o.getExisting("freq","pitch","key","scale","octave","parsedScale")),a={dur:i};return t&&(a.s=t),new Vm(a,this.app).chord(s)}else if(r instanceof $m)return Fc.createRestProxy(r.duration,this.app)}else return Uc.createSkipProxy()}midi(t=void 0){if(this.areWeThereYet()){const r=this.next(),i=r.getExisting("note","pitch","bend","key","scale","octave","parsedScale");if(r instanceof ti){r.soundIndex&&(i.channel=r.soundIndex);const s=new zm(i,this.app);return t?s.note(t):s}else{if(r instanceof $m)return Fc.createRestProxy(r.duration,this.app);if(r instanceof Ra){const s=r.midiChord();return new zm(i,this.app).chord(s)}}}else return Uc.createSkipProxy()}scale(t){return this.atTheBeginning()&&this.ziffers.scale(t),this}key(t){return this.atTheBeginning()&&this.ziffers.key(t),this}octave(t){return this.atTheBeginning()&&this.ziffers.octave(t),this}voiceleading(){return this.atTheBeginning()&&this.ziffers.lead(),this}retrograde(){return this.atTheBeginning()&&this.ziffers.retrograde(),this}wait(t){if(this.atTheBeginning()){if(typeof t=="function"){const r=this.app.api.patternCache.get(t.name);return r&&(this.waitTime=r.nextEndTime()),this}this.waitTime=this.origin()+Math.ceil(t*4*this.app.clock.ppqn)}return this}sync(t){if(this.atTheBeginning()&&this.notStarted()){const r=this.app.clock.pulses_since_origin,i=typeof t=="function"?t.name:t;if(r>0){const s=this.app.api.patternCache.get(i);if(s){const a=s.ziffers.duration,o=s.startCallTime,l=a*4*this.app.clock.ppqn;this.waitTime=o+l}}}return this}}const lB=n=>n[0]==="{"&&n[n.length-1]==="}",co=(n,e)=>{if(lB(n)){const t=JSON.parse(n);return JSON.stringify({...t,...e})}else return JSON.stringify({...e,text:n})},cB=n=>{String.prototype.speak=function(){const e=JSON.parse(this.valueOf());new PI({...e,text:e.text}).speak().then(()=>{}).catch(t=>{console.log("Error speaking:",t)})},String.prototype.rate=function(e){return co(this.valueOf(),{rate:e})},String.prototype.pitch=function(e){return co(this.valueOf(),{pitch:e})},String.prototype.lang=function(e){return co(this.valueOf(),{lang:e})},String.prototype.volume=function(e){return co(this.valueOf(),{volume:e})},String.prototype.voice=function(e){return co(this.valueOf(),{voice:e})},String.prototype.z=function(e={}){return n.z(this.valueOf(),e)},String.prototype.z0=function(e={}){return n.z0(this.valueOf(),e)},String.prototype.z1=function(e={}){return n.z1(this.valueOf(),e)},String.prototype.z2=function(e={}){return n.z2(this.valueOf(),e)},String.prototype.z3=function(e={}){return n.z3(this.valueOf(),e)},String.prototype.z4=function(e={}){return n.z4(this.valueOf(),e)},String.prototype.z5=function(e={}){return n.z5(this.valueOf(),e)},String.prototype.z6=function(e={}){return n.z6(this.valueOf(),e)},String.prototype.z7=function(e={}){return n.z7(this.valueOf(),e)},String.prototype.z8=function(e={}){return n.z8(this.valueOf(),e)},String.prototype.z9=function(e={}){return n.z9(this.valueOf(),e)},String.prototype.z10=function(e={}){return n.z10(this.valueOf(),e)},String.prototype.z11=function(e={}){return n.z11(this.valueOf(),e)},String.prototype.z12=function(e={}){return n.z12(this.valueOf(),e)},String.prototype.z13=function(e={}){return n.z13(this.valueOf(),e)},String.prototype.z14=function(e={}){return n.z14(this.valueOf(),e)},String.prototype.z15=function(e={}){return n.z15(this.valueOf(),e)},String.prototype.z16=function(e={}){return n.z16(this.valueOf(),e)},String.prototype.note=function(){try{return parseInt(this.valueOf())}catch{return oi(this.valueOf())}}};let rd;class PI{constructor(e){b(this,"speak",()=>new Promise((e,t)=>{if(this.options.text){const r=window.speechSynthesis;r.speaking&&r.cancel();const i=new SpeechSynthesisUtterance(this.options.text);i.rate=this.options.rate||1,i.pitch=this.options.pitch||1,i.volume=this.options.volume||1,this.options.voice&&(i.voice=r.getVoices()[this.options.voice]),this.options.lang&&(this.options.lang.length===2?i.lang=`${this.options.lang}-${this.options.lang.toUpperCase()}`:this.options.lang.length===5?i.lang=this.options.lang:i.lang="en-US"),i.onend=()=>{e()},i.onerror=s=>{t(s)},r.speaking?(r.cancel(),rd&&clearTimeout(rd),rd=setTimeout(()=>{r.speak(i)},200)):r.speak(i)}else t("No text provided")}));this.options=e}}async function vE(){return Promise.all([Y3(),$i("github:tidalcycles/Dirt-Samples/master").then(()=>eB()),aB(),$i("github:Bubobubobubobubo/Dough-Fox/main"),$i("github:Bubobubobubobubo/Dough-Samples/main"),$i("github:Bubobubobubobubo/Dough-Amiga/main"),$i("github:Bubobubobubobubo/Dough-Amen/main"),$i("github:Bubobubobubobubo/Dough-Waveforms/main")])}class uB{constructor(e){b(this,"variables",{});b(this,"codeExamples",{});b(this,"counters",{});b(this,"_drunk",new A3(-100,100,!1));b(this,"randomGen",Math.random);b(this,"currentSeed");b(this,"localSeeds",new Map);b(this,"patternCache",new Xm({max:1e3,ttl:1e3*60*5}));b(this,"errorTimeoutID",0);b(this,"printTimeoutID",0);b(this,"MidiConnection");b(this,"load");b(this,"_loadUniverseFromInterface",e=>{this.app.loadUniverse(e),this.app.openBuffersModal()});b(this,"_deleteUniverseFromInterface",e=>{delete this.app.universes[e],this.app.settings.saveApplicationToLocalStorage(this.app.universes,this.app.settings),this.app.updateKnownUniversesView()});b(this,"_playDocExample",e=>{let t=this.app.universes[this.app.selected_universe];this.app.exampleIsPlaying=!0,t.example?t.example.candidate=e||this.app.selectedExample:(t.example={candidate:"",committed:"",evaluations:0},t.example.candidate=e||this.app.selectedExample),this.play()});b(this,"_stopDocExample",()=>{let e=this.app.universes[this.app.selected_universe];(e==null?void 0:e.example)!==void 0&&(this.app.exampleIsPlaying=!1,e.example.candidate="",e.example.committed=""),this.pause()});b(this,"_playDocExampleOnce",e=>{let t=this.app.universes[this.app.selected_universe];(t==null?void 0:t.example)!==void 0&&(t.example.candidate="",t.example.committed=""),this.play(),this.app.exampleIsPlaying=!0,xP(this.app,e)});b(this,"_all_samples",()=>a_.get());b(this,"_reportError",e=>{console.log(e),clearTimeout(this.errorTimeoutID),clearTimeout(this.printTimeoutID),this.app.error_line.innerHTML=e,this.app.error_line.style.color="color-red-800",this.app.error_line.classList.remove("hidden"),this.errorTimeoutID=setTimeout(()=>this.app.error_line.classList.add("hidden"),2e3)});b(this,"_logMessage",e=>{console.log(e),clearTimeout(this.printTimeoutID),clearTimeout(this.errorTimeoutID),this.app.error_line.innerHTML=e,this.app.error_line.style.color="white",this.app.error_line.classList.remove("hidden"),this.printTimeoutID=setTimeout(()=>this.app.error_line.classList.add("hidden"),4e3)});b(this,"time",()=>this.app.audioContext.currentTime);b(this,"play",()=>{this.app.setButtonHighlighting("play",!0),this.MidiConnection.sendStartMessage(),this.app.clock.start()});b(this,"pause",()=>{this.app.setButtonHighlighting("pause",!0),this.MidiConnection.sendStopMessage(),this.app.clock.pause()});b(this,"stop",()=>{this.app.setButtonHighlighting("stop",!0),this.MidiConnection.sendStopMessage(),this.app.clock.stop()});b(this,"silence",this.stop);b(this,"hush",this.stop);b(this,"warp",e=>{this.app.clock.tick=e,this.app.clock.time_position=this.app.clock.convertTicksToTimeposition(e)});b(this,"beat_warp",e=>{this.app.clock.tick=e*this.app.clock.ppqn,this.app.clock.time_position=this.app.clock.convertTicksToTimeposition(e*this.app.clock.ppqn)});b(this,"onmousemove",e=>{this.app._mouseX=e.pageX,this.app._mouseY=e.pageY});b(this,"mouseX",()=>this.app._mouseX);b(this,"mouseY",()=>this.app._mouseY);b(this,"noteX",()=>Math.floor(this.app._mouseX/document.body.clientWidth*127));b(this,"noteY",()=>Math.floor(this.app._mouseY/document.body.clientHeight*127));b(this,"script",(...e)=>{e.forEach(t=>{ls(this.app,this.app.universes[this.app.selected_universe].locals[t])})});b(this,"s",this.script);b(this,"delete_script",e=>{this.app.universes[this.app.selected_universe].locals[e]={candidate:"",committed:"",evaluations:0}});b(this,"cs",this.delete_script);b(this,"copy_script",(e,t)=>{this.app.universes[this.app.selected_universe].locals[t]={...this.app.universes[this.app.selected_universe].locals[e]}});b(this,"cps",this.copy_script);b(this,"copy_universe",(e,t)=>{this.app.universes[t]={...this.app.universes[e]}});b(this,"delete_universe",e=>{this.app.selected_universe===e&&(this.app.selected_universe="Default"),delete this.app.universes[e],this.app.settings.saveApplicationToLocalStorage(this.app.universes,this.app.settings),this.app.updateKnownUniversesView()});b(this,"big_bang",()=>{confirm("Are you sure you want to delete all universes?")&&(this.app.universes={...Ao},this.app.settings.saveApplicationToLocalStorage(this.app.universes,this.app.settings)),this.app.selected_universe="Default",this.app.updateKnownUniversesView()});b(this,"midi_outputs",()=>{this._logMessage(this.MidiConnection.listMidiOutputs())});b(this,"midi_output",e=>{e?this.MidiConnection.switchMidiOutput(e):console.log(this.MidiConnection.getCurrentMidiPort())});b(this,"midi",(e=60,t,r)=>(t!==void 0&&(typeof e=="number"&&(e={note:e}),e.velocity=t),r!==void 0&&(typeof e=="number"&&(e={note:e}),e.channel=r),new zm(e,this.app)));b(this,"sysex",e=>{this.MidiConnection.sendSysExMessage(e)});b(this,"pitch_bend",(e,t)=>{this.MidiConnection.sendPitchBend(e,t)});b(this,"program_change",(e,t)=>{this.MidiConnection.sendProgramChange(e,t)});b(this,"midi_clock",()=>{this.MidiConnection.sendMidiClock()});b(this,"control_change",({control:e=20,value:t=0,channel:r=0})=>{this.MidiConnection.sendMidiControlChange(e,t,r)});b(this,"midi_panic",()=>{this.MidiConnection.panic()});b(this,"active_note_events",e=>{let t;if(e?t=this.MidiConnection.activeNotesFromChannel(e):t=this.MidiConnection.activeNotes,t.length>0)return t});b(this,"active_notes",e=>{const t=this.active_note_events(e);if(t&&t.length>0)return t.map(r=>r.note)});b(this,"kill_active_notes",()=>{this.MidiConnection.activeNotes=[]});b(this,"sticky_notes",e=>{let t;if(e?t=this.MidiConnection.stickyNotesFromChannel(e):t=this.MidiConnection.stickyNotes,t.length>0)return t.map(r=>r.note)});b(this,"kill_sticky_notes",()=>{this.MidiConnection.stickyNotes=[]});b(this,"buffer",e=>e?this.MidiConnection.findNoteFromBufferInChannel(e)!==void 0:this.MidiConnection.noteInputBuffer.length>0);b(this,"buffer_event",e=>e?this.MidiConnection.findNoteFromBufferInChannel(e):this.MidiConnection.noteInputBuffer.shift());b(this,"buffer_note",e=>{const t=this.buffer_event(e);return t?t.note:void 0});b(this,"last_note_event",e=>e?this.MidiConnection.lastNoteInChannel[e]:this.MidiConnection.lastNote);b(this,"last_note",e=>{const t=this.last_note_event(e);return t?t.note:60});b(this,"last_cc",(e,t)=>t?this.MidiConnection.lastCCInChannel[t]?this.MidiConnection.lastCCInChannel[t][e]:64:this.MidiConnection.lastCC[e]||64);b(this,"has_cc",e=>e?this.MidiConnection.findCCFromBufferInChannel(e)!==void 0:this.MidiConnection.ccInputBuffer.length>0);b(this,"buffer_cc",e=>e?this.MidiConnection.findCCFromBufferInChannel(e):this.MidiConnection.ccInputBuffer.shift());b(this,"generateCacheKey",(...e)=>e.map(t=>JSON.stringify(t)).join(","));b(this,"z",(e,t={},r="")=>{const i="z"+r.toString(),s=r===""?this.generateCacheKey(e,t):i;let a;return this.app.api.patternCache.has(s)&&(a=this.app.api.patternCache.get(s),a.input!==e&&(a=void 0)),a||(a=new oB(e,t,this.app),this.app.api.patternCache.set(s,a)),typeof r=="number"&&(a.zid=i),a.updateLastCallTime(),r!==""&&a.sync("z0"),a});b(this,"z0",(e,t={})=>this.z(e,t,0));b(this,"z1",(e,t={})=>this.z(e,t,1));b(this,"z2",(e,t={})=>this.z(e,t,2));b(this,"z3",(e,t={})=>this.z(e,t,3));b(this,"z4",(e,t={})=>this.z(e,t,4));b(this,"z5",(e,t={})=>this.z(e,t,5));b(this,"z6",(e,t={})=>this.z(e,t,6));b(this,"z7",(e,t={})=>this.z(e,t,7));b(this,"z8",(e,t={})=>this.z(e,t,8));b(this,"z9",(e,t={})=>this.z(e,t,9));b(this,"z10",(e,t={})=>this.z(e,t,10));b(this,"z11",(e,t={})=>this.z(e,t,11));b(this,"z12",(e,t={})=>this.z(e,t,12));b(this,"z13",(e,t={})=>this.z(e,t,13));b(this,"z14",(e,t={})=>this.z(e,t,14));b(this,"z15",(e,t={})=>this.z(e,t,15));b(this,"z16",(e,t={})=>this.z(e,t,16));b(this,"counter",(e,t,r)=>(e in this.counters?(this.counters[e].limit!==t&&(this.counters[e].value=0,this.counters[e].limit=t),this.counters[e].step!==r&&(this.counters[e].step=r??this.counters[e].step),this.counters[e].value+=this.counters[e].step,this.counters[e].limit!==void 0&&this.counters[e].value>this.counters[e].limit&&(this.counters[e].value=0)):this.counters[e]={value:0,step:r??1,limit:t},this.counters[e].value));b(this,"$",this.counter);b(this,"i",e=>e!==void 0?(this.app.universes[this.app.selected_universe].global.evaluations=e,this.app.universes[this.app.selected_universe]):this.app.universes[this.app.selected_universe].global.evaluations);b(this,"drunk",e=>e!==void 0?(this._drunk.position=e,this._drunk.getPosition()):(this._drunk.step(),this._drunk.getPosition()));b(this,"drunk_max",e=>{this._drunk.max=e});b(this,"drunk_min",e=>{this._drunk.min=e});b(this,"drunk_wrap",e=>{this._drunk.toggleWrap(e)});b(this,"variable",(e,t)=>typeof e=="string"&&t===void 0?this.variables[e]:(this.variables[e]=t,this.variables[e]));b(this,"v",this.variable);b(this,"delete_variable",e=>{delete this.variables[e]});b(this,"dv",this.delete_variable);b(this,"clear_variables",()=>{this.variables={}});b(this,"cv",this.clear_variables);b(this,"randI",(e,t)=>Math.floor(this.randomGen()*(t-e+1))+e);b(this,"rand",(e,t)=>this.randomGen()*(t-e)+e);b(this,"irand",this.randI);b(this,"rI",this.randI);b(this,"r",this.rand);b(this,"ir",this.randI);b(this,"seed",e=>{typeof e=="number"&&(e=e.toString()),this.currentSeed!==e&&(this.currentSeed=e,this.randomGen=Ym(e))});b(this,"localSeededRandom",e=>{if(typeof e=="number"&&(e=e.toString()),this.localSeeds.has(e))return this.localSeeds.get(e);const t=Ym(e);return this.localSeeds.set(e,t),t});b(this,"clearLocalSeed",(e=void 0)=>{e&&this.localSeeds.delete(e.toString()),this.localSeeds.clear()});b(this,"quantize",(e,t)=>{if(t.length===0)return e;let r=t[0];return t.forEach(i=>{Math.abs(i-e)Math.min(Math.max(e,t),r));b(this,"cmp",this.clamp);b(this,"nudge",e=>(e&&(this.app.clock.nudge=e),this.app.clock.nudge));b(this,"bpm",e=>e===void 0?this.app.clock.bpm:((e<1||e>500)&&console.log(`Setting bpm to ${e}`),this.app.clock.bpm=e,e));b(this,"tempo",this.bpm);b(this,"bpb",e=>e===void 0?this.app.clock.time_signature[0]:(e<1&&console.log(`Setting bpb to ${e}`),this.app.clock.time_signature[0]=e,e));b(this,"ppqn",e=>e===void 0?this.app.clock.ppqn:(e<1&&console.log(`Setting ppqn to ${e}`),this.app.clock.ppqn=e,e));b(this,"time_signature",(e,t)=>{this.app.clock.time_signature=[e,t]});b(this,"prob",e=>this.randomGen()*100this.randomGen()>.5);b(this,"odds",(e,t=1)=>this.randomGen()!1);b(this,"almostNever",(e=1)=>this.randomGen()<.025*this.ppqn()/(this.ppqn()*e));b(this,"rarely",(e=1)=>this.randomGen()<.1*this.ppqn()/(this.ppqn()*e));b(this,"scarcely",(e=1)=>this.randomGen()<.25*this.ppqn()/(this.ppqn()*e));b(this,"sometimes",(e=1)=>this.randomGen()<.5*this.ppqn()/(this.ppqn()*e));b(this,"often",(e=1)=>this.randomGen()<.75*this.ppqn()/(this.ppqn()*e));b(this,"frequently",(e=1)=>this.randomGen()<.9*this.ppqn()/(this.ppqn()*e));b(this,"almostAlways",(e=1)=>this.randomGen()<.985*this.ppqn()/(this.ppqn()*e));b(this,"always",(e=1)=>!0);b(this,"dice",e=>Math.floor(this.randomGen()*e)+1);b(this,"cbar",()=>this.app.clock.time_position.bar+1);b(this,"ctick",()=>this.app.clock.tick+1);b(this,"cpulse",()=>this.app.clock.time_position.pulse+1);b(this,"cbeat",()=>this.app.clock.time_position.beat+1);b(this,"ebeat",()=>this.app.clock.beats_since_origin+1);b(this,"epulse",()=>this.app.clock.pulses_since_origin+1);b(this,"nominator",()=>this.app.clock.time_signature[0]);b(this,"meter",()=>this.app.clock.time_signature[1]);b(this,"denominator",this.meter);b(this,"beat",(...e)=>e.map(r=>this.app.clock.pulses_since_origin%Math.floor(r*this.ppqn())===0).some(r=>r===!0));b(this,"b",this.beat);b(this,"pulse",(...e)=>e.map(r=>this.app.clock.pulses_since_origin%r===0).some(r=>r===!0));b(this,"flip",(e,t=50)=>{let r=e*2;const i=this.app.clock.pulses_since_origin,s=Math.floor(r*this.ppqn()),a=Math.floor(t/100*s);return i%s{let t=e*2;const r=this.app.clock.time_position.bar;return Math.floor(r/t)%2===0});b(this,"onbar",(e,t=this.app.clock.time_signature[0])=>{let r=this.app.clock.time_position.bar%t+1;return typeof e=="number"?e===r:e.some(i=>i==r)});b(this,"onbeat",(...e)=>{let t=[];return e.forEach(r=>{let i=r%this.nominator()||this.nominator(),s=Math.floor(i);s=s==0?this.nominator():s;let a=Math.floor((i-s)*this.ppqn()+1);a<=0&&(a=a+this.ppqn()*this.nominator()),t.push(s===this.cbeat()&&this.cpulse()===a)}),t.some(r=>r==!0)});b(this,"oncount",(e,t)=>{typeof e=="number"&&(e=[e]);const r=this.app.clock.pulses_since_origin;let i=[];return e.forEach(s=>{s=s<1?0:s-1;const a=Math.ceil(s*this.ppqn()),o=r%(this.ppqn()*t);return i.push(o===a)}),i.some(s=>s==!0)});b(this,"oneuclid",(e,t,r=0)=>{const s=this._euclidean_cycle(e,t,r).reduce((a,o,l)=>(o&&a.push(l+1),a),[]);return this.oncount(s,t)});b(this,"delay",(e,t)=>{setTimeout(t,e)});b(this,"delayr",(e,t,r)=>{[...Array(t).keys()].map(s=>e*s).forEach((s,a)=>{setTimeout(r,s)})});b(this,"euclid",(e,t,r,i=0)=>this._euclidean_cycle(t,r,i)[e%r]);b(this,"ec",this.euclid);b(this,"rhythm",(e,t,r,i=0)=>this.beat(e)&&this._euclidean_cycle(t,r,i).beat(e));b(this,"bin",(e,t)=>{let i=t.toString(2).split("").map(s=>s==="1");return i[e%i.length]});b(this,"binrhythm",(e,t)=>{let i=t.toString(2).split("").map(s=>s==="1");return this.beat(e)&&i.beat(e)});b(this,"line",(e,t,r=1)=>{const i=[];if(t>e&&r>0||tMath.sin(this.app.clock.ctx.currentTime*Math.PI*2*e)+t);b(this,"usine",(e=1,t=0)=>(this.sine(e,t)+1)/2);b(this,"saw",(e=1,t=0)=>this.app.clock.ctx.currentTime*e%1*2-1+t);b(this,"usaw",(e=1,t=0)=>(this.saw(e,t)+1)/2);b(this,"triangle",(e=1,t=0)=>Math.abs(this.saw(e,t))*2-1);b(this,"utriangle",(e=1,t=0)=>(this.triangle(e,t)+1)/2);b(this,"square",(e=1,t=0,r=.5)=>{const i=1/e;return(Date.now()/1e3+t)%i/i(this.square(e,t,r)+1)/2);b(this,"noise",()=>this.randomGen()*2-1);b(this,"min",(...e)=>Math.min(...e));b(this,"max",(...e)=>Math.max(...e));b(this,"mean",(...e)=>e.reduce((r,i)=>r+i,0)/e.length);b(this,"limit",(e,t,r)=>Math.min(Math.max(e,t),r));b(this,"abs",Math.abs);b(this,"speak",(e,t="en-US",r=0,i=1,s=1)=>{new PI({text:e,lang:t,voice:r,rate:i,pitch:s}).speak().then(()=>{}).catch(o=>{console.log(o)})});b(this,"stop_hydra",()=>{this.app.hydra.hush()});b(this,"sound",e=>new Vm(e,this.app));b(this,"snd",this.sound);b(this,"samples",$i);b(this,"log",e=>{console.log(e),this._logMessage(e)});b(this,"scale",n_);b(this,"rate",e=>{});b(this,"divseq",(...e)=>{const t=e[0],r=e.slice(1),i=this.app.clock.pulses_since_origin,s=Math.floor(i/Math.floor(t*this.ppqn()));return r[s%r.length]});b(this,"seqbeat",(...e)=>e[this.app.clock.time_position.beat%e.length]);b(this,"seqbar",(...e)=>e[(this.app.clock.time_position.bar+1)%e.length]);b(this,"shuffle",e=>e.sort(()=>this.randomGen()-.5));b(this,"reverse",e=>e.reverse());b(this,"rotate",e=>t=>t.slice(e,t.length).concat(t.slice(0,e)));b(this,"repeat",e=>t=>t.flatMap(r=>Array(e).fill(r)));b(this,"repeatOdd",e=>t=>t.flatMap((r,i)=>i%2===0?Array(e).fill(r):r));b(this,"repeatEven",e=>t=>t.flatMap((r,i)=>i%2!==0?Array(e).fill(r):r));b(this,"palindrome",e=>e.concat(e.slice(0,e.length-1).reverse()));this.app=e,this.MidiConnection=new y3(this,e.settings)}transmission(){return this.MidiConnection.activeNotes.length>0}_euclidean_cycle(e,t,r=0){if(e==t)return Array.from({length:t},()=>!0);function i(o,l){const c=o.length,u=(l+1)%c;return o[l]>o[u]}if(e>=t)return[!0];const s=Array.from({length:t},(o,l)=>(e*(l-1)%t+t)%t);let a=s.map((o,l)=>i(s,l));return r!=0&&(a=a.slice(r).concat(a.slice(0,r))),a}}const dB=n=>{Array.prototype.square=function(){return this.map(e=>e*e)},Array.prototype.sometimes=function(e){return n.randomGen()<.5?e(this):this},Array.prototype.apply=function(e){return e(this)},Array.prototype.sqrt=function(){if(this.some(e=>e<0))throw new Error("Cannot take square root of negative number");return this.map(e=>Math.sqrt(e))},Array.prototype.add=function(e){return this.map(t=>t+e)},Array.prototype.sub=function(e){return this.map(t=>t-e)},Array.prototype.mult=function(e){return this.map(t=>t*e)},Array.prototype.div=function(e){if(e===0)throw new Error("Division by zero");return this.map(t=>t/e)},Array.prototype.pick=function(){return this[Math.floor(n.randomGen()*this.length)]},Array.prototype.gen=function(e,t,r){return r<1?[]:Array.from({length:r},()=>Math.floor(n.randomGen()*(t-e+1))+e)},Array.prototype.bar=function(e=1){return e===1?this[n.app.clock.time_position.bar%this.length]:this[Math.floor(n.app.clock.time_position.bar/e)%this.length]},Array.prototype.beat=function(e=1){const t=e,r=n.app.clock.pulses_since_origin,i=Math.floor(r/Math.floor(t*n.ppqn()));return this[i%this.length]},Array.prototype.b=Array.prototype.beat,Array.prototype.shuffle=function(){let e=this.length,t;for(;e!==0;)t=Math.floor(n.randomGen()*e),e--,[this[e],this[t]]=[this[t],this[e]];return this},Array.prototype.rotate=function(e){const t=this.length;if(e<0)e=t+e%t;else if(e>0)e=e%t;else return this;const r=this.splice(-e,e);return this.unshift(...r),this},Array.prototype.unique=function(){const e=new Set;let t=0;for(let r=0;r100)throw new Error("Amount should be between 0 and 100");if(this.length<=1)return this;for(let t=0;t1)this.splice(t,1);else return this;else t++;return this},Array.prototype.repeat=function(e=1){if(e<1)throw new Error("Amount should be at least 1");let t=[];for(let r=0;r(i%s+s)%s,r=yI(cl(n));return this.map(i=>{const s=Math.floor(i/r.length)*12;return r[t(i,r.length)]+e+s})};Array.prototype.scaleArp=function(n="major",e=0){const t=yI(cl(n));let r=[];e=e>t.length?t.length:e,e=e==0?t.length:e;for(let i=0;i>1|(Bt&21845)<<1;Li=(Li&52428)>>2|(Li&13107)<<2,Li=(Li&61680)>>4|(Li&3855)<<4,tg[Bt]=((Li&65280)>>8|(Li&255)<<8)>>1}var ri=function(n,e,t){for(var r=n.length,i=0,s=new ln(e);i>l]=c}else for(o=new ln(r),i=0;i>15-n[i]);return o},ji=new Sr(288);for(var Bt=0;Bt<144;++Bt)ji[Bt]=8;for(var Bt=144;Bt<256;++Bt)ji[Bt]=9;for(var Bt=256;Bt<280;++Bt)ji[Bt]=7;for(var Bt=280;Bt<288;++Bt)ji[Bt]=8;var Ho=new Sr(32);for(var Bt=0;Bt<32;++Bt)Ho[Bt]=5;var hB=ri(ji,9,0),fB=ri(ji,9,1),mB=ri(Ho,5,0),gB=ri(Ho,5,1),nd=function(n){for(var e=n[0],t=1;te&&(e=n[t]);return e},Rn=function(n,e,t){var r=e/8|0;return(n[r]|n[r+1]<<8)>>(e&7)&t},id=function(n,e){var t=e/8|0;return(n[t]|n[t+1]<<8|n[t+2]<<16)>>(e&7)},c_=function(n){return(n+7)/8|0},u_=function(n,e,t){(e==null||e<0)&&(e=0),(t==null||t>n.length)&&(t=n.length);var r=new Sr(t-e);return r.set(n.subarray(e,t)),r},_B=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],$r=function(n,e,t){var r=new Error(e||_B[n]);if(r.code=n,Error.captureStackTrace&&Error.captureStackTrace(r,$r),!t)throw r;return r},d_=function(n,e,t,r){var i=n.length,s=r?r.length:0;if(!i||e.f&&!e.l)return t||new Sr(0);var a=!t||e.i!=2,o=e.i;t||(t=new Sr(i*3));var l=function(Le){var tt=t.length;if(Le>tt){var nt=new Sr(Math.max(tt*2,Le));nt.set(t),t=nt}},c=e.f||0,u=e.p||0,p=e.b||0,m=e.l,_=e.d,T=e.m,I=e.n,R=i*8;do{if(!m){c=Rn(n,u,1);var L=Rn(n,u+1,3);if(u+=3,L)if(L==1)m=fB,_=gB,T=9,I=5;else if(L==2){var E=Rn(n,u,31)+257,S=Rn(n,u+10,15)+4,N=E+Rn(n,u+5,31)+1;u+=14;for(var k=new Sr(N),x=new Sr(19),M=0;M>4;if($<16)k[M++]=$;else{var ee=0,B=0;for($==16?(B=3+Rn(n,u,3),u+=2,ee=k[M-1]):$==17?(B=3+Rn(n,u,7),u+=3):$==18&&(B=11+Rn(n,u,127),u+=7);B--;)k[M++]=ee}}var Q=k.subarray(0,E),j=k.subarray(E);T=nd(Q),I=nd(j),m=ri(Q,T,1),_=ri(j,I,1)}else $r(1);else{var $=c_(u)+4,K=n[$-4]|n[$-3]<<8,f=$+K;if(f>i){o&&$r(0);break}a&&l(p+K),t.set(n.subarray($,f),p),e.b=p+=K,e.p=u=f*8,e.f=c;continue}if(u>R){o&&$r(0);break}}a&&l(p+131072);for(var Z=(1<>4;if(u+=ee&15,u>R){o&&$r(0);break}if(ee||$r(2),Ee<256)t[p++]=Ee;else if(Ee==256){le=u,m=null;break}else{var De=Ee-254;if(Ee>264){var M=Ee-257,xe=iu[M];De=Rn(n,u,(1<>4;be||$r(3),u+=be&15;var j=pB[Re];if(Re>3){var xe=au[Re];j+=id(n,u)&(1<R){o&&$r(0);break}a&&l(p+131072);var ce=p+De;if(p>8},uo=function(n,e,t){t<<=e&7;var r=e/8|0;n[r]|=t,n[r+1]|=t>>8,n[r+2]|=t>>16},ad=function(n,e){for(var t=[],r=0;rm&&(m=s[r].s);var _=new ln(m+1),T=rg(t[u-1],_,0);if(T>e){var r=0,I=0,R=T-e,L=1<e)I+=L-(1<>=R;I>0;){var K=s[r].s;_[K]=0&&I;--r){var f=s[r].s;_[f]==e&&(--_[f],++I)}T=e}return{t:new Sr(_),l:T}},rg=function(n,e,t){return n.s==-1?Math.max(rg(n.l,e,t+1),rg(n.r,e,t+1)):e[n.s]=t},CE=function(n){for(var e=n.length;e&&!n[--e];);for(var t=new ln(++e),r=0,i=n[0],s=1,a=function(l){t[r++]=l},o=1;o<=e;++o)if(n[o]==i&&o!=e)++s;else{if(!i&&s>2){for(;s>138;s-=138)a(32754);s>2&&(a(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(a(i),--s;s>6;s-=6)a(8304);s>2&&(a(s-3<<5|8208),s=0)}for(;s--;)a(i);s=1,i=n[o]}return{c:t.subarray(0,r),n:e}},po=function(n,e){for(var t=0,r=0;r>8,n[i+2]=n[i]^255,n[i+3]=n[i+1]^255;for(var s=0;s4&&!M[Jm[te-1]];--te);var ne=c+5<<3,re=po(i,ji)+po(s,Ho)+a,ee=po(i,m)+po(s,I)+a+14+3*te+po(N,M)+2*N[16]+3*N[17]+7*N[18];if(l>=0&&ne<=re&&ne<=ee)return $I(e,u,n.subarray(l,l+c));var B,Q,j,Z;if(fi(e,u,1+(ee15&&(fi(e,u,De[k]>>5&127),u+=De[k]>>12)}}else B=hB,Q=ji,j=mB,Z=Ho;for(var k=0;k255){var xe=be>>18&31;uo(e,u,B[xe+257]),u+=Q[xe+257],xe>7&&(fi(e,u,be>>23&31),u+=iu[xe]);var Re=be&31;uo(e,u,j[Re]),u+=Z[Re],Re>3&&(uo(e,u,be>>5&8191),u+=au[Re])}else uo(e,u,B[be]),u+=Q[be]}return uo(e,u,B[256]),u+Q[256]},SB=new l_([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),GI=new Sr(0),OB=function(n,e,t,r,i,s){var a=s.z||n.length,o=new Sr(r+a+5*(1+Math.ceil(a/7e3))+i),l=o.subarray(r,o.length-i),c=s.l,u=(s.r||0)&7;if(e){u&&(l[0]=s.r>>3);for(var p=SB[e-1],m=p>>13,_=p&8191,T=(1<7e3||M>24576)&&(B>423||!c)){u=yE(n,l,0,f,E,S,k,M,te,x-te,u),M=N=k=0,te=x;for(var Q=0;Q<286;++Q)E[Q]=0;for(var Q=0;Q<30;++Q)S[Q]=0}var j=2,Z=0,ue=_,le=re-ee&32767;if(B>2&&ne==K(x-le))for(var Ee=Math.min(m,B)-1,De=Math.min(32767,x),xe=Math.min(258,B);le<=De&&--ue&&re!=ee;){if(n[x+j]==n[x+j-le]){for(var be=0;bej){if(j=be,Z=le,be>Ee)break;for(var Re=Math.min(le,be-2),ce=0,Q=0;Qce&&(ce=Le,ee=ke)}}}re=ee,ee=I[re],le+=re-ee&32767}if(Z){f[M++]=268435456|eg[j]<<18|TE[Z];var tt=eg[j]&31,nt=TE[Z]&31;k+=iu[tt]+au[nt],++E[257+tt],++S[nt],G=x+j,++N}else f[M++]=n[x],++E[n[x]]}}for(x=Math.max(x,G);x=a&&(l[u/8|0]=c,ze=a),u=$I(l,u+1,n.subarray(x,ze))}s.i=a}return u_(o,0,r+c_(u)+i)},EB=function(){for(var n=new Int32Array(256),e=0;e<256;++e){for(var t=e,r=9;--r;)t=(t&1&&-306674912)^t>>>1;n[e]=t}return n}(),bB=function(){var n=-1;return{p:function(e){for(var t=n,r=0;r>>8;n=t},d:function(){return~n}}},vB=function(n,e,t,r,i){if(!i&&(i={l:1},e.dictionary)){var s=e.dictionary.subarray(-32768),a=new Sr(s.length+n.length);a.set(s),a.set(n,s.length),n=a,i.w=s.length}return OB(n,e.level==null?6:e.level,e.mem==null?Math.ceil(Math.max(8,Math.min(13,Math.log(n.length)))*1.5):12+e.mem,t,r,i)},ng=function(n,e,t){for(;t;++e)n[e]=t,t>>>=8},TB=function(n,e){var t=e.filename;if(n[0]=31,n[1]=139,n[2]=8,n[8]=e.level<2?4:e.level==9?2:0,n[9]=3,e.mtime!=0&&ng(n,4,Math.floor(new Date(e.mtime||Date.now())/1e3)),t){n[3]=8;for(var r=0;r<=t.length;++r)n[r+10]=t.charCodeAt(r)}},CB=function(n){(n[0]!=31||n[1]!=139||n[2]!=8)&&$r(6,"invalid gzip data");var e=n[3],t=10;e&4&&(t+=(n[10]|n[11]<<8)+2);for(var r=(e>>3&1)+(e>>4&1);r>0;r-=!n[t++]);return t+(e&2)},yB=function(n){var e=n.length;return(n[e-4]|n[e-3]<<8|n[e-2]<<16|n[e-1]<<24)>>>0},AB=function(n){return 10+(n.filename?n.filename.length+1:0)},IB=function(n,e){return((n[0]&15)!=8||n[0]>>4>7||(n[0]<<8|n[1])%31)&&$r(6,"invalid zlib data"),(n[1]>>5&1)==+!e&&$r(6,"invalid zlib data: "+(n[1]&32?"need":"unexpected")+" dictionary"),(n[1]>>3&4)+2};function RB(n,e){return d_(n,{i:2},e&&e.out,e&&e.dictionary)}function NB(n,e){e||(e={});var t=bB(),r=n.length;t.p(n);var i=vB(n,e,AB(e),8),s=i.length;return TB(i,e),ng(i,s-8,t.d()),ng(i,s-4,r),i}function wB(n,e){var t=CB(n);return t+8>n.length&&$r(6,"invalid gzip data"),d_(n.subarray(t,-8),{i:2},e&&e.out||new Sr(yB(n)),e&&e.dictionary)}function DB(n,e){return d_(n.subarray(IB(n,e&&e.dictionary),-4),{i:2},e&&e.out,e&&e.dictionary)}function xB(n,e){return n[0]==31&&n[1]==139&&n[2]==8?wB(n,e):(n[0]&15)!=8||n[0]>>4>7||(n[0]<<8|n[1])%31?RB(n,e):DB(n,e)}var ig=typeof TextDecoder<"u"&&new TextDecoder,kB=0;try{ig.decode(GI,{stream:!0}),kB=1}catch{}var LB=function(n){for(var e="",t=0;;){var r=n[t++],i=(r>127)+(r>223)+(r>239);if(t+i>n.length)return{s:e,r:u_(n,t-1)};i?i==3?(r=((r&15)<<18|(n[t++]&63)<<12|(n[t++]&63)<<6|n[t++]&63)-65536,e+=String.fromCharCode(55296|r>>10,56320|r&1023)):i&1?e+=String.fromCharCode((r&31)<<6|n[t++]&63):e+=String.fromCharCode((r&15)<<12|(n[t++]&63)<<6|n[t++]&63):e+=String.fromCharCode(r)}};function MB(n,e){if(e){for(var t="",r=0;r (GFM Style)",type:"boolean"},requireSpaceBeforeHeadingText:{defaultValue:!1,describe:"Makes adding a space between `#` and the header text mandatory (GFM Style)",type:"boolean"},ghMentions:{defaultValue:!1,describe:"Enables github @mentions",type:"boolean"},ghMentionsLink:{defaultValue:"https://github.com/{u}",describe:"Changes the link generated by @mentions. Only applies if ghMentions option is enabled.",type:"string"},encodeEmails:{defaultValue:!0,describe:"Encode e-mail addresses through the use of Character Entities, transforming ASCII e-mail addresses into its equivalent decimal entities",type:"boolean"},openLinksInNewWindow:{defaultValue:!1,describe:"Open all links in new windows",type:"boolean"},backslashEscapesHTMLTags:{defaultValue:!1,describe:"Support for HTML Tag escaping. ex:
foo
",type:"boolean"},emoji:{defaultValue:!1,describe:"Enable emoji support. Ex: `this is a :smile: emoji`",type:"boolean"},underline:{defaultValue:!1,describe:"Enable support for underline. Syntax is double or triple underscores: `__underline word__`. With this option enabled, underscores no longer parses into `` and ``",type:"boolean"},ellipsis:{defaultValue:!0,describe:"Replaces three dots with the ellipsis unicode character",type:"boolean"},completeHTMLDocument:{defaultValue:!1,describe:"Outputs a complete html document, including ``, `` and `` tags",type:"boolean"},metadata:{defaultValue:!1,describe:"Enable support for document metadata (defined at the top of the document between `«««` and `»»»` or between `---` and `---`).",type:"boolean"},splitAdjacentBlockquotes:{defaultValue:!1,describe:"Split adjacent blockquote blocks",type:"boolean"}};if(f===!1)return JSON.parse(JSON.stringify(E));var S={};for(var N in E)E.hasOwnProperty(N)&&(S[N]=E[N].defaultValue);return S}function t(){var f=e(!0),E={};for(var S in f)f.hasOwnProperty(S)&&(E[S]=!0);return E}var r={},i={},s={},a=e(!0),o="vanilla",l={github:{omitExtraWLInCodeBlocks:!0,simplifiedAutoLink:!0,excludeTrailingPunctuationFromURLs:!0,literalMidWordUnderscores:!0,strikethrough:!0,tables:!0,tablesHeaderId:!0,ghCodeBlocks:!0,tasklists:!0,disableForced4SpacesIndentedSublists:!0,simpleLineBreaks:!0,requireSpaceBeforeHeadingText:!0,ghCompatibleHeaderId:!0,ghMentions:!0,backslashEscapesHTMLTags:!0,emoji:!0,splitAdjacentBlockquotes:!0},original:{noHeaderId:!0,ghCodeBlocks:!1},ghost:{omitExtraWLInCodeBlocks:!0,parseImgDimensions:!0,simplifiedAutoLink:!0,excludeTrailingPunctuationFromURLs:!0,literalMidWordUnderscores:!0,strikethrough:!0,tables:!0,tablesHeaderId:!0,ghCodeBlocks:!0,tasklists:!0,smoothLivePreview:!0,simpleLineBreaks:!0,requireSpaceBeforeHeadingText:!0,ghMentions:!1,encodeEmails:!0},vanilla:e(!0),allOn:t()};r.helper={},r.extensions={},r.setOption=function(f,E){return a[f]=E,this},r.getOption=function(f){return a[f]},r.getOptions=function(){return a},r.resetOptions=function(){a=e(!0)},r.setFlavor=function(f){if(!l.hasOwnProperty(f))throw Error(f+" flavor was not found");r.resetOptions();var E=l[f];o=f;for(var S in E)E.hasOwnProperty(S)&&(a[S]=E[S])},r.getFlavor=function(){return o},r.getFlavorOptions=function(f){if(l.hasOwnProperty(f))return l[f]},r.getDefaultOptions=function(f){return e(f)},r.subParser=function(f,E){if(r.helper.isString(f))if(typeof E<"u")i[f]=E;else{if(i.hasOwnProperty(f))return i[f];throw Error("SubParser named "+f+" not registered!")}},r.extension=function(f,E){if(!r.helper.isString(f))throw Error("Extension 'name' must be a string");if(f=r.helper.stdExtName(f),r.helper.isUndefined(E)){if(!s.hasOwnProperty(f))throw Error("Extension named "+f+" is not registered!");return s[f]}else{typeof E=="function"&&(E=E()),r.helper.isArray(E)||(E=[E]);var S=c(E,f);if(S.valid)s[f]=E;else throw Error(S.error)}},r.getAllExtensions=function(){return s},r.removeExtension=function(f){delete s[f]},r.resetExtensions=function(){s={}};function c(f,E){var S=E?"Error in "+E+" extension->":"Error in unnamed extension",N={valid:!0,error:""};r.helper.isArray(f)||(f=[f]);for(var k=0;k"u"},r.helper.forEach=function(f,E){if(r.helper.isUndefined(f))throw new Error("obj param is required");if(r.helper.isUndefined(E))throw new Error("callback param is required");if(!r.helper.isFunction(E))throw new Error("callback param must be a function/closure");if(typeof f.forEach=="function")f.forEach(E);else if(r.helper.isArray(f))for(var S=0;S").replace(/&/g,"&")};var p=function(f,E,S,N){var k=N||"",x=k.indexOf("g")>-1,M=new RegExp(E+"|"+S,"g"+k.replace(/g/g,"")),G=new RegExp(E,k.replace(/g/g,"")),te=[],ne,re,ee,B,Q;do for(ne=0;ee=M.exec(f);)if(G.test(ee[0]))ne++||(re=M.lastIndex,B=re-ee[0].length);else if(ne&&!--ne){Q=ee.index+ee[0].length;var j={left:{start:B,end:re},match:{start:re,end:ee.index},right:{start:ee.index,end:Q},wholeMatch:{start:B,end:Q}};if(te.push(j),!x)return te}while(ne&&(M.lastIndex=re));return te};r.helper.matchRecursiveRegExp=function(f,E,S,N){for(var k=p(f,E,S,N),x=[],M=0;M0){var ne=[];M[0].wholeMatch.start!==0&&ne.push(f.slice(0,M[0].wholeMatch.start));for(var re=0;re=0?N+(S||0):N},r.helper.splitAtIndex=function(f,E){if(!r.helper.isString(f))throw"InvalidArgumentError: first parameter of showdown.helper.regexIndexOf function must be a string";return[f.substring(0,E),f.substring(E)]},r.helper.encodeEmailAddress=function(f){var E=[function(S){return"&#"+S.charCodeAt(0)+";"},function(S){return"&#x"+S.charCodeAt(0).toString(16)+";"},function(S){return S}];return f=f.replace(/./g,function(S){if(S==="@")S=E[Math.floor(Math.random()*2)](S);else{var N=Math.random();S=N>.9?E[2](S):N>.45?E[1](S):E[0](S)}return S}),f},r.helper.padEnd=function(E,S,N){return S=S>>0,N=String(N||" "),E.length>S?String(E):(S=S-E.length,S>N.length&&(N+=N.repeat(S/N.length)),String(E)+N.slice(0,S))},typeof console>"u"&&(console={warn:function(f){alert(f)},log:function(f){alert(f)},error:function(f){throw f}}),r.helper.regexes={asteriskDashAndColon:/([*_:~])/g},r.helper.emojis={"+1":"👍","-1":"👎",100:"💯",1234:"🔢","1st_place_medal":"🥇","2nd_place_medal":"🥈","3rd_place_medal":"🥉","8ball":"🎱",a:"🅰️",ab:"🆎",abc:"🔤",abcd:"🔡",accept:"🉑",aerial_tramway:"🚡",airplane:"✈️",alarm_clock:"⏰",alembic:"⚗️",alien:"👽",ambulance:"🚑",amphora:"🏺",anchor:"⚓️",angel:"👼",anger:"💢",angry:"😠",anguished:"😧",ant:"🐜",apple:"🍎",aquarius:"♒️",aries:"♈️",arrow_backward:"◀️",arrow_double_down:"⏬",arrow_double_up:"⏫",arrow_down:"⬇️",arrow_down_small:"🔽",arrow_forward:"▶️",arrow_heading_down:"⤵️",arrow_heading_up:"⤴️",arrow_left:"⬅️",arrow_lower_left:"↙️",arrow_lower_right:"↘️",arrow_right:"➡️",arrow_right_hook:"↪️",arrow_up:"⬆️",arrow_up_down:"↕️",arrow_up_small:"🔼",arrow_upper_left:"↖️",arrow_upper_right:"↗️",arrows_clockwise:"🔃",arrows_counterclockwise:"🔄",art:"🎨",articulated_lorry:"🚛",artificial_satellite:"🛰",astonished:"😲",athletic_shoe:"👟",atm:"🏧",atom_symbol:"⚛️",avocado:"🥑",b:"🅱️",baby:"👶",baby_bottle:"🍼",baby_chick:"🐤",baby_symbol:"🚼",back:"🔙",bacon:"🥓",badminton:"🏸",baggage_claim:"🛄",baguette_bread:"🥖",balance_scale:"⚖️",balloon:"🎈",ballot_box:"🗳",ballot_box_with_check:"☑️",bamboo:"🎍",banana:"🍌",bangbang:"‼️",bank:"🏦",bar_chart:"📊",barber:"💈",baseball:"⚾️",basketball:"🏀",basketball_man:"⛹️",basketball_woman:"⛹️‍♀️",bat:"🦇",bath:"🛀",bathtub:"🛁",battery:"🔋",beach_umbrella:"🏖",bear:"🐻",bed:"🛏",bee:"🐝",beer:"🍺",beers:"🍻",beetle:"🐞",beginner:"🔰",bell:"🔔",bellhop_bell:"🛎",bento:"🍱",biking_man:"🚴",bike:"🚲",biking_woman:"🚴‍♀️",bikini:"👙",biohazard:"☣️",bird:"🐦",birthday:"🎂",black_circle:"⚫️",black_flag:"🏴",black_heart:"🖤",black_joker:"🃏",black_large_square:"⬛️",black_medium_small_square:"◾️",black_medium_square:"◼️",black_nib:"✒️",black_small_square:"▪️",black_square_button:"🔲",blonde_man:"👱",blonde_woman:"👱‍♀️",blossom:"🌼",blowfish:"🐡",blue_book:"📘",blue_car:"🚙",blue_heart:"💙",blush:"😊",boar:"🐗",boat:"⛵️",bomb:"💣",book:"📖",bookmark:"🔖",bookmark_tabs:"📑",books:"📚",boom:"💥",boot:"👢",bouquet:"💐",bowing_man:"🙇",bow_and_arrow:"🏹",bowing_woman:"🙇‍♀️",bowling:"🎳",boxing_glove:"🥊",boy:"👦",bread:"🍞",bride_with_veil:"👰",bridge_at_night:"🌉",briefcase:"💼",broken_heart:"💔",bug:"🐛",building_construction:"🏗",bulb:"💡",bullettrain_front:"🚅",bullettrain_side:"🚄",burrito:"🌯",bus:"🚌",business_suit_levitating:"🕴",busstop:"🚏",bust_in_silhouette:"👤",busts_in_silhouette:"👥",butterfly:"🦋",cactus:"🌵",cake:"🍰",calendar:"📆",call_me_hand:"🤙",calling:"📲",camel:"🐫",camera:"📷",camera_flash:"📸",camping:"🏕",cancer:"♋️",candle:"🕯",candy:"🍬",canoe:"🛶",capital_abcd:"🔠",capricorn:"♑️",car:"🚗",card_file_box:"🗃",card_index:"📇",card_index_dividers:"🗂",carousel_horse:"🎠",carrot:"🥕",cat:"🐱",cat2:"🐈",cd:"💿",chains:"⛓",champagne:"🍾",chart:"💹",chart_with_downwards_trend:"📉",chart_with_upwards_trend:"📈",checkered_flag:"🏁",cheese:"🧀",cherries:"🍒",cherry_blossom:"🌸",chestnut:"🌰",chicken:"🐔",children_crossing:"🚸",chipmunk:"🐿",chocolate_bar:"🍫",christmas_tree:"🎄",church:"⛪️",cinema:"🎦",circus_tent:"🎪",city_sunrise:"🌇",city_sunset:"🌆",cityscape:"🏙",cl:"🆑",clamp:"🗜",clap:"👏",clapper:"🎬",classical_building:"🏛",clinking_glasses:"🥂",clipboard:"📋",clock1:"🕐",clock10:"🕙",clock1030:"🕥",clock11:"🕚",clock1130:"🕦",clock12:"🕛",clock1230:"🕧",clock130:"🕜",clock2:"🕑",clock230:"🕝",clock3:"🕒",clock330:"🕞",clock4:"🕓",clock430:"🕟",clock5:"🕔",clock530:"🕠",clock6:"🕕",clock630:"🕡",clock7:"🕖",clock730:"🕢",clock8:"🕗",clock830:"🕣",clock9:"🕘",clock930:"🕤",closed_book:"📕",closed_lock_with_key:"🔐",closed_umbrella:"🌂",cloud:"☁️",cloud_with_lightning:"🌩",cloud_with_lightning_and_rain:"⛈",cloud_with_rain:"🌧",cloud_with_snow:"🌨",clown_face:"🤡",clubs:"♣️",cocktail:"🍸",coffee:"☕️",coffin:"⚰️",cold_sweat:"😰",comet:"☄️",computer:"💻",computer_mouse:"🖱",confetti_ball:"🎊",confounded:"😖",confused:"😕",congratulations:"㊗️",construction:"🚧",construction_worker_man:"👷",construction_worker_woman:"👷‍♀️",control_knobs:"🎛",convenience_store:"🏪",cookie:"🍪",cool:"🆒",policeman:"👮",copyright:"©️",corn:"🌽",couch_and_lamp:"🛋",couple:"👫",couple_with_heart_woman_man:"💑",couple_with_heart_man_man:"👨‍❤️‍👨",couple_with_heart_woman_woman:"👩‍❤️‍👩",couplekiss_man_man:"👨‍❤️‍💋‍👨",couplekiss_man_woman:"💏",couplekiss_woman_woman:"👩‍❤️‍💋‍👩",cow:"🐮",cow2:"🐄",cowboy_hat_face:"🤠",crab:"🦀",crayon:"🖍",credit_card:"💳",crescent_moon:"🌙",cricket:"🏏",crocodile:"🐊",croissant:"🥐",crossed_fingers:"🤞",crossed_flags:"🎌",crossed_swords:"⚔️",crown:"👑",cry:"😢",crying_cat_face:"😿",crystal_ball:"🔮",cucumber:"🥒",cupid:"💘",curly_loop:"➰",currency_exchange:"💱",curry:"🍛",custard:"🍮",customs:"🛃",cyclone:"🌀",dagger:"🗡",dancer:"💃",dancing_women:"👯",dancing_men:"👯‍♂️",dango:"🍡",dark_sunglasses:"🕶",dart:"🎯",dash:"💨",date:"📅",deciduous_tree:"🌳",deer:"🦌",department_store:"🏬",derelict_house:"🏚",desert:"🏜",desert_island:"🏝",desktop_computer:"🖥",male_detective:"🕵️",diamond_shape_with_a_dot_inside:"💠",diamonds:"♦️",disappointed:"😞",disappointed_relieved:"😥",dizzy:"💫",dizzy_face:"😵",do_not_litter:"🚯",dog:"🐶",dog2:"🐕",dollar:"💵",dolls:"🎎",dolphin:"🐬",door:"🚪",doughnut:"🍩",dove:"🕊",dragon:"🐉",dragon_face:"🐲",dress:"👗",dromedary_camel:"🐪",drooling_face:"🤤",droplet:"💧",drum:"🥁",duck:"🦆",dvd:"📀","e-mail":"📧",eagle:"🦅",ear:"👂",ear_of_rice:"🌾",earth_africa:"🌍",earth_americas:"🌎",earth_asia:"🌏",egg:"🥚",eggplant:"🍆",eight_pointed_black_star:"✴️",eight_spoked_asterisk:"✳️",electric_plug:"🔌",elephant:"🐘",email:"✉️",end:"🔚",envelope_with_arrow:"📩",euro:"💶",european_castle:"🏰",european_post_office:"🏤",evergreen_tree:"🌲",exclamation:"❗️",expressionless:"😑",eye:"👁",eye_speech_bubble:"👁‍🗨",eyeglasses:"👓",eyes:"👀",face_with_head_bandage:"🤕",face_with_thermometer:"🤒",fist_oncoming:"👊",factory:"🏭",fallen_leaf:"🍂",family_man_woman_boy:"👪",family_man_boy:"👨‍👦",family_man_boy_boy:"👨‍👦‍👦",family_man_girl:"👨‍👧",family_man_girl_boy:"👨‍👧‍👦",family_man_girl_girl:"👨‍👧‍👧",family_man_man_boy:"👨‍👨‍👦",family_man_man_boy_boy:"👨‍👨‍👦‍👦",family_man_man_girl:"👨‍👨‍👧",family_man_man_girl_boy:"👨‍👨‍👧‍👦",family_man_man_girl_girl:"👨‍👨‍👧‍👧",family_man_woman_boy_boy:"👨‍👩‍👦‍👦",family_man_woman_girl:"👨‍👩‍👧",family_man_woman_girl_boy:"👨‍👩‍👧‍👦",family_man_woman_girl_girl:"👨‍👩‍👧‍👧",family_woman_boy:"👩‍👦",family_woman_boy_boy:"👩‍👦‍👦",family_woman_girl:"👩‍👧",family_woman_girl_boy:"👩‍👧‍👦",family_woman_girl_girl:"👩‍👧‍👧",family_woman_woman_boy:"👩‍👩‍👦",family_woman_woman_boy_boy:"👩‍👩‍👦‍👦",family_woman_woman_girl:"👩‍👩‍👧",family_woman_woman_girl_boy:"👩‍👩‍👧‍👦",family_woman_woman_girl_girl:"👩‍👩‍👧‍👧",fast_forward:"⏩",fax:"📠",fearful:"😨",feet:"🐾",female_detective:"🕵️‍♀️",ferris_wheel:"🎡",ferry:"⛴",field_hockey:"🏑",file_cabinet:"🗄",file_folder:"📁",film_projector:"📽",film_strip:"🎞",fire:"🔥",fire_engine:"🚒",fireworks:"🎆",first_quarter_moon:"🌓",first_quarter_moon_with_face:"🌛",fish:"🐟",fish_cake:"🍥",fishing_pole_and_fish:"🎣",fist_raised:"✊",fist_left:"🤛",fist_right:"🤜",flags:"🎏",flashlight:"🔦",fleur_de_lis:"⚜️",flight_arrival:"🛬",flight_departure:"🛫",floppy_disk:"💾",flower_playing_cards:"🎴",flushed:"😳",fog:"🌫",foggy:"🌁",football:"🏈",footprints:"👣",fork_and_knife:"🍴",fountain:"⛲️",fountain_pen:"🖋",four_leaf_clover:"🍀",fox_face:"🦊",framed_picture:"🖼",free:"🆓",fried_egg:"🍳",fried_shrimp:"🍤",fries:"🍟",frog:"🐸",frowning:"😦",frowning_face:"☹️",frowning_man:"🙍‍♂️",frowning_woman:"🙍",middle_finger:"🖕",fuelpump:"⛽️",full_moon:"🌕",full_moon_with_face:"🌝",funeral_urn:"⚱️",game_die:"🎲",gear:"⚙️",gem:"💎",gemini:"♊️",ghost:"👻",gift:"🎁",gift_heart:"💝",girl:"👧",globe_with_meridians:"🌐",goal_net:"🥅",goat:"🐐",golf:"⛳️",golfing_man:"🏌️",golfing_woman:"🏌️‍♀️",gorilla:"🦍",grapes:"🍇",green_apple:"🍏",green_book:"📗",green_heart:"💚",green_salad:"🥗",grey_exclamation:"❕",grey_question:"❔",grimacing:"😬",grin:"😁",grinning:"😀",guardsman:"💂",guardswoman:"💂‍♀️",guitar:"🎸",gun:"🔫",haircut_woman:"💇",haircut_man:"💇‍♂️",hamburger:"🍔",hammer:"🔨",hammer_and_pick:"⚒",hammer_and_wrench:"🛠",hamster:"🐹",hand:"✋",handbag:"👜",handshake:"🤝",hankey:"💩",hatched_chick:"🐥",hatching_chick:"🐣",headphones:"🎧",hear_no_evil:"🙉",heart:"❤️",heart_decoration:"💟",heart_eyes:"😍",heart_eyes_cat:"😻",heartbeat:"💓",heartpulse:"💗",hearts:"♥️",heavy_check_mark:"✔️",heavy_division_sign:"➗",heavy_dollar_sign:"💲",heavy_heart_exclamation:"❣️",heavy_minus_sign:"➖",heavy_multiplication_x:"✖️",heavy_plus_sign:"➕",helicopter:"🚁",herb:"🌿",hibiscus:"🌺",high_brightness:"🔆",high_heel:"👠",hocho:"🔪",hole:"🕳",honey_pot:"🍯",horse:"🐴",horse_racing:"🏇",hospital:"🏥",hot_pepper:"🌶",hotdog:"🌭",hotel:"🏨",hotsprings:"♨️",hourglass:"⌛️",hourglass_flowing_sand:"⏳",house:"🏠",house_with_garden:"🏡",houses:"🏘",hugs:"🤗",hushed:"😯",ice_cream:"🍨",ice_hockey:"🏒",ice_skate:"⛸",icecream:"🍦",id:"🆔",ideograph_advantage:"🉐",imp:"👿",inbox_tray:"📥",incoming_envelope:"📨",tipping_hand_woman:"💁",information_source:"ℹ️",innocent:"😇",interrobang:"⁉️",iphone:"📱",izakaya_lantern:"🏮",jack_o_lantern:"🎃",japan:"🗾",japanese_castle:"🏯",japanese_goblin:"👺",japanese_ogre:"👹",jeans:"👖",joy:"😂",joy_cat:"😹",joystick:"🕹",kaaba:"🕋",key:"🔑",keyboard:"⌨️",keycap_ten:"🔟",kick_scooter:"🛴",kimono:"👘",kiss:"💋",kissing:"😗",kissing_cat:"😽",kissing_closed_eyes:"😚",kissing_heart:"😘",kissing_smiling_eyes:"😙",kiwi_fruit:"🥝",koala:"🐨",koko:"🈁",label:"🏷",large_blue_circle:"🔵",large_blue_diamond:"🔷",large_orange_diamond:"🔶",last_quarter_moon:"🌗",last_quarter_moon_with_face:"🌜",latin_cross:"✝️",laughing:"😆",leaves:"🍃",ledger:"📒",left_luggage:"🛅",left_right_arrow:"↔️",leftwards_arrow_with_hook:"↩️",lemon:"🍋",leo:"♌️",leopard:"🐆",level_slider:"🎚",libra:"♎️",light_rail:"🚈",link:"🔗",lion:"🦁",lips:"👄",lipstick:"💄",lizard:"🦎",lock:"🔒",lock_with_ink_pen:"🔏",lollipop:"🍭",loop:"➿",loud_sound:"🔊",loudspeaker:"📢",love_hotel:"🏩",love_letter:"💌",low_brightness:"🔅",lying_face:"🤥",m:"Ⓜ️",mag:"🔍",mag_right:"🔎",mahjong:"🀄️",mailbox:"📫",mailbox_closed:"📪",mailbox_with_mail:"📬",mailbox_with_no_mail:"📭",man:"👨",man_artist:"👨‍🎨",man_astronaut:"👨‍🚀",man_cartwheeling:"🤸‍♂️",man_cook:"👨‍🍳",man_dancing:"🕺",man_facepalming:"🤦‍♂️",man_factory_worker:"👨‍🏭",man_farmer:"👨‍🌾",man_firefighter:"👨‍🚒",man_health_worker:"👨‍⚕️",man_in_tuxedo:"🤵",man_judge:"👨‍⚖️",man_juggling:"🤹‍♂️",man_mechanic:"👨‍🔧",man_office_worker:"👨‍💼",man_pilot:"👨‍✈️",man_playing_handball:"🤾‍♂️",man_playing_water_polo:"🤽‍♂️",man_scientist:"👨‍🔬",man_shrugging:"🤷‍♂️",man_singer:"👨‍🎤",man_student:"👨‍🎓",man_teacher:"👨‍🏫",man_technologist:"👨‍💻",man_with_gua_pi_mao:"👲",man_with_turban:"👳",tangerine:"🍊",mans_shoe:"👞",mantelpiece_clock:"🕰",maple_leaf:"🍁",martial_arts_uniform:"🥋",mask:"😷",massage_woman:"💆",massage_man:"💆‍♂️",meat_on_bone:"🍖",medal_military:"🎖",medal_sports:"🏅",mega:"📣",melon:"🍈",memo:"📝",men_wrestling:"🤼‍♂️",menorah:"🕎",mens:"🚹",metal:"🤘",metro:"🚇",microphone:"🎤",microscope:"🔬",milk_glass:"🥛",milky_way:"🌌",minibus:"🚐",minidisc:"💽",mobile_phone_off:"📴",money_mouth_face:"🤑",money_with_wings:"💸",moneybag:"💰",monkey:"🐒",monkey_face:"🐵",monorail:"🚝",moon:"🌔",mortar_board:"🎓",mosque:"🕌",motor_boat:"🛥",motor_scooter:"🛵",motorcycle:"🏍",motorway:"🛣",mount_fuji:"🗻",mountain:"⛰",mountain_biking_man:"🚵",mountain_biking_woman:"🚵‍♀️",mountain_cableway:"🚠",mountain_railway:"🚞",mountain_snow:"🏔",mouse:"🐭",mouse2:"🐁",movie_camera:"🎥",moyai:"🗿",mrs_claus:"🤶",muscle:"💪",mushroom:"🍄",musical_keyboard:"🎹",musical_note:"🎵",musical_score:"🎼",mute:"🔇",nail_care:"💅",name_badge:"📛",national_park:"🏞",nauseated_face:"🤢",necktie:"👔",negative_squared_cross_mark:"❎",nerd_face:"🤓",neutral_face:"😐",new:"🆕",new_moon:"🌑",new_moon_with_face:"🌚",newspaper:"📰",newspaper_roll:"🗞",next_track_button:"⏭",ng:"🆖",no_good_man:"🙅‍♂️",no_good_woman:"🙅",night_with_stars:"🌃",no_bell:"🔕",no_bicycles:"🚳",no_entry:"⛔️",no_entry_sign:"🚫",no_mobile_phones:"📵",no_mouth:"😶",no_pedestrians:"🚷",no_smoking:"🚭","non-potable_water":"🚱",nose:"👃",notebook:"📓",notebook_with_decorative_cover:"📔",notes:"🎶",nut_and_bolt:"🔩",o:"⭕️",o2:"🅾️",ocean:"🌊",octopus:"🐙",oden:"🍢",office:"🏢",oil_drum:"🛢",ok:"🆗",ok_hand:"👌",ok_man:"🙆‍♂️",ok_woman:"🙆",old_key:"🗝",older_man:"👴",older_woman:"👵",om:"🕉",on:"🔛",oncoming_automobile:"🚘",oncoming_bus:"🚍",oncoming_police_car:"🚔",oncoming_taxi:"🚖",open_file_folder:"📂",open_hands:"👐",open_mouth:"😮",open_umbrella:"☂️",ophiuchus:"⛎",orange_book:"📙",orthodox_cross:"☦️",outbox_tray:"📤",owl:"🦉",ox:"🐂",package:"📦",page_facing_up:"📄",page_with_curl:"📃",pager:"📟",paintbrush:"🖌",palm_tree:"🌴",pancakes:"🥞",panda_face:"🐼",paperclip:"📎",paperclips:"🖇",parasol_on_ground:"⛱",parking:"🅿️",part_alternation_mark:"〽️",partly_sunny:"⛅️",passenger_ship:"🛳",passport_control:"🛂",pause_button:"⏸",peace_symbol:"☮️",peach:"🍑",peanuts:"🥜",pear:"🍐",pen:"🖊",pencil2:"✏️",penguin:"🐧",pensive:"😔",performing_arts:"🎭",persevere:"😣",person_fencing:"🤺",pouting_woman:"🙎",phone:"☎️",pick:"⛏",pig:"🐷",pig2:"🐖",pig_nose:"🐽",pill:"💊",pineapple:"🍍",ping_pong:"🏓",pisces:"♓️",pizza:"🍕",place_of_worship:"🛐",plate_with_cutlery:"🍽",play_or_pause_button:"⏯",point_down:"👇",point_left:"👈",point_right:"👉",point_up:"☝️",point_up_2:"👆",police_car:"🚓",policewoman:"👮‍♀️",poodle:"🐩",popcorn:"🍿",post_office:"🏣",postal_horn:"📯",postbox:"📮",potable_water:"🚰",potato:"🥔",pouch:"👝",poultry_leg:"🍗",pound:"💷",rage:"😡",pouting_cat:"😾",pouting_man:"🙎‍♂️",pray:"🙏",prayer_beads:"📿",pregnant_woman:"🤰",previous_track_button:"⏮",prince:"🤴",princess:"👸",printer:"🖨",purple_heart:"💜",purse:"👛",pushpin:"📌",put_litter_in_its_place:"🚮",question:"❓",rabbit:"🐰",rabbit2:"🐇",racehorse:"🐎",racing_car:"🏎",radio:"📻",radio_button:"🔘",radioactive:"☢️",railway_car:"🚃",railway_track:"🛤",rainbow:"🌈",rainbow_flag:"🏳️‍🌈",raised_back_of_hand:"🤚",raised_hand_with_fingers_splayed:"🖐",raised_hands:"🙌",raising_hand_woman:"🙋",raising_hand_man:"🙋‍♂️",ram:"🐏",ramen:"🍜",rat:"🐀",record_button:"⏺",recycle:"♻️",red_circle:"🔴",registered:"®️",relaxed:"☺️",relieved:"😌",reminder_ribbon:"🎗",repeat:"🔁",repeat_one:"🔂",rescue_worker_helmet:"⛑",restroom:"🚻",revolving_hearts:"💞",rewind:"⏪",rhinoceros:"🦏",ribbon:"🎀",rice:"🍚",rice_ball:"🍙",rice_cracker:"🍘",rice_scene:"🎑",right_anger_bubble:"🗯",ring:"💍",robot:"🤖",rocket:"🚀",rofl:"🤣",roll_eyes:"🙄",roller_coaster:"🎢",rooster:"🐓",rose:"🌹",rosette:"🏵",rotating_light:"🚨",round_pushpin:"📍",rowing_man:"🚣",rowing_woman:"🚣‍♀️",rugby_football:"🏉",running_man:"🏃",running_shirt_with_sash:"🎽",running_woman:"🏃‍♀️",sa:"🈂️",sagittarius:"♐️",sake:"🍶",sandal:"👡",santa:"🎅",satellite:"📡",saxophone:"🎷",school:"🏫",school_satchel:"🎒",scissors:"✂️",scorpion:"🦂",scorpius:"♏️",scream:"😱",scream_cat:"🙀",scroll:"📜",seat:"💺",secret:"㊙️",see_no_evil:"🙈",seedling:"🌱",selfie:"🤳",shallow_pan_of_food:"🥘",shamrock:"☘️",shark:"🦈",shaved_ice:"🍧",sheep:"🐑",shell:"🐚",shield:"🛡",shinto_shrine:"⛩",ship:"🚢",shirt:"👕",shopping:"🛍",shopping_cart:"🛒",shower:"🚿",shrimp:"🦐",signal_strength:"📶",six_pointed_star:"🔯",ski:"🎿",skier:"⛷",skull:"💀",skull_and_crossbones:"☠️",sleeping:"😴",sleeping_bed:"🛌",sleepy:"😪",slightly_frowning_face:"🙁",slightly_smiling_face:"🙂",slot_machine:"🎰",small_airplane:"🛩",small_blue_diamond:"🔹",small_orange_diamond:"🔸",small_red_triangle:"🔺",small_red_triangle_down:"🔻",smile:"😄",smile_cat:"😸",smiley:"😃",smiley_cat:"😺",smiling_imp:"😈",smirk:"😏",smirk_cat:"😼",smoking:"🚬",snail:"🐌",snake:"🐍",sneezing_face:"🤧",snowboarder:"🏂",snowflake:"❄️",snowman:"⛄️",snowman_with_snow:"☃️",sob:"😭",soccer:"⚽️",soon:"🔜",sos:"🆘",sound:"🔉",space_invader:"👾",spades:"♠️",spaghetti:"🍝",sparkle:"❇️",sparkler:"🎇",sparkles:"✨",sparkling_heart:"💖",speak_no_evil:"🙊",speaker:"🔈",speaking_head:"🗣",speech_balloon:"💬",speedboat:"🚤",spider:"🕷",spider_web:"🕸",spiral_calendar:"🗓",spiral_notepad:"🗒",spoon:"🥄",squid:"🦑",stadium:"🏟",star:"⭐️",star2:"🌟",star_and_crescent:"☪️",star_of_david:"✡️",stars:"🌠",station:"🚉",statue_of_liberty:"🗽",steam_locomotive:"🚂",stew:"🍲",stop_button:"⏹",stop_sign:"🛑",stopwatch:"⏱",straight_ruler:"📏",strawberry:"🍓",stuck_out_tongue:"😛",stuck_out_tongue_closed_eyes:"😝",stuck_out_tongue_winking_eye:"😜",studio_microphone:"🎙",stuffed_flatbread:"🥙",sun_behind_large_cloud:"🌥",sun_behind_rain_cloud:"🌦",sun_behind_small_cloud:"🌤",sun_with_face:"🌞",sunflower:"🌻",sunglasses:"😎",sunny:"☀️",sunrise:"🌅",sunrise_over_mountains:"🌄",surfing_man:"🏄",surfing_woman:"🏄‍♀️",sushi:"🍣",suspension_railway:"🚟",sweat:"😓",sweat_drops:"💦",sweat_smile:"😅",sweet_potato:"🍠",swimming_man:"🏊",swimming_woman:"🏊‍♀️",symbols:"🔣",synagogue:"🕍",syringe:"💉",taco:"🌮",tada:"🎉",tanabata_tree:"🎋",taurus:"♉️",taxi:"🚕",tea:"🍵",telephone_receiver:"📞",telescope:"🔭",tennis:"🎾",tent:"⛺️",thermometer:"🌡",thinking:"🤔",thought_balloon:"💭",ticket:"🎫",tickets:"🎟",tiger:"🐯",tiger2:"🐅",timer_clock:"⏲",tipping_hand_man:"💁‍♂️",tired_face:"😫",tm:"™️",toilet:"🚽",tokyo_tower:"🗼",tomato:"🍅",tongue:"👅",top:"🔝",tophat:"🎩",tornado:"🌪",trackball:"🖲",tractor:"🚜",traffic_light:"🚥",train:"🚋",train2:"🚆",tram:"🚊",triangular_flag_on_post:"🚩",triangular_ruler:"📐",trident:"🔱",triumph:"😤",trolleybus:"🚎",trophy:"🏆",tropical_drink:"🍹",tropical_fish:"🐠",truck:"🚚",trumpet:"🎺",tulip:"🌷",tumbler_glass:"🥃",turkey:"🦃",turtle:"🐢",tv:"📺",twisted_rightwards_arrows:"🔀",two_hearts:"💕",two_men_holding_hands:"👬",two_women_holding_hands:"👭",u5272:"🈹",u5408:"🈴",u55b6:"🈺",u6307:"🈯️",u6708:"🈷️",u6709:"🈶",u6e80:"🈵",u7121:"🈚️",u7533:"🈸",u7981:"🈲",u7a7a:"🈳",umbrella:"☔️",unamused:"😒",underage:"🔞",unicorn:"🦄",unlock:"🔓",up:"🆙",upside_down_face:"🙃",v:"✌️",vertical_traffic_light:"🚦",vhs:"📼",vibration_mode:"📳",video_camera:"📹",video_game:"🎮",violin:"🎻",virgo:"♍️",volcano:"🌋",volleyball:"🏐",vs:"🆚",vulcan_salute:"🖖",walking_man:"🚶",walking_woman:"🚶‍♀️",waning_crescent_moon:"🌘",waning_gibbous_moon:"🌖",warning:"⚠️",wastebasket:"🗑",watch:"⌚️",water_buffalo:"🐃",watermelon:"🍉",wave:"👋",wavy_dash:"〰️",waxing_crescent_moon:"🌒",wc:"🚾",weary:"😩",wedding:"💒",weight_lifting_man:"🏋️",weight_lifting_woman:"🏋️‍♀️",whale:"🐳",whale2:"🐋",wheel_of_dharma:"☸️",wheelchair:"♿️",white_check_mark:"✅",white_circle:"⚪️",white_flag:"🏳️",white_flower:"💮",white_large_square:"⬜️",white_medium_small_square:"◽️",white_medium_square:"◻️",white_small_square:"▫️",white_square_button:"🔳",wilted_flower:"🥀",wind_chime:"🎐",wind_face:"🌬",wine_glass:"🍷",wink:"😉",wolf:"🐺",woman:"👩",woman_artist:"👩‍🎨",woman_astronaut:"👩‍🚀",woman_cartwheeling:"🤸‍♀️",woman_cook:"👩‍🍳",woman_facepalming:"🤦‍♀️",woman_factory_worker:"👩‍🏭",woman_farmer:"👩‍🌾",woman_firefighter:"👩‍🚒",woman_health_worker:"👩‍⚕️",woman_judge:"👩‍⚖️",woman_juggling:"🤹‍♀️",woman_mechanic:"👩‍🔧",woman_office_worker:"👩‍💼",woman_pilot:"👩‍✈️",woman_playing_handball:"🤾‍♀️",woman_playing_water_polo:"🤽‍♀️",woman_scientist:"👩‍🔬",woman_shrugging:"🤷‍♀️",woman_singer:"👩‍🎤",woman_student:"👩‍🎓",woman_teacher:"👩‍🏫",woman_technologist:"👩‍💻",woman_with_turban:"👳‍♀️",womans_clothes:"👚",womans_hat:"👒",women_wrestling:"🤼‍♀️",womens:"🚺",world_map:"🗺",worried:"😟",wrench:"🔧",writing_hand:"✍️",x:"❌",yellow_heart:"💛",yen:"💴",yin_yang:"☯️",yum:"😋",zap:"⚡️",zipper_mouth_face:"🤐",zzz:"💤",octocat:':octocat:',showdown:`S`},r.Converter=function(f){var E={},S=[],N=[],k={},x=o,M={parsed:{},raw:"",format:""};G();function G(){f=f||{};for(var B in a)a.hasOwnProperty(B)&&(E[B]=a[B]);if(typeof f=="object")for(var Q in f)f.hasOwnProperty(Q)&&(E[Q]=f[Q]);else throw Error("Converter expects the passed parameter to be an object, but "+typeof f+" was passed instead.");E.extensions&&r.helper.forEach(E.extensions,te)}function te(B,Q){if(Q=Q||null,r.helper.isString(B))if(B=r.helper.stdExtName(B),Q=B,r.extensions[B]){console.warn("DEPRECATION WARNING: "+B+" is an old extension that uses a deprecated loading method.Please inform the developer that the extension should be updated!"),ne(r.extensions[B],B);return}else if(!r.helper.isUndefined(s[B]))B=s[B];else throw Error('Extension "'+B+'" could not be loaded. It was either not found or is not a valid extension.');typeof B=="function"&&(B=B()),r.helper.isArray(B)||(B=[B]);var j=c(B,Q);if(!j.valid)throw Error(j.error);for(var Z=0;Z",!1),Ht=lt("@",!1),ut=lt(":",!1),It=Zr(["m","k","l","p","d","c","w","y","h","n","q","a","e","f","s","x","t","g","u","j","z","o"],!1,!1),Vr=lt("/",!1),ht=lt("(",!1),Zt=lt(")",!1),Ct=lt("[:",!1),Be=lt("]",!1),Ur=lt("[",!1),Fn=lt("{",!1),dt=lt("}",!1),zr=lt("+",!1),Ir=lt("*",!1),Ii=lt("%",!1),Rr=lt("^",!1),Wt=lt("&",!1),yn=lt(">>",!1),ea=lt("<<",!1),li=lt("_",!1),ta=lt("?",!1),cn=lt("!",!1),ci=lt("r",!1),An=Zr([["a","z"],["A","Z"],["0","9"]],!1,!1),Kt=lt("#",!1),ui=lt("b",!1),di=Zr([["a","z"],["A","Z"],["0","9"],"-","*","+"],!1,!1),q=Zr([["A","G"]],!1,!1),ie=Zr(["b","s"],!1,!1),de=lt("iii",!1),ge=lt("ii",!1),Ae=lt("iv",!1),Qe=lt("i",!1),Me=lt("vii",!1),yt=lt("vi",!1),Nr=lt("v",!1),Hr=function(v){return v.filter(w=>w)},Da=function(){return parseFloat(Yr())},ra=function(){return parseInt(Yr())},Ds=function(){return parseInt(Yr())},Wr=function(){},xs=function(v){return Ut(XP,{sound:v})},xa=function(){return Yr()},ka=function(v){return Ut(Io,{items:v})},ks=function(v){return v},La=function(v,w){return Ut(ZP,{item:v,sound:w})},Ls=function(v,w){return Ut(KP,{item:v,soundIndex:w})},Ma=function(v){return v},Fr=function(){return UP[Yr()]},Ms=function(v,w){return v/w},Ps=function(v){return v.filter(w=>w)},Pa=function(v){return Ut(Io,{items:v})},Ba=function(v,w){return w?Ut(mE,{item:v,times:w}):Ut(gE,{items:v})},Bs=function(v){return v},Ua=function(v,w,P){return Ut(r3,{left:v,operation:w,right:P})},Us=function(v,w){return Ut(t3,{items:v,times:w})},Fa=function(v){return Ut(vI,{items:v})},Fs=function(v){return v.map(w=>typeof w=="number"?w:void 0)},Ys=function(){return Math.ceil(EI(Yr()))},un=function(v){var w=v.filter(P=>P).map(P=>Ut(ti,{pitch:P[0]},P.toString()));return Ut(gE,{items:w})},bt=function(v){return v},$s=function(v){return v},Ri=function(){},Gs=function(v){return Ut(Io,{items:v})},pi=function(v){return Ut(JP,{octave:v})},Qs=function(){return Yr().split("").reduce((v,w)=>v+(w==="^"?1:-1),0)},Ni=function(){return Ut(Mc,{seededRandom:s.seededRandom})},Ya=function(v,w){return Ut(Mc,{min:v,max:w,seededRandom:s.seededRandom})},$a=function(v,w){return Ut(mE,{item:v,times:w})},qs=function(v){return Ut(e3,{duration:v})},wi=function(v){return v},Ga=function(v){return Ut($m,{duration:v})},Di=function(v,w,P,X){const oe=v?s.nodeOptions.octave+v:s.nodeOptions.octave;return Ut(ti,{duration:w,pitch:X,pitchOctave:oe,add:P})},xi=function(v){return v.reduce((w,P)=>w+(P==="#"?1:-1),0)},Qa=function(v,w,P){return Ut(Ra,{pitches:[v].concat(w),inversion:P})},na=function(){return Yr()},hi=function(v){return v},fr=function(){return Yr()},qa=function(v,w,P,X,oe){const ve=s.nodeOptions.scaleName?s.nodeOptions.scaleName:"MAJOR",gt=s.nodeOptions.key?s.nodeOptions.key:"C",hn=d3(X,P,ve,v,w),Zs=w||s.nodeOptions.duration,mR=v?s.nodeOptions.octave+v:s.nodeOptions.octave;return Ut(Ra,{duration:Zs,chordOctave:mR,pitches:hn,chordName:X,inversion:oe,scaleName:ve,key:gt})},Xr=function(v,w,P){const X=s.nodeOptions.scaleName?s.nodeOptions.scaleName:"MAJOR",oe=s.nodeOptions.key?s.nodeOptions.key:"C";return Ut(jP,{roman:v,chordName:w,inversion:P,scaleName:X,key:oe})},ia=function(v){const w=s.nodeOptions.scaleName?s.nodeOptions.scaleName:"MAJOR",P=s.nodeOptions.key?s.nodeOptions.key:"C",X=O3(v,P,w);return Ut(ti,{pitch:X.pc,add:X.add,scaleName:w,key:P})},A=0,We=0,Va=[{line:1,column:1}],dn=0,Vs=[],Oe=0,me={},aa;if("startRule"in s){if(!(s.startRule in l))throw new Error(`Can't start parsing from rule "`+s.startRule+'".');c=l[s.startRule]}function Yr(){return i.substring(We,A)}function ul(){return d(We,A)}function lt(v,w){return{type:"literal",text:v,ignoreCase:w}}function Zr(v,w,P){return{type:"class",parts:v,inverted:w,ignoreCase:P}}function dl(){return{type:"end"}}function zs(v){return{type:"other",description:v}}function pl(v){var w=Va[v],P;if(w)return w;for(P=v-1;!Va[P];)P--;for(w=Va[P],w={line:w.line,column:w.column};Pdn&&(dn=A,Vs=[]),Vs.push(v))}function g(v,w,P){return new e(e.buildMessage(v,w),v,w,P)}function O(){var v,w,P=A*56+0,X=me[P];return X?(A=X.nextPos,X.result):(v=A,w=Xt(),w!==a&&(We=v,w=Hr(w)),v=w,me[P]={nextPos:A,result:v},v)}function C(){var v,w,P,X,oe,ve,gt,hn=A*56+1,Zs=me[hn];if(Zs)return A=Zs.nextPos,Zs.result;for(v=A,w=A,i.charCodeAt(A)===45?(P=u,A++):(P=a,Oe===0&&h(hr)),P===a&&(P=null),X=[],Le.test(i.charAt(A))?(oe=i.charAt(A),A++):(oe=a,Oe===0&&h(rt));oe!==a;)X.push(oe),Le.test(i.charAt(A))?(oe=i.charAt(A),A++):(oe=a,Oe===0&&h(rt));if(i.charCodeAt(A)===46?(oe=p,A++):(oe=a,Oe===0&&h(He)),oe!==a){if(ve=[],Le.test(i.charAt(A))?(gt=i.charAt(A),A++):(gt=a,Oe===0&&h(rt)),gt!==a)for(;gt!==a;)ve.push(gt),Le.test(i.charAt(A))?(gt=i.charAt(A),A++):(gt=a,Oe===0&&h(rt));else ve=a;ve!==a?(P=[P,X,oe,ve],w=P):(A=w,w=a)}else A=w,w=a;if(w===a)if(w=A,i.charCodeAt(A)===46?(P=p,A++):(P=a,Oe===0&&h(He)),P!==a){if(X=[],Le.test(i.charAt(A))?(oe=i.charAt(A),A++):(oe=a,Oe===0&&h(rt)),oe!==a)for(;oe!==a;)X.push(oe),Le.test(i.charAt(A))?(oe=i.charAt(A),A++):(oe=a,Oe===0&&h(rt));else X=a;X!==a?(P=[P,X],w=P):(A=w,w=a)}else A=w,w=a;return w!==a&&(We=v,w=Da()),v=w,me[hn]={nextPos:A,result:v},v}function y(){var v,w,P=A*56+2,X=me[P];return X?(A=X.nextPos,X.result):(v=A,i.charCodeAt(A)===45?A++:Oe===0&&h(hr),Le.test(i.charAt(A))?(w=i.charAt(A),A++):(w=a,Oe===0&&h(rt)),w!==a?(We=v,v=ra()):(A=v,v=a),me[P]={nextPos:A,result:v},v)}function D(){var v,w,P,X=A*56+3,oe=me[X];if(oe)return A=oe.nextPos,oe.result;if(v=A,i.charCodeAt(A)===45?A++:Oe===0&&h(hr),w=[],Le.test(i.charAt(A))?(P=i.charAt(A),A++):(P=a,Oe===0&&h(rt)),P!==a)for(;P!==a;)w.push(P),Le.test(i.charAt(A))?(P=i.charAt(A),A++):(P=a,Oe===0&&h(rt));else w=a;return w!==a?(We=v,v=Ds()):(A=v,v=a),me[X]={nextPos:A,result:v},v}function F(){var v,w,P=A*56+4,X=me[P];return X?(A=X.nextPos,X.result):(Oe++,v=A,tt.test(i.charAt(A))?(w=i.charAt(A),A++):(w=a,Oe===0&&h(cr)),w!==a&&(We=v,w=Wr()),v=w,Oe--,v===a&&(w=a,Oe===0&&h(Br)),me[P]={nextPos:A,result:v},v)}function U(){var v,w,P=A*56+8,X=me[P];return X?(A=X.nextPos,X.result):(v=A,w=H(),w!==a&&(We=v,w=xs(w)),v=w,me[P]={nextPos:A,result:v},v)}function H(){var v,w,P,X,oe,ve=A*56+10,gt=me[ve];if(gt)return A=gt.nextPos,gt.result;if(v=A,nt.test(i.charAt(A))?(w=i.charAt(A),A++):(w=a,Oe===0&&h(_e)),w!==a){if(P=[],ze.test(i.charAt(A))?(X=i.charAt(A),A++):(X=a,Oe===0&&h(we)),X!==a)for(;X!==a;)P.push(X),ze.test(i.charAt(A))?(X=i.charAt(A),A++):(X=a,Oe===0&&h(we));else P=a;if(P!==a){for(X=[],St.test(i.charAt(A))?(oe=i.charAt(A),A++):(oe=a,Oe===0&&h(Ne));oe!==a;)X.push(oe),St.test(i.charAt(A))?(oe=i.charAt(A),A++):(oe=a,Oe===0&&h(Ne));We=v,v=xa()}else A=v,v=a}else A=v,v=a;return me[ve]={nextPos:A,result:v},v}function z(){var v,w=A*56+11,P=me[w];return P?(A=P.nextPos,P.result):(v=pe(),v===a&&(v=he()),me[w]={nextPos:A,result:v},v)}function pe(){var v,w,P,X,oe=A*56+12,ve=me[oe];if(ve)return A=ve.nextPos,ve.result;if(v=A,i.charCodeAt(A)===60?(w=T,A++):(w=a,Oe===0&&h(Je)),w!==a){if(P=[],X=z(),X!==a)for(;X!==a;)P.push(X),X=z();else P=a;P!==a?(i.charCodeAt(A)===62?(X=I,A++):(X=a,Oe===0&&h(ye)),X!==a?(We=v,v=ka(P)):(A=v,v=a)):(A=v,v=a)}else A=v,v=a;return me[oe]={nextPos:A,result:v},v}function he(){var v,w=A*56+13,P=me[w];return P?(A=P.nextPos,P.result):(v=H(),v===a&&(v=pe(),v===a&&(v=F())),me[w]={nextPos:A,result:v},v)}function se(){var v,w,P,X=A*56+14,oe=me[X];return oe?(A=oe.nextPos,oe.result):(v=A,i.charCodeAt(A)===64?(w=R,A++):(w=a,Oe===0&&h(Ht)),w!==a?(P=z(),P!==a?(We=v,v=ks(P)):(A=v,v=a)):(A=v,v=a),me[X]={nextPos:A,result:v},v)}function ae(){var v,w=A*56+15,P=me[w];return P?(A=P.nextPos,P.result):(v=rr(),v===a&&(v=st(),v===a&&(v=qt(),v===a&&(v=ou(),v===a&&(v=Qt())))),me[w]={nextPos:A,result:v},v)}function Ce(){var v,w,P,X=A*56+16,oe=me[X];return oe?(A=oe.nextPos,oe.result):(v=A,w=ae(),w===a&&(w=Xs()),w!==a?(P=se(),P!==a?(We=v,v=La(w,P)):(A=v,v=a)):(A=v,v=a),me[X]={nextPos:A,result:v},v)}function Se(){var v,w,P,X=A*56+17,oe=me[X];return oe?(A=oe.nextPos,oe.result):(v=A,w=Ce(),w===a&&(w=ae(),w===a&&(w=Xs())),w!==a?(P=qe(),P!==a?(We=v,v=Ls(w,P)):(A=v,v=a)):(A=v,v=a),me[X]={nextPos:A,result:v},v)}function qe(){var v,w,P,X=A*56+18,oe=me[X];return oe?(A=oe.nextPos,oe.result):(v=A,i.charCodeAt(A)===58?(w=L,A++):(w=a,Oe===0&&h(ut)),w!==a?(P=Dt(),P!==a?(We=v,v=Ma(P)):(A=v,v=a)):(A=v,v=a),me[X]={nextPos:A,result:v},v)}function je(){var v,w,P=A*56+19,X=me[P];return X?(A=X.nextPos,X.result):(v=A,mt.test(i.charAt(A))?(w=i.charAt(A),A++):(w=a,Oe===0&&h(It)),w!==a&&(We=v,w=Fr()),v=w,me[P]={nextPos:A,result:v},v)}function Ue(){var v,w=A*56+20,P=me[w];return P?(A=P.nextPos,P.result):(v=Nt(),v===a&&(v=C(),v===a&&(v=je())),me[w]={nextPos:A,result:v},v)}function Nt(){var v,w,P,X,oe=A*56+21,ve=me[oe];return ve?(A=ve.nextPos,ve.result):(v=A,w=D(),w!==a?(i.charCodeAt(A)===47?(P=$,A++):(P=a,Oe===0&&h(Vr)),P!==a?(X=D(),X!==a?(We=v,v=Ms(w,X)):(A=v,v=a)):(A=v,v=a)):(A=v,v=a),me[oe]={nextPos:A,result:v},v)}function Xt(){var v,w,P,X=A*56+22,oe=me[X];if(oe)return A=oe.nextPos,oe.result;if(v=A,w=[],P=E_(),P===a&&(P=Se(),P===a&&(P=Ce(),P===a&&(P=rr(),P===a&&(P=qt(),P===a&&(P=st(),P===a&&(P=Qt(),P===a&&(P=Xs(),P===a&&(P=ou())))))))),P!==a)for(;P!==a;)w.push(P),P=E_(),P===a&&(P=Se(),P===a&&(P=Ce(),P===a&&(P=rr(),P===a&&(P=qt(),P===a&&(P=st(),P===a&&(P=Qt(),P===a&&(P=Xs(),P===a&&(P=ou()))))))));else w=a;return w!==a&&(We=v,w=Ps(w)),v=w,me[X]={nextPos:A,result:v},v}function Dt(){var v,w=A*56+23,P=me[w];return P?(A=P.nextPos,P.result):(v=F(),v===a&&(v=D(),v===a&&(v=O_(),v===a&&(v=cu(),v===a&&(v=er(),v===a&&(v=__()))))),me[w]={nextPos:A,result:v},v)}function er(){var v,w,P,X,oe=A*56+24,ve=me[oe];if(ve)return A=ve.nextPos,ve.result;if(v=A,i.charCodeAt(A)===60?(w=T,A++):(w=a,Oe===0&&h(Je)),w!==a){if(P=[],X=Dt(),X!==a)for(;X!==a;)P.push(X),X=Dt();else P=a;P!==a?(i.charCodeAt(A)===62?(X=I,A++):(X=a,Oe===0&&h(ye)),X!==a?(We=v,v=Pa(P)):(A=v,v=a)):(A=v,v=a)}else A=v,v=a;return me[oe]={nextPos:A,result:v},v}function st(){var v,w,P,X,oe,ve=A*56+25,gt=me[ve];return gt?(A=gt.nextPos,gt.result):(v=A,i.charCodeAt(A)===40?(w=K,A++):(w=a,Oe===0&&h(ht)),w!==a?(i.charCodeAt(A)===58?A++:Oe===0&&h(ut),P=Xt(),P!==a?(X=ft(),X===a&&(X=null),i.charCodeAt(A)===41?(oe=f,A++):(oe=a,Oe===0&&h(Zt)),oe!==a?(We=v,v=Ba(P,X)):(A=v,v=a)):(A=v,v=a)):(A=v,v=a),me[ve]={nextPos:A,result:v},v)}function ft(){var v,w,P,X=A*56+26,oe=me[X];return oe?(A=oe.nextPos,oe.result):(v=A,i.charCodeAt(A)===58?(w=L,A++):(w=a,Oe===0&&h(ut)),w!==a?(P=D(),P!==a?(We=v,v=Bs(P)):(A=v,v=a)):(A=v,v=a),me[X]={nextPos:A,result:v},v)}function rr(){var v,w,P,X,oe=A*56+27,ve=me[oe];return ve?(A=ve.nextPos,ve.result):(v=A,w=st(),w!==a?(P=S_(),P!==a?(X=st(),X!==a?(We=v,v=Ua(w,P,X)):(A=v,v=a)):(A=v,v=a)):(A=v,v=a),me[oe]={nextPos:A,result:v},v)}function Qt(){var v,w,P,X,oe,ve=A*56+28,gt=me[ve];return gt?(A=gt.nextPos,gt.result):(v=A,i.substr(A,2)===E?(w=E,A+=2):(w=a,Oe===0&&h(Ct)),w!==a?(P=Xt(),P!==a?(X=ft(),X===a&&(X=null),i.charCodeAt(A)===93?(oe=S,A++):(oe=a,Oe===0&&h(Be)),oe!==a?(We=v,v=Us(P,X)):(A=v,v=a)):(A=v,v=a)):(A=v,v=a),me[ve]={nextPos:A,result:v},v)}function qt(){var v,w,P,X,oe=A*56+29,ve=me[oe];return ve?(A=ve.nextPos,ve.result):(v=A,i.charCodeAt(A)===91?(w=N,A++):(w=a,Oe===0&&h(Ur)),w!==a?(P=Xt(),P!==a?(i.charCodeAt(A)===93?(X=S,A++):(X=a,Oe===0&&h(Be)),X!==a?(We=v,v=Fa(P)):(A=v,v=a)):(A=v,v=a)):(A=v,v=a),me[oe]={nextPos:A,result:v},v)}function pn(){var v,w=A*56+30,P=me[w];return P?(A=P.nextPos,P.result):(v=D(),v===a&&(v=y()),me[w]={nextPos:A,result:v},v)}function Hs(){var v,w,P,X=A*56+31,oe=me[X];if(oe)return A=oe.nextPos,oe.result;if(v=A,w=[],P=hl(),P===a&&(P=pn()),P!==a)for(;P!==a;)w.push(P),P=hl(),P===a&&(P=pn());else w=a;return w!==a&&(We=v,w=Fs(w)),v=w,me[X]={nextPos:A,result:v},v}function hl(){var v,w,P,X,oe=A*56+32,ve=me[oe];return ve?(A=ve.nextPos,ve.result):(v=A,i.charCodeAt(A)===40?A++:Oe===0&&h(ht),w=pn(),w!==a?(P=S_(),P!==a?(X=Hs(),X!==a?(i.charCodeAt(A)===41?A++:Oe===0&&h(Zt),We=v,v=Ys()):(A=v,v=a)):(A=v,v=a)):(A=v,v=a),me[oe]={nextPos:A,result:v},v)}function Ws(){var v,w,P,X,oe=A*56+33,ve=me[oe];if(ve)return A=ve.nextPos,ve.result;if(v=A,i.charCodeAt(A)===123?(w=k,A++):(w=a,Oe===0&&h(Fn)),w!==a){if(P=[],X=Hs(),X===a&&(X=F()),X!==a)for(;X!==a;)P.push(X),X=Hs(),X===a&&(X=F());else P=a;P!==a?(i.charCodeAt(A)===125?(X=x,A++):(X=a,Oe===0&&h(dt)),X!==a?(We=v,v=un(P)):(A=v,v=a)):(A=v,v=a)}else A=v,v=a;return me[oe]={nextPos:A,result:v},v}function __(){var v,w,P,X,oe=A*56+34,ve=me[oe];return ve?(A=ve.nextPos,ve.result):(v=A,i.charCodeAt(A)===123?(w=k,A++):(w=a,Oe===0&&h(Fn)),w!==a?(P=D(),P===a&&(P=cu()),P!==a?(i.charCodeAt(A)===125?(X=x,A++):(X=a,Oe===0&&h(dt)),X!==a?(We=v,v=bt(P)):(A=v,v=a)):(A=v,v=a)):(A=v,v=a),me[oe]={nextPos:A,result:v},v)}function S_(){var v,w=A*56+35,P=me[w];return P?(A=P.nextPos,P.result):(i.charCodeAt(A)===43?(v=M,A++):(v=a,Oe===0&&h(zr)),v===a&&(i.charCodeAt(A)===45?(v=u,A++):(v=a,Oe===0&&h(hr)),v===a&&(i.charCodeAt(A)===42?(v=G,A++):(v=a,Oe===0&&h(Ir)),v===a&&(i.charCodeAt(A)===47?(v=$,A++):(v=a,Oe===0&&h(Vr)),v===a&&(i.charCodeAt(A)===37?(v=te,A++):(v=a,Oe===0&&h(Ii)),v===a&&(i.charCodeAt(A)===94?(v=ne,A++):(v=a,Oe===0&&h(Rr)),v===a&&(i.charCodeAt(A)===124?(v=_,A++):(v=a,Oe===0&&h(W)),v===a&&(i.charCodeAt(A)===38?(v=re,A++):(v=a,Oe===0&&h(Wt)),v===a&&(i.substr(A,2)===ee?(v=ee,A+=2):(v=a,Oe===0&&h(yn)),v===a&&(i.substr(A,2)===B?(v=B,A+=2):(v=a,Oe===0&&h(ea))))))))))),me[w]={nextPos:A,result:v},v)}function Xs(){var v,w,P=A*56+36,X=me[P];return X?(A=X.nextPos,X.result):(v=A,w=cR(),w===a&&(w=hR(),w===a&&(w=pR(),w===a&&(w=fR(),w===a&&(w=U(),w===a&&(w=dR(),w===a&&(w=fl(),w===a&&(w=sR(),w===a&&(w=F(),w===a&&(w=oR(),w===a&&(w=st(),w===a&&(w=Ws(),w===a&&(w=aR())))))))))))),w!==a&&(We=v,w=$s(w)),v=w,me[P]={nextPos:A,result:v},v)}function aR(){var v,w,P=A*56+37,X=me[P];return X?(A=X.nextPos,X.result):(v=A,i.charCodeAt(A)===124?(w=_,A++):(w=a,Oe===0&&h(W)),w!==a&&(We=v,w=Ri()),v=w,me[P]={nextPos:A,result:v},v)}function ou(){var v,w,P,X,oe=A*56+38,ve=me[oe];return ve?(A=ve.nextPos,ve.result):(v=A,i.charCodeAt(A)===60?(w=T,A++):(w=a,Oe===0&&h(Je)),w!==a?(P=Xt(),P!==a?(i.charCodeAt(A)===62?(X=I,A++):(X=a,Oe===0&&h(ye)),X!==a?(We=v,v=Gs(P)):(A=v,v=a)):(A=v,v=a)):(A=v,v=a),me[oe]={nextPos:A,result:v},v)}function sR(){var v,w,P=A*56+39,X=me[P];return X?(A=X.nextPos,X.result):(v=A,w=lu(),w!==a&&(We=v,w=pi(w)),v=w,me[P]={nextPos:A,result:v},v)}function lu(){var v,w,P,X=A*56+40,oe=me[X];if(oe)return A=oe.nextPos,oe.result;if(v=A,w=[],i.charCodeAt(A)===94?(P=ne,A++):(P=a,Oe===0&&h(Rr)),P===a&&(i.charCodeAt(A)===95?(P=Q,A++):(P=a,Oe===0&&h(li))),P!==a)for(;P!==a;)w.push(P),i.charCodeAt(A)===94?(P=ne,A++):(P=a,Oe===0&&h(Rr)),P===a&&(i.charCodeAt(A)===95?(P=Q,A++):(P=a,Oe===0&&h(li)));else w=a;return w!==a&&(We=v,w=Qs()),v=w,me[X]={nextPos:A,result:v},v}function O_(){var v,w,P=A*56+41,X=me[P];return X?(A=X.nextPos,X.result):(v=A,i.charCodeAt(A)===63?(w=j,A++):(w=a,Oe===0&&h(ta)),w!==a&&(We=v,w=Ni()),v=w,me[P]={nextPos:A,result:v},v)}function cu(){var v,w,P,X,oe,ve,gt=A*56+42,hn=me[gt];return hn?(A=hn.nextPos,hn.result):(v=A,i.charCodeAt(A)===40?(w=K,A++):(w=a,Oe===0&&h(ht)),w!==a?(P=D(),P!==a?(i.charCodeAt(A)===44?(X=m,A++):(X=a,Oe===0&&h(vr)),X!==a?(oe=D(),oe!==a?(i.charCodeAt(A)===41?(ve=f,A++):(ve=a,Oe===0&&h(Zt)),ve!==a?(We=v,v=Ya(P,oe)):(A=v,v=a)):(A=v,v=a)):(A=v,v=a)):(A=v,v=a)):(A=v,v=a),me[gt]={nextPos:A,result:v},v)}function E_(){var v,w,P,X,oe=A*56+43,ve=me[oe];return ve?(A=ve.nextPos,ve.result):(v=A,w=Se(),w===a&&(w=Ce(),w===a&&(w=ae(),w===a&&(w=Xs()))),w!==a?(i.charCodeAt(A)===33?(P=Z,A++):(P=a,Oe===0&&h(cn)),P!==a?(X=D(),X!==a?(We=v,v=$a(w,X)):(A=v,v=a)):(A=v,v=a)):(A=v,v=a),me[oe]={nextPos:A,result:v},v)}function oR(){var v,w,P=A*56+44,X=me[P];return X?(A=X.nextPos,X.result):(v=A,w=Ue(),w!==a&&(We=v,w=qs(w)),v=w,me[P]={nextPos:A,result:v},v)}function lR(){var v,w,P,X=A*56+45,oe=me[X];return oe?(A=oe.nextPos,oe.result):(v=A,w=Ue(),w!==a?(i.charCodeAt(A)===94?(P=ne,A++):(P=a,Oe===0&&h(Rr)),P!==a?(We=v,v=wi(w)):(A=v,v=a)):(A=v,v=a),me[X]={nextPos:A,result:v},v)}function cR(){var v,w,P,X,oe,ve=A*56+46,gt=me[ve];return gt?(A=gt.nextPos,gt.result):(v=A,w=lR(),w===a&&(w=null),i.charCodeAt(A)===114?(P=ue,A++):(P=a,Oe===0&&h(ci)),P!==a?(X=A,Oe++,At.test(i.charAt(A))?(oe=i.charAt(A),A++):(oe=a,Oe===0&&h(An)),Oe--,oe===a?X=void 0:(A=X,X=a),X!==a?(We=v,v=Ga(w)):(A=v,v=a)):(A=v,v=a),me[ve]={nextPos:A,result:v},v)}function fl(){var v,w,P,X,oe,ve=A*56+47,gt=me[ve];return gt?(A=gt.nextPos,gt.result):(v=A,w=lu(),w===a&&(w=null),P=Ue(),P===a&&(P=null),X=uR(),X===a&&(X=null),oe=y(),oe===a&&(oe=O_(),oe===a&&(oe=cu(),oe===a&&(oe=__()))),oe!==a?(We=v,v=Di(w,P,X,oe)):(A=v,v=a),me[ve]={nextPos:A,result:v},v)}function uR(){var v,w,P,X=A*56+48,oe=me[X];if(oe)return A=oe.nextPos,oe.result;if(v=A,w=[],i.charCodeAt(A)===35?(P=le,A++):(P=a,Oe===0&&h(Kt)),P===a&&(i.charCodeAt(A)===98?(P=Ee,A++):(P=a,Oe===0&&h(ui))),P!==a)for(;P!==a;)w.push(P),i.charCodeAt(A)===35?(P=le,A++):(P=a,Oe===0&&h(Kt)),P===a&&(i.charCodeAt(A)===98?(P=Ee,A++):(P=a,Oe===0&&h(ui)));else w=a;return w!==a&&(We=v,w=xi(w)),v=w,me[X]={nextPos:A,result:v},v}function dR(){var v,w,P,X,oe=A*56+49,ve=me[oe];if(ve)return A=ve.nextPos,ve.result;if(v=A,w=fl(),w!==a){if(P=[],X=fl(),X!==a)for(;X!==a;)P.push(X),X=fl();else P=a;P!==a?(X=uu(),X===a&&(X=null),We=v,v=Qa(w,P,X)):(A=v,v=a)}else A=v,v=a;return me[oe]={nextPos:A,result:v},v}function b_(){var v,w,P,X=A*56+50,oe=me[X];if(oe)return A=oe.nextPos,oe.result;if(v=A,w=[],Rt.test(i.charAt(A))?(P=i.charAt(A),A++):(P=a,Oe===0&&h(di)),P!==a)for(;P!==a;)w.push(P),Rt.test(i.charAt(A))?(P=i.charAt(A),A++):(P=a,Oe===0&&h(di));else w=a;return w!==a&&(We=v,w=na()),v=w,me[X]={nextPos:A,result:v},v}function uu(){var v,w,P,X=A*56+51,oe=me[X];return oe?(A=oe.nextPos,oe.result):(v=A,i.charCodeAt(A)===37?(w=te,A++):(w=a,Oe===0&&h(Ii)),w!==a?(P=D(),P!==a?(We=v,v=hi(P)):(A=v,v=a)):(A=v,v=a),me[X]={nextPos:A,result:v},v)}function v_(){var v,w,P=A*56+52,X=me[P];return X?(A=X.nextPos,X.result):(v=A,at.test(i.charAt(A))?(w=i.charAt(A),A++):(w=a,Oe===0&&h(q)),w!==a?($e.test(i.charAt(A))?(i.charAt(A),A++):Oe===0&&h(ie),We=v,v=fr()):(A=v,v=a),me[P]={nextPos:A,result:v},v)}function pR(){var v,w,P,X,oe,ve,gt=A*56+53,hn=me[gt];return hn?(A=hn.nextPos,hn.result):(v=A,w=lu(),w===a&&(w=null),P=Ue(),P===a&&(P=null),X=v_(),X!==a?(i.charCodeAt(A)===94?A++:Oe===0&&h(Rr),oe=b_(),oe!==a?(ve=uu(),ve===a&&(ve=null),We=v,v=qa(w,P,X,oe,ve)):(A=v,v=a)):(A=v,v=a),me[gt]={nextPos:A,result:v},v)}function hR(){var v,w,P,X,oe=A*56+54,ve=me[oe];return ve?(A=ve.nextPos,ve.result):(v=A,i.substr(A,3)===De?(w=De,A+=3):(w=a,Oe===0&&h(de)),w===a&&(i.substr(A,2)===xe?(w=xe,A+=2):(w=a,Oe===0&&h(ge)),w===a&&(i.substr(A,2)===be?(w=be,A+=2):(w=a,Oe===0&&h(Ae)),w===a&&(i.charCodeAt(A)===105?(w=Re,A++):(w=a,Oe===0&&h(Qe)),w===a&&(i.substr(A,3)===ce?(w=ce,A+=3):(w=a,Oe===0&&h(Me)),w===a&&(i.substr(A,2)===ke?(w=ke,A+=2):(w=a,Oe===0&&h(yt)),w===a&&(i.charCodeAt(A)===118?(w=Ze,A++):(w=a,Oe===0&&h(Nr)))))))),w!==a?(i.charCodeAt(A)===94?A++:Oe===0&&h(Rr),P=b_(),P===a&&(P=null),X=uu(),X===a&&(X=null),We=v,v=Xr(w,P,X)):(A=v,v=a),me[oe]={nextPos:A,result:v},v)}function fR(){var v,w,P=A*56+55,X=me[P];return X?(A=X.nextPos,X.result):(v=A,w=v_(),w!==a&&(We=v,w=ia(w)),v=w,me[P]={nextPos:A,result:v},v)}var T_=s.nodeOptions||{};function Ut(v,w,P=void 0){w.text=P||Yr(),w.location=ul();for(var X in T_)(w[X]===void 0||w[X]===null)&&(w[X]=T_[X]);return new v(w)}if(aa=c(),aa!==a&&A===i.length)return aa;throw aa!==a&&Ae.collect("pitch"))}notes(){return this.evaluated.map(e=>e.collect("note"))}sounds(){return this.evaluated.map(e=>e.collect("sound"))}indices(){return this.evaluated.map(e=>e.collect("soundIndex"))}freqs(){return this.evaluated.map(e=>e.collect("freq"))}durations(){return this.evaluated.map(e=>e.collect("duration"))}octaves(){return this.evaluated.map(e=>e.collect("octave"))}retrograde(){return this.evaluated=this.evaluated.reverse(),this}scale(e){return this.applyOptions({scale:e}),this}key(e){return this.applyOptions({key:e}),this}octave(e){return this.applyOptions({octave:e}),this}invert(e){return this.applyOptions({inversion:e}),this}isInOptions(e,t){return this.options.nodeOptions&&this.options.nodeOptions[e]===t}atLast(){return this.index+1>=this.evaluated.length*this.redo}clone(){return ei(this)}notStarted(){return this.index<0}peek(){return this.evaluated[this.index-1||0]}hasStarted(){return this.index>=0}next(){this.index<0&&(this.index=0);const e=this.evaluated[this.index%this.evaluated.length];return this.index++,this.counter++,this.redo>0&&this.index>=this.evaluated.length*this.redo&&(this.index=0,this.evaluated=this.evaluate(this.values)),e}applyOptions(e={}){this.evaluated=this.evaluate(this.evaluated,e),this.applyTransformations()}applyTransformations(){var e;(e=this.globalOptions)!=null&&e.retrograde&&(this.evaluated=this.evaluated.reverse())}update(){return this.evaluated=this.evaluate(this.values),this.applyTransformations(),this}evaluate(e,t={}){let r=e.map(i=>i.evaluate(t)).flat(1/0).filter(i=>i!==void 0);return t.subdivisions&&(r=NI(r)),r}totalDuration(){return this.evaluated.reduce((t,r)=>t+r.collect("duration"),0)}lead(){let e=this.evaluated.findIndex(t=>t instanceof Ra);if(e>=0){for(let t=e+1;t<=this.evaluated.length;t++)if(this.evaluated[t]instanceof Ra){const r=this.evaluated[e],i=this.evaluated[t],s=b3(r.notes(),i.notes()),a=ei(i);a.voiceLeadFromNotes(s,this.options.nodeOptions),this.evaluated[t]=a,e=t}}return this}}const NI=(n,e=void 0)=>n.map(r=>{if(r instanceof vI){const i=r.evaluated.length,s=(e||r.duration)/i;return NI(r.evaluated,s)}else return r.duration=e||r.duration,r}).flat(1/0),C3=n=>{let e={};return WP.forEach(t=>{if(n[t]!==void 0){const r=n[t];e[t]=r,delete n[t]}}),e};class y3{constructor(e,t){b(this,"api");b(this,"settings");b(this,"midiAccess",null);b(this,"midiOutputs",[]);b(this,"currentOutputIndex",0);b(this,"scheduledNotes",{});b(this,"midiInputs",[]);b(this,"currentInputIndex");b(this,"bufferLength",512);b(this,"noteInputBuffer",[]);b(this,"ccInputBuffer",[]);b(this,"activeNotes",[]);b(this,"stickyNotes",[]);b(this,"lastNote");b(this,"lastCC",{});b(this,"lastNoteInChannel",{});b(this,"lastCCInChannel",{});b(this,"midiClockInputIndex");b(this,"midiClockInput");b(this,"lastTimestamp",0);b(this,"midiClockDelta",0);b(this,"lastBPM");b(this,"roundedBPM",0);b(this,"clockBuffer",[]);b(this,"clockBufferLength",24);b(this,"clockTicks",0);b(this,"clockErrorCount",0);b(this,"skipOnError",0);this.api=e,this.settings=t,this.lastBPM=e.bpm(),this.roundedBPM=this.lastBPM,this.initializeMidiAccess()}async initializeMidiAccess(){try{this.midiAccess=await navigator.requestMIDIAccess(),this.midiOutputs=Array.from(this.midiAccess.outputs.values()),this.midiOutputs.length===0&&(console.warn("No MIDI outputs available."),this.currentOutputIndex=-1),this.midiInputs=Array.from(this.midiAccess.inputs.values()),this.midiInputs.length===0?console.warn("No MIDI inputs available."):this.updateInputSelects()}catch(e){console.error("Failed to initialize MIDI:",e)}}getCurrentMidiPort(){return this.midiOutputs.length>0&&this.currentOutputIndex>=0&&this.currentOutputIndex0&&this.currentOutputIndex>=0&&this.currentOutputIndex0){const e=document.getElementById("midi-clock-input"),t=document.getElementById("default-midi-input");e.innerHTML="",t.innerHTML="";const r=document.createElement("option");r.value="-1",r.text="Internal",e.appendChild(r);const i=document.createElement("option");if(i.value="-1",i.text="None",t.appendChild(i),this.midiInputs.forEach((s,a)=>{const o=document.createElement("option");o.value=a.toString(),o.text=s.name||a.toString(),e.appendChild(o),t.appendChild(o.cloneNode(!0))}),this.settings.midi_clock_input){const s=this.getMidiInputIndex(this.settings.midi_clock_input);e.value=s.toString(),s>0&&(this.midiClockInput=this.midiInputs[s],this.registerMidiInputListener(s))}else e.value="-1";if(this.settings.default_midi_input){const s=this.getMidiInputIndex(this.settings.default_midi_input);t.value=s.toString(),s>0&&(this.currentInputIndex=s,this.registerMidiInputListener(s))}else t.value="-1";e.addEventListener("change",s=>{const a=s.target.value;if(a==="-1")this.midiClockInput&&this.midiClockInputIndex!=this.currentInputIndex&&(this.midiClockInput.onmidimessage=null),this.midiClockInput=void 0,this.settings.midi_clock_input=void 0;else{const o=parseInt(a);this.midiClockInputIndex=o,this.midiClockInput&&this.midiClockInputIndex!=this.currentInputIndex&&(this.midiClockInput.onmidimessage=null),this.midiClockInput=this.midiInputs[o],this.registerMidiInputListener(o),this.settings.midi_clock_input=this.midiClockInput.name||void 0}}),t.addEventListener("change",s=>{const a=s.target.value;a==="-1"?(this.currentInputIndex&&this.currentInputIndex!=this.midiClockInputIndex&&this.unregisterMidiInputListener(this.currentInputIndex),this.currentInputIndex=void 0,this.settings.default_midi_input=void 0):(this.currentInputIndex&&this.currentInputIndex!=this.midiClockInputIndex&&this.unregisterMidiInputListener(this.currentInputIndex),this.currentInputIndex=parseInt(a),this.registerMidiInputListener(this.currentInputIndex),this.settings.default_midi_input=this.midiInputs[this.currentInputIndex].name||void 0)})}}registerMidiInputListener(e){if(e!==void 0){const t=this.midiInputs[e];t&&!t.onmidimessage&&(t.onmidimessage=r=>{const i=r;if(t.name===this.settings.midi_clock_input&&(i.data[0]===248?this.skipOnError>0?this.skipOnError-=1:this.onMidiClock(r.timeStamp):i.data[0]===250?(console.log("MIDI start received"),this.api.stop(),this.api.play()):i.data[0]===252?(console.log("MIDI stop received"),this.api.pause()):i.data[0]===251?(console.log("MIDI continue received"),this.api.play()):i.data[0]===254&&console.log("MIDI active sensing received")),t.name===this.settings.default_midi_input){if(i.data[0]>=144&&i.data[0]<=159){const s=i.data[0]-144+1,a=i.data[1],o=i.data[2];this.lastNote={note:a,velocity:o,channel:s,timestamp:r.timeStamp},this.lastNoteInChannel[s]={note:a,velocity:o,channel:s,timestamp:r.timeStamp},this.settings.midi_channels_scripts&&this.api.script(s),this.pushToMidiInputBuffer({note:a,velocity:o,channel:s,timestamp:r.timeStamp}),this.activeNotes.push({note:a,velocity:o,channel:s,timestamp:r.timeStamp}),this.removeFromStickyNotes(a,s)||this.stickyNotes.push({note:a,velocity:o,channel:s,timestamp:r.timeStamp})}if(i.data[0]>=128&&i.data[0]<=143){const s=i.data[0]-128+1,a=i.data[1];this.removeFromActiveNotes(a,s)}if(i.data[0]>=176&&i.data[0]<=191){const s=i.data[0]-176+1,a=i.data[1],o=i.data[2];this.lastCC[a]=o,this.lastCCInChannel[s]?this.lastCCInChannel[s][a]=o:(this.lastCCInChannel[s]={},this.lastCCInChannel[s][a]=o),this.pushToMidiCCBuffer({control:a,value:o,channel:s,timestamp:r.timeStamp})}}})}}removeFromActiveNotes(e,t){const r=this.activeNotes.findIndex(i=>i.note===e&&i.channel===t);r>=0&&this.activeNotes.splice(r,1)}removeFromStickyNotes(e,t){const r=this.stickyNotes.findIndex(i=>i.note===e&&i.channel===t);return r>=0?(this.stickyNotes.splice(r,1),!0):!1}stickyNotesFromChannel(e){return this.stickyNotes.filter(t=>t.channel===e)}activeNotesFromChannel(e){return this.activeNotes.filter(t=>t.channel===e)}killActiveNotes(){this.activeNotes=[]}killActiveNotesFromChannel(e){this.activeNotes=this.activeNotes.filter(t=>t.channel!==e)}pushToMidiInputBuffer(e){this.noteInputBuffer.push(e),this.noteInputBuffer.length>this.bufferLength&&this.noteInputBuffer.shift()}pushToMidiCCBuffer(e){this.ccInputBuffer.push(e),this.ccInputBuffer.length>this.bufferLength&&this.ccInputBuffer.shift()}findNoteFromBufferInChannel(e){const t=this.noteInputBuffer.findIndex(r=>r.channel===e);if(t>=0){const r=this.noteInputBuffer[t];return this.noteInputBuffer.splice(t,1),r}else return}findCCFromBufferInChannel(e){const t=this.ccInputBuffer.findIndex(r=>r.channel===e);if(t>=0){const r=this.ccInputBuffer[t];return this.ccInputBuffer.splice(t,1),r}else return}unregisterMidiInputListener(e){if(e!==void 0){const t=this.midiInputs[e];t&&(t.onmidimessage=null)}}onMidiClock(e){if(this.clockTicks+=1,this.lastTimestamp>0)if(this.lastTimestamp===e)this.clockErrorCount+=1;else if(this.clockErrorCount>0)console.log("Timestamp error count: ",this.clockErrorCount),console.log("Current timestamp: ",e),console.log("Last timestamp: ",this.lastTimestamp),console.log("Last delta: ",this.midiClockDelta),console.log("Current delta: ",e-this.lastTimestamp),console.log("BPMs",this.clockBuffer),this.clockErrorCount=0,this.skipOnError=this.settings.midi_clock_ppqn/4,e=0;else{this.midiClockDelta=e-this.lastTimestamp,this.lastBPM=60*(1e3/this.midiClockDelta/this.settings.midi_clock_ppqn),this.clockBuffer.push(this.lastBPM),this.clockBuffer.length>this.clockBufferLength&&this.clockBuffer.shift();const t=this.estimatedBPM();t!==this.roundedBPM&&(console.log("Estimated BPM: ",t),this.api.bpm(t),this.roundedBPM=t)}this.lastTimestamp=e}estimatedBPM(){const e=this.clockBuffer.reduce((t,r)=>t+r);return Math.round(e/this.clockBuffer.length)}sendMidiClock(){if(!this.midiClockInput){const e=this.midiOutputs[this.currentOutputIndex];e&&e.send([248])}}switchMidiOutput(e){const t=this.getMidiOutputIndex(e);return t!==-1?(this.currentOutputIndex=t,!0):!1}getMidiOutputIndex(e){if(typeof e=="number")return e<0||e>=this.midiOutputs.length?(console.error(`Invalid MIDI output index. Index must be in the range 0-${this.midiOutputs.length-1}.`),this.currentOutputIndex):e;{const t=this.midiOutputs.findIndex(r=>r.name===e);return t!==-1?t:(console.error(`MIDI output "${e}" not found.`),this.currentOutputIndex)}}getMidiInputIndex(e){if(typeof e=="number")return e<0||e>=this.midiInputs.length?(console.error(`Invalid MIDI input index. Index must be in the range 0-${this.midiInputs.length-1}.`),-1):e;{const t=this.midiInputs.findIndex(r=>r.name===e);return t!==-1?t:(console.error(`MIDI input "${e}" not found.`),-1)}}listMidiOutputs(){let e="Available MIDI Outputs: ";return this.midiOutputs.forEach((t,r)=>{e+=`(${r+1}) ${t.name} `}),e}sendMidiNote(e,t,r,i,s=this.currentOutputIndex,a=void 0){typeof s=="string"&&(s=this.getMidiOutputIndex(s));const o=this.midiOutputs[s];if(e=Math.min(Math.max(e,0),127),o){const l=[144+t,e,r],c=[128+t,e,0];o.send(l),a&&this.sendPitchBend(a,t,s);const u=setTimeout(()=>{o.send(c),a&&this.sendPitchBend(8192,t,s),delete this.scheduledNotes[e]},(i-.02)*1e3);this.scheduledNotes[e]=u}else console.error("MIDI output not available.")}sendSysExMessage(e){const t=this.midiOutputs[this.currentOutputIndex];t?t.send(e):console.error("MIDI output not available.")}sendPitchBend(e,t,r=this.currentOutputIndex){(e<0||e>16383)&&console.error("Invalid pitch bend value. Value must be in the range 0-16383."),(t<0||t>15)&&console.error("Invalid MIDI channel. Channel must be in the range 0-15."),typeof r=="string"&&(r=this.getMidiOutputIndex(r));const i=this.midiOutputs[r];if(i){const s=e&127,a=e>>7&127;i.send([224|t,s,a])}else console.error("MIDI output not available.")}sendProgramChange(e,t){const r=this.midiOutputs[this.currentOutputIndex];r?r.send([192+t,e]):console.error("MIDI output not available.")}sendMidiControlChange(e,t,r){const i=this.midiOutputs[this.currentOutputIndex];i?i.send([176+r,e,t]):console.error("MIDI output not available.")}panic(){const e=this.midiOutputs[this.currentOutputIndex];if(e){for(const t in this.scheduledNotes){const r=this.scheduledNotes[t];clearTimeout(r),e.send([128,parseInt(t),0])}this.scheduledNotes={}}else console.error("MIDI output not available.")}}class A3{constructor(e,t,r){b(this,"min");b(this,"max");b(this,"wrap");b(this,"position");this.min=e,this.max=t,this.wrap=r,this.position=0}step(){const e=Math.floor(Math.random()*3)-1;this.position+=e,this.wrap?this.position>this.max?this.position=this.min:this.positionthis.max&&(this.position=this.max)}getPosition(){return this.position}toggleWrap(e){this.wrap=e}}class i_{constructor(e){b(this,"seedValue");b(this,"randomGen",Math.random);b(this,"app");b(this,"values",{});b(this,"evenbar",e=>this.app.clock.time_position.bar%2===0?this.modify(e):this);b(this,"even",e=>this.app.clock.time_position.beat%2===0?this.modify(e):this);b(this,"odd",e=>this.app.clock.time_position.beat%2!==0?this.modify(e):this);b(this,"odds",(e,t)=>this.randomGen()this);b(this,"almostNever",e=>this.odds(.025,e));b(this,"rarely",e=>this.odds(.1,e));b(this,"scarcely",e=>this.odds(.25,e));b(this,"sometimes",e=>this.odds(.5,e));b(this,"often",e=>this.odds(.75,e));b(this,"frequently",e=>this.odds(.9,e));b(this,"almostAlways",e=>this.odds(.985,e));b(this,"always",e=>this.modify(e));b(this,"modify",e=>e(this));b(this,"seed",e=>(this.seedValue=e.toString(),this.randomGen=this.app.api.localSeededRandom(this.seedValue),this));b(this,"clear",()=>(this.app.api.clearLocalSeed(this.seedValue),this));b(this,"apply",e=>this.modify(e));b(this,"length",e=>(this.values.length=e,this));this.app=e,this.app.api.currentSeed&&(this.randomGen=this.app.api.randomGen)}}class wI extends i_{constructor(t){super(t);b(this,"octave",t=>(this.values.octave=t,this.update(),this));b(this,"key",t=>(this.values.key=t,this.update(),this));b(this,"scale",t=>(e_(t)?(this.values.scaleName=t,this.values.parsedScale=vi(t)):this.values.parsedScale=t_(t),this.update(),this));b(this,"freq",t=>{this.values.freq=t;const r=n3(t);return r%1!==0?(this.values.note=Math.floor(r),this.values.bend=TI(r)[1]):this.values.note=r,this});b(this,"update",()=>{})}}let Dr=[],I3=(n,e)=>{let t,r=[],i={lc:0,l:e||0,value:n,set(s){i.value=s,i.notify()},get(){return i.lc||i.listen(()=>{})(),i.value},notify(s){t=r;let a=!Dr.length;for(let o=0;o{r===t&&(r=r.slice());let o=r.indexOf(s);~o&&(r.splice(o,2),i.lc--,i.lc||i.off())}},subscribe(s,a){let o=i.listen(s,a);return s(i.value),o},off(){}};return i},R3=(n={})=>{let e=I3(n);return e.setKey=function(t,r){typeof r>"u"?t in e.value&&(e.value={...e.value},delete e.value[t],e.notify(t)):e.value[t]!==r&&(e.value={...e.value,[t]:r},e.notify(t))},e};if(typeof DelayNode<"u"){class n extends DelayNode{constructor(t,r,i,s){super(t),r=Math.abs(r),this.delayTime.value=i;const a=t.createGain();a.gain.value=Math.min(Math.abs(s),.995),this.feedback=a.gain;const o=t.createGain();return o.gain.value=r,this.delayGain=o,this.connect(a),this.connect(o),a.connect(this),this.connect=l=>o.connect(l),this}start(t){this.delayGain.gain.setValueAtTime(this.delayGain.gain.value,t+this.delayTime.value)}}AudioContext.prototype.createFeedbackDelay=function(e,t,r){return new n(this,e,t,r)}}typeof AudioContext<"u"&&(AudioContext.prototype.impulseResponse=function(n,e=1){const t=this.sampleRate*n,r=this.createBuffer(e,t,this.sampleRate),i=r.getChannelData(0);for(let s=0;s(e.buffer=this.impulseResponse(t),e.duration=n,e),e.setDuration(n),e});var _E={a:{freqs:[660,1120,2750,3e3,3350],gains:[1,.5012,.0708,.0631,.0126],qs:[80,90,120,130,140]},e:{freqs:[440,1800,2700,3e3,3300],gains:[1,.1995,.1259,.1,.1],qs:[70,80,100,120,120]},i:{freqs:[270,1850,2900,3350,3590],gains:[1,.0631,.0631,.0158,.0158],qs:[40,90,100,120,120]},o:{freqs:[430,820,2700,3e3,3300],gains:[1,.3162,.0501,.0794,.01995],qs:[40,80,100,120,120]},u:{freqs:[370,630,2750,3e3,3400],gains:[1,.1,.0708,.0316,.01995],qs:[40,60,100,120,120]}};if(typeof GainNode<"u"){class n extends GainNode{constructor(t,r){if(super(t),!_E[r])throw new Error("vowel: unknown vowel "+r);const{gains:i,qs:s,freqs:a}=_E[r],o=t.createGain();for(let l=0;l<5;l++){const c=t.createGain();c.gain.value=i[l];const u=t.createBiquadFilter();u.type="bandpass",u.Q.value=s[l],u.frequency.value=a[l],this.connect(u),u.connect(c),c.connect(o)}return o.gain.value=8,this.connect=l=>o.connect(l),this}}AudioContext.prototype.createVowelFilter=function(e){return new n(this,e)}}const N3=n=>{var i;if(typeof n!="string")return[];const[e,t="",r]=((i=n.match(/^([a-gA-G])([#bsf]*)([0-9]*)$/))==null?void 0:i.slice(1))||[];return e?[e,t,r?Number(r):void 0]:[]},w3={c:0,d:2,e:4,f:5,g:7,a:9,b:11},D3={"#":1,b:-1,s:1,f:-1},nu=(n,e=3)=>{const[t,r,i=e]=N3(n);if(!t)throw new Error('not a note: "'+n+'"');const s=w3[t.toLowerCase()],a=(r==null?void 0:r.split("").reduce((o,l)=>o+D3[l],0))||0;return(Number(i)+1)*12+s+a},DI=n=>Math.pow(2,(n-69)/12)*440,Qm=(n,e,t)=>Math.min(Math.max(n,e),t),x3=n=>12*Math.log(n/440)/Math.LN2+69,k3=(n,e)=>{if(typeof n!="object")throw new Error("valueToMidi: expected object value");let{freq:t,note:r}=n;if(typeof t=="number")return x3(t);if(typeof r=="string")return nu(r);if(typeof r=="number")return r;if(!e)throw new Error("valueToMidi: expected freq or note to be set");return e},L3="data:application/javascript;base64,Ly8gTElDRU5TRSBHTlUgR2VuZXJhbCBQdWJsaWMgTGljZW5zZSB2My4wIHNlZSBodHRwczovL2dpdGh1Yi5jb20vZGt0cjAvV2ViRGlydC9ibG9iL21haW4vTElDRU5TRQovLyBhbGwgdGhlIGNyZWRpdCBnb2VzIHRvIGRrdHIwJ3Mgd2ViZGlydDogaHR0cHM6Ly9naXRodWIuY29tL2RrdHIwL1dlYkRpcnQvYmxvYi81Y2UzZDY5ODM2MmM1NGQ2ZTFiNjhhY2M0N2ViMjk1NWFjNjJjNzkzL2Rpc3QvQXVkaW9Xb3JrbGV0cy5qcwovLyA8MwoKY2xhc3MgQ29hcnNlUHJvY2Vzc29yIGV4dGVuZHMgQXVkaW9Xb3JrbGV0UHJvY2Vzc29yIHsKICBzdGF0aWMgZ2V0IHBhcmFtZXRlckRlc2NyaXB0b3JzKCkgewogICAgcmV0dXJuIFt7IG5hbWU6ICdjb2Fyc2UnLCBkZWZhdWx0VmFsdWU6IDEgfV07CiAgfQoKICBjb25zdHJ1Y3RvcigpIHsKICAgIHN1cGVyKCk7CiAgICB0aGlzLm5vdFN0YXJ0ZWQgPSB0cnVlOwogIH0KCiAgcHJvY2VzcyhpbnB1dHMsIG91dHB1dHMsIHBhcmFtZXRlcnMpIHsKICAgIGNvbnN0IGlucHV0ID0gaW5wdXRzWzBdOwogICAgY29uc3Qgb3V0cHV0ID0gb3V0cHV0c1swXTsKICAgIGNvbnN0IGNvYXJzZSA9IHBhcmFtZXRlcnMuY29hcnNlOwogICAgY29uc3QgYmxvY2tTaXplID0gMTI4OwogICAgY29uc3QgaGFzSW5wdXQgPSAhKGlucHV0WzBdID09PSB1bmRlZmluZWQpOwogICAgaWYgKGhhc0lucHV0KSB7CiAgICAgIHRoaXMubm90U3RhcnRlZCA9IGZhbHNlOwogICAgICBvdXRwdXRbMF1bMF0gPSBpbnB1dFswXVswXTsKICAgICAgZm9yIChsZXQgbiA9IDE7IG4gPCBibG9ja1NpemU7IG4rKykgewogICAgICAgIGZvciAobGV0IG8gPSAwOyBvIDwgb3V0cHV0Lmxlbmd0aDsgbysrKSB7CiAgICAgICAgICBvdXRwdXRbb11bbl0gPSBuICUgY29hcnNlID09IDAgPyBpbnB1dFswXVtuXSA6IG91dHB1dFtvXVtuIC0gMV07CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICByZXR1cm4gdGhpcy5ub3RTdGFydGVkIHx8IGhhc0lucHV0OwogIH0KfQoKcmVnaXN0ZXJQcm9jZXNzb3IoJ2NvYXJzZS1wcm9jZXNzb3InLCBDb2Fyc2VQcm9jZXNzb3IpOwoKY2xhc3MgQ3J1c2hQcm9jZXNzb3IgZXh0ZW5kcyBBdWRpb1dvcmtsZXRQcm9jZXNzb3IgewogIHN0YXRpYyBnZXQgcGFyYW1ldGVyRGVzY3JpcHRvcnMoKSB7CiAgICByZXR1cm4gW3sgbmFtZTogJ2NydXNoJywgZGVmYXVsdFZhbHVlOiAwIH1dOwogIH0KCiAgY29uc3RydWN0b3IoKSB7CiAgICBzdXBlcigpOwogICAgdGhpcy5ub3RTdGFydGVkID0gdHJ1ZTsKICB9CgogIHByb2Nlc3MoaW5wdXRzLCBvdXRwdXRzLCBwYXJhbWV0ZXJzKSB7CiAgICBjb25zdCBpbnB1dCA9IGlucHV0c1swXTsKICAgIGNvbnN0IG91dHB1dCA9IG91dHB1dHNbMF07CiAgICBjb25zdCBjcnVzaCA9IHBhcmFtZXRlcnMuY3J1c2g7CiAgICBjb25zdCBibG9ja1NpemUgPSAxMjg7CiAgICBjb25zdCBoYXNJbnB1dCA9ICEoaW5wdXRbMF0gPT09IHVuZGVmaW5lZCk7CiAgICBpZiAoaGFzSW5wdXQpIHsKICAgICAgdGhpcy5ub3RTdGFydGVkID0gZmFsc2U7CiAgICAgIGlmIChjcnVzaC5sZW5ndGggPT09IDEpIHsKICAgICAgICBjb25zdCB4ID0gTWF0aC5wb3coMiwgY3J1c2hbMF0gLSAxKTsKICAgICAgICBmb3IgKGxldCBuID0gMDsgbiA8IGJsb2NrU2l6ZTsgbisrKSB7CiAgICAgICAgICBjb25zdCB2YWx1ZSA9IE1hdGgucm91bmQoaW5wdXRbMF1bbl0gKiB4KSAvIHg7CiAgICAgICAgICBmb3IgKGxldCBvID0gMDsgbyA8IG91dHB1dC5sZW5ndGg7IG8rKykgewogICAgICAgICAgICBvdXRwdXRbb11bbl0gPSB2YWx1ZTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgZm9yIChsZXQgbiA9IDA7IG4gPCBibG9ja1NpemU7IG4rKykgewogICAgICAgICAgbGV0IHggPSBNYXRoLnBvdygyLCBjcnVzaFtuXSAtIDEpOwogICAgICAgICAgY29uc3QgdmFsdWUgPSBNYXRoLnJvdW5kKGlucHV0WzBdW25dICogeCkgLyB4OwogICAgICAgICAgZm9yIChsZXQgbyA9IDA7IG8gPCBvdXRwdXQubGVuZ3RoOyBvKyspIHsKICAgICAgICAgICAgb3V0cHV0W29dW25dID0gdmFsdWU7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICByZXR1cm4gdGhpcy5ub3RTdGFydGVkIHx8IGhhc0lucHV0OwogIH0KfQpyZWdpc3RlclByb2Nlc3NvcignY3J1c2gtcHJvY2Vzc29yJywgQ3J1c2hQcm9jZXNzb3IpOwoKY2xhc3MgU2hhcGVQcm9jZXNzb3IgZXh0ZW5kcyBBdWRpb1dvcmtsZXRQcm9jZXNzb3IgewogIHN0YXRpYyBnZXQgcGFyYW1ldGVyRGVzY3JpcHRvcnMoKSB7CiAgICByZXR1cm4gW3sgbmFtZTogJ3NoYXBlJywgZGVmYXVsdFZhbHVlOiAwIH1dOwogIH0KCiAgY29uc3RydWN0b3IoKSB7CiAgICBzdXBlcigpOwogICAgdGhpcy5ub3RTdGFydGVkID0gdHJ1ZTsKICB9CgogIHByb2Nlc3MoaW5wdXRzLCBvdXRwdXRzLCBwYXJhbWV0ZXJzKSB7CiAgICBjb25zdCBpbnB1dCA9IGlucHV0c1swXTsKICAgIGNvbnN0IG91dHB1dCA9IG91dHB1dHNbMF07CiAgICBjb25zdCBzaGFwZTAgPSBwYXJhbWV0ZXJzLnNoYXBlWzBdOwogICAgY29uc3Qgc2hhcGUxID0gc2hhcGUwIDwgMSA/IHNoYXBlMCA6IDEuMCAtIDRlLTEwOwogICAgY29uc3Qgc2hhcGUgPSAoMi4wICogc2hhcGUxKSAvICgxLjAgLSBzaGFwZTEpOwogICAgY29uc3QgYmxvY2tTaXplID0gMTI4OwogICAgY29uc3QgaGFzSW5wdXQgPSAhKGlucHV0WzBdID09PSB1bmRlZmluZWQpOwogICAgaWYgKGhhc0lucHV0KSB7CiAgICAgIHRoaXMubm90U3RhcnRlZCA9IGZhbHNlOwogICAgICBmb3IgKGxldCBuID0gMDsgbiA8IGJsb2NrU2l6ZTsgbisrKSB7CiAgICAgICAgY29uc3QgdmFsdWUgPSAoKDEgKyBzaGFwZSkgKiBpbnB1dFswXVtuXSkgLyAoMSArIHNoYXBlICogTWF0aC5hYnMoaW5wdXRbMF1bbl0pKTsKICAgICAgICBmb3IgKGxldCBvID0gMDsgbyA8IG91dHB1dC5sZW5ndGg7IG8rKykgewogICAgICAgICAgb3V0cHV0W29dW25dID0gdmFsdWU7CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICByZXR1cm4gdGhpcy5ub3RTdGFydGVkIHx8IGhhc0lucHV0OwogIH0KfQoKcmVnaXN0ZXJQcm9jZXNzb3IoJ3NoYXBlLXByb2Nlc3NvcicsIFNoYXBlUHJvY2Vzc29yKTsK";function Pc(n){const e=Jt().createGain();return e.gain.value=n,e}const qm=(n,e,t,r,i,s)=>{const a=Jt().createGain();return a.gain.setValueAtTime(0,s),a.gain.linearRampToValueAtTime(i,s+n),a.gain.linearRampToValueAtTime(t*i,s+n+e),{node:a,stop:o=>{a.gain.setValueAtTime(t*i,o),a.gain.linearRampToValueAtTime(0,o+r)}}},M3=(n,e,t,r,i,s)=>{t=Math.max(.001,t),i=Math.max(.001,i);const a=Jt().createGain();return a.gain.setValueAtTime(1e-4,s),a.gain.exponentialRampToValueAtTime(i,s+n),a.gain.exponentialRampToValueAtTime(t*i,s+n+e),{node:a,stop:o=>{a.gain.exponentialRampToValueAtTime(1e-4,o+r)}}},P3=(n,e,t,r,i,s,a,o,l)=>{const c=a-s,u=s+c,p=s+r*c;n.setValueAtTime(s,o),n.linearRampToValueAtTime(u,o+e),n.linearRampToValueAtTime(p,o+e+t),n.setValueAtTime(p,l),n.linearRampToValueAtTime(s,l+Math.max(i,.1))};function Zu(n,e,t,r,i,s,a,o,l,c,u,p=.5){const m=n.createBiquadFilter();if(m.type=e,m.Q.value=r,m.frequency.value=t,!isNaN(l)&&l!==0){const _=l*p,T=Qm(2**-_*t,0,2e4),I=Qm(2**(l-_)*t,0,2e4);return P3(m.frequency,i,s,a,o,T,I,c,u),m}return m}let B3=n=>console.log(n);const ys=(...n)=>B3(...n),a_=R3();function s_(n,e,t={}){a_.setKey(n,{onTrigger:e,data:t})}function SE(n){return a_.get()[n]}let Ku;const Jt=()=>(Ku||(Ku=new AudioContext),Ku);let Ul;const o_=()=>{const n=Jt();return Ul||(Ul=n.createGain(),Ul.connect(n.destination)),Ul};let ju;function U3(){return ju||(ju=Jt().audioWorklet.addModule(L3),ju)}function Ju(n,e,t){const r=new AudioWorkletNode(n,e);return Object.entries(t).forEach(([i,s])=>{r.parameters.get(i).value=s}),r}async function F3(n={}){const{disableWorklets:e=!1}=n;typeof window<"u"&&(await Jt().resume(),e?console.log("disableWorklets: AudioWorklet effects coarse, crush and shape are skipped!"):await U3().catch(t=>{console.warn("could not load AudioWorklet effects coarse, crush and shape",t)}))}async function Y3(n){return new Promise(e=>{document.addEventListener("click",async function t(){await F3(n),e(),document.removeEventListener("click",t)})})}let la={};function $3(n,e,t,r){var i;if(t=Qm(t,0,.98),!la[n]){const s=Jt().createFeedbackDelay(1,e,t);(i=s.start)==null||i.call(s,r),s.connect(o_()),la[n]=s}return la[n].delayTime.value!==e&&la[n].delayTime.setValueAtTime(e,r),la[n].feedback.value!==t&&la[n].feedback.setValueAtTime(t,r),la[n]}let ca={};function G3(n,e=2){if(!ca[n]){const t=Jt().createReverb(e);t.connect(o_()),ca[n]=t}return ca[n].duration!==e&&(ca[n]=ca[n].setDuration(e),ca[n].duration=e),ca[n]}let ua;function Q3(n=2048){if(!ua){const e=Jt().createAnalyser();e.fftSize=n,ua=e,new Float32Array(ua.frequencyBinCount)}return ua.fftSize!==n&&(ua.fftSize=n,new Float32Array(ua.frequencyBinCount)),ua}function ed(n,e,t){const r=Pc(t);return n.connect(r),r.connect(e),r}const OE=async(n,e,t)=>{const r=Jt();if(typeof n!="object")throw new Error(`expected hap.value to be an object, but got "${n}". Hint: append .note() or .s() to the end`,"error");n.duration=t;let i=r.currentTime+e,{s="triangle",bank:a,source:o,gain:l=.8,ftype:c="12db",fanchor:u=.5,cutoff:p,lpenv:m,lpattack:_=.01,lpdecay:T=.01,lpsustain:I=1,lprelease:R=.01,resonance:L=1,hpenv:$,hcutoff:K,hpattack:f=.01,hpdecay:E=.01,hpsustain:S=1,hprelease:N=.01,hresonance:k=1,bpenv:x,bandf:M,bpattack:G=.01,bpdecay:te=.01,bpsustain:ne=1,bprelease:re=.01,bandq:ee=1,coarse:B,crush:Q,shape:j,pan:Z,vowel:ue,delay:le=0,delayfeedback:Ee=.5,delaytime:De=.25,orbit:xe=1,room:be,size:Re=2,velocity:ce=1,analyze:ke,fft:Ze=8}=n;l*=ce;let Le=[];const tt=()=>{Le.forEach(at=>at==null?void 0:at.disconnect())};a&&s&&(s=`${a}_${s}`);let nt;if(o)nt=o(i,n,t);else if(SE(s)){const{onTrigger:at}=SE(s),$e=await at(i,n,tt);$e&&(nt=$e.node,$e.stop(i+t))}else throw new Error(`sound ${s} not found! Is it loaded?`);if(!nt)return;if(r.currentTime>i){ys("[webaudio] skip hap: still loading",r.currentTime-i);return}const ze=[];if(ze.push(nt),ze.push(Pc(l)),p!==void 0){let at=()=>Zu(r,"lowpass",p,L,_,T,I,R,m,i,i+t,u);ze.push(at()),c==="24db"&&ze.push(at())}if(K!==void 0){let at=()=>Zu(r,"highpass",K,k,f,E,S,N,$,i,i+t,u);ze.push(at()),c==="24db"&&ze.push(at())}if(M!==void 0){let at=()=>Zu(r,"bandpass",M,ee,G,te,ne,re,x,i,i+t,u);ze.push(at()),c==="24db"&&ze.push(at())}if(ue!==void 0){const at=r.createVowelFilter(ue);ze.push(at)}if(B!==void 0&&ze.push(Ju(r,"coarse-processor",{coarse:B})),Q!==void 0&&ze.push(Ju(r,"crush-processor",{crush:Q})),j!==void 0&&ze.push(Ju(r,"shape-processor",{shape:j})),Z!==void 0){const at=r.createStereoPanner();at.pan.value=2*Z-1,ze.push(at)}const St=Pc(1);ze.push(St),St.connect(o_());let mt;if(le>0&&De>0&&Ee>0){const at=$3(xe,De,Ee,i);mt=ed(St,at,le)}let At;if(be>0&&Re>0){const at=G3(xe,Re);At=ed(St,at,be)}let Rt;if(ke){const at=Q3(2**(Ze+5));Rt=ed(St,at,ke)}ze.slice(1).reduce((at,$e)=>at.connect($e),ze[0]),Le=ze.concat([mt,At,Rt])},td={};function q3(n,e){var t=e?1e3:1024;if(n=t);return n.toFixed(1)+" "+r[i]}const V3=async(n,e,t,r,i,s,a)=>{let o=0;i!==void 0&&t!==void 0&&ys("[sampler] hap has note and freq. ignoring note","warning");let l=k3({freq:i,note:t},36);o=l-36;const c=Jt();let u;if(Array.isArray(s))u=s[e%s.length];else{const T=R=>nu(R)-l,I=Object.keys(s).filter(R=>!R.startsWith("_")).reduce((R,L,$)=>!R||Math.abs(T(L)){const i=t?`sound "${t}:${r}"`:"sample";if(!td[n]){ys(`[sampler] load ${i}..`,"load-sample",{url:n});const s=Date.now();td[n]=fetch(n).then(a=>a.arrayBuffer()).then(async a=>{const o=Date.now()-s,l=q3(a.byteLength);return ys(`[sampler] load ${i}... done! loaded ${l} in ${o}ms`,"loaded-sample",{url:n}),await e.decodeAudioData(a)})}return td[n]};function H3(n){const e=Jt(),t=e.createBuffer(n.numberOfChannels,n.length,e.sampleRate);for(let r=0;rObject.entries(n).forEach(([r,i])=>{if(typeof i=="string"&&(i=[i]),typeof i!="object")throw new Error("wrong sample map format for "+r);t=i._base||t;const s=a=>(t+a).replace("github:","https://raw.githubusercontent.com/");Array.isArray(i)?i=i.map(s):i=Object.fromEntries(Object.entries(i).map(([a,o])=>[a,(typeof o=="string"?[o]:o).map(s)])),e(r,i)});let X3={};function Z3(n){const e=Object.entries(X3).find(([t])=>n.startsWith(t));if(e)return e[1]}const $i=async(n,e=n._base||"",t={})=>{if(typeof n=="string"){const s=Z3(n);if(s)return s(n);if(n.startsWith("github:")){let[o,l]=n.split("github:");l=l.endsWith("/")?l.slice(0,-1):l,n=`https://raw.githubusercontent.com/${l}/strudel.json`}if(typeof fetch!="function")return;const a=n.split("/").slice(0,-1).join("/");return typeof fetch>"u"?void 0:fetch(n).then(o=>o.json()).then(o=>$i(o,e||o._base||a,t)).catch(o=>{throw console.error(o),new Error(`error loading "${n}"`)})}const{prebake:r,tag:i}=t;W3(n,(s,a)=>s_(s,(o,l,c)=>K3(o,l,c,a),{type:"sample",samples:a,baseUrl:e,prebake:r,tag:i}),e)},EE=[];async function K3(n,e,t,r,i){let{s,freq:a,unit:o,nudge:l=0,cut:c,loop:u,clip:p=void 0,n:m=0,note:_,speed:T=1,loopBegin:I=0,begin:R=0,loopEnd:L=1,end:$=1}=e;if(T===0)return;u=s.startsWith("wt_")?1:e.loop;const K=Jt(),{attack:f=.001,decay:E=.001,sustain:S=1,release:N=.001}=e,k=n+l,x=await V3(s,m,_,T,a,r,i);if(K.currentTime>n){ys(`[sampler] still loading sound "${s}:${m}"`,"highlight");return}if(!x){ys(`[sampler] could not load "${s}:${m}"`,"error");return}x.playbackRate.value=Math.abs(T)*x.playbackRate.value,o==="c"&&(x.playbackRate.value=x.playbackRate.value*x.buffer.duration*1);const M=R*x.buffer.duration;u&&(x.loop=!0,x.loopStart=I*x.buffer.duration-M,x.loopEnd=L*x.buffer.duration-M),x.start(k,M);const{node:G,stop:te}=qm(f,E,S,N,1,n);x.connect(G);const ne=K.createGain();G.connect(ne),x.onended=function(){x.disconnect(),G.disconnect(),ne.disconnect(),t()};const re={node:ne,bufferSource:x,stop:(ee,B=p===void 0&&u===void 0)=>{let Q=ee;if(B){const j=x.buffer.duration/x.playbackRate.value;Q=n+($-R)*j}x.stop(Q+N),te(Q)}};if(c!==void 0){const ee=EE[c];ee&&(ee.node.gain.setValueAtTime(1,k),ee.node.gain.linearRampToValueAtTime(0,k+.01)),EE[c]=re}return re}const j3=(n,e=1,t="sine")=>{const r=Jt(),i=r.createOscillator();i.type=t,i.frequency.value=n,i.start();const s=new GainNode(r,{gain:e});return i.connect(s),{node:s,stop:a=>i.stop(a)}},J3=(n,e,t,r="sine")=>{const i=n.frequency.value*e,s=i*t;return j3(i,s,r)};function eB(){["sine","square","triangle","sawtooth"].forEach(n=>{s_(n,(e,t,r)=>{let{attack:i=.001,decay:s=.05,sustain:a=.6,release:o=.01,fmh:l=1,fmi:c,fmenv:u="lin",fmattack:p,fmdecay:m,fmsustain:_,fmrelease:T,fmvelocity:I,fmwave:R="sine",vib:L=0,vibmod:$=.5}=t,{n:K,note:f,freq:E}=t;f=f||36,typeof f=="string"&&(f=nu(f)),!E&&typeof f=="number"&&(E=DI(f));const{node:S,stop:N}=rB({t:e,s:n,freq:E,vib:L,vibmod:$,partials:K});let k,x;if(c){const{node:ne,stop:re}=J3(S,l,c,R);[p,m,_,T,I].find(ee=>ee!==void 0)?(p=p??.001,m=m??.001,_=_??1,T=T??.001,I=I??1,x=qm(p,m,_,T,I,e),u==="exp"&&(x=M3(p,m,_,T,I,e),x.node.maxValue=c*2,x.node.minValue=1e-5),ne.connect(x.node),x.node.connect(S.frequency)):ne.connect(S.frequency),k=re}const M=Pc(.3),{node:G,stop:te}=qm(i,s,a,o,1,e);return S.onended=()=>{S.disconnect(),M.disconnect(),r()},{node:S.connect(M).connect(G),stop:ne=>{te(ne),x==null||x.stop(ne);let re=ne+o;N(re),k==null||k(re)}}},{type:"synth",prebake:!0})})}function tB(n,e){const t=new Float32Array(n+1),r=new Float32Array(n+1),i=Jt(),s=i.createOscillator(),a={sawtooth:c=>1/c,square:c=>c%2===0?0:1/c,triangle:c=>c%2===0?0:1/(c*c)};if(!a[e])throw new Error(`unknown wave type ${e}`);t[0]=0,r[0]=0;let o=1;for(;o<=n;)t[o]=a[e](o),r[o]=0,o++;const l=i.createPeriodicWave(t,r);return s.setPeriodicWave(l),s}function rB({s:n,freq:e,t,vib:r,vibmod:i,partials:s}){let a;!s||n==="sine"?(a=Jt().createOscillator(),a.type=n||"triangle"):a=tB(s,n),a.frequency.value=Number(e),a.start(t);let o;if(r>0){o=Jt().createOscillator(),o.frequency.value=r;const l=Jt().createGain();l.gain.value=i*100,o.connect(l),l.connect(a.detune),o.start(t)}return{node:a,stop:l=>{o==null||o.stop(l),a.stop(l)}}}function nB(n=1,e=.05,t=220,r=0,i=0,s=.1,a=0,o=1,l=0,c=0,u=0,p=0,m=0,_=0,T=0,I=0,R=0,L=1,$=0,K=0){let f=Math.PI*2,E=Jt().sampleRate,S=Z=>Z>0?1:-1,N=l*=500*f/E/E,k=t*=(1+e*2*Math.random()-e)*f/E,x=[],M=0,G=0,te=0,ne=1,re=0,ee=0,B=0,Q,j;for(r=r*E+9,$*=E,i*=E,s*=E,R*=E,c*=500*f/E**3,T*=f/E,u*=f/E,p*=E,m=m*E|0,j=r+$+i+s+R|0;te1?a>2?a>3?Math.sin((M%f)**3):Math.max(Math.min(Math.tan(M),1),-1):1-(2*M/f%2+2)%2:1-4*Math.abs(Math.round(M/f)-M/f):Math.sin(M),B=(m?1-K+K*Math.sin(f*te/m):1)*S(B)*Math.abs(B)**o*n*1*(tete?0:(tep&&(t+=u,k+=u,ne=0),m&&!(++re%m)&&(t=k,l=N,ne||(ne=1));return x}const iB=(n,e)=>{let{s:t,note:r=36,freq:i,zrand:s=0,attack:a=0,decay:o=0,sustain:l=.8,release:c=.1,curve:u=1,slide:p=0,deltaSlide:m=0,pitchJump:_=0,pitchJumpTime:T=0,lfo:I=0,noise:R=0,zmod:L=0,zcrush:$=0,zdelay:K=0,tremolo:f=0,duration:E=.2,zzfx:S}=n;const N=Math.max(E-a-o,0);typeof r=="string"&&(r=nu(r)),!i&&typeof r=="number"&&(i=DI(r)),t=t.replace("z_","");const k=["sine","triangle","sawtooth","tan","noise"].indexOf(t)||0;u=t==="square"?0:u;const x=nB(...S||[.25,s,i,a,N,c,k,u,p,m,_,T,I,R,L,$,K,l,o,f]),M=Jt(),G=M.createBuffer(1,x.length,M.sampleRate);G.getChannelData(0).set(x);const te=Jt().createBufferSource();return te.buffer=G,te.start(e),{node:te}};function aB(){["zzfx","z_sine","z_sawtooth","z_triangle","z_square","z_tan","z_noise"].forEach(n=>{s_(n,(e,t,r)=>{const{node:i}=iB({s:n,...t},e);return i.onended=()=>{i.disconnect(),r()},{node:i,stop:()=>{}}},{type:"synth",prebake:!0})})}class Vm extends wI{constructor(t,r){super(r);b(this,"nudge");b(this,"volume",t=>this.updateValue("volume",t));b(this,"vol",this.volume);b(this,"zrand",t=>this.updateValue("zrand",t));b(this,"curve",t=>this.updateValue("curve",t));b(this,"slide",t=>this.updateValue("slide",t));b(this,"sld",this.slide);b(this,"deltaSlide",t=>this.updateValue("deltaSlide",t));b(this,"dslide",this.deltaSlide);b(this,"pitchJump",t=>this.updateValue("pitchJump",t));b(this,"pj",this.pitchJump);b(this,"pitchJumpTime",t=>this.updateValue("pitchJumpTime",t));b(this,"pjt",this.pitchJumpTime);b(this,"lfo",t=>this.updateValue("lfo",t));b(this,"noise",t=>this.updateValue("noise",t));b(this,"zmod",t=>this.updateValue("zmod",t));b(this,"zcrush",t=>this.updateValue("zcrush",t));b(this,"zdelay",t=>this.updateValue("zdelay",t));b(this,"sustainVolume",t=>this.updateValue("sustainVolume",t));b(this,"tremolo",t=>this.updateValue("tremolo",t));b(this,"dur",t=>this.updateValue("dur",t));b(this,"zzfx",t=>this.updateValue("zzfx",t));b(this,"fmi",t=>this.updateValue("fmi",t));b(this,"fmh",t=>this.updateValue("fmh",t));b(this,"fmenv",t=>this.updateValue("fmenv",t));b(this,"fmattack",t=>this.updateValue("fmattack",t));b(this,"fmatk",this.fmattack);b(this,"fmdecay",t=>this.updateValue("fmdecay",t));b(this,"fmdec",this.fmdecay);b(this,"fmsustain",t=>this.updateValue("fmsustain",t));b(this,"fmsus",this.fmsustain);b(this,"fmrelease",t=>this.updateValue("fmrelease",t));b(this,"fmrel",this.fmrelease);b(this,"fmvelocity",t=>this.updateValue("fmvelocity",t));b(this,"fmvel",this.fmvelocity);b(this,"fmwave",t=>this.updateValue("fmwave",t));b(this,"fmw",this.fmwave);b(this,"ftype",t=>this.updateValue("ftype",t));b(this,"fanchor",t=>this.updateValue("fanchor",t));b(this,"attack",t=>this.updateValue("attack",t));b(this,"atk",this.attack);b(this,"decay",t=>this.updateValue("decay",t));b(this,"dec",this.decay);b(this,"sustain",t=>this.updateValue("sustain",t));b(this,"sus",this.sustain);b(this,"release",t=>this.updateValue("release",t));b(this,"rel",this.release);b(this,"adsr",(t,r,i,s)=>(this.attack(t),this.decay(r),this.sustain(i),this.release(s),this));b(this,"lpenv",t=>this.updateValue("lpenv",t));b(this,"lpe",t=>this.updateValue("lpenv",t));b(this,"lpattack",t=>this.updateValue("lpattack",t));b(this,"lpa",this.lpattack);b(this,"lpdecay",t=>this.updateValue("lpdecay",t));b(this,"lpd",this.lpdecay);b(this,"lpsustain",t=>this.updateValue("lpsustain",t));b(this,"lps",this.lpsustain);b(this,"lprelease",t=>this.updateValue("lprelease",t));b(this,"lpr",this.lprelease);b(this,"cutoff",t=>this.updateValue("cutoff",t));b(this,"lpf",this.cutoff);b(this,"resonance",t=>this.updateValue("resonance",Math.min(Math.max(t,0),50)));b(this,"lpq",this.resonance);b(this,"lpadsr",(t,r,i,s,a)=>(this.lpenv(t),this.lpattack(r),this.lpdecay(i),this.lpsustain(s),this.lprelease(a),this));b(this,"hpenv",t=>this.updateValue("hpenv",t));b(this,"hpe",t=>this.updateValue("hpe",t));b(this,"hpattack",t=>this.updateValue("hpattack",t));b(this,"hpa",this.hpattack);b(this,"hpdecay",t=>this.updateValue("hpdecay",t));b(this,"hpd",this.hpdecay);b(this,"hpsustain",t=>this.updateValue("hpsustain",t));b(this,"hpsus",this.hpsustain);b(this,"hprelease",t=>this.updateValue("hprelease",t));b(this,"hpr",this.hprelease);b(this,"hcutoff",t=>this.updateValue("hcutoff",t));b(this,"hpf",this.hcutoff);b(this,"hresonance",t=>this.updateValue("hresonance",t));b(this,"hpq",this.hresonance);b(this,"hpadsr",(t,r,i,s,a)=>(this.hpenv(t),this.hpattack(r),this.hpdecay(i),this.hpsustain(s),this.hprelease(a),this));b(this,"bpenv",t=>this.updateValue("bpenv",t));b(this,"bpe",t=>this.updateValue("bpe",t));b(this,"bpattack",t=>this.updateValue("bpattack",t));b(this,"bpa",this.bpattack);b(this,"bpdecay",t=>this.updateValue("bpdecay",t));b(this,"bpd",this.bpdecay);b(this,"bpsustain",t=>this.updateValue("bpsustain",t));b(this,"bps",this.bpsustain);b(this,"bprelease",t=>this.updateValue("bprelease",t));b(this,"bpr",this.bprelease);b(this,"bandf",t=>this.updateValue("bandf",t));b(this,"bpf",this.bandf);b(this,"bandq",t=>this.updateValue("bandq",t));b(this,"bpq",this.bandq);b(this,"bpadsr",(t,r,i,s,a)=>(this.bpenv(t),this.bpattack(r),this.bpdecay(i),this.bpsustain(s),this.bprelease(a),this));b(this,"freq",t=>this.updateValue("freq",t));b(this,"f",this.freq);b(this,"vib",t=>this.updateValue("vib",t));b(this,"vibmod",t=>this.updateValue("vibmod",t));b(this,"fm",t=>{if(typeof t=="number")this.values.fmi=t;else{let r=t.split(":");this.values.fmi=parseFloat(r[0]),r.length>1&&(this.values.fmh=parseFloat(r[1]))}return this});b(this,"loop",t=>this.updateValue("loop",t));b(this,"loopBegin",t=>this.updateValue("loopBegin",t));b(this,"loopEnd",t=>this.updateValue("loopEnd",t));b(this,"begin",t=>this.updateValue("begin",t));b(this,"end",t=>this.updateValue("end",t));b(this,"gain",t=>this.updateValue("gain",t));b(this,"dbgain",t=>this.updateValue("gain",Math.min(Math.pow(10,t/20),10)));b(this,"db",this.dbgain);b(this,"velocity",t=>this.updateValue("velocity",t));b(this,"vel",this.velocity);b(this,"pan",t=>this.updateValue("pan",t));b(this,"sound",t=>this.updateValue("s",t));b(this,"chord",(t,...r)=>(typeof t=="string"?t=f3(t).map(s=>({note:s,freq:Zn(s)})):t instanceof Array&&typeof t[0]=="number"?t=t.map(i=>({note:i,freq:Zn(i)})):typeof t=="number"&&r.length>0&&(t=[t,...r].map(i=>({note:i,freq:Zn(i)}))),this.updateValue("chord",t)));b(this,"invert",(t=0)=>{if(this.values.chord){let r=this.values.chord.map(s=>s.note);r=t<0?[...r].reverse():r;for(let s=0;s({note:s,freq:Zn(s)}));return this.updateValue("chord",i)}else return this});b(this,"snd",this.sound);b(this,"cut",t=>this.updateValue("cut",t));b(this,"clip",t=>this.updateValue("clip",t));b(this,"n",t=>this.updateValue("n",t));b(this,"note",t=>typeof t=="string"?this.updateValue("note",oi(t)):typeof t==null||t==null?this.updateValue("note",0).updateValue("gain",0):this.updateValue("note",t));b(this,"speed",t=>this.updateValue("speed",t));b(this,"spd",this.speed);b(this,"coarse",t=>this.updateValue("coarse",t));b(this,"crush",t=>this.updateValue("crush",t));b(this,"shape",t=>this.updateValue("shape",t));b(this,"vowel",t=>this.updateValue("vowel",t));b(this,"vow",this.vowel);b(this,"delay",t=>this.updateValue("delay",t));b(this,"del",this.delay);b(this,"delayfeedback",t=>this.updateValue("delayfeedback",t));b(this,"delayfb",this.delayfeedback);b(this,"delaytime",t=>this.updateValue("delaytime",t));b(this,"delayt",this.delaytime);b(this,"orbit",t=>this.updateValue("orbit",t));b(this,"o",this.orbit);b(this,"room",t=>this.updateValue("room",t));b(this,"rm",this.room);b(this,"size",t=>this.updateValue("size",t));b(this,"sz",this.size);b(this,"stretch",t=>(this.updateValue("unit","c"),this.updateValue("speed",1/t),this.updateValue("cut",t),this));b(this,"modify",t=>{const r=t(this);return r instanceof Object?r:(t(this.values),this.update(),this)});b(this,"update",()=>{const[t,r]=r_(this.values.key||"C4",this.values.pitch||0,this.values.parsedScale||"MAJOR",this.values.octave||0);this.values.freq=Zn(t)});b(this,"out",()=>{this.values.chord?this.values.chord.forEach(t=>{const r={...this.values};r.freq=t.freq,OE(r,this.nudge,this.values.dur)}):OE(this.values,this.nudge,this.values.dur)});this.app=r,this.nudge=r.dough_nudge/100,typeof t=="string"?t.includes(":")?this.values={s:t.split(":")[0],n:t.split(":")[1],dur:r.clock.convertPulseToSecond(r.clock.ppqn)}:this.values={s:t,dur:.5}:this.values=t}updateValue(t,r){return this.values[t]=r,this}}class zm extends wI{constructor(t,r){super(r);b(this,"midiConnection");b(this,"chord",t=>(this.values.chord=t,this));b(this,"note",t=>(this.values.note=t,this));b(this,"sustain",t=>(this.values.sustain=t,this));b(this,"channel",t=>(this.values.channel=t,this));b(this,"port",t=>(this.values.port=this.midiConnection.getMidiOutputIndex(t),this));b(this,"add",t=>(this.values.note+=t,this));b(this,"modify",t=>{const r=t(this);return r instanceof Object?r:(t(this.values),this.update(),this)});b(this,"bend",t=>(this.values.bend=t,this));b(this,"random",(t=0,r=127)=>(t=Math.min(Math.max(t,0),127),r=Math.min(Math.max(r,0),127),this.values.note=Math.floor(this.randomGen()*(r-t+1))+t,this));b(this,"update",()=>{const[t,r]=r_(this.values.key||"C4",this.values.pitch||0,this.values.parsedScale||"MAJOR",this.values.octave||0);this.values.note=t,this.values.freq=Zn(t),r&&(this.values.bend=r)});b(this,"out",()=>{function t(r,i){const s=i&&i.channel?i.channel:0,a=r.values.channel?r.values.channel:s,o=r.values.velocity?r.values.velocity:100,l=i&&i.note?i.note:60,c=r.values.note?r.values.note:l,u=r.values.sustain?r.values.sustain*r.app.clock.pulse_duration*r.app.api.ppqn():r.app.clock.pulse_duration*r.app.api.ppqn(),p=r.values.bend?r.values.bend:void 0,m=r.values.port?r.midiConnection.getMidiOutputIndex(r.values.port):r.midiConnection.getCurrentMidiPortIndex();r.midiConnection.sendMidiNote(c,a,o,u,m,p)}this.values.chord?this.values.chord.forEach(r=>{t(this,r)}):t(this)});this.app=r,typeof t=="number"?this.values.note=t:this.values=t,this.midiConnection=r.api.MidiConnection}}const lo=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,xI=new Set,Hm=typeof process=="object"&&process?process:{},kI=(n,e,t,r)=>{typeof Hm.emitWarning=="function"?Hm.emitWarning(n,e,t,r):console.error(`[${t}] ${e}: ${n}`)};let Bc=globalThis.AbortController,bE=globalThis.AbortSignal;var dT;if(typeof Bc>"u"){bE=class{constructor(){b(this,"onabort");b(this,"_onabort",[]);b(this,"reason");b(this,"aborted",!1)}addEventListener(r,i){this._onabort.push(i)}},Bc=class{constructor(){b(this,"signal",new bE);e()}abort(r){var i,s;if(!this.signal.aborted){this.signal.reason=r,this.signal.aborted=!0;for(const a of this.signal._onabort)a(r);(s=(i=this.signal).onabort)==null||s.call(i,r)}}};let n=((dT=Hm.env)==null?void 0:dT.LRU_CACHE_IGNORE_AC_WARNING)!=="1";const e=()=>{n&&(n=!1,kI("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e))}}const sB=n=>!xI.has(n),Pi=n=>n&&n===Math.floor(n)&&n>0&&isFinite(n),LI=n=>Pi(n)?n<=Math.pow(2,8)?Uint8Array:n<=Math.pow(2,16)?Uint16Array:n<=Math.pow(2,32)?Uint32Array:n<=Number.MAX_SAFE_INTEGER?ec:null:null;class ec extends Array{constructor(e){super(e),this.fill(0)}}var cs;const ha=class ha{constructor(e,t){b(this,"heap");b(this,"length");if(!V(ha,cs))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0}static create(e){const t=LI(e);if(!t)return[];Xe(ha,cs,!0);const r=new ha(e,t);return Xe(ha,cs,!1),r}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}};cs=new WeakMap,ot(ha,cs,!1);let Wm=ha;var Nn,Jr,wn,Dn,us,nr,xn,ir,Mt,it,xr,en,Tr,dr,kn,pr,gi,_i,Ln,Mn,Qi,kr,Zo,Zm,Oa,Si,Ko,tn,Gc,MI,Ea,ds,jo,qn,Bi,Vn,Ui,Jo,Km,ps,tc,hs,rc,xt,Ft,el,jm,ba,Oo;const g_=class g_{constructor(e){ot(this,Zo);ot(this,Gc);ot(this,qn);ot(this,Vn);ot(this,Jo);ot(this,ps);ot(this,hs);ot(this,xt);ot(this,el);ot(this,ba);ot(this,Nn,void 0);ot(this,Jr,void 0);ot(this,wn,void 0);ot(this,Dn,void 0);ot(this,us,void 0);b(this,"ttl");b(this,"ttlResolution");b(this,"ttlAutopurge");b(this,"updateAgeOnGet");b(this,"updateAgeOnHas");b(this,"allowStale");b(this,"noDisposeOnSet");b(this,"noUpdateTTL");b(this,"maxEntrySize");b(this,"sizeCalculation");b(this,"noDeleteOnFetchRejection");b(this,"noDeleteOnStaleGet");b(this,"allowStaleOnFetchAbort");b(this,"allowStaleOnFetchRejection");b(this,"ignoreFetchAbort");ot(this,nr,void 0);ot(this,xn,void 0);ot(this,ir,void 0);ot(this,Mt,void 0);ot(this,it,void 0);ot(this,xr,void 0);ot(this,en,void 0);ot(this,Tr,void 0);ot(this,dr,void 0);ot(this,kn,void 0);ot(this,pr,void 0);ot(this,gi,void 0);ot(this,_i,void 0);ot(this,Ln,void 0);ot(this,Mn,void 0);ot(this,Qi,void 0);ot(this,kr,void 0);ot(this,Oa,()=>{});ot(this,Si,()=>{});ot(this,Ko,()=>{});ot(this,tn,()=>!1);ot(this,Ea,e=>{});ot(this,ds,(e,t,r)=>{});ot(this,jo,(e,t,r,i)=>{if(r||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});const{max:t=0,ttl:r,ttlResolution:i=1,ttlAutopurge:s,updateAgeOnGet:a,updateAgeOnHas:o,allowStale:l,dispose:c,disposeAfter:u,noDisposeOnSet:p,noUpdateTTL:m,maxSize:_=0,maxEntrySize:T=0,sizeCalculation:I,fetchMethod:R,noDeleteOnFetchRejection:L,noDeleteOnStaleGet:$,allowStaleOnFetchRejection:K,allowStaleOnFetchAbort:f,ignoreFetchAbort:E}=e;if(t!==0&&!Pi(t))throw new TypeError("max option must be a nonnegative integer");const S=t?LI(t):Array;if(!S)throw new Error("invalid max value: "+t);if(Xe(this,Nn,t),Xe(this,Jr,_),this.maxEntrySize=T||V(this,Jr),this.sizeCalculation=I,this.sizeCalculation){if(!V(this,Jr)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(R!==void 0&&typeof R!="function")throw new TypeError("fetchMethod must be a function if specified");if(Xe(this,us,R),Xe(this,Qi,!!R),Xe(this,ir,new Map),Xe(this,Mt,new Array(t).fill(void 0)),Xe(this,it,new Array(t).fill(void 0)),Xe(this,xr,new S(t)),Xe(this,en,new S(t)),Xe(this,Tr,0),Xe(this,dr,0),Xe(this,kn,Wm.create(t)),Xe(this,nr,0),Xe(this,xn,0),typeof c=="function"&&Xe(this,wn,c),typeof u=="function"?(Xe(this,Dn,u),Xe(this,pr,[])):(Xe(this,Dn,void 0),Xe(this,pr,void 0)),Xe(this,Mn,!!V(this,wn)),Xe(this,kr,!!V(this,Dn)),this.noDisposeOnSet=!!p,this.noUpdateTTL=!!m,this.noDeleteOnFetchRejection=!!L,this.allowStaleOnFetchRejection=!!K,this.allowStaleOnFetchAbort=!!f,this.ignoreFetchAbort=!!E,this.maxEntrySize!==0){if(V(this,Jr)!==0&&!Pi(V(this,Jr)))throw new TypeError("maxSize must be a positive integer if specified");if(!Pi(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");Ve(this,Gc,MI).call(this)}if(this.allowStale=!!l,this.noDeleteOnStaleGet=!!$,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!o,this.ttlResolution=Pi(i)||i===0?i:1,this.ttlAutopurge=!!s,this.ttl=r||0,this.ttl){if(!Pi(this.ttl))throw new TypeError("ttl must be a positive integer if specified");Ve(this,Zo,Zm).call(this)}if(V(this,Nn)===0&&this.ttl===0&&V(this,Jr)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!V(this,Nn)&&!V(this,Jr)){const N="LRU_CACHE_UNBOUNDED";sB(N)&&(xI.add(N),kI("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",N,g_))}}static unsafeExposeInternals(e){return{starts:V(e,_i),ttls:V(e,Ln),sizes:V(e,gi),keyMap:V(e,ir),keyList:V(e,Mt),valList:V(e,it),next:V(e,xr),prev:V(e,en),get head(){return V(e,Tr)},get tail(){return V(e,dr)},free:V(e,kn),isBackgroundFetch:t=>{var r;return Ve(r=e,xt,Ft).call(r,t)},backgroundFetch:(t,r,i,s)=>{var a;return Ve(a=e,hs,rc).call(a,t,r,i,s)},moveToTail:t=>{var r;return Ve(r=e,ba,Oo).call(r,t)},indexes:t=>{var r;return Ve(r=e,qn,Bi).call(r,t)},rindexes:t=>{var r;return Ve(r=e,Vn,Ui).call(r,t)},isStale:t=>{var r;return V(r=e,tn).call(r,t)}}}get max(){return V(this,Nn)}get maxSize(){return V(this,Jr)}get calculatedSize(){return V(this,xn)}get size(){return V(this,nr)}get fetchMethod(){return V(this,us)}get dispose(){return V(this,wn)}get disposeAfter(){return V(this,Dn)}getRemainingTTL(e){return V(this,ir).has(e)?1/0:0}*entries(){for(const e of Ve(this,qn,Bi).call(this))V(this,it)[e]!==void 0&&V(this,Mt)[e]!==void 0&&!Ve(this,xt,Ft).call(this,V(this,it)[e])&&(yield[V(this,Mt)[e],V(this,it)[e]])}*rentries(){for(const e of Ve(this,Vn,Ui).call(this))V(this,it)[e]!==void 0&&V(this,Mt)[e]!==void 0&&!Ve(this,xt,Ft).call(this,V(this,it)[e])&&(yield[V(this,Mt)[e],V(this,it)[e]])}*keys(){for(const e of Ve(this,qn,Bi).call(this)){const t=V(this,Mt)[e];t!==void 0&&!Ve(this,xt,Ft).call(this,V(this,it)[e])&&(yield t)}}*rkeys(){for(const e of Ve(this,Vn,Ui).call(this)){const t=V(this,Mt)[e];t!==void 0&&!Ve(this,xt,Ft).call(this,V(this,it)[e])&&(yield t)}}*values(){for(const e of Ve(this,qn,Bi).call(this))V(this,it)[e]!==void 0&&!Ve(this,xt,Ft).call(this,V(this,it)[e])&&(yield V(this,it)[e])}*rvalues(){for(const e of Ve(this,Vn,Ui).call(this))V(this,it)[e]!==void 0&&!Ve(this,xt,Ft).call(this,V(this,it)[e])&&(yield V(this,it)[e])}[Symbol.iterator](){return this.entries()}find(e,t={}){for(const r of Ve(this,qn,Bi).call(this)){const i=V(this,it)[r],s=Ve(this,xt,Ft).call(this,i)?i.__staleWhileFetching:i;if(s!==void 0&&e(s,V(this,Mt)[r],this))return this.get(V(this,Mt)[r],t)}}forEach(e,t=this){for(const r of Ve(this,qn,Bi).call(this)){const i=V(this,it)[r],s=Ve(this,xt,Ft).call(this,i)?i.__staleWhileFetching:i;s!==void 0&&e.call(t,s,V(this,Mt)[r],this)}}rforEach(e,t=this){for(const r of Ve(this,Vn,Ui).call(this)){const i=V(this,it)[r],s=Ve(this,xt,Ft).call(this,i)?i.__staleWhileFetching:i;s!==void 0&&e.call(t,s,V(this,Mt)[r],this)}}purgeStale(){let e=!1;for(const t of Ve(this,Vn,Ui).call(this,{allowStale:!0}))V(this,tn).call(this,t)&&(this.delete(V(this,Mt)[t]),e=!0);return e}dump(){const e=[];for(const t of Ve(this,qn,Bi).call(this,{allowStale:!0})){const r=V(this,Mt)[t],i=V(this,it)[t],s=Ve(this,xt,Ft).call(this,i)?i.__staleWhileFetching:i;if(s===void 0||r===void 0)continue;const a={value:s};if(V(this,Ln)&&V(this,_i)){a.ttl=V(this,Ln)[t];const o=lo.now()-V(this,_i)[t];a.start=Math.floor(Date.now()-o)}V(this,gi)&&(a.size=V(this,gi)[t]),e.unshift([r,a])}return e}load(e){this.clear();for(const[t,r]of e){if(r.start){const i=Date.now()-r.start;r.start=lo.now()-i}this.set(t,r.value,r)}}set(e,t,r={}){var m,_,T,I,R;if(t===void 0)return this.delete(e),this;const{ttl:i=this.ttl,start:s,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:o=this.sizeCalculation,status:l}=r;let{noUpdateTTL:c=this.noUpdateTTL}=r;const u=V(this,jo).call(this,e,t,r.size||0,o);if(this.maxEntrySize&&u>this.maxEntrySize)return l&&(l.set="miss",l.maxEntrySizeExceeded=!0),this.delete(e),this;let p=V(this,nr)===0?void 0:V(this,ir).get(e);if(p===void 0)p=V(this,nr)===0?V(this,dr):V(this,kn).length!==0?V(this,kn).pop():V(this,nr)===V(this,Nn)?Ve(this,ps,tc).call(this,!1):V(this,nr),V(this,Mt)[p]=e,V(this,it)[p]=t,V(this,ir).set(e,p),V(this,xr)[V(this,dr)]=p,V(this,en)[p]=V(this,dr),Xe(this,dr,p),ml(this,nr)._++,V(this,ds).call(this,p,u,l),l&&(l.set="add"),c=!1;else{Ve(this,ba,Oo).call(this,p);const L=V(this,it)[p];if(t!==L){if(V(this,Qi)&&Ve(this,xt,Ft).call(this,L)){L.__abortController.abort(new Error("replaced"));const{__staleWhileFetching:$}=L;$!==void 0&&!a&&(V(this,Mn)&&((m=V(this,wn))==null||m.call(this,$,e,"set")),V(this,kr)&&((_=V(this,pr))==null||_.push([$,e,"set"])))}else a||(V(this,Mn)&&((T=V(this,wn))==null||T.call(this,L,e,"set")),V(this,kr)&&((I=V(this,pr))==null||I.push([L,e,"set"])));if(V(this,Ea).call(this,p),V(this,ds).call(this,p,u,l),V(this,it)[p]=t,l){l.set="replace";const $=L&&Ve(this,xt,Ft).call(this,L)?L.__staleWhileFetching:L;$!==void 0&&(l.oldValue=$)}}else l&&(l.set="update")}if(i!==0&&!V(this,Ln)&&Ve(this,Zo,Zm).call(this),V(this,Ln)&&(c||V(this,Ko).call(this,p,i,s),l&&V(this,Si).call(this,l,p)),!a&&V(this,kr)&&V(this,pr)){const L=V(this,pr);let $;for(;$=L==null?void 0:L.shift();)(R=V(this,Dn))==null||R.call(this,...$)}return this}pop(){var e;try{for(;V(this,nr);){const t=V(this,it)[V(this,Tr)];if(Ve(this,ps,tc).call(this,!0),Ve(this,xt,Ft).call(this,t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(V(this,kr)&&V(this,pr)){const t=V(this,pr);let r;for(;r=t==null?void 0:t.shift();)(e=V(this,Dn))==null||e.call(this,...r)}}}has(e,t={}){const{updateAgeOnHas:r=this.updateAgeOnHas,status:i}=t,s=V(this,ir).get(e);if(s!==void 0){const a=V(this,it)[s];if(Ve(this,xt,Ft).call(this,a)&&a.__staleWhileFetching===void 0)return!1;if(V(this,tn).call(this,s))i&&(i.has="stale",V(this,Si).call(this,i,s));else return r&&V(this,Oa).call(this,s),i&&(i.has="hit",V(this,Si).call(this,i,s)),!0}else i&&(i.has="miss");return!1}peek(e,t={}){const{allowStale:r=this.allowStale}=t,i=V(this,ir).get(e);if(i!==void 0&&(r||!V(this,tn).call(this,i))){const s=V(this,it)[i];return Ve(this,xt,Ft).call(this,s)?s.__staleWhileFetching:s}}async fetch(e,t={}){const{allowStale:r=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:o=this.noDisposeOnSet,size:l=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:u=this.noUpdateTTL,noDeleteOnFetchRejection:p=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:m=this.allowStaleOnFetchRejection,ignoreFetchAbort:_=this.ignoreFetchAbort,allowStaleOnFetchAbort:T=this.allowStaleOnFetchAbort,context:I,forceRefresh:R=!1,status:L,signal:$}=t;if(!V(this,Qi))return L&&(L.fetch="get"),this.get(e,{allowStale:r,updateAgeOnGet:i,noDeleteOnStaleGet:s,status:L});const K={allowStale:r,updateAgeOnGet:i,noDeleteOnStaleGet:s,ttl:a,noDisposeOnSet:o,size:l,sizeCalculation:c,noUpdateTTL:u,noDeleteOnFetchRejection:p,allowStaleOnFetchRejection:m,allowStaleOnFetchAbort:T,ignoreFetchAbort:_,status:L,signal:$};let f=V(this,ir).get(e);if(f===void 0){L&&(L.fetch="miss");const E=Ve(this,hs,rc).call(this,e,f,K,I);return E.__returned=E}else{const E=V(this,it)[f];if(Ve(this,xt,Ft).call(this,E)){const M=r&&E.__staleWhileFetching!==void 0;return L&&(L.fetch="inflight",M&&(L.returnedStale=!0)),M?E.__staleWhileFetching:E.__returned=E}const S=V(this,tn).call(this,f);if(!R&&!S)return L&&(L.fetch="hit"),Ve(this,ba,Oo).call(this,f),i&&V(this,Oa).call(this,f),L&&V(this,Si).call(this,L,f),E;const N=Ve(this,hs,rc).call(this,e,f,K,I),x=N.__staleWhileFetching!==void 0&&r;return L&&(L.fetch=S?"stale":"refresh",x&&S&&(L.returnedStale=!0)),x?N.__staleWhileFetching:N.__returned=N}}get(e,t={}){const{allowStale:r=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,status:a}=t,o=V(this,ir).get(e);if(o!==void 0){const l=V(this,it)[o],c=Ve(this,xt,Ft).call(this,l);return a&&V(this,Si).call(this,a,o),V(this,tn).call(this,o)?(a&&(a.get="stale"),c?(a&&r&&l.__staleWhileFetching!==void 0&&(a.returnedStale=!0),r?l.__staleWhileFetching:void 0):(s||this.delete(e),a&&r&&(a.returnedStale=!0),r?l:void 0)):(a&&(a.get="hit"),c?l.__staleWhileFetching:(Ve(this,ba,Oo).call(this,o),i&&V(this,Oa).call(this,o),l))}else a&&(a.get="miss")}delete(e){var r,i,s,a;let t=!1;if(V(this,nr)!==0){const o=V(this,ir).get(e);if(o!==void 0)if(t=!0,V(this,nr)===1)this.clear();else{V(this,Ea).call(this,o);const l=V(this,it)[o];Ve(this,xt,Ft).call(this,l)?l.__abortController.abort(new Error("deleted")):(V(this,Mn)||V(this,kr))&&(V(this,Mn)&&((r=V(this,wn))==null||r.call(this,l,e,"delete")),V(this,kr)&&((i=V(this,pr))==null||i.push([l,e,"delete"]))),V(this,ir).delete(e),V(this,Mt)[o]=void 0,V(this,it)[o]=void 0,o===V(this,dr)?Xe(this,dr,V(this,en)[o]):o===V(this,Tr)?Xe(this,Tr,V(this,xr)[o]):(V(this,xr)[V(this,en)[o]]=V(this,xr)[o],V(this,en)[V(this,xr)[o]]=V(this,en)[o]),ml(this,nr)._--,V(this,kn).push(o)}}if(V(this,kr)&&((s=V(this,pr))!=null&&s.length)){const o=V(this,pr);let l;for(;l=o==null?void 0:o.shift();)(a=V(this,Dn))==null||a.call(this,...l)}return t}clear(){var e,t,r;for(const i of Ve(this,Vn,Ui).call(this,{allowStale:!0})){const s=V(this,it)[i];if(Ve(this,xt,Ft).call(this,s))s.__abortController.abort(new Error("deleted"));else{const a=V(this,Mt)[i];V(this,Mn)&&((e=V(this,wn))==null||e.call(this,s,a,"delete")),V(this,kr)&&((t=V(this,pr))==null||t.push([s,a,"delete"]))}}if(V(this,ir).clear(),V(this,it).fill(void 0),V(this,Mt).fill(void 0),V(this,Ln)&&V(this,_i)&&(V(this,Ln).fill(0),V(this,_i).fill(0)),V(this,gi)&&V(this,gi).fill(0),Xe(this,Tr,0),Xe(this,dr,0),V(this,kn).length=0,Xe(this,xn,0),Xe(this,nr,0),V(this,kr)&&V(this,pr)){const i=V(this,pr);let s;for(;s=i==null?void 0:i.shift();)(r=V(this,Dn))==null||r.call(this,...s)}}};Nn=new WeakMap,Jr=new WeakMap,wn=new WeakMap,Dn=new WeakMap,us=new WeakMap,nr=new WeakMap,xn=new WeakMap,ir=new WeakMap,Mt=new WeakMap,it=new WeakMap,xr=new WeakMap,en=new WeakMap,Tr=new WeakMap,dr=new WeakMap,kn=new WeakMap,pr=new WeakMap,gi=new WeakMap,_i=new WeakMap,Ln=new WeakMap,Mn=new WeakMap,Qi=new WeakMap,kr=new WeakMap,Zo=new WeakSet,Zm=function(){const e=new ec(V(this,Nn)),t=new ec(V(this,Nn));Xe(this,Ln,e),Xe(this,_i,t),Xe(this,Ko,(s,a,o=lo.now())=>{if(t[s]=a!==0?o:0,e[s]=a,a!==0&&this.ttlAutopurge){const l=setTimeout(()=>{V(this,tn).call(this,s)&&this.delete(V(this,Mt)[s])},a+1);l.unref&&l.unref()}}),Xe(this,Oa,s=>{t[s]=e[s]!==0?lo.now():0}),Xe(this,Si,(s,a)=>{if(e[a]){const o=e[a],l=t[a];s.ttl=o,s.start=l,s.now=r||i();const c=s.now-l;s.remainingTTL=o-c}});let r=0;const i=()=>{const s=lo.now();if(this.ttlResolution>0){r=s;const a=setTimeout(()=>r=0,this.ttlResolution);a.unref&&a.unref()}return s};this.getRemainingTTL=s=>{const a=V(this,ir).get(s);if(a===void 0)return 0;const o=e[a],l=t[a];if(o===0||l===0)return 1/0;const c=(r||i())-l;return o-c},Xe(this,tn,s=>e[s]!==0&&t[s]!==0&&(r||i())-t[s]>e[s])},Oa=new WeakMap,Si=new WeakMap,Ko=new WeakMap,tn=new WeakMap,Gc=new WeakSet,MI=function(){const e=new ec(V(this,Nn));Xe(this,xn,0),Xe(this,gi,e),Xe(this,Ea,t=>{Xe(this,xn,V(this,xn)-e[t]),e[t]=0}),Xe(this,jo,(t,r,i,s)=>{if(Ve(this,xt,Ft).call(this,r))return 0;if(!Pi(i))if(s){if(typeof s!="function")throw new TypeError("sizeCalculation must be a function");if(i=s(r,t),!Pi(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return i}),Xe(this,ds,(t,r,i)=>{if(e[t]=r,V(this,Jr)){const s=V(this,Jr)-e[t];for(;V(this,xn)>s;)Ve(this,ps,tc).call(this,!0)}Xe(this,xn,V(this,xn)+e[t]),i&&(i.entrySize=r,i.totalCalculatedSize=V(this,xn))})},Ea=new WeakMap,ds=new WeakMap,jo=new WeakMap,qn=new WeakSet,Bi=function*({allowStale:e=this.allowStale}={}){if(V(this,nr))for(let t=V(this,dr);!(!Ve(this,Jo,Km).call(this,t)||((e||!V(this,tn).call(this,t))&&(yield t),t===V(this,Tr)));)t=V(this,en)[t]},Vn=new WeakSet,Ui=function*({allowStale:e=this.allowStale}={}){if(V(this,nr))for(let t=V(this,Tr);!(!Ve(this,Jo,Km).call(this,t)||((e||!V(this,tn).call(this,t))&&(yield t),t===V(this,dr)));)t=V(this,xr)[t]},Jo=new WeakSet,Km=function(e){return e!==void 0&&V(this,ir).get(V(this,Mt)[e])===e},ps=new WeakSet,tc=function(e){var s,a;const t=V(this,Tr),r=V(this,Mt)[t],i=V(this,it)[t];return V(this,Qi)&&Ve(this,xt,Ft).call(this,i)?i.__abortController.abort(new Error("evicted")):(V(this,Mn)||V(this,kr))&&(V(this,Mn)&&((s=V(this,wn))==null||s.call(this,i,r,"evict")),V(this,kr)&&((a=V(this,pr))==null||a.push([i,r,"evict"]))),V(this,Ea).call(this,t),e&&(V(this,Mt)[t]=void 0,V(this,it)[t]=void 0,V(this,kn).push(t)),V(this,nr)===1?(Xe(this,Tr,Xe(this,dr,0)),V(this,kn).length=0):Xe(this,Tr,V(this,xr)[t]),V(this,ir).delete(r),ml(this,nr)._--,t},hs=new WeakSet,rc=function(e,t,r,i){const s=t===void 0?void 0:V(this,it)[t];if(Ve(this,xt,Ft).call(this,s))return s;const a=new Bc,{signal:o}=r;o==null||o.addEventListener("abort",()=>a.abort(o.reason),{signal:a.signal});const l={signal:a.signal,options:r,context:i},c=(I,R=!1)=>{const{aborted:L}=a.signal,$=r.ignoreFetchAbort&&I!==void 0;if(r.status&&(L&&!R?(r.status.fetchAborted=!0,r.status.fetchError=a.signal.reason,$&&(r.status.fetchAbortIgnored=!0)):r.status.fetchResolved=!0),L&&!$&&!R)return p(a.signal.reason);const K=_;return V(this,it)[t]===_&&(I===void 0?K.__staleWhileFetching?V(this,it)[t]=K.__staleWhileFetching:this.delete(e):(r.status&&(r.status.fetchUpdated=!0),this.set(e,I,l.options))),I},u=I=>(r.status&&(r.status.fetchRejected=!0,r.status.fetchError=I),p(I)),p=I=>{const{aborted:R}=a.signal,L=R&&r.allowStaleOnFetchAbort,$=L||r.allowStaleOnFetchRejection,K=$||r.noDeleteOnFetchRejection,f=_;if(V(this,it)[t]===_&&(!K||f.__staleWhileFetching===void 0?this.delete(e):L||(V(this,it)[t]=f.__staleWhileFetching)),$)return r.status&&f.__staleWhileFetching!==void 0&&(r.status.returnedStale=!0),f.__staleWhileFetching;if(f.__returned===f)throw I},m=(I,R)=>{var $;const L=($=V(this,us))==null?void 0:$.call(this,e,s,l);L&&L instanceof Promise&&L.then(K=>I(K===void 0?void 0:K),R),a.signal.addEventListener("abort",()=>{(!r.ignoreFetchAbort||r.allowStaleOnFetchAbort)&&(I(void 0),r.allowStaleOnFetchAbort&&(I=K=>c(K,!0)))})};r.status&&(r.status.fetchDispatched=!0);const _=new Promise(m).then(c,u),T=Object.assign(_,{__abortController:a,__staleWhileFetching:s,__returned:void 0});return t===void 0?(this.set(e,T,{...l.options,status:void 0}),t=V(this,ir).get(e)):V(this,it)[t]=T,T},xt=new WeakSet,Ft=function(e){if(!V(this,Qi))return!1;const t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof Bc},el=new WeakSet,jm=function(e,t){V(this,en)[t]=e,V(this,xr)[e]=t},ba=new WeakSet,Oo=function(e){e!==V(this,dr)&&(e===V(this,Tr)?Xe(this,Tr,V(this,xr)[e]):Ve(this,el,jm).call(this,V(this,en)[e],V(this,xr)[e]),Ve(this,el,jm).call(this,V(this,dr),e),Xe(this,dr,e))};let Xm=g_;const Ro=class Ro{constructor(){b(this,"_fallbackMethod",()=>Ro.createSkipProxy());b(this,"out",()=>{})}};b(Ro,"createSkipProxy",()=>{const e=new Ro;return new Proxy(e,{get(t,r,i){return typeof t[r]>"u"?t._fallbackMethod:t[r]},set(t,r,i,s){return!1}})});let Uc=Ro;const No=class No extends i_{constructor(t,r){super(r);b(this,"_fallbackMethod",()=>No.createRestProxy(this.values.length,this.app));b(this,"out",()=>{});this.values.length=t}};b(No,"createRestProxy",(t,r)=>{const i=new No(t,r);return new Proxy(i,{get(s,a,o){return typeof s[a]>"u"?s._fallbackMethod:s[a]},set(s,a,o,l){return!1}})});let Fc=No;class oB extends i_{constructor(t,r,i){super(i);b(this,"input");b(this,"ziffers");b(this,"initCallTime",0);b(this,"startCallTime",0);b(this,"lastCallTime",0);b(this,"waitTime",0);b(this,"startBeat",0);b(this,"played",!1);b(this,"current");b(this,"retro",!1);b(this,"index",-1);b(this,"zid","");b(this,"options",{});b(this,"skipIndex",0);b(this,"endTime",0);b(this,"next",()=>(this.current=this.ziffers.next(),this.played=!0,this.current));b(this,"pulseToSecond",t=>this.app.clock.convertPulseToSecond(t));b(this,"firstRun",()=>this.notStarted());b(this,"atTheBeginning",()=>this.skipIndex===0&&this.ziffers.index<=0);b(this,"origin",()=>this.app.clock.pulses_since_origin+1);b(this,"pulse",()=>this.app.clock.time_position.pulse);b(this,"beat",()=>this.app.clock.time_position.beat);b(this,"nextBeat",()=>this.app.clock.next_beat_in_ticks);b(this,"nextBeatInTicks",()=>this.app.clock.next_beat_in_ticks);b(this,"areWeThereYet",()=>{this.app.clock.pulses_since_origin=this.nextBeatInTicks())&&this.origin()>=this.waitTime,r=this.current&&this.pulseToSecond(this.origin())>=this.pulseToSecond(this.lastCallTime)+this.pulseToSecond(this.current.duration*4*this.app.clock.ppqn)&&this.origin()>=this.waitTime,i=t||r;return this.skipIndex=i?0:this.skipIndex+1,this.index=i?this.index+1:this.index,i&&this.notStarted()&&(this.initCallTime=this.app.clock.pulses_since_origin),this.atTheBeginning()&&(this.startCallTime=this.app.clock.pulses_since_origin),i});b(this,"lead",()=>this.voiceleading());b(this,"invert",t=>(this.atTheBeginning()&&this.ziffers.invert(t),this));b(this,"out",()=>{});this.app=i,this.input=t,this.options=r,this.ziffers=new T3(t,r)}get ticks(){return this.ziffers.duration*4*this.app.clock.ppqn}nextEndTime(){return this.startCallTime+this.ticks}updateLastCallTime(){(this.notStarted()||this.played)&&(this.lastCallTime=this.app.clock.pulses_since_origin,this.played=!1)}notStarted(){return this.ziffers.notStarted()}sound(t){if(this.areWeThereYet()){const r=this.next(),i=this.app.clock.convertPulseToSecond(r.duration*4*this.app.clock.ppqn);if(r instanceof ti){const s=r.getExisting("freq","pitch","key","scale","octave","parsedScale");return r.sound&&(t=r.sound),r.soundIndex&&(s.n=r.soundIndex),s.dur=i,new Vm(s,this.app).sound(t||"sine")}else if(r instanceof Ra){const s=r.pitches.map(o=>o.getExisting("freq","pitch","key","scale","octave","parsedScale")),a={dur:i};return t&&(a.s=t),new Vm(a,this.app).chord(s)}else if(r instanceof $m)return Fc.createRestProxy(r.duration,this.app)}else return Uc.createSkipProxy()}midi(t=void 0){if(this.areWeThereYet()){const r=this.next(),i=r.getExisting("note","pitch","bend","key","scale","octave","parsedScale");if(r instanceof ti){r.soundIndex&&(i.channel=r.soundIndex);const s=new zm(i,this.app);return t?s.note(t):s}else{if(r instanceof $m)return Fc.createRestProxy(r.duration,this.app);if(r instanceof Ra){const s=r.midiChord();return new zm(i,this.app).chord(s)}}}else return Uc.createSkipProxy()}scale(t){return this.atTheBeginning()&&this.ziffers.scale(t),this}key(t){return this.atTheBeginning()&&this.ziffers.key(t),this}octave(t){return this.atTheBeginning()&&this.ziffers.octave(t),this}voiceleading(){return this.atTheBeginning()&&this.ziffers.lead(),this}retrograde(){return this.atTheBeginning()&&this.ziffers.retrograde(),this}wait(t){if(this.atTheBeginning()){if(typeof t=="function"){const r=this.app.api.patternCache.get(t.name);return r&&(this.waitTime=r.nextEndTime()),this}this.waitTime=this.origin()+Math.ceil(t*4*this.app.clock.ppqn)}return this}sync(t){if(this.atTheBeginning()&&this.notStarted()){const r=this.app.clock.pulses_since_origin,i=typeof t=="function"?t.name:t;if(r>0){const s=this.app.api.patternCache.get(i);if(s){const a=s.ziffers.duration,o=s.startCallTime,l=a*4*this.app.clock.ppqn;this.waitTime=o+l}}}return this}}const lB=n=>n[0]==="{"&&n[n.length-1]==="}",co=(n,e)=>{if(lB(n)){const t=JSON.parse(n);return JSON.stringify({...t,...e})}else return JSON.stringify({...e,text:n})},cB=n=>{String.prototype.speak=function(){const e=JSON.parse(this.valueOf());new PI({...e,text:e.text}).speak().then(()=>{}).catch(t=>{console.log("Error speaking:",t)})},String.prototype.rate=function(e){return co(this.valueOf(),{rate:e})},String.prototype.pitch=function(e){return co(this.valueOf(),{pitch:e})},String.prototype.lang=function(e){return co(this.valueOf(),{lang:e})},String.prototype.volume=function(e){return co(this.valueOf(),{volume:e})},String.prototype.voice=function(e){return co(this.valueOf(),{voice:e})},String.prototype.z=function(e={}){return n.z(this.valueOf(),e)},String.prototype.z0=function(e={}){return n.z0(this.valueOf(),e)},String.prototype.z1=function(e={}){return n.z1(this.valueOf(),e)},String.prototype.z2=function(e={}){return n.z2(this.valueOf(),e)},String.prototype.z3=function(e={}){return n.z3(this.valueOf(),e)},String.prototype.z4=function(e={}){return n.z4(this.valueOf(),e)},String.prototype.z5=function(e={}){return n.z5(this.valueOf(),e)},String.prototype.z6=function(e={}){return n.z6(this.valueOf(),e)},String.prototype.z7=function(e={}){return n.z7(this.valueOf(),e)},String.prototype.z8=function(e={}){return n.z8(this.valueOf(),e)},String.prototype.z9=function(e={}){return n.z9(this.valueOf(),e)},String.prototype.z10=function(e={}){return n.z10(this.valueOf(),e)},String.prototype.z11=function(e={}){return n.z11(this.valueOf(),e)},String.prototype.z12=function(e={}){return n.z12(this.valueOf(),e)},String.prototype.z13=function(e={}){return n.z13(this.valueOf(),e)},String.prototype.z14=function(e={}){return n.z14(this.valueOf(),e)},String.prototype.z15=function(e={}){return n.z15(this.valueOf(),e)},String.prototype.z16=function(e={}){return n.z16(this.valueOf(),e)},String.prototype.note=function(){try{return parseInt(this.valueOf())}catch{return oi(this.valueOf())}}};let rd;class PI{constructor(e){b(this,"speak",()=>new Promise((e,t)=>{if(this.options.text){const r=window.speechSynthesis;r.speaking&&r.cancel();const i=new SpeechSynthesisUtterance(this.options.text);i.rate=this.options.rate||1,i.pitch=this.options.pitch||1,i.volume=this.options.volume||1,this.options.voice&&(i.voice=r.getVoices()[this.options.voice]),this.options.lang&&(this.options.lang.length===2?i.lang=`${this.options.lang}-${this.options.lang.toUpperCase()}`:this.options.lang.length===5?i.lang=this.options.lang:i.lang="en-US"),i.onend=()=>{e()},i.onerror=s=>{t(s)},r.speaking?(r.cancel(),rd&&clearTimeout(rd),rd=setTimeout(()=>{r.speak(i)},200)):r.speak(i)}else t("No text provided")}));this.options=e}}async function vE(){return Promise.all([Y3(),$i("github:tidalcycles/Dirt-Samples/master").then(()=>eB()),aB(),$i("github:Bubobubobubobubo/Dough-Fox/main"),$i("github:Bubobubobubobubo/Dough-Samples/main"),$i("github:Bubobubobubobubo/Dough-Amiga/main"),$i("github:Bubobubobubobubo/Dough-Amen/main"),$i("github:Bubobubobubobubo/Dough-Waveforms/main")])}class uB{constructor(e){b(this,"variables",{});b(this,"codeExamples",{});b(this,"counters",{});b(this,"_drunk",new A3(-100,100,!1));b(this,"randomGen",Math.random);b(this,"currentSeed");b(this,"localSeeds",new Map);b(this,"patternCache",new Xm({max:1e3,ttl:1e3*60*5}));b(this,"errorTimeoutID",0);b(this,"printTimeoutID",0);b(this,"MidiConnection");b(this,"load");b(this,"_loadUniverseFromInterface",e=>{this.app.loadUniverse(e),this.app.openBuffersModal()});b(this,"_deleteUniverseFromInterface",e=>{delete this.app.universes[e],this.app.settings.saveApplicationToLocalStorage(this.app.universes,this.app.settings),this.app.updateKnownUniversesView()});b(this,"_playDocExample",e=>{let t=this.app.universes[this.app.selected_universe];this.app.exampleIsPlaying=!0,t.example?t.example.candidate=e||this.app.selectedExample:(t.example={candidate:"",committed:"",evaluations:0},t.example.candidate=e||this.app.selectedExample),this.play()});b(this,"_stopDocExample",()=>{let e=this.app.universes[this.app.selected_universe];(e==null?void 0:e.example)!==void 0&&(this.app.exampleIsPlaying=!1,e.example.candidate="",e.example.committed=""),this.pause()});b(this,"_playDocExampleOnce",e=>{let t=this.app.universes[this.app.selected_universe];(t==null?void 0:t.example)!==void 0&&(t.example.candidate="",t.example.committed=""),this.play(),this.app.exampleIsPlaying=!0,xP(this.app,e)});b(this,"_all_samples",()=>a_.get());b(this,"_reportError",e=>{console.log(e),clearTimeout(this.errorTimeoutID),clearTimeout(this.printTimeoutID),this.app.error_line.innerHTML=e,this.app.error_line.style.color="color-red-800",this.app.error_line.classList.remove("hidden"),this.errorTimeoutID=setTimeout(()=>this.app.error_line.classList.add("hidden"),2e3)});b(this,"_logMessage",e=>{console.log(e),clearTimeout(this.printTimeoutID),clearTimeout(this.errorTimeoutID),this.app.error_line.innerHTML=e,this.app.error_line.style.color="white",this.app.error_line.classList.remove("hidden"),this.printTimeoutID=setTimeout(()=>this.app.error_line.classList.add("hidden"),4e3)});b(this,"time",()=>this.app.audioContext.currentTime);b(this,"play",()=>{this.app.setButtonHighlighting("play",!0),this.MidiConnection.sendStartMessage(),this.app.clock.start()});b(this,"pause",()=>{this.app.setButtonHighlighting("pause",!0),this.MidiConnection.sendStopMessage(),this.app.clock.pause()});b(this,"stop",()=>{this.app.setButtonHighlighting("stop",!0),this.MidiConnection.sendStopMessage(),this.app.clock.stop()});b(this,"silence",this.stop);b(this,"hush",this.stop);b(this,"warp",e=>{this.app.clock.tick=e,this.app.clock.time_position=this.app.clock.convertTicksToTimeposition(e)});b(this,"beat_warp",e=>{this.app.clock.tick=e*this.app.clock.ppqn,this.app.clock.time_position=this.app.clock.convertTicksToTimeposition(e*this.app.clock.ppqn)});b(this,"onmousemove",e=>{this.app._mouseX=e.pageX,this.app._mouseY=e.pageY});b(this,"mouseX",()=>this.app._mouseX);b(this,"mouseY",()=>this.app._mouseY);b(this,"noteX",()=>Math.floor(this.app._mouseX/document.body.clientWidth*127));b(this,"noteY",()=>Math.floor(this.app._mouseY/document.body.clientHeight*127));b(this,"script",(...e)=>{e.forEach(t=>{ls(this.app,this.app.universes[this.app.selected_universe].locals[t])})});b(this,"s",this.script);b(this,"delete_script",e=>{this.app.universes[this.app.selected_universe].locals[e]={candidate:"",committed:"",evaluations:0}});b(this,"cs",this.delete_script);b(this,"copy_script",(e,t)=>{this.app.universes[this.app.selected_universe].locals[t]={...this.app.universes[this.app.selected_universe].locals[e]}});b(this,"cps",this.copy_script);b(this,"copy_universe",(e,t)=>{this.app.universes[t]={...this.app.universes[e]}});b(this,"delete_universe",e=>{this.app.selected_universe===e&&(this.app.selected_universe="Default"),delete this.app.universes[e],this.app.settings.saveApplicationToLocalStorage(this.app.universes,this.app.settings),this.app.updateKnownUniversesView()});b(this,"big_bang",()=>{confirm("Are you sure you want to delete all universes?")&&(this.app.universes={...Ao},this.app.settings.saveApplicationToLocalStorage(this.app.universes,this.app.settings)),this.app.selected_universe="Default",this.app.updateKnownUniversesView()});b(this,"midi_outputs",()=>{this._logMessage(this.MidiConnection.listMidiOutputs())});b(this,"midi_output",e=>{e?this.MidiConnection.switchMidiOutput(e):console.log(this.MidiConnection.getCurrentMidiPort())});b(this,"midi",(e=60,t,r)=>(t!==void 0&&(typeof e=="number"&&(e={note:e}),e.velocity=t),r!==void 0&&(typeof e=="number"&&(e={note:e}),e.channel=r),new zm(e,this.app)));b(this,"sysex",e=>{this.MidiConnection.sendSysExMessage(e)});b(this,"pitch_bend",(e,t)=>{this.MidiConnection.sendPitchBend(e,t)});b(this,"program_change",(e,t)=>{this.MidiConnection.sendProgramChange(e,t)});b(this,"midi_clock",()=>{this.MidiConnection.sendMidiClock()});b(this,"control_change",({control:e=20,value:t=0,channel:r=0})=>{this.MidiConnection.sendMidiControlChange(e,t,r)});b(this,"midi_panic",()=>{this.MidiConnection.panic()});b(this,"active_note_events",e=>{let t;if(e?t=this.MidiConnection.activeNotesFromChannel(e):t=this.MidiConnection.activeNotes,t.length>0)return t});b(this,"active_notes",e=>{const t=this.active_note_events(e);if(t&&t.length>0)return t.map(r=>r.note)});b(this,"kill_active_notes",()=>{this.MidiConnection.activeNotes=[]});b(this,"sticky_notes",e=>{let t;if(e?t=this.MidiConnection.stickyNotesFromChannel(e):t=this.MidiConnection.stickyNotes,t.length>0)return t.map(r=>r.note)});b(this,"kill_sticky_notes",()=>{this.MidiConnection.stickyNotes=[]});b(this,"buffer",e=>e?this.MidiConnection.findNoteFromBufferInChannel(e)!==void 0:this.MidiConnection.noteInputBuffer.length>0);b(this,"buffer_event",e=>e?this.MidiConnection.findNoteFromBufferInChannel(e):this.MidiConnection.noteInputBuffer.shift());b(this,"buffer_note",e=>{const t=this.buffer_event(e);return t?t.note:void 0});b(this,"last_note_event",e=>e?this.MidiConnection.lastNoteInChannel[e]:this.MidiConnection.lastNote);b(this,"last_note",e=>{const t=this.last_note_event(e);return t?t.note:60});b(this,"last_cc",(e,t)=>t?this.MidiConnection.lastCCInChannel[t]?this.MidiConnection.lastCCInChannel[t][e]:64:this.MidiConnection.lastCC[e]||64);b(this,"has_cc",e=>e?this.MidiConnection.findCCFromBufferInChannel(e)!==void 0:this.MidiConnection.ccInputBuffer.length>0);b(this,"buffer_cc",e=>e?this.MidiConnection.findCCFromBufferInChannel(e):this.MidiConnection.ccInputBuffer.shift());b(this,"generateCacheKey",(...e)=>e.map(t=>JSON.stringify(t)).join(","));b(this,"z",(e,t={},r="")=>{const i="z"+r.toString(),s=r===""?this.generateCacheKey(e,t):i;let a;return this.app.api.patternCache.has(s)&&(a=this.app.api.patternCache.get(s),a.input!==e&&(a=void 0)),a||(a=new oB(e,t,this.app),this.app.api.patternCache.set(s,a)),typeof r=="number"&&(a.zid=i),a.updateLastCallTime(),r!==""&&a.sync("z0"),a});b(this,"z0",(e,t={})=>this.z(e,t,0));b(this,"z1",(e,t={})=>this.z(e,t,1));b(this,"z2",(e,t={})=>this.z(e,t,2));b(this,"z3",(e,t={})=>this.z(e,t,3));b(this,"z4",(e,t={})=>this.z(e,t,4));b(this,"z5",(e,t={})=>this.z(e,t,5));b(this,"z6",(e,t={})=>this.z(e,t,6));b(this,"z7",(e,t={})=>this.z(e,t,7));b(this,"z8",(e,t={})=>this.z(e,t,8));b(this,"z9",(e,t={})=>this.z(e,t,9));b(this,"z10",(e,t={})=>this.z(e,t,10));b(this,"z11",(e,t={})=>this.z(e,t,11));b(this,"z12",(e,t={})=>this.z(e,t,12));b(this,"z13",(e,t={})=>this.z(e,t,13));b(this,"z14",(e,t={})=>this.z(e,t,14));b(this,"z15",(e,t={})=>this.z(e,t,15));b(this,"z16",(e,t={})=>this.z(e,t,16));b(this,"counter",(e,t,r)=>(e in this.counters?(this.counters[e].limit!==t&&(this.counters[e].value=0,this.counters[e].limit=t),this.counters[e].step!==r&&(this.counters[e].step=r??this.counters[e].step),this.counters[e].value+=this.counters[e].step,this.counters[e].limit!==void 0&&this.counters[e].value>this.counters[e].limit&&(this.counters[e].value=0)):this.counters[e]={value:0,step:r??1,limit:t},this.counters[e].value));b(this,"$",this.counter);b(this,"i",e=>e!==void 0?(this.app.universes[this.app.selected_universe].global.evaluations=e,this.app.universes[this.app.selected_universe]):this.app.universes[this.app.selected_universe].global.evaluations);b(this,"drunk",e=>e!==void 0?(this._drunk.position=e,this._drunk.getPosition()):(this._drunk.step(),this._drunk.getPosition()));b(this,"drunk_max",e=>{this._drunk.max=e});b(this,"drunk_min",e=>{this._drunk.min=e});b(this,"drunk_wrap",e=>{this._drunk.toggleWrap(e)});b(this,"variable",(e,t)=>typeof e=="string"&&t===void 0?this.variables[e]:(this.variables[e]=t,this.variables[e]));b(this,"v",this.variable);b(this,"delete_variable",e=>{delete this.variables[e]});b(this,"dv",this.delete_variable);b(this,"clear_variables",()=>{this.variables={}});b(this,"cv",this.clear_variables);b(this,"randI",(e,t)=>Math.floor(this.randomGen()*(t-e+1))+e);b(this,"rand",(e,t)=>this.randomGen()*(t-e)+e);b(this,"irand",this.randI);b(this,"rI",this.randI);b(this,"r",this.rand);b(this,"ir",this.randI);b(this,"seed",e=>{typeof e=="number"&&(e=e.toString()),this.currentSeed!==e&&(this.currentSeed=e,this.randomGen=Ym(e))});b(this,"localSeededRandom",e=>{if(typeof e=="number"&&(e=e.toString()),this.localSeeds.has(e))return this.localSeeds.get(e);const t=Ym(e);return this.localSeeds.set(e,t),t});b(this,"clearLocalSeed",(e=void 0)=>{e&&this.localSeeds.delete(e.toString()),this.localSeeds.clear()});b(this,"quantize",(e,t)=>{if(t.length===0)return e;let r=t[0];return t.forEach(i=>{Math.abs(i-e)Math.min(Math.max(e,t),r));b(this,"cmp",this.clamp);b(this,"nudge",e=>(e&&(this.app.clock.nudge=e),this.app.clock.nudge));b(this,"bpm",e=>e===void 0?this.app.clock.bpm:((e<1||e>500)&&console.log(`Setting bpm to ${e}`),this.app.clock.bpm=e,e));b(this,"tempo",this.bpm);b(this,"bpb",e=>e===void 0?this.app.clock.time_signature[0]:(e<1&&console.log(`Setting bpb to ${e}`),this.app.clock.time_signature[0]=e,e));b(this,"ppqn",e=>e===void 0?this.app.clock.ppqn:(e<1&&console.log(`Setting ppqn to ${e}`),this.app.clock.ppqn=e,e));b(this,"time_signature",(e,t)=>{this.app.clock.time_signature=[e,t]});b(this,"prob",e=>this.randomGen()*100this.randomGen()>.5);b(this,"odds",(e,t=1)=>this.randomGen()!1);b(this,"almostNever",(e=1)=>this.randomGen()<.025*this.ppqn()/(this.ppqn()*e));b(this,"rarely",(e=1)=>this.randomGen()<.1*this.ppqn()/(this.ppqn()*e));b(this,"scarcely",(e=1)=>this.randomGen()<.25*this.ppqn()/(this.ppqn()*e));b(this,"sometimes",(e=1)=>this.randomGen()<.5*this.ppqn()/(this.ppqn()*e));b(this,"often",(e=1)=>this.randomGen()<.75*this.ppqn()/(this.ppqn()*e));b(this,"frequently",(e=1)=>this.randomGen()<.9*this.ppqn()/(this.ppqn()*e));b(this,"almostAlways",(e=1)=>this.randomGen()<.985*this.ppqn()/(this.ppqn()*e));b(this,"always",(e=1)=>!0);b(this,"dice",e=>Math.floor(this.randomGen()*e)+1);b(this,"cbar",()=>this.app.clock.time_position.bar+1);b(this,"ctick",()=>this.app.clock.tick+1);b(this,"cpulse",()=>this.app.clock.time_position.pulse+1);b(this,"cbeat",()=>this.app.clock.time_position.beat+1);b(this,"ebeat",()=>this.app.clock.beats_since_origin+1);b(this,"epulse",()=>this.app.clock.pulses_since_origin+1);b(this,"nominator",()=>this.app.clock.time_signature[0]);b(this,"meter",()=>this.app.clock.time_signature[1]);b(this,"denominator",this.meter);b(this,"beat",(...e)=>e.map(r=>this.app.clock.pulses_since_origin%Math.floor(r*this.ppqn())===0).some(r=>r===!0));b(this,"b",this.beat);b(this,"pulse",(...e)=>e.map(r=>this.app.clock.pulses_since_origin%r===0).some(r=>r===!0));b(this,"flip",(e,t=50)=>{let r=e*2;const i=this.app.clock.pulses_since_origin,s=Math.floor(r*this.ppqn()),a=Math.floor(t/100*s);return i%s{let t=e*2;const r=this.app.clock.time_position.bar;return Math.floor(r/t)%2===0});b(this,"onbar",(e,t=this.app.clock.time_signature[0])=>{let r=this.app.clock.time_position.bar%t+1;return typeof e=="number"?e===r:e.some(i=>i==r)});b(this,"onbeat",(...e)=>{let t=[];return e.forEach(r=>{let i=r%this.nominator()||this.nominator(),s=Math.floor(i);s=s==0?this.nominator():s;let a=Math.floor((i-s)*this.ppqn()+1);a<=0&&(a=a+this.ppqn()*this.nominator()),t.push(s===this.cbeat()&&this.cpulse()===a)}),t.some(r=>r==!0)});b(this,"oncount",(e,t)=>{typeof e=="number"&&(e=[e]);const r=this.app.clock.pulses_since_origin;let i=[];return e.forEach(s=>{s=s<1?0:s-1;const a=Math.ceil(s*this.ppqn()),o=r%(this.ppqn()*t);return i.push(o===a)}),i.some(s=>s==!0)});b(this,"oneuclid",(e,t,r=0)=>{const s=this._euclidean_cycle(e,t,r).reduce((a,o,l)=>(o&&a.push(l+1),a),[]);return this.oncount(s,t)});b(this,"delay",(e,t)=>{setTimeout(t,e)});b(this,"delayr",(e,t,r)=>{[...Array(t).keys()].map(s=>e*s).forEach((s,a)=>{setTimeout(r,s)})});b(this,"euclid",(e,t,r,i=0)=>this._euclidean_cycle(t,r,i)[e%r]);b(this,"ec",this.euclid);b(this,"rhythm",(e,t,r,i=0)=>this.beat(e)&&this._euclidean_cycle(t,r,i).beat(e));b(this,"bin",(e,t)=>{let i=t.toString(2).split("").map(s=>s==="1");return i[e%i.length]});b(this,"binrhythm",(e,t)=>{let i=t.toString(2).split("").map(s=>s==="1");return this.beat(e)&&i.beat(e)});b(this,"line",(e,t,r=1)=>{const i=[];if(t>e&&r>0||tMath.sin(this.app.clock.ctx.currentTime*Math.PI*2*e)+t);b(this,"usine",(e=1,t=0)=>(this.sine(e,t)+1)/2);b(this,"saw",(e=1,t=0)=>this.app.clock.ctx.currentTime*e%1*2-1+t);b(this,"usaw",(e=1,t=0)=>(this.saw(e,t)+1)/2);b(this,"triangle",(e=1,t=0)=>Math.abs(this.saw(e,t))*2-1);b(this,"utriangle",(e=1,t=0)=>(this.triangle(e,t)+1)/2);b(this,"square",(e=1,t=0,r=.5)=>{const i=1/e;return(Date.now()/1e3+t)%i/i(this.square(e,t,r)+1)/2);b(this,"noise",()=>this.randomGen()*2-1);b(this,"min",(...e)=>Math.min(...e));b(this,"max",(...e)=>Math.max(...e));b(this,"mean",(...e)=>e.reduce((r,i)=>r+i,0)/e.length);b(this,"limit",(e,t,r)=>Math.min(Math.max(e,t),r));b(this,"abs",Math.abs);b(this,"speak",(e,t="en-US",r=0,i=1,s=1)=>{new PI({text:e,lang:t,voice:r,rate:i,pitch:s}).speak().then(()=>{}).catch(o=>{console.log(o)})});b(this,"stop_hydra",()=>{this.app.hydra.hush()});b(this,"sound",e=>new Vm(e,this.app));b(this,"snd",this.sound);b(this,"samples",$i);b(this,"log",e=>{console.log(e),this._logMessage(e)});b(this,"scale",n_);b(this,"rate",e=>{});b(this,"divseq",(...e)=>{const t=e[0],r=e.slice(1),i=this.app.clock.pulses_since_origin,s=Math.floor(i/Math.floor(t*this.ppqn()));return r[s%r.length]});b(this,"seqbeat",(...e)=>e[this.app.clock.time_position.beat%e.length]);b(this,"seqbar",(...e)=>e[(this.app.clock.time_position.bar+1)%e.length]);b(this,"shuffle",e=>e.sort(()=>this.randomGen()-.5));b(this,"reverse",e=>e.reverse());b(this,"rotate",e=>t=>t.slice(e,t.length).concat(t.slice(0,e)));b(this,"repeat",e=>t=>t.flatMap(r=>Array(e).fill(r)));b(this,"repeatOdd",e=>t=>t.flatMap((r,i)=>i%2===0?Array(e).fill(r):r));b(this,"repeatEven",e=>t=>t.flatMap((r,i)=>i%2!==0?Array(e).fill(r):r));b(this,"palindrome",e=>e.concat(e.slice(0,e.length-1).reverse()));this.app=e,this.MidiConnection=new y3(this,e.settings)}transmission(){return this.MidiConnection.activeNotes.length>0}_euclidean_cycle(e,t,r=0){if(e==t)return Array.from({length:t},()=>!0);function i(o,l){const c=o.length,u=(l+1)%c;return o[l]>o[u]}if(e>=t)return[!0];const s=Array.from({length:t},(o,l)=>(e*(l-1)%t+t)%t);let a=s.map((o,l)=>i(s,l));return r!=0&&(a=a.slice(r).concat(a.slice(0,r))),a}}const dB=n=>{Array.prototype.square=function(){return this.map(e=>e*e)},Array.prototype.sometimes=function(e){return n.randomGen()<.5?e(this):this},Array.prototype.apply=function(e){return e(this)},Array.prototype.sqrt=function(){if(this.some(e=>e<0))throw new Error("Cannot take square root of negative number");return this.map(e=>Math.sqrt(e))},Array.prototype.add=function(e){return this.map(t=>t+e)},Array.prototype.sub=function(e){return this.map(t=>t-e)},Array.prototype.mult=function(e){return this.map(t=>t*e)},Array.prototype.div=function(e){if(e===0)throw new Error("Division by zero");return this.map(t=>t/e)},Array.prototype.pick=function(){return this[Math.floor(n.randomGen()*this.length)]},Array.prototype.gen=function(e,t,r){return r<1?[]:Array.from({length:r},()=>Math.floor(n.randomGen()*(t-e+1))+e)},Array.prototype.bar=function(e=1){return e===1?this[n.app.clock.time_position.bar%this.length]:this[Math.floor(n.app.clock.time_position.bar/e)%this.length]},Array.prototype.beat=function(e=1){const t=e,r=n.app.clock.pulses_since_origin,i=Math.floor(r/Math.floor(t*n.ppqn()));return this[i%this.length]},Array.prototype.b=Array.prototype.beat,Array.prototype.shuffle=function(){let e=this.length,t;for(;e!==0;)t=Math.floor(n.randomGen()*e),e--,[this[e],this[t]]=[this[t],this[e]];return this},Array.prototype.rotate=function(e){const t=this.length;if(e<0)e=t+e%t;else if(e>0)e=e%t;else return this;const r=this.splice(-e,e);return this.unshift(...r),this},Array.prototype.unique=function(){const e=new Set;let t=0;for(let r=0;r100)throw new Error("Amount should be between 0 and 100");if(this.length<=1)return this;for(let t=0;t1)this.splice(t,1);else return this;else t++;return this},Array.prototype.repeat=function(e=1){if(e<1)throw new Error("Amount should be at least 1");let t=[];for(let r=0;r(i%s+s)%s,r=yI(cl(n));return this.map(i=>{const s=Math.floor(i/r.length)*12;return r[t(i,r.length)]+e+s})};Array.prototype.scaleArp=function(n="major",e=0){const t=yI(cl(n));let r=[];e=e>t.length?t.length:e,e=e==0?t.length:e;for(let i=0;i>1|(Bt&21845)<<1;Li=(Li&52428)>>2|(Li&13107)<<2,Li=(Li&61680)>>4|(Li&3855)<<4,tg[Bt]=((Li&65280)>>8|(Li&255)<<8)>>1}var ri=function(n,e,t){for(var r=n.length,i=0,s=new ln(e);i>l]=c}else for(o=new ln(r),i=0;i>15-n[i]);return o},ji=new Sr(288);for(var Bt=0;Bt<144;++Bt)ji[Bt]=8;for(var Bt=144;Bt<256;++Bt)ji[Bt]=9;for(var Bt=256;Bt<280;++Bt)ji[Bt]=7;for(var Bt=280;Bt<288;++Bt)ji[Bt]=8;var Ho=new Sr(32);for(var Bt=0;Bt<32;++Bt)Ho[Bt]=5;var hB=ri(ji,9,0),fB=ri(ji,9,1),mB=ri(Ho,5,0),gB=ri(Ho,5,1),nd=function(n){for(var e=n[0],t=1;te&&(e=n[t]);return e},Rn=function(n,e,t){var r=e/8|0;return(n[r]|n[r+1]<<8)>>(e&7)&t},id=function(n,e){var t=e/8|0;return(n[t]|n[t+1]<<8|n[t+2]<<16)>>(e&7)},c_=function(n){return(n+7)/8|0},u_=function(n,e,t){(e==null||e<0)&&(e=0),(t==null||t>n.length)&&(t=n.length);var r=new Sr(t-e);return r.set(n.subarray(e,t)),r},_B=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],$r=function(n,e,t){var r=new Error(e||_B[n]);if(r.code=n,Error.captureStackTrace&&Error.captureStackTrace(r,$r),!t)throw r;return r},d_=function(n,e,t,r){var i=n.length,s=r?r.length:0;if(!i||e.f&&!e.l)return t||new Sr(0);var a=!t||e.i!=2,o=e.i;t||(t=new Sr(i*3));var l=function(Le){var tt=t.length;if(Le>tt){var nt=new Sr(Math.max(tt*2,Le));nt.set(t),t=nt}},c=e.f||0,u=e.p||0,p=e.b||0,m=e.l,_=e.d,T=e.m,I=e.n,R=i*8;do{if(!m){c=Rn(n,u,1);var L=Rn(n,u+1,3);if(u+=3,L)if(L==1)m=fB,_=gB,T=9,I=5;else if(L==2){var E=Rn(n,u,31)+257,S=Rn(n,u+10,15)+4,N=E+Rn(n,u+5,31)+1;u+=14;for(var k=new Sr(N),x=new Sr(19),M=0;M>4;if($<16)k[M++]=$;else{var ee=0,B=0;for($==16?(B=3+Rn(n,u,3),u+=2,ee=k[M-1]):$==17?(B=3+Rn(n,u,7),u+=3):$==18&&(B=11+Rn(n,u,127),u+=7);B--;)k[M++]=ee}}var Q=k.subarray(0,E),j=k.subarray(E);T=nd(Q),I=nd(j),m=ri(Q,T,1),_=ri(j,I,1)}else $r(1);else{var $=c_(u)+4,K=n[$-4]|n[$-3]<<8,f=$+K;if(f>i){o&&$r(0);break}a&&l(p+K),t.set(n.subarray($,f),p),e.b=p+=K,e.p=u=f*8,e.f=c;continue}if(u>R){o&&$r(0);break}}a&&l(p+131072);for(var Z=(1<>4;if(u+=ee&15,u>R){o&&$r(0);break}if(ee||$r(2),Ee<256)t[p++]=Ee;else if(Ee==256){le=u,m=null;break}else{var De=Ee-254;if(Ee>264){var M=Ee-257,xe=iu[M];De=Rn(n,u,(1<>4;be||$r(3),u+=be&15;var j=pB[Re];if(Re>3){var xe=au[Re];j+=id(n,u)&(1<R){o&&$r(0);break}a&&l(p+131072);var ce=p+De;if(p>8},uo=function(n,e,t){t<<=e&7;var r=e/8|0;n[r]|=t,n[r+1]|=t>>8,n[r+2]|=t>>16},ad=function(n,e){for(var t=[],r=0;rm&&(m=s[r].s);var _=new ln(m+1),T=rg(t[u-1],_,0);if(T>e){var r=0,I=0,R=T-e,L=1<e)I+=L-(1<>=R;I>0;){var K=s[r].s;_[K]=0&&I;--r){var f=s[r].s;_[f]==e&&(--_[f],++I)}T=e}return{t:new Sr(_),l:T}},rg=function(n,e,t){return n.s==-1?Math.max(rg(n.l,e,t+1),rg(n.r,e,t+1)):e[n.s]=t},CE=function(n){for(var e=n.length;e&&!n[--e];);for(var t=new ln(++e),r=0,i=n[0],s=1,a=function(l){t[r++]=l},o=1;o<=e;++o)if(n[o]==i&&o!=e)++s;else{if(!i&&s>2){for(;s>138;s-=138)a(32754);s>2&&(a(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(a(i),--s;s>6;s-=6)a(8304);s>2&&(a(s-3<<5|8208),s=0)}for(;s--;)a(i);s=1,i=n[o]}return{c:t.subarray(0,r),n:e}},po=function(n,e){for(var t=0,r=0;r>8,n[i+2]=n[i]^255,n[i+3]=n[i+1]^255;for(var s=0;s4&&!M[Jm[te-1]];--te);var ne=c+5<<3,re=po(i,ji)+po(s,Ho)+a,ee=po(i,m)+po(s,I)+a+14+3*te+po(N,M)+2*N[16]+3*N[17]+7*N[18];if(l>=0&&ne<=re&&ne<=ee)return $I(e,u,n.subarray(l,l+c));var B,Q,j,Z;if(fi(e,u,1+(ee15&&(fi(e,u,De[k]>>5&127),u+=De[k]>>12)}}else B=hB,Q=ji,j=mB,Z=Ho;for(var k=0;k255){var xe=be>>18&31;uo(e,u,B[xe+257]),u+=Q[xe+257],xe>7&&(fi(e,u,be>>23&31),u+=iu[xe]);var Re=be&31;uo(e,u,j[Re]),u+=Z[Re],Re>3&&(uo(e,u,be>>5&8191),u+=au[Re])}else uo(e,u,B[be]),u+=Q[be]}return uo(e,u,B[256]),u+Q[256]},SB=new l_([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),GI=new Sr(0),OB=function(n,e,t,r,i,s){var a=s.z||n.length,o=new Sr(r+a+5*(1+Math.ceil(a/7e3))+i),l=o.subarray(r,o.length-i),c=s.l,u=(s.r||0)&7;if(e){u&&(l[0]=s.r>>3);for(var p=SB[e-1],m=p>>13,_=p&8191,T=(1<7e3||M>24576)&&(B>423||!c)){u=yE(n,l,0,f,E,S,k,M,te,x-te,u),M=N=k=0,te=x;for(var Q=0;Q<286;++Q)E[Q]=0;for(var Q=0;Q<30;++Q)S[Q]=0}var j=2,Z=0,ue=_,le=re-ee&32767;if(B>2&&ne==K(x-le))for(var Ee=Math.min(m,B)-1,De=Math.min(32767,x),xe=Math.min(258,B);le<=De&&--ue&&re!=ee;){if(n[x+j]==n[x+j-le]){for(var be=0;bej){if(j=be,Z=le,be>Ee)break;for(var Re=Math.min(le,be-2),ce=0,Q=0;Qce&&(ce=Le,ee=ke)}}}re=ee,ee=I[re],le+=re-ee&32767}if(Z){f[M++]=268435456|eg[j]<<18|TE[Z];var tt=eg[j]&31,nt=TE[Z]&31;k+=iu[tt]+au[nt],++E[257+tt],++S[nt],G=x+j,++N}else f[M++]=n[x],++E[n[x]]}}for(x=Math.max(x,G);x=a&&(l[u/8|0]=c,ze=a),u=$I(l,u+1,n.subarray(x,ze))}s.i=a}return u_(o,0,r+c_(u)+i)},EB=function(){for(var n=new Int32Array(256),e=0;e<256;++e){for(var t=e,r=9;--r;)t=(t&1&&-306674912)^t>>>1;n[e]=t}return n}(),bB=function(){var n=-1;return{p:function(e){for(var t=n,r=0;r>>8;n=t},d:function(){return~n}}},vB=function(n,e,t,r,i){if(!i&&(i={l:1},e.dictionary)){var s=e.dictionary.subarray(-32768),a=new Sr(s.length+n.length);a.set(s),a.set(n,s.length),n=a,i.w=s.length}return OB(n,e.level==null?6:e.level,e.mem==null?Math.ceil(Math.max(8,Math.min(13,Math.log(n.length)))*1.5):12+e.mem,t,r,i)},ng=function(n,e,t){for(;t;++e)n[e]=t,t>>>=8},TB=function(n,e){var t=e.filename;if(n[0]=31,n[1]=139,n[2]=8,n[8]=e.level<2?4:e.level==9?2:0,n[9]=3,e.mtime!=0&&ng(n,4,Math.floor(new Date(e.mtime||Date.now())/1e3)),t){n[3]=8;for(var r=0;r<=t.length;++r)n[r+10]=t.charCodeAt(r)}},CB=function(n){(n[0]!=31||n[1]!=139||n[2]!=8)&&$r(6,"invalid gzip data");var e=n[3],t=10;e&4&&(t+=(n[10]|n[11]<<8)+2);for(var r=(e>>3&1)+(e>>4&1);r>0;r-=!n[t++]);return t+(e&2)},yB=function(n){var e=n.length;return(n[e-4]|n[e-3]<<8|n[e-2]<<16|n[e-1]<<24)>>>0},AB=function(n){return 10+(n.filename?n.filename.length+1:0)},IB=function(n,e){return((n[0]&15)!=8||n[0]>>4>7||(n[0]<<8|n[1])%31)&&$r(6,"invalid zlib data"),(n[1]>>5&1)==+!e&&$r(6,"invalid zlib data: "+(n[1]&32?"need":"unexpected")+" dictionary"),(n[1]>>3&4)+2};function RB(n,e){return d_(n,{i:2},e&&e.out,e&&e.dictionary)}function NB(n,e){e||(e={});var t=bB(),r=n.length;t.p(n);var i=vB(n,e,AB(e),8),s=i.length;return TB(i,e),ng(i,s-8,t.d()),ng(i,s-4,r),i}function wB(n,e){var t=CB(n);return t+8>n.length&&$r(6,"invalid gzip data"),d_(n.subarray(t,-8),{i:2},e&&e.out||new Sr(yB(n)),e&&e.dictionary)}function DB(n,e){return d_(n.subarray(IB(n,e&&e.dictionary),-4),{i:2},e&&e.out,e&&e.dictionary)}function xB(n,e){return n[0]==31&&n[1]==139&&n[2]==8?wB(n,e):(n[0]&15)!=8||n[0]>>4>7||(n[0]<<8|n[1])%31?RB(n,e):DB(n,e)}var ig=typeof TextDecoder<"u"&&new TextDecoder,kB=0;try{ig.decode(GI,{stream:!0}),kB=1}catch{}var LB=function(n){for(var e="",t=0;;){var r=n[t++],i=(r>127)+(r>223)+(r>239);if(t+i>n.length)return{s:e,r:u_(n,t-1)};i?i==3?(r=((r&15)<<18|(n[t++]&63)<<12|(n[t++]&63)<<6|n[t++]&63)-65536,e+=String.fromCharCode(55296|r>>10,56320|r&1023)):i&1?e+=String.fromCharCode((r&31)<<6|n[t++]&63):e+=String.fromCharCode((r&15)<<12|(n[t++]&63)<<6|n[t++]&63):e+=String.fromCharCode(r)}};function MB(n,e){if(e){for(var t="",r=0;r (GFM Style)",type:"boolean"},requireSpaceBeforeHeadingText:{defaultValue:!1,describe:"Makes adding a space between `#` and the header text mandatory (GFM Style)",type:"boolean"},ghMentions:{defaultValue:!1,describe:"Enables github @mentions",type:"boolean"},ghMentionsLink:{defaultValue:"https://github.com/{u}",describe:"Changes the link generated by @mentions. Only applies if ghMentions option is enabled.",type:"string"},encodeEmails:{defaultValue:!0,describe:"Encode e-mail addresses through the use of Character Entities, transforming ASCII e-mail addresses into its equivalent decimal entities",type:"boolean"},openLinksInNewWindow:{defaultValue:!1,describe:"Open all links in new windows",type:"boolean"},backslashEscapesHTMLTags:{defaultValue:!1,describe:"Support for HTML Tag escaping. ex:
foo
",type:"boolean"},emoji:{defaultValue:!1,describe:"Enable emoji support. Ex: `this is a :smile: emoji`",type:"boolean"},underline:{defaultValue:!1,describe:"Enable support for underline. Syntax is double or triple underscores: `__underline word__`. With this option enabled, underscores no longer parses into `` and ``",type:"boolean"},ellipsis:{defaultValue:!0,describe:"Replaces three dots with the ellipsis unicode character",type:"boolean"},completeHTMLDocument:{defaultValue:!1,describe:"Outputs a complete html document, including ``, `` and `` tags",type:"boolean"},metadata:{defaultValue:!1,describe:"Enable support for document metadata (defined at the top of the document between `«««` and `»»»` or between `---` and `---`).",type:"boolean"},splitAdjacentBlockquotes:{defaultValue:!1,describe:"Split adjacent blockquote blocks",type:"boolean"}};if(f===!1)return JSON.parse(JSON.stringify(E));var S={};for(var N in E)E.hasOwnProperty(N)&&(S[N]=E[N].defaultValue);return S}function t(){var f=e(!0),E={};for(var S in f)f.hasOwnProperty(S)&&(E[S]=!0);return E}var r={},i={},s={},a=e(!0),o="vanilla",l={github:{omitExtraWLInCodeBlocks:!0,simplifiedAutoLink:!0,excludeTrailingPunctuationFromURLs:!0,literalMidWordUnderscores:!0,strikethrough:!0,tables:!0,tablesHeaderId:!0,ghCodeBlocks:!0,tasklists:!0,disableForced4SpacesIndentedSublists:!0,simpleLineBreaks:!0,requireSpaceBeforeHeadingText:!0,ghCompatibleHeaderId:!0,ghMentions:!0,backslashEscapesHTMLTags:!0,emoji:!0,splitAdjacentBlockquotes:!0},original:{noHeaderId:!0,ghCodeBlocks:!1},ghost:{omitExtraWLInCodeBlocks:!0,parseImgDimensions:!0,simplifiedAutoLink:!0,excludeTrailingPunctuationFromURLs:!0,literalMidWordUnderscores:!0,strikethrough:!0,tables:!0,tablesHeaderId:!0,ghCodeBlocks:!0,tasklists:!0,smoothLivePreview:!0,simpleLineBreaks:!0,requireSpaceBeforeHeadingText:!0,ghMentions:!1,encodeEmails:!0},vanilla:e(!0),allOn:t()};r.helper={},r.extensions={},r.setOption=function(f,E){return a[f]=E,this},r.getOption=function(f){return a[f]},r.getOptions=function(){return a},r.resetOptions=function(){a=e(!0)},r.setFlavor=function(f){if(!l.hasOwnProperty(f))throw Error(f+" flavor was not found");r.resetOptions();var E=l[f];o=f;for(var S in E)E.hasOwnProperty(S)&&(a[S]=E[S])},r.getFlavor=function(){return o},r.getFlavorOptions=function(f){if(l.hasOwnProperty(f))return l[f]},r.getDefaultOptions=function(f){return e(f)},r.subParser=function(f,E){if(r.helper.isString(f))if(typeof E<"u")i[f]=E;else{if(i.hasOwnProperty(f))return i[f];throw Error("SubParser named "+f+" not registered!")}},r.extension=function(f,E){if(!r.helper.isString(f))throw Error("Extension 'name' must be a string");if(f=r.helper.stdExtName(f),r.helper.isUndefined(E)){if(!s.hasOwnProperty(f))throw Error("Extension named "+f+" is not registered!");return s[f]}else{typeof E=="function"&&(E=E()),r.helper.isArray(E)||(E=[E]);var S=c(E,f);if(S.valid)s[f]=E;else throw Error(S.error)}},r.getAllExtensions=function(){return s},r.removeExtension=function(f){delete s[f]},r.resetExtensions=function(){s={}};function c(f,E){var S=E?"Error in "+E+" extension->":"Error in unnamed extension",N={valid:!0,error:""};r.helper.isArray(f)||(f=[f]);for(var k=0;k"u"},r.helper.forEach=function(f,E){if(r.helper.isUndefined(f))throw new Error("obj param is required");if(r.helper.isUndefined(E))throw new Error("callback param is required");if(!r.helper.isFunction(E))throw new Error("callback param must be a function/closure");if(typeof f.forEach=="function")f.forEach(E);else if(r.helper.isArray(f))for(var S=0;S").replace(/&/g,"&")};var p=function(f,E,S,N){var k=N||"",x=k.indexOf("g")>-1,M=new RegExp(E+"|"+S,"g"+k.replace(/g/g,"")),G=new RegExp(E,k.replace(/g/g,"")),te=[],ne,re,ee,B,Q;do for(ne=0;ee=M.exec(f);)if(G.test(ee[0]))ne++||(re=M.lastIndex,B=re-ee[0].length);else if(ne&&!--ne){Q=ee.index+ee[0].length;var j={left:{start:B,end:re},match:{start:re,end:ee.index},right:{start:ee.index,end:Q},wholeMatch:{start:B,end:Q}};if(te.push(j),!x)return te}while(ne&&(M.lastIndex=re));return te};r.helper.matchRecursiveRegExp=function(f,E,S,N){for(var k=p(f,E,S,N),x=[],M=0;M0){var ne=[];M[0].wholeMatch.start!==0&&ne.push(f.slice(0,M[0].wholeMatch.start));for(var re=0;re=0?N+(S||0):N},r.helper.splitAtIndex=function(f,E){if(!r.helper.isString(f))throw"InvalidArgumentError: first parameter of showdown.helper.regexIndexOf function must be a string";return[f.substring(0,E),f.substring(E)]},r.helper.encodeEmailAddress=function(f){var E=[function(S){return"&#"+S.charCodeAt(0)+";"},function(S){return"&#x"+S.charCodeAt(0).toString(16)+";"},function(S){return S}];return f=f.replace(/./g,function(S){if(S==="@")S=E[Math.floor(Math.random()*2)](S);else{var N=Math.random();S=N>.9?E[2](S):N>.45?E[1](S):E[0](S)}return S}),f},r.helper.padEnd=function(E,S,N){return S=S>>0,N=String(N||" "),E.length>S?String(E):(S=S-E.length,S>N.length&&(N+=N.repeat(S/N.length)),String(E)+N.slice(0,S))},typeof console>"u"&&(console={warn:function(f){alert(f)},log:function(f){alert(f)},error:function(f){throw f}}),r.helper.regexes={asteriskDashAndColon:/([*_:~])/g},r.helper.emojis={"+1":"👍","-1":"👎",100:"💯",1234:"🔢","1st_place_medal":"🥇","2nd_place_medal":"🥈","3rd_place_medal":"🥉","8ball":"🎱",a:"🅰️",ab:"🆎",abc:"🔤",abcd:"🔡",accept:"🉑",aerial_tramway:"🚡",airplane:"✈️",alarm_clock:"⏰",alembic:"⚗️",alien:"👽",ambulance:"🚑",amphora:"🏺",anchor:"⚓️",angel:"👼",anger:"💢",angry:"😠",anguished:"😧",ant:"🐜",apple:"🍎",aquarius:"♒️",aries:"♈️",arrow_backward:"◀️",arrow_double_down:"⏬",arrow_double_up:"⏫",arrow_down:"⬇️",arrow_down_small:"🔽",arrow_forward:"▶️",arrow_heading_down:"⤵️",arrow_heading_up:"⤴️",arrow_left:"⬅️",arrow_lower_left:"↙️",arrow_lower_right:"↘️",arrow_right:"➡️",arrow_right_hook:"↪️",arrow_up:"⬆️",arrow_up_down:"↕️",arrow_up_small:"🔼",arrow_upper_left:"↖️",arrow_upper_right:"↗️",arrows_clockwise:"🔃",arrows_counterclockwise:"🔄",art:"🎨",articulated_lorry:"🚛",artificial_satellite:"🛰",astonished:"😲",athletic_shoe:"👟",atm:"🏧",atom_symbol:"⚛️",avocado:"🥑",b:"🅱️",baby:"👶",baby_bottle:"🍼",baby_chick:"🐤",baby_symbol:"🚼",back:"🔙",bacon:"🥓",badminton:"🏸",baggage_claim:"🛄",baguette_bread:"🥖",balance_scale:"⚖️",balloon:"🎈",ballot_box:"🗳",ballot_box_with_check:"☑️",bamboo:"🎍",banana:"🍌",bangbang:"‼️",bank:"🏦",bar_chart:"📊",barber:"💈",baseball:"⚾️",basketball:"🏀",basketball_man:"⛹️",basketball_woman:"⛹️‍♀️",bat:"🦇",bath:"🛀",bathtub:"🛁",battery:"🔋",beach_umbrella:"🏖",bear:"🐻",bed:"🛏",bee:"🐝",beer:"🍺",beers:"🍻",beetle:"🐞",beginner:"🔰",bell:"🔔",bellhop_bell:"🛎",bento:"🍱",biking_man:"🚴",bike:"🚲",biking_woman:"🚴‍♀️",bikini:"👙",biohazard:"☣️",bird:"🐦",birthday:"🎂",black_circle:"⚫️",black_flag:"🏴",black_heart:"🖤",black_joker:"🃏",black_large_square:"⬛️",black_medium_small_square:"◾️",black_medium_square:"◼️",black_nib:"✒️",black_small_square:"▪️",black_square_button:"🔲",blonde_man:"👱",blonde_woman:"👱‍♀️",blossom:"🌼",blowfish:"🐡",blue_book:"📘",blue_car:"🚙",blue_heart:"💙",blush:"😊",boar:"🐗",boat:"⛵️",bomb:"💣",book:"📖",bookmark:"🔖",bookmark_tabs:"📑",books:"📚",boom:"💥",boot:"👢",bouquet:"💐",bowing_man:"🙇",bow_and_arrow:"🏹",bowing_woman:"🙇‍♀️",bowling:"🎳",boxing_glove:"🥊",boy:"👦",bread:"🍞",bride_with_veil:"👰",bridge_at_night:"🌉",briefcase:"💼",broken_heart:"💔",bug:"🐛",building_construction:"🏗",bulb:"💡",bullettrain_front:"🚅",bullettrain_side:"🚄",burrito:"🌯",bus:"🚌",business_suit_levitating:"🕴",busstop:"🚏",bust_in_silhouette:"👤",busts_in_silhouette:"👥",butterfly:"🦋",cactus:"🌵",cake:"🍰",calendar:"📆",call_me_hand:"🤙",calling:"📲",camel:"🐫",camera:"📷",camera_flash:"📸",camping:"🏕",cancer:"♋️",candle:"🕯",candy:"🍬",canoe:"🛶",capital_abcd:"🔠",capricorn:"♑️",car:"🚗",card_file_box:"🗃",card_index:"📇",card_index_dividers:"🗂",carousel_horse:"🎠",carrot:"🥕",cat:"🐱",cat2:"🐈",cd:"💿",chains:"⛓",champagne:"🍾",chart:"💹",chart_with_downwards_trend:"📉",chart_with_upwards_trend:"📈",checkered_flag:"🏁",cheese:"🧀",cherries:"🍒",cherry_blossom:"🌸",chestnut:"🌰",chicken:"🐔",children_crossing:"🚸",chipmunk:"🐿",chocolate_bar:"🍫",christmas_tree:"🎄",church:"⛪️",cinema:"🎦",circus_tent:"🎪",city_sunrise:"🌇",city_sunset:"🌆",cityscape:"🏙",cl:"🆑",clamp:"🗜",clap:"👏",clapper:"🎬",classical_building:"🏛",clinking_glasses:"🥂",clipboard:"📋",clock1:"🕐",clock10:"🕙",clock1030:"🕥",clock11:"🕚",clock1130:"🕦",clock12:"🕛",clock1230:"🕧",clock130:"🕜",clock2:"🕑",clock230:"🕝",clock3:"🕒",clock330:"🕞",clock4:"🕓",clock430:"🕟",clock5:"🕔",clock530:"🕠",clock6:"🕕",clock630:"🕡",clock7:"🕖",clock730:"🕢",clock8:"🕗",clock830:"🕣",clock9:"🕘",clock930:"🕤",closed_book:"📕",closed_lock_with_key:"🔐",closed_umbrella:"🌂",cloud:"☁️",cloud_with_lightning:"🌩",cloud_with_lightning_and_rain:"⛈",cloud_with_rain:"🌧",cloud_with_snow:"🌨",clown_face:"🤡",clubs:"♣️",cocktail:"🍸",coffee:"☕️",coffin:"⚰️",cold_sweat:"😰",comet:"☄️",computer:"💻",computer_mouse:"🖱",confetti_ball:"🎊",confounded:"😖",confused:"😕",congratulations:"㊗️",construction:"🚧",construction_worker_man:"👷",construction_worker_woman:"👷‍♀️",control_knobs:"🎛",convenience_store:"🏪",cookie:"🍪",cool:"🆒",policeman:"👮",copyright:"©️",corn:"🌽",couch_and_lamp:"🛋",couple:"👫",couple_with_heart_woman_man:"💑",couple_with_heart_man_man:"👨‍❤️‍👨",couple_with_heart_woman_woman:"👩‍❤️‍👩",couplekiss_man_man:"👨‍❤️‍💋‍👨",couplekiss_man_woman:"💏",couplekiss_woman_woman:"👩‍❤️‍💋‍👩",cow:"🐮",cow2:"🐄",cowboy_hat_face:"🤠",crab:"🦀",crayon:"🖍",credit_card:"💳",crescent_moon:"🌙",cricket:"🏏",crocodile:"🐊",croissant:"🥐",crossed_fingers:"🤞",crossed_flags:"🎌",crossed_swords:"⚔️",crown:"👑",cry:"😢",crying_cat_face:"😿",crystal_ball:"🔮",cucumber:"🥒",cupid:"💘",curly_loop:"➰",currency_exchange:"💱",curry:"🍛",custard:"🍮",customs:"🛃",cyclone:"🌀",dagger:"🗡",dancer:"💃",dancing_women:"👯",dancing_men:"👯‍♂️",dango:"🍡",dark_sunglasses:"🕶",dart:"🎯",dash:"💨",date:"📅",deciduous_tree:"🌳",deer:"🦌",department_store:"🏬",derelict_house:"🏚",desert:"🏜",desert_island:"🏝",desktop_computer:"🖥",male_detective:"🕵️",diamond_shape_with_a_dot_inside:"💠",diamonds:"♦️",disappointed:"😞",disappointed_relieved:"😥",dizzy:"💫",dizzy_face:"😵",do_not_litter:"🚯",dog:"🐶",dog2:"🐕",dollar:"💵",dolls:"🎎",dolphin:"🐬",door:"🚪",doughnut:"🍩",dove:"🕊",dragon:"🐉",dragon_face:"🐲",dress:"👗",dromedary_camel:"🐪",drooling_face:"🤤",droplet:"💧",drum:"🥁",duck:"🦆",dvd:"📀","e-mail":"📧",eagle:"🦅",ear:"👂",ear_of_rice:"🌾",earth_africa:"🌍",earth_americas:"🌎",earth_asia:"🌏",egg:"🥚",eggplant:"🍆",eight_pointed_black_star:"✴️",eight_spoked_asterisk:"✳️",electric_plug:"🔌",elephant:"🐘",email:"✉️",end:"🔚",envelope_with_arrow:"📩",euro:"💶",european_castle:"🏰",european_post_office:"🏤",evergreen_tree:"🌲",exclamation:"❗️",expressionless:"😑",eye:"👁",eye_speech_bubble:"👁‍🗨",eyeglasses:"👓",eyes:"👀",face_with_head_bandage:"🤕",face_with_thermometer:"🤒",fist_oncoming:"👊",factory:"🏭",fallen_leaf:"🍂",family_man_woman_boy:"👪",family_man_boy:"👨‍👦",family_man_boy_boy:"👨‍👦‍👦",family_man_girl:"👨‍👧",family_man_girl_boy:"👨‍👧‍👦",family_man_girl_girl:"👨‍👧‍👧",family_man_man_boy:"👨‍👨‍👦",family_man_man_boy_boy:"👨‍👨‍👦‍👦",family_man_man_girl:"👨‍👨‍👧",family_man_man_girl_boy:"👨‍👨‍👧‍👦",family_man_man_girl_girl:"👨‍👨‍👧‍👧",family_man_woman_boy_boy:"👨‍👩‍👦‍👦",family_man_woman_girl:"👨‍👩‍👧",family_man_woman_girl_boy:"👨‍👩‍👧‍👦",family_man_woman_girl_girl:"👨‍👩‍👧‍👧",family_woman_boy:"👩‍👦",family_woman_boy_boy:"👩‍👦‍👦",family_woman_girl:"👩‍👧",family_woman_girl_boy:"👩‍👧‍👦",family_woman_girl_girl:"👩‍👧‍👧",family_woman_woman_boy:"👩‍👩‍👦",family_woman_woman_boy_boy:"👩‍👩‍👦‍👦",family_woman_woman_girl:"👩‍👩‍👧",family_woman_woman_girl_boy:"👩‍👩‍👧‍👦",family_woman_woman_girl_girl:"👩‍👩‍👧‍👧",fast_forward:"⏩",fax:"📠",fearful:"😨",feet:"🐾",female_detective:"🕵️‍♀️",ferris_wheel:"🎡",ferry:"⛴",field_hockey:"🏑",file_cabinet:"🗄",file_folder:"📁",film_projector:"📽",film_strip:"🎞",fire:"🔥",fire_engine:"🚒",fireworks:"🎆",first_quarter_moon:"🌓",first_quarter_moon_with_face:"🌛",fish:"🐟",fish_cake:"🍥",fishing_pole_and_fish:"🎣",fist_raised:"✊",fist_left:"🤛",fist_right:"🤜",flags:"🎏",flashlight:"🔦",fleur_de_lis:"⚜️",flight_arrival:"🛬",flight_departure:"🛫",floppy_disk:"💾",flower_playing_cards:"🎴",flushed:"😳",fog:"🌫",foggy:"🌁",football:"🏈",footprints:"👣",fork_and_knife:"🍴",fountain:"⛲️",fountain_pen:"🖋",four_leaf_clover:"🍀",fox_face:"🦊",framed_picture:"🖼",free:"🆓",fried_egg:"🍳",fried_shrimp:"🍤",fries:"🍟",frog:"🐸",frowning:"😦",frowning_face:"☹️",frowning_man:"🙍‍♂️",frowning_woman:"🙍",middle_finger:"🖕",fuelpump:"⛽️",full_moon:"🌕",full_moon_with_face:"🌝",funeral_urn:"⚱️",game_die:"🎲",gear:"⚙️",gem:"💎",gemini:"♊️",ghost:"👻",gift:"🎁",gift_heart:"💝",girl:"👧",globe_with_meridians:"🌐",goal_net:"🥅",goat:"🐐",golf:"⛳️",golfing_man:"🏌️",golfing_woman:"🏌️‍♀️",gorilla:"🦍",grapes:"🍇",green_apple:"🍏",green_book:"📗",green_heart:"💚",green_salad:"🥗",grey_exclamation:"❕",grey_question:"❔",grimacing:"😬",grin:"😁",grinning:"😀",guardsman:"💂",guardswoman:"💂‍♀️",guitar:"🎸",gun:"🔫",haircut_woman:"💇",haircut_man:"💇‍♂️",hamburger:"🍔",hammer:"🔨",hammer_and_pick:"⚒",hammer_and_wrench:"🛠",hamster:"🐹",hand:"✋",handbag:"👜",handshake:"🤝",hankey:"💩",hatched_chick:"🐥",hatching_chick:"🐣",headphones:"🎧",hear_no_evil:"🙉",heart:"❤️",heart_decoration:"💟",heart_eyes:"😍",heart_eyes_cat:"😻",heartbeat:"💓",heartpulse:"💗",hearts:"♥️",heavy_check_mark:"✔️",heavy_division_sign:"➗",heavy_dollar_sign:"💲",heavy_heart_exclamation:"❣️",heavy_minus_sign:"➖",heavy_multiplication_x:"✖️",heavy_plus_sign:"➕",helicopter:"🚁",herb:"🌿",hibiscus:"🌺",high_brightness:"🔆",high_heel:"👠",hocho:"🔪",hole:"🕳",honey_pot:"🍯",horse:"🐴",horse_racing:"🏇",hospital:"🏥",hot_pepper:"🌶",hotdog:"🌭",hotel:"🏨",hotsprings:"♨️",hourglass:"⌛️",hourglass_flowing_sand:"⏳",house:"🏠",house_with_garden:"🏡",houses:"🏘",hugs:"🤗",hushed:"😯",ice_cream:"🍨",ice_hockey:"🏒",ice_skate:"⛸",icecream:"🍦",id:"🆔",ideograph_advantage:"🉐",imp:"👿",inbox_tray:"📥",incoming_envelope:"📨",tipping_hand_woman:"💁",information_source:"ℹ️",innocent:"😇",interrobang:"⁉️",iphone:"📱",izakaya_lantern:"🏮",jack_o_lantern:"🎃",japan:"🗾",japanese_castle:"🏯",japanese_goblin:"👺",japanese_ogre:"👹",jeans:"👖",joy:"😂",joy_cat:"😹",joystick:"🕹",kaaba:"🕋",key:"🔑",keyboard:"⌨️",keycap_ten:"🔟",kick_scooter:"🛴",kimono:"👘",kiss:"💋",kissing:"😗",kissing_cat:"😽",kissing_closed_eyes:"😚",kissing_heart:"😘",kissing_smiling_eyes:"😙",kiwi_fruit:"🥝",koala:"🐨",koko:"🈁",label:"🏷",large_blue_circle:"🔵",large_blue_diamond:"🔷",large_orange_diamond:"🔶",last_quarter_moon:"🌗",last_quarter_moon_with_face:"🌜",latin_cross:"✝️",laughing:"😆",leaves:"🍃",ledger:"📒",left_luggage:"🛅",left_right_arrow:"↔️",leftwards_arrow_with_hook:"↩️",lemon:"🍋",leo:"♌️",leopard:"🐆",level_slider:"🎚",libra:"♎️",light_rail:"🚈",link:"🔗",lion:"🦁",lips:"👄",lipstick:"💄",lizard:"🦎",lock:"🔒",lock_with_ink_pen:"🔏",lollipop:"🍭",loop:"➿",loud_sound:"🔊",loudspeaker:"📢",love_hotel:"🏩",love_letter:"💌",low_brightness:"🔅",lying_face:"🤥",m:"Ⓜ️",mag:"🔍",mag_right:"🔎",mahjong:"🀄️",mailbox:"📫",mailbox_closed:"📪",mailbox_with_mail:"📬",mailbox_with_no_mail:"📭",man:"👨",man_artist:"👨‍🎨",man_astronaut:"👨‍🚀",man_cartwheeling:"🤸‍♂️",man_cook:"👨‍🍳",man_dancing:"🕺",man_facepalming:"🤦‍♂️",man_factory_worker:"👨‍🏭",man_farmer:"👨‍🌾",man_firefighter:"👨‍🚒",man_health_worker:"👨‍⚕️",man_in_tuxedo:"🤵",man_judge:"👨‍⚖️",man_juggling:"🤹‍♂️",man_mechanic:"👨‍🔧",man_office_worker:"👨‍💼",man_pilot:"👨‍✈️",man_playing_handball:"🤾‍♂️",man_playing_water_polo:"🤽‍♂️",man_scientist:"👨‍🔬",man_shrugging:"🤷‍♂️",man_singer:"👨‍🎤",man_student:"👨‍🎓",man_teacher:"👨‍🏫",man_technologist:"👨‍💻",man_with_gua_pi_mao:"👲",man_with_turban:"👳",tangerine:"🍊",mans_shoe:"👞",mantelpiece_clock:"🕰",maple_leaf:"🍁",martial_arts_uniform:"🥋",mask:"😷",massage_woman:"💆",massage_man:"💆‍♂️",meat_on_bone:"🍖",medal_military:"🎖",medal_sports:"🏅",mega:"📣",melon:"🍈",memo:"📝",men_wrestling:"🤼‍♂️",menorah:"🕎",mens:"🚹",metal:"🤘",metro:"🚇",microphone:"🎤",microscope:"🔬",milk_glass:"🥛",milky_way:"🌌",minibus:"🚐",minidisc:"💽",mobile_phone_off:"📴",money_mouth_face:"🤑",money_with_wings:"💸",moneybag:"💰",monkey:"🐒",monkey_face:"🐵",monorail:"🚝",moon:"🌔",mortar_board:"🎓",mosque:"🕌",motor_boat:"🛥",motor_scooter:"🛵",motorcycle:"🏍",motorway:"🛣",mount_fuji:"🗻",mountain:"⛰",mountain_biking_man:"🚵",mountain_biking_woman:"🚵‍♀️",mountain_cableway:"🚠",mountain_railway:"🚞",mountain_snow:"🏔",mouse:"🐭",mouse2:"🐁",movie_camera:"🎥",moyai:"🗿",mrs_claus:"🤶",muscle:"💪",mushroom:"🍄",musical_keyboard:"🎹",musical_note:"🎵",musical_score:"🎼",mute:"🔇",nail_care:"💅",name_badge:"📛",national_park:"🏞",nauseated_face:"🤢",necktie:"👔",negative_squared_cross_mark:"❎",nerd_face:"🤓",neutral_face:"😐",new:"🆕",new_moon:"🌑",new_moon_with_face:"🌚",newspaper:"📰",newspaper_roll:"🗞",next_track_button:"⏭",ng:"🆖",no_good_man:"🙅‍♂️",no_good_woman:"🙅",night_with_stars:"🌃",no_bell:"🔕",no_bicycles:"🚳",no_entry:"⛔️",no_entry_sign:"🚫",no_mobile_phones:"📵",no_mouth:"😶",no_pedestrians:"🚷",no_smoking:"🚭","non-potable_water":"🚱",nose:"👃",notebook:"📓",notebook_with_decorative_cover:"📔",notes:"🎶",nut_and_bolt:"🔩",o:"⭕️",o2:"🅾️",ocean:"🌊",octopus:"🐙",oden:"🍢",office:"🏢",oil_drum:"🛢",ok:"🆗",ok_hand:"👌",ok_man:"🙆‍♂️",ok_woman:"🙆",old_key:"🗝",older_man:"👴",older_woman:"👵",om:"🕉",on:"🔛",oncoming_automobile:"🚘",oncoming_bus:"🚍",oncoming_police_car:"🚔",oncoming_taxi:"🚖",open_file_folder:"📂",open_hands:"👐",open_mouth:"😮",open_umbrella:"☂️",ophiuchus:"⛎",orange_book:"📙",orthodox_cross:"☦️",outbox_tray:"📤",owl:"🦉",ox:"🐂",package:"📦",page_facing_up:"📄",page_with_curl:"📃",pager:"📟",paintbrush:"🖌",palm_tree:"🌴",pancakes:"🥞",panda_face:"🐼",paperclip:"📎",paperclips:"🖇",parasol_on_ground:"⛱",parking:"🅿️",part_alternation_mark:"〽️",partly_sunny:"⛅️",passenger_ship:"🛳",passport_control:"🛂",pause_button:"⏸",peace_symbol:"☮️",peach:"🍑",peanuts:"🥜",pear:"🍐",pen:"🖊",pencil2:"✏️",penguin:"🐧",pensive:"😔",performing_arts:"🎭",persevere:"😣",person_fencing:"🤺",pouting_woman:"🙎",phone:"☎️",pick:"⛏",pig:"🐷",pig2:"🐖",pig_nose:"🐽",pill:"💊",pineapple:"🍍",ping_pong:"🏓",pisces:"♓️",pizza:"🍕",place_of_worship:"🛐",plate_with_cutlery:"🍽",play_or_pause_button:"⏯",point_down:"👇",point_left:"👈",point_right:"👉",point_up:"☝️",point_up_2:"👆",police_car:"🚓",policewoman:"👮‍♀️",poodle:"🐩",popcorn:"🍿",post_office:"🏣",postal_horn:"📯",postbox:"📮",potable_water:"🚰",potato:"🥔",pouch:"👝",poultry_leg:"🍗",pound:"💷",rage:"😡",pouting_cat:"😾",pouting_man:"🙎‍♂️",pray:"🙏",prayer_beads:"📿",pregnant_woman:"🤰",previous_track_button:"⏮",prince:"🤴",princess:"👸",printer:"🖨",purple_heart:"💜",purse:"👛",pushpin:"📌",put_litter_in_its_place:"🚮",question:"❓",rabbit:"🐰",rabbit2:"🐇",racehorse:"🐎",racing_car:"🏎",radio:"📻",radio_button:"🔘",radioactive:"☢️",railway_car:"🚃",railway_track:"🛤",rainbow:"🌈",rainbow_flag:"🏳️‍🌈",raised_back_of_hand:"🤚",raised_hand_with_fingers_splayed:"🖐",raised_hands:"🙌",raising_hand_woman:"🙋",raising_hand_man:"🙋‍♂️",ram:"🐏",ramen:"🍜",rat:"🐀",record_button:"⏺",recycle:"♻️",red_circle:"🔴",registered:"®️",relaxed:"☺️",relieved:"😌",reminder_ribbon:"🎗",repeat:"🔁",repeat_one:"🔂",rescue_worker_helmet:"⛑",restroom:"🚻",revolving_hearts:"💞",rewind:"⏪",rhinoceros:"🦏",ribbon:"🎀",rice:"🍚",rice_ball:"🍙",rice_cracker:"🍘",rice_scene:"🎑",right_anger_bubble:"🗯",ring:"💍",robot:"🤖",rocket:"🚀",rofl:"🤣",roll_eyes:"🙄",roller_coaster:"🎢",rooster:"🐓",rose:"🌹",rosette:"🏵",rotating_light:"🚨",round_pushpin:"📍",rowing_man:"🚣",rowing_woman:"🚣‍♀️",rugby_football:"🏉",running_man:"🏃",running_shirt_with_sash:"🎽",running_woman:"🏃‍♀️",sa:"🈂️",sagittarius:"♐️",sake:"🍶",sandal:"👡",santa:"🎅",satellite:"📡",saxophone:"🎷",school:"🏫",school_satchel:"🎒",scissors:"✂️",scorpion:"🦂",scorpius:"♏️",scream:"😱",scream_cat:"🙀",scroll:"📜",seat:"💺",secret:"㊙️",see_no_evil:"🙈",seedling:"🌱",selfie:"🤳",shallow_pan_of_food:"🥘",shamrock:"☘️",shark:"🦈",shaved_ice:"🍧",sheep:"🐑",shell:"🐚",shield:"🛡",shinto_shrine:"⛩",ship:"🚢",shirt:"👕",shopping:"🛍",shopping_cart:"🛒",shower:"🚿",shrimp:"🦐",signal_strength:"📶",six_pointed_star:"🔯",ski:"🎿",skier:"⛷",skull:"💀",skull_and_crossbones:"☠️",sleeping:"😴",sleeping_bed:"🛌",sleepy:"😪",slightly_frowning_face:"🙁",slightly_smiling_face:"🙂",slot_machine:"🎰",small_airplane:"🛩",small_blue_diamond:"🔹",small_orange_diamond:"🔸",small_red_triangle:"🔺",small_red_triangle_down:"🔻",smile:"😄",smile_cat:"😸",smiley:"😃",smiley_cat:"😺",smiling_imp:"😈",smirk:"😏",smirk_cat:"😼",smoking:"🚬",snail:"🐌",snake:"🐍",sneezing_face:"🤧",snowboarder:"🏂",snowflake:"❄️",snowman:"⛄️",snowman_with_snow:"☃️",sob:"😭",soccer:"⚽️",soon:"🔜",sos:"🆘",sound:"🔉",space_invader:"👾",spades:"♠️",spaghetti:"🍝",sparkle:"❇️",sparkler:"🎇",sparkles:"✨",sparkling_heart:"💖",speak_no_evil:"🙊",speaker:"🔈",speaking_head:"🗣",speech_balloon:"💬",speedboat:"🚤",spider:"🕷",spider_web:"🕸",spiral_calendar:"🗓",spiral_notepad:"🗒",spoon:"🥄",squid:"🦑",stadium:"🏟",star:"⭐️",star2:"🌟",star_and_crescent:"☪️",star_of_david:"✡️",stars:"🌠",station:"🚉",statue_of_liberty:"🗽",steam_locomotive:"🚂",stew:"🍲",stop_button:"⏹",stop_sign:"🛑",stopwatch:"⏱",straight_ruler:"📏",strawberry:"🍓",stuck_out_tongue:"😛",stuck_out_tongue_closed_eyes:"😝",stuck_out_tongue_winking_eye:"😜",studio_microphone:"🎙",stuffed_flatbread:"🥙",sun_behind_large_cloud:"🌥",sun_behind_rain_cloud:"🌦",sun_behind_small_cloud:"🌤",sun_with_face:"🌞",sunflower:"🌻",sunglasses:"😎",sunny:"☀️",sunrise:"🌅",sunrise_over_mountains:"🌄",surfing_man:"🏄",surfing_woman:"🏄‍♀️",sushi:"🍣",suspension_railway:"🚟",sweat:"😓",sweat_drops:"💦",sweat_smile:"😅",sweet_potato:"🍠",swimming_man:"🏊",swimming_woman:"🏊‍♀️",symbols:"🔣",synagogue:"🕍",syringe:"💉",taco:"🌮",tada:"🎉",tanabata_tree:"🎋",taurus:"♉️",taxi:"🚕",tea:"🍵",telephone_receiver:"📞",telescope:"🔭",tennis:"🎾",tent:"⛺️",thermometer:"🌡",thinking:"🤔",thought_balloon:"💭",ticket:"🎫",tickets:"🎟",tiger:"🐯",tiger2:"🐅",timer_clock:"⏲",tipping_hand_man:"💁‍♂️",tired_face:"😫",tm:"™️",toilet:"🚽",tokyo_tower:"🗼",tomato:"🍅",tongue:"👅",top:"🔝",tophat:"🎩",tornado:"🌪",trackball:"🖲",tractor:"🚜",traffic_light:"🚥",train:"🚋",train2:"🚆",tram:"🚊",triangular_flag_on_post:"🚩",triangular_ruler:"📐",trident:"🔱",triumph:"😤",trolleybus:"🚎",trophy:"🏆",tropical_drink:"🍹",tropical_fish:"🐠",truck:"🚚",trumpet:"🎺",tulip:"🌷",tumbler_glass:"🥃",turkey:"🦃",turtle:"🐢",tv:"📺",twisted_rightwards_arrows:"🔀",two_hearts:"💕",two_men_holding_hands:"👬",two_women_holding_hands:"👭",u5272:"🈹",u5408:"🈴",u55b6:"🈺",u6307:"🈯️",u6708:"🈷️",u6709:"🈶",u6e80:"🈵",u7121:"🈚️",u7533:"🈸",u7981:"🈲",u7a7a:"🈳",umbrella:"☔️",unamused:"😒",underage:"🔞",unicorn:"🦄",unlock:"🔓",up:"🆙",upside_down_face:"🙃",v:"✌️",vertical_traffic_light:"🚦",vhs:"📼",vibration_mode:"📳",video_camera:"📹",video_game:"🎮",violin:"🎻",virgo:"♍️",volcano:"🌋",volleyball:"🏐",vs:"🆚",vulcan_salute:"🖖",walking_man:"🚶",walking_woman:"🚶‍♀️",waning_crescent_moon:"🌘",waning_gibbous_moon:"🌖",warning:"⚠️",wastebasket:"🗑",watch:"⌚️",water_buffalo:"🐃",watermelon:"🍉",wave:"👋",wavy_dash:"〰️",waxing_crescent_moon:"🌒",wc:"🚾",weary:"😩",wedding:"💒",weight_lifting_man:"🏋️",weight_lifting_woman:"🏋️‍♀️",whale:"🐳",whale2:"🐋",wheel_of_dharma:"☸️",wheelchair:"♿️",white_check_mark:"✅",white_circle:"⚪️",white_flag:"🏳️",white_flower:"💮",white_large_square:"⬜️",white_medium_small_square:"◽️",white_medium_square:"◻️",white_small_square:"▫️",white_square_button:"🔳",wilted_flower:"🥀",wind_chime:"🎐",wind_face:"🌬",wine_glass:"🍷",wink:"😉",wolf:"🐺",woman:"👩",woman_artist:"👩‍🎨",woman_astronaut:"👩‍🚀",woman_cartwheeling:"🤸‍♀️",woman_cook:"👩‍🍳",woman_facepalming:"🤦‍♀️",woman_factory_worker:"👩‍🏭",woman_farmer:"👩‍🌾",woman_firefighter:"👩‍🚒",woman_health_worker:"👩‍⚕️",woman_judge:"👩‍⚖️",woman_juggling:"🤹‍♀️",woman_mechanic:"👩‍🔧",woman_office_worker:"👩‍💼",woman_pilot:"👩‍✈️",woman_playing_handball:"🤾‍♀️",woman_playing_water_polo:"🤽‍♀️",woman_scientist:"👩‍🔬",woman_shrugging:"🤷‍♀️",woman_singer:"👩‍🎤",woman_student:"👩‍🎓",woman_teacher:"👩‍🏫",woman_technologist:"👩‍💻",woman_with_turban:"👳‍♀️",womans_clothes:"👚",womans_hat:"👒",women_wrestling:"🤼‍♀️",womens:"🚺",world_map:"🗺",worried:"😟",wrench:"🔧",writing_hand:"✍️",x:"❌",yellow_heart:"💛",yen:"💴",yin_yang:"☯️",yum:"😋",zap:"⚡️",zipper_mouth_face:"🤐",zzz:"💤",octocat:':octocat:',showdown:`S`},r.Converter=function(f){var E={},S=[],N=[],k={},x=o,M={parsed:{},raw:"",format:""};G();function G(){f=f||{};for(var B in a)a.hasOwnProperty(B)&&(E[B]=a[B]);if(typeof f=="object")for(var Q in f)f.hasOwnProperty(Q)&&(E[Q]=f[Q]);else throw Error("Converter expects the passed parameter to be an object, but "+typeof f+" was passed instead.");E.extensions&&r.helper.forEach(E.extensions,te)}function te(B,Q){if(Q=Q||null,r.helper.isString(B))if(B=r.helper.stdExtName(B),Q=B,r.extensions[B]){console.warn("DEPRECATION WARNING: "+B+" is an old extension that uses a deprecated loading method.Please inform the developer that the extension should be updated!"),ne(r.extensions[B],B);return}else if(!r.helper.isUndefined(s[B]))B=s[B];else throw Error('Extension "'+B+'" could not be loaded. It was either not found or is not a valid extension.');typeof B=="function"&&(B=B()),r.helper.isArray(B)||(B=[B]);var j=c(B,Q);if(!j.valid)throw Error(j.error);for(var Z=0;Z - +