@webgamekit/strudel-flow 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/LICENSE +661 -0
  2. package/dist/arrangeGrid.d.ts +58 -0
  3. package/dist/callArguments.d.ts +15 -0
  4. package/dist/chordSymbols.d.ts +15 -0
  5. package/dist/chords.d.ts +42 -0
  6. package/dist/codeScanner.d.ts +54 -0
  7. package/dist/compileStrudelFlow.d.ts +27 -0
  8. package/dist/components/notation/notationContextKey.d.ts +4 -0
  9. package/dist/components/overlayTargetKey.d.ts +3 -0
  10. package/dist/components/previewSoundKey.d.ts +3 -0
  11. package/dist/components/sampleFamilyIcons.d.ts +6 -0
  12. package/dist/components/visualizerWidgetIdsKey.d.ts +3 -0
  13. package/dist/config.d.ts +323 -0
  14. package/dist/connections.d.ts +29 -0
  15. package/dist/defaultPatch.d.ts +7 -0
  16. package/dist/envelopeShape.d.ts +13 -0
  17. package/dist/fretPlacement.d.ts +9 -0
  18. package/dist/index.d.ts +50 -0
  19. package/dist/index.js +6351 -0
  20. package/dist/index.umd.cjs +21 -0
  21. package/dist/layout.d.ts +30 -0
  22. package/dist/nodeCodeRange.d.ts +36 -0
  23. package/dist/nodeDefaults.d.ts +56 -0
  24. package/dist/nodeDefinitions.d.ts +9 -0
  25. package/dist/nodePatterns.d.ts +23 -0
  26. package/dist/notationPick.d.ts +22 -0
  27. package/dist/notationSequence.d.ts +15 -0
  28. package/dist/noteGrid.d.ts +45 -0
  29. package/dist/noteValues.d.ts +26 -0
  30. package/dist/parseStrudelFlowCode.d.ts +20 -0
  31. package/dist/patchStorage.d.ts +9 -0
  32. package/dist/patternVariables.d.ts +25 -0
  33. package/dist/readStoredValue.d.ts +32 -0
  34. package/dist/readStrudelFlowNodeData.d.ts +15 -0
  35. package/dist/sampleFamilies.d.ts +10 -0
  36. package/dist/sampleSequence.d.ts +14 -0
  37. package/dist/sheetLayout.d.ts +11 -0
  38. package/dist/solo.d.ts +23 -0
  39. package/dist/storage.d.ts +12 -0
  40. package/dist/structSteps.d.ts +12 -0
  41. package/dist/style.css +1 -0
  42. package/dist/tabLayout.d.ts +11 -0
  43. package/dist/tempo.d.ts +12 -0
  44. package/dist/types.d.ts +461 -0
  45. package/dist/useStrudelFlow.d.ts +8 -0
  46. package/package.json +43 -3
  47. package/README.md +0 -3
@@ -0,0 +1,21 @@
1
+ (function(d,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("@vue-flow/controls"),require("@vue-flow/core"),require("lucide-vue-next")):typeof define=="function"&&define.amd?define(["exports","vue","@vue-flow/controls","@vue-flow/core","lucide-vue-next"],e):(d=typeof globalThis<"u"?globalThis:d||self,e(d.WebGameKitStrudelFlow={},d.Vue,d.VueFlowControls,d.VueFlow,d.lucideVueNext))})(this,function(d,e,_s,j,L){"use strict";const wt="strudel-flow-patch",Le={name:"Strudel Flow",url:"https://xyflow.com/strudel-flow",author:"xyflow",authorUrl:"https://xyflow.com",sourceUrl:"https://github.com/xyflow/strudel-flow",license:"AGPL-3.0"},ye=120,je=1,Fe=300,ee=4,Lt=[{value:"2",label:"2"},{value:"3",label:"3"},{value:"4",label:"4"},{value:"5",label:"5"},{value:"6",label:"6"},{value:"7",label:"7"},{value:"8",label:"8"}],z=16,Ke=16,Ye=8,ce=80,qe=120,Vn=480,ps=360,Wn=2,$e=1e5,Gn=20,Hn=2e4,xn=.1,Xn=20,zn=20,Be=[{value:"pianoroll",label:"Pianoroll"},{value:"punchcard",label:"Punchcard"},{value:"scope",label:"Scope"},{value:"spiral",label:"Spiral"},{value:"pitchwheel",label:"Pitch wheel"},{value:"spectrum",label:"Spectrum"}],jn=[{value:"inline",label:"Under the line"},{value:"background",label:"Behind the code"}],fs=[{value:"code",label:"Code"},{value:"flow",label:"Flow"}],yt=[{value:"triangle",label:"Triangle"},{value:"sawtooth",label:"Sawtooth"},{value:"square",label:"Square"},{value:"sine",label:"Sine"}],ie=[{value:"C",label:"C"},{value:"C#",label:"C#"},{value:"D",label:"D"},{value:"D#",label:"D#"},{value:"E",label:"E"},{value:"F",label:"F"},{value:"F#",label:"F#"},{value:"G",label:"G"},{value:"G#",label:"G#"},{value:"A",label:"A"},{value:"A#",label:"A#"},{value:"B",label:"B"}],de=[{value:"major",label:"Major"},{value:"minor",label:"Minor"},{value:"dorian",label:"Dorian"},{value:"phrygian",label:"Phrygian"},{value:"lydian",label:"Lydian"},{value:"mixolydian",label:"Mixolydian"},{value:"aeolian",label:"Aeolian"},{value:"locrian",label:"Locrian"},{value:"major:pentatonic",label:"Major pentatonic"},{value:"minor:pentatonic",label:"Minor pentatonic"},{value:"blues",label:"Blues"},{value:"chromatic",label:"Chromatic"},{value:"diminished",label:"Diminished"},{value:"harmonic:minor",label:"Harmonic minor"},{value:"melodic:minor",label:"Melodic minor"}],Ze=[{value:"major",label:"Major"},{value:"minor",label:"Minor"}],Re=[{value:"",label:"None"},{value:"!2",label:"!2"},{value:"!3",label:"!3"},{value:"!4",label:"!4"},{value:"/2",label:"/2"},{value:"/3",label:"/3"},{value:"/4",label:"/4"},{value:"@2",label:"@2"},{value:"@3",label:"@3"},{value:"@4",label:"@4"},{value:"*2",label:"*2"},{value:"*3",label:"*3"},{value:"*4",label:"*4"}],Oe=8,Ft=128,$t=64,Je=2,Kn=128,Bt=16,Yn=[{sound:"bd",hits:[0,4,8,12]},{sound:"sd",hits:[4,12]},{sound:"hh",hits:[0,2,4,6,8,10,12,14]}],Rt=["bd","sd","hh","cp","ho","lt","mt","cr"],Ot=[{label:"Kicks",sounds:["bd","808bd","clubkick","hardkick","kicklinn","popkick","reverbkick"]},{label:"Snares",sounds:["sd","sn","808sd","dr","dr2","dr55","dr_few","drum","drumtraks","electro1","gretsch","hardcore","house","ifdrums","jungle"]},{label:"Hi-hats",sounds:["hh","hh27","linnhats","hc","ho","oc","808hc","808oh"]},{label:"Claps",sounds:["cp","realclaps","hand","clak"]},{label:"Toms",sounds:["lt","mt","ht","808lt","808mt","808ht","808lc","808mc"]},{label:"Cymbals",sounds:["cr","808cy","cb","rm","rs"]},{label:"Percussion",sounds:["perc","tabla","tok","tink","click","stomp","glasstap","can","bottle"]}],qn="_widget_",Zn="test-canvas",Jn={mask:[{kind:"toggles",label:"Plays"}],struct:[{kind:"toggles",label:"Hits"}],sometimesBy:[{kind:"number",label:"Chance",min:0,max:1,step:.01},{kind:"text",label:"Then"}],someCyclesBy:[{kind:"number",label:"Chance",min:0,max:1,step:.01},{kind:"text",label:"Then"}],degradeBy:[{kind:"number",label:"Drop",min:0,max:1,step:.01}],swingBy:[{kind:"number",label:"Swing",min:0,max:.5,step:.01},{kind:"number",label:"Subdivision",min:1,max:16,step:1}],fast:[{kind:"number",label:"Speed",min:.25,max:8,step:.25}],slow:[{kind:"number",label:"Speed",min:.25,max:8,step:.25}],ply:[{kind:"number",label:"Repeats",min:1,max:8,step:1}],late:[{kind:"number",label:"Shift",min:0,max:1,step:.01}],early:[{kind:"number",label:"Shift",min:0,max:1,step:.01}],velocity:[{kind:"number",label:"Velocity",min:0,max:1,step:.01}],speed:[{kind:"number",label:"Rate",min:-2,max:4,step:.05}],crush:[{kind:"number",label:"Bits",min:1,max:16,step:1}],shape:[{kind:"number",label:"Drive",min:0,max:1,step:.01}],hpf:[{kind:"number",label:"Cutoff",min:20,max:2e4,step:10}]},Qn={bass:[43,38,33,28],guitar:[64,59,55,50,45,40]},vn=24,el=4,Ne=[{value:"auto",label:"Auto"},{value:"grid",label:"Grid"},{value:"guitar",label:"Guitar tab"},{value:"bass",label:"Bass tab"},{value:"sheet",label:"Piano sheet"},{value:"piano",label:"Piano roll"},{value:"names",label:"Note names"},{value:"text",label:"Mini notation"}],tl=[{word:"bass",view:"bass"},{word:"guitar",view:"guitar"},{word:"piano",view:"sheet"},{word:"keys",view:"sheet"},{word:"organ",view:"sheet"},{word:"rhodes",view:"sheet"},{word:"harpsichord",view:"sheet"},{word:"clavinet",view:"sheet"}],nl=12,ll=1.5,Es=.8,Nt=3,ol=1,al=2.6,At=.2,sl=.4,rl=.8,cl=3.4,Ct=.62,Dt=.68,il=.15,dl=.2,ml=.6,ul=.3,Qe=2,_l=1.5,Ae=[1,.5,.25,.125],Mt=2,Pt=3,me=8,Ut=32,pl=26,fl=12,El=[1,3,6,8,10],It=5,Vt=.8,Wt=.35,hl=.1,gl=.12,Sl=1,kl=.36,Gt=.5,Ce=.3,Ht=.25,xt=.7,Xt=.25,bl=4.3,Tl={c:0,d:2,e:4,f:5,g:7,a:9,b:11},wl=3,Ll=["#","s"],yl=24,zt=["c","d","e","f","g","a","b"],Fl=[{letter:"c",alteration:0},{letter:"c",alteration:1},{letter:"d",alteration:0},{letter:"d",alteration:1},{letter:"e",alteration:0},{letter:"f",alteration:0},{letter:"f",alteration:1},{letter:"g",alteration:0},{letter:"g",alteration:1},{letter:"a",alteration:0},{letter:"a",alteration:1},{letter:"b",alteration:0}],ve=60,$l={treble:30,bass:18},ue=[{beats:4,filled:!1,stem:!1,flags:0},{beats:2,filled:!1,stem:!0,flags:0},{beats:1,filled:!0,stem:!0,flags:0},{beats:.5,filled:!0,stem:!0,flags:1},{beats:.25,filled:!0,stem:!0,flags:2},{beats:.125,filled:!0,stem:!0,flags:3}],Bl=1.5,Rl={treble:"𝄞",bass:"𝄢"},Ol={sharp:"♯",flat:"♭",natural:"♮"},Nl=8,Al=5,Cl=4,Dl=10,Ml=4.5,et=2.4,Pl=2.5,Ul=1.4,Il=6,jt=.65,Vl=.45,Wl=3.5,Gl=.8,Kt=1,Hl=1.4,xl=1.1,tt=.7,Xl=.7,zl=3,jl=.12,Yt=[{value:"",label:"Once",kind:"once"},{value:"*2",label:"2 hits in its step",kind:"faster"},{value:"*3",label:"3 hits in its step",kind:"faster"},{value:"*4",label:"4 hits in its step",kind:"faster"},{value:"*8",label:"8 hits in its step",kind:"faster"},{value:"!2",label:"Repeat over 2 steps",kind:"repeat"},{value:"!3",label:"Repeat over 3 steps",kind:"repeat"},{value:"!4",label:"Repeat over 4 steps",kind:"repeat"},{value:"@2",label:"Last 2 steps",kind:"hold"},{value:"@3",label:"Last 3 steps",kind:"hold"},{value:"/2",label:"Every 2nd cycle",kind:"slower"},{value:"/4",label:"Every 4th cycle",kind:"slower"},{value:"?",label:"Sometimes",kind:"chance"},{value:"(3,8)",label:"3 hits spread over 8",kind:"rhythm"},{value:"(5,8)",label:"5 hits spread over 8",kind:"rhythm"},{value:"(3,8,2)",label:"3 over 8, shifted by 2",kind:"rhythm"}],Kl=[{id:"once",label:"Plays"},{id:"faster",label:"Faster"},{id:"repeat",label:"Repeat"},{id:"hold",label:"Longer"},{id:"slower",label:"Slower"},{id:"chance",label:"Chance"},{id:"rhythm",label:"Rhythm"}],qt=[{id:"kick",label:"Kicks",match:"(^|[_\\d])(bd|kick)|kick|bassdrum"},{id:"snare",label:"Snares",match:"(^|[_\\d])(sd|sn|rim|rs)(\\b|_|$|\\d)|snare|rimshot"},{id:"hihat",label:"Hi-hats",match:"(^|[_\\d])(hh|oh|ch|hc|ho|oc)|hat"},{id:"clap",label:"Claps",match:"(^|[_\\d])cp|clap|hand"},{id:"tom",label:"Toms",match:"(^|[_\\d])(lt|mt|ht|lc|mc|hc)(\\b|_|$|\\d)|tom"},{id:"cymbal",label:"Cymbals",match:"(^|[_\\d])(cr|cy|cb|rd)(\\b|_|$|\\d)|ride|crash|cymbal|cowbell"},{id:"percussion",label:"Percussion",match:"perc|tabla|conga|bongo|shaker|tamb|tok|tink|click|stomp|clave|glass|can|bottle|wood"},{id:"bass",label:"Bass",match:"bass|sub|jvbass|jungbass"},{id:"keys",label:"Keys",match:"piano|keys|rhodes|organ|epiano|casio|wurli|clav|pad|arpy"},{id:"strings",label:"Guitar and strings",match:"guitar|gtr|string|violin|cello|harp|pluck"},{id:"voice",label:"Voices",match:"voc|voice|vox|choir|speech|sing|numbers|alphabet|mouth"},{id:"fx",label:"Effects and noise",match:"fx|noise|glitch|sweep|wind|metal|industrial|space"}],Yl=t=>{try{return localStorage.getItem(t)}catch{return null}},ql=(t,n)=>{try{localStorage.setItem(t,n)}catch{}},q=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),x=(t,n)=>typeof t=="string"?t:n,W=(t,n,l,o)=>typeof t=="number"&&Number.isFinite(t)?Math.min(o,Math.max(l,t)):n,_e=(t,n,l)=>typeof n=="string"&&t.some(o=>o.value===n)?n:l,hs=["C","C♯","D","E♭","E","F","F♯","G","A♭","A","B♭","B"],gs={C:0,"C#":1,Db:1,D:2,"D#":3,Eb:3,E:4,F:5,"F#":6,Gb:6,G:7,"G#":8,Ab:8,A:9,"A#":10,Bb:10,B:11},Zt=[0,2,4,5,7,9,11],Jt=[0,2,3,5,7,8,10],Ss={major:["I","ii","iii","IV","V","vi","vii°"],minor:["i","ii°","III","iv","v","VI","VII"]},Zl=[{label:"Home",steps:[0,5,3,4]},{label:"Turnaround",steps:[1,4,0,0]},{label:"Descending",steps:[0,6,5,4]}],ks=3,Qt=t=>{var n;return((n=t.chordNotes)==null?void 0:n.map(l=>(l[0]??0)%7))??t.chordProgression},bs=t=>Array.from({length:ks},(n,l)=>t+l*2),nt=t=>t.chordNotes??Qt(t).map(bs),Jl=t=>{const n=t.scaleType==="minor"?Jt:Zt,l=Ss[t.scaleType],o=c=>(gs[t.key]??0)+n[c%7]+Math.floor(c/7)*12,a=c=>hs[o(c)%12];return{degrees:l,noteName:a,noteLabel:c=>`${a(c)}${t.octave+Math.floor(o(c)/12)}`,chordName:c=>{const i=l[c%7];return i.includes("°")?`${a(c)}°`:`${a(c)}${i===i.toLowerCase()?"m":""}`}}},Ts=t=>[...t],vt=new Set(['"',"'","`"]),ws=new Set(["(","[","{"]),Ls=new Set([")","]","}"]),ys=new Set([".",",","(","[","{","+","-","*","/","=","&","|","?",":"]),Fs={parts:[],current:"",quote:"",escaped:!1,depth:0},De=(t,n)=>({...t,current:t.current+n}),$s=(t,n)=>t.escaped?{...De(t,n),escaped:!1}:n==="\\"?{...De(t,n),escaped:!0}:{...De(t,n),quote:n===t.quote?"":t.quote},Ql=t=>{const n=t.current.trim();return{...t,parts:n.length>0?[...t.parts,n]:t.parts,current:""}},vl=t=>ws.has(t)?1:Ls.has(t)?-1:0,Bs=t=>(n,l,o)=>n.quote.length>0?$s(n,l):vt.has(l)?{...De(n,l),quote:l}:n.depth===0&&t(l,o,n.current)?Ql(n):{...De(n,l),depth:n.depth+vl(l)},eo=(t,n)=>Ql([...t].reduce(Bs(n),Fs)).parts,X=(t,n)=>eo(t,l=>l===n),Rs=t=>{const n=[...t],l=n.reduce((o,a,s)=>{if(o.end!==-1)return o;if(o.quote.length>0){const r=!o.escaped&&a===o.quote;return{...o,quote:r?"":o.quote,escaped:!o.escaped&&a==="\\"}}return vt.has(a)?{...o,quote:a}:a==="/"&&n[s+1]==="/"?{...o,end:s}:o},{quote:"",escaped:!1,end:-1}).end;return(l===-1?t:t.slice(0,l)).trimEnd()},en=t=>t.split(`
2
+ `).map(Rs).join(`
3
+ `),to=t=>eo(t,(n,l,o)=>{if(n===";")return!0;if(n!==`
4
+ `)return!1;const a=o.trim();return a.length>0&&!t.slice(l+1).trimStart().startsWith(".")&&!ys.has(a.at(-1)??"")}),Os=t=>{try{return typeof new Function(`return async () => {
5
+ ${t}
6
+ }`)=="function"}catch{return!1}},Ns=t=>{if(!t.startsWith("(")||!t.endsWith(")"))return!1;const n=t.length-1;return![...t].reduce((o,a,s)=>{if(o.closesEarly)return o;if(o.quote.length>0){const c=!o.escaped&&a===o.quote;return{...o,quote:c?"":o.quote,escaped:!o.escaped&&a==="\\"}}if(vt.has(a))return{...o,quote:a};const r=o.depth+vl(a);return{...o,depth:r,closesEarly:r===0&&s<n}},{quote:"",escaped:!1,depth:0,closesEarly:!1}).closesEarly},As=new Set(["[","<","(","{"]),Cs=new Set(["]",">",")","}"]),no=t=>{const n=t.current.trim();return{parts:n.length>0?[...t.parts,n]:t.parts,current:"",depth:0}},te=(t,n)=>no([...t].reduce((l,o)=>{if(l.depth===0&&n(o))return{...no(l),depth:0};const a=As.has(o)?1:Cs.has(o)?-1:0;return{...l,current:l.current+o,depth:Math.max(0,l.depth+a)}},{parts:[],current:"",depth:0})).parts,pe=t=>/^(["'`])[\S\s]*\1$/.test(t.trim()),K=t=>{const n=t.trim();if(n.startsWith('"'))try{const l=JSON.parse(n);return typeof l=="string"?l:n.slice(1,-1)}catch{return n.slice(1,-1)}return n.slice(1,-1).replace(/\\'/g,"'")},tn=12,Ds=[0,2,4],lo="~",Ms=/^([A-G]#?)(m|dim)?$/,Me=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],oo={major:Zt,minor:Jt},ao={major:["","m","m","","","m","dim"],minor:["m","dim","","m","m","",""]},Ps=t=>{if(t===lo)return null;const n=Ms.exec(t);return n===null?void 0:{rootPitch:Me.indexOf(n[1]),suffix:n[2]??""}},Us=(t,n,l)=>{if(t===null)return 0;const o=(t.rootPitch-n+tn)%tn,a=oo[l].indexOf(o);return a!==-1&&ao[l][a]===t.suffix?a:void 0},Is=(t,n,l)=>{const o=t.map(a=>Us(a,n,l));return o.every(a=>a!==void 0)?{key:Me[n],scaleType:l,degrees:o}:null},Vs=t=>t.degrees[0]===0,Ws=t=>{const n=t.trim();if(!n.startsWith("<")||!n.endsWith(">"))return null;const l=n.slice(1,-1).trim().split(/\s+/).map(Ps);if(l.some(r=>r===void 0)||l.every(r=>r===null))return null;const o=Ze.flatMap(r=>Me.map((c,i)=>Is(l,i,r.value))).filter(r=>r!==null),a=o.find(Vs)??o[0];if(a===void 0)return null;const s=l.some(r=>r===null);return{kind:"chords",key:a.key,octave:4,scaleType:a.scaleType,chordProgression:a.degrees,chordSymbols:!0,...s?{chordNotes:a.degrees.map((r,c)=>l[c]===null?[]:Ds.map(i=>r+i))}:{}}},Gs=t=>{const n=Me.indexOf(t.key),l=oo[t.scaleType];return`<${nt(t).map(a=>{if(a.length===0)return lo;const s=a[0]%l.length;return`${Me[(n+l[s])%tn]}${ao[t.scaleType][s]}`}).join(" ")}>`},Hs="~",G=t=>Number.isFinite(t)?Math.round(t*100)/100:0,so=t=>{if(!Number.isFinite(t))return"0.0";if(Math.abs(t)>=1e4)return`${(t/1e3).toFixed(1)}k`;if(Math.abs(t)>=1e3)return`${(t/1e3).toFixed(2)}k`;if(Math.abs(t)>=100)return t.toFixed(0);if(Math.abs(t)>=10)return t.toFixed(1);const n=t.toFixed(2);return n.endsWith("0")?n.slice(0,-1):n},xs=(t,n,l)=>{const o=(t??[]).map((s,r)=>s?String(r):null).filter(s=>s!==null),a=l.columnModifiers[n]??"";return o.length===0?`[~]${a}`:`[${o.join(l.mode==="arp"?" ":", ")}]${a}`},Xs=t=>{const n=Math.max(1,Math.min(t.steps,t.grid.length)),l=t.grid.slice(0,n).map((a,s)=>xs(a,s,t));if(l.every(a=>a.startsWith("[~]")))return"";const o=`${t.key}${t.octave}:${t.scaleType}`;return`n(${JSON.stringify(l.join(" "))}).scale(${JSON.stringify(o)})`},zs=(t,n)=>{const l=t.steps.slice(0,n);if(!l.some(a=>a))return"";const o=l.map((a,s)=>a?`${t.sound}${t.modifiers[s]??""}`:Hs);return`s(${JSON.stringify(o.join(" "))})`},js=t=>{const n=t.rows.map(l=>zs(l,t.steps)).filter(l=>l.length>0);return n.length===0?"":n.length===1?n[0]:`stack(${n.join(", ")})`},Ks=t=>{const n=nt(t);if(n.every(a=>a.length===0))return"";if(t.chordSymbols===!0)return`chord(${JSON.stringify(Gs(t))})`;const l=n.map(a=>a.length>0?`[${a.join(",")}]`:"~"),o=`${t.key}${t.octave}:${t.scaleType}`;return`n(${JSON.stringify(`<${l.join(" ")}>`)}).scale(${JSON.stringify(o)})`},ro=(t,n)=>n.trim().length===0?"":`${t}(${JSON.stringify(n.trim())})`,Ys=t=>{const n=t.code.trim().replace(/;+\s*$/,"");return n.length===0?"":n.includes(`
7
+ `)?`(
8
+ ${n}
9
+ )`:`(${n})`},qs=(t,n)=>n.length===0?"":`${n}.sound(${JSON.stringify(t.sound)})`,Zs=(t,n)=>n.length===0?"":`${n}.lpf(${G(t.cutoff)}).lpq(${G(t.resonance)})`,Js=(t,n)=>n.length===0?"":`${n}.delay(${G(t.mix)}).delaytime(${G(t.time)}).delayfeedback(${G(t.feedback)})`,Qs=(t,n)=>n.length===0?"":`${n}.room(${G(t.room)}).roomsize(${G(t.roomSize)}).roomfade(${G(t.roomFade)}).roomlp(${G(t.roomLowPass)}).roomdim(${G(t.roomDim)})`,vs=(t,n)=>n.length===0?"":`${n}.gain(${G(t.gain)})`,er=(t,n)=>n.length===0?"":`${n}.pan(${G(t.pan)}).postgain(${G(t.postgain)})`,tr=(t,n)=>{const l=t.argument.trim();return n.length===0||l.length===0?n:`${n}.mask(${l})`},nr=(t,n)=>{const l=t.argument.trim();return n.length===0||l.length===0?n:`${n}.struct(${l})`},lr=(t,n)=>n.length===0?"":`${n}.slow(${G(t.amount)})`,or=(t,n)=>n.length===0?"":`${n}.attack(${G(t.attack)}).decay(${G(t.decay)}).sustain(${G(t.sustain)}).release(${G(t.release)})`,ar=(t,n)=>{if(n.length===0)return"";const l=t.placement==="inline"?"_":"";return`${n}.${l}${t.visual}(${t.options.trim()})`},sr=t=>t.filter(n=>n.method.trim().length>0).map(n=>`.${n.method.trim()}(${n.argument.trim()})`).join(""),rr={pad:Xs,beats:js,chords:Ks,notes:t=>ro(t.head??"note",t.pattern),samples:t=>ro("s",t.pattern),code:Ys,arrange:(t,n)=>n,voice:qs,filter:Zs,delay:Js,space:Qs,gain:vs,level:er,mask:tr,struct:nr,slow:lr,voicing:(t,n)=>n.length===0?"":`${n}.voicing()`,envelope:or,visualizer:ar,effect:(t,n)=>n.length===0?"":`${n}${sr(t.calls)}`},cr=(t,n)=>rr[t.kind](t,n),Pe=(t,n)=>cr(t,n),ir=/^-?(\d+\.?\d*|\.\d+)(\/(\d+\.?\d*|\.\d+))?$/,dr=/^(["'])(<?)\s*([01](?:!\d+)?(?:\s+[01](?:!\d+)?)*)\s*(>?)\1$/,mr=64,ur=t=>{if(!ir.test(t))return null;const[n,l]=t.split("/").map(Number),o=l===void 0?n:n/l;return Number.isFinite(o)?o:null},_r=(t,n)=>{const l=dr.exec(n);if(l===null||l[2]==="<"!=(l[4]===">"))return null;const o=l[3].split(/\s+/).flatMap(a=>{const[s,r]=a.split("!");return Array.from({length:Number(r??1)},()=>s==="1")});return o.length>mr?null:{kind:"toggles",label:t,steps:o,perCycle:l[2]==="<",...l[3].includes("!")?{repeated:!0}:{}}},pr=(t,n)=>{if(t.kind==="text")return n.length===0?null:{...t,value:n};if(t.kind==="toggles")return _r(t.label,n);const l=ur(n);return l===null?null:{...t,value:l}},nn=t=>{const n=Jn[t.method.trim()],l=X(t.argument,",").map(a=>a.trim());if(n===void 0||l.length!==n.length)return null;const o=n.map((a,s)=>pr(a,l[s]));return o.every(a=>a!==null)?o:null},co=t=>t?"1":"0",fr=t=>t.reduce((n,l)=>{var o,a;return((o=n.at(-1))==null?void 0:o.step)===l?[...n.slice(0,-1),{step:l,length:(((a=n.at(-1))==null?void 0:a.length)??0)+1}]:[...n,{step:l,length:1}]},[]).map(n=>`${co(n.step)}${n.length>1?`!${n.length}`:""}`),Er=t=>{if(t.kind==="number")return String(G(t.value));if(t.kind==="text")return t.value;const n=(t.repeated===!0?fr(t.steps):t.steps.map(co)).join(" ");return t.perCycle?`"<${n}>"`:`"${n}"`},ln=t=>t.map(Er).join(", "),io=["pad","beats","chords","notes","samples","code"],hr=[[0,7],[1,5],[2,3],[3,1],[4,3],[5,2],[6,6],[7,3]],gr=new Set(hr.map(([t,n])=>`${t}:${n}`)),lt=()=>Array.from({length:Ke},(t,n)=>Array.from({length:Ye},(l,o)=>gr.has(`${n}:${o}`))),oe={kind:"pad",steps:8,mode:"arp",octave:3,key:"C",scaleType:"major",grid:lt(),columnModifiers:{}},fe={kind:"chords",key:"C",octave:4,scaleType:"major",chordProgression:[0,5,3,4]},on={kind:"notes",pattern:"c3 [e3 g3] a3 [g3 e3]",notation:"grid"},an={kind:"samples",pattern:"bd*2 [~ sd] bd sd"},ot={kind:"code",code:'n("<[0,2,4,6] [5,7,9,11]>").scale("C3:major").slow(2)'},at={kind:"arrange",sequence:[0,0,0,0,1,1,1,1]},sn={kind:"voice",sound:"triangle"},rn={kind:"effect",calls:[{method:"fast",argument:"2"}]},st={kind:"filter",cutoff:1500,resonance:1},Ue={kind:"delay",mix:.5,time:.25,feedback:.4},ae={kind:"space",room:.4,roomSize:2,roomFade:.5,roomLowPass:1e4,roomDim:8e3},cn={kind:"gain",gain:1},rt={kind:"level",pan:.5,postgain:1},dn={kind:"mask",argument:'"<1 1 1 0>"'},mn={kind:"struct",argument:'"x ~ x x ~ x x ~"'},un={kind:"slow",amount:2},mo={kind:"voicing"},Ee={kind:"envelope",attack:.1,decay:.1,sustain:.7,release:.2},_n={kind:"visualizer",visual:"pianoroll",placement:"inline",options:""},he=(t,n=[])=>({sound:t,steps:Array.from({length:z},(l,o)=>n.includes(o)),modifiers:{}}),pn=()=>Yn.map(t=>he(t.sound,t.hits)),Sr={pad:()=>({...oe,grid:lt(),columnModifiers:{}}),beats:()=>({kind:"beats",steps:Bt,rows:pn(),showModifiers:!1}),chords:()=>({...fe,chordProgression:[0,5,3,4]}),notes:()=>({...on}),samples:()=>({...an}),code:()=>({...ot}),arrange:()=>({...at,sequence:[...at.sequence]}),voice:()=>({...sn}),filter:()=>({...st}),delay:()=>({...Ue}),space:()=>({...ae}),gain:()=>({...cn}),level:()=>({...rt}),mask:()=>({...dn}),struct:()=>({...mn}),slow:()=>({...un}),voicing:()=>({...mo}),envelope:()=>({...Ee}),visualizer:()=>({..._n}),effect:()=>({...rn,calls:rn.calls.map(t=>({...t}))})},ge=t=>Sr[t](),Y=t=>io.includes(t),kr=t=>!io.includes(t),br=["pad","beats","chords","notes","samples","code","arrange","voice","filter","delay","space","gain","level","mask","struct","slow","voicing","envelope","visualizer","effect"],Tr=(t,n)=>Array.isArray(t)&&t.length===z&&t.every(l=>typeof l=="boolean")?t:n,wr=t=>typeof t=="string"&&t.length>0&&Re.some(n=>n.value===t),uo=t=>q(t)?Object.fromEntries(Object.entries(t).flatMap(([n,l])=>{const o=Number(n);return Number.isInteger(o)&&o>=0&&o<z&&wr(l)?[[o,l]]:[]})):{},Lr=t=>{if(!q(t))return null;const n=x(t.sound??t.instrument,"").trim();return n.length===0?null:{sound:n,steps:Tr(t.steps,he(n).steps),modifiers:uo(t.modifiers)}},yr=t=>{const n=(Array.isArray(t)?t:[]).map(Lr).filter(l=>l!==null).slice(0,Oe);return n.length>0?n:pn()},Ie=(t,n,l,o)=>Math.round(W(t,n,l,o)),Fr=t=>{const n=lt();return Array.isArray(t)?Array.from({length:Ke},(l,o)=>{const a=t[o];return Array.from({length:Ye},(s,r)=>Array.isArray(a)?a[r]===!0:!1)}):n},$r=t=>{const n=fe.chordProgression;return!Array.isArray(t)||t.length===0||t.length>z||!t.every(l=>Number.isInteger(l)&&l>=0&&l<=6)?n:t},Br=t=>{if(!(!Array.isArray(t)||t.length===0||t.length>z||!t.every(n=>Array.isArray(n)&&n.every(l=>Number.isInteger(l)&&l>=0&&l<28))))return t.map(n=>[...n].sort((l,o)=>l-o))},_o=t=>typeof t=="string"&&br.some(n=>n===t),Se=t=>t.muted===!0?{muted:!0}:{},Rr=t=>({...Se(t),kind:"pad",steps:Ie(t.steps,oe.steps,1,Ke),mode:_e([{value:"arp"},{value:"chord"}],t.mode,oe.mode),octave:Ie(t.octave,oe.octave,1,8),key:_e(ie,t.key,oe.key),scaleType:_e(de,t.scaleType,oe.scaleType),grid:Fr(t.grid),columnModifiers:uo(t.columnModifiers)}),Or=t=>{const n=Br(t.chordNotes);return{...Se(t),kind:"chords",key:_e(ie,t.key,fe.key),octave:Ie(t.octave,fe.octave,1,8),scaleType:_e(Ze,t.scaleType,fe.scaleType),chordProgression:$r(t.chordProgression),...n===void 0?{}:{chordNotes:n},...t.chordSymbols===!0?{chordSymbols:!0}:{}}},Nr=t=>q(t)&&typeof t.method=="string"&&typeof t.argument=="string",Ar=t=>Array.isArray(t)?t.filter(Nr).map(n=>({method:n.method,argument:n.argument})):[],Cr=t=>{const n=(Array.isArray(t)?t:[]).map(l=>Ie(l,-1,-1,$t));return n.length>0?n:at.sequence},Dr={pad:Rr,beats:t=>({...Se(t),kind:"beats",steps:Ie(t.steps,Bt,1,z),rows:yr(t.rows),showModifiers:t.showModifiers===!0}),chords:Or,notes:t=>{var n;return{...Se(t),kind:"notes",pattern:x(t.pattern,on.pattern),notation:((n=Ne.find(l=>l.value===t.notation))==null?void 0:n.value)??"auto",...t.head==="chord"?{head:"chord"}:{},...t.showPattern===!0?{showPattern:!0}:{}}},samples:t=>({...Se(t),kind:"samples",pattern:x(t.pattern,an.pattern),...t.showPattern===!0?{showPattern:!0}:{}}),code:t=>({...Se(t),kind:"code",code:x(t.code,ot.code)}),arrange:t=>({kind:"arrange",sequence:Cr(t.sequence)}),voice:t=>({kind:"voice",sound:x(t.sound,sn.sound)}),filter:t=>({kind:"filter",cutoff:W(t.cutoff,st.cutoff,Gn,Hn),resonance:W(t.resonance,st.resonance,xn,Xn)}),delay:t=>({kind:"delay",mix:W(t.mix,Ue.mix,0,1),time:W(t.time,Ue.time,0,1),feedback:W(t.feedback,Ue.feedback,0,1)}),space:t=>({kind:"space",room:W(t.room,ae.room,0,1),roomSize:W(t.roomSize,ae.roomSize,0,zn),roomFade:W(t.roomFade,ae.roomFade,0,10),roomLowPass:W(t.roomLowPass,ae.roomLowPass,0,2e4),roomDim:W(t.roomDim,ae.roomDim,0,2e4)}),gain:t=>({kind:"gain",gain:W(t.gain,cn.gain,0,2)}),mask:t=>({kind:"mask",argument:x(t.argument,dn.argument)}),struct:t=>({kind:"struct",argument:x(t.argument,mn.argument)}),slow:t=>({kind:"slow",amount:W(t.amount,un.amount,.25,8)}),voicing:()=>({kind:"voicing"}),level:t=>({kind:"level",pan:W(t.pan,rt.pan,0,1),postgain:W(t.postgain,rt.postgain,0,2)}),envelope:t=>({kind:"envelope",attack:W(t.attack,Ee.attack,0,2),decay:W(t.decay,Ee.decay,0,2),sustain:W(t.sustain,Ee.sustain,0,1),release:W(t.release,Ee.release,0,2)}),visualizer:t=>{var n;return{kind:"visualizer",visual:((n=Be.find(l=>l.value===t.visual))==null?void 0:n.value)??_n.visual,placement:t.placement==="background"?"background":"inline",options:x(t.options,"")}},effect:t=>({kind:"effect",calls:t.calls===void 0&&typeof t.method=="string"?[{method:t.method,argument:x(t.argument,"")}]:Ar(t.calls)})},po=(t,n)=>{const l=q(n)?n:{};return Dr[t](l)},ct=[{kind:"pad",title:"Pad",category:"Instruments",description:"An eight-step note grid on a key and scale."},{kind:"beats",title:"Beats",category:"Instruments",description:"Drum tracks of any sample, such as cp or 808bd, on a step grid."},{kind:"chords",title:"Chords",category:"Instruments",description:"A chord progression with editable scale degrees."},{kind:"notes",title:"Notes",category:"Instruments",description:"A note line in mini notation, such as c3 [e3 g3]."},{kind:"samples",title:"Samples",category:"Instruments",description:"A line of samples, rests and groups, such as bd*2 [~ sd]."},{kind:"code",title:"Code",category:"Instruments",description:"One custom Strudel expression."},{kind:"arrange",title:"Arrange",category:"Effects",description:"Plays the chains cabled into it one after another, each for the cycles you pick."},{kind:"voice",title:"Voice",category:"Sounds",description:"The synth or sample bank that plays the notes."},{kind:"filter",title:"Filter",category:"Effects",description:"A low-pass filter and its resonance."},{kind:"delay",title:"Delay",category:"Effects",description:"A feedback delay with mix and time."},{kind:"space",title:"Space",category:"Effects",description:"A room reverb with size, fade and damping."},{kind:"gain",title:"Gain",category:"Effects",description:"How loud the pattern plays."},{kind:"level",title:"Level",category:"Effects",description:"Stereo pan and postgain."},{kind:"mask",title:"Mask",category:"Effects",description:"Which steps or cycles of the pattern play, such as <1 1 1 0>."},{kind:"struct",title:"Struct",category:"Effects",description:"Which steps of the pattern hit, picked with switches."},{kind:"slow",title:"Slow",category:"Effects",description:"Stretches each cycle over more time."},{kind:"voicing",title:"Voicing",category:"Effects",description:"Spreads chord symbols into played notes."},{kind:"envelope",title:"Envelope",category:"Effects",description:"An attack, decay, sustain and release shape."},{kind:"visualizer",title:"Visualizer",category:"Effects",description:"A pianoroll, punchcard, scope, spiral, pitch wheel or spectrum of the pattern."},{kind:"effect",title:"Effect",category:"Effects",description:"Any other Strudel call, such as fast(2) or jux(rev)."}],fn=t=>ct.find(n=>n.kind===t)??ct[0],it="silence",Mr=new Set([it,"~",""]),En=-1,fo=t=>Mr.has(t.trim()),Pr=t=>{const n=[...new Set(t.filter(({pattern:l})=>!fo(l)).map(({pattern:l})=>l.trim()))];return{parts:n,sequence:t.flatMap(({cycles:l,pattern:o})=>Array.from({length:l},()=>fo(o)?En:n.indexOf(o.trim())))}},Ur=t=>t.reduce((n,l)=>{const o=n.at(-1);return(o==null?void 0:o.part)===l?[...n.slice(0,-1),{...o,cycles:o.cycles+1}]:[...n,{cycles:1,part:l}]},[]),Ir=(t,n,l)=>t.map((o,a)=>a===l?o===n?En:n:o),Vr=(t,n)=>Array.from({length:n},(l,o)=>t[o]??En),Wr=(t,n)=>{const l=Ur(t).map(({cycles:o,part:a})=>`[${o}, ${n[a]??it}]`);return l.every(o=>o.endsWith(`${it}]`))?it:`arrange(${l.join(", ")})`},Gr=(t,n)=>t.position.y-n.position.y||t.position.x-n.position.x,Eo=t=>[...t].sort(Gr),se=t=>Number.isFinite(t)?Math.min(Fe,Math.max(je,Math.round(t))):ye,Ve=t=>Lt.some(n=>Number(n.value)===t)?t:ee,Hr={visiting:[],visited:[],ordered:[],hasCycle:!1},xr=t=>t.reduce((n,l)=>{const o=n.get(l.source)??[],a=n.get(l.target)??[];return new Map([...n,[l.source,[...o,l.target]],[l.target,[...a,l.source]]])},new Map),ho=(t,n)=>t.reduce((l,o)=>!n.includes(o.source)||!n.includes(o.target)?l:new Map([...l,[o.source,[...l.get(o.source)??[],o.target]]]),new Map),go=(t,n,l)=>{if(l.includes(t))return{component:[],visited:l};const o=[...l,t];return(n.get(t)??[]).reduce((a,s)=>{const r=go(s,n,a.visited);return{component:[...a.component,...r.component],visited:r.visited}},{component:[t],visited:o})},So=(t,n)=>{const l=xr(n);return t.reduce((o,a)=>{if(o.visited.includes(a.id))return o;const s=go(a.id,l,o.visited);return{components:[...o.components,s.component],visited:s.visited}},{components:[],visited:[]}).components},ko=(t,n,l)=>{if(l.visiting.includes(t))return{...l,hasCycle:!0};if(l.visited.includes(t))return l;const o={...l,visiting:[...l.visiting,t]},a=(n.get(t)??[]).reduce((s,r)=>ko(r,n,s),o);return{visiting:a.visiting.filter(s=>s!==t),visited:[...a.visited,t],ordered:[t,...a.ordered],hasCycle:a.hasCycle}},bo=(t,n)=>{const l=ho(n,t);return t.reduce((o,a)=>ko(a,l,o),Hr)},Xr=(t,n)=>t.find(l=>{const o=n.get(l.target);return o!==void 0&&Y(o.data.kind)}),To=t=>"muted"in t.data&&t.data.muted===!0,zr=(t,n)=>t.map(l=>n.get(l)).filter(l=>l!==void 0).filter(l=>Y(l.data.kind)),wo=(t,n,l)=>(n.get(t)??[]).reduce((o,a)=>o.includes(a)?o:wo(a,n,[...o,a]),l),jr=t=>{const n=Math.min(...t.map(l=>l.length));return Array.from({length:n},(l,o)=>o+1).findLast(l=>t.every(o=>o.slice(-l).join()===t[0].slice(-l).join()))??0},We=(t,n,l)=>n.reduce((o,a)=>{const s=l.get(a);return s===void 0?o:Pe(s.data,o)},t),Kr=(t,n,l)=>{const o=zr(t,l),a=o.length>0&&o.every(To),s=ho(n,t),r=bo(t,n).ordered,c=o.flatMap(m=>{const _=Pe(m.data,"");if(_.length===0)return[];const f=wo(m.id,s,[]);return[{nodeId:m.id,pattern:!a&&To(m)?`${_}.hush()`:_,effectIds:r.filter(g=>f.includes(g))}]});if(c.length===0)return null;const i=jr(c.map(m=>m.effectIds));return{label:a?"_$:":"$:",branches:c.map(m=>({nodeId:m.nodeId,pattern:m.pattern,effectIds:m.effectIds.slice(0,m.effectIds.length-i)})),sharedIds:c[0].effectIds.slice(c[0].effectIds.length-i)}},Yr=(t,n,l)=>{var i;const o=t.sharedIds.slice(0,n),a=(i=l.get(t.sharedIds[n]))==null?void 0:i.data,s=t.branches.flatMap(m=>{const _=l.get([...m.effectIds,...o].at(-1)??m.nodeId);return _===void 0?[]:[{tail:_,pattern:We(We(m.pattern,m.effectIds,l),o,l)}]}),r=Eo(s.map(m=>m.tail)).map(m=>{var _;return((_=s.find(f=>f.tail===m))==null?void 0:_.pattern)??""}),c=Wr((a==null?void 0:a.kind)==="arrange"?a.sequence:[],r);return`${t.label} ${We(c,t.sharedIds.slice(n+1),l)}`},qr=(t,n)=>{const l=t.sharedIds.findIndex(a=>{var s;return((s=n.get(a))==null?void 0:s.data.kind)==="arrange"});if(l!==-1)return Yr(t,l,n);const o=t.branches.map(a=>We(a.pattern,a.effectIds,n));return`${t.label} ${We(Zr(o),t.sharedIds,n)}`},hn=(t,n,l)=>So(t,n).flatMap(o=>{const a=Kr(o,n,l);return a===null?[]:[a]}),Zr=t=>t.length===1?t[0]:`stack(${t.join(", ")})`,Lo=t=>{const n=new Map(t.nodes.map(c=>[c.id,c]));if(Xr(t.edges,n)!==void 0)return{code:"",errorMessage:"An instrument cannot take an input. Connect the effect to another effect instead."};if(!t.nodes.some(c=>Y(c.data.kind)))return{code:"",errorMessage:"Add an instrument node such as Pad, Beats, Chords or Code to start a pattern."};if(So(t.nodes,t.edges).find(c=>bo(c,t.edges).hasCycle)!==void 0)return{code:"",errorMessage:"Remove the loop from the flow: an effect cannot feed back into itself."};const a=hn(t.nodes,t.edges,n).map(c=>qr(c,n));if(a.length===0)return{code:"",errorMessage:"The flow makes no sound yet. Turn on a drum step, add notes, or write an expression."};const s=`setcpm(${se(t.beatsPerMinute)}/${Ve(t.beatsPerCycle)})`,r=t.setup.trim();return{code:[s,...r.length>0?[r]:[],...a].join(`
10
+ `),errorMessage:null}},yo=(t,n)=>{const l=new Map(t.map(a=>[a.id,a])),o=hn(t,n,l).flatMap(a=>[...a.branches.flatMap(s=>s.effectIds),...a.sharedIds]).flatMap(a=>{var r;const s=(r=l.get(a))==null?void 0:r.data;return(s==null?void 0:s.kind)==="visualizer"&&s.placement==="inline"?[{nodeId:a,call:`_${s.visual}`}]:[]});return Object.fromEntries(o.map(({nodeId:a,call:s},r)=>{const c=o.slice(0,r).filter(i=>i.call===s).length;return[a,`${qn}${s}_${c}`]}))},Fo=(t,n)=>{const l=new Map(t.map(o=>[o.id,o]));return hn(t,n,l).flatMap(o=>[...o.branches.flatMap(a=>[a.nodeId,...a.effectIds]),...o.sharedIds])},$o=(t,n,l,o=[])=>{if(t===n)return!0;if(o.includes(t))return!1;const a=[...o,t];return l.filter(s=>s.source===t).some(s=>$o(s.target,n,l,a))},dt=(t,n,l,o)=>{if(t===n)return!1;const a=l.find(r=>r.id===t),s=l.find(r=>r.id===n);return a===void 0||s===void 0||Y(s.data.kind)||o.some(r=>r.source===t&&r.target===n)?!1:!$o(n,t,o)},Bo=(t,n,l)=>t.id!==void 0||dt(t.source??"",t.target??"",n,l),gn=()=>({nodes:[{id:"pad-starter",type:"strudel",position:{x:80,y:120},data:ge("pad")},{id:"voice-starter",type:"strudel",position:{x:640,y:120},data:ge("voice")},{id:"filter-starter",type:"strudel",position:{x:640,y:420},data:ge("filter")}],edges:[{id:"pad-starter-voice-starter",source:"pad-starter",target:"voice-starter"},{id:"voice-starter-filter-starter",source:"voice-starter",target:"filter-starter"}],beatsPerMinute:ye,beatsPerCycle:ee,setup:""}),Jr=t=>{if(!q(t))return null;const n=x(t.id,""),l=q(t.position)?t.position:{},o=q(t.data)?t.data:{};return n.length===0||!_o(o.kind)?null:{id:n,type:x(t.type,"strudel"),position:{x:W(l.x,0,-$e,$e),y:W(l.y,0,-$e,$e)},data:po(o.kind,o)}},Qr=t=>Array.isArray(t)?t.flatMap(n=>{const l=Jr(n);return l===null?[]:[l]}).reduce((n,l)=>n.some(o=>o.id===l.id)?n:[...n,l],[]):[],vr=(t,n,l,o)=>{const a=x(t.id,"");return a.length>0&&!o.some(s=>s.id===a)?a:`${n}-${l}`},ec=(t,n,l)=>{if(!q(t))return null;const o=x(t.source,""),a=x(t.target,"");return dt(o,a,n,l)?{id:vr(t,o,a,l),source:o,target:a}:null},tc=(t,n)=>Array.isArray(t)?t.reduce((l,o)=>{const a=ec(o,n,l);return a===null?l:[...l,a]},[]):[],Ro=t=>{if(t===null)return null;try{const n=JSON.parse(t);if(!q(n)||!Array.isArray(n.nodes))return null;const l=Qr(n.nodes);return{nodes:l,edges:tc(n.edges,l),beatsPerMinute:se(W(n.beatsPerMinute,ye,je,Fe)),beatsPerCycle:Ve(W(n.beatsPerCycle,ee,1,Fe)),setup:x(n.setup,"")}}catch{return null}},nc={width:448,height:300},lc={pad:{width:448,height:540},beats:{width:704,height:320},chords:{width:416,height:520},notes:{width:384,height:440},samples:{width:480,height:320},code:{width:448,height:300},arrange:{width:704,height:420},voice:{width:320,height:240},filter:{width:448,height:240},delay:{width:448,height:240},space:{width:448,height:460},gain:{width:256,height:220},level:{width:320,height:220},mask:{width:384,height:240},struct:{width:384,height:240},slow:{width:256,height:220},voicing:{width:256,height:140},envelope:{width:448,height:260},visualizer:{width:384,height:320},effect:{width:320,height:220}},ke=32,oc=40,ac=1e3,mt=t=>lc[t]??nc,Ge=t=>{var l,o;const n=mt(t.data.kind);return{width:((l=t.dimensions)==null?void 0:l.width)??n.width,height:((o=t.dimensions)==null?void 0:o.height)??n.height}},Oo=(t,n)=>t.x<n.x+n.width+ke&&n.x<t.x+t.width+ke&&t.y<n.y+n.height+ke&&n.y<t.y+t.height+ke,No=(t,n)=>Oo({...t.position,...Ge(t)},{...n.position,...Ge(n)}),sc=(t,n)=>{const l=mt(n),o=s=>t.every(r=>!Oo({...s,...l},{...r.position,...Ge(r)}));return Array.from({length:ac},(s,r)=>Array.from({length:Wn},(c,i)=>({x:ce+i*Vn,y:qe+r*oc}))).flat().find(o)??{x:ce,y:qe}},rc=t=>t.position.y+Ge(t).height,cc=t=>t.position.x+Ge(t).width,ic=(t,n)=>{const l=rc(n)+ke-t.position.y,o=cc(n)+ke-t.position.x;return o<l&&t.position.x>=n.position.x?{...t,position:{...t.position,x:t.position.x+o}}:{...t,position:{...t.position,y:t.position.y+l}}},dc=t=>{const n=[...t].sort((l,o)=>l.position.y-o.position.y||l.position.x-o.position.x).reduce((l,o)=>{const a=l.find(s=>No(o,s));return[...l,a===void 0?o:ic(o,a)]},[]);return t.map(l=>n.find(o=>o.id===l.id)??l)},mc=/^(?:const|let|var)\s+([$A-Z_a-z][\w$]*)\s*=\s*([\S\s]+?);?\s*$/,ut=/^[$A-Z_a-z][\w$]*$/,Ao=/^arrange\s*\(([\S\s]*)\)$/,uc=/^([$A-Z_a-z][\w$]*)\s*\(([\S\s]*)\)$/,_c=/^\(([^()]*)\)\s*=>\s*([\S\s]+)$/,pc=new RegExp(`"(?:[^"\\\\]|\\\\.)*"|'(?:[^'\\\\]|\\\\.)*'|(?<![\\w$.])([$A-Z_a-z][\\w$]*)(?![\\w$])`,"g"),Co=/^\[([\S\s]*)]$/,fc=/^([\S\s]+)!(\d+)$/,Ec=new RegExp("(?<![\\w$.])(note|chord)\\(\\s*([$A-Z_a-z][\\w$]*)\\s*\\)","g"),hc="silence",Do="~",Mo=8,gc=8,Sn=t=>/\s/.test(t),kn=(t,n)=>n===0?t:kn(n,t%n),Sc=(t,n)=>t*n/kn(t,n),kc=t=>!t.includes("<")&&!t.includes("/")&&t!=="_"&&te(t,n=>n==="@").length<=1,bc=t=>te(t,Sn).length>1||te(t,n=>n===",").length>1?`[${t}]`:t,Tc=t=>{const n=fc.exec(t);return n===null?[t]:Array.from({length:Number(n[2])},()=>n[1])},wc=t=>t.startsWith("<")&&t.endsWith(">")&&te(t,Sn).length===1&&te(t,n=>n===",").length===1,Lc=t=>{const n=wc(t)?te(t.slice(1,-1),Sn).flatMap(Tc):[bc(t)];return n.length>0&&n.every(kc)?n:null},yc=t=>`<${t.reduce((n,l)=>{const o=n.at(-1);return(o==null?void 0:o.bar)===l?[...n.slice(0,-1),{bar:l,count:o.count+1}]:[...n,{bar:l,count:1}]},[]).map(({bar:n,count:l})=>l>1?`${n}!${l}`:n).join(" ")}>`,Fc=(t,n,l)=>{var _;const o=(_=Co.exec(t.trim()))==null?void 0:_[1],[a,s,...r]=o===void 0?[]:X(o,","),c=Number(a);if(s===void 0||r.length>0||!Number.isInteger(c)||c<1)return null;const i=_t(s,n,l+1),m=i===null?null:Lc(i);return m===null?null:{cycles:c,bars:m}},$c=(t,n,l)=>{const o=X(t,",").map(r=>Fc(r,n,l));if(o.length===0||o.some(r=>r===null))return null;const a=o.filter(r=>r!==null),s=a.reduce((r,{cycles:c,bars:i})=>Sc(r,i.length/kn(c,i.length)),1);return s>gc?null:yc(Array.from({length:s},(r,c)=>c).flatMap(r=>a.flatMap(({cycles:c,bars:i})=>Array.from({length:c},(m,_)=>i[(r*c+_)%i.length]??Do))))},Bc=(t,n)=>t.replace(pc,(l,o)=>o===void 0?l:n.get(o)??l),Rc=(t,n)=>{const l=uc.exec(t),o=l===null?void 0:n.get(l[1]),a=o===void 0?null:_c.exec(o);if(l===null||a===null)return null;const s=X(a[1],","),r=X(l[2],",");return s.length===r.length&&s.every(c=>ut.test(c))?Bc(a[2],new Map(s.map((c,i)=>[c,r[i]]))):null},_t=(t,n,l)=>{var c;const o=t.trim();if(l>Mo)return null;if(o===hc)return Do;if(pe(o))return K(o);const a=ut.test(o)?n.get(o):void 0;if(a!==void 0)return _t(a,n,l+1);const s=(c=Ao.exec(o))==null?void 0:c[1];if(s!==void 0)return $c(s,n,l);const r=Rc(o,n);return r===null?null:_t(r,n,l+1)},Oc=t=>new Map(t.flatMap(n=>{const l=mc.exec(n.trim());return l===null?[]:[[l[1],l[2].trim()]]})),Nc=(t,n)=>t.replace(Ec,(l,o,a)=>{const s=_t(a,n,0);return s===null?l:`${o}(${JSON.stringify(s)})`}),Po=(t,n,l)=>{const o=l>Mo?void 0:n.get(t);return o===void 0?t:ut.test(o)?Po(o,n,l+1):o},Ac=(t,n)=>{var r;const[l,...o]=X(t.trim(),"."),a=(r=Ao.exec(l??""))==null?void 0:r[1];return a===void 0?t:[`arrange(${X(a,",").map(c=>{var g;const i=(g=Co.exec(c.trim()))==null?void 0:g[1],[m,_,...f]=i===void 0?[]:X(i,",");return _===void 0||f.length>0||!ut.test(_.trim())?c:`[${m}, ${Po(_.trim(),n,0)}]`}).join(", ")})`,...o].join(".")},Cc=48,Dc=40,Mc=64,Uo=96,Pc={key:"C",octave:3,scaleType:"major"},Uc="~",Ic=new Map(Be.map(t=>t.value).flatMap(t=>[[`_${t}`,t],[t,t]])),Io=/^(\d*[A-Za-z]\w*(?::\d+)?)(![2-4]|\/[2-4]|@[2-4]|\*[2-4])?$/,Vc={Db:"C#",Eb:"D#",Gb:"F#",Ab:"G#",Bb:"A#"},Wc=new Set(["sound","s"]),Gc="mask",Hc="struct",xc="slow",Xc="voicing",bn=new Set(["s","sound"]),Tn="chord",pt=/^(_?\$|[A-Z_a-z]\w*)\s*:(?!:)\s*/,Vo=/^(const|let|var|function|async|await|import|class)\b/,zc=/^setc(pm|ps)\s*\(([^)]*)\)$/,jc={lpf:{kind:"filter",field:"cutoff"},lpq:{kind:"filter",field:"resonance"},delay:{kind:"delay",field:"mix"},delaytime:{kind:"delay",field:"time"},delayfeedback:{kind:"delay",field:"feedback"},room:{kind:"space",field:"room"},roomsize:{kind:"space",field:"roomSize"},roomfade:{kind:"space",field:"roomFade"},roomlp:{kind:"space",field:"roomLowPass"},roomdim:{kind:"space",field:"roomDim"},gain:{kind:"gain",field:"gain"},pan:{kind:"level",field:"pan"},postgain:{kind:"level",field:"postgain"},attack:{kind:"envelope",field:"attack"},decay:{kind:"envelope",field:"decay"},sustain:{kind:"envelope",field:"sustain"},release:{kind:"envelope",field:"release"}},Wo=t=>{const n=/^\s*([$A-Z_a-z][\w$]*)\s*\(([\S\s]*)\)\s*$/.exec(t);return n===null?null:{name:n[1],argument:n[2].trim()}},Go=t=>{const n=Number(t.trim());return t.trim().length>0&&Number.isFinite(n)?n:null},Ho=t=>Ns(t)?t.slice(1,-1).trim():null,Kc=t=>{const n=/^([A-G][#b]?)(-?\d+):(.+)$/.exec(t);if(n===null)return Pc;const l=Vc[n[1]]??n[1];return{key:ie.some(o=>o.value===l)?l:"C",octave:Math.min(8,Math.max(1,Number(n[2]))),scaleType:de.some(o=>o.value===n[3])?n[3]:"major"}},Yc=t=>{const n=/^\[([^\]]*)](![2-4]|\/[2-4]|@[2-4]|\*[2-4])?$/.exec(t);if(n===null)return null;const l=n[1].split(/[\s,]+/).filter(a=>a.length>0&&a!=="~").map(Number);if(l.some(a=>!Number.isInteger(a)||a<0||a>7))return null;const o=Re.some(a=>a.value===n[2])?n[2]??"":"";return{notes:l,modifier:o}},qc=(t,n)=>{const o=X(t," ").map(Yc);if(o.length===0||o.length>16||o.some(s=>s===null))return null;const a=o.filter(s=>s!==null);return{kind:"pad",steps:a.length,mode:t.includes(",")?"chord":"arp",...n,grid:Array.from({length:16},(s,r)=>Array.from({length:8},(c,i)=>{var m;return((m=a[r])==null?void 0:m.notes.includes(i))??!1})),columnModifiers:Object.fromEntries(a.flatMap((s,r)=>s.modifier.length>0?[[r,s.modifier]]:[]))}},Zc=t=>{if(t==="~")return[];const n=/^\[([^\]]*)]$/.exec(t);if(n===null)return null;const l=X(n[1],",").map(Number);return l.every(o=>Number.isInteger(o)&&o>=0&&o<28)?l:null},Jc=(t,n)=>{if(!t.startsWith("<")||!t.endsWith(">"))return null;const l=X(t.slice(1,-1)," ").map(Zc);if(l.length===0||l.length>16||l.some(r=>r===null))return null;const o=l.filter(r=>r!==null),a=o.map(r=>(r[0]??0)%7),s=o.some((r,c)=>r.join(",")!==[0,2,4].map(i=>i+a[c]).join(","));return{kind:"chords",key:n.key,octave:n.octave,scaleType:n.scaleType==="minor"?"minor":"major",chordProgression:a,...s?{chordNotes:o}:{}}},wn=(t,n)=>({kind:"beats",steps:n,rows:t,showModifiers:t.some(l=>Object.keys(l.modifiers).length>0)}),Qc=t=>{if(t===Uc)return[];const n=/^\[([^\]]+)]$/.exec(t),l=(n===null?[t]:n[1].split(",")).map(o=>Io.exec(o.trim()));return l.every(o=>o!==null)?l.map(o=>({sound:(o==null?void 0:o[1])??"",modifier:(o==null?void 0:o[2])??""})):null},vc=t=>{if(!bn.has(t.name)||!pe(t.argument))return null;const n=K(t.argument).trim().split(/\s+/),l=n.map(Qc);if(n.length>z||l.some(s=>s===null))return null;const o=l.map(s=>s??[]),a=[...new Set(o.flat().map(s=>s.sound))];return a.length===0||a.length>Oe?null:wn(a.map(s=>({...he(s),steps:Array.from({length:z},(r,c)=>(o[c]??[]).some(i=>i.sound===s)),modifiers:Object.fromEntries(o.flatMap((r,c)=>r.filter(i=>i.sound===s&&i.modifier.length>0).map(i=>[c,i.modifier])))})),n.length)},ei=(t,n)=>{if(!bn.has(t.name)||n===void 0||!pe(t.argument))return null;const l=K(t.argument),o=K(n.argument).split(/\s+/);if(!Io.test(l)||o.length>z)return null;const a=o.flatMap((s,r)=>s==="1"?[r]:[]);return wn([he(l,a)],o.length)},xo=t=>{const[n]=t.instruments;return t.instruments.length===1&&t.effects.length===0&&(n==null?void 0:n.kind)==="beats"&&n.muted!==!0?n:null},ti=t=>t.reduce((n,l)=>{const o=n.at(-1),a=o===void 0?null:xo(o),s=xo(l);return a===null||s===null||a.steps!==s.steps||a.rows.length+s.rows.length>Oe?[...n,l]:[...n.slice(0,-1),Z(wn([...a.rows,...s.rows],s.steps))]},[]),Xo=t=>{const n=Ho(t.trim());return n===null?t.trim():Xo(n)},He=t=>({kind:"code",code:Xo(t)}),ni=(t,n)=>n&&Y(t.kind)?Object.assign({},t,{muted:!0}):t,Z=t=>({instruments:[t],effects:[]}),zo=t=>{const n=yn(t);if(n.effects.length===0)return n.branches;const[l]=n.branches;return n.branches.length===1&&l!==void 0?[{...l,effects:[...l.effects,...n.effects]}]:[Z(He(t))]},jo=(t,n)=>t.map(l=>({...l,instruments:l.instruments.map(o=>ni(o,n))})),li=t=>ti(X(t,",").flatMap(zo)),oi=(t,n)=>{const l=n.find(s=>s.name==="scale");if(t.name!=="n"||l===void 0||!pe(t.argument))return null;const o=K(t.argument),a=Kc(K(l.argument));return o.startsWith("<")?Jc(o,a):qc(o,a)},ai=t=>{if(!pe(t.argument))return null;if(t.name==="note")return{kind:"notes",pattern:K(t.argument),notation:"auto"};const n=t.name===Tn?Ws(K(t.argument)):null;return n!==null?n:t.name===Tn?{kind:"notes",pattern:K(t.argument),notation:"names",head:Tn}:bn.has(t.name)?{kind:"samples",pattern:K(t.argument)}:null},Ko=(t,n)=>{const l=t.findIndex(o=>o.name===n);return l===-1?t:[...t.slice(0,l),...t.slice(l+1)]},si=t=>{const n=X(t,",").map(a=>{var _;const s=(_=/^\[([\S\s]*)]$/.exec(a.trim()))==null?void 0:_[1],[r,c,...i]=s===void 0?[]:X(s,","),m=Number(r);return c===void 0||i.length>0||!Number.isInteger(m)||m<1||m>Ft?null:{cycles:m,pattern:c}});if(n.length===0||n.some(a=>a===null))return null;const{parts:l,sequence:o}=Pr(n.filter(a=>a!==null));return l.length===0||l.length>$t?null:{branches:l.map(ri),sequence:o}},ri=t=>{const n=zo(t),[l]=n;return n.length===1&&(l==null?void 0:l.instruments.length)===1?l:Z(He(t))},ci=(t,n)=>{const l=Wo(t);if(l===null)return{branches:[Z(He(t))],remaining:n};const o=ei(l,n.find(i=>i.name==="struct"));if(o!==null)return{branches:[Z(o)],remaining:Ko(n,"struct")};const a=oi(l,n);if(a!==null)return{branches:[Z(a)],remaining:Ko(n,"scale")};if(l.name==="stack")return{branches:li(l.argument),remaining:n};const s=l.name==="arrange"?si(l.argument):null;if(s!==null)return{branches:s.branches,remaining:n,effects:[{kind:"arrange",sequence:s.sequence}]};const r=vc(l);if(r!==null)return{branches:[Z(r)],remaining:n};const c=ai(l);return{branches:[Z(c??He(t))],remaining:n}},Yo=(t,n,l)=>Object.assign({},t,{[n]:l}),ii=(t,n)=>[...t.slice(0,-1),n],di=(t,n)=>({...t,effects:[...t.effects,{kind:"effect",calls:[{method:n.name,argument:n.argument}]}],fieldsOnLast:[]}),Ln={[Gc]:t=>t.argument.length>0?{kind:"mask",argument:t.argument}:null,[Hc]:t=>t.argument.length>0?{kind:"struct",argument:t.argument}:null,[xc]:t=>{const n=Go(t.argument);return n===null?null:{kind:"slow",amount:n}},[Xc]:t=>t.argument.length===0?{kind:"voicing"}:null},mi=t=>{if(Wc.has(t.name)&&pe(t.argument))return{kind:"voice",sound:K(t.argument)};const n=Ic.get(t.name);return n===void 0?null:{kind:"visualizer",visual:n,placement:t.name.startsWith("_")?"inline":"background",options:t.argument}},ui=t=>{var n;return((n=Ln[t.name])==null?void 0:n.call(Ln,t))??mi(t)},_i=(t,n)=>{const l=ui(n);if(l!==null)return{...t,effects:[...t.effects,l],fieldsOnLast:[]};const o=jc[n.name],a=Go(n.argument);if(o===void 0||a===null)return di(t,n);const s=t.effects.at(-1);return(s==null?void 0:s.kind)===o.kind&&!t.fieldsOnLast.includes(o.field)?{...t,effects:ii(t.effects,Yo(s,o.field,a)),fieldsOnLast:[...t.fieldsOnLast,o.field]}:{...t,effects:[...t.effects,Yo(ge(o.kind),o.field,a)],fieldsOnLast:[o.field]}},qo=(t,n)=>{const l=n.some(a=>a.name==="hush"),o=n.filter(a=>a.name!=="hush").reduce(_i,{...t,fieldsOnLast:[]});return{branches:jo(o.branches,l),effects:o.effects}},yn=t=>{const n=X(t,"."),l=n.slice(1).map(Wo);if(n.length===0||l.some(c=>c===null))return{branches:[Z(He(t))],effects:[]};const o=l.filter(c=>c!==null),a=Ho(n[0]);if(a!==null)return qo(yn(a),o);const s=ci(n[0],o.filter(c=>c.name!=="hush")),r=o.some(c=>c.name==="hush");return qo({branches:s.branches,effects:s.effects??[]},r?[...s.remaining,{name:"hush",argument:""}]:s.remaining)},pi=t=>t.split("/").map(n=>Number(n.trim())),Fn=t=>{const n=zc.exec(t);if(n===null)return null;const l=pi(n[2]);if(l.some(s=>!Number.isFinite(s)||s<=0))return null;if(n[1]==="pm"&&l.length===2)return{beatsPerMinute:se(l[0]),beatsPerCycle:Ve(l[1])};const o=l.slice(1).reduce((s,r)=>s/r,l[0]),a=n[1]==="pm"?o:o*60;return{beatsPerMinute:se(a*ee),beatsPerCycle:ee}},fi=t=>{const n=to(en(t)),l=n.map(Fn).find(c=>c!==null)??{beatsPerMinute:ye,beatsPerCycle:ee},o=n.filter(c=>Fn(c)===null),a=o.filter(c=>pt.test(c));if(a.length>0)return{blocks:a.map(c=>({expression:c.replace(pt,""),muted:c.startsWith("_")})),setup:o.filter(c=>!pt.test(c)),tempo:l};const s=o.at(-1),r=s!==void 0&&!Vo.test(s);return{blocks:r?[{expression:s,muted:!1}]:[],setup:r?o.slice(0,-1):o,tempo:l}},Ei=(t,n)=>{const l=t.reusable.findIndex(o=>o.data.kind===n);return l===-1?{node:null,reusable:t.reusable}:{node:t.reusable[l],reusable:[...t.reusable.slice(0,l),...t.reusable.slice(l+1)]}},hi=(t,n)=>t.kind==="notes"&&(n==null?void 0:n.data.kind)==="notes"&&n.data.head===t.head?{...t,notation:n.data.notation,...n.data.showPattern===!0?{showPattern:!0}:{}}:t,gi=(t,n)=>{const l=new Set(n.map(a=>a.id)),o=Array.from({length:n.length+1},(a,s)=>s+1).find(a=>!l.has(`${t}-${a}`))??n.length+1;return`${t}-${o}`},Zo=(t,n,l)=>{var s;const o=Ei(t,n.kind),a=gi(n.kind,t.nodes);return{nodeId:a,state:{...t,reusable:o.reusable,layoutPositions:o.node===null?t.layoutPositions:{...t.layoutPositions,[a]:l},nodes:[...t.nodes,{id:a,type:"strudel",position:((s=o.node)==null?void 0:s.position)??l,data:hi(n,o.node)}]}}},Si=(t,n,l)=>({...t,edges:[...t.edges,{id:`${n}-${l}`,source:n,target:l}]}),ki=t=>t.kind==="effect"?Mc+t.calls.length*Dc:0,ft=t=>mt(t.kind).height+ki(t)+Cc,bi=t=>Math.max(t.instruments.reduce((n,l)=>n+ft(l),0),...t.effects.map(ft)),Jo=t=>mt(t.kind).width,Qo=(t,n,l)=>n.reduce((o,a)=>{const s=Zo(o.state,a,{x:o.nextX,y:l});return{state:o.previousIds.reduce((r,c)=>Si(r,c,s.nodeId),s.state),previousIds:[s.nodeId],nextX:o.nextX+Jo(a)+Uo}},t),Ti=(t,n,l)=>{const o=n.instruments.reduce((s,r)=>{const c=Zo(s.state,r,{x:ce,y:s.y});return{state:c.state,previousIds:[...s.previousIds,c.nodeId],y:s.y+ft(r)}},{state:t,previousIds:[],y:l}),a=Math.max(0,...n.instruments.map(Jo));return Qo({state:o.state,previousIds:o.previousIds,nextX:ce+a+Uo},n.effects,l)},wi=(t,n)=>{const l=n.branches.reduce((s,r)=>{const c=Ti(s.state,r,s.y);return{state:c.state,tails:[...s.tails,...c.previousIds],y:s.y+bi(r),rightEdge:Math.max(s.rightEdge,c.nextX)}},{state:t,tails:[],y:t.rowTop,rightEdge:ce}),o=Qo({state:l.state,previousIds:l.tails,nextX:l.rightEdge},n.effects,t.rowTop),a=Math.max(0,...n.effects.map(ft));return{...o.state,rowTop:Math.max(l.y,t.rowTop+a)}},vo=(t,n)=>{const l=r=>r.id in n,o=t.find(r=>l(r)&&t.some(c=>!l(c)&&No(r,c)));if(o===void 0)return t;const{[o.id]:a,...s}=n;return vo(t.map(r=>r.id===o.id?{...r,position:a}:r),s)},Li=(t,n)=>{const l=o=>o.map(a=>a.data.kind).sort().join(",");return l(t)===l(n)},ea=(t,n=[])=>{if(!Os(t))return null;const l=fi(t),o=Oc(l.setup),a=c=>l.blocks.map(i=>{const m=yn(Nc(Ac(i.expression,o),o));return{...m,branches:jo(m.branches,i.muted)}}).reduce(wi,{nodes:[],edges:[],reusable:c,layoutPositions:{},rowTop:qe}),s=a([]),r=Li(s.nodes,n)?a(n):s;return{nodes:vo(r.nodes,r.layoutPositions),edges:r.edges,beatsPerMinute:l.tempo.beatsPerMinute,beatsPerCycle:l.tempo.beatsPerCycle,setup:l.setup.join(`
11
+ `)}},yi=t=>{const n=en(t),l=to(n).filter(m=>Fn(m)===null),o=l.at(-1);if(o===void 0||Vo.test(o)||l.some(m=>pt.test(m)))return t;const a=n.lastIndexOf(o.split(`
12
+ `)[0]),s=n.slice(0,a).split(`
13
+ `).length-1,r=a-(n.lastIndexOf(`
14
+ `,a-1)+1),c=t.split(`
15
+ `),i=c[s];return[...c.slice(0,s),`${i.slice(0,r)}$: ${i.slice(r)}`,...c.slice(s+1)].join(`
16
+ `)},Fi=(t,n)=>{const l=t.trimEnd();return l.length===0?n:`${yi(l)}
17
+
18
+ ${n}`},$i=()=>Ro(Yl(wt))??gn(),ta=(t,n,l)=>n.some(o=>o.id===`${t}-${l}`)?ta(t,n,l+1):`${t}-${l}`,Bi=t=>({...t,nodes:t.nodes.map(n=>({id:n.id,type:n.type,position:{x:n.position.x,y:n.position.y},data:n.data})),edges:t.edges.map(n=>({id:n.id,source:n.source,target:n.target}))}),Ri=()=>{const t=$i(),n=e.ref(t.nodes),l=e.ref(t.edges),o=e.ref(t.beatsPerMinute),a=e.ref(t.beatsPerCycle),s=e.ref(t.setup),r=()=>({nodes:n.value,edges:l.value,beatsPerMinute:o.value,beatsPerCycle:a.value,setup:s.value}),c=u=>{n.value=u.nodes,l.value=u.edges,o.value=u.beatsPerMinute,a.value=u.beatsPerCycle,s.value=u.setup},i=e.computed(()=>Lo(r())),m=u=>{n.value=[...n.value,{id:ta(u,n.value,1),type:"strudel",position:sc(n.value,u),data:ge(u)}]},_=(u,S)=>{n.value=n.value.map(T=>T.id===u?{...T,data:S}:T)},f=u=>{n.value=n.value.filter(S=>S.id!==u),l.value=l.value.filter(S=>S.source!==u&&S.target!==u)},g=(u,S)=>dt(u,S,n.value,l.value)?(l.value=[...l.value,{id:`${u}-${S}`,source:u,target:S}],!0):!1,h=u=>{o.value=se(u)},k=u=>{a.value=Ve(u)},E=()=>{c(gn())},p=u=>{const S=ea(u,n.value);return S===null?!1:(c(S),!0)};return e.watch([n,l,o,a,s],()=>{ql(wt,JSON.stringify(Bi(r())))},{deep:!0}),{nodes:n,edges:l,beatsPerMinute:o,beatsPerCycle:a,compilation:i,addNode:m,updateNodeData:_,removeNode:f,connectNodes:g,setBeatsPerMinute:h,setBeatsPerCycle:k,resetPatch:E,loadCode:p}},Oi=/^([a-g])([#bfs]*)(-?\d+)?$/i,Ni=/^-?\d+(\.\d+)?$/,xe=12,Ai=1e-6,na=t=>{const n=(t%xe+xe)%xe;return{...Fl[n],octave:Math.floor(t/xe)-1,midiNote:t}},Et=t=>{if(Ni.test(t))return na(Math.round(Number(t)));const n=Oi.exec(t);if(n===null)return null;const[,l,o,a]=n,s=[...o].reduce((c,i)=>c+(Ll.includes(i)?1:-1),0),r=Number(a??wl);return{letter:l.toLowerCase(),alteration:s,octave:r,midiNote:(r+1)*xe+Tl[l.toLowerCase()]+s}},ne=t=>{var n;return((n=Et(t))==null?void 0:n.midiNote)??null},la=t=>{const n=Array.from({length:yl},(o,a)=>a+1).find(o=>Math.abs(t*o-Math.round(t*o))<Ai*o);if(n===void 0)return String(Math.round(t*100)/100);const l=Math.round(t*n);return n===1?String(l):`${l}/${n}`},oa=t=>{const{letter:n,alteration:l,octave:o}=na(t);return`${n}${l>0?"#":""}${o}`},Ci=(t,n)=>n.flatMap((l,o)=>{const a=t-l;return a>=0&&a<=vn?[{lineIndex:o,fret:a}]:[]}),Di=t=>t.reduce((n,l)=>n.flatMap(o=>l.filter(a=>!o.some(s=>s.lineIndex===a.lineIndex)).map(a=>[...o,a])),[[]]),Mi=t=>{const n=t.filter(l=>l.fret>0).map(l=>l.fret);return n.length===0||Math.max(...n)-Math.min(...n)<=el},aa=(t,n)=>t.reduce((l,o)=>l+Math.abs(o.fret-n),0),sa=(t,n)=>{const l=Di(t);if(l.length===0)return sa(t.slice(0,-1),n);const o=l.filter(Mi);return(o.length>0?o:l).reduce((a,s)=>aa(s,n)<aa(a,n)?s:a)},ra=(t,n)=>t.reduce((l,o)=>{const a=o.toSorted((c,i)=>c-i).map(c=>Ci(c,n)).filter(c=>c.length>0),s=a.length===0?[]:sa(a,l.handFret),r=s.length===0?l.handFret:s.reduce((c,i)=>c+i.fret,0)/s.length;return{chords:[...l.chords,s],handFret:r}},{chords:[],handFret:0}).chords,$n=t=>{var n;return((n=tl.find(l=>t.toLowerCase().includes(l.word)))==null?void 0:n.view)??"names"},ca=(t,n)=>t==="auto"?$n(n):t,ia=(t,n,l,o)=>{const a=l.filter(c=>c.source===t&&!o.has(c.target)).map(c=>c.target),s=a.map(c=>{var i;return(i=n.find(m=>m.id===c))==null?void 0:i.data}).find(c=>(c==null?void 0:c.kind)==="voice");if((s==null?void 0:s.kind)==="voice")return s.sound;const r=new Set([...o,...a]);return a.reduce((c,i)=>c.length>0?c:ia(i,n,l,r),"")},da=(t,n,l)=>ia(t,n,l,new Set([t])),ma=t=>{const n=t.toSorted((l,o)=>l.start-o.start);return n.map((l,o)=>{var s;const a=((s=n[o+1])==null?void 0:s.start)??1/0;return{...l,beats:Math.min(l.beats,a-l.start)}})},Bn=(t,n)=>t.reduce((l,o,a)=>{const s=t[a-1];return s!==void 0&&n(s,o)?[...l.slice(0,-1),[...l.at(-1),o]]:[...l,[o]]},[]),be=1e-6,I=nl,ua=Ae.length-1,_a=t=>Math.floor(t.start+be),Pi=t=>Ae.findIndex(n=>Math.abs(n*Mt/Pt-t)<be),Ui=(t,n)=>{const l=t+n,o=Math.floor(t+be)+1,a=Array.from({length:Math.max(0,Math.ceil(l-be)-o)},(r,c)=>o+c),s=[t,...a,l];return s.slice(1).map((r,c)=>({start:s[c],beats:r-s[c]}))},Ii=t=>Ae.reduce((n,l)=>{const o=Math.floor((n.left+be)/l);return{left:n.left-o*l,lengths:[...n.lengths,...Array.from({length:o},()=>l)]}},{left:t,lengths:[]}).lengths,Vi=t=>{const n=Pi(t.beats);if(n!==-1)return[{start:t.start,beats:t.beats,beams:n,isTriplet:!0}];const l=Ui(t.start,t.beats).flatMap(o=>Ii(o.beats).reduce((a,s)=>{const r=a.reduce((c,i)=>c+i.beats,o.start);return[...a,{start:r,beats:s,beams:Ae.indexOf(s),isTriplet:!1}]},[]));return l.length>0?l:[{start:t.start,beats:t.beats,beams:ua,isTriplet:!1}]},Wi=(t,n)=>{const l=t.map(ma),o=l.flat().map(r=>r.notes.flatMap(c=>{const i=ne(c);return i===null?[]:[i]})),a=ra(o,n),s=l.map((r,c)=>l.slice(0,c).reduce((i,m)=>i+m.length,0));return l.map((r,c)=>r.map((i,m)=>({...i,positions:a[s[c]+m]})))},pa=t=>(Qe+_l*t)*I,Rn=(t,n)=>n>be?{...t,x:t.x+pa(n),restXs:[...t.restXs,t.x+Qe/2*I]}:t,Gi=(t,n,l)=>{const o=Rn(t,n.start-t.beat),a=n.start+n.beats;if(n.positions.length===0)return{...Rn(o,n.beats),beat:a};const s=Vi(n).reduce((r,c,i)=>{var m;return{x:r.x+pa(c.beats),units:[...r.units,{...c,x:r.x+Qe/2*I,barIndex:l,positions:n.positions,tiedFromX:i===0?null:((m=r.units.at(-1))==null?void 0:m.x)??null}]}},{x:o.x,units:[]});return{...o,beat:a,x:s.x,units:[...o.units,...s.units]}},Hi=(t,n,l,o)=>{const a=t.reduce((s,r)=>Gi(s,r,n),{beat:0,x:l,units:[],restXs:[]});return Rn(a,o-a.beat)},xi=(t,n,l)=>t.reduce((o,a,s)=>{var g;const r=((g=o.at(-1))==null?void 0:g.endX)??n,c=s===0,i=s===t.length-1,m=r+(c?Nt*I:0),_=Hi(a,s,m,l),f=Math.max(_.x+(i?Nt*I:0),r+It*I);return[...o,{units:_.units,restXs:_.restXs,endX:f}]},[]),Xi=(t,n)=>t-(At/2+(n-1)*sl)*I,zi=(t,n)=>Array.from({length:ua},(l,o)=>o+1).flatMap(l=>{const o=Xi(n,l);return Bn(t,(s,r)=>s.beams>=l&&r.beams>=l).filter(s=>s[0].beams>=l).map(s=>{if(s.length>1)return{x1:s[0].x,y1:o,x2:s.at(-1).x,y2:o};const r=s[0]===t[0]?1:-1;return{x1:s[0].x,y1:o,x2:s[0].x+r*rl*I,y2:o}})}),ji=(t,n)=>Bn(t,(l,o)=>l.beams>0&&o.beams>0&&l.barIndex===o.barIndex&&_a(l)===_a(o)).filter(l=>l[0].beams>0).flatMap(l=>zi(l,n)),Ki=(t,n)=>Bn(t,(l,o)=>l.isTriplet&&o.isTriplet&&l.barIndex===o.barIndex).filter(l=>l[0].isTriplet).map(l=>{const o=l[0].x-Ce*I,a=l.at(-1).x+Ce*I,s=(o+a)/2,r=n-Ht*I,c=Gt*I;return{labelX:s,path:[`M ${o} ${r} L ${o} ${n} L ${s-c} ${n}`,`M ${s+c} ${n} L ${a} ${n} L ${a} ${r}`].join(" ")}}),Yi=(t,n,l)=>{const o=l+dl*I,a=l+ml*I,s=t+Ct*I,r=n-ul*I;return`M ${s} ${o} Q ${(s+r)/2} ${a} ${r} ${o}`},qi=(t,n)=>{const l=[...String(t)],o=n-(l.length-1)*Dt*I/2;return l.map((a,s)=>({digit:a,x:o+s*Dt*I}))},fa=t=>String(t).length*Ct*I/2+il*I,Zi=(t,n,l,o,a)=>{const r=l.filter(c=>c.lineIndex===t).map(c=>[c.x-fa(c.fret),c.x+fa(c.fret)]).toSorted((c,i)=>c[0]-i[0]).reduce((c,[i,m])=>({fromX:Math.max(c.fromX,m),segments:i>c.fromX?[...c.segments,{x1:c.fromX,y1:n,x2:i,y2:n}]:c.segments}),{fromX:o,segments:[]});return[...r.segments,{x1:r.fromX,y1:n,x2:a,y2:n}]},Ea=(t,n,l)=>{var k;const o=Qn[n],a=o.map((E,p)=>(ll+p)*I),s=a.at(-1),r=I/2,c=xi(Wi(t,o),r,l),i=((k=c.at(-1))==null?void 0:k.endX)??r+It*I,m=c.flatMap(E=>E.units),_=s+al*I,f=s+cl*I,g=m.filter(E=>E.tiedFromX===null).flatMap(E=>E.positions.map(p=>({...p,x:E.x,y:a[p.lineIndex],digits:qi(p.fret,E.x)}))),h=m.flatMap(E=>E.tiedFromX===null?[]:E.positions.map(p=>Yi(E.tiedFromX,E.x,a[p.lineIndex])));return{width:i+I/2,height:s+bl*I,lineGap:I,strings:a.map((E,p)=>Zi(p,E,g,r,i)),barLines:[r,...c.map(E=>E.endX)].map(E=>({x1:E,y1:a[0],x2:E,y2:s})),frets:g,stems:m.map(E=>({x:E.x})),rests:c.flatMap(E=>E.restXs).map(E=>({x:E-Vt/2*I,y:(a[0]+s-Wt*I)/2,width:Vt*I,height:Wt*I})),beams:ji(m,_),ties:h,brackets:Ki(m,f),stemTop:s+ol*I,stemBottom:_,bracketLabelY:f+Xt*I}},ht=1e-6,$=Nl,J=$/2,Ji=zt.length,ha=4,On=8,Qi=Mt/Pt,ga=ue[0].beats,vi=ue.at(-1).beats,ed=ue.flatMap(t=>[{beats:t.beats*Bl,value:t.beats,dotted:!0},{beats:t.beats,value:t.beats,dotted:!1}]).filter(t=>t.beats<=ga+ht).toSorted((t,n)=>n.beats-t.beats),Sa=t=>{const n=ed.find(l=>l.beats<=t+ht);return n===void 0?[]:[{...n,isTriplet:!1},...Sa(t-n.beats)]},ka=t=>{var o;const n=(o=ue.find(a=>Math.abs(a.beats*Qi-t)<ht))==null?void 0:o.beats;if(n!==void 0)return[{beats:t,value:n,dotted:!1,isTriplet:!0}];const l=Sa(t);return l.length>0?l:[{beats:t,value:vi,dotted:!1,isTriplet:!1}]},gt=t=>zt.indexOf(t.letter)+Ji*t.octave,td=t=>{const n=t.length===0||t.some(a=>a.midiNote>=ve),l=t.some(a=>a.midiNote<ve);return[...n?["treble"]:[],...l?["bass"]:[]].map((a,s)=>{const r=(Al+s*Dl)*$;return{clef:a,topY:r,bottomY:r+On*J,bottomStep:$l[a]}})},nd=(t,n)=>n.length===1||t.midiNote>=ve?0:1,ba=(t,n)=>t>ht?ka(t).map(l=>({unit:l,notesByStaff:Array.from({length:n},()=>[]),isFirstUnit:!0,tiedForward:!1})):[],ld=(t,n,l)=>{const o=ma(t).reduce((a,s)=>{const r=s.notes.flatMap(m=>{const _=Et(m);return _===null?[]:[_]}),c=n.map((m,_)=>r.filter(f=>nd(f,n)===_)),i=ka(s.beats);return{beat:s.start+s.beats,columns:[...a.columns,...ba(s.start-a.beat,n.length),...i.map((m,_)=>({unit:m,notesByStaff:c,isFirstUnit:_===0,tiedForward:_<i.length-1}))]}},{beat:0,columns:[]});return[...o.columns,...ba(l-o.beat,n.length)]},od=t=>t>0?"sharp":t<0?"flat":"natural",ad=(t,n)=>{const l=Array.from({length:Math.max(0,Math.floor(-n/2))},(a,s)=>-2*(s+1)),o=Array.from({length:Math.max(0,Math.floor((n-On)/2))},(a,s)=>On+2*(s+1));return[...l,...o].map(a=>t.bottomY-a*J)},sd=(t,n,l,o)=>t.toSorted((a,s)=>gt(a)-gt(s)).reduce((a,s)=>{const r=String(gt(s)),c=gt(s)-n.bottomStep,i=o&&(a.signs.get(r)??0)!==s.alteration;return{signs:i?new Map(a.signs).set(r,s.alteration):a.signs,heads:[...a.heads,{y:n.bottomY-c*J,step:c,accidental:i?od(s.alteration):null,ledgerYs:ad(n,c)}]}},{heads:[],signs:l}),rd=(t,n,l)=>`M ${t} ${n} c ${.1*$} ${l*.8*$} ${1.1*$} ${l*$} ${.9*$} ${l*2*$}`,cd=(t,n,l,o)=>{const a=ue.find(f=>f.beats===n.unit.value),s=t.reduce((f,g)=>f+g.step,0)/t.length<ha,r=t.map(f=>f.y),c=s?-1:1,i=o+(s?1:-1)*jt*$,m=s?Math.max(...r):Math.min(...r),_=(s?Math.min(...r):Math.max(...r))+c*Wl*$;return{x:o,staffIndex:l,heads:t.map(({y:f,accidental:g,ledgerYs:h})=>({y:f,accidental:g,ledgerYs:h})),filled:a.filled,stem:a.stem?{x1:i,y1:m,x2:i,y2:_}:null,flags:Array.from({length:a.flags},(f,g)=>rd(i,_-c*g*Gl*$,-c)),dots:n.unit.dotted?t.map(f=>({x:o+xl*$,y:f.step%2===0?f.y-J:f.y})):[],isTriplet:n.unit.isTriplet,tiedForward:n.tiedForward}},id=(t,n,l)=>{const o=l.topY+ha*J;if(t>=2){const r=t===ga?l.topY+$:o-J;return`M ${n-.6*$} ${r} h ${1.2*$} v ${J} h ${-1.2*$} Z`}if(t===1)return`M ${n-.2*$} ${o-1.5*$} l ${.6*$} ${.8*$} l ${-.5*$} ${.6*$} l ${.5*$} ${.8*$} c ${-.6*$} ${-.3*$} ${-.9*$} ${.2*$} ${-.3*$} ${.8*$}`;const a=Math.round(Math.log2(1/t));return[...Array.from({length:a},(r,c)=>{const i=o-.6*$+c*.7*$,m=n-.35*$,_=.16*$;return[`M ${m-_} ${i} a ${_} ${_} 0 1 0 ${2*_} 0 a ${_} ${_} 0 1 0 ${-2*_} 0`,`M ${m} ${i+_} q ${.4*$} ${.15*$} ${.75*$} ${-.25*$}`].join(" ")}),`M ${n+.4*$} ${o-.8*$} L ${n-.1*$} ${o+1.2*$}`].join(" ")},dd=(t,n,l)=>{const o=t.stem===null||t.stem.y2<t.stem.y1?1:-1,a=t.x+tt*$,s=n.x-tt*$,r=l+o*tt*$,c=r+o*Xl*$;return`M ${a} ${r} Q ${(a+s)/2} ${c} ${s} ${r}`},md=t=>(et+Pl*t.beats)*$,ud=(t,n,l)=>{const o=l.map((_,f)=>sd(n.notesByStaff[f],_,t.signs,n.isFirstUnit)),a=o.some(_=>_.heads.some(f=>f.accidental!==null)),s=t.x+(a?Ul*$:0)+et/2*$,r=o.reduce((_,f)=>new Map([..._,...f.signs]),t.signs),c=l.map((_,f)=>o[f].heads.length===0?{chord:null,rest:{x:s,staffIndex:f,beats:n.unit.value,dotted:n.unit.dotted,isTriplet:n.unit.isTriplet,path:id(n.unit.value,s,_),solid:n.unit.value>=2}}:{chord:cd(o[f].heads,n,f,s),rest:null}),i=c.flatMap((_,f)=>{const g=t.lastChordByStaff[f];return _.chord!==null&&!n.isFirstUnit&&g!==null?_.chord.heads.map(h=>dd(g,_.chord,h.y)):[]}),m=t.tripletXs.at(-1);return{x:s+md(n.unit)-et/2*$,chords:[...t.chords,...c.flatMap(_=>_.chord===null?[]:[_.chord])],rests:[...t.rests,...c.flatMap(_=>_.rest===null?[]:[_.rest])],ties:[...t.ties,...i],tripletXs:n.unit.isTriplet?[...t.tripletXs.slice(0,-1),[...m??[],s]]:m===void 0||m.length>0?[...t.tripletXs,[]]:t.tripletXs,signs:r,lastChordByStaff:c.map(_=>_.chord)}},_d=(t,n)=>{const l=t[0]-Ce*$,o=t.at(-1)+Ce*$,a=(l+o)/2,s=n+Ht*$,r=Gt*$;return{labelX:a,path:[`M ${l} ${s} L ${l} ${n} L ${a-r} ${n}`,`M ${a+r} ${n} L ${o} ${n} L ${o} ${s}`].join(" ")}},Ta=(t,n)=>{const l=t.flat().flatMap(i=>i.notes.flatMap(m=>{const _=Et(m);return _===null?[]:[_]})),o=td(l),a=J,s=t.reduce((i,m)=>{const _=i.x,f=ld(m,o,n).reduce((h,k)=>ud(h,k,o),{x:_,chords:[],rests:[],ties:[],tripletXs:[],signs:new Map,lastChordByStaff:o.map(()=>null)}),g=Math.max(f.x+$,_+Il*$);return{x:g,barEndXs:[...i.barEndXs,g],chords:[...i.chords,...f.chords],rests:[...i.rests,...f.rests],ties:[...i.ties,...f.ties],tripletXs:[...i.tripletXs,...f.tripletXs]}},{x:a+Ml*$,barEndXs:[],chords:[],rests:[],ties:[],tripletXs:[]}),r=s.barEndXs.at(-1)??s.x,c=o[0].topY-zl*$;return{width:r+J,height:o.at(-1).bottomY+Cl*$,lineGap:$,staves:o,staffStartX:a,staffEndX:r,barEndXs:s.barEndXs,chords:s.chords,rests:s.rests,ties:s.ties,brackets:s.tripletXs.filter(i=>i.length>0).map(i=>_d(i,c)),bracketLabelY:c+Xt*$}},pd=new Set(["[","<","(","{"]),fd=new Set(["]",">",")","}"]),Ed=new Set(["~","-"]),hd=/^([\dA-Za-z][\w.]*(?::\d+)?)(.*)$/,wa=/^(?:[!*/@]\d*\.?\d+|!|\?\d*\.?\d*|\(\s*\d+\s*(?:,\s*\d+\s*){1,2}\))*$/,La={subdivide:["[","]"],alternate:["<",">"]},gd=(t,n)=>[...t].reduce((l,o,a)=>{if(l.closedAt!==-1)return l;const s=l.depth+(pd.has(o)?1:fd.has(o)?-1:0);return{depth:s,closedAt:s===0&&o===n?a:-1}},{depth:0,closedAt:-1}).closedAt,Sd=t=>{const n=t.startsWith("[")?"subdivide":t.startsWith("<")?"alternate":null;if(n===null)return null;const l=gd(t,La[n][1]),o=t.slice(l+1);return l===-1||!wa.test(o)?null:{kind:"group",bracket:n,layers:Nn(t.slice(1,l)),modifier:o}},kd=t=>{if(Ed.has(t))return{kind:"rest"};const n=Sd(t);if(n!==null)return n;const l=hd.exec(t);return l!==null&&wa.test(l[2])?{kind:"sound",sound:l[1],modifier:l[2]}:{kind:"text",text:t}},Nn=t=>te(t,n=>n===",").map(n=>te(n,l=>/\s/.test(l)).map(kd)),bd=t=>{if(t.kind==="rest")return"~";if(t.kind==="text")return t.text;if(t.kind==="sound")return`${t.sound}${t.modifier}`;const[n,l]=La[t.bracket];return`${n}${An(t.layers)}${l}${t.modifier}`},An=t=>t.map(n=>n.map(bd).join(" ")).filter(n=>n.length>0).join(", "),Cn={id:"other",label:"Other",match:""},Dn=t=>qt.find(n=>new RegExp(n.match).test(t.toLowerCase()))??Cn,Td=["s","sound"],ya="input",wd=/^\(?\s*([$A-Z_a-z][\w$]*)\s*\(/,Ld=new RegExp(`^${ya}\\.([$A-Z_a-z][\\w$]*)\\(`),yd=t=>{var o;const n=t.data;if(n.kind==="beats"||n.kind==="samples"||n.kind==="voice")return{chained:n.kind==="voice",names:Td};if(n.kind!=="effect")return null;const l=((o=n.calls[0])==null?void 0:o.method.trim())??"";return{chained:!0,names:l.length===0?[]:[l]}},Fd=t=>{var s;const n=yd(t);if(n!==null)return n.names.length===0?null:n;const l=Y(t.data.kind),o=Pe(t.data,l?"":ya),a=(s=(l?wd:Ld).exec(o))==null?void 0:s[1];return a===void 0?null:{chained:!l,names:[a]}},$d=t=>`${t.chained}:${[...t.names].sort().join(",")}`,Bd=t=>t.data.kind==="beats"?Math.max(1,t.data.rows.filter(n=>n.steps.some(l=>l)).length):1,Rd=t=>{const n=en(t).split(`
19
+ `);return t.split(`
20
+ `).map((l,o)=>(n[o]??"").padEnd(l.length)).join(`
21
+ `)},Od=(t,n)=>[...t.slice(n)].reduce((l,o,a)=>{if(l.end!==-1)return l;const s=l.depth+(o==="("?1:o===")"?-1:0);return{depth:s,end:s===0?n+a+1:-1}},{depth:0,end:-1}).end,Nd=(t,n)=>{const l=n.names.map(s=>s.replace(/\$/g,"\\$")).join("|"),o=n.chained?"\\.\\s*":"(?<![\\w$.])",a=new RegExp(`${o}(${l})\\s*\\(`,"g");return[...t.matchAll(a)].flatMap(s=>{const r=(s.index??0)+s[0].indexOf(s[1]),c=Od(t,(s.index??0)+s[0].length-1);return c===-1?[]:[{from:r,to:c}]})},Fa=(t,n,l)=>{const o=new Map(n.map(c=>[c.id,c])),a=Rd(t),s=Fo(n,l).flatMap(c=>{const i=o.get(c),m=i===void 0?null:Fd(i);return i===void 0||m===null?[]:[{nodeId:c,key:m,id:$d(m),count:Bd(i)}]}),r=Object.fromEntries(s.map(c=>[c.id,Nd(a,c.key)]));return s.flatMap((c,i)=>{const m=s.slice(0,i).reduce((_,f)=>_+(f.id===c.id?f.count:0),0);return(r[c.id]??[]).slice(m,m+c.count).map(_=>({..._,nodeId:c.nodeId}))})},Ad=(t,n,l,o)=>{const a=Fa(t,n,l).find(s=>s.nodeId===o);return a===void 0?null:{from:a.from,to:a.to}},Cd=t=>t.reduce((n,l)=>n===null||l.from<n.from?l:n,null),$a=(t,n,l,o=[])=>{const a=t.get(l);if(a===void 0||o.includes(l))return[];if(Y(a.data.kind))return[l];const s=[...o,l];return n.filter(r=>r.target===l).flatMap(r=>$a(t,n,r.source,s))},Dd=(t,n,l,o)=>{const a=new Map(l.map(i=>[i.id,i])),s=i=>{const m=a.get(i.nodeId);return m!==void 0&&Y(m.data.kind)},r=i=>t.filter(m=>m.from<=i&&i<m.to).reduce((m,_)=>m===null||_.to-_.from<m.to-m.from?_:m,null),c=n.flatMap(i=>{const m=i.flatMap(g=>r(g)??[]),_=Cd(m.filter(s));if(_!==null)return[_.nodeId];const f=[...new Set(m.flatMap(g=>$a(a,o,g.nodeId)))];return f.length===1?f:[]});return[...new Set(c)]},Md=e.defineComponent({__name:"StrudelFlowCable",props:{id:{},sourceNode:{},targetNode:{},source:{},target:{},type:{},label:{type:[String,Object,Function]},style:{},selected:{type:Boolean},sourcePosition:{},targetPosition:{},sourceHandleId:{},targetHandleId:{},animated:{type:Boolean},updatable:{type:Boolean},markerStart:{},markerEnd:{},curvature:{},interactionWidth:{},data:{},events:{},labelStyle:{},labelShowBg:{type:Boolean},labelBgStyle:{},labelBgPadding:{},labelBgBorderRadius:{},sourceX:{},sourceY:{},targetX:{},targetY:{}},setup(t){const n=t,{removeEdges:l}=j.useVueFlow(),o=e.computed(()=>j.getBezierPath({sourceX:n.sourceX,sourceY:n.sourceY,sourcePosition:n.sourcePosition,targetX:n.targetX,targetY:n.targetY,targetPosition:n.targetPosition}));return(a,s)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(e.unref(j.BaseEdge),{id:t.id,path:o.value[0],"marker-end":t.markerEnd,style:e.normalizeStyle(t.style),"interaction-width":24},null,8,["id","path","marker-end","style"]),e.createVNode(e.unref(j.EdgeLabelRenderer),null,{default:e.withCtx(()=>[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["strudel-flow-edge__remove nodrag nopan",{"strudel-flow-edge__remove--selected":t.selected}]),style:e.normalizeStyle({transform:`translate(-50%, -50%) translate(${o.value[1]}px, ${o.value[2]}px)`}),"aria-label":"Disconnect",title:"Disconnect",onClick:s[0]||(s[0]=e.withModifiers(r=>e.unref(l)([t.id]),["stop"]))},[e.createVNode(e.unref(L.Unplug),{"aria-hidden":"true"})],6)]),_:1})],64))}}),Pd={class:"strudel-flow-accordion"},Ud={class:"strudel-flow-accordion__trigger"},Id={class:"strudel-flow-accordion__badge"},Vd={class:"strudel-flow-accordion__summary"},Wd={key:0,class:"strudel-flow-accordion__meta"},Gd={class:"strudel-flow-accordion__content"},St=e.defineComponent({__name:"StrudelFlowAccordion",props:{badge:{},summary:{},meta:{}},setup(t){return(n,l)=>(e.openBlock(),e.createElementBlock("details",Pd,[e.createElementVNode("summary",Ud,[e.createVNode(e.unref(L.SlidersHorizontal),{class:"strudel-flow-accordion__icon","aria-hidden":"true"}),e.createElementVNode("span",Id,e.toDisplayString(t.badge),1),e.createElementVNode("span",Vd,e.toDisplayString(t.summary),1),t.meta?(e.openBlock(),e.createElementBlock("span",Wd,"· "+e.toDisplayString(t.meta),1)):e.createCommentVNode("",!0),e.createVNode(e.unref(L.ChevronDown),{class:"strudel-flow-accordion__chevron","aria-hidden":"true"})]),e.createElementVNode("div",Gd,[e.renderSlot(n.$slots,"default")])]))}}),Ba=Symbol("strudel-flow-overlay-target"),Ra=Symbol("strudel-flow-preview-sound"),Oa={kick:e.markRaw(L.Drum),snare:e.markRaw(L.CircleDot),hihat:e.markRaw(L.Sparkles),clap:e.markRaw(L.Hand),tom:e.markRaw(L.Cylinder),cymbal:e.markRaw(L.Disc),percussion:e.markRaw(L.Bell),bass:e.markRaw(L.Speaker),keys:e.markRaw(L.Piano),strings:e.markRaw(L.Guitar),voice:e.markRaw(L.Mic),fx:e.markRaw(L.Zap),other:e.markRaw(L.AudioWaveform)},Hd={once:e.markRaw(L.Circle),faster:e.markRaw(L.FastForward),repeat:e.markRaw(L.Repeat),hold:e.markRaw(L.MoveHorizontal),slower:e.markRaw(L.Hourglass),chance:e.markRaw(L.Dices),rhythm:e.markRaw(L.CircleDashed)},xd={class:"strudel-flow-field"},Xd={class:"strudel-flow-select"},zd=["value","aria-label"],jd=["value"],Kd=["label"],Yd=["value"],Q=e.defineComponent({__name:"StrudelFlowSelect",props:{label:{},modelValue:{},options:{},groups:{},hideLabel:{type:Boolean}},emits:["update:modelValue"],setup(t,{emit:n}){const l=n,o=a=>{const s=a.target;s instanceof HTMLSelectElement&&l("update:modelValue",s.value)};return(a,s)=>(e.openBlock(),e.createElementBlock("label",xd,[e.createElementVNode("span",{class:e.normalizeClass(["strudel-flow-field__label",{"strudel-flow-field__label--hidden":t.hideLabel}])},e.toDisplayString(t.label),3),e.createElementVNode("span",Xd,[e.createElementVNode("select",{value:t.modelValue,"aria-label":t.label,class:"nodrag",onChange:o},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.options??[],r=>(e.openBlock(),e.createElementBlock("option",{key:r.value,value:r.value},e.toDisplayString(r.label),9,jd))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.groups??[],r=>(e.openBlock(),e.createElementBlock("optgroup",{key:r.label,label:r.label},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.options,c=>(e.openBlock(),e.createElementBlock("option",{key:c.value,value:c.value},e.toDisplayString(c.label),9,Yd))),128))],8,Kd))),128))],40,zd),e.createVNode(e.unref(L.ChevronDown),{class:"strudel-flow-select__chevron","aria-hidden":"true"})])]))}}),qd=["aria-label","title","aria-expanded"],Zd={class:"strudel-flow-sample-picker__trigger-text"},Jd=["aria-label","onKeydown"],Qd={class:"strudel-flow-sample-picker__search"},vd=["onKeydown"],em={class:"strudel-flow-sample-picker__body"},tm={class:"strudel-flow-sample-picker__families","aria-label":"Instrument families"},nm=["aria-pressed"],lm={class:"strudel-flow-sample-picker__count"},om=["aria-pressed","onClick"],am={class:"strudel-flow-sample-picker__count"},sm={class:"strudel-flow-sample-picker__results"},rm={key:0,class:"strudel-flow-sample-picker__note"},cm={key:1,class:"strudel-flow-sample-picker__grid","aria-label":"Samples"},im=["aria-pressed","title","onClick"],dm={class:"strudel-flow-sample-picker__option-text"},mm={class:"strudel-flow-sample-picker__option-label"},um={class:"strudel-flow-sample-picker__option-group"},_m=["aria-label","onClick"],pm={key:2,class:"strudel-flow-sample-picker__note"},re="all",fm=480,Na=360,Te=4,Em=240,Xe=e.defineComponent({__name:"StrudelFlowSamplePicker",props:{label:{},modelValue:{},groups:{},placeholder:{},emptyIcon:{}},emits:["update:modelValue"],setup(t,{emit:n}){const l=t,o=n,a=e.inject(Ba,null),s=e.inject(Ra,null),r=e.computed(()=>(a==null?void 0:a.value)??"body"),c=e.ref(null),i=e.ref(null),m=e.ref(null),_=e.ref(!1),f=e.ref(!1),g=e.ref(""),h=e.ref(re),k=e.ref({left:0,top:0}),E=R=>Oa[R]??Oa.other,p=e.computed(()=>l.modelValue.length===0||l.groups.some(R=>R.samples.some(U=>U.value===l.modelValue))?l.groups:[{label:"In this pattern",samples:[{value:l.modelValue,label:l.modelValue}]},...l.groups]),u=e.computed(()=>{const R=new Set;return p.value.flatMap(U=>U.samples.flatMap(M=>R.has(M.value)?[]:(R.add(M.value),[{...M,group:U.label,familyId:M.familyId??Dn(M.value).id}])))}),S=e.computed(()=>[...qt,Cn].map(R=>({...R,count:u.value.filter(U=>U.familyId===R.id).length})).filter(R=>R.count>0)),T=e.computed(()=>{const R=g.value.toLowerCase().split(/\s+/).filter(Boolean);return u.value.filter(U=>(h.value===re||U.familyId===h.value)&&R.every(M=>`${U.value} ${U.label} ${U.group}`.toLowerCase().includes(M)))}),O=e.computed(()=>T.value.slice(0,Em)),V=e.computed(()=>u.value.find(R=>R.value===l.modelValue)),A=e.computed(()=>{var R;return l.modelValue.length===0?l.placeholder??"":((R=V.value)==null?void 0:R.label)??l.modelValue}),y=e.computed(()=>{var R;return l.modelValue.length===0?re:((R=V.value)==null?void 0:R.familyId)??Dn(l.modelValue).id}),w=e.computed(()=>p.value.filter(R=>R.samples.length>0).map(R=>({label:R.label,options:R.samples}))),b=e.computed(()=>l.placeholder===void 0?[]:[{value:"",label:l.placeholder}]),F=()=>{var M;const R=(M=c.value)==null?void 0:M.getBoundingClientRect();if(R===void 0)return;const U=R.bottom+Te+Na<=window.innerHeight;k.value={left:Math.max(Te,Math.min(R.left,window.innerWidth-fm-Te)),top:U?R.bottom+Te:Math.max(Te,R.top-Te-Na)}},B=()=>{f.value=!1},D=()=>{g.value="",h.value=S.value.some(R=>R.id===y.value)?y.value:re,F(),f.value=!0,e.nextTick(()=>{var R;return(R=m.value)==null?void 0:R.focus()})};e.watch(g,(R,U)=>{R.trim().length>0&&U.trim().length===0&&(h.value=re)});const N=R=>{var U;o("update:modelValue",R),s==null||s(R),B(),(U=c.value)==null||U.focus()},C=()=>{const[R]=T.value;R!==void 0&&N(R.value)},P=R=>{var M,le;const U=R.target;f.value&&U instanceof Node&&!((M=i.value)!=null&&M.contains(U))&&!((le=c.value)!=null&&le.contains(U))&&B()};return e.onMounted(()=>{var R;_.value=((R=window.matchMedia)==null?void 0:R.call(window,"(pointer: fine)").matches)===!0,window.addEventListener("pointerdown",P)}),e.onBeforeUnmount(()=>window.removeEventListener("pointerdown",P)),(R,U)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[_.value?(e.openBlock(),e.createElementBlock("button",{key:1,ref_key:"trigger",ref:c,type:"button",class:e.normalizeClass(["strudel-flow-sample-picker__trigger nodrag",{"strudel-flow-sample-picker__trigger--empty":t.modelValue.length===0}]),"aria-label":t.label,title:t.modelValue,"aria-haspopup":"dialog","aria-expanded":f.value,onClick:U[1]||(U[1]=M=>f.value?B():D())},[t.modelValue.length>0||t.emptyIcon!==void 0?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.modelValue.length>0?E(y.value):t.emptyIcon),{key:0,class:"strudel-flow-sample-picker__icon","aria-hidden":"true"})):e.createCommentVNode("",!0),e.createElementVNode("span",Zd,e.toDisplayString(A.value),1),e.createVNode(e.unref(L.ChevronDown),{class:"strudel-flow-sample-picker__chevron","aria-hidden":"true"})],10,qd)):(e.openBlock(),e.createBlock(Q,{key:0,label:t.label,"hide-label":"","model-value":t.modelValue,options:b.value,groups:w.value,"onUpdate:modelValue":U[0]||(U[0]=M=>o("update:modelValue",M))},null,8,["label","model-value","options","groups"])),f.value?(e.openBlock(),e.createBlock(e.Teleport,{key:2,to:r.value},[e.createElementVNode("div",{ref_key:"popover",ref:i,class:"strudel-flow-sample-picker nodrag nowheel",role:"dialog","aria-label":t.label,style:e.normalizeStyle({left:`${k.value.left}px`,top:`${k.value.top}px`}),onKeydown:e.withKeys(e.withModifiers(B,["stop"]),["escape"])},[e.createElementVNode("label",Qd,[e.createVNode(e.unref(L.Search),{class:"strudel-flow-sample-picker__icon","aria-hidden":"true"}),e.withDirectives(e.createElementVNode("input",{ref_key:"searchField",ref:m,"onUpdate:modelValue":U[2]||(U[2]=M=>g.value=M),type:"search",placeholder:"Search samples","aria-label":"Search samples",spellcheck:"false",onKeydown:e.withKeys(e.withModifiers(C,["prevent"]),["enter"])},null,40,vd),[[e.vModelText,g.value]])]),e.createElementVNode("div",em,[e.createElementVNode("ul",tm,[e.createElementVNode("li",null,[e.createElementVNode("button",{type:"button",class:"strudel-flow-sample-picker__family","aria-pressed":h.value===re,onClick:U[3]||(U[3]=M=>h.value=re)},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(E("other")),{class:"strudel-flow-sample-picker__icon","aria-hidden":"true"})),U[4]||(U[4]=e.createElementVNode("span",null,"All",-1)),e.createElementVNode("span",lm,e.toDisplayString(u.value.length),1)],8,nm)]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(S.value,M=>(e.openBlock(),e.createElementBlock("li",{key:M.id},[e.createElementVNode("button",{type:"button",class:"strudel-flow-sample-picker__family","aria-pressed":h.value===M.id,onClick:le=>h.value=M.id},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(E(M.id)),{class:"strudel-flow-sample-picker__icon","aria-hidden":"true"})),e.createElementVNode("span",null,e.toDisplayString(M.label),1),e.createElementVNode("span",am,e.toDisplayString(M.count),1)],8,om)]))),128))]),e.createElementVNode("div",sm,[T.value.length===0?(e.openBlock(),e.createElementBlock("p",rm," No sample matches. ")):(e.openBlock(),e.createElementBlock("ul",cm,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(O.value,M=>(e.openBlock(),e.createElementBlock("li",{key:M.value,class:"strudel-flow-sample-picker__item"},[e.createElementVNode("button",{type:"button",class:"strudel-flow-sample-picker__option","aria-pressed":M.value===t.modelValue,title:`${M.value} · ${M.group}`,onClick:le=>N(M.value)},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(E(M.familyId)),{class:"strudel-flow-sample-picker__icon","aria-hidden":"true"})),e.createElementVNode("span",dm,[e.createElementVNode("span",mm,e.toDisplayString(M.label),1),e.createElementVNode("span",um,e.toDisplayString(M.group),1)])],8,im),e.unref(s)!==null?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"strudel-flow-sample-picker__play","aria-label":`Play ${M.label}, ${M.group}`,onClick:le=>e.unref(s)(M.value)},[e.createVNode(e.unref(L.Play),{class:"strudel-flow-sample-picker__icon","aria-hidden":"true"})],8,_m)):e.createCommentVNode("",!0)]))),128))])),T.value.length>O.value.length?(e.openBlock(),e.createElementBlock("p",pm,e.toDisplayString(T.value.length-O.value.length)+" more; type to narrow the list. ",1)):e.createCommentVNode("",!0)])])],44,Jd)],8,["to"])):e.createCommentVNode("",!0)],64))}}),hm={class:"strudel-flow-field"},gm={class:"strudel-flow-field__label"},Sm=["aria-label"],km=["aria-label","disabled"],bm={class:"strudel-flow-stepper__value"},Tm=["aria-label","disabled"],v=e.defineComponent({__name:"StrudelFlowStepper",props:{label:{},modelValue:{},min:{},max:{}},emits:["update:modelValue"],setup(t,{emit:n}){const l=t,o=n,a=s=>{o("update:modelValue",Math.min(l.max,Math.max(l.min,l.modelValue+s)))};return(s,r)=>(e.openBlock(),e.createElementBlock("div",hm,[e.createElementVNode("span",gm,e.toDisplayString(t.label),1),e.createElementVNode("div",{class:"strudel-flow-stepper",role:"group","aria-label":t.label},[e.createElementVNode("button",{type:"button",class:"strudel-flow-stepper__button nodrag","aria-label":`Decrease ${t.label.toLowerCase()}`,disabled:t.modelValue<=t.min,onClick:r[0]||(r[0]=c=>a(-1))},[e.createVNode(e.unref(L.Minus),{"aria-hidden":"true"})],8,km),e.createElementVNode("output",bm,e.toDisplayString(t.modelValue),1),e.createElementVNode("button",{type:"button",class:"strudel-flow-stepper__button nodrag","aria-label":`Increase ${t.label.toLowerCase()}`,disabled:t.modelValue>=t.max,onClick:r[1]||(r[1]=c=>a(1))},[e.createVNode(e.unref(L.Plus),{"aria-hidden":"true"})],8,Tm)],8,Sm)]))}}),wm={class:"strudel-flow-beats"},Lm={class:"strudel-flow-beats__tracks",role:"group","aria-label":"Drum tracks"},ym=["aria-pressed","aria-label","title","onClick"],Fm={key:0,class:"strudel-flow-select strudel-flow-pad__modifier"},$m=["value","aria-label","onChange"],Bm=["value"],Rm={class:"strudel-flow-accordion__row"},Om={class:"strudel-flow-field"},Nm=["aria-checked"],Aa=e.defineComponent({__name:"StrudelFlowBeatsControls",props:{data:{},sampleGroups:{}},emits:["update"],setup(t,{emit:n}){const l=t,o=n,a=e.computed(()=>Array.from({length:l.data.steps},(E,p)=>p)),s=new Set(Ot.flatMap(E=>E.sounds)),r=e.computed(()=>(l.sampleGroups??[]).map(E=>({label:E.label,samples:E.samples.filter(p=>!s.has(p.value))})).filter(E=>E.samples.length>0)),c=E=>E.map(p=>({value:p,label:p})),i=e.computed(()=>[...Ot.map(E=>({label:E.label,samples:c(E.sounds)})),...r.value]),m=E=>{o("update",{...l.data,...E})},_=(E,p)=>{m({rows:l.data.rows.map((u,S)=>S===E?{...u,...p}:u)})},f=(E,p)=>{const u=l.data.rows[E];u!==void 0&&_(E,{steps:u.steps.map((S,T)=>T===p?!S:S)})},g=(E,p,u)=>{const S=l.data.rows[E];if(S===void 0||!(u.target instanceof HTMLSelectElement))return;const T=u.target.value;_(E,{modifiers:Object.fromEntries([...Object.entries(S.modifiers).filter(([O])=>Number(O)!==p),...T.length>0?[[p,T]]:[]])})},h=E=>Rt.find(p=>!E.some(u=>u.sound===p))??Rt[0],k=E=>{const p=E<=l.data.rows.length?l.data.rows.slice(0,E):Array.from({length:E-l.data.rows.length}).reduce(u=>[...u,he(h(u))],l.data.rows);m({rows:p})};return(E,p)=>(e.openBlock(),e.createElementBlock("div",wm,[e.createElementVNode("div",Lm,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.data.rows,(u,S)=>(e.openBlock(),e.createElementBlock("div",{key:S,class:"strudel-flow-beats__track"},[e.createVNode(Xe,{label:`Track ${S+1} sound`,"model-value":u.sound,groups:i.value,"onUpdate:modelValue":T=>_(S,{sound:T})},null,8,["label","model-value","groups","onUpdate:modelValue"]),e.createElementVNode("div",{class:"strudel-flow-beats__steps",style:e.normalizeStyle({"--beats-steps":t.data.steps})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value,T=>(e.openBlock(),e.createElementBlock("div",{key:T,class:"strudel-flow-pad__column"},[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["strudel-flow-pad__cell nodrag",{"strudel-flow-pad__cell--on":u.steps[T]}]),"aria-pressed":u.steps[T]===!0,"aria-label":`${u.sound} step ${T+1}`,title:`${u.sound} step ${T+1}`,onClick:O=>f(S,T)},null,10,ym),t.data.showModifiers?(e.openBlock(),e.createElementBlock("span",Fm,[e.createElementVNode("select",{class:"nodrag",value:u.modifiers[T]??"","aria-label":`${u.sound} step ${T+1} variation`,onChange:O=>g(S,T,O)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(Re),O=>(e.openBlock(),e.createElementBlock("option",{key:O.value,value:O.value},e.toDisplayString(O.value||"○"),9,Bm))),128))],40,$m)])):e.createCommentVNode("",!0)]))),128))],4)]))),128))]),e.createVNode(St,{badge:String(t.data.rows.length),summary:"Shape",meta:`${t.data.steps} steps`},{default:e.withCtx(()=>[e.createElementVNode("div",Rm,[e.createVNode(v,{label:"Steps","model-value":t.data.steps,min:1,max:e.unref(z),"onUpdate:modelValue":p[0]||(p[0]=u=>m({steps:u}))},null,8,["model-value","max"]),e.createVNode(v,{label:"Tracks","model-value":t.data.rows.length,min:1,max:e.unref(Oe),"onUpdate:modelValue":k},null,8,["model-value","max"]),e.createElementVNode("div",Om,[p[3]||(p[3]=e.createElementVNode("span",{class:"strudel-flow-field__label"},"Modifiers",-1)),e.createElementVNode("button",{type:"button",role:"switch",class:"strudel-flow-switch nodrag","aria-checked":t.data.showModifiers,"aria-label":"Show step modifiers",onClick:p[1]||(p[1]=u=>m({showModifiers:!t.data.showModifiers}))},[...p[2]||(p[2]=[e.createElementVNode("span",{class:"strudel-flow-switch__thumb","aria-hidden":"true"},null,-1)])],8,Nm)])])]),_:1},8,["badge","meta"])]))}}),Am={class:"strudel-flow-knob"},Cm={class:"strudel-flow-knob__dial"},Dm={class:"strudel-flow-knob__graphic",viewBox:"0 0 100 100","aria-hidden":"true"},Mm=["stroke-dasharray"],Pm=["transform"],Um=["value","min","max","step","aria-label","aria-valuetext"],Im={class:"strudel-flow-knob__value"},Vm={class:"strudel-flow-knob__label"},Mn=-135,Ca=270,Da=50,kt=46,H=e.defineComponent({__name:"StrudelFlowKnob",props:{label:{},modelValue:{},min:{},max:{},step:{},suffix:{}},emits:["update:modelValue"],setup(t,{emit:n}){const l=t,o=n,a=(f,g)=>{const h=g*Math.PI/180;return`${Da+f*Math.sin(h)} ${Da-f*Math.cos(h)}`},s=`M ${a(kt,Mn)} A ${kt} ${kt} 0 1 1 ${a(kt,Mn+Ca)}`,r=e.computed(()=>{const f=l.max-l.min;return f<=0?0:Math.min(1,Math.max(0,(l.modelValue-l.min)/f))}),c=e.computed(()=>Mn+r.value*Ca),i=e.computed(()=>so(l.modelValue)),m=e.computed(()=>{var f;return((f=l.suffix)==null?void 0:f.trim())??""}),_=f=>{const g=f.target;g instanceof HTMLInputElement&&o("update:modelValue",Number(g.value))};return(f,g)=>(e.openBlock(),e.createElementBlock("label",Am,[e.createElementVNode("span",Cm,[(e.openBlock(),e.createElementBlock("svg",Dm,[e.createElementVNode("path",{class:"strudel-flow-knob__track",d:s}),e.createElementVNode("path",{class:"strudel-flow-knob__fill",d:s,pathLength:"100","stroke-dasharray":`${r.value*100} 100`},null,8,Mm),g[0]||(g[0]=e.createElementVNode("circle",{class:"strudel-flow-knob__face",cx:"50",cy:"50",r:"38"},null,-1)),e.createElementVNode("line",{class:"strudel-flow-knob__indicator",x1:"50",y1:"41",x2:"50",y2:"28",transform:`rotate(${c.value} 50 50)`},null,8,Pm)])),e.createElementVNode("input",{class:"strudel-flow-knob__input",type:"range",value:t.modelValue,min:t.min,max:t.max,step:t.step,"aria-label":t.label,"aria-valuetext":`${i.value}${m.value}`,onInput:_},null,40,Um)]),e.createElementVNode("span",Im,e.toDisplayString(i.value),1),e.createElementVNode("span",Vm,e.toDisplayString(t.label),1)]))}}),Wm={class:"strudel-flow-calls","aria-label":"Chained calls"},Gm={class:"strudel-flow-calls__list"},Hm={key:0,class:"strudel-flow-calls__row strudel-flow-calls__row--controls"},xm={class:"strudel-flow-calls__heading"},Xm={class:"strudel-flow-calls__name"},zm=["aria-label","title","onClick"],jm={key:0,class:"strudel-flow-knobs"},Km={key:0,class:"strudel-flow-calls__control"},Ym={class:"strudel-flow-calls__control-label"},qm=["value","aria-label","onInput"],Zm={key:1,class:"strudel-flow-calls__control"},Jm={class:"strudel-flow-calls__control-label"},Qm=["aria-label"],vm=["aria-pressed","aria-label","onClick"],eu={key:1,class:"strudel-flow-calls__row"},tu=["value","size","onInput"],nu=["value","aria-label","onInput"],lu=["aria-label","title","onClick"],ou=e.defineComponent({__name:"StrudelFlowCallList",props:{data:{}},emits:["update"],setup(t,{emit:n}){const l=t,o=n,a=e.computed(()=>l.data.calls),s=e.computed(()=>a.value.map(nn)),r=E=>{o("update",{...l.data,calls:E})},c=(E,p,u)=>{const S=u.target;(S instanceof HTMLInputElement||S instanceof HTMLTextAreaElement)&&r(a.value.map((T,O)=>O===E?{...T,[p]:S.value}:T))},i=(E,p)=>{r(a.value.map((u,S)=>S===E?{...u,argument:p}:u))},m=(E,p,u)=>{const S=s.value[E]??[];i(E,ln(S.map((T,O)=>O===p?u:T)))},_=(E,p,u,S)=>{m(E,p,{...u,value:S})},f=E=>E.some(p=>p.kind==="number"),g=(E,p,u,S)=>{S.target instanceof HTMLInputElement&&m(E,p,{...u,value:S.target.value})},h=(E,p,u,S)=>{m(E,p,{...u,steps:u.steps.map((T,O)=>O===S?!T:T)})},k=E=>{r(a.value.filter((p,u)=>u!==E))};return(E,p)=>(e.openBlock(),e.createElementBlock("section",Wm,[p[3]||(p[3]=e.createElementVNode("span",{class:"strudel-flow-field__label"},"Calls",-1)),e.createElementVNode("ul",Gm,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value,(u,S)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:S},[s.value[S]!==null?(e.openBlock(),e.createElementBlock("li",Hm,[e.createElementVNode("div",xm,[e.createElementVNode("span",Xm,"."+e.toDisplayString(u.method),1),e.createElementVNode("button",{type:"button",class:"strudel-flow-calls__remove nodrag","aria-label":`Remove ${u.method}`,title:`Remove ${u.method}`,onClick:T=>k(S)},[e.createVNode(e.unref(L.X),{"aria-hidden":"true"})],8,zm)]),f(s.value[S]??[])?(e.openBlock(),e.createElementBlock("div",jm,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.value[S],(T,O)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:O},[T.kind==="number"?(e.openBlock(),e.createBlock(H,{key:0,label:T.label,"model-value":T.value,min:T.min,max:T.max,step:T.step,"onUpdate:modelValue":V=>_(S,O,T,V)},null,8,["label","model-value","min","max","step","onUpdate:modelValue"])):e.createCommentVNode("",!0)],64))),128))])):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.value[S],(T,O)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:O},[T.kind==="text"?(e.openBlock(),e.createElementBlock("label",Km,[e.createElementVNode("span",Ym,e.toDisplayString(T.label),1),e.createElementVNode("input",{class:"strudel-flow-calls__text nodrag",value:T.value,"aria-label":`${u.method} ${T.label.toLowerCase()}`,spellcheck:"false",onInput:V=>g(S,O,T,V)},null,40,qm)])):T.kind==="toggles"?(e.openBlock(),e.createElementBlock("div",Zm,[e.createElementVNode("span",Jm,e.toDisplayString(T.label),1),e.createElementVNode("div",{class:"strudel-flow-calls__steps",role:"group","aria-label":`${u.method} ${T.perCycle?"cycles":"steps"}`},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(T.steps,(V,A)=>(e.openBlock(),e.createElementBlock("button",{key:A,type:"button",class:e.normalizeClass(["strudel-flow-calls__step nodrag",{"strudel-flow-calls__step--on":V}]),"aria-pressed":V,"aria-label":`${T.perCycle?"Cycle":"Step"} ${A+1}`,onClick:y=>h(S,O,T,A)},null,10,vm))),128))],8,Qm)])):e.createCommentVNode("",!0)],64))),128))])):(e.openBlock(),e.createElementBlock("li",eu,[p[0]||(p[0]=e.createElementVNode("span",{class:"strudel-flow-calls__punctuation","aria-hidden":"true"},".",-1)),e.createElementVNode("input",{class:"strudel-flow-calls__method nodrag",value:u.method,placeholder:"fast",size:Math.max(4,u.method.length),"aria-label":"Call name",spellcheck:"false",onInput:T=>c(S,"method",T)},null,40,tu),p[1]||(p[1]=e.createElementVNode("span",{class:"strudel-flow-calls__punctuation","aria-hidden":"true"},"(",-1)),e.createElementVNode("textarea",{class:"strudel-flow-calls__argument nodrag nowheel",value:u.argument,rows:"1",placeholder:"2","aria-label":`${u.method||"Call"} argument`,spellcheck:"false",onInput:T=>c(S,"argument",T)},null,40,nu),p[2]||(p[2]=e.createElementVNode("span",{class:"strudel-flow-calls__punctuation","aria-hidden":"true"},")",-1)),e.createElementVNode("button",{type:"button",class:"strudel-flow-calls__remove nodrag","aria-label":`Remove ${u.method||"call"}`,title:`Remove ${u.method||"call"}`,onClick:T=>k(S)},[e.createVNode(e.unref(L.X),{"aria-hidden":"true"})],8,lu)]))],64))),128))])]))}}),au={class:"strudel-flow-chord-editor"},su=["data-degree","aria-label","aria-pressed","title","onClick","onKeydown"],ru={class:"strudel-flow-chord-editor__degree"},cu={key:0,class:"strudel-flow-chord-editor__bar"},iu={class:"strudel-flow-chord-editor__name"},Ma=e.defineComponent({__name:"StrudelFlowChordEditor",props:{notes:{},noteSlots:{},noteName:{type:Function},noteLabel:{type:Function}},emits:["update"],setup(t,{emit:n}){const l=t,o=n,a=e.ref(null),s=e.ref(null),r=e.ref(null),c=e.computed(()=>Array.from({length:l.noteSlots},(p,u)=>u)),i=p=>{o("update",l.notes.includes(p)?l.notes.filter(u=>u!==p):[...l.notes,p].sort((u,S)=>u-S))},m=(p,u,S)=>[...new Set([...p.filter(T=>T!==u),S])].sort((T,O)=>T-O),_=()=>{s.value=null,r.value=null},f=p=>{var O;if(!p.isPrimary||p.button!==0)return;const u=p.target;if(!(u instanceof Element))return;const S=u.closest("button[data-degree]");if(S===null)return;p.preventDefault(),S.focus();const T=Number(S.dataset.degree);s.value={pointerId:p.pointerId,startX:p.clientX,degree:T,target:T,moved:!1,notes:[...l.notes],slots:l.noteSlots},(O=a.value)==null||O.setPointerCapture(p.pointerId)},g=p=>{var O;const u=s.value;if(u===null||u.pointerId!==p.pointerId||!u.moved&&Math.abs(p.clientX-u.startX)<4)return;u.moved=!0;const S=(O=a.value)==null?void 0:O.getBoundingClientRect();if(S===void 0||S.width===0)return;const T=Math.max(0,Math.min(u.slots-1,u.degree+(p.clientX-u.startX)/S.width*u.slots));u.target=Math.round(T),r.value={from:u.degree,target:u.target,position:(T+.5)/u.slots*100}},h=p=>{var S;const u=s.value;u===null||u.pointerId!==p.pointerId||(s.value=null,r.value=null,u.moved?o("update",m(u.notes,u.degree,u.target)):i(u.degree),(S=a.value)==null||S.releasePointerCapture(p.pointerId))},k=(p,u)=>{u.detail===0&&i(p)},E=async(p,u)=>{var T,O;if(!l.notes.includes(u)||!["ArrowLeft","ArrowRight"].includes(p.key))return;p.preventDefault();const S=Math.max(0,Math.min(l.noteSlots-1,u+(p.key==="ArrowRight"?1:-1)));o("update",m(l.notes,u,S)),await e.nextTick(),(O=(T=a.value)==null?void 0:T.querySelector(`[data-degree="${S}"]`))==null||O.focus()};return(p,u)=>(e.openBlock(),e.createElementBlock("div",au,[e.createElementVNode("div",{ref_key:"container",ref:a,class:"strudel-flow-chord-editor__grid",role:"group","aria-label":"Edit chord notes",style:e.normalizeStyle({gridTemplateColumns:`repeat(${t.noteSlots}, minmax(0, 1fr))`}),onPointerdown:f,onPointermove:g,onPointerup:h,onPointercancel:_,onLostpointercapture:_},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.value,S=>{var T,O;return e.openBlock(),e.createElementBlock("button",{key:S,type:"button",class:"strudel-flow-chord-editor__slot nodrag","data-degree":S,"aria-label":`Scale degree ${S}: ${t.noteLabel(S)}`,"aria-pressed":t.notes.includes(S),title:`${S}: ${t.noteName(S)} · Click to ${t.notes.includes(S)?"remove":"add"}${t.notes.includes(S)?", drag to move":""}`,onClick:V=>k(S,V),onKeydown:V=>E(V,S)},[e.createElementVNode("span",ru,e.toDisplayString(S),1),e.createElementVNode("span",{class:e.normalizeClass(["strudel-flow-chord-editor__lane",{"strudel-flow-chord-editor__lane--target":((T=r.value)==null?void 0:T.target)===S}])},[t.notes.includes(S)&&((O=r.value)==null?void 0:O.from)!==S?(e.openBlock(),e.createElementBlock("span",cu,[...u[0]||(u[0]=[e.createElementVNode("span",{class:"strudel-flow-chord-editor__bar-dot"},null,-1)])])):e.createCommentVNode("",!0)],2),e.createElementVNode("span",iu,e.toDisplayString(t.noteName(S)),1)],40,su)}),128)),r.value!==null?(e.openBlock(),e.createElementBlock("span",{key:0,class:"strudel-flow-chord-editor__preview",style:e.normalizeStyle({left:`${r.value.position}%`}),"aria-hidden":"true"},[...u[1]||(u[1]=[e.createElementVNode("span",{class:"strudel-flow-chord-editor__bar-dot"},null,-1)])],4)):e.createCommentVNode("",!0)],36)]))}}),du={class:"strudel-flow-chords"},mu={class:"strudel-flow-chords__presets",role:"group","aria-label":"Progression presets"},uu=["onClick"],_u={viewBox:"0 0 72 22","aria-hidden":"true"},pu=["points"],fu=["cx","cy"],Eu={class:"strudel-flow-chords__progression",role:"group","aria-label":"Chord progression"},hu=["aria-label","aria-pressed","onClick"],gu={class:"strudel-flow-chords__card-meta"},Su={viewBox:"0 0 48 40",class:"strudel-flow-chords__shape","aria-hidden":"true"},ku=["d"],bu=["x","y"],Tu={class:"strudel-flow-chords__card-name"},wu=["disabled"],Lu={class:"strudel-flow-accordion__row"},Pa=e.defineComponent({__name:"StrudelFlowChordsControls",props:{data:{}},emits:["update"],setup(t,{emit:n}){const l=t,o=n,a=e.ref(0),s=e.computed(()=>nt(l.data)),r=e.computed(()=>Qt(l.data)),c=e.computed(()=>Jl(l.data)),i=e.computed(()=>Math.min(a.value,Math.max(0,s.value.length-1))),m=e.computed(()=>s.value[i.value]??[]),_=e.computed(()=>Math.max(14,Math.ceil((Math.max(0,...s.value.flat())+1)/7)*7)),f=e.computed(()=>{var A;return((A=de.find(y=>y.value===l.data.scaleType))==null?void 0:A.label)??l.data.scaleType}),g=e.computed(()=>Math.max(13,...s.value.flat())),h=A=>{o("update",{...l.data,...A})},k=A=>{h({chordNotes:A})},E=A=>{k(s.value.length>0?s.value.map((y,w)=>w===i.value?A:y):[A])},p=A=>{h({chordProgression:[...A],chordNotes:void 0}),a.value=0},u=()=>{if(r.value.length>=16)return;const A=s.value.at(-1)??[0,2,4];k([...s.value,[...A]]),a.value=s.value.length},S=A=>A.map((y,w)=>`${9+w*18},${18-y*2}`).join(" "),T=A=>{(A==="major"||A==="minor")&&h({scaleType:A})},O=A=>{var y;return l.data.chordNotes!==void 0?(y=s.value[A])!=null&&y.length?s.value[A].join(", "):"rest":c.value.degrees[r.value[A]??0]??""},V=A=>{var y;return l.data.chordNotes!==void 0?(y=s.value[A])!=null&&y.length?s.value[A].join("·"):"Rest":c.value.chordName(r.value[A]??0)};return(A,y)=>(e.openBlock(),e.createElementBlock("div",du,[(e.openBlock(),e.createBlock(Ma,{key:i.value,notes:m.value,"note-slots":_.value,"note-name":c.value.noteName,"note-label":c.value.noteLabel,onUpdate:E},null,8,["notes","note-slots","note-name","note-label"])),e.createElementVNode("div",mu,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(Zl),w=>(e.openBlock(),e.createElementBlock("button",{key:w.label,type:"button",class:"strudel-flow-chords__preset nodrag",onClick:b=>p(w.steps)},[(e.openBlock(),e.createElementBlock("svg",_u,[e.createElementVNode("polyline",{points:S(w.steps),fill:"none"},null,8,pu),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(w.steps,(b,F)=>(e.openBlock(),e.createElementBlock("circle",{key:F,cx:9+F*18,cy:18-b*2,r:"3"},null,8,fu))),128))])),e.createTextVNode(" "+e.toDisplayString(w.label),1)],8,uu))),128))]),e.createElementVNode("div",Eu,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,(w,b)=>(e.openBlock(),e.createElementBlock("button",{key:b,type:"button",class:e.normalizeClass(["strudel-flow-chords__card nodrag",{"strudel-flow-chords__card--active":i.value===b}]),"aria-label":`Chord step ${b+1}: ${O(b)}`,"aria-pressed":i.value===b,onClick:F=>a.value=b},[e.createElementVNode("span",gu,[e.createElementVNode("span",null,e.toDisplayString(b+1),1),e.createElementVNode("span",null,e.toDisplayString(t.data.chordNotes!==void 0?"n":c.value.degrees[w]),1)]),(e.openBlock(),e.createElementBlock("svg",Su,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList([0,1,2,3,4],F=>e.createElementVNode("path",{key:F,d:`M4 ${6+F*7}H44`,class:"strudel-flow-chords__staff"},null,8,ku)),64)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.value[b],(F,B)=>{var D;return e.openBlock(),e.createElementBlock("rect",{key:B,x:5+B*28/Math.max(1,(((D=s.value[b])==null?void 0:D.length)??1)-1),y:32-F/g.value*26,width:"15",height:"4",rx:"2",class:"strudel-flow-chords__note"},null,8,bu)}),128))])),e.createElementVNode("span",Tu,e.toDisplayString(V(b)),1)],10,hu))),128))]),e.createElementVNode("button",{type:"button",class:"strudel-flow-chords__add nodrag","aria-label":"Add chord step",disabled:r.value.length>=16,onClick:u}," + ",8,wu),e.createVNode(St,{badge:`${t.data.key}${t.data.octave}`,summary:f.value,meta:`${r.value.length} chords`},{default:e.withCtx(()=>[e.createElementVNode("div",Lu,[e.createVNode(Q,{label:"Key","model-value":t.data.key,options:e.unref(ie),"onUpdate:modelValue":y[0]||(y[0]=w=>h({key:w}))},null,8,["model-value","options"]),e.createVNode(Q,{label:"Scale","model-value":t.data.scaleType,options:e.unref(Ze),"onUpdate:modelValue":T},null,8,["model-value","options"]),e.createVNode(v,{label:"Octave","model-value":t.data.octave,min:1,max:8,"onUpdate:modelValue":y[1]||(y[1]=w=>h({octave:w}))},null,8,["model-value"])])]),_:1},8,["badge","summary","meta"])]))}}),yu={class:"strudel-flow-arrange"},Fu={key:0,class:"strudel-flow-arrange__empty"},$u={class:"strudel-flow-arrange__row","aria-hidden":"true"},Bu={class:"strudel-flow-arrange__label"},Ru=["aria-pressed","aria-label","onClick"],Ou=4,Ua=e.defineComponent({__name:"StrudelFlowArrangeControls",props:{data:{}},emits:["update"],setup(t,{emit:n}){const l=t,o=n,a=j.useNodeId(),{getEdges:s,getNodes:r}=j.useVueFlow(),c=(f,g=[])=>{var E;const h=(E=s.value.find(p=>p.target===f.id&&!g.includes(p.source)))==null?void 0:E.source,k=r.value.find(p=>p.id===h);return k===void 0?f:c(k,[...g,f.id])},i=e.computed(()=>{const f=new Set(s.value.filter(g=>g.target===a).map(g=>g.source));return Eo(r.value.filter(g=>f.has(g.id))).map((g,h)=>({label:`${h+1}. ${fn(c(g).data.kind).title}`}))}),m=(f,g)=>{o("update",{...l.data,sequence:Ir(l.data.sequence,f,g)})},_=f=>{o("update",{...l.data,sequence:Vr(l.data.sequence,f)})};return(f,g)=>(e.openBlock(),e.createElementBlock("div",yu,[e.createVNode(v,{label:"Cycles","model-value":t.data.sequence.length,min:1,max:Math.max(e.unref(Ft),t.data.sequence.length),"onUpdate:modelValue":_},null,8,["model-value","max"]),i.value.length===0?(e.openBlock(),e.createElementBlock("p",Fu," Cable the nodes that make each part into this one. ")):(e.openBlock(),e.createElementBlock("div",{key:1,class:"strudel-flow-arrange__grid nodrag nowheel",role:"group","aria-label":"Arrangement",style:e.normalizeStyle({"--arrange-cycles":t.data.sequence.length})},[e.createElementVNode("div",$u,[g[0]||(g[0]=e.createElementVNode("span",{class:"strudel-flow-arrange__label"},null,-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.data.sequence,(h,k)=>(e.openBlock(),e.createElementBlock("span",{key:k,class:"strudel-flow-arrange__mark"},e.toDisplayString(k%Ou===0?k+1:""),1))),128))]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,(h,k)=>(e.openBlock(),e.createElementBlock("div",{key:k,class:"strudel-flow-arrange__row"},[e.createElementVNode("span",Bu,e.toDisplayString(h.label),1),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.data.sequence,(E,p)=>(e.openBlock(),e.createElementBlock("button",{key:p,type:"button",class:e.normalizeClass(["strudel-flow-pad__cell strudel-flow-arrange__cell",{"strudel-flow-pad__cell--on":E===k}]),"aria-pressed":E===k,"aria-label":`${h.label} cycle ${p+1}`,onClick:u=>m(k,p)},null,10,Ru))),128))]))),128))],4))]))}}),Nu={class:"strudel-flow-field"},Au=["value","placeholder"],Ia=e.defineComponent({__name:"StrudelFlowCodeControls",props:{data:{}},emits:["update"],setup(t,{emit:n}){const l=t,o=n,a=s=>{const r=s.target;r instanceof HTMLTextAreaElement&&o("update",{kind:"code",code:r.value})};return(s,r)=>(e.openBlock(),e.createElementBlock("label",Nu,[r[0]||(r[0]=e.createElementVNode("span",{class:"strudel-flow-field__label"},"Expression",-1)),e.createElementVNode("textarea",{class:"strudel-flow-textarea",value:l.data.code,placeholder:e.unref(ot).code,"aria-label":"Code expression",rows:"5",spellcheck:"false",onInput:a},null,40,Au)]))}}),Cu={class:"strudel-flow-knobs"},Va=e.defineComponent({__name:"StrudelFlowDelayControls",props:{data:{}},emits:["update"],setup(t,{emit:n}){const l=t,o=n,a=c=>{o("update",{...l.data,mix:c})},s=c=>{o("update",{...l.data,time:c})},r=c=>{o("update",{...l.data,feedback:c})};return(c,i)=>(e.openBlock(),e.createElementBlock("div",Cu,[e.createVNode(H,{label:"Mix","model-value":t.data.mix,min:0,max:1,step:.01,"onUpdate:modelValue":a},null,8,["model-value"]),e.createVNode(H,{label:"Time","model-value":t.data.time,min:0,max:1,step:.01,suffix:"s","onUpdate:modelValue":s},null,8,["model-value"]),e.createVNode(H,{label:"Feedback","model-value":t.data.feedback,min:0,max:1,step:.01,"onUpdate:modelValue":r},null,8,["model-value"])]))}}),Du=.25,Mu=.1,Pu=t=>{const{attack:n,decay:l,sustain:o,release:a}=t,s=n+l+a,r=Math.max(s*Du,Mu),c=s+r,i=n/c,m=(n+l)/c,_=(n+l+r)/c;return[{x:0,y:0},{x:i,y:1},{x:m,y:o},{x:_,y:o},{x:1,y:0}]},Uu=["viewBox"],Iu=["points"],Vu=["points"],Wu={class:"strudel-flow-knobs"},Wa=160,bt=56,we=4,Ga=e.defineComponent({__name:"StrudelFlowEnvelopeControls",props:{data:{}},emits:["update"],setup(t,{emit:n}){const l=t,o=n,a=r=>{o("update",{...l.data,...r})},s=e.computed(()=>Pu(l.data).map(({x:r,y:c})=>`${we+r*(Wa-we*2)},${bt-we-c*(bt-we*2)}`).join(" "));return(r,c)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[(e.openBlock(),e.createElementBlock("svg",{class:"strudel-flow-envelope-chart",viewBox:`0 0 ${Wa} ${bt}`,role:"img","aria-label":"Envelope shape"},[e.createElementVNode("polygon",{points:`${we},${bt-we} ${s.value}`,class:"fill"},null,8,Iu),e.createElementVNode("polyline",{points:s.value,class:"line"},null,8,Vu)],8,Uu)),e.createElementVNode("div",Wu,[e.createVNode(H,{label:"Attack","model-value":t.data.attack,min:0,max:2,step:.01,"onUpdate:modelValue":c[0]||(c[0]=i=>a({attack:i}))},null,8,["model-value"]),e.createVNode(H,{label:"Decay","model-value":t.data.decay,min:0,max:2,step:.01,"onUpdate:modelValue":c[1]||(c[1]=i=>a({decay:i}))},null,8,["model-value"]),e.createVNode(H,{label:"Sustain","model-value":t.data.sustain,min:0,max:1,step:.01,"onUpdate:modelValue":c[2]||(c[2]=i=>a({sustain:i}))},null,8,["model-value"]),e.createVNode(H,{label:"Release","model-value":t.data.release,min:0,max:2,step:.01,"onUpdate:modelValue":c[3]||(c[3]=i=>a({release:i}))},null,8,["model-value"])])],64))}}),Gu={class:"strudel-flow-knobs"},Ha=e.defineComponent({__name:"StrudelFlowFilterControls",props:{data:{}},emits:["update"],setup(t,{emit:n}){const l=t,o=n,a=r=>{o("update",{...l.data,cutoff:r})},s=r=>{o("update",{...l.data,resonance:r})};return(r,c)=>(e.openBlock(),e.createElementBlock("div",Gu,[e.createVNode(H,{label:"LPF","model-value":t.data.cutoff,min:20,max:2e4,step:10,suffix:"Hz","onUpdate:modelValue":a},null,8,["model-value"]),e.createVNode(H,{label:"LPQ","model-value":t.data.resonance,min:.1,max:20,step:.1,"onUpdate:modelValue":s},null,8,["model-value"])]))}}),Hu={class:"strudel-flow-knobs"},xu=e.defineComponent({__name:"StrudelFlowGainControls",props:{data:{}},emits:["update"],setup(t,{emit:n}){const l=t,o=n;return(a,s)=>(e.openBlock(),e.createElementBlock("div",Hu,[e.createVNode(H,{label:"Gain","model-value":l.data.gain,min:0,max:2,step:.01,suffix:"×","onUpdate:modelValue":s[0]||(s[0]=r=>o("update",{...l.data,gain:r}))},null,8,["model-value"])]))}}),Xu={class:"strudel-flow-knobs"},xa=e.defineComponent({__name:"StrudelFlowLevelControls",props:{data:{}},emits:["update"],setup(t,{emit:n}){const l=t,o=n,a=s=>{o("update",{...l.data,...s})};return(s,r)=>(e.openBlock(),e.createElementBlock("div",Xu,[e.createVNode(H,{label:"Pan","model-value":t.data.pan,min:0,max:1,step:.01,"onUpdate:modelValue":r[0]||(r[0]=c=>a({pan:c}))},null,8,["model-value"]),e.createVNode(H,{label:"Postgain","model-value":t.data.postgain,min:0,max:2,step:.01,suffix:"×","onUpdate:modelValue":r[1]||(r[1]=c=>a({postgain:c}))},null,8,["model-value"])]))}}),zu={key:0,class:"strudel-flow-calls__control"},ju={class:"strudel-flow-field__label"},Ku=["aria-label"],Yu=["aria-pressed","aria-label","onClick"],qu={class:"strudel-flow-field"},Zu=["value"],Ju=e.defineComponent({__name:"StrudelFlowMaskControls",props:{data:{}},emits:["update"],setup(t,{emit:n}){const l=t,o=n,a=e.computed(()=>{const[i]=nn({method:"mask",argument:l.data.argument})??[];return(i==null?void 0:i.kind)==="toggles"?i:null}),s=i=>{o("update",{...l.data,argument:i})},r=i=>{a.value!==null&&s(ln([{...a.value,steps:a.value.steps.map((m,_)=>_===i?!m:m)}]))},c=i=>{i.target instanceof HTMLInputElement&&s(i.target.value)};return(i,m)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[a.value!==null?(e.openBlock(),e.createElementBlock("div",zu,[e.createElementVNode("span",ju,e.toDisplayString(a.value.perCycle?"Cycles that play":"Steps that play"),1),e.createElementVNode("div",{class:"strudel-flow-calls__steps",role:"group","aria-label":`Mask ${a.value.perCycle?"cycles":"steps"}`},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value.steps,(_,f)=>(e.openBlock(),e.createElementBlock("button",{key:f,type:"button",class:e.normalizeClass(["strudel-flow-calls__step nodrag",{"strudel-flow-calls__step--on":_}]),"aria-pressed":_,"aria-label":`${a.value.perCycle?"Cycle":"Step"} ${f+1}`,onClick:g=>r(f)},null,10,Yu))),128))],8,Ku)])):e.createCommentVNode("",!0),e.createElementVNode("label",qu,[m[0]||(m[0]=e.createElementVNode("span",{class:"strudel-flow-field__label"},"Mask pattern",-1)),e.createElementVNode("input",{class:"strudel-flow-calls__text nodrag",value:t.data.argument,"aria-label":"Mask pattern",spellcheck:"false",onInput:c},null,40,Zu)])],64))}}),Qu={class:"strudel-flow-knobs"},vu=e.defineComponent({__name:"StrudelFlowSlowControls",props:{data:{}},emits:["update"],setup(t,{emit:n}){const l=t,o=n;return(a,s)=>(e.openBlock(),e.createElementBlock("div",Qu,[e.createVNode(H,{label:"Slower by","model-value":l.data.amount,min:.25,max:8,step:.25,suffix:"×","onUpdate:modelValue":s[0]||(s[0]=r=>o("update",{...l.data,amount:r}))},null,8,["model-value"])]))}}),e_=/^"\s*([x~](?:\s+[x~])*)\s*"$/,t_=t=>{var l;const n=(l=e_.exec(t.trim()))==null?void 0:l[1].split(/\s+/);return n===void 0||n.length>z?null:n.map(o=>o==="x")},n_=t=>`"${t.map(n=>n?"x":"~").join(" ")}"`,l_={class:"strudel-flow-calls__steps",role:"group","aria-label":"Struct steps"},o_=["aria-pressed","aria-label","onClick"],a_={class:"strudel-flow-field"},s_=["value"],r_=e.defineComponent({__name:"StrudelFlowStructControls",props:{data:{}},emits:["update"],setup(t,{emit:n}){const l=t,o=n,a=e.computed(()=>t_(l.data.argument)),s=_=>{o("update",{...l.data,argument:_})},r=_=>{s(n_(_))},c=_=>{a.value!==null&&r(a.value.map((f,g)=>g===_?!f:f))},i=_=>{a.value!==null&&r(Array.from({length:_},(f,g)=>{var h;return((h=a.value)==null?void 0:h[g])??!1}))},m=_=>{_.target instanceof HTMLInputElement&&s(_.target.value)};return(_,f)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[a.value!==null?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createVNode(v,{label:"Steps","model-value":a.value.length,min:1,max:e.unref(z),"onUpdate:modelValue":i},null,8,["model-value","max"]),e.createElementVNode("div",l_,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value,(g,h)=>(e.openBlock(),e.createElementBlock("button",{key:h,type:"button",class:e.normalizeClass(["strudel-flow-calls__step nodrag",{"strudel-flow-calls__step--on":g}]),"aria-pressed":g,"aria-label":`Step ${h+1}`,onClick:k=>c(h)},null,10,o_))),128))])],64)):e.createCommentVNode("",!0),e.createElementVNode("label",a_,[f[0]||(f[0]=e.createElementVNode("span",{class:"strudel-flow-field__label"},"Struct pattern",-1)),e.createElementVNode("input",{class:"strudel-flow-calls__text nodrag",value:t.data.argument,"aria-label":"Struct pattern",spellcheck:"false",onInput:m},null,40,s_)])],64))}}),c_={class:"strudel-flow-field__label"},i_=e.defineComponent({__name:"StrudelFlowVoicingControls",props:{data:{}},setup(t){return(n,l)=>(e.openBlock(),e.createElementBlock("p",c_,"Chord symbols play as voiced notes."))}}),d_={class:"strudel-flow-pad"},m_=["aria-pressed","aria-label","title","onClick"],u_={class:"strudel-flow-select strudel-flow-pad__modifier"},__=["value","aria-label","title","onChange"],p_=["value"],f_={class:"strudel-flow-accordion__row"},E_={class:"strudel-flow-accordion__row"},h_={class:"strudel-flow-field"},g_={class:"strudel-flow-mode",role:"group","aria-label":"Pad mode"},S_=["aria-pressed","onClick"],Xa=e.defineComponent({__name:"StrudelFlowPadControls",props:{data:{}},emits:["update"],setup(t,{emit:n}){const l=t,o=n,a=Array.from({length:Ye},(f,g)=>g),s=["arp","chord"],r=e.computed(()=>Array.from({length:l.data.steps},(f,g)=>g)),c=e.computed(()=>{var f;return((f=de.find(g=>g.value===l.data.scaleType))==null?void 0:f.label)??l.data.scaleType}),i=f=>{o("update",{...l.data,...f})},m=(f,g)=>{i({grid:l.data.grid.map((h,k)=>k===f?h.map((E,p)=>p===g?!E:E):h)})},_=(f,g)=>{const h=g.target;if(!(h instanceof HTMLSelectElement))return;const k={...l.data.columnModifiers};h.value.length===0?delete k[f]:k[f]=h.value,i({columnModifiers:k})};return(f,g)=>(e.openBlock(),e.createElementBlock("div",d_,[e.createElementVNode("div",{class:"strudel-flow-pad__grid",style:e.normalizeStyle({"--pad-steps":t.data.steps}),role:"group","aria-label":"Pad notes"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,h=>(e.openBlock(),e.createElementBlock("div",{key:h,class:"strudel-flow-pad__column"},[g[4]||(g[4]=e.createElementVNode("span",{class:"strudel-flow-pad__playhead","aria-hidden":"true"},null,-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(a),k=>{var E,p;return e.openBlock(),e.createElementBlock("button",{key:k,type:"button",class:e.normalizeClass(["strudel-flow-pad__cell nodrag",{"strudel-flow-pad__cell--on":((E=t.data.grid[h])==null?void 0:E[k])===!0}]),"aria-pressed":((p=t.data.grid[h])==null?void 0:p[k])===!0,"aria-label":`Note ${k+1}, step ${h+1}`,title:`Note ${k+1}, step ${h+1}`,onClick:u=>m(h,k)},null,10,m_)}),128)),e.createElementVNode("span",u_,[e.createElementVNode("select",{value:t.data.columnModifiers[h]??"","aria-label":`Step ${h+1} variation`,title:`Step ${h+1} variation`,onChange:k=>_(h,k)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(Re),k=>(e.openBlock(),e.createElementBlock("option",{key:k.value,value:k.value},e.toDisplayString(k.value||"○"),9,p_))),128))],40,__)])]))),128))],4),e.createVNode(St,{badge:`${t.data.key}${t.data.octave}`,summary:c.value,meta:`${t.data.steps} steps`},{default:e.withCtx(()=>[e.createElementVNode("div",f_,[e.createVNode(Q,{label:"Key","model-value":t.data.key,options:e.unref(ie),"onUpdate:modelValue":g[0]||(g[0]=h=>i({key:h}))},null,8,["model-value","options"]),e.createVNode(Q,{label:"Scale","model-value":t.data.scaleType,options:e.unref(de),"onUpdate:modelValue":g[1]||(g[1]=h=>i({scaleType:h}))},null,8,["model-value","options"]),e.createVNode(v,{label:"Octave","model-value":t.data.octave,min:1,max:8,"onUpdate:modelValue":g[2]||(g[2]=h=>i({octave:h}))},null,8,["model-value"])]),e.createElementVNode("div",E_,[e.createVNode(v,{label:"Steps","model-value":t.data.steps,min:1,max:16,"onUpdate:modelValue":g[3]||(g[3]=h=>i({steps:h}))},null,8,["model-value"]),e.createElementVNode("div",h_,[g[5]||(g[5]=e.createElementVNode("span",{class:"strudel-flow-field__label"},"Mode",-1)),e.createElementVNode("div",g_,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(s,h=>e.createElementVNode("button",{key:h,type:"button",class:e.normalizeClass(["strudel-flow-mode__button nodrag",{"strudel-flow-mode__button--active":t.data.mode===h}]),"aria-pressed":t.data.mode===h,onClick:k=>i({mode:h})},e.toDisplayString(h==="arp"?"Arp":"Chord"),11,S_)),64))])])])]),_:1},8,["badge","summary","meta"])]))}}),Pn="~",za=t=>Array.from({length:t},()=>[]),k_=t=>Math.round(t*Je),b_=(t,n)=>{const l=k_(n);return t.map(o=>o.reduce((a,s)=>{const r=Math.min(l-1,Math.round(s.start*Je));return a.map((c,i)=>i===r?[...new Set([...c,...s.notes])]:c)},za(l)))},ja=t=>ne(t)??Number.NEGATIVE_INFINITY,T_=t=>[...new Set(t.flat(2))].sort((n,l)=>ja(l)-ja(n)),w_=(t,n,l,o)=>t.map((a,s)=>s!==n?a:a.map((r,c)=>c!==l?r:r.includes(o)?r.filter(i=>i!==o):[...r,o])),L_=t=>t.length===0?Pn:t.length===1?t[0]:`[${t.join(",")}]`,y_=t=>t.every(n=>n.length===0)?Pn:t.map(L_).join(" "),F_=t=>{const n=t.map(y_);return n.length===1?n[0]:`<${n.map(l=>l===Pn?l:`[${l}]`).join(" ")}>`},$_=(t,n)=>Array.from({length:n},(l,o)=>{var a;return t[o]??za(((a=t[0])==null?void 0:a.length)??0)}),B_=(t,n,l)=>t.map(o=>o.map(a=>[...new Set(a.map(s=>s===n?l:s))])),R_={class:"strudel-flow-arrange"},O_={class:"strudel-flow-arrange__row","aria-hidden":"true"},N_={class:"strudel-flow-arrange__label"},A_=["value","aria-label","onChange"],C_=["aria-label","onClick"],D_=["aria-pressed","aria-label","onClick"],M_="c3",P_=e.defineComponent({__name:"StrudelFlowNoteGrid",props:{bars:{},beatsPerBar:{}},emits:["update:pattern"],setup(t,{emit:n}){const l=t,o=n,a=e.ref([]),s=e.computed(()=>b_(l.bars,l.beatsPerBar)),r=e.computed(()=>[...new Set([...a.value,...T_(s.value)])].sort((p,u)=>(ne(u)??Number.NEGATIVE_INFINITY)-(ne(p)??Number.NEGATIVE_INFINITY))),c=e.computed(()=>s.value.flatMap((E,p)=>E.map((u,S)=>({barIndex:p,stepIndex:S,step:u})))),i=e.computed(()=>{var E;return((E=s.value[0])==null?void 0:E.length)??0}),m=E=>{o("update:pattern",F_(E))},_=(E,p,u)=>{a.value=r.value,m(w_(s.value,p,u,E))},f=E=>{const p=i.value||Math.round(l.beatsPerBar*Je),u=s.value.length>0?s.value:[Array.from({length:p},()=>[])];m($_(u,E))},g=(E,p)=>{if(p.target instanceof HTMLInputElement){const u=p.target.value.trim().toLowerCase();ne(u)!==null&&u!==E&&(a.value=r.value.map(S=>S===E?u:S),m(B_(s.value,E,u)))}},h=E=>{a.value=r.value.filter(p=>p!==E),m(s.value.map(p=>p.map(u=>u.filter(S=>S!==E))))},k=()=>{const E=ne(r.value.at(-1)??""),p=E===null?M_:oa(E-1);a.value=[...new Set([...r.value,p])]};return(E,p)=>(e.openBlock(),e.createElementBlock("div",R_,[e.createVNode(v,{label:"Bars","model-value":s.value.length,min:1,max:Math.max(e.unref(Kn),s.value.length),"onUpdate:modelValue":f},null,8,["model-value","max"]),e.createElementVNode("div",{class:"strudel-flow-arrange__grid nodrag nowheel",role:"group","aria-label":"Note grid",style:e.normalizeStyle({"--arrange-cycles":c.value.length})},[e.createElementVNode("div",O_,[p[0]||(p[0]=e.createElementVNode("span",{class:"strudel-flow-arrange__label"},null,-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.value,u=>(e.openBlock(),e.createElementBlock("span",{key:`${u.barIndex}-${u.stepIndex}`,class:"strudel-flow-arrange__mark"},e.toDisplayString(u.stepIndex===0?u.barIndex+1:""),1))),128))]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,u=>(e.openBlock(),e.createElementBlock("div",{key:u,class:"strudel-flow-arrange__row"},[e.createElementVNode("span",N_,[e.createElementVNode("input",{class:"strudel-flow-arrange__part",type:"text",spellcheck:"false",value:u,"aria-label":`Pitch ${u}`,onChange:S=>g(u,S)},null,40,A_),e.createElementVNode("button",{type:"button",class:"strudel-flow-arrange__remove","aria-label":`Remove ${u}`,onClick:S=>h(u)},[e.createVNode(e.unref(L.X),{"aria-hidden":"true"})],8,C_)]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.value,S=>(e.openBlock(),e.createElementBlock("button",{key:`${S.barIndex}-${S.stepIndex}`,type:"button",class:e.normalizeClass(["strudel-flow-pad__cell strudel-flow-arrange__cell",{"strudel-flow-pad__cell--on":S.step.includes(u)}]),"aria-pressed":S.step.includes(u),"aria-label":`${u} bar ${S.barIndex+1} step ${S.stepIndex+1}`,onClick:T=>_(u,S.barIndex,S.stepIndex)},null,10,D_))),128))]))),128))],4),e.createElementVNode("button",{type:"button",class:"strudel-flow-arrange__add",onClick:k},[e.createVNode(e.unref(L.Plus),{"aria-hidden":"true"}),p[1]||(p[1]=e.createTextVNode(" Add pitch ",-1))])]))}}),U_={class:"strudel-flow-note-names nowheel","aria-label":"Notes by bar"},I_={class:"strudel-flow-note-names__bar-number"},V_={class:"strudel-flow-note-names__name"},W_={class:"strudel-flow-note-names__length"},G_="~",H_=1e-6,Ka=e.defineComponent({__name:"StrudelFlowNoteNames",props:{bars:{},beatsPerBar:{}},setup(t){const n=t,l=a=>a>H_?[{name:G_,beats:a}]:[],o=e.computed(()=>n.bars.map(a=>{const s=a.reduce((r,c)=>({end:c.start+c.beats,entries:[...r.entries,...l(c.start-r.end),{name:c.notes.join(","),beats:c.beats}]}),{end:0,entries:[]});return[...s.entries,...l(n.beatsPerBar-s.end)]}));return(a,s)=>(e.openBlock(),e.createElementBlock("ol",U_,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value,(r,c)=>(e.openBlock(),e.createElementBlock("li",{key:c,class:"strudel-flow-note-names__bar"},[e.createElementVNode("span",I_,e.toDisplayString(c+1),1),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r,(i,m)=>(e.openBlock(),e.createElementBlock("span",{key:m,class:"strudel-flow-note-names__note"},[e.createElementVNode("span",V_,e.toDisplayString(i.name),1),s[0]||(s[0]=e.createTextVNode()),e.createElementVNode("span",W_,e.toDisplayString(e.unref(la)(i.beats)),1)]))),128))]))),128))]))}}),x_={key:0,class:"strudel-flow-piano-roll nowheel"},X_=["width","height","viewBox","aria-label"],z_=["y","width","height"],j_=["y"],K_=["x1","x2","y2"],Y_=["x","y","width","height"],Un=12,Ya=e.defineComponent({__name:"StrudelFlowPianoRoll",props:{bars:{},beatsPerBar:{}},setup(t){const n=t,l=e.computed(()=>n.bars.flatMap((g,h)=>g.flatMap(k=>k.notes.flatMap(E=>{const p=ne(E);return p===null?[]:[{midiNote:p,beat:h*n.beatsPerBar+k.start,beats:k.beats}]})))),o=e.computed(()=>{const g=l.value.map(E=>E.midiNote),h=Math.min(...g)-1,k=Math.max(Math.max(...g)+1,h+fl-1);return{low:h,high:k}}),a=e.computed(()=>Array.from({length:o.value.high-o.value.low+1},(g,h)=>o.value.high-h)),s=g=>(o.value.high-g)*me,r=g=>pl+g*Ut,c=e.computed(()=>r(n.bars.length*n.beatsPerBar)),i=e.computed(()=>a.value.length*me),m=g=>El.includes(g%Un),_=g=>g%Un===0,f=g=>Math.floor(g/Un)-1;return(g,h)=>l.value.length>0?(e.openBlock(),e.createElementBlock("div",x_,[(e.openBlock(),e.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg","data-notation":"piano",width:c.value,height:i.value,viewBox:`0 0 ${c.value} ${i.value}`,role:"img","aria-label":`Piano roll, ${t.bars.length} bars`},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value,k=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:k},[m(k)?(e.openBlock(),e.createElementBlock("rect",{key:0,class:"strudel-flow-piano-roll__black-key",x:0,y:s(k),width:c.value,height:e.unref(me)},null,8,z_)):e.createCommentVNode("",!0),_(k)?(e.openBlock(),e.createElementBlock("text",{key:1,class:"strudel-flow-piano-roll__label",x:2,y:s(k)+e.unref(me)}," C"+e.toDisplayString(f(k)),9,j_)):e.createCommentVNode("",!0)],64))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.bars.length+1,k=>(e.openBlock(),e.createElementBlock("line",{key:`bar-${k}`,class:"strudel-flow-piano-roll__bar-line",x1:r((k-1)*t.beatsPerBar),y1:0,x2:r((k-1)*t.beatsPerBar),y2:i.value},null,8,K_))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,(k,E)=>(e.openBlock(),e.createElementBlock("rect",{key:`note-${E}`,class:"strudel-flow-piano-roll__note",x:r(k.beat),y:s(k.midiNote),width:Math.max(1,k.beats*e.unref(Ut)-1),height:e.unref(me),rx:"1"},null,8,Y_))),128))],8,X_))])):e.createCommentVNode("",!0)}}),q_={class:"strudel-flow-sheet nowheel"},Z_=["width","height","viewBox","aria-label"],J_=["data-clef","stroke-width"],Q_=["x1","y1","x2","y2"],v_=["x","y","font-size"],ep=["x1","y1","x2","y2","stroke-width"],tp=["d","stroke-width"],np=["d","stroke-width"],lp=["x1","y1","x2","y2","stroke-width"],op=["cx","cy","rx","ry","transform","stroke-width"],ap=["x","y","font-size"],sp=["x1","y1","x2","y2","stroke-width"],rp=["d","stroke-width"],cp=["cx","cy","r"],ip=["d","stroke-width"],dp=["x","y","font-size"],mp="'Noto Music', 'Apple Symbols', 'Segoe UI Symbol', serif",up=4.2,_p=-20,qa=e.defineComponent({__name:"StrudelFlowSheet",props:{bars:{},beatsPerBar:{}},setup(t){const n=t,l=[0,1,2,3,4],o={treble:3,bass:1},a=e.computed(()=>Ta(n.bars,n.beatsPerBar)),s=e.computed(()=>a.value.lineGap),r=e.computed(()=>jl*s.value),c=e.computed(()=>a.value.staves[0].topY),i=e.computed(()=>a.value.staves.at(-1).bottomY),m=(f,g)=>f.bottomY-g*s.value,_=e.computed(()=>`Piano sheet on ${a.value.staves.map(f=>f.clef).join(" and ")} clef, ${n.bars.length} bars`);return(f,g)=>(e.openBlock(),e.createElementBlock("div",q_,[(e.openBlock(),e.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg","data-notation":"sheet",width:a.value.width,height:a.value.height,viewBox:`0 0 ${a.value.width} ${a.value.height}`,role:"img","aria-label":_.value},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value.staves,h=>(e.openBlock(),e.createElementBlock("g",{key:h.clef,class:"strudel-flow-sheet__staff","data-clef":h.clef,"stroke-width":r.value},[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(l,k=>e.createElementVNode("line",{key:k,class:"strudel-flow-sheet__line",x1:a.value.staffStartX,y1:m(h,k),x2:a.value.staffEndX,y2:m(h,k)},null,8,Q_)),64)),e.createElementVNode("text",{class:"strudel-flow-sheet__clef",x:a.value.staffStartX+s.value*.4,y:m(h,o[h.clef])+(h.clef==="treble"?s.value:0),"font-size":up*s.value,"font-family":mp},e.toDisplayString(e.unref(Rl)[h.clef]),9,v_)],8,J_))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList([a.value.staffStartX,...a.value.barEndXs],h=>(e.openBlock(),e.createElementBlock("line",{key:`bar-${h}`,class:"strudel-flow-sheet__bar-line",x1:h,y1:c.value,x2:h,y2:i.value,"stroke-width":r.value},null,8,ep))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value.ties,(h,k)=>(e.openBlock(),e.createElementBlock("path",{key:`tie-${k}`,class:"strudel-flow-sheet__tie",d:h,fill:"none","stroke-width":r.value*1.4},null,8,tp))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value.rests,(h,k)=>(e.openBlock(),e.createElementBlock("path",{key:`rest-${k}`,class:e.normalizeClass(["strudel-flow-sheet__rest",{"strudel-flow-sheet__rest--solid":h.solid}]),d:h.path,"stroke-width":r.value*2},null,10,np))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value.chords,(h,k)=>(e.openBlock(),e.createElementBlock("g",{key:`chord-${k}`,class:"strudel-flow-sheet__chord"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.heads,(E,p)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:p},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(E.ledgerYs,u=>(e.openBlock(),e.createElementBlock("line",{key:`ledger-${u}`,class:"strudel-flow-sheet__ledger",x1:h.x-e.unref(Kt)*s.value,y1:u,x2:h.x+e.unref(Kt)*s.value,y2:u,"stroke-width":r.value},null,8,lp))),128)),e.createElementVNode("ellipse",{class:e.normalizeClass(["strudel-flow-sheet__head",{"strudel-flow-sheet__head--open":!h.filled}]),cx:h.x,cy:E.y,rx:e.unref(jt)*s.value,ry:e.unref(Vl)*s.value,transform:`rotate(${_p} ${h.x} ${E.y})`,"stroke-width":r.value*1.5},null,10,op),E.accidental!==null?(e.openBlock(),e.createElementBlock("text",{key:0,class:"strudel-flow-sheet__accidental",x:h.x-e.unref(Hl)*s.value,y:E.y+s.value*.5,"text-anchor":"middle","font-size":s.value*2},e.toDisplayString(e.unref(Ol)[E.accidental]),9,ap)):e.createCommentVNode("",!0)],64))),128)),h.stem!==null?(e.openBlock(),e.createElementBlock("line",{key:0,class:"strudel-flow-sheet__stem",x1:h.stem.x1,y1:h.stem.y1,x2:h.stem.x2,y2:h.stem.y2,"stroke-width":r.value},null,8,sp)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.flags,(E,p)=>(e.openBlock(),e.createElementBlock("path",{key:`flag-${p}`,class:"strudel-flow-sheet__flag",d:E,fill:"none","stroke-width":r.value*1.5},null,8,rp))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.dots,(E,p)=>(e.openBlock(),e.createElementBlock("circle",{key:`dot-${p}`,class:"strudel-flow-sheet__dot",cx:E.x,cy:E.y,r:s.value*.18},null,8,cp))),128))]))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value.brackets,(h,k)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:`bracket-${k}`},[e.createElementVNode("path",{class:"strudel-flow-sheet__bracket",d:h.path,fill:"none","stroke-width":r.value},null,8,ip),e.createElementVNode("text",{class:"strudel-flow-sheet__bracket-label",x:h.labelX,y:a.value.bracketLabelY,"text-anchor":"middle","font-size":e.unref(xt)*s.value*1.4}," 3 ",8,dp)],64))),128))],8,Z_))]))}}),pp={class:"strudel-flow-tab-staff nowheel"},fp=["data-notation","width","height","viewBox","aria-label"],Ep=["stroke-width"],hp=["x1","y1","x2","y2"],gp=["x1","y1","x2","y2","stroke-width"],Sp=["d","stroke-width"],kp=["x","y","font-size"],bp=["x"],Tp=["x","y","width","height"],wp=["x1","y1","x2","y2","stroke-width"],Lp=["x1","y1","x2","y2","stroke-width"],yp=["d","stroke-width"],Fp=["x","y","font-size"],Za="Arial, Helvetica, sans-serif",Ja=e.defineComponent({__name:"StrudelFlowTabStaff",props:{bars:{},instrument:{},beatsPerBar:{}},setup(t){const n=t,l=e.computed(()=>Ea(n.bars,n.instrument,n.beatsPerBar)),o=e.computed(()=>hl*l.value.lineGap),a=e.computed(()=>`${n.instrument==="bass"?"Bass":"Guitar"} tab, ${n.bars.length} bars`);return(s,r)=>(e.openBlock(),e.createElementBlock("div",pp,[(e.openBlock(),e.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",class:"strudel-flow-tab-staff__staff","data-notation":t.instrument,width:l.value.width,height:l.value.height,viewBox:`0 0 ${l.value.width} ${l.value.height}`,role:"img","aria-label":a.value},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value.strings,(c,i)=>(e.openBlock(),e.createElementBlock("g",{key:`string-${i}`,class:"strudel-flow-tab-staff__string","stroke-width":o.value},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c,(m,_)=>(e.openBlock(),e.createElementBlock("line",{key:_,x1:m.x1,y1:m.y1,x2:m.x2,y2:m.y2},null,8,hp))),128))],8,Ep))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value.barLines,(c,i)=>(e.openBlock(),e.createElementBlock("line",{key:`bar-${i}`,class:"strudel-flow-tab-staff__bar-line",x1:c.x1,y1:c.y1,x2:c.x2,y2:c.y2,"stroke-width":o.value},null,8,gp))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value.ties,(c,i)=>(e.openBlock(),e.createElementBlock("path",{key:`tie-${i}`,class:"strudel-flow-tab-staff__tie",d:c,fill:"none","stroke-width":o.value},null,8,Sp))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value.frets,(c,i)=>(e.openBlock(),e.createElementBlock("text",{key:`fret-${i}`,class:"strudel-flow-tab-staff__fret",x:c.x,y:c.y+e.unref(kl)*l.value.lineGap,"text-anchor":"middle","font-family":Za,"font-weight":"700","font-size":e.unref(Sl)*l.value.lineGap},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.digits,(m,_)=>(e.openBlock(),e.createElementBlock("tspan",{key:_,x:m.x},e.toDisplayString(m.digit),9,bp))),128))],8,kp))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value.rests,(c,i)=>(e.openBlock(),e.createElementBlock("rect",{key:`rest-${i}`,class:"strudel-flow-tab-staff__rest",x:c.x,y:c.y,width:c.width,height:c.height},null,8,Tp))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value.stems,(c,i)=>(e.openBlock(),e.createElementBlock("line",{key:`stem-${i}`,class:"strudel-flow-tab-staff__stem",x1:c.x,y1:l.value.stemTop,x2:c.x,y2:l.value.stemBottom,"stroke-width":e.unref(gl)*l.value.lineGap},null,8,wp))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value.beams,(c,i)=>(e.openBlock(),e.createElementBlock("line",{key:`beam-${i}`,class:"strudel-flow-tab-staff__beam",x1:c.x1,y1:c.y1,x2:c.x2,y2:c.y2,"stroke-width":e.unref(At)*l.value.lineGap},null,8,Lp))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value.brackets,(c,i)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:`bracket-${i}`},[e.createElementVNode("path",{class:"strudel-flow-tab-staff__bracket",d:c.path,fill:"none","stroke-width":o.value},null,8,yp),e.createElementVNode("text",{class:"strudel-flow-tab-staff__bracket-label",x:c.labelX,y:l.value.bracketLabelY,"text-anchor":"middle","font-family":Za,"font-size":e.unref(xt)*l.value.lineGap}," 3 ",8,Fp)],64))),128))],8,fp))]))}}),In=Symbol("strudelFlowNotationContext"),$p={key:0,class:"strudel-flow-field"},Bp=["aria-checked"],Qa=e.defineComponent({__name:"StrudelFlowNotation",props:{data:{}},emits:["update"],setup(t,{emit:n}){const l=t,o=n,a=e.inject(In,null),s=j.useNodeId(),r=e.ref([]),c=e.computed(()=>(a==null?void 0:a.value.beatsPerCycle)??ee),i=e.computed(()=>(a==null?void 0:a.value.soundOf(s))??""),m=new Set(["names","text"]),_=e.computed(()=>l.data.head==="chord"),f=e.computed(()=>{const p=ca(l.data.notation,i.value);return _.value&&!m.has(p)?"names":p}),g=p=>{var u;return((u=Ne.find(S=>S.value===p))==null?void 0:u.label)??p},h=e.computed(()=>Ne.filter(p=>!_.value||m.has(p.value)).map(p=>p.value==="auto"?{...p,label:`Auto: ${g($n(i.value))}`}:p));e.watch([()=>l.data.pattern,c,()=>a==null?void 0:a.value.readNoteBars],async([p,u,S])=>{const T=S==null?[]:await S(p,u);p===l.data.pattern&&(r.value=T)},{immediate:!0});const k=()=>{o("update",{...l.data,showPattern:l.data.showPattern!==!0})},E=p=>{var S;const u=(S=Ne.find(T=>T.value===p))==null?void 0:S.value;u!==void 0&&o("update",{...l.data,notation:u})};return(p,u)=>{var S;return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(Q,{label:"Notation","model-value":t.data.notation,options:h.value,"onUpdate:modelValue":E},null,8,["model-value","options"]),f.value!=="text"&&((S=e.unref(a))!=null&&S.readNoteBars)?(e.openBlock(),e.createElementBlock("div",$p,[u[2]||(u[2]=e.createElementVNode("span",{class:"strudel-flow-field__label"},"Mini notation",-1)),e.createElementVNode("button",{type:"button",role:"switch",class:"strudel-flow-switch nodrag","aria-checked":t.data.showPattern===!0,"aria-label":"Show mini notation",onClick:k},[...u[1]||(u[1]=[e.createElementVNode("span",{class:"strudel-flow-switch__thumb","aria-hidden":"true"},null,-1)])],8,Bp)])):e.createCommentVNode("",!0),f.value==="grid"?(e.openBlock(),e.createBlock(P_,{key:1,bars:r.value,"beats-per-bar":c.value,"onUpdate:pattern":u[0]||(u[0]=T=>o("update",{...t.data,pattern:T}))},null,8,["bars","beats-per-bar"])):r.value.length>0&&f.value!=="text"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[f.value==="bass"||f.value==="guitar"?(e.openBlock(),e.createBlock(Ja,{key:0,bars:r.value,instrument:f.value,"beats-per-bar":c.value},null,8,["bars","instrument","beats-per-bar"])):f.value==="sheet"?(e.openBlock(),e.createBlock(qa,{key:1,bars:r.value,"beats-per-bar":c.value},null,8,["bars","beats-per-bar"])):f.value==="piano"?(e.openBlock(),e.createBlock(Ya,{key:2,bars:r.value,"beats-per-bar":c.value},null,8,["bars","beats-per-bar"])):(e.openBlock(),e.createBlock(Ka,{key:3,bars:r.value,"beats-per-bar":c.value},null,8,["bars","beats-per-bar"]))],64)):e.createCommentVNode("",!0)],64)}}}),Rp={key:0,class:"strudel-flow-field"},Op=["value"],Np=e.defineComponent({__name:"StrudelFlowPatternControls",props:{data:{}},emits:["update"],setup(t,{emit:n}){const l=t,o=n,a=e.inject(In,null),s=e.computed(()=>!(a!=null&&a.value.readNoteBars)||l.data.notation==="text"||l.data.showPattern===!0),r=c=>{const i=c.target;i instanceof HTMLTextAreaElement&&o("update",{...l.data,pattern:i.value})};return(c,i)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(Qa,{data:t.data,onUpdate:i[0]||(i[0]=m=>o("update",m))},null,8,["data"]),s.value?(e.openBlock(),e.createElementBlock("label",Rp,[i[1]||(i[1]=e.createElementVNode("span",{class:"strudel-flow-field__label"},"Notes in mini notation",-1)),e.createElementVNode("textarea",{class:"strudel-flow-textarea",value:t.data.pattern,"aria-label":"Notes pattern",rows:"2",spellcheck:"false",onInput:r},null,40,Op)])):e.createCommentVNode("",!0)],64))}}),Ap={key:0,class:"strudel-flow-sample-steps__hint"},Cp=["aria-label"],Dp={key:0,class:"strudel-flow-sample-steps__layer-label"},Mp=["aria-label","onClick"],Pp={class:"strudel-flow-sample-steps__sequence"},Up={class:"strudel-flow-sample-steps__tile-header"},Ip={class:"strudel-flow-sample-steps__index","aria-hidden":"true"},Vp={key:0,class:"strudel-flow-sample-steps__bracket",role:"group","aria-label":"Group timing"},Wp=["aria-pressed","aria-label","title","onClick"],Gp=["aria-label","title","onClick"],Hp=["value","aria-label","onChange"],xp={key:4,class:"strudel-flow-sample-steps__modifier"},Xp={class:"strudel-flow-sample-steps__add"},zp=["onClick"],jp=["onClick"],Kp=e.defineComponent({__name:"StrudelFlowSampleSteps",props:{layers:{},sampleGroups:{},nested:{type:Boolean}},emits:["update:layers"],setup(t,{emit:n}){const l=t,o=n,a=[{value:"subdivide",label:"Fit in one step",icon:e.markRaw(L.Brackets)},{value:"alternate",label:"One per cycle",icon:e.markRaw(L.ArrowLeftRight)}],s=e.markRaw(L.Plus),r=e.markRaw(L.Pause),c=e.markRaw(L.Code),i=w=>{var b;return(b=Yt.find(F=>F.value===w))==null?void 0:b.kind},m=w=>{const b=i(w);return b===void 0?c:Hd[b]},_=w=>{const b=Kl.map(F=>({label:F.label,options:Yt.filter(B=>B.kind===F.id)}));return i(w)===void 0?[{label:"In this pattern",options:[{value:w,label:w}]},...b]:b},f=w=>w.kind==="group"&&w.layers.every(b=>b.length===0),g=w=>{o("update:layers",w)},h=(w,b)=>{g(l.layers.map((F,B)=>B===w?b.filter(D=>!f(D)):F))},k=(w,b,F)=>{h(w,(l.layers[w]??[]).map((B,D)=>D===b?F:B))},E=(w,b)=>{h(w,(l.layers[w]??[]).filter((F,B)=>B!==b))},p=(w,b)=>{h(w,[...l.layers[w]??[],b])},u=(w,b)=>{b.length>0&&p(w,{kind:"sound",sound:b,modifier:""})},S=(w,b,F)=>{F.length>0&&k(w,b,{kind:"sound",sound:F,modifier:""})},T=w=>{p(w,{kind:"group",bracket:"subdivide",layers:[[{kind:"rest"}]],modifier:""})},O=()=>{g([...l.layers,[{kind:"rest"}]])},V=w=>{g(l.layers.filter((b,F)=>F!==w))},A=w=>w.target instanceof HTMLInputElement?w.target.value:"",y=w=>w.kind==="sound"?w.sound:w.kind==="text"?"notation":w.kind;return(w,b)=>{const F=e.resolveComponent("StrudelFlowSampleSteps",!0);return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["strudel-flow-sample-steps",{"strudel-flow-sample-steps--nested":t.nested}])},[t.nested?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("p",Ap," Steps share one cycle, left to right. Layers play together. ")),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.layers,(B,D)=>(e.openBlock(),e.createElementBlock("div",{key:D,class:"strudel-flow-sample-steps__layer",role:"group","aria-label":t.layers.length>1?`Layer ${D+1}`:"Steps"},[t.layers.length>1?(e.openBlock(),e.createElementBlock("div",Dp,[e.createVNode(e.unref(L.Layers),{"aria-hidden":"true"}),e.createElementVNode("span",null,"Layer "+e.toDisplayString(D+1),1),e.createElementVNode("button",{type:"button",class:"strudel-flow-calls__remove nodrag","aria-label":`Remove layer ${D+1}`,title:"Remove layer",onClick:N=>V(D)},[e.createVNode(e.unref(L.X),{"aria-hidden":"true"})],8,Mp)])):e.createCommentVNode("",!0),e.createElementVNode("ol",Pp,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(B,(N,C)=>(e.openBlock(),e.createElementBlock("li",{key:C,class:e.normalizeClass(["strudel-flow-sample-steps__tile",`strudel-flow-sample-steps__tile--${N.kind}`])},[e.createElementVNode("div",Up,[e.createElementVNode("span",Ip,e.toDisplayString(C+1),1),N.kind==="group"?(e.openBlock(),e.createElementBlock("div",Vp,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(a,P=>e.createElementVNode("button",{key:P.value,type:"button",class:e.normalizeClass(["strudel-flow-sample-steps__bracket-button nodrag",{"strudel-flow-sample-steps__bracket-button--active":N.bracket===P.value}]),"aria-pressed":N.bracket===P.value,"aria-label":P.label,title:P.label,onClick:R=>k(D,C,{...N,bracket:P.value})},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(P.icon),{"aria-hidden":"true"}))],10,Wp)),64))])):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",class:"strudel-flow-calls__remove strudel-flow-sample-steps__remove nodrag","aria-label":`Remove ${y(N)} step ${C+1}`,title:`Remove ${y(N)}`,onClick:P=>E(D,C)},[e.createVNode(e.unref(L.X),{"aria-hidden":"true"})],8,Gp)]),N.kind==="group"?(e.openBlock(),e.createBlock(F,{key:0,layers:N.layers,"sample-groups":t.sampleGroups,nested:"","onUpdate:layers":P=>k(D,C,{...N,layers:P})},null,8,["layers","sample-groups","onUpdate:layers"])):N.kind==="sound"?(e.openBlock(),e.createBlock(Xe,{key:1,label:`Step ${C+1} sample`,"model-value":N.sound,groups:t.sampleGroups,"onUpdate:modelValue":P=>k(D,C,{...N,sound:P})},null,8,["label","model-value","groups","onUpdate:modelValue"])):N.kind==="rest"?(e.openBlock(),e.createBlock(Xe,{key:2,label:`Step ${C+1} sample`,"model-value":"",placeholder:"Rest","empty-icon":e.unref(r),groups:t.sampleGroups,"onUpdate:modelValue":P=>S(D,C,P)},null,8,["label","empty-icon","groups","onUpdate:modelValue"])):(e.openBlock(),e.createElementBlock("input",{key:3,class:"strudel-flow-calls__text nodrag",value:N.text,"aria-label":`Step ${C+1} mini notation`,spellcheck:"false",onChange:P=>k(D,C,{kind:"text",text:A(P)})},null,40,Hp)),N.kind==="sound"||N.kind==="group"?(e.openBlock(),e.createElementBlock("div",xp,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(m(N.modifier)),{class:"strudel-flow-sample-steps__modifier-icon","aria-hidden":"true"})),e.createVNode(Q,{label:N.kind==="group"?"Group plays":`Step ${C+1} plays`,"hide-label":"","model-value":N.modifier,groups:_(N.modifier),"onUpdate:modelValue":P=>k(D,C,{...N,modifier:P})},null,8,["label","model-value","groups","onUpdate:modelValue"])])):e.createCommentVNode("",!0)],2))),128)),e.createElementVNode("li",Xp,[t.sampleGroups.length>0?(e.openBlock(),e.createBlock(Xe,{key:0,label:"Add sample","model-value":"",placeholder:"Sample","empty-icon":e.unref(s),groups:t.sampleGroups,"onUpdate:modelValue":N=>u(D,N)},null,8,["empty-icon","groups","onUpdate:modelValue"])):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",class:"strudel-flow-sample-steps__add-button nodrag","aria-label":"Add rest",title:"Add a rest",onClick:N=>p(D,{kind:"rest"})},[e.createVNode(e.unref(L.Pause),{"aria-hidden":"true"})],8,zp),e.createElementVNode("button",{type:"button",class:"strudel-flow-sample-steps__add-button nodrag","aria-label":"Add group",title:"Add a group of steps that share one step",onClick:N=>T(D)},[e.createVNode(e.unref(L.Brackets),{"aria-hidden":"true"})],8,jp)])])],8,Cp))),128)),t.nested?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"strudel-flow-calls__add nodrag",title:"Add a layer that plays alongside",onClick:O},[e.createVNode(e.unref(L.Layers),{"aria-hidden":"true"}),b[0]||(b[0]=e.createTextVNode(" Add layer ",-1))]))],2)}}}),Yp={class:"strudel-flow-field strudel-flow-field--inline"},qp=["aria-checked"],Zp=["value"],Jp=e.defineComponent({__name:"StrudelFlowSamplesControls",props:{data:{},sampleGroups:{}},emits:["update"],setup(t,{emit:n}){const l=t,o=n,a=e.computed(()=>Nn(l.data.pattern)),s=i=>{o("update",{...l.data,...i})},r=i=>{s({pattern:An(i)})},c=i=>{i.target instanceof HTMLTextAreaElement&&s({pattern:i.target.value})};return(i,m)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(Kp,{layers:a.value,"sample-groups":t.sampleGroups??[],"onUpdate:layers":r},null,8,["layers","sample-groups"]),e.createElementVNode("div",Yp,[m[2]||(m[2]=e.createElementVNode("span",{class:"strudel-flow-field__label"},"Mini notation",-1)),e.createElementVNode("button",{type:"button",role:"switch",class:"strudel-flow-switch nodrag","aria-checked":t.data.showPattern===!0,"aria-label":"Show mini notation",onClick:m[0]||(m[0]=_=>s({showPattern:t.data.showPattern!==!0}))},[...m[1]||(m[1]=[e.createElementVNode("span",{class:"strudel-flow-switch__thumb","aria-hidden":"true"},null,-1)])],8,qp)]),t.data.showPattern===!0?(e.openBlock(),e.createElementBlock("textarea",{key:0,class:"strudel-flow-textarea",value:t.data.pattern,"aria-label":"Samples pattern",rows:"2",spellcheck:"false",onInput:c},null,40,Zp)):e.createCommentVNode("",!0)],64))}}),Qp={class:"strudel-flow-visualizer__settings"},vp={class:"strudel-flow-mode",role:"group","aria-label":"Where the visual draws"},ef=["aria-pressed","onClick"],va=e.defineComponent({__name:"StrudelFlowVisualizerControls",props:{data:{}},emits:["update"],setup(t,{emit:n}){const l=t,o=n,a=r=>{o("update",{...l.data,...r})},s=r=>{const c=Be.find(i=>i.value===r);c!==void 0&&a({visual:c.value})};return(r,c)=>(e.openBlock(),e.createElementBlock("div",Qp,[e.createVNode(Q,{label:"Type","hide-label":"","model-value":t.data.visual,options:e.unref(Be),"onUpdate:modelValue":s},null,8,["model-value","options"]),e.createElementVNode("div",vp,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(jn),i=>(e.openBlock(),e.createElementBlock("button",{key:i.value,type:"button",class:e.normalizeClass(["strudel-flow-mode__button nodrag",{"strudel-flow-mode__button--active":t.data.placement===i.value}]),"aria-pressed":t.data.placement===i.value,onClick:m=>a({placement:i.value==="background"?"background":"inline"})},e.toDisplayString(i.label),11,ef))),128))])]))}}),tf={key:0,class:"strudel-flow-visualizer__hint"},es=e.defineComponent({__name:"StrudelFlowVisualPreview",props:{placement:{},widgetId:{}},setup(t){const n=t,l=e.ref(null),o=e.ref(!1);let a=null;const s=e.computed(()=>n.placement==="background"),r=e.computed(()=>n.widgetId===null&&n.placement==="inline"?"Connect an instrument to draw its visual here.":"Press Play to draw the visual here."),c=e.computed(()=>n.placement==="background"?Zn:n.widgetId),i=()=>{const _=c.value===null?null:document.getElementById(c.value);return _ instanceof HTMLCanvasElement&&_.width>0&&_.height>0?_:null},m=()=>{const _=i(),f=l.value,g=f==null?void 0:f.getContext("2d");_!==null&&f!==null&&g!==null&&g!==void 0&&((f.width!==_.width||f.height!==_.height)&&(f.width=_.width,f.height=_.height),g.clearRect(0,0,f.width,f.height),g.drawImage(_,0,0)),o.value!==(_!==null)&&(o.value=_!==null),a=window.requestAnimationFrame(m)};return e.onMounted(()=>{a=window.requestAnimationFrame(m)}),e.onBeforeUnmount(()=>{a!==null&&window.cancelAnimationFrame(a)}),(_,f)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["strudel-flow-visual-preview",{"strudel-flow-visual-preview--backdrop":s.value}])},[e.withDirectives(e.createElementVNode("canvas",{ref_key:"previewCanvas",ref:l,class:"strudel-flow-visual-preview__canvas",role:"img","aria-label":"Live visual of the pattern"},null,512),[[e.vShow,o.value]]),!o.value&&!s.value?(e.openBlock(),e.createElementBlock("p",tf,e.toDisplayString(r.value),1)):e.createCommentVNode("",!0)],2))}}),nf={class:"strudel-flow-knobs"},ts=e.defineComponent({__name:"StrudelFlowSpaceControls",props:{data:{}},emits:["update"],setup(t,{emit:n}){const l=t,o=n,a=s=>{o("update",{...l.data,...s})};return(s,r)=>(e.openBlock(),e.createElementBlock("div",nf,[e.createVNode(H,{label:"Room","model-value":t.data.room,min:0,max:1,step:.01,"onUpdate:modelValue":r[0]||(r[0]=c=>a({room:c}))},null,8,["model-value"]),e.createVNode(H,{label:"Size","model-value":t.data.roomSize,min:0,max:20,step:.1,"onUpdate:modelValue":r[1]||(r[1]=c=>a({roomSize:c}))},null,8,["model-value"]),e.createVNode(H,{label:"Fade","model-value":t.data.roomFade,min:0,max:10,step:.1,"onUpdate:modelValue":r[2]||(r[2]=c=>a({roomFade:c}))},null,8,["model-value"]),e.createVNode(H,{label:"Low-pass","model-value":t.data.roomLowPass,min:0,max:2e4,step:100,suffix:"Hz","onUpdate:modelValue":r[3]||(r[3]=c=>a({roomLowPass:c}))},null,8,["model-value"]),e.createVNode(H,{label:"Dim","model-value":t.data.roomDim,min:0,max:2e4,step:100,suffix:"Hz","onUpdate:modelValue":r[4]||(r[4]=c=>a({roomDim:c}))},null,8,["model-value"])]))}}),lf={class:"strudel-flow-voice"},of={class:"strudel-flow-voice__waveforms",role:"group","aria-label":"Voice waveform"},af=["aria-label","title","aria-pressed","onClick"],sf={viewBox:"0 0 36 32","aria-hidden":"true"},rf=["d"],ns=e.defineComponent({__name:"StrudelFlowVoiceControls",props:{data:{},voiceGroups:{}},emits:["update"],setup(t,{emit:n}){const l=t,o=n,a=e.computed(()=>l.data.sound),s=new Set(yt.map(m=>m.value)),r=e.computed(()=>[{label:"Waveforms",samples:yt},...(l.voiceGroups??[]).map(m=>({label:m.label,samples:m.samples.filter(_=>!s.has(_.value))})).filter(m=>m.samples.length>0)]),c=m=>{o("update",{kind:"voice",sound:m})},i=[{value:"sine",label:"Sine",path:"M2 16 C8 0 12 0 18 16 S28 32 34 16"},{value:"triangle",label:"Triangle",path:"M2 24 L10 8 L26 24 L34 8"},{value:"sawtooth",label:"Saw",path:"M2 24 L17 8 L17 24 L32 8 L32 24"},{value:"square",label:"Square",path:"M2 24 L2 8 L18 8 L18 24 L34 24 L34 8"}];return(m,_)=>(e.openBlock(),e.createElementBlock("div",lf,[e.createElementVNode("div",of,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(i,f=>e.createElementVNode("button",{key:f.value,type:"button",class:e.normalizeClass(["strudel-flow-voice__waveform nodrag",{"strudel-flow-voice__waveform--active":a.value===f.value}]),"aria-label":f.label,title:f.label,"aria-pressed":a.value===f.value,onClick:g=>c(f.value)},[(e.openBlock(),e.createElementBlock("svg",sf,[e.createElementVNode("path",{d:f.path},null,8,rf)]))],10,af)),64))]),e.createVNode(Xe,{label:"Voice","model-value":a.value,groups:r.value,"onUpdate:modelValue":c},null,8,["model-value","groups"])]))}}),ls=Symbol("strudelFlowVisualizerWidgetIds"),cf=["data-node-kind"],df={class:"strudel-flow-node__header"},mf={class:"strudel-flow-node__title"},uf=["title","aria-label","aria-pressed"],_f=["title","aria-label","aria-pressed"],pf=["title","aria-label","aria-expanded"],ff={key:2,class:"strudel-flow-node__menu nodrag",role:"menu"},Ef={key:2,class:"strudel-flow-node__code nodrag"},hf={class:"strudel-flow-node__body nodrag"},gf="pattern",os=e.defineComponent({__name:"StrudelFlowNode",props:{id:{},data:{},selected:{type:Boolean},sampleGroups:{},voiceGroups:{},isSoloed:{type:Boolean},isPlaying:{type:Boolean}},emits:["update","remove","showCode","solo"],setup(t,{emit:n}){const l=t,o=n,a={pad:e.markRaw(Xa),beats:e.markRaw(Aa),chords:e.markRaw(Pa),notes:e.markRaw(Np),samples:e.markRaw(Jp),code:e.markRaw(Ia),arrange:e.markRaw(Ua),voice:e.markRaw(ns),filter:e.markRaw(Ha),delay:e.markRaw(Va),space:e.markRaw(ts),gain:e.markRaw(xu),level:e.markRaw(xa),mask:e.markRaw(Ju),struct:e.markRaw(r_),slow:e.markRaw(vu),voicing:e.markRaw(i_),envelope:e.markRaw(Ga),visualizer:e.markRaw(va)},s=new Set(["samples","beats"]),r=e.ref(!1),c=e.ref(!1),i=e.computed(()=>fn(l.data.kind)),m=e.computed(()=>i.value.title),_=e.computed(()=>s.has(l.data.kind)?{sampleGroups:l.sampleGroups??[]}:l.data.kind==="voice"?{voiceGroups:l.voiceGroups??[]}:{}),f=e.inject(ls,null),g=e.computed(()=>(f==null?void 0:f.value[l.id])??null),h=e.computed(()=>Y(l.data.kind)),k=e.computed(()=>"muted"in l.data&&l.data.muted===!0),E=e.computed(()=>h.value||l.data.kind==="voice"),p=e.computed(()=>`${l.isSoloed?"End solo of":"Solo"} ${m.value}`),u=e.computed(()=>`${m.value} pattern input`),S=e.computed(()=>`${m.value} pattern output`),T=e.computed(()=>`${k.value?"Unmute":"Mute"} ${m.value}`),O=e.computed(()=>Pe(l.data,h.value?"":gf)),V=F=>{o("update",F)},A=()=>{o("update",Object.assign({},l.data,{muted:!k.value}))},y=()=>{c.value=!c.value,r.value=!1},w=()=>{r.value=!1,o("showCode",l.id)},b=()=>{r.value=!1,o("remove",l.id)};return(F,B)=>(e.openBlock(),e.createElementBlock("article",{class:e.normalizeClass(["strudel-flow-node",{"strudel-flow-node--selected":t.selected,"strudel-flow-node--muted":k.value,"strudel-flow-node--playing":t.isPlaying}]),"data-node-kind":t.data.kind},[t.data.kind==="visualizer"&&t.data.placement==="background"?(e.openBlock(),e.createBlock(es,{key:0,placement:t.data.placement,"widget-id":g.value},null,8,["placement","widget-id"])):e.createCommentVNode("",!0),h.value?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(e.unref(j.Handle),{key:1,type:"target",position:e.unref(j.Position).Left,class:"strudel-flow-node__handle strudel-flow-node__handle--input","aria-label":u.value},null,8,["position","aria-label"])),e.createElementVNode("header",df,[e.createElementVNode("h3",mf,e.toDisplayString(m.value),1),E.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"strudel-flow-node__action nodrag",title:p.value,"aria-label":p.value,"aria-pressed":t.isSoloed===!0,onPointerdown:B[0]||(B[0]=e.withModifiers(()=>{},["stop"])),onClick:B[1]||(B[1]=e.withModifiers(D=>o("solo",t.id),["stop"]))},[e.createVNode(e.unref(L.Headphones),{"aria-hidden":"true"})],40,uf)):e.createCommentVNode("",!0),h.value?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"strudel-flow-node__action nodrag",title:T.value,"aria-label":T.value,"aria-pressed":k.value,onPointerdown:B[2]||(B[2]=e.withModifiers(()=>{},["stop"])),onClick:e.withModifiers(A,["stop"])},[k.value?(e.openBlock(),e.createBlock(e.unref(L.VolumeX),{key:0,"aria-hidden":"true"})):(e.openBlock(),e.createBlock(e.unref(L.Volume2),{key:1,"aria-hidden":"true"}))],40,_f)):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",class:"strudel-flow-node__action nodrag",title:`${m.value} options`,"aria-label":`${m.value} options`,"aria-expanded":r.value,onPointerdown:B[3]||(B[3]=e.withModifiers(()=>{},["stop"])),onClick:B[4]||(B[4]=e.withModifiers(D=>r.value=!r.value,["stop"])),onKeydown:B[5]||(B[5]=e.withKeys(D=>r.value=!1,["escape"]))},[e.createVNode(e.unref(L.Ellipsis),{"aria-hidden":"true"})],40,pf),r.value?(e.openBlock(),e.createElementBlock("div",ff,[e.createElementVNode("button",{type:"button",class:"strudel-flow-node__menu-item",role:"menuitem",onPointerdown:B[6]||(B[6]=e.withModifiers(()=>{},["stop"])),onClick:e.withModifiers(y,["stop"])},[e.createVNode(e.unref(L.Code2),{"aria-hidden":"true"}),e.createTextVNode(" "+e.toDisplayString(c.value?"Hide code":"View code"),1)],32),e.createElementVNode("button",{type:"button",class:"strudel-flow-node__menu-item",role:"menuitem",onPointerdown:B[7]||(B[7]=e.withModifiers(()=>{},["stop"])),onClick:e.withModifiers(w,["stop"])},[e.createVNode(e.unref(L.SquareCode),{"aria-hidden":"true"}),B[9]||(B[9]=e.createTextVNode(" Go to code ",-1))],32),e.createElementVNode("button",{type:"button",class:"strudel-flow-node__menu-item strudel-flow-node__menu-item--danger",role:"menuitem",onPointerdown:B[8]||(B[8]=e.withModifiers(()=>{},["stop"])),onClick:e.withModifiers(b,["stop"])},[e.createVNode(e.unref(L.Trash2),{"aria-hidden":"true"}),B[10]||(B[10]=e.createTextVNode(" Remove ",-1))],32)])):e.createCommentVNode("",!0)]),c.value?(e.openBlock(),e.createElementBlock("pre",Ef,e.toDisplayString(O.value),1)):e.createCommentVNode("",!0),e.createElementVNode("div",hf,[t.data.kind==="visualizer"&&t.data.placement==="inline"?(e.openBlock(),e.createBlock(es,{key:0,placement:t.data.placement,"widget-id":g.value},null,8,["placement","widget-id"])):e.createCommentVNode("",!0),t.data.kind==="effect"?(e.openBlock(),e.createBlock(ou,{key:1,data:t.data,onUpdate:V},null,8,["data"])):(e.openBlock(),e.createBlock(e.resolveDynamicComponent(a[t.data.kind]),e.mergeProps({key:2,data:t.data},_.value,{onUpdate:V}),null,16,["data"]))]),e.createVNode(e.unref(j.Handle),{type:"source",position:e.unref(j.Position).Right,class:"strudel-flow-node__handle strudel-flow-node__handle--output","aria-label":S.value},null,8,["position","aria-label"])],10,cf))}}),Sf={class:"strudel-flow-radial",role:"dialog","aria-modal":"true","aria-label":"Add node"},kf=["viewBox"],bf=["d","onMouseenter","onClick"],Tf=["d","onMouseenter","onClick"],wf=["aria-label","aria-expanded","onClick","onFocus"],Lf=["aria-label","onClick","onFocus"],ze=380,yf=73,Ff=145,as=150,ss=e.defineComponent({__name:"StrudelFlowRadialMenu",emits:["add"],setup(t,{expose:n,emit:l}){const o=l,a=ze/2,s=[{label:"Instruments",category:"Instruments",icon:e.markRaw(L.Piano)},{label:"Effects",category:"Effects",icon:e.markRaw(L.SlidersHorizontal)},{label:"Sounds",category:"Sounds",icon:e.markRaw(L.AudioLines)}],r={pad:e.markRaw(L.Grid3x3),beats:e.markRaw(L.Drum),chords:e.markRaw(L.Music2),notes:e.markRaw(L.Music),samples:e.markRaw(L.Disc3),code:e.markRaw(L.Code),arrange:e.markRaw(L.ListOrdered),voice:e.markRaw(L.AudioLines),filter:e.markRaw(L.SlidersHorizontal),delay:e.markRaw(L.Clock),space:e.markRaw(L.Waves),gain:e.markRaw(L.Gauge),level:e.markRaw(L.Volume1),mask:e.markRaw(L.EyeOff),struct:e.markRaw(L.Rows3),slow:e.markRaw(L.Hourglass),voicing:e.markRaw(L.Piano),envelope:e.markRaw(L.Activity),visualizer:e.markRaw(L.AudioWaveform),effect:e.markRaw(L.Wand2)},c=e.ref(!1),i=e.ref(0),m=e.ref(null),_=e.computed(()=>s.map(b=>({...b,items:ct.filter(F=>F.category===b.category)}))),f=e.computed(()=>_.value[i.value]??null),g=e.computed(()=>90+180/_.value.length),h=e.computed(()=>_.value.map((b,F)=>E(yf,g.value-(F+.5)*360/_.value.length))),k=e.computed(()=>{var F;const b=((F=f.value)==null?void 0:F.items)??[];return b.map((B,D)=>E(Ff,b.length===1?90:as-(D+.5)*360/b.length))}),E=(b,F)=>{const B=F*Math.PI/180;return{x:a+b*Math.cos(B),y:a-b*Math.sin(B)}},p=(b,F)=>[`M ${a+b} ${a}`,`A ${b} ${b} 0 1 ${F} ${a-b} ${a}`,`A ${b} ${b} 0 1 ${F} ${a+b} ${a}`,"Z"].join(" "),u=(b,F,B,D,N=180)=>{const C=360/F;if(F===1)return`${p(B,1)} ${p(D,0)}`;const P=N-b*C,R=P-C,U=E(B,P),M=E(B,R),le=E(D,P),ms=E(D,R),us=C>180?1:0;return[`M ${U.x} ${U.y}`,`A ${B} ${B} 0 ${us} 1 ${M.x} ${M.y}`,`L ${ms.x} ${ms.y}`,`A ${D} ${D} 0 ${us} 0 ${le.x} ${le.y}`,"Z"].join(" ")},S=b=>u(b,_.value.length,110,36,g.value),T=b=>f.value===null?"":u(b,f.value.items.length,178,112,as),O=b=>({left:`${b.x/ze*100}%`,top:`${b.y/ze*100}%`}),V=()=>{i.value=0,c.value=!0},A=()=>{c.value=!1},y=b=>{o("add",b),A()},w=b=>{b.key==="Escape"&&c.value&&A()};return e.onMounted(()=>window.addEventListener("keydown",w)),e.onBeforeUnmount(()=>window.removeEventListener("keydown",w)),n({open:V}),(b,F)=>{var B,D;return c.value?(e.openBlock(),e.createElementBlock("div",{key:1,class:"strudel-flow-radial__overlay",onClick:e.withModifiers(A,["self"])},[e.createElementVNode("div",Sf,[(e.openBlock(),e.createElementBlock("svg",{class:"strudel-flow-radial__sectors",viewBox:`0 0 ${ze} ${ze}`,"aria-hidden":"true"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(_.value,(N,C)=>(e.openBlock(),e.createElementBlock("path",{key:`category-${C}`,d:S(C),class:e.normalizeClass(["strudel-flow-radial__sector",{"strudel-flow-radial__sector--active":i.value===C,"strudel-flow-radial__sector--hover":m.value===`category-${C}`}]),onMouseenter:P=>m.value=`category-${C}`,onMouseleave:F[0]||(F[0]=P=>m.value=null),onClick:P=>i.value=C},null,42,bf))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(((B=f.value)==null?void 0:B.items)??[],(N,C)=>(e.openBlock(),e.createElementBlock("path",{key:`item-${C}`,d:T(C),class:e.normalizeClass(["strudel-flow-radial__sector strudel-flow-radial__sector--item",{"strudel-flow-radial__sector--hover":m.value===`item-${C}`}]),onMouseenter:P=>m.value=`item-${C}`,onMouseleave:F[1]||(F[1]=P=>m.value=null),onClick:P=>y(N.kind)},null,42,Tf))),128))],8,kf)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(_.value,(N,C)=>(e.openBlock(),e.createElementBlock("button",{key:N.label,type:"button",class:e.normalizeClass(["strudel-flow-radial__category nodrag",{"strudel-flow-radial__category--active":i.value===C}]),style:e.normalizeStyle(O(h.value[C]??{x:a,y:a})),"aria-label":N.label,"aria-expanded":i.value===C,onClick:P=>i.value=C,onFocus:P=>m.value=`category-${C}`,onBlur:F[2]||(F[2]=P=>m.value=null)},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(N.icon),{class:"strudel-flow-radial__icon","aria-hidden":"true"})),e.createElementVNode("span",null,e.toDisplayString(N.label),1)],46,wf))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(((D=f.value)==null?void 0:D.items)??[],(N,C)=>(e.openBlock(),e.createElementBlock("button",{key:N.kind,type:"button",class:"strudel-flow-radial__item nodrag",style:e.normalizeStyle(O(k.value[C]??{x:a,y:a})),"aria-label":`Add ${N.title} node`,onClick:P=>y(N.kind),onFocus:P=>m.value=`item-${C}`,onBlur:F[3]||(F[3]=P=>m.value=null)},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(r[N.kind]),{class:"strudel-flow-radial__icon","aria-hidden":"true"})),e.createElementVNode("span",null,e.toDisplayString(N.title),1)],44,Lf))),128)),e.createElementVNode("button",{type:"button",class:"strudel-flow-radial__close nodrag","aria-label":"Close menu",title:"Close menu",onClick:A},[e.createVNode(e.unref(L.X),{"aria-hidden":"true"})])])])):(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"strudel-flow-radial__trigger nodrag","aria-label":"Add node",title:"Add node",onClick:e.withModifiers(V,["stop"])},[e.createVNode(e.unref(L.Plus),{"aria-hidden":"true"})]))}}}),$f={class:"strudel-flow-toolbar nodrag",role:"group","aria-label":"Tempo"},Bf={class:"strudel-flow-toolbar__field"},Rf=["min","max","value"],Of={class:"strudel-flow-toolbar__field"},Nf={class:"strudel-flow-toolbar__cycle"},Af=["value"],Cf=["value"],Df=e.defineComponent({__name:"StrudelFlowToolbar",props:{beatsPerMinute:{},beatsPerCycle:{}},emits:["update:beatsPerMinute","update:beatsPerCycle"],setup(t,{emit:n}){const l=t,o=n,a=e.ref(String(l.beatsPerMinute));e.watch(()=>l.beatsPerMinute,i=>{a.value=String(i)});const s=()=>{const i=Number(a.value);if(a.value.trim().length===0||!Number.isFinite(i)){a.value=String(l.beatsPerMinute);return}const m=se(i);a.value=String(m),m!==l.beatsPerMinute&&o("update:beatsPerMinute",m)},r=i=>{i.target instanceof HTMLInputElement&&(a.value=i.target.value)},c=i=>{i.target instanceof HTMLSelectElement&&o("update:beatsPerCycle",Number(i.target.value))};return(i,m)=>(e.openBlock(),e.createElementBlock("div",$f,[e.createElementVNode("label",Bf,[e.createElementVNode("input",{class:"strudel-flow-toolbar__tempo",type:"number",inputmode:"numeric",min:e.unref(je),max:e.unref(Fe),value:a.value,"aria-label":"Beats per minute",onInput:r,onBlur:s,onKeydown:e.withKeys(s,["enter"])},null,40,Rf),m[0]||(m[0]=e.createElementVNode("span",{class:"strudel-flow-toolbar__unit"},"BPM",-1))]),e.createElementVNode("label",Of,[e.createElementVNode("span",Nf,[e.createElementVNode("select",{value:String(t.beatsPerCycle),"aria-label":"Beats per cycle",onChange:c},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(Lt),_=>(e.openBlock(),e.createElementBlock("option",{key:_.value,value:_.value},e.toDisplayString(_.label),9,Cf))),128))],40,Af),e.createVNode(e.unref(L.ChevronDown),{"aria-hidden":"true"})]),m[1]||(m[1]=e.createElementVNode("span",{class:"strudel-flow-toolbar__unit"},"B/C",-1))])]))}}),Tt=t=>Y(t.data.kind),rs=t=>"muted"in t.data&&t.data.muted===!0,Mf=(t,n)=>n.flatMap(l=>l.source===t?[l.target]:l.target===t?[l.source]:[]),cs=(t,n,l=[])=>l.includes(t)?l:Mf(t,n).reduce((o,a)=>cs(a,n,o),[...l,t]),is=(t,n,l)=>{const o=t.find(s=>s.id===l);if(o===void 0)return[];if(Tt(o))return[l];const a=cs(l,n);return t.filter(s=>Tt(s)&&a.includes(s.id)).map(({id:s})=>s)},ds=(t,n,l)=>{const o=is(t,n,l),a=t.filter(Tt);return o.length>0&&a.length>o.length&&a.every(s=>o.includes(s.id)!==rs(s))},Pf=(t,n,l)=>{const o=is(t,n,l),a=ds(t,n,l);return t.filter(Tt).map(s=>({node:s,muted:a?!1:!o.includes(s.id)})).filter(({node:s,muted:r})=>rs(s)!==r).map(({node:s,muted:r})=>({nodeId:s.id,muted:r}))},Uf={class:"strudel-flow-credit"},If=["href"],Vf=["href"],Wf=e.defineComponent({__name:"StrudelFlowEditor",props:{nodes:{},edges:{},beatsPerMinute:{},beatsPerCycle:{},sampleGroups:{},voiceGroups:{},noteReader:{type:Function},previewSound:{type:Function},playingNodeIds:{}},emits:["update:nodes","update:edges","connect","update-node","remove-node","show-code","add-node","update:beatsPerMinute","update:beatsPerCycle"],setup(t,{emit:n}){const l=t,o=n,a={type:"strudel"},s=e.ref(null);e.provide(Ba,s),e.provide(Ra,y=>{var w;return(w=l.previewSound)==null?void 0:w.call(l,y)}),e.provide(ls,e.computed(()=>yo(l.nodes,l.edges))),e.provide(In,e.computed(()=>({readNoteBars:l.noteReader??null,beatsPerCycle:l.beatsPerCycle,soundOf:y=>da(y,l.nodes,l.edges)})));const r=e.ref(null),c=e.shallowRef(null),i=e.ref(!1),m=["Backspace","Delete"];e.watch(()=>l.nodes.length,(y,w)=>{y<=w||(i.value=!0,e.nextTick(()=>{var b;return(b=c.value)==null?void 0:b.fitView({padding:.2})}))});const _=y=>{c.value=y},f=()=>{var F;const y=((F=c.value)==null?void 0:F.getNodes.value)??[],w=dc(y);w.some((B,D)=>{var N,C;return B.position.x!==((N=y[D])==null?void 0:N.position.x)||B.position.y!==((C=y[D])==null?void 0:C.position.y)})&&o("update:nodes",w)},g=e.computed(()=>{var y;return(((y=c.value)==null?void 0:y.getNodes.value)??[]).map(w=>`${w.dimensions.width}x${w.dimensions.height}`).join()});e.watch(g,()=>e.nextTick(f));const h=()=>{var y;f(),i.value&&(i.value=!1,(y=c.value)==null||y.fitView({padding:.2}))},k=y=>Bo(y,l.nodes,l.edges),E=y=>{k(y)&&o("connect",y.source,y.target)},p=y=>{o("update:nodes",y)},u=y=>{o("update:edges",y)},S=(y,w)=>{o("update-node",y,w)},T=y=>{Pf(l.nodes,l.edges,y).forEach(w=>{const b=l.nodes.find(F=>F.id===w.nodeId);b!==void 0&&o("update-node",w.nodeId,{...b.data,muted:w.muted})})},O=y=>{o("remove-node",y)},V=y=>{o("add-node",y)},A=()=>{var y;(y=r.value)==null||y.open()};return(y,w)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"shell",ref:s,class:"strudel-flow-editor-shell",onContextmenu:e.withModifiers(A,["prevent"])},[e.createVNode(e.unref(j.VueFlow),{class:"strudel-flow-editor",nodes:t.nodes,edges:t.edges,"default-edge-options":a,"delete-key-code":m,"edges-updatable":!1,"fit-view-on-init":!0,"connect-on-click":!0,"is-valid-connection":k,"min-zoom":.2,"max-zoom":2,"onUpdate:nodes":p,"onUpdate:edges":u,onConnect:E,onPaneReady:_,onNodesInitialized:h},{"node-strudel":e.withCtx(b=>{var F;return[e.createVNode(os,{id:b.id,data:b.data,selected:b.selected,"sample-groups":t.sampleGroups??[],"voice-groups":t.voiceGroups??[],"is-soloed":e.unref(ds)(t.nodes,t.edges,b.id),"is-playing":((F=t.playingNodeIds)==null?void 0:F.includes(b.id))??!1,onUpdate:B=>S(b.id,B),onSolo:T,onRemove:O,onShowCode:w[0]||(w[0]=B=>o("show-code",B))},null,8,["id","data","selected","sample-groups","voice-groups","is-soloed","is-playing","onUpdate"])]}),"edge-strudel":e.withCtx(b=>[e.createVNode(Md,e.normalizeProps(e.guardReactiveProps(b)),null,16)]),default:e.withCtx(()=>[e.createVNode(e.unref(_s.Controls))]),_:1},8,["nodes","edges"]),e.createVNode(Df,{"beats-per-minute":t.beatsPerMinute,"beats-per-cycle":t.beatsPerCycle,"onUpdate:beatsPerMinute":w[1]||(w[1]=b=>o("update:beatsPerMinute",b)),"onUpdate:beatsPerCycle":w[2]||(w[2]=b=>o("update:beatsPerCycle",b))},null,8,["beats-per-minute","beats-per-cycle"]),e.createVNode(ss,{ref_key:"radialMenu",ref:r,onAdd:V},null,512),e.createElementVNode("p",Uf,[w[3]||(w[3]=e.createTextVNode(" After ",-1)),e.createElementVNode("a",{href:e.unref(Le).url,target:"_blank",rel:"noopener"},e.toDisplayString(e.unref(Le).name),9,If),w[4]||(w[4]=e.createTextVNode(" by ",-1)),e.createElementVNode("a",{href:e.unref(Le).authorUrl,target:"_blank",rel:"noopener"},e.toDisplayString(e.unref(Le).author),9,Vf)])],544))}});d.MAJOR_SCALE=Zt,d.MINOR_SCALE=Jt,d.STRUDEL_FLOW_ARRANGE_DEFAULTS=at,d.STRUDEL_FLOW_BACKGROUND_CANVAS_ID=Zn,d.STRUDEL_FLOW_BEATS_PER_CYCLE_OPTIONS=Lt,d.STRUDEL_FLOW_BLACK_KEY_CLASSES=El,d.STRUDEL_FLOW_CALL_PARAMETERS=Jn,d.STRUDEL_FLOW_CHORDS_DEFAULTS=fe,d.STRUDEL_FLOW_CHORD_FRET_SPAN=el,d.STRUDEL_FLOW_CHORD_PRESETS=Zl,d.STRUDEL_FLOW_CHORD_SCALE_OPTIONS=Ze,d.STRUDEL_FLOW_CODE_DEFAULTS=ot,d.STRUDEL_FLOW_DEFAULT_BEATS_PER_CYCLE=ee,d.STRUDEL_FLOW_DEFAULT_BEATS_PER_MINUTE=ye,d.STRUDEL_FLOW_DEFAULT_BEATS_STEPS=Bt,d.STRUDEL_FLOW_DEFAULT_OCTAVE=wl,d.STRUDEL_FLOW_DELAY_DEFAULTS=Ue,d.STRUDEL_FLOW_DRUM_ROWS=Yn,d.STRUDEL_FLOW_DRUM_SOUND_GROUPS=Ot,d.STRUDEL_FLOW_EDITOR_MODE_OPTIONS=fs,d.STRUDEL_FLOW_EFFECT_DEFAULTS=rn,d.STRUDEL_FLOW_ENVELOPE_DEFAULTS=Ee,d.STRUDEL_FLOW_FILTER_DEFAULTS=st,d.STRUDEL_FLOW_GAIN_DEFAULTS=cn,d.STRUDEL_FLOW_KEY_OPTIONS=ie,d.STRUDEL_FLOW_LEVEL_DEFAULTS=rt,d.STRUDEL_FLOW_MASK_DEFAULTS=dn,d.STRUDEL_FLOW_MAX_ARRANGE_CYCLES=Ft,d.STRUDEL_FLOW_MAX_ARRANGE_PARTS=$t,d.STRUDEL_FLOW_MAX_BEATS_PER_MINUTE=Fe,d.STRUDEL_FLOW_MAX_DRUM_ROWS=Oe,d.STRUDEL_FLOW_MAX_FILTER_CUTOFF=Hn,d.STRUDEL_FLOW_MAX_FILTER_RESONANCE=Xn,d.STRUDEL_FLOW_MAX_FRET=vn,d.STRUDEL_FLOW_MAX_LENGTH_DENOMINATOR=yl,d.STRUDEL_FLOW_MAX_NODE_COORDINATE=$e,d.STRUDEL_FLOW_MAX_NOTE_GRID_BARS=Kn,d.STRUDEL_FLOW_MAX_ROOM_SIZE=zn,d.STRUDEL_FLOW_MIN_BEATS_PER_MINUTE=je,d.STRUDEL_FLOW_MIN_FILTER_CUTOFF=Gn,d.STRUDEL_FLOW_MIN_FILTER_RESONANCE=xn,d.STRUDEL_FLOW_NEW_DRUM_SOUNDS=Rt,d.STRUDEL_FLOW_NODE_COLUMNS=Wn,d.STRUDEL_FLOW_NODE_COLUMN_GAP=Vn,d.STRUDEL_FLOW_NODE_DEFINITIONS=ct,d.STRUDEL_FLOW_NODE_ROW_GAP=ps,d.STRUDEL_FLOW_NODE_START_X=ce,d.STRUDEL_FLOW_NODE_START_Y=qe,d.STRUDEL_FLOW_NOTATION_BY_SOUND=tl,d.STRUDEL_FLOW_NOTATION_OPTIONS=Ne,d.STRUDEL_FLOW_NOTES_DEFAULTS=on,d.STRUDEL_FLOW_NOTE_GRID_STEPS_PER_BEAT=Je,d.STRUDEL_FLOW_NOTE_LETTERS=zt,d.STRUDEL_FLOW_OPEN_STRINGS=Qn,d.STRUDEL_FLOW_OTHER_SAMPLE_FAMILY=Cn,d.STRUDEL_FLOW_PAD_DEFAULTS=oe,d.STRUDEL_FLOW_PAD_MODIFIER_OPTIONS=Re,d.STRUDEL_FLOW_PAD_NOTE_COUNT=Ye,d.STRUDEL_FLOW_PAD_STEP_COUNT=Ke,d.STRUDEL_FLOW_PATCH_STORAGE_KEY=wt,d.STRUDEL_FLOW_PIANO_ROLL_BEAT_WIDTH=Ut,d.STRUDEL_FLOW_PIANO_ROLL_GUTTER=pl,d.STRUDEL_FLOW_PIANO_ROLL_MIN_ROWS=fl,d.STRUDEL_FLOW_PIANO_ROLL_ROW_HEIGHT=me,d.STRUDEL_FLOW_PITCH_CLASSES=Tl,d.STRUDEL_FLOW_REFERENCE=Le,d.STRUDEL_FLOW_SAMPLES_DEFAULTS=an,d.STRUDEL_FLOW_SAMPLE_FAMILIES=qt,d.STRUDEL_FLOW_SAMPLE_MODIFIER_KINDS=Kl,d.STRUDEL_FLOW_SAMPLE_MODIFIER_OPTIONS=Yt,d.STRUDEL_FLOW_SCALE_OPTIONS=de,d.STRUDEL_FLOW_SHARP_SIGNS=Ll,d.STRUDEL_FLOW_SHARP_SPELLINGS=Fl,d.STRUDEL_FLOW_SHEET_ACCIDENTAL_GLYPHS=Ol,d.STRUDEL_FLOW_SHEET_ACCIDENTAL_OFFSET=Hl,d.STRUDEL_FLOW_SHEET_ACCIDENTAL_SPACE=Ul,d.STRUDEL_FLOW_SHEET_BOTTOM_MARGIN=Cl,d.STRUDEL_FLOW_SHEET_BOTTOM_STEPS=$l,d.STRUDEL_FLOW_SHEET_BRACKET_RISE=zl,d.STRUDEL_FLOW_SHEET_CLEF_GLYPHS=Rl,d.STRUDEL_FLOW_SHEET_CLEF_SPACE=Ml,d.STRUDEL_FLOW_SHEET_COLUMN_SPACE=et,d.STRUDEL_FLOW_SHEET_DOT_FACTOR=Bl,d.STRUDEL_FLOW_SHEET_DOT_OFFSET=xl,d.STRUDEL_FLOW_SHEET_FLAG_STEP=Gl,d.STRUDEL_FLOW_SHEET_HEAD_RADIUS_X=jt,d.STRUDEL_FLOW_SHEET_HEAD_RADIUS_Y=Vl,d.STRUDEL_FLOW_SHEET_LEDGER_HALF_WIDTH=Kt,d.STRUDEL_FLOW_SHEET_LINE_GAP=Nl,d.STRUDEL_FLOW_SHEET_MIN_BAR_WIDTH=Il,d.STRUDEL_FLOW_SHEET_SPACE_PER_BEAT=Pl,d.STRUDEL_FLOW_SHEET_STAFF_DISTANCE=Dl,d.STRUDEL_FLOW_SHEET_STEM_LENGTH=Wl,d.STRUDEL_FLOW_SHEET_STROKE_WIDTH=jl,d.STRUDEL_FLOW_SHEET_TIE_OFFSET=tt,d.STRUDEL_FLOW_SHEET_TIE_SAG=Xl,d.STRUDEL_FLOW_SHEET_TOP_MARGIN=Al,d.STRUDEL_FLOW_SHEET_TREBLE_LOWEST_NOTE=ve,d.STRUDEL_FLOW_SHEET_VALUES=ue,d.STRUDEL_FLOW_SLOW_DEFAULTS=un,d.STRUDEL_FLOW_SOUND_OPTIONS=yt,d.STRUDEL_FLOW_SPACE_DEFAULTS=ae,d.STRUDEL_FLOW_STEP_COUNT=z,d.STRUDEL_FLOW_STRUCT_DEFAULTS=mn,d.STRUDEL_FLOW_TAB_BEAM_BEATS=Ae,d.STRUDEL_FLOW_TAB_BEAM_STEP=sl,d.STRUDEL_FLOW_TAB_BEAM_THICKNESS=At,d.STRUDEL_FLOW_TAB_BOTTOM_MARGIN=Es,d.STRUDEL_FLOW_TAB_BOTTOM_SPACE=bl,d.STRUDEL_FLOW_TAB_BRACKET_HOOK=Ht,d.STRUDEL_FLOW_TAB_BRACKET_LABEL_BASELINE=Xt,d.STRUDEL_FLOW_TAB_BRACKET_LABEL_GAP=Gt,d.STRUDEL_FLOW_TAB_BRACKET_LABEL_SIZE=xt,d.STRUDEL_FLOW_TAB_BRACKET_OVERHANG=Ce,d.STRUDEL_FLOW_TAB_BRACKET_Y=cl,d.STRUDEL_FLOW_TAB_DIGIT_BASELINE=kl,d.STRUDEL_FLOW_TAB_DIGIT_CLEARANCE=il,d.STRUDEL_FLOW_TAB_DIGIT_PITCH=Dt,d.STRUDEL_FLOW_TAB_DIGIT_SIZE=Sl,d.STRUDEL_FLOW_TAB_DIGIT_WIDTH=Ct,d.STRUDEL_FLOW_TAB_FLAG_LENGTH=rl,d.STRUDEL_FLOW_TAB_LINE_GAP=nl,d.STRUDEL_FLOW_TAB_MIN_BAR_WIDTH=It,d.STRUDEL_FLOW_TAB_REST_HEIGHT=Wt,d.STRUDEL_FLOW_TAB_REST_WIDTH=Vt,d.STRUDEL_FLOW_TAB_SIDE_MARGIN=Nt,d.STRUDEL_FLOW_TAB_SPACE_PER_BEAT=_l,d.STRUDEL_FLOW_TAB_STEM_BOTTOM=al,d.STRUDEL_FLOW_TAB_STEM_SPACE=Qe,d.STRUDEL_FLOW_TAB_STEM_TOP=ol,d.STRUDEL_FLOW_TAB_STEM_WIDTH=gl,d.STRUDEL_FLOW_TAB_STROKE_WIDTH=hl,d.STRUDEL_FLOW_TAB_TIE_END_GAP=ul,d.STRUDEL_FLOW_TAB_TIE_SAG=ml,d.STRUDEL_FLOW_TAB_TIE_TOP=dl,d.STRUDEL_FLOW_TAB_TOP_MARGIN=ll,d.STRUDEL_FLOW_TAB_TRIPLET_DENOMINATOR=Pt,d.STRUDEL_FLOW_TAB_TRIPLET_NUMERATOR=Mt,d.STRUDEL_FLOW_VISUALIZER_DEFAULTS=_n,d.STRUDEL_FLOW_VISUAL_OPTIONS=Be,d.STRUDEL_FLOW_VISUAL_PLACEMENT_OPTIONS=jn,d.STRUDEL_FLOW_VOICE_DEFAULTS=sn,d.STRUDEL_FLOW_VOICING_DEFAULTS=mo,d.STRUDEL_FLOW_WIDGET_ID_PREFIX=qn,d.StrudelFlowAccordion=St,d.StrudelFlowArrangeControls=Ua,d.StrudelFlowBeatsControls=Aa,d.StrudelFlowChordEditor=Ma,d.StrudelFlowChordsControls=Pa,d.StrudelFlowCodeControls=Ia,d.StrudelFlowDelayControls=Va,d.StrudelFlowEditor=Wf,d.StrudelFlowEnvelopeControls=Ga,d.StrudelFlowFilterControls=Ha,d.StrudelFlowKnob=H,d.StrudelFlowLevelControls=xa,d.StrudelFlowNode=os,d.StrudelFlowNotation=Qa,d.StrudelFlowNoteNames=Ka,d.StrudelFlowPadControls=Xa,d.StrudelFlowPianoRoll=Ya,d.StrudelFlowRadialMenu=ss,d.StrudelFlowSelect=Q,d.StrudelFlowSheet=qa,d.StrudelFlowSpaceControls=ts,d.StrudelFlowStepper=v,d.StrudelFlowTabStaff=Ja,d.StrudelFlowVisualizerControls=va,d.StrudelFlowVoiceControls=ns,d.appendStrudelFlowBlocks=Fi,d.canConnectStrudelFlowNodes=dt,d.canUseStrudelFlowConnection=Bo,d.compileStrudelFlow=Lo,d.copyStrudelFlowChord=Ts,d.createDefaultDrumRows=pn,d.createDefaultPadGrid=lt,d.createDefaultStrudelFlowPatch=gn,d.createStrudelFlowDrumRow=he,d.createStrudelFlowNodeData=ge,d.findStrudelFlowNodeCode=Ad,d.findStrudelFlowNotesSound=da,d.findStrudelFlowPlayingNodeIds=Dd,d.findStrudelFlowSampleFamily=Dn,d.formatStrudelFlowBeats=la,d.formatStrudelFlowKnobValue=so,d.formatStrudelFlowMidiNote=oa,d.formatStrudelFlowNumber=G,d.generateStrudelFlowNodePattern=Pe,d.getStrudelFlowChordLabels=Jl,d.getStrudelFlowChordNotes=nt,d.getStrudelFlowChordProgression=Qt,d.getStrudelFlowCodeOrder=Fo,d.getStrudelFlowNodeCodeRanges=Fa,d.getStrudelFlowNodeDefinition=fn,d.getStrudelFlowVisualizerWidgetIds=yo,d.isStoredRecord=q,d.isStrudelFlowEffectKind=kr,d.isStrudelFlowInstrumentKind=Y,d.isStrudelFlowNodeKind=_o,d.layoutStrudelFlowSheet=Ta,d.layoutStrudelFlowTab=Ea,d.normalizeStrudelFlowBeatsPerCycle=Ve,d.normalizeStrudelFlowBeatsPerMinute=se,d.parseStrudelFlowCode=ea,d.parseStrudelFlowPatch=Ro,d.parseStrudelFlowSampleLayers=Nn,d.pickStrudelFlowNotation=$n,d.placeStrudelFlowFrets=ra,d.readStorage=Yl,d.readStoredChoice=_e,d.readStoredNumber=W,d.readStoredString=x,d.readStrudelFlowCallFields=nn,d.readStrudelFlowMidiNote=ne,d.readStrudelFlowNodeData=po,d.readStrudelFlowSpelledNote=Et,d.resolveStrudelFlowNotation=ca,d.useStrudelFlow=Ri,d.writeStorage=ql,d.writeStrudelFlowCallFields=ln,d.writeStrudelFlowSampleLayers=An,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
@@ -0,0 +1,30 @@
1
+ import type { StrudelFlowNode, StrudelFlowNodeKind, StrudelFlowNodePosition, StrudelFlowNodeSize as NodeSize } from './types';
2
+ /**
3
+ * The size a node of this kind is laid out with before the canvas has measured it.
4
+ * @param kind - the node kind
5
+ * @returns its expected width and height
6
+ */
7
+ export declare const getStrudelFlowNodeSize: (kind: StrudelFlowNodeKind) => NodeSize;
8
+ /**
9
+ * Whether two nodes would be drawn on top of each other or closer than the canvas gap.
10
+ * @param left - one node, at its position and measured or expected size
11
+ * @param right - the other node
12
+ * @returns true when their boxes, padded by the gap, intersect
13
+ */
14
+ export declare const doStrudelFlowNodesOverlap: (left: StrudelFlowNode, right: StrudelFlowNode) => boolean;
15
+ /**
16
+ * Finds the first free slot for a new node on the two-column canvas. Existing nodes keep
17
+ * their positions, so adding a node near a tall pad or accordion never hides it underneath.
18
+ * @param nodes - nodes already on the canvas
19
+ * @param kind - the node that is about to be added
20
+ * @returns a position that does not overlap any existing node
21
+ */
22
+ export declare const findStrudelFlowNodePosition: (nodes: StrudelFlowNode[], kind: StrudelFlowNodeKind) => StrudelFlowNodePosition;
23
+ /**
24
+ * Moves overlapping nodes apart using the sizes the canvas measured. The layout only knows a
25
+ * node's expected size, and one with an open accordion or a long pattern renders larger, so
26
+ * the node next to it would otherwise be drawn underneath.
27
+ * @param nodes - nodes with their measured dimensions
28
+ * @returns the nodes, each moved clear of whatever it overlapped, in the same order
29
+ */
30
+ export declare const separateStrudelFlowNodes: (nodes: StrudelFlowNode[]) => StrudelFlowNode[];
@@ -0,0 +1,36 @@
1
+ import type { StrudelFlowCodeRange, StrudelFlowEdge, StrudelFlowNode, StrudelFlowNodeCodeRange } from './types';
2
+ /**
3
+ * Finds the code every node writes in the program: for each node, the calls of its kind that
4
+ * follow the nodes of the same kind before it in code order, one per sounding Beats row.
5
+ * ponytail: matched by call name and position, not by parsing; a helper in the setup that makes
6
+ * the same call shifts the count. Track source offsets in the parser if that ever matters.
7
+ * @param code - the program in the code editor
8
+ * @param nodes - the patch's nodes
9
+ * @param edges - the patch's cables
10
+ * @returns the ranges of every node's calls, in code order of the nodes
11
+ */
12
+ export declare const getStrudelFlowNodeCodeRanges: (code: string, nodes: StrudelFlowNode[], edges: StrudelFlowEdge[]) => StrudelFlowNodeCodeRange[];
13
+ /**
14
+ * Finds the code a node writes in the program.
15
+ * @param code - the program in the code editor
16
+ * @param nodes - the patch's nodes
17
+ * @param edges - the patch's cables
18
+ * @param nodeId - the node to find
19
+ * @returns the range of the node's first call, or null when the code has no such call
20
+ */
21
+ export declare const findStrudelFlowNodeCode: (code: string, nodes: StrudelFlowNode[], edges: StrudelFlowEdge[], nodeId: string) => StrudelFlowCodeRange | null;
22
+ /**
23
+ * Finds the instruments a sounding note came from. A note carries a location for each piece of
24
+ * mini-notation it was built from, in no reliable order, and a note held in a setup variable has
25
+ * none in any node. Each offset is mapped to its node (the narrowest range wins); the leftmost
26
+ * instrument among them owns the note, else the instruments upstream of the owners do, when
27
+ * there is exactly one.
28
+ * ponytail: a note whose mini-notation lives in a setup variable and passes through a shared
29
+ * effect lights nothing; give the parser source offsets for setup variables to light it.
30
+ * @param ranges - every node's code ranges
31
+ * @param offsetsPerHap - for each sounding note, the character offsets of its locations
32
+ * @param nodes - the patch's nodes
33
+ * @param edges - the patch's cables
34
+ * @returns the id of the instrument each note came from, once each
35
+ */
36
+ export declare const findStrudelFlowPlayingNodeIds: (ranges: StrudelFlowNodeCodeRange[], offsetsPerHap: number[][], nodes: StrudelFlowNode[], edges: StrudelFlowEdge[]) => string[];