text: import{Faceplate as t,Bang as e,Patch as s,Knob as n,Switch as _}from"/js/core.js";function o(t,e,s){const n=t.slice();return n[9]=e[s],n[11]=s,n}function l(t,e,s){const n=t.slice();return n[12]=e[s],n[14]=s,n}function r(t,e,s){const n=t.slice();return n[15]=e[s],n[16]=e,n[17]=s,n}function i(t,e,s){const n=t.slice();return n[18]=e[s],n[19]=e,n[17]=s,n}function a(t,e,s){const n=t.slice();return n[20]=e[s],n[22]=s,n}function c(t){let e,s,n,_=t[22]+1+"";return{c(){e=__sv.element("div"),s=__sv.text("rhythm "),n=__sv.text(_),__sv.attr(e,"class","division-heading svelte-wfswc5"),__sv.set_style(e,"left",64*t[22]+"px"),__sv.set_style(e,"top","24px")},m(t,_){__sv.insert(t,e,_),__sv.append(e,s),__sv.append(e,n)},p:__sv.noop,d(t){t&&__sv.detach(e)}}}function v(t){let e,s,_;function o(e){t[5](e,t[18],t[19],t[17])}let l={size:"s",x:64*t[17],y:48,min:1,max:16,precision:0,label:t[18]};return void 0!==t[18]&&(l.value=t[18]),e=new n({props:l}),__sv.binding_callbacks.push((()=>__sv.bind(e,"value",o))),{c(){__sv.create_component(e.$$.fragment)},m(t,s){__sv.mount_component(e,t,s),_=!0},p(n,_){t=n;const o={};1&_&&(o.label=t[18]),!s&&1&_&&(s=!0,o.value=t[18],__sv.add_flush_callback((()=>s=!1))),e.$set(o)},i(t){_||(__sv.transition_in(e.$$.fragment,t),_=!0)},o(t){__sv.transition_out(e.$$.fragment,t),_=!1},d(t){__sv.destroy_component(e,t)}}}function f(t){let e,s,_;function o(e){t[6](e,t[15],t[16],t[17])}let l={size:"s",x:64*t[17],y:56,min:0,max:15,precision:0,label:t[15]?t[15]:"0"};return void 0!==t[15]&&(l.value=t[15]),e=new n({props:l}),__sv.binding_callbacks.push((()=>__sv.bind(e,"value",o))),{c(){__sv.create_component(e.$$.fragment)},m(t,s){__sv.mount_component(e,t,s),_=!0},p(n,_){t=n;const o={};1&_&&(o.label=t[15]?t[15]:"0"),!s&&1&_&&(s=!0,o.value=t[15],__sv.add_flush_callback((()=>s=!1))),e.$set(o)},i(t){_||(__sv.transition_in(e.$$.fragment,t),_=!0)},o(t){__sv.transition_out(e.$$.fragment,t),_=!1},d(t){__sv.destroy_component(e,t)}}}function p(t){let e,s;return e=new _({props:{x:8+64*t[14],y:24+48*t[11],value:1===t[12],square:!0,onToggle:function(){return t[7](t[11],t[14])}}}),{c(){__sv.create_component(e.$$.fragment)},m(t,n){__sv.mount_component(e,t,n),s=!0},p(s,n){t=s;const _={};1&n&&(_.value=1===t[12]),e.$set(_)},i(t){s||(__sv.transition_in(e.$$.fragment,t),s=!0)},o(t){__sv.transition_out(e.$$.fragment,t),s=!1},d(t){__sv.destroy_component(e,t)}}}function u(t){let e,n,_,o=t[9],r=[];for(let e=0;e<o.length;e+=1)r[e]=p(l(t,o,e));const i=t=>__sv.transition_out(r[t],1,1,(()=>{r[t]=null}));return n=new s({props:{label:"gate "+(t[11]+1),x:64*d,y:24+48*t[11],name:"out-gate-"+t[11],output:t[1][t[11]]}}),{c(){for(let t=0;t<r.length;t+=1)r[t].c();e=__sv.space(),__sv.create_component(n.$$.fragment)},m(t,s){for(let e=0;e<r.length;e+=1)r[e].m(t,s);__sv.insert(t,e,s),__sv.mount_component(n,t,s),_=!0},p(t,s){if(17&s){let n;for(o=t[9],n=0;n<o.length;n+=1){const _=l(t,o,n);r[n]?(r[n].p(_,s),__sv.transition_in(r[n],1)):(r[n]=p(_),r[n].c(),__sv.transition_in(r[n],1),r[n].m(e.parentNode,e))}for(__sv.group_outros(),n=o.length;n<r.length;n+=1)i(n);__sv.check_outros()}},i(t){if(!_){for(let t=0;t<o.length;t+=1)__sv.transition_in(r[t]);__sv.transition_in(n.$$.fragment,t),_=!0}},o(t){r=r.filter(Boolean);for(let t=0;t<r.length;t+=1)__sv.transition_out(r[t]);__sv.transition_out(n.$$.fragment,t),_=!1},d(t){__sv.destroy_each(r,t),t&&__sv.detach(e),__sv.destroy_component(n,t)}}}function m(t){let e,n,_,l,p,m,g,h,$,w,y,x,b,k,q,T=Array(d).fill(0),A=[];for(let e=0;e<T.length;e+=1)A[e]=c(a(t,T,e));let B=t[0].dividers,z=[];for(let e=0;e<B.length;e+=1)z[e]=v(i(t,B,e));const C=t=>__sv.transition_out(z[t],1,1,(()=>{z[t]=null}));let j=t[0].offsets,E=[];for(let e=0;e<j.length;e+=1)E[e]=f(r(t,j,e));const H=t=>__sv.transition_out(E[t],1,1,(()=>{E[t]=null}));let R=t[0].seqToggles,Y=[];for(let e=0;e<R.length;e+=1)Y[e]=u(o(t,R,e));const D=t=>__sv.transition_out(Y[t],1,1,(()=>{Y[t]=null}));return x=new s({props:{label:"clock",x:80,y:330,name:"clock",input:t[2]}}),k=new s({props:{label:"reset",x:200,y:330,name:"reset",input:t[3]}}),{c(){e=__sv.element("dividers");for(let t=0;t<A.length;t+=1)A[t].c();n=__sv.space();for(let t=0;t<z.length;t+=1)z[t].c();_=__sv.space(),l=__sv.element("div"),l.textContent="divider",p=__sv.space(),m=__sv.element("offsets");for(let t=0;t<E.length;t+=1)E[t].c();g=__sv.space(),h=__sv.element("div"),h.textContent="offset",$=__sv.space(),w=__sv.element("toggles");for(let t=0;t<Y.length;t+=1)Y[t].c();y=__sv.space(),__sv.create_component(x.$$.fragment),b=__sv.space(),__sv.create_component(k.$$.fragment),__sv.attr(l,"class","row-title svelte-wfswc5"),__sv.set_style(l,"top","52px"),__sv.set_style(e,"top","30px"),__sv.attr(e,"class","svelte-wfswc5"),__sv.attr(h,"class","row-title svelte-wfswc5"),__sv.set_style(h,"top","60px"),__sv.set_style(m,"top","90px"),__sv.attr(m,"class","svelte-wfswc5"),__sv.set_style(w,"top","190px"),__sv.attr(w,"class","svelte-wfswc5")},m(t,s){__sv.insert(t,e,s);for(let t=0;t<A.length;t+=1)A[t].m(e,null);__sv.append(e,n);for(let t=0;t<z.length;t+=1)z[t].m(e,null);__sv.append(e,_),__sv.append(e,l),__sv.insert(t,p,s),__sv.insert(t,m,s);for(let t=0;t<E.length;t+=1)E[t].m(m,null);__sv.append(m,g),__sv.append(m,h),__sv.insert(t,$,s),__sv.insert(t,w,s);for(let t=0;t<Y.length;t+=1)Y[t].m(w,null);__sv.insert(t,y,s),__sv.mount_component(x,t,s),__sv.insert(t,b,s),__sv.mount_component(k,t,s),q=!0},p(t,s){if(1&s){let n;for(B=t[0].dividers,n=0;n<B.length;n+=1){const o=i(t,B,n);z[n]?(z[n].p(o,s),__sv.transition_in(z[n],1)):(z[n]=v(o),z[n].c(),__sv.transition_in(z[n],1),z[n].m(e,_))}for(__sv.group_outros(),n=B.length;n<z.length;n+=1)C(n);__sv.check_outros()}if(1&s){let e;for(j=t[0].offsets,e=0;e<j.length;e+=1){const n=r(t,j,e);E[e]?(E[e].p(n,s),__sv.transition_in(E[e],1)):(E[e]=f(n),E[e].c(),__sv.transition_in(E[e],1),E[e].m(m,g))}for(__sv.group_outros(),e=j.length;e<E.length;e+=1)H(e);__sv.check_outros()}if(19&s){let e;for(R=t[0].seqToggles,e=0;e<R.length;e+=1){const n=o(t,R,e);Y[e]?(Y[e].p(n,s),__sv.transition_in(Y[e],1)):(Y[e]=u(n),Y[e].c(),__sv.transition_in(Y[e],1),Y[e].m(w,null))}for(__sv.group_outros(),e=R.length;e<Y.length;e+=1)D(e);__sv.check_outros()}},i(t){if(!q){for(let t=0;t<B.length;t+=1)__sv.transition_in(z[t]);for(let t=0;t<j.length;t+=1)__sv.transition_in(E[t]);for(let t=0;t<R.length;t+=1)__sv.transition_in(Y[t]);__sv.transition_in(x.$$.fragment,t),__sv.transition_in(k.$$.fragment,t),q=!0}},o(t){z=z.filter(Boolean);for(let t=0;t<z.length;t+=1)__sv.transition_out(z[t]);E=E.filter(Boolean);for(let t=0;t<E.length;t+=1)__sv.transition_out(E[t]);Y=Y.filter(Boolean);for(let t=0;t<Y.length;t+=1)__sv.transition_out(Y[t]);__sv.transition_out(x.$$.fragment,t),__sv.transition_out(k.$$.fragment,t),q=!1},d(t){t&&__sv.detach(e),__sv.destroy_each(A,t),__sv.destroy_each(z,t),t&&__sv.detach(p),t&&__sv.detach(m),__sv.destroy_each(E,t),t&&__sv.detach($),t&&__sv.detach(w),__sv.destroy_each(Y,t),t&&__sv.detach(y),__sv.destroy_component(x,t),t&&__sv.detach(b),__sv.destroy_component(k,t)}}}function g(e){let s,n;return s=new t({props:{title:"POLYRHYTHM",color:"#1D1E22",$$slots:{default:[m]},$$scope:{ctx:e}}}),{c(){__sv.create_component(s.$$.fragment)},m(t,e){__sv.mount_component(s,t,e),n=!0},p(t,[e]){const n={};8388609&e&&(n.$$scope={dirty:e,ctx:t}),s.$set(n)},i(t){n||(__sv.transition_in(s.$$.fragment,t),n=!0)},o(t){__sv.transition_out(s.$$.fragment,t),n=!1},d(t){__sv.destroy_component(s,t)}}}const d=4,h=2;function $(t,s,n){let{state:_={dividers:Array(d).fill(1),offsets:Array(d).fill(0),seqToggles:Array(h).fill(Array(d).fill(0))}}=s,o=0;const l=Array(h).fill(!0).map((()=>new e)),r=new e(((t,e,s)=>{const n=Array(h).fill(!1);for(let t=0;t<d;t++){let e=_.dividers[t];if((o+_.offsets[t])%e==0)for(let e=0;e<h;e++)1==_.seqToggles[e][t]&&(n[e]=!0)}for(let e=0;e<h;e++)n[e]&&l[e].bang(t,!0,!0);o++})),i=new e((()=>{o=0})),a=(t,e)=>{const s=[];for(let n=0;n<h;n++)s[n]=_.seqToggles[n].slice(0),n===t&&(s[n][e]=1===s[n][e]?0:1);n(0,_.seqToggles=s,_)};return t.$$set=t=>{"state"in t&&n(0,_=t.state)},[_,l,r,i,a,function(t,e,s,o){s[o]=t,n(0,_)},function(t,e,s,o){s[o]=t,n(0,_)},(t,e)=>a(t,e)]}class w extends __sv.SvelteComponent{constructor(t){var e;super(),document.getElementById("svelte-wfswc5-style")||((e=__sv.element("style")).id="svelte-wfswc5-style",e.textContent="dividers.svelte-wfswc5,offsets.svelte-wfswc5{position:absolute;left:20px;display:grid;grid-template-columns:repeat(4, 1fr);grid-template-rows:1fr;grid-column-gap:10px;width:calc(100% - 40px);margin-bottom:8px}toggles.svelte-wfswc5{position:absolute;left:22px;display:grid;grid-template-columns:repeat(4, 1fr);grid-template-rows:1fr;grid-column-gap:10px;width:calc(100% - 40px);height:20px;margin-bottom:8px}.division-heading.svelte-wfswc5{position:absolute;font-size:x-small}.row-title.svelte-wfswc5{position:absolute;left:250px;pointer-events:none;font-family:'Routed Gothic';font-size:11px;color:inherit;white-space:nowrap}",__sv.append(document.head,e)),__sv.init(this,t,$,g,__sv.safe_not_equal,{state:0})}}export default w;
  