diff --git a/assets/index-cd6cb535.js b/assets/index-a992c2dd.js similarity index 97% rename from assets/index-cd6cb535.js rename to assets/index-a992c2dd.js index 71e6589..7b2cb10 100644 --- a/assets/index-cd6cb535.js +++ b/assets/index-a992c2dd.js @@ -53,7 +53,7 @@ var Dn=Object.defineProperty;var Bn=(s,e,r)=>e in s?Dn(s,e,{enumerable:!0,config `));return}var K=0,Ne=function(){if(K=V){Ot(u,"Invalid argument: "+p.argString.substring(b));return}for(var Z=0;Z<=V-R;Z++){var Pe=String.fromCharCode(R+Z);delete m.marks[Pe]}}else{Ot(u,"Invalid argument: "+T+"-");return}}else delete m.marks[A]}}},ei=new ln;function Pn(u,p,m,v,b,A,T,M,R){u.state.vim.exMode=!0;var V=!1,Z,Pe,Le;function Oe(){u.operation(function(){for(;!V;)K(),Me();Fe()})}function K(){var He=u.getRange(A.from(),A.to()),yt=He.replace(T,M),Dt=A.to().line;A.replace(yt),Pe=A.to().line,b+=Pe-Dt,Le=Pe1&&(gn(u,m,m.insertModeRepeat-1,!0),m.lastEditInputState.repeatOverride=m.insertModeRepeat),delete m.insertModeRepeat,m.insertMode=!1,p||u.setCursor(u.getCursor().line,u.getCursor().ch-1),u.setOption("keyMap","vim"),u.setOption("disableInput",!0),u.toggleOverwrite(!1),b.setText(T.changes.join("")),s.signal(u,"vim-mode-change",{mode:"normal"}),v.isRecording&&Rn(v)}function hn(u){o.unshift(u)}function Tn(u,p,m,v,b){var A={keys:u,type:p};A[p]=m,A[p+"Args"]=v;for(var T in b)A[T]=b[T];hn(A)}mt("insertModeEscKeysTimeout",200,"number"),s.keyMap["vim-insert"]={fallthrough:["default"],attach:d,detach:f,call:g},s.keyMap["vim-replace"]={Backspace:"goCharLeft",fallthrough:["vim-insert"],attach:d,detach:f};function Ln(u,p,m,v){var b=Ye.registerController.getRegister(v);if(v==":"){b.keyBuffer[0]&&ei.processCommand(u,b.keyBuffer[0]),m.isPlaying=!1;return}var A=b.keyBuffer,T=0;m.isPlaying=!0,m.replaySearchQueries=b.searchQueries.slice(0);for(var M=0;M|<\w+>|./.exec(R),Z=V[0],R=R.substring(V.index+Z.length),Tt.handleKey(u,Z,"macro"),p.insertMode){var Pe=b.insertModeChanges[T++].changes;Ye.macroModeState.lastInsertModeChanges.changes=Pe,mn(u,Pe,1),Ci(u)}m.isPlaying=!1}function Qn(u,p){if(!u.isPlaying){var m=u.latestRegister,v=Ye.registerController.getRegister(m);v&&v.pushText(p)}}function Rn(u){if(!u.isPlaying){var p=u.latestRegister,m=Ye.registerController.getRegister(p);m&&m.pushInsertModeChanges&&m.pushInsertModeChanges(u.lastInsertModeChanges)}}function Mn(u,p){if(!u.isPlaying){var m=u.latestRegister,v=Ye.registerController.getRegister(m);v&&v.pushSearchQuery&&v.pushSearchQuery(p)}}function un(u,p){var m=Ye.macroModeState,v=m.lastInsertModeChanges;if(!m.isPlaying)for(var b=u.state.vim;p;){if(v.expectCursorActivityForChange=!0,v.ignoreCount>1)v.ignoreCount--;else if(p.origin=="+input"||p.origin=="paste"||p.origin===void 0){var A=u.listSelections().length;A>1&&(v.ignoreCount=A);var T=p.text.join(` `);if(v.maybeReset&&(v.changes=[],v.maybeReset=!1),T)if(u.state.overwrite&&!/\n/.test(T))v.changes.push([T]);else{if(T.length>1){var M=b&&b.insertEnd&&b.insertEnd.find(),R=u.getCursor();if(M&&M.line==R.line){var V=M.ch-R.ch;V>0&&V",xt(v,m))}else p.insertMode||(p.lastHPos=u.getCursor().ch)}function Fr(u){this.keyName=u}function pn(u){var p=Ye.macroModeState,m=p.lastInsertModeChanges,v=s.keyName(u);if(!v)return;function b(){return m.maybeReset&&(m.changes=[],m.maybeReset=!1),m.changes.push(new Fr(v)),!0}(v.indexOf("Delete")!=-1||v.indexOf("Backspace")!=-1)&&s.lookupKey(v,"vim-insert",b)}function gn(u,p,m,v){var b=Ye.macroModeState;b.isPlaying=!0;var A=!!p.lastEditActionCommand,T=p.inputState;function M(){A?ui.processAction(u,p,p.lastEditActionCommand):ui.evalInput(u,p)}function R(Z){if(b.lastInsertModeChanges.changes.length>0){Z=p.lastEditActionCommand?Z:1;var Pe=b.lastInsertModeChanges;mn(u,Pe.changes,Z)}}if(p.inputState=p.lastEditInputState,A&&p.lastEditActionCommand.interlaceInsertRepeat)for(var V=0;V"&&!b.insertMode&&!b.visualMode&&T&&b.status=="")Lt(u);else if(A||!T||u.inVirtualSelectionMode)v=Tt.handleKey(u,p,m);else{var M=Ur(b),R=b.inputState.changeQueueList||[];u.operation(function(){u.curOp.isVimOp=!0;var V=0;u.forEachSelection(function(){u.state.vim.inputState.changeQueue=R[V];var Z=u.getCursor("head"),Pe=u.getCursor("anchor"),Le=rt(Z,Pe)?0:-1,Oe=rt(Z,Pe)?-1:0;Z=wt(Z,0,Le),Pe=wt(Pe,0,Oe),u.state.vim.sel.head=Z,u.state.vim.sel.anchor=Pe,v=Tt.handleKey(u,p,m),u.virtualSelection&&(R[V]=u.state.vim.inputState.changeQueue,u.state.vim=Ur(M)),V++}),u.curOp.cursorActivity&&!v&&(u.curOp.cursorActivity=!1),u.state.vim=b,b.inputState.changeQueueList=R,b.inputState.changeQueue=null},!0)}return v&&!b.visualMode&&!b.insert&&b.visualMode!=u.somethingSelected()&&dn(u,b),v}return ur(),Tt}function indexFromPos(s,e){var r=e.ch,n=e.line+1;n<1&&(n=1,r=0),n>s.lines&&(n=s.lines,r=Number.MAX_VALUE);var o=s.line(n);return Math.min(o.from+Math.max(0,r),o.to)}function posFromIndex(s,e){let r=s.lineAt(e);return{line:r.number-1,ch:e-r.from}}class Pos{constructor(e,r){this.line=e,this.ch=r}}function on(s,e,r){if(s.addEventListener)s.addEventListener(e,r,!1);else{var n=s._handlers||(s._handlers={});n[e]=(n[e]||[]).concat(r)}}function off(s,e,r){if(s.removeEventListener)s.removeEventListener(e,r,!1);else{var n=s._handlers,o=n&&n[e];if(o){var a=o.indexOf(r);a>-1&&(n[e]=o.slice(0,a).concat(o.slice(a+1)))}}}function signal(s,e,...r){var n,o=(n=s._handlers)===null||n===void 0?void 0:n[e];if(o)for(var a=0;a({anchor:posFromIndex(e,r.anchor),head:posFromIndex(e,r.head)}))}setSelections(e,r){var n=this.cm6.state.doc,o=e.map(a=>EditorSelection.range(indexFromPos(n,a.anchor),indexFromPos(n,a.head)));this.cm6.dispatch({selection:EditorSelection.create(o,r)})}setSelection(e,r,n){var o=this.cm6.state.doc,a=[EditorSelection.range(indexFromPos(o,e),indexFromPos(o,r))];this.cm6.dispatch({selection:EditorSelection.create(a,0)}),n&&n.origin=="*mouse"&&this.onBeforeEndOperation()}getLine(e){var r=this.cm6.state.doc;return e<0||e>=r.lines?"":this.cm6.state.doc.line(e+1).text}getLineHandle(e){return this.$lineHandleChanges||(this.$lineHandleChanges=[]),{row:e,index:this.indexFromPos(new Pos(e,0))}}getLineNumber(e){var r=this.$lineHandleChanges;if(!r)return null;for(var n=e.index,o=0;o({from:o.from,to:o.to,insert:e[a]||""}));dispatchChange(this,{changes:n})}getSelection(){return this.getSelections().join(` `)}getSelections(){var e=this.cm6;return e.state.selection.ranges.map(r=>e.state.sliceDoc(r.from,r.to))}somethingSelected(){return this.cm6.state.selection.ranges.some(e=>!e.empty)}getInputField(){return this.cm6.contentDOM}clipPos(e){var r=this.cm6.state.doc,n=e.ch,o=e.line+1;o<1&&(o=1,n=0),o>r.lines&&(o=r.lines,n=Number.MAX_VALUE);var a=r.line(o);return n=Math.min(Math.max(0,n),a.to-a.from),new Pos(o-1,n)}getValue(){return this.cm6.state.doc.toString()}setValue(e){var r=this.cm6;return r.dispatch({changes:{from:0,to:r.state.doc.length,insert:e},selection:EditorSelection.range(0,0)})}focus(){return this.cm6.focus()}blur(){return this.cm6.contentDOM.blur()}defaultTextHeight(){return this.cm6.defaultLineHeight}findMatchingBracket(e){var r=this.cm6.state,n=indexFromPos(r.doc,e),o=matchBrackets(r,n+1,-1);return o&&o.end?{to:posFromIndex(r.doc,o.end.from)}:(o=matchBrackets(r,n,1),o&&o.end?{to:posFromIndex(r.doc,o.end.from)}:{to:void 0})}scanForBracket(e,r,n,o){return scanForBracket(this,e,r,n,o)}indentLine(e,r){r?this.indentMore():this.indentLess()}indentMore(){indentMore(this.cm6)}indentLess(){indentLess(this.cm6)}execCommand(e){e=="indentAuto"?CodeMirror.commands.indentAuto(this):e=="goLineLeft"?cursorLineBoundaryBackward(this.cm6):e=="goLineRight"?(cursorLineBoundaryForward(this.cm6),cursorCharBackward(this.cm6)):console.log(e+" is not implemented")}setBookmark(e,r){var n=r!=null&&r.insertLeft?1:-1,o=this.indexFromPos(e),a=new Marker(this,o,n);return a}addOverlay({query:e}){let r=new SearchQuery({regexp:!0,search:e.source,caseSensitive:!/i/.test(e.flags)});if(r.valid){r.forVim=!0,this.cm6Query=r;let n=setSearchQuery.of(r);return this.cm6.dispatch({effects:n}),r}}removeOverlay(e){if(!this.cm6Query)return;this.cm6Query.forVim=!1;let r=setSearchQuery.of(this.cm6Query);this.cm6.dispatch({effects:r})}getSearchCursor(e,r){var n=this,o=null,a=null;r.ch==null&&(r.ch=Number.MAX_VALUE);var l=indexFromPos(n.cm6.state.doc,r),c=e.source.replace(/(\\.|{(?:\d+(?:,\d*)?|,\d+)})|[{}]/g,function(y,I){return I||"\\"+y});function h(y,I=0,P=y.length){return new RegExpCursor(y,c,{ignoreCase:e.ignoreCase},I,P)}function f(y){var I=n.cm6.state.doc;if(y>I.length)return null;let P=h(I,y).next();return P.done?null:P.value}var d=1e4;function g(y,I){var P=n.cm6.state.doc;for(let N=1;;N++){let Y=Math.max(y,I-N*d),H=h(P,Y,I),Se=null;for(;!H.next().done;)Se=H.value;if(Se&&(Y==y||Se.from>Y+10))return Se;if(Y==y)return null}}return{findNext:function(){return this.find(!1)},findPrevious:function(){return this.find(!0)},find:function(y){var I=n.cm6.state.doc;if(y){let P=o?o.from==o.to?o.to-1:o.from:l;o=g(0,P)}else{let P=o?o.from==o.to?o.to+1:o.to:l;o=f(P)}return a=o&&{from:posFromIndex(I,o.from),to:posFromIndex(I,o.to),match:o.match},o&&o.match},from:function(){return a==null?void 0:a.from},to:function(){return a==null?void 0:a.to},replace:function(y){o&&(dispatchChange(n,{changes:{from:o.from,to:o.to,insert:y}}),o.to=o.from+y.length,a&&(a.to=posFromIndex(n.cm6.state.doc,o.to)))}}}findPosV(e,r,n,o){let{cm6:a}=this;const l=a.state.doc;let c=n=="page"?a.dom.clientHeight:0;const h=indexFromPos(l,e);let f=EditorSelection.range(h,h,o),d=Math.round(Math.abs(r));for(let y=0;y0,c):n=="line"&&(f=a.moveVertically(f,r>0));let g=posFromIndex(l,f.head);return(r<0&&f.head==0&&o!=0&&e.line==0&&e.ch!=0||r>0&&f.head==l.length&&g.ch!=o&&e.line==g.line)&&(g.hitSide=!0),g}charCoords(e,r){var n=this.cm6.contentDOM.getBoundingClientRect(),o=indexFromPos(this.cm6.state.doc,e),a=this.cm6.coordsAtPos(o),l=-n.top;return{left:((a==null?void 0:a.left)||0)-n.left,top:((a==null?void 0:a.top)||0)+l,bottom:((a==null?void 0:a.bottom)||0)+l}}coordsChar(e,r){var n=this.cm6.contentDOM.getBoundingClientRect(),o=this.cm6.posAtCoords({x:e.left+n.left,y:e.top+n.top})||0;return posFromIndex(this.cm6.state.doc,o)}getScrollInfo(){var e=this.cm6.scrollDOM;return{left:e.scrollLeft,top:e.scrollTop,height:e.scrollHeight,width:e.scrollWidth,clientHeight:e.clientHeight,clientWidth:e.clientWidth}}scrollTo(e,r){e!=null&&(this.cm6.scrollDOM.scrollLeft=e),r!=null&&(this.cm6.scrollDOM.scrollTop=r)}scrollIntoView(e,r){if(e){var n=this.indexFromPos(e);this.cm6.dispatch({effects:EditorView.scrollIntoView(n)})}else this.cm6.dispatch({scrollIntoView:!0,userEvent:"scroll"})}getWrapperElement(){return this.cm6.dom}getMode(){return{name:this.getOption("mode")}}setSize(e,r){this.cm6.dom.style.width=e+4+"px",this.cm6.dom.style.height=r+"px",this.refresh()}refresh(){this.cm6.measure()}destroy(){this.removeOverlay()}getLastEditEnd(){return this.posFromIndex(this.$lastChangeEndOffset)}onChange(e){this.$lineHandleChanges&&this.$lineHandleChanges.push(e);for(let n in this.marks)this.marks[n].update(e.changes);this.virtualSelection&&(this.virtualSelection.ranges=this.virtualSelection.ranges.map(n=>n.map(e.changes)));var r=this.curOp=this.curOp||{};e.changes.iterChanges((n,o,a,l,c)=>{(r.$changeStart==null||r.$changeStart>a)&&(r.$changeStart=a),this.$lastChangeEndOffset=l;var h={text:c.toJSON()};r.lastChange?r.lastChange.next=r.lastChange=h:r.lastChange=r.change=h},!0),r.changeHandlers||(r.changeHandlers=this._handlers.change&&this._handlers.change.slice())}onSelectionChange(){var e=this.curOp=this.curOp||{};e.cursorActivityHandlers||(e.cursorActivityHandlers=this._handlers.cursorActivity&&this._handlers.cursorActivity.slice()),this.curOp.cursorActivity=!0}operation(e){this.curOp||(this.curOp={$d:0}),this.curOp.$d++;try{var r=e()}finally{this.curOp&&(this.curOp.$d--,this.curOp.$d||this.onBeforeEndOperation())}return r}onBeforeEndOperation(){var e=this.curOp,r=!1;e&&(e.change&&signalTo(e.changeHandlers,this,e.change),e&&e.cursorActivity&&(signalTo(e.cursorActivityHandlers,this,null),e.isVimOp&&(r=!0)),this.curOp=null),r&&this.scrollIntoView()}moveH(e,r){if(r=="char"){var n=this.getCursor();this.setCursor(n.line,n.ch+e)}}setOption(e,r){switch(e){case"keyMap":this.state.keyMap=r;break}}getOption(e){switch(e){case"firstLineNumber":return 1;case"tabSize":return this.cm6.state.tabSize||4;case"readonly":return this.cm6.state.readOnly;case"indentWithTabs":return this.cm6.state.facet(indentUnit)==" ";case"indentUnit":return this.cm6.state.facet(indentUnit).length||2;case"keyMap":return this.state.keyMap||"vim"}}toggleOverwrite(e){this.state.overwrite=e}getTokenTypeAt(e){var r,n=this.indexFromPos(e),o=ensureSyntaxTree(this.cm6.state,n),a=o==null?void 0:o.resolve(n),l=((r=a==null?void 0:a.type)===null||r===void 0?void 0:r.name)||"";return/comment/i.test(l)?"comment":/string/i.test(l)?"string":""}overWriteSelection(e){var r=this.cm6.state.doc,n=this.cm6.state.selection,o=n.ranges.map(a=>{if(a.empty){var l=a.to1}virtualSelectionMode(){return!!this.virtualSelection}forEachSelection(e){var r=this.cm6.state.selection;this.virtualSelection=EditorSelection.create(r.ranges,r.mainIndex);for(var n=0;ndispatchChange(s,e)})},indentAuto:function(s){indentSelection(s.cm6)}};CodeMirror.defineOption=function(s,e,r){};CodeMirror.isWordChar=function(s){return wordChar.test(s)};CodeMirror.keys=keys;CodeMirror.keyMap={};CodeMirror.addClass=function(){};CodeMirror.rmClass=function(){};CodeMirror.e_preventDefault=function(s){s.preventDefault()};CodeMirror.e_stop=function(s){var e,r;(e=s==null?void 0:s.stopPropagation)===null||e===void 0||e.call(s),(r=s==null?void 0:s.preventDefault)===null||r===void 0||r.call(s)};CodeMirror.keyName=function(s){var e=s.key;if(!ignoredKeys[e]){e=="Escape"&&(e="Esc"),e==" "&&(e="Space"),e.length>1&&(e=e.replace(/Numpad|Arrow/,"")),e.length==1&&(e=e.toUpperCase());var r="";return s.ctrlKey&&(r+="Ctrl-"),s.altKey&&(r+="Alt-"),(r||e.length>1)&&s.shiftKey&&(r+="Shift-"),r+=e,r}};CodeMirror.vimKey=function(e){var r=e.key;if(!ignoredKeys[r]){r.length>1&&r[0]=="n"&&(r=r.replace("Numpad","")),r=specialKey[r]||r;var n="";return e.ctrlKey&&(n+="C-"),e.altKey&&(n+="A-"),e.metaKey&&(n+="M-"),CodeMirror.isMac&&e.altKey&&!e.metaKey&&!e.ctrlKey&&(n=n.slice(2)),(n||r.length>1)&&e.shiftKey&&(n+="S-"),n+=r,n.length>1&&(n="<"+n+">"),n}};CodeMirror.lookupKey=function(e,r,n){var o=CodeMirror.keys[e];o&&n(o)};CodeMirror.on=on;CodeMirror.off=off;CodeMirror.signal=signal;CodeMirror.findMatchingTag=findMatchingTag;CodeMirror.findEnclosingTag=findEnclosingTag;function dialogDiv(s,e,r){var n=document.createElement("div");return n.appendChild(e),n}function closeNotification(s,e){s.state.currentNotificationClose&&s.state.currentNotificationClose(),s.state.currentNotificationClose=e}function openNotification(s,e,r){closeNotification(s,c);var n=dialogDiv(s,e,r&&r.bottom),o=!1,a,l=r&&typeof r.duration<"u"?r.duration:5e3;function c(){o||(o=!0,clearTimeout(a),n.remove(),hideDialog(s,n))}return n.onclick=function(h){h.preventDefault(),c()},showDialog(s,n),l&&(a=setTimeout(c,l)),c}function showDialog(s,e){var r=s.state.dialog;s.state.dialog=e,e&&r!==e&&(r&&r.contains(document.activeElement)&&s.focus(),r&&r.parentElement?r.parentElement.replaceChild(e,r):r&&r.remove(),CodeMirror.signal(s,"dialog"))}function hideDialog(s,e){s.state.dialog==e&&(s.state.dialog=null,CodeMirror.signal(s,"dialog"))}function openDialog(s,e,r,n){n||(n={}),closeNotification(s,void 0);var o=dialogDiv(s,e,n.bottom),a=!1;showDialog(s,o);function l(h){if(typeof h=="string")c.value=h;else{if(a)return;a=!0,hideDialog(s,o),s.state.dialog||s.focus(),n.onClose&&n.onClose(o)}}var c=o.getElementsByTagName("input")[0];return c&&(n.value&&(c.value=n.value,n.selectValueOnOpen!==!1&&c.select()),n.onInput&&CodeMirror.on(c,"input",function(h){n.onInput(h,c.value,l)}),n.onKeyUp&&CodeMirror.on(c,"keyup",function(h){n.onKeyUp(h,c.value,l)}),CodeMirror.on(c,"keydown",function(h){n&&n.onKeyDown&&n.onKeyDown(h,c.value,l)||(h.keyCode==13&&r(c.value),(h.keyCode==27||n.closeOnEnter!==!1&&h.keyCode==13)&&(c.blur(),CodeMirror.e_stop(h),l()))}),n.closeOnBlur!==!1&&CodeMirror.on(c,"blur",function(){setTimeout(function(){document.activeElement!==c&&l()})}),c.focus()),l}var matching={"(":")>",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<","<":">>",">":"<<"};function bracketRegex(s){return s&&s.bracketRegex||/[(){}[\]]/}function scanForBracket(s,e,r,n,o){for(var a=o&&o.maxScanLineLength||1e4,l=o&&o.maxScanLines||1e3,c=[],h=bracketRegex(o),f=r>0?Math.min(e.line+l,s.lastLine()+1):Math.max(s.firstLine()-1,e.line-l),d=e.line;d!=f;d+=r){var g=s.getLine(d);if(g){var y=r>0?0:g.length-1,I=r>0?g.length:-1;if(!(g.length>a))for(d==e.line&&(y=e.ch-(r<0?1:0));y!=I;y+=r){var P=g.charAt(y);if(h.test(P)){var N=matching[P];if(N&&N.charAt(1)==">"==r>0)c.push(P);else if(c.length)c.pop();else return{pos:new Pos(d,y),ch:P}}}}}return d-r==(r>0?s.lastLine():s.firstLine())?!1:null}function findMatchingTag(s,e){}function findEnclosingTag(s,e){var r,n,o=s.cm6.state,a=s.indexFromPos(e);if(a!r.eq(this.cursors[n]))){let r=this.cursorLayer.children;if(r.length!==e.length){this.cursorLayer.textContent="";for(const n of e)this.cursorLayer.appendChild(n.draw())}else e.forEach((n,o)=>n.adjust(r[o]));this.cursors=e}}destroy(){this.cursorLayer.remove()}}const themeSpec={".cm-vimMode .cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-fat-cursor":{position:"absolute",background:"#ff9696",border:"none",whiteSpace:"pre"},"&:not(.cm-focused) .cm-fat-cursor":{background:"none",outline:"solid 1px #ff9696",color:"transparent !important"}},hideNativeSelection=Prec.highest(EditorView.theme(themeSpec));function getBase(s){let e=s.scrollDOM.getBoundingClientRect();return{left:(s.textDirection==Direction.LTR?e.left:e.right-s.scrollDOM.clientWidth)-s.scrollDOM.scrollLeft,top:e.top-s.scrollDOM.scrollTop}}function measureCursor(s,e,r,n){let o=r.head,a=!1,l=1,c=s.state.vim;if(c&&(!c.insertMode||s.state.overwrite)){if(a=!0,c.visualBlock&&!n)return null;r.anchor1&&(o--,f=e.state.sliceDoc(o,o+1));let d=e.coordsAtPos(o,1);if(!d)return null;let g=getBase(e),y=e.domAtPos(o),I=y?y.node:e.contentDOM;for(;y&&y.node instanceof HTMLElement;)I=y.node,y={node:y.node.childNodes[y.offset],offset:0};if(!(I instanceof HTMLElement)){if(!I.parentNode)return null;I=I.parentNode}let P=getComputedStyle(I),N=d.left;if(!f||f==` -`||f=="\r")f=" ";else if(f==" "){f=" ";var h=e.coordsAtPos(o+1,-1);h&&(N=h.left-(h.left-d.left)/parseInt(P.tabSize))}else/[\uD800-\uDBFF]/.test(f)&&o{e.state.vim&&(e.state.vim.status=""),this.blockCursor.scheduleRedraw(),this.updateStatus()}),this.cm.on("vim-mode-change",r=>{e.state.vim.mode=r.mode,r.subMode&&(e.state.vim.mode+=" block"),e.state.vim.status="",this.blockCursor.scheduleRedraw(),this.updateClass(),this.updateStatus()}),this.cm.on("dialog",()=>{this.cm.state.statusbar?this.updateStatus():s.dispatch({effects:showVimPanel.of(!!this.cm.state.dialog)})}),this.dom=document.createElement("span"),this.dom.style.cssText="position: absolute; right: 10px; top: 1px",this.statusButton=document.createElement("span"),this.statusButton.onclick=r=>{Vim.handleKey(this.cm,"","user"),this.cm.focus()},this.statusButton.style.cssText="cursor: pointer"}update(s){var e;if((s.viewportChanged||s.docChanged)&&this.query&&this.highlight(this.query),s.docChanged&&this.cm.onChange(s),s.selectionSet&&this.cm.onSelectionChange(),s.viewportChanged,this.cm.curOp&&!this.cm.curOp.isVimOp&&this.cm.onBeforeEndOperation(),s.transactions){for(let r of s.transactions)for(let n of r.effects)if(n.is(setSearchQuery))if(!((e=n.value)===null||e===void 0?void 0:e.forVim))this.highlight(null);else{let a=n.value.create();this.highlight(a)}}this.blockCursor.update(s)}updateClass(){const s=this.cm.state;!s.vim||s.vim.insertMode&&!s.overwrite?this.view.scrollDOM.classList.remove("cm-vimMode"):this.view.scrollDOM.classList.add("cm-vimMode")}updateStatus(){let s=this.cm.state.statusbar,e=this.cm.state.vim;if(!s||!e)return;let r=this.cm.state.dialog;if(r)r.parentElement!=s&&(s.textContent="",s.appendChild(r));else{s.textContent="";var n=(e.mode||"normal").toUpperCase();e.insertModeReturn&&(n+="(C-O)"),this.statusButton.textContent=`--${n}--`,s.appendChild(this.statusButton)}this.dom.textContent=e.status,s.appendChild(this.dom)}destroy(){Vim.leaveVimMode(this.cm),this.updateClass(),this.blockCursor.destroy(),delete this.view.cm}highlight(s){if(this.query=s,!s)return this.decorations=Decoration.none;let{view:e}=this,r=new RangeSetBuilder;for(let n=0,o=e.visibleRanges,a=o.length;no[n+1].from-2*HighlightMargin;)c=o[++n].to;s.highlight(e.state,l,c,(h,f)=>{r.add(h,f,matchMark)})}return this.decorations=r.finish()}handleKey(s,e){const r=CodeMirror.vimKey(s),n=this.cm;if(!r)return;let o=n.state.vim;if(!o)return;if(r==""&&!o.insertMode&&!o.visualMode&&this.query){const c=o.searchState_;c&&(n.removeOverlay(c.getOverlay()),c.setOverlay(null))}if(r===""&&!CodeMirror.isMac&&n.somethingSelected())return this.waitForCopy=!0,!0;o.status=(o.status||"")+r;let l=Vim.multiSelectHandleKey(n,r,"user");return o=n.state.vim,!l&&o.insertMode&&n.state.overwrite&&(s.key&&s.key.length==1&&!/\n/.test(s.key)?(l=!0,n.overWriteSelection(s.key)):s.key=="Backspace"&&(l=!0,CodeMirror.commands.cursorCharLeft(n))),l&&(CodeMirror.signal(this.cm,"vim-keypress",r),s.preventDefault(),s.stopPropagation(),this.blockCursor.scheduleRedraw()),this.updateStatus(),!!l}},{eventHandlers:{copy:function(s,e){this.waitForCopy&&(this.waitForCopy=!1,Promise.resolve().then(()=>{var r=this.cm,n=r.state.vim;n&&(n.insertMode?r.setSelection(r.getCursor(),r.getCursor()):r.operation(()=>{r.curOp&&(r.curOp.isVimOp=!0),Vim.handleKey(r,"","user")}))}))},compositionstart:function(s,e){this.useNextTextInput=!0},keypress:function(s,e){this.lastKeydown=="Dead"&&this.handleKey(s,e)},keydown:function(s,e){this.lastKeydown=s.key,this.lastKeydown=="Unidentified"||this.lastKeydown=="Process"||this.lastKeydown=="Dead"?this.useNextTextInput=!0:(this.useNextTextInput=!1,this.handleKey(s,e))}},provide:()=>[EditorView.inputHandler.of((s,e,r,n)=>{var o,a,l=getCM(s);if(!l)return!1;var c=(o=l.state)===null||o===void 0?void 0:o.vim,h=l.state.vimPlugin;return c&&!c.insertMode&&!(!((a=l.curOp)===null||a===void 0)&&a.isVimOp)?(n==="\0\0"||(n.length==1&&h.useNextTextInput&&h.handleKey({key:n,preventDefault:()=>{},stopPropagation:()=>{}}),forceEndComposition(s)),!0):!1})],decorations:s=>s.decorations});function forceEndComposition(s){var e=s.scrollDOM.parentElement;if(e){if(FIREFOX_LINUX){s.contentDOM.textContent="\0\0",s.contentDOM.dispatchEvent(new CustomEvent("compositionend"));return}var r=s.scrollDOM.nextSibling,n=window.getSelection(),o=n&&{anchorNode:n.anchorNode,anchorOffset:n.anchorOffset,focusNode:n.focusNode,focusOffset:n.focusOffset};s.scrollDOM.remove(),e.insertBefore(s.scrollDOM,r);try{o&&n&&(n.setPosition(o.anchorNode,o.anchorOffset),o.focusNode&&n.extend(o.focusNode,o.focusOffset))}catch(a){console.error(a)}s.focus(),s.contentDOM.dispatchEvent(new CustomEvent("compositionend"))}}const matchMark=Decoration.mark({class:"cm-searchMatch"}),showVimPanel=StateEffect.define(),vimPanelState=StateField.define({create:()=>!1,update(s,e){for(let r of e.effects)r.is(showVimPanel)&&(s=r.value);return s},provide:s=>showPanel.from(s,e=>e?createVimPanel:null)});function createVimPanel(s){let e=document.createElement("div");e.className="cm-vim-panel";let r=s.cm;return r.state.dialog&&e.appendChild(r.state.dialog),{top:!1,dom:e}}function statusPanel(s){let e=document.createElement("div");e.className="cm-vim-panel";let r=s.cm;return r.state.statusbar=e,r.state.vimPlugin.updateStatus(),{dom:e}}function vim(s={}){return[vimStyle,vimPlugin,hideNativeSelection,s.status?showPanel.of(statusPanel):vimPanelState]}function getCM(s){return s.cm||null}function codeInterceptor(s){return s.replace(/->/g,"&&").replace(/t\[(\d+),(\d+)\]/g,"mod($1,$2)").replace(/b\[(\d+),(\d+)\]/g,"[$1,$2].includes(beat)").replace(/eb\[(\d+),(\d+)\]/g,"[$1,$2].includes(ebeat)").replace(/m\[(\d+),(\d+)\]/g,"[$1,$2].includes(bar)")}const delay=s=>new Promise((e,r)=>setTimeout(()=>r(new Error("Operation took too long")),s)),tryCatchWrapper=(s,e)=>new Promise((r,n)=>{try{Function(`with (this) {try{${codeInterceptor(e)}} catch (e) {console.log(e)}};`).call(s.api),r(!0)}catch(o){console.log(o),r(!1)}}),tryEvaluate=async(s,e,r=5e3)=>{try{e.evaluations++,await Promise.race([tryCatchWrapper(s,`let i = ${e.evaluations};`+codeInterceptor(e.candidate)),delay(r)])?e.committed=e.candidate:await evaluate(s,e,r)}catch(n){console.log(n)}},evaluate=async(s,e,r=1e3)=>{try{await Promise.race([tryCatchWrapper(s,codeInterceptor(e.committed)),delay(r)]),e.evaluations&&e.evaluations++}catch(n){console.log(n)}},zeroPad=(s,e)=>String(s).padStart(e,"0");class TransportNode extends AudioWorkletNode{constructor(r,n,o){super(r,"transport",n);$e(this,"handleMessage",r=>{if(r.data&&r.data.type==="bang"){this.startTime===null&&(this.startTime=r.data.currentTime),this.elapsedTime=r.data.currentTime-this.startTime,this.prevCurrentTime=r.data.currentTime;let{futureTimeStamp:n,timeToNextPulse:o,nextPulsePosition:a}=this.convertTimeToNextBarsBeats(this.elapsedTime);this.nextPulsePosition!==a&&(this.nextPulsePosition=a,setTimeout(()=>{const l=performance.now();this.app.clock.time_position=n,this.$clock.innerHTML=`[${n.bar}:${n.beat}:${zeroPad(n.pulse,"2")}]`,tryEvaluate(this.app,this.app.global_buffer),this.hasBeenEvaluated=!0,this.currentPulsePosition=a;const c=performance.now();this.lastLatencies[this.indexOfLastLatencies]=c-l,this.indexOfLastLatencies=(this.indexOfLastLatencies+1)%this.lastLatencies.length;const h=this.lastLatencies.reduce((f,d)=>f+d)/this.lastLatencies.length;this.executionLatency=h/1e3},(o+this.executionLatency)*1e3))}});this.app=o,this.port.addEventListener("message",this.handleMessage),this.port.start(),this.$clock=document.getElementById("clockviewer"),this.hasBeenEvaluated=!1,this.currentPulsePosition=0,this.nextPulsePosition=-1,this.executionLatency=0,this.lastLatencies=[0,0,0,0,0,0,0,0,0,0],this.indexOfLastLatencies=0,this.startTime=null,this.elapsedTime=0}start(){this.port.postMessage("start")}pause(){this.port.postMessage("pause")}stop(){this.startTime=null,this.elapsedTime=null,this.app.clock.tick=0,this.$clock.innerHTML=`[1 | 1 | ${zeroPad(1,"2")}]`,this.port.postMessage("stop")}convertTimeToBarsBeats(r){const n=60/this.app.clock.bpm,o=r/n,a=this.app.clock.time_signature[0],l=Math.floor(o/a)+1,c=Math.floor(o%a)+1,h=Math.floor(o%1*this.app.clock.ppqn);return this.app.clock.tick++,{bar:l,beat:c,ppqn:h}}convertTimeToNextBarsBeats(r){const n=60/this.app.clock.bpm,o=r/n,a=this.app.clock.time_signature[0];this.currentPulsePosition=o*this.app.clock.ppqn;const l=Math.ceil(this.currentPulsePosition),c=this.app.clock.convertPulseToSecond(this.nextPulsePosition-this.currentPulsePosition),h=this.nextPulsePosition/this.app.clock.ppqn,f=h/a,d={bar:Math.floor(f)+1,beat:Math.floor(h)%a+1,pulse:Math.floor(this.nextPulsePosition)%this.app.clock.ppqn};return this.app.clock.tick++,{futureTimeStamp:d,timeToNextPulse:c,nextPulsePosition:l}}}const TransportProcessor="/assets/TransportProcessor-9e6f56da.js";class Clock{constructor(e,r){$e(this,"ctx");$e(this,"transportNode");$e(this,"bpm");$e(this,"time_signature");$e(this,"time_position");$e(this,"ppqn");$e(this,"tick");this.app=e,this.transportNode=null,this.ctx=r,this.tick=0,this.time_position={bar:0,beat:0,pulse:0},this.bpm=120,this.time_signature=[4,4],this.ppqn=48,r.audioWorklet.addModule(TransportProcessor).then(n=>(this.transportNode=new TransportNode(r,{},this.app),this.transportNode.connect(r.destination),n)).catch(n=>{console.log("Error loading TransportProcessor.js:",n)})}get beats_per_bar(){return this.time_signature[0]}get beats_since_origin(){return(this.time_position.bar-1)*this.beats_per_bar+this.time_position.beat}get pulse_duration(){return 60/this.bpm/this.ppqn}convertPulseToSecond(e){return e*this.pulse_duration}start(){var e,r;((e=this.transportNode)==null?void 0:e.state)==="running"?console.log("Already started"):(this.app.audioContext.resume(),(r=this.transportNode)==null||r.start())}pause(){var e;(e=this.transportNode)==null||e.pause()}stop(){var e;(e=this.transportNode)==null||e.stop()}}const global_text=` +`||f=="\r")f=" ";else if(f==" "){f=" ";var h=e.coordsAtPos(o+1,-1);h&&(N=h.left-(h.left-d.left)/parseInt(P.tabSize))}else/[\uD800-\uDBFF]/.test(f)&&o{e.state.vim&&(e.state.vim.status=""),this.blockCursor.scheduleRedraw(),this.updateStatus()}),this.cm.on("vim-mode-change",r=>{e.state.vim.mode=r.mode,r.subMode&&(e.state.vim.mode+=" block"),e.state.vim.status="",this.blockCursor.scheduleRedraw(),this.updateClass(),this.updateStatus()}),this.cm.on("dialog",()=>{this.cm.state.statusbar?this.updateStatus():s.dispatch({effects:showVimPanel.of(!!this.cm.state.dialog)})}),this.dom=document.createElement("span"),this.dom.style.cssText="position: absolute; right: 10px; top: 1px",this.statusButton=document.createElement("span"),this.statusButton.onclick=r=>{Vim.handleKey(this.cm,"","user"),this.cm.focus()},this.statusButton.style.cssText="cursor: pointer"}update(s){var e;if((s.viewportChanged||s.docChanged)&&this.query&&this.highlight(this.query),s.docChanged&&this.cm.onChange(s),s.selectionSet&&this.cm.onSelectionChange(),s.viewportChanged,this.cm.curOp&&!this.cm.curOp.isVimOp&&this.cm.onBeforeEndOperation(),s.transactions){for(let r of s.transactions)for(let n of r.effects)if(n.is(setSearchQuery))if(!((e=n.value)===null||e===void 0?void 0:e.forVim))this.highlight(null);else{let a=n.value.create();this.highlight(a)}}this.blockCursor.update(s)}updateClass(){const s=this.cm.state;!s.vim||s.vim.insertMode&&!s.overwrite?this.view.scrollDOM.classList.remove("cm-vimMode"):this.view.scrollDOM.classList.add("cm-vimMode")}updateStatus(){let s=this.cm.state.statusbar,e=this.cm.state.vim;if(!s||!e)return;let r=this.cm.state.dialog;if(r)r.parentElement!=s&&(s.textContent="",s.appendChild(r));else{s.textContent="";var n=(e.mode||"normal").toUpperCase();e.insertModeReturn&&(n+="(C-O)"),this.statusButton.textContent=`--${n}--`,s.appendChild(this.statusButton)}this.dom.textContent=e.status,s.appendChild(this.dom)}destroy(){Vim.leaveVimMode(this.cm),this.updateClass(),this.blockCursor.destroy(),delete this.view.cm}highlight(s){if(this.query=s,!s)return this.decorations=Decoration.none;let{view:e}=this,r=new RangeSetBuilder;for(let n=0,o=e.visibleRanges,a=o.length;no[n+1].from-2*HighlightMargin;)c=o[++n].to;s.highlight(e.state,l,c,(h,f)=>{r.add(h,f,matchMark)})}return this.decorations=r.finish()}handleKey(s,e){const r=CodeMirror.vimKey(s),n=this.cm;if(!r)return;let o=n.state.vim;if(!o)return;if(r==""&&!o.insertMode&&!o.visualMode&&this.query){const c=o.searchState_;c&&(n.removeOverlay(c.getOverlay()),c.setOverlay(null))}if(r===""&&!CodeMirror.isMac&&n.somethingSelected())return this.waitForCopy=!0,!0;o.status=(o.status||"")+r;let l=Vim.multiSelectHandleKey(n,r,"user");return o=n.state.vim,!l&&o.insertMode&&n.state.overwrite&&(s.key&&s.key.length==1&&!/\n/.test(s.key)?(l=!0,n.overWriteSelection(s.key)):s.key=="Backspace"&&(l=!0,CodeMirror.commands.cursorCharLeft(n))),l&&(CodeMirror.signal(this.cm,"vim-keypress",r),s.preventDefault(),s.stopPropagation(),this.blockCursor.scheduleRedraw()),this.updateStatus(),!!l}},{eventHandlers:{copy:function(s,e){this.waitForCopy&&(this.waitForCopy=!1,Promise.resolve().then(()=>{var r=this.cm,n=r.state.vim;n&&(n.insertMode?r.setSelection(r.getCursor(),r.getCursor()):r.operation(()=>{r.curOp&&(r.curOp.isVimOp=!0),Vim.handleKey(r,"","user")}))}))},compositionstart:function(s,e){this.useNextTextInput=!0},keypress:function(s,e){this.lastKeydown=="Dead"&&this.handleKey(s,e)},keydown:function(s,e){this.lastKeydown=s.key,this.lastKeydown=="Unidentified"||this.lastKeydown=="Process"||this.lastKeydown=="Dead"?this.useNextTextInput=!0:(this.useNextTextInput=!1,this.handleKey(s,e))}},provide:()=>[EditorView.inputHandler.of((s,e,r,n)=>{var o,a,l=getCM(s);if(!l)return!1;var c=(o=l.state)===null||o===void 0?void 0:o.vim,h=l.state.vimPlugin;return c&&!c.insertMode&&!(!((a=l.curOp)===null||a===void 0)&&a.isVimOp)?(n==="\0\0"||(n.length==1&&h.useNextTextInput&&h.handleKey({key:n,preventDefault:()=>{},stopPropagation:()=>{}}),forceEndComposition(s)),!0):!1})],decorations:s=>s.decorations});function forceEndComposition(s){var e=s.scrollDOM.parentElement;if(e){if(FIREFOX_LINUX){s.contentDOM.textContent="\0\0",s.contentDOM.dispatchEvent(new CustomEvent("compositionend"));return}var r=s.scrollDOM.nextSibling,n=window.getSelection(),o=n&&{anchorNode:n.anchorNode,anchorOffset:n.anchorOffset,focusNode:n.focusNode,focusOffset:n.focusOffset};s.scrollDOM.remove(),e.insertBefore(s.scrollDOM,r);try{o&&n&&(n.setPosition(o.anchorNode,o.anchorOffset),o.focusNode&&n.extend(o.focusNode,o.focusOffset))}catch(a){console.error(a)}s.focus(),s.contentDOM.dispatchEvent(new CustomEvent("compositionend"))}}const matchMark=Decoration.mark({class:"cm-searchMatch"}),showVimPanel=StateEffect.define(),vimPanelState=StateField.define({create:()=>!1,update(s,e){for(let r of e.effects)r.is(showVimPanel)&&(s=r.value);return s},provide:s=>showPanel.from(s,e=>e?createVimPanel:null)});function createVimPanel(s){let e=document.createElement("div");e.className="cm-vim-panel";let r=s.cm;return r.state.dialog&&e.appendChild(r.state.dialog),{top:!1,dom:e}}function statusPanel(s){let e=document.createElement("div");e.className="cm-vim-panel";let r=s.cm;return r.state.statusbar=e,r.state.vimPlugin.updateStatus(),{dom:e}}function vim(s={}){return[vimStyle,vimPlugin,hideNativeSelection,s.status?showPanel.of(statusPanel):vimPanelState]}function getCM(s){return s.cm||null}const delay=s=>new Promise((e,r)=>setTimeout(()=>r(new Error("Operation took too long")),s)),tryCatchWrapper=(s,e)=>new Promise((r,n)=>{try{Function(`with (this) {try{${e}} catch (e) {console.log(e)}};`).call(s.api),r(!0)}catch(o){console.log(o),r(!1)}}),tryEvaluate=async(s,e,r=5e3)=>{try{e.evaluations++,await Promise.race([tryCatchWrapper(s,`let i = ${e.evaluations};`+e.candidate),delay(r)])?e.committed=e.candidate:await evaluate(s,e,r)}catch(n){console.log(n)}},evaluate=async(s,e,r=1e3)=>{try{await Promise.race([tryCatchWrapper(s,e.committed),delay(r)]),e.evaluations&&e.evaluations++}catch(n){console.log(n)}},zeroPad=(s,e)=>String(s).padStart(e,"0");class TransportNode extends AudioWorkletNode{constructor(r,n,o){super(r,"transport",n);$e(this,"handleMessage",r=>{if(r.data&&r.data.type==="bang"){this.startTime===null&&(this.startTime=r.data.currentTime),this.elapsedTime=r.data.currentTime-this.startTime,this.prevCurrentTime=r.data.currentTime;let{futureTimeStamp:n,timeToNextPulse:o,nextPulsePosition:a}=this.convertTimeToNextBarsBeats(this.elapsedTime);this.nextPulsePosition!==a&&(this.nextPulsePosition=a,setTimeout(()=>{const l=performance.now();this.app.clock.time_position=n,this.$clock.innerHTML=`[${n.bar}:${n.beat}:${zeroPad(n.pulse,"2")}]`,tryEvaluate(this.app,this.app.global_buffer),this.hasBeenEvaluated=!0,this.currentPulsePosition=a;const c=performance.now();this.lastLatencies[this.indexOfLastLatencies]=c-l,this.indexOfLastLatencies=(this.indexOfLastLatencies+1)%this.lastLatencies.length;const h=this.lastLatencies.reduce((f,d)=>f+d)/this.lastLatencies.length;this.executionLatency=h/1e3},(o+this.executionLatency)*1e3))}});this.app=o,this.port.addEventListener("message",this.handleMessage),this.port.start(),this.$clock=document.getElementById("clockviewer"),this.hasBeenEvaluated=!1,this.currentPulsePosition=0,this.nextPulsePosition=-1,this.executionLatency=0,this.lastLatencies=[0,0,0,0,0,0,0,0,0,0],this.indexOfLastLatencies=0,this.startTime=null,this.elapsedTime=0}start(){this.port.postMessage("start")}pause(){this.port.postMessage("pause")}stop(){this.startTime=null,this.elapsedTime=null,this.app.clock.tick=0,this.$clock.innerHTML=`[1 | 1 | ${zeroPad(1,"2")}]`,this.port.postMessage("stop")}convertTimeToBarsBeats(r){const n=60/this.app.clock.bpm,o=r/n,a=this.app.clock.time_signature[0],l=Math.floor(o/a)+1,c=Math.floor(o%a)+1,h=Math.floor(o%1*this.app.clock.ppqn);return this.app.clock.tick++,{bar:l,beat:c,ppqn:h}}convertTimeToNextBarsBeats(r){const n=60/this.app.clock.bpm,o=r/n,a=this.app.clock.time_signature[0];this.currentPulsePosition=o*this.app.clock.ppqn;const l=Math.ceil(this.currentPulsePosition),c=this.app.clock.convertPulseToSecond(this.nextPulsePosition-this.currentPulsePosition),h=this.nextPulsePosition/this.app.clock.ppqn,f=h/a,d={bar:Math.floor(f)+1,beat:Math.floor(h)%a+1,pulse:Math.floor(this.nextPulsePosition)%this.app.clock.ppqn};return this.app.clock.tick++,{futureTimeStamp:d,timeToNextPulse:c,nextPulsePosition:l}}}const TransportProcessor="/assets/TransportProcessor-9e6f56da.js";class Clock{constructor(e,r){$e(this,"ctx");$e(this,"transportNode");$e(this,"bpm");$e(this,"time_signature");$e(this,"time_position");$e(this,"ppqn");$e(this,"tick");this.app=e,this.transportNode=null,this.ctx=r,this.tick=0,this.time_position={bar:0,beat:0,pulse:0},this.bpm=120,this.time_signature=[4,4],this.ppqn=48,r.audioWorklet.addModule(TransportProcessor).then(n=>(this.transportNode=new TransportNode(r,{},this.app),this.transportNode.connect(r.destination),n)).catch(n=>{console.log("Error loading TransportProcessor.js:",n)})}get beats_per_bar(){return this.time_signature[0]}get beats_since_origin(){return(this.time_position.bar-1)*this.beats_per_bar+this.time_position.beat}get pulse_duration(){return 60/this.bpm/this.ppqn}convertPulseToSecond(e){return e*this.pulse_duration}start(){var e,r;((e=this.transportNode)==null?void 0:e.state)==="running"?console.log("Already started"):(this.app.audioContext.resume(),(r=this.transportNode)==null||r.start())}pause(){var e;(e=this.transportNode)==null||e.pause()}stop(){var e;(e=this.transportNode)==null||e.stop()}}const global_text=` // Global buffer: a central buffer to command them all. // ==================================================== // The global buffer is a special buffer used to control @@ -80,4 +80,4 @@ var Dn=Object.defineProperty;var Bn=(s,e,r)=>e in s?Dn(s,e,{enumerable:!0,config `+a.line+" | "+f+` `+h+" | "+peg$padEnd("",o.column-1," ")+peg$padEnd("",g,"^")}else e+=` at `+l}return e},peg$SyntaxError.buildMessage=function(s,e){var r={literal:function(f){return'"'+o(f.text)+'"'},class:function(f){var d=f.parts.map(function(g){return Array.isArray(g)?a(g[0])+"-"+a(g[1]):a(g)});return"["+(f.inverted?"^":"")+d.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(f){return f.description}};function n(f){return f.charCodeAt(0).toString(16).toUpperCase()}function o(f){return f.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(d){return"\\x0"+n(d)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(d){return"\\x"+n(d)})}function a(f){return f.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(d){return"\\x0"+n(d)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(d){return"\\x"+n(d)})}function l(f){return r[f.type](f)}function c(f){var d=f.map(l),g,y;if(d.sort(),d.length>0){for(g=1,y=1;g",peg$c9="[",peg$c10="+",peg$c11="*",peg$c12="%",peg$c13="&",peg$c14="|",peg$c15="<<",peg$c16=">>",peg$r0=/^[' '\t\r\n]/,peg$r1=/^[0-9]/,peg$e0=peg$classExpectation(["'"," ","'"," ","\r",` -`],!1,!1),peg$e1=peg$literalExpectation("(",!1),peg$e2=peg$literalExpectation(",",!1),peg$e3=peg$literalExpectation(")",!1),peg$e4=peg$classExpectation([["0","9"]],!1,!1),peg$e5=peg$literalExpectation(".",!1),peg$e6=peg$literalExpectation("-",!1),peg$e7=peg$literalExpectation("/",!1),peg$e8=peg$literalExpectation("\\",!1),peg$e9=peg$literalExpectation("<",!1),peg$e10=peg$literalExpectation(">",!1),peg$e11=peg$literalExpectation("[",!1),peg$e12=peg$literalExpectation("+",!1),peg$e13=peg$literalExpectation("*",!1),peg$e14=peg$literalExpectation("%",!1),peg$e15=peg$literalExpectation("&",!1),peg$e16=peg$literalExpectation("|",!1),peg$e17=peg$literalExpectation("<<",!1),peg$e18=peg$literalExpectation(">>",!1),peg$f0=function(s){return centsToSemitones(s.filter(e=>e))},peg$f1=function(){},peg$f2=function(s,e){return Math.floor(Math.random()*(e-s+1)+s)},peg$f3=function(s,e){return Math.random()*(e-s)+s},peg$f4=function(){return parseFloat(text())},peg$f5=function(){return parseInt(text())},peg$f6=function(s){return ratioToCents(s)},peg$f7=function(s,e){return s/e},peg$f8=function(s,e){return Math.pow(2,s/e)},peg$f9=function(s,e,r,n){var o=n?r/n:r;return Math.pow(o,s/e)},peg$f10=function(s,e){return parseFloat(s.toString()+"."+e.toString())},peg$f11=function(s){return s.filter(e=>e)},peg$f12=function(s){return monzoToCents(s)},peg$f13=function(){return eval(text())},peg$currPos=0,peg$savedPos=0,peg$posDetailsCache=[{line:1,column:1}],peg$maxFailPos=0,peg$maxFailExpected=[],peg$resultsCache={},peg$result;if("startRule"in options){if(!(options.startRule in peg$startRuleFunctions))throw new Error(`Can't start parsing from rule "`+options.startRule+'".');peg$startRuleFunction=peg$startRuleFunctions[options.startRule]}function text(){return input.substring(peg$savedPos,peg$currPos)}function peg$literalExpectation(s,e){return{type:"literal",text:s,ignoreCase:e}}function peg$classExpectation(s,e,r){return{type:"class",parts:s,inverted:e,ignoreCase:r}}function peg$endExpectation(){return{type:"end"}}function peg$computePosDetails(s){var e=peg$posDetailsCache[s],r;if(e)return e;for(r=s-1;!peg$posDetailsCache[r];)r--;for(e=peg$posDetailsCache[r],e={line:e.line,column:e.column};rpeg$maxFailPos&&(peg$maxFailPos=peg$currPos,peg$maxFailExpected=[]),peg$maxFailExpected.push(s))}function peg$buildStructuredError(s,e,r){return new peg$SyntaxError(peg$SyntaxError.buildMessage(s,e),s,e,r)}function peg$parselines(){var s,e,r,n=peg$currPos*17+0,o=peg$resultsCache[n];if(o)return peg$currPos=o.nextPos,o.result;if(s=peg$currPos,e=[],r=peg$parseratio(),r===peg$FAILED&&(r=peg$parsevalue(),r===peg$FAILED&&(r=peg$parsemonzo(),r===peg$FAILED&&(r=peg$parseoperation(),r===peg$FAILED&&(r=peg$parsesep())))),r!==peg$FAILED)for(;r!==peg$FAILED;)e.push(r),r=peg$parseratio(),r===peg$FAILED&&(r=peg$parsevalue(),r===peg$FAILED&&(r=peg$parsemonzo(),r===peg$FAILED&&(r=peg$parseoperation(),r===peg$FAILED&&(r=peg$parsesep()))));else e=peg$FAILED;return e!==peg$FAILED&&(peg$savedPos=s,e=peg$f0(e)),s=e,peg$resultsCache[n]={nextPos:peg$currPos,result:s},s}function peg$parsesep(){var s,e,r=peg$currPos*17+1,n=peg$resultsCache[r];return n?(peg$currPos=n.nextPos,n.result):(s=peg$currPos,peg$r0.test(input.charAt(peg$currPos))?(e=input.charAt(peg$currPos),peg$currPos++):(e=peg$FAILED,peg$fail(peg$e0)),e!==peg$FAILED&&(peg$savedPos=s,e=peg$f1()),s=e,peg$resultsCache[r]={nextPos:peg$currPos,result:s},s)}function peg$parsevalue(){var s,e=peg$currPos*17+2,r=peg$resultsCache[e];return r?(peg$currPos=r.nextPos,r.result):(s=peg$parsefloat(),s===peg$FAILED&&(s=peg$parseint(),s===peg$FAILED&&(s=peg$parserandom_int(),s===peg$FAILED&&(s=peg$parserandom_float()))),peg$resultsCache[e]={nextPos:peg$currPos,result:s},s)}function peg$parserandom_int(){var s,e,r,n,o,a,l=peg$currPos*17+3,c=peg$resultsCache[l];return c?(peg$currPos=c.nextPos,c.result):(s=peg$currPos,input.charCodeAt(peg$currPos)===40?(e=peg$c0,peg$currPos++):(e=peg$FAILED,peg$fail(peg$e1)),e!==peg$FAILED?(r=peg$parseint(),r!==peg$FAILED?(input.charCodeAt(peg$currPos)===44?(n=peg$c1,peg$currPos++):(n=peg$FAILED,peg$fail(peg$e2)),n!==peg$FAILED?(o=peg$parseint(),o!==peg$FAILED?(input.charCodeAt(peg$currPos)===41?(a=peg$c2,peg$currPos++):(a=peg$FAILED,peg$fail(peg$e3)),a!==peg$FAILED?(peg$savedPos=s,s=peg$f2(r,o)):(peg$currPos=s,s=peg$FAILED)):(peg$currPos=s,s=peg$FAILED)):(peg$currPos=s,s=peg$FAILED)):(peg$currPos=s,s=peg$FAILED)):(peg$currPos=s,s=peg$FAILED),peg$resultsCache[l]={nextPos:peg$currPos,result:s},s)}function peg$parserandom_float(){var s,e,r,n,o,a,l=peg$currPos*17+4,c=peg$resultsCache[l];return c?(peg$currPos=c.nextPos,c.result):(s=peg$currPos,input.charCodeAt(peg$currPos)===40?(e=peg$c0,peg$currPos++):(e=peg$FAILED,peg$fail(peg$e1)),e!==peg$FAILED?(r=peg$parsefloat(),r!==peg$FAILED?(input.charCodeAt(peg$currPos)===44?(n=peg$c1,peg$currPos++):(n=peg$FAILED,peg$fail(peg$e2)),n!==peg$FAILED?(o=peg$parsefloat(),o!==peg$FAILED?(input.charCodeAt(peg$currPos)===41?(a=peg$c2,peg$currPos++):(a=peg$FAILED,peg$fail(peg$e3)),a!==peg$FAILED?(peg$savedPos=s,s=peg$f3(r,o)):(peg$currPos=s,s=peg$FAILED)):(peg$currPos=s,s=peg$FAILED)):(peg$currPos=s,s=peg$FAILED)):(peg$currPos=s,s=peg$FAILED)):(peg$currPos=s,s=peg$FAILED),peg$resultsCache[l]={nextPos:peg$currPos,result:s},s)}function peg$parsefloat(){var s,e,r,n,o,a,l,c=peg$currPos*17+5,h=peg$resultsCache[c];if(h)return peg$currPos=h.nextPos,h.result;if(s=peg$currPos,e=peg$currPos,r=[],peg$r1.test(input.charAt(peg$currPos))?(n=input.charAt(peg$currPos),peg$currPos++):(n=peg$FAILED,peg$fail(peg$e4)),n!==peg$FAILED)for(;n!==peg$FAILED;)r.push(n),peg$r1.test(input.charAt(peg$currPos))?(n=input.charAt(peg$currPos),peg$currPos++):(n=peg$FAILED,peg$fail(peg$e4));else r=peg$FAILED;if(r!==peg$FAILED?(input.charCodeAt(peg$currPos)===46?(n=peg$c3,peg$currPos++):(n=peg$FAILED,peg$fail(peg$e5)),n!==peg$FAILED?(r=[r,n],e=r):(peg$currPos=e,e=peg$FAILED)):(peg$currPos=e,e=peg$FAILED),e===peg$FAILED){for(e=peg$currPos,input.charCodeAt(peg$currPos)===45?(r=peg$c4,peg$currPos++):(r=peg$FAILED,peg$fail(peg$e6)),r===peg$FAILED&&(r=null),n=[],peg$r1.test(input.charAt(peg$currPos))?(o=input.charAt(peg$currPos),peg$currPos++):(o=peg$FAILED,peg$fail(peg$e4));o!==peg$FAILED;)n.push(o),peg$r1.test(input.charAt(peg$currPos))?(o=input.charAt(peg$currPos),peg$currPos++):(o=peg$FAILED,peg$fail(peg$e4));if(input.charCodeAt(peg$currPos)===46?(o=peg$c3,peg$currPos++):(o=peg$FAILED,peg$fail(peg$e5)),o!==peg$FAILED){if(a=[],peg$r1.test(input.charAt(peg$currPos))?(l=input.charAt(peg$currPos),peg$currPos++):(l=peg$FAILED,peg$fail(peg$e4)),l!==peg$FAILED)for(;l!==peg$FAILED;)a.push(l),peg$r1.test(input.charAt(peg$currPos))?(l=input.charAt(peg$currPos),peg$currPos++):(l=peg$FAILED,peg$fail(peg$e4));else a=peg$FAILED;a!==peg$FAILED?(r=[r,n,o,a],e=r):(peg$currPos=e,e=peg$FAILED)}else peg$currPos=e,e=peg$FAILED;if(e===peg$FAILED)if(e=peg$currPos,input.charCodeAt(peg$currPos)===46?(r=peg$c3,peg$currPos++):(r=peg$FAILED,peg$fail(peg$e5)),r!==peg$FAILED){if(n=[],peg$r1.test(input.charAt(peg$currPos))?(o=input.charAt(peg$currPos),peg$currPos++):(o=peg$FAILED,peg$fail(peg$e4)),o!==peg$FAILED)for(;o!==peg$FAILED;)n.push(o),peg$r1.test(input.charAt(peg$currPos))?(o=input.charAt(peg$currPos),peg$currPos++):(o=peg$FAILED,peg$fail(peg$e4));else n=peg$FAILED;n!==peg$FAILED?(r=[r,n],e=r):(peg$currPos=e,e=peg$FAILED)}else peg$currPos=e,e=peg$FAILED}return e!==peg$FAILED&&(peg$savedPos=s,e=peg$f4()),s=e,peg$resultsCache[c]={nextPos:peg$currPos,result:s},s}function peg$parseint(){var s,e,r,n=peg$currPos*17+6,o=peg$resultsCache[n];if(o)return peg$currPos=o.nextPos,o.result;if(s=peg$currPos,input.charCodeAt(peg$currPos)===45?peg$currPos++:peg$fail(peg$e6),e=[],peg$r1.test(input.charAt(peg$currPos))?(r=input.charAt(peg$currPos),peg$currPos++):(r=peg$FAILED,peg$fail(peg$e4)),r!==peg$FAILED)for(;r!==peg$FAILED;)e.push(r),peg$r1.test(input.charAt(peg$currPos))?(r=input.charAt(peg$currPos),peg$currPos++):(r=peg$FAILED,peg$fail(peg$e4));else e=peg$FAILED;return e!==peg$FAILED?(peg$savedPos=s,s=peg$f5()):(peg$currPos=s,s=peg$FAILED),peg$resultsCache[n]={nextPos:peg$currPos,result:s},s}function peg$parseratio(){var s,e,r=peg$currPos*17+7,n=peg$resultsCache[r];return n?(peg$currPos=n.nextPos,n.result):(s=peg$currPos,e=peg$parseedji_ratio(),e===peg$FAILED&&(e=peg$parseedo_ratio(),e===peg$FAILED&&(e=peg$parsefrac_ratio(),e===peg$FAILED&&(e=peg$parsedecimal_ratio()))),e!==peg$FAILED&&(peg$savedPos=s,e=peg$f6(e)),s=e,peg$resultsCache[r]={nextPos:peg$currPos,result:s},s)}function peg$parsefrac_ratio(){var s,e,r,n,o=peg$currPos*17+8,a=peg$resultsCache[o];return a?(peg$currPos=a.nextPos,a.result):(s=peg$currPos,e=peg$parseint(),e===peg$FAILED&&(e=peg$parserandom_int()),e!==peg$FAILED?(input.charCodeAt(peg$currPos)===47?(r=peg$c5,peg$currPos++):(r=peg$FAILED,peg$fail(peg$e7)),r!==peg$FAILED?(n=peg$parseint(),n===peg$FAILED&&(n=peg$parserandom_int()),n!==peg$FAILED?(peg$savedPos=s,s=peg$f7(e,n)):(peg$currPos=s,s=peg$FAILED)):(peg$currPos=s,s=peg$FAILED)):(peg$currPos=s,s=peg$FAILED),peg$resultsCache[o]={nextPos:peg$currPos,result:s},s)}function peg$parseedo_ratio(){var s,e,r,n,o=peg$currPos*17+9,a=peg$resultsCache[o];return a?(peg$currPos=a.nextPos,a.result):(s=peg$currPos,e=peg$parseint(),e===peg$FAILED&&(e=peg$parserandom_int()),e!==peg$FAILED?(input.charCodeAt(peg$currPos)===92?(r=peg$c6,peg$currPos++):(r=peg$FAILED,peg$fail(peg$e8)),r!==peg$FAILED?(n=peg$parseint(),n===peg$FAILED&&(n=peg$parserandom_int()),n!==peg$FAILED?(peg$savedPos=s,s=peg$f8(e,n)):(peg$currPos=s,s=peg$FAILED)):(peg$currPos=s,s=peg$FAILED)):(peg$currPos=s,s=peg$FAILED),peg$resultsCache[o]={nextPos:peg$currPos,result:s},s)}function peg$parseedji_ratio(){var s,e,r,n,o,a,l,c,h=peg$currPos*17+10,f=peg$resultsCache[h];return f?(peg$currPos=f.nextPos,f.result):(s=peg$currPos,e=peg$parseint(),e===peg$FAILED&&(e=peg$parserandom_int()),e!==peg$FAILED?(input.charCodeAt(peg$currPos)===92?(r=peg$c6,peg$currPos++):(r=peg$FAILED,peg$fail(peg$e8)),r!==peg$FAILED?(n=peg$parseint(),n===peg$FAILED&&(n=peg$parserandom_int()),n!==peg$FAILED?(input.charCodeAt(peg$currPos)===60?(o=peg$c7,peg$currPos++):(o=peg$FAILED,peg$fail(peg$e9)),o!==peg$FAILED?(a=peg$parseint(),a===peg$FAILED&&(a=peg$parserandom_int()),a!==peg$FAILED?(input.charCodeAt(peg$currPos)===47?peg$currPos++:peg$fail(peg$e7),l=peg$parseint(),l===peg$FAILED&&(l=peg$parserandom_int()),l===peg$FAILED&&(l=null),input.charCodeAt(peg$currPos)===62?(c=peg$c8,peg$currPos++):(c=peg$FAILED,peg$fail(peg$e10)),c!==peg$FAILED?(peg$savedPos=s,s=peg$f9(e,n,a,l)):(peg$currPos=s,s=peg$FAILED)):(peg$currPos=s,s=peg$FAILED)):(peg$currPos=s,s=peg$FAILED)):(peg$currPos=s,s=peg$FAILED)):(peg$currPos=s,s=peg$FAILED)):(peg$currPos=s,s=peg$FAILED),peg$resultsCache[h]={nextPos:peg$currPos,result:s},s)}function peg$parsedecimal_ratio(){var s,e,r,n,o=peg$currPos*17+11,a=peg$resultsCache[o];return a?(peg$currPos=a.nextPos,a.result):(s=peg$currPos,e=peg$parseint(),e!==peg$FAILED?(input.charCodeAt(peg$currPos)===44?(r=peg$c1,peg$currPos++):(r=peg$FAILED,peg$fail(peg$e2)),r!==peg$FAILED?(n=peg$parseint(),n!==peg$FAILED?(peg$savedPos=s,s=peg$f10(e,n)):(peg$currPos=s,s=peg$FAILED)):(peg$currPos=s,s=peg$FAILED)):(peg$currPos=s,s=peg$FAILED),peg$resultsCache[o]={nextPos:peg$currPos,result:s},s)}function peg$parseints(){var s,e,r,n=peg$currPos*17+12,o=peg$resultsCache[n];if(o)return peg$currPos=o.nextPos,o.result;if(s=peg$currPos,e=[],r=peg$parseint(),r===peg$FAILED&&(r=peg$parsesep()),r!==peg$FAILED)for(;r!==peg$FAILED;)e.push(r),r=peg$parseint(),r===peg$FAILED&&(r=peg$parsesep());else e=peg$FAILED;return e!==peg$FAILED&&(peg$savedPos=s,e=peg$f11(e)),s=e,peg$resultsCache[n]={nextPos:peg$currPos,result:s},s}function peg$parsemonzo(){var s,e,r,n,o=peg$currPos*17+13,a=peg$resultsCache[o];return a?(peg$currPos=a.nextPos,a.result):(s=peg$currPos,input.charCodeAt(peg$currPos)===91?(e=peg$c9,peg$currPos++):(e=peg$FAILED,peg$fail(peg$e11)),e!==peg$FAILED?(r=peg$parseints(),r!==peg$FAILED?(input.charCodeAt(peg$currPos)===62?(n=peg$c8,peg$currPos++):(n=peg$FAILED,peg$fail(peg$e10)),n!==peg$FAILED?(peg$savedPos=s,s=peg$f12(r)):(peg$currPos=s,s=peg$FAILED)):(peg$currPos=s,s=peg$FAILED)):(peg$currPos=s,s=peg$FAILED),peg$resultsCache[o]={nextPos:peg$currPos,result:s},s)}function peg$parseoperation(){var s,e,r,n,o,a,l,c=peg$currPos*17+14,h=peg$resultsCache[c];if(h)return peg$currPos=h.nextPos,h.result;if(s=peg$currPos,e=peg$parsevalue(),e===peg$FAILED&&(e=peg$parseratio(),e===peg$FAILED&&(e=peg$parsemonzo(),e===peg$FAILED)))for(e=[],r=peg$parsesep();r!==peg$FAILED;)e.push(r),r=peg$parsesep();if(e!==peg$FAILED){if(r=[],n=peg$currPos,o=peg$parseoperator(),o!==peg$FAILED){if(a=peg$parsevalue(),a===peg$FAILED&&(a=peg$parseratio(),a===peg$FAILED&&(a=peg$parsemonzo(),a===peg$FAILED&&(a=peg$parsesub_operations(),a===peg$FAILED&&(a=peg$parseoperation(),a===peg$FAILED)))))for(a=[],l=peg$parsesep();l!==peg$FAILED;)a.push(l),l=peg$parsesep();a!==peg$FAILED?(o=[o,a],n=o):(peg$currPos=n,n=peg$FAILED)}else peg$currPos=n,n=peg$FAILED;if(n!==peg$FAILED)for(;n!==peg$FAILED;)if(r.push(n),n=peg$currPos,o=peg$parseoperator(),o!==peg$FAILED){if(a=peg$parsevalue(),a===peg$FAILED&&(a=peg$parseratio(),a===peg$FAILED&&(a=peg$parsemonzo(),a===peg$FAILED&&(a=peg$parsesub_operations(),a===peg$FAILED&&(a=peg$parseoperation(),a===peg$FAILED)))))for(a=[],l=peg$parsesep();l!==peg$FAILED;)a.push(l),l=peg$parsesep();a!==peg$FAILED?(o=[o,a],n=o):(peg$currPos=n,n=peg$FAILED)}else peg$currPos=n,n=peg$FAILED;else r=peg$FAILED;r!==peg$FAILED?(peg$savedPos=s,s=peg$f13()):(peg$currPos=s,s=peg$FAILED)}else peg$currPos=s,s=peg$FAILED;return peg$resultsCache[c]={nextPos:peg$currPos,result:s},s}function peg$parseoperator(){var s,e=peg$currPos*17+15,r=peg$resultsCache[e];return r?(peg$currPos=r.nextPos,r.result):(input.charCodeAt(peg$currPos)===43?(s=peg$c10,peg$currPos++):(s=peg$FAILED,peg$fail(peg$e12)),s===peg$FAILED&&(input.charCodeAt(peg$currPos)===45?(s=peg$c4,peg$currPos++):(s=peg$FAILED,peg$fail(peg$e6)),s===peg$FAILED&&(input.charCodeAt(peg$currPos)===42?(s=peg$c11,peg$currPos++):(s=peg$FAILED,peg$fail(peg$e13)),s===peg$FAILED&&(input.charCodeAt(peg$currPos)===37?(s=peg$c12,peg$currPos++):(s=peg$FAILED,peg$fail(peg$e14)),s===peg$FAILED&&(input.charCodeAt(peg$currPos)===38?(s=peg$c13,peg$currPos++):(s=peg$FAILED,peg$fail(peg$e15)),s===peg$FAILED&&(input.charCodeAt(peg$currPos)===124?(s=peg$c14,peg$currPos++):(s=peg$FAILED,peg$fail(peg$e16)),s===peg$FAILED&&(input.substr(peg$currPos,2)===peg$c15?(s=peg$c15,peg$currPos+=2):(s=peg$FAILED,peg$fail(peg$e17)),s===peg$FAILED&&(input.substr(peg$currPos,2)===peg$c16?(s=peg$c16,peg$currPos+=2):(s=peg$FAILED,peg$fail(peg$e18))))))))),peg$resultsCache[e]={nextPos:peg$currPos,result:s},s)}function peg$parsesub_operations(){var s,e,r,n,o=peg$currPos*17+16,a=peg$resultsCache[o];return a?(peg$currPos=a.nextPos,a.result):(s=peg$currPos,input.charCodeAt(peg$currPos)===40?(e=peg$c0,peg$currPos++):(e=peg$FAILED,peg$fail(peg$e1)),e!==peg$FAILED?(r=peg$parseoperation(),r!==peg$FAILED?(input.charCodeAt(peg$currPos)===41?(n=peg$c2,peg$currPos++):(n=peg$FAILED,peg$fail(peg$e3)),n!==peg$FAILED?(e=[e,r,n],s=e):(peg$currPos=s,s=peg$FAILED)):(peg$currPos=s,s=peg$FAILED)):(peg$currPos=s,s=peg$FAILED),peg$resultsCache[o]={nextPos:peg$currPos,result:s},s)}if(peg$result=peg$startRuleFunction(),peg$result!==peg$FAILED&&peg$currPos===input.length)return peg$result;throw peg$result!==peg$FAILED&&peg$currPos{typeof PROCESS.emitWarning=="function"?PROCESS.emitWarning(s,e,r,n):console.error(`[${r}] ${e}: ${s}`)};let AC=globalThis.AbortController,AS=globalThis.AbortSignal;var Sn;if(typeof AC>"u"){AS=class{constructor(){$e(this,"onabort");$e(this,"_onabort",[]);$e(this,"reason");$e(this,"aborted",!1)}addEventListener(n,o){this._onabort.push(o)}},AC=class{constructor(){$e(this,"signal",new AS);e()}abort(n){var o,a;if(!this.signal.aborted){this.signal.reason=n,this.signal.aborted=!0;for(const l of this.signal._onabort)l(n);(a=(o=this.signal).onabort)==null||a.call(o,n)}}};let s=((Sn=PROCESS.env)==null?void 0:Sn.LRU_CACHE_IGNORE_AC_WARNING)!=="1";const e=()=>{s&&(s=!1,emitWarning("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 shouldWarn=s=>!warned.has(s),isPosInt=s=>s&&s===Math.floor(s)&&s>0&&isFinite(s),getUintArray=s=>isPosInt(s)?s<=Math.pow(2,8)?Uint8Array:s<=Math.pow(2,16)?Uint16Array:s<=Math.pow(2,32)?Uint32Array:s<=Number.MAX_SAFE_INTEGER?ZeroArray:null:null;class ZeroArray extends Array{constructor(e){super(e),this.fill(0)}}var Vi;const Ti=class Ti{constructor(e,r){$e(this,"heap");$e(this,"length");if(!B(Ti,Vi))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new r(e),this.length=0}static create(e){const r=getUintArray(e);if(!r)return[];ze(Ti,Vi,!0);const n=new Ti(e,r);return ze(Ti,Vi,!1),n}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}};Vi=new WeakMap,lt(Ti,Vi,!1);let Stack=Ti;var ti,Ut,ii,ri,_i,At,ni,Pt,vt,nt,Zt,zt,Bt,Mt,si,Et,fi,di,oi,ai,xi,Vt,or,Kr,Li,pi,ar,jt,Lr,vn,Qi,Gi,lr,ci,Ii,hi,wi,cr,Jr,Hi,Pr,Wi,Tr,St,Ct,hr,en,Ri,nr;const tn=class tn{constructor(e){lt(this,or);lt(this,Lr);lt(this,ci);lt(this,hi);lt(this,cr);lt(this,Hi);lt(this,Wi);lt(this,St);lt(this,hr);lt(this,Ri);lt(this,ti,void 0);lt(this,Ut,void 0);lt(this,ii,void 0);lt(this,ri,void 0);lt(this,_i,void 0);$e(this,"ttl");$e(this,"ttlResolution");$e(this,"ttlAutopurge");$e(this,"updateAgeOnGet");$e(this,"updateAgeOnHas");$e(this,"allowStale");$e(this,"noDisposeOnSet");$e(this,"noUpdateTTL");$e(this,"maxEntrySize");$e(this,"sizeCalculation");$e(this,"noDeleteOnFetchRejection");$e(this,"noDeleteOnStaleGet");$e(this,"allowStaleOnFetchAbort");$e(this,"allowStaleOnFetchRejection");$e(this,"ignoreFetchAbort");lt(this,At,void 0);lt(this,ni,void 0);lt(this,Pt,void 0);lt(this,vt,void 0);lt(this,nt,void 0);lt(this,Zt,void 0);lt(this,zt,void 0);lt(this,Bt,void 0);lt(this,Mt,void 0);lt(this,si,void 0);lt(this,Et,void 0);lt(this,fi,void 0);lt(this,di,void 0);lt(this,oi,void 0);lt(this,ai,void 0);lt(this,xi,void 0);lt(this,Vt,void 0);lt(this,Li,()=>{});lt(this,pi,()=>{});lt(this,ar,()=>{});lt(this,jt,()=>!1);lt(this,Qi,e=>{});lt(this,Gi,(e,r,n)=>{});lt(this,lr,(e,r,n,o)=>{if(n||o)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});const{max:r=0,ttl:n,ttlResolution:o=1,ttlAutopurge:a,updateAgeOnGet:l,updateAgeOnHas:c,allowStale:h,dispose:f,disposeAfter:d,noDisposeOnSet:g,noUpdateTTL:y,maxSize:I=0,maxEntrySize:P=0,sizeCalculation:N,fetchMethod:Y,noDeleteOnFetchRejection:H,noDeleteOnStaleGet:Se,allowStaleOnFetchRejection:Re,allowStaleOnFetchAbort:oe,ignoreFetchAbort:ke}=e;if(r!==0&&!isPosInt(r))throw new TypeError("max option must be a nonnegative integer");const Te=r?getUintArray(r):Array;if(!Te)throw new Error("invalid max value: "+r);if(ze(this,ti,r),ze(this,Ut,I),this.maxEntrySize=P||B(this,Ut),this.sizeCalculation=N,this.sizeCalculation){if(!B(this,Ut)&&!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(Y!==void 0&&typeof Y!="function")throw new TypeError("fetchMethod must be a function if specified");if(ze(this,_i,Y),ze(this,xi,!!Y),ze(this,Pt,new Map),ze(this,vt,new Array(r).fill(void 0)),ze(this,nt,new Array(r).fill(void 0)),ze(this,Zt,new Te(r)),ze(this,zt,new Te(r)),ze(this,Bt,0),ze(this,Mt,0),ze(this,si,Stack.create(r)),ze(this,At,0),ze(this,ni,0),typeof f=="function"&&ze(this,ii,f),typeof d=="function"?(ze(this,ri,d),ze(this,Et,[])):(ze(this,ri,void 0),ze(this,Et,void 0)),ze(this,ai,!!B(this,ii)),ze(this,Vt,!!B(this,ri)),this.noDisposeOnSet=!!g,this.noUpdateTTL=!!y,this.noDeleteOnFetchRejection=!!H,this.allowStaleOnFetchRejection=!!Re,this.allowStaleOnFetchAbort=!!oe,this.ignoreFetchAbort=!!ke,this.maxEntrySize!==0){if(B(this,Ut)!==0&&!isPosInt(B(this,Ut)))throw new TypeError("maxSize must be a positive integer if specified");if(!isPosInt(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");We(this,Lr,vn).call(this)}if(this.allowStale=!!h,this.noDeleteOnStaleGet=!!Se,this.updateAgeOnGet=!!l,this.updateAgeOnHas=!!c,this.ttlResolution=isPosInt(o)||o===0?o:1,this.ttlAutopurge=!!a,this.ttl=n||0,this.ttl){if(!isPosInt(this.ttl))throw new TypeError("ttl must be a positive integer if specified");We(this,or,Kr).call(this)}if(B(this,ti)===0&&this.ttl===0&&B(this,Ut)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!B(this,ti)&&!B(this,Ut)){const Qe="LRU_CACHE_UNBOUNDED";shouldWarn(Qe)&&(warned.add(Qe),emitWarning("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Qe,tn))}}static unsafeExposeInternals(e){return{starts:B(e,di),ttls:B(e,oi),sizes:B(e,fi),keyMap:B(e,Pt),keyList:B(e,vt),valList:B(e,nt),next:B(e,Zt),prev:B(e,zt),get head(){return B(e,Bt)},get tail(){return B(e,Mt)},free:B(e,si),isBackgroundFetch:r=>{var n;return We(n=e,St,Ct).call(n,r)},backgroundFetch:(r,n,o,a)=>{var l;return We(l=e,Wi,Tr).call(l,r,n,o,a)},moveToTail:r=>{var n;return We(n=e,Ri,nr).call(n,r)},indexes:r=>{var n;return We(n=e,ci,Ii).call(n,r)},rindexes:r=>{var n;return We(n=e,hi,wi).call(n,r)},isStale:r=>{var n;return B(n=e,jt).call(n,r)}}}get max(){return B(this,ti)}get maxSize(){return B(this,Ut)}get calculatedSize(){return B(this,ni)}get size(){return B(this,At)}get fetchMethod(){return B(this,_i)}get dispose(){return B(this,ii)}get disposeAfter(){return B(this,ri)}getRemainingTTL(e){return B(this,Pt).has(e)?1/0:0}*entries(){for(const e of We(this,ci,Ii).call(this))B(this,nt)[e]!==void 0&&B(this,vt)[e]!==void 0&&!We(this,St,Ct).call(this,B(this,nt)[e])&&(yield[B(this,vt)[e],B(this,nt)[e]])}*rentries(){for(const e of We(this,hi,wi).call(this))B(this,nt)[e]!==void 0&&B(this,vt)[e]!==void 0&&!We(this,St,Ct).call(this,B(this,nt)[e])&&(yield[B(this,vt)[e],B(this,nt)[e]])}*keys(){for(const e of We(this,ci,Ii).call(this)){const r=B(this,vt)[e];r!==void 0&&!We(this,St,Ct).call(this,B(this,nt)[e])&&(yield r)}}*rkeys(){for(const e of We(this,hi,wi).call(this)){const r=B(this,vt)[e];r!==void 0&&!We(this,St,Ct).call(this,B(this,nt)[e])&&(yield r)}}*values(){for(const e of We(this,ci,Ii).call(this))B(this,nt)[e]!==void 0&&!We(this,St,Ct).call(this,B(this,nt)[e])&&(yield B(this,nt)[e])}*rvalues(){for(const e of We(this,hi,wi).call(this))B(this,nt)[e]!==void 0&&!We(this,St,Ct).call(this,B(this,nt)[e])&&(yield B(this,nt)[e])}[Symbol.iterator](){return this.entries()}find(e,r={}){for(const n of We(this,ci,Ii).call(this)){const o=B(this,nt)[n],a=We(this,St,Ct).call(this,o)?o.__staleWhileFetching:o;if(a!==void 0&&e(a,B(this,vt)[n],this))return this.get(B(this,vt)[n],r)}}forEach(e,r=this){for(const n of We(this,ci,Ii).call(this)){const o=B(this,nt)[n],a=We(this,St,Ct).call(this,o)?o.__staleWhileFetching:o;a!==void 0&&e.call(r,a,B(this,vt)[n],this)}}rforEach(e,r=this){for(const n of We(this,hi,wi).call(this)){const o=B(this,nt)[n],a=We(this,St,Ct).call(this,o)?o.__staleWhileFetching:o;a!==void 0&&e.call(r,a,B(this,vt)[n],this)}}purgeStale(){let e=!1;for(const r of We(this,hi,wi).call(this,{allowStale:!0}))B(this,jt).call(this,r)&&(this.delete(B(this,vt)[r]),e=!0);return e}dump(){const e=[];for(const r of We(this,ci,Ii).call(this,{allowStale:!0})){const n=B(this,vt)[r],o=B(this,nt)[r],a=We(this,St,Ct).call(this,o)?o.__staleWhileFetching:o;if(a===void 0||n===void 0)continue;const l={value:a};if(B(this,oi)&&B(this,di)){l.ttl=B(this,oi)[r];const c=perf.now()-B(this,di)[r];l.start=Math.floor(Date.now()-c)}B(this,fi)&&(l.size=B(this,fi)[r]),e.unshift([n,l])}return e}load(e){this.clear();for(const[r,n]of e){if(n.start){const o=Date.now()-n.start;n.start=perf.now()-o}this.set(r,n.value,n)}}set(e,r,n={}){var y,I,P,N,Y;if(r===void 0)return this.delete(e),this;const{ttl:o=this.ttl,start:a,noDisposeOnSet:l=this.noDisposeOnSet,sizeCalculation:c=this.sizeCalculation,status:h}=n;let{noUpdateTTL:f=this.noUpdateTTL}=n;const d=B(this,lr).call(this,e,r,n.size||0,c);if(this.maxEntrySize&&d>this.maxEntrySize)return h&&(h.set="miss",h.maxEntrySizeExceeded=!0),this.delete(e),this;let g=B(this,At)===0?void 0:B(this,Pt).get(e);if(g===void 0)g=B(this,At)===0?B(this,Mt):B(this,si).length!==0?B(this,si).pop():B(this,At)===B(this,ti)?We(this,Hi,Pr).call(this,!1):B(this,At),B(this,vt)[g]=e,B(this,nt)[g]=r,B(this,Pt).set(e,g),B(this,Zt)[B(this,Mt)]=g,B(this,zt)[g]=B(this,Mt),ze(this,Mt,g),Ar(this,At)._++,B(this,Gi).call(this,g,d,h),h&&(h.set="add"),f=!1;else{We(this,Ri,nr).call(this,g);const H=B(this,nt)[g];if(r!==H){if(B(this,xi)&&We(this,St,Ct).call(this,H)){H.__abortController.abort(new Error("replaced"));const{__staleWhileFetching:Se}=H;Se!==void 0&&!l&&(B(this,ai)&&((y=B(this,ii))==null||y.call(this,Se,e,"set")),B(this,Vt)&&((I=B(this,Et))==null||I.push([Se,e,"set"])))}else l||(B(this,ai)&&((P=B(this,ii))==null||P.call(this,H,e,"set")),B(this,Vt)&&((N=B(this,Et))==null||N.push([H,e,"set"])));if(B(this,Qi).call(this,g),B(this,Gi).call(this,g,d,h),B(this,nt)[g]=r,h){h.set="replace";const Se=H&&We(this,St,Ct).call(this,H)?H.__staleWhileFetching:H;Se!==void 0&&(h.oldValue=Se)}}else h&&(h.set="update")}if(o!==0&&!B(this,oi)&&We(this,or,Kr).call(this),B(this,oi)&&(f||B(this,ar).call(this,g,o,a),h&&B(this,pi).call(this,h,g)),!l&&B(this,Vt)&&B(this,Et)){const H=B(this,Et);let Se;for(;Se=H==null?void 0:H.shift();)(Y=B(this,ri))==null||Y.call(this,...Se)}return this}pop(){var e;try{for(;B(this,At);){const r=B(this,nt)[B(this,Bt)];if(We(this,Hi,Pr).call(this,!0),We(this,St,Ct).call(this,r)){if(r.__staleWhileFetching)return r.__staleWhileFetching}else if(r!==void 0)return r}}finally{if(B(this,Vt)&&B(this,Et)){const r=B(this,Et);let n;for(;n=r==null?void 0:r.shift();)(e=B(this,ri))==null||e.call(this,...n)}}}has(e,r={}){const{updateAgeOnHas:n=this.updateAgeOnHas,status:o}=r,a=B(this,Pt).get(e);if(a!==void 0){const l=B(this,nt)[a];if(We(this,St,Ct).call(this,l)&&l.__staleWhileFetching===void 0)return!1;if(B(this,jt).call(this,a))o&&(o.has="stale",B(this,pi).call(this,o,a));else return n&&B(this,Li).call(this,a),o&&(o.has="hit",B(this,pi).call(this,o,a)),!0}else o&&(o.has="miss");return!1}peek(e,r={}){const{allowStale:n=this.allowStale}=r,o=B(this,Pt).get(e);if(o!==void 0&&(n||!B(this,jt).call(this,o))){const a=B(this,nt)[o];return We(this,St,Ct).call(this,a)?a.__staleWhileFetching:a}}async fetch(e,r={}){const{allowStale:n=this.allowStale,updateAgeOnGet:o=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,ttl:l=this.ttl,noDisposeOnSet:c=this.noDisposeOnSet,size:h=0,sizeCalculation:f=this.sizeCalculation,noUpdateTTL:d=this.noUpdateTTL,noDeleteOnFetchRejection:g=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:y=this.allowStaleOnFetchRejection,ignoreFetchAbort:I=this.ignoreFetchAbort,allowStaleOnFetchAbort:P=this.allowStaleOnFetchAbort,context:N,forceRefresh:Y=!1,status:H,signal:Se}=r;if(!B(this,xi))return H&&(H.fetch="get"),this.get(e,{allowStale:n,updateAgeOnGet:o,noDeleteOnStaleGet:a,status:H});const Re={allowStale:n,updateAgeOnGet:o,noDeleteOnStaleGet:a,ttl:l,noDisposeOnSet:c,size:h,sizeCalculation:f,noUpdateTTL:d,noDeleteOnFetchRejection:g,allowStaleOnFetchRejection:y,allowStaleOnFetchAbort:P,ignoreFetchAbort:I,status:H,signal:Se};let oe=B(this,Pt).get(e);if(oe===void 0){H&&(H.fetch="miss");const ke=We(this,Wi,Tr).call(this,e,oe,Re,N);return ke.__returned=ke}else{const ke=B(this,nt)[oe];if(We(this,St,Ct).call(this,ke)){const De=n&&ke.__staleWhileFetching!==void 0;return H&&(H.fetch="inflight",De&&(H.returnedStale=!0)),De?ke.__staleWhileFetching:ke.__returned=ke}const Te=B(this,jt).call(this,oe);if(!Y&&!Te)return H&&(H.fetch="hit"),We(this,Ri,nr).call(this,oe),o&&B(this,Li).call(this,oe),H&&B(this,pi).call(this,H,oe),ke;const Qe=We(this,Wi,Tr).call(this,e,oe,Re,N),Ze=Qe.__staleWhileFetching!==void 0&&n;return H&&(H.fetch=Te?"stale":"refresh",Ze&&Te&&(H.returnedStale=!0)),Ze?Qe.__staleWhileFetching:Qe.__returned=Qe}}get(e,r={}){const{allowStale:n=this.allowStale,updateAgeOnGet:o=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,status:l}=r,c=B(this,Pt).get(e);if(c!==void 0){const h=B(this,nt)[c],f=We(this,St,Ct).call(this,h);return l&&B(this,pi).call(this,l,c),B(this,jt).call(this,c)?(l&&(l.get="stale"),f?(l&&n&&h.__staleWhileFetching!==void 0&&(l.returnedStale=!0),n?h.__staleWhileFetching:void 0):(a||this.delete(e),l&&n&&(l.returnedStale=!0),n?h:void 0)):(l&&(l.get="hit"),f?h.__staleWhileFetching:(We(this,Ri,nr).call(this,c),o&&B(this,Li).call(this,c),h))}else l&&(l.get="miss")}delete(e){var n,o,a,l;let r=!1;if(B(this,At)!==0){const c=B(this,Pt).get(e);if(c!==void 0)if(r=!0,B(this,At)===1)this.clear();else{B(this,Qi).call(this,c);const h=B(this,nt)[c];We(this,St,Ct).call(this,h)?h.__abortController.abort(new Error("deleted")):(B(this,ai)||B(this,Vt))&&(B(this,ai)&&((n=B(this,ii))==null||n.call(this,h,e,"delete")),B(this,Vt)&&((o=B(this,Et))==null||o.push([h,e,"delete"]))),B(this,Pt).delete(e),B(this,vt)[c]=void 0,B(this,nt)[c]=void 0,c===B(this,Mt)?ze(this,Mt,B(this,zt)[c]):c===B(this,Bt)?ze(this,Bt,B(this,Zt)[c]):(B(this,Zt)[B(this,zt)[c]]=B(this,Zt)[c],B(this,zt)[B(this,Zt)[c]]=B(this,zt)[c]),Ar(this,At)._--,B(this,si).push(c)}}if(B(this,Vt)&&((a=B(this,Et))!=null&&a.length)){const c=B(this,Et);let h;for(;h=c==null?void 0:c.shift();)(l=B(this,ri))==null||l.call(this,...h)}return r}clear(){var e,r,n;for(const o of We(this,hi,wi).call(this,{allowStale:!0})){const a=B(this,nt)[o];if(We(this,St,Ct).call(this,a))a.__abortController.abort(new Error("deleted"));else{const l=B(this,vt)[o];B(this,ai)&&((e=B(this,ii))==null||e.call(this,a,l,"delete")),B(this,Vt)&&((r=B(this,Et))==null||r.push([a,l,"delete"]))}}if(B(this,Pt).clear(),B(this,nt).fill(void 0),B(this,vt).fill(void 0),B(this,oi)&&B(this,di)&&(B(this,oi).fill(0),B(this,di).fill(0)),B(this,fi)&&B(this,fi).fill(0),ze(this,Bt,0),ze(this,Mt,0),B(this,si).length=0,ze(this,ni,0),ze(this,At,0),B(this,Vt)&&B(this,Et)){const o=B(this,Et);let a;for(;a=o==null?void 0:o.shift();)(n=B(this,ri))==null||n.call(this,...a)}}};ti=new WeakMap,Ut=new WeakMap,ii=new WeakMap,ri=new WeakMap,_i=new WeakMap,At=new WeakMap,ni=new WeakMap,Pt=new WeakMap,vt=new WeakMap,nt=new WeakMap,Zt=new WeakMap,zt=new WeakMap,Bt=new WeakMap,Mt=new WeakMap,si=new WeakMap,Et=new WeakMap,fi=new WeakMap,di=new WeakMap,oi=new WeakMap,ai=new WeakMap,xi=new WeakMap,Vt=new WeakMap,or=new WeakSet,Kr=function(){const e=new ZeroArray(B(this,ti)),r=new ZeroArray(B(this,ti));ze(this,oi,e),ze(this,di,r),ze(this,ar,(a,l,c=perf.now())=>{if(r[a]=l!==0?c:0,e[a]=l,l!==0&&this.ttlAutopurge){const h=setTimeout(()=>{B(this,jt).call(this,a)&&this.delete(B(this,vt)[a])},l+1);h.unref&&h.unref()}}),ze(this,Li,a=>{r[a]=e[a]!==0?perf.now():0}),ze(this,pi,(a,l)=>{if(e[l]){const c=e[l],h=r[l];a.ttl=c,a.start=h,a.now=n||o();const f=a.now-h;a.remainingTTL=c-f}});let n=0;const o=()=>{const a=perf.now();if(this.ttlResolution>0){n=a;const l=setTimeout(()=>n=0,this.ttlResolution);l.unref&&l.unref()}return a};this.getRemainingTTL=a=>{const l=B(this,Pt).get(a);if(l===void 0)return 0;const c=e[l],h=r[l];if(c===0||h===0)return 1/0;const f=(n||o())-h;return c-f},ze(this,jt,a=>e[a]!==0&&r[a]!==0&&(n||o())-r[a]>e[a])},Li=new WeakMap,pi=new WeakMap,ar=new WeakMap,jt=new WeakMap,Lr=new WeakSet,vn=function(){const e=new ZeroArray(B(this,ti));ze(this,ni,0),ze(this,fi,e),ze(this,Qi,r=>{ze(this,ni,B(this,ni)-e[r]),e[r]=0}),ze(this,lr,(r,n,o,a)=>{if(We(this,St,Ct).call(this,n))return 0;if(!isPosInt(o))if(a){if(typeof a!="function")throw new TypeError("sizeCalculation must be a function");if(o=a(n,r),!isPosInt(o))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 o}),ze(this,Gi,(r,n,o)=>{if(e[r]=n,B(this,Ut)){const a=B(this,Ut)-e[r];for(;B(this,ni)>a;)We(this,Hi,Pr).call(this,!0)}ze(this,ni,B(this,ni)+e[r]),o&&(o.entrySize=n,o.totalCalculatedSize=B(this,ni))})},Qi=new WeakMap,Gi=new WeakMap,lr=new WeakMap,ci=new WeakSet,Ii=function*({allowStale:e=this.allowStale}={}){if(B(this,At))for(let r=B(this,Mt);!(!We(this,cr,Jr).call(this,r)||((e||!B(this,jt).call(this,r))&&(yield r),r===B(this,Bt)));)r=B(this,zt)[r]},hi=new WeakSet,wi=function*({allowStale:e=this.allowStale}={}){if(B(this,At))for(let r=B(this,Bt);!(!We(this,cr,Jr).call(this,r)||((e||!B(this,jt).call(this,r))&&(yield r),r===B(this,Mt)));)r=B(this,Zt)[r]},cr=new WeakSet,Jr=function(e){return e!==void 0&&B(this,Pt).get(B(this,vt)[e])===e},Hi=new WeakSet,Pr=function(e){var a,l;const r=B(this,Bt),n=B(this,vt)[r],o=B(this,nt)[r];return B(this,xi)&&We(this,St,Ct).call(this,o)?o.__abortController.abort(new Error("evicted")):(B(this,ai)||B(this,Vt))&&(B(this,ai)&&((a=B(this,ii))==null||a.call(this,o,n,"evict")),B(this,Vt)&&((l=B(this,Et))==null||l.push([o,n,"evict"]))),B(this,Qi).call(this,r),e&&(B(this,vt)[r]=void 0,B(this,nt)[r]=void 0,B(this,si).push(r)),B(this,At)===1?(ze(this,Bt,ze(this,Mt,0)),B(this,si).length=0):ze(this,Bt,B(this,Zt)[r]),B(this,Pt).delete(n),Ar(this,At)._--,r},Wi=new WeakSet,Tr=function(e,r,n,o){const a=r===void 0?void 0:B(this,nt)[r];if(We(this,St,Ct).call(this,a))return a;const l=new AC,{signal:c}=n;c==null||c.addEventListener("abort",()=>l.abort(c.reason),{signal:l.signal});const h={signal:l.signal,options:n,context:o},f=(N,Y=!1)=>{const{aborted:H}=l.signal,Se=n.ignoreFetchAbort&&N!==void 0;if(n.status&&(H&&!Y?(n.status.fetchAborted=!0,n.status.fetchError=l.signal.reason,Se&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),H&&!Se&&!Y)return g(l.signal.reason);const Re=I;return B(this,nt)[r]===I&&(N===void 0?Re.__staleWhileFetching?B(this,nt)[r]=Re.__staleWhileFetching:this.delete(e):(n.status&&(n.status.fetchUpdated=!0),this.set(e,N,h.options))),N},d=N=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=N),g(N)),g=N=>{const{aborted:Y}=l.signal,H=Y&&n.allowStaleOnFetchAbort,Se=H||n.allowStaleOnFetchRejection,Re=Se||n.noDeleteOnFetchRejection,oe=I;if(B(this,nt)[r]===I&&(!Re||oe.__staleWhileFetching===void 0?this.delete(e):H||(B(this,nt)[r]=oe.__staleWhileFetching)),Se)return n.status&&oe.__staleWhileFetching!==void 0&&(n.status.returnedStale=!0),oe.__staleWhileFetching;if(oe.__returned===oe)throw N},y=(N,Y)=>{var Se;const H=(Se=B(this,_i))==null?void 0:Se.call(this,e,a,h);H&&H instanceof Promise&&H.then(Re=>N(Re===void 0?void 0:Re),Y),l.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(N(void 0),n.allowStaleOnFetchAbort&&(N=Re=>f(Re,!0)))})};n.status&&(n.status.fetchDispatched=!0);const I=new Promise(y).then(f,d),P=Object.assign(I,{__abortController:l,__staleWhileFetching:a,__returned:void 0});return r===void 0?(this.set(e,P,{...h.options,status:void 0}),r=B(this,Pt).get(e)):B(this,nt)[r]=P,P},St=new WeakSet,Ct=function(e){if(!B(this,xi))return!1;const r=e;return!!r&&r instanceof Promise&&r.hasOwnProperty("__staleWhileFetching")&&r.__abortController instanceof AC},hr=new WeakSet,en=function(e,r){B(this,zt)[r]=e,B(this,Zt)[e]=r},Ri=new WeakSet,nr=function(e){e!==B(this,Mt)&&(e===B(this,Bt)?ze(this,Bt,B(this,Zt)[e]):We(this,hr,en).call(this,B(this,zt)[e],B(this,Zt)[e]),We(this,hr,en).call(this,B(this,Mt),e),ze(this,Mt,e))};let LRUCache=tn;const zcache=new LRUCache({max:1e3,ttl:1e3*60*5});class Ziffers{constructor(e,r={}){$e(this,"values");$e(this,"evaluated");$e(this,"options");$e(this,"index");$e(this,"redo");this.index=0,r={...DEFAULT_OPTIONS,...r},r.scale&&(typeof r.scale=="string"&&(isScale(r.scale)?(r.scaleName=r.scale,r.scale=getScale(r.scale)):r.scale=parse(r.scale)),r.parsedScale=r.scale,delete r.scale),r.redo!==void 0?this.redo=r.redo:this.redo=1,this.options={nodeOptions:r};try{this.values=parse$1(e,this.options),this.evaluated=this.evaluate()}catch(n){console.log(n),this.values=[],this.evaluated=[]}}update(){this.evaluated=this.evaluate()}pitches(){return this.evaluated.map(e=>e.collect("pitch"))}notes(){return this.evaluated.map(e=>e.collect("note"))}freqs(){return this.evaluated.map(e=>e.collect("freq"))}durations(){return this.evaluated.map(e=>e.collect("duration"))}next(){const e=this.evaluated[this.index%this.evaluated.length];return this.index++,this.redo>0&&this.index>=this.evaluated.length*this.redo&&(this.index=0,this.update()),e}evaluate(){return this.values.map(e=>e.evaluate()).flat(1/0).filter(e=>e!==void 0)}}const generateCacheKey=(...s)=>s.map(e=>JSON.stringify(e)).join(","),cachedCall=(s,e)=>{const r=generateCacheKey(s,e);if(zcache.has(r))return zcache.get(r);{const n=new Ziffers(s,e);return zcache.set(r,n),n}},next=(s,e={})=>cachedCall(s,e).next();let listenerQueue=[],atom=(s,e)=>{let r,n=[],o={lc:0,l:e||0,value:s,set(a){o.value=a,o.notify()},get(){return o.lc||o.listen(()=>{})(),o.value},notify(a){r=n;let l=!listenerQueue.length;for(let c=0;c{n===r&&(n=n.slice());let c=n.indexOf(a);~c&&(n.splice(c,2),o.lc--,o.lc||o.off())}},subscribe(a,l){let c=o.listen(a,l);return a(o.value),c},off(){}};return o},map=(s={})=>{let e=atom(s);return e.setKey=function(r,n){typeof n>"u"?r in e.value&&(e.value={...e.value},delete e.value[r],e.notify(r)):e.value[r]!==n&&(e.value={...e.value,[r]:n},e.notify(r))},e};if(typeof DelayNode<"u"){class s extends DelayNode{constructor(r,n,o,a){super(r),n=Math.abs(n),this.delayTime.value=o;const l=r.createGain();l.gain.value=Math.min(Math.abs(a),.995),this.feedback=l.gain;const c=r.createGain();return c.gain.value=n,this.delayGain=c,this.connect(l),this.connect(c),l.connect(this),this.connect=h=>c.connect(h),this}start(r){this.delayGain.gain.setValueAtTime(this.delayGain.gain.value,r+this.delayTime.value)}}AudioContext.prototype.createFeedbackDelay=function(e,r,n){return new s(this,e,r,n)}}typeof AudioContext<"u"&&(AudioContext.prototype.impulseResponse=function(s,e=1){const r=this.sampleRate*s,n=this.createBuffer(e,r,this.sampleRate),o=n.getChannelData(0);for(let a=0;a(e.buffer=this.impulseResponse(r),e.duration=s,e),e.setDuration(s),e});var q={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 s extends GainNode{constructor(r,n){if(super(r),!q[n])throw new Error("vowel: unknown vowel "+n);const{gains:o,qs:a,freqs:l}=q[n],c=r.createGain();for(let h=0;h<5;h++){const f=r.createGain();f.gain.value=o[h];const d=r.createBiquadFilter();d.type="bandpass",d.Q.value=a[h],d.frequency.value=l[h],this.connect(d),d.connect(f),f.connect(c)}return c.gain.value=8,this.connect=h=>c.connect(h),this}}AudioContext.prototype.createVowelFilter=function(e){return new s(this,e)}}const ce=s=>{var o;if(typeof s!="string")return[];const[e,r="",n]=((o=s.match(/^([a-gA-G])([#bsf]*)([0-9]*)$/))==null?void 0:o.slice(1))||[];return e?[e,r,n?Number(n):void 0]:[]},re={c:0,d:2,e:4,f:5,g:7,a:9,b:11},ie={"#":1,b:-1,s:1,f:-1},L=(s,e=3)=>{const[r,n,o=e]=ce(s);if(!r)throw new Error('not a note: "'+s+'"');const a=re[r.toLowerCase()],l=(n==null?void 0:n.split("").reduce((c,h)=>c+ie[h],0))||0;return(Number(o)+1)*12+a+l},se=s=>Math.pow(2,(s-69)/12)*440,ae=(s,e,r)=>Math.min(Math.max(s,e),r),ge=s=>12*Math.log(s/440)/Math.LN2+69,de=(s,e)=>{if(typeof s!="object")throw new Error("valueToMidi: expected object value");let{freq:r,note:n}=s;if(typeof r=="number")return ge(r);if(typeof n=="string")return L(n);if(typeof n=="number")return n;if(!e)throw new Error("valueToMidi: expected freq or note to be set");return e},ue="data:application/javascript;base64,Ly8gTElDRU5TRSBHTlUgR2VuZXJhbCBQdWJsaWMgTGljZW5zZSB2My4wIHNlZSBodHRwczovL2dpdGh1Yi5jb20vZGt0cjAvV2ViRGlydC9ibG9iL21haW4vTElDRU5TRQovLyBhbGwgdGhlIGNyZWRpdCBnb2VzIHRvIGRrdHIwJ3Mgd2ViZGlydDogaHR0cHM6Ly9naXRodWIuY29tL2RrdHIwL1dlYkRpcnQvYmxvYi81Y2UzZDY5ODM2MmM1NGQ2ZTFiNjhhY2M0N2ViMjk1NWFjNjJjNzkzL2Rpc3QvQXVkaW9Xb3JrbGV0cy5qcwovLyA8MwoKY2xhc3MgQ29hcnNlUHJvY2Vzc29yIGV4dGVuZHMgQXVkaW9Xb3JrbGV0UHJvY2Vzc29yIHsKICBzdGF0aWMgZ2V0IHBhcmFtZXRlckRlc2NyaXB0b3JzKCkgewogICAgcmV0dXJuIFt7IG5hbWU6ICdjb2Fyc2UnLCBkZWZhdWx0VmFsdWU6IDEgfV07CiAgfQoKICBjb25zdHJ1Y3RvcigpIHsKICAgIHN1cGVyKCk7CiAgICB0aGlzLm5vdFN0YXJ0ZWQgPSB0cnVlOwogIH0KCiAgcHJvY2VzcyhpbnB1dHMsIG91dHB1dHMsIHBhcmFtZXRlcnMpIHsKICAgIGNvbnN0IGlucHV0ID0gaW5wdXRzWzBdOwogICAgY29uc3Qgb3V0cHV0ID0gb3V0cHV0c1swXTsKICAgIGNvbnN0IGNvYXJzZSA9IHBhcmFtZXRlcnMuY29hcnNlOwogICAgY29uc3QgYmxvY2tTaXplID0gMTI4OwogICAgY29uc3QgaGFzSW5wdXQgPSAhKGlucHV0WzBdID09PSB1bmRlZmluZWQpOwogICAgaWYgKGhhc0lucHV0KSB7CiAgICAgIHRoaXMubm90U3RhcnRlZCA9IGZhbHNlOwogICAgICBvdXRwdXRbMF1bMF0gPSBpbnB1dFswXVswXTsKICAgICAgZm9yIChsZXQgbiA9IDE7IG4gPCBibG9ja1NpemU7IG4rKykgewogICAgICAgIGZvciAobGV0IG8gPSAwOyBvIDwgb3V0cHV0Lmxlbmd0aDsgbysrKSB7CiAgICAgICAgICBvdXRwdXRbb11bbl0gPSBuICUgY29hcnNlID09IDAgPyBpbnB1dFswXVtuXSA6IG91dHB1dFtvXVtuIC0gMV07CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICByZXR1cm4gdGhpcy5ub3RTdGFydGVkIHx8IGhhc0lucHV0OwogIH0KfQoKcmVnaXN0ZXJQcm9jZXNzb3IoJ2NvYXJzZS1wcm9jZXNzb3InLCBDb2Fyc2VQcm9jZXNzb3IpOwoKY2xhc3MgQ3J1c2hQcm9jZXNzb3IgZXh0ZW5kcyBBdWRpb1dvcmtsZXRQcm9jZXNzb3IgewogIHN0YXRpYyBnZXQgcGFyYW1ldGVyRGVzY3JpcHRvcnMoKSB7CiAgICByZXR1cm4gW3sgbmFtZTogJ2NydXNoJywgZGVmYXVsdFZhbHVlOiAwIH1dOwogIH0KCiAgY29uc3RydWN0b3IoKSB7CiAgICBzdXBlcigpOwogICAgdGhpcy5ub3RTdGFydGVkID0gdHJ1ZTsKICB9CgogIHByb2Nlc3MoaW5wdXRzLCBvdXRwdXRzLCBwYXJhbWV0ZXJzKSB7CiAgICBjb25zdCBpbnB1dCA9IGlucHV0c1swXTsKICAgIGNvbnN0IG91dHB1dCA9IG91dHB1dHNbMF07CiAgICBjb25zdCBjcnVzaCA9IHBhcmFtZXRlcnMuY3J1c2g7CiAgICBjb25zdCBibG9ja1NpemUgPSAxMjg7CiAgICBjb25zdCBoYXNJbnB1dCA9ICEoaW5wdXRbMF0gPT09IHVuZGVmaW5lZCk7CiAgICBpZiAoaGFzSW5wdXQpIHsKICAgICAgdGhpcy5ub3RTdGFydGVkID0gZmFsc2U7CiAgICAgIGlmIChjcnVzaC5sZW5ndGggPT09IDEpIHsKICAgICAgICBjb25zdCB4ID0gTWF0aC5wb3coMiwgY3J1c2hbMF0gLSAxKTsKICAgICAgICBmb3IgKGxldCBuID0gMDsgbiA8IGJsb2NrU2l6ZTsgbisrKSB7CiAgICAgICAgICBjb25zdCB2YWx1ZSA9IE1hdGgucm91bmQoaW5wdXRbMF1bbl0gKiB4KSAvIHg7CiAgICAgICAgICBmb3IgKGxldCBvID0gMDsgbyA8IG91dHB1dC5sZW5ndGg7IG8rKykgewogICAgICAgICAgICBvdXRwdXRbb11bbl0gPSB2YWx1ZTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgZm9yIChsZXQgbiA9IDA7IG4gPCBibG9ja1NpemU7IG4rKykgewogICAgICAgICAgbGV0IHggPSBNYXRoLnBvdygyLCBjcnVzaFtuXSAtIDEpOwogICAgICAgICAgY29uc3QgdmFsdWUgPSBNYXRoLnJvdW5kKGlucHV0WzBdW25dICogeCkgLyB4OwogICAgICAgICAgZm9yIChsZXQgbyA9IDA7IG8gPCBvdXRwdXQubGVuZ3RoOyBvKyspIHsKICAgICAgICAgICAgb3V0cHV0W29dW25dID0gdmFsdWU7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICByZXR1cm4gdGhpcy5ub3RTdGFydGVkIHx8IGhhc0lucHV0OwogIH0KfQpyZWdpc3RlclByb2Nlc3NvcignY3J1c2gtcHJvY2Vzc29yJywgQ3J1c2hQcm9jZXNzb3IpOwoKY2xhc3MgU2hhcGVQcm9jZXNzb3IgZXh0ZW5kcyBBdWRpb1dvcmtsZXRQcm9jZXNzb3IgewogIHN0YXRpYyBnZXQgcGFyYW1ldGVyRGVzY3JpcHRvcnMoKSB7CiAgICByZXR1cm4gW3sgbmFtZTogJ3NoYXBlJywgZGVmYXVsdFZhbHVlOiAwIH1dOwogIH0KCiAgY29uc3RydWN0b3IoKSB7CiAgICBzdXBlcigpOwogICAgdGhpcy5ub3RTdGFydGVkID0gdHJ1ZTsKICB9CgogIHByb2Nlc3MoaW5wdXRzLCBvdXRwdXRzLCBwYXJhbWV0ZXJzKSB7CiAgICBjb25zdCBpbnB1dCA9IGlucHV0c1swXTsKICAgIGNvbnN0IG91dHB1dCA9IG91dHB1dHNbMF07CiAgICBjb25zdCBzaGFwZTAgPSBwYXJhbWV0ZXJzLnNoYXBlWzBdOwogICAgY29uc3Qgc2hhcGUxID0gc2hhcGUwIDwgMSA/IHNoYXBlMCA6IDEuMCAtIDRlLTEwOwogICAgY29uc3Qgc2hhcGUgPSAoMi4wICogc2hhcGUxKSAvICgxLjAgLSBzaGFwZTEpOwogICAgY29uc3QgYmxvY2tTaXplID0gMTI4OwogICAgY29uc3QgaGFzSW5wdXQgPSAhKGlucHV0WzBdID09PSB1bmRlZmluZWQpOwogICAgaWYgKGhhc0lucHV0KSB7CiAgICAgIHRoaXMubm90U3RhcnRlZCA9IGZhbHNlOwogICAgICBmb3IgKGxldCBuID0gMDsgbiA8IGJsb2NrU2l6ZTsgbisrKSB7CiAgICAgICAgY29uc3QgdmFsdWUgPSAoKDEgKyBzaGFwZSkgKiBpbnB1dFswXVtuXSkgLyAoMSArIHNoYXBlICogTWF0aC5hYnMoaW5wdXRbMF1bbl0pKTsKICAgICAgICBmb3IgKGxldCBvID0gMDsgbyA8IG91dHB1dC5sZW5ndGg7IG8rKykgewogICAgICAgICAgb3V0cHV0W29dW25dID0gdmFsdWU7CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICByZXR1cm4gdGhpcy5ub3RTdGFydGVkIHx8IGhhc0lucHV0OwogIH0KfQoKcmVnaXN0ZXJQcm9jZXNzb3IoJ3NoYXBlLXByb2Nlc3NvcicsIFNoYXBlUHJvY2Vzc29yKTsK";function k(s){const e=C().createGain();return e.gain.value=s,e}const Ie=({s,freq:e,t:r})=>{const n=C().createOscillator();return n.type=s||"triangle",n.frequency.value=Number(e),n.start(r),{node:n,stop:o=>n.stop(o)}},ee=(s,e,r,n,o,a)=>{const l=C().createGain();return l.gain.setValueAtTime(0,a),l.gain.linearRampToValueAtTime(o,a+s),l.gain.linearRampToValueAtTime(r*o,a+s+e),{node:l,stop:c=>{l.gain.setValueAtTime(r*o,c),l.gain.linearRampToValueAtTime(0,c+n)}}},Q=(s,e,r)=>{const n=C().createBiquadFilter();return n.type=s,n.frequency.value=e,n.Q.value=r,n},E=map();function te(s,e,r={}){E.setKey(s,{onTrigger:e,data:r})}function U(s){return E.get()[s]}let J;const C=()=>(J||(J=new AudioContext),J);let W;const j=()=>{const s=C();return W||(W=s.createGain(),W.connect(s.destination)),W};let D;function le(){return D||(D=C().audioWorklet.addModule(ue),D)}function x(s,e,r){const n=new AudioWorkletNode(s,e);return Object.entries(r).forEach(([o,a])=>{n.parameters.get(o).value=a}),n}async function Ce(s={}){const{disableWorklets:e=!1}=s;typeof window<"u"&&(await C().resume(),e?console.log("disableWorklets: AudioWorklet effects coarse, crush and shape are skipped!"):await le().catch(r=>{console.warn("could not load AudioWorklet effects coarse, crush and shape",r)}))}async function ve(s){return new Promise(e=>{document.addEventListener("click",async function r(){await Ce(s),e(),document.removeEventListener("click",r)})})}let G={};function fe(s,e,r,n){var o;if(r=ae(r,0,.98),!G[s]){const a=C().createFeedbackDelay(1,e,r);(o=a.start)==null||o.call(a,n),a.connect(j()),G[s]=a}return G[s].delayTime.value!==e&&G[s].delayTime.setValueAtTime(e,n),G[s].feedback.value!==r&&G[s].feedback.setValueAtTime(r,n),G[s]}let w={};function Ae(s,e=2){if(!w[s]){const r=C().createReverb(e);r.connect(j()),w[s]=r}return w[s].duration!==e&&(w[s]=w[s].setDuration(e),w[s].duration=e),w[s]}function _(s,e,r){const n=k(r);return s.connect(n),n.connect(e),n}const he=async(s,e,r)=>{const n=C();if(typeof s!="object")throw new Error(`expected hap.value to be an object, but got "${s}". Hint: append .note() or .s() to the end`,"error");let o=n.currentTime+e,{s:a="triangle",bank:l,source:c,gain:h=.8,cutoff:f,resonance:d=1,hcutoff:g,hresonance:y=1,bandf:I,bandq:P=1,coarse:N,crush:Y,shape:H,pan:Se,vowel:Re,delay:oe=0,delayfeedback:ke=.5,delaytime:Te=.25,orbit:Qe=1,room:Ve,size:Ze=2,velocity:De=1}=s;h*=De;let je=[];const at=()=>{je.forEach(ut=>ut==null?void 0:ut.disconnect())};l&&a&&(a=`${l}_${a}`);let tt;if(c)tt=c(o,s,r);else if(U(a)){const{onTrigger:ut}=U(a),ct=await ut(o,s,at);ct&&(tt=ct.node,ct.stop(o+r))}else throw new Error(`sound ${a} not found! Is it loaded?`);if(!tt||n.currentTime>o)return;const qe=[];if(qe.push(tt),qe.push(k(h)),f!==void 0&&qe.push(Q("lowpass",f,d)),g!==void 0&&qe.push(Q("highpass",g,y)),I!==void 0&&qe.push(Q("bandpass",I,P)),Re!==void 0&&qe.push(n.createVowelFilter(Re)),N!==void 0&&qe.push(x(n,"coarse-processor",{coarse:N})),Y!==void 0&&qe.push(x(n,"crush-processor",{crush:Y})),H!==void 0&&qe.push(x(n,"shape-processor",{shape:H})),Se!==void 0){const ut=n.createStereoPanner();ut.pan.value=2*Se-1,qe.push(ut)}const ht=k(1);qe.push(ht),ht.connect(j());let Je;if(oe>0&&Te>0&&ke>0){const ut=fe(Qe,Te,ke,o);Je=_(ht,ut,oe)}let pt;if(Ve>0&&Ze>0){const ut=Ae(Qe,Ze);pt=_(ht,ut,Ve)}qe.slice(1).reduce((ut,ct)=>ut.connect(ct),qe[0]),je=qe.concat([Je,pt])},O={};function pe(s,e){var r=e?1e3:1024;if(s=r);return s.toFixed(1)+" "+n[o]}const be=async(s,e,r,n,o,a,l)=>{let c=0,h=de({freq:o,note:r},36);c=h-36;const f=C();let d;if(Array.isArray(a))d=a[e%a.length];else{const P=Y=>L(Y)-h,N=Object.keys(a).filter(Y=>!Y.startsWith("_")).reduce((Y,H,Se)=>!Y||Math.abs(P(H))(O[s]||(O[s]=fetch(s).then(o=>o.arrayBuffer()).then(async o=>(pe(o.byteLength),await e.decodeAudioData(o)))),O[s]);function ye(s){const e=C(),r=e.createBuffer(s.numberOfChannels,s.length,e.sampleRate);for(let n=0;nObject.entries(s).forEach(([n,o])=>{if(typeof o=="string"&&(o=[o]),typeof o!="object")throw new Error("wrong sample map format for "+n);r=o._base||r;const a=l=>(r+l).replace("github:","https://raw.githubusercontent.com/");Array.isArray(o)?o=o.map(a):o=Object.fromEntries(Object.entries(o).map(([l,c])=>[l,(typeof c=="string"?[c]:c).map(a)])),e(n,o)});let ne={};function Ge(s){const e=Object.entries(ne).find(([r])=>s.startsWith(r));if(e)return e[1]}const we=async(s,e=s._base||"",r={})=>{if(typeof s=="string"){const a=Ge(s);if(a)return a(s);if(s.startsWith("github:")){let[c,h]=s.split("github:");h=h.endsWith("/")?h.slice(0,-1):h,s=`https://raw.githubusercontent.com/${h}/strudel.json`}if(typeof fetch!="function")return;const l=s.split("/").slice(0,-1).join("/");return typeof fetch>"u"?void 0:fetch(s).then(c=>c.json()).then(c=>we(c,e||c._base||l,r)).catch(c=>{throw console.error(c),new Error(`error loading "${s}"`)})}const{prebake:n,tag:o}=r;me(s,(a,l)=>te(a,(c,h,f)=>Xe(c,h,f,l),{type:"sample",samples:l,baseUrl:e,prebake:n,tag:o}),e)},$=[];async function Xe(s,e,r,n,o){const{s:a,freq:l,unit:c,nudge:h=0,cut:f,loop:d,clip:g=void 0,n:y=0,note:I,speed:P=1,begin:N=0,end:Y=1}=e;if(P===0)return;const H=C(),{attack:Se=.001,decay:Re=.001,sustain:oe=1,release:ke=.001}=e,Te=s+h,Qe=await be(a,y,I,P,l,n,o);if(H.currentTime>s||!Qe)return;Qe.playbackRate.value=Math.abs(P)*Qe.playbackRate.value,c==="c"&&(Qe.playbackRate.value=Qe.playbackRate.value*Qe.buffer.duration*1);const Ve=N*Qe.buffer.duration;Qe.start(Te,Ve);const Ze=Qe.buffer.duration/Qe.playbackRate.value,{node:De,stop:je}=ee(Se,Re,oe,ke,1,s);Qe.connect(De);const at=H.createGain();De.connect(at),Qe.onended=function(){Qe.disconnect(),De.disconnect(),at.disconnect(),r()};const tt={node:at,bufferSource:Qe,stop:(qe,ht=g===void 0)=>{let Je=qe;ht&&(Je=s+(Y-N)*Ze),Qe.stop(Je+ke),je(Je)}};if(f!==void 0){const qe=$[f];qe&&(qe.node.gain.setValueAtTime(1,Te),qe.node.gain.linearRampToValueAtTime(0,Te+.01)),$[f]=tt}return tt}function Ke(){["sine","square","triangle","sawtooth"].forEach(s=>{te(s,(e,r,n)=>{const{attack:o=.001,decay:a=.05,sustain:l=.6,release:c=.01}=r;let{n:h,note:f,freq:d}=r;h=f||h||36,typeof h=="string"&&(h=L(h)),!d&&typeof h=="number"&&(d=se(h));const{node:g,stop:y}=Ie({t:e,s,freq:d}),I=k(.3),{node:P,stop:N}=ee(o,a,l,c,1,e);return g.onended=()=>{g.disconnect(),I.disconnect(),n()},{node:g.connect(I).connect(P),stop:Y=>{N(Y),y(Y+c)}}},{type:"synth",prebake:!0})})}Array.prototype.in=function(s){return this.includes(s)};Promise.all([ve(),we("github:tidalcycles/Dirt-Samples/master"),Ke()]);class UserAPI{constructor(e){$e(this,"variables",{});$e(this,"iterators",{});$e(this,"_drunk",new DrunkWalk(-100,100,!1));$e(this,"MidiConnection",new MidiConnection);$e(this,"load");$e(this,"log",console.log);$e(this,"scale",scale);$e(this,"s",this.script);$e(this,"cs",this.clearscript);$e(this,"cps",this.copyscript);$e(this,"$",this.iterator);$e(this,"v",this.variable);$e(this,"dv",this.delete_variable);$e(this,"cv",this.clear_variables);$e(this,"rI",this.randI);$e(this,"r",this.rand);$e(this,"quant",this.quantize);$e(this,"cmp",this.clamp);$e(this,"tempo",this.bpm);$e(this,"silence",this.stop);$e(this,"hush",this.stop);$e(this,"abs",Math.abs);$e(this,"sound",async(e,r=0)=>{he(e,r)});$e(this,"d",this.sound);this.app=e,this.load=we("github:tidalcycles/Dirt-Samples/master")}get time(){return this.app.audioContext.currentTime}get mouseX(){return this.app._mouseX}get mouseY(){return this.app._mouseY}rate(e){}script(...e){e.forEach(r=>{tryEvaluate(this.app,this.app.universes[this.app.selected_universe].locals[r])})}clearscript(e){this.app.universes[this.app.selected_universe].locals[e]={candidate:"",committed:"",evaluations:0}}copyscript(e,r){this.app.universes[this.app.selected_universe].locals[r]=this.app.universes[this.app.selected_universe].locals[e]}midi_outputs(){return console.log(this.MidiConnection.listMidiOutputs()),this.MidiConnection.midiOutputs}midi_output(e){e?this.MidiConnection.switchMidiOutput(e):console.log(this.MidiConnection.getCurrentMidiPort())}note(e,r={}){const n=r.channel?r.channel:0,o=r.velocity?r.velocity:100,a=r.duration?r.duration:.5;this.MidiConnection.sendMidiNote(e,n,o,a)}zn(e,r={}){const n=next(e,r),o=r.channel?r.channel:0,a=r.velocity?r.velocity:100,l=r.sustain?r.sustain:.5;return n instanceof Pitch?(n.bend&&this.MidiConnection.sendPitchBend(n.bend,o),this.MidiConnection.sendMidiNote(n.note,o,a,l),n.bend&&this.MidiConnection.sendPitchBend(8192,o)):n instanceof Chord&&n.pitches.forEach(c=>{c.bend&&this.MidiConnection.sendPitchBend(c.bend,o),this.MidiConnection.sendMidiNote(c.note,o,a,l),c.bend&&this.MidiConnection.sendPitchBend(8192,o)}),n}sysex(e){this.MidiConnection.sendSysExMessage(e)}pitch_bend(e,r){this.MidiConnection.sendPitchBend(e,r)}program_change(e,r){this.MidiConnection.sendProgramChange(e,r)}midi_clock(){this.MidiConnection.sendMidiClock()}cc(e,r){this.MidiConnection.sendMidiControlChange(e,r)}midi_panic(){this.MidiConnection.panic()}iterator(e,r,n){return e in this.iterators?(this.iterators[e].limit!==r&&(this.iterators[e].value=0,this.iterators[e].limit=r),this.iterators[e].step!==n&&(this.iterators[e].step=n??this.iterators[e].step),this.iterators[e].value+=this.iterators[e].step,this.iterators[e].limit!==void 0&&this.iterators[e].value>this.iterators[e].limit&&(this.iterators[e].value=0)):this.iterators[e]={value:0,step:n??1,limit:r},this.iterators[e].value}get drunk(){return this._drunk.step(),this._drunk.getPosition()}set drunk(e){this._drunk.position=e}set drunk_max(e){this._drunk.max=e}set drunk_min(e){this._drunk.min=e}set drunk_wrap(e){this._drunk.toggleWrap(e)}variable(e,r){return typeof e=="string"&&r===void 0?this.variables[e]:(this.variables[e]=r,this.variables[e])}delete_variable(e){delete this.variables[e]}clear_variables(){this.variables={}}pick(...e){return e[Math.floor(Math.random()*e.length)]}seqbeat(...e){return e[this.app.clock.time_position.beat%e.length]}mel(e,r){return r[e%r.length]}seqbar(...e){return e[this.app.clock.time_position.bar%e.length]}seqpulse(...e){return e[this.app.clock.time_position.pulse%e.length]}randI(e,r){return Math.floor(Math.random()*(r-e+1))+e}rand(e,r){return Math.random()*(r-e)+e}quantize(e,r){if(r.length===0)return e;let n=r[0];return r.forEach(o=>{Math.abs(o-e)500)&&console.log(`Setting bpm to ${e}`),this.app.clock.bpm=e,e)}time_signature(e,r){this.app.clock.time_signature=[e,r]}almostNever(){return Math.random()>.9}sometimes(){return Math.random()>.5}rarely(){return Math.random()>.75}often(){return Math.random()>.25}almostAlways(){return Math.random()>.1}dice(e){return Math.floor(Math.random()*e)+1}get i(){return this.app.universes[this.app.selected_universe].global.evaluations}set i(e){this.app.universes[this.app.selected_universe].global.evaluations=e}get bar(){return this.app.clock.time_position.bar}get tick(){return this.app.clock.tick}get pulse(){return this.app.clock.time_position.pulse}get beat(){return this.app.clock.time_position.beat}get ebeat(){return this.app.clock.beats_since_origin}onbar(e,...r){const n=[...Array(e).keys()].map(o=>o+1);return console.log(r.some(o=>n.includes(o%e))),r.some(o=>n.includes(o%e))}onbeat(...e){let r=[];return e.forEach(n=>{n=1+n%this.app.clock.time_signature[0];let o=Math.floor(n),a=n-o;r.push(o===this.app.clock.time_position.beat&&this.app.clock.time_position.pulse===a*this.app.clock.ppqn)}),r.some(n=>n==!0)}stop(){this.app.clock.pause(),this.app.setButtonHighlighting("pause",!0)}prob(e){return Math.random()*100.5}min(...e){return Math.min(...e)}max(...e){return Math.max(...e)}limit(e,r,n){return Math.min(Math.max(e,r),n)}delay(e,r){setTimeout(r,e)}delayr(e,r,n){[...Array(r).keys()].map(a=>e*a).forEach((a,l)=>{setTimeout(n,a)})}mod(...e){return e.some(r=>this.app.clock.time_position.pulse%r===0)}modbar(...e){return e.some(r=>this.app.clock.time_position.bar%r===0)}euclid(e,r,n,o=0){return this._euclidean_cycle(r,n,o)[e%n]}_euclidean_cycle(e,r,n=0){function o(c,h){const f=c.length,d=(h+1)%f;return c[h]>c[d]}if(e>=r)return[!0];const a=Array.from({length:r},(c,h)=>(e*(h-1)%r+r)%r);let l=a.map((c,h)=>o(a,h));return n!=0&&(l=l.slice(n).concat(l.slice(0,n))),l}bin(e,r){let o=r.toString(2).split("").map(a=>a==="1");return o[e%o.length]}line(e,r,n=1){const o=[];if(r>e&&n>0||r0?1:-1}noise(){return Math.random()*2-1}}class Editor{constructor(){$e(this,"universes",template_universes);$e(this,"selected_universe");$e(this,"local_index",1);$e(this,"editor_mode","local");$e(this,"fontSize");$e(this,"withLineNumbers");$e(this,"vimModeCompartment");$e(this,"chosenLanguage");$e(this,"settings",new AppSettings);$e(this,"editorExtensions",[]);$e(this,"userPlugins",[]);$e(this,"state");$e(this,"api");$e(this,"audioContext");$e(this,"view");$e(this,"clock");$e(this,"manualPlay",!1);$e(this,"_mouseX",0);$e(this,"_mouseY",0);$e(this,"play_buttons",[document.getElementById("play-button-1"),document.getElementById("play-button-2")]);$e(this,"pause_buttons",[document.getElementById("pause-button-1"),document.getElementById("pause-button-2")]);$e(this,"stop_buttons",[document.getElementById("stop-button-1"),document.getElementById("stop-button-2")]);$e(this,"clear_buttons",[document.getElementById("clear-button-1"),document.getElementById("clear-button-2")]);$e(this,"local_button",document.getElementById("local-button"));$e(this,"global_button",document.getElementById("global-button"));$e(this,"init_button",document.getElementById("init-button"));$e(this,"note_button",document.getElementById("note-button"));$e(this,"settings_button",document.getElementById("settings-button"));$e(this,"close_settings_button",document.getElementById("close-settings-button"));$e(this,"universe_viewer",document.getElementById("universe-viewer"));$e(this,"buffer_modal",document.getElementById("modal-buffers"));$e(this,"buffer_search",document.getElementById("buffer-search"));$e(this,"local_script_tabs",document.getElementById("local-script-tabs"));$e(this,"font_size_slider",document.getElementById("font-size-slider"));$e(this,"font_size_witness",document.getElementById("font-size-witness"));$e(this,"line_numbers_checkbox",document.getElementById("show-line-numbers"));$e(this,"normal_mode_button",document.getElementById("normal-mode"));$e(this,"vim_mode_button",document.getElementById("vim-mode"));this.selected_universe=this.settings.selected_universe,this.universe_viewer.innerHTML=`Topos: ${this.selected_universe}`,this.universes={...template_universes,...this.settings.universes},this.audioContext=new AudioContext({latencyHint:"playback"}),this.clock=new Clock(this,this.audioContext),this.api=new UserAPI(this),this.vimModeCompartment=new Compartment,this.withLineNumbers=new Compartment,this.chosenLanguage=new Compartment,this.fontSize=new Compartment;const e=this.settings.vimMode?vim():[],r=this.settings.line_numbers?lineNumbers():[],n=EditorView.theme({"&":{fontSize:`${this.settings.font_size}px`},".cm-gutters":{fontSize:`${this.settings.font_size}px`}});this.editorExtensions=[this.withLineNumbers.of(r),this.fontSize.of(n),this.vimModeCompartment.of(e),editorSetup,oneDark,this.chosenLanguage.of(javascript()),EditorView.updateListener.of(l=>{})];let o=new Compartment;this.state=EditorState.create({extensions:[...this.editorExtensions,EditorView.lineWrapping,o.of(this.userPlugins)],doc:this.universes[this.selected_universe].locals[this.local_index].candidate}),this.view=new EditorView({parent:document.getElementById("editor"),state:this.state}),document.addEventListener("keydown",l=>{l.key==="Tab"&&l.preventDefault(),l.ctrlKey&&l.key==="s"&&(l.preventDefault(),this.setButtonHighlighting("pause",!0),this.clock.pause()),l.ctrlKey&&l.key==="r"&&(l.preventDefault(),this.setButtonHighlighting("stop",!0),this.clock.stop()),l.ctrlKey&&l.key==="p"&&(l.preventDefault(),this.setButtonHighlighting("play",!0),this.clock.start()),(l.key==="v"||l.key==="V")&&l.ctrlKey&&l.shiftKey&&(this.settings.vimMode=!this.settings.vimMode,l.preventDefault(),this.userPlugins=this.settings.vimMode?[]:[vim()],this.view.dispatch({effects:o.reconfigure(this.userPlugins)})),(l.key==="Enter"||l.key==="Return")&&l.ctrlKey&&(l.preventDefault(),this.currentFile().candidate=this.view.state.doc.toString(),this.flashBackground("#2d313d",200)),(l.key==="Enter"&&l.shiftKey||l.key==="e"&&l.ctrlKey)&&(l.preventDefault(),this.currentFile().candidate=this.view.state.doc.toString(),this.flashBackground("#2d313d",200)),l.ctrlKey&&l.key==="b"&&this.openBuffersModal(),l.shiftKey&&l.key==="Escape"&&this.openSettingsModal(),l.ctrlKey&&l.key==="l"&&(l.preventDefault(),this.changeModeFromInterface("local"),this.view.focus()),l.ctrlKey&&l.key==="n"&&(l.preventDefault(),this.changeModeFromInterface("notes"),this.view.focus()),l.ctrlKey&&l.key==="g"&&(l.preventDefault(),this.changeModeFromInterface("global"),this.view.focus()),l.ctrlKey&&l.key==="i"&&(l.preventDefault(),this.changeModeFromInterface("init"),this.changeToLocalBuffer(0),this.view.focus()),[112,113,114,115,116,117,118,119,120].forEach((c,h)=>{l.keyCode===c&&(l.preventDefault(),l.ctrlKey?this.api.script(c-111):(this.changeModeFromInterface("local"),this.changeToLocalBuffer(h)))}),l.keyCode==121&&this.changeModeFromInterface("global"),l.keyCode==122&&this.changeModeFromInterface("init")});const a=document.querySelectorAll('[id^="tab-"]');for(let l=0;l{a[l].classList.add("bg-orange-300");for(let d=0;d{l.addEventListener("click",()=>{this.setButtonHighlighting("play",!0),this.clock.start()})}),this.clear_buttons.forEach(l=>{l.addEventListener("click",()=>{this.setButtonHighlighting("clear",!0),confirm("Do you want to reset the current universe?")&&(this.universes[this.selected_universe]=template_universe,this.updateEditorView())})}),this.pause_buttons.forEach(l=>{l.addEventListener("click",()=>{this.setButtonHighlighting("pause",!0),this.clock.pause()})}),this.stop_buttons.forEach(l=>{l.addEventListener("click",()=>{this.setButtonHighlighting("stop",!0),this.clock.stop()})}),this.local_button.addEventListener("click",()=>this.changeModeFromInterface("local")),this.global_button.addEventListener("click",()=>this.changeModeFromInterface("global")),this.init_button.addEventListener("click",()=>this.changeModeFromInterface("init")),this.note_button.addEventListener("click",()=>this.changeModeFromInterface("notes")),this.settings_button.addEventListener("click",()=>{var h;this.font_size_slider.value=this.settings.font_size.toString(),this.font_size_witness.innerHTML=`Font Size: ${this.settings.font_size}px`,(h=this.font_size_witness)==null||h.setAttribute("style",`font-size: ${this.settings.font_size}px;`),this.line_numbers_checkbox.checked=this.settings.line_numbers;let l=document.getElementById("modal-settings"),c=document.getElementById("editor");l==null||l.classList.remove("invisible"),c==null||c.classList.add("invisible")}),this.close_settings_button.addEventListener("click",()=>{let l=document.getElementById("modal-settings"),c=document.getElementById("editor");l==null||l.classList.add("invisible"),c==null||c.classList.remove("invisible")}),this.font_size_slider.addEventListener("input",()=>{const l=this.font_size_slider.value;this.settings.font_size=parseInt(l),this.font_size_witness.style.fontSize=`${l}px`,this.font_size_witness.innerHTML=`Font Size: ${l}px`;let c=EditorView.theme({"&":{fontSize:l+"px"},".cm-gutters":{fontSize:l+"px"}});this.view.dispatch({effects:this.fontSize.reconfigure(c)}),this.settings.font_size=parseInt(l)}),this.normal_mode_button.addEventListener("click",()=>{this.settings.vimMode=!1,this.view.dispatch({effects:this.vimModeCompartment.reconfigure([])})}),this.line_numbers_checkbox.addEventListener("change",()=>{let l=!!this.line_numbers_checkbox.checked;this.settings.line_numbers=l,this.view.dispatch({effects:this.withLineNumbers.reconfigure(l?[lineNumbers()]:[])})}),this.vim_mode_button.addEventListener("click",()=>{this.settings.vimMode=!0,this.view.dispatch({effects:this.vimModeCompartment.reconfigure(vim())})}),this.buffer_search.addEventListener("keydown",l=>{if(l.key==="Enter"){let c=this.buffer_search.value;c.length>2&&c.length<20&&(this.loadUniverse(c),this.settings.selected_universe=c,this.buffer_search.value="",this.closeBuffersModal(),this.view.focus())}}),tryEvaluate(this,this.universes[this.selected_universe.toString()].init)}get note_buffer(){return this.universes[this.selected_universe.toString()].notes}get global_buffer(){return this.universes[this.selected_universe.toString()].global}get init_buffer(){return this.universes[this.selected_universe.toString()].init}get local_buffer(){return this.universes[this.selected_universe.toString()].locals[this.local_index]}changeToLocalBuffer(e){const r=document.querySelectorAll('[id^="tab-"]'),n=r[e];n.classList.add("bg-orange-300");for(let a=0;a{r.forEach(a=>{let l=a.children[0];l.classList.contains("text-orange-300")&&(l.classList.remove("text-orange-300"),a.classList.remove("text-orange-300"))}),o.children[0].classList.remove("text-white"),o.children[0].classList.add("text-orange-300"),o.classList.add("text-orange-300")};switch(e){case"local":this.local_script_tabs.classList.contains("hidden")&&this.local_script_tabs.classList.remove("hidden"),this.editor_mode="local",this.local_index=0,this.changeToLocalBuffer(this.local_index),n(this.local_button);break;case"global":this.local_script_tabs.classList.contains("hidden")||this.local_script_tabs.classList.add("hidden"),this.editor_mode="global",n(this.global_button);break;case"init":this.local_script_tabs.classList.contains("hidden")||this.local_script_tabs.classList.add("hidden"),this.editor_mode="init",n(this.init_button);break;case"notes":this.local_script_tabs.classList.contains("hidden")||this.local_script_tabs.classList.add("hidden"),this.editor_mode="notes",n(this.note_button);break}this.view.dispatch({effects:this.chosenLanguage.reconfigure(this.editor_mode=="notes"?[markdown()]:[javascript()])}),this.updateEditorView()}setButtonHighlighting(e,r){this.flashBackground("#2d313d",200);const n=['[id^="play-button-"]','[id^="pause-button-"]','[id^="clear-button-"]','[id^="stop-button-"]'];let o;switch(e){case"play":o=0;break;case"pause":o=1;break;case"clear":o=2;break;case"stop":o=3;break}document.querySelectorAll(n[o]).forEach(a=>{r&&a.children[0].classList.add("fill-orange-300")}),document.querySelectorAll(n.filter((a,l)=>l!=o).join(",")).forEach(a=>{a.children[0].classList.remove("fill-orange-300"),a.children[0].classList.remove("text-orange-300"),a.children[0].classList.remove("bg-orange-300")})}unfocusPlayButtons(){document.querySelectorAll('[id^="play-button-"]').forEach(e=>{e.children[0].classList.remove("fill-orange-300")})}updateEditorView(){this.view.dispatch({changes:{from:0,to:this.view.state.doc.toString().length,insert:this.currentFile().candidate}})}currentFile(){switch(this.editor_mode){case"global":return this.global_buffer;case"local":return this.local_buffer;case"init":return this.init_buffer;case"notes":return this.note_buffer}}loadUniverse(e){this.currentFile().candidate=this.view.state.doc.toString();let r=e.trim();this.universes[r]===void 0&&(this.universes[r]=template_universe),this.selected_universe=r,this.settings.selected_universe=this.selected_universe,this.universe_viewer.innerHTML=`Topos: ${r}`,this.updateEditorView(),tryEvaluate(this,this.universes[this.selected_universe.toString()].init)}openSettingsModal(){document.getElementById("modal-settings").classList.contains("invisible")?(document.getElementById("editor").classList.add("invisible"),document.getElementById("modal-settings").classList.remove("invisible")):this.closeSettingsModal()}closeSettingsModal(){document.getElementById("editor").classList.remove("invisible"),document.getElementById("modal-settings").classList.add("invisible")}openBuffersModal(){document.getElementById("modal-buffers").classList.contains("invisible")?(document.getElementById("editor").classList.add("invisible"),document.getElementById("modal-buffers").classList.remove("invisible"),document.getElementById("buffer-search").focus()):this.closeBuffersModal()}closeBuffersModal(){document.getElementById("buffer-search").value="",document.getElementById("editor").classList.remove("invisible"),document.getElementById("modal").classList.add("invisible"),document.getElementById("modal-buffers").classList.add("invisible")}flashBackground(e,r){this.view.dom.style.backgroundColor=e;const n=this.view.dom.getElementsByClassName("cm-gutter");Array.from(n).forEach(o=>o.style.backgroundColor=e),setTimeout(()=>{this.view.dom.style.backgroundColor="",Array.from(n).forEach(o=>o.style.backgroundColor="")},r)}}const app=new Editor;function startClock(){document.getElementById("editor").classList.remove("invisible"),document.getElementById("modal").classList.add("hidden"),document.getElementById("modal-container").classList.remove("motion-safe:animate-pulse"),document.getElementById("start-button").removeEventListener("click",startClock),document.removeEventListener("click",startClock),document.removeEventListener("keydown",startOnEnter),document.removeEventListener("click",startOnClick),app.clock.start(),app.view.focus(),app.setButtonHighlighting("play",!0)}function startOnEnter(s){(s.code==="Enter"||s.code==="Space")&&startClock()}function startOnClick(s){s.button===0&&startClock()}document.addEventListener("keydown",startOnEnter);document.addEventListener("click",startOnClick);function reportMouseCoordinates(s){app._mouseX=s.clientX,app._mouseY=s.clientY}window.addEventListener("mousemove",reportMouseCoordinates);window.addEventListener("beforeunload",()=>(event.preventDefault(),app.currentFile().candidate=app.view.state.doc.toString(),app.currentFile().committed=app.view.state.doc.toString(),app.settings.saveApplicationToLocalStorage(app.universes,app.settings),app.clock.stop(),null)); +`],!1,!1),peg$e1=peg$literalExpectation("(",!1),peg$e2=peg$literalExpectation(",",!1),peg$e3=peg$literalExpectation(")",!1),peg$e4=peg$classExpectation([["0","9"]],!1,!1),peg$e5=peg$literalExpectation(".",!1),peg$e6=peg$literalExpectation("-",!1),peg$e7=peg$literalExpectation("/",!1),peg$e8=peg$literalExpectation("\\",!1),peg$e9=peg$literalExpectation("<",!1),peg$e10=peg$literalExpectation(">",!1),peg$e11=peg$literalExpectation("[",!1),peg$e12=peg$literalExpectation("+",!1),peg$e13=peg$literalExpectation("*",!1),peg$e14=peg$literalExpectation("%",!1),peg$e15=peg$literalExpectation("&",!1),peg$e16=peg$literalExpectation("|",!1),peg$e17=peg$literalExpectation("<<",!1),peg$e18=peg$literalExpectation(">>",!1),peg$f0=function(s){return centsToSemitones(s.filter(e=>e))},peg$f1=function(){},peg$f2=function(s,e){return Math.floor(Math.random()*(e-s+1)+s)},peg$f3=function(s,e){return Math.random()*(e-s)+s},peg$f4=function(){return parseFloat(text())},peg$f5=function(){return parseInt(text())},peg$f6=function(s){return ratioToCents(s)},peg$f7=function(s,e){return s/e},peg$f8=function(s,e){return Math.pow(2,s/e)},peg$f9=function(s,e,r,n){var o=n?r/n:r;return Math.pow(o,s/e)},peg$f10=function(s,e){return parseFloat(s.toString()+"."+e.toString())},peg$f11=function(s){return s.filter(e=>e)},peg$f12=function(s){return monzoToCents(s)},peg$f13=function(){return eval(text())},peg$currPos=0,peg$savedPos=0,peg$posDetailsCache=[{line:1,column:1}],peg$maxFailPos=0,peg$maxFailExpected=[],peg$resultsCache={},peg$result;if("startRule"in options){if(!(options.startRule in peg$startRuleFunctions))throw new Error(`Can't start parsing from rule "`+options.startRule+'".');peg$startRuleFunction=peg$startRuleFunctions[options.startRule]}function text(){return input.substring(peg$savedPos,peg$currPos)}function peg$literalExpectation(s,e){return{type:"literal",text:s,ignoreCase:e}}function peg$classExpectation(s,e,r){return{type:"class",parts:s,inverted:e,ignoreCase:r}}function peg$endExpectation(){return{type:"end"}}function peg$computePosDetails(s){var e=peg$posDetailsCache[s],r;if(e)return e;for(r=s-1;!peg$posDetailsCache[r];)r--;for(e=peg$posDetailsCache[r],e={line:e.line,column:e.column};rpeg$maxFailPos&&(peg$maxFailPos=peg$currPos,peg$maxFailExpected=[]),peg$maxFailExpected.push(s))}function peg$buildStructuredError(s,e,r){return new peg$SyntaxError(peg$SyntaxError.buildMessage(s,e),s,e,r)}function peg$parselines(){var s,e,r,n=peg$currPos*17+0,o=peg$resultsCache[n];if(o)return peg$currPos=o.nextPos,o.result;if(s=peg$currPos,e=[],r=peg$parseratio(),r===peg$FAILED&&(r=peg$parsevalue(),r===peg$FAILED&&(r=peg$parsemonzo(),r===peg$FAILED&&(r=peg$parseoperation(),r===peg$FAILED&&(r=peg$parsesep())))),r!==peg$FAILED)for(;r!==peg$FAILED;)e.push(r),r=peg$parseratio(),r===peg$FAILED&&(r=peg$parsevalue(),r===peg$FAILED&&(r=peg$parsemonzo(),r===peg$FAILED&&(r=peg$parseoperation(),r===peg$FAILED&&(r=peg$parsesep()))));else e=peg$FAILED;return e!==peg$FAILED&&(peg$savedPos=s,e=peg$f0(e)),s=e,peg$resultsCache[n]={nextPos:peg$currPos,result:s},s}function peg$parsesep(){var s,e,r=peg$currPos*17+1,n=peg$resultsCache[r];return n?(peg$currPos=n.nextPos,n.result):(s=peg$currPos,peg$r0.test(input.charAt(peg$currPos))?(e=input.charAt(peg$currPos),peg$currPos++):(e=peg$FAILED,peg$fail(peg$e0)),e!==peg$FAILED&&(peg$savedPos=s,e=peg$f1()),s=e,peg$resultsCache[r]={nextPos:peg$currPos,result:s},s)}function peg$parsevalue(){var s,e=peg$currPos*17+2,r=peg$resultsCache[e];return r?(peg$currPos=r.nextPos,r.result):(s=peg$parsefloat(),s===peg$FAILED&&(s=peg$parseint(),s===peg$FAILED&&(s=peg$parserandom_int(),s===peg$FAILED&&(s=peg$parserandom_float()))),peg$resultsCache[e]={nextPos:peg$currPos,result:s},s)}function peg$parserandom_int(){var s,e,r,n,o,a,l=peg$currPos*17+3,c=peg$resultsCache[l];return c?(peg$currPos=c.nextPos,c.result):(s=peg$currPos,input.charCodeAt(peg$currPos)===40?(e=peg$c0,peg$currPos++):(e=peg$FAILED,peg$fail(peg$e1)),e!==peg$FAILED?(r=peg$parseint(),r!==peg$FAILED?(input.charCodeAt(peg$currPos)===44?(n=peg$c1,peg$currPos++):(n=peg$FAILED,peg$fail(peg$e2)),n!==peg$FAILED?(o=peg$parseint(),o!==peg$FAILED?(input.charCodeAt(peg$currPos)===41?(a=peg$c2,peg$currPos++):(a=peg$FAILED,peg$fail(peg$e3)),a!==peg$FAILED?(peg$savedPos=s,s=peg$f2(r,o)):(peg$currPos=s,s=peg$FAILED)):(peg$currPos=s,s=peg$FAILED)):(peg$currPos=s,s=peg$FAILED)):(peg$currPos=s,s=peg$FAILED)):(peg$currPos=s,s=peg$FAILED),peg$resultsCache[l]={nextPos:peg$currPos,result:s},s)}function peg$parserandom_float(){var s,e,r,n,o,a,l=peg$currPos*17+4,c=peg$resultsCache[l];return c?(peg$currPos=c.nextPos,c.result):(s=peg$currPos,input.charCodeAt(peg$currPos)===40?(e=peg$c0,peg$currPos++):(e=peg$FAILED,peg$fail(peg$e1)),e!==peg$FAILED?(r=peg$parsefloat(),r!==peg$FAILED?(input.charCodeAt(peg$currPos)===44?(n=peg$c1,peg$currPos++):(n=peg$FAILED,peg$fail(peg$e2)),n!==peg$FAILED?(o=peg$parsefloat(),o!==peg$FAILED?(input.charCodeAt(peg$currPos)===41?(a=peg$c2,peg$currPos++):(a=peg$FAILED,peg$fail(peg$e3)),a!==peg$FAILED?(peg$savedPos=s,s=peg$f3(r,o)):(peg$currPos=s,s=peg$FAILED)):(peg$currPos=s,s=peg$FAILED)):(peg$currPos=s,s=peg$FAILED)):(peg$currPos=s,s=peg$FAILED)):(peg$currPos=s,s=peg$FAILED),peg$resultsCache[l]={nextPos:peg$currPos,result:s},s)}function peg$parsefloat(){var s,e,r,n,o,a,l,c=peg$currPos*17+5,h=peg$resultsCache[c];if(h)return peg$currPos=h.nextPos,h.result;if(s=peg$currPos,e=peg$currPos,r=[],peg$r1.test(input.charAt(peg$currPos))?(n=input.charAt(peg$currPos),peg$currPos++):(n=peg$FAILED,peg$fail(peg$e4)),n!==peg$FAILED)for(;n!==peg$FAILED;)r.push(n),peg$r1.test(input.charAt(peg$currPos))?(n=input.charAt(peg$currPos),peg$currPos++):(n=peg$FAILED,peg$fail(peg$e4));else r=peg$FAILED;if(r!==peg$FAILED?(input.charCodeAt(peg$currPos)===46?(n=peg$c3,peg$currPos++):(n=peg$FAILED,peg$fail(peg$e5)),n!==peg$FAILED?(r=[r,n],e=r):(peg$currPos=e,e=peg$FAILED)):(peg$currPos=e,e=peg$FAILED),e===peg$FAILED){for(e=peg$currPos,input.charCodeAt(peg$currPos)===45?(r=peg$c4,peg$currPos++):(r=peg$FAILED,peg$fail(peg$e6)),r===peg$FAILED&&(r=null),n=[],peg$r1.test(input.charAt(peg$currPos))?(o=input.charAt(peg$currPos),peg$currPos++):(o=peg$FAILED,peg$fail(peg$e4));o!==peg$FAILED;)n.push(o),peg$r1.test(input.charAt(peg$currPos))?(o=input.charAt(peg$currPos),peg$currPos++):(o=peg$FAILED,peg$fail(peg$e4));if(input.charCodeAt(peg$currPos)===46?(o=peg$c3,peg$currPos++):(o=peg$FAILED,peg$fail(peg$e5)),o!==peg$FAILED){if(a=[],peg$r1.test(input.charAt(peg$currPos))?(l=input.charAt(peg$currPos),peg$currPos++):(l=peg$FAILED,peg$fail(peg$e4)),l!==peg$FAILED)for(;l!==peg$FAILED;)a.push(l),peg$r1.test(input.charAt(peg$currPos))?(l=input.charAt(peg$currPos),peg$currPos++):(l=peg$FAILED,peg$fail(peg$e4));else a=peg$FAILED;a!==peg$FAILED?(r=[r,n,o,a],e=r):(peg$currPos=e,e=peg$FAILED)}else peg$currPos=e,e=peg$FAILED;if(e===peg$FAILED)if(e=peg$currPos,input.charCodeAt(peg$currPos)===46?(r=peg$c3,peg$currPos++):(r=peg$FAILED,peg$fail(peg$e5)),r!==peg$FAILED){if(n=[],peg$r1.test(input.charAt(peg$currPos))?(o=input.charAt(peg$currPos),peg$currPos++):(o=peg$FAILED,peg$fail(peg$e4)),o!==peg$FAILED)for(;o!==peg$FAILED;)n.push(o),peg$r1.test(input.charAt(peg$currPos))?(o=input.charAt(peg$currPos),peg$currPos++):(o=peg$FAILED,peg$fail(peg$e4));else n=peg$FAILED;n!==peg$FAILED?(r=[r,n],e=r):(peg$currPos=e,e=peg$FAILED)}else peg$currPos=e,e=peg$FAILED}return e!==peg$FAILED&&(peg$savedPos=s,e=peg$f4()),s=e,peg$resultsCache[c]={nextPos:peg$currPos,result:s},s}function peg$parseint(){var s,e,r,n=peg$currPos*17+6,o=peg$resultsCache[n];if(o)return peg$currPos=o.nextPos,o.result;if(s=peg$currPos,input.charCodeAt(peg$currPos)===45?peg$currPos++:peg$fail(peg$e6),e=[],peg$r1.test(input.charAt(peg$currPos))?(r=input.charAt(peg$currPos),peg$currPos++):(r=peg$FAILED,peg$fail(peg$e4)),r!==peg$FAILED)for(;r!==peg$FAILED;)e.push(r),peg$r1.test(input.charAt(peg$currPos))?(r=input.charAt(peg$currPos),peg$currPos++):(r=peg$FAILED,peg$fail(peg$e4));else e=peg$FAILED;return e!==peg$FAILED?(peg$savedPos=s,s=peg$f5()):(peg$currPos=s,s=peg$FAILED),peg$resultsCache[n]={nextPos:peg$currPos,result:s},s}function peg$parseratio(){var s,e,r=peg$currPos*17+7,n=peg$resultsCache[r];return n?(peg$currPos=n.nextPos,n.result):(s=peg$currPos,e=peg$parseedji_ratio(),e===peg$FAILED&&(e=peg$parseedo_ratio(),e===peg$FAILED&&(e=peg$parsefrac_ratio(),e===peg$FAILED&&(e=peg$parsedecimal_ratio()))),e!==peg$FAILED&&(peg$savedPos=s,e=peg$f6(e)),s=e,peg$resultsCache[r]={nextPos:peg$currPos,result:s},s)}function peg$parsefrac_ratio(){var s,e,r,n,o=peg$currPos*17+8,a=peg$resultsCache[o];return a?(peg$currPos=a.nextPos,a.result):(s=peg$currPos,e=peg$parseint(),e===peg$FAILED&&(e=peg$parserandom_int()),e!==peg$FAILED?(input.charCodeAt(peg$currPos)===47?(r=peg$c5,peg$currPos++):(r=peg$FAILED,peg$fail(peg$e7)),r!==peg$FAILED?(n=peg$parseint(),n===peg$FAILED&&(n=peg$parserandom_int()),n!==peg$FAILED?(peg$savedPos=s,s=peg$f7(e,n)):(peg$currPos=s,s=peg$FAILED)):(peg$currPos=s,s=peg$FAILED)):(peg$currPos=s,s=peg$FAILED),peg$resultsCache[o]={nextPos:peg$currPos,result:s},s)}function peg$parseedo_ratio(){var s,e,r,n,o=peg$currPos*17+9,a=peg$resultsCache[o];return a?(peg$currPos=a.nextPos,a.result):(s=peg$currPos,e=peg$parseint(),e===peg$FAILED&&(e=peg$parserandom_int()),e!==peg$FAILED?(input.charCodeAt(peg$currPos)===92?(r=peg$c6,peg$currPos++):(r=peg$FAILED,peg$fail(peg$e8)),r!==peg$FAILED?(n=peg$parseint(),n===peg$FAILED&&(n=peg$parserandom_int()),n!==peg$FAILED?(peg$savedPos=s,s=peg$f8(e,n)):(peg$currPos=s,s=peg$FAILED)):(peg$currPos=s,s=peg$FAILED)):(peg$currPos=s,s=peg$FAILED),peg$resultsCache[o]={nextPos:peg$currPos,result:s},s)}function peg$parseedji_ratio(){var s,e,r,n,o,a,l,c,h=peg$currPos*17+10,f=peg$resultsCache[h];return f?(peg$currPos=f.nextPos,f.result):(s=peg$currPos,e=peg$parseint(),e===peg$FAILED&&(e=peg$parserandom_int()),e!==peg$FAILED?(input.charCodeAt(peg$currPos)===92?(r=peg$c6,peg$currPos++):(r=peg$FAILED,peg$fail(peg$e8)),r!==peg$FAILED?(n=peg$parseint(),n===peg$FAILED&&(n=peg$parserandom_int()),n!==peg$FAILED?(input.charCodeAt(peg$currPos)===60?(o=peg$c7,peg$currPos++):(o=peg$FAILED,peg$fail(peg$e9)),o!==peg$FAILED?(a=peg$parseint(),a===peg$FAILED&&(a=peg$parserandom_int()),a!==peg$FAILED?(input.charCodeAt(peg$currPos)===47?peg$currPos++:peg$fail(peg$e7),l=peg$parseint(),l===peg$FAILED&&(l=peg$parserandom_int()),l===peg$FAILED&&(l=null),input.charCodeAt(peg$currPos)===62?(c=peg$c8,peg$currPos++):(c=peg$FAILED,peg$fail(peg$e10)),c!==peg$FAILED?(peg$savedPos=s,s=peg$f9(e,n,a,l)):(peg$currPos=s,s=peg$FAILED)):(peg$currPos=s,s=peg$FAILED)):(peg$currPos=s,s=peg$FAILED)):(peg$currPos=s,s=peg$FAILED)):(peg$currPos=s,s=peg$FAILED)):(peg$currPos=s,s=peg$FAILED),peg$resultsCache[h]={nextPos:peg$currPos,result:s},s)}function peg$parsedecimal_ratio(){var s,e,r,n,o=peg$currPos*17+11,a=peg$resultsCache[o];return a?(peg$currPos=a.nextPos,a.result):(s=peg$currPos,e=peg$parseint(),e!==peg$FAILED?(input.charCodeAt(peg$currPos)===44?(r=peg$c1,peg$currPos++):(r=peg$FAILED,peg$fail(peg$e2)),r!==peg$FAILED?(n=peg$parseint(),n!==peg$FAILED?(peg$savedPos=s,s=peg$f10(e,n)):(peg$currPos=s,s=peg$FAILED)):(peg$currPos=s,s=peg$FAILED)):(peg$currPos=s,s=peg$FAILED),peg$resultsCache[o]={nextPos:peg$currPos,result:s},s)}function peg$parseints(){var s,e,r,n=peg$currPos*17+12,o=peg$resultsCache[n];if(o)return peg$currPos=o.nextPos,o.result;if(s=peg$currPos,e=[],r=peg$parseint(),r===peg$FAILED&&(r=peg$parsesep()),r!==peg$FAILED)for(;r!==peg$FAILED;)e.push(r),r=peg$parseint(),r===peg$FAILED&&(r=peg$parsesep());else e=peg$FAILED;return e!==peg$FAILED&&(peg$savedPos=s,e=peg$f11(e)),s=e,peg$resultsCache[n]={nextPos:peg$currPos,result:s},s}function peg$parsemonzo(){var s,e,r,n,o=peg$currPos*17+13,a=peg$resultsCache[o];return a?(peg$currPos=a.nextPos,a.result):(s=peg$currPos,input.charCodeAt(peg$currPos)===91?(e=peg$c9,peg$currPos++):(e=peg$FAILED,peg$fail(peg$e11)),e!==peg$FAILED?(r=peg$parseints(),r!==peg$FAILED?(input.charCodeAt(peg$currPos)===62?(n=peg$c8,peg$currPos++):(n=peg$FAILED,peg$fail(peg$e10)),n!==peg$FAILED?(peg$savedPos=s,s=peg$f12(r)):(peg$currPos=s,s=peg$FAILED)):(peg$currPos=s,s=peg$FAILED)):(peg$currPos=s,s=peg$FAILED),peg$resultsCache[o]={nextPos:peg$currPos,result:s},s)}function peg$parseoperation(){var s,e,r,n,o,a,l,c=peg$currPos*17+14,h=peg$resultsCache[c];if(h)return peg$currPos=h.nextPos,h.result;if(s=peg$currPos,e=peg$parsevalue(),e===peg$FAILED&&(e=peg$parseratio(),e===peg$FAILED&&(e=peg$parsemonzo(),e===peg$FAILED)))for(e=[],r=peg$parsesep();r!==peg$FAILED;)e.push(r),r=peg$parsesep();if(e!==peg$FAILED){if(r=[],n=peg$currPos,o=peg$parseoperator(),o!==peg$FAILED){if(a=peg$parsevalue(),a===peg$FAILED&&(a=peg$parseratio(),a===peg$FAILED&&(a=peg$parsemonzo(),a===peg$FAILED&&(a=peg$parsesub_operations(),a===peg$FAILED&&(a=peg$parseoperation(),a===peg$FAILED)))))for(a=[],l=peg$parsesep();l!==peg$FAILED;)a.push(l),l=peg$parsesep();a!==peg$FAILED?(o=[o,a],n=o):(peg$currPos=n,n=peg$FAILED)}else peg$currPos=n,n=peg$FAILED;if(n!==peg$FAILED)for(;n!==peg$FAILED;)if(r.push(n),n=peg$currPos,o=peg$parseoperator(),o!==peg$FAILED){if(a=peg$parsevalue(),a===peg$FAILED&&(a=peg$parseratio(),a===peg$FAILED&&(a=peg$parsemonzo(),a===peg$FAILED&&(a=peg$parsesub_operations(),a===peg$FAILED&&(a=peg$parseoperation(),a===peg$FAILED)))))for(a=[],l=peg$parsesep();l!==peg$FAILED;)a.push(l),l=peg$parsesep();a!==peg$FAILED?(o=[o,a],n=o):(peg$currPos=n,n=peg$FAILED)}else peg$currPos=n,n=peg$FAILED;else r=peg$FAILED;r!==peg$FAILED?(peg$savedPos=s,s=peg$f13()):(peg$currPos=s,s=peg$FAILED)}else peg$currPos=s,s=peg$FAILED;return peg$resultsCache[c]={nextPos:peg$currPos,result:s},s}function peg$parseoperator(){var s,e=peg$currPos*17+15,r=peg$resultsCache[e];return r?(peg$currPos=r.nextPos,r.result):(input.charCodeAt(peg$currPos)===43?(s=peg$c10,peg$currPos++):(s=peg$FAILED,peg$fail(peg$e12)),s===peg$FAILED&&(input.charCodeAt(peg$currPos)===45?(s=peg$c4,peg$currPos++):(s=peg$FAILED,peg$fail(peg$e6)),s===peg$FAILED&&(input.charCodeAt(peg$currPos)===42?(s=peg$c11,peg$currPos++):(s=peg$FAILED,peg$fail(peg$e13)),s===peg$FAILED&&(input.charCodeAt(peg$currPos)===37?(s=peg$c12,peg$currPos++):(s=peg$FAILED,peg$fail(peg$e14)),s===peg$FAILED&&(input.charCodeAt(peg$currPos)===38?(s=peg$c13,peg$currPos++):(s=peg$FAILED,peg$fail(peg$e15)),s===peg$FAILED&&(input.charCodeAt(peg$currPos)===124?(s=peg$c14,peg$currPos++):(s=peg$FAILED,peg$fail(peg$e16)),s===peg$FAILED&&(input.substr(peg$currPos,2)===peg$c15?(s=peg$c15,peg$currPos+=2):(s=peg$FAILED,peg$fail(peg$e17)),s===peg$FAILED&&(input.substr(peg$currPos,2)===peg$c16?(s=peg$c16,peg$currPos+=2):(s=peg$FAILED,peg$fail(peg$e18))))))))),peg$resultsCache[e]={nextPos:peg$currPos,result:s},s)}function peg$parsesub_operations(){var s,e,r,n,o=peg$currPos*17+16,a=peg$resultsCache[o];return a?(peg$currPos=a.nextPos,a.result):(s=peg$currPos,input.charCodeAt(peg$currPos)===40?(e=peg$c0,peg$currPos++):(e=peg$FAILED,peg$fail(peg$e1)),e!==peg$FAILED?(r=peg$parseoperation(),r!==peg$FAILED?(input.charCodeAt(peg$currPos)===41?(n=peg$c2,peg$currPos++):(n=peg$FAILED,peg$fail(peg$e3)),n!==peg$FAILED?(e=[e,r,n],s=e):(peg$currPos=s,s=peg$FAILED)):(peg$currPos=s,s=peg$FAILED)):(peg$currPos=s,s=peg$FAILED),peg$resultsCache[o]={nextPos:peg$currPos,result:s},s)}if(peg$result=peg$startRuleFunction(),peg$result!==peg$FAILED&&peg$currPos===input.length)return peg$result;throw peg$result!==peg$FAILED&&peg$currPos{typeof PROCESS.emitWarning=="function"?PROCESS.emitWarning(s,e,r,n):console.error(`[${r}] ${e}: ${s}`)};let AC=globalThis.AbortController,AS=globalThis.AbortSignal;var Sn;if(typeof AC>"u"){AS=class{constructor(){$e(this,"onabort");$e(this,"_onabort",[]);$e(this,"reason");$e(this,"aborted",!1)}addEventListener(n,o){this._onabort.push(o)}},AC=class{constructor(){$e(this,"signal",new AS);e()}abort(n){var o,a;if(!this.signal.aborted){this.signal.reason=n,this.signal.aborted=!0;for(const l of this.signal._onabort)l(n);(a=(o=this.signal).onabort)==null||a.call(o,n)}}};let s=((Sn=PROCESS.env)==null?void 0:Sn.LRU_CACHE_IGNORE_AC_WARNING)!=="1";const e=()=>{s&&(s=!1,emitWarning("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 shouldWarn=s=>!warned.has(s),isPosInt=s=>s&&s===Math.floor(s)&&s>0&&isFinite(s),getUintArray=s=>isPosInt(s)?s<=Math.pow(2,8)?Uint8Array:s<=Math.pow(2,16)?Uint16Array:s<=Math.pow(2,32)?Uint32Array:s<=Number.MAX_SAFE_INTEGER?ZeroArray:null:null;class ZeroArray extends Array{constructor(e){super(e),this.fill(0)}}var Vi;const Ti=class Ti{constructor(e,r){$e(this,"heap");$e(this,"length");if(!B(Ti,Vi))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new r(e),this.length=0}static create(e){const r=getUintArray(e);if(!r)return[];ze(Ti,Vi,!0);const n=new Ti(e,r);return ze(Ti,Vi,!1),n}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}};Vi=new WeakMap,lt(Ti,Vi,!1);let Stack=Ti;var ti,Ut,ii,ri,_i,At,ni,Pt,vt,nt,Zt,zt,Bt,Mt,si,Et,fi,di,oi,ai,xi,Vt,or,Kr,Li,pi,ar,jt,Lr,vn,Qi,Gi,lr,ci,Ii,hi,wi,cr,Jr,Hi,Pr,Wi,Tr,St,Ct,hr,en,Ri,nr;const tn=class tn{constructor(e){lt(this,or);lt(this,Lr);lt(this,ci);lt(this,hi);lt(this,cr);lt(this,Hi);lt(this,Wi);lt(this,St);lt(this,hr);lt(this,Ri);lt(this,ti,void 0);lt(this,Ut,void 0);lt(this,ii,void 0);lt(this,ri,void 0);lt(this,_i,void 0);$e(this,"ttl");$e(this,"ttlResolution");$e(this,"ttlAutopurge");$e(this,"updateAgeOnGet");$e(this,"updateAgeOnHas");$e(this,"allowStale");$e(this,"noDisposeOnSet");$e(this,"noUpdateTTL");$e(this,"maxEntrySize");$e(this,"sizeCalculation");$e(this,"noDeleteOnFetchRejection");$e(this,"noDeleteOnStaleGet");$e(this,"allowStaleOnFetchAbort");$e(this,"allowStaleOnFetchRejection");$e(this,"ignoreFetchAbort");lt(this,At,void 0);lt(this,ni,void 0);lt(this,Pt,void 0);lt(this,vt,void 0);lt(this,nt,void 0);lt(this,Zt,void 0);lt(this,zt,void 0);lt(this,Bt,void 0);lt(this,Mt,void 0);lt(this,si,void 0);lt(this,Et,void 0);lt(this,fi,void 0);lt(this,di,void 0);lt(this,oi,void 0);lt(this,ai,void 0);lt(this,xi,void 0);lt(this,Vt,void 0);lt(this,Li,()=>{});lt(this,pi,()=>{});lt(this,ar,()=>{});lt(this,jt,()=>!1);lt(this,Qi,e=>{});lt(this,Gi,(e,r,n)=>{});lt(this,lr,(e,r,n,o)=>{if(n||o)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});const{max:r=0,ttl:n,ttlResolution:o=1,ttlAutopurge:a,updateAgeOnGet:l,updateAgeOnHas:c,allowStale:h,dispose:f,disposeAfter:d,noDisposeOnSet:g,noUpdateTTL:y,maxSize:I=0,maxEntrySize:P=0,sizeCalculation:N,fetchMethod:Y,noDeleteOnFetchRejection:H,noDeleteOnStaleGet:Se,allowStaleOnFetchRejection:Re,allowStaleOnFetchAbort:oe,ignoreFetchAbort:ke}=e;if(r!==0&&!isPosInt(r))throw new TypeError("max option must be a nonnegative integer");const Te=r?getUintArray(r):Array;if(!Te)throw new Error("invalid max value: "+r);if(ze(this,ti,r),ze(this,Ut,I),this.maxEntrySize=P||B(this,Ut),this.sizeCalculation=N,this.sizeCalculation){if(!B(this,Ut)&&!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(Y!==void 0&&typeof Y!="function")throw new TypeError("fetchMethod must be a function if specified");if(ze(this,_i,Y),ze(this,xi,!!Y),ze(this,Pt,new Map),ze(this,vt,new Array(r).fill(void 0)),ze(this,nt,new Array(r).fill(void 0)),ze(this,Zt,new Te(r)),ze(this,zt,new Te(r)),ze(this,Bt,0),ze(this,Mt,0),ze(this,si,Stack.create(r)),ze(this,At,0),ze(this,ni,0),typeof f=="function"&&ze(this,ii,f),typeof d=="function"?(ze(this,ri,d),ze(this,Et,[])):(ze(this,ri,void 0),ze(this,Et,void 0)),ze(this,ai,!!B(this,ii)),ze(this,Vt,!!B(this,ri)),this.noDisposeOnSet=!!g,this.noUpdateTTL=!!y,this.noDeleteOnFetchRejection=!!H,this.allowStaleOnFetchRejection=!!Re,this.allowStaleOnFetchAbort=!!oe,this.ignoreFetchAbort=!!ke,this.maxEntrySize!==0){if(B(this,Ut)!==0&&!isPosInt(B(this,Ut)))throw new TypeError("maxSize must be a positive integer if specified");if(!isPosInt(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");We(this,Lr,vn).call(this)}if(this.allowStale=!!h,this.noDeleteOnStaleGet=!!Se,this.updateAgeOnGet=!!l,this.updateAgeOnHas=!!c,this.ttlResolution=isPosInt(o)||o===0?o:1,this.ttlAutopurge=!!a,this.ttl=n||0,this.ttl){if(!isPosInt(this.ttl))throw new TypeError("ttl must be a positive integer if specified");We(this,or,Kr).call(this)}if(B(this,ti)===0&&this.ttl===0&&B(this,Ut)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!B(this,ti)&&!B(this,Ut)){const Qe="LRU_CACHE_UNBOUNDED";shouldWarn(Qe)&&(warned.add(Qe),emitWarning("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Qe,tn))}}static unsafeExposeInternals(e){return{starts:B(e,di),ttls:B(e,oi),sizes:B(e,fi),keyMap:B(e,Pt),keyList:B(e,vt),valList:B(e,nt),next:B(e,Zt),prev:B(e,zt),get head(){return B(e,Bt)},get tail(){return B(e,Mt)},free:B(e,si),isBackgroundFetch:r=>{var n;return We(n=e,St,Ct).call(n,r)},backgroundFetch:(r,n,o,a)=>{var l;return We(l=e,Wi,Tr).call(l,r,n,o,a)},moveToTail:r=>{var n;return We(n=e,Ri,nr).call(n,r)},indexes:r=>{var n;return We(n=e,ci,Ii).call(n,r)},rindexes:r=>{var n;return We(n=e,hi,wi).call(n,r)},isStale:r=>{var n;return B(n=e,jt).call(n,r)}}}get max(){return B(this,ti)}get maxSize(){return B(this,Ut)}get calculatedSize(){return B(this,ni)}get size(){return B(this,At)}get fetchMethod(){return B(this,_i)}get dispose(){return B(this,ii)}get disposeAfter(){return B(this,ri)}getRemainingTTL(e){return B(this,Pt).has(e)?1/0:0}*entries(){for(const e of We(this,ci,Ii).call(this))B(this,nt)[e]!==void 0&&B(this,vt)[e]!==void 0&&!We(this,St,Ct).call(this,B(this,nt)[e])&&(yield[B(this,vt)[e],B(this,nt)[e]])}*rentries(){for(const e of We(this,hi,wi).call(this))B(this,nt)[e]!==void 0&&B(this,vt)[e]!==void 0&&!We(this,St,Ct).call(this,B(this,nt)[e])&&(yield[B(this,vt)[e],B(this,nt)[e]])}*keys(){for(const e of We(this,ci,Ii).call(this)){const r=B(this,vt)[e];r!==void 0&&!We(this,St,Ct).call(this,B(this,nt)[e])&&(yield r)}}*rkeys(){for(const e of We(this,hi,wi).call(this)){const r=B(this,vt)[e];r!==void 0&&!We(this,St,Ct).call(this,B(this,nt)[e])&&(yield r)}}*values(){for(const e of We(this,ci,Ii).call(this))B(this,nt)[e]!==void 0&&!We(this,St,Ct).call(this,B(this,nt)[e])&&(yield B(this,nt)[e])}*rvalues(){for(const e of We(this,hi,wi).call(this))B(this,nt)[e]!==void 0&&!We(this,St,Ct).call(this,B(this,nt)[e])&&(yield B(this,nt)[e])}[Symbol.iterator](){return this.entries()}find(e,r={}){for(const n of We(this,ci,Ii).call(this)){const o=B(this,nt)[n],a=We(this,St,Ct).call(this,o)?o.__staleWhileFetching:o;if(a!==void 0&&e(a,B(this,vt)[n],this))return this.get(B(this,vt)[n],r)}}forEach(e,r=this){for(const n of We(this,ci,Ii).call(this)){const o=B(this,nt)[n],a=We(this,St,Ct).call(this,o)?o.__staleWhileFetching:o;a!==void 0&&e.call(r,a,B(this,vt)[n],this)}}rforEach(e,r=this){for(const n of We(this,hi,wi).call(this)){const o=B(this,nt)[n],a=We(this,St,Ct).call(this,o)?o.__staleWhileFetching:o;a!==void 0&&e.call(r,a,B(this,vt)[n],this)}}purgeStale(){let e=!1;for(const r of We(this,hi,wi).call(this,{allowStale:!0}))B(this,jt).call(this,r)&&(this.delete(B(this,vt)[r]),e=!0);return e}dump(){const e=[];for(const r of We(this,ci,Ii).call(this,{allowStale:!0})){const n=B(this,vt)[r],o=B(this,nt)[r],a=We(this,St,Ct).call(this,o)?o.__staleWhileFetching:o;if(a===void 0||n===void 0)continue;const l={value:a};if(B(this,oi)&&B(this,di)){l.ttl=B(this,oi)[r];const c=perf.now()-B(this,di)[r];l.start=Math.floor(Date.now()-c)}B(this,fi)&&(l.size=B(this,fi)[r]),e.unshift([n,l])}return e}load(e){this.clear();for(const[r,n]of e){if(n.start){const o=Date.now()-n.start;n.start=perf.now()-o}this.set(r,n.value,n)}}set(e,r,n={}){var y,I,P,N,Y;if(r===void 0)return this.delete(e),this;const{ttl:o=this.ttl,start:a,noDisposeOnSet:l=this.noDisposeOnSet,sizeCalculation:c=this.sizeCalculation,status:h}=n;let{noUpdateTTL:f=this.noUpdateTTL}=n;const d=B(this,lr).call(this,e,r,n.size||0,c);if(this.maxEntrySize&&d>this.maxEntrySize)return h&&(h.set="miss",h.maxEntrySizeExceeded=!0),this.delete(e),this;let g=B(this,At)===0?void 0:B(this,Pt).get(e);if(g===void 0)g=B(this,At)===0?B(this,Mt):B(this,si).length!==0?B(this,si).pop():B(this,At)===B(this,ti)?We(this,Hi,Pr).call(this,!1):B(this,At),B(this,vt)[g]=e,B(this,nt)[g]=r,B(this,Pt).set(e,g),B(this,Zt)[B(this,Mt)]=g,B(this,zt)[g]=B(this,Mt),ze(this,Mt,g),Ar(this,At)._++,B(this,Gi).call(this,g,d,h),h&&(h.set="add"),f=!1;else{We(this,Ri,nr).call(this,g);const H=B(this,nt)[g];if(r!==H){if(B(this,xi)&&We(this,St,Ct).call(this,H)){H.__abortController.abort(new Error("replaced"));const{__staleWhileFetching:Se}=H;Se!==void 0&&!l&&(B(this,ai)&&((y=B(this,ii))==null||y.call(this,Se,e,"set")),B(this,Vt)&&((I=B(this,Et))==null||I.push([Se,e,"set"])))}else l||(B(this,ai)&&((P=B(this,ii))==null||P.call(this,H,e,"set")),B(this,Vt)&&((N=B(this,Et))==null||N.push([H,e,"set"])));if(B(this,Qi).call(this,g),B(this,Gi).call(this,g,d,h),B(this,nt)[g]=r,h){h.set="replace";const Se=H&&We(this,St,Ct).call(this,H)?H.__staleWhileFetching:H;Se!==void 0&&(h.oldValue=Se)}}else h&&(h.set="update")}if(o!==0&&!B(this,oi)&&We(this,or,Kr).call(this),B(this,oi)&&(f||B(this,ar).call(this,g,o,a),h&&B(this,pi).call(this,h,g)),!l&&B(this,Vt)&&B(this,Et)){const H=B(this,Et);let Se;for(;Se=H==null?void 0:H.shift();)(Y=B(this,ri))==null||Y.call(this,...Se)}return this}pop(){var e;try{for(;B(this,At);){const r=B(this,nt)[B(this,Bt)];if(We(this,Hi,Pr).call(this,!0),We(this,St,Ct).call(this,r)){if(r.__staleWhileFetching)return r.__staleWhileFetching}else if(r!==void 0)return r}}finally{if(B(this,Vt)&&B(this,Et)){const r=B(this,Et);let n;for(;n=r==null?void 0:r.shift();)(e=B(this,ri))==null||e.call(this,...n)}}}has(e,r={}){const{updateAgeOnHas:n=this.updateAgeOnHas,status:o}=r,a=B(this,Pt).get(e);if(a!==void 0){const l=B(this,nt)[a];if(We(this,St,Ct).call(this,l)&&l.__staleWhileFetching===void 0)return!1;if(B(this,jt).call(this,a))o&&(o.has="stale",B(this,pi).call(this,o,a));else return n&&B(this,Li).call(this,a),o&&(o.has="hit",B(this,pi).call(this,o,a)),!0}else o&&(o.has="miss");return!1}peek(e,r={}){const{allowStale:n=this.allowStale}=r,o=B(this,Pt).get(e);if(o!==void 0&&(n||!B(this,jt).call(this,o))){const a=B(this,nt)[o];return We(this,St,Ct).call(this,a)?a.__staleWhileFetching:a}}async fetch(e,r={}){const{allowStale:n=this.allowStale,updateAgeOnGet:o=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,ttl:l=this.ttl,noDisposeOnSet:c=this.noDisposeOnSet,size:h=0,sizeCalculation:f=this.sizeCalculation,noUpdateTTL:d=this.noUpdateTTL,noDeleteOnFetchRejection:g=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:y=this.allowStaleOnFetchRejection,ignoreFetchAbort:I=this.ignoreFetchAbort,allowStaleOnFetchAbort:P=this.allowStaleOnFetchAbort,context:N,forceRefresh:Y=!1,status:H,signal:Se}=r;if(!B(this,xi))return H&&(H.fetch="get"),this.get(e,{allowStale:n,updateAgeOnGet:o,noDeleteOnStaleGet:a,status:H});const Re={allowStale:n,updateAgeOnGet:o,noDeleteOnStaleGet:a,ttl:l,noDisposeOnSet:c,size:h,sizeCalculation:f,noUpdateTTL:d,noDeleteOnFetchRejection:g,allowStaleOnFetchRejection:y,allowStaleOnFetchAbort:P,ignoreFetchAbort:I,status:H,signal:Se};let oe=B(this,Pt).get(e);if(oe===void 0){H&&(H.fetch="miss");const ke=We(this,Wi,Tr).call(this,e,oe,Re,N);return ke.__returned=ke}else{const ke=B(this,nt)[oe];if(We(this,St,Ct).call(this,ke)){const De=n&&ke.__staleWhileFetching!==void 0;return H&&(H.fetch="inflight",De&&(H.returnedStale=!0)),De?ke.__staleWhileFetching:ke.__returned=ke}const Te=B(this,jt).call(this,oe);if(!Y&&!Te)return H&&(H.fetch="hit"),We(this,Ri,nr).call(this,oe),o&&B(this,Li).call(this,oe),H&&B(this,pi).call(this,H,oe),ke;const Qe=We(this,Wi,Tr).call(this,e,oe,Re,N),Ze=Qe.__staleWhileFetching!==void 0&&n;return H&&(H.fetch=Te?"stale":"refresh",Ze&&Te&&(H.returnedStale=!0)),Ze?Qe.__staleWhileFetching:Qe.__returned=Qe}}get(e,r={}){const{allowStale:n=this.allowStale,updateAgeOnGet:o=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,status:l}=r,c=B(this,Pt).get(e);if(c!==void 0){const h=B(this,nt)[c],f=We(this,St,Ct).call(this,h);return l&&B(this,pi).call(this,l,c),B(this,jt).call(this,c)?(l&&(l.get="stale"),f?(l&&n&&h.__staleWhileFetching!==void 0&&(l.returnedStale=!0),n?h.__staleWhileFetching:void 0):(a||this.delete(e),l&&n&&(l.returnedStale=!0),n?h:void 0)):(l&&(l.get="hit"),f?h.__staleWhileFetching:(We(this,Ri,nr).call(this,c),o&&B(this,Li).call(this,c),h))}else l&&(l.get="miss")}delete(e){var n,o,a,l;let r=!1;if(B(this,At)!==0){const c=B(this,Pt).get(e);if(c!==void 0)if(r=!0,B(this,At)===1)this.clear();else{B(this,Qi).call(this,c);const h=B(this,nt)[c];We(this,St,Ct).call(this,h)?h.__abortController.abort(new Error("deleted")):(B(this,ai)||B(this,Vt))&&(B(this,ai)&&((n=B(this,ii))==null||n.call(this,h,e,"delete")),B(this,Vt)&&((o=B(this,Et))==null||o.push([h,e,"delete"]))),B(this,Pt).delete(e),B(this,vt)[c]=void 0,B(this,nt)[c]=void 0,c===B(this,Mt)?ze(this,Mt,B(this,zt)[c]):c===B(this,Bt)?ze(this,Bt,B(this,Zt)[c]):(B(this,Zt)[B(this,zt)[c]]=B(this,Zt)[c],B(this,zt)[B(this,Zt)[c]]=B(this,zt)[c]),Ar(this,At)._--,B(this,si).push(c)}}if(B(this,Vt)&&((a=B(this,Et))!=null&&a.length)){const c=B(this,Et);let h;for(;h=c==null?void 0:c.shift();)(l=B(this,ri))==null||l.call(this,...h)}return r}clear(){var e,r,n;for(const o of We(this,hi,wi).call(this,{allowStale:!0})){const a=B(this,nt)[o];if(We(this,St,Ct).call(this,a))a.__abortController.abort(new Error("deleted"));else{const l=B(this,vt)[o];B(this,ai)&&((e=B(this,ii))==null||e.call(this,a,l,"delete")),B(this,Vt)&&((r=B(this,Et))==null||r.push([a,l,"delete"]))}}if(B(this,Pt).clear(),B(this,nt).fill(void 0),B(this,vt).fill(void 0),B(this,oi)&&B(this,di)&&(B(this,oi).fill(0),B(this,di).fill(0)),B(this,fi)&&B(this,fi).fill(0),ze(this,Bt,0),ze(this,Mt,0),B(this,si).length=0,ze(this,ni,0),ze(this,At,0),B(this,Vt)&&B(this,Et)){const o=B(this,Et);let a;for(;a=o==null?void 0:o.shift();)(n=B(this,ri))==null||n.call(this,...a)}}};ti=new WeakMap,Ut=new WeakMap,ii=new WeakMap,ri=new WeakMap,_i=new WeakMap,At=new WeakMap,ni=new WeakMap,Pt=new WeakMap,vt=new WeakMap,nt=new WeakMap,Zt=new WeakMap,zt=new WeakMap,Bt=new WeakMap,Mt=new WeakMap,si=new WeakMap,Et=new WeakMap,fi=new WeakMap,di=new WeakMap,oi=new WeakMap,ai=new WeakMap,xi=new WeakMap,Vt=new WeakMap,or=new WeakSet,Kr=function(){const e=new ZeroArray(B(this,ti)),r=new ZeroArray(B(this,ti));ze(this,oi,e),ze(this,di,r),ze(this,ar,(a,l,c=perf.now())=>{if(r[a]=l!==0?c:0,e[a]=l,l!==0&&this.ttlAutopurge){const h=setTimeout(()=>{B(this,jt).call(this,a)&&this.delete(B(this,vt)[a])},l+1);h.unref&&h.unref()}}),ze(this,Li,a=>{r[a]=e[a]!==0?perf.now():0}),ze(this,pi,(a,l)=>{if(e[l]){const c=e[l],h=r[l];a.ttl=c,a.start=h,a.now=n||o();const f=a.now-h;a.remainingTTL=c-f}});let n=0;const o=()=>{const a=perf.now();if(this.ttlResolution>0){n=a;const l=setTimeout(()=>n=0,this.ttlResolution);l.unref&&l.unref()}return a};this.getRemainingTTL=a=>{const l=B(this,Pt).get(a);if(l===void 0)return 0;const c=e[l],h=r[l];if(c===0||h===0)return 1/0;const f=(n||o())-h;return c-f},ze(this,jt,a=>e[a]!==0&&r[a]!==0&&(n||o())-r[a]>e[a])},Li=new WeakMap,pi=new WeakMap,ar=new WeakMap,jt=new WeakMap,Lr=new WeakSet,vn=function(){const e=new ZeroArray(B(this,ti));ze(this,ni,0),ze(this,fi,e),ze(this,Qi,r=>{ze(this,ni,B(this,ni)-e[r]),e[r]=0}),ze(this,lr,(r,n,o,a)=>{if(We(this,St,Ct).call(this,n))return 0;if(!isPosInt(o))if(a){if(typeof a!="function")throw new TypeError("sizeCalculation must be a function");if(o=a(n,r),!isPosInt(o))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 o}),ze(this,Gi,(r,n,o)=>{if(e[r]=n,B(this,Ut)){const a=B(this,Ut)-e[r];for(;B(this,ni)>a;)We(this,Hi,Pr).call(this,!0)}ze(this,ni,B(this,ni)+e[r]),o&&(o.entrySize=n,o.totalCalculatedSize=B(this,ni))})},Qi=new WeakMap,Gi=new WeakMap,lr=new WeakMap,ci=new WeakSet,Ii=function*({allowStale:e=this.allowStale}={}){if(B(this,At))for(let r=B(this,Mt);!(!We(this,cr,Jr).call(this,r)||((e||!B(this,jt).call(this,r))&&(yield r),r===B(this,Bt)));)r=B(this,zt)[r]},hi=new WeakSet,wi=function*({allowStale:e=this.allowStale}={}){if(B(this,At))for(let r=B(this,Bt);!(!We(this,cr,Jr).call(this,r)||((e||!B(this,jt).call(this,r))&&(yield r),r===B(this,Mt)));)r=B(this,Zt)[r]},cr=new WeakSet,Jr=function(e){return e!==void 0&&B(this,Pt).get(B(this,vt)[e])===e},Hi=new WeakSet,Pr=function(e){var a,l;const r=B(this,Bt),n=B(this,vt)[r],o=B(this,nt)[r];return B(this,xi)&&We(this,St,Ct).call(this,o)?o.__abortController.abort(new Error("evicted")):(B(this,ai)||B(this,Vt))&&(B(this,ai)&&((a=B(this,ii))==null||a.call(this,o,n,"evict")),B(this,Vt)&&((l=B(this,Et))==null||l.push([o,n,"evict"]))),B(this,Qi).call(this,r),e&&(B(this,vt)[r]=void 0,B(this,nt)[r]=void 0,B(this,si).push(r)),B(this,At)===1?(ze(this,Bt,ze(this,Mt,0)),B(this,si).length=0):ze(this,Bt,B(this,Zt)[r]),B(this,Pt).delete(n),Ar(this,At)._--,r},Wi=new WeakSet,Tr=function(e,r,n,o){const a=r===void 0?void 0:B(this,nt)[r];if(We(this,St,Ct).call(this,a))return a;const l=new AC,{signal:c}=n;c==null||c.addEventListener("abort",()=>l.abort(c.reason),{signal:l.signal});const h={signal:l.signal,options:n,context:o},f=(N,Y=!1)=>{const{aborted:H}=l.signal,Se=n.ignoreFetchAbort&&N!==void 0;if(n.status&&(H&&!Y?(n.status.fetchAborted=!0,n.status.fetchError=l.signal.reason,Se&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),H&&!Se&&!Y)return g(l.signal.reason);const Re=I;return B(this,nt)[r]===I&&(N===void 0?Re.__staleWhileFetching?B(this,nt)[r]=Re.__staleWhileFetching:this.delete(e):(n.status&&(n.status.fetchUpdated=!0),this.set(e,N,h.options))),N},d=N=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=N),g(N)),g=N=>{const{aborted:Y}=l.signal,H=Y&&n.allowStaleOnFetchAbort,Se=H||n.allowStaleOnFetchRejection,Re=Se||n.noDeleteOnFetchRejection,oe=I;if(B(this,nt)[r]===I&&(!Re||oe.__staleWhileFetching===void 0?this.delete(e):H||(B(this,nt)[r]=oe.__staleWhileFetching)),Se)return n.status&&oe.__staleWhileFetching!==void 0&&(n.status.returnedStale=!0),oe.__staleWhileFetching;if(oe.__returned===oe)throw N},y=(N,Y)=>{var Se;const H=(Se=B(this,_i))==null?void 0:Se.call(this,e,a,h);H&&H instanceof Promise&&H.then(Re=>N(Re===void 0?void 0:Re),Y),l.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(N(void 0),n.allowStaleOnFetchAbort&&(N=Re=>f(Re,!0)))})};n.status&&(n.status.fetchDispatched=!0);const I=new Promise(y).then(f,d),P=Object.assign(I,{__abortController:l,__staleWhileFetching:a,__returned:void 0});return r===void 0?(this.set(e,P,{...h.options,status:void 0}),r=B(this,Pt).get(e)):B(this,nt)[r]=P,P},St=new WeakSet,Ct=function(e){if(!B(this,xi))return!1;const r=e;return!!r&&r instanceof Promise&&r.hasOwnProperty("__staleWhileFetching")&&r.__abortController instanceof AC},hr=new WeakSet,en=function(e,r){B(this,zt)[r]=e,B(this,Zt)[e]=r},Ri=new WeakSet,nr=function(e){e!==B(this,Mt)&&(e===B(this,Bt)?ze(this,Bt,B(this,Zt)[e]):We(this,hr,en).call(this,B(this,zt)[e],B(this,Zt)[e]),We(this,hr,en).call(this,B(this,Mt),e),ze(this,Mt,e))};let LRUCache=tn;const zcache=new LRUCache({max:1e3,ttl:1e3*60*5});class Ziffers{constructor(e,r={}){$e(this,"values");$e(this,"evaluated");$e(this,"options");$e(this,"index");$e(this,"redo");this.index=0,r={...DEFAULT_OPTIONS,...r},r.scale&&(typeof r.scale=="string"&&(isScale(r.scale)?(r.scaleName=r.scale,r.scale=getScale(r.scale)):r.scale=parse(r.scale)),r.parsedScale=r.scale,delete r.scale),r.redo!==void 0?this.redo=r.redo:this.redo=1,this.options={nodeOptions:r};try{this.values=parse$1(e,this.options),this.evaluated=this.evaluate()}catch(n){console.log(n),this.values=[],this.evaluated=[]}}update(){this.evaluated=this.evaluate()}pitches(){return this.evaluated.map(e=>e.collect("pitch"))}notes(){return this.evaluated.map(e=>e.collect("note"))}freqs(){return this.evaluated.map(e=>e.collect("freq"))}durations(){return this.evaluated.map(e=>e.collect("duration"))}next(){const e=this.evaluated[this.index%this.evaluated.length];return this.index++,this.redo>0&&this.index>=this.evaluated.length*this.redo&&(this.index=0,this.update()),e}evaluate(){return this.values.map(e=>e.evaluate()).flat(1/0).filter(e=>e!==void 0)}}const generateCacheKey=(...s)=>s.map(e=>JSON.stringify(e)).join(","),cachedCall=(s,e)=>{const r=generateCacheKey(s,e);if(zcache.has(r))return zcache.get(r);{const n=new Ziffers(s,e);return zcache.set(r,n),n}},next=(s,e={})=>cachedCall(s,e).next();let listenerQueue=[],atom=(s,e)=>{let r,n=[],o={lc:0,l:e||0,value:s,set(a){o.value=a,o.notify()},get(){return o.lc||o.listen(()=>{})(),o.value},notify(a){r=n;let l=!listenerQueue.length;for(let c=0;c{n===r&&(n=n.slice());let c=n.indexOf(a);~c&&(n.splice(c,2),o.lc--,o.lc||o.off())}},subscribe(a,l){let c=o.listen(a,l);return a(o.value),c},off(){}};return o},map=(s={})=>{let e=atom(s);return e.setKey=function(r,n){typeof n>"u"?r in e.value&&(e.value={...e.value},delete e.value[r],e.notify(r)):e.value[r]!==n&&(e.value={...e.value,[r]:n},e.notify(r))},e};if(typeof DelayNode<"u"){class s extends DelayNode{constructor(r,n,o,a){super(r),n=Math.abs(n),this.delayTime.value=o;const l=r.createGain();l.gain.value=Math.min(Math.abs(a),.995),this.feedback=l.gain;const c=r.createGain();return c.gain.value=n,this.delayGain=c,this.connect(l),this.connect(c),l.connect(this),this.connect=h=>c.connect(h),this}start(r){this.delayGain.gain.setValueAtTime(this.delayGain.gain.value,r+this.delayTime.value)}}AudioContext.prototype.createFeedbackDelay=function(e,r,n){return new s(this,e,r,n)}}typeof AudioContext<"u"&&(AudioContext.prototype.impulseResponse=function(s,e=1){const r=this.sampleRate*s,n=this.createBuffer(e,r,this.sampleRate),o=n.getChannelData(0);for(let a=0;a(e.buffer=this.impulseResponse(r),e.duration=s,e),e.setDuration(s),e});var q={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 s extends GainNode{constructor(r,n){if(super(r),!q[n])throw new Error("vowel: unknown vowel "+n);const{gains:o,qs:a,freqs:l}=q[n],c=r.createGain();for(let h=0;h<5;h++){const f=r.createGain();f.gain.value=o[h];const d=r.createBiquadFilter();d.type="bandpass",d.Q.value=a[h],d.frequency.value=l[h],this.connect(d),d.connect(f),f.connect(c)}return c.gain.value=8,this.connect=h=>c.connect(h),this}}AudioContext.prototype.createVowelFilter=function(e){return new s(this,e)}}const ce=s=>{var o;if(typeof s!="string")return[];const[e,r="",n]=((o=s.match(/^([a-gA-G])([#bsf]*)([0-9]*)$/))==null?void 0:o.slice(1))||[];return e?[e,r,n?Number(n):void 0]:[]},re={c:0,d:2,e:4,f:5,g:7,a:9,b:11},ie={"#":1,b:-1,s:1,f:-1},L=(s,e=3)=>{const[r,n,o=e]=ce(s);if(!r)throw new Error('not a note: "'+s+'"');const a=re[r.toLowerCase()],l=(n==null?void 0:n.split("").reduce((c,h)=>c+ie[h],0))||0;return(Number(o)+1)*12+a+l},se=s=>Math.pow(2,(s-69)/12)*440,ae=(s,e,r)=>Math.min(Math.max(s,e),r),ge=s=>12*Math.log(s/440)/Math.LN2+69,de=(s,e)=>{if(typeof s!="object")throw new Error("valueToMidi: expected object value");let{freq:r,note:n}=s;if(typeof r=="number")return ge(r);if(typeof n=="string")return L(n);if(typeof n=="number")return n;if(!e)throw new Error("valueToMidi: expected freq or note to be set");return e},ue="data:application/javascript;base64,Ly8gTElDRU5TRSBHTlUgR2VuZXJhbCBQdWJsaWMgTGljZW5zZSB2My4wIHNlZSBodHRwczovL2dpdGh1Yi5jb20vZGt0cjAvV2ViRGlydC9ibG9iL21haW4vTElDRU5TRQovLyBhbGwgdGhlIGNyZWRpdCBnb2VzIHRvIGRrdHIwJ3Mgd2ViZGlydDogaHR0cHM6Ly9naXRodWIuY29tL2RrdHIwL1dlYkRpcnQvYmxvYi81Y2UzZDY5ODM2MmM1NGQ2ZTFiNjhhY2M0N2ViMjk1NWFjNjJjNzkzL2Rpc3QvQXVkaW9Xb3JrbGV0cy5qcwovLyA8MwoKY2xhc3MgQ29hcnNlUHJvY2Vzc29yIGV4dGVuZHMgQXVkaW9Xb3JrbGV0UHJvY2Vzc29yIHsKICBzdGF0aWMgZ2V0IHBhcmFtZXRlckRlc2NyaXB0b3JzKCkgewogICAgcmV0dXJuIFt7IG5hbWU6ICdjb2Fyc2UnLCBkZWZhdWx0VmFsdWU6IDEgfV07CiAgfQoKICBjb25zdHJ1Y3RvcigpIHsKICAgIHN1cGVyKCk7CiAgICB0aGlzLm5vdFN0YXJ0ZWQgPSB0cnVlOwogIH0KCiAgcHJvY2VzcyhpbnB1dHMsIG91dHB1dHMsIHBhcmFtZXRlcnMpIHsKICAgIGNvbnN0IGlucHV0ID0gaW5wdXRzWzBdOwogICAgY29uc3Qgb3V0cHV0ID0gb3V0cHV0c1swXTsKICAgIGNvbnN0IGNvYXJzZSA9IHBhcmFtZXRlcnMuY29hcnNlOwogICAgY29uc3QgYmxvY2tTaXplID0gMTI4OwogICAgY29uc3QgaGFzSW5wdXQgPSAhKGlucHV0WzBdID09PSB1bmRlZmluZWQpOwogICAgaWYgKGhhc0lucHV0KSB7CiAgICAgIHRoaXMubm90U3RhcnRlZCA9IGZhbHNlOwogICAgICBvdXRwdXRbMF1bMF0gPSBpbnB1dFswXVswXTsKICAgICAgZm9yIChsZXQgbiA9IDE7IG4gPCBibG9ja1NpemU7IG4rKykgewogICAgICAgIGZvciAobGV0IG8gPSAwOyBvIDwgb3V0cHV0Lmxlbmd0aDsgbysrKSB7CiAgICAgICAgICBvdXRwdXRbb11bbl0gPSBuICUgY29hcnNlID09IDAgPyBpbnB1dFswXVtuXSA6IG91dHB1dFtvXVtuIC0gMV07CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICByZXR1cm4gdGhpcy5ub3RTdGFydGVkIHx8IGhhc0lucHV0OwogIH0KfQoKcmVnaXN0ZXJQcm9jZXNzb3IoJ2NvYXJzZS1wcm9jZXNzb3InLCBDb2Fyc2VQcm9jZXNzb3IpOwoKY2xhc3MgQ3J1c2hQcm9jZXNzb3IgZXh0ZW5kcyBBdWRpb1dvcmtsZXRQcm9jZXNzb3IgewogIHN0YXRpYyBnZXQgcGFyYW1ldGVyRGVzY3JpcHRvcnMoKSB7CiAgICByZXR1cm4gW3sgbmFtZTogJ2NydXNoJywgZGVmYXVsdFZhbHVlOiAwIH1dOwogIH0KCiAgY29uc3RydWN0b3IoKSB7CiAgICBzdXBlcigpOwogICAgdGhpcy5ub3RTdGFydGVkID0gdHJ1ZTsKICB9CgogIHByb2Nlc3MoaW5wdXRzLCBvdXRwdXRzLCBwYXJhbWV0ZXJzKSB7CiAgICBjb25zdCBpbnB1dCA9IGlucHV0c1swXTsKICAgIGNvbnN0IG91dHB1dCA9IG91dHB1dHNbMF07CiAgICBjb25zdCBjcnVzaCA9IHBhcmFtZXRlcnMuY3J1c2g7CiAgICBjb25zdCBibG9ja1NpemUgPSAxMjg7CiAgICBjb25zdCBoYXNJbnB1dCA9ICEoaW5wdXRbMF0gPT09IHVuZGVmaW5lZCk7CiAgICBpZiAoaGFzSW5wdXQpIHsKICAgICAgdGhpcy5ub3RTdGFydGVkID0gZmFsc2U7CiAgICAgIGlmIChjcnVzaC5sZW5ndGggPT09IDEpIHsKICAgICAgICBjb25zdCB4ID0gTWF0aC5wb3coMiwgY3J1c2hbMF0gLSAxKTsKICAgICAgICBmb3IgKGxldCBuID0gMDsgbiA8IGJsb2NrU2l6ZTsgbisrKSB7CiAgICAgICAgICBjb25zdCB2YWx1ZSA9IE1hdGgucm91bmQoaW5wdXRbMF1bbl0gKiB4KSAvIHg7CiAgICAgICAgICBmb3IgKGxldCBvID0gMDsgbyA8IG91dHB1dC5sZW5ndGg7IG8rKykgewogICAgICAgICAgICBvdXRwdXRbb11bbl0gPSB2YWx1ZTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgZm9yIChsZXQgbiA9IDA7IG4gPCBibG9ja1NpemU7IG4rKykgewogICAgICAgICAgbGV0IHggPSBNYXRoLnBvdygyLCBjcnVzaFtuXSAtIDEpOwogICAgICAgICAgY29uc3QgdmFsdWUgPSBNYXRoLnJvdW5kKGlucHV0WzBdW25dICogeCkgLyB4OwogICAgICAgICAgZm9yIChsZXQgbyA9IDA7IG8gPCBvdXRwdXQubGVuZ3RoOyBvKyspIHsKICAgICAgICAgICAgb3V0cHV0W29dW25dID0gdmFsdWU7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICByZXR1cm4gdGhpcy5ub3RTdGFydGVkIHx8IGhhc0lucHV0OwogIH0KfQpyZWdpc3RlclByb2Nlc3NvcignY3J1c2gtcHJvY2Vzc29yJywgQ3J1c2hQcm9jZXNzb3IpOwoKY2xhc3MgU2hhcGVQcm9jZXNzb3IgZXh0ZW5kcyBBdWRpb1dvcmtsZXRQcm9jZXNzb3IgewogIHN0YXRpYyBnZXQgcGFyYW1ldGVyRGVzY3JpcHRvcnMoKSB7CiAgICByZXR1cm4gW3sgbmFtZTogJ3NoYXBlJywgZGVmYXVsdFZhbHVlOiAwIH1dOwogIH0KCiAgY29uc3RydWN0b3IoKSB7CiAgICBzdXBlcigpOwogICAgdGhpcy5ub3RTdGFydGVkID0gdHJ1ZTsKICB9CgogIHByb2Nlc3MoaW5wdXRzLCBvdXRwdXRzLCBwYXJhbWV0ZXJzKSB7CiAgICBjb25zdCBpbnB1dCA9IGlucHV0c1swXTsKICAgIGNvbnN0IG91dHB1dCA9IG91dHB1dHNbMF07CiAgICBjb25zdCBzaGFwZTAgPSBwYXJhbWV0ZXJzLnNoYXBlWzBdOwogICAgY29uc3Qgc2hhcGUxID0gc2hhcGUwIDwgMSA/IHNoYXBlMCA6IDEuMCAtIDRlLTEwOwogICAgY29uc3Qgc2hhcGUgPSAoMi4wICogc2hhcGUxKSAvICgxLjAgLSBzaGFwZTEpOwogICAgY29uc3QgYmxvY2tTaXplID0gMTI4OwogICAgY29uc3QgaGFzSW5wdXQgPSAhKGlucHV0WzBdID09PSB1bmRlZmluZWQpOwogICAgaWYgKGhhc0lucHV0KSB7CiAgICAgIHRoaXMubm90U3RhcnRlZCA9IGZhbHNlOwogICAgICBmb3IgKGxldCBuID0gMDsgbiA8IGJsb2NrU2l6ZTsgbisrKSB7CiAgICAgICAgY29uc3QgdmFsdWUgPSAoKDEgKyBzaGFwZSkgKiBpbnB1dFswXVtuXSkgLyAoMSArIHNoYXBlICogTWF0aC5hYnMoaW5wdXRbMF1bbl0pKTsKICAgICAgICBmb3IgKGxldCBvID0gMDsgbyA8IG91dHB1dC5sZW5ndGg7IG8rKykgewogICAgICAgICAgb3V0cHV0W29dW25dID0gdmFsdWU7CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICByZXR1cm4gdGhpcy5ub3RTdGFydGVkIHx8IGhhc0lucHV0OwogIH0KfQoKcmVnaXN0ZXJQcm9jZXNzb3IoJ3NoYXBlLXByb2Nlc3NvcicsIFNoYXBlUHJvY2Vzc29yKTsK";function k(s){const e=C().createGain();return e.gain.value=s,e}const Ie=({s,freq:e,t:r})=>{const n=C().createOscillator();return n.type=s||"triangle",n.frequency.value=Number(e),n.start(r),{node:n,stop:o=>n.stop(o)}},ee=(s,e,r,n,o,a)=>{const l=C().createGain();return l.gain.setValueAtTime(0,a),l.gain.linearRampToValueAtTime(o,a+s),l.gain.linearRampToValueAtTime(r*o,a+s+e),{node:l,stop:c=>{l.gain.setValueAtTime(r*o,c),l.gain.linearRampToValueAtTime(0,c+n)}}},Q=(s,e,r)=>{const n=C().createBiquadFilter();return n.type=s,n.frequency.value=e,n.Q.value=r,n},E=map();function te(s,e,r={}){E.setKey(s,{onTrigger:e,data:r})}function U(s){return E.get()[s]}let J;const C=()=>(J||(J=new AudioContext),J);let W;const j=()=>{const s=C();return W||(W=s.createGain(),W.connect(s.destination)),W};let D;function le(){return D||(D=C().audioWorklet.addModule(ue),D)}function x(s,e,r){const n=new AudioWorkletNode(s,e);return Object.entries(r).forEach(([o,a])=>{n.parameters.get(o).value=a}),n}async function Ce(s={}){const{disableWorklets:e=!1}=s;typeof window<"u"&&(await C().resume(),e?console.log("disableWorklets: AudioWorklet effects coarse, crush and shape are skipped!"):await le().catch(r=>{console.warn("could not load AudioWorklet effects coarse, crush and shape",r)}))}async function ve(s){return new Promise(e=>{document.addEventListener("click",async function r(){await Ce(s),e(),document.removeEventListener("click",r)})})}let G={};function fe(s,e,r,n){var o;if(r=ae(r,0,.98),!G[s]){const a=C().createFeedbackDelay(1,e,r);(o=a.start)==null||o.call(a,n),a.connect(j()),G[s]=a}return G[s].delayTime.value!==e&&G[s].delayTime.setValueAtTime(e,n),G[s].feedback.value!==r&&G[s].feedback.setValueAtTime(r,n),G[s]}let w={};function Ae(s,e=2){if(!w[s]){const r=C().createReverb(e);r.connect(j()),w[s]=r}return w[s].duration!==e&&(w[s]=w[s].setDuration(e),w[s].duration=e),w[s]}function _(s,e,r){const n=k(r);return s.connect(n),n.connect(e),n}const he=async(s,e,r)=>{const n=C();if(typeof s!="object")throw new Error(`expected hap.value to be an object, but got "${s}". Hint: append .note() or .s() to the end`,"error");let o=n.currentTime+e,{s:a="triangle",bank:l,source:c,gain:h=.8,cutoff:f,resonance:d=1,hcutoff:g,hresonance:y=1,bandf:I,bandq:P=1,coarse:N,crush:Y,shape:H,pan:Se,vowel:Re,delay:oe=0,delayfeedback:ke=.5,delaytime:Te=.25,orbit:Qe=1,room:Ve,size:Ze=2,velocity:De=1}=s;h*=De;let je=[];const at=()=>{je.forEach(ut=>ut==null?void 0:ut.disconnect())};l&&a&&(a=`${l}_${a}`);let tt;if(c)tt=c(o,s,r);else if(U(a)){const{onTrigger:ut}=U(a),ct=await ut(o,s,at);ct&&(tt=ct.node,ct.stop(o+r))}else throw new Error(`sound ${a} not found! Is it loaded?`);if(!tt||n.currentTime>o)return;const qe=[];if(qe.push(tt),qe.push(k(h)),f!==void 0&&qe.push(Q("lowpass",f,d)),g!==void 0&&qe.push(Q("highpass",g,y)),I!==void 0&&qe.push(Q("bandpass",I,P)),Re!==void 0&&qe.push(n.createVowelFilter(Re)),N!==void 0&&qe.push(x(n,"coarse-processor",{coarse:N})),Y!==void 0&&qe.push(x(n,"crush-processor",{crush:Y})),H!==void 0&&qe.push(x(n,"shape-processor",{shape:H})),Se!==void 0){const ut=n.createStereoPanner();ut.pan.value=2*Se-1,qe.push(ut)}const ht=k(1);qe.push(ht),ht.connect(j());let Je;if(oe>0&&Te>0&&ke>0){const ut=fe(Qe,Te,ke,o);Je=_(ht,ut,oe)}let pt;if(Ve>0&&Ze>0){const ut=Ae(Qe,Ze);pt=_(ht,ut,Ve)}qe.slice(1).reduce((ut,ct)=>ut.connect(ct),qe[0]),je=qe.concat([Je,pt])},O={};function pe(s,e){var r=e?1e3:1024;if(s=r);return s.toFixed(1)+" "+n[o]}const be=async(s,e,r,n,o,a,l)=>{let c=0,h=de({freq:o,note:r},36);c=h-36;const f=C();let d;if(Array.isArray(a))d=a[e%a.length];else{const P=Y=>L(Y)-h,N=Object.keys(a).filter(Y=>!Y.startsWith("_")).reduce((Y,H,Se)=>!Y||Math.abs(P(H))(O[s]||(O[s]=fetch(s).then(o=>o.arrayBuffer()).then(async o=>(pe(o.byteLength),await e.decodeAudioData(o)))),O[s]);function ye(s){const e=C(),r=e.createBuffer(s.numberOfChannels,s.length,e.sampleRate);for(let n=0;nObject.entries(s).forEach(([n,o])=>{if(typeof o=="string"&&(o=[o]),typeof o!="object")throw new Error("wrong sample map format for "+n);r=o._base||r;const a=l=>(r+l).replace("github:","https://raw.githubusercontent.com/");Array.isArray(o)?o=o.map(a):o=Object.fromEntries(Object.entries(o).map(([l,c])=>[l,(typeof c=="string"?[c]:c).map(a)])),e(n,o)});let ne={};function Ge(s){const e=Object.entries(ne).find(([r])=>s.startsWith(r));if(e)return e[1]}const we=async(s,e=s._base||"",r={})=>{if(typeof s=="string"){const a=Ge(s);if(a)return a(s);if(s.startsWith("github:")){let[c,h]=s.split("github:");h=h.endsWith("/")?h.slice(0,-1):h,s=`https://raw.githubusercontent.com/${h}/strudel.json`}if(typeof fetch!="function")return;const l=s.split("/").slice(0,-1).join("/");return typeof fetch>"u"?void 0:fetch(s).then(c=>c.json()).then(c=>we(c,e||c._base||l,r)).catch(c=>{throw console.error(c),new Error(`error loading "${s}"`)})}const{prebake:n,tag:o}=r;me(s,(a,l)=>te(a,(c,h,f)=>Xe(c,h,f,l),{type:"sample",samples:l,baseUrl:e,prebake:n,tag:o}),e)},$=[];async function Xe(s,e,r,n,o){const{s:a,freq:l,unit:c,nudge:h=0,cut:f,loop:d,clip:g=void 0,n:y=0,note:I,speed:P=1,begin:N=0,end:Y=1}=e;if(P===0)return;const H=C(),{attack:Se=.001,decay:Re=.001,sustain:oe=1,release:ke=.001}=e,Te=s+h,Qe=await be(a,y,I,P,l,n,o);if(H.currentTime>s||!Qe)return;Qe.playbackRate.value=Math.abs(P)*Qe.playbackRate.value,c==="c"&&(Qe.playbackRate.value=Qe.playbackRate.value*Qe.buffer.duration*1);const Ve=N*Qe.buffer.duration;Qe.start(Te,Ve);const Ze=Qe.buffer.duration/Qe.playbackRate.value,{node:De,stop:je}=ee(Se,Re,oe,ke,1,s);Qe.connect(De);const at=H.createGain();De.connect(at),Qe.onended=function(){Qe.disconnect(),De.disconnect(),at.disconnect(),r()};const tt={node:at,bufferSource:Qe,stop:(qe,ht=g===void 0)=>{let Je=qe;ht&&(Je=s+(Y-N)*Ze),Qe.stop(Je+ke),je(Je)}};if(f!==void 0){const qe=$[f];qe&&(qe.node.gain.setValueAtTime(1,Te),qe.node.gain.linearRampToValueAtTime(0,Te+.01)),$[f]=tt}return tt}function Ke(){["sine","square","triangle","sawtooth"].forEach(s=>{te(s,(e,r,n)=>{const{attack:o=.001,decay:a=.05,sustain:l=.6,release:c=.01}=r;let{n:h,note:f,freq:d}=r;h=f||h||36,typeof h=="string"&&(h=L(h)),!d&&typeof h=="number"&&(d=se(h));const{node:g,stop:y}=Ie({t:e,s,freq:d}),I=k(.3),{node:P,stop:N}=ee(o,a,l,c,1,e);return g.onended=()=>{g.disconnect(),I.disconnect(),n()},{node:g.connect(I).connect(P),stop:Y=>{N(Y),y(Y+c)}}},{type:"synth",prebake:!0})})}Array.prototype.in=function(s){return this.includes(s)};Promise.all([ve(),we("github:tidalcycles/Dirt-Samples/master"),Ke()]);class UserAPI{constructor(e){$e(this,"variables",{});$e(this,"iterators",{});$e(this,"_drunk",new DrunkWalk(-100,100,!1));$e(this,"MidiConnection",new MidiConnection);$e(this,"load");$e(this,"log",console.log);$e(this,"scale",scale);$e(this,"s",this.script);$e(this,"cs",this.clearscript);$e(this,"cps",this.copyscript);$e(this,"$",this.iterator);$e(this,"v",this.variable);$e(this,"dv",this.delete_variable);$e(this,"cv",this.clear_variables);$e(this,"rI",this.randI);$e(this,"r",this.rand);$e(this,"quant",this.quantize);$e(this,"cmp",this.clamp);$e(this,"tempo",this.bpm);$e(this,"silence",this.stop);$e(this,"hush",this.stop);$e(this,"abs",Math.abs);$e(this,"sound",async(e,r=0)=>{he(e,r)});$e(this,"d",this.sound);$e(this,"samples",we);this.app=e,this.load=we("github:tidalcycles/Dirt-Samples/master")}get time(){return this.app.audioContext.currentTime}get mouseX(){return this.app._mouseX}get mouseY(){return this.app._mouseY}rate(e){}script(...e){e.forEach(r=>{tryEvaluate(this.app,this.app.universes[this.app.selected_universe].locals[r])})}clearscript(e){this.app.universes[this.app.selected_universe].locals[e]={candidate:"",committed:"",evaluations:0}}copyscript(e,r){this.app.universes[this.app.selected_universe].locals[r]=this.app.universes[this.app.selected_universe].locals[e]}midi_outputs(){return console.log(this.MidiConnection.listMidiOutputs()),this.MidiConnection.midiOutputs}midi_output(e){e?this.MidiConnection.switchMidiOutput(e):console.log(this.MidiConnection.getCurrentMidiPort())}note(e,r={}){const n=r.channel?r.channel:0,o=r.velocity?r.velocity:100,a=r.duration?r.duration:.5;this.MidiConnection.sendMidiNote(e,n,o,a)}zn(e,r={}){const n=next(e,r),o=r.channel?r.channel:0,a=r.velocity?r.velocity:100,l=r.sustain?r.sustain:.5;return n instanceof Pitch?(n.bend&&this.MidiConnection.sendPitchBend(n.bend,o),this.MidiConnection.sendMidiNote(n.note,o,a,l),n.bend&&this.MidiConnection.sendPitchBend(8192,o)):n instanceof Chord&&n.pitches.forEach(c=>{c.bend&&this.MidiConnection.sendPitchBend(c.bend,o),this.MidiConnection.sendMidiNote(c.note,o,a,l),c.bend&&this.MidiConnection.sendPitchBend(8192,o)}),n}sysex(e){this.MidiConnection.sendSysExMessage(e)}pitch_bend(e,r){this.MidiConnection.sendPitchBend(e,r)}program_change(e,r){this.MidiConnection.sendProgramChange(e,r)}midi_clock(){this.MidiConnection.sendMidiClock()}cc(e,r){this.MidiConnection.sendMidiControlChange(e,r)}midi_panic(){this.MidiConnection.panic()}iterator(e,r,n){return e in this.iterators?(this.iterators[e].limit!==r&&(this.iterators[e].value=0,this.iterators[e].limit=r),this.iterators[e].step!==n&&(this.iterators[e].step=n??this.iterators[e].step),this.iterators[e].value+=this.iterators[e].step,this.iterators[e].limit!==void 0&&this.iterators[e].value>this.iterators[e].limit&&(this.iterators[e].value=0)):this.iterators[e]={value:0,step:n??1,limit:r},this.iterators[e].value}get drunk(){return this._drunk.step(),this._drunk.getPosition()}set drunk(e){this._drunk.position=e}set drunk_max(e){this._drunk.max=e}set drunk_min(e){this._drunk.min=e}set drunk_wrap(e){this._drunk.toggleWrap(e)}variable(e,r){return typeof e=="string"&&r===void 0?this.variables[e]:(this.variables[e]=r,this.variables[e])}delete_variable(e){delete this.variables[e]}clear_variables(){this.variables={}}pick(...e){return e[Math.floor(Math.random()*e.length)]}seqbeat(...e){return e[this.ebeat%e.length]}mel(e,r){return r[e%r.length]}seqbar(...e){return e[(this.app.clock.time_position.bar+1)%e.length]}seqpulse(...e){return e[this.app.clock.time_position.pulse%e.length]}randI(e,r){return Math.floor(Math.random()*(r-e+1))+e}rand(e,r){return Math.random()*(r-e)+e}quantize(e,r){if(r.length===0)return e;let n=r[0];return r.forEach(o=>{Math.abs(o-e)500)&&console.log(`Setting bpm to ${e}`),this.app.clock.bpm=e,e)}time_signature(e,r){this.app.clock.time_signature=[e,r]}almostNever(){return Math.random()>.9}sometimes(){return Math.random()>.5}rarely(){return Math.random()>.75}often(){return Math.random()>.25}almostAlways(){return Math.random()>.1}dice(e){return Math.floor(Math.random()*e)+1}get i(){return this.app.universes[this.app.selected_universe].global.evaluations}set i(e){this.app.universes[this.app.selected_universe].global.evaluations=e}get bar(){return this.app.clock.time_position.bar}get tick(){return this.app.clock.tick}get pulse(){return this.app.clock.time_position.pulse}get beat(){return this.app.clock.time_position.beat}get ebeat(){return this.app.clock.beats_since_origin}onbar(e,...r){const n=[...Array(e).keys()].map(o=>o+1);return console.log(r.some(o=>n.includes(o%e))),r.some(o=>n.includes(o%e))}onbeat(...e){let r=[];return e.forEach(n=>{n=1+n%this.app.clock.time_signature[0];let o=Math.floor(n),a=n-o;r.push(o===this.app.clock.time_position.beat&&this.app.clock.time_position.pulse===a*this.app.clock.ppqn)}),r.some(n=>n==!0)}stop(){this.app.clock.pause(),this.app.setButtonHighlighting("pause",!0)}prob(e){return Math.random()*100.5}min(...e){return Math.min(...e)}max(...e){return Math.max(...e)}limit(e,r,n){return Math.min(Math.max(e,r),n)}delay(e,r){setTimeout(r,e)}delayr(e,r,n){[...Array(r).keys()].map(a=>e*a).forEach((a,l)=>{setTimeout(n,a)})}mod(...e){return e.some(r=>this.app.clock.time_position.pulse%r===0)}modbar(...e){return e.some(r=>this.app.clock.time_position.bar%r===0)}euclid(e,r,n,o=0){return this._euclidean_cycle(r,n,o)[e%n]}_euclidean_cycle(e,r,n=0){function o(c,h){const f=c.length,d=(h+1)%f;return c[h]>c[d]}if(e>=r)return[!0];const a=Array.from({length:r},(c,h)=>(e*(h-1)%r+r)%r);let l=a.map((c,h)=>o(a,h));return n!=0&&(l=l.slice(n).concat(l.slice(0,n))),l}bin(e,r){let o=r.toString(2).split("").map(a=>a==="1");return o[e%o.length]}gold(){}line(e,r,n=1){const o=[];if(r>e&&n>0||r0?1:-1}noise(){return Math.random()*2-1}}class Editor{constructor(){$e(this,"universes",template_universes);$e(this,"selected_universe");$e(this,"local_index",1);$e(this,"editor_mode","local");$e(this,"fontSize");$e(this,"withLineNumbers");$e(this,"vimModeCompartment");$e(this,"chosenLanguage");$e(this,"settings",new AppSettings);$e(this,"editorExtensions",[]);$e(this,"userPlugins",[]);$e(this,"state");$e(this,"api");$e(this,"audioContext");$e(this,"view");$e(this,"clock");$e(this,"manualPlay",!1);$e(this,"_mouseX",0);$e(this,"_mouseY",0);$e(this,"play_buttons",[document.getElementById("play-button-1"),document.getElementById("play-button-2")]);$e(this,"pause_buttons",[document.getElementById("pause-button-1"),document.getElementById("pause-button-2")]);$e(this,"stop_buttons",[document.getElementById("stop-button-1"),document.getElementById("stop-button-2")]);$e(this,"clear_buttons",[document.getElementById("clear-button-1"),document.getElementById("clear-button-2")]);$e(this,"local_button",document.getElementById("local-button"));$e(this,"global_button",document.getElementById("global-button"));$e(this,"init_button",document.getElementById("init-button"));$e(this,"note_button",document.getElementById("note-button"));$e(this,"settings_button",document.getElementById("settings-button"));$e(this,"close_settings_button",document.getElementById("close-settings-button"));$e(this,"universe_viewer",document.getElementById("universe-viewer"));$e(this,"buffer_modal",document.getElementById("modal-buffers"));$e(this,"buffer_search",document.getElementById("buffer-search"));$e(this,"local_script_tabs",document.getElementById("local-script-tabs"));$e(this,"font_size_slider",document.getElementById("font-size-slider"));$e(this,"font_size_witness",document.getElementById("font-size-witness"));$e(this,"line_numbers_checkbox",document.getElementById("show-line-numbers"));$e(this,"normal_mode_button",document.getElementById("normal-mode"));$e(this,"vim_mode_button",document.getElementById("vim-mode"));this.selected_universe=this.settings.selected_universe,this.universe_viewer.innerHTML=`Topos: ${this.selected_universe}`,this.universes={...template_universes,...this.settings.universes},this.audioContext=new AudioContext({latencyHint:"playback"}),this.clock=new Clock(this,this.audioContext),this.api=new UserAPI(this),this.vimModeCompartment=new Compartment,this.withLineNumbers=new Compartment,this.chosenLanguage=new Compartment,this.fontSize=new Compartment;const e=this.settings.vimMode?vim():[],r=this.settings.line_numbers?lineNumbers():[],n=EditorView.theme({"&":{fontSize:`${this.settings.font_size}px`},".cm-gutters":{fontSize:`${this.settings.font_size}px`}});this.editorExtensions=[this.withLineNumbers.of(r),this.fontSize.of(n),this.vimModeCompartment.of(e),editorSetup,oneDark,this.chosenLanguage.of(javascript()),EditorView.updateListener.of(l=>{})];let o=new Compartment;this.state=EditorState.create({extensions:[...this.editorExtensions,EditorView.lineWrapping,o.of(this.userPlugins)],doc:this.universes[this.selected_universe].locals[this.local_index].candidate}),this.view=new EditorView({parent:document.getElementById("editor"),state:this.state}),document.addEventListener("keydown",l=>{l.key==="Tab"&&l.preventDefault(),l.ctrlKey&&l.key==="s"&&(l.preventDefault(),this.setButtonHighlighting("pause",!0),this.clock.pause()),l.ctrlKey&&l.key==="r"&&(l.preventDefault(),this.setButtonHighlighting("stop",!0),this.clock.stop()),l.ctrlKey&&l.key==="p"&&(l.preventDefault(),this.setButtonHighlighting("play",!0),this.clock.start()),(l.key==="v"||l.key==="V")&&l.ctrlKey&&l.shiftKey&&(this.settings.vimMode=!this.settings.vimMode,l.preventDefault(),this.userPlugins=this.settings.vimMode?[]:[vim()],this.view.dispatch({effects:o.reconfigure(this.userPlugins)})),(l.key==="Enter"||l.key==="Return")&&l.ctrlKey&&(l.preventDefault(),this.currentFile().candidate=this.view.state.doc.toString(),this.flashBackground("#2d313d",200)),(l.key==="Enter"&&l.shiftKey||l.key==="e"&&l.ctrlKey)&&(l.preventDefault(),this.currentFile().candidate=this.view.state.doc.toString(),this.flashBackground("#2d313d",200)),l.ctrlKey&&l.key==="b"&&this.openBuffersModal(),l.shiftKey&&l.key==="Escape"&&this.openSettingsModal(),l.ctrlKey&&l.key==="l"&&(l.preventDefault(),this.changeModeFromInterface("local"),this.view.focus()),l.ctrlKey&&l.key==="n"&&(l.preventDefault(),this.changeModeFromInterface("notes"),this.view.focus()),l.ctrlKey&&l.key==="g"&&(l.preventDefault(),this.changeModeFromInterface("global"),this.view.focus()),l.ctrlKey&&l.key==="i"&&(l.preventDefault(),this.changeModeFromInterface("init"),this.changeToLocalBuffer(0),this.view.focus()),[112,113,114,115,116,117,118,119,120].forEach((c,h)=>{l.keyCode===c&&(l.preventDefault(),l.ctrlKey?this.api.script(c-111):(this.changeModeFromInterface("local"),this.changeToLocalBuffer(h)))}),l.keyCode==121&&this.changeModeFromInterface("global"),l.keyCode==122&&this.changeModeFromInterface("init")});const a=document.querySelectorAll('[id^="tab-"]');for(let l=0;l{a[l].classList.add("bg-orange-300");for(let d=0;d{l.addEventListener("click",()=>{this.setButtonHighlighting("play",!0),this.clock.start()})}),this.clear_buttons.forEach(l=>{l.addEventListener("click",()=>{this.setButtonHighlighting("clear",!0),confirm("Do you want to reset the current universe?")&&(this.universes[this.selected_universe]=template_universe,this.updateEditorView())})}),this.pause_buttons.forEach(l=>{l.addEventListener("click",()=>{this.setButtonHighlighting("pause",!0),this.clock.pause()})}),this.stop_buttons.forEach(l=>{l.addEventListener("click",()=>{this.setButtonHighlighting("stop",!0),this.clock.stop()})}),this.local_button.addEventListener("click",()=>this.changeModeFromInterface("local")),this.global_button.addEventListener("click",()=>this.changeModeFromInterface("global")),this.init_button.addEventListener("click",()=>this.changeModeFromInterface("init")),this.note_button.addEventListener("click",()=>this.changeModeFromInterface("notes")),this.settings_button.addEventListener("click",()=>{var h;this.font_size_slider.value=this.settings.font_size.toString(),this.font_size_witness.innerHTML=`Font Size: ${this.settings.font_size}px`,(h=this.font_size_witness)==null||h.setAttribute("style",`font-size: ${this.settings.font_size}px;`),this.line_numbers_checkbox.checked=this.settings.line_numbers;let l=document.getElementById("modal-settings"),c=document.getElementById("editor");l==null||l.classList.remove("invisible"),c==null||c.classList.add("invisible")}),this.close_settings_button.addEventListener("click",()=>{let l=document.getElementById("modal-settings"),c=document.getElementById("editor");l==null||l.classList.add("invisible"),c==null||c.classList.remove("invisible")}),this.font_size_slider.addEventListener("input",()=>{const l=this.font_size_slider.value;this.settings.font_size=parseInt(l),this.font_size_witness.style.fontSize=`${l}px`,this.font_size_witness.innerHTML=`Font Size: ${l}px`;let c=EditorView.theme({"&":{fontSize:l+"px"},".cm-gutters":{fontSize:l+"px"}});this.view.dispatch({effects:this.fontSize.reconfigure(c)}),this.settings.font_size=parseInt(l)}),this.normal_mode_button.addEventListener("click",()=>{this.settings.vimMode=!1,this.view.dispatch({effects:this.vimModeCompartment.reconfigure([])})}),this.line_numbers_checkbox.addEventListener("change",()=>{let l=!!this.line_numbers_checkbox.checked;this.settings.line_numbers=l,this.view.dispatch({effects:this.withLineNumbers.reconfigure(l?[lineNumbers()]:[])})}),this.vim_mode_button.addEventListener("click",()=>{this.settings.vimMode=!0,this.view.dispatch({effects:this.vimModeCompartment.reconfigure(vim())})}),this.buffer_search.addEventListener("keydown",l=>{if(l.key==="Enter"){let c=this.buffer_search.value;c.length>2&&c.length<20&&(this.loadUniverse(c),this.settings.selected_universe=c,this.buffer_search.value="",this.closeBuffersModal(),this.view.focus())}}),tryEvaluate(this,this.universes[this.selected_universe.toString()].init)}get note_buffer(){return this.universes[this.selected_universe.toString()].notes}get global_buffer(){return this.universes[this.selected_universe.toString()].global}get init_buffer(){return this.universes[this.selected_universe.toString()].init}get local_buffer(){return this.universes[this.selected_universe.toString()].locals[this.local_index]}changeToLocalBuffer(e){const r=document.querySelectorAll('[id^="tab-"]'),n=r[e];n.classList.add("bg-orange-300");for(let a=0;a{r.forEach(a=>{let l=a.children[0];l.classList.contains("text-orange-300")&&(l.classList.remove("text-orange-300"),a.classList.remove("text-orange-300"))}),o.children[0].classList.remove("text-white"),o.children[0].classList.add("text-orange-300"),o.classList.add("text-orange-300")};switch(e){case"local":this.local_script_tabs.classList.contains("hidden")&&this.local_script_tabs.classList.remove("hidden"),this.editor_mode="local",this.local_index=0,this.changeToLocalBuffer(this.local_index),n(this.local_button);break;case"global":this.local_script_tabs.classList.contains("hidden")||this.local_script_tabs.classList.add("hidden"),this.editor_mode="global",n(this.global_button);break;case"init":this.local_script_tabs.classList.contains("hidden")||this.local_script_tabs.classList.add("hidden"),this.editor_mode="init",n(this.init_button);break;case"notes":this.local_script_tabs.classList.contains("hidden")||this.local_script_tabs.classList.add("hidden"),this.editor_mode="notes",n(this.note_button);break}this.view.dispatch({effects:this.chosenLanguage.reconfigure(this.editor_mode=="notes"?[markdown()]:[javascript()])}),this.updateEditorView()}setButtonHighlighting(e,r){this.flashBackground("#2d313d",200);const n=['[id^="play-button-"]','[id^="pause-button-"]','[id^="clear-button-"]','[id^="stop-button-"]'];let o;switch(e){case"play":o=0;break;case"pause":o=1;break;case"clear":o=2;break;case"stop":o=3;break}document.querySelectorAll(n[o]).forEach(a=>{r&&a.children[0].classList.add("fill-orange-300")}),document.querySelectorAll(n.filter((a,l)=>l!=o).join(",")).forEach(a=>{a.children[0].classList.remove("fill-orange-300"),a.children[0].classList.remove("text-orange-300"),a.children[0].classList.remove("bg-orange-300")})}unfocusPlayButtons(){document.querySelectorAll('[id^="play-button-"]').forEach(e=>{e.children[0].classList.remove("fill-orange-300")})}updateEditorView(){this.view.dispatch({changes:{from:0,to:this.view.state.doc.toString().length,insert:this.currentFile().candidate}})}currentFile(){switch(this.editor_mode){case"global":return this.global_buffer;case"local":return this.local_buffer;case"init":return this.init_buffer;case"notes":return this.note_buffer}}loadUniverse(e){this.currentFile().candidate=this.view.state.doc.toString();let r=e.trim();this.universes[r]===void 0&&(this.universes[r]=template_universe),this.selected_universe=r,this.settings.selected_universe=this.selected_universe,this.universe_viewer.innerHTML=`Topos: ${r}`,this.updateEditorView(),tryEvaluate(this,this.universes[this.selected_universe.toString()].init)}openSettingsModal(){document.getElementById("modal-settings").classList.contains("invisible")?(document.getElementById("editor").classList.add("invisible"),document.getElementById("modal-settings").classList.remove("invisible")):this.closeSettingsModal()}closeSettingsModal(){document.getElementById("editor").classList.remove("invisible"),document.getElementById("modal-settings").classList.add("invisible")}openBuffersModal(){document.getElementById("modal-buffers").classList.contains("invisible")?(document.getElementById("editor").classList.add("invisible"),document.getElementById("modal-buffers").classList.remove("invisible"),document.getElementById("buffer-search").focus()):this.closeBuffersModal()}closeBuffersModal(){document.getElementById("buffer-search").value="",document.getElementById("editor").classList.remove("invisible"),document.getElementById("modal").classList.add("invisible"),document.getElementById("modal-buffers").classList.add("invisible")}flashBackground(e,r){this.view.dom.style.backgroundColor=e;const n=this.view.dom.getElementsByClassName("cm-gutter");Array.from(n).forEach(o=>o.style.backgroundColor=e),setTimeout(()=>{this.view.dom.style.backgroundColor="",Array.from(n).forEach(o=>o.style.backgroundColor="")},r)}}const app=new Editor;function startClock(){document.getElementById("editor").classList.remove("invisible"),document.getElementById("modal").classList.add("hidden"),document.getElementById("modal-container").classList.remove("motion-safe:animate-pulse"),document.getElementById("start-button").removeEventListener("click",startClock),document.removeEventListener("click",startClock),document.removeEventListener("keydown",startOnEnter),document.removeEventListener("click",startOnClick),app.clock.start(),app.view.focus(),app.setButtonHighlighting("play",!0)}function startOnEnter(s){(s.code==="Enter"||s.code==="Space")&&startClock()}function startOnClick(s){s.button===0&&startClock()}document.addEventListener("keydown",startOnEnter);document.addEventListener("click",startOnClick);function reportMouseCoordinates(s){app._mouseX=s.clientX,app._mouseY=s.clientY}window.addEventListener("mousemove",reportMouseCoordinates);window.addEventListener("beforeunload",()=>(event.preventDefault(),app.currentFile().candidate=app.view.state.doc.toString(),app.currentFile().committed=app.view.state.doc.toString(),app.settings.saveApplicationToLocalStorage(app.universes,app.settings),app.clock.stop(),null)); diff --git a/index.html b/index.html index 1477cb4..e123a3f 100644 --- a/index.html +++ b/index.html @@ -6,7 +6,7 @@ Topos - +